@magicx-eng/ai-autocomplete-react 0.2.1 → 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 +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +386 -219
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +386 -219
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
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 mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.AIAutocomplete-module_inputWrapper_FLq1b {
|
|
11
|
-
padding:
|
|
12
|
-
border: 1px solid var(--aia-
|
|
13
|
-
border-radius:
|
|
14
|
-
background:
|
|
11
|
+
padding: 12px 10px;
|
|
12
|
+
border: 1px solid var(--aia-border, #b0b0b0);
|
|
13
|
+
border-radius: 24px;
|
|
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 mt,useCallback as Ee,useEffect as Ge,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 mt,useCallback as Ee,useEffect as Ge,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
|
|
|
@@ -109,26 +109,6 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
109
109
|
margin-left: 0;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
.AIAutocomplete-module_submitButton_sl1Mi {
|
|
113
|
-
flex-shrink: 0;
|
|
114
|
-
width: 36px;
|
|
115
|
-
height: 36px;
|
|
116
|
-
border-radius: 50%;
|
|
117
|
-
border: none;
|
|
118
|
-
background: var(--aia-submit-bg, var(--aia-color-text-default, #fff));
|
|
119
|
-
color: var(--aia-submit-color, var(--aia-color-bg-default, #000));
|
|
120
|
-
cursor: pointer;
|
|
121
|
-
display: flex;
|
|
122
|
-
align-items: center;
|
|
123
|
-
justify-content: center;
|
|
124
|
-
padding: 0;
|
|
125
|
-
transition: opacity 0.2s ease;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.AIAutocomplete-module_submitButton_sl1Mi:hover {
|
|
129
|
-
opacity: 0.85;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
112
|
.AIAutocomplete-module_submitSlot_GhuCM {
|
|
133
113
|
display: contents;
|
|
134
114
|
}
|
|
@@ -165,21 +145,166 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
165
145
|
background-position: -50% 0;
|
|
166
146
|
}
|
|
167
147
|
}
|
|
168
|
-
`,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 {
|
|
169
281
|
position: absolute;
|
|
170
282
|
left: 0;
|
|
171
283
|
right: 0;
|
|
172
284
|
top: 100%;
|
|
173
|
-
max-width:
|
|
285
|
+
max-width: 544px;
|
|
174
286
|
margin-top: 6px;
|
|
175
287
|
display: flex;
|
|
176
288
|
flex-direction: column;
|
|
289
|
+
box-sizing: border-box;
|
|
290
|
+
padding: 4px;
|
|
177
291
|
overflow: hidden;
|
|
178
292
|
container-type: inline-size;
|
|
179
293
|
z-index: 10;
|
|
180
294
|
opacity: 0;
|
|
181
295
|
pointer-events: none;
|
|
182
296
|
transition: opacity 400ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
297
|
+
/* Solid surface is the default (matches the Figma components). Opt into the
|
|
298
|
+
frosted-glass look with data-aia-surface="glass". */
|
|
299
|
+
background: var(--aia-surface, #ffffff);
|
|
300
|
+
border: 1px solid var(--aia-dropdown-border, #e5e7eb);
|
|
301
|
+
border-radius: 25px;
|
|
302
|
+
box-shadow: var(--aia-dropdown-shadow, 0 8px 12px rgba(0, 0, 0, 0.12));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.AIAutocompleteDropdown-module_dropdown_yz2KC[data-aia-surface="glass"] {
|
|
306
|
+
background: transparent;
|
|
307
|
+
border-color: transparent;
|
|
183
308
|
box-shadow:
|
|
184
309
|
hsla(0, 0%, 100%, 1) -3.2px -3.2px 3.2px -3.2px inset,
|
|
185
310
|
hsla(0, 0%, 100%, 1) 6.4px 6.4px 1.6px -8px inset,
|
|
@@ -192,7 +317,6 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
192
317
|
inset 0 0 30px 5px hsla(0, 0%, 0%, 0.05),
|
|
193
318
|
hsla(0, 0%, 0%, 0.08) 0px 0px 30px 2px;
|
|
194
319
|
backdrop-filter: blur(30px);
|
|
195
|
-
border-radius: 28px;
|
|
196
320
|
}
|
|
197
321
|
|
|
198
322
|
.AIAutocompleteDropdown-module_visible_QCoXj {
|
|
@@ -200,8 +324,10 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
200
324
|
pointer-events: auto;
|
|
201
325
|
}
|
|
202
326
|
|
|
327
|
+
/* The dropdown owns a uniform 4px pad; each section adds its own 7px/8px inset
|
|
328
|
+
(matches the Figma PillList). */
|
|
203
329
|
.AIAutocompleteDropdown-module_pillBar_pwTXe {
|
|
204
|
-
padding:
|
|
330
|
+
padding: 7px 8px;
|
|
205
331
|
overflow-x: auto;
|
|
206
332
|
overflow-y: hidden;
|
|
207
333
|
scrollbar-width: none;
|
|
@@ -218,12 +344,12 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
218
344
|
display: flex;
|
|
219
345
|
flex-direction: column;
|
|
220
346
|
gap: 20px;
|
|
221
|
-
padding:
|
|
347
|
+
padding: 7px 8px;
|
|
222
348
|
}
|
|
223
349
|
|
|
224
350
|
.AIAutocompleteDropdown-module_skeletonBar_O3xIx {
|
|
225
351
|
display: block;
|
|
226
|
-
height:
|
|
352
|
+
height: 14px;
|
|
227
353
|
border-radius: 999px;
|
|
228
354
|
background: var(--aia-skeleton-bg, var(--aia-pill-bg, rgba(189, 189, 189, 0.51)));
|
|
229
355
|
opacity: 0.5;
|
|
@@ -247,66 +373,158 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
247
373
|
opacity: 0.25;
|
|
248
374
|
}
|
|
249
375
|
}
|
|
250
|
-
`,document.head.appendChild(e)}var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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 {
|
|
377
|
+
.aia-cluster {
|
|
378
|
+
display: flex;
|
|
379
|
+
flex-wrap: wrap;
|
|
380
|
+
gap: var(--aia-cluster-gap, 0.5rem);
|
|
381
|
+
}
|
|
382
|
+
/* Inline-level variant \u2014 used when the cluster must sit inline (e.g. inside
|
|
383
|
+
a contentEditable). Rendered on a <span> so it's valid inline content. */
|
|
384
|
+
.aia-cluster[data-inline] {
|
|
385
|
+
display: inline-flex;
|
|
386
|
+
}
|
|
387
|
+
.aia-cluster[data-nowrap] {
|
|
388
|
+
flex-wrap: nowrap;
|
|
389
|
+
}
|
|
390
|
+
.aia-cluster[data-align="start"] {
|
|
391
|
+
align-items: start;
|
|
392
|
+
}
|
|
393
|
+
.aia-cluster[data-align="center"] {
|
|
394
|
+
align-items: center;
|
|
395
|
+
}
|
|
396
|
+
.aia-cluster[data-align="end"] {
|
|
397
|
+
align-items: end;
|
|
398
|
+
}
|
|
399
|
+
.aia-cluster[data-align="baseline"] {
|
|
400
|
+
align-items: baseline;
|
|
401
|
+
}
|
|
402
|
+
.aia-cluster[data-justify="start"] {
|
|
403
|
+
justify-content: start;
|
|
404
|
+
}
|
|
405
|
+
.aia-cluster[data-justify="center"] {
|
|
406
|
+
justify-content: center;
|
|
407
|
+
}
|
|
408
|
+
.aia-cluster[data-justify="end"] {
|
|
409
|
+
justify-content: end;
|
|
410
|
+
}
|
|
411
|
+
.aia-cluster[data-justify="between"] {
|
|
412
|
+
justify-content: space-between;
|
|
413
|
+
}
|
|
414
|
+
.aia-cluster[data-justify="around"] {
|
|
415
|
+
justify-content: space-around;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
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. */
|
|
421
|
+
.DropdownFooter-module_footer_qQQ7x {
|
|
422
|
+
display: flex;
|
|
423
|
+
flex-direction: column;
|
|
424
|
+
gap: 8px;
|
|
425
|
+
padding: 7px 8px;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.DropdownFooter-module_divider_FlX4C {
|
|
429
|
+
border-top: 0.5px solid var(--aia-footer-divider, rgba(176, 176, 176, 0.4));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.DropdownFooter-module_hintGroup_ZzbPf {
|
|
433
|
+
min-width: 0;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.DropdownFooter-module_brandLink_r4f3R {
|
|
254
437
|
display: inline-flex;
|
|
255
|
-
gap: 5px;
|
|
256
438
|
align-items: center;
|
|
257
|
-
|
|
439
|
+
gap: 2px;
|
|
440
|
+
text-decoration: none;
|
|
441
|
+
cursor: pointer;
|
|
442
|
+
transition: opacity 150ms ease-out;
|
|
258
443
|
}
|
|
259
444
|
|
|
260
|
-
.
|
|
445
|
+
.DropdownFooter-module_brandLink_r4f3R:hover {
|
|
446
|
+
opacity: 0.7;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.DropdownFooter-module_key_Bz1H- {
|
|
261
450
|
display: inline-flex;
|
|
262
451
|
align-items: center;
|
|
263
452
|
justify-content: center;
|
|
264
|
-
|
|
265
|
-
|
|
453
|
+
min-width: 30px;
|
|
454
|
+
height: 22px;
|
|
455
|
+
padding: 2px 6px;
|
|
456
|
+
border: 0.5px solid var(--aia-footer-hint-color, #505050);
|
|
457
|
+
border-radius: 5px;
|
|
458
|
+
font-family: inherit;
|
|
459
|
+
font-size: 11px;
|
|
460
|
+
line-height: 18px;
|
|
461
|
+
color: var(--aia-footer-hint-color, #505050);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.DropdownFooter-module_hint_GKEOH {
|
|
465
|
+
font-family: inherit;
|
|
466
|
+
font-size: 11px;
|
|
467
|
+
line-height: 18px;
|
|
468
|
+
color: var(--aia-footer-hint-color, #505050);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.DropdownFooter-module_brand_Al-lR {
|
|
472
|
+
font-family: inherit;
|
|
473
|
+
font-size: 10px;
|
|
474
|
+
line-height: 18px;
|
|
475
|
+
color: var(--aia-footer-brand-color, #b0b0b0);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.DropdownFooter-module_badge_Fk9vg {
|
|
479
|
+
display: inline-flex;
|
|
480
|
+
align-items: center;
|
|
481
|
+
height: 23px;
|
|
482
|
+
padding: 2.5px 5.5px;
|
|
483
|
+
border: 0.5px solid var(--aia-footer-badge-border, rgba(189, 189, 189, 0.51));
|
|
484
|
+
border-radius: 999px;
|
|
485
|
+
font-family: inherit;
|
|
486
|
+
font-size: 10px;
|
|
487
|
+
line-height: 18px;
|
|
488
|
+
color: var(--aia-footer-brand-color, #b0b0b0);
|
|
489
|
+
}
|
|
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- {
|
|
491
|
+
display: inline-flex;
|
|
492
|
+
align-items: center;
|
|
493
|
+
justify-content: center;
|
|
494
|
+
padding: 7px 8px;
|
|
266
495
|
border: none;
|
|
267
496
|
border-radius: 999px;
|
|
268
497
|
background: rgba(49, 50, 85, 0.25);
|
|
269
498
|
background: color-mix(
|
|
270
499
|
in srgb,
|
|
271
|
-
var(--aia-pill-bg, var(--aia-color-background-supportive, #313255))
|
|
500
|
+
var(--aia-pill-bg, var(--aia-color-background-supportive, #313255)) 30%,
|
|
272
501
|
transparent
|
|
273
502
|
);
|
|
274
503
|
color: var(--aia-pill-color, var(--aia-color-text-muted, #c1c4cb));
|
|
275
504
|
font-family: inherit;
|
|
276
|
-
font-size: var(--aia-pill-font-size,
|
|
277
|
-
|
|
505
|
+
font-size: var(--aia-pill-font-size, 14px);
|
|
506
|
+
font-weight: 500;
|
|
507
|
+
line-height: normal;
|
|
278
508
|
cursor: pointer;
|
|
279
509
|
white-space: nowrap;
|
|
280
|
-
animation:
|
|
281
|
-
box-shadow:
|
|
282
|
-
hsla(0, 0%, 100%, 1) -3.2px -3.2px 3.2px -3.2px inset,
|
|
283
|
-
hsla(0, 0%, 100%, 1) 6.4px 6.4px 1.6px -8px inset,
|
|
284
|
-
var(--aia-dropdown-bg, transparent) -6.4px 6.4px 1.6px -8px inset,
|
|
285
|
-
var(--aia-dropdown-bg, transparent) 6.4px -6.4px 1.6px -8px inset,
|
|
286
|
-
hsla(0, 0%, 100%, 0.15) -1.6px 0px 0px -1.6px inset,
|
|
287
|
-
hsla(0, 0%, 100%, 0.15) 0px -1.6px 0px -1.6px inset,
|
|
288
|
-
hsla(0, 0%, 100%, 0.3) 0px 1.6px 0px 0px inset,
|
|
289
|
-
hsla(0, 0%, 100%, 0.3) 1.6px 0px 0px 0px inset,
|
|
290
|
-
inset 0 0 30px 5px hsla(0, 0%, 0%, 0.05),
|
|
291
|
-
hsla(0, 0%, 0%, 0.08) 0px 0px 30px 2px;
|
|
292
|
-
backdrop-filter: blur(30px);
|
|
510
|
+
animation: Pill-module_fadeIn_Bbqtz 400ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
|
293
511
|
}
|
|
294
512
|
|
|
295
|
-
.
|
|
513
|
+
.Pill-module_rounded_6WMps {
|
|
296
514
|
border-radius: 999px;
|
|
297
515
|
}
|
|
298
516
|
|
|
299
517
|
/* Loading skeleton \u2014 preserves the pill's exact box (same width and height)
|
|
300
518
|
and just hides the text. The pill's native background acts as the visible
|
|
301
519
|
shape; the pulse provides the shimmer. */
|
|
302
|
-
.
|
|
520
|
+
.Pill-module_skeleton_-u9-j {
|
|
303
521
|
pointer-events: none;
|
|
304
522
|
cursor: default;
|
|
305
523
|
color: transparent;
|
|
306
|
-
animation:
|
|
524
|
+
animation: Pill-module_skeletonPulse_xHh-7 1.4s ease-in-out infinite;
|
|
307
525
|
}
|
|
308
526
|
|
|
309
|
-
@keyframes
|
|
527
|
+
@keyframes Pill-module_skeletonPulse_xHh-7 {
|
|
310
528
|
0%,
|
|
311
529
|
100% {
|
|
312
530
|
filter: brightness(1);
|
|
@@ -316,75 +534,75 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
316
534
|
}
|
|
317
535
|
}
|
|
318
536
|
|
|
319
|
-
|
|
320
|
-
filter: brightness(1.2);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
.PillList-module_active_Oll-- {
|
|
324
|
-
outline: 1px solid #5a5b8a;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
@keyframes PillList-module_fadeIn_Aezob {
|
|
537
|
+
@keyframes Pill-module_fadeIn_Bbqtz {
|
|
328
538
|
from {
|
|
329
539
|
opacity: 0;
|
|
330
540
|
}
|
|
331
541
|
}
|
|
332
|
-
`,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 {
|
|
333
543
|
position: relative;
|
|
544
|
+
z-index: 1;
|
|
545
|
+
pointer-events: auto;
|
|
546
|
+
display: inline-flex;
|
|
547
|
+
gap: 7px;
|
|
548
|
+
align-items: center;
|
|
549
|
+
vertical-align: middle;
|
|
334
550
|
}
|
|
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 {
|
|
552
|
+
.aia-grid {
|
|
553
|
+
display: grid;
|
|
554
|
+
grid-template-columns: repeat(
|
|
555
|
+
auto-fit,
|
|
556
|
+
minmax(min(var(--aia-grid-min), 100%), var(--aia-grid-max, 1fr))
|
|
557
|
+
);
|
|
558
|
+
gap: var(--aia-grid-gap, 0);
|
|
559
|
+
}
|
|
335
560
|
|
|
336
|
-
.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
bottom: 0;
|
|
342
|
-
height: 50%;
|
|
343
|
-
pointer-events: none;
|
|
344
|
-
opacity: 0;
|
|
345
|
-
transition: opacity 150ms ease-out;
|
|
346
|
-
backdrop-filter: blur(12px);
|
|
347
|
-
mask-image: linear-gradient(to bottom, transparent, white);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
.SuggestionGrid-module_scrollWrapper_MOqfw[data-fade]::after {
|
|
351
|
-
opacity: 1;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
.SuggestionGrid-module_grid_jvaPb {
|
|
355
|
-
display: grid;
|
|
356
|
-
grid-template-columns: minmax(0, 250px);
|
|
357
|
-
/* Pack rows from the top instead of stretching to fill the grid container. */
|
|
358
|
-
grid-auto-rows: min-content;
|
|
359
|
-
align-content: start;
|
|
360
|
-
max-width: 100cqi;
|
|
361
|
-
padding: 8px 8px;
|
|
362
|
-
max-height: 200px;
|
|
363
|
-
overflow-y: auto;
|
|
364
|
-
scrollbar-width: thin;
|
|
365
|
-
scrollbar-color: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3)) transparent;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
@container (min-width: 516px) {
|
|
369
|
-
.SuggestionGrid-module_grid_jvaPb {
|
|
370
|
-
grid-template-columns: repeat(2, minmax(0, 250px));
|
|
561
|
+
/* Scrollable variant \u2014 capped height with a styled thin scrollbar. Rows pack
|
|
562
|
+
from the top instead of stretching to fill the container. */
|
|
563
|
+
.aia-grid[data-scroll] {
|
|
564
|
+
grid-auto-rows: min-content;
|
|
565
|
+
align-content: start;
|
|
371
566
|
justify-content: start;
|
|
567
|
+
padding: var(--aia-grid-scroll-pad, 0);
|
|
568
|
+
max-height: var(--aia-grid-max-height, 200px);
|
|
569
|
+
overflow-y: auto;
|
|
570
|
+
scrollbar-width: thin;
|
|
571
|
+
scrollbar-color: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3)) transparent;
|
|
572
|
+
}
|
|
573
|
+
.aia-grid[data-scroll]::-webkit-scrollbar {
|
|
574
|
+
width: 6px;
|
|
575
|
+
}
|
|
576
|
+
.aia-grid[data-scroll]::-webkit-scrollbar-track {
|
|
577
|
+
background: transparent;
|
|
578
|
+
}
|
|
579
|
+
.aia-grid[data-scroll]::-webkit-scrollbar-thumb {
|
|
580
|
+
background: var(--aia-scrollbar-thumb, rgba(0, 0, 0, 0.3));
|
|
581
|
+
border-radius: 3px;
|
|
372
582
|
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
.SuggestionGrid-module_grid_jvaPb::-webkit-scrollbar {
|
|
376
|
-
width: 6px;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
.SuggestionGrid-module_grid_jvaPb::-webkit-scrollbar-track {
|
|
380
|
-
background: transparent;
|
|
381
|
-
}
|
|
382
583
|
|
|
383
|
-
.
|
|
384
|
-
|
|
385
|
-
|
|
584
|
+
/* Fade wrapper \u2014 bottom blur overlay shown while the grid overflows below. */
|
|
585
|
+
.aia-grid-fade {
|
|
586
|
+
position: relative;
|
|
587
|
+
}
|
|
588
|
+
.aia-grid-fade::after {
|
|
589
|
+
content: "";
|
|
590
|
+
position: absolute;
|
|
591
|
+
left: 0;
|
|
592
|
+
right: 0;
|
|
593
|
+
bottom: 0;
|
|
594
|
+
height: 50%;
|
|
595
|
+
pointer-events: none;
|
|
596
|
+
opacity: 0;
|
|
597
|
+
transition: opacity 150ms ease-out;
|
|
598
|
+
backdrop-filter: blur(12px);
|
|
599
|
+
mask-image: linear-gradient(to bottom, transparent, white);
|
|
600
|
+
}
|
|
601
|
+
.aia-grid-fade[data-fade]::after {
|
|
602
|
+
opacity: 1;
|
|
603
|
+
}
|
|
386
604
|
}
|
|
387
|
-
`,document.head.appendChild(e)}
|
|
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 {
|
|
388
606
|
position: relative;
|
|
389
607
|
overflow: visible;
|
|
390
608
|
display: flex;
|
|
@@ -392,14 +610,16 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
392
610
|
the same baseline at the top edge of the cell. */
|
|
393
611
|
align-items: flex-start;
|
|
394
612
|
font-family: inherit;
|
|
395
|
-
font-size: var(--aia-option-font-size,
|
|
396
|
-
font-weight:
|
|
397
|
-
line-height:
|
|
613
|
+
font-size: var(--aia-option-font-size, 14px);
|
|
614
|
+
font-weight: 300;
|
|
615
|
+
line-height: 18px;
|
|
398
616
|
color: var(--aia-option-color, var(--aia-color-text-muted, #c1c4cb));
|
|
399
617
|
white-space: normal;
|
|
400
618
|
word-break: break-word;
|
|
401
|
-
|
|
402
|
-
|
|
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;
|
|
403
623
|
animation: SuggestionItem-module_fadeIn_I8u35 500ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
|
404
624
|
}
|
|
405
625
|
|
|
@@ -429,6 +649,7 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
429
649
|
.SuggestionItem-module_highlighted_Hb0SU {
|
|
430
650
|
color: var(--aia-option-color-selected, var(--aia-color-text-default, #fff));
|
|
431
651
|
background: var(--aia-option-bg, transparent);
|
|
652
|
+
font-weight: 700;
|
|
432
653
|
}
|
|
433
654
|
|
|
434
655
|
.SuggestionItem-module_tag_e3Fwe {
|
|
@@ -731,100 +952,46 @@ import{forwardRef as mt,useCallback as Ee,useEffect as Ge,useImperativeHandle as
|
|
|
731
952
|
filter: brightness(0.55);
|
|
732
953
|
}
|
|
733
954
|
}
|
|
734
|
-
`,document.head.appendChild(e)}var
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
* keeps the library self-contained without leaking onto consumer markup.
|
|
751
|
-
*/
|
|
752
|
-
:where(.magicx-aia, .magicx-aia *, .magicx-aia *::before, .magicx-aia *::after) {
|
|
753
|
-
box-sizing: border-box;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
/* Light mode defaults (base) */
|
|
757
|
-
:where(.magicx-aia),
|
|
758
|
-
:where(.magicx-aia[data-mode="light"]) {
|
|
759
|
-
--aia-pill-bg: #bdbdbd;
|
|
760
|
-
--aia-pill-color: #000000;
|
|
761
|
-
--aia-pill-font-size: 19px;
|
|
762
|
-
|
|
763
|
-
--aia-option-bg: transparent;
|
|
764
|
-
--aia-option-color: #4f4f4f;
|
|
765
|
-
--aia-option-color-selected: #000000;
|
|
766
|
-
--aia-option-font-size: 19px;
|
|
767
|
-
|
|
768
|
-
--aia-written-text-color: #000000;
|
|
769
|
-
--aia-written-text-font-size: 19px;
|
|
770
|
-
--aia-caret-color: var(--aia-written-text-color, #000000);
|
|
771
|
-
|
|
772
|
-
--aia-submit-bg: #000000;
|
|
773
|
-
--aia-submit-color: #ffffff;
|
|
774
|
-
|
|
775
|
-
--aia-color-text-muted: #6b7280;
|
|
776
|
-
|
|
777
|
-
--aia-skeleton-bg: rgba(189, 189, 189, 0.51);
|
|
778
|
-
|
|
779
|
-
--aia-streak-rgb: 99, 102, 241;
|
|
780
|
-
--aia-streak-glass-bg: rgba(99, 102, 241, 0.1);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
/* Dark mode defaults */
|
|
784
|
-
:where(.magicx-aia[data-mode="dark"]) {
|
|
785
|
-
--aia-pill-bg: #bdbdbd;
|
|
786
|
-
--aia-pill-color: #ffffff;
|
|
787
|
-
--aia-pill-font-size: 19px;
|
|
788
|
-
|
|
789
|
-
--aia-option-bg: transparent;
|
|
790
|
-
--aia-option-color: #b0b0b0;
|
|
791
|
-
--aia-option-color-selected: #ffffff;
|
|
792
|
-
--aia-option-font-size: 19px;
|
|
793
|
-
|
|
794
|
-
--aia-written-text-color: #ffffff;
|
|
795
|
-
--aia-written-text-font-size: 19px;
|
|
796
|
-
--aia-caret-color: var(--aia-written-text-color, #ffffff);
|
|
797
|
-
|
|
798
|
-
--aia-submit-bg: #ffffff;
|
|
799
|
-
--aia-submit-color: #000000;
|
|
800
|
-
|
|
801
|
-
--aia-color-text-muted: #c1c4cb;
|
|
802
|
-
|
|
803
|
-
--aia-skeleton-bg: #333539;
|
|
804
|
-
|
|
805
|
-
--aia-streak-rgb: 255, 255, 255;
|
|
806
|
-
--aia-streak-glass-bg: rgba(255, 255, 255, 0.1);
|
|
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 {
|
|
956
|
+
.aia-stack {
|
|
957
|
+
display: flex;
|
|
958
|
+
flex-direction: column;
|
|
959
|
+
gap: var(--aia-stack-space, 0.5rem);
|
|
960
|
+
}
|
|
961
|
+
.aia-stack[data-align="start"] {
|
|
962
|
+
align-items: start;
|
|
963
|
+
}
|
|
964
|
+
.aia-stack[data-align="center"] {
|
|
965
|
+
align-items: center;
|
|
966
|
+
}
|
|
967
|
+
.aia-stack[data-align="end"] {
|
|
968
|
+
align-items: end;
|
|
969
|
+
}
|
|
970
|
+
/* data-align="stretch" is the flex default \u2014 no rule needed. */
|
|
807
971
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
:
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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 {
|
|
973
|
+
flex-shrink: 0;
|
|
974
|
+
width: 32px;
|
|
975
|
+
height: 32px;
|
|
976
|
+
border-radius: 50%;
|
|
977
|
+
border: none;
|
|
978
|
+
background: var(--aia-submit-bg, var(--aia-color-text-default, #fff));
|
|
979
|
+
color: var(--aia-submit-color, var(--aia-color-bg-default, #000));
|
|
980
|
+
cursor: pointer;
|
|
981
|
+
display: flex;
|
|
982
|
+
align-items: center;
|
|
983
|
+
justify-content: center;
|
|
984
|
+
padding: 0;
|
|
985
|
+
transition: opacity 0.2s ease;
|
|
816
986
|
}
|
|
817
987
|
|
|
818
|
-
|
|
819
|
-
|
|
988
|
+
.SubmitButton-module_submitButton_otz7H:hover {
|
|
989
|
+
opacity: 0.85;
|
|
820
990
|
}
|
|
821
991
|
|
|
822
|
-
|
|
823
|
-
:
|
|
824
|
-
:
|
|
825
|
-
:where(.magicx-aia[data-animations="off"]) *::after {
|
|
826
|
-
animation-duration: 0s !important;
|
|
827
|
-
transition-duration: 0s !important;
|
|
992
|
+
.SubmitButton-module_submitButton_otz7H:disabled {
|
|
993
|
+
opacity: 0.4;
|
|
994
|
+
cursor: default;
|
|
828
995
|
}
|
|
829
|
-
`,document.head.appendChild(e)}import{buildQuery as bt,ModeController as ht,setCursorOffset as xt}from"@magicx-eng/ai-autocomplete-vanilla";import{AIAutocomplete as st}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as He,useEffect as he,useRef as z,useState as lt}from"react";var dt={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};function Ae({onSubmit:e,onError:_,optionOverrides:f,maskCompletedText:v,apiConfig:c,columns:l=2,dropdownTrigger:m,optionsPosition:g,closeDropdownOnBlur:h,showNonTappableOptions:n,onFocus:d,onBlur:I,value:A,completedParams:S,onChange:D,onParamsChange:H,source:N,setCursor:E}){let a=z(null),[w,G]=lt(null),X=z(e);X.current=e;let K=z(_);K.current=_;let Q=z(D);Q.current=D;let V=z(H);V.current=H;let C=z(d);C.current=d;let J=z(I);J.current=I;let L=z(E);L.current=E,he(()=>{if(typeof document>"u")return;let t=new st(document.createElement("div"),{renderMode:"headless",apiConfig:c,optionOverrides:f,maskCompletedText:v,columns:l,dropdownTrigger:m,optionsPosition:g,closeDropdownOnBlur:h,showNonTappableOptions:n,source:N,value:A,completedParams:S,onSubmit:(...y)=>X.current?.(...y),onError:(...y)=>K.current?.(...y),onChange:(...y)=>Q.current?.(...y),onParamsChange:(...y)=>V.current?.(...y),onFocus:()=>C.current?.(),onBlur:()=>J.current?.(),setCursor:y=>L.current?.(y)});a.current=t,G(t.getState());let k=t.subscribe(y=>G(y));return()=>{k(),t.destroy(),a.current===t&&(a.current=null)}},[]),he(()=>{A!==void 0&&a.current?.setValue(A)},[A]),he(()=>{S!==void 0&&a.current?.setCompletedParams(S)},[S]);let ae=JSON.stringify(c??null),Z=z(f),q=z(0);if(f!==Z.current){let t=Z.current,k=f,y=Object.keys(t??{}),ne=Object.keys(k??{});(y.length!==ne.length||ne.some(ie=>!t?.[ie]||k[ie]!==t[ie]))&&q.current++,Z.current=f}he(()=>{a.current?.update({apiConfig:c,optionOverrides:f,dropdownTrigger:m,optionsPosition:g,closeDropdownOnBlur:h,showNonTappableOptions:n})},[ae,q.current,m,g,h,n]);let F=z(null);F.current===null&&(F.current={handleTextChange:t=>a.current?.handleTextChange(t),handleKeyDown:t=>{let k="nativeEvent"in t?t.nativeEvent:t;a.current?.handleKeyDown(k)},setFocused:t=>a.current?.setFocused(t),startEditingParam:t=>a.current?.startEditingParam(t),exitEditMode:()=>a.current?.exitEditMode(),handleCaretAfterInput:t=>a.current?.handleCaretAfterInput(t),handleCaretMove:t=>a.current?.handleCaretMove(t),replaceEditingRange:t=>a.current?.replaceEditingRange(t)??!1,setActivePill:t=>a.current?.setActivePill(t),removeLastParam:()=>a.current?.removeLastParam(),clearNewParamId:()=>a.current?.clearNewParamId(),reset:()=>a.current?.reset(),selectOption:t=>a.current?.selectOption(t),setActiveDropdownIndex:t=>a.current?.setActiveDropdownIndex(t),handleFocus:()=>a.current?.setFocused(!0),handleBlur:()=>a.current?.setFocused(!1)});let b=F.current,Y=He(t=>{let k=t.target.value,ne=k.length>0&&!t.nativeEvent?.isComposing&&k[0]!==k[0].toUpperCase()?k[0].toUpperCase()+k.slice(1):k;a.current?.handleTextChange(ne)},[]),ee=He(t=>{a.current?.handleKeyDown(t.nativeEvent)},[]),$=a.current,r=w??dt,o=A!==void 0?A:r.text,i=S!==void 0?S:r.completedParams,s=r.actionableSuggestions,x=s[0],p=$?.listboxId??"",P=r.activeDropdownIndex>=0&&$?`${p}-option-${r.activeDropdownIndex}`:void 0,R=r.editingParam,W=R?{type:R.suggestionType,text:R.suggestionPlaceholder,required:!0,options:R.options}:null,de=W??x,ve=W?[W]:s,pe=!$||r.isLoading&&!r.editingParam&&!r.inSelectionAnimation;return{completedParams:i,suggestionPills:s,setActivePill:b.setActivePill,removeLastParam:b.removeLastParam,segments:r.segments,newParamId:r.newParamId,clearNewParamId:b.clearNewParamId,suggestions:r.suggestions,activeIndex:r.activeDropdownIndex,isReady:r.isReady,isLoading:pe,isFocused:r.isFocused,isDropdownOpen:r.isDropdownOpen,placeholderText:r.placeholderText,listboxId:p,error:r.error,handleTextChange:b.handleTextChange,handleKeyDown:b.handleKeyDown,setFocused:b.setFocused,editingParam:R,editingAnchor:r.editingAnchor,caretOffset:r.caretOffset,startEditingParam:b.startEditingParam,exitEditMode:b.exitEditMode,handleCaretAfterInput:b.handleCaretAfterInput,handleCaretMove:b.handleCaretMove,replaceEditingRange:b.replaceEditingRange,inputProps:{value:o,placeholder:r.placeholderText||void 0,onChange:Y,onKeyDown:ee,onFocus:b.handleFocus,onBlur:b.handleBlur,role:"combobox","aria-expanded":r.isDropdownOpen,"aria-activedescendant":P,"aria-autocomplete":"list","aria-controls":p},reset:b.reset,dropdownProps:{suggestions:de?[{...de,options:r.filteredOptions}]:[],activeIndex:r.activeDropdownIndex,onSelect:b.selectOption,onHighlight:b.setActiveDropdownIndex,isOpen:r.isDropdownOpen,id:p,pills:ve,onPillClick:b.setActivePill,isLoading:pe}}}import{extractPlainText as Ke,getCursorOffset as Fe,plainTextLength as pt,renderEditableContent as ut,setCursorOffset as We}from"@magicx-eng/ai-autocomplete-vanilla";import{useCallback as M,useEffect as Se,useLayoutEffect as Pe,useRef as re}from"react";var xe;function ct(){if(xe!==void 0)return xe;if(typeof document>"u")return!1;let e=document.createElement("div");return e.setAttribute("contenteditable","plaintext-only"),xe=e.contentEditable==="plaintext-only",xe}function Ne(e){let{segments:_,newParamId:f,editingParam:v,editingAnchor:c,caretOffset:l,placeholderText:m,isFocused:g,isDropdownOpen:h,listboxId:n,activeDescendantId:d,autoFocus:I,handleTextChange:A,handleKeyDown:S,handleCaretAfterInput:D,handleCaretMove:H,startEditingParam:N,replaceEditingRange:E,setFocused:a}=e,w=re(null),G=re(!1),X=re(""),K=re(""),Q=re(null),V=re(0);Q.current=l,Se(()=>{if(!I)return;let o=w.current;o&&(document.activeElement===o?a(!0):o.focus())},[I,a]),Se(()=>{let o=w.current;if(!o)return;let i=o.ownerDocument??document,s=()=>{let x=i.getSelection();if(!x||x.rangeCount===0||!x.anchorNode||!o.contains(x.anchorNode))return;let p=x.anchorNode,W=(p.nodeType===Node.ELEMENT_NODE?p:p.parentElement)?.closest('strong[data-seg="completed"][data-param-id]')?.dataset.paramId??null;if(W&&W!==v?.id){N(W);return}performance.now()-V.current<50||H(Fe(o))};return i.addEventListener("selectionchange",s),()=>i.removeEventListener("selectionchange",s)},[v,N,H]),Pe(()=>{let o=w.current;o&&ut({input:o,segments:_,newParamId:f,editingParamId:v?.id??null,placeholderText:m??"",isFocused:g})},[_,f,v,m,g]),Pe(()=>{let o=X.current,i=f??"";if(X.current=i,!i||i===o)return;let s=w.current;if(!s)return;s.focus();let x=Q.current??pt(s);We(s,x)},[f]),Pe(()=>{let o=K.current,i=v?.id??"";if(K.current=i,!i||i===o||c==null)return;let s=w.current;s&&We(s,c)},[v,c]);let C=M(()=>{if(G.current)return;let o=w.current;if(!o)return;let i=Ke(o),x=i.length>0&&i[0]!==i[0].toUpperCase()?i[0].toUpperCase()+i.slice(1):i;A(x)},[A]),J=M(()=>{V.current=performance.now(),C();let o=w.current;o&&D(Fe(o))},[C,D]);Se(()=>{let o=w.current;if(!o)return;let i=s=>{let x=s,p=x.inputType;if(p==="insertParagraph"||p==="insertLineBreak"||p==="insertFromDrop"){s.preventDefault();return}if(p.startsWith("insert")||p.startsWith("delete")){let P=p.startsWith("delete")?"":x.data??"";E(P)&&s.preventDefault()}};return o.addEventListener("beforeinput",i),()=>o.removeEventListener("beforeinput",i)},[E]);let L=M(()=>{G.current=!0},[]),ae=M(()=>{G.current=!1,C()},[C]),Z=M(o=>{o.preventDefault();let i=w.current;if(!i)return;let s=(o.clipboardData.getData("text/plain")??"").replace(/\r?\n/g," ");if(!s)return;let x=i.ownerDocument??document,p=x.getSelection();if(!p||p.rangeCount===0)return;let P=p.getRangeAt(0);if(!i.contains(P.startContainer))return;P.deleteContents();let R=x.createTextNode(s);P.insertNode(R),P.setStartAfter(R),P.collapse(!0),p.removeAllRanges(),p.addRange(P),C()},[C]),q=M(o=>S(o),[S]),F=M(()=>a(!0),[a]),b=M(()=>a(!1),[a]),Y=M(()=>w.current?.focus(),[]),ee=M(()=>w.current?.blur(),[]),$=M(()=>{let o=w.current;return o?Ke(o):""},[]),r=ct()?"plaintext-only":"true";return{inputRef:w,editorProps:{ref:w,contentEditable:r,suppressContentEditableWarning:!0,tabIndex:0,role:"combobox","aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n,"aria-expanded":h,"aria-activedescendant":d,spellCheck:!0,enterKeyHint:"send",onInput:J,onKeyDown:q,onCompositionStart:L,onCompositionEnd:ae,onPaste:Z,onFocus:F,onBlur:b},getPlainText:$,focus:Y,blur:ee}}import{jsx as j,jsxs as Ce}from"react/jsx-runtime";function vt(e){return e!=="auto"?e:typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var wt=mt(function({onSubmit:_,onError:f,optionOverrides:v,maskCompletedText:c,className:l,apiConfig:m,columns:g,pillPlacement:h="inline",mode:n="auto",optionsPosition:d="below",animations:I=!0,dropdownTrigger:A,closeDropdownOnBlur:S,showNonTappableOptions:D,autoFocus:H=!0,onFocus:N,onBlur:E,value:a,completedParams:w,onChange:G,onParamsChange:X,submitButton:K},Q){let V=le(null),C=le(null),J=le(()=>{}),L=le(null),ae=le(null);Ge(()=>{let u=V.current;if(u)return L.current?L.current.setMode(n):L.current=new ht(u,n),()=>{L.current?.destroy(),L.current=null}},[n]);let Z=Ee(u=>{let O=ae.current?.current;O&&(O.focus(),xt(O,u))},[]),{completedParams:q,suggestionPills:F,setActivePill:b,segments:Y,newParamId:ee,clearNewParamId:$,placeholderText:r,isFocused:o,isDropdownOpen:i,isLoading:s,activeIndex:x,listboxId:p,handleTextChange:P,handleKeyDown:R,setFocused:W,editingParam:de,editingAnchor:ve,caretOffset:pe,startEditingParam:t,handleCaretAfterInput:k,handleCaretMove:y,replaceEditingRange:ne,dropdownProps:ie,reset:ue}=Ae({onSubmit:u=>J.current(u),onError:f,optionOverrides:v,maskCompletedText:c,apiConfig:m,columns:g,dropdownTrigger:A,optionsPosition:d,closeDropdownOnBlur:S,showNonTappableOptions:D,onFocus:N,onBlur:E,value:a,completedParams:w,onChange:G,onParamsChange:X,source:"full-sdk",setCursor:Z});Ge(()=>{if(!ee)return;let u=window.setTimeout(()=>$(),650);return()=>window.clearTimeout(u)},[ee,$]);let Ve=x>=0?`${p}-option-${x}`:void 0,{inputRef:we,editorProps:qe,focus:ce,blur:De,getPlainText:Le}=Ne({segments:Y,newParamId:ee,editingParam:de,editingAnchor:ve,caretOffset:pe,placeholderText:r,isFocused:o,isDropdownOpen:i,listboxId:p,activeDescendantId:Ve,autoFocus:H,handleTextChange:P,handleKeyDown:R,handleCaretAfterInput:k,handleCaretMove:y,startEditingParam:t,replaceEditingRange:ne,setFocused:W});ae.current=we,ft(()=>{let u=C.current,O=we.current;if(!u||!O)return;let ge=()=>{let Te=u.firstElementChild;if(!Te)return;let Xe=Te.getBoundingClientRect(),Qe=O.getBoundingClientRect();Xe.top>=Qe.bottom-2?u.setAttribute("data-aia-pill-wrapped",""):u.removeAttribute("data-aia-pill-wrapped")};ge();let Re=new ResizeObserver(ge);return Re.observe(O),()=>Re.disconnect()},[Y,F.length,s,we]),gt(Q,()=>({focus:ce,blur:De,reset:ue,setMode:u=>L.current?.setMode(u)}),[ce,De,ue]);let me=!!Y.length||q.length>0,_e=Ee(()=>{if(!me)return;let u=Le(),{rawQuery:O,completedParams:ge}=bt(u,q);_({query:u.trim(),raw_query:O,completed_params:ge}),ue()},[me,q,_,ue,Le]);J.current=_e;let $e=Ee(u=>{u.target?.closest("[data-aia-pill]")||ce()},[ce]),Ue=h==="inline",je=h==="dropdown";return Ce("div",{ref:V,className:`magicx-aia ${U.container} ${l??""}`,"data-pill-placement":h,"data-options-position":d,"data-animations":I?"on":"off","data-mode":vt(n),children:[j(ke,{...ie,showPills:je}),Ce("div",{className:U.inputWrapper,onClick:$e,children:[Ce("div",{className:U.editorArea,"data-aia-editor":"",children:[j("div",{...qe,className:U.input,"data-aia-input":""}),Ue&&(s||F.length>0)&&j("span",{ref:C,className:U.pillListContainer,"data-aia-pill-list-container":"",children:j(se,{pills:F,activePillIndex:0,onSelectPill:b,loading:s})})]}),K===null?null:K===void 0?j("button",{type:"button","data-aia-submit":"",className:U.submitButton,disabled:!me,onClick:u=>{u.stopPropagation(),_e()},"aria-label":"Submit",children:j("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Submit",children:j("path",{d:"M9 14V4M9 4L4 9M9 4L14 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}):j("span",{"data-aia-submit":"",className:U.submitSlot,onClick:u=>{me&&(u.stopPropagation(),_e())},children:K})]})]})});export{wt as AIAutocomplete,ke as AIAutocompleteDropdown,Ae 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};
|
|
830
997
|
//# sourceMappingURL=index.mjs.map
|