@telia-ace/widget-conversation 1.0.12 → 1.0.13

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 (131) hide show
  1. package/{lib-esm → dist}/agent.d.ts +0 -0
  2. package/{lib-esm → dist}/conversation-controller.d.ts +0 -0
  3. package/{lib-esm → dist}/conversation-form-adapter.d.ts +0 -0
  4. package/{lib-esm → dist}/conversation-platform.d.ts +0 -0
  5. package/{lib-esm → dist}/conversation-provider.d.ts +0 -0
  6. package/dist/conversation.js +1357 -0
  7. package/dist/conversation.js.map +1 -0
  8. package/{lib-esm → dist}/index.d.ts +0 -0
  9. package/dist/index.js +867 -0
  10. package/dist/index.js.map +1 -0
  11. package/{lib-esm → dist}/resolve-entity-value.d.ts +0 -0
  12. package/dist/return-button.js +174 -0
  13. package/dist/return-button.js.map +1 -0
  14. package/{lib-esm → dist}/types.d.ts +0 -0
  15. package/{lib-esm → dist}/ui/conversation/conversation-component.d.ts +0 -0
  16. package/{lib-esm → dist}/ui/conversation/conversation-content.d.ts +0 -0
  17. package/{lib-esm → dist}/ui/conversation/conversation-input.d.ts +0 -0
  18. package/{lib-esm → dist}/ui/conversation/conversation-loader.d.ts +0 -0
  19. package/{lib-esm → dist}/ui/conversation/conversation-message.d.ts +0 -0
  20. package/{lib-esm → dist}/ui/conversation/conversation-styles.d.ts +0 -0
  21. package/{lib-esm → dist}/ui/conversation/conversation.d.ts +0 -0
  22. package/{lib-esm → dist}/ui/conversation/index.d.ts +0 -0
  23. package/{lib-esm → dist}/ui/conversation/message-types/agent.d.ts +0 -0
  24. package/{lib-esm → dist}/ui/conversation/message-types/custom-message-list-item.d.ts +0 -0
  25. package/{lib-esm → dist}/ui/conversation/message-types/custom.d.ts +0 -0
  26. package/{lib-esm → dist}/ui/conversation/message-types/index.d.ts +0 -0
  27. package/{lib-esm → dist}/ui/conversation/message-types/system.d.ts +0 -0
  28. package/{lib-esm → dist}/ui/conversation/message-types/timestamp.d.ts +0 -0
  29. package/{lib-esm → dist}/ui/conversation/message-types/user.d.ts +0 -0
  30. package/{lib-esm → dist}/ui/index.d.ts +0 -0
  31. package/{lib-esm → dist}/ui/return-button/index.d.ts +0 -0
  32. package/{lib-esm → dist}/ui/return-button/return-button-component.d.ts +0 -0
  33. package/{lib-esm → dist}/ui/return-button/return-button.d.ts +0 -0
  34. package/{lib-esm → dist}/user.d.ts +0 -0
  35. package/{lib-esm → dist}/utils/custom-message.d.ts +0 -0
  36. package/{lib-esm → dist}/utils/index.d.ts +0 -0
  37. package/{lib-esm → dist}/utils/open-chat-widget.d.ts +0 -0
  38. package/package.json +14 -15
  39. package/lib/agent.d.ts +0 -17
  40. package/lib/agent.js +0 -37
  41. package/lib/conversation-controller.d.ts +0 -88
  42. package/lib/conversation-controller.js +0 -318
  43. package/lib/conversation-form-adapter.d.ts +0 -7
  44. package/lib/conversation-form-adapter.js +0 -88
  45. package/lib/conversation-platform.d.ts +0 -49
  46. package/lib/conversation-platform.js +0 -295
  47. package/lib/conversation-provider.d.ts +0 -22
  48. package/lib/conversation-provider.js +0 -73
  49. package/lib/index.d.ts +0 -9
  50. package/lib/index.js +0 -17
  51. package/lib/resolve-entity-value.d.ts +0 -10
  52. package/lib/resolve-entity-value.js +0 -22
  53. package/lib/types.d.ts +0 -110
  54. package/lib/types.js +0 -19
  55. package/lib/ui/conversation/conversation-component.d.ts +0 -37
  56. package/lib/ui/conversation/conversation-component.js +0 -152
  57. package/lib/ui/conversation/conversation-content.d.ts +0 -11
  58. package/lib/ui/conversation/conversation-content.js +0 -240
  59. package/lib/ui/conversation/conversation-input.d.ts +0 -6
  60. package/lib/ui/conversation/conversation-input.js +0 -163
  61. package/lib/ui/conversation/conversation-loader.d.ts +0 -8
  62. package/lib/ui/conversation/conversation-loader.js +0 -18
  63. package/lib/ui/conversation/conversation-message.d.ts +0 -7
  64. package/lib/ui/conversation/conversation-message.js +0 -141
  65. package/lib/ui/conversation/conversation-styles.d.ts +0 -11
  66. package/lib/ui/conversation/conversation-styles.js +0 -65
  67. package/lib/ui/conversation/conversation.d.ts +0 -6
  68. package/lib/ui/conversation/conversation.js +0 -139
  69. package/lib/ui/conversation/index.d.ts +0 -2
  70. package/lib/ui/conversation/index.js +0 -7
  71. package/lib/ui/conversation/message-types/agent.d.ts +0 -11
  72. package/lib/ui/conversation/message-types/agent.js +0 -54
  73. package/lib/ui/conversation/message-types/custom-message-list-item.d.ts +0 -9
  74. package/lib/ui/conversation/message-types/custom-message-list-item.js +0 -27
  75. package/lib/ui/conversation/message-types/custom.d.ts +0 -9
  76. package/lib/ui/conversation/message-types/custom.js +0 -50
  77. package/lib/ui/conversation/message-types/index.d.ts +0 -5
  78. package/lib/ui/conversation/message-types/index.js +0 -16
  79. package/lib/ui/conversation/message-types/system.d.ts +0 -12
  80. package/lib/ui/conversation/message-types/system.js +0 -26
  81. package/lib/ui/conversation/message-types/timestamp.d.ts +0 -8
  82. package/lib/ui/conversation/message-types/timestamp.js +0 -36
  83. package/lib/ui/conversation/message-types/user.d.ts +0 -8
  84. package/lib/ui/conversation/message-types/user.js +0 -24
  85. package/lib/ui/index.d.ts +0 -2
  86. package/lib/ui/index.js +0 -10
  87. package/lib/ui/return-button/index.d.ts +0 -2
  88. package/lib/ui/return-button/index.js +0 -7
  89. package/lib/ui/return-button/return-button-component.d.ts +0 -19
  90. package/lib/ui/return-button/return-button-component.js +0 -70
  91. package/lib/ui/return-button/return-button.d.ts +0 -6
  92. package/lib/ui/return-button/return-button.js +0 -82
  93. package/lib/user.d.ts +0 -7
  94. package/lib/user.js +0 -16
  95. package/lib/utils/custom-message.d.ts +0 -3
  96. package/lib/utils/custom-message.js +0 -56
  97. package/lib/utils/index.d.ts +0 -1
  98. package/lib/utils/index.js +0 -7
  99. package/lib/utils/open-chat-widget.d.ts +0 -4
  100. package/lib/utils/open-chat-widget.js +0 -148
  101. package/lib-esm/agent.js +0 -34
  102. package/lib-esm/conversation-controller.js +0 -314
  103. package/lib-esm/conversation-form-adapter.js +0 -85
  104. package/lib-esm/conversation-platform.js +0 -292
  105. package/lib-esm/conversation-provider.js +0 -70
  106. package/lib-esm/index.js +0 -6
  107. package/lib-esm/resolve-entity-value.js +0 -18
  108. package/lib-esm/types.js +0 -16
  109. package/lib-esm/ui/conversation/conversation-component.js +0 -127
  110. package/lib-esm/ui/conversation/conversation-content.js +0 -212
  111. package/lib-esm/ui/conversation/conversation-input.js +0 -138
  112. package/lib-esm/ui/conversation/conversation-loader.js +0 -13
  113. package/lib-esm/ui/conversation/conversation-message.js +0 -113
  114. package/lib-esm/ui/conversation/conversation-styles.js +0 -39
  115. package/lib-esm/ui/conversation/conversation.js +0 -111
  116. package/lib-esm/ui/conversation/index.js +0 -2
  117. package/lib-esm/ui/conversation/message-types/agent.js +0 -25
  118. package/lib-esm/ui/conversation/message-types/custom-message-list-item.js +0 -22
  119. package/lib-esm/ui/conversation/message-types/custom.js +0 -25
  120. package/lib-esm/ui/conversation/message-types/index.js +0 -5
  121. package/lib-esm/ui/conversation/message-types/system.js +0 -20
  122. package/lib-esm/ui/conversation/message-types/timestamp.js +0 -31
  123. package/lib-esm/ui/conversation/message-types/user.js +0 -19
  124. package/lib-esm/ui/index.js +0 -2
  125. package/lib-esm/ui/return-button/index.js +0 -2
  126. package/lib-esm/ui/return-button/return-button-component.js +0 -44
  127. package/lib-esm/ui/return-button/return-button.js +0 -54
  128. package/lib-esm/user.js +0 -13
  129. package/lib-esm/utils/custom-message.js +0 -52
  130. package/lib-esm/utils/index.js +0 -1
  131. package/lib-esm/utils/open-chat-widget.js +0 -142
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.Discrete = exports.StyledSystemMessage = void 0;
11
- var widget_utilities_1 = require("@telia-ace/widget-utilities");
12
- var react_1 = __importDefault(require("react"));
13
- var styled_components_1 = __importDefault(require("styled-components"));
14
- var timestamp_1 = __importDefault(require("./timestamp"));
15
- var SystemMessage = function (_a) {
16
- var className = _a.className, children = _a.children, timestamp = _a.timestamp, discrete = _a.discrete, fullWidth = _a.fullWidth;
17
- return (react_1.default.createElement(exports.StyledSystemMessage, { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-conversation-system-message'), fullWidth: fullWidth }, discrete ? (react_1.default.createElement(exports.Discrete, { className: "humany-conversation-discrete-message" },
18
- children,
19
- react_1.default.createElement(timestamp_1.default, { timestamp: timestamp }))) : (react_1.default.createElement(react_1.default.Fragment, null,
20
- children,
21
- react_1.default.createElement(timestamp_1.default, { timestamp: timestamp })))));
22
- };
23
- exports.StyledSystemMessage = styled_components_1.default.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; });
24
- exports.Discrete = styled_components_1.default.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; });
25
- exports.default = SystemMessage;
26
- var templateObject_1, templateObject_2;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- declare type Props = {
3
- className?: string;
4
- name?: string;
5
- timestamp?: number | null;
6
- };
7
- declare const Timestamp: React.FC<Props>;
8
- export default Timestamp;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- var react_1 = __importDefault(require("react"));
11
- var styled_components_1 = __importDefault(require("styled-components"));
12
- var StyledTimestamp = styled_components_1.default.p(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n && {\n font-size: ", ";\n font-weight: 300;\n }\n padding-top: ", ";\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 padding-top: ", ";\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.sizes) === 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; });
13
- var getTimestamp = function (raw) {
14
- return new Date(raw).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
15
- };
16
- var Timestamp = function (_a) {
17
- var className = _a.className, name = _a.name, timestamp = _a.timestamp;
18
- if (!name && !timestamp) {
19
- return null;
20
- }
21
- var output = '';
22
- if (name) {
23
- if (timestamp) {
24
- output = "".concat(name, ": ").concat(getTimestamp(timestamp));
25
- }
26
- else {
27
- output = name;
28
- }
29
- }
30
- else if (timestamp) {
31
- output = getTimestamp(timestamp);
32
- }
33
- return react_1.default.createElement(StyledTimestamp, null, output);
34
- };
35
- exports.default = Timestamp;
36
- var templateObject_1;
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- export declare type Props = {
3
- className?: string;
4
- timestamp: number;
5
- children: any;
6
- };
7
- declare const UserMessage: React.FC<Props>;
8
- export default UserMessage;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- var widget_ui_1 = require("@telia-ace/widget-ui");
11
- var widget_utilities_1 = require("@telia-ace/widget-utilities");
12
- var react_1 = __importDefault(require("react"));
13
- var styled_components_1 = __importDefault(require("styled-components"));
14
- var timestamp_1 = __importDefault(require("./timestamp"));
15
- var UserMessage = function (_a) {
16
- var className = _a.className, children = _a.children, timestamp = _a.timestamp;
17
- var _b = (0, widget_ui_1.useProperties)().userLabel, userLabel = _b === void 0 ? '' : _b;
18
- return (react_1.default.createElement(StyledUserMessage, { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-conversation-user-message') },
19
- children,
20
- react_1.default.createElement(timestamp_1.default, { name: userLabel, timestamp: timestamp })));
21
- };
22
- var StyledUserMessage = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n margin-left: 10%;\n width: 90%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n"], ["\n margin-left: 10%;\n width: 90%;\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n"])));
23
- exports.default = UserMessage;
24
- var templateObject_1;
package/lib/ui/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { default as ConversationComponent } from './conversation';
2
- export { default as ConversationReturnButtonComponent } from './return-button';
package/lib/ui/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConversationReturnButtonComponent = exports.ConversationComponent = void 0;
7
- var conversation_1 = require("./conversation");
8
- Object.defineProperty(exports, "ConversationComponent", { enumerable: true, get: function () { return __importDefault(conversation_1).default; } });
9
- var return_button_1 = require("./return-button");
10
- Object.defineProperty(exports, "ConversationReturnButtonComponent", { enumerable: true, get: function () { return __importDefault(return_button_1).default; } });
@@ -1,2 +0,0 @@
1
- import ConversationReturnButtonComponent from './return-button-component';
2
- export default ConversationReturnButtonComponent;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var return_button_component_1 = __importDefault(require("./return-button-component"));
7
- exports.default = return_button_component_1.default;
@@ -1,19 +0,0 @@
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;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __read = (this && this.__read) || function (o, n) {
26
- var m = typeof Symbol === "function" && o[Symbol.iterator];
27
- if (!m) return o;
28
- var i = m.call(o), r, ar = [], e;
29
- try {
30
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
- }
32
- catch (error) { e = { error: error }; }
33
- finally {
34
- try {
35
- if (r && !r.done && (m = i["return"])) m.call(i);
36
- }
37
- finally { if (e) throw e.error; }
38
- }
39
- return ar;
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.ButtonMode = void 0;
43
- var widget_core_1 = require("@telia-ace/widget-core");
44
- var widget_ui_1 = require("@telia-ace/widget-ui");
45
- var __1 = require("../../");
46
- var ButtonMode;
47
- (function (ButtonMode) {
48
- ButtonMode["flat"] = "flat";
49
- ButtonMode["flashing"] = "flashing";
50
- ButtonMode["flashingGradient"] = "flashingGradient";
51
- })(ButtonMode = exports.ButtonMode || (exports.ButtonMode = {}));
52
- var ConversationReturnButtonComponent = function (container) {
53
- return Promise.all([
54
- widget_core_1.ComponentPlatform.getInstance(container),
55
- __1.ConversationPlatform.getInstance(container),
56
- container.getAsync('router'),
57
- ]).then(function (_a) {
58
- var _b = __read(_a, 3), components = _b[0], platform = _b[1], router = _b[2];
59
- return (0, widget_ui_1.createReactComponent)(container, 'conversation-return-button', Promise.resolve().then(function () { return __importStar(require('./return-button')); }), function (component) {
60
- component.actions.create('toggle', function (options) {
61
- var _a;
62
- if (options === void 0) { options = {}; }
63
- (_a = platform.getComponentRoute()) === null || _a === void 0 ? void 0 : _a.then(function (route) {
64
- route && router.navigate(route.name, route.params);
65
- });
66
- });
67
- });
68
- });
69
- };
70
- exports.default = ConversationReturnButtonComponent;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- declare type Props = {
3
- className: string;
4
- };
5
- declare const ReturnButton: React.SFC<Props>;
6
- export default ReturnButton;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || function (mod) {
23
- if (mod && mod.__esModule) return mod;
24
- var result = {};
25
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
26
- __setModuleDefault(result, mod);
27
- return result;
28
- };
29
- var __rest = (this && this.__rest) || function (s, e) {
30
- var t = {};
31
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
32
- t[p] = s[p];
33
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
34
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
35
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
36
- t[p[i]] = s[p[i]];
37
- }
38
- return t;
39
- };
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- // import { Component } from '@telia-ace/widget-types-grid';
45
- var widget_ui_1 = require("@telia-ace/widget-ui");
46
- var react_1 = __importDefault(require("react"));
47
- var styled_components_1 = __importStar(require("styled-components"));
48
- var ReturnButton = function (_a) {
49
- var className = _a.className, other = __rest(_a, ["className"]);
50
- var _b = (0, widget_ui_1.useProperties)(), label = _b.label, active = _b.active, _c = _b.mode, mode = _c === void 0 ? 'flat' : _c, _d = _b.alert, alert = _d === void 0 ? {} : _d;
51
- var symbol = alert.symbol, alertLabel = alert.label, showAlert = alert.show;
52
- // const [showAlert, setShowAlert] = useState(show);
53
- var dispatch = (0, widget_ui_1.useDispatch)();
54
- if (!active) {
55
- return null;
56
- }
57
- return (react_1.default.createElement(StyledHighlightedButton, { className: className, mode: mode, "aria-label": label, onClick: function () {
58
- dispatch('toggle');
59
- } },
60
- react_1.default.createElement(StyledLabel, null, label),
61
- symbol && (react_1.default.createElement(StyledIconHolder, { showAlert: showAlert },
62
- react_1.default.createElement(widget_ui_1.SymbolBadge, { symbol: symbol, title: alertLabel, size: 20 })))));
63
- };
64
- var FlashingColorAnimation = function (props) {
65
- var _a, _b, _c;
66
- return (0, styled_components_1.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);
67
- };
68
- var ScrollingGradientAnimation = function (props) { return (0, styled_components_1.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"]))); };
69
- var PulsatingIcon = (0, styled_components_1.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"])));
70
- var StyledIconHolder = styled_components_1.default.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); });
71
- var StyledLabel = styled_components_1.default.span(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n flex: 1;\n font-weight: 300;\n"], ["\n flex: 1;\n font-weight: 300;\n"])));
72
- var flashingStyle = (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n animation: ", " 1s ease infinite;\n"], ["\n animation: ", " 1s ease infinite;\n"])), FlashingColorAnimation);
73
- var flashingGradientStyle = (0, styled_components_1.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);
74
- var StyledHighlightedButton = (0, styled_components_1.default)(widget_ui_1.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) {
75
- return p.mode === 'flashing'
76
- ? flashingStyle
77
- : p.mode === 'flashingGradient'
78
- ? flashingGradientStyle
79
- : '';
80
- }, 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) && widget_ui_1.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; });
81
- exports.default = ReturnButton;
82
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
package/lib/user.d.ts DELETED
@@ -1,7 +0,0 @@
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/user.js DELETED
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.User = void 0;
4
- var conversation_controller_1 = require("./conversation-controller");
5
- var User = /** @class */ (function () {
6
- function User(controller) {
7
- var _this = this;
8
- this.controller = controller;
9
- this.print = function (settings) {
10
- var normalized = (0, conversation_controller_1.getNormalizedMessageSettings)(settings);
11
- return _this.controller.createEntry(normalized.key, normalized.content, conversation_controller_1.ConversationMessageType.User, undefined, normalized.timestamp);
12
- };
13
- }
14
- return User;
15
- }());
16
- exports.User = User;
@@ -1,3 +0,0 @@
1
- import { ReactComponent } from '@telia-ace/widget-core';
2
- import { Container } from '@webprovisions/platform';
3
- export declare const registerCustomMessageComponent: (container: Container, type: string, component: ReactComponent) => Promise<void>;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.registerCustomMessageComponent = void 0;
40
- var react_1 = require("react");
41
- var __1 = require("..");
42
- var registerCustomMessageComponent = function (container, type, component) {
43
- return container.getAsync('componentResolver').then(function (o) { return __awaiter(void 0, void 0, void 0, function () {
44
- var platform;
45
- return __generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0: return [4 /*yield*/, __1.ConversationPlatform.getInstance(container)];
48
- case 1:
49
- platform = _a.sent();
50
- platform.addSubscription(o.registerComponent(type, (0, react_1.lazy)(function () { return component; })));
51
- return [2 /*return*/];
52
- }
53
- });
54
- }); });
55
- };
56
- exports.registerCustomMessageComponent = registerCustomMessageComponent;
@@ -1 +0,0 @@
1
- export { navigateToConversation, openChatWidget, shouldPreventDefault } from './open-chat-widget';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldPreventDefault = exports.openChatWidget = exports.navigateToConversation = void 0;
4
- var open_chat_widget_1 = require("./open-chat-widget");
5
- Object.defineProperty(exports, "navigateToConversation", { enumerable: true, get: function () { return open_chat_widget_1.navigateToConversation; } });
6
- Object.defineProperty(exports, "openChatWidget", { enumerable: true, get: function () { return open_chat_widget_1.openChatWidget; } });
7
- Object.defineProperty(exports, "shouldPreventDefault", { enumerable: true, get: function () { return open_chat_widget_1.shouldPreventDefault; } });
@@ -1,4 +0,0 @@
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;
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.navigateToConversation = exports.openChatWidget = exports.shouldPreventDefault = void 0;
4
- var widget_plugins_1 = require("@telia-ace/widget-plugins");
5
- var widget_services_1 = require("@telia-ace/widget-services");
6
- var __1 = require("../");
7
- var getParentWidget = function (widgetName, implementation) {
8
- var mainWidgetName = widgetName.split('_contact');
9
- return implementation.widgets.get(mainWidgetName[0]);
10
- };
11
- var getSeparateWidget = function (container) {
12
- var originWidget = container.get('$widget');
13
- var _a = container.get('$widget'), name = _a.name, implementation = _a.implementation;
14
- var mainWidget = name.indexOf('_contact') > -1 ? getParentWidget(name, implementation) : originWidget;
15
- var data = container.get('$settings').data;
16
- var trigger = mainWidget.container.get('$settings').trigger;
17
- var chatWidgetName = "".concat(name
18
- .replace('_contact-method', '')
19
- .replace('_contact', ''), "_contact-method");
20
- var chatWidget = implementation.widgets.get(chatWidgetName);
21
- if (chatWidget && !trigger) {
22
- return { chatWidget: chatWidget, mainWidget: mainWidget, data: data };
23
- }
24
- return { mainWidget: mainWidget, data: data };
25
- };
26
- var shouldPreventDefault = function (container) {
27
- var chatWidget = getSeparateWidget(container).chatWidget;
28
- return !!chatWidget;
29
- };
30
- exports.shouldPreventDefault = shouldPreventDefault;
31
- var openChatWidget = function (container, contactMethod /*ContactMethodType*/, triggerDOMTarget) {
32
- var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, data = _a.data, chatWidget = _a.chatWidget;
33
- if (chatWidget) {
34
- if (chatWidget.state === 'activated') {
35
- return chatWidget.invoke('open').then(function () {
36
- chatWidget.container.getAsync('conversation').then(function (conversation) {
37
- conversation
38
- .navigateToConversationIfActive(contactMethod.id)
39
- .then(function () { return (0, widget_plugins_1.closeAllModals)(container); });
40
- });
41
- });
42
- }
43
- return chatWidget
44
- .activate()
45
- .then(function () {
46
- var trigger = chatWidget.container.get('$settings').trigger;
47
- trigger.action = 'hide'; // could be default in configuration
48
- return chatWidget
49
- .invoke('setSettings', function () { return ({
50
- data: data,
51
- trigger: trigger,
52
- activate: true,
53
- }); })
54
- .then(function () {
55
- return chatWidget.container
56
- .getAsync('components')
57
- .then(function (components) {
58
- /**
59
- * Could cause issues if target widget is no longer as specific for this use case
60
- */
61
- var contactMethodsQuery = components
62
- .components()
63
- .ofType('contact-method');
64
- components.write({
65
- key: 'setContactMethodId',
66
- attributes: {
67
- properties: {
68
- id: contactMethod.id,
69
- guideId: contactMethod.guideId,
70
- },
71
- },
72
- target: contactMethodsQuery,
73
- provider: 'localStorage',
74
- });
75
- var conversationsQuery = components
76
- .components()
77
- .ofType('conversation');
78
- components.write({
79
- key: 'setConversationProvider',
80
- attributes: {
81
- properties: { providers: [contactMethod.clientName] },
82
- },
83
- target: conversationsQuery,
84
- provider: 'localStorage',
85
- });
86
- });
87
- });
88
- })
89
- .then(function () {
90
- return chatWidget.invoke('attach', {
91
- key: 'contact-method',
92
- triggerDOMElement: triggerDOMTarget,
93
- withRenderState: 'open',
94
- });
95
- })
96
- .then(function () {
97
- (0, widget_services_1.createStorageWriter)(chatWidget.container, 'activeStickyWidget', widget_services_1.StorageCategory.Necessary, {
98
- medium: widget_services_1.StorageMedium.Local,
99
- scope: widget_services_1.StorageScope.Implementation,
100
- }).then(function (write) { return write(chatWidget.name); });
101
- return chatWidget.container
102
- .getAsync('conversation')
103
- .then(function (platform) {
104
- platform.setConversationEndedBehavior(__1.ConversationEndedBehavior.Deactivate);
105
- })
106
- .then(function () { return (0, widget_plugins_1.closeAllModals)(container); })
107
- .then(function () { return false; });
108
- });
109
- }
110
- mainWidget.container.getAsync('conversation').then(function (platform) {
111
- return platform
112
- .navigateToConversationIfActive(contactMethod.id)
113
- .then(function () { return platform.setConversationEndedBehavior(__1.ConversationEndedBehavior.Navigate); });
114
- });
115
- return chatWidget ? false : true;
116
- };
117
- exports.openChatWidget = openChatWidget;
118
- var navigateToConversation = function (container, contactMethod /*ContactMethodType*/, routeName) {
119
- if (routeName === void 0) { routeName = 'conversation'; }
120
- var _a = getSeparateWidget(container), mainWidget = _a.mainWidget, chatWidget = _a.chatWidget;
121
- if (chatWidget) {
122
- return chatWidget.container.getAsync('router').then(function (router) {
123
- router.navigate(routeName, { id: contactMethod.id });
124
- });
125
- }
126
- return mainWidget.container.getAsync('conversation').then(function (platform) {
127
- var _a;
128
- (_a = platform.setConversationEndedBehavior(__1.ConversationEndedBehavior.Navigate)) === null || _a === void 0 ? void 0 : _a.then(function () {
129
- mainWidget.container.getAsync('router').then(function (router) {
130
- mainWidget.container
131
- .getAsync('components')
132
- .then(function (components) {
133
- var conversationQuery = components.components().ofType('conversation');
134
- components.write({
135
- key: 'setConversationProvider',
136
- attributes: { properties: { providers: [contactMethod.clientName] } },
137
- target: conversationQuery,
138
- provider: 'localStorage',
139
- });
140
- })
141
- .then(function () {
142
- router.navigate(routeName, { id: contactMethod.id });
143
- });
144
- });
145
- });
146
- });
147
- };
148
- exports.navigateToConversation = navigateToConversation;
package/lib-esm/agent.js DELETED
@@ -1,34 +0,0 @@
1
- import { ConversationMessageType, getNormalizedMessageSettings, } from './conversation-controller';
2
- var Agent = /** @class */ (function () {
3
- function Agent(provider, settings) {
4
- var _this = this;
5
- this.provider = provider;
6
- this.print = function (settings) {
7
- var sender = { name: _this.name, avatar: _this.avatar };
8
- var normalized = getNormalizedMessageSettings(settings);
9
- return _this.provider.createEntry(normalized.key, normalized.content, ConversationMessageType.Agent, sender, normalized.timestamp);
10
- };
11
- this.typing = function () {
12
- return _this.provider.setTypingState({ name: _this.name, avatar: _this.avatar });
13
- };
14
- this.name = settings.name;
15
- this.avatar = settings.avatar;
16
- }
17
- Agent.prototype.update = function (settings) {
18
- var name = settings.name, avatar = settings.avatar;
19
- if (avatar === null) {
20
- this.avatar = undefined;
21
- }
22
- else if (avatar) {
23
- this.avatar = avatar;
24
- }
25
- if (name === null) {
26
- this.name = undefined;
27
- }
28
- else if (name) {
29
- this.name = name;
30
- }
31
- };
32
- return Agent;
33
- }());
34
- export { Agent };