@magicx-eng/ai-autocomplete-react 0.29.4 → 0.30.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 +8 -0
- package/dist/index.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +13 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as dn,cellDay as cn,cellIso as pn,DATE_RANGE_META_END as hn,DATE_RANGE_META_START as un,DEFAULT_OPTION_COUNT_UNIT as mn,dateCellMarks as gn,formatDate as fn,formatDateRange as bn,formatOptionCount as vn,isoDate as wn,monthLabel as xn,optionCountLabel as yn,optionHasImage as kn,optionImageSrc as Cn,optionLabel as Pn,PRODUCT_PATH_PREFIX as Sn,parseDate as In,parseLooseDate as En,parseLooseDateRange as Tn,productFromMatchedItem as An,productsFromCustomFields as Rn,sanitizeOptionIconSvg as On,selectedRangeFor as Dn,visibleDateRange as Ln,WEEKDAY_LABELS as Mn,withSkippedParams as zn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ci,useCallback as st,useEffect as Gt,useImperativeHandle as pi,useLayoutEffect as hi,useRef as ze}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 nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
262
262
|
opacity: 0;
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
`,document.head.appendChild(e)}var
|
|
265
|
+
`,document.head.appendChild(e)}var 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 Ua,containScroll as Qa,isCalendarFormat as Ya,SCROLL_ARROW_LABEL as ja}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ue,useRef as qe,useState as Za}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
|
*
|
|
@@ -1041,7 +1041,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1041
1041
|
opacity: 0.25;
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
`,document.head.appendChild(e)}var re={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as
|
|
1044
|
+
`,document.head.appendChild(e)}var re={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as 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) ---
|
|
1045
1045
|
|
|
1046
1046
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1047
1047
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1204,7 +1204,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1204
1204
|
opacity: 0.8;
|
|
1205
1205
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1206
1206
|
}
|
|
1207
|
-
`,document.head.appendChild(e)}var
|
|
1207
|
+
`,document.head.appendChild(e)}var O={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as V,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:l,onPreviousMonth:y,onNextMonth:v}){let w=ta(new Date),P=ia({pendingStart:r.rangeStart,highlightedIso:Ie(e[o]),selected:r.selectedRange});return mt("div",{className:O.datepicker,"data-aia-datepicker":"",children:[mt("div",{className:O.header,children:[V("button",{type:"button",tabIndex:-1,className:O.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:y,children:"\u2039"}),V("span",{className:O.month,"data-aia-date-month":"","aria-live":"polite",children:aa(n)}),V("button",{type:"button",tabIndex:-1,className:O.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u203A"})]}),V("div",{className:O.weekdays,"aria-hidden":"true",children:oa.map((u,x)=>V("span",{className:O.weekday,children:u},ra[x]))}),V("div",{className:O.grid,"data-aia-date-grid":"",children:e.map((u,x)=>V(sa,{option:u,id:`${t}-option-${x}`,index:x,isHighlighted:x===o&&u.is_tappable,isToday:Ie(u)===w,isPast:Ie(u)!=null&&Ie(u)<w,marks:ea(Ie(u),{selectedIso:r.selectedIso,range:P}),onSelect:i,onHighlight:a,onUnhighlight:l},Ie(u)??`pad-${x}`))})]})}function sa({option:e,id:o,index:t,isHighlighted:n,isToday:r,isPast:i,marks:a,onSelect:l,onHighlight:y,onUnhighlight:v}){let[w,P]=na(!1),u=Jt(e);if(u==null)return V("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${O.cell} ${O.blank}`});let x=()=>{P(!0),l(e),setTimeout(()=>P(!1),170)},T=[O.cell,O.day,i?O.past:"",n?O.highlighted:"",r?O.today:"",a.inRange?O.inRange:"",a.selected?O.selected:"",w?O.pressed:""].filter(Boolean).join(" ");return V("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:T,onClick:x,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),x())},onMouseEnter:()=>y(t),onMouseLeave:v?()=>v(t):void 0,children:V("span",{className:O.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 {
|
|
1208
1208
|
display: flex;
|
|
1209
1209
|
flex-wrap: wrap;
|
|
1210
1210
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1244,7 +1244,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1244
1244
|
.aia-cluster[data-justify="around"] {
|
|
1245
1245
|
justify-content: space-around;
|
|
1246
1246
|
}
|
|
1247
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1247
|
+
`,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,...l}){let y=e?{"--aia-cluster-gap":e}:void 0,v={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":o,"data-justify":t,"data-nowrap":n||void 0,"data-inline":r||void 0,style:y,...l};return r?ft("span",{...v,children:a}):ft("div",{...v,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
|
|
1248
1248
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1249
1249
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1250
1250
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1378,7 +1378,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1378
1378
|
justify-content: flex-end;
|
|
1379
1379
|
}
|
|
1380
1380
|
}
|
|
1381
|
-
`,document.head.appendChild(e)}var se={footer:"aia-footer-qQQ7x",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",row:"aia-row-BgZ6Q"};import{jsx as
|
|
1381
|
+
`,document.head.appendChild(e)}var se={footer:"aia-footer-qQQ7x",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",row:"aia-row-BgZ6Q"};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:se.footer,"data-aia-footer":"",children:Xe(De,{justify:"between",noWrap:!0,className:se.row,children:[Xe(De,{gap:"5px",className:se.hintGroup,children:[Le("kbd",{className:se.key,children:t}),Le("span",{className:se.hint,children:n})]}),Xe("a",{className:se.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Le("span",{className:se.brand,children:"AI"}),Le("span",{className:se.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
1382
1382
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1383
1383
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1384
1384
|
as it was when the outline was dashed. */
|
|
@@ -1454,7 +1454,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1454
1454
|
opacity: 0;
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
|
-
`,document.head.appendChild(e)}var
|
|
1457
|
+
`,document.head.appendChild(e)}var fe={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 ua}from"react/jsx-runtime";var Je={selected:1,first:.7,next:.4,last:.2};function vt({label:e,state:o,rounded:t,loading:n,onClick:r}){let i=[fe.pill,t?fe.rounded:"",n?fe.skeleton:""].filter(Boolean).join(" ");return ua("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:Je[o]},onMouseDown:a=>a.preventDefault(),onClick:n?void 0:r,disabled:n,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 {
|
|
1458
1458
|
position: relative;
|
|
1459
1459
|
z-index: 1;
|
|
1460
1460
|
pointer-events: auto;
|
|
@@ -1464,7 +1464,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1464
1464
|
align-items: center;
|
|
1465
1465
|
vertical-align: middle;
|
|
1466
1466
|
}
|
|
1467
|
-
`,document.head.appendChild(e)}var
|
|
1467
|
+
`,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,l)=>Ge("span",{"data-aia-pill-skeleton":"",className:`${fe.pill} ${r?fe.rounded:""} ${fe.skeleton}`,style:{width:a,opacity:Je[wt(l)]}},`skel-${a}`))}):Ge("span",{className:et.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((a,l)=>{let y=!!n&&l===o;return Ge(vt,{label:a.text,state:y?"selected":wt(l),selected:y,rounded:r,loading:i,onClick:()=>t(l)},`${a.type}-${a.text}`)})})}import{attachProductRowWheel as ga,productInitial as fa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ba,useRef as va,useState as wa}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
|
|
1468
1468
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1469
1469
|
theming one package sees the same result in the other.
|
|
1470
1470
|
|
|
@@ -1692,7 +1692,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1692
1692
|
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
|
|
1693
1693
|
flex: 1 1 auto;
|
|
1694
1694
|
}
|
|
1695
|
-
`,document.head.appendChild(e)}var Q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE"};import{jsx as
|
|
1695
|
+
`,document.head.appendChild(e)}var Q={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE"};import{jsx as be,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 l=e.length>0,y=va(null);if(ba(()=>{let w=y.current;if(!(!l||!w))return ga(w)},[l]),!l)return null;let v=`${o}-products-label`;return _e("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":v,children:[be("div",{className:Q.label,id:v,"data-aia-products-label":"",children:"Products"}),be("div",{ref:y,className:Q.row,"data-aia-products-row":"",children:e.map((w,P)=>be(xa,{product:w,id:`${o}-product-${P}`,onSelect:t,onFocusChange:n,focusable:r,imageFallback:a},w.id))})]})}function xa({product:e,id:o,onSelect:t,onFocusChange:n,focusable:r,imageFallback:i}){let a=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),t(e))};return _e("a",{id:o,className:Q.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:a,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),t(e))},onFocus:()=>n?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[be(ya,{src:e.imageUrl?.trim(),title:e.title,fallback:i},e.imageUrl?.trim()??""),_e("span",{className:Q.body,children:[e.vendor?be("span",{className:Q.vendor,children:e.vendor}):null,be("span",{className:Q.title,children:e.title}),e.price?be("span",{className:Q.price,children:e.price}):null]})]})}function ya({src:e,title:o,fallback:t}){let[n,r]=wa(!1),i=!!e&&!n,a=!i&&t==="initial";return _e("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!a?"":void 0,"data-aia-product-initial":a?"":void 0,children:[i?be("img",{className:Q.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0)}):null,a?fa(o):null]})}import{isOptionsGridMobileViewport as za,measureOptionsGrid as Na,needsOptionsGridMeasurement as Ba,OPTIONS_GRID_MOBILE_QUERY as Ha,optionEnterDelayMs as Fa,planOptionsGrid as Ct,sameOptionRows as Ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ga,useLayoutEffect as Wa,useRef as Pt,useState as It}from"react";import{optionsGridTemplateColumns as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ca,useRef as Pa}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 {
|
|
1696
1696
|
display: grid;
|
|
1697
1697
|
grid-template-columns: repeat(
|
|
1698
1698
|
auto-fit,
|
|
@@ -1728,7 +1728,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
1728
1728
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1729
1729
|
display: none;
|
|
1730
1730
|
}
|
|
1731
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1731
|
+
`,document.head.appendChild(e)}import{jsx as Sa}from"react/jsx-runtime";function yt({min:e="16rem",max:o,gap:t,scroll:n=!1,maxHeight:r,scrollResetKey:i,cols:a,template:l,innerRef:y,className:v,children:w,...P}){let u=Pa(null);Ca(()=>{if(i===void 0)return;let T=u.current;T&&(T.scrollTop=0)},[i]);let x={"--aia-grid-min":e};return o&&(x["--aia-grid-max"]=o),t&&(x["--aia-grid-gap"]=t),r&&(x["--aia-grid-max-height"]=r),a&&(x.gridTemplateColumns=ka(a)),l&&(x.gridTemplateColumns=l),Sa("div",{ref:T=>{u.current=T,y?.(T)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":n||void 0,style:x,...P,children:w})}import{formatOptionCount as Ia,OPTION_ENTER_DELAY_VAR as Ea,optionImageSrc as Ta,optionLabel as Aa,sanitizeOptionIconSvg as Ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Oa,useMemo as Da,useRef as La,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 {
|
|
1732
1732
|
position: relative;
|
|
1733
1733
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1734
1734
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2125,7 +2125,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2125
2125
|
opacity: 0;
|
|
2126
2126
|
}
|
|
2127
2127
|
}
|
|
2128
|
-
`,document.head.appendChild(e)}var
|
|
2128
|
+
`,document.head.appendChild(e)}var W={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 Ma}from"react/jsx-runtime";function kt({option:e,isHighlighted:o,onSelect:t,onHighlight:n,onUnhighlight:r,id:i,loading:a,showIcon:l=!0,showImage:y=!0,showCount:v=!0,scrollHint:w,enterDelayMs:P=0}){let[u]=tt(P),[x,T]=tt(!1),I=y?Ta(e.image_url):null,[K,L]=tt(null),A=Da(()=>!I&&l&&e.icon_svg?Ra(e.icon_svg):null,[I,l,e.icon_svg]),S=v?Ia(e.item_count):null,M=La(void 0);Oa(()=>()=>clearTimeout(M.current),[]);let E=()=>{a||!e.is_tappable||x||(T(!0),t(e),clearTimeout(M.current),M.current=setTimeout(()=>T(!1),170))},C=[W.item,o&&!a?W.highlighted:"",e.is_tappable?W.tappable:W.nonTappable,x?W.pressed:"",w?W.scrollHint:""].filter(Boolean).join(" ");return ke("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":A&&e.icon?e.icon:void 0,"data-aia-image":I?"":void 0,"data-aia-item-count":S!==null?e.item_count:void 0,"aria-selected":o,className:C,style:{[Ea]:`${u}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:E,onKeyDown:H=>{!a&&e.is_tappable&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),E())},onMouseEnter:!a&&e.is_tappable?n:void 0,onMouseLeave:r,children:Ma("span",{className:W.content,children:[I&&ke("span",{className:`${W.image} magicx-aia-option-image`,"aria-hidden":"true",children:ke("img",{src:I,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:K===I,onError:()=>L(I)})}),A&&ke("span",{className:`${W.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:A}}),ke("span",{className:W.text,children:Aa(e)}),e.tag&&ke("span",{className:W.tag,children:e.tag}),S!==null&&ke("span",{className:`${W.count} magicx-aia-option-count`,children:S})]})})}import{jsx as St}from"react/jsx-runtime";function _a(){let[e,o]=It(za);return Ga(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Ha),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:l="",optionsPosition:y="below",showIcons:v=!0,showImages:w=!0,showCounts:P=!0}){let u=_a(),x=Pt(null),[T,I]=It(null),K=Pt(null);Wa(()=>{if(a&&Ka(K.current,e))return;K.current=a?null:e;let A=x.current,M=A&&!a&&Ba(e.length,u)?Na(A):null;I(M?Ct(e.length,u,M.rowWidths,M.gridWidth):null)},[e,u,a]);let L=T??Ct(e.length,u,null,null);return St(yt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:l,template:L.template,maxHeight:L.maxHeight,innerRef:A=>{x.current=A},"data-aia-group":l,children:e.map((A,S)=>St(kt,{option:A,isHighlighted:S===o,onSelect:t,onHighlight:()=>n(S),onUnhighlight:r?()=>r(S):void 0,id:`${i}-option-${S}`,loading:a,showIcon:v,showImage:w,showCount:P,scrollHint:!a&&L.scrollHintIndices.includes(S),enterDelayMs:a?0:Fa(S,L.cols,e.length,y)},`${l}\0${A.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2129
2129
|
display: flex;
|
|
2130
2130
|
flex-direction: column;
|
|
2131
2131
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2140,7 +2140,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2140
2140
|
align-items: end;
|
|
2141
2141
|
}
|
|
2142
2142
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2143
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2143
|
+
`,document.head.appendChild(e)}import{jsx as qa}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 qa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...r,children:n})}import{jsx as U,jsxs as at}from"react/jsx-runtime";var $a=[159,119,164],Va=()=>{},At=()=>{};function Xa(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=Za(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 Ja(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:Ua({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:l,pills:y,onPillClick:v,showPills:w=!0,onSkip:P,showSkipButton:u=!0,showOptionIcons:x=!0,showOptionImages:T=!0,showOptionCounts:I=!0,skipDisabled:K=!1,activeSelected:L=!1,isLoading:A=!1,skeletonExiting:S=!1,isInputEmpty:M=!1,products:E,onProductSelect:C,onProductFocusChange:H,productsLayout:X="row",productImageFallback:le="image",formatType:J="options",dateView:de=null,selectedDateIso:G=null,selectedDateRange:g=null,dateRangeStart:ve=null,onPreviousMonth:ce,onNextMonth:pe,optionsPosition:ee="below",mode:he}){let te=Xa(he),j=te!==void 0,_=qe(null),ae=qe(null);Ja(_,ae),Ue(()=>{if(_.current)return Qa(_.current)},[]);let ie=e[0]?.options??[],d=!!(y&&y.length>0&&v),m=!!(E&&E.length>0),h=i&&(ie.length>0||w&&d||A||m),f={suggestions:e,activeIndex:o,pills:y,showPills:w,showSkipButton:u,showOptionIcons:x,showOptionImages:T,showOptionCounts:I,skipDisabled:K,activeSelected:L,isLoading:A,skeletonExiting:S,isInputEmpty:M,products:E,formatType:J,dateView:de,selectedDateIso:G,selectedDateRange:g,dateRangeStart:ve},k=qe(f);h&&(k.current=f);let s=h?f:k.current,z=s.suggestions[0],N=z?.options??[],Z=s.activeIndex>=0&&!!N[s.activeIndex]?.is_tappable,b=!!(s.pills&&s.pills.length>0&&v),we=s.showPills&&b,Ae=s.showPills&&!b&&s.isLoading,oe=we||Ae,c=b&&s.showSkipButton&&!s.isInputEmpty&&!!P,ne=s.pills?.[0]?.text,xe=Ya(s.formatType)&&s.dateView!=null,ue=N.length>0&&!xe,Ce=N.length>0&&xe&&!s.isLoading,me=s.isLoading&&!ue&&!Ce,Pe=s.products??[];return at("div",{ref:_,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":ee,"data-mode":te,"data-aia-loading":s.isLoading?"":void 0,"data-aia-skeleton-exiting":s.skeletonExiting?"":void 0,"data-aia-has-products":Pe.length>0?"":void 0,className:`${j?"magicx-aia ":""}${re.dropdown} ${h?re.visible:""} ${l??""}`,onMouseDown:B=>B.preventDefault(),children:[at(Tt,{space:"8px",children:[(oe||c)&&at(De,{noWrap:!0,className:re.pillBar,"data-aia-pillbar":"",children:[oe&&U("span",{className:re.pillScroll,"data-aia-pill-scroll":"",children:U(We,{pills:s.pills??[],activePillIndex:0,activeSelected:s.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:s.isLoading})}),c&&U("button",{type:"button",tabIndex:-1,className:re.skip,"data-aia-skip":"",disabled:s.isLoading||s.skipDisabled,"aria-label":ne?`Skip ${ne}`:"Skip",onClick:P,children:"skip"})]}),ue&&U(Et,{options:N,activeIndex:s.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:a,loading:s.isLoading,groupKey:z?`${z.type} ${z.text}`:"",optionsPosition:ee,showIcons:s.showOptionIcons,showImages:s.showOptionImages,showCounts:s.showOptionCounts}),Ce&&s.dateView&&U(gt,{options:N,activeIndex:s.activeIndex,listboxId:a,view:s.dateView,selection:{selectedIso:s.selectedDateIso??null,selectedRange:s.selectedDateRange??null,rangeStart:s.dateRangeStart??null},onSelect:t,onHighlight:n,onUnhighlight:r,onPreviousMonth:ce??At,onNextMonth:pe??At}),me&&U("div",{className:re.skeletonBars,"data-aia-skeleton-bars":"",children:$a.map(B=>U("span",{className:re.skeletonBar,style:{width:B}},`bar-${B}`))}),U(xt,{products:Pe,listboxId:a,onSelect:C??Va,onFocusChange:H,focusable:h,layout:X,imageFallback:le}),U(bt,{isOptionHighlighted:Z,isInputEmpty:s.isInputEmpty})]}),U("button",{ref:ae,type:"button",tabIndex:-1,className:re.scrollArrow,"data-aia-scroll-arrow":"","aria-label":ja,"aria-hidden":"true",children:U("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:U("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as ui,ModeController as mi,setCursorOffset 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 {
|
|
2144
2144
|
flex-shrink: 0;
|
|
2145
2145
|
width: 32px;
|
|
2146
2146
|
height: 32px;
|
|
@@ -2193,5 +2193,5 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2193
2193
|
);
|
|
2194
2194
|
cursor: default;
|
|
2195
2195
|
}
|
|
2196
|
-
`,document.head.appendChild(e)}var It={submitButton:"aia-submitButton-otz7H"};import{jsx as Je}from"react/jsx-runtime";function Et({disabled:e,onClick:o}){return Je("button",{type:"button","data-aia-submit":"",className:It.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),o()},"aria-label":"Submit",children:Je("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Je("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Xa,dateSelectionFor as Ja,identifiedParamLabel as ei}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Oe,useRef as G,useState as ti}from"react";import{useRef as Tt}from"react";function At(e){let o=Tt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),n=Tt({key:"",overrides:void 0});if(n.current.key!==t){let r={};for(let i of Object.keys(e??{})){let a=(l,w,b)=>{let v=o.current?.[i];return v?v(l,w,b):[]};r[i]=a}n.current={key:t,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:t}}import{useRef as Rt}from"react";function Ot(e){let o=Rt(e);o.current=e;let t=Rt(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 ai={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 et({onSubmit:e,onResult:o,onError:t,optionOverrides:n,maskCompletedText:r,apiConfig:i,additionalContext:a,columns:l=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:C,showOptionIcons:g,showOptionImages:x,showOptionCounts:T,showSkipButton:S,showProducts:z,productImageFallback:M="image",onFocus:I,onBlur:A,value:R,completedParams:E,onChange:P,onParamsChange:N,products:le,onProductSelect:J,source:de,setCursor:ee}){let c=G(null),[we,ce]=ti(null),pe=G(e);pe.current=e;let he=G(o);he.current=o;let te=G(t);te.current=t;let ue=G(P);ue.current=P;let W=G(N);W.current=N;let ae=G(I);ae.current=I;let _=G(A);_.current=A;let j=G(ee);j.current=ee;let ie=G(J);ie.current=J;let d=Ot(le),p=At(n);Oe(()=>{if(typeof document>"u")return;let u=new Xa(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:a,optionOverrides:p.overrides,maskCompletedText:r,columns:l,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:C,showProducts:z,source:de,value:R,completedParams:E,onSubmit:(...L)=>pe.current?.(...L),onResult:(...L)=>he.current?.(...L),onError:(...L)=>te.current?.(...L),onChange:(...L)=>ue.current?.(...L),onParamsChange:(...L)=>W.current?.(...L),onFocus:()=>ae.current?.(),onBlur:()=>_.current?.(),onProductSelect:L=>ie.current?.(L),setCursor:L=>j.current?.(L),products:d.config});c.current=u,ce(u.getState());let F=u.subscribe(L=>ce(L));return()=>{F(),u.destroy(),c.current===u&&(c.current=null)}},[]),Oe(()=>{R!==void 0&&c.current?.setValue(R)},[R]),Oe(()=>{E!==void 0&&c.current?.setCompletedParams(E)},[E]);let f=JSON.stringify(i??null),k;try{k=JSON.stringify(a??null)}catch{k="[unstringifiable]"}Oe(()=>{c.current?.update({apiConfig:i,additionalContext:a,optionOverrides:p.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:C,showProducts:z})},[f,k,p.key,w,b,v,C,z]);let y=G(!1);Oe(()=>{if(!y.current){y.current=!0;return}c.current?.update({products:d.config})},[d.enabled]);let s=G(null);s.current===null&&(s.current={handleTextChange:u=>c.current?.handleTextChange(u),handleKeyDown:u=>{let F="nativeEvent"in u?u.nativeEvent:u;c.current?.handleKeyDown(F)},setFocused:u=>c.current?.setFocused(u),startEditingParam:u=>c.current?.startEditingParam(u),exitEditMode:()=>c.current?.exitEditMode(),handleCaretAfterInput:u=>c.current?.handleCaretAfterInput(u),handleCaretMove:u=>c.current?.handleCaretMove(u),replaceEditingRange:u=>c.current?.replaceEditingRange(u)??!1,setActivePill:u=>c.current?.setActivePill(u),skipActivePill:()=>c.current?.skipActivePill(),removeLastParam:()=>c.current?.removeLastParam(),clearNewParamId:()=>c.current?.clearNewParamId(),reset:()=>c.current?.reset(),selectOption:u=>c.current?.selectOption(u),selectProduct:u=>c.current?.selectProduct(u),setActiveDropdownIndex:u=>c.current?.setActiveDropdownIndex(u),clearHighlight:u=>c.current?.clearHighlight(u),showPreviousMonth:()=>c.current?.showPreviousMonth(),showNextMonth:()=>c.current?.showNextMonth(),handleFocus:()=>c.current?.setFocused(!0),handleBlur:()=>c.current?.setFocused(!1)});let m=s.current,B=Dt(u=>{let F=u.target.value,qe=F.length>0&&!u.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;c.current?.handleTextChange(qe)},[]),me=Dt(u=>{c.current?.handleKeyDown(u.nativeEvent)},[]),q=c.current,h=we??ai,xe=R!==void 0?R:h.text,ge=E!==void 0?E:h.completedParams,Z=h.actionableSuggestions,ye=Z[0],oe=q?.listboxId??"",Pe=h.activeDropdownIndex>=0&&q?`${oe}-option-${h.activeDropdownIndex}`:void 0,U=h.editingParam,ne=h.editingIdentified,$=U?{type:U.suggestionType,text:U.suggestionPlaceholder,required:!0,options:U.options}:ne?{type:ne.type,text:ei(ne.type),required:!0,options:[]}:null,V=h.dropdownSuggestion??$??ye,Le=$?[$]:Z,Te=Ja(h),ze=!q||h.dropdownLoading;return{completedParams:ge,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:Z,setActivePill:m.setActivePill,skipActivePill:m.skipActivePill,removeLastParam:m.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:m.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:ze,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:oe,error:h.error,products:h.products,customFields:h.customFields,selectProduct:m.selectProduct,handleTextChange:m.handleTextChange,handleKeyDown:m.handleKeyDown,setFocused:m.setFocused,editingParam:U,editingIdentified:ne,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:m.startEditingParam,exitEditMode:m.exitEditMode,handleCaretAfterInput:m.handleCaretAfterInput,handleCaretMove:m.handleCaretMove,replaceEditingRange:m.replaceEditingRange,inputProps:{value:xe,placeholder:h.placeholderText||void 0,onChange:B,onKeyDown:me,onFocus:m.handleFocus,onBlur:m.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":Pe,"aria-autocomplete":"list","aria-controls":oe},reset:m.reset,dropdownProps:{suggestions:V?[{...V,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:m.selectOption,onHighlight:m.setActiveDropdownIndex,onUnhighlight:m.clearHighlight,isOpen:h.isDropdownOpen,id:oe,pills:Le,activeSelected:h.isActivePillSelected,onPillClick:m.setActivePill,onSkip:m.skipActivePill,showSkipButton:(S??!0)&&!U&&!ne,showOptionIcons:g??!0,showOptionImages:x??!0,showOptionCounts:T??!0,skipDisabled:h.inSelectionAnimation,isLoading:ze,skeletonExiting:h.skeletonExiting,isInputEmpty:xe.trim().length===0,products:h.products,productImageFallback:M,onProductSelect:m.selectProduct,onProductFocusChange:m.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Te.selectedIso,selectedDateRange:Te.selectedRange,dateRangeStart:Te.rangeStart,onPreviousMonth:m.showPreviousMonth,onNextMonth:m.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as Lt,getCursorOffset as zt,plainTextLength as ii,renderEditableContent as oi,setCursorOffset as Mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Y,useEffect as tt,useLayoutEffect as at,useRef as Ie}from"react";var _e;function ni(){if(_e!==void 0)return _e;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),_e=e.contentEditable==="plaintext-only",_e}function Nt(e){let{segments:o,showChipIcons:t=!0,showChipImages:n=!0,newParamId:r,editingParam:i,editingIdentified:a,editingAnchor:l,caretOffset:w,placeholderText:b,isFocused:v,isDropdownOpen:C,listboxId:g,activeDescendantId:x,autoFocus:T,handleTextChange:S,handleKeyDown:z,handleCaretAfterInput:M,handleCaretMove:I,startEditingParam:A,replaceEditingRange:R,setFocused:E}=e,P=Ie(null),N=Ie(!1),le=Ie(""),J=Ie(""),de=Ie(null),ee=Ie(0);de.current=w,tt(()=>{if(!T)return;let d=P.current;if(!d)return;document.activeElement===d?E(!0):d.focus();let p=d.ownerDocument??document,f=p.getSelection(),k=f&&f.rangeCount>0&&d.contains(f.anchorNode);if(f&&!k){let y=p.createRange();y.selectNodeContents(d),y.collapse(!0),f.removeAllRanges(),f.addRange(y)}},[T,E]),tt(()=>{let d=P.current;if(!d)return;let p=d.ownerDocument??document,f=()=>{let k=p.getSelection();if(!k||k.rangeCount===0||!k.anchorNode||!d.contains(k.anchorNode))return;let y=k.anchorNode,s=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,B=(k.isCollapsed?s?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,me=i?.id??a?.id??null;if(B&&B!==me){A(B);return}performance.now()-ee.current<50||I(zt(d))};return p.addEventListener("selectionchange",f),()=>p.removeEventListener("selectionchange",f)},[i,a,A,I]),at(()=>{let d=P.current;d&&oi({input:d,segments:o,newParamId:r,editingParamId:i?.id??null,placeholderText:b??"",isFocused:v,showChipIcons:t,showChipImages:n})},[o,r,i,b,v,t,n]),at(()=>{let d=le.current,p=r??"";if(le.current=p,!p||p===d)return;let f=P.current;if(!f)return;f.focus();let k=de.current??ii(f);Mt(f,k)},[r]),at(()=>{let d=J.current,p=i?.id??"";if(J.current=p,!p||p===d||l==null)return;let f=P.current;f&&Mt(f,l)},[i,l]);let c=Y(()=>{if(N.current)return;let d=P.current;if(!d)return;let p=Lt(d),k=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;S(k)},[S]),we=Y(()=>{ee.current=performance.now(),c();let d=P.current;d&&M(zt(d))},[c,M]);tt(()=>{let d=P.current;if(!d)return;let p=f=>{let k=f,y=k.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){f.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let s=y.startsWith("delete")?"":k.data??"";R(s)&&f.preventDefault()}};return d.addEventListener("beforeinput",p),()=>d.removeEventListener("beforeinput",p)},[R]);let ce=Y(()=>{N.current=!0},[]),pe=Y(()=>{N.current=!1,c()},[c]),he=Y(d=>{d.preventDefault();let p=P.current;if(!p)return;let f=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let k=p.ownerDocument??document,y=k.getSelection();if(!y||y.rangeCount===0)return;let s=y.getRangeAt(0);if(!p.contains(s.startContainer))return;s.deleteContents();let m=k.createTextNode(f);s.insertNode(m),s.setStartAfter(m),s.collapse(!0),y.removeAllRanges(),y.addRange(s),c()},[c]),te=Y(d=>z(d),[z]),ue=Y(()=>E(!0),[E]),W=Y(()=>E(!1),[E]),ae=Y(()=>P.current?.focus(),[]),_=Y(()=>P.current?.blur(),[]),j=Y(()=>{let d=P.current;return d?Lt(d):""},[]),ie=ni()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:ie,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":C,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:we,onKeyDown:te,onCompositionStart:ce,onCompositionEnd:pe,onPaste:he,onFocus:ue,onBlur:W},getPlainText:j,focus:ae,blur:_}}import{jsx as Ee,jsxs as ot}from"react/jsx-runtime";function hi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ui=ri(function({onSubmit:o,onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,className:a,apiConfig:l,additionalContext:w,columns:b,pillPlacement:v="dropdown",mode:C="auto",optionsPosition:g="below",animations:x=!0,dropdownTrigger:T,closeDropdownOnBlur:S,showNonTappableOptions:z,showOptionIcons:M=!0,showChipIcons:I=!0,showChipImages:A=!0,showOptionImages:R=!0,showOptionCounts:E=!0,showSkipButton:P,showProducts:N,productsLayout:le,productImageFallback:J,autoFocus:de=!0,onFocus:ee,onBlur:c,value:we,completedParams:ce,onChange:pe,onParamsChange:he,products:te,onProductSelect:ue,submitButton:W,resetOnSubmit:ae=!0},_){let j=De(null),ie=De(null),d=De(()=>{}),p=De(null),f=De(null);Bt(()=>{let O=j.current;if(O)return p.current?p.current.setMode(C):p.current=new ci(O,C),()=>{p.current?.destroy(),p.current=null}},[C]);let k=it(O=>{let fe=f.current?.current;fe&&(fe.focus(),pi(fe,O))},[]),{completedParams:y,skippedParams:s,identifiedParams:m,isReady:B,customFields:me,suggestionPills:q,setActivePill:h,skipActivePill:xe,segments:ge,newParamId:Z,clearNewParamId:ye,placeholderText:oe,isFocused:Pe,isDropdownOpen:U,isActivePillSelected:ne,isLoading:$,activeIndex:V,listboxId:Le,handleTextChange:Te,handleKeyDown:ze,setFocused:u,editingParam:F,editingIdentified:L,editingAnchor:qe,caretOffset:Ht,startEditingParam:Ft,handleCaretAfterInput:Kt,handleCaretMove:Gt,replaceEditingRange:Wt,dropdownProps:_t,reset:Me}=et({onSubmit:O=>d.current(O),onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,apiConfig:l,additionalContext:w,columns:b,dropdownTrigger:T,optionsPosition:g,closeDropdownOnBlur:S,showNonTappableOptions:z,showOptionIcons:M,showOptionImages:R,showOptionCounts:E,showSkipButton:P,showProducts:N,onFocus:ee,onBlur:c,value:we,completedParams:ce,onChange:pe,onParamsChange:he,products:te,onProductSelect:ue,source:"full-sdk",setCursor:k});Bt(()=>{if(!Z)return;let O=window.setTimeout(()=>ye(),650);return()=>window.clearTimeout(O)},[Z,ye]);let qt=V>=0?`${Le}-option-${V}`:void 0,{inputRef:Ue,editorProps:Ut,focus:Ne,blur:nt,getPlainText:rt}=Nt({segments:ge,newParamId:Z,editingParam:F,editingIdentified:L,editingAnchor:qe,caretOffset:Ht,placeholderText:oe,isFocused:Pe,showChipIcons:I,showChipImages:A,isDropdownOpen:U,listboxId:Le,activeDescendantId:qt,autoFocus:de,handleTextChange:Te,handleKeyDown:ze,handleCaretAfterInput:Kt,handleCaretMove:Gt,startEditingParam:Ft,replaceEditingRange:Wt,setFocused:u});f.current=Ue,li(()=>{let O=ie.current,fe=Ue.current;if(!O||!fe)return;let st=()=>{let dt=O.firstElementChild;if(!dt)return;let Zt=dt.getBoundingClientRect(),$t=fe.getBoundingClientRect();Zt.top>=$t.bottom-2?O.setAttribute("data-aia-pill-wrapped",""):O.removeAttribute("data-aia-pill-wrapped")};st();let lt=new ResizeObserver(st);return lt.observe(fe),()=>lt.disconnect()},[ge,q.length,$,Ue]),si(_,()=>({focus:Ne,blur:nt,reset:Me,setMode:O=>p.current?.setMode(O),skipActivePill:xe}),[Ne,nt,Me,xe]);let Be=!!ge.length||y.length>0,Qe=it(()=>{if(!Be)return;let O=rt();o(di(O,y,s,{identifiedParams:m,isReady:B,customFields:me})),ae&&Me()},[ae,Be,y,s,m,B,me,o,Me,rt]);d.current=Qe;let Qt=it(O=>{O.target?.closest("[data-aia-pill]")||Ne()},[Ne]),Yt=v==="inline",jt=v==="dropdown";return ot("div",{ref:j,className:`magicx-aia ${ke.container} ${a??""}`,"data-pill-placement":v,"data-options-position":g,"data-animations":x?"on":"off","data-mode":hi(C),children:[Ee(Xe,{..._t,showPills:jt,productsLayout:le,productImageFallback:J}),ot("div",{className:ke.inputWrapper,"data-aia-input-wrapper":"",onClick:Qt,children:[ot("div",{className:ke.editorArea,"data-aia-editor":"",children:[Ee("div",{...Ut,className:ke.input,"data-aia-input":""}),Yt&&($||q.length>0)&&Ee("span",{ref:ie,className:ke.pillListContainer,"data-aia-pill-list-container":"",children:Ee(Fe,{pills:q,activePillIndex:0,activeSelected:ne,onSelectPill:h,loading:$})})]}),W===null?null:W===void 0?Ee(Et,{disabled:!Be,onClick:Qe}):Ee("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ke.submitSlot,onClick:O=>{Be&&(O.stopPropagation(),Qe())},children:W})]})]})});export{ui as AIAutocomplete,Xe as AIAutocompleteDropdown,ln as DATE_RANGE_META_END,dn as DATE_RANGE_META_START,cn as DEFAULT_OPTION_COUNT_UNIT,yn as PRODUCT_PATH_PREFIX,Rn as WEEKDAY_LABELS,nn as buildSubmitResult,rn as cellDay,sn as cellIso,pn as dateCellMarks,hn as formatDate,un as formatDateRange,mn as formatOptionCount,gn as isoDate,fn as monthLabel,bn as optionCountLabel,vn as optionHasImage,wn as optionImageSrc,xn as optionLabel,kn as parseDate,Cn as parseLooseDate,Pn as parseLooseDateRange,Sn as productFromMatchedItem,In as productsFromCustomFields,En as sanitizeOptionIconSvg,Tn as selectedRangeFor,et as useAIAutocomplete,An as visibleDateRange,On as withSkippedParams};
|
|
2196
|
+
`,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 Me,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 Mt}from"react";function zt(e){let o=Mt(e);o.current=e;let t=Mt(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:M,value:E,completedParams:C,onChange:H,onParamsChange:X,products:le,onProductSelect:J,source:de,setCursor:G}){let g=F(null),[ve,ce]=ii(null),pe=F(e);pe.current=e;let ee=F(o);ee.current=o;let he=F(t);he.current=t;let te=F(H);te.current=H;let j=F(X);j.current=X;let _=F(S);_.current=S;let ae=F(M);ae.current=M;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=zt(le),k=Lt(n);Me(()=>{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:de,value:E,completedParams:C,onSubmit:(...D)=>pe.current?.(...D),onResult:(...D)=>ee.current?.(...D),onError:(...D)=>he.current?.(...D),onChange:(...D)=>te.current?.(...D),onParamsChange:(...D)=>j.current?.(...D),onFocus:()=>_.current?.(),onBlur:()=>ae.current?.(),onProductSelect:D=>d.current?.(D),setCursor:D=>ie.current?.(D),products:f.config});g.current=p,ce(p.getState());let q=p.subscribe(D=>ce(D));return()=>{q(),p.destroy(),g.current===p&&(g.current=null)}},[]),Me(()=>{E!==void 0&&g.current?.setValue(E)},[E]),Me(()=>{C!==void 0&&g.current?.setCompletedParams(C)},[C]);let s=JSON.stringify(i??null),z;try{z=JSON.stringify(a??null)}catch{z="[unstringifiable]"}Me(()=>{g.current?.update({apiConfig:i,additionalContext:a,optionOverrides:k.overrides,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:P,showNonTappableOptions:u,showProducts:L})},[s,z,k.key,v,w,P,u,L]);let N=F(!1);Me(()=>{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,ue=c.actionableSuggestions,Ce=ue[0],me=oe?.listboxId??"",Pe=c.activeDropdownIndex>=0&&oe?`${me}-option-${c.activeDropdownIndex}`:void 0,B=c.editingParam,ge=c.editingIdentified,Se=B?{type:B.suggestionType,text:B.suggestionPlaceholder,required:!0,options:B.options}:ge?{type:ge.type,text:ai(ge.type),required:!0,options:[]}:null,Ne=c.dropdownSuggestion??Se??Ce,je=Se?[Se]:ue,Re=ti(c),Be=!oe||c.dropdownLoading;return{completedParams:xe,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:ue,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:me,error:c.error,products:c.products,customFields:c.customFields,selectProduct:b.selectProduct,handleTextChange:b.handleTextChange,handleKeyDown:b.handleKeyDown,setFocused:b.setFocused,editingParam:B,editingIdentified:ge,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":me},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:me,pills:je,activeSelected:c.isActivePillSelected,onPillClick:b.setActivePill,onSkip:b.skipActivePill,showSkipButton:(K??!0)&&!B&&!ge,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 Y,useEffect as Qe,useLayoutEffect as rt,useRef as Ee}from"react";var Ye;function di(){if(Ye!==void 0)return Ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ye=e.contentEditable==="plaintext-only",Ye}function 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:M,setFocused:E}=e,C=Ee(null),H=Ee(!1),X=Ee(""),le=Ee(""),J=Ee(null),de=Ee(0);J.current=y,Qe(()=>{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]),Qe(()=>{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()-de.current<50||A(Ht(d))};return m.addEventListener("selectionchange",h),()=>m.removeEventListener("selectionchange",h)},[i,a,S,A]),Qe(()=>{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=le.current,m=i?.id??"";if(le.current=m,!m||m===d||l==null)return;let h=C.current;h&&Ft(h,l)},[i,l]);let G=Y(()=>{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=Y(()=>{de.current=performance.now(),G();let d=C.current;d&&L(Ht(d))},[G,L]);Qe(()=>{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??"";M(s)&&h.preventDefault()}};return d.addEventListener("beforeinput",m),()=>d.removeEventListener("beforeinput",m)},[M]);let ve=Y(()=>{H.current=!0},[]),ce=Y(()=>{H.current=!1,G()},[G]),pe=Y(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 z=f.createTextNode(h);s.insertNode(z),s.setStartAfter(z),s.collapse(!0),k.removeAllRanges(),k.addRange(s),G()},[G]),ee=Y(d=>K(d),[K]),he=Y(()=>E(!0),[E]),te=Y(()=>E(!1),[E]),j=Y(()=>C.current?.focus(),[]),_=Y(()=>C.current?.blur(),[]),ae=Y(()=>{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:ce,onPaste:pe,onFocus:he,onBlur:te},getPlainText:ae,focus:j,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:M=!0,showOptionImages:E=!0,showOptionCounts:C=!0,showSkipButton:H,showProducts:X,productsLayout:le,productImageFallback:J,autoFocus:de=!0,onFocus:G,onBlur:g,value:ve,completedParams:ce,onChange:pe,onParamsChange:ee,products:he,onProductSelect:te,submitButton:j,resetOnSubmit:_=!0},ae){let ie=ze(null),d=ze(null),m=ze(()=>{}),h=ze(null),f=ze(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:z,identifiedParams:N,isReady:Z,customFields:b,suggestionPills:we,setActivePill:Ae,skipActivePill:oe,segments:c,newParamId:ne,clearNewParamId:xe,placeholderText:ue,isFocused:Ce,isDropdownOpen:me,isActivePillSelected:Pe,isLoading:B,activeIndex:ge,listboxId:Se,handleTextChange:Ne,handleKeyDown:je,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:ce,onChange:pe,onParamsChange:ee,products:he,onProductSelect:te,source:"full-sdk",setCursor:k});Gt(()=>{if(!ne)return;let R=window.setTimeout(()=>xe(),650);return()=>window.clearTimeout(R)},[ne,xe]);let Qt=ge>=0?`${Se}-option-${ge}`:void 0,{inputRef:$e,editorProps:Yt,focus:Fe,blur:ct,getPlainText:pt}=Kt({segments:c,newParamId:ne,editingParam:Be,editingIdentified:p,editingAnchor:q,caretOffset:D,placeholderText:ue,isFocused:Ce,showChipIcons:S,showChipImages:M,isDropdownOpen:me,listboxId:Se,activeDescendantId:Qt,autoFocus:de,handleTextChange:Ne,handleKeyDown:je,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,z,{identifiedParams:N,isReady:Z,customFields:b});R&&dt(Oe),o(Oe),_&&He()},[dt,_,Ke,s,z,N,Z,b,o,He,pt]);m.current=()=>Ve(!1);let jt=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:le,productImageFallback:J}),lt("div",{className:ye.inputWrapper,"data-aia-input-wrapper":"",onClick:jt,children:[lt("div",{className:ye.editorArea,"data-aia-editor":"",children:[Te("div",{...Yt,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})})]}),j===null?null:j===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:j})]})]})});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,Mn 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,zn as withSkippedParams};
|
|
2197
2197
|
//# sourceMappingURL=index.mjs.map
|