@magicx-eng/ai-autocomplete-react 0.33.4 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/index.d.mts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as wn,cellDay as xn,cellIso as yn,DATE_RANGE_META_END as kn,DATE_RANGE_META_START as Cn,DEFAULT_OPTION_COUNT_UNIT as Pn,dateCellMarks as Sn,formatDate as In,formatDateRange as En,formatOptionCount as Tn,isoDate as An,monthLabel as Rn,optionCountLabel as On,optionHasImage as Dn,optionImageSources as Ln,optionImageSrc as zn,optionLabel as Mn,PRODUCT_PATH_PREFIX as Nn,parseDate as Bn,parseLooseDate as Hn,parseLooseDateRange as Fn,productFromMatchedItem as Kn,productImageSources as Gn,productsFromCustomFields as Wn,sanitizeOptionIconSvg as _n,selectedRangeFor as Un,visibleDateRange as qn,WEEKDAY_LABELS as jn,withSkippedParams as Qn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as vi,useCallback as ht,useEffect as Qt,useImperativeHandle as wi,useLayoutEffect as xi,useRef as Fe}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
262
262
|
opacity: 0;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,document.head.appendChild(e)}var
|
|
265
|
+
`,document.head.appendChild(e)}var Ie={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"};import{attachScrollArrow as Xa,containScroll as Ja,isCalendarFormat as ei,uiStringsFor as ti}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $e,useRef as Ze,useState as ai}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
1045
1045
|
opacity: 0.25;
|
|
1046
1046
|
}
|
|
1047
1047
|
}
|
|
1048
|
-
`,document.head.appendChild(e)}var
|
|
1048
|
+
`,document.head.appendChild(e)}var re={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"};import{cellDay as aa,cellIso as Ae,dateCellMarks as ia,isoDate as oa,monthLabel as na,visibleDateRange as ra,WEEKDAY_LABELS as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as la}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
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 O={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"};import{jsx as ae,jsxs as xt}from"react/jsx-runtime";var da=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function yt({options:e,activeIndex:n,listboxId:t,view:i,selection:r,onSelect:o,onHighlight:a,onUnhighlight:c,onPreviousMonth:d,onNextMonth:y}){let C=oa(new Date),P=ra({pendingStart:r.rangeStart,highlightedIso:Ae(e[n]),selected:r.selectedRange});return xt("div",{className:O.datepicker,"data-aia-datepicker":"",children:[xt("div",{className:O.header,children:[ae("button",{type:"button",tabIndex:-1,className:O.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:d,children:"\u2039"}),ae("span",{className:O.month,"data-aia-date-month":"","aria-live":"polite",children:na(i)}),ae("button",{type:"button",tabIndex:-1,className:O.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:y,children:"\u203A"})]}),ae("div",{className:O.weekdays,"aria-hidden":"true",children:sa.map((u,f)=>ae("span",{className:O.weekday,children:u},da[f]))}),ae("div",{className:O.grid,"data-aia-date-grid":"",children:e.map((u,f)=>ae(ca,{option:u,id:`${t}-option-${f}`,index:f,isHighlighted:f===n&&u.is_tappable,isToday:Ae(u)===C,isPast:Ae(u)!=null&&Ae(u)<C,marks:ia(Ae(u),{selectedIso:r.selectedIso,range:P}),onSelect:o,onHighlight:a,onUnhighlight:c},Ae(u)??`pad-${f}`))})]})}function ca({option:e,id:n,index:t,isHighlighted:i,isToday:r,isPast:o,marks:a,onSelect:c,onHighlight:d,onUnhighlight:y}){let[C,P]=la(!1),u=aa(e);if(u==null)return ae("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${O.cell} ${O.blank}`});let f=()=>{P(!0),c(e),setTimeout(()=>P(!1),170)},I=[O.cell,O.day,o?O.past:"",i?O.highlighted:"",r?O.today:"",a.inRange?O.inRange:"",a.selected?O.selected:"",C?O.pressed:""].filter(Boolean).join(" ");return ae("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:I,onClick:f,onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),f())},onMouseEnter:()=>d(t),onMouseLeave:y?()=>y(t):void 0,children:ae("span",{className:O.number,children:u})})}import{ATTRIBUTION_URL as pa,buildAttributionUrl as ha,getFooterHint as ua,uiStringsFor as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ga,useState as fa}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
1248
1248
|
.aia-cluster[data-justify="around"] {
|
|
1249
1249
|
justify-content: space-around;
|
|
1250
1250
|
}
|
|
1251
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1251
|
+
`,document.head.appendChild(e)}import{jsx as kt}from"react/jsx-runtime";function Be({gap:e,align:n="center",justify:t="start",noWrap:i=!1,inline:r=!1,className:o,children:a,...c}){let d=e?{"--aia-cluster-gap":e}:void 0,y={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":i||void 0,"data-inline":r||void 0,style:d,...c};return r?kt("span",{...y,children:a}):kt("div",{...y,children:a})}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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
1395
1395
|
justify-content: flex-end;
|
|
1396
1396
|
}
|
|
1397
1397
|
}
|
|
1398
|
-
`,document.head.appendChild(e)}var
|
|
1398
|
+
`,document.head.appendChild(e)}var se={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"};import{jsx as He,jsxs as it}from"react/jsx-runtime";function Ct({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=ma()}){let{key:i,hint:r}=ua(e,n,t),[o,a]=fa(pa);return ga(()=>{a(ha())},[]),He("footer",{className:se.footer,"data-aia-footer":"",children:it(Be,{justify:"between",noWrap:!0,className:se.row,children:[it(Be,{gap:"5px",className:se.hintGroup,children:[He("kbd",{className:se.key,children:i}),He("span",{className:se.hint,children:r})]}),it("a",{className:se.brandLink,href:o,target:"_blank",rel:"noopener noreferrer",children:[He("span",{className:se.brand,children:"AI"}),He("span",{className:se.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. */
|
|
@@ -1471,7 +1471,7 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
1471
1471
|
opacity: 0;
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
`,document.head.appendChild(e)}var we={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{jsx as
|
|
1474
|
+
`,document.head.appendChild(e)}var we={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};import{jsx as ba}from"react/jsx-runtime";var ot={selected:1,first:.7,next:.4,last:.2};function Pt({label:e,state:n,rounded:t,loading:i,onClick:r}){let o=[we.pill,t?we.rounded:"",i?we.skeleton:""].filter(Boolean).join(" ");return ba("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:ot[n]},onMouseDown:a=>a.preventDefault(),onClick:i?void 0:r,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1475
1475
|
position: relative;
|
|
1476
1476
|
z-index: 1;
|
|
1477
1477
|
pointer-events: auto;
|
|
@@ -1481,7 +1481,7 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
1481
1481
|
align-items: center;
|
|
1482
1482
|
vertical-align: middle;
|
|
1483
1483
|
}
|
|
1484
|
-
`,document.head.appendChild(e)}var
|
|
1484
|
+
`,document.head.appendChild(e)}var nt={list:"aia-list-qvLqO"};import{jsx as je}from"react/jsx-runtime";var va=[125,69];function St(e){return e===0?"first":e===1?"next":"last"}function Qe({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:i,rounded:r,loading:o}){return o&&e.length===0?je("span",{className:nt.list,"data-aia-pill-list-loading":"",children:va.map((a,c)=>je("span",{"data-aia-pill-skeleton":"",className:`${we.pill} ${r?we.rounded:""} ${we.skeleton}`,style:{width:a,opacity:ot[St(c)]}},`skel-${a}`))}):je("span",{className:nt.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((a,c)=>{let d=!!i&&c===n;return je(Pt,{label:a.text,state:d?"selected":St(c),selected:d,rounded:r,loading:o,onClick:()=>t(c)},`${a.parameter}-${a.text}`)})})}import{attachProductRowWheel as wa,productImageSources as xa,productImageSrc as ya,productInitial as ka,uiStringsFor as Ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Pa,useRef as Sa,useState as Ia}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
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 Q={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"};import{jsx as le,jsxs as Ye}from"react/jsx-runtime";function It({products:e,listboxId:n,onSelect:t,onFocusChange:i,focusable:r=!0,layout:o="row",imageFallback:a="image",strings:c=Ca()}){let d=e.length>0,y=Sa(null);if(Pa(()=>{let P=y.current;if(!(!d||!P))return wa(P)},[d]),!d)return null;let C=`${n}-products-label`;return Ye("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":o,role:"group","aria-labelledby":C,children:[le("div",{className:Q.label,id:C,"data-aia-products-label":"",children:c.products}),le("div",{ref:y,className:Q.row,"data-aia-products-row":"",children:e.map((P,u)=>le(Ea,{product:P,id:`${n}-product-${u}`,onSelect:t,onFocusChange:i,focusable:r,imageFallback:a,soldOut:c.soldOut},P.id))})]})}function Ea({product:e,id:n,onSelect:t,onFocusChange:i,focusable:r,imageFallback:o,soldOut:a}){let c=d=>{d.metaKey||d.ctrlKey||d.shiftKey||d.altKey||d.button!==0||(d.preventDefault(),t(e))};return Ye("a",{id:n,className:Q.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:c,onKeyDown:d=>{d.key!=="Enter"&&d.key!==" "||(d.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:d=>{d.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[le(Ta,{sources:xa(e.imageUrl),title:e.title,fallback:o},ya(e.imageUrl)??""),Ye("span",{className:Q.body,children:[e.vendor?le("span",{className:Q.vendor,children:e.vendor}):null,le("span",{className:Q.title,children:e.title}),e.price?le("span",{className:Q.price,children:e.price}):null,e.available===!1?le("span",{className:Q.badge,children:a}):null]})]})}function Ta({sources:e,title:n,fallback:t}){let[i,r]=Ia(0),o=e[i],a=!!o,c=!a&&t==="initial";return Ye("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!a&&!c?"":void 0,"data-aia-product-initial":c?"":void 0,children:[a?le("img",{className:Q.image,src:o,alt:"",loading:"lazy",decoding:"async",onError:()=>r(d=>d+1)}):null,c?ka(n):null]})}import{isOptionsGridMobileViewport as Wa,measureOptionsGrid as _a,needsOptionsGridMeasurement as Ua,OPTIONS_GRID_MOBILE_QUERY as qa,optionEnterDelayMs as ja,planOptionsGrid as At,sameOptionRows as Qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ya,useLayoutEffect as Za,useRef as Rt,useState as Dt}from"react";import{optionsGridTemplateColumns as Aa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ra,useRef as Oa}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
1801
1801
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1802
1802
|
display: none;
|
|
1803
1803
|
}
|
|
1804
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1804
|
+
`,document.head.appendChild(e)}import{jsx as Da}from"react/jsx-runtime";function Et({min:e="16rem",max:n,gap:t,scroll:i=!1,maxHeight:r,scrollResetKey:o,cols:a,template:c,innerRef:d,className:y,children:C,...P}){let u=Oa(null);Ra(()=>{if(o===void 0)return;let I=u.current;I&&(I.scrollTop=0)},[o]);let f={"--aia-grid-min":e};return n&&(f["--aia-grid-max"]=n),t&&(f["--aia-grid-gap"]=t),r&&(f["--aia-grid-max-height"]=r),a&&(f.gridTemplateColumns=Aa(a)),c&&(f.gridTemplateColumns=c),Da("div",{ref:I=>{u.current=I,d?.(I)},className:y?`aia-grid ${y}`:"aia-grid","data-scroll":i||void 0,style:f,...P,children:C})}import{formatOptionCount as La,OPTION_ENTER_DELAY_VAR as za,optionImageSources as Ma,optionLabel as Na,sanitizeOptionIconSvg as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ha,useMemo as Fa,useRef as Ka,useState as rt}from"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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
2198
2198
|
opacity: 0;
|
|
2199
2199
|
}
|
|
2200
2200
|
}
|
|
2201
|
-
`,document.head.appendChild(e)}var
|
|
2201
|
+
`,document.head.appendChild(e)}var q={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"};import{jsx as Ee,jsxs as Ga}from"react/jsx-runtime";function Tt({option:e,isHighlighted:n,onSelect:t,onHighlight:i,onUnhighlight:r,id:o,loading:a,showIcon:c=!0,showImage:d=!0,showCount:y=!0,scrollHint:C,enterDelayMs:P=0}){let[u]=rt(P),[f,I]=rt(!1),D=d?Ma(e.image_url):[],L=D[0]??null,[K,E]=rt([]),S=D.find(B=>!K.includes(B))??null,z=Fa(()=>!L&&c&&e.icon_svg?Ba(e.icon_svg):null,[L,c,e.icon_svg]),M=y?La(e.item_count):null,k=Ka(void 0);Ha(()=>()=>clearTimeout(k.current),[]);let N=()=>{a||!e.is_tappable||f||(I(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>I(!1),170))},Z=[q.item,n&&!a?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,f?q.pressed:"",C?q.scrollHint:""].filter(Boolean).join(" ");return Ee("div",{id:o,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":z&&e.icon?e.icon:void 0,"data-aia-image":L?"":void 0,"data-aia-item-count":M!==null?e.item_count:void 0,"aria-selected":n,className:Z,style:{[za]:`${u}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:N,onKeyDown:B=>{!a&&e.is_tappable&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),N())},onMouseEnter:!a&&e.is_tappable?i:void 0,onMouseLeave:r,children:Ga("span",{className:q.content,children:[L&&Ee("span",{className:`${q.image} magicx-aia-option-image`,"aria-hidden":"true",children:Ee("img",{src:S??L,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:S===null,onError:()=>{S!==null&&E(B=>[...B,S])}})}),z&&Ee("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:z}}),Ee("span",{className:q.text,children:Na(e)}),e.tag&&Ee("span",{className:q.tag,children:e.tag}),M!==null&&Ee("span",{className:`${q.count} magicx-aia-option-count`,children:M})]})})}import{jsx as Ot}from"react/jsx-runtime";function $a(){let[e,n]=Dt(Wa);return Ya(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(qa),i=()=>n(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function Lt({options:e,activeIndex:n,onSelect:t,onHighlight:i,onUnhighlight:r,listboxId:o,loading:a,groupKey:c="",optionsPosition:d="below",showIcons:y=!0,showImages:C=!0,showCounts:P=!0}){let u=$a(),f=Rt(null),[I,D]=Dt(null),L=Rt(null);Za(()=>{if(a&&Qa(L.current,e))return;L.current=a?null:e;let E=f.current,z=E&&!a&&Ua(e.length,u)?_a(E):null;D(z?At(e.length,u,z.rowWidths,z.gridWidth):null)},[e,u,a]);let K=I??At(e.length,u,null,null);return Ot(Et,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:c,template:K.template,maxHeight:K.maxHeight,innerRef:E=>{f.current=E},"data-aia-group":c,children:e.map((E,S)=>Ot(Tt,{option:E,isHighlighted:S===n,onSelect:t,onHighlight:()=>i(S),onUnhighlight:r?()=>r(S):void 0,id:`${o}-option-${S}`,loading:a,showIcon:y,showImage:C,showCount:P,scrollHint:!a&&K.scrollHintIndices.includes(S),enterDelayMs:a?0:ja(S,K.cols,e.length,d)},`${c}\0${E.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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
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)}import{jsx as
|
|
2216
|
+
`,document.head.appendChild(e)}import{jsx as Va}from"react/jsx-runtime";function zt({space:e,align:n="stretch",className:t,children:i,...r}){let o=e?{"--aia-stack-space":e}:void 0;return Va("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:o,...r,children:i})}import{jsx as Y,jsxs as st}from"react/jsx-runtime";var ii=[159,119,164],oi=()=>{},Mt=()=>{};function ni(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=ai(n);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>i(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ri(e,n){let t=Ze(null);$e(()=>{let i=e.current,r=n.current;if(!i||!r)return;let o=i.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==o&&(t.current.controller.destroy(),t.current=null),o&&!t.current){t.current={grid:o,controller:Xa({dropdown:i,grid:o,button:r})};return}t.current?.controller.update()}),$e(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function lt({suggestions:e,activeIndex:n,onSelect:t,onHighlight:i,onUnhighlight:r,isOpen:o,id:a,className:c,pills:d,onPillClick:y,showPills:C=!0,onSkip:P,showSkipButton:u=!0,showOptionIcons:f=!0,showOptionImages:I=!0,showOptionCounts:D=!0,skipDisabled:L=!1,activeSelected:K=!1,isLoading:E=!1,skeletonExiting:S=!1,isInputEmpty:z=!1,language:M,products:k,onProductSelect:N,onProductFocusChange:Z,productsLayout:B="row",productImageFallback:de="image",formatType:V="options",dateView:W=null,selectedDateIso:xe=null,selectedDateRange:ce=null,dateRangeStart:m=null,onPreviousMonth:ye,onNextMonth:pe,optionsPosition:ie="below",mode:he}){let oe=ni(he),ue=oe!==void 0,_=Ze(null),X=Ze(null);ri(_,X),$e(()=>{if(_.current)return Ja(_.current)},[]);let s=e[0]?.options??[],g=!!(d&&d.length>0&&y),b=!!(k&&k.length>0),v=o&&(s.length>0||C&&g||E||b),w={suggestions:e,activeIndex:n,pills:d,showPills:C,showSkipButton:u,showOptionIcons:f,showOptionImages:I,showOptionCounts:D,skipDisabled:L,activeSelected:K,isLoading:E,skeletonExiting:S,isInputEmpty:z,products:k,formatType:V,dateView:W,selectedDateIso:xe,selectedDateRange:ce,dateRangeStart:m},R=Ze(w);v&&(R.current=w);let p=v?w:R.current,H=ti(M),U=p.suggestions[0],j=U?.options??[],Te=p.activeIndex>=0&&!!j[p.activeIndex]?.is_tappable,J=!!(p.pills&&p.pills.length>0&&y),me=p.showPills&&J,ke=p.showPills&&!J&&p.isLoading,x=me||ke,ge=J&&p.showSkipButton&&!p.isInputEmpty&&!!P,fe=p.pills?.[0]?.text,ne=ei(p.formatType)&&p.dateView!=null,h=j.length>0&&!ne,Ce=j.length>0&&ne&&!p.isLoading,Le=p.isLoading&&!h&&!Ce,be=p.products??[];return st("div",{ref:_,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":ie,"data-mode":oe,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":be.length>0?"":void 0,className:`${ue?"magicx-aia ":""}${re.dropdown} ${v?re.visible:""} ${c??""}`,onMouseDown:ee=>ee.preventDefault(),children:[st(zt,{space:"8px",children:[(x||ge)&&st(Be,{noWrap:!0,className:re.pillBar,"data-aia-pillbar":"",children:[x&&Y("span",{className:re.pillScroll,"data-aia-pill-scroll":"",children:Y(Qe,{pills:p.pills??[],activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:y??(()=>{}),rounded:!0,loading:p.isLoading})}),ge&&Y("button",{type:"button",tabIndex:-1,className:re.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":fe?`${H.skipLabel} ${fe}`:H.skipLabel,onClick:P,children:H.skip})]}),h&&Y(Lt,{options:j,activeIndex:p.activeIndex,onSelect:t,onHighlight:i,onUnhighlight:r,listboxId:a,loading:p.isLoading,groupKey:U?`${U.parameter} ${U.text}`:"",optionsPosition:ie,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),Ce&&p.dateView&&Y(yt,{options:j,activeIndex:p.activeIndex,listboxId:a,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:i,onUnhighlight:r,onPreviousMonth:ye??Mt,onNextMonth:pe??Mt}),Le&&Y("div",{className:re.skeletonBars,"data-aia-skeleton-bars":"",children:ii.map(ee=>Y("span",{className:re.skeletonBar,style:{width:ee}},`bar-${ee}`))}),Y(It,{products:be,listboxId:a,onSelect:N??oi,onFocusChange:Z,focusable:v,layout:B,imageFallback:de,strings:H}),Y(Ct,{isOptionHighlighted:Te,isInputEmpty:p.isInputEmpty,strings:H})]}),Y("button",{ref:X,type:"button",tabIndex:-1,className:re.scrollArrow,"data-aia-scroll-arrow":"","aria-label":H.scrollArrow,"aria-hidden":"true",children:Y("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:Y("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as yi,ModeController as ki,setCursorOffset as Ci,uiStringsFor as Pi}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as si}from"@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 @@ import{buildSubmitResult as bn,cellDay as vn,cellIso as wn,DATE_RANGE_META_END a
|
|
|
2266
2266
|
);
|
|
2267
2267
|
cursor: default;
|
|
2268
2268
|
}
|
|
2269
|
-
`,document.head.appendChild(e)}var Ot={submitButton:"aia-submitButton-otz7H"};import{jsx as nt}from"react/jsx-runtime";function Dt({disabled:e,onClick:n,label:t=ni().submit}){return nt("button",{type:"button","data-aia-submit":"",className:Ot.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),n()},"aria-label":t,children:nt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:nt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ri,dateSelectionFor as si,identifiedParamLabel as li}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Bt,useEffect as Me,useRef as K,useState as di}from"react";import{useRef as Lt}from"react";function zt(e){let n=Lt(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=Lt({key:"",overrides:void 0});if(i.current.key!==t){let r={};for(let o of Object.keys(e??{})){let a=(d,l,w)=>{let C=n.current?.[o];return C?C(d,l,w):[]};r[o]=a}i.current={key:t,overrides:e?r:void 0}}return{overrides:i.current.overrides,key:t}}import{useRef as Mt}from"react";function Nt(e){let n=Mt(e);n.current=e;let t=Mt(null);t.current===null&&(t.current={fetch:(r,o)=>{let a=n.current;return a?a.fetch(r,o):Promise.reject(new Error("products config removed"))},transform:r=>n.current?.transform(r)??[],get limit(){return n.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var ci={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 rt({onSubmit:e,onResult:n,onError:t,optionOverrides:i,maskCompletedText:r,apiConfig:o,additionalContext:a,language:d,visitorId:l,columns:w=2,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:b,showOptionIcons:I,showOptionImages:D,showOptionCounts:L,showSkipButton:F,showProducts:E,productImageFallback:S="image",onFocus:z,onBlur:M,value:x,completedParams:N,onChange:V,onParamsChange:B,products:he,onProductSelect:ae,source:q,setCursor:ue}){let m=K(null),[xe,ge]=di(null),me=K(e);me.current=e;let ie=K(n);ie.current=n;let fe=K(t);fe.current=t;let oe=K(V);oe.current=V;let J=K(B);J.current=B;let U=K(z);U.current=z;let ne=K(M);ne.current=M;let s=K(ue);s.current=ue;let g=K(ae);g.current=ae;let v=K(l);v.current=l;let f=K(()=>{let h=v.current;return typeof h=="function"?h():h}).current,y=Nt(he),R=zt(i);Me(()=>{if(typeof document>"u")return;let h=new ri(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:a,language:d,visitorId:f,optionOverrides:R.overrides,maskCompletedText:r,columns:w,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:b,showProducts:E,source:q,value:x,completedParams:N,onSubmit:(...O)=>me.current?.(...O),onResult:(...O)=>ie.current?.(...O),onError:(...O)=>fe.current?.(...O),onChange:(...O)=>oe.current?.(...O),onParamsChange:(...O)=>J.current?.(...O),onFocus:()=>U.current?.(),onBlur:()=>ne.current?.(),onProductSelect:O=>g.current?.(O),setCursor:O=>s.current?.(O),products:y.config});m.current=h,ge(h.getState());let Y=h.subscribe(O=>ge(O));return()=>{Y(),h.destroy(),m.current===h&&(m.current=null)}},[]),Me(()=>{x!==void 0&&m.current?.setValue(x)},[x]),Me(()=>{N!==void 0&&m.current?.setCompletedParams(N)},[N]);let c=JSON.stringify(o??null),H;try{H=JSON.stringify(a??null)}catch{H="[unstringifiable]"}Me(()=>{m.current?.update({apiConfig:o,additionalContext:a,language:d,optionOverrides:R.overrides,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:b,showProducts:E})},[c,H,d,R.key,C,P,u,b,E]);let j=K(!1);Me(()=>{if(!j.current){j.current=!0;return}m.current?.update({products:y.config})},[y.enabled]);let Q=K(null);Q.current===null&&(Q.current={handleTextChange:h=>m.current?.handleTextChange(h),handleKeyDown:h=>{let Y="nativeEvent"in h?h.nativeEvent:h;m.current?.handleKeyDown(Y)},setFocused:h=>m.current?.setFocused(h),startEditingParam:h=>m.current?.startEditingParam(h),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:h=>m.current?.handleCaretAfterInput(h),handleCaretMove:h=>m.current?.handleCaretMove(h),replaceEditingRange:h=>m.current?.replaceEditingRange(h)??!1,setActivePill:h=>m.current?.setActivePill(h),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),recordSubmit:h=>m.current?.recordSubmit(h),selectOption:h=>m.current?.selectOption(h),selectProduct:h=>m.current?.selectProduct(h),setActiveDropdownIndex:h=>m.current?.setActiveDropdownIndex(h),clearHighlight:h=>m.current?.clearHighlight(h),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let k=Q.current,re=Bt(h=>{let Y=h.target.value,$e=Y.length>0&&!h.nativeEvent?.isComposing&&Y[0]!==Y[0].toUpperCase()?Y[0].toUpperCase()+Y.slice(1):Y;m.current?.handleTextChange($e)},[]),Ae=Bt(h=>{m.current?.handleKeyDown(h.nativeEvent)},[]),be=m.current,p=xe??ci,se=x!==void 0?x:p.text,ye=N!==void 0?N:p.completedParams,ve=p.actionableSuggestions,Pe=ve[0],le=be?.listboxId??"",Re=p.activeDropdownIndex>=0&&be?`${le}-option-${p.activeDropdownIndex}`:void 0,G=p.editingParam,W=p.editingIdentified,Se=G?{parameter:G.suggestionParameter,text:G.suggestionPlaceholder,required:!0,options:G.options}:W?{parameter:W.parameter,text:li(W.parameter),required:!0,options:[]}:null,Be=p.dropdownSuggestion??Se??Pe,Ze=Se?[Se]:ve,Oe=si(p),He=!be||p.dropdownLoading;return{completedParams:ye,skippedParams:p.skippedParams,identifiedParams:p.identifiedParams,suggestionPills:ve,setActivePill:k.setActivePill,skipActivePill:k.skipActivePill,removeLastParam:k.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:k.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:He,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:le,error:p.error,products:p.products,customFields:p.customFields,selectProduct:k.selectProduct,handleTextChange:k.handleTextChange,handleKeyDown:k.handleKeyDown,setFocused:k.setFocused,editingParam:G,editingIdentified:W,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:k.startEditingParam,exitEditMode:k.exitEditMode,handleCaretAfterInput:k.handleCaretAfterInput,handleCaretMove:k.handleCaretMove,replaceEditingRange:k.replaceEditingRange,inputProps:{value:se,placeholder:p.placeholderText||void 0,onChange:re,onKeyDown:Ae,onFocus:k.handleFocus,onBlur:k.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":Re,"aria-autocomplete":"list","aria-controls":le},reset:k.reset,recordSubmit:k.recordSubmit,dropdownProps:{suggestions:Be?[{...Be,options:p.dropdownOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:k.selectOption,onHighlight:k.setActiveDropdownIndex,onUnhighlight:k.clearHighlight,isOpen:p.isDropdownOpen,id:le,pills:Ze,activeSelected:p.isActivePillSelected,onPillClick:k.setActivePill,onSkip:k.skipActivePill,showSkipButton:(F??!0)&&!G&&!W,showOptionIcons:I??!0,showOptionImages:D??!0,showOptionCounts:L??!0,skipDisabled:p.inSelectionAnimation,isLoading:He,skeletonExiting:p.skeletonExiting,isInputEmpty:se.trim().length===0,language:d,products:p.products,productImageFallback:S,onProductSelect:k.selectProduct,onProductFocusChange:k.setFocused,formatType:p.activeFormatType,dateView:p.dateView,selectedDateIso:Oe.selectedIso,selectedDateRange:Oe.selectedRange,dateRangeStart:Oe.rangeStart,onPreviousMonth:k.showPreviousMonth,onNextMonth:k.showNextMonth,optionsPosition:P??"below"}}}import{chipIdFromTap as pi,extractPlainText as Ht,getCursorOffset as Ft,keepCaretOnChip as hi,plainTextLength as ui,renderEditableContent as gi,setCursorOffset as Kt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Qe,useLayoutEffect as st,useRef as Ee}from"react";var Ye;function mi(){if(Ye!==void 0)return Ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ye=e.contentEditable==="plaintext-only",Ye}function Gt(e){let{segments:n,showChipIcons:t=!0,showChipImages:i=!0,newParamId:r,editingParam:o,editingIdentified:a,editingAnchor:d,caretOffset:l,placeholderText:w,isFocused:C,isDropdownOpen:P,listboxId:u,activeDescendantId:b,autoFocus:I,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:F,handleCaretMove:E,startEditingParam:S,replaceEditingRange:z,setFocused:M}=e,x=Ee(null),N=Ee(!1),V=Ee(""),B=Ee(""),he=Ee(null),ae=Ee(0);he.current=l,Qe(()=>{if(!I)return;let s=x.current;if(!s)return;document.activeElement===s?M(!0):s.focus();let g=s.ownerDocument??document,v=g.getSelection(),f=v&&v.rangeCount>0&&s.contains(v.anchorNode);if(v&&!f){let y=g.createRange();y.selectNodeContents(s),y.collapse(!0),v.removeAllRanges(),v.addRange(y)}},[I,M]),Qe(()=>{let s=x.current;if(!s)return;let g=s.ownerDocument??document,v=()=>{let f=g.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!s.contains(f.anchorNode))return;let y=f.anchorNode,R=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,H=(f.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=o?.id??a?.id??null;if(H&&H!==j){S(H);return}performance.now()-ae.current<50||E(Ft(s))};return g.addEventListener("selectionchange",v),()=>g.removeEventListener("selectionchange",v)},[o,a,S,E]),Qe(()=>{let s=x.current;if(!s)return;let g=v=>{let f=pi(s,v.target);f&&(S(f),hi(s,f))};return s.addEventListener("click",g),()=>s.removeEventListener("click",g)},[S]),st(()=>{let s=x.current;s&&gi({input:s,segments:n,newParamId:r,editingParamId:o?.id??null,placeholderText:w??"",isFocused:C,showChipIcons:t,showChipImages:i})},[n,r,o,w,C,t,i]),st(()=>{let s=V.current,g=r??"";if(V.current=g,!g||g===s)return;let v=x.current;if(!v)return;v.focus();let f=he.current??ui(v);Kt(v,f)},[r]),st(()=>{let s=B.current,g=o?.id??"";if(B.current=g,!g||g===s||d==null)return;let v=x.current;v&&Kt(v,d)},[o,d]);let q=X(()=>{if(N.current)return;let s=x.current;if(!s)return;let g=Ht(s),f=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;D(f)},[D]),ue=X(()=>{ae.current=performance.now(),q();let s=x.current;s&&F(Ft(s))},[q,F]);Qe(()=>{let s=x.current;if(!s)return;let g=v=>{let f=v,y=f.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){v.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let R=y.startsWith("delete")?"":f.data??"";z(R)&&v.preventDefault()}};return s.addEventListener("beforeinput",g),()=>s.removeEventListener("beforeinput",g)},[z]);let m=X(()=>{N.current=!0},[]),xe=X(()=>{N.current=!1,q()},[q]),ge=X(s=>{s.preventDefault();let g=x.current;if(!g)return;let v=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!v)return;let f=g.ownerDocument??document,y=f.getSelection();if(!y||y.rangeCount===0)return;let R=y.getRangeAt(0);if(!g.contains(R.startContainer))return;R.deleteContents();let c=f.createTextNode(v);R.insertNode(c),R.setStartAfter(c),R.collapse(!0),y.removeAllRanges(),y.addRange(R),q()},[q]),me=X(s=>L(s),[L]),ie=X(()=>M(!0),[M]),fe=X(()=>M(!1),[M]),oe=X(()=>x.current?.focus(),[]),J=X(()=>x.current?.blur(),[]),U=X(()=>{let s=x.current;return s?Ht(s):""},[]),ne=mi()?"plaintext-only":"true";return{inputRef:x,editorProps:{ref:x,contentEditable:ne,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":P,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:ue,onKeyDown:me,onCompositionStart:m,onCompositionEnd:xe,onPaste:ge,onFocus:ie,onBlur:fe},getPlainText:U,focus:oe,blur:J}}import{jsx as Te,jsxs as dt}from"react/jsx-runtime";function Ci(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Pi=fi(function({onSubmit:n,onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,className:a,apiConfig:d,additionalContext:l,language:w,visitorId:C,columns:P,pillPlacement:u="dropdown",mode:b="auto",optionsPosition:I="below",animations:D=!0,dropdownTrigger:L,closeDropdownOnBlur:F,showNonTappableOptions:E,showOptionIcons:S=!0,showChipIcons:z=!0,showChipImages:M=!0,showOptionImages:x=!0,showOptionCounts:N=!0,showSkipButton:V,showProducts:B,productsLayout:he,productImageFallback:ae,autoFocus:q=!0,onFocus:ue,onBlur:m,value:xe,completedParams:ge,onChange:me,onParamsChange:ie,products:fe,onProductSelect:oe,submitButton:J,resetOnSubmit:U=!0},ne){let s=Ne(null),g=Ne(null),v=Ne(()=>{}),f=Ne(null),y=Ne(null);Wt(()=>{let T=s.current;if(T)return f.current?f.current.setMode(b):f.current=new xi(T,b),()=>{f.current?.destroy(),f.current=null}},[b]);let R=lt(T=>{let ee=y.current?.current;ee&&(ee.focus(),yi(ee,T))},[]),{completedParams:c,skippedParams:H,identifiedParams:j,isReady:Q,customFields:k,suggestionPills:re,setActivePill:Ae,skipActivePill:be,segments:p,newParamId:se,clearNewParamId:ye,placeholderText:ve,isFocused:Pe,isDropdownOpen:le,isActivePillSelected:Re,isLoading:G,activeIndex:W,listboxId:Se,handleTextChange:Be,handleKeyDown:Ze,setFocused:Oe,editingParam:He,editingIdentified:h,editingAnchor:Y,caretOffset:O,startEditingParam:$e,handleCaretAfterInput:_t,handleCaretMove:qt,replaceEditingRange:Ut,dropdownProps:jt,reset:Fe,recordSubmit:ct}=rt({onSubmit:T=>v.current(T),onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,apiConfig:d,additionalContext:l,language:w,visitorId:C,columns:P,dropdownTrigger:L,optionsPosition:I,closeDropdownOnBlur:F,showNonTappableOptions:E,showOptionIcons:S,showOptionImages:x,showOptionCounts:N,showSkipButton:V,showProducts:B,onFocus:ue,onBlur:m,value:xe,completedParams:ge,onChange:me,onParamsChange:ie,products:fe,onProductSelect:oe,source:"full-sdk",setCursor:R});Wt(()=>{if(!se)return;let T=window.setTimeout(()=>ye(),650);return()=>window.clearTimeout(T)},[se,ye]);let Qt=W>=0?`${Se}-option-${W}`:void 0,{inputRef:Ve,editorProps:Yt,focus:Ke,blur:pt,getPlainText:ht}=Gt({segments:p,newParamId:se,editingParam:He,editingIdentified:h,editingAnchor:Y,caretOffset:O,placeholderText:ve,isFocused:Pe,showChipIcons:z,showChipImages:M,isDropdownOpen:le,listboxId:Se,activeDescendantId:Qt,autoFocus:q,handleTextChange:Be,handleKeyDown:Ze,handleCaretAfterInput:_t,handleCaretMove:qt,startEditingParam:$e,replaceEditingRange:Ut,setFocused:Oe});y.current=Ve,vi(()=>{let T=g.current,ee=Ve.current;if(!T||!ee)return;let De=()=>{let gt=T.firstElementChild;if(!gt)return;let Xt=gt.getBoundingClientRect(),Jt=ee.getBoundingClientRect();Xt.top>=Jt.bottom-2?T.setAttribute("data-aia-pill-wrapped",""):T.removeAttribute("data-aia-pill-wrapped")};De();let ut=new ResizeObserver(De);return ut.observe(ee),()=>ut.disconnect()},[p,re.length,G,Ve]),bi(ne,()=>({focus:Ke,blur:pt,reset:Fe,setMode:T=>f.current?.setMode(T),skipActivePill:be}),[Ke,pt,Fe,be]);let Ge=!!p.length||c.length>0,Xe=lt(T=>{if(!Ge)return;let ee=ht(),De=wi(ee,c,H,{identifiedParams:j,isReady:Q,customFields:k});T&&ct(De),n(De),U&&Fe()},[ct,U,Ge,c,H,j,Q,k,n,Fe,ht]);v.current=()=>Xe(!1);let Zt=lt(T=>{T.target?.closest("[data-aia-pill]")||Ke()},[Ke]),$t=u==="inline",Vt=u==="dropdown";return dt("div",{ref:s,className:`magicx-aia ${ke.container} ${a??""}`,"data-pill-placement":u,"data-options-position":I,"data-animations":D?"on":"off","data-mode":Ci(b),children:[Te(ot,{...jt,showPills:Vt,productsLayout:he,productImageFallback:ae}),dt("div",{className:ke.inputWrapper,"data-aia-input-wrapper":"",onClick:Zt,children:[dt("div",{className:ke.editorArea,"data-aia-editor":"",children:[Te("div",{...Yt,className:ke.input,"data-aia-input":""}),$t&&(G||re.length>0)&&Te("span",{ref:g,className:ke.pillListContainer,"data-aia-pill-list-container":"",children:Te(_e,{pills:re,activePillIndex:0,activeSelected:Re,onSelectPill:Ae,loading:G})})]}),J===null?null:J===void 0?Te(Dt,{disabled:!Ge,onClick:()=>Xe(!0),label:ki(w).submit}):Te("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ke.submitSlot,onClick:T=>{Ge&&(T.stopPropagation(),Xe(!0))},children:J})]})]})});export{Pi as AIAutocomplete,ot as AIAutocompleteDropdown,xn as DATE_RANGE_META_END,yn as DATE_RANGE_META_START,kn as DEFAULT_OPTION_COUNT_UNIT,zn as PRODUCT_PATH_PREFIX,qn as WEEKDAY_LABELS,bn as buildSubmitResult,vn as cellDay,wn as cellIso,Cn as dateCellMarks,Pn as formatDate,Sn as formatDateRange,In as formatOptionCount,En as isoDate,Tn as monthLabel,An as optionCountLabel,Rn as optionHasImage,On as optionImageSources,Dn as optionImageSrc,Ln as optionLabel,Mn as parseDate,Nn as parseLooseDate,Bn as parseLooseDateRange,Hn as productFromMatchedItem,Fn as productImageSources,Kn as productsFromCustomFields,Gn as sanitizeOptionIconSvg,Wn as selectedRangeFor,rt as useAIAutocomplete,_n as visibleDateRange,Un as withSkippedParams};
|
|
2269
|
+
`,document.head.appendChild(e)}var Nt={submitButton:"aia-submitButton-otz7H"};import{jsx as dt}from"react/jsx-runtime";function Bt({disabled:e,onClick:n,label:t=si().submit}){return dt("button",{type:"button","data-aia-submit":"",className:Nt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),n()},"aria-label":t,children:dt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:dt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as li,dateSelectionFor as di,identifiedParamLabel as ci}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Wt,useEffect as Re,useRef as F,useState as pi}from"react";import{useRef as Ht}from"react";function Ft(e){let n=Ht(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),i=Ht({key:"",overrides:void 0});if(i.current.key!==t){let r={};for(let o of Object.keys(e??{})){let a=(c,d,y)=>{let C=n.current?.[o];return C?C(c,d,y):[]};r[o]=a}i.current={key:t,overrides:e?r:void 0}}return{overrides:i.current.overrides,key:t}}import{useRef as Kt}from"react";function Gt(e){let n=Kt(e);n.current=e;let t=Kt(null);t.current===null&&(t.current={fetch:(r,o)=>{let a=n.current;return a?a.fetch(r,o):Promise.reject(new Error("products config removed"))},transform:r=>n.current?.transform(r)??[],get limit(){return n.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var hi={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 ct({onSubmit:e,onResult:n,onError:t,optionOverrides:i,maskCompletedText:r,apiConfig:o,additionalContext:a,language:c,visitorId:d,columns:y=2,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showOptionIcons:I,showOptionImages:D,showOptionCounts:L,showSkipButton:K,showProducts:E,productImageFallback:S="image",onFocus:z,onBlur:M,value:k,completedParams:N,onChange:Z,onParamsChange:B,products:de,mapProducts:V,onProductSelect:W,source:xe,setCursor:ce}){let m=F(null),[ye,pe]=pi(null),ie=F(e);ie.current=e;let he=F(n);he.current=n;let oe=F(t);oe.current=t;let ue=F(Z);ue.current=Z;let _=F(B);_.current=B;let X=F(z);X.current=z;let s=F(M);s.current=M;let g=F(ce);g.current=ce;let b=F(W);b.current=W;let v=F(d);v.current=d;let w=F(()=>{let l=v.current;return typeof l=="function"?l():l}).current,R=Gt(de),p=F(V);p.current=V;let H=F((l,G)=>{let T=p.current;return T?T(l,G):l}).current,U=V?H:void 0,j=Ft(i);Re(()=>{if(typeof document>"u")return;let l=new li(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:a,language:c,visitorId:w,optionOverrides:j.overrides,maskCompletedText:r,columns:y,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showProducts:E,source:xe,value:k,completedParams:N,onSubmit:(...T)=>ie.current?.(...T),onResult:(...T)=>he.current?.(...T),onError:(...T)=>oe.current?.(...T),onChange:(...T)=>ue.current?.(...T),onParamsChange:(...T)=>_.current?.(...T),onFocus:()=>X.current?.(),onBlur:()=>s.current?.(),onProductSelect:T=>b.current?.(T),setCursor:T=>g.current?.(T),products:R.config,mapProducts:U});m.current=l,pe(l.getState());let G=l.subscribe(T=>pe(T));return()=>{G(),l.destroy(),m.current===l&&(m.current=null)}},[]),Re(()=>{k!==void 0&&m.current?.setValue(k)},[k]),Re(()=>{N!==void 0&&m.current?.setCompletedParams(N)},[N]);let Te=JSON.stringify(o??null),J;try{J=JSON.stringify(a??null)}catch{J="[unstringifiable]"}Re(()=>{m.current?.update({apiConfig:o,additionalContext:a,language:c,optionOverrides:j.overrides,dropdownTrigger:C,optionsPosition:P,closeDropdownOnBlur:u,showNonTappableOptions:f,showProducts:E})},[Te,J,c,j.key,C,P,u,f,E]);let me=F(!1);Re(()=>{if(!me.current){me.current=!0;return}m.current?.update({products:R.config})},[R.enabled]),Re(()=>{m.current?.update({mapProducts:U})},[U]);let ke=F(null);ke.current===null&&(ke.current={handleTextChange:l=>m.current?.handleTextChange(l),handleKeyDown:l=>{let G="nativeEvent"in l?l.nativeEvent:l;m.current?.handleKeyDown(G)},setFocused:l=>m.current?.setFocused(l),startEditingParam:l=>m.current?.startEditingParam(l),exitEditMode:()=>m.current?.exitEditMode(),handleCaretAfterInput:l=>m.current?.handleCaretAfterInput(l),handleCaretMove:l=>m.current?.handleCaretMove(l),replaceEditingRange:l=>m.current?.replaceEditingRange(l)??!1,setActivePill:l=>m.current?.setActivePill(l),skipActivePill:()=>m.current?.skipActivePill(),removeLastParam:()=>m.current?.removeLastParam(),clearNewParamId:()=>m.current?.clearNewParamId(),reset:()=>m.current?.reset(),refreshProducts:()=>m.current?.refreshProducts(),recordSubmit:l=>m.current?.recordSubmit(l),selectOption:l=>m.current?.selectOption(l),selectProduct:l=>m.current?.selectProduct(l),setActiveDropdownIndex:l=>m.current?.setActiveDropdownIndex(l),clearHighlight:l=>m.current?.clearHighlight(l),showPreviousMonth:()=>m.current?.showPreviousMonth(),showNextMonth:()=>m.current?.showNextMonth(),handleFocus:()=>m.current?.setFocused(!0),handleBlur:()=>m.current?.setFocused(!1)});let x=ke.current,ge=Wt(l=>{let G=l.target.value,et=G.length>0&&!l.nativeEvent?.isComposing&&G[0]!==G[0].toUpperCase()?G[0].toUpperCase()+G.slice(1):G;m.current?.handleTextChange(et)},[]),fe=Wt(l=>{m.current?.handleKeyDown(l.nativeEvent)},[]),ne=m.current,h=ye??hi,Ce=k!==void 0?k:h.text,Le=N!==void 0?N:h.completedParams,be=h.actionableSuggestions,ee=be[0],Pe=ne?.listboxId??"",Ke=h.activeDropdownIndex>=0&&ne?`${Pe}-option-${h.activeDropdownIndex}`:void 0,ve=h.editingParam,Se=h.editingIdentified,ze=ve?{parameter:ve.suggestionParameter,text:ve.suggestionPlaceholder,required:!0,options:ve.options}:Se?{parameter:Se.parameter,text:ci(Se.parameter),required:!0,options:[]}:null,Ge=h.dropdownSuggestion??ze??ee,Je=ze?[ze]:be,Me=di(h),We=!ne||h.dropdownLoading;return{completedParams:Le,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:be,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:We,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Pe,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:ve,editingIdentified:Se,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ce,placeholder:h.placeholderText||void 0,onChange:ge,onKeyDown:fe,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":Ke,"aria-autocomplete":"list","aria-controls":Pe},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Ge?[{...Ge,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Pe,pills:Je,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(K??!0)&&!ve&&!Se,showOptionIcons:I??!0,showOptionImages:D??!0,showOptionCounts:L??!0,skipDisabled:h.inSelectionAnimation,isLoading:We,skeletonExiting:h.skeletonExiting,isInputEmpty:Ce.trim().length===0,language:c,products:h.products,productImageFallback:S,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Me.selectedIso,selectedDateRange:Me.selectedRange,dateRangeStart:Me.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:P??"below"}}}import{chipIdFromTap as ui,extractPlainText as _t,getCursorOffset as Ut,keepCaretOnChip as mi,plainTextLength as gi,renderEditableContent as fi,setCursorOffset as qt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as $,useEffect as Ve,useLayoutEffect as pt,useRef as Oe}from"react";var Xe;function bi(){if(Xe!==void 0)return Xe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Xe=e.contentEditable==="plaintext-only",Xe}function jt(e){let{segments:n,showChipIcons:t=!0,showChipImages:i=!0,newParamId:r,editingParam:o,editingIdentified:a,editingAnchor:c,caretOffset:d,placeholderText:y,isFocused:C,isDropdownOpen:P,listboxId:u,activeDescendantId:f,autoFocus:I,handleTextChange:D,handleKeyDown:L,handleCaretAfterInput:K,handleCaretMove:E,startEditingParam:S,replaceEditingRange:z,setFocused:M}=e,k=Oe(null),N=Oe(!1),Z=Oe(""),B=Oe(""),de=Oe(null),V=Oe(0);de.current=d,Ve(()=>{if(!I)return;let s=k.current;if(!s)return;document.activeElement===s?M(!0):s.focus();let g=s.ownerDocument??document,b=g.getSelection(),v=b&&b.rangeCount>0&&s.contains(b.anchorNode);if(b&&!v){let w=g.createRange();w.selectNodeContents(s),w.collapse(!0),b.removeAllRanges(),b.addRange(w)}},[I,M]),Ve(()=>{let s=k.current;if(!s)return;let g=s.ownerDocument??document,b=()=>{let v=g.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!s.contains(v.anchorNode))return;let w=v.anchorNode,R=w.nodeType===Node.ELEMENT_NODE?w:w.parentElement,H=(v.isCollapsed?R?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,U=o?.id??a?.id??null;if(H&&H!==U){S(H);return}performance.now()-V.current<50||E(Ut(s))};return g.addEventListener("selectionchange",b),()=>g.removeEventListener("selectionchange",b)},[o,a,S,E]),Ve(()=>{let s=k.current;if(!s)return;let g=b=>{let v=ui(s,b.target);v&&(S(v),mi(s,v))};return s.addEventListener("click",g),()=>s.removeEventListener("click",g)},[S]),pt(()=>{let s=k.current;s&&fi({input:s,segments:n,newParamId:r,editingParamId:o?.id??null,placeholderText:y??"",isFocused:C,showChipIcons:t,showChipImages:i})},[n,r,o,y,C,t,i]),pt(()=>{let s=Z.current,g=r??"";if(Z.current=g,!g||g===s)return;let b=k.current;if(!b)return;b.focus();let v=de.current??gi(b);qt(b,v)},[r]),pt(()=>{let s=B.current,g=o?.id??"";if(B.current=g,!g||g===s||c==null)return;let b=k.current;b&&qt(b,c)},[o,c]);let W=$(()=>{if(N.current)return;let s=k.current;if(!s)return;let g=_t(s),v=g.length>0&&g[0]!==g[0].toUpperCase()?g[0].toUpperCase()+g.slice(1):g;D(v)},[D]),xe=$(()=>{V.current=performance.now(),W();let s=k.current;s&&K(Ut(s))},[W,K]);Ve(()=>{let s=k.current;if(!s)return;let g=b=>{let v=b,w=v.inputType;if(w==="insertParagraph"||w==="insertLineBreak"||w==="insertFromDrop"){b.preventDefault();return}if(w.startsWith("insert")||w.startsWith("delete")){let R=w.startsWith("delete")?"":v.data??"";z(R)&&b.preventDefault()}};return s.addEventListener("beforeinput",g),()=>s.removeEventListener("beforeinput",g)},[z]);let ce=$(()=>{N.current=!0},[]),m=$(()=>{N.current=!1,W()},[W]),ye=$(s=>{s.preventDefault();let g=k.current;if(!g)return;let b=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let v=g.ownerDocument??document,w=v.getSelection();if(!w||w.rangeCount===0)return;let R=w.getRangeAt(0);if(!g.contains(R.startContainer))return;R.deleteContents();let p=v.createTextNode(b);R.insertNode(p),R.setStartAfter(p),R.collapse(!0),w.removeAllRanges(),w.addRange(R),W()},[W]),pe=$(s=>L(s),[L]),ie=$(()=>M(!0),[M]),he=$(()=>M(!1),[M]),oe=$(()=>k.current?.focus(),[]),ue=$(()=>k.current?.blur(),[]),_=$(()=>{let s=k.current;return s?_t(s):""},[]),X=bi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:X,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":P,"aria-activedescendant":f,spellCheck:!0,enterKeyHint:"send",onInput:xe,onKeyDown:pe,onCompositionStart:ce,onCompositionEnd:m,onPaste:ye,onFocus:ie,onBlur:he},getPlainText:_,focus:oe,blur:ue}}import{jsx as De,jsxs as ut}from"react/jsx-runtime";function Si(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ii=vi(function({onSubmit:n,onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,className:a,apiConfig:c,additionalContext:d,language:y,visitorId:C,columns:P,pillPlacement:u="dropdown",mode:f="auto",optionsPosition:I="below",animations:D=!0,dropdownTrigger:L,closeDropdownOnBlur:K,showNonTappableOptions:E,showOptionIcons:S=!0,showChipIcons:z=!0,showChipImages:M=!0,showOptionImages:k=!0,showOptionCounts:N=!0,showSkipButton:Z,showProducts:B,productsLayout:de,productImageFallback:V,autoFocus:W=!0,onFocus:xe,onBlur:ce,value:m,completedParams:ye,onChange:pe,onParamsChange:ie,products:he,mapProducts:oe,onProductSelect:ue,submitButton:_,resetOnSubmit:X=!0},s){let g=Fe(null),b=Fe(null),v=Fe(()=>{}),w=Fe(null),R=Fe(null);Qt(()=>{let A=g.current;if(A)return w.current?w.current.setMode(f):w.current=new ki(A,f),()=>{w.current?.destroy(),w.current=null}},[f]);let p=ht(A=>{let te=R.current?.current;te&&(te.focus(),Ci(te,A))},[]),{completedParams:H,skippedParams:U,identifiedParams:j,isReady:Te,customFields:J,suggestionPills:me,setActivePill:ke,skipActivePill:x,segments:ge,newParamId:fe,clearNewParamId:ne,placeholderText:h,isFocused:Ce,isDropdownOpen:Le,isActivePillSelected:be,isLoading:ee,activeIndex:Pe,listboxId:Ke,handleTextChange:ve,handleKeyDown:Se,setFocused:ze,editingParam:Ge,editingIdentified:Je,editingAnchor:Me,caretOffset:We,startEditingParam:l,handleCaretAfterInput:G,handleCaretMove:T,replaceEditingRange:et,dropdownProps:Yt,reset:_e,refreshProducts:mt,recordSubmit:gt}=ct({onSubmit:A=>v.current(A),onResult:t,onError:i,optionOverrides:r,maskCompletedText:o,apiConfig:c,additionalContext:d,language:y,visitorId:C,columns:P,dropdownTrigger:L,optionsPosition:I,closeDropdownOnBlur:K,showNonTappableOptions:E,showOptionIcons:S,showOptionImages:k,showOptionCounts:N,showSkipButton:Z,showProducts:B,onFocus:xe,onBlur:ce,value:m,completedParams:ye,onChange:pe,onParamsChange:ie,products:he,mapProducts:oe,onProductSelect:ue,source:"full-sdk",setCursor:p});Qt(()=>{if(!fe)return;let A=window.setTimeout(()=>ne(),650);return()=>window.clearTimeout(A)},[fe,ne]);let Zt=Pe>=0?`${Ke}-option-${Pe}`:void 0,{inputRef:tt,editorProps:$t,focus:Ue,blur:ft,getPlainText:bt}=jt({segments:ge,newParamId:fe,editingParam:Ge,editingIdentified:Je,editingAnchor:Me,caretOffset:We,placeholderText:h,isFocused:Ce,showChipIcons:z,showChipImages:M,isDropdownOpen:Le,listboxId:Ke,activeDescendantId:Zt,autoFocus:W,handleTextChange:ve,handleKeyDown:Se,handleCaretAfterInput:G,handleCaretMove:T,startEditingParam:l,replaceEditingRange:et,setFocused:ze});R.current=tt,xi(()=>{let A=b.current,te=tt.current;if(!A||!te)return;let Ne=()=>{let wt=A.firstElementChild;if(!wt)return;let ea=wt.getBoundingClientRect(),ta=te.getBoundingClientRect();ea.top>=ta.bottom-2?A.setAttribute("data-aia-pill-wrapped",""):A.removeAttribute("data-aia-pill-wrapped")};Ne();let vt=new ResizeObserver(Ne);return vt.observe(te),()=>vt.disconnect()},[ge,me.length,ee,tt]),wi(s,()=>({focus:Ue,blur:ft,reset:_e,refreshProducts:mt,setMode:A=>w.current?.setMode(A),skipActivePill:x}),[Ue,ft,_e,mt,x]);let qe=!!ge.length||H.length>0,at=ht(A=>{if(!qe)return;let te=bt(),Ne=yi(te,H,U,{identifiedParams:j,isReady:Te,customFields:J});A&>(Ne),n(Ne),X&&_e()},[gt,X,qe,H,U,j,Te,J,n,_e,bt]);v.current=()=>at(!1);let Vt=ht(A=>{A.target?.closest("[data-aia-pill]")||Ue()},[Ue]),Xt=u==="inline",Jt=u==="dropdown";return ut("div",{ref:g,className:`magicx-aia ${Ie.container} ${a??""}`,"data-pill-placement":u,"data-options-position":I,"data-animations":D?"on":"off","data-mode":Si(f),children:[De(lt,{...Yt,showPills:Jt,productsLayout:de,productImageFallback:V}),ut("div",{className:Ie.inputWrapper,"data-aia-input-wrapper":"",onClick:Vt,children:[ut("div",{className:Ie.editorArea,"data-aia-editor":"",children:[De("div",{...$t,className:Ie.input,"data-aia-input":""}),Xt&&(ee||me.length>0)&&De("span",{ref:b,className:Ie.pillListContainer,"data-aia-pill-list-container":"",children:De(Qe,{pills:me,activePillIndex:0,activeSelected:be,onSelectPill:ke,loading:ee})})]}),_===null?null:_===void 0?De(Bt,{disabled:!qe,onClick:()=>at(!0),label:Pi(y).submit}):De("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ie.submitSlot,onClick:A=>{qe&&(A.stopPropagation(),at(!0))},children:_})]})]})});export{Ii as AIAutocomplete,lt as AIAutocompleteDropdown,kn as DATE_RANGE_META_END,Cn as DATE_RANGE_META_START,Pn as DEFAULT_OPTION_COUNT_UNIT,Nn as PRODUCT_PATH_PREFIX,jn as WEEKDAY_LABELS,wn as buildSubmitResult,xn as cellDay,yn as cellIso,Sn as dateCellMarks,In as formatDate,En as formatDateRange,Tn as formatOptionCount,An as isoDate,Rn as monthLabel,On as optionCountLabel,Dn as optionHasImage,Ln as optionImageSources,zn as optionImageSrc,Mn as optionLabel,Bn as parseDate,Hn as parseLooseDate,Fn as parseLooseDateRange,Kn as productFromMatchedItem,Gn as productImageSources,Wn as productsFromCustomFields,_n as sanitizeOptionIconSvg,Un as selectedRangeFor,ct as useAIAutocomplete,qn as visibleDateRange,Qn as withSkippedParams};
|
|
2270
2270
|
//# sourceMappingURL=index.mjs.map
|