@magicx-eng/ai-autocomplete-react 0.26.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -7
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +53 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -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 an,cellDay as on,cellIso as nn,DATE_RANGE_META_END as rn,DATE_RANGE_META_START as sn,DEFAULT_OPTION_COUNT_UNIT as ln,dateCellMarks as dn,formatDate as cn,formatDateRange as pn,formatOptionCount as hn,isoDate as un,monthLabel as mn,optionCountLabel as gn,optionHasImage as fn,optionImageSrc as bn,optionLabel as vn,PRODUCT_PATH_PREFIX as wn,parseDate as xn,parseLooseDate as yn,parseLooseDateRange as kn,productFromMatchedItem as Cn,productsFromCustomFields as Pn,sanitizeOptionIconSvg as Sn,selectedRangeFor as In,visibleDateRange as En,WEEKDAY_LABELS as Tn,withSkippedParams as An}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as oi,useCallback as it,useEffect as Bt,useImperativeHandle as ni,useLayoutEffect as ri,useRef as De}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 Xo,cellDay as Jo,cellIso as en,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 xe={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 Wa,isCalendarFormat as _a,SCROLL_ARROW_LABEL as qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ve,useRef as Ke,useState as Ua}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 Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
1041
1041
|
opacity: 0.25;
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
`,document.head.appendChild(e)}var
|
|
1044
|
+
`,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 $t,cellIso as Pe,dateCellMarks as Vt,isoDate as Xt,monthLabel as Jt,visibleDateRange as ea,WEEKDAY_LABELS as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as aa}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 Xo,cellDay as Jo,cellIso as en,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 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
|
|
1207
|
+
`,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 $,jsxs as ct}from"react/jsx-runtime";var ia=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function pt({options:e,activeIndex:o,listboxId:a,view:n,selection:r,onSelect:t,onHighlight:s,onPreviousMonth:l,onNextMonth:v}){let w=Xt(new Date),f=ea({pendingStart:r.rangeStart,highlightedIso:Pe(e[o]),selected:r.selectedRange});return ct("div",{className:A.datepicker,"data-aia-datepicker":"",children:[ct("div",{className:A.header,children:[$("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:h=>h.preventDefault(),onClick:l,children:"\u2039"}),$("span",{className:A.month,"data-aia-date-month":"","aria-live":"polite",children:Jt(n)}),$("button",{type:"button",tabIndex:-1,className:A.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:h=>h.preventDefault(),onClick:v,children:"\u203A"})]}),$("div",{className:A.weekdays,"aria-hidden":"true",children:ta.map((h,k)=>$("span",{className:A.weekday,children:h},ia[k]))}),$("div",{className:A.grid,"data-aia-date-grid":"",children:e.map((h,k)=>$(oa,{option:h,id:`${a}-option-${k}`,index:k,isHighlighted:k===o&&h.is_tappable,isToday:Pe(h)===w,isPast:Pe(h)!=null&&Pe(h)<w,marks:Vt(Pe(h),{selectedIso:r.selectedIso,range:f}),onSelect:t,onHighlight:s},Pe(h)??`pad-${k}`))})]})}function oa({option:e,id:o,index:a,isHighlighted:n,isToday:r,isPast:t,marks:s,onSelect:l,onHighlight:v}){let[w,f]=aa(!1),h=$t(e);if(h==null)return $("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 k=()=>{f(!0),l(e),setTimeout(()=>f(!1),170)},S=[A.cell,A.day,t?A.past:"",n?A.highlighted:"",r?A.today:"",s.inRange?A.inRange:"",s.selected?A.selected:"",w?A.pressed:""].filter(Boolean).join(" ");return $("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:S,onClick:k,onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),k())},onMouseEnter:()=>v(a),children:$("span",{className:A.number,children:h})})}import{ATTRIBUTION_URL as na,buildAttributionUrl as ra,getFooterHint as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as la,useState as da}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 Xo,cellDay as Jo,cellIso as en,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 ht}from"react/jsx-runtime";function Ae({gap:e,align:o="center",justify:a="start",noWrap:n=!1,inline:r=!1,className:t,children:s,...l}){let v=e?{"--aia-cluster-gap":e}:void 0,w={className:t?`aia-cluster ${t}`:"aia-cluster","data-align":o,"data-justify":a,"data-nowrap":n||void 0,"data-inline":r||void 0,style:v,...l};return r?ht("span",{...w,children:s}):ht("div",{...w,children:s})}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 Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
1378
1378
|
justify-content: flex-end;
|
|
1379
1379
|
}
|
|
1380
1380
|
}
|
|
1381
|
-
`,document.head.appendChild(e)}var
|
|
1381
|
+
`,document.head.appendChild(e)}var le={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 Re,jsxs as Qe}from"react/jsx-runtime";function ut({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:a,hint:n}=sa(e,o),[r,t]=da(na);return la(()=>{t(ra())},[]),Re("footer",{className:le.footer,"data-aia-footer":"",children:Qe(Ae,{justify:"between",noWrap:!0,className:le.row,children:[Qe(Ae,{gap:"5px",className:le.hintGroup,children:[Re("kbd",{className:le.key,children:a}),Re("span",{className:le.hint,children:n})]}),Qe("a",{className:le.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Re("span",{className:le.brand,children:"AI"}),Re("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,
|
|
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 Xo,cellDay as Jo,cellIso as en,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 ca}from"react/jsx-runtime";var Ye={selected:1,first:.7,next:.4,last:.2};function mt({label:e,state:o,rounded:a,loading:n,onClick:r}){let t=[fe.pill,a?fe.rounded:"",n?fe.skeleton:""].filter(Boolean).join(" ");return ca("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:t,style:{opacity:Ye[o]},onMouseDown:s=>s.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 Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
1464
1464
|
align-items: center;
|
|
1465
1465
|
vertical-align: middle;
|
|
1466
1466
|
}
|
|
1467
|
-
`,document.head.appendChild(e)}var je={list:"aia-list-qvLqO"};import{jsx as
|
|
1467
|
+
`,document.head.appendChild(e)}var je={list:"aia-list-qvLqO"};import{jsx as Be}from"react/jsx-runtime";var pa=[125,69];function gt(e){return e===0?"first":e===1?"next":"last"}function He({pills:e,activePillIndex:o,onSelectPill:a,activeSelected:n,rounded:r,loading:t}){return t&&e.length===0?Be("span",{className:je.list,"data-aia-pill-list-loading":"",children:pa.map((s,l)=>Be("span",{"data-aia-pill-skeleton":"",className:`${fe.pill} ${r?fe.rounded:""} ${fe.skeleton}`,style:{width:s,opacity:Ye[gt(l)]}},`skel-${s}`))}):Be("span",{className:je.list,"data-aia-pill-list-loading":t?"":void 0,children:e.map((s,l)=>{let v=!!n&&l===o;return Be(mt,{label:s.text,state:v?"selected":gt(l),selected:v,rounded:r,loading:t,onClick:()=>a(l)},`${s.type}-${s.text}`)})})}import{attachProductRowWheel as ha,productInitial as ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ma,useRef as ga,useState as fa}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
|
|
|
@@ -1579,6 +1579,16 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
1579
1579
|
the same media fill, so a card without art reads as "no photo" instead of
|
|
1580
1580
|
broken. The pictogram is inlined as a data URI so the placeholder needs no
|
|
1581
1581
|
network and no asset pipeline; --aia-product-placeholder-image swaps it. */
|
|
1582
|
+
.aia-media-RrbGe:where([data-aia-product-initial]) {
|
|
1583
|
+
display: flex;
|
|
1584
|
+
align-items: center;
|
|
1585
|
+
justify-content: center;
|
|
1586
|
+
color: var(--aia-product-title-color, var(--aia-option-color-selected, currentColor));
|
|
1587
|
+
font-size: 24px;
|
|
1588
|
+
font-weight: 600;
|
|
1589
|
+
line-height: 1;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1582
1592
|
.aia-media-RrbGe[data-aia-product-placeholder]::after {
|
|
1583
1593
|
content: "";
|
|
1584
1594
|
position: absolute;
|
|
@@ -1682,7 +1692,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
1682
1692
|
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
|
|
1683
1693
|
flex: 1 1 auto;
|
|
1684
1694
|
}
|
|
1685
|
-
`,document.head.appendChild(e)}var
|
|
1695
|
+
`,document.head.appendChild(e)}var _={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 Fe}from"react/jsx-runtime";function ft({products:e,listboxId:o,onSelect:a,onFocusChange:n,focusable:r=!0,layout:t="row",imageFallback:s="image"}){let l=e.length>0,v=ga(null);if(ma(()=>{let f=v.current;if(!(!l||!f))return ha(f)},[l]),!l)return null;let w=`${o}-products-label`;return Fe("section",{className:_.section,"data-aia-products":"","data-aia-products-layout":t,role:"group","aria-labelledby":w,children:[be("div",{className:_.label,id:w,"data-aia-products-label":"",children:"Products"}),be("div",{ref:v,className:_.row,"data-aia-products-row":"",children:e.map((f,h)=>be(ba,{product:f,id:`${o}-product-${h}`,onSelect:a,onFocusChange:n,focusable:r,imageFallback:s},f.id))})]})}function ba({product:e,id:o,onSelect:a,onFocusChange:n,focusable:r,imageFallback:t}){let s=l=>{l.metaKey||l.ctrlKey||l.shiftKey||l.altKey||l.button!==0||(l.preventDefault(),a(e))};return Fe("a",{id:o,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:s,onKeyDown:l=>{l.key!=="Enter"&&l.key!==" "||(l.preventDefault(),a(e))},onFocus:()=>n?.(!0),onBlur:l=>{l.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[be(va,{src:e.imageUrl?.trim(),title:e.title,fallback:t},e.imageUrl?.trim()??""),Fe("span",{className:_.body,children:[e.vendor?be("span",{className:_.vendor,children:e.vendor}):null,be("span",{className:_.title,children:e.title}),e.price?be("span",{className:_.price,children:e.price}):null]})]})}function va({src:e,title:o,fallback:a}){let[n,r]=fa(!1),t=!!e&&!n,s=!t&&a==="initial";return Fe("span",{className:_.media,"aria-hidden":"true","data-aia-product-placeholder":!t&&!s?"":void 0,"data-aia-product-initial":s?"":void 0,children:[t?be("img",{className:_.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0)}):null,s?ua(o):null]})}import{isOptionsGridMobileViewport as Da,measureOptionsGrid as La,needsOptionsGridMeasurement as Ma,OPTIONS_GRID_MOBILE_QUERY as za,optionEnterDelayMs as Na,planOptionsGrid as wt,sameOptionRows as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ha,useLayoutEffect as Fa,useRef as xt,useState as kt}from"react";import{optionsGridTemplateColumns as wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as xa,useRef as ya}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 {
|
|
1686
1696
|
display: grid;
|
|
1687
1697
|
grid-template-columns: repeat(
|
|
1688
1698
|
auto-fit,
|
|
@@ -1715,7 +1725,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
1715
1725
|
background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
|
|
1716
1726
|
border-radius: 3px;
|
|
1717
1727
|
}
|
|
1718
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1728
|
+
`,document.head.appendChild(e)}import{jsx as ka}from"react/jsx-runtime";function bt({min:e="16rem",max:o,gap:a,scroll:n=!1,maxHeight:r,scrollResetKey:t,cols:s,template:l,innerRef:v,className:w,children:f,...h}){let k=ya(null);xa(()=>{if(t===void 0)return;let y=k.current;y&&(y.scrollTop=0)},[t]);let S={"--aia-grid-min":e};return o&&(S["--aia-grid-max"]=o),a&&(S["--aia-grid-gap"]=a),r&&(S["--aia-grid-max-height"]=r),s&&(S.gridTemplateColumns=wa(s)),l&&(S.gridTemplateColumns=l),ka("div",{ref:y=>{k.current=y,v?.(y)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":n||void 0,style:S,...h,children:f})}import{formatOptionCount as Ca,OPTION_ENTER_DELAY_VAR as Pa,optionImageSrc as Sa,optionLabel as Ia,sanitizeOptionIconSvg as Ea}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ta,useMemo as Aa,useRef as Ra,useState as Ze}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 {
|
|
1719
1729
|
position: relative;
|
|
1720
1730
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1721
1731
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2033,6 +2043,36 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
2033
2043
|
--aia-option-row-height: calc(var(--aia-option-image-size, 40px) + 16px);
|
|
2034
2044
|
}
|
|
2035
2045
|
|
|
2046
|
+
/* A row without a picture, in a grid where other rows have one, lines up
|
|
2047
|
+
with them: it becomes the same centred flex row, its icon sits centred in a
|
|
2048
|
+
tile-sized box, and a row with no icon either is indented by the tile and
|
|
2049
|
+
its gap, so every option's text starts at the same x. Grids with no
|
|
2050
|
+
pictures keep the inline icon and hanging indent above. The text is left
|
|
2051
|
+
to size itself: letting it grow here would out-rank the loading-bar rule
|
|
2052
|
+
that makes a skeleton bar hug its text. */
|
|
2053
|
+
[data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) {
|
|
2054
|
+
display: flex;
|
|
2055
|
+
flex: 1 1 auto;
|
|
2056
|
+
align-items: center;
|
|
2057
|
+
gap: var(--aia-option-image-gap, 12px);
|
|
2058
|
+
min-width: 0;
|
|
2059
|
+
min-height: var(--aia-option-image-size, 40px);
|
|
2060
|
+
padding-left: 0;
|
|
2061
|
+
text-indent: 0;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
[data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) .aia-icon-Qw938 {
|
|
2065
|
+
flex: 0 0 auto;
|
|
2066
|
+
justify-content: center;
|
|
2067
|
+
width: var(--aia-option-image-size, 40px);
|
|
2068
|
+
height: var(--aia-option-image-size, 40px);
|
|
2069
|
+
margin-right: 0;
|
|
2070
|
+
}
|
|
2071
|
+
|
|
2072
|
+
[data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)):not(:has(.aia-icon-Qw938)) {
|
|
2073
|
+
padding-left: calc(var(--aia-option-image-size, 40px) + var(--aia-option-image-gap, 12px));
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2036
2076
|
@keyframes aia-skeletonPulse-plvdD {
|
|
2037
2077
|
0%,
|
|
2038
2078
|
100% {
|
|
@@ -2075,7 +2115,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
2075
2115
|
opacity: 0;
|
|
2076
2116
|
}
|
|
2077
2117
|
}
|
|
2078
|
-
`,document.head.appendChild(e)}var
|
|
2118
|
+
`,document.head.appendChild(e)}var N={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 ye,jsxs as Oa}from"react/jsx-runtime";function vt({option:e,isHighlighted:o,onSelect:a,onHighlight:n,id:r,loading:t,showIcon:s=!0,showImage:l=!0,showCount:v=!0,scrollHint:w,enterDelayMs:f=0}){let[h]=Ze(f),[k,S]=Ze(!1),y=l?Sa(e.image_url):null,[z,L]=Ze(null),I=Aa(()=>!y&&s&&e.icon_svg?Ea(e.icon_svg):null,[y,s,e.icon_svg]),T=v?Ca(e.item_count):null,M=Ra(void 0);Ta(()=>()=>clearTimeout(M.current),[]);let O=()=>{t||!e.is_tappable||k||(S(!0),a(e),clearTimeout(M.current),M.current=setTimeout(()=>S(!1),170))},R=[N.item,o&&!t?N.highlighted:"",e.is_tappable?N.tappable:N.nonTappable,k?N.pressed:"",w?N.scrollHint:""].filter(Boolean).join(" ");return ye("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":t?"":void 0,"data-aia-icon":I&&e.icon?e.icon:void 0,"data-aia-image":y?"":void 0,"data-aia-item-count":T!==null?e.item_count:void 0,"aria-selected":o,className:R,style:{[Pa]:`${h}ms`},tabIndex:t||!e.is_tappable?-1:0,onClick:O,onKeyDown:C=>{!t&&e.is_tappable&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),O())},onMouseEnter:!t&&e.is_tappable?n:void 0,children:Oa("span",{className:N.content,children:[y&&ye("span",{className:`${N.image} magicx-aia-option-image`,"aria-hidden":"true",children:ye("img",{src:y,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:z===y,onError:()=>L(y)})}),I&&ye("span",{className:`${N.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:I}}),ye("span",{className:N.text,children:Ia(e)}),e.tag&&ye("span",{className:N.tag,children:e.tag}),T!==null&&ye("span",{className:`${N.count} magicx-aia-option-count`,children:T})]})})}import{jsx as yt}from"react/jsx-runtime";function Ka(){let[e,o]=kt(Da);return Ha(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(za),n=()=>o(a.matches);return n(),a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),e}function Ct({options:e,activeIndex:o,onSelect:a,onHighlight:n,listboxId:r,loading:t,groupKey:s="",optionsPosition:l="below",showIcons:v=!0,showImages:w=!0,showCounts:f=!0}){let h=Ka(),k=xt(null),[S,y]=kt(null),z=xt(null);Fa(()=>{if(t&&Ba(z.current,e))return;z.current=t?null:e;let I=k.current,M=I&&!t&&Ma(e.length,h)?La(I):null;y(M?wt(e.length,h,M.rowWidths,M.gridWidth):null)},[e,h,t]);let L=S??wt(e.length,h,null,null);return yt(bt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:L.template,maxHeight:L.maxHeight,innerRef:I=>{k.current=I},"data-aia-group":s,children:e.map((I,T)=>yt(vt,{option:I,isHighlighted:T===o,onSelect:a,onHighlight:()=>n(T),id:`${r}-option-${T}`,loading:t,showIcon:v,showImage:w,showCount:f,scrollHint:!t&&L.scrollHintIndices.includes(T),enterDelayMs:t?0:Na(T,L.cols,e.length,l)},`${s}\0${I.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2079
2119
|
display: flex;
|
|
2080
2120
|
flex-direction: column;
|
|
2081
2121
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2090,7 +2130,7 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
2090
2130
|
align-items: end;
|
|
2091
2131
|
}
|
|
2092
2132
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2093
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2133
|
+
`,document.head.appendChild(e)}import{jsx as Ga}from"react/jsx-runtime";function Pt({space:e,align:o="stretch",className:a,children:n,...r}){let t=e?{"--aia-stack-space":e}:void 0;return Ga("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":o,style:t,...r,children:n})}import{jsx as F,jsxs as $e}from"react/jsx-runtime";var Qa=[159,119,164],Ya=()=>{},St=()=>{};function ja(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,n]=Ua(o);if(Ve(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),t=()=>n(r.matches);return r.addEventListener("change",t),()=>r.removeEventListener("change",t)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Za(e,o){let a=Ke(null);Ve(()=>{let n=e.current,r=o.current;if(!n||!r)return;let t=n.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==t&&(a.current.controller.destroy(),a.current=null),t&&!a.current){a.current={grid:t,controller:Wa({dropdown:n,grid:t,button:r})};return}a.current?.controller.update()}),Ve(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Xe({suggestions:e,activeIndex:o,onSelect:a,onHighlight:n,isOpen:r,id:t,className:s,pills:l,onPillClick:v,showPills:w=!0,onSkip:f,showSkipButton:h=!0,showOptionIcons:k=!0,showOptionImages:S=!0,showOptionCounts:y=!0,skipDisabled:z=!1,activeSelected:L=!1,isLoading:I=!1,skeletonExiting:T=!1,isInputEmpty:M=!1,products:O,onProductSelect:R,onProductFocusChange:C,productsLayout:U="row",productImageFallback:de="image",formatType:V="options",dateView:ce=null,selectedDateIso:X=null,selectedDateRange:p=null,dateRangeStart:ve=null,onPreviousMonth:pe,onNextMonth:he,optionsPosition:J="below",mode:ue}){let ee=ja(ue),Q=ee!==void 0,te=Ke(null),Y=Ke(null);Za(te,Y);let ae=e[0]?.options??[],ie=!!(l&&l.length>0&&v),d=!!(O&&O.length>0),u=r&&(ae.length>0||w&&ie||I||d),b={suggestions:e,activeIndex:o,pills:l,showPills:w,showSkipButton:h,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,skipDisabled:z,activeSelected:L,isLoading:I,skeletonExiting:T,isInputEmpty:M,products:O,formatType:V,dateView:ce,selectedDateIso:X,selectedDateRange:p,dateRangeStart:ve},x=Ke(b);u&&(x.current=b);let i=u?b:x.current,P=i.suggestions[0],m=P?.options??[],j=i.activeIndex>=0&&!!m[i.activeIndex]?.is_tappable,G=!!(i.pills&&i.pills.length>0&&v),we=i.showPills&&G,c=i.showPills&&!G&&i.isLoading,oe=we||c,me=G&&i.showSkipButton&&!i.isInputEmpty&&!!f,ne=i.pills?.[0]?.text,ke=_a(i.formatType)&&i.dateView!=null,re=m.length>0&&!ke,Ce=m.length>0&&ke&&!i.isLoading,Z=i.isLoading&&!re&&!Ce,B=i.products??[];return $e("div",{ref:te,id:t,role:"listbox","data-aia-dropdown":"","data-options-position":J,"data-mode":ee,"data-aia-loading":i.isLoading?"":void 0,"data-aia-skeleton-exiting":i.skeletonExiting?"":void 0,"data-aia-has-products":B.length>0?"":void 0,className:`${Q?"magicx-aia ":""}${se.dropdown} ${u?se.visible:""} ${s??""}`,onMouseDown:W=>W.preventDefault(),children:[$e(Pt,{space:"8px",children:[(oe||me)&&$e(Ae,{noWrap:!0,className:se.pillBar,"data-aia-pillbar":"",children:[oe&&F("span",{className:se.pillScroll,"data-aia-pill-scroll":"",children:F(He,{pills:i.pills??[],activePillIndex:0,activeSelected:i.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:i.isLoading})}),me&&F("button",{type:"button",tabIndex:-1,className:se.skip,"data-aia-skip":"",disabled:i.isLoading||i.skipDisabled,"aria-label":ne?`Skip ${ne}`:"Skip",onClick:f,children:"skip"})]}),re&&F(Ct,{options:m,activeIndex:i.activeIndex,onSelect:a,onHighlight:n,listboxId:t,loading:i.isLoading,groupKey:P?`${P.type} ${P.text}`:"",optionsPosition:J,showIcons:i.showOptionIcons,showImages:i.showOptionImages,showCounts:i.showOptionCounts}),Ce&&i.dateView&&F(pt,{options:m,activeIndex:i.activeIndex,listboxId:t,view:i.dateView,selection:{selectedIso:i.selectedDateIso??null,selectedRange:i.selectedDateRange??null,rangeStart:i.dateRangeStart??null},onSelect:a,onHighlight:n,onPreviousMonth:pe??St,onNextMonth:he??St}),Z&&F("div",{className:se.skeletonBars,"data-aia-skeleton-bars":"",children:Qa.map(W=>F("span",{className:se.skeletonBar,style:{width:W}},`bar-${W}`))}),F(ft,{products:B,listboxId:t,onSelect:R??Ya,onFocusChange:C,focusable:u,layout:U,imageFallback:de}),F(ut,{isOptionHighlighted:j,isInputEmpty:i.isInputEmpty})]}),F("button",{ref:Y,type:"button",tabIndex:-1,className:se.scrollArrow,"data-aia-scroll-arrow":"","aria-label":qa,"aria-hidden":"true",children:F("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:F("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as si,ModeController as li,setCursorOffset as di}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 {
|
|
2094
2134
|
flex-shrink: 0;
|
|
2095
2135
|
width: 32px;
|
|
2096
2136
|
height: 32px;
|
|
@@ -2143,5 +2183,5 @@ import{buildSubmitResult as Xo,cellDay as Jo,cellIso as en,DATE_RANGE_META_END a
|
|
|
2143
2183
|
);
|
|
2144
2184
|
cursor: default;
|
|
2145
2185
|
}
|
|
2146
|
-
`,document.head.appendChild(e)}var St={submitButton:"aia-submitButton-otz7H"};import{jsx as Xe}from"react/jsx-runtime";function It({disabled:e,onClick:n}){return Xe("button",{type:"button","data-aia-submit":"",className:St.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":"Submit",children:Xe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Xe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ja,dateSelectionFor as Qa,identifiedParamLabel as Ya}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Re,useRef as W,useState as $a}from"react";import{useRef as Et}from"react";function Tt(e){let n=Et(e);n.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=Et({key:"",overrides:void 0});if(r.current.key!==a){let s={};for(let t of Object.keys(e??{})){let o=(u,w,b)=>{let x=n.current?.[t];return x?x(u,w,b):[]};s[t]=o}r.current={key:a,overrides:e?s:void 0}}return{overrides:r.current.overrides,key:a}}import{useRef as At}from"react";function Rt(e){let n=At(e);n.current=e;let a=At(null);a.current===null&&(a.current={fetch:(s,t)=>{let o=n.current;return o?o.fetch(s,t):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var Va={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 Je({onSubmit:e,onResult:n,onError:a,optionOverrides:r,maskCompletedText:s,apiConfig:t,additionalContext:o,columns:u=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,showSkipButton:z,showProducts:O,onFocus:P,onBlur:T,value:I,completedParams:R,onChange:L,onParamsChange:C,products:Z,onProductSelect:X,source:pe,setCursor:J}){let h=W(null),[H,he]=$a(null),ue=W(e);ue.current=e;let ee=W(n);ee.current=n;let me=W(a);me.current=a;let te=W(L);te.current=L;let j=W(C);j.current=C;let ae=W(P);ae.current=P;let Q=W(T);Q.current=T;let ie=W(J);ie.current=J;let oe=W(X);oe.current=X;let M=Rt(Z),l=Tt(r);Re(()=>{if(typeof document>"u")return;let g=new ja(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:o,optionOverrides:l.overrides,maskCompletedText:s,columns:u,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showProducts:O,source:pe,value:I,completedParams:R,onSubmit:(...D)=>ue.current?.(...D),onResult:(...D)=>ee.current?.(...D),onError:(...D)=>me.current?.(...D),onChange:(...D)=>te.current?.(...D),onParamsChange:(...D)=>j.current?.(...D),onFocus:()=>ae.current?.(),onBlur:()=>Q.current?.(),onProductSelect:D=>oe.current?.(D),setCursor:D=>ie.current?.(D),products:M.config});h.current=g,he(g.getState());let K=g.subscribe(D=>he(D));return()=>{K(),g.destroy(),h.current===g&&(h.current=null)}},[]),Re(()=>{I!==void 0&&h.current?.setValue(I)},[I]),Re(()=>{R!==void 0&&h.current?.setCompletedParams(R)},[R]);let m=JSON.stringify(t??null),f;try{f=JSON.stringify(o??null)}catch{f="[unstringifiable]"}Re(()=>{h.current?.update({apiConfig:t,additionalContext:o,optionOverrides:l.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:p,showProducts:O})},[m,f,l.key,w,b,x,p,O]);let i=W(!1);Re(()=>{if(!i.current){i.current=!0;return}h.current?.update({products:M.config})},[M.enabled]);let v=W(null);v.current===null&&(v.current={handleTextChange:g=>h.current?.handleTextChange(g),handleKeyDown:g=>{let K="nativeEvent"in g?g.nativeEvent:g;h.current?.handleKeyDown(K)},setFocused:g=>h.current?.setFocused(g),startEditingParam:g=>h.current?.startEditingParam(g),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:g=>h.current?.handleCaretAfterInput(g),handleCaretMove:g=>h.current?.handleCaretMove(g),replaceEditingRange:g=>h.current?.replaceEditingRange(g)??!1,setActivePill:g=>h.current?.setActivePill(g),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:g=>h.current?.selectOption(g),selectProduct:g=>h.current?.selectProduct(g),setActiveDropdownIndex:g=>h.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let d=v.current,Y=Dt(g=>{let K=g.target.value,Ge=K.length>0&&!g.nativeEvent?.isComposing&&K[0]!==K[0].toUpperCase()?K[0].toUpperCase()+K.slice(1):K;h.current?.handleTextChange(Ge)},[]),N=Dt(g=>{h.current?.handleKeyDown(g.nativeEvent)},[]),ne=h.current,c=H??Va,re=I!==void 0?I:c.text,fe=R!==void 0?R:c.completedParams,se=c.actionableSuggestions,ye=se[0],le=ne?.listboxId??"",ke=c.activeDropdownIndex>=0&&ne?`${le}-option-${c.activeDropdownIndex}`:void 0,$=c.editingParam,F=c.editingIdentified,_=$?{type:$.suggestionType,text:$.suggestionPlaceholder,required:!0,options:$.options}:F?{type:F.type,text:Ya(F.type),required:!0,options:[]}:null,Ie=c.dropdownSuggestion??_??ye,Ke=_?[_]:se,Ee=Qa(c),Oe=!ne||c.dropdownLoading;return{completedParams:fe,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:se,setActivePill:d.setActivePill,skipActivePill:d.skipActivePill,removeLastParam:d.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:d.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Oe,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:le,error:c.error,products:c.products,customFields:c.customFields,selectProduct:d.selectProduct,handleTextChange:d.handleTextChange,handleKeyDown:d.handleKeyDown,setFocused:d.setFocused,editingParam:$,editingIdentified:F,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:d.startEditingParam,exitEditMode:d.exitEditMode,handleCaretAfterInput:d.handleCaretAfterInput,handleCaretMove:d.handleCaretMove,replaceEditingRange:d.replaceEditingRange,inputProps:{value:re,placeholder:c.placeholderText||void 0,onChange:Y,onKeyDown:N,onFocus:d.handleFocus,onBlur:d.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":ke,"aria-autocomplete":"list","aria-controls":le},reset:d.reset,dropdownProps:{suggestions:Ie?[{...Ie,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:d.selectOption,onHighlight:d.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:le,pills:Ke,activeSelected:c.isActivePillSelected,onPillClick:d.setActivePill,onSkip:d.skipActivePill,showSkipButton:(z??!0)&&!$&&!F,showOptionIcons:k??!0,showOptionImages:S??!0,showOptionCounts:y??!0,skipDisabled:c.inSelectionAnimation,isLoading:Oe,skeletonExiting:c.skeletonExiting,isInputEmpty:re.trim().length===0,products:c.products,onProductSelect:d.selectProduct,onProductFocusChange:d.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Ee.selectedIso,selectedDateRange:Ee.selectedRange,dateRangeStart:Ee.rangeStart,onPreviousMonth:d.showPreviousMonth,onNextMonth:d.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as Ot,getCursorOffset as Lt,plainTextLength as Za,renderEditableContent as Xa,setCursorOffset as Mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as et,useLayoutEffect as tt,useRef as Pe}from"react";var Fe;function Ja(){if(Fe!==void 0)return Fe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Fe=e.contentEditable==="plaintext-only",Fe}function zt(e){let{segments:n,showChipIcons:a=!0,showChipImages:r=!0,newParamId:s,editingParam:t,editingIdentified:o,editingAnchor:u,caretOffset:w,placeholderText:b,isFocused:x,isDropdownOpen:p,listboxId:k,activeDescendantId:S,autoFocus:y,handleTextChange:z,handleKeyDown:O,handleCaretAfterInput:P,handleCaretMove:T,startEditingParam:I,replaceEditingRange:R,setFocused:L}=e,C=Pe(null),Z=Pe(!1),X=Pe(""),pe=Pe(""),J=Pe(null),h=Pe(0);J.current=w,et(()=>{if(!y)return;let l=C.current;if(!l)return;document.activeElement===l?L(!0):l.focus();let m=l.ownerDocument??document,f=m.getSelection(),i=f&&f.rangeCount>0&&l.contains(f.anchorNode);if(f&&!i){let v=m.createRange();v.selectNodeContents(l),v.collapse(!0),f.removeAllRanges(),f.addRange(v)}},[y,L]),et(()=>{let l=C.current;if(!l)return;let m=l.ownerDocument??document,f=()=>{let i=m.getSelection();if(!i||i.rangeCount===0||!i.anchorNode||!l.contains(i.anchorNode))return;let v=i.anchorNode,d=v.nodeType===Node.ELEMENT_NODE?v:v.parentElement,N=(i.isCollapsed?d?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ne=t?.id??o?.id??null;if(N&&N!==ne){I(N);return}performance.now()-h.current<50||T(Lt(l))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[t,o,I,T]),tt(()=>{let l=C.current;l&&Xa({input:l,segments:n,newParamId:s,editingParamId:t?.id??null,placeholderText:b??"",isFocused:x,showChipIcons:a,showChipImages:r})},[n,s,t,b,x,a,r]),tt(()=>{let l=X.current,m=s??"";if(X.current=m,!m||m===l)return;let f=C.current;if(!f)return;f.focus();let i=J.current??Za(f);Mt(f,i)},[s]),tt(()=>{let l=pe.current,m=t?.id??"";if(pe.current=m,!m||m===l||u==null)return;let f=C.current;f&&Mt(f,u)},[t,u]);let H=U(()=>{if(Z.current)return;let l=C.current;if(!l)return;let m=Ot(l),i=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;z(i)},[z]),he=U(()=>{h.current=performance.now(),H();let l=C.current;l&&P(Lt(l))},[H,P]);et(()=>{let l=C.current;if(!l)return;let m=f=>{let i=f,v=i.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){f.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let d=v.startsWith("delete")?"":i.data??"";R(d)&&f.preventDefault()}};return l.addEventListener("beforeinput",m),()=>l.removeEventListener("beforeinput",m)},[R]);let ue=U(()=>{Z.current=!0},[]),ee=U(()=>{Z.current=!1,H()},[H]),me=U(l=>{l.preventDefault();let m=C.current;if(!m)return;let f=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let i=m.ownerDocument??document,v=i.getSelection();if(!v||v.rangeCount===0)return;let d=v.getRangeAt(0);if(!m.contains(d.startContainer))return;d.deleteContents();let Y=i.createTextNode(f);d.insertNode(Y),d.setStartAfter(Y),d.collapse(!0),v.removeAllRanges(),v.addRange(d),H()},[H]),te=U(l=>O(l),[O]),j=U(()=>L(!0),[L]),ae=U(()=>L(!1),[L]),Q=U(()=>C.current?.focus(),[]),ie=U(()=>C.current?.blur(),[]),oe=U(()=>{let l=C.current;return l?Ot(l):""},[]),M=Ja()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:M,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":k,"aria-expanded":p,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:he,onKeyDown:te,onCompositionStart:ue,onCompositionEnd:ee,onPaste:me,onFocus:j,onBlur:ae},getPlainText:oe,focus:Q,blur:ie}}import{jsx as Se,jsxs as it}from"react/jsx-runtime";function ri(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var si=ei(function({onSubmit:n,onResult:a,onError:r,optionOverrides:s,maskCompletedText:t,className:o,apiConfig:u,additionalContext:w,columns:b,pillPlacement:x="dropdown",mode:p="auto",optionsPosition:k="below",animations:S=!0,dropdownTrigger:y,closeDropdownOnBlur:z,showNonTappableOptions:O,showOptionIcons:P=!0,showChipIcons:T=!0,showChipImages:I=!0,showOptionImages:R=!0,showOptionCounts:L=!0,showSkipButton:C,showProducts:Z,productsLayout:X,autoFocus:pe=!0,onFocus:J,onBlur:h,value:H,completedParams:he,onChange:ue,onParamsChange:ee,products:me,onProductSelect:te,submitButton:j},ae){let Q=De(null),ie=De(null),oe=De(()=>{}),M=De(null),l=De(null);Nt(()=>{let E=Q.current;if(E)return M.current?M.current.setMode(p):M.current=new oi(E,p),()=>{M.current?.destroy(),M.current=null}},[p]);let m=at(E=>{let ge=l.current?.current;ge&&(ge.focus(),ni(ge,E))},[]),{completedParams:f,skippedParams:i,identifiedParams:v,isReady:d,customFields:Y,suggestionPills:N,setActivePill:ne,skipActivePill:c,segments:re,newParamId:fe,clearNewParamId:se,placeholderText:ye,isFocused:le,isDropdownOpen:ke,isActivePillSelected:$,isLoading:F,activeIndex:_,listboxId:Ie,handleTextChange:Ke,handleKeyDown:Ee,setFocused:Oe,editingParam:g,editingIdentified:K,editingAnchor:D,caretOffset:Ge,startEditingParam:Bt,handleCaretAfterInput:Ht,handleCaretMove:Ft,replaceEditingRange:Kt,dropdownProps:Gt,reset:Le}=Je({onSubmit:E=>oe.current(E),onResult:a,onError:r,optionOverrides:s,maskCompletedText:t,apiConfig:u,additionalContext:w,columns:b,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:z,showNonTappableOptions:O,showOptionIcons:P,showOptionImages:R,showOptionCounts:L,showSkipButton:C,showProducts:Z,onFocus:J,onBlur:h,value:H,completedParams:he,onChange:ue,onParamsChange:ee,products:me,onProductSelect:te,source:"full-sdk",setCursor:m});Nt(()=>{if(!fe)return;let E=window.setTimeout(()=>se(),650);return()=>window.clearTimeout(E)},[fe,se]);let Wt=_>=0?`${Ie}-option-${_}`:void 0,{inputRef:We,editorProps:_t,focus:Me,blur:ot,getPlainText:nt}=zt({segments:re,newParamId:fe,editingParam:g,editingIdentified:K,editingAnchor:D,caretOffset:Ge,placeholderText:ye,isFocused:le,showChipIcons:T,showChipImages:I,isDropdownOpen:ke,listboxId:Ie,activeDescendantId:Wt,autoFocus:pe,handleTextChange:Ke,handleKeyDown:Ee,handleCaretAfterInput:Ht,handleCaretMove:Ft,startEditingParam:Bt,replaceEditingRange:Kt,setFocused:Oe});l.current=We,ai(()=>{let E=ie.current,ge=We.current;if(!E||!ge)return;let rt=()=>{let lt=E.firstElementChild;if(!lt)return;let Qt=lt.getBoundingClientRect(),Yt=ge.getBoundingClientRect();Qt.top>=Yt.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};rt();let st=new ResizeObserver(rt);return st.observe(ge),()=>st.disconnect()},[re,N.length,F,We]),ti(ae,()=>({focus:Me,blur:ot,reset:Le,setMode:E=>M.current?.setMode(E),skipActivePill:c}),[Me,ot,Le,c]);let ze=!!re.length||f.length>0,_e=at(()=>{if(!ze)return;let E=nt();n(ii(E,f,i,{identifiedParams:v,isReady:d,customFields:Y})),Le()},[ze,f,i,v,d,Y,n,Le,nt]);oe.current=_e;let qt=at(E=>{E.target?.closest("[data-aia-pill]")||Me()},[Me]),Ut=x==="inline",jt=x==="dropdown";return it("div",{ref:Q,className:`magicx-aia ${we.container} ${o??""}`,"data-pill-placement":x,"data-options-position":k,"data-animations":S?"on":"off","data-mode":ri(p),children:[Se(Ze,{...Gt,showPills:jt,productsLayout:X}),it("div",{className:we.inputWrapper,"data-aia-input-wrapper":"",onClick:qt,children:[it("div",{className:we.editorArea,"data-aia-editor":"",children:[Se("div",{..._t,className:we.input,"data-aia-input":""}),Ut&&(F||N.length>0)&&Se("span",{ref:ie,className:we.pillListContainer,"data-aia-pill-list-container":"",children:Se(Be,{pills:N,activePillIndex:0,activeSelected:$,onSelectPill:ne,loading:F})})]}),j===null?null:j===void 0?Se(It,{disabled:!ze,onClick:_e}):Se("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:we.submitSlot,onClick:E=>{ze&&(E.stopPropagation(),_e())},children:j})]})]})});export{si as AIAutocomplete,Ze as AIAutocompleteDropdown,tn as DATE_RANGE_META_END,an as DATE_RANGE_META_START,on as DEFAULT_OPTION_COUNT_UNIT,fn as PRODUCT_PATH_PREFIX,Pn as WEEKDAY_LABELS,Xo as buildSubmitResult,Jo as cellDay,en as cellIso,nn as dateCellMarks,rn as formatDate,sn as formatDateRange,ln as formatOptionCount,dn as isoDate,cn as monthLabel,pn as optionCountLabel,hn as optionHasImage,un as optionImageSrc,mn as optionLabel,gn as parseDate,bn as parseLooseDate,vn as parseLooseDateRange,wn as productFromMatchedItem,xn as productsFromCustomFields,yn as sanitizeOptionIconSvg,kn as selectedRangeFor,Je as useAIAutocomplete,Cn as visibleDateRange,Sn as withSkippedParams};
|
|
2186
|
+
`,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:a=>{a.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 $a,dateSelectionFor as Va,identifiedParamLabel as Xa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Dt,useEffect as Oe,useRef as K,useState as Ja}from"react";import{useRef as Tt}from"react";function At(e){let o=Tt(e);o.current=e;let a=Object.keys(e??{}).sort().join("\0"),n=Tt({key:"",overrides:void 0});if(n.current.key!==a){let r={};for(let t of Object.keys(e??{})){let s=(l,v,w)=>{let f=o.current?.[t];return f?f(l,v,w):[]};r[t]=s}n.current={key:a,overrides:e?r:void 0}}return{overrides:n.current.overrides,key:a}}import{useRef as Rt}from"react";function Ot(e){let o=Rt(e);o.current=e;let a=Rt(null);a.current===null&&(a.current={fetch:(r,t)=>{let s=o.current;return s?s.fetch(r,t):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?a.current:void 0,enabled:n}}var ei={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:a,optionOverrides:n,maskCompletedText:r,apiConfig:t,additionalContext:s,columns:l=2,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:f,showNonTappableOptions:h,showOptionIcons:k,showOptionImages:S,showOptionCounts:y,showSkipButton:z,showProducts:L,productImageFallback:I="image",onFocus:T,onBlur:M,value:O,completedParams:R,onChange:C,onParamsChange:U,products:de,onProductSelect:V,source:ce,setCursor:X}){let p=K(null),[ve,pe]=Ja(null),he=K(e);he.current=e;let J=K(o);J.current=o;let ue=K(a);ue.current=a;let ee=K(C);ee.current=C;let Q=K(U);Q.current=U;let te=K(T);te.current=T;let Y=K(M);Y.current=M;let ae=K(X);ae.current=X;let ie=K(V);ie.current=V;let d=Ot(de),u=At(n);Oe(()=>{if(typeof document>"u")return;let g=new $a(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:s,optionOverrides:u.overrides,maskCompletedText:r,columns:l,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:f,showNonTappableOptions:h,showProducts:L,source:ce,value:O,completedParams:R,onSubmit:(...D)=>he.current?.(...D),onResult:(...D)=>J.current?.(...D),onError:(...D)=>ue.current?.(...D),onChange:(...D)=>ee.current?.(...D),onParamsChange:(...D)=>Q.current?.(...D),onFocus:()=>te.current?.(),onBlur:()=>Y.current?.(),onProductSelect:D=>ie.current?.(D),setCursor:D=>ae.current?.(D),products:d.config});p.current=g,pe(g.getState());let H=g.subscribe(D=>pe(D));return()=>{H(),g.destroy(),p.current===g&&(p.current=null)}},[]),Oe(()=>{O!==void 0&&p.current?.setValue(O)},[O]),Oe(()=>{R!==void 0&&p.current?.setCompletedParams(R)},[R]);let b=JSON.stringify(t??null),x;try{x=JSON.stringify(s??null)}catch{x="[unstringifiable]"}Oe(()=>{p.current?.update({apiConfig:t,additionalContext:s,optionOverrides:u.overrides,dropdownTrigger:v,optionsPosition:w,closeDropdownOnBlur:f,showNonTappableOptions:h,showProducts:L})},[b,x,u.key,v,w,f,h,L]);let i=K(!1);Oe(()=>{if(!i.current){i.current=!0;return}p.current?.update({products:d.config})},[d.enabled]);let P=K(null);P.current===null&&(P.current={handleTextChange:g=>p.current?.handleTextChange(g),handleKeyDown:g=>{let H="nativeEvent"in g?g.nativeEvent:g;p.current?.handleKeyDown(H)},setFocused:g=>p.current?.setFocused(g),startEditingParam:g=>p.current?.startEditingParam(g),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:g=>p.current?.handleCaretAfterInput(g),handleCaretMove:g=>p.current?.handleCaretMove(g),replaceEditingRange:g=>p.current?.replaceEditingRange(g)??!1,setActivePill:g=>p.current?.setActivePill(g),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:g=>p.current?.selectOption(g),selectProduct:g=>p.current?.selectProduct(g),setActiveDropdownIndex:g=>p.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let m=P.current,j=Dt(g=>{let H=g.target.value,_e=H.length>0&&!g.nativeEvent?.isComposing&&H[0]!==H[0].toUpperCase()?H[0].toUpperCase()+H.slice(1):H;p.current?.handleTextChange(_e)},[]),G=Dt(g=>{p.current?.handleKeyDown(g.nativeEvent)},[]),we=p.current,c=ve??ei,oe=O!==void 0?O:c.text,me=R!==void 0?R:c.completedParams,ne=c.actionableSuggestions,ke=ne[0],re=we?.listboxId??"",Ce=c.activeDropdownIndex>=0&&we?`${re}-option-${c.activeDropdownIndex}`:void 0,Z=c.editingParam,B=c.editingIdentified,W=Z?{type:Z.suggestionType,text:Z.suggestionPlaceholder,required:!0,options:Z.options}:B?{type:B.type,text:Xa(B.type),required:!0,options:[]}:null,Ee=c.dropdownSuggestion??W??ke,We=W?[W]:ne,Te=Va(c),Le=!we||c.dropdownLoading;return{completedParams:me,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:ne,setActivePill:m.setActivePill,skipActivePill:m.skipActivePill,removeLastParam:m.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:m.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Le,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:re,error:c.error,products:c.products,customFields:c.customFields,selectProduct:m.selectProduct,handleTextChange:m.handleTextChange,handleKeyDown:m.handleKeyDown,setFocused:m.setFocused,editingParam:Z,editingIdentified:B,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:m.startEditingParam,exitEditMode:m.exitEditMode,handleCaretAfterInput:m.handleCaretAfterInput,handleCaretMove:m.handleCaretMove,replaceEditingRange:m.replaceEditingRange,inputProps:{value:oe,placeholder:c.placeholderText||void 0,onChange:j,onKeyDown:G,onFocus:m.handleFocus,onBlur:m.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":Ce,"aria-autocomplete":"list","aria-controls":re},reset:m.reset,dropdownProps:{suggestions:Ee?[{...Ee,options:c.dropdownOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:m.selectOption,onHighlight:m.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:re,pills:We,activeSelected:c.isActivePillSelected,onPillClick:m.setActivePill,onSkip:m.skipActivePill,showSkipButton:(z??!0)&&!Z&&!B,showOptionIcons:k??!0,showOptionImages:S??!0,showOptionCounts:y??!0,skipDisabled:c.inSelectionAnimation,isLoading:Le,skeletonExiting:c.skeletonExiting,isInputEmpty:oe.trim().length===0,products:c.products,productImageFallback:I,onProductSelect:m.selectProduct,onProductFocusChange:m.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Te.selectedIso,selectedDateRange:Te.selectedRange,dateRangeStart:Te.rangeStart,onPreviousMonth:m.showPreviousMonth,onNextMonth:m.showNextMonth,optionsPosition:w??"below"}}}import{extractPlainText as Lt,getCursorOffset as Mt,plainTextLength as ti,renderEditableContent as ai,setCursorOffset as zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as q,useEffect as tt,useLayoutEffect as at,useRef as Se}from"react";var Ge;function ii(){if(Ge!==void 0)return Ge;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ge=e.contentEditable==="plaintext-only",Ge}function Nt(e){let{segments:o,showChipIcons:a=!0,showChipImages:n=!0,newParamId:r,editingParam:t,editingIdentified:s,editingAnchor:l,caretOffset:v,placeholderText:w,isFocused:f,isDropdownOpen:h,listboxId:k,activeDescendantId:S,autoFocus:y,handleTextChange:z,handleKeyDown:L,handleCaretAfterInput:I,handleCaretMove:T,startEditingParam:M,replaceEditingRange:O,setFocused:R}=e,C=Se(null),U=Se(!1),de=Se(""),V=Se(""),ce=Se(null),X=Se(0);ce.current=v,tt(()=>{if(!y)return;let d=C.current;if(!d)return;document.activeElement===d?R(!0):d.focus();let u=d.ownerDocument??document,b=u.getSelection(),x=b&&b.rangeCount>0&&d.contains(b.anchorNode);if(b&&!x){let i=u.createRange();i.selectNodeContents(d),i.collapse(!0),b.removeAllRanges(),b.addRange(i)}},[y,R]),tt(()=>{let d=C.current;if(!d)return;let u=d.ownerDocument??document,b=()=>{let x=u.getSelection();if(!x||x.rangeCount===0||!x.anchorNode||!d.contains(x.anchorNode))return;let i=x.anchorNode,P=i.nodeType===Node.ELEMENT_NODE?i:i.parentElement,j=(x.isCollapsed?P?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,G=t?.id??s?.id??null;if(j&&j!==G){M(j);return}performance.now()-X.current<50||T(Mt(d))};return u.addEventListener("selectionchange",b),()=>u.removeEventListener("selectionchange",b)},[t,s,M,T]),at(()=>{let d=C.current;d&&ai({input:d,segments:o,newParamId:r,editingParamId:t?.id??null,placeholderText:w??"",isFocused:f,showChipIcons:a,showChipImages:n})},[o,r,t,w,f,a,n]),at(()=>{let d=de.current,u=r??"";if(de.current=u,!u||u===d)return;let b=C.current;if(!b)return;b.focus();let x=ce.current??ti(b);zt(b,x)},[r]),at(()=>{let d=V.current,u=t?.id??"";if(V.current=u,!u||u===d||l==null)return;let b=C.current;b&&zt(b,l)},[t,l]);let p=q(()=>{if(U.current)return;let d=C.current;if(!d)return;let u=Lt(d),x=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;z(x)},[z]),ve=q(()=>{X.current=performance.now(),p();let d=C.current;d&&I(Mt(d))},[p,I]);tt(()=>{let d=C.current;if(!d)return;let u=b=>{let x=b,i=x.inputType;if(i==="insertParagraph"||i==="insertLineBreak"||i==="insertFromDrop"){b.preventDefault();return}if(i.startsWith("insert")||i.startsWith("delete")){let P=i.startsWith("delete")?"":x.data??"";O(P)&&b.preventDefault()}};return d.addEventListener("beforeinput",u),()=>d.removeEventListener("beforeinput",u)},[O]);let pe=q(()=>{U.current=!0},[]),he=q(()=>{U.current=!1,p()},[p]),J=q(d=>{d.preventDefault();let u=C.current;if(!u)return;let b=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let x=u.ownerDocument??document,i=x.getSelection();if(!i||i.rangeCount===0)return;let P=i.getRangeAt(0);if(!u.contains(P.startContainer))return;P.deleteContents();let m=x.createTextNode(b);P.insertNode(m),P.setStartAfter(m),P.collapse(!0),i.removeAllRanges(),i.addRange(P),p()},[p]),ue=q(d=>L(d),[L]),ee=q(()=>R(!0),[R]),Q=q(()=>R(!1),[R]),te=q(()=>C.current?.focus(),[]),Y=q(()=>C.current?.blur(),[]),ae=q(()=>{let d=C.current;return d?Lt(d):""},[]),ie=ii()?"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":k,"aria-expanded":h,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:ve,onKeyDown:ue,onCompositionStart:pe,onCompositionEnd:he,onPaste:J,onFocus:ee,onBlur:Q},getPlainText:ae,focus:te,blur:Y}}import{jsx as Ie,jsxs as ot}from"react/jsx-runtime";function ci(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var pi=oi(function({onSubmit:o,onResult:a,onError:n,optionOverrides:r,maskCompletedText:t,className:s,apiConfig:l,additionalContext:v,columns:w,pillPlacement:f="dropdown",mode:h="auto",optionsPosition:k="below",animations:S=!0,dropdownTrigger:y,closeDropdownOnBlur:z,showNonTappableOptions:L,showOptionIcons:I=!0,showChipIcons:T=!0,showChipImages:M=!0,showOptionImages:O=!0,showOptionCounts:R=!0,showSkipButton:C,showProducts:U,productsLayout:de,productImageFallback:V,autoFocus:ce=!0,onFocus:X,onBlur:p,value:ve,completedParams:pe,onChange:he,onParamsChange:J,products:ue,onProductSelect:ee,submitButton:Q},te){let Y=De(null),ae=De(null),ie=De(()=>{}),d=De(null),u=De(null);Bt(()=>{let E=Y.current;if(E)return d.current?d.current.setMode(h):d.current=new li(E,h),()=>{d.current?.destroy(),d.current=null}},[h]);let b=it(E=>{let ge=u.current?.current;ge&&(ge.focus(),di(ge,E))},[]),{completedParams:x,skippedParams:i,identifiedParams:P,isReady:m,customFields:j,suggestionPills:G,setActivePill:we,skipActivePill:c,segments:oe,newParamId:me,clearNewParamId:ne,placeholderText:ke,isFocused:re,isDropdownOpen:Ce,isActivePillSelected:Z,isLoading:B,activeIndex:W,listboxId:Ee,handleTextChange:We,handleKeyDown:Te,setFocused:Le,editingParam:g,editingIdentified:H,editingAnchor:D,caretOffset:_e,startEditingParam:Ht,handleCaretAfterInput:Ft,handleCaretMove:Kt,replaceEditingRange:Gt,dropdownProps:Wt,reset:Me}=et({onSubmit:E=>ie.current(E),onResult:a,onError:n,optionOverrides:r,maskCompletedText:t,apiConfig:l,additionalContext:v,columns:w,dropdownTrigger:y,optionsPosition:k,closeDropdownOnBlur:z,showNonTappableOptions:L,showOptionIcons:I,showOptionImages:O,showOptionCounts:R,showSkipButton:C,showProducts:U,onFocus:X,onBlur:p,value:ve,completedParams:pe,onChange:he,onParamsChange:J,products:ue,onProductSelect:ee,source:"full-sdk",setCursor:b});Bt(()=>{if(!me)return;let E=window.setTimeout(()=>ne(),650);return()=>window.clearTimeout(E)},[me,ne]);let _t=W>=0?`${Ee}-option-${W}`:void 0,{inputRef:qe,editorProps:qt,focus:ze,blur:nt,getPlainText:rt}=Nt({segments:oe,newParamId:me,editingParam:g,editingIdentified:H,editingAnchor:D,caretOffset:_e,placeholderText:ke,isFocused:re,showChipIcons:T,showChipImages:M,isDropdownOpen:Ce,listboxId:Ee,activeDescendantId:_t,autoFocus:ce,handleTextChange:We,handleKeyDown:Te,handleCaretAfterInput:Ft,handleCaretMove:Kt,startEditingParam:Ht,replaceEditingRange:Gt,setFocused:Le});u.current=qe,ri(()=>{let E=ae.current,ge=qe.current;if(!E||!ge)return;let st=()=>{let dt=E.firstElementChild;if(!dt)return;let jt=dt.getBoundingClientRect(),Zt=ge.getBoundingClientRect();jt.top>=Zt.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};st();let lt=new ResizeObserver(st);return lt.observe(ge),()=>lt.disconnect()},[oe,G.length,B,qe]),ni(te,()=>({focus:ze,blur:nt,reset:Me,setMode:E=>d.current?.setMode(E),skipActivePill:c}),[ze,nt,Me,c]);let Ne=!!oe.length||x.length>0,Ue=it(()=>{if(!Ne)return;let E=rt();o(si(E,x,i,{identifiedParams:P,isReady:m,customFields:j})),Me()},[Ne,x,i,P,m,j,o,Me,rt]);ie.current=Ue;let Ut=it(E=>{E.target?.closest("[data-aia-pill]")||ze()},[ze]),Qt=f==="inline",Yt=f==="dropdown";return ot("div",{ref:Y,className:`magicx-aia ${xe.container} ${s??""}`,"data-pill-placement":f,"data-options-position":k,"data-animations":S?"on":"off","data-mode":ci(h),children:[Ie(Xe,{...Wt,showPills:Yt,productsLayout:de,productImageFallback:V}),ot("div",{className:xe.inputWrapper,"data-aia-input-wrapper":"",onClick:Ut,children:[ot("div",{className:xe.editorArea,"data-aia-editor":"",children:[Ie("div",{...qt,className:xe.input,"data-aia-input":""}),Qt&&(B||G.length>0)&&Ie("span",{ref:ae,className:xe.pillListContainer,"data-aia-pill-list-container":"",children:Ie(He,{pills:G,activePillIndex:0,activeSelected:Z,onSelectPill:we,loading:B})})]}),Q===null?null:Q===void 0?Ie(Et,{disabled:!Ne,onClick:Ue}):Ie("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:xe.submitSlot,onClick:E=>{Ne&&(E.stopPropagation(),Ue())},children:Q})]})]})});export{pi as AIAutocomplete,Xe as AIAutocompleteDropdown,rn as DATE_RANGE_META_END,sn as DATE_RANGE_META_START,ln as DEFAULT_OPTION_COUNT_UNIT,wn as PRODUCT_PATH_PREFIX,Tn as WEEKDAY_LABELS,an as buildSubmitResult,on as cellDay,nn as cellIso,dn as dateCellMarks,cn as formatDate,pn as formatDateRange,hn as formatOptionCount,un as isoDate,mn as monthLabel,gn as optionCountLabel,fn as optionHasImage,bn as optionImageSrc,vn as optionLabel,xn as parseDate,yn as parseLooseDate,kn as parseLooseDateRange,Cn as productFromMatchedItem,Pn as productsFromCustomFields,Sn as sanitizeOptionIconSvg,In as selectedRangeFor,et as useAIAutocomplete,En as visibleDateRange,An as withSkippedParams};
|
|
2147
2187
|
//# sourceMappingURL=index.mjs.map
|