@telia-ace/widget-conversation 1.0.0
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 +256 -0
- package/lib/agent.d.ts +17 -0
- package/lib/agent.js +37 -0
- package/lib/conversation-controller.d.ts +87 -0
- package/lib/conversation-controller.js +298 -0
- package/lib/conversation-form-adapter.d.ts +7 -0
- package/lib/conversation-form-adapter.js +88 -0
- package/lib/conversation-platform.d.ts +49 -0
- package/lib/conversation-platform.js +295 -0
- package/lib/conversation-provider.d.ts +22 -0
- package/lib/conversation-provider.js +73 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +15 -0
- package/lib/resolve-entity-value.d.ts +10 -0
- package/lib/resolve-entity-value.js +22 -0
- package/lib/types.d.ts +35 -0
- package/lib/types.js +2 -0
- package/lib/ui/conversation/conversation-component.d.ts +32 -0
- package/lib/ui/conversation/conversation-component.js +152 -0
- package/lib/ui/conversation/conversation-content.d.ts +11 -0
- package/lib/ui/conversation/conversation-content.js +100 -0
- package/lib/ui/conversation/conversation-input.d.ts +6 -0
- package/lib/ui/conversation/conversation-input.js +154 -0
- package/lib/ui/conversation/conversation-loader.d.ts +8 -0
- package/lib/ui/conversation/conversation-loader.js +18 -0
- package/lib/ui/conversation/conversation-message.d.ts +7 -0
- package/lib/ui/conversation/conversation-message.js +141 -0
- package/lib/ui/conversation/conversation-styles.d.ts +9 -0
- package/lib/ui/conversation/conversation-styles.js +63 -0
- package/lib/ui/conversation/conversation.d.ts +6 -0
- package/lib/ui/conversation/conversation.js +139 -0
- package/lib/ui/conversation/index.d.ts +2 -0
- package/lib/ui/conversation/index.js +7 -0
- package/lib/ui/conversation/message-types/agent.d.ts +11 -0
- package/lib/ui/conversation/message-types/agent.js +54 -0
- package/lib/ui/conversation/message-types/custom.d.ts +9 -0
- package/lib/ui/conversation/message-types/custom.js +26 -0
- package/lib/ui/conversation/message-types/index.d.ts +5 -0
- package/lib/ui/conversation/message-types/index.js +16 -0
- package/lib/ui/conversation/message-types/system.d.ts +12 -0
- package/lib/ui/conversation/message-types/system.js +26 -0
- package/lib/ui/conversation/message-types/timestamp.d.ts +8 -0
- package/lib/ui/conversation/message-types/timestamp.js +36 -0
- package/lib/ui/conversation/message-types/user.d.ts +8 -0
- package/lib/ui/conversation/message-types/user.js +24 -0
- package/lib/ui/index.d.ts +2 -0
- package/lib/ui/index.js +10 -0
- package/lib/ui/return-button/index.d.ts +2 -0
- package/lib/ui/return-button/index.js +7 -0
- package/lib/ui/return-button/return-button-component.d.ts +19 -0
- package/lib/ui/return-button/return-button-component.js +70 -0
- package/lib/ui/return-button/return-button.d.ts +6 -0
- package/lib/ui/return-button/return-button.js +82 -0
- package/lib/user.d.ts +7 -0
- package/lib/user.js +16 -0
- package/lib/utils/custom-message.d.ts +3 -0
- package/lib/utils/custom-message.js +56 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +7 -0
- package/lib/utils/open-chat-widget.d.ts +4 -0
- package/lib/utils/open-chat-widget.js +148 -0
- package/lib-esm/agent.d.ts +17 -0
- package/lib-esm/agent.js +34 -0
- package/lib-esm/conversation-controller.d.ts +87 -0
- package/lib-esm/conversation-controller.js +294 -0
- package/lib-esm/conversation-form-adapter.d.ts +7 -0
- package/lib-esm/conversation-form-adapter.js +85 -0
- package/lib-esm/conversation-platform.d.ts +49 -0
- package/lib-esm/conversation-platform.js +292 -0
- package/lib-esm/conversation-provider.d.ts +22 -0
- package/lib-esm/conversation-provider.js +70 -0
- package/lib-esm/index.d.ts +8 -0
- package/lib-esm/index.js +5 -0
- package/lib-esm/resolve-entity-value.d.ts +10 -0
- package/lib-esm/resolve-entity-value.js +18 -0
- package/lib-esm/types.d.ts +35 -0
- package/lib-esm/types.js +1 -0
- package/lib-esm/ui/conversation/conversation-component.d.ts +32 -0
- package/lib-esm/ui/conversation/conversation-component.js +127 -0
- package/lib-esm/ui/conversation/conversation-content.d.ts +11 -0
- package/lib-esm/ui/conversation/conversation-content.js +72 -0
- package/lib-esm/ui/conversation/conversation-input.d.ts +6 -0
- package/lib-esm/ui/conversation/conversation-input.js +129 -0
- package/lib-esm/ui/conversation/conversation-loader.d.ts +8 -0
- package/lib-esm/ui/conversation/conversation-loader.js +13 -0
- package/lib-esm/ui/conversation/conversation-message.d.ts +7 -0
- package/lib-esm/ui/conversation/conversation-message.js +113 -0
- package/lib-esm/ui/conversation/conversation-styles.d.ts +9 -0
- package/lib-esm/ui/conversation/conversation-styles.js +37 -0
- package/lib-esm/ui/conversation/conversation.d.ts +6 -0
- package/lib-esm/ui/conversation/conversation.js +111 -0
- package/lib-esm/ui/conversation/index.d.ts +2 -0
- package/lib-esm/ui/conversation/index.js +2 -0
- package/lib-esm/ui/conversation/message-types/agent.d.ts +11 -0
- package/lib-esm/ui/conversation/message-types/agent.js +25 -0
- package/lib-esm/ui/conversation/message-types/custom.d.ts +9 -0
- package/lib-esm/ui/conversation/message-types/custom.js +21 -0
- package/lib-esm/ui/conversation/message-types/index.d.ts +5 -0
- package/lib-esm/ui/conversation/message-types/index.js +5 -0
- package/lib-esm/ui/conversation/message-types/system.d.ts +12 -0
- package/lib-esm/ui/conversation/message-types/system.js +20 -0
- package/lib-esm/ui/conversation/message-types/timestamp.d.ts +8 -0
- package/lib-esm/ui/conversation/message-types/timestamp.js +31 -0
- package/lib-esm/ui/conversation/message-types/user.d.ts +8 -0
- package/lib-esm/ui/conversation/message-types/user.js +19 -0
- package/lib-esm/ui/index.d.ts +2 -0
- package/lib-esm/ui/index.js +2 -0
- package/lib-esm/ui/return-button/index.d.ts +2 -0
- package/lib-esm/ui/return-button/index.js +2 -0
- package/lib-esm/ui/return-button/return-button-component.d.ts +19 -0
- package/lib-esm/ui/return-button/return-button-component.js +44 -0
- package/lib-esm/ui/return-button/return-button.d.ts +6 -0
- package/lib-esm/ui/return-button/return-button.js +54 -0
- package/lib-esm/user.d.ts +7 -0
- package/lib-esm/user.js +13 -0
- package/lib-esm/utils/custom-message.d.ts +3 -0
- package/lib-esm/utils/custom-message.js +52 -0
- package/lib-esm/utils/index.d.ts +1 -0
- package/lib-esm/utils/index.js +1 -0
- package/lib-esm/utils/open-chat-widget.d.ts +4 -0
- package/lib-esm/utils/open-chat-widget.js +142 -0
- package/package.json +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { useComponent } from '@telia-ace/widget-ui';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { MessageContent, MessageContentPart } from '../conversation-styles';
|
|
15
|
+
var CustomMessage = function (props) {
|
|
16
|
+
var CustomComponent = useComponent(props.type);
|
|
17
|
+
return (React.createElement(MessageContent, { user: props.isUser, stacked: !!props.stacked && props.stacked, fullWidth: !!props.content.form || !!props.content.actions },
|
|
18
|
+
React.createElement(MessageContentPart, null,
|
|
19
|
+
React.createElement(CustomComponent, __assign({}, props.content)))));
|
|
20
|
+
};
|
|
21
|
+
export default CustomMessage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type Props = {
|
|
3
|
+
className?: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
discrete?: boolean;
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
children: any;
|
|
8
|
+
};
|
|
9
|
+
declare const SystemMessage: React.FC<Props>;
|
|
10
|
+
export declare const StyledSystemMessage: import("styled-components").StyledComponent<"div", any, any, never>;
|
|
11
|
+
export declare const Discrete: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
+
export default SystemMessage;
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { appendClassNames } from '@telia-ace/widget-utilities';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import Timestamp from './timestamp';
|
|
9
|
+
var SystemMessage = function (_a) {
|
|
10
|
+
var className = _a.className, children = _a.children, timestamp = _a.timestamp, discrete = _a.discrete, fullWidth = _a.fullWidth;
|
|
11
|
+
return (React.createElement(StyledSystemMessage, { className: appendClassNames(className, 'humany-conversation-system-message'), fullWidth: fullWidth }, discrete ? (React.createElement(Discrete, { className: "humany-conversation-discrete-message" },
|
|
12
|
+
children,
|
|
13
|
+
React.createElement(Timestamp, { timestamp: timestamp }))) : (React.createElement(React.Fragment, null,
|
|
14
|
+
children,
|
|
15
|
+
React.createElement(Timestamp, { timestamp: timestamp })))));
|
|
16
|
+
};
|
|
17
|
+
export var StyledSystemMessage = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n padding: 0 ", ";\n overflow: auto;\n"], ["\n ", ";\n padding: 0 ", ";\n overflow: auto;\n"])), function (p) { return p.fullWidth && 'width: 100%'; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large; });
|
|
18
|
+
export var Discrete = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n text-align: center;\n word-wrap: break-word;\n font-size: ", ";\n color: ", ";\n > p {\n margin: 0;\n }\n"], ["\n text-align: center;\n word-wrap: break-word;\n font-size: ", ";\n color: ", ";\n > p {\n margin: 0;\n }\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
|
|
19
|
+
export default SystemMessage;
|
|
20
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,31 @@
|
|
|
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 React from 'react';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
var StyledTimestamp = styled.p(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n font-size: ", ";\n font-weight: 300;\n }\n margin: 0;\n line-height: 1.5em;\n grid-area: info;\n color: ", ";\n"], ["\n && {\n font-size: ", ";\n font-weight: 300;\n }\n margin: 0;\n line-height: 1.5em;\n grid-area: info;\n color: ", ";\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.small; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
|
|
8
|
+
var getTimestamp = function (raw) {
|
|
9
|
+
return new Date(raw).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
10
|
+
};
|
|
11
|
+
var Timestamp = function (_a) {
|
|
12
|
+
var className = _a.className, name = _a.name, timestamp = _a.timestamp;
|
|
13
|
+
if (!name && !timestamp) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
var output = '';
|
|
17
|
+
if (name) {
|
|
18
|
+
if (timestamp) {
|
|
19
|
+
output = "".concat(name, ": ").concat(getTimestamp(timestamp));
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
output = name;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (timestamp) {
|
|
26
|
+
output = getTimestamp(timestamp);
|
|
27
|
+
}
|
|
28
|
+
return React.createElement(StyledTimestamp, null, output);
|
|
29
|
+
};
|
|
30
|
+
export default Timestamp;
|
|
31
|
+
var templateObject_1;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { useProperties } from '@telia-ace/widget-ui';
|
|
6
|
+
import { appendClassNames } from '@telia-ace/widget-utilities';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import styled from 'styled-components';
|
|
9
|
+
import Timestamp from './timestamp';
|
|
10
|
+
var UserMessage = function (_a) {
|
|
11
|
+
var className = _a.className, children = _a.children, timestamp = _a.timestamp;
|
|
12
|
+
var _b = useProperties().userLabel, userLabel = _b === void 0 ? '' : _b;
|
|
13
|
+
return (React.createElement(StyledUserMessage, { className: appendClassNames(className, 'humany-conversation-user-message') },
|
|
14
|
+
children,
|
|
15
|
+
React.createElement(Timestamp, { name: userLabel, timestamp: timestamp })));
|
|
16
|
+
};
|
|
17
|
+
var StyledUserMessage = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-left: 15%;\n width: 85%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n"], ["\n margin-left: 15%;\n width: 85%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n"])));
|
|
18
|
+
export default UserMessage;
|
|
19
|
+
var templateObject_1;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Symbol } from '@telia-ace/widget-ui';
|
|
2
|
+
import { Container } from '@webprovisions/platform';
|
|
3
|
+
export declare enum ButtonMode {
|
|
4
|
+
flat = "flat",
|
|
5
|
+
flashing = "flashing",
|
|
6
|
+
flashingGradient = "flashingGradient"
|
|
7
|
+
}
|
|
8
|
+
export declare type ReturnButtonProps = {
|
|
9
|
+
label: string;
|
|
10
|
+
active: boolean;
|
|
11
|
+
mode: ButtonMode;
|
|
12
|
+
alert?: {
|
|
13
|
+
symbol?: Symbol;
|
|
14
|
+
show?: boolean;
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
declare const ConversationReturnButtonComponent: (container: Container) => Promise<void>;
|
|
19
|
+
export default ConversationReturnButtonComponent;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
+
if (!m) return o;
|
|
4
|
+
var i = m.call(o), r, ar = [], e;
|
|
5
|
+
try {
|
|
6
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
+
}
|
|
8
|
+
catch (error) { e = { error: error }; }
|
|
9
|
+
finally {
|
|
10
|
+
try {
|
|
11
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
+
}
|
|
13
|
+
finally { if (e) throw e.error; }
|
|
14
|
+
}
|
|
15
|
+
return ar;
|
|
16
|
+
};
|
|
17
|
+
import { ComponentPlatform } from '@telia-ace/widget-core';
|
|
18
|
+
import { createReactComponent } from '@telia-ace/widget-ui';
|
|
19
|
+
import { ConversationPlatform } from '../../';
|
|
20
|
+
export var ButtonMode;
|
|
21
|
+
(function (ButtonMode) {
|
|
22
|
+
ButtonMode["flat"] = "flat";
|
|
23
|
+
ButtonMode["flashing"] = "flashing";
|
|
24
|
+
ButtonMode["flashingGradient"] = "flashingGradient";
|
|
25
|
+
})(ButtonMode || (ButtonMode = {}));
|
|
26
|
+
var ConversationReturnButtonComponent = function (container) {
|
|
27
|
+
return Promise.all([
|
|
28
|
+
ComponentPlatform.getInstance(container),
|
|
29
|
+
ConversationPlatform.getInstance(container),
|
|
30
|
+
container.getAsync('router'),
|
|
31
|
+
]).then(function (_a) {
|
|
32
|
+
var _b = __read(_a, 3), components = _b[0], platform = _b[1], router = _b[2];
|
|
33
|
+
return createReactComponent(container, 'conversation-return-button', import('./return-button'), function (component) {
|
|
34
|
+
component.actions.create('toggle', function (options) {
|
|
35
|
+
var _a;
|
|
36
|
+
if (options === void 0) { options = {}; }
|
|
37
|
+
(_a = platform.getComponentRoute()) === null || _a === void 0 ? void 0 : _a.then(function (route) {
|
|
38
|
+
route && router.navigate(route.name, route.params);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export default ConversationReturnButtonComponent;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
6
|
+
var t = {};
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
10
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
11
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
12
|
+
t[p[i]] = s[p[i]];
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
// import { Component } from '@telia-ace/widget-types-grid';
|
|
17
|
+
import { borderTabStyle, Button, SymbolBadge, useDispatch, useProperties, } from '@telia-ace/widget-ui';
|
|
18
|
+
import React from 'react';
|
|
19
|
+
import styled, { css, keyframes } from 'styled-components';
|
|
20
|
+
var ReturnButton = function (_a) {
|
|
21
|
+
var className = _a.className, other = __rest(_a, ["className"]);
|
|
22
|
+
var _b = useProperties(), label = _b.label, active = _b.active, _c = _b.mode, mode = _c === void 0 ? 'flat' : _c, _d = _b.alert, alert = _d === void 0 ? {} : _d;
|
|
23
|
+
var symbol = alert.symbol, alertLabel = alert.label, showAlert = alert.show;
|
|
24
|
+
// const [showAlert, setShowAlert] = useState(show);
|
|
25
|
+
var dispatch = useDispatch();
|
|
26
|
+
if (!active) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return (React.createElement(StyledHighlightedButton, { className: className, mode: mode, "aria-label": label, onClick: function () {
|
|
30
|
+
dispatch('toggle');
|
|
31
|
+
} },
|
|
32
|
+
React.createElement(StyledLabel, null, label),
|
|
33
|
+
symbol && (React.createElement(StyledIconHolder, { showAlert: showAlert },
|
|
34
|
+
React.createElement(SymbolBadge, { symbol: symbol, title: alertLabel, size: 20 })))));
|
|
35
|
+
};
|
|
36
|
+
var FlashingColorAnimation = function (props) {
|
|
37
|
+
var _a, _b, _c;
|
|
38
|
+
return keyframes(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n 0% {\n background-color: ", ";\n }\n 50% {\n background-color: ", ";\n }\n 100 {\n background-color: ", ";\n }\n"], ["\n 0% {\n background-color: ", ";\n }\n 50% {\n background-color: ", ";\n }\n 100 {\n background-color: ", ";\n }\n"])), (_a = props.theme.colors) === null || _a === void 0 ? void 0 : _a.primary, (_b = props.theme.colors) === null || _b === void 0 ? void 0 : _b.accent, (_c = props.theme.colors) === null || _c === void 0 ? void 0 : _c.primary);
|
|
39
|
+
};
|
|
40
|
+
var ScrollingGradientAnimation = function (props) { return keyframes(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n 0% {\n background-position:0% 51%\n }\n 50% {\n background-position:100% 0%\n }\n 100% {\n background-position:0% 51%\n }\n"], ["\n 0% {\n background-position:0% 51%\n }\n 50% {\n background-position:100% 0%\n }\n 100% {\n background-position:0% 51%\n }\n"]))); };
|
|
41
|
+
var PulsatingIcon = keyframes(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n 0% {\n transform: rotate(0deg) scale(1.00);\n }\n 50% {\n transform: rotate(0deg) scale(1.00);\n }\n 55% {\n transform: rotate(-3deg) scale(0.80);\n }\n 60% {\n transform: rotate(-3deg) scale(0.80);\n }\n 65% {\n transform: rotate(3deg) scale(1.20);\n }\n 70% {\n transform: rotate(-3deg) scale(1.20);\n }\n 75% {\n transform: rotate(3deg) scale(1.20);\n }\n 80% {\n transform: rotate(-3deg) scale(1.20);\n }\n 85% {\n transform: rotate(3deg) scale(1.20);\n }\n 90% {\n transform: rotate(-3deg) scale(1.20);\n }\n 95% {\n transform: rotate(3deg) scale(1.20);\n }\n 100% {\n transform: rotate(0deg) scale(1);\n }\n"], ["\n 0% {\n transform: rotate(0deg) scale(1.00);\n }\n 50% {\n transform: rotate(0deg) scale(1.00);\n }\n 55% {\n transform: rotate(-3deg) scale(0.80);\n }\n 60% {\n transform: rotate(-3deg) scale(0.80);\n }\n 65% {\n transform: rotate(3deg) scale(1.20);\n }\n 70% {\n transform: rotate(-3deg) scale(1.20);\n }\n 75% {\n transform: rotate(3deg) scale(1.20);\n }\n 80% {\n transform: rotate(-3deg) scale(1.20);\n }\n 85% {\n transform: rotate(3deg) scale(1.20);\n }\n 90% {\n transform: rotate(-3deg) scale(1.20);\n }\n 95% {\n transform: rotate(3deg) scale(1.20);\n }\n 100% {\n transform: rotate(0deg) scale(1);\n }\n"])));
|
|
42
|
+
var StyledIconHolder = styled.span(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n flex-grow: 0;\n transform: translateX(", ");\n opacity: ", ";\n transition: transform 0.5s ease, opacity 0.3s ease;\n"], ["\n flex-grow: 0;\n transform: translateX(", ");\n opacity: ", ";\n transition: transform 0.5s ease, opacity 0.3s ease;\n"])), function (p) { return (p.showAlert ? '0px' : '50px'); }, function (p) { return (p.showAlert ? 1 : 0); });
|
|
43
|
+
var StyledLabel = styled.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n flex: 1;\n font-weight: 300;\n"], ["\n flex: 1;\n font-weight: 300;\n"])));
|
|
44
|
+
var flashingStyle = css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n animation: ", " 1s ease infinite;\n"], ["\n animation: ", " 1s ease infinite;\n"])), FlashingColorAnimation);
|
|
45
|
+
var flashingGradientStyle = css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n background: linear-gradient(\n 155deg,\n ", ",\n ", "\n );\n background-position: 0px 0px;\n background-size: 200% 200%;\n animation: ", " 1.5s ease infinite;\n"], ["\n background: linear-gradient(\n 155deg,\n ", ",\n ", "\n );\n background-position: 0px 0px;\n background-size: 200% 200%;\n animation: ", " 1.5s ease infinite;\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; }, ScrollingGradientAnimation);
|
|
46
|
+
var StyledHighlightedButton = styled(Button)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n overflow: hidden;\n padding: ", ";\n border-radius: ", ";\n color: ", ";\n ", "\n background-color: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n i,\n svg {\n animation: ", " 3s ease infinite;\n }\n\n &:focus {\n ", "\n background: ", ";\n color: ", ";\n }\n"], ["\n overflow: hidden;\n padding: ", ";\n border-radius: ", ";\n color: ", ";\n ", "\n background-color: ", ";\n display: flex;\n align-items: center;\n justify-content: center;\n i,\n svg {\n animation: ", " 3s ease infinite;\n }\n\n &:focus {\n ", "\n background: ", ";\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.theme.borderRadius; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) {
|
|
47
|
+
return p.mode === 'flashing'
|
|
48
|
+
? flashingStyle
|
|
49
|
+
: p.mode === 'flashingGradient'
|
|
50
|
+
? flashingGradientStyle
|
|
51
|
+
: '';
|
|
52
|
+
}, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, PulsatingIcon, 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.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; });
|
|
53
|
+
export default ReturnButton;
|
|
54
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConversationController, ConversationEntry } from './conversation-controller';
|
|
2
|
+
import { ConversationMessageSettings } from './types';
|
|
3
|
+
export declare class User {
|
|
4
|
+
private controller;
|
|
5
|
+
constructor(controller: ConversationController);
|
|
6
|
+
print: (settings: string | ConversationMessageSettings) => ConversationEntry;
|
|
7
|
+
}
|
package/lib-esm/user.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConversationMessageType, getNormalizedMessageSettings, } from './conversation-controller';
|
|
2
|
+
var User = /** @class */ (function () {
|
|
3
|
+
function User(controller) {
|
|
4
|
+
var _this = this;
|
|
5
|
+
this.controller = controller;
|
|
6
|
+
this.print = function (settings) {
|
|
7
|
+
var normalized = getNormalizedMessageSettings(settings);
|
|
8
|
+
return _this.controller.createEntry(normalized.key, normalized.content, ConversationMessageType.User, undefined, normalized.timestamp);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return User;
|
|
12
|
+
}());
|
|
13
|
+
export { User };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { lazy } from 'react';
|
|
38
|
+
import { ConversationPlatform } from '..';
|
|
39
|
+
export var registerCustomMessageComponent = function (container, type, component) {
|
|
40
|
+
return container.getAsync('componentResolver').then(function (o) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
+
var platform;
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
switch (_a.label) {
|
|
44
|
+
case 0: return [4 /*yield*/, ConversationPlatform.getInstance(container)];
|
|
45
|
+
case 1:
|
|
46
|
+
platform = _a.sent();
|
|
47
|
+
platform.addSubscription(o.registerComponent(type, lazy(function () { return component; })));
|
|
48
|
+
return [2 /*return*/];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}); });
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { navigateToConversation, openChatWidget, shouldPreventDefault } from './open-chat-widget';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { navigateToConversation, openChatWidget, shouldPreventDefault } from './open-chat-widget';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Container } from '@webprovisions/platform';
|
|
2
|
+
export declare const shouldPreventDefault: (container: Container) => boolean;
|
|
3
|
+
export declare const openChatWidget: (container: Container, contactMethod: any, triggerDOMTarget?: HTMLElement | undefined) => boolean | Promise<void> | Promise<boolean>;
|
|
4
|
+
export declare const navigateToConversation: (container: Container, contactMethod: any, routeName?: string) => any;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { closeAllModals } from '@telia-ace/widget-plugins';
|
|
2
|
+
import { createStorageWriter, StorageCategory, StorageMedium, StorageScope, } from '@telia-ace/widget-services';
|
|
3
|
+
import { ConversationEndedBehavior } from '../';
|
|
4
|
+
var getParentWidget = function (widgetName, implementation) {
|
|
5
|
+
var mainWidgetName = widgetName.split('_contact');
|
|
6
|
+
return implementation.widgets.get(mainWidgetName[0]);
|
|
7
|
+
};
|
|
8
|
+
var getSeparateWidget = function (container) {
|
|
9
|
+
var originWidget = container.get('$widget');
|
|
10
|
+
var _a = container.get('$widget'), name = _a.name, implementation = _a.implementation;
|
|
11
|
+
var mainWidget = name.indexOf('_contact') > -1 ? getParentWidget(name, implementation) : originWidget;
|
|
12
|
+
var data = container.get('$settings').data;
|
|
13
|
+
var trigger = mainWidget.container.get('$settings').trigger;
|
|
14
|
+
var chatWidgetName = "".concat(name
|
|
15
|
+
.replace('_contact-method', '')
|
|
16
|
+
.replace('_contact', ''), "_contact-method");
|
|
17
|
+
var chatWidget = implementation.widgets.get(chatWidgetName);
|
|
18
|
+
if (chatWidget && !trigger) {
|
|
19
|
+
return { chatWidget: chatWidget, mainWidget: mainWidget, data: data };
|
|
20
|
+
}
|
|
21
|
+
return { mainWidget: mainWidget, data: data };
|
|
22
|
+
};
|
|
23
|
+
export var shouldPreventDefault = function (container) {
|
|
24
|
+
var chatWidget = getSeparateWidget(container).chatWidget;
|
|
25
|
+
return !!chatWidget;
|
|
26
|
+
};
|
|
27
|
+
export var openChatWidget = function (container, contactMethod /*ContactMethodType*/, triggerDOMTarget) {
|
|
28
|
+
var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, data = _a.data, chatWidget = _a.chatWidget;
|
|
29
|
+
if (chatWidget) {
|
|
30
|
+
if (chatWidget.state === 'activated') {
|
|
31
|
+
return chatWidget.invoke('open').then(function () {
|
|
32
|
+
chatWidget.container.getAsync('conversation').then(function (conversation) {
|
|
33
|
+
conversation
|
|
34
|
+
.navigateToConversationIfActive(contactMethod.id)
|
|
35
|
+
.then(function () { return closeAllModals(container); });
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return chatWidget
|
|
40
|
+
.activate()
|
|
41
|
+
.then(function () {
|
|
42
|
+
var trigger = chatWidget.container.get('$settings').trigger;
|
|
43
|
+
trigger.action = 'hide'; // could be default in configuration
|
|
44
|
+
return chatWidget
|
|
45
|
+
.invoke('setSettings', function () { return ({
|
|
46
|
+
data: data,
|
|
47
|
+
trigger: trigger,
|
|
48
|
+
activate: true,
|
|
49
|
+
}); })
|
|
50
|
+
.then(function () {
|
|
51
|
+
return chatWidget.container
|
|
52
|
+
.getAsync('components')
|
|
53
|
+
.then(function (components) {
|
|
54
|
+
/**
|
|
55
|
+
* Could cause issues if target widget is no longer as specific for this use case
|
|
56
|
+
*/
|
|
57
|
+
var contactMethodsQuery = components
|
|
58
|
+
.components()
|
|
59
|
+
.ofType('contact-method');
|
|
60
|
+
components.write({
|
|
61
|
+
key: 'setContactMethodId',
|
|
62
|
+
attributes: {
|
|
63
|
+
properties: {
|
|
64
|
+
id: contactMethod.id,
|
|
65
|
+
guideId: contactMethod.guideId,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
target: contactMethodsQuery,
|
|
69
|
+
provider: 'localStorage',
|
|
70
|
+
});
|
|
71
|
+
var conversationsQuery = components
|
|
72
|
+
.components()
|
|
73
|
+
.ofType('conversation');
|
|
74
|
+
components.write({
|
|
75
|
+
key: 'setConversationProvider',
|
|
76
|
+
attributes: {
|
|
77
|
+
properties: { providers: [contactMethod.clientName] },
|
|
78
|
+
},
|
|
79
|
+
target: conversationsQuery,
|
|
80
|
+
provider: 'localStorage',
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
})
|
|
85
|
+
.then(function () {
|
|
86
|
+
return chatWidget.invoke('attach', {
|
|
87
|
+
key: 'contact-method',
|
|
88
|
+
triggerDOMElement: triggerDOMTarget,
|
|
89
|
+
withRenderState: 'open',
|
|
90
|
+
});
|
|
91
|
+
})
|
|
92
|
+
.then(function () {
|
|
93
|
+
createStorageWriter(chatWidget.container, 'activeStickyWidget', StorageCategory.Necessary, {
|
|
94
|
+
medium: StorageMedium.Local,
|
|
95
|
+
scope: StorageScope.Implementation,
|
|
96
|
+
}).then(function (write) { return write(chatWidget.name); });
|
|
97
|
+
return chatWidget.container
|
|
98
|
+
.getAsync('conversation')
|
|
99
|
+
.then(function (platform) {
|
|
100
|
+
platform.setConversationEndedBehavior(ConversationEndedBehavior.Deactivate);
|
|
101
|
+
})
|
|
102
|
+
.then(function () { return closeAllModals(container); })
|
|
103
|
+
.then(function () { return false; });
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
mainWidget.container.getAsync('conversation').then(function (platform) {
|
|
107
|
+
return platform
|
|
108
|
+
.navigateToConversationIfActive(contactMethod.id)
|
|
109
|
+
.then(function () { return platform.setConversationEndedBehavior(ConversationEndedBehavior.Navigate); });
|
|
110
|
+
});
|
|
111
|
+
return chatWidget ? false : true;
|
|
112
|
+
};
|
|
113
|
+
export var navigateToConversation = function (container, contactMethod /*ContactMethodType*/, routeName) {
|
|
114
|
+
if (routeName === void 0) { routeName = 'conversation'; }
|
|
115
|
+
var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, chatWidget = _a.chatWidget;
|
|
116
|
+
if (chatWidget) {
|
|
117
|
+
return chatWidget.container.getAsync('router').then(function (router) {
|
|
118
|
+
router.navigate(routeName, { id: contactMethod.id });
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return mainWidget.container.getAsync('conversation').then(function (platform) {
|
|
122
|
+
var _a;
|
|
123
|
+
(_a = platform.setConversationEndedBehavior(ConversationEndedBehavior.Navigate)) === null || _a === void 0 ? void 0 : _a.then(function () {
|
|
124
|
+
mainWidget.container.getAsync('router').then(function (router) {
|
|
125
|
+
mainWidget.container
|
|
126
|
+
.getAsync('components')
|
|
127
|
+
.then(function (components) {
|
|
128
|
+
var conversationQuery = components.components().ofType('conversation');
|
|
129
|
+
components.write({
|
|
130
|
+
key: 'setConversationProvider',
|
|
131
|
+
attributes: { properties: { providers: [contactMethod.clientName] } },
|
|
132
|
+
target: conversationQuery,
|
|
133
|
+
provider: 'localStorage',
|
|
134
|
+
});
|
|
135
|
+
})
|
|
136
|
+
.then(function () {
|
|
137
|
+
router.navigate(routeName, { id: contactMethod.id });
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telia-ace/widget-conversation",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ACE Widget Conversation Platform",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"author": "Telia Company AB",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"telia"
|
|
9
|
+
],
|
|
10
|
+
"main": "lib/index.js",
|
|
11
|
+
"module": "lib-esm/index.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"README.md",
|
|
15
|
+
"lib/",
|
|
16
|
+
"lib-esm/"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"clean": "cleandir lib && cleandir lib-esm",
|
|
23
|
+
"compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"typings": "lib/index.d.ts",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@telia-ace/widget-core": "^1.0.0",
|
|
29
|
+
"@telia-ace/widget-forms": "^1.0.0",
|
|
30
|
+
"@telia-ace/widget-plugins": "^1.0.0",
|
|
31
|
+
"@telia-ace/widget-routing": "^1.0.0",
|
|
32
|
+
"@telia-ace/widget-services": "^1.0.0",
|
|
33
|
+
"@telia-ace/widget-ui": "^1.0.0",
|
|
34
|
+
"@telia-ace/widget-utilities": "^1.0.1",
|
|
35
|
+
"@webprovisions/platform": "^1.1.2",
|
|
36
|
+
"react": "^17.0.2",
|
|
37
|
+
"styled-components": "^4.3.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^17.0.39"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "a45fde2bae0981a2a791a2362f2ecaf53430570b"
|
|
43
|
+
}
|