@telia-ace/knowledge-widget-adapters 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +6 -0
- package/README.md +3 -0
- package/lib/contact-methods/chat-popup/chat-popup-plugin.d.ts +2 -0
- package/lib/contact-methods/chat-popup/chat-popup-plugin.js +79 -0
- package/lib/contact-methods/chat-popup/index.d.ts +1 -0
- package/lib/contact-methods/chat-popup/index.js +8 -0
- package/lib/contact-methods/email/email-form-component.d.ts +4 -0
- package/lib/contact-methods/email/email-form-component.js +58 -0
- package/lib/contact-methods/email/email-plugin.d.ts +16 -0
- package/lib/contact-methods/email/email-plugin.js +83 -0
- package/lib/contact-methods/email/index.d.ts +1 -0
- package/lib/contact-methods/email/index.js +12 -0
- package/lib/contact-methods/free-text/free-text-component.d.ts +4 -0
- package/lib/contact-methods/free-text/free-text-component.js +49 -0
- package/lib/contact-methods/free-text/free-text-plugin.d.ts +2 -0
- package/lib/contact-methods/free-text/free-text-plugin.js +34 -0
- package/lib/contact-methods/free-text/index.d.ts +1 -0
- package/lib/contact-methods/free-text/index.js +8 -0
- package/lib/contact-methods/index.d.ts +10 -0
- package/lib/contact-methods/index.js +31 -0
- package/lib/contact-methods/link/index.d.ts +1 -0
- package/lib/contact-methods/link/index.js +8 -0
- package/lib/contact-methods/link/link-component.d.ts +4 -0
- package/lib/contact-methods/link/link-component.js +13 -0
- package/lib/contact-methods/link/link-plugin.d.ts +2 -0
- package/lib/contact-methods/link/link-plugin.js +34 -0
- package/lib/contact-methods/phone/index.d.ts +1 -0
- package/lib/contact-methods/phone/index.js +8 -0
- package/lib/contact-methods/phone/phone-component.d.ts +4 -0
- package/lib/contact-methods/phone/phone-component.js +12 -0
- package/lib/contact-methods/phone/phone-plugin.d.ts +2 -0
- package/lib/contact-methods/phone/phone-plugin.js +34 -0
- package/lib/contact-methods/platform.d.ts +49 -0
- package/lib/contact-methods/platform.js +256 -0
- package/lib/contact-methods/ui/confirmation.d.ts +6 -0
- package/lib/contact-methods/ui/confirmation.js +47 -0
- package/lib/contact-methods/ui/contact-list.d.ts +15 -0
- package/lib/contact-methods/ui/contact-list.js +61 -0
- package/lib/contact-methods/ui/contact-method.d.ts +39 -0
- package/lib/contact-methods/ui/contact-method.js +110 -0
- package/lib/contact-methods/ui/description.d.ts +3 -0
- package/lib/contact-methods/ui/description.js +13 -0
- package/lib/contact-methods/ui/form.d.ts +4 -0
- package/lib/contact-methods/ui/form.js +54 -0
- package/lib/contact-methods/ui/index.d.ts +7 -0
- package/lib/contact-methods/ui/index.js +20 -0
- package/lib/contact-methods/ui/use-contact-method.d.ts +2 -0
- package/lib/contact-methods/ui/use-contact-method.js +39 -0
- package/lib/contact-methods/web-service/index.d.ts +1 -0
- package/lib/contact-methods/web-service/index.js +8 -0
- package/lib/contact-methods/web-service/web-service-plugin.d.ts +2 -0
- package/lib/contact-methods/web-service/web-service-plugin.js +30 -0
- package/lib/create-adapter.d.ts +7 -0
- package/lib/create-adapter.js +43 -0
- package/lib/default-contact-methods-plugin.d.ts +8 -0
- package/lib/default-contact-methods-plugin.js +42 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +25 -0
- package/lib-esm/contact-methods/chat-popup/chat-popup-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/chat-popup/chat-popup-plugin.js +76 -0
- package/lib-esm/contact-methods/chat-popup/index.d.ts +1 -0
- package/lib-esm/contact-methods/chat-popup/index.js +1 -0
- package/lib-esm/contact-methods/email/email-form-component.d.ts +4 -0
- package/lib-esm/contact-methods/email/email-form-component.js +33 -0
- package/lib-esm/contact-methods/email/email-plugin.d.ts +16 -0
- package/lib-esm/contact-methods/email/email-plugin.js +52 -0
- package/lib-esm/contact-methods/email/index.d.ts +1 -0
- package/lib-esm/contact-methods/email/index.js +1 -0
- package/lib-esm/contact-methods/free-text/free-text-component.d.ts +4 -0
- package/lib-esm/contact-methods/free-text/free-text-component.js +21 -0
- package/lib-esm/contact-methods/free-text/free-text-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/free-text/free-text-plugin.js +8 -0
- package/lib-esm/contact-methods/free-text/index.d.ts +1 -0
- package/lib-esm/contact-methods/free-text/index.js +1 -0
- package/lib-esm/contact-methods/index.d.ts +10 -0
- package/lib-esm/contact-methods/index.js +8 -0
- package/lib-esm/contact-methods/link/index.d.ts +1 -0
- package/lib-esm/contact-methods/link/index.js +1 -0
- package/lib-esm/contact-methods/link/link-component.d.ts +4 -0
- package/lib-esm/contact-methods/link/link-component.js +11 -0
- package/lib-esm/contact-methods/link/link-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/link/link-plugin.js +8 -0
- package/lib-esm/contact-methods/phone/index.d.ts +1 -0
- package/lib-esm/contact-methods/phone/index.js +1 -0
- package/lib-esm/contact-methods/phone/phone-component.d.ts +4 -0
- package/lib-esm/contact-methods/phone/phone-component.js +10 -0
- package/lib-esm/contact-methods/phone/phone-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/phone/phone-plugin.js +8 -0
- package/lib-esm/contact-methods/platform.d.ts +49 -0
- package/lib-esm/contact-methods/platform.js +253 -0
- package/lib-esm/contact-methods/ui/confirmation.d.ts +6 -0
- package/lib-esm/contact-methods/ui/confirmation.js +22 -0
- package/lib-esm/contact-methods/ui/contact-list.d.ts +15 -0
- package/lib-esm/contact-methods/ui/contact-list.js +32 -0
- package/lib-esm/contact-methods/ui/contact-method.d.ts +39 -0
- package/lib-esm/contact-methods/ui/contact-method.js +81 -0
- package/lib-esm/contact-methods/ui/description.d.ts +3 -0
- package/lib-esm/contact-methods/ui/description.js +8 -0
- package/lib-esm/contact-methods/ui/form.d.ts +4 -0
- package/lib-esm/contact-methods/ui/form.js +49 -0
- package/lib-esm/contact-methods/ui/index.d.ts +7 -0
- package/lib-esm/contact-methods/ui/index.js +6 -0
- package/lib-esm/contact-methods/ui/use-contact-method.d.ts +2 -0
- package/lib-esm/contact-methods/ui/use-contact-method.js +37 -0
- package/lib-esm/contact-methods/web-service/index.d.ts +1 -0
- package/lib-esm/contact-methods/web-service/index.js +1 -0
- package/lib-esm/contact-methods/web-service/web-service-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/web-service/web-service-plugin.js +27 -0
- package/lib-esm/create-adapter.d.ts +7 -0
- package/lib-esm/create-adapter.js +39 -0
- package/lib-esm/default-contact-methods-plugin.d.ts +8 -0
- package/lib-esm/default-contact-methods-plugin.js +39 -0
- package/lib-esm/index.d.ts +5 -0
- package/lib-esm/index.js +3 -0
- package/package.json +43 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import { useContainer } from '@telia-ace/knowledge-widget-ui';
|
|
18
|
+
import { useEffect, useState } from 'react';
|
|
19
|
+
var useContactMethod = function (clientName) {
|
|
20
|
+
var _a = __read(useState(null), 2), component = _a[0], setComponent = _a[1];
|
|
21
|
+
var container = useContainer();
|
|
22
|
+
useEffect(function () {
|
|
23
|
+
var unsubscribe;
|
|
24
|
+
container.getAsync('componentResolver').then(function (resolver) {
|
|
25
|
+
unsubscribe = resolver.registerResolver(clientName, function (component) {
|
|
26
|
+
return setComponent(component);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
return function () {
|
|
30
|
+
if (unsubscribe) {
|
|
31
|
+
unsubscribe();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}, [clientName]);
|
|
35
|
+
return component;
|
|
36
|
+
};
|
|
37
|
+
export default useContactMethod;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as WebServicePlugin } from './web-service-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as WebServicePlugin } from './web-service-plugin';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { defaultComplete, defaultSubmit, defaultValidate } from '..';
|
|
13
|
+
export default function webServicePlugin(container) {
|
|
14
|
+
container.getAsync('contactMethods').then(function (platform) {
|
|
15
|
+
platform.create({
|
|
16
|
+
clientName: 'custom.webservice',
|
|
17
|
+
render: 'email.form',
|
|
18
|
+
onValidate: function (contactMethod) { return defaultValidate(container, contactMethod); },
|
|
19
|
+
onComplete: function (contactMethod) { return defaultComplete(container, contactMethod); },
|
|
20
|
+
onSubmit: function (contactMethod) {
|
|
21
|
+
return defaultSubmit(container, contactMethod, function (response) {
|
|
22
|
+
return __assign(__assign({}, response), { ConfirmationText: response.ResponseHtml });
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
export declare type Callback = (settings: {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
}, data?: {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}) => Promise<string | void> | (string | void);
|
|
7
|
+
export declare const createSubmitAdapter: (container: Container, clientName: string, fn: Callback) => Promise<void>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { FormReader } from '@telia-ace/widget-forms';
|
|
13
|
+
import { defaultComplete, defaultValidate } from './contact-methods';
|
|
14
|
+
export var createSubmitAdapter = function (container, clientName, fn) {
|
|
15
|
+
return container.getAsync('contactMethods').then(function (platform) {
|
|
16
|
+
platform.create({
|
|
17
|
+
clientName: clientName,
|
|
18
|
+
render: 'email.form',
|
|
19
|
+
handleClick: function () {
|
|
20
|
+
return function (e, cm) {
|
|
21
|
+
var _a = cm.body, form = _a.form, guideId = _a.guideId, confirmationFallback = _a.confirmationFallback, rest = __rest(_a, ["form", "guideId", "confirmationFallback"]);
|
|
22
|
+
if (!form) {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
fn(rest);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
onValidate: function (cm) { return defaultValidate(container, cm); },
|
|
29
|
+
onComplete: function (cm) { return defaultComplete(container, cm); },
|
|
30
|
+
onSubmit: function (cm) {
|
|
31
|
+
var _a = cm.body, form = _a.form, guideId = _a.guideId, confirmationFallback = _a.confirmationFallback, rest = __rest(_a, ["form", "guideId", "confirmationFallback"]);
|
|
32
|
+
var values = new FormReader(form).export().values;
|
|
33
|
+
return Promise.resolve(fn(rest, values)).then(function (confirmation) {
|
|
34
|
+
return confirmation || confirmationFallback;
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin } from '@telia-ace/knowledge-widget-core';
|
|
2
|
+
import { Container } from '@webprovisions/platform';
|
|
3
|
+
/**
|
|
4
|
+
* Registers default Humany contact methods.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultContactMethodsPlugin extends Plugin {
|
|
7
|
+
constructor(container: Container, settings: any);
|
|
8
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
import { Plugin } from '@telia-ace/knowledge-widget-core';
|
|
17
|
+
import { ChatPopupPlugin, EmailFormPlugin, FreeTextPlugin, LinkPlugin, PhonePlugin, WebServicePlugin, } from '.';
|
|
18
|
+
/**
|
|
19
|
+
* Registers default Humany contact methods.
|
|
20
|
+
*/
|
|
21
|
+
var DefaultContactMethodsPlugin = /** @class */ (function (_super) {
|
|
22
|
+
__extends(DefaultContactMethodsPlugin, _super);
|
|
23
|
+
function DefaultContactMethodsPlugin(container, settings) {
|
|
24
|
+
var _this = _super.call(this, container, settings) || this;
|
|
25
|
+
var implementation = _this.widget.implementation;
|
|
26
|
+
implementation.configure(function (config) {
|
|
27
|
+
config
|
|
28
|
+
.plugin(EmailFormPlugin)
|
|
29
|
+
.plugin(ChatPopupPlugin)
|
|
30
|
+
.plugin(FreeTextPlugin)
|
|
31
|
+
.plugin(PhonePlugin)
|
|
32
|
+
.plugin(WebServicePlugin)
|
|
33
|
+
.plugin(LinkPlugin);
|
|
34
|
+
});
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
return DefaultContactMethodsPlugin;
|
|
38
|
+
}(Plugin));
|
|
39
|
+
export { DefaultContactMethodsPlugin };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ChatPopupPlugin, contactItemList, contactLink, ContactList, ContactMethod, ContactMethodPlatform, defaultComplete, defaultEvaluate, DefaultForm, defaultSubmit, defaultValidate, EmailPlugin as EmailFormPlugin, FreeTextPlugin, LinkPlugin, PhonePlugin, useContactMethod, WebServicePlugin, } from './contact-methods';
|
|
2
|
+
export type { ContactMethodClick, ContactMethodType, ReactComponentImport, } from './contact-methods';
|
|
3
|
+
export { createSubmitAdapter } from './create-adapter';
|
|
4
|
+
export type { Callback } from './create-adapter';
|
|
5
|
+
export { DefaultContactMethodsPlugin } from './default-contact-methods-plugin';
|
package/lib-esm/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ChatPopupPlugin, contactItemList, contactLink, ContactList, ContactMethod, ContactMethodPlatform, defaultComplete, defaultEvaluate, DefaultForm, defaultSubmit, defaultValidate, EmailPlugin as EmailFormPlugin, FreeTextPlugin, LinkPlugin, PhonePlugin, useContactMethod, WebServicePlugin, } from './contact-methods';
|
|
2
|
+
export { createSubmitAdapter } from './create-adapter';
|
|
3
|
+
export { DefaultContactMethodsPlugin } from './default-contact-methods-plugin';
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/knowledge-widget-adapters",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "ACE knowledge adapters for ACE widgets.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "Telia Company AB",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"telia"
|
|
9
|
+
],
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"module": "lib-esm/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"README.md",
|
|
15
|
+
"lib/",
|
|
16
|
+
"lib-esm/"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "cleandir lib && cleandir lib-esm",
|
|
23
|
+
"compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"typings": "lib/index.d.ts",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@telia-ace/knowledge-serviceclient": "^1.0.0",
|
|
29
|
+
"@telia-ace/knowledge-widget-core": "^1.0.1",
|
|
30
|
+
"@telia-ace/knowledge-widget-ui": "^1.0.1",
|
|
31
|
+
"@telia-ace/widget-forms": "^1.0.1",
|
|
32
|
+
"@telia-ace/widget-routing": "^1.0.1",
|
|
33
|
+
"@telia-ace/widget-utilities": "^1.0.1",
|
|
34
|
+
"@webprovisions/platform": "^1.1.2",
|
|
35
|
+
"react": "^17.0.2",
|
|
36
|
+
"styled-components": "^4.3.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/react": "^17.0.39",
|
|
40
|
+
"@types/styled-components": "^5.1.7"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "2df7de1fc7344c709b46911133e9e50f7cab8e5c"
|
|
43
|
+
}
|