@magicx-eng/ai-autocomplete-react 0.14.2 → 0.16.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 +67 -21
- package/dist/index.d.mts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +42 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +42 -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 Ei,cellDay as Ti,cellIso as Ri,formatDate as Li,isoDate as Oi,monthLabel as Mi,parseDate as Ni,parseLooseDate as zi,WEEKDAY_LABELS as Bi,withSkippedParams as Fi}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Mo,useCallback as Qe,useEffect as Et,useImperativeHandle as No,useLayoutEffect as zo,useRef as Pe}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 _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
193
193
|
opacity: 0;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
`,document.head.appendChild(e)}var fe={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
|
|
196
|
+
`,document.head.appendChild(e)}var fe={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 xo,SCROLL_ARROW_LABEL as yo}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Ue,useRef as Re,useState as _o}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 _i,cellDay as ki,cellIso as Pi,formatDate as Ii,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 _i,cellDay as ki,cellIso as Pi,formatDate as Ii,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 _i,cellDay as ki,cellIso as Pi,formatDate as Ii,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 _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
780
801
|
opacity: 0.25;
|
|
781
802
|
}
|
|
782
803
|
}
|
|
783
|
-
`,document.head.appendChild(e)}var
|
|
804
|
+
`,document.head.appendChild(e)}var le={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 Gt,cellIso as xe,isoDate as Ht,monthLabel as Kt,WEEKDAY_LABELS as Wt}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as Ut}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
|
|
@@ -936,7 +957,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
936
957
|
opacity: 0.8;
|
|
937
958
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
938
959
|
}
|
|
939
|
-
`,document.head.appendChild(e)}var S={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",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};import{jsx as
|
|
960
|
+
`,document.head.appendChild(e)}var S={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",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};import{jsx as j,jsxs as at}from"react/jsx-runtime";var qt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function it({options:e,activeIndex:n,listboxId:t,view:a,selectedIso:r,onSelect:o,onHighlight:i,onPreviousMonth:g,onNextMonth:b}){let w=Ht(new Date);return at("div",{className:S.datepicker,"data-aia-datepicker":"",children:[at("div",{className:S.header,children:[j("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:c=>c.preventDefault(),onClick:g,children:"\u2039"}),j("span",{className:S.month,"data-aia-date-month":"","aria-live":"polite",children:Kt(a)}),j("button",{type:"button",tabIndex:-1,className:S.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:c=>c.preventDefault(),onClick:b,children:"\u203A"})]}),j("div",{className:S.weekdays,"aria-hidden":"true",children:Wt.map((c,x)=>j("span",{className:S.weekday,children:c},qt[x]))}),j("div",{className:S.grid,"data-aia-date-grid":"",children:e.map((c,x)=>j($t,{option:c,id:`${t}-option-${x}`,index:x,isHighlighted:x===n&&c.is_tappable,isToday:xe(c)===w,isPast:xe(c)!=null&&xe(c)<w,isSelected:r!=null&&xe(c)===r,onSelect:o,onHighlight:i},xe(c)??`pad-${x}`))})]})}function $t({option:e,id:n,index:t,isHighlighted:a,isToday:r,isPast:o,isSelected:i,onSelect:g,onHighlight:b}){let[w,c]=Ut(!1),x=Gt(e);if(x==null)return j("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${S.cell} ${S.blank}`});let k=()=>{c(!0),g(e),setTimeout(()=>c(!1),170)},y=[S.cell,S.day,o?S.past:"",a?S.highlighted:"",r?S.today:"",i?S.selected:"",w?S.pressed:""].filter(Boolean).join(" ");return j("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:y,onClick:k,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),k())},onMouseEnter:()=>b(t),children:j("span",{className:S.number,children:x})})}import{ATTRIBUTION_URL as jt,buildAttributionUrl as Vt,getFooterHint as Yt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Qt,useState as Xt}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
961
|
.aia-cluster {
|
|
941
962
|
display: flex;
|
|
942
963
|
flex-wrap: wrap;
|
|
@@ -978,7 +999,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
978
999
|
justify-content: space-around;
|
|
979
1000
|
}
|
|
980
1001
|
}
|
|
981
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1002
|
+
`,document.head.appendChild(e)}import{jsx as nt}from"react/jsx-runtime";function ye({gap:e,align:n="center",justify:t="start",noWrap:a=!1,inline:r=!1,className:o,children:i,...g}){let b=e?{"--aia-cluster-gap":e}:void 0,w={className:o?`aia-cluster ${o}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":a||void 0,"data-inline":r||void 0,style:b,...g};return r?nt("span",{...w,children:i}):nt("div",{...w,children:i})}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
1003
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
983
1004
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
984
1005
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1112,7 +1133,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1112
1133
|
justify-content: flex-end;
|
|
1113
1134
|
}
|
|
1114
1135
|
}
|
|
1115
|
-
`,document.head.appendChild(e)}var
|
|
1136
|
+
`,document.head.appendChild(e)}var de={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 _e,jsxs as Be}from"react/jsx-runtime";function rt({isOptionHighlighted:e=!1,isInputEmpty:n=!1}){let{key:t,hint:a}=Yt(e,n),[r,o]=Xt(jt);return Qt(()=>{o(Vt())},[]),_e("footer",{className:de.footer,"data-aia-footer":"",children:Be(ye,{justify:"between",noWrap:!0,className:de.row,children:[Be(ye,{gap:"5px",className:de.hintGroup,children:[_e("kbd",{className:de.key,children:t}),_e("span",{className:de.hint,children:a})]}),Be("a",{className:de.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[_e("span",{className:de.brand,children:"AI"}),_e("span",{className:de.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
1137
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1117
1138
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1118
1139
|
as it was when the outline was dashed. */
|
|
@@ -1169,7 +1190,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1169
1190
|
opacity: 0;
|
|
1170
1191
|
}
|
|
1171
1192
|
}
|
|
1172
|
-
`,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
|
|
1193
|
+
`,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 Zt}from"react/jsx-runtime";var Fe={selected:1,first:.7,next:.4,last:.2};function st({label:e,state:n,rounded:t,loading:a,onClick:r}){let o=[ue.pill,t?ue.rounded:"",a?ue.skeleton:""].filter(Boolean).join(" ");return Zt("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:o,style:{opacity:Fe[n]},onMouseDown:i=>i.preventDefault(),onClick:a?void 0:r,disabled:a,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
1194
|
position: relative;
|
|
1174
1195
|
z-index: 1;
|
|
1175
1196
|
pointer-events: auto;
|
|
@@ -1179,7 +1200,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1179
1200
|
align-items: center;
|
|
1180
1201
|
vertical-align: middle;
|
|
1181
1202
|
}
|
|
1182
|
-
`,document.head.appendChild(e)}var
|
|
1203
|
+
`,document.head.appendChild(e)}var Ge={list:"PillList-module_list_qvLqO"};import{jsx as Ee}from"react/jsx-runtime";var Jt=[125,69];function lt(e){return e===0?"first":e===1?"next":"last"}function Te({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:a,rounded:r,loading:o}){return o&&e.length===0?Ee("span",{className:Ge.list,"data-aia-pill-list-loading":"",children:Jt.map((i,g)=>Ee("span",{"data-aia-pill-skeleton":"",className:`${ue.pill} ${r?ue.rounded:""} ${ue.skeleton}`,style:{width:i,opacity:Fe[lt(g)]}},`skel-${i}`))}):Ee("span",{className:Ge.list,"data-aia-pill-list-loading":o?"":void 0,children:e.map((i,g)=>{let b=!!a&&g===n;return Ee(st,{label:i.text,state:b?"selected":lt(g),selected:b,rounded:r,loading:o,onClick:()=>t(g)},`${i.type}-${i.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
1204
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1184
1205
|
theming one package sees the same result in the other.
|
|
1185
1206
|
|
|
@@ -1346,7 +1367,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1346
1367
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1347
1368
|
);
|
|
1348
1369
|
}
|
|
1349
|
-
`,document.head.appendChild(e)}var
|
|
1370
|
+
`,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 He}from"react/jsx-runtime";function dt({products:e,listboxId:n,onSelect:t,onFocusChange:a,focusable:r=!0}){if(e.length===0)return null;let o=`${n}-products-label`;return He("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((i,g)=>me(eo,{product:i,id:`${n}-product-${g}`,onSelect:t,onFocusChange:a,focusable:r},i.id))})]})}function eo({product:e,id:n,onSelect:t,onFocusChange:a,focusable:r}){let o=i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0||(i.preventDefault(),t(e))};return He("a",{id:n,className:H.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:r?0:-1,onClick:o,onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),t(e))},onFocus:()=>a?.(!0),onBlur:i=>{i.relatedTarget?.closest("[data-aia-dropdown]")||a?.(!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}),He("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 co,measureOptionsGrid as po,needsOptionsGridMeasurement as uo,OPTIONS_GRID_MOBILE_QUERY as mo,optionEnterDelayMs as ho,planOptionsGrid as mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as fo,useLayoutEffect as go,useRef as bo,useState as ft}from"react";import{optionsGridTemplateColumns as to}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as oo,useRef as ao}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
1371
|
.aia-grid {
|
|
1351
1372
|
display: grid;
|
|
1352
1373
|
grid-template-columns: repeat(
|
|
@@ -1381,7 +1402,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1381
1402
|
border-radius: 3px;
|
|
1382
1403
|
}
|
|
1383
1404
|
}
|
|
1384
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1405
|
+
`,document.head.appendChild(e)}import{jsx as io}from"react/jsx-runtime";function ct({min:e="16rem",max:n,gap:t,scroll:a=!1,maxHeight:r,scrollResetKey:o,cols:i,template:g,innerRef:b,className:w,children:c,...x}){let k=ao(null);oo(()=>{if(o===void 0)return;let v=k.current;v&&(v.scrollTop=0)},[o]);let y={"--aia-grid-min":e};return n&&(y["--aia-grid-max"]=n),t&&(y["--aia-grid-gap"]=t),r&&(y["--aia-grid-max-height"]=r),i&&(y.gridTemplateColumns=to(i)),g&&(y.gridTemplateColumns=g),io("div",{ref:v=>{k.current=v,b?.(v)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:y,...x,children:c})}import{OPTION_ENTER_DELAY_VAR as no}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ro,useRef as so,useState as pt}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
1406
|
position: relative;
|
|
1386
1407
|
overflow: visible;
|
|
1387
1408
|
display: flex;
|
|
@@ -1461,12 +1482,12 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1461
1482
|
option steps back in opacity \u2014 no fill, no glow, the hierarchy carries it. */
|
|
1462
1483
|
.SuggestionItem-module_pressed_98o-r {
|
|
1463
1484
|
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
1464
|
-
animation: SuggestionItem-module_pressCompress_ICV3q
|
|
1485
|
+
animation: SuggestionItem-module_pressCompress_ICV3q 170ms ease forwards;
|
|
1465
1486
|
}
|
|
1466
1487
|
|
|
1467
1488
|
[role="listbox"]:has(.SuggestionItem-module_pressed_98o-r) .SuggestionItem-module_item_d4vpD:not(.SuggestionItem-module_pressed_98o-r) {
|
|
1468
1489
|
opacity: 0.35;
|
|
1469
|
-
transition: opacity
|
|
1490
|
+
transition: opacity 60ms ease;
|
|
1470
1491
|
}
|
|
1471
1492
|
|
|
1472
1493
|
@keyframes SuggestionItem-module_pressCompress_ICV3q {
|
|
@@ -1528,7 +1549,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1528
1549
|
filter: brightness(0.55);
|
|
1529
1550
|
}
|
|
1530
1551
|
}
|
|
1531
|
-
`,document.head.appendChild(e)}var
|
|
1552
|
+
`,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 Ke,jsxs as lo}from"react/jsx-runtime";function ut({option:e,isHighlighted:n,onSelect:t,onHighlight:a,id:r,loading:o,scrollHint:i,enterDelayMs:g=0}){let[b]=pt(g),[w,c]=pt(!1),x=so(void 0);ro(()=>()=>clearTimeout(x.current),[]);let k=()=>{o||!e.is_tappable||w||(c(!0),t(e),clearTimeout(x.current),x.current=setTimeout(()=>c(!1),170))},y=[V.item,n&&!o?V.highlighted:"",e.is_tappable?V.tappable:V.nonTappable,w?V.pressed:"",i?V.scrollHint:""].filter(Boolean).join(" ");return Ke("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":o?"":void 0,"aria-selected":n,className:y,style:{[no]:`${b}ms`},tabIndex:o||!e.is_tappable?-1:0,onClick:k,onKeyDown:v=>{!o&&e.is_tappable&&(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),k())},onMouseEnter:!o&&e.is_tappable?a:void 0,children:lo("span",{className:V.content,children:[Ke("span",{className:V.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&Ke("span",{className:V.tag,children:e.tag})]})})}import{jsx as ht}from"react/jsx-runtime";function vo(){let[e,n]=ft(co);return fo(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(mo),a=()=>n(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function gt({options:e,activeIndex:n,onSelect:t,onHighlight:a,listboxId:r,loading:o,groupKey:i="",optionsPosition:g="below"}){let b=vo(),w=bo(null),[c,x]=ft(null);go(()=>{let y=w.current,D=y&&!o&&uo(e.length,b)?po(y):null;x(D?mt(e.length,b,D.rowWidths,D.gridWidth):null)},[e,b,o]);let k=c??mt(e.length,b,null,null);return ht(ct,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:i,template:k.template,maxHeight:k.maxHeight,innerRef:y=>{w.current=y},"data-aia-group":i,children:e.map((y,v)=>ht(ut,{option:y,isHighlighted:v===n,onSelect:t,onHighlight:()=>a(v),id:`${r}-option-${v}`,loading:o,scrollHint:!o&&k.scrollHintIndices.includes(v),enterDelayMs:o?0:ho(v,k.cols,e.length,g)},`${i}\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
1553
|
.aia-stack {
|
|
1533
1554
|
display: flex;
|
|
1534
1555
|
flex-direction: column;
|
|
@@ -1545,7 +1566,7 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1545
1566
|
}
|
|
1546
1567
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1547
1568
|
}
|
|
1548
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1569
|
+
`,document.head.appendChild(e)}import{jsx as wo}from"react/jsx-runtime";function bt({space:e,align:n="stretch",className:t,children:a,...r}){let o=e?{"--aia-stack-space":e}:void 0;return wo("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:o,...r,children:a})}import{jsx as B,jsxs as We}from"react/jsx-runtime";var ko=[159,119,164],Po=()=>{},vt=()=>{};function Io(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=_o(n);if(Ue(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),o=()=>a(r.matches);return r.addEventListener("change",o),()=>r.removeEventListener("change",o)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Ao(e,n){let t=Re(null);Ue(()=>{let a=e.current,r=n.current;if(!a||!r)return;let o=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==o&&(t.current.controller.destroy(),t.current=null),o&&!t.current){t.current={grid:o,controller:xo({dropdown:a,grid:o,button:r})};return}t.current?.controller.update()}),Ue(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function qe({suggestions:e,activeIndex:n,onSelect:t,onHighlight:a,isOpen:r,id:o,className:i,pills:g,onPillClick:b,showPills:w=!0,onSkip:c,showSkipButton:x=!0,skipDisabled:k=!1,activeSelected:y=!1,isLoading:v=!1,isInputEmpty:D=!1,products:E,onProductSelect:Y,onProductFocusChange:Q,formatType:O="options",dateView:P=null,selectedDateIso:X=null,onPreviousMonth:Z,onNextMonth:p,optionsPosition:J="below",mode:ee}){let T=Io(ee),W=T!==void 0,te=Re(null),U=Re(null);Ao(te,U);let oe=e[0]?.options??[],ae=!!(g&&g.length>0&&b),R=!!(E&&E.length>0),M=r&&(oe.length>0||w&&ae||v||R),q={suggestions:e,activeIndex:n,pills:g,showPills:w,showSkipButton:x,skipDisabled:k,activeSelected:y,isLoading:v,isInputEmpty:D,products:E,formatType:O,dateView:P,selectedDateIso:X},N=Re(q);M&&(N.current=q);let u=M?q:N.current,G=u.suggestions[0],s=G?.options??[],m=u.activeIndex>=0&&!!s[u.activeIndex]?.is_tappable,f=!!(u.pills&&u.pills.length>0&&b),l=u.showPills&&f,_=u.showPills&&!f&&u.isLoading,A=l||_,L=f&&u.showSkipButton&&!u.isInputEmpty&&!!c,d=u.pills?.[0]?.text,ie=u.formatType==="date"&&u.dateView!=null,ge=s.length>0&&!ie,ce=s.length>0&&ie,he=u.isLoading&&!ge&&!ce,$=u.products??[];return We("div",{ref:te,id:o,role:"listbox","data-aia-dropdown":"","data-options-position":J,"data-mode":T,"data-aia-loading":u.isLoading?"":void 0,"data-aia-has-products":$.length>0?"":void 0,className:`${W?"magicx-aia ":""}${le.dropdown} ${M?le.visible:""} ${i??""}`,onMouseDown:ne=>ne.preventDefault(),children:[We(bt,{space:"8px",children:[(A||L)&&We(ye,{noWrap:!0,className:le.pillBar,"data-aia-pillbar":"",children:[A&&B("span",{className:le.pillScroll,"data-aia-pill-scroll":"",children:B(Te,{pills:u.pills??[],activePillIndex:0,activeSelected:u.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:u.isLoading})}),L&&B("button",{type:"button",tabIndex:-1,className:le.skip,"data-aia-skip":"",disabled:u.isLoading||u.skipDisabled,"aria-label":d?`Skip ${d}`:"Skip",onClick:c,children:"skip"})]}),ge&&B(gt,{options:s,activeIndex:u.activeIndex,onSelect:t,onHighlight:a,listboxId:o,loading:u.isLoading,groupKey:G?`${G.type} ${G.text}`:"",optionsPosition:J}),ce&&u.dateView&&B(it,{options:s,activeIndex:u.activeIndex,listboxId:o,view:u.dateView,selectedIso:u.selectedDateIso??null,onSelect:t,onHighlight:a,onPreviousMonth:Z??vt,onNextMonth:p??vt}),he&&B("div",{className:le.skeletonBars,"data-aia-skeleton-bars":"",children:ko.map(ne=>B("span",{className:le.skeletonBar,style:{width:ne}},`bar-${ne}`))}),B(dt,{products:$,listboxId:o,onSelect:Y??Po,onFocusChange:Q,focusable:M}),B(rt,{isOptionHighlighted:m,isInputEmpty:u.isInputEmpty})]}),B("button",{ref:U,type:"button",tabIndex:-1,className:le.scrollArrow,"data-aia-scroll-arrow":"","aria-label":yo,"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 Bo,ModeController as Fo,setCursorOffset as Go}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
1570
|
flex-shrink: 0;
|
|
1550
1571
|
width: 32px;
|
|
1551
1572
|
height: 32px;
|
|
@@ -1580,5 +1601,5 @@ import{buildSubmitResult as _i,cellDay as ki,cellIso as Pi,formatDate as Ii,isoD
|
|
|
1580
1601
|
);
|
|
1581
1602
|
cursor: default;
|
|
1582
1603
|
}
|
|
1583
|
-
`,document.head.appendChild(e)}var vt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as qe}from"react/jsx-runtime";function wt({disabled:e,onClick:n}){return qe("button",{type:"button","data-aia-submit":"",className:vt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),n()},"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 ya,identifiedParamLabel as _a,selectedIsoFromText as ka}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as _t,useEffect as Pe,useRef as N,useState as Pa}from"react";import{useRef as xt}from"react";function yt(e){let n=xt(e);n.current=e;let t=xt(null);t.current===null&&(t.current={fetch:(s,a)=>{let r=n.current;return r?r.fetch(s,a):Promise.reject(new Error("products config removed"))},transform:s=>n.current?.transform(s)??[],get limit(){return n.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var Ia={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 $e({onSubmit:e,onError:n,optionOverrides:t,maskCompletedText:i,apiConfig:s,additionalContext:a,columns:r=2,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,showSkipButton:x,onFocus:k,onBlur:w,value:f,completedParams:D,onChange:B,onParamsChange:Z,products:re,onProductSelect:L,source:I,setCursor:q}){let h=N(null),[se,$]=Pa(null),J=N(e);J.current=e;let E=N(n);E.current=n;let le=N(B);le.current=B;let j=N(Z);j.current=Z;let V=N(k);V.current=k;let ee=N(w);ee.current=w;let M=N(q);M.current=q;let te=N(L);te.current=L;let z=yt(re);Pe(()=>{if(typeof document>"u")return;let c=new ya(document.createElement("div"),{renderMode:"headless",apiConfig:s,additionalContext:a,optionOverrides:t,maskCompletedText:i,columns:r,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,source:I,value:f,completedParams:D,onSubmit:(...C)=>J.current?.(...C),onError:(...C)=>E.current?.(...C),onChange:(...C)=>le.current?.(...C),onParamsChange:(...C)=>j.current?.(...C),onFocus:()=>V.current?.(),onBlur:()=>ee.current?.(),onProductSelect:C=>te.current?.(C),setCursor:C=>M.current?.(C),products:z.config});h.current=c,$(c.getState());let T=c.subscribe(C=>$(C));return()=>{T(),c.destroy(),h.current===c&&(h.current=null)}},[]),Pe(()=>{f!==void 0&&h.current?.setValue(f)},[f]),Pe(()=>{D!==void 0&&h.current?.setCompletedParams(D)},[D]);let F=JSON.stringify(s??null),G;try{G=JSON.stringify(a??null)}catch{G="[unstringifiable]"}let p=N(t),H=N(0);if(t!==p.current){let c=p.current,T=t,C=Object.keys(c??{}),be=Object.keys(T??{});(C.length!==be.length||be.some(ce=>!c?.[ce]||T[ce]!==c[ce]))&&H.current++,p.current=t}Pe(()=>{h.current?.update({apiConfig:s,additionalContext:a,optionOverrides:t,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m})},[F,G,H.current,g,b,v,m]);let l=N(!1);Pe(()=>{if(!l.current){l.current=!0;return}h.current?.update({products:z.config})},[z.enabled]);let u=N(null);u.current===null&&(u.current={handleTextChange:c=>h.current?.handleTextChange(c),handleKeyDown:c=>{let T="nativeEvent"in c?c.nativeEvent:c;h.current?.handleKeyDown(T)},setFocused:c=>h.current?.setFocused(c),startEditingParam:c=>h.current?.startEditingParam(c),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:c=>h.current?.handleCaretAfterInput(c),handleCaretMove:c=>h.current?.handleCaretMove(c),replaceEditingRange:c=>h.current?.replaceEditingRange(c)??!1,setActivePill:c=>h.current?.setActivePill(c),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:c=>h.current?.selectOption(c),selectProduct:c=>h.current?.selectProduct(c),setActiveDropdownIndex:c=>h.current?.setActiveDropdownIndex(c),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let o=u.current,_=_t(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;h.current?.handleTextChange(be)},[]),y=_t(c=>{h.current?.handleKeyDown(c.nativeEvent)},[]),A=h.current,d=se??Ia,K=f!==void 0?f:d.text,Y=D!==void 0?D:d.completedParams,ae=d.actionableSuggestions,he=ae[0],de=A?.listboxId??"",ge=d.activeDropdownIndex>=0&&A?`${de}-option-${d.activeDropdownIndex}`:void 0,R=d.editingParam,oe=d.editingIdentified,xe=R?{type:R.suggestionType,text:R.suggestionPlaceholder,required:!0,options:R.options}:oe?{type:oe.type,text:_a(oe.type),required:!0,options:[]}:null,Ae=xe??he,Me=xe?[xe]:ae,Se=!A||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:Y,skippedParams:d.skippedParams,suggestionPills:ae,setActivePill:o.setActivePill,skipActivePill:o.skipActivePill,removeLastParam:o.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:o.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:de,error:d.error,products:d.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:R,editingIdentified:oe,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:K,placeholder:d.placeholderText||void 0,onChange:_,onKeyDown:y,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ge,"aria-autocomplete":"list","aria-controls":de},reset:o.reset,dropdownProps:{suggestions:Ae?[{...Ae,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:de,pills:Me,activeSelected:d.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(x??!0)&&!R&&!oe,skipDisabled:d.inSelectionAnimation,isLoading:Se,isInputEmpty:K.trim().length===0,products:d.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:oe?oe.iso:ka(R?.text),onPreviousMonth:o.showPreviousMonth,onNextMonth:o.showNextMonth,optionsPosition:b??"below"}}}import{extractPlainText as kt,getCursorOffset as Pt,plainTextLength as Aa,renderEditableContent as Sa,setCursorOffset as It}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as U,useEffect as je,useLayoutEffect as Ve,useRef as ve}from"react";var Le;function Ca(){if(Le!==void 0)return Le;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Le=e.contentEditable==="plaintext-only",Le}function At(e){let{segments:n,newParamId:t,editingParam:i,editingIdentified:s,editingAnchor:a,caretOffset:r,placeholderText:g,isFocused:b,isDropdownOpen:v,listboxId:m,activeDescendantId:x,autoFocus:k,handleTextChange:w,handleKeyDown:f,handleCaretAfterInput:D,handleCaretMove:B,startEditingParam:Z,replaceEditingRange:re,setFocused:L}=e,I=ve(null),q=ve(!1),h=ve(""),se=ve(""),$=ve(null),J=ve(0);$.current=r,je(()=>{if(!k)return;let l=I.current;if(!l)return;document.activeElement===l?L(!0):l.focus();let u=l.ownerDocument??document,o=u.getSelection(),_=o&&o.rangeCount>0&&l.contains(o.anchorNode);if(o&&!_){let y=u.createRange();y.selectNodeContents(l),y.collapse(!0),o.removeAllRanges(),o.addRange(y)}},[k,L]),je(()=>{let l=I.current;if(!l)return;let u=l.ownerDocument??document,o=()=>{let _=u.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!l.contains(_.anchorNode))return;let y=_.anchorNode,A=y.nodeType===Node.ELEMENT_NODE?y:y.parentElement,K=(_.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Y=i?.id??s?.id??null;if(K&&K!==Y){Z(K);return}performance.now()-J.current<50||B(Pt(l))};return u.addEventListener("selectionchange",o),()=>u.removeEventListener("selectionchange",o)},[i,s,Z,B]),Ve(()=>{let l=I.current;l&&Sa({input:l,segments:n,newParamId:t,editingParamId:i?.id??null,placeholderText:g??"",isFocused:b})},[n,t,i,g,b]),Ve(()=>{let l=h.current,u=t??"";if(h.current=u,!u||u===l)return;let o=I.current;if(!o)return;o.focus();let _=$.current??Aa(o);It(o,_)},[t]),Ve(()=>{let l=se.current,u=i?.id??"";if(se.current=u,!u||u===l||a==null)return;let o=I.current;o&&It(o,a)},[i,a]);let E=U(()=>{if(q.current)return;let l=I.current;if(!l)return;let u=kt(l),_=u.length>0&&u[0]!==u[0].toUpperCase()?u[0].toUpperCase()+u.slice(1):u;w(_)},[w]),le=U(()=>{J.current=performance.now(),E();let l=I.current;l&&D(Pt(l))},[E,D]);je(()=>{let l=I.current;if(!l)return;let u=o=>{let _=o,y=_.inputType;if(y==="insertParagraph"||y==="insertLineBreak"||y==="insertFromDrop"){o.preventDefault();return}if(y.startsWith("insert")||y.startsWith("delete")){let A=y.startsWith("delete")?"":_.data??"";re(A)&&o.preventDefault()}};return l.addEventListener("beforeinput",u),()=>l.removeEventListener("beforeinput",u)},[re]);let j=U(()=>{q.current=!0},[]),V=U(()=>{q.current=!1,E()},[E]),ee=U(l=>{l.preventDefault();let u=I.current;if(!u)return;let o=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!o)return;let _=u.ownerDocument??document,y=_.getSelection();if(!y||y.rangeCount===0)return;let A=y.getRangeAt(0);if(!u.contains(A.startContainer))return;A.deleteContents();let d=_.createTextNode(o);A.insertNode(d),A.setStartAfter(d),A.collapse(!0),y.removeAllRanges(),y.addRange(A),E()},[E]),M=U(l=>f(l),[f]),te=U(()=>L(!0),[L]),z=U(()=>L(!1),[L]),F=U(()=>I.current?.focus(),[]),G=U(()=>I.current?.blur(),[]),p=U(()=>{let l=I.current;return l?kt(l):""},[]),H=Ca()?"plaintext-only":"true";return{inputRef:I,editorProps:{ref:I,contentEditable:H,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":v,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:le,onKeyDown:M,onCompositionStart:j,onCompositionEnd:V,onPaste:ee,onFocus:te,onBlur:z},getPlainText:p,focus:F,blur:G}}import{jsx as we,jsxs as Qe}from"react/jsx-runtime";function Na(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var za=Da(function({onSubmit:n,onError:t,optionOverrides:i,maskCompletedText:s,className:a,apiConfig:r,additionalContext:g,columns:b,pillPlacement:v="dropdown",mode:m="auto",optionsPosition:x="below",animations:k=!0,dropdownTrigger:w,closeDropdownOnBlur:f,showNonTappableOptions:D,showSkipButton:B,autoFocus:Z=!0,onFocus:re,onBlur:L,value:I,completedParams:q,onChange:h,onParamsChange:se,products:$,onProductSelect:J,submitButton:E},le){let j=Ie(null),V=Ie(null),ee=Ie(()=>{}),M=Ie(null),te=Ie(null);St(()=>{let P=j.current;if(P)return M.current?M.current.setMode(m):M.current=new La(P,m),()=>{M.current?.destroy(),M.current=null}},[m]);let z=Ye(P=>{let pe=te.current?.current;pe&&(pe.focus(),Ma(pe,P))},[]),{completedParams:F,skippedParams:G,suggestionPills:p,setActivePill:H,skipActivePill:l,segments:u,newParamId:o,clearNewParamId:_,placeholderText:y,isFocused:A,isDropdownOpen:d,isActivePillSelected:K,isLoading:Y,activeIndex:ae,listboxId:he,handleTextChange:de,handleKeyDown:ge,setFocused:R,editingParam:oe,editingIdentified:xe,editingAnchor:Ae,caretOffset:Me,startEditingParam:Se,handleCaretAfterInput:c,handleCaretMove:T,replaceEditingRange:C,dropdownProps:be,reset:ce}=$e({onSubmit:P=>ee.current(P),onError:t,optionOverrides:i,maskCompletedText:s,apiConfig:r,additionalContext:g,columns:b,dropdownTrigger:w,optionsPosition:x,closeDropdownOnBlur:f,showNonTappableOptions:D,showSkipButton:B,onFocus:re,onBlur:L,value:I,completedParams:q,onChange:h,onParamsChange:se,products:$,onProductSelect:J,source:"full-sdk",setCursor:z});St(()=>{if(!o)return;let P=window.setTimeout(()=>_(),650);return()=>window.clearTimeout(P)},[o,_]);let Ct=ae>=0?`${he}-option-${ae}`:void 0,{inputRef:Ne,editorProps:Dt,focus:Ce,blur:Xe,getPlainText:Ze}=At({segments:u,newParamId:o,editingParam:oe,editingIdentified:xe,editingAnchor:Ae,caretOffset:Me,placeholderText:y,isFocused:A,isDropdownOpen:d,listboxId:he,activeDescendantId:Ct,autoFocus:Z,handleTextChange:de,handleKeyDown:ge,handleCaretAfterInput:c,handleCaretMove:T,startEditingParam:Se,replaceEditingRange:C,setFocused:R});te.current=Ne,Ta(()=>{let P=V.current,pe=Ne.current;if(!P||!pe)return;let Je=()=>{let tt=P.firstElementChild;if(!tt)return;let Lt=tt.getBoundingClientRect(),Mt=pe.getBoundingClientRect();Lt.top>=Mt.bottom-2?P.setAttribute("data-aia-pill-wrapped",""):P.removeAttribute("data-aia-pill-wrapped")};Je();let et=new ResizeObserver(Je);return et.observe(pe),()=>et.disconnect()},[u,p.length,Y,Ne]),Ea(le,()=>({focus:Ce,blur:Xe,reset:ce,setMode:P=>M.current?.setMode(P),skipActivePill:l}),[Ce,Xe,ce,l]);let De=!!u.length||F.length>0,ze=Ye(()=>{if(!De)return;let P=Ze();n(Ra(P,F,G)),ce()},[De,F,G,n,ce,Ze]);ee.current=ze;let Et=Ye(P=>{P.target?.closest("[data-aia-pill]")||Ce()},[Ce]),Tt=v==="inline",Rt=v==="dropdown";return Qe("div",{ref:j,className:`magicx-aia ${fe.container} ${a??""}`,"data-pill-placement":v,"data-options-position":x,"data-animations":k?"on":"off","data-mode":Na(m),children:[we(Ue,{...be,showPills:Rt}),Qe("div",{className:fe.inputWrapper,onClick:Et,children:[Qe("div",{className:fe.editorArea,"data-aia-editor":"",children:[we("div",{...Dt,className:fe.input,"data-aia-input":""}),Tt&&(Y||p.length>0)&&we("span",{ref:V,className:fe.pillListContainer,"data-aia-pill-list-container":"",children:we(Te,{pills:p,activePillIndex:0,activeSelected:K,onSelectPill:H,loading:Y})})]}),E===null?null:E===void 0?we(wt,{disabled:!De,onClick:ze}):we("span",{"data-aia-submit":"",className:fe.submitSlot,onClick:P=>{De&&(P.stopPropagation(),ze())},children:E})]})]})});export{za as AIAutocomplete,Ue as AIAutocompleteDropdown,Ei as WEEKDAY_LABELS,_i as buildSubmitResult,ki as cellDay,Pi as cellIso,Ii as formatDate,Ai as isoDate,Si as monthLabel,Ci as parseDate,Di as parseLooseDate,$e as useAIAutocomplete,Ti as withSkippedParams};
|
|
1604
|
+
`,document.head.appendChild(e)}var wt={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as $e}from"react/jsx-runtime";function xt({disabled:e,onClick:n}){return $e("button",{type:"button","data-aia-submit":"",className:wt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),n()},"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 So,identifiedParamLabel as Co,selectedIsoFromText as Do}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as It,useEffect as ke,useRef as F,useState as Eo}from"react";import{useRef as yt}from"react";function _t(e){let n=yt(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=yt({key:"",overrides:void 0});if(a.current.key!==t){let r={};for(let o of Object.keys(e??{})){let i=(g,b,w)=>{let c=n.current?.[o];return c?c(g,b,w):[]};r[o]=i}a.current={key:t,overrides:e?r:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as kt}from"react";function Pt(e){let n=kt(e);n.current=e;let t=kt(null);t.current===null&&(t.current={fetch:(r,o)=>{let i=n.current;return i?i.fetch(r,o):Promise.reject(new Error("products config removed"))},transform:r=>n.current?.transform(r)??[],get limit(){return n.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var To={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,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};function je({onSubmit:e,onResult:n,onError:t,optionOverrides:a,maskCompletedText:r,apiConfig:o,additionalContext:i,columns:g=2,dropdownTrigger:b,optionsPosition:w,closeDropdownOnBlur:c,showNonTappableOptions:x,showSkipButton:k,onFocus:y,onBlur:v,value:D,completedParams:E,onChange:Y,onParamsChange:Q,products:O,onProductSelect:P,source:X,setCursor:Z}){let p=F(null),[J,ee]=Eo(null),T=F(e);T.current=e;let W=F(n);W.current=n;let te=F(t);te.current=t;let U=F(Y);U.current=Y;let oe=F(Q);oe.current=Q;let ae=F(y);ae.current=y;let R=F(v);R.current=v;let M=F(Z);M.current=Z;let q=F(P);q.current=P;let N=Pt(O),u=_t(a);ke(()=>{if(typeof document>"u")return;let h=new So(document.createElement("div"),{renderMode:"headless",apiConfig:o,additionalContext:i,optionOverrides:u.overrides,maskCompletedText:r,columns:g,dropdownTrigger:b,optionsPosition:w,closeDropdownOnBlur:c,showNonTappableOptions:x,source:X,value:D,completedParams:E,onSubmit:(...C)=>T.current?.(...C),onResult:(...C)=>W.current?.(...C),onError:(...C)=>te.current?.(...C),onChange:(...C)=>U.current?.(...C),onParamsChange:(...C)=>oe.current?.(...C),onFocus:()=>ae.current?.(),onBlur:()=>R.current?.(),onProductSelect:C=>q.current?.(C),setCursor:C=>M.current?.(C),products:N.config});p.current=h,ee(h.getState());let z=h.subscribe(C=>ee(C));return()=>{z(),h.destroy(),p.current===h&&(p.current=null)}},[]),ke(()=>{D!==void 0&&p.current?.setValue(D)},[D]),ke(()=>{E!==void 0&&p.current?.setCompletedParams(E)},[E]);let G=JSON.stringify(o??null),s;try{s=JSON.stringify(i??null)}catch{s="[unstringifiable]"}ke(()=>{p.current?.update({apiConfig:o,additionalContext:i,optionOverrides:u.overrides,dropdownTrigger:b,optionsPosition:w,closeDropdownOnBlur:c,showNonTappableOptions:x})},[G,s,u.key,b,w,c,x]);let m=F(!1);ke(()=>{if(!m.current){m.current=!0;return}p.current?.update({products:N.config})},[N.enabled]);let f=F(null);f.current===null&&(f.current={handleTextChange:h=>p.current?.handleTextChange(h),handleKeyDown:h=>{let z="nativeEvent"in h?h.nativeEvent:h;p.current?.handleKeyDown(z)},setFocused:h=>p.current?.setFocused(h),startEditingParam:h=>p.current?.startEditingParam(h),exitEditMode:()=>p.current?.exitEditMode(),handleCaretAfterInput:h=>p.current?.handleCaretAfterInput(h),handleCaretMove:h=>p.current?.handleCaretMove(h),replaceEditingRange:h=>p.current?.replaceEditingRange(h)??!1,setActivePill:h=>p.current?.setActivePill(h),skipActivePill:()=>p.current?.skipActivePill(),removeLastParam:()=>p.current?.removeLastParam(),clearNewParamId:()=>p.current?.clearNewParamId(),reset:()=>p.current?.reset(),selectOption:h=>p.current?.selectOption(h),selectProduct:h=>p.current?.selectProduct(h),setActiveDropdownIndex:h=>p.current?.setActiveDropdownIndex(h),showPreviousMonth:()=>p.current?.showPreviousMonth(),showNextMonth:()=>p.current?.showNextMonth(),handleFocus:()=>p.current?.setFocused(!0),handleBlur:()=>p.current?.setFocused(!1)});let l=f.current,_=It(h=>{let z=h.target.value,Me=z.length>0&&!h.nativeEvent?.isComposing&&z[0]!==z[0].toUpperCase()?z[0].toUpperCase()+z.slice(1):z;p.current?.handleTextChange(Me)},[]),A=It(h=>{p.current?.handleKeyDown(h.nativeEvent)},[]),L=p.current,d=J??To,ie=D!==void 0?D:d.text,ge=E!==void 0?E:d.completedParams,ce=d.actionableSuggestions,he=ce[0],$=L?.listboxId??"",ne=d.activeDropdownIndex>=0&&L?`${$}-option-${d.activeDropdownIndex}`:void 0,re=d.editingParam,se=d.editingIdentified,we=re?{type:re.suggestionType,text:re.suggestionPlaceholder,required:!0,options:re.options}:se?{type:se.type,text:Co(se.type),required:!0,options:[]}:null,Ie=we??he,Oe=we?[we]:ce,Ae=!L||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:ge,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:ce,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:$,error:d.error,products:d.products,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:re,editingIdentified:se,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:_,onKeyDown:A,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":ne,"aria-autocomplete":"list","aria-controls":$},reset:l.reset,dropdownProps:{suggestions:Ie?[{...Ie,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:$,pills:Oe,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(k??!0)&&!re&&!se,skipDisabled:d.inSelectionAnimation,isLoading:Ae,isInputEmpty:ie.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:se?se.iso:Do(re?.text),onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:w??"below"}}}import{extractPlainText as At,getCursorOffset as St,plainTextLength as Ro,renderEditableContent as Lo,setCursorOffset as Ct}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as K,useEffect as Ve,useLayoutEffect as Ye,useRef as be}from"react";var Le;function Oo(){if(Le!==void 0)return Le;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Le=e.contentEditable==="plaintext-only",Le}function Dt(e){let{segments:n,newParamId:t,editingParam:a,editingIdentified:r,editingAnchor:o,caretOffset:i,placeholderText:g,isFocused:b,isDropdownOpen:w,listboxId:c,activeDescendantId:x,autoFocus:k,handleTextChange:y,handleKeyDown:v,handleCaretAfterInput:D,handleCaretMove:E,startEditingParam:Y,replaceEditingRange:Q,setFocused:O}=e,P=be(null),X=be(!1),Z=be(""),p=be(""),J=be(null),ee=be(0);J.current=i,Ve(()=>{if(!k)return;let s=P.current;if(!s)return;document.activeElement===s?O(!0):s.focus();let m=s.ownerDocument??document,f=m.getSelection(),l=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!l){let _=m.createRange();_.selectNodeContents(s),_.collapse(!0),f.removeAllRanges(),f.addRange(_)}},[k,O]),Ve(()=>{let s=P.current;if(!s)return;let m=s.ownerDocument??document,f=()=>{let l=m.getSelection();if(!l||l.rangeCount===0||!l.anchorNode||!s.contains(l.anchorNode))return;let _=l.anchorNode,A=_.nodeType===Node.ELEMENT_NODE?_:_.parentElement,d=(l.isCollapsed?A?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ie=a?.id??r?.id??null;if(d&&d!==ie){Y(d);return}performance.now()-ee.current<50||E(St(s))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[a,r,Y,E]),Ye(()=>{let s=P.current;s&&Lo({input:s,segments:n,newParamId:t,editingParamId:a?.id??null,placeholderText:g??"",isFocused:b})},[n,t,a,g,b]),Ye(()=>{let s=Z.current,m=t??"";if(Z.current=m,!m||m===s)return;let f=P.current;if(!f)return;f.focus();let l=J.current??Ro(f);Ct(f,l)},[t]),Ye(()=>{let s=p.current,m=a?.id??"";if(p.current=m,!m||m===s||o==null)return;let f=P.current;f&&Ct(f,o)},[a,o]);let T=K(()=>{if(X.current)return;let s=P.current;if(!s)return;let m=At(s),l=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;y(l)},[y]),W=K(()=>{ee.current=performance.now(),T();let s=P.current;s&&D(St(s))},[T,D]);Ve(()=>{let s=P.current;if(!s)return;let m=f=>{let l=f,_=l.inputType;if(_==="insertParagraph"||_==="insertLineBreak"||_==="insertFromDrop"){f.preventDefault();return}if(_.startsWith("insert")||_.startsWith("delete")){let A=_.startsWith("delete")?"":l.data??"";Q(A)&&f.preventDefault()}};return s.addEventListener("beforeinput",m),()=>s.removeEventListener("beforeinput",m)},[Q]);let te=K(()=>{X.current=!0},[]),U=K(()=>{X.current=!1,T()},[T]),oe=K(s=>{s.preventDefault();let m=P.current;if(!m)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let l=m.ownerDocument??document,_=l.getSelection();if(!_||_.rangeCount===0)return;let A=_.getRangeAt(0);if(!m.contains(A.startContainer))return;A.deleteContents();let L=l.createTextNode(f);A.insertNode(L),A.setStartAfter(L),A.collapse(!0),_.removeAllRanges(),_.addRange(A),T()},[T]),ae=K(s=>v(s),[v]),R=K(()=>O(!0),[O]),M=K(()=>O(!1),[O]),q=K(()=>P.current?.focus(),[]),N=K(()=>P.current?.blur(),[]),u=K(()=>{let s=P.current;return s?At(s):""},[]),G=Oo()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:G,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":c,"aria-expanded":w,"aria-activedescendant":x,spellCheck:!0,enterKeyHint:"send",onInput:W,onKeyDown:ae,onCompositionStart:te,onCompositionEnd:U,onPaste:oe,onFocus:R,onBlur:M},getPlainText:u,focus:q,blur:N}}import{jsx as ve,jsxs as Xe}from"react/jsx-runtime";function Ho(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ko=Mo(function({onSubmit:n,onResult:t,onError:a,optionOverrides:r,maskCompletedText:o,className:i,apiConfig:g,additionalContext:b,columns:w,pillPlacement:c="dropdown",mode:x="auto",optionsPosition:k="below",animations:y=!0,dropdownTrigger:v,closeDropdownOnBlur:D,showNonTappableOptions:E,showSkipButton:Y,autoFocus:Q=!0,onFocus:O,onBlur:P,value:X,completedParams:Z,onChange:p,onParamsChange:J,products:ee,onProductSelect:T,submitButton:W},te){let U=Pe(null),oe=Pe(null),ae=Pe(()=>{}),R=Pe(null),M=Pe(null);Et(()=>{let I=U.current;if(I)return R.current?R.current.setMode(x):R.current=new Fo(I,x),()=>{R.current?.destroy(),R.current=null}},[x]);let q=Qe(I=>{let pe=M.current?.current;pe&&(pe.focus(),Go(pe,I))},[]),{completedParams:N,skippedParams:u,identifiedParams:G,isReady:s,suggestionPills:m,setActivePill:f,skipActivePill:l,segments:_,newParamId:A,clearNewParamId:L,placeholderText:d,isFocused:ie,isDropdownOpen:ge,isActivePillSelected:ce,isLoading:he,activeIndex:$,listboxId:ne,handleTextChange:re,handleKeyDown:se,setFocused:we,editingParam:Ie,editingIdentified:Oe,editingAnchor:Ae,caretOffset:h,startEditingParam:z,handleCaretAfterInput:C,handleCaretMove:Me,replaceEditingRange:Tt,dropdownProps:Rt,reset:Se}=je({onSubmit:I=>ae.current(I),onResult:t,onError:a,optionOverrides:r,maskCompletedText:o,apiConfig:g,additionalContext:b,columns:w,dropdownTrigger:v,optionsPosition:k,closeDropdownOnBlur:D,showNonTappableOptions:E,showSkipButton:Y,onFocus:O,onBlur:P,value:X,completedParams:Z,onChange:p,onParamsChange:J,products:ee,onProductSelect:T,source:"full-sdk",setCursor:q});Et(()=>{if(!A)return;let I=window.setTimeout(()=>L(),650);return()=>window.clearTimeout(I)},[A,L]);let Lt=$>=0?`${ne}-option-${$}`:void 0,{inputRef:Ne,editorProps:Ot,focus:Ce,blur:Ze,getPlainText:Je}=Dt({segments:_,newParamId:A,editingParam:Ie,editingIdentified:Oe,editingAnchor:Ae,caretOffset:h,placeholderText:d,isFocused:ie,isDropdownOpen:ge,listboxId:ne,activeDescendantId:Lt,autoFocus:Q,handleTextChange:re,handleKeyDown:se,handleCaretAfterInput:C,handleCaretMove:Me,startEditingParam:z,replaceEditingRange:Tt,setFocused:we});M.current=Ne,zo(()=>{let I=oe.current,pe=Ne.current;if(!I||!pe)return;let et=()=>{let ot=I.firstElementChild;if(!ot)return;let Bt=ot.getBoundingClientRect(),Ft=pe.getBoundingClientRect();Bt.top>=Ft.bottom-2?I.setAttribute("data-aia-pill-wrapped",""):I.removeAttribute("data-aia-pill-wrapped")};et();let tt=new ResizeObserver(et);return tt.observe(pe),()=>tt.disconnect()},[_,m.length,he,Ne]),No(te,()=>({focus:Ce,blur:Ze,reset:Se,setMode:I=>R.current?.setMode(I),skipActivePill:l}),[Ce,Ze,Se,l]);let De=!!_.length||N.length>0,ze=Qe(()=>{if(!De)return;let I=Je();n(Bo(I,N,u,{identifiedParams:G,isReady:s})),Se()},[De,N,u,G,s,n,Se,Je]);ae.current=ze;let Mt=Qe(I=>{I.target?.closest("[data-aia-pill]")||Ce()},[Ce]),Nt=c==="inline",zt=c==="dropdown";return Xe("div",{ref:U,className:`magicx-aia ${fe.container} ${i??""}`,"data-pill-placement":c,"data-options-position":k,"data-animations":y?"on":"off","data-mode":Ho(x),children:[ve(qe,{...Rt,showPills:zt}),Xe("div",{className:fe.inputWrapper,onClick:Mt,children:[Xe("div",{className:fe.editorArea,"data-aia-editor":"",children:[ve("div",{...Ot,className:fe.input,"data-aia-input":""}),Nt&&(he||m.length>0)&&ve("span",{ref:oe,className:fe.pillListContainer,"data-aia-pill-list-container":"",children:ve(Te,{pills:m,activePillIndex:0,activeSelected:ce,onSelectPill:f,loading:he})})]}),W===null?null:W===void 0?ve(xt,{disabled:!De,onClick:ze}):ve("span",{"data-aia-submit":"",className:fe.submitSlot,onClick:I=>{De&&(I.stopPropagation(),ze())},children:W})]})]})});export{Ko as AIAutocomplete,qe as AIAutocompleteDropdown,Bi as WEEKDAY_LABELS,Ei as buildSubmitResult,Ti as cellDay,Ri as cellIso,Li as formatDate,Oi as isoDate,Mi as monthLabel,Ni as parseDate,zi as parseLooseDate,je as useAIAutocomplete,Fi as withSkippedParams};
|
|
1584
1605
|
//# sourceMappingURL=index.mjs.map
|