@magicx-eng/ai-autocomplete-react 0.38.1 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -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 Tn,cellDay as En,cellIso as An,DATE_RANGE_META_END as Rn,DATE_RANGE_META_START as Dn,DEFAULT_OPTION_COUNT_UNIT as On,dateCellMarks as Ln,formatDate as zn,formatDateRange as Mn,formatOptionCount as Nn,isoDate as Fn,monthLabel as Bn,optionCountLabel as Hn,optionHasImage as Kn,optionImageSources as Gn,optionImageSrc as Wn,optionLabel as _n,PRODUCT_PATH_PREFIX as qn,parseDate as Un,parseLooseDate as jn,parseLooseDateRange as Qn,productFromMatchedItem as Yn,productImageSources as Zn,productsFromCustomFields as Vn,sanitizeOptionIconSvg as $n,selectedRangeFor as Xn,visibleDateRange as Jn,WEEKDAY_LABELS as er,withSkippedParams as tr}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Ii,useCallback as mt,useEffect as $t,useImperativeHandle as Ti,useLayoutEffect as Ei,useRef as We}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 In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
262
262
|
opacity: 0;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,document.head.appendChild(e)}var Ae={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
|
|
265
|
+
`,document.head.appendChild(e)}var Ae={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 ti,attachViewportFit as ai,containScroll as ii,hasSkippablePill as oi,isCalendarFormat as ni,labelTraditionalAutocomplete as ri,uiStringsFor as si}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Oe,useRef as De,useState as li}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
|
*
|
|
@@ -1098,7 +1098,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1098
1098
|
opacity: 0.25;
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
|
-
`,document.head.appendChild(e)}var se={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
|
|
1101
|
+
`,document.head.appendChild(e)}var se={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 na,cellIso as Re,dateCellMarks as ra,isoDate as sa,monthLabel as la,visibleDateRange as da,WEEKDAY_LABELS as ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as pa}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) ---
|
|
1102
1102
|
|
|
1103
1103
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1104
1104
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1261,7 +1261,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1261
1261
|
opacity: 0.8;
|
|
1262
1262
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1263
1263
|
}
|
|
1264
|
-
`,document.head.appendChild(e)}var
|
|
1264
|
+
`,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"};import{jsx as ae,jsxs as Ct}from"react/jsx-runtime";var ha=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Pt({options:e,activeIndex:o,listboxId:t,view:a,selection:n,onSelect:r,onHighlight:i,onUnhighlight:c,onPreviousMonth:l,onNextMonth:v}){let P=sa(new Date),C=da({pendingStart:n.rangeStart,highlightedIso:Re(e[o]),selected:n.selectedRange});return Ct("div",{className:D.datepicker,"data-aia-datepicker":"",children:[Ct("div",{className:D.header,children:[ae("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:g=>g.preventDefault(),onClick:l,children:"\u2039"}),ae("span",{className:D.month,"data-aia-date-month":"","aria-live":"polite",children:la(a)}),ae("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:g=>g.preventDefault(),onClick:v,children:"\u203A"})]}),ae("div",{className:D.weekdays,"aria-hidden":"true",children:ca.map((g,b)=>ae("span",{className:D.weekday,children:g},ha[b]))}),ae("div",{className:D.grid,"data-aia-date-grid":"",children:e.map((g,b)=>ae(ua,{option:g,id:`${t}-option-${b}`,index:b,isHighlighted:b===o&&g.is_tappable,isToday:Re(g)===P,isPast:Re(g)!=null&&Re(g)<P,marks:ra(Re(g),{selectedIso:n.selectedIso,range:C}),onSelect:r,onHighlight:i,onUnhighlight:c},Re(g)??`pad-${b}`))})]})}function ua({option:e,id:o,index:t,isHighlighted:a,isToday:n,isPast:r,marks:i,onSelect:c,onHighlight:l,onUnhighlight:v}){let[P,C]=pa(!1),g=na(e);if(g==null)return ae("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${D.cell} ${D.blank}`});let b=()=>{C(!0),c(e),setTimeout(()=>C(!1),170)},S=[D.cell,D.day,r?D.past:"",a?D.highlighted:"",n?D.today:"",i.inRange?D.inRange:"",i.selected?D.selected:"",P?D.pressed:""].filter(Boolean).join(" ");return ae("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:S,onClick:b,onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),b())},onMouseEnter:()=>l(t),onMouseLeave:v?()=>v(t):void 0,children:ae("span",{className:D.number,children:g})})}import{ATTRIBUTION_URL as ga,buildAttributionUrl as ma,getFooterHint as fa,uiStringsFor as ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as wa,useState as va}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 {
|
|
1265
1265
|
display: flex;
|
|
1266
1266
|
flex-wrap: wrap;
|
|
1267
1267
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1301,7 +1301,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1301
1301
|
.aia-cluster[data-justify="around"] {
|
|
1302
1302
|
justify-content: space-around;
|
|
1303
1303
|
}
|
|
1304
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1304
|
+
`,document.head.appendChild(e)}import{jsx as St}from"react/jsx-runtime";function Ke({gap:e,align:o="center",justify:t="start",noWrap:a=!1,inline:n=!1,className:r,children:i,...c}){let l=e?{"--aia-cluster-gap":e}:void 0,v={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":a||void 0,"data-inline":n||void 0,style:l,...c};return n?St("span",{...v,children:i}):St("div",{...v,children:i})}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
|
|
1305
1305
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1306
1306
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1307
1307
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1448,7 +1448,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1448
1448
|
justify-content: flex-end;
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
|
-
`,document.head.appendChild(e)}var le={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 Ge,jsxs as nt}from"react/jsx-runtime";function
|
|
1451
|
+
`,document.head.appendChild(e)}var le={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 Ge,jsxs as nt}from"react/jsx-runtime";function It({isOptionHighlighted:e=!1,isInputEmpty:o=!1,strings:t=ba()}){let{key:a,hint:n}=fa(e,o,t),[r,i]=va(ga);return wa(()=>{i(ma())},[]),Ge("footer",{className:le.footer,"data-aia-footer":"",children:nt(Ke,{justify:"between",noWrap:!0,className:le.row,children:[nt(Ke,{gap:"5px",className:le.hintGroup,children:[Ge("kbd",{className:le.key,children:a}),Ge("span",{className:le.hint,children:n})]}),nt("a",{className:le.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Ge("span",{className:le.brand,children:"AI"}),Ge("span",{className:le.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,
|
|
1452
1452
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1453
1453
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1454
1454
|
as it was when the outline was dashed. */
|
|
@@ -1524,7 +1524,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1524
1524
|
opacity: 0;
|
|
1525
1525
|
}
|
|
1526
1526
|
}
|
|
1527
|
-
`,document.head.appendChild(e)}var ye={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
|
|
1527
|
+
`,document.head.appendChild(e)}var ye={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 xa}from"react/jsx-runtime";var rt={selected:1,first:.7,next:.4,last:.2};function Tt({label:e,state:o,rounded:t,loading:a,onClick:n}){let r=[ye.pill,t?ye.rounded:"",a?ye.skeleton:""].filter(Boolean).join(" ");return xa("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:rt[o]},onMouseDown:i=>i.preventDefault(),onClick:a?void 0:n,disabled:a,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 {
|
|
1528
1528
|
position: relative;
|
|
1529
1529
|
z-index: 1;
|
|
1530
1530
|
pointer-events: auto;
|
|
@@ -1534,7 +1534,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1534
1534
|
align-items: center;
|
|
1535
1535
|
vertical-align: middle;
|
|
1536
1536
|
}
|
|
1537
|
-
`,document.head.appendChild(e)}var st={list:"aia-list-qvLqO"};import{jsx as Ze}from"react/jsx-runtime";var
|
|
1537
|
+
`,document.head.appendChild(e)}var st={list:"aia-list-qvLqO"};import{jsx as Ze}from"react/jsx-runtime";var ya=[125,69];function Et(e){return e===0?"first":e===1?"next":"last"}function Ve({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:a,rounded:n,loading:r}){return r&&e.length===0?Ze("span",{className:st.list,"data-aia-pill-list-loading":"",children:ya.map((i,c)=>Ze("span",{"data-aia-pill-skeleton":"",className:`${ye.pill} ${n?ye.rounded:""} ${ye.skeleton}`,style:{width:i,opacity:rt[Et(c)]}},`skel-${i}`))}):Ze("span",{className:st.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((i,c)=>{let l=!!a&&c===o;return Ze(Tt,{label:i.text,state:l?"selected":Et(c),selected:l,rounded:n,loading:r,onClick:()=>t(c)},`${i.parameter}-${i.text}`)})})}import{attachProductRowWheel as ka,productImageSources as Ca,productImageSrc as Pa,productInitial as Sa,uiStringsFor as Ia}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ta,useRef as Ea,useState as Aa}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
|
|
1538
1538
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1539
1539
|
theming one package sees the same result in the other.
|
|
1540
1540
|
|
|
@@ -1821,7 +1821,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1821
1821
|
letter-spacing: 0.02em;
|
|
1822
1822
|
text-align: center;
|
|
1823
1823
|
}
|
|
1824
|
-
`,document.head.appendChild(e)}var Y={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 de,jsxs as $e}from"react/jsx-runtime";function
|
|
1824
|
+
`,document.head.appendChild(e)}var Y={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 de,jsxs as $e}from"react/jsx-runtime";function At({products:e,listboxId:o,onSelect:t,onFocusChange:a,focusable:n=!0,layout:r="row",imageFallback:i="image",strings:c=Ia()}){let l=e.length>0,v=Ea(null);if(Ta(()=>{let C=v.current;if(!(!l||!C))return ka(C)},[l]),!l)return null;let P=`${o}-products-label`;return $e("section",{className:Y.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":P,children:[de("div",{className:Y.label,id:P,"data-aia-products-label":"",children:c.products}),de("div",{ref:v,className:Y.row,"data-aia-products-row":"",children:e.map((C,g)=>de(Ra,{product:C,id:`${o}-product-${g}`,onSelect:t,onFocusChange:a,focusable:n,imageFallback:i,soldOut:c.soldOut},C.id))})]})}function Ra({product:e,id:o,onSelect:t,onFocusChange:a,focusable:n,imageFallback:r,soldOut:i}){let c=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return $e("a",{id:o,className:Y.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:c,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>a?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||a?.(!1)},children:[de(Da,{sources:Ca(e.imageUrl),title:e.title,fallback:r},Pa(e.imageUrl)??""),$e("span",{className:Y.body,children:[e.vendor?de("span",{className:Y.vendor,children:e.vendor}):null,de("span",{className:Y.title,children:e.title}),e.price?de("span",{className:Y.price,children:e.price}):null,e.available===!1?de("span",{className:Y.badge,children:i}):null]})]})}function Da({sources:e,title:o,fallback:t}){let[a,n]=Aa(0),r=e[a],i=!!r,c=!i&&t==="initial";return $e("span",{className:Y.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!c?"":void 0,"data-aia-product-initial":c?"":void 0,children:[i?de("img",{className:Y.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>n(l=>l+1)}):null,c?Sa(o):null]})}import{isOptionsGridMobileViewport as Ua,measureOptionsGrid as ja,needsOptionsGridMeasurement as Qa,OPTIONS_GRID_MOBILE_QUERY as Ya,optionEnterDelayMs as Za,planOptionsGrid as Lt,sameOptionRows as Va}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $a,useLayoutEffect as Xa,useRef as zt,useState as Nt}from"react";import{optionsGridTemplateColumns as Oa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as La,useRef as za}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 {
|
|
1825
1825
|
display: grid;
|
|
1826
1826
|
grid-template-columns: repeat(
|
|
1827
1827
|
auto-fit,
|
|
@@ -1857,7 +1857,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
1857
1857
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1858
1858
|
display: none;
|
|
1859
1859
|
}
|
|
1860
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1860
|
+
`,document.head.appendChild(e)}import{jsx as Ma}from"react/jsx-runtime";function Rt({min:e="16rem",max:o,gap:t,scroll:a=!1,maxHeight:n,scrollResetKey:r,cols:i,template:c,innerRef:l,className:v,children:P,...C}){let g=za(null);La(()=>{if(r===void 0)return;let S=g.current;S&&(S.scrollTop=0)},[r]);let b={"--aia-grid-min":e};return o&&(b["--aia-grid-max"]=o),t&&(b["--aia-grid-gap"]=t),n&&(b["--aia-grid-max-height"]=n),i&&(b.gridTemplateColumns=Oa(i)),c&&(b.gridTemplateColumns=c),Ma("div",{ref:S=>{g.current=S,l?.(S)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":a||void 0,style:b,...C,children:P})}import{formatOptionCount as Na,highlightParts as Fa,OPTION_ENTER_DELAY_VAR as Ba,optionImageSources as Ha,optionLabel as Dt,sanitizeOptionIconSvg as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ga,useMemo as Wa,useRef as _a,useState as lt}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 {
|
|
1861
1861
|
position: relative;
|
|
1862
1862
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1863
1863
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2025,6 +2025,23 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
2025
2025
|
display: none;
|
|
2026
2026
|
}
|
|
2027
2027
|
|
|
2028
|
+
/* The parameter an option is a value of, under its text ("Flavor", "Subcategory"):
|
|
2029
|
+
muted and smaller, so options that read alike are told apart. Block inside the
|
|
2030
|
+
text box, so a hanging indent never moves it; a skeleton row drops it. */
|
|
2031
|
+
.aia-parameter-Dt2zF {
|
|
2032
|
+
display: block;
|
|
2033
|
+
font-size: var(--aia-option-parameter-font-size, 12px);
|
|
2034
|
+
font-weight: 400;
|
|
2035
|
+
line-height: 16px;
|
|
2036
|
+
text-indent: 0;
|
|
2037
|
+
color: var(--aia-option-parameter-color, inherit);
|
|
2038
|
+
opacity: var(--aia-option-parameter-opacity, 0.6);
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
.aia-item-d4vpD[data-aia-loading] .aia-parameter-Dt2zF {
|
|
2042
|
+
display: none;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2028
2045
|
/* Server-provided option icon (\`icon_svg\` on the option): a box exactly one
|
|
2029
2046
|
text line tall, top-aligned, so it sits centred on the first line of a
|
|
2030
2047
|
wrapped option and never grows the line box. The glyph draws in
|
|
@@ -2174,6 +2191,14 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
2174
2191
|
display: none;
|
|
2175
2192
|
}
|
|
2176
2193
|
|
|
2194
|
+
/* A grid of rows with a parameter line is taller per row: the row's 21px text
|
|
2195
|
+
line and 16px padding plus the 16px parameter line, so the visible-rows cap
|
|
2196
|
+
(\`--aia-grid-max-height\`) does not cut the last row. Before the picture rule,
|
|
2197
|
+
which wins when a group has both. */
|
|
2198
|
+
[data-aia-group]:has(.aia-parameter-Dt2zF) {
|
|
2199
|
+
--aia-option-row-height: 53px;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2177
2202
|
/* A grid of picture rows is taller per row: the visible-rows cap
|
|
2178
2203
|
(\`--aia-grid-max-height\`, computed from \`--aia-option-row-height\` by
|
|
2179
2204
|
planOptionsGrid) follows the tile's height plus the row's padding, so the
|
|
@@ -2261,7 +2286,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
2261
2286
|
opacity: 0;
|
|
2262
2287
|
}
|
|
2263
2288
|
}
|
|
2264
|
-
`,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 ke,jsxs as
|
|
2289
|
+
`,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",parameter:"aia-parameter-Dt2zF",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd"};import{Fragment as qa,jsx as ke,jsxs as dt}from"react/jsx-runtime";function Ot({option:e,isHighlighted:o,onSelect:t,onHighlight:a,onUnhighlight:n,id:r,loading:i,showIcon:c=!0,showImage:l=!0,showCount:v=!0,scrollHint:P,enterDelayMs:C=0}){let[g]=lt(C),[b,S]=lt(!1),L=l?Ha(e.image_url):[],z=L[0]??null,[K,O]=lt([]),I=L.find(E=>!K.includes(E))??null,F=Wa(()=>!z&&c&&e.icon_svg?Ka(e.icon_svg):null,[z,c,e.icon_svg]),M=v?Na(e.item_count):null,k=_a(void 0);Ga(()=>()=>clearTimeout(k.current),[]);let N=()=>{i||!e.is_tappable||b||(S(!0),t(e),clearTimeout(k.current),k.current=setTimeout(()=>S(!1),170))},G=[q.item,o&&!i?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,b?q.pressed:"",P?q.scrollHint:""].filter(Boolean).join(" ");return ke("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":F&&e.icon?e.icon:void 0,"data-aia-image":z?"":void 0,"data-aia-item-count":M!==null?e.item_count:void 0,"aria-selected":o,className:G,style:{[Ba]:`${g}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:N,onKeyDown:E=>{!i&&e.is_tappable&&(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),N())},onMouseEnter:!i&&e.is_tappable?a:void 0,onMouseLeave:n,children:dt("span",{className:q.content,children:[z&&ke("span",{className:`${q.image} magicx-aia-option-image`,"aria-hidden":"true",children:ke("img",{src:I??z,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:I===null,onError:()=>{I!==null&&O(E=>[...E,I])}})}),F&&ke("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:F}}),dt("span",{className:q.text,children:[e.matchedText?Fa(Dt(e),e.matchedText).map((E,V)=>E.bold?ke("strong",{children:E.text},V):E.text):Dt(e),e.parameterLabel&&dt(qa,{children:[" ",ke("span",{className:`${q.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&ke("span",{className:q.tag,children:e.tag}),M!==null&&ke("span",{className:`${q.count} magicx-aia-option-count`,children:M})]})})}import{jsx as Mt}from"react/jsx-runtime";function Ja(){let[e,o]=Nt(Ua);return $a(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ya),a=()=>o(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function Ft({options:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:n,listboxId:r,loading:i,groupKey:c="",optionsPosition:l="below",showIcons:v=!0,showImages:P=!0,showCounts:C=!0}){let g=Ja(),b=zt(null),[S,L]=Nt(null),z=zt(null);Xa(()=>{if(i&&Va(z.current,e))return;z.current=i?null:e;let O=b.current,F=O&&!i&&Qa(e.length,g)?ja(O):null;L(F?Lt(e.length,g,F.rowWidths,F.gridWidth):null)},[e,g,i]);let K=S??Lt(e.length,g,null,null);return Mt(Rt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:c,template:K.template,maxHeight:K.maxHeight,innerRef:O=>{b.current=O},"data-aia-group":c,children:e.map((O,I)=>Mt(Ot,{option:O,isHighlighted:I===o,onSelect:t,onHighlight:()=>a(I),onUnhighlight:n?()=>n(I):void 0,id:`${r}-option-${I}`,loading:i,showIcon:v,showImage:P,showCount:C,scrollHint:!i&&K.scrollHintIndices.includes(I),enterDelayMs:i?0:Za(I,K.cols,e.length,l)},`${c}\0${O.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2265
2290
|
display: flex;
|
|
2266
2291
|
flex-direction: column;
|
|
2267
2292
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2276,7 +2301,7 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
2276
2301
|
align-items: end;
|
|
2277
2302
|
}
|
|
2278
2303
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2279
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2304
|
+
`,document.head.appendChild(e)}import{jsx as ei}from"react/jsx-runtime";function Bt({space:e,align:o="stretch",className:t,children:a,...n}){let r=e?{"--aia-stack-space":e}:void 0;return ei("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:r,...n,children:a})}import{jsx as Z,jsxs as ct}from"react/jsx-runtime";var di=[159,119,164],ci=()=>{},Ht=()=>{};function pi(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=li(o);if(Oe(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(n.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function hi(e,o){let t=De(null);Oe(()=>{let a=e.current,n=o.current;if(!a||!n)return;let r=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:ti({dropdown:a,grid:r,button:n})};return}t.current?.controller.update()}),Oe(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function ui(e,o){let t=De(o);t.current=o;let a=De(null);Oe(()=>{let n=e.current;if(n){if(!a.current){a.current=ai({dropdown:n,isOpen:()=>t.current});return}a.current.update()}}),Oe(()=>()=>{a.current?.destroy(),a.current=null},[])}function pt({suggestions:e,activeIndex:o,onSelect:t,onHighlight:a,onUnhighlight:n,isOpen:r,id:i,className:c,pills:l,onPillClick:v,showPills:P=!0,onSkip:C,showSkipButton:g=!0,showOptionIcons:b=!0,showOptionImages:S=!0,showOptionCounts:L=!0,skipDisabled:z=!1,activeSelected:K=!1,isLoading:O=!1,skeletonExiting:I=!1,isInputEmpty:F=!1,language:M,products:k,onProductSelect:N,onProductFocusChange:G,productsLayout:E="row",productImageFallback:V="image",formatType:ce="options",dateView:W=null,selectedDateIso:pe=null,selectedDateRange:Ce=null,dateRangeStart:he=null,onPreviousMonth:u,onNextMonth:Pe,optionsPosition:ie="below",mode:ue}){let oe=pi(ue),ge=oe!==void 0,U=De(null),$=De(null);hi(U,$),Oe(()=>{if(U.current)return ii(U.current)},[]);let s=e[0]?.options??[],m=!!(l&&l.length>0&&v),f=!!(k&&k.length>0),w=r&&(s.length>0||P&&m||O||f);ui(U,w);let y={suggestions:e,activeIndex:o,pills:l,showPills:P,showSkipButton:g,showOptionIcons:b,showOptionImages:S,showOptionCounts:L,skipDisabled:z,activeSelected:K,isLoading:O,skeletonExiting:I,isInputEmpty:F,products:k,formatType:ce,dateView:W,selectedDateIso:pe,selectedDateRange:Ce,dateRangeStart:he},T=De(y);w&&(T.current=y);let p=w?y:T.current,B=si(M),j=p.suggestions[0],Q=j?.options??[],me=p.activeIndex>=0&&!!Q[p.activeIndex]?.is_tappable,ne=ri(p.pills??[],B.keepTyping),J=!!(ne.length>0&&v),fe=p.showPills&&J,Se=p.showPills&&!J&&p.isLoading,x=fe||Se,be=J&&oi(ne)&&p.showSkipButton&&!p.isInputEmpty&&!!C,we=ne[0]?.text,re=ni(p.formatType)&&p.dateView!=null,h=Q.length>0&&!re,Ie=Q.length>0&&re&&!p.isLoading,Ne=p.isLoading&&!h&&!Ie,ve=p.products??[];return ct("div",{ref:U,id:i,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":ve.length>0?"":void 0,className:`${ge?"magicx-aia ":""}${se.dropdown} ${w?se.visible:""} ${c??""}`,onMouseDown:ee=>ee.preventDefault(),children:[ct(Bt,{space:"8px",children:[(x||be)&&ct(Ke,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[x&&Z("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:Z(Ve,{pills:ne,activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:p.isLoading})}),be&&Z("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":we?`${B.skipLabel} ${we}`:B.skipLabel,onClick:C,children:B.skip})]}),h&&Z(Ft,{options:Q,activeIndex:p.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:n,listboxId:i,loading:p.isLoading,groupKey:j?`${j.parameter} ${j.text}`:"",optionsPosition:ie,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),Ie&&p.dateView&&Z(Pt,{options:Q,activeIndex:p.activeIndex,listboxId:i,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:n,onPreviousMonth:u??Ht,onNextMonth:Pe??Ht}),Ne&&Z("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:di.map(ee=>Z("span",{className:se.skeletonBar,style:{width:ee}},`bar-${ee}`))}),Z(At,{products:ve,listboxId:i,onSelect:N??ci,onFocusChange:G,focusable:w,layout:E,imageFallback:V,strings:B}),Z(It,{isOptionHighlighted:me,isInputEmpty:p.isInputEmpty,strings:B})]}),Z("button",{ref:$,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":B.scrollArrow,"aria-hidden":"true",children:Z("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:Z("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Ai,ModeController as Ri,setCursorOffset as Di,uiStringsFor as Oi}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as gi}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 {
|
|
2280
2305
|
flex-shrink: 0;
|
|
2281
2306
|
width: 32px;
|
|
2282
2307
|
height: 32px;
|
|
@@ -2329,5 +2354,5 @@ import{buildSubmitResult as In,cellDay as Tn,cellIso as En,DATE_RANGE_META_END a
|
|
|
2329
2354
|
);
|
|
2330
2355
|
cursor: default;
|
|
2331
2356
|
}
|
|
2332
|
-
`,document.head.appendChild(e)}var Ht={submitButton:"aia-submitButton-otz7H"};import{jsx as pt}from"react/jsx-runtime";function Kt({disabled:e,onClick:o,label:t=ui().submit}){return pt("button",{type:"button","data-aia-submit":"",className:Ht.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":t,children:pt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:pt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as gi,dateSelectionFor as mi,identifiedParamLabel as fi,withoutTraditionalAutocomplete as bi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ut,useEffect as Le,useRef as H,useState as wi}from"react";import{useRef as Gt}from"react";function Wt(e){let o=Gt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=Gt({key:"",overrides:void 0});if(a.current.key!==t){let n={};for(let r of Object.keys(e??{})){let i=(c,l,v)=>{let P=o.current?.[r];return P?P(c,l,v):[]};n[r]=i}a.current={key:t,overrides:e?n:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as _t}from"react";function qt(e){let o=_t(e);o.current=e;let t=_t(null);t.current===null&&(t.current={fetch:(n,r)=>{let i=o.current;return i?i.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var vi={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ht({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:n,apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:v,columns:P=2,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showOptionIcons:L,showOptionImages:z,showOptionCounts:K,showSkipButton:D,showProducts:I,productImageFallback:F="image",onFocus:M,onBlur:k,value:N,completedParams:G,onChange:E,onParamsChange:V,products:ce,mapProducts:W,onProductSelect:pe,source:Ce,setCursor:he}){let u=H(null),[Pe,ie]=wi(null),ue=H(e);ue.current=e;let oe=H(o);oe.current=o;let ge=H(t);ge.current=t;let U=H(E);U.current=E;let $=H(V);$.current=V;let s=H(M);s.current=M;let m=H(k);m.current=k;let f=H(he);f.current=he;let w=H(pe);w.current=pe;let y=H(v);y.current=v;let T=H(()=>{let d=y.current;return typeof d=="function"?d():d}).current,p=qt(ce),B=H(W);B.current=W;let j=H((d,_)=>{let A=B.current;return A?A(d,_):d}).current,Q=W?j:void 0,me=Wt(a);Le(()=>{if(typeof document>"u")return;let d=new gi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:T,optionOverrides:me.overrides,maskCompletedText:n,columns:P,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I,source:Ce,value:N,completedParams:G,onSubmit:(...A)=>ue.current?.(...A),onResult:(...A)=>oe.current?.(...A),onError:(...A)=>ge.current?.(...A),onChange:(...A)=>U.current?.(...A),onParamsChange:(...A)=>$.current?.(...A),onFocus:()=>s.current?.(),onBlur:()=>m.current?.(),onProductSelect:A=>w.current?.(A),setCursor:A=>f.current?.(A),products:p.config,mapProducts:Q});u.current=d,ie(d.getState());let _=d.subscribe(A=>ie(A));return()=>{_(),d.destroy(),u.current===d&&(u.current=null)}},[]),Le(()=>{N!==void 0&&u.current?.setValue(N)},[N]),Le(()=>{G!==void 0&&u.current?.setCompletedParams(G)},[G]);let ne=JSON.stringify(r??null),J;try{J=JSON.stringify(i??null)}catch{J="[unstringifiable]"}Le(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:c,productId:l,optionOverrides:me.overrides,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I})},[ne,J,c,l,me.key,C,g,b,S,I]);let fe=H(!1);Le(()=>{if(!fe.current){fe.current=!0;return}u.current?.update({products:p.config})},[p.enabled]),Le(()=>{u.current?.update({mapProducts:Q})},[Q]);let Se=H(null);Se.current===null&&(Se.current={handleTextChange:d=>u.current?.handleTextChange(d),handleKeyDown:d=>{let _="nativeEvent"in d?d.nativeEvent:d;u.current?.handleKeyDown(_)},setFocused:d=>u.current?.setFocused(d),startEditingParam:d=>u.current?.startEditingParam(d),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:d=>u.current?.handleCaretAfterInput(d),handleCaretMove:d=>u.current?.handleCaretMove(d),replaceEditingRange:d=>u.current?.replaceEditingRange(d)??!1,setActivePill:d=>u.current?.setActivePill(d),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:d=>u.current?.recordSubmit(d),selectOption:d=>u.current?.selectOption(d),selectProduct:d=>u.current?.selectProduct(d),setActiveDropdownIndex:d=>u.current?.setActiveDropdownIndex(d),clearHighlight:d=>u.current?.clearHighlight(d),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=Se.current,be=Ut(d=>{let _=d.target.value,at=_.length>0&&!d.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;u.current?.handleTextChange(at)},[]),we=Ut(d=>{u.current?.handleKeyDown(d.nativeEvent)},[]),re=u.current,h=Pe??vi,Ie=N!==void 0?N:h.text,Ne=G!==void 0?G:h.completedParams,ve=h.actionableSuggestions,ee=ve[0],_e=bi(ve),Te=re?.listboxId??"",et=h.activeDropdownIndex>=0&&re?`${Te}-option-${h.activeDropdownIndex}`:void 0,xe=h.editingParam,Ee=h.editingIdentified,Fe=xe?{parameter:xe.suggestionParameter,text:xe.suggestionPlaceholder,required:!0,options:xe.options}:Ee?{parameter:Ee.parameter,text:fi(Ee.parameter),required:!0,options:[]}:null,qe=h.dropdownSuggestion??Fe??ee,tt=Fe?[Fe]:ve,Be=mi(h),Ue=!re||h.dropdownLoading;return{completedParams:Ne,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:_e,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:Ue,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Te,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:xe,editingIdentified:Ee,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ie,placeholder:h.placeholderText||void 0,onChange:be,onKeyDown:we,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":et,"aria-autocomplete":"list","aria-controls":Te},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:qe?[{...qe,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Te,pills:tt,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(D??!0)&&!xe&&!Ee,showOptionIcons:L??!0,showOptionImages:z??!0,showOptionCounts:K??!0,skipDisabled:h.inSelectionAnimation,isLoading:Ue,skeletonExiting:h.skeletonExiting,isInputEmpty:Ie.trim().length===0,language:c,products:h.products,productImageFallback:F,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Be.selectedIso,selectedDateRange:Be.selectedRange,dateRangeStart:Be.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:g??"below"}}}import{chipIdFromTap as xi,extractPlainText as jt,getCursorOffset as Qt,keepCaretOnChip as yi,plainTextLength as ki,renderEditableContent as Ci,setCursorOffset as Yt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Xe,useLayoutEffect as ut,useRef as ze}from"react";var Je;function Pi(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Zt(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:n,editingParam:r,editingIdentified:i,editingAnchor:c,caretOffset:l,placeholderText:v,isFocused:P,isDropdownOpen:C,listboxId:g,activeDescendantId:b,autoFocus:S,handleTextChange:L,handleKeyDown:z,handleCaretAfterInput:K,handleCaretMove:D,startEditingParam:I,replaceEditingRange:F,setFocused:M}=e,k=ze(null),N=ze(!1),G=ze(""),E=ze(""),V=ze(null),ce=ze(0);V.current=l,Xe(()=>{if(!S)return;let s=k.current;if(!s)return;document.activeElement===s?M(!0):s.focus();let m=s.ownerDocument??document,f=m.getSelection(),w=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!w){let y=m.createRange();y.selectNodeContents(s),y.collapse(!0),f.removeAllRanges(),f.addRange(y)}},[S,M]),Xe(()=>{let s=k.current;if(!s)return;let m=s.ownerDocument??document,f=()=>{let w=m.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!s.contains(w.anchorNode))return;let y=w.anchorNode,T=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,B=(w.isCollapsed?T?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=r?.id??i?.id??null;if(B&&B!==j){I(B);return}performance.now()-ce.current<50||D(Qt(s))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[r,i,I,D]),Xe(()=>{let s=k.current;if(!s)return;let m=f=>{let w=xi(s,f.target);w&&(I(w),yi(s,w))};return s.addEventListener("click",m),()=>s.removeEventListener("click",m)},[I]),ut(()=>{let s=k.current;s&&Ci({input:s,segments:o,newParamId:n,editingParamId:r?.id??null,placeholderText:v??"",isFocused:P,showChipIcons:t,showChipImages:a})},[o,n,r,v,P,t,a]),ut(()=>{let s=G.current,m=n??"";if(G.current=m,!m||m===s)return;let f=k.current;if(!f)return;f.focus();let w=V.current??ki(f);Yt(f,w)},[n]),ut(()=>{let s=E.current,m=r?.id??"";if(E.current=m,!m||m===s||c==null)return;let f=k.current;f&&Yt(f,c)},[r,c]);let W=X(()=>{if(N.current)return;let s=k.current;if(!s)return;let m=jt(s),w=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;L(w)},[L]),pe=X(()=>{ce.current=performance.now(),W();let s=k.current;s&&K(Qt(s))},[W,K]);Xe(()=>{let s=k.current;if(!s)return;let m=f=>{let w=f,y=w.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){f.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let T=y.startsWith("delete")?"":w.data??"";F(T)&&f.preventDefault()}};return s.addEventListener("beforeinput",m),()=>s.removeEventListener("beforeinput",m)},[F]);let Ce=X(()=>{N.current=!0},[]),he=X(()=>{N.current=!1,W()},[W]),u=X(s=>{s.preventDefault();let m=k.current;if(!m)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let w=m.ownerDocument??document,y=w.getSelection();if(!y||y.rangeCount===0)return;let T=y.getRangeAt(0);if(!m.contains(T.startContainer))return;T.deleteContents();let p=w.createTextNode(f);T.insertNode(p),T.setStartAfter(p),T.collapse(!0),y.removeAllRanges(),y.addRange(T),W()},[W]),Pe=X(s=>z(s),[z]),ie=X(()=>M(!0),[M]),ue=X(()=>M(!1),[M]),oe=X(()=>k.current?.focus(),[]),ge=X(()=>k.current?.blur(),[]),U=X(()=>{let s=k.current;return s?jt(s):""},[]),$=Pi()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:$,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":C,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:Pe,onCompositionStart:Ce,onCompositionEnd:he,onPaste:u,onFocus:ie,onBlur:ue},getPlainText:U,focus:oe,blur:ge}}import{jsx as Me,jsxs as mt}from"react/jsx-runtime";function Di(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Li=Si(function({onSubmit:o,onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,className:i,apiConfig:c,additionalContext:l,language:v,productId:P,visitorId:C,columns:g,pillPlacement:b="dropdown",mode:S="auto",optionsPosition:L="below",animations:z=!0,dropdownTrigger:K,closeDropdownOnBlur:D,showNonTappableOptions:I,showOptionIcons:F=!0,showChipIcons:M=!0,showChipImages:k=!0,showOptionImages:N=!0,showOptionCounts:G=!0,showSkipButton:E,showProducts:V,productsLayout:ce,productImageFallback:W,autoFocus:pe=!0,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,submitButton:$,resetOnSubmit:s=!0},m){let f=We(null),w=We(null),y=We(()=>{}),T=We(null),p=We(null);Vt(()=>{let R=f.current;if(R)return T.current?T.current.setMode(S):T.current=new Ai(R,S),()=>{T.current?.destroy(),T.current=null}},[S]);let B=gt(R=>{let te=p.current?.current;te&&(te.focus(),Ri(te,R))},[]),{completedParams:j,skippedParams:Q,identifiedParams:me,isReady:ne,customFields:J,suggestionPills:fe,setActivePill:Se,skipActivePill:x,segments:be,newParamId:we,clearNewParamId:re,placeholderText:h,isFocused:Ie,isDropdownOpen:Ne,isActivePillSelected:ve,isLoading:ee,activeIndex:_e,listboxId:Te,handleTextChange:et,handleKeyDown:xe,setFocused:Ee,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,startEditingParam:Ue,handleCaretAfterInput:d,handleCaretMove:_,replaceEditingRange:A,dropdownProps:at,reset:je,refreshProducts:ft,recordSubmit:bt}=ht({onSubmit:R=>y.current(R),onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:c,additionalContext:l,language:v,productId:P,visitorId:C,columns:g,dropdownTrigger:K,optionsPosition:L,closeDropdownOnBlur:D,showNonTappableOptions:I,showOptionIcons:F,showOptionImages:N,showOptionCounts:G,showSkipButton:E,showProducts:V,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,source:"full-sdk",setCursor:B});Vt(()=>{if(!we)return;let R=window.setTimeout(()=>re(),650);return()=>window.clearTimeout(R)},[we,re]);let $t=_e>=0?`${Te}-option-${_e}`:void 0,{inputRef:it,editorProps:Xt,focus:Qe,blur:wt,getPlainText:vt}=Zt({segments:be,newParamId:we,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,placeholderText:h,isFocused:Ie,showChipIcons:M,showChipImages:k,isDropdownOpen:Ne,listboxId:Te,activeDescendantId:$t,autoFocus:pe,handleTextChange:et,handleKeyDown:xe,handleCaretAfterInput:d,handleCaretMove:_,startEditingParam:Ue,replaceEditingRange:A,setFocused:Ee});p.current=it,Ti(()=>{let R=w.current,te=it.current;if(!R||!te)return;let He=()=>{let yt=R.firstElementChild;if(!yt)return;let aa=yt.getBoundingClientRect(),ia=te.getBoundingClientRect();aa.top>=ia.bottom-2?R.setAttribute("data-aia-pill-wrapped",""):R.removeAttribute("data-aia-pill-wrapped")};He();let xt=new ResizeObserver(He);return xt.observe(te),()=>xt.disconnect()},[be,fe.length,ee,it]),Ii(m,()=>({focus:Qe,blur:wt,reset:je,refreshProducts:ft,setMode:R=>T.current?.setMode(R),skipActivePill:x}),[Qe,wt,je,ft,x]);let Ye=!!be.length||j.length>0,ot=gt(R=>{if(!Ye)return;let te=vt(),He=Ei(te,j,Q,{identifiedParams:me,isReady:ne,customFields:J});R&&bt(He),o(He),s&&je()},[bt,s,Ye,j,Q,me,ne,J,o,je,vt]);y.current=()=>ot(!1);let Jt=gt(R=>{R.target?.closest("[data-aia-pill]")||Qe()},[Qe]),ea=b==="inline",ta=b==="dropdown";return mt("div",{ref:f,className:`magicx-aia ${Ae.container} ${i??""}`,"data-pill-placement":b,"data-options-position":L,"data-animations":z?"on":"off","data-mode":Di(S),children:[Me(ct,{...at,showPills:ta,productsLayout:ce,productImageFallback:W}),mt("div",{className:Ae.inputWrapper,"data-aia-input-wrapper":"",onClick:Jt,children:[mt("div",{className:Ae.editorArea,"data-aia-editor":"",children:[Me("div",{...Xt,className:Ae.input,"data-aia-input":""}),ea&&(ee||fe.length>0)&&Me("span",{ref:w,className:Ae.pillListContainer,"data-aia-pill-list-container":"",children:Me(Ve,{pills:fe,activePillIndex:0,activeSelected:ve,onSelectPill:Se,loading:ee})})]}),$===null?null:$===void 0?Me(Kt,{disabled:!Ye,onClick:()=>ot(!0),label:Oi(v).submit}):Me("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ae.submitSlot,onClick:R=>{Ye&&(R.stopPropagation(),ot(!0))},children:$})]})]})});export{Li as AIAutocomplete,ct as AIAutocompleteDropdown,An as DATE_RANGE_META_END,Rn as DATE_RANGE_META_START,On as DEFAULT_OPTION_COUNT_UNIT,_n as PRODUCT_PATH_PREFIX,Jn as WEEKDAY_LABELS,In as buildSubmitResult,Tn as cellDay,En as cellIso,Dn as dateCellMarks,Ln as formatDate,zn as formatDateRange,Mn as formatOptionCount,Nn as isoDate,Fn as monthLabel,Bn as optionCountLabel,Hn as optionHasImage,Kn as optionImageSources,Gn as optionImageSrc,Wn as optionLabel,qn as parseDate,Un as parseLooseDate,jn as parseLooseDateRange,Qn as productFromMatchedItem,Yn as productImageSources,Zn as productsFromCustomFields,Vn as sanitizeOptionIconSvg,$n as selectedRangeFor,ht as useAIAutocomplete,Xn as visibleDateRange,er as withSkippedParams};
|
|
2357
|
+
`,document.head.appendChild(e)}var Kt={submitButton:"aia-submitButton-otz7H"};import{jsx as ht}from"react/jsx-runtime";function Gt({disabled:e,onClick:o,label:t=gi().submit}){return ht("button",{type:"button","data-aia-submit":"",className:Kt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":t,children:ht("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:ht("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as mi,dateSelectionFor as fi,identifiedParamLabel as bi,withoutTraditionalAutocomplete as wi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as jt,useEffect as Le,useRef as H,useState as vi}from"react";import{useRef as Wt}from"react";function _t(e){let o=Wt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=Wt({key:"",overrides:void 0});if(a.current.key!==t){let n={};for(let r of Object.keys(e??{})){let i=(c,l,v)=>{let P=o.current?.[r];return P?P(c,l,v):[]};n[r]=i}a.current={key:t,overrides:e?n:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as qt}from"react";function Ut(e){let o=qt(e);o.current=e;let t=qt(null);t.current===null&&(t.current={fetch:(n,r)=>{let i=o.current;return i?i.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var xi={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ut({onSubmit:e,onResult:o,onError:t,optionOverrides:a,maskCompletedText:n,apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:v,columns:P=2,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showOptionIcons:L,showOptionImages:z,showOptionCounts:K,showSkipButton:O,showProducts:I,productImageFallback:F="image",onFocus:M,onBlur:k,value:N,completedParams:G,onChange:E,onParamsChange:V,products:ce,mapProducts:W,onProductSelect:pe,source:Ce,setCursor:he}){let u=H(null),[Pe,ie]=vi(null),ue=H(e);ue.current=e;let oe=H(o);oe.current=o;let ge=H(t);ge.current=t;let U=H(E);U.current=E;let $=H(V);$.current=V;let s=H(M);s.current=M;let m=H(k);m.current=k;let f=H(he);f.current=he;let w=H(pe);w.current=pe;let y=H(v);y.current=v;let T=H(()=>{let d=y.current;return typeof d=="function"?d():d}).current,p=Ut(ce),B=H(W);B.current=W;let j=H((d,_)=>{let A=B.current;return A?A(d,_):d}).current,Q=W?j:void 0,me=_t(a);Le(()=>{if(typeof document>"u")return;let d=new mi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:T,optionOverrides:me.overrides,maskCompletedText:n,columns:P,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I,source:Ce,value:N,completedParams:G,onSubmit:(...A)=>ue.current?.(...A),onResult:(...A)=>oe.current?.(...A),onError:(...A)=>ge.current?.(...A),onChange:(...A)=>U.current?.(...A),onParamsChange:(...A)=>$.current?.(...A),onFocus:()=>s.current?.(),onBlur:()=>m.current?.(),onProductSelect:A=>w.current?.(A),setCursor:A=>f.current?.(A),products:p.config,mapProducts:Q});u.current=d,ie(d.getState());let _=d.subscribe(A=>ie(A));return()=>{_(),d.destroy(),u.current===d&&(u.current=null)}},[]),Le(()=>{N!==void 0&&u.current?.setValue(N)},[N]),Le(()=>{G!==void 0&&u.current?.setCompletedParams(G)},[G]);let ne=JSON.stringify(r??null),J;try{J=JSON.stringify(i??null)}catch{J="[unstringifiable]"}Le(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:c,productId:l,optionOverrides:me.overrides,dropdownTrigger:C,optionsPosition:g,closeDropdownOnBlur:b,showNonTappableOptions:S,showProducts:I})},[ne,J,c,l,me.key,C,g,b,S,I]);let fe=H(!1);Le(()=>{if(!fe.current){fe.current=!0;return}u.current?.update({products:p.config})},[p.enabled]),Le(()=>{u.current?.update({mapProducts:Q})},[Q]);let Se=H(null);Se.current===null&&(Se.current={handleTextChange:d=>u.current?.handleTextChange(d),handleKeyDown:d=>{let _="nativeEvent"in d?d.nativeEvent:d;u.current?.handleKeyDown(_)},setFocused:d=>u.current?.setFocused(d),startEditingParam:d=>u.current?.startEditingParam(d),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:d=>u.current?.handleCaretAfterInput(d),handleCaretMove:d=>u.current?.handleCaretMove(d),replaceEditingRange:d=>u.current?.replaceEditingRange(d)??!1,setActivePill:d=>u.current?.setActivePill(d),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:d=>u.current?.recordSubmit(d),selectOption:d=>u.current?.selectOption(d),selectProduct:d=>u.current?.selectProduct(d),setActiveDropdownIndex:d=>u.current?.setActiveDropdownIndex(d),clearHighlight:d=>u.current?.clearHighlight(d),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=Se.current,be=jt(d=>{let _=d.target.value,at=_.length>0&&!d.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;u.current?.handleTextChange(at)},[]),we=jt(d=>{u.current?.handleKeyDown(d.nativeEvent)},[]),re=u.current,h=Pe??xi,Ie=N!==void 0?N:h.text,Ne=G!==void 0?G:h.completedParams,ve=h.actionableSuggestions,ee=ve[0],_e=wi(ve),Te=re?.listboxId??"",et=h.activeDropdownIndex>=0&&re?`${Te}-option-${h.activeDropdownIndex}`:void 0,xe=h.editingParam,Ee=h.editingIdentified,Fe=xe?{parameter:xe.suggestionParameter,text:xe.suggestionPlaceholder,required:!0,options:xe.options}:Ee?{parameter:Ee.parameter,text:bi(Ee.parameter),required:!0,options:[]}:null,qe=h.dropdownSuggestion??Fe??ee,tt=Fe?[Fe]:ve,Be=fi(h),Ue=!re||h.dropdownLoading;return{completedParams:Ne,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:_e,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:Ue,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Te,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:xe,editingIdentified:Ee,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ie,placeholder:h.placeholderText||void 0,onChange:be,onKeyDown:we,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":et,"aria-autocomplete":"list","aria-controls":Te},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:qe?[{...qe,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Te,pills:tt,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(O??!0)&&!xe&&!Ee,showOptionIcons:L??!0,showOptionImages:z??!0,showOptionCounts:K??!0,skipDisabled:h.inSelectionAnimation,isLoading:Ue,skeletonExiting:h.skeletonExiting,isInputEmpty:Ie.trim().length===0,language:c,products:h.products,productImageFallback:F,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Be.selectedIso,selectedDateRange:Be.selectedRange,dateRangeStart:Be.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:g??"below"}}}import{chipIdFromTap as yi,extractPlainText as Qt,getCursorOffset as Yt,keepCaretOnChip as ki,plainTextLength as Ci,renderEditableContent as Pi,setCursorOffset as Zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Xe,useLayoutEffect as gt,useRef as ze}from"react";var Je;function Si(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Vt(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:n,editingParam:r,editingIdentified:i,editingAnchor:c,caretOffset:l,placeholderText:v,isFocused:P,isDropdownOpen:C,listboxId:g,activeDescendantId:b,autoFocus:S,handleTextChange:L,handleKeyDown:z,handleCaretAfterInput:K,handleCaretMove:O,startEditingParam:I,replaceEditingRange:F,setFocused:M}=e,k=ze(null),N=ze(!1),G=ze(""),E=ze(""),V=ze(null),ce=ze(0);V.current=l,Xe(()=>{if(!S)return;let s=k.current;if(!s)return;document.activeElement===s?M(!0):s.focus();let m=s.ownerDocument??document,f=m.getSelection(),w=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!w){let y=m.createRange();y.selectNodeContents(s),y.collapse(!0),f.removeAllRanges(),f.addRange(y)}},[S,M]),Xe(()=>{let s=k.current;if(!s)return;let m=s.ownerDocument??document,f=()=>{let w=m.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!s.contains(w.anchorNode))return;let y=w.anchorNode,T=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,B=(w.isCollapsed?T?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=r?.id??i?.id??null;if(B&&B!==j){I(B);return}performance.now()-ce.current<50||O(Yt(s))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[r,i,I,O]),Xe(()=>{let s=k.current;if(!s)return;let m=f=>{let w=yi(s,f.target);w&&(I(w),ki(s,w))};return s.addEventListener("click",m),()=>s.removeEventListener("click",m)},[I]),gt(()=>{let s=k.current;s&&Pi({input:s,segments:o,newParamId:n,editingParamId:r?.id??null,placeholderText:v??"",isFocused:P,showChipIcons:t,showChipImages:a})},[o,n,r,v,P,t,a]),gt(()=>{let s=G.current,m=n??"";if(G.current=m,!m||m===s)return;let f=k.current;if(!f)return;f.focus();let w=V.current??Ci(f);Zt(f,w)},[n]),gt(()=>{let s=E.current,m=r?.id??"";if(E.current=m,!m||m===s||c==null)return;let f=k.current;f&&Zt(f,c)},[r,c]);let W=X(()=>{if(N.current)return;let s=k.current;if(!s)return;let m=Qt(s),w=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;L(w)},[L]),pe=X(()=>{ce.current=performance.now(),W();let s=k.current;s&&K(Yt(s))},[W,K]);Xe(()=>{let s=k.current;if(!s)return;let m=f=>{let w=f,y=w.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){f.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let T=y.startsWith("delete")?"":w.data??"";F(T)&&f.preventDefault()}};return s.addEventListener("beforeinput",m),()=>s.removeEventListener("beforeinput",m)},[F]);let Ce=X(()=>{N.current=!0},[]),he=X(()=>{N.current=!1,W()},[W]),u=X(s=>{s.preventDefault();let m=k.current;if(!m)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let w=m.ownerDocument??document,y=w.getSelection();if(!y||y.rangeCount===0)return;let T=y.getRangeAt(0);if(!m.contains(T.startContainer))return;T.deleteContents();let p=w.createTextNode(f);T.insertNode(p),T.setStartAfter(p),T.collapse(!0),y.removeAllRanges(),y.addRange(T),W()},[W]),Pe=X(s=>z(s),[z]),ie=X(()=>M(!0),[M]),ue=X(()=>M(!1),[M]),oe=X(()=>k.current?.focus(),[]),ge=X(()=>k.current?.blur(),[]),U=X(()=>{let s=k.current;return s?Qt(s):""},[]),$=Si()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:$,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":C,"aria-activedescendant":b,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:Pe,onCompositionStart:Ce,onCompositionEnd:he,onPaste:u,onFocus:ie,onBlur:ue},getPlainText:U,focus:oe,blur:ge}}import{jsx as Me,jsxs as ft}from"react/jsx-runtime";function Li(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var zi=Ii(function({onSubmit:o,onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,className:i,apiConfig:c,additionalContext:l,language:v,productId:P,visitorId:C,columns:g,pillPlacement:b="dropdown",mode:S="auto",optionsPosition:L="below",animations:z=!0,dropdownTrigger:K,closeDropdownOnBlur:O,showNonTappableOptions:I,showOptionIcons:F=!0,showChipIcons:M=!0,showChipImages:k=!0,showOptionImages:N=!0,showOptionCounts:G=!0,showSkipButton:E,showProducts:V,productsLayout:ce,productImageFallback:W,autoFocus:pe=!0,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,submitButton:$,resetOnSubmit:s=!0},m){let f=We(null),w=We(null),y=We(()=>{}),T=We(null),p=We(null);$t(()=>{let R=f.current;if(R)return T.current?T.current.setMode(S):T.current=new Ri(R,S),()=>{T.current?.destroy(),T.current=null}},[S]);let B=mt(R=>{let te=p.current?.current;te&&(te.focus(),Di(te,R))},[]),{completedParams:j,skippedParams:Q,identifiedParams:me,isReady:ne,customFields:J,suggestionPills:fe,setActivePill:Se,skipActivePill:x,segments:be,newParamId:we,clearNewParamId:re,placeholderText:h,isFocused:Ie,isDropdownOpen:Ne,isActivePillSelected:ve,isLoading:ee,activeIndex:_e,listboxId:Te,handleTextChange:et,handleKeyDown:xe,setFocused:Ee,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,startEditingParam:Ue,handleCaretAfterInput:d,handleCaretMove:_,replaceEditingRange:A,dropdownProps:at,reset:je,refreshProducts:bt,recordSubmit:wt}=ut({onSubmit:R=>y.current(R),onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:c,additionalContext:l,language:v,productId:P,visitorId:C,columns:g,dropdownTrigger:K,optionsPosition:L,closeDropdownOnBlur:O,showNonTappableOptions:I,showOptionIcons:F,showOptionImages:N,showOptionCounts:G,showSkipButton:E,showProducts:V,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,source:"full-sdk",setCursor:B});$t(()=>{if(!we)return;let R=window.setTimeout(()=>re(),650);return()=>window.clearTimeout(R)},[we,re]);let Xt=_e>=0?`${Te}-option-${_e}`:void 0,{inputRef:it,editorProps:Jt,focus:Qe,blur:vt,getPlainText:xt}=Vt({segments:be,newParamId:we,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,placeholderText:h,isFocused:Ie,showChipIcons:M,showChipImages:k,isDropdownOpen:Ne,listboxId:Te,activeDescendantId:Xt,autoFocus:pe,handleTextChange:et,handleKeyDown:xe,handleCaretAfterInput:d,handleCaretMove:_,startEditingParam:Ue,replaceEditingRange:A,setFocused:Ee});p.current=it,Ei(()=>{let R=w.current,te=it.current;if(!R||!te)return;let He=()=>{let kt=R.firstElementChild;if(!kt)return;let ia=kt.getBoundingClientRect(),oa=te.getBoundingClientRect();ia.top>=oa.bottom-2?R.setAttribute("data-aia-pill-wrapped",""):R.removeAttribute("data-aia-pill-wrapped")};He();let yt=new ResizeObserver(He);return yt.observe(te),()=>yt.disconnect()},[be,fe.length,ee,it]),Ti(m,()=>({focus:Qe,blur:vt,reset:je,refreshProducts:bt,setMode:R=>T.current?.setMode(R),skipActivePill:x}),[Qe,vt,je,bt,x]);let Ye=!!be.length||j.length>0,ot=mt(R=>{if(!Ye)return;let te=xt(),He=Ai(te,j,Q,{identifiedParams:me,isReady:ne,customFields:J});R&&wt(He),o(He),s&&je()},[wt,s,Ye,j,Q,me,ne,J,o,je,xt]);y.current=()=>ot(!1);let ea=mt(R=>{R.target?.closest("[data-aia-pill]")||Qe()},[Qe]),ta=b==="inline",aa=b==="dropdown";return ft("div",{ref:f,className:`magicx-aia ${Ae.container} ${i??""}`,"data-pill-placement":b,"data-options-position":L,"data-animations":z?"on":"off","data-mode":Li(S),children:[Me(pt,{...at,showPills:aa,productsLayout:ce,productImageFallback:W}),ft("div",{className:Ae.inputWrapper,"data-aia-input-wrapper":"",onClick:ea,children:[ft("div",{className:Ae.editorArea,"data-aia-editor":"",children:[Me("div",{...Jt,className:Ae.input,"data-aia-input":""}),ta&&(ee||fe.length>0)&&Me("span",{ref:w,className:Ae.pillListContainer,"data-aia-pill-list-container":"",children:Me(Ve,{pills:fe,activePillIndex:0,activeSelected:ve,onSelectPill:Se,loading:ee})})]}),$===null?null:$===void 0?Me(Gt,{disabled:!Ye,onClick:()=>ot(!0),label:Oi(v).submit}):Me("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ae.submitSlot,onClick:R=>{Ye&&(R.stopPropagation(),ot(!0))},children:$})]})]})});export{zi as AIAutocomplete,pt as AIAutocompleteDropdown,Rn as DATE_RANGE_META_END,Dn as DATE_RANGE_META_START,On as DEFAULT_OPTION_COUNT_UNIT,qn as PRODUCT_PATH_PREFIX,er as WEEKDAY_LABELS,Tn as buildSubmitResult,En as cellDay,An as cellIso,Ln as dateCellMarks,zn as formatDate,Mn as formatDateRange,Nn as formatOptionCount,Fn as isoDate,Bn as monthLabel,Hn as optionCountLabel,Kn as optionHasImage,Gn as optionImageSources,Wn as optionImageSrc,_n as optionLabel,Un as parseDate,jn as parseLooseDate,Qn as parseLooseDateRange,Yn as productFromMatchedItem,Zn as productImageSources,Vn as productsFromCustomFields,$n as sanitizeOptionIconSvg,Xn as selectedRangeFor,ut as useAIAutocomplete,Jn as visibleDateRange,tr as withSkippedParams};
|
|
2333
2358
|
//# sourceMappingURL=index.mjs.map
|