@magicx-eng/ai-autocomplete-react 0.23.0 → 0.24.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 +10 -0
- package/dist/index.d.mts +23 -3
- package/dist/index.d.ts +23 -3
- package/dist/index.js +49 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -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 jo,cellDay as $o,cellIso as Vo,DATE_RANGE_META_END as Qo,DATE_RANGE_META_START as Zo,dateCellMarks as Yo,formatDate as Xo,formatDateRange as Jo,isoDate as en,monthLabel as tn,optionLabel as an,PRODUCT_PATH_PREFIX as on,parseDate as nn,parseLooseDate as rn,parseLooseDateRange as sn,productFromMatchedItem as ln,productsFromCustomFields as dn,sanitizeOptionIconSvg as cn,selectedRangeFor as pn,visibleDateRange as hn,WEEKDAY_LABELS as un,withSkippedParams as fn}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Va,useCallback as Je,useEffect as Mt,useImperativeHandle as Qa,useLayoutEffect as Za,useRef as Ie}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
|
|
@@ -227,7 +227,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
227
227
|
opacity: 0;
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
`,document.head.appendChild(e)}var ge={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
|
|
230
|
+
`,document.head.appendChild(e)}var ge={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 La,isCalendarFormat as Ma,SCROLL_ARROW_LABEL as Oa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $e,useRef as Ne,useState as za}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
231
231
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
232
232
|
* Consumer CSS always wins without !important.
|
|
233
233
|
*
|
|
@@ -982,7 +982,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
982
982
|
opacity: 0.25;
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
|
-
`,document.head.appendChild(e)}var
|
|
985
|
+
`,document.head.appendChild(e)}var re={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as Ut,cellIso as we,dateCellMarks as jt,isoDate as $t,monthLabel as Vt,visibleDateRange as Qt,WEEKDAY_LABELS as Zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Yt}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) ---
|
|
986
986
|
|
|
987
987
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
988
988
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1145,7 +1145,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1145
1145
|
opacity: 0.8;
|
|
1146
1146
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1147
1147
|
}
|
|
1148
|
-
`,document.head.appendChild(e)}var
|
|
1148
|
+
`,document.head.appendChild(e)}var E={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 Q,jsxs as rt}from"react/jsx-runtime";var Xt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:a,view:n,selection:s,onSelect:i,onHighlight:o,onPreviousMonth:g,onNextMonth:b}){let p=$t(new Date),x=Qt({pendingStart:s.rangeStart,highlightedIso:we(e[r]),selected:s.selectedRange});return rt("div",{className:E.datepicker,"data-aia-datepicker":"",children:[rt("div",{className:E.header,children:[Q("button",{type:"button",tabIndex:-1,className:E.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:g,children:"\u2039"}),Q("span",{className:E.month,"data-aia-date-month":"","aria-live":"polite",children:Vt(n)}),Q("button",{type:"button",tabIndex:-1,className:E.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:b,children:"\u203A"})]}),Q("div",{className:E.weekdays,"aria-hidden":"true",children:Zt.map((u,y)=>Q("span",{className:E.weekday,children:u},Xt[y]))}),Q("div",{className:E.grid,"data-aia-date-grid":"",children:e.map((u,y)=>Q(Jt,{option:u,id:`${a}-option-${y}`,index:y,isHighlighted:y===r&&u.is_tappable,isToday:we(u)===p,isPast:we(u)!=null&&we(u)<p,marks:jt(we(u),{selectedIso:s.selectedIso,range:x}),onSelect:i,onHighlight:o},we(u)??`pad-${y}`))})]})}function Jt({option:e,id:r,index:a,isHighlighted:n,isToday:s,isPast:i,marks:o,onSelect:g,onHighlight:b}){let[p,x]=Yt(!1),u=Ut(e);if(u==null)return Q("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${E.cell} ${E.blank}`});let y=()=>{x(!0),g(e),setTimeout(()=>x(!1),170)},k=[E.cell,E.day,i?E.past:"",n?E.highlighted:"",s?E.today:"",o.inRange?E.inRange:"",o.selected?E.selected:"",p?E.pressed:""].filter(Boolean).join(" ");return Q("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:k,onClick:y,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),y())},onMouseEnter:()=>b(a),children:Q("span",{className:E.number,children:u})})}import{ATTRIBUTION_URL as ea,buildAttributionUrl as ta,getFooterHint as aa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ia,useState as oa}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 {
|
|
1149
1149
|
display: flex;
|
|
1150
1150
|
flex-wrap: wrap;
|
|
1151
1151
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1185,7 +1185,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1185
1185
|
.aia-cluster[data-justify="around"] {
|
|
1186
1186
|
justify-content: space-around;
|
|
1187
1187
|
}
|
|
1188
|
-
`,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:
|
|
1188
|
+
`,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:a="start",noWrap:n=!1,inline:s=!1,className:i,children:o,...g}){let b=e?{"--aia-cluster-gap":e}:void 0,p={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":r,"data-justify":a,"data-nowrap":n||void 0,"data-inline":s||void 0,style:b,...g};return s?lt("span",{...p,children:o}):lt("div",{...p,children:o})}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
|
|
1189
1189
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1190
1190
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1191
1191
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1319,7 +1319,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1319
1319
|
justify-content: flex-end;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
`,document.head.appendChild(e)}var
|
|
1322
|
+
`,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 Se,jsxs as We}from"react/jsx-runtime";function dt({isOptionHighlighted:e=!1,isInputEmpty:r=!1}){let{key:a,hint:n}=aa(e,r),[s,i]=oa(ea);return ia(()=>{i(ta())},[]),Se("footer",{className:se.footer,"data-aia-footer":"",children:We(Pe,{justify:"between",noWrap:!0,className:se.row,children:[We(Pe,{gap:"5px",className:se.hintGroup,children:[Se("kbd",{className:se.key,children:a}),Se("span",{className:se.hint,children:n})]}),We("a",{className:se.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[Se("span",{className:se.brand,children:"AI"}),Se("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,
|
|
1323
1323
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1324
1324
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1325
1325
|
as it was when the outline was dashed. */
|
|
@@ -1376,7 +1376,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1376
1376
|
opacity: 0;
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
1379
|
-
`,document.head.appendChild(e)}var
|
|
1379
|
+
`,document.head.appendChild(e)}var ue={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonPulse:"aia-skeletonPulse-xGcUy"};import{jsx as na}from"react/jsx-runtime";var _e={selected:1,first:.7,next:.4,last:.2};function ct({label:e,state:r,rounded:a,loading:n,onClick:s}){let i=[ue.pill,a?ue.rounded:"",n?ue.skeleton:""].filter(Boolean).join(" ");return na("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:_e[r]},onMouseDown:o=>o.preventDefault(),onClick:n?void 0:s,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 {
|
|
1380
1380
|
position: relative;
|
|
1381
1381
|
z-index: 1;
|
|
1382
1382
|
pointer-events: auto;
|
|
@@ -1386,7 +1386,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1386
1386
|
align-items: center;
|
|
1387
1387
|
vertical-align: middle;
|
|
1388
1388
|
}
|
|
1389
|
-
`,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var
|
|
1389
|
+
`,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var ra=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:a,activeSelected:n,rounded:s,loading:i}){return i&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:ra.map((o,g)=>Me("span",{"data-aia-pill-skeleton":"",className:`${ue.pill} ${s?ue.rounded:""} ${ue.skeleton}`,style:{width:o,opacity:_e[pt(g)]}},`skel-${o}`))}):Me("span",{className:qe.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((o,g)=>{let b=!!n&&g===r;return Me(ct,{label:o.text,state:b?"selected":pt(g),selected:b,rounded:s,loading:i,onClick:()=>a(g)},`${o.type}-${o.text}`)})})}import{attachProductRowWheel as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as la,useRef as da}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
|
|
1390
1390
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1391
1391
|
theming one package sees the same result in the other.
|
|
1392
1392
|
|
|
@@ -1567,7 +1567,44 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1567
1567
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1568
1568
|
);
|
|
1569
1569
|
}
|
|
1570
|
-
|
|
1570
|
+
|
|
1571
|
+
/* --- List layout (\`productsLayout: "list"\`) ---
|
|
1572
|
+
The same cards stacked as full-width rows \u2014 thumbnail on the left, text on
|
|
1573
|
+
the right \u2014 for results that read as a list (courses, listings, documents)
|
|
1574
|
+
rather than a shelf. The column scrolls vertically inside its own cap
|
|
1575
|
+
instead of sideways; the dropdown's \`overflow: hidden\` still contains it
|
|
1576
|
+
and the hidden scrollbar chrome above carries over. Appended after the row
|
|
1577
|
+
rules on purpose: the parity test finds each base rule by its first
|
|
1578
|
+
occurrence, and these selectors contain the base selectors. */
|
|
1579
|
+
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-row-WDVBX {
|
|
1580
|
+
flex-direction: column;
|
|
1581
|
+
gap: var(--aia-product-list-gap, 2px);
|
|
1582
|
+
max-height: var(--aia-product-list-max-height, 320px);
|
|
1583
|
+
overflow-x: hidden;
|
|
1584
|
+
overflow-y: auto;
|
|
1585
|
+
overscroll-behavior-y: contain;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-card-JBGYT {
|
|
1589
|
+
flex-direction: row;
|
|
1590
|
+
align-items: center;
|
|
1591
|
+
gap: 10px;
|
|
1592
|
+
width: auto;
|
|
1593
|
+
padding: 6px 8px;
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
/* A fixed square thumbnail: width and height together, so the row's height
|
|
1597
|
+
is the tile's, not the card width's. */
|
|
1598
|
+
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-media-RrbGe {
|
|
1599
|
+
flex: 0 0 auto;
|
|
1600
|
+
width: var(--aia-product-list-media-size, 44px);
|
|
1601
|
+
height: var(--aia-product-list-media-size, 44px);
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1604
|
+
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-body-ly032 {
|
|
1605
|
+
flex: 1 1 auto;
|
|
1606
|
+
}
|
|
1607
|
+
`,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 fe,jsxs as Ue}from"react/jsx-runtime";function ht({products:e,listboxId:r,onSelect:a,onFocusChange:n,focusable:s=!0,layout:i="row"}){let o=e.length>0,g=da(null);if(la(()=>{let p=g.current;if(!(!o||!p))return sa(p)},[o]),!o)return null;let b=`${r}-products-label`;return Ue("section",{className:_.section,"data-aia-products":"","data-aia-products-layout":i,role:"group","aria-labelledby":b,children:[fe("div",{className:_.label,id:b,"data-aia-products-label":"",children:"Products"}),fe("div",{ref:g,className:_.row,"data-aia-products-row":"",children:e.map((p,x)=>fe(ca,{product:p,id:`${r}-product-${x}`,onSelect:a,onFocusChange:n,focusable:s},p.id))})]})}function ca({product:e,id:r,onSelect:a,onFocusChange:n,focusable:s}){let i=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),a(e))};return Ue("a",{id:r,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:i,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),a(e))},onFocus:()=>n?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[fe("span",{className:_.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?fe("img",{className:_.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Ue("span",{className:_.body,children:[e.vendor?fe("span",{className:_.vendor,children:e.vendor}):null,fe("span",{className:_.title,children:e.title}),e.price?fe("span",{className:_.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as ka,measureOptionsGrid as Ca,needsOptionsGridMeasurement as Pa,OPTIONS_GRID_MOBILE_QUERY as Sa,optionEnterDelayMs as Ea,planOptionsGrid as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ia,useLayoutEffect as Ta,useRef as Aa,useState as vt}from"react";import{optionsGridTemplateColumns as pa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ha,useRef as ua}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 {
|
|
1571
1608
|
display: grid;
|
|
1572
1609
|
grid-template-columns: repeat(
|
|
1573
1610
|
auto-fit,
|
|
@@ -1600,7 +1637,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1600
1637
|
background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
|
|
1601
1638
|
border-radius: 3px;
|
|
1602
1639
|
}
|
|
1603
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1640
|
+
`,document.head.appendChild(e)}import{jsx as fa}from"react/jsx-runtime";function ut({min:e="16rem",max:r,gap:a,scroll:n=!1,maxHeight:s,scrollResetKey:i,cols:o,template:g,innerRef:b,className:p,children:x,...u}){let y=ua(null);ha(()=>{if(i===void 0)return;let v=y.current;v&&(v.scrollTop=0)},[i]);let k={"--aia-grid-min":e};return r&&(k["--aia-grid-max"]=r),a&&(k["--aia-grid-gap"]=a),s&&(k["--aia-grid-max-height"]=s),o&&(k.gridTemplateColumns=pa(o)),g&&(k.gridTemplateColumns=g),fa("div",{ref:v=>{y.current=v,b?.(v)},className:p?`aia-grid ${p}`:"aia-grid","data-scroll":n||void 0,style:k,...u,children:x})}import{OPTION_ENTER_DELAY_VAR as ma,optionLabel as ga,sanitizeOptionIconSvg as ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as va,useMemo as wa,useRef as xa,useState as ft}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 {
|
|
1604
1641
|
position: relative;
|
|
1605
1642
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1606
1643
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -1805,7 +1842,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1805
1842
|
filter: brightness(0.55);
|
|
1806
1843
|
}
|
|
1807
1844
|
}
|
|
1808
|
-
`,document.head.appendChild(e)}var q={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",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",icon:"aia-icon-Qw938"};import{jsx as ze,jsxs as
|
|
1845
|
+
`,document.head.appendChild(e)}var q={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",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",icon:"aia-icon-Qw938"};import{jsx as ze,jsxs as ya}from"react/jsx-runtime";function mt({option:e,isHighlighted:r,onSelect:a,onHighlight:n,id:s,loading:i,showIcon:o=!0,scrollHint:g,enterDelayMs:b=0}){let[p]=ft(b),[x,u]=ft(!1),y=wa(()=>o&&e.icon_svg?ba(e.icon_svg):null,[o,e.icon_svg]),k=xa(void 0);va(()=>()=>clearTimeout(k.current),[]);let v=()=>{i||!e.is_tappable||x||(u(!0),a(e),clearTimeout(k.current),k.current=setTimeout(()=>u(!1),170))},I=[q.item,r&&!i?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,x?q.pressed:"",g?q.scrollHint:""].filter(Boolean).join(" ");return ze("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":y&&e.icon?e.icon:void 0,"aria-selected":r,className:I,style:{[ma]:`${p}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:v,onKeyDown:A=>{!i&&e.is_tappable&&(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),v())},onMouseEnter:!i&&e.is_tappable?n:void 0,children:ya("span",{className:q.content,children:[y&&ze("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:y}}),ze("span",{className:q.text,children:ga(e)}),e.tag&&ze("span",{className:q.tag,children:e.tag})]})})}import{jsx as bt}from"react/jsx-runtime";function Ra(){let[e,r]=vt(ka);return Ia(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(Sa),n=()=>r(a.matches);return n(),a.addEventListener("change",n),()=>a.removeEventListener("change",n)},[]),e}function wt({options:e,activeIndex:r,onSelect:a,onHighlight:n,listboxId:s,loading:i,groupKey:o="",optionsPosition:g="below",showIcons:b=!0}){let p=Ra(),x=Aa(null),[u,y]=vt(null);Ta(()=>{let v=x.current,A=v&&!i&&Pa(e.length,p)?Ca(v):null;y(A?gt(e.length,p,A.rowWidths,A.gridWidth):null)},[e,p,i]);let k=u??gt(e.length,p,null,null);return bt(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:k.template,maxHeight:k.maxHeight,innerRef:v=>{x.current=v},"data-aia-group":o,children:e.map((v,I)=>bt(mt,{option:v,isHighlighted:I===r,onSelect:a,onHighlight:()=>n(I),id:`${s}-option-${I}`,loading:i,showIcon:b,scrollHint:!i&&k.scrollHintIndices.includes(I),enterDelayMs:i?0:Ea(I,k.cols,e.length,g)},`${o}\0${v.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
1809
1846
|
display: flex;
|
|
1810
1847
|
flex-direction: column;
|
|
1811
1848
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -1820,7 +1857,7 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1820
1857
|
align-items: end;
|
|
1821
1858
|
}
|
|
1822
1859
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1823
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1860
|
+
`,document.head.appendChild(e)}import{jsx as Da}from"react/jsx-runtime";function xt({space:e,align:r="stretch",className:a,children:n,...s}){let i=e?{"--aia-stack-space":e}:void 0;return Da("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":r,style:i,...s,children:n})}import{jsx as K,jsxs as je}from"react/jsx-runtime";var Na=[159,119,164],Ha=()=>{},yt=()=>{};function Ba(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,n]=za(r);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>n(s.matches);return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Fa(e,r){let a=Ne(null);$e(()=>{let n=e.current,s=r.current;if(!n||!s)return;let i=n.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==i&&(a.current.controller.destroy(),a.current=null),i&&!a.current){a.current={grid:i,controller:La({dropdown:n,grid:i,button:s})};return}a.current?.controller.update()}),$e(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function Ve({suggestions:e,activeIndex:r,onSelect:a,onHighlight:n,isOpen:s,id:i,className:o,pills:g,onPillClick:b,showPills:p=!0,onSkip:x,showSkipButton:u=!0,showOptionIcons:y=!0,skipDisabled:k=!1,activeSelected:v=!1,isLoading:I=!1,isInputEmpty:A=!1,products:R,onProductSelect:D,onProductFocusChange:Z,productsLayout:L="row",formatType:P="options",dateView:j=null,selectedDateIso:le=null,selectedDateRange:Y=null,dateRangeStart:h=null,onPreviousMonth:de,onNextMonth:M,optionsPosition:X="below",mode:ce}){let J=Ba(ce),$=J!==void 0,ee=Ne(null),V=Ne(null);Fa(ee,V);let te=e[0]?.options??[],ae=!!(g&&g.length>0&&b),O=!!(R&&R.length>0),z=s&&(te.length>0||p&&ae||I||O),W={suggestions:e,activeIndex:r,pills:g,showPills:p,showSkipButton:u,showOptionIcons:y,skipDisabled:k,activeSelected:v,isLoading:I,isInputEmpty:A,products:R,formatType:P,dateView:j,selectedDateIso:le,selectedDateRange:Y,dateRangeStart:h},c=Ne(W);z&&(c.current=W);let t=z?W:c.current,f=t.suggestions[0],w=f?.options??[],l=t.activeIndex>=0&&!!w[t.activeIndex]?.is_tappable,S=!!(t.pills&&t.pills.length>0&&b),ie=t.showPills&&S,B=t.showPills&&!S&&t.isLoading,d=ie||B,oe=S&&t.showSkipButton&&!t.isInputEmpty&&!!x,me=t.pills?.[0]?.text,pe=Ma(t.formatType)&&t.dateView!=null,be=w.length>0&&!pe,ne=w.length>0&&pe&&!t.isLoading,ke=t.isLoading&&!be&&!ne,N=t.products??[];return je("div",{ref:ee,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":X,"data-mode":J,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":N.length>0?"":void 0,className:`${$?"magicx-aia ":""}${re.dropdown} ${z?re.visible:""} ${o??""}`,onMouseDown:H=>H.preventDefault(),children:[je(xt,{space:"8px",children:[(d||oe)&&je(Pe,{noWrap:!0,className:re.pillBar,"data-aia-pillbar":"",children:[d&&K("span",{className:re.pillScroll,"data-aia-pill-scroll":"",children:K(Oe,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:t.isLoading})}),oe&&K("button",{type:"button",tabIndex:-1,className:re.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":me?`Skip ${me}`:"Skip",onClick:x,children:"skip"})]}),be&&K(wt,{options:w,activeIndex:t.activeIndex,onSelect:a,onHighlight:n,listboxId:i,loading:t.isLoading,groupKey:f?`${f.type} ${f.text}`:"",optionsPosition:X,showIcons:t.showOptionIcons}),ne&&t.dateView&&K(st,{options:w,activeIndex:t.activeIndex,listboxId:i,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:a,onHighlight:n,onPreviousMonth:de??yt,onNextMonth:M??yt}),ke&&K("div",{className:re.skeletonBars,"data-aia-skeleton-bars":"",children:Na.map(H=>K("span",{className:re.skeletonBar,style:{width:H}},`bar-${H}`))}),K(ht,{products:N,listboxId:i,onSelect:D??Ha,onFocusChange:Z,focusable:z,layout:L}),K(dt,{isOptionHighlighted:l,isInputEmpty:t.isInputEmpty})]}),K("button",{ref:V,type:"button",tabIndex:-1,className:re.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Oa,"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 Ya,ModeController as Xa,setCursorOffset as Ja}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 {
|
|
1824
1861
|
flex-shrink: 0;
|
|
1825
1862
|
width: 32px;
|
|
1826
1863
|
height: 32px;
|
|
@@ -1873,5 +1910,5 @@ import{buildSubmitResult as Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END a
|
|
|
1873
1910
|
);
|
|
1874
1911
|
cursor: default;
|
|
1875
1912
|
}
|
|
1876
|
-
`,document.head.appendChild(e)}var kt={submitButton:"aia-submitButton-otz7H"};import{jsx as Qe}from"react/jsx-runtime";function Ct({disabled:e,onClick:r}){return Qe("button",{type:"button","data-aia-submit":"",className:kt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),r()},"aria-label":"Submit",children:Qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Fa,dateSelectionFor as Ka,identifiedParamLabel as Ga}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as Wa}from"react";import{useRef as Pt}from"react";function St(e){let r=Pt(e);r.current=e;let i=Object.keys(e??{}).sort().join("\0"),n=Pt({key:"",overrides:void 0});if(n.current.key!==i){let s={};for(let a of Object.keys(e??{})){let o=(g,f,b)=>{let w=r.current?.[a];return w?w(g,f,b):[]};s[a]=o}n.current={key:i,overrides:e?s:void 0}}return{overrides:n.current.overrides,key:i}}import{useRef as Et}from"react";function It(e){let r=Et(e);r.current=e;let i=Et(null);i.current===null&&(i.current={fetch:(s,a)=>{let o=r.current;return o?o.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let n=e!==void 0;return{config:n?i.current:void 0,enabled:n}}var _a={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:[],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 Ze({onSubmit:e,onResult:r,onError:i,optionOverrides:n,maskCompletedText:s,apiConfig:a,additionalContext:o,columns:g=2,dropdownTrigger:f,optionsPosition:b,closeDropdownOnBlur:w,showNonTappableOptions:u,showOptionIcons:x,showSkipButton:k,showProducts:v,onFocus:E,onBlur:T,value:R,completedParams:O,onChange:Y,onParamsChange:z,products:P,onProductSelect:j,source:ne,setCursor:X}){let p=G(null),[re,D]=Wa(null),se=G(e);se.current=e;let J=G(r);J.current=r;let $=G(i);$.current=i;let ee=G(Y);ee.current=Y;let V=G(z);V.current=z;let te=G(E);te.current=E;let ae=G(T);ae.current=T;let N=G(X);N.current=X;let H=G(j);H.current=j;let W=It(P),B=St(n);Ee(()=>{if(typeof document>"u")return;let m=new Fa(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:B.overrides,maskCompletedText:s,columns:g,dropdownTrigger:f,optionsPosition:b,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:v,source:ne,value:R,completedParams:O,onSubmit:(...I)=>se.current?.(...I),onResult:(...I)=>J.current?.(...I),onError:(...I)=>$.current?.(...I),onChange:(...I)=>ee.current?.(...I),onParamsChange:(...I)=>V.current?.(...I),onFocus:()=>te.current?.(),onBlur:()=>ae.current?.(),onProductSelect:I=>H.current?.(I),setCursor:I=>N.current?.(I),products:W.config});p.current=m,D(m.getState());let F=m.subscribe(I=>D(I));return()=>{F(),m.destroy(),p.current===m&&(p.current=null)}},[]),Ee(()=>{R!==void 0&&p.current?.setValue(R)},[R]),Ee(()=>{O!==void 0&&p.current?.setCompletedParams(O)},[O]);let t=JSON.stringify(a??null),c;try{c=JSON.stringify(o??null)}catch{c="[unstringifiable]"}Ee(()=>{p.current?.update({apiConfig:a,additionalContext:o,optionOverrides:B.overrides,dropdownTrigger:f,optionsPosition:b,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:v})},[t,c,B.key,f,b,w,u,v]);let h=G(!1);Ee(()=>{if(!h.current){h.current=!0;return}p.current?.update({products:W.config})},[W.enabled]);let y=G(null);y.current===null&&(y.current={handleTextChange:m=>p.current?.handleTextChange(m),handleKeyDown:m=>{let F="nativeEvent"in m?m.nativeEvent:m;p.current?.handleKeyDown(F)},setFocused:m=>p.current?.setFocused(m),startEditingParam:m=>p.current?.startEditingParam(m),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:m=>p.current?.handleCaretAfterInput(m),handleCaretMove:m=>p.current?.handleCaretMove(m),replaceEditingRange:m=>p.current?.replaceEditingRange(m)??!1,setActivePill:m=>p.current?.setActivePill(m),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:m=>p.current?.selectOption(m),selectProduct:m=>p.current?.selectProduct(m),setActiveDropdownIndex:m=>p.current?.setActiveDropdownIndex(m),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let l=y.current,A=Tt(m=>{let F=m.target.value,Fe=F.length>0&&!m.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;p.current?.handleTextChange(Fe)},[]),Q=Tt(m=>{p.current?.handleKeyDown(m.nativeEvent)},[]),L=p.current,d=re??_a,le=R!==void 0?R:d.text,be=O!==void 0?O:d.completedParams,de=d.actionableSuggestions,ve=de[0],ce=L?.listboxId??"",pe=d.activeDropdownIndex>=0&&L?`${ce}-option-${d.activeDropdownIndex}`:void 0,M=d.editingParam,he=d.editingIdentified,ke=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:he?{type:he.type,text:Ga(he.type),required:!0,options:[]}:null,Te=ke??ve,Be=ke?[ke]:de,Ce=Ka(d),Ae=!L||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:be,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:de,setActivePill:l.setActivePill,skipActivePill:l.skipActivePill,removeLastParam:l.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:l.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ae,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ce,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:M,editingIdentified:he,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:le,placeholder:d.placeholderText||void 0,onChange:A,onKeyDown:Q,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":pe,"aria-autocomplete":"list","aria-controls":ce},reset:l.reset,dropdownProps:{suggestions:Te?[{...Te,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ce,pills:Be,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!M&&!he,showOptionIcons:x??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:le.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as qa,renderEditableContent as Ua,setCursorOffset as Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Ye,useLayoutEffect as Xe,useRef as xe}from"react";var He;function ja(){if(He!==void 0)return He;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),He=e.contentEditable==="plaintext-only",He}function Lt(e){let{segments:r,showChipIcons:i=!0,newParamId:n,editingParam:s,editingIdentified:a,editingAnchor:o,caretOffset:g,placeholderText:f,isFocused:b,isDropdownOpen:w,listboxId:u,activeDescendantId:x,autoFocus:k,handleTextChange:v,handleKeyDown:E,handleCaretAfterInput:T,handleCaretMove:R,startEditingParam:O,replaceEditingRange:Y,setFocused:z}=e,P=xe(null),j=xe(!1),ne=xe(""),X=xe(""),p=xe(null),re=xe(0);p.current=g,Ye(()=>{if(!k)return;let t=P.current;if(!t)return;document.activeElement===t?z(!0):t.focus();let c=t.ownerDocument??document,h=c.getSelection(),y=h&&h.rangeCount>0&&t.contains(h.anchorNode);if(h&&!y){let l=c.createRange();l.selectNodeContents(t),l.collapse(!0),h.removeAllRanges(),h.addRange(l)}},[k,z]),Ye(()=>{let t=P.current;if(!t)return;let c=t.ownerDocument??document,h=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!t.contains(y.anchorNode))return;let l=y.anchorNode,A=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,L=(y.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=s?.id??a?.id??null;if(L&&L!==d){O(L);return}performance.now()-re.current<50||R(Rt(t))};return c.addEventListener("selectionchange",h),()=>c.removeEventListener("selectionchange",h)},[s,a,O,R]),Xe(()=>{let t=P.current;t&&Ua({input:t,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:f??"",isFocused:b,showChipIcons:i})},[r,n,s,f,b,i]),Xe(()=>{let t=ne.current,c=n??"";if(ne.current=c,!c||c===t)return;let h=P.current;if(!h)return;h.focus();let y=p.current??qa(h);Dt(h,y)},[n]),Xe(()=>{let t=X.current,c=s?.id??"";if(X.current=c,!c||c===t||o==null)return;let h=P.current;h&&Dt(h,o)},[s,o]);let D=U(()=>{if(j.current)return;let t=P.current;if(!t)return;let c=At(t),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;v(y)},[v]),se=U(()=>{re.current=performance.now(),D();let t=P.current;t&&T(Rt(t))},[D,T]);Ye(()=>{let t=P.current;if(!t)return;let c=h=>{let y=h,l=y.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){h.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let A=l.startsWith("delete")?"":y.data??"";Y(A)&&h.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[Y]);let J=U(()=>{j.current=!0},[]),$=U(()=>{j.current=!1,D()},[D]),ee=U(t=>{t.preventDefault();let c=P.current;if(!c)return;let h=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let y=c.ownerDocument??document,l=y.getSelection();if(!l||l.rangeCount===0)return;let A=l.getRangeAt(0);if(!c.contains(A.startContainer))return;A.deleteContents();let Q=y.createTextNode(h);A.insertNode(Q),A.setStartAfter(Q),A.collapse(!0),l.removeAllRanges(),l.addRange(A),D()},[D]),V=U(t=>E(t),[E]),te=U(()=>z(!0),[z]),ae=U(()=>z(!1),[z]),N=U(()=>P.current?.focus(),[]),H=U(()=>P.current?.blur(),[]),W=U(()=>{let t=P.current;return t?At(t):""},[]),B=ja()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:B,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":w,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:se,onKeyDown:V,onCompositionStart:J,onCompositionEnd:$,onPaste:ee,onFocus:te,onBlur:ae},getPlainText:W,focus:N,blur:H}}import{jsx as ye,jsxs as et}from"react/jsx-runtime";function Ja(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ei=$a(function({onSubmit:r,onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:g,additionalContext:f,columns:b,pillPlacement:w="dropdown",mode:u="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:v,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R=!0,showChipIcons:O=!0,showSkipButton:Y,showProducts:z,autoFocus:P=!0,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,submitButton:$},ee){let V=Ie(null),te=Ie(null),ae=Ie(()=>{}),N=Ie(null),H=Ie(null);Mt(()=>{let C=V.current;if(C)return N.current?N.current.setMode(u):N.current=new Ya(C,u),()=>{N.current?.destroy(),N.current=null}},[u]);let W=Je(C=>{let ue=H.current?.current;ue&&(ue.focus(),Xa(ue,C))},[]),{completedParams:B,skippedParams:t,identifiedParams:c,isReady:h,customFields:y,suggestionPills:l,setActivePill:A,skipActivePill:Q,segments:L,newParamId:d,clearNewParamId:le,placeholderText:be,isFocused:de,isDropdownOpen:ve,isActivePillSelected:ce,isLoading:pe,activeIndex:M,listboxId:he,handleTextChange:ke,handleKeyDown:Te,setFocused:Be,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,startEditingParam:I,handleCaretAfterInput:Fe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Re}=Ze({onSubmit:C=>ae.current(C),onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,apiConfig:g,additionalContext:f,columns:b,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R,showSkipButton:Y,showProducts:z,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,source:"full-sdk",setCursor:W});Mt(()=>{if(!d)return;let C=window.setTimeout(()=>le(),650);return()=>window.clearTimeout(C)},[d,le]);let Ht=M>=0?`${he}-option-${M}`:void 0,{inputRef:Ke,editorProps:Bt,focus:De,blur:tt,getPlainText:at}=Lt({segments:L,newParamId:d,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,placeholderText:be,isFocused:de,showChipIcons:O,isDropdownOpen:ve,listboxId:he,activeDescendantId:Ht,autoFocus:P,handleTextChange:ke,handleKeyDown:Te,handleCaretAfterInput:Fe,handleCaretMove:Ot,startEditingParam:I,replaceEditingRange:zt,setFocused:Be});H.current=Ke,Qa(()=>{let C=te.current,ue=Ke.current;if(!C||!ue)return;let it=()=>{let nt=C.firstElementChild;if(!nt)return;let Wt=nt.getBoundingClientRect(),_t=ue.getBoundingClientRect();Wt.top>=_t.bottom-2?C.setAttribute("data-aia-pill-wrapped",""):C.removeAttribute("data-aia-pill-wrapped")};it();let ot=new ResizeObserver(it);return ot.observe(ue),()=>ot.disconnect()},[L,l.length,pe,Ke]),Va(ee,()=>({focus:De,blur:tt,reset:Re,setMode:C=>N.current?.setMode(C),skipActivePill:Q}),[De,tt,Re,Q]);let Le=!!L.length||B.length>0,Ge=Je(()=>{if(!Le)return;let C=at();r(Za(C,B,t,{identifiedParams:c,isReady:h,customFields:y})),Re()},[Le,B,t,c,h,y,r,Re,at]);ae.current=Ge;let Ft=Je(C=>{C.target?.closest("[data-aia-pill]")||De()},[De]),Kt=w==="inline",Gt=w==="dropdown";return et("div",{ref:V,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":w,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Ja(u),children:[ye(Ve,{...Nt,showPills:Gt}),et("div",{className:ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[et("div",{className:ge.editorArea,"data-aia-editor":"",children:[ye("div",{...Bt,className:ge.input,"data-aia-input":""}),Kt&&(pe||l.length>0)&&ye("span",{ref:te,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ye(Oe,{pills:l,activePillIndex:0,activeSelected:ce,onSelectPill:A,loading:pe})})]}),$===null?null:$===void 0?ye(Ct,{disabled:!Le,onClick:Ge}):ye("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ge.submitSlot,onClick:C=>{Le&&(C.stopPropagation(),Ge())},children:$})]})]})});export{ei as AIAutocomplete,Ve as AIAutocompleteDropdown,Vo as DATE_RANGE_META_END,Qo as DATE_RANGE_META_START,an as PRODUCT_PATH_PREFIX,hn as WEEKDAY_LABELS,Uo as buildSubmitResult,jo as cellDay,$o as cellIso,Zo as dateCellMarks,Yo as formatDate,Xo as formatDateRange,Jo as isoDate,en as monthLabel,tn as optionLabel,on as parseDate,nn as parseLooseDate,rn as parseLooseDateRange,sn as productFromMatchedItem,ln as productsFromCustomFields,dn as sanitizeOptionIconSvg,cn as selectedRangeFor,Ze as useAIAutocomplete,pn as visibleDateRange,un as withSkippedParams};
|
|
1913
|
+
`,document.head.appendChild(e)}var kt={submitButton:"aia-submitButton-otz7H"};import{jsx as Qe}from"react/jsx-runtime";function Ct({disabled:e,onClick:r}){return Qe("button",{type:"button","data-aia-submit":"",className:kt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),r()},"aria-label":"Submit",children:Qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Ka,dateSelectionFor as Ga,identifiedParamLabel as Wa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as _a}from"react";import{useRef as Pt}from"react";function St(e){let r=Pt(e);r.current=e;let a=Object.keys(e??{}).sort().join("\0"),n=Pt({key:"",overrides:void 0});if(n.current.key!==a){let s={};for(let i of Object.keys(e??{})){let o=(g,b,p)=>{let x=r.current?.[i];return x?x(g,b,p):[]};s[i]=o}n.current={key:a,overrides:e?s:void 0}}return{overrides:n.current.overrides,key:a}}import{useRef as Et}from"react";function It(e){let r=Et(e);r.current=e;let a=Et(null);a.current===null&&(a.current={fetch:(s,i)=>{let o=r.current;return o?o.fetch(s,i):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let n=e!==void 0;return{config:n?a.current:void 0,enabled:n}}var qa={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:[],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 Ze({onSubmit:e,onResult:r,onError:a,optionOverrides:n,maskCompletedText:s,apiConfig:i,additionalContext:o,columns:g=2,dropdownTrigger:b,optionsPosition:p,closeDropdownOnBlur:x,showNonTappableOptions:u,showOptionIcons:y,showSkipButton:k,showProducts:v,onFocus:I,onBlur:A,value:R,completedParams:D,onChange:Z,onParamsChange:L,products:P,onProductSelect:j,source:le,setCursor:Y}){let h=G(null),[de,M]=_a(null),X=G(e);X.current=e;let ce=G(r);ce.current=r;let J=G(a);J.current=a;let $=G(Z);$.current=Z;let ee=G(L);ee.current=L;let V=G(I);V.current=I;let te=G(A);te.current=A;let ae=G(Y);ae.current=Y;let O=G(j);O.current=j;let z=It(P),W=St(n);Ee(()=>{if(typeof document>"u")return;let m=new Ka(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:o,optionOverrides:W.overrides,maskCompletedText:s,columns:g,dropdownTrigger:b,optionsPosition:p,closeDropdownOnBlur:x,showNonTappableOptions:u,showProducts:v,source:le,value:R,completedParams:D,onSubmit:(...T)=>X.current?.(...T),onResult:(...T)=>ce.current?.(...T),onError:(...T)=>J.current?.(...T),onChange:(...T)=>$.current?.(...T),onParamsChange:(...T)=>ee.current?.(...T),onFocus:()=>V.current?.(),onBlur:()=>te.current?.(),onProductSelect:T=>O.current?.(T),setCursor:T=>ae.current?.(T),products:z.config});h.current=m,M(m.getState());let F=m.subscribe(T=>M(T));return()=>{F(),m.destroy(),h.current===m&&(h.current=null)}},[]),Ee(()=>{R!==void 0&&h.current?.setValue(R)},[R]),Ee(()=>{D!==void 0&&h.current?.setCompletedParams(D)},[D]);let c=JSON.stringify(i??null),t;try{t=JSON.stringify(o??null)}catch{t="[unstringifiable]"}Ee(()=>{h.current?.update({apiConfig:i,additionalContext:o,optionOverrides:W.overrides,dropdownTrigger:b,optionsPosition:p,closeDropdownOnBlur:x,showNonTappableOptions:u,showProducts:v})},[c,t,W.key,b,p,x,u,v]);let f=G(!1);Ee(()=>{if(!f.current){f.current=!0;return}h.current?.update({products:z.config})},[z.enabled]);let w=G(null);w.current===null&&(w.current={handleTextChange:m=>h.current?.handleTextChange(m),handleKeyDown:m=>{let F="nativeEvent"in m?m.nativeEvent:m;h.current?.handleKeyDown(F)},setFocused:m=>h.current?.setFocused(m),startEditingParam:m=>h.current?.startEditingParam(m),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:m=>h.current?.handleCaretAfterInput(m),handleCaretMove:m=>h.current?.handleCaretMove(m),replaceEditingRange:m=>h.current?.replaceEditingRange(m)??!1,setActivePill:m=>h.current?.setActivePill(m),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:m=>h.current?.selectOption(m),selectProduct:m=>h.current?.selectProduct(m),setActiveDropdownIndex:m=>h.current?.setActiveDropdownIndex(m),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let l=w.current,S=Tt(m=>{let F=m.target.value,Fe=F.length>0&&!m.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;h.current?.handleTextChange(Fe)},[]),ie=Tt(m=>{h.current?.handleKeyDown(m.nativeEvent)},[]),B=h.current,d=de??qa,oe=R!==void 0?R:d.text,me=D!==void 0?D:d.completedParams,pe=d.actionableSuggestions,be=pe[0],ne=B?.listboxId??"",ke=d.activeDropdownIndex>=0&&B?`${ne}-option-${d.activeDropdownIndex}`:void 0,N=d.editingParam,H=d.editingIdentified,ve=N?{type:N.suggestionType,text:N.suggestionPlaceholder,required:!0,options:N.options}:H?{type:H.type,text:Wa(H.type),required:!0,options:[]}:null,Te=ve??be,Be=ve?[ve]:pe,Ce=Ga(d),Ae=!B||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:me,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:pe,setActivePill:l.setActivePill,skipActivePill:l.skipActivePill,removeLastParam:l.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:l.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ae,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ne,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:N,editingIdentified:H,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:oe,placeholder:d.placeholderText||void 0,onChange:S,onKeyDown:ie,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ke,"aria-autocomplete":"list","aria-controls":ne},reset:l.reset,dropdownProps:{suggestions:Te?[{...Te,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ne,pills:Be,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!N&&!H,showOptionIcons:y??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:oe.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:p??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as Ua,renderEditableContent as ja,setCursorOffset as Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Ye,useLayoutEffect as Xe,useRef as xe}from"react";var He;function $a(){if(He!==void 0)return He;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),He=e.contentEditable==="plaintext-only",He}function Lt(e){let{segments:r,showChipIcons:a=!0,newParamId:n,editingParam:s,editingIdentified:i,editingAnchor:o,caretOffset:g,placeholderText:b,isFocused:p,isDropdownOpen:x,listboxId:u,activeDescendantId:y,autoFocus:k,handleTextChange:v,handleKeyDown:I,handleCaretAfterInput:A,handleCaretMove:R,startEditingParam:D,replaceEditingRange:Z,setFocused:L}=e,P=xe(null),j=xe(!1),le=xe(""),Y=xe(""),h=xe(null),de=xe(0);h.current=g,Ye(()=>{if(!k)return;let c=P.current;if(!c)return;document.activeElement===c?L(!0):c.focus();let t=c.ownerDocument??document,f=t.getSelection(),w=f&&f.rangeCount>0&&c.contains(f.anchorNode);if(f&&!w){let l=t.createRange();l.selectNodeContents(c),l.collapse(!0),f.removeAllRanges(),f.addRange(l)}},[k,L]),Ye(()=>{let c=P.current;if(!c)return;let t=c.ownerDocument??document,f=()=>{let w=t.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!c.contains(w.anchorNode))return;let l=w.anchorNode,S=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,B=(w.isCollapsed?S?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=s?.id??i?.id??null;if(B&&B!==d){D(B);return}performance.now()-de.current<50||R(Rt(c))};return t.addEventListener("selectionchange",f),()=>t.removeEventListener("selectionchange",f)},[s,i,D,R]),Xe(()=>{let c=P.current;c&&ja({input:c,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:b??"",isFocused:p,showChipIcons:a})},[r,n,s,b,p,a]),Xe(()=>{let c=le.current,t=n??"";if(le.current=t,!t||t===c)return;let f=P.current;if(!f)return;f.focus();let w=h.current??Ua(f);Dt(f,w)},[n]),Xe(()=>{let c=Y.current,t=s?.id??"";if(Y.current=t,!t||t===c||o==null)return;let f=P.current;f&&Dt(f,o)},[s,o]);let M=U(()=>{if(j.current)return;let c=P.current;if(!c)return;let t=At(c),w=t.length>0&&t[0]!==t[0].toUpperCase()?t[0].toUpperCase()+t.slice(1):t;v(w)},[v]),X=U(()=>{de.current=performance.now(),M();let c=P.current;c&&A(Rt(c))},[M,A]);Ye(()=>{let c=P.current;if(!c)return;let t=f=>{let w=f,l=w.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){f.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let S=l.startsWith("delete")?"":w.data??"";Z(S)&&f.preventDefault()}};return c.addEventListener("beforeinput",t),()=>c.removeEventListener("beforeinput",t)},[Z]);let ce=U(()=>{j.current=!0},[]),J=U(()=>{j.current=!1,M()},[M]),$=U(c=>{c.preventDefault();let t=P.current;if(!t)return;let f=(c.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let w=t.ownerDocument??document,l=w.getSelection();if(!l||l.rangeCount===0)return;let S=l.getRangeAt(0);if(!t.contains(S.startContainer))return;S.deleteContents();let ie=w.createTextNode(f);S.insertNode(ie),S.setStartAfter(ie),S.collapse(!0),l.removeAllRanges(),l.addRange(S),M()},[M]),ee=U(c=>I(c),[I]),V=U(()=>L(!0),[L]),te=U(()=>L(!1),[L]),ae=U(()=>P.current?.focus(),[]),O=U(()=>P.current?.blur(),[]),z=U(()=>{let c=P.current;return c?At(c):""},[]),W=$a()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:W,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":x,"aria-activedescendant":y,spellCheck:!0,enterKeyHint:"send",onInput:X,onKeyDown:ee,onCompositionStart:ce,onCompositionEnd:J,onPaste:$,onFocus:V,onBlur:te},getPlainText:z,focus:ae,blur:O}}import{jsx as ye,jsxs as et}from"react/jsx-runtime";function ei(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ti=Va(function({onSubmit:r,onResult:a,onError:n,optionOverrides:s,maskCompletedText:i,className:o,apiConfig:g,additionalContext:b,columns:p,pillPlacement:x="dropdown",mode:u="auto",optionsPosition:y="below",animations:k=!0,dropdownTrigger:v,closeDropdownOnBlur:I,showNonTappableOptions:A,showOptionIcons:R=!0,showChipIcons:D=!0,showSkipButton:Z,showProducts:L,productsLayout:P,autoFocus:j=!0,onFocus:le,onBlur:Y,value:h,completedParams:de,onChange:M,onParamsChange:X,products:ce,onProductSelect:J,submitButton:$},ee){let V=Ie(null),te=Ie(null),ae=Ie(()=>{}),O=Ie(null),z=Ie(null);Mt(()=>{let C=V.current;if(C)return O.current?O.current.setMode(u):O.current=new Xa(C,u),()=>{O.current?.destroy(),O.current=null}},[u]);let W=Je(C=>{let he=z.current?.current;he&&(he.focus(),Ja(he,C))},[]),{completedParams:c,skippedParams:t,identifiedParams:f,isReady:w,customFields:l,suggestionPills:S,setActivePill:ie,skipActivePill:B,segments:d,newParamId:oe,clearNewParamId:me,placeholderText:pe,isFocused:be,isDropdownOpen:ne,isActivePillSelected:ke,isLoading:N,activeIndex:H,listboxId:ve,handleTextChange:Te,handleKeyDown:Be,setFocused:Ce,editingParam:Ae,editingIdentified:m,editingAnchor:F,caretOffset:T,startEditingParam:Fe,handleCaretAfterInput:Ot,handleCaretMove:zt,replaceEditingRange:Nt,dropdownProps:Ht,reset:Re}=Ze({onSubmit:C=>ae.current(C),onResult:a,onError:n,optionOverrides:s,maskCompletedText:i,apiConfig:g,additionalContext:b,columns:p,dropdownTrigger:v,optionsPosition:y,closeDropdownOnBlur:I,showNonTappableOptions:A,showOptionIcons:R,showSkipButton:Z,showProducts:L,onFocus:le,onBlur:Y,value:h,completedParams:de,onChange:M,onParamsChange:X,products:ce,onProductSelect:J,source:"full-sdk",setCursor:W});Mt(()=>{if(!oe)return;let C=window.setTimeout(()=>me(),650);return()=>window.clearTimeout(C)},[oe,me]);let Bt=H>=0?`${ve}-option-${H}`:void 0,{inputRef:Ke,editorProps:Ft,focus:De,blur:tt,getPlainText:at}=Lt({segments:d,newParamId:oe,editingParam:Ae,editingIdentified:m,editingAnchor:F,caretOffset:T,placeholderText:pe,isFocused:be,showChipIcons:D,isDropdownOpen:ne,listboxId:ve,activeDescendantId:Bt,autoFocus:j,handleTextChange:Te,handleKeyDown:Be,handleCaretAfterInput:Ot,handleCaretMove:zt,startEditingParam:Fe,replaceEditingRange:Nt,setFocused:Ce});z.current=Ke,Za(()=>{let C=te.current,he=Ke.current;if(!C||!he)return;let it=()=>{let nt=C.firstElementChild;if(!nt)return;let _t=nt.getBoundingClientRect(),qt=he.getBoundingClientRect();_t.top>=qt.bottom-2?C.setAttribute("data-aia-pill-wrapped",""):C.removeAttribute("data-aia-pill-wrapped")};it();let ot=new ResizeObserver(it);return ot.observe(he),()=>ot.disconnect()},[d,S.length,N,Ke]),Qa(ee,()=>({focus:De,blur:tt,reset:Re,setMode:C=>O.current?.setMode(C),skipActivePill:B}),[De,tt,Re,B]);let Le=!!d.length||c.length>0,Ge=Je(()=>{if(!Le)return;let C=at();r(Ya(C,c,t,{identifiedParams:f,isReady:w,customFields:l})),Re()},[Le,c,t,f,w,l,r,Re,at]);ae.current=Ge;let Kt=Je(C=>{C.target?.closest("[data-aia-pill]")||De()},[De]),Gt=x==="inline",Wt=x==="dropdown";return et("div",{ref:V,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":x,"data-options-position":y,"data-animations":k?"on":"off","data-mode":ei(u),children:[ye(Ve,{...Ht,showPills:Wt,productsLayout:P}),et("div",{className:ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Kt,children:[et("div",{className:ge.editorArea,"data-aia-editor":"",children:[ye("div",{...Ft,className:ge.input,"data-aia-input":""}),Gt&&(N||S.length>0)&&ye("span",{ref:te,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ye(Oe,{pills:S,activePillIndex:0,activeSelected:ke,onSelectPill:ie,loading:N})})]}),$===null?null:$===void 0?ye(Ct,{disabled:!Le,onClick:Ge}):ye("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ge.submitSlot,onClick:C=>{Le&&(C.stopPropagation(),Ge())},children:$})]})]})});export{ti as AIAutocomplete,Ve as AIAutocompleteDropdown,Qo as DATE_RANGE_META_END,Zo as DATE_RANGE_META_START,on as PRODUCT_PATH_PREFIX,un as WEEKDAY_LABELS,jo as buildSubmitResult,$o as cellDay,Vo as cellIso,Yo as dateCellMarks,Xo as formatDate,Jo as formatDateRange,en as isoDate,tn as monthLabel,an as optionLabel,nn as parseDate,rn as parseLooseDate,sn as parseLooseDateRange,ln as productFromMatchedItem,dn as productsFromCustomFields,cn as sanitizeOptionIconSvg,pn as selectedRangeFor,Ze as useAIAutocomplete,hn as visibleDateRange,fn as withSkippedParams};
|
|
1877
1914
|
//# sourceMappingURL=index.mjs.map
|