@magicx-eng/ai-autocomplete-react 0.10.1 → 0.12.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 +2 -0
- package/dist/index.d.mts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -229,6 +229,8 @@ function App() {
|
|
|
229
229
|
| `onSubmit` | `(result: AutocompleteResult) => void` | **required** | Called on Enter or submit button. |
|
|
230
230
|
| `onError?` | `(error: Error) => void` | — | Called when a fetch fails. |
|
|
231
231
|
| `apiConfig?` | `APIConfig` | — | Runtime API configuration (see below). |
|
|
232
|
+
| `additionalContext?` | `Record<string, unknown>` | — | Optional user context. Include whatever you know about the user (a profile, preferences, workspace, anything) to personalize suggested parameters and options to them. |
|
|
233
|
+
| `generateStartingStateOptions?` | `boolean` | `false` | When `true`, each time the query is empty, the initial suggestions are generated fresh — personalized to `additionalContext` when set — instead of the fixed defaults. The initial placeholder text itself is unchanged. |
|
|
232
234
|
| `optionOverrides?` | `Record<string, (query: string) => SuggestionOption[]>` | — | Override options per suggestion type. |
|
|
233
235
|
| `maskCompletedText?` | `boolean` | `false` | When `true`, omits completed params' literal text from API requests (for masking PII/sensitive values from the server). |
|
|
234
236
|
| `className?` | `string` | — | CSS class applied to the container. |
|
package/dist/index.d.mts
CHANGED
|
@@ -23,6 +23,21 @@ interface AIAutocompleteProps {
|
|
|
23
23
|
maskCompletedText?: boolean;
|
|
24
24
|
className?: string;
|
|
25
25
|
apiConfig?: APIConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Optional user context. Include whatever you know about the user — a
|
|
28
|
+
* profile, preferences, workspace, anything — to personalize suggested
|
|
29
|
+
* parameters and options to them. May be re-created on every render; only
|
|
30
|
+
* a genuinely different value reaches the core (same JSON.stringify
|
|
31
|
+
* comparison used for `apiConfig`).
|
|
32
|
+
*/
|
|
33
|
+
additionalContext?: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* When true, each time the query is empty, the initial suggestions are
|
|
36
|
+
* generated fresh — personalized to `additionalContext` when set —
|
|
37
|
+
* instead of the fixed defaults. The initial placeholder text itself is
|
|
38
|
+
* unchanged. Default: false.
|
|
39
|
+
*/
|
|
40
|
+
generateStartingStateOptions?: boolean;
|
|
26
41
|
columns?: number;
|
|
27
42
|
/** Where to render unfilled pills. "dropdown" (default) renders them above the options grid; "inline" renders them in the input. */
|
|
28
43
|
pillPlacement?: "inline" | "dropdown" | "hidden";
|
|
@@ -99,6 +114,21 @@ interface UseAIAutocompleteOptions {
|
|
|
99
114
|
optionOverrides?: OptionOverrides;
|
|
100
115
|
maskCompletedText?: boolean;
|
|
101
116
|
apiConfig?: APIConfig;
|
|
117
|
+
/**
|
|
118
|
+
* Optional user context. Include whatever you know about the user — a
|
|
119
|
+
* profile, preferences, workspace, anything — to personalize suggested
|
|
120
|
+
* parameters and options to them. May be re-created on every render; only
|
|
121
|
+
* a genuinely different value reaches the core (same JSON.stringify
|
|
122
|
+
* comparison used for `apiConfig`).
|
|
123
|
+
*/
|
|
124
|
+
additionalContext?: Record<string, unknown>;
|
|
125
|
+
/**
|
|
126
|
+
* When true, each time the query is empty, the initial suggestions are
|
|
127
|
+
* generated fresh — personalized to `additionalContext` when set —
|
|
128
|
+
* instead of the fixed defaults. The initial placeholder text itself is
|
|
129
|
+
* unchanged. Default: false.
|
|
130
|
+
*/
|
|
131
|
+
generateStartingStateOptions?: boolean;
|
|
102
132
|
columns?: number;
|
|
103
133
|
/**
|
|
104
134
|
* SDK surface identifier for telemetry. Set automatically by the Tier 1
|
|
@@ -330,6 +360,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
330
360
|
|
|
331
361
|
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, skipDisabled, activeSelected, isLoading, isInputEmpty, products, onProductSelect, onProductFocusChange, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
332
362
|
|
|
333
|
-
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showSkipButton, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
363
|
+
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, generateStartingStateOptions, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showSkipButton, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
334
364
|
|
|
335
365
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,21 @@ interface AIAutocompleteProps {
|
|
|
23
23
|
maskCompletedText?: boolean;
|
|
24
24
|
className?: string;
|
|
25
25
|
apiConfig?: APIConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Optional user context. Include whatever you know about the user — a
|
|
28
|
+
* profile, preferences, workspace, anything — to personalize suggested
|
|
29
|
+
* parameters and options to them. May be re-created on every render; only
|
|
30
|
+
* a genuinely different value reaches the core (same JSON.stringify
|
|
31
|
+
* comparison used for `apiConfig`).
|
|
32
|
+
*/
|
|
33
|
+
additionalContext?: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* When true, each time the query is empty, the initial suggestions are
|
|
36
|
+
* generated fresh — personalized to `additionalContext` when set —
|
|
37
|
+
* instead of the fixed defaults. The initial placeholder text itself is
|
|
38
|
+
* unchanged. Default: false.
|
|
39
|
+
*/
|
|
40
|
+
generateStartingStateOptions?: boolean;
|
|
26
41
|
columns?: number;
|
|
27
42
|
/** Where to render unfilled pills. "dropdown" (default) renders them above the options grid; "inline" renders them in the input. */
|
|
28
43
|
pillPlacement?: "inline" | "dropdown" | "hidden";
|
|
@@ -99,6 +114,21 @@ interface UseAIAutocompleteOptions {
|
|
|
99
114
|
optionOverrides?: OptionOverrides;
|
|
100
115
|
maskCompletedText?: boolean;
|
|
101
116
|
apiConfig?: APIConfig;
|
|
117
|
+
/**
|
|
118
|
+
* Optional user context. Include whatever you know about the user — a
|
|
119
|
+
* profile, preferences, workspace, anything — to personalize suggested
|
|
120
|
+
* parameters and options to them. May be re-created on every render; only
|
|
121
|
+
* a genuinely different value reaches the core (same JSON.stringify
|
|
122
|
+
* comparison used for `apiConfig`).
|
|
123
|
+
*/
|
|
124
|
+
additionalContext?: Record<string, unknown>;
|
|
125
|
+
/**
|
|
126
|
+
* When true, each time the query is empty, the initial suggestions are
|
|
127
|
+
* generated fresh — personalized to `additionalContext` when set —
|
|
128
|
+
* instead of the fixed defaults. The initial placeholder text itself is
|
|
129
|
+
* unchanged. Default: false.
|
|
130
|
+
*/
|
|
131
|
+
generateStartingStateOptions?: boolean;
|
|
102
132
|
columns?: number;
|
|
103
133
|
/**
|
|
104
134
|
* SDK surface identifier for telemetry. Set automatically by the Tier 1
|
|
@@ -330,6 +360,6 @@ declare const AIAutocomplete: react.ForwardRefExoticComponent<AIAutocompleteProp
|
|
|
330
360
|
|
|
331
361
|
declare function AIAutocompleteDropdown({ suggestions, activeIndex, onSelect, onHighlight, isOpen, id, className, pills, onPillClick, showPills, onSkip, showSkipButton, skipDisabled, activeSelected, isLoading, isInputEmpty, products, onProductSelect, onProductFocusChange, optionsPosition, mode, }: AIAutocompleteDropdownProps): react_jsx_runtime.JSX.Element;
|
|
332
362
|
|
|
333
|
-
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showSkipButton, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
363
|
+
declare function useAIAutocomplete({ onSubmit, onError, optionOverrides, maskCompletedText, apiConfig, additionalContext, generateStartingStateOptions, columns, dropdownTrigger, optionsPosition, closeDropdownOnBlur, showNonTappableOptions, showSkipButton, onFocus, onBlur, value: controlledValue, completedParams: controlledParams, onChange: onChangeProp, onParamsChange, products, onProductSelect, source, setCursor, }: UseAIAutocompleteOptions): UseAIAutocompleteReturn;
|
|
334
364
|
|
|
335
365
|
export { AIAutocomplete, AIAutocompleteDropdown, type AIAutocompleteDropdownProps, type AIAutocompleteHandle, type AIAutocompleteProps, type UseAIAutocompleteOptions, type UseAIAutocompleteReturn, useAIAutocomplete };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Ve=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Et=Object.prototype.hasOwnProperty;var Dt=(e,a)=>{for(var t in a)Ve(e,t,{get:a[t],enumerable:!0})},Rt=(e,a,t,r)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of Ct(a))!Et.call(e,n)&&n!==t&&Ve(e,n,{get:()=>a[n],enumerable:!(r=At(a,n))||r.enumerable});return e};var Tt=e=>Rt(Ve({},"__esModule",{value:!0}),e);var Kt={};Dt(Kt,{AIAutocomplete:()=>xt,AIAutocompleteDropdown:()=>Fe,buildSubmitResult:()=>He.buildSubmitResult,useAIAutocomplete:()=>Ne,withSkippedParams:()=>He.withSkippedParams});module.exports=Tt(Kt);var He=require("@magicx-eng/ai-autocomplete-vanilla");var S=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-67791514")){let e=document.createElement("style");e.id="ac-style-67791514",e.textContent=`.AIAutocomplete-module_container_KKjFU {
|
|
2
2
|
position: relative;
|
|
3
3
|
/* Inherits the host page's font by default. Consumers can pin a specific
|
|
4
4
|
font on the library via \`--aia-font-family: 'Custom Font'\` without
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
opacity: 0;
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
`,document.head.appendChild(e)}var me={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};var
|
|
182
|
+
`,document.head.appendChild(e)}var me={container:"AIAutocomplete-module_container_KKjFU",inputWrapper:"AIAutocomplete-module_inputWrapper_FLq1b",editorArea:"AIAutocomplete-module_editorArea_7rBWq",input:"AIAutocomplete-module_input_IW-P-",pillListContainer:"AIAutocomplete-module_pillListContainer_h92IA",submitSlot:"AIAutocomplete-module_submitSlot_GhuCM",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};var we=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
183
183
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
184
184
|
* Consumer CSS always wins without !important.
|
|
185
185
|
*
|
|
@@ -665,7 +665,7 @@
|
|
|
665
665
|
opacity: 0.25;
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
|
-
`,document.head.appendChild(e)}var
|
|
668
|
+
`,document.head.appendChild(e)}var de={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",pillScroll:"AIAutocompleteDropdown-module_pillScroll_Tpzus",skip:"AIAutocompleteDropdown-module_skip_7-olS",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};var be=require("@magicx-eng/ai-autocomplete-vanilla"),Te=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
|
|
669
669
|
.aia-cluster {
|
|
670
670
|
display: flex;
|
|
671
671
|
flex-wrap: wrap;
|
|
@@ -707,7 +707,7 @@
|
|
|
707
707
|
justify-content: space-around;
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
-
`,document.head.appendChild(e)}var
|
|
710
|
+
`,document.head.appendChild(e)}var qe=require("react/jsx-runtime");function Pe({gap:e,align:a="center",justify:t="start",noWrap:r=!1,inline:n=!1,className:l,children:i,...g}){let w=e?{"--aia-cluster-gap":e}:void 0,y={className:l?`aia-cluster ${l}`:"aia-cluster","data-align":a,"data-justify":t,"data-nowrap":r||void 0,"data-inline":n||void 0,style:w,...g};return n?(0,qe.jsx)("span",{...y,children:i}):(0,qe.jsx)("div",{...y,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
|
|
711
711
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
712
712
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
713
713
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -837,7 +837,7 @@
|
|
|
837
837
|
justify-content: flex-end;
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
`,document.head.appendChild(e)}var
|
|
840
|
+
`,document.head.appendChild(e)}var ie={footer:"DropdownFooter-module_footer_qQQ7x",hintGroup:"DropdownFooter-module_hintGroup_ZzbPf",brandLink:"DropdownFooter-module_brandLink_r4f3R",key:"DropdownFooter-module_key_Bz1H-",hint:"DropdownFooter-module_hint_GKEOH",brand:"DropdownFooter-module_brand_Al-lR",badge:"DropdownFooter-module_badge_Fk9vg",row:"DropdownFooter-module_row_BgZ6Q"};var Q=require("react/jsx-runtime");function at({isOptionHighlighted:e=!1,isInputEmpty:a=!1}){let{key:t,hint:r}=(0,be.getFooterHint)(e,a),[n,l]=(0,Te.useState)(be.ATTRIBUTION_URL);return(0,Te.useEffect)(()=>{l((0,be.buildAttributionUrl)())},[]),(0,Q.jsx)("footer",{className:ie.footer,"data-aia-footer":"",children:(0,Q.jsxs)(Pe,{justify:"between",noWrap:!0,className:ie.row,children:[(0,Q.jsxs)(Pe,{gap:"5px",className:ie.hintGroup,children:[(0,Q.jsx)("kbd",{className:ie.key,children:t}),(0,Q.jsx)("span",{className:ie.hint,children:r})]}),(0,Q.jsxs)("a",{className:ie.brandLink,href:n,target:"_blank",rel:"noopener noreferrer",children:[(0,Q.jsx)("span",{className:ie.brand,children:"AI"}),(0,Q.jsx)("span",{className:ie.badge,children:"Autocomplete"})]})]})})}if(typeof document<"u"&&!document.getElementById("ac-style-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill,
|
|
841
841
|
no outline. ~28px via 6px padding + 14px text + the 1px border (border-box).
|
|
842
842
|
The border is kept as a 1px transparent line so the box stays the same size
|
|
843
843
|
as it was when the outline was dashed. */
|
|
@@ -894,7 +894,7 @@
|
|
|
894
894
|
opacity: 0;
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
|
-
`,document.head.appendChild(e)}var
|
|
897
|
+
`,document.head.appendChild(e)}var pe={pill:"ParamPill-module_pill_6Ga7S",fadeIn:"ParamPill-module_fadeIn_Ux4eQ",rounded:"ParamPill-module_rounded_y7xA9",skeleton:"ParamPill-module_skeleton_57P0T",skeletonPulse:"ParamPill-module_skeletonPulse_xGcUy"};var it=require("react/jsx-runtime"),$e={selected:1,first:.7,next:.4,last:.2};function ot({label:e,state:a,rounded:t,loading:r,onClick:n}){let l=[pe.pill,t?pe.rounded:"",r?pe.skeleton:""].filter(Boolean).join(" ");return(0,it.jsx)("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:l,style:{opacity:$e[a]},onMouseDown:i=>i.preventDefault(),onClick:r?void 0:n,disabled:r,children:e})}if(typeof document<"u"&&!document.getElementById("ac-style-0fcb7940")){let e=document.createElement("style");e.id="ac-style-0fcb7940",e.textContent=`.PillList-module_list_qvLqO {
|
|
898
898
|
position: relative;
|
|
899
899
|
z-index: 1;
|
|
900
900
|
pointer-events: auto;
|
|
@@ -904,7 +904,7 @@
|
|
|
904
904
|
align-items: center;
|
|
905
905
|
vertical-align: middle;
|
|
906
906
|
}
|
|
907
|
-
`,document.head.appendChild(e)}var
|
|
907
|
+
`,document.head.appendChild(e)}var je={list:"PillList-module_list_qvLqO"};var Ie=require("react/jsx-runtime"),Lt=[125,69];function rt(e){return e===0?"first":e===1?"next":"last"}function Le({pills:e,activePillIndex:a,onSelectPill:t,activeSelected:r,rounded:n,loading:l}){return l&&e.length===0?(0,Ie.jsx)("span",{className:je.list,"data-aia-pill-list-loading":"",children:Lt.map((i,g)=>(0,Ie.jsx)("span",{"data-aia-pill-skeleton":"",className:`${pe.pill} ${n?pe.rounded:""} ${pe.skeleton}`,style:{width:i,opacity:$e[rt(g)]}},`skel-${i}`))}):(0,Ie.jsx)("span",{className:je.list,"data-aia-pill-list-loading":l?"":void 0,children:e.map((i,g)=>{let w=!!r&&g===a;return(0,Ie.jsx)(ot,{label:i.text,state:w?"selected":rt(g),selected:w,rounded:n,loading:l,onClick:()=>t(g)},`${i.type}-${i.text}`)})})}if(typeof document<"u"&&!document.getElementById("ac-style-fef1688d")){let e=document.createElement("style");e.id="ac-style-fef1688d",e.textContent=`/* Product strip \u2014 the React counterpart of the vanilla core's strip rules
|
|
908
908
|
(packages/vanilla/src/styles.css). Same tokens, same defaults, so a consumer
|
|
909
909
|
theming one package sees the same result in the other.
|
|
910
910
|
|
|
@@ -1071,7 +1071,7 @@
|
|
|
1071
1071
|
var(--aia-option-color-selected, var(--aia-color-text-default, #fff))
|
|
1072
1072
|
);
|
|
1073
1073
|
}
|
|
1074
|
-
`,document.head.appendChild(e)}var
|
|
1074
|
+
`,document.head.appendChild(e)}var U={section:"ProductStrip-module_section_Hugfg",label:"ProductStrip-module_label_nuc93",row:"ProductStrip-module_row_WDVBX",card:"ProductStrip-module_card_JBGYT",media:"ProductStrip-module_media_RrbGe",image:"ProductStrip-module_image_5pNL7",body:"ProductStrip-module_body_ly032",vendor:"ProductStrip-module_vendor_Gvu7G",title:"ProductStrip-module_title_gCNmq",price:"ProductStrip-module_price_gULcE"};var z=require("react/jsx-runtime");function nt({products:e,listboxId:a,onSelect:t,onFocusChange:r,focusable:n=!0}){if(e.length===0)return null;let l=`${a}-products-label`;return(0,z.jsxs)("section",{className:U.section,"data-aia-products":"",role:"group","aria-labelledby":l,children:[(0,z.jsx)("div",{className:U.label,id:l,children:"Products"}),(0,z.jsx)("div",{className:U.row,"data-aia-products-row":"",children:e.map((i,g)=>(0,z.jsx)(zt,{product:i,id:`${a}-product-${g}`,onSelect:t,onFocusChange:r,focusable:n},i.id))})]})}function zt({product:e,id:a,onSelect:t,onFocusChange:r,focusable:n}){let l=i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||i.button!==0||(i.preventDefault(),t(e))};return(0,z.jsxs)("a",{id:a,className:U.card,"data-aia-product":"",role:"option","aria-selected":!1,href:e.url,tabIndex:n?0:-1,onClick:l,onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),t(e))},onFocus:()=>r?.(!0),onBlur:i=>{i.relatedTarget?.closest("[data-aia-dropdown]")||r?.(!1)},children:[(0,z.jsx)("span",{className:U.media,"data-aia-product-placeholder":e.imageUrl?void 0:"",children:e.imageUrl?(0,z.jsx)("img",{className:U.image,src:e.imageUrl,alt:"",loading:"lazy",decoding:"async"}):null}),(0,z.jsxs)("span",{className:U.body,children:[e.vendor?(0,z.jsx)("span",{className:U.vendor,children:e.vendor}):null,(0,z.jsx)("span",{className:U.title,children:e.title}),e.price?(0,z.jsx)("span",{className:U.price,children:e.price}):null]})]})}var xe=require("@magicx-eng/ai-autocomplete-vanilla"),Be=require("react");var st=require("@magicx-eng/ai-autocomplete-vanilla"),ze=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
|
|
1075
1075
|
.aia-grid {
|
|
1076
1076
|
display: grid;
|
|
1077
1077
|
grid-template-columns: repeat(
|
|
@@ -1106,7 +1106,7 @@
|
|
|
1106
1106
|
border-radius: 3px;
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
1109
|
-
`,document.head.appendChild(e)}var
|
|
1109
|
+
`,document.head.appendChild(e)}var dt=require("react/jsx-runtime");function lt({min:e="16rem",max:a,gap:t,scroll:r=!1,maxHeight:n,scrollResetKey:l,cols:i,className:g,children:w,...y}){let _=(0,ze.useRef)(null);(0,ze.useLayoutEffect)(()=>{if(l===void 0)return;let M=_.current;M&&(M.scrollTop=0)},[l]);let b={"--aia-grid-min":e};return a&&(b["--aia-grid-max"]=a),t&&(b["--aia-grid-gap"]=t),n&&(b["--aia-grid-max-height"]=n),i&&(b.gridTemplateColumns=(0,st.optionsGridTemplateColumns)(i)),(0,dt.jsx)("div",{ref:_,className:g?`aia-grid ${g}`:"aia-grid","data-scroll":r||void 0,style:b,...y,children:w})}var ve=require("react");if(typeof document<"u"&&!document.getElementById("ac-style-82820da7")){let e=document.createElement("style");e.id="ac-style-82820da7",e.textContent=`.SuggestionItem-module_item_d4vpD {
|
|
1110
1110
|
position: relative;
|
|
1111
1111
|
overflow: visible;
|
|
1112
1112
|
display: flex;
|
|
@@ -1456,7 +1456,7 @@
|
|
|
1456
1456
|
filter: brightness(0.55);
|
|
1457
1457
|
}
|
|
1458
1458
|
}
|
|
1459
|
-
`,document.head.appendChild(e)}var
|
|
1459
|
+
`,document.head.appendChild(e)}var V={item:"SuggestionItem-module_item_d4vpD",fadeIn:"SuggestionItem-module_fadeIn_I8u35",content:"SuggestionItem-module_content_T-Qba",tappable:"SuggestionItem-module_tappable_70KcX",nonTappable:"SuggestionItem-module_nonTappable_xSZM-",highlighted:"SuggestionItem-module_highlighted_Hb0SU",tag:"SuggestionItem-module_tag_e3Fwe",pressed:"SuggestionItem-module_pressed_98o-r",glassFade:"SuggestionItem-module_glassFade_oyiSj",tapDown:"SuggestionItem-module_tapDown_G3WGz",streaks:"SuggestionItem-module_streaks_d9PEB",streaksVert:"SuggestionItem-module_streaksVert_ERlV1",streakHorizRight:"SuggestionItem-module_streakHorizRight_aboGz",streakHorizLeft:"SuggestionItem-module_streakHorizLeft_BreWJ",streakVertUp:"SuggestionItem-module_streakVertUp_to1GD",streakVertDown:"SuggestionItem-module_streakVertDown_OrcLh",skeletonPulse:"SuggestionItem-module_skeletonPulse_plvdD",text:"SuggestionItem-module_text_yqoh9"};var ce=require("react/jsx-runtime");function pt({option:e,isHighlighted:a,onSelect:t,onHighlight:r,id:n,loading:l}){let[i,g]=(0,ve.useState)(!1),w=(0,ve.useRef)(void 0);(0,ve.useEffect)(()=>()=>clearTimeout(w.current),[]);let y=()=>{l||!e.is_tappable||i||(g(!0),t(e),clearTimeout(w.current),w.current=setTimeout(()=>g(!1),500))},_=[V.item,a&&!l?V.highlighted:"",e.is_tappable?V.tappable:V.nonTappable,i?V.pressed:""].filter(Boolean).join(" ");return(0,ce.jsxs)("div",{id:n,role:"option","data-aia-option":"","data-aia-loading":l?"":void 0,"aria-selected":a,className:_,tabIndex:l||!e.is_tappable?-1:0,onClick:y,onKeyDown:b=>{!l&&e.is_tappable&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),y())},onMouseEnter:!l&&e.is_tappable?r:void 0,children:[(0,ce.jsx)("div",{className:V.streaks}),(0,ce.jsx)("div",{className:V.streaksVert}),(0,ce.jsxs)("span",{className:V.content,children:[(0,ce.jsx)("span",{className:V.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&(0,ce.jsx)("span",{className:V.tag,children:e.tag})]})]})}var Qe=require("react/jsx-runtime");function Bt(){let[e,a]=(0,Be.useState)(xe.isOptionsGridMobileViewport);return(0,Be.useEffect)(()=>{if(typeof window>"u"||!window.matchMedia)return;let t=window.matchMedia(xe.OPTIONS_GRID_MOBILE_QUERY),r=()=>a(t.matches);return r(),t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[]),e}function ct({options:e,activeIndex:a,onSelect:t,onHighlight:r,listboxId:n,loading:l,groupKey:i}){let g=Bt(),{cols:w,maxHeight:y}=(0,xe.computeOptionsGridLayout)(e.length,g);return(0,Qe.jsx)(lt,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:i,cols:w,maxHeight:y,children:e.map((_,b)=>(0,Qe.jsx)(pt,{option:_,isHighlighted:b===a,onSelect:t,onHighlight:()=>r(b),id:`${n}-option-${b}`,loading:l},_.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
|
|
1460
1460
|
.aia-stack {
|
|
1461
1461
|
display: flex;
|
|
1462
1462
|
flex-direction: column;
|
|
@@ -1473,7 +1473,7 @@
|
|
|
1473
1473
|
}
|
|
1474
1474
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1475
1475
|
}
|
|
1476
|
-
`,document.head.appendChild(e)}var
|
|
1476
|
+
`,document.head.appendChild(e)}var mt=require("react/jsx-runtime");function ut({space:e,align:a="stretch",className:t,children:r,...n}){let l=e?{"--aia-stack-space":e}:void 0;return(0,mt.jsx)("div",{className:t?`aia-stack ${t}`:"aia-stack","data-align":a,style:l,...n,children:r})}var B=require("react/jsx-runtime"),Ft=[159,119,164],Mt=()=>{};function Nt(e){let a=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[t,r]=(0,we.useState)(a);if((0,we.useEffect)(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let n=window.matchMedia("(prefers-color-scheme: dark)"),l=()=>r(n.matches);return n.addEventListener("change",l),()=>n.removeEventListener("change",l)},[e]),e!==void 0)return e==="auto"?t?"dark":"light":e}function Fe({suggestions:e,activeIndex:a,onSelect:t,onHighlight:r,isOpen:n,id:l,className:i,pills:g,onPillClick:w,showPills:y=!0,onSkip:_,showSkipButton:b=!0,skipDisabled:M=!1,activeSelected:J=!1,isLoading:$=!1,isInputEmpty:D=!1,products:C,onProductSelect:X,onProductFocusChange:R,optionsPosition:P="below",mode:j}){let Z=Nt(j),Y=Z!==void 0,c=e[0]?.options??[],re=!!(g&&g.length>0&&w),T=!!(C&&C.length>0),H=n&&(c.length>0||y&&re||$||T),N={suggestions:e,activeIndex:a,pills:g,showPills:y,showSkipButton:b,skipDisabled:M,activeSelected:J,isLoading:$,isInputEmpty:D,products:C},ee=(0,we.useRef)(N);H&&(ee.current=N);let h=H?N:ee.current,O=h.suggestions[0],G=O?.options??[],L=h.activeIndex>=0&&!!G[h.activeIndex]?.is_tappable,K=!!(h.pills&&h.pills.length>0&&w),te=h.showPills&&K,ae=h.showPills&&!K&&h.isLoading,W=te||ae,s=K&&h.showSkipButton&&!h.isInputEmpty&&!!_,p=h.pills?.[0]?.text,u=G.length>0,f=h.isLoading&&!u,o=h.products??[];return(0,B.jsx)("div",{id:l,role:"listbox","data-aia-dropdown":"","data-options-position":P,"data-mode":Z,"data-aia-loading":h.isLoading?"":void 0,"data-aia-has-products":o.length>0?"":void 0,className:`${Y?"magicx-aia ":""}${de.dropdown} ${H?de.visible:""} ${i??""}`,onMouseDown:I=>I.preventDefault(),children:(0,B.jsxs)(ut,{space:"8px",children:[(W||s)&&(0,B.jsxs)(Pe,{noWrap:!0,className:de.pillBar,"data-aia-pillbar":"",children:[W&&(0,B.jsx)("span",{className:de.pillScroll,"data-aia-pill-scroll":"",children:(0,B.jsx)(Le,{pills:h.pills??[],activePillIndex:0,activeSelected:h.activeSelected,onSelectPill:w??(()=>{}),rounded:!0,loading:h.isLoading})}),s&&(0,B.jsx)("button",{type:"button",tabIndex:-1,className:de.skip,"data-aia-skip":"",disabled:h.isLoading||h.skipDisabled,"aria-label":p?`Skip ${p}`:"Skip",onClick:_,children:"skip"})]}),u&&(0,B.jsx)(ct,{options:G,activeIndex:h.activeIndex,onSelect:t,onHighlight:r,listboxId:l,loading:h.isLoading,groupKey:O?`${O.type} ${O.text}`:""}),f&&(0,B.jsx)("div",{className:de.skeletonBars,"data-aia-skeleton-bars":"",children:Ft.map(I=>(0,B.jsx)("span",{className:de.skeletonBar,style:{width:I}},`bar-${I}`))}),(0,B.jsx)(nt,{products:o,listboxId:l,onSelect:X??Mt,onFocusChange:R,focusable:H}),(0,B.jsx)(at,{isOptionHighlighted:L,isInputEmpty:h.isInputEmpty})]})})}var ye=require("@magicx-eng/ai-autocomplete-vanilla");if(typeof document<"u"&&!document.getElementById("ac-style-fdee06e6")){let e=document.createElement("style");e.id="ac-style-fdee06e6",e.textContent=`.SubmitButton-module_submitButton_otz7H {
|
|
1477
1477
|
flex-shrink: 0;
|
|
1478
1478
|
width: 32px;
|
|
1479
1479
|
height: 32px;
|
|
@@ -1508,5 +1508,5 @@
|
|
|
1508
1508
|
);
|
|
1509
1509
|
cursor: default;
|
|
1510
1510
|
}
|
|
1511
|
-
`,document.head.appendChild(e)}var ut={submitButton:"SubmitButton-module_submitButton_otz7H"};var Be=require("react/jsx-runtime");function mt({disabled:e,onClick:o}){return(0,Be.jsx)("button",{type:"button","data-aia-submit":"",className:ut.submitButton,disabled:e,onClick:a=>{a.stopPropagation(),o()},"aria-label":"Submit",children:(0,Be.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Be.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var gt=require("@magicx-eng/ai-autocomplete-vanilla"),x=require("react");var je=require("react");function ht(e){let o=(0,je.useRef)(e);o.current=e;let a=(0,je.useRef)(null);a.current===null&&(a.current={fetch:(s,d)=>{let i=o.current;return i?i.fetch(s,d):Promise.reject(new Error("products config removed"))},transform:s=>o.current?.transform(s)??[],get limit(){return o.current?.limit}});let n=e!==void 0;return{config:n?a.current:void 0,enabled:n}}var Mt={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function Fe({onSubmit:e,onError:o,optionOverrides:a,maskCompletedText:n,apiConfig:s,columns:d=2,dropdownTrigger:i,optionsPosition:m,closeDropdownOnBlur:b,showNonTappableOptions:w,showSkipButton:S,onFocus:y,onBlur:F,value:R,completedParams:D,onChange:J,onParamsChange:M,products:ae,onProductSelect:T,source:_,setCursor:V}){let c=(0,x.useRef)(null),[oe,X]=(0,x.useState)(null),Z=(0,x.useRef)(e);Z.current=e;let C=(0,x.useRef)(o);C.current=o;let N=(0,x.useRef)(J);N.current=J;let O=(0,x.useRef)(M);O.current=M;let q=(0,x.useRef)(y);q.current=y;let h=(0,x.useRef)(F);h.current=F;let A=(0,x.useRef)(V);A.current=V;let H=(0,x.useRef)(T);H.current=T;let Y=ht(ae);(0,x.useEffect)(()=>{if(typeof document>"u")return;let p=new gt.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:s,optionOverrides:a,maskCompletedText:n,columns:d,dropdownTrigger:i,optionsPosition:m,closeDropdownOnBlur:b,showNonTappableOptions:w,source:_,value:R,completedParams:D,onSubmit:(...I)=>Z.current?.(...I),onError:(...I)=>C.current?.(...I),onChange:(...I)=>N.current?.(...I),onParamsChange:(...I)=>O.current?.(...I),onFocus:()=>q.current?.(),onBlur:()=>h.current?.(),onProductSelect:I=>H.current?.(I),setCursor:I=>A.current?.(I),products:Y.config});c.current=p,X(p.getState());let E=p.subscribe(I=>X(I));return()=>{E(),p.destroy(),c.current===p&&(c.current=null)}},[]),(0,x.useEffect)(()=>{R!==void 0&&c.current?.setValue(R)},[R]),(0,x.useEffect)(()=>{D!==void 0&&c.current?.setCompletedParams(D)},[D]);let G=JSON.stringify(s??null),$=(0,x.useRef)(a),j=(0,x.useRef)(0);if(a!==$.current){let p=$.current,E=a,I=Object.keys(p??{}),he=Object.keys(E??{});(I.length!==he.length||he.some(ye=>!p?.[ye]||E[ye]!==p[ye]))&&j.current++,$.current=a}(0,x.useEffect)(()=>{c.current?.update({apiConfig:s,optionOverrides:a,dropdownTrigger:i,optionsPosition:m,closeDropdownOnBlur:b,showNonTappableOptions:w})},[G,j.current,i,m,b,w]);let ee=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(!ee.current){ee.current=!0;return}c.current?.update({products:Y.config})},[Y.enabled]);let l=(0,x.useRef)(null);l.current===null&&(l.current={handleTextChange:p=>c.current?.handleTextChange(p),handleKeyDown:p=>{let E="nativeEvent"in p?p.nativeEvent:p;c.current?.handleKeyDown(E)},setFocused:p=>c.current?.setFocused(p),startEditingParam:p=>c.current?.startEditingParam(p),exitEditMode:()=>c.current?.exitEditMode(),handleCaretAfterInput:p=>c.current?.handleCaretAfterInput(p),handleCaretMove:p=>c.current?.handleCaretMove(p),replaceEditingRange:p=>c.current?.replaceEditingRange(p)??!1,setActivePill:p=>c.current?.setActivePill(p),skipActivePill:()=>c.current?.skipActivePill(),removeLastParam:()=>c.current?.removeLastParam(),clearNewParamId:()=>c.current?.clearNewParamId(),reset:()=>c.current?.reset(),selectOption:p=>c.current?.selectOption(p),selectProduct:p=>c.current?.selectProduct(p),setActiveDropdownIndex:p=>c.current?.setActiveDropdownIndex(p),handleFocus:()=>c.current?.setFocused(!0),handleBlur:()=>c.current?.setFocused(!1)});let t=l.current,u=(0,x.useCallback)(p=>{let E=p.target.value,he=E.length>0&&!p.nativeEvent?.isComposing&&E[0]!==E[0].toUpperCase()?E[0].toUpperCase()+E.slice(1):E;c.current?.handleTextChange(he)},[]),v=(0,x.useCallback)(p=>{c.current?.handleKeyDown(p.nativeEvent)},[]),g=c.current,r=oe??Mt,ie=R!==void 0?R:r.text,pe=D!==void 0?D:r.completedParams,ce=r.actionableSuggestions,Pe=ce[0],ue=g?.listboxId??"",Oe=r.activeDropdownIndex>=0&&g?`${ue}-option-${r.activeDropdownIndex}`:void 0,re=r.editingParam,we=re?{type:re.suggestionType,text:re.suggestionPlaceholder,required:!0,options:re.options}:null,Ie=we??Pe,He=we?[we]:ce,Se=!g||r.isLoading&&!r.editingParam&&!r.inSelectionAnimation;return{completedParams:pe,skippedParams:r.skippedParams,suggestionPills:ce,setActivePill:t.setActivePill,skipActivePill:t.skipActivePill,removeLastParam:t.removeLastParam,segments:r.segments,newParamId:r.newParamId,clearNewParamId:t.clearNewParamId,suggestions:r.suggestions,activeIndex:r.activeDropdownIndex,isReady:r.isReady,isLoading:Se,isFocused:r.isFocused,isDropdownOpen:r.isDropdownOpen,isActivePillSelected:r.isActivePillSelected,placeholderText:r.placeholderText,listboxId:ue,error:r.error,products:r.products,selectProduct:t.selectProduct,handleTextChange:t.handleTextChange,handleKeyDown:t.handleKeyDown,setFocused:t.setFocused,editingParam:re,editingAnchor:r.editingAnchor,caretOffset:r.caretOffset,startEditingParam:t.startEditingParam,exitEditMode:t.exitEditMode,handleCaretAfterInput:t.handleCaretAfterInput,handleCaretMove:t.handleCaretMove,replaceEditingRange:t.replaceEditingRange,inputProps:{value:ie,placeholder:r.placeholderText||void 0,onChange:u,onKeyDown:v,onFocus:t.handleFocus,onBlur:t.handleBlur,role:"combobox","aria-expanded":r.isDropdownOpen,"aria-activedescendant":Oe,"aria-autocomplete":"list","aria-controls":ue},reset:t.reset,dropdownProps:{suggestions:Ie?[{...Ie,options:r.filteredOptions}]:[],activeIndex:r.activeDropdownIndex,onSelect:t.selectOption,onHighlight:t.setActiveDropdownIndex,isOpen:r.isDropdownOpen,id:ue,pills:He,activeSelected:r.isActivePillSelected,onPillClick:t.setActivePill,onSkip:t.skipActivePill,showSkipButton:(S??!0)&&!re,skipDisabled:r.inSelectionAnimation,isLoading:Se,isInputEmpty:ie.trim().length===0,products:r.products,onProductSelect:t.selectProduct,onProductFocusChange:t.setFocused,optionsPosition:m??"below"}}}var B=require("@magicx-eng/ai-autocomplete-vanilla"),f=require("react"),Me;function Nt(){if(Me!==void 0)return Me;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Me=e.contentEditable==="plaintext-only",Me}function ft(e){let{segments:o,newParamId:a,editingParam:n,editingAnchor:s,caretOffset:d,placeholderText:i,isFocused:m,isDropdownOpen:b,listboxId:w,activeDescendantId:S,autoFocus:y,handleTextChange:F,handleKeyDown:R,handleCaretAfterInput:D,handleCaretMove:J,startEditingParam:M,replaceEditingRange:ae,setFocused:T}=e,_=(0,f.useRef)(null),V=(0,f.useRef)(!1),c=(0,f.useRef)(""),oe=(0,f.useRef)(""),X=(0,f.useRef)(null),Z=(0,f.useRef)(0);X.current=d,(0,f.useEffect)(()=>{if(!y)return;let l=_.current;if(!l)return;document.activeElement===l?T(!0):l.focus();let t=l.ownerDocument??document,u=t.getSelection(),v=u&&u.rangeCount>0&&l.contains(u.anchorNode);if(u&&!v){let g=t.createRange();g.selectNodeContents(l),g.collapse(!0),u.removeAllRanges(),u.addRange(g)}},[y,T]),(0,f.useEffect)(()=>{let l=_.current;if(!l)return;let t=l.ownerDocument??document,u=()=>{let v=t.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!l.contains(v.anchorNode))return;let g=v.anchorNode,r=g.nodeType===Node.ELEMENT_NODE?g:g.parentElement,pe=(v.isCollapsed?r?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(pe&&pe!==n?.id){M(pe);return}performance.now()-Z.current<50||J((0,B.getCursorOffset)(l))};return t.addEventListener("selectionchange",u),()=>t.removeEventListener("selectionchange",u)},[n,M,J]),(0,f.useLayoutEffect)(()=>{let l=_.current;l&&(0,B.renderEditableContent)({input:l,segments:o,newParamId:a,editingParamId:n?.id??null,placeholderText:i??"",isFocused:m})},[o,a,n,i,m]),(0,f.useLayoutEffect)(()=>{let l=c.current,t=a??"";if(c.current=t,!t||t===l)return;let u=_.current;if(!u)return;u.focus();let v=X.current??(0,B.plainTextLength)(u);(0,B.setCursorOffset)(u,v)},[a]),(0,f.useLayoutEffect)(()=>{let l=oe.current,t=n?.id??"";if(oe.current=t,!t||t===l||s==null)return;let u=_.current;u&&(0,B.setCursorOffset)(u,s)},[n,s]);let C=(0,f.useCallback)(()=>{if(V.current)return;let l=_.current;if(!l)return;let t=(0,B.extractPlainText)(l),v=t.length>0&&t[0]!==t[0].toUpperCase()?t[0].toUpperCase()+t.slice(1):t;F(v)},[F]),N=(0,f.useCallback)(()=>{Z.current=performance.now(),C();let l=_.current;l&&D((0,B.getCursorOffset)(l))},[C,D]);(0,f.useEffect)(()=>{let l=_.current;if(!l)return;let t=u=>{let v=u,g=v.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){u.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let r=g.startsWith("delete")?"":v.data??"";ae(r)&&u.preventDefault()}};return l.addEventListener("beforeinput",t),()=>l.removeEventListener("beforeinput",t)},[ae]);let O=(0,f.useCallback)(()=>{V.current=!0},[]),q=(0,f.useCallback)(()=>{V.current=!1,C()},[C]),h=(0,f.useCallback)(l=>{l.preventDefault();let t=_.current;if(!t)return;let u=(l.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let v=t.ownerDocument??document,g=v.getSelection();if(!g||g.rangeCount===0)return;let r=g.getRangeAt(0);if(!t.contains(r.startContainer))return;r.deleteContents();let ie=v.createTextNode(u);r.insertNode(ie),r.setStartAfter(ie),r.collapse(!0),g.removeAllRanges(),g.addRange(r),C()},[C]),A=(0,f.useCallback)(l=>R(l),[R]),H=(0,f.useCallback)(()=>T(!0),[T]),Y=(0,f.useCallback)(()=>T(!1),[T]),G=(0,f.useCallback)(()=>_.current?.focus(),[]),$=(0,f.useCallback)(()=>_.current?.blur(),[]),j=(0,f.useCallback)(()=>{let l=_.current;return l?(0,B.extractPlainText)(l):""},[]),ee=Nt()?"plaintext-only":"true";return{inputRef:_,editorProps:{ref:_,contentEditable:ee,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":w,"aria-expanded":b,"aria-activedescendant":S,spellCheck:!0,enterKeyHint:"send",onInput:N,onKeyDown:A,onCompositionStart:O,onCompositionEnd:q,onPaste:h,onFocus:H,onBlur:Y},getPlainText:j,focus:G,blur:$}}var U=require("react/jsx-runtime");function Ot(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var bt=(0,P.forwardRef)(function({onSubmit:o,onError:a,optionOverrides:n,maskCompletedText:s,className:d,apiConfig:i,columns:m,pillPlacement:b="dropdown",mode:w="auto",optionsPosition:S="below",animations:y=!0,dropdownTrigger:F,closeDropdownOnBlur:R,showNonTappableOptions:D,showSkipButton:J,autoFocus:M=!0,onFocus:ae,onBlur:T,value:_,completedParams:V,onChange:c,onParamsChange:oe,products:X,onProductSelect:Z,submitButton:C},N){let O=(0,P.useRef)(null),q=(0,P.useRef)(null),h=(0,P.useRef)(()=>{}),A=(0,P.useRef)(null),H=(0,P.useRef)(null);(0,P.useEffect)(()=>{let k=O.current;if(k)return A.current?A.current.setMode(w):A.current=new xe.ModeController(k,w),()=>{A.current?.destroy(),A.current=null}},[w]);let Y=(0,P.useCallback)(k=>{let ne=H.current?.current;ne&&(ne.focus(),(0,xe.setCursorOffset)(ne,k))},[]),{completedParams:G,skippedParams:$,suggestionPills:j,setActivePill:ee,skipActivePill:l,segments:t,newParamId:u,clearNewParamId:v,placeholderText:g,isFocused:r,isDropdownOpen:ie,isActivePillSelected:pe,isLoading:ce,activeIndex:Pe,listboxId:ue,handleTextChange:Oe,handleKeyDown:re,setFocused:we,editingParam:Ie,editingAnchor:He,caretOffset:Se,startEditingParam:p,handleCaretAfterInput:E,handleCaretMove:I,replaceEditingRange:he,dropdownProps:ye,reset:Ae}=Fe({onSubmit:k=>h.current(k),onError:a,optionOverrides:n,maskCompletedText:s,apiConfig:i,columns:m,dropdownTrigger:F,optionsPosition:S,closeDropdownOnBlur:R,showNonTappableOptions:D,showSkipButton:J,onFocus:ae,onBlur:T,value:_,completedParams:V,onChange:c,onParamsChange:oe,products:X,onProductSelect:Z,source:"full-sdk",setCursor:Y});(0,P.useEffect)(()=>{if(!u)return;let k=window.setTimeout(()=>v(),650);return()=>window.clearTimeout(k)},[u,v]);let vt=Pe>=0?`${ue}-option-${Pe}`:void 0,{inputRef:Ge,editorProps:xt,focus:Ce,blur:Qe,getPlainText:Je}=ft({segments:t,newParamId:u,editingParam:Ie,editingAnchor:He,caretOffset:Se,placeholderText:g,isFocused:r,isDropdownOpen:ie,listboxId:ue,activeDescendantId:vt,autoFocus:M,handleTextChange:Oe,handleKeyDown:re,handleCaretAfterInput:E,handleCaretMove:I,startEditingParam:p,replaceEditingRange:he,setFocused:we});H.current=Ge,(0,P.useLayoutEffect)(()=>{let k=q.current,ne=Ge.current;if(!k||!ne)return;let Xe=()=>{let Ye=k.firstElementChild;if(!Ye)return;let _t=Ye.getBoundingClientRect(),Pt=ne.getBoundingClientRect();_t.top>=Pt.bottom-2?k.setAttribute("data-aia-pill-wrapped",""):k.removeAttribute("data-aia-pill-wrapped")};Xe();let Ze=new ResizeObserver(Xe);return Ze.observe(ne),()=>Ze.disconnect()},[t,j.length,ce,Ge]),(0,P.useImperativeHandle)(N,()=>({focus:Ce,blur:Qe,reset:Ae,setMode:k=>A.current?.setMode(k),skipActivePill:l}),[Ce,Qe,Ae,l]);let Ee=!!t.length||G.length>0,Ke=(0,P.useCallback)(()=>{if(!Ee)return;let k=Je();o((0,xe.buildSubmitResult)(k,G,$)),Ae()},[Ee,G,$,o,Ae,Je]);h.current=Ke;let wt=(0,P.useCallback)(k=>{k.target?.closest("[data-aia-pill]")||Ce()},[Ce]),yt=b==="inline",kt=b==="dropdown";return(0,U.jsxs)("div",{ref:O,className:`magicx-aia ${me.container} ${d??""}`,"data-pill-placement":b,"data-options-position":S,"data-animations":y?"on":"off","data-mode":Ot(w),children:[(0,U.jsx)(ze,{...ye,showPills:kt}),(0,U.jsxs)("div",{className:me.inputWrapper,onClick:wt,children:[(0,U.jsxs)("div",{className:me.editorArea,"data-aia-editor":"",children:[(0,U.jsx)("div",{...xt,className:me.input,"data-aia-input":""}),yt&&(ce||j.length>0)&&(0,U.jsx)("span",{ref:q,className:me.pillListContainer,"data-aia-pill-list-container":"",children:(0,U.jsx)(Re,{pills:j,activePillIndex:0,activeSelected:pe,onSelectPill:ee,loading:ce})})]}),C===null?null:C===void 0?(0,U.jsx)(mt,{disabled:!Ee,onClick:Ke}):(0,U.jsx)("span",{"data-aia-submit":"",className:me.submitSlot,onClick:k=>{Ee&&(k.stopPropagation(),Ke())},children:C})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,buildSubmitResult,useAIAutocomplete,withSkippedParams});
|
|
1511
|
+
`,document.head.appendChild(e)}var ht={submitButton:"SubmitButton-module_submitButton_otz7H"};var Me=require("react/jsx-runtime");function gt({disabled:e,onClick:a}){return(0,Me.jsx)("button",{type:"button","data-aia-submit":"",className:ht.submitButton,disabled:e,onClick:t=>{t.stopPropagation(),a()},"aria-label":"Submit",children:(0,Me.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:(0,Me.jsx)("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}var bt=require("@magicx-eng/ai-autocomplete-vanilla"),x=require("react");var Je=require("react");function ft(e){let a=(0,Je.useRef)(e);a.current=e;let t=(0,Je.useRef)(null);t.current===null&&(t.current={fetch:(n,l)=>{let i=a.current;return i?i.fetch(n,l):Promise.reject(new Error("products config removed"))},transform:n=>a.current?.transform(n)??[],get limit(){return a.current?.limit}});let r=e!==void 0;return{config:r?t.current:void 0,enabled:r}}var Ot={text:"",completedParams:[],identifiedParams:[],skippedParams:[],pendingSpan:null,suggestions:[],products:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,isActivePillSelected:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1};function Ne({onSubmit:e,onError:a,optionOverrides:t,maskCompletedText:r,apiConfig:n,additionalContext:l,generateStartingStateOptions:i,columns:g=2,dropdownTrigger:w,optionsPosition:y,closeDropdownOnBlur:_,showNonTappableOptions:b,showSkipButton:M,onFocus:J,onBlur:$,value:D,completedParams:C,onChange:X,onParamsChange:R,products:P,onProductSelect:j,source:Z,setCursor:Y}){let c=(0,x.useRef)(null),[re,T]=(0,x.useState)(null),H=(0,x.useRef)(e);H.current=e;let N=(0,x.useRef)(a);N.current=a;let ee=(0,x.useRef)(X);ee.current=X;let h=(0,x.useRef)(R);h.current=R;let O=(0,x.useRef)(J);O.current=J;let G=(0,x.useRef)($);G.current=$;let L=(0,x.useRef)(Y);L.current=Y;let K=(0,x.useRef)(j);K.current=j;let te=ft(P);(0,x.useEffect)(()=>{if(typeof document>"u")return;let d=new bt.AIAutocomplete(document.createElement("div"),{renderMode:"headless",apiConfig:n,additionalContext:l,generateStartingStateOptions:i,optionOverrides:t,maskCompletedText:r,columns:g,dropdownTrigger:w,optionsPosition:y,closeDropdownOnBlur:_,showNonTappableOptions:b,source:Z,value:D,completedParams:C,onSubmit:(...A)=>H.current?.(...A),onError:(...A)=>N.current?.(...A),onChange:(...A)=>ee.current?.(...A),onParamsChange:(...A)=>h.current?.(...A),onFocus:()=>O.current?.(),onBlur:()=>G.current?.(),onProductSelect:A=>K.current?.(A),setCursor:A=>L.current?.(A),products:te.config});c.current=d,T(d.getState());let E=d.subscribe(A=>T(A));return()=>{E(),d.destroy(),c.current===d&&(c.current=null)}},[]),(0,x.useEffect)(()=>{D!==void 0&&c.current?.setValue(D)},[D]),(0,x.useEffect)(()=>{C!==void 0&&c.current?.setCompletedParams(C)},[C]);let ae=JSON.stringify(n??null),W;try{W=JSON.stringify(l??null)}catch{W="[unstringifiable]"}let s=(0,x.useRef)(t),p=(0,x.useRef)(0);if(t!==s.current){let d=s.current,E=t,A=Object.keys(d??{}),fe=Object.keys(E??{});(A.length!==fe.length||fe.some(se=>!d?.[se]||E[se]!==d[se]))&&p.current++,s.current=t}(0,x.useEffect)(()=>{c.current?.update({apiConfig:n,additionalContext:l,generateStartingStateOptions:i,optionOverrides:t,dropdownTrigger:w,optionsPosition:y,closeDropdownOnBlur:_,showNonTappableOptions:b})},[ae,W,i,p.current,w,y,_,b]);let u=(0,x.useRef)(!1);(0,x.useEffect)(()=>{if(!u.current){u.current=!0;return}c.current?.update({products:te.config})},[te.enabled]);let f=(0,x.useRef)(null);f.current===null&&(f.current={handleTextChange:d=>c.current?.handleTextChange(d),handleKeyDown:d=>{let E="nativeEvent"in d?d.nativeEvent:d;c.current?.handleKeyDown(E)},setFocused:d=>c.current?.setFocused(d),startEditingParam:d=>c.current?.startEditingParam(d),exitEditMode:()=>c.current?.exitEditMode(),handleCaretAfterInput:d=>c.current?.handleCaretAfterInput(d),handleCaretMove:d=>c.current?.handleCaretMove(d),replaceEditingRange:d=>c.current?.replaceEditingRange(d)??!1,setActivePill:d=>c.current?.setActivePill(d),skipActivePill:()=>c.current?.skipActivePill(),removeLastParam:()=>c.current?.removeLastParam(),clearNewParamId:()=>c.current?.clearNewParamId(),reset:()=>c.current?.reset(),selectOption:d=>c.current?.selectOption(d),selectProduct:d=>c.current?.selectProduct(d),setActiveDropdownIndex:d=>c.current?.setActiveDropdownIndex(d),handleFocus:()=>c.current?.setFocused(!0),handleBlur:()=>c.current?.setFocused(!1)});let o=f.current,I=(0,x.useCallback)(d=>{let E=d.target.value,fe=E.length>0&&!d.nativeEvent?.isComposing&&E[0]!==E[0].toUpperCase()?E[0].toUpperCase()+E.slice(1):E;c.current?.handleTextChange(fe)},[]),ue=(0,x.useCallback)(d=>{c.current?.handleKeyDown(d.nativeEvent)},[]),oe=c.current,m=re??Ot,Se=D!==void 0?D:m.text,ke=C!==void 0?C:m.completedParams,he=m.actionableSuggestions,Ae=he[0],ge=oe?.listboxId??"",Ge=m.activeDropdownIndex>=0&&oe?`${ge}-option-${m.activeDropdownIndex}`:void 0,ne=m.editingParam,_e=ne?{type:ne.suggestionType,text:ne.suggestionPlaceholder,required:!0,options:ne.options}:null,Ce=_e??Ae,Ke=_e?[_e]:he,Ee=!oe||m.isLoading&&!m.editingParam&&!m.inSelectionAnimation;return{completedParams:ke,skippedParams:m.skippedParams,suggestionPills:he,setActivePill:o.setActivePill,skipActivePill:o.skipActivePill,removeLastParam:o.removeLastParam,segments:m.segments,newParamId:m.newParamId,clearNewParamId:o.clearNewParamId,suggestions:m.suggestions,activeIndex:m.activeDropdownIndex,isReady:m.isReady,isLoading:Ee,isFocused:m.isFocused,isDropdownOpen:m.isDropdownOpen,isActivePillSelected:m.isActivePillSelected,placeholderText:m.placeholderText,listboxId:ge,error:m.error,products:m.products,selectProduct:o.selectProduct,handleTextChange:o.handleTextChange,handleKeyDown:o.handleKeyDown,setFocused:o.setFocused,editingParam:ne,editingAnchor:m.editingAnchor,caretOffset:m.caretOffset,startEditingParam:o.startEditingParam,exitEditMode:o.exitEditMode,handleCaretAfterInput:o.handleCaretAfterInput,handleCaretMove:o.handleCaretMove,replaceEditingRange:o.replaceEditingRange,inputProps:{value:Se,placeholder:m.placeholderText||void 0,onChange:I,onKeyDown:ue,onFocus:o.handleFocus,onBlur:o.handleBlur,role:"combobox","aria-expanded":m.isDropdownOpen,"aria-activedescendant":Ge,"aria-autocomplete":"list","aria-controls":ge},reset:o.reset,dropdownProps:{suggestions:Ce?[{...Ce,options:m.filteredOptions}]:[],activeIndex:m.activeDropdownIndex,onSelect:o.selectOption,onHighlight:o.setActiveDropdownIndex,isOpen:m.isDropdownOpen,id:ge,pills:Ke,activeSelected:m.isActivePillSelected,onPillClick:o.setActivePill,onSkip:o.skipActivePill,showSkipButton:(M??!0)&&!ne,skipDisabled:m.inSelectionAnimation,isLoading:Ee,isInputEmpty:Se.trim().length===0,products:m.products,onProductSelect:o.selectProduct,onProductFocusChange:o.setFocused,optionsPosition:y??"below"}}}var F=require("@magicx-eng/ai-autocomplete-vanilla"),v=require("react"),Oe;function Ht(){if(Oe!==void 0)return Oe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),Oe=e.contentEditable==="plaintext-only",Oe}function vt(e){let{segments:a,newParamId:t,editingParam:r,editingAnchor:n,caretOffset:l,placeholderText:i,isFocused:g,isDropdownOpen:w,listboxId:y,activeDescendantId:_,autoFocus:b,handleTextChange:M,handleKeyDown:J,handleCaretAfterInput:$,handleCaretMove:D,startEditingParam:C,replaceEditingRange:X,setFocused:R}=e,P=(0,v.useRef)(null),j=(0,v.useRef)(!1),Z=(0,v.useRef)(""),Y=(0,v.useRef)(""),c=(0,v.useRef)(null),re=(0,v.useRef)(0);c.current=l,(0,v.useEffect)(()=>{if(!b)return;let s=P.current;if(!s)return;document.activeElement===s?R(!0):s.focus();let p=s.ownerDocument??document,u=p.getSelection(),f=u&&u.rangeCount>0&&s.contains(u.anchorNode);if(u&&!f){let o=p.createRange();o.selectNodeContents(s),o.collapse(!0),u.removeAllRanges(),u.addRange(o)}},[b,R]),(0,v.useEffect)(()=>{let s=P.current;if(!s)return;let p=s.ownerDocument??document,u=()=>{let f=p.getSelection();if(!f||f.rangeCount===0||!f.anchorNode||!s.contains(f.anchorNode))return;let o=f.anchorNode,I=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement,oe=(f.isCollapsed?I?.closest('strong[data-seg="completed"][data-param-id]'):null)?.dataset.paramId??null;if(oe&&oe!==r?.id){C(oe);return}performance.now()-re.current<50||D((0,F.getCursorOffset)(s))};return p.addEventListener("selectionchange",u),()=>p.removeEventListener("selectionchange",u)},[r,C,D]),(0,v.useLayoutEffect)(()=>{let s=P.current;s&&(0,F.renderEditableContent)({input:s,segments:a,newParamId:t,editingParamId:r?.id??null,placeholderText:i??"",isFocused:g})},[a,t,r,i,g]),(0,v.useLayoutEffect)(()=>{let s=Z.current,p=t??"";if(Z.current=p,!p||p===s)return;let u=P.current;if(!u)return;u.focus();let f=c.current??(0,F.plainTextLength)(u);(0,F.setCursorOffset)(u,f)},[t]),(0,v.useLayoutEffect)(()=>{let s=Y.current,p=r?.id??"";if(Y.current=p,!p||p===s||n==null)return;let u=P.current;u&&(0,F.setCursorOffset)(u,n)},[r,n]);let T=(0,v.useCallback)(()=>{if(j.current)return;let s=P.current;if(!s)return;let p=(0,F.extractPlainText)(s),f=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;M(f)},[M]),H=(0,v.useCallback)(()=>{re.current=performance.now(),T();let s=P.current;s&&$((0,F.getCursorOffset)(s))},[T,$]);(0,v.useEffect)(()=>{let s=P.current;if(!s)return;let p=u=>{let f=u,o=f.inputType;if(o==="insertParagraph"||o==="insertLineBreak"||o==="insertFromDrop"){u.preventDefault();return}if(o.startsWith("insert")||o.startsWith("delete")){let I=o.startsWith("delete")?"":f.data??"";X(I)&&u.preventDefault()}};return s.addEventListener("beforeinput",p),()=>s.removeEventListener("beforeinput",p)},[X]);let N=(0,v.useCallback)(()=>{j.current=!0},[]),ee=(0,v.useCallback)(()=>{j.current=!1,T()},[T]),h=(0,v.useCallback)(s=>{s.preventDefault();let p=P.current;if(!p)return;let u=(s.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!u)return;let f=p.ownerDocument??document,o=f.getSelection();if(!o||o.rangeCount===0)return;let I=o.getRangeAt(0);if(!p.contains(I.startContainer))return;I.deleteContents();let ue=f.createTextNode(u);I.insertNode(ue),I.setStartAfter(ue),I.collapse(!0),o.removeAllRanges(),o.addRange(I),T()},[T]),O=(0,v.useCallback)(s=>J(s),[J]),G=(0,v.useCallback)(()=>R(!0),[R]),L=(0,v.useCallback)(()=>R(!1),[R]),K=(0,v.useCallback)(()=>P.current?.focus(),[]),te=(0,v.useCallback)(()=>P.current?.blur(),[]),ae=(0,v.useCallback)(()=>{let s=P.current;return s?(0,F.extractPlainText)(s):""},[]),W=Ht()?"plaintext-only":"true";return{inputRef:P,editorProps:{ref:P,contentEditable:W,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":y,"aria-expanded":w,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:H,onKeyDown:O,onCompositionStart:N,onCompositionEnd:ee,onPaste:h,onFocus:G,onBlur:L},getPlainText:ae,focus:K,blur:te}}var q=require("react/jsx-runtime");function Gt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var xt=(0,S.forwardRef)(function({onSubmit:a,onError:t,optionOverrides:r,maskCompletedText:n,className:l,apiConfig:i,additionalContext:g,generateStartingStateOptions:w,columns:y,pillPlacement:_="dropdown",mode:b="auto",optionsPosition:M="below",animations:J=!0,dropdownTrigger:$,closeDropdownOnBlur:D,showNonTappableOptions:C,showSkipButton:X,autoFocus:R=!0,onFocus:P,onBlur:j,value:Z,completedParams:Y,onChange:c,onParamsChange:re,products:T,onProductSelect:H,submitButton:N},ee){let h=(0,S.useRef)(null),O=(0,S.useRef)(null),G=(0,S.useRef)(()=>{}),L=(0,S.useRef)(null),K=(0,S.useRef)(null);(0,S.useEffect)(()=>{let k=h.current;if(k)return L.current?L.current.setMode(b):L.current=new ye.ModeController(k,b),()=>{L.current?.destroy(),L.current=null}},[b]);let te=(0,S.useCallback)(k=>{let le=K.current?.current;le&&(le.focus(),(0,ye.setCursorOffset)(le,k))},[]),{completedParams:ae,skippedParams:W,suggestionPills:s,setActivePill:p,skipActivePill:u,segments:f,newParamId:o,clearNewParamId:I,placeholderText:ue,isFocused:oe,isDropdownOpen:m,isActivePillSelected:Se,isLoading:ke,activeIndex:he,listboxId:Ae,handleTextChange:ge,handleKeyDown:Ge,setFocused:ne,editingParam:_e,editingAnchor:Ce,caretOffset:Ke,startEditingParam:Ee,handleCaretAfterInput:d,handleCaretMove:E,replaceEditingRange:A,dropdownProps:fe,reset:se}=Ne({onSubmit:k=>G.current(k),onError:t,optionOverrides:r,maskCompletedText:n,apiConfig:i,additionalContext:g,generateStartingStateOptions:w,columns:y,dropdownTrigger:$,optionsPosition:M,closeDropdownOnBlur:D,showNonTappableOptions:C,showSkipButton:X,onFocus:P,onBlur:j,value:Z,completedParams:Y,onChange:c,onParamsChange:re,products:T,onProductSelect:H,source:"full-sdk",setCursor:te});(0,S.useEffect)(()=>{if(!o)return;let k=window.setTimeout(()=>I(),650);return()=>window.clearTimeout(k)},[o,I]);let wt=he>=0?`${Ae}-option-${he}`:void 0,{inputRef:We,editorProps:yt,focus:De,blur:Xe,getPlainText:Ze}=vt({segments:f,newParamId:o,editingParam:_e,editingAnchor:Ce,caretOffset:Ke,placeholderText:ue,isFocused:oe,isDropdownOpen:m,listboxId:Ae,activeDescendantId:wt,autoFocus:R,handleTextChange:ge,handleKeyDown:Ge,handleCaretAfterInput:d,handleCaretMove:E,startEditingParam:Ee,replaceEditingRange:A,setFocused:ne});K.current=We,(0,S.useLayoutEffect)(()=>{let k=O.current,le=We.current;if(!k||!le)return;let Ye=()=>{let tt=k.firstElementChild;if(!tt)return;let It=tt.getBoundingClientRect(),St=le.getBoundingClientRect();It.top>=St.bottom-2?k.setAttribute("data-aia-pill-wrapped",""):k.removeAttribute("data-aia-pill-wrapped")};Ye();let et=new ResizeObserver(Ye);return et.observe(le),()=>et.disconnect()},[f,s.length,ke,We]),(0,S.useImperativeHandle)(ee,()=>({focus:De,blur:Xe,reset:se,setMode:k=>L.current?.setMode(k),skipActivePill:u}),[De,Xe,se,u]);let Re=!!f.length||ae.length>0,Ue=(0,S.useCallback)(()=>{if(!Re)return;let k=Ze();a((0,ye.buildSubmitResult)(k,ae,W)),se()},[Re,ae,W,a,se,Ze]);G.current=Ue;let kt=(0,S.useCallback)(k=>{k.target?.closest("[data-aia-pill]")||De()},[De]),_t=_==="inline",Pt=_==="dropdown";return(0,q.jsxs)("div",{ref:h,className:`magicx-aia ${me.container} ${l??""}`,"data-pill-placement":_,"data-options-position":M,"data-animations":J?"on":"off","data-mode":Gt(b),children:[(0,q.jsx)(Fe,{...fe,showPills:Pt}),(0,q.jsxs)("div",{className:me.inputWrapper,onClick:kt,children:[(0,q.jsxs)("div",{className:me.editorArea,"data-aia-editor":"",children:[(0,q.jsx)("div",{...yt,className:me.input,"data-aia-input":""}),_t&&(ke||s.length>0)&&(0,q.jsx)("span",{ref:O,className:me.pillListContainer,"data-aia-pill-list-container":"",children:(0,q.jsx)(Le,{pills:s,activePillIndex:0,activeSelected:Se,onSelectPill:p,loading:ke})})]}),N===null?null:N===void 0?(0,q.jsx)(gt,{disabled:!Re,onClick:Ue}):(0,q.jsx)("span",{"data-aia-submit":"",className:me.submitSlot,onClick:k=>{Re&&(k.stopPropagation(),Ue())},children:N})]})]})});0&&(module.exports={AIAutocomplete,AIAutocompleteDropdown,buildSubmitResult,useAIAutocomplete,withSkippedParams});
|
|
1512
1512
|
//# sourceMappingURL=index.js.map
|