@magicx-eng/ai-autocomplete-react 0.47.1 → 0.48.0
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/README.md +62 -531
- package/REFERENCE.md +594 -0
- package/dist/index.d.mts +42 -6
- package/dist/index.d.ts +42 -6
- package/dist/index.js +325 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +325 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Lt=Object.defineProperty;var Ca=Object.getOwnPropertyDescriptor;var Sa=Object.getOwnPropertyNames;var Ta=Object.prototype.hasOwnProperty;var Pa=(e,i)=>{for(var t in i)Lt(e,t,{get:i[t],enumerable:!0})},Ia=(e,i,t,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of Sa(i))!Ta.call(e,o)&&o!==t&&Lt(e,o,{get:()=>i[o],enumerable:!(a=Ca(i,o))||a.enumerable});return e};var Ea=e=>Ia(Lt({},"__esModule",{value:!0}),e);var ai={};Pa(ai,{AIAutocomplete:()=>ga,AIAutocompleteDropdown:()=>St,DATE_RANGE_META_END:()=>s.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>s.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>s.DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY:()=>s.LOCATION_META_KEY,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,TIME_META_KEY:()=>s.TIME_META_KEY,WEEKDAY_LABELS:()=>s.WEEKDAY_LABELS,buildSubmitResult:()=>s.buildSubmitResult,cellDay:()=>s.cellDay,cellIso:()=>s.cellIso,dateCellMarks:()=>s.dateCellMarks,formatDate:()=>s.formatDate,formatDateRange:()=>s.formatDateRange,formatOptionCount:()=>s.formatOptionCount,formatPlace:()=>s.formatPlace,formatTime:()=>s.formatTime,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSources:()=>s.optionImageSources,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,optionsShowLeadingVisuals:()=>s.optionsShowLeadingVisuals,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,parseTime:()=>s.parseTime,productFromMatchedItem:()=>s.productFromMatchedItem,productImageSources:()=>s.productImageSources,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>Pt,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=Ea(ai);var s=require("@magicx-eng/ai-autocomplete-vanilla");var _=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-container-KKjFU {
|
|
2
2
|
position: relative;
|
|
3
3
|
/* Inherits the host page's font by default. Consumers can pin a specific
|
|
4
4
|
font on the library via \`--aia-font-family: 'Custom Font'\` without
|
|
@@ -264,23 +264,89 @@
|
|
|
264
264
|
display: contents;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
/*
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
riding on shimmer-sweep so it only plays on genuine promotions. */
|
|
267
|
+
/* Word \u2192 chip. A newly recognised param (renderEditable stamps shimmer-sweep
|
|
268
|
+
on it) keeps its text in place while the chip forms around it: the fill and
|
|
269
|
+
padding grow in over 300ms, and the picked option's icon or picture grows in
|
|
270
|
+
front of the word \u2014 its width opening the room (so the words slide over),
|
|
271
|
+
a small spring on its scale, a quick fade. The text itself never fades, so
|
|
272
|
+
a typed word turns into a chip rather than vanishing and coming back. */
|
|
274
273
|
:where(.aia-input-IW-P-) strong[class~="magicx-aia-shimmer-sweep"] {
|
|
275
|
-
animation: aia-
|
|
274
|
+
animation: aia-aiaChipForm-tKbNc 300ms ease both;
|
|
276
275
|
}
|
|
277
276
|
|
|
278
|
-
|
|
277
|
+
:where(.aia-input-IW-P-) strong[class~="magicx-aia-shimmer-sweep"] span[class~="magicx-aia-segment-icon"] {
|
|
278
|
+
animation:
|
|
279
|
+
aia-aiaTileGrow-j9Pat 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
|
|
280
|
+
aia-aiaTileSpring-FEwNg 380ms cubic-bezier(0.3, 1.5, 0.5, 1) both,
|
|
281
|
+
aia-aiaTileFade-H1LDQ 200ms ease both;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/* The picture tile is an inline box (see its own rule), which can't scale, so
|
|
285
|
+
it opens and fades without the spring. */
|
|
286
|
+
:where(.aia-input-IW-P-) strong[class~="magicx-aia-shimmer-sweep"] span[class~="magicx-aia-segment-image"] {
|
|
287
|
+
animation:
|
|
288
|
+
aia-aiaImageGrow-i9yw8 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
|
|
289
|
+
aia-aiaTileFade-H1LDQ 200ms ease both;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
@keyframes aia-aiaChipForm-tKbNc {
|
|
279
293
|
from {
|
|
280
|
-
|
|
294
|
+
background-color: transparent;
|
|
295
|
+
padding-left: 0;
|
|
296
|
+
padding-right: 0;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@keyframes aia-aiaTileGrow-j9Pat {
|
|
301
|
+
from {
|
|
302
|
+
width: 0;
|
|
303
|
+
margin-right: 0;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@keyframes aia-aiaTileSpring-FEwNg {
|
|
308
|
+
from {
|
|
309
|
+
transform: scale(0.4);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* A hair above zero, like the other fades \u2014 see magicx-aia-fadeIn. */
|
|
314
|
+
@keyframes aia-aiaTileFade-H1LDQ {
|
|
315
|
+
from {
|
|
316
|
+
opacity: 0.01;
|
|
281
317
|
}
|
|
282
318
|
}
|
|
283
|
-
|
|
319
|
+
|
|
320
|
+
@keyframes aia-aiaImageGrow-i9yw8 {
|
|
321
|
+
from {
|
|
322
|
+
padding-left: 0;
|
|
323
|
+
margin-right: 0;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* Reduced motion: a word becomes a chip at once. */
|
|
328
|
+
@media (prefers-reduced-motion: reduce) {
|
|
329
|
+
:where(.aia-input-IW-P-) strong[class~="magicx-aia-shimmer-sweep"],
|
|
330
|
+
:where(.aia-input-IW-P-) strong[class~="magicx-aia-shimmer-sweep"] span[class~="magicx-aia-segment-icon"],
|
|
331
|
+
:where(.aia-input-IW-P-) strong[class~="magicx-aia-shimmer-sweep"] span[class~="magicx-aia-segment-image"] {
|
|
332
|
+
animation: none;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/* --- Text box growth ---
|
|
337
|
+
watchEditorHeight writes the editor's height on every change, so a new line
|
|
338
|
+
opens over EDITOR_GROW_MS (340ms) instead of popping in. Reduced motion and
|
|
339
|
+
\`animations: false\` drop the slide; the height still follows the text. */
|
|
340
|
+
.aia-editorArea-7rBWq {
|
|
341
|
+
transition: height 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@media (prefers-reduced-motion: reduce) {
|
|
345
|
+
.aia-editorArea-7rBWq {
|
|
346
|
+
transition: none;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
`,document.head.appendChild(e)}var ot={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaChipForm:"aia-aiaChipForm-tKbNc",aiaTileGrow:"aia-aiaTileGrow-j9Pat",aiaTileSpring:"aia-aiaTileSpring-FEwNg",aiaTileFade:"aia-aiaTileFade-H1LDQ",aiaImageGrow:"aia-aiaImageGrow-i9yw8"};var ge=require("@magicx-eng/ai-autocomplete-vanilla"),de=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
284
350
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
285
351
|
* Consumer CSS always wins without !important.
|
|
286
352
|
*
|
|
@@ -823,6 +889,23 @@
|
|
|
823
889
|
overflow: visible;
|
|
824
890
|
}
|
|
825
891
|
|
|
892
|
+
/* A calendar is the exception to "sections keep their own height": a month
|
|
893
|
+
cut off mid-week reads as broken, and nothing shows that the rest is a
|
|
894
|
+
scroll away. So it gives instead: its weeks squeeze to share the space that
|
|
895
|
+
is left (the datepicker's weeks rule, which sets the floor), and only below
|
|
896
|
+
that floor does the stack scroll. */
|
|
897
|
+
[data-aia-dropdown][data-aia-fit] [data-aia-datepicker] {
|
|
898
|
+
flex-shrink: 1;
|
|
899
|
+
min-height: 0;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/* The footer goes while a calendar is fitted. Its keyboard hint and badge
|
|
903
|
+
would take a week and a half of rows from a month that is already short of
|
|
904
|
+
room, and the calendar's own bottom padding then closes the panel. */
|
|
905
|
+
[data-aia-dropdown][data-aia-fit]:has([data-aia-datepicker]) [data-aia-footer] {
|
|
906
|
+
display: none;
|
|
907
|
+
}
|
|
908
|
+
|
|
826
909
|
[data-aia-dropdown][aria-multiselectable="true"] {
|
|
827
910
|
--aia-grid-scroll-bottom: 0px;
|
|
828
911
|
--aia-grid-overlap-bottom: 0px;
|
|
@@ -831,6 +914,25 @@
|
|
|
831
914
|
--aia-footer-fade-lead: 0px;
|
|
832
915
|
--aia-footer-row-min-height: 0px;
|
|
833
916
|
}
|
|
917
|
+
|
|
918
|
+
/* A multi-select shows three rows and scrolls the rest, in every layout (one
|
|
919
|
+
column, two columns, phone), so its Done button always sits right under
|
|
920
|
+
the third row. The planned cap (--aia-grid-max-height) still wins when it
|
|
921
|
+
is smaller: fewer than three rows of options. */
|
|
922
|
+
[data-aia-dropdown][aria-multiselectable="true"] .aia-grid[data-scroll] {
|
|
923
|
+
max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/* Fitted to the viewport, every other grid hands its scrolling to the panel,
|
|
927
|
+
which would carry Done off screen with the rows. A multi-select keeps its
|
|
928
|
+
own three-row scroll box, and gives up rows before the panel has to scroll,
|
|
929
|
+
so Done stays in view. */
|
|
930
|
+
[data-aia-dropdown][data-aia-fit][aria-multiselectable="true"] .aia-grid[data-scroll] {
|
|
931
|
+
flex-shrink: 1;
|
|
932
|
+
min-height: var(--aia-option-row-height, 37px);
|
|
933
|
+
max-height: min(var(--aia-grid-max-height, 120px), calc(3 * var(--aia-option-row-height, 37px)));
|
|
934
|
+
overflow-y: auto;
|
|
935
|
+
}
|
|
834
936
|
`,document.head.appendChild(e)}if(typeof document<"u"&&!document.getElementById("ac-style-3819c762")){let e=document.createElement("style");e.id="ac-style-3819c762",e.textContent=`.aia-dropdown-yz2KC {
|
|
835
937
|
position: absolute;
|
|
836
938
|
left: 0;
|
|
@@ -925,7 +1027,7 @@
|
|
|
925
1027
|
A bare down chevron at the bottom-centre of the option list, shown while
|
|
926
1028
|
there is more to scroll to \u2014 no disc, border or shadow around it. It rests
|
|
927
1029
|
just above the grid's reserved band, or \u2014 when a product strip follows the
|
|
928
|
-
grid \u2014 centred on the strip's "
|
|
1030
|
+
grid \u2014 centred on the strip's "Best match" label row, off the last option row
|
|
929
1031
|
(--aia-scroll-arrow-bottom is measured and set inline by the controller so
|
|
930
1032
|
it tracks the layout). It never travels with the scroll: the controller toggles
|
|
931
1033
|
data-aia-visible and the only thing that transitions is opacity \u2014 a slow,
|
|
@@ -1162,7 +1264,7 @@
|
|
|
1162
1264
|
font-weight: inherit;
|
|
1163
1265
|
cursor: pointer;
|
|
1164
1266
|
}
|
|
1165
|
-
`,document.head.appendChild(e)}var
|
|
1267
|
+
`,document.head.appendChild(e)}var De={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q",multiDone:"aia-multiDone-y12U7"};var $=require("@magicx-eng/ai-autocomplete-vanilla"),qt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
1166
1268
|
|
|
1167
1269
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1168
1270
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1237,6 +1339,27 @@
|
|
|
1237
1339
|
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
1238
1340
|
}
|
|
1239
1341
|
|
|
1342
|
+
/* The weeks. A row is --aia-date-row-height tall whenever there is room, which
|
|
1343
|
+
keeps a month readable in a narrow dropdown without letting a 6-row month
|
|
1344
|
+
grow the panel past the options grid it replaces. In a panel fitted to a
|
|
1345
|
+
short window (data-aia-fit, see appearance.css) the calendar is the section
|
|
1346
|
+
that gives: the rows share what is left, down to --aia-date-row-min-height,
|
|
1347
|
+
so the whole month stays on screen with its bottom padding instead of the
|
|
1348
|
+
last week being sliced by the panel's edge. Only below that floor does the
|
|
1349
|
+
panel scroll. */
|
|
1350
|
+
.aia-grid-mQCgw {
|
|
1351
|
+
flex: 1 1 auto;
|
|
1352
|
+
/* Without it the grid's automatic minimum is its full-height rows, and
|
|
1353
|
+
nothing squeezes. */
|
|
1354
|
+
min-height: 0;
|
|
1355
|
+
/* The floor never exceeds the chosen height, so a host that set a row
|
|
1356
|
+
shorter than the floor still gets exactly its own height. */
|
|
1357
|
+
grid-auto-rows: minmax(
|
|
1358
|
+
min(var(--aia-date-row-min-height, 20px), var(--aia-date-row-height, 28px)),
|
|
1359
|
+
var(--aia-date-row-height, 28px)
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1240
1363
|
.aia-weekday-3lF4B {
|
|
1241
1364
|
padding: 2px 0;
|
|
1242
1365
|
text-align: center;
|
|
@@ -1259,9 +1382,9 @@
|
|
|
1259
1382
|
items disagree, which makes it look like a column-count bug. The cell
|
|
1260
1383
|
fills its track; the square is the number span inside it. */
|
|
1261
1384
|
min-width: 0;
|
|
1262
|
-
/*
|
|
1263
|
-
|
|
1264
|
-
|
|
1385
|
+
/* No height of its own: the cell fills its row, and the row's height is the
|
|
1386
|
+
grid's to give (see the weeks rule above), so a short window can squeeze
|
|
1387
|
+
the weeks instead of cutting the last one off. */
|
|
1265
1388
|
font-family: inherit;
|
|
1266
1389
|
font-size: var(--aia-date-cell-font-size, 13px);
|
|
1267
1390
|
font-weight: 450;
|
|
@@ -1277,6 +1400,9 @@
|
|
|
1277
1400
|
justify-content: center;
|
|
1278
1401
|
width: var(--aia-date-cell-size, 26px);
|
|
1279
1402
|
height: var(--aia-date-cell-size, 26px);
|
|
1403
|
+
/* A squeezed row (see the weeks rule) is shorter than the square: it stays
|
|
1404
|
+
inside its own row rather than touching the week above and below. */
|
|
1405
|
+
max-height: 100%;
|
|
1280
1406
|
border-radius: 6px;
|
|
1281
1407
|
}
|
|
1282
1408
|
|
|
@@ -1325,7 +1451,7 @@
|
|
|
1325
1451
|
opacity: 0.8;
|
|
1326
1452
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1327
1453
|
}
|
|
1328
|
-
`,document.head.appendChild(e)}var
|
|
1454
|
+
`,document.head.appendChild(e)}var Q={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};var ue=require("react/jsx-runtime"),Aa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function _t({options:e,activeIndex:i,listboxId:t,view:a,selection:o,onSelect:r,onHighlight:n,onUnhighlight:l,onPreviousMonth:f,onNextMonth:x}){let y=(0,$.isoDate)(new Date),m=(0,$.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,$.cellIso)(e[i]),selected:o.selectedRange});return(0,ue.jsxs)("div",{className:Q.datepicker,"data-aia-datepicker":"",children:[(0,ue.jsxs)("div",{className:Q.header,children:[(0,ue.jsx)("button",{type:"button",tabIndex:-1,className:Q.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:c=>c.preventDefault(),onClick:f,children:"\u2039"}),(0,ue.jsx)("span",{className:Q.month,"data-aia-date-month":"","aria-live":"polite",children:(0,$.monthLabel)(a)}),(0,ue.jsx)("button",{type:"button",tabIndex:-1,className:Q.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:c=>c.preventDefault(),onClick:x,children:"\u203A"})]}),(0,ue.jsx)("div",{className:Q.weekdays,"aria-hidden":"true",children:$.WEEKDAY_LABELS.map((c,p)=>(0,ue.jsx)("span",{className:Q.weekday,children:c},Aa[p]))}),(0,ue.jsx)("div",{className:Q.grid,"data-aia-date-grid":"",children:e.map((c,p)=>(0,ue.jsx)(La,{option:c,id:`${t}-option-${p}`,index:p,isHighlighted:p===i&&c.is_tappable,isToday:(0,$.cellIso)(c)===y,isPast:(0,$.cellIso)(c)!=null&&(0,$.cellIso)(c)<y,marks:(0,$.dateCellMarks)((0,$.cellIso)(c),{selectedIso:o.selectedIso,range:m}),onSelect:r,onHighlight:n,onUnhighlight:l},(0,$.cellIso)(c)??`pad-${p}`))})]})}function La({option:e,id:i,index:t,isHighlighted:a,isToday:o,isPast:r,marks:n,onSelect:l,onHighlight:f,onUnhighlight:x}){let[y,m]=(0,qt.useState)(!1),c=(0,$.cellDay)(e);if(c==null)return(0,ue.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${Q.cell} ${Q.blank}`});let p=()=>{m(!0),l(e),setTimeout(()=>m(!1),170)},v=[Q.cell,Q.day,r?Q.past:"",a?Q.highlighted:"",o?Q.today:"",n.inRange?Q.inRange:"",n.selected?Q.selected:"",y?Q.pressed:""].filter(Boolean).join(" ");return(0,ue.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:v,onClick:p,onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),p())},onMouseEnter:()=>f(t),onMouseLeave:x?()=>x(t):void 0,children:(0,ue.jsx)("span",{className:Q.number,children:c})})}var $e=require("@magicx-eng/ai-autocomplete-vanilla"),xt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1329
1455
|
display: flex;
|
|
1330
1456
|
flex-wrap: wrap;
|
|
1331
1457
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1365,7 +1491,7 @@
|
|
|
1365
1491
|
.aia-cluster[data-justify="around"] {
|
|
1366
1492
|
justify-content: space-around;
|
|
1367
1493
|
}
|
|
1368
|
-
`,document.head.appendChild(e)}var
|
|
1494
|
+
`,document.head.appendChild(e)}var Rt=require("react/jsx-runtime");function gt({gap:e,align:i="center",justify:t="start",noWrap:a=!1,inline:o=!1,className:r,children:n,...l}){let f=e?{"--aia-cluster-gap":e}:void 0,x={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":i,"data-justify":t,"data-nowrap":a||void 0,"data-inline":o||void 0,style:f,...l};return o?(0,Rt.jsx)("span",{...x,children:n}):(0,Rt.jsx)("div",{...x,children:n})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1369
1495
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1370
1496
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1371
1497
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1512,7 +1638,134 @@
|
|
|
1512
1638
|
justify-content: flex-end;
|
|
1513
1639
|
}
|
|
1514
1640
|
}
|
|
1515
|
-
`,document.head.appendChild(e)}var
|
|
1641
|
+
`,document.head.appendChild(e)}var qe={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};var Me=require("react/jsx-runtime");function Vt({isOptionHighlighted:e=!1,isInputEmpty:i=!1,strings:t=(0,$e.uiStringsFor)()}){let{key:a,hint:o}=(0,$e.getFooterHint)(e,i,t),[r,n]=(0,xt.useState)($e.ATTRIBUTION_URL);return(0,xt.useEffect)(()=>{n((0,$e.buildAttributionUrl)())},[]),(0,Me.jsx)("footer",{className:qe.footer,"data-aia-footer":"",children:(0,Me.jsxs)(gt,{justify:"between",noWrap:!0,className:qe.row,children:[(0,Me.jsxs)(gt,{gap:"5px",className:qe.hintGroup,children:[(0,Me.jsx)("kbd",{className:qe.key,children:a}),(0,Me.jsx)("span",{className:qe.hint,children:o})]}),(0,Me.jsxs)("a",{className:qe.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,Me.jsx)("span",{className:qe.brand,children:"AI"}),(0,Me.jsx)("span",{className:qe.badge,children:"Autocomplete"})]})]})})}var ie=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-2feec02e")){let e=document.createElement("style");e.id="ac-style-2feec02e",e.textContent=`/* Location search \u2014 React copy of the vanilla rules in styles.css (and of the
|
|
1642
|
+
Angular copy). The three are kept identical by
|
|
1643
|
+
packages/vanilla/tests/render/locationFieldParity.test.ts. */
|
|
1644
|
+
.aia-location-6-fsr {
|
|
1645
|
+
display: flex;
|
|
1646
|
+
flex-direction: column;
|
|
1647
|
+
gap: 4px;
|
|
1648
|
+
padding: 6px 6px 4px;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
.aia-field-xEzwi {
|
|
1652
|
+
display: flex;
|
|
1653
|
+
align-items: center;
|
|
1654
|
+
gap: 8px;
|
|
1655
|
+
padding: 8px 10px;
|
|
1656
|
+
border-radius: var(--aia-location-field-radius, 10px);
|
|
1657
|
+
background: var(--aia-location-field-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06));
|
|
1658
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
1659
|
+
cursor: text;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
.aia-icon-czx6C {
|
|
1663
|
+
display: block;
|
|
1664
|
+
width: 15px;
|
|
1665
|
+
height: 15px;
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
.aia-input-Yi9V- {
|
|
1669
|
+
flex: 1;
|
|
1670
|
+
min-width: 0;
|
|
1671
|
+
padding: 0;
|
|
1672
|
+
border: 0;
|
|
1673
|
+
outline: 0;
|
|
1674
|
+
background: transparent;
|
|
1675
|
+
font: inherit;
|
|
1676
|
+
/* Never under 16px: iOS Safari zooms the page into a smaller field it focuses. */
|
|
1677
|
+
font-size: max(16px, var(--aia-location-font-size, 15px));
|
|
1678
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
.aia-input-Yi9V-::placeholder {
|
|
1682
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
1683
|
+
opacity: 0.7;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
.aia-results-C3O0V {
|
|
1687
|
+
display: flex;
|
|
1688
|
+
flex-direction: column;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
.aia-row-Q9y8g {
|
|
1692
|
+
display: flex;
|
|
1693
|
+
align-items: center;
|
|
1694
|
+
gap: 10px;
|
|
1695
|
+
padding: 8px 10px;
|
|
1696
|
+
border-radius: 8px;
|
|
1697
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
1698
|
+
cursor: pointer;
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
.aia-row-Q9y8g:hover,
|
|
1702
|
+
.aia-highlighted-RJjPx {
|
|
1703
|
+
background: var(
|
|
1704
|
+
--aia-location-row-bg-highlighted,
|
|
1705
|
+
rgba(var(--aia-streak-rgb, 255, 255, 255), 0.08)
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
.aia-pin-OjabL {
|
|
1710
|
+
flex: 0 0 15px;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
.aia-text-Xs84O {
|
|
1714
|
+
display: flex;
|
|
1715
|
+
flex-direction: column;
|
|
1716
|
+
min-width: 0;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
.aia-name-Z-WJR {
|
|
1720
|
+
overflow: hidden;
|
|
1721
|
+
font-size: var(--aia-location-font-size, 15px);
|
|
1722
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
1723
|
+
text-overflow: ellipsis;
|
|
1724
|
+
white-space: nowrap;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
.aia-secondary-4sCT1 {
|
|
1728
|
+
overflow: hidden;
|
|
1729
|
+
font-size: 13px;
|
|
1730
|
+
text-overflow: ellipsis;
|
|
1731
|
+
white-space: nowrap;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
.aia-note-xCSvY {
|
|
1735
|
+
display: flex;
|
|
1736
|
+
flex-direction: column;
|
|
1737
|
+
gap: 2px;
|
|
1738
|
+
padding: 8px 10px;
|
|
1739
|
+
font-size: 13px;
|
|
1740
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
.aia-empty-SYBzi {
|
|
1744
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
.aia-loading-Ih1gi {
|
|
1748
|
+
display: flex;
|
|
1749
|
+
flex-direction: column;
|
|
1750
|
+
gap: 12px;
|
|
1751
|
+
padding: 10px;
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
.aia-loadingBar-OLCr4 {
|
|
1755
|
+
width: 70%;
|
|
1756
|
+
height: 12px;
|
|
1757
|
+
border-radius: 6px;
|
|
1758
|
+
background: var(--aia-skeleton-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.08));
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
.aia-loadingBar-OLCr4:nth-child(2) {
|
|
1762
|
+
width: 50%;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
1766
|
+
width: 60%;
|
|
1767
|
+
}
|
|
1768
|
+
`,document.head.appendChild(e)}var Y={location:"aia-location-6-fsr",field:"aia-field-xEzwi",icon:"aia-icon-czx6C",input:"aia-input-Yi9V-",results:"aia-results-C3O0V",row:"aia-row-Q9y8g",highlighted:"aia-highlighted-RJjPx",pin:"aia-pin-OjabL",text:"aia-text-Xs84O",name:"aia-name-Z-WJR",secondary:"aia-secondary-4sCT1",note:"aia-note-xCSvY",empty:"aia-empty-SYBzi",loading:"aia-loading-Ih1gi",loadingBar:"aia-loadingBar-OLCr4"};var W=require("react/jsx-runtime"),Ra=0;function ft(e){return e.getRootNode().activeElement??null}function Qt(e){return e.getRootNode().getSelection?.()??document.getSelection()}function Oa(e){if(!e.isContentEditable)return null;let i=Qt(e);if(!i||i.rangeCount===0)return null;let t=i.getRangeAt(0);return e.contains(t.startContainer)?t.cloneRange():null}function Ut(e,i){if(e.focus({preventScroll:!0}),!e.isContentEditable)return;let t=Qt(e);if(!t)return;let a=i;(!a||!a.startContainer.isConnected||!e.contains(a.startContainer))&&(a=document.createRange(),a.selectNodeContents(e),a.collapse(!1)),t.removeAllRanges(),t.addRange(a)}var Da=(0,W.jsxs)("svg",{className:Y.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,W.jsx)("path",{d:"M12 21s-7-6.2-7-11.5A7 7 0 0 1 19 9.5C19 14.8 12 21 12 21z"}),(0,W.jsx)("circle",{cx:"12",cy:"9.5",r:"2.5"})]}),Ma=(0,W.jsxs)("svg",{className:Y.icon,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:[(0,W.jsx)("circle",{cx:"11",cy:"11",r:"7"}),(0,W.jsx)("path",{d:"m20 20-3.5-3.5"})]});function Yt({view:e,searchLabel:i,noResultsLabel:t,useTypedLabel:a,widgetFocused:o,visible:r=!0,interactive:n=!0,onQuery:l,onMove:f,onCommit:x,onFocusChange:y}){let m=(0,ie.useRef)(null),c=(0,ie.useRef)(null),p=(0,ie.useRef)(null),v=(0,ie.useRef)(null),O=(0,ie.useRef)(null),G=(0,ie.useRef)(!1),N=(0,ie.useRef)(!1),V=(0,ie.useRef)(!1),Z=(0,ie.useRef)(o);Z.current=o;let D=(0,ie.useRef)(y);D.current=y;let E=h=>{V.current=h,y(h)},S=()=>{let h=m.current;return h!=null&&ft(h)===h},ee=()=>{let h=c.current;if(!h)return;let A=ft(h);A instanceof HTMLElement&&A!==m.current&&A!==document.body&&!h.contains(A)&&(v.current=A,O.current=Oa(A))},te=(0,ie.useRef)(null);te.current===null&&(te.current=`aia-location-${++Ra}`);let U=`${te.current}-row-`;(0,ie.useEffect)(()=>{let h=m.current;h&&h.value!==e.query&&ft(h)!==h&&(h.value=e.query)},[e.query]),(0,ie.useEffect)(()=>{let h=m.current;if(h){if(!r&&S()){N.current=!0,K();return}if(!o){setTimeout(()=>{if(Z.current)return;let A=v.current;A&&ft(A)===A||(N.current=!1)},0);return}if(!(N.current||!n||S())){if(ee(),E(!0),h.focus({preventScroll:!0}),!S()){N.current=!0,E(!1);return}h.value&&h.select()}}}),(0,ie.useLayoutEffect)(()=>()=>{if(!V.current)return;let h=m.current,A=v.current;A?.isConnected&&h&&ft(h)===h&&(G.current=!0,Ut(A,O.current),G.current=!1),V.current=!1,D.current(!1)},[]);let K=(h=!1)=>{h&&(N.current=!0);let A=v.current;A?.isConnected&&S()&&(G.current=!0,Ut(A,O.current),G.current=!1),E(!1)},fe=e.query.trim(),I=e.highlighted>=0&&e.highlighted<e.places.length?`${U}${e.highlighted}`:void 0,X=null;return e.places.length>0?X=e.places.map((h,A)=>(0,W.jsxs)("div",{id:`${U}${A}`,role:"option","aria-selected":A===e.highlighted,className:A===e.highlighted?`${Y.row} ${Y.highlighted}`:Y.row,"data-aia-location-row":"","data-aia-index":A,onClick:()=>{n&&(K(!0),x(A))},children:[(0,W.jsx)("span",{className:Y.pin,children:Da}),(0,W.jsxs)("span",{className:Y.text,children:[(0,W.jsx)("span",{className:Y.name,children:h.name}),h.secondary&&(0,W.jsx)("span",{className:Y.secondary,children:h.secondary})]})]},h.id)):e.status==="loading"?X=(0,W.jsxs)("div",{className:Y.loading,"data-aia-location-loading":"",children:[(0,W.jsx)("span",{className:Y.loadingBar}),(0,W.jsx)("span",{className:Y.loadingBar}),(0,W.jsx)("span",{className:Y.loadingBar})]}):fe&&(X=(0,W.jsxs)("div",{className:Y.note,"data-aia-location-note":"",children:[e.status==="done"&&(0,W.jsx)("span",{className:Y.empty,children:t}),(0,W.jsx)("span",{children:a})]})),(0,W.jsxs)("div",{ref:c,className:Y.location,"data-aia-location":"",onMouseDown:h=>{!(h.target instanceof Node)||!p.current?.contains(h.target)||(h.stopPropagation(),ee(),E(!0))},children:[(0,W.jsxs)("label",{ref:p,className:Y.field,children:[Ma,(0,W.jsx)("input",{ref:m,type:"text",className:Y.input,"data-aia-location-input":"",defaultValue:e.query,placeholder:i,"aria-label":i,"aria-activedescendant":I,autoComplete:"off",autoCapitalize:"words",enterKeyHint:"done",spellCheck:!1,tabIndex:r?0:-1,onChange:h=>l(h.target.value),onFocus:()=>E(!0),onBlur:()=>{G.current||(N.current=!0,E(!1))},onKeyDown:h=>{if(!h.nativeEvent.isComposing)switch(h.key){case"ArrowDown":case"ArrowUp":h.preventDefault(),f(h.key==="ArrowDown"?1:-1);return;case"Enter":if(h.preventDefault(),!n)return;K(!0),x();return;case"Escape":h.preventDefault(),h.stopPropagation(),N.current=!0,K();return;case"Backspace":if(h.currentTarget.value!=="")return;h.preventDefault(),N.current=!0,K();return}}})]}),(0,W.jsx)("div",{className:Y.results,"data-aia-location-results":"","aria-live":"polite",children:X})]})}var yt=require("@magicx-eng/ai-autocomplete-vanilla");var jt=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
1516
1769
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1517
1770
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1518
1771
|
as it was when the outline was dashed. */
|
|
@@ -1692,7 +1945,7 @@
|
|
|
1692
1945
|
opacity: 0;
|
|
1693
1946
|
}
|
|
1694
1947
|
}
|
|
1695
|
-
`,document.head.appendChild(e)}var
|
|
1948
|
+
`,document.head.appendChild(e)}var ze={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var Ze=require("react/jsx-runtime"),Ot={selected:1,first:.7,next:.4,last:.2};function $t({label:e,state:i,rounded:t,loading:a,smartSuggestion:o,completionHeader:r,onClick:n}){let l=[ze.pill,t?ze.rounded:"",a?ze.skeleton:""].filter(Boolean).join(" ");return(0,Ze.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,"data-aia-smart-suggestion":o?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:l,style:{opacity:Ot[i]},onMouseDown:f=>f.preventDefault(),onClick:a?void 0:n,disabled:a,children:o?(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)("span",{className:`${ze.smartText} magicx-aia-smart-suggestion-text`,children:e}),(0,Ze.jsx)("span",{className:`${ze.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:jt.SMART_SUGGESTION_SPARKLE_SVG}})]}):e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1696
1949
|
position: relative;
|
|
1697
1950
|
z-index: 1;
|
|
1698
1951
|
pointer-events: auto;
|
|
@@ -1702,7 +1955,7 @@
|
|
|
1702
1955
|
align-items: center;
|
|
1703
1956
|
vertical-align: middle;
|
|
1704
1957
|
}
|
|
1705
|
-
`,document.head.appendChild(e)}var
|
|
1958
|
+
`,document.head.appendChild(e)}var Dt={list:"aia-list-qvLqO"};var bt=require("react/jsx-runtime"),za=[125,69];function Zt(e){return e===0?"first":e===1?"next":"last"}function kt({pills:e,activePillIndex:i,onSelectPill:t,activeSelected:a,rounded:o,loading:r}){return r&&e.length===0?(0,bt.jsx)("span",{className:Dt.list,"data-aia-pill-list-loading":"",children:za.map((n,l)=>(0,bt.jsx)("span",{"data-aia-pill-skeleton":"",className:`${ze.pill} ${o?ze.rounded:""} ${ze.skeleton}`,style:{width:n,opacity:Ot[Zt(l)]}},`skel-${n}`))}):(0,bt.jsx)("span",{className:Dt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((n,l)=>{let f=!!a&&l===i;return(0,bt.jsx)($t,{label:n.text,state:f?"selected":Zt(l),selected:f,rounded:o,loading:r,smartSuggestion:(0,yt.isSmartSuggestion)(n),completionHeader:(0,yt.isTraditionalAutocompleteSuggestion)(n),onClick:()=>t(l)},`${n.parameter}-${n.text}`)})})}var xe=require("@magicx-eng/ai-autocomplete-vanilla"),me=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
|
|
1706
1959
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1707
1960
|
theming one package sees the same result in the other.
|
|
1708
1961
|
|
|
@@ -2158,7 +2411,7 @@
|
|
|
2158
2411
|
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2159
2412
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2160
2413
|
}
|
|
2161
|
-
`,document.head.appendChild(e)}var
|
|
2414
|
+
`,document.head.appendChild(e)}var j={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",compareAt:"aia-compareAt-ewE54",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr"};var H=require("react/jsx-runtime");function Xt({products:e,listboxId:i,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r=!0,layout:n="row",imageFallback:l="image",strings:f=(0,xe.uiStringsFor)()}){let x=e.length>0,y=(0,me.useRef)(null);if((0,me.useEffect)(()=>{let c=y.current;if(!(!x||!c))return(0,xe.attachProductRowWheel)(c)},[x]),!x)return null;let m=`${i}-products-label`;return(0,H.jsxs)("section",{className:j.section,"data-aia-products":"","data-aia-products-layout":n,role:"group","aria-labelledby":m,children:[(0,H.jsx)("div",{className:j.label,id:m,"data-aia-products-label":"",children:f.products}),(0,H.jsx)("div",{ref:y,className:j.row,"data-aia-products-row":"",children:e.map((c,p)=>(0,H.jsx)(Na,{product:c,id:`${i}-product-${p}`,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:l,soldOut:f.soldOut,addToCart:f.addToCart},c.id))})]})}function Na({product:e,id:i,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:n,soldOut:l,addToCart:f}){let x=!!a&&e.available!==!1,[y,m]=(0,me.useState)(null),c=v=>{v.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},p=v=>{v.metaKey||v.ctrlKey||v.shiftKey||v.altKey||v.button!==0||(v.preventDefault(),t(e))};return(0,H.jsxs)("a",{id:i,className:j.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":x?"":void 0,role:"option","aria-selected":!1,style:y?{"--aia-product-photo-fill-x":String(y.x),"--aia-product-photo-fill-y":String(y.y)}:void 0,href:e.url,tabIndex:r?0:-1,onClick:p,onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),t(e))},onFocus:()=>o?.(!0),onBlur:c,children:[(0,H.jsx)(Ba,{sources:(0,xe.productImageSources)(e.imageUrl),title:e.title,fallback:n,onPhotoFill:m},(0,xe.productImageSrc)(e.imageUrl)??""),(0,H.jsxs)("span",{className:j.body,children:[e.vendor?(0,H.jsx)("span",{className:j.vendor,children:e.vendor}):null,(0,H.jsx)("span",{className:j.title,children:e.title}),e.price?(0,H.jsxs)("span",{className:j.price,children:[e.price,e.compareAtPrice?(0,H.jsx)("s",{className:j.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?(0,H.jsx)("span",{className:j.badge,children:l}):null]}),x&&a?(0,H.jsx)(Ha,{product:e,label:`${f}: ${e.title}`,focusable:r,onAddToCart:a,onFocus:()=>o?.(!0),onBlur:c},Fa(e)):null]})}function Fa(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(i=>i??"").join("\0")}function Ha({product:e,label:i,focusable:t,onAddToCart:a,onFocus:o,onBlur:r}){let[n,l]=(0,me.useState)(null),f=(0,me.useRef)(null),x=(0,me.useRef)(e);x.current=e;let y=(0,me.useRef)(!0);(0,me.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let m=p=>{f.current=p,y.current&&l(p)},c=p=>{if(p.preventDefault(),p.stopPropagation(),f.current==="adding")return;m("adding");let v;try{v=Promise.resolve(a(x.current))}catch(O){v=Promise.reject(O)}v.then(()=>m("added"),()=>m(null))};return(0,H.jsx)("span",{className:j.cart,"data-aia-product-cart":"","data-aia-cart-state":n??void 0,"aria-busy":n==="adding"?!0:void 0,role:"button","aria-label":i,tabIndex:t?0:-1,onClick:c,onKeyDown:p=>{p.key!=="Enter"&&p.key!==" "||c(p)},onFocus:p=>{p.stopPropagation(),o()},onBlur:p=>{p.stopPropagation(),r(p)},children:(0,H.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[(0,H.jsx)("path",{className:j.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),(0,H.jsx)("path",{className:j.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),(0,H.jsx)("path",{className:j.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),(0,H.jsx)("path",{className:j.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),(0,H.jsx)("circle",{className:j.cartGlyph,cx:"9",cy:"20",r:"1.3"}),(0,H.jsx)("circle",{className:j.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function Ba({sources:e,title:i,fallback:t,onPhotoFill:a}){let[o,r]=(0,me.useState)(0),n=e[o],l=!!n,[f,x]=(0,me.useState)(null),y=!l&&t==="initial";return(0,me.useEffect)(()=>()=>a(null),[a]),(0,H.jsxs)("span",{className:j.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!y?"":void 0,"data-aia-product-initial":y?"":void 0,"data-aia-image-loaded":l&&f===n?"":void 0,children:[l?(0,H.jsx)("img",{className:j.image,src:n,alt:"",loading:"lazy",decoding:"async",onLoad:m=>{x(n),a((0,xe.productPhotoFill)(m.currentTarget.naturalWidth,m.currentTarget.naturalHeight))},onError:()=>{o+1>=e.length&&a(null),r(m=>m+1)}}):null,y?(0,xe.productInitial)(i):null]})}var ne=require("@magicx-eng/ai-autocomplete-vanilla"),Ne=require("react");var Jt=require("@magicx-eng/ai-autocomplete-vanilla"),Ct=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
2162
2415
|
display: grid;
|
|
2163
2416
|
grid-template-columns: repeat(
|
|
2164
2417
|
auto-fit,
|
|
@@ -2194,11 +2447,11 @@
|
|
|
2194
2447
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
2195
2448
|
display: none;
|
|
2196
2449
|
}
|
|
2197
|
-
`,document.head.appendChild(e)}var
|
|
2450
|
+
`,document.head.appendChild(e)}var ta=require("react/jsx-runtime");function ea({min:e="16rem",max:i,gap:t,scroll:a=!1,maxHeight:o,scrollResetKey:r,cols:n,template:l,innerRef:f,className:x,children:y,...m}){let c=(0,Ct.useRef)(null);(0,Ct.useLayoutEffect)(()=>{if(r===void 0)return;let v=c.current;v&&(v.scrollTop=0)},[r]);let p={"--aia-grid-min":e};return i&&(p["--aia-grid-max"]=i),t&&(p["--aia-grid-gap"]=t),o&&(p["--aia-grid-max-height"]=o),n&&(p.gridTemplateColumns=(0,Jt.optionsGridTemplateColumns)(n)),l&&(p.gridTemplateColumns=l),(0,ta.jsx)("div",{ref:v=>{c.current=v,f?.(v)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":a||void 0,style:p,...m,children:y})}var ce=require("@magicx-eng/ai-autocomplete-vanilla"),Ce=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
|
|
2198
2451
|
position: relative;
|
|
2199
2452
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2200
2453
|
and a transformed box extends its scroll container's scrollable area.
|
|
2201
|
-
Unclipped, the rows rising
|
|
2454
|
+
Unclipped, the rows rising 7px from below made the option grid overflow
|
|
2202
2455
|
for the length of the entrance whenever nothing sat under the grid to
|
|
2203
2456
|
absorb it (product strip, optionsPosition="above"), so a scrollbar
|
|
2204
2457
|
flashed in and out and the columns shifted sideways by its width. The
|
|
@@ -2239,7 +2492,7 @@
|
|
|
2239
2492
|
|
|
2240
2493
|
@keyframes aia-riseIn-etXZT {
|
|
2241
2494
|
from {
|
|
2242
|
-
transform: translateY(
|
|
2495
|
+
transform: translateY(7px);
|
|
2243
2496
|
}
|
|
2244
2497
|
}
|
|
2245
2498
|
|
|
@@ -2248,6 +2501,7 @@
|
|
|
2248
2501
|
.aia-content-T-Qba {
|
|
2249
2502
|
animation-duration: 0s;
|
|
2250
2503
|
animation-delay: 0s;
|
|
2504
|
+
transition-duration: 0s;
|
|
2251
2505
|
}
|
|
2252
2506
|
}
|
|
2253
2507
|
|
|
@@ -2263,8 +2517,8 @@
|
|
|
2263
2517
|
(see the row's own comment). The durations and distance mirror
|
|
2264
2518
|
OPTION_ENTER_* in the core's derive/optionsEntrance.ts \u2014 change both together. */
|
|
2265
2519
|
animation:
|
|
2266
|
-
aia-riseIn-etXZT
|
|
2267
|
-
aia-fadeIn-I8u35
|
|
2520
|
+
aia-riseIn-etXZT 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
|
|
2521
|
+
aia-fadeIn-I8u35 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
|
|
2268
2522
|
animation-delay: var(--aia-option-enter-delay, 0ms);
|
|
2269
2523
|
}
|
|
2270
2524
|
|
|
@@ -2280,12 +2534,31 @@
|
|
|
2280
2534
|
cursor: default;
|
|
2281
2535
|
}
|
|
2282
2536
|
|
|
2283
|
-
.aia-highlighted-Hb0SU
|
|
2537
|
+
.aia-highlighted-Hb0SU,
|
|
2538
|
+
.aia-liveMatch--eYfs {
|
|
2284
2539
|
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
2285
2540
|
background: var(--aia-option-bg, transparent);
|
|
2286
2541
|
font-weight: 500;
|
|
2287
2542
|
}
|
|
2288
2543
|
|
|
2544
|
+
/* Live match: while a word is typed, the row it is spelling out lights up
|
|
2545
|
+
(the rule above) and every other row steps back, so the choice reads as
|
|
2546
|
+
locked in before the word is finished. The core marks the row
|
|
2547
|
+
(\`liveMatch\`). The step back is a filter on the inner content: on iOS a tap
|
|
2548
|
+
on a row whose own opacity is changing is dropped (lessons.md), and the
|
|
2549
|
+
content's entrance already owns its opacity. */
|
|
2550
|
+
.aia-item-d4vpD {
|
|
2551
|
+
transition: background-color 180ms ease;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
.aia-content-T-Qba {
|
|
2555
|
+
transition: filter 180ms ease;
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
[role="listbox"]:has(.aia-liveMatch--eYfs) .aia-item-d4vpD:not(.aia-liveMatch--eYfs):not(.aia-highlighted-Hb0SU) .aia-content-T-Qba {
|
|
2559
|
+
filter: opacity(0.42);
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2289
2562
|
.aia-tag-e3Fwe {
|
|
2290
2563
|
font-size: 11px;
|
|
2291
2564
|
margin-left: 6px;
|
|
@@ -2700,7 +2973,7 @@
|
|
|
2700
2973
|
.aia-item-d4vpD:has(.aia-checkbox-KGRhg[data-checked="true"]) {
|
|
2701
2974
|
background: var(--aia-option-bg, transparent);
|
|
2702
2975
|
}
|
|
2703
|
-
`,document.head.appendChild(e)}var
|
|
2976
|
+
`,document.head.appendChild(e)}var oe={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",liveMatch:"aia-liveMatch--eYfs",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd",checkbox:"aia-checkbox-KGRhg"};var se=require("react/jsx-runtime");function aa({option:e,isHighlighted:i,checked:t,onSelect:a,onHighlight:o,onUnhighlight:r,id:n,loading:l,showIcon:f=!0,showImage:x=!0,showCount:y=!0,scrollHint:m,enterDelayMs:c=0}){let[p]=(0,Ce.useState)(c),[v,O]=(0,Ce.useState)(!1),G=x?(0,ce.optionImageSources)(e.image_url):[],N=G[0]??null,[V,Z]=(0,Ce.useState)([]),D=G.find(I=>!V.includes(I))??null,[E,S]=(0,Ce.useState)(null),ee=(0,Ce.useMemo)(()=>!N&&f&&e.icon_svg?(0,ce.sanitizeOptionIconSvg)(e.icon_svg):null,[N,f,e.icon_svg]),te=y?(0,ce.formatOptionCount)(e.item_count):null,U=(0,Ce.useRef)(void 0);(0,Ce.useEffect)(()=>()=>clearTimeout(U.current),[]);let K=I=>{if(l||!e.is_tappable||v&&t===void 0)return;O(!0);let X=I?.currentTarget;t!==void 0&&X!==void 0&&I!==void 0&&!(0,ce.isMultiSelectToggleTap)(X,X.querySelector("[data-aia-checkbox]"),I)?a(e,{commit:!0}):a(e),clearTimeout(U.current),U.current=setTimeout(()=>O(!1),170)},fe=[oe.item,i&&!l?oe.highlighted:"",e.liveMatch&&!l?oe.liveMatch:"",e.is_tappable?oe.tappable:oe.nonTappable,v?oe.pressed:"",m?oe.scrollHint:""].filter(Boolean).join(" ");return(0,se.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":ee&&e.icon?e.icon:void 0,"data-aia-image":N?"":void 0,"data-aia-item-count":te!==null?e.item_count:void 0,"aria-selected":t??i,className:fe,style:{[ce.OPTION_ENTER_DELAY_VAR]:`${p}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:K,onKeyDown:I=>{!l&&e.is_tappable&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),K())},onMouseEnter:!l&&e.is_tappable?o:void 0,onMouseLeave:r,children:(0,se.jsxs)("span",{className:oe.content,children:[t!==void 0&&e.is_tappable&&(0,se.jsx)("span",{className:oe.checkbox,"aria-hidden":"true","data-aia-checkbox":"","data-checked":t,children:t?"\u2713":""}),N&&(0,se.jsx)("span",{className:`${oe.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":D!==null&&E===D?"":void 0,children:(0,se.jsx)("img",{src:D??N,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:D===null,onLoad:()=>S(D),onError:()=>{D!==null&&Z(I=>[...I,D])}})}),ee&&(0,se.jsx)("span",{className:`${oe.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:ee}}),(0,se.jsxs)("span",{className:oe.text,children:[e.matchedText?(0,ce.highlightParts)((0,ce.optionLabel)(e),e.matchedText).map((I,X)=>I.bold?(0,se.jsx)("strong",{className:`${oe.match} magicx-aia-option-match`,children:I.text},X):I.text):(0,ce.optionLabel)(e),e.parameterLabel&&(0,se.jsxs)(se.Fragment,{children:[" ",(0,se.jsx)("span",{className:`${oe.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&(0,se.jsx)("span",{className:oe.tag,children:e.tag}),te!==null&&(0,se.jsx)("span",{className:`${oe.count} magicx-aia-option-count`,children:te})]})})}var Mt=require("react/jsx-runtime");function Wa(){let[e,i]=(0,Ne.useState)(ne.isOptionsGridMobileViewport);return(0,Ne.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ne.OPTIONS_GRID_MOBILE_QUERY),a=()=>i(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function ia({options:e,activeIndex:i,picked:t,onSelect:a,onHighlight:o,onUnhighlight:r,listboxId:n,loading:l,groupKey:f="",optionsPosition:x="below",showIcons:y=!0,showImages:m=!0,showCounts:c=!0}){let p=Wa(),v=(0,Ne.useRef)(null),[O,G]=(0,Ne.useState)(null),N=(0,Ne.useRef)(null);(0,Ne.useLayoutEffect)(()=>{if(l&&(0,ne.sameOptionRows)(N.current,e))return;N.current=l?null:e;let D=v.current,S=D&&!l&&(0,ne.needsOptionsGridMeasurement)(e.length,p)?(0,ne.measureOptionsGrid)(D):null;G(S?(0,ne.planOptionsGrid)(e.length,p,S.rowWidths,S.gridWidth):null)},[e,p,l]);let V=O??(0,ne.planOptionsGrid)(e.length,p,null,null),Z=(0,ne.optionsShowLeadingVisuals)(e,y,m);return(0,Mt.jsx)(ea,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:f,template:V.template,maxHeight:V.maxHeight,innerRef:D=>{v.current=D},"data-aia-group":f,children:e.map((D,E)=>(0,Mt.jsx)(aa,{option:D,isHighlighted:E===i,checked:t?t.includes(D.text):void 0,onSelect:a,onHighlight:()=>o(E),onUnhighlight:r?()=>r(E):void 0,id:`${n}-option-${E}`,loading:l,showIcon:y&&Z,showImage:m&&Z,showCount:c,scrollHint:!l&&V.scrollHintIndices.includes(E),enterDelayMs:l?0:(0,ne.optionEnterDelayMs)(E,V.cols,e.length,x)},`${f}\0${D.text}`))})}var le=require("@magicx-eng/ai-autocomplete-vanilla"),Te=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
|
|
2704
2977
|
|
|
2705
2978
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
2706
2979
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -2825,7 +3098,7 @@
|
|
|
2825
3098
|
.aia-done-llNY5:hover {
|
|
2826
3099
|
background: var(--aia-time-done-bg-hover, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.16));
|
|
2827
3100
|
}
|
|
2828
|
-
`,document.head.appendChild(e)}var
|
|
3101
|
+
`,document.head.appendChild(e)}var Se={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};var ye=require("react/jsx-runtime"),Ga=120;function oa({view:e,label:i,doneLabel:t,interactive:a=!0,onTimeChange:o,onTimeCommit:r}){return(0,ye.jsxs)("div",{className:Se.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":i,onMouseDown:n=>n.preventDefault(),children:[(0,ye.jsx)("span",{className:Se.value,"data-aia-time-value":"","aria-live":"polite",children:(0,le.formatTime)(e.minutes)}),(0,ye.jsxs)("div",{className:Se.columns,"aria-hidden":"true",children:[(0,ye.jsx)("div",{className:Se.band}),le.TIME_WHEEL_COLUMNS.map(n=>(0,ye.jsxs)(Te.Fragment,{children:[n==="minute"&&(0,ye.jsx)("span",{className:Se.separator,children:":"}),(0,ye.jsx)(Ka,{column:n,minutes:e.minutes,interactive:a,onTimeChange:o})]},n))]}),(0,ye.jsx)("button",{type:"button",tabIndex:-1,className:Se.done,"data-aia-time-done":"",onClick:()=>{a&&r()},children:t})]})}function Ka({column:e,minutes:i,interactive:t,onTimeChange:a}){let o=(0,Te.useRef)(null),r=(0,Te.useRef)(null),n=(0,Te.useRef)(null),l=(0,Te.useRef)({minutes:i,interactive:t,onTimeChange:a});l.current={minutes:i,interactive:t,onTimeChange:a};let f=(0,le.timeWheelIndex)(e,i);(0,Te.useLayoutEffect)(()=>{let m=o.current;if(!m||n.current)return;let c=f*le.TIME_WHEEL_ROW_HEIGHT;Math.abs(m.scrollTop-c)<1||(r.current=c,m.scrollTop=c)},[f]),(0,Te.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let x=()=>{n.current=null;let m=o.current,c=l.current;if(!m||!c.interactive)return;let p=(0,le.timeWheelIndexFromScroll)(e,m.scrollTop);p!==(0,le.timeWheelIndex)(e,c.minutes)&&c.onTimeChange((0,le.withTimeWheelIndex)(e,c.minutes,p))},y=()=>{let m=o.current;if(m){if(r.current!=null&&Math.abs(m.scrollTop-r.current)<1){r.current=null;return}r.current=null,n.current&&clearTimeout(n.current),n.current=setTimeout(x,Ga)}};return(0,ye.jsx)("div",{ref:o,className:Se.column,"data-aia-time-column":e,onScroll:y,children:(0,le.timeWheelRows)(e).map((m,c)=>(0,ye.jsx)("div",{className:c===f?`${Se.row} ${Se.selected}`:Se.row,"data-aia-time-row":"","data-aia-index":c,onClick:()=>{l.current.interactive&&a((0,le.withTimeWheelIndex)(e,l.current.minutes,c))},children:m.label},m.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2829
3102
|
display: flex;
|
|
2830
3103
|
flex-direction: column;
|
|
2831
3104
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2840,7 +3113,7 @@
|
|
|
2840
3113
|
align-items: end;
|
|
2841
3114
|
}
|
|
2842
3115
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2843
|
-
`,document.head.appendChild(e)}var
|
|
3116
|
+
`,document.head.appendChild(e)}var ra=require("react/jsx-runtime");function na({space:e,align:i="stretch",className:t,children:a,...o}){let r=e?{"--aia-stack-space":e}:void 0;return(0,ra.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":i,style:r,...o,children:a})}var q=require("react/jsx-runtime"),qa=[159,119,164],_a=()=>{},sa=()=>{},Va=e=>{},Ua=()=>{},Qa=e=>{},Ya=e=>{},ja=e=>{},$a=e=>{};function Za(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=(0,de.useState)(i);if((0,de.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(o.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Xa(e,i){let t=(0,de.useRef)(null);(0,de.useEffect)(()=>{let a=e.current,o=i.current;if(!a||!o)return;let r=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:(0,ge.attachScrollArrow)({dropdown:a,grid:r,button:o})};return}t.current?.controller.update()}),(0,de.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ja(e,i){let t=(0,de.useRef)(i);t.current=i;let a=(0,de.useRef)(null);(0,de.useEffect)(()=>{let o=e.current;if(o){if(!a.current){a.current=(0,ge.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}a.current.update()}}),(0,de.useEffect)(()=>()=>{a.current?.destroy(),a.current=null},[])}function St({suggestions:e,activeIndex:i,onSelect:t,onHighlight:a,onUnhighlight:o,isOpen:r,id:n,className:l,pills:f,onPillClick:x,showPills:y=!0,onSkip:m,showSkipButton:c=!0,showOptionIcons:p=!0,showOptionImages:v=!0,showOptionCounts:O=!0,skipDisabled:G=!1,activeSelected:N=!1,isLoading:V=!1,skeletonExiting:Z=!1,isInputEmpty:D=!1,language:E,products:S,onProductSelect:ee,onProductAddToCart:te,onProductFocusChange:U,productsLayout:K="row",productImageFallback:fe="image",formatType:I="options",dateView:X=null,selectedDateIso:h=null,selectedDateRange:A=null,dateRangeStart:He=null,onPreviousMonth:Je,onNextMonth:_e,timeView:b=null,multiSelectView:et=null,onMultiSelectCommit:Ve,onTimeChange:Ue,onTimeCommit:Qe,locationView:w=null,onLocationQuery:C,onLocationMove:T,onLocationCommit:L,onLocationFocusChange:z,isFocused:J=!1,optionsPosition:be="below",mode:we}){let Ie=Za(we),Ee=Ie!==void 0,ve=(0,de.useRef)(null),tt=(0,de.useRef)(null);Xa(ve,tt),(0,de.useEffect)(()=>{if(ve.current)return(0,ge.containScroll)(ve.current)},[]);let ct=e[0]?.options??[],Be=!!(f&&f.length>0&&x),at=!!(S&&S.length>0),nt=I==="time"&&b!=null,We=I==="location"&&w!=null,pe=r&&(ct.length>0||y&&Be||V||at||nt||We);Ja(ve,pe);let Ae={suggestions:e,activeIndex:i,pills:f,showPills:y,showSkipButton:c,showOptionIcons:p,showOptionImages:v,showOptionCounts:O,skipDisabled:G,activeSelected:N,isLoading:V,skeletonExiting:Z,isInputEmpty:D,products:S,formatType:I,dateView:X,selectedDateIso:h,selectedDateRange:A,dateRangeStart:He,timeView:b,multiSelectView:et,locationView:w},k=(0,de.useRef)(Ae);pe&&(k.current=Ae);let u=pe?Ae:k.current,ae=(0,ge.uiStringsFor)(E),Le=u.suggestions[0],g=Le?.options??[],rt=u.activeIndex>=0&&!!g[u.activeIndex]?.is_tappable,Ge=(0,ge.labelTraditionalAutocomplete)(u.pills??[],ae.keepTyping),Re=!!(Ge.length>0&&x),pt=u.showPills&&Re,ht=u.showPills&&!Re&&u.isLoading,Ke=pt||ht,st=Re&&(0,ge.hasSkippablePill)(Ge)&&u.showSkipButton&&!u.isInputEmpty&&!!m,ke=Ge[0]?.text,Oe=(0,ge.isCalendarFormat)(u.formatType)&&u.dateView!=null,Ye=g.length>0&&!Oe,it=g.length>0&&Oe&&!u.isLoading,lt=u.formatType==="time"&&u.timeView!=null&&!u.isLoading,je=u.formatType==="location"&&u.locationView!=null&&!u.isLoading,dt=u.isLoading&&!Ye&&!it&&!lt&&!je,d=u.products??[];return(0,q.jsxs)("div",{ref:ve,id:n,role:"listbox","aria-multiselectable":!!u.multiSelectView,"data-aia-dropdown":"","data-options-position":be,"data-mode":Ie,"data-aia-loading":u.isLoading?"":void 0,"data-aia-skeleton-exiting":u.skeletonExiting?"":void 0,"data-aia-has-products":d.length>0?"":void 0,className:`${Ee?"magicx-aia ":""}${De.dropdown} ${pe?De.visible:""} ${l??""}`,onMouseDown:P=>P.preventDefault(),children:[(0,q.jsxs)(na,{space:"8px",children:[(Ke||st)&&(0,q.jsxs)(gt,{noWrap:!0,className:De.pillBar,"data-aia-pillbar":"",children:[Ke&&(0,q.jsx)("span",{className:De.pillScroll,"data-aia-pill-scroll":"",children:(0,q.jsx)(kt,{pills:Ge,activePillIndex:0,activeSelected:u.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:u.isLoading})}),st&&(0,q.jsx)("button",{type:"button",tabIndex:-1,className:De.skip,"data-aia-skip":"",disabled:u.isLoading||u.skipDisabled,"aria-label":ke?`${ae.skipLabel} ${ke}`:ae.skipLabel,onClick:m,children:ae.skip})]}),Ye&&(0,q.jsx)(ia,{options:g,activeIndex:u.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:n,loading:u.isLoading,groupKey:Le?`${Le.parameter} ${Le.text}`:"",optionsPosition:be,showIcons:u.showOptionIcons,showImages:u.showOptionImages,showCounts:u.showOptionCounts,picked:u.isLoading?void 0:u.multiSelectView?.picked}),u.multiSelectView&&!u.isLoading&&(0,q.jsx)("div",{onClick:P=>{P.target.closest("[data-aia-multi-done]")&&!u.skipDisabled&&Ve?.()},children:(0,q.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:De.multiDone,ref:P=>{P&&(P.disabled=!0,P.offsetHeight,P.disabled=u.skipDisabled)},children:ae.done})}),it&&u.dateView&&(0,q.jsx)(_t,{options:g,activeIndex:u.activeIndex,listboxId:n,view:u.dateView,selection:{selectedIso:u.selectedDateIso??null,selectedRange:u.selectedDateRange??null,rangeStart:u.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:o,onPreviousMonth:Je??sa,onNextMonth:_e??sa}),lt&&u.timeView&&(0,q.jsx)(oa,{view:u.timeView,label:ae.timeLabel,doneLabel:ae.done,interactive:!u.skipDisabled,onTimeChange:Ue??Va,onTimeCommit:Qe??Ua}),je&&u.locationView&&(0,q.jsx)(Yt,{view:u.locationView,searchLabel:ae.locationSearch,noResultsLabel:ae.locationNoResults,useTypedLabel:ae.locationUseTyped,widgetFocused:J&&pe,visible:pe,interactive:!u.skipDisabled,onQuery:C??Qa,onMove:T??Ya,onCommit:L??ja,onFocusChange:z??$a}),dt&&(0,q.jsx)("div",{className:De.skeletonBars,"data-aia-skeleton-bars":"",children:qa.map(P=>(0,q.jsx)("span",{className:De.skeletonBar,style:{width:P}},`bar-${P}`))}),(0,q.jsx)(Xt,{products:d,listboxId:n,onSelect:ee??_a,onAddToCart:te,onFocusChange:U,focusable:pe,layout:K,imageFallback:fe,strings:ae}),(0,q.jsx)(Vt,{isOptionHighlighted:rt,isInputEmpty:u.isInputEmpty,strings:ae})]}),(0,q.jsx)("button",{ref:tt,type:"button",tabIndex:-1,className:De.scrollArrow,"data-aia-scroll-arrow":"","aria-label":ae.scrollArrow,"aria-hidden":"true",children:(0,q.jsx)("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,q.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Fe=require("@magicx-eng/ai-autocomplete-vanilla");var da=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
|
|
2844
3117
|
flex-shrink: 0;
|
|
2845
3118
|
width: 32px;
|
|
2846
3119
|
height: 32px;
|
|
@@ -2853,7 +3126,10 @@
|
|
|
2853
3126
|
align-items: center;
|
|
2854
3127
|
justify-content: center;
|
|
2855
3128
|
padding: 0;
|
|
2856
|
-
transition:
|
|
3129
|
+
transition:
|
|
3130
|
+
opacity 0.2s ease,
|
|
3131
|
+
background-color 250ms ease,
|
|
3132
|
+
transform 250ms ease;
|
|
2857
3133
|
}
|
|
2858
3134
|
|
|
2859
3135
|
/* Size and paint by class as well as by attribute: a presentation attribute
|
|
@@ -2893,5 +3169,20 @@
|
|
|
2893
3169
|
);
|
|
2894
3170
|
cursor: default;
|
|
2895
3171
|
}
|
|
2896
|
-
`,document.head.appendChild(e)}var Xt={submitButton:"aia-submitButton-otz7H"};var vt=require("react/jsx-runtime");function ea({disabled:e,onClick:i,label:t=(0,Jt.uiStringsFor)().submit}){return(0,vt.jsx)("button",{type:"button","data-aia-submit":"",className:Xt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":t,children:(0,vt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,vt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ve=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react");var Rt=require("react");function ta(e){let i=(0,Rt.useRef)(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=(0,Rt.useRef)({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(l,u,w)=>{let y=i.current?.[r];return y?y(l,u,w):[]};o[r]=n}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}var Ot=require("react");function aa(e){let i=(0,Ot.useRef)(e);i.current=e;let t=(0,Ot.useRef)(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=i.current;return n?n.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ia={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,timeView:null,multiSelectView:null,multiSelectDraft:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function xt({onSubmit:e,onResult:i,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:n,language:l,currency:u,productId:w,visitorId:y,columns:g=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:v,showNonTappableOptions:R,showOptionIcons:ie,showOptionImages:q,showOptionCounts:Q,showSkipButton:te,showProducts:A,productImageFallback:M="image",onFocus:S,onBlur:oe,value:U,completedParams:V,onChange:ce,onParamsChange:ge,products:O,mapProducts:fe,onProductSelect:Le,onProductAddToCart:Ee,source:je,setCursor:Me}){let f=(0,P.useRef)(null),[ze,Ne]=(0,P.useState)(null),He=(0,P.useRef)(e);He.current=e;let Fe=(0,P.useRef)(i);Fe.current=i;let Be=(0,P.useRef)(t);Be.current=t;let m=(0,P.useRef)(ce);m.current=ce;let k=(0,P.useRef)(ge);k.current=ge;let C=(0,P.useRef)(S);C.current=S;let I=(0,P.useRef)(oe);I.current=oe;let T=(0,P.useRef)(Me);T.current=Me;let B=(0,P.useRef)(Le);B.current=Le;let pe=(0,P.useRef)(Ee);pe.current=Ee;let ae=(0,P.useRef)(y);ae.current=y;let We=(0,P.useRef)(()=>{let p=ae.current;return typeof p=="function"?p():p}).current,Qe=aa(O),Ce=(0,P.useRef)(fe);Ce.current=fe;let Ae=(0,P.useRef)((p,_)=>{let L=Ce.current;return L?L(p,_):p}).current,Ge=fe?Ae:void 0,h=ta(a);(0,P.useEffect)(()=>{if(typeof document>"u")return;let p=new Ve.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:l,currency:u,productId:w,visitorId:We,optionOverrides:h.overrides,maskCompletedText:o,columns:g,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:v,showNonTappableOptions:R,showProducts:A,source:je,value:U,completedParams:V,onSubmit:(...L)=>He.current?.(...L),onResult:(...L)=>Fe.current?.(...L),onError:(...L)=>Be.current?.(...L),onChange:(...L)=>m.current?.(...L),onParamsChange:(...L)=>k.current?.(...L),onFocus:()=>C.current?.(),onBlur:()=>I.current?.(),onProductSelect:L=>B.current?.(L),onProductAddToCart:L=>pe.current?.(L),setCursor:L=>T.current?.(L),products:Qe.config,mapProducts:Ge});f.current=p,Ne(p.getState());let _=p.subscribe(L=>Ne(L));return()=>{_(),p.destroy(),f.current===p&&(f.current=null)}},[]),(0,P.useEffect)(()=>{U!==void 0&&f.current?.setValue(U)},[U]),(0,P.useEffect)(()=>{V!==void 0&&f.current?.setCompletedParams(V)},[V]);let $=JSON.stringify(r??null),he;try{he=JSON.stringify(n??null)}catch{he="[unstringifiable]"}(0,P.useEffect)(()=>{f.current?.update({apiConfig:r,additionalContext:n,language:l,currency:u,productId:w,optionOverrides:h.overrides,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:v,showNonTappableOptions:R,showProducts:A})},[$,he,l,u?.code,u?.rate,u?.country,w,h.key,d,c,v,R,A]);let be=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(!be.current){be.current=!0;return}f.current?.update({products:Qe.config})},[Qe.enabled]),(0,P.useEffect)(()=>{f.current?.update({mapProducts:Ge})},[Ge]);let $e=(0,P.useRef)(null);$e.current===null&&($e.current={handleTextChange:p=>f.current?.handleTextChange(p),handleKeyDown:p=>{let _="nativeEvent"in p?p.nativeEvent:p;f.current?.handleKeyDown(_)},setFocused:p=>f.current?.setFocused(p),startEditingParam:p=>f.current?.startEditingParam(p),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:p=>f.current?.handleCaretAfterInput(p),handleCaretMove:p=>f.current?.handleCaretMove(p),replaceEditingRange:p=>f.current?.replaceEditingRange(p)??!1,setActivePill:p=>f.current?.setActivePill(p),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??ia,recordSubmit:p=>f.current?.recordSubmit(p),selectOption:p=>f.current?.selectOption(p),selectProduct:p=>f.current?.selectProduct(p),addProductToCart:p=>{let _=f.current;return!_||!pe.current?Promise.resolve():_.addProductToCart(p)},setActiveDropdownIndex:p=>f.current?.setActiveDropdownIndex(p),clearHighlight:p=>f.current?.clearHighlight(p),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:p=>f.current?.setTime(p),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:p=>f.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>f.current?.commitMultiSelect(),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let x=$e.current,Ze=(0,P.useCallback)(p=>{let _=p.target.value,pt=_.length>0&&!p.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;f.current?.handleTextChange(pt)},[]),it=(0,P.useCallback)(p=>{f.current?.handleKeyDown(p.nativeEvent)},[]),Re=f.current,b=ze??ia,Ke=U!==void 0?U:b.text,et=V!==void 0?V:b.completedParams,_e=b.actionableSuggestions,tt=_e[0],at=(0,Ve.withoutTraditionalAutocomplete)(_e),Oe=Re?.listboxId??"",ot=b.activeDropdownIndex>=0&&Re?`${Oe}-option-${b.activeDropdownIndex}`:void 0,we=b.editingParam,W=b.editingIdentified,nt=we?{parameter:we.suggestionParameter,text:we.suggestionPlaceholder,required:!0,options:we.options}:W?{parameter:W.parameter,text:(0,Ve.identifiedParamLabel)(W.parameter),required:!0,options:[]}:null,ct=b.dropdownSuggestion??nt??tt,kt=nt?[nt]:_e,rt=(0,Ve.dateSelectionFor)(b),Xe=!Re||b.dropdownLoading;return{completedParams:et,multiSelectView:b.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:at,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:x.clearNewParamId,suggestions:b.suggestions,activeIndex:b.activeDropdownIndex,isReady:b.isReady,isLoading:Xe,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:Oe,error:b.error,products:b.products,customFields:b.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:we,editingIdentified:W,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ke,placeholder:b.placeholderText||void 0,onChange:Ze,onKeyDown:it,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":ot,"aria-autocomplete":"list","aria-controls":Oe},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:ct?[{...ct,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:b.isDropdownOpen,id:Oe,pills:kt,activeSelected:b.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(te??!0)&&!we&&!W,showOptionIcons:ie??!0,showOptionImages:q??!0,showOptionCounts:Q??!0,skipDisabled:b.inSelectionAnimation,isLoading:Xe,skeletonExiting:b.skeletonExiting,isInputEmpty:Ke.trim().length===0,language:l,products:b.products,productImageFallback:M,onProductSelect:x.selectProduct,onProductAddToCart:Ee?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:rt.selectedIso,selectedDateRange:rt.selectedRange,dateRangeStart:rt.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:b.timeView,multiSelectView:b.multiSelectView,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,optionsPosition:c??"below"}}}var j=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react"),yt;function Na(){if(yt!==void 0)return yt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),yt=e.contentEditable==="plaintext-only",yt}function oa(e){let{segments:i,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:l,caretOffset:u,placeholderText:w,isFocused:y,isDropdownOpen:g,listboxId:d,activeDescendantId:c,autoFocus:v,handleTextChange:R,handleKeyDown:ie,handleCaretAfterInput:q,handleCaretMove:Q,startEditingParam:te,replaceEditingRange:A,setFocused:M}=e,S=(0,E.useRef)(null),oe=(0,E.useRef)(!1),U=(0,E.useRef)(""),V=(0,E.useRef)(""),ce=(0,E.useRef)(null),ge=(0,E.useRef)(0);ce.current=u,(0,E.useEffect)(()=>{if(!v)return;let m=S.current;if(!m)return;document.activeElement===m?M(!0):m.focus();let k=m.ownerDocument??document,C=k.getSelection(),I=C&&C.rangeCount>0&&m.contains(C.anchorNode);if(C&&!I){let T=k.createRange();T.selectNodeContents(m),T.collapse(!0),C.removeAllRanges(),C.addRange(T)}},[v,M]),(0,E.useEffect)(()=>{let m=S.current;if(!m)return;let k=m.ownerDocument??document,C=()=>{let I=k.getSelection();if(!I||I.rangeCount===0||!I.anchorNode||!m.contains(I.anchorNode))return;let T=I.anchorNode,B=T.nodeType===Node.ELEMENT_NODE?T:T.parentElement,ae=(I.isCollapsed?B?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,We=r?.id??n?.id??null;if(ae&&ae!==We){te(ae);return}performance.now()-ge.current<50||Q((0,j.getCursorOffset)(m))};return k.addEventListener("selectionchange",C),()=>k.removeEventListener("selectionchange",C)},[r,n,te,Q]),(0,E.useEffect)(()=>{let m=S.current;if(!m)return;let k=C=>{let I=(0,j.chipIdFromTap)(m,C.target);I&&(te(I),(0,j.keepCaretOnChip)(m,I))};return m.addEventListener("click",k),()=>m.removeEventListener("click",k)},[te]),(0,E.useLayoutEffect)(()=>{let m=S.current;m&&(0,j.renderEditableContent)({input:m,segments:i,newParamId:o,editingParamId:r?.id??null,placeholderText:w??"",isFocused:y,showChipIcons:t,showChipImages:a})},[i,o,r,w,y,t,a]),(0,E.useLayoutEffect)(()=>{let m=U.current,k=o??"";if(U.current=k,!k||k===m)return;let C=S.current;if(!C)return;C.focus();let I=ce.current??(0,j.plainTextLength)(C);(0,j.setCursorOffset)(C,I)},[o]),(0,E.useLayoutEffect)(()=>{let m=V.current,k=r?.id??"";if(V.current=k,!k||k===m||l==null)return;let C=S.current;C&&(0,j.setCursorOffset)(C,l)},[r,l]);let O=(0,E.useCallback)(()=>{if(oe.current)return;let m=S.current;if(!m)return;let k=(0,j.extractPlainText)(m),I=k.length>0&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;R(I)},[R]),fe=(0,E.useCallback)(()=>{ge.current=performance.now(),O();let m=S.current;m&&q((0,j.getCursorOffset)(m))},[O,q]);(0,E.useEffect)(()=>{let m=S.current;if(!m)return;let k=C=>{let I=C,T=I.inputType;if(T==="insertParagraph"||T==="insertLineBreak"||T==="insertFromDrop"){C.preventDefault();return}if(T.startsWith("insert")||T.startsWith("delete")){let B=T.startsWith("delete")?"":I.data??"";A(B)&&C.preventDefault()}};return m.addEventListener("beforeinput",k),()=>m.removeEventListener("beforeinput",k)},[A]);let Le=(0,E.useCallback)(()=>{oe.current=!0,S.current?.setAttribute("data-aia-composing","true")},[]),Ee=(0,E.useCallback)(()=>{oe.current=!1,S.current?.removeAttribute("data-aia-composing"),O()},[O]),je=(0,E.useCallback)(m=>{m.preventDefault();let k=S.current;if(!k)return;let C=(m.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!C)return;let I=k.ownerDocument??document,T=I.getSelection();if(!T||T.rangeCount===0)return;let B=T.getRangeAt(0);if(!k.contains(B.startContainer))return;B.deleteContents();let pe=I.createTextNode(C);B.insertNode(pe),B.setStartAfter(pe),B.collapse(!0),T.removeAllRanges(),T.addRange(B),O()},[O]),Me=(0,E.useCallback)(m=>ie(m),[ie]),f=(0,E.useCallback)(()=>M(!0),[M]),ze=(0,E.useCallback)(()=>M(!1),[M]),Ne=(0,E.useCallback)(()=>S.current?.focus(),[]),He=(0,E.useCallback)(()=>S.current?.blur(),[]),Fe=(0,E.useCallback)(()=>{let m=S.current;return m?(0,j.extractPlainText)(m):""},[]),Be=Na()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:Be,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":d,"aria-expanded":g,"aria-activedescendant":c,spellCheck:!0,enterKeyHint:"send",onInput:fe,onKeyDown:Me,onCompositionStart:Le,onCompositionEnd:Ee,onPaste:je,onFocus:f,onBlur:ze},getPlainText:Fe,focus:Ne,blur:He}}var ke=require("react/jsx-runtime");function Ha(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var na=(0,K.forwardRef)(function({onSubmit:i,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:l,additionalContext:u,language:w,currency:y,productId:g,visitorId:d,columns:c,pillPlacement:v="dropdown",mode:R="auto",optionsPosition:ie="below",animations:q=!0,dropdownTrigger:Q,closeDropdownOnBlur:te,showNonTappableOptions:A,showOptionIcons:M=!0,showChipIcons:S=!0,showChipImages:oe=!0,showOptionImages:U=!0,showOptionCounts:V=!0,showSkipButton:ce,showProducts:ge,productsLayout:O,productImageFallback:fe,autoFocus:Le=!0,onFocus:Ee,onBlur:je,value:Me,completedParams:f,onChange:ze,onParamsChange:Ne,products:He,mapProducts:Fe,onProductSelect:Be,onProductAddToCart:m,submitButton:k,resetOnSubmit:C=!0},I){let T=(0,K.useRef)(null),B=(0,K.useRef)(null),pe=(0,K.useRef)(()=>{}),ae=(0,K.useRef)(null),We=(0,K.useRef)(null);(0,K.useEffect)(()=>{let z=T.current;if(z)return ae.current?ae.current.setMode(R):ae.current=new Ye.ModeController(z,R),()=>{ae.current?.destroy(),ae.current=null}},[R]);let Qe=(0,K.useCallback)(z=>{let ne=We.current?.current;ne&&(ne.focus(),(0,Ye.setCursorOffset)(ne,z))},[]),{completedParams:Ce,suggestionPills:Ae,setActivePill:Ge,skipActivePill:h,segments:$,newParamId:he,clearNewParamId:be,placeholderText:$e,isFocused:x,isDropdownOpen:Ze,isActivePillSelected:it,isLoading:Re,activeIndex:b,listboxId:Ke,handleTextChange:et,handleKeyDown:_e,setFocused:tt,editingParam:at,editingIdentified:Oe,editingAnchor:ot,caretOffset:we,startEditingParam:W,handleCaretAfterInput:nt,handleCaretMove:ct,replaceEditingRange:kt,dropdownProps:rt,reset:Xe,refreshProducts:p,prepareSubmit:_,getState:L,recordSubmit:pt}=xt({onSubmit:z=>pe.current(z),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:l,additionalContext:u,language:w,currency:y,productId:g,visitorId:d,columns:c,dropdownTrigger:Q,optionsPosition:ie,closeDropdownOnBlur:te,showNonTappableOptions:A,showOptionIcons:M,showOptionImages:U,showOptionCounts:V,showSkipButton:ce,showProducts:ge,onFocus:Ee,onBlur:je,value:Me,completedParams:f,onChange:ze,onParamsChange:Ne,products:He,mapProducts:Fe,onProductSelect:Be,onProductAddToCart:m,source:"full-sdk",setCursor:Qe});(0,K.useEffect)(()=>{if(!he)return;let z=window.setTimeout(()=>be(),650);return()=>window.clearTimeout(z)},[he,be]);let ra=b>=0?`${Ke}-option-${b}`:void 0,{inputRef:Ct,editorProps:sa,focus:ht,blur:Dt,getPlainText:Lt}=oa({segments:$,newParamId:he,editingParam:at,editingIdentified:Oe,editingAnchor:ot,caretOffset:we,placeholderText:$e,isFocused:x,showChipIcons:S,showChipImages:oe,isDropdownOpen:Ze,listboxId:Ke,activeDescendantId:ra,autoFocus:Le,handleTextChange:et,handleKeyDown:_e,handleCaretAfterInput:nt,handleCaretMove:ct,startEditingParam:W,replaceEditingRange:kt,setFocused:tt});We.current=Ct,(0,K.useLayoutEffect)(()=>{let z=B.current,ne=Ct.current;if(!z||!ne)return;let st=()=>{let zt=z.firstElementChild;if(!zt)return;let pa=zt.getBoundingClientRect(),ha=ne.getBoundingClientRect();pa.top>=ha.bottom-2?z.setAttribute("data-aia-pill-wrapped",""):z.removeAttribute("data-aia-pill-wrapped")};st();let Mt=new ResizeObserver(st);return Mt.observe(ne),()=>Mt.disconnect()},[$,Ae.length,Re,Ct]),(0,K.useImperativeHandle)(I,()=>({focus:ht,blur:Dt,reset:Xe,refreshProducts:p,setMode:z=>ae.current?.setMode(z),skipActivePill:h}),[ht,Dt,Xe,p,h]);let ut=!!$.length||Ce.length>0,St=(0,K.useCallback)(z=>{if(!ut)return;z&&_();let ne=L(),st=(0,Ye.buildSubmitResult)(Lt(),ne.completedParams,ne.skippedParams,{identifiedParams:ne.identifiedParams,isReady:ne.isReady,customFields:ne.customFields});z&&pt(st),i(st),C&&Xe()},[pt,C,ut,_,L,i,Xe,Lt]);pe.current=()=>St(!1);let la=(0,K.useCallback)(z=>{z.target?.closest("[data-aia-pill]")||ht()},[ht]),da=v==="inline",ca=v==="dropdown";return(0,ke.jsxs)("div",{ref:T,className:`magicx-aia ${Je.container} ${n??""}`,"data-pill-placement":v,"data-options-position":ie,"data-animations":q?"on":"off","data-mode":Ha(R),children:[(0,ke.jsx)(wt,{...rt,showPills:ca,productsLayout:O,productImageFallback:fe}),(0,ke.jsxs)("div",{className:Je.inputWrapper,"data-aia-input-wrapper":"",onClick:la,children:[(0,ke.jsxs)("div",{className:Je.editorArea,"data-aia-editor":"",children:[(0,ke.jsx)("div",{...sa,className:Je.input,"data-aia-input":""}),da&&(Re||Ae.length>0)&&(0,ke.jsx)("span",{ref:B,className:Je.pillListContainer,"data-aia-pill-list-container":"",children:(0,ke.jsx)(ft,{pills:Ae,activePillIndex:0,activeSelected:it,onSelectPill:Ge,loading:Re})})]}),k===null?null:k===void 0?(0,ke.jsx)(ea,{disabled:!ut,onClick:()=>St(!0),label:(0,Ye.uiStringsFor)(w).submit}):(0,ke.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Je.submitSlot,onClick:z=>{ut&&(z.stopPropagation(),St(!0))},children:k})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
3172
|
+
|
|
3173
|
+
/* Ready: the request is complete, so the button lifts slightly and takes its
|
|
3174
|
+
ready color (--aia-submit-bg-ready, defaulting to the normal one). The state
|
|
3175
|
+
sits in :where() so a theme's own \`.x .magicx-aia-submit { background }\`
|
|
3176
|
+
still wins. */
|
|
3177
|
+
.aia-submitButton-otz7H:where([data-aia-ready]:not(:disabled)) {
|
|
3178
|
+
background: var(--aia-submit-bg-ready, var(--aia-submit-bg, var(--aia-color-text-default, #fff)));
|
|
3179
|
+
transform: scale(1.08);
|
|
3180
|
+
}
|
|
3181
|
+
|
|
3182
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3183
|
+
.aia-submitButton-otz7H {
|
|
3184
|
+
transition: none;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
`,document.head.appendChild(e)}var la={submitButton:"aia-submitButton-otz7H"};var Tt=require("react/jsx-runtime");function ca({disabled:e,ready:i,onClick:t,label:a=(0,da.uiStringsFor)().submit}){return(0,Tt.jsx)("button",{type:"button","data-aia-submit":"",className:la.submitButton,disabled:e,"data-aia-ready":i?"":void 0,onClick:o=>{o.stopPropagation(),t()},"aria-label":a,children:(0,Tt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":a,children:(0,Tt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Xe=require("@magicx-eng/ai-autocomplete-vanilla"),R=require("react");var zt=require("react");function pa(e){let i=(0,zt.useRef)(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=(0,zt.useRef)({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(l,f,x)=>{let y=i.current?.[r];return y?y(l,f,x):[]};o[r]=n}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}var Nt=require("react");function ha(e){let i=(0,Nt.useRef)(e);i.current=e;let t=(0,Nt.useRef)(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=i.current;return n?n.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ua={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,timeView:null,multiSelectView:null,multiSelectDraft:null,locationView:null,locationSearch:null,locationAutocomplete:!0,locationFieldFocused:!1,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function Pt({onSubmit:e,onResult:i,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:n,language:l,currency:f,productId:x,visitorId:y,columns:m=2,dropdownTrigger:c,optionsPosition:p,closeDropdownOnBlur:v,showNonTappableOptions:O,locationSearch:G,showOptionIcons:N,showOptionImages:V,showOptionCounts:Z,showSkipButton:D,showProducts:E,productImageFallback:S="image",onFocus:ee,onBlur:te,value:U,completedParams:K,onChange:fe,onParamsChange:I,products:X,mapProducts:h,onProductSelect:A,onProductAddToCart:He,source:Je,setCursor:_e}){let b=(0,R.useRef)(null),[et,Ve]=(0,R.useState)(null),Ue=(0,R.useRef)(e);Ue.current=e;let Qe=(0,R.useRef)(i);Qe.current=i;let w=(0,R.useRef)(t);w.current=t;let C=(0,R.useRef)(fe);C.current=fe;let T=(0,R.useRef)(I);T.current=I;let L=(0,R.useRef)(ee);L.current=ee;let z=(0,R.useRef)(te);z.current=te;let J=(0,R.useRef)(_e);J.current=_e;let be=(0,R.useRef)(A);be.current=A;let we=(0,R.useRef)(He);we.current=He;let Ie=(0,R.useRef)(y);Ie.current=y;let Ee=(0,R.useRef)(()=>{let d=Ie.current;return typeof d=="function"?d():d}).current,ve=ha(X),tt=(0,R.useRef)(h);tt.current=h;let ct=(0,R.useRef)((d,P)=>{let B=tt.current;return B?B(d,P):d}).current,Be=h?ct:void 0,at=pa(a);(0,R.useEffect)(()=>{if(typeof document>"u")return;let d=new Xe.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:l,currency:f,productId:x,visitorId:Ee,optionOverrides:at.overrides,maskCompletedText:o,columns:m,dropdownTrigger:c,optionsPosition:p,closeDropdownOnBlur:v,showNonTappableOptions:O,locationSearch:G,showProducts:E,source:Je,value:U,completedParams:K,onSubmit:(...B)=>Ue.current?.(...B),onResult:(...B)=>Qe.current?.(...B),onError:(...B)=>w.current?.(...B),onChange:(...B)=>C.current?.(...B),onParamsChange:(...B)=>T.current?.(...B),onFocus:()=>L.current?.(),onBlur:()=>z.current?.(),onProductSelect:B=>be.current?.(B),onProductAddToCart:B=>we.current?.(B),setCursor:B=>J.current?.(B),products:ve.config,mapProducts:Be});b.current=d,Ve(d.getState());let P=d.subscribe(B=>Ve(B));return()=>{P(),d.destroy(),b.current===d&&(b.current=null)}},[]),(0,R.useEffect)(()=>{U!==void 0&&b.current?.setValue(U)},[U]),(0,R.useEffect)(()=>{K!==void 0&&b.current?.setCompletedParams(K)},[K]);let nt=JSON.stringify(r??null),We;try{We=JSON.stringify(n??null)}catch{We="[unstringifiable]"}(0,R.useEffect)(()=>{b.current?.update({apiConfig:r,additionalContext:n,language:l,currency:f,productId:x,optionOverrides:at.overrides,dropdownTrigger:c,optionsPosition:p,closeDropdownOnBlur:v,showNonTappableOptions:O,locationSearch:G,showProducts:E})},[nt,We,l,f?.code,f?.rate,f?.country,x,at.key,c,p,v,O,G,E]);let pe=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(!pe.current){pe.current=!0;return}b.current?.update({products:ve.config})},[ve.enabled]),(0,R.useEffect)(()=>{b.current?.update({mapProducts:Be})},[Be]);let Ae=(0,R.useRef)(null);Ae.current===null&&(Ae.current={handleTextChange:d=>b.current?.handleTextChange(d),handleKeyDown:d=>{let P="nativeEvent"in d?d.nativeEvent:d;b.current?.handleKeyDown(P)},setFocused:d=>b.current?.setFocused(d),startEditingParam:d=>b.current?.startEditingParam(d),exitEditMode:()=>b.current?.exitEditMode(),handleCaretAfterInput:d=>b.current?.handleCaretAfterInput(d),handleCaretMove:d=>b.current?.handleCaretMove(d),replaceEditingRange:d=>b.current?.replaceEditingRange(d)??!1,setActivePill:d=>b.current?.setActivePill(d),skipActivePill:()=>b.current?.skipActivePill(),removeLastParam:()=>b.current?.removeLastParam(),clearNewParamId:()=>b.current?.clearNewParamId(),reset:()=>b.current?.reset(),refreshProducts:()=>b.current?.refreshProducts(),prepareSubmit:()=>b.current?.prepareSubmit(),getState:()=>b.current?.getState()??ua,recordSubmit:d=>b.current?.recordSubmit(d),selectOption:(d,P)=>b.current?.selectOption(d,P),selectProduct:d=>b.current?.selectProduct(d),addProductToCart:d=>{let P=b.current;return!P||!we.current?Promise.resolve():P.addProductToCart(d)},setActiveDropdownIndex:d=>b.current?.setActiveDropdownIndex(d),clearHighlight:d=>b.current?.clearHighlight(d),showPreviousMonth:()=>b.current?.showPreviousMonth(),showNextMonth:()=>b.current?.showNextMonth(),setTime:d=>b.current?.setTime(d),commitTime:()=>b.current?.commitTime(),toggleMultiSelectOption:d=>b.current?.toggleMultiSelectOption(d),commitMultiSelect:()=>b.current?.commitMultiSelect(),setLocationQuery:d=>b.current?.setLocationQuery(d),moveLocationHighlight:d=>b.current?.moveLocationHighlight(d),commitLocation:d=>b.current?.commitLocation(d),setLocationFieldFocused:d=>b.current?.setLocationFieldFocused(d),handleFocus:()=>b.current?.setFocused(!0),handleBlur:()=>b.current?.setFocused(!1)});let k=Ae.current,u=(0,R.useCallback)(d=>{let P=d.target.value,wt=P.length>0&&!d.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;b.current?.handleTextChange(wt)},[]),ae=(0,R.useCallback)(d=>{b.current?.handleKeyDown(d.nativeEvent)},[]),Le=b.current,g=et??ua,rt=U!==void 0?U:g.text,Ge=K!==void 0?K:g.completedParams,Re=g.actionableSuggestions,pt=Re[0],ht=(0,Xe.withoutTraditionalAutocomplete)(Re),Ke=Le?.listboxId??"",st=g.activeDropdownIndex>=0&&Le?`${Ke}-option-${g.activeDropdownIndex}`:void 0,ke=g.editingParam,Oe=g.editingIdentified,Ye=ke?{parameter:ke.suggestionParameter,text:ke.suggestionPlaceholder,required:!0,options:ke.options}:Oe?{parameter:Oe.parameter,text:(0,Xe.identifiedParamLabel)(Oe.parameter),required:!0,options:[]}:null,it=g.dropdownSuggestion??Ye??pt,lt=Ye?[Ye]:Re,je=(0,Xe.dateSelectionFor)(g),dt=!Le||g.dropdownLoading;return{completedParams:Ge,multiSelectView:g.multiSelectView,toggleMultiSelectOption:k.toggleMultiSelectOption,commitMultiSelect:k.commitMultiSelect,skippedParams:g.skippedParams,identifiedParams:g.identifiedParams,suggestionPills:ht,setActivePill:k.setActivePill,skipActivePill:k.skipActivePill,removeLastParam:k.removeLastParam,segments:g.segments,newParamId:g.newParamId,clearNewParamId:k.clearNewParamId,suggestions:g.suggestions,activeIndex:g.activeDropdownIndex,isReady:g.isReady,isLoading:dt,isFocused:g.isFocused,isDropdownOpen:g.isDropdownOpen,isActivePillSelected:g.isActivePillSelected,placeholderText:g.placeholderText,listboxId:Ke,error:g.error,products:g.products,customFields:g.customFields,selectProduct:k.selectProduct,addProductToCart:k.addProductToCart,handleTextChange:k.handleTextChange,handleKeyDown:k.handleKeyDown,setFocused:k.setFocused,editingParam:ke,editingIdentified:Oe,editingAnchor:g.editingAnchor,caretOffset:g.caretOffset,startEditingParam:k.startEditingParam,exitEditMode:k.exitEditMode,handleCaretAfterInput:k.handleCaretAfterInput,handleCaretMove:k.handleCaretMove,replaceEditingRange:k.replaceEditingRange,inputProps:{value:rt,placeholder:g.placeholderText||void 0,onChange:u,onKeyDown:ae,onFocus:k.handleFocus,onBlur:k.handleBlur,role:"combobox","aria-expanded":g.isDropdownOpen,"aria-activedescendant":st,"aria-autocomplete":"list","aria-controls":Ke},reset:k.reset,refreshProducts:k.refreshProducts,prepareSubmit:k.prepareSubmit,getState:k.getState,recordSubmit:k.recordSubmit,dropdownProps:{suggestions:it?[{...it,options:g.dropdownOptions}]:[],activeIndex:g.activeDropdownIndex,onSelect:k.selectOption,onHighlight:k.setActiveDropdownIndex,onUnhighlight:k.clearHighlight,isOpen:g.isDropdownOpen,id:Ke,pills:lt,activeSelected:g.isActivePillSelected,onPillClick:k.setActivePill,onSkip:k.skipActivePill,showSkipButton:(D??!0)&&!ke&&!Oe,showOptionIcons:N??!0,showOptionImages:V??!0,showOptionCounts:Z??!0,skipDisabled:g.inSelectionAnimation,isLoading:dt,skeletonExiting:g.skeletonExiting,isInputEmpty:rt.trim().length===0,language:l,products:g.products,productImageFallback:S,onProductSelect:k.selectProduct,onProductAddToCart:He?k.addProductToCart:void 0,onProductFocusChange:k.setFocused,formatType:g.activeFormatType,dateView:g.dateView,selectedDateIso:je.selectedIso,selectedDateRange:je.selectedRange,dateRangeStart:je.rangeStart,onPreviousMonth:k.showPreviousMonth,onNextMonth:k.showNextMonth,timeView:g.timeView,multiSelectView:g.multiSelectView,onMultiSelectCommit:k.commitMultiSelect,onTimeChange:k.setTime,onTimeCommit:k.commitTime,locationView:g.locationView,onLocationQuery:k.setLocationQuery,onLocationMove:k.moveLocationHighlight,onLocationCommit:k.commitLocation,onLocationFocusChange:k.setLocationFieldFocused,isFocused:g.isFocused||g.locationFieldFocused,optionsPosition:p??"below"}}}var re=require("@magicx-eng/ai-autocomplete-vanilla"),M=require("react"),It;function ei(){if(It!==void 0)return It;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),It=e.contentEditable==="plaintext-only",It}function ma(e){let{segments:i,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:l,caretOffset:f,placeholderText:x,isFocused:y,isDropdownOpen:m,listboxId:c,activeDescendantId:p,autoFocus:v,handleTextChange:O,handleKeyDown:G,handleCaretAfterInput:N,handleCaretMove:V,startEditingParam:Z,replaceEditingRange:D,setFocused:E}=e,S=(0,M.useRef)(null),ee=(0,M.useRef)(!1),te=(0,M.useRef)(""),U=(0,M.useRef)(""),K=(0,M.useRef)(null),fe=(0,M.useRef)(0);K.current=f,(0,M.useEffect)(()=>{if(!v)return;let w=S.current;if(!w)return;document.activeElement===w?E(!0):w.focus();let C=w.ownerDocument??document,T=C.getSelection(),L=T&&T.rangeCount>0&&w.contains(T.anchorNode);if(T&&!L){let z=C.createRange();z.selectNodeContents(w),z.collapse(!0),T.removeAllRanges(),T.addRange(z)}},[v,E]),(0,M.useEffect)(()=>{let w=S.current;if(!w)return;let C=w.ownerDocument??document,T=()=>{let L=C.getSelection();if(!L||L.rangeCount===0||!L.anchorNode||!w.contains(L.anchorNode))return;let z=L.anchorNode,J=z.nodeType===Node.ELEMENT_NODE?z:z.parentElement,we=(L.isCollapsed?J?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Ie=r?.id??n?.id??null;if(we&&we!==Ie){Z(we);return}performance.now()-fe.current<50||V((0,re.getCursorOffset)(w))};return C.addEventListener("selectionchange",T),()=>C.removeEventListener("selectionchange",T)},[r,n,Z,V]),(0,M.useEffect)(()=>{let w=S.current;if(!w)return;let C=T=>{let L=(0,re.chipIdFromTap)(w,T.target);L&&(Z(L),(0,re.keepCaretOnChip)(w,L))};return w.addEventListener("click",C),()=>w.removeEventListener("click",C)},[Z]),(0,M.useLayoutEffect)(()=>{let w=S.current;w&&(0,re.renderEditableContent)({input:w,segments:i,newParamId:o,editingParamId:r?.id??null,placeholderText:x??"",isFocused:y,showChipIcons:t,showChipImages:a})},[i,o,r,x,y,t,a]),(0,M.useLayoutEffect)(()=>{let w=te.current,C=o??"";if(te.current=C,!C||C===w)return;let T=S.current;if(!T)return;T.focus();let L=K.current??(0,re.plainTextLength)(T);(0,re.setCursorOffset)(T,L)},[o]),(0,M.useLayoutEffect)(()=>{let w=U.current,C=r?.id??"";if(U.current=C,!C||C===w||l==null)return;let T=S.current;T&&(0,re.setCursorOffset)(T,l)},[r,l]);let I=(0,M.useCallback)(()=>{if(ee.current)return;let w=S.current;if(!w)return;let C=(0,re.extractPlainText)(w),L=C.length>0&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;O(L)},[O]),X=(0,M.useCallback)(()=>{fe.current=performance.now(),I();let w=S.current;w&&N((0,re.getCursorOffset)(w))},[I,N]);(0,M.useEffect)(()=>{let w=S.current;if(!w)return;let C=T=>{let L=T,z=L.inputType;if(z==="insertParagraph"||z==="insertLineBreak"||z==="insertFromDrop"){T.preventDefault();return}if(z.startsWith("insert")||z.startsWith("delete")){let J=z.startsWith("delete")?"":L.data??"";D(J)&&T.preventDefault()}};return w.addEventListener("beforeinput",C),()=>w.removeEventListener("beforeinput",C)},[D]);let h=(0,M.useCallback)(()=>{ee.current=!0,S.current?.setAttribute("data-aia-composing","true")},[]),A=(0,M.useCallback)(()=>{ee.current=!1,S.current?.removeAttribute("data-aia-composing"),I()},[I]),He=(0,M.useCallback)(w=>{w.preventDefault();let C=S.current;if(!C)return;let T=(w.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!T)return;let L=C.ownerDocument??document,z=L.getSelection();if(!z||z.rangeCount===0)return;let J=z.getRangeAt(0);if(!C.contains(J.startContainer))return;J.deleteContents();let be=L.createTextNode(T);J.insertNode(be),J.setStartAfter(be),J.collapse(!0),z.removeAllRanges(),z.addRange(J),I()},[I]),Je=(0,M.useCallback)(w=>G(w),[G]),_e=(0,M.useCallback)(()=>E(!0),[E]),b=(0,M.useCallback)(()=>E(!1),[E]),et=(0,M.useCallback)(()=>S.current?.focus(),[]),Ve=(0,M.useCallback)(()=>S.current?.blur(),[]),Ue=(0,M.useCallback)(()=>{let w=S.current;return w?(0,re.extractPlainText)(w):""},[]),Qe=ei()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:Qe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":c,"aria-expanded":m,"aria-activedescendant":p,spellCheck:!0,enterKeyHint:"send",onInput:X,onKeyDown:Je,onCompositionStart:h,onCompositionEnd:A,onPaste:He,onFocus:_e,onBlur:b},getPlainText:Ue,focus:et,blur:Ve}}var Pe=require("react/jsx-runtime");function ti(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ga=(0,_.forwardRef)(function({onSubmit:i,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:l,additionalContext:f,language:x,currency:y,productId:m,visitorId:c,columns:p,pillPlacement:v="dropdown",mode:O="auto",optionsPosition:G="below",animations:N=!0,dropdownTrigger:V,closeDropdownOnBlur:Z,showNonTappableOptions:D,locationSearch:E,showOptionIcons:S=!0,showChipIcons:ee=!0,showChipImages:te=!0,showOptionImages:U=!0,showOptionCounts:K=!0,showSkipButton:fe,showProducts:I,productsLayout:X,productImageFallback:h,autoFocus:A=!0,onFocus:He,onBlur:Je,value:_e,completedParams:b,onChange:et,onParamsChange:Ve,products:Ue,mapProducts:Qe,onProductSelect:w,onProductAddToCart:C,submitButton:T,resetOnSubmit:L=!0},z){let J=(0,_.useRef)(null),be=(0,_.useRef)(null),we=(0,_.useRef)(null),Ie=(0,_.useRef)(()=>{}),Ee=(0,_.useRef)(null),ve=(0,_.useRef)(null);(0,_.useEffect)(()=>{let F=J.current;if(F)return Ee.current?Ee.current.setMode(O):Ee.current=new Fe.ModeController(F,O),()=>{Ee.current?.destroy(),Ee.current=null}},[O]);let tt=(0,_.useCallback)(F=>{let he=ve.current?.current;he&&(he.focus(),(0,Fe.setCursorOffset)(he,F))},[]),{completedParams:ct,suggestionPills:Be,setActivePill:at,skipActivePill:nt,segments:We,newParamId:pe,clearNewParamId:Ae,placeholderText:k,isFocused:u,isDropdownOpen:ae,isActivePillSelected:Le,isLoading:g,isReady:rt,activeIndex:Ge,listboxId:Re,handleTextChange:pt,handleKeyDown:ht,setFocused:Ke,editingParam:st,editingIdentified:ke,editingAnchor:Oe,caretOffset:Ye,startEditingParam:it,handleCaretAfterInput:lt,handleCaretMove:je,replaceEditingRange:dt,dropdownProps:d,reset:P,refreshProducts:B,prepareSubmit:wt,getState:Ft,recordSubmit:Ht}=Pt({onSubmit:F=>Ie.current(F),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:l,additionalContext:f,language:x,currency:y,productId:m,visitorId:c,columns:p,dropdownTrigger:V,optionsPosition:G,closeDropdownOnBlur:Z,showNonTappableOptions:D,locationSearch:E,showOptionIcons:S,showOptionImages:U,showOptionCounts:K,showSkipButton:fe,showProducts:I,onFocus:He,onBlur:Je,value:_e,completedParams:b,onChange:et,onParamsChange:Ve,products:Ue,mapProducts:Qe,onProductSelect:w,onProductAddToCart:C,source:"full-sdk",setCursor:tt});(0,_.useEffect)(()=>{if(!pe)return;let F=window.setTimeout(()=>Ae(),650);return()=>window.clearTimeout(F)},[pe,Ae]);let fa=Ge>=0?`${Re}-option-${Ge}`:void 0,{inputRef:Et,editorProps:ba,focus:vt,blur:Bt,getPlainText:Wt}=ma({segments:We,newParamId:pe,editingParam:st,editingIdentified:ke,editingAnchor:Oe,caretOffset:Ye,placeholderText:k,isFocused:u,showChipIcons:ee,showChipImages:te,isDropdownOpen:ae,listboxId:Re,activeDescendantId:fa,autoFocus:A,handleTextChange:pt,handleKeyDown:ht,handleCaretAfterInput:lt,handleCaretMove:je,startEditingParam:it,replaceEditingRange:dt,setFocused:Ke});ve.current=Et,(0,_.useLayoutEffect)(()=>{let F=be.current,he=Et.current;if(!F||!he)return;let mt=()=>{let Kt=F.firstElementChild;if(!Kt)return;let ya=Kt.getBoundingClientRect(),ka=he.getBoundingClientRect();ya.top>=ka.bottom-2?F.setAttribute("data-aia-pill-wrapped",""):F.removeAttribute("data-aia-pill-wrapped")};mt();let Gt=new ResizeObserver(mt);return Gt.observe(he),()=>Gt.disconnect()},[We,Be.length,g,Et]),(0,_.useEffect)(()=>{let F=we.current;if(F)return(0,Fe.watchEditorHeight)(F)},[]),(0,_.useImperativeHandle)(z,()=>({focus:vt,blur:Bt,reset:P,refreshProducts:B,setMode:F=>Ee.current?.setMode(F),skipActivePill:nt}),[vt,Bt,P,B,nt]);let ut=!!We.length||ct.length>0,At=(0,_.useCallback)(F=>{if(!ut)return;F&&wt();let he=Ft(),mt=(0,Fe.buildSubmitResult)(Wt(),he.completedParams,he.skippedParams,{identifiedParams:he.identifiedParams,isReady:he.isReady,customFields:he.customFields});F&&Ht(mt),i(mt),L&&P()},[Ht,L,ut,wt,Ft,i,P,Wt]);Ie.current=()=>At(!1);let wa=(0,_.useCallback)(F=>{F.target?.closest("[data-aia-pill]")||document.activeElement?.closest("[data-aia-location]")||vt()},[vt]),va=v==="inline",xa=v==="dropdown";return(0,Pe.jsxs)("div",{ref:J,className:`magicx-aia ${ot.container} ${n??""}`,"data-pill-placement":v,"data-options-position":G,"data-animations":N?"on":"off","data-mode":ti(O),children:[(0,Pe.jsx)(St,{...d,showPills:xa,productsLayout:X,productImageFallback:h}),(0,Pe.jsxs)("div",{className:ot.inputWrapper,"data-aia-input-wrapper":"",onClick:wa,children:[(0,Pe.jsxs)("div",{ref:we,className:ot.editorArea,"data-aia-editor":"",children:[(0,Pe.jsx)("div",{...ba,className:ot.input,"data-aia-input":""}),va&&(g||Be.length>0)&&(0,Pe.jsx)("span",{ref:be,className:ot.pillListContainer,"data-aia-pill-list-container":"",children:(0,Pe.jsx)(kt,{pills:Be,activePillIndex:0,activeSelected:Le,onSelectPill:at,loading:g})})]}),T===null?null:T===void 0?(0,Pe.jsx)(ca,{disabled:!ut,ready:ut&&rt,onClick:()=>At(!0),label:(0,Fe.uiStringsFor)(x).submit}):(0,Pe.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ot.submitSlot,onClick:F=>{ut&&(F.stopPropagation(),At(!0))},children:T})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,LOCATION_META_KEY,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatPlace,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2897
3188
|
//# sourceMappingURL=index.js.map
|