@magicx-eng/ai-autocomplete-react 0.18.1 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -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 et=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var qt=Object.prototype.hasOwnProperty;var Ut=(e,
|
|
1
|
+
"use strict";var et=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var qt=Object.prototype.hasOwnProperty;var Ut=(e,o)=>{for(var a in o)et(e,a,{get:o[a],enumerable:!0})},jt=(e,o,a,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of Wt(o))!qt.call(e,n)&&n!==a&&et(e,n,{get:()=>o[n],enumerable:!(r=Kt(o,n))||r.enumerable});return e};var $t=e=>jt(et({},"__esModule",{value:!0}),e);var ra={};Ut(ra,{AIAutocomplete:()=>Rt,AIAutocompleteDropdown:()=>je,DATE_RANGE_META_END:()=>u.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>u.DATE_RANGE_META_START,WEEKDAY_LABELS:()=>u.WEEKDAY_LABELS,buildSubmitResult:()=>u.buildSubmitResult,cellDay:()=>u.cellDay,cellIso:()=>u.cellIso,dateCellMarks:()=>u.dateCellMarks,formatDate:()=>u.formatDate,formatDateRange:()=>u.formatDateRange,isoDate:()=>u.isoDate,monthLabel:()=>u.monthLabel,optionLabel:()=>u.optionLabel,parseDate:()=>u.parseDate,parseLooseDate:()=>u.parseLooseDate,parseLooseDateRange:()=>u.parseLooseDateRange,sanitizeOptionIconSvg:()=>u.sanitizeOptionIconSvg,selectedRangeFor:()=>u.selectedRangeFor,useAIAutocomplete:()=>Ve,visibleDateRange:()=>u.visibleDateRange,withSkippedParams:()=>u.withSkippedParams});module.exports=$t(ra);var u=require("@magicx-eng/ai-autocomplete-vanilla");var R=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
|
|
@@ -116,6 +116,12 @@
|
|
|
116
116
|
vertical-align: -0.125em;
|
|
117
117
|
pointer-events: none;
|
|
118
118
|
user-select: none;
|
|
119
|
+
/* Own compositing layer. The row (entrance) and the chip (promotion fade)
|
|
120
|
+
animate on a layer WebKit drops when the animation ends; content drawn at
|
|
121
|
+
a fractional x then re-rasterizes on a different sub-pixel, which crisp
|
|
122
|
+
SVG strokes show as a nudge to the right. A permanent layer keeps the
|
|
123
|
+
glyph's rasterization stable across that hand-off. */
|
|
124
|
+
will-change: transform;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
:where(.AIAutocomplete-module_input_IW-P-) span[class~="magicx-aia-segment-icon"] svg {
|
|
@@ -970,7 +976,7 @@
|
|
|
970
976
|
opacity: 0.8;
|
|
971
977
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
972
978
|
}
|
|
973
|
-
`,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",past:"DateGrid-module_past_CEZsj",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",inRange:"DateGrid-module_inRange_r9S2q",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};var
|
|
979
|
+
`,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",past:"DateGrid-module_past_CEZsj",highlighted:"DateGrid-module_highlighted_YIdtK",today:"DateGrid-module_today_iI3ME",inRange:"DateGrid-module_inRange_r9S2q",selected:"DateGrid-module_selected_28KDn",pressed:"DateGrid-module_pressed_bEyyN"};var G=require("react/jsx-runtime"),Vt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function ht({options:e,activeIndex:o,listboxId:a,view:r,selection:n,onSelect:i,onHighlight:s,onPreviousMonth:f,onNextMonth:w}){let b=(0,T.isoDate)(new Date),y=(0,T.visibleDateRange)({pendingStart:n.rangeStart,highlightedIso:(0,T.cellIso)(e[o]),selected:n.selectedRange});return(0,G.jsxs)("div",{className:C.datepicker,"data-aia-datepicker":"",children:[(0,G.jsxs)("div",{className:C.header,children:[(0,G.jsx)("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:m=>m.preventDefault(),onClick:f,children:"\u2039"}),(0,G.jsx)("span",{className:C.month,"data-aia-date-month":"","aria-live":"polite",children:(0,T.monthLabel)(r)}),(0,G.jsx)("button",{type:"button",tabIndex:-1,className:C.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:m=>m.preventDefault(),onClick:w,children:"\u203A"})]}),(0,G.jsx)("div",{className:C.weekdays,"aria-hidden":"true",children:T.WEEKDAY_LABELS.map((m,_)=>(0,G.jsx)("span",{className:C.weekday,children:m},Vt[_]))}),(0,G.jsx)("div",{className:C.grid,"data-aia-date-grid":"",children:e.map((m,_)=>(0,G.jsx)(Qt,{option:m,id:`${a}-option-${_}`,index:_,isHighlighted:_===o&&m.is_tappable,isToday:(0,T.cellIso)(m)===b,isPast:(0,T.cellIso)(m)!=null&&(0,T.cellIso)(m)<b,marks:(0,T.dateCellMarks)((0,T.cellIso)(m),{selectedIso:n.selectedIso,range:y}),onSelect:i,onHighlight:s},(0,T.cellIso)(m)??`pad-${_}`))})]})}function Qt({option:e,id:o,index:a,isHighlighted:r,isToday:n,isPast:i,marks:s,onSelect:f,onHighlight:w}){let[b,y]=(0,ut.useState)(!1),m=(0,T.cellDay)(e);if(m==null)return(0,G.jsx)("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${C.cell} ${C.blank}`});let _=()=>{y(!0),f(e),setTimeout(()=>y(!1),170)},P=[C.cell,C.day,i?C.past:"",r?C.highlighted:"",n?C.today:"",s.inRange?C.inRange:"",s.selected?C.selected:"",b?C.pressed:""].filter(Boolean).join(" ");return(0,G.jsx)("div",{id:o,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":r,"aria-label":e.text,tabIndex:0,className:P,onClick:_,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),_())},onMouseEnter:()=>w(a),children:(0,G.jsx)("span",{className:C.number,children:m})})}var Ce=require("@magicx-eng/ai-autocomplete-vanilla"),We=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 {
|
|
974
980
|
.aia-cluster {
|
|
975
981
|
display: flex;
|
|
976
982
|
flex-wrap: wrap;
|
|
@@ -1012,7 +1018,7 @@
|
|
|
1012
1018
|
justify-content: space-around;
|
|
1013
1019
|
}
|
|
1014
1020
|
}
|
|
1015
|
-
`,document.head.appendChild(e)}var tt=require("react/jsx-runtime");function
|
|
1021
|
+
`,document.head.appendChild(e)}var tt=require("react/jsx-runtime");function ze({gap:e,align:o="center",justify:a="start",noWrap:r=!1,inline:n=!1,className:i,children:s,...f}){let w=e?{"--aia-cluster-gap":e}:void 0,b={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":o,"data-justify":a,"data-nowrap":r||void 0,"data-inline":n||void 0,style:w,...f};return n?(0,tt.jsx)("span",{...b,children:s}):(0,tt.jsx)("div",{...b,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
|
|
1016
1022
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1017
1023
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1018
1024
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1146,7 +1152,7 @@
|
|
|
1146
1152
|
justify-content: flex-end;
|
|
1147
1153
|
}
|
|
1148
1154
|
}
|
|
1149
|
-
`,document.head.appendChild(e)}var ge={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 ie=require("react/jsx-runtime");function mt({isOptionHighlighted:e=!1,isInputEmpty:
|
|
1155
|
+
`,document.head.appendChild(e)}var ge={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 ie=require("react/jsx-runtime");function mt({isOptionHighlighted:e=!1,isInputEmpty:o=!1}){let{key:a,hint:r}=(0,Ce.getFooterHint)(e,o),[n,i]=(0,We.useState)(Ce.ATTRIBUTION_URL);return(0,We.useEffect)(()=>{i((0,Ce.buildAttributionUrl)())},[]),(0,ie.jsx)("footer",{className:ge.footer,"data-aia-footer":"",children:(0,ie.jsxs)(ze,{justify:"between",noWrap:!0,className:ge.row,children:[(0,ie.jsxs)(ze,{gap:"5px",className:ge.hintGroup,children:[(0,ie.jsx)("kbd",{className:ge.key,children:a}),(0,ie.jsx)("span",{className:ge.hint,children:r})]}),(0,ie.jsxs)("a",{className:ge.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,ie.jsx)("span",{className:ge.brand,children:"AI"}),(0,ie.jsx)("span",{className:ge.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,
|
|
1150
1156
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1151
1157
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1152
1158
|
as it was when the outline was dashed. */
|
|
@@ -1203,7 +1209,7 @@
|
|
|
1203
1209
|
opacity: 0;
|
|
1204
1210
|
}
|
|
1205
1211
|
}
|
|
1206
|
-
`,document.head.appendChild(e)}var ke={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 ft=require("react/jsx-runtime"),
|
|
1212
|
+
`,document.head.appendChild(e)}var ke={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 ft=require("react/jsx-runtime"),at={selected:1,first:.7,next:.4,last:.2};function gt({label:e,state:o,rounded:a,loading:r,onClick:n}){let i=[ke.pill,a?ke.rounded:"",r?ke.skeleton:""].filter(Boolean).join(" ");return(0,ft.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:at[o]},onMouseDown:s=>s.preventDefault(),onClick:r?void 0:n,disabled:r,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 {
|
|
1207
1213
|
position: relative;
|
|
1208
1214
|
z-index: 1;
|
|
1209
1215
|
pointer-events: auto;
|
|
@@ -1213,7 +1219,7 @@
|
|
|
1213
1219
|
align-items: center;
|
|
1214
1220
|
vertical-align: middle;
|
|
1215
1221
|
}
|
|
1216
|
-
`,document.head.appendChild(e)}var
|
|
1222
|
+
`,document.head.appendChild(e)}var ot={list:"PillList-module_list_qvLqO"};var Ne=require("react/jsx-runtime"),Yt=[125,69];function bt(e){return e===0?"first":e===1?"next":"last"}function qe({pills:e,activePillIndex:o,onSelectPill:a,activeSelected:r,rounded:n,loading:i}){return i&&e.length===0?(0,Ne.jsx)("span",{className:ot.list,"data-aia-pill-list-loading":"",children:Yt.map((s,f)=>(0,Ne.jsx)("span",{"data-aia-pill-skeleton":"",className:`${ke.pill} ${n?ke.rounded:""} ${ke.skeleton}`,style:{width:s,opacity:at[bt(f)]}},`skel-${s}`))}):(0,Ne.jsx)("span",{className:ot.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((s,f)=>{let w=!!r&&f===o;return(0,Ne.jsx)(gt,{label:s.text,state:w?"selected":bt(f),selected:w,rounded:n,loading:i,onClick:()=>a(f)},`${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
|
|
1217
1223
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1218
1224
|
theming one package sees the same result in the other.
|
|
1219
1225
|
|
|
@@ -1380,7 +1386,7 @@
|
|
|
1380
1386
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1381
1387
|
);
|
|
1382
1388
|
}
|
|
1383
|
-
`,document.head.appendChild(e)}var Z={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 vt({products:e,listboxId:
|
|
1389
|
+
`,document.head.appendChild(e)}var Z={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 vt({products:e,listboxId:o,onSelect:a,onFocusChange:r,focusable:n=!0}){if(e.length===0)return null;let i=`${o}-products-label`;return(0,K.jsxs)("section",{className:Z.section,"data-aia-products":"",role:"group","aria-labelledby":i,children:[(0,K.jsx)("div",{className:Z.label,id:i,children:"Products"}),(0,K.jsx)("div",{className:Z.row,"data-aia-products-row":"",children:e.map((s,f)=>(0,K.jsx)(Xt,{product:s,id:`${o}-product-${f}`,onSelect:a,onFocusChange:r,focusable:n},s.id))})]})}function Xt({product:e,id:o,onSelect:a,onFocusChange:r,focusable:n}){let i=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),a(e))};return(0,K.jsxs)("a",{id:o,className:Z.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:i,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),a(e))},onFocus:()=>r?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[(0,K.jsx)("span",{className:Z.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,K.jsx)("img",{className:Z.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,K.jsxs)("span",{className:Z.body,children:[e.vendor?(0,K.jsx)("span",{className:Z.vendor,children:e.vendor}):null,(0,K.jsx)("span",{className:Z.title,children:e.title}),e.price?(0,K.jsx)("span",{className:Z.price,children:e.price}):null]})]})}var W=require("@magicx-eng/ai-autocomplete-vanilla"),be=require("react");var wt=require("@magicx-eng/ai-autocomplete-vanilla"),Ue=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 {
|
|
1384
1390
|
.aia-grid {
|
|
1385
1391
|
display: grid;
|
|
1386
1392
|
grid-template-columns: repeat(
|
|
@@ -1415,7 +1421,7 @@
|
|
|
1415
1421
|
border-radius: 3px;
|
|
1416
1422
|
}
|
|
1417
1423
|
}
|
|
1418
|
-
`,document.head.appendChild(e)}var yt=require("react/jsx-runtime");function xt({min:e="16rem",max:
|
|
1424
|
+
`,document.head.appendChild(e)}var yt=require("react/jsx-runtime");function xt({min:e="16rem",max:o,gap:a,scroll:r=!1,maxHeight:n,scrollResetKey:i,cols:s,template:f,innerRef:w,className:b,children:y,...m}){let _=(0,Ue.useRef)(null);(0,Ue.useLayoutEffect)(()=>{if(i===void 0)return;let v=_.current;v&&(v.scrollTop=0)},[i]);let P={"--aia-grid-min":e};return o&&(P["--aia-grid-max"]=o),a&&(P["--aia-grid-gap"]=a),n&&(P["--aia-grid-max-height"]=n),s&&(P.gridTemplateColumns=(0,wt.optionsGridTemplateColumns)(s)),f&&(P.gridTemplateColumns=f),(0,yt.jsx)("div",{ref:v=>{_.current=v,w?.(v)},className:b?`aia-grid ${b}`:"aia-grid","data-scroll":r||void 0,style:P,...m,children:y})}var Ee=require("@magicx-eng/ai-autocomplete-vanilla"),fe=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 {
|
|
1419
1425
|
position: relative;
|
|
1420
1426
|
overflow: visible;
|
|
1421
1427
|
display: flex;
|
|
@@ -1564,6 +1570,12 @@
|
|
|
1564
1570
|
height: 21px; /* = the option's line-height */
|
|
1565
1571
|
margin-right: 8px;
|
|
1566
1572
|
vertical-align: top;
|
|
1573
|
+
/* Own compositing layer. The row (entrance) and the chip (promotion fade)
|
|
1574
|
+
animate on a layer WebKit drops when the animation ends; content drawn at
|
|
1575
|
+
a fractional x then re-rasterizes on a different sub-pixel, which crisp
|
|
1576
|
+
SVG strokes show as a nudge to the right. A permanent layer keeps the
|
|
1577
|
+
glyph's rasterization stable across that hand-off. */
|
|
1578
|
+
will-change: transform;
|
|
1567
1579
|
}
|
|
1568
1580
|
|
|
1569
1581
|
.SuggestionItem-module_icon_Qw938 svg {
|
|
@@ -1600,7 +1612,7 @@
|
|
|
1600
1612
|
filter: brightness(0.55);
|
|
1601
1613
|
}
|
|
1602
1614
|
}
|
|
1603
|
-
`,document.head.appendChild(e)}var J={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",icon:"SuggestionItem-module_icon_Qw938"};var Ie=require("react/jsx-runtime");function _t({option:e,isHighlighted:
|
|
1615
|
+
`,document.head.appendChild(e)}var J={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",icon:"SuggestionItem-module_icon_Qw938"};var Ie=require("react/jsx-runtime");function _t({option:e,isHighlighted:o,onSelect:a,onHighlight:r,id:n,loading:i,showIcon:s=!0,scrollHint:f,enterDelayMs:w=0}){let[b]=(0,fe.useState)(w),[y,m]=(0,fe.useState)(!1),_=(0,fe.useMemo)(()=>s&&e.icon_svg?(0,Ee.sanitizeOptionIconSvg)(e.icon_svg):null,[s,e.icon_svg]),P=(0,fe.useRef)(void 0);(0,fe.useEffect)(()=>()=>clearTimeout(P.current),[]);let v=()=>{i||!e.is_tappable||y||(m(!0),a(e),clearTimeout(P.current),P.current=setTimeout(()=>m(!1),170))},E=[J.item,o&&!i?J.highlighted:"",e.is_tappable?J.tappable:J.nonTappable,y?J.pressed:"",f?J.scrollHint:""].filter(Boolean).join(" ");return(0,Ie.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":_&&e.icon?e.icon:void 0,"aria-selected":o,className:E,style:{[Ee.OPTION_ENTER_DELAY_VAR]:`${b}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:v,onKeyDown:S=>{!i&&e.is_tappable&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),v())},onMouseEnter:!i&&e.is_tappable?r:void 0,children:(0,Ie.jsxs)("span",{className:J.content,children:[_&&(0,Ie.jsx)("span",{className:`${J.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:_}}),(0,Ie.jsx)("span",{className:J.text,children:(0,Ee.optionLabel)(e)}),e.tag&&(0,Ie.jsx)("span",{className:J.tag,children:e.tag})]})})}var it=require("react/jsx-runtime");function Zt(){let[e,o]=(0,be.useState)(W.isOptionsGridMobileViewport);return(0,be.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let a=window.matchMedia(W.OPTIONS_GRID_MOBILE_QUERY),r=()=>o(a.matches);return r(),a.addEventListener("change",r),()=>a.removeEventListener("change",r)},[]),e}function kt({options:e,activeIndex:o,onSelect:a,onHighlight:r,listboxId:n,loading:i,groupKey:s="",optionsPosition:f="below",showIcons:w=!0}){let b=Zt(),y=(0,be.useRef)(null),[m,_]=(0,be.useState)(null);(0,be.useLayoutEffect)(()=>{let v=y.current,S=v&&!i&&(0,W.needsOptionsGridMeasurement)(e.length,b)?(0,W.measureOptionsGrid)(v):null;_(S?(0,W.planOptionsGrid)(e.length,b,S.rowWidths,S.gridWidth):null)},[e,b,i]);let P=m??(0,W.planOptionsGrid)(e.length,b,null,null);return(0,it.jsx)(xt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:s,template:P.template,maxHeight:P.maxHeight,innerRef:v=>{y.current=v},"data-aia-group":s,children:e.map((v,E)=>(0,it.jsx)(_t,{option:v,isHighlighted:E===o,onSelect:a,onHighlight:()=>r(E),id:`${n}-option-${E}`,loading:i,showIcon:w,scrollHint:!i&&P.scrollHintIndices.includes(E),enterDelayMs:i?0:(0,W.optionEnterDelayMs)(E,P.cols,e.length,f)},`${s}\0${v.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
|
|
1604
1616
|
.aia-stack {
|
|
1605
1617
|
display: flex;
|
|
1606
1618
|
flex-direction: column;
|
|
@@ -1617,7 +1629,7 @@
|
|
|
1617
1629
|
}
|
|
1618
1630
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1619
1631
|
}
|
|
1620
|
-
`,document.head.appendChild(e)}var It=require("react/jsx-runtime");function Pt({space:e,align:
|
|
1632
|
+
`,document.head.appendChild(e)}var It=require("react/jsx-runtime");function Pt({space:e,align:o="stretch",className:a,children:r,...n}){let i=e?{"--aia-stack-space":e}:void 0;return(0,It.jsx)("div",{className:a?`aia-stack ${a}`:"aia-stack","data-align":o,style:i,...n,children:r})}var M=require("react/jsx-runtime"),Jt=[159,119,164],ea=()=>{},St=()=>{};function ta(e){let o=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[a,r]=(0,ee.useState)(o);if((0,ee.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(n.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?a?"dark":"light":e}function aa(e,o){let a=(0,ee.useRef)(null);(0,ee.useEffect)(()=>{let r=e.current,n=o.current;if(!r||!n)return;let i=r.querySelector(".aia-grid[data-scroll]");if(a.current&&a.current.grid!==i&&(a.current.controller.destroy(),a.current=null),i&&!a.current){a.current={grid:i,controller:(0,Te.attachScrollArrow)({dropdown:r,grid:i,button:n})};return}a.current?.controller.update()}),(0,ee.useEffect)(()=>()=>{a.current?.controller.destroy(),a.current=null},[])}function je({suggestions:e,activeIndex:o,onSelect:a,onHighlight:r,isOpen:n,id:i,className:s,pills:f,onPillClick:w,showPills:b=!0,onSkip:y,showSkipButton:m=!0,showOptionIcons:_=!0,skipDisabled:P=!1,activeSelected:v=!1,isLoading:E=!1,isInputEmpty:S=!1,products:z,onProductSelect:ne,onProductFocusChange:re,formatType:U="options",dateView:A=null,selectedDateIso:se=null,selectedDateRange:le=null,dateRangeStart:h=null,onPreviousMonth:ve,onNextMonth:de,optionsPosition:N="below",mode:we}){let Y=ta(we),xe=Y!==void 0,ae=(0,ee.useRef)(null),oe=(0,ee.useRef)(null);aa(ae,oe);let ce=e[0]?.options??[],B=!!(f&&f.length>0&&w),pe=!!(z&&z.length>0),j=n&&(ce.length>0||b&&B||E||pe),F={suggestions:e,activeIndex:o,pills:f,showPills:b,showSkipButton:m,showOptionIcons:_,skipDisabled:P,activeSelected:v,isLoading:E,isInputEmpty:S,products:z,formatType:U,dateView:A,selectedDateIso:se,selectedDateRange:le,dateRangeStart:h},ue=(0,ee.useRef)(F);j&&(ue.current=F);let t=j?F:ue.current,c=t.suggestions[0],p=c?.options??[],l=t.activeIndex>=0&&!!p[t.activeIndex]?.is_tappable,x=!!(t.pills&&t.pills.length>0&&w),O=t.showPills&&x,H=t.showPills&&!x&&t.isLoading,d=O||H,he=x&&t.showSkipButton&&!t.isInputEmpty&&!!y,Se=t.pills?.[0]?.text,ye=(0,Te.isCalendarFormat)(t.formatType)&&t.dateView!=null,Ae=p.length>0&&!ye,X=p.length>0&&ye&&!t.isLoading,De=t.isLoading&&!Ae&&!X,$=t.products??[];return(0,M.jsxs)("div",{ref:ae,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":N,"data-mode":Y,"data-aia-loading":t.isLoading?"":void 0,"data-aia-has-products":$.length>0?"":void 0,className:`${xe?"magicx-aia ":""}${me.dropdown} ${j?me.visible:""} ${s??""}`,onMouseDown:V=>V.preventDefault(),children:[(0,M.jsxs)(Pt,{space:"8px",children:[(d||he)&&(0,M.jsxs)(ze,{noWrap:!0,className:me.pillBar,"data-aia-pillbar":"",children:[d&&(0,M.jsx)("span",{className:me.pillScroll,"data-aia-pill-scroll":"",children:(0,M.jsx)(qe,{pills:t.pills??[],activePillIndex:0,activeSelected:t.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:t.isLoading})}),he&&(0,M.jsx)("button",{type:"button",tabIndex:-1,className:me.skip,"data-aia-skip":"",disabled:t.isLoading||t.skipDisabled,"aria-label":Se?`Skip ${Se}`:"Skip",onClick:y,children:"skip"})]}),Ae&&(0,M.jsx)(kt,{options:p,activeIndex:t.activeIndex,onSelect:a,onHighlight:r,listboxId:i,loading:t.isLoading,groupKey:c?`${c.type} ${c.text}`:"",optionsPosition:N,showIcons:t.showOptionIcons}),X&&t.dateView&&(0,M.jsx)(ht,{options:p,activeIndex:t.activeIndex,listboxId:i,view:t.dateView,selection:{selectedIso:t.selectedDateIso??null,selectedRange:t.selectedDateRange??null,rangeStart:t.dateRangeStart??null},onSelect:a,onHighlight:r,onPreviousMonth:ve??St,onNextMonth:de??St}),De&&(0,M.jsx)("div",{className:me.skeletonBars,"data-aia-skeleton-bars":"",children:Jt.map(V=>(0,M.jsx)("span",{className:me.skeletonBar,style:{width:V}},`bar-${V}`))}),(0,M.jsx)(vt,{products:$,listboxId:i,onSelect:ne??ea,onFocusChange:re,focusable:j}),(0,M.jsx)(mt,{isOptionHighlighted:l,isInputEmpty:t.isInputEmpty})]}),(0,M.jsx)("button",{ref:oe,type:"button",tabIndex:-1,className:me.scrollArrow,"data-aia-scroll-arrow":"","aria-label":Te.SCROLL_ARROW_LABEL,"aria-hidden":"true",children:(0,M.jsx)("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:(0,M.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Oe=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 {
|
|
1621
1633
|
flex-shrink: 0;
|
|
1622
1634
|
width: 32px;
|
|
1623
1635
|
height: 32px;
|
|
@@ -1652,5 +1664,5 @@
|
|
|
1652
1664
|
);
|
|
1653
1665
|
cursor: default;
|
|
1654
1666
|
}
|
|
1655
|
-
`,document.head.appendChild(e)}var At={submitButton:"SubmitButton-module_submitButton_otz7H"};var $e=require("react/jsx-runtime");function Dt({disabled:e,onClick:a}){return(0,$e.jsx)("button",{type:"button","data-aia-submit":"",className:At.submitButton,disabled:e,onClick:o=>{o.stopPropagation(),a()},"aria-label":"Submit",children:(0,$e.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,$e.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Re=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var nt=require("react");function Ct(e){let a=(0,nt.useRef)(e);a.current=e;let o=Object.keys(e??{}).sort().join("\0"),r=(0,nt.useRef)({key:"",overrides:void 0});if(r.current.key!==o){let n={};for(let i of Object.keys(e??{})){let s=(f,w,b)=>{let y=a.current?.[i];return y?y(f,w,b):[]};n[i]=s}r.current={key:o,overrides:e?n:void 0}}return{overrides:r.current.overrides,key:o}}var rt=require("react");function Et(e){let a=(0,rt.useRef)(e);a.current=e;let o=(0,rt.useRef)(null);o.current===null&&(o.current={fetch:(n,i)=>{let s=a.current;return s?s.fetch(n,i):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?o.current:void 0,enabled:r}}var ao={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function Ve({onSubmit:e,onResult:a,onError:o,optionOverrides:r,maskCompletedText:n,apiConfig:i,additionalContext:s,columns:f=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:y,showNonTappableOptions:m,showOptionIcons:_,showSkipButton:P,onFocus:v,onBlur:E,value:S,completedParams:N,onChange:ne,onParamsChange:re,products:U,onProductSelect:A,source:se,setCursor:le}){let h=(0,I.useRef)(null),[ve,de]=(0,I.useState)(null),z=(0,I.useRef)(e);z.current=e;let we=(0,I.useRef)(a);we.current=a;let Y=(0,I.useRef)(o);Y.current=o;let xe=(0,I.useRef)(ne);xe.current=ne;let oe=(0,I.useRef)(re);oe.current=re;let ae=(0,I.useRef)(v);ae.current=v;let ce=(0,I.useRef)(E);ce.current=E;let G=(0,I.useRef)(le);G.current=le;let pe=(0,I.useRef)(A);pe.current=A;let j=Et(U),F=Ct(r);(0,I.useEffect)(()=>{if(typeof document>"u")return;let g=new Re.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:s,optionOverrides:F.overrides,maskCompletedText:n,columns:f,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:y,showNonTappableOptions:m,source:se,value:S,completedParams:N,onSubmit:(...L)=>z.current?.(...L),onResult:(...L)=>we.current?.(...L),onError:(...L)=>Y.current?.(...L),onChange:(...L)=>xe.current?.(...L),onParamsChange:(...L)=>oe.current?.(...L),onFocus:()=>ae.current?.(),onBlur:()=>ce.current?.(),onProductSelect:L=>pe.current?.(L),setCursor:L=>G.current?.(L),products:j.config});h.current=g,de(g.getState());let Q=g.subscribe(L=>de(L));return()=>{Q(),g.destroy(),h.current===g&&(h.current=null)}},[]),(0,I.useEffect)(()=>{S!==void 0&&h.current?.setValue(S)},[S]),(0,I.useEffect)(()=>{N!==void 0&&h.current?.setCompletedParams(N)},[N]);let ue=JSON.stringify(i??null),t;try{t=JSON.stringify(s??null)}catch{t="[unstringifiable]"}(0,I.useEffect)(()=>{h.current?.update({apiConfig:i,additionalContext:s,optionOverrides:F.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:y,showNonTappableOptions:m})},[ue,t,F.key,w,b,y,m]);let c=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c.current){c.current=!0;return}h.current?.update({products:j.config})},[j.enabled]);let p=(0,I.useRef)(null);p.current===null&&(p.current={handleTextChange:g=>h.current?.handleTextChange(g),handleKeyDown:g=>{let Q="nativeEvent"in g?g.nativeEvent:g;h.current?.handleKeyDown(Q)},setFocused:g=>h.current?.setFocused(g),startEditingParam:g=>h.current?.startEditingParam(g),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:g=>h.current?.handleCaretAfterInput(g),handleCaretMove:g=>h.current?.handleCaretMove(g),replaceEditingRange:g=>h.current?.replaceEditingRange(g)??!1,setActivePill:g=>h.current?.setActivePill(g),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:g=>h.current?.selectOption(g),selectProduct:g=>h.current?.selectProduct(g),setActiveDropdownIndex:g=>h.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let l=p.current,x=(0,I.useCallback)(g=>{let Q=g.target.value,Xe=Q.length>0&&!g.nativeEvent?.isComposing&&Q[0]!==Q[0].toUpperCase()?Q[0].toUpperCase()+Q.slice(1):Q;h.current?.handleTextChange(Xe)},[]),O=(0,I.useCallback)(g=>{h.current?.handleKeyDown(g.nativeEvent)},[]),H=h.current,d=ve??ao,he=S!==void 0?S:d.text,Se=N!==void 0?N:d.completedParams,ye=d.actionableSuggestions,Ae=ye[0],X=H?.listboxId??"",De=d.activeDropdownIndex>=0&&H?`${X}-option-${d.activeDropdownIndex}`:void 0,$=d.editingParam,V=d.editingIdentified,Le=$?{type:$.suggestionType,text:$.suggestionPlaceholder,required:!0,options:$.options}:V?{type:V.type,text:(0,Re.identifiedParamLabel)(V.type),required:!0,options:[]}:null,Be=Le??Ae,Ye=Le?[Le]:ye,Me=(0,Re.dateSelectionFor)(d),Ge=!H||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:Se,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:ye,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:Ge,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:X,error:d.error,products:d.products,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:$,editingIdentified:V,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:he,placeholder:d.placeholderText||void 0,onChange:x,onKeyDown:O,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":De,"aria-autocomplete":"list","aria-controls":X},reset:l.reset,dropdownProps:{suggestions:Be?[{...Be,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:X,pills:Ye,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(P??!0)&&!$&&!V,showOptionIcons:_??!0,skipDisabled:d.inSelectionAnimation,isLoading:Ge,isInputEmpty:he.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Me.selectedIso,selectedDateRange:Me.selectedRange,dateRangeStart:Me.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:b??"below"}}}var q=require("@magicx-eng/ai-autocomplete-vanilla"),k=require("react"),Qe;function io(){if(Qe!==void 0)return Qe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Qe=e.contentEditable==="plaintext-only",Qe}function Tt(e){let{segments:a,showChipIcons:o=!0,newParamId:r,editingParam:n,editingIdentified:i,editingAnchor:s,caretOffset:f,placeholderText:w,isFocused:b,isDropdownOpen:y,listboxId:m,activeDescendantId:_,autoFocus:P,handleTextChange:v,handleKeyDown:E,handleCaretAfterInput:S,handleCaretMove:N,startEditingParam:ne,replaceEditingRange:re,setFocused:U}=e,A=(0,k.useRef)(null),se=(0,k.useRef)(!1),le=(0,k.useRef)(""),h=(0,k.useRef)(""),ve=(0,k.useRef)(null),de=(0,k.useRef)(0);ve.current=f,(0,k.useEffect)(()=>{if(!P)return;let t=A.current;if(!t)return;document.activeElement===t?U(!0):t.focus();let c=t.ownerDocument??document,p=c.getSelection(),l=p&&p.rangeCount>0&&t.contains(p.anchorNode);if(p&&!l){let x=c.createRange();x.selectNodeContents(t),x.collapse(!0),p.removeAllRanges(),p.addRange(x)}},[P,U]),(0,k.useEffect)(()=>{let t=A.current;if(!t)return;let c=t.ownerDocument??document,p=()=>{let l=c.getSelection();if(!l||l.rangeCount===0||!l.anchorNode||!t.contains(l.anchorNode))return;let x=l.anchorNode,O=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,d=(l.isCollapsed?O?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,he=n?.id??i?.id??null;if(d&&d!==he){ne(d);return}performance.now()-de.current<50||N((0,q.getCursorOffset)(t))};return c.addEventListener("selectionchange",p),()=>c.removeEventListener("selectionchange",p)},[n,i,ne,N]),(0,k.useLayoutEffect)(()=>{let t=A.current;t&&(0,q.renderEditableContent)({input:t,segments:a,newParamId:r,editingParamId:n?.id??null,placeholderText:w??"",isFocused:b,showChipIcons:o})},[a,r,n,w,b,o]),(0,k.useLayoutEffect)(()=>{let t=le.current,c=r??"";if(le.current=c,!c||c===t)return;let p=A.current;if(!p)return;p.focus();let l=ve.current??(0,q.plainTextLength)(p);(0,q.setCursorOffset)(p,l)},[r]),(0,k.useLayoutEffect)(()=>{let t=h.current,c=n?.id??"";if(h.current=c,!c||c===t||s==null)return;let p=A.current;p&&(0,q.setCursorOffset)(p,s)},[n,s]);let z=(0,k.useCallback)(()=>{if(se.current)return;let t=A.current;if(!t)return;let c=(0,q.extractPlainText)(t),l=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;v(l)},[v]),we=(0,k.useCallback)(()=>{de.current=performance.now(),z();let t=A.current;t&&S((0,q.getCursorOffset)(t))},[z,S]);(0,k.useEffect)(()=>{let t=A.current;if(!t)return;let c=p=>{let l=p,x=l.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){p.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let O=x.startsWith("delete")?"":l.data??"";re(O)&&p.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[re]);let Y=(0,k.useCallback)(()=>{se.current=!0},[]),xe=(0,k.useCallback)(()=>{se.current=!1,z()},[z]),oe=(0,k.useCallback)(t=>{t.preventDefault();let c=A.current;if(!c)return;let p=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!p)return;let l=c.ownerDocument??document,x=l.getSelection();if(!x||x.rangeCount===0)return;let O=x.getRangeAt(0);if(!c.contains(O.startContainer))return;O.deleteContents();let H=l.createTextNode(p);O.insertNode(H),O.setStartAfter(H),O.collapse(!0),x.removeAllRanges(),x.addRange(O),z()},[z]),ae=(0,k.useCallback)(t=>E(t),[E]),ce=(0,k.useCallback)(()=>U(!0),[U]),G=(0,k.useCallback)(()=>U(!1),[U]),pe=(0,k.useCallback)(()=>A.current?.focus(),[]),j=(0,k.useCallback)(()=>A.current?.blur(),[]),F=(0,k.useCallback)(()=>{let t=A.current;return t?(0,q.extractPlainText)(t):""},[]),ue=io()?"plaintext-only":"true";return{inputRef:A,editorProps:{ref:A,contentEditable:ue,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":y,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:we,onKeyDown:ae,onCompositionStart:Y,onCompositionEnd:xe,onPaste:oe,onFocus:ce,onBlur:G},getPlainText:F,focus:pe,blur:j}}var te=require("react/jsx-runtime");function no(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Rt=(0,R.forwardRef)(function({onSubmit:a,onResult:o,onError:r,optionOverrides:n,maskCompletedText:i,className:s,apiConfig:f,additionalContext:w,columns:b,pillPlacement:y="dropdown",mode:m="auto",optionsPosition:_="below",animations:P=!0,dropdownTrigger:v,closeDropdownOnBlur:E,showNonTappableOptions:S,showOptionIcons:N=!0,showChipIcons:ne=!0,showSkipButton:re,autoFocus:U=!0,onFocus:A,onBlur:se,value:le,completedParams:h,onChange:ve,onParamsChange:de,products:z,onProductSelect:we,submitButton:Y},xe){let oe=(0,R.useRef)(null),ae=(0,R.useRef)(null),ce=(0,R.useRef)(()=>{}),G=(0,R.useRef)(null),pe=(0,R.useRef)(null);(0,R.useEffect)(()=>{let D=oe.current;if(D)return G.current?G.current.setMode(m):G.current=new Oe.ModeController(D,m),()=>{G.current?.destroy(),G.current=null}},[m]);let j=(0,R.useCallback)(D=>{let _e=pe.current?.current;_e&&(_e.focus(),(0,Oe.setCursorOffset)(_e,D))},[]),{completedParams:F,skippedParams:ue,identifiedParams:t,isReady:c,suggestionPills:p,setActivePill:l,skipActivePill:x,segments:O,newParamId:H,clearNewParamId:d,placeholderText:he,isFocused:Se,isDropdownOpen:ye,isActivePillSelected:Ae,isLoading:X,activeIndex:De,listboxId:$,handleTextChange:V,handleKeyDown:Le,setFocused:Be,editingParam:Ye,editingIdentified:Me,editingAnchor:Ge,caretOffset:g,startEditingParam:Q,handleCaretAfterInput:L,handleCaretMove:Xe,replaceEditingRange:Ot,dropdownProps:Lt,reset:Fe}=Ve({onSubmit:D=>ce.current(D),onResult:o,onError:r,optionOverrides:n,maskCompletedText:i,apiConfig:f,additionalContext:w,columns:b,dropdownTrigger:v,optionsPosition:_,closeDropdownOnBlur:E,showNonTappableOptions:S,showOptionIcons:N,showSkipButton:re,onFocus:A,onBlur:se,value:le,completedParams:h,onChange:ve,onParamsChange:de,products:z,onProductSelect:we,source:"full-sdk",setCursor:j});(0,R.useEffect)(()=>{if(!H)return;let D=window.setTimeout(()=>d(),650);return()=>window.clearTimeout(D)},[H,d]);let Mt=De>=0?`${$}-option-${De}`:void 0,{inputRef:Ze,editorProps:Nt,focus:He,blur:st,getPlainText:lt}=Tt({segments:O,newParamId:H,editingParam:Ye,editingIdentified:Me,editingAnchor:Ge,caretOffset:g,placeholderText:he,isFocused:Se,showChipIcons:ne,isDropdownOpen:ye,listboxId:$,activeDescendantId:Mt,autoFocus:U,handleTextChange:V,handleKeyDown:Le,handleCaretAfterInput:L,handleCaretMove:Xe,startEditingParam:Q,replaceEditingRange:Ot,setFocused:Be});pe.current=Ze,(0,R.useLayoutEffect)(()=>{let D=ae.current,_e=Ze.current;if(!D||!_e)return;let dt=()=>{let pt=D.firstElementChild;if(!pt)return;let Ft=pt.getBoundingClientRect(),Ht=_e.getBoundingClientRect();Ft.top>=Ht.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};dt();let ct=new ResizeObserver(dt);return ct.observe(_e),()=>ct.disconnect()},[O,p.length,X,Ze]),(0,R.useImperativeHandle)(xe,()=>({focus:He,blur:st,reset:Fe,setMode:D=>G.current?.setMode(D),skipActivePill:x}),[He,st,Fe,x]);let Ke=!!O.length||F.length>0,Je=(0,R.useCallback)(()=>{if(!Ke)return;let D=lt();a((0,Oe.buildSubmitResult)(D,F,ue,{identifiedParams:t,isReady:c})),Fe()},[Ke,F,ue,t,c,a,Fe,lt]);ce.current=Je;let zt=(0,R.useCallback)(D=>{D.target?.closest("[data-aia-pill]")||He()},[He]),Bt=y==="inline",Gt=y==="dropdown";return(0,te.jsxs)("div",{ref:oe,className:`magicx-aia ${Pe.container} ${s??""}`,"data-pill-placement":y,"data-options-position":_,"data-animations":P?"on":"off","data-mode":no(m),children:[(0,te.jsx)(je,{...Lt,showPills:Gt}),(0,te.jsxs)("div",{className:Pe.inputWrapper,onClick:zt,children:[(0,te.jsxs)("div",{className:Pe.editorArea,"data-aia-editor":"",children:[(0,te.jsx)("div",{...Nt,className:Pe.input,"data-aia-input":""}),Bt&&(X||p.length>0)&&(0,te.jsx)("span",{ref:ae,className:Pe.pillListContainer,"data-aia-pill-list-container":"",children:(0,te.jsx)(qe,{pills:p,activePillIndex:0,activeSelected:Ae,onSelectPill:l,loading:X})})]}),Y===null?null:Y===void 0?(0,te.jsx)(Dt,{disabled:!Ke,onClick:Je}):(0,te.jsx)("span",{"data-aia-submit":"",className:Pe.submitSlot,onClick:D=>{Ke&&(D.stopPropagation(),Je())},children:Y})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,isoDate,monthLabel,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
1667
|
+
`,document.head.appendChild(e)}var At={submitButton:"SubmitButton-module_submitButton_otz7H"};var $e=require("react/jsx-runtime");function Dt({disabled:e,onClick:o}){return(0,$e.jsx)("button",{type:"button","data-aia-submit":"",className:At.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":"Submit",children:(0,$e.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,$e.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Re=require("@magicx-eng/ai-autocomplete-vanilla"),I=require("react");var nt=require("react");function Ct(e){let o=(0,nt.useRef)(e);o.current=e;let a=Object.keys(e??{}).sort().join("\0"),r=(0,nt.useRef)({key:"",overrides:void 0});if(r.current.key!==a){let n={};for(let i of Object.keys(e??{})){let s=(f,w,b)=>{let y=o.current?.[i];return y?y(f,w,b):[]};n[i]=s}r.current={key:a,overrides:e?n:void 0}}return{overrides:r.current.overrides,key:a}}var rt=require("react");function Et(e){let o=(0,rt.useRef)(e);o.current=e;let a=(0,rt.useRef)(null);a.current===null&&(a.current={fetch:(n,i)=>{let s=o.current;return s?s.fetch(n,i):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let r=e!==void 0;return{config:r?a.current:void 0,enabled:r}}var oa={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],activeFormatType:"options",dateView:null,dateRangeStart:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function Ve({onSubmit:e,onResult:o,onError:a,optionOverrides:r,maskCompletedText:n,apiConfig:i,additionalContext:s,columns:f=2,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:y,showNonTappableOptions:m,showOptionIcons:_,showSkipButton:P,onFocus:v,onBlur:E,value:S,completedParams:z,onChange:ne,onParamsChange:re,products:U,onProductSelect:A,source:se,setCursor:le}){let h=(0,I.useRef)(null),[ve,de]=(0,I.useState)(null),N=(0,I.useRef)(e);N.current=e;let we=(0,I.useRef)(o);we.current=o;let Y=(0,I.useRef)(a);Y.current=a;let xe=(0,I.useRef)(ne);xe.current=ne;let ae=(0,I.useRef)(re);ae.current=re;let oe=(0,I.useRef)(v);oe.current=v;let ce=(0,I.useRef)(E);ce.current=E;let B=(0,I.useRef)(le);B.current=le;let pe=(0,I.useRef)(A);pe.current=A;let j=Et(U),F=Ct(r);(0,I.useEffect)(()=>{if(typeof document>"u")return;let g=new Re.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:i,additionalContext:s,optionOverrides:F.overrides,maskCompletedText:n,columns:f,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:y,showNonTappableOptions:m,source:se,value:S,completedParams:z,onSubmit:(...L)=>N.current?.(...L),onResult:(...L)=>we.current?.(...L),onError:(...L)=>Y.current?.(...L),onChange:(...L)=>xe.current?.(...L),onParamsChange:(...L)=>ae.current?.(...L),onFocus:()=>oe.current?.(),onBlur:()=>ce.current?.(),onProductSelect:L=>pe.current?.(L),setCursor:L=>B.current?.(L),products:j.config});h.current=g,de(g.getState());let Q=g.subscribe(L=>de(L));return()=>{Q(),g.destroy(),h.current===g&&(h.current=null)}},[]),(0,I.useEffect)(()=>{S!==void 0&&h.current?.setValue(S)},[S]),(0,I.useEffect)(()=>{z!==void 0&&h.current?.setCompletedParams(z)},[z]);let ue=JSON.stringify(i??null),t;try{t=JSON.stringify(s??null)}catch{t="[unstringifiable]"}(0,I.useEffect)(()=>{h.current?.update({apiConfig:i,additionalContext:s,optionOverrides:F.overrides,dropdownTrigger:w,optionsPosition:b,closeDropdownOnBlur:y,showNonTappableOptions:m})},[ue,t,F.key,w,b,y,m]);let c=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c.current){c.current=!0;return}h.current?.update({products:j.config})},[j.enabled]);let p=(0,I.useRef)(null);p.current===null&&(p.current={handleTextChange:g=>h.current?.handleTextChange(g),handleKeyDown:g=>{let Q="nativeEvent"in g?g.nativeEvent:g;h.current?.handleKeyDown(Q)},setFocused:g=>h.current?.setFocused(g),startEditingParam:g=>h.current?.startEditingParam(g),exitEditMode:()=>h.current?.exitEditMode(),handleCaretAfterInput:g=>h.current?.handleCaretAfterInput(g),handleCaretMove:g=>h.current?.handleCaretMove(g),replaceEditingRange:g=>h.current?.replaceEditingRange(g)??!1,setActivePill:g=>h.current?.setActivePill(g),skipActivePill:()=>h.current?.skipActivePill(),removeLastParam:()=>h.current?.removeLastParam(),clearNewParamId:()=>h.current?.clearNewParamId(),reset:()=>h.current?.reset(),selectOption:g=>h.current?.selectOption(g),selectProduct:g=>h.current?.selectProduct(g),setActiveDropdownIndex:g=>h.current?.setActiveDropdownIndex(g),showPreviousMonth:()=>h.current?.showPreviousMonth(),showNextMonth:()=>h.current?.showNextMonth(),handleFocus:()=>h.current?.setFocused(!0),handleBlur:()=>h.current?.setFocused(!1)});let l=p.current,x=(0,I.useCallback)(g=>{let Q=g.target.value,Xe=Q.length>0&&!g.nativeEvent?.isComposing&&Q[0]!==Q[0].toUpperCase()?Q[0].toUpperCase()+Q.slice(1):Q;h.current?.handleTextChange(Xe)},[]),O=(0,I.useCallback)(g=>{h.current?.handleKeyDown(g.nativeEvent)},[]),H=h.current,d=ve??oa,he=S!==void 0?S:d.text,Se=z!==void 0?z:d.completedParams,ye=d.actionableSuggestions,Ae=ye[0],X=H?.listboxId??"",De=d.activeDropdownIndex>=0&&H?`${X}-option-${d.activeDropdownIndex}`:void 0,$=d.editingParam,V=d.editingIdentified,Le=$?{type:$.suggestionType,text:$.suggestionPlaceholder,required:!0,options:$.options}:V?{type:V.type,text:(0,Re.identifiedParamLabel)(V.type),required:!0,options:[]}:null,Ge=Le??Ae,Ye=Le?[Le]:ye,Me=(0,Re.dateSelectionFor)(d),Be=!H||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation||d.isSearchingOptions;return{completedParams:Se,skippedParams:d.skippedParams,identifiedParams:d.identifiedParams,suggestionPills:ye,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:Be,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:X,error:d.error,products:d.products,selectProduct:l.selectProduct,handleTextChange:l.handleTextChange,handleKeyDown:l.handleKeyDown,setFocused:l.setFocused,editingParam:$,editingIdentified:V,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:l.startEditingParam,exitEditMode:l.exitEditMode,handleCaretAfterInput:l.handleCaretAfterInput,handleCaretMove:l.handleCaretMove,replaceEditingRange:l.replaceEditingRange,inputProps:{value:he,placeholder:d.placeholderText||void 0,onChange:x,onKeyDown:O,onFocus:l.handleFocus,onBlur:l.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":De,"aria-autocomplete":"list","aria-controls":X},reset:l.reset,dropdownProps:{suggestions:Ge?[{...Ge,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:l.selectOption,onHighlight:l.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:X,pills:Ye,activeSelected:d.isActivePillSelected,onPillClick:l.setActivePill,onSkip:l.skipActivePill,showSkipButton:(P??!0)&&!$&&!V,showOptionIcons:_??!0,skipDisabled:d.inSelectionAnimation,isLoading:Be,isInputEmpty:he.trim().length===0,products:d.products,onProductSelect:l.selectProduct,onProductFocusChange:l.setFocused,formatType:d.activeFormatType,dateView:d.dateView,selectedDateIso:Me.selectedIso,selectedDateRange:Me.selectedRange,dateRangeStart:Me.rangeStart,onPreviousMonth:l.showPreviousMonth,onNextMonth:l.showNextMonth,optionsPosition:b??"below"}}}var q=require("@magicx-eng/ai-autocomplete-vanilla"),k=require("react"),Qe;function ia(){if(Qe!==void 0)return Qe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Qe=e.contentEditable==="plaintext-only",Qe}function Tt(e){let{segments:o,showChipIcons:a=!0,newParamId:r,editingParam:n,editingIdentified:i,editingAnchor:s,caretOffset:f,placeholderText:w,isFocused:b,isDropdownOpen:y,listboxId:m,activeDescendantId:_,autoFocus:P,handleTextChange:v,handleKeyDown:E,handleCaretAfterInput:S,handleCaretMove:z,startEditingParam:ne,replaceEditingRange:re,setFocused:U}=e,A=(0,k.useRef)(null),se=(0,k.useRef)(!1),le=(0,k.useRef)(""),h=(0,k.useRef)(""),ve=(0,k.useRef)(null),de=(0,k.useRef)(0);ve.current=f,(0,k.useEffect)(()=>{if(!P)return;let t=A.current;if(!t)return;document.activeElement===t?U(!0):t.focus();let c=t.ownerDocument??document,p=c.getSelection(),l=p&&p.rangeCount>0&&t.contains(p.anchorNode);if(p&&!l){let x=c.createRange();x.selectNodeContents(t),x.collapse(!0),p.removeAllRanges(),p.addRange(x)}},[P,U]),(0,k.useEffect)(()=>{let t=A.current;if(!t)return;let c=t.ownerDocument??document,p=()=>{let l=c.getSelection();if(!l||l.rangeCount===0||!l.anchorNode||!t.contains(l.anchorNode))return;let x=l.anchorNode,O=x.nodeType===Node.ELEMENT_NODE?x:x.parentElement,d=(l.isCollapsed?O?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,he=n?.id??i?.id??null;if(d&&d!==he){ne(d);return}performance.now()-de.current<50||z((0,q.getCursorOffset)(t))};return c.addEventListener("selectionchange",p),()=>c.removeEventListener("selectionchange",p)},[n,i,ne,z]),(0,k.useLayoutEffect)(()=>{let t=A.current;t&&(0,q.renderEditableContent)({input:t,segments:o,newParamId:r,editingParamId:n?.id??null,placeholderText:w??"",isFocused:b,showChipIcons:a})},[o,r,n,w,b,a]),(0,k.useLayoutEffect)(()=>{let t=le.current,c=r??"";if(le.current=c,!c||c===t)return;let p=A.current;if(!p)return;p.focus();let l=ve.current??(0,q.plainTextLength)(p);(0,q.setCursorOffset)(p,l)},[r]),(0,k.useLayoutEffect)(()=>{let t=h.current,c=n?.id??"";if(h.current=c,!c||c===t||s==null)return;let p=A.current;p&&(0,q.setCursorOffset)(p,s)},[n,s]);let N=(0,k.useCallback)(()=>{if(se.current)return;let t=A.current;if(!t)return;let c=(0,q.extractPlainText)(t),l=c.length>0&&c[0]!==c[0].toUpperCase()?c[0].toUpperCase()+c.slice(1):c;v(l)},[v]),we=(0,k.useCallback)(()=>{de.current=performance.now(),N();let t=A.current;t&&S((0,q.getCursorOffset)(t))},[N,S]);(0,k.useEffect)(()=>{let t=A.current;if(!t)return;let c=p=>{let l=p,x=l.inputType;if(x==="insertParagraph"||x==="insertLineBreak"||x==="insertFromDrop"){p.preventDefault();return}if(x.startsWith("insert")||x.startsWith("delete")){let O=x.startsWith("delete")?"":l.data??"";re(O)&&p.preventDefault()}};return t.addEventListener("beforeinput",c),()=>t.removeEventListener("beforeinput",c)},[re]);let Y=(0,k.useCallback)(()=>{se.current=!0},[]),xe=(0,k.useCallback)(()=>{se.current=!1,N()},[N]),ae=(0,k.useCallback)(t=>{t.preventDefault();let c=A.current;if(!c)return;let p=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!p)return;let l=c.ownerDocument??document,x=l.getSelection();if(!x||x.rangeCount===0)return;let O=x.getRangeAt(0);if(!c.contains(O.startContainer))return;O.deleteContents();let H=l.createTextNode(p);O.insertNode(H),O.setStartAfter(H),O.collapse(!0),x.removeAllRanges(),x.addRange(O),N()},[N]),oe=(0,k.useCallback)(t=>E(t),[E]),ce=(0,k.useCallback)(()=>U(!0),[U]),B=(0,k.useCallback)(()=>U(!1),[U]),pe=(0,k.useCallback)(()=>A.current?.focus(),[]),j=(0,k.useCallback)(()=>A.current?.blur(),[]),F=(0,k.useCallback)(()=>{let t=A.current;return t?(0,q.extractPlainText)(t):""},[]),ue=ia()?"plaintext-only":"true";return{inputRef:A,editorProps:{ref:A,contentEditable:ue,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":m,"aria-expanded":y,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:we,onKeyDown:oe,onCompositionStart:Y,onCompositionEnd:xe,onPaste:ae,onFocus:ce,onBlur:B},getPlainText:F,focus:pe,blur:j}}var te=require("react/jsx-runtime");function na(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Rt=(0,R.forwardRef)(function({onSubmit:o,onResult:a,onError:r,optionOverrides:n,maskCompletedText:i,className:s,apiConfig:f,additionalContext:w,columns:b,pillPlacement:y="dropdown",mode:m="auto",optionsPosition:_="below",animations:P=!0,dropdownTrigger:v,closeDropdownOnBlur:E,showNonTappableOptions:S,showOptionIcons:z=!0,showChipIcons:ne=!0,showSkipButton:re,autoFocus:U=!0,onFocus:A,onBlur:se,value:le,completedParams:h,onChange:ve,onParamsChange:de,products:N,onProductSelect:we,submitButton:Y},xe){let ae=(0,R.useRef)(null),oe=(0,R.useRef)(null),ce=(0,R.useRef)(()=>{}),B=(0,R.useRef)(null),pe=(0,R.useRef)(null);(0,R.useEffect)(()=>{let D=ae.current;if(D)return B.current?B.current.setMode(m):B.current=new Oe.ModeController(D,m),()=>{B.current?.destroy(),B.current=null}},[m]);let j=(0,R.useCallback)(D=>{let _e=pe.current?.current;_e&&(_e.focus(),(0,Oe.setCursorOffset)(_e,D))},[]),{completedParams:F,skippedParams:ue,identifiedParams:t,isReady:c,suggestionPills:p,setActivePill:l,skipActivePill:x,segments:O,newParamId:H,clearNewParamId:d,placeholderText:he,isFocused:Se,isDropdownOpen:ye,isActivePillSelected:Ae,isLoading:X,activeIndex:De,listboxId:$,handleTextChange:V,handleKeyDown:Le,setFocused:Ge,editingParam:Ye,editingIdentified:Me,editingAnchor:Be,caretOffset:g,startEditingParam:Q,handleCaretAfterInput:L,handleCaretMove:Xe,replaceEditingRange:Ot,dropdownProps:Lt,reset:Fe}=Ve({onSubmit:D=>ce.current(D),onResult:a,onError:r,optionOverrides:n,maskCompletedText:i,apiConfig:f,additionalContext:w,columns:b,dropdownTrigger:v,optionsPosition:_,closeDropdownOnBlur:E,showNonTappableOptions:S,showOptionIcons:z,showSkipButton:re,onFocus:A,onBlur:se,value:le,completedParams:h,onChange:ve,onParamsChange:de,products:N,onProductSelect:we,source:"full-sdk",setCursor:j});(0,R.useEffect)(()=>{if(!H)return;let D=window.setTimeout(()=>d(),650);return()=>window.clearTimeout(D)},[H,d]);let Mt=De>=0?`${$}-option-${De}`:void 0,{inputRef:Ze,editorProps:zt,focus:He,blur:st,getPlainText:lt}=Tt({segments:O,newParamId:H,editingParam:Ye,editingIdentified:Me,editingAnchor:Be,caretOffset:g,placeholderText:he,isFocused:Se,showChipIcons:ne,isDropdownOpen:ye,listboxId:$,activeDescendantId:Mt,autoFocus:U,handleTextChange:V,handleKeyDown:Le,handleCaretAfterInput:L,handleCaretMove:Xe,startEditingParam:Q,replaceEditingRange:Ot,setFocused:Ge});pe.current=Ze,(0,R.useLayoutEffect)(()=>{let D=oe.current,_e=Ze.current;if(!D||!_e)return;let dt=()=>{let pt=D.firstElementChild;if(!pt)return;let Ft=pt.getBoundingClientRect(),Ht=_e.getBoundingClientRect();Ft.top>=Ht.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};dt();let ct=new ResizeObserver(dt);return ct.observe(_e),()=>ct.disconnect()},[O,p.length,X,Ze]),(0,R.useImperativeHandle)(xe,()=>({focus:He,blur:st,reset:Fe,setMode:D=>B.current?.setMode(D),skipActivePill:x}),[He,st,Fe,x]);let Ke=!!O.length||F.length>0,Je=(0,R.useCallback)(()=>{if(!Ke)return;let D=lt();o((0,Oe.buildSubmitResult)(D,F,ue,{identifiedParams:t,isReady:c})),Fe()},[Ke,F,ue,t,c,o,Fe,lt]);ce.current=Je;let Nt=(0,R.useCallback)(D=>{D.target?.closest("[data-aia-pill]")||He()},[He]),Gt=y==="inline",Bt=y==="dropdown";return(0,te.jsxs)("div",{ref:ae,className:`magicx-aia ${Pe.container} ${s??""}`,"data-pill-placement":y,"data-options-position":_,"data-animations":P?"on":"off","data-mode":na(m),children:[(0,te.jsx)(je,{...Lt,showPills:Bt}),(0,te.jsxs)("div",{className:Pe.inputWrapper,onClick:Nt,children:[(0,te.jsxs)("div",{className:Pe.editorArea,"data-aia-editor":"",children:[(0,te.jsx)("div",{...zt,className:Pe.input,"data-aia-input":""}),Gt&&(X||p.length>0)&&(0,te.jsx)("span",{ref:oe,className:Pe.pillListContainer,"data-aia-pill-list-container":"",children:(0,te.jsx)(qe,{pills:p,activePillIndex:0,activeSelected:Ae,onSelectPill:l,loading:X})})]}),Y===null?null:Y===void 0?(0,te.jsx)(Dt,{disabled:!Ke,onClick:Je}):(0,te.jsx)("span",{"data-aia-submit":"",className:Pe.submitSlot,onClick:D=>{Ke&&(D.stopPropagation(),Je())},children:Y})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,isoDate,monthLabel,optionLabel,parseDate,parseLooseDate,parseLooseDateRange,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
1656
1668
|
//# sourceMappingURL=index.js.map
|