@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.
Files changed (123) hide show
  1. package/LICENSE.txt +6 -0
  2. package/README.md +256 -0
  3. package/lib/agent.d.ts +17 -0
  4. package/lib/agent.js +37 -0
  5. package/lib/conversation-controller.d.ts +87 -0
  6. package/lib/conversation-controller.js +298 -0
  7. package/lib/conversation-form-adapter.d.ts +7 -0
  8. package/lib/conversation-form-adapter.js +88 -0
  9. package/lib/conversation-platform.d.ts +49 -0
  10. package/lib/conversation-platform.js +295 -0
  11. package/lib/conversation-provider.d.ts +22 -0
  12. package/lib/conversation-provider.js +73 -0
  13. package/lib/index.d.ts +8 -0
  14. package/lib/index.js +15 -0
  15. package/lib/resolve-entity-value.d.ts +10 -0
  16. package/lib/resolve-entity-value.js +22 -0
  17. package/lib/types.d.ts +35 -0
  18. package/lib/types.js +2 -0
  19. package/lib/ui/conversation/conversation-component.d.ts +32 -0
  20. package/lib/ui/conversation/conversation-component.js +152 -0
  21. package/lib/ui/conversation/conversation-content.d.ts +11 -0
  22. package/lib/ui/conversation/conversation-content.js +100 -0
  23. package/lib/ui/conversation/conversation-input.d.ts +6 -0
  24. package/lib/ui/conversation/conversation-input.js +154 -0
  25. package/lib/ui/conversation/conversation-loader.d.ts +8 -0
  26. package/lib/ui/conversation/conversation-loader.js +18 -0
  27. package/lib/ui/conversation/conversation-message.d.ts +7 -0
  28. package/lib/ui/conversation/conversation-message.js +141 -0
  29. package/lib/ui/conversation/conversation-styles.d.ts +9 -0
  30. package/lib/ui/conversation/conversation-styles.js +63 -0
  31. package/lib/ui/conversation/conversation.d.ts +6 -0
  32. package/lib/ui/conversation/conversation.js +139 -0
  33. package/lib/ui/conversation/index.d.ts +2 -0
  34. package/lib/ui/conversation/index.js +7 -0
  35. package/lib/ui/conversation/message-types/agent.d.ts +11 -0
  36. package/lib/ui/conversation/message-types/agent.js +54 -0
  37. package/lib/ui/conversation/message-types/custom.d.ts +9 -0
  38. package/lib/ui/conversation/message-types/custom.js +26 -0
  39. package/lib/ui/conversation/message-types/index.d.ts +5 -0
  40. package/lib/ui/conversation/message-types/index.js +16 -0
  41. package/lib/ui/conversation/message-types/system.d.ts +12 -0
  42. package/lib/ui/conversation/message-types/system.js +26 -0
  43. package/lib/ui/conversation/message-types/timestamp.d.ts +8 -0
  44. package/lib/ui/conversation/message-types/timestamp.js +36 -0
  45. package/lib/ui/conversation/message-types/user.d.ts +8 -0
  46. package/lib/ui/conversation/message-types/user.js +24 -0
  47. package/lib/ui/index.d.ts +2 -0
  48. package/lib/ui/index.js +10 -0
  49. package/lib/ui/return-button/index.d.ts +2 -0
  50. package/lib/ui/return-button/index.js +7 -0
  51. package/lib/ui/return-button/return-button-component.d.ts +19 -0
  52. package/lib/ui/return-button/return-button-component.js +70 -0
  53. package/lib/ui/return-button/return-button.d.ts +6 -0
  54. package/lib/ui/return-button/return-button.js +82 -0
  55. package/lib/user.d.ts +7 -0
  56. package/lib/user.js +16 -0
  57. package/lib/utils/custom-message.d.ts +3 -0
  58. package/lib/utils/custom-message.js +56 -0
  59. package/lib/utils/index.d.ts +1 -0
  60. package/lib/utils/index.js +7 -0
  61. package/lib/utils/open-chat-widget.d.ts +4 -0
  62. package/lib/utils/open-chat-widget.js +148 -0
  63. package/lib-esm/agent.d.ts +17 -0
  64. package/lib-esm/agent.js +34 -0
  65. package/lib-esm/conversation-controller.d.ts +87 -0
  66. package/lib-esm/conversation-controller.js +294 -0
  67. package/lib-esm/conversation-form-adapter.d.ts +7 -0
  68. package/lib-esm/conversation-form-adapter.js +85 -0
  69. package/lib-esm/conversation-platform.d.ts +49 -0
  70. package/lib-esm/conversation-platform.js +292 -0
  71. package/lib-esm/conversation-provider.d.ts +22 -0
  72. package/lib-esm/conversation-provider.js +70 -0
  73. package/lib-esm/index.d.ts +8 -0
  74. package/lib-esm/index.js +5 -0
  75. package/lib-esm/resolve-entity-value.d.ts +10 -0
  76. package/lib-esm/resolve-entity-value.js +18 -0
  77. package/lib-esm/types.d.ts +35 -0
  78. package/lib-esm/types.js +1 -0
  79. package/lib-esm/ui/conversation/conversation-component.d.ts +32 -0
  80. package/lib-esm/ui/conversation/conversation-component.js +127 -0
  81. package/lib-esm/ui/conversation/conversation-content.d.ts +11 -0
  82. package/lib-esm/ui/conversation/conversation-content.js +72 -0
  83. package/lib-esm/ui/conversation/conversation-input.d.ts +6 -0
  84. package/lib-esm/ui/conversation/conversation-input.js +129 -0
  85. package/lib-esm/ui/conversation/conversation-loader.d.ts +8 -0
  86. package/lib-esm/ui/conversation/conversation-loader.js +13 -0
  87. package/lib-esm/ui/conversation/conversation-message.d.ts +7 -0
  88. package/lib-esm/ui/conversation/conversation-message.js +113 -0
  89. package/lib-esm/ui/conversation/conversation-styles.d.ts +9 -0
  90. package/lib-esm/ui/conversation/conversation-styles.js +37 -0
  91. package/lib-esm/ui/conversation/conversation.d.ts +6 -0
  92. package/lib-esm/ui/conversation/conversation.js +111 -0
  93. package/lib-esm/ui/conversation/index.d.ts +2 -0
  94. package/lib-esm/ui/conversation/index.js +2 -0
  95. package/lib-esm/ui/conversation/message-types/agent.d.ts +11 -0
  96. package/lib-esm/ui/conversation/message-types/agent.js +25 -0
  97. package/lib-esm/ui/conversation/message-types/custom.d.ts +9 -0
  98. package/lib-esm/ui/conversation/message-types/custom.js +21 -0
  99. package/lib-esm/ui/conversation/message-types/index.d.ts +5 -0
  100. package/lib-esm/ui/conversation/message-types/index.js +5 -0
  101. package/lib-esm/ui/conversation/message-types/system.d.ts +12 -0
  102. package/lib-esm/ui/conversation/message-types/system.js +20 -0
  103. package/lib-esm/ui/conversation/message-types/timestamp.d.ts +8 -0
  104. package/lib-esm/ui/conversation/message-types/timestamp.js +31 -0
  105. package/lib-esm/ui/conversation/message-types/user.d.ts +8 -0
  106. package/lib-esm/ui/conversation/message-types/user.js +19 -0
  107. package/lib-esm/ui/index.d.ts +2 -0
  108. package/lib-esm/ui/index.js +2 -0
  109. package/lib-esm/ui/return-button/index.d.ts +2 -0
  110. package/lib-esm/ui/return-button/index.js +2 -0
  111. package/lib-esm/ui/return-button/return-button-component.d.ts +19 -0
  112. package/lib-esm/ui/return-button/return-button-component.js +44 -0
  113. package/lib-esm/ui/return-button/return-button.d.ts +6 -0
  114. package/lib-esm/ui/return-button/return-button.js +54 -0
  115. package/lib-esm/user.d.ts +7 -0
  116. package/lib-esm/user.js +13 -0
  117. package/lib-esm/utils/custom-message.d.ts +3 -0
  118. package/lib-esm/utils/custom-message.js +52 -0
  119. package/lib-esm/utils/index.d.ts +1 -0
  120. package/lib-esm/utils/index.js +1 -0
  121. package/lib-esm/utils/open-chat-widget.d.ts +4 -0
  122. package/lib-esm/utils/open-chat-widget.js +142 -0
  123. package/package.json +43 -0
