@telia-ace/knowledge-widget-adapters 1.0.13 → 1.0.16
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 +5 -5
- package/README.md +3 -3
- package/{lib-esm → dist}/contact-methods/chat-popup/chat-popup-plugin.d.ts +2 -2
- package/{lib → dist}/contact-methods/chat-popup/index.d.ts +1 -1
- package/{lib-esm → dist}/contact-methods/email/email-form-component.d.ts +4 -4
- package/{lib-esm → dist}/contact-methods/email/email-plugin.d.ts +16 -16
- package/{lib-esm → dist}/contact-methods/email/index.d.ts +1 -1
- package/{lib → dist}/contact-methods/free-text/free-text-component.d.ts +4 -4
- package/{lib → dist}/contact-methods/free-text/free-text-plugin.d.ts +2 -2
- package/{lib → dist}/contact-methods/free-text/index.d.ts +1 -1
- package/{lib → dist}/contact-methods/index.d.ts +10 -10
- package/{lib-esm → dist}/contact-methods/link/index.d.ts +1 -1
- package/{lib → dist}/contact-methods/link/link-component.d.ts +4 -4
- package/{lib → dist}/contact-methods/link/link-plugin.d.ts +2 -2
- package/{lib-esm → dist}/contact-methods/phone/index.d.ts +1 -1
- package/{lib → dist}/contact-methods/phone/phone-component.d.ts +4 -4
- package/{lib → dist}/contact-methods/phone/phone-plugin.d.ts +2 -2
- package/{lib-esm → dist}/contact-methods/platform.d.ts +50 -50
- package/{lib-esm → dist}/contact-methods/ui/confirmation.d.ts +6 -6
- package/{lib → dist}/contact-methods/ui/contact-list.d.ts +15 -15
- package/{lib → dist}/contact-methods/ui/contact-method.d.ts +39 -39
- package/{lib-esm → dist}/contact-methods/ui/description.d.ts +3 -2
- package/{lib-esm → dist}/contact-methods/ui/form.d.ts +4 -4
- package/{lib-esm → dist}/contact-methods/ui/index.d.ts +7 -7
- package/{lib-esm → dist}/contact-methods/ui/use-contact-method.d.ts +2 -2
- package/{lib-esm → dist}/contact-methods/web-service/index.d.ts +1 -1
- package/{lib-esm → dist}/contact-methods/web-service/web-service-plugin.d.ts +2 -2
- package/{lib-esm → dist}/create-adapter.d.ts +7 -7
- package/{lib-esm → dist}/default-contact-methods-plugin.d.ts +8 -8
- package/dist/email-form-component.js +63 -0
- package/dist/email-form-component.js.map +1 -0
- package/dist/free-text-component.js +31 -0
- package/dist/free-text-component.js.map +1 -0
- package/{lib-esm → dist}/index.d.ts +5 -5
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/index2.js +699 -0
- package/dist/index2.js.map +1 -0
- package/dist/link-component.js +16 -0
- package/dist/link-component.js.map +1 -0
- package/dist/phone-component.js +15 -0
- package/dist/phone-component.js.map +1 -0
- package/package.json +14 -15
- package/lib/contact-methods/chat-popup/chat-popup-plugin.d.ts +0 -2
- package/lib/contact-methods/chat-popup/chat-popup-plugin.js +0 -79
- package/lib/contact-methods/chat-popup/index.js +0 -8
- package/lib/contact-methods/email/email-form-component.d.ts +0 -4
- package/lib/contact-methods/email/email-form-component.js +0 -58
- package/lib/contact-methods/email/email-plugin.d.ts +0 -16
- package/lib/contact-methods/email/email-plugin.js +0 -83
- package/lib/contact-methods/email/index.d.ts +0 -1
- package/lib/contact-methods/email/index.js +0 -12
- package/lib/contact-methods/free-text/free-text-component.js +0 -49
- package/lib/contact-methods/free-text/free-text-plugin.js +0 -34
- package/lib/contact-methods/free-text/index.js +0 -8
- package/lib/contact-methods/index.js +0 -31
- package/lib/contact-methods/link/index.d.ts +0 -1
- package/lib/contact-methods/link/index.js +0 -8
- package/lib/contact-methods/link/link-component.js +0 -13
- package/lib/contact-methods/link/link-plugin.js +0 -34
- package/lib/contact-methods/phone/index.d.ts +0 -1
- package/lib/contact-methods/phone/index.js +0 -8
- package/lib/contact-methods/phone/phone-component.js +0 -12
- package/lib/contact-methods/phone/phone-plugin.js +0 -34
- package/lib/contact-methods/platform.d.ts +0 -50
- package/lib/contact-methods/platform.js +0 -273
- package/lib/contact-methods/ui/confirmation.d.ts +0 -6
- package/lib/contact-methods/ui/confirmation.js +0 -47
- package/lib/contact-methods/ui/contact-list.js +0 -61
- package/lib/contact-methods/ui/contact-method.js +0 -110
- package/lib/contact-methods/ui/description.d.ts +0 -2
- package/lib/contact-methods/ui/description.js +0 -13
- package/lib/contact-methods/ui/form.d.ts +0 -4
- package/lib/contact-methods/ui/form.js +0 -54
- package/lib/contact-methods/ui/index.d.ts +0 -7
- package/lib/contact-methods/ui/index.js +0 -20
- package/lib/contact-methods/ui/use-contact-method.d.ts +0 -2
- package/lib/contact-methods/ui/use-contact-method.js +0 -39
- package/lib/contact-methods/web-service/index.d.ts +0 -1
- package/lib/contact-methods/web-service/index.js +0 -8
- package/lib/contact-methods/web-service/web-service-plugin.d.ts +0 -2
- package/lib/contact-methods/web-service/web-service-plugin.js +0 -30
- package/lib/create-adapter.d.ts +0 -7
- package/lib/create-adapter.js +0 -43
- package/lib/default-contact-methods-plugin.d.ts +0 -8
- package/lib/default-contact-methods-plugin.js +0 -42
- package/lib/index.d.ts +0 -5
- package/lib/index.js +0 -25
- package/lib-esm/contact-methods/chat-popup/chat-popup-plugin.js +0 -76
- package/lib-esm/contact-methods/chat-popup/index.d.ts +0 -1
- package/lib-esm/contact-methods/chat-popup/index.js +0 -1
- package/lib-esm/contact-methods/email/email-form-component.js +0 -33
- package/lib-esm/contact-methods/email/email-plugin.js +0 -52
- package/lib-esm/contact-methods/email/index.js +0 -1
- package/lib-esm/contact-methods/free-text/free-text-component.d.ts +0 -4
- package/lib-esm/contact-methods/free-text/free-text-component.js +0 -21
- package/lib-esm/contact-methods/free-text/free-text-plugin.d.ts +0 -2
- package/lib-esm/contact-methods/free-text/free-text-plugin.js +0 -8
- package/lib-esm/contact-methods/free-text/index.d.ts +0 -1
- package/lib-esm/contact-methods/free-text/index.js +0 -1
- package/lib-esm/contact-methods/index.d.ts +0 -10
- package/lib-esm/contact-methods/index.js +0 -8
- package/lib-esm/contact-methods/link/index.js +0 -1
- package/lib-esm/contact-methods/link/link-component.d.ts +0 -4
- package/lib-esm/contact-methods/link/link-component.js +0 -11
- package/lib-esm/contact-methods/link/link-plugin.d.ts +0 -2
- package/lib-esm/contact-methods/link/link-plugin.js +0 -8
- package/lib-esm/contact-methods/phone/index.js +0 -1
- package/lib-esm/contact-methods/phone/phone-component.d.ts +0 -4
- package/lib-esm/contact-methods/phone/phone-component.js +0 -10
- package/lib-esm/contact-methods/phone/phone-plugin.d.ts +0 -2
- package/lib-esm/contact-methods/phone/phone-plugin.js +0 -8
- package/lib-esm/contact-methods/platform.js +0 -270
- package/lib-esm/contact-methods/ui/confirmation.js +0 -22
- package/lib-esm/contact-methods/ui/contact-list.d.ts +0 -15
- package/lib-esm/contact-methods/ui/contact-list.js +0 -32
- package/lib-esm/contact-methods/ui/contact-method.d.ts +0 -39
- package/lib-esm/contact-methods/ui/contact-method.js +0 -81
- package/lib-esm/contact-methods/ui/description.js +0 -8
- package/lib-esm/contact-methods/ui/form.js +0 -49
- package/lib-esm/contact-methods/ui/index.js +0 -6
- package/lib-esm/contact-methods/ui/use-contact-method.js +0 -37
- package/lib-esm/contact-methods/web-service/index.js +0 -1
- package/lib-esm/contact-methods/web-service/web-service-plugin.js +0 -27
- package/lib-esm/create-adapter.js +0 -39
- package/lib-esm/default-contact-methods-plugin.js +0 -39
- package/lib-esm/index.js +0 -3
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { FormComponent } from '@telia-ace/widget-forms';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
/**
|
|
4
|
-
* Recursively find form component in schema
|
|
5
|
-
* @param node Form schema
|
|
6
|
-
* @param id actionKey of component to find
|
|
7
|
-
*/
|
|
8
|
-
var lookupComponent = function (node, id) {
|
|
9
|
-
if (node.actionKey === id) {
|
|
10
|
-
return node;
|
|
11
|
-
}
|
|
12
|
-
if (!node.properties) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
var keys = Object.keys(node.properties);
|
|
16
|
-
var result;
|
|
17
|
-
// tslint:disable-next-line:no-increment-decrement
|
|
18
|
-
for (var i = 0; i < keys.length; i++) {
|
|
19
|
-
result = lookupComponent(node.properties[keys[i]], id);
|
|
20
|
-
if (result) {
|
|
21
|
-
return result;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return false;
|
|
25
|
-
};
|
|
26
|
-
var Form = function (_a) {
|
|
27
|
-
var className = _a.className, form = _a.body.form, id = _a.id, action = _a.action, dispatch = _a.dispatch, disabled = _a.disabled, autoFocus = _a.autoFocus;
|
|
28
|
-
if (form && !disabled) {
|
|
29
|
-
var schema_1 = form.schema, layout_1 = form.layout, data = form.data;
|
|
30
|
-
var trigger_1 = dispatch || action || (function () { });
|
|
31
|
-
return (React.createElement(FormComponent, { className: className, schema: schema_1, layout: layout_1, data: data, autoFocus: autoFocus, onChange: function (event, data) {
|
|
32
|
-
var form = { schema: schema_1, layout: layout_1, data: data };
|
|
33
|
-
if (event.toString() === 'submit') {
|
|
34
|
-
trigger_1('submit', { id: id, form: form });
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
var formComponent = lookupComponent(schema_1, event);
|
|
38
|
-
if (formComponent.evaluate) {
|
|
39
|
-
trigger_1('evaluate', { id: id, form: form });
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
trigger_1('validate', { id: id, form: form });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
} }));
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
};
|
|
49
|
-
export default Form;
|
|
@@ -1,6 +0,0 @@
|
|
|
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 { default as Description } from './description';
|
|
5
|
-
export { default as Form } from './form';
|
|
6
|
-
export { default as useContactMethod } from './use-contact-method';
|
|
@@ -1,37 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as WebServicePlugin } from './web-service-plugin';
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
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 };
|
package/lib-esm/index.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
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';
|