@nuskin/react-search-components 1.0.0 → 1.1.0-cx130-2624.2
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/index.d.mts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +771 -335
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +772 -336
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef, useState, useId, useRef, useImperativeHandle, useEffect, useCallback } from 'react';
|
|
1
|
+
import { forwardRef, useState, useId, useRef, useImperativeHandle, useEffect, useCallback, useLayoutEffect } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import styled4 from '@emotion/styled';
|
|
4
4
|
import { NsIcon } from '@nuskin/foundation-ui-components';
|
|
@@ -133,6 +133,7 @@ function Icon({
|
|
|
133
133
|
}
|
|
134
134
|
var { colors } = nuskinTheme;
|
|
135
135
|
var DESKTOP_MIN_PX = 1025;
|
|
136
|
+
var DESKTOP_SEARCH_COLUMN_MAX = "860px";
|
|
136
137
|
var AGENT_DESKTOP_BLOCK_SIZE = "70dvh";
|
|
137
138
|
var SearchPanelLayoutRoot = styled4.dialog`
|
|
138
139
|
background-color: ${colors.primary.white};
|
|
@@ -172,26 +173,46 @@ var SearchPanelLayoutRoot = styled4.dialog`
|
|
|
172
173
|
`}
|
|
173
174
|
`;
|
|
174
175
|
var SearchPanelLayoutInner = styled4.div`
|
|
176
|
+
align-items: ${({ $agentMode }) => $agentMode ? "stretch" : "center"};
|
|
175
177
|
box-sizing: border-box;
|
|
176
178
|
display: grid;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
justify-items: stretch;
|
|
180
|
+
grid-template-areas:
|
|
181
|
+
'input cancel'
|
|
182
|
+
'content content';
|
|
183
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
184
|
+
inline-size: 100%;
|
|
179
185
|
margin-inline: auto;
|
|
180
|
-
padding:
|
|
186
|
+
padding: 30px 0;
|
|
187
|
+
row-gap: 0;
|
|
188
|
+
|
|
189
|
+
@media (min-width: ${DESKTOP_MIN_PX}px) {
|
|
190
|
+
grid-template-areas:
|
|
191
|
+
'logo cancel'
|
|
192
|
+
'input input'
|
|
193
|
+
'content content';
|
|
194
|
+
padding: 20px clamp(12px, 4vw, 32px) 30px;
|
|
195
|
+
}
|
|
196
|
+
|
|
181
197
|
${({ $agentMode }) => $agentMode && `
|
|
182
198
|
display: flex;
|
|
183
199
|
flex-direction: column;
|
|
184
200
|
flex: 1;
|
|
201
|
+
gap: 1.5rem;
|
|
185
202
|
min-block-size: 0;
|
|
186
203
|
overflow: hidden;
|
|
204
|
+
padding: clamp(1rem, 2vw, 2rem);
|
|
187
205
|
`}
|
|
188
206
|
`;
|
|
189
207
|
var SearchPanelLayoutAgentContent = styled4.div`
|
|
208
|
+
align-self: stretch;
|
|
190
209
|
flex: 1;
|
|
210
|
+
inline-size: 100%;
|
|
191
211
|
min-block-size: 0;
|
|
192
212
|
min-inline-size: 0;
|
|
193
213
|
overflow: hidden;
|
|
194
214
|
position: relative;
|
|
215
|
+
width: 100%;
|
|
195
216
|
`;
|
|
196
217
|
var SearchPanelLayoutHeader = styled4.header`
|
|
197
218
|
display: flex;
|
|
@@ -203,9 +224,23 @@ var SearchPanelLayoutHeader = styled4.header`
|
|
|
203
224
|
`}
|
|
204
225
|
`;
|
|
205
226
|
var SearchPanelLayoutLogoSlot = styled4.div`
|
|
227
|
+
display: none;
|
|
206
228
|
flex: 0 0 auto;
|
|
207
|
-
|
|
229
|
+
grid-area: logo;
|
|
208
230
|
margin-inline-end: auto;
|
|
231
|
+
|
|
232
|
+
@media (min-width: ${DESKTOP_MIN_PX}px) {
|
|
233
|
+
display: block;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
${({ $agentMode }) => $agentMode && `display: block;`}
|
|
237
|
+
`;
|
|
238
|
+
var SearchPanelLayoutCloseIcon = styled4.span`
|
|
239
|
+
display: none;
|
|
240
|
+
|
|
241
|
+
@media (min-width: ${DESKTOP_MIN_PX}px) {
|
|
242
|
+
display: inline-flex;
|
|
243
|
+
}
|
|
209
244
|
`;
|
|
210
245
|
var SearchPanelLayoutCloseButton = styled4.button`
|
|
211
246
|
align-items: center;
|
|
@@ -217,32 +252,91 @@ var SearchPanelLayoutCloseButton = styled4.button`
|
|
|
217
252
|
display: inline-flex;
|
|
218
253
|
font: inherit;
|
|
219
254
|
gap: 0.375rem;
|
|
220
|
-
|
|
255
|
+
grid-area: cancel;
|
|
256
|
+
justify-self: end;
|
|
257
|
+
padding: 0.5rem 20px 0.5rem 12px;
|
|
258
|
+
text-transform: uppercase;
|
|
221
259
|
|
|
222
260
|
&:focus-visible {
|
|
223
261
|
outline: 2px solid ${colors.primary.black};
|
|
224
262
|
outline-offset: 2px;
|
|
225
263
|
}
|
|
264
|
+
|
|
265
|
+
@media (min-width: ${DESKTOP_MIN_PX}px) {
|
|
266
|
+
padding: 0.5rem;
|
|
267
|
+
text-transform: none;
|
|
268
|
+
}
|
|
226
269
|
`;
|
|
227
270
|
var SearchPanelLayoutContent = styled4.div`
|
|
271
|
+
grid-area: content;
|
|
228
272
|
min-inline-size: 0;
|
|
273
|
+
width: 100%;
|
|
274
|
+
|
|
275
|
+
@media (min-width: ${DESKTOP_MIN_PX}px) {
|
|
276
|
+
inline-size: min(100%, ${DESKTOP_SEARCH_COLUMN_MAX});
|
|
277
|
+
justify-self: center;
|
|
278
|
+
}
|
|
229
279
|
`;
|
|
230
280
|
var SearchPanelLayoutInputSlot = styled4.div`
|
|
231
|
-
|
|
232
|
-
|
|
281
|
+
grid-area: input;
|
|
282
|
+
min-inline-size: 0;
|
|
283
|
+
overflow: visible;
|
|
284
|
+
padding-inline: 20px 0;
|
|
233
285
|
width: 100%;
|
|
286
|
+
|
|
287
|
+
@media (min-width: ${DESKTOP_MIN_PX}px) {
|
|
288
|
+
inline-size: min(100%, ${DESKTOP_SEARCH_COLUMN_MAX});
|
|
289
|
+
justify-self: center;
|
|
290
|
+
margin-block-start: 30px;
|
|
291
|
+
padding-inline: 0;
|
|
292
|
+
}
|
|
234
293
|
`;
|
|
294
|
+
function SearchPanelCloseControl({
|
|
295
|
+
cancelLabelTag,
|
|
296
|
+
cancelShowIconTag,
|
|
297
|
+
closeLabel,
|
|
298
|
+
onClose,
|
|
299
|
+
showCancelIcon
|
|
300
|
+
}) {
|
|
301
|
+
return /* @__PURE__ */ jsxs(
|
|
302
|
+
SearchPanelLayoutCloseButton,
|
|
303
|
+
{
|
|
304
|
+
type: "button",
|
|
305
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
306
|
+
onClick: onClose,
|
|
307
|
+
...showCancelIcon ? {} : cancelShowIconTag != null ? cancelShowIconTag : {},
|
|
308
|
+
children: [
|
|
309
|
+
showCancelIcon ? /* @__PURE__ */ jsx(SearchPanelLayoutCloseIcon, { ...cancelShowIconTag != null ? cancelShowIconTag : {}, children: /* @__PURE__ */ jsx(Icon, { cursor: ICON_CURSORS.POINTER, size: ICON_SIZES.SMALL, type: ICON_TYPES.CLOSE }) }) : null,
|
|
310
|
+
/* @__PURE__ */ jsx("span", { ...cancelLabelTag != null ? cancelLabelTag : {}, children: closeLabel })
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
235
315
|
var SearchPanelLayout = forwardRef(
|
|
236
316
|
function SearchPanelLayout2({
|
|
237
317
|
"aria-label": ariaLabel,
|
|
238
318
|
agentMode = false,
|
|
239
319
|
children,
|
|
240
320
|
closeLabel,
|
|
321
|
+
showCancelIcon = true,
|
|
322
|
+
cancelLabelTag,
|
|
323
|
+
cancelShowIconTag,
|
|
241
324
|
inputSlot,
|
|
242
325
|
logoSlot,
|
|
243
326
|
onClose,
|
|
244
327
|
...props
|
|
245
328
|
}, ref) {
|
|
329
|
+
const logo = logoSlot ? /* @__PURE__ */ jsx(SearchPanelLayoutLogoSlot, { $agentMode: agentMode, children: logoSlot }) : null;
|
|
330
|
+
const closeControl = /* @__PURE__ */ jsx(
|
|
331
|
+
SearchPanelCloseControl,
|
|
332
|
+
{
|
|
333
|
+
closeLabel,
|
|
334
|
+
onClose,
|
|
335
|
+
showCancelIcon,
|
|
336
|
+
...cancelLabelTag ? { cancelLabelTag } : {},
|
|
337
|
+
...cancelShowIconTag ? { cancelShowIconTag } : {}
|
|
338
|
+
}
|
|
339
|
+
);
|
|
246
340
|
return /* @__PURE__ */ jsx(
|
|
247
341
|
SearchPanelLayoutRoot,
|
|
248
342
|
{
|
|
@@ -252,22 +346,14 @@ var SearchPanelLayout = forwardRef(
|
|
|
252
346
|
"aria-label": ariaLabel,
|
|
253
347
|
$agentMode: agentMode,
|
|
254
348
|
children: /* @__PURE__ */ jsxs(SearchPanelLayoutInner, { $agentMode: agentMode, children: [
|
|
255
|
-
/* @__PURE__ */ jsxs(SearchPanelLayoutHeader, { $agentMode:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
262
|
-
onClick: onClose,
|
|
263
|
-
children: [
|
|
264
|
-
/* @__PURE__ */ jsx(Icon, { cursor: ICON_CURSORS.POINTER, size: ICON_SIZES.SMALL, type: ICON_TYPES.CLOSE }),
|
|
265
|
-
closeLabel
|
|
266
|
-
]
|
|
267
|
-
}
|
|
268
|
-
)
|
|
349
|
+
agentMode ? /* @__PURE__ */ jsxs(SearchPanelLayoutHeader, { $agentMode: true, children: [
|
|
350
|
+
logo,
|
|
351
|
+
closeControl
|
|
352
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
353
|
+
logo,
|
|
354
|
+
closeControl
|
|
269
355
|
] }),
|
|
270
|
-
!agentMode && inputSlot
|
|
356
|
+
!agentMode && inputSlot ? /* @__PURE__ */ jsx(SearchPanelLayoutInputSlot, { children: inputSlot }) : null,
|
|
271
357
|
agentMode ? /* @__PURE__ */ jsx(SearchPanelLayoutAgentContent, { "data-agent-container": "", children }) : /* @__PURE__ */ jsx(SearchPanelLayoutContent, { children })
|
|
272
358
|
] })
|
|
273
359
|
}
|
|
@@ -292,9 +378,11 @@ var SearchMessageInputRoot = styled4.form`
|
|
|
292
378
|
border-radius: 999px;
|
|
293
379
|
box-sizing: border-box;
|
|
294
380
|
display: flex;
|
|
381
|
+
flex-wrap: nowrap;
|
|
295
382
|
gap: 0.25rem;
|
|
296
383
|
inline-size: 100%;
|
|
297
384
|
min-block-size: 3rem;
|
|
385
|
+
min-inline-size: 0;
|
|
298
386
|
padding: 0.25rem 0.5rem;
|
|
299
387
|
|
|
300
388
|
&:focus-within {
|
|
@@ -308,15 +396,26 @@ var SearchMessageInputField = styled4.input`
|
|
|
308
396
|
border: 0;
|
|
309
397
|
box-sizing: border-box;
|
|
310
398
|
color: ${colors2.primary.black};
|
|
311
|
-
|
|
399
|
+
display: block;
|
|
312
400
|
font: inherit;
|
|
401
|
+
inline-size: 100%;
|
|
313
402
|
min-inline-size: 0;
|
|
314
403
|
outline: 0;
|
|
315
404
|
padding: 0.5rem;
|
|
405
|
+
text-overflow: clip;
|
|
406
|
+
white-space: nowrap;
|
|
316
407
|
|
|
317
408
|
&::placeholder {
|
|
318
409
|
color: ${colors2.neutral[20]};
|
|
319
410
|
opacity: 1;
|
|
411
|
+
overflow: visible;
|
|
412
|
+
text-overflow: clip;
|
|
413
|
+
white-space: nowrap;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
&[type='search']::-webkit-search-cancel-button,
|
|
417
|
+
&[type='search']::-webkit-search-decoration {
|
|
418
|
+
appearance: none;
|
|
320
419
|
}
|
|
321
420
|
`;
|
|
322
421
|
var SearchMessageInputSubmit = styled4.button`
|
|
@@ -365,6 +464,200 @@ var SearchMessageInputClear = styled4.button`
|
|
|
365
464
|
outline-offset: 2px;
|
|
366
465
|
}
|
|
367
466
|
`;
|
|
467
|
+
var SearchMessageInputAuxiliary = styled4.span`
|
|
468
|
+
align-items: center;
|
|
469
|
+
display: inline-flex;
|
|
470
|
+
flex: 0 0 auto;
|
|
471
|
+
gap: 0.25rem;
|
|
472
|
+
margin-inline-start: auto;
|
|
473
|
+
|
|
474
|
+
> span {
|
|
475
|
+
align-items: center;
|
|
476
|
+
display: inline-flex;
|
|
477
|
+
flex-shrink: 0;
|
|
478
|
+
inline-size: 2.125rem;
|
|
479
|
+
block-size: 2.125rem;
|
|
480
|
+
justify-content: center;
|
|
481
|
+
line-height: 0;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
svg {
|
|
485
|
+
display: block;
|
|
486
|
+
overflow: visible;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
[data-testid='search-nui-voice'] svg {
|
|
490
|
+
block-size: 2.125rem;
|
|
491
|
+
inline-size: 2.125rem;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
@media (max-width: 1024px) {
|
|
495
|
+
> span {
|
|
496
|
+
block-size: 1.75rem;
|
|
497
|
+
inline-size: 1.75rem;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
[data-testid='search-nui-voice'] svg {
|
|
501
|
+
block-size: 1.75rem;
|
|
502
|
+
inline-size: 1.75rem;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
`;
|
|
506
|
+
var SearchMessageInputFieldWrap = styled4.span`
|
|
507
|
+
display: block;
|
|
508
|
+
flex: 1 1 auto;
|
|
509
|
+
min-inline-size: 0;
|
|
510
|
+
position: relative;
|
|
511
|
+
`;
|
|
512
|
+
var SearchMessageInputRotatingPlaceholder = styled4.span`
|
|
513
|
+
color: ${colors2.neutral[20]};
|
|
514
|
+
inset-block-start: 50%;
|
|
515
|
+
inset-inline: 0.5rem;
|
|
516
|
+
overflow: hidden;
|
|
517
|
+
pointer-events: none;
|
|
518
|
+
position: absolute;
|
|
519
|
+
text-overflow: ellipsis;
|
|
520
|
+
transform: translateY(-50%);
|
|
521
|
+
white-space: nowrap;
|
|
522
|
+
`;
|
|
523
|
+
function BrandedSparkleIcon() {
|
|
524
|
+
const reactId = useId();
|
|
525
|
+
const largeId = `${reactId}-sparkle-large`;
|
|
526
|
+
const smallId = `${reactId}-sparkle-small`;
|
|
527
|
+
return /* @__PURE__ */ jsxs(
|
|
528
|
+
"svg",
|
|
529
|
+
{
|
|
530
|
+
width: "18",
|
|
531
|
+
height: "26",
|
|
532
|
+
viewBox: "0 0 18 26",
|
|
533
|
+
fill: "none",
|
|
534
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
535
|
+
"aria-hidden": "true",
|
|
536
|
+
focusable: "false",
|
|
537
|
+
children: [
|
|
538
|
+
/* @__PURE__ */ jsx(
|
|
539
|
+
"path",
|
|
540
|
+
{
|
|
541
|
+
d: "M7.72184 7.28096C7.74702 7.14678 8.02273 7.14678 8.04791 7.28096C8.29593 8.60232 8.86587 10.8381 10.0145 11.9867C11.1631 13.1353 13.3989 13.7053 14.7202 13.9533C14.8544 13.9785 14.8544 14.2542 14.7202 14.2794C13.3989 14.5274 11.1631 15.0973 10.0145 16.246C8.86587 17.3946 8.29593 19.6303 8.04791 20.9517C8.02273 21.0859 7.74702 21.0859 7.72184 20.9517C7.47382 19.6303 6.90388 17.3946 5.75524 16.246C4.60661 15.0973 2.37088 14.5274 1.04952 14.2794C0.915335 14.2542 0.915335 13.9785 1.04952 13.9533C2.37088 13.7053 4.60661 13.1353 5.75524 11.9867C6.90388 10.8381 7.47382 8.60232 7.72184 7.28096Z",
|
|
542
|
+
fill: `url(#${largeId})`
|
|
543
|
+
}
|
|
544
|
+
),
|
|
545
|
+
/* @__PURE__ */ jsx(
|
|
546
|
+
"path",
|
|
547
|
+
{
|
|
548
|
+
d: "M14.0975 4.49258C14.1092 4.42963 14.2378 4.42963 14.2495 4.49258C14.3682 5.13172 14.6448 6.23139 15.2073 6.79394C15.7699 7.35648 16.8696 7.63311 17.5087 7.7518C17.5716 7.76349 17.5716 7.89209 17.5087 7.90378C16.8696 8.02246 15.7699 8.29909 15.2073 8.86164C14.6448 9.42418 14.3682 10.5239 14.2495 11.163C14.2378 11.2259 14.1092 11.2259 14.0975 11.163C13.9788 10.5239 13.7022 9.42418 13.1396 8.86164C12.5771 8.29909 11.4774 8.02246 10.8383 7.90378C10.7753 7.89209 10.7753 7.76349 10.8383 7.7518C11.4774 7.63311 12.5771 7.35648 13.1396 6.79394C13.7022 6.23139 13.9788 5.13172 14.0975 4.49258Z",
|
|
549
|
+
fill: `url(#${smallId})`
|
|
550
|
+
}
|
|
551
|
+
),
|
|
552
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
553
|
+
/* @__PURE__ */ jsxs(
|
|
554
|
+
"linearGradient",
|
|
555
|
+
{
|
|
556
|
+
id: largeId,
|
|
557
|
+
x1: "0.985745",
|
|
558
|
+
y1: "8.72141",
|
|
559
|
+
x2: "15.9969",
|
|
560
|
+
y2: "10.2253",
|
|
561
|
+
gradientUnits: "userSpaceOnUse",
|
|
562
|
+
children: [
|
|
563
|
+
/* @__PURE__ */ jsx("stop", { stopColor: "#6964F1" }),
|
|
564
|
+
/* @__PURE__ */ jsx("stop", { offset: "0.361696", stopColor: "#7561F3" }),
|
|
565
|
+
/* @__PURE__ */ jsx("stop", { offset: "0.743652", stopColor: "#855EF5" })
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
/* @__PURE__ */ jsxs(
|
|
570
|
+
"linearGradient",
|
|
571
|
+
{
|
|
572
|
+
id: smallId,
|
|
573
|
+
x1: "10.8242",
|
|
574
|
+
y1: "5.20877",
|
|
575
|
+
x2: "18.1115",
|
|
576
|
+
y2: "5.93885",
|
|
577
|
+
gradientUnits: "userSpaceOnUse",
|
|
578
|
+
children: [
|
|
579
|
+
/* @__PURE__ */ jsx("stop", { stopColor: "#6964F1" }),
|
|
580
|
+
/* @__PURE__ */ jsx("stop", { offset: "0.361696", stopColor: "#7561F3" }),
|
|
581
|
+
/* @__PURE__ */ jsx("stop", { offset: "0.743652", stopColor: "#855EF5" })
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
] })
|
|
586
|
+
]
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
function BrandedVoiceSearchIcon() {
|
|
591
|
+
return /* @__PURE__ */ jsxs(
|
|
592
|
+
"svg",
|
|
593
|
+
{
|
|
594
|
+
width: "32",
|
|
595
|
+
height: "32",
|
|
596
|
+
viewBox: "0 0 32 32",
|
|
597
|
+
fill: "none",
|
|
598
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
599
|
+
"aria-hidden": "true",
|
|
600
|
+
focusable: "false",
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ jsx("rect", { width: "32", height: "32", rx: "16", fill: "#EDEDED" }),
|
|
603
|
+
/* @__PURE__ */ jsx(
|
|
604
|
+
"path",
|
|
605
|
+
{
|
|
606
|
+
d: "M12.125 21V11H13.625V21H12.125ZM15.25 24V8H16.75V24H15.25ZM9 18V14H10.5V18H9ZM18.375 21V11H19.875V21H18.375ZM21.5 18V14H23V18H21.5Z",
|
|
607
|
+
fill: "#5F5F5F"
|
|
608
|
+
}
|
|
609
|
+
)
|
|
610
|
+
]
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
var SEARCH_MOBILE_MAX_PX = 1024;
|
|
615
|
+
var MOBILE_QUERY = `(max-width: ${SEARCH_MOBILE_MAX_PX}px)`;
|
|
616
|
+
function useMobileSearchLayout(mediaQuery = MOBILE_QUERY) {
|
|
617
|
+
const [isMobile, setIsMobile] = useState(() => {
|
|
618
|
+
if (typeof window === "undefined") return false;
|
|
619
|
+
return window.matchMedia(mediaQuery).matches;
|
|
620
|
+
});
|
|
621
|
+
useEffect(() => {
|
|
622
|
+
if (typeof window === "undefined") return void 0;
|
|
623
|
+
const mq = window.matchMedia(mediaQuery);
|
|
624
|
+
const onChange = () => setIsMobile(mq.matches);
|
|
625
|
+
onChange();
|
|
626
|
+
mq.addEventListener("change", onChange);
|
|
627
|
+
return () => mq.removeEventListener("change", onChange);
|
|
628
|
+
}, [mediaQuery]);
|
|
629
|
+
return isMobile;
|
|
630
|
+
}
|
|
631
|
+
var DEFAULT_PLACEHOLDER_ROTATION_MS = 3e3;
|
|
632
|
+
function normalizeMessages(messages) {
|
|
633
|
+
if (!messages) return [];
|
|
634
|
+
return messages.filter((message) => message.trim() !== "");
|
|
635
|
+
}
|
|
636
|
+
function useRotatingPlaceholder(enabled, messages, intervalMs) {
|
|
637
|
+
var _a;
|
|
638
|
+
const [index, setIndex] = useState(0);
|
|
639
|
+
const rotationMs = intervalMs && intervalMs > 0 ? intervalMs : DEFAULT_PLACEHOLDER_ROTATION_MS;
|
|
640
|
+
const safeMessages = normalizeMessages(messages);
|
|
641
|
+
const messagesKey = safeMessages.join("\0");
|
|
642
|
+
useEffect(() => {
|
|
643
|
+
if (!enabled || safeMessages.length <= 1) {
|
|
644
|
+
setIndex(0);
|
|
645
|
+
return void 0;
|
|
646
|
+
}
|
|
647
|
+
const prefersReducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
648
|
+
if (prefersReducedMotion) {
|
|
649
|
+
setIndex(0);
|
|
650
|
+
return void 0;
|
|
651
|
+
}
|
|
652
|
+
const timerId = window.setInterval(
|
|
653
|
+
() => setIndex((current) => (current + 1) % safeMessages.length),
|
|
654
|
+
rotationMs
|
|
655
|
+
);
|
|
656
|
+
return () => window.clearInterval(timerId);
|
|
657
|
+
}, [enabled, rotationMs, messagesKey, safeMessages.length]);
|
|
658
|
+
if (!enabled || safeMessages.length === 0) return "";
|
|
659
|
+
return (_a = safeMessages[index % safeMessages.length]) != null ? _a : "";
|
|
660
|
+
}
|
|
368
661
|
function SearchMessageInput({
|
|
369
662
|
clearLabel,
|
|
370
663
|
inputLabel,
|
|
@@ -375,8 +668,16 @@ function SearchMessageInput({
|
|
|
375
668
|
placeholder,
|
|
376
669
|
submitLabel,
|
|
377
670
|
value,
|
|
671
|
+
showNuiIcons = false,
|
|
672
|
+
voiceSearchLabel = "",
|
|
673
|
+
askNuiLabel = "",
|
|
674
|
+
rotatingPlaceholders,
|
|
675
|
+
rotatingPlaceholderIntervalMs,
|
|
676
|
+
placeholderTag,
|
|
677
|
+
rotatingPlaceholderTag,
|
|
378
678
|
...props
|
|
379
679
|
}) {
|
|
680
|
+
var _a;
|
|
380
681
|
const field = useRef(null);
|
|
381
682
|
const setField = useCallback(
|
|
382
683
|
(node) => {
|
|
@@ -396,6 +697,14 @@ function SearchMessageInput({
|
|
|
396
697
|
event.preventDefault();
|
|
397
698
|
submitMessage();
|
|
398
699
|
}
|
|
700
|
+
const isMobile = useMobileSearchLayout();
|
|
701
|
+
const hasQuery = value.trim() !== "";
|
|
702
|
+
const showRotatingPlaceholder = isMobile && !hasQuery && ((_a = rotatingPlaceholders == null ? void 0 : rotatingPlaceholders.length) != null ? _a : 0) > 0;
|
|
703
|
+
const rotatingPlaceholderText = useRotatingPlaceholder(
|
|
704
|
+
showRotatingPlaceholder,
|
|
705
|
+
rotatingPlaceholders,
|
|
706
|
+
rotatingPlaceholderIntervalMs
|
|
707
|
+
);
|
|
399
708
|
function handleKeyDown(event) {
|
|
400
709
|
if (event.key === "Enter" && !event.nativeEvent.isComposing) {
|
|
401
710
|
event.preventDefault();
|
|
@@ -422,19 +731,40 @@ function SearchMessageInput({
|
|
|
422
731
|
type: ICON_TYPES.SEARCH_FIELD
|
|
423
732
|
}
|
|
424
733
|
) }),
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
|
|
734
|
+
/* @__PURE__ */ jsxs(
|
|
735
|
+
SearchMessageInputFieldWrap,
|
|
427
736
|
{
|
|
428
|
-
|
|
429
|
-
"
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
737
|
+
"data-testid": "search-message-input-wrap",
|
|
738
|
+
"data-rotating-placeholder": showRotatingPlaceholder ? "true" : void 0,
|
|
739
|
+
children: [
|
|
740
|
+
showRotatingPlaceholder ? /* @__PURE__ */ jsx(
|
|
741
|
+
SearchMessageInputRotatingPlaceholder,
|
|
742
|
+
{
|
|
743
|
+
"data-testid": "search-rotating-placeholder",
|
|
744
|
+
...rotatingPlaceholderTag != null ? rotatingPlaceholderTag : {},
|
|
745
|
+
children: rotatingPlaceholderText
|
|
746
|
+
}
|
|
747
|
+
) : null,
|
|
748
|
+
/* @__PURE__ */ jsx(
|
|
749
|
+
SearchMessageInputField,
|
|
750
|
+
{
|
|
751
|
+
...placeholderTag != null ? placeholderTag : {},
|
|
752
|
+
ref: setField,
|
|
753
|
+
id: "header-product-search",
|
|
754
|
+
name: "header-product-search",
|
|
755
|
+
"aria-label": inputLabel,
|
|
756
|
+
autoComplete: "off",
|
|
757
|
+
autoCorrect: "off",
|
|
758
|
+
enterKeyHint: "search",
|
|
759
|
+
onChange: (event) => onChange(event.target.value),
|
|
760
|
+
onKeyDown: handleKeyDown,
|
|
761
|
+
placeholder: showRotatingPlaceholder ? "" : placeholder,
|
|
762
|
+
spellCheck: false,
|
|
763
|
+
type: "text",
|
|
764
|
+
value
|
|
765
|
+
}
|
|
766
|
+
)
|
|
767
|
+
]
|
|
438
768
|
}
|
|
439
769
|
),
|
|
440
770
|
value !== "" && /* @__PURE__ */ jsx(
|
|
@@ -443,9 +773,9 @@ function SearchMessageInput({
|
|
|
443
773
|
type: "button",
|
|
444
774
|
"aria-label": clearLabel,
|
|
445
775
|
onClick: () => {
|
|
446
|
-
var
|
|
776
|
+
var _a2;
|
|
447
777
|
onChange("");
|
|
448
|
-
(
|
|
778
|
+
(_a2 = field.current) == null ? void 0 : _a2.focus();
|
|
449
779
|
},
|
|
450
780
|
children: /* @__PURE__ */ jsx(
|
|
451
781
|
Icon,
|
|
@@ -456,7 +786,11 @@ function SearchMessageInput({
|
|
|
456
786
|
}
|
|
457
787
|
)
|
|
458
788
|
}
|
|
459
|
-
)
|
|
789
|
+
),
|
|
790
|
+
showNuiIcons ? /* @__PURE__ */ jsxs(SearchMessageInputAuxiliary, { "data-testid": "search-nui-icons", children: [
|
|
791
|
+
/* @__PURE__ */ jsx("span", { "aria-label": voiceSearchLabel, "data-testid": "search-nui-voice", children: /* @__PURE__ */ jsx(BrandedVoiceSearchIcon, {}) }),
|
|
792
|
+
/* @__PURE__ */ jsx("span", { "aria-label": askNuiLabel, "data-testid": "search-nui-sparkle", children: /* @__PURE__ */ jsx(BrandedSparkleIcon, {}) })
|
|
793
|
+
] }) : null
|
|
460
794
|
]
|
|
461
795
|
}
|
|
462
796
|
);
|
|
@@ -612,19 +946,23 @@ function RecentSearches({
|
|
|
612
946
|
clearLabel,
|
|
613
947
|
moreLabel,
|
|
614
948
|
onSelect,
|
|
615
|
-
onClear
|
|
949
|
+
onClear,
|
|
950
|
+
titleTag,
|
|
951
|
+
clearTag,
|
|
952
|
+
enableTag
|
|
616
953
|
}) {
|
|
617
954
|
const [showAll, setShowAll] = useState(false);
|
|
618
955
|
const visible = showAll ? items : items.slice(0, MAX_RECENT);
|
|
619
|
-
return /* @__PURE__ */ jsxs(RecentSearchesSection, { "aria-label": title, children: [
|
|
956
|
+
return /* @__PURE__ */ jsxs(RecentSearchesSection, { "aria-label": title, ...enableTag != null ? enableTag : {}, children: [
|
|
620
957
|
/* @__PURE__ */ jsxs(RecentSearchesHeader, { children: [
|
|
621
|
-
/* @__PURE__ */ jsx(RecentSearchesTitle, { children: title }),
|
|
958
|
+
/* @__PURE__ */ jsx(RecentSearchesTitle, { ...titleTag != null ? titleTag : {}, children: title }),
|
|
622
959
|
/* @__PURE__ */ jsx(
|
|
623
960
|
RecentSearchesClearButton,
|
|
624
961
|
{
|
|
625
962
|
type: "button",
|
|
626
963
|
onMouseDown: (e) => e.preventDefault(),
|
|
627
964
|
onClick: onClear,
|
|
965
|
+
...clearTag != null ? clearTag : {},
|
|
628
966
|
children: clearLabel
|
|
629
967
|
}
|
|
630
968
|
)
|
|
@@ -652,25 +990,69 @@ function RecentSearches({
|
|
|
652
990
|
] })
|
|
653
991
|
] });
|
|
654
992
|
}
|
|
993
|
+
|
|
994
|
+
// src/components/SuggestionRow/helpers.ts
|
|
995
|
+
function getSuggestionUrl(option) {
|
|
996
|
+
var _a, _b;
|
|
997
|
+
return "url" in option ? (_b = (_a = option.url) != null ? _a : option.href) != null ? _b : "" : "";
|
|
998
|
+
}
|
|
999
|
+
function suggestionRequiresProductPage(option) {
|
|
1000
|
+
var _a;
|
|
1001
|
+
if (option.requiresProductPage === true) {
|
|
1002
|
+
return true;
|
|
1003
|
+
}
|
|
1004
|
+
if (option.requiresProductPage === false) {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (option.productType === "bundle") {
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
const skuCount = Number((_a = option.skuCount) != null ? _a : 0);
|
|
1011
|
+
return skuCount > 1;
|
|
1012
|
+
}
|
|
1013
|
+
function getSuggestionDisplayData(option) {
|
|
1014
|
+
if ("suggestionType" in option) {
|
|
1015
|
+
return {
|
|
1016
|
+
imageSrc: "",
|
|
1017
|
+
displayLabel: option.value,
|
|
1018
|
+
requiresProductPage: false,
|
|
1019
|
+
isBundle: false,
|
|
1020
|
+
isDidYouMean: true,
|
|
1021
|
+
isOutOfStock: false,
|
|
1022
|
+
isCartActionDisabled: false
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
const requiresProductPage = suggestionRequiresProductPage(option);
|
|
1026
|
+
return {
|
|
1027
|
+
imageSrc: option.imageURL.trim() || option.thumbnail.trim(),
|
|
1028
|
+
displayLabel: option.value,
|
|
1029
|
+
requiresProductPage,
|
|
1030
|
+
isBundle: requiresProductPage,
|
|
1031
|
+
isDidYouMean: false,
|
|
1032
|
+
isOutOfStock: option.outOfStock,
|
|
1033
|
+
isCartActionDisabled: option.cartActionDisabled
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function optionalAddToCartHandlerProps(onAddSuggestionToCart) {
|
|
1037
|
+
if (!onAddSuggestionToCart) {
|
|
1038
|
+
return {};
|
|
1039
|
+
}
|
|
1040
|
+
return { onAddSuggestionToCart };
|
|
1041
|
+
}
|
|
655
1042
|
var SUGGESTION_MOBILE_MAX_PX = 1024;
|
|
656
1043
|
var colors4 = {
|
|
657
|
-
text: "#111827"
|
|
658
|
-
|
|
659
|
-
var
|
|
660
|
-
display:
|
|
1044
|
+
text: "#111827"
|
|
1045
|
+
};
|
|
1046
|
+
var SuggestionRow = styled4.li`
|
|
1047
|
+
display: grid;
|
|
1048
|
+
grid-template-columns: minmax(0, 1fr);
|
|
661
1049
|
align-items: center;
|
|
1050
|
+
justify-items: stretch;
|
|
662
1051
|
width: 100%;
|
|
663
1052
|
min-height: 58px;
|
|
664
1053
|
padding: 4px 24px;
|
|
665
1054
|
box-sizing: border-box;
|
|
666
1055
|
color: ${colors4.text};
|
|
667
|
-
`;
|
|
668
|
-
var SuggestionRow = styled4(SuggestionOption)`
|
|
669
|
-
display: grid;
|
|
670
|
-
grid-template-columns: minmax(0, 1fr) 18px;
|
|
671
|
-
align-items: center;
|
|
672
|
-
column-gap: 12px;
|
|
673
|
-
width: 100%;
|
|
674
1056
|
background: transparent;
|
|
675
1057
|
|
|
676
1058
|
&[data-highlighted='true'],
|
|
@@ -682,23 +1064,25 @@ var SuggestionRow = styled4(SuggestionOption)`
|
|
|
682
1064
|
opacity: 0.75;
|
|
683
1065
|
}
|
|
684
1066
|
|
|
685
|
-
&[data-suggestion-type='did-you-mean'] {
|
|
686
|
-
grid-template-columns: minmax(0, 1fr);
|
|
687
|
-
}
|
|
688
|
-
|
|
689
1067
|
@media (max-width: ${SUGGESTION_MOBILE_MAX_PX}px) {
|
|
690
1068
|
padding: 6px 24px;
|
|
691
|
-
|
|
1069
|
+
}
|
|
1070
|
+
`;
|
|
1071
|
+
var SuggestionProductSnippet = styled4.div`
|
|
1072
|
+
display: block;
|
|
1073
|
+
min-width: 0;
|
|
1074
|
+
width: 100%;
|
|
1075
|
+
|
|
1076
|
+
/* ProductSnippet Icon SVGs default to cursor:default and cover the CTA hit target. */
|
|
1077
|
+
button svg {
|
|
1078
|
+
cursor: inherit;
|
|
692
1079
|
}
|
|
693
1080
|
`;
|
|
694
1081
|
var SuggestionContentWrapper = styled4.button`
|
|
695
1082
|
appearance: none;
|
|
696
1083
|
background: transparent;
|
|
697
1084
|
border: 0;
|
|
698
|
-
display:
|
|
699
|
-
grid-template-columns: 50px minmax(0, 1fr);
|
|
700
|
-
align-items: center;
|
|
701
|
-
column-gap: 16px;
|
|
1085
|
+
display: block;
|
|
702
1086
|
width: 100%;
|
|
703
1087
|
min-width: 0;
|
|
704
1088
|
margin: 0;
|
|
@@ -707,32 +1091,12 @@ var SuggestionContentWrapper = styled4.button`
|
|
|
707
1091
|
cursor: pointer;
|
|
708
1092
|
font: inherit;
|
|
709
1093
|
outline: none;
|
|
710
|
-
border-radius: 6px;
|
|
711
1094
|
text-align: start;
|
|
712
1095
|
|
|
713
|
-
&[data-out-of-stock='true'] {
|
|
714
|
-
cursor: default;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
&[data-has-image='false'] {
|
|
718
|
-
grid-template-columns: minmax(0, 1fr);
|
|
719
|
-
}
|
|
720
|
-
|
|
721
1096
|
&:focus-visible {
|
|
722
1097
|
outline: 2px solid ${colors4.text};
|
|
723
1098
|
outline-offset: 3px;
|
|
724
1099
|
}
|
|
725
|
-
|
|
726
|
-
&[data-suggestion-type='did-you-mean'] {
|
|
727
|
-
grid-template-columns: minmax(0, 1fr);
|
|
728
|
-
}
|
|
729
|
-
`;
|
|
730
|
-
var SuggestionThumbnail = styled4.img`
|
|
731
|
-
width: 50px;
|
|
732
|
-
height: 50px;
|
|
733
|
-
object-fit: contain;
|
|
734
|
-
flex-shrink: 0;
|
|
735
|
-
align-self: center;
|
|
736
1100
|
`;
|
|
737
1101
|
var SuggestionLabel = styled4.span`
|
|
738
1102
|
display: block;
|
|
@@ -749,202 +1113,153 @@ var SuggestionLabel = styled4.span`
|
|
|
749
1113
|
line-height: 20px;
|
|
750
1114
|
}
|
|
751
1115
|
`;
|
|
752
|
-
var
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
width: 24px;
|
|
757
|
-
height: 24px;
|
|
758
|
-
color: var(--suggestion-icon-color, ${colors4.text});
|
|
759
|
-
flex-shrink: 0;
|
|
760
|
-
align-self: center;
|
|
761
|
-
|
|
762
|
-
&[data-cart-disabled='true'] {
|
|
763
|
-
color: var(--suggestion-muted, ${colors4.muted});
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
svg {
|
|
767
|
-
width: 24px;
|
|
768
|
-
height: 24px;
|
|
769
|
-
display: block;
|
|
770
|
-
}
|
|
771
|
-
`;
|
|
772
|
-
var SuggestionActionButton = styled4.button`
|
|
773
|
-
display: inline-flex;
|
|
774
|
-
align-items: center;
|
|
775
|
-
justify-content: center;
|
|
776
|
-
width: 24px;
|
|
777
|
-
height: 24px;
|
|
778
|
-
margin: 0;
|
|
779
|
-
padding: 0;
|
|
780
|
-
border: none;
|
|
781
|
-
background: transparent;
|
|
782
|
-
color: var(--suggestion-icon-color, ${colors4.text});
|
|
783
|
-
flex-shrink: 0;
|
|
784
|
-
align-self: center;
|
|
785
|
-
cursor: pointer;
|
|
786
|
-
|
|
787
|
-
&:focus-visible {
|
|
788
|
-
outline: 2px solid ${colors4.text};
|
|
789
|
-
outline-offset: 3px;
|
|
790
|
-
border-radius: 4px;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
svg {
|
|
794
|
-
width: 24px;
|
|
795
|
-
height: 24px;
|
|
796
|
-
display: block;
|
|
797
|
-
}
|
|
798
|
-
`;
|
|
799
|
-
|
|
800
|
-
// src/components/SuggestionRow/helpers.ts
|
|
801
|
-
function getSuggestionUrl(option) {
|
|
802
|
-
var _a, _b;
|
|
803
|
-
return "url" in option ? (_b = (_a = option.url) != null ? _a : option.href) != null ? _b : "" : "";
|
|
1116
|
+
var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
1117
|
+
function assignProductControlRef(node, controlRef) {
|
|
1118
|
+
const productButton = node == null ? void 0 : node.querySelector("button");
|
|
1119
|
+
controlRef == null ? void 0 : controlRef(productButton != null ? productButton : null);
|
|
804
1120
|
}
|
|
805
|
-
function
|
|
806
|
-
if (
|
|
1121
|
+
function snippetCtaProps(display, addToCartLabel, openBundleLabel, logos) {
|
|
1122
|
+
if (display.requiresProductPage) {
|
|
807
1123
|
return {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
isDidYouMean: true,
|
|
812
|
-
isOutOfStock: false,
|
|
813
|
-
isCartActionDisabled: false
|
|
1124
|
+
ctaDisabled: false,
|
|
1125
|
+
ctaLogo: logos.PRODUCT_PAGE_LOGO,
|
|
1126
|
+
ctaAriaLabel: openBundleLabel(display.displayLabel)
|
|
814
1127
|
};
|
|
815
1128
|
}
|
|
816
1129
|
return {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
isDidYouMean: false,
|
|
821
|
-
isOutOfStock: option.outOfStock,
|
|
822
|
-
isCartActionDisabled: option.cartActionDisabled
|
|
1130
|
+
ctaDisabled: display.isCartActionDisabled,
|
|
1131
|
+
ctaLogo: logos.CART_LOGO,
|
|
1132
|
+
ctaAriaLabel: addToCartLabel(display.displayLabel)
|
|
823
1133
|
};
|
|
824
1134
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
function passArrowKeysToList(event, onNavigate) {
|
|
828
|
-
const direction = getArrowDirection(event);
|
|
829
|
-
if (direction === null) return;
|
|
830
|
-
event.preventDefault();
|
|
831
|
-
onNavigate(direction);
|
|
832
|
-
}
|
|
833
|
-
function SuggestionImage({
|
|
834
|
-
fallbackImageUrl,
|
|
835
|
-
id,
|
|
836
|
-
src
|
|
837
|
-
}) {
|
|
838
|
-
return /* @__PURE__ */ jsx(
|
|
839
|
-
SuggestionThumbnail,
|
|
840
|
-
{
|
|
841
|
-
src: src || fallbackImageUrl,
|
|
842
|
-
alt: "",
|
|
843
|
-
"aria-hidden": true,
|
|
844
|
-
"data-testid": `suggestion-thumbnail-${id}`,
|
|
845
|
-
onError: (event) => {
|
|
846
|
-
const image = event.currentTarget;
|
|
847
|
-
if (fallbackImageUrl && image.getAttribute("src") !== fallbackImageUrl) {
|
|
848
|
-
image.src = fallbackImageUrl;
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
);
|
|
853
|
-
}
|
|
854
|
-
function SuggestionContent({
|
|
1135
|
+
function ProductSuggestionSnippet({
|
|
1136
|
+
addToCartLabel,
|
|
855
1137
|
controlRef,
|
|
856
1138
|
display,
|
|
857
1139
|
fallbackImageUrl,
|
|
858
1140
|
onHighlightSuggestion,
|
|
1141
|
+
onNavigate,
|
|
1142
|
+
onRunSuggestionAction,
|
|
1143
|
+
onAddSuggestionToCart,
|
|
859
1144
|
onSelectSuggestion,
|
|
1145
|
+
openBundleLabel,
|
|
1146
|
+
openProductPageLabel,
|
|
860
1147
|
suggestionIndex,
|
|
861
1148
|
suggestionOption
|
|
862
1149
|
}) {
|
|
863
|
-
const
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
{
|
|
867
|
-
|
|
868
|
-
type: "button",
|
|
869
|
-
"aria-disabled": isOutOfStock ? true : void 0,
|
|
870
|
-
"data-testid": `suggestion-content-${suggestionOption.id}`,
|
|
871
|
-
"data-suggestion-type": isDidYouMean ? "did-you-mean" : "product",
|
|
872
|
-
"data-has-image": flag(!isDidYouMean),
|
|
873
|
-
"data-out-of-stock": flag(isOutOfStock),
|
|
874
|
-
"data-gtm-type": GTM_SEARCH_RESULT_CLICK,
|
|
875
|
-
"data-gtm-result-title": displayLabel,
|
|
876
|
-
"data-gtm-result-url": getSuggestionUrl(suggestionOption),
|
|
877
|
-
onFocus: () => onHighlightSuggestion(suggestionIndex),
|
|
878
|
-
onClick: () => {
|
|
879
|
-
if (!isOutOfStock) onSelectSuggestion(suggestionOption);
|
|
880
|
-
},
|
|
881
|
-
children: [
|
|
882
|
-
!isDidYouMean && /* @__PURE__ */ jsx(
|
|
883
|
-
SuggestionImage,
|
|
884
|
-
{
|
|
885
|
-
fallbackImageUrl,
|
|
886
|
-
id: suggestionOption.id,
|
|
887
|
-
src: imageSrc
|
|
888
|
-
}
|
|
889
|
-
),
|
|
890
|
-
/* @__PURE__ */ jsx(SuggestionLabel, { children: displayLabel })
|
|
891
|
-
]
|
|
1150
|
+
const [productModule, setProductModule] = useState(null);
|
|
1151
|
+
const hostRef = useRef(null);
|
|
1152
|
+
useEffect(() => {
|
|
1153
|
+
if (typeof window === "undefined") {
|
|
1154
|
+
return void 0;
|
|
892
1155
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
testId: isBundle ? `suggestion-bundle-icon-${id}` : `suggestion-cart-icon-${id}`,
|
|
907
|
-
type: isBundle ? ICON_TYPES.SUGGESTION_TASK : ICON_TYPES.SUGGESTION_CART
|
|
1156
|
+
let canceled = false;
|
|
1157
|
+
void import('@nuskin/react-product-components').then((module) => {
|
|
1158
|
+
if (!canceled) {
|
|
1159
|
+
setProductModule(module);
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
return () => {
|
|
1163
|
+
canceled = true;
|
|
1164
|
+
};
|
|
1165
|
+
}, []);
|
|
1166
|
+
useIsomorphicLayoutEffect(() => {
|
|
1167
|
+
if (productModule) {
|
|
1168
|
+
assignProductControlRef(hostRef.current, controlRef);
|
|
908
1169
|
}
|
|
1170
|
+
}, [productModule, controlRef]);
|
|
1171
|
+
const { displayLabel, imageSrc } = display;
|
|
1172
|
+
const imageUrl = imageSrc || fallbackImageUrl;
|
|
1173
|
+
const setSnippetRef = useCallback(
|
|
1174
|
+
(node) => {
|
|
1175
|
+
hostRef.current = node;
|
|
1176
|
+
assignProductControlRef(node, controlRef);
|
|
1177
|
+
},
|
|
1178
|
+
[controlRef]
|
|
909
1179
|
);
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
if (isCartActionDisabled) {
|
|
1180
|
+
const onFocusCapture = useCallback(
|
|
1181
|
+
() => onHighlightSuggestion(suggestionIndex),
|
|
1182
|
+
[onHighlightSuggestion, suggestionIndex]
|
|
1183
|
+
);
|
|
1184
|
+
const onKeyDownCapture = useCallback(
|
|
1185
|
+
(event) => {
|
|
1186
|
+
const direction = getArrowDirection(event);
|
|
1187
|
+
if (direction === null) return;
|
|
1188
|
+
event.preventDefault();
|
|
1189
|
+
onNavigate(direction);
|
|
1190
|
+
},
|
|
1191
|
+
[onNavigate]
|
|
1192
|
+
);
|
|
1193
|
+
if (!productModule) {
|
|
925
1194
|
return /* @__PURE__ */ jsx(
|
|
926
|
-
|
|
1195
|
+
SuggestionProductSnippet,
|
|
927
1196
|
{
|
|
928
|
-
|
|
929
|
-
"data-suggestion-
|
|
930
|
-
|
|
931
|
-
|
|
1197
|
+
ref: setSnippetRef,
|
|
1198
|
+
"data-testid": "suggestion-product-snippet",
|
|
1199
|
+
onFocusCapture,
|
|
1200
|
+
onKeyDownCapture,
|
|
1201
|
+
"aria-busy": "true",
|
|
1202
|
+
children: /* @__PURE__ */ jsx(SuggestionLabel, { children: displayLabel })
|
|
932
1203
|
}
|
|
933
1204
|
);
|
|
934
1205
|
}
|
|
1206
|
+
const { ProductSnippet, PRODUCT_SNIPPET_CTA_LOGOS } = productModule;
|
|
1207
|
+
const { ctaDisabled, ctaLogo, ctaAriaLabel } = snippetCtaProps(
|
|
1208
|
+
display,
|
|
1209
|
+
addToCartLabel,
|
|
1210
|
+
openBundleLabel,
|
|
1211
|
+
PRODUCT_SNIPPET_CTA_LOGOS
|
|
1212
|
+
);
|
|
935
1213
|
return /* @__PURE__ */ jsx(
|
|
936
|
-
|
|
1214
|
+
SuggestionProductSnippet,
|
|
937
1215
|
{
|
|
938
|
-
|
|
939
|
-
"data-testid":
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1216
|
+
ref: setSnippetRef,
|
|
1217
|
+
"data-testid": "suggestion-product-snippet",
|
|
1218
|
+
onFocusCapture,
|
|
1219
|
+
onKeyDownCapture,
|
|
1220
|
+
children: /* @__PURE__ */ jsx(
|
|
1221
|
+
ProductSnippet,
|
|
1222
|
+
{
|
|
1223
|
+
title: displayLabel,
|
|
1224
|
+
imageUrl,
|
|
1225
|
+
imageAlt: "",
|
|
1226
|
+
productAriaLabel: openProductPageLabel(displayLabel),
|
|
1227
|
+
ctaLogo,
|
|
1228
|
+
ctaAriaLabel,
|
|
1229
|
+
ctaDisabled,
|
|
1230
|
+
onProductClick: () => onSelectSuggestion(suggestionOption),
|
|
1231
|
+
onCtaClick: () => {
|
|
1232
|
+
onHighlightSuggestion(suggestionIndex);
|
|
1233
|
+
if (ctaDisabled) {
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
if (display.requiresProductPage) {
|
|
1237
|
+
onRunSuggestionAction(suggestionOption);
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
if (onAddSuggestionToCart) {
|
|
1241
|
+
onAddSuggestionToCart(suggestionOption);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
onRunSuggestionAction(suggestionOption);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
)
|
|
945
1248
|
}
|
|
946
1249
|
);
|
|
947
1250
|
}
|
|
1251
|
+
var GTM_SEARCH_RESULT_CLICK = "searchResultClick";
|
|
1252
|
+
var flag = (value) => value ? "true" : "false";
|
|
1253
|
+
function passArrowKeysToList(event, onNavigate) {
|
|
1254
|
+
const direction = getArrowDirection(event);
|
|
1255
|
+
if (direction === null) return;
|
|
1256
|
+
event.preventDefault();
|
|
1257
|
+
onNavigate(direction);
|
|
1258
|
+
}
|
|
1259
|
+
function cartDisabledAttr(isDidYouMean, display) {
|
|
1260
|
+
if (isDidYouMean || display.requiresProductPage) return "false";
|
|
1261
|
+
return flag(display.isCartActionDisabled);
|
|
1262
|
+
}
|
|
948
1263
|
function SuggestionRow2({
|
|
949
1264
|
addToCartLabel,
|
|
950
1265
|
controlRef,
|
|
@@ -952,46 +1267,58 @@ function SuggestionRow2({
|
|
|
952
1267
|
onHighlightSuggestion,
|
|
953
1268
|
onNavigate,
|
|
954
1269
|
onRunSuggestionAction,
|
|
1270
|
+
onAddSuggestionToCart,
|
|
955
1271
|
onSelectSuggestion,
|
|
956
1272
|
openBundleLabel,
|
|
1273
|
+
openProductPageLabel,
|
|
957
1274
|
suggestionIndex,
|
|
958
1275
|
suggestionOption,
|
|
959
1276
|
fallbackImageUrl = ""
|
|
960
1277
|
}) {
|
|
961
1278
|
const display = getSuggestionDisplayData(suggestionOption);
|
|
962
|
-
const { displayLabel,
|
|
1279
|
+
const { displayLabel, isDidYouMean, isOutOfStock } = display;
|
|
963
1280
|
const controls = { onHighlightSuggestion, suggestionIndex, suggestionOption };
|
|
964
|
-
|
|
1281
|
+
const addToCartHandlerProps = optionalAddToCartHandlerProps(onAddSuggestionToCart);
|
|
1282
|
+
return /* @__PURE__ */ jsx(
|
|
965
1283
|
SuggestionRow,
|
|
966
1284
|
{
|
|
967
1285
|
"data-testid": `suggestion-row-${suggestionOption.id}`,
|
|
968
1286
|
"data-highlighted": flag(isHighlighted),
|
|
969
1287
|
"data-suggestion-type": isDidYouMean ? "did-you-mean" : "product",
|
|
1288
|
+
"data-product-snippet": isDidYouMean ? "false" : "true",
|
|
1289
|
+
"data-cart-disabled": cartDisabledAttr(isDidYouMean, display),
|
|
970
1290
|
onMouseEnter: () => onHighlightSuggestion(suggestionIndex),
|
|
971
1291
|
onKeyDown: (event) => passArrowKeysToList(event, onNavigate),
|
|
972
1292
|
"data-out-of-stock": flag(isOutOfStock),
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
1293
|
+
"data-gtm-type": GTM_SEARCH_RESULT_CLICK,
|
|
1294
|
+
"data-gtm-result-title": displayLabel,
|
|
1295
|
+
"data-gtm-result-url": getSuggestionUrl(suggestionOption),
|
|
1296
|
+
children: isDidYouMean ? /* @__PURE__ */ jsx(
|
|
1297
|
+
SuggestionContentWrapper,
|
|
1298
|
+
{
|
|
1299
|
+
type: "button",
|
|
1300
|
+
"data-testid": `suggestion-content-${suggestionOption.id}`,
|
|
1301
|
+
"data-suggestion-type": "did-you-mean",
|
|
1302
|
+
onFocus: () => onHighlightSuggestion(suggestionIndex),
|
|
1303
|
+
onClick: () => onSelectSuggestion(suggestionOption),
|
|
1304
|
+
children: /* @__PURE__ */ jsx(SuggestionLabel, { children: displayLabel })
|
|
1305
|
+
}
|
|
1306
|
+
) : /* @__PURE__ */ jsx(
|
|
1307
|
+
ProductSuggestionSnippet,
|
|
1308
|
+
{
|
|
1309
|
+
...controls,
|
|
1310
|
+
addToCartLabel,
|
|
1311
|
+
controlRef,
|
|
1312
|
+
display,
|
|
1313
|
+
fallbackImageUrl,
|
|
1314
|
+
onNavigate,
|
|
1315
|
+
onRunSuggestionAction,
|
|
1316
|
+
...addToCartHandlerProps,
|
|
1317
|
+
onSelectSuggestion,
|
|
1318
|
+
openBundleLabel,
|
|
1319
|
+
openProductPageLabel
|
|
1320
|
+
}
|
|
1321
|
+
)
|
|
995
1322
|
}
|
|
996
1323
|
);
|
|
997
1324
|
}
|
|
@@ -1085,11 +1412,13 @@ var SearchSuggestions = forwardRef(function SearchSuggestions2({
|
|
|
1085
1412
|
didYouMeanText,
|
|
1086
1413
|
noSuggestionsText,
|
|
1087
1414
|
openBundleLabel,
|
|
1415
|
+
openProductPageLabel,
|
|
1088
1416
|
seeMoreText,
|
|
1089
1417
|
suggestionsLabel,
|
|
1090
1418
|
fallbackImageUrl,
|
|
1091
1419
|
onSelect,
|
|
1092
1420
|
onRunAction,
|
|
1421
|
+
onAddToCartAction,
|
|
1093
1422
|
onSeeMore,
|
|
1094
1423
|
onLeaveTop
|
|
1095
1424
|
}, ref) {
|
|
@@ -1097,54 +1426,84 @@ var SearchSuggestions = forwardRef(function SearchSuggestions2({
|
|
|
1097
1426
|
const headingId = useId();
|
|
1098
1427
|
const rowControls = useRef([]);
|
|
1099
1428
|
const seeMoreButton = useRef(null);
|
|
1429
|
+
const pendingFirstFocus = useRef(false);
|
|
1100
1430
|
const rowCount = loading ? 0 : items.length;
|
|
1101
1431
|
const showSeeMore = !loading && hasMore && !showDidYouMean;
|
|
1432
|
+
const showDidYouMeanHeading = showDidYouMean && didYouMeanText.trim() !== "";
|
|
1102
1433
|
const stopCount = rowCount + (showSeeMore ? 1 : 0);
|
|
1103
1434
|
function focusStop(index) {
|
|
1104
1435
|
const stop = index < rowCount ? rowControls.current[index] : seeMoreButton.current;
|
|
1105
1436
|
stop == null ? void 0 : stop.focus();
|
|
1437
|
+
return Boolean(stop);
|
|
1106
1438
|
}
|
|
1107
1439
|
function moveFrom(index, direction) {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1440
|
+
let next = index + direction;
|
|
1441
|
+
while (next >= 0 && next < stopCount) {
|
|
1442
|
+
if (focusStop(next)) return;
|
|
1443
|
+
next += direction;
|
|
1444
|
+
}
|
|
1445
|
+
if (next < 0) {
|
|
1446
|
+
if (index === 0) onLeaveTop();
|
|
1447
|
+
else focusStop(index);
|
|
1448
|
+
}
|
|
1111
1449
|
}
|
|
1112
1450
|
useImperativeHandle(ref, () => ({
|
|
1113
1451
|
focusFirst() {
|
|
1114
|
-
if (
|
|
1115
|
-
|
|
1116
|
-
|
|
1452
|
+
if (rowCount > 0) {
|
|
1453
|
+
const stop = rowControls.current[0];
|
|
1454
|
+
if (!stop) {
|
|
1455
|
+
pendingFirstFocus.current = true;
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
pendingFirstFocus.current = false;
|
|
1459
|
+
stop.focus();
|
|
1460
|
+
return true;
|
|
1461
|
+
}
|
|
1462
|
+
if (showSeeMore && seeMoreButton.current) {
|
|
1463
|
+
seeMoreButton.current.focus();
|
|
1464
|
+
return true;
|
|
1465
|
+
}
|
|
1466
|
+
return false;
|
|
1117
1467
|
}
|
|
1118
1468
|
}));
|
|
1119
1469
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1120
|
-
|
|
1470
|
+
showDidYouMeanHeading ? /* @__PURE__ */ jsx(SuggestionSectionHeading, { id: headingId, "data-testid": "autocomplete-did-you-mean-heading", children: didYouMeanText }) : null,
|
|
1121
1471
|
/* @__PURE__ */ jsxs(
|
|
1122
1472
|
SearchSuggestionsList,
|
|
1123
1473
|
{
|
|
1124
|
-
"aria-label":
|
|
1125
|
-
"aria-labelledby":
|
|
1474
|
+
"aria-label": showDidYouMeanHeading ? void 0 : suggestionsLabel,
|
|
1475
|
+
"aria-labelledby": showDidYouMeanHeading ? headingId : void 0,
|
|
1126
1476
|
"aria-busy": loading,
|
|
1127
1477
|
"data-testid": "autocomplete-results-list",
|
|
1128
1478
|
children: [
|
|
1129
|
-
!loading && items.map((option, index) =>
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1479
|
+
!loading && items.map((option, index) => {
|
|
1480
|
+
const addToCartHandlerProps = optionalAddToCartHandlerProps(onAddToCartAction);
|
|
1481
|
+
return /* @__PURE__ */ jsx(
|
|
1482
|
+
SuggestionRow2,
|
|
1483
|
+
{
|
|
1484
|
+
addToCartLabel,
|
|
1485
|
+
openBundleLabel,
|
|
1486
|
+
openProductPageLabel,
|
|
1487
|
+
controlRef: (control) => {
|
|
1488
|
+
rowControls.current[index] = control;
|
|
1489
|
+
if (control && index === 0 && pendingFirstFocus.current) {
|
|
1490
|
+
pendingFirstFocus.current = false;
|
|
1491
|
+
control.focus();
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
isHighlighted: index === highlightedIndex,
|
|
1495
|
+
onHighlightSuggestion: setHighlightedIndex,
|
|
1496
|
+
onNavigate: (direction) => moveFrom(index, direction),
|
|
1497
|
+
onRunSuggestionAction: onRunAction,
|
|
1498
|
+
...addToCartHandlerProps,
|
|
1499
|
+
onSelectSuggestion: onSelect,
|
|
1500
|
+
suggestionIndex: index,
|
|
1501
|
+
suggestionOption: option,
|
|
1502
|
+
fallbackImageUrl
|
|
1136
1503
|
},
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
onRunSuggestionAction: onRunAction,
|
|
1141
|
-
onSelectSuggestion: onSelect,
|
|
1142
|
-
suggestionIndex: index,
|
|
1143
|
-
suggestionOption: option,
|
|
1144
|
-
fallbackImageUrl
|
|
1145
|
-
},
|
|
1146
|
-
option.id
|
|
1147
|
-
)),
|
|
1504
|
+
option.id
|
|
1505
|
+
);
|
|
1506
|
+
}),
|
|
1148
1507
|
showNoResults && /* @__PURE__ */ jsx(PassiveSuggestionOption, { "data-highlighted": "false", children: noSuggestionsText })
|
|
1149
1508
|
]
|
|
1150
1509
|
}
|
|
@@ -1161,6 +1520,10 @@ var SearchSuggestions = forwardRef(function SearchSuggestions2({
|
|
|
1161
1520
|
)
|
|
1162
1521
|
] });
|
|
1163
1522
|
});
|
|
1523
|
+
function shouldShowRecentSearches(hasQuery, recentSearches) {
|
|
1524
|
+
if (hasQuery || !recentSearches) return false;
|
|
1525
|
+
return recentSearches.items.length > 0 || Boolean(recentSearches.showWhenEmpty);
|
|
1526
|
+
}
|
|
1164
1527
|
function useIsMounted() {
|
|
1165
1528
|
const [isMounted, setIsMounted] = useState(false);
|
|
1166
1529
|
useEffect(() => {
|
|
@@ -1202,6 +1565,83 @@ function getStatusText({ loading, showNoResults, items }, copy) {
|
|
|
1202
1565
|
if (showNoResults) return copy.noSuggestions;
|
|
1203
1566
|
return items.length > 0 ? copy.suggestionsCount(items.length) : "";
|
|
1204
1567
|
}
|
|
1568
|
+
function messageInputEditProps(editTags) {
|
|
1569
|
+
if (!editTags) return {};
|
|
1570
|
+
const props = {};
|
|
1571
|
+
if (editTags.searchPlaceholder) props.placeholderTag = editTags.searchPlaceholder;
|
|
1572
|
+
if (editTags.mobileRotatingPlaceholder) {
|
|
1573
|
+
props.rotatingPlaceholderTag = editTags.mobileRotatingPlaceholder;
|
|
1574
|
+
}
|
|
1575
|
+
return props;
|
|
1576
|
+
}
|
|
1577
|
+
function layoutCancelEditProps(editTags) {
|
|
1578
|
+
if (!editTags) return {};
|
|
1579
|
+
const props = {};
|
|
1580
|
+
if (editTags.cancelLabel) props.cancelLabelTag = editTags.cancelLabel;
|
|
1581
|
+
if (editTags.cancelShowIcon) props.cancelShowIconTag = editTags.cancelShowIcon;
|
|
1582
|
+
return props;
|
|
1583
|
+
}
|
|
1584
|
+
function recentSearchesEditProps(editTags) {
|
|
1585
|
+
if (!editTags) return {};
|
|
1586
|
+
const props = {};
|
|
1587
|
+
if (editTags.recentSearchesHeading) props.titleTag = editTags.recentSearchesHeading;
|
|
1588
|
+
if (editTags.clearAllLabel) props.clearTag = editTags.clearAllLabel;
|
|
1589
|
+
if (editTags.enableRecentSearches) props.enableTag = editTags.enableRecentSearches;
|
|
1590
|
+
return props;
|
|
1591
|
+
}
|
|
1592
|
+
function SearchPanelAutocompleteBody({
|
|
1593
|
+
copy,
|
|
1594
|
+
editTags,
|
|
1595
|
+
fallbackImageUrl,
|
|
1596
|
+
hasQuery,
|
|
1597
|
+
inputRef,
|
|
1598
|
+
recentSearches,
|
|
1599
|
+
showSuggestions,
|
|
1600
|
+
suggestions,
|
|
1601
|
+
suggestionsRef
|
|
1602
|
+
}) {
|
|
1603
|
+
var _a;
|
|
1604
|
+
const showRecent = shouldShowRecentSearches(hasQuery, recentSearches);
|
|
1605
|
+
return /* @__PURE__ */ jsxs(
|
|
1606
|
+
SearchSuggestionsPanel,
|
|
1607
|
+
{
|
|
1608
|
+
"data-testid": "autocomplete-suggestions-panel",
|
|
1609
|
+
...(_a = editTags == null ? void 0 : editTags.enableAutocomplete) != null ? _a : {},
|
|
1610
|
+
children: [
|
|
1611
|
+
/* @__PURE__ */ jsx(SearchPanelStatus, { "aria-atomic": "true", "data-testid": "search-panel-status", children: showSuggestions ? getStatusText(suggestions, copy) : "" }),
|
|
1612
|
+
showSuggestions ? /* @__PURE__ */ jsx(
|
|
1613
|
+
SearchSuggestions,
|
|
1614
|
+
{
|
|
1615
|
+
...suggestions,
|
|
1616
|
+
ref: suggestionsRef,
|
|
1617
|
+
onLeaveTop: () => {
|
|
1618
|
+
var _a2;
|
|
1619
|
+
return (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
1620
|
+
},
|
|
1621
|
+
addToCartLabel: copy.addToCart,
|
|
1622
|
+
didYouMeanText: copy.didYouMean,
|
|
1623
|
+
noSuggestionsText: copy.noSuggestions,
|
|
1624
|
+
openBundleLabel: copy.openBundle,
|
|
1625
|
+
openProductPageLabel: copy.openProductPage,
|
|
1626
|
+
seeMoreText: copy.seeMoreResults,
|
|
1627
|
+
suggestionsLabel: copy.suggestionsLabel,
|
|
1628
|
+
fallbackImageUrl
|
|
1629
|
+
}
|
|
1630
|
+
) : null,
|
|
1631
|
+
showRecent && recentSearches ? /* @__PURE__ */ jsx(
|
|
1632
|
+
RecentSearches,
|
|
1633
|
+
{
|
|
1634
|
+
...recentSearches,
|
|
1635
|
+
title: copy.recentSearches,
|
|
1636
|
+
clearLabel: copy.clearRecentSearches,
|
|
1637
|
+
moreLabel: copy.moreRecentSearches,
|
|
1638
|
+
...recentSearchesEditProps(editTags)
|
|
1639
|
+
}
|
|
1640
|
+
) : null
|
|
1641
|
+
]
|
|
1642
|
+
}
|
|
1643
|
+
);
|
|
1644
|
+
}
|
|
1205
1645
|
function SearchPanel({
|
|
1206
1646
|
isOpen,
|
|
1207
1647
|
onClose,
|
|
@@ -1210,10 +1650,15 @@ function SearchPanel({
|
|
|
1210
1650
|
copy,
|
|
1211
1651
|
input,
|
|
1212
1652
|
suggestions,
|
|
1653
|
+
showSuggestions = true,
|
|
1213
1654
|
recentSearches,
|
|
1214
|
-
agentPanel
|
|
1655
|
+
agentPanel,
|
|
1656
|
+
showNuiIcons = false,
|
|
1657
|
+
showCancelIcon = true,
|
|
1658
|
+
rotatingPlaceholders,
|
|
1659
|
+
rotatingPlaceholderIntervalMs,
|
|
1660
|
+
editTags
|
|
1215
1661
|
}) {
|
|
1216
|
-
var _a;
|
|
1217
1662
|
const inputRef = useRef(null);
|
|
1218
1663
|
const layoutRef = useRef(null);
|
|
1219
1664
|
const suggestionsRef = useRef(null);
|
|
@@ -1225,7 +1670,6 @@ function SearchPanel({
|
|
|
1225
1670
|
useFocusOnOpen(hasAgent ? layoutRef : inputRef, isShown);
|
|
1226
1671
|
if (!isShown) return null;
|
|
1227
1672
|
const hasQuery = input.value.trim() !== "";
|
|
1228
|
-
const hasRecentSearches = ((_a = recentSearches == null ? void 0 : recentSearches.items.length) != null ? _a : 0) > 0;
|
|
1229
1673
|
const searchInput = /* @__PURE__ */ jsx(
|
|
1230
1674
|
SearchMessageInput,
|
|
1231
1675
|
{
|
|
@@ -1233,14 +1677,20 @@ function SearchPanel({
|
|
|
1233
1677
|
inputLabel: copy.searchLabel,
|
|
1234
1678
|
inputRef,
|
|
1235
1679
|
onArrowDown: () => {
|
|
1236
|
-
var
|
|
1237
|
-
return (_b = (
|
|
1680
|
+
var _a, _b;
|
|
1681
|
+
return (_b = (_a = suggestionsRef.current) == null ? void 0 : _a.focusFirst()) != null ? _b : false;
|
|
1238
1682
|
},
|
|
1239
1683
|
onChange: input.onChange,
|
|
1240
1684
|
onSubmit: input.onSubmit,
|
|
1241
1685
|
placeholder: copy.searchPlaceholder,
|
|
1242
1686
|
submitLabel: copy.submitSearch,
|
|
1243
1687
|
value: input.value,
|
|
1688
|
+
showNuiIcons,
|
|
1689
|
+
voiceSearchLabel: copy.voiceSearch,
|
|
1690
|
+
askNuiLabel: copy.askNui,
|
|
1691
|
+
...messageInputEditProps(editTags),
|
|
1692
|
+
...rotatingPlaceholders ? { rotatingPlaceholders } : {},
|
|
1693
|
+
...rotatingPlaceholderIntervalMs != null ? { rotatingPlaceholderIntervalMs } : {},
|
|
1244
1694
|
"data-testid": "search-panel-input"
|
|
1245
1695
|
}
|
|
1246
1696
|
);
|
|
@@ -1259,40 +1709,26 @@ function SearchPanel({
|
|
|
1259
1709
|
"aria-label": copy.searchLabel,
|
|
1260
1710
|
tabIndex: -1,
|
|
1261
1711
|
closeLabel: copy.cancel,
|
|
1712
|
+
showCancelIcon,
|
|
1713
|
+
...layoutCancelEditProps(editTags),
|
|
1262
1714
|
onClose,
|
|
1263
1715
|
logoSlot: logo,
|
|
1264
1716
|
agentMode: hasAgent,
|
|
1265
1717
|
inputSlot: hasAgent ? void 0 : searchInput,
|
|
1266
|
-
children: agentPanel != null ? agentPanel : /* @__PURE__ */
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
openBundleLabel: copy.openBundle,
|
|
1281
|
-
seeMoreText: copy.seeMoreResults,
|
|
1282
|
-
suggestionsLabel: copy.suggestionsLabel,
|
|
1283
|
-
fallbackImageUrl
|
|
1284
|
-
}
|
|
1285
|
-
),
|
|
1286
|
-
!hasQuery && recentSearches && hasRecentSearches && /* @__PURE__ */ jsx(
|
|
1287
|
-
RecentSearches,
|
|
1288
|
-
{
|
|
1289
|
-
...recentSearches,
|
|
1290
|
-
title: copy.recentSearches,
|
|
1291
|
-
clearLabel: copy.clearRecentSearches,
|
|
1292
|
-
moreLabel: copy.moreRecentSearches
|
|
1293
|
-
}
|
|
1294
|
-
)
|
|
1295
|
-
] })
|
|
1718
|
+
children: agentPanel != null ? agentPanel : /* @__PURE__ */ jsx(
|
|
1719
|
+
SearchPanelAutocompleteBody,
|
|
1720
|
+
{
|
|
1721
|
+
copy,
|
|
1722
|
+
editTags,
|
|
1723
|
+
fallbackImageUrl,
|
|
1724
|
+
hasQuery,
|
|
1725
|
+
inputRef,
|
|
1726
|
+
recentSearches,
|
|
1727
|
+
showSuggestions,
|
|
1728
|
+
suggestions,
|
|
1729
|
+
suggestionsRef
|
|
1730
|
+
}
|
|
1731
|
+
)
|
|
1296
1732
|
}
|
|
1297
1733
|
)
|
|
1298
1734
|
}
|