@@ -0,0 +1,63 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.MessageContentPart = exports.MessageContent = exports.MessageContainer = exports.MessageTitle = exports.ContentBundle = exports.Loader = exports.LoaderAnimation = exports.Avatar = void 0;
31
+ var widget_ui_1 = require("@telia-ace/widget-ui");
32
+ var styled_components_1 = __importStar(require("styled-components"));
33
+ exports.Avatar = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n border: ", ";\n grid-area: avatar;\n align-self: flex-end;\n justify-self: center;\n overflow: hidden;\n margin-right: 10px;\n display: flex;\n justify-content: center;\n align-items: center;\n color: ", ";\n\n > img {\n height: 100%;\n width: 100%;\n object-fit: cover;\n }\n\n > svg {\n width: 90%;\n height: 90%;\n padding: 10%;\n color: ", ";\n\n line,\n path,\n circle,\n fill {\n stroke: ", ";\n }\n }\n"], ["\n width: ", ";\n height: ", ";\n border-radius: 50%;\n background-color: ", ";\n border: ", ";\n grid-area: avatar;\n align-self: flex-end;\n justify-self: center;\n overflow: hidden;\n margin-right: 10px;\n display: flex;\n justify-content: center;\n align-items: center;\n color: ", ";\n\n > img {\n height: 100%;\n width: 100%;\n object-fit: cover;\n }\n\n > svg {\n width: 90%;\n height: 90%;\n padding: 10%;\n color: ", ";\n\n line,\n path,\n circle,\n fill {\n stroke: ", ";\n }\n }\n"])), function (p) { return p.avatarSize || '32px'; }, function (p) { return p.avatarSize || '32px'; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; }, function (p) { return p.theme.border; }, 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.text; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; });
34
+ exports.LoaderAnimation = (0, styled_components_1.keyframes)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n 0% {\n opacity: 0;\n }\n 75% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n"], ["\n 0% {\n opacity: 0;\n }\n 75% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n"])));
35
+ exports.Loader = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n > div {\n height: 10px;\n width: 10px;\n border-radius: 50%;\n margin: 5px;\n background-color: ", ";\n animation: ", " 1s infinite;\n }\n > div:nth-child(2) {\n animation-delay: 100ms;\n }\n > div:nth-child(3) {\n animation-delay: 200ms;\n }\n"], ["\n display: flex;\n justify-content: center;\n > div {\n height: 10px;\n width: 10px;\n border-radius: 50%;\n margin: 5px;\n background-color: ", ";\n animation: ", " 1s infinite;\n }\n > div:nth-child(2) {\n animation-delay: 100ms;\n }\n > div:nth-child(3) {\n animation-delay: 200ms;\n }\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, exports.LoaderAnimation);
36
+ exports.ContentBundle = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n grid-area: content;\n max-width: 100%;\n overflow: auto;\n"], ["\n grid-area: content;\n max-width: 100%;\n overflow: auto;\n"])));
37
+ exports.MessageTitle = (0, styled_components_1.default)(widget_ui_1.Typography)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-size: ", ";\n font-weight: normal;\n margin: 0;\n"], ["\n font-size: ", ";\n font-weight: normal;\n margin: 0;\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; });
38
+ exports.MessageContainer = styled_components_1.default.div(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
39
+ exports.MessageContent = styled_components_1.default.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n padding: ", ";\n background-color: ", ";\n color: ", ";\n border-radius: 5px; // TODO: prop?\n margin-top: ", ";\n display: inline-block;\n && > * {\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-all;\n word-break: break-word;\n hyphens: auto;\n }\n max-width: 100%;\n ", "\n\n ", "\n ", ";\n\n ", "\n ", "\n ", "\n ", "\n ", "\n ", ";\n\n ", ";\n\n transition: border-radius 500ms linear;\n"], ["\n padding: ", ";\n background-color: ", ";\n color: ", ";\n border-radius: 5px; // TODO: prop?\n margin-top: ", ";\n display: inline-block;\n && > * {\n overflow-wrap: break-word;\n word-wrap: break-word;\n word-break: break-all;\n word-break: break-word;\n hyphens: auto;\n }\n max-width: 100%;\n ", "\n\n ", "\n ", ";\n\n ", "\n ", "\n ", "\n ", "\n ", "\n ", ";\n\n ", ";\n\n transition: border-radius 500ms linear;\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a, _b; return (p.user ? (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary : (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.accent); }, function (p) { var _a, _b; return (p.user ? (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent : (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.text); }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { return p.fullWidth && 'width: 100%;'; }, function (p) {
40
+ return !p.user && (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n border: ", ";\n "], ["\n border: ", ";\n "])), p.theme.border);
41
+ }, function (p) { return p.user && 'margin-left: auto'; }, function (p) {
42
+ return p.stacked === 'first' &&
43
+ p.user && (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n border-bottom-right-radius: 1px; // TODO: Prop?\n "], ["\n border-bottom-right-radius: 1px; // TODO: Prop?\n "])));
44
+ }, function (p) {
45
+ return p.stacked === 'middle' &&
46
+ p.user && (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n border-bottom-right-radius: 1px;\n border-top-right-radius: 1px;\n "], ["\n border-bottom-right-radius: 1px;\n border-top-right-radius: 1px;\n "])));
47
+ }, function (p) {
48
+ return p.stacked === 'last' &&
49
+ p.user && (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n border-top-right-radius: 1px;\n "], ["\n border-top-right-radius: 1px;\n "])));
50
+ }, function (p) {
51
+ return p.stacked === 'first' &&
52
+ !p.user && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n border-bottom-left-radius: 1px;\n "], ["\n border-bottom-left-radius: 1px;\n "])));
53
+ }, function (p) {
54
+ return p.stacked === 'middle' &&
55
+ !p.user && (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n border-bottom-left-radius: 1px;\n border-top-left-radius: 1px;\n "], ["\n border-bottom-left-radius: 1px;\n border-top-left-radius: 1px;\n "])));
56
+ }, function (p) {
57
+ return p.stacked === 'last' &&
58
+ !p.user && (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n border-top-left-radius: 1px;\n "], ["\n border-top-left-radius: 1px;\n "])));
59
+ }, function (p) {
60
+ return !p.stacked && (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), p.user ? 'border-bottom-right-radius: 1px;' : 'border-bottom-left-radius: 1px;');
61
+ });
62
+ exports.MessageContentPart = styled_components_1.default.div(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n margin-bottom: ", ";\n &:last-child {\n margin-bottom: 0;\n }\n"], ["\n margin-bottom: ", ";\n &:last-child {\n margin-bottom: 0;\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
63
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare type Props = {
3
+ className: string;
4
+ };
5
+ declare const Conversation: React.FC<Props>;
6
+ export default Conversation;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ var __read = (this && this.__read) || function (o, n) {
41
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
42
+ if (!m) return o;
43
+ var i = m.call(o), r, ar = [], e;
44
+ try {
45
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
46
+ }
47
+ catch (error) { e = { error: error }; }
48
+ finally {
49
+ try {
50
+ if (r && !r.done && (m = i["return"])) m.call(i);
51
+ }
52
+ finally { if (e) throw e.error; }
53
+ }
54
+ return ar;
55
+ };
56
+ var __importDefault = (this && this.__importDefault) || function (mod) {
57
+ return (mod && mod.__esModule) ? mod : { "default": mod };
58
+ };
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ var widget_ui_1 = require("@telia-ace/widget-ui");
61
+ var widget_utilities_1 = require("@telia-ace/widget-utilities");
62
+ var react_1 = __importStar(require("react"));
63
+ var styled_components_1 = __importStar(require("styled-components"));
64
+ var conversation_input_1 = __importDefault(require("./conversation-input"));
65
+ var conversation_loader_1 = __importDefault(require("./conversation-loader"));
66
+ var conversation_message_1 = __importDefault(require("./conversation-message"));
67
+ var message_types_1 = require("./message-types");
68
+ var Conversation = function (_a) {
69
+ var className = _a.className;
70
+ var lastEntry = (0, react_1.useRef)(document.createElement('div'));
71
+ var _b = __read((0, widget_ui_1.useScroll)(true), 2), scrollableCss = _b[0], viewElem = _b[1];
72
+ var _c = (0, widget_ui_1.useProperties)(), messages = _c.messages, loading = _c.loading, typingActors = _c.typingActors;
73
+ var _d = __read((0, react_1.useState)(false), 2), canSmooth = _d[0], setCanSmooth = _d[1];
74
+ var scrollView = (0, react_1.useCallback)(function (lastEntry, smooth) {
75
+ if (smooth === void 0) { smooth = true; }
76
+ if (lastEntry !== null && lastEntry.current !== null) {
77
+ if (messages && messages.length === 1) {
78
+ lastEntry.current.focus();
79
+ }
80
+ /**
81
+ * Don't scroll on typing state if the user has scrolled up a bit.
82
+ */
83
+ if (lastEntry.current.id.indexOf('typing_') !== -1 &&
84
+ viewElem.current.scrollTopMax - viewElem.current.scrollTop >
85
+ lastEntry.current.clientHeight + 100) {
86
+ return;
87
+ }
88
+ setTimeout(function () {
89
+ if (lastEntry.current) {
90
+ lastEntry.current.scrollIntoView({
91
+ block: 'end',
92
+ behavior: smooth ? 'smooth' : 'auto',
93
+ });
94
+ }
95
+ }, 0);
96
+ }
97
+ }, [lastEntry]);
98
+ (0, react_1.useEffect)(function () {
99
+ if (canSmooth) {
100
+ scrollView(lastEntry);
101
+ }
102
+ }, [messages, typingActors]);
103
+ (0, widget_ui_1.useTransitionEnd)(function () {
104
+ setCanSmooth(true);
105
+ scrollView(lastEntry, false);
106
+ });
107
+ var renderTypingActors = function () {
108
+ if (typingActors && typingActors.length) {
109
+ return typingActors.map(function (actor, index) {
110
+ return (react_1.default.createElement(MessageEntry, { id: "typing_".concat(actor.name), ref: typingActors.length ? lastEntry : null, key: "typing_".concat(actor.name) },
111
+ react_1.default.createElement(message_types_1.AgentMessage, { timestamp: Date.now(), sender: actor },
112
+ react_1.default.createElement(conversation_loader_1.default, null))));
113
+ });
114
+ }
115
+ return null;
116
+ };
117
+ return (react_1.default.createElement(Wrapper, { className: (0, widget_utilities_1.appendClassNames)(className, 'humany-conversation-component') },
118
+ react_1.default.createElement(Scrollable, { tabIndex: 0, scrollableCss: scrollableCss, ref: viewElem },
119
+ messages && messages.length
120
+ ? messages.map(function (message, index) {
121
+ var type = message.type, timestamp = message.timestamp, sender = message.sender, content = message.content;
122
+ return (react_1.default.createElement(MessageEntry, { className: 'humany-conversation-entry', tabIndex: -1, key: "".concat(type, "_").concat(sender === null || sender === void 0 ? void 0 : sender.name, "_").concat(timestamp, "_").concat(content[0].key), ref: index + 1 < messages.length
123
+ ? null
124
+ : typingActors.length
125
+ ? null
126
+ : lastEntry },
127
+ react_1.default.createElement(conversation_message_1.default, __assign({}, message))));
128
+ })
129
+ : null,
130
+ renderTypingActors(),
131
+ loading && (react_1.default.createElement(MessageEntry, null,
132
+ react_1.default.createElement(conversation_loader_1.default, null)))),
133
+ react_1.default.createElement(conversation_input_1.default, null)));
134
+ };
135
+ var Wrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n"], ["\n position: absolute;\n right: 0;\n left: 0;\n bottom: 0;\n top: 0;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n"])));
136
+ var Scrollable = styled_components_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n align-items: stretch;\n flex: 0 1 100%;\n padding: 0 ", ";\n ", ";\n &:focus {\n ", ";\n }\n"], ["\n display: flex;\n flex-direction: column;\n align-items: stretch;\n flex: 0 1 100%;\n padding: 0 ", ";\n ", ";\n &:focus {\n ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { return !!p.scrollableCss && p.scrollableCss; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
137
+ var MessageEntry = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin: 0;\n margin-bottom: ", ";\n\n &:first-of-type {\n margin-top: ", ";\n }\n\n &:last-of-type {\n padding-bottom: ", ";\n }\n\n * {\n font-size: ", ";\n }\n\n & span,\n p,\n a,\n div {\n font-weight: 300;\n }\n\n & b,\n h1 {\n font-weight: normal;\n }\n\n ", "\n"], ["\n margin: 0;\n margin-bottom: ", ";\n\n &:first-of-type {\n margin-top: ", ";\n }\n\n &:last-of-type {\n padding-bottom: ", ";\n }\n\n * {\n font-size: ", ";\n }\n\n & span,\n p,\n a,\n div {\n font-weight: 300;\n }\n\n & b,\n h1 {\n font-weight: normal;\n }\n\n ", "\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium; }, function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.normal; }, (0, widget_ui_1.headingElement)('h1', (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-weight: normal;\n "], ["\n font-weight: normal;\n "])))));
138
+ exports.default = Conversation;
139
+ var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
@@ -0,0 +1,2 @@
1
+ import ConversationComponent from './conversation-component';
2
+ export default ConversationComponent;
@@ -0,0 +1,7 @@
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 conversation_component_1 = __importDefault(require("./conversation-component"));
7
+ exports.default = conversation_component_1.default;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { ConversationMessageSender } from '../../../types';
3
+ declare type Props = {
4
+ className?: string;
5
+ children: any;
6
+ sender: ConversationMessageSender;
7
+ timestamp: number | null;
8
+ };
9
+ declare const AgentMessage: React.FC<Props>;
10
+ export declare const StyledAgentMessage: import("styled-components").StyledComponent<"div", any, any, never>;
11
+ export default AgentMessage;
@@ -0,0 +1,54 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
30
+ return (mod && mod.__esModule) ? mod : { "default": mod };
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.StyledAgentMessage = void 0;
34
+ var widget_ui_1 = require("@telia-ace/widget-ui");
35
+ var widget_utilities_1 = require("@telia-ace/widget-utilities");
36
+ var react_1 = __importDefault(require("react"));
37
+ var styled_components_1 = __importStar(require("styled-components"));
38
+ var conversation_styles_1 = require("../conversation-styles");
39
+ var timestamp_1 = __importDefault(require("./timestamp"));
40
+ var AgentMessage = function (_a) {
41
+ var className = _a.className, children = _a.children, sender = _a.sender, timestamp = _a.timestamp;
42
+ var avatar = sender.avatar, name = sender.name;
43
+ var avatarSize = (0, widget_ui_1.useProperties)().avatarSize;
44
+ return (react_1.default.createElement(exports.StyledAgentMessage, { hasAvatar: !!avatar, className: (0, widget_utilities_1.appendClassNames)(className, 'humany-conversation-agent-message') },
45
+ avatar && (react_1.default.createElement(conversation_styles_1.Avatar, { avatarSize: avatarSize }, typeof avatar === 'string' ? (react_1.default.createElement("img", { src: avatar })) : (react_1.default.createElement(widget_ui_1.SymbolBadge, { symbol: avatar })))),
46
+ children,
47
+ react_1.default.createElement(timestamp_1.default, { name: name, timestamp: timestamp })));
48
+ };
49
+ exports.StyledAgentMessage = styled_components_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: grid;\n margin-right: 0;\n width: 100%;\n ", ";\n"], ["\n display: grid;\n margin-right: 0;\n width: 100%;\n ", ";\n"])), function (p) {
50
+ return p.hasAvatar
51
+ ? (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n grid-template-columns: auto 1fr;\n grid-template-rows: 1fr auto;\n grid-template-areas:\n 'avatar content'\n '. info';\n "], ["\n grid-template-columns: auto 1fr;\n grid-template-rows: 1fr auto;\n grid-template-areas:\n 'avatar content'\n '. info';\n "]))) : (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n grid-template-columns: 1fr;\n grid-template-rows: 1fr auto;\n grid-template-areas:\n 'content'\n 'info';\n "], ["\n grid-template-columns: 1fr;\n grid-template-rows: 1fr auto;\n grid-template-areas:\n 'content'\n 'info';\n "])));
52
+ });
53
+ exports.default = AgentMessage;
54
+ var templateObject_1, templateObject_2, templateObject_3;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ export declare type Props = {
3
+ type: any;
4
+ content: any;
5
+ isUser: any;
6
+ stacked: any;
7
+ };
8
+ declare const CustomMessage: React.FC<Props>;
9
+ export default CustomMessage;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var widget_ui_1 = require("@telia-ace/widget-ui");
18
+ var react_1 = __importDefault(require("react"));
19
+ var conversation_styles_1 = require("../conversation-styles");
20
+ var CustomMessage = function (props) {
21
+ var CustomComponent = (0, widget_ui_1.useComponent)(props.type);
22
+ return (react_1.default.createElement(conversation_styles_1.MessageContent, { user: props.isUser, stacked: !!props.stacked && props.stacked, fullWidth: !!props.content.form || !!props.content.actions },
23
+ react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
24
+ react_1.default.createElement(CustomComponent, __assign({}, props.content)))));
25
+ };
26
+ exports.default = CustomMessage;
@@ -0,0 +1,5 @@
1
+ export { default as AgentMessage } from './agent';
2
+ export { default as CustomMessage } from './custom';
3
+ export { default as SystemMessage } from './system';
4
+ export { default as Timestamp } from './timestamp';
5
+ export { default as UserMessage } from './user';
@@ -0,0 +1,16 @@
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.UserMessage = exports.Timestamp = exports.SystemMessage = exports.CustomMessage = exports.AgentMessage = void 0;
7
+ var agent_1 = require("./agent");
8
+ Object.defineProperty(exports, "AgentMessage", { enumerable: true, get: function () { return __importDefault(agent_1).default; } });
9
+ var custom_1 = require("./custom");
10
+ Object.defineProperty(exports, "CustomMessage", { enumerable: true, get: function () { return __importDefault(custom_1).default; } });
11
+ var system_1 = require("./system");
12
+ Object.defineProperty(exports, "SystemMessage", { enumerable: true, get: function () { return __importDefault(system_1).default; } });
13
+ var timestamp_1 = require("./timestamp");
14
+ Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return __importDefault(timestamp_1).default; } });
15
+ var user_1 = require("./user");
16
+ Object.defineProperty(exports, "UserMessage", { enumerable: true, get: function () { return __importDefault(user_1).default; } });
@@ -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,26 @@
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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,36 @@
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 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; });
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;
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,24 @@
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: 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"])));
23
+ exports.default = UserMessage;
24
+ var templateObject_1;
@@ -0,0 +1,2 @@
1
+ export { default as ConversationComponent } from './conversation';
2
+ export { default as ConversationReturnButtonComponent } from './return-button';
@@ -0,0 +1,10 @@
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; } });
@@ -0,0 +1,2 @@
1
+ import ConversationReturnButtonComponent from './return-button-component';
2
+ export default ConversationReturnButtonComponent;
@@ -0,0 +1,7 @@
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;
@@ -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,70 @@
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;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ declare type Props = {
3
+ className: string;
4
+ };
5
+ declare const ReturnButton: React.SFC<Props>;
6
+ export default ReturnButton;