@magicx-eng/ai-autocomplete-react 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -18
- package/dist/index.d.mts +15 -9
- package/dist/index.d.ts +15 -9
- package/dist/index.js +49 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as Li,cellDay as Oi,cellIso as Mi,DATE_RANGE_META_END as Ni,DATE_RANGE_META_START as zi,dateCellMarks as Bi,formatDate as Gi,formatDateRange as Fi,isoDate as Hi,monthLabel as Ki,parseDate as Wi,parseLooseDate as qi,parseLooseDateRange as Ui,selectedRangeFor as ji,visibleDateRange as $i,WEEKDAY_LABELS as Vi,withSkippedParams as Yi}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as za,useCallback as Xe,useEffect as Tt,useImperativeHandle as Ba,useLayoutEffect as Ga,useRef as Ie}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.AIAutocomplete-module_container_KKjFU {
|
|
2
2
|
position: relative;
|
|
3
3
|
/* Inherits the host page's font by default. Consumers can pin a specific
|
|
4
4
|
font on the library via \`--aia-font-family: 'Custom Font'\` without
|
|
@@ -193,7 +193,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
193
193
|
opacity: 0;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
`,document.head.appendChild(e)}var
|
|
196
|
+
`,document.head.appendChild(e)}var he={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};import{attachScrollArrow as ya,isCalendarFormat as _a,SCROLL_ARROW_LABEL as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ue,useRef as Le,useState as Pa}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
197
197
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
198
198
|
* Consumer CSS always wins without !important.
|
|
199
199
|
*
|
|
@@ -620,12 +620,13 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
620
620
|
disc at the bottom-centre of the option list, shown while the list can still
|
|
621
621
|
scroll down. It rests just above the grid's reserved band
|
|
622
622
|
(--aia-scroll-arrow-bottom is measured and set inline by the controller so it
|
|
623
|
-
tracks the grid's bottom edge in every layout)
|
|
624
|
-
the dropdown's lower edge, where the
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
623
|
+
tracks the grid's bottom edge in every layout). Its two moves differ on
|
|
624
|
+
purpose: it ENTERS by rising from below the dropdown's lower edge, where the
|
|
625
|
+
dropdown's overflow clips it \u2014 so it emerges from behind the footer \u2014 and it
|
|
626
|
+
LEAVES by dissolving in place under data-aia-leaving (see below). z-index 2
|
|
627
|
+
puts it over the option rows and under the footer (z-index 3). Declarations
|
|
628
|
+
mirror vanilla's .magicx-aia-scroll-arrow and Angular's copy \u2014 change all
|
|
629
|
+
three in the same commit. */
|
|
629
630
|
.AIAutocompleteDropdown-module_scrollArrow_uUzV0 {
|
|
630
631
|
position: absolute;
|
|
631
632
|
left: 50%;
|
|
@@ -649,15 +650,34 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
649
650
|
box-shadow: var(--aia-scroll-arrow-shadow, 0 2px 8px rgba(0, 0, 0, 0.12));
|
|
650
651
|
cursor: pointer;
|
|
651
652
|
pointer-events: none;
|
|
653
|
+
/* Parked: below the panel's edge (clipped), and transparent so the re-park
|
|
654
|
+
after a fade \u2014 scale back out to here \u2014 never shows. Only the transform
|
|
655
|
+
transitions here, so the disc rises at full strength instead of fading
|
|
656
|
+
in on the way up. */
|
|
657
|
+
opacity: 0;
|
|
652
658
|
transform: translateY(calc(100% + var(--aia-scroll-arrow-bottom, 8px) + 4px));
|
|
653
659
|
transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
654
660
|
}
|
|
655
661
|
|
|
656
662
|
.AIAutocompleteDropdown-module_scrollArrow_uUzV0[data-aia-visible] {
|
|
657
663
|
pointer-events: auto;
|
|
664
|
+
opacity: 1;
|
|
658
665
|
transform: translateY(0);
|
|
659
666
|
}
|
|
660
667
|
|
|
668
|
+
/* Leaving: dissolve where it stands \u2014 no travel. Ease-out so most of the fade
|
|
669
|
+
happens at once and the last of it lingers; the shrink keeps it from reading
|
|
670
|
+
as a flat cut. The controller holds this attribute for SCROLL_ARROW_LEAVE_MS
|
|
671
|
+
(scrollArrow.ts) \u2014 keep the two durations equal. */
|
|
672
|
+
.AIAutocompleteDropdown-module_scrollArrow_uUzV0[data-aia-leaving] {
|
|
673
|
+
pointer-events: none;
|
|
674
|
+
opacity: 0;
|
|
675
|
+
transform: translateY(0) scale(0.86);
|
|
676
|
+
transition:
|
|
677
|
+
opacity 240ms cubic-bezier(0.22, 0.61, 0.36, 1),
|
|
678
|
+
transform 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
|
|
679
|
+
}
|
|
680
|
+
|
|
661
681
|
.AIAutocompleteDropdown-module_scrollArrow_uUzV0:hover {
|
|
662
682
|
color: var(
|
|
663
683
|
--aia-scroll-arrow-color-hover,
|
|
@@ -667,6 +687,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
667
687
|
|
|
668
688
|
@media (prefers-reduced-motion: reduce) {
|
|
669
689
|
.AIAutocompleteDropdown-module_scrollArrow_uUzV0,
|
|
690
|
+
.AIAutocompleteDropdown-module_scrollArrow_uUzV0[data-aia-leaving],
|
|
670
691
|
.AIAutocompleteDropdown-module_dropdown_yz2KC {
|
|
671
692
|
transition-duration: 0s;
|
|
672
693
|
}
|
|
@@ -780,7 +801,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
780
801
|
opacity: 0.25;
|
|
781
802
|
}
|
|
782
803
|
}
|
|
783
|
-
`,document.head.appendChild(e)}var
|
|
804
|
+
`,document.head.appendChild(e)}var ne={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",scrollArrow:"AIAutocompleteDropdown-module_scrollArrow_uUzV0",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",pillScroll:"AIAutocompleteDropdown-module_pillScroll_Tpzus",skip:"AIAutocompleteDropdown-module_skip_7-olS",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{cellDay as Ft,cellIso as be,dateCellMarks as Ht,isoDate as Kt,monthLabel as Wt,visibleDateRange as qt,WEEKDAY_LABELS as Ut}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as jt}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) ---
|
|
784
805
|
|
|
785
806
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
786
807
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -926,6 +947,13 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
926
947
|
var(--aia-date-today-ring, var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb)));
|
|
927
948
|
}
|
|
928
949
|
|
|
950
|
+
/* Between the two ends of a picked span. The band sits on the CELL, not on the
|
|
951
|
+
number square inside it, so consecutive days join into one continuous strip
|
|
952
|
+
instead of a row of separate pills \u2014 the ends stay the two filled squares. */
|
|
953
|
+
.DateGrid-module_inRange_r9S2q {
|
|
954
|
+
background: var(--aia-date-range-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06));
|
|
955
|
+
}
|
|
956
|
+
|
|
929
957
|
.DateGrid-module_selected_28KDn .DateGrid-module_number_aoT01 {
|
|
930
958
|
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
931
959
|
background: var(--aia-date-selected-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.12));
|
|
@@ -936,7 +964,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
936
964
|
opacity: 0.8;
|
|
937
965
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
938
966
|
}
|
|
939
|
-
`,document.head.appendChild(e)}var
|
|
967
|
+
`,document.head.appendChild(e)}var I={datepicker:"DateGrid-module_datepicker_6RrTs",header:"DateGrid-module_header_z4LRk",month:"DateGrid-module_month_urB2T",nav:"DateGrid-module_nav_ap4AN",weekdays:"DateGrid-module_weekdays_3EA3q",grid:"DateGrid-module_grid_mQCgw",weekday:"DateGrid-module_weekday_3lF4B",cell:"DateGrid-module_cell_59k0y",number:"DateGrid-module_number_aoT01",day:"DateGrid-module_day_cB3u9",blank:"DateGrid-module_blank_ivgRC",past:"DateGrid-module_past_CEZsj",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",inRange:"DateGrid-module_inRange_r9S2q",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};import{jsx as $,jsxs as it}from"react/jsx-runtime";var $t=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function nt({options:e,activeIndex:r,listboxId:a,view:i,selection:s,onSelect:o,onHighlight:n,onPreviousMonth:f,onNextMonth:g}){let v=Kt(new Date),_=qt({pendingStart:s.rangeStart,highlightedIso:be(e[r]),selected:s.selectedRange});return it("div",{className:I.datepicker,"data-aia-datepicker":"",children:[it("div",{className:I.header,children:[$("button",{type:"button",tabIndex:-1,className:I.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:p=>p.preventDefault(),onClick:f,children:"\u2039"}),$("span",{className:I.month,"data-aia-date-month":"","aria-live":"polite",children:Wt(i)}),$("button",{type:"button",tabIndex:-1,className:I.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:p=>p.preventDefault(),onClick:g,children:"\u203A"})]}),$("div",{className:I.weekdays,"aria-hidden":"true",children:Ut.map((p,w)=>$("span",{className:I.weekday,children:p},$t[w]))}),$("div",{className:I.grid,"data-aia-date-grid":"",children:e.map((p,w)=>$(Vt,{option:p,id:`${a}-option-${w}`,index:w,isHighlighted:w===r&&p.is_tappable,isToday:be(p)===v,isPast:be(p)!=null&&be(p)<v,marks:Ht(be(p),{selectedIso:s.selectedIso,range:_}),onSelect:o,onHighlight:n},be(p)??`pad-${w}`))})]})}function Vt({option:e,id:r,index:a,isHighlighted:i,isToday:s,isPast:o,marks:n,onSelect:f,onHighlight:g}){let[v,_]=jt(!1),p=Ft(e);if(p==null)return $("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${I.cell} ${I.blank}`});let w=()=>{_(!0),f(e),setTimeout(()=>_(!1),170)},y=[I.cell,I.day,o?I.past:"",i?I.highlighted:"",s?I.today:"",n.inRange?I.inRange:"",n.selected?I.selected:"",v?I.pressed:""].filter(Boolean).join(" ");return $("div",{id:r,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:y,onClick:w,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),w())},onMouseEnter:()=>g(a),children:$("span",{className:I.number,children:p})})}import{ATTRIBUTION_URL as Yt,buildAttributionUrl as Qt,getFooterHint as Xt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Zt,useState as Jt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
|
|
940
968
|
.aia-cluster {
|
|
941
969
|
display: flex;
|
|
942
970
|
flex-wrap: wrap;
|
|
@@ -978,7 +1006,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
978
1006
|
justify-content: space-around;
|
|
979
1007
|
}
|
|
980
1008
|
}
|
|
981
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1009
|
+
`,document.head.appendChild(e)}import{jsx as rt}from"react/jsx-runtime";function _e({gap:e,align:r="center",justify:a="start",noWrap:i=!1,inline:s=!1,className:o,children:n,...f}){let g=e?{"--aia-cluster-gap":e}:void 0,v={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":r,"data-justify":a,"data-nowrap":i||void 0,"data-inline":s||void 0,style:g,...f};return s?rt("span",{...v,children:n}):rt("div",{...v,children:n})}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
|
|
982
1010
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
983
1011
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
984
1012
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1112,7 +1140,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1112
1140
|
justify-content: flex-end;
|
|
1113
1141
|
}
|
|
1114
1142
|
}
|
|
1115
|
-
`,document.head.appendChild(e)}var
|
|
1143
|
+
`,document.head.appendChild(e)}var re={footer:"DropdownFooter-module_footer_qQQ7x",hintGroup:"DropdownFooter-module_hintGroup_ZzbPf",brandLink:"DropdownFooter-module_brandLink_r4f3R",key:"DropdownFooter-module_key_Bz1H-",hint:"DropdownFooter-module_hint_GKEOH",brand:"DropdownFooter-module_brand_Al-lR",badge:"DropdownFooter-module_badge_Fk9vg",row:"DropdownFooter-module_row_BgZ6Q"};import{jsx as ke,jsxs as Ge}from"react/jsx-runtime";function st({isOptionHighlighted:e=!1,isInputEmpty:r=!1}){let{key:a,hint:i}=Xt(e,r),[s,o]=Jt(Yt);return Zt(()=>{o(Qt())},[]),ke("footer",{className:re.footer,"data-aia-footer":"",children:Ge(_e,{justify:"between",noWrap:!0,className:re.row,children:[Ge(_e,{gap:"5px",className:re.hintGroup,children:[ke("kbd",{className:re.key,children:a}),ke("span",{className:re.hint,children:i})]}),Ge("a",{className:re.brandLink,href:s,target:"_blank",rel:"noopener noreferrer",children:[ke("span",{className:re.brand,children:"AI"}),ke("span",{className:re.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
1116
1144
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1117
1145
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1118
1146
|
as it was when the outline was dashed. */
|
|
@@ -1169,7 +1197,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1169
1197
|
opacity: 0;
|
|
1170
1198
|
}
|
|
1171
1199
|
}
|
|
1172
|
-
`,document.head.appendChild(e)}var
|
|
1200
|
+
`,document.head.appendChild(e)}var ue={pill:"ParamPill-module_pill_6Ga7S",fadeIn:"ParamPill-module_fadeIn_Ux4eQ",rounded:"ParamPill-module_rounded_y7xA9",skeleton:"ParamPill-module_skeleton_57P0T",skeletonPulse:"ParamPill-module_skeletonPulse_xGcUy"};import{jsx as ea}from"react/jsx-runtime";var Fe={selected:1,first:.7,next:.4,last:.2};function lt({label:e,state:r,rounded:a,loading:i,onClick:s}){let o=[ue.pill,a?ue.rounded:"",i?ue.skeleton:""].filter(Boolean).join(" ");return ea("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:Fe[r]},onMouseDown:n=>n.preventDefault(),onClick:i?void 0:s,disabled:i,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
|
|
1173
1201
|
position: relative;
|
|
1174
1202
|
z-index: 1;
|
|
1175
1203
|
pointer-events: auto;
|
|
@@ -1179,7 +1207,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1179
1207
|
align-items: center;
|
|
1180
1208
|
vertical-align: middle;
|
|
1181
1209
|
}
|
|
1182
|
-
`,document.head.appendChild(e)}var
|
|
1210
|
+
`,document.head.appendChild(e)}var He={list:"PillList-module_list_qvLqO"};import{jsx as Te}from"react/jsx-runtime";var ta=[125,69];function dt(e){return e===0?"first":e===1?"next":"last"}function Re({pills:e,activePillIndex:r,onSelectPill:a,activeSelected:i,rounded:s,loading:o}){return o&&e.length===0?Te("span",{className:He.list,"data-aia-pill-list-loading":"",children:ta.map((n,f)=>Te("span",{"data-aia-pill-skeleton":"",className:`${ue.pill} ${s?ue.rounded:""} ${ue.skeleton}`,style:{width:n,opacity:Fe[dt(f)]}},`skel-${n}`))}):Te("span",{className:He.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((n,f)=>{let g=!!i&&f===r;return Te(lt,{label:n.text,state:g?"selected":dt(f),selected:g,rounded:s,loading:o,onClick:()=>a(f)},`${n.type}-${n.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
|
|
1183
1211
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1184
1212
|
theming one package sees the same result in the other.
|
|
1185
1213
|
|
|
@@ -1346,7 +1374,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1346
1374
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1347
1375
|
);
|
|
1348
1376
|
}
|
|
1349
|
-
`,document.head.appendChild(e)}var
|
|
1377
|
+
`,document.head.appendChild(e)}var H={section:"ProductStrip-module_section_Hugfg",label:"ProductStrip-module_label_nuc93",row:"ProductStrip-module_row_WDVBX",card:"ProductStrip-module_card_JBGYT",media:"ProductStrip-module_media_RrbGe",image:"ProductStrip-module_image_5pNL7",body:"ProductStrip-module_body_ly032",vendor:"ProductStrip-module_vendor_Gvu7G",title:"ProductStrip-module_title_gCNmq",price:"ProductStrip-module_price_gULcE"};import{jsx as me,jsxs as Ke}from"react/jsx-runtime";function ct({products:e,listboxId:r,onSelect:a,onFocusChange:i,focusable:s=!0}){if(e.length===0)return null;let o=`${r}-products-label`;return Ke("section",{className:H.section,"data-aia-products":"",role:"group","aria-labelledby":o,children:[me("div",{className:H.label,id:o,children:"Products"}),me("div",{className:H.row,"data-aia-products-row":"",children:e.map((n,f)=>me(aa,{product:n,id:`${r}-product-${f}`,onSelect:a,onFocusChange:i,focusable:s},n.id))})]})}function aa({product:e,id:r,onSelect:a,onFocusChange:i,focusable:s}){let o=n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),a(e))};return Ke("a",{id:r,className:H.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:s?0:-1,onClick:o,onKeyDown:n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),a(e))},onFocus:()=>i?.(!0),onBlur:n=>{n.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[me("span",{className:H.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?me("img",{className:H.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),Ke("span",{className:H.body,children:[e.vendor?me("span",{className:H.vendor,children:e.vendor}):null,me("span",{className:H.title,children:e.title}),e.price?me("span",{className:H.price,children:e.price}):null]})]})}import{isOptionsGridMobileViewport as pa,measureOptionsGrid as ua,needsOptionsGridMeasurement as ma,OPTIONS_GRID_MOBILE_QUERY as ha,optionEnterDelayMs as fa,planOptionsGrid as ht}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ga,useLayoutEffect as ba,useRef as va,useState as gt}from"react";import{optionsGridTemplateColumns as oa}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as ia,useRef as na}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
|
|
1350
1378
|
.aia-grid {
|
|
1351
1379
|
display: grid;
|
|
1352
1380
|
grid-template-columns: repeat(
|
|
@@ -1381,7 +1409,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1381
1409
|
border-radius: 3px;
|
|
1382
1410
|
}
|
|
1383
1411
|
}
|
|
1384
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1412
|
+
`,document.head.appendChild(e)}import{jsx as ra}from"react/jsx-runtime";function pt({min:e="16rem",max:r,gap:a,scroll:i=!1,maxHeight:s,scrollResetKey:o,cols:n,template:f,innerRef:g,className:v,children:_,...p}){let w=na(null);ia(()=>{if(o===void 0)return;let b=w.current;b&&(b.scrollTop=0)},[o]);let y={"--aia-grid-min":e};return r&&(y["--aia-grid-max"]=r),a&&(y["--aia-grid-gap"]=a),s&&(y["--aia-grid-max-height"]=s),n&&(y.gridTemplateColumns=oa(n)),f&&(y.gridTemplateColumns=f),ra("div",{ref:b=>{w.current=b,g?.(b)},className:v?`aia-grid ${v}`:"aia-grid","data-scroll":i||void 0,style:y,...p,children:_})}import{OPTION_ENTER_DELAY_VAR as sa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as la,useRef as da,useState as ut}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.SuggestionItem-module_item_d4vpD {
|
|
1385
1413
|
position: relative;
|
|
1386
1414
|
overflow: visible;
|
|
1387
1415
|
display: flex;
|
|
@@ -1461,12 +1489,12 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1461
1489
|
option steps back in opacity \u2014 no fill, no glow, the hierarchy carries it. */
|
|
1462
1490
|
.SuggestionItem-module_pressed_98o-r {
|
|
1463
1491
|
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
1464
|
-
animation: SuggestionItem-module_pressCompress_ICV3q
|
|
1492
|
+
animation: SuggestionItem-module_pressCompress_ICV3q 170ms ease forwards;
|
|
1465
1493
|
}
|
|
1466
1494
|
|
|
1467
1495
|
[role="listbox"]:has(.SuggestionItem-module_pressed_98o-r) .SuggestionItem-module_item_d4vpD:not(.SuggestionItem-module_pressed_98o-r) {
|
|
1468
1496
|
opacity: 0.35;
|
|
1469
|
-
transition: opacity
|
|
1497
|
+
transition: opacity 60ms ease;
|
|
1470
1498
|
}
|
|
1471
1499
|
|
|
1472
1500
|
@keyframes SuggestionItem-module_pressCompress_ICV3q {
|
|
@@ -1528,7 +1556,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1528
1556
|
filter: brightness(0.55);
|
|
1529
1557
|
}
|
|
1530
1558
|
}
|
|
1531
|
-
`,document.head.appendChild(e)}var
|
|
1559
|
+
`,document.head.appendChild(e)}var V={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",riseIn:"SuggestionItem-module_riseIn_etXZT",content:"SuggestionItem-module_content_T-Qba",tappable:"SuggestionItem-module_tappable_70KcX",nonTappable:"SuggestionItem-module_nonTappable_xSZM-",highlighted:"SuggestionItem-module_highlighted_Hb0SU",tag:"SuggestionItem-module_tag_e3Fwe",pressed:"SuggestionItem-module_pressed_98o-r",pressCompress:"SuggestionItem-module_pressCompress_ICV3q",scrollHint:"SuggestionItem-module_scrollHint_xKXPt",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};import{jsx as We,jsxs as ca}from"react/jsx-runtime";function mt({option:e,isHighlighted:r,onSelect:a,onHighlight:i,id:s,loading:o,scrollHint:n,enterDelayMs:f=0}){let[g]=ut(f),[v,_]=ut(!1),p=da(void 0);la(()=>()=>clearTimeout(p.current),[]);let w=()=>{o||!e.is_tappable||v||(_(!0),a(e),clearTimeout(p.current),p.current=setTimeout(()=>_(!1),170))},y=[V.item,r&&!o?V.highlighted:"",e.is_tappable?V.tappable:V.nonTappable,v?V.pressed:"",n?V.scrollHint:""].filter(Boolean).join(" ");return We("div",{id:s,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"aria-selected":r,className:y,style:{[sa]:`${g}ms`},tabIndex:o||!e.is_tappable?-1:0,onClick:w,onKeyDown:b=>{!o&&e.is_tappable&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),w())},onMouseEnter:!o&&e.is_tappable?i:void 0,children:ca("span",{className:V.content,children:[We("span",{className:V.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&We("span",{className:V.tag,children:e.tag})]})})}import{jsx as ft}from"react/jsx-runtime";function wa(){let[e,r]=gt(pa);return ga(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(ha),i=()=>r(a.matches);return i(),a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),e}function bt({options:e,activeIndex:r,onSelect:a,onHighlight:i,listboxId:s,loading:o,groupKey:n="",optionsPosition:f="below"}){let g=wa(),v=va(null),[_,p]=gt(null);ba(()=>{let y=v.current,D=y&&!o&&ma(e.length,g)?ua(y):null;p(D?ht(e.length,g,D.rowWidths,D.gridWidth):null)},[e,g,o]);let w=_??ht(e.length,g,null,null);return ft(pt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:n,template:w.template,maxHeight:w.maxHeight,innerRef:y=>{v.current=y},"data-aia-group":n,children:e.map((y,b)=>ft(mt,{option:y,isHighlighted:b===r,onSelect:a,onHighlight:()=>i(b),id:`${s}-option-${b}`,loading:o,scrollHint:!o&&w.scrollHintIndices.includes(b),enterDelayMs:o?0:fa(b,w.cols,e.length,f)},`${n}\0${y.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
|
|
1532
1560
|
.aia-stack {
|
|
1533
1561
|
display: flex;
|
|
1534
1562
|
flex-direction: column;
|
|
@@ -1545,7 +1573,7 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1545
1573
|
}
|
|
1546
1574
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1547
1575
|
}
|
|
1548
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1576
|
+
`,document.head.appendChild(e)}import{jsx as xa}from"react/jsx-runtime";function vt({space:e,align:r="stretch",className:a,children:i,...s}){let o=e?{"--aia-stack-space":e}:void 0;return xa("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":r,style:o,...s,children:i})}import{jsx as B,jsxs as qe}from"react/jsx-runtime";var Ia=[159,119,164],Aa=()=>{},wt=()=>{};function Sa(e){let r=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,i]=Pa(r);if(Ue(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let s=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>i(s.matches);return s.addEventListener("change",o),()=>s.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function Da(e,r){let a=Le(null);Ue(()=>{let i=e.current,s=r.current;if(!i||!s)return;let o=i.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==o&&(a.current.controller.destroy(),a.current=null),o&&!a.current){a.current={grid:o,controller:ya({dropdown:i,grid:o,button:s})};return}a.current?.controller.update()}),Ue(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function je({suggestions:e,activeIndex:r,onSelect:a,onHighlight:i,isOpen:s,id:o,className:n,pills:f,onPillClick:g,showPills:v=!0,onSkip:_,showSkipButton:p=!0,skipDisabled:w=!1,activeSelected:y=!1,isLoading:b=!1,isInputEmpty:D=!1,products:C,onProductSelect:Y,onProductFocusChange:Q,formatType:L="options",dateView:k=null,selectedDateIso:X=null,selectedDateRange:Z=null,dateRangeStart:u=null,onPreviousMonth:se,onNextMonth:J,optionsPosition:E="below",mode:W}){let ee=Sa(W),te=ee!==void 0,q=Le(null),U=Le(null);Da(q,U);let R=e[0]?.options??[],ae=!!(f&&f.length>0&&g),le=!!(C&&C.length>0),T=s&&(R.length>0||v&&ae||b||le),O={suggestions:e,activeIndex:r,pills:f,showPills:v,showSkipButton:p,skipDisabled:w,activeSelected:y,isLoading:b,isInputEmpty:D,products:C,formatType:L,dateView:k,selectedDateIso:X,selectedDateRange:Z,dateRangeStart:u},oe=Le(O);T&&(oe.current=O);let t=T?O:oe.current,c=t.suggestions[0],m=c?.options??[],l=t.activeIndex>=0&&!!m[t.activeIndex]?.is_tappable,x=!!(t.pills&&t.pills.length>0&&g),A=t.showPills&&x,M=t.showPills&&!x&&t.isLoading,d=A||M,ie=x&&t.showSkipButton&&!t.isInputEmpty&&!!_,fe=t.pills?.[0]?.text,de=_a(t.formatType)&&t.dateView!=null,ce=m.length>0&&!de,j=m.length>0&&de,ge=t.isLoading&&!ce&&!j,F=t.products??[];return qe("div",{ref:q,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":E,"data-mode":ee,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":F.length>0?"":void 0,className:`${te?"magicx-aia ":""}${ne.dropdown} ${T?ne.visible:""} ${n??""}`,onMouseDown:N=>N.preventDefault(),children:[qe(vt,{space:"8px",children:[(d||ie)&&qe(_e,{noWrap:!0,className:ne.pillBar,"data-aia-pillbar":"",children:[d&&B("span",{className:ne.pillScroll,"data-aia-pill-scroll":"",children:B(Re,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:g??(()=>{}),rounded:!0,loading:t.isLoading})}),ie&&B("button",{type:"button",tabIndex:-1,className:ne.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":fe?`Skip ${fe}`:"Skip",onClick:_,children:"skip"})]}),ce&&B(bt,{options:m,activeIndex:t.activeIndex,onSelect:a,onHighlight:i,listboxId:o,loading:t.isLoading,groupKey:c?`${c.type} ${c.text}`:"",optionsPosition:E}),j&&t.dateView&&B(nt,{options:m,activeIndex:t.activeIndex,listboxId:o,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:a,onHighlight:i,onPreviousMonth:se??wt,onNextMonth:J??wt}),ge&&B("div",{className:ne.skeletonBars,"data-aia-skeleton-bars":"",children:Ia.map(N=>B("span",{className:ne.skeletonBar,style:{width:N}},`bar-${N}`))}),B(ct,{products:F,listboxId:o,onSelect:Y??Aa,onFocusChange:Q,focusable:T}),B(st,{isOptionHighlighted:l,isInputEmpty:t.isInputEmpty})]}),B("button",{ref:U,type:"button",tabIndex:-1,className:ne.scrollArrow,"data-aia-scroll-arrow":"","aria-label":ka,"aria-hidden":"true",children:B("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:B("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Fa,ModeController as Ha,setCursorOffset as Ka}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=`.SubmitButton-module_submitButton_otz7H {
|
|
1549
1577
|
flex-shrink: 0;
|
|
1550
1578
|
width: 32px;
|
|
1551
1579
|
height: 32px;
|
|
@@ -1580,5 +1608,5 @@ import{buildSubmitResult as Ii,cellDay as Ai,cellIso as Si,formatDate as Ci,isoD
|
|
|
1580
1608
|
);
|
|
1581
1609
|
cursor: default;
|
|
1582
1610
|
}
|
|
1583
|
-
`,document.head.appendChild(e)}var yt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ve}from"react/jsx-runtime";function _t({disabled:e,onClick:n}){return Ve("button",{type:"button","data-aia-submit":"",className:yt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":"Submit",children:Ve("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ve("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Pa,identifiedParamLabel as Ia,selectedIsoFromText as Aa}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as It,useEffect as Ie,useRef as L,useState as Sa}from"react";import{useRef as kt}from"react";function Pt(e){let n=kt(e);n.current=e;let a=kt(null);a.current===null&&(a.current={fetch:(l,t)=>{let i=n.current;return i?i.fetch(l,t):Promise.reject(new Error("products config removed"))},transform:l=>n.current?.transform(l)??[],get limit(){return n.current?.limit}});let o=e!==void 0;return{config:o?a.current:void 0,enabled:o}}var Ca={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,placeholderText:"",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};function Ye({onSubmit:e,onResult:n,onError:a,optionOverrides:o,maskCompletedText:l,apiConfig:t,additionalContext:i,columns:g=2,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:m,showNonTappableOptions:w,showSkipButton:k,onFocus:y,onBlur:b,value:D,completedParams:E,onChange:Q,onParamsChange:X,products:z,onProductSelect:P,source:Z,setCursor:J}){let p=L(null),[ee,te]=Sa(null),R=L(e);R.current=e;let q=L(n);q.current=n;let ae=L(a);ae.current=a;let $=L(Q);$.current=Q;let oe=L(X);oe.current=X;let ie=L(y);ie.current=y;let M=L(b);M.current=b;let O=L(J);O.current=J;let j=L(P);j.current=P;let B=Pt(z);Ie(()=>{if(typeof document>"u")return;let c=new Pa(document.createElement("div"),{renderMode:"headless",apiConfig:t,additionalContext:i,optionOverrides:o,maskCompletedText:l,columns:g,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:m,showNonTappableOptions:w,source:Z,value:D,completedParams:E,onSubmit:(...A)=>R.current?.(...A),onResult:(...A)=>q.current?.(...A),onError:(...A)=>ae.current?.(...A),onChange:(...A)=>$.current?.(...A),onParamsChange:(...A)=>oe.current?.(...A),onFocus:()=>ie.current?.(),onBlur:()=>M.current?.(),onProductSelect:A=>j.current?.(A),setCursor:A=>O.current?.(A),products:B.config});p.current=c,te(c.getState());let T=c.subscribe(A=>te(A));return()=>{T(),c.destroy(),p.current===c&&(p.current=null)}},[]),Ie(()=>{D!==void 0&&p.current?.setValue(D)},[D]),Ie(()=>{E!==void 0&&p.current?.setCompletedParams(E)},[E]);let h=JSON.stringify(t??null),N;try{N=JSON.stringify(i??null)}catch{N="[unstringifiable]"}let s=L(o),u=L(0);if(o!==s.current){let c=s.current,T=o,A=Object.keys(c??{}),be=Object.keys(T??{});(A.length!==be.length||be.some(ye=>!c?.[ye]||T[ye]!==c[ye]))&&u.current++,s.current=o}Ie(()=>{p.current?.update({apiConfig:t,additionalContext:i,optionOverrides:o,dropdownTrigger:v,optionsPosition:x,closeDropdownOnBlur:m,showNonTappableOptions:w})},[h,N,u.current,v,x,m,w]);let f=L(!1);Ie(()=>{if(!f.current){f.current=!0;return}p.current?.update({products:B.config})},[B.enabled]);let _=L(null);_.current===null&&(_.current={handleTextChange:c=>p.current?.handleTextChange(c),handleKeyDown:c=>{let T="nativeEvent"in c?c.nativeEvent:c;p.current?.handleKeyDown(T)},setFocused:c=>p.current?.setFocused(c),startEditingParam:c=>p.current?.startEditingParam(c),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:c=>p.current?.handleCaretAfterInput(c),handleCaretMove:c=>p.current?.handleCaretMove(c),replaceEditingRange:c=>p.current?.replaceEditingRange(c)??!1,setActivePill:c=>p.current?.setActivePill(c),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:c=>p.current?.selectOption(c),selectProduct:c=>p.current?.selectProduct(c),setActiveDropdownIndex:c=>p.current?.setActiveDropdownIndex(c),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let r=_.current,S=It(c=>{let T=c.target.value,be=T.length>0&&!c.nativeEvent?.isComposing&&T[0]!==T[0].toUpperCase()?T[0].toUpperCase()+T.slice(1):T;p.current?.handleTextChange(be)},[]),K=It(c=>{p.current?.handleKeyDown(c.nativeEvent)},[]),F=p.current,d=ee??Ca,me=D!==void 0?D:d.text,ge=E!==void 0?E:d.completedParams,ne=d.actionableSuggestions,he=ne[0],G=F?.listboxId??"",ze=d.activeDropdownIndex>=0&&F?`${G}-option-${d.activeDropdownIndex}`:void 0,re=d.editingParam,se=d.editingIdentified,xe=re?{type:re.suggestionType,text:re.suggestionPlaceholder,required:!0,options:re.options}:se?{type:se.type,text:Ia(se.type),required:!0,options:[]}:null,Se=xe??he,Oe=xe?[xe]:ne,Ce=!F||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:ge,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:ne,setActivePill:r.setActivePill,skipActivePill:r.skipActivePill,removeLastParam:r.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:r.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:Ce,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:G,error:d.error,products:d.products,selectProduct:r.selectProduct,handleTextChange:r.handleTextChange,handleKeyDown:r.handleKeyDown,setFocused:r.setFocused,editingParam:re,editingIdentified:se,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:r.startEditingParam,exitEditMode:r.exitEditMode,handleCaretAfterInput:r.handleCaretAfterInput,handleCaretMove:r.handleCaretMove,replaceEditingRange:r.replaceEditingRange,inputProps:{value:me,placeholder:d.placeholderText||void 0,onChange:S,onKeyDown:K,onFocus:r.handleFocus,onBlur:r.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ze,"aria-autocomplete":"list","aria-controls":G},reset:r.reset,dropdownProps:{suggestions:Se?[{...Se,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:r.selectOption,onHighlight:r.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:G,pills:Oe,activeSelected:d.isActivePillSelected,onPillClick:r.setActivePill,onSkip:r.skipActivePill,showSkipButton:(k??!0)&&!re&&!se,skipDisabled:d.inSelectionAnimation,isLoading:Ce,isInputEmpty:me.trim().length===0,products:d.products,onProductSelect:r.selectProduct,onProductFocusChange:r.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:se?se.iso:Aa(re?.text),onPreviousMonth:r.showPreviousMonth,onNextMonth:r.showNextMonth,optionsPosition:x??"below"}}}import{extractPlainText as At,getCursorOffset as St,plainTextLength as Da,renderEditableContent as Ea,setCursorOffset as Ct}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as Qe,useLayoutEffect as Xe,useRef as ve}from"react";var Ne;function Ta(){if(Ne!==void 0)return Ne;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ne=e.contentEditable==="plaintext-only",Ne}function Dt(e){let{segments:n,newParamId:a,editingParam:o,editingIdentified:l,editingAnchor:t,caretOffset:i,placeholderText:g,isFocused:v,isDropdownOpen:x,listboxId:m,activeDescendantId:w,autoFocus:k,handleTextChange:y,handleKeyDown:b,handleCaretAfterInput:D,handleCaretMove:E,startEditingParam:Q,replaceEditingRange:X,setFocused:z}=e,P=ve(null),Z=ve(!1),J=ve(""),p=ve(""),ee=ve(null),te=ve(0);ee.current=i,Qe(()=>{if(!k)return;let s=P.current;if(!s)return;document.activeElement===s?z(!0):s.focus();let u=s.ownerDocument??document,f=u.getSelection(),_=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!_){let r=u.createRange();r.selectNodeContents(s),r.collapse(!0),f.removeAllRanges(),f.addRange(r)}},[k,z]),Qe(()=>{let s=P.current;if(!s)return;let u=s.ownerDocument??document,f=()=>{let _=u.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!s.contains(_.anchorNode))return;let r=_.anchorNode,S=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement,F=(_.isCollapsed?S?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,d=o?.id??l?.id??null;if(F&&F!==d){Q(F);return}performance.now()-te.current<50||E(St(s))};return u.addEventListener("selectionchange",f),()=>u.removeEventListener("selectionchange",f)},[o,l,Q,E]),Xe(()=>{let s=P.current;s&&Ea({input:s,segments:n,newParamId:a,editingParamId:o?.id??null,placeholderText:g??"",isFocused:v})},[n,a,o,g,v]),Xe(()=>{let s=J.current,u=a??"";if(J.current=u,!u||u===s)return;let f=P.current;if(!f)return;f.focus();let _=ee.current??Da(f);Ct(f,_)},[a]),Xe(()=>{let s=p.current,u=o?.id??"";if(p.current=u,!u||u===s||t==null)return;let f=P.current;f&&Ct(f,t)},[o,t]);let R=U(()=>{if(Z.current)return;let s=P.current;if(!s)return;let u=At(s),_=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;y(_)},[y]),q=U(()=>{te.current=performance.now(),R();let s=P.current;s&&D(St(s))},[R,D]);Qe(()=>{let s=P.current;if(!s)return;let u=f=>{let _=f,r=_.inputType;if(r==="insertParagraph"||r==="insertLineBreak"||r==="insertFromDrop"){f.preventDefault();return}if(r.startsWith("insert")||r.startsWith("delete")){let S=r.startsWith("delete")?"":_.data??"";X(S)&&f.preventDefault()}};return s.addEventListener("beforeinput",u),()=>s.removeEventListener("beforeinput",u)},[X]);let ae=U(()=>{Z.current=!0},[]),$=U(()=>{Z.current=!1,R()},[R]),oe=U(s=>{s.preventDefault();let u=P.current;if(!u)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let _=u.ownerDocument??document,r=_.getSelection();if(!r||r.rangeCount===0)return;let S=r.getRangeAt(0);if(!u.contains(S.startContainer))return;S.deleteContents();let K=_.createTextNode(f);S.insertNode(K),S.setStartAfter(K),S.collapse(!0),r.removeAllRanges(),r.addRange(S),R()},[R]),ie=U(s=>b(s),[b]),M=U(()=>z(!0),[z]),O=U(()=>z(!1),[z]),j=U(()=>P.current?.focus(),[]),B=U(()=>P.current?.blur(),[]),h=U(()=>{let s=P.current;return s?At(s):""},[]),N=Ta()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:N,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":x,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:q,onKeyDown:ie,onCompositionStart:ae,onCompositionEnd:$,onPaste:oe,onFocus:M,onBlur:O},getPlainText:h,focus:j,blur:B}}import{jsx as we,jsxs as Je}from"react/jsx-runtime";function Ba(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Fa=Ra(function({onSubmit:n,onResult:a,onError:o,optionOverrides:l,maskCompletedText:t,className:i,apiConfig:g,additionalContext:v,columns:x,pillPlacement:m="dropdown",mode:w="auto",optionsPosition:k="below",animations:y=!0,dropdownTrigger:b,closeDropdownOnBlur:D,showNonTappableOptions:E,showSkipButton:Q,autoFocus:X=!0,onFocus:z,onBlur:P,value:Z,completedParams:J,onChange:p,onParamsChange:ee,products:te,onProductSelect:R,submitButton:q},ae){let $=Ae(null),oe=Ae(null),ie=Ae(()=>{}),M=Ae(null),O=Ae(null);Et(()=>{let I=$.current;if(I)return M.current?M.current.setMode(w):M.current=new za(I,w),()=>{M.current?.destroy(),M.current=null}},[w]);let j=Ze(I=>{let ce=O.current?.current;ce&&(ce.focus(),Oa(ce,I))},[]),{completedParams:B,skippedParams:h,identifiedParams:N,isReady:s,suggestionPills:u,setActivePill:f,skipActivePill:_,segments:r,newParamId:S,clearNewParamId:K,placeholderText:F,isFocused:d,isDropdownOpen:me,isActivePillSelected:ge,isLoading:ne,activeIndex:he,listboxId:G,handleTextChange:ze,handleKeyDown:re,setFocused:se,editingParam:xe,editingIdentified:Se,editingAnchor:Oe,caretOffset:Ce,startEditingParam:c,handleCaretAfterInput:T,handleCaretMove:A,replaceEditingRange:be,dropdownProps:ye,reset:De}=Ye({onSubmit:I=>ie.current(I),onResult:a,onError:o,optionOverrides:l,maskCompletedText:t,apiConfig:g,additionalContext:v,columns:x,dropdownTrigger:b,optionsPosition:k,closeDropdownOnBlur:D,showNonTappableOptions:E,showSkipButton:Q,onFocus:z,onBlur:P,value:Z,completedParams:J,onChange:p,onParamsChange:ee,products:te,onProductSelect:R,source:"full-sdk",setCursor:j});Et(()=>{if(!S)return;let I=window.setTimeout(()=>K(),650);return()=>window.clearTimeout(I)},[S,K]);let Tt=he>=0?`${G}-option-${he}`:void 0,{inputRef:Be,editorProps:Rt,focus:Ee,blur:et,getPlainText:tt}=Dt({segments:r,newParamId:S,editingParam:xe,editingIdentified:Se,editingAnchor:Oe,caretOffset:Ce,placeholderText:F,isFocused:d,isDropdownOpen:me,listboxId:G,activeDescendantId:Tt,autoFocus:X,handleTextChange:ze,handleKeyDown:re,handleCaretAfterInput:T,handleCaretMove:A,startEditingParam:c,replaceEditingRange:be,setFocused:se});O.current=Be,Ma(()=>{let I=oe.current,ce=Be.current;if(!I||!ce)return;let at=()=>{let it=I.firstElementChild;if(!it)return;let zt=it.getBoundingClientRect(),Ot=ce.getBoundingClientRect();zt.top>=Ot.bottom-2?I.setAttribute("data-aia-pill-wrapped",""):I.removeAttribute("data-aia-pill-wrapped")};at();let ot=new ResizeObserver(at);return ot.observe(ce),()=>ot.disconnect()},[r,u.length,ne,Be]),La(ae,()=>({focus:Ee,blur:et,reset:De,setMode:I=>M.current?.setMode(I),skipActivePill:_}),[Ee,et,De,_]);let Te=!!r.length||B.length>0,Fe=Ze(()=>{if(!Te)return;let I=tt();n(Na(I,B,h,{identifiedParams:N,isReady:s})),De()},[Te,B,h,N,s,n,De,tt]);ie.current=Fe;let Lt=Ze(I=>{I.target?.closest("[data-aia-pill]")||Ee()},[Ee]),Mt=m==="inline",Nt=m==="dropdown";return Je("div",{ref:$,className:`magicx-aia ${fe.container} ${i??""}`,"data-pill-placement":m,"data-options-position":k,"data-animations":y?"on":"off","data-mode":Ba(w),children:[we(je,{...ye,showPills:Nt}),Je("div",{className:fe.inputWrapper,onClick:Lt,children:[Je("div",{className:fe.editorArea,"data-aia-editor":"",children:[we("div",{...Rt,className:fe.input,"data-aia-input":""}),Mt&&(ne||u.length>0)&&we("span",{ref:oe,className:fe.pillListContainer,"data-aia-pill-list-container":"",children:we(Le,{pills:u,activePillIndex:0,activeSelected:ge,onSelectPill:f,loading:ne})})]}),q===null?null:q===void 0?we(_t,{disabled:!Te,onClick:Fe}):we("span",{"data-aia-submit":"",className:fe.submitSlot,onClick:I=>{Te&&(I.stopPropagation(),Fe())},children:q})]})]})});export{Fa as AIAutocomplete,je as AIAutocompleteDropdown,Li as WEEKDAY_LABELS,Ii as buildSubmitResult,Ai as cellDay,Si as cellIso,Ci as formatDate,Di as isoDate,Ei as monthLabel,Ti as parseDate,Ri as parseLooseDate,Ye as useAIAutocomplete,Mi as withSkippedParams};
|
|
1611
|
+
`,document.head.appendChild(e)}var xt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as $e}from"react/jsx-runtime";function yt({disabled:e,onClick:r}){return $e("button",{type:"button","data-aia-submit":"",className:xt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),r()},"aria-label":"Submit",children:$e("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:$e("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as Ca,dateSelectionFor as Ea,identifiedParamLabel as Ta}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as At,useEffect as Pe,useRef as G,useState as Ra}from"react";import{useRef as _t}from"react";function kt(e){let r=_t(e);r.current=e;let a=Object.keys(e??{}).sort().join("\0"),i=_t({key:"",overrides:void 0});if(i.current.key!==a){let s={};for(let o of Object.keys(e??{})){let n=(f,g,v)=>{let _=r.current?.[o];return _?_(f,g,v):[]};s[o]=n}i.current={key:a,overrides:e?s:void 0}}return{overrides:i.current.overrides,key:a}}import{useRef as Pt}from"react";function It(e){let r=Pt(e);r.current=e;let a=Pt(null);a.current===null&&(a.current={fetch:(s,o)=>{let n=r.current;return n?n.fetch(s,o):Promise.reject(new Error("products config removed"))},transform:s=>r.current?.transform(s)??[],get limit(){return r.current?.limit}});let i=e!==void 0;return{config:i?a.current:void 0,enabled:i}}var La={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],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 Ve({onSubmit:e,onResult:r,onError:a,optionOverrides:i,maskCompletedText:s,apiConfig:o,additionalContext:n,columns:f=2,dropdownTrigger:g,optionsPosition:v,closeDropdownOnBlur:_,showNonTappableOptions:p,showSkipButton:w,onFocus:y,onBlur:b,value:D,completedParams:C,onChange:Y,onParamsChange:Q,products:L,onProductSelect:k,source:X,setCursor:Z}){let u=G(null),[se,J]=Ra(null),E=G(e);E.current=e;let W=G(r);W.current=r;let ee=G(a);ee.current=a;let te=G(Y);te.current=Y;let q=G(Q);q.current=Q;let U=G(y);U.current=y;let R=G(b);R.current=b;let ae=G(Z);ae.current=Z;let le=G(k);le.current=k;let T=It(L),O=kt(i);Pe(()=>{if(typeof document>"u")return;let h=new Ca(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:n,optionOverrides:O.overrides,maskCompletedText:s,columns:f,dropdownTrigger:g,optionsPosition:v,closeDropdownOnBlur:_,showNonTappableOptions:p,source:X,value:D,completedParams:C,onSubmit:(...S)=>E.current?.(...S),onResult:(...S)=>W.current?.(...S),onError:(...S)=>ee.current?.(...S),onChange:(...S)=>te.current?.(...S),onParamsChange:(...S)=>q.current?.(...S),onFocus:()=>U.current?.(),onBlur:()=>R.current?.(),onProductSelect:S=>le.current?.(S),setCursor:S=>ae.current?.(S),products:T.config});u.current=h,J(h.getState());let z=h.subscribe(S=>J(S));return()=>{z(),h.destroy(),u.current===h&&(u.current=null)}},[]),Pe(()=>{D!==void 0&&u.current?.setValue(D)},[D]),Pe(()=>{C!==void 0&&u.current?.setCompletedParams(C)},[C]);let oe=JSON.stringify(o??null),t;try{t=JSON.stringify(n??null)}catch{t="[unstringifiable]"}Pe(()=>{u.current?.update({apiConfig:o,additionalContext:n,optionOverrides:O.overrides,dropdownTrigger:g,optionsPosition:v,closeDropdownOnBlur:_,showNonTappableOptions:p})},[oe,t,O.key,g,v,_,p]);let c=G(!1);Pe(()=>{if(!c.current){c.current=!0;return}u.current?.update({products:T.config})},[T.enabled]);let m=G(null);m.current===null&&(m.current={handleTextChange:h=>u.current?.handleTextChange(h),handleKeyDown:h=>{let z="nativeEvent"in h?h.nativeEvent:h;u.current?.handleKeyDown(z)},setFocused:h=>u.current?.setFocused(h),startEditingParam:h=>u.current?.startEditingParam(h),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:h=>u.current?.handleCaretAfterInput(h),handleCaretMove:h=>u.current?.handleCaretMove(h),replaceEditingRange:h=>u.current?.replaceEditingRange(h)??!1,setActivePill:h=>u.current?.setActivePill(h),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),selectOption:h=>u.current?.selectOption(h),selectProduct:h=>u.current?.selectProduct(h),setActiveDropdownIndex:h=>u.current?.setActiveDropdownIndex(h),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let l=m.current,x=At(h=>{let z=h.target.value,Ne=z.length>0&&!h.nativeEvent?.isComposing&&z[0]!==z[0].toUpperCase()?z[0].toUpperCase()+z.slice(1):z;u.current?.handleTextChange(Ne)},[]),A=At(h=>{u.current?.handleKeyDown(h.nativeEvent)},[]),M=u.current,d=se??La,ie=D!==void 0?D:d.text,fe=C!==void 0?C:d.completedParams,de=d.actionableSuggestions,ce=de[0],j=M?.listboxId??"",ge=d.activeDropdownIndex>=0&&M?`${j}-option-${d.activeDropdownIndex}`:void 0,F=d.editingParam,N=d.editingIdentified,xe=F?{type:F.suggestionType,text:F.suggestionPlaceholder,required:!0,options:F.options}:N?{type:N.type,text:Ta(N.type),required:!0,options:[]}:null,Ae=xe??ce,Me=xe?[xe]:de,ye=Ea(d),Se=!M||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:fe,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:Se,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:j,error:d.error,products:d.products,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:F,editingIdentified:N,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:ie,placeholder:d.placeholderText||void 0,onChange:x,onKeyDown:A,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ge,"aria-autocomplete":"list","aria-controls":j},reset:l.reset,dropdownProps:{suggestions:Ae?[{...Ae,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:j,pills:Me,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(w??!0)&&!F&&!N,skipDisabled:d.inSelectionAnimation,isLoading:Se,isInputEmpty:ie.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:ye.selectedIso,selectedDateRange:ye.selectedRange,dateRangeStart:ye.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:v??"below"}}}import{extractPlainText as St,getCursorOffset as Dt,plainTextLength as Oa,renderEditableContent as Ma,setCursorOffset as Ct}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as K,useEffect as Ye,useLayoutEffect as Qe,useRef as ve}from"react";var Oe;function Na(){if(Oe!==void 0)return Oe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Oe=e.contentEditable==="plaintext-only",Oe}function Et(e){let{segments:r,newParamId:a,editingParam:i,editingIdentified:s,editingAnchor:o,caretOffset:n,placeholderText:f,isFocused:g,isDropdownOpen:v,listboxId:_,activeDescendantId:p,autoFocus:w,handleTextChange:y,handleKeyDown:b,handleCaretAfterInput:D,handleCaretMove:C,startEditingParam:Y,replaceEditingRange:Q,setFocused:L}=e,k=ve(null),X=ve(!1),Z=ve(""),u=ve(""),se=ve(null),J=ve(0);se.current=n,Ye(()=>{if(!w)return;let t=k.current;if(!t)return;document.activeElement===t?L(!0):t.focus();let c=t.ownerDocument??document,m=c.getSelection(),l=m&&m.rangeCount>0&&t.contains(m.anchorNode);if(m&&!l){let x=c.createRange();x.selectNodeContents(t),x.collapse(!0),m.removeAllRanges(),m.addRange(x)}},[w,L]),Ye(()=>{let t=k.current;if(!t)return;let c=t.ownerDocument??document,m=()=>{let l=c.getSelection();if(!l||l.rangeCount===0||!l.anchorNode||!t.contains(l.anchorNode))return;let x=l.anchorNode,A=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,d=(l.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ie=i?.id??s?.id??null;if(d&&d!==ie){Y(d);return}performance.now()-J.current<50||C(Dt(t))};return c.addEventListener("selectionchange",m),()=>c.removeEventListener("selectionchange",m)},[i,s,Y,C]),Qe(()=>{let t=k.current;t&&Ma({input:t,segments:r,newParamId:a,editingParamId:i?.id??null,placeholderText:f??"",isFocused:g})},[r,a,i,f,g]),Qe(()=>{let t=Z.current,c=a??"";if(Z.current=c,!c||c===t)return;let m=k.current;if(!m)return;m.focus();let l=se.current??Oa(m);Ct(m,l)},[a]),Qe(()=>{let t=u.current,c=i?.id??"";if(u.current=c,!c||c===t||o==null)return;let m=k.current;m&&Ct(m,o)},[i,o]);let E=K(()=>{if(X.current)return;let t=k.current;if(!t)return;let c=St(t),l=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;y(l)},[y]),W=K(()=>{J.current=performance.now(),E();let t=k.current;t&&D(Dt(t))},[E,D]);Ye(()=>{let t=k.current;if(!t)return;let c=m=>{let l=m,x=l.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){m.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let A=x.startsWith("delete")?"":l.data??"";Q(A)&&m.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[Q]);let ee=K(()=>{X.current=!0},[]),te=K(()=>{X.current=!1,E()},[E]),q=K(t=>{t.preventDefault();let c=k.current;if(!c)return;let m=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!m)return;let l=c.ownerDocument??document,x=l.getSelection();if(!x||x.rangeCount===0)return;let A=x.getRangeAt(0);if(!c.contains(A.startContainer))return;A.deleteContents();let M=l.createTextNode(m);A.insertNode(M),A.setStartAfter(M),A.collapse(!0),x.removeAllRanges(),x.addRange(A),E()},[E]),U=K(t=>b(t),[b]),R=K(()=>L(!0),[L]),ae=K(()=>L(!1),[L]),le=K(()=>k.current?.focus(),[]),T=K(()=>k.current?.blur(),[]),O=K(()=>{let t=k.current;return t?St(t):""},[]),oe=Na()?"plaintext-only":"true";return{inputRef:k,editorProps:{ref:k,contentEditable:oe,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":_,"aria-expanded":v,"aria-activedescendant":p,spellCheck:!0,enterKeyHint:"send",onInput:W,onKeyDown:U,onCompositionStart:ee,onCompositionEnd:te,onPaste:q,onFocus:R,onBlur:ae},getPlainText:O,focus:le,blur:T}}import{jsx as we,jsxs as Ze}from"react/jsx-runtime";function Wa(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var qa=za(function({onSubmit:r,onResult:a,onError:i,optionOverrides:s,maskCompletedText:o,className:n,apiConfig:f,additionalContext:g,columns:v,pillPlacement:_="dropdown",mode:p="auto",optionsPosition:w="below",animations:y=!0,dropdownTrigger:b,closeDropdownOnBlur:D,showNonTappableOptions:C,showSkipButton:Y,autoFocus:Q=!0,onFocus:L,onBlur:k,value:X,completedParams:Z,onChange:u,onParamsChange:se,products:J,onProductSelect:E,submitButton:W},ee){let te=Ie(null),q=Ie(null),U=Ie(()=>{}),R=Ie(null),ae=Ie(null);Tt(()=>{let P=te.current;if(P)return R.current?R.current.setMode(p):R.current=new Ha(P,p),()=>{R.current?.destroy(),R.current=null}},[p]);let le=Xe(P=>{let pe=ae.current?.current;pe&&(pe.focus(),Ka(pe,P))},[]),{completedParams:T,skippedParams:O,identifiedParams:oe,isReady:t,suggestionPills:c,setActivePill:m,skipActivePill:l,segments:x,newParamId:A,clearNewParamId:M,placeholderText:d,isFocused:ie,isDropdownOpen:fe,isActivePillSelected:de,isLoading:ce,activeIndex:j,listboxId:ge,handleTextChange:F,handleKeyDown:N,setFocused:xe,editingParam:Ae,editingIdentified:Me,editingAnchor:ye,caretOffset:Se,startEditingParam:h,handleCaretAfterInput:z,handleCaretMove:S,replaceEditingRange:Ne,dropdownProps:Rt,reset:De}=Ve({onSubmit:P=>U.current(P),onResult:a,onError:i,optionOverrides:s,maskCompletedText:o,apiConfig:f,additionalContext:g,columns:v,dropdownTrigger:b,optionsPosition:w,closeDropdownOnBlur:D,showNonTappableOptions:C,showSkipButton:Y,onFocus:L,onBlur:k,value:X,completedParams:Z,onChange:u,onParamsChange:se,products:J,onProductSelect:E,source:"full-sdk",setCursor:le});Tt(()=>{if(!A)return;let P=window.setTimeout(()=>M(),650);return()=>window.clearTimeout(P)},[A,M]);let Lt=j>=0?`${ge}-option-${j}`:void 0,{inputRef:ze,editorProps:Ot,focus:Ce,blur:Je,getPlainText:et}=Et({segments:x,newParamId:A,editingParam:Ae,editingIdentified:Me,editingAnchor:ye,caretOffset:Se,placeholderText:d,isFocused:ie,isDropdownOpen:fe,listboxId:ge,activeDescendantId:Lt,autoFocus:Q,handleTextChange:F,handleKeyDown:N,handleCaretAfterInput:z,handleCaretMove:S,startEditingParam:h,replaceEditingRange:Ne,setFocused:xe});ae.current=ze,Ga(()=>{let P=q.current,pe=ze.current;if(!P||!pe)return;let tt=()=>{let ot=P.firstElementChild;if(!ot)return;let Bt=ot.getBoundingClientRect(),Gt=pe.getBoundingClientRect();Bt.top>=Gt.bottom-2?P.setAttribute("data-aia-pill-wrapped",""):P.removeAttribute("data-aia-pill-wrapped")};tt();let at=new ResizeObserver(tt);return at.observe(pe),()=>at.disconnect()},[x,c.length,ce,ze]),Ba(ee,()=>({focus:Ce,blur:Je,reset:De,setMode:P=>R.current?.setMode(P),skipActivePill:l}),[Ce,Je,De,l]);let Ee=!!x.length||T.length>0,Be=Xe(()=>{if(!Ee)return;let P=et();r(Fa(P,T,O,{identifiedParams:oe,isReady:t})),De()},[Ee,T,O,oe,t,r,De,et]);U.current=Be;let Mt=Xe(P=>{P.target?.closest("[data-aia-pill]")||Ce()},[Ce]),Nt=_==="inline",zt=_==="dropdown";return Ze("div",{ref:te,className:`magicx-aia ${he.container} ${n??""}`,"data-pill-placement":_,"data-options-position":w,"data-animations":y?"on":"off","data-mode":Wa(p),children:[we(je,{...Rt,showPills:zt}),Ze("div",{className:he.inputWrapper,onClick:Mt,children:[Ze("div",{className:he.editorArea,"data-aia-editor":"",children:[we("div",{...Ot,className:he.input,"data-aia-input":""}),Nt&&(ce||c.length>0)&&we("span",{ref:q,className:he.pillListContainer,"data-aia-pill-list-container":"",children:we(Re,{pills:c,activePillIndex:0,activeSelected:de,onSelectPill:m,loading:ce})})]}),W===null?null:W===void 0?we(yt,{disabled:!Ee,onClick:Be}):we("span",{"data-aia-submit":"",className:he.submitSlot,onClick:P=>{Ee&&(P.stopPropagation(),Be())},children:W})]})]})});export{qa as AIAutocomplete,je as AIAutocompleteDropdown,Ni as DATE_RANGE_META_END,zi as DATE_RANGE_META_START,Vi as WEEKDAY_LABELS,Li as buildSubmitResult,Oi as cellDay,Mi as cellIso,Bi as dateCellMarks,Gi as formatDate,Fi as formatDateRange,Hi as isoDate,Ki as monthLabel,Wi as parseDate,qi as parseLooseDate,Ui as parseLooseDateRange,ji as selectedRangeFor,Ve as useAIAutocomplete,$i as visibleDateRange,Yi as withSkippedParams};
|
|
1584
1612
|
//# sourceMappingURL=index.mjs.map
|