@athoscommerce/snap-preact 1.13.3-beta.168 → 1.13.3-beta.191
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.js +3 -1
- package/dist/cjs/components/src/components/Molecules/ChatMessageText/ChatMessageText.js +2 -1
- package/dist/cjs/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.js +4 -0
- package/dist/cjs/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +1 -0
- package/dist/cjs/components/src/components/Molecules/ChatQuickview/ChatQuickview.js +514 -0
- package/dist/cjs/components/src/components/Molecules/{ChatProductQueryMessage → ChatQuickview}/index.js +1 -1
- package/dist/cjs/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.js +2 -2
- package/dist/cjs/components/src/components/Molecules/Slideshow/Slideshow.js +47 -20
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.js +12 -5
- package/dist/cjs/components/src/components/Organisms/Chat/Chat.lang.js +5 -0
- package/dist/cjs/components/src/components/Organisms/Chat/components/ChatAttachments.js +5 -4
- package/dist/cjs/components/src/components/Organisms/Chat/components/ChatComposer.js +3 -3
- package/dist/cjs/components/src/components/Organisms/Chat/components/ChatSideChat.js +3 -3
- package/dist/cjs/components/src/components/Organisms/Chat/components/chatAccentTheme.js +22 -20
- package/dist/cjs/components/src/components/Organisms/QuickviewLayout/QuickviewLayout.js +44 -11
- package/dist/cjs/components/src/index.js +1 -1
- package/dist/cjs/components/src/providers/themeComponents.js +1 -1
- package/dist/cjs/src/Snap.js +13 -1
- package/dist/cjs/src/Templates/Stores/LibraryStore.js +2 -2
- package/dist/cjs/src/Templates/Stores/library/languages/ar.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/de.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/es.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/fr.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/hi.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/it.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/ja.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/ko.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/nl.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/pt.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/ru.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/tr.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/vi.js +45 -34
- package/dist/cjs/src/Templates/Stores/library/languages/zh.js +45 -34
- package/dist/cjs/src/create/createChatController.js +1 -0
- package/dist/esm/components/src/components/Atoms/Button/Button.d.ts +1 -1
- package/dist/esm/components/src/components/Atoms/Button/Button.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.d.ts +12 -5
- package/dist/esm/components/src/components/Molecules/ChatAttachmentContext/ChatAttachmentContext.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts +13 -2
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatInspirationResultMessage/ChatInspirationResultMessage.js +3 -1
- package/dist/esm/components/src/components/Molecules/ChatMessageText/ChatMessageText.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatMessageText/ChatMessageText.js +2 -1
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.d.ts +17 -3
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatMessageUser/ChatMessageUser.js +4 -0
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts +7 -1
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/ChatProductComparisonMessage/ChatProductComparisonMessage.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatQuickview/ChatQuickview.d.ts +30 -0
- package/dist/esm/components/src/components/Molecules/ChatQuickview/ChatQuickview.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatQuickview/ChatQuickview.js +508 -0
- package/dist/esm/components/src/components/Molecules/ChatQuickview/index.d.ts +2 -0
- package/dist/esm/components/src/components/Molecules/ChatQuickview/index.d.ts.map +1 -0
- package/dist/esm/components/src/components/Molecules/ChatQuickview/index.js +1 -0
- package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.js +2 -2
- package/dist/esm/components/src/components/Molecules/Slideshow/Slideshow.d.ts.map +1 -1
- package/dist/esm/components/src/components/Molecules/Slideshow/Slideshow.js +47 -20
- package/dist/esm/components/src/components/Organisms/Chat/Chat.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/Chat.js +12 -5
- package/dist/esm/components/src/components/Organisms/Chat/Chat.lang.d.ts +3 -0
- package/dist/esm/components/src/components/Organisms/Chat/Chat.lang.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/Chat.lang.js +5 -0
- package/dist/esm/components/src/components/Organisms/Chat/components/ChatAttachments.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/components/ChatAttachments.js +5 -4
- package/dist/esm/components/src/components/Organisms/Chat/components/ChatComposer.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/components/ChatComposer.js +3 -3
- package/dist/esm/components/src/components/Organisms/Chat/components/ChatSideChat.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/components/ChatSideChat.js +3 -3
- package/dist/esm/components/src/components/Organisms/Chat/components/chatAccentTheme.d.ts +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/components/chatAccentTheme.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/Chat/components/chatAccentTheme.js +22 -20
- package/dist/esm/components/src/components/Organisms/QuickviewLayout/QuickviewLayout.d.ts +5 -1
- package/dist/esm/components/src/components/Organisms/QuickviewLayout/QuickviewLayout.d.ts.map +1 -1
- package/dist/esm/components/src/components/Organisms/QuickviewLayout/QuickviewLayout.js +44 -11
- package/dist/esm/components/src/index.d.ts +1 -1
- package/dist/esm/components/src/index.d.ts.map +1 -1
- package/dist/esm/components/src/index.js +1 -1
- package/dist/esm/components/src/providers/langComponents.d.ts +2 -2
- package/dist/esm/components/src/providers/langComponents.d.ts.map +1 -1
- package/dist/esm/components/src/providers/themeComponents.d.ts +7 -7
- package/dist/esm/components/src/providers/themeComponents.d.ts.map +1 -1
- package/dist/esm/components/src/providers/themeComponents.js +1 -1
- package/dist/esm/src/Snap.d.ts +1 -0
- package/dist/esm/src/Snap.d.ts.map +1 -1
- package/dist/esm/src/Snap.js +13 -1
- package/dist/esm/src/Templates/Stores/LibraryStore.d.ts +2 -2
- package/dist/esm/src/Templates/Stores/LibraryStore.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/LibraryStore.js +2 -2
- package/dist/esm/src/Templates/Stores/library/languages/ar.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/ar.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/de.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/de.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/es.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/es.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/fr.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/fr.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/hi.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/hi.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/it.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/it.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/ja.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/ja.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/ko.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/ko.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/nl.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/nl.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/pt.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/pt.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/ru.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/ru.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/tr.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/tr.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/vi.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/vi.js +45 -34
- package/dist/esm/src/Templates/Stores/library/languages/zh.d.ts.map +1 -1
- package/dist/esm/src/Templates/Stores/library/languages/zh.js +45 -34
- package/dist/esm/src/create/createChatController.js +1 -0
- package/package.json +12 -12
- package/dist/cjs/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +0 -577
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts +0 -38
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.d.ts.map +0 -1
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/ChatProductQueryMessage.js +0 -571
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts +0 -2
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.d.ts.map +0 -1
- package/dist/esm/components/src/components/Molecules/ChatProductQueryMessage/index.js +0 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { observer } from 'mobx-react-lite';
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import deepmerge from 'deepmerge';
|
|
6
|
+
import { useTheme, CacheProvider, useTreePath } from '../../../providers';
|
|
7
|
+
import { Colour, defined, mergeProps, mergeStyles } from '../../../utilities';
|
|
8
|
+
import { useCustomComponentOverride } from '../../../hooks';
|
|
9
|
+
import { Button } from '../../Atoms/Button';
|
|
10
|
+
import { QuickviewLayout } from '../../Organisms/QuickviewLayout';
|
|
11
|
+
const defaultStyles = ({ primaryColor, primaryColorText, theme }) => {
|
|
12
|
+
const colorPrimary = primaryColor || Colour.concrete(theme?.variables?.colors?.primary) || '#253B80';
|
|
13
|
+
const colorPrimaryText = primaryColorText || '#fff';
|
|
14
|
+
const colorCta = Colour.concrete(theme?.variables?.colors?.accent) || '#feeeae';
|
|
15
|
+
// neutral colors — no theme variable equivalents
|
|
16
|
+
const colorText = '#374151';
|
|
17
|
+
const colorBorder = '#E5E7EB';
|
|
18
|
+
return css({
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
paddingBottom: '1em',
|
|
22
|
+
'.ss__chat-quickview__header__back.ss__button': {
|
|
23
|
+
// Overlay banner pinned to the top of the secondary chat's scrollable messages
|
|
24
|
+
// container so it stays visible while the product details scroll underneath.
|
|
25
|
+
// Styling mirrors `.ss__chat__session-feedback` (dark primary bg, primary text,
|
|
26
|
+
// 8px/15px padding, 10px gap, 14px font).
|
|
27
|
+
position: 'sticky',
|
|
28
|
+
top: 0,
|
|
29
|
+
zIndex: 2,
|
|
30
|
+
display: 'flex',
|
|
31
|
+
flexDirection: 'row-reverse',
|
|
32
|
+
justifyContent: 'flex-end',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
gap: '10px',
|
|
35
|
+
padding: '8px 15px',
|
|
36
|
+
background: colorPrimary,
|
|
37
|
+
color: colorPrimaryText,
|
|
38
|
+
fontSize: '14px',
|
|
39
|
+
cursor: 'pointer',
|
|
40
|
+
border: 'none',
|
|
41
|
+
font: 'inherit',
|
|
42
|
+
width: 'auto',
|
|
43
|
+
'.ss__button__content': {
|
|
44
|
+
width: 'auto',
|
|
45
|
+
},
|
|
46
|
+
// pin the background so the Chat organism's generic `.ss__button:hover`
|
|
47
|
+
// lightening rule (higher specificity) doesn't recolor the banner
|
|
48
|
+
'&:not(.ss__button--disabled):hover': {
|
|
49
|
+
background: colorPrimary,
|
|
50
|
+
},
|
|
51
|
+
'&:focus-visible': {
|
|
52
|
+
outline: `2px solid ${colorPrimaryText}`,
|
|
53
|
+
outlineOffset: '-2px',
|
|
54
|
+
},
|
|
55
|
+
svg: {
|
|
56
|
+
fill: colorPrimaryText,
|
|
57
|
+
stroke: colorPrimaryText,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
// Content sizing for the chat's secondary window, overriding QuickviewLayout's modal sizing
|
|
61
|
+
// (close-button padding and min/max widths) — the extra `.ss__quickview` class out-ranks the
|
|
62
|
+
// layout's own same-specificity rule, whose styles are inserted after these. The content
|
|
63
|
+
// spans the panel with no gutter of its own so the header banner can bleed to the panel
|
|
64
|
+
// edges; every other section row gets the standard gutter below.
|
|
65
|
+
'.ss__quickview .ss__quickview__content': {
|
|
66
|
+
padding: 0,
|
|
67
|
+
minWidth: 'auto',
|
|
68
|
+
maxWidth: '100%',
|
|
69
|
+
display: 'flex',
|
|
70
|
+
flexDirection: 'column',
|
|
71
|
+
gap: '1em',
|
|
72
|
+
},
|
|
73
|
+
'.ss__quickview__content > .ss__quickview__row': {
|
|
74
|
+
padding: '0 1em',
|
|
75
|
+
},
|
|
76
|
+
// Default layout only: the component fills the chat's secondary window, the header banner row
|
|
77
|
+
// stays put, and the remaining rows (grouped in column 3) scroll on their own. A custom
|
|
78
|
+
// `layout` opts out since its rows are not grouped this way.
|
|
79
|
+
'&.ss__chat-quickview--default-layout': {
|
|
80
|
+
height: '100%',
|
|
81
|
+
minHeight: 0,
|
|
82
|
+
boxSizing: 'border-box',
|
|
83
|
+
'.ss__quickview, .ss__quickview__content': {
|
|
84
|
+
flex: '1 1 auto',
|
|
85
|
+
minHeight: 0,
|
|
86
|
+
display: 'flex',
|
|
87
|
+
flexDirection: 'column',
|
|
88
|
+
},
|
|
89
|
+
'.ss__quickview__content > .ss__quickview__row:first-of-type': {
|
|
90
|
+
flex: '0 0 auto',
|
|
91
|
+
},
|
|
92
|
+
'.ss__quickview__content > .ss__quickview__row:first-of-type + .ss__quickview__row': {
|
|
93
|
+
flex: '1 1 auto',
|
|
94
|
+
minHeight: 0,
|
|
95
|
+
overflowY: 'auto',
|
|
96
|
+
padding: 0,
|
|
97
|
+
},
|
|
98
|
+
'.ss__quickview__column.ss__quickview__column--c3': {
|
|
99
|
+
padding: '0 1em',
|
|
100
|
+
gap: '1em',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
// Header banner: product image beside the name/price/actions on the primary color.
|
|
104
|
+
// The column flex rules out-rank QuickviewLayout's own (viewport-based) column sizing so
|
|
105
|
+
// the header keeps its side-by-side arrangement at every panel width.
|
|
106
|
+
'.ss__quickview__content > .ss__quickview__row:first-of-type': {
|
|
107
|
+
background: colorPrimary,
|
|
108
|
+
color: colorPrimaryText,
|
|
109
|
+
padding: '1em',
|
|
110
|
+
gap: '1em',
|
|
111
|
+
flexWrap: 'nowrap',
|
|
112
|
+
'.ss__quickview__column.ss__quickview__column--c1': {
|
|
113
|
+
flex: '0 0 25%',
|
|
114
|
+
maxWidth: '25%',
|
|
115
|
+
},
|
|
116
|
+
'.ss__quickview__column.ss__quickview__column--c2': {
|
|
117
|
+
flex: '1 1 auto',
|
|
118
|
+
maxWidth: '100%',
|
|
119
|
+
gap: '0.5em',
|
|
120
|
+
justifyContent: 'space-evenly',
|
|
121
|
+
'.ss__quickview__row': {
|
|
122
|
+
padding: 0,
|
|
123
|
+
gap: '0.5em',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
// the header thumbnail is a plain image — hide the slideshow chrome
|
|
127
|
+
'.ss__quickview__slideshow': {
|
|
128
|
+
background: '#fff',
|
|
129
|
+
borderRadius: '0.33em',
|
|
130
|
+
overflow: 'hidden',
|
|
131
|
+
'.ss__slideshow__navigation, .ss__slideshow__pagination': {
|
|
132
|
+
display: 'none',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
'.ss__quickview__title': {
|
|
136
|
+
fontWeight: 'bold',
|
|
137
|
+
fontSize: '1.2em',
|
|
138
|
+
padding: 0,
|
|
139
|
+
},
|
|
140
|
+
'.ss__quickview__price': {
|
|
141
|
+
fontWeight: 'bold',
|
|
142
|
+
fontSize: '1.1em',
|
|
143
|
+
'.ss__price': {
|
|
144
|
+
color: colorPrimaryText,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
'.ss__button': {
|
|
148
|
+
flexDirection: 'row-reverse', // icon renders after the label — reverse to place it left
|
|
149
|
+
borderRadius: '0.5em',
|
|
150
|
+
padding: '0.4em 0.75em',
|
|
151
|
+
fontWeight: 'bold',
|
|
152
|
+
whiteSpace: 'nowrap',
|
|
153
|
+
cursor: 'pointer',
|
|
154
|
+
fontSize: '0.8em',
|
|
155
|
+
justifyContent: 'center',
|
|
156
|
+
textAlign: 'center',
|
|
157
|
+
'.ss__button__content': {
|
|
158
|
+
width: 'auto',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
// Action button colors. Kept at the same specificity as the Chat organism's accent theme
|
|
163
|
+
// (chatAccentTheme.ts), which is applied after these and wins. The hover rules pin the
|
|
164
|
+
// backgrounds so the Chat organism's generic `.ss__button:hover` lightening rule doesn't
|
|
165
|
+
// recolor them.
|
|
166
|
+
'.ss__quickview__add-to-cart.ss__button': {
|
|
167
|
+
background: colorCta,
|
|
168
|
+
color: '#000',
|
|
169
|
+
border: 'none',
|
|
170
|
+
svg: {
|
|
171
|
+
fill: '#000',
|
|
172
|
+
stroke: '#000',
|
|
173
|
+
},
|
|
174
|
+
'&:not(.ss__button--disabled):hover': {
|
|
175
|
+
background: colorCta,
|
|
176
|
+
filter: 'brightness(0.97)',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
'.ss__quickview__more-info.ss__button, .ss__quickview__similar.ss__button, .ss__quickview__discuss.ss__button': {
|
|
180
|
+
background: '#000',
|
|
181
|
+
color: '#fff',
|
|
182
|
+
border: 'none',
|
|
183
|
+
svg: {
|
|
184
|
+
fill: '#fff',
|
|
185
|
+
stroke: '#fff',
|
|
186
|
+
},
|
|
187
|
+
'&:not(.ss__button--disabled):hover': {
|
|
188
|
+
background: '#000',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
'.ss__quickview__content .ss__quickview__variant-title': {
|
|
192
|
+
fontWeight: 600,
|
|
193
|
+
fontSize: '0.9em',
|
|
194
|
+
color: colorText,
|
|
195
|
+
textTransform: 'uppercase',
|
|
196
|
+
marginBottom: '0.5em',
|
|
197
|
+
},
|
|
198
|
+
// untyped selections (e.g. size) render as a row of selectable tiles
|
|
199
|
+
'.ss__variant-selection--list': {
|
|
200
|
+
'.ss__list__title': {
|
|
201
|
+
display: 'none', // the variant-title above already labels the selection
|
|
202
|
+
},
|
|
203
|
+
'.ss__list__options': {
|
|
204
|
+
display: 'flex',
|
|
205
|
+
flexDirection: 'row',
|
|
206
|
+
flexWrap: 'wrap',
|
|
207
|
+
gap: '0.5em',
|
|
208
|
+
margin: 0,
|
|
209
|
+
padding: 0,
|
|
210
|
+
},
|
|
211
|
+
'.ss__list__option': {
|
|
212
|
+
flex: '1 1 auto',
|
|
213
|
+
justifyContent: 'center',
|
|
214
|
+
textAlign: 'center',
|
|
215
|
+
border: '2px solid transparent',
|
|
216
|
+
borderRadius: '0.5em',
|
|
217
|
+
padding: '0.4em 0.75em',
|
|
218
|
+
color: colorText,
|
|
219
|
+
cursor: 'pointer',
|
|
220
|
+
transition: 'border-color 0.15s ease',
|
|
221
|
+
'.ss__list__option__label': {
|
|
222
|
+
cursor: 'pointer',
|
|
223
|
+
},
|
|
224
|
+
'&:hover': {
|
|
225
|
+
borderColor: colorPrimary,
|
|
226
|
+
},
|
|
227
|
+
'&.ss__list__option--selected': {
|
|
228
|
+
borderColor: colorPrimary,
|
|
229
|
+
borderWidth: '3px',
|
|
230
|
+
padding: '0.3em 0.65em',
|
|
231
|
+
fontWeight: 'normal',
|
|
232
|
+
},
|
|
233
|
+
'&.ss__list__option--unavailable': {
|
|
234
|
+
opacity: 0.4,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
// a selection with a single value offers no choice — the legacy panel left these out
|
|
239
|
+
'.ss__quickview__variant:has(.ss__list__option:only-child), .ss__quickview__variant:has(.ss__slideshow__slide:only-child)': {
|
|
240
|
+
display: 'none',
|
|
241
|
+
},
|
|
242
|
+
// swatch selections (e.g. colour) mirror the legacy chat panel: the Swatches slideshow is
|
|
243
|
+
// flattened into a wrapping row of tiles, each a thumbnail with its value label
|
|
244
|
+
// beneath. Values without a thumbnail fall back to the legacy text-only pill.
|
|
245
|
+
'.ss__variant-selection--swatches .ss__swatches': {
|
|
246
|
+
'.ss__slideshow': {
|
|
247
|
+
overflow: 'visible',
|
|
248
|
+
'.ss__slideshow__navigation, .ss__slideshow__pagination': {
|
|
249
|
+
display: 'none',
|
|
250
|
+
},
|
|
251
|
+
'.ss__slideshow__container': {
|
|
252
|
+
width: '100%',
|
|
253
|
+
margin: 0,
|
|
254
|
+
},
|
|
255
|
+
'.ss__slideshow__track': {
|
|
256
|
+
flexWrap: 'wrap',
|
|
257
|
+
justifyContent: 'flex-start',
|
|
258
|
+
gap: '0.5em',
|
|
259
|
+
width: '100%',
|
|
260
|
+
transform: 'none !important',
|
|
261
|
+
transition: 'none',
|
|
262
|
+
},
|
|
263
|
+
'.ss__slideshow__slide': {
|
|
264
|
+
display: 'flex',
|
|
265
|
+
flex: '1 1 auto',
|
|
266
|
+
width: 'auto',
|
|
267
|
+
minWidth: 0,
|
|
268
|
+
maxWidth: 'none',
|
|
269
|
+
margin: 0,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
'.ss__swatches__slideshow__swatch': {
|
|
273
|
+
boxSizing: 'border-box',
|
|
274
|
+
width: '100%',
|
|
275
|
+
aspectRatio: 'auto',
|
|
276
|
+
flexDirection: 'column',
|
|
277
|
+
alignItems: 'center',
|
|
278
|
+
justifyContent: 'flex-start',
|
|
279
|
+
padding: '0.25em',
|
|
280
|
+
paddingBottom: 'calc(0.25em + 1em)', // reserve room for the label positioned below the thumbnail
|
|
281
|
+
border: '2px solid transparent',
|
|
282
|
+
borderRadius: '0.5em',
|
|
283
|
+
background: 'transparent',
|
|
284
|
+
color: colorText,
|
|
285
|
+
transition: 'border-color 0.15s ease',
|
|
286
|
+
'&:hover': {
|
|
287
|
+
borderColor: colorPrimary,
|
|
288
|
+
},
|
|
289
|
+
'&:focus-visible': {
|
|
290
|
+
outline: `2px solid ${colorPrimary}`,
|
|
291
|
+
outlineOffset: '2px',
|
|
292
|
+
},
|
|
293
|
+
'&.ss__swatches__slideshow__swatch--selected': {
|
|
294
|
+
borderColor: colorPrimary,
|
|
295
|
+
borderWidth: '3px',
|
|
296
|
+
padding: '0.15em',
|
|
297
|
+
paddingBottom: 'calc(0.15em + 1em)',
|
|
298
|
+
},
|
|
299
|
+
'&.ss__swatches__slideshow__swatch--disabled, &.ss__swatches__slideshow__swatch--unavailable': {
|
|
300
|
+
opacity: 0.4,
|
|
301
|
+
'&:before': {
|
|
302
|
+
display: 'none', // the faded tile replaces the strike-through
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
'&.ss__swatches__slideshow__swatch--unavailable': {
|
|
306
|
+
cursor: 'not-allowed',
|
|
307
|
+
},
|
|
308
|
+
'&.ss__swatches__slideshow__swatch--dark': {
|
|
309
|
+
color: colorText,
|
|
310
|
+
},
|
|
311
|
+
'.ss__swatches__slideshow__swatch__inner': {
|
|
312
|
+
position: 'relative',
|
|
313
|
+
flex: '0 0 auto',
|
|
314
|
+
width: '48px',
|
|
315
|
+
height: '48px',
|
|
316
|
+
'.ss__image': {
|
|
317
|
+
width: '100%',
|
|
318
|
+
height: '100%',
|
|
319
|
+
img: {
|
|
320
|
+
width: '100%',
|
|
321
|
+
height: '100%',
|
|
322
|
+
objectFit: 'contain',
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
'.ss__swatches__slideshow__swatch__value': {
|
|
327
|
+
position: 'absolute',
|
|
328
|
+
top: '100%',
|
|
329
|
+
left: '50%',
|
|
330
|
+
transform: 'translateX(-50%)',
|
|
331
|
+
marginTop: '0.25em',
|
|
332
|
+
fontSize: '0.75em',
|
|
333
|
+
lineHeight: 1,
|
|
334
|
+
color: colorText,
|
|
335
|
+
textAlign: 'center',
|
|
336
|
+
maxWidth: '60px',
|
|
337
|
+
overflow: 'hidden',
|
|
338
|
+
textOverflow: 'ellipsis',
|
|
339
|
+
whiteSpace: 'nowrap',
|
|
340
|
+
},
|
|
341
|
+
// text-only tile: no thumbnail to show, so the colour chip is dropped and the label
|
|
342
|
+
// itself becomes the pill
|
|
343
|
+
'&:not(:has(.ss__image))': {
|
|
344
|
+
padding: '0.4em 0.75em',
|
|
345
|
+
alignSelf: 'center',
|
|
346
|
+
'&.ss__swatches__slideshow__swatch--selected': {
|
|
347
|
+
padding: '0.3em 0.65em',
|
|
348
|
+
},
|
|
349
|
+
'.ss__swatches__slideshow__swatch__inner': {
|
|
350
|
+
width: 'auto',
|
|
351
|
+
height: 'auto',
|
|
352
|
+
background: 'none !important',
|
|
353
|
+
},
|
|
354
|
+
'.ss__swatches__slideshow__swatch__value': {
|
|
355
|
+
position: 'static',
|
|
356
|
+
transform: 'none',
|
|
357
|
+
margin: 0,
|
|
358
|
+
fontSize: '1em',
|
|
359
|
+
lineHeight: 'inherit',
|
|
360
|
+
maxWidth: 'none',
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
'.ss__quickview__content .ss__quickview__attributes': {
|
|
366
|
+
'& tr': {
|
|
367
|
+
borderBottom: `1px solid ${colorBorder}`,
|
|
368
|
+
transition: 'background-color 0.15s ease',
|
|
369
|
+
},
|
|
370
|
+
'& tbody tr:hover': {
|
|
371
|
+
background: '#F3F4F6',
|
|
372
|
+
},
|
|
373
|
+
'& th': {
|
|
374
|
+
color: '#6B7280',
|
|
375
|
+
letterSpacing: '0.03em',
|
|
376
|
+
},
|
|
377
|
+
'& td': {
|
|
378
|
+
textAlign: 'right',
|
|
379
|
+
color: '#111827',
|
|
380
|
+
fontWeight: 500,
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
'.ss__quickview__content .ss__quickview__description': {
|
|
384
|
+
fontSize: '0.9em',
|
|
385
|
+
color: colorText,
|
|
386
|
+
lineHeight: 1.5,
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
export const ChatQuickview = observer((properties) => {
|
|
391
|
+
const globalTheme = useTheme();
|
|
392
|
+
const globalTreePath = useTreePath();
|
|
393
|
+
const defaultProps = {
|
|
394
|
+
treePath: globalTreePath,
|
|
395
|
+
hideBadge: true,
|
|
396
|
+
// legacy chat presentation: non-swatch selections render as a row of selectable tiles
|
|
397
|
+
variantDropdownType: 'list',
|
|
398
|
+
// mirrors the legacy chat product panel: a header banner (image beside name/price and the
|
|
399
|
+
// add-to-cart/more-info/similar/discuss actions) followed by variants, the attribute table,
|
|
400
|
+
// and the description — the banner styling lives in defaultStyles above. The detail rows are
|
|
401
|
+
// grouped in column 3 so they can scroll independently of the banner (see defaultStyles).
|
|
402
|
+
layout: [['c1', 'c2'], ['c3']],
|
|
403
|
+
column1: {
|
|
404
|
+
layout: ['slideshow'],
|
|
405
|
+
width: '25%',
|
|
406
|
+
},
|
|
407
|
+
column2: {
|
|
408
|
+
layout: [
|
|
409
|
+
['productDetail.mappings.core.name'],
|
|
410
|
+
['productDetail.mappings.core.price'],
|
|
411
|
+
['button.add-to-cart', 'button.more-info', 'button.similar', 'button.discuss'],
|
|
412
|
+
],
|
|
413
|
+
width: 'auto',
|
|
414
|
+
},
|
|
415
|
+
column3: {
|
|
416
|
+
layout: [['variantSelections'], ['productDetailTable'], ['productDetail.mappings.core.description']],
|
|
417
|
+
width: '100%',
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
const props = mergeProps('chatQuickview', globalTheme, defaultProps, properties);
|
|
421
|
+
const { chatItem, controller, disableStyles, className, internalClassName, treePath, layout, hideBadge, variantDropdownType, column1, column2, column3, column4, recommendation, } = props;
|
|
422
|
+
const { overrideElement, shouldRenderDefault } = useCustomComponentOverride('chatQuickview', props);
|
|
423
|
+
// the fixed-header/scrolling-details styling only applies to this component's own default layout
|
|
424
|
+
const isDefaultLayout = layout === defaultProps.layout;
|
|
425
|
+
const styling = mergeStyles(props, defaultStyles);
|
|
426
|
+
const { messageType } = chatItem;
|
|
427
|
+
const quickviewManager = controller?.quickviewManager;
|
|
428
|
+
const chatMessages = controller?.store.currentChat?.chat || [];
|
|
429
|
+
const sourceMessage = chatItem.sourceMessageId ? chatMessages.find((m) => m.id === chatItem.sourceMessageId) : null;
|
|
430
|
+
const cameFromInspiration = sourceMessage?.messageType === 'inspirationResult';
|
|
431
|
+
const cameFromComparison = sourceMessage?.messageType === 'productComparison';
|
|
432
|
+
// after all hooks — an override that resolves or fails mid-lifecycle must not
|
|
433
|
+
// change the hook count between renders
|
|
434
|
+
if (!shouldRenderDefault) {
|
|
435
|
+
return overrideElement;
|
|
436
|
+
}
|
|
437
|
+
//initialize lang
|
|
438
|
+
const defaultLang = {
|
|
439
|
+
backToComparisonButton: {
|
|
440
|
+
value: 'Back to comparison',
|
|
441
|
+
attributes: {
|
|
442
|
+
'aria-label': 'Back to comparison',
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
backToInspirationButton: {
|
|
446
|
+
value: 'Back to inspiration',
|
|
447
|
+
attributes: {
|
|
448
|
+
'aria-label': 'Back to inspiration',
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
//deep merge with props.lang
|
|
453
|
+
const lang = deepmerge(defaultLang, props.lang || {});
|
|
454
|
+
if (messageType !== 'productQuery') {
|
|
455
|
+
controller?.log?.warn('ChatQuickview received message with unsupported type:', messageType, 'Expected type: productQuery');
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
if (!quickviewManager) {
|
|
459
|
+
controller?.log?.warn(`ChatQuickview requires the controller's quickview manager — chat controllers receive one from Snap whenever they are configured`);
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
// legacy chat presentation, injected through the theme so the children apply it via their own
|
|
463
|
+
// prop pipeline (the incoming theme wins on conflict): the action buttons carry icons, and swatch
|
|
464
|
+
// tiles show their value label beneath (the Swatches default hides labels).
|
|
465
|
+
const themePresentationProps = {
|
|
466
|
+
components: {
|
|
467
|
+
'button.add-to-cart': {
|
|
468
|
+
icon: 'cart',
|
|
469
|
+
},
|
|
470
|
+
'button.more-info': {
|
|
471
|
+
icon: 'info',
|
|
472
|
+
},
|
|
473
|
+
'button.similar': {
|
|
474
|
+
icon: 'search-thin',
|
|
475
|
+
},
|
|
476
|
+
'button.discuss': {
|
|
477
|
+
icon: 'chat',
|
|
478
|
+
},
|
|
479
|
+
swatches: {
|
|
480
|
+
hideLabels: false,
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
};
|
|
484
|
+
props.theme = deepmerge.all([themePresentationProps, props?.theme || {}], { arrayMerge: (destinationArray, sourceArray) => sourceArray });
|
|
485
|
+
const subProps = {
|
|
486
|
+
button: {
|
|
487
|
+
disableStyles,
|
|
488
|
+
theme: props.theme,
|
|
489
|
+
treePath,
|
|
490
|
+
},
|
|
491
|
+
quickviewLayout: {
|
|
492
|
+
// default props
|
|
493
|
+
...defined({ hideBadge, variantDropdownType, column1, column2, column3, column4, recommendation, lang }),
|
|
494
|
+
// inherited props
|
|
495
|
+
...defined({
|
|
496
|
+
disableStyles,
|
|
497
|
+
}),
|
|
498
|
+
// component theme overrides
|
|
499
|
+
theme: props.theme,
|
|
500
|
+
treePath,
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
const handleBack = () => {
|
|
504
|
+
controller?.store.currentChat?.popProductQueryMessage(chatItem.sourceMessageId);
|
|
505
|
+
controller?.closeProductQuickview();
|
|
506
|
+
};
|
|
507
|
+
return (_jsx(CacheProvider, { children: _jsxs("div", { className: classnames('ss__chat-quickview', { 'ss__chat-quickview--default-layout': isDefaultLayout }, className, internalClassName), ...styling, children: [(cameFromInspiration || cameFromComparison) && (_jsx(Button, { ...subProps.button, internalClassName: classnames('ss__chat-quickview__header__back'), icon: { icon: 'angle-left', size: '14px' }, onClick: handleBack, lang: { button: cameFromComparison ? lang.backToComparisonButton : lang.backToInspirationButton } })), _jsx(QuickviewLayout, { inline: true, quickviewManager: quickviewManager, ...subProps.quickviewLayout, layout: layout })] }) }));
|
|
508
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/ChatQuickview/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChatQuickview';
|
package/dist/esm/components/src/components/Molecules/ChatResultsDisplay/ChatResultsDisplay.js
CHANGED
|
@@ -50,10 +50,10 @@ export const ChatResultsDisplay = observer((properties) => {
|
|
|
50
50
|
currentChat?.dismissedSideChatMessageId !== activeMessage.id;
|
|
51
51
|
const isNarrow = useMediaQuery('(max-width: 549px)');
|
|
52
52
|
// only the tablet range needs the narrower slideshow when the side chat is open;
|
|
53
|
-
// at >= 1200px there's room to keep
|
|
53
|
+
// at >= 1200px there's room to keep 3 slides alongside the secondary chat
|
|
54
54
|
const isTabletRange = useMediaQuery('(min-width: 768px) and (max-width: 1200px)');
|
|
55
55
|
const isConstrained = !isNarrow && isSideChatOpen && isTabletRange;
|
|
56
|
-
const slidesToShow = isNarrow || isConstrained ?
|
|
56
|
+
const slidesToShow = isNarrow || isConstrained ? 2 : 3;
|
|
57
57
|
// after all hooks — an override that resolves or fails mid-lifecycle must not
|
|
58
58
|
// change the hook count between renders
|
|
59
59
|
if (!shouldRenderDefault) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slideshow.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/Slideshow/Slideshow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAM3B,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAI7D,OAAO,EAAE,IAAI,EAAuC,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"Slideshow.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Molecules/Slideshow/Slideshow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAM3B,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAI7D,OAAO,EAAE,IAAI,EAAuC,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA6JxD,eAAO,MAAM,SAAS,gBAAyB,cAAc;;CA2wB3D,CAAC;AAEH,MAAM,WAAW,aAAa;IAC7B,WAAW,EAAE,IAAI,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;QACnB,cAAc,EAAE,OAAO,CAAC;QACxB,cAAc,EAAE,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,gBAAgB,EAAE,cAAc,CAAC;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;IACH,UAAU,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,cAAc,EAAE,OAAO,CAAC;QACxB,cAAc,EAAE,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,UAAU,EAAE,IAAI,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,cAAc,EAAE,OAAO,CAAC;QACxB,cAAc,EAAE,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,KAAK,EAAE,cAAc,CAAC;QACrB,eAAe,EAAE,OAAO,CAAC;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IACH,cAAc,EAAE,IAAI,CAAC;QACpB,aAAa,EAAE,OAAO,CAAC;KACvB,CAAC,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GAAG;IAC5B,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC9B,GAAG,4BAA4B,GAC/B,cAAc,CAAC,cAAc,CAAC,CAAC;AAEhC,MAAM,MAAM,4BAA4B,GAAG;IAC1C,MAAM,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC"}
|
|
@@ -24,6 +24,10 @@ const defaultStyles = ({ theme, slidesToShow = 1, slideWidth, gap = 16, overlayN
|
|
|
24
24
|
display: 'flex',
|
|
25
25
|
width: `100%`,
|
|
26
26
|
transition: 'transform 0.3s ease-in-out',
|
|
27
|
+
// keep the track on its own compositor layer at all times; otherwise Chrome promotes it
|
|
28
|
+
// when a transform transition starts and demotes it when it ends, re-rasterizing the
|
|
29
|
+
// (scaled) slide content each time, which reads as every image flickering
|
|
30
|
+
willChange: 'transform',
|
|
27
31
|
// Disable transition during dragging
|
|
28
32
|
'&.ss__slideshow__track--dragging': {
|
|
29
33
|
transition: 'none',
|
|
@@ -265,6 +269,8 @@ export const Slideshow = observer((properties) => {
|
|
|
265
269
|
return () => observer.disconnect();
|
|
266
270
|
}, []);
|
|
267
271
|
// Touch/Drag state
|
|
272
|
+
// drag positions live in refs so the document-level mousemove/mouseup listeners
|
|
273
|
+
// (registered once per drag) always read current values instead of stale state
|
|
268
274
|
const [isDragging, setIsDragging] = useState(false);
|
|
269
275
|
// mirrors `isDragging` state - the state drives renders (the dragging class, the transform,
|
|
270
276
|
// the autoplay effect), but the drag handlers below run through refs and can fire before
|
|
@@ -424,8 +430,17 @@ export const Slideshow = observer((properties) => {
|
|
|
424
430
|
return;
|
|
425
431
|
const diff = currentXRef.current - startXRef.current;
|
|
426
432
|
const threshold = getNavigationThreshold();
|
|
433
|
+
const slideWidthPx = (trackRef.current?.parentElement?.offsetWidth || 0) / visibleSlides;
|
|
427
434
|
if (Math.abs(diff) > threshold) {
|
|
428
|
-
|
|
435
|
+
const slidesDragged = slideWidthPx > 0 ? Math.round(Math.abs(diff) / slideWidthPx) : 0;
|
|
436
|
+
if (slidesDragged > slidesToMove) {
|
|
437
|
+
// long drags land on the slide group they were dragged to instead of snapping back
|
|
438
|
+
setCurrentIndex((prevIndex) => {
|
|
439
|
+
const newIndex = diff > 0 ? prevIndex - slidesDragged : prevIndex + slidesDragged;
|
|
440
|
+
return Math.max(0, Math.min(maxIndex, newIndex));
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
else if (diff > 0 && (loop || currentIndex > 0)) {
|
|
429
444
|
// Dragged right - go to previous
|
|
430
445
|
goToPrevious();
|
|
431
446
|
}
|
|
@@ -510,6 +525,16 @@ export const Slideshow = observer((properties) => {
|
|
|
510
525
|
}, autoPlayInterval);
|
|
511
526
|
}
|
|
512
527
|
};
|
|
528
|
+
// The browser fires a click after a drag's mouseup/touchend. Catch it in the capture phase on
|
|
529
|
+
// the container so it never reaches slide content that carries its own onClick (e.g. product
|
|
530
|
+
// cards that open a quickview) — those handlers can't know a drag just happened.
|
|
531
|
+
const handleContainerClickCapture = (event) => {
|
|
532
|
+
if (!hasDraggedRef.current)
|
|
533
|
+
return;
|
|
534
|
+
hasDraggedRef.current = false;
|
|
535
|
+
event.stopPropagation();
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
};
|
|
513
538
|
// Handle image click
|
|
514
539
|
const handleSlideClick = (slide, index) => {
|
|
515
540
|
if (slide.onClick && !isDragging && !hasDraggedRef.current) {
|
|
@@ -656,27 +681,29 @@ export const Slideshow = observer((properties) => {
|
|
|
656
681
|
}, { activeBreakpoint: globalTheme?.activeBreakpoint });
|
|
657
682
|
return (_jsx(CacheProvider, { children: _jsxs("div", { ...styling, className: classnames('ss__slideshow', className), ref: slideshowRef, role: "region", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-roledescription": "slideshow", onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave,
|
|
658
683
|
// @ts-ignore - ignore
|
|
659
|
-
onKeyDown: handleKeyDown, tabIndex: 0, children: [_jsx("div", { className: "ss__slideshow__sr-only", ...mergedLang.srInstructions.all }), _jsx("div", { className: "ss__slideshow__container",
|
|
684
|
+
onKeyDown: handleKeyDown, tabIndex: 0, children: [_jsx("div", { className: "ss__slideshow__sr-only", ...mergedLang.srInstructions.all }), _jsx("div", { className: "ss__slideshow__container",
|
|
685
|
+
// @ts-ignore - capture-phase click
|
|
686
|
+
onClickCapture: touchDragging ? handleContainerClickCapture : undefined,
|
|
687
|
+
// Touch events
|
|
688
|
+
// @ts-ignore - touch events
|
|
689
|
+
onTouchStart: touchDragging ? (event) => handleDragStart(event.touches[0].clientX) : undefined,
|
|
690
|
+
// @ts-ignore - touch events
|
|
691
|
+
onTouchMove: touchDragging
|
|
692
|
+
? (event) => {
|
|
693
|
+
if (isDraggingRef.current) {
|
|
694
|
+
event.preventDefault(); // Prevent scrolling while dragging
|
|
695
|
+
}
|
|
696
|
+
const touch = event.touches[0];
|
|
697
|
+
handleDragMove(touch.clientX);
|
|
698
|
+
}
|
|
699
|
+
: undefined, onTouchEnd: touchDragging ? handleDragEnd : undefined,
|
|
700
|
+
// mouse events for desktop dragging
|
|
701
|
+
// move/up are bound on document in handleMouseDown so the drag keeps tracking outside the container
|
|
702
|
+
// @ts-ignore - mouse events
|
|
703
|
+
onMouseDown: touchDragging ? handleMouseDown : undefined, children: _jsx("div", { ref: trackRef, className: classnames('ss__slideshow__track', {
|
|
660
704
|
'ss__slideshow__track--dragging': isDragging,
|
|
661
705
|
'ss__slideshow__track--centered': centerInsufficientSlides && totalSlides <= computedSlidesToShow,
|
|
662
|
-
}), style: { transform: `translateX(${translateX}${translateUnit})` }, role: "group", "aria-label": `Slide group ${currentIndex} of ${totalDots}`,
|
|
663
|
-
// Touch events
|
|
664
|
-
// @ts-ignore - touch events
|
|
665
|
-
onTouchStart: touchDragging ? (event) => handleDragStart(event.touches[0].clientX) : undefined,
|
|
666
|
-
// @ts-ignore - touch events
|
|
667
|
-
onTouchMove: touchDragging
|
|
668
|
-
? (event) => {
|
|
669
|
-
if (isDraggingRef.current) {
|
|
670
|
-
event.preventDefault(); // Prevent scrolling while dragging
|
|
671
|
-
}
|
|
672
|
-
const touch = event.touches[0];
|
|
673
|
-
handleDragMove(touch.clientX);
|
|
674
|
-
}
|
|
675
|
-
: undefined, onTouchEnd: touchDragging ? handleDragEnd : undefined,
|
|
676
|
-
// mouse events for desktop dragging
|
|
677
|
-
// move/up are bound on document in handleMouseDown so the drag keeps tracking outside the track
|
|
678
|
-
// @ts-ignore - mouse events
|
|
679
|
-
onMouseDown: touchDragging ? handleMouseDown : undefined, children: normalizedSlides.map((slide, index) => {
|
|
706
|
+
}), style: { transform: `translateX(${translateX}${translateUnit})` }, role: "group", "aria-label": `Slide group ${currentIndex} of ${totalDots}`, children: normalizedSlides.map((slide, index) => {
|
|
680
707
|
const isVisible = index >= currentIndex && index < currentIndex + computedSlidesToShow;
|
|
681
708
|
const hasClickHandler = !!slide.onClick;
|
|
682
709
|
const hasContent = !!slide.content;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAQ3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIrE,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAa7D,OAAO,EAAE,QAAQ,EAA2C,MAAM,aAAa,CAAC;AA8BhF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAqVF,eAAO,MAAM,YAAY,gBAAyB,iBAAiB;;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../../../../../../components/src/components/Organisms/Chat/Chat.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAQ3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAIrE,OAAO,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAa7D,OAAO,EAAE,QAAQ,EAA2C,MAAM,aAAa,CAAC;AA8BhF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAqVF,eAAO,MAAM,YAAY,gBAAyB,iBAAiB;;CAkdjE,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,UAAU,EAAE,cAAc,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CACzB,GAAG,uBAAuB,GAC1B,cAAc,CAAC,iBAAiB,CAAC,CAAC;AAEnC,MAAM,MAAM,uBAAuB,GAAG;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C;;kGAE8F;IAC9F,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC"}
|