@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.
Files changed (127) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +3 -3
  3. package/{lib-esm → dist}/contact-methods/chat-popup/chat-popup-plugin.d.ts +2 -2
  4. package/{lib → dist}/contact-methods/chat-popup/index.d.ts +1 -1
  5. package/{lib-esm → dist}/contact-methods/email/email-form-component.d.ts +4 -4
  6. package/{lib-esm → dist}/contact-methods/email/email-plugin.d.ts +16 -16
  7. package/{lib-esm → dist}/contact-methods/email/index.d.ts +1 -1
  8. package/{lib → dist}/contact-methods/free-text/free-text-component.d.ts +4 -4
  9. package/{lib → dist}/contact-methods/free-text/free-text-plugin.d.ts +2 -2
  10. package/{lib → dist}/contact-methods/free-text/index.d.ts +1 -1
  11. package/{lib → dist}/contact-methods/index.d.ts +10 -10
  12. package/{lib-esm → dist}/contact-methods/link/index.d.ts +1 -1
  13. package/{lib → dist}/contact-methods/link/link-component.d.ts +4 -4
  14. package/{lib → dist}/contact-methods/link/link-plugin.d.ts +2 -2
  15. package/{lib-esm → dist}/contact-methods/phone/index.d.ts +1 -1
  16. package/{lib → dist}/contact-methods/phone/phone-component.d.ts +4 -4
  17. package/{lib → dist}/contact-methods/phone/phone-plugin.d.ts +2 -2
  18. package/{lib-esm → dist}/contact-methods/platform.d.ts +50 -50
  19. package/{lib-esm → dist}/contact-methods/ui/confirmation.d.ts +6 -6
  20. package/{lib → dist}/contact-methods/ui/contact-list.d.ts +15 -15
  21. package/{lib → dist}/contact-methods/ui/contact-method.d.ts +39 -39
  22. package/{lib-esm → dist}/contact-methods/ui/description.d.ts +3 -2
  23. package/{lib-esm → dist}/contact-methods/ui/form.d.ts +4 -4
  24. package/{lib-esm → dist}/contact-methods/ui/index.d.ts +7 -7
  25. package/{lib-esm → dist}/contact-methods/ui/use-contact-method.d.ts +2 -2
  26. package/{lib-esm → dist}/contact-methods/web-service/index.d.ts +1 -1
  27. package/{lib-esm → dist}/contact-methods/web-service/web-service-plugin.d.ts +2 -2
  28. package/{lib-esm → dist}/create-adapter.d.ts +7 -7
  29. package/{lib-esm → dist}/default-contact-methods-plugin.d.ts +8 -8
  30. package/dist/email-form-component.js +63 -0
  31. package/dist/email-form-component.js.map +1 -0
  32. package/dist/free-text-component.js +31 -0
  33. package/dist/free-text-component.js.map +1 -0
  34. package/{lib-esm → dist}/index.d.ts +5 -5
  35. package/dist/index.js +8 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/index2.js +699 -0
  38. package/dist/index2.js.map +1 -0
  39. package/dist/link-component.js +16 -0
  40. package/dist/link-component.js.map +1 -0
  41. package/dist/phone-component.js +15 -0
  42. package/dist/phone-component.js.map +1 -0
  43. package/package.json +14 -15
  44. package/lib/contact-methods/chat-popup/chat-popup-plugin.d.ts +0 -2
  45. package/lib/contact-methods/chat-popup/chat-popup-plugin.js +0 -79
  46. package/lib/contact-methods/chat-popup/index.js +0 -8
  47. package/lib/contact-methods/email/email-form-component.d.ts +0 -4
  48. package/lib/contact-methods/email/email-form-component.js +0 -58
  49. package/lib/contact-methods/email/email-plugin.d.ts +0 -16
  50. package/lib/contact-methods/email/email-plugin.js +0 -83
  51. package/lib/contact-methods/email/index.d.ts +0 -1
  52. package/lib/contact-methods/email/index.js +0 -12
  53. package/lib/contact-methods/free-text/free-text-component.js +0 -49
  54. package/lib/contact-methods/free-text/free-text-plugin.js +0 -34
  55. package/lib/contact-methods/free-text/index.js +0 -8
  56. package/lib/contact-methods/index.js +0 -31
  57. package/lib/contact-methods/link/index.d.ts +0 -1
  58. package/lib/contact-methods/link/index.js +0 -8
  59. package/lib/contact-methods/link/link-component.js +0 -13
  60. package/lib/contact-methods/link/link-plugin.js +0 -34
  61. package/lib/contact-methods/phone/index.d.ts +0 -1
  62. package/lib/contact-methods/phone/index.js +0 -8
  63. package/lib/contact-methods/phone/phone-component.js +0 -12
  64. package/lib/contact-methods/phone/phone-plugin.js +0 -34
  65. package/lib/contact-methods/platform.d.ts +0 -50
  66. package/lib/contact-methods/platform.js +0 -273
  67. package/lib/contact-methods/ui/confirmation.d.ts +0 -6
  68. package/lib/contact-methods/ui/confirmation.js +0 -47
  69. package/lib/contact-methods/ui/contact-list.js +0 -61
  70. package/lib/contact-methods/ui/contact-method.js +0 -110
  71. package/lib/contact-methods/ui/description.d.ts +0 -2
  72. package/lib/contact-methods/ui/description.js +0 -13
  73. package/lib/contact-methods/ui/form.d.ts +0 -4
  74. package/lib/contact-methods/ui/form.js +0 -54
  75. package/lib/contact-methods/ui/index.d.ts +0 -7
  76. package/lib/contact-methods/ui/index.js +0 -20
  77. package/lib/contact-methods/ui/use-contact-method.d.ts +0 -2
  78. package/lib/contact-methods/ui/use-contact-method.js +0 -39
  79. package/lib/contact-methods/web-service/index.d.ts +0 -1
  80. package/lib/contact-methods/web-service/index.js +0 -8
  81. package/lib/contact-methods/web-service/web-service-plugin.d.ts +0 -2
  82. package/lib/contact-methods/web-service/web-service-plugin.js +0 -30
  83. package/lib/create-adapter.d.ts +0 -7
  84. package/lib/create-adapter.js +0 -43
  85. package/lib/default-contact-methods-plugin.d.ts +0 -8
  86. package/lib/default-contact-methods-plugin.js +0 -42
  87. package/lib/index.d.ts +0 -5
  88. package/lib/index.js +0 -25
  89. package/lib-esm/contact-methods/chat-popup/chat-popup-plugin.js +0 -76
  90. package/lib-esm/contact-methods/chat-popup/index.d.ts +0 -1
  91. package/lib-esm/contact-methods/chat-popup/index.js +0 -1
  92. package/lib-esm/contact-methods/email/email-form-component.js +0 -33
  93. package/lib-esm/contact-methods/email/email-plugin.js +0 -52
  94. package/lib-esm/contact-methods/email/index.js +0 -1
  95. package/lib-esm/contact-methods/free-text/free-text-component.d.ts +0 -4
  96. package/lib-esm/contact-methods/free-text/free-text-component.js +0 -21
  97. package/lib-esm/contact-methods/free-text/free-text-plugin.d.ts +0 -2
  98. package/lib-esm/contact-methods/free-text/free-text-plugin.js +0 -8
  99. package/lib-esm/contact-methods/free-text/index.d.ts +0 -1
  100. package/lib-esm/contact-methods/free-text/index.js +0 -1
  101. package/lib-esm/contact-methods/index.d.ts +0 -10
  102. package/lib-esm/contact-methods/index.js +0 -8
  103. package/lib-esm/contact-methods/link/index.js +0 -1
  104. package/lib-esm/contact-methods/link/link-component.d.ts +0 -4
  105. package/lib-esm/contact-methods/link/link-component.js +0 -11
  106. package/lib-esm/contact-methods/link/link-plugin.d.ts +0 -2
  107. package/lib-esm/contact-methods/link/link-plugin.js +0 -8
  108. package/lib-esm/contact-methods/phone/index.js +0 -1
  109. package/lib-esm/contact-methods/phone/phone-component.d.ts +0 -4
  110. package/lib-esm/contact-methods/phone/phone-component.js +0 -10
  111. package/lib-esm/contact-methods/phone/phone-plugin.d.ts +0 -2
  112. package/lib-esm/contact-methods/phone/phone-plugin.js +0 -8
  113. package/lib-esm/contact-methods/platform.js +0 -270
  114. package/lib-esm/contact-methods/ui/confirmation.js +0 -22
  115. package/lib-esm/contact-methods/ui/contact-list.d.ts +0 -15
  116. package/lib-esm/contact-methods/ui/contact-list.js +0 -32
  117. package/lib-esm/contact-methods/ui/contact-method.d.ts +0 -39
  118. package/lib-esm/contact-methods/ui/contact-method.js +0 -81
  119. package/lib-esm/contact-methods/ui/description.js +0 -8
  120. package/lib-esm/contact-methods/ui/form.js +0 -49
  121. package/lib-esm/contact-methods/ui/index.js +0 -6
  122. package/lib-esm/contact-methods/ui/use-contact-method.js +0 -37
  123. package/lib-esm/contact-methods/web-service/index.js +0 -1
  124. package/lib-esm/contact-methods/web-service/web-service-plugin.js +0 -27
  125. package/lib-esm/create-adapter.js +0 -39
  126. package/lib-esm/default-contact-methods-plugin.js +0 -39
  127. package/lib-esm/index.js +0 -3
