@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,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var widget_forms_1 = require("@telia-ace/widget-forms");
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
/**
|
|
9
|
+
* Recursively find form component in schema
|
|
10
|
+
* @param node Form schema
|
|
11
|
+
* @param id actionKey of component to find
|
|
12
|
+
*/
|
|
13
|
+
var lookupComponent = function (node, id) {
|
|
14
|
+
if (node.actionKey === id) {
|
|
15
|
+
return node;
|
|
16
|
+
}
|
|
17
|
+
if (!node.properties) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var keys = Object.keys(node.properties);
|
|
21
|
+
var result;
|
|
22
|
+
// tslint:disable-next-line:no-increment-decrement
|
|
23
|
+
for (var i = 0; i < keys.length; i++) {
|
|
24
|
+
result = lookupComponent(node.properties[keys[i]], id);
|
|
25
|
+
if (result) {
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
var Form = function (_a) {
|
|
32
|
+
var className = _a.className, form = _a.body.form, id = _a.id, action = _a.action, dispatch = _a.dispatch, disabled = _a.disabled, autoFocus = _a.autoFocus;
|
|
33
|
+
if (form && !disabled) {
|
|
34
|
+
var schema_1 = form.schema, layout_1 = form.layout, data = form.data;
|
|
35
|
+
var trigger_1 = dispatch || action || (function () { });
|
|
36
|
+
return (react_1.default.createElement(widget_forms_1.FormComponent, { className: className, schema: schema_1, layout: layout_1, data: data, autoFocus: autoFocus, onChange: function (event, data) {
|
|
37
|
+
var form = { schema: schema_1, layout: layout_1, data: data };
|
|
38
|
+
if (event.toString() === 'submit') {
|
|
39
|
+
trigger_1('submit', { id: id, form: form });
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
var formComponent = lookupComponent(schema_1, event);
|
|
43
|
+
if (formComponent.evaluate) {
|
|
44
|
+
trigger_1('evaluate', { id: id, form: form });
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
trigger_1('validate', { id: id, form: form });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} }));
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
exports.default = Form;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Confirmation } from './confirmation';
|
|
2
|
+
export { contactItemList, default as ContactList } from './contact-list';
|
|
3
|
+
export { contactLink, default as ContactMethod } from './contact-method';
|
|
4
|
+
export type { ContactMethodType, Props as ContactMethodProps } from './contact-method';
|
|
5
|
+
export { default as Description } from './description';
|
|
6
|
+
export { default as Form } from './form';
|
|
7
|
+
export { default as useContactMethod } from './use-contact-method';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useContactMethod = exports.Form = exports.Description = exports.ContactMethod = exports.contactLink = exports.ContactList = exports.contactItemList = exports.Confirmation = void 0;
|
|
7
|
+
var confirmation_1 = require("./confirmation");
|
|
8
|
+
Object.defineProperty(exports, "Confirmation", { enumerable: true, get: function () { return __importDefault(confirmation_1).default; } });
|
|
9
|
+
var contact_list_1 = require("./contact-list");
|
|
10
|
+
Object.defineProperty(exports, "contactItemList", { enumerable: true, get: function () { return contact_list_1.contactItemList; } });
|
|
11
|
+
Object.defineProperty(exports, "ContactList", { enumerable: true, get: function () { return __importDefault(contact_list_1).default; } });
|
|
12
|
+
var contact_method_1 = require("./contact-method");
|
|
13
|
+
Object.defineProperty(exports, "contactLink", { enumerable: true, get: function () { return contact_method_1.contactLink; } });
|
|
14
|
+
Object.defineProperty(exports, "ContactMethod", { enumerable: true, get: function () { return __importDefault(contact_method_1).default; } });
|
|
15
|
+
var description_1 = require("./description");
|
|
16
|
+
Object.defineProperty(exports, "Description", { enumerable: true, get: function () { return __importDefault(description_1).default; } });
|
|
17
|
+
var form_1 = require("./form");
|
|
18
|
+
Object.defineProperty(exports, "Form", { enumerable: true, get: function () { return __importDefault(form_1).default; } });
|
|
19
|
+
var use_contact_method_1 = require("./use-contact-method");
|
|
20
|
+
Object.defineProperty(exports, "useContactMethod", { enumerable: true, get: function () { return __importDefault(use_contact_method_1).default; } });
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var knowledge_widget_ui_1 = require("@telia-ace/knowledge-widget-ui");
|
|
20
|
+
var react_1 = require("react");
|
|
21
|
+
var useContactMethod = function (clientName) {
|
|
22
|
+
var _a = __read((0, react_1.useState)(null), 2), component = _a[0], setComponent = _a[1];
|
|
23
|
+
var container = (0, knowledge_widget_ui_1.useContainer)();
|
|
24
|
+
(0, react_1.useEffect)(function () {
|
|
25
|
+
var unsubscribe;
|
|
26
|
+
container.getAsync('componentResolver').then(function (resolver) {
|
|
27
|
+
unsubscribe = resolver.registerResolver(clientName, function (component) {
|
|
28
|
+
return setComponent(component);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return function () {
|
|
32
|
+
if (unsubscribe) {
|
|
33
|
+
unsubscribe();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, [clientName]);
|
|
37
|
+
return component;
|
|
38
|
+
};
|
|
39
|
+
exports.default = useContactMethod;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as WebServicePlugin } from './web-service-plugin';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebServicePlugin = void 0;
|
|
7
|
+
var web_service_plugin_1 = require("./web-service-plugin");
|
|
8
|
+
Object.defineProperty(exports, "WebServicePlugin", { enumerable: true, get: function () { return __importDefault(web_service_plugin_1).default; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var __1 = require("..");
|
|
15
|
+
function webServicePlugin(container) {
|
|
16
|
+
container.getAsync('contactMethods').then(function (platform) {
|
|
17
|
+
platform.create({
|
|
18
|
+
clientName: 'custom.webservice',
|
|
19
|
+
render: 'email.form',
|
|
20
|
+
onValidate: function (contactMethod) { return (0, __1.defaultValidate)(container, contactMethod); },
|
|
21
|
+
onComplete: function (contactMethod) { return (0, __1.defaultComplete)(container, contactMethod); },
|
|
22
|
+
onSubmit: function (contactMethod) {
|
|
23
|
+
return (0, __1.defaultSubmit)(container, contactMethod, function (response) {
|
|
24
|
+
return __assign(__assign({}, response), { ConfirmationText: response.ResponseHtml });
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.default = webServicePlugin;
|
|
@@ -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,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.createSubmitAdapter = void 0;
|
|
15
|
+
var widget_forms_1 = require("@telia-ace/widget-forms");
|
|
16
|
+
var contact_methods_1 = require("./contact-methods");
|
|
17
|
+
var createSubmitAdapter = function (container, clientName, fn) {
|
|
18
|
+
return container.getAsync('contactMethods').then(function (platform) {
|
|
19
|
+
platform.create({
|
|
20
|
+
clientName: clientName,
|
|
21
|
+
render: 'email.form',
|
|
22
|
+
handleClick: function () {
|
|
23
|
+
return function (e, cm) {
|
|
24
|
+
var _a = cm.body, form = _a.form, guideId = _a.guideId, confirmationFallback = _a.confirmationFallback, rest = __rest(_a, ["form", "guideId", "confirmationFallback"]);
|
|
25
|
+
if (!form) {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
fn(rest);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
onValidate: function (cm) { return (0, contact_methods_1.defaultValidate)(container, cm); },
|
|
32
|
+
onComplete: function (cm) { return (0, contact_methods_1.defaultComplete)(container, cm); },
|
|
33
|
+
onSubmit: function (cm) {
|
|
34
|
+
var _a = cm.body, form = _a.form, guideId = _a.guideId, confirmationFallback = _a.confirmationFallback, rest = __rest(_a, ["form", "guideId", "confirmationFallback"]);
|
|
35
|
+
var values = new widget_forms_1.FormReader(form).export().values;
|
|
36
|
+
return Promise.resolve(fn(rest, values)).then(function (confirmation) {
|
|
37
|
+
return confirmation || confirmationFallback;
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
exports.createSubmitAdapter = createSubmitAdapter;
|
|
@@ -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,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DefaultContactMethodsPlugin = void 0;
|
|
19
|
+
var knowledge_widget_core_1 = require("@telia-ace/knowledge-widget-core");
|
|
20
|
+
var _1 = require(".");
|
|
21
|
+
/**
|
|
22
|
+
* Registers default Humany contact methods.
|
|
23
|
+
*/
|
|
24
|
+
var DefaultContactMethodsPlugin = /** @class */ (function (_super) {
|
|
25
|
+
__extends(DefaultContactMethodsPlugin, _super);
|
|
26
|
+
function DefaultContactMethodsPlugin(container, settings) {
|
|
27
|
+
var _this = _super.call(this, container, settings) || this;
|
|
28
|
+
var implementation = _this.widget.implementation;
|
|
29
|
+
implementation.configure(function (config) {
|
|
30
|
+
config
|
|
31
|
+
.plugin(_1.EmailFormPlugin)
|
|
32
|
+
.plugin(_1.ChatPopupPlugin)
|
|
33
|
+
.plugin(_1.FreeTextPlugin)
|
|
34
|
+
.plugin(_1.PhonePlugin)
|
|
35
|
+
.plugin(_1.WebServicePlugin)
|
|
36
|
+
.plugin(_1.LinkPlugin);
|
|
37
|
+
});
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
return DefaultContactMethodsPlugin;
|
|
41
|
+
}(knowledge_widget_core_1.Plugin));
|
|
42
|
+
exports.DefaultContactMethodsPlugin = DefaultContactMethodsPlugin;
|
package/lib/index.d.ts
ADDED
|
@@ -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/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultContactMethodsPlugin = exports.createSubmitAdapter = exports.WebServicePlugin = exports.useContactMethod = exports.PhonePlugin = exports.LinkPlugin = exports.FreeTextPlugin = exports.EmailFormPlugin = exports.defaultValidate = exports.defaultSubmit = exports.DefaultForm = exports.defaultEvaluate = exports.defaultComplete = exports.ContactMethodPlatform = exports.ContactMethod = exports.ContactList = exports.contactLink = exports.contactItemList = exports.ChatPopupPlugin = void 0;
|
|
4
|
+
var contact_methods_1 = require("./contact-methods");
|
|
5
|
+
Object.defineProperty(exports, "ChatPopupPlugin", { enumerable: true, get: function () { return contact_methods_1.ChatPopupPlugin; } });
|
|
6
|
+
Object.defineProperty(exports, "contactItemList", { enumerable: true, get: function () { return contact_methods_1.contactItemList; } });
|
|
7
|
+
Object.defineProperty(exports, "contactLink", { enumerable: true, get: function () { return contact_methods_1.contactLink; } });
|
|
8
|
+
Object.defineProperty(exports, "ContactList", { enumerable: true, get: function () { return contact_methods_1.ContactList; } });
|
|
9
|
+
Object.defineProperty(exports, "ContactMethod", { enumerable: true, get: function () { return contact_methods_1.ContactMethod; } });
|
|
10
|
+
Object.defineProperty(exports, "ContactMethodPlatform", { enumerable: true, get: function () { return contact_methods_1.ContactMethodPlatform; } });
|
|
11
|
+
Object.defineProperty(exports, "defaultComplete", { enumerable: true, get: function () { return contact_methods_1.defaultComplete; } });
|
|
12
|
+
Object.defineProperty(exports, "defaultEvaluate", { enumerable: true, get: function () { return contact_methods_1.defaultEvaluate; } });
|
|
13
|
+
Object.defineProperty(exports, "DefaultForm", { enumerable: true, get: function () { return contact_methods_1.DefaultForm; } });
|
|
14
|
+
Object.defineProperty(exports, "defaultSubmit", { enumerable: true, get: function () { return contact_methods_1.defaultSubmit; } });
|
|
15
|
+
Object.defineProperty(exports, "defaultValidate", { enumerable: true, get: function () { return contact_methods_1.defaultValidate; } });
|
|
16
|
+
Object.defineProperty(exports, "EmailFormPlugin", { enumerable: true, get: function () { return contact_methods_1.EmailPlugin; } });
|
|
17
|
+
Object.defineProperty(exports, "FreeTextPlugin", { enumerable: true, get: function () { return contact_methods_1.FreeTextPlugin; } });
|
|
18
|
+
Object.defineProperty(exports, "LinkPlugin", { enumerable: true, get: function () { return contact_methods_1.LinkPlugin; } });
|
|
19
|
+
Object.defineProperty(exports, "PhonePlugin", { enumerable: true, get: function () { return contact_methods_1.PhonePlugin; } });
|
|
20
|
+
Object.defineProperty(exports, "useContactMethod", { enumerable: true, get: function () { return contact_methods_1.useContactMethod; } });
|
|
21
|
+
Object.defineProperty(exports, "WebServicePlugin", { enumerable: true, get: function () { return contact_methods_1.WebServicePlugin; } });
|
|
22
|
+
var create_adapter_1 = require("./create-adapter");
|
|
23
|
+
Object.defineProperty(exports, "createSubmitAdapter", { enumerable: true, get: function () { return create_adapter_1.createSubmitAdapter; } });
|
|
24
|
+
var default_contact_methods_plugin_1 = require("./default-contact-methods-plugin");
|
|
25
|
+
Object.defineProperty(exports, "DefaultContactMethodsPlugin", { enumerable: true, get: function () { return default_contact_methods_plugin_1.DefaultContactMethodsPlugin; } });
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
import { FormReader } from '@telia-ace/widget-forms';
|
|
29
|
+
import { defaultValidate } from '..';
|
|
30
|
+
import { defaultComplete } from '../email';
|
|
31
|
+
var popup = function (title, settings, formValues) {
|
|
32
|
+
var url = settings.url, width = settings.width, height = settings.height;
|
|
33
|
+
var queries = formValues ? formValues : {};
|
|
34
|
+
var link = document.createElement('a');
|
|
35
|
+
link.href = url;
|
|
36
|
+
link.search
|
|
37
|
+
.replace('?', '')
|
|
38
|
+
.split('&')
|
|
39
|
+
.forEach(function (part) {
|
|
40
|
+
var _a = __read(part.split('='), 2), key = _a[0], value = _a[1];
|
|
41
|
+
typeof value !== 'undefined' && (queries[key] = value);
|
|
42
|
+
});
|
|
43
|
+
link.search = Object.keys(queries)
|
|
44
|
+
.map(function (key) { return "".concat(key, "=").concat(queries[key]); })
|
|
45
|
+
.join('&');
|
|
46
|
+
window.open(link.href, title, "width=".concat(width, ",height=").concat(height));
|
|
47
|
+
return '';
|
|
48
|
+
};
|
|
49
|
+
export default function chatPopupPlugin(container) {
|
|
50
|
+
container.getAsync('contactMethods').then(function (platform) {
|
|
51
|
+
platform.create({
|
|
52
|
+
clientName: 'chat.popup',
|
|
53
|
+
render: 'email.form',
|
|
54
|
+
handleClick: function (contactMethod) {
|
|
55
|
+
var title = contactMethod.title, body = contactMethod.body;
|
|
56
|
+
var form = body.form, guideId = body.guideId, confirmationFallback = body.confirmationFallback, rest = __rest(body, ["form", "guideId", "confirmationFallback"]);
|
|
57
|
+
if (!form) {
|
|
58
|
+
return function (e) {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
popup(title, rest);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return function () { };
|
|
64
|
+
},
|
|
65
|
+
onValidate: function (contactMethod) { return defaultValidate(container, contactMethod); },
|
|
66
|
+
onComplete: function (contactMethod) { return defaultComplete(container, contactMethod); },
|
|
67
|
+
onSubmit: function (contactMethod) {
|
|
68
|
+
var title = contactMethod.title, body = contactMethod.body;
|
|
69
|
+
var form = body.form, guideId = body.guideId, confirmationFallback = body.confirmationFallback, rest = __rest(body, ["form", "guideId", "confirmationFallback"]);
|
|
70
|
+
var formValues = new FormReader(form).export().values;
|
|
71
|
+
popup(title, rest, formValues);
|
|
72
|
+
return confirmationFallback;
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ChatPopupPlugin } from './chat-popup-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ChatPopupPlugin } from './chat-popup-plugin';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { genericHtml, headingElement, Html } from '@telia-ace/knowledge-widget-ui';
|
|
17
|
+
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import styled, { css } from 'styled-components';
|
|
20
|
+
import { Form } from '../ui';
|
|
21
|
+
var StyledHtml = styled(Html)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n\n ", "\n"], ["\n ", "\n\n ", "\n"])), genericHtml, headingElement('h1', css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n font-weight: normal;\n font-size: ", ";\n "], ["\n font-weight: normal;\n font-size: ", ";\n "])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.medium; })));
|
|
22
|
+
var EmailFormComponent = function (props) {
|
|
23
|
+
var className = props.className, _a = props.renderDefault, renderDefault = _a === void 0 ? function () { } : _a, form = props.body.form, confirmation = props.confirmation, htmlParseInstruction = props.htmlParseInstruction, disabled = props.disabled;
|
|
24
|
+
if (confirmation) {
|
|
25
|
+
return (React.createElement(StyledHtml, { className: appendClassNames(className, 'humany-contact-method-confirmation', 'humany-contact-method-email'), html: confirmation, htmlParseInstruction: htmlParseInstruction }));
|
|
26
|
+
}
|
|
27
|
+
if (form && !disabled) {
|
|
28
|
+
return (React.createElement(Form, __assign({}, props, { className: appendClassNames(className, 'humany-contact-method-email') })));
|
|
29
|
+
}
|
|
30
|
+
return renderDefault();
|
|
31
|
+
};
|
|
32
|
+
export default EmailFormComponent;
|
|
33
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SubmissionApiResult } from '@telia-ace/knowledge-serviceclient';
|
|
2
|
+
import { Container } from '@webprovisions/platform';
|
|
3
|
+
import { ContactMethodType } from '../ui';
|
|
4
|
+
export declare const submit: (container: Container, contactMethod: ContactMethodType, transform?: ((response: any) => SubmissionApiResult) | undefined) => Promise<string>;
|
|
5
|
+
export declare const validate: (container: Container, contactMethod: ContactMethodType) => Promise<{
|
|
6
|
+
valid: boolean;
|
|
7
|
+
errors: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
errorTypes: {
|
|
11
|
+
[key: string]: string;
|
|
12
|
+
};
|
|
13
|
+
}>;
|
|
14
|
+
export declare const evaluate: (container: Container, contactMethod: ContactMethodType) => Promise<import("@telia-ace/widget-forms").Form>;
|
|
15
|
+
export declare const complete: (container: Container, contactMethod: ContactMethodType) => Promise<void>;
|
|
16
|
+
export default function emailPlugin(container: Container): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FormBuilder, FormReader } from '@telia-ace/widget-forms';
|
|
2
|
+
var post = function (container, contactMethod, validate) {
|
|
3
|
+
if (validate === void 0) { validate = false; }
|
|
4
|
+
return container.getManyAsync('matchingClient', 'router').then(function (services) {
|
|
5
|
+
var formData = new FormReader(contactMethod.body.form).export(validate).formData;
|
|
6
|
+
var _a = services, router = _a.router, matchingClient = _a.matchingClient;
|
|
7
|
+
var params = router.getRouteData().params;
|
|
8
|
+
return matchingClient.customRequest("contactmethods/".concat(contactMethod.id).concat(validate ? '/validatedwithpayload' : ''), 'POST', {
|
|
9
|
+
body: formData,
|
|
10
|
+
configuration: {
|
|
11
|
+
guideId: contactMethod.body.guideId || params.guideId,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export var submit = function (container, contactMethod, transform) {
|
|
17
|
+
return post(container, contactMethod)
|
|
18
|
+
.then(function (response) { return (transform ? transform(response) : response); })
|
|
19
|
+
.then(function (_a) {
|
|
20
|
+
var ConfirmationText = _a.ConfirmationText;
|
|
21
|
+
return ConfirmationText;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export var validate = function (container, contactMethod) {
|
|
25
|
+
return post(container, contactMethod, true).then(function (result) { return ({
|
|
26
|
+
valid: result.Validation.IsValid,
|
|
27
|
+
errors: result.Validation.Errors,
|
|
28
|
+
errorTypes: result.Validation.ErrorTypes,
|
|
29
|
+
}); });
|
|
30
|
+
};
|
|
31
|
+
export var evaluate = function (container, contactMethod) {
|
|
32
|
+
return post(container, contactMethod, true).then(function (result) {
|
|
33
|
+
return FormBuilder.fromLegacyForm(contactMethod.id, result.ContactMethod.Form).get();
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
export var complete = function (container, contactMethod) {
|
|
37
|
+
return container.getAsync('matchingClient').then(function (matchingClient) {
|
|
38
|
+
matchingClient.completeContactMethod(contactMethod.id);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
export default function emailPlugin(container) {
|
|
42
|
+
container.getAsync('contactMethods').then(function (platform) {
|
|
43
|
+
platform.create({
|
|
44
|
+
clientName: 'email.form',
|
|
45
|
+
render: import('./email-form-component'),
|
|
46
|
+
onEvaluate: function (contactMethod) { return evaluate(container, contactMethod); },
|
|
47
|
+
onValidate: function (contactMethod) { return validate(container, contactMethod); },
|
|
48
|
+
onSubmit: function (contactMethod) { return submit(container, contactMethod); },
|
|
49
|
+
onComplete: function (contactMethod) { return complete(container, contactMethod); },
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { complete as defaultComplete, default as EmailPlugin, evaluate as defaultEvaluate, submit as defaultSubmit, validate as defaultValidate, } from './email-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { complete as defaultComplete, default as EmailPlugin, evaluate as defaultEvaluate, submit as defaultSubmit, validate as defaultValidate, } from './email-plugin';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { genericHtml, Html } from '@telia-ace/knowledge-widget-ui';
|
|
6
|
+
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import { Description } from '../ui';
|
|
10
|
+
var FreeTextComponent = function (_a) {
|
|
11
|
+
var className = _a.className, description = _a.description, freetext = _a.body.freetext, htmlParseInstruction = _a.htmlParseInstruction;
|
|
12
|
+
if (!freetext) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return (React.createElement("div", { className: appendClassNames(className, 'humany-contact-method-free-text') },
|
|
16
|
+
React.createElement(StyledHtml, { html: freetext, htmlParseInstruction: htmlParseInstruction }),
|
|
17
|
+
description && (React.createElement(Description, { html: description, htmlParseInstruction: htmlParseInstruction }))));
|
|
18
|
+
};
|
|
19
|
+
export default FreeTextComponent;
|
|
20
|
+
var StyledHtml = styled(Html)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n"], ["\n ", ";\n"])), genericHtml);
|
|
21
|
+
var templateObject_1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FreeTextPlugin } from './free-text-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FreeTextPlugin } from './free-text-plugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { ChatPopupPlugin } from './chat-popup';
|
|
2
|
+
export { defaultComplete, defaultEvaluate, defaultSubmit, defaultValidate, EmailPlugin, } from './email';
|
|
3
|
+
export { FreeTextPlugin } from './free-text';
|
|
4
|
+
export { LinkPlugin } from './link';
|
|
5
|
+
export { PhonePlugin } from './phone';
|
|
6
|
+
export { default as ContactMethodPlatform } from './platform';
|
|
7
|
+
export type { Click as ContactMethodClick, ReactComponentImport } from './platform';
|
|
8
|
+
export { contactItemList, contactLink, ContactList, ContactMethod, Form as DefaultForm, useContactMethod, } from './ui';
|
|
9
|
+
export type { ContactMethodType } from './ui';
|
|
10
|
+
export { WebServicePlugin } from './web-service';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ChatPopupPlugin } from './chat-popup';
|
|
2
|
+
export { defaultComplete, defaultEvaluate, defaultSubmit, defaultValidate, EmailPlugin, } from './email';
|
|
3
|
+
export { FreeTextPlugin } from './free-text';
|
|
4
|
+
export { LinkPlugin } from './link';
|
|
5
|
+
export { PhonePlugin } from './phone';
|
|
6
|
+
export { default as ContactMethodPlatform } from './platform';
|
|
7
|
+
export { contactItemList, contactLink, ContactList, ContactMethod, Form as DefaultForm, useContactMethod, } from './ui';
|
|
8
|
+
export { WebServicePlugin } from './web-service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as LinkPlugin } from './link-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as LinkPlugin } from './link-plugin';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
2
|
+
var LinkComponent = function (_a) {
|
|
3
|
+
var className = _a.className, body = _a.body, _b = _a.renderDefault, renderDefault = _b === void 0 ? function () { } : _b;
|
|
4
|
+
var uri = body.uri, target = body.target, protocol = body.protocol;
|
|
5
|
+
return renderDefault({
|
|
6
|
+
target: target,
|
|
7
|
+
className: appendClassNames(className, 'humany-contact-method-link'),
|
|
8
|
+
href: "".concat(protocol).concat(uri),
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export default LinkComponent;
|