@magicx-eng/ai-autocomplete-react 0.12.0 → 0.13.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 +97 -2
- package/dist/index.d.mts +31 -18
- package/dist/index.d.ts +31 -18
- package/dist/index.js +159 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Qe=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var zt=Object.getOwnPropertyNames;var Nt=Object.prototype.hasOwnProperty;var Mt=(e,a)=>{for(var t in a)Qe(e,t,{get:a[t],enumerable:!0})},Bt=(e,a,t,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of zt(a))!Nt.call(e,n)&&n!==t&&Qe(e,n,{get:()=>a[n],enumerable:!(i=Lt(a,n))||i.enumerable});return e};var Gt=e=>Bt(Qe({},"__esModule",{value:!0}),e);var Yt={};Mt(Yt,{AIAutocomplete:()=>It,AIAutocompleteDropdown:()=>Fe,WEEKDAY_LABELS:()=>I.WEEKDAY_LABELS,buildSubmitResult:()=>I.buildSubmitResult,cellDay:()=>I.cellDay,cellIso:()=>I.cellIso,formatDate:()=>I.formatDate,isoDate:()=>I.isoDate,monthLabel:()=>I.monthLabel,parseDate:()=>I.parseDate,parseLooseDate:()=>I.parseLooseDate,useAIAutocomplete:()=>We,withSkippedParams:()=>I.withSkippedParams});module.exports=Gt(Yt);var I=require("@magicx-eng/ai-autocomplete-vanilla");var A=require("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
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
opacity: 0;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
`,document.head.appendChild(e)}var
|
|
182
|
+
`,document.head.appendChild(e)}var ke={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"};var Ae=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
183
183
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
184
184
|
* Consumer CSS always wins without !important.
|
|
185
185
|
*
|
|
@@ -665,7 +665,154 @@
|
|
|
665
665
|
opacity: 0.25;
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
`,document.head.appendChild(e)}var
|
|
668
|
+
`,document.head.appendChild(e)}var ve={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",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"};var U=require("@magicx-eng/ai-autocomplete-vanilla"),nt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
669
|
+
|
|
670
|
+
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
671
|
+
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
672
|
+
declarations must match, and \`datepickerParity.test.ts\` fails the build if
|
|
673
|
+
they drift. See CLAUDE.md's duplicated-stylesheet rule.
|
|
674
|
+
|
|
675
|
+
Every colour resolves through the same --aia-option-* chain the option rows
|
|
676
|
+
use. The dropdown paints a background but sets no \`color\`, so anything here
|
|
677
|
+
relying on \`color: inherit\` would pick up the HOST page's text colour and go
|
|
678
|
+
black on a dark panel \u2014 and \`prefers-color-scheme\` can't be used to guess,
|
|
679
|
+
because the panel's darkness comes from --aia-surface, which the media query
|
|
680
|
+
says nothing about. Going through the option chain means one consumer
|
|
681
|
+
override restyles the calendar and the options together. */
|
|
682
|
+
.DateGrid-module_datepicker_6RrTs {
|
|
683
|
+
display: flex;
|
|
684
|
+
flex-direction: column;
|
|
685
|
+
gap: 4px;
|
|
686
|
+
padding: 4px 2px 8px;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.DateGrid-module_header_z4LRk {
|
|
690
|
+
display: flex;
|
|
691
|
+
align-items: center;
|
|
692
|
+
justify-content: space-between;
|
|
693
|
+
gap: 8px;
|
|
694
|
+
padding: 2px 6px 6px;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.DateGrid-module_month_urB2T {
|
|
698
|
+
font-family: inherit;
|
|
699
|
+
font-size: var(--aia-date-month-font-size, 14px);
|
|
700
|
+
font-weight: 500;
|
|
701
|
+
line-height: 20px;
|
|
702
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
.DateGrid-module_nav_ap4AN {
|
|
706
|
+
display: inline-flex;
|
|
707
|
+
align-items: center;
|
|
708
|
+
justify-content: center;
|
|
709
|
+
width: 24px;
|
|
710
|
+
height: 24px;
|
|
711
|
+
padding: 0;
|
|
712
|
+
border: none;
|
|
713
|
+
border-radius: 6px;
|
|
714
|
+
background: transparent;
|
|
715
|
+
font-family: inherit;
|
|
716
|
+
font-size: 16px;
|
|
717
|
+
line-height: 1;
|
|
718
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
719
|
+
cursor: pointer;
|
|
720
|
+
transition:
|
|
721
|
+
color 150ms ease-out,
|
|
722
|
+
background-color 150ms ease-out;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
.DateGrid-module_nav_ap4AN:hover {
|
|
726
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
727
|
+
background: var(--aia-option-bg, transparent);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
.DateGrid-module_weekdays_3EA3q,
|
|
731
|
+
.DateGrid-module_grid_mQCgw {
|
|
732
|
+
display: grid;
|
|
733
|
+
/* The 7 columns live on the cell container itself, not on an ancestor:
|
|
734
|
+
KeyboardController.getEffectiveColumns() measures grid-template-columns by
|
|
735
|
+
walking up from option-0's PARENT, and it is this number that makes
|
|
736
|
+
ArrowDown mean "+1 week". */
|
|
737
|
+
grid-template-columns: repeat(7, minmax(0, 1fr));
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
.DateGrid-module_weekday_3lF4B {
|
|
741
|
+
padding: 2px 0;
|
|
742
|
+
text-align: center;
|
|
743
|
+
font-family: inherit;
|
|
744
|
+
font-size: var(--aia-date-weekday-font-size, 11px);
|
|
745
|
+
font-weight: 500;
|
|
746
|
+
line-height: 16px;
|
|
747
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
748
|
+
opacity: 0.7;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
.DateGrid-module_cell_59k0y {
|
|
752
|
+
display: flex;
|
|
753
|
+
align-items: center;
|
|
754
|
+
justify-content: center;
|
|
755
|
+
/* Deliberately NOT sized here. Giving the grid item a definite size (an
|
|
756
|
+
aspect-ratio, a width) stops it stretching to its track, so it parks at
|
|
757
|
+
the track's start edge and the whole month drifts left of the weekday
|
|
758
|
+
header above it \u2014 the two grids agree on their columns, and only the
|
|
759
|
+
items disagree, which makes it look like a column-count bug. The cell
|
|
760
|
+
fills its track; the square is the number span inside it. */
|
|
761
|
+
min-width: 0;
|
|
762
|
+
/* Keeps a month readable in a narrow dropdown without letting a 6-row month
|
|
763
|
+
grow the panel past the options grid it replaces. */
|
|
764
|
+
height: var(--aia-date-row-height, 40px);
|
|
765
|
+
font-family: inherit;
|
|
766
|
+
font-size: var(--aia-date-cell-font-size, 14px);
|
|
767
|
+
font-weight: 450;
|
|
768
|
+
line-height: 20px;
|
|
769
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/* The visual box: everything a cell paints \u2014 fill, ring, press \u2014 lands here so
|
|
773
|
+
it reads as a square centred in its column rather than a full-width band. */
|
|
774
|
+
.DateGrid-module_number_aoT01 {
|
|
775
|
+
display: flex;
|
|
776
|
+
align-items: center;
|
|
777
|
+
justify-content: center;
|
|
778
|
+
width: var(--aia-date-cell-size, 36px);
|
|
779
|
+
height: var(--aia-date-cell-size, 36px);
|
|
780
|
+
border-radius: 8px;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
.DateGrid-module_day_cB3u9 {
|
|
784
|
+
cursor: pointer;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
.DateGrid-module_blank_ivgRC {
|
|
788
|
+
cursor: default;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
.DateGrid-module_day_cB3u9:hover .DateGrid-module_number_aoT01,
|
|
792
|
+
.DateGrid-module_highlighted_YIdtK .DateGrid-module_number_aoT01 {
|
|
793
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
794
|
+
background: var(--aia-option-bg, transparent);
|
|
795
|
+
font-weight: 500;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/* Today reads as an outline, the committed answer as a fill \u2014 so a re-edited
|
|
799
|
+
date can show both at once without either being ambiguous. */
|
|
800
|
+
.DateGrid-module_today_iI3ME .DateGrid-module_number_aoT01 {
|
|
801
|
+
box-shadow: inset 0 0 0 1px
|
|
802
|
+
var(--aia-date-today-ring, var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb)));
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
.DateGrid-module_selected_28KDn .DateGrid-module_number_aoT01 {
|
|
806
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
807
|
+
background: var(--aia-date-selected-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.12));
|
|
808
|
+
font-weight: 500;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
.DateGrid-module_pressed_bEyyN .DateGrid-module_number_aoT01 {
|
|
812
|
+
opacity: 0.8;
|
|
813
|
+
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
814
|
+
}
|
|
815
|
+
`,document.head.appendChild(e)}var C={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",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};var M=require("react/jsx-runtime"),Ot=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function st({options:e,activeIndex:a,listboxId:t,view:i,selectedIso:n,onSelect:r,onHighlight:s,onPreviousMonth:g,onNextMonth:b}){let v=(0,U.isoDate)(new Date);return(0,M.jsxs)("div",{className:C.datepicker,"data-aia-datepicker":"",children:[(0,M.jsxs)("div",{className:C.header,children:[(0,M.jsx)("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:g,children:"\u2039"}),(0,M.jsx)("span",{className:C.month,"data-aia-date-month":"","aria-live":"polite",children:(0,U.monthLabel)(i)}),(0,M.jsx)("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:b,children:"\u203A"})]}),(0,M.jsx)("div",{className:C.weekdays,"aria-hidden":"true",children:U.WEEKDAY_LABELS.map((m,f)=>(0,M.jsx)("span",{className:C.weekday,children:m},Ot[f]))}),(0,M.jsx)("div",{className:C.grid,"data-aia-date-grid":"",children:e.map((m,f)=>(0,M.jsx)(Ft,{option:m,id:`${t}-option-${f}`,index:f,isHighlighted:f===a&&m.is_tappable,isToday:(0,U.cellIso)(m)===v,isSelected:n!=null&&(0,U.cellIso)(m)===n,onSelect:r,onHighlight:s},(0,U.cellIso)(m)??`pad-${f}`))})]})}function Ft({option:e,id:a,index:t,isHighlighted:i,isToday:n,isSelected:r,onSelect:s,onHighlight:g}){let[b,v]=(0,nt.useState)(!1),m=(0,U.cellDay)(e);if(m==null)return(0,M.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${C.cell} ${C.blank}`});let f=()=>{v(!0),s(e),setTimeout(()=>v(!1),500)},z=[C.cell,C.day,i?C.highlighted:"",n?C.today:"",r?C.selected:"",b?C.pressed:""].filter(Boolean).join(" ");return(0,M.jsx)("div",{id:a,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":i,"aria-label":e.text,tabIndex:0,className:z,onClick:f,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),f())},onMouseEnter:()=>g(t),children:(0,M.jsx)("span",{className:C.number,children:m})})}var Pe=require("@magicx-eng/ai-autocomplete-vanilla"),Me=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
|
|
669
816
|
.aia-cluster {
|
|
670
817
|
display: flex;
|
|
671
818
|
flex-wrap: wrap;
|
|
@@ -707,7 +854,7 @@
|
|
|
707
854
|
justify-content: space-around;
|
|
708
855
|
}
|
|
709
856
|
}
|
|
710
|
-
`,document.head.appendChild(e)}var
|
|
857
|
+
`,document.head.appendChild(e)}var Ye=require("react/jsx-runtime");function Ee({gap:e,align:a="center",justify:t="start",noWrap:i=!1,inline:n=!1,className:r,children:s,...g}){let b=e?{"--aia-cluster-gap":e}:void 0,v={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":i||void 0,"data-inline":n||void 0,style:b,...g};return n?(0,Ye.jsx)("span",{...v,children:s}):(0,Ye.jsx)("div",{...v,children:s})}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
|
|
711
858
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
712
859
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
713
860
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -837,7 +984,7 @@
|
|
|
837
984
|
justify-content: flex-end;
|
|
838
985
|
}
|
|
839
986
|
}
|
|
840
|
-
`,document.head.appendChild(e)}var
|
|
987
|
+
`,document.head.appendChild(e)}var pe={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"};var te=require("react/jsx-runtime");function lt({isOptionHighlighted:e=!1,isInputEmpty:a=!1}){let{key:t,hint:i}=(0,Pe.getFooterHint)(e,a),[n,r]=(0,Me.useState)(Pe.ATTRIBUTION_URL);return(0,Me.useEffect)(()=>{r((0,Pe.buildAttributionUrl)())},[]),(0,te.jsx)("footer",{className:pe.footer,"data-aia-footer":"",children:(0,te.jsxs)(Ee,{justify:"between",noWrap:!0,className:pe.row,children:[(0,te.jsxs)(Ee,{gap:"5px",className:pe.hintGroup,children:[(0,te.jsx)("kbd",{className:pe.key,children:t}),(0,te.jsx)("span",{className:pe.hint,children:i})]}),(0,te.jsxs)("a",{className:pe.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,te.jsx)("span",{className:pe.brand,children:"AI"}),(0,te.jsx)("span",{className:pe.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,
|
|
841
988
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
842
989
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
843
990
|
as it was when the outline was dashed. */
|
|
@@ -894,7 +1041,7 @@
|
|
|
894
1041
|
opacity: 0;
|
|
895
1042
|
}
|
|
896
1043
|
}
|
|
897
|
-
`,document.head.appendChild(e)}var
|
|
1044
|
+
`,document.head.appendChild(e)}var xe={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"};var pt=require("react/jsx-runtime"),Je={selected:1,first:.7,next:.4,last:.2};function dt({label:e,state:a,rounded:t,loading:i,onClick:n}){let r=[xe.pill,t?xe.rounded:"",i?xe.skeleton:""].filter(Boolean).join(" ");return(0,pt.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":i?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:r,style:{opacity:Je[a]},onMouseDown:s=>s.preventDefault(),onClick:i?void 0:n,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 {
|
|
898
1045
|
position: relative;
|
|
899
1046
|
z-index: 1;
|
|
900
1047
|
pointer-events: auto;
|
|
@@ -904,7 +1051,7 @@
|
|
|
904
1051
|
align-items: center;
|
|
905
1052
|
vertical-align: middle;
|
|
906
1053
|
}
|
|
907
|
-
`,document.head.appendChild(e)}var
|
|
1054
|
+
`,document.head.appendChild(e)}var Xe={list:"PillList-module_list_qvLqO"};var Te=require("react/jsx-runtime"),Ht=[125,69];function ct(e){return e===0?"first":e===1?"next":"last"}function Be({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:i,rounded:n,loading:r}){return r&&e.length===0?(0,Te.jsx)("span",{className:Xe.list,"data-aia-pill-list-loading":"",children:Ht.map((s,g)=>(0,Te.jsx)("span",{"data-aia-pill-skeleton":"",className:`${xe.pill} ${n?xe.rounded:""} ${xe.skeleton}`,style:{width:s,opacity:Je[ct(g)]}},`skel-${s}`))}):(0,Te.jsx)("span",{className:Xe.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((s,g)=>{let b=!!i&&g===a;return(0,Te.jsx)(dt,{label:s.text,state:b?"selected":ct(g),selected:b,rounded:n,loading:r,onClick:()=>t(g)},`${s.type}-${s.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
|
|
908
1055
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
909
1056
|
theming one package sees the same result in the other.
|
|
910
1057
|
|
|
@@ -1071,7 +1218,7 @@
|
|
|
1071
1218
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1072
1219
|
);
|
|
1073
1220
|
}
|
|
1074
|
-
`,document.head.appendChild(e)}var
|
|
1221
|
+
`,document.head.appendChild(e)}var Q={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"};var K=require("react/jsx-runtime");function ut({products:e,listboxId:a,onSelect:t,onFocusChange:i,focusable:n=!0}){if(e.length===0)return null;let r=`${a}-products-label`;return(0,K.jsxs)("section",{className:Q.section,"data-aia-products":"",role:"group","aria-labelledby":r,children:[(0,K.jsx)("div",{className:Q.label,id:r,children:"Products"}),(0,K.jsx)("div",{className:Q.row,"data-aia-products-row":"",children:e.map((s,g)=>(0,K.jsx)(Kt,{product:s,id:`${a}-product-${g}`,onSelect:t,onFocusChange:i,focusable:n},s.id))})]})}function Kt({product:e,id:a,onSelect:t,onFocusChange:i,focusable:n}){let r=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),t(e))};return(0,K.jsxs)("a",{id:a,className:Q.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:r,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),t(e))},onFocus:()=>i?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||i?.(!1)},children:[(0,K.jsx)("span",{className:Q.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,K.jsx)("img",{className:Q.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,K.jsxs)("span",{className:Q.body,children:[e.vendor?(0,K.jsx)("span",{className:Q.vendor,children:e.vendor}):null,(0,K.jsx)("span",{className:Q.title,children:e.title}),e.price?(0,K.jsx)("span",{className:Q.price,children:e.price}):null]})]})}var Se=require("@magicx-eng/ai-autocomplete-vanilla"),Oe=require("react");var mt=require("@magicx-eng/ai-autocomplete-vanilla"),Ge=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
|
|
1075
1222
|
.aia-grid {
|
|
1076
1223
|
display: grid;
|
|
1077
1224
|
grid-template-columns: repeat(
|
|
@@ -1106,7 +1253,7 @@
|
|
|
1106
1253
|
border-radius: 3px;
|
|
1107
1254
|
}
|
|
1108
1255
|
}
|
|
1109
|
-
`,document.head.appendChild(e)}var
|
|
1256
|
+
`,document.head.appendChild(e)}var gt=require("react/jsx-runtime");function ht({min:e="16rem",max:a,gap:t,scroll:i=!1,maxHeight:n,scrollResetKey:r,cols:s,className:g,children:b,...v}){let m=(0,Ge.useRef)(null);(0,Ge.useLayoutEffect)(()=>{if(r===void 0)return;let z=m.current;z&&(z.scrollTop=0)},[r]);let f={"--aia-grid-min":e};return a&&(f["--aia-grid-max"]=a),t&&(f["--aia-grid-gap"]=t),n&&(f["--aia-grid-max-height"]=n),s&&(f.gridTemplateColumns=(0,mt.optionsGridTemplateColumns)(s)),(0,gt.jsx)("div",{ref:m,className:g?`aia-grid ${g}`:"aia-grid","data-scroll":i||void 0,style:f,...v,children:b})}var Ie=require("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 {
|
|
1110
1257
|
position: relative;
|
|
1111
1258
|
overflow: visible;
|
|
1112
1259
|
display: flex;
|
|
@@ -1456,7 +1603,7 @@
|
|
|
1456
1603
|
filter: brightness(0.55);
|
|
1457
1604
|
}
|
|
1458
1605
|
}
|
|
1459
|
-
`,document.head.appendChild(e)}var
|
|
1606
|
+
`,document.head.appendChild(e)}var Y={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",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",glassFade:"SuggestionItem-module_glassFade_oyiSj",tapDown:"SuggestionItem-module_tapDown_G3WGz",streaks:"SuggestionItem-module_streaks_d9PEB",streaksVert:"SuggestionItem-module_streaksVert_ERlV1",streakHorizRight:"SuggestionItem-module_streakHorizRight_aboGz",streakHorizLeft:"SuggestionItem-module_streakHorizLeft_BreWJ",streakVertUp:"SuggestionItem-module_streakVertUp_to1GD",streakVertDown:"SuggestionItem-module_streakVertDown_OrcLh",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};var we=require("react/jsx-runtime");function ft({option:e,isHighlighted:a,onSelect:t,onHighlight:i,id:n,loading:r}){let[s,g]=(0,Ie.useState)(!1),b=(0,Ie.useRef)(void 0);(0,Ie.useEffect)(()=>()=>clearTimeout(b.current),[]);let v=()=>{r||!e.is_tappable||s||(g(!0),t(e),clearTimeout(b.current),b.current=setTimeout(()=>g(!1),500))},m=[Y.item,a&&!r?Y.highlighted:"",e.is_tappable?Y.tappable:Y.nonTappable,s?Y.pressed:""].filter(Boolean).join(" ");return(0,we.jsxs)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":r?"":void 0,"aria-selected":a,className:m,tabIndex:r||!e.is_tappable?-1:0,onClick:v,onKeyDown:f=>{!r&&e.is_tappable&&(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),v())},onMouseEnter:!r&&e.is_tappable?i:void 0,children:[(0,we.jsx)("div",{className:Y.streaks}),(0,we.jsx)("div",{className:Y.streaksVert}),(0,we.jsxs)("span",{className:Y.content,children:[(0,we.jsx)("span",{className:Y.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,we.jsx)("span",{className:Y.tag,children:e.tag})]})]})}var Ze=require("react/jsx-runtime");function Wt(){let[e,a]=(0,Oe.useState)(Se.isOptionsGridMobileViewport);return(0,Oe.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Se.OPTIONS_GRID_MOBILE_QUERY),i=()=>a(t.matches);return i(),t.addEventListener("change",i),()=>t.removeEventListener("change",i)},[]),e}function bt({options:e,activeIndex:a,onSelect:t,onHighlight:i,listboxId:n,loading:r,groupKey:s}){let g=Wt(),{cols:b,maxHeight:v}=(0,Se.computeOptionsGridLayout)(e.length,g);return(0,Ze.jsx)(ht,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,cols:b,maxHeight:v,children:e.map((m,f)=>(0,Ze.jsx)(ft,{option:m,isHighlighted:f===a,onSelect:t,onHighlight:()=>i(f),id:`${n}-option-${f}`,loading:r},m.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
|
|
1460
1607
|
.aia-stack {
|
|
1461
1608
|
display: flex;
|
|
1462
1609
|
flex-direction: column;
|
|
@@ -1473,7 +1620,7 @@
|
|
|
1473
1620
|
}
|
|
1474
1621
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1475
1622
|
}
|
|
1476
|
-
`,document.head.appendChild(e)}var
|
|
1623
|
+
`,document.head.appendChild(e)}var xt=require("react/jsx-runtime");function vt({space:e,align:a="stretch",className:t,children:i,...n}){let r=e?{"--aia-stack-space":e}:void 0;return(0,xt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:r,...n,children:i})}var B=require("react/jsx-runtime"),Ut=[159,119,164],Vt=()=>{},wt=()=>{};function qt(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,i]=(0,Ae.useState)(a);if((0,Ae.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>i(n.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Fe({suggestions:e,activeIndex:a,onSelect:t,onHighlight:i,isOpen:n,id:r,className:s,pills:g,onPillClick:b,showPills:v=!0,onSkip:m,showSkipButton:f=!0,skipDisabled:z=!1,activeSelected:G=!1,isLoading:N=!1,isInputEmpty:O=!1,products:V,onProductSelect:ae,onProductFocusChange:ce,formatType:F="options",dateView:P=null,selectedDateIso:X=null,onPreviousMonth:u,onNextMonth:ue,optionsPosition:oe="below",mode:ie}){let E=qt(ie),me=E!==void 0,re=e[0]?.options??[],ne=!!(g&&g.length>0&&b),se=!!(V&&V.length>0),T=n&&(re.length>0||v&&ne||N||se),q={suggestions:e,activeIndex:a,pills:g,showPills:v,showSkipButton:f,skipDisabled:z,activeSelected:G,isLoading:N,isInputEmpty:O,products:V,formatType:F,dateView:P,selectedDateIso:X},Z=(0,Ae.useRef)(q);T&&(Z.current=q);let h=T?q:Z.current,H=h.suggestions[0],R=H?.options??[],he=h.activeIndex>=0&&!!R[h.activeIndex]?.is_tappable,l=!!(h.pills&&h.pills.length>0&&b),c=h.showPills&&l,o=h.showPills&&!l&&h.isLoading,y=c||o,x=l&&h.showSkipButton&&!h.isInputEmpty&&!!m,S=h.pills?.[0]?.text,d=h.formatType==="date"&&h.dateView!=null,$=R.length>0&&!d,ee=R.length>0&&d,ge=h.isLoading&&!$&&!ee,ye=h.products??[];return(0,B.jsx)("div",{id:r,role:"listbox","data-aia-dropdown":"","data-options-position":oe,"data-mode":E,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":ye.length>0?"":void 0,className:`${me?"magicx-aia ":""}${ve.dropdown} ${T?ve.visible:""} ${s??""}`,onMouseDown:j=>j.preventDefault(),children:(0,B.jsxs)(vt,{space:"8px",children:[(y||x)&&(0,B.jsxs)(Ee,{noWrap:!0,className:ve.pillBar,"data-aia-pillbar":"",children:[y&&(0,B.jsx)("span",{className:ve.pillScroll,"data-aia-pill-scroll":"",children:(0,B.jsx)(Be,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:b??(()=>{}),rounded:!0,loading:h.isLoading})}),x&&(0,B.jsx)("button",{type:"button",tabIndex:-1,className:ve.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":S?`Skip ${S}`:"Skip",onClick:m,children:"skip"})]}),$&&(0,B.jsx)(bt,{options:R,activeIndex:h.activeIndex,onSelect:t,onHighlight:i,listboxId:r,loading:h.isLoading,groupKey:H?`${H.type} ${H.text}`:""}),ee&&h.dateView&&(0,B.jsx)(st,{options:R,activeIndex:h.activeIndex,listboxId:r,view:h.dateView,selectedIso:h.selectedDateIso??null,onSelect:t,onHighlight:i,onPreviousMonth:u??wt,onNextMonth:ue??wt}),ge&&(0,B.jsx)("div",{className:ve.skeletonBars,"data-aia-skeleton-bars":"",children:Ut.map(j=>(0,B.jsx)("span",{className:ve.skeletonBar,style:{width:j}},`bar-${j}`))}),(0,B.jsx)(ut,{products:ye,listboxId:r,onSelect:ae??Vt,onFocusChange:ce,focusable:T}),(0,B.jsx)(lt,{isOptionHighlighted:he,isInputEmpty:h.isInputEmpty})]})})}var De=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.SubmitButton-module_submitButton_otz7H {
|
|
1477
1624
|
flex-shrink: 0;
|
|
1478
1625
|
width: 32px;
|
|
1479
1626
|
height: 32px;
|
|
@@ -1508,5 +1655,5 @@
|
|
|
1508
1655
|
);
|
|
1509
1656
|
cursor: default;
|
|
1510
1657
|
}
|
|
1511
|
-
`,document.head.appendChild(e)}var ht={submitButton:"SubmitButton-module_submitButton_otz7H"};var Me=require("react/jsx-runtime");function gt({disabled:e,onClick:a}){return(0,Me.jsx)("button",{type:"button","data-aia-submit":"",className:ht.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,Me.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Me.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var bt=require("@magicx-eng/ai-autocomplete-vanilla"),x=require("react");var Je=require("react");function ft(e){let a=(0,Je.useRef)(e);a.current=e;let t=(0,Je.useRef)(null);t.current===null&&(t.current={fetch:(n,l)=>{let i=a.current;return i?i.fetch(n,l):Promise.reject(new Error("products config removed"))},transform:n=>a.current?.transform(n)??[],get limit(){return a.current?.limit}});let r=e!==void 0;return{config:r?t.current:void 0,enabled:r}}var Ot={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function Ne({onSubmit:e,onError:a,optionOverrides:t,maskCompletedText:r,apiConfig:n,additionalContext:l,generateStartingStateOptions:i,columns:g=2,dropdownTrigger:w,optionsPosition:y,closeDropdownOnBlur:_,showNonTappableOptions:b,showSkipButton:M,onFocus:J,onBlur:$,value:D,completedParams:C,onChange:X,onParamsChange:R,products:P,onProductSelect:j,source:Z,setCursor:Y}){let c=(0,x.useRef)(null),[re,T]=(0,x.useState)(null),H=(0,x.useRef)(e);H.current=e;let N=(0,x.useRef)(a);N.current=a;let ee=(0,x.useRef)(X);ee.current=X;let h=(0,x.useRef)(R);h.current=R;let O=(0,x.useRef)(J);O.current=J;let G=(0,x.useRef)($);G.current=$;let L=(0,x.useRef)(Y);L.current=Y;let K=(0,x.useRef)(j);K.current=j;let te=ft(P);(0,x.useEffect)(()=>{if(typeof document>"u")return;let d=new bt.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:n,additionalContext:l,generateStartingStateOptions:i,optionOverrides:t,maskCompletedText:r,columns:g,dropdownTrigger:w,optionsPosition:y,closeDropdownOnBlur:_,showNonTappableOptions:b,source:Z,value:D,completedParams:C,onSubmit:(...A)=>H.current?.(...A),onError:(...A)=>N.current?.(...A),onChange:(...A)=>ee.current?.(...A),onParamsChange:(...A)=>h.current?.(...A),onFocus:()=>O.current?.(),onBlur:()=>G.current?.(),onProductSelect:A=>K.current?.(A),setCursor:A=>L.current?.(A),products:te.config});c.current=d,T(d.getState());let E=d.subscribe(A=>T(A));return()=>{E(),d.destroy(),c.current===d&&(c.current=null)}},[]),(0,x.useEffect)(()=>{D!==void 0&&c.current?.setValue(D)},[D]),(0,x.useEffect)(()=>{C!==void 0&&c.current?.setCompletedParams(C)},[C]);let ae=JSON.stringify(n??null),W;try{W=JSON.stringify(l??null)}catch{W="[unstringifiable]"}let s=(0,x.useRef)(t),p=(0,x.useRef)(0);if(t!==s.current){let d=s.current,E=t,A=Object.keys(d??{}),fe=Object.keys(E??{});(A.length!==fe.length||fe.some(se=>!d?.[se]||E[se]!==d[se]))&&p.current++,s.current=t}(0,x.useEffect)(()=>{c.current?.update({apiConfig:n,additionalContext:l,generateStartingStateOptions:i,optionOverrides:t,dropdownTrigger:w,optionsPosition:y,closeDropdownOnBlur:_,showNonTappableOptions:b})},[ae,W,i,p.current,w,y,_,b]);let u=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(!u.current){u.current=!0;return}c.current?.update({products:te.config})},[te.enabled]);let f=(0,x.useRef)(null);f.current===null&&(f.current={handleTextChange:d=>c.current?.handleTextChange(d),handleKeyDown:d=>{let E="nativeEvent"in d?d.nativeEvent:d;c.current?.handleKeyDown(E)},setFocused:d=>c.current?.setFocused(d),startEditingParam:d=>c.current?.startEditingParam(d),exitEditMode:()=>c.current?.exitEditMode(),handleCaretAfterInput:d=>c.current?.handleCaretAfterInput(d),handleCaretMove:d=>c.current?.handleCaretMove(d),replaceEditingRange:d=>c.current?.replaceEditingRange(d)??!1,setActivePill:d=>c.current?.setActivePill(d),skipActivePill:()=>c.current?.skipActivePill(),removeLastParam:()=>c.current?.removeLastParam(),clearNewParamId:()=>c.current?.clearNewParamId(),reset:()=>c.current?.reset(),selectOption:d=>c.current?.selectOption(d),selectProduct:d=>c.current?.selectProduct(d),setActiveDropdownIndex:d=>c.current?.setActiveDropdownIndex(d),handleFocus:()=>c.current?.setFocused(!0),handleBlur:()=>c.current?.setFocused(!1)});let o=f.current,I=(0,x.useCallback)(d=>{let E=d.target.value,fe=E.length>0&&!d.nativeEvent?.isComposing&&E[0]!==E[0].toUpperCase()?E[0].toUpperCase()+E.slice(1):E;c.current?.handleTextChange(fe)},[]),ue=(0,x.useCallback)(d=>{c.current?.handleKeyDown(d.nativeEvent)},[]),oe=c.current,m=re??Ot,Se=D!==void 0?D:m.text,ke=C!==void 0?C:m.completedParams,he=m.actionableSuggestions,Ae=he[0],ge=oe?.listboxId??"",Ge=m.activeDropdownIndex>=0&&oe?`${ge}-option-${m.activeDropdownIndex}`:void 0,ne=m.editingParam,_e=ne?{type:ne.suggestionType,text:ne.suggestionPlaceholder,required:!0,options:ne.options}:null,Ce=_e??Ae,Ke=_e?[_e]:he,Ee=!oe||m.isLoading&&!m.editingParam&&!m.inSelectionAnimation;return{completedParams:ke,skippedParams:m.skippedParams,suggestionPills:he,setActivePill:o.setActivePill,skipActivePill:o.skipActivePill,removeLastParam:o.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:o.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:Ee,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:ge,error:m.error,products:m.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:ne,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:Se,placeholder:m.placeholderText||void 0,onChange:I,onKeyDown:ue,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":Ge,"aria-autocomplete":"list","aria-controls":ge},reset:o.reset,dropdownProps:{suggestions:Ce?[{...Ce,options:m.filteredOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:m.isDropdownOpen,id:ge,pills:Ke,activeSelected:m.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(M??!0)&&!ne,skipDisabled:m.inSelectionAnimation,isLoading:Ee,isInputEmpty:Se.trim().length===0,products:m.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,optionsPosition:y??"below"}}}var F=require("@magicx-eng/ai-autocomplete-vanilla"),v=require("react"),Oe;function Ht(){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 vt(e){let{segments:a,newParamId:t,editingParam:r,editingAnchor:n,caretOffset:l,placeholderText:i,isFocused:g,isDropdownOpen:w,listboxId:y,activeDescendantId:_,autoFocus:b,handleTextChange:M,handleKeyDown:J,handleCaretAfterInput:$,handleCaretMove:D,startEditingParam:C,replaceEditingRange:X,setFocused:R}=e,P=(0,v.useRef)(null),j=(0,v.useRef)(!1),Z=(0,v.useRef)(""),Y=(0,v.useRef)(""),c=(0,v.useRef)(null),re=(0,v.useRef)(0);c.current=l,(0,v.useEffect)(()=>{if(!b)return;let s=P.current;if(!s)return;document.activeElement===s?R(!0):s.focus();let p=s.ownerDocument??document,u=p.getSelection(),f=u&&u.rangeCount>0&&s.contains(u.anchorNode);if(u&&!f){let o=p.createRange();o.selectNodeContents(s),o.collapse(!0),u.removeAllRanges(),u.addRange(o)}},[b,R]),(0,v.useEffect)(()=>{let s=P.current;if(!s)return;let p=s.ownerDocument??document,u=()=>{let f=p.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!s.contains(f.anchorNode))return;let o=f.anchorNode,I=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement,oe=(f.isCollapsed?I?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(oe&&oe!==r?.id){C(oe);return}performance.now()-re.current<50||D((0,F.getCursorOffset)(s))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[r,C,D]),(0,v.useLayoutEffect)(()=>{let s=P.current;s&&(0,F.renderEditableContent)({input:s,segments:a,newParamId:t,editingParamId:r?.id??null,placeholderText:i??"",isFocused:g})},[a,t,r,i,g]),(0,v.useLayoutEffect)(()=>{let s=Z.current,p=t??"";if(Z.current=p,!p||p===s)return;let u=P.current;if(!u)return;u.focus();let f=c.current??(0,F.plainTextLength)(u);(0,F.setCursorOffset)(u,f)},[t]),(0,v.useLayoutEffect)(()=>{let s=Y.current,p=r?.id??"";if(Y.current=p,!p||p===s||n==null)return;let u=P.current;u&&(0,F.setCursorOffset)(u,n)},[r,n]);let T=(0,v.useCallback)(()=>{if(j.current)return;let s=P.current;if(!s)return;let p=(0,F.extractPlainText)(s),f=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;M(f)},[M]),H=(0,v.useCallback)(()=>{re.current=performance.now(),T();let s=P.current;s&&$((0,F.getCursorOffset)(s))},[T,$]);(0,v.useEffect)(()=>{let s=P.current;if(!s)return;let p=u=>{let f=u,o=f.inputType;if(o==="insertParagraph"||o==="insertLineBreak"||o==="insertFromDrop"){u.preventDefault();return}if(o.startsWith("insert")||o.startsWith("delete")){let I=o.startsWith("delete")?"":f.data??"";X(I)&&u.preventDefault()}};return s.addEventListener("beforeinput",p),()=>s.removeEventListener("beforeinput",p)},[X]);let N=(0,v.useCallback)(()=>{j.current=!0},[]),ee=(0,v.useCallback)(()=>{j.current=!1,T()},[T]),h=(0,v.useCallback)(s=>{s.preventDefault();let p=P.current;if(!p)return;let u=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let f=p.ownerDocument??document,o=f.getSelection();if(!o||o.rangeCount===0)return;let I=o.getRangeAt(0);if(!p.contains(I.startContainer))return;I.deleteContents();let ue=f.createTextNode(u);I.insertNode(ue),I.setStartAfter(ue),I.collapse(!0),o.removeAllRanges(),o.addRange(I),T()},[T]),O=(0,v.useCallback)(s=>J(s),[J]),G=(0,v.useCallback)(()=>R(!0),[R]),L=(0,v.useCallback)(()=>R(!1),[R]),K=(0,v.useCallback)(()=>P.current?.focus(),[]),te=(0,v.useCallback)(()=>P.current?.blur(),[]),ae=(0,v.useCallback)(()=>{let s=P.current;return s?(0,F.extractPlainText)(s):""},[]),W=Ht()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:W,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":y,"aria-expanded":w,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:H,onKeyDown:O,onCompositionStart:N,onCompositionEnd:ee,onPaste:h,onFocus:G,onBlur:L},getPlainText:ae,focus:K,blur:te}}var q=require("react/jsx-runtime");function Gt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var xt=(0,S.forwardRef)(function({onSubmit:a,onError:t,optionOverrides:r,maskCompletedText:n,className:l,apiConfig:i,additionalContext:g,generateStartingStateOptions:w,columns:y,pillPlacement:_="dropdown",mode:b="auto",optionsPosition:M="below",animations:J=!0,dropdownTrigger:$,closeDropdownOnBlur:D,showNonTappableOptions:C,showSkipButton:X,autoFocus:R=!0,onFocus:P,onBlur:j,value:Z,completedParams:Y,onChange:c,onParamsChange:re,products:T,onProductSelect:H,submitButton:N},ee){let h=(0,S.useRef)(null),O=(0,S.useRef)(null),G=(0,S.useRef)(()=>{}),L=(0,S.useRef)(null),K=(0,S.useRef)(null);(0,S.useEffect)(()=>{let k=h.current;if(k)return L.current?L.current.setMode(b):L.current=new ye.ModeController(k,b),()=>{L.current?.destroy(),L.current=null}},[b]);let te=(0,S.useCallback)(k=>{let le=K.current?.current;le&&(le.focus(),(0,ye.setCursorOffset)(le,k))},[]),{completedParams:ae,skippedParams:W,suggestionPills:s,setActivePill:p,skipActivePill:u,segments:f,newParamId:o,clearNewParamId:I,placeholderText:ue,isFocused:oe,isDropdownOpen:m,isActivePillSelected:Se,isLoading:ke,activeIndex:he,listboxId:Ae,handleTextChange:ge,handleKeyDown:Ge,setFocused:ne,editingParam:_e,editingAnchor:Ce,caretOffset:Ke,startEditingParam:Ee,handleCaretAfterInput:d,handleCaretMove:E,replaceEditingRange:A,dropdownProps:fe,reset:se}=Ne({onSubmit:k=>G.current(k),onError:t,optionOverrides:r,maskCompletedText:n,apiConfig:i,additionalContext:g,generateStartingStateOptions:w,columns:y,dropdownTrigger:$,optionsPosition:M,closeDropdownOnBlur:D,showNonTappableOptions:C,showSkipButton:X,onFocus:P,onBlur:j,value:Z,completedParams:Y,onChange:c,onParamsChange:re,products:T,onProductSelect:H,source:"full-sdk",setCursor:te});(0,S.useEffect)(()=>{if(!o)return;let k=window.setTimeout(()=>I(),650);return()=>window.clearTimeout(k)},[o,I]);let wt=he>=0?`${Ae}-option-${he}`:void 0,{inputRef:We,editorProps:yt,focus:De,blur:Xe,getPlainText:Ze}=vt({segments:f,newParamId:o,editingParam:_e,editingAnchor:Ce,caretOffset:Ke,placeholderText:ue,isFocused:oe,isDropdownOpen:m,listboxId:Ae,activeDescendantId:wt,autoFocus:R,handleTextChange:ge,handleKeyDown:Ge,handleCaretAfterInput:d,handleCaretMove:E,startEditingParam:Ee,replaceEditingRange:A,setFocused:ne});K.current=We,(0,S.useLayoutEffect)(()=>{let k=O.current,le=We.current;if(!k||!le)return;let Ye=()=>{let tt=k.firstElementChild;if(!tt)return;let It=tt.getBoundingClientRect(),St=le.getBoundingClientRect();It.top>=St.bottom-2?k.setAttribute("data-aia-pill-wrapped",""):k.removeAttribute("data-aia-pill-wrapped")};Ye();let et=new ResizeObserver(Ye);return et.observe(le),()=>et.disconnect()},[f,s.length,ke,We]),(0,S.useImperativeHandle)(ee,()=>({focus:De,blur:Xe,reset:se,setMode:k=>L.current?.setMode(k),skipActivePill:u}),[De,Xe,se,u]);let Re=!!f.length||ae.length>0,Ue=(0,S.useCallback)(()=>{if(!Re)return;let k=Ze();a((0,ye.buildSubmitResult)(k,ae,W)),se()},[Re,ae,W,a,se,Ze]);G.current=Ue;let kt=(0,S.useCallback)(k=>{k.target?.closest("[data-aia-pill]")||De()},[De]),_t=_==="inline",Pt=_==="dropdown";return(0,q.jsxs)("div",{ref:h,className:`magicx-aia ${me.container} ${l??""}`,"data-pill-placement":_,"data-options-position":M,"data-animations":J?"on":"off","data-mode":Gt(b),children:[(0,q.jsx)(Fe,{...fe,showPills:Pt}),(0,q.jsxs)("div",{className:me.inputWrapper,onClick:kt,children:[(0,q.jsxs)("div",{className:me.editorArea,"data-aia-editor":"",children:[(0,q.jsx)("div",{...yt,className:me.input,"data-aia-input":""}),_t&&(ke||s.length>0)&&(0,q.jsx)("span",{ref:O,className:me.pillListContainer,"data-aia-pill-list-container":"",children:(0,q.jsx)(Le,{pills:s,activePillIndex:0,activeSelected:Se,onSelectPill:p,loading:ke})})]}),N===null?null:N===void 0?(0,q.jsx)(gt,{disabled:!Re,onClick:Ue}):(0,q.jsx)("span",{"data-aia-submit":"",className:me.submitSlot,onClick:k=>{Re&&(k.stopPropagation(),Ue())},children:N})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,buildSubmitResult,useAIAutocomplete,withSkippedParams});
|
|
1658
|
+
`,document.head.appendChild(e)}var yt={submitButton:"SubmitButton-module_submitButton_otz7H"};var He=require("react/jsx-runtime");function kt({disabled:e,onClick:a}){return(0,He.jsx)("button",{type:"button","data-aia-submit":"",className:yt.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,He.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,He.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ke=require("@magicx-eng/ai-autocomplete-vanilla"),k=require("react");var et=require("react");function _t(e){let a=(0,et.useRef)(e);a.current=e;let t=(0,et.useRef)(null);t.current===null&&(t.current={fetch:(n,r)=>{let s=a.current;return s?s.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>a.current?.transform(n)??[],get limit(){return a.current?.limit}});let i=e!==void 0;return{config:i?t.current:void 0,enabled:i}}var $t={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 We({onSubmit:e,onError:a,optionOverrides:t,maskCompletedText:i,apiConfig:n,additionalContext:r,columns:s=2,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,showSkipButton:f,onFocus:z,onBlur:G,value:N,completedParams:O,onChange:V,onParamsChange:ae,products:ce,onProductSelect:F,source:P,setCursor:X}){let u=(0,k.useRef)(null),[ue,oe]=(0,k.useState)(null),ie=(0,k.useRef)(e);ie.current=e;let E=(0,k.useRef)(a);E.current=a;let me=(0,k.useRef)(V);me.current=V;let re=(0,k.useRef)(ae);re.current=ae;let ne=(0,k.useRef)(z);ne.current=z;let se=(0,k.useRef)(G);se.current=G;let T=(0,k.useRef)(X);T.current=X;let q=(0,k.useRef)(F);q.current=F;let Z=_t(ce);(0,k.useEffect)(()=>{if(typeof document>"u")return;let p=new Ke.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:n,additionalContext:r,optionOverrides:t,maskCompletedText:i,columns:s,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m,source:P,value:N,completedParams:O,onSubmit:(...D)=>ie.current?.(...D),onError:(...D)=>E.current?.(...D),onChange:(...D)=>me.current?.(...D),onParamsChange:(...D)=>re.current?.(...D),onFocus:()=>ne.current?.(),onBlur:()=>se.current?.(),onProductSelect:D=>q.current?.(D),setCursor:D=>T.current?.(D),products:Z.config});u.current=p,oe(p.getState());let L=p.subscribe(D=>oe(D));return()=>{L(),p.destroy(),u.current===p&&(u.current=null)}},[]),(0,k.useEffect)(()=>{N!==void 0&&u.current?.setValue(N)},[N]),(0,k.useEffect)(()=>{O!==void 0&&u.current?.setCompletedParams(O)},[O]);let h=JSON.stringify(n??null),H;try{H=JSON.stringify(r??null)}catch{H="[unstringifiable]"}let R=(0,k.useRef)(t),he=(0,k.useRef)(0);if(t!==R.current){let p=R.current,L=t,D=Object.keys(p??{}),_e=Object.keys(L??{});(D.length!==_e.length||_e.some(fe=>!p?.[fe]||L[fe]!==p[fe]))&&he.current++,R.current=t}(0,k.useEffect)(()=>{u.current?.update({apiConfig:n,additionalContext:r,optionOverrides:t,dropdownTrigger:g,optionsPosition:b,closeDropdownOnBlur:v,showNonTappableOptions:m})},[h,H,he.current,g,b,v,m]);let l=(0,k.useRef)(!1);(0,k.useEffect)(()=>{if(!l.current){l.current=!0;return}u.current?.update({products:Z.config})},[Z.enabled]);let c=(0,k.useRef)(null);c.current===null&&(c.current={handleTextChange:p=>u.current?.handleTextChange(p),handleKeyDown:p=>{let L="nativeEvent"in p?p.nativeEvent:p;u.current?.handleKeyDown(L)},setFocused:p=>u.current?.setFocused(p),startEditingParam:p=>u.current?.startEditingParam(p),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:p=>u.current?.handleCaretAfterInput(p),handleCaretMove:p=>u.current?.handleCaretMove(p),replaceEditingRange:p=>u.current?.replaceEditingRange(p)??!1,setActivePill:p=>u.current?.setActivePill(p),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),selectOption:p=>u.current?.selectOption(p),selectProduct:p=>u.current?.selectProduct(p),setActiveDropdownIndex:p=>u.current?.setActiveDropdownIndex(p),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let o=c.current,y=(0,k.useCallback)(p=>{let L=p.target.value,_e=L.length>0&&!p.nativeEvent?.isComposing&&L[0]!==L[0].toUpperCase()?L[0].toUpperCase()+L.slice(1):L;u.current?.handleTextChange(_e)},[]),x=(0,k.useCallback)(p=>{u.current?.handleKeyDown(p.nativeEvent)},[]),S=u.current,d=ue??$t,$=N!==void 0?N:d.text,ee=O!==void 0?O:d.completedParams,ge=d.actionableSuggestions,ye=ge[0],j=S?.listboxId??"",Ve=d.activeDropdownIndex>=0&&S?`${j}-option-${d.activeDropdownIndex}`:void 0,le=d.editingParam,de=d.editingIdentified,Ce=le?{type:le.suggestionType,text:le.suggestionPlaceholder,required:!0,options:le.options}:de?{type:de.type,text:de.type,required:!0,options:[]}:null,Re=Ce??ye,qe=Ce?[Ce]:ge,Le=!S||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:ee,skippedParams:d.skippedParams,suggestionPills:ge,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:Le,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:j,error:d.error,products:d.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:le,editingIdentified:de,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:$,placeholder:d.placeholderText||void 0,onChange:y,onKeyDown:x,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":Ve,"aria-autocomplete":"list","aria-controls":j},reset:o.reset,dropdownProps:{suggestions:Re?[{...Re,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:j,pills:qe,activeSelected:d.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(f??!0)&&!le&&!de,skipDisabled:d.inSelectionAnimation,isLoading:Le,isInputEmpty:$.trim().length===0,products:d.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:de?de.iso:(0,Ke.selectedIsoFromText)(le?.text),onPreviousMonth:o.showPreviousMonth,onNextMonth:o.showNextMonth,optionsPosition:b??"below"}}}var W=require("@magicx-eng/ai-autocomplete-vanilla"),w=require("react"),Ue;function jt(){if(Ue!==void 0)return Ue;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Ue=e.contentEditable==="plaintext-only",Ue}function Pt(e){let{segments:a,newParamId:t,editingParam:i,editingIdentified:n,editingAnchor:r,caretOffset:s,placeholderText:g,isFocused:b,isDropdownOpen:v,listboxId:m,activeDescendantId:f,autoFocus:z,handleTextChange:G,handleKeyDown:N,handleCaretAfterInput:O,handleCaretMove:V,startEditingParam:ae,replaceEditingRange:ce,setFocused:F}=e,P=(0,w.useRef)(null),X=(0,w.useRef)(!1),u=(0,w.useRef)(""),ue=(0,w.useRef)(""),oe=(0,w.useRef)(null),ie=(0,w.useRef)(0);oe.current=s,(0,w.useEffect)(()=>{if(!z)return;let l=P.current;if(!l)return;document.activeElement===l?F(!0):l.focus();let c=l.ownerDocument??document,o=c.getSelection(),y=o&&o.rangeCount>0&&l.contains(o.anchorNode);if(o&&!y){let x=c.createRange();x.selectNodeContents(l),x.collapse(!0),o.removeAllRanges(),o.addRange(x)}},[z,F]),(0,w.useEffect)(()=>{let l=P.current;if(!l)return;let c=l.ownerDocument??document,o=()=>{let y=c.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!l.contains(y.anchorNode))return;let x=y.anchorNode,S=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,$=(y.isCollapsed?S?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ee=i?.id??n?.id??null;if($&&$!==ee){ae($);return}performance.now()-ie.current<50||V((0,W.getCursorOffset)(l))};return c.addEventListener("selectionchange",o),()=>c.removeEventListener("selectionchange",o)},[i,n,ae,V]),(0,w.useLayoutEffect)(()=>{let l=P.current;l&&(0,W.renderEditableContent)({input:l,segments:a,newParamId:t,editingParamId:i?.id??null,placeholderText:g??"",isFocused:b})},[a,t,i,g,b]),(0,w.useLayoutEffect)(()=>{let l=u.current,c=t??"";if(u.current=c,!c||c===l)return;let o=P.current;if(!o)return;o.focus();let y=oe.current??(0,W.plainTextLength)(o);(0,W.setCursorOffset)(o,y)},[t]),(0,w.useLayoutEffect)(()=>{let l=ue.current,c=i?.id??"";if(ue.current=c,!c||c===l||r==null)return;let o=P.current;o&&(0,W.setCursorOffset)(o,r)},[i,r]);let E=(0,w.useCallback)(()=>{if(X.current)return;let l=P.current;if(!l)return;let c=(0,W.extractPlainText)(l),y=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;G(y)},[G]),me=(0,w.useCallback)(()=>{ie.current=performance.now(),E();let l=P.current;l&&O((0,W.getCursorOffset)(l))},[E,O]);(0,w.useEffect)(()=>{let l=P.current;if(!l)return;let c=o=>{let y=o,x=y.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){o.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let S=x.startsWith("delete")?"":y.data??"";ce(S)&&o.preventDefault()}};return l.addEventListener("beforeinput",c),()=>l.removeEventListener("beforeinput",c)},[ce]);let re=(0,w.useCallback)(()=>{X.current=!0},[]),ne=(0,w.useCallback)(()=>{X.current=!1,E()},[E]),se=(0,w.useCallback)(l=>{l.preventDefault();let c=P.current;if(!c)return;let o=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!o)return;let y=c.ownerDocument??document,x=y.getSelection();if(!x||x.rangeCount===0)return;let S=x.getRangeAt(0);if(!c.contains(S.startContainer))return;S.deleteContents();let d=y.createTextNode(o);S.insertNode(d),S.setStartAfter(d),S.collapse(!0),x.removeAllRanges(),x.addRange(S),E()},[E]),T=(0,w.useCallback)(l=>N(l),[N]),q=(0,w.useCallback)(()=>F(!0),[F]),Z=(0,w.useCallback)(()=>F(!1),[F]),h=(0,w.useCallback)(()=>P.current?.focus(),[]),H=(0,w.useCallback)(()=>P.current?.blur(),[]),R=(0,w.useCallback)(()=>{let l=P.current;return l?(0,W.extractPlainText)(l):""},[]),he=jt()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:he,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":v,"aria-activedescendant":f,spellCheck:!0,enterKeyHint:"send",onInput:me,onKeyDown:T,onCompositionStart:re,onCompositionEnd:ne,onPaste:se,onFocus:q,onBlur:Z},getPlainText:R,focus:h,blur:H}}var J=require("react/jsx-runtime");function Qt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var It=(0,A.forwardRef)(function({onSubmit:a,onError:t,optionOverrides:i,maskCompletedText:n,className:r,apiConfig:s,additionalContext:g,columns:b,pillPlacement:v="dropdown",mode:m="auto",optionsPosition:f="below",animations:z=!0,dropdownTrigger:G,closeDropdownOnBlur:N,showNonTappableOptions:O,showSkipButton:V,autoFocus:ae=!0,onFocus:ce,onBlur:F,value:P,completedParams:X,onChange:u,onParamsChange:ue,products:oe,onProductSelect:ie,submitButton:E},me){let re=(0,A.useRef)(null),ne=(0,A.useRef)(null),se=(0,A.useRef)(()=>{}),T=(0,A.useRef)(null),q=(0,A.useRef)(null);(0,A.useEffect)(()=>{let _=re.current;if(_)return T.current?T.current.setMode(m):T.current=new De.ModeController(_,m),()=>{T.current?.destroy(),T.current=null}},[m]);let Z=(0,A.useCallback)(_=>{let be=q.current?.current;be&&(be.focus(),(0,De.setCursorOffset)(be,_))},[]),{completedParams:h,skippedParams:H,suggestionPills:R,setActivePill:he,skipActivePill:l,segments:c,newParamId:o,clearNewParamId:y,placeholderText:x,isFocused:S,isDropdownOpen:d,isActivePillSelected:$,isLoading:ee,activeIndex:ge,listboxId:ye,handleTextChange:j,handleKeyDown:Ve,setFocused:le,editingParam:de,editingIdentified:Ce,editingAnchor:Re,caretOffset:qe,startEditingParam:Le,handleCaretAfterInput:p,handleCaretMove:L,replaceEditingRange:D,dropdownProps:_e,reset:fe}=We({onSubmit:_=>se.current(_),onError:t,optionOverrides:i,maskCompletedText:n,apiConfig:s,additionalContext:g,columns:b,dropdownTrigger:G,optionsPosition:f,closeDropdownOnBlur:N,showNonTappableOptions:O,showSkipButton:V,onFocus:ce,onBlur:F,value:P,completedParams:X,onChange:u,onParamsChange:ue,products:oe,onProductSelect:ie,source:"full-sdk",setCursor:Z});(0,A.useEffect)(()=>{if(!o)return;let _=window.setTimeout(()=>y(),650);return()=>window.clearTimeout(_)},[o,y]);let St=ge>=0?`${ye}-option-${ge}`:void 0,{inputRef:$e,editorProps:At,focus:ze,blur:tt,getPlainText:at}=Pt({segments:c,newParamId:o,editingParam:de,editingIdentified:Ce,editingAnchor:Re,caretOffset:qe,placeholderText:x,isFocused:S,isDropdownOpen:d,listboxId:ye,activeDescendantId:St,autoFocus:ae,handleTextChange:j,handleKeyDown:Ve,handleCaretAfterInput:p,handleCaretMove:L,startEditingParam:Le,replaceEditingRange:D,setFocused:le});q.current=$e,(0,A.useLayoutEffect)(()=>{let _=ne.current,be=$e.current;if(!_||!be)return;let ot=()=>{let rt=_.firstElementChild;if(!rt)return;let Tt=rt.getBoundingClientRect(),Rt=be.getBoundingClientRect();Tt.top>=Rt.bottom-2?_.setAttribute("data-aia-pill-wrapped",""):_.removeAttribute("data-aia-pill-wrapped")};ot();let it=new ResizeObserver(ot);return it.observe(be),()=>it.disconnect()},[c,R.length,ee,$e]),(0,A.useImperativeHandle)(me,()=>({focus:ze,blur:tt,reset:fe,setMode:_=>T.current?.setMode(_),skipActivePill:l}),[ze,tt,fe,l]);let Ne=!!c.length||h.length>0,je=(0,A.useCallback)(()=>{if(!Ne)return;let _=at();a((0,De.buildSubmitResult)(_,h,H)),fe()},[Ne,h,H,a,fe,at]);se.current=je;let Dt=(0,A.useCallback)(_=>{_.target?.closest("[data-aia-pill]")||ze()},[ze]),Ct=v==="inline",Et=v==="dropdown";return(0,J.jsxs)("div",{ref:re,className:`magicx-aia ${ke.container} ${r??""}`,"data-pill-placement":v,"data-options-position":f,"data-animations":z?"on":"off","data-mode":Qt(m),children:[(0,J.jsx)(Fe,{..._e,showPills:Et}),(0,J.jsxs)("div",{className:ke.inputWrapper,onClick:Dt,children:[(0,J.jsxs)("div",{className:ke.editorArea,"data-aia-editor":"",children:[(0,J.jsx)("div",{...At,className:ke.input,"data-aia-input":""}),Ct&&(ee||R.length>0)&&(0,J.jsx)("span",{ref:ne,className:ke.pillListContainer,"data-aia-pill-list-container":"",children:(0,J.jsx)(Be,{pills:R,activePillIndex:0,activeSelected:$,onSelectPill:he,loading:ee})})]}),E===null?null:E===void 0?(0,J.jsx)(kt,{disabled:!Ne,onClick:je}):(0,J.jsx)("span",{"data-aia-submit":"",className:ke.submitSlot,onClick:_=>{Ne&&(_.stopPropagation(),je())},children:E})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,formatDate,isoDate,monthLabel,parseDate,parseLooseDate,useAIAutocomplete,withSkippedParams});
|
|
1512
1659
|
//# sourceMappingURL=index.js.map
|