@telia-ace/widget-conversation 1.0.10 → 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.
- package/{lib-esm → dist}/agent.d.ts +0 -0
- package/{lib-esm → dist}/conversation-controller.d.ts +0 -0
- package/{lib-esm → dist}/conversation-form-adapter.d.ts +0 -0
- package/{lib-esm → dist}/conversation-platform.d.ts +0 -0
- package/{lib-esm → dist}/conversation-provider.d.ts +0 -0
- package/dist/conversation.js +1357 -0
- package/dist/conversation.js.map +1 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +867 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/resolve-entity-value.d.ts +0 -0
- package/dist/return-button.js +174 -0
- package/dist/return-button.js.map +1 -0
- package/{lib-esm → dist}/types.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-component.d.ts +5 -0
- package/{lib-esm → dist}/ui/conversation/conversation-content.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-input.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-loader.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-message.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation-styles.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/conversation.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/agent.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/custom-message-list-item.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/custom.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/system.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/timestamp.d.ts +0 -0
- package/{lib-esm → dist}/ui/conversation/message-types/user.d.ts +0 -0
- package/{lib-esm → dist}/ui/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/index.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/return-button-component.d.ts +0 -0
- package/{lib-esm → dist}/ui/return-button/return-button.d.ts +0 -0
- package/{lib-esm → dist}/user.d.ts +0 -0
- package/{lib-esm → dist}/utils/custom-message.d.ts +0 -0
- package/{lib-esm → dist}/utils/index.d.ts +0 -0
- package/{lib-esm → dist}/utils/open-chat-widget.d.ts +0 -0
- package/package.json +14 -15
- package/lib/agent.d.ts +0 -17
- package/lib/agent.js +0 -37
- package/lib/conversation-controller.d.ts +0 -88
- package/lib/conversation-controller.js +0 -318
- package/lib/conversation-form-adapter.d.ts +0 -7
- package/lib/conversation-form-adapter.js +0 -88
- package/lib/conversation-platform.d.ts +0 -49
- package/lib/conversation-platform.js +0 -295
- package/lib/conversation-provider.d.ts +0 -22
- package/lib/conversation-provider.js +0 -73
- package/lib/index.d.ts +0 -9
- package/lib/index.js +0 -17
- package/lib/resolve-entity-value.d.ts +0 -10
- package/lib/resolve-entity-value.js +0 -22
- package/lib/types.d.ts +0 -110
- package/lib/types.js +0 -19
- package/lib/ui/conversation/conversation-component.d.ts +0 -32
- package/lib/ui/conversation/conversation-component.js +0 -152
- package/lib/ui/conversation/conversation-content.d.ts +0 -11
- package/lib/ui/conversation/conversation-content.js +0 -240
- package/lib/ui/conversation/conversation-input.d.ts +0 -6
- package/lib/ui/conversation/conversation-input.js +0 -160
- package/lib/ui/conversation/conversation-loader.d.ts +0 -8
- package/lib/ui/conversation/conversation-loader.js +0 -18
- package/lib/ui/conversation/conversation-message.d.ts +0 -7
- package/lib/ui/conversation/conversation-message.js +0 -141
- package/lib/ui/conversation/conversation-styles.d.ts +0 -11
- package/lib/ui/conversation/conversation-styles.js +0 -65
- package/lib/ui/conversation/conversation.d.ts +0 -6
- package/lib/ui/conversation/conversation.js +0 -139
- package/lib/ui/conversation/index.d.ts +0 -2
- package/lib/ui/conversation/index.js +0 -7
- package/lib/ui/conversation/message-types/agent.d.ts +0 -11
- package/lib/ui/conversation/message-types/agent.js +0 -54
- package/lib/ui/conversation/message-types/custom-message-list-item.d.ts +0 -9
- package/lib/ui/conversation/message-types/custom-message-list-item.js +0 -27
- package/lib/ui/conversation/message-types/custom.d.ts +0 -9
- package/lib/ui/conversation/message-types/custom.js +0 -50
- package/lib/ui/conversation/message-types/index.d.ts +0 -5
- package/lib/ui/conversation/message-types/index.js +0 -16
- package/lib/ui/conversation/message-types/system.d.ts +0 -12
- package/lib/ui/conversation/message-types/system.js +0 -26
- package/lib/ui/conversation/message-types/timestamp.d.ts +0 -8
- package/lib/ui/conversation/message-types/timestamp.js +0 -36
- package/lib/ui/conversation/message-types/user.d.ts +0 -8
- package/lib/ui/conversation/message-types/user.js +0 -24
- package/lib/ui/index.d.ts +0 -2
- package/lib/ui/index.js +0 -10
- package/lib/ui/return-button/index.d.ts +0 -2
- package/lib/ui/return-button/index.js +0 -7
- package/lib/ui/return-button/return-button-component.d.ts +0 -19
- package/lib/ui/return-button/return-button-component.js +0 -70
- package/lib/ui/return-button/return-button.d.ts +0 -6
- package/lib/ui/return-button/return-button.js +0 -82
- package/lib/user.d.ts +0 -7
- package/lib/user.js +0 -16
- package/lib/utils/custom-message.d.ts +0 -3
- package/lib/utils/custom-message.js +0 -56
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -7
- package/lib/utils/open-chat-widget.d.ts +0 -4
- package/lib/utils/open-chat-widget.js +0 -148
- package/lib-esm/agent.js +0 -34
- package/lib-esm/conversation-controller.js +0 -314
- package/lib-esm/conversation-form-adapter.js +0 -85
- package/lib-esm/conversation-platform.js +0 -292
- package/lib-esm/conversation-provider.js +0 -70
- package/lib-esm/index.js +0 -6
- package/lib-esm/resolve-entity-value.js +0 -18
- package/lib-esm/types.js +0 -16
- package/lib-esm/ui/conversation/conversation-component.js +0 -127
- package/lib-esm/ui/conversation/conversation-content.js +0 -212
- package/lib-esm/ui/conversation/conversation-input.js +0 -135
- package/lib-esm/ui/conversation/conversation-loader.js +0 -13
- package/lib-esm/ui/conversation/conversation-message.js +0 -113
- package/lib-esm/ui/conversation/conversation-styles.js +0 -39
- package/lib-esm/ui/conversation/conversation.js +0 -111
- package/lib-esm/ui/conversation/index.js +0 -2
- package/lib-esm/ui/conversation/message-types/agent.js +0 -25
- package/lib-esm/ui/conversation/message-types/custom-message-list-item.js +0 -22
- package/lib-esm/ui/conversation/message-types/custom.js +0 -25
- package/lib-esm/ui/conversation/message-types/index.js +0 -5
- package/lib-esm/ui/conversation/message-types/system.js +0 -20
- package/lib-esm/ui/conversation/message-types/timestamp.js +0 -31
- package/lib-esm/ui/conversation/message-types/user.js +0 -19
- package/lib-esm/ui/index.js +0 -2
- package/lib-esm/ui/return-button/index.js +0 -2
- package/lib-esm/ui/return-button/return-button-component.js +0 -44
- package/lib-esm/ui/return-button/return-button.js +0 -54
- package/lib-esm/user.js +0 -13
- package/lib-esm/utils/custom-message.js +0 -52
- package/lib-esm/utils/index.js +0 -1
- package/lib-esm/utils/open-chat-widget.js +0 -142
|
@@ -1,152 +0,0 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
-
if (!m) return o;
|
|
39
|
-
var i = m.call(o), r, ar = [], e;
|
|
40
|
-
try {
|
|
41
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
-
}
|
|
43
|
-
catch (error) { e = { error: error }; }
|
|
44
|
-
finally {
|
|
45
|
-
try {
|
|
46
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
-
}
|
|
48
|
-
finally { if (e) throw e.error; }
|
|
49
|
-
}
|
|
50
|
-
return ar;
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var widget_ui_1 = require("@telia-ace/widget-ui");
|
|
54
|
-
var conversation_controller_1 = require("../../conversation-controller");
|
|
55
|
-
var conversation_platform_1 = require("../../conversation-platform");
|
|
56
|
-
/**
|
|
57
|
-
* Group items by sender, type and time. Current grouping threshold is 2000 ms.
|
|
58
|
-
* Put this as a property on either the component or on the provider?
|
|
59
|
-
* Could possibly be implemented directly in the createEntry method
|
|
60
|
-
* of the conversation controller to avoid iterating over the entire array on
|
|
61
|
-
* each update.
|
|
62
|
-
*/
|
|
63
|
-
var groupedMessages = function (messages, timeout) {
|
|
64
|
-
return messages.reduce(function (acc, current, index) {
|
|
65
|
-
var _a, _b;
|
|
66
|
-
var newItem = __assign(__assign({}, current), { content: [__assign(__assign({}, current.content), { key: current.key })] });
|
|
67
|
-
if (acc.length > 0 && current.type !== conversation_controller_1.ConversationMessageType.System) {
|
|
68
|
-
var previous = acc[acc.length - 1];
|
|
69
|
-
if ((!timeout && timeout !== 0) ||
|
|
70
|
-
Math.abs(previous.timestamp - current.timestamp) < timeout) {
|
|
71
|
-
if (((_a = previous.sender) === null || _a === void 0 ? void 0 : _a.name) === ((_b = current.sender) === null || _b === void 0 ? void 0 : _b.name) &&
|
|
72
|
-
previous.type === current.type) {
|
|
73
|
-
previous.timestamp = current.timestamp;
|
|
74
|
-
previous.content.push(__assign(__assign({}, current.content), { key: current.key }));
|
|
75
|
-
return acc;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
acc.push(newItem);
|
|
80
|
-
return acc;
|
|
81
|
-
}, []);
|
|
82
|
-
};
|
|
83
|
-
var ConversationComponent = function (container) {
|
|
84
|
-
return Promise.all([
|
|
85
|
-
conversation_platform_1.ConversationPlatform.getInstance(container),
|
|
86
|
-
container.getAsync('router'),
|
|
87
|
-
]).then(function (_a) {
|
|
88
|
-
var _b = __read(_a, 2), platform = _b[0], router = _b[1];
|
|
89
|
-
return (0, widget_ui_1.createReactComponent)(container, 'conversation', Promise.resolve().then(function () { return __importStar(require('./conversation')); }), function (component) {
|
|
90
|
-
var routeData = router.getRouteData();
|
|
91
|
-
var name = routeData.params.id || component.node.name || 'component';
|
|
92
|
-
var conversation = platform.createController(name);
|
|
93
|
-
var isNewController = platform.registerController(conversation, component);
|
|
94
|
-
var messageGroupingTimeout = 3 * 60 * 1000;
|
|
95
|
-
var setProperties = function (properties) {
|
|
96
|
-
var _a = properties.providers, providers = _a === void 0 ? [] : _a;
|
|
97
|
-
if (providers) {
|
|
98
|
-
var providerKeys = Array.isArray(providers) ? providers : [providers];
|
|
99
|
-
conversation.setProviders(providerKeys);
|
|
100
|
-
return providerKeys;
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
setProperties(component.properties(setProperties));
|
|
104
|
-
conversation.setComponentMountedState(true);
|
|
105
|
-
var writeMessages = function (messageStream) {
|
|
106
|
-
var loading = messageStream.loading, typingActors = messageStream.typingActors, messages = messageStream.messages;
|
|
107
|
-
component.writeProperties({
|
|
108
|
-
loading: loading,
|
|
109
|
-
typingActors: typingActors,
|
|
110
|
-
messages: groupedMessages(messages, messageGroupingTimeout),
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
writeMessages(conversation.getMessageStream());
|
|
114
|
-
if (isNewController) {
|
|
115
|
-
// todo: dont create actions here, there will be duplicates due to reuseController = true
|
|
116
|
-
component.actions.create('user-submit', function (data, options) {
|
|
117
|
-
if (options) {
|
|
118
|
-
var preventDefault = options.preventDefault, validationPromise = options.validationPromise;
|
|
119
|
-
if (preventDefault) {
|
|
120
|
-
if (validationPromise) {
|
|
121
|
-
validationPromise().then(function (text) {
|
|
122
|
-
if (text) {
|
|
123
|
-
conversation.user.print(text);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
conversation.user.print(data.text);
|
|
131
|
-
});
|
|
132
|
-
component.actions.create('user-typing', function (data, options) { });
|
|
133
|
-
component.actions.create('form', function (data, options) { });
|
|
134
|
-
component.actions.create('action', function (data, options) { });
|
|
135
|
-
}
|
|
136
|
-
var unsubscribe = conversation.events.subscribe('conversation:updated', function (e, conversationData) {
|
|
137
|
-
writeMessages(conversationData);
|
|
138
|
-
});
|
|
139
|
-
return function () {
|
|
140
|
-
conversation.setComponentMountedState(false);
|
|
141
|
-
unsubscribe();
|
|
142
|
-
if (!conversation.active) {
|
|
143
|
-
// unregisterController();
|
|
144
|
-
// todo: add possibility to dispose this through extendComponent()
|
|
145
|
-
// component.dispose();
|
|
146
|
-
writeMessages({ messages: [], typingActors: [], loading: false });
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}, { reuseController: true });
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
exports.default = ConversationComponent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConversationMessageContent } from '../../types';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
className?: string;
|
|
5
|
-
content: ConversationMessageContent;
|
|
6
|
-
isUser: boolean;
|
|
7
|
-
stacked?: string;
|
|
8
|
-
CustomComponent?: any;
|
|
9
|
-
};
|
|
10
|
-
declare const ConversationContent: React.FC<Props>;
|
|
11
|
-
export default ConversationContent;
|
|
@@ -1,240 +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 __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_forms_1 = require("@telia-ace/widget-forms");
|
|
61
|
-
var widget_ui_1 = require("@telia-ace/widget-ui");
|
|
62
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
63
|
-
var react_1 = __importStar(require("react"));
|
|
64
|
-
var styled_components_1 = __importStar(require("styled-components"));
|
|
65
|
-
var types_1 = require("../../types");
|
|
66
|
-
var conversation_styles_1 = require("./conversation-styles");
|
|
67
|
-
var message_types_1 = require("./message-types");
|
|
68
|
-
var custom_message_list_item_1 = __importDefault(require("./message-types/custom-message-list-item"));
|
|
69
|
-
var imageLightboxRenderer = function (attrs) { return react_1.default.createElement(widget_ui_1.Lightbox, { attrs: attrs }); };
|
|
70
|
-
var htmlParseInstructions = {
|
|
71
|
-
transform: {
|
|
72
|
-
img: imageLightboxRenderer,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
var ConversationContent = function (_a) {
|
|
76
|
-
var content = _a.content, isUser = _a.isUser, stacked = _a.stacked;
|
|
77
|
-
var dispatch = (0, widget_ui_1.useDispatch)();
|
|
78
|
-
var title = content.title, body = content.body, actions = content.actions, form = content.form, type = content.type, items = content.items;
|
|
79
|
-
if (type)
|
|
80
|
-
return react_1.default.createElement(message_types_1.CustomMessage, { type: type, content: content, isUser: isUser, stacked: stacked });
|
|
81
|
-
return (react_1.default.createElement(conversation_styles_1.MessageContent, { noPadding: true, user: isUser, stacked: !!stacked && stacked, fullWidth: !!form || !!actions },
|
|
82
|
-
title && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
|
|
83
|
-
react_1.default.createElement(conversation_styles_1.MessageTitle, { variant: "h2" }, title))),
|
|
84
|
-
body && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
|
|
85
|
-
react_1.default.createElement(StyledHtml, { html: body, htmlParseInstruction: htmlParseInstructions }))),
|
|
86
|
-
form && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
|
|
87
|
-
react_1.default.createElement(StyledForm, __assign({}, form, { onChange: function (key, data) {
|
|
88
|
-
dispatch('form', {
|
|
89
|
-
data: data,
|
|
90
|
-
formKey: form.schema.id,
|
|
91
|
-
actionKey: key,
|
|
92
|
-
});
|
|
93
|
-
} })))),
|
|
94
|
-
actions && (react_1.default.createElement(conversation_styles_1.MessageContentPart, null,
|
|
95
|
-
react_1.default.createElement(StyledActionList, { items: Object.keys(actions).map(function (i) {
|
|
96
|
-
return { label: actions[i], actionKey: i };
|
|
97
|
-
}), renderItem: function (item) {
|
|
98
|
-
return (react_1.default.createElement("li", { key: item.actionKey },
|
|
99
|
-
react_1.default.createElement(StyledActionButton, { onClick: function () {
|
|
100
|
-
dispatch('action', item.actionKey);
|
|
101
|
-
} }, item.label)));
|
|
102
|
-
} }))),
|
|
103
|
-
items && (react_1.default.createElement(react_1.Fragment, null,
|
|
104
|
-
react_1.default.createElement(conversation_styles_1.MessageContentPart, { key: (0, widget_utilities_1.uuid)(), noPadding: true },
|
|
105
|
-
react_1.default.createElement(StyledActionList, { items: items.map(function (_a) {
|
|
106
|
-
var _b = __read(_a, 2), type = _b[0], content = _b[1];
|
|
107
|
-
return { type: type, content: content };
|
|
108
|
-
}), renderItem: function (item) {
|
|
109
|
-
var itemKey = (0, widget_utilities_1.uuid)();
|
|
110
|
-
switch (item.type) {
|
|
111
|
-
case types_1.ConversationMessageListItemType.Header: {
|
|
112
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
113
|
-
react_1.default.createElement(HeaderText, null, item.content)));
|
|
114
|
-
}
|
|
115
|
-
case types_1.ConversationMessageListItemType.Text: {
|
|
116
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
117
|
-
react_1.default.createElement("span", null, item.content)));
|
|
118
|
-
}
|
|
119
|
-
case types_1.ConversationMessageListItemType.HTML: {
|
|
120
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
121
|
-
react_1.default.createElement(StyledHtml, { html: item.content.body, htmlParseInstruction: htmlParseInstructions })));
|
|
122
|
-
}
|
|
123
|
-
case types_1.ConversationMessageListItemType.Separator: {
|
|
124
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey, noPadding: true },
|
|
125
|
-
react_1.default.createElement(SeparatorPadding, null,
|
|
126
|
-
react_1.default.createElement(Separator, null))));
|
|
127
|
-
}
|
|
128
|
-
case types_1.ConversationMessageListItemType.LinkList: {
|
|
129
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
130
|
-
react_1.default.createElement(StyledLinkList, { items: Object.keys(item.content.actions).map(function (i) {
|
|
131
|
-
return {
|
|
132
|
-
label: item.content.actions[i],
|
|
133
|
-
actionKey: i,
|
|
134
|
-
};
|
|
135
|
-
}), renderItem: function (item) {
|
|
136
|
-
return (react_1.default.createElement("li", { key: item.actionKey },
|
|
137
|
-
react_1.default.createElement(StyledLinkButton, { help: item.actionKey === 'help', onClick: function () {
|
|
138
|
-
dispatch('action', item.actionKey);
|
|
139
|
-
} },
|
|
140
|
-
item.label,
|
|
141
|
-
item.actionKey === 'help' && (react_1.default.createElement(widget_ui_1.SymbolBadge, { size: 14, symbol: {
|
|
142
|
-
type: 'Svg',
|
|
143
|
-
content: 'caret-down',
|
|
144
|
-
} })))));
|
|
145
|
-
} })));
|
|
146
|
-
}
|
|
147
|
-
case types_1.ConversationMessageListItemType.ButtonList: {
|
|
148
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
149
|
-
react_1.default.createElement(StyledButtonList, { items: Object.keys(item.content.actions).map(function (i) {
|
|
150
|
-
return {
|
|
151
|
-
label: item.content.actions[i],
|
|
152
|
-
actionKey: i,
|
|
153
|
-
};
|
|
154
|
-
}), renderItem: function (item) {
|
|
155
|
-
return (react_1.default.createElement("li", { key: item.actionKey },
|
|
156
|
-
react_1.default.createElement(StyledButtonListButton, { onClick: function () {
|
|
157
|
-
dispatch('action', item.actionKey);
|
|
158
|
-
} }, item.label)));
|
|
159
|
-
} })));
|
|
160
|
-
}
|
|
161
|
-
case types_1.ConversationMessageListItemType.NoGoodAlternative: {
|
|
162
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
163
|
-
react_1.default.createElement(NoGoodAlternativeWrapper, { onClick: function () {
|
|
164
|
-
dispatch('action', 'help');
|
|
165
|
-
} },
|
|
166
|
-
react_1.default.createElement(widget_ui_1.SymbolBadge, { size: 14, symbol: {
|
|
167
|
-
type: 'FontAwesome',
|
|
168
|
-
content: 'meh-o',
|
|
169
|
-
} }),
|
|
170
|
-
react_1.default.createElement("span", null, item.content.body))));
|
|
171
|
-
}
|
|
172
|
-
case types_1.ConversationMessageListItemType.FeedbackList: {
|
|
173
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
174
|
-
react_1.default.createElement(StyledButtonList, { items: Object.keys(item.content.actions).map(function (i) {
|
|
175
|
-
return {
|
|
176
|
-
label: item.content.actions[i],
|
|
177
|
-
actionKey: i,
|
|
178
|
-
};
|
|
179
|
-
}), renderItem: function (item) {
|
|
180
|
-
return (react_1.default.createElement(FeedbackItem, { key: item.actionKey },
|
|
181
|
-
react_1.default.createElement(FeedbackButton, { className: "humany-feedback-button", disabled: false, "aria-pressed": true, "data-selected": true, "data-direction": 'vertical', onClick: function () {
|
|
182
|
-
dispatch('action', item.actionKey);
|
|
183
|
-
} },
|
|
184
|
-
react_1.default.createElement(widget_ui_1.Icon, { faIcon: item.actionKey == 'yes'
|
|
185
|
-
? 'smile-o'
|
|
186
|
-
: 'frown-o' }),
|
|
187
|
-
react_1.default.createElement("span", null, item.label))));
|
|
188
|
-
} })));
|
|
189
|
-
}
|
|
190
|
-
default: {
|
|
191
|
-
return (react_1.default.createElement(ConversationListItem, { key: itemKey },
|
|
192
|
-
react_1.default.createElement(custom_message_list_item_1.default, { type: item.type, content: item.content })));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
} }))))));
|
|
196
|
-
};
|
|
197
|
-
var StyledForm = (0, styled_components_1.default)(widget_forms_1.FormComponent)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n & button.humany-form-component-button {\n ", ";\n display: block;\n width: 100%;\n margin-bottom: ", ";\n }\n & button.humany-form-component-submit {\n width: 100%;\n margin: 0;\n :not(:last-child) {\n margin-bottom: ", ";\n }\n }\n"], ["\n & button.humany-form-component-button {\n ", ";\n display: block;\n width: 100%;\n margin-bottom: ", ";\n }\n & button.humany-form-component-submit {\n width: 100%;\n margin: 0;\n :not(:last-child) {\n margin-bottom: ", ";\n }\n }\n"])), function (p) {
|
|
198
|
-
var _a, _b;
|
|
199
|
-
return (0, widget_ui_1.invertedHoverButton)({
|
|
200
|
-
active: false,
|
|
201
|
-
primaryColor: (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary,
|
|
202
|
-
secondaryColor: (_b = p.theme.colors) === null || _b === void 0 ? void 0 : _b.accent,
|
|
203
|
-
});
|
|
204
|
-
}, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
205
|
-
var StyledHtml = (0, styled_components_1.default)(widget_ui_1.Html)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n white-space: pre-wrap;\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n"], ["\n white-space: pre-wrap;\n a {\n color: ", ";\n &:focus {\n ", ";\n }\n }\n"])), function (p) { return p.theme.colors.link; }, function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
|
|
206
|
-
var StyledActionList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n margin: 0 -", ";\n > li {\n margin: ", ";\n }\n"], ["\n padding: 0;\n list-style: none;\n margin: 0 -", ";\n > li {\n margin: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
207
|
-
var StyledButtonList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n > li {\n margin: ", " ", ";\n margin-left: 0;\n display: inline-block;\n }\n"], ["\n padding: 0;\n list-style: none;\n > li {\n margin: ", " ", ";\n margin-left: 0;\n display: inline-block;\n }\n"])), 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.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
208
|
-
var StyledButtonListButton = styled_components_1.default.button(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n display: block;\n text-align: left;\n background-color: ", ";\n width: 100%;\n color: #fff;\n &:focus {\n ", "\n }\n"], ["\n ", ";\n display: block;\n text-align: left;\n background-color: ", ";\n width: 100%;\n color: #fff;\n &:focus {\n ", "\n }\n"])), widget_ui_1.buttonCss, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) {
|
|
209
|
-
var _a;
|
|
210
|
-
return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n ", "\n background-color: transparent;\n "], ["\n ", "\n background-color: transparent;\n "])), widget_ui_1.borderTabStyle);
|
|
211
|
-
});
|
|
212
|
-
var StyledLinkList = (0, styled_components_1.default)(widget_ui_1.List)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 0;\n list-style: none;\n > li {\n margin-bottom: ", ";\n\n &:last-child {\n margin-bottom: 0;\n }\n }\n"], ["\n padding: 0;\n list-style: none;\n > li {\n margin-bottom: ", ";\n\n &:last-child {\n margin-bottom: 0;\n }\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
213
|
-
var HeaderText = styled_components_1.default.strong(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n font-size: ", ";\n"], ["\n font-size: ", ";\n"])), function (p) { var _a; return (_a = p.theme.fonts) === null || _a === void 0 ? void 0 : _a.huge; });
|
|
214
|
-
var StyledLinkButton = styled_components_1.default.button(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: block;\n background-color: transparent;\n text-align: left;\n border: none;\n padding: 0;\n font-weight: 300;\n font-family: inherit;\n cursor: pointer;\n color: ", ";\n\n ", "\n"], ["\n display: block;\n background-color: transparent;\n text-align: left;\n border: none;\n padding: 0;\n font-weight: 300;\n font-family: inherit;\n cursor: pointer;\n color: ", ";\n\n ", "\n"])), function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary; }, function (p) {
|
|
215
|
-
var _a, _b;
|
|
216
|
-
return p.help && (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n color: ", ";\n text-decoration: underline;\n\n i,\n svg {\n margin-left: ", ";\n }\n "], ["\n color: ", ";\n text-decoration: underline;\n\n i,\n svg {\n margin-left: ", ";\n }\n "])), (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text, (_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.small);
|
|
217
|
-
});
|
|
218
|
-
var StyledActionButton = styled_components_1.default.button(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n font-family: Lato;\n font-size: ", ";\n font-weight: 300;\n &:focus {\n ", "\n }\n"], ["\n ", ";\n display: block;\n background-color: ", ";\n width: 100%;\n color: #fff;\n font-family: Lato;\n font-size: ", ";\n font-weight: 300;\n &:focus {\n ", "\n }\n"])), widget_ui_1.buttonCss, 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.fonts) === null || _a === void 0 ? void 0 : _a.huge; }, function (p) {
|
|
219
|
-
var _a;
|
|
220
|
-
return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n ", "\n background-color: transparent;\n "], ["\n ", "\n background-color: transparent;\n "])), widget_ui_1.borderTabStyle);
|
|
221
|
-
});
|
|
222
|
-
var SeparatorPadding = styled_components_1.default.div(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n padding-top: calc(", " - ", ");\n padding-bottom: calc(", " - ", ");\n"], ["\n padding-top: calc(", " - ", ");\n padding-bottom: calc(", " - ", ");\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.normal; }, 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.normal; });
|
|
223
|
-
var Separator = styled_components_1.default.div(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n background-color: #efefef;\n height: 1px;\n width: 100%;\n"], ["\n background-color: #efefef;\n height: 1px;\n width: 100%;\n"])));
|
|
224
|
-
var NoGoodAlternativeWrapper = styled_components_1.default.div(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n\n > i,\n svg {\n margin-right: ", ";\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n\n > i,\n svg {\n margin-right: ", ";\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; });
|
|
225
|
-
var ConversationListItem = styled_components_1.default.li(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n padding-left: ", ";\n padding-right: ", ";\n"], ["\n padding-left: ", ";\n padding-right: ", ";\n"])), function (p) { var _a; return (p.noPadding ? 0 : (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium); }, function (p) { var _a; return (p.noPadding ? 0 : (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.medium); });
|
|
226
|
-
var FeedbackItem = styled_components_1.default.li(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n @media (min-width: 768px) {\n display: list-item !important;\n margin-right: 0 !important;\n margin-top: ", " !important;\n }\n"], ["\n @media (min-width: 768px) {\n display: list-item !important;\n margin-right: 0 !important;\n margin-top: ", " !important;\n }\n"])), function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.normal; });
|
|
227
|
-
var FeedbackButton = styled_components_1.default.button(templateObject_20 || (templateObject_20 = __makeTemplateObject(["\n @media (min-width: 768px) {\n min-width: 100%;\n margin-right: 0;\n }\n display: inline-block;\n font-size: ", ";\n border-color: ", " !important;\n font-weight: 300;\n && {\n margin-right: ", ";\n }\n ", "\n ", "\n ", "\n i {\n margin: 0 ", " 0 0;\n }\n span {\n }\n"], ["\n @media (min-width: 768px) {\n min-width: 100%;\n margin-right: 0;\n }\n display: inline-block;\n font-size: ", ";\n border-color: ", " !important;\n font-weight: 300;\n && {\n margin-right: ", ";\n }\n ", "\n ", "\n ", "\n i {\n margin: 0 ", " 0 0;\n }\n span {\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.primary; }, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; }, function (p) {
|
|
228
|
-
var _a, _b;
|
|
229
|
-
return p['data-direction'] === 'horizontal' && (0, styled_components_1.css)(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n width: 225px;\n max-width: calc(50% - ", " - ", ");\n "], ["\n width: 225px;\n max-width: calc(50% - ", " - ", ");\n "])), (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.large, (_b = p.theme.sizes) === null || _b === void 0 ? void 0 : _b.small);
|
|
230
|
-
}, function (p) {
|
|
231
|
-
return p['data-direction'] === 'vertical' && (0, styled_components_1.css)(templateObject_19 || (templateObject_19 = __makeTemplateObject(["\n min-width: 150px;\n "], ["\n min-width: 150px;\n "])));
|
|
232
|
-
}, function (p) {
|
|
233
|
-
var _a;
|
|
234
|
-
return (0, widget_ui_1.invertedHoverButton)({
|
|
235
|
-
primaryColor: "".concat((_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary),
|
|
236
|
-
secondaryColor: '#FFFFFF',
|
|
237
|
-
});
|
|
238
|
-
}, function (p) { var _a; return (_a = p.theme.sizes) === null || _a === void 0 ? void 0 : _a.small; });
|
|
239
|
-
exports.default = ConversationContent;
|
|
240
|
-
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, templateObject_17, templateObject_18, templateObject_19, templateObject_20;
|
|
@@ -1,160 +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 __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 __rest = (this && this.__rest) || function (s, e) {
|
|
41
|
-
var t = {};
|
|
42
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
43
|
-
t[p] = s[p];
|
|
44
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
45
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
46
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
47
|
-
t[p[i]] = s[p[i]];
|
|
48
|
-
}
|
|
49
|
-
return t;
|
|
50
|
-
};
|
|
51
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
52
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
53
|
-
if (!m) return o;
|
|
54
|
-
var i = m.call(o), r, ar = [], e;
|
|
55
|
-
try {
|
|
56
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
57
|
-
}
|
|
58
|
-
catch (error) { e = { error: error }; }
|
|
59
|
-
finally {
|
|
60
|
-
try {
|
|
61
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
62
|
-
}
|
|
63
|
-
finally { if (e) throw e.error; }
|
|
64
|
-
}
|
|
65
|
-
return ar;
|
|
66
|
-
};
|
|
67
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
-
var widget_ui_1 = require("@telia-ace/widget-ui");
|
|
69
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
70
|
-
var react_1 = __importStar(require("react"));
|
|
71
|
-
var styled_components_1 = __importStar(require("styled-components"));
|
|
72
|
-
var ConversationInput = function (_a) {
|
|
73
|
-
var className = _a.className;
|
|
74
|
-
var _b = __read((0, react_1.useState)(''), 2), inputText = _b[0], setInputText = _b[1];
|
|
75
|
-
var _c = __read((0, react_1.useState)(false), 2), inputFocus = _c[0], setInputFocus = _c[1];
|
|
76
|
-
var _d = __read((0, react_1.useState)(0), 2), calculatedLineHeight = _d[0], setCalculatedLineHeight = _d[1];
|
|
77
|
-
var _e = __read((0, react_1.useState)(0), 2), textareaMaxHeight = _e[0], setTextareaMaxHeight = _e[1];
|
|
78
|
-
var dispatch = (0, widget_ui_1.useDispatch)();
|
|
79
|
-
var _f = (0, widget_ui_1.useProperties)(), _g = _f.inputPlaceholder, inputPlaceholder = _g === void 0 ? 'Type your message' : _g, _h = _f.inputHidden, inputHidden = _h === void 0 ? false : _h, _j = _f.inputDisabled, inputDisabled = _j === void 0 ? false : _j, _k = _f.sendButtonLabel, sendButtonLabel = _k === void 0 ? 'Send message' : _k, _l = _f.inputMultiline, multiline = _l === void 0 ? true : _l;
|
|
80
|
-
var _m = __read((0, widget_ui_1.useScroll)(true), 2), scrollableCss = _m[0], inputRef = _m[1];
|
|
81
|
-
(0, react_1.useEffect)(function () {
|
|
82
|
-
if (inputRef.current) {
|
|
83
|
-
var _a = getComputedStyle(inputRef.current), lineHeight = _a.lineHeight, maxHeight = _a.maxHeight;
|
|
84
|
-
if (lineHeight && lineHeight.indexOf('px') > -1) {
|
|
85
|
-
var lineHeightNumber = lineHeight.split('px');
|
|
86
|
-
var calcLH = parseInt(lineHeightNumber[0], 10);
|
|
87
|
-
setCalculatedLineHeight(calcLH);
|
|
88
|
-
var maxHeightNumber = maxHeight.split('px');
|
|
89
|
-
setTextareaMaxHeight(parseInt(maxHeightNumber[0], 10));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, [inputRef.current]);
|
|
93
|
-
var submit = function (e) {
|
|
94
|
-
if (!e.shiftKey || !multiline) {
|
|
95
|
-
e.preventDefault();
|
|
96
|
-
if (inputText && inputText.length > 0) {
|
|
97
|
-
dispatch('user-submit', { text: inputText });
|
|
98
|
-
setInputText('');
|
|
99
|
-
onChange('');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
else if (inputText.length < 1) {
|
|
103
|
-
e.preventDefault();
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
var getCategories = function (e) {
|
|
107
|
-
e.preventDefault();
|
|
108
|
-
dispatch('action', 'burger-clicked');
|
|
109
|
-
};
|
|
110
|
-
var calculateHeight = function (value) {
|
|
111
|
-
if (multiline && inputRef.current) {
|
|
112
|
-
var scrollHeight = inputRef.current.scrollHeight;
|
|
113
|
-
if (scrollHeight > calculatedLineHeight) {
|
|
114
|
-
inputRef.current.style.height = 'auto';
|
|
115
|
-
var areaHeight = scrollHeight;
|
|
116
|
-
if (value.length < 1) {
|
|
117
|
-
areaHeight = calculatedLineHeight;
|
|
118
|
-
}
|
|
119
|
-
inputRef.current.style.height = "".concat(areaHeight, "px");
|
|
120
|
-
if (areaHeight >= textareaMaxHeight) {
|
|
121
|
-
inputRef.current.style.overflowY = 'scroll';
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
inputRef.current.style.overflowY = 'hidden';
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
var onChange = function (value) {
|
|
130
|
-
calculateHeight(value);
|
|
131
|
-
setInputText(value);
|
|
132
|
-
if (value && value.length > 0) {
|
|
133
|
-
dispatch('user-typing', { textLength: value.length });
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
if (inputHidden) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return (react_1.default.createElement(Wrapper, { grow: multiline, className: (0, widget_utilities_1.appendClassNames)('humany-conversation-input', className), "data-has-focus": inputFocus, scrollableCss: scrollableCss },
|
|
140
|
-
react_1.default.createElement(StyledButton, { disabled: inputDisabled, onClick: getCategories, title: sendButtonLabel, "aria-label": sendButtonLabel },
|
|
141
|
-
react_1.default.createElement(widget_ui_1.SymbolBadge, { size: 22, symbol: { type: 'Svg', content: 'options' } })),
|
|
142
|
-
multiline ? (react_1.default.createElement(StyledTextArea, { value: inputText, onChange: onChange, onEnter: submit, disabled: inputDisabled, "aria-label": inputPlaceholder, placeholder: inputPlaceholder, onFocusChange: setInputFocus, type: 'textarea', rows: 1, ref: inputRef })) : (react_1.default.createElement(StyledInput, { value: inputText, onChange: onChange, onEnter: submit, disabled: inputDisabled, "aria-label": inputPlaceholder, placeholder: inputPlaceholder, onFocusChange: setInputFocus })),
|
|
143
|
-
react_1.default.createElement(StyledButton, { disabled: inputDisabled, onClick: submit, title: sendButtonLabel, "aria-label": sendButtonLabel },
|
|
144
|
-
react_1.default.createElement(SendSymbol, { size: 22, symbol: { type: 'Svg', content: 'send' }, hasContent: inputText && inputText.length }))));
|
|
145
|
-
};
|
|
146
|
-
var StyledTextArea = (0, styled_components_1.default)(widget_ui_1.Input)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n resize: none;\n flex: 1;\n flex-shrink: 1;\n min-height: 1.2em;\n max-height: 148px;\n line-height: 1.2em;\n height: 1.2em;\n padding: 0;\n margin: ", " ", ";\n font-size: ", ";\n border: none;\n transition: height 200ms linear;\n outline: none;\n"], ["\n resize: none;\n flex: 1;\n flex-shrink: 1;\n min-height: 1.2em;\n max-height: 148px;\n line-height: 1.2em;\n height: 1.2em;\n padding: 0;\n margin: ", " ", ";\n font-size: ", ";\n border: none;\n transition: height 200ms linear;\n outline: none;\n"])), 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.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; });
|
|
147
|
-
var StyledInput = (0, styled_components_1.default)(widget_ui_1.Input)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n flex: 1;\n border: none;\n background-color: transparent;\n font-weight: 300;\n font-size: ", ";\n line-height: 1.2em;\n outline: none;\n padding-left: ", ";\n color: ", ";\n &::placeholder {\n color: ", ";\n font-style: italic;\n }\n"], ["\n flex: 1;\n border: none;\n background-color: transparent;\n font-weight: 300;\n font-size: ", ";\n line-height: 1.2em;\n outline: none;\n padding-left: ", ";\n color: ", ";\n &::placeholder {\n color: ", ";\n font-style: italic;\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.sizes) === null || _a === void 0 ? void 0 : _a.large; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.text; }, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.textLight; });
|
|
148
|
-
var StyledButton = (0, styled_components_1.default)(widget_ui_1.Button)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n flex: 0 0 50px;\n align-self: stretch;\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n &:focus {\n ", ";\n }\n"], ["\n flex: 0 0 50px;\n align-self: stretch;\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n &:focus {\n ", ";\n }\n"])), function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
|
|
149
|
-
var Wrapper = styled_components_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n ", "\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n background-color: ", ";\n border-top: ", ";\n ", "\n ", " {\n ", "\n }\n"], ["\n ", "\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n background-color: ", ";\n border-top: ", ";\n ", "\n ", " {\n ", "\n }\n"])), function (p) {
|
|
150
|
-
return p.grow
|
|
151
|
-
? (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n min-height: 50px;\n max-height: 150px;\n "], ["\n min-height: 50px;\n max-height: 150px;\n "]))) : (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n height: 50px;\n "], ["\n height: 50px;\n "])));
|
|
152
|
-
}, function (p) { var _a; return (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.accent; }, function (p) { return p.theme.inputBorder; }, function (p) {
|
|
153
|
-
return p['data-has-focus'] && (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n ", ";\n "], ["\n ", ";\n "])), function (p) { var _a; return ((_a = p.theme.accessibility) === null || _a === void 0 ? void 0 : _a.isTabbing) && widget_ui_1.borderTabStyle; });
|
|
154
|
-
}, StyledTextArea, function (p) { return !!p.scrollableCss && p.scrollableCss; });
|
|
155
|
-
var SendSymbol = (0, styled_components_1.default)(function (_a) {
|
|
156
|
-
var hasContent = _a.hasContent, other = __rest(_a, ["hasContent"]);
|
|
157
|
-
return react_1.default.createElement(widget_ui_1.SymbolBadge, __assign({}, other));
|
|
158
|
-
})(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n line,\n path {\n stroke: ", ";\n fill: ", ";\n }\n"], ["\n line,\n path {\n stroke: ", ";\n fill: ", ";\n }\n"])), function (p) { var _a; return (p.hasContent ? (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary : '#a6a6a6'); }, function (p) { var _a; return (p.hasContent ? (_a = p.theme.colors) === null || _a === void 0 ? void 0 : _a.primary : '#a6a6a6'); });
|
|
159
|
-
exports.default = ConversationInput;
|
|
160
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ConversationMessageSender } from '../../types';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
className?: string;
|
|
5
|
-
agentData?: ConversationMessageSender;
|
|
6
|
-
};
|
|
7
|
-
declare const ConversationLoader: React.FC<Props>;
|
|
8
|
-
export default ConversationLoader;
|
|
@@ -1,18 +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 react_1 = __importDefault(require("react"));
|
|
7
|
-
var conversation_styles_1 = require("./conversation-styles");
|
|
8
|
-
var ConversationLoader = function (_a) {
|
|
9
|
-
var className = _a.className, agentData = _a.agentData;
|
|
10
|
-
return (react_1.default.createElement(conversation_styles_1.ContentBundle, null,
|
|
11
|
-
react_1.default.createElement(conversation_styles_1.MessageContainer, null,
|
|
12
|
-
react_1.default.createElement(conversation_styles_1.MessageContent, null,
|
|
13
|
-
react_1.default.createElement(conversation_styles_1.Loader, null,
|
|
14
|
-
react_1.default.createElement("div", null),
|
|
15
|
-
react_1.default.createElement("div", null),
|
|
16
|
-
react_1.default.createElement("div", null))))));
|
|
17
|
-
};
|
|
18
|
-
exports.default = ConversationLoader;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BundledConversationMessage } from './conversation-component';
|
|
3
|
-
declare type Props = {
|
|
4
|
-
className?: string;
|
|
5
|
-
} & BundledConversationMessage;
|
|
6
|
-
declare const ConversationMessageComponent: React.FC<Props>;
|
|
7
|
-
export default ConversationMessageComponent;
|