Comparing version 1.0.4 to 1.1.0
@@ -90,3 +90,3 @@ import { WindowElev, OnEventTypes } from './elevio'; | ||
*/ | ||
on: <T extends Readonly<keyof OnEventTypes>>(elevioEvent: T, cb: OnEventTypes[T]) => void; | ||
on: <T extends "load" | "ready" | "widget:opened" | "widget:closed" | "module:opened" | "popup:opened" | "popup:closed" | "search:query" | "search:article:clicked" | "category:article:clicked" | "widget:article:view" | "helper:clicked">(elevioEvent: T, cb: OnEventTypes[T]) => void; | ||
/** Open the widget to the last page the user was on. */ | ||
@@ -93,0 +93,0 @@ open: () => void; |
export declare type Nullable<T> = { | ||
[P in keyof T]: T[P] | null; | ||
}; | ||
export declare type RenderType = 'elevioInline' | 'elevioArticle' | 'elevioModule'; | ||
export declare type OnEventTypes = { | ||
@@ -61,2 +62,14 @@ /** | ||
'widget:article:view': (articleId: string) => void; | ||
/** | ||
* Called when a helper is clicked. | ||
* The callback returns an object containing `actionId` (the article or module that the helper | ||
* opens), `type` ('elevioInline' for popup article, 'elevioArticle' for article that opens in | ||
* Assistant, 'elevioModule' for module that opens in Assistant) and `target` (the Element that the | ||
* helper is attached to). | ||
*/ | ||
'helper:clicked': (result: { | ||
actionId: string; | ||
type: RenderType; | ||
target: HTMLElement; | ||
}) => void; | ||
}; | ||
@@ -245,3 +258,3 @@ export declare type OnEventKey = keyof OnEventTypes; | ||
export declare type ElevioButtonOptions = { | ||
type: 'elevioInline' | 'elevioArticle' | 'elevioModule'; | ||
type: RenderType; | ||
/** | ||
@@ -248,0 +261,0 @@ * For types `elevioInline` and `elevioArticle` it is the ID of the article that should be opened. For type elevioModule it is the ID of the module that should be opened. |
@@ -1,2 +0,2 @@ | ||
import { Nullable, User, SettingsOptions, WindowElev } from './elevio'; | ||
import { Nullable, User, SettingsOptions, WindowElev, RenderType } from './elevio'; | ||
import * as React from 'react'; | ||
@@ -104,2 +104,14 @@ import Elevio from './client'; | ||
onWidgetArticleView?: (articleId: string) => void; | ||
/** | ||
* Called when a helper is clicked. | ||
* The callback returns an object containing `actionId` (the article or module that the helper | ||
* opens), `type` ('elevioInline' for popup article, 'elevioArticle' for article that opens in | ||
* Assistant, 'elevioModule' for module that opens in Assistant) and `target` (the Element that the | ||
* helper is attached to). | ||
*/ | ||
onHelperClicked?: (result: { | ||
actionId: string; | ||
type: RenderType; | ||
target: HTMLElement; | ||
}) => void; | ||
}; | ||
@@ -127,2 +139,3 @@ declare class ElevioReact extends React.Component<Props> { | ||
onWidgetArticleView: PropTypes.Requireable<(...args: any[]) => any>; | ||
onHelperClicked: PropTypes.Requireable<(...args: any[]) => any>; | ||
}; | ||
@@ -159,4 +172,9 @@ constructor(props: Props); | ||
onWidgetArticleView: (articleId: string) => void; | ||
onHelperClicked: (result: { | ||
actionId: string; | ||
type: RenderType; | ||
target: HTMLElement; | ||
}) => void; | ||
render(): null; | ||
} | ||
export default ElevioReact; |
@@ -5,8 +5,6 @@ var __extends = (this && this.__extends) || (function () { | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -73,2 +71,5 @@ function __() { this.constructor = d; } | ||
}; | ||
_this.onHelperClicked = function (result) { | ||
_this.props.onHelperClicked && _this.props.onHelperClicked(result); | ||
}; | ||
Elevio.on('ready', _this.onReady); | ||
@@ -84,2 +85,3 @@ Elevio.on('widget:opened', _this.onWidgetOpened); | ||
Elevio.on('widget:article:view', _this.onWidgetArticleView); | ||
Elevio.on('helper:clicked', _this.onHelperClicked); | ||
return _this; | ||
@@ -186,2 +188,3 @@ } | ||
onWidgetArticleView: PropTypes.func, | ||
onHelperClicked: PropTypes.func, | ||
}; | ||
@@ -188,0 +191,0 @@ return ElevioReact; |
@@ -90,3 +90,3 @@ import { WindowElev, OnEventTypes } from './elevio'; | ||
*/ | ||
on: <T extends Readonly<keyof OnEventTypes>>(elevioEvent: T, cb: OnEventTypes[T]) => void; | ||
on: <T extends "load" | "ready" | "widget:opened" | "widget:closed" | "module:opened" | "popup:opened" | "popup:closed" | "search:query" | "search:article:clicked" | "category:article:clicked" | "widget:article:view" | "helper:clicked">(elevioEvent: T, cb: OnEventTypes[T]) => void; | ||
/** Open the widget to the last page the user was on. */ | ||
@@ -93,0 +93,0 @@ open: () => void; |
export declare type Nullable<T> = { | ||
[P in keyof T]: T[P] | null; | ||
}; | ||
export declare type RenderType = 'elevioInline' | 'elevioArticle' | 'elevioModule'; | ||
export declare type OnEventTypes = { | ||
@@ -61,2 +62,14 @@ /** | ||
'widget:article:view': (articleId: string) => void; | ||
/** | ||
* Called when a helper is clicked. | ||
* The callback returns an object containing `actionId` (the article or module that the helper | ||
* opens), `type` ('elevioInline' for popup article, 'elevioArticle' for article that opens in | ||
* Assistant, 'elevioModule' for module that opens in Assistant) and `target` (the Element that the | ||
* helper is attached to). | ||
*/ | ||
'helper:clicked': (result: { | ||
actionId: string; | ||
type: RenderType; | ||
target: HTMLElement; | ||
}) => void; | ||
}; | ||
@@ -245,3 +258,3 @@ export declare type OnEventKey = keyof OnEventTypes; | ||
export declare type ElevioButtonOptions = { | ||
type: 'elevioInline' | 'elevioArticle' | 'elevioModule'; | ||
type: RenderType; | ||
/** | ||
@@ -248,0 +261,0 @@ * For types `elevioInline` and `elevioArticle` it is the ID of the article that should be opened. For type elevioModule it is the ID of the module that should be opened. |
@@ -1,2 +0,2 @@ | ||
import { Nullable, User, SettingsOptions, WindowElev } from './elevio'; | ||
import { Nullable, User, SettingsOptions, WindowElev, RenderType } from './elevio'; | ||
import * as React from 'react'; | ||
@@ -104,2 +104,14 @@ import Elevio from './client'; | ||
onWidgetArticleView?: (articleId: string) => void; | ||
/** | ||
* Called when a helper is clicked. | ||
* The callback returns an object containing `actionId` (the article or module that the helper | ||
* opens), `type` ('elevioInline' for popup article, 'elevioArticle' for article that opens in | ||
* Assistant, 'elevioModule' for module that opens in Assistant) and `target` (the Element that the | ||
* helper is attached to). | ||
*/ | ||
onHelperClicked?: (result: { | ||
actionId: string; | ||
type: RenderType; | ||
target: HTMLElement; | ||
}) => void; | ||
}; | ||
@@ -127,2 +139,3 @@ declare class ElevioReact extends React.Component<Props> { | ||
onWidgetArticleView: PropTypes.Requireable<(...args: any[]) => any>; | ||
onHelperClicked: PropTypes.Requireable<(...args: any[]) => any>; | ||
}; | ||
@@ -159,4 +172,9 @@ constructor(props: Props); | ||
onWidgetArticleView: (articleId: string) => void; | ||
onHelperClicked: (result: { | ||
actionId: string; | ||
type: RenderType; | ||
target: HTMLElement; | ||
}) => void; | ||
render(): null; | ||
} | ||
export default ElevioReact; |
@@ -6,8 +6,6 @@ "use strict"; | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -33,3 +31,3 @@ function __() { this.constructor = d; } | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
@@ -99,2 +97,5 @@ return result; | ||
}; | ||
_this.onHelperClicked = function (result) { | ||
_this.props.onHelperClicked && _this.props.onHelperClicked(result); | ||
}; | ||
client_1.default.on('ready', _this.onReady); | ||
@@ -110,2 +111,3 @@ client_1.default.on('widget:opened', _this.onWidgetOpened); | ||
client_1.default.on('widget:article:view', _this.onWidgetArticleView); | ||
client_1.default.on('helper:clicked', _this.onHelperClicked); | ||
return _this; | ||
@@ -212,2 +214,3 @@ } | ||
onWidgetArticleView: prop_types_1.default.func, | ||
onHelperClicked: prop_types_1.default.func, | ||
}; | ||
@@ -214,0 +217,0 @@ return ElevioReact; |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"devDependencies": { | ||
@@ -47,3 +47,3 @@ "@skypack/package-check": "^0.2.2", | ||
"ci": "start-server-and-test example-server 4000 cypress", | ||
"prepare": "npm run build" | ||
"prepublishOnly": "npm run build" | ||
}, | ||
@@ -50,0 +50,0 @@ "dependencies": { |
111810
2520