@magicx-eng/ai-autocomplete-react 0.29.3 → 0.29.4
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 +1 -1
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -11
- 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 nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END as ln,DATE_RANGE_META_START as dn,DEFAULT_OPTION_COUNT_UNIT as cn,dateCellMarks as pn,formatDate as hn,formatDateRange as un,formatOptionCount as mn,isoDate as gn,monthLabel as fn,optionCountLabel as bn,optionHasImage as vn,optionImageSrc as wn,optionLabel as xn,PRODUCT_PATH_PREFIX as yn,parseDate as kn,parseLooseDate as Cn,parseLooseDateRange as Pn,productFromMatchedItem as Sn,productsFromCustomFields as In,sanitizeOptionIconSvg as En,selectedRangeFor as Tn,visibleDateRange as An,WEEKDAY_LABELS as Rn,withSkippedParams as
|
|
1
|
+
import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END as ln,DATE_RANGE_META_START as dn,DEFAULT_OPTION_COUNT_UNIT as cn,dateCellMarks as pn,formatDate as hn,formatDateRange as un,formatOptionCount as mn,isoDate as gn,monthLabel as fn,optionCountLabel as bn,optionHasImage as vn,optionImageSrc as wn,optionLabel as xn,PRODUCT_PATH_PREFIX as yn,parseDate as kn,parseLooseDate as Cn,parseLooseDateRange as Pn,productFromMatchedItem as Sn,productsFromCustomFields as In,sanitizeOptionIconSvg as En,selectedRangeFor as Tn,visibleDateRange as An,WEEKDAY_LABELS as Rn,withSkippedParams as On}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as ri,useCallback as it,useEffect as Bt,useImperativeHandle as si,useLayoutEffect as li,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 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 ke={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 _a,containScroll as qa,isCalendarFormat as Ua,SCROLL_ARROW_LABEL as Qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as We,useRef as Ge,useState as
|
|
265
|
+
`,document.head.appendChild(e)}var ke={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 _a,containScroll as qa,isCalendarFormat as Ua,SCROLL_ARROW_LABEL as Qa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as We,useRef as Ge,useState as Ya}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
|
*
|
|
@@ -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 D={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as X,jsxs as ct}from"react/jsx-runtime";var oa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function pt({options:e,activeIndex:o,listboxId:t,view:n,selection:r,onSelect:i,onHighlight:a,onUnhighlight:l,onPreviousMonth:w,onNextMonth:b}){let v=Jt(new Date),C=ta({pendingStart:r.rangeStart,highlightedIso:Se(e[o]),selected:r.selectedRange});return ct("div",{className:D.datepicker,"data-aia-datepicker":"",children:[ct("div",{className:D.header,children:[X("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:g=>g.preventDefault(),onClick:w,children:"\u2039"}),X("span",{className:D.month,"data-aia-date-month":"","aria-live":"polite",children:ea(n)}),X("button",{type:"button",tabIndex:-1,className:D.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:g=>g.preventDefault(),onClick:b,children:"\u203A"})]}),X("div",{className:D.weekdays,"aria-hidden":"true",children:aa.map((g,x)=>X("span",{className:D.weekday,children:g},oa[x]))}),X("div",{className:D.grid,"data-aia-date-grid":"",children:e.map((g,x)=>X(na,{option:g,id:`${t}-option-${x}`,index:x,isHighlighted:x===o&&g.is_tappable,isToday:Se(g)===v,isPast:Se(g)!=null&&Se(g)<v,marks:Xt(Se(g),{selectedIso:r.selectedIso,range:C}),onSelect:i,onHighlight:a,onUnhighlight:l},Se(g)??`pad-${x}`))})]})}function na({option:e,id:o,index:t,isHighlighted:n,isToday:r,isPast:i,marks:a,onSelect:l,onHighlight:w,onUnhighlight:b}){let[v,C]=ia(!1),g=Vt(e);if(g==null)return X("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${D.cell} ${D.blank}`});let x=()=>{C(!0),l(e),setTimeout(()=>C(!1),170)},T=[D.cell,D.day,i?D.past:"",n?D.highlighted:"",r?D.today:"",a.inRange?D.inRange:"",a.selected?D.selected:"",v?D.pressed:""].filter(Boolean).join(" ");return X("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:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),x())},onMouseEnter:()=>w(t),onMouseLeave:b?()=>b(t):void 0,children:X("span",{className:D.number,children:g})})}import{ATTRIBUTION_URL as ra,buildAttributionUrl as sa,getFooterHint as la}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as da,useState as ca}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);
|
|
@@ -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 Re,jsxs 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 Re,jsxs as Ye}from"react/jsx-runtime";function ut({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:t,hint:n}=la(e,o),[r,i]=ca(ra);return da(()=>{i(sa())},[]),Re("footer",{className:se.footer,"data-aia-footer":"",children:Ye(Ae,{justify:"between",noWrap:!0,className:se.row,children:[Ye(Ae,{gap:"5px",className:se.hintGroup,children:[Re("kbd",{className:se.key,children:t}),Re("span",{className:se.hint,children:n})]}),Ye("a",{className:se.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[Re("span",{className:se.brand,children:"AI"}),Re("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 be={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 pa}from"react/jsx-runtime";var
|
|
1457
|
+
`,document.head.appendChild(e)}var be={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 pa}from"react/jsx-runtime";var je={selected:1,first:.7,next:.4,last:.2};function mt({label:e,state:o,rounded:t,loading:n,onClick:r}){let i=[be.pill,t?be.rounded:"",n?be.skeleton:""].filter(Boolean).join(" ");return pa("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 Ze={list:"aia-list-qvLqO"};import{jsx as He}from"react/jsx-runtime";var ha=[125,69];function gt(e){return e===0?"first":e===1?"next":"last"}function Fe({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:n,rounded:r,loading:i}){return i&&e.length===0?He("span",{className:Ze.list,"data-aia-pill-list-loading":"",children:ha.map((a,l)=>He("span",{"data-aia-pill-skeleton":"",className:`${be.pill} ${r?be.rounded:""} ${be.skeleton}`,style:{width:a,opacity:
|
|
1467
|
+
`,document.head.appendChild(e)}var Ze={list:"aia-list-qvLqO"};import{jsx as He}from"react/jsx-runtime";var ha=[125,69];function gt(e){return e===0?"first":e===1?"next":"last"}function Fe({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:n,rounded:r,loading:i}){return i&&e.length===0?He("span",{className:Ze.list,"data-aia-pill-list-loading":"",children:ha.map((a,l)=>He("span",{"data-aia-pill-skeleton":"",className:`${be.pill} ${r?be.rounded:""} ${be.skeleton}`,style:{width:a,opacity:je[gt(l)]}},`skel-${a}`))}):He("span",{className:Ze.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((a,l)=>{let w=!!n&&l===o;return He(mt,{label:a.text,state:w?"selected":gt(l),selected:w,rounded:r,loading:i,onClick:()=>t(l)},`${a.type}-${a.text}`)})})}import{attachProductRowWheel as ua,productInitial as ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ga,useRef as fa,useState as ba}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 ve,jsxs as Ke}from"react/jsx-runtime";function ft({products:e,listboxId:o,onSelect:t,onFocusChange:n,focusable:r=!0,layout:i="row",imageFallback:a="image"}){let l=e.length>0,w=fa(null);if(ga(()=>{let v=w.current;if(!(!l||!v))return ua(v)},[l]),!l)return null;let b=`${o}-products-label`;return Ke("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":b,children:[ve("div",{className:Q.label,id:b,"data-aia-products-label":"",children:"Products"}),ve("div",{ref:w,className:Q.row,"data-aia-products-row":"",children:e.map((v,C)=>ve(va,{product:v,id:`${o}-product-${C}`,onSelect:t,onFocusChange:n,focusable:r,imageFallback:a},v.id))})]})}function va({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 Ke("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:[ve(wa,{src:e.imageUrl?.trim(),title:e.title,fallback:i},e.imageUrl?.trim()??""),Ke("span",{className:Q.body,children:[e.vendor?ve("span",{className:Q.vendor,children:e.vendor}):null,ve("span",{className:Q.title,children:e.title}),e.price?ve("span",{className:Q.price,children:e.price}):null]})]})}function wa({src:e,title:o,fallback:t}){let[n,r]=ba(!1),i=!!e&&!n,a=!i&&t==="initial";return Ke("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!a?"":void 0,"data-aia-product-initial":a?"":void 0,children:[i?ve("img",{className:Q.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0)}):null,a?ma(o):null]})}import{isOptionsGridMobileViewport as La,measureOptionsGrid 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 ve,jsxs as Ke}from"react/jsx-runtime";function ft({products:e,listboxId:o,onSelect:t,onFocusChange:n,focusable:r=!0,layout:i="row",imageFallback:a="image"}){let l=e.length>0,w=fa(null);if(ga(()=>{let v=w.current;if(!(!l||!v))return ua(v)},[l]),!l)return null;let b=`${o}-products-label`;return Ke("section",{className:Q.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":b,children:[ve("div",{className:Q.label,id:b,"data-aia-products-label":"",children:"Products"}),ve("div",{ref:w,className:Q.row,"data-aia-products-row":"",children:e.map((v,C)=>ve(va,{product:v,id:`${o}-product-${C}`,onSelect:t,onFocusChange:n,focusable:r,imageFallback:a},v.id))})]})}function va({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 Ke("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:[ve(wa,{src:e.imageUrl?.trim(),title:e.title,fallback:i},e.imageUrl?.trim()??""),Ke("span",{className:Q.body,children:[e.vendor?ve("span",{className:Q.vendor,children:e.vendor}):null,ve("span",{className:Q.title,children:e.title}),e.price?ve("span",{className:Q.price,children:e.price}):null]})]})}function wa({src:e,title:o,fallback:t}){let[n,r]=ba(!1),i=!!e&&!n,a=!i&&t==="initial";return Ke("span",{className:Q.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!a?"":void 0,"data-aia-product-initial":a?"":void 0,children:[i?ve("img",{className:Q.image,src:e,alt:"",loading:"lazy",decoding:"async",onError:()=>r(!0)}):null,a?ma(o):null]})}import{isOptionsGridMobileViewport as La,measureOptionsGrid as za,needsOptionsGridMeasurement as Ma,OPTIONS_GRID_MOBILE_QUERY as Na,optionEnterDelayMs as Ba,planOptionsGrid as wt,sameOptionRows as Ha}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Fa,useLayoutEffect as Ka,useRef as xt,useState as kt}from"react";import{optionsGridTemplateColumns as xa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ya,useRef as ka}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 Ca}from"react/jsx-runtime";function bt({min:e="16rem",max:o,gap:t,scroll:n=!1,maxHeight:r,scrollResetKey:i,cols:a,template:l,innerRef:w,className:b,children:v,...C}){let g=ka(null);ya(()=>{if(i===void 0)return;let T=g.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=xa(a)),l&&(x.gridTemplateColumns=l),Ca("div",{ref:T=>{g.current=T,w?.(T)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":n||void 0,style:x,...C,children:v})}import{formatOptionCount as Pa,OPTION_ENTER_DELAY_VAR as Sa,optionImageSrc as Ia,optionLabel as Ea,sanitizeOptionIconSvg as Ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Aa,useMemo as Ra,useRef as
|
|
1731
|
+
`,document.head.appendChild(e)}import{jsx as Ca}from"react/jsx-runtime";function bt({min:e="16rem",max:o,gap:t,scroll:n=!1,maxHeight:r,scrollResetKey:i,cols:a,template:l,innerRef:w,className:b,children:v,...C}){let g=ka(null);ya(()=>{if(i===void 0)return;let T=g.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=xa(a)),l&&(x.gridTemplateColumns=l),Ca("div",{ref:T=>{g.current=T,w?.(T)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":n||void 0,style:x,...C,children:v})}import{formatOptionCount as Pa,OPTION_ENTER_DELAY_VAR as Sa,optionImageSrc as Ia,optionLabel as Ea,sanitizeOptionIconSvg as Ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Aa,useMemo as Ra,useRef as Oa,useState as $e}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.
|
|
@@ -2073,6 +2073,16 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2073
2073
|
margin-right: 0;
|
|
2074
2074
|
}
|
|
2075
2075
|
|
|
2076
|
+
/* The glyph scales up with its box: at one text line (1em) it reads as a speck
|
|
2077
|
+
beside the picture tiles in the same column. 1.5em (24px at the default
|
|
2078
|
+
option font size) is 60% of the default tile, about where a picture's
|
|
2079
|
+
subject sits in its frame. Still em-based, so --aia-option-font-size scales
|
|
2080
|
+
it; --aia-option-tile-icon-size overrides it. */
|
|
2081
|
+
[data-aia-group]:has(.aia-image-YZAbO) .aia-content-T-Qba:not(:has(.aia-image-YZAbO)) .aia-icon-Qw938 svg {
|
|
2082
|
+
width: var(--aia-option-tile-icon-size, 1.5em);
|
|
2083
|
+
height: var(--aia-option-tile-icon-size, 1.5em);
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2076
2086
|
@keyframes aia-skeletonPulse-plvdD {
|
|
2077
2087
|
0%,
|
|
2078
2088
|
100% {
|
|
@@ -2115,7 +2125,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2115
2125
|
opacity: 0;
|
|
2116
2126
|
}
|
|
2117
2127
|
}
|
|
2118
|
-
`,document.head.appendChild(e)}var H={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 Ce,jsxs as
|
|
2128
|
+
`,document.head.appendChild(e)}var H={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 Ce,jsxs as Da}from"react/jsx-runtime";function vt({option:e,isHighlighted:o,onSelect:t,onHighlight:n,onUnhighlight:r,id:i,loading:a,showIcon:l=!0,showImage:w=!0,showCount:b=!0,scrollHint:v,enterDelayMs:C=0}){let[g]=$e(C),[x,T]=$e(!1),S=w?Ia(e.image_url):null,[z,M]=$e(null),I=Ra(()=>!S&&l&&e.icon_svg?Ta(e.icon_svg):null,[S,l,e.icon_svg]),A=b?Pa(e.item_count):null,R=Oa(void 0);Aa(()=>()=>clearTimeout(R.current),[]);let E=()=>{a||!e.is_tappable||x||(T(!0),t(e),clearTimeout(R.current),R.current=setTimeout(()=>T(!1),170))},P=[H.item,o&&!a?H.highlighted:"",e.is_tappable?H.tappable:H.nonTappable,x?H.pressed:"",v?H.scrollHint:""].filter(Boolean).join(" ");return Ce("div",{id:i,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":I&&e.icon?e.icon:void 0,"data-aia-image":S?"":void 0,"data-aia-item-count":A!==null?e.item_count:void 0,"aria-selected":o,className:P,style:{[Sa]:`${g}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:E,onKeyDown:N=>{!a&&e.is_tappable&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),E())},onMouseEnter:!a&&e.is_tappable?n:void 0,onMouseLeave:r,children:Da("span",{className:H.content,children:[S&&Ce("span",{className:`${H.image} magicx-aia-option-image`,"aria-hidden":"true",children:Ce("img",{src:S,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:z===S,onError:()=>M(S)})}),I&&Ce("span",{className:`${H.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:I}}),Ce("span",{className:H.text,children:Ea(e)}),e.tag&&Ce("span",{className:H.tag,children:e.tag}),A!==null&&Ce("span",{className:`${H.count} magicx-aia-option-count`,children:A})]})})}import{jsx as yt}from"react/jsx-runtime";function Ga(){let[e,o]=kt(La);return Fa(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Na),n=()=>o(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[]),e}function Ct({options:e,activeIndex:o,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:i,loading:a,groupKey:l="",optionsPosition:w="below",showIcons:b=!0,showImages:v=!0,showCounts:C=!0}){let g=Ga(),x=xt(null),[T,S]=kt(null),z=xt(null);Ka(()=>{if(a&&Ha(z.current,e))return;z.current=a?null:e;let I=x.current,R=I&&!a&&Ma(e.length,g)?za(I):null;S(R?wt(e.length,g,R.rowWidths,R.gridWidth):null)},[e,g,a]);let M=T??wt(e.length,g,null,null);return yt(bt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:l,template:M.template,maxHeight:M.maxHeight,innerRef:I=>{x.current=I},"data-aia-group":l,children:e.map((I,A)=>yt(vt,{option:I,isHighlighted:A===o,onSelect:t,onHighlight:()=>n(A),onUnhighlight:r?()=>r(A):void 0,id:`${i}-option-${A}`,loading:a,showIcon:b,showImage:v,showCount:C,scrollHint:!a&&M.scrollHintIndices.includes(A),enterDelayMs:a?0:Ba(A,M.cols,e.length,w)},`${l}\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 {
|
|
2119
2129
|
display: flex;
|
|
2120
2130
|
flex-direction: column;
|
|
2121
2131
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2130,7 +2140,7 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2130
2140
|
align-items: end;
|
|
2131
2141
|
}
|
|
2132
2142
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2133
|
-
`,document.head.appendChild(e)}import{jsx as Wa}from"react/jsx-runtime";function Pt({space:e,align:o="stretch",className:t,children:n,...r}){let i=e?{"--aia-stack-space":e}:void 0;return Wa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...r,children:n})}import{jsx as K,jsxs as Ve}from"react/jsx-runtime";var
|
|
2143
|
+
`,document.head.appendChild(e)}import{jsx as Wa}from"react/jsx-runtime";function Pt({space:e,align:o="stretch",className:t,children:n,...r}){let i=e?{"--aia-stack-space":e}:void 0;return Wa("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...r,children:n})}import{jsx as K,jsxs as Ve}from"react/jsx-runtime";var ja=[159,119,164],Za=()=>{},St=()=>{};function $a(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,n]=Ya(o);if(We(()=>{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 Va(e,o){let t=Ge(null);We(()=>{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:_a({dropdown:n,grid:i,button:r})};return}t.current?.controller.update()}),We(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Xe({suggestions:e,activeIndex:o,onSelect:t,onHighlight:n,onUnhighlight:r,isOpen:i,id:a,className:l,pills:w,onPillClick:b,showPills:v=!0,onSkip:C,showSkipButton:g=!0,showOptionIcons:x=!0,showOptionImages:T=!0,showOptionCounts:S=!0,skipDisabled:z=!1,activeSelected:M=!1,isLoading:I=!1,skeletonExiting:A=!1,isInputEmpty:R=!1,products:E,onProductSelect:P,onProductFocusChange:N,productsLayout:le="row",productImageFallback:J="image",formatType:de="options",dateView:ee=null,selectedDateIso:c=null,selectedDateRange:we=null,dateRangeStart:ce=null,onPreviousMonth:pe,onNextMonth:he,optionsPosition:te="below",mode:ue}){let W=$a(ue),ae=W!==void 0,_=Ge(null),j=Ge(null);Va(_,j),We(()=>{if(_.current)return qa(_.current)},[]);let ie=e[0]?.options??[],d=!!(w&&w.length>0&&b),p=!!(E&&E.length>0),f=i&&(ie.length>0||v&&d||I||p),k={suggestions:e,activeIndex:o,pills:w,showPills:v,showSkipButton:g,showOptionIcons:x,showOptionImages:T,showOptionCounts:S,skipDisabled:z,activeSelected:M,isLoading:I,skeletonExiting:A,isInputEmpty:R,products:E,formatType:de,dateView:ee,selectedDateIso:c,selectedDateRange:we,dateRangeStart:ce},y=Ge(k);f&&(y.current=k);let s=f?k:y.current,m=s.suggestions[0],B=m?.options??[],me=s.activeIndex>=0&&!!B[s.activeIndex]?.is_tappable,q=!!(s.pills&&s.pills.length>0&&b),h=s.showPills&&q,xe=s.showPills&&!q&&s.isLoading,ge=h||xe,Z=q&&s.showSkipButton&&!s.isInputEmpty&&!!C,ye=s.pills?.[0]?.text,oe=Ua(s.formatType)&&s.dateView!=null,Pe=B.length>0&&!oe,U=B.length>0&&oe&&!s.isLoading,ne=s.isLoading&&!Pe&&!U,$=s.products??[];return Ve("div",{ref:_,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":te,"data-mode":W,"data-aia-loading":s.isLoading?"":void 0,"data-aia-skeleton-exiting":s.skeletonExiting?"":void 0,"data-aia-has-products":$.length>0?"":void 0,className:`${ae?"magicx-aia ":""}${re.dropdown} ${f?re.visible:""} ${l??""}`,onMouseDown:V=>V.preventDefault(),children:[Ve(Pt,{space:"8px",children:[(ge||Z)&&Ve(Ae,{noWrap:!0,className:re.pillBar,"data-aia-pillbar":"",children:[ge&&K("span",{className:re.pillScroll,"data-aia-pill-scroll":"",children:K(Fe,{pills:s.pills??[],activePillIndex:0,activeSelected:s.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:s.isLoading})}),Z&&K("button",{type:"button",tabIndex:-1,className:re.skip,"data-aia-skip":"",disabled:s.isLoading||s.skipDisabled,"aria-label":ye?`Skip ${ye}`:"Skip",onClick:C,children:"skip"})]}),Pe&&K(Ct,{options:B,activeIndex:s.activeIndex,onSelect:t,onHighlight:n,onUnhighlight:r,listboxId:a,loading:s.isLoading,groupKey:m?`${m.type} ${m.text}`:"",optionsPosition:te,showIcons:s.showOptionIcons,showImages:s.showOptionImages,showCounts:s.showOptionCounts}),U&&s.dateView&&K(pt,{options:B,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:pe??St,onNextMonth:he??St}),ne&&K("div",{className:re.skeletonBars,"data-aia-skeleton-bars":"",children:ja.map(V=>K("span",{className:re.skeletonBar,style:{width:V}},`bar-${V}`))}),K(ft,{products:$,listboxId:a,onSelect:P??Za,onFocusChange:N,focusable:f,layout:le,imageFallback:J}),K(ut,{isOptionHighlighted:me,isInputEmpty:s.isInputEmpty})]}),K("button",{ref:j,type:"button",tabIndex:-1,className:re.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Qa,"aria-hidden":"true",children:K("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:K("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as di,ModeController as ci,setCursorOffset as pi}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 {
|
|
2134
2144
|
flex-shrink: 0;
|
|
2135
2145
|
width: 32px;
|
|
2136
2146
|
height: 32px;
|
|
@@ -2183,5 +2193,5 @@ import{buildSubmitResult as nn,cellDay as rn,cellIso as sn,DATE_RANGE_META_END a
|
|
|
2183
2193
|
);
|
|
2184
2194
|
cursor: default;
|
|
2185
2195
|
}
|
|
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: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 Ot,useEffect as De,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 Dt(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:M,productImageFallback:z="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 Y=G(ee);Y.current=ee;let ie=G(J);ie.current=J;let d=Dt(le),p=At(n);De(()=>{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:M,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=>Y.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)}},[]),De(()=>{R!==void 0&&c.current?.setValue(R)},[R]),De(()=>{E!==void 0&&c.current?.setCompletedParams(E)},[E]);let f=JSON.stringify(i??null),k;try{k=JSON.stringify(a??null)}catch{k="[unstringifiable]"}De(()=>{c.current?.update({apiConfig:i,additionalContext:a,optionOverrides:p.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:C,showProducts:M})},[f,k,p.key,w,b,v,C,M]);let y=G(!1);De(()=>{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=Ot(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=Ot(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),Me=!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:Me,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:Me,skeletonExiting:h.skeletonExiting,isInputEmpty:xe.trim().length===0,products:h.products,productImageFallback:z,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 Mt,plainTextLength as ii,renderEditableContent as oi,setCursorOffset as zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as j,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:M,handleCaretAfterInput:z,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(Mt(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);zt(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&&zt(f,l)},[i,l]);let c=j(()=>{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=j(()=>{ee.current=performance.now(),c();let d=P.current;d&&z(Mt(d))},[c,z]);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=j(()=>{N.current=!0},[]),pe=j(()=>{N.current=!1,c()},[c]),he=j(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=j(d=>M(d),[M]),ue=j(()=>E(!0),[E]),W=j(()=>E(!1),[E]),ae=j(()=>P.current?.focus(),[]),_=j(()=>P.current?.blur(),[]),Y=j(()=>{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:Y,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:M,showOptionIcons:z=!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 Y=Oe(null),ie=Oe(null),d=Oe(()=>{}),p=Oe(null),f=Oe(null);Bt(()=>{let D=Y.current;if(D)return p.current?p.current.setMode(C):p.current=new ci(D,C),()=>{p.current?.destroy(),p.current=null}},[C]);let k=it(D=>{let fe=f.current?.current;fe&&(fe.focus(),pi(fe,D))},[]),{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:Me,setFocused:u,editingParam:F,editingIdentified:L,editingAnchor:qe,caretOffset:Ht,startEditingParam:Ft,handleCaretAfterInput:Kt,handleCaretMove:Gt,replaceEditingRange:Wt,dropdownProps:_t,reset:ze}=et({onSubmit:D=>d.current(D),onResult:t,onError:n,optionOverrides:r,maskCompletedText:i,apiConfig:l,additionalContext:w,columns:b,dropdownTrigger:T,optionsPosition:g,closeDropdownOnBlur:S,showNonTappableOptions:M,showOptionIcons:z,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 D=window.setTimeout(()=>ye(),650);return()=>window.clearTimeout(D)},[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:Me,handleCaretAfterInput:Kt,handleCaretMove:Gt,startEditingParam:Ft,replaceEditingRange:Wt,setFocused:u});f.current=Ue,li(()=>{let D=ie.current,fe=Ue.current;if(!D||!fe)return;let st=()=>{let dt=D.firstElementChild;if(!dt)return;let Zt=dt.getBoundingClientRect(),$t=fe.getBoundingClientRect();Zt.top>=$t.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.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:ze,setMode:D=>p.current?.setMode(D),skipActivePill:xe}),[Ne,nt,ze,xe]);let Be=!!ge.length||y.length>0,Qe=it(()=>{if(!Be)return;let D=rt();o(di(D,y,s,{identifiedParams:m,isReady:B,customFields:me})),ae&&ze()},[ae,Be,y,s,m,B,me,o,ze,rt]);d.current=Qe;let Qt=it(D=>{D.target?.closest("[data-aia-pill]")||Ne()},[Ne]),jt=v==="inline",Yt=v==="dropdown";return ot("div",{ref:Y,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:Yt,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":""}),jt&&($||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:D=>{Be&&(D.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,Dn as withSkippedParams};
|
|
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};
|
|
2187
2197
|
//# sourceMappingURL=index.mjs.map
|