@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.
Files changed (29) hide show
  1. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
  2. package/dist/cjs/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +4 -1
  3. package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +1 -1
  4. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -1
  5. package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +5 -2
  6. package/dist/cjs/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
  7. package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +143 -39
  8. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts +2 -3
  9. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -1
  10. package/dist/cjs/components/src/components/Organisms/Chat/ChatResult.js +17 -7
  11. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -1
  12. package/dist/cjs/components/src/components/Organisms/Chat/MessageUser.js +54 -22
  13. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -1
  14. package/dist/cjs/components/src/components/Organisms/Chat/ResultsDisplay.js +4 -1
  15. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
  16. package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +4 -1
  17. package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +1 -1
  18. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +1 -1
  19. package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +5 -2
  20. package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
  21. package/dist/esm/components/src/components/Organisms/Chat/Chat.js +131 -28
  22. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts +2 -3
  23. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.d.ts.map +1 -1
  24. package/dist/esm/components/src/components/Organisms/Chat/ChatResult.js +17 -7
  25. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.d.ts.map +1 -1
  26. package/dist/esm/components/src/components/Organisms/Chat/MessageUser.js +51 -20
  27. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.d.ts.map +1 -1
  28. package/dist/esm/components/src/components/Organisms/Chat/ResultsDisplay.js +4 -1
  29. package/package.json +12 -12
@@ -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;AAyHhE,eAAO,MAAM,WAAW,WAAoB,gBAAgB;;CAsE1D,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"}
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
- gap: '8px',
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
- return 'Filtering products';
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 (_jsxs("div", { className: "ss__chat__message-user", ...styling, children: [requestTypeLabel ? _jsx("div", { className: "ss__chat__message-user__request-type", children: requestTypeLabel }) : null, _jsxs("div", { className: "ss__chat__message-user__row", children: [_jsx("ul", { className: "ss__chat__message-user__attachments", children: chatItem.attachments?.length
146
- ? chatItem.attachments?.map((attachmentId) => {
147
- const attachment = store.currentChat?.attachments.get(attachmentId);
148
- switch (attachment?.type) {
149
- case 'image':
150
- 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));
151
- case 'product': {
152
- const canOpen = !!findProductInChat(store.currentChat?.chat, attachment.productId);
153
- return (_jsx("li", { className: classnames('ss__chat__message-user__attachment__product', {
154
- 'ss__chat__message-user__attachment__product--clickable': canOpen,
155
- }), 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));
156
- }
157
- case 'facet':
158
- 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));
159
- default:
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
- : null }), chatItem.text ? (_jsx("div", { className: "ss__chat__message-user__text", dangerouslySetInnerHTML: { __html: marked.parse(chatItem.text) } })) : null] })] }));
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;;CA2EhE,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"}
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
- const isConstrained = !isNarrow && isSideChatOpen && typeof window !== 'undefined' && window.innerWidth >= 768;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@athoscommerce/snap-preact",
3
- "version": "1.2.3-beta.2+2c4c9a7f8",
3
+ "version": "1.2.3-beta.3+25a2f4522",
4
4
  "description": "Snap Preact",
5
5
  "main": "dist/cjs/src/index.js",
6
6
  "module": "dist/esm/src/index.js",
@@ -26,16 +26,16 @@
26
26
  "storybook": "storybook dev -c ./components/.storybook -p 6006"
27
27
  },
28
28
  "dependencies": {
29
- "@athoscommerce/snap-client": "1.2.3-beta.2+2c4c9a7f8",
30
- "@athoscommerce/snap-controller": "1.2.3-beta.2+2c4c9a7f8",
31
- "@athoscommerce/snap-event-manager": "1.2.3-beta.2+2c4c9a7f8",
32
- "@athoscommerce/snap-logger": "1.2.3-beta.2+2c4c9a7f8",
33
- "@athoscommerce/snap-platforms": "1.2.3-beta.2+2c4c9a7f8",
34
- "@athoscommerce/snap-profiler": "1.2.3-beta.2+2c4c9a7f8",
35
- "@athoscommerce/snap-store-mobx": "1.2.3-beta.2+2c4c9a7f8",
36
- "@athoscommerce/snap-toolbox": "1.2.3-beta.2+2c4c9a7f8",
37
- "@athoscommerce/snap-tracker": "1.2.3-beta.2+2c4c9a7f8",
38
- "@athoscommerce/snap-url-manager": "1.2.3-beta.2+2c4c9a7f8",
29
+ "@athoscommerce/snap-client": "1.2.3-beta.3+25a2f4522",
30
+ "@athoscommerce/snap-controller": "1.2.3-beta.3+25a2f4522",
31
+ "@athoscommerce/snap-event-manager": "1.2.3-beta.3+25a2f4522",
32
+ "@athoscommerce/snap-logger": "1.2.3-beta.3+25a2f4522",
33
+ "@athoscommerce/snap-platforms": "1.2.3-beta.3+25a2f4522",
34
+ "@athoscommerce/snap-profiler": "1.2.3-beta.3+25a2f4522",
35
+ "@athoscommerce/snap-store-mobx": "1.2.3-beta.3+25a2f4522",
36
+ "@athoscommerce/snap-toolbox": "1.2.3-beta.3+25a2f4522",
37
+ "@athoscommerce/snap-tracker": "1.2.3-beta.3+25a2f4522",
38
+ "@athoscommerce/snap-url-manager": "1.2.3-beta.3+25a2f4522",
39
39
  "@emotion/react": "11.13.0",
40
40
  "classnames": "^2.3.2",
41
41
  "color": "^4.2.3",
@@ -97,5 +97,5 @@
97
97
  "require": "./dist/cjs/toolbox/src/index.js"
98
98
  }
99
99
  },
100
- "gitHead": "2c4c9a7f897641582adeeb5c5b57993143387548"
100
+ "gitHead": "25a2f452248ffbf114c80137ea8ad95516b3f106"
101
101
  }