@magicx-eng/ai-autocomplete-react 0.21.3 → 0.23.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 +7 -5
- package/dist/index.js +67 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -26
- 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 Uo,cellDay as jo,cellIso as $o,DATE_RANGE_META_END as Vo,DATE_RANGE_META_START as Qo,dateCellMarks as Zo,formatDate as Yo,formatDateRange as Xo,isoDate as Jo,monthLabel as en,optionLabel as tn,PRODUCT_PATH_PREFIX as an,parseDate as on,parseLooseDate as nn,parseLooseDateRange as rn,productFromMatchedItem as sn,productsFromCustomFields as ln,sanitizeOptionIconSvg as dn,selectedRangeFor as cn,visibleDateRange as pn,WEEKDAY_LABELS as hn,withSkippedParams as un}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as $a,useCallback as Je,useEffect as Mt,useImperativeHandle as Va,useLayoutEffect as Qa,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
|
|
@@ -8,7 +8,14 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.aia-inputWrapper-FLq1b {
|
|
11
|
-
|
|
11
|
+
/* The left inset is a token shared with the dropdown (which insets its
|
|
12
|
+
content by the same amount), so the typed text, the parameter label,
|
|
13
|
+
the option text and the product strip share one left edge. A host that
|
|
14
|
+
pads the field to clear its own leading icon sets --aia-content-inset-left
|
|
15
|
+
and the dropdown follows. Floored at 10px \u2014 the dropdown's sections inset
|
|
16
|
+
their text by 10px and its own padding can't go below zero, so below
|
|
17
|
+
10px the two sides would diverge; flooring both keeps them together. */
|
|
18
|
+
padding: 12px 16px 12px max(10px, var(--aia-content-inset-left, 16px));
|
|
12
19
|
border: 1px solid var(--aia-border, #b0b0b0);
|
|
13
20
|
border-radius: 20px;
|
|
14
21
|
background: var(--aia-surface, #ffffff);
|
|
@@ -220,7 +227,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
220
227
|
opacity: 0;
|
|
221
228
|
}
|
|
222
229
|
}
|
|
223
|
-
`,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 Da,isCalendarFormat as La,SCROLL_ARROW_LABEL as Ma}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as $e,useRef as Ne,useState as Oa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
224
231
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
225
232
|
* Consumer CSS always wins without !important.
|
|
226
233
|
*
|
|
@@ -701,7 +708,15 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
701
708
|
display: flex;
|
|
702
709
|
flex-direction: column;
|
|
703
710
|
box-sizing: border-box;
|
|
704
|
-
padding
|
|
711
|
+
/* The left padding derives from --aia-content-inset-left, the token the
|
|
712
|
+
input wrapper reads for its own left padding. The option text and the
|
|
713
|
+
parameter label sit 10px inside this padding edge (the option's padding;
|
|
714
|
+
the pill bar's list wrapper carries the same 10px \u2014 see appearance.css),
|
|
715
|
+
and the product strip is inset to the same line, so the whole panel's
|
|
716
|
+
content starts exactly under the typed text. max() keeps the padding at
|
|
717
|
+
zero (never negative, which CSS would clamp anyway) for a token under
|
|
718
|
+
10px \u2014 the input wrapper floors the token at 10px to match. */
|
|
719
|
+
padding: 10px 8px 10px max(0px, calc(var(--aia-content-inset-left, 16px) - 10px));
|
|
705
720
|
overflow: hidden;
|
|
706
721
|
container-type: inline-size;
|
|
707
722
|
z-index: 10;
|
|
@@ -770,9 +785,10 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
770
785
|
/* "More below" scroll arrow \u2014 see the core's render/scrollArrow.ts.
|
|
771
786
|
A bare down chevron at the bottom-centre of the option list, shown while
|
|
772
787
|
there is more to scroll to \u2014 no disc, border or shadow around it. It rests
|
|
773
|
-
just above the grid's reserved band
|
|
774
|
-
|
|
775
|
-
|
|
788
|
+
just above the grid's reserved band, or \u2014 when a product strip follows the
|
|
789
|
+
grid \u2014 centred on the strip's "Products" label row, off the last option row
|
|
790
|
+
(--aia-scroll-arrow-bottom is measured and set inline by the controller so
|
|
791
|
+
it tracks the layout). It never travels with the scroll: the controller toggles
|
|
776
792
|
data-aia-visible and the only thing that transitions is opacity \u2014 a slow,
|
|
777
793
|
even second in and the same second out. Its one motion is an idle bob, a few
|
|
778
794
|
pixels up and back over a couple of seconds, running all the time so a fade
|
|
@@ -1129,7 +1145,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1129
1145
|
opacity: 0.8;
|
|
1130
1146
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1131
1147
|
}
|
|
1132
|
-
`,document.head.appendChild(e)}var S={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 Z,jsxs as rt}from"react/jsx-runtime";var Yt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:i,view:n,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:
|
|
1148
|
+
`,document.head.appendChild(e)}var S={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 Z,jsxs as rt}from"react/jsx-runtime";var Yt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:i,view:n,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:g,onNextMonth:f}){let b=jt(new Date),w=Vt({pendingStart:s.rangeStart,highlightedIso:we(e[r]),selected:s.selectedRange});return rt("div",{className:S.datepicker,"data-aia-datepicker":"",children:[rt("div",{className:S.header,children:[Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:g,children:"\u2039"}),Z("span",{className:S.month,"data-aia-date-month":"","aria-live":"polite",children:$t(n)}),Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:f,children:"\u203A"})]}),Z("div",{className:S.weekdays,"aria-hidden":"true",children:Qt.map((u,x)=>Z("span",{className:S.weekday,children:u},Yt[x]))}),Z("div",{className:S.grid,"data-aia-date-grid":"",children:e.map((u,x)=>Z(Xt,{option:u,id:`${i}-option-${x}`,index:x,isHighlighted:x===r&&u.is_tappable,isToday:we(u)===b,isPast:we(u)!=null&&we(u)<b,marks:Ut(we(u),{selectedIso:s.selectedIso,range:w}),onSelect:a,onHighlight:o},we(u)??`pad-${x}`))})]})}function Xt({option:e,id:r,index:i,isHighlighted:n,isToday:s,isPast:a,marks:o,onSelect:g,onHighlight:f}){let[b,w]=Zt(!1),u=qt(e);if(u==null)return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${S.cell} ${S.blank}`});let x=()=>{w(!0),g(e),setTimeout(()=>w(!1),170)},k=[S.cell,S.day,a?S.past:"",n?S.highlighted:"",s?S.today:"",o.inRange?S.inRange:"",o.selected?S.selected:"",b?S.pressed:""].filter(Boolean).join(" ");return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:k,onClick:x,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),x())},onMouseEnter:()=>f(i),children:Z("span",{className:S.number,children:u})})}import{ATTRIBUTION_URL as Jt,buildAttributionUrl as ea,getFooterHint as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as aa,useState as ia}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 {
|
|
1133
1149
|
display: flex;
|
|
1134
1150
|
flex-wrap: wrap;
|
|
1135
1151
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1169,7 +1185,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1169
1185
|
.aia-cluster[data-justify="around"] {
|
|
1170
1186
|
justify-content: space-around;
|
|
1171
1187
|
}
|
|
1172
|
-
`,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:i="start",noWrap:n=!1,inline:s=!1,className:a,children:o,...
|
|
1188
|
+
`,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:i="start",noWrap:n=!1,inline:s=!1,className:a,children:o,...g}){let f=e?{"--aia-cluster-gap":e}:void 0,b={className:a?`aia-cluster ${a}`:"aia-cluster","data-align":r,"data-justify":i,"data-nowrap":n||void 0,"data-inline":s||void 0,style:f,...g};return s?lt("span",{...b,children:o}):lt("div",{...b,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
|
|
1173
1189
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1174
1190
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1175
1191
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1370,7 +1386,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1370
1386
|
align-items: center;
|
|
1371
1387
|
vertical-align: middle;
|
|
1372
1388
|
}
|
|
1373
|
-
`,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var na=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:i,activeSelected:n,rounded:s,loading:a}){return a&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:na.map((o,
|
|
1389
|
+
`,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var na=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:i,activeSelected:n,rounded:s,loading:a}){return a&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:na.map((o,g)=>Me("span",{"data-aia-pill-skeleton":"",className:`${me.pill} ${s?me.rounded:""} ${me.skeleton}`,style:{width:o,opacity:_e[pt(g)]}},`skel-${o}`))}):Me("span",{className:qe.list,"data-aia-pill-list-loading":a?"":void 0,children:e.map((o,g)=>{let f=!!n&&g===r;return Me(ct,{label:o.text,state:f?"selected":pt(g),selected:f,rounded:s,loading:a,onClick:()=>i(g)},`${o.type}-${o.text}`)})})}import{attachProductRowWheel as ra}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as sa,useRef as la}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
|
|
1374
1390
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1375
1391
|
theming one package sees the same result in the other.
|
|
1376
1392
|
|
|
@@ -1384,9 +1400,11 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1384
1400
|
display: flex;
|
|
1385
1401
|
flex-direction: column;
|
|
1386
1402
|
gap: 6px;
|
|
1387
|
-
/*
|
|
1388
|
-
|
|
1389
|
-
|
|
1403
|
+
/* The option text sits 10px inside the dropdown's padding edge (the
|
|
1404
|
+
option's own padding), so the section carries the same 10px and its
|
|
1405
|
+
label lands on the option text's left edge \u2014 which the dropdown in turn
|
|
1406
|
+
places under the typed text (--aia-content-inset-left). */
|
|
1407
|
+
padding: 0 10px;
|
|
1390
1408
|
min-width: 0;
|
|
1391
1409
|
}
|
|
1392
1410
|
|
|
@@ -1414,8 +1432,15 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1414
1432
|
overflow-y: hidden;
|
|
1415
1433
|
overscroll-behavior-x: contain;
|
|
1416
1434
|
padding-bottom: 2px;
|
|
1435
|
+
/* Pull the row out by the card's own 6px padding so the first card's
|
|
1436
|
+
image tile \u2014 not its hover fill \u2014 starts on the label's left edge, the
|
|
1437
|
+
same way the option's highlight fill hangs outside its text. */
|
|
1438
|
+
margin-inline: -6px;
|
|
1417
1439
|
/* Hide the scrollbar chrome across all three engines while leaving the box
|
|
1418
|
-
scrollable by trackpad,
|
|
1440
|
+
scrollable by trackpad, touch and keyboard. A mouse wheel is vertical and
|
|
1441
|
+
would otherwise have no way through a row with no scrollbar to grab, so
|
|
1442
|
+
ProductStrip.tsx binds the vanilla package's attachProductRowWheel on the
|
|
1443
|
+
row to turn a wheel over it into sideways travel. */
|
|
1419
1444
|
scrollbar-width: none;
|
|
1420
1445
|
-ms-overflow-style: none;
|
|
1421
1446
|
}
|
|
@@ -1542,7 +1567,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1542
1567
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1543
1568
|
);
|
|
1544
1569
|
}
|
|
1545
|
-
`,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:i,onFocusChange:n,focusable:s=!0}){
|
|
1570
|
+
`,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:i,onFocusChange:n,focusable:s=!0}){let a=e.length>0,o=la(null);if(sa(()=>{let f=o.current;if(!(!a||!f))return ra(f)},[a]),!a)return null;let g=`${r}-products-label`;return Ue("section",{className:_.section,"data-aia-products":"",role:"group","aria-labelledby":g,children:[fe("div",{className:_.label,id:g,"data-aia-products-label":"",children:"Products"}),fe("div",{ref:o,className:_.row,"data-aia-products-row":"",children:e.map((f,b)=>fe(da,{product:f,id:`${r}-product-${b}`,onSelect:i,onFocusChange:n,focusable:s},f.id))})]})}function da({product:e,id:r,onSelect:i,onFocusChange:n,focusable:s}){let a=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),i(e))};return Ue("a",{id:r,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:a,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),i(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 ya,measureOptionsGrid as ka,needsOptionsGridMeasurement as Ca,OPTIONS_GRID_MOBILE_QUERY as Pa,optionEnterDelayMs as Sa,planOptionsGrid as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ea,useLayoutEffect as Ia,useRef as Ta,useState as vt}from"react";import{optionsGridTemplateColumns as ca}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as pa,useRef as ha}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 {
|
|
1546
1571
|
display: grid;
|
|
1547
1572
|
grid-template-columns: repeat(
|
|
1548
1573
|
auto-fit,
|
|
@@ -1575,9 +1600,19 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1575
1600
|
background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
|
|
1576
1601
|
border-radius: 3px;
|
|
1577
1602
|
}
|
|
1578
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1603
|
+
`,document.head.appendChild(e)}import{jsx as ua}from"react/jsx-runtime";function ut({min:e="16rem",max:r,gap:i,scroll:n=!1,maxHeight:s,scrollResetKey:a,cols:o,template:g,innerRef:f,className:b,children:w,...u}){let x=ha(null);pa(()=>{if(a===void 0)return;let v=x.current;v&&(v.scrollTop=0)},[a]);let k={"--aia-grid-min":e};return r&&(k["--aia-grid-max"]=r),i&&(k["--aia-grid-gap"]=i),s&&(k["--aia-grid-max-height"]=s),o&&(k.gridTemplateColumns=ca(o)),g&&(k.gridTemplateColumns=g),ua("div",{ref:v=>{x.current=v,f?.(v)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":n||void 0,style:k,...u,children:w})}import{OPTION_ENTER_DELAY_VAR as ma,optionLabel as fa,sanitizeOptionIconSvg as ga}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ba,useMemo as va,useRef as wa,useState as mt}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 {
|
|
1579
1604
|
position: relative;
|
|
1580
|
-
|
|
1605
|
+
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1606
|
+
and a transformed box extends its scroll container's scrollable area.
|
|
1607
|
+
Unclipped, the rows rising 16px from below made the option grid overflow
|
|
1608
|
+
for the length of the entrance whenever nothing sat under the grid to
|
|
1609
|
+
absorb it (product strip, optionsPosition="above"), so a scrollbar
|
|
1610
|
+
flashed in and out and the columns shifted sideways by its width. The
|
|
1611
|
+
cell's own children never paint outside it (the streak layer clips
|
|
1612
|
+
itself; press and highlight stay inside the box), so nothing is lost.
|
|
1613
|
+
\`hidden\` first for engines without \`clip\`. */
|
|
1614
|
+
overflow: hidden;
|
|
1615
|
+
overflow: clip;
|
|
1581
1616
|
display: flex;
|
|
1582
1617
|
/* Top-align so single-line and multi-line options in the same row share
|
|
1583
1618
|
the same baseline at the top edge of the cell. */
|
|
@@ -1595,11 +1630,10 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1595
1630
|
padding: 8px 10px;
|
|
1596
1631
|
/* Entrance: fade in while rising into place, each row a beat after the one
|
|
1597
1632
|
before it (--aia-option-enter-delay is set inline per row from the core's
|
|
1598
|
-
optionEnterDelayMs). The
|
|
1599
|
-
the
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
aia-riseIn-etXZT 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
|
|
1633
|
+
optionEnterDelayMs). The fade is here; the rise is on the inner content
|
|
1634
|
+
(see the overflow note above). The durations and distance mirror
|
|
1635
|
+
OPTION_ENTER_* in the core's derive/optionsEntrance.ts \u2014 change both together. */
|
|
1636
|
+
animation: aia-fadeIn-I8u35 150ms ease-out both;
|
|
1603
1637
|
animation-delay: var(--aia-option-enter-delay, 0ms);
|
|
1604
1638
|
}
|
|
1605
1639
|
|
|
@@ -1616,7 +1650,8 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1616
1650
|
}
|
|
1617
1651
|
|
|
1618
1652
|
@media (prefers-reduced-motion: reduce) {
|
|
1619
|
-
.aia-item-d4vpD
|
|
1653
|
+
.aia-item-d4vpD,
|
|
1654
|
+
.aia-content-T-Qba {
|
|
1620
1655
|
animation-duration: 0s;
|
|
1621
1656
|
animation-delay: 0s;
|
|
1622
1657
|
}
|
|
@@ -1625,6 +1660,10 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1625
1660
|
.aia-content-T-Qba {
|
|
1626
1661
|
position: relative;
|
|
1627
1662
|
z-index: 2;
|
|
1663
|
+
/* The entrance rise (the cell above keeps the fade). Inherits the cell's
|
|
1664
|
+
per-row delay through the custom property. */
|
|
1665
|
+
animation: aia-riseIn-etXZT 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
|
|
1666
|
+
animation-delay: var(--aia-option-enter-delay, 0ms);
|
|
1628
1667
|
}
|
|
1629
1668
|
|
|
1630
1669
|
.aia-tappable-70KcX {
|
|
@@ -1766,7 +1805,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1766
1805
|
filter: brightness(0.55);
|
|
1767
1806
|
}
|
|
1768
1807
|
}
|
|
1769
|
-
`,document.head.appendChild(e)}var q={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",
|
|
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 xa}from"react/jsx-runtime";function ft({option:e,isHighlighted:r,onSelect:i,onHighlight:n,id:s,loading:a,showIcon:o=!0,scrollHint:g,enterDelayMs:f=0}){let[b]=mt(f),[w,u]=mt(!1),x=va(()=>o&&e.icon_svg?ga(e.icon_svg):null,[o,e.icon_svg]),k=wa(void 0);ba(()=>()=>clearTimeout(k.current),[]);let v=()=>{a||!e.is_tappable||w||(u(!0),i(e),clearTimeout(k.current),k.current=setTimeout(()=>u(!1),170))},E=[q.item,r&&!a?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,w?q.pressed:"",g?q.scrollHint:""].filter(Boolean).join(" ");return ze("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":x&&e.icon?e.icon:void 0,"aria-selected":r,className:E,style:{[ma]:`${b}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:v,onKeyDown:T=>{!a&&e.is_tappable&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),v())},onMouseEnter:!a&&e.is_tappable?n:void 0,children:xa("span",{className:q.content,children:[x&&ze("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x}}),ze("span",{className:q.text,children:fa(e)}),e.tag&&ze("span",{className:q.tag,children:e.tag})]})})}import{jsx as bt}from"react/jsx-runtime";function Aa(){let[e,r]=vt(ya);return Ea(()=>{if(typeof window>"u"||!window.matchMedia)return;let i=window.matchMedia(Pa),n=()=>r(i.matches);return n(),i.addEventListener("change",n),()=>i.removeEventListener("change",n)},[]),e}function wt({options:e,activeIndex:r,onSelect:i,onHighlight:n,listboxId:s,loading:a,groupKey:o="",optionsPosition:g="below",showIcons:f=!0}){let b=Aa(),w=Ta(null),[u,x]=vt(null);Ia(()=>{let v=w.current,T=v&&!a&&Ca(e.length,b)?ka(v):null;x(T?gt(e.length,b,T.rowWidths,T.gridWidth):null)},[e,b,a]);let k=u??gt(e.length,b,null,null);return bt(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:k.template,maxHeight:k.maxHeight,innerRef:v=>{w.current=v},"data-aia-group":o,children:e.map((v,E)=>bt(ft,{option:v,isHighlighted:E===r,onSelect:i,onHighlight:()=>n(E),id:`${s}-option-${E}`,loading:a,showIcon:f,scrollHint:!a&&k.scrollHintIndices.includes(E),enterDelayMs:a?0:Sa(E,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 {
|
|
1770
1809
|
display: flex;
|
|
1771
1810
|
flex-direction: column;
|
|
1772
1811
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -1781,7 +1820,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1781
1820
|
align-items: end;
|
|
1782
1821
|
}
|
|
1783
1822
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1784
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1823
|
+
`,document.head.appendChild(e)}import{jsx as Ra}from"react/jsx-runtime";function xt({space:e,align:r="stretch",className:i,children:n,...s}){let a=e?{"--aia-stack-space":e}:void 0;return Ra("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":r,style:a,...s,children:n})}import{jsx as K,jsxs as je}from"react/jsx-runtime";var za=[159,119,164],Na=()=>{},yt=()=>{};function Ha(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,n]=Oa(r);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function Ba(e,r){let i=Ne(null);$e(()=>{let n=e.current,s=r.current;if(!n||!s)return;let a=n.querySelector(".aia-grid[data-scroll]");if(i.current&&i.current.grid!==a&&(i.current.controller.destroy(),i.current=null),a&&!i.current){i.current={grid:a,controller:Da({dropdown:n,grid:a,button:s})};return}i.current?.controller.update()}),$e(()=>()=>{i.current?.controller.destroy(),i.current=null},[])}function Ve({suggestions:e,activeIndex:r,onSelect:i,onHighlight:n,isOpen:s,id:a,className:o,pills:g,onPillClick:f,showPills:b=!0,onSkip:w,showSkipButton:u=!0,showOptionIcons:x=!0,skipDisabled:k=!1,activeSelected:v=!1,isLoading:E=!1,isInputEmpty:T=!1,products:R,onProductSelect:O,onProductFocusChange:Y,formatType:z="options",dateView:P=null,selectedDateIso:j=null,selectedDateRange:ne=null,dateRangeStart:X=null,onPreviousMonth:p,onNextMonth:re,optionsPosition:D="below",mode:se}){let J=Ha(se),$=J!==void 0,ee=Ne(null),V=Ne(null);Ba(ee,V);let te=e[0]?.options??[],ae=!!(g&&g.length>0&&f),N=!!(R&&R.length>0),H=s&&(te.length>0||b&&ae||E||N),W={suggestions:e,activeIndex:r,pills:g,showPills:b,showSkipButton:u,showOptionIcons:x,skipDisabled:k,activeSelected:v,isLoading:E,isInputEmpty:T,products:R,formatType:z,dateView:P,selectedDateIso:j,selectedDateRange:ne,dateRangeStart:X},B=Ne(W);H&&(B.current=W);let t=H?W:B.current,c=t.suggestions[0],h=c?.options??[],y=t.activeIndex>=0&&!!h[t.activeIndex]?.is_tappable,l=!!(t.pills&&t.pills.length>0&&f),A=t.showPills&&l,Q=t.showPills&&!l&&t.isLoading,L=A||Q,d=l&&t.showSkipButton&&!t.isInputEmpty&&!!w,le=t.pills?.[0]?.text,be=La(t.formatType)&&t.dateView!=null,de=h.length>0&&!be,ve=h.length>0&&be&&!t.isLoading,ce=t.isLoading&&!de&&!ve,pe=t.products??[];return je("div",{ref:ee,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":D,"data-mode":J,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":pe.length>0?"":void 0,className:`${$?"magicx-aia ":""}${ie.dropdown} ${H?ie.visible:""} ${o??""}`,onMouseDown:M=>M.preventDefault(),children:[je(xt,{space:"8px",children:[(L||d)&&je(Pe,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[L&&K("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:K(Oe,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:f??(()=>{}),rounded:!0,loading:t.isLoading})}),d&&K("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":le?`Skip ${le}`:"Skip",onClick:w,children:"skip"})]}),de&&K(wt,{options:h,activeIndex:t.activeIndex,onSelect:i,onHighlight:n,listboxId:a,loading:t.isLoading,groupKey:c?`${c.type} ${c.text}`:"",optionsPosition:D,showIcons:t.showOptionIcons}),ve&&t.dateView&&K(st,{options:h,activeIndex:t.activeIndex,listboxId:a,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:i,onHighlight:n,onPreviousMonth:p??yt,onNextMonth:re??yt}),ce&&K("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:za.map(M=>K("span",{className:ie.skeletonBar,style:{width:M}},`bar-${M}`))}),K(ht,{products:pe,listboxId:a,onSelect:O??Na,onFocusChange:Y,focusable:H}),K(dt,{isOptionHighlighted:y,isInputEmpty:t.isInputEmpty})]}),K("button",{ref:V,type:"button",tabIndex:-1,className:ie.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ma,"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 Za,ModeController as Ya,setCursorOffset as Xa}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 {
|
|
1785
1824
|
flex-shrink: 0;
|
|
1786
1825
|
width: 32px;
|
|
1787
1826
|
height: 32px;
|
|
@@ -1834,5 +1873,5 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1834
1873
|
);
|
|
1835
1874
|
cursor: default;
|
|
1836
1875
|
}
|
|
1837
|
-
`,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 Na,dateSelectionFor as Ha,identifiedParamLabel as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as Fa}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=(f,v,g)=>{let w=r.current?.[a];return w?w(f,v,g):[]};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 Ka={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:f=2,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showOptionIcons:x,showSkipButton:k,showProducts:b,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]=Fa(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 Na(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:B.overrides,maskCompletedText:s,columns:f,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b,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:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b})},[t,c,B.key,v,g,w,u,b]);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??Ka,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:Ba(he.type),required:!0,options:[]}:null,Te=ke??ve,Be=ke?[ke]:de,Ce=Ha(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:g??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as Ga,renderEditableContent as Wa,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:i=!0,newParamId:n,editingParam:s,editingIdentified:a,editingAnchor:o,caretOffset:f,placeholderText:v,isFocused:g,isDropdownOpen:w,listboxId:u,activeDescendantId:x,autoFocus:k,handleTextChange:b,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=f,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&&Wa({input:t,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:v??"",isFocused:g,showChipIcons:i})},[r,n,s,v,g,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??Ga(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;b(y)},[b]),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=_a()?"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 Za(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ya=qa(function({onSubmit:r,onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:f,additionalContext:v,columns:g,pillPlacement:w="dropdown",mode:u="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:b,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 Va(C,u),()=>{N.current?.destroy(),N.current=null}},[u]);let W=Je(C=>{let ue=H.current?.current;ue&&(ue.focus(),Qa(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:f,additionalContext:v,columns:g,dropdownTrigger:b,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,ja(()=>{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]),Ua(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($a(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":Za(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{Ya as AIAutocomplete,Ve as AIAutocompleteDropdown,_o as DATE_RANGE_META_END,qo as DATE_RANGE_META_START,Yo as PRODUCT_PATH_PREFIX,sn as WEEKDAY_LABELS,Ko as buildSubmitResult,Go as cellDay,Wo as cellIso,Uo as dateCellMarks,jo as formatDate,$o as formatDateRange,Vo as isoDate,Qo as monthLabel,Zo as optionLabel,Xo as parseDate,Jo as parseLooseDate,en as parseLooseDateRange,tn as productFromMatchedItem,an as productsFromCustomFields,on as sanitizeOptionIconSvg,nn as selectedRangeFor,Ze as useAIAutocomplete,rn as visibleDateRange,ln as withSkippedParams};
|
|
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};
|
|
1838
1877
|
//# sourceMappingURL=index.mjs.map
|