@magicx-eng/ai-autocomplete-react 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/index.js +112 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +114 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -323,6 +323,49 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
894
966
|
opacity: 0.25;
|
|
895
967
|
}
|
|
896
968
|
}
|
|
897
|
-
`,document.head.appendChild(e)}var ie={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"};import{cellDay as qt,cellIso as we,dateCellMarks as Ut,isoDate as jt,monthLabel as $t,visibleDateRange as Vt,WEEKDAY_LABELS as Qt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Zt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
969
|
+
`,document.head.appendChild(e)}var ie={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q"};import{cellDay as qt,cellIso as we,dateCellMarks as Ut,isoDate as jt,monthLabel as $t,visibleDateRange as Vt,WEEKDAY_LABELS as Qt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Zt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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 S={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as Z,jsxs as rt}from"react/jsx-runtime";var Yt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:i,view:n,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:
|
|
1132
|
+
`,document.head.appendChild(e)}var S={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};import{jsx as Z,jsxs as rt}from"react/jsx-runtime";var Yt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:r,listboxId:i,view:n,selection:s,onSelect:a,onHighlight:o,onPreviousMonth:f,onNextMonth:v}){let g=jt(new Date),w=Vt({pendingStart:s.rangeStart,highlightedIso:we(e[r]),selected:s.selectedRange});return rt("div",{className:S.datepicker,"data-aia-datepicker":"",children:[rt("div",{className:S.header,children:[Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:u=>u.preventDefault(),onClick:f,children:"\u2039"}),Z("span",{className:S.month,"data-aia-date-month":"","aria-live":"polite",children:$t(n)}),Z("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:u=>u.preventDefault(),onClick:v,children:"\u203A"})]}),Z("div",{className:S.weekdays,"aria-hidden":"true",children:Qt.map((u,x)=>Z("span",{className:S.weekday,children:u},Yt[x]))}),Z("div",{className:S.grid,"data-aia-date-grid":"",children:e.map((u,x)=>Z(Xt,{option:u,id:`${i}-option-${x}`,index:x,isHighlighted:x===r&&u.is_tappable,isToday:we(u)===g,isPast:we(u)!=null&&we(u)<g,marks:Ut(we(u),{selectedIso:s.selectedIso,range:w}),onSelect:a,onHighlight:o},we(u)??`pad-${x}`))})]})}function Xt({option:e,id:r,index:i,isHighlighted:n,isToday:s,isPast:a,marks:o,onSelect:f,onHighlight:v}){let[g,w]=Zt(!1),u=qt(e);if(u==null)return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${S.cell} ${S.blank}`});let x=()=>{w(!0),f(e),setTimeout(()=>w(!1),170)},k=[S.cell,S.day,a?S.past:"",n?S.highlighted:"",s?S.today:"",o.inRange?S.inRange:"",o.selected?S.selected:"",g?S.pressed:""].filter(Boolean).join(" ");return Z("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":n,"aria-label":e.text,tabIndex:0,className:k,onClick:x,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x())},onMouseEnter:()=>v(i),children:Z("span",{className:S.number,children:u})})}import{ATTRIBUTION_URL as Jt,buildAttributionUrl as ea,getFooterHint as ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as aa,useState as ia}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1061
1133
|
display: flex;
|
|
1062
1134
|
flex-wrap: wrap;
|
|
1063
1135
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1097,7 +1169,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1097
1169
|
.aia-cluster[data-justify="around"] {
|
|
1098
1170
|
justify-content: space-around;
|
|
1099
1171
|
}
|
|
1100
|
-
`,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:i="start",noWrap:n=!1,inline:s=!1,className:a,children:o,...
|
|
1172
|
+
`,document.head.appendChild(e)}import{jsx as lt}from"react/jsx-runtime";function Pe({gap:e,align:r="center",justify:i="start",noWrap:n=!1,inline:s=!1,className:a,children:o,...f}){let v=e?{"--aia-cluster-gap":e}:void 0,g={className:a?`aia-cluster ${a}`:"aia-cluster","data-align":r,"data-justify":i,"data-nowrap":n||void 0,"data-inline":s||void 0,style:v,...f};return s?lt("span",{...g,children:o}):lt("div",{...g,children:o})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1101
1173
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1102
1174
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1103
1175
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1288,7 +1360,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1288
1360
|
opacity: 0;
|
|
1289
1361
|
}
|
|
1290
1362
|
}
|
|
1291
|
-
`,document.head.appendChild(e)}var
|
|
1363
|
+
`,document.head.appendChild(e)}var me={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",skeleton:"aia-skeleton-57P0T",skeletonPulse:"aia-skeletonPulse-xGcUy"};import{jsx as oa}from"react/jsx-runtime";var _e={selected:1,first:.7,next:.4,last:.2};function ct({label:e,state:r,rounded:i,loading:n,onClick:s}){let a=[me.pill,i?me.rounded:"",n?me.skeleton:""].filter(Boolean).join(" ");return oa("button",{type:"button","data-aia-pill":"","data-aia-loading":n?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:a,style:{opacity:_e[r]},onMouseDown:o=>o.preventDefault(),onClick:n?void 0:s,disabled:n,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1292
1364
|
position: relative;
|
|
1293
1365
|
z-index: 1;
|
|
1294
1366
|
pointer-events: auto;
|
|
@@ -1298,7 +1370,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1298
1370
|
align-items: center;
|
|
1299
1371
|
vertical-align: middle;
|
|
1300
1372
|
}
|
|
1301
|
-
`,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var na=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:i,activeSelected:n,rounded:s,loading:a}){return a&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:na.map((o,
|
|
1373
|
+
`,document.head.appendChild(e)}var qe={list:"aia-list-qvLqO"};import{jsx as Me}from"react/jsx-runtime";var na=[125,69];function pt(e){return e===0?"first":e===1?"next":"last"}function Oe({pills:e,activePillIndex:r,onSelectPill:i,activeSelected:n,rounded:s,loading:a}){return a&&e.length===0?Me("span",{className:qe.list,"data-aia-pill-list-loading":"",children:na.map((o,f)=>Me("span",{"data-aia-pill-skeleton":"",className:`${me.pill} ${s?me.rounded:""} ${me.skeleton}`,style:{width:o,opacity:_e[pt(f)]}},`skel-${o}`))}):Me("span",{className:qe.list,"data-aia-pill-list-loading":a?"":void 0,children:e.map((o,f)=>{let v=!!n&&f===r;return Me(ct,{label:o.text,state:v?"selected":pt(f),selected:v,rounded:s,loading:a,onClick:()=>i(f)},`${o.type}-${o.text}`)})})}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
|
|
1302
1374
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1303
1375
|
theming one package sees the same result in the other.
|
|
1304
1376
|
|
|
@@ -1470,7 +1542,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1470
1542
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1471
1543
|
);
|
|
1472
1544
|
}
|
|
1473
|
-
`,document.head.appendChild(e)}var _={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE"};import{jsx as
|
|
1545
|
+
`,document.head.appendChild(e)}var _={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE"};import{jsx as fe,jsxs as Ue}from"react/jsx-runtime";function ht({products:e,listboxId:r,onSelect:i,onFocusChange:n,focusable:s=!0}){if(e.length===0)return null;let a=`${r}-products-label`;return Ue("section",{className:_.section,"data-aia-products":"",role:"group","aria-labelledby":a,children:[fe("div",{className:_.label,id:a,children:"Products"}),fe("div",{className:_.row,"data-aia-products-row":"",children:e.map((o,f)=>fe(ra,{product:o,id:`${r}-product-${f}`,onSelect:i,onFocusChange:n,focusable:s},o.id))})]})}function ra({product:e,id:r,onSelect:i,onFocusChange:n,focusable:s}){let a=o=>{o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||o.button!==0||(o.preventDefault(),i(e))};return Ue("a",{id:r,className:_.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:a,onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),i(e))},onFocus:()=>n?.(!0),onBlur:o=>{o.relatedTarget?.closest("[data-aia-dropdown]")||n?.(!1)},children:[fe("span",{className:_.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?fe("img",{className:_.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Ue("span",{className:_.body,children:[e.vendor?fe("span",{className:_.vendor,children:e.vendor}):null,fe("span",{className:_.title,children:e.title}),e.price?fe("span",{className:_.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as va,measureOptionsGrid as wa,needsOptionsGridMeasurement as xa,OPTIONS_GRID_MOBILE_QUERY as ya,optionEnterDelayMs as ka,planOptionsGrid as gt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ca,useLayoutEffect as Pa,useRef as Sa,useState as vt}from"react";import{optionsGridTemplateColumns as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as la,useRef as da}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
1474
1546
|
display: grid;
|
|
1475
1547
|
grid-template-columns: repeat(
|
|
1476
1548
|
auto-fit,
|
|
@@ -1503,7 +1575,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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)}import{jsx as ca}from"react/jsx-runtime";function ut({min:e="16rem",max:r,gap:i,scroll:n=!1,maxHeight:s,scrollResetKey:a,cols:o,template:
|
|
1578
|
+
`,document.head.appendChild(e)}import{jsx as ca}from"react/jsx-runtime";function ut({min:e="16rem",max:r,gap:i,scroll:n=!1,maxHeight:s,scrollResetKey:a,cols:o,template:f,innerRef:v,className:g,children:w,...u}){let x=da(null);la(()=>{if(a===void 0)return;let b=x.current;b&&(b.scrollTop=0)},[a]);let k={"--aia-grid-min":e};return r&&(k["--aia-grid-max"]=r),i&&(k["--aia-grid-gap"]=i),s&&(k["--aia-grid-max-height"]=s),o&&(k.gridTemplateColumns=sa(o)),f&&(k.gridTemplateColumns=f),ca("div",{ref:b=>{x.current=b,v?.(b)},className:g?`aia-grid ${g}`:"aia-grid","data-scroll":n||void 0,style:k,...u,children:w})}import{OPTION_ENTER_DELAY_VAR as pa,optionLabel as ha,sanitizeOptionIconSvg as ua}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ma,useMemo as fa,useRef as ga,useState as mt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
|
|
1507
1579
|
position: relative;
|
|
1508
1580
|
overflow: visible;
|
|
1509
1581
|
display: flex;
|
|
@@ -1694,7 +1766,7 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1694
1766
|
filter: brightness(0.55);
|
|
1695
1767
|
}
|
|
1696
1768
|
}
|
|
1697
|
-
`,document.head.appendChild(e)}var q={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"};import{jsx as ze,jsxs as ba}from"react/jsx-runtime";function
|
|
1769
|
+
`,document.head.appendChild(e)}var q={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"};import{jsx as ze,jsxs as ba}from"react/jsx-runtime";function ft({option:e,isHighlighted:r,onSelect:i,onHighlight:n,id:s,loading:a,showIcon:o=!0,scrollHint:f,enterDelayMs:v=0}){let[g]=mt(v),[w,u]=mt(!1),x=fa(()=>o&&e.icon_svg?ua(e.icon_svg):null,[o,e.icon_svg]),k=ga(void 0);ma(()=>()=>clearTimeout(k.current),[]);let b=()=>{a||!e.is_tappable||w||(u(!0),i(e),clearTimeout(k.current),k.current=setTimeout(()=>u(!1),170))},E=[q.item,r&&!a?q.highlighted:"",e.is_tappable?q.tappable:q.nonTappable,w?q.pressed:"",f?q.scrollHint:""].filter(Boolean).join(" ");return ze("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":a?"":void 0,"data-aia-icon":x&&e.icon?e.icon:void 0,"aria-selected":r,className:E,style:{[pa]:`${g}ms`},tabIndex:a||!e.is_tappable?-1:0,onClick:b,onKeyDown:T=>{!a&&e.is_tappable&&(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),b())},onMouseEnter:!a&&e.is_tappable?n:void 0,children:ba("span",{className:q.content,children:[x&&ze("span",{className:`${q.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:x}}),ze("span",{className:q.text,children:ha(e)}),e.tag&&ze("span",{className:q.tag,children:e.tag})]})})}import{jsx as bt}from"react/jsx-runtime";function Ea(){let[e,r]=vt(va);return Ca(()=>{if(typeof window>"u"||!window.matchMedia)return;let i=window.matchMedia(ya),n=()=>r(i.matches);return n(),i.addEventListener("change",n),()=>i.removeEventListener("change",n)},[]),e}function wt({options:e,activeIndex:r,onSelect:i,onHighlight:n,listboxId:s,loading:a,groupKey:o="",optionsPosition:f="below",showIcons:v=!0}){let g=Ea(),w=Sa(null),[u,x]=vt(null);Pa(()=>{let b=w.current,T=b&&!a&&xa(e.length,g)?wa(b):null;x(T?gt(e.length,g,T.rowWidths,T.gridWidth):null)},[e,g,a]);let k=u??gt(e.length,g,null,null);return bt(ut,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:o,template:k.template,maxHeight:k.maxHeight,innerRef:b=>{w.current=b},"data-aia-group":o,children:e.map((b,E)=>bt(ft,{option:b,isHighlighted:E===r,onSelect:i,onHighlight:()=>n(E),id:`${s}-option-${E}`,loading:a,showIcon:v,scrollHint:!a&&k.scrollHintIndices.includes(E),enterDelayMs:a?0:ka(E,k.cols,e.length,f)},`${o}\0${b.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 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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)}import{jsx as Ia}from"react/jsx-runtime";function xt({space:e,align:r="stretch",className:i,children:n,...s}){let a=e?{"--aia-stack-space":e}:void 0;return Ia("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":r,style:a,...s,children:n})}import{jsx as K,jsxs as je}from"react/jsx-runtime";var La=[159,119,164],Ma=()=>{},yt=()=>{};function Oa(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,n]=Da(r);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function za(e,r){let i=Ne(null);$e(()=>{let n=e.current,s=r.current;if(!n||!s)return;let a=n.querySelector(".aia-grid[data-scroll]");if(i.current&&i.current.grid!==a&&(i.current.controller.destroy(),i.current=null),a&&!i.current){i.current={grid:a,controller:Ta({dropdown:n,grid:a,button:s})};return}i.current?.controller.update()}),$e(()=>()=>{i.current?.controller.destroy(),i.current=null},[])}function Ve({suggestions:e,activeIndex:r,onSelect:i,onHighlight:n,isOpen:s,id:a,className:o,pills:
|
|
1784
|
+
`,document.head.appendChild(e)}import{jsx as Ia}from"react/jsx-runtime";function xt({space:e,align:r="stretch",className:i,children:n,...s}){let a=e?{"--aia-stack-space":e}:void 0;return Ia("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":r,style:a,...s,children:n})}import{jsx as K,jsxs as je}from"react/jsx-runtime";var La=[159,119,164],Ma=()=>{},yt=()=>{};function Oa(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[i,n]=Da(r);if($e(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),a=()=>n(s.matches);return s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),e!==void 0)return e==="auto"?i?"dark":"light":e}function za(e,r){let i=Ne(null);$e(()=>{let n=e.current,s=r.current;if(!n||!s)return;let a=n.querySelector(".aia-grid[data-scroll]");if(i.current&&i.current.grid!==a&&(i.current.controller.destroy(),i.current=null),a&&!i.current){i.current={grid:a,controller:Ta({dropdown:n,grid:a,button:s})};return}i.current?.controller.update()}),$e(()=>()=>{i.current?.controller.destroy(),i.current=null},[])}function Ve({suggestions:e,activeIndex:r,onSelect:i,onHighlight:n,isOpen:s,id:a,className:o,pills:f,onPillClick:v,showPills:g=!0,onSkip:w,showSkipButton:u=!0,showOptionIcons:x=!0,skipDisabled:k=!1,activeSelected:b=!1,isLoading:E=!1,isInputEmpty:T=!1,products:R,onProductSelect:O,onProductFocusChange:Y,formatType:z="options",dateView:P=null,selectedDateIso:j=null,selectedDateRange:ne=null,dateRangeStart:X=null,onPreviousMonth:p,onNextMonth:re,optionsPosition:D="below",mode:se}){let J=Oa(se),$=J!==void 0,ee=Ne(null),V=Ne(null);za(ee,V);let te=e[0]?.options??[],ae=!!(f&&f.length>0&&v),N=!!(R&&R.length>0),H=s&&(te.length>0||g&&ae||E||N),W={suggestions:e,activeIndex:r,pills:f,showPills:g,showSkipButton:u,showOptionIcons:x,skipDisabled:k,activeSelected:b,isLoading:E,isInputEmpty:T,products:R,formatType:z,dateView:P,selectedDateIso:j,selectedDateRange:ne,dateRangeStart:X},B=Ne(W);H&&(B.current=W);let t=H?W:B.current,c=t.suggestions[0],h=c?.options??[],y=t.activeIndex>=0&&!!h[t.activeIndex]?.is_tappable,l=!!(t.pills&&t.pills.length>0&&v),A=t.showPills&&l,Q=t.showPills&&!l&&t.isLoading,L=A||Q,d=l&&t.showSkipButton&&!t.isInputEmpty&&!!w,le=t.pills?.[0]?.text,be=Aa(t.formatType)&&t.dateView!=null,de=h.length>0&&!be,ve=h.length>0&&be&&!t.isLoading,ce=t.isLoading&&!de&&!ve,pe=t.products??[];return je("div",{ref:ee,id:a,role:"listbox","data-aia-dropdown":"","data-options-position":D,"data-mode":J,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":pe.length>0?"":void 0,className:`${$?"magicx-aia ":""}${ie.dropdown} ${H?ie.visible:""} ${o??""}`,onMouseDown:M=>M.preventDefault(),children:[je(xt,{space:"8px",children:[(L||d)&&je(Pe,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:[L&&K("span",{className:ie.pillScroll,"data-aia-pill-scroll":"",children:K(Oe,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:v??(()=>{}),rounded:!0,loading:t.isLoading})}),d&&K("button",{type:"button",tabIndex:-1,className:ie.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":le?`Skip ${le}`:"Skip",onClick:w,children:"skip"})]}),de&&K(wt,{options:h,activeIndex:t.activeIndex,onSelect:i,onHighlight:n,listboxId:a,loading:t.isLoading,groupKey:c?`${c.type} ${c.text}`:"",optionsPosition:D,showIcons:t.showOptionIcons}),ve&&t.dateView&&K(st,{options:h,activeIndex:t.activeIndex,listboxId:a,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:i,onHighlight:n,onPreviousMonth:p??yt,onNextMonth:re??yt}),ce&&K("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:La.map(M=>K("span",{className:ie.skeletonBar,style:{width:M}},`bar-${M}`))}),K(ht,{products:pe,listboxId:a,onSelect:O??Ma,onFocusChange:Y,focusable:H}),K(dt,{isOptionHighlighted:y,isInputEmpty:t.isInputEmpty})]}),K("button",{ref:V,type:"button",tabIndex:-1,className:ie.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Ra,"aria-hidden":"true",children:K("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:K("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as $a,ModeController as Va,setCursorOffset as Qa}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
|
|
1713
1785
|
flex-shrink: 0;
|
|
1714
1786
|
width: 32px;
|
|
1715
1787
|
height: 32px;
|
|
@@ -1725,6 +1797,20 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
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
|
+
}
|
|
1809
|
+
.aia-submitButton-otz7H svg path {
|
|
1810
|
+
fill: none;
|
|
1811
|
+
stroke: currentColor;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1728
1814
|
.aia-submitButton-otz7H:hover {
|
|
1729
1815
|
opacity: 0.85;
|
|
1730
1816
|
}
|
|
@@ -1744,5 +1830,5 @@ import{buildSubmitResult as Ko,cellDay as Go,cellIso as Wo,DATE_RANGE_META_END a
|
|
|
1744
1830
|
);
|
|
1745
1831
|
cursor: default;
|
|
1746
1832
|
}
|
|
1747
|
-
`,document.head.appendChild(e)}var kt={submitButton:"aia-submitButton-otz7H"};import{jsx as Qe}from"react/jsx-runtime";function Ct({disabled:e,onClick:r}){return Qe("button",{type:"button","data-aia-submit":"",className:kt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),r()},"aria-label":"Submit",children:Qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Na,dateSelectionFor as Ha,identifiedParamLabel as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as Fa}from"react";import{useRef as Pt}from"react";function St(e){let r=Pt(e);r.current=e;let i=Object.keys(e??{}).sort().join("\0"),n=Pt({key:"",overrides:void 0});if(n.current.key!==i){let s={};for(let a of Object.keys(e??{})){let o=(m,v,g)=>{let w=r.current?.[a];return w?w(m,v,g):[]};s[a]=o}n.current={key:i,overrides:e?s:void 0}}return{overrides:n.current.overrides,key:i}}import{useRef as Et}from"react";function It(e){let r=Et(e);r.current=e;let i=Et(null);i.current===null&&(i.current={fetch:(s,a)=>{let o=r.current;return o?o.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let n=e!==void 0;return{config:n?i.current:void 0,enabled:n}}var Ka={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function Ze({onSubmit:e,onResult:r,onError:i,optionOverrides:n,maskCompletedText:s,apiConfig:a,additionalContext:o,columns:m=2,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showOptionIcons:x,showSkipButton:k,showProducts:b,onFocus:E,onBlur:T,value:R,completedParams:O,onChange:Y,onParamsChange:z,products:P,onProductSelect:j,source:ne,setCursor:X}){let p=G(null),[re,D]=Fa(null),se=G(e);se.current=e;let J=G(r);J.current=r;let $=G(i);$.current=i;let ee=G(Y);ee.current=Y;let V=G(z);V.current=z;let te=G(E);te.current=E;let ae=G(T);ae.current=T;let N=G(X);N.current=X;let H=G(j);H.current=j;let W=It(P),B=St(n);Ee(()=>{if(typeof document>"u")return;let f=new Na(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:B.overrides,maskCompletedText:s,columns:m,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b,source:ne,value:R,completedParams:O,onSubmit:(...I)=>se.current?.(...I),onResult:(...I)=>J.current?.(...I),onError:(...I)=>$.current?.(...I),onChange:(...I)=>ee.current?.(...I),onParamsChange:(...I)=>V.current?.(...I),onFocus:()=>te.current?.(),onBlur:()=>ae.current?.(),onProductSelect:I=>H.current?.(I),setCursor:I=>N.current?.(I),products:W.config});p.current=f,D(f.getState());let F=f.subscribe(I=>D(I));return()=>{F(),f.destroy(),p.current===f&&(p.current=null)}},[]),Ee(()=>{R!==void 0&&p.current?.setValue(R)},[R]),Ee(()=>{O!==void 0&&p.current?.setCompletedParams(O)},[O]);let t=JSON.stringify(a??null),c;try{c=JSON.stringify(o??null)}catch{c="[unstringifiable]"}Ee(()=>{p.current?.update({apiConfig:a,additionalContext:o,optionOverrides:B.overrides,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b})},[t,c,B.key,v,g,w,u,b]);let h=G(!1);Ee(()=>{if(!h.current){h.current=!0;return}p.current?.update({products:W.config})},[W.enabled]);let y=G(null);y.current===null&&(y.current={handleTextChange:f=>p.current?.handleTextChange(f),handleKeyDown:f=>{let F="nativeEvent"in f?f.nativeEvent:f;p.current?.handleKeyDown(F)},setFocused:f=>p.current?.setFocused(f),startEditingParam:f=>p.current?.startEditingParam(f),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:f=>p.current?.handleCaretAfterInput(f),handleCaretMove:f=>p.current?.handleCaretMove(f),replaceEditingRange:f=>p.current?.replaceEditingRange(f)??!1,setActivePill:f=>p.current?.setActivePill(f),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:f=>p.current?.selectOption(f),selectProduct:f=>p.current?.selectProduct(f),setActiveDropdownIndex:f=>p.current?.setActiveDropdownIndex(f),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let l=y.current,A=Tt(f=>{let F=f.target.value,Fe=F.length>0&&!f.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;p.current?.handleTextChange(Fe)},[]),Q=Tt(f=>{p.current?.handleKeyDown(f.nativeEvent)},[]),L=p.current,d=re??Ka,le=R!==void 0?R:d.text,be=O!==void 0?O:d.completedParams,de=d.actionableSuggestions,ve=de[0],ce=L?.listboxId??"",pe=d.activeDropdownIndex>=0&&L?`${ce}-option-${d.activeDropdownIndex}`:void 0,M=d.editingParam,he=d.editingIdentified,ke=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:he?{type:he.type,text:Ba(he.type),required:!0,options:[]}:null,Te=ke??ve,Be=ke?[ke]:de,Ce=Ha(d),Ae=!L||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:be,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:de,setActivePill:l.setActivePill,skipActivePill:l.skipActivePill,removeLastParam:l.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:l.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ae,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ce,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:M,editingIdentified:he,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:le,placeholder:d.placeholderText||void 0,onChange:A,onKeyDown:Q,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":pe,"aria-autocomplete":"list","aria-controls":ce},reset:l.reset,dropdownProps:{suggestions:Te?[{...Te,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ce,pills:Be,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!M&&!he,showOptionIcons:x??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:le.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:g??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as Ga,renderEditableContent as Wa,setCursorOffset as Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Ye,useLayoutEffect as Xe,useRef as xe}from"react";var He;function _a(){if(He!==void 0)return He;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),He=e.contentEditable==="plaintext-only",He}function Lt(e){let{segments:r,showChipIcons:i=!0,newParamId:n,editingParam:s,editingIdentified:a,editingAnchor:o,caretOffset:m,placeholderText:v,isFocused:g,isDropdownOpen:w,listboxId:u,activeDescendantId:x,autoFocus:k,handleTextChange:b,handleKeyDown:E,handleCaretAfterInput:T,handleCaretMove:R,startEditingParam:O,replaceEditingRange:Y,setFocused:z}=e,P=xe(null),j=xe(!1),ne=xe(""),X=xe(""),p=xe(null),re=xe(0);p.current=m,Ye(()=>{if(!k)return;let t=P.current;if(!t)return;document.activeElement===t?z(!0):t.focus();let c=t.ownerDocument??document,h=c.getSelection(),y=h&&h.rangeCount>0&&t.contains(h.anchorNode);if(h&&!y){let l=c.createRange();l.selectNodeContents(t),l.collapse(!0),h.removeAllRanges(),h.addRange(l)}},[k,z]),Ye(()=>{let t=P.current;if(!t)return;let c=t.ownerDocument??document,h=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!t.contains(y.anchorNode))return;let l=y.anchorNode,A=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,L=(y.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=s?.id??a?.id??null;if(L&&L!==d){O(L);return}performance.now()-re.current<50||R(Rt(t))};return c.addEventListener("selectionchange",h),()=>c.removeEventListener("selectionchange",h)},[s,a,O,R]),Xe(()=>{let t=P.current;t&&Wa({input:t,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:v??"",isFocused:g,showChipIcons:i})},[r,n,s,v,g,i]),Xe(()=>{let t=ne.current,c=n??"";if(ne.current=c,!c||c===t)return;let h=P.current;if(!h)return;h.focus();let y=p.current??Ga(h);Dt(h,y)},[n]),Xe(()=>{let t=X.current,c=s?.id??"";if(X.current=c,!c||c===t||o==null)return;let h=P.current;h&&Dt(h,o)},[s,o]);let D=U(()=>{if(j.current)return;let t=P.current;if(!t)return;let c=At(t),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;b(y)},[b]),se=U(()=>{re.current=performance.now(),D();let t=P.current;t&&T(Rt(t))},[D,T]);Ye(()=>{let t=P.current;if(!t)return;let c=h=>{let y=h,l=y.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){h.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let A=l.startsWith("delete")?"":y.data??"";Y(A)&&h.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[Y]);let J=U(()=>{j.current=!0},[]),$=U(()=>{j.current=!1,D()},[D]),ee=U(t=>{t.preventDefault();let c=P.current;if(!c)return;let h=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let y=c.ownerDocument??document,l=y.getSelection();if(!l||l.rangeCount===0)return;let A=l.getRangeAt(0);if(!c.contains(A.startContainer))return;A.deleteContents();let Q=y.createTextNode(h);A.insertNode(Q),A.setStartAfter(Q),A.collapse(!0),l.removeAllRanges(),l.addRange(A),D()},[D]),V=U(t=>E(t),[E]),te=U(()=>z(!0),[z]),ae=U(()=>z(!1),[z]),N=U(()=>P.current?.focus(),[]),H=U(()=>P.current?.blur(),[]),W=U(()=>{let t=P.current;return t?At(t):""},[]),B=_a()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:B,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":w,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:se,onKeyDown:V,onCompositionStart:J,onCompositionEnd:$,onPaste:ee,onFocus:te,onBlur:ae},getPlainText:W,focus:N,blur:H}}import{jsx as ye,jsxs as et}from"react/jsx-runtime";function Za(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ya=qa(function({onSubmit:r,onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:m,additionalContext:v,columns:g,pillPlacement:w="dropdown",mode:u="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:b,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R=!0,showChipIcons:O=!0,showSkipButton:Y,showProducts:z,autoFocus:P=!0,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,submitButton:$},ee){let V=Ie(null),te=Ie(null),ae=Ie(()=>{}),N=Ie(null),H=Ie(null);Mt(()=>{let C=V.current;if(C)return N.current?N.current.setMode(u):N.current=new Va(C,u),()=>{N.current?.destroy(),N.current=null}},[u]);let W=Je(C=>{let ue=H.current?.current;ue&&(ue.focus(),Qa(ue,C))},[]),{completedParams:B,skippedParams:t,identifiedParams:c,isReady:h,customFields:y,suggestionPills:l,setActivePill:A,skipActivePill:Q,segments:L,newParamId:d,clearNewParamId:le,placeholderText:be,isFocused:de,isDropdownOpen:ve,isActivePillSelected:ce,isLoading:pe,activeIndex:M,listboxId:he,handleTextChange:ke,handleKeyDown:Te,setFocused:Be,editingParam:Ce,editingIdentified:Ae,editingAnchor:f,caretOffset:F,startEditingParam:I,handleCaretAfterInput:Fe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Re}=Ze({onSubmit:C=>ae.current(C),onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,apiConfig:m,additionalContext:v,columns:g,dropdownTrigger:b,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R,showSkipButton:Y,showProducts:z,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,source:"full-sdk",setCursor:W});Mt(()=>{if(!d)return;let C=window.setTimeout(()=>le(),650);return()=>window.clearTimeout(C)},[d,le]);let Ht=M>=0?`${he}-option-${M}`:void 0,{inputRef:Ke,editorProps:Bt,focus:De,blur:tt,getPlainText:at}=Lt({segments:L,newParamId:d,editingParam:Ce,editingIdentified:Ae,editingAnchor:f,caretOffset:F,placeholderText:be,isFocused:de,showChipIcons:O,isDropdownOpen:ve,listboxId:he,activeDescendantId:Ht,autoFocus:P,handleTextChange:ke,handleKeyDown:Te,handleCaretAfterInput:Fe,handleCaretMove:Ot,startEditingParam:I,replaceEditingRange:zt,setFocused:Be});H.current=Ke,ja(()=>{let C=te.current,ue=Ke.current;if(!C||!ue)return;let it=()=>{let nt=C.firstElementChild;if(!nt)return;let Wt=nt.getBoundingClientRect(),_t=ue.getBoundingClientRect();Wt.top>=_t.bottom-2?C.setAttribute("data-aia-pill-wrapped",""):C.removeAttribute("data-aia-pill-wrapped")};it();let ot=new ResizeObserver(it);return ot.observe(ue),()=>ot.disconnect()},[L,l.length,pe,Ke]),Ua(ee,()=>({focus:De,blur:tt,reset:Re,setMode:C=>N.current?.setMode(C),skipActivePill:Q}),[De,tt,Re,Q]);let Le=!!L.length||B.length>0,Ge=Je(()=>{if(!Le)return;let C=at();r($a(C,B,t,{identifiedParams:c,isReady:h,customFields:y})),Re()},[Le,B,t,c,h,y,r,Re,at]);ae.current=Ge;let Ft=Je(C=>{C.target?.closest("[data-aia-pill]")||De()},[De]),Kt=w==="inline",Gt=w==="dropdown";return et("div",{ref:V,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":w,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Za(u),children:[ye(Ve,{...Nt,showPills:Gt}),et("div",{className:ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[et("div",{className:ge.editorArea,"data-aia-editor":"",children:[ye("div",{...Bt,className:ge.input,"data-aia-input":""}),Kt&&(pe||l.length>0)&&ye("span",{ref:te,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ye(Oe,{pills:l,activePillIndex:0,activeSelected:ce,onSelectPill:A,loading:pe})})]}),$===null?null:$===void 0?ye(Ct,{disabled:!Le,onClick:Ge}):ye("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ge.submitSlot,onClick:C=>{Le&&(C.stopPropagation(),Ge())},children:$})]})]})});export{Ya as AIAutocomplete,Ve as AIAutocompleteDropdown,_o as DATE_RANGE_META_END,qo as DATE_RANGE_META_START,Yo as PRODUCT_PATH_PREFIX,sn as WEEKDAY_LABELS,Ko as buildSubmitResult,Go as cellDay,Wo as cellIso,Uo as dateCellMarks,jo as formatDate,$o as formatDateRange,Vo as isoDate,Qo as monthLabel,Zo as optionLabel,Xo as parseDate,Jo as parseLooseDate,en as parseLooseDateRange,tn as productFromMatchedItem,an as productsFromCustomFields,on as sanitizeOptionIconSvg,nn as selectedRangeFor,Ze as useAIAutocomplete,rn as visibleDateRange,ln as withSkippedParams};
|
|
1833
|
+
`,document.head.appendChild(e)}var kt={submitButton:"aia-submitButton-otz7H"};import{jsx as Qe}from"react/jsx-runtime";function Ct({disabled:e,onClick:r}){return Qe("button",{type:"button","data-aia-submit":"",className:kt.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),r()},"aria-label":"Submit",children:Qe("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Qe("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Na,dateSelectionFor as Ha,identifiedParamLabel as Ba}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Tt,useEffect as Ee,useRef as G,useState as Fa}from"react";import{useRef as Pt}from"react";function St(e){let r=Pt(e);r.current=e;let i=Object.keys(e??{}).sort().join("\0"),n=Pt({key:"",overrides:void 0});if(n.current.key!==i){let s={};for(let a of Object.keys(e??{})){let o=(f,v,g)=>{let w=r.current?.[a];return w?w(f,v,g):[]};s[a]=o}n.current={key:i,overrides:e?s:void 0}}return{overrides:n.current.overrides,key:i}}import{useRef as Et}from"react";function It(e){let r=Et(e);r.current=e;let i=Et(null);i.current===null&&(i.current={fetch:(s,a)=>{let o=r.current;return o?o.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let n=e!==void 0;return{config:n?i.current:void 0,enabled:n}}var Ka={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function Ze({onSubmit:e,onResult:r,onError:i,optionOverrides:n,maskCompletedText:s,apiConfig:a,additionalContext:o,columns:f=2,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showOptionIcons:x,showSkipButton:k,showProducts:b,onFocus:E,onBlur:T,value:R,completedParams:O,onChange:Y,onParamsChange:z,products:P,onProductSelect:j,source:ne,setCursor:X}){let p=G(null),[re,D]=Fa(null),se=G(e);se.current=e;let J=G(r);J.current=r;let $=G(i);$.current=i;let ee=G(Y);ee.current=Y;let V=G(z);V.current=z;let te=G(E);te.current=E;let ae=G(T);ae.current=T;let N=G(X);N.current=X;let H=G(j);H.current=j;let W=It(P),B=St(n);Ee(()=>{if(typeof document>"u")return;let m=new Na(document.createElement("div"),{renderMode:"headless",apiConfig:a,additionalContext:o,optionOverrides:B.overrides,maskCompletedText:s,columns:f,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b,source:ne,value:R,completedParams:O,onSubmit:(...I)=>se.current?.(...I),onResult:(...I)=>J.current?.(...I),onError:(...I)=>$.current?.(...I),onChange:(...I)=>ee.current?.(...I),onParamsChange:(...I)=>V.current?.(...I),onFocus:()=>te.current?.(),onBlur:()=>ae.current?.(),onProductSelect:I=>H.current?.(I),setCursor:I=>N.current?.(I),products:W.config});p.current=m,D(m.getState());let F=m.subscribe(I=>D(I));return()=>{F(),m.destroy(),p.current===m&&(p.current=null)}},[]),Ee(()=>{R!==void 0&&p.current?.setValue(R)},[R]),Ee(()=>{O!==void 0&&p.current?.setCompletedParams(O)},[O]);let t=JSON.stringify(a??null),c;try{c=JSON.stringify(o??null)}catch{c="[unstringifiable]"}Ee(()=>{p.current?.update({apiConfig:a,additionalContext:o,optionOverrides:B.overrides,dropdownTrigger:v,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:u,showProducts:b})},[t,c,B.key,v,g,w,u,b]);let h=G(!1);Ee(()=>{if(!h.current){h.current=!0;return}p.current?.update({products:W.config})},[W.enabled]);let y=G(null);y.current===null&&(y.current={handleTextChange:m=>p.current?.handleTextChange(m),handleKeyDown:m=>{let F="nativeEvent"in m?m.nativeEvent:m;p.current?.handleKeyDown(F)},setFocused:m=>p.current?.setFocused(m),startEditingParam:m=>p.current?.startEditingParam(m),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:m=>p.current?.handleCaretAfterInput(m),handleCaretMove:m=>p.current?.handleCaretMove(m),replaceEditingRange:m=>p.current?.replaceEditingRange(m)??!1,setActivePill:m=>p.current?.setActivePill(m),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:m=>p.current?.selectOption(m),selectProduct:m=>p.current?.selectProduct(m),setActiveDropdownIndex:m=>p.current?.setActiveDropdownIndex(m),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let l=y.current,A=Tt(m=>{let F=m.target.value,Fe=F.length>0&&!m.nativeEvent?.isComposing&&F[0]!==F[0].toUpperCase()?F[0].toUpperCase()+F.slice(1):F;p.current?.handleTextChange(Fe)},[]),Q=Tt(m=>{p.current?.handleKeyDown(m.nativeEvent)},[]),L=p.current,d=re??Ka,le=R!==void 0?R:d.text,be=O!==void 0?O:d.completedParams,de=d.actionableSuggestions,ve=de[0],ce=L?.listboxId??"",pe=d.activeDropdownIndex>=0&&L?`${ce}-option-${d.activeDropdownIndex}`:void 0,M=d.editingParam,he=d.editingIdentified,ke=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:he?{type:he.type,text:Ba(he.type),required:!0,options:[]}:null,Te=ke??ve,Be=ke?[ke]:de,Ce=Ha(d),Ae=!L||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:be,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:de,setActivePill:l.setActivePill,skipActivePill:l.skipActivePill,removeLastParam:l.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:l.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ae,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:ce,error:d.error,products:d.products,customFields:d.customFields,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:M,editingIdentified:he,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:le,placeholder:d.placeholderText||void 0,onChange:A,onKeyDown:Q,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":pe,"aria-autocomplete":"list","aria-controls":ce},reset:l.reset,dropdownProps:{suggestions:Te?[{...Te,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:ce,pills:Be,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!M&&!he,showOptionIcons:x??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:le.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Ce.selectedIso,selectedDateRange:Ce.selectedRange,dateRangeStart:Ce.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:g??"below"}}}import{extractPlainText as At,getCursorOffset as Rt,plainTextLength as Ga,renderEditableContent as Wa,setCursorOffset as Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Ye,useLayoutEffect as Xe,useRef as xe}from"react";var He;function _a(){if(He!==void 0)return He;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),He=e.contentEditable==="plaintext-only",He}function Lt(e){let{segments:r,showChipIcons:i=!0,newParamId:n,editingParam:s,editingIdentified:a,editingAnchor:o,caretOffset:f,placeholderText:v,isFocused:g,isDropdownOpen:w,listboxId:u,activeDescendantId:x,autoFocus:k,handleTextChange:b,handleKeyDown:E,handleCaretAfterInput:T,handleCaretMove:R,startEditingParam:O,replaceEditingRange:Y,setFocused:z}=e,P=xe(null),j=xe(!1),ne=xe(""),X=xe(""),p=xe(null),re=xe(0);p.current=f,Ye(()=>{if(!k)return;let t=P.current;if(!t)return;document.activeElement===t?z(!0):t.focus();let c=t.ownerDocument??document,h=c.getSelection(),y=h&&h.rangeCount>0&&t.contains(h.anchorNode);if(h&&!y){let l=c.createRange();l.selectNodeContents(t),l.collapse(!0),h.removeAllRanges(),h.addRange(l)}},[k,z]),Ye(()=>{let t=P.current;if(!t)return;let c=t.ownerDocument??document,h=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!t.contains(y.anchorNode))return;let l=y.anchorNode,A=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement,L=(y.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=s?.id??a?.id??null;if(L&&L!==d){O(L);return}performance.now()-re.current<50||R(Rt(t))};return c.addEventListener("selectionchange",h),()=>c.removeEventListener("selectionchange",h)},[s,a,O,R]),Xe(()=>{let t=P.current;t&&Wa({input:t,segments:r,newParamId:n,editingParamId:s?.id??null,placeholderText:v??"",isFocused:g,showChipIcons:i})},[r,n,s,v,g,i]),Xe(()=>{let t=ne.current,c=n??"";if(ne.current=c,!c||c===t)return;let h=P.current;if(!h)return;h.focus();let y=p.current??Ga(h);Dt(h,y)},[n]),Xe(()=>{let t=X.current,c=s?.id??"";if(X.current=c,!c||c===t||o==null)return;let h=P.current;h&&Dt(h,o)},[s,o]);let D=U(()=>{if(j.current)return;let t=P.current;if(!t)return;let c=At(t),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;b(y)},[b]),se=U(()=>{re.current=performance.now(),D();let t=P.current;t&&T(Rt(t))},[D,T]);Ye(()=>{let t=P.current;if(!t)return;let c=h=>{let y=h,l=y.inputType;if(l==="insertParagraph"||l==="insertLineBreak"||l==="insertFromDrop"){h.preventDefault();return}if(l.startsWith("insert")||l.startsWith("delete")){let A=l.startsWith("delete")?"":y.data??"";Y(A)&&h.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[Y]);let J=U(()=>{j.current=!0},[]),$=U(()=>{j.current=!1,D()},[D]),ee=U(t=>{t.preventDefault();let c=P.current;if(!c)return;let h=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!h)return;let y=c.ownerDocument??document,l=y.getSelection();if(!l||l.rangeCount===0)return;let A=l.getRangeAt(0);if(!c.contains(A.startContainer))return;A.deleteContents();let Q=y.createTextNode(h);A.insertNode(Q),A.setStartAfter(Q),A.collapse(!0),l.removeAllRanges(),l.addRange(A),D()},[D]),V=U(t=>E(t),[E]),te=U(()=>z(!0),[z]),ae=U(()=>z(!1),[z]),N=U(()=>P.current?.focus(),[]),H=U(()=>P.current?.blur(),[]),W=U(()=>{let t=P.current;return t?At(t):""},[]),B=_a()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:B,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":u,"aria-expanded":w,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:se,onKeyDown:V,onCompositionStart:J,onCompositionEnd:$,onPaste:ee,onFocus:te,onBlur:ae},getPlainText:W,focus:N,blur:H}}import{jsx as ye,jsxs as et}from"react/jsx-runtime";function Za(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ya=qa(function({onSubmit:r,onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,className:o,apiConfig:f,additionalContext:v,columns:g,pillPlacement:w="dropdown",mode:u="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:b,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R=!0,showChipIcons:O=!0,showSkipButton:Y,showProducts:z,autoFocus:P=!0,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,submitButton:$},ee){let V=Ie(null),te=Ie(null),ae=Ie(()=>{}),N=Ie(null),H=Ie(null);Mt(()=>{let C=V.current;if(C)return N.current?N.current.setMode(u):N.current=new Va(C,u),()=>{N.current?.destroy(),N.current=null}},[u]);let W=Je(C=>{let ue=H.current?.current;ue&&(ue.focus(),Qa(ue,C))},[]),{completedParams:B,skippedParams:t,identifiedParams:c,isReady:h,customFields:y,suggestionPills:l,setActivePill:A,skipActivePill:Q,segments:L,newParamId:d,clearNewParamId:le,placeholderText:be,isFocused:de,isDropdownOpen:ve,isActivePillSelected:ce,isLoading:pe,activeIndex:M,listboxId:he,handleTextChange:ke,handleKeyDown:Te,setFocused:Be,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,startEditingParam:I,handleCaretAfterInput:Fe,handleCaretMove:Ot,replaceEditingRange:zt,dropdownProps:Nt,reset:Re}=Ze({onSubmit:C=>ae.current(C),onResult:i,onError:n,optionOverrides:s,maskCompletedText:a,apiConfig:f,additionalContext:v,columns:g,dropdownTrigger:b,optionsPosition:x,closeDropdownOnBlur:E,showNonTappableOptions:T,showOptionIcons:R,showSkipButton:Y,showProducts:z,onFocus:j,onBlur:ne,value:X,completedParams:p,onChange:re,onParamsChange:D,products:se,onProductSelect:J,source:"full-sdk",setCursor:W});Mt(()=>{if(!d)return;let C=window.setTimeout(()=>le(),650);return()=>window.clearTimeout(C)},[d,le]);let Ht=M>=0?`${he}-option-${M}`:void 0,{inputRef:Ke,editorProps:Bt,focus:De,blur:tt,getPlainText:at}=Lt({segments:L,newParamId:d,editingParam:Ce,editingIdentified:Ae,editingAnchor:m,caretOffset:F,placeholderText:be,isFocused:de,showChipIcons:O,isDropdownOpen:ve,listboxId:he,activeDescendantId:Ht,autoFocus:P,handleTextChange:ke,handleKeyDown:Te,handleCaretAfterInput:Fe,handleCaretMove:Ot,startEditingParam:I,replaceEditingRange:zt,setFocused:Be});H.current=Ke,ja(()=>{let C=te.current,ue=Ke.current;if(!C||!ue)return;let it=()=>{let nt=C.firstElementChild;if(!nt)return;let Wt=nt.getBoundingClientRect(),_t=ue.getBoundingClientRect();Wt.top>=_t.bottom-2?C.setAttribute("data-aia-pill-wrapped",""):C.removeAttribute("data-aia-pill-wrapped")};it();let ot=new ResizeObserver(it);return ot.observe(ue),()=>ot.disconnect()},[L,l.length,pe,Ke]),Ua(ee,()=>({focus:De,blur:tt,reset:Re,setMode:C=>N.current?.setMode(C),skipActivePill:Q}),[De,tt,Re,Q]);let Le=!!L.length||B.length>0,Ge=Je(()=>{if(!Le)return;let C=at();r($a(C,B,t,{identifiedParams:c,isReady:h,customFields:y})),Re()},[Le,B,t,c,h,y,r,Re,at]);ae.current=Ge;let Ft=Je(C=>{C.target?.closest("[data-aia-pill]")||De()},[De]),Kt=w==="inline",Gt=w==="dropdown";return et("div",{ref:V,className:`magicx-aia ${ge.container} ${o??""}`,"data-pill-placement":w,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Za(u),children:[ye(Ve,{...Nt,showPills:Gt}),et("div",{className:ge.inputWrapper,"data-aia-input-wrapper":"",onClick:Ft,children:[et("div",{className:ge.editorArea,"data-aia-editor":"",children:[ye("div",{...Bt,className:ge.input,"data-aia-input":""}),Kt&&(pe||l.length>0)&&ye("span",{ref:te,className:ge.pillListContainer,"data-aia-pill-list-container":"",children:ye(Oe,{pills:l,activePillIndex:0,activeSelected:ce,onSelectPill:A,loading:pe})})]}),$===null?null:$===void 0?ye(Ct,{disabled:!Le,onClick:Ge}):ye("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:ge.submitSlot,onClick:C=>{Le&&(C.stopPropagation(),Ge())},children:$})]})]})});export{Ya as AIAutocomplete,Ve as AIAutocompleteDropdown,_o as DATE_RANGE_META_END,qo as DATE_RANGE_META_START,Yo as PRODUCT_PATH_PREFIX,sn as WEEKDAY_LABELS,Ko as buildSubmitResult,Go as cellDay,Wo as cellIso,Uo as dateCellMarks,jo as formatDate,$o as formatDateRange,Vo as isoDate,Qo as monthLabel,Zo as optionLabel,Xo as parseDate,Jo as parseLooseDate,en as parseLooseDateRange,tn as productFromMatchedItem,an as productsFromCustomFields,on as sanitizeOptionIconSvg,nn as selectedRangeFor,Ze as useAIAutocomplete,rn as visibleDateRange,ln as withSkippedParams};
|
|
1748
1834
|
//# sourceMappingURL=index.mjs.map
|