@magicx-eng/ai-autocomplete-react 0.32.3 → 0.32.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
-
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
+
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AutocompleteResult, OptionOverrides, APIConfig, AppearanceMode, CompletedParamState, ProductsLayout, ProductImageFallback, ProductsConfig, Product, Suggestion, SuggestionOption, FormatType, DateMonthView, DateRange, SkippedParamState, IdentifiedParamState, Segment, CustomFieldsReport } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
-
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
2
|
+
export { APIConfig, APIKeyConfig, AccessTokenConfig, AccessTokenResult, AppearanceMode, AutocompleteResult, CompletedParam, CompletedParamState, CustomFieldsReport, DATE_RANGE_META_END, DATE_RANGE_META_START, DEFAULT_OPTION_COUNT_UNIT, DateMonthView, DateRange, ExpressedFilter, FilterOp, FormatType, IdentifiedParam, IdentifiedParamState, MatchedItem, MatchedItems, OptionOverrides, PRODUCT_PATH_PREFIX, Product, ProductImageFallback, ProductsConfig, ProductsLayout, Segment, SkippedParamState, SubmitResultExtras, Suggestion, SuggestionOption, TaskKind, WEEKDAY_LABELS, buildSubmitResult, cellDay, cellIso, dateCellMarks, formatDate, formatDateRange, formatOptionCount, isoDate, monthLabel, optionCountLabel, optionHasImage, optionImageSources, optionImageSrc, optionLabel, parseDate, parseLooseDate, parseLooseDateRange, productFromMatchedItem, productImageSources, productsFromCustomFields, sanitizeOptionIconSvg, selectedRangeFor, visibleDateRange, withSkippedParams } from '@magicx-eng/ai-autocomplete-vanilla';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, KeyboardEvent, ChangeEvent } from 'react';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ct=Object.defineProperty;var ea=Object.getOwnPropertyDescriptor;var ta=Object.getOwnPropertyNames;var aa=Object.prototype.hasOwnProperty;var ia=(e,a)=>{for(var t in a)ct(e,t,{get:a[t],enumerable:!0})},oa=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of ta(a))!aa.call(e,i)&&i!==t&&ct(e,i,{get:()=>a[i],enumerable:!(n=ea(a,i))||n.enumerable});return e};var na=e=>oa(ct({},"__esModule",{value:!0}),e);var wa={};ia(wa,{AIAutocomplete:()=>Wt,AIAutocompleteDropdown:()=>at,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,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,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,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,productFromMatchedItem:()=>s.productFromMatchedItem,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>ot,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=na(wa);var s=require("@magicx-eng/ai-autocomplete-vanilla");var
|
|
1
|
+
"use strict";var ct=Object.defineProperty;var ea=Object.getOwnPropertyDescriptor;var ta=Object.getOwnPropertyNames;var aa=Object.prototype.hasOwnProperty;var ia=(e,a)=>{for(var t in a)ct(e,t,{get:a[t],enumerable:!0})},oa=(e,a,t,n)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of ta(a))!aa.call(e,i)&&i!==t&&ct(e,i,{get:()=>a[i],enumerable:!(n=ea(a,i))||n.enumerable});return e};var na=e=>oa(ct({},"__esModule",{value:!0}),e);var wa={};ia(wa,{AIAutocomplete:()=>Wt,AIAutocompleteDropdown:()=>at,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,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,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,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSources:()=>s.optionImageSources,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,productFromMatchedItem:()=>s.productFromMatchedItem,productImageSources:()=>s.productImageSources,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>ot,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=na(wa);var s=require("@magicx-eng/ai-autocomplete-vanilla");var M=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
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
opacity: 0;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,document.head.appendChild(e)}var
|
|
265
|
+
`,document.head.appendChild(e)}var Me={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",aiaPillReveal:"aia-aiaPillReveal-wf05b"};var Oe=require("@magicx-eng/ai-autocomplete-vanilla"),ae=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
266
266
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
267
267
|
* Consumer CSS always wins without !important.
|
|
268
268
|
*
|
|
@@ -1045,7 +1045,7 @@
|
|
|
1045
1045
|
opacity: 0.25;
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
`,document.head.appendChild(e)}var
|
|
1048
|
+
`,document.head.appendChild(e)}var xe={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"};var z=require("@magicx-eng/ai-autocomplete-vanilla"),kt=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) ---
|
|
1049
1049
|
|
|
1050
1050
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1051
1051
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1208,7 +1208,7 @@
|
|
|
1208
1208
|
opacity: 0.8;
|
|
1209
1209
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1210
1210
|
}
|
|
1211
|
-
`,document.head.appendChild(e)}var
|
|
1211
|
+
`,document.head.appendChild(e)}var D={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 Z=require("react/jsx-runtime"),ra=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Ct({options:e,activeIndex:a,listboxId:t,view:n,selection:i,onSelect:r,onHighlight:o,onUnhighlight:l,onPreviousMonth:w,onNextMonth:x}){let y=(0,z.isoDate)(new Date),E=(0,z.visibleDateRange)({pendingStart:i.rangeStart,highlightedIso:(0,z.cellIso)(e[a]),selected:i.selectedRange});return(0,Z.jsxs)("div",{className:D.datepicker,"data-aia-datepicker":"",children:[(0,Z.jsxs)("div",{className:D.header,children:[(0,Z.jsx)("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:w,children:"\u2039"}),(0,Z.jsx)("span",{className:D.month,"data-aia-date-month":"","aria-live":"polite",children:(0,z.monthLabel)(n)}),(0,Z.jsx)("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:x,children:"\u203A"})]}),(0,Z.jsx)("div",{className:D.weekdays,"aria-hidden":"true",children:z.WEEKDAY_LABELS.map((m,k)=>(0,Z.jsx)("span",{className:D.weekday,children:m},ra[k]))}),(0,Z.jsx)("div",{className:D.grid,"data-aia-date-grid":"",children:e.map((m,k)=>(0,Z.jsx)(sa,{option:m,id:`${t}-option-${k}`,index:k,isHighlighted:k===a&&m.is_tappable,isToday:(0,z.cellIso)(m)===y,isPast:(0,z.cellIso)(m)!=null&&(0,z.cellIso)(m)<y,marks:(0,z.dateCellMarks)((0,z.cellIso)(m),{selectedIso:i.selectedIso,range:E}),onSelect:r,onHighlight:o,onUnhighlight:l},(0,z.cellIso)(m)??`pad-${k}`))})]})}function sa({option:e,id:a,index:t,isHighlighted:n,isToday:i,isPast:r,marks:o,onSelect:l,onHighlight:w,onUnhighlight:x}){let[y,E]=(0,kt.useState)(!1),m=(0,z.cellDay)(e);if(m==null)return(0,Z.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${D.cell} ${D.blank}`});let k=()=>{E(!0),l(e),setTimeout(()=>E(!1),170)},R=[D.cell,D.day,r?D.past:"",n?D.highlighted:"",i?D.today:"",o.inRange?D.inRange:"",o.selected?D.selected:"",y?D.pressed:""].filter(Boolean).join(" ");return(0,Z.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:R,onClick:k,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),k())},onMouseEnter:()=>w(t),onMouseLeave:x?()=>x(t):void 0,children:(0,Z.jsx)("span",{className:D.number,children:m})})}var Fe=require("@magicx-eng/ai-autocomplete-vanilla"),Je=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 {
|
|
1212
1212
|
display: flex;
|
|
1213
1213
|
flex-wrap: wrap;
|
|
1214
1214
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1248,7 +1248,7 @@
|
|
|
1248
1248
|
.aia-cluster[data-justify="around"] {
|
|
1249
1249
|
justify-content: space-around;
|
|
1250
1250
|
}
|
|
1251
|
-
`,document.head.appendChild(e)}var pt=require("react/jsx-runtime");function
|
|
1251
|
+
`,document.head.appendChild(e)}var pt=require("react/jsx-runtime");function je({gap:e,align:a="center",justify:t="start",noWrap:n=!1,inline:i=!1,className:r,children:o,...l}){let w=e?{"--aia-cluster-gap":e}:void 0,x={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":n||void 0,"data-inline":i||void 0,style:w,...l};return i?(0,pt.jsx)("span",{...x,children:o}):(0,pt.jsx)("div",{...x,children:o})}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
|
|
1252
1252
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1253
1253
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1254
1254
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1395,7 +1395,7 @@
|
|
|
1395
1395
|
justify-content: flex-end;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
-
`,document.head.appendChild(e)}var
|
|
1398
|
+
`,document.head.appendChild(e)}var ye={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 le=require("react/jsx-runtime");function Pt({isOptionHighlighted:e=!1,isInputEmpty:a=!1}){let{key:t,hint:n}=(0,Fe.getFooterHint)(e,a),[i,r]=(0,Je.useState)(Fe.ATTRIBUTION_URL);return(0,Je.useEffect)(()=>{r((0,Fe.buildAttributionUrl)())},[]),(0,le.jsx)("footer",{className:ye.footer,"data-aia-footer":"",children:(0,le.jsxs)(je,{justify:"between",noWrap:!0,className:ye.row,children:[(0,le.jsxs)(je,{gap:"5px",className:ye.hintGroup,children:[(0,le.jsx)("kbd",{className:ye.key,children:t}),(0,le.jsx)("span",{className:ye.hint,children:n})]}),(0,le.jsxs)("a",{className:ye.brandLink,href:i,target:"_blank",rel:"noopener noreferrer",children:[(0,le.jsx)("span",{className:ye.brand,children:"AI"}),(0,le.jsx)("span",{className:ye.badge,children:"Autocomplete"})]})]})})}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,
|
|
1399
1399
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1400
1400
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1401
1401
|
as it was when the outline was dashed. */
|
|
@@ -1481,7 +1481,7 @@
|
|
|
1481
1481
|
align-items: center;
|
|
1482
1482
|
vertical-align: middle;
|
|
1483
1483
|
}
|
|
1484
|
-
`,document.head.appendChild(e)}var ut={list:"aia-list-qvLqO"};var
|
|
1484
|
+
`,document.head.appendChild(e)}var ut={list:"aia-list-qvLqO"};var Qe=require("react/jsx-runtime"),la=[125,69];function Et(e){return e===0?"first":e===1?"next":"last"}function et({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:n,rounded:i,loading:r}){return r&&e.length===0?(0,Qe.jsx)("span",{className:ut.list,"data-aia-pill-list-loading":"",children:la.map((o,l)=>(0,Qe.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Ae.pill} ${i?Ae.rounded:""} ${Ae.skeleton}`,style:{width:o,opacity:ht[Et(l)]}},`skel-${o}`))}):(0,Qe.jsx)("span",{className:ut.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((o,l)=>{let w=!!n&&l===a;return(0,Qe.jsx)(St,{label:o.text,state:w?"selected":Et(l),selected:w,rounded:i,loading:r,onClick:()=>t(l)},`${o.parameter}-${o.text}`)})})}var Re=require("@magicx-eng/ai-autocomplete-vanilla"),Ke=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
|
|
1485
1485
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1486
1486
|
theming one package sees the same result in the other.
|
|
1487
1487
|
|
|
@@ -1765,7 +1765,7 @@
|
|
|
1765
1765
|
letter-spacing: 0.02em;
|
|
1766
1766
|
text-align: center;
|
|
1767
1767
|
}
|
|
1768
|
-
`,document.head.appendChild(e)}var
|
|
1768
|
+
`,document.head.appendChild(e)}var te={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",badge:"aia-badge-j9Hcd"};var Q=require("react/jsx-runtime");function Tt({products:e,listboxId:a,onSelect:t,onFocusChange:n,focusable:i=!0,layout:r="row",imageFallback:o="image"}){let l=e.length>0,w=(0,Ke.useRef)(null);if((0,Ke.useEffect)(()=>{let y=w.current;if(!(!l||!y))return(0,Re.attachProductRowWheel)(y)},[l]),!l)return null;let x=`${a}-products-label`;return(0,Q.jsxs)("section",{className:te.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":x,children:[(0,Q.jsx)("div",{className:te.label,id:x,"data-aia-products-label":"",children:"Products"}),(0,Q.jsx)("div",{ref:w,className:te.row,"data-aia-products-row":"",children:e.map((y,E)=>(0,Q.jsx)(da,{product:y,id:`${a}-product-${E}`,onSelect:t,onFocusChange:n,focusable:i,imageFallback:o},y.id))})]})}function da({product:e,id:a,onSelect:t,onFocusChange:n,focusable:i,imageFallback:r}){let o=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return(0,Q.jsxs)("a",{id:a,className:te.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:i?0:-1,onClick:o,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[(0,Q.jsx)(ca,{sources:(0,Re.productImageSources)(e.imageUrl),title:e.title,fallback:r},(0,Re.productImageSrc)(e.imageUrl)??""),(0,Q.jsxs)("span",{className:te.body,children:[e.vendor?(0,Q.jsx)("span",{className:te.vendor,children:e.vendor}):null,(0,Q.jsx)("span",{className:te.title,children:e.title}),e.price?(0,Q.jsx)("span",{className:te.price,children:e.price}):null,e.available===!1?(0,Q.jsx)("span",{className:te.badge,children:"Sold out"}):null]})]})}function ca({sources:e,title:a,fallback:t}){let[n,i]=(0,Ke.useState)(0),r=e[n],o=!!r,l=!o&&t==="initial";return(0,Q.jsxs)("span",{className:te.media,"aria-hidden":"true","data-aia-product-placeholder":!o&&!l?"":void 0,"data-aia-product-initial":l?"":void 0,children:[o?(0,Q.jsx)("img",{className:te.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>i(w=>w+1)}):null,l?(0,Re.productInitial)(a):null]})}var Y=require("@magicx-eng/ai-autocomplete-vanilla"),he=require("react");var At=require("@magicx-eng/ai-autocomplete-vanilla"),tt=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 {
|
|
1769
1769
|
display: grid;
|
|
1770
1770
|
grid-template-columns: repeat(
|
|
1771
1771
|
auto-fit,
|
|
@@ -1801,7 +1801,7 @@
|
|
|
1801
1801
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1802
1802
|
display: none;
|
|
1803
1803
|
}
|
|
1804
|
-
`,document.head.appendChild(e)}var Ot=require("react/jsx-runtime");function Rt({min:e="16rem",max:a,gap:t,scroll:n=!1,maxHeight:i,scrollResetKey:r,cols:o,template:
|
|
1804
|
+
`,document.head.appendChild(e)}var Ot=require("react/jsx-runtime");function Rt({min:e="16rem",max:a,gap:t,scroll:n=!1,maxHeight:i,scrollResetKey:r,cols:o,template:l,innerRef:w,className:x,children:y,...E}){let m=(0,tt.useRef)(null);(0,tt.useLayoutEffect)(()=>{if(r===void 0)return;let R=m.current;R&&(R.scrollTop=0)},[r]);let k={"--aia-grid-min":e};return a&&(k["--aia-grid-max"]=a),t&&(k["--aia-grid-gap"]=t),i&&(k["--aia-grid-max-height"]=i),o&&(k.gridTemplateColumns=(0,At.optionsGridTemplateColumns)(o)),l&&(k.gridTemplateColumns=l),(0,Ot.jsx)("div",{ref:R=>{m.current=R,w?.(R)},className:x?`aia-grid ${x}`:"aia-grid","data-scroll":n||void 0,style:k,...E,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 {
|
|
1805
1805
|
position: relative;
|
|
1806
1806
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1807
1807
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2198,7 +2198,7 @@
|
|
|
2198
2198
|
opacity: 0;
|
|
2199
2199
|
}
|
|
2200
2200
|
}
|
|
2201
|
-
`,document.head.appendChild(e)}var
|
|
2201
|
+
`,document.head.appendChild(e)}var X={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",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",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};var de=require("react/jsx-runtime");function Dt({option:e,isHighlighted:a,onSelect:t,onHighlight:n,onUnhighlight:i,id:r,loading:o,showIcon:l=!0,showImage:w=!0,showCount:x=!0,scrollHint:y,enterDelayMs:E=0}){let[m]=(0,ce.useState)(E),[k,R]=(0,ce.useState)(!1),B=w?(0,pe.optionImageSources)(e.image_url):[],H=B[0]??null,[F,L]=(0,ce.useState)([]),T=B.find(_=>!F.includes(_))??null,K=(0,ce.useMemo)(()=>!H&&l&&e.icon_svg?(0,pe.sanitizeOptionIconSvg)(e.icon_svg):null,[H,l,e.icon_svg]),A=x?(0,pe.formatOptionCount)(e.item_count):null,C=(0,ce.useRef)(void 0);(0,ce.useEffect)(()=>()=>clearTimeout(C.current),[]);let $=()=>{o||!e.is_tappable||k||(R(!0),t(e),clearTimeout(C.current),C.current=setTimeout(()=>R(!1),170))},ie=[X.item,a&&!o?X.highlighted:"",e.is_tappable?X.tappable:X.nonTappable,k?X.pressed:"",y?X.scrollHint:""].filter(Boolean).join(" ");return(0,de.jsx)("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"data-aia-icon":K&&e.icon?e.icon:void 0,"data-aia-image":H?"":void 0,"data-aia-item-count":A!==null?e.item_count:void 0,"aria-selected":a,className:ie,style:{[pe.OPTION_ENTER_DELAY_VAR]:`${m}ms`},tabIndex:o||!e.is_tappable?-1:0,onClick:$,onKeyDown:_=>{!o&&e.is_tappable&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),$())},onMouseEnter:!o&&e.is_tappable?n:void 0,onMouseLeave:i,children:(0,de.jsxs)("span",{className:X.content,children:[H&&(0,de.jsx)("span",{className:`${X.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,de.jsx)("img",{src:T??H,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:T===null,onError:()=>{T!==null&&L(_=>[..._,T])}})}),K&&(0,de.jsx)("span",{className:`${X.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:K}}),(0,de.jsx)("span",{className:X.text,children:(0,pe.optionLabel)(e)}),e.tag&&(0,de.jsx)("span",{className:X.tag,children:e.tag}),A!==null&&(0,de.jsx)("span",{className:`${X.count} magicx-aia-option-count`,children:A})]})})}var mt=require("react/jsx-runtime");function pa(){let[e,a]=(0,he.useState)(Y.isOptionsGridMobileViewport);return(0,he.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Y.OPTIONS_GRID_MOBILE_QUERY),n=()=>a(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function Lt({options:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:r,loading:o,groupKey:l="",optionsPosition:w="below",showIcons:x=!0,showImages:y=!0,showCounts:E=!0}){let m=pa(),k=(0,he.useRef)(null),[R,B]=(0,he.useState)(null),H=(0,he.useRef)(null);(0,he.useLayoutEffect)(()=>{if(o&&(0,Y.sameOptionRows)(H.current,e))return;H.current=o?null:e;let L=k.current,K=L&&!o&&(0,Y.needsOptionsGridMeasurement)(e.length,m)?(0,Y.measureOptionsGrid)(L):null;B(K?(0,Y.planOptionsGrid)(e.length,m,K.rowWidths,K.gridWidth):null)},[e,m,o]);let F=R??(0,Y.planOptionsGrid)(e.length,m,null,null);return(0,mt.jsx)(Rt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:l,template:F.template,maxHeight:F.maxHeight,innerRef:L=>{k.current=L},"data-aia-group":l,children:e.map((L,T)=>(0,mt.jsx)(Dt,{option:L,isHighlighted:T===a,onSelect:t,onHighlight:()=>n(T),onUnhighlight:i?()=>i(T):void 0,id:`${r}-option-${T}`,loading:o,showIcon:x,showImage:y,showCount:E,scrollHint:!o&&F.scrollHintIndices.includes(T),enterDelayMs:o?0:(0,Y.optionEnterDelayMs)(T,F.cols,e.length,w)},`${l}\0${L.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2202
2202
|
display: flex;
|
|
2203
2203
|
flex-direction: column;
|
|
2204
2204
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2213,7 +2213,7 @@
|
|
|
2213
2213
|
align-items: end;
|
|
2214
2214
|
}
|
|
2215
2215
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2216
|
-
`,document.head.appendChild(e)}var Mt=require("react/jsx-runtime");function zt({space:e,align:a="stretch",className:t,children:n,...i}){let r=e?{"--aia-stack-space":e}:void 0;return(0,Mt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...i,children:n})}var
|
|
2216
|
+
`,document.head.appendChild(e)}var Mt=require("react/jsx-runtime");function zt({space:e,align:a="stretch",className:t,children:n,...i}){let r=e?{"--aia-stack-space":e}:void 0;return(0,Mt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...i,children:n})}var G=require("react/jsx-runtime"),ha=[159,119,164],ua=()=>{},Nt=()=>{};function ma(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=(0,ae.useState)(a);if((0,ae.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let i=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>n(i.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ga(e,a){let t=(0,ae.useRef)(null);(0,ae.useEffect)(()=>{let n=e.current,i=a.current;if(!n||!i)return;let r=n.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,Oe.attachScrollArrow)({dropdown:n,grid:r,button:i})};return}t.current?.controller.update()}),(0,ae.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function at({suggestions:e,activeIndex:a,onSelect:t,onHighlight:n,onUnhighlight:i,isOpen:r,id:o,className:l,pills:w,onPillClick:x,showPills:y=!0,onSkip:E,showSkipButton:m=!0,showOptionIcons:k=!0,showOptionImages:R=!0,showOptionCounts:B=!0,skipDisabled:H=!1,activeSelected:F=!1,isLoading:L=!1,skeletonExiting:T=!1,isInputEmpty:K=!1,products:A,onProductSelect:C,onProductFocusChange:$,productsLayout:ie="row",productImageFallback:_="image",formatType:ue="options",dateView:ke=null,selectedDateIso:V=null,selectedDateRange:f=null,dateRangeStart:De=null,onPreviousMonth:Ce,onNextMonth:Pe,optionsPosition:me="below",mode:Se}){let ge=ma(Se),ne=ge!==void 0,J=(0,ae.useRef)(null),fe=(0,ae.useRef)(null);ga(J,fe),(0,ae.useEffect)(()=>{if(J.current)return(0,Oe.containScroll)(J.current)},[]);let be=e[0]?.options??[],c=!!(w&&w.length>0&&x),g=!!(A&&A.length>0),u=r&&(be.length>0||y&&c||L||g),b={suggestions:e,activeIndex:a,pills:w,showPills:y,showSkipButton:m,showOptionIcons:k,showOptionImages:R,showOptionCounts:B,skipDisabled:H,activeSelected:F,isLoading:L,skeletonExiting:T,isInputEmpty:K,products:A,formatType:ue,dateView:ke,selectedDateIso:V,selectedDateRange:f,dateRangeStart:De},P=(0,ae.useRef)(b);u&&(P.current=b);let d=u?b:P.current,q=d.suggestions[0],U=q?.options??[],re=d.activeIndex>=0&&!!U[d.activeIndex]?.is_tappable,v=!!(d.pills&&d.pills.length>0&&x),Le=d.showPills&&v,_e=d.showPills&&!v&&d.isLoading,ve=Le||_e,p=v&&d.showSkipButton&&!d.isInputEmpty&&!!E,we=d.pills?.[0]?.text,ze=(0,Oe.isCalendarFormat)(d.formatType)&&d.dateView!=null,Ie=U.length>0&&!ze,Ne=U.length>0&&ze&&!d.isLoading,Ee=d.isLoading&&!Ie&&!Ne,Be=d.products??[];return(0,G.jsxs)("div",{ref:J,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":me,"data-mode":ge,"data-aia-loading":d.isLoading?"":void 0,"data-aia-skeleton-exiting":d.skeletonExiting?"":void 0,"data-aia-has-products":Be.length>0?"":void 0,className:`${ne?"magicx-aia ":""}${xe.dropdown} ${u?xe.visible:""} ${l??""}`,onMouseDown:j=>j.preventDefault(),children:[(0,G.jsxs)(zt,{space:"8px",children:[(ve||p)&&(0,G.jsxs)(je,{noWrap:!0,className:xe.pillBar,"data-aia-pillbar":"",children:[ve&&(0,G.jsx)("span",{className:xe.pillScroll,"data-aia-pill-scroll":"",children:(0,G.jsx)(et,{pills:d.pills??[],activePillIndex:0,activeSelected:d.activeSelected,onSelectPill:x??(()=>{}),rounded:!0,loading:d.isLoading})}),p&&(0,G.jsx)("button",{type:"button",tabIndex:-1,className:xe.skip,"data-aia-skip":"",disabled:d.isLoading||d.skipDisabled,"aria-label":we?`Skip ${we}`:"Skip",onClick:E,children:"skip"})]}),Ie&&(0,G.jsx)(Lt,{options:U,activeIndex:d.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:i,listboxId:o,loading:d.isLoading,groupKey:q?`${q.parameter} ${q.text}`:"",optionsPosition:me,showIcons:d.showOptionIcons,showImages:d.showOptionImages,showCounts:d.showOptionCounts}),Ne&&d.dateView&&(0,G.jsx)(Ct,{options:U,activeIndex:d.activeIndex,listboxId:o,view:d.dateView,selection:{selectedIso:d.selectedDateIso??null,selectedRange:d.selectedDateRange??null,rangeStart:d.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:i,onPreviousMonth:Ce??Nt,onNextMonth:Pe??Nt}),Ee&&(0,G.jsx)("div",{className:xe.skeletonBars,"data-aia-skeleton-bars":"",children:ha.map(j=>(0,G.jsx)("span",{className:xe.skeletonBar,style:{width:j}},`bar-${j}`))}),(0,G.jsx)(Tt,{products:Be,listboxId:o,onSelect:C??ua,onFocusChange:$,focusable:u,layout:ie,imageFallback:_}),(0,G.jsx)(Pt,{isOptionHighlighted:re,isInputEmpty:d.isInputEmpty})]}),(0,G.jsx)("button",{ref:fe,type:"button",tabIndex:-1,className:xe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Oe.SCROLL_ARROW_LABEL,"aria-hidden":"true",children:(0,G.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,G.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var We=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 {
|
|
2217
2217
|
flex-shrink: 0;
|
|
2218
2218
|
width: 32px;
|
|
2219
2219
|
height: 32px;
|
|
@@ -2266,5 +2266,5 @@
|
|
|
2266
2266
|
);
|
|
2267
2267
|
cursor: default;
|
|
2268
2268
|
}
|
|
2269
|
-
`,document.head.appendChild(e)}var Bt={submitButton:"aia-submitButton-otz7H"};var it=require("react/jsx-runtime");function Ht({disabled:e,onClick:a}){return(0,it.jsx)("button",{type:"button","data-aia-submit":"",className:Bt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,it.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,it.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ke=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var gt=require("react");function Ft(e){let a=(0,gt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=(0,gt.useRef)({key:"",overrides:void 0});if(n.current.key!==t){let i={};for(let r of Object.keys(e??{})){let o=(d,k,w)=>{let x=a.current?.[r];return x?x(d,k,w):[]};i[r]=o}n.current={key:t,overrides:e?i:void 0}}return{overrides:n.current.overrides,key:t}}var ft=require("react");function Kt(e){let a=(0,ft.useRef)(e);a.current=e;let t=(0,ft.useRef)(null);t.current===null&&(t.current={fetch:(i,r)=>{let o=a.current;return o?o.fetch(i,r):Promise.reject(new Error("products config removed"))},transform:i=>a.current?.transform(i)??[],get limit(){return a.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var fa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],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,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ot({onSubmit:e,onResult:a,onError:t,optionOverrides:n,maskCompletedText:i,apiConfig:r,additionalContext:o,visitorId:d,columns:k=2,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:m,showOptionIcons:y,showOptionImages:O,showOptionCounts:A,showSkipButton:Z,showProducts:H,productImageFallback:D="image",onFocus:T,onBlur:F,value:R,completedParams:P,onChange:Q,onParamsChange:pe,products:ye,onProductSelect:he,source:ke,setCursor:$}){let f=(0,I.useRef)(null),[Oe,Ce]=(0,I.useState)(null),Pe=(0,I.useRef)(e);Pe.current=e;let ue=(0,I.useRef)(a);ue.current=a;let Se=(0,I.useRef)(t);Se.current=t;let me=(0,I.useRef)(Q);me.current=Q;let ie=(0,I.useRef)(pe);ie.current=pe;let X=(0,I.useRef)(T);X.current=T;let ge=(0,I.useRef)(F);ge.current=F;let fe=(0,I.useRef)($);fe.current=$;let c=(0,I.useRef)(he);c.current=he;let g=(0,I.useRef)(d);g.current=d;let u=(0,I.useRef)(()=>{let h=g.current;return typeof h=="function"?h():h}).current,b=Kt(ye),C=Ft(n);(0,I.useEffect)(()=>{if(typeof document>"u")return;let h=new Ke.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:o,visitorId:u,optionOverrides:C.overrides,maskCompletedText:i,columns:k,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:m,showProducts:H,source:ke,value:R,completedParams:P,onSubmit:(...B)=>Pe.current?.(...B),onResult:(...B)=>ue.current?.(...B),onError:(...B)=>Se.current?.(...B),onChange:(...B)=>me.current?.(...B),onParamsChange:(...B)=>ie.current?.(...B),onFocus:()=>X.current?.(),onBlur:()=>ge.current?.(),onProductSelect:B=>c.current?.(B),setCursor:B=>fe.current?.(B),products:b.config});f.current=h,Ce(h.getState());let J=h.subscribe(B=>Ce(B));return()=>{J(),h.destroy(),f.current===h&&(f.current=null)}},[]),(0,I.useEffect)(()=>{R!==void 0&&f.current?.setValue(R)},[R]),(0,I.useEffect)(()=>{P!==void 0&&f.current?.setCompletedParams(P)},[P]);let l=JSON.stringify(r??null),W;try{W=JSON.stringify(o??null)}catch{W="[unstringifiable]"}(0,I.useEffect)(()=>{f.current?.update({apiConfig:r,additionalContext:o,optionOverrides:C.overrides,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:m,showProducts:H})},[l,W,C.key,w,x,E,m,H]);let _=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!_.current){_.current=!0;return}f.current?.update({products:b.config})},[b.enabled]);let oe=(0,I.useRef)(null);oe.current===null&&(oe.current={handleTextChange:h=>f.current?.handleTextChange(h),handleKeyDown:h=>{let J="nativeEvent"in h?h.nativeEvent:h;f.current?.handleKeyDown(J)},setFocused:h=>f.current?.setFocused(h),startEditingParam:h=>f.current?.startEditingParam(h),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:h=>f.current?.handleCaretAfterInput(h),handleCaretMove:h=>f.current?.handleCaretMove(h),replaceEditingRange:h=>f.current?.replaceEditingRange(h)??!1,setActivePill:h=>f.current?.setActivePill(h),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),recordSubmit:h=>f.current?.recordSubmit(h),selectOption:h=>f.current?.selectOption(h),selectProduct:h=>f.current?.selectProduct(h),setActiveDropdownIndex:h=>f.current?.setActiveDropdownIndex(h),clearHighlight:h=>f.current?.clearHighlight(h),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let v=oe.current,De=(0,I.useCallback)(h=>{let J=h.target.value,st=J.length>0&&!h.nativeEvent?.isComposing&&J[0]!==J[0].toUpperCase()?J[0].toUpperCase()+J.slice(1):J;f.current?.handleTextChange(st)},[]),We=(0,I.useCallback)(h=>{f.current?.handleKeyDown(h.nativeEvent)},[]),be=f.current,p=Oe??fa,ve=R!==void 0?R:p.text,Le=P!==void 0?P:p.completedParams,Ie=p.actionableSuggestions,Me=Ie[0],Ee=be?.listboxId??"",Ne=p.activeDropdownIndex>=0&&be?`${Ee}-option-${p.activeDropdownIndex}`:void 0,q=p.editingParam,Te=p.editingIdentified,Be=q?{parameter:q.suggestionParameter,text:q.suggestionPlaceholder,required:!0,options:q.options}:Te?{parameter:Te.parameter,text:(0,Ke.identifiedParamLabel)(Te.parameter),required:!0,options:[]}:null,Qe=p.dropdownSuggestion??Be??Me,rt=Be?[Be]:Ie,_e=(0,Ke.dateSelectionFor)(p),Ye=!be||p.dropdownLoading;return{completedParams:Le,skippedParams:p.skippedParams,identifiedParams:p.identifiedParams,suggestionPills:Ie,setActivePill:v.setActivePill,skipActivePill:v.skipActivePill,removeLastParam:v.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:v.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:Ye,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:Ee,error:p.error,products:p.products,customFields:p.customFields,selectProduct:v.selectProduct,handleTextChange:v.handleTextChange,handleKeyDown:v.handleKeyDown,setFocused:v.setFocused,editingParam:q,editingIdentified:Te,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:v.startEditingParam,exitEditMode:v.exitEditMode,handleCaretAfterInput:v.handleCaretAfterInput,handleCaretMove:v.handleCaretMove,replaceEditingRange:v.replaceEditingRange,inputProps:{value:ve,placeholder:p.placeholderText||void 0,onChange:De,onKeyDown:We,onFocus:v.handleFocus,onBlur:v.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":Ne,"aria-autocomplete":"list","aria-controls":Ee},reset:v.reset,recordSubmit:v.recordSubmit,dropdownProps:{suggestions:Qe?[{...Qe,options:p.dropdownOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:v.selectOption,onHighlight:v.setActiveDropdownIndex,onUnhighlight:v.clearHighlight,isOpen:p.isDropdownOpen,id:Ee,pills:rt,activeSelected:p.isActivePillSelected,onPillClick:v.setActivePill,onSkip:v.skipActivePill,showSkipButton:(Z??!0)&&!q&&!Te,showOptionIcons:y??!0,showOptionImages:O??!0,showOptionCounts:A??!0,skipDisabled:p.inSelectionAnimation,isLoading:Ye,skeletonExiting:p.skeletonExiting,isInputEmpty:ve.trim().length===0,products:p.products,productImageFallback:D,onProductSelect:v.selectProduct,onProductFocusChange:v.setFocused,formatType:p.activeFormatType,dateView:p.dateView,selectedDateIso:_e.selectedIso,selectedDateRange:_e.selectedRange,dateRangeStart:_e.rangeStart,onPreviousMonth:v.showPreviousMonth,onNextMonth:v.showNextMonth,optionsPosition:x??"below"}}}var G=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react"),nt;function ba(){if(nt!==void 0)return nt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),nt=e.contentEditable==="plaintext-only",nt}function Gt(e){let{segments:a,showChipIcons:t=!0,showChipImages:n=!0,newParamId:i,editingParam:r,editingIdentified:o,editingAnchor:d,caretOffset:k,placeholderText:w,isFocused:x,isDropdownOpen:E,listboxId:m,activeDescendantId:y,autoFocus:O,handleTextChange:A,handleKeyDown:Z,handleCaretAfterInput:H,handleCaretMove:D,startEditingParam:T,replaceEditingRange:F,setFocused:R}=e,P=(0,S.useRef)(null),Q=(0,S.useRef)(!1),pe=(0,S.useRef)(""),ye=(0,S.useRef)(""),he=(0,S.useRef)(null),ke=(0,S.useRef)(0);he.current=k,(0,S.useEffect)(()=>{if(!O)return;let c=P.current;if(!c)return;document.activeElement===c?R(!0):c.focus();let g=c.ownerDocument??document,u=g.getSelection(),b=u&&u.rangeCount>0&&c.contains(u.anchorNode);if(u&&!b){let C=g.createRange();C.selectNodeContents(c),C.collapse(!0),u.removeAllRanges(),u.addRange(C)}},[O,R]),(0,S.useEffect)(()=>{let c=P.current;if(!c)return;let g=c.ownerDocument??document,u=()=>{let b=g.getSelection();if(!b||b.rangeCount===0||!b.anchorNode||!c.contains(b.anchorNode))return;let C=b.anchorNode,l=C.nodeType===Node.ELEMENT_NODE?C:C.parentElement,_=(b.isCollapsed?l?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,oe=r?.id??o?.id??null;if(_&&_!==oe){T(_);return}performance.now()-ke.current<50||D((0,G.getCursorOffset)(c))};return g.addEventListener("selectionchange",u),()=>g.removeEventListener("selectionchange",u)},[r,o,T,D]),(0,S.useEffect)(()=>{let c=P.current;if(!c)return;let g=u=>{let b=(0,G.chipIdFromTap)(c,u.target);b&&(T(b),(0,G.keepCaretOnChip)(c,b))};return c.addEventListener("click",g),()=>c.removeEventListener("click",g)},[T]),(0,S.useLayoutEffect)(()=>{let c=P.current;c&&(0,G.renderEditableContent)({input:c,segments:a,newParamId:i,editingParamId:r?.id??null,placeholderText:w??"",isFocused:x,showChipIcons:t,showChipImages:n})},[a,i,r,w,x,t,n]),(0,S.useLayoutEffect)(()=>{let c=pe.current,g=i??"";if(pe.current=g,!g||g===c)return;let u=P.current;if(!u)return;u.focus();let b=he.current??(0,G.plainTextLength)(u);(0,G.setCursorOffset)(u,b)},[i]),(0,S.useLayoutEffect)(()=>{let c=ye.current,g=r?.id??"";if(ye.current=g,!g||g===c||d==null)return;let u=P.current;u&&(0,G.setCursorOffset)(u,d)},[r,d]);let $=(0,S.useCallback)(()=>{if(Q.current)return;let c=P.current;if(!c)return;let g=(0,G.extractPlainText)(c),b=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;A(b)},[A]),f=(0,S.useCallback)(()=>{ke.current=performance.now(),$();let c=P.current;c&&H((0,G.getCursorOffset)(c))},[$,H]);(0,S.useEffect)(()=>{let c=P.current;if(!c)return;let g=u=>{let b=u,C=b.inputType;if(C==="insertParagraph"||C==="insertLineBreak"||C==="insertFromDrop"){u.preventDefault();return}if(C.startsWith("insert")||C.startsWith("delete")){let l=C.startsWith("delete")?"":b.data??"";F(l)&&u.preventDefault()}};return c.addEventListener("beforeinput",g),()=>c.removeEventListener("beforeinput",g)},[F]);let Oe=(0,S.useCallback)(()=>{Q.current=!0},[]),Ce=(0,S.useCallback)(()=>{Q.current=!1,$()},[$]),Pe=(0,S.useCallback)(c=>{c.preventDefault();let g=P.current;if(!g)return;let u=(c.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let b=g.ownerDocument??document,C=b.getSelection();if(!C||C.rangeCount===0)return;let l=C.getRangeAt(0);if(!g.contains(l.startContainer))return;l.deleteContents();let W=b.createTextNode(u);l.insertNode(W),l.setStartAfter(W),l.collapse(!0),C.removeAllRanges(),C.addRange(l),$()},[$]),ue=(0,S.useCallback)(c=>Z(c),[Z]),Se=(0,S.useCallback)(()=>R(!0),[R]),me=(0,S.useCallback)(()=>R(!1),[R]),ie=(0,S.useCallback)(()=>P.current?.focus(),[]),X=(0,S.useCallback)(()=>P.current?.blur(),[]),ge=(0,S.useCallback)(()=>{let c=P.current;return c?(0,G.extractPlainText)(c):""},[]),fe=ba()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:fe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":E,"aria-activedescendant":y,spellCheck:!0,enterKeyHint:"send",onInput:f,onKeyDown:ue,onCompositionStart:Oe,onCompositionEnd:Ce,onPaste:Pe,onFocus:Se,onBlur:me},getPlainText:ge,focus:ie,blur:X}}var ae=require("react/jsx-runtime");function va(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wt=(0,N.forwardRef)(function({onSubmit:a,onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,className:o,apiConfig:d,additionalContext:k,visitorId:w,columns:x,pillPlacement:E="dropdown",mode:m="auto",optionsPosition:y="below",animations:O=!0,dropdownTrigger:A,closeDropdownOnBlur:Z,showNonTappableOptions:H,showOptionIcons:D=!0,showChipIcons:T=!0,showChipImages:F=!0,showOptionImages:R=!0,showOptionCounts:P=!0,showSkipButton:Q,showProducts:pe,productsLayout:ye,productImageFallback:he,autoFocus:ke=!0,onFocus:$,onBlur:f,value:Oe,completedParams:Ce,onChange:Pe,onParamsChange:ue,products:Se,onProductSelect:me,submitButton:ie,resetOnSubmit:X=!0},ge){let fe=(0,N.useRef)(null),c=(0,N.useRef)(null),g=(0,N.useRef)(()=>{}),u=(0,N.useRef)(null),b=(0,N.useRef)(null);(0,N.useEffect)(()=>{let L=fe.current;if(L)return u.current?u.current.setMode(m):u.current=new Ge.ModeController(L,m),()=>{u.current?.destroy(),u.current=null}},[m]);let C=(0,N.useCallback)(L=>{let ne=b.current?.current;ne&&(ne.focus(),(0,Ge.setCursorOffset)(ne,L))},[]),{completedParams:l,skippedParams:W,identifiedParams:_,isReady:oe,customFields:v,suggestionPills:De,setActivePill:We,skipActivePill:be,segments:p,newParamId:ve,clearNewParamId:Le,placeholderText:Ie,isFocused:Me,isDropdownOpen:Ee,isActivePillSelected:Ne,isLoading:q,activeIndex:Te,listboxId:Be,handleTextChange:Qe,handleKeyDown:rt,setFocused:_e,editingParam:Ye,editingIdentified:h,editingAnchor:J,caretOffset:B,startEditingParam:st,handleCaretAfterInput:_t,handleCaretMove:qt,replaceEditingRange:Ut,dropdownProps:jt,reset:Ze,recordSubmit:bt}=ot({onSubmit:L=>g.current(L),onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,apiConfig:d,additionalContext:k,visitorId:w,columns:x,dropdownTrigger:A,optionsPosition:y,closeDropdownOnBlur:Z,showNonTappableOptions:H,showOptionIcons:D,showOptionImages:R,showOptionCounts:P,showSkipButton:Q,showProducts:pe,onFocus:$,onBlur:f,value:Oe,completedParams:Ce,onChange:Pe,onParamsChange:ue,products:Se,onProductSelect:me,source:"full-sdk",setCursor:C});(0,N.useEffect)(()=>{if(!ve)return;let L=window.setTimeout(()=>Le(),650);return()=>window.clearTimeout(L)},[ve,Le]);let Qt=Te>=0?`${Be}-option-${Te}`:void 0,{inputRef:lt,editorProps:Yt,focus:$e,blur:vt,getPlainText:wt}=Gt({segments:p,newParamId:ve,editingParam:Ye,editingIdentified:h,editingAnchor:J,caretOffset:B,placeholderText:Ie,isFocused:Me,showChipIcons:T,showChipImages:F,isDropdownOpen:Ee,listboxId:Be,activeDescendantId:Qt,autoFocus:ke,handleTextChange:Qe,handleKeyDown:rt,handleCaretAfterInput:_t,handleCaretMove:qt,startEditingParam:st,replaceEditingRange:Ut,setFocused:_e});b.current=lt,(0,N.useLayoutEffect)(()=>{let L=c.current,ne=lt.current;if(!L||!ne)return;let qe=()=>{let yt=L.firstElementChild;if(!yt)return;let Xt=yt.getBoundingClientRect(),Jt=ne.getBoundingClientRect();Xt.top>=Jt.bottom-2?L.setAttribute("data-aia-pill-wrapped",""):L.removeAttribute("data-aia-pill-wrapped")};qe();let xt=new ResizeObserver(qe);return xt.observe(ne),()=>xt.disconnect()},[p,De.length,q,lt]),(0,N.useImperativeHandle)(ge,()=>({focus:$e,blur:vt,reset:Ze,setMode:L=>u.current?.setMode(L),skipActivePill:be}),[$e,vt,Ze,be]);let Ve=!!p.length||l.length>0,dt=(0,N.useCallback)(L=>{if(!Ve)return;let ne=wt(),qe=(0,Ge.buildSubmitResult)(ne,l,W,{identifiedParams:_,isReady:oe,customFields:v});L&&bt(qe),a(qe),X&&Ze()},[bt,X,Ve,l,W,_,oe,v,a,Ze,wt]);g.current=()=>dt(!1);let Zt=(0,N.useCallback)(L=>{L.target?.closest("[data-aia-pill]")||$e()},[$e]),$t=E==="inline",Vt=E==="dropdown";return(0,ae.jsxs)("div",{ref:fe,className:`magicx-aia ${ze.container} ${o??""}`,"data-pill-placement":E,"data-options-position":y,"data-animations":O?"on":"off","data-mode":va(m),children:[(0,ae.jsx)(at,{...jt,showPills:Vt,productsLayout:ye,productImageFallback:he}),(0,ae.jsxs)("div",{className:ze.inputWrapper,"data-aia-input-wrapper":"",onClick:Zt,children:[(0,ae.jsxs)("div",{className:ze.editorArea,"data-aia-editor":"",children:[(0,ae.jsx)("div",{...Yt,className:ze.input,"data-aia-input":""}),$t&&(q||De.length>0)&&(0,ae.jsx)("span",{ref:c,className:ze.pillListContainer,"data-aia-pill-list-container":"",children:(0,ae.jsx)(Je,{pills:De,activePillIndex:0,activeSelected:Ne,onSelectPill:We,loading:q})})]}),ie===null?null:ie===void 0?(0,ae.jsx)(Ht,{disabled:!Ve,onClick:()=>dt(!0)}):(0,ae.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ze.submitSlot,onClick:L=>{Ve&&(L.stopPropagation(),dt(!0))},children:ie})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2269
|
+
`,document.head.appendChild(e)}var Bt={submitButton:"aia-submitButton-otz7H"};var it=require("react/jsx-runtime");function Ht({disabled:e,onClick:a}){return(0,it.jsx)("button",{type:"button","data-aia-submit":"",className:Bt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,it.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,it.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ge=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var gt=require("react");function Ft(e){let a=(0,gt.useRef)(e);a.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=(0,gt.useRef)({key:"",overrides:void 0});if(n.current.key!==t){let i={};for(let r of Object.keys(e??{})){let o=(l,w,x)=>{let y=a.current?.[r];return y?y(l,w,x):[]};i[r]=o}n.current={key:t,overrides:e?i:void 0}}return{overrides:n.current.overrides,key:t}}var ft=require("react");function Kt(e){let a=(0,ft.useRef)(e);a.current=e;let t=(0,ft.useRef)(null);t.current===null&&(t.current={fetch:(i,r)=>{let o=a.current;return o?o.fetch(i,r):Promise.reject(new Error("products config removed"))},transform:i=>a.current?.transform(i)??[],get limit(){return a.current?.limit}});let n=e!==void 0;return{config:n?t.current:void 0,enabled:n}}var fa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],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,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ot({onSubmit:e,onResult:a,onError:t,optionOverrides:n,maskCompletedText:i,apiConfig:r,additionalContext:o,visitorId:l,columns:w=2,dropdownTrigger:x,optionsPosition:y,closeDropdownOnBlur:E,showNonTappableOptions:m,showOptionIcons:k,showOptionImages:R,showOptionCounts:B,showSkipButton:H,showProducts:F,productImageFallback:L="image",onFocus:T,onBlur:K,value:A,completedParams:C,onChange:$,onParamsChange:ie,products:_,onProductSelect:ue,source:ke,setCursor:V}){let f=(0,I.useRef)(null),[De,Ce]=(0,I.useState)(null),Pe=(0,I.useRef)(e);Pe.current=e;let me=(0,I.useRef)(a);me.current=a;let Se=(0,I.useRef)(t);Se.current=t;let ge=(0,I.useRef)($);ge.current=$;let ne=(0,I.useRef)(ie);ne.current=ie;let J=(0,I.useRef)(T);J.current=T;let fe=(0,I.useRef)(K);fe.current=K;let be=(0,I.useRef)(V);be.current=V;let c=(0,I.useRef)(ue);c.current=ue;let g=(0,I.useRef)(l);g.current=l;let u=(0,I.useRef)(()=>{let h=g.current;return typeof h=="function"?h():h}).current,b=Kt(_),P=Ft(n);(0,I.useEffect)(()=>{if(typeof document>"u")return;let h=new Ge.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:o,visitorId:u,optionOverrides:P.overrides,maskCompletedText:i,columns:w,dropdownTrigger:x,optionsPosition:y,closeDropdownOnBlur:E,showNonTappableOptions:m,showProducts:F,source:ke,value:A,completedParams:C,onSubmit:(...N)=>Pe.current?.(...N),onResult:(...N)=>me.current?.(...N),onError:(...N)=>Se.current?.(...N),onChange:(...N)=>ge.current?.(...N),onParamsChange:(...N)=>ne.current?.(...N),onFocus:()=>J.current?.(),onBlur:()=>fe.current?.(),onProductSelect:N=>c.current?.(N),setCursor:N=>be.current?.(N),products:b.config});f.current=h,Ce(h.getState());let ee=h.subscribe(N=>Ce(N));return()=>{ee(),h.destroy(),f.current===h&&(f.current=null)}},[]),(0,I.useEffect)(()=>{A!==void 0&&f.current?.setValue(A)},[A]),(0,I.useEffect)(()=>{C!==void 0&&f.current?.setCompletedParams(C)},[C]);let d=JSON.stringify(r??null),q;try{q=JSON.stringify(o??null)}catch{q="[unstringifiable]"}(0,I.useEffect)(()=>{f.current?.update({apiConfig:r,additionalContext:o,optionOverrides:P.overrides,dropdownTrigger:x,optionsPosition:y,closeDropdownOnBlur:E,showNonTappableOptions:m,showProducts:F})},[d,q,P.key,x,y,E,m,F]);let U=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!U.current){U.current=!0;return}f.current?.update({products:b.config})},[b.enabled]);let re=(0,I.useRef)(null);re.current===null&&(re.current={handleTextChange:h=>f.current?.handleTextChange(h),handleKeyDown:h=>{let ee="nativeEvent"in h?h.nativeEvent:h;f.current?.handleKeyDown(ee)},setFocused:h=>f.current?.setFocused(h),startEditingParam:h=>f.current?.startEditingParam(h),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:h=>f.current?.handleCaretAfterInput(h),handleCaretMove:h=>f.current?.handleCaretMove(h),replaceEditingRange:h=>f.current?.replaceEditingRange(h)??!1,setActivePill:h=>f.current?.setActivePill(h),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),recordSubmit:h=>f.current?.recordSubmit(h),selectOption:h=>f.current?.selectOption(h),selectProduct:h=>f.current?.selectProduct(h),setActiveDropdownIndex:h=>f.current?.setActiveDropdownIndex(h),clearHighlight:h=>f.current?.clearHighlight(h),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let v=re.current,Le=(0,I.useCallback)(h=>{let ee=h.target.value,st=ee.length>0&&!h.nativeEvent?.isComposing&&ee[0]!==ee[0].toUpperCase()?ee[0].toUpperCase()+ee.slice(1):ee;f.current?.handleTextChange(st)},[]),_e=(0,I.useCallback)(h=>{f.current?.handleKeyDown(h.nativeEvent)},[]),ve=f.current,p=De??fa,we=A!==void 0?A:p.text,ze=C!==void 0?C:p.completedParams,Ie=p.actionableSuggestions,Ne=Ie[0],Ee=ve?.listboxId??"",Be=p.activeDropdownIndex>=0&&ve?`${Ee}-option-${p.activeDropdownIndex}`:void 0,j=p.editingParam,Te=p.editingIdentified,He=j?{parameter:j.suggestionParameter,text:j.suggestionPlaceholder,required:!0,options:j.options}:Te?{parameter:Te.parameter,text:(0,Ge.identifiedParamLabel)(Te.parameter),required:!0,options:[]}:null,Ye=p.dropdownSuggestion??He??Ne,rt=He?[He]:Ie,qe=(0,Ge.dateSelectionFor)(p),Ze=!ve||p.dropdownLoading;return{completedParams:ze,skippedParams:p.skippedParams,identifiedParams:p.identifiedParams,suggestionPills:Ie,setActivePill:v.setActivePill,skipActivePill:v.skipActivePill,removeLastParam:v.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:v.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:Ze,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:Ee,error:p.error,products:p.products,customFields:p.customFields,selectProduct:v.selectProduct,handleTextChange:v.handleTextChange,handleKeyDown:v.handleKeyDown,setFocused:v.setFocused,editingParam:j,editingIdentified:Te,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:v.startEditingParam,exitEditMode:v.exitEditMode,handleCaretAfterInput:v.handleCaretAfterInput,handleCaretMove:v.handleCaretMove,replaceEditingRange:v.replaceEditingRange,inputProps:{value:we,placeholder:p.placeholderText||void 0,onChange:Le,onKeyDown:_e,onFocus:v.handleFocus,onBlur:v.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":Be,"aria-autocomplete":"list","aria-controls":Ee},reset:v.reset,recordSubmit:v.recordSubmit,dropdownProps:{suggestions:Ye?[{...Ye,options:p.dropdownOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:v.selectOption,onHighlight:v.setActiveDropdownIndex,onUnhighlight:v.clearHighlight,isOpen:p.isDropdownOpen,id:Ee,pills:rt,activeSelected:p.isActivePillSelected,onPillClick:v.setActivePill,onSkip:v.skipActivePill,showSkipButton:(H??!0)&&!j&&!Te,showOptionIcons:k??!0,showOptionImages:R??!0,showOptionCounts:B??!0,skipDisabled:p.inSelectionAnimation,isLoading:Ze,skeletonExiting:p.skeletonExiting,isInputEmpty:we.trim().length===0,products:p.products,productImageFallback:L,onProductSelect:v.selectProduct,onProductFocusChange:v.setFocused,formatType:p.activeFormatType,dateView:p.dateView,selectedDateIso:qe.selectedIso,selectedDateRange:qe.selectedRange,dateRangeStart:qe.rangeStart,onPreviousMonth:v.showPreviousMonth,onNextMonth:v.showNextMonth,optionsPosition:y??"below"}}}var W=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react"),nt;function ba(){if(nt!==void 0)return nt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),nt=e.contentEditable==="plaintext-only",nt}function Gt(e){let{segments:a,showChipIcons:t=!0,showChipImages:n=!0,newParamId:i,editingParam:r,editingIdentified:o,editingAnchor:l,caretOffset:w,placeholderText:x,isFocused:y,isDropdownOpen:E,listboxId:m,activeDescendantId:k,autoFocus:R,handleTextChange:B,handleKeyDown:H,handleCaretAfterInput:F,handleCaretMove:L,startEditingParam:T,replaceEditingRange:K,setFocused:A}=e,C=(0,S.useRef)(null),$=(0,S.useRef)(!1),ie=(0,S.useRef)(""),_=(0,S.useRef)(""),ue=(0,S.useRef)(null),ke=(0,S.useRef)(0);ue.current=w,(0,S.useEffect)(()=>{if(!R)return;let c=C.current;if(!c)return;document.activeElement===c?A(!0):c.focus();let g=c.ownerDocument??document,u=g.getSelection(),b=u&&u.rangeCount>0&&c.contains(u.anchorNode);if(u&&!b){let P=g.createRange();P.selectNodeContents(c),P.collapse(!0),u.removeAllRanges(),u.addRange(P)}},[R,A]),(0,S.useEffect)(()=>{let c=C.current;if(!c)return;let g=c.ownerDocument??document,u=()=>{let b=g.getSelection();if(!b||b.rangeCount===0||!b.anchorNode||!c.contains(b.anchorNode))return;let P=b.anchorNode,d=P.nodeType===Node.ELEMENT_NODE?P:P.parentElement,U=(b.isCollapsed?d?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,re=r?.id??o?.id??null;if(U&&U!==re){T(U);return}performance.now()-ke.current<50||L((0,W.getCursorOffset)(c))};return g.addEventListener("selectionchange",u),()=>g.removeEventListener("selectionchange",u)},[r,o,T,L]),(0,S.useEffect)(()=>{let c=C.current;if(!c)return;let g=u=>{let b=(0,W.chipIdFromTap)(c,u.target);b&&(T(b),(0,W.keepCaretOnChip)(c,b))};return c.addEventListener("click",g),()=>c.removeEventListener("click",g)},[T]),(0,S.useLayoutEffect)(()=>{let c=C.current;c&&(0,W.renderEditableContent)({input:c,segments:a,newParamId:i,editingParamId:r?.id??null,placeholderText:x??"",isFocused:y,showChipIcons:t,showChipImages:n})},[a,i,r,x,y,t,n]),(0,S.useLayoutEffect)(()=>{let c=ie.current,g=i??"";if(ie.current=g,!g||g===c)return;let u=C.current;if(!u)return;u.focus();let b=ue.current??(0,W.plainTextLength)(u);(0,W.setCursorOffset)(u,b)},[i]),(0,S.useLayoutEffect)(()=>{let c=_.current,g=r?.id??"";if(_.current=g,!g||g===c||l==null)return;let u=C.current;u&&(0,W.setCursorOffset)(u,l)},[r,l]);let V=(0,S.useCallback)(()=>{if($.current)return;let c=C.current;if(!c)return;let g=(0,W.extractPlainText)(c),b=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;B(b)},[B]),f=(0,S.useCallback)(()=>{ke.current=performance.now(),V();let c=C.current;c&&F((0,W.getCursorOffset)(c))},[V,F]);(0,S.useEffect)(()=>{let c=C.current;if(!c)return;let g=u=>{let b=u,P=b.inputType;if(P==="insertParagraph"||P==="insertLineBreak"||P==="insertFromDrop"){u.preventDefault();return}if(P.startsWith("insert")||P.startsWith("delete")){let d=P.startsWith("delete")?"":b.data??"";K(d)&&u.preventDefault()}};return c.addEventListener("beforeinput",g),()=>c.removeEventListener("beforeinput",g)},[K]);let De=(0,S.useCallback)(()=>{$.current=!0},[]),Ce=(0,S.useCallback)(()=>{$.current=!1,V()},[V]),Pe=(0,S.useCallback)(c=>{c.preventDefault();let g=C.current;if(!g)return;let u=(c.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let b=g.ownerDocument??document,P=b.getSelection();if(!P||P.rangeCount===0)return;let d=P.getRangeAt(0);if(!g.contains(d.startContainer))return;d.deleteContents();let q=b.createTextNode(u);d.insertNode(q),d.setStartAfter(q),d.collapse(!0),P.removeAllRanges(),P.addRange(d),V()},[V]),me=(0,S.useCallback)(c=>H(c),[H]),Se=(0,S.useCallback)(()=>A(!0),[A]),ge=(0,S.useCallback)(()=>A(!1),[A]),ne=(0,S.useCallback)(()=>C.current?.focus(),[]),J=(0,S.useCallback)(()=>C.current?.blur(),[]),fe=(0,S.useCallback)(()=>{let c=C.current;return c?(0,W.extractPlainText)(c):""},[]),be=ba()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:be,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":E,"aria-activedescendant":k,spellCheck:!0,enterKeyHint:"send",onInput:f,onKeyDown:me,onCompositionStart:De,onCompositionEnd:Ce,onPaste:Pe,onFocus:Se,onBlur:ge},getPlainText:fe,focus:ne,blur:J}}var oe=require("react/jsx-runtime");function va(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wt=(0,M.forwardRef)(function({onSubmit:a,onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,className:o,apiConfig:l,additionalContext:w,visitorId:x,columns:y,pillPlacement:E="dropdown",mode:m="auto",optionsPosition:k="below",animations:R=!0,dropdownTrigger:B,closeDropdownOnBlur:H,showNonTappableOptions:F,showOptionIcons:L=!0,showChipIcons:T=!0,showChipImages:K=!0,showOptionImages:A=!0,showOptionCounts:C=!0,showSkipButton:$,showProducts:ie,productsLayout:_,productImageFallback:ue,autoFocus:ke=!0,onFocus:V,onBlur:f,value:De,completedParams:Ce,onChange:Pe,onParamsChange:me,products:Se,onProductSelect:ge,submitButton:ne,resetOnSubmit:J=!0},fe){let be=(0,M.useRef)(null),c=(0,M.useRef)(null),g=(0,M.useRef)(()=>{}),u=(0,M.useRef)(null),b=(0,M.useRef)(null);(0,M.useEffect)(()=>{let O=be.current;if(O)return u.current?u.current.setMode(m):u.current=new We.ModeController(O,m),()=>{u.current?.destroy(),u.current=null}},[m]);let P=(0,M.useCallback)(O=>{let se=b.current?.current;se&&(se.focus(),(0,We.setCursorOffset)(se,O))},[]),{completedParams:d,skippedParams:q,identifiedParams:U,isReady:re,customFields:v,suggestionPills:Le,setActivePill:_e,skipActivePill:ve,segments:p,newParamId:we,clearNewParamId:ze,placeholderText:Ie,isFocused:Ne,isDropdownOpen:Ee,isActivePillSelected:Be,isLoading:j,activeIndex:Te,listboxId:He,handleTextChange:Ye,handleKeyDown:rt,setFocused:qe,editingParam:Ze,editingIdentified:h,editingAnchor:ee,caretOffset:N,startEditingParam:st,handleCaretAfterInput:_t,handleCaretMove:qt,replaceEditingRange:Ut,dropdownProps:jt,reset:$e,recordSubmit:bt}=ot({onSubmit:O=>g.current(O),onResult:t,onError:n,optionOverrides:i,maskCompletedText:r,apiConfig:l,additionalContext:w,visitorId:x,columns:y,dropdownTrigger:B,optionsPosition:k,closeDropdownOnBlur:H,showNonTappableOptions:F,showOptionIcons:L,showOptionImages:A,showOptionCounts:C,showSkipButton:$,showProducts:ie,onFocus:V,onBlur:f,value:De,completedParams:Ce,onChange:Pe,onParamsChange:me,products:Se,onProductSelect:ge,source:"full-sdk",setCursor:P});(0,M.useEffect)(()=>{if(!we)return;let O=window.setTimeout(()=>ze(),650);return()=>window.clearTimeout(O)},[we,ze]);let Qt=Te>=0?`${He}-option-${Te}`:void 0,{inputRef:lt,editorProps:Yt,focus:Ve,blur:vt,getPlainText:wt}=Gt({segments:p,newParamId:we,editingParam:Ze,editingIdentified:h,editingAnchor:ee,caretOffset:N,placeholderText:Ie,isFocused:Ne,showChipIcons:T,showChipImages:K,isDropdownOpen:Ee,listboxId:He,activeDescendantId:Qt,autoFocus:ke,handleTextChange:Ye,handleKeyDown:rt,handleCaretAfterInput:_t,handleCaretMove:qt,startEditingParam:st,replaceEditingRange:Ut,setFocused:qe});b.current=lt,(0,M.useLayoutEffect)(()=>{let O=c.current,se=lt.current;if(!O||!se)return;let Ue=()=>{let yt=O.firstElementChild;if(!yt)return;let Xt=yt.getBoundingClientRect(),Jt=se.getBoundingClientRect();Xt.top>=Jt.bottom-2?O.setAttribute("data-aia-pill-wrapped",""):O.removeAttribute("data-aia-pill-wrapped")};Ue();let xt=new ResizeObserver(Ue);return xt.observe(se),()=>xt.disconnect()},[p,Le.length,j,lt]),(0,M.useImperativeHandle)(fe,()=>({focus:Ve,blur:vt,reset:$e,setMode:O=>u.current?.setMode(O),skipActivePill:ve}),[Ve,vt,$e,ve]);let Xe=!!p.length||d.length>0,dt=(0,M.useCallback)(O=>{if(!Xe)return;let se=wt(),Ue=(0,We.buildSubmitResult)(se,d,q,{identifiedParams:U,isReady:re,customFields:v});O&&bt(Ue),a(Ue),J&&$e()},[bt,J,Xe,d,q,U,re,v,a,$e,wt]);g.current=()=>dt(!1);let Zt=(0,M.useCallback)(O=>{O.target?.closest("[data-aia-pill]")||Ve()},[Ve]),$t=E==="inline",Vt=E==="dropdown";return(0,oe.jsxs)("div",{ref:be,className:`magicx-aia ${Me.container} ${o??""}`,"data-pill-placement":E,"data-options-position":k,"data-animations":R?"on":"off","data-mode":va(m),children:[(0,oe.jsx)(at,{...jt,showPills:Vt,productsLayout:_,productImageFallback:ue}),(0,oe.jsxs)("div",{className:Me.inputWrapper,"data-aia-input-wrapper":"",onClick:Zt,children:[(0,oe.jsxs)("div",{className:Me.editorArea,"data-aia-editor":"",children:[(0,oe.jsx)("div",{...Yt,className:Me.input,"data-aia-input":""}),$t&&(j||Le.length>0)&&(0,oe.jsx)("span",{ref:c,className:Me.pillListContainer,"data-aia-pill-list-container":"",children:(0,oe.jsx)(et,{pills:Le,activePillIndex:0,activeSelected:Be,onSelectPill:_e,loading:j})})]}),ne===null?null:ne===void 0?(0,oe.jsx)(Ht,{disabled:!Xe,onClick:()=>dt(!0)}):(0,oe.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Me.submitSlot,onClick:O=>{Xe&&(O.stopPropagation(),dt(!0))},children:ne})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2270
2270
|
//# sourceMappingURL=index.js.map
|