@@ -1,110 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __assign = (this && this.__assign) || function () {
7
- __assign = Object.assign || function(t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
- t[p] = s[p];
12
- }
13
- return t;
14
- };
15
- return __assign.apply(this, arguments);
16
- };
17
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- var desc = Object.getOwnPropertyDescriptor(m, k);
20
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
- desc = { enumerable: true, get: function() { return m[k]; } };
22
- }
23
- Object.defineProperty(o, k2, desc);
24
- }) : (function(o, m, k, k2) {
25
- if (k2 === undefined) k2 = k;
26
- o[k2] = m[k];
27
- }));
28
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
- Object.defineProperty(o, "default", { enumerable: true, value: v });
30
- }) : function(o, v) {
31
- o["default"] = v;
32
- });
33
- var __importStar = (this && this.__importStar) || function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.contactLink = void 0;
45
- var knowledge_widget_ui_1 = require("@telia-ace/knowledge-widget-ui");
46
- var widget_utilities_1 = require("@telia-ace/widget-utilities");
47
- var react_1 = __importStar(require("react"));
48
- var styled_components_1 = __importStar(require("styled-components"));
49
- var description_1 = __importDefault(require("./description"));
50
- var ContactMethod = function (props) {
51
- var ResolvedComponent = (0, knowledge_widget_ui_1.useComponent)(props.clientName);
52
- var _a = (0, knowledge_widget_ui_1.useRouteData)().params, contactCategory = _a.contactCategory, guideCategory = _a.guideCategory, phrase = _a.phrase;
53
- if (typeof ResolvedComponent === 'undefined') {
54
- return null;
55
- }
56
- if (ResolvedComponent === null) {
57
- if (process.env.NODE_ENV !== 'production') {
58
- return (react_1.default.createElement(NonResolvedContactMethodWrapper, { title: "client-name: ".concat(props.clientName, ", id: ").concat(props.id), className: "humany-non-resolved-contact-method" },
59
- react_1.default.createElement(knowledge_widget_ui_1.Typography, { variant: "h5" }, "Non resolved Contact Method type")));
60
- }
61
- return null;
62
- }
63
- var renderLink = function (extraProps) {
64
- if (extraProps === void 0) { extraProps = {}; }
65
- var enhancedProps = __assign(__assign({}, props), extraProps);
66
- var id = enhancedProps.id, title = enhancedProps.title, clientName = enhancedProps.clientName, symbol = enhancedProps.symbol, inline = enhancedProps.inline, _a = enhancedProps.onClick, onClick = _a === void 0 ? function () { } : _a, description = enhancedProps.description, htmlParseInstruction = enhancedProps.htmlParseInstruction, className = enhancedProps.className, disabled = enhancedProps.disabled, guideId = enhancedProps.guideId, _b = enhancedProps.dispatch, dispatch = _b === void 0 ? function () { } : _b, expanded = enhancedProps.expanded;
67
- var linkProps = inline
68
- ? {
69
- onKeyDown: function (event) {
70
- if (event.key && event.key === 'Enter') {
71
- onClick(event, enhancedProps);
72
- if (!event.defaultPrevented) {
73
- !expanded && dispatch('expand', id);
74
- }
75
- }
76
- },
77
- onClick: function (event) {
78
- onClick(event, enhancedProps);
79
- if (!event.defaultPrevented) {
80
- !expanded && dispatch('expand', id);
81
- }
82
- },
83
- }
84
- : {
85
- onClick: function (event) { return onClick(event, enhancedProps); },
86
- routeName: 'contact-method',
87
- params: (0, widget_utilities_1.createParams)({
88
- contactCategory: contactCategory,
89
- guideId: guideId,
90
- guideCategory: guideCategory,
91
- phrase: phrase,
92
- contactMethod: id,
93
- uriName: (0, widget_utilities_1.formatUrl)(title),
94
- }),
95
- };
96
- return (react_1.default.createElement(StyledLink, __assign({ title: title, "aria-label": title, className: className, disabled: disabled, description: description, "data-client-name": clientName }, extraProps, linkProps),
97
- symbol && react_1.default.createElement(knowledge_widget_ui_1.SymbolBadge, { symbol: symbol }),
98
- description ? (react_1.default.createElement("div", { className: "humany-contact-link-rich-content" },
99
- react_1.default.createElement(StyledTitle, null, title),
100
- react_1.default.createElement(description_1.default, { html: description, htmlParseInstruction: htmlParseInstruction }))) : (react_1.default.createElement(StyledTitle, null, title))));
101
- };
102
- return props.expanded ? (react_1.default.createElement(react_1.Suspense, { fallback: null },
103
- react_1.default.createElement(ResolvedComponent, __assign({}, props, { renderDefault: renderLink })))) : (renderLink());
104
- };
105
- exports.default = ContactMethod;
106
- exports.contactLink = (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n padding: ", ";\n ", "\n text-decoration: none;\n span {\n display: inline-block;\n color: ", ";\n }\n i {\n font-size: ", ";\n margin: 0 ", " 0 0;\n min-height: ", ";\n min-width: ", ";\n line-height: ", ";\n display: inline-block;\n vertical-align: bottom;\n color: ", ";\n }\n"], ["\n display: flex;\n padding: ", ";\n ", "\n text-decoration: none;\n span {\n display: inline-block;\n color: ", ";\n }\n i {\n font-size: ", ";\n margin: 0 ", " 0 0;\n min-height: ", ";\n min-width: ", ";\n line-height: ", ";\n display: inline-block;\n vertical-align: bottom;\n color: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { return (!!p.description ? '' : 'align-items: center;'); }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
107
- var StyledTitle = (0, styled_components_1.default)(knowledge_widget_ui_1.StyledText)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n line-height: ", ";\n"], ["\n line-height: ", ";\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.large; });
108
- var StyledLink = (0, styled_components_1.default)(knowledge_widget_ui_1.Link)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n\n &:focus {\n ", ";\n }\n"], ["\n ", "\n\n &:focus {\n ", ";\n }\n"])), exports.contactLink, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && knowledge_widget_ui_1.borderTabStyle; });
109
- var NonResolvedContactMethodWrapper = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n text-align: center;\n display: block;\n ", "\n"], ["\n text-align: center;\n display: block;\n ", "\n"])), function (p) { var _a, _b; return typeof ((_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.warning) !== 'undefined' && "color: ".concat((_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.warning, ";"); });
110
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1,2 +0,0 @@
1
- declare const _default: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<Pick<import("@telia-ace/knowledge-widget-ui").HtmlProps, "html" | "key" | keyof import("react").HTMLAttributes<HTMLDivElement> | "htmlParseInstruction"> & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
2
- export default _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- var knowledge_widget_ui_1 = require("@telia-ace/knowledge-widget-ui");
11
- var styled_components_1 = __importDefault(require("styled-components"));
12
- exports.default = (0, styled_components_1.default)(knowledge_widget_ui_1.Html)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", "\n font-weight: 300;\n line-height: 1.5em;\n button:focus {\n ", ";\n }\n\n a:focus {\n ", ";\n }\n"], ["\n ", "\n font-weight: 300;\n line-height: 1.5em;\n button:focus {\n ", ";\n }\n\n a:focus {\n ", ";\n }\n"])), knowledge_widget_ui_1.genericHtml, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && knowledge_widget_ui_1.borderTabStyle; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && knowledge_widget_ui_1.linkTabStyle; });
13
- var templateObject_1;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { ContactMethodProps } from '.';
3
- declare const Form: React.SFC<ContactMethodProps>;
4
- export default Form;
@@ -1,54 +0,0 @@
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;
@@ -1,7 +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 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';
@@ -1,20 +0,0 @@
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; } });
@@ -1,2 +0,0 @@
1
- declare const useContactMethod: (clientName: string) => any | null;
2
- export default useContactMethod;
@@ -1,39 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export { default as WebServicePlugin } from './web-service-plugin';
@@ -1,8 +0,0 @@
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; } });
@@ -1,2 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- export default function webServicePlugin(container: Container): void;
@@ -1,30 +0,0 @@
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;
@@ -1,7 +0,0 @@
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>;
@@ -1,43 +0,0 @@
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;
@@ -1,8 +0,0 @@
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
- }
@@ -1,42 +0,0 @@
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 DELETED
@@ -1,5 +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 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 DELETED
@@ -1,25 +0,0 @@
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; } });
@@ -1,76 +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
- 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
- }
@@ -1 +0,0 @@
1
- export { default as ChatPopupPlugin } from './chat-popup-plugin';
@@ -1 +0,0 @@
1
- export { default as ChatPopupPlugin } from './chat-popup-plugin';
@@ -1,33 +0,0 @@
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;
@@ -1,52 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { complete as defaultComplete, default as EmailPlugin, evaluate as defaultEvaluate, submit as defaultSubmit, validate as defaultValidate, } from './email-plugin';
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { ContactMethodProps } from '../ui';
3
- declare const FreeTextComponent: React.SFC<ContactMethodProps>;
4
- export default FreeTextComponent;