@magicx-eng/ai-autocomplete-react 0.25.0 → 0.26.1
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 +2 -2
- package/dist/index.js +46 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -763,10 +763,10 @@ Override on the container (via `className`). The variables are declared with `:w
|
|
|
763
763
|
| `--aia-submit-bg-disabled` | `--aia-submit-bg` | `--aia-submit-bg` | Submit background when disabled (empty input). Defaults to the enabled background so themed colors aren't washed out. Set this for a faded rest state. |
|
|
764
764
|
| `--aia-submit-color-disabled` | `--aia-submit-color` | `--aia-submit-color` | Submit arrow color when disabled. Defaults to the enabled color. |
|
|
765
765
|
| `--aia-border` | `rgba(17, 24, 39, 0.14)` | `#505050` | Input container border color |
|
|
766
|
-
| `--aia-shadow` | `
|
|
766
|
+
| `--aia-shadow` | `none` | `none` | Input container elevation (box-shadow). Flat by default; set it to add one |
|
|
767
767
|
| `--aia-dropdown-offset` | `13px` | `13px` | Gap between the input box and the dropdown (the dropdown's margin toward the input). |
|
|
768
768
|
| `--aia-content-inset-left` | `16px` | `16px` | Left inset of the SDK's content: the input wrapper's left padding, and the line the dropdown's content (parameter label, option text, product strip) starts on. Set it when you pad the field to clear a leading icon of your own, so the dropdown's content stays aligned under the typed text. Practical minimum is `10px` (the option text's own inset); both surfaces floor it there. |
|
|
769
|
-
| `--aia-footer-gap` | `
|
|
769
|
+
| `--aia-footer-gap` | `12px` | `12px` | Breathing room above the dropdown footer (badge / keyboard hints), additive to the dropdown's 8px section gap. |
|
|
770
770
|
| `--aia-footer-chip-bg` | `--aia-surface` at 65% | `--aia-surface` at 65% | Fill behind the footer's keyboard hint and AI-Autocomplete badge. The option list scrolls under the footer, so this keeps both legible over the row passing behind them. `transparent` on the glass surface. |
|
|
771
771
|
| `--aia-dropdown-bg` | — | — | Optional bg color the dropdown's "glass" rim shadow tints toward. Set this to the page background behind the dropdown so the bottom-corner glow blends seamlessly. |
|
|
772
772
|
| `--aia-scrollbar-thumb` | `rgba(0, 0, 0, 0.3)` | `rgba(0, 0, 0, 0.3)` | Color of the option list's scrollbar thumb (Firefox + WebKit). |
|
package/dist/index.js
CHANGED
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
10px the two sides would diverge; flooring both keeps them together. */
|
|
18
18
|
padding: 12px 16px 12px max(10px, var(--aia-content-inset-left, 16px));
|
|
19
19
|
border: 1px solid var(--aia-border, #b0b0b0);
|
|
20
|
-
border-radius:
|
|
20
|
+
border-radius: 10px;
|
|
21
21
|
background: var(--aia-surface, #ffffff);
|
|
22
|
+
/* Flat by default; consumers can set --aia-shadow for elevation. */
|
|
22
23
|
box-shadow: var(--aia-shadow, none);
|
|
23
24
|
overflow: hidden;
|
|
24
25
|
display: flex;
|
|
@@ -445,15 +446,14 @@
|
|
|
445
446
|
:where(.magicx-aia[data-mode="light"]) {
|
|
446
447
|
--aia-surface: var(--aia-primitive-neutral-1000);
|
|
447
448
|
--aia-border: rgba(17, 24, 39, 0.14); /* subtle slate hairline (off-palette) */
|
|
448
|
-
/*
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
0 8px 24px rgba(16, 24, 40, 0.08);
|
|
449
|
+
/* Flat by default \u2014 no elevation on the input container. Consumers set
|
|
450
|
+
--aia-shadow to add one. */
|
|
451
|
+
--aia-shadow: none;
|
|
452
452
|
/* Half-strength stroke: neutral-900 (was #e5e7eb \u2014 snapped to palette,
|
|
453
453
|
\u03942) at 50% alpha over the surface, so the hairline lands exactly
|
|
454
454
|
halfway between its old value and the white behind it. */
|
|
455
455
|
--aia-dropdown-border: var(--aia-primitive-neutral-900-a50);
|
|
456
|
-
--aia-dropdown-shadow:
|
|
456
|
+
--aia-dropdown-shadow: none; /* flat by default */
|
|
457
457
|
/* Suggestion pills (Figma "ParamPill"): transparent fill, no visible border;
|
|
458
458
|
per-pill opacity via getPillOpacity. */
|
|
459
459
|
--aia-pill-bg: var(--aia-primitive-neutral-750);
|
|
@@ -500,15 +500,13 @@
|
|
|
500
500
|
:where(.magicx-aia[data-mode="dark"]) {
|
|
501
501
|
--aia-surface: var(--aia-primitive-neutral-0);
|
|
502
502
|
--aia-border: var(--aia-primitive-neutral-500);
|
|
503
|
-
/*
|
|
504
|
-
|
|
505
|
-
--aia-shadow:
|
|
506
|
-
inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.2),
|
|
507
|
-
0 8px 24px rgba(0, 0, 0, 0.25);
|
|
503
|
+
/* Flat by default \u2014 no elevation on the input container. Consumers set
|
|
504
|
+
--aia-shadow to add one. */
|
|
505
|
+
--aia-shadow: none;
|
|
508
506
|
/* Half-strength stroke \u2014 neutral-400 (was #484848 \u2014 snapped to palette,
|
|
509
507
|
\u03942) at 50% alpha; see the light-mode note above. */
|
|
510
508
|
--aia-dropdown-border: var(--aia-primitive-neutral-400-a50);
|
|
511
|
-
--aia-dropdown-shadow:
|
|
509
|
+
--aia-dropdown-shadow: none; /* flat by default */
|
|
512
510
|
/* Suggestion pills (Figma "ParamPill"): transparent fill, no visible border. */
|
|
513
511
|
--aia-pill-bg: var(--aia-primitive-neutral-750);
|
|
514
512
|
--aia-pill-color: var(--aia-primitive-neutral-700);
|
|
@@ -568,7 +566,7 @@
|
|
|
568
566
|
(the kbd is shorter and centers against it). The band derives from it, so
|
|
569
567
|
restyling the badge's height keeps the overlap in step. */
|
|
570
568
|
--aia-footer-row-height: 23px;
|
|
571
|
-
--aia-footer-band: calc(var(--aia-footer-gap,
|
|
569
|
+
--aia-footer-band: calc(var(--aia-footer-gap, 12px) + var(--aia-footer-row-height, 23px));
|
|
572
570
|
--aia-grid-scroll-bottom: var(--aia-footer-band);
|
|
573
571
|
--aia-grid-overlap-bottom: calc(-1 * (var(--aia-footer-band) + 8px));
|
|
574
572
|
/* How far above the band the fade starts. */
|
|
@@ -700,7 +698,7 @@
|
|
|
700
698
|
bottom edge \u2014 the side the option rows scroll under. */
|
|
701
699
|
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] [data-aia-footer],
|
|
702
700
|
[data-aia-dropdown][data-options-position="above"] [data-aia-footer] {
|
|
703
|
-
padding: 0 0 var(--aia-footer-gap,
|
|
701
|
+
padding: 0 0 var(--aia-footer-gap, 12px) 8px;
|
|
704
702
|
}
|
|
705
703
|
|
|
706
704
|
/* ...and the fade runs the other way, out of the footer and down into the list. */
|
|
@@ -771,8 +769,9 @@
|
|
|
771
769
|
frosted-glass look with data-aia-surface="glass". */
|
|
772
770
|
background: var(--aia-surface, #ffffff);
|
|
773
771
|
border: 1px solid var(--aia-dropdown-border, rgba(231, 231, 231, 0.5));
|
|
774
|
-
border-radius:
|
|
775
|
-
|
|
772
|
+
border-radius: 9px;
|
|
773
|
+
/* Flat by default; consumers can set --aia-dropdown-shadow for elevation. */
|
|
774
|
+
box-shadow: var(--aia-dropdown-shadow, none);
|
|
776
775
|
}
|
|
777
776
|
|
|
778
777
|
/* A calendar has nothing wide to read, so the whole panel narrows with it \u2014
|
|
@@ -795,8 +794,7 @@
|
|
|
795
794
|
hsla(0, 0%, 100%, 0.15) 0px -1.6px 0px -1.6px inset,
|
|
796
795
|
hsla(0, 0%, 100%, 0.3) 0px 1.6px 0px 0px inset,
|
|
797
796
|
hsla(0, 0%, 100%, 0.3) 1.6px 0px 0px 0px inset,
|
|
798
|
-
inset 0 0 30px 5px hsla(0, 0%, 0%, 0.05)
|
|
799
|
-
hsla(0, 0%, 0%, 0.08) 0px 0px 30px 2px;
|
|
797
|
+
inset 0 0 30px 5px hsla(0, 0%, 0%, 0.05);
|
|
800
798
|
backdrop-filter: blur(30px);
|
|
801
799
|
}
|
|
802
800
|
|
|
@@ -879,6 +877,13 @@
|
|
|
879
877
|
opacity: 1;
|
|
880
878
|
}
|
|
881
879
|
|
|
880
|
+
/* Visible but not yet armed: the arrow is disabled for the length of its
|
|
881
|
+
fade-in (scrollArrow.ts \u2014 a native button appearing clickable cancels an
|
|
882
|
+
iOS tap in flight). No pointer cursor over a button that takes no click. */
|
|
883
|
+
.aia-scrollArrow-uUzV0:disabled {
|
|
884
|
+
cursor: default;
|
|
885
|
+
}
|
|
886
|
+
|
|
882
887
|
/* The chevron's size and paint by class \u2014 a page's \`svg { \u2026 }\` type rule
|
|
883
888
|
would otherwise beat its presentation attributes. */
|
|
884
889
|
.aia-scrollArrow-uUzV0 svg {
|
|
@@ -1231,7 +1236,7 @@
|
|
|
1231
1236
|
badge sits as far from the right edge as it does from the bottom \u2014 12px
|
|
1232
1237
|
both ways (dropdown padding 10 + pill 2 down, dropdown padding 8 + pill 4
|
|
1233
1238
|
across). */
|
|
1234
|
-
padding: var(--aia-footer-gap,
|
|
1239
|
+
padding: var(--aia-footer-gap, 12px) 0 0 8px;
|
|
1235
1240
|
/* The fade itself lives in appearance.css, on the footer's background.
|
|
1236
1241
|
Paints above the rows it covers: option content sits at z-index 2 (see
|
|
1237
1242
|
SuggestionItem.module.css) in this same stacking context, so anything
|
|
@@ -1420,7 +1425,7 @@
|
|
|
1420
1425
|
align-items: center;
|
|
1421
1426
|
vertical-align: middle;
|
|
1422
1427
|
}
|
|
1423
|
-
`,document.head.appendChild(e)}var st={list:"aia-list-qvLqO"};var
|
|
1428
|
+
`,document.head.appendChild(e)}var st={list:"aia-list-qvLqO"};var Ge=require("react/jsx-runtime"),oa=[125,69];function yt(e){return e===0?"first":e===1?"next":"last"}function Qe({pills:e,activePillIndex:o,onSelectPill:t,activeSelected:s,rounded:n,loading:i}){return i&&e.length===0?(0,Ge.jsx)("span",{className:st.list,"data-aia-pill-list-loading":"",children:oa.map((r,m)=>(0,Ge.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Ae.pill} ${n?Ae.rounded:""} ${Ae.skeleton}`,style:{width:r,opacity:rt[yt(m)]}},`skel-${r}`))}):(0,Ge.jsx)("span",{className:st.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((r,m)=>{let w=!!s&&m===o;return(0,Ge.jsx)(wt,{label:r.text,state:w?"selected":yt(m),selected:w,rounded:n,loading:i,onClick:()=>t(m)},`${r.type}-${r.text}`)})})}var kt=require("@magicx-eng/ai-autocomplete-vanilla"),Ye=require("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
|
|
1424
1429
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1425
1430
|
theming one package sees the same result in the other.
|
|
1426
1431
|
|
|
@@ -1699,13 +1704,13 @@
|
|
|
1699
1704
|
SuggestionItem selection. The 9px/10px inset is the item's own padding. */
|
|
1700
1705
|
border-radius: 8px;
|
|
1701
1706
|
padding: 8px 10px;
|
|
1702
|
-
/*
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1707
|
+
/* No entrance animation on the row itself \u2014 deliberately. The row is the
|
|
1708
|
+
tappable element, and iOS Safari drops a tap on a scripted-clickable
|
|
1709
|
+
element (a div with a click handler; a native button is exempt) whose
|
|
1710
|
+
own opacity is mid-animation \u2014 its tap-or-hover pass counts the change
|
|
1711
|
+
as content moving under the finger, fires only the hover events (the
|
|
1712
|
+
row highlights) and never the click. Both halves of the entrance run
|
|
1713
|
+
on the inner content instead (next rule). */
|
|
1709
1714
|
}
|
|
1710
1715
|
|
|
1711
1716
|
@keyframes aia-fadeIn-I8u35 {
|
|
@@ -1731,9 +1736,17 @@
|
|
|
1731
1736
|
.aia-content-T-Qba {
|
|
1732
1737
|
position: relative;
|
|
1733
1738
|
z-index: 2;
|
|
1734
|
-
/* The entrance
|
|
1735
|
-
|
|
1736
|
-
|
|
1739
|
+
/* The entrance: fade in while rising into place, each row a beat after the
|
|
1740
|
+
one before it (--aia-option-enter-delay is set inline per row from the
|
|
1741
|
+
core's optionEnterDelayMs). Both run here, on the inner content, never on
|
|
1742
|
+
the row: the rise because a transformed cell extends the grid's
|
|
1743
|
+
scrollable area (see the overflow note on the row), the fade because iOS
|
|
1744
|
+
Safari drops a tap on a tappable element whose own opacity is animating
|
|
1745
|
+
(see the row's own comment). The durations and distance mirror
|
|
1746
|
+
OPTION_ENTER_* in the core's derive/optionsEntrance.ts \u2014 change both together. */
|
|
1747
|
+
animation:
|
|
1748
|
+
aia-riseIn-etXZT 280ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both,
|
|
1749
|
+
aia-fadeIn-I8u35 150ms ease-out both;
|
|
1737
1750
|
animation-delay: var(--aia-option-enter-delay, 0ms);
|
|
1738
1751
|
}
|
|
1739
1752
|
|
|
@@ -1980,7 +1993,7 @@
|
|
|
1980
1993
|
filter: brightness(0.55);
|
|
1981
1994
|
}
|
|
1982
1995
|
}
|
|
1983
|
-
`,document.head.appendChild(e)}var U={item:"aia-item-d4vpD",
|
|
1996
|
+
`,document.head.appendChild(e)}var U={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO"};var oe=require("react/jsx-runtime");function Et({option:e,isHighlighted:o,onSelect:t,onHighlight:s,id:n,loading:i,showIcon:r=!0,showImage:m=!0,showCount:w=!0,scrollHint:g,enterDelayMs:x=0}){let[h]=(0,ne.useState)(x),[C,E]=(0,ne.useState)(!1),k=m?(0,re.optionImageSrc)(e.image_url):null,[K,R]=(0,ne.useState)(null),T=(0,ne.useMemo)(()=>!k&&r&&e.icon_svg?(0,re.sanitizeOptionIconSvg)(e.icon_svg):null,[k,r,e.icon_svg]),N=w?(0,re.formatOptionCount)(e.item_count):null,L=(0,ne.useRef)(void 0);(0,ne.useEffect)(()=>()=>clearTimeout(L.current),[]);let F=()=>{i||!e.is_tappable||C||(E(!0),t(e),clearTimeout(L.current),L.current=setTimeout(()=>E(!1),170))},G=[U.item,o&&!i?U.highlighted:"",e.is_tappable?U.tappable:U.nonTappable,C?U.pressed:"",g?U.scrollHint:""].filter(Boolean).join(" ");return(0,oe.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":T&&e.icon?e.icon:void 0,"data-aia-image":k?"":void 0,"data-aia-item-count":N!==null?e.item_count:void 0,"aria-selected":o,className:G,style:{[re.OPTION_ENTER_DELAY_VAR]:`${h}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:F,onKeyDown:S=>{!i&&e.is_tappable&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),F())},onMouseEnter:!i&&e.is_tappable?s:void 0,children:(0,oe.jsxs)("span",{className:U.content,children:[k&&(0,oe.jsx)("span",{className:`${U.image} magicx-aia-option-image`,"aria-hidden":"true",children:(0,oe.jsx)("img",{src:k,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:K===k,onError:()=>R(k)})}),T&&(0,oe.jsx)("span",{className:`${U.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:T}}),(0,oe.jsx)("span",{className:U.text,children:(0,re.optionLabel)(e)}),e.tag&&(0,oe.jsx)("span",{className:U.tag,children:e.tag}),N!==null&&(0,oe.jsx)("span",{className:`${U.count} magicx-aia-option-count`,children:N})]})})}var lt=require("react/jsx-runtime");function ra(){let[e,o]=(0,ke.useState)(j.isOptionsGridMobileViewport);return(0,ke.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(j.OPTIONS_GRID_MOBILE_QUERY),s=()=>o(t.matches);return s(),t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[]),e}function Tt({options:e,activeIndex:o,onSelect:t,onHighlight:s,listboxId:n,loading:i,groupKey:r="",optionsPosition:m="below",showIcons:w=!0,showImages:g=!0,showCounts:x=!0}){let h=ra(),C=(0,ke.useRef)(null),[E,k]=(0,ke.useState)(null);(0,ke.useLayoutEffect)(()=>{let R=C.current,N=R&&!i&&(0,j.needsOptionsGridMeasurement)(e.length,h)?(0,j.measureOptionsGrid)(R):null;k(N?(0,j.planOptionsGrid)(e.length,h,N.rowWidths,N.gridWidth):null)},[e,h,i]);let K=E??(0,j.planOptionsGrid)(e.length,h,null,null);return(0,lt.jsx)(St,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:r,template:K.template,maxHeight:K.maxHeight,innerRef:R=>{C.current=R},"data-aia-group":r,children:e.map((R,T)=>(0,lt.jsx)(Et,{option:R,isHighlighted:T===o,onSelect:t,onHighlight:()=>s(T),id:`${n}-option-${T}`,loading:i,showIcon:w,showImage:g,showCount:x,scrollHint:!i&&K.scrollHintIndices.includes(T),enterDelayMs:i?0:(0,j.optionEnterDelayMs)(T,K.cols,e.length,m)},`${r}\0${R.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
1984
1997
|
display: flex;
|
|
1985
1998
|
flex-direction: column;
|
|
1986
1999
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -1995,7 +2008,7 @@
|
|
|
1995
2008
|
align-items: end;
|
|
1996
2009
|
}
|
|
1997
2010
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1998
|
-
`,document.head.appendChild(e)}var Rt=require("react/jsx-runtime");function At({space:e,align:o="stretch",className:t,children:s,...n}){let i=e?{"--aia-stack-space":e}:void 0;return(0,Rt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...n,children:s})}var B=require("react/jsx-runtime"),sa=[159,119,164],la=()=>{},Dt=()=>{};function da(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,s]=(0,te.useState)(o);if((0,te.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>s(n.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ca(e,o){let t=(0,te.useRef)(null);(0,te.useEffect)(()=>{let s=e.current,n=o.current;if(!s||!n)return;let i=s.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==i&&(t.current.controller.destroy(),t.current=null),i&&!t.current){t.current={grid:i,controller:(0,Me.attachScrollArrow)({dropdown:s,grid:i,button:n})};return}t.current?.controller.update()}),(0,te.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ve({suggestions:e,activeIndex:o,onSelect:t,onHighlight:s,isOpen:n,id:i,className:r,pills:m,onPillClick:w,showPills:g=!0,onSkip:x,showSkipButton:h=!0,showOptionIcons:C=!0,showOptionImages:E=!0,showOptionCounts:k=!0,skipDisabled:K=!1,activeSelected:R=!1,isLoading:T=!1,isInputEmpty:N=!1,products:L,onProductSelect:F,onProductFocusChange:
|
|
2011
|
+
`,document.head.appendChild(e)}var Rt=require("react/jsx-runtime");function At({space:e,align:o="stretch",className:t,children:s,...n}){let i=e?{"--aia-stack-space":e}:void 0;return(0,Rt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":o,style:i,...n,children:s})}var B=require("react/jsx-runtime"),sa=[159,119,164],la=()=>{},Dt=()=>{};function da(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,s]=(0,te.useState)(o);if((0,te.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>s(n.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function ca(e,o){let t=(0,te.useRef)(null);(0,te.useEffect)(()=>{let s=e.current,n=o.current;if(!s||!n)return;let i=s.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==i&&(t.current.controller.destroy(),t.current=null),i&&!t.current){t.current={grid:i,controller:(0,Me.attachScrollArrow)({dropdown:s,grid:i,button:n})};return}t.current?.controller.update()}),(0,te.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function Ve({suggestions:e,activeIndex:o,onSelect:t,onHighlight:s,isOpen:n,id:i,className:r,pills:m,onPillClick:w,showPills:g=!0,onSkip:x,showSkipButton:h=!0,showOptionIcons:C=!0,showOptionImages:E=!0,showOptionCounts:k=!0,skipDisabled:K=!1,activeSelected:R=!1,isLoading:T=!1,isInputEmpty:N=!1,products:L,onProductSelect:F,onProductFocusChange:G,productsLayout:S="row",formatType:se="options",dateView:le=null,selectedDateIso:Ce=null,selectedDateRange:de=null,dateRangeStart:u=null,onPreviousMonth:Y,onNextMonth:Pe,optionsPosition:ce="below",mode:Se}){let pe=da(Se),Ie=pe!==void 0,Z=(0,te.useRef)(null),he=(0,te.useRef)(null);ca(Z,he);let ue=e[0]?.options??[],me=!!(m&&m.length>0&&w),fe=!!(L&&L.length>0),H=n&&(ue.length>0||g&&me||T||fe),d={suggestions:e,activeIndex:o,pills:m,showPills:g,showSkipButton:h,showOptionIcons:C,showOptionImages:E,showOptionCounts:k,skipDisabled:K,activeSelected:R,isLoading:T,isInputEmpty:N,products:L,formatType:se,dateView:le,selectedDateIso:Ce,selectedDateRange:de,dateRangeStart:u},b=(0,te.useRef)(d);H&&(b.current=d);let a=H?d:b.current,y=a.suggestions[0],v=y?.options??[],p=a.activeIndex>=0&&!!v[a.activeIndex]?.is_tappable,$=!!(a.pills&&a.pills.length>0&&w),X=a.showPills&&$,ge=a.showPills&&!$&&a.isLoading,c=X||ge,be=$&&a.showSkipButton&&!a.isInputEmpty&&!!x,Ee=a.pills?.[0]?.text,ve=(0,Me.isCalendarFormat)(a.formatType)&&a.dateView!=null,De=v.length>0&&!ve,we=v.length>0&&ve&&!a.isLoading,He=a.isLoading&&!De&&!we,J=a.products??[];return(0,B.jsxs)("div",{ref:Z,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":ce,"data-mode":pe,"data-aia-loading":a.isLoading?"":void 0,"data-aia-has-products":J.length>0?"":void 0,className:`${Ie?"magicx-aia ":""}${xe.dropdown} ${H?xe.visible:""} ${r??""}`,onMouseDown:W=>W.preventDefault(),children:[(0,B.jsxs)(At,{space:"8px",children:[(c||be)&&(0,B.jsxs)(Ke,{noWrap:!0,className:xe.pillBar,"data-aia-pillbar":"",children:[c&&(0,B.jsx)("span",{className:xe.pillScroll,"data-aia-pill-scroll":"",children:(0,B.jsx)(Qe,{pills:a.pills??[],activePillIndex:0,activeSelected:a.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:a.isLoading})}),be&&(0,B.jsx)("button",{type:"button",tabIndex:-1,className:xe.skip,"data-aia-skip":"",disabled:a.isLoading||a.skipDisabled,"aria-label":Ee?`Skip ${Ee}`:"Skip",onClick:x,children:"skip"})]}),De&&(0,B.jsx)(Tt,{options:v,activeIndex:a.activeIndex,onSelect:t,onHighlight:s,listboxId:i,loading:a.isLoading,groupKey:y?`${y.type} ${y.text}`:"",optionsPosition:ce,showIcons:a.showOptionIcons,showImages:a.showOptionImages,showCounts:a.showOptionCounts}),we&&a.dateView&&(0,B.jsx)(bt,{options:v,activeIndex:a.activeIndex,listboxId:i,view:a.dateView,selection:{selectedIso:a.selectedDateIso??null,selectedRange:a.selectedDateRange??null,rangeStart:a.dateRangeStart??null},onSelect:t,onHighlight:s,onPreviousMonth:Y??Dt,onNextMonth:Pe??Dt}),He&&(0,B.jsx)("div",{className:xe.skeletonBars,"data-aia-skeleton-bars":"",children:sa.map(W=>(0,B.jsx)("span",{className:xe.skeletonBar,style:{width:W}},`bar-${W}`))}),(0,B.jsx)(Ct,{products:J,listboxId:i,onSelect:F??la,onFocusChange:G,focusable:H,layout:S}),(0,B.jsx)(vt,{isOptionHighlighted:p,isInputEmpty:a.isInputEmpty})]}),(0,B.jsx)("button",{ref:he,type:"button",tabIndex:-1,className:xe.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Me.SCROLL_ARROW_LABEL,"aria-hidden":"true",children:(0,B.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,B.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Ne=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 {
|
|
1999
2012
|
flex-shrink: 0;
|
|
2000
2013
|
width: 32px;
|
|
2001
2014
|
height: 32px;
|
|
@@ -2048,5 +2061,5 @@
|
|
|
2048
2061
|
);
|
|
2049
2062
|
cursor: default;
|
|
2050
2063
|
}
|
|
2051
|
-
`,document.head.appendChild(e)}var Lt={submitButton:"aia-submitButton-otz7H"};var Ze=require("react/jsx-runtime");function Ot({disabled:e,onClick:o}){return(0,Ze.jsx)("button",{type:"button","data-aia-submit":"",className:Lt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),o()},"aria-label":"Submit",children:(0,Ze.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Ze.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var ze=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var dt=require("react");function Mt(e){let o=(0,dt.useRef)(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),s=(0,dt.useRef)({key:"",overrides:void 0});if(s.current.key!==t){let n={};for(let i of Object.keys(e??{})){let r=(m,w,g)=>{let x=o.current?.[i];return x?x(m,w,g):[]};n[i]=r}s.current={key:t,overrides:e?n:void 0}}return{overrides:s.current.overrides,key:t}}var ct=require("react");function zt(e){let o=(0,ct.useRef)(e);o.current=e;let t=(0,ct.useRef)(null);t.current===null&&(t.current={fetch:(n,i)=>{let r=o.current;return r?r.fetch(n,i):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let s=e!==void 0;return{config:s?t.current:void 0,enabled:s}}var pa={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 Xe({onSubmit:e,onResult:o,onError:t,optionOverrides:s,maskCompletedText:n,apiConfig:i,additionalContext:r,columns:m=2,dropdownTrigger:w,optionsPosition:g,closeDropdownOnBlur:x,showNonTappableOptions:h,showOptionIcons:C,showOptionImages:E,showOptionCounts:k,showSkipButton:K,showProducts:R,onFocus:T,onBlur:N,value:L,completedParams:F,onChange:W,onParamsChange:S,products:se,onProductSelect:le,source:Ce,setCursor:de}){let u=(0,I.useRef)(null),[Y,Pe]=(0,I.useState)(null),ce=(0,I.useRef)(e);ce.current=e;let Se=(0,I.useRef)(o);Se.current=o;let pe=(0,I.useRef)(t);pe.current=t;let Ie=(0,I.useRef)(W);Ie.current=W;let Z=(0,I.useRef)(S);Z.current=S;let he=(0,I.useRef)(T);he.current=T;let ue=(0,I.useRef)(N);ue.current=N;let me=(0,I.useRef)(de);me.current=de;let fe=(0,I.useRef)(le);fe.current=le;let H=zt(se),d=Mt(s);(0,I.useEffect)(()=>{if(typeof document>"u")return;let f=new ze.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:r,optionOverrides:d.overrides,maskCompletedText:n,columns:m,dropdownTrigger:w,optionsPosition:g,closeDropdownOnBlur:x,showNonTappableOptions:h,showProducts:R,source:Ce,value:L,completedParams:F,onSubmit:(...z)=>ce.current?.(...z),onResult:(...z)=>Se.current?.(...z),onError:(...z)=>pe.current?.(...z),onChange:(...z)=>Ie.current?.(...z),onParamsChange:(...z)=>Z.current?.(...z),onFocus:()=>he.current?.(),onBlur:()=>ue.current?.(),onProductSelect:z=>fe.current?.(z),setCursor:z=>me.current?.(z),products:H.config});u.current=f,Pe(f.getState());let V=f.subscribe(z=>Pe(z));return()=>{V(),f.destroy(),u.current===f&&(u.current=null)}},[]),(0,I.useEffect)(()=>{L!==void 0&&u.current?.setValue(L)},[L]),(0,I.useEffect)(()=>{F!==void 0&&u.current?.setCompletedParams(F)},[F]);let b=JSON.stringify(i??null),a;try{a=JSON.stringify(r??null)}catch{a="[unstringifiable]"}(0,I.useEffect)(()=>{u.current?.update({apiConfig:i,additionalContext:r,optionOverrides:d.overrides,dropdownTrigger:w,optionsPosition:g,closeDropdownOnBlur:x,showNonTappableOptions:h,showProducts:R})},[b,a,d.key,w,g,x,h,R]);let y=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!y.current){y.current=!0;return}u.current?.update({products:H.config})},[H.enabled]);let v=(0,I.useRef)(null);v.current===null&&(v.current={handleTextChange:f=>u.current?.handleTextChange(f),handleKeyDown:f=>{let V="nativeEvent"in f?f.nativeEvent:f;u.current?.handleKeyDown(V)},setFocused:f=>u.current?.setFocused(f),startEditingParam:f=>u.current?.startEditingParam(f),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:f=>u.current?.handleCaretAfterInput(f),handleCaretMove:f=>u.current?.handleCaretMove(f),replaceEditingRange:f=>u.current?.replaceEditingRange(f)??!1,setActivePill:f=>u.current?.setActivePill(f),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),selectOption:f=>u.current?.selectOption(f),selectProduct:f=>u.current?.selectProduct(f),setActiveDropdownIndex:f=>u.current?.setActiveDropdownIndex(f),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let p=v.current,$=(0,I.useCallback)(f=>{let V=f.target.value,tt=V.length>0&&!f.nativeEvent?.isComposing&&V[0]!==V[0].toUpperCase()?V[0].toUpperCase()+V.slice(1):V;u.current?.handleTextChange(tt)},[]),X=(0,I.useCallback)(f=>{u.current?.handleKeyDown(f.nativeEvent)},[]),ge=u.current,c=Y??pa,be=L!==void 0?L:c.text,Ee=F!==void 0?F:c.completedParams,ve=c.actionableSuggestions,De=ve[0],we=ge?.listboxId??"",He=c.activeDropdownIndex>=0&&ge?`${we}-option-${c.activeDropdownIndex}`:void 0,J=c.editingParam,G=c.editingIdentified,Le=J?{type:J.suggestionType,text:J.suggestionPlaceholder,required:!0,options:J.options}:G?{type:G.type,text:(0,ze.identifiedParamLabel)(G.type),required:!0,options:[]}:null,Be=Le??De,et=Le?[Le]:ve,Fe=(0,ze.dateSelectionFor)(c),Ge=!ge||c.isLoading&&!c.editingParam&&!c.inSelectionAnimation||c.isSearchingOptions;return{completedParams:Ee,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:ve,setActivePill:p.setActivePill,skipActivePill:p.skipActivePill,removeLastParam:p.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:p.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:Ge,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:we,error:c.error,products:c.products,customFields:c.customFields,selectProduct:p.selectProduct,handleTextChange:p.handleTextChange,handleKeyDown:p.handleKeyDown,setFocused:p.setFocused,editingParam:J,editingIdentified:G,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:p.startEditingParam,exitEditMode:p.exitEditMode,handleCaretAfterInput:p.handleCaretAfterInput,handleCaretMove:p.handleCaretMove,replaceEditingRange:p.replaceEditingRange,inputProps:{value:be,placeholder:c.placeholderText||void 0,onChange:$,onKeyDown:X,onFocus:p.handleFocus,onBlur:p.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":He,"aria-autocomplete":"list","aria-controls":we},reset:p.reset,dropdownProps:{suggestions:Be?[{...Be,options:c.filteredOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:p.selectOption,onHighlight:p.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:we,pills:et,activeSelected:c.isActivePillSelected,onPillClick:p.setActivePill,onSkip:p.skipActivePill,showSkipButton:(K??!0)&&!J&&!G,showOptionIcons:C??!0,showOptionImages:E??!0,showOptionCounts:k??!0,skipDisabled:c.inSelectionAnimation,isLoading:Ge,isInputEmpty:be.trim().length===0,products:c.products,onProductSelect:p.selectProduct,onProductFocusChange:p.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Fe.selectedIso,selectedDateRange:Fe.selectedRange,dateRangeStart:Fe.rangeStart,onPreviousMonth:p.showPreviousMonth,onNextMonth:p.showNextMonth,optionsPosition:g??"below"}}}var Q=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react"),Je;function ha(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Nt(e){let{segments:o,showChipIcons:t=!0,showChipImages:s=!0,newParamId:n,editingParam:i,editingIdentified:r,editingAnchor:m,caretOffset:w,placeholderText:g,isFocused:x,isDropdownOpen:h,listboxId:C,activeDescendantId:E,autoFocus:k,handleTextChange:K,handleKeyDown:R,handleCaretAfterInput:T,handleCaretMove:N,startEditingParam:L,replaceEditingRange:F,setFocused:W}=e,S=(0,P.useRef)(null),se=(0,P.useRef)(!1),le=(0,P.useRef)(""),Ce=(0,P.useRef)(""),de=(0,P.useRef)(null),u=(0,P.useRef)(0);de.current=w,(0,P.useEffect)(()=>{if(!k)return;let d=S.current;if(!d)return;document.activeElement===d?W(!0):d.focus();let b=d.ownerDocument??document,a=b.getSelection(),y=a&&a.rangeCount>0&&d.contains(a.anchorNode);if(a&&!y){let v=b.createRange();v.selectNodeContents(d),v.collapse(!0),a.removeAllRanges(),a.addRange(v)}},[k,W]),(0,P.useEffect)(()=>{let d=S.current;if(!d)return;let b=d.ownerDocument??document,a=()=>{let y=b.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!d.contains(y.anchorNode))return;let v=y.anchorNode,p=v.nodeType===Node.ELEMENT_NODE?v:v.parentElement,X=(y.isCollapsed?p?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ge=i?.id??r?.id??null;if(X&&X!==ge){L(X);return}performance.now()-u.current<50||N((0,Q.getCursorOffset)(d))};return b.addEventListener("selectionchange",a),()=>b.removeEventListener("selectionchange",a)},[i,r,L,N]),(0,P.useLayoutEffect)(()=>{let d=S.current;d&&(0,Q.renderEditableContent)({input:d,segments:o,newParamId:n,editingParamId:i?.id??null,placeholderText:g??"",isFocused:x,showChipIcons:t,showChipImages:s})},[o,n,i,g,x,t,s]),(0,P.useLayoutEffect)(()=>{let d=le.current,b=n??"";if(le.current=b,!b||b===d)return;let a=S.current;if(!a)return;a.focus();let y=de.current??(0,Q.plainTextLength)(a);(0,Q.setCursorOffset)(a,y)},[n]),(0,P.useLayoutEffect)(()=>{let d=Ce.current,b=i?.id??"";if(Ce.current=b,!b||b===d||m==null)return;let a=S.current;a&&(0,Q.setCursorOffset)(a,m)},[i,m]);let Y=(0,P.useCallback)(()=>{if(se.current)return;let d=S.current;if(!d)return;let b=(0,Q.extractPlainText)(d),y=b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b;K(y)},[K]),Pe=(0,P.useCallback)(()=>{u.current=performance.now(),Y();let d=S.current;d&&T((0,Q.getCursorOffset)(d))},[Y,T]);(0,P.useEffect)(()=>{let d=S.current;if(!d)return;let b=a=>{let y=a,v=y.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){a.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let p=v.startsWith("delete")?"":y.data??"";F(p)&&a.preventDefault()}};return d.addEventListener("beforeinput",b),()=>d.removeEventListener("beforeinput",b)},[F]);let ce=(0,P.useCallback)(()=>{se.current=!0},[]),Se=(0,P.useCallback)(()=>{se.current=!1,Y()},[Y]),pe=(0,P.useCallback)(d=>{d.preventDefault();let b=S.current;if(!b)return;let a=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!a)return;let y=b.ownerDocument??document,v=y.getSelection();if(!v||v.rangeCount===0)return;let p=v.getRangeAt(0);if(!b.contains(p.startContainer))return;p.deleteContents();let $=y.createTextNode(a);p.insertNode($),p.setStartAfter($),p.collapse(!0),v.removeAllRanges(),v.addRange(p),Y()},[Y]),Ie=(0,P.useCallback)(d=>R(d),[R]),Z=(0,P.useCallback)(()=>W(!0),[W]),he=(0,P.useCallback)(()=>W(!1),[W]),ue=(0,P.useCallback)(()=>S.current?.focus(),[]),me=(0,P.useCallback)(()=>S.current?.blur(),[]),fe=(0,P.useCallback)(()=>{let d=S.current;return d?(0,Q.extractPlainText)(d):""},[]),H=ha()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:H,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":C,"aria-expanded":h,"aria-activedescendant":E,spellCheck:!0,enterKeyHint:"send",onInput:Pe,onKeyDown:Ie,onCompositionStart:ce,onCompositionEnd:Se,onPaste:pe,onFocus:Z,onBlur:he},getPlainText:fe,focus:ue,blur:me}}var ae=require("react/jsx-runtime");function ua(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ht=(0,M.forwardRef)(function({onSubmit:o,onResult:t,onError:s,optionOverrides:n,maskCompletedText:i,className:r,apiConfig:m,additionalContext:w,columns:g,pillPlacement:x="dropdown",mode:h="auto",optionsPosition:C="below",animations:E=!0,dropdownTrigger:k,closeDropdownOnBlur:K,showNonTappableOptions:R,showOptionIcons:T=!0,showChipIcons:N=!0,showChipImages:L=!0,showOptionImages:F=!0,showOptionCounts:W=!0,showSkipButton:S,showProducts:se,productsLayout:le,autoFocus:Ce=!0,onFocus:de,onBlur:u,value:Y,completedParams:Pe,onChange:ce,onParamsChange:Se,products:pe,onProductSelect:Ie,submitButton:Z},he){let ue=(0,M.useRef)(null),me=(0,M.useRef)(null),fe=(0,M.useRef)(()=>{}),H=(0,M.useRef)(null),d=(0,M.useRef)(null);(0,M.useEffect)(()=>{let A=ue.current;if(A)return H.current?H.current.setMode(h):H.current=new Ne.ModeController(A,h),()=>{H.current?.destroy(),H.current=null}},[h]);let b=(0,M.useCallback)(A=>{let Te=d.current?.current;Te&&(Te.focus(),(0,Ne.setCursorOffset)(Te,A))},[]),{completedParams:a,skippedParams:y,identifiedParams:v,isReady:p,customFields:$,suggestionPills:X,setActivePill:ge,skipActivePill:c,segments:be,newParamId:Ee,clearNewParamId:ve,placeholderText:De,isFocused:we,isDropdownOpen:He,isActivePillSelected:J,isLoading:G,activeIndex:Le,listboxId:Be,handleTextChange:et,handleKeyDown:Fe,setFocused:Ge,editingParam:f,editingIdentified:V,editingAnchor:z,caretOffset:tt,startEditingParam:Bt,handleCaretAfterInput:Ft,handleCaretMove:Kt,replaceEditingRange:Wt,dropdownProps:Gt,reset:_e}=Xe({onSubmit:A=>fe.current(A),onResult:t,onError:s,optionOverrides:n,maskCompletedText:i,apiConfig:m,additionalContext:w,columns:g,dropdownTrigger:k,optionsPosition:C,closeDropdownOnBlur:K,showNonTappableOptions:R,showOptionIcons:T,showOptionImages:F,showOptionCounts:W,showSkipButton:S,showProducts:se,onFocus:de,onBlur:u,value:Y,completedParams:Pe,onChange:ce,onParamsChange:Se,products:pe,onProductSelect:Ie,source:"full-sdk",setCursor:b});(0,M.useEffect)(()=>{if(!Ee)return;let A=window.setTimeout(()=>ve(),650);return()=>window.clearTimeout(A)},[Ee,ve]);let _t=Le>=0?`${Be}-option-${Le}`:void 0,{inputRef:at,editorProps:qt,focus:qe,blur:pt,getPlainText:ht}=Nt({segments:be,newParamId:Ee,editingParam:f,editingIdentified:V,editingAnchor:z,caretOffset:tt,placeholderText:De,isFocused:we,showChipIcons:N,showChipImages:L,isDropdownOpen:He,listboxId:Be,activeDescendantId:_t,autoFocus:Ce,handleTextChange:et,handleKeyDown:Fe,handleCaretAfterInput:Ft,handleCaretMove:Kt,startEditingParam:Bt,replaceEditingRange:Wt,setFocused:Ge});d.current=at,(0,M.useLayoutEffect)(()=>{let A=me.current,Te=at.current;if(!A||!Te)return;let ut=()=>{let ft=A.firstElementChild;if(!ft)return;let Yt=ft.getBoundingClientRect(),$t=Te.getBoundingClientRect();Yt.top>=$t.bottom-2?A.setAttribute("data-aia-pill-wrapped",""):A.removeAttribute("data-aia-pill-wrapped")};ut();let mt=new ResizeObserver(ut);return mt.observe(Te),()=>mt.disconnect()},[be,X.length,G,at]),(0,M.useImperativeHandle)(he,()=>({focus:qe,blur:pt,reset:_e,setMode:A=>H.current?.setMode(A),skipActivePill:c}),[qe,pt,_e,c]);let Ue=!!be.length||a.length>0,it=(0,M.useCallback)(()=>{if(!Ue)return;let A=ht();o((0,Ne.buildSubmitResult)(A,a,y,{identifiedParams:v,isReady:p,customFields:$})),_e()},[Ue,a,y,v,p,$,o,_e,ht]);fe.current=it;let Ut=(0,M.useCallback)(A=>{A.target?.closest("[data-aia-pill]")||qe()},[qe]),jt=x==="inline",Qt=x==="dropdown";return(0,ae.jsxs)("div",{ref:ue,className:`magicx-aia ${Re.container} ${r??""}`,"data-pill-placement":x,"data-options-position":C,"data-animations":E?"on":"off","data-mode":ua(h),children:[(0,ae.jsx)(Ve,{...Gt,showPills:Qt,productsLayout:le}),(0,ae.jsxs)("div",{className:Re.inputWrapper,"data-aia-input-wrapper":"",onClick:Ut,children:[(0,ae.jsxs)("div",{className:Re.editorArea,"data-aia-editor":"",children:[(0,ae.jsx)("div",{...qt,className:Re.input,"data-aia-input":""}),jt&&(G||X.length>0)&&(0,ae.jsx)("span",{ref:me,className:Re.pillListContainer,"data-aia-pill-list-container":"",children:(0,ae.jsx)(Qe,{pills:X,activePillIndex:0,activeSelected:J,onSelectPill:ge,loading:G})})]}),Z===null?null:Z===void 0?(0,ae.jsx)(Ot,{disabled:!Ue,onClick:it}):(0,ae.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Re.submitSlot,onClick:A=>{Ue&&(A.stopPropagation(),it())},children:Z})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2064
|
+
`,document.head.appendChild(e)}var Lt={submitButton:"aia-submitButton-otz7H"};var Ze=require("react/jsx-runtime");function Ot({disabled:e,onClick:o}){return(0,Ze.jsx)("button",{type:"button","data-aia-submit":"",className:Lt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),o()},"aria-label":"Submit",children:(0,Ze.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Ze.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var ze=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var dt=require("react");function Mt(e){let o=(0,dt.useRef)(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),s=(0,dt.useRef)({key:"",overrides:void 0});if(s.current.key!==t){let n={};for(let i of Object.keys(e??{})){let r=(m,w,g)=>{let x=o.current?.[i];return x?x(m,w,g):[]};n[i]=r}s.current={key:t,overrides:e?n:void 0}}return{overrides:s.current.overrides,key:t}}var ct=require("react");function zt(e){let o=(0,ct.useRef)(e);o.current=e;let t=(0,ct.useRef)(null);t.current===null&&(t.current={fetch:(n,i)=>{let r=o.current;return r?r.fetch(n,i):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let s=e!==void 0;return{config:s?t.current:void 0,enabled:s}}var pa={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 Xe({onSubmit:e,onResult:o,onError:t,optionOverrides:s,maskCompletedText:n,apiConfig:i,additionalContext:r,columns:m=2,dropdownTrigger:w,optionsPosition:g,closeDropdownOnBlur:x,showNonTappableOptions:h,showOptionIcons:C,showOptionImages:E,showOptionCounts:k,showSkipButton:K,showProducts:R,onFocus:T,onBlur:N,value:L,completedParams:F,onChange:G,onParamsChange:S,products:se,onProductSelect:le,source:Ce,setCursor:de}){let u=(0,I.useRef)(null),[Y,Pe]=(0,I.useState)(null),ce=(0,I.useRef)(e);ce.current=e;let Se=(0,I.useRef)(o);Se.current=o;let pe=(0,I.useRef)(t);pe.current=t;let Ie=(0,I.useRef)(G);Ie.current=G;let Z=(0,I.useRef)(S);Z.current=S;let he=(0,I.useRef)(T);he.current=T;let ue=(0,I.useRef)(N);ue.current=N;let me=(0,I.useRef)(de);me.current=de;let fe=(0,I.useRef)(le);fe.current=le;let H=zt(se),d=Mt(s);(0,I.useEffect)(()=>{if(typeof document>"u")return;let f=new ze.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:r,optionOverrides:d.overrides,maskCompletedText:n,columns:m,dropdownTrigger:w,optionsPosition:g,closeDropdownOnBlur:x,showNonTappableOptions:h,showProducts:R,source:Ce,value:L,completedParams:F,onSubmit:(...z)=>ce.current?.(...z),onResult:(...z)=>Se.current?.(...z),onError:(...z)=>pe.current?.(...z),onChange:(...z)=>Ie.current?.(...z),onParamsChange:(...z)=>Z.current?.(...z),onFocus:()=>he.current?.(),onBlur:()=>ue.current?.(),onProductSelect:z=>fe.current?.(z),setCursor:z=>me.current?.(z),products:H.config});u.current=f,Pe(f.getState());let V=f.subscribe(z=>Pe(z));return()=>{V(),f.destroy(),u.current===f&&(u.current=null)}},[]),(0,I.useEffect)(()=>{L!==void 0&&u.current?.setValue(L)},[L]),(0,I.useEffect)(()=>{F!==void 0&&u.current?.setCompletedParams(F)},[F]);let b=JSON.stringify(i??null),a;try{a=JSON.stringify(r??null)}catch{a="[unstringifiable]"}(0,I.useEffect)(()=>{u.current?.update({apiConfig:i,additionalContext:r,optionOverrides:d.overrides,dropdownTrigger:w,optionsPosition:g,closeDropdownOnBlur:x,showNonTappableOptions:h,showProducts:R})},[b,a,d.key,w,g,x,h,R]);let y=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!y.current){y.current=!0;return}u.current?.update({products:H.config})},[H.enabled]);let v=(0,I.useRef)(null);v.current===null&&(v.current={handleTextChange:f=>u.current?.handleTextChange(f),handleKeyDown:f=>{let V="nativeEvent"in f?f.nativeEvent:f;u.current?.handleKeyDown(V)},setFocused:f=>u.current?.setFocused(f),startEditingParam:f=>u.current?.startEditingParam(f),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:f=>u.current?.handleCaretAfterInput(f),handleCaretMove:f=>u.current?.handleCaretMove(f),replaceEditingRange:f=>u.current?.replaceEditingRange(f)??!1,setActivePill:f=>u.current?.setActivePill(f),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),selectOption:f=>u.current?.selectOption(f),selectProduct:f=>u.current?.selectProduct(f),setActiveDropdownIndex:f=>u.current?.setActiveDropdownIndex(f),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let p=v.current,$=(0,I.useCallback)(f=>{let V=f.target.value,tt=V.length>0&&!f.nativeEvent?.isComposing&&V[0]!==V[0].toUpperCase()?V[0].toUpperCase()+V.slice(1):V;u.current?.handleTextChange(tt)},[]),X=(0,I.useCallback)(f=>{u.current?.handleKeyDown(f.nativeEvent)},[]),ge=u.current,c=Y??pa,be=L!==void 0?L:c.text,Ee=F!==void 0?F:c.completedParams,ve=c.actionableSuggestions,De=ve[0],we=ge?.listboxId??"",He=c.activeDropdownIndex>=0&&ge?`${we}-option-${c.activeDropdownIndex}`:void 0,J=c.editingParam,W=c.editingIdentified,Le=J?{type:J.suggestionType,text:J.suggestionPlaceholder,required:!0,options:J.options}:W?{type:W.type,text:(0,ze.identifiedParamLabel)(W.type),required:!0,options:[]}:null,Be=Le??De,et=Le?[Le]:ve,Fe=(0,ze.dateSelectionFor)(c),We=!ge||c.isLoading&&!c.editingParam&&!c.inSelectionAnimation||c.isSearchingOptions;return{completedParams:Ee,skippedParams:c.skippedParams,identifiedParams:c.identifiedParams,suggestionPills:ve,setActivePill:p.setActivePill,skipActivePill:p.skipActivePill,removeLastParam:p.removeLastParam,segments:c.segments,newParamId:c.newParamId,clearNewParamId:p.clearNewParamId,suggestions:c.suggestions,activeIndex:c.activeDropdownIndex,isReady:c.isReady,isLoading:We,isFocused:c.isFocused,isDropdownOpen:c.isDropdownOpen,isActivePillSelected:c.isActivePillSelected,placeholderText:c.placeholderText,listboxId:we,error:c.error,products:c.products,customFields:c.customFields,selectProduct:p.selectProduct,handleTextChange:p.handleTextChange,handleKeyDown:p.handleKeyDown,setFocused:p.setFocused,editingParam:J,editingIdentified:W,editingAnchor:c.editingAnchor,caretOffset:c.caretOffset,startEditingParam:p.startEditingParam,exitEditMode:p.exitEditMode,handleCaretAfterInput:p.handleCaretAfterInput,handleCaretMove:p.handleCaretMove,replaceEditingRange:p.replaceEditingRange,inputProps:{value:be,placeholder:c.placeholderText||void 0,onChange:$,onKeyDown:X,onFocus:p.handleFocus,onBlur:p.handleBlur,role:"combobox","aria-expanded":c.isDropdownOpen,"aria-activedescendant":He,"aria-autocomplete":"list","aria-controls":we},reset:p.reset,dropdownProps:{suggestions:Be?[{...Be,options:c.filteredOptions}]:[],activeIndex:c.activeDropdownIndex,onSelect:p.selectOption,onHighlight:p.setActiveDropdownIndex,isOpen:c.isDropdownOpen,id:we,pills:et,activeSelected:c.isActivePillSelected,onPillClick:p.setActivePill,onSkip:p.skipActivePill,showSkipButton:(K??!0)&&!J&&!W,showOptionIcons:C??!0,showOptionImages:E??!0,showOptionCounts:k??!0,skipDisabled:c.inSelectionAnimation,isLoading:We,isInputEmpty:be.trim().length===0,products:c.products,onProductSelect:p.selectProduct,onProductFocusChange:p.setFocused,formatType:c.activeFormatType,dateView:c.dateView,selectedDateIso:Fe.selectedIso,selectedDateRange:Fe.selectedRange,dateRangeStart:Fe.rangeStart,onPreviousMonth:p.showPreviousMonth,onNextMonth:p.showNextMonth,optionsPosition:g??"below"}}}var Q=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react"),Je;function ha(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Nt(e){let{segments:o,showChipIcons:t=!0,showChipImages:s=!0,newParamId:n,editingParam:i,editingIdentified:r,editingAnchor:m,caretOffset:w,placeholderText:g,isFocused:x,isDropdownOpen:h,listboxId:C,activeDescendantId:E,autoFocus:k,handleTextChange:K,handleKeyDown:R,handleCaretAfterInput:T,handleCaretMove:N,startEditingParam:L,replaceEditingRange:F,setFocused:G}=e,S=(0,P.useRef)(null),se=(0,P.useRef)(!1),le=(0,P.useRef)(""),Ce=(0,P.useRef)(""),de=(0,P.useRef)(null),u=(0,P.useRef)(0);de.current=w,(0,P.useEffect)(()=>{if(!k)return;let d=S.current;if(!d)return;document.activeElement===d?G(!0):d.focus();let b=d.ownerDocument??document,a=b.getSelection(),y=a&&a.rangeCount>0&&d.contains(a.anchorNode);if(a&&!y){let v=b.createRange();v.selectNodeContents(d),v.collapse(!0),a.removeAllRanges(),a.addRange(v)}},[k,G]),(0,P.useEffect)(()=>{let d=S.current;if(!d)return;let b=d.ownerDocument??document,a=()=>{let y=b.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!d.contains(y.anchorNode))return;let v=y.anchorNode,p=v.nodeType===Node.ELEMENT_NODE?v:v.parentElement,X=(y.isCollapsed?p?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ge=i?.id??r?.id??null;if(X&&X!==ge){L(X);return}performance.now()-u.current<50||N((0,Q.getCursorOffset)(d))};return b.addEventListener("selectionchange",a),()=>b.removeEventListener("selectionchange",a)},[i,r,L,N]),(0,P.useLayoutEffect)(()=>{let d=S.current;d&&(0,Q.renderEditableContent)({input:d,segments:o,newParamId:n,editingParamId:i?.id??null,placeholderText:g??"",isFocused:x,showChipIcons:t,showChipImages:s})},[o,n,i,g,x,t,s]),(0,P.useLayoutEffect)(()=>{let d=le.current,b=n??"";if(le.current=b,!b||b===d)return;let a=S.current;if(!a)return;a.focus();let y=de.current??(0,Q.plainTextLength)(a);(0,Q.setCursorOffset)(a,y)},[n]),(0,P.useLayoutEffect)(()=>{let d=Ce.current,b=i?.id??"";if(Ce.current=b,!b||b===d||m==null)return;let a=S.current;a&&(0,Q.setCursorOffset)(a,m)},[i,m]);let Y=(0,P.useCallback)(()=>{if(se.current)return;let d=S.current;if(!d)return;let b=(0,Q.extractPlainText)(d),y=b.length>0&&b[0]!==b[0].toUpperCase()?b[0].toUpperCase()+b.slice(1):b;K(y)},[K]),Pe=(0,P.useCallback)(()=>{u.current=performance.now(),Y();let d=S.current;d&&T((0,Q.getCursorOffset)(d))},[Y,T]);(0,P.useEffect)(()=>{let d=S.current;if(!d)return;let b=a=>{let y=a,v=y.inputType;if(v==="insertParagraph"||v==="insertLineBreak"||v==="insertFromDrop"){a.preventDefault();return}if(v.startsWith("insert")||v.startsWith("delete")){let p=v.startsWith("delete")?"":y.data??"";F(p)&&a.preventDefault()}};return d.addEventListener("beforeinput",b),()=>d.removeEventListener("beforeinput",b)},[F]);let ce=(0,P.useCallback)(()=>{se.current=!0},[]),Se=(0,P.useCallback)(()=>{se.current=!1,Y()},[Y]),pe=(0,P.useCallback)(d=>{d.preventDefault();let b=S.current;if(!b)return;let a=(d.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!a)return;let y=b.ownerDocument??document,v=y.getSelection();if(!v||v.rangeCount===0)return;let p=v.getRangeAt(0);if(!b.contains(p.startContainer))return;p.deleteContents();let $=y.createTextNode(a);p.insertNode($),p.setStartAfter($),p.collapse(!0),v.removeAllRanges(),v.addRange(p),Y()},[Y]),Ie=(0,P.useCallback)(d=>R(d),[R]),Z=(0,P.useCallback)(()=>G(!0),[G]),he=(0,P.useCallback)(()=>G(!1),[G]),ue=(0,P.useCallback)(()=>S.current?.focus(),[]),me=(0,P.useCallback)(()=>S.current?.blur(),[]),fe=(0,P.useCallback)(()=>{let d=S.current;return d?(0,Q.extractPlainText)(d):""},[]),H=ha()?"plaintext-only":"true";return{inputRef:S,editorProps:{ref:S,contentEditable:H,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":C,"aria-expanded":h,"aria-activedescendant":E,spellCheck:!0,enterKeyHint:"send",onInput:Pe,onKeyDown:Ie,onCompositionStart:ce,onCompositionEnd:Se,onPaste:pe,onFocus:Z,onBlur:he},getPlainText:fe,focus:ue,blur:me}}var ae=require("react/jsx-runtime");function ua(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ht=(0,M.forwardRef)(function({onSubmit:o,onResult:t,onError:s,optionOverrides:n,maskCompletedText:i,className:r,apiConfig:m,additionalContext:w,columns:g,pillPlacement:x="dropdown",mode:h="auto",optionsPosition:C="below",animations:E=!0,dropdownTrigger:k,closeDropdownOnBlur:K,showNonTappableOptions:R,showOptionIcons:T=!0,showChipIcons:N=!0,showChipImages:L=!0,showOptionImages:F=!0,showOptionCounts:G=!0,showSkipButton:S,showProducts:se,productsLayout:le,autoFocus:Ce=!0,onFocus:de,onBlur:u,value:Y,completedParams:Pe,onChange:ce,onParamsChange:Se,products:pe,onProductSelect:Ie,submitButton:Z},he){let ue=(0,M.useRef)(null),me=(0,M.useRef)(null),fe=(0,M.useRef)(()=>{}),H=(0,M.useRef)(null),d=(0,M.useRef)(null);(0,M.useEffect)(()=>{let A=ue.current;if(A)return H.current?H.current.setMode(h):H.current=new Ne.ModeController(A,h),()=>{H.current?.destroy(),H.current=null}},[h]);let b=(0,M.useCallback)(A=>{let Te=d.current?.current;Te&&(Te.focus(),(0,Ne.setCursorOffset)(Te,A))},[]),{completedParams:a,skippedParams:y,identifiedParams:v,isReady:p,customFields:$,suggestionPills:X,setActivePill:ge,skipActivePill:c,segments:be,newParamId:Ee,clearNewParamId:ve,placeholderText:De,isFocused:we,isDropdownOpen:He,isActivePillSelected:J,isLoading:W,activeIndex:Le,listboxId:Be,handleTextChange:et,handleKeyDown:Fe,setFocused:We,editingParam:f,editingIdentified:V,editingAnchor:z,caretOffset:tt,startEditingParam:Bt,handleCaretAfterInput:Ft,handleCaretMove:Kt,replaceEditingRange:Gt,dropdownProps:Wt,reset:_e}=Xe({onSubmit:A=>fe.current(A),onResult:t,onError:s,optionOverrides:n,maskCompletedText:i,apiConfig:m,additionalContext:w,columns:g,dropdownTrigger:k,optionsPosition:C,closeDropdownOnBlur:K,showNonTappableOptions:R,showOptionIcons:T,showOptionImages:F,showOptionCounts:G,showSkipButton:S,showProducts:se,onFocus:de,onBlur:u,value:Y,completedParams:Pe,onChange:ce,onParamsChange:Se,products:pe,onProductSelect:Ie,source:"full-sdk",setCursor:b});(0,M.useEffect)(()=>{if(!Ee)return;let A=window.setTimeout(()=>ve(),650);return()=>window.clearTimeout(A)},[Ee,ve]);let _t=Le>=0?`${Be}-option-${Le}`:void 0,{inputRef:at,editorProps:qt,focus:qe,blur:pt,getPlainText:ht}=Nt({segments:be,newParamId:Ee,editingParam:f,editingIdentified:V,editingAnchor:z,caretOffset:tt,placeholderText:De,isFocused:we,showChipIcons:N,showChipImages:L,isDropdownOpen:He,listboxId:Be,activeDescendantId:_t,autoFocus:Ce,handleTextChange:et,handleKeyDown:Fe,handleCaretAfterInput:Ft,handleCaretMove:Kt,startEditingParam:Bt,replaceEditingRange:Gt,setFocused:We});d.current=at,(0,M.useLayoutEffect)(()=>{let A=me.current,Te=at.current;if(!A||!Te)return;let ut=()=>{let ft=A.firstElementChild;if(!ft)return;let Yt=ft.getBoundingClientRect(),$t=Te.getBoundingClientRect();Yt.top>=$t.bottom-2?A.setAttribute("data-aia-pill-wrapped",""):A.removeAttribute("data-aia-pill-wrapped")};ut();let mt=new ResizeObserver(ut);return mt.observe(Te),()=>mt.disconnect()},[be,X.length,W,at]),(0,M.useImperativeHandle)(he,()=>({focus:qe,blur:pt,reset:_e,setMode:A=>H.current?.setMode(A),skipActivePill:c}),[qe,pt,_e,c]);let Ue=!!be.length||a.length>0,it=(0,M.useCallback)(()=>{if(!Ue)return;let A=ht();o((0,Ne.buildSubmitResult)(A,a,y,{identifiedParams:v,isReady:p,customFields:$})),_e()},[Ue,a,y,v,p,$,o,_e,ht]);fe.current=it;let Ut=(0,M.useCallback)(A=>{A.target?.closest("[data-aia-pill]")||qe()},[qe]),jt=x==="inline",Qt=x==="dropdown";return(0,ae.jsxs)("div",{ref:ue,className:`magicx-aia ${Re.container} ${r??""}`,"data-pill-placement":x,"data-options-position":C,"data-animations":E?"on":"off","data-mode":ua(h),children:[(0,ae.jsx)(Ve,{...Wt,showPills:Qt,productsLayout:le}),(0,ae.jsxs)("div",{className:Re.inputWrapper,"data-aia-input-wrapper":"",onClick:Ut,children:[(0,ae.jsxs)("div",{className:Re.editorArea,"data-aia-editor":"",children:[(0,ae.jsx)("div",{...qt,className:Re.input,"data-aia-input":""}),jt&&(W||X.length>0)&&(0,ae.jsx)("span",{ref:me,className:Re.pillListContainer,"data-aia-pill-list-container":"",children:(0,ae.jsx)(Qe,{pills:X,activePillIndex:0,activeSelected:J,onSelectPill:ge,loading:W})})]}),Z===null?null:Z===void 0?(0,ae.jsx)(Ot,{disabled:!Ue,onClick:it}):(0,ae.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Re.submitSlot,onClick:A=>{Ue&&(A.stopPropagation(),it())},children:Z})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSrc,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2052
2065
|
//# sourceMappingURL=index.js.map
|