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