@magicx-eng/ai-autocomplete-react 0.40.1 → 0.41.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/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +129 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +129 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{buildSubmitResult as
|
|
1
|
+
import{buildSubmitResult as Nn,cellDay as Fn,cellIso as Hn,DATE_RANGE_META_END as Bn,DATE_RANGE_META_START as Kn,DEFAULT_OPTION_COUNT_UNIT as Gn,dateCellMarks as Wn,formatDate as _n,formatDateRange as qn,formatOptionCount as Un,isoDate as Vn,monthLabel as jn,optionCountLabel as Qn,optionHasImage as Yn,optionImageSources as $n,optionImageSrc as Zn,optionLabel as Xn,optionsShowLeadingVisuals as Jn,PRODUCT_PATH_PREFIX as er,parseDate as tr,parseLooseDate as ar,parseLooseDateRange as ir,productFromMatchedItem as or,productImageSources as nr,productsFromCustomFields as rr,sanitizeOptionIconSvg as sr,selectedRangeFor as lr,visibleDateRange as dr,WEEKDAY_LABELS as cr,withSkippedParams as pr}from"@magicx-eng/ai-autocomplete-vanilla";import{forwardRef as Li,useCallback as bt,useEffect as Jt,useImperativeHandle as zi,useLayoutEffect as Mi,useRef as _e}from"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
|
|
@@ -268,7 +268,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
268
268
|
opacity: 0;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
`,document.head.appendChild(e)}var
|
|
271
|
+
`,document.head.appendChild(e)}var Ee={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"};import{attachScrollArrow as li,attachViewportFit as di,containScroll as ci,hasSkippablePill as pi,isCalendarFormat as hi,labelTraditionalAutocomplete as ui,uiStringsFor as mi}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as Le,useRef as Oe,useState as gi}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
272
272
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
273
273
|
* Consumer CSS always wins without !important.
|
|
274
274
|
*
|
|
@@ -467,6 +467,9 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
467
467
|
--aia-pill-bg: var(--aia-primitive-neutral-750);
|
|
468
468
|
--aia-pill-color: var(--aia-primitive-neutral-300);
|
|
469
469
|
--aia-pill-font-size: 16px;
|
|
470
|
+
/* Smart Suggestion sparkle, matched text, and the shimmer's bright centre. */
|
|
471
|
+
--aia-smart-suggestion-accent: #b84549;
|
|
472
|
+
--aia-smart-suggestion-glint: #f3c4c5;
|
|
470
473
|
|
|
471
474
|
/* Completed params (Figma "RichTextPill"): compact faint-gray chip with
|
|
472
475
|
primary-color regular-weight text. -active is the hover / tapped (re-edit)
|
|
@@ -519,6 +522,9 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
519
522
|
--aia-pill-bg: var(--aia-primitive-neutral-750);
|
|
520
523
|
--aia-pill-color: var(--aia-primitive-neutral-700);
|
|
521
524
|
--aia-pill-font-size: 16px;
|
|
525
|
+
/* Smart Suggestion sparkle, matched text, and the shimmer's bright centre. */
|
|
526
|
+
--aia-smart-suggestion-accent: #e0787b;
|
|
527
|
+
--aia-smart-suggestion-glint: #ffe1e1;
|
|
522
528
|
|
|
523
529
|
/* Completed params (Figma "RichTextPill") \u2014 dark theme (design source):
|
|
524
530
|
white text on a faint-gray chip. -active is the hover / tapped highlight.
|
|
@@ -1114,7 +1120,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1114
1120
|
opacity: 0.25;
|
|
1115
1121
|
}
|
|
1116
1122
|
}
|
|
1117
|
-
`,document.head.appendChild(e)}var
|
|
1123
|
+
`,document.head.appendChild(e)}var le={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"};import{cellDay as sa,cellIso as De,dateCellMarks as la,isoDate as da,monthLabel as ca,visibleDateRange as pa,WEEKDAY_LABELS as ha}from"@magicx-eng/ai-autocomplete-vanilla";import{useState as ua}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-f687bd03")){let e=document.createElement("style");e.id="ac-style-f687bd03",e.textContent=`/* --- Datepicker (replaces the options grid for date suggestions) ---
|
|
1118
1124
|
|
|
1119
1125
|
One of three hand-maintained copies (vanilla styles.css, this file, Angular's
|
|
1120
1126
|
date-grid.component.css). Only the class-naming layer differs \u2014 the
|
|
@@ -1277,7 +1283,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1277
1283
|
opacity: 0.8;
|
|
1278
1284
|
background: rgba(var(--aia-streak-rgb, 255, 255, 255), 0.06);
|
|
1279
1285
|
}
|
|
1280
|
-
`,document.head.appendChild(e)}var L={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"};import{jsx as
|
|
1286
|
+
`,document.head.appendChild(e)}var L={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"};import{jsx as te,jsxs as Pt}from"react/jsx-runtime";var ma=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function It({options:e,activeIndex:n,listboxId:t,view:a,selection:o,onSelect:r,onHighlight:i,onUnhighlight:d,onPreviousMonth:s,onNextMonth:f}){let C=da(new Date),S=pa({pendingStart:o.rangeStart,highlightedIso:De(e[n]),selected:o.selectedRange});return Pt("div",{className:L.datepicker,"data-aia-datepicker":"",children:[Pt("div",{className:L.header,children:[te("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-prev":"","aria-label":"Previous month",onMouseDown:g=>g.preventDefault(),onClick:s,children:"\u2039"}),te("span",{className:L.month,"data-aia-date-month":"","aria-live":"polite",children:ca(a)}),te("button",{type:"button",tabIndex:-1,className:L.nav,"data-aia-date-next":"","aria-label":"Next month",onMouseDown:g=>g.preventDefault(),onClick:f,children:"\u203A"})]}),te("div",{className:L.weekdays,"aria-hidden":"true",children:ha.map((g,v)=>te("span",{className:L.weekday,children:g},ma[v]))}),te("div",{className:L.grid,"data-aia-date-grid":"",children:e.map((g,v)=>te(ga,{option:g,id:`${t}-option-${v}`,index:v,isHighlighted:v===n&&g.is_tappable,isToday:De(g)===C,isPast:De(g)!=null&&De(g)<C,marks:la(De(g),{selectedIso:o.selectedIso,range:S}),onSelect:r,onHighlight:i,onUnhighlight:d},De(g)??`pad-${v}`))})]})}function ga({option:e,id:n,index:t,isHighlighted:a,isToday:o,isPast:r,marks:i,onSelect:d,onHighlight:s,onUnhighlight:f}){let[C,S]=ua(!1),g=sa(e);if(g==null)return te("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-hidden":"true","aria-selected":!1,tabIndex:-1,className:`${L.cell} ${L.blank}`});let v=()=>{S(!0),d(e),setTimeout(()=>S(!1),170)},P=[L.cell,L.day,r?L.past:"",a?L.highlighted:"",o?L.today:"",i.inRange?L.inRange:"",i.selected?L.selected:"",C?L.pressed:""].filter(Boolean).join(" ");return te("div",{id:n,role:"option","data-aia-option":"","data-aia-date-cell":"","aria-selected":a,"aria-label":e.text,tabIndex:0,className:P,onClick:v,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),v())},onMouseEnter:()=>s(t),onMouseLeave:f?()=>f(t):void 0,children:te("span",{className:L.number,children:g})})}import{ATTRIBUTION_URL as fa,buildAttributionUrl as ba,getFooterHint as wa,uiStringsFor as va}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as xa,useState as ya}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`.aia-cluster {
|
|
1281
1287
|
display: flex;
|
|
1282
1288
|
flex-wrap: wrap;
|
|
1283
1289
|
gap: var(--aia-cluster-gap, 0.5rem);
|
|
@@ -1317,7 +1323,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1317
1323
|
.aia-cluster[data-justify="around"] {
|
|
1318
1324
|
justify-content: space-around;
|
|
1319
1325
|
}
|
|
1320
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1326
|
+
`,document.head.appendChild(e)}import{jsx as Tt}from"react/jsx-runtime";function Ge({gap:e,align:n="center",justify:t="start",noWrap:a=!1,inline:o=!1,className:r,children:i,...d}){let s=e?{"--aia-cluster-gap":e}:void 0,f={className:r?`aia-cluster ${r}`:"aia-cluster","data-align":n,"data-justify":t,"data-nowrap":a||void 0,"data-inline":o||void 0,style:s,...d};return o?Tt("span",{...f,children:i}):Tt("div",{...f,children:i})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 8px horizontal inset so it stays clear of the
|
|
1321
1327
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
1322
1328
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
1323
1329
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -1464,7 +1470,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1464
1470
|
justify-content: flex-end;
|
|
1465
1471
|
}
|
|
1466
1472
|
}
|
|
1467
|
-
`,document.head.appendChild(e)}var
|
|
1473
|
+
`,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"};import{jsx as We,jsxs as rt}from"react/jsx-runtime";function Et({isOptionHighlighted:e=!1,isInputEmpty:n=!1,strings:t=va()}){let{key:a,hint:o}=wa(e,n,t),[r,i]=ya(fa);return xa(()=>{i(ba())},[]),We("footer",{className:de.footer,"data-aia-footer":"",children:rt(Ge,{justify:"between",noWrap:!0,className:de.row,children:[rt(Ge,{gap:"5px",className:de.hintGroup,children:[We("kbd",{className:de.key,children:a}),We("span",{className:de.hint,children:o})]}),rt("a",{className:de.brandLink,href:r,target:"_blank",rel:"noopener noreferrer",children:[We("span",{className:de.brand,children:"AI"}),We("span",{className:de.badge,children:"Autocomplete"})]})]})})}import{isSmartSuggestion as Pa,isTraditionalAutocompleteSuggestion as Ia}from"@magicx-eng/ai-autocomplete-vanilla";import{SMART_SUGGESTION_SPARKLE_SVG as ka}from"@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,
|
|
1468
1474
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
1469
1475
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
1470
1476
|
as it was when the outline was dashed. */
|
|
@@ -1494,6 +1500,110 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1494
1500
|
border-radius: 999px;
|
|
1495
1501
|
}
|
|
1496
1502
|
|
|
1503
|
+
/* Smart Suggestion header: the question label's type, with a sparkle after
|
|
1504
|
+
it, over the completions of the word being typed or on a question the server
|
|
1505
|
+
marks. When it appears a glint of the accent sweeps the text twice and the
|
|
1506
|
+
sparkle twinkles as each lands. Only the header over completions
|
|
1507
|
+
("header") takes no pointer: a marked question is tapped like any pill. */
|
|
1508
|
+
.aia-pill-6Ga7S[data-aia-smart-suggestion] {
|
|
1509
|
+
gap: 0.35em;
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
.aia-pill-6Ga7S[data-aia-smart-suggestion="header"] {
|
|
1513
|
+
cursor: default;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
.aia-smartText-R0cfw {
|
|
1517
|
+
background:
|
|
1518
|
+
linear-gradient(
|
|
1519
|
+
105deg,
|
|
1520
|
+
var(--aia-pill-color, var(--aia-color-text-muted, #c1c4cb)) 34%,
|
|
1521
|
+
var(--aia-smart-suggestion-accent, #b84549) 44%,
|
|
1522
|
+
var(--aia-smart-suggestion-glint, #f3c4c5) 50%,
|
|
1523
|
+
var(--aia-smart-suggestion-accent, #b84549) 56%,
|
|
1524
|
+
var(--aia-pill-color, var(--aia-color-text-muted, #c1c4cb)) 66%
|
|
1525
|
+
)
|
|
1526
|
+
100% 0 / 300% 100%;
|
|
1527
|
+
-webkit-background-clip: text;
|
|
1528
|
+
background-clip: text;
|
|
1529
|
+
-webkit-text-fill-color: transparent;
|
|
1530
|
+
animation: aia-smartSuggestion-shimmer-F-yoD 2.5s ease-in-out 2;
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
.aia-smartSparkle-IVabG {
|
|
1534
|
+
display: inline-flex;
|
|
1535
|
+
color: var(--aia-smart-suggestion-accent, #b84549);
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
.aia-smartSparkle-IVabG .aia-sparkle-large,
|
|
1539
|
+
.aia-smartSparkle-IVabG .aia-sparkle-small {
|
|
1540
|
+
transform-box: fill-box;
|
|
1541
|
+
transform-origin: center;
|
|
1542
|
+
animation: aia-smartSuggestion-sparkle-Wfj-4 2.5s ease-in-out 2;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
.aia-smartSparkle-IVabG .aia-sparkle-small {
|
|
1546
|
+
animation-name: aia-smartSuggestion-sparkle-small-3VsWJ;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
.aia-skeleton-57P0T .aia-smartText-R0cfw,
|
|
1550
|
+
.aia-skeleton-57P0T .aia-smartSparkle-IVabG {
|
|
1551
|
+
visibility: hidden;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
@keyframes aia-smartSuggestion-shimmer-F-yoD {
|
|
1555
|
+
0% {
|
|
1556
|
+
background-position: 100% 0;
|
|
1557
|
+
}
|
|
1558
|
+
60%,
|
|
1559
|
+
100% {
|
|
1560
|
+
background-position: 0 0;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
@keyframes aia-smartSuggestion-sparkle-Wfj-4 {
|
|
1565
|
+
0%,
|
|
1566
|
+
45%,
|
|
1567
|
+
75%,
|
|
1568
|
+
100% {
|
|
1569
|
+
transform: scale(1);
|
|
1570
|
+
}
|
|
1571
|
+
60% {
|
|
1572
|
+
transform: scale(1.12);
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
@keyframes aia-smartSuggestion-sparkle-small-3VsWJ {
|
|
1577
|
+
0%,
|
|
1578
|
+
45%,
|
|
1579
|
+
75%,
|
|
1580
|
+
100% {
|
|
1581
|
+
transform: scale(1);
|
|
1582
|
+
opacity: 1;
|
|
1583
|
+
}
|
|
1584
|
+
60% {
|
|
1585
|
+
transform: scale(1.5);
|
|
1586
|
+
opacity: 0.55;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1591
|
+
.aia-smartText-R0cfw,
|
|
1592
|
+
.aia-smartSparkle-IVabG .aia-sparkle-large,
|
|
1593
|
+
.aia-smartSparkle-IVabG .aia-sparkle-small {
|
|
1594
|
+
animation: none;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/* Forced colours drop the background-clip paint, so the text is drawn plainly. */
|
|
1599
|
+
@media (forced-colors: active) {
|
|
1600
|
+
.aia-smartText-R0cfw {
|
|
1601
|
+
background: none;
|
|
1602
|
+
-webkit-text-fill-color: currentColor;
|
|
1603
|
+
animation: none;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1497
1607
|
/* Loading skeleton \u2014 preserves the pill's exact box (same width and height)
|
|
1498
1608
|
and hides the text. The base pill is now transparent, so fill the interior
|
|
1499
1609
|
with the skeleton color (inside the dashed border) and pulse it so it still
|
|
@@ -1540,7 +1650,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1540
1650
|
opacity: 0;
|
|
1541
1651
|
}
|
|
1542
1652
|
}
|
|
1543
|
-
`,document.head.appendChild(e)}var
|
|
1653
|
+
`,document.head.appendChild(e)}var ae={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"};import{Fragment as Ca,jsx as st,jsxs as Sa}from"react/jsx-runtime";var lt={selected:1,first:.7,next:.4,last:.2};function At({label:e,state:n,rounded:t,loading:a,smartSuggestion:o,completionHeader:r,onClick:i}){let d=[ae.pill,t?ae.rounded:"",a?ae.skeleton:""].filter(Boolean).join(" ");return st("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:d,style:{opacity:lt[n]},onMouseDown:s=>s.preventDefault(),onClick:a?void 0:i,disabled:a,children:o?Sa(Ca,{children:[st("span",{className:`${ae.smartText} magicx-aia-smart-suggestion-text`,children:e}),st("span",{className:`${ae.smartSparkle} magicx-aia-smart-suggestion-sparkle`,dangerouslySetInnerHTML:{__html:ka}})]}):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 {
|
|
1544
1654
|
position: relative;
|
|
1545
1655
|
z-index: 1;
|
|
1546
1656
|
pointer-events: auto;
|
|
@@ -1550,7 +1660,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1550
1660
|
align-items: center;
|
|
1551
1661
|
vertical-align: middle;
|
|
1552
1662
|
}
|
|
1553
|
-
`,document.head.appendChild(e)}var
|
|
1663
|
+
`,document.head.appendChild(e)}var dt={list:"aia-list-qvLqO"};import{jsx as $e}from"react/jsx-runtime";var Ta=[125,69];function Rt(e){return e===0?"first":e===1?"next":"last"}function Ze({pills:e,activePillIndex:n,onSelectPill:t,activeSelected:a,rounded:o,loading:r}){return r&&e.length===0?$e("span",{className:dt.list,"data-aia-pill-list-loading":"",children:Ta.map((i,d)=>$e("span",{"data-aia-pill-skeleton":"",className:`${ae.pill} ${o?ae.rounded:""} ${ae.skeleton}`,style:{width:i,opacity:lt[Rt(d)]}},`skel-${i}`))}):$e("span",{className:dt.list,"data-aia-pill-list-loading":r?"":void 0,children:e.map((i,d)=>{let s=!!a&&d===n;return $e(At,{label:i.text,state:s?"selected":Rt(d),selected:s,rounded:o,loading:r,smartSuggestion:Pa(i),completionHeader:Ia(i),onClick:()=>t(d)},`${i.parameter}-${i.text}`)})})}import{attachProductRowWheel as Ea,productImageSources as Aa,productImageSrc as Ra,productInitial as Da,uiStringsFor as Oa}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as La,useRef as za,useState as Ma}from"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
|
|
1554
1664
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
1555
1665
|
theming one package sees the same result in the other.
|
|
1556
1666
|
|
|
@@ -1837,7 +1947,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1837
1947
|
letter-spacing: 0.02em;
|
|
1838
1948
|
text-align: center;
|
|
1839
1949
|
}
|
|
1840
|
-
`,document.head.appendChild(e)}var
|
|
1950
|
+
`,document.head.appendChild(e)}var V={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"};import{jsx as ce,jsxs as Xe}from"react/jsx-runtime";function Dt({products:e,listboxId:n,onSelect:t,onFocusChange:a,focusable:o=!0,layout:r="row",imageFallback:i="image",strings:d=Oa()}){let s=e.length>0,f=za(null);if(La(()=>{let S=f.current;if(!(!s||!S))return Ea(S)},[s]),!s)return null;let C=`${n}-products-label`;return Xe("section",{className:V.section,"data-aia-products":"","data-aia-products-layout":r,role:"group","aria-labelledby":C,children:[ce("div",{className:V.label,id:C,"data-aia-products-label":"",children:d.products}),ce("div",{ref:f,className:V.row,"data-aia-products-row":"",children:e.map((S,g)=>ce(Na,{product:S,id:`${n}-product-${g}`,onSelect:t,onFocusChange:a,focusable:o,imageFallback:i,soldOut:d.soldOut},S.id))})]})}function Na({product:e,id:n,onSelect:t,onFocusChange:a,focusable:o,imageFallback:r,soldOut:i}){let d=s=>{s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.button!==0||(s.preventDefault(),t(e))};return Xe("a",{id:n,className:V.card,"data-aia-product":"","data-aia-product-sold-out":e.available===!1?"":void 0,role:"option","aria-selected":!1,href:e.url,tabIndex:o?0:-1,onClick:d,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),t(e))},onFocus:()=>a?.(!0),onBlur:s=>{s.relatedTarget?.closest("[data-aia-dropdown]")||a?.(!1)},children:[ce(Fa,{sources:Aa(e.imageUrl),title:e.title,fallback:r},Ra(e.imageUrl)??""),Xe("span",{className:V.body,children:[e.vendor?ce("span",{className:V.vendor,children:e.vendor}):null,ce("span",{className:V.title,children:e.title}),e.price?ce("span",{className:V.price,children:e.price}):null,e.available===!1?ce("span",{className:V.badge,children:i}):null]})]})}function Fa({sources:e,title:n,fallback:t}){let[a,o]=Ma(0),r=e[a],i=!!r,d=!i&&t==="initial";return Xe("span",{className:V.media,"aria-hidden":"true","data-aia-product-placeholder":!i&&!d?"":void 0,"data-aia-product-initial":d?"":void 0,children:[i?ce("img",{className:V.image,src:r,alt:"",loading:"lazy",decoding:"async",onError:()=>o(s=>s+1)}):null,d?Da(n):null]})}import{isOptionsGridMobileViewport as Za,measureOptionsGrid as Xa,needsOptionsGridMeasurement as Ja,OPTIONS_GRID_MOBILE_QUERY as ei,optionEnterDelayMs as ti,optionsShowLeadingVisuals as ai,planOptionsGrid as Mt,sameOptionRows as ii}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as oi,useLayoutEffect as ni,useRef as Nt,useState as Ht}from"react";import{optionsGridTemplateColumns as Ha}from"@magicx-eng/ai-autocomplete-vanilla";import{useLayoutEffect as Ba,useRef as Ka}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`.aia-grid {
|
|
1841
1951
|
display: grid;
|
|
1842
1952
|
grid-template-columns: repeat(
|
|
1843
1953
|
auto-fit,
|
|
@@ -1873,7 +1983,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
1873
1983
|
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
1874
1984
|
display: none;
|
|
1875
1985
|
}
|
|
1876
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1986
|
+
`,document.head.appendChild(e)}import{jsx as Ga}from"react/jsx-runtime";function Ot({min:e="16rem",max:n,gap:t,scroll:a=!1,maxHeight:o,scrollResetKey:r,cols:i,template:d,innerRef:s,className:f,children:C,...S}){let g=Ka(null);Ba(()=>{if(r===void 0)return;let P=g.current;P&&(P.scrollTop=0)},[r]);let v={"--aia-grid-min":e};return n&&(v["--aia-grid-max"]=n),t&&(v["--aia-grid-gap"]=t),o&&(v["--aia-grid-max-height"]=o),i&&(v.gridTemplateColumns=Ha(i)),d&&(v.gridTemplateColumns=d),Ga("div",{ref:P=>{g.current=P,s?.(P)},className:f?`aia-grid ${f}`:"aia-grid","data-scroll":a||void 0,style:v,...S,children:C})}import{formatOptionCount as Wa,highlightParts as _a,OPTION_ENTER_DELAY_VAR as qa,optionImageSources as Ua,optionLabel as Lt,sanitizeOptionIconSvg as Va}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as ja,useMemo as Qa,useRef as Ya,useState as ct}from"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 {
|
|
1877
1987
|
position: relative;
|
|
1878
1988
|
/* Clip, not visible: the entrance rise below runs on the inner content,
|
|
1879
1989
|
and a transformed box extends its scroll container's scrollable area.
|
|
@@ -2054,6 +2164,12 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2054
2164
|
opacity: var(--aia-option-parameter-opacity, 0.6);
|
|
2055
2165
|
}
|
|
2056
2166
|
|
|
2167
|
+
/* The part of a completion the typed text matches, in the Smart Suggestion accent. */
|
|
2168
|
+
.aia-match-pp-9v {
|
|
2169
|
+
color: var(--aia-smart-suggestion-accent, #b84549);
|
|
2170
|
+
font-weight: 600;
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2057
2173
|
.aia-item-d4vpD[data-aia-loading] .aia-parameter-Dt2zF {
|
|
2058
2174
|
display: none;
|
|
2059
2175
|
}
|
|
@@ -2305,7 +2421,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2305
2421
|
opacity: 0;
|
|
2306
2422
|
}
|
|
2307
2423
|
}
|
|
2308
|
-
`,document.head.appendChild(e)}var
|
|
2424
|
+
`,document.head.appendChild(e)}var K={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"};import{Fragment as $a,jsx as Se,jsxs as pt}from"react/jsx-runtime";function zt({option:e,isHighlighted:n,onSelect:t,onHighlight:a,onUnhighlight:o,id:r,loading:i,showIcon:d=!0,showImage:s=!0,showCount:f=!0,scrollHint:C,enterDelayMs:S=0}){let[g]=ct(S),[v,P]=ct(!1),E=s?Ua(e.image_url):[],M=E[0]??null,[H,G]=ct([]),T=E.find(I=>!H.includes(I))??null,A=Qa(()=>!M&&d&&e.icon_svg?Va(e.icon_svg):null,[M,d,e.icon_svg]),O=f?Wa(e.item_count):null,y=Ya(void 0);ja(()=>()=>clearTimeout(y.current),[]);let _=()=>{i||!e.is_tappable||v||(P(!0),t(e),clearTimeout(y.current),y.current=setTimeout(()=>P(!1),170))},B=[K.item,n&&!i?K.highlighted:"",e.is_tappable?K.tappable:K.nonTappable,v?K.pressed:"",C?K.scrollHint:""].filter(Boolean).join(" ");return Se("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"data-aia-icon":A&&e.icon?e.icon:void 0,"data-aia-image":M?"":void 0,"data-aia-item-count":O!==null?e.item_count:void 0,"aria-selected":n,className:B,style:{[qa]:`${g}ms`},tabIndex:i||!e.is_tappable?-1:0,onClick:_,onKeyDown:I=>{!i&&e.is_tappable&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),_())},onMouseEnter:!i&&e.is_tappable?a:void 0,onMouseLeave:o,children:pt("span",{className:K.content,children:[M&&Se("span",{className:`${K.image} magicx-aia-option-image`,"aria-hidden":"true",children:Se("img",{src:T??M,alt:"",loading:"lazy",decoding:"async",referrerPolicy:"no-referrer",draggable:!1,hidden:T===null,onError:()=>{T!==null&&G(I=>[...I,T])}})}),A&&Se("span",{className:`${K.icon} magicx-aia-option-icon`,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:A}}),pt("span",{className:K.text,children:[e.matchedText?_a(Lt(e),e.matchedText).map((I,Q)=>I.bold?Se("strong",{className:`${K.match} magicx-aia-option-match`,children:I.text},Q):I.text):Lt(e),e.parameterLabel&&pt($a,{children:[" ",Se("span",{className:`${K.parameter} magicx-aia-option-parameter`,children:e.parameterLabel})]})]}),e.tag&&Se("span",{className:K.tag,children:e.tag}),O!==null&&Se("span",{className:`${K.count} magicx-aia-option-count`,children:O})]})})}import{jsx as Ft}from"react/jsx-runtime";function ri(){let[e,n]=Ht(Za);return oi(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(ei),a=()=>n(t.matches);return a(),t.addEventListener("change",a),()=>t.removeEventListener("change",a)},[]),e}function Bt({options:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:r,loading:i,groupKey:d="",optionsPosition:s="below",showIcons:f=!0,showImages:C=!0,showCounts:S=!0}){let g=ri(),v=Nt(null),[P,E]=Ht(null),M=Nt(null);ni(()=>{if(i&&ii(M.current,e))return;M.current=i?null:e;let T=v.current,O=T&&!i&&Ja(e.length,g)?Xa(T):null;E(O?Mt(e.length,g,O.rowWidths,O.gridWidth):null)},[e,g,i]);let H=P??Mt(e.length,g,null,null),G=ai(e,f,C);return Ft(Ot,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:d,template:H.template,maxHeight:H.maxHeight,innerRef:T=>{v.current=T},"data-aia-group":d,children:e.map((T,A)=>Ft(zt,{option:T,isHighlighted:A===n,onSelect:t,onHighlight:()=>a(A),onUnhighlight:o?()=>o(A):void 0,id:`${r}-option-${A}`,loading:i,showIcon:f&&G,showImage:C&&G,showCount:S,scrollHint:!i&&H.scrollHintIndices.includes(A),enterDelayMs:i?0:ti(A,H.cols,e.length,s)},`${d}\0${T.text}`))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`.aia-stack {
|
|
2309
2425
|
display: flex;
|
|
2310
2426
|
flex-direction: column;
|
|
2311
2427
|
gap: var(--aia-stack-space, 0.5rem);
|
|
@@ -2320,7 +2436,7 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2320
2436
|
align-items: end;
|
|
2321
2437
|
}
|
|
2322
2438
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
2323
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
2439
|
+
`,document.head.appendChild(e)}import{jsx as si}from"react/jsx-runtime";function Kt({space:e,align:n="stretch",className:t,children:a,...o}){let r=e?{"--aia-stack-space":e}:void 0;return si("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":n,style:r,...o,children:a})}import{jsx as j,jsxs as ht}from"react/jsx-runtime";var fi=[159,119,164],bi=()=>{},Gt=()=>{};function wi(e){let n=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,a]=gi(n);if(Le(()=>{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 vi(e,n){let t=Oe(null);Le(()=>{let a=e.current,o=n.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:li({dropdown:a,grid:r,button:o})};return}t.current?.controller.update()}),Le(()=>()=>{t.current?.controller.destroy(),t.current=null},[])}function xi(e,n){let t=Oe(n);t.current=n;let a=Oe(null);Le(()=>{let o=e.current;if(o){if(!a.current){a.current=di({dropdown:o,isOpen:()=>t.current});return}a.current.update()}}),Le(()=>()=>{a.current?.destroy(),a.current=null},[])}function ut({suggestions:e,activeIndex:n,onSelect:t,onHighlight:a,onUnhighlight:o,isOpen:r,id:i,className:d,pills:s,onPillClick:f,showPills:C=!0,onSkip:S,showSkipButton:g=!0,showOptionIcons:v=!0,showOptionImages:P=!0,showOptionCounts:E=!0,skipDisabled:M=!1,activeSelected:H=!1,isLoading:G=!1,skeletonExiting:T=!1,isInputEmpty:A=!1,language:O,products:y,onProductSelect:_,onProductFocusChange:B,productsLayout:I="row",productImageFallback:Q="image",formatType:ie="options",dateView:q=null,selectedDateIso:oe=null,selectedDateRange:pe=null,dateRangeStart:Pe=null,onPreviousMonth:he,onNextMonth:u,optionsPosition:ue="below",mode:me}){let ne=wi(me),ge=ne!==void 0,U=Oe(null),re=Oe(null);vi(U,re),Le(()=>{if(U.current)return ci(U.current)},[]);let l=e[0]?.options??[],m=!!(s&&s.length>0&&f),b=!!(y&&y.length>0),w=r&&(l.length>0||C&&m||G||b);xi(U,w);let k={suggestions:e,activeIndex:n,pills:s,showPills:C,showSkipButton:g,showOptionIcons:v,showOptionImages:P,showOptionCounts:E,skipDisabled:M,activeSelected:H,isLoading:G,skeletonExiting:T,isInputEmpty:A,products:y,formatType:ie,dateView:q,selectedDateIso:oe,selectedDateRange:pe,dateRangeStart:Pe},z=Oe(k);w&&(z.current=k);let p=w?k:z.current,N=mi(O),Y=p.suggestions[0],$=Y?.options??[],fe=p.activeIndex>=0&&!!$[p.activeIndex]?.is_tappable,Z=ui(p.pills??[],N.keepTyping),be=!!(Z.length>0&&f),we=p.showPills&&be,ve=p.showPills&&!be&&p.isLoading,xe=we||ve,x=be&&pi(Z)&&p.showSkipButton&&!p.isInputEmpty&&!!S,ye=Z[0]?.text,ke=hi(p.formatType)&&p.dateView!=null,se=$.length>0&&!ke,h=$.length>0&&ke&&!p.isLoading,Ae=p.isLoading&&!se&&!h,Re=p.products??[];return ht("div",{ref:U,id:i,role:"listbox","data-aia-dropdown":"","data-options-position":ue,"data-mode":ne,"data-aia-loading":p.isLoading?"":void 0,"data-aia-skeleton-exiting":p.skeletonExiting?"":void 0,"data-aia-has-products":Re.length>0?"":void 0,className:`${ge?"magicx-aia ":""}${le.dropdown} ${w?le.visible:""} ${d??""}`,onMouseDown:J=>J.preventDefault(),children:[ht(Kt,{space:"8px",children:[(xe||x)&&ht(Ge,{noWrap:!0,className:le.pillBar,"data-aia-pillbar":"",children:[xe&&j("span",{className:le.pillScroll,"data-aia-pill-scroll":"",children:j(Ze,{pills:Z,activePillIndex:0,activeSelected:p.activeSelected,onSelectPill:f??(()=>{}),rounded:!0,loading:p.isLoading})}),x&&j("button",{type:"button",tabIndex:-1,className:le.skip,"data-aia-skip":"",disabled:p.isLoading||p.skipDisabled,"aria-label":ye?`${N.skipLabel} ${ye}`:N.skipLabel,onClick:S,children:N.skip})]}),se&&j(Bt,{options:$,activeIndex:p.activeIndex,onSelect:t,onHighlight:a,onUnhighlight:o,listboxId:i,loading:p.isLoading,groupKey:Y?`${Y.parameter} ${Y.text}`:"",optionsPosition:ue,showIcons:p.showOptionIcons,showImages:p.showOptionImages,showCounts:p.showOptionCounts}),h&&p.dateView&&j(It,{options:$,activeIndex:p.activeIndex,listboxId:i,view:p.dateView,selection:{selectedIso:p.selectedDateIso??null,selectedRange:p.selectedDateRange??null,rangeStart:p.dateRangeStart??null},onSelect:t,onHighlight:a,onUnhighlight:o,onPreviousMonth:he??Gt,onNextMonth:u??Gt}),Ae&&j("div",{className:le.skeletonBars,"data-aia-skeleton-bars":"",children:fi.map(J=>j("span",{className:le.skeletonBar,style:{width:J}},`bar-${J}`))}),j(Dt,{products:Re,listboxId:i,onSelect:_??bi,onFocusChange:B,focusable:w,layout:I,imageFallback:Q,strings:N}),j(Et,{isOptionHighlighted:fe,isInputEmpty:p.isInputEmpty,strings:N})]}),j("button",{ref:re,type:"button",tabIndex:-1,className:le.scrollArrow,"data-aia-scroll-arrow":"","aria-label":N.scrollArrow,"aria-hidden":"true",children:j("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:j("path",{d:"M4 6.5 8 10.5l4-4"})})})]})}import{buildSubmitResult as Ni,ModeController as Fi,setCursorOffset as Hi,uiStringsFor as Bi}from"@magicx-eng/ai-autocomplete-vanilla";import{uiStringsFor as yi}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.aia-submitButton-otz7H {
|
|
2324
2440
|
flex-shrink: 0;
|
|
2325
2441
|
width: 32px;
|
|
2326
2442
|
height: 32px;
|
|
@@ -2373,5 +2489,5 @@ import{buildSubmitResult as En,cellDay as An,cellIso as Rn,DATE_RANGE_META_END a
|
|
|
2373
2489
|
);
|
|
2374
2490
|
cursor: default;
|
|
2375
2491
|
}
|
|
2376
|
-
`,document.head.appendChild(e)}var Kt={submitButton:"aia-submitButton-otz7H"};import{jsx as ht}from"react/jsx-runtime";function Gt({disabled:e,onClick:o,label:t=mi().submit}){return ht("button",{type:"button","data-aia-submit":"",className:Kt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":t,children:ht("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:ht("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as fi,dateSelectionFor as bi,identifiedParamLabel as wi,withoutTraditionalAutocomplete as vi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as jt,useEffect as Le,useRef as B,useState as xi}from"react";import{useRef as Wt}from"react";function _t(e){let o=Wt(e);o.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=Wt({key:"",overrides:void 0});if(a.current.key!==t){let n={};for(let r of Object.keys(e??{})){let i=(c,l,b)=>{let C=o.current?.[r];return C?C(c,l,b):[]};n[r]=i}a.current={key:t,overrides:e?n:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as qt}from"react";function Ut(e){let o=qt(e);o.current=e;let t=qt(null);t.current===null&&(t.current={fetch:(n,r)=>{let i=o.current;return i?i.fetch(n,r):Promise.reject(new Error("products config removed"))},transform:n=>o.current?.transform(n)??[],get limit(){return o.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var yi={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:o,onError:t,optionOverrides:a,maskCompletedText:n,apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:b,columns:C=2,dropdownTrigger:P,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:S,showOptionIcons:z,showOptionImages:M,showOptionCounts:H,showSkipButton:G,showProducts:I,productImageFallback:O="image",onFocus:E,onBlur:y,value:N,completedParams:K,onChange:A,onParamsChange:Z,products:ce,mapProducts:W,onProductSelect:pe,source:Ce,setCursor:he}){let u=B(null),[Pe,ie]=xi(null),ue=B(e);ue.current=e;let oe=B(o);oe.current=o;let ge=B(t);ge.current=t;let U=B(A);U.current=A;let $=B(Z);$.current=Z;let s=B(E);s.current=E;let m=B(y);m.current=y;let f=B(he);f.current=he;let v=B(pe);v.current=pe;let k=B(b);k.current=b;let T=B(()=>{let d=k.current;return typeof d=="function"?d():d}).current,p=Ut(ce),F=B(W);F.current=W;let j=B((d,_)=>{let R=F.current;return R?R(d,_):d}).current,Q=W?j:void 0,me=_t(a);Le(()=>{if(typeof document>"u")return;let d=new fi(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:c,productId:l,visitorId:T,optionOverrides:me.overrides,maskCompletedText:n,columns:C,dropdownTrigger:P,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:S,showProducts:I,source:Ce,value:N,completedParams:K,onSubmit:(...R)=>ue.current?.(...R),onResult:(...R)=>oe.current?.(...R),onError:(...R)=>ge.current?.(...R),onChange:(...R)=>U.current?.(...R),onParamsChange:(...R)=>$.current?.(...R),onFocus:()=>s.current?.(),onBlur:()=>m.current?.(),onProductSelect:R=>v.current?.(R),setCursor:R=>f.current?.(R),products:p.config,mapProducts:Q});u.current=d,ie(d.getState());let _=d.subscribe(R=>ie(R));return()=>{_(),d.destroy(),u.current===d&&(u.current=null)}},[]),Le(()=>{N!==void 0&&u.current?.setValue(N)},[N]),Le(()=>{K!==void 0&&u.current?.setCompletedParams(K)},[K]);let ne=JSON.stringify(r??null),J;try{J=JSON.stringify(i??null)}catch{J="[unstringifiable]"}Le(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:c,productId:l,optionOverrides:me.overrides,dropdownTrigger:P,optionsPosition:g,closeDropdownOnBlur:w,showNonTappableOptions:S,showProducts:I})},[ne,J,c,l,me.key,P,g,w,S,I]);let fe=B(!1);Le(()=>{if(!fe.current){fe.current=!0;return}u.current?.update({products:p.config})},[p.enabled]),Le(()=>{u.current?.update({mapProducts:Q})},[Q]);let Se=B(null);Se.current===null&&(Se.current={handleTextChange:d=>u.current?.handleTextChange(d),handleKeyDown:d=>{let _="nativeEvent"in d?d.nativeEvent:d;u.current?.handleKeyDown(_)},setFocused:d=>u.current?.setFocused(d),startEditingParam:d=>u.current?.startEditingParam(d),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:d=>u.current?.handleCaretAfterInput(d),handleCaretMove:d=>u.current?.handleCaretMove(d),replaceEditingRange:d=>u.current?.replaceEditingRange(d)??!1,setActivePill:d=>u.current?.setActivePill(d),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:d=>u.current?.recordSubmit(d),selectOption:d=>u.current?.selectOption(d),selectProduct:d=>u.current?.selectProduct(d),setActiveDropdownIndex:d=>u.current?.setActiveDropdownIndex(d),clearHighlight:d=>u.current?.clearHighlight(d),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=Se.current,be=jt(d=>{let _=d.target.value,at=_.length>0&&!d.nativeEvent?.isComposing&&_[0]!==_[0].toUpperCase()?_[0].toUpperCase()+_.slice(1):_;u.current?.handleTextChange(at)},[]),we=jt(d=>{u.current?.handleKeyDown(d.nativeEvent)},[]),re=u.current,h=Pe??yi,Ie=N!==void 0?N:h.text,Ne=K!==void 0?K:h.completedParams,ve=h.actionableSuggestions,ee=ve[0],_e=vi(ve),Te=re?.listboxId??"",et=h.activeDropdownIndex>=0&&re?`${Te}-option-${h.activeDropdownIndex}`:void 0,xe=h.editingParam,Ee=h.editingIdentified,Fe=xe?{parameter:xe.suggestionParameter,text:xe.suggestionPlaceholder,required:!0,options:xe.options}:Ee?{parameter:Ee.parameter,text:wi(Ee.parameter),required:!0,options:[]}:null,qe=h.dropdownSuggestion??Fe??ee,tt=Fe?[Fe]:ve,Be=bi(h),Ue=!re||h.dropdownLoading;return{completedParams:Ne,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:_e,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:Ue,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Te,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:xe,editingIdentified:Ee,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ie,placeholder:h.placeholderText||void 0,onChange:be,onKeyDown:we,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":et,"aria-autocomplete":"list","aria-controls":Te},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:qe?[{...qe,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Te,pills:tt,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(G??!0)&&!xe&&!Ee,showOptionIcons:z??!0,showOptionImages:M??!0,showOptionCounts:H??!0,skipDisabled:h.inSelectionAnimation,isLoading:Ue,skeletonExiting:h.skeletonExiting,isInputEmpty:Ie.trim().length===0,language:c,products:h.products,productImageFallback:O,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Be.selectedIso,selectedDateRange:Be.selectedRange,dateRangeStart:Be.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:g??"below"}}}import{chipIdFromTap as ki,extractPlainText as Qt,getCursorOffset as Yt,keepCaretOnChip as Ci,plainTextLength as Pi,renderEditableContent as Si,setCursorOffset as Vt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Xe,useLayoutEffect as gt,useRef as ze}from"react";var Je;function Ii(){if(Je!==void 0)return Je;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Je=e.contentEditable==="plaintext-only",Je}function Zt(e){let{segments:o,showChipIcons:t=!0,showChipImages:a=!0,newParamId:n,editingParam:r,editingIdentified:i,editingAnchor:c,caretOffset:l,placeholderText:b,isFocused:C,isDropdownOpen:P,listboxId:g,activeDescendantId:w,autoFocus:S,handleTextChange:z,handleKeyDown:M,handleCaretAfterInput:H,handleCaretMove:G,startEditingParam:I,replaceEditingRange:O,setFocused:E}=e,y=ze(null),N=ze(!1),K=ze(""),A=ze(""),Z=ze(null),ce=ze(0);Z.current=l,Xe(()=>{if(!S)return;let s=y.current;if(!s)return;document.activeElement===s?E(!0):s.focus();let m=s.ownerDocument??document,f=m.getSelection(),v=f&&f.rangeCount>0&&s.contains(f.anchorNode);if(f&&!v){let k=m.createRange();k.selectNodeContents(s),k.collapse(!0),f.removeAllRanges(),f.addRange(k)}},[S,E]),Xe(()=>{let s=y.current;if(!s)return;let m=s.ownerDocument??document,f=()=>{let v=m.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!s.contains(v.anchorNode))return;let k=v.anchorNode,T=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,F=(v.isCollapsed?T?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,j=r?.id??i?.id??null;if(F&&F!==j){I(F);return}performance.now()-ce.current<50||G(Yt(s))};return m.addEventListener("selectionchange",f),()=>m.removeEventListener("selectionchange",f)},[r,i,I,G]),Xe(()=>{let s=y.current;if(!s)return;let m=f=>{let v=ki(s,f.target);v&&(I(v),Ci(s,v))};return s.addEventListener("click",m),()=>s.removeEventListener("click",m)},[I]),gt(()=>{let s=y.current;s&&Si({input:s,segments:o,newParamId:n,editingParamId:r?.id??null,placeholderText:b??"",isFocused:C,showChipIcons:t,showChipImages:a})},[o,n,r,b,C,t,a]),gt(()=>{let s=K.current,m=n??"";if(K.current=m,!m||m===s)return;let f=y.current;if(!f)return;f.focus();let v=Z.current??Pi(f);Vt(f,v)},[n]),gt(()=>{let s=A.current,m=r?.id??"";if(A.current=m,!m||m===s||c==null)return;let f=y.current;f&&Vt(f,c)},[r,c]);let W=X(()=>{if(N.current)return;let s=y.current;if(!s)return;let m=Qt(s),v=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;z(v)},[z]),pe=X(()=>{ce.current=performance.now(),W();let s=y.current;s&&H(Yt(s))},[W,H]);Xe(()=>{let s=y.current;if(!s)return;let m=f=>{let v=f,k=v.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){f.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let T=k.startsWith("delete")?"":v.data??"";O(T)&&f.preventDefault()}};return s.addEventListener("beforeinput",m),()=>s.removeEventListener("beforeinput",m)},[O]);let Ce=X(()=>{N.current=!0,y.current?.setAttribute("data-aia-composing","true")},[]),he=X(()=>{N.current=!1,y.current?.removeAttribute("data-aia-composing"),W()},[W]),u=X(s=>{s.preventDefault();let m=y.current;if(!m)return;let f=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let v=m.ownerDocument??document,k=v.getSelection();if(!k||k.rangeCount===0)return;let T=k.getRangeAt(0);if(!m.contains(T.startContainer))return;T.deleteContents();let p=v.createTextNode(f);T.insertNode(p),T.setStartAfter(p),T.collapse(!0),k.removeAllRanges(),k.addRange(T),W()},[W]),Pe=X(s=>M(s),[M]),ie=X(()=>E(!0),[E]),ue=X(()=>E(!1),[E]),oe=X(()=>y.current?.focus(),[]),ge=X(()=>y.current?.blur(),[]),U=X(()=>{let s=y.current;return s?Qt(s):""},[]),$=Ii()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:$,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":P,"aria-activedescendant":w,spellCheck:!0,enterKeyHint:"send",onInput:pe,onKeyDown:Pe,onCompositionStart:Ce,onCompositionEnd:he,onPaste:u,onFocus:ie,onBlur:ue},getPlainText:U,focus:oe,blur:ge}}import{jsx as Me,jsxs as ft}from"react/jsx-runtime";function zi(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mi=Ti(function({onSubmit:o,onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,className:i,apiConfig:c,additionalContext:l,language:b,productId:C,visitorId:P,columns:g,pillPlacement:w="dropdown",mode:S="auto",optionsPosition:z="below",animations:M=!0,dropdownTrigger:H,closeDropdownOnBlur:G,showNonTappableOptions:I,showOptionIcons:O=!0,showChipIcons:E=!0,showChipImages:y=!0,showOptionImages:N=!0,showOptionCounts:K=!0,showSkipButton:A,showProducts:Z,productsLayout:ce,productImageFallback:W,autoFocus:pe=!0,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,submitButton:$,resetOnSubmit:s=!0},m){let f=We(null),v=We(null),k=We(()=>{}),T=We(null),p=We(null);$t(()=>{let D=f.current;if(D)return T.current?T.current.setMode(S):T.current=new Di(D,S),()=>{T.current?.destroy(),T.current=null}},[S]);let F=mt(D=>{let te=p.current?.current;te&&(te.focus(),Oi(te,D))},[]),{completedParams:j,skippedParams:Q,identifiedParams:me,isReady:ne,customFields:J,suggestionPills:fe,setActivePill:Se,skipActivePill:x,segments:be,newParamId:we,clearNewParamId:re,placeholderText:h,isFocused:Ie,isDropdownOpen:Ne,isActivePillSelected:ve,isLoading:ee,activeIndex:_e,listboxId:Te,handleTextChange:et,handleKeyDown:xe,setFocused:Ee,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,startEditingParam:Ue,handleCaretAfterInput:d,handleCaretMove:_,replaceEditingRange:R,dropdownProps:at,reset:je,refreshProducts:bt,recordSubmit:wt}=ut({onSubmit:D=>k.current(D),onResult:t,onError:a,optionOverrides:n,maskCompletedText:r,apiConfig:c,additionalContext:l,language:b,productId:C,visitorId:P,columns:g,dropdownTrigger:H,optionsPosition:z,closeDropdownOnBlur:G,showNonTappableOptions:I,showOptionIcons:O,showOptionImages:N,showOptionCounts:K,showSkipButton:A,showProducts:Z,onFocus:Ce,onBlur:he,value:u,completedParams:Pe,onChange:ie,onParamsChange:ue,products:oe,mapProducts:ge,onProductSelect:U,source:"full-sdk",setCursor:F});$t(()=>{if(!we)return;let D=window.setTimeout(()=>re(),650);return()=>window.clearTimeout(D)},[we,re]);let Xt=_e>=0?`${Te}-option-${_e}`:void 0,{inputRef:it,editorProps:Jt,focus:Qe,blur:vt,getPlainText:xt}=Zt({segments:be,newParamId:we,editingParam:Fe,editingIdentified:qe,editingAnchor:tt,caretOffset:Be,placeholderText:h,isFocused:Ie,showChipIcons:E,showChipImages:y,isDropdownOpen:Ne,listboxId:Te,activeDescendantId:Xt,autoFocus:pe,handleTextChange:et,handleKeyDown:xe,handleCaretAfterInput:d,handleCaretMove:_,startEditingParam:Ue,replaceEditingRange:R,setFocused:Ee});p.current=it,Ai(()=>{let D=v.current,te=it.current;if(!D||!te)return;let He=()=>{let kt=D.firstElementChild;if(!kt)return;let ia=kt.getBoundingClientRect(),oa=te.getBoundingClientRect();ia.top>=oa.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};He();let yt=new ResizeObserver(He);return yt.observe(te),()=>yt.disconnect()},[be,fe.length,ee,it]),Ei(m,()=>({focus:Qe,blur:vt,reset:je,refreshProducts:bt,setMode:D=>T.current?.setMode(D),skipActivePill:x}),[Qe,vt,je,bt,x]);let Ye=!!be.length||j.length>0,ot=mt(D=>{if(!Ye)return;let te=xt(),He=Ri(te,j,Q,{identifiedParams:me,isReady:ne,customFields:J});D&&wt(He),o(He),s&&je()},[wt,s,Ye,j,Q,me,ne,J,o,je,xt]);k.current=()=>ot(!1);let ea=mt(D=>{D.target?.closest("[data-aia-pill]")||Qe()},[Qe]),ta=w==="inline",aa=w==="dropdown";return ft("div",{ref:f,className:`magicx-aia ${Ae.container} ${i??""}`,"data-pill-placement":w,"data-options-position":z,"data-animations":M?"on":"off","data-mode":zi(S),children:[Me(pt,{...at,showPills:aa,productsLayout:ce,productImageFallback:W}),ft("div",{className:Ae.inputWrapper,"data-aia-input-wrapper":"",onClick:ea,children:[ft("div",{className:Ae.editorArea,"data-aia-editor":"",children:[Me("div",{...Jt,className:Ae.input,"data-aia-input":""}),ta&&(ee||fe.length>0)&&Me("span",{ref:v,className:Ae.pillListContainer,"data-aia-pill-list-container":"",children:Me(Ze,{pills:fe,activePillIndex:0,activeSelected:ve,onSelectPill:Se,loading:ee})})]}),$===null?null:$===void 0?Me(Gt,{disabled:!Ye,onClick:()=>ot(!0),label:Li(b).submit}):Me("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ae.submitSlot,onClick:D=>{Ye&&(D.stopPropagation(),ot(!0))},children:$})]})]})});export{Mi as AIAutocomplete,pt as AIAutocompleteDropdown,Dn as DATE_RANGE_META_END,On as DATE_RANGE_META_START,Ln as DEFAULT_OPTION_COUNT_UNIT,jn as PRODUCT_PATH_PREFIX,ar as WEEKDAY_LABELS,En as buildSubmitResult,An as cellDay,Rn as cellIso,zn as dateCellMarks,Mn as formatDate,Nn as formatDateRange,Fn as formatOptionCount,Bn as isoDate,Hn as monthLabel,Kn as optionCountLabel,Gn as optionHasImage,Wn as optionImageSources,_n as optionImageSrc,qn as optionLabel,Un as optionsShowLeadingVisuals,Qn as parseDate,Yn as parseLooseDate,Vn as parseLooseDateRange,Zn as productFromMatchedItem,$n as productImageSources,Xn as productsFromCustomFields,Jn as sanitizeOptionIconSvg,er as selectedRangeFor,ut as useAIAutocomplete,tr as visibleDateRange,ir as withSkippedParams};
|
|
2492
|
+
`,document.head.appendChild(e)}var Wt={submitButton:"aia-submitButton-otz7H"};import{jsx as mt}from"react/jsx-runtime";function _t({disabled:e,onClick:n,label:t=yi().submit}){return mt("button",{type:"button","data-aia-submit":"",className:Wt.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),n()},"aria-label":t,children:mt("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":t,children:mt("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as ki,dateSelectionFor as Ci,identifiedParamLabel as Si,withoutTraditionalAutocomplete as Pi}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Qt,useEffect as ze,useRef as F,useState as Ii}from"react";import{useRef as qt}from"react";function Ut(e){let n=qt(e);n.current=e;let t=Object.keys(e??{}).sort().join("\0"),a=qt({key:"",overrides:void 0});if(a.current.key!==t){let o={};for(let r of Object.keys(e??{})){let i=(d,s,f)=>{let C=n.current?.[r];return C?C(d,s,f):[]};o[r]=i}a.current={key:t,overrides:e?o:void 0}}return{overrides:a.current.overrides,key:t}}import{useRef as Vt}from"react";function jt(e){let n=Vt(e);n.current=e;let t=Vt(null);t.current===null&&(t.current={fetch:(o,r)=>{let i=n.current;return i?i.fetch(o,r):Promise.reject(new Error("products config removed"))},transform:o=>n.current?.transform(o)??[],get limit(){return n.current?.limit}});let a=e!==void 0;return{config:a?t.current:void 0,enabled:a}}var Ti={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 gt({onSubmit:e,onResult:n,onError:t,optionOverrides:a,maskCompletedText:o,apiConfig:r,additionalContext:i,language:d,currency:s,productId:f,visitorId:C,columns:S=2,dropdownTrigger:g,optionsPosition:v,closeDropdownOnBlur:P,showNonTappableOptions:E,showOptionIcons:M,showOptionImages:H,showOptionCounts:G,showSkipButton:T,showProducts:A,productImageFallback:O="image",onFocus:y,onBlur:_,value:B,completedParams:I,onChange:Q,onParamsChange:ie,products:q,mapProducts:oe,onProductSelect:pe,source:Pe,setCursor:he}){let u=F(null),[ue,me]=Ii(null),ne=F(e);ne.current=e;let ge=F(n);ge.current=n;let U=F(t);U.current=t;let re=F(Q);re.current=Q;let l=F(ie);l.current=ie;let m=F(y);m.current=y;let b=F(_);b.current=_;let w=F(he);w.current=he;let k=F(pe);k.current=pe;let z=F(C);z.current=C;let p=F(()=>{let c=z.current;return typeof c=="function"?c():c}).current,N=jt(q),Y=F(oe);Y.current=oe;let $=F((c,W)=>{let R=Y.current;return R?R(c,W):c}).current,fe=oe?$:void 0,Z=Ut(a);ze(()=>{if(typeof document>"u")return;let c=new ki(document.createElement("div"),{renderMode:"headless",apiConfig:r,additionalContext:i,language:d,currency:s,productId:f,visitorId:p,optionOverrides:Z.overrides,maskCompletedText:o,columns:S,dropdownTrigger:g,optionsPosition:v,closeDropdownOnBlur:P,showNonTappableOptions:E,showProducts:A,source:Pe,value:B,completedParams:I,onSubmit:(...R)=>ne.current?.(...R),onResult:(...R)=>ge.current?.(...R),onError:(...R)=>U.current?.(...R),onChange:(...R)=>re.current?.(...R),onParamsChange:(...R)=>l.current?.(...R),onFocus:()=>m.current?.(),onBlur:()=>b.current?.(),onProductSelect:R=>k.current?.(R),setCursor:R=>w.current?.(R),products:N.config,mapProducts:fe});u.current=c,me(c.getState());let W=c.subscribe(R=>me(R));return()=>{W(),c.destroy(),u.current===c&&(u.current=null)}},[]),ze(()=>{B!==void 0&&u.current?.setValue(B)},[B]),ze(()=>{I!==void 0&&u.current?.setCompletedParams(I)},[I]);let be=JSON.stringify(r??null),we;try{we=JSON.stringify(i??null)}catch{we="[unstringifiable]"}ze(()=>{u.current?.update({apiConfig:r,additionalContext:i,language:d,currency:s,productId:f,optionOverrides:Z.overrides,dropdownTrigger:g,optionsPosition:v,closeDropdownOnBlur:P,showNonTappableOptions:E,showProducts:A})},[be,we,d,s?.code,s?.rate,s?.country,f,Z.key,g,v,P,E,A]);let ve=F(!1);ze(()=>{if(!ve.current){ve.current=!0;return}u.current?.update({products:N.config})},[N.enabled]),ze(()=>{u.current?.update({mapProducts:fe})},[fe]);let xe=F(null);xe.current===null&&(xe.current={handleTextChange:c=>u.current?.handleTextChange(c),handleKeyDown:c=>{let W="nativeEvent"in c?c.nativeEvent:c;u.current?.handleKeyDown(W)},setFocused:c=>u.current?.setFocused(c),startEditingParam:c=>u.current?.startEditingParam(c),exitEditMode:()=>u.current?.exitEditMode(),handleCaretAfterInput:c=>u.current?.handleCaretAfterInput(c),handleCaretMove:c=>u.current?.handleCaretMove(c),replaceEditingRange:c=>u.current?.replaceEditingRange(c)??!1,setActivePill:c=>u.current?.setActivePill(c),skipActivePill:()=>u.current?.skipActivePill(),removeLastParam:()=>u.current?.removeLastParam(),clearNewParamId:()=>u.current?.clearNewParamId(),reset:()=>u.current?.reset(),refreshProducts:()=>u.current?.refreshProducts(),recordSubmit:c=>u.current?.recordSubmit(c),selectOption:c=>u.current?.selectOption(c),selectProduct:c=>u.current?.selectProduct(c),setActiveDropdownIndex:c=>u.current?.setActiveDropdownIndex(c),clearHighlight:c=>u.current?.clearHighlight(c),showPreviousMonth:()=>u.current?.showPreviousMonth(),showNextMonth:()=>u.current?.showNextMonth(),handleFocus:()=>u.current?.setFocused(!0),handleBlur:()=>u.current?.setFocused(!1)});let x=xe.current,ye=Qt(c=>{let W=c.target.value,it=W.length>0&&!c.nativeEvent?.isComposing&&W[0]!==W[0].toUpperCase()?W[0].toUpperCase()+W.slice(1):W;u.current?.handleTextChange(it)},[]),ke=Qt(c=>{u.current?.handleKeyDown(c.nativeEvent)},[]),se=u.current,h=ue??Ti,Ae=B!==void 0?B:h.text,Re=I!==void 0?I:h.completedParams,J=h.actionableSuggestions,Fe=J[0],qe=Pi(J),Ie=se?.listboxId??"",tt=h.activeDropdownIndex>=0&&se?`${Ie}-option-${h.activeDropdownIndex}`:void 0,Ce=h.editingParam,Te=h.editingIdentified,He=Ce?{parameter:Ce.suggestionParameter,text:Ce.suggestionPlaceholder,required:!0,options:Ce.options}:Te?{parameter:Te.parameter,text:Si(Te.parameter),required:!0,options:[]}:null,Ue=h.dropdownSuggestion??He??Fe,at=He?[He]:J,Be=Ci(h),Ve=!se||h.dropdownLoading;return{completedParams:Re,skippedParams:h.skippedParams,identifiedParams:h.identifiedParams,suggestionPills:qe,setActivePill:x.setActivePill,skipActivePill:x.skipActivePill,removeLastParam:x.removeLastParam,segments:h.segments,newParamId:h.newParamId,clearNewParamId:x.clearNewParamId,suggestions:h.suggestions,activeIndex:h.activeDropdownIndex,isReady:h.isReady,isLoading:Ve,isFocused:h.isFocused,isDropdownOpen:h.isDropdownOpen,isActivePillSelected:h.isActivePillSelected,placeholderText:h.placeholderText,listboxId:Ie,error:h.error,products:h.products,customFields:h.customFields,selectProduct:x.selectProduct,handleTextChange:x.handleTextChange,handleKeyDown:x.handleKeyDown,setFocused:x.setFocused,editingParam:Ce,editingIdentified:Te,editingAnchor:h.editingAnchor,caretOffset:h.caretOffset,startEditingParam:x.startEditingParam,exitEditMode:x.exitEditMode,handleCaretAfterInput:x.handleCaretAfterInput,handleCaretMove:x.handleCaretMove,replaceEditingRange:x.replaceEditingRange,inputProps:{value:Ae,placeholder:h.placeholderText||void 0,onChange:ye,onKeyDown:ke,onFocus:x.handleFocus,onBlur:x.handleBlur,role:"combobox","aria-expanded":h.isDropdownOpen,"aria-activedescendant":tt,"aria-autocomplete":"list","aria-controls":Ie},reset:x.reset,refreshProducts:x.refreshProducts,recordSubmit:x.recordSubmit,dropdownProps:{suggestions:Ue?[{...Ue,options:h.dropdownOptions}]:[],activeIndex:h.activeDropdownIndex,onSelect:x.selectOption,onHighlight:x.setActiveDropdownIndex,onUnhighlight:x.clearHighlight,isOpen:h.isDropdownOpen,id:Ie,pills:at,activeSelected:h.isActivePillSelected,onPillClick:x.setActivePill,onSkip:x.skipActivePill,showSkipButton:(T??!0)&&!Ce&&!Te,showOptionIcons:M??!0,showOptionImages:H??!0,showOptionCounts:G??!0,skipDisabled:h.inSelectionAnimation,isLoading:Ve,skeletonExiting:h.skeletonExiting,isInputEmpty:Ae.trim().length===0,language:d,products:h.products,productImageFallback:O,onProductSelect:x.selectProduct,onProductFocusChange:x.setFocused,formatType:h.activeFormatType,dateView:h.dateView,selectedDateIso:Be.selectedIso,selectedDateRange:Be.selectedRange,dateRangeStart:Be.rangeStart,onPreviousMonth:x.showPreviousMonth,onNextMonth:x.showNextMonth,optionsPosition:v??"below"}}}import{chipIdFromTap as Ei,extractPlainText as Yt,getCursorOffset as $t,keepCaretOnChip as Ai,plainTextLength as Ri,renderEditableContent as Di,setCursorOffset as Zt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as X,useEffect as Je,useLayoutEffect as ft,useRef as Me}from"react";var et;function Oi(){if(et!==void 0)return et;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),et=e.contentEditable==="plaintext-only",et}function Xt(e){let{segments:n,showChipIcons:t=!0,showChipImages:a=!0,newParamId:o,editingParam:r,editingIdentified:i,editingAnchor:d,caretOffset:s,placeholderText:f,isFocused:C,isDropdownOpen:S,listboxId:g,activeDescendantId:v,autoFocus:P,handleTextChange:E,handleKeyDown:M,handleCaretAfterInput:H,handleCaretMove:G,startEditingParam:T,replaceEditingRange:A,setFocused:O}=e,y=Me(null),_=Me(!1),B=Me(""),I=Me(""),Q=Me(null),ie=Me(0);Q.current=s,Je(()=>{if(!P)return;let l=y.current;if(!l)return;document.activeElement===l?O(!0):l.focus();let m=l.ownerDocument??document,b=m.getSelection(),w=b&&b.rangeCount>0&&l.contains(b.anchorNode);if(b&&!w){let k=m.createRange();k.selectNodeContents(l),k.collapse(!0),b.removeAllRanges(),b.addRange(k)}},[P,O]),Je(()=>{let l=y.current;if(!l)return;let m=l.ownerDocument??document,b=()=>{let w=m.getSelection();if(!w||w.rangeCount===0||!w.anchorNode||!l.contains(w.anchorNode))return;let k=w.anchorNode,z=k.nodeType===Node.ELEMENT_NODE?k:k.parentElement,N=(w.isCollapsed?z?.closest("strong[data-param-id]"):null)?.dataset.paramId??null,Y=r?.id??i?.id??null;if(N&&N!==Y){T(N);return}performance.now()-ie.current<50||G($t(l))};return m.addEventListener("selectionchange",b),()=>m.removeEventListener("selectionchange",b)},[r,i,T,G]),Je(()=>{let l=y.current;if(!l)return;let m=b=>{let w=Ei(l,b.target);w&&(T(w),Ai(l,w))};return l.addEventListener("click",m),()=>l.removeEventListener("click",m)},[T]),ft(()=>{let l=y.current;l&&Di({input:l,segments:n,newParamId:o,editingParamId:r?.id??null,placeholderText:f??"",isFocused:C,showChipIcons:t,showChipImages:a})},[n,o,r,f,C,t,a]),ft(()=>{let l=B.current,m=o??"";if(B.current=m,!m||m===l)return;let b=y.current;if(!b)return;b.focus();let w=Q.current??Ri(b);Zt(b,w)},[o]),ft(()=>{let l=I.current,m=r?.id??"";if(I.current=m,!m||m===l||d==null)return;let b=y.current;b&&Zt(b,d)},[r,d]);let q=X(()=>{if(_.current)return;let l=y.current;if(!l)return;let m=Yt(l),w=m.length>0&&m[0]!==m[0].toUpperCase()?m[0].toUpperCase()+m.slice(1):m;E(w)},[E]),oe=X(()=>{ie.current=performance.now(),q();let l=y.current;l&&H($t(l))},[q,H]);Je(()=>{let l=y.current;if(!l)return;let m=b=>{let w=b,k=w.inputType;if(k==="insertParagraph"||k==="insertLineBreak"||k==="insertFromDrop"){b.preventDefault();return}if(k.startsWith("insert")||k.startsWith("delete")){let z=k.startsWith("delete")?"":w.data??"";A(z)&&b.preventDefault()}};return l.addEventListener("beforeinput",m),()=>l.removeEventListener("beforeinput",m)},[A]);let pe=X(()=>{_.current=!0,y.current?.setAttribute("data-aia-composing","true")},[]),Pe=X(()=>{_.current=!1,y.current?.removeAttribute("data-aia-composing"),q()},[q]),he=X(l=>{l.preventDefault();let m=y.current;if(!m)return;let b=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!b)return;let w=m.ownerDocument??document,k=w.getSelection();if(!k||k.rangeCount===0)return;let z=k.getRangeAt(0);if(!m.contains(z.startContainer))return;z.deleteContents();let p=w.createTextNode(b);z.insertNode(p),z.setStartAfter(p),z.collapse(!0),k.removeAllRanges(),k.addRange(z),q()},[q]),u=X(l=>M(l),[M]),ue=X(()=>O(!0),[O]),me=X(()=>O(!1),[O]),ne=X(()=>y.current?.focus(),[]),ge=X(()=>y.current?.blur(),[]),U=X(()=>{let l=y.current;return l?Yt(l):""},[]),re=Oi()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:re,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":g,"aria-expanded":S,"aria-activedescendant":v,spellCheck:!0,enterKeyHint:"send",onInput:oe,onKeyDown:u,onCompositionStart:pe,onCompositionEnd:Pe,onPaste:he,onFocus:ue,onBlur:me},getPlainText:U,focus:ne,blur:ge}}import{jsx as Ne,jsxs as wt}from"react/jsx-runtime";function Ki(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Gi=Li(function({onSubmit:n,onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,className:i,apiConfig:d,additionalContext:s,language:f,currency:C,productId:S,visitorId:g,columns:v,pillPlacement:P="dropdown",mode:E="auto",optionsPosition:M="below",animations:H=!0,dropdownTrigger:G,closeDropdownOnBlur:T,showNonTappableOptions:A,showOptionIcons:O=!0,showChipIcons:y=!0,showChipImages:_=!0,showOptionImages:B=!0,showOptionCounts:I=!0,showSkipButton:Q,showProducts:ie,productsLayout:q,productImageFallback:oe,autoFocus:pe=!0,onFocus:Pe,onBlur:he,value:u,completedParams:ue,onChange:me,onParamsChange:ne,products:ge,mapProducts:U,onProductSelect:re,submitButton:l,resetOnSubmit:m=!0},b){let w=_e(null),k=_e(null),z=_e(()=>{}),p=_e(null),N=_e(null);Jt(()=>{let D=w.current;if(D)return p.current?p.current.setMode(E):p.current=new Fi(D,E),()=>{p.current?.destroy(),p.current=null}},[E]);let Y=bt(D=>{let ee=N.current?.current;ee&&(ee.focus(),Hi(ee,D))},[]),{completedParams:$,skippedParams:fe,identifiedParams:Z,isReady:be,customFields:we,suggestionPills:ve,setActivePill:xe,skipActivePill:x,segments:ye,newParamId:ke,clearNewParamId:se,placeholderText:h,isFocused:Ae,isDropdownOpen:Re,isActivePillSelected:J,isLoading:Fe,activeIndex:qe,listboxId:Ie,handleTextChange:tt,handleKeyDown:Ce,setFocused:Te,editingParam:He,editingIdentified:Ue,editingAnchor:at,caretOffset:Be,startEditingParam:Ve,handleCaretAfterInput:c,handleCaretMove:W,replaceEditingRange:R,dropdownProps:it,reset:je,refreshProducts:vt,recordSubmit:xt}=gt({onSubmit:D=>z.current(D),onResult:t,onError:a,optionOverrides:o,maskCompletedText:r,apiConfig:d,additionalContext:s,language:f,currency:C,productId:S,visitorId:g,columns:v,dropdownTrigger:G,optionsPosition:M,closeDropdownOnBlur:T,showNonTappableOptions:A,showOptionIcons:O,showOptionImages:B,showOptionCounts:I,showSkipButton:Q,showProducts:ie,onFocus:Pe,onBlur:he,value:u,completedParams:ue,onChange:me,onParamsChange:ne,products:ge,mapProducts:U,onProductSelect:re,source:"full-sdk",setCursor:Y});Jt(()=>{if(!ke)return;let D=window.setTimeout(()=>se(),650);return()=>window.clearTimeout(D)},[ke,se]);let ea=qe>=0?`${Ie}-option-${qe}`:void 0,{inputRef:ot,editorProps:ta,focus:Qe,blur:yt,getPlainText:kt}=Xt({segments:ye,newParamId:ke,editingParam:He,editingIdentified:Ue,editingAnchor:at,caretOffset:Be,placeholderText:h,isFocused:Ae,showChipIcons:y,showChipImages:_,isDropdownOpen:Re,listboxId:Ie,activeDescendantId:ea,autoFocus:pe,handleTextChange:tt,handleKeyDown:Ce,handleCaretAfterInput:c,handleCaretMove:W,startEditingParam:Ve,replaceEditingRange:R,setFocused:Te});N.current=ot,Mi(()=>{let D=k.current,ee=ot.current;if(!D||!ee)return;let Ke=()=>{let St=D.firstElementChild;if(!St)return;let na=St.getBoundingClientRect(),ra=ee.getBoundingClientRect();na.top>=ra.bottom-2?D.setAttribute("data-aia-pill-wrapped",""):D.removeAttribute("data-aia-pill-wrapped")};Ke();let Ct=new ResizeObserver(Ke);return Ct.observe(ee),()=>Ct.disconnect()},[ye,ve.length,Fe,ot]),zi(b,()=>({focus:Qe,blur:yt,reset:je,refreshProducts:vt,setMode:D=>p.current?.setMode(D),skipActivePill:x}),[Qe,yt,je,vt,x]);let Ye=!!ye.length||$.length>0,nt=bt(D=>{if(!Ye)return;let ee=kt(),Ke=Ni(ee,$,fe,{identifiedParams:Z,isReady:be,customFields:we});D&&xt(Ke),n(Ke),m&&je()},[xt,m,Ye,$,fe,Z,be,we,n,je,kt]);z.current=()=>nt(!1);let aa=bt(D=>{D.target?.closest("[data-aia-pill]")||Qe()},[Qe]),ia=P==="inline",oa=P==="dropdown";return wt("div",{ref:w,className:`magicx-aia ${Ee.container} ${i??""}`,"data-pill-placement":P,"data-options-position":M,"data-animations":H?"on":"off","data-mode":Ki(E),children:[Ne(ut,{...it,showPills:oa,productsLayout:q,productImageFallback:oe}),wt("div",{className:Ee.inputWrapper,"data-aia-input-wrapper":"",onClick:aa,children:[wt("div",{className:Ee.editorArea,"data-aia-editor":"",children:[Ne("div",{...ta,className:Ee.input,"data-aia-input":""}),ia&&(Fe||ve.length>0)&&Ne("span",{ref:k,className:Ee.pillListContainer,"data-aia-pill-list-container":"",children:Ne(Ze,{pills:ve,activePillIndex:0,activeSelected:J,onSelectPill:xe,loading:Fe})})]}),l===null?null:l===void 0?Ne(_t,{disabled:!Ye,onClick:()=>nt(!0),label:Bi(f).submit}):Ne("span",{"data-aia-submit":"","data-aia-submit-slot":"",className:Ee.submitSlot,onClick:D=>{Ye&&(D.stopPropagation(),nt(!0))},children:l})]})]})});export{Gi as AIAutocomplete,ut as AIAutocompleteDropdown,Bn as DATE_RANGE_META_END,Kn as DATE_RANGE_META_START,Gn as DEFAULT_OPTION_COUNT_UNIT,er as PRODUCT_PATH_PREFIX,cr as WEEKDAY_LABELS,Nn as buildSubmitResult,Fn as cellDay,Hn as cellIso,Wn as dateCellMarks,_n as formatDate,qn as formatDateRange,Un as formatOptionCount,Vn as isoDate,jn as monthLabel,Qn as optionCountLabel,Yn as optionHasImage,$n as optionImageSources,Zn as optionImageSrc,Xn as optionLabel,Jn as optionsShowLeadingVisuals,tr as parseDate,ar as parseLooseDate,ir as parseLooseDateRange,or as productFromMatchedItem,nr as productImageSources,rr as productsFromCustomFields,sr as sanitizeOptionIconSvg,lr as selectedRangeFor,gt as useAIAutocomplete,dr as visibleDateRange,pr as withSkippedParams};
|
|
2377
2493
|
//# sourceMappingURL=index.mjs.map
|