@athoscommerce/snap-preact 1.2.3-beta.1 → 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/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +6 -10
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +4 -8
- package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
- package/dist/cjs/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +5 -9
- package/dist/cjs/components/src/hooks/useAcRenderedInput.js +1 -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/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.js +4 -8
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.js +4 -8
- package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.d.ts.map +1 -1
- package/dist/esm/components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.js +4 -8
- package/dist/esm/components/src/hooks/useAcRenderedInput.js +1 -1
- package/package.json +12 -12
|
@@ -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"}
|
|
@@ -3,7 +3,7 @@ import { observer } from 'mobx-react-lite';
|
|
|
3
3
|
import { Image } from '../../Atoms/Image';
|
|
4
4
|
import { Button } from '../../Atoms/Button';
|
|
5
5
|
import { mergeProps, mergeStyles } from '../../../utilities';
|
|
6
|
-
import { css, useTheme, useTreePath, useSnap } from '../../../providers';
|
|
6
|
+
import { css, useTheme, useTreePath, useSnap, withTracking } from '../../../providers';
|
|
7
7
|
import { CalloutBadge, OverlayBadge, Price } from '../../..';
|
|
8
8
|
import { useComponent } from '../../../hooks';
|
|
9
9
|
const defaultStyles = () => {
|
|
@@ -100,7 +100,7 @@ const defaultStyles = () => {
|
|
|
100
100
|
},
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
|
-
export const ChatResult = observer((properties) => {
|
|
103
|
+
export const ChatResult = withTracking(observer((properties) => {
|
|
104
104
|
const globalTheme = useTheme();
|
|
105
105
|
const globalTreePath = useTreePath();
|
|
106
106
|
const snap = useSnap();
|
|
@@ -108,7 +108,7 @@ export const ChatResult = observer((properties) => {
|
|
|
108
108
|
treePath: globalTreePath,
|
|
109
109
|
};
|
|
110
110
|
const props = mergeProps('chatResult', globalTheme, defaultProps, properties);
|
|
111
|
-
const { controller, result, scrollToBottom, customComponent } = props;
|
|
111
|
+
const { controller, result, scrollToBottom, customComponent, trackingRef } = props;
|
|
112
112
|
if (customComponent) {
|
|
113
113
|
const ComponentOverride = useComponent(snap?.templates?.library.import.component.result || {}, customComponent);
|
|
114
114
|
if (ComponentOverride) {
|
|
@@ -116,6 +116,9 @@ export const ChatResult = observer((properties) => {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
const isInComparison = controller.store.currentChat?.comparisons.items.some((item) => item.result?.id === result.id);
|
|
119
|
+
// a result is "configurable" when it ships with selectable variant options
|
|
120
|
+
// (e.g. color/size); those need a selection before they can be added to cart
|
|
121
|
+
const isConfigurable = !!result.variants?.optionConfig && Object.keys(result.variants.optionConfig).length > 0;
|
|
119
122
|
const subProps = {
|
|
120
123
|
button: {
|
|
121
124
|
// component theme overrides
|
|
@@ -131,13 +134,20 @@ export const ChatResult = observer((properties) => {
|
|
|
131
134
|
},
|
|
132
135
|
};
|
|
133
136
|
const styling = mergeStyles(properties, defaultStyles);
|
|
134
|
-
return (_jsxs("div", { className: "ss__chat__result", ...styling, children: [_jsxs("div", { className: "ss__chat__result__image", children: [_jsx(OverlayBadge, { controller: controller, result: result, renderEmpty: true, children: _jsx(Image, { className: 'ss__chat__result__detail-slot__image', alt: result.display.mappings.core?.name || '', src: result.display.mappings.core?.imageUrl || '', ...subProps.image }) }), _jsxs("div", { className: "ss__chat__result__image__buttons", children: [controller.store.features.similarProducts.enabled && (_jsx(Button, { className: 'ss__chat__result__image__buttons__similar', content: 'Similar', onClick: () => {
|
|
137
|
+
return (_jsxs("div", { className: "ss__chat__result", ref: trackingRef, ...styling, children: [_jsxs("div", { className: "ss__chat__result__image", children: [_jsx(OverlayBadge, { controller: controller, result: result, renderEmpty: true, children: _jsx(Image, { className: 'ss__chat__result__detail-slot__image', alt: result.display.mappings.core?.name || '', src: result.display.mappings.core?.imageUrl || '', ...subProps.image }) }), _jsxs("div", { className: "ss__chat__result__image__buttons", children: [controller.store.features.similarProducts.enabled && (_jsx(Button, { className: 'ss__chat__result__image__buttons__similar', content: 'Similar', onClick: () => {
|
|
135
138
|
controller.discussProduct(result, { requestType: 'productSimilar' });
|
|
136
139
|
} })), _jsx(Button, { className: 'ss__chat__result__image__buttons__compare', content: isInComparison ? undefined : 'Compare', icon: isInComparison ? { icon: 'check-thin', title: 'Added to comparison' } : undefined, onClick: () => {
|
|
137
140
|
controller.compareProduct(result);
|
|
138
141
|
} })] }), _jsxs("div", { className: "ss__chat__result__image__icons", children: [_jsx(Button, { className: 'ss__chat__result__image__icons__icon--inquire', icon: { icon: 'chat', title: 'Discuss Product' }, onClick: () => {
|
|
139
142
|
controller.discussProduct(result, { requestType: 'productQuery' });
|
|
140
|
-
} }), _jsx(Button, { className: 'ss__chat__result__image__icons__icon--cart', icon: { icon: 'cart', title: 'Add to Cart' }, onClick: () => {
|
|
143
|
+
} }), _jsx(Button, { className: 'ss__chat__result__image__icons__icon--cart', icon: { icon: 'cart', title: isConfigurable ? 'Configure' : 'Add to Cart' }, onClick: () => {
|
|
144
|
+
// configurable products need a variant selection — open the product
|
|
145
|
+
// information panel so the user can pick options before adding to cart
|
|
146
|
+
if (isConfigurable) {
|
|
147
|
+
controller.viewProduct(result);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
controller.track.product.addToCart(result);
|
|
141
151
|
controller.addToCart(result);
|
|
142
|
-
} })] })] }), _jsxs("div", { className: "ss__chat__result__content", children: [result.display.mappings.core?.name && _jsx("div", { className: "ss__chat__result__content__title--primary", children: result.display.mappings.core?.name }), result.display.mappings.core?.price && (_jsx("div", { className: "ss__chat__result__content__price", children: _jsx(Price, { value: result.display.mappings.core?.price }) })), _jsx(CalloutBadge, { controller: controller, result: result })] })] }));
|
|
143
|
-
});
|
|
152
|
+
} })] })] }), _jsxs("div", { className: "ss__chat__result__content", children: [result.display.mappings.core?.name && (_jsx("div", { className: "ss__chat__result__content__title--primary", children: result.display.mappings.core?.name })), result.display.mappings.core?.price && (_jsx("div", { className: "ss__chat__result__content__price", children: _jsx(Price, { value: result.display.mappings.core?.price }) })), _jsx(CalloutBadge, { controller: controller, result: result })] })] }));
|
|
153
|
+
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUser.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/MessageUser.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageUser.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/MessageUser.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAwIhE,eAAO,MAAM,WAAW,WAAoB,gBAAgB;;CA6F1D,CAAC;AAEH,UAAU,gBAAgB;IACzB,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,cAAc,CAAC;IAC3B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;CACvC"}
|
|
@@ -27,6 +27,11 @@ const defaultStyles = () => {
|
|
|
27
27
|
alignItems: 'center',
|
|
28
28
|
gap: '10px',
|
|
29
29
|
},
|
|
30
|
+
'.ss__chat__message-user__text-wrapper': {
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
alignItems: 'flex-end',
|
|
34
|
+
},
|
|
30
35
|
'.ss__chat__message-user__text': {
|
|
31
36
|
padding: '0.5em 1em',
|
|
32
37
|
borderRadius: '12px',
|
|
@@ -39,9 +44,10 @@ const defaultStyles = () => {
|
|
|
39
44
|
padding: 0,
|
|
40
45
|
margin: 0,
|
|
41
46
|
display: 'flex',
|
|
42
|
-
|
|
43
|
-
flexWrap: 'nowrap',
|
|
47
|
+
flexWrap: 'wrap',
|
|
44
48
|
justifyContent: 'flex-end',
|
|
49
|
+
flex: '0 0 40px',
|
|
50
|
+
alignSelf: 'flex-end',
|
|
45
51
|
'.ss__chat__message-user__attachment__product, .ss__chat__message-user__attachment__image, .ss__chat__message-user__attachment__facet': {
|
|
46
52
|
width: '40px',
|
|
47
53
|
height: '40px',
|
|
@@ -67,6 +73,11 @@ const defaultStyles = () => {
|
|
|
67
73
|
borderColor: colorPrimary,
|
|
68
74
|
},
|
|
69
75
|
},
|
|
76
|
+
'.ss__chat__message-user__attachment__facet--overflow': {
|
|
77
|
+
fontSize: '12px',
|
|
78
|
+
fontWeight: 600,
|
|
79
|
+
color: '#555',
|
|
80
|
+
},
|
|
70
81
|
},
|
|
71
82
|
});
|
|
72
83
|
};
|
|
@@ -80,7 +91,12 @@ function getRequestTypeLabel(chatItem) {
|
|
|
80
91
|
case 'productComparison':
|
|
81
92
|
return 'Comparing products';
|
|
82
93
|
case 'productSearch':
|
|
83
|
-
|
|
94
|
+
if (chatItem.request?.searchFilters?.length) {
|
|
95
|
+
return 'Filtering products';
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return 'Searching products';
|
|
99
|
+
}
|
|
84
100
|
case 'imageSearch':
|
|
85
101
|
return 'Searching by image';
|
|
86
102
|
case 'productSimilar':
|
|
@@ -142,23 +158,38 @@ export const MessageUser = observer((props) => {
|
|
|
142
158
|
onViewProduct?.(product);
|
|
143
159
|
}
|
|
144
160
|
};
|
|
145
|
-
return (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
return (_jsx("div", { className: "ss__chat__message-user", ...styling, children: _jsxs("div", { className: "ss__chat__message-user__row", children: [_jsx("ul", { className: "ss__chat__message-user__attachments", children: (() => {
|
|
162
|
+
if (!chatItem.attachments?.length)
|
|
163
|
+
return null;
|
|
164
|
+
const resolved = chatItem.attachments.map((id) => store.currentChat?.attachments.get(id)).filter(Boolean);
|
|
165
|
+
const totalFacets = resolved.filter((a) => a.type === 'facet').length;
|
|
166
|
+
const hiddenFacetCount = Math.max(0, totalFacets - 2);
|
|
167
|
+
let facetIndex = 0;
|
|
168
|
+
const items = resolved
|
|
169
|
+
.map((attachment) => {
|
|
170
|
+
switch (attachment.type) {
|
|
171
|
+
case 'image':
|
|
172
|
+
return (_jsx("li", { className: "ss__chat__message-user__attachment__image", children: _jsx(Image, { style: { height: '200px', width: '200px' }, src: attachment.thumbnailUrl || attachment.base64 || '', alt: '' }) }, attachment.id));
|
|
173
|
+
case 'product': {
|
|
174
|
+
const canOpen = !!findProductInChat(store.currentChat?.chat, attachment.productId);
|
|
175
|
+
return (_jsx("li", { className: classnames('ss__chat__message-user__attachment__product', {
|
|
176
|
+
'ss__chat__message-user__attachment__product--clickable': canOpen,
|
|
177
|
+
}), onClick: canOpen ? () => handleProductAttachmentClick(attachment) : undefined, title: canOpen ? `View details for ${attachment.name}` : undefined, children: _jsx(Image, { style: { height: '200px', width: '200px' }, src: attachment.thumbnailUrl || '', alt: attachment.name }) }, attachment.id));
|
|
178
|
+
}
|
|
179
|
+
case 'facet': {
|
|
180
|
+
facetIndex += 1;
|
|
181
|
+
if (facetIndex > 2)
|
|
160
182
|
return null;
|
|
183
|
+
return (_jsx("li", { className: "ss__chat__message-user__attachment__facet", children: _jsx(Icon, { title: `Filter: ${attachment.facetLabel} = ${attachment.label}`, icon: "filter-funnel", size: 27 }) }, attachment.id));
|
|
161
184
|
}
|
|
162
|
-
|
|
163
|
-
|
|
185
|
+
default:
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
.filter(Boolean);
|
|
190
|
+
if (hiddenFacetCount > 0) {
|
|
191
|
+
items.push(_jsxs("li", { className: "ss__chat__message-user__attachment__facet ss__chat__message-user__attachment__facet--overflow", title: `${hiddenFacetCount} more filter${hiddenFacetCount === 1 ? '' : 's'}`, children: ["+", hiddenFacetCount] }, "facet-overflow"));
|
|
192
|
+
}
|
|
193
|
+
return items;
|
|
194
|
+
})() }), _jsxs("div", { className: "ss__chat__message-user__text-wrapper", children: [requestTypeLabel ? _jsx("div", { className: "ss__chat__message-user__request-type", children: requestTypeLabel }) : null, chatItem.text ? (_jsx("div", { className: "ss__chat__message-user__text", dangerouslySetInnerHTML: { __html: marked.parse(chatItem.text) } })) : null] })] }) }));
|
|
164
195
|
});
|
|
@@ -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"}
|
|
@@ -38,7 +38,9 @@ export const ResultsDisplay = observer((props) => {
|
|
|
38
38
|
['inspirationResult', 'productComparison', 'productQuery'].includes(activeMessage.messageType) &&
|
|
39
39
|
currentChat?.dismissedSideChatMessageId !== activeMessage.id;
|
|
40
40
|
const isNarrow = typeof window !== 'undefined' && window.innerWidth < 550;
|
|
41
|
-
|
|
41
|
+
// only the tablet range needs the narrower carousel when the side chat is open;
|
|
42
|
+
// at >= 1200px there's room to keep 2.9 slides alongside the secondary chat
|
|
43
|
+
const isConstrained = !isNarrow && isSideChatOpen && typeof window !== 'undefined' && window.innerWidth >= 768 && window.innerWidth <= 1200;
|
|
42
44
|
const slidesPerView = isNarrow || isConstrained ? 1.9 : 2.9;
|
|
43
45
|
const carouselProps = {
|
|
44
46
|
breakpoints: undefined,
|
|
@@ -54,6 +56,7 @@ export const ResultsDisplay = observer((props) => {
|
|
|
54
56
|
// buttons should be able to be clicked without triggering the product click
|
|
55
57
|
if (e.composedPath().some((el) => el instanceof HTMLElement && el.matches('button, .ss__button, a')))
|
|
56
58
|
return;
|
|
59
|
+
controller.track.product.click(e, result);
|
|
57
60
|
controller.viewProduct(result);
|
|
58
61
|
onViewProduct?.();
|
|
59
62
|
};
|
package/dist/esm/components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteFixed.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AA+CjG,eAAO,MAAM,iBAAiB,gBAAyB,sBAAsB;;
|
|
1
|
+
{"version":3,"file":"AutocompleteFixed.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteFixed/AutocompleteFixed.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AA+CjG,eAAO,MAAM,iBAAiB,gBAAyB,sBAAsB;;CAsN3E,CAAC;AAEH,UAAU,WAAW;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAQD,MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,EAAE,sBAAsB,CAAC;IACnC,eAAe,CAAC,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC;CAC7C,GAAG,oCAAoC,GACvC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAEzC,MAAM,MAAM,oCAAoC,GAAG;IAClD,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;CAC9C,GAAG,uBAAuB,CAAC"}
|
|
@@ -55,7 +55,10 @@ export const AutocompleteFixed = observer((properties) => {
|
|
|
55
55
|
};
|
|
56
56
|
const props = mergeProps('autocompleteFixed', globalTheme, defaultProps, properties);
|
|
57
57
|
const [active, setActive] = useState(false);
|
|
58
|
-
|
|
58
|
+
// Use an empty inputName so the rendered SearchInput does not participate in form
|
|
59
|
+
// serialization. The original input retains its name (e.g. 'q') so that native form
|
|
60
|
+
// submission still produces the expected ?q= query parameter.
|
|
61
|
+
const inputName = '';
|
|
59
62
|
let input = props.input;
|
|
60
63
|
let buttonSelector = props.buttonSelector;
|
|
61
64
|
let inputPlaceholderText = undefined;
|
|
@@ -63,13 +66,6 @@ export const AutocompleteFixed = observer((properties) => {
|
|
|
63
66
|
if (typeof input === 'string') {
|
|
64
67
|
input = document.querySelector(input);
|
|
65
68
|
}
|
|
66
|
-
const existingInputName = input?.getAttribute('name');
|
|
67
|
-
if (existingInputName) {
|
|
68
|
-
setInputName(existingInputName);
|
|
69
|
-
if (props.renderInput) {
|
|
70
|
-
input.setAttribute('name', '');
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
69
|
inputPlaceholderText = input?.getAttribute('placeholder');
|
|
74
70
|
}
|
|
75
71
|
if (!buttonSelector && input) {
|
package/dist/esm/components/src/components/Templates/AutocompleteModal/AutocompleteModal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteModal.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteModal/AutocompleteModal.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AA8DjG,eAAO,MAAM,iBAAiB,gBAAyB,sBAAsB;;
|
|
1
|
+
{"version":3,"file":"AutocompleteModal.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteModal/AutocompleteModal.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AA8DjG,eAAO,MAAM,iBAAiB,gBAAyB,sBAAsB;;CAiK3E,CAAC;AAQH,MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,EAAE,sBAAsB,CAAC;IACnC,eAAe,CAAC,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC;CAC7C,GAAG,oCAAoC,GACvC,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAEzC,MAAM,MAAM,oCAAoC,GAAG;IAClD,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,uBAAuB,CAAC"}
|
|
@@ -71,20 +71,16 @@ export const AutocompleteModal = observer((properties) => {
|
|
|
71
71
|
};
|
|
72
72
|
const props = mergeProps('autocompleteModal', globalTheme, defaultProps, properties);
|
|
73
73
|
const [active, setActive] = useState(false);
|
|
74
|
-
|
|
74
|
+
// Use an empty inputName so the rendered SearchInput does not participate in form
|
|
75
|
+
// serialization. The original input retains its name (e.g. 'q') so that native form
|
|
76
|
+
// submission still produces the expected ?q= query parameter.
|
|
77
|
+
const inputName = '';
|
|
75
78
|
let input = props.input;
|
|
76
79
|
let buttonSelector = props.buttonSelector;
|
|
77
80
|
if (input) {
|
|
78
81
|
if (typeof input === 'string') {
|
|
79
82
|
input = document.querySelector(input);
|
|
80
83
|
}
|
|
81
|
-
const existingInputName = input?.getAttribute('name');
|
|
82
|
-
if (existingInputName) {
|
|
83
|
-
setInputName(existingInputName);
|
|
84
|
-
if (props.renderInput) {
|
|
85
|
-
input.setAttribute('name', '');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
84
|
}
|
|
89
85
|
if (!buttonSelector && input) {
|
|
90
86
|
buttonSelector = input;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteSlideout.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAA2B,MAAM,0BAA0B,CAAC;AAsBvF,eAAO,MAAM,oBAAoB,gBAAyB,yBAAyB;;
|
|
1
|
+
{"version":3,"file":"AutocompleteSlideout.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Templates/AutocompleteSlideout/AutocompleteSlideout.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAsB,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAA2B,MAAM,0BAA0B,CAAC;AAsBvF,eAAO,MAAM,oBAAoB,gBAAyB,yBAAyB;;CAyJjF,CAAC;AAOH,MAAM,MAAM,yBAAyB,GAAG;IACvC,UAAU,EAAE,sBAAsB,CAAC;IACnC,eAAe,CAAC,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC;CAC7C,GAAG,uCAAuC,GAC1C,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAEzC,MAAM,MAAM,uCAAuC,GAAG;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,uBAAuB,CAAC"}
|