@magicx-eng/ai-autocomplete-react 0.48.0 → 0.48.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -212,7 +212,7 @@ function App() {
|
|
|
212
212
|
|
|
213
213
|
Skip `<AIAutocompleteDropdown />` and render the suggestions UI yourself. `dropdownProps` carries the data + actions — the active suggestion's options, the highlighted index, `isOpen`, and `onSelect` / `onHighlight`:
|
|
214
214
|
|
|
215
|
-
> **Datepicker in a custom UI.** For a date parameter, `dropdownProps.formatType` is `"date"` and `suggestions[0].options` holds that month's day cells. Each cell's `text` is the date it commits (`"March 23"`, or `"Tuesday"` inside the next week), so rendering them as a plain list already works — `onSelect` behaves exactly as it does for an option. To draw an actual calendar, read `dateView` for the month on show, `cellDay(option)` for the number to paint, and call `onPreviousMonth` / `onNextMonth` to page. Cells that pad the start and end of the month have `is_tappable: false`. For a **range** parameter `formatType` is `"date-range"` and the same `onSelect` fires twice: the first records the start (`dropdownProps.dateRangeStart` holds it, and nothing is committed yet), the second commits the span. `dateCellMarks` and `visibleDateRange` are exported to paint the two ends and the band between them the way the built-in calendar does.
|
|
215
|
+
> **Datepicker in a custom UI.** For a date parameter, `dropdownProps.formatType` is `"date"` and `suggestions[0].options` holds that month's day cells. Each cell's `text` is the date it commits (`"March 23"`, or `"Tuesday"` inside the next week), so rendering them as a plain list already works — `onSelect` behaves exactly as it does for an option. To draw an actual calendar, read `dateView` for the month on show, `cellDay(option)` for the number to paint, and call `onPreviousMonth` / `onNextMonth` to page. Cells that pad the start and end of the month have `is_tappable: false`. For a **range** parameter `formatType` is `"date-range"` and the same `onSelect` fires twice: the first records the start (`dropdownProps.dateRangeStart` holds it, and nothing is committed yet), the second commits the span. `dateCellMarks` and `visibleDateRange` are exported to paint the two ends and the band between them the way the built-in calendar does. A `"date"` question can also ask the end of a range whose start is already known. Then `dropdownProps.dateRangeStart` holds that start: mark it, dim the days before it, and note that picking one of them does nothing.
|
|
216
216
|
|
|
217
217
|
> **Time picker in a custom UI.** For a time parameter, `dropdownProps.formatType` is `"time"`, `suggestions[0].options` is empty, and `dropdownProps.timeView` holds `{ minutes, touched }` — the time on show, as minutes since midnight. Draw it however you like (`formatTime(minutes)` gives `"7:30 PM"`), call `onTimeChange(minutes)` to move it (snapped to 5 minutes) and `onTimeCommit()` to answer with it. The input's ↑ / ↓ / Enter keys already drive it through `inputProps`.
|
|
218
218
|
|
|
@@ -512,7 +512,7 @@ Pressing <kbd>→</kbd> at the end of the input dismisses the active pill. The d
|
|
|
512
512
|
{ placeholder: "", parameter: "goal", text: "skipped", kind: null }
|
|
513
513
|
```
|
|
514
514
|
|
|
515
|
-
Tier 2 consumers who build their own submit payload get the raw skips from the hook as `skippedParams`, and can fold them in the same way with the exported `buildSubmitResult(text, completedParams, skippedParams, { identifiedParams, isReady })` — the last argument carries the hook's `identifiedParams` and `isReady` so a hand-rolled submit reports the same `identified_params` and `is_ready` the SDK's own results do.
|
|
515
|
+
Tier 2 consumers who build their own submit payload get the raw skips from the hook as `skippedParams`, and can fold them in the same way with the exported `buildSubmitResult(text, completedParams, skippedParams, { identifiedParams, isReady })` — the last argument carries the hook's `identifiedParams` and `isReady` so a hand-rolled submit reports the same `identified_params` and `is_ready` the SDK's own results do. Call `prepareSubmit()` first, then pass `getState().identifiedParams` and `getState().isReady` (not the hook's render-time values): a typed value with no pill yet joins `identifiedParams` only in that call.
|
|
516
516
|
|
|
517
517
|
> **Reading `skippedParams` directly:** the array is append-only until `reset()`. The "drop a skip whose parameter got filled" rule is applied when the payload is built, not by pruning the array — so if the user skips `goal` and later fills one, the raw array still holds the `goal` entry. That's deliberate: the filter self-heals if they then delete that param's text, where pruning would discard the signal for good. `buildSubmitResult` applies the rule for you; to apply it elsewhere (say, a "you skipped X" badge), use the exported `withSkippedParams(completedParams, skippedParams)`.
|
|
518
518
|
|
package/dist/index.d.mts
CHANGED
|
@@ -430,7 +430,10 @@ interface UseAIAutocompleteReturn {
|
|
|
430
430
|
* Does nothing without mapProducts or with a custom products integration.
|
|
431
431
|
*/
|
|
432
432
|
refreshProducts: () => void;
|
|
433
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* Prepare the typed word before you build a submit result from your own button.
|
|
435
|
+
* A typed value with no pill yet joins `identifiedParams` only in this call. Read `getState()` after it.
|
|
436
|
+
*/
|
|
434
437
|
prepareSubmit: () => void;
|
|
435
438
|
/** Read the current state, including changes from prepareSubmit(). */
|
|
436
439
|
getState: () => CoreState;
|
|
@@ -666,7 +669,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
666
669
|
selectedDateIso?: string | null;
|
|
667
670
|
/** Both ends of a range param being re-edited, so both cells read as the current answer. Provided by `dropdownProps` from the hook. */
|
|
668
671
|
selectedDateRange?: DateRange | null;
|
|
669
|
-
/** The first end of a range picked so far, while the user chooses the second. Provided by `dropdownProps` from the hook. */
|
|
672
|
+
/** The first end of a range picked so far, while the user chooses the second. On a single-date question (`formatType: "date"`) it is the known start of the range whose end is asked: days before it are dimmed and cannot be picked. Provided by `dropdownProps` from the hook. */
|
|
670
673
|
dateRangeStart?: string | null;
|
|
671
674
|
/** Page the calendar back a month. Provided by `dropdownProps` from the hook. */
|
|
672
675
|
onPreviousMonth?: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -430,7 +430,10 @@ interface UseAIAutocompleteReturn {
|
|
|
430
430
|
* Does nothing without mapProducts or with a custom products integration.
|
|
431
431
|
*/
|
|
432
432
|
refreshProducts: () => void;
|
|
433
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* Prepare the typed word before you build a submit result from your own button.
|
|
435
|
+
* A typed value with no pill yet joins `identifiedParams` only in this call. Read `getState()` after it.
|
|
436
|
+
*/
|
|
434
437
|
prepareSubmit: () => void;
|
|
435
438
|
/** Read the current state, including changes from prepareSubmit(). */
|
|
436
439
|
getState: () => CoreState;
|
|
@@ -666,7 +669,7 @@ interface AIAutocompleteDropdownProps {
|
|
|
666
669
|
selectedDateIso?: string | null;
|
|
667
670
|
/** Both ends of a range param being re-edited, so both cells read as the current answer. Provided by `dropdownProps` from the hook. */
|
|
668
671
|
selectedDateRange?: DateRange | null;
|
|
669
|
-
/** The first end of a range picked so far, while the user chooses the second. Provided by `dropdownProps` from the hook. */
|
|
672
|
+
/** The first end of a range picked so far, while the user chooses the second. On a single-date question (`formatType: "date"`) it is the known start of the range whose end is asked: days before it are dimmed and cannot be picked. Provided by `dropdownProps` from the hook. */
|
|
670
673
|
dateRangeStart?: string | null;
|
|
671
674
|
/** Page the calendar back a month. Provided by `dropdownProps` from the hook. */
|
|
672
675
|
onPreviousMonth?: () => void;
|
package/dist/index.js
CHANGED
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
transition: none;
|
|
347
347
|
}
|
|
348
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
|
|
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 ce=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=`/*
|
|
350
350
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
351
351
|
* Consumer CSS always wins without !important.
|
|
352
352
|
*
|
|
@@ -1264,7 +1264,7 @@
|
|
|
1264
1264
|
font-weight: inherit;
|
|
1265
1265
|
cursor: pointer;
|
|
1266
1266
|
}
|
|
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
|
|
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 Y=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) ---
|
|
1268
1268
|
|
|
1269
1269
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1270
1270
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1451,7 +1451,7 @@
|
|
|
1451
1451
|
opacity: 0.8;
|
|
1452
1452
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1453
1453
|
}
|
|
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
|
|
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 me=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,Y.isoDate)(new Date),m=(0,Y.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,Y.cellIso)(e[i]),selected:o.selectedRange,floor:o.floor});return(0,me.jsxs)("div",{className:Q.datepicker,"data-aia-datepicker":"",children:[(0,me.jsxs)("div",{className:Q.header,children:[(0,me.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,me.jsx)("span",{className:Q.month,"data-aia-date-month":"","aria-live":"polite",children:(0,Y.monthLabel)(a)}),(0,me.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,me.jsx)("div",{className:Q.weekdays,"aria-hidden":"true",children:Y.WEEKDAY_LABELS.map((c,p)=>(0,me.jsx)("span",{className:Q.weekday,children:c},Aa[p]))}),(0,me.jsx)("div",{className:Q.grid,"data-aia-date-grid":"",children:e.map((c,p)=>(0,me.jsx)(La,{option:c,id:`${t}-option-${p}`,index:p,isHighlighted:p===i&&c.is_tappable,isToday:(0,Y.cellIso)(c)===y,isPast:(0,Y.isDimmedDay)((0,Y.cellIso)(c),y,o.floor),marks:(0,Y.dateCellMarks)((0,Y.cellIso)(c),{selectedIso:o.selectedIso,range:m}),onSelect:r,onHighlight:n,onUnhighlight:l},(0,Y.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,Y.cellDay)(e);if(c==null)return(0,me.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,me.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,me.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 {
|
|
1455
1455
|
display: flex;
|
|
1456
1456
|
flex-wrap: wrap;
|
|
1457
1457
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1765,7 +1765,7 @@
|
|
|
1765
1765
|
.aia-loadingBar-OLCr4:nth-child(3) {
|
|
1766
1766
|
width: 60%;
|
|
1767
1767
|
}
|
|
1768
|
-
`,document.head.appendChild(e)}var
|
|
1768
|
+
`,document.head.appendChild(e)}var j={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:j.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:j.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?`${j.row} ${j.highlighted}`:j.row,"data-aia-location-row":"","data-aia-index":A,onClick:()=>{n&&(K(!0),x(A))},children:[(0,W.jsx)("span",{className:j.pin,children:Da}),(0,W.jsxs)("span",{className:j.text,children:[(0,W.jsx)("span",{className:j.name,children:h.name}),h.secondary&&(0,W.jsx)("span",{className:j.secondary,children:h.secondary})]})]},h.id)):e.status==="loading"?X=(0,W.jsxs)("div",{className:j.loading,"data-aia-location-loading":"",children:[(0,W.jsx)("span",{className:j.loadingBar}),(0,W.jsx)("span",{className:j.loadingBar}),(0,W.jsx)("span",{className:j.loadingBar})]}):fe&&(X=(0,W.jsxs)("div",{className:j.note,"data-aia-location-note":"",children:[e.status==="done"&&(0,W.jsx)("span",{className:j.empty,children:t}),(0,W.jsx)("span",{children:a})]})),(0,W.jsxs)("div",{ref:c,className:j.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:j.field,children:[Ma,(0,W.jsx)("input",{ref:m,type:"text",className:j.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:j.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,
|
|
1769
1769
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1770
1770
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1771
1771
|
as it was when the outline was dashed. */
|
|
@@ -1955,7 +1955,7 @@
|
|
|
1955
1955
|
align-items: center;
|
|
1956
1956
|
vertical-align: middle;
|
|
1957
1957
|
}
|
|
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"),
|
|
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"),ge=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
|
|
1959
1959
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1960
1960
|
theming one package sees the same result in the other.
|
|
1961
1961
|
|
|
@@ -2411,7 +2411,7 @@
|
|
|
2411
2411
|
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2412
2412
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2413
2413
|
}
|
|
2414
|
-
`,document.head.appendChild(e)}var
|
|
2414
|
+
`,document.head.appendChild(e)}var $={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,ge.useRef)(null);if((0,ge.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:$.section,"data-aia-products":"","data-aia-products-layout":n,role:"group","aria-labelledby":m,children:[(0,H.jsx)("div",{className:$.label,id:m,"data-aia-products-label":"",children:f.products}),(0,H.jsx)("div",{ref:y,className:$.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,ge.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:$.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:$.body,children:[e.vendor?(0,H.jsx)("span",{className:$.vendor,children:e.vendor}):null,(0,H.jsx)("span",{className:$.title,children:e.title}),e.price?(0,H.jsxs)("span",{className:$.price,children:[e.price,e.compareAtPrice?(0,H.jsx)("s",{className:$.compareAt,children:e.compareAtPrice}):null]}):null,e.available===!1?(0,H.jsx)("span",{className:$.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,ge.useState)(null),f=(0,ge.useRef)(null),x=(0,ge.useRef)(e);x.current=e;let y=(0,ge.useRef)(!0);(0,ge.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:$.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:$.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:$.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),(0,H.jsx)("path",{className:$.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),(0,H.jsx)("path",{className:$.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),(0,H.jsx)("circle",{className:$.cartGlyph,cx:"9",cy:"20",r:"1.3"}),(0,H.jsx)("circle",{className:$.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function Ba({sources:e,title:i,fallback:t,onPhotoFill:a}){let[o,r]=(0,ge.useState)(0),n=e[o],l=!!n,[f,x]=(0,ge.useState)(null),y=!l&&t==="initial";return(0,ge.useEffect)(()=>()=>a(null),[a]),(0,H.jsxs)("span",{className:$.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:$.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 {
|
|
2415
2415
|
display: grid;
|
|
2416
2416
|
grid-template-columns: repeat(
|
|
2417
2417
|
auto-fit,
|
|
@@ -2447,7 +2447,7 @@
|
|
|
2447
2447
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
2448
2448
|
display: none;
|
|
2449
2449
|
}
|
|
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
|
|
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 pe=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 {
|
|
2451
2451
|
position: relative;
|
|
2452
2452
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2453
2453
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2973,7 +2973,7 @@
|
|
|
2973
2973
|
.aia-item-d4vpD:has(.aia-checkbox-KGRhg[data-checked="true"]) {
|
|
2974
2974
|
background: var(--aia-option-bg, transparent);
|
|
2975
2975
|
}
|
|
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,
|
|
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,pe.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,pe.sanitizeOptionIconSvg)(e.icon_svg):null,[N,f,e.icon_svg]),te=y?(0,pe.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,pe.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:{[pe.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,pe.highlightParts)((0,pe.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,pe.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) ---
|
|
2977
2977
|
|
|
2978
2978
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
2979
2979
|
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -3113,7 +3113,7 @@
|
|
|
3113
3113
|
align-items: end;
|
|
3114
3114
|
}
|
|
3115
3115
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
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,
|
|
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,ce.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,ce.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,ce.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,he=r&&(ct.length>0||y&&Be||V||at||nt||We);Ja(ve,he);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);he&&(k.current=Ae);let u=he?Ae:k.current,ae=(0,ce.uiStringsFor)(E),Le=u.suggestions[0],g=Le?.options??[],rt=u.activeIndex>=0&&!!g[u.activeIndex]?.is_tappable,Ge=(0,ce.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,ce.hasSkippablePill)(Ge)&&u.showSkipButton&&!u.isInputEmpty&&!!m,ke=Ge[0]?.text,Oe=(0,ce.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} ${he?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,floor:(0,ce.dateFloorFor)(u.formatType,u.dateRangeStart)},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&&he,visible:he,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:he,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 {
|
|
3117
3117
|
flex-shrink: 0;
|
|
3118
3118
|
width: 32px;
|
|
3119
3119
|
height: 32px;
|
|
@@ -3184,5 +3184,5 @@
|
|
|
3184
3184
|
transition: none;
|
|
3185
3185
|
}
|
|
3186
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});
|
|
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,dateFloor: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 he=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(!he.current){he.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 ue=ve.current?.current;ue&&(ue.focus(),(0,Fe.setCursorOffset)(ue,F))},[]),{completedParams:ct,suggestionPills:Be,setActivePill:at,skipActivePill:nt,segments:We,newParamId:he,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(!he)return;let F=window.setTimeout(()=>Ae(),650);return()=>window.clearTimeout(F)},[he,Ae]);let fa=Ge>=0?`${Re}-option-${Ge}`:void 0,{inputRef:Et,editorProps:ba,focus:vt,blur:Bt,getPlainText:Wt}=ma({segments:We,newParamId:he,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,ue=Et.current;if(!F||!ue)return;let mt=()=>{let Kt=F.firstElementChild;if(!Kt)return;let ya=Kt.getBoundingClientRect(),ka=ue.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(ue),()=>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 ue=Ft(),mt=(0,Fe.buildSubmitResult)(Wt(),ue.completedParams,ue.skippedParams,{identifiedParams:ue.identifiedParams,isReady:ue.isReady,customFields:ue.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});
|
|
3188
3188
|
//# sourceMappingURL=index.js.map
|