@magicx-eng/ai-autocomplete-react 0.6.5 → 0.6.7
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 -1
- package/dist/index.js +149 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +149 -44
- 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 Mt,useCallback as Le,useEffect as at,useImperativeHandle as Ot,useLayoutEffect as Ht,useRef as pe}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
|
|
@@ -158,7 +158,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
158
158
|
opacity: 0;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
`,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",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};import{useEffect as
|
|
161
|
+
`,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",aiaPillReveal:"AIAutocomplete-module_aiaPillReveal_wf05b"};import{useEffect as Pt,useRef as St,useState as At}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-0ae03977")){let e=document.createElement("style");e.id="ac-style-0ae03977",e.textContent=`/*
|
|
162
162
|
* Built-in appearance defaults \u2014 zero specificity via :where().
|
|
163
163
|
* Consumer CSS always wins without !important.
|
|
164
164
|
*
|
|
@@ -187,6 +187,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
187
187
|
*/
|
|
188
188
|
:where(.magicx-aia) {
|
|
189
189
|
--aia-primitive-neutral-0: #000000;
|
|
190
|
+
--aia-primitive-neutral-150: #1a1b1d;
|
|
190
191
|
--aia-primitive-neutral-250: #323232;
|
|
191
192
|
--aia-primitive-neutral-300: #333539;
|
|
192
193
|
--aia-primitive-neutral-400: #4a4a4a;
|
|
@@ -197,6 +198,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
197
198
|
--aia-primitive-neutral-1000: #ffffff;
|
|
198
199
|
--aia-primitive-blue-50: #eef2ff;
|
|
199
200
|
--aia-primitive-neutral-750-a50: rgba(189, 189, 189, 0.51);
|
|
201
|
+
--aia-primitive-neutral-750-a25: rgba(189, 189, 189, 0.25);
|
|
200
202
|
--aia-primitive-neutral-750-a35: rgba(189, 189, 189, 0.35);
|
|
201
203
|
--aia-primitive-neutral-750-a30: rgba(189, 189, 189, 0.3);
|
|
202
204
|
--aia-primitive-neutral-750-a15: rgba(189, 189, 189, 0.15);
|
|
@@ -245,7 +247,9 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
245
247
|
|
|
246
248
|
--aia-color-text-muted: #6b7280; /* off shared palette (slate) */
|
|
247
249
|
|
|
248
|
-
|
|
250
|
+
/* Loading bars sit at half the contrast of the surrounding chrome so they
|
|
251
|
+
read as a placeholder, not as content (a50 -> a25 over the light surface). */
|
|
252
|
+
--aia-skeleton-bg: var(--aia-primitive-neutral-750-a25);
|
|
249
253
|
|
|
250
254
|
--aia-streak-rgb: 99, 102, 241; /* off shared palette (indigo effect) */
|
|
251
255
|
--aia-streak-glass-bg: rgba(99, 102, 241, 0.1);
|
|
@@ -294,7 +298,9 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
294
298
|
|
|
295
299
|
--aia-color-text-muted: #c1c4cb; /* off shared palette (slate) */
|
|
296
300
|
|
|
297
|
-
|
|
301
|
+
/* Half as light against the dark surface as the old neutral-300 fill \u2014 the
|
|
302
|
+
dark-mode counterpart of the light theme's a50 -> a25 step-down. */
|
|
303
|
+
--aia-skeleton-bg: var(--aia-primitive-neutral-150);
|
|
298
304
|
|
|
299
305
|
--aia-streak-rgb: 255, 255, 255;
|
|
300
306
|
--aia-streak-glass-bg: rgba(255, 255, 255, 0.1);
|
|
@@ -304,6 +310,71 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
304
310
|
--aia-footer-badge-border: var(--aia-primitive-neutral-500);
|
|
305
311
|
}
|
|
306
312
|
|
|
313
|
+
/* Footer band \u2014 the option list runs *under* the dropdown footer and dissolves
|
|
314
|
+
into it, instead of being cut off mid-row above it. The band is the footer's
|
|
315
|
+
own height \u2014 its top inset (--aia-footer-gap) + --aia-footer-row-height:
|
|
316
|
+
- the options grid reserves it as bottom padding, so the last option can
|
|
317
|
+
still be scrolled fully clear of the footer;
|
|
318
|
+
- --aia-grid-overlap-bottom (the band + the 8px stack gap) pulls the footer
|
|
319
|
+
back up over that band;
|
|
320
|
+
- the footer's background is the fade: transparent at the band's top edge,
|
|
321
|
+
the full dropdown surface at its bottom, so a row dissolves as it passes
|
|
322
|
+
behind. Its hint and branding groups sit on a 65%-opaque fill of their
|
|
323
|
+
own (--aia-footer-chip-bg) so they stay legible across it.
|
|
324
|
+
Lives here rather than with the dropdown's own rules so the
|
|
325
|
+
optionsPosition="above" reset below always follows it in the cascade. */
|
|
326
|
+
[data-aia-dropdown] {
|
|
327
|
+
/* Height of the footer's hint / branding row \u2014 the badge is its tallest item
|
|
328
|
+
(the kbd is shorter and centers against it). The band derives from it, so
|
|
329
|
+
restyling the badge's height keeps the overlap in step. */
|
|
330
|
+
--aia-footer-row-height: 23px;
|
|
331
|
+
--aia-footer-band: calc(var(--aia-footer-gap, 8px) + var(--aia-footer-row-height, 23px));
|
|
332
|
+
--aia-grid-scroll-bottom: var(--aia-footer-band);
|
|
333
|
+
--aia-grid-overlap-bottom: calc(-1 * (var(--aia-footer-band) + 8px));
|
|
334
|
+
/* How far above the band the fade starts. */
|
|
335
|
+
--aia-footer-fade-lead: 20px;
|
|
336
|
+
--aia-footer-fade-inset: calc(-1 * var(--aia-footer-fade-lead)) 0 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* The reserved band the footer overlaps, kept OUT of \`@layer layout\` on
|
|
340
|
+
purpose. A consumer reset (\`* { margin: 0; padding: 0 }\`, Tailwind's
|
|
341
|
+
preflight, \u2026) is unlayered, and an unlayered declaration beats every layered
|
|
342
|
+
one no matter its specificity \u2014 inside the layer this padding and margin
|
|
343
|
+
were silently zeroed and the footer had nothing to sit over. */
|
|
344
|
+
[data-aia-dropdown] .aia-grid[data-scroll] {
|
|
345
|
+
padding-top: var(--aia-grid-scroll-top, 0);
|
|
346
|
+
padding-bottom: var(--aia-grid-scroll-bottom, 0);
|
|
347
|
+
margin-top: var(--aia-grid-overlap-top, 0);
|
|
348
|
+
margin-bottom: var(--aia-grid-overlap-bottom, 0);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/* The fade. Painted on a pseudo-element rather than the footer box so it can
|
|
352
|
+
start --aia-footer-fade-lead above the band's top edge: a row is then already
|
|
353
|
+
dissolving by the time it reaches the hint / branding line, instead of
|
|
354
|
+
crossing it at half strength. --aia-surface is what the dropdown paints
|
|
355
|
+
itself with, so theming the surface retints the fade with it. z-index: -1
|
|
356
|
+
keeps it under the footer's own content but, via the footer's stacking
|
|
357
|
+
context, above the option rows. */
|
|
358
|
+
[data-aia-dropdown] [data-aia-footer]::before {
|
|
359
|
+
content: "";
|
|
360
|
+
position: absolute;
|
|
361
|
+
inset: var(--aia-footer-fade-inset, -20px 0 0);
|
|
362
|
+
z-index: -1;
|
|
363
|
+
pointer-events: none;
|
|
364
|
+
background: linear-gradient(to bottom, transparent, var(--aia-surface, #ffffff));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/* The glass surface is translucent \u2014 there's no solid color to dissolve into,
|
|
368
|
+
and a fill behind the hint / branding would paint an opaque patch on a
|
|
369
|
+
frosted panel. Both opt out. */
|
|
370
|
+
[data-aia-dropdown][data-aia-surface="glass"] {
|
|
371
|
+
--aia-footer-chip-bg: transparent;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
[data-aia-dropdown][data-aia-surface="glass"] [data-aia-footer]::before {
|
|
375
|
+
display: none;
|
|
376
|
+
}
|
|
377
|
+
|
|
307
378
|
/* optionsPosition: dropdown above the input. The sections live inside the
|
|
308
379
|
dropdown's .aia-stack, so the reversal targets the stack (not the dropdown,
|
|
309
380
|
whose only child is the stack).
|
|
@@ -316,6 +387,13 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
316
387
|
hand-copied CSS. */
|
|
317
388
|
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown],
|
|
318
389
|
[data-aia-dropdown][data-options-position="above"] {
|
|
390
|
+
/* The stack is reversed here (the footer sits on top of the list), so the
|
|
391
|
+
reserved band and the overlap flip to the top edge. */
|
|
392
|
+
--aia-grid-scroll-bottom: 0px;
|
|
393
|
+
--aia-grid-overlap-bottom: 0px;
|
|
394
|
+
--aia-grid-scroll-top: var(--aia-footer-band);
|
|
395
|
+
--aia-grid-overlap-top: calc(-1 * (var(--aia-footer-band) + 8px));
|
|
396
|
+
--aia-footer-fade-inset: 0 0 calc(-1 * var(--aia-footer-fade-lead));
|
|
319
397
|
top: auto;
|
|
320
398
|
bottom: 100%;
|
|
321
399
|
margin-top: 0;
|
|
@@ -327,6 +405,19 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
327
405
|
flex-direction: column-reverse;
|
|
328
406
|
}
|
|
329
407
|
|
|
408
|
+
/* The footer now sits on top of the list, so its breathing room flips to the
|
|
409
|
+
bottom edge \u2014 the side the option rows scroll under. */
|
|
410
|
+
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] [data-aia-footer],
|
|
411
|
+
[data-aia-dropdown][data-options-position="above"] [data-aia-footer] {
|
|
412
|
+
padding: 0 8px var(--aia-footer-gap, 8px);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/* ...and the fade runs the other way, out of the footer and down into the list. */
|
|
416
|
+
:where(.magicx-aia[data-options-position="above"]) [data-aia-dropdown] [data-aia-footer]::before,
|
|
417
|
+
[data-aia-dropdown][data-options-position="above"] [data-aia-footer]::before {
|
|
418
|
+
background: linear-gradient(to top, transparent, var(--aia-surface, #ffffff));
|
|
419
|
+
}
|
|
420
|
+
|
|
330
421
|
/* Disable all animations when data-animations="off" */
|
|
331
422
|
:where(.magicx-aia[data-animations="off"]) *,
|
|
332
423
|
:where(.magicx-aia[data-animations="off"]) *::before,
|
|
@@ -408,7 +499,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
408
499
|
display: block;
|
|
409
500
|
height: 14px;
|
|
410
501
|
border-radius: 999px;
|
|
411
|
-
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.
|
|
502
|
+
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
|
|
412
503
|
opacity: 0.5;
|
|
413
504
|
animation: AIAutocompleteDropdown-module_aiaSkeletonPulse_G8W7q 1.4s ease-in-out infinite;
|
|
414
505
|
}
|
|
@@ -430,7 +521,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
430
521
|
opacity: 0.25;
|
|
431
522
|
}
|
|
432
523
|
}
|
|
433
|
-
`,document.head.appendChild(e)}var ie={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
|
|
524
|
+
`,document.head.appendChild(e)}var ie={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{ATTRIBUTION_URL as ct,buildAttributionUrl as ut,getFooterHint as mt}from"@magicx-eng/ai-autocomplete-vanilla";import{useEffect as gt,useState as ht}from"react";if(typeof document<"u"&&!document.getElementById("ac-style-5259a217")){let e=document.createElement("style");e.id="ac-style-5259a217",e.textContent=`@layer layout {
|
|
434
525
|
.aia-cluster {
|
|
435
526
|
display: flex;
|
|
436
527
|
flex-wrap: wrap;
|
|
@@ -472,7 +563,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
472
563
|
justify-content: space-around;
|
|
473
564
|
}
|
|
474
565
|
}
|
|
475
|
-
`,document.head.appendChild(e)}import{jsx as He}from"react/jsx-runtime";function le({gap:e,align:l="center",justify:
|
|
566
|
+
`,document.head.appendChild(e)}import{jsx as He}from"react/jsx-runtime";function le({gap:e,align:l="center",justify:o="start",noWrap:s=!1,inline:r=!1,className:i,children:u,...m}){let g=e?{"--aia-cluster-gap":e}:void 0,x={className:i?`aia-cluster ${i}`:"aia-cluster","data-align":l,"data-justify":o,"data-nowrap":s||void 0,"data-inline":r||void 0,style:g,...m};return r?He("span",{...x,children:u}):He("div",{...x,children:u})}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
|
|
476
567
|
dropdown's rounded edges. The top inset (--aia-footer-gap) adds breathing
|
|
477
568
|
room above the hint/branding row so the footer doesn't butt against the last
|
|
478
569
|
option row \u2014 additive to the dropdown's 8px section gap. */
|
|
@@ -481,12 +572,29 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
481
572
|
flex-direction: column;
|
|
482
573
|
gap: 8px;
|
|
483
574
|
padding: var(--aia-footer-gap, 8px) 8px 0;
|
|
575
|
+
/* The fade itself lives in appearance.css, on the footer's background.
|
|
576
|
+
Paints above the rows it covers: option content sits at z-index 2 (see
|
|
577
|
+
SuggestionItem.module.css) in this same stacking context, so anything
|
|
578
|
+
lower would end up *behind* the rows. */
|
|
579
|
+
position: relative;
|
|
580
|
+
z-index: 3;
|
|
581
|
+
/* Sitting on top of the list would otherwise swallow clicks and hovers on
|
|
582
|
+
the rows scrolling under it \u2014 only the branding link needs to be hit. */
|
|
583
|
+
pointer-events: none;
|
|
484
584
|
}
|
|
485
585
|
|
|
486
586
|
.DropdownFooter-module_hintGroup_ZzbPf {
|
|
487
587
|
min-width: 0;
|
|
488
588
|
}
|
|
489
589
|
|
|
590
|
+
/* Re-enabled over the footer's \`pointer-events: none\`: both groups are visible
|
|
591
|
+
chips sitting on the scroll band, so a click on one must land on the chip
|
|
592
|
+
rather than falling through to the option row behind it. */
|
|
593
|
+
.DropdownFooter-module_hintGroup_ZzbPf,
|
|
594
|
+
.DropdownFooter-module_brandLink_r4f3R {
|
|
595
|
+
pointer-events: auto;
|
|
596
|
+
}
|
|
597
|
+
|
|
490
598
|
.DropdownFooter-module_brandLink_r4f3R {
|
|
491
599
|
display: inline-flex;
|
|
492
600
|
align-items: center;
|
|
@@ -496,6 +604,27 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
496
604
|
transition: opacity 150ms ease-out;
|
|
497
605
|
}
|
|
498
606
|
|
|
607
|
+
/* The two content groups carry a solid surface fill so the keyboard hint and
|
|
608
|
+
the AI-Autocomplete badge stay fully legible over whatever option row is
|
|
609
|
+
scrolling behind the footer. The inline padding keeps the fill from hugging
|
|
610
|
+
the glyphs. --aia-footer-chip-bg resolves to \`transparent\` on the glass
|
|
611
|
+
surface, where there's no solid color to fill with. */
|
|
612
|
+
.DropdownFooter-module_hintGroup_ZzbPf,
|
|
613
|
+
.DropdownFooter-module_brandLink_r4f3R {
|
|
614
|
+
/* Mixed here rather than declared on the container: a custom property
|
|
615
|
+
substitutes var() on the element its declaration applies to, so a mix
|
|
616
|
+
computed upstream would freeze the *theme's* surface and miss a
|
|
617
|
+
dropdown-level --aia-surface retint. Computed on the footer, it picks up
|
|
618
|
+
whichever ancestor set the surface. --aia-footer-chip-bg stays the
|
|
619
|
+
override hook \u2014 consumers set it, and the glass surface zeroes it. */
|
|
620
|
+
background: var(
|
|
621
|
+
--aia-footer-chip-bg,
|
|
622
|
+
color-mix(in srgb, var(--aia-surface, #ffffff) 65%, transparent)
|
|
623
|
+
);
|
|
624
|
+
padding-inline: 4px;
|
|
625
|
+
border-radius: 6px;
|
|
626
|
+
}
|
|
627
|
+
|
|
499
628
|
.DropdownFooter-module_brandLink_r4f3R:hover {
|
|
500
629
|
opacity: 0.7;
|
|
501
630
|
}
|
|
@@ -532,7 +661,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
532
661
|
.DropdownFooter-module_badge_Fk9vg {
|
|
533
662
|
display: inline-flex;
|
|
534
663
|
align-items: center;
|
|
535
|
-
height: 23px;
|
|
664
|
+
height: var(--aia-footer-row-height, 23px);
|
|
536
665
|
padding: 2.5px 5.5px;
|
|
537
666
|
border: 0.5px solid var(--aia-footer-badge-border, rgba(189, 189, 189, 0.51));
|
|
538
667
|
border-radius: 999px;
|
|
@@ -553,7 +682,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
553
682
|
justify-content: flex-end;
|
|
554
683
|
}
|
|
555
684
|
}
|
|
556
|
-
`,document.head.appendChild(e)}var q={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"};import{jsx as de,jsxs as Pe}from"react/jsx-runtime";function Ne({isOptionHighlighted:e=!1,isInputEmpty:l=!1}){let{key:
|
|
685
|
+
`,document.head.appendChild(e)}var q={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"};import{jsx as de,jsxs as Pe}from"react/jsx-runtime";function Ne({isOptionHighlighted:e=!1,isInputEmpty:l=!1}){let{key:o,hint:s}=mt(e,l),[r,i]=ht(ct);return gt(()=>{i(ut())},[]),de("footer",{className:q.footer,"data-aia-footer":"",children:Pe(le,{justify:"between",noWrap:!0,className:q.row,children:[Pe(le,{gap:"5px",className:q.hintGroup,children:[de("kbd",{className:q.key,children:o}),de("span",{className:q.hint,children:s})]}),Pe("a",{className:q.brandLink,href:r,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-199d0432")){let e=document.createElement("style");e.id="ac-style-199d0432",e.textContent=`/* ParamPill (Figma "ParamPill") \u2014 unfilled suggestion pill: transparent fill
|
|
557
686
|
with a dashed border. ~28px via 6px padding + 14px text + the 1px border
|
|
558
687
|
(border-box). */
|
|
559
688
|
.ParamPill-module_pill_6Ga7S {
|
|
@@ -586,7 +715,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
586
715
|
pointer-events: none;
|
|
587
716
|
cursor: default;
|
|
588
717
|
color: transparent;
|
|
589
|
-
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.
|
|
718
|
+
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
|
|
590
719
|
animation: ParamPill-module_skeletonPulse_xGcUy 1.4s ease-in-out infinite;
|
|
591
720
|
}
|
|
592
721
|
|
|
@@ -605,7 +734,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
605
734
|
opacity: 0;
|
|
606
735
|
}
|
|
607
736
|
}
|
|
608
|
-
`,document.head.appendChild(e)}var J={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"};import{jsx as
|
|
737
|
+
`,document.head.appendChild(e)}var J={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"};import{jsx as ft}from"react/jsx-runtime";var Se={selected:1,first:.7,next:.4,last:.2};function Ke({label:e,state:l,rounded:o,loading:s,onClick:r}){let i=[J.pill,o?J.rounded:"",s?J.skeleton:""].filter(Boolean).join(" ");return ft("button",{type:"button","data-aia-pill":"","data-aia-loading":s?"":void 0,tabIndex:-1,contentEditable:!1,suppressContentEditableWarning:!0,className:i,style:{opacity:Se[l]},onMouseDown:u=>u.preventDefault(),onClick:s?void 0:r,disabled:s,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 {
|
|
609
738
|
position: relative;
|
|
610
739
|
z-index: 1;
|
|
611
740
|
pointer-events: auto;
|
|
@@ -615,7 +744,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
615
744
|
align-items: center;
|
|
616
745
|
vertical-align: middle;
|
|
617
746
|
}
|
|
618
|
-
`,document.head.appendChild(e)}var Ae={list:"PillList-module_list_qvLqO"};import{jsx as be}from"react/jsx-runtime";var
|
|
747
|
+
`,document.head.appendChild(e)}var Ae={list:"PillList-module_list_qvLqO"};import{jsx as be}from"react/jsx-runtime";var bt=[125,69];function We(e){return e===0?"first":e===1?"next":"last"}function ve({pills:e,activePillIndex:l,onSelectPill:o,activeSelected:s,rounded:r,loading:i}){return i&&e.length===0?be("span",{className:Ae.list,"data-aia-pill-list-loading":"",children:bt.map((u,m)=>be("span",{"data-aia-pill-skeleton":"",className:`${J.pill} ${r?J.rounded:""} ${J.skeleton}`,style:{width:u,opacity:Se[We(m)]}},`skel-${u}`))}):be("span",{className:Ae.list,"data-aia-pill-list-loading":i?"":void 0,children:e.map((u,m)=>{let g=!!s&&m===l;return be(Ke,{label:u.text,state:g?"selected":We(m),selected:g,rounded:r,loading:i,onClick:()=>o(m)},`${u.type}-${u.text}`)})})}import{useLayoutEffect as vt,useRef 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 {
|
|
619
748
|
.aia-grid {
|
|
620
749
|
display: grid;
|
|
621
750
|
grid-template-columns: repeat(
|
|
@@ -631,7 +760,9 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
631
760
|
grid-auto-rows: min-content;
|
|
632
761
|
align-content: start;
|
|
633
762
|
justify-content: start;
|
|
634
|
-
|
|
763
|
+
/* The scroll box's reserved band (--aia-grid-scroll-* / --aia-grid-overlap-*)
|
|
764
|
+
is deliberately NOT declared here \u2014 see the unlayered rule in
|
|
765
|
+
appearance.css for why. */
|
|
635
766
|
max-height: var(--aia-grid-max-height, 120px);
|
|
636
767
|
overflow-y: auto;
|
|
637
768
|
scrollbar-width: thin;
|
|
@@ -647,34 +778,8 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
647
778
|
background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
|
|
648
779
|
border-radius: 3px;
|
|
649
780
|
}
|
|
650
|
-
|
|
651
|
-
/* Fade wrapper \u2014 bottom gradient overlay shown while the grid overflows
|
|
652
|
-
below: overflowing options fade into the dropdown surface color. */
|
|
653
|
-
.aia-grid-fade {
|
|
654
|
-
position: relative;
|
|
655
|
-
}
|
|
656
|
-
.aia-grid-fade::after {
|
|
657
|
-
content: "";
|
|
658
|
-
position: absolute;
|
|
659
|
-
left: 0;
|
|
660
|
-
right: 0;
|
|
661
|
-
bottom: 0;
|
|
662
|
-
height: 30%;
|
|
663
|
-
pointer-events: none;
|
|
664
|
-
opacity: 0;
|
|
665
|
-
transition: opacity 150ms ease-out;
|
|
666
|
-
background: linear-gradient(to bottom, transparent, var(--aia-surface, #ffffff));
|
|
667
|
-
}
|
|
668
|
-
.aia-grid-fade[data-fade]::after {
|
|
669
|
-
opacity: 1;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/* Glass surface has no solid color to fade into, so skip the fade entirely. */
|
|
673
|
-
[data-aia-surface="glass"] .aia-grid-fade::after {
|
|
674
|
-
display: none;
|
|
675
|
-
}
|
|
676
781
|
}
|
|
677
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
782
|
+
`,document.head.appendChild(e)}import{jsx as wt}from"react/jsx-runtime";function Ge({min:e="16rem",max:l,gap:o,scroll:s=!1,maxHeight:r,scrollResetKey:i,className:u,children:m,...g}){let x=xt(null);vt(()=>{if(i===void 0)return;let _=x.current;_&&(_.scrollTop=0)},[i]);let k={"--aia-grid-min":e};return l&&(k["--aia-grid-max"]=l),o&&(k["--aia-grid-gap"]=o),r&&(k["--aia-grid-max-height"]=r),wt("div",{ref:x,className:u?`aia-grid ${u}`:"aia-grid","data-scroll":s||void 0,style:k,...g,children:m})}import{useEffect as yt,useRef as _t,useState as kt}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 {
|
|
678
783
|
position: relative;
|
|
679
784
|
overflow: visible;
|
|
680
785
|
display: flex;
|
|
@@ -1005,7 +1110,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
1005
1110
|
makes the radius render cleanly on each line bar. */
|
|
1006
1111
|
.SuggestionItem-module_item_d4vpD[data-aia-loading] .SuggestionItem-module_text_yqoh9 {
|
|
1007
1112
|
color: transparent;
|
|
1008
|
-
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.
|
|
1113
|
+
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.25)));
|
|
1009
1114
|
border-radius: 999px;
|
|
1010
1115
|
-webkit-box-decoration-break: clone;
|
|
1011
1116
|
box-decoration-break: clone;
|
|
@@ -1024,7 +1129,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
1024
1129
|
filter: brightness(0.55);
|
|
1025
1130
|
}
|
|
1026
1131
|
}
|
|
1027
|
-
`,document.head.appendChild(e)}var
|
|
1132
|
+
`,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 xe,jsxs as Ue}from"react/jsx-runtime";function je({option:e,isHighlighted:l,onSelect:o,onHighlight:s,id:r,loading:i}){let[u,m]=kt(!1),g=_t(void 0);yt(()=>()=>clearTimeout(g.current),[]);let x=()=>{i||!e.is_tappable||u||(m(!0),o(e),clearTimeout(g.current),g.current=setTimeout(()=>m(!1),500))},k=[M.item,l&&!i?M.highlighted:"",e.is_tappable?M.tappable:M.nonTappable,u?M.pressed:""].filter(Boolean).join(" ");return Ue("div",{id:r,role:"option","data-aia-option":"","data-aia-loading":i?"":void 0,"aria-selected":l,className:k,tabIndex:i||!e.is_tappable?-1:0,onClick:x,onKeyDown:_=>{!i&&e.is_tappable&&(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),x())},onMouseEnter:!i&&e.is_tappable?s:void 0,children:[xe("div",{className:M.streaks}),xe("div",{className:M.streaksVert}),Ue("span",{className:M.content,children:[xe("span",{className:M.text,children:e.icon?`${e.icon} ${e.text}`:e.text}),e.tag&&xe("span",{className:M.tag,children:e.tag})]})]})}import{jsx as Ve}from"react/jsx-runtime";function $e({options:e,activeIndex:l,onSelect:o,onHighlight:s,listboxId:r,loading:i,groupKey:u}){return Ve(Ge,{min:"250px",max:"1fr",gap:"0",scroll:!0,scrollResetKey:u,children:e.map((m,g)=>Ve(je,{option:m,isHighlighted:g===l,onSelect:o,onHighlight:()=>s(g),id:`${r}-option-${g}`,loading:i},m.text))})}if(typeof document<"u"&&!document.getElementById("ac-style-8414cd5f")){let e=document.createElement("style");e.id="ac-style-8414cd5f",e.textContent=`@layer layout {
|
|
1028
1133
|
.aia-stack {
|
|
1029
1134
|
display: flex;
|
|
1030
1135
|
flex-direction: column;
|
|
@@ -1041,7 +1146,7 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
1041
1146
|
}
|
|
1042
1147
|
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
1043
1148
|
}
|
|
1044
|
-
`,document.head.appendChild(e)}import{jsx as
|
|
1149
|
+
`,document.head.appendChild(e)}import{jsx as It}from"react/jsx-runtime";function qe({space:e,align:l="stretch",className:o,children:s,...r}){let i=e?{"--aia-stack-space":e}:void 0;return It("div",{className:o?`aia-stack ${o}`:"aia-stack","data-align":l,style:i,...r,children:s})}import{jsx as ae,jsxs as Rt}from"react/jsx-runtime";var Ct=[159,119,164];function Et(e){let l=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,[o,s]=At(l);if(Pt(()=>{if(e!=="auto"||typeof window>"u"||typeof window.matchMedia!="function")return;let r=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>s(r.matches);return r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[e]),e!==void 0)return e==="auto"?o?"dark":"light":e}function Ce({suggestions:e,activeIndex:l,onSelect:o,onHighlight:s,isOpen:r,id:i,className:u,pills:m,onPillClick:g,showPills:x=!0,activeSelected:k=!1,isLoading:_=!1,isInputEmpty:C=!1,optionsPosition:E="below",mode:U}){let N=Et(U),Q=N!==void 0,j=e[0]?.options??[],n=!!(m&&m.length>0&&g),w=r&&(j.length>0||x&&n||_),D={suggestions:e,activeIndex:l,pills:m,showPills:x,activeSelected:k,isLoading:_,isInputEmpty:C},K=St(D);w&&(K.current=D);let f=w?D:K.current,T=f.suggestions[0],L=T?.options??[],S=f.activeIndex>=0&&!!L[f.activeIndex]?.is_tappable,W=!!(f.pills&&f.pills.length>0&&g),R=f.showPills&&W,Z=f.showPills&&!W&&f.isLoading,V=R||Z,z=L.length>0,F=f.isLoading&&!z;return ae("div",{id:i,role:"listbox","data-aia-dropdown":"","data-options-position":E,"data-mode":N,"data-aia-loading":f.isLoading?"":void 0,className:`${Q?"magicx-aia ":""}${ie.dropdown} ${w?ie.visible:""} ${u??""}`,onMouseDown:b=>b.preventDefault(),children:Rt(qe,{space:"8px",children:[V&&ae(le,{noWrap:!0,className:ie.pillBar,"data-aia-pillbar":"",children:ae(ve,{pills:f.pills??[],activePillIndex:0,activeSelected:f.activeSelected,onSelectPill:g??(()=>{}),rounded:!0,loading:f.isLoading})}),z&&ae($e,{options:L,activeIndex:f.activeIndex,onSelect:o,onHighlight:s,listboxId:i,loading:f.isLoading,groupKey:T?`${T.type} ${T.text}`:""}),F&&ae("div",{className:ie.skeletonBars,"data-aia-skeleton-bars":"",children:Ct.map(b=>ae("span",{className:ie.skeletonBar,style:{width:b}},`bar-${b}`))}),ae(Ne,{isOptionHighlighted:S,isInputEmpty:f.isInputEmpty})]})})}import{buildQuery as Nt,ModeController as Kt,setCursorOffset as Wt}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 {
|
|
1045
1150
|
flex-shrink: 0;
|
|
1046
1151
|
width: 32px;
|
|
1047
1152
|
height: 32px;
|
|
@@ -1076,5 +1181,5 @@ import{forwardRef as Ft,useCallback as Le,useEffect as ot,useImperativeHandle as
|
|
|
1076
1181
|
);
|
|
1077
1182
|
cursor: default;
|
|
1078
1183
|
}
|
|
1079
|
-
`,document.head.appendChild(e)}var Xe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ee}from"react/jsx-runtime";function Ze({disabled:e,onClick:l}){return Ee("button",{type:"button","data-aia-submit":"",className:Xe.submitButton,disabled:e,onClick:i=>{i.stopPropagation(),l()},"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 Et}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Je,useEffect as we,useRef as N,useState as Dt}from"react";var Rt={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};function De({onSubmit:e,onError:l,optionOverrides:i,maskCompletedText:r,apiConfig:d,columns:a=2,dropdownTrigger:s,optionsPosition:c,closeDropdownOnBlur:b,showNonTappableOptions:x,onFocus:R,onBlur:I,value:k,completedParams:P,onChange:w,onParamsChange:C,source:F,setCursor:j}){let n=N(null),[y,L]=Dt(null),W=N(e);W.current=e;let f=N(l);f.current=l;let Q=N(w);Q.current=w;let z=N(C);z.current=C;let E=N(R);E.current=R;let G=N(I);G.current=I;let T=N(j);T.current=j,we(()=>{if(typeof document>"u")return;let o=new Et(document.createElement("div"),{renderMode:"headless",apiConfig:d,optionOverrides:i,maskCompletedText:r,columns:a,dropdownTrigger:s,optionsPosition:c,closeDropdownOnBlur:b,showNonTappableOptions:x,source:F,value:k,completedParams:P,onSubmit:(...S)=>W.current?.(...S),onError:(...S)=>f.current?.(...S),onChange:(...S)=>Q.current?.(...S),onParamsChange:(...S)=>z.current?.(...S),onFocus:()=>E.current?.(),onBlur:()=>G.current?.(),setCursor:S=>T.current?.(S)});n.current=o,L(o.getState());let A=o.subscribe(S=>L(S));return()=>{A(),o.destroy(),n.current===o&&(n.current=null)}},[]),we(()=>{k!==void 0&&n.current?.setValue(k)},[k]),we(()=>{P!==void 0&&n.current?.setCompletedParams(P)},[P]);let X=JSON.stringify(d??null),V=N(i),B=N(0);if(i!==V.current){let o=V.current,A=i,S=Object.keys(o??{}),oe=Object.keys(A??{});(S.length!==oe.length||oe.some(se=>!o?.[se]||A[se]!==o[se]))&&B.current++,V.current=i}we(()=>{n.current?.update({apiConfig:d,optionOverrides:i,dropdownTrigger:s,optionsPosition:c,closeDropdownOnBlur:b,showNonTappableOptions:x})},[X,B.current,s,c,b,x]);let O=N(null);O.current===null&&(O.current={handleTextChange:o=>n.current?.handleTextChange(o),handleKeyDown:o=>{let A="nativeEvent"in o?o.nativeEvent:o;n.current?.handleKeyDown(A)},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 h=O.current,Y=Je(o=>{let A=o.target.value,oe=A.length>0&&!o.nativeEvent?.isComposing&&A[0]!==A[0].toUpperCase()?A[0].toUpperCase()+A.slice(1):A;n.current?.handleTextChange(oe)},[]),ee=Je(o=>{n.current?.handleKeyDown(o.nativeEvent)},[]),Z=n.current,u=y??Rt,t=k!==void 0?k:u.text,p=P!==void 0?P:u.completedParams,m=u.actionableSuggestions,v=m[0],g=Z?.listboxId??"",D=u.activeDropdownIndex>=0&&Z?`${g}-option-${u.activeDropdownIndex}`:void 0,M=u.editingParam,$=M?{type:M.suggestionType,text:M.suggestionPlaceholder,required:!0,options:M.options}:null,ce=$??v,_e=$?[$]:m,ue=!Z||u.isLoading&&!u.editingParam&&!u.inSelectionAnimation;return{completedParams:p,suggestionPills:m,setActivePill:h.setActivePill,removeLastParam:h.removeLastParam,segments:u.segments,newParamId:u.newParamId,clearNewParamId:h.clearNewParamId,suggestions:u.suggestions,activeIndex:u.activeDropdownIndex,isReady:u.isReady,isLoading:ue,isFocused:u.isFocused,isDropdownOpen:u.isDropdownOpen,isActivePillSelected:u.isActivePillSelected,placeholderText:u.placeholderText,listboxId:g,error:u.error,handleTextChange:h.handleTextChange,handleKeyDown:h.handleKeyDown,setFocused:h.setFocused,editingParam:M,editingAnchor:u.editingAnchor,caretOffset:u.caretOffset,startEditingParam:h.startEditingParam,exitEditMode:h.exitEditMode,handleCaretAfterInput:h.handleCaretAfterInput,handleCaretMove:h.handleCaretMove,replaceEditingRange:h.replaceEditingRange,inputProps:{value:t,placeholder:u.placeholderText||void 0,onChange:Y,onKeyDown:ee,onFocus:h.handleFocus,onBlur:h.handleBlur,role:"combobox","aria-expanded":u.isDropdownOpen,"aria-activedescendant":D,"aria-autocomplete":"list","aria-controls":g},reset:h.reset,dropdownProps:{suggestions:ce?[{...ce,options:u.filteredOptions}]:[],activeIndex:u.activeDropdownIndex,onSelect:h.selectOption,onHighlight:h.setActiveDropdownIndex,isOpen:u.isDropdownOpen,id:g,pills:_e,activeSelected:u.isActivePillSelected,onPillClick:h.setActivePill,isLoading:ue,isInputEmpty:t.trim().length===0,optionsPosition:c??"below"}}}import{extractPlainText as Ye,getCursorOffset as et,plainTextLength as Tt,renderEditableContent as Lt,setCursorOffset as tt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as K,useEffect as Re,useLayoutEffect as Te,useRef as ne}from"react";var ye;function zt(){if(ye!==void 0)return ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),ye=e.contentEditable==="plaintext-only",ye}function at(e){let{segments:l,newParamId:i,editingParam:r,editingAnchor:d,caretOffset:a,placeholderText:s,isFocused:c,isDropdownOpen:b,listboxId:x,activeDescendantId:R,autoFocus:I,handleTextChange:k,handleKeyDown:P,handleCaretAfterInput:w,handleCaretMove:C,startEditingParam:F,replaceEditingRange:j,setFocused:n}=e,y=ne(null),L=ne(!1),W=ne(""),f=ne(""),Q=ne(null),z=ne(0);Q.current=a,Re(()=>{if(!I)return;let t=y.current;if(!t)return;document.activeElement===t?n(!0):t.focus();let p=t.ownerDocument??document,m=p.getSelection(),v=m&&m.rangeCount>0&&t.contains(m.anchorNode);if(m&&!v){let g=p.createRange();g.selectNodeContents(t),g.collapse(!0),m.removeAllRanges(),m.addRange(g)}},[I,n]),Re(()=>{let t=y.current;if(!t)return;let p=t.ownerDocument??document,m=()=>{let v=p.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!t.contains(v.anchorNode))return;let g=v.anchorNode,$=(g.nodeType===Node.ELEMENT_NODE?g:g.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if($&&$!==r?.id){F($);return}performance.now()-z.current<50||C(et(t))};return p.addEventListener("selectionchange",m),()=>p.removeEventListener("selectionchange",m)},[r,F,C]),Te(()=>{let t=y.current;t&&Lt({input:t,segments:l,newParamId:i,editingParamId:r?.id??null,placeholderText:s??"",isFocused:c})},[l,i,r,s,c]),Te(()=>{let t=W.current,p=i??"";if(W.current=p,!p||p===t)return;let m=y.current;if(!m)return;m.focus();let v=Q.current??Tt(m);tt(m,v)},[i]),Te(()=>{let t=f.current,p=r?.id??"";if(f.current=p,!p||p===t||d==null)return;let m=y.current;m&&tt(m,d)},[r,d]);let E=K(()=>{if(L.current)return;let t=y.current;if(!t)return;let p=Ye(t),v=p.length>0&&p[0]!==p[0].toUpperCase()?p[0].toUpperCase()+p.slice(1):p;k(v)},[k]),G=K(()=>{z.current=performance.now(),E();let t=y.current;t&&w(et(t))},[E,w]);Re(()=>{let t=y.current;if(!t)return;let p=m=>{let v=m,g=v.inputType;if(g==="insertParagraph"||g==="insertLineBreak"||g==="insertFromDrop"){m.preventDefault();return}if(g.startsWith("insert")||g.startsWith("delete")){let D=g.startsWith("delete")?"":v.data??"";j(D)&&m.preventDefault()}};return t.addEventListener("beforeinput",p),()=>t.removeEventListener("beforeinput",p)},[j]);let T=K(()=>{L.current=!0},[]),X=K(()=>{L.current=!1,E()},[E]),V=K(t=>{t.preventDefault();let p=y.current;if(!p)return;let m=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!m)return;let v=p.ownerDocument??document,g=v.getSelection();if(!g||g.rangeCount===0)return;let D=g.getRangeAt(0);if(!p.contains(D.startContainer))return;D.deleteContents();let M=v.createTextNode(m);D.insertNode(M),D.setStartAfter(M),D.collapse(!0),g.removeAllRanges(),g.addRange(D),E()},[E]),B=K(t=>P(t),[P]),O=K(()=>n(!0),[n]),h=K(()=>n(!1),[n]),Y=K(()=>y.current?.focus(),[]),ee=K(()=>y.current?.blur(),[]),Z=K(()=>{let t=y.current;return t?Ye(t):""},[]),u=zt()?"plaintext-only":"true";return{inputRef:y,editorProps:{ref:y,contentEditable:u,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":b,"aria-activedescendant":R,spellCheck:!0,enterKeyHint:"send",onInput:G,onKeyDown:B,onCompositionStart:T,onCompositionEnd:X,onPaste:V,onFocus:O,onBlur:h},getPlainText:Z,focus:Y,blur:ee}}import{jsx as re,jsxs as ze}from"react/jsx-runtime";function Kt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Wt=Ft(function({onSubmit:l,onError:i,optionOverrides:r,maskCompletedText:d,className:a,apiConfig:s,columns:c,pillPlacement:b="dropdown",mode:x="auto",optionsPosition:R="below",animations:I=!0,dropdownTrigger:k,closeDropdownOnBlur:P,showNonTappableOptions:w,autoFocus:C=!0,onFocus:F,onBlur:j,value:n,completedParams:y,onChange:L,onParamsChange:W,submitButton:f},Q){let z=pe(null),E=pe(null),G=pe(()=>{}),T=pe(null),X=pe(null);ot(()=>{let _=z.current;if(_)return T.current?T.current.setMode(x):T.current=new Ht(_,x),()=>{T.current?.destroy(),T.current=null}},[x]);let V=Le(_=>{let U=X.current?.current;U&&(U.focus(),Nt(U,_))},[]),{completedParams:B,suggestionPills:O,setActivePill:h,segments:Y,newParamId:ee,clearNewParamId:Z,placeholderText:u,isFocused:t,isDropdownOpen:p,isActivePillSelected:m,isLoading:v,activeIndex:g,listboxId:D,handleTextChange:M,handleKeyDown:$,setFocused:ce,editingParam:_e,editingAnchor:ue,caretOffset:o,startEditingParam:A,handleCaretAfterInput:S,handleCaretMove:oe,replaceEditingRange:se,dropdownProps:it,reset:me}=De({onSubmit:_=>G.current(_),onError:i,optionOverrides:r,maskCompletedText:d,apiConfig:s,columns:c,dropdownTrigger:k,optionsPosition:R,closeDropdownOnBlur:P,showNonTappableOptions:w,onFocus:F,onBlur:j,value:n,completedParams:y,onChange:L,onParamsChange:W,source:"full-sdk",setCursor:V});ot(()=>{if(!ee)return;let _=window.setTimeout(()=>Z(),650);return()=>window.clearTimeout(_)},[ee,Z]);let nt=g>=0?`${D}-option-${g}`:void 0,{inputRef:ke,editorProps:rt,focus:ge,blur:Fe,getPlainText:Be}=at({segments:Y,newParamId:ee,editingParam:_e,editingAnchor:ue,caretOffset:o,placeholderText:u,isFocused:t,isDropdownOpen:p,listboxId:D,activeDescendantId:nt,autoFocus:C,handleTextChange:M,handleKeyDown:$,handleCaretAfterInput:S,handleCaretMove:oe,startEditingParam:A,replaceEditingRange:se,setFocused:ce});X.current=ke,Ot(()=>{let _=E.current,U=ke.current;if(!_||!U)return;let he=()=>{let Me=_.firstElementChild;if(!Me)return;let pt=Me.getBoundingClientRect(),ct=U.getBoundingClientRect();pt.top>=ct.bottom-2?_.setAttribute("data-aia-pill-wrapped",""):_.removeAttribute("data-aia-pill-wrapped")};he();let Oe=new ResizeObserver(he);return Oe.observe(U),()=>Oe.disconnect()},[Y,O.length,v,ke]),Bt(Q,()=>({focus:ge,blur:Fe,reset:me,setMode:_=>T.current?.setMode(_)}),[ge,Fe,me]);let fe=!!Y.length||B.length>0,Ie=Le(()=>{if(!fe)return;let _=Be(),{rawQuery:U,completedParams:he}=Mt(_,B);l({query:_.trim(),raw_query:U,completed_params:he}),me()},[fe,B,l,me,Be]);G.current=Ie;let st=Le(_=>{_.target?.closest("[data-aia-pill]")||ge()},[ge]),lt=b==="inline",dt=b==="dropdown";return ze("div",{ref:z,className:`magicx-aia ${te.container} ${a??""}`,"data-pill-placement":b,"data-options-position":R,"data-animations":I?"on":"off","data-mode":Kt(x),children:[re(Ce,{...it,showPills:dt}),ze("div",{className:te.inputWrapper,onClick:st,children:[ze("div",{className:te.editorArea,"data-aia-editor":"",children:[re("div",{...rt,className:te.input,"data-aia-input":""}),lt&&(v||O.length>0)&&re("span",{ref:E,className:te.pillListContainer,"data-aia-pill-list-container":"",children:re(xe,{pills:O,activePillIndex:0,activeSelected:m,onSelectPill:h,loading:v})})]}),f===null?null:f===void 0?re(Ze,{disabled:!fe,onClick:Ie}):re("span",{"data-aia-submit":"",className:te.submitSlot,onClick:_=>{fe&&(_.stopPropagation(),Ie())},children:f})]})]})});export{Wt as AIAutocomplete,Ce as AIAutocompleteDropdown,De as useAIAutocomplete};
|
|
1184
|
+
`,document.head.appendChild(e)}var Qe={submitButton:"SubmitButton-module_submitButton_otz7H"};import{jsx as Ee}from"react/jsx-runtime";function Ze({disabled:e,onClick:l}){return Ee("button",{type:"button","data-aia-submit":"",className:Qe.submitButton,disabled:e,onClick:o=>{o.stopPropagation(),l()},"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 Dt}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as Xe,useEffect as we,useRef as O,useState as Tt}from"react";var Lt={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};function Re({onSubmit:e,onError:l,optionOverrides:o,maskCompletedText:s,apiConfig:r,columns:i=2,dropdownTrigger:u,optionsPosition:m,closeDropdownOnBlur:g,showNonTappableOptions:x,onFocus:k,onBlur:_,value:C,completedParams:E,onChange:U,onParamsChange:N,source:Q,setCursor:j}){let n=O(null),[w,D]=Tt(null),K=O(e);K.current=e;let f=O(l);f.current=l;let T=O(U);T.current=U;let L=O(N);L.current=N;let S=O(k);S.current=k;let W=O(_);W.current=_;let R=O(j);R.current=j,we(()=>{if(typeof document>"u")return;let a=new Dt(document.createElement("div"),{renderMode:"headless",apiConfig:r,optionOverrides:o,maskCompletedText:s,columns:i,dropdownTrigger:u,optionsPosition:m,closeDropdownOnBlur:g,showNonTappableOptions:x,source:Q,value:C,completedParams:E,onSubmit:(...I)=>K.current?.(...I),onError:(...I)=>f.current?.(...I),onChange:(...I)=>T.current?.(...I),onParamsChange:(...I)=>L.current?.(...I),onFocus:()=>S.current?.(),onBlur:()=>W.current?.(),setCursor:I=>R.current?.(I)});n.current=a,D(a.getState());let P=a.subscribe(I=>D(I));return()=>{P(),a.destroy(),n.current===a&&(n.current=null)}},[]),we(()=>{C!==void 0&&n.current?.setValue(C)},[C]),we(()=>{E!==void 0&&n.current?.setCompletedParams(E)},[E]);let Z=JSON.stringify(r??null),V=O(o),z=O(0);if(o!==V.current){let a=V.current,P=o,I=Object.keys(a??{}),oe=Object.keys(P??{});(I.length!==oe.length||oe.some(se=>!a?.[se]||P[se]!==a[se]))&&z.current++,V.current=o}we(()=>{n.current?.update({apiConfig:r,optionOverrides:o,dropdownTrigger:u,optionsPosition:m,closeDropdownOnBlur:g,showNonTappableOptions:x})},[Z,z.current,u,m,g,x]);let F=O(null);F.current===null&&(F.current={handleTextChange:a=>n.current?.handleTextChange(a),handleKeyDown:a=>{let P="nativeEvent"in a?a.nativeEvent:a;n.current?.handleKeyDown(P)},setFocused:a=>n.current?.setFocused(a),startEditingParam:a=>n.current?.startEditingParam(a),exitEditMode:()=>n.current?.exitEditMode(),handleCaretAfterInput:a=>n.current?.handleCaretAfterInput(a),handleCaretMove:a=>n.current?.handleCaretMove(a),replaceEditingRange:a=>n.current?.replaceEditingRange(a)??!1,setActivePill:a=>n.current?.setActivePill(a),removeLastParam:()=>n.current?.removeLastParam(),clearNewParamId:()=>n.current?.clearNewParamId(),reset:()=>n.current?.reset(),selectOption:a=>n.current?.selectOption(a),setActiveDropdownIndex:a=>n.current?.setActiveDropdownIndex(a),handleFocus:()=>n.current?.setFocused(!0),handleBlur:()=>n.current?.setFocused(!1)});let b=F.current,Y=Xe(a=>{let P=a.target.value,oe=P.length>0&&!a.nativeEvent?.isComposing&&P[0]!==P[0].toUpperCase()?P[0].toUpperCase()+P.slice(1):P;n.current?.handleTextChange(oe)},[]),ee=Xe(a=>{n.current?.handleKeyDown(a.nativeEvent)},[]),X=n.current,p=w??Lt,t=C!==void 0?C:p.text,d=E!==void 0?E:p.completedParams,c=p.actionableSuggestions,v=c[0],h=X?.listboxId??"",A=p.activeDropdownIndex>=0&&X?`${h}-option-${p.activeDropdownIndex}`:void 0,B=p.editingParam,$=B?{type:B.suggestionType,text:B.suggestionPlaceholder,required:!0,options:B.options}:null,ce=$??v,_e=$?[$]:c,ue=!X||p.isLoading&&!p.editingParam&&!p.inSelectionAnimation;return{completedParams:d,suggestionPills:c,setActivePill:b.setActivePill,removeLastParam:b.removeLastParam,segments:p.segments,newParamId:p.newParamId,clearNewParamId:b.clearNewParamId,suggestions:p.suggestions,activeIndex:p.activeDropdownIndex,isReady:p.isReady,isLoading:ue,isFocused:p.isFocused,isDropdownOpen:p.isDropdownOpen,isActivePillSelected:p.isActivePillSelected,placeholderText:p.placeholderText,listboxId:h,error:p.error,handleTextChange:b.handleTextChange,handleKeyDown:b.handleKeyDown,setFocused:b.setFocused,editingParam:B,editingAnchor:p.editingAnchor,caretOffset:p.caretOffset,startEditingParam:b.startEditingParam,exitEditMode:b.exitEditMode,handleCaretAfterInput:b.handleCaretAfterInput,handleCaretMove:b.handleCaretMove,replaceEditingRange:b.replaceEditingRange,inputProps:{value:t,placeholder:p.placeholderText||void 0,onChange:Y,onKeyDown:ee,onFocus:b.handleFocus,onBlur:b.handleBlur,role:"combobox","aria-expanded":p.isDropdownOpen,"aria-activedescendant":A,"aria-autocomplete":"list","aria-controls":h},reset:b.reset,dropdownProps:{suggestions:ce?[{...ce,options:p.filteredOptions}]:[],activeIndex:p.activeDropdownIndex,onSelect:b.selectOption,onHighlight:b.setActiveDropdownIndex,isOpen:p.isDropdownOpen,id:h,pills:_e,activeSelected:p.isActivePillSelected,onPillClick:b.setActivePill,isLoading:ue,isInputEmpty:t.trim().length===0,optionsPosition:m??"below"}}}import{extractPlainText as Je,getCursorOffset as Ye,plainTextLength as zt,renderEditableContent as Ft,setCursorOffset as et}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as H,useEffect as De,useLayoutEffect as Te,useRef as ne}from"react";var ye;function Bt(){if(ye!==void 0)return ye;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),ye=e.contentEditable==="plaintext-only",ye}function tt(e){let{segments:l,newParamId:o,editingParam:s,editingAnchor:r,caretOffset:i,placeholderText:u,isFocused:m,isDropdownOpen:g,listboxId:x,activeDescendantId:k,autoFocus:_,handleTextChange:C,handleKeyDown:E,handleCaretAfterInput:U,handleCaretMove:N,startEditingParam:Q,replaceEditingRange:j,setFocused:n}=e,w=ne(null),D=ne(!1),K=ne(""),f=ne(""),T=ne(null),L=ne(0);T.current=i,De(()=>{if(!_)return;let t=w.current;if(!t)return;document.activeElement===t?n(!0):t.focus();let d=t.ownerDocument??document,c=d.getSelection(),v=c&&c.rangeCount>0&&t.contains(c.anchorNode);if(c&&!v){let h=d.createRange();h.selectNodeContents(t),h.collapse(!0),c.removeAllRanges(),c.addRange(h)}},[_,n]),De(()=>{let t=w.current;if(!t)return;let d=t.ownerDocument??document,c=()=>{let v=d.getSelection();if(!v||v.rangeCount===0||!v.anchorNode||!t.contains(v.anchorNode))return;let h=v.anchorNode,$=(h.nodeType===Node.ELEMENT_NODE?h:h.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if($&&$!==s?.id){Q($);return}performance.now()-L.current<50||N(Ye(t))};return d.addEventListener("selectionchange",c),()=>d.removeEventListener("selectionchange",c)},[s,Q,N]),Te(()=>{let t=w.current;t&&Ft({input:t,segments:l,newParamId:o,editingParamId:s?.id??null,placeholderText:u??"",isFocused:m})},[l,o,s,u,m]),Te(()=>{let t=K.current,d=o??"";if(K.current=d,!d||d===t)return;let c=w.current;if(!c)return;c.focus();let v=T.current??zt(c);et(c,v)},[o]),Te(()=>{let t=f.current,d=s?.id??"";if(f.current=d,!d||d===t||r==null)return;let c=w.current;c&&et(c,r)},[s,r]);let S=H(()=>{if(D.current)return;let t=w.current;if(!t)return;let d=Je(t),v=d.length>0&&d[0]!==d[0].toUpperCase()?d[0].toUpperCase()+d.slice(1):d;C(v)},[C]),W=H(()=>{L.current=performance.now(),S();let t=w.current;t&&U(Ye(t))},[S,U]);De(()=>{let t=w.current;if(!t)return;let d=c=>{let v=c,h=v.inputType;if(h==="insertParagraph"||h==="insertLineBreak"||h==="insertFromDrop"){c.preventDefault();return}if(h.startsWith("insert")||h.startsWith("delete")){let A=h.startsWith("delete")?"":v.data??"";j(A)&&c.preventDefault()}};return t.addEventListener("beforeinput",d),()=>t.removeEventListener("beforeinput",d)},[j]);let R=H(()=>{D.current=!0},[]),Z=H(()=>{D.current=!1,S()},[S]),V=H(t=>{t.preventDefault();let d=w.current;if(!d)return;let c=(t.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!c)return;let v=d.ownerDocument??document,h=v.getSelection();if(!h||h.rangeCount===0)return;let A=h.getRangeAt(0);if(!d.contains(A.startContainer))return;A.deleteContents();let B=v.createTextNode(c);A.insertNode(B),A.setStartAfter(B),A.collapse(!0),h.removeAllRanges(),h.addRange(A),S()},[S]),z=H(t=>E(t),[E]),F=H(()=>n(!0),[n]),b=H(()=>n(!1),[n]),Y=H(()=>w.current?.focus(),[]),ee=H(()=>w.current?.blur(),[]),X=H(()=>{let t=w.current;return t?Je(t):""},[]),p=Bt()?"plaintext-only":"true";return{inputRef:w,editorProps:{ref:w,contentEditable:p,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":x,"aria-expanded":g,"aria-activedescendant":k,spellCheck:!0,enterKeyHint:"send",onInput:W,onKeyDown:z,onCompositionStart:R,onCompositionEnd:Z,onPaste:V,onFocus:F,onBlur:b},getPlainText:X,focus:Y,blur:ee}}import{jsx as re,jsxs as ze}from"react/jsx-runtime";function Gt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var Ut=Mt(function({onSubmit:l,onError:o,optionOverrides:s,maskCompletedText:r,className:i,apiConfig:u,columns:m,pillPlacement:g="dropdown",mode:x="auto",optionsPosition:k="below",animations:_=!0,dropdownTrigger:C,closeDropdownOnBlur:E,showNonTappableOptions:U,autoFocus:N=!0,onFocus:Q,onBlur:j,value:n,completedParams:w,onChange:D,onParamsChange:K,submitButton:f},T){let L=pe(null),S=pe(null),W=pe(()=>{}),R=pe(null),Z=pe(null);at(()=>{let y=L.current;if(y)return R.current?R.current.setMode(x):R.current=new Kt(y,x),()=>{R.current?.destroy(),R.current=null}},[x]);let V=Le(y=>{let G=Z.current?.current;G&&(G.focus(),Wt(G,y))},[]),{completedParams:z,suggestionPills:F,setActivePill:b,segments:Y,newParamId:ee,clearNewParamId:X,placeholderText:p,isFocused:t,isDropdownOpen:d,isActivePillSelected:c,isLoading:v,activeIndex:h,listboxId:A,handleTextChange:B,handleKeyDown:$,setFocused:ce,editingParam:_e,editingAnchor:ue,caretOffset:a,startEditingParam:P,handleCaretAfterInput:I,handleCaretMove:oe,replaceEditingRange:se,dropdownProps:ot,reset:me}=Re({onSubmit:y=>W.current(y),onError:o,optionOverrides:s,maskCompletedText:r,apiConfig:u,columns:m,dropdownTrigger:C,optionsPosition:k,closeDropdownOnBlur:E,showNonTappableOptions:U,onFocus:Q,onBlur:j,value:n,completedParams:w,onChange:D,onParamsChange:K,source:"full-sdk",setCursor:V});at(()=>{if(!ee)return;let y=window.setTimeout(()=>X(),650);return()=>window.clearTimeout(y)},[ee,X]);let it=h>=0?`${A}-option-${h}`:void 0,{inputRef:ke,editorProps:nt,focus:ge,blur:Fe,getPlainText:Be}=tt({segments:Y,newParamId:ee,editingParam:_e,editingAnchor:ue,caretOffset:a,placeholderText:p,isFocused:t,isDropdownOpen:d,listboxId:A,activeDescendantId:it,autoFocus:N,handleTextChange:B,handleKeyDown:$,handleCaretAfterInput:I,handleCaretMove:oe,startEditingParam:P,replaceEditingRange:se,setFocused:ce});Z.current=ke,Ht(()=>{let y=S.current,G=ke.current;if(!y||!G)return;let fe=()=>{let Oe=y.firstElementChild;if(!Oe)return;let dt=Oe.getBoundingClientRect(),pt=G.getBoundingClientRect();dt.top>=pt.bottom-2?y.setAttribute("data-aia-pill-wrapped",""):y.removeAttribute("data-aia-pill-wrapped")};fe();let Me=new ResizeObserver(fe);return Me.observe(G),()=>Me.disconnect()},[Y,F.length,v,ke]),Ot(T,()=>({focus:ge,blur:Fe,reset:me,setMode:y=>R.current?.setMode(y)}),[ge,Fe,me]);let he=!!Y.length||z.length>0,Ie=Le(()=>{if(!he)return;let y=Be(),{rawQuery:G,completedParams:fe}=Nt(y,z);l({query:y.trim(),raw_query:G,completed_params:fe}),me()},[he,z,l,me,Be]);W.current=Ie;let rt=Le(y=>{y.target?.closest("[data-aia-pill]")||ge()},[ge]),st=g==="inline",lt=g==="dropdown";return ze("div",{ref:L,className:`magicx-aia ${te.container} ${i??""}`,"data-pill-placement":g,"data-options-position":k,"data-animations":_?"on":"off","data-mode":Gt(x),children:[re(Ce,{...ot,showPills:lt}),ze("div",{className:te.inputWrapper,onClick:rt,children:[ze("div",{className:te.editorArea,"data-aia-editor":"",children:[re("div",{...nt,className:te.input,"data-aia-input":""}),st&&(v||F.length>0)&&re("span",{ref:S,className:te.pillListContainer,"data-aia-pill-list-container":"",children:re(ve,{pills:F,activePillIndex:0,activeSelected:c,onSelectPill:b,loading:v})})]}),f===null?null:f===void 0?re(Ze,{disabled:!he,onClick:Ie}):re("span",{"data-aia-submit":"",className:te.submitSlot,onClick:y=>{he&&(y.stopPropagation(),Ie())},children:f})]})]})});export{Ut as AIAutocomplete,Ce as AIAutocompleteDropdown,Re as useAIAutocomplete};
|
|
1080
1185
|
//# sourceMappingURL=index.mjs.map
|