@telia-ace/knowledge-widget-adapters 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +6 -0
- package/README.md +3 -0
- package/lib/contact-methods/chat-popup/chat-popup-plugin.d.ts +2 -0
- package/lib/contact-methods/chat-popup/chat-popup-plugin.js +79 -0
- package/lib/contact-methods/chat-popup/index.d.ts +1 -0
- package/lib/contact-methods/chat-popup/index.js +8 -0
- package/lib/contact-methods/email/email-form-component.d.ts +4 -0
- package/lib/contact-methods/email/email-form-component.js +58 -0
- package/lib/contact-methods/email/email-plugin.d.ts +16 -0
- package/lib/contact-methods/email/email-plugin.js +83 -0
- package/lib/contact-methods/email/index.d.ts +1 -0
- package/lib/contact-methods/email/index.js +12 -0
- package/lib/contact-methods/free-text/free-text-component.d.ts +4 -0
- package/lib/contact-methods/free-text/free-text-component.js +49 -0
- package/lib/contact-methods/free-text/free-text-plugin.d.ts +2 -0
- package/lib/contact-methods/free-text/free-text-plugin.js +34 -0
- package/lib/contact-methods/free-text/index.d.ts +1 -0
- package/lib/contact-methods/free-text/index.js +8 -0
- package/lib/contact-methods/index.d.ts +10 -0
- package/lib/contact-methods/index.js +31 -0
- package/lib/contact-methods/link/index.d.ts +1 -0
- package/lib/contact-methods/link/index.js +8 -0
- package/lib/contact-methods/link/link-component.d.ts +4 -0
- package/lib/contact-methods/link/link-component.js +13 -0
- package/lib/contact-methods/link/link-plugin.d.ts +2 -0
- package/lib/contact-methods/link/link-plugin.js +34 -0
- package/lib/contact-methods/phone/index.d.ts +1 -0
- package/lib/contact-methods/phone/index.js +8 -0
- package/lib/contact-methods/phone/phone-component.d.ts +4 -0
- package/lib/contact-methods/phone/phone-component.js +12 -0
- package/lib/contact-methods/phone/phone-plugin.d.ts +2 -0
- package/lib/contact-methods/phone/phone-plugin.js +34 -0
- package/lib/contact-methods/platform.d.ts +49 -0
- package/lib/contact-methods/platform.js +256 -0
- package/lib/contact-methods/ui/confirmation.d.ts +6 -0
- package/lib/contact-methods/ui/confirmation.js +47 -0
- package/lib/contact-methods/ui/contact-list.d.ts +15 -0
- package/lib/contact-methods/ui/contact-list.js +61 -0
- package/lib/contact-methods/ui/contact-method.d.ts +39 -0
- package/lib/contact-methods/ui/contact-method.js +110 -0
- package/lib/contact-methods/ui/description.d.ts +3 -0
- package/lib/contact-methods/ui/description.js +13 -0
- package/lib/contact-methods/ui/form.d.ts +4 -0
- package/lib/contact-methods/ui/form.js +54 -0
- package/lib/contact-methods/ui/index.d.ts +7 -0
- package/lib/contact-methods/ui/index.js +20 -0
- package/lib/contact-methods/ui/use-contact-method.d.ts +2 -0
- package/lib/contact-methods/ui/use-contact-method.js +39 -0
- package/lib/contact-methods/web-service/index.d.ts +1 -0
- package/lib/contact-methods/web-service/index.js +8 -0
- package/lib/contact-methods/web-service/web-service-plugin.d.ts +2 -0
- package/lib/contact-methods/web-service/web-service-plugin.js +30 -0
- package/lib/create-adapter.d.ts +7 -0
- package/lib/create-adapter.js +43 -0
- package/lib/default-contact-methods-plugin.d.ts +8 -0
- package/lib/default-contact-methods-plugin.js +42 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +25 -0
- package/lib-esm/contact-methods/chat-popup/chat-popup-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/chat-popup/chat-popup-plugin.js +76 -0
- package/lib-esm/contact-methods/chat-popup/index.d.ts +1 -0
- package/lib-esm/contact-methods/chat-popup/index.js +1 -0
- package/lib-esm/contact-methods/email/email-form-component.d.ts +4 -0
- package/lib-esm/contact-methods/email/email-form-component.js +33 -0
- package/lib-esm/contact-methods/email/email-plugin.d.ts +16 -0
- package/lib-esm/contact-methods/email/email-plugin.js +52 -0
- package/lib-esm/contact-methods/email/index.d.ts +1 -0
- package/lib-esm/contact-methods/email/index.js +1 -0
- package/lib-esm/contact-methods/free-text/free-text-component.d.ts +4 -0
- package/lib-esm/contact-methods/free-text/free-text-component.js +21 -0
- package/lib-esm/contact-methods/free-text/free-text-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/free-text/free-text-plugin.js +8 -0
- package/lib-esm/contact-methods/free-text/index.d.ts +1 -0
- package/lib-esm/contact-methods/free-text/index.js +1 -0
- package/lib-esm/contact-methods/index.d.ts +10 -0
- package/lib-esm/contact-methods/index.js +8 -0
- package/lib-esm/contact-methods/link/index.d.ts +1 -0
- package/lib-esm/contact-methods/link/index.js +1 -0
- package/lib-esm/contact-methods/link/link-component.d.ts +4 -0
- package/lib-esm/contact-methods/link/link-component.js +11 -0
- package/lib-esm/contact-methods/link/link-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/link/link-plugin.js +8 -0
- package/lib-esm/contact-methods/phone/index.d.ts +1 -0
- package/lib-esm/contact-methods/phone/index.js +1 -0
- package/lib-esm/contact-methods/phone/phone-component.d.ts +4 -0
- package/lib-esm/contact-methods/phone/phone-component.js +10 -0
- package/lib-esm/contact-methods/phone/phone-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/phone/phone-plugin.js +8 -0
- package/lib-esm/contact-methods/platform.d.ts +49 -0
- package/lib-esm/contact-methods/platform.js +253 -0
- package/lib-esm/contact-methods/ui/confirmation.d.ts +6 -0
- package/lib-esm/contact-methods/ui/confirmation.js +22 -0
- package/lib-esm/contact-methods/ui/contact-list.d.ts +15 -0
- package/lib-esm/contact-methods/ui/contact-list.js +32 -0
- package/lib-esm/contact-methods/ui/contact-method.d.ts +39 -0
- package/lib-esm/contact-methods/ui/contact-method.js +81 -0
- package/lib-esm/contact-methods/ui/description.d.ts +3 -0
- package/lib-esm/contact-methods/ui/description.js +8 -0
- package/lib-esm/contact-methods/ui/form.d.ts +4 -0
- package/lib-esm/contact-methods/ui/form.js +49 -0
- package/lib-esm/contact-methods/ui/index.d.ts +7 -0
- package/lib-esm/contact-methods/ui/index.js +6 -0
- package/lib-esm/contact-methods/ui/use-contact-method.d.ts +2 -0
- package/lib-esm/contact-methods/ui/use-contact-method.js +37 -0
- package/lib-esm/contact-methods/web-service/index.d.ts +1 -0
- package/lib-esm/contact-methods/web-service/index.js +1 -0
- package/lib-esm/contact-methods/web-service/web-service-plugin.d.ts +2 -0
- package/lib-esm/contact-methods/web-service/web-service-plugin.js +27 -0
- package/lib-esm/create-adapter.d.ts +7 -0
- package/lib-esm/create-adapter.js +39 -0
- package/lib-esm/default-contact-methods-plugin.d.ts +8 -0
- package/lib-esm/default-contact-methods-plugin.js +39 -0
- package/lib-esm/index.d.ts +5 -0
- package/lib-esm/index.js +3 -0
- package/package.json +43 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PhonePlugin } from './phone-plugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as PhonePlugin } from './phone-plugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComponentPlatform } from '@telia-ace/knowledge-widget-core';
|
|
2
|
+
import { Form } from '@telia-ace/widget-forms';
|
|
3
|
+
import { Container } from '@webprovisions/platform';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { ContactMethodProps } from './ui';
|
|
6
|
+
export declare type ReactComponentImport = Promise<{
|
|
7
|
+
default: React.FunctionComponent<any>;
|
|
8
|
+
}>;
|
|
9
|
+
export declare type Click = (e: React.MouseEvent, cm: ContactMethodProps) => void;
|
|
10
|
+
export declare type AdapterSettings = {
|
|
11
|
+
clientName: string;
|
|
12
|
+
render: string | ReactComponentImport;
|
|
13
|
+
handleDescription?: (cm: ContactMethodProps) => Promise<string> | string;
|
|
14
|
+
handleDisabled?: (cm: ContactMethodProps) => Promise<boolean> | boolean;
|
|
15
|
+
handleClick?: (cm: ContactMethodProps) => Promise<Click> | Click;
|
|
16
|
+
onEvaluate?: (cm: ContactMethodProps) => Promise<Form> | Form;
|
|
17
|
+
onValidate?: (cm: ContactMethodProps) => Promise<ValidationResult> | ValidationResult;
|
|
18
|
+
onSubmit?: (cm: ContactMethodProps) => Promise<string> | string;
|
|
19
|
+
onComplete?: (cm: ContactMethodProps) => Promise<void> | void;
|
|
20
|
+
};
|
|
21
|
+
export declare type ValidationResult = {
|
|
22
|
+
errors?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
errorTypes?: {
|
|
26
|
+
[key: string]: string;
|
|
27
|
+
};
|
|
28
|
+
valid: boolean;
|
|
29
|
+
};
|
|
30
|
+
export declare enum ContactMethodTrackTypes {
|
|
31
|
+
ContactMethodValidate = "contact-method-validate",
|
|
32
|
+
ContactMethodComplete = "contact-method-complete"
|
|
33
|
+
}
|
|
34
|
+
declare class ContactMethodPlatform {
|
|
35
|
+
private container;
|
|
36
|
+
private componentPlatform;
|
|
37
|
+
private adapters;
|
|
38
|
+
private subs;
|
|
39
|
+
static create(container: Container): Promise<ContactMethodPlatform>;
|
|
40
|
+
constructor(container: Container, componentPlatform: ComponentPlatform);
|
|
41
|
+
private track;
|
|
42
|
+
complete(contactMethod: ContactMethodProps): void | Promise<void>;
|
|
43
|
+
evaluate(contactMethod: ContactMethodProps): Promise<Form>;
|
|
44
|
+
validate(contactMethod: ContactMethodProps): Promise<ValidationResult>;
|
|
45
|
+
submit(contactMethod: ContactMethodProps): Promise<string>;
|
|
46
|
+
create(settings: AdapterSettings): Promise<void>;
|
|
47
|
+
dispose(): void;
|
|
48
|
+
}
|
|
49
|
+
export default ContactMethodPlatform;
|
|
@@ -0,0 +1,253 @@
|
|
|
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 { lazy } from 'react';
|
|
50
|
+
import { defaultComplete, defaultEvaluate, defaultValidate } from './email';
|
|
51
|
+
export var ContactMethodTrackTypes;
|
|
52
|
+
(function (ContactMethodTrackTypes) {
|
|
53
|
+
ContactMethodTrackTypes["ContactMethodValidate"] = "contact-method-validate";
|
|
54
|
+
ContactMethodTrackTypes["ContactMethodComplete"] = "contact-method-complete";
|
|
55
|
+
})(ContactMethodTrackTypes || (ContactMethodTrackTypes = {}));
|
|
56
|
+
var handleContactMethod = function (adapters, contactMethod) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
+
var adapter, description, disabled, onClick, handleClick, handleDescription, handleDisabled;
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
switch (_a.label) {
|
|
60
|
+
case 0:
|
|
61
|
+
adapter = adapters.get(contactMethod.clientName);
|
|
62
|
+
description = contactMethod.description, disabled = contactMethod.disabled, onClick = contactMethod.onClick;
|
|
63
|
+
if (!adapter) return [3 /*break*/, 6];
|
|
64
|
+
handleClick = adapter.handleClick, handleDescription = adapter.handleDescription, handleDisabled = adapter.handleDisabled;
|
|
65
|
+
if (!(typeof handleClick === 'function')) return [3 /*break*/, 2];
|
|
66
|
+
return [4 /*yield*/, Promise.resolve(handleClick(contactMethod))];
|
|
67
|
+
case 1:
|
|
68
|
+
onClick = _a.sent();
|
|
69
|
+
_a.label = 2;
|
|
70
|
+
case 2:
|
|
71
|
+
if (!(typeof handleDescription === 'function')) return [3 /*break*/, 4];
|
|
72
|
+
return [4 /*yield*/, Promise.resolve(handleDescription(contactMethod))];
|
|
73
|
+
case 3:
|
|
74
|
+
description = _a.sent();
|
|
75
|
+
_a.label = 4;
|
|
76
|
+
case 4:
|
|
77
|
+
if (!(typeof handleDisabled === 'function')) return [3 /*break*/, 6];
|
|
78
|
+
return [4 /*yield*/, Promise.resolve(handleDisabled(contactMethod))];
|
|
79
|
+
case 5:
|
|
80
|
+
disabled = _a.sent();
|
|
81
|
+
_a.label = 6;
|
|
82
|
+
case 6: return [2 /*return*/, Promise.resolve(__assign(__assign({}, contactMethod), { description: description, disabled: disabled, onClick: onClick }))];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}); };
|
|
86
|
+
var ContactMethodPlatform = /** @class */ (function () {
|
|
87
|
+
function ContactMethodPlatform(container, componentPlatform) {
|
|
88
|
+
var _this = this;
|
|
89
|
+
this.container = container;
|
|
90
|
+
this.componentPlatform = componentPlatform;
|
|
91
|
+
this.adapters = new Map();
|
|
92
|
+
this.subs = [];
|
|
93
|
+
if (componentPlatform) {
|
|
94
|
+
var contactListComponent = componentPlatform
|
|
95
|
+
.components()
|
|
96
|
+
.ofType('contact-list')
|
|
97
|
+
.select();
|
|
98
|
+
contactListComponent.actions.watch('contact-list.fetched', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
99
|
+
var contactMethods, promises;
|
|
100
|
+
var _this = this;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
switch (_a.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
contactMethods = input.contactMethods;
|
|
105
|
+
if (!contactMethods) return [3 /*break*/, 2];
|
|
106
|
+
promises = Promise.all(contactMethods.map(function (cm) {
|
|
107
|
+
return handleContactMethod(_this.adapters, cm);
|
|
108
|
+
}));
|
|
109
|
+
return [4 /*yield*/, Promise.resolve(promises).then(function (contactMethods) {
|
|
110
|
+
input.contactMethods = contactMethods;
|
|
111
|
+
})];
|
|
112
|
+
case 1:
|
|
113
|
+
_a.sent();
|
|
114
|
+
_a.label = 2;
|
|
115
|
+
case 2: return [2 /*return*/, next(input)];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}); });
|
|
119
|
+
var guideComponent = componentPlatform.components().ofType('guide').select();
|
|
120
|
+
guideComponent.actions.watch('guide.fetched', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
121
|
+
var contactMethods, promises;
|
|
122
|
+
var _this = this;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
contactMethods = input.contactMethods;
|
|
127
|
+
if (!contactMethods) return [3 /*break*/, 2];
|
|
128
|
+
promises = Promise.all(contactMethods.map(function (cm) {
|
|
129
|
+
return handleContactMethod(_this.adapters, cm);
|
|
130
|
+
}));
|
|
131
|
+
return [4 /*yield*/, Promise.resolve(promises).then(function (contactMethods) {
|
|
132
|
+
input.contactMethods = contactMethods;
|
|
133
|
+
})];
|
|
134
|
+
case 1:
|
|
135
|
+
_a.sent();
|
|
136
|
+
_a.label = 2;
|
|
137
|
+
case 2: return [2 /*return*/, next(input)];
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}); });
|
|
141
|
+
guideComponent.actions.watch('guide.handover', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
142
|
+
var handoverContactMethods, promises;
|
|
143
|
+
var _this = this;
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
handoverContactMethods = input.handoverContactMethods;
|
|
148
|
+
if (!handoverContactMethods) return [3 /*break*/, 2];
|
|
149
|
+
promises = Promise.all(handoverContactMethods.map(function (cm) {
|
|
150
|
+
return handleContactMethod(_this.adapters, cm);
|
|
151
|
+
}));
|
|
152
|
+
return [4 /*yield*/, Promise.resolve(promises).then(function (handoverContactMethods) {
|
|
153
|
+
input.handoverContactMethods = handoverContactMethods;
|
|
154
|
+
})];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
_a.label = 2;
|
|
158
|
+
case 2: return [2 /*return*/, next(input)];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}); });
|
|
162
|
+
var contactMethodComponent = componentPlatform
|
|
163
|
+
.components()
|
|
164
|
+
.ofType('contact-method')
|
|
165
|
+
.select();
|
|
166
|
+
contactMethodComponent.actions.watch('contact-method.fetched', function (input, next) { return __awaiter(_this, void 0, void 0, function () {
|
|
167
|
+
var contactMethod;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
contactMethod = input.contactMethod;
|
|
170
|
+
if (contactMethod) {
|
|
171
|
+
return [2 /*return*/, handleContactMethod(this.adapters, contactMethod).then(function (contactMethod) {
|
|
172
|
+
return next(__assign(__assign({}, input), { contactMethod: contactMethod }));
|
|
173
|
+
})];
|
|
174
|
+
}
|
|
175
|
+
return [2 /*return*/, next(input)];
|
|
176
|
+
});
|
|
177
|
+
}); });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
ContactMethodPlatform.create = function (container) {
|
|
181
|
+
return ComponentPlatform.getInstance(container).then(function (platform) {
|
|
182
|
+
return new ContactMethodPlatform(container, platform);
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
ContactMethodPlatform.prototype.track = function (data, type) {
|
|
186
|
+
if (data === void 0) { data = {}; }
|
|
187
|
+
var events = this.container.get('$widget').events;
|
|
188
|
+
events.dispatch('tracking:service-client-response', {
|
|
189
|
+
type: type,
|
|
190
|
+
data: data,
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
ContactMethodPlatform.prototype.complete = function (contactMethod) {
|
|
194
|
+
var id = contactMethod.id, title = contactMethod.title, clientName = contactMethod.clientName, expanded = contactMethod.expanded, body = contactMethod.body;
|
|
195
|
+
this.track({ contactMethod: { id: id, title: title, expanded: expanded, type: clientName }, hasGuide: !!body.guideId }, ContactMethodTrackTypes.ContactMethodComplete);
|
|
196
|
+
var adapter = this.adapters.get(clientName);
|
|
197
|
+
if (adapter && adapter.onComplete) {
|
|
198
|
+
return adapter.onComplete(contactMethod);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
ContactMethodPlatform.prototype.evaluate = function (contactMethod) {
|
|
202
|
+
var clientName = contactMethod.clientName;
|
|
203
|
+
var adapter = this.adapters.get(clientName);
|
|
204
|
+
if (adapter && adapter.onEvaluate) {
|
|
205
|
+
return Promise.resolve(adapter.onEvaluate(contactMethod));
|
|
206
|
+
}
|
|
207
|
+
return Promise.resolve(contactMethod.body.form);
|
|
208
|
+
};
|
|
209
|
+
ContactMethodPlatform.prototype.validate = function (contactMethod) {
|
|
210
|
+
var _this = this;
|
|
211
|
+
var id = contactMethod.id, title = contactMethod.title, clientName = contactMethod.clientName;
|
|
212
|
+
var adapter = this.adapters.get(clientName);
|
|
213
|
+
if (adapter && adapter.onValidate) {
|
|
214
|
+
return Promise.resolve(adapter.onValidate(contactMethod)).then(function (result) {
|
|
215
|
+
_this.track({ contactMethod: { id: id, title: title, type: clientName }, isValid: result.valid }, ContactMethodTrackTypes.ContactMethodValidate);
|
|
216
|
+
var events = _this.container.get('$widget').events;
|
|
217
|
+
events.dispatch('form:validated', { isValid: result.valid });
|
|
218
|
+
return result;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return Promise.resolve({ valid: true });
|
|
222
|
+
};
|
|
223
|
+
ContactMethodPlatform.prototype.submit = function (contactMethod) {
|
|
224
|
+
var _this = this;
|
|
225
|
+
var clientName = contactMethod.clientName;
|
|
226
|
+
var adapter = this.adapters.get(clientName);
|
|
227
|
+
if (adapter && adapter.onSubmit) {
|
|
228
|
+
return Promise.resolve(adapter.onSubmit(contactMethod)).then(function (result) {
|
|
229
|
+
_this.complete(contactMethod);
|
|
230
|
+
return result;
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return Promise.resolve('');
|
|
234
|
+
};
|
|
235
|
+
ContactMethodPlatform.prototype.create = function (settings) {
|
|
236
|
+
var _this = this;
|
|
237
|
+
var clientName = settings.clientName, render = settings.render;
|
|
238
|
+
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));
|
|
239
|
+
return this.container.getAsync('componentResolver').then(function (resolver) {
|
|
240
|
+
if (typeof render === 'string') {
|
|
241
|
+
_this.subs.push(resolver.registerAlias(clientName, render));
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
_this.subs.push(resolver.registerComponent(clientName, lazy(function () { return render; })));
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
ContactMethodPlatform.prototype.dispose = function () {
|
|
249
|
+
this.subs.forEach(function (s) { return s(); });
|
|
250
|
+
};
|
|
251
|
+
return ContactMethodPlatform;
|
|
252
|
+
}());
|
|
253
|
+
export default ContactMethodPlatform;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,32 @@
|
|
|
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;
|
|
@@ -0,0 +1,39 @@
|
|
|
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>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
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: 30px;\n margin: 0 ", " 0 0;\n min-height: 30px;\n min-width: 30px;\n line-height: 30px;\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: 30px;\n margin: 0 ", " 0 0;\n min-height: 30px;\n min-width: 30px;\n line-height: 30px;\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.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.text; });
|
|
78
|
+
var StyledTitle = styled(StyledText)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n line-height: 30px;\n"], ["\n line-height: 30px;\n"])));
|
|
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;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
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>;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
@@ -0,0 +1,49 @@
|
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Confirmation } from './confirmation';
|
|
2
|
+
export { contactItemList, default as ContactList } from './contact-list';
|
|
3
|
+
export { contactLink, default as ContactMethod } from './contact-method';
|
|
4
|
+
export type { ContactMethodType, Props as ContactMethodProps } from './contact-method';
|
|
5
|
+
export { default as Description } from './description';
|
|
6
|
+
export { default as Form } from './form';
|
|
7
|
+
export { default as useContactMethod } from './use-contact-method';
|
|
@@ -0,0 +1,6 @@
|
|
|
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';
|