@magicx-eng/ai-autocomplete-react 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -2
- package/dist/index.d.mts +27 -7
- package/dist/index.d.ts +27 -7
- package/dist/index.js +232 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +232 -16
- 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 Tt=Object.defineProperty;var ua=Object.getOwnPropertyDescriptor;var ma=Object.getOwnPropertyNames;var ga=Object.prototype.hasOwnProperty;var fa=(e,i)=>{for(var t in i)Tt(e,t,{get:i[t],enumerable:!0})},ba=(e,i,t,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of ma(i))!ga.call(e,o)&&o!==t&&Tt(e,o,{get:()=>i[o],enumerable:!(a=ua(i,o))||a.enumerable});return e};var wa=e=>ba(Tt({},"__esModule",{value:!0}),e);var Fa={};fa(Fa,{AIAutocomplete:()=>na,AIAutocompleteDropdown:()=>wt,DATE_RANGE_META_END:()=>s.DATE_RANGE_META_END,DATE_RANGE_META_START:()=>s.DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT:()=>s.DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX:()=>s.PRODUCT_PATH_PREFIX,TIME_META_KEY:()=>s.TIME_META_KEY,WEEKDAY_LABELS:()=>s.WEEKDAY_LABELS,buildSubmitResult:()=>s.buildSubmitResult,cellDay:()=>s.cellDay,cellIso:()=>s.cellIso,dateCellMarks:()=>s.dateCellMarks,formatDate:()=>s.formatDate,formatDateRange:()=>s.formatDateRange,formatOptionCount:()=>s.formatOptionCount,formatTime:()=>s.formatTime,isoDate:()=>s.isoDate,monthLabel:()=>s.monthLabel,optionCountLabel:()=>s.optionCountLabel,optionHasImage:()=>s.optionHasImage,optionImageSources:()=>s.optionImageSources,optionImageSrc:()=>s.optionImageSrc,optionLabel:()=>s.optionLabel,optionsShowLeadingVisuals:()=>s.optionsShowLeadingVisuals,parseDate:()=>s.parseDate,parseLooseDate:()=>s.parseLooseDate,parseLooseDateRange:()=>s.parseLooseDateRange,parseTime:()=>s.parseTime,productFromMatchedItem:()=>s.productFromMatchedItem,productImageSources:()=>s.productImageSources,productsFromCustomFields:()=>s.productsFromCustomFields,sanitizeOptionIconSvg:()=>s.sanitizeOptionIconSvg,selectedRangeFor:()=>s.selectedRangeFor,useAIAutocomplete:()=>xt,visibleDateRange:()=>s.visibleDateRange,withSkippedParams:()=>s.withSkippedParams});module.exports=wa(Fa);var s=require("@magicx-eng/ai-autocomplete-vanilla");var K=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.aia-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
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
opacity: 0;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
`,document.head.appendChild(e)}var
|
|
283
|
+
`,document.head.appendChild(e)}var Je={container:"aia-container-KKjFU",inputWrapper:"aia-inputWrapper-FLq1b",editorArea:"aia-editorArea-7rBWq",input:"aia-input-IW-P-",pillListContainer:"aia-pillListContainer-h92IA",submitSlot:"aia-submitSlot-GhuCM",aiaPillReveal:"aia-aiaPillReveal-wf05b"};var le=require("@magicx-eng/ai-autocomplete-vanilla"),ee=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
284
284
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
285
285
|
* Consumer CSS always wins without !important.
|
|
286
286
|
*
|
|
@@ -822,6 +822,15 @@
|
|
|
822
822
|
max-height: none;
|
|
823
823
|
overflow: visible;
|
|
824
824
|
}
|
|
825
|
+
|
|
826
|
+
[data-aia-dropdown][aria-multiselectable="true"] {
|
|
827
|
+
--aia-grid-scroll-bottom: 0px;
|
|
828
|
+
--aia-grid-overlap-bottom: 0px;
|
|
829
|
+
--aia-grid-scroll-top: 0px;
|
|
830
|
+
--aia-grid-overlap-top: 0px;
|
|
831
|
+
--aia-footer-fade-lead: 0px;
|
|
832
|
+
--aia-footer-row-min-height: 0px;
|
|
833
|
+
}
|
|
825
834
|
`,document.head.appendChild(e)}if(typeof document<"u"&&!document.getElementById("ac-style-3819c762")){let e=document.createElement("style");e.id="ac-style-3819c762",e.textContent=`.aia-dropdown-yz2KC {
|
|
826
835
|
position: absolute;
|
|
827
836
|
left: 0;
|
|
@@ -875,6 +884,11 @@
|
|
|
875
884
|
max-width: var(--aia-date-panel-width, 312px);
|
|
876
885
|
}
|
|
877
886
|
|
|
887
|
+
/* The time wheel is narrower still \u2014 three short wheels and a button. */
|
|
888
|
+
.aia-dropdown-yz2KC:has([data-aia-time-wheel]) {
|
|
889
|
+
max-width: var(--aia-time-panel-width, 240px);
|
|
890
|
+
}
|
|
891
|
+
|
|
878
892
|
.aia-dropdown-yz2KC[data-aia-surface="glass"] {
|
|
879
893
|
background: transparent;
|
|
880
894
|
border-color: transparent;
|
|
@@ -1132,7 +1146,23 @@
|
|
|
1132
1146
|
opacity: 0.25;
|
|
1133
1147
|
}
|
|
1134
1148
|
}
|
|
1135
|
-
|
|
1149
|
+
|
|
1150
|
+
.aia-multiDone-y12U7 {
|
|
1151
|
+
display: block;
|
|
1152
|
+
width: auto;
|
|
1153
|
+
margin-left: auto;
|
|
1154
|
+
height: 32px;
|
|
1155
|
+
padding: 0 18px;
|
|
1156
|
+
border: none;
|
|
1157
|
+
border-radius: 999px;
|
|
1158
|
+
background: var(--aia-option-bg, transparent);
|
|
1159
|
+
color: var(--aia-option-color);
|
|
1160
|
+
font-family: inherit;
|
|
1161
|
+
font-size: 15px;
|
|
1162
|
+
font-weight: inherit;
|
|
1163
|
+
cursor: pointer;
|
|
1164
|
+
}
|
|
1165
|
+
`,document.head.appendChild(e)}var Ce={dropdown:"aia-dropdown-yz2KC",visible:"aia-visible-QCoXj",scrollArrow:"aia-scrollArrow-uUzV0","magicx-aia-scroll-arrow-bob":"aia-magicx-aia-scroll-arrow-bob-z-HXC",pillBar:"aia-pillBar-pwTXe",pillScroll:"aia-pillScroll-Tpzus",skip:"aia-skip-7-olS",skeletonBars:"aia-skeletonBars-HVr9C",skeletonBarsIn:"aia-skeletonBarsIn-BdPrL",skeletonBarsOut:"aia-skeletonBarsOut-TqKeD",skeletonBar:"aia-skeletonBar-O3xIx",aiaSkeletonPulse:"aia-aiaSkeletonPulse-G8W7q",multiDone:"aia-multiDone-y12U7"};var W=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) ---
|
|
1136
1166
|
|
|
1137
1167
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1138
1168
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1295,7 +1325,7 @@
|
|
|
1295
1325
|
opacity: 0.8;
|
|
1296
1326
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1297
1327
|
}
|
|
1298
|
-
`,document.head.appendChild(e)}var
|
|
1328
|
+
`,document.head.appendChild(e)}var N={datepicker:"aia-datepicker-6RrTs",header:"aia-header-z4LRk",month:"aia-month-urB2T",nav:"aia-nav-ap4AN",weekdays:"aia-weekdays-3EA3q",grid:"aia-grid-mQCgw",weekday:"aia-weekday-3lF4B",cell:"aia-cell-59k0y",number:"aia-number-aoT01",day:"aia-day-cB3u9",blank:"aia-blank-ivgRC",past:"aia-past-CEZsj",highlighted:"aia-highlighted-YIdtK",today:"aia-today-iI3ME",inRange:"aia-inRange-r9S2q",selected:"aia-selected-28KDn",pressed:"aia-pressed-bEyyN"};var re=require("react/jsx-runtime"),va=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function Ht({options:e,activeIndex:i,listboxId:t,view:a,selection:o,onSelect:r,onHighlight:n,onUnhighlight:l,onPreviousMonth:u,onNextMonth:w}){let y=(0,W.isoDate)(new Date),g=(0,W.visibleDateRange)({pendingStart:o.rangeStart,highlightedIso:(0,W.cellIso)(e[i]),selected:o.selectedRange});return(0,re.jsxs)("div",{className:N.datepicker,"data-aia-datepicker":"",children:[(0,re.jsxs)("div",{className:N.header,children:[(0,re.jsx)("button",{type:"button",tabIndex:-1,className:N.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:d=>d.preventDefault(),onClick:u,children:"\u2039"}),(0,re.jsx)("span",{className:N.month,"data-aia-date-month":"","aria-live":"polite",children:(0,W.monthLabel)(a)}),(0,re.jsx)("button",{type:"button",tabIndex:-1,className:N.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:d=>d.preventDefault(),onClick:w,children:"\u203A"})]}),(0,re.jsx)("div",{className:N.weekdays,"aria-hidden":"true",children:W.WEEKDAY_LABELS.map((d,c)=>(0,re.jsx)("span",{className:N.weekday,children:d},va[c]))}),(0,re.jsx)("div",{className:N.grid,"data-aia-date-grid":"",children:e.map((d,c)=>(0,re.jsx)(xa,{option:d,id:`${t}-option-${c}`,index:c,isHighlighted:c===i&&d.is_tappable,isToday:(0,W.cellIso)(d)===y,isPast:(0,W.cellIso)(d)!=null&&(0,W.cellIso)(d)<y,marks:(0,W.dateCellMarks)((0,W.cellIso)(d),{selectedIso:o.selectedIso,range:g}),onSelect:r,onHighlight:n,onUnhighlight:l},(0,W.cellIso)(d)??`pad-${c}`))})]})}function xa({option:e,id:i,index:t,isHighlighted:a,isToday:o,isPast:r,marks:n,onSelect:l,onHighlight:u,onUnhighlight:w}){let[y,g]=(0,Nt.useState)(!1),d=(0,W.cellDay)(e);if(d==null)return(0,re.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${N.cell} ${N.blank}`});let c=()=>{g(!0),l(e),setTimeout(()=>g(!1),170)},v=[N.cell,N.day,r?N.past:"",a?N.highlighted:"",o?N.today:"",n.inRange?N.inRange:"",n.selected?N.selected:"",y?N.pressed:""].filter(Boolean).join(" ");return(0,re.jsx)("div",{id:i,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:v,onClick:c,onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),c())},onMouseEnter:()=>u(t),onMouseLeave:w?()=>w(t):void 0,children:(0,re.jsx)("span",{className:N.number,children:d})})}var _e=require("@magicx-eng/ai-autocomplete-vanilla"),mt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1299
1329
|
display: flex;
|
|
1300
1330
|
flex-wrap: wrap;
|
|
1301
1331
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1335,7 +1365,7 @@
|
|
|
1335
1365
|
.aia-cluster[data-justify="around"] {
|
|
1336
1366
|
justify-content: space-around;
|
|
1337
1367
|
}
|
|
1338
|
-
`,document.head.appendChild(e)}var
|
|
1368
|
+
`,document.head.appendChild(e)}var Pt=require("react/jsx-runtime");function lt({gap:e,align:i="center",justify:t="start",noWrap:a=!1,inline:o=!1,className:r,children:n,...l}){let u=e?{"--aia-cluster-gap":e}:void 0,w={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":i,"data-justify":t,"data-nowrap":a||void 0,"data-inline":o||void 0,style:u,...l};return o?(0,Pt.jsx)("span",{...w,children:n}):(0,Pt.jsx)("div",{...w,children:n})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1339
1369
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1340
1370
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1341
1371
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1482,7 +1512,7 @@
|
|
|
1482
1512
|
justify-content: flex-end;
|
|
1483
1513
|
}
|
|
1484
1514
|
}
|
|
1485
|
-
`,document.head.appendChild(e)}var
|
|
1515
|
+
`,document.head.appendChild(e)}var De={footer:"aia-footer-qQQ7x",row:"aia-row-BgZ6Q",hintGroup:"aia-hintGroup-ZzbPf",brandLink:"aia-brandLink-r4f3R",key:"aia-key-Bz1H-",hint:"aia-hint-GKEOH",brand:"aia-brand-Al-lR",badge:"aia-badge-Fk9vg"};var Te=require("react/jsx-runtime");function Ft({isOptionHighlighted:e=!1,isInputEmpty:i=!1,strings:t=(0,_e.uiStringsFor)()}){let{key:a,hint:o}=(0,_e.getFooterHint)(e,i,t),[r,n]=(0,mt.useState)(_e.ATTRIBUTION_URL);return(0,mt.useEffect)(()=>{n((0,_e.buildAttributionUrl)())},[]),(0,Te.jsx)("footer",{className:De.footer,"data-aia-footer":"",children:(0,Te.jsxs)(lt,{justify:"between",noWrap:!0,className:De.row,children:[(0,Te.jsxs)(lt,{gap:"5px",className:De.hintGroup,children:[(0,Te.jsx)("kbd",{className:De.key,children:a}),(0,Te.jsx)("span",{className:De.hint,children:o})]}),(0,Te.jsxs)("a",{className:De.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[(0,Te.jsx)("span",{className:De.brand,children:"AI"}),(0,Te.jsx)("span",{className:De.badge,children:"Autocomplete"})]})]})})}var gt=require("@magicx-eng/ai-autocomplete-vanilla");var Bt=require("@magicx-eng/ai-autocomplete-vanilla");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,
|
|
1486
1516
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1487
1517
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1488
1518
|
as it was when the outline was dashed. */
|
|
@@ -1662,7 +1692,7 @@
|
|
|
1662
1692
|
opacity: 0;
|
|
1663
1693
|
}
|
|
1664
1694
|
}
|
|
1665
|
-
`,document.head.appendChild(e)}var
|
|
1695
|
+
`,document.head.appendChild(e)}var Pe={pill:"aia-pill-6Ga7S",fadeIn:"aia-fadeIn-Ux4eQ",rounded:"aia-rounded-y7xA9",smartText:"aia-smartText-R0cfw","smartSuggestion-shimmer":"aia-smartSuggestion-shimmer-F-yoD",smartSparkle:"aia-smartSparkle-IVabG","smartSuggestion-sparkle":"aia-smartSuggestion-sparkle-Wfj-4","smartSuggestion-sparkle-small":"aia-smartSuggestion-sparkle-small-3VsWJ",skeleton:"aia-skeleton-57P0T",skeletonIn:"aia-skeletonIn-54kMv",skeletonPulse:"aia-skeletonPulse-xGcUy",skeletonOut:"aia-skeletonOut-1sJ-r"};var Ue=require("react/jsx-runtime"),It={selected:1,first:.7,next:.4,last:.2};function Wt({label:e,state:i,rounded:t,loading:a,smartSuggestion:o,completionHeader:r,onClick:n}){let l=[Pe.pill,t?Pe.rounded:"",a?Pe.skeleton:""].filter(Boolean).join(" ");return(0,Ue.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":a?"":void 0,"data-aia-smart-suggestion":o?r?"header":"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:l,style:{opacity:It[i]},onMouseDown:u=>u.preventDefault(),onClick:a?void 0:n,disabled:a,children:o?(0,Ue.jsxs)(Ue.Fragment,{children:[(0,Ue.jsx)("span",{className:`${Pe.smartText} magicx-aia-smart-suggestion-text`,children:e}),(0,Ue.jsx)("span",{className:`${Pe.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:Bt.SMART_SUGGESTION_SPARKLE_SVG}})]}):e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.aia-list-qvLqO {
|
|
1666
1696
|
position: relative;
|
|
1667
1697
|
z-index: 1;
|
|
1668
1698
|
pointer-events: auto;
|
|
@@ -1672,7 +1702,7 @@
|
|
|
1672
1702
|
align-items: center;
|
|
1673
1703
|
vertical-align: middle;
|
|
1674
1704
|
}
|
|
1675
|
-
`,document.head.appendChild(e)}var
|
|
1705
|
+
`,document.head.appendChild(e)}var Et={list:"aia-list-qvLqO"};var dt=require("react/jsx-runtime"),ya=[125,69];function Gt(e){return e===0?"first":e===1?"next":"last"}function ft({pills:e,activePillIndex:i,onSelectPill:t,activeSelected:a,rounded:o,loading:r}){return r&&e.length===0?(0,dt.jsx)("span",{className:Et.list,"data-aia-pill-list-loading":"",children:ya.map((n,l)=>(0,dt.jsx)("span",{"data-aia-pill-skeleton":"",className:`${Pe.pill} ${o?Pe.rounded:""} ${Pe.skeleton}`,style:{width:n,opacity:It[Gt(l)]}},`skel-${n}`))}):(0,dt.jsx)("span",{className:Et.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((n,l)=>{let u=!!a&&l===i;return(0,dt.jsx)(Wt,{label:n.text,state:u?"selected":Gt(l),selected:u,rounded:o,loading:r,smartSuggestion:(0,gt.isSmartSuggestion)(n),completionHeader:(0,gt.isTraditionalAutocompleteSuggestion)(n),onClick:()=>t(l)},`${n.parameter}-${n.text}`)})})}var ue=require("@magicx-eng/ai-autocomplete-vanilla"),se=require("react");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
|
|
1676
1706
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1677
1707
|
theming one package sees the same result in the other.
|
|
1678
1708
|
|
|
@@ -1991,10 +2021,10 @@
|
|
|
1991
2021
|
display: none;
|
|
1992
2022
|
}
|
|
1993
2023
|
|
|
1994
|
-
/* While the integration's promise is in flight the button
|
|
1995
|
-
|
|
2024
|
+
/* While the integration's promise is in flight the button ignores presses
|
|
2025
|
+
and shows a spinner (below); once it resolves the cart turns into a check,
|
|
2026
|
+
which stays. */
|
|
1996
2027
|
.aia-cart-kSlqU[data-aia-cart-state="adding"] {
|
|
1997
|
-
opacity: 0.6;
|
|
1998
2028
|
cursor: progress;
|
|
1999
2029
|
}
|
|
2000
2030
|
|
|
@@ -2006,6 +2036,36 @@
|
|
|
2006
2036
|
display: inline;
|
|
2007
2037
|
}
|
|
2008
2038
|
|
|
2039
|
+
/* While the add is in flight the cart gives way to a spinning arc. A slower
|
|
2040
|
+
turn under reduced motion: it is the only sign the press took. */
|
|
2041
|
+
.aia-cartSpinner-442rc {
|
|
2042
|
+
display: none;
|
|
2043
|
+
}
|
|
2044
|
+
|
|
2045
|
+
.aia-cart-kSlqU[data-aia-cart-state="adding"] .aia-cartGlyph-cmqAk {
|
|
2046
|
+
display: none;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
.aia-cart-kSlqU[data-aia-cart-state="adding"] .aia-cartSpinner-442rc {
|
|
2050
|
+
display: inline;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
.aia-cart-kSlqU[data-aia-cart-state="adding"] svg {
|
|
2054
|
+
animation: aia-magicx-aia-product-cart-spin-x8mgr 0.8s linear infinite;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
@keyframes aia-magicx-aia-product-cart-spin-x8mgr {
|
|
2058
|
+
to {
|
|
2059
|
+
transform: rotate(360deg);
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2064
|
+
.aia-cart-kSlqU[data-aia-cart-state="adding"] svg {
|
|
2065
|
+
animation-duration: 2s;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2009
2069
|
/* A sold-out product's image steps back, so the badge is not the only cue.
|
|
2010
2070
|
Desaturated rather than faded: opacity lets the panel show through, which
|
|
2011
2071
|
muddies a photo on a dark surface. */
|
|
@@ -2086,7 +2146,7 @@
|
|
|
2086
2146
|
.aia-section-Hugfg[data-aia-products-layout="list"] .aia-card-JBGYT[data-aia-product-has-cart] {
|
|
2087
2147
|
padding-right: calc(var(--aia-product-cart-size, 28px) + 16px);
|
|
2088
2148
|
}
|
|
2089
|
-
`,document.head.appendChild(e)}var
|
|
2149
|
+
`,document.head.appendChild(e)}var G={section:"aia-section-Hugfg",label:"aia-label-nuc93",row:"aia-row-WDVBX",card:"aia-card-JBGYT",media:"aia-media-RrbGe",image:"aia-image-5pNL7",body:"aia-body-ly032",vendor:"aia-vendor-Gvu7G",title:"aia-title-gCNmq",price:"aia-price-gULcE",badge:"aia-badge-j9Hcd",cart:"aia-cart-kSlqU",cartCheck:"aia-cartCheck-YTTQ6",cartGlyph:"aia-cartGlyph-cmqAk",cartSpinner:"aia-cartSpinner-442rc","magicx-aia-product-cart-spin":"aia-magicx-aia-product-cart-spin-x8mgr"};var L=require("react/jsx-runtime");function Kt({products:e,listboxId:i,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r=!0,layout:n="row",imageFallback:l="image",strings:u=(0,ue.uiStringsFor)()}){let w=e.length>0,y=(0,se.useRef)(null);if((0,se.useEffect)(()=>{let d=y.current;if(!(!w||!d))return(0,ue.attachProductRowWheel)(d)},[w]),!w)return null;let g=`${i}-products-label`;return(0,L.jsxs)("section",{className:G.section,"data-aia-products":"","data-aia-products-layout":n,role:"group","aria-labelledby":g,children:[(0,L.jsx)("div",{className:G.label,id:g,"data-aia-products-label":"",children:u.products}),(0,L.jsx)("div",{ref:y,className:G.row,"data-aia-products-row":"",children:e.map((d,c)=>(0,L.jsx)(ka,{product:d,id:`${i}-product-${c}`,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:l,soldOut:u.soldOut,addToCart:u.addToCart},d.id))})]})}function ka({product:e,id:i,onSelect:t,onAddToCart:a,onFocusChange:o,focusable:r,imageFallback:n,soldOut:l,addToCart:u}){let w=!!a&&e.available!==!1,[y,g]=(0,se.useState)(null),d=v=>{v.relatedTarget?.closest("[data-aia-dropdown]")||o?.(!1)},c=v=>{v.metaKey||v.ctrlKey||v.shiftKey||v.altKey||v.button!==0||(v.preventDefault(),t(e))};return(0,L.jsxs)("a",{id:i,className:G.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,"data-aia-product-has-cart":w?"":void 0,role:"option","aria-selected":!1,style:y?{"--aia-product-photo-fill-x":String(y.x),"--aia-product-photo-fill-y":String(y.y)}:void 0,href:e.url,tabIndex:r?0:-1,onClick:c,onKeyDown:v=>{v.key!=="Enter"&&v.key!==" "||(v.preventDefault(),t(e))},onFocus:()=>o?.(!0),onBlur:d,children:[(0,L.jsx)(Ta,{sources:(0,ue.productImageSources)(e.imageUrl),title:e.title,fallback:n,onPhotoFill:g},(0,ue.productImageSrc)(e.imageUrl)??""),(0,L.jsxs)("span",{className:G.body,children:[e.vendor?(0,L.jsx)("span",{className:G.vendor,children:e.vendor}):null,(0,L.jsx)("span",{className:G.title,children:e.title}),e.price?(0,L.jsx)("span",{className:G.price,children:e.price}):null,e.available===!1?(0,L.jsx)("span",{className:G.badge,children:l}):null]}),w&&a?(0,L.jsx)(Ca,{product:e,label:`${u}: ${e.title}`,focusable:r,onAddToCart:a,onFocus:()=>o?.(!0),onBlur:d},Sa(e)):null]})}function Sa(e){return[e.id,e.title,e.url,e.imageUrl,e.vendor].map(i=>i??"").join("\0")}function Ca({product:e,label:i,focusable:t,onAddToCart:a,onFocus:o,onBlur:r}){let[n,l]=(0,se.useState)(null),u=(0,se.useRef)(null),w=(0,se.useRef)(e);w.current=e;let y=(0,se.useRef)(!0);(0,se.useEffect)(()=>(y.current=!0,()=>{y.current=!1}),[]);let g=c=>{u.current=c,y.current&&l(c)},d=c=>{if(c.preventDefault(),c.stopPropagation(),u.current==="adding")return;g("adding");let v;try{v=Promise.resolve(a(w.current))}catch(R){v=Promise.reject(R)}v.then(()=>g("added"),()=>g(null))};return(0,L.jsx)("span",{className:G.cart,"data-aia-product-cart":"","data-aia-cart-state":n??void 0,"aria-busy":n==="adding"?!0:void 0,role:"button","aria-label":i,tabIndex:t?0:-1,onClick:d,onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||d(c)},onFocus:c=>{c.stopPropagation(),o()},onBlur:c=>{c.stopPropagation(),r(c)},children:(0,L.jsxs)("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[(0,L.jsx)("path",{className:G.cartGlyph,d:"M2 3h2.2l2.4 11.2a2 2 0 0 0 2 1.6h8.9a2 2 0 0 0 1.9-1.5L21 8H6"}),(0,L.jsx)("path",{className:G.cartGlyph,d:"M13.5 6.5v-4M11.5 4.5h4"}),(0,L.jsx)("path",{className:G.cartCheck,d:"M5 12.5l4.5 4.5L19 7.5"}),(0,L.jsx)("path",{className:G.cartSpinner,d:"M12 4a8 8 0 1 0 8 8"}),(0,L.jsx)("circle",{className:G.cartGlyph,cx:"9",cy:"20",r:"1.3"}),(0,L.jsx)("circle",{className:G.cartGlyph,cx:"17.5",cy:"20",r:"1.3"})]})})}function Ta({sources:e,title:i,fallback:t,onPhotoFill:a}){let[o,r]=(0,se.useState)(0),n=e[o],l=!!n,[u,w]=(0,se.useState)(null),y=!l&&t==="initial";return(0,se.useEffect)(()=>()=>a(null),[a]),(0,L.jsxs)("span",{className:G.media,"aria-hidden":"true","data-aia-product-placeholder":!l&&!y?"":void 0,"data-aia-product-initial":y?"":void 0,"data-aia-image-loaded":l&&u===n?"":void 0,children:[l?(0,L.jsx)("img",{className:G.image,src:n,alt:"",loading:"lazy",decoding:"async",onLoad:g=>{w(n),a((0,ue.productPhotoFill)(g.currentTarget.naturalWidth,g.currentTarget.naturalHeight))},onError:()=>{o+1>=e.length&&a(null),r(g=>g+1)}}):null,y?(0,ue.productInitial)(i):null]})}var Y=require("@magicx-eng/ai-autocomplete-vanilla"),Ie=require("react");var qt=require("@magicx-eng/ai-autocomplete-vanilla"),bt=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
2090
2150
|
display: grid;
|
|
2091
2151
|
grid-template-columns: repeat(
|
|
2092
2152
|
auto-fit,
|
|
@@ -2122,7 +2182,7 @@
|
|
|
2122
2182
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
2123
2183
|
display: none;
|
|
2124
2184
|
}
|
|
2125
|
-
`,document.head.appendChild(e)}var
|
|
2185
|
+
`,document.head.appendChild(e)}var Ut=require("react/jsx-runtime");function _t({min:e="16rem",max:i,gap:t,scroll:a=!1,maxHeight:o,scrollResetKey:r,cols:n,template:l,innerRef:u,className:w,children:y,...g}){let d=(0,bt.useRef)(null);(0,bt.useLayoutEffect)(()=>{if(r===void 0)return;let v=d.current;v&&(v.scrollTop=0)},[r]);let c={"--aia-grid-min":e};return i&&(c["--aia-grid-max"]=i),t&&(c["--aia-grid-gap"]=t),o&&(c["--aia-grid-max-height"]=o),n&&(c.gridTemplateColumns=(0,qt.optionsGridTemplateColumns)(n)),l&&(c.gridTemplateColumns=l),(0,Ut.jsx)("div",{ref:v=>{d.current=v,u?.(v)},className:w?`aia-grid ${w}`:"aia-grid","data-scroll":a||void 0,style:c,...g,children:y})}var de=require("@magicx-eng/ai-autocomplete-vanilla"),ve=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.aia-item-d4vpD {
|
|
2126
2186
|
position: relative;
|
|
2127
2187
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
2128
2188
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2580,7 +2640,163 @@
|
|
|
2580
2640
|
opacity: 0;
|
|
2581
2641
|
}
|
|
2582
2642
|
}
|
|
2583
|
-
|
|
2643
|
+
|
|
2644
|
+
.aia-content-T-Qba:has(.aia-checkbox-KGRhg) {
|
|
2645
|
+
display: flex;
|
|
2646
|
+
align-items: center;
|
|
2647
|
+
gap: 10px;
|
|
2648
|
+
}
|
|
2649
|
+
|
|
2650
|
+
.aia-checkbox-KGRhg {
|
|
2651
|
+
display: inline-flex;
|
|
2652
|
+
align-items: center;
|
|
2653
|
+
justify-content: center;
|
|
2654
|
+
flex: 0 0 18px;
|
|
2655
|
+
width: 18px;
|
|
2656
|
+
height: 18px;
|
|
2657
|
+
border: 1px solid var(--aia-border);
|
|
2658
|
+
border-radius: 6px;
|
|
2659
|
+
background: var(--aia-surface);
|
|
2660
|
+
color: transparent;
|
|
2661
|
+
font-size: 11px;
|
|
2662
|
+
line-height: 1;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
.aia-checkbox-KGRhg[data-checked="true"] {
|
|
2666
|
+
background: rgba(var(--aia-streak-rgb, 99, 102, 241), 0.16);
|
|
2667
|
+
border-color: rgba(var(--aia-streak-rgb, 99, 102, 241), 0.45);
|
|
2668
|
+
color: rgb(var(--aia-streak-rgb, 99, 102, 241));
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
.aia-item-d4vpD:has(.aia-checkbox-KGRhg[data-checked="true"]) {
|
|
2672
|
+
background: var(--aia-option-bg, transparent);
|
|
2673
|
+
}
|
|
2674
|
+
`,document.head.appendChild(e)}var Z={item:"aia-item-d4vpD",content:"aia-content-T-Qba",riseIn:"aia-riseIn-etXZT",fadeIn:"aia-fadeIn-I8u35",tappable:"aia-tappable-70KcX",nonTappable:"aia-nonTappable-xSZM-",highlighted:"aia-highlighted-Hb0SU",tag:"aia-tag-e3Fwe",pressed:"aia-pressed-98o-r",pressCompress:"aia-pressCompress-ICV3q",scrollHint:"aia-scrollHint-xKXPt",skeletonPulse:"aia-skeletonPulse-plvdD",text:"aia-text-yqoh9",skeletonBarIn:"aia-skeletonBarIn-ZlEM0",parameter:"aia-parameter-Dt2zF",match:"aia-match-pp-9v",icon:"aia-icon-Qw938",count:"aia-count-IpYbQ",image:"aia-image-YZAbO",skeletonOut:"aia-skeletonOut-x6NRd",checkbox:"aia-checkbox-KGRhg"};var X=require("react/jsx-runtime");function Vt({option:e,isHighlighted:i,checked:t,onSelect:a,onHighlight:o,onUnhighlight:r,id:n,loading:l,showIcon:u=!0,showImage:w=!0,showCount:y=!0,scrollHint:g,enterDelayMs:d=0}){let[c]=(0,ve.useState)(d),[v,R]=(0,ve.useState)(!1),ie=w?(0,de.optionImageSources)(e.image_url):[],_=ie[0]??null,[Q,te]=(0,ve.useState)([]),A=ie.find(O=>!Q.includes(O))??null,[M,C]=(0,ve.useState)(null),oe=(0,ve.useMemo)(()=>!_&&u&&e.icon_svg?(0,de.sanitizeOptionIconSvg)(e.icon_svg):null,[_,u,e.icon_svg]),U=y?(0,de.formatOptionCount)(e.item_count):null,V=(0,ve.useRef)(void 0);(0,ve.useEffect)(()=>()=>clearTimeout(V.current),[]);let ce=()=>{l||!e.is_tappable||v&&t===void 0||(R(!0),a(e),clearTimeout(V.current),V.current=setTimeout(()=>R(!1),170))},ge=[Z.item,i&&!l?Z.highlighted:"",e.is_tappable?Z.tappable:Z.nonTappable,v?Z.pressed:"",g?Z.scrollHint:""].filter(Boolean).join(" ");return(0,X.jsx)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"data-aia-icon":oe&&e.icon?e.icon:void 0,"data-aia-image":_?"":void 0,"data-aia-item-count":U!==null?e.item_count:void 0,"aria-selected":t??i,className:ge,style:{[de.OPTION_ENTER_DELAY_VAR]:`${c}ms`},tabIndex:l||!e.is_tappable?-1:0,onClick:ce,onKeyDown:O=>{!l&&e.is_tappable&&(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),ce())},onMouseEnter:!l&&e.is_tappable?o:void 0,onMouseLeave:r,children:(0,X.jsxs)("span",{className:Z.content,children:[t!==void 0&&(0,X.jsx)("span",{className:Z.checkbox,"aria-hidden":"true","data-checked":t,children:t?"\u2713":""}),_&&(0,X.jsx)("span",{className:`${Z.image} magicx-aia-option-image`,"aria-hidden":"true","data-aia-image-loaded":A!==null&&M===A?"":void 0,children:(0,X.jsx)("img",{src:A??_,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:A===null,onLoad:()=>C(A),onError:()=>{A!==null&&te(O=>[...O,A])}})}),oe&&(0,X.jsx)("span",{className:`${Z.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:oe}}),(0,X.jsxs)("span",{className:Z.text,children:[e.matchedText?(0,de.highlightParts)((0,de.optionLabel)(e),e.matchedText).map((O,fe)=>O.bold?(0,X.jsx)("strong",{className:`${Z.match} magicx-aia-option-match`,children:O.text},fe):O.text):(0,de.optionLabel)(e),e.parameterLabel&&(0,X.jsxs)(X.Fragment,{children:[" ",(0,X.jsx)("span",{className:`${Z.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&(0,X.jsx)("span",{className:Z.tag,children:e.tag}),U!==null&&(0,X.jsx)("span",{className:`${Z.count} magicx-aia-option-count`,children:U})]})})}var At=require("react/jsx-runtime");function Pa(){let[e,i]=(0,Ie.useState)(Y.isOptionsGridMobileViewport);return(0,Ie.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(Y.OPTIONS_GRID_MOBILE_QUERY),a=()=>i(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function Yt({options:e,activeIndex:i,picked:t,onSelect:a,onHighlight:o,onUnhighlight:r,listboxId:n,loading:l,groupKey:u="",optionsPosition:w="below",showIcons:y=!0,showImages:g=!0,showCounts:d=!0}){let c=Pa(),v=(0,Ie.useRef)(null),[R,ie]=(0,Ie.useState)(null),_=(0,Ie.useRef)(null);(0,Ie.useLayoutEffect)(()=>{if(l&&(0,Y.sameOptionRows)(_.current,e))return;_.current=l?null:e;let A=v.current,C=A&&!l&&(0,Y.needsOptionsGridMeasurement)(e.length,c)?(0,Y.measureOptionsGrid)(A):null;ie(C?(0,Y.planOptionsGrid)(e.length,c,C.rowWidths,C.gridWidth):null)},[e,c,l]);let Q=R??(0,Y.planOptionsGrid)(e.length,c,null,null),te=(0,Y.optionsShowLeadingVisuals)(e,y,g);return(0,At.jsx)(_t,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:u,template:Q.template,maxHeight:Q.maxHeight,innerRef:A=>{v.current=A},"data-aia-group":u,children:e.map((A,M)=>(0,At.jsx)(Vt,{option:A,isHighlighted:M===i,checked:t?t.includes(A.text):void 0,onSelect:a,onHighlight:()=>o(M),onUnhighlight:r?()=>r(M):void 0,id:`${n}-option-${M}`,loading:l,showIcon:y&&te,showImage:g&&te,showCount:d,scrollHint:!l&&Q.scrollHintIndices.includes(M),enterDelayMs:l?0:(0,Y.optionEnterDelayMs)(M,Q.cols,e.length,w)},`${u}\0${A.text}`))})}var J=require("@magicx-eng/ai-autocomplete-vanilla"),ye=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-52a922cb")){let e=document.createElement("style");e.id="ac-style-52a922cb",e.textContent=`/* --- Time wheel (replaces the options grid for time suggestions) ---
|
|
2675
|
+
|
|
2676
|
+
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
2677
|
+
time-wheel.component.css). Only the class-naming layer differs \u2014 the
|
|
2678
|
+
declarations must match, and \`timeWheelParity.test.ts\` fails the build if
|
|
2679
|
+
they drift. See CLAUDE.md's duplicated-stylesheet rule.
|
|
2680
|
+
|
|
2681
|
+
Colours go through the same --aia-option-* chain as the option rows and the
|
|
2682
|
+
calendar (see DateGrid.module.css for why). The 30px row height is
|
|
2683
|
+
load-bearing: the component turns a column's scroll offset into a row as
|
|
2684
|
+
\`scrollTop / 30\` (TIME_WHEEL_ROW_HEIGHT in the core), so it is not a token. */
|
|
2685
|
+
.aia-timeWheel-KdR4A {
|
|
2686
|
+
display: flex;
|
|
2687
|
+
flex-direction: column;
|
|
2688
|
+
align-items: center;
|
|
2689
|
+
gap: 8px;
|
|
2690
|
+
padding: 6px 6px 4px;
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
/* Announces the time to AT (the wheels themselves are aria-hidden). */
|
|
2694
|
+
.aia-value--wqvm {
|
|
2695
|
+
position: absolute;
|
|
2696
|
+
width: 1px;
|
|
2697
|
+
height: 1px;
|
|
2698
|
+
overflow: hidden;
|
|
2699
|
+
clip-path: inset(50%);
|
|
2700
|
+
white-space: nowrap;
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
.aia-columns-TaD-f {
|
|
2704
|
+
position: relative;
|
|
2705
|
+
display: flex;
|
|
2706
|
+
align-items: flex-start;
|
|
2707
|
+
justify-content: center;
|
|
2708
|
+
gap: 2px;
|
|
2709
|
+
width: 100%;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
/* The one soft band the chosen time sits in, behind the wheels' top rows. */
|
|
2713
|
+
.aia-band-pVy-f {
|
|
2714
|
+
position: absolute;
|
|
2715
|
+
top: 0;
|
|
2716
|
+
right: 0;
|
|
2717
|
+
left: 0;
|
|
2718
|
+
height: 30px;
|
|
2719
|
+
border-radius: 8px;
|
|
2720
|
+
background: var(--aia-time-band-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.08));
|
|
2721
|
+
pointer-events: none;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
.aia-column-lwtdd {
|
|
2725
|
+
position: relative;
|
|
2726
|
+
flex: 0 0 auto;
|
|
2727
|
+
width: 44px;
|
|
2728
|
+
/* Three rows show: the chosen one and the two after it. The bottom padding
|
|
2729
|
+
lets the last row scroll up to the top; border-box keeps it inside those
|
|
2730
|
+
90px, where it only adds scroll range, rather than adding 60px of visible
|
|
2731
|
+
column below them. */
|
|
2732
|
+
height: 90px;
|
|
2733
|
+
padding-bottom: 60px;
|
|
2734
|
+
box-sizing: border-box;
|
|
2735
|
+
overflow-y: auto;
|
|
2736
|
+
overscroll-behavior: contain;
|
|
2737
|
+
scroll-snap-type: y mandatory;
|
|
2738
|
+
scrollbar-width: none;
|
|
2739
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 34%, transparent 100%);
|
|
2740
|
+
mask-image: linear-gradient(to bottom, #000 34%, transparent 100%);
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
.aia-column-lwtdd::-webkit-scrollbar {
|
|
2744
|
+
display: none;
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2747
|
+
.aia-row-A3pAx {
|
|
2748
|
+
display: flex;
|
|
2749
|
+
align-items: center;
|
|
2750
|
+
justify-content: center;
|
|
2751
|
+
height: 30px;
|
|
2752
|
+
scroll-snap-align: start;
|
|
2753
|
+
font-family: inherit;
|
|
2754
|
+
font-size: var(--aia-time-font-size, 15px);
|
|
2755
|
+
font-variant-numeric: tabular-nums;
|
|
2756
|
+
font-weight: 450;
|
|
2757
|
+
line-height: 20px;
|
|
2758
|
+
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
2759
|
+
cursor: pointer;
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
.aia-selected-xgOWY {
|
|
2763
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
2764
|
+
font-weight: 500;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
.aia-separator-kX9WO {
|
|
2768
|
+
display: flex;
|
|
2769
|
+
align-items: center;
|
|
2770
|
+
height: 30px;
|
|
2771
|
+
font-size: var(--aia-time-font-size, 15px);
|
|
2772
|
+
font-weight: 500;
|
|
2773
|
+
line-height: 20px;
|
|
2774
|
+
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2777
|
+
.aia-done-llNY5 {
|
|
2778
|
+
align-self: stretch;
|
|
2779
|
+
height: 32px;
|
|
2780
|
+
padding: 0 12px;
|
|
2781
|
+
border: none;
|
|
2782
|
+
border-radius: 8px;
|
|
2783
|
+
background: var(--aia-time-done-bg, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.1));
|
|
2784
|
+
font-family: inherit;
|
|
2785
|
+
font-size: 13px;
|
|
2786
|
+
font-weight: 500;
|
|
2787
|
+
line-height: 20px;
|
|
2788
|
+
color: var(
|
|
2789
|
+
--aia-time-done-color,
|
|
2790
|
+
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
2791
|
+
);
|
|
2792
|
+
cursor: pointer;
|
|
2793
|
+
transition: background-color 150ms ease-out;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
.aia-done-llNY5:hover {
|
|
2797
|
+
background: var(--aia-time-done-bg-hover, rgba(var(--aia-streak-rgb, 255, 255, 255), 0.16));
|
|
2798
|
+
}
|
|
2799
|
+
`,document.head.appendChild(e)}var xe={timeWheel:"aia-timeWheel-KdR4A",value:"aia-value--wqvm",columns:"aia-columns-TaD-f",band:"aia-band-pVy-f",column:"aia-column-lwtdd",row:"aia-row-A3pAx",selected:"aia-selected-xgOWY",separator:"aia-separator-kX9WO",done:"aia-done-llNY5"};var me=require("react/jsx-runtime"),Ia=120;function jt({view:e,label:i,doneLabel:t,interactive:a=!0,onTimeChange:o,onTimeCommit:r}){return(0,me.jsxs)("div",{className:xe.timeWheel,"data-aia-time-wheel":"",role:"group","aria-label":i,onMouseDown:n=>n.preventDefault(),children:[(0,me.jsx)("span",{className:xe.value,"data-aia-time-value":"","aria-live":"polite",children:(0,J.formatTime)(e.minutes)}),(0,me.jsxs)("div",{className:xe.columns,"aria-hidden":"true",children:[(0,me.jsx)("div",{className:xe.band}),J.TIME_WHEEL_COLUMNS.map(n=>(0,me.jsxs)(ye.Fragment,{children:[n==="minute"&&(0,me.jsx)("span",{className:xe.separator,children:":"}),(0,me.jsx)(Ea,{column:n,minutes:e.minutes,interactive:a,onTimeChange:o})]},n))]}),(0,me.jsx)("button",{type:"button",tabIndex:-1,className:xe.done,"data-aia-time-done":"",onClick:()=>{a&&r()},children:t})]})}function Ea({column:e,minutes:i,interactive:t,onTimeChange:a}){let o=(0,ye.useRef)(null),r=(0,ye.useRef)(null),n=(0,ye.useRef)(null),l=(0,ye.useRef)({minutes:i,interactive:t,onTimeChange:a});l.current={minutes:i,interactive:t,onTimeChange:a};let u=(0,J.timeWheelIndex)(e,i);(0,ye.useLayoutEffect)(()=>{let g=o.current;if(!g||n.current)return;let d=u*J.TIME_WHEEL_ROW_HEIGHT;Math.abs(g.scrollTop-d)<1||(r.current=d,g.scrollTop=d)},[u]),(0,ye.useEffect)(()=>()=>{n.current&&clearTimeout(n.current)},[]);let w=()=>{n.current=null;let g=o.current,d=l.current;if(!g||!d.interactive)return;let c=(0,J.timeWheelIndexFromScroll)(e,g.scrollTop);c!==(0,J.timeWheelIndex)(e,d.minutes)&&d.onTimeChange((0,J.withTimeWheelIndex)(e,d.minutes,c))},y=()=>{let g=o.current;if(g){if(r.current!=null&&Math.abs(g.scrollTop-r.current)<1){r.current=null;return}r.current=null,n.current&&clearTimeout(n.current),n.current=setTimeout(w,Ia)}};return(0,me.jsx)("div",{ref:o,className:xe.column,"data-aia-time-column":e,onScroll:y,children:(0,J.timeWheelRows)(e).map((g,d)=>(0,me.jsx)("div",{className:d===u?`${xe.row} ${xe.selected}`:xe.row,"data-aia-time-row":"","data-aia-index":d,onClick:()=>{l.current.interactive&&a((0,J.withTimeWheelIndex)(e,l.current.minutes,d))},children:g.label},g.label))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2584
2800
|
display: flex;
|
|
2585
2801
|
flex-direction: column;
|
|
2586
2802
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2595,7 +2811,7 @@
|
|
|
2595
2811
|
align-items: end;
|
|
2596
2812
|
}
|
|
2597
2813
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2598
|
-
`,document.head.appendChild(e)}var
|
|
2814
|
+
`,document.head.appendChild(e)}var $t=require("react/jsx-runtime");function Qt({space:e,align:i="stretch",className:t,children:a,...o}){let r=e?{"--aia-stack-space":e}:void 0;return(0,$t.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":i,style:r,...o,children:a})}var H=require("react/jsx-runtime"),Aa=[159,119,164],Ra=()=>{},Zt=()=>{},Oa=e=>{},Da=()=>{};function La(e){let i=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=(0,ee.useState)(i);if((0,ee.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let o=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>a(o.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Ma(e,i){let t=(0,ee.useRef)(null);(0,ee.useEffect)(()=>{let a=e.current,o=i.current;if(!a||!o)return;let r=a.querySelector(".aia-grid[data-scroll]");if(t.current&&t.current.grid!==r&&(t.current.controller.destroy(),t.current=null),r&&!t.current){t.current={grid:r,controller:(0,le.attachScrollArrow)({dropdown:a,grid:r,button:o})};return}t.current?.controller.update()}),(0,ee.useEffect)(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function za(e,i){let t=(0,ee.useRef)(i);t.current=i;let a=(0,ee.useRef)(null);(0,ee.useEffect)(()=>{let o=e.current;if(o){if(!a.current){a.current=(0,le.attachViewportFit)({dropdown:o,isOpen:()=>t.current});return}a.current.update()}}),(0,ee.useEffect)(()=>()=>{a.current?.destroy(),a.current=null},[])}function wt({suggestions:e,activeIndex:i,onSelect:t,onHighlight:a,onUnhighlight:o,isOpen:r,id:n,className:l,pills:u,onPillClick:w,showPills:y=!0,onSkip:g,showSkipButton:d=!0,showOptionIcons:c=!0,showOptionImages:v=!0,showOptionCounts:R=!0,skipDisabled:ie=!1,activeSelected:_=!1,isLoading:Q=!1,skeletonExiting:te=!1,isInputEmpty:A=!1,language:M,products:C,onProductSelect:oe,onProductAddToCart:U,onProductFocusChange:V,productsLayout:ce="row",productImageFallback:ge="image",formatType:O="options",dateView:fe=null,selectedDateIso:Le=null,selectedDateRange:Ee=null,dateRangeStart:je=null,onPreviousMonth:Me,onNextMonth:f,timeView:ze=null,multiSelectView:Ne=null,onMultiSelectCommit:He,onTimeChange:Fe,onTimeCommit:Be,optionsPosition:m="below",mode:k}){let S=La(k),I=S!==void 0,T=(0,ee.useRef)(null),F=(0,ee.useRef)(null);Ma(T,F),(0,ee.useEffect)(()=>{if(T.current)return(0,le.containScroll)(T.current)},[]);let pe=e[0]?.options??[],ae=!!(u&&u.length>0&&w),We=!!(C&&C.length>0),Qe=O==="time"&&ze!=null,Se=r&&(pe.length>0||y&&ae||Q||We||Qe);za(T,Se);let Ae={suggestions:e,activeIndex:i,pills:u,showPills:y,showSkipButton:d,showOptionIcons:c,showOptionImages:v,showOptionCounts:R,skipDisabled:ie,activeSelected:_,isLoading:Q,skeletonExiting:te,isInputEmpty:A,products:C,formatType:O,dateView:fe,selectedDateIso:Le,selectedDateRange:Ee,dateRangeStart:je,timeView:ze,multiSelectView:Ne},Ge=(0,ee.useRef)(Ae);Se&&(Ge.current=Ae);let h=Se?Ae:Ge.current,$=(0,le.uiStringsFor)(M),he=h.suggestions[0],be=he?.options??[],$e=h.activeIndex>=0&&!!be[h.activeIndex]?.is_tappable,x=(0,le.labelTraditionalAutocomplete)(h.pills??[],$.keepTyping),Ze=!!(x.length>0&&w),it=h.showPills&&Ze,Re=h.showPills&&!Ze&&h.isLoading,b=it||Re,Ke=Ze&&(0,le.hasSkippablePill)(x)&&h.showSkipButton&&!h.isInputEmpty&&!!g,et=x[0]?.text,qe=(0,le.isCalendarFormat)(h.formatType)&&h.dateView!=null,tt=be.length>0&&!qe,at=be.length>0&&qe&&!h.isLoading,Oe=h.formatType==="time"&&h.timeView!=null&&!h.isLoading,ot=h.isLoading&&!tt&&!at&&!Oe,we=h.products??[];return(0,H.jsxs)("div",{ref:T,id:n,role:"listbox","aria-multiselectable":!!h.multiSelectView,"data-aia-dropdown":"","data-options-position":m,"data-mode":S,"data-aia-loading":h.isLoading?"":void 0,"data-aia-skeleton-exiting":h.skeletonExiting?"":void 0,"data-aia-has-products":we.length>0?"":void 0,className:`${I?"magicx-aia ":""}${Ce.dropdown} ${Se?Ce.visible:""} ${l??""}`,onMouseDown:B=>B.preventDefault(),children:[(0,H.jsxs)(Qt,{space:"8px",children:[(b||Ke)&&(0,H.jsxs)(lt,{noWrap:!0,className:Ce.pillBar,"data-aia-pillbar":"",children:[b&&(0,H.jsx)("span",{className:Ce.pillScroll,"data-aia-pill-scroll":"",children:(0,H.jsx)(ft,{pills:x,activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:h.isLoading})}),Ke&&(0,H.jsx)("button",{type:"button",tabIndex:-1,className:Ce.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":et?`${$.skipLabel} ${et}`:$.skipLabel,onClick:g,children:$.skip})]}),tt&&(0,H.jsx)(Yt,{options:be,activeIndex:h.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:n,loading:h.isLoading,groupKey:he?`${he.parameter} ${he.text}`:"",optionsPosition:m,showIcons:h.showOptionIcons,showImages:h.showOptionImages,showCounts:h.showOptionCounts,picked:h.isLoading?void 0:h.multiSelectView?.picked}),h.multiSelectView&&!h.isLoading&&(0,H.jsx)("div",{onClick:B=>{B.target.closest("[data-aia-multi-done]")&&!h.skipDisabled&&He?.()},children:(0,H.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"data-aia-multi-done":"",className:Ce.multiDone,ref:B=>{B&&(B.disabled=!0,B.offsetHeight,B.disabled=h.skipDisabled)},children:$.done})}),at&&h.dateView&&(0,H.jsx)(Ht,{options:be,activeIndex:h.activeIndex,listboxId:n,view:h.dateView,selection:{selectedIso:h.selectedDateIso??null,selectedRange:h.selectedDateRange??null,rangeStart:h.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:o,onPreviousMonth:Me??Zt,onNextMonth:f??Zt}),Oe&&h.timeView&&(0,H.jsx)(jt,{view:h.timeView,label:$.timeLabel,doneLabel:$.done,interactive:!h.skipDisabled,onTimeChange:Fe??Oa,onTimeCommit:Be??Da}),ot&&(0,H.jsx)("div",{className:Ce.skeletonBars,"data-aia-skeleton-bars":"",children:Aa.map(B=>(0,H.jsx)("span",{className:Ce.skeletonBar,style:{width:B}},`bar-${B}`))}),(0,H.jsx)(Kt,{products:we,listboxId:n,onSelect:oe??Ra,onAddToCart:U,onFocusChange:V,focusable:Se,layout:ce,imageFallback:ge,strings:$}),(0,H.jsx)(Ft,{isOptionHighlighted:$e,isInputEmpty:h.isInputEmpty,strings:$})]}),(0,H.jsx)("button",{ref:F,type:"button",tabIndex:-1,className:Ce.scrollArrow,"data-aia-scroll-arrow":"","aria-label":$.scrollArrow,"aria-hidden":"true",children:(0,H.jsx)("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:(0,H.jsx)("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}var Ye=require("@magicx-eng/ai-autocomplete-vanilla");var Jt=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=`.aia-submitButton-otz7H {
|
|
2599
2815
|
flex-shrink: 0;
|
|
2600
2816
|
width: 32px;
|
|
2601
2817
|
height: 32px;
|
|
@@ -2648,5 +2864,5 @@
|
|
|
2648
2864
|
);
|
|
2649
2865
|
cursor: default;
|
|
2650
2866
|
}
|
|
2651
|
-
`,document.head.appendChild(e)}var Vt={submitButton:"aia-submitButton-otz7H"};var ht=require("react/jsx-runtime");function Qt({disabled:e,onClick:i,label:t=(0,Yt.uiStringsFor)().submit}){return(0,ht.jsx)("button",{type:"button","data-aia-submit":"",className:Vt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":t,children:(0,ht.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,ht.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ge=require("@magicx-eng/ai-autocomplete-vanilla"),T=require("react");var Tt=require("react");function $t(e){let i=(0,Tt.useRef)(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=(0,Tt.useRef)({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(h,m,g)=>{let w=i.current?.[r];return w?w(h,m,g):[]};o[r]=n}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}var It=require("react");function Zt(e){let i=(0,It.useRef)(e);i.current=e;let t=(0,It.useRef)(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=i.current;return n?n.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Xt={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,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,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null};function ut({onSubmit:e,onResult:i,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:n,language:h,currency:m,productId:g,visitorId:w,columns:C=2,dropdownTrigger:d,optionsPosition:v,closeDropdownOnBlur:l,showNonTappableOptions:A,showOptionIcons:M,showOptionImages:$,showOptionCounts:ee,showSkipButton:R,showProducts:N,productImageFallback:K="image",onFocus:P,onBlur:te,value:U,completedParams:Y,onChange:pe,onParamsChange:z,products:ae,mapProducts:ke,onProductSelect:Ee,onProductAddToCart:Ce,source:qe,setCursor:Ae}){let f=(0,T.useRef)(null),[Re,De]=(0,T.useState)(null),Se=(0,T.useRef)(e);Se.current=e;let Oe=(0,T.useRef)(i);Oe.current=i;let de=(0,T.useRef)(t);de.current=t;let c=(0,T.useRef)(pe);c.current=pe;let x=(0,T.useRef)(z);x.current=z;let k=(0,T.useRef)(P);k.current=P;let I=(0,T.useRef)(te);I.current=te;let S=(0,T.useRef)(Ae);S.current=Ae;let F=(0,T.useRef)(Ee);F.current=Ee;let se=(0,T.useRef)(Ce);se.current=Ce;let u=(0,T.useRef)(w);u.current=w;let ie=(0,T.useRef)(()=>{let p=u.current;return typeof p=="function"?p():p}).current,me=Zt(ae),ge=(0,T.useRef)(ke);ge.current=ke;let We=(0,T.useRef)((p,q)=>{let D=ge.current;return D?D(p,q):p}).current,fe=ke?We:void 0,be=$t(a);(0,T.useEffect)(()=>{if(typeof document>"u")return;let p=new Ge.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:h,currency:m,productId:g,visitorId:ie,optionOverrides:be.overrides,maskCompletedText:o,columns:C,dropdownTrigger:d,optionsPosition:v,closeDropdownOnBlur:l,showNonTappableOptions:A,showProducts:N,source:qe,value:U,completedParams:Y,onSubmit:(...D)=>Se.current?.(...D),onResult:(...D)=>Oe.current?.(...D),onError:(...D)=>de.current?.(...D),onChange:(...D)=>c.current?.(...D),onParamsChange:(...D)=>x.current?.(...D),onFocus:()=>k.current?.(),onBlur:()=>I.current?.(),onProductSelect:D=>F.current?.(D),onProductAddToCart:D=>se.current?.(D),setCursor:D=>S.current?.(D),products:me.config,mapProducts:fe});f.current=p,De(p.getState());let q=p.subscribe(D=>De(D));return()=>{q(),p.destroy(),f.current===p&&(f.current=null)}},[]),(0,T.useEffect)(()=>{U!==void 0&&f.current?.setValue(U)},[U]),(0,T.useEffect)(()=>{Y!==void 0&&f.current?.setCompletedParams(Y)},[Y]);let Ue=JSON.stringify(r??null),Pe;try{Pe=JSON.stringify(n??null)}catch{Pe="[unstringifiable]"}(0,T.useEffect)(()=>{f.current?.update({apiConfig:r,additionalContext:n,language:h,currency:m,productId:g,optionOverrides:be.overrides,dropdownTrigger:d,optionsPosition:v,closeDropdownOnBlur:l,showNonTappableOptions:A,showProducts:N})},[Ue,Pe,h,m?.code,m?.rate,m?.country,g,be.key,d,v,l,A,N]);let Le=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!Le.current){Le.current=!0;return}f.current?.update({products:me.config})},[me.enabled]),(0,T.useEffect)(()=>{f.current?.update({mapProducts:fe})},[fe]);let ze=(0,T.useRef)(null);ze.current===null&&(ze.current={handleTextChange:p=>f.current?.handleTextChange(p),handleKeyDown:p=>{let q="nativeEvent"in p?p.nativeEvent:p;f.current?.handleKeyDown(q)},setFocused:p=>f.current?.setFocused(p),startEditingParam:p=>f.current?.startEditingParam(p),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:p=>f.current?.handleCaretAfterInput(p),handleCaretMove:p=>f.current?.handleCaretMove(p),replaceEditingRange:p=>f.current?.replaceEditingRange(p)??!1,setActivePill:p=>f.current?.setActivePill(p),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??Xt,recordSubmit:p=>f.current?.recordSubmit(p),selectOption:p=>f.current?.selectOption(p),selectProduct:p=>f.current?.selectProduct(p),addProductToCart:p=>{let q=f.current;return!q||!se.current?Promise.resolve():q.addProductToCart(p)},setActiveDropdownIndex:p=>f.current?.setActiveDropdownIndex(p),clearHighlight:p=>f.current?.clearHighlight(p),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let y=ze.current,Ye=(0,T.useCallback)(p=>{let q=p.target.value,ot=q.length>0&&!p.nativeEvent?.isComposing&&q[0]!==q[0].toUpperCase()?q[0].toUpperCase()+q.slice(1):q;f.current?.handleTextChange(ot)},[]),Qe=(0,T.useCallback)(p=>{f.current?.handleKeyDown(p.nativeEvent)},[]),we=f.current,b=Re??Xt,Me=U!==void 0?U:b.text,Ne=Y!==void 0?Y:b.completedParams,Ze=b.actionableSuggestions,gt=Ze[0],ft=(0,Ge.withoutTraditionalAutocomplete)(Ze),$e=we?.listboxId??"",bt=b.activeDropdownIndex>=0&&we?`${$e}-option-${b.activeDropdownIndex}`:void 0,Fe=b.editingParam,_e=b.editingIdentified,Xe=Fe?{parameter:Fe.suggestionParameter,text:Fe.suggestionPlaceholder,required:!0,options:Fe.options}:_e?{parameter:_e.parameter,text:(0,Ge.identifiedParamLabel)(_e.parameter),required:!0,options:[]}:null,it=b.dropdownSuggestion??Xe??gt,wt=Xe?[Xe]:Ze,Je=(0,Ge.dateSelectionFor)(b),je=!we||b.dropdownLoading;return{completedParams:Ne,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:ft,setActivePill:y.setActivePill,skipActivePill:y.skipActivePill,removeLastParam:y.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:y.clearNewParamId,suggestions:b.suggestions,activeIndex:b.activeDropdownIndex,isReady:b.isReady,isLoading:je,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:$e,error:b.error,products:b.products,customFields:b.customFields,selectProduct:y.selectProduct,addProductToCart:y.addProductToCart,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:Fe,editingIdentified:_e,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:Me,placeholder:b.placeholderText||void 0,onChange:Ye,onKeyDown:Qe,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":bt,"aria-autocomplete":"list","aria-controls":$e},reset:y.reset,refreshProducts:y.refreshProducts,prepareSubmit:y.prepareSubmit,getState:y.getState,recordSubmit:y.recordSubmit,dropdownProps:{suggestions:it?[{...it,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,onUnhighlight:y.clearHighlight,isOpen:b.isDropdownOpen,id:$e,pills:wt,activeSelected:b.isActivePillSelected,onPillClick:y.setActivePill,onSkip:y.skipActivePill,showSkipButton:(R??!0)&&!Fe&&!_e,showOptionIcons:M??!0,showOptionImages:$??!0,showOptionCounts:ee??!0,skipDisabled:b.inSelectionAnimation,isLoading:je,skeletonExiting:b.skeletonExiting,isInputEmpty:Me.trim().length===0,language:h,products:b.products,productImageFallback:K,onProductSelect:y.selectProduct,onProductAddToCart:Ce?y.addProductToCart:void 0,onProductFocusChange:y.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:Je.selectedIso,selectedDateRange:Je.selectedRange,dateRangeStart:Je.rangeStart,onPreviousMonth:y.showPreviousMonth,onNextMonth:y.showNextMonth,optionsPosition:v??"below"}}}var V=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react"),mt;function Ia(){if(mt!==void 0)return mt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),mt=e.contentEditable==="plaintext-only",mt}function Jt(e){let{segments:i,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:h,caretOffset:m,placeholderText:g,isFocused:w,isDropdownOpen:C,listboxId:d,activeDescendantId:v,autoFocus:l,handleTextChange:A,handleKeyDown:M,handleCaretAfterInput:$,handleCaretMove:ee,startEditingParam:R,replaceEditingRange:N,setFocused:K}=e,P=(0,E.useRef)(null),te=(0,E.useRef)(!1),U=(0,E.useRef)(""),Y=(0,E.useRef)(""),pe=(0,E.useRef)(null),z=(0,E.useRef)(0);pe.current=m,(0,E.useEffect)(()=>{if(!l)return;let c=P.current;if(!c)return;document.activeElement===c?K(!0):c.focus();let x=c.ownerDocument??document,k=x.getSelection(),I=k&&k.rangeCount>0&&c.contains(k.anchorNode);if(k&&!I){let S=x.createRange();S.selectNodeContents(c),S.collapse(!0),k.removeAllRanges(),k.addRange(S)}},[l,K]),(0,E.useEffect)(()=>{let c=P.current;if(!c)return;let x=c.ownerDocument??document,k=()=>{let I=x.getSelection();if(!I||I.rangeCount===0||!I.anchorNode||!c.contains(I.anchorNode))return;let S=I.anchorNode,F=S.nodeType===Node.ELEMENT_NODE?S:S.parentElement,u=(I.isCollapsed?F?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,ie=r?.id??n?.id??null;if(u&&u!==ie){R(u);return}performance.now()-z.current<50||ee((0,V.getCursorOffset)(c))};return x.addEventListener("selectionchange",k),()=>x.removeEventListener("selectionchange",k)},[r,n,R,ee]),(0,E.useEffect)(()=>{let c=P.current;if(!c)return;let x=k=>{let I=(0,V.chipIdFromTap)(c,k.target);I&&(R(I),(0,V.keepCaretOnChip)(c,I))};return c.addEventListener("click",x),()=>c.removeEventListener("click",x)},[R]),(0,E.useLayoutEffect)(()=>{let c=P.current;c&&(0,V.renderEditableContent)({input:c,segments:i,newParamId:o,editingParamId:r?.id??null,placeholderText:g??"",isFocused:w,showChipIcons:t,showChipImages:a})},[i,o,r,g,w,t,a]),(0,E.useLayoutEffect)(()=>{let c=U.current,x=o??"";if(U.current=x,!x||x===c)return;let k=P.current;if(!k)return;k.focus();let I=pe.current??(0,V.plainTextLength)(k);(0,V.setCursorOffset)(k,I)},[o]),(0,E.useLayoutEffect)(()=>{let c=Y.current,x=r?.id??"";if(Y.current=x,!x||x===c||h==null)return;let k=P.current;k&&(0,V.setCursorOffset)(k,h)},[r,h]);let ae=(0,E.useCallback)(()=>{if(te.current)return;let c=P.current;if(!c)return;let x=(0,V.extractPlainText)(c),I=x.length>0&&x[0]!==x[0].toUpperCase()?x[0].toUpperCase()+x.slice(1):x;A(I)},[A]),ke=(0,E.useCallback)(()=>{z.current=performance.now(),ae();let c=P.current;c&&$((0,V.getCursorOffset)(c))},[ae,$]);(0,E.useEffect)(()=>{let c=P.current;if(!c)return;let x=k=>{let I=k,S=I.inputType;if(S==="insertParagraph"||S==="insertLineBreak"||S==="insertFromDrop"){k.preventDefault();return}if(S.startsWith("insert")||S.startsWith("delete")){let F=S.startsWith("delete")?"":I.data??"";N(F)&&k.preventDefault()}};return c.addEventListener("beforeinput",x),()=>c.removeEventListener("beforeinput",x)},[N]);let Ee=(0,E.useCallback)(()=>{te.current=!0,P.current?.setAttribute("data-aia-composing","true")},[]),Ce=(0,E.useCallback)(()=>{te.current=!1,P.current?.removeAttribute("data-aia-composing"),ae()},[ae]),qe=(0,E.useCallback)(c=>{c.preventDefault();let x=P.current;if(!x)return;let k=(c.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!k)return;let I=x.ownerDocument??document,S=I.getSelection();if(!S||S.rangeCount===0)return;let F=S.getRangeAt(0);if(!x.contains(F.startContainer))return;F.deleteContents();let se=I.createTextNode(k);F.insertNode(se),F.setStartAfter(se),F.collapse(!0),S.removeAllRanges(),S.addRange(F),ae()},[ae]),Ae=(0,E.useCallback)(c=>M(c),[M]),f=(0,E.useCallback)(()=>K(!0),[K]),Re=(0,E.useCallback)(()=>K(!1),[K]),De=(0,E.useCallback)(()=>P.current?.focus(),[]),Se=(0,E.useCallback)(()=>P.current?.blur(),[]),Oe=(0,E.useCallback)(()=>{let c=P.current;return c?(0,V.extractPlainText)(c):""},[]),de=Ia()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:de,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":d,"aria-expanded":C,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:ke,onKeyDown:Ae,onCompositionStart:Ee,onCompositionEnd:Ce,onPaste:qe,onFocus:f,onBlur:Re},getPlainText:Oe,focus:De,blur:Se}}var ue=require("react/jsx-runtime");function Ea(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ea=(0,G.forwardRef)(function({onSubmit:i,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:h,additionalContext:m,language:g,currency:w,productId:C,visitorId:d,columns:v,pillPlacement:l="dropdown",mode:A="auto",optionsPosition:M="below",animations:$=!0,dropdownTrigger:ee,closeDropdownOnBlur:R,showNonTappableOptions:N,showOptionIcons:K=!0,showChipIcons:P=!0,showChipImages:te=!0,showOptionImages:U=!0,showOptionCounts:Y=!0,showSkipButton:pe,showProducts:z,productsLayout:ae,productImageFallback:ke,autoFocus:Ee=!0,onFocus:Ce,onBlur:qe,value:Ae,completedParams:f,onChange:Re,onParamsChange:De,products:Se,mapProducts:Oe,onProductSelect:de,onProductAddToCart:c,submitButton:x,resetOnSubmit:k=!0},I){let S=(0,G.useRef)(null),F=(0,G.useRef)(null),se=(0,G.useRef)(()=>{}),u=(0,G.useRef)(null),ie=(0,G.useRef)(null);(0,G.useEffect)(()=>{let L=S.current;if(L)return u.current?u.current.setMode(A):u.current=new Ke.ModeController(L,A),()=>{u.current?.destroy(),u.current=null}},[A]);let me=(0,G.useCallback)(L=>{let oe=ie.current?.current;oe&&(oe.focus(),(0,Ke.setCursorOffset)(oe,L))},[]),{completedParams:ge,suggestionPills:We,setActivePill:fe,skipActivePill:be,segments:Ue,newParamId:Pe,clearNewParamId:Le,placeholderText:ze,isFocused:y,isDropdownOpen:Ye,isActivePillSelected:Qe,isLoading:we,activeIndex:b,listboxId:Me,handleTextChange:Ne,handleKeyDown:Ze,setFocused:gt,editingParam:ft,editingIdentified:$e,editingAnchor:bt,caretOffset:Fe,startEditingParam:_e,handleCaretAfterInput:Xe,handleCaretMove:it,replaceEditingRange:wt,dropdownProps:Je,reset:je,refreshProducts:p,prepareSubmit:q,getState:D,recordSubmit:ot}=ut({onSubmit:L=>se.current(L),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:h,additionalContext:m,language:g,currency:w,productId:C,visitorId:d,columns:v,dropdownTrigger:ee,optionsPosition:M,closeDropdownOnBlur:R,showNonTappableOptions:N,showOptionIcons:K,showOptionImages:U,showOptionCounts:Y,showSkipButton:pe,showProducts:z,onFocus:Ce,onBlur:qe,value:Ae,completedParams:f,onChange:Re,onParamsChange:De,products:Se,mapProducts:Oe,onProductSelect:de,onProductAddToCart:c,source:"full-sdk",setCursor:me});(0,G.useEffect)(()=>{if(!Pe)return;let L=window.setTimeout(()=>Le(),650);return()=>window.clearTimeout(L)},[Pe,Le]);let ta=b>=0?`${Me}-option-${b}`:void 0,{inputRef:vt,editorProps:aa,focus:nt,blur:Et,getPlainText:At}=Jt({segments:Ue,newParamId:Pe,editingParam:ft,editingIdentified:$e,editingAnchor:bt,caretOffset:Fe,placeholderText:ze,isFocused:y,showChipIcons:P,showChipImages:te,isDropdownOpen:Ye,listboxId:Me,activeDescendantId:ta,autoFocus:Ee,handleTextChange:Ne,handleKeyDown:Ze,handleCaretAfterInput:Xe,handleCaretMove:it,startEditingParam:_e,replaceEditingRange:wt,setFocused:gt});ie.current=vt,(0,G.useLayoutEffect)(()=>{let L=F.current,oe=vt.current;if(!L||!oe)return;let et=()=>{let Dt=L.firstElementChild;if(!Dt)return;let ra=Dt.getBoundingClientRect(),sa=oe.getBoundingClientRect();ra.top>=sa.bottom-2?L.setAttribute("data-aia-pill-wrapped",""):L.removeAttribute("data-aia-pill-wrapped")};et();let Rt=new ResizeObserver(et);return Rt.observe(oe),()=>Rt.disconnect()},[Ue,We.length,we,vt]),(0,G.useImperativeHandle)(I,()=>({focus:nt,blur:Et,reset:je,refreshProducts:p,setMode:L=>u.current?.setMode(L),skipActivePill:be}),[nt,Et,je,p,be]);let rt=!!Ue.length||ge.length>0,xt=(0,G.useCallback)(L=>{if(!rt)return;L&&q();let oe=D(),et=(0,Ke.buildSubmitResult)(At(),oe.completedParams,oe.skippedParams,{identifiedParams:oe.identifiedParams,isReady:oe.isReady,customFields:oe.customFields});L&&ot(et),i(et),k&&je()},[ot,k,rt,q,D,i,je,At]);se.current=()=>xt(!1);let ia=(0,G.useCallback)(L=>{L.target?.closest("[data-aia-pill]")||nt()},[nt]),oa=l==="inline",na=l==="dropdown";return(0,ue.jsxs)("div",{ref:S,className:`magicx-aia ${Ve.container} ${n??""}`,"data-pill-placement":l,"data-options-position":M,"data-animations":$?"on":"off","data-mode":Ea(A),children:[(0,ue.jsx)(pt,{...Je,showPills:na,productsLayout:ae,productImageFallback:ke}),(0,ue.jsxs)("div",{className:Ve.inputWrapper,"data-aia-input-wrapper":"",onClick:ia,children:[(0,ue.jsxs)("div",{className:Ve.editorArea,"data-aia-editor":"",children:[(0,ue.jsx)("div",{...aa,className:Ve.input,"data-aia-input":""}),oa&&(we||We.length>0)&&(0,ue.jsx)("span",{ref:F,className:Ve.pillListContainer,"data-aia-pill-list-container":"",children:(0,ue.jsx)(dt,{pills:We,activePillIndex:0,activeSelected:Qe,onSelectPill:fe,loading:we})})]}),x===null?null:x===void 0?(0,ue.jsx)(Qt,{disabled:!rt,onClick:()=>xt(!0),label:(0,Ke.uiStringsFor)(g).submit}):(0,ue.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ve.submitSlot,onClick:L=>{rt&&(L.stopPropagation(),xt(!0))},children:x})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2867
|
+
`,document.head.appendChild(e)}var Xt={submitButton:"aia-submitButton-otz7H"};var vt=require("react/jsx-runtime");function ea({disabled:e,onClick:i,label:t=(0,Jt.uiStringsFor)().submit}){return(0,vt.jsx)("button",{type:"button","data-aia-submit":"",className:Xt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),i()},"aria-label":t,children:(0,vt.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:(0,vt.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var Ve=require("@magicx-eng/ai-autocomplete-vanilla"),P=require("react");var Rt=require("react");function ta(e){let i=(0,Rt.useRef)(e);i.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=(0,Rt.useRef)({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let n=(l,u,w)=>{let y=i.current?.[r];return y?y(l,u,w):[]};o[r]=n}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}var Ot=require("react");function aa(e){let i=(0,Ot.useRef)(e);i.current=e;let t=(0,Ot.useRef)(null);t.current===null&&(t.current={fetch:(o,r)=>{let n=i.current;return n?n.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>i.current?.transform(o)??[],get limit(){return i.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var ia={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],traditionalAutocomplete:!1,customFields:null,optionSearch:null,activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],dropdownLoading:!0,dropdownOptions:[],skeletonOptions:null,skeletonSuggestion:null,dropdownSuggestion:null,skeletonRequested:!1,skeletonExiting:!1,activeFormatType:"options",dateView:null,dateRangeStart:null,timeView:null,multiSelectView:null,multiSelectDraft:null,placeholderText:"",optionQuery:"",isSearchingOptions:!1,isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,dropdownHeld:!1,editingParam:null,editingIdentified:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,dateViewMonth:null,pendingRangeStart:null,timeDraft:null};function xt({onSubmit:e,onResult:i,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:n,language:l,currency:u,productId:w,visitorId:y,columns:g=2,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:v,showNonTappableOptions:R,showOptionIcons:ie,showOptionImages:_,showOptionCounts:Q,showSkipButton:te,showProducts:A,productImageFallback:M="image",onFocus:C,onBlur:oe,value:U,completedParams:V,onChange:ce,onParamsChange:ge,products:O,mapProducts:fe,onProductSelect:Le,onProductAddToCart:Ee,source:je,setCursor:Me}){let f=(0,P.useRef)(null),[ze,Ne]=(0,P.useState)(null),He=(0,P.useRef)(e);He.current=e;let Fe=(0,P.useRef)(i);Fe.current=i;let Be=(0,P.useRef)(t);Be.current=t;let m=(0,P.useRef)(ce);m.current=ce;let k=(0,P.useRef)(ge);k.current=ge;let S=(0,P.useRef)(C);S.current=C;let I=(0,P.useRef)(oe);I.current=oe;let T=(0,P.useRef)(Me);T.current=Me;let F=(0,P.useRef)(Le);F.current=Le;let pe=(0,P.useRef)(Ee);pe.current=Ee;let ae=(0,P.useRef)(y);ae.current=y;let We=(0,P.useRef)(()=>{let p=ae.current;return typeof p=="function"?p():p}).current,Qe=aa(O),Se=(0,P.useRef)(fe);Se.current=fe;let Ae=(0,P.useRef)((p,q)=>{let D=Se.current;return D?D(p,q):p}).current,Ge=fe?Ae:void 0,h=ta(a);(0,P.useEffect)(()=>{if(typeof document>"u")return;let p=new Ve.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:n,language:l,currency:u,productId:w,visitorId:We,optionOverrides:h.overrides,maskCompletedText:o,columns:g,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:v,showNonTappableOptions:R,showProducts:A,source:je,value:U,completedParams:V,onSubmit:(...D)=>He.current?.(...D),onResult:(...D)=>Fe.current?.(...D),onError:(...D)=>Be.current?.(...D),onChange:(...D)=>m.current?.(...D),onParamsChange:(...D)=>k.current?.(...D),onFocus:()=>S.current?.(),onBlur:()=>I.current?.(),onProductSelect:D=>F.current?.(D),onProductAddToCart:D=>pe.current?.(D),setCursor:D=>T.current?.(D),products:Qe.config,mapProducts:Ge});f.current=p,Ne(p.getState());let q=p.subscribe(D=>Ne(D));return()=>{q(),p.destroy(),f.current===p&&(f.current=null)}},[]),(0,P.useEffect)(()=>{U!==void 0&&f.current?.setValue(U)},[U]),(0,P.useEffect)(()=>{V!==void 0&&f.current?.setCompletedParams(V)},[V]);let $=JSON.stringify(r??null),he;try{he=JSON.stringify(n??null)}catch{he="[unstringifiable]"}(0,P.useEffect)(()=>{f.current?.update({apiConfig:r,additionalContext:n,language:l,currency:u,productId:w,optionOverrides:h.overrides,dropdownTrigger:d,optionsPosition:c,closeDropdownOnBlur:v,showNonTappableOptions:R,showProducts:A})},[$,he,l,u?.code,u?.rate,u?.country,w,h.key,d,c,v,R,A]);let be=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(!be.current){be.current=!0;return}f.current?.update({products:Qe.config})},[Qe.enabled]),(0,P.useEffect)(()=>{f.current?.update({mapProducts:Ge})},[Ge]);let $e=(0,P.useRef)(null);$e.current===null&&($e.current={handleTextChange:p=>f.current?.handleTextChange(p),handleKeyDown:p=>{let q="nativeEvent"in p?p.nativeEvent:p;f.current?.handleKeyDown(q)},setFocused:p=>f.current?.setFocused(p),startEditingParam:p=>f.current?.startEditingParam(p),exitEditMode:()=>f.current?.exitEditMode(),handleCaretAfterInput:p=>f.current?.handleCaretAfterInput(p),handleCaretMove:p=>f.current?.handleCaretMove(p),replaceEditingRange:p=>f.current?.replaceEditingRange(p)??!1,setActivePill:p=>f.current?.setActivePill(p),skipActivePill:()=>f.current?.skipActivePill(),removeLastParam:()=>f.current?.removeLastParam(),clearNewParamId:()=>f.current?.clearNewParamId(),reset:()=>f.current?.reset(),refreshProducts:()=>f.current?.refreshProducts(),prepareSubmit:()=>f.current?.prepareSubmit(),getState:()=>f.current?.getState()??ia,recordSubmit:p=>f.current?.recordSubmit(p),selectOption:p=>f.current?.selectOption(p),selectProduct:p=>f.current?.selectProduct(p),addProductToCart:p=>{let q=f.current;return!q||!pe.current?Promise.resolve():q.addProductToCart(p)},setActiveDropdownIndex:p=>f.current?.setActiveDropdownIndex(p),clearHighlight:p=>f.current?.clearHighlight(p),showPreviousMonth:()=>f.current?.showPreviousMonth(),showNextMonth:()=>f.current?.showNextMonth(),setTime:p=>f.current?.setTime(p),commitTime:()=>f.current?.commitTime(),toggleMultiSelectOption:p=>f.current?.toggleMultiSelectOption(p),commitMultiSelect:()=>f.current?.commitMultiSelect(),handleFocus:()=>f.current?.setFocused(!0),handleBlur:()=>f.current?.setFocused(!1)});let x=$e.current,Ze=(0,P.useCallback)(p=>{let q=p.target.value,pt=q.length>0&&!p.nativeEvent?.isComposing&&q[0]!==q[0].toUpperCase()?q[0].toUpperCase()+q.slice(1):q;f.current?.handleTextChange(pt)},[]),it=(0,P.useCallback)(p=>{f.current?.handleKeyDown(p.nativeEvent)},[]),Re=f.current,b=ze??ia,Ke=U!==void 0?U:b.text,et=V!==void 0?V:b.completedParams,qe=b.actionableSuggestions,tt=qe[0],at=(0,Ve.withoutTraditionalAutocomplete)(qe),Oe=Re?.listboxId??"",ot=b.activeDropdownIndex>=0&&Re?`${Oe}-option-${b.activeDropdownIndex}`:void 0,we=b.editingParam,B=b.editingIdentified,nt=we?{parameter:we.suggestionParameter,text:we.suggestionPlaceholder,required:!0,options:we.options}:B?{parameter:B.parameter,text:(0,Ve.identifiedParamLabel)(B.parameter),required:!0,options:[]}:null,ct=b.dropdownSuggestion??nt??tt,kt=nt?[nt]:qe,rt=(0,Ve.dateSelectionFor)(b),Xe=!Re||b.dropdownLoading;return{completedParams:et,multiSelectView:b.multiSelectView,toggleMultiSelectOption:x.toggleMultiSelectOption,commitMultiSelect:x.commitMultiSelect,skippedParams:b.skippedParams,identifiedParams:b.identifiedParams,suggestionPills:at,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:b.segments,newParamId:b.newParamId,clearNewParamId:x.clearNewParamId,suggestions:b.suggestions,activeIndex:b.activeDropdownIndex,isReady:b.isReady,isLoading:Xe,isFocused:b.isFocused,isDropdownOpen:b.isDropdownOpen,isActivePillSelected:b.isActivePillSelected,placeholderText:b.placeholderText,listboxId:Oe,error:b.error,products:b.products,customFields:b.customFields,selectProduct:x.selectProduct,addProductToCart:x.addProductToCart,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:we,editingIdentified:B,editingAnchor:b.editingAnchor,caretOffset:b.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ke,placeholder:b.placeholderText||void 0,onChange:Ze,onKeyDown:it,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":b.isDropdownOpen,"aria-activedescendant":ot,"aria-autocomplete":"list","aria-controls":Oe},reset:x.reset,refreshProducts:x.refreshProducts,prepareSubmit:x.prepareSubmit,getState:x.getState,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:ct?[{...ct,options:b.dropdownOptions}]:[],activeIndex:b.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:b.isDropdownOpen,id:Oe,pills:kt,activeSelected:b.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(te??!0)&&!we&&!B,showOptionIcons:ie??!0,showOptionImages:_??!0,showOptionCounts:Q??!0,skipDisabled:b.inSelectionAnimation,isLoading:Xe,skeletonExiting:b.skeletonExiting,isInputEmpty:Ke.trim().length===0,language:l,products:b.products,productImageFallback:M,onProductSelect:x.selectProduct,onProductAddToCart:Ee?x.addProductToCart:void 0,onProductFocusChange:x.setFocused,formatType:b.activeFormatType,dateView:b.dateView,selectedDateIso:rt.selectedIso,selectedDateRange:rt.selectedRange,dateRangeStart:rt.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,timeView:b.timeView,multiSelectView:b.multiSelectView,onMultiSelectCommit:x.commitMultiSelect,onTimeChange:x.setTime,onTimeCommit:x.commitTime,optionsPosition:c??"below"}}}var j=require("@magicx-eng/ai-autocomplete-vanilla"),E=require("react"),yt;function Na(){if(yt!==void 0)return yt;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),yt=e.contentEditable==="plaintext-only",yt}function oa(e){let{segments:i,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:n,editingAnchor:l,caretOffset:u,placeholderText:w,isFocused:y,isDropdownOpen:g,listboxId:d,activeDescendantId:c,autoFocus:v,handleTextChange:R,handleKeyDown:ie,handleCaretAfterInput:_,handleCaretMove:Q,startEditingParam:te,replaceEditingRange:A,setFocused:M}=e,C=(0,E.useRef)(null),oe=(0,E.useRef)(!1),U=(0,E.useRef)(""),V=(0,E.useRef)(""),ce=(0,E.useRef)(null),ge=(0,E.useRef)(0);ce.current=u,(0,E.useEffect)(()=>{if(!v)return;let m=C.current;if(!m)return;document.activeElement===m?M(!0):m.focus();let k=m.ownerDocument??document,S=k.getSelection(),I=S&&S.rangeCount>0&&m.contains(S.anchorNode);if(S&&!I){let T=k.createRange();T.selectNodeContents(m),T.collapse(!0),S.removeAllRanges(),S.addRange(T)}},[v,M]),(0,E.useEffect)(()=>{let m=C.current;if(!m)return;let k=m.ownerDocument??document,S=()=>{let I=k.getSelection();if(!I||I.rangeCount===0||!I.anchorNode||!m.contains(I.anchorNode))return;let T=I.anchorNode,F=T.nodeType===Node.ELEMENT_NODE?T:T.parentElement,ae=(I.isCollapsed?F?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,We=r?.id??n?.id??null;if(ae&&ae!==We){te(ae);return}performance.now()-ge.current<50||Q((0,j.getCursorOffset)(m))};return k.addEventListener("selectionchange",S),()=>k.removeEventListener("selectionchange",S)},[r,n,te,Q]),(0,E.useEffect)(()=>{let m=C.current;if(!m)return;let k=S=>{let I=(0,j.chipIdFromTap)(m,S.target);I&&(te(I),(0,j.keepCaretOnChip)(m,I))};return m.addEventListener("click",k),()=>m.removeEventListener("click",k)},[te]),(0,E.useLayoutEffect)(()=>{let m=C.current;m&&(0,j.renderEditableContent)({input:m,segments:i,newParamId:o,editingParamId:r?.id??null,placeholderText:w??"",isFocused:y,showChipIcons:t,showChipImages:a})},[i,o,r,w,y,t,a]),(0,E.useLayoutEffect)(()=>{let m=U.current,k=o??"";if(U.current=k,!k||k===m)return;let S=C.current;if(!S)return;S.focus();let I=ce.current??(0,j.plainTextLength)(S);(0,j.setCursorOffset)(S,I)},[o]),(0,E.useLayoutEffect)(()=>{let m=V.current,k=r?.id??"";if(V.current=k,!k||k===m||l==null)return;let S=C.current;S&&(0,j.setCursorOffset)(S,l)},[r,l]);let O=(0,E.useCallback)(()=>{if(oe.current)return;let m=C.current;if(!m)return;let k=(0,j.extractPlainText)(m),I=k.length>0&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;R(I)},[R]),fe=(0,E.useCallback)(()=>{ge.current=performance.now(),O();let m=C.current;m&&_((0,j.getCursorOffset)(m))},[O,_]);(0,E.useEffect)(()=>{let m=C.current;if(!m)return;let k=S=>{let I=S,T=I.inputType;if(T==="insertParagraph"||T==="insertLineBreak"||T==="insertFromDrop"){S.preventDefault();return}if(T.startsWith("insert")||T.startsWith("delete")){let F=T.startsWith("delete")?"":I.data??"";A(F)&&S.preventDefault()}};return m.addEventListener("beforeinput",k),()=>m.removeEventListener("beforeinput",k)},[A]);let Le=(0,E.useCallback)(()=>{oe.current=!0,C.current?.setAttribute("data-aia-composing","true")},[]),Ee=(0,E.useCallback)(()=>{oe.current=!1,C.current?.removeAttribute("data-aia-composing"),O()},[O]),je=(0,E.useCallback)(m=>{m.preventDefault();let k=C.current;if(!k)return;let S=(m.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!S)return;let I=k.ownerDocument??document,T=I.getSelection();if(!T||T.rangeCount===0)return;let F=T.getRangeAt(0);if(!k.contains(F.startContainer))return;F.deleteContents();let pe=I.createTextNode(S);F.insertNode(pe),F.setStartAfter(pe),F.collapse(!0),T.removeAllRanges(),T.addRange(F),O()},[O]),Me=(0,E.useCallback)(m=>ie(m),[ie]),f=(0,E.useCallback)(()=>M(!0),[M]),ze=(0,E.useCallback)(()=>M(!1),[M]),Ne=(0,E.useCallback)(()=>C.current?.focus(),[]),He=(0,E.useCallback)(()=>C.current?.blur(),[]),Fe=(0,E.useCallback)(()=>{let m=C.current;return m?(0,j.extractPlainText)(m):""},[]),Be=Na()?"plaintext-only":"true";return{inputRef:C,editorProps:{ref:C,contentEditable:Be,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":d,"aria-expanded":g,"aria-activedescendant":c,spellCheck:!0,enterKeyHint:"send",onInput:fe,onKeyDown:Me,onCompositionStart:Le,onCompositionEnd:Ee,onPaste:je,onFocus:f,onBlur:ze},getPlainText:Fe,focus:Ne,blur:He}}var ke=require("react/jsx-runtime");function Ha(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var na=(0,K.forwardRef)(function({onSubmit:i,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:n,apiConfig:l,additionalContext:u,language:w,currency:y,productId:g,visitorId:d,columns:c,pillPlacement:v="dropdown",mode:R="auto",optionsPosition:ie="below",animations:_=!0,dropdownTrigger:Q,closeDropdownOnBlur:te,showNonTappableOptions:A,showOptionIcons:M=!0,showChipIcons:C=!0,showChipImages:oe=!0,showOptionImages:U=!0,showOptionCounts:V=!0,showSkipButton:ce,showProducts:ge,productsLayout:O,productImageFallback:fe,autoFocus:Le=!0,onFocus:Ee,onBlur:je,value:Me,completedParams:f,onChange:ze,onParamsChange:Ne,products:He,mapProducts:Fe,onProductSelect:Be,onProductAddToCart:m,submitButton:k,resetOnSubmit:S=!0},I){let T=(0,K.useRef)(null),F=(0,K.useRef)(null),pe=(0,K.useRef)(()=>{}),ae=(0,K.useRef)(null),We=(0,K.useRef)(null);(0,K.useEffect)(()=>{let z=T.current;if(z)return ae.current?ae.current.setMode(R):ae.current=new Ye.ModeController(z,R),()=>{ae.current?.destroy(),ae.current=null}},[R]);let Qe=(0,K.useCallback)(z=>{let ne=We.current?.current;ne&&(ne.focus(),(0,Ye.setCursorOffset)(ne,z))},[]),{completedParams:Se,suggestionPills:Ae,setActivePill:Ge,skipActivePill:h,segments:$,newParamId:he,clearNewParamId:be,placeholderText:$e,isFocused:x,isDropdownOpen:Ze,isActivePillSelected:it,isLoading:Re,activeIndex:b,listboxId:Ke,handleTextChange:et,handleKeyDown:qe,setFocused:tt,editingParam:at,editingIdentified:Oe,editingAnchor:ot,caretOffset:we,startEditingParam:B,handleCaretAfterInput:nt,handleCaretMove:ct,replaceEditingRange:kt,dropdownProps:rt,reset:Xe,refreshProducts:p,prepareSubmit:q,getState:D,recordSubmit:pt}=xt({onSubmit:z=>pe.current(z),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:l,additionalContext:u,language:w,currency:y,productId:g,visitorId:d,columns:c,dropdownTrigger:Q,optionsPosition:ie,closeDropdownOnBlur:te,showNonTappableOptions:A,showOptionIcons:M,showOptionImages:U,showOptionCounts:V,showSkipButton:ce,showProducts:ge,onFocus:Ee,onBlur:je,value:Me,completedParams:f,onChange:ze,onParamsChange:Ne,products:He,mapProducts:Fe,onProductSelect:Be,onProductAddToCart:m,source:"full-sdk",setCursor:Qe});(0,K.useEffect)(()=>{if(!he)return;let z=window.setTimeout(()=>be(),650);return()=>window.clearTimeout(z)},[he,be]);let ra=b>=0?`${Ke}-option-${b}`:void 0,{inputRef:St,editorProps:sa,focus:ht,blur:Dt,getPlainText:Lt}=oa({segments:$,newParamId:he,editingParam:at,editingIdentified:Oe,editingAnchor:ot,caretOffset:we,placeholderText:$e,isFocused:x,showChipIcons:C,showChipImages:oe,isDropdownOpen:Ze,listboxId:Ke,activeDescendantId:ra,autoFocus:Le,handleTextChange:et,handleKeyDown:qe,handleCaretAfterInput:nt,handleCaretMove:ct,startEditingParam:B,replaceEditingRange:kt,setFocused:tt});We.current=St,(0,K.useLayoutEffect)(()=>{let z=F.current,ne=St.current;if(!z||!ne)return;let st=()=>{let zt=z.firstElementChild;if(!zt)return;let pa=zt.getBoundingClientRect(),ha=ne.getBoundingClientRect();pa.top>=ha.bottom-2?z.setAttribute("data-aia-pill-wrapped",""):z.removeAttribute("data-aia-pill-wrapped")};st();let Mt=new ResizeObserver(st);return Mt.observe(ne),()=>Mt.disconnect()},[$,Ae.length,Re,St]),(0,K.useImperativeHandle)(I,()=>({focus:ht,blur:Dt,reset:Xe,refreshProducts:p,setMode:z=>ae.current?.setMode(z),skipActivePill:h}),[ht,Dt,Xe,p,h]);let ut=!!$.length||Se.length>0,Ct=(0,K.useCallback)(z=>{if(!ut)return;z&&q();let ne=D(),st=(0,Ye.buildSubmitResult)(Lt(),ne.completedParams,ne.skippedParams,{identifiedParams:ne.identifiedParams,isReady:ne.isReady,customFields:ne.customFields});z&&pt(st),i(st),S&&Xe()},[pt,S,ut,q,D,i,Xe,Lt]);pe.current=()=>Ct(!1);let la=(0,K.useCallback)(z=>{z.target?.closest("[data-aia-pill]")||ht()},[ht]),da=v==="inline",ca=v==="dropdown";return(0,ke.jsxs)("div",{ref:T,className:`magicx-aia ${Je.container} ${n??""}`,"data-pill-placement":v,"data-options-position":ie,"data-animations":_?"on":"off","data-mode":Ha(R),children:[(0,ke.jsx)(wt,{...rt,showPills:ca,productsLayout:O,productImageFallback:fe}),(0,ke.jsxs)("div",{className:Je.inputWrapper,"data-aia-input-wrapper":"",onClick:la,children:[(0,ke.jsxs)("div",{className:Je.editorArea,"data-aia-editor":"",children:[(0,ke.jsx)("div",{...sa,className:Je.input,"data-aia-input":""}),da&&(Re||Ae.length>0)&&(0,ke.jsx)("span",{ref:F,className:Je.pillListContainer,"data-aia-pill-list-container":"",children:(0,ke.jsx)(ft,{pills:Ae,activePillIndex:0,activeSelected:it,onSelectPill:Ge,loading:Re})})]}),k===null?null:k===void 0?(0,ke.jsx)(ea,{disabled:!ut,onClick:()=>Ct(!0),label:(0,Ye.uiStringsFor)(w).submit}):(0,ke.jsx)("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Je.submitSlot,onClick:z=>{ut&&(z.stopPropagation(),Ct(!0))},children:k})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,DATE_RANGE_META_END,DATE_RANGE_META_START,DEFAULT_OPTION_COUNT_UNIT,PRODUCT_PATH_PREFIX,TIME_META_KEY,WEEKDAY_LABELS,buildSubmitResult,cellDay,cellIso,dateCellMarks,formatDate,formatDateRange,formatOptionCount,formatTime,isoDate,monthLabel,optionCountLabel,optionHasImage,optionImageSources,optionImageSrc,optionLabel,optionsShowLeadingVisuals,parseDate,parseLooseDate,parseLooseDateRange,parseTime,productFromMatchedItem,productImageSources,productsFromCustomFields,sanitizeOptionIconSvg,selectedRangeFor,useAIAutocomplete,visibleDateRange,withSkippedParams});
|
|
2652
2868
|
//# sourceMappingURL=index.js.map
|