@magicx-eng/ai-autocomplete-react 0.3.0 → 0.4.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 +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +180 -165
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +181 -166
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{forwardRef as
|
|
1
|
+
import{forwardRef as Tt,useCallback as Le,useEffect as at,useImperativeHandle as Lt,useLayoutEffect as Bt,useRef as ce}from"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
|
|
@@ -8,24 +8,24 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.AIAutocomplete-module_inputWrapper_FLq1b {
|
|
11
|
-
padding:
|
|
11
|
+
padding: 12px 10px;
|
|
12
12
|
border: 1px solid var(--aia-border, #b0b0b0);
|
|
13
|
-
border-radius:
|
|
13
|
+
border-radius: 24px;
|
|
14
14
|
background: var(--aia-surface, #ffffff);
|
|
15
15
|
overflow: hidden;
|
|
16
16
|
display: flex;
|
|
17
17
|
align-items: center;
|
|
18
|
-
gap:
|
|
18
|
+
gap: 12px;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.AIAutocomplete-module_editorArea_7rBWq {
|
|
22
22
|
position: relative;
|
|
23
23
|
flex: 1;
|
|
24
24
|
min-width: 0;
|
|
25
|
-
min-height:
|
|
26
|
-
line-height:
|
|
25
|
+
min-height: 19px;
|
|
26
|
+
line-height: 19px;
|
|
27
27
|
font-family: inherit;
|
|
28
|
-
font-size: var(--aia-written-text-font-size,
|
|
28
|
+
font-size: var(--aia-written-text-font-size, 14px);
|
|
29
29
|
white-space: pre-wrap;
|
|
30
30
|
word-break: break-word;
|
|
31
31
|
overflow-wrap: anywhere;
|
|
@@ -40,7 +40,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
40
40
|
--aia-caret-color,
|
|
41
41
|
var(--aia-written-text-color, var(--aia-color-text-default, #fff))
|
|
42
42
|
);
|
|
43
|
-
font-weight:
|
|
43
|
+
font-weight: 300;
|
|
44
44
|
/* Align the text's inline box with the pill list (also vertical-align: middle)
|
|
45
45
|
so they share a vertical center when pills stretch the line box to ~36px. */
|
|
46
46
|
vertical-align: middle;
|
|
@@ -49,7 +49,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
49
49
|
/* Completed params render as inline bold runs. \`:where()\` keeps specificity
|
|
50
50
|
at (0,2,0) so consumers can override without \`!important\`. */
|
|
51
51
|
:where(.AIAutocomplete-module_input_IW-P-) strong {
|
|
52
|
-
font-weight:
|
|
52
|
+
font-weight: 600;
|
|
53
53
|
letter-spacing: -0.01em;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -145,17 +145,149 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
145
145
|
background-position: -50% 0;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
`,document.head.appendChild(e)}var
|
|
148
|
+
`,document.head.appendChild(e)}var te={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",textShimmer:"AIAutocomplete-module_textShimmer_eCLdq"};import{useRef as It}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
149
|
+
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
150
|
+
* Consumer CSS always wins without !important.
|
|
151
|
+
*
|
|
152
|
+
* Resolution priority (highest wins):
|
|
153
|
+
* 1. Consumer CSS targeting new vars (--aia-pill-bg, etc.)
|
|
154
|
+
* 2. Consumer CSS targeting legacy vars (--aia-color-*, via fallback chain)
|
|
155
|
+
* 3. These built-in defaults
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/*
|
|
159
|
+
* Library-scoped box-sizing reset. The SDK's pill / option / wrapper styles
|
|
160
|
+
* mix explicit dimensions with padding (e.g. .magicx-aia-pill has height:36px
|
|
161
|
+
* + padding:13px) and were authored assuming \`border-box\`. In consumer apps
|
|
162
|
+
* without a global \`* { box-sizing: border-box }\` reset the pill rendered
|
|
163
|
+
* ~62px tall instead of 36px. Scoping the reset to \`.magicx-aia\` descendants
|
|
164
|
+
* keeps the library self-contained without leaking onto consumer markup.
|
|
165
|
+
*/
|
|
166
|
+
:where(.magicx-aia, .magicx-aia *, .magicx-aia *::before, .magicx-aia *::after) {
|
|
167
|
+
box-sizing: border-box;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Light mode defaults (base) */
|
|
171
|
+
:where(.magicx-aia),
|
|
172
|
+
:where(.magicx-aia[data-mode="light"]) {
|
|
173
|
+
--aia-surface: #ffffff;
|
|
174
|
+
--aia-border: #b0b0b0;
|
|
175
|
+
--aia-dropdown-border: #e5e7eb;
|
|
176
|
+
--aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.12);
|
|
177
|
+
--aia-pill-bg: #bdbdbd;
|
|
178
|
+
--aia-pill-color: #333539;
|
|
179
|
+
--aia-pill-font-size: 14px;
|
|
180
|
+
|
|
181
|
+
--aia-option-bg: #eef2ff;
|
|
182
|
+
--aia-option-color: #505050;
|
|
183
|
+
--aia-option-color-selected: #000000;
|
|
184
|
+
--aia-option-font-size: 14px;
|
|
185
|
+
|
|
186
|
+
--aia-written-text-color: #000000;
|
|
187
|
+
--aia-written-text-font-size: 14px;
|
|
188
|
+
--aia-caret-color: var(--aia-written-text-color, #000000);
|
|
189
|
+
|
|
190
|
+
--aia-submit-bg: #000000;
|
|
191
|
+
--aia-submit-color: #ffffff;
|
|
192
|
+
|
|
193
|
+
--aia-color-text-muted: #6b7280;
|
|
194
|
+
|
|
195
|
+
--aia-skeleton-bg: rgba(189, 189, 189, 0.51);
|
|
196
|
+
|
|
197
|
+
--aia-streak-rgb: 99, 102, 241;
|
|
198
|
+
--aia-streak-glass-bg: rgba(99, 102, 241, 0.1);
|
|
199
|
+
|
|
200
|
+
--aia-footer-divider: rgba(176, 176, 176, 0.4);
|
|
201
|
+
--aia-footer-hint-color: #505050;
|
|
202
|
+
--aia-footer-brand-color: #b0b0b0;
|
|
203
|
+
--aia-footer-badge-border: rgba(189, 189, 189, 0.51);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* Dark mode defaults */
|
|
207
|
+
:where(.magicx-aia[data-mode="dark"]) {
|
|
208
|
+
--aia-surface: #000000;
|
|
209
|
+
--aia-border: #505050;
|
|
210
|
+
--aia-dropdown-border: #484848;
|
|
211
|
+
--aia-dropdown-shadow: 0 8px 12px rgba(0, 0, 0, 0.12);
|
|
212
|
+
--aia-pill-bg: #bdbdbd;
|
|
213
|
+
--aia-pill-color: #b0b0b0;
|
|
214
|
+
--aia-pill-font-size: 14px;
|
|
215
|
+
|
|
216
|
+
--aia-option-bg: transparent;
|
|
217
|
+
--aia-option-color: #b0b0b0;
|
|
218
|
+
--aia-option-color-selected: #ffffff;
|
|
219
|
+
--aia-option-font-size: 14px;
|
|
220
|
+
|
|
221
|
+
--aia-written-text-color: #ffffff;
|
|
222
|
+
--aia-written-text-font-size: 14px;
|
|
223
|
+
--aia-caret-color: var(--aia-written-text-color, #ffffff);
|
|
224
|
+
|
|
225
|
+
--aia-submit-bg: #ffffff;
|
|
226
|
+
--aia-submit-color: #000000;
|
|
227
|
+
|
|
228
|
+
--aia-color-text-muted: #c1c4cb;
|
|
229
|
+
|
|
230
|
+
--aia-skeleton-bg: #333539;
|
|
231
|
+
|
|
232
|
+
--aia-streak-rgb: 255, 255, 255;
|
|
233
|
+
--aia-streak-glass-bg: rgba(255, 255, 255, 0.1);
|
|
234
|
+
|
|
235
|
+
--aia-footer-divider: rgba(255, 255, 255, 0.15);
|
|
236
|
+
--aia-footer-hint-color: #b0b0b0;
|
|
237
|
+
--aia-footer-brand-color: #505050;
|
|
238
|
+
--aia-footer-badge-border: #505050;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* optionsPosition: dropdown above the input. The sections live inside the
|
|
242
|
+
dropdown's .aia-stack, so the reversal targets the stack (not the dropdown,
|
|
243
|
+
whose only child is the stack).
|
|
244
|
+
Two forms are supported:
|
|
245
|
+
1. ancestor form \u2014 Tier 1 sets data-options-position on the .magicx-aia
|
|
246
|
+
container and the dropdown is a descendant.
|
|
247
|
+
2. self form \u2014 headless consumers spread \`optionsPosition\` from the hook's
|
|
248
|
+
dropdownProps, so the attribute lands on the dropdown element itself.
|
|
249
|
+
This lets the dropdown position above with NO wrapper attribute and no
|
|
250
|
+
hand-copied CSS. */
|
|
251
|
+
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown],
|
|
252
|
+
[data-aia-dropdown][data-options-position="above"] {
|
|
253
|
+
top: auto;
|
|
254
|
+
bottom: 100%;
|
|
255
|
+
margin-top: 0;
|
|
256
|
+
margin-bottom: 6px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] .aia-stack,
|
|
260
|
+
[data-aia-dropdown][data-options-position="above"] .aia-stack {
|
|
261
|
+
flex-direction: column-reverse;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* The footer sits at the top when the dropdown is above, so flip its own
|
|
265
|
+
internal stack too \u2014 the divider should sit BELOW the hint/branding row
|
|
266
|
+
(between the footer and the options beneath it), not above it. The footer's
|
|
267
|
+
own class is CSS-module-scoped, so target the stable data attribute. */
|
|
268
|
+
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] [data-aia-footer],
|
|
269
|
+
[data-aia-dropdown][data-options-position="above"] [data-aia-footer] {
|
|
270
|
+
flex-direction: column-reverse;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* Disable all animations when data-animations="off" */
|
|
274
|
+
:where(.magicx-aia[data-animations="off"]) *,
|
|
275
|
+
:where(.magicx-aia[data-animations="off"]) *::before,
|
|
276
|
+
:where(.magicx-aia[data-animations="off"]) *::after {
|
|
277
|
+
animation-duration: 0s !important;
|
|
278
|
+
transition-duration: 0s !important;
|
|
279
|
+
}
|
|
280
|
+
`,document.head.appendChild(e)}if(typeof document<"u"&&!document.getElementById("ac-style-3819c762")){let e=document.createElement("style");e.id="ac-style-3819c762",e.textContent=`.AIAutocompleteDropdown-module_dropdown_yz2KC {
|
|
149
281
|
position: absolute;
|
|
150
282
|
left: 0;
|
|
151
283
|
right: 0;
|
|
152
284
|
top: 100%;
|
|
153
|
-
max-width:
|
|
285
|
+
max-width: 544px;
|
|
154
286
|
margin-top: 6px;
|
|
155
287
|
display: flex;
|
|
156
288
|
flex-direction: column;
|
|
157
289
|
box-sizing: border-box;
|
|
158
|
-
padding:
|
|
290
|
+
padding: 4px;
|
|
159
291
|
overflow: hidden;
|
|
160
292
|
container-type: inline-size;
|
|
161
293
|
z-index: 10;
|
|
@@ -165,8 +297,9 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
165
297
|
/* Solid surface is the default (matches the Figma components). Opt into the
|
|
166
298
|
frosted-glass look with data-aia-surface="glass". */
|
|
167
299
|
background: var(--aia-surface, #ffffff);
|
|
168
|
-
border: 1px solid var(--aia-border, #
|
|
300
|
+
border: 1px solid var(--aia-dropdown-border, #e5e7eb);
|
|
169
301
|
border-radius: 25px;
|
|
302
|
+
box-shadow: var(--aia-dropdown-shadow, 0 8px 12px rgba(0, 0, 0, 0.12));
|
|
170
303
|
}
|
|
171
304
|
|
|
172
305
|
.AIAutocompleteDropdown-module_dropdown_yz2KC[data-aia-surface="glass"] {
|
|
@@ -191,10 +324,10 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
191
324
|
pointer-events: auto;
|
|
192
325
|
}
|
|
193
326
|
|
|
194
|
-
/* The dropdown owns
|
|
195
|
-
|
|
327
|
+
/* The dropdown owns a uniform 4px pad; each section adds its own 7px/8px inset
|
|
328
|
+
(matches the Figma PillList). */
|
|
196
329
|
.AIAutocompleteDropdown-module_pillBar_pwTXe {
|
|
197
|
-
padding:
|
|
330
|
+
padding: 7px 8px;
|
|
198
331
|
overflow-x: auto;
|
|
199
332
|
overflow-y: hidden;
|
|
200
333
|
scrollbar-width: none;
|
|
@@ -211,12 +344,12 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
211
344
|
display: flex;
|
|
212
345
|
flex-direction: column;
|
|
213
346
|
gap: 20px;
|
|
214
|
-
padding:
|
|
347
|
+
padding: 7px 8px;
|
|
215
348
|
}
|
|
216
349
|
|
|
217
350
|
.AIAutocompleteDropdown-module_skeletonBar_O3xIx {
|
|
218
351
|
display: block;
|
|
219
|
-
height:
|
|
352
|
+
height: 14px;
|
|
220
353
|
border-radius: 999px;
|
|
221
354
|
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.51)));
|
|
222
355
|
opacity: 0.5;
|
|
@@ -240,7 +373,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
240
373
|
opacity: 0.25;
|
|
241
374
|
}
|
|
242
375
|
}
|
|
243
|
-
`,document.head.appendChild(e)}var ne={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{getFooterHint as
|
|
376
|
+
`,document.head.appendChild(e)}var ne={dropdown:"AIAutocompleteDropdown-module_dropdown_yz2KC",visible:"AIAutocompleteDropdown-module_visible_QCoXj",pillBar:"AIAutocompleteDropdown-module_pillBar_pwTXe",skeletonBars:"AIAutocompleteDropdown-module_skeletonBars_HVr9C",skeletonBar:"AIAutocompleteDropdown-module_skeletonBar_O3xIx",aiaSkeletonPulse:"AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q"};import{getFooterHint as ut}from"@magicx-eng/ai-autocomplete-vanilla";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
|
|
244
377
|
.aia-cluster {
|
|
245
378
|
display: flex;
|
|
246
379
|
flex-wrap: wrap;
|
|
@@ -282,14 +415,14 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
282
415
|
justify-content: space-around;
|
|
283
416
|
}
|
|
284
417
|
}
|
|
285
|
-
`,document.head.appendChild(e)}import{jsx as Me}from"react/jsx-runtime";function le({gap:e,align:
|
|
286
|
-
|
|
287
|
-
|
|
418
|
+
`,document.head.appendChild(e)}import{jsx as Me}from"react/jsx-runtime";function le({gap:e,align:c="center",justify:i="start",noWrap:u=!1,inline:r=!1,className:n,children:s,...l}){let g=e?{"--aia-cluster-gap":e}:void 0,b={className:n?`aia-cluster ${n}`:"aia-cluster","data-align":c,"data-justify":i,"data-nowrap":u||void 0,"data-inline":r||void 0,style:g,...l};return r?Me("span",{...b,children:s}):Me("div",{...b,children:s})}if(typeof document<"u"&&!document.getElementById("ac-style-56b0c577")){let e=document.createElement("style");e.id="ac-style-56b0c577",e.textContent=`/* The footer adds its own 7px/8px inset (the dropdown owns a uniform 4px pad),
|
|
419
|
+
so the divider spans the full footer width yet still stays clear of the
|
|
420
|
+
dropdown's rounded edges. */
|
|
288
421
|
.DropdownFooter-module_footer_qQQ7x {
|
|
289
422
|
display: flex;
|
|
290
423
|
flex-direction: column;
|
|
291
|
-
gap:
|
|
292
|
-
padding:
|
|
424
|
+
gap: 8px;
|
|
425
|
+
padding: 7px 8px;
|
|
293
426
|
}
|
|
294
427
|
|
|
295
428
|
.DropdownFooter-module_divider_FlX4C {
|
|
@@ -323,14 +456,14 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
323
456
|
border: 0.5px solid var(--aia-footer-hint-color, #505050);
|
|
324
457
|
border-radius: 5px;
|
|
325
458
|
font-family: inherit;
|
|
326
|
-
font-size:
|
|
459
|
+
font-size: 11px;
|
|
327
460
|
line-height: 18px;
|
|
328
461
|
color: var(--aia-footer-hint-color, #505050);
|
|
329
462
|
}
|
|
330
463
|
|
|
331
464
|
.DropdownFooter-module_hint_GKEOH {
|
|
332
465
|
font-family: inherit;
|
|
333
|
-
font-size:
|
|
466
|
+
font-size: 11px;
|
|
334
467
|
line-height: 18px;
|
|
335
468
|
color: var(--aia-footer-hint-color, #505050);
|
|
336
469
|
}
|
|
@@ -347,19 +480,18 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
347
480
|
align-items: center;
|
|
348
481
|
height: 23px;
|
|
349
482
|
padding: 2.5px 5.5px;
|
|
350
|
-
border: 0.
|
|
483
|
+
border: 0.5px solid var(--aia-footer-badge-border, rgba(189, 189, 189, 0.51));
|
|
351
484
|
border-radius: 999px;
|
|
352
485
|
font-family: inherit;
|
|
353
486
|
font-size: 10px;
|
|
354
487
|
line-height: 18px;
|
|
355
488
|
color: var(--aia-footer-brand-color, #b0b0b0);
|
|
356
489
|
}
|
|
357
|
-
`,document.head.appendChild(e)}var
|
|
490
|
+
`,document.head.appendChild(e)}var Q={footer:"DropdownFooter-module_footer_qQQ7x",divider:"DropdownFooter-module_divider_FlX4C",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"};import{jsx as de,jsxs as be}from"react/jsx-runtime";function Ne({hasTabbedToHighlight:e=!1,isOptionHighlighted:c=!1,isInputEmpty:i=!1}){let{key:u,hint:r}=ut(e,c,i);return be("footer",{className:Q.footer,"data-aia-footer":"",children:[de("div",{className:Q.divider}),be(le,{justify:"between",noWrap:!0,children:[be(le,{gap:"5px",className:Q.hintGroup,children:[de("kbd",{className:Q.key,children:u}),de("span",{className:Q.hint,children:r})]}),be("a",{className:Q.brandLink,href:"https://ai-autocomplete.com",target:"_blank",rel:"noopener noreferrer",children:[de("span",{className:Q.brand,children:"AI"}),de("span",{className:Q.badge,children:"Autocomplete"})]})]})]})}if(typeof document<"u"&&!document.getElementById("ac-style-04fef8d6")){let e=document.createElement("style");e.id="ac-style-04fef8d6",e.textContent=`.Pill-module_pill_3Rkw- {
|
|
358
491
|
display: inline-flex;
|
|
359
492
|
align-items: center;
|
|
360
493
|
justify-content: center;
|
|
361
|
-
|
|
362
|
-
padding: 10px 12px;
|
|
494
|
+
padding: 7px 8px;
|
|
363
495
|
border: none;
|
|
364
496
|
border-radius: 999px;
|
|
365
497
|
background: rgba(49, 50, 85, 0.25);
|
|
@@ -370,8 +502,9 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
370
502
|
);
|
|
371
503
|
color: var(--aia-pill-color, var(--aia-color-text-muted, #c1c4cb));
|
|
372
504
|
font-family: inherit;
|
|
373
|
-
font-size: var(--aia-pill-font-size,
|
|
374
|
-
|
|
505
|
+
font-size: var(--aia-pill-font-size, 14px);
|
|
506
|
+
font-weight: 500;
|
|
507
|
+
line-height: normal;
|
|
375
508
|
cursor: pointer;
|
|
376
509
|
white-space: nowrap;
|
|
377
510
|
animation: Pill-module_fadeIn_Bbqtz 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
|
@@ -406,7 +539,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
406
539
|
opacity: 0;
|
|
407
540
|
}
|
|
408
541
|
}
|
|
409
|
-
`,document.head.appendChild(e)}var
|
|
542
|
+
`,document.head.appendChild(e)}var X={pill:"Pill-module_pill_3Rkw-",fadeIn:"Pill-module_fadeIn_Bbqtz",rounded:"Pill-module_rounded_6WMps",skeleton:"Pill-module_skeleton_-u9-j",skeletonPulse:"Pill-module_skeletonPulse_xHh-7"};import{jsx as mt}from"react/jsx-runtime";var Ae={selected:1,first:.7,next:.4,last:.2};function Ke({label:e,state:c,selected:i,rounded:u,loading:r,onClick:n}){let s=[X.pill,u?X.rounded:"",i&&!r?X.active:"",r?X.skeleton:""].filter(Boolean).join(" ");return mt("button",{type:"button","data-aia-pill":"","data-aia-loading":r?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:s,style:{opacity:Ae[c]},onMouseDown:l=>l.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 {
|
|
410
543
|
position: relative;
|
|
411
544
|
z-index: 1;
|
|
412
545
|
pointer-events: auto;
|
|
@@ -415,7 +548,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
415
548
|
align-items: center;
|
|
416
549
|
vertical-align: middle;
|
|
417
550
|
}
|
|
418
|
-
`,document.head.appendChild(e)}var
|
|
551
|
+
`,document.head.appendChild(e)}var Pe={list:"PillList-module_list_qvLqO"};import{jsx as xe}from"react/jsx-runtime";var gt=[125,69];function We(e){return e===0?"first":e===1?"next":"last"}function ve({pills:e,activePillIndex:c,onSelectPill:i,activeSelected:u,rounded:r,loading:n}){return n&&e.length===0?xe("span",{className:Pe.list,"data-aia-pill-list-loading":"",children:gt.map((s,l)=>xe("span",{"data-aia-pill-skeleton":"",className:`${X.pill} ${r?X.rounded:""} ${X.skeleton}`,style:{width:s,opacity:Ae[We(l)]}},`skel-${s}`))}):xe("span",{className:Pe.list,"data-aia-pill-list-loading":n?"":void 0,children:e.map((s,l)=>{let g=!!u&&l===c;return xe(Ke,{label:s.text,state:g?"selected":We(l),selected:g,rounded:r,loading:n,onClick:()=>i(l)},`${s.type}-${s.text}`)})})}import{useEffect as ft,useLayoutEffect as ht,useRef as bt,useState as xt}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-948e58da")){let e=document.createElement("style");e.id="ac-style-948e58da",e.textContent=`@layer layout {
|
|
419
552
|
.aia-grid {
|
|
420
553
|
display: grid;
|
|
421
554
|
grid-template-columns: repeat(
|
|
@@ -469,7 +602,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
469
602
|
opacity: 1;
|
|
470
603
|
}
|
|
471
604
|
}
|
|
472
|
-
`,document.head.appendChild(e)}import{jsx as Ge}from"react/jsx-runtime";function je({min:e="16rem",max:
|
|
605
|
+
`,document.head.appendChild(e)}import{jsx as Ge}from"react/jsx-runtime";function je({min:e="16rem",max:c,gap:i,scroll:u=!1,maxHeight:r,fade:n=!1,className:s,children:l,...g}){let b=bt(null),[D,k]=xt(!1);ft(()=>{if(!n)return;let x=b.current;if(!x)return;let R=()=>{k(x.scrollHeight-x.scrollTop-x.clientHeight>1)};x.addEventListener("scroll",R,{passive:!0});let z=new ResizeObserver(R);return z.observe(x),()=>{x.removeEventListener("scroll",R),z.disconnect()}},[n]),ht(()=>{let x=b.current;!n||!x||k(x.scrollHeight-x.scrollTop-x.clientHeight>1)},[n,l]);let I={"--aia-grid-min":e};c&&(I["--aia-grid-max"]=c),i&&(I["--aia-grid-gap"]=i),r&&(I["--aia-grid-max-height"]=r);let S=Ge("div",{ref:b,className:!n&&s?`aia-grid ${s}`:"aia-grid","data-scroll":u||void 0,style:I,...n?{}:g,children:l});return n?Ge("div",{className:s?`aia-grid-fade ${s}`:"aia-grid-fade","data-fade":D?"":void 0,...g,children:S}):S}import{useEffect as vt,useRef as wt,useState as yt}from"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 {
|
|
473
606
|
position: relative;
|
|
474
607
|
overflow: visible;
|
|
475
608
|
display: flex;
|
|
@@ -477,17 +610,16 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
477
610
|
the same baseline at the top edge of the cell. */
|
|
478
611
|
align-items: flex-start;
|
|
479
612
|
font-family: inherit;
|
|
480
|
-
font-size: var(--aia-option-font-size,
|
|
481
|
-
font-weight:
|
|
482
|
-
line-height:
|
|
613
|
+
font-size: var(--aia-option-font-size, 14px);
|
|
614
|
+
font-weight: 300;
|
|
615
|
+
line-height: 18px;
|
|
483
616
|
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
484
617
|
white-space: normal;
|
|
485
618
|
word-break: break-word;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
padding: 10px 15px;
|
|
619
|
+
/* 8px radius on the highlighted fill (--aia-option-bg), matching the Figma
|
|
620
|
+
SuggestionItem selection. The 7px/8px inset is the item's own padding. */
|
|
621
|
+
border-radius: 8px;
|
|
622
|
+
padding: 7px 8px;
|
|
491
623
|
animation: SuggestionItem-module_fadeIn_I8u35 500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
|
492
624
|
}
|
|
493
625
|
|
|
@@ -517,6 +649,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
517
649
|
.SuggestionItem-module_highlighted_Hb0SU {
|
|
518
650
|
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
519
651
|
background: var(--aia-option-bg, transparent);
|
|
652
|
+
font-weight: 700;
|
|
520
653
|
}
|
|
521
654
|
|
|
522
655
|
.SuggestionItem-module_tag_e3Fwe {
|
|
@@ -819,7 +952,7 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
819
952
|
filter: brightness(0.55);
|
|
820
953
|
}
|
|
821
954
|
}
|
|
822
|
-
`,document.head.appendChild(e)}var
|
|
955
|
+
`,document.head.appendChild(e)}var M={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"};import{jsx as we,jsxs as Ve}from"react/jsx-runtime";function qe({option:e,isHighlighted:c,onSelect:i,onHighlight:u,id:r,loading:n}){let[s,l]=yt(!1),g=wt(void 0);vt(()=>()=>clearTimeout(g.current),[]);let b=()=>{n||!e.is_tappable||s||(l(!0),i(e),clearTimeout(g.current),g.current=setTimeout(()=>l(!1),500))},D=[M.item,c&&!n?M.highlighted:"",e.is_tappable?M.tappable:M.nonTappable,s?M.pressed:""].filter(Boolean).join(" ");return Ve("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":n?"":void 0,"aria-selected":c,className:D,tabIndex:n||!e.is_tappable?-1:0,onClick:b,onKeyDown:k=>{!n&&e.is_tappable&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),b())},onMouseEnter:!n&&e.is_tappable?u:void 0,children:[we("div",{className:M.streaks}),we("div",{className:M.streaksVert}),Ve("span",{className:M.content,children:[we("span",{className:M.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&we("span",{className:M.tag,children:e.tag})]})]})}import{jsx as $e}from"react/jsx-runtime";function Ue({options:e,activeIndex:c,onSelect:i,onHighlight:u,listboxId:r,loading:n}){return $e(je,{min:"250px",max:"250px",gap:"0",scroll:!0,fade:!0,children:e.map((s,l)=>$e(qe,{option:s,isHighlighted:l===c,onSelect:i,onHighlight:()=>u(l),id:`${r}-option-${l}`,loading:n},s.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
|
|
823
956
|
.aia-stack {
|
|
824
957
|
display: flex;
|
|
825
958
|
flex-direction: column;
|
|
@@ -836,128 +969,10 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
836
969
|
}
|
|
837
970
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
838
971
|
}
|
|
839
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
840
|
-
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
841
|
-
* Consumer CSS always wins without !important.
|
|
842
|
-
*
|
|
843
|
-
* Resolution priority (highest wins):
|
|
844
|
-
* 1. Consumer CSS targeting new vars (--aia-pill-bg, etc.)
|
|
845
|
-
* 2. Consumer CSS targeting legacy vars (--aia-color-*, via fallback chain)
|
|
846
|
-
* 3. These built-in defaults
|
|
847
|
-
*/
|
|
848
|
-
|
|
849
|
-
/*
|
|
850
|
-
* Library-scoped box-sizing reset. The SDK's pill / option / wrapper styles
|
|
851
|
-
* mix explicit dimensions with padding (e.g. .magicx-aia-pill has height:36px
|
|
852
|
-
* + padding:13px) and were authored assuming \`border-box\`. In consumer apps
|
|
853
|
-
* without a global \`* { box-sizing: border-box }\` reset the pill rendered
|
|
854
|
-
* ~62px tall instead of 36px. Scoping the reset to \`.magicx-aia\` descendants
|
|
855
|
-
* keeps the library self-contained without leaking onto consumer markup.
|
|
856
|
-
*/
|
|
857
|
-
:where(.magicx-aia, .magicx-aia *, .magicx-aia *::before, .magicx-aia *::after) {
|
|
858
|
-
box-sizing: border-box;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
/* Light mode defaults (base) */
|
|
862
|
-
:where(.magicx-aia),
|
|
863
|
-
:where(.magicx-aia[data-mode="light"]) {
|
|
864
|
-
--aia-surface: #ffffff;
|
|
865
|
-
--aia-border: #b0b0b0;
|
|
866
|
-
--aia-pill-bg: #bdbdbd;
|
|
867
|
-
--aia-pill-color: #333539;
|
|
868
|
-
--aia-pill-font-size: 18px;
|
|
869
|
-
|
|
870
|
-
--aia-option-bg: transparent;
|
|
871
|
-
--aia-option-color: #505050;
|
|
872
|
-
--aia-option-color-selected: #000000;
|
|
873
|
-
--aia-option-font-size: 18px;
|
|
874
|
-
|
|
875
|
-
--aia-written-text-color: #000000;
|
|
876
|
-
--aia-written-text-font-size: 20px;
|
|
877
|
-
--aia-caret-color: var(--aia-written-text-color, #000000);
|
|
878
|
-
|
|
879
|
-
--aia-submit-bg: #000000;
|
|
880
|
-
--aia-submit-color: #ffffff;
|
|
881
|
-
|
|
882
|
-
--aia-color-text-muted: #6b7280;
|
|
883
|
-
|
|
884
|
-
--aia-skeleton-bg: rgba(189, 189, 189, 0.51);
|
|
885
|
-
|
|
886
|
-
--aia-streak-rgb: 99, 102, 241;
|
|
887
|
-
--aia-streak-glass-bg: rgba(99, 102, 241, 0.1);
|
|
888
|
-
|
|
889
|
-
--aia-footer-divider: rgba(176, 176, 176, 0.4);
|
|
890
|
-
--aia-footer-hint-color: #505050;
|
|
891
|
-
--aia-footer-brand-color: #b0b0b0;
|
|
892
|
-
--aia-footer-badge-border: rgba(189, 189, 189, 0.51);
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
/* Dark mode defaults */
|
|
896
|
-
:where(.magicx-aia[data-mode="dark"]) {
|
|
897
|
-
--aia-surface: #000000;
|
|
898
|
-
--aia-border: #505050;
|
|
899
|
-
--aia-pill-bg: #bdbdbd;
|
|
900
|
-
--aia-pill-color: #b0b0b0;
|
|
901
|
-
--aia-pill-font-size: 18px;
|
|
902
|
-
|
|
903
|
-
--aia-option-bg: transparent;
|
|
904
|
-
--aia-option-color: #b0b0b0;
|
|
905
|
-
--aia-option-color-selected: #ffffff;
|
|
906
|
-
--aia-option-font-size: 18px;
|
|
907
|
-
|
|
908
|
-
--aia-written-text-color: #ffffff;
|
|
909
|
-
--aia-written-text-font-size: 20px;
|
|
910
|
-
--aia-caret-color: var(--aia-written-text-color, #ffffff);
|
|
911
|
-
|
|
912
|
-
--aia-submit-bg: #ffffff;
|
|
913
|
-
--aia-submit-color: #000000;
|
|
914
|
-
|
|
915
|
-
--aia-color-text-muted: #c1c4cb;
|
|
916
|
-
|
|
917
|
-
--aia-skeleton-bg: #333539;
|
|
918
|
-
|
|
919
|
-
--aia-streak-rgb: 255, 255, 255;
|
|
920
|
-
--aia-streak-glass-bg: rgba(255, 255, 255, 0.1);
|
|
921
|
-
|
|
922
|
-
--aia-footer-divider: rgba(255, 255, 255, 0.15);
|
|
923
|
-
--aia-footer-hint-color: #b0b0b0;
|
|
924
|
-
--aia-footer-brand-color: #505050;
|
|
925
|
-
--aia-footer-badge-border: #505050;
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
/* optionsPosition: dropdown above the input. The sections live inside the
|
|
929
|
-
dropdown's .aia-stack, so the reversal targets the stack (not the dropdown,
|
|
930
|
-
whose only child is the stack). */
|
|
931
|
-
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] {
|
|
932
|
-
top: auto;
|
|
933
|
-
bottom: 100%;
|
|
934
|
-
margin-top: 0;
|
|
935
|
-
margin-bottom: 6px;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] .aia-stack {
|
|
939
|
-
flex-direction: column-reverse;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
/* The footer sits at the top when the dropdown is above, so flip its own
|
|
943
|
-
internal stack too \u2014 the divider should sit BELOW the hint/branding row
|
|
944
|
-
(between the footer and the options beneath it), not above it. The footer's
|
|
945
|
-
own class is CSS-module-scoped, so target the stable data attribute. */
|
|
946
|
-
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] [data-aia-footer] {
|
|
947
|
-
flex-direction: column-reverse;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
/* Disable all animations when data-animations="off" */
|
|
951
|
-
:where(.magicx-aia[data-animations="off"]) *,
|
|
952
|
-
:where(.magicx-aia[data-animations="off"]) *::before,
|
|
953
|
-
:where(.magicx-aia[data-animations="off"]) *::after {
|
|
954
|
-
animation-duration: 0s !important;
|
|
955
|
-
transition-duration: 0s !important;
|
|
956
|
-
}
|
|
957
|
-
`,document.head.appendChild(e)}import{buildQuery as Lt,ModeController as zt,setCursorOffset as Bt}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=`.SubmitButton-module_submitButton_otz7H {
|
|
972
|
+
`,document.head.appendChild(e)}import{jsx as _t}from"react/jsx-runtime";function Qe({space:e,align:c="stretch",className:i,children:u,...r}){let n=e?{"--aia-stack-space":e}:void 0;return _t("div",{className:i?`aia-stack ${i}`:"aia-stack","data-align":c,style:n,...r,children:u})}import{jsx as oe,jsxs as St}from"react/jsx-runtime";var kt=[159,119,164];function Ce({suggestions:e,activeIndex:c,onSelect:i,onHighlight:u,isOpen:r,id:n,className:s,pills:l,onPillClick:g,showPills:b=!0,activeSelected:D=!1,isLoading:k=!1,hasTabbedToHighlight:I=!1,isInputEmpty:S=!1,optionsPosition:x="below"}){let R=e[0]?.options??[],z=!!(l&&l.length>0&&g),F=r&&(R.length>0||b&&z||k),t={suggestions:e,activeIndex:c,pills:l,showPills:b,activeSelected:D,isLoading:k,hasTabbedToHighlight:I,isInputEmpty:S},w=It(t);F&&(w.current=t);let m=F?t:w.current,T=m.suggestions[0]?.options??[],G=m.activeIndex>=0&&!!T[m.activeIndex]?.is_tappable,H=!!(m.pills&&m.pills.length>0&&g),C=m.showPills&&H,j=m.showPills&&!H&&m.isLoading,L=C||j,V=T.length>0,q=m.isLoading&&!V;return oe("div",{id:n,role:"listbox","data-aia-dropdown":"","data-options-position":x,"data-aia-loading":m.isLoading?"":void 0,className:`${ne.dropdown} ${F?ne.visible:""} ${s??""}`,onMouseDown:B=>B.preventDefault(),children:St(Qe,{space:"2px",children:[L&&oe(le,{noWrap:!0,className:ne.pillBar,"data-aia-pillbar":"",children:oe(ve,{pills:m.pills??[],activePillIndex:0,activeSelected:m.activeSelected,onSelectPill:g??(()=>{}),rounded:!0,loading:m.isLoading})}),V&&oe(Ue,{options:T,activeIndex:m.activeIndex,onSelect:i,onHighlight:u,listboxId:n,loading:m.isLoading}),q&&oe("div",{className:ne.skeletonBars,"data-aia-skeleton-bars":"",children:kt.map(B=>oe("span",{className:ne.skeletonBar,style:{width:B}},`bar-${B}`))}),oe(Ne,{hasTabbedToHighlight:m.hasTabbedToHighlight,isOptionHighlighted:G,isInputEmpty:m.isInputEmpty})]})})}import{buildQuery as zt,ModeController as Ft,setCursorOffset as Ht}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=`.SubmitButton-module_submitButton_otz7H {
|
|
958
973
|
flex-shrink: 0;
|
|
959
|
-
width:
|
|
960
|
-
height:
|
|
974
|
+
width: 32px;
|
|
975
|
+
height: 32px;
|
|
961
976
|
border-radius: 50%;
|
|
962
977
|
border: none;
|
|
963
978
|
background: var(--aia-submit-bg, var(--aia-color-text-default, #fff));
|
|
@@ -978,5 +993,5 @@ import{forwardRef as Dt,useCallback as Le,useEffect as at,useImperativeHandle as
|
|
|
978
993
|
opacity: 0.4;
|
|
979
994
|
cursor: default;
|
|
980
995
|
}
|
|
981
|
-
`,document.head.appendChild(e)}var Xe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ee}from"react/jsx-runtime";function Je({disabled:e,onClick:s}){return Ee("button",{type:"button","data-aia-submit":"",className:Xe.submitButton,disabled:e,onClick:r=>{r.stopPropagation(),s()},"aria-label":"Submit",children:Ee("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ee("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as It}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ze,useEffect as ye,useRef as F,useState as St}from"react";var At={text:"",completedParams:[],suggestions:[],activeDropdownIndex:-1,newParamId:null,isLoading:!0,isReady:!1,error:null,segments:[],actionableSuggestions:[],filteredOptions:[],placeholderText:"",isDropdownOpen:!1,filterBase:0,filterInProgress:!1,pillTapped:!1,skipNextFetch:!1,lastRawQuery:"",isFocused:!1,editingParam:null,editingAnchor:null,editingTail:null,caretOffset:null,inSelectionAnimation:!1,hasTabbedToHighlight:!1};function De({onSubmit:e,onError:s,optionOverrides:r,maskCompletedText:c,apiConfig:i,columns:t=2,dropdownTrigger:l,optionsPosition:u,closeDropdownOnBlur:v,showNonTappableOptions:f,onFocus:_,onBlur:S,value:I,completedParams:k,onChange:h,onParamsChange:P,source:R,setCursor:V}){let n=F(null),[b,O]=St(null),N=F(e);N.current=e;let E=F(s);E.current=s;let Q=F(h);Q.current=h;let q=F(P);q.current=P;let T=F(_);T.current=_;let X=F(S);X.current=S;let L=F(V);L.current=V,ye(()=>{if(typeof document>"u")return;let o=new It(document.createElement("div"),{renderMode:"headless",apiConfig:i,optionOverrides:r,maskCompletedText:c,columns:t,dropdownTrigger:l,optionsPosition:u,closeDropdownOnBlur:v,showNonTappableOptions:f,source:R,value:I,completedParams:k,onSubmit:(...A)=>N.current?.(...A),onError:(...A)=>E.current?.(...A),onChange:(...A)=>Q.current?.(...A),onParamsChange:(...A)=>q.current?.(...A),onFocus:()=>T.current?.(),onBlur:()=>X.current?.(),setCursor:A=>L.current?.(A)});n.current=o,O(o.getState());let C=o.subscribe(A=>O(A));return()=>{C(),o.destroy(),n.current===o&&(n.current=null)}},[]),ye(()=>{I!==void 0&&n.current?.setValue(I)},[I]),ye(()=>{k!==void 0&&n.current?.setCompletedParams(k)},[k]);let oe=JSON.stringify(i??null),J=F(r),$=F(0);if(r!==J.current){let o=J.current,C=r,A=Object.keys(o??{}),ae=Object.keys(C??{});(A.length!==ae.length||ae.some(se=>!o?.[se]||C[se]!==o[se]))&&$.current++,J.current=r}ye(()=>{n.current?.update({apiConfig:i,optionOverrides:r,dropdownTrigger:l,optionsPosition:u,closeDropdownOnBlur:v,showNonTappableOptions:f})},[oe,$.current,l,u,v,f]);let K=F(null);K.current===null&&(K.current={handleTextChange:o=>n.current?.handleTextChange(o),handleKeyDown:o=>{let C="nativeEvent"in o?o.nativeEvent:o;n.current?.handleKeyDown(C)},setFocused:o=>n.current?.setFocused(o),startEditingParam:o=>n.current?.startEditingParam(o),exitEditMode:()=>n.current?.exitEditMode(),handleCaretAfterInput:o=>n.current?.handleCaretAfterInput(o),handleCaretMove:o=>n.current?.handleCaretMove(o),replaceEditingRange:o=>n.current?.replaceEditingRange(o)??!1,setActivePill:o=>n.current?.setActivePill(o),removeLastParam:()=>n.current?.removeLastParam(),clearNewParamId:()=>n.current?.clearNewParamId(),reset:()=>n.current?.reset(),selectOption:o=>n.current?.selectOption(o),setActiveDropdownIndex:o=>n.current?.setActiveDropdownIndex(o),handleFocus:()=>n.current?.setFocused(!0),handleBlur:()=>n.current?.setFocused(!1)});let w=K.current,Z=Ze(o=>{let C=o.target.value,ae=C.length>0&&!o.nativeEvent?.isComposing&&C[0]!==C[0].toUpperCase()?C[0].toUpperCase()+C.slice(1):C;n.current?.handleTextChange(ae)},[]),Y=Ze(o=>{n.current?.handleKeyDown(o.nativeEvent)},[]),U=n.current,d=b??At,a=I!==void 0?I:d.text,p=k!==void 0?k:d.completedParams,m=d.actionableSuggestions,y=m[0],g=U?.listboxId??"",D=d.activeDropdownIndex>=0&&U?`${g}-option-${d.activeDropdownIndex}`:void 0,z=d.editingParam,W=z?{type:z.suggestionType,text:z.suggestionPlaceholder,required:!0,options:z.options}:null,pe=W??y,ke=W?[W]:m,ue=!U||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:p,suggestionPills:m,setActivePill:w.setActivePill,removeLastParam:w.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:w.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:ue,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,placeholderText:d.placeholderText,listboxId:g,error:d.error,handleTextChange:w.handleTextChange,handleKeyDown:w.handleKeyDown,setFocused:w.setFocused,editingParam:z,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:w.startEditingParam,exitEditMode:w.exitEditMode,handleCaretAfterInput:w.handleCaretAfterInput,handleCaretMove:w.handleCaretMove,replaceEditingRange:w.replaceEditingRange,inputProps:{value:a,placeholder:d.placeholderText||void 0,onChange:Z,onKeyDown:Y,onFocus:w.handleFocus,onBlur:w.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":D,"aria-autocomplete":"list","aria-controls":g},reset:w.reset,dropdownProps:{suggestions:pe?[{...pe,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:w.selectOption,onHighlight:w.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:g,pills:ke,onPillClick:w.setActivePill,isLoading:ue,hasTabbedToHighlight:d.hasTabbedToHighlight}}}import{extractPlainText as Ye,getCursorOffset as et,plainTextLength as Ct,renderEditableContent as Pt,setCursorOffset as tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as H,useEffect as Re,useLayoutEffect as Te,useRef as re}from"react";var _e;function Et(){if(_e!==void 0)return _e;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),_e=e.contentEditable==="plaintext-only",_e}function ot(e){let{segments:s,newParamId:r,editingParam:c,editingAnchor:i,caretOffset:t,placeholderText:l,isFocused:u,isDropdownOpen:v,listboxId:f,activeDescendantId:_,autoFocus:S,handleTextChange:I,handleKeyDown:k,handleCaretAfterInput:h,handleCaretMove:P,startEditingParam:R,replaceEditingRange:V,setFocused:n}=e,b=re(null),O=re(!1),N=re(""),E=re(""),Q=re(null),q=re(0);Q.current=t,Re(()=>{if(!S)return;let a=b.current;a&&(document.activeElement===a?n(!0):a.focus())},[S,n]),Re(()=>{let a=b.current;if(!a)return;let p=a.ownerDocument??document,m=()=>{let y=p.getSelection();if(!y||y.rangeCount===0||!y.anchorNode||!a.contains(y.anchorNode))return;let g=y.anchorNode,W=(g.nodeType===Node.ELEMENT_NODE?g:g.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(W&&W!==c?.id){R(W);return}performance.now()-q.current<50||P(et(a))};return p.addEventListener("selectionchange",m),()=>p.removeEventListener("selectionchange",m)},[c,R,P]),Te(()=>{let a=b.current;a&&Pt({input:a,segments:s,newParamId:r,editingParamId:c?.id??null,placeholderText:l??"",isFocused:u})},[s,r,c,l,u]),Te(()=>{let a=N.current,p=r??"";if(N.current=p,!p||p===a)return;let m=b.current;if(!m)return;m.focus();let y=Q.current??Ct(m);tt(m,y)},[r]),Te(()=>{let a=E.current,p=c?.id??"";if(E.current=p,!p||p===a||i==null)return;let m=b.current;m&&tt(m,i)},[c,i]);let T=H(()=>{if(O.current)return;let a=b.current;if(!a)return;let p=Ye(a),y=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;I(y)},[I]),X=H(()=>{q.current=performance.now(),T();let a=b.current;a&&h(et(a))},[T,h]);Re(()=>{let a=b.current;if(!a)return;let p=m=>{let y=m,g=y.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){m.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let D=g.startsWith("delete")?"":y.data??"";V(D)&&m.preventDefault()}};return a.addEventListener("beforeinput",p),()=>a.removeEventListener("beforeinput",p)},[V]);let L=H(()=>{O.current=!0},[]),oe=H(()=>{O.current=!1,T()},[T]),J=H(a=>{a.preventDefault();let p=b.current;if(!p)return;let m=(a.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!m)return;let y=p.ownerDocument??document,g=y.getSelection();if(!g||g.rangeCount===0)return;let D=g.getRangeAt(0);if(!p.contains(D.startContainer))return;D.deleteContents();let z=y.createTextNode(m);D.insertNode(z),D.setStartAfter(z),D.collapse(!0),g.removeAllRanges(),g.addRange(D),T()},[T]),$=H(a=>k(a),[k]),K=H(()=>n(!0),[n]),w=H(()=>n(!1),[n]),Z=H(()=>b.current?.focus(),[]),Y=H(()=>b.current?.blur(),[]),U=H(()=>{let a=b.current;return a?Ye(a):""},[]),d=Et()?"plaintext-only":"true";return{inputRef:b,editorProps:{ref:b,contentEditable:d,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":f,"aria-expanded":v,"aria-activedescendant":_,spellCheck:!0,enterKeyHint:"send",onInput:X,onKeyDown:$,onCompositionStart:L,onCompositionEnd:oe,onPaste:J,onFocus:K,onBlur:w},getPlainText:U,focus:Z,blur:Y}}import{jsx as ie,jsxs as ze}from"react/jsx-runtime";function Ft(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ht=Dt(function({onSubmit:s,onError:r,optionOverrides:c,maskCompletedText:i,className:t,apiConfig:l,columns:u,pillPlacement:v="inline",mode:f="auto",optionsPosition:_="below",animations:S=!0,dropdownTrigger:I,closeDropdownOnBlur:k,showNonTappableOptions:h,autoFocus:P=!0,onFocus:R,onBlur:V,value:n,completedParams:b,onChange:O,onParamsChange:N,submitButton:E},Q){let q=ce(null),T=ce(null),X=ce(()=>{}),L=ce(null),oe=ce(null);at(()=>{let x=q.current;if(x)return L.current?L.current.setMode(f):L.current=new zt(x,f),()=>{L.current?.destroy(),L.current=null}},[f]);let J=Le(x=>{let M=oe.current?.current;M&&(M.focus(),Bt(M,x))},[]),{completedParams:$,suggestionPills:K,setActivePill:w,segments:Z,newParamId:Y,clearNewParamId:U,placeholderText:d,isFocused:a,isDropdownOpen:p,isLoading:m,activeIndex:y,listboxId:g,handleTextChange:D,handleKeyDown:z,setFocused:W,editingParam:pe,editingAnchor:ke,caretOffset:ue,startEditingParam:o,handleCaretAfterInput:C,handleCaretMove:A,replaceEditingRange:ae,dropdownProps:se,reset:me}=De({onSubmit:x=>X.current(x),onError:r,optionOverrides:c,maskCompletedText:i,apiConfig:l,columns:u,dropdownTrigger:I,optionsPosition:_,closeDropdownOnBlur:k,showNonTappableOptions:h,onFocus:R,onBlur:V,value:n,completedParams:b,onChange:O,onParamsChange:N,source:"full-sdk",setCursor:J});at(()=>{if(!Y)return;let x=window.setTimeout(()=>U(),650);return()=>window.clearTimeout(x)},[Y,U]);let nt=y>=0?`${g}-option-${y}`:void 0,{inputRef:Ie,editorProps:rt,focus:ge,blur:Be,getPlainText:Fe}=ot({segments:Z,newParamId:Y,editingParam:pe,editingAnchor:ke,caretOffset:ue,placeholderText:d,isFocused:a,isDropdownOpen:p,listboxId:g,activeDescendantId:nt,autoFocus:P,handleTextChange:D,handleKeyDown:z,handleCaretAfterInput:C,handleCaretMove:A,startEditingParam:o,replaceEditingRange:ae,setFocused:W});oe.current=Ie,Tt(()=>{let x=T.current,M=Ie.current;if(!x||!M)return;let he=()=>{let Oe=x.firstElementChild;if(!Oe)return;let dt=Oe.getBoundingClientRect(),ct=M.getBoundingClientRect();dt.top>=ct.bottom-2?x.setAttribute("data-aia-pill-wrapped",""):x.removeAttribute("data-aia-pill-wrapped")};he();let He=new ResizeObserver(he);return He.observe(M),()=>He.disconnect()},[Z,K.length,m,Ie]),Rt(Q,()=>({focus:ge,blur:Be,reset:me,setMode:x=>L.current?.setMode(x)}),[ge,Be,me]);let fe=!!Z.length||$.length>0,Se=Le(()=>{if(!fe)return;let x=Fe(),{rawQuery:M,completedParams:he}=Lt(x,$);s({query:x.trim(),raw_query:M,completed_params:he}),me()},[fe,$,s,me,Fe]);X.current=Se;let it=Le(x=>{x.target?.closest("[data-aia-pill]")||ge()},[ge]),st=v==="inline",lt=v==="dropdown";return ze("div",{ref:q,className:`magicx-aia ${ee.container} ${t??""}`,"data-pill-placement":v,"data-options-position":_,"data-animations":S?"on":"off","data-mode":Ft(f),children:[ie(Pe,{...se,showPills:lt}),ze("div",{className:ee.inputWrapper,onClick:it,children:[ze("div",{className:ee.editorArea,"data-aia-editor":"",children:[ie("div",{...rt,className:ee.input,"data-aia-input":""}),st&&(m||K.length>0)&&ie("span",{ref:T,className:ee.pillListContainer,"data-aia-pill-list-container":"",children:ie(ve,{pills:K,activePillIndex:0,onSelectPill:w,loading:m})})]}),E===null?null:E===void 0?ie(Je,{disabled:!fe,onClick:Se}):ie("span",{"data-aia-submit":"",className:ee.submitSlot,onClick:x=>{fe&&(x.stopPropagation(),Se())},children:E})]})]})});export{Ht as AIAutocomplete,Pe as AIAutocompleteDropdown,De as useAIAutocomplete};
|
|
996
|
+
`,document.head.appendChild(e)}var Xe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ee}from"react/jsx-runtime";function Je({disabled:e,onClick:c}){return Ee("button",{type:"button","data-aia-submit":"",className:Xe.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),c()},"aria-label":"Submit",children:Ee("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:Ee("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})}import{AIAutocomplete as At}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Ze,useEffect as ye,useRef as N,useState as Pt}from"react";var Ct={text:"",completedParams:[],suggestions:[],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,hasTabbedToHighlight:!1};function De({onSubmit:e,onError:c,optionOverrides:i,maskCompletedText:u,apiConfig:r,columns:n=2,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:g,showNonTappableOptions:b,onFocus:D,onBlur:k,value:I,completedParams:S,onChange:x,onParamsChange:R,source:z,setCursor:F}){let t=N(null),[w,m]=Pt(null),J=N(e);J.current=e;let T=N(c);T.current=c;let G=N(x);G.current=x;let H=N(R);H.current=R;let C=N(D);C.current=D;let j=N(k);j.current=k;let L=N(F);L.current=F,ye(()=>{if(typeof document>"u")return;let a=new At(document.createElement("div"),{renderMode:"headless",apiConfig:r,optionOverrides:i,maskCompletedText:u,columns:n,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:g,showNonTappableOptions:b,source:z,value:I,completedParams:S,onSubmit:(...A)=>J.current?.(...A),onError:(...A)=>T.current?.(...A),onChange:(...A)=>G.current?.(...A),onParamsChange:(...A)=>H.current?.(...A),onFocus:()=>C.current?.(),onBlur:()=>j.current?.(),setCursor:A=>L.current?.(A)});t.current=a,m(a.getState());let P=a.subscribe(A=>m(A));return()=>{P(),a.destroy(),t.current===a&&(t.current=null)}},[]),ye(()=>{I!==void 0&&t.current?.setValue(I)},[I]),ye(()=>{S!==void 0&&t.current?.setCompletedParams(S)},[S]);let V=JSON.stringify(r??null),q=N(i),B=N(0);if(i!==q.current){let a=q.current,P=i,A=Object.keys(a??{}),ae=Object.keys(P??{});(A.length!==ae.length||ae.some(se=>!a?.[se]||P[se]!==a[se]))&&B.current++,q.current=i}ye(()=>{t.current?.update({apiConfig:r,optionOverrides:i,dropdownTrigger:s,optionsPosition:l,closeDropdownOnBlur:g,showNonTappableOptions:b})},[V,B.current,s,l,g,b]);let $=N(null);$.current===null&&($.current={handleTextChange:a=>t.current?.handleTextChange(a),handleKeyDown:a=>{let P="nativeEvent"in a?a.nativeEvent:a;t.current?.handleKeyDown(P)},setFocused:a=>t.current?.setFocused(a),startEditingParam:a=>t.current?.startEditingParam(a),exitEditMode:()=>t.current?.exitEditMode(),handleCaretAfterInput:a=>t.current?.handleCaretAfterInput(a),handleCaretMove:a=>t.current?.handleCaretMove(a),replaceEditingRange:a=>t.current?.replaceEditingRange(a)??!1,setActivePill:a=>t.current?.setActivePill(a),removeLastParam:()=>t.current?.removeLastParam(),clearNewParamId:()=>t.current?.clearNewParamId(),reset:()=>t.current?.reset(),selectOption:a=>t.current?.selectOption(a),setActiveDropdownIndex:a=>t.current?.setActiveDropdownIndex(a),handleFocus:()=>t.current?.setFocused(!0),handleBlur:()=>t.current?.setFocused(!1)});let y=$.current,Y=Ze(a=>{let P=a.target.value,ae=P.length>0&&!a.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;t.current?.handleTextChange(ae)},[]),ee=Ze(a=>{t.current?.handleKeyDown(a.nativeEvent)},[]),Z=t.current,d=w??Ct,o=I!==void 0?I:d.text,p=S!==void 0?S:d.completedParams,f=d.actionableSuggestions,_=f[0],h=Z?.listboxId??"",E=d.activeDropdownIndex>=0&&Z?`${h}-option-${d.activeDropdownIndex}`:void 0,O=d.editingParam,U=O?{type:O.suggestionType,text:O.suggestionPlaceholder,required:!0,options:O.options}:null,pe=U??_,Ie=U?[U]:f,ue=!Z||d.isLoading&&!d.editingParam&&!d.inSelectionAnimation;return{completedParams:p,suggestionPills:f,setActivePill:y.setActivePill,removeLastParam:y.removeLastParam,segments:d.segments,newParamId:d.newParamId,clearNewParamId:y.clearNewParamId,suggestions:d.suggestions,activeIndex:d.activeDropdownIndex,isReady:d.isReady,isLoading:ue,isFocused:d.isFocused,isDropdownOpen:d.isDropdownOpen,isActivePillSelected:d.isActivePillSelected,placeholderText:d.placeholderText,listboxId:h,error:d.error,handleTextChange:y.handleTextChange,handleKeyDown:y.handleKeyDown,setFocused:y.setFocused,editingParam:O,editingAnchor:d.editingAnchor,caretOffset:d.caretOffset,startEditingParam:y.startEditingParam,exitEditMode:y.exitEditMode,handleCaretAfterInput:y.handleCaretAfterInput,handleCaretMove:y.handleCaretMove,replaceEditingRange:y.replaceEditingRange,inputProps:{value:o,placeholder:d.placeholderText||void 0,onChange:Y,onKeyDown:ee,onFocus:y.handleFocus,onBlur:y.handleBlur,role:"combobox","aria-expanded":d.isDropdownOpen,"aria-activedescendant":E,"aria-autocomplete":"list","aria-controls":h},reset:y.reset,dropdownProps:{suggestions:pe?[{...pe,options:d.filteredOptions}]:[],activeIndex:d.activeDropdownIndex,onSelect:y.selectOption,onHighlight:y.setActiveDropdownIndex,isOpen:d.isDropdownOpen,id:h,pills:Ie,activeSelected:d.isActivePillSelected,onPillClick:y.setActivePill,isLoading:ue,hasTabbedToHighlight:d.hasTabbedToHighlight,isInputEmpty:o.trim().length===0,optionsPosition:l??"below"}}}import{extractPlainText as Ye,getCursorOffset as et,plainTextLength as Et,renderEditableContent as Dt,setCursorOffset as tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as K,useEffect as Re,useLayoutEffect as Te,useRef as ie}from"react";var _e;function Rt(){if(_e!==void 0)return _e;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),_e=e.contentEditable==="plaintext-only",_e}function ot(e){let{segments:c,newParamId:i,editingParam:u,editingAnchor:r,caretOffset:n,placeholderText:s,isFocused:l,isDropdownOpen:g,listboxId:b,activeDescendantId:D,autoFocus:k,handleTextChange:I,handleKeyDown:S,handleCaretAfterInput:x,handleCaretMove:R,startEditingParam:z,replaceEditingRange:F,setFocused:t}=e,w=ie(null),m=ie(!1),J=ie(""),T=ie(""),G=ie(null),H=ie(0);G.current=n,Re(()=>{if(!k)return;let o=w.current;o&&(document.activeElement===o?t(!0):o.focus())},[k,t]),Re(()=>{let o=w.current;if(!o)return;let p=o.ownerDocument??document,f=()=>{let _=p.getSelection();if(!_||_.rangeCount===0||!_.anchorNode||!o.contains(_.anchorNode))return;let h=_.anchorNode,U=(h.nodeType===Node.ELEMENT_NODE?h:h.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(U&&U!==u?.id){z(U);return}performance.now()-H.current<50||R(et(o))};return p.addEventListener("selectionchange",f),()=>p.removeEventListener("selectionchange",f)},[u,z,R]),Te(()=>{let o=w.current;o&&Dt({input:o,segments:c,newParamId:i,editingParamId:u?.id??null,placeholderText:s??"",isFocused:l})},[c,i,u,s,l]),Te(()=>{let o=J.current,p=i??"";if(J.current=p,!p||p===o)return;let f=w.current;if(!f)return;f.focus();let _=G.current??Et(f);tt(f,_)},[i]),Te(()=>{let o=T.current,p=u?.id??"";if(T.current=p,!p||p===o||r==null)return;let f=w.current;f&&tt(f,r)},[u,r]);let C=K(()=>{if(m.current)return;let o=w.current;if(!o)return;let p=Ye(o),_=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;I(_)},[I]),j=K(()=>{H.current=performance.now(),C();let o=w.current;o&&x(et(o))},[C,x]);Re(()=>{let o=w.current;if(!o)return;let p=f=>{let _=f,h=_.inputType;if(h==="insertParagraph"||h==="insertLineBreak"||h==="insertFromDrop"){f.preventDefault();return}if(h.startsWith("insert")||h.startsWith("delete")){let E=h.startsWith("delete")?"":_.data??"";F(E)&&f.preventDefault()}};return o.addEventListener("beforeinput",p),()=>o.removeEventListener("beforeinput",p)},[F]);let L=K(()=>{m.current=!0},[]),V=K(()=>{m.current=!1,C()},[C]),q=K(o=>{o.preventDefault();let p=w.current;if(!p)return;let f=(o.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!f)return;let _=p.ownerDocument??document,h=_.getSelection();if(!h||h.rangeCount===0)return;let E=h.getRangeAt(0);if(!p.contains(E.startContainer))return;E.deleteContents();let O=_.createTextNode(f);E.insertNode(O),E.setStartAfter(O),E.collapse(!0),h.removeAllRanges(),h.addRange(E),C()},[C]),B=K(o=>S(o),[S]),$=K(()=>t(!0),[t]),y=K(()=>t(!1),[t]),Y=K(()=>w.current?.focus(),[]),ee=K(()=>w.current?.blur(),[]),Z=K(()=>{let o=w.current;return o?Ye(o):""},[]),d=Rt()?"plaintext-only":"true";return{inputRef:w,editorProps:{ref:w,contentEditable:d,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":b,"aria-expanded":g,"aria-activedescendant":D,spellCheck:!0,enterKeyHint:"send",onInput:j,onKeyDown:B,onCompositionStart:L,onCompositionEnd:V,onPaste:q,onFocus:$,onBlur:y},getPlainText:Z,focus:Y,blur:ee}}import{jsx as re,jsxs as Be}from"react/jsx-runtime";function Ot(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Mt=Tt(function({onSubmit:c,onError:i,optionOverrides:u,maskCompletedText:r,className:n,apiConfig:s,columns:l,pillPlacement:g="inline",mode:b="auto",optionsPosition:D="below",animations:k=!0,dropdownTrigger:I,closeDropdownOnBlur:S,showNonTappableOptions:x,autoFocus:R=!0,onFocus:z,onBlur:F,value:t,completedParams:w,onChange:m,onParamsChange:J,submitButton:T},G){let H=ce(null),C=ce(null),j=ce(()=>{}),L=ce(null),V=ce(null);at(()=>{let v=H.current;if(v)return L.current?L.current.setMode(b):L.current=new Ft(v,b),()=>{L.current?.destroy(),L.current=null}},[b]);let q=Le(v=>{let W=V.current?.current;W&&(W.focus(),Ht(W,v))},[]),{completedParams:B,suggestionPills:$,setActivePill:y,segments:Y,newParamId:ee,clearNewParamId:Z,placeholderText:d,isFocused:o,isDropdownOpen:p,isActivePillSelected:f,isLoading:_,activeIndex:h,listboxId:E,handleTextChange:O,handleKeyDown:U,setFocused:pe,editingParam:Ie,editingAnchor:ue,caretOffset:a,startEditingParam:P,handleCaretAfterInput:A,handleCaretMove:ae,replaceEditingRange:se,dropdownProps:nt,reset:me}=De({onSubmit:v=>j.current(v),onError:i,optionOverrides:u,maskCompletedText:r,apiConfig:s,columns:l,dropdownTrigger:I,optionsPosition:D,closeDropdownOnBlur:S,showNonTappableOptions:x,onFocus:z,onBlur:F,value:t,completedParams:w,onChange:m,onParamsChange:J,source:"full-sdk",setCursor:q});at(()=>{if(!ee)return;let v=window.setTimeout(()=>Z(),650);return()=>window.clearTimeout(v)},[ee,Z]);let it=h>=0?`${E}-option-${h}`:void 0,{inputRef:ke,editorProps:rt,focus:ge,blur:ze,getPlainText:Fe}=ot({segments:Y,newParamId:ee,editingParam:Ie,editingAnchor:ue,caretOffset:a,placeholderText:d,isFocused:o,isDropdownOpen:p,listboxId:E,activeDescendantId:it,autoFocus:R,handleTextChange:O,handleKeyDown:U,handleCaretAfterInput:A,handleCaretMove:ae,startEditingParam:P,replaceEditingRange:se,setFocused:pe});V.current=ke,Bt(()=>{let v=C.current,W=ke.current;if(!v||!W)return;let he=()=>{let Oe=v.firstElementChild;if(!Oe)return;let ct=Oe.getBoundingClientRect(),pt=W.getBoundingClientRect();ct.top>=pt.bottom-2?v.setAttribute("data-aia-pill-wrapped",""):v.removeAttribute("data-aia-pill-wrapped")};he();let He=new ResizeObserver(he);return He.observe(W),()=>He.disconnect()},[Y,$.length,_,ke]),Lt(G,()=>({focus:ge,blur:ze,reset:me,setMode:v=>L.current?.setMode(v)}),[ge,ze,me]);let fe=!!Y.length||B.length>0,Se=Le(()=>{if(!fe)return;let v=Fe(),{rawQuery:W,completedParams:he}=zt(v,B);c({query:v.trim(),raw_query:W,completed_params:he}),me()},[fe,B,c,me,Fe]);j.current=Se;let st=Le(v=>{v.target?.closest("[data-aia-pill]")||ge()},[ge]),lt=g==="inline",dt=g==="dropdown";return Be("div",{ref:H,className:`magicx-aia ${te.container} ${n??""}`,"data-pill-placement":g,"data-options-position":D,"data-animations":k?"on":"off","data-mode":Ot(b),children:[re(Ce,{...nt,showPills:dt}),Be("div",{className:te.inputWrapper,onClick:st,children:[Be("div",{className:te.editorArea,"data-aia-editor":"",children:[re("div",{...rt,className:te.input,"data-aia-input":""}),lt&&(_||$.length>0)&&re("span",{ref:C,className:te.pillListContainer,"data-aia-pill-list-container":"",children:re(ve,{pills:$,activePillIndex:0,activeSelected:f,onSelectPill:y,loading:_})})]}),T===null?null:T===void 0?re(Je,{disabled:!fe,onClick:Se}):re("span",{"data-aia-submit":"",className:te.submitSlot,onClick:v=>{fe&&(v.stopPropagation(),Se())},children:T})]})]})});export{Mt as AIAutocomplete,Ce as AIAutocompleteDropdown,De as useAIAutocomplete};
|
|
982
997
|
//# sourceMappingURL=index.mjs.map
|