@magicx-eng/ai-autocomplete-react 0.21.1 → 0.21.3
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 +0 -3
- package/dist/index.js +116 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -759,10 +759,7 @@ Override on the container (via `className`). The variables are declared with `:w
|
|
|
759
759
|
| `--aia-product-bg` | `transparent` | `transparent` | Product card background. |
|
|
760
760
|
| `--aia-product-bg-active` | `--aia-option-bg` | `--aia-option-bg` | Product card background on hover. |
|
|
761
761
|
| `--aia-product-media-bg` | `--aia-skeleton-bg` | `--aia-skeleton-bg` | Fill behind the product image, and of the placeholder tile when a product has no image. |
|
|
762
|
-
| `--aia-scroll-arrow-bg` | `--aia-surface` | `--aia-surface` | Fill of the "more below" arrow — the round button that fades in at the bottom of the option list while there is more to scroll to, and out while it scrolls. |
|
|
763
762
|
| `--aia-scroll-arrow-color` | `--aia-option-color` | `--aia-option-color` | Chevron color of the arrow (`--aia-scroll-arrow-color-hover` on hover). |
|
|
764
|
-
| `--aia-scroll-arrow-border` | `--aia-dropdown-border` | `--aia-dropdown-border` | Hairline around the arrow. |
|
|
765
|
-
| `--aia-scroll-arrow-shadow` | `0 2px 8px rgba(0,0,0,0.12)` | `0 2px 8px rgba(0,0,0,0.12)` | Elevation of the arrow. |
|
|
766
763
|
| `--aia-placeholder-fade` | `120ms` | `120ms` | Fade-out of the outgoing placeholder phrase when the starting-state placeholder changes (the incoming one types itself in). |
|
|
767
764
|
| `--aia-product-placeholder-image` | storefront pictogram | storefront pictogram | The image drawn on the placeholder tile when a product has no `imageUrl`: a two-tone storefront pictogram, inlined as a data URI. Set it to any `url(...)` to swap the pictogram; it is drawn centered and contained inside the tile, over `--aia-product-media-bg`. |
|
|
768
765
|
| `--aia-product-title-color` | `--aia-option-color-selected` | `--aia-option-color-selected` | Product title text. Follows the option colors by default, so theming the panel moves suggestions and products together. |
|
package/dist/index.js
CHANGED
|
@@ -323,6 +323,49 @@
|
|
|
323
323
|
cursor: auto;
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
/* Inline SVG is outside the reset: \`revert\` would strip an icon's presentation
|
|
327
|
+
attributes (\`stroke\`, \`d\`, \`fill="none"\`) and blank it. A page's
|
|
328
|
+
\`svg { display: block; max-width: 100%; margin: 0 auto; transition: \u2026 }\`
|
|
329
|
+
would therefore still reach every icon, so the box properties a page puts
|
|
330
|
+
on \`svg\` are reverted here by name \u2014 never width, height, fill, the stroke
|
|
331
|
+
family, opacity or transform, which an icon carries as attributes. Size and
|
|
332
|
+
paint are pinned by class where the SDK draws an icon itself (the submit
|
|
333
|
+
arrow, the scroll chevron; option icons are sized by their own class rule).
|
|
334
|
+
The consumer's submit slot keeps its own icon styling. Same (0,0,5) as the
|
|
335
|
+
reset; the second rule is for a \`* { transition }\` reaching the paths. */
|
|
336
|
+
:where([data-aia-input-wrapper] svg, [data-aia-dropdown] svg):not(
|
|
337
|
+
:where([data-aia-submit-slot] *)
|
|
338
|
+
):not(html):not(html):not(html):not(html):not(html) {
|
|
339
|
+
display: revert;
|
|
340
|
+
vertical-align: revert;
|
|
341
|
+
position: revert;
|
|
342
|
+
inset: revert;
|
|
343
|
+
float: revert;
|
|
344
|
+
margin: revert;
|
|
345
|
+
padding: revert;
|
|
346
|
+
border: revert;
|
|
347
|
+
border-radius: revert;
|
|
348
|
+
outline: revert;
|
|
349
|
+
background: revert;
|
|
350
|
+
box-shadow: revert;
|
|
351
|
+
min-width: revert;
|
|
352
|
+
max-width: revert;
|
|
353
|
+
min-height: revert;
|
|
354
|
+
max-height: revert;
|
|
355
|
+
flex: revert;
|
|
356
|
+
transition: revert;
|
|
357
|
+
animation: revert;
|
|
358
|
+
rotate: revert;
|
|
359
|
+
scale: revert;
|
|
360
|
+
translate: revert;
|
|
361
|
+
}
|
|
362
|
+
:where([data-aia-input-wrapper] svg *, [data-aia-dropdown] svg *):not(
|
|
363
|
+
:where([data-aia-submit-slot] *)
|
|
364
|
+
):not(html):not(html):not(html):not(html):not(html) {
|
|
365
|
+
transition: revert;
|
|
366
|
+
animation: revert;
|
|
367
|
+
}
|
|
368
|
+
|
|
326
369
|
/*
|
|
327
370
|
* Primitive color ramp \u2014 single source of truth, mirroring the Figma
|
|
328
371
|
* "Primitives" collection. INTERNAL: theme via the public --aia-* vars below,
|
|
@@ -725,22 +768,24 @@
|
|
|
725
768
|
}
|
|
726
769
|
|
|
727
770
|
/* "More below" scroll arrow \u2014 see the core's render/scrollArrow.ts.
|
|
728
|
-
A
|
|
729
|
-
more to scroll to
|
|
730
|
-
(--aia-scroll-arrow-bottom is measured
|
|
731
|
-
it tracks the grid's bottom edge in
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
771
|
+
A bare down chevron at the bottom-centre of the option list, shown while
|
|
772
|
+
there is more to scroll to \u2014 no disc, border or shadow around it. It rests
|
|
773
|
+
just above the grid's reserved band (--aia-scroll-arrow-bottom is measured
|
|
774
|
+
and set inline by the controller so it tracks the grid's bottom edge in
|
|
775
|
+
every layout). It never travels with the scroll: the controller toggles
|
|
776
|
+
data-aia-visible and the only thing that transitions is opacity \u2014 a slow,
|
|
777
|
+
even second in and the same second out. Its one motion is an idle bob, a few
|
|
778
|
+
pixels up and back over a couple of seconds, running all the time so a fade
|
|
779
|
+
never restarts it mid-stroke. z-index 4 puts it over the option rows and the
|
|
780
|
+
footer (z-index 3), whose opaque fade plate would otherwise bury it.
|
|
781
|
+
Declarations mirror vanilla's .magicx-aia-scroll-arrow and Angular's copy \u2014
|
|
782
|
+
change all three in the same commit. */
|
|
738
783
|
.aia-scrollArrow-uUzV0 {
|
|
739
784
|
position: absolute;
|
|
740
785
|
left: 50%;
|
|
741
786
|
bottom: var(--aia-scroll-arrow-bottom, 8px);
|
|
742
787
|
/* Above the footer (z-index 3): its fade plate is opaque on desktop and
|
|
743
|
-
would otherwise bury the
|
|
788
|
+
would otherwise bury the chevron, which sits half over it by design. */
|
|
744
789
|
z-index: 4;
|
|
745
790
|
display: inline-flex;
|
|
746
791
|
align-items: center;
|
|
@@ -749,22 +794,34 @@
|
|
|
749
794
|
height: 32px;
|
|
750
795
|
margin: 0 0 0 -16px;
|
|
751
796
|
padding: 0;
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
border-radius:
|
|
755
|
-
background:
|
|
797
|
+
/* Just the chevron: the 32px box is the hit target, nothing is drawn on it. */
|
|
798
|
+
border: 0;
|
|
799
|
+
border-radius: 0;
|
|
800
|
+
background: transparent;
|
|
756
801
|
color: var(
|
|
757
802
|
--aia-scroll-arrow-color,
|
|
758
803
|
var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb))
|
|
759
804
|
);
|
|
760
|
-
box-shadow:
|
|
805
|
+
box-shadow: none;
|
|
761
806
|
cursor: pointer;
|
|
762
807
|
pointer-events: none;
|
|
763
|
-
/* Hidden: transparent, in place. Only opacity ever transitions, so the
|
|
764
|
-
cannot travel. One second each way \u2014 SCROLL_ARROW_FADE_MS in
|
|
808
|
+
/* Hidden: transparent, in place. Only opacity ever transitions, so the
|
|
809
|
+
chevron cannot travel. One second each way \u2014 SCROLL_ARROW_FADE_MS in
|
|
765
810
|
scrollArrow.ts documents this number; change both together. */
|
|
766
811
|
opacity: 0;
|
|
767
812
|
transition: opacity 1000ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
813
|
+
/* The idle bob: 3px up and back, eased both ways, always running. */
|
|
814
|
+
animation: aia-magicx-aia-scroll-arrow-bob-z-HXC 2600ms ease-in-out infinite;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
@keyframes aia-magicx-aia-scroll-arrow-bob-z-HXC {
|
|
818
|
+
0%,
|
|
819
|
+
100% {
|
|
820
|
+
transform: translateY(0);
|
|
821
|
+
}
|
|
822
|
+
50% {
|
|
823
|
+
transform: translateY(-3px);
|
|
824
|
+
}
|
|
768
825
|
}
|
|
769
826
|
|
|
770
827
|
.aia-scrollArrow-uUzV0[data-aia-visible] {
|
|
@@ -772,6 +829,19 @@
|
|
|
772
829
|
opacity: 1;
|
|
773
830
|
}
|
|
774
831
|
|
|
832
|
+
/* The chevron's size and paint by class \u2014 a page's \`svg { \u2026 }\` type rule
|
|
833
|
+
would otherwise beat its presentation attributes. */
|
|
834
|
+
.aia-scrollArrow-uUzV0 svg {
|
|
835
|
+
width: 14px;
|
|
836
|
+
height: 14px;
|
|
837
|
+
fill: none;
|
|
838
|
+
stroke: currentColor;
|
|
839
|
+
}
|
|
840
|
+
.aia-scrollArrow-uUzV0 svg path {
|
|
841
|
+
fill: none;
|
|
842
|
+
stroke: currentColor;
|
|
843
|
+
}
|
|
844
|
+
|
|
775
845
|
.aia-scrollArrow-uUzV0:hover {
|
|
776
846
|
color: var(
|
|
777
847
|
--aia-scroll-arrow-color-hover,
|
|
@@ -782,6 +852,8 @@
|
|
|
782
852
|
@media (prefers-reduced-motion: reduce) {
|
|
783
853
|
.aia-scrollArrow-uUzV0,
|
|
784
854
|
.aia-dropdown-yz2KC {
|
|
855
|
+
animation-duration: 0s;
|
|
856
|
+
animation-delay: 0s;
|
|
785
857
|
transition-duration: 0s;
|
|
786
858
|
}
|
|
787
859
|
}
|
|
@@ -894,7 +966,7 @@
|
|
|
894
966
|
opacity: 0.25;
|
|
895
967
|
}
|
|
896
968
|
}
|
|
897
|
-
`,document.head.appendChild(e)}var he={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0",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"};var R=require("@magicx-eng/ai-autocomplete-vanilla"),ut=require("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) ---
|
|
969
|
+
`,document.head.appendChild(e)}var he={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"};var R=require("@magicx-eng/ai-autocomplete-vanilla"),ut=require("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) ---
|
|
898
970
|
|
|
899
971
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
900
972
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1057,7 +1129,7 @@
|
|
|
1057
1129
|
opacity: 0.8;
|
|
1058
1130
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1059
1131
|
}
|
|
1060
|
-
`,document.head.appendChild(e)}var T={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"};var K=require("react/jsx-runtime"),Zt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function
|
|
1132
|
+
`,document.head.appendChild(e)}var T={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"};var K=require("react/jsx-runtime"),Zt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function mt({options:e,activeIndex:i,listboxId:a,view:r,selection:n,onSelect:o,onHighlight:s,onPreviousMonth:g,onNextMonth:w}){let b=(0,R.isoDate)(new Date),x=(0,R.visibleDateRange)({pendingStart:n.rangeStart,highlightedIso:(0,R.cellIso)(e[i]),selected:n.selectedRange});return(0,K.jsxs)("div",{className:T.datepicker,"data-aia-datepicker":"",children:[(0,K.jsxs)("div",{className:T.header,children:[(0,K.jsx)("button",{type:"button",tabIndex:-1,className:T.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:g,children:"\u2039"}),(0,K.jsx)("span",{className:T.month,"data-aia-date-month":"","aria-live":"polite",children:(0,R.monthLabel)(r)}),(0,K.jsx)("button",{type:"button",tabIndex:-1,className:T.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:w,children:"\u203A"})]}),(0,K.jsx)("div",{className:T.weekdays,"aria-hidden":"true",children:R.WEEKDAY_LABELS.map((m,y)=>(0,K.jsx)("span",{className:T.weekday,children:m},Zt[y]))}),(0,K.jsx)("div",{className:T.grid,"data-aia-date-grid":"",children:e.map((m,y)=>(0,K.jsx)(Yt,{option:m,id:`${a}-option-${y}`,index:y,isHighlighted:y===i&&m.is_tappable,isToday:(0,R.cellIso)(m)===b,isPast:(0,R.cellIso)(m)!=null&&(0,R.cellIso)(m)<b,marks:(0,R.dateCellMarks)((0,R.cellIso)(m),{selectedIso:n.selectedIso,range:x}),onSelect:o,onHighlight:s},(0,R.cellIso)(m)??`pad-${y}`))})]})}function Yt({option:e,id:i,index:a,isHighlighted:r,isToday:n,isPast:o,marks:s,onSelect:g,onHighlight:w}){let[b,x]=(0,ut.useState)(!1),m=(0,R.cellDay)(e);if(m==null)return(0,K.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${T.cell} ${T.blank}`});let y=()=>{x(!0),g(e),setTimeout(()=>x(!1),170)},P=[T.cell,T.day,o?T.past:"",r?T.highlighted:"",n?T.today:"",s.inRange?T.inRange:"",s.selected?T.selected:"",b?T.pressed:""].filter(Boolean).join(" ");return(0,K.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":r,"aria-label":e.text,tabIndex:0,className:P,onClick:y,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),y())},onMouseEnter:()=>w(a),children:(0,K.jsx)("span",{className:T.number,children:m})})}var Re=require("@magicx-eng/ai-autocomplete-vanilla"),qe=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1061
1133
|
display: flex;
|
|
1062
1134
|
flex-wrap: wrap;
|
|
1063
1135
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1231,7 +1303,7 @@
|
|
|
1231
1303
|
justify-content: flex-end;
|
|
1232
1304
|
}
|
|
1233
1305
|
}
|
|
1234
|
-
`,document.head.appendChild(e)}var ue={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"};var ne=require("react/jsx-runtime");function
|
|
1306
|
+
`,document.head.appendChild(e)}var ue={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"};var ne=require("react/jsx-runtime");function ft({isOptionHighlighted:e=!1,isInputEmpty:i=!1}){let{key:a,hint:r}=(0,Re.getFooterHint)(e,i),[n,o]=(0,qe.useState)(Re.ATTRIBUTION_URL);return(0,qe.useEffect)(()=>{o((0,Re.buildAttributionUrl)())},[]),(0,ne.jsx)("footer",{className:ue.footer,"data-aia-footer":"",children:(0,ne.jsxs)(He,{justify:"between",noWrap:!0,className:ue.row,children:[(0,ne.jsxs)(He,{gap:"5px",className:ue.hintGroup,children:[(0,ne.jsx)("kbd",{className:ue.key,children:a}),(0,ne.jsx)("span",{className:ue.hint,children:r})]}),(0,ne.jsxs)("a",{className:ue.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,ne.jsx)("span",{className:ue.brand,children:"AI"}),(0,ne.jsx)("span",{className:ue.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,
|
|
1235
1307
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1236
1308
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1237
1309
|
as it was when the outline was dashed. */
|
|
@@ -1470,7 +1542,7 @@
|
|
|
1470
1542
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1471
1543
|
);
|
|
1472
1544
|
}
|
|
1473
|
-
`,document.head.appendChild(e)}var Y={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"};var q=require("react/jsx-runtime");function wt({products:e,listboxId:i,onSelect:a,onFocusChange:r,focusable:n=!0}){if(e.length===0)return null;let o=`${i}-products-label`;return(0,q.jsxs)("section",{className:Y.section,"data-aia-products":"",role:"group","aria-labelledby":o,children:[(0,q.jsx)("div",{className:Y.label,id:o,children:"Products"}),(0,q.jsx)("div",{className:Y.row,"data-aia-products-row":"",children:e.map((s,g)=>(0,q.jsx)(Jt,{product:s,id:`${i}-product-${g}`,onSelect:a,onFocusChange:r,focusable:n},s.id))})]})}function Jt({product:e,id:i,onSelect:a,onFocusChange:r,focusable:n}){let o=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),a(e))};return(0,q.jsxs)("a",{id:i,className:Y.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:o,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),a(e))},onFocus:()=>r?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[(0,q.jsx)("span",{className:Y.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,q.jsx)("img",{className:Y.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,q.jsxs)("span",{className:Y.body,children:[e.vendor?(0,q.jsx)("span",{className:Y.vendor,children:e.vendor}):null,(0,q.jsx)("span",{className:Y.title,children:e.title}),e.price?(0,q.jsx)("span",{className:Y.price,children:e.price}):null]})]})}var U=require("@magicx-eng/ai-autocomplete-vanilla"),
|
|
1545
|
+
`,document.head.appendChild(e)}var Y={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"};var q=require("react/jsx-runtime");function wt({products:e,listboxId:i,onSelect:a,onFocusChange:r,focusable:n=!0}){if(e.length===0)return null;let o=`${i}-products-label`;return(0,q.jsxs)("section",{className:Y.section,"data-aia-products":"",role:"group","aria-labelledby":o,children:[(0,q.jsx)("div",{className:Y.label,id:o,children:"Products"}),(0,q.jsx)("div",{className:Y.row,"data-aia-products-row":"",children:e.map((s,g)=>(0,q.jsx)(Jt,{product:s,id:`${i}-product-${g}`,onSelect:a,onFocusChange:r,focusable:n},s.id))})]})}function Jt({product:e,id:i,onSelect:a,onFocusChange:r,focusable:n}){let o=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),a(e))};return(0,q.jsxs)("a",{id:i,className:Y.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:o,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),a(e))},onFocus:()=>r?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[(0,q.jsx)("span",{className:Y.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,q.jsx)("img",{className:Y.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,q.jsxs)("span",{className:Y.body,children:[e.vendor?(0,q.jsx)("span",{className:Y.vendor,children:e.vendor}):null,(0,q.jsx)("span",{className:Y.title,children:e.title}),e.price?(0,q.jsx)("span",{className:Y.price,children:e.price}):null]})]})}var U=require("@magicx-eng/ai-autocomplete-vanilla"),fe=require("react");var xt=require("@magicx-eng/ai-autocomplete-vanilla"),je=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
1474
1546
|
display: grid;
|
|
1475
1547
|
grid-template-columns: repeat(
|
|
1476
1548
|
auto-fit,
|
|
@@ -1503,7 +1575,7 @@
|
|
|
1503
1575
|
background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
|
|
1504
1576
|
border-radius: 3px;
|
|
1505
1577
|
}
|
|
1506
|
-
`,document.head.appendChild(e)}var kt=require("react/jsx-runtime");function yt({min:e="16rem",max:i,gap:a,scroll:r=!1,maxHeight:n,scrollResetKey:o,cols:s,template:g,innerRef:w,className:b,children:x,...
|
|
1578
|
+
`,document.head.appendChild(e)}var kt=require("react/jsx-runtime");function yt({min:e="16rem",max:i,gap:a,scroll:r=!1,maxHeight:n,scrollResetKey:o,cols:s,template:g,innerRef:w,className:b,children:x,...m}){let y=(0,je.useRef)(null);(0,je.useLayoutEffect)(()=>{if(o===void 0)return;let v=y.current;v&&(v.scrollTop=0)},[o]);let P={"--aia-grid-min":e};return i&&(P["--aia-grid-max"]=i),a&&(P["--aia-grid-gap"]=a),n&&(P["--aia-grid-max-height"]=n),s&&(P.gridTemplateColumns=(0,xt.optionsGridTemplateColumns)(s)),g&&(P.gridTemplateColumns=g),(0,kt.jsx)("div",{ref:v=>{y.current=v,w?.(v)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":r||void 0,style:P,...m,children:x})}var De=require("@magicx-eng/ai-autocomplete-vanilla"),me=require("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 {
|
|
1507
1579
|
position: relative;
|
|
1508
1580
|
overflow: visible;
|
|
1509
1581
|
display: flex;
|
|
@@ -1694,7 +1766,7 @@
|
|
|
1694
1766
|
filter: brightness(0.55);
|
|
1695
1767
|
}
|
|
1696
1768
|
}
|
|
1697
|
-
`,document.head.appendChild(e)}var X={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",riseIn:"aia-riseIn-etXZT",content:"aia-content-T-Qba",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"};var Ie=require("react/jsx-runtime");function Ct({option:e,isHighlighted:i,onSelect:a,onHighlight:r,id:n,loading:o,showIcon:s=!0,scrollHint:g,enterDelayMs:w=0}){let[b]=(0,
|
|
1769
|
+
`,document.head.appendChild(e)}var X={item:"aia-item-d4vpD",fadeIn:"aia-fadeIn-I8u35",riseIn:"aia-riseIn-etXZT",content:"aia-content-T-Qba",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"};var Ie=require("react/jsx-runtime");function Ct({option:e,isHighlighted:i,onSelect:a,onHighlight:r,id:n,loading:o,showIcon:s=!0,scrollHint:g,enterDelayMs:w=0}){let[b]=(0,me.useState)(w),[x,m]=(0,me.useState)(!1),y=(0,me.useMemo)(()=>s&&e.icon_svg?(0,De.sanitizeOptionIconSvg)(e.icon_svg):null,[s,e.icon_svg]),P=(0,me.useRef)(void 0);(0,me.useEffect)(()=>()=>clearTimeout(P.current),[]);let v=()=>{o||!e.is_tappable||x||(m(!0),a(e),clearTimeout(P.current),P.current=setTimeout(()=>m(!1),170))},A=[X.item,i&&!o?X.highlighted:"",e.is_tappable?X.tappable:X.nonTappable,x?X.pressed:"",g?X.scrollHint:""].filter(Boolean).join(" ");return(0,Ie.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"data-aia-icon":y&&e.icon?e.icon:void 0,"aria-selected":i,className:A,style:{[De.OPTION_ENTER_DELAY_VAR]:`${b}ms`},tabIndex:o||!e.is_tappable?-1:0,onClick:v,onKeyDown:M=>{!o&&e.is_tappable&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),v())},onMouseEnter:!o&&e.is_tappable?r:void 0,children:(0,Ie.jsxs)("span",{className:X.content,children:[y&&(0,Ie.jsx)("span",{className:`${X.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:y}}),(0,Ie.jsx)("span",{className:X.text,children:(0,De.optionLabel)(e)}),e.tag&&(0,Ie.jsx)("span",{className:X.tag,children:e.tag})]})})}var nt=require("react/jsx-runtime");function ea(){let[e,i]=(0,fe.useState)(U.isOptionsGridMobileViewport);return(0,fe.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(U.OPTIONS_GRID_MOBILE_QUERY),r=()=>i(a.matches);return r(),a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),e}function Pt({options:e,activeIndex:i,onSelect:a,onHighlight:r,listboxId:n,loading:o,groupKey:s="",optionsPosition:g="below",showIcons:w=!0}){let b=ea(),x=(0,fe.useRef)(null),[m,y]=(0,fe.useState)(null);(0,fe.useLayoutEffect)(()=>{let v=x.current,M=v&&!o&&(0,U.needsOptionsGridMeasurement)(e.length,b)?(0,U.measureOptionsGrid)(v):null;y(M?(0,U.planOptionsGrid)(e.length,b,M.rowWidths,M.gridWidth):null)},[e,b,o]);let P=m??(0,U.planOptionsGrid)(e.length,b,null,null);return(0,nt.jsx)(yt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:P.template,maxHeight:P.maxHeight,innerRef:v=>{x.current=v},"data-aia-group":s,children:e.map((v,A)=>(0,nt.jsx)(Ct,{option:v,isHighlighted:A===i,onSelect:a,onHighlight:()=>r(A),id:`${n}-option-${A}`,loading:o,showIcon:w,scrollHint:!o&&P.scrollHintIndices.includes(A),enterDelayMs:o?0:(0,U.optionEnterDelayMs)(A,P.cols,e.length,g)},`${s}\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 {
|
|
1698
1770
|
display: flex;
|
|
1699
1771
|
flex-direction: column;
|
|
1700
1772
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -1709,7 +1781,7 @@
|
|
|
1709
1781
|
align-items: end;
|
|
1710
1782
|
}
|
|
1711
1783
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1712
|
-
`,document.head.appendChild(e)}var Et=require("react/jsx-runtime");function St({space:e,align:i="stretch",className:a,children:r,...n}){let o=e?{"--aia-stack-space":e}:void 0;return(0,Et.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":i,style:o,...n,children:r})}var O=require("react/jsx-runtime"),ta=[159,119,164],aa=()=>{},It=()=>{};function ia(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,r]=(0,J.useState)(i);if((0,J.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(n.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function oa(e,i){let a=(0,J.useRef)(null);(0,J.useEffect)(()=>{let r=e.current,n=i.current;if(!r||!n)return;let o=r.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==o&&(a.current.controller.destroy(),a.current=null),o&&!a.current){a.current={grid:o,controller:(0,Le.attachScrollArrow)({dropdown:r,grid:o,button:n})};return}a.current?.controller.update()}),(0,J.useEffect)(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function $e({suggestions:e,activeIndex:i,onSelect:a,onHighlight:r,isOpen:n,id:o,className:s,pills:g,onPillClick:w,showPills:b=!0,onSkip:x,showSkipButton:
|
|
1784
|
+
`,document.head.appendChild(e)}var Et=require("react/jsx-runtime");function St({space:e,align:i="stretch",className:a,children:r,...n}){let o=e?{"--aia-stack-space":e}:void 0;return(0,Et.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":i,style:o,...n,children:r})}var O=require("react/jsx-runtime"),ta=[159,119,164],aa=()=>{},It=()=>{};function ia(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,r]=(0,J.useState)(i);if((0,J.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>r(n.matches);return n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function oa(e,i){let a=(0,J.useRef)(null);(0,J.useEffect)(()=>{let r=e.current,n=i.current;if(!r||!n)return;let o=r.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==o&&(a.current.controller.destroy(),a.current=null),o&&!a.current){a.current={grid:o,controller:(0,Le.attachScrollArrow)({dropdown:r,grid:o,button:n})};return}a.current?.controller.update()}),(0,J.useEffect)(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function $e({suggestions:e,activeIndex:i,onSelect:a,onHighlight:r,isOpen:n,id:o,className:s,pills:g,onPillClick:w,showPills:b=!0,onSkip:x,showSkipButton:m=!0,showOptionIcons:y=!0,skipDisabled:P=!1,activeSelected:v=!1,isLoading:A=!1,isInputEmpty:M=!1,products:N,onProductSelect:G,onProductFocusChange:re,formatType:W="options",dateView:I=null,selectedDateIso:te=null,selectedDateRange:ge=null,dateRangeStart:se=null,onPreviousMonth:h,onNextMonth:be,optionsPosition:H="below",mode:ve}){let le=ia(ve),ae=le!==void 0,de=(0,J.useRef)(null),ie=(0,J.useRef)(null);oa(de,ie);let ce=e[0]?.options??[],pe=!!(g&&g.length>0&&w),_=!!(N&&N.length>0),$=n&&(ce.length>0||b&&pe||A||_),Z={suggestions:e,activeIndex:i,pills:g,showPills:b,showSkipButton:m,showOptionIcons:y,skipDisabled:P,activeSelected:v,isLoading:A,isInputEmpty:M,products:N,formatType:W,dateView:I,selectedDateIso:te,selectedDateRange:ge,dateRangeStart:se},V=(0,J.useRef)(Z);$&&(V.current=Z);let t=$?Z:V.current,p=t.suggestions[0],u=p?.options??[],k=t.activeIndex>=0&&!!u[t.activeIndex]?.is_tappable,l=!!(t.pills&&t.pills.length>0&&w),z=t.showPills&&l,oe=t.showPills&&!l&&t.isLoading,B=z||oe,d=l&&t.showSkipButton&&!t.isInputEmpty&&!!x,we=t.pills?.[0]?.text,Te=(0,Le.isCalendarFormat)(t.formatType)&&t.dateView!=null,xe=u.length>0&&!Te,Ae=u.length>0&&Te&&!t.isLoading,ye=t.isLoading&&!xe&&!Ae,ke=t.products??[];return(0,O.jsxs)("div",{ref:de,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":H,"data-mode":le,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":ke.length>0?"":void 0,className:`${ae?"magicx-aia ":""}${he.dropdown} ${$?he.visible:""} ${s??""}`,onMouseDown:F=>F.preventDefault(),children:[(0,O.jsxs)(St,{space:"8px",children:[(B||d)&&(0,O.jsxs)(He,{noWrap:!0,className:he.pillBar,"data-aia-pillbar":"",children:[B&&(0,O.jsx)("span",{className:he.pillScroll,"data-aia-pill-scroll":"",children:(0,O.jsx)(Ue,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:t.isLoading})}),d&&(0,O.jsx)("button",{type:"button",tabIndex:-1,className:he.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":we?`Skip ${we}`:"Skip",onClick:x,children:"skip"})]}),xe&&(0,O.jsx)(Pt,{options:u,activeIndex:t.activeIndex,onSelect:a,onHighlight:r,listboxId:o,loading:t.isLoading,groupKey:p?`${p.type} ${p.text}`:"",optionsPosition:H,showIcons:t.showOptionIcons}),Ae&&t.dateView&&(0,O.jsx)(mt,{options:u,activeIndex:t.activeIndex,listboxId:o,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:a,onHighlight:r,onPreviousMonth:h??It,onNextMonth:be??It}),ye&&(0,O.jsx)("div",{className:he.skeletonBars,"data-aia-skeleton-bars":"",children:ta.map(F=>(0,O.jsx)("span",{className:he.skeletonBar,style:{width:F}},`bar-${F}`))}),(0,O.jsx)(wt,{products:ke,listboxId:o,onSelect:G??aa,onFocusChange:re,focusable:$}),(0,O.jsx)(ft,{isOptionHighlighted:k,isInputEmpty:t.isInputEmpty})]}),(0,O.jsx)("button",{ref:ie,type:"button",tabIndex:-1,className:he.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Le.SCROLL_ARROW_LABEL,"aria-hidden":"true",children:(0,O.jsx)("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:(0,O.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Oe=require("@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 {
|
|
1713
1785
|
flex-shrink: 0;
|
|
1714
1786
|
width: 32px;
|
|
1715
1787
|
height: 32px;
|
|
@@ -1725,6 +1797,24 @@
|
|
|
1725
1797
|
transition: opacity 0.2s ease;
|
|
1726
1798
|
}
|
|
1727
1799
|
|
|
1800
|
+
/* Size and paint by class as well as by attribute: a presentation attribute
|
|
1801
|
+
has no specificity, so a page's \`svg { width: 100%; fill: currentColor }\`
|
|
1802
|
+
would otherwise resize the arrow and fill it solid \u2014 the consumer-isolation
|
|
1803
|
+
reset leaves inline SVG alone. A class rule outranks any type selector. */
|
|
1804
|
+
.aia-submitButton-otz7H svg {
|
|
1805
|
+
width: 18px;
|
|
1806
|
+
height: 18px;
|
|
1807
|
+
fill: none;
|
|
1808
|
+
/* The root draws nothing and the path pins its own stroke, but a page's
|
|
1809
|
+
\`svg { stroke: \u2026 }\` would otherwise still land here; say none, as the
|
|
1810
|
+
markup does. */
|
|
1811
|
+
stroke: none;
|
|
1812
|
+
}
|
|
1813
|
+
.aia-submitButton-otz7H svg path {
|
|
1814
|
+
fill: none;
|
|
1815
|
+
stroke: currentColor;
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1728
1818
|
.aia-submitButton-otz7H:hover {
|
|
1729
1819
|
opacity: 0.85;
|
|
1730
1820
|
}
|
|
@@ -1744,5 +1834,5 @@
|
|
|
1744
1834
|
);
|
|
1745
1835
|
cursor: default;
|
|
1746
1836
|
}
|
|
1747
|
-
`,document.head.appendChild(e)}var Tt={submitButton:"aia-submitButton-otz7H"};var Ve=require("react/jsx-runtime");function At({disabled:e,onClick:i}){return(0,Ve.jsx)("button",{type:"button","data-aia-submit":"",className:Tt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":"Submit",children:(0,Ve.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Ve.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Me=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react");var rt=require("react");function Rt(e){let i=(0,rt.useRef)(e);i.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=(0,rt.useRef)({key:"",overrides:void 0});if(r.current.key!==a){let n={};for(let o of Object.keys(e??{})){let s=(g,w,b)=>{let x=i.current?.[o];return x?x(g,w,b):[]};n[o]=s}r.current={key:a,overrides:e?n:void 0}}return{overrides:r.current.overrides,key:a}}var st=require("react");function Dt(e){let i=(0,st.useRef)(e);i.current=e;let a=(0,st.useRef)(null);a.current===null&&(a.current={fetch:(n,o)=>{let s=i.current;return s?s.fetch(n,o):Promise.reject(new Error("products config removed"))},transform:n=>i.current?.transform(n)??[],get limit(){return i.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var na={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 Qe({onSubmit:e,onResult:i,onError:a,optionOverrides:r,maskCompletedText:n,apiConfig:o,additionalContext:s,columns:g=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:f,showOptionIcons:y,showSkipButton:P,showProducts:v,onFocus:A,onBlur:M,value:N,completedParams:G,onChange:re,onParamsChange:W,products:I,onProductSelect:te,source:ge,setCursor:se}){let h=(0,S.useRef)(null),[be,H]=(0,S.useState)(null),ve=(0,S.useRef)(e);ve.current=e;let le=(0,S.useRef)(i);le.current=i;let ae=(0,S.useRef)(a);ae.current=a;let de=(0,S.useRef)(re);de.current=re;let ie=(0,S.useRef)(W);ie.current=W;let ce=(0,S.useRef)(A);ce.current=A;let pe=(0,S.useRef)(M);pe.current=M;let _=(0,S.useRef)(se);_.current=se;let $=(0,S.useRef)(te);$.current=te;let Z=Dt(I),V=Rt(r);(0,S.useEffect)(()=>{if(typeof document>"u")return;let m=new Me.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:s,optionOverrides:V.overrides,maskCompletedText:n,columns:g,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:f,showProducts:v,source:ge,value:N,completedParams:G,onSubmit:(...L)=>ve.current?.(...L),onResult:(...L)=>le.current?.(...L),onError:(...L)=>ae.current?.(...L),onChange:(...L)=>de.current?.(...L),onParamsChange:(...L)=>ie.current?.(...L),onFocus:()=>ce.current?.(),onBlur:()=>pe.current?.(),onProductSelect:L=>$.current?.(L),setCursor:L=>_.current?.(L),products:Z.config});h.current=m,H(m.getState());let Q=m.subscribe(L=>H(L));return()=>{Q(),m.destroy(),h.current===m&&(h.current=null)}},[]),(0,S.useEffect)(()=>{N!==void 0&&h.current?.setValue(N)},[N]),(0,S.useEffect)(()=>{G!==void 0&&h.current?.setCompletedParams(G)},[G]);let t=JSON.stringify(o??null),p;try{p=JSON.stringify(s??null)}catch{p="[unstringifiable]"}(0,S.useEffect)(()=>{h.current?.update({apiConfig:o,additionalContext:s,optionOverrides:V.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:f,showProducts:v})},[t,p,V.key,w,b,x,f,v]);let u=(0,S.useRef)(!1);(0,S.useEffect)(()=>{if(!u.current){u.current=!0;return}h.current?.update({products:Z.config})},[Z.enabled]);let k=(0,S.useRef)(null);k.current===null&&(k.current={handleTextChange:m=>h.current?.handleTextChange(m),handleKeyDown:m=>{let Q="nativeEvent"in m?m.nativeEvent:m;h.current?.handleKeyDown(Q)},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=k.current,z=(0,S.useCallback)(m=>{let Q=m.target.value,Xe=Q.length>0&&!m.nativeEvent?.isComposing&&Q[0]!==Q[0].toUpperCase()?Q[0].toUpperCase()+Q.slice(1):Q;h.current?.handleTextChange(Xe)},[]),oe=(0,S.useCallback)(m=>{h.current?.handleKeyDown(m.nativeEvent)},[]),B=h.current,d=be??na,we=N!==void 0?N:d.text,Te=G!==void 0?G:d.completedParams,xe=d.actionableSuggestions,Ae=xe[0],ye=B?.listboxId??"",ke=d.activeDropdownIndex>=0&&B?`${ye}-option-${d.activeDropdownIndex}`:void 0,F=d.editingParam,Ce=d.editingIdentified,ze=F?{type:F.suggestionType,text:F.suggestionPlaceholder,required:!0,options:F.options}:Ce?{type:Ce.type,text:(0,Me.identifiedParamLabel)(Ce.type),required:!0,options:[]}:null,Fe=ze??Ae,Ye=ze?[ze]:xe,Ne=(0,Me.dateSelectionFor)(d),Ke=!B||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:Te,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:xe,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:Ke,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ye,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:F,editingIdentified:Ce,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:we,placeholder:d.placeholderText||void 0,onChange:z,onKeyDown:oe,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ke,"aria-autocomplete":"list","aria-controls":ye},reset:l.reset,dropdownProps:{suggestions:Fe?[{...Fe,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ye,pills:Ye,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(P??!0)&&!F&&!Ce,showOptionIcons:y??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ke,isInputEmpty:we.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ne.selectedIso,selectedDateRange:Ne.selectedRange,dateRangeStart:Ne.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:b??"below"}}}var j=require("@magicx-eng/ai-autocomplete-vanilla"),C=require("react"),Ze;function ra(){if(Ze!==void 0)return Ze;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ze=e.contentEditable==="plaintext-only",Ze}function Lt(e){let{segments:i,showChipIcons:a=!0,newParamId:r,editingParam:n,editingIdentified:o,editingAnchor:s,caretOffset:g,placeholderText:w,isFocused:b,isDropdownOpen:x,listboxId:f,activeDescendantId:y,autoFocus:P,handleTextChange:v,handleKeyDown:A,handleCaretAfterInput:M,handleCaretMove:N,startEditingParam:G,replaceEditingRange:re,setFocused:W}=e,I=(0,C.useRef)(null),te=(0,C.useRef)(!1),ge=(0,C.useRef)(""),se=(0,C.useRef)(""),h=(0,C.useRef)(null),be=(0,C.useRef)(0);h.current=g,(0,C.useEffect)(()=>{if(!P)return;let t=I.current;if(!t)return;document.activeElement===t?W(!0):t.focus();let p=t.ownerDocument??document,u=p.getSelection(),k=u&&u.rangeCount>0&&t.contains(u.anchorNode);if(u&&!k){let l=p.createRange();l.selectNodeContents(t),l.collapse(!0),u.removeAllRanges(),u.addRange(l)}},[P,W]),(0,C.useEffect)(()=>{let t=I.current;if(!t)return;let p=t.ownerDocument??document,u=()=>{let k=p.getSelection();if(!k||k.rangeCount===0||!k.anchorNode||!t.contains(k.anchorNode))return;let l=k.anchorNode,z=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,B=(k.isCollapsed?z?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=n?.id??o?.id??null;if(B&&B!==d){G(B);return}performance.now()-be.current<50||N((0,j.getCursorOffset)(t))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[n,o,G,N]),(0,C.useLayoutEffect)(()=>{let t=I.current;t&&(0,j.renderEditableContent)({input:t,segments:i,newParamId:r,editingParamId:n?.id??null,placeholderText:w??"",isFocused:b,showChipIcons:a})},[i,r,n,w,b,a]),(0,C.useLayoutEffect)(()=>{let t=ge.current,p=r??"";if(ge.current=p,!p||p===t)return;let u=I.current;if(!u)return;u.focus();let k=h.current??(0,j.plainTextLength)(u);(0,j.setCursorOffset)(u,k)},[r]),(0,C.useLayoutEffect)(()=>{let t=se.current,p=n?.id??"";if(se.current=p,!p||p===t||s==null)return;let u=I.current;u&&(0,j.setCursorOffset)(u,s)},[n,s]);let H=(0,C.useCallback)(()=>{if(te.current)return;let t=I.current;if(!t)return;let p=(0,j.extractPlainText)(t),k=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;v(k)},[v]),ve=(0,C.useCallback)(()=>{be.current=performance.now(),H();let t=I.current;t&&M((0,j.getCursorOffset)(t))},[H,M]);(0,C.useEffect)(()=>{let t=I.current;if(!t)return;let p=u=>{let k=u,l=k.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){u.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let z=l.startsWith("delete")?"":k.data??"";re(z)&&u.preventDefault()}};return t.addEventListener("beforeinput",p),()=>t.removeEventListener("beforeinput",p)},[re]);let le=(0,C.useCallback)(()=>{te.current=!0},[]),ae=(0,C.useCallback)(()=>{te.current=!1,H()},[H]),de=(0,C.useCallback)(t=>{t.preventDefault();let p=I.current;if(!p)return;let u=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let k=p.ownerDocument??document,l=k.getSelection();if(!l||l.rangeCount===0)return;let z=l.getRangeAt(0);if(!p.contains(z.startContainer))return;z.deleteContents();let oe=k.createTextNode(u);z.insertNode(oe),z.setStartAfter(oe),z.collapse(!0),l.removeAllRanges(),l.addRange(z),H()},[H]),ie=(0,C.useCallback)(t=>A(t),[A]),ce=(0,C.useCallback)(()=>W(!0),[W]),pe=(0,C.useCallback)(()=>W(!1),[W]),_=(0,C.useCallback)(()=>I.current?.focus(),[]),$=(0,C.useCallback)(()=>I.current?.blur(),[]),Z=(0,C.useCallback)(()=>{let t=I.current;return t?(0,j.extractPlainText)(t):""},[]),V=ra()?"plaintext-only":"true";return{inputRef:I,editorProps:{ref:I,contentEditable:V,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":f,"aria-expanded":x,"aria-activedescendant":y,spellCheck:!0,enterKeyHint:"send",onInput:ve,onKeyDown:ie,onCompositionStart:le,onCompositionEnd:ae,onPaste:de,onFocus:ce,onBlur:pe},getPlainText:Z,focus:_,blur:$}}var ee=require("react/jsx-runtime");function sa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mt=(0,D.forwardRef)(function({onSubmit:i,onResult:a,onError:r,optionOverrides:n,maskCompletedText:o,className:s,apiConfig:g,additionalContext:w,columns:b,pillPlacement:x="dropdown",mode:f="auto",optionsPosition:y="below",animations:P=!0,dropdownTrigger:v,closeDropdownOnBlur:A,showNonTappableOptions:M,showOptionIcons:N=!0,showChipIcons:G=!0,showSkipButton:re,showProducts:W,autoFocus:I=!0,onFocus:te,onBlur:ge,value:se,completedParams:h,onChange:be,onParamsChange:H,products:ve,onProductSelect:le,submitButton:ae},de){let ie=(0,D.useRef)(null),ce=(0,D.useRef)(null),pe=(0,D.useRef)(()=>{}),_=(0,D.useRef)(null),$=(0,D.useRef)(null);(0,D.useEffect)(()=>{let E=ie.current;if(E)return _.current?_.current.setMode(f):_.current=new Oe.ModeController(E,f),()=>{_.current?.destroy(),_.current=null}},[f]);let Z=(0,D.useCallback)(E=>{let Pe=$.current?.current;Pe&&(Pe.focus(),(0,Oe.setCursorOffset)(Pe,E))},[]),{completedParams:V,skippedParams:t,identifiedParams:p,isReady:u,customFields:k,suggestionPills:l,setActivePill:z,skipActivePill:oe,segments:B,newParamId:d,clearNewParamId:we,placeholderText:Te,isFocused:xe,isDropdownOpen:Ae,isActivePillSelected:ye,isLoading:ke,activeIndex:F,listboxId:Ce,handleTextChange:ze,handleKeyDown:Fe,setFocused:Ye,editingParam:Ne,editingIdentified:Ke,editingAnchor:m,caretOffset:Q,startEditingParam:L,handleCaretAfterInput:Xe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Ge}=Qe({onSubmit:E=>pe.current(E),onResult:a,onError:r,optionOverrides:n,maskCompletedText:o,apiConfig:g,additionalContext:w,columns:b,dropdownTrigger:v,optionsPosition:y,closeDropdownOnBlur:A,showNonTappableOptions:M,showOptionIcons:N,showSkipButton:re,showProducts:W,onFocus:te,onBlur:ge,value:se,completedParams:h,onChange:be,onParamsChange:H,products:ve,onProductSelect:le,source:"full-sdk",setCursor:Z});(0,D.useEffect)(()=>{if(!d)return;let E=window.setTimeout(()=>we(),650);return()=>window.clearTimeout(E)},[d,we]);let Ht=F>=0?`${Ce}-option-${F}`:void 0,{inputRef:Je,editorProps:Bt,focus:We,blur:lt,getPlainText:dt}=Lt({segments:B,newParamId:d,editingParam:Ne,editingIdentified:Ke,editingAnchor:m,caretOffset:Q,placeholderText:Te,isFocused:xe,showChipIcons:G,isDropdownOpen:Ae,listboxId:Ce,activeDescendantId:Ht,autoFocus:I,handleTextChange:ze,handleKeyDown:Fe,handleCaretAfterInput:Xe,handleCaretMove:Ot,startEditingParam:L,replaceEditingRange:zt,setFocused:Ye});$.current=Je,(0,D.useLayoutEffect)(()=>{let E=ce.current,Pe=Je.current;if(!E||!Pe)return;let ct=()=>{let ht=E.firstElementChild;if(!ht)return;let Wt=ht.getBoundingClientRect(),_t=Pe.getBoundingClientRect();Wt.top>=_t.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};ct();let pt=new ResizeObserver(ct);return pt.observe(Pe),()=>pt.disconnect()},[B,l.length,ke,Je]),(0,D.useImperativeHandle)(de,()=>({focus:We,blur:lt,reset:Ge,setMode:E=>_.current?.setMode(E),skipActivePill:oe}),[We,lt,Ge,oe]);let _e=!!B.length||V.length>0,et=(0,D.useCallback)(()=>{if(!_e)return;let E=dt();i((0,Oe.buildSubmitResult)(E,V,t,{identifiedParams:p,isReady:u,customFields:k})),Ge()},[_e,V,t,p,u,k,i,Ge,dt]);pe.current=et;let Ft=(0,D.useCallback)(E=>{E.target?.closest("[data-aia-pill]")||We()},[We]),Kt=x==="inline",Gt=x==="dropdown";return(0,ee.jsxs)("div",{ref:ie,className:`magicx-aia ${Ee.container} ${s??""}`,"data-pill-placement":x,"data-options-position":y,"data-animations":P?"on":"off","data-mode":sa(f),children:[(0,ee.jsx)($e,{...Nt,showPills:Gt}),(0,ee.jsxs)("div",{className:Ee.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[(0,ee.jsxs)("div",{className:Ee.editorArea,"data-aia-editor":"",children:[(0,ee.jsx)("div",{...Bt,className:Ee.input,"data-aia-input":""}),Kt&&(ke||l.length>0)&&(0,ee.jsx)("span",{ref:ce,className:Ee.pillListContainer,"data-aia-pill-list-container":"",children:(0,ee.jsx)(Ue,{pills:l,activePillIndex:0,activeSelected:ye,onSelectPill:z,loading:ke})})]}),ae===null?null:ae===void 0?(0,ee.jsx)(At,{disabled:!_e,onClick:et}):(0,ee.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ee.submitSlot,onClick:E=>{_e&&(E.stopPropagation(),et())},children:ae})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,isoDate,monthLabel,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
1837
|
+
`,document.head.appendChild(e)}var Tt={submitButton:"aia-submitButton-otz7H"};var Ve=require("react/jsx-runtime");function At({disabled:e,onClick:i}){return(0,Ve.jsx)("button",{type:"button","data-aia-submit":"",className:Tt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":"Submit",children:(0,Ve.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Ve.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Me=require("@magicx-eng/ai-autocomplete-vanilla"),S=require("react");var rt=require("react");function Rt(e){let i=(0,rt.useRef)(e);i.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=(0,rt.useRef)({key:"",overrides:void 0});if(r.current.key!==a){let n={};for(let o of Object.keys(e??{})){let s=(g,w,b)=>{let x=i.current?.[o];return x?x(g,w,b):[]};n[o]=s}r.current={key:a,overrides:e?n:void 0}}return{overrides:r.current.overrides,key:a}}var st=require("react");function Dt(e){let i=(0,st.useRef)(e);i.current=e;let a=(0,st.useRef)(null);a.current===null&&(a.current={fetch:(n,o)=>{let s=i.current;return s?s.fetch(n,o):Promise.reject(new Error("products config removed"))},transform:n=>i.current?.transform(n)??[],get limit(){return i.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var na={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 Qe({onSubmit:e,onResult:i,onError:a,optionOverrides:r,maskCompletedText:n,apiConfig:o,additionalContext:s,columns:g=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:m,showOptionIcons:y,showSkipButton:P,showProducts:v,onFocus:A,onBlur:M,value:N,completedParams:G,onChange:re,onParamsChange:W,products:I,onProductSelect:te,source:ge,setCursor:se}){let h=(0,S.useRef)(null),[be,H]=(0,S.useState)(null),ve=(0,S.useRef)(e);ve.current=e;let le=(0,S.useRef)(i);le.current=i;let ae=(0,S.useRef)(a);ae.current=a;let de=(0,S.useRef)(re);de.current=re;let ie=(0,S.useRef)(W);ie.current=W;let ce=(0,S.useRef)(A);ce.current=A;let pe=(0,S.useRef)(M);pe.current=M;let _=(0,S.useRef)(se);_.current=se;let $=(0,S.useRef)(te);$.current=te;let Z=Dt(I),V=Rt(r);(0,S.useEffect)(()=>{if(typeof document>"u")return;let f=new Me.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:s,optionOverrides:V.overrides,maskCompletedText:n,columns:g,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:m,showProducts:v,source:ge,value:N,completedParams:G,onSubmit:(...L)=>ve.current?.(...L),onResult:(...L)=>le.current?.(...L),onError:(...L)=>ae.current?.(...L),onChange:(...L)=>de.current?.(...L),onParamsChange:(...L)=>ie.current?.(...L),onFocus:()=>ce.current?.(),onBlur:()=>pe.current?.(),onProductSelect:L=>$.current?.(L),setCursor:L=>_.current?.(L),products:Z.config});h.current=f,H(f.getState());let Q=f.subscribe(L=>H(L));return()=>{Q(),f.destroy(),h.current===f&&(h.current=null)}},[]),(0,S.useEffect)(()=>{N!==void 0&&h.current?.setValue(N)},[N]),(0,S.useEffect)(()=>{G!==void 0&&h.current?.setCompletedParams(G)},[G]);let t=JSON.stringify(o??null),p;try{p=JSON.stringify(s??null)}catch{p="[unstringifiable]"}(0,S.useEffect)(()=>{h.current?.update({apiConfig:o,additionalContext:s,optionOverrides:V.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:x,showNonTappableOptions:m,showProducts:v})},[t,p,V.key,w,b,x,m,v]);let u=(0,S.useRef)(!1);(0,S.useEffect)(()=>{if(!u.current){u.current=!0;return}h.current?.update({products:Z.config})},[Z.enabled]);let k=(0,S.useRef)(null);k.current===null&&(k.current={handleTextChange:f=>h.current?.handleTextChange(f),handleKeyDown:f=>{let Q="nativeEvent"in f?f.nativeEvent:f;h.current?.handleKeyDown(Q)},setFocused:f=>h.current?.setFocused(f),startEditingParam:f=>h.current?.startEditingParam(f),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:f=>h.current?.handleCaretAfterInput(f),handleCaretMove:f=>h.current?.handleCaretMove(f),replaceEditingRange:f=>h.current?.replaceEditingRange(f)??!1,setActivePill:f=>h.current?.setActivePill(f),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:f=>h.current?.selectOption(f),selectProduct:f=>h.current?.selectProduct(f),setActiveDropdownIndex:f=>h.current?.setActiveDropdownIndex(f),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let l=k.current,z=(0,S.useCallback)(f=>{let Q=f.target.value,Xe=Q.length>0&&!f.nativeEvent?.isComposing&&Q[0]!==Q[0].toUpperCase()?Q[0].toUpperCase()+Q.slice(1):Q;h.current?.handleTextChange(Xe)},[]),oe=(0,S.useCallback)(f=>{h.current?.handleKeyDown(f.nativeEvent)},[]),B=h.current,d=be??na,we=N!==void 0?N:d.text,Te=G!==void 0?G:d.completedParams,xe=d.actionableSuggestions,Ae=xe[0],ye=B?.listboxId??"",ke=d.activeDropdownIndex>=0&&B?`${ye}-option-${d.activeDropdownIndex}`:void 0,F=d.editingParam,Ce=d.editingIdentified,ze=F?{type:F.suggestionType,text:F.suggestionPlaceholder,required:!0,options:F.options}:Ce?{type:Ce.type,text:(0,Me.identifiedParamLabel)(Ce.type),required:!0,options:[]}:null,Fe=ze??Ae,Ye=ze?[ze]:xe,Ne=(0,Me.dateSelectionFor)(d),Ke=!B||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:Te,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:xe,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:Ke,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ye,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:F,editingIdentified:Ce,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:we,placeholder:d.placeholderText||void 0,onChange:z,onKeyDown:oe,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ke,"aria-autocomplete":"list","aria-controls":ye},reset:l.reset,dropdownProps:{suggestions:Fe?[{...Fe,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ye,pills:Ye,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(P??!0)&&!F&&!Ce,showOptionIcons:y??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ke,isInputEmpty:we.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ne.selectedIso,selectedDateRange:Ne.selectedRange,dateRangeStart:Ne.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:b??"below"}}}var j=require("@magicx-eng/ai-autocomplete-vanilla"),C=require("react"),Ze;function ra(){if(Ze!==void 0)return Ze;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ze=e.contentEditable==="plaintext-only",Ze}function Lt(e){let{segments:i,showChipIcons:a=!0,newParamId:r,editingParam:n,editingIdentified:o,editingAnchor:s,caretOffset:g,placeholderText:w,isFocused:b,isDropdownOpen:x,listboxId:m,activeDescendantId:y,autoFocus:P,handleTextChange:v,handleKeyDown:A,handleCaretAfterInput:M,handleCaretMove:N,startEditingParam:G,replaceEditingRange:re,setFocused:W}=e,I=(0,C.useRef)(null),te=(0,C.useRef)(!1),ge=(0,C.useRef)(""),se=(0,C.useRef)(""),h=(0,C.useRef)(null),be=(0,C.useRef)(0);h.current=g,(0,C.useEffect)(()=>{if(!P)return;let t=I.current;if(!t)return;document.activeElement===t?W(!0):t.focus();let p=t.ownerDocument??document,u=p.getSelection(),k=u&&u.rangeCount>0&&t.contains(u.anchorNode);if(u&&!k){let l=p.createRange();l.selectNodeContents(t),l.collapse(!0),u.removeAllRanges(),u.addRange(l)}},[P,W]),(0,C.useEffect)(()=>{let t=I.current;if(!t)return;let p=t.ownerDocument??document,u=()=>{let k=p.getSelection();if(!k||k.rangeCount===0||!k.anchorNode||!t.contains(k.anchorNode))return;let l=k.anchorNode,z=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,B=(k.isCollapsed?z?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=n?.id??o?.id??null;if(B&&B!==d){G(B);return}performance.now()-be.current<50||N((0,j.getCursorOffset)(t))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[n,o,G,N]),(0,C.useLayoutEffect)(()=>{let t=I.current;t&&(0,j.renderEditableContent)({input:t,segments:i,newParamId:r,editingParamId:n?.id??null,placeholderText:w??"",isFocused:b,showChipIcons:a})},[i,r,n,w,b,a]),(0,C.useLayoutEffect)(()=>{let t=ge.current,p=r??"";if(ge.current=p,!p||p===t)return;let u=I.current;if(!u)return;u.focus();let k=h.current??(0,j.plainTextLength)(u);(0,j.setCursorOffset)(u,k)},[r]),(0,C.useLayoutEffect)(()=>{let t=se.current,p=n?.id??"";if(se.current=p,!p||p===t||s==null)return;let u=I.current;u&&(0,j.setCursorOffset)(u,s)},[n,s]);let H=(0,C.useCallback)(()=>{if(te.current)return;let t=I.current;if(!t)return;let p=(0,j.extractPlainText)(t),k=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;v(k)},[v]),ve=(0,C.useCallback)(()=>{be.current=performance.now(),H();let t=I.current;t&&M((0,j.getCursorOffset)(t))},[H,M]);(0,C.useEffect)(()=>{let t=I.current;if(!t)return;let p=u=>{let k=u,l=k.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){u.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let z=l.startsWith("delete")?"":k.data??"";re(z)&&u.preventDefault()}};return t.addEventListener("beforeinput",p),()=>t.removeEventListener("beforeinput",p)},[re]);let le=(0,C.useCallback)(()=>{te.current=!0},[]),ae=(0,C.useCallback)(()=>{te.current=!1,H()},[H]),de=(0,C.useCallback)(t=>{t.preventDefault();let p=I.current;if(!p)return;let u=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let k=p.ownerDocument??document,l=k.getSelection();if(!l||l.rangeCount===0)return;let z=l.getRangeAt(0);if(!p.contains(z.startContainer))return;z.deleteContents();let oe=k.createTextNode(u);z.insertNode(oe),z.setStartAfter(oe),z.collapse(!0),l.removeAllRanges(),l.addRange(z),H()},[H]),ie=(0,C.useCallback)(t=>A(t),[A]),ce=(0,C.useCallback)(()=>W(!0),[W]),pe=(0,C.useCallback)(()=>W(!1),[W]),_=(0,C.useCallback)(()=>I.current?.focus(),[]),$=(0,C.useCallback)(()=>I.current?.blur(),[]),Z=(0,C.useCallback)(()=>{let t=I.current;return t?(0,j.extractPlainText)(t):""},[]),V=ra()?"plaintext-only":"true";return{inputRef:I,editorProps:{ref:I,contentEditable:V,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":x,"aria-activedescendant":y,spellCheck:!0,enterKeyHint:"send",onInput:ve,onKeyDown:ie,onCompositionStart:le,onCompositionEnd:ae,onPaste:de,onFocus:ce,onBlur:pe},getPlainText:Z,focus:_,blur:$}}var ee=require("react/jsx-runtime");function sa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mt=(0,D.forwardRef)(function({onSubmit:i,onResult:a,onError:r,optionOverrides:n,maskCompletedText:o,className:s,apiConfig:g,additionalContext:w,columns:b,pillPlacement:x="dropdown",mode:m="auto",optionsPosition:y="below",animations:P=!0,dropdownTrigger:v,closeDropdownOnBlur:A,showNonTappableOptions:M,showOptionIcons:N=!0,showChipIcons:G=!0,showSkipButton:re,showProducts:W,autoFocus:I=!0,onFocus:te,onBlur:ge,value:se,completedParams:h,onChange:be,onParamsChange:H,products:ve,onProductSelect:le,submitButton:ae},de){let ie=(0,D.useRef)(null),ce=(0,D.useRef)(null),pe=(0,D.useRef)(()=>{}),_=(0,D.useRef)(null),$=(0,D.useRef)(null);(0,D.useEffect)(()=>{let E=ie.current;if(E)return _.current?_.current.setMode(m):_.current=new Oe.ModeController(E,m),()=>{_.current?.destroy(),_.current=null}},[m]);let Z=(0,D.useCallback)(E=>{let Pe=$.current?.current;Pe&&(Pe.focus(),(0,Oe.setCursorOffset)(Pe,E))},[]),{completedParams:V,skippedParams:t,identifiedParams:p,isReady:u,customFields:k,suggestionPills:l,setActivePill:z,skipActivePill:oe,segments:B,newParamId:d,clearNewParamId:we,placeholderText:Te,isFocused:xe,isDropdownOpen:Ae,isActivePillSelected:ye,isLoading:ke,activeIndex:F,listboxId:Ce,handleTextChange:ze,handleKeyDown:Fe,setFocused:Ye,editingParam:Ne,editingIdentified:Ke,editingAnchor:f,caretOffset:Q,startEditingParam:L,handleCaretAfterInput:Xe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Ge}=Qe({onSubmit:E=>pe.current(E),onResult:a,onError:r,optionOverrides:n,maskCompletedText:o,apiConfig:g,additionalContext:w,columns:b,dropdownTrigger:v,optionsPosition:y,closeDropdownOnBlur:A,showNonTappableOptions:M,showOptionIcons:N,showSkipButton:re,showProducts:W,onFocus:te,onBlur:ge,value:se,completedParams:h,onChange:be,onParamsChange:H,products:ve,onProductSelect:le,source:"full-sdk",setCursor:Z});(0,D.useEffect)(()=>{if(!d)return;let E=window.setTimeout(()=>we(),650);return()=>window.clearTimeout(E)},[d,we]);let Ht=F>=0?`${Ce}-option-${F}`:void 0,{inputRef:Je,editorProps:Bt,focus:We,blur:lt,getPlainText:dt}=Lt({segments:B,newParamId:d,editingParam:Ne,editingIdentified:Ke,editingAnchor:f,caretOffset:Q,placeholderText:Te,isFocused:xe,showChipIcons:G,isDropdownOpen:Ae,listboxId:Ce,activeDescendantId:Ht,autoFocus:I,handleTextChange:ze,handleKeyDown:Fe,handleCaretAfterInput:Xe,handleCaretMove:Ot,startEditingParam:L,replaceEditingRange:zt,setFocused:Ye});$.current=Je,(0,D.useLayoutEffect)(()=>{let E=ce.current,Pe=Je.current;if(!E||!Pe)return;let ct=()=>{let ht=E.firstElementChild;if(!ht)return;let Wt=ht.getBoundingClientRect(),_t=Pe.getBoundingClientRect();Wt.top>=_t.bottom-2?E.setAttribute("data-aia-pill-wrapped",""):E.removeAttribute("data-aia-pill-wrapped")};ct();let pt=new ResizeObserver(ct);return pt.observe(Pe),()=>pt.disconnect()},[B,l.length,ke,Je]),(0,D.useImperativeHandle)(de,()=>({focus:We,blur:lt,reset:Ge,setMode:E=>_.current?.setMode(E),skipActivePill:oe}),[We,lt,Ge,oe]);let _e=!!B.length||V.length>0,et=(0,D.useCallback)(()=>{if(!_e)return;let E=dt();i((0,Oe.buildSubmitResult)(E,V,t,{identifiedParams:p,isReady:u,customFields:k})),Ge()},[_e,V,t,p,u,k,i,Ge,dt]);pe.current=et;let Ft=(0,D.useCallback)(E=>{E.target?.closest("[data-aia-pill]")||We()},[We]),Kt=x==="inline",Gt=x==="dropdown";return(0,ee.jsxs)("div",{ref:ie,className:`magicx-aia ${Ee.container} ${s??""}`,"data-pill-placement":x,"data-options-position":y,"data-animations":P?"on":"off","data-mode":sa(m),children:[(0,ee.jsx)($e,{...Nt,showPills:Gt}),(0,ee.jsxs)("div",{className:Ee.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[(0,ee.jsxs)("div",{className:Ee.editorArea,"data-aia-editor":"",children:[(0,ee.jsx)("div",{...Bt,className:Ee.input,"data-aia-input":""}),Kt&&(ke||l.length>0)&&(0,ee.jsx)("span",{ref:ce,className:Ee.pillListContainer,"data-aia-pill-list-container":"",children:(0,ee.jsx)(Ue,{pills:l,activePillIndex:0,activeSelected:ye,onSelectPill:z,loading:ke})})]}),ae===null?null:ae===void 0?(0,ee.jsx)(At,{disabled:!_e,onClick:et}):(0,ee.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ee.submitSlot,onClick:E=>{_e&&(E.stopPropagation(),et())},children:ae})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,isoDate,monthLabel,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
1748
1838
|
//# sourceMappingURL=index.js.map
|