@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,21 +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
- 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;
@@ -1,2 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- export default function freeTextPlugin(container: Container): void;
@@ -1,8 +0,0 @@
1
- export default function freeTextPlugin(container) {
2
- container.getAsync('contactMethods').then(function (platform) {
3
- platform.create({
4
- clientName: 'custom.freetext',
5
- render: import('./free-text-component'),
6
- });
7
- });
8
- }
@@ -1 +0,0 @@
1
- export { default as FreeTextPlugin } from './free-text-plugin';
@@ -1 +0,0 @@
1
- export { default as FreeTextPlugin } from './free-text-plugin';
@@ -1,10 +0,0 @@
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';
@@ -1,8 +0,0 @@
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';
@@ -1 +0,0 @@
1
- export { default as LinkPlugin } from './link-plugin';
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { ContactMethodProps } from '../ui';
3
- declare const LinkComponent: React.SFC<ContactMethodProps>;
4
- export default LinkComponent;
@@ -1,11 +0,0 @@
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;
@@ -1,2 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- export default function linkPlugin(container: Container): void;
@@ -1,8 +0,0 @@
1
- export default function linkPlugin(container) {
2
- container.getAsync('contactMethods').then(function (platform) {
3
- platform.create({
4
- clientName: 'custom.link',
5
- render: import('./link-component'),
6
- });
7
- });
8
- }
@@ -1 +0,0 @@
1
- export { default as PhonePlugin } from './phone-plugin';
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { ContactMethodProps } from '../ui';
3
- declare const PhoneComponent: React.SFC<ContactMethodProps>;
4
- export default PhoneComponent;
@@ -1,10 +0,0 @@
1
- import { appendClassNames } from '@telia-ace/widget-utilities';
2
- var PhoneComponent = function (_a) {
3
- var className = _a.className, phoneNumber = _a.body.phoneNumber, _b = _a.renderDefault, renderDefault = _b === void 0 ? function () { } : _b;
4
- return renderDefault({
5
- title: phoneNumber,
6
- className: appendClassNames(className, 'humany-contact-method-phone'),
7
- href: "tel: ".concat(phoneNumber),
8
- });
9
- };
10
- export default PhoneComponent;
@@ -1,2 +0,0 @@
1
- import { Container } from '@webprovisions/platform';
2
- export default function phonePlugin(container: Container): void;
@@ -1,8 +0,0 @@
1
- export default function phonePlugin(container) {
2
- container.getAsync('contactMethods').then(function (platform) {
3
- platform.create({
4
- clientName: 'phone.text',
5
- render: import('./phone-component'),
6
- });
7
- });
8
- }
@@ -1,270 +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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import { ComponentPlatform } from '@telia-ace/knowledge-widget-core';
49
- import { lock } from '@telia-ace/widget-utilities';
50
- import { lazy } from 'react';
51
- import { defaultComplete, defaultEvaluate, defaultValidate } from './email';
52
- export var ContactMethodTrackTypes;
53
- (function (ContactMethodTrackTypes) {
54
- ContactMethodTrackTypes["ContactMethodValidate"] = "contact-method-validate";
55
- ContactMethodTrackTypes["ContactMethodComplete"] = "contact-method-complete";
56
- })(ContactMethodTrackTypes || (ContactMethodTrackTypes = {}));
57
- var handleContactMethod = function (adapters, contactMethod) { return __awaiter(void 0, void 0, void 0, function () {
58
- var adapter, description, disabled, onClick, handleClick, handleDescription, handleDisabled;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0:
62
- adapter = adapters.get(contactMethod.clientName);
63
- description = contactMethod.description, disabled = contactMethod.disabled, onClick = contactMethod.onClick;
64
- if (!adapter) return [3 /*break*/, 6];
65
- handleClick = adapter.handleClick, handleDescription = adapter.handleDescription, handleDisabled = adapter.handleDisabled;
66
- if (!(typeof handleClick === 'function')) return [3 /*break*/, 2];
67
- return [4 /*yield*/, Promise.resolve(handleClick(contactMethod))];
68
- case 1:
69
- onClick = _a.sent();
70
- _a.label = 2;
71
- case 2:
72
- if (!(typeof handleDescription === 'function')) return [3 /*break*/, 4];
73
- return [4 /*yield*/, Promise.resolve(handleDescription(contactMethod))];
74
- case 3:
75
- description = _a.sent();
76
- _a.label = 4;
77
- case 4:
78
- if (!(typeof handleDisabled === 'function')) return [3 /*break*/, 6];
79
- return [4 /*yield*/, Promise.resolve(handleDisabled(contactMethod))];
80
- case 5:
81
- disabled = _a.sent();
82
- _a.label = 6;
83
- case 6: return [2 /*return*/, Promise.resolve(__assign(__assign({}, contactMethod), { description: description, disabled: disabled, onClick: onClick }))];
84
- }
85
- });
86
- }); };
87
- var ContactMethodPlatform = /** @class */ (function () {
88
- function ContactMethodPlatform(container, componentPlatform) {
89
- var _this = this;
90
- this.container = container;
91
- this.componentPlatform = componentPlatform;
92
- this.adapters = new Map();
93
- this.subs = [];
94
- if (componentPlatform) {
95
- var contactListComponent = componentPlatform
96
- .components()
97
- .ofType('contact-list')
98
- .select();
99
- contactListComponent.actions.watch('contact-list.fetched', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
100
- var contactMethods, promises;
101
- var _this = this;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0:
105
- contactMethods = input.contactMethods;
106
- if (!contactMethods) return [3 /*break*/, 2];
107
- promises = Promise.all(contactMethods.map(function (cm) {
108
- return handleContactMethod(_this.adapters, cm);
109
- }));
110
- return [4 /*yield*/, Promise.resolve(promises).then(function (contactMethods) {
111
- input.contactMethods = contactMethods;
112
- })];
113
- case 1:
114
- _a.sent();
115
- _a.label = 2;
116
- case 2: return [2 /*return*/, next(input)];
117
- }
118
- });
119
- }); });
120
- var guideComponent = componentPlatform.components().ofType('guide').select();
121
- guideComponent.actions.watch('guide.fetched', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
122
- var contactMethods, promises;
123
- var _this = this;
124
- return __generator(this, function (_a) {
125
- switch (_a.label) {
126
- case 0:
127
- contactMethods = input.contactMethods;
128
- if (!contactMethods) return [3 /*break*/, 2];
129
- promises = Promise.all(contactMethods.map(function (cm) {
130
- return handleContactMethod(_this.adapters, cm);
131
- }));
132
- return [4 /*yield*/, Promise.resolve(promises).then(function (contactMethods) {
133
- input.contactMethods = contactMethods;
134
- })];
135
- case 1:
136
- _a.sent();
137
- _a.label = 2;
138
- case 2: return [2 /*return*/, next(input)];
139
- }
140
- });
141
- }); });
142
- guideComponent.actions.watch('guide.handover', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
143
- var handoverContactMethods, promises;
144
- var _this = this;
145
- return __generator(this, function (_a) {
146
- switch (_a.label) {
147
- case 0:
148
- handoverContactMethods = input.handoverContactMethods;
149
- if (!handoverContactMethods) return [3 /*break*/, 2];
150
- promises = Promise.all(handoverContactMethods.map(function (cm) {
151
- return handleContactMethod(_this.adapters, cm);
152
- }));
153
- return [4 /*yield*/, Promise.resolve(promises).then(function (handoverContactMethods) {
154
- input.handoverContactMethods = handoverContactMethods;
155
- })];
156
- case 1:
157
- _a.sent();
158
- _a.label = 2;
159
- case 2: return [2 /*return*/, next(input)];
160
- }
161
- });
162
- }); });
163
- var contactMethodComponent = componentPlatform
164
- .components()
165
- .ofType('contact-method')
166
- .select();
167
- contactMethodComponent.actions.watch('contact-method.fetched', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
168
- var contactMethod;
169
- return __generator(this, function (_a) {
170
- contactMethod = input.contactMethod;
171
- if (contactMethod) {
172
- return [2 /*return*/, handleContactMethod(this.adapters, contactMethod).then(function (contactMethod) {
173
- return next(__assign(__assign({}, input), { contactMethod: contactMethod }));
174
- })];
175
- }
176
- return [2 /*return*/, next(input)];
177
- });
178
- }); });
179
- }
180
- }
181
- ContactMethodPlatform.create = function (container) {
182
- return ComponentPlatform.getInstance(container).then(function (platform) {
183
- return new ContactMethodPlatform(container, platform);
184
- });
185
- };
186
- ContactMethodPlatform.getInstance = function (container, key) {
187
- if (key === void 0) { key = 'contactMethods'; }
188
- return lock(container)(function () {
189
- return container.getAsync(key).then(function (value) {
190
- var contactMethodPlatform = value;
191
- if (!contactMethodPlatform) {
192
- return ComponentPlatform.getInstance(container).then(function (components) {
193
- contactMethodPlatform = new ContactMethodPlatform(container, components);
194
- container.registerAsync(key, function () { return contactMethodPlatform; });
195
- return contactMethodPlatform;
196
- });
197
- }
198
- return contactMethodPlatform;
199
- });
200
- });
201
- };
202
- ContactMethodPlatform.prototype.track = function (data, type) {
203
- if (data === void 0) { data = {}; }
204
- var events = this.container.get('$widget').events;
205
- events.dispatch('tracking:service-client-response', {
206
- type: type,
207
- data: data,
208
- });
209
- };
210
- ContactMethodPlatform.prototype.complete = function (contactMethod) {
211
- var id = contactMethod.id, title = contactMethod.title, clientName = contactMethod.clientName, expanded = contactMethod.expanded, body = contactMethod.body;
212
- this.track({ contactMethod: { id: id, title: title, expanded: expanded, type: clientName }, hasGuide: !!body.guideId }, ContactMethodTrackTypes.ContactMethodComplete);
213
- var adapter = this.adapters.get(clientName);
214
- if (adapter && adapter.onComplete) {
215
- return adapter.onComplete(contactMethod);
216
- }
217
- };
218
- ContactMethodPlatform.prototype.evaluate = function (contactMethod) {
219
- var clientName = contactMethod.clientName;
220
- var adapter = this.adapters.get(clientName);
221
- if (adapter && adapter.onEvaluate) {
222
- return Promise.resolve(adapter.onEvaluate(contactMethod));
223
- }
224
- return Promise.resolve(contactMethod.body.form);
225
- };
226
- ContactMethodPlatform.prototype.validate = function (contactMethod) {
227
- var _this = this;
228
- var id = contactMethod.id, title = contactMethod.title, clientName = contactMethod.clientName;
229
- var adapter = this.adapters.get(clientName);
230
- if (adapter && adapter.onValidate) {
231
- return Promise.resolve(adapter.onValidate(contactMethod)).then(function (result) {
232
- _this.track({ contactMethod: { id: id, title: title, type: clientName }, isValid: result.valid }, ContactMethodTrackTypes.ContactMethodValidate);
233
- var events = _this.container.get('$widget').events;
234
- events.dispatch('form:validated', { isValid: result.valid });
235
- return result;
236
- });
237
- }
238
- return Promise.resolve({ valid: true });
239
- };
240
- ContactMethodPlatform.prototype.submit = function (contactMethod) {
241
- var _this = this;
242
- var clientName = contactMethod.clientName;
243
- var adapter = this.adapters.get(clientName);
244
- if (adapter && adapter.onSubmit) {
245
- return Promise.resolve(adapter.onSubmit(contactMethod)).then(function (result) {
246
- _this.complete(contactMethod);
247
- return result;
248
- });
249
- }
250
- return Promise.resolve('');
251
- };
252
- ContactMethodPlatform.prototype.create = function (settings) {
253
- var _this = this;
254
- var clientName = settings.clientName, render = settings.render;
255
- this.adapters.set(clientName, __assign({ onValidate: function (cm) { return defaultValidate(_this.container, cm); }, onEvaluate: function (cm) { return defaultEvaluate(_this.container, cm); }, onComplete: function (cm) { return defaultComplete(_this.container, cm); } }, settings));
256
- return this.container.getAsync('componentResolver').then(function (resolver) {
257
- if (typeof render === 'string') {
258
- _this.subs.push(resolver.registerAlias(clientName, render));
259
- }
260
- else {
261
- _this.subs.push(resolver.registerComponent(clientName, lazy(function () { return render; })));
262
- }
263
- });
264
- };
265
- ContactMethodPlatform.prototype.dispose = function () {
266
- this.subs.forEach(function (s) { return s(); });
267
- };
268
- return ContactMethodPlatform;
269
- }());
270
- export default ContactMethodPlatform;
@@ -1,22 +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 { headingElement, Paragraph } from '@telia-ace/knowledge-widget-ui';
17
- import * as React from 'react';
18
- import styled, { css } from 'styled-components';
19
- var Confirmation = function (props) { return (React.createElement(StyledParagraph, __assign({}, props, { className: "humany-confirmation" }))); };
20
- export default Confirmation;
21
- var StyledParagraph = styled(Paragraph)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), 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 templateObject_1, templateObject_2;
@@ -1,15 +0,0 @@
1
- import { DispatchAction } from '@telia-ace/knowledge-widget-ui';
2
- import React, { ReactNode } from 'react';
3
- import { ContactMethodType } from './contact-method';
4
- export declare const contactItemList: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<any>>;
5
- declare type Props = {
6
- contactMethods: ContactMethodType[];
7
- header?: string;
8
- className?: string;
9
- action?: (action: string, value?: any) => void;
10
- dispatch?: DispatchAction;
11
- children?: ReactNode;
12
- guideId?: string;
13
- };
14
- declare const ContactList: React.SFC<Props>;
15
- export default ContactList;
@@ -1,32 +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 { headingElement, ItemList, itemList } from '@telia-ace/knowledge-widget-ui';
17
- import { appendClassNames } from '@telia-ace/widget-utilities';
18
- import React from 'react';
19
- import styled, { css } from 'styled-components';
20
- import ContactMethod from './contact-method';
21
- export var contactItemList = css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n\n > div {\n padding: ", ";\n\n ", "\n }\n > ul {\n &:not(:first-child) {\n border-top: ", ";\n }\n\n > li {\n margin: 0;\n white-space: normal;\n\n > a {\n overflow: hidden;\n }\n\n &:first-child > a {\n border-radius: ", ";\n }\n\n &:last-child:not(:first-child) > a {\n border-radius: ", ";\n }\n\n &:not(:last-child) {\n border-bottom: ", ";\n }\n\n > div {\n padding: ", ";\n }\n }\n }\n\n @media (hover: hover) {\n a:hover {\n background-color: ", ";\n }\n }\n"], ["\n ", "\n\n > div {\n padding: ", ";\n\n ", "\n }\n > ul {\n &:not(:first-child) {\n border-top: ", ";\n }\n\n > li {\n margin: 0;\n white-space: normal;\n\n > a {\n overflow: hidden;\n }\n\n &:first-child > a {\n border-radius: ", ";\n }\n\n &:last-child:not(:first-child) > a {\n border-radius: ", ";\n }\n\n &:not(:last-child) {\n border-bottom: ", ";\n }\n\n > div {\n padding: ", ";\n }\n }\n }\n\n @media (hover: hover) {\n a:hover {\n background-color: ", ";\n }\n }\n"])), itemList, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; }, headingElement('h1', css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin: 0;\n "], ["\n margin: 0;\n "])))), function (p) { return p.theme.border; }, function (p) { return "".concat(p.theme.borderRadius, " ").concat(p.theme.borderRadius, " 0 0"); }, function (p) { return "0 0 ".concat(p.theme.borderRadius, " ").concat(p.theme.borderRadius); }, function (p) { return p.theme.border; }, 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.colors) === null || _a === void 0 ? void 0 : _a.accent; });
22
- var StyledItemList = styled(ItemList)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n"], ["\n ", "\n"])), contactItemList);
23
- var ContactList = function (_a) {
24
- var contactMethods = _a.contactMethods, children = _a.children, guideId = _a.guideId, dispatch = _a.dispatch, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.action, action = _c === void 0 ? function () { } : _c, _d = _a.header, header = _d === void 0 ? '' : _d;
25
- if (!contactMethods.length) {
26
- return null;
27
- }
28
- return (React.createElement(StyledItemList, { header: header, className: appendClassNames(className, 'humany-contact-list'), items: contactMethods, renderItem: function (cm) { return (React.createElement("li", { key: cm.id, "data-contact-method": cm.id },
29
- React.createElement(ContactMethod, __assign({}, cm, { action: action, dispatch: dispatch, guideId: guideId })))); } }, children));
30
- };
31
- export default ContactList;
32
- var templateObject_1, templateObject_2, templateObject_3;
@@ -1,39 +0,0 @@
1
- import { Symbol } from '@telia-ace/knowledge-widget-core';
2
- import { DispatchAction, HtmlParseInstruction } from '@telia-ace/knowledge-widget-ui';
3
- import React from 'react';
4
- export declare type ContactMethodType = {
5
- id: string;
6
- title: string;
7
- symbol?: Symbol;
8
- clientName: string;
9
- expanded: boolean;
10
- inline: boolean;
11
- body: {
12
- [key: string]: any;
13
- };
14
- description?: string;
15
- confirmation?: string;
16
- disabled?: boolean;
17
- guideId?: string;
18
- };
19
- export declare type Props = Merge<ContactMethodType, {
20
- className?: string;
21
- onClick?: (event: React.MouseEvent, properties: Props) => void;
22
- renderDefault?: (extraProps?: Partial<Props>) => any;
23
- htmlParseInstruction?: HtmlParseInstruction;
24
- href?: string;
25
- target?: string;
26
- disabled?: boolean;
27
- action?: (action: string, value: any) => void;
28
- dispatch?: DispatchAction;
29
- symbol?: Symbol;
30
- description?: string;
31
- confirmation?: string;
32
- guideId?: string;
33
- autoFocus?: boolean;
34
- }>;
35
- declare const ContactMethod: React.FC<Props>;
36
- export default ContactMethod;
37
- export declare const contactLink: import("styled-components").FlattenInterpolation<import("styled-components").ThemedStyledProps<{
38
- description?: string | undefined;
39
- }, any>>;
@@ -1,81 +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 { borderTabStyle, Link, StyledText, SymbolBadge, Typography, useComponent, useRouteData, } from '@telia-ace/knowledge-widget-ui';
17
- import { createParams, formatUrl } from '@telia-ace/widget-utilities';
18
- import React, { Suspense } from 'react';
19
- import styled, { css } from 'styled-components';
20
- import Description from './description';
21
- var ContactMethod = function (props) {
22
- var ResolvedComponent = useComponent(props.clientName);
23
- var _a = useRouteData().params, contactCategory = _a.contactCategory, guideCategory = _a.guideCategory, phrase = _a.phrase;
24
- if (typeof ResolvedComponent === 'undefined') {
25
- return null;
26
- }
27
- if (ResolvedComponent === null) {
28
- if (process.env.NODE_ENV !== 'production') {
29
- return (React.createElement(NonResolvedContactMethodWrapper, { title: "client-name: ".concat(props.clientName, ", id: ").concat(props.id), className: "humany-non-resolved-contact-method" },
30
- React.createElement(Typography, { variant: "h5" }, "Non resolved Contact Method type")));
31
- }
32
- return null;
33
- }
34
- var renderLink = function (extraProps) {
35
- if (extraProps === void 0) { extraProps = {}; }
36
- var enhancedProps = __assign(__assign({}, props), extraProps);
37
- 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;
38
- var linkProps = inline
39
- ? {
40
- onKeyDown: function (event) {
41
- if (event.key && event.key === 'Enter') {
42
- onClick(event, enhancedProps);
43
- if (!event.defaultPrevented) {
44
- !expanded && dispatch('expand', id);
45
- }
46
- }
47
- },
48
- onClick: function (event) {
49
- onClick(event, enhancedProps);
50
- if (!event.defaultPrevented) {
51
- !expanded && dispatch('expand', id);
52
- }
53
- },
54
- }
55
- : {
56
- onClick: function (event) { return onClick(event, enhancedProps); },
57
- routeName: 'contact-method',
58
- params: createParams({
59
- contactCategory: contactCategory,
60
- guideId: guideId,
61
- guideCategory: guideCategory,
62
- phrase: phrase,
63
- contactMethod: id,
64
- uriName: formatUrl(title),
65
- }),
66
- };
67
- return (React.createElement(StyledLink, __assign({ title: title, "aria-label": title, className: className, disabled: disabled, description: description, "data-client-name": clientName }, extraProps, linkProps),
68
- symbol && React.createElement(SymbolBadge, { symbol: symbol }),
69
- description ? (React.createElement("div", { className: "humany-contact-link-rich-content" },
70
- React.createElement(StyledTitle, null, title),
71
- React.createElement(Description, { html: description, htmlParseInstruction: htmlParseInstruction }))) : (React.createElement(StyledTitle, null, title))));
72
- };
73
- return props.expanded ? (React.createElement(Suspense, { fallback: null },
74
- React.createElement(ResolvedComponent, __assign({}, props, { renderDefault: renderLink })))) : (renderLink());
75
- };
76
- export default ContactMethod;
77
- export var contactLink = 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; });
78
- var StyledTitle = styled(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; });
79
- var StyledLink = styled(Link)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n\n &:focus {\n ", ";\n }\n"], ["\n ", "\n\n &:focus {\n ", ";\n }\n"])), contactLink, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && borderTabStyle; });
80
- var NonResolvedContactMethodWrapper = styled.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, ";"); });
81
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -1,8 +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
- import { borderTabStyle, genericHtml, Html, linkTabStyle } from '@telia-ace/knowledge-widget-ui';
6
- import styled from 'styled-components';
7
- export default styled(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"])), genericHtml, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && borderTabStyle; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && linkTabStyle; });
8
- var templateObject_1;