@athoscommerce/snap-preact 1.2.3-beta.2 → 1.2.3-beta.3
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/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +4 -1
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +5 -2
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +143 -39
- package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts +2 -3
- package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.js +17 -7
- package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.js +54 -22
- package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.js +4 -1
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +4 -1
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +1 -1
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +5 -2
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/Chat.js +131 -28
- package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts +2 -3
- package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/ChatResult.js +17 -7
- package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/MessageUser.js +51 -20
- package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.js +4 -1
- package/package.json +12 -12
|
@@ -44,6 +44,11 @@ var defaultStyles = function () {
|
|
|
44
44
|
alignItems: 'center',
|
|
45
45
|
gap: '10px',
|
|
46
46
|
},
|
|
47
|
+
'.ss__chat__message-user__text-wrapper': {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexDirection: 'column',
|
|
50
|
+
alignItems: 'flex-end',
|
|
51
|
+
},
|
|
47
52
|
'.ss__chat__message-user__text': {
|
|
48
53
|
padding: '0.5em 1em',
|
|
49
54
|
borderRadius: '12px',
|
|
@@ -56,9 +61,10 @@ var defaultStyles = function () {
|
|
|
56
61
|
padding: 0,
|
|
57
62
|
margin: 0,
|
|
58
63
|
display: 'flex',
|
|
59
|
-
|
|
60
|
-
flexWrap: 'nowrap',
|
|
64
|
+
flexWrap: 'wrap',
|
|
61
65
|
justifyContent: 'flex-end',
|
|
66
|
+
flex: '0 0 40px',
|
|
67
|
+
alignSelf: 'flex-end',
|
|
62
68
|
'.ss__chat__message-user__attachment__product, .ss__chat__message-user__attachment__image, .ss__chat__message-user__attachment__facet': {
|
|
63
69
|
width: '40px',
|
|
64
70
|
height: '40px',
|
|
@@ -84,10 +90,16 @@ var defaultStyles = function () {
|
|
|
84
90
|
borderColor: colorPrimary,
|
|
85
91
|
},
|
|
86
92
|
},
|
|
93
|
+
'.ss__chat__message-user__attachment__facet--overflow': {
|
|
94
|
+
fontSize: '12px',
|
|
95
|
+
fontWeight: 600,
|
|
96
|
+
color: '#555',
|
|
97
|
+
},
|
|
87
98
|
},
|
|
88
99
|
});
|
|
89
100
|
};
|
|
90
101
|
function getRequestTypeLabel(chatItem) {
|
|
102
|
+
var _a, _b;
|
|
91
103
|
var requestType = chatItem.requestType;
|
|
92
104
|
if (!requestType || requestType === 'general')
|
|
93
105
|
return undefined;
|
|
@@ -97,7 +109,12 @@ function getRequestTypeLabel(chatItem) {
|
|
|
97
109
|
case 'productComparison':
|
|
98
110
|
return 'Comparing products';
|
|
99
111
|
case 'productSearch':
|
|
100
|
-
|
|
112
|
+
if ((_b = (_a = chatItem.request) === null || _a === void 0 ? void 0 : _a.searchFilters) === null || _b === void 0 ? void 0 : _b.length) {
|
|
113
|
+
return 'Filtering products';
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
return 'Searching products';
|
|
117
|
+
}
|
|
101
118
|
case 'imageSearch':
|
|
102
119
|
return 'Searching by image';
|
|
103
120
|
case 'productSimilar':
|
|
@@ -147,7 +164,6 @@ function findProductInChat(chat, productId) {
|
|
|
147
164
|
return null;
|
|
148
165
|
}
|
|
149
166
|
exports.MessageUser = (0, mobx_react_lite_1.observer)(function (props) {
|
|
150
|
-
var _a, _b;
|
|
151
167
|
var controller = props.controller, chatItem = props.chatItem, onViewProduct = props.onViewProduct;
|
|
152
168
|
var store = controller.store;
|
|
153
169
|
var styling = (0, utilities_1.mergeStyles)(props, defaultStyles);
|
|
@@ -169,24 +185,40 @@ exports.MessageUser = (0, mobx_react_lite_1.observer)(function (props) {
|
|
|
169
185
|
onViewProduct === null || onViewProduct === void 0 ? void 0 : onViewProduct(product);
|
|
170
186
|
}
|
|
171
187
|
};
|
|
172
|
-
return ((0, jsx_runtime_1.
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
return ((0, jsx_runtime_1.jsx)("div", __assign({ className: "ss__chat__message-user" }, styling, { children: (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__message-user__row", children: [(0, jsx_runtime_1.jsx)("ul", { className: "ss__chat__message-user__attachments", children: (function () {
|
|
189
|
+
var _a;
|
|
190
|
+
if (!((_a = chatItem.attachments) === null || _a === void 0 ? void 0 : _a.length))
|
|
191
|
+
return null;
|
|
192
|
+
var resolved = chatItem.attachments.map(function (id) { var _a; return (_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.attachments.get(id); }).filter(Boolean);
|
|
193
|
+
var totalFacets = resolved.filter(function (a) { return a.type === 'facet'; }).length;
|
|
194
|
+
var hiddenFacetCount = Math.max(0, totalFacets - 2);
|
|
195
|
+
var facetIndex = 0;
|
|
196
|
+
var items = resolved
|
|
197
|
+
.map(function (attachment) {
|
|
198
|
+
var _a;
|
|
199
|
+
switch (attachment.type) {
|
|
200
|
+
case 'image':
|
|
201
|
+
return ((0, jsx_runtime_1.jsx)("li", { className: "ss__chat__message-user__attachment__image", children: (0, jsx_runtime_1.jsx)(Image_1.Image, { style: { height: '200px', width: '200px' }, src: attachment.thumbnailUrl || attachment.base64 || '', alt: '' }) }, attachment.id));
|
|
202
|
+
case 'product': {
|
|
203
|
+
var canOpen = !!findProductInChat((_a = store.currentChat) === null || _a === void 0 ? void 0 : _a.chat, attachment.productId);
|
|
204
|
+
return ((0, jsx_runtime_1.jsx)("li", { className: (0, classnames_1.default)('ss__chat__message-user__attachment__product', {
|
|
205
|
+
'ss__chat__message-user__attachment__product--clickable': canOpen,
|
|
206
|
+
}), onClick: canOpen ? function () { return handleProductAttachmentClick(attachment); } : undefined, title: canOpen ? "View details for ".concat(attachment.name) : undefined, children: (0, jsx_runtime_1.jsx)(Image_1.Image, { style: { height: '200px', width: '200px' }, src: attachment.thumbnailUrl || '', alt: attachment.name }) }, attachment.id));
|
|
207
|
+
}
|
|
208
|
+
case 'facet': {
|
|
209
|
+
facetIndex += 1;
|
|
210
|
+
if (facetIndex > 2)
|
|
188
211
|
return null;
|
|
212
|
+
return ((0, jsx_runtime_1.jsx)("li", { className: "ss__chat__message-user__attachment__facet", children: (0, jsx_runtime_1.jsx)(Icon_1.Icon, { title: "Filter: ".concat(attachment.facetLabel, " = ").concat(attachment.label), icon: "filter-funnel", size: 27 }) }, attachment.id));
|
|
189
213
|
}
|
|
190
|
-
|
|
191
|
-
|
|
214
|
+
default:
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
.filter(Boolean);
|
|
219
|
+
if (hiddenFacetCount > 0) {
|
|
220
|
+
items.push((0, jsx_runtime_1.jsxs)("li", { className: "ss__chat__message-user__attachment__facet ss__chat__message-user__attachment__facet--overflow", title: "".concat(hiddenFacetCount, " more filter").concat(hiddenFacetCount === 1 ? '' : 's'), children: ["+", hiddenFacetCount] }, "facet-overflow"));
|
|
221
|
+
}
|
|
222
|
+
return items;
|
|
223
|
+
})() }), (0, jsx_runtime_1.jsxs)("div", { className: "ss__chat__message-user__text-wrapper", children: [requestTypeLabel ? (0, jsx_runtime_1.jsx)("div", { className: "ss__chat__message-user__request-type", children: requestTypeLabel }) : null, chatItem.text ? ((0, jsx_runtime_1.jsx)("div", { className: "ss__chat__message-user__text", dangerouslySetInnerHTML: { __html: marked_1.marked.parse(chatItem.text) } })) : null] })] }) })));
|
|
192
224
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultsDisplay.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/ResultsDisplay.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAgChE,eAAO,MAAM,cAAc,WAAoB,mBAAmB;;
|
|
1
|
+
{"version":3,"file":"ResultsDisplay.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/ResultsDisplay.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAgChE,eAAO,MAAM,cAAc,WAAoB,mBAAmB;;CA8EhE,CAAC;AAEH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,cAAc,CAAC;IAC3B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B"}
|
|
@@ -53,7 +53,9 @@ exports.ResultsDisplay = (0, mobx_react_lite_1.observer)(function (props) {
|
|
|
53
53
|
['inspirationResult', 'productComparison', 'productQuery'].includes(activeMessage.messageType) &&
|
|
54
54
|
(currentChat === null || currentChat === void 0 ? void 0 : currentChat.dismissedSideChatMessageId) !== activeMessage.id;
|
|
55
55
|
var isNarrow = typeof window !== 'undefined' && window.innerWidth < 550;
|
|
56
|
-
|
|
56
|
+
// only the tablet range needs the narrower carousel when the side chat is open;
|
|
57
|
+
// at >= 1200px there's room to keep 2.9 slides alongside the secondary chat
|
|
58
|
+
var isConstrained = !isNarrow && isSideChatOpen && typeof window !== 'undefined' && window.innerWidth >= 768 && window.innerWidth <= 1200;
|
|
57
59
|
var slidesPerView = isNarrow || isConstrained ? 1.9 : 2.9;
|
|
58
60
|
var carouselProps = {
|
|
59
61
|
breakpoints: undefined,
|
|
@@ -69,6 +71,7 @@ exports.ResultsDisplay = (0, mobx_react_lite_1.observer)(function (props) {
|
|
|
69
71
|
// buttons should be able to be clicked without triggering the product click
|
|
70
72
|
if (e.composedPath().some(function (el) { return el instanceof HTMLElement && el.matches('button, .ss__button, a'); }))
|
|
71
73
|
return;
|
|
74
|
+
controller.track.product.click(e, result);
|
|
72
75
|
controller.viewProduct(result);
|
|
73
76
|
onViewProduct === null || onViewProduct === void 0 ? void 0 : onViewProduct();
|
|
74
77
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatInspirationResultMessage.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAoB,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAyDjG,eAAO,MAAM,4BAA4B,gBAAyB,iCAAiC;;
|
|
1
|
+
{"version":3,"file":"ChatInspirationResultMessage.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAoB,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAyDjG,eAAO,MAAM,4BAA4B,gBAAyB,iCAAiC;;CA8GjG,CAAC;AAMH,MAAM,MAAM,iCAAiC,GAAG;IAC/C,QAAQ,EAAE,iCAAiC,CAAC;IAC5C,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC;CACjD,GAAG,+CAA+C,GAClD,cAAc,CAAC,iCAAiC,CAAC,CAAC;AAEnD,MAAM,MAAM,+CAA+C,GAAG;IAC7D,QAAQ,EAAE,iCAAiC,CAAC;CAC5C,CAAC;AAEF,MAAM,WAAW,gCAAgC;CAKhD"}
|
|
@@ -98,10 +98,13 @@ export const ChatInspirationResultMessage = observer((properties) => {
|
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
100
|
return inspirationSections.length ? (_jsx(CacheProvider, { children: _jsx("div", { className: classnames('ss__chat-inspiration-result-message', className, internalClassName), ...styling, children: _jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections'), children: inspirationSections.map((section, index) => (_jsxs("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section'), children: [_jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__title'), children: section.clusterTitle }), _jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__description'), children: section.clusterDescription }), _jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__queries'), children: section.searchQueries.map((searchTerm, index) => (_jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__queries__query'), onClick: () => {
|
|
101
|
+
if (controller?.store.loading || controller?.store.blocked)
|
|
102
|
+
return;
|
|
101
103
|
controller?.search({ data: { requestType: 'productSearch', searchTerm } });
|
|
102
104
|
}, children: searchTerm }, index))) }), _jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__products'), children: _jsx(Carousel, { ...subProps.Carousel, children: section.products.map((product) => {
|
|
103
105
|
const display = product?.display || product;
|
|
104
|
-
return (_jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__products__product'), children: _jsx(Image, { onClick: () => {
|
|
106
|
+
return (_jsx("div", { className: classnames('ss__chat-inspiration-result-message__inspiration-sections__section__products__product'), children: _jsx(Image, { onClick: (e) => {
|
|
107
|
+
controller?.track.product.click(e, product);
|
|
105
108
|
controller?.viewProduct(product);
|
|
106
109
|
onViewProduct?.();
|
|
107
110
|
}, alt: display?.mappings?.core?.name || '', src: display?.mappings?.core?.imageUrl || '' }) }, product.id));
|
|
@@ -73,7 +73,7 @@ export const ChatProductComparisonMessage = observer((properties) => {
|
|
|
73
73
|
console.warn('ChatProductComparisonMessage received message with unsupported type:', messageType, 'Expected type: productComparison');
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
|
-
const headings =
|
|
76
|
+
const headings = searchResults.length ? searchResults.map((r) => String(r?.id)) : [];
|
|
77
77
|
const getDisplay = (r) => r?.display || r;
|
|
78
78
|
const allProductsHaveImage = headings.length > 0 && headings.every((heading) => !!getDisplay(searchResults.find((r) => r?.id === heading))?.mappings?.core?.imageUrl);
|
|
79
79
|
return comparisonData.features.length ? (_jsx(CacheProvider, { children: _jsx("div", { className: classnames('ss__chat-product-comparison-message', className, internalClassName), ...styling, children: _jsx("div", { className: classnames('ss__chat-product-comparison-message__table-wrapper'), children: _jsxs("table", { className: classnames('ss__chat-product-comparison-message__table'), children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", {}), headings.map((heading) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatProductQueryMessage.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AA+ZrE,eAAO,MAAM,uBAAuB,gBAAyB,4BAA4B;;
|
|
1
|
+
{"version":3,"file":"ChatProductQueryMessage.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AA+ZrE,eAAO,MAAM,uBAAuB,gBAAyB,4BAA4B;;CA0OvF,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG;IAC1C,QAAQ,EAAE,2BAA2B,CAAC;IACtC,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;CAC5C,GAAG,0CAA0C,GAC7C,cAAc,CAAC,4BAA4B,CAAC,CAAC;AAE9C,MAAM,MAAM,2BAA2B,GAAG;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,cAAc,CAAC;IAC5B,aAAa,EAAE,GAAG,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACxD,QAAQ,EAAE,2BAA2B,CAAC;CACtC,CAAC;AAEF,MAAM,WAAW,2BAA2B;CAE3C"}
|
|
@@ -407,7 +407,10 @@ export const ChatProductQueryMessage = observer((properties) => {
|
|
|
407
407
|
controller?.store.currentChat?.popProductQueryMessage(chatItem.sourceMessageId);
|
|
408
408
|
controller?.store.clearProductQuickview();
|
|
409
409
|
};
|
|
410
|
-
return (_jsx(CacheProvider, { children: _jsxs("div", { className: classnames('ss__chat-product-query-message', className, internalClassName), ...styling, children: [_jsxs("div", { className: classnames('ss__chat-product-query-message__header'), children: [cameFromInspiration && (_jsxs("div", { className: classnames('ss__chat-product-query-message__header__back'), onClick: handleBack, children: [_jsx(Icon, { icon: "angle-left", size: "14px" }), _jsx("span", { children: "Back to inspiration" })] })), _jsxs("div", { className: classnames('ss__chat-product-query-message__header__product'), children: [displayedCore.imageUrl && (_jsx(Image, { className: classnames('ss__chat-product-query-message__header__product__image'), src: displayedCore.imageUrl, alt: displayedCore.name || '' })), _jsxs("div", { className: classnames('ss__chat-product-query-message__header__product__details'), children: [displayedCore.name && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__details__name'), children: displayedCore.url ? (_jsx("a", { href: displayedCore.url, target: "_blank", rel: "noopener noreferrer", children: displayedCore.name })) : (displayedCore.name) })), displayedCore.brand && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__details__brand'), children: displayedCore.brand })), displayedCore.price != null && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__details__price'), children: _jsx(Price, { value: displayedCore.price }) }))] }), _jsxs("div", { className: classnames('ss__chat-product-query-message__header__product__actions'), children: [displayedCore.url && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__actions__go-to-product'), children: _jsx("a", { href: displayedCore.url, target: "_blank", rel: "noopener noreferrer", children: "Go to product" }) })), _jsx("div", { className: classnames('ss__chat-product-query-message__header__product__actions__add-to-cart'), children: _jsx(Button, { content: 'Add to Cart', onClick: () =>
|
|
410
|
+
return (_jsx(CacheProvider, { children: _jsxs("div", { className: classnames('ss__chat-product-query-message', className, internalClassName), ...styling, children: [_jsxs("div", { className: classnames('ss__chat-product-query-message__header'), children: [cameFromInspiration && (_jsxs("div", { className: classnames('ss__chat-product-query-message__header__back'), onClick: handleBack, children: [_jsx(Icon, { icon: "angle-left", size: "14px" }), _jsx("span", { children: "Back to inspiration" })] })), _jsxs("div", { className: classnames('ss__chat-product-query-message__header__product'), children: [displayedCore.imageUrl && (_jsx(Image, { className: classnames('ss__chat-product-query-message__header__product__image'), src: displayedCore.imageUrl, alt: displayedCore.name || '' })), _jsxs("div", { className: classnames('ss__chat-product-query-message__header__product__details'), children: [displayedCore.name && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__details__name'), children: displayedCore.url ? (_jsx("a", { href: displayedCore.url, onClick: (e) => controller?.track.product.click(e, product), target: "_blank", rel: "noopener noreferrer", children: displayedCore.name })) : (displayedCore.name) })), displayedCore.brand && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__details__brand'), children: displayedCore.brand })), displayedCore.price != null && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__details__price'), children: _jsx(Price, { value: displayedCore.price }) }))] }), _jsxs("div", { className: classnames('ss__chat-product-query-message__header__product__actions'), children: [displayedCore.url && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__actions__go-to-product'), children: _jsx("a", { href: displayedCore.url, onClick: (e) => controller?.track.product.click(e, product), target: "_blank", rel: "noopener noreferrer", children: "Go to product" }) })), _jsx("div", { className: classnames('ss__chat-product-query-message__header__product__actions__add-to-cart'), children: _jsx(Button, { content: 'Add to Cart', onClick: () => {
|
|
411
|
+
controller?.track.product.addToCart(product);
|
|
412
|
+
controller?.addToCart(product);
|
|
413
|
+
} }) }), controller?.store.features.similarProducts.enabled && (_jsx("div", { className: classnames('ss__chat-product-query-message__header__product__actions__show-similar'), children: _jsx(Button, { content: 'Show Similar', onClick: () => controller?.discussProduct(sourceProduct, { requestType: 'productSimilar' }) }) }))] })] })] }), selections.length > 0 && (_jsx("div", { className: classnames('ss__chat-product-query-message__variants'), children: selections.map((selection) => (_jsxs("div", { children: [_jsxs("div", { className: classnames('ss__chat-product-query-message__variants__label'), children: [formatLabel(selection.field), " (", selection.values.length, ")"] }), _jsx("div", { className: classnames('ss__chat-product-query-message__variants__swatches'), children: selection.values.map((selectionValue) => {
|
|
411
414
|
const isUnavailable = !selectionValue.available;
|
|
412
415
|
const isSelected = selection.selected?.value === selectionValue.value;
|
|
413
416
|
return (_jsxs("div", { className: classnames('ss__chat-product-query-message__variants__swatch', {
|
|
@@ -417,5 +420,5 @@ export const ChatProductQueryMessage = observer((properties) => {
|
|
|
417
420
|
}) })] }, selection.field))) })), infoRows.length > 0 && (_jsxs("div", { className: classnames('ss__chat-product-query-message__section'), children: [_jsx("div", { className: classnames('ss__chat-product-query-message__section__title'), children: "Product Information" }), _jsx("table", { className: classnames('ss__chat-product-query-message__section__table'), children: _jsx("tbody", { children: infoRows.map((row) => (_jsxs("tr", { children: [_jsx("td", { children: row.label }), _jsx("td", { children: row.rawKey === 'availability' ? (_jsx("span", { className: classnames({
|
|
418
421
|
'ss__chat-product-query-message__section__table__availability--in-stock': row.value === 'In Stock',
|
|
419
422
|
'ss__chat-product-query-message__section__table__availability--out-of-stock': row.value === 'Out of Stock',
|
|
420
|
-
}), children: row.value === 'In Stock' ? `\u2713 ${row.value}` : row.value })) : (row.value) })] }, row.key))) }) })] })), descriptionRow && (_jsxs("div", { className: classnames('ss__chat-product-query-message__section'), children: [_jsx("div", { className: classnames('ss__chat-product-query-message__section__title'), children: "Description" }), _jsx("div", { className: classnames('ss__chat-product-query-message__section__description'), children: descriptionRow.value })] })), features.length > 0 && (_jsxs("div", { className: classnames('ss__chat-product-query-message__section'), children: [_jsx("div", { className: classnames('ss__chat-product-query-message__section__title'), children: "Features" }), _jsx("ul", { className: classnames('ss__chat-product-query-message__section__features'), children: features.map((feature, idx) => (_jsx("li", { children: feature }, idx))) })] }))] }) }));
|
|
423
|
+
}), children: row.value === 'In Stock' ? `\u2713 ${row.value}` : row.value })) : row.rawKey.toLowerCase() === 'price' ? (_jsx(Price, { value: Number(row.value) })) : (row.value) })] }, row.key))) }) })] })), descriptionRow && (_jsxs("div", { className: classnames('ss__chat-product-query-message__section'), children: [_jsx("div", { className: classnames('ss__chat-product-query-message__section__title'), children: "Description" }), _jsx("div", { className: classnames('ss__chat-product-query-message__section__description'), children: descriptionRow.value })] })), features.length > 0 && (_jsxs("div", { className: classnames('ss__chat-product-query-message__section'), children: [_jsx("div", { className: classnames('ss__chat-product-query-message__section__title'), children: "Features" }), _jsx("ul", { className: classnames('ss__chat-product-query-message__section__features'), children: features.map((feature, idx) => (_jsx("li", { children: feature }, idx))) })] }))] }) }));
|
|
421
424
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/Chat.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/Chat.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAwgCrE,eAAO,MAAM,IAAI,gBAAyB,SAAS,KAAG,GAAG,CAAC,OAAO;;CAwwC/D,CAAC;AAEH,MAAM,WAAW,SAAU,SAAQ,cAAc;IAChD,UAAU,EAAE,cAAc,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -170,11 +170,11 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
170
170
|
padding: '12px 16px',
|
|
171
171
|
fontSize: '14px',
|
|
172
172
|
color: '#333',
|
|
173
|
-
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.
|
|
173
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.2)',
|
|
174
174
|
cursor: 'pointer',
|
|
175
175
|
lineHeight: 1.4,
|
|
176
176
|
'&:hover': {
|
|
177
|
-
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.
|
|
177
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.2)',
|
|
178
178
|
},
|
|
179
179
|
},
|
|
180
180
|
},
|
|
@@ -220,6 +220,7 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
220
220
|
display: 'flex',
|
|
221
221
|
'.ss__chat__header__title__logo': {
|
|
222
222
|
height: '44px',
|
|
223
|
+
width: 'auto',
|
|
223
224
|
},
|
|
224
225
|
'.ss__chat__header__title__text': {
|
|
225
226
|
display: 'flex',
|
|
@@ -435,9 +436,9 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
435
436
|
alignItems: 'stretch',
|
|
436
437
|
'.ss__chat__content__header__comparisons__content__items': {
|
|
437
438
|
display: 'flex',
|
|
438
|
-
gap: '1em',
|
|
439
439
|
flex: '1 1 calc(100% - 100px)',
|
|
440
440
|
justifyContent: 'space-between',
|
|
441
|
+
gap: '0.5em',
|
|
441
442
|
},
|
|
442
443
|
'.ss__chat__content__header__comparisons__content__comparison': {
|
|
443
444
|
background: '#fff',
|
|
@@ -446,7 +447,7 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
446
447
|
display: 'flex',
|
|
447
448
|
flexDirection: 'column',
|
|
448
449
|
gap: '0.5em',
|
|
449
|
-
flex: '0 1
|
|
450
|
+
flex: '0 1 25%',
|
|
450
451
|
position: 'relative',
|
|
451
452
|
'&.ss__chat__content__header__comparisons__content__comparison--placeholder': {
|
|
452
453
|
border: '2px dashed #ddd',
|
|
@@ -503,7 +504,6 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
503
504
|
},
|
|
504
505
|
'.ss__chat__messages': {
|
|
505
506
|
flex: '1 1 auto',
|
|
506
|
-
overflowY: 'auto',
|
|
507
507
|
overscrollBehavior: 'contain',
|
|
508
508
|
margin: 0,
|
|
509
509
|
maxHeight: '100%',
|
|
@@ -511,6 +511,32 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
511
511
|
'.ss__chat__messages__end': {
|
|
512
512
|
height: '1px',
|
|
513
513
|
},
|
|
514
|
+
'.ss__chat__new-messages': {
|
|
515
|
+
position: 'sticky',
|
|
516
|
+
bottom: '10px',
|
|
517
|
+
display: 'flex',
|
|
518
|
+
alignItems: 'center',
|
|
519
|
+
justifyContent: 'center',
|
|
520
|
+
gap: '6px',
|
|
521
|
+
margin: '0 auto',
|
|
522
|
+
width: 'fit-content',
|
|
523
|
+
padding: '6px 16px',
|
|
524
|
+
background: colorPrimary,
|
|
525
|
+
color: '#fff',
|
|
526
|
+
borderRadius: '999px',
|
|
527
|
+
fontSize: '13px',
|
|
528
|
+
fontWeight: 500,
|
|
529
|
+
cursor: 'pointer',
|
|
530
|
+
boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
|
|
531
|
+
zIndex: 5,
|
|
532
|
+
'&:hover': {
|
|
533
|
+
background: '#1a2a5c',
|
|
534
|
+
},
|
|
535
|
+
svg: {
|
|
536
|
+
fill: '#fff',
|
|
537
|
+
stroke: '#fff',
|
|
538
|
+
},
|
|
539
|
+
},
|
|
514
540
|
'.ss__chat__message': {
|
|
515
541
|
marginBottom: '30px',
|
|
516
542
|
ul: {
|
|
@@ -675,13 +701,19 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
675
701
|
display: 'flex',
|
|
676
702
|
justifyContent: 'flex-end',
|
|
677
703
|
padding: '0 2px',
|
|
704
|
+
// reserve the slot so toggling the button's visibility doesn't reflow the header
|
|
705
|
+
visibility: 'hidden',
|
|
706
|
+
'&.ss__chat__actions__facets-apply--active': {
|
|
707
|
+
visibility: 'visible',
|
|
708
|
+
},
|
|
678
709
|
'.ss__button': {
|
|
679
710
|
background: '#253B80',
|
|
680
711
|
color: '#fff',
|
|
681
712
|
border: 'none',
|
|
682
713
|
borderRadius: '999px',
|
|
683
|
-
padding: '
|
|
684
|
-
fontSize: '
|
|
714
|
+
padding: '2px 10px',
|
|
715
|
+
fontSize: '12px',
|
|
716
|
+
lineHeight: '1.4',
|
|
685
717
|
cursor: 'pointer',
|
|
686
718
|
'&:not(.ss__button--disabled):hover': {
|
|
687
719
|
background: '#1a2a5c',
|
|
@@ -926,6 +958,7 @@ const defaultStyles = ({ mobile, offset, hasSideChat, footerHeight }) => {
|
|
|
926
958
|
padding: '0.5em 0',
|
|
927
959
|
margin: '0 0 0 1em',
|
|
928
960
|
flex: '1 0 auto',
|
|
961
|
+
border: 'none',
|
|
929
962
|
'&::placeholder': {
|
|
930
963
|
color: '#999',
|
|
931
964
|
opacity: 0.7,
|
|
@@ -1010,6 +1043,8 @@ export const Chat = observer((properties) => {
|
|
|
1010
1043
|
const [swipeAnimating, setSwipeAnimating] = useState(false);
|
|
1011
1044
|
const [mobileProductInfoOpen, setMobileProductInfoOpen] = useState(false);
|
|
1012
1045
|
const [footerHeight, setFooterHeight] = useState(0);
|
|
1046
|
+
const [showNewMessages, setShowNewMessages] = useState(false);
|
|
1047
|
+
const isNearBottomRef = useRef(true);
|
|
1013
1048
|
const updateSwipeOffset = (value) => {
|
|
1014
1049
|
swipeOffsetRef.current = value;
|
|
1015
1050
|
setSwipeOffsetRaw(value);
|
|
@@ -1017,15 +1052,78 @@ export const Chat = observer((properties) => {
|
|
|
1017
1052
|
const scrollToBottom = () => {
|
|
1018
1053
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
1019
1054
|
};
|
|
1020
|
-
//
|
|
1055
|
+
// Conditional scroll: only scrolls if the user is already near the bottom.
|
|
1056
|
+
// Passed to child components (e.g. image onLoad) so they don't yank the user
|
|
1057
|
+
// back to the bottom when they have scrolled up to read older messages.
|
|
1058
|
+
const scrollToBottomIfNear = () => {
|
|
1059
|
+
if (isNearBottomRef.current) {
|
|
1060
|
+
scrollToBottom();
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
// productQuery messages are filtered out of the main chat render (they only drive the side-chat panel),
|
|
1064
|
+
// so don't auto-scroll when one is added — otherwise clicking a product in the side chat scrolls the main thread.
|
|
1065
|
+
const visibleChatLength = (store.currentChat?.chat || []).filter((m) => m.messageType !== 'productQuery').length;
|
|
1066
|
+
// Scroll to bottom when chat opens
|
|
1021
1067
|
useEffect(() => {
|
|
1022
|
-
// if (store.open && messagesContainerRef.current) {
|
|
1023
|
-
// messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;
|
|
1024
|
-
// }
|
|
1025
1068
|
if (store.open) {
|
|
1026
1069
|
scrollToBottom();
|
|
1070
|
+
setShowNewMessages(false);
|
|
1071
|
+
isNearBottomRef.current = true;
|
|
1072
|
+
}
|
|
1073
|
+
}, [store.open]);
|
|
1074
|
+
// Handle new messages — auto-scroll for user messages, show popup for response messages when scrolled up
|
|
1075
|
+
useEffect(() => {
|
|
1076
|
+
if (!store.open)
|
|
1077
|
+
return;
|
|
1078
|
+
const chat = store.currentChat?.chat || [];
|
|
1079
|
+
const visibleChat = chat.filter((m) => m.messageType !== 'productQuery');
|
|
1080
|
+
const lastMessage = visibleChat[visibleChat.length - 1];
|
|
1081
|
+
if (!lastMessage)
|
|
1082
|
+
return;
|
|
1083
|
+
if (lastMessage.messageType === 'user') {
|
|
1084
|
+
scrollToBottom();
|
|
1085
|
+
setShowNewMessages(false);
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
if (isNearBottomRef.current) {
|
|
1089
|
+
scrollToBottom();
|
|
1090
|
+
setShowNewMessages(false);
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
setShowNewMessages(true);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}, [visibleChatLength]);
|
|
1097
|
+
// Scroll to show loading indicator when user sends a message
|
|
1098
|
+
useEffect(() => {
|
|
1099
|
+
if (store.open && store.loading) {
|
|
1100
|
+
scrollToBottom();
|
|
1101
|
+
}
|
|
1102
|
+
}, [store.loading]);
|
|
1103
|
+
// Track scroll position to dismiss the "New messages" popup when user scrolls to bottom
|
|
1104
|
+
useEffect(() => {
|
|
1105
|
+
const container = messagesContainerRef.current;
|
|
1106
|
+
if (!container)
|
|
1107
|
+
return;
|
|
1108
|
+
const handleScroll = () => {
|
|
1109
|
+
const threshold = 100;
|
|
1110
|
+
const isNearBottom = container.scrollHeight - container.scrollTop - container.clientHeight < threshold;
|
|
1111
|
+
isNearBottomRef.current = isNearBottom;
|
|
1112
|
+
if (isNearBottom) {
|
|
1113
|
+
setShowNewMessages(false);
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
container.addEventListener('scroll', handleScroll);
|
|
1117
|
+
return () => container.removeEventListener('scroll', handleScroll);
|
|
1118
|
+
}, [store.open]);
|
|
1119
|
+
// Re-focus the chat input on desktop after a search completes.
|
|
1120
|
+
// The input is disabled while loading, which causes the browser to drop focus.
|
|
1121
|
+
// On mobile we intentionally skip this so the virtual keyboard dismisses.
|
|
1122
|
+
useEffect(() => {
|
|
1123
|
+
if (!store.loading && !isMobile && store.open) {
|
|
1124
|
+
controller.focusInput();
|
|
1027
1125
|
}
|
|
1028
|
-
}, [store.
|
|
1126
|
+
}, [store.loading]);
|
|
1029
1127
|
// const subProps: ChatSubProps = {};
|
|
1030
1128
|
const activeMessage = store.currentChat?.activeMessage;
|
|
1031
1129
|
// On mobile, only auto-open the secondary panel for the first productComparison
|
|
@@ -1192,8 +1290,7 @@ export const Chat = observer((properties) => {
|
|
|
1192
1290
|
productQuery: 'Product Information',
|
|
1193
1291
|
}[activeMessage.messageType] || null }), _jsx("div", { className: "ss__chat__header__title__secondary", children: {
|
|
1194
1292
|
inspirationResult: 'Choose a style direction to explore',
|
|
1195
|
-
productComparison: `Comparing ${activeMessage?.
|
|
1196
|
-
activeMessage?.searchResults?.length} products`,
|
|
1293
|
+
productComparison: `Comparing ${activeMessage?.searchResults?.length || ''} products`,
|
|
1197
1294
|
productQuery: 'Complete product details',
|
|
1198
1295
|
}[activeMessage.messageType] || null })] }), _jsx("div", { className: "ss__chat__header__buttons", children: _jsx(Button, { className: "ss__chat__header__button--close", icon: { icon: 'close2', title: 'Close Chat' }, onClick: () => {
|
|
1199
1296
|
// clear any product attachments tied to the side chat (discuss product flow)
|
|
@@ -1245,34 +1342,39 @@ export const Chat = observer((properties) => {
|
|
|
1245
1342
|
}, children: _jsx(Icon, { icon: 'close-thin', size: '12px' }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { icon: 'plus-thin' }), _jsx("div", { className: 'ss__chat__content__header__comparisons__content__comparison--placeholder__text', children: "Add" })] })) }, index));
|
|
1246
1343
|
}) }), _jsx("div", { className: classnames('ss__chat__content__header__comparisons__action', {
|
|
1247
1344
|
'ss__chat__content__header__comparisons__action--hidden': (store.currentChat?.comparisons.compared.length || 0) < 2,
|
|
1248
|
-
}), children: _jsx(Button, { onClick: () => controller.search(), icon: { icon: 'compare', title: 'Compare' }, children: "Compare" }) })] })] })) }), _jsxs("div", { className: 'ss__chat__messages', ref: messagesContainerRef, children: [(!store.currentChat?.chat || store.currentChat.chat.length === 0) && store.welcomeMessage && (_jsxs("div", { className: "ss__chat__welcome", children: [_jsx("div", { className: "ss__chat__welcome__message", children: store.welcomeMessage }), _jsx(SuggestedQuestions, { questions: store.suggestedQuestions, controller: controller })] })), store.currentChat?.chat
|
|
1345
|
+
}), children: _jsx(Button, { onClick: () => controller.search(), icon: { icon: 'compare', title: 'Compare' }, children: "Compare" }) })] })] })) }), _jsxs("div", { className: 'ss__chat__messages', ref: messagesContainerRef, style: visibleChatLength ? { overflowY: 'auto', scrollbarGutter: 'stable' } : undefined, children: [(!store.currentChat?.chat || store.currentChat.chat.length === 0) && store.welcomeMessage && (_jsxs("div", { className: "ss__chat__welcome", children: [_jsx("div", { className: "ss__chat__welcome__message", children: store.welcomeMessage }), _jsx(SuggestedQuestions, { questions: store.suggestedQuestions, controller: controller })] })), store.currentChat?.chat
|
|
1249
1346
|
.filter((chatItem) => chatItem.messageType !== 'productQuery')
|
|
1250
1347
|
.map((chatItem, index) => (_jsx("div", { className: `ss__chat__message ss__chat__message--${chatItem.messageType}`, children: {
|
|
1251
1348
|
user: (_jsx(MessageUser, { chatItem: chatItem, controller: controller, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined })),
|
|
1252
|
-
text: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1253
|
-
content: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1254
|
-
productSearchResult: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1255
|
-
inspirationResult: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1256
|
-
productAnswer: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1349
|
+
text: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
|
|
1350
|
+
content: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
|
|
1351
|
+
productSearchResult: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
|
|
1352
|
+
inspirationResult: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
|
|
1353
|
+
productAnswer: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
|
|
1257
1354
|
productComparison: (() => {
|
|
1258
1355
|
// On mobile, only the first productComparison in the session
|
|
1259
1356
|
// auto-opens the secondary panel. Subsequent ones get a
|
|
1260
1357
|
// prominent "Show Details" button instead.
|
|
1261
1358
|
const comparisonMessages = (store.currentChat?.chat || []).filter((m) => m.messageType === 'productComparison');
|
|
1262
1359
|
const isFirst = comparisonMessages.length > 0 && comparisonMessages[0].id === chatItem.id;
|
|
1263
|
-
return (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1360
|
+
return (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, showDetailsButton: isMobile && !isFirst, sideChatOpen: !!shouldShowSideChat }));
|
|
1264
1361
|
})(),
|
|
1265
|
-
productRecommendation: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1362
|
+
productRecommendation: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, onViewProduct: isMobile ? () => setMobileProductInfoOpen(true) : undefined, sideChatOpen: !!shouldShowSideChat })),
|
|
1266
1363
|
actions: _jsx(SuggestedQuestions, { actions: chatItem.actions, controller: controller }),
|
|
1267
|
-
errorResponse: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1268
|
-
topicDrift: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom:
|
|
1364
|
+
errorResponse: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat })),
|
|
1365
|
+
topicDrift: (_jsx(MessageText, { chatItem: chatItem, controller: controller, scrollToBottom: scrollToBottomIfNear, sideChatOpen: !!shouldShowSideChat })),
|
|
1269
1366
|
productQuery: null,
|
|
1270
|
-
}[chatItem.messageType] || null }, index))), _jsx("div", { className: "ss__chat__messages__end", ref: messagesEndRef })
|
|
1367
|
+
}[chatItem.messageType] || null }, index))), _jsx("div", { className: "ss__chat__messages__end", ref: messagesEndRef }), showNewMessages && (_jsxs("div", { className: "ss__chat__new-messages", onClick: () => {
|
|
1368
|
+
scrollToBottom();
|
|
1369
|
+
setShowNewMessages(false);
|
|
1370
|
+
}, children: [_jsx(Icon, { icon: "angle-down", size: "12px" }), _jsx("span", { children: "New messages" })] }))] }), _jsx(ChatLoadingIndicator, { loading: store.loading, verbs: loadingVerbs }), !store.currentChat?.isExpired ? (_jsxs("div", { className: "ss__chat__content__footer", ref: footerRef, children: [store.error && _jsx("div", { className: "ss__chat__error", children: store.error.message }), store.currentChat?.sessionLimitReached && (_jsxs("div", { className: 'ss__chat__topic-drift', children: [_jsx(Icon, { icon: "info", size: "18px", className: 'ss__chat__topic-drift__icon--info' }), _jsxs("div", { className: 'ss__chat__topic-drift__text', children: [_jsx("span", { children: "Session limit reached" }), _jsx("span", { children: "This chat has reached its maximum number of interactions. Start a new session to continue." })] }), _jsx(Button, { className: 'ss__chat__topic-drift__button', onClick: () => {
|
|
1271
1371
|
controller.store.createChat();
|
|
1272
1372
|
}, children: "New Session" })] })), store.currentChat?.actions && store.currentChat.actions.length > 0 && (_jsx("div", { className: 'ss__chat__actions', children: store.currentChat?.actions.map((action, index) => (_jsx("div", { className: "ss__chat__actions__wrap", children: {
|
|
1273
|
-
facets: action.data.length ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "ss__chat__actions__facets-header", children: [_jsx("div", { className: "ss__chat__actions--title", children: "Filter by:" }), multiselectFacets && (store.currentChat?.attachments.attached.some((item) => item.type === 'facet')
|
|
1373
|
+
facets: action.data.length ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "ss__chat__actions__facets-header", children: [_jsx("div", { className: "ss__chat__actions--title", children: "Filter by:" }), multiselectFacets && (_jsx("div", { className: `ss__chat__actions__facets-apply${store.currentChat?.attachments.attached.some((item) => item.type === 'facet')
|
|
1374
|
+
? ' ss__chat__actions__facets-apply--active'
|
|
1375
|
+
: ''}`, children: _jsx(Button, { onClick: () => {
|
|
1274
1376
|
controller.search();
|
|
1275
|
-
}, children: "Apply
|
|
1377
|
+
}, children: "Apply" }) }))] }), _jsx("div", { className: "ss__chat__actions--facets", children: action.data.slice(0, 10).map((facet, idx) => {
|
|
1276
1378
|
if (!facet.values?.length)
|
|
1277
1379
|
return null;
|
|
1278
1380
|
return (_jsx("div", { className: `ss__chat__actions__facet ss__chat__actions__facet--${facet.type}`, children: _jsx(Dropdown, { usePortal: true, dropUp: true, button: _jsx(FacetButton, { label: facet.label || facet.field }), style: {
|
|
@@ -1509,6 +1611,7 @@ export const Chat = observer((properties) => {
|
|
|
1509
1611
|
const messageText = store.currentChat?.handleTopicDrift();
|
|
1510
1612
|
if (messageText) {
|
|
1511
1613
|
controller.store.createChat();
|
|
1614
|
+
controller.search({ data: { message: messageText } });
|
|
1512
1615
|
}
|
|
1513
1616
|
}, children: buttonText })), _jsx("span", { onClick: () => {
|
|
1514
1617
|
store.currentChat?.dismissTopicDrift();
|
|
@@ -1547,7 +1650,7 @@ export const Chat = observer((properties) => {
|
|
|
1547
1650
|
}, multiple: true, type: "file", accept: "image/*", className: "ss__chat__input__input__file" })] }))] }), _jsx("div", { className: 'ss__chat__input__actions', children: (() => {
|
|
1548
1651
|
const hasImageAttachment = (store.currentChat?.attachments.attached || []).some((item) => item.type === 'image' && !item.error);
|
|
1549
1652
|
const messageEmpty = !controller.store.inputValue.trim();
|
|
1550
|
-
const sendDisabled = store.blocked || store.currentChat?.sessionLimitReached || (hasImageAttachment && messageEmpty);
|
|
1653
|
+
const sendDisabled = store.blocked || store.currentChat?.sessionLimitReached || (hasImageAttachment && messageEmpty) || messageEmpty;
|
|
1551
1654
|
return (_jsx(Button, { className: "ss__chat__send-button", icon: { icon: 'send', title: 'Send Message' }, disabled: sendDisabled, onClick: () => {
|
|
1552
1655
|
if (sendDisabled)
|
|
1553
1656
|
return;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ChatController } from '@athoscommerce/snap-controller';
|
|
2
2
|
import { Product } from '@athoscommerce/snap-store-mobx';
|
|
3
3
|
import { ComponentProps } from '../../../types';
|
|
4
|
-
export declare const ChatResult: (
|
|
5
|
-
displayName: string;
|
|
6
|
-
};
|
|
4
|
+
export declare const ChatResult: (props: ChatResultProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
5
|
export interface ChatResultProps extends ComponentProps {
|
|
8
6
|
result: Product;
|
|
9
7
|
controller: ChatController;
|
|
10
8
|
scrollToBottom: () => void;
|
|
9
|
+
trackingRef?: (el: HTMLElement | null) => void;
|
|
11
10
|
}
|
|
12
11
|
//# sourceMappingURL=ChatResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatResult.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/ChatResult.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAMzD,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAyG7D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"ChatResult.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/ChatResult.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAMzD,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAyG7D,eAAO,MAAM,UAAU,8EA+GtB,CAAC;AAMF,MAAM,WAAW,eAAgB,SAAQ,cAAc;IACtD,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,cAAc,CAAC;IAC3B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/C"}
|