@sereno-ds/ui 0.40.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,492 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { createPortal } from "react-dom";
5
+ import { ChevronDown, X } from "lucide-react";
6
+ import { sx } from "../_internal/style.js";
7
+ import { srOnlyStyle } from "../_internal/srOnly.js";
8
+ import { Field } from "../_internal/Field.js";
9
+ import { fieldA11y } from "../_internal/fieldA11y.js";
10
+ import { useIsoLayoutEffect } from "../_internal/useIsoLayoutEffect.js";
11
+ import { useLatest } from "../_internal/useLatest.js";
12
+ import { useCoarsePointer } from "../_internal/useCoarsePointer.js";
13
+ import { useMenuPlacement } from "../_internal/useMenuPlacement.js";
14
+ import { revealInList, useRevealActive } from "../_internal/useRevealActive.js";
15
+ import { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from "../_internal/MenuOption.js";
16
+ import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
17
+ const TEXT = {
18
+ "pt-BR": {
19
+ placeholder: "Buscar\u2026",
20
+ clear: "Limpar sele\xE7\xE3o",
21
+ open: "Abrir lista",
22
+ close: "Fechar lista",
23
+ loading: "Carregando\u2026",
24
+ empty: "Nenhum resultado",
25
+ results: (n) => n === 1 ? "1 resultado" : n + " resultados"
26
+ },
27
+ en: {
28
+ placeholder: "Search\u2026",
29
+ clear: "Clear selection",
30
+ open: "Open list",
31
+ close: "Close list",
32
+ loading: "Loading\u2026",
33
+ empty: "No results",
34
+ results: (n) => n === 1 ? "1 result" : n + " results"
35
+ }
36
+ };
37
+ const REACH_ROWS = 5;
38
+ const MARKS = /[̀-ͯ]/g;
39
+ const plain = (s) => s.normalize("NFD").replace(MARKS, "").toLowerCase();
40
+ function narrow(options, filter, query) {
41
+ if (filter === false) return options;
42
+ const q = query.trim();
43
+ if (!q) return options;
44
+ if (typeof filter === "function") return options.filter((o) => filter(o, query));
45
+ const needle = plain(q);
46
+ return options.filter((o) => plain(o.label).includes(needle));
47
+ }
48
+ const Autocomplete = React.forwardRef(function Autocomplete2({
49
+ label,
50
+ hint,
51
+ error,
52
+ required,
53
+ options = [],
54
+ value: valueProp,
55
+ defaultValue,
56
+ onValueChange,
57
+ filter = true,
58
+ onSearch,
59
+ debounce = 250,
60
+ loading = false,
61
+ onReachEnd,
62
+ onOpenChange,
63
+ clearable = true,
64
+ placeholder,
65
+ size = "md",
66
+ disabled,
67
+ name,
68
+ id,
69
+ containerStyle,
70
+ "aria-label": ariaLabel,
71
+ preserveHelperSpace,
72
+ locale = "pt-BR",
73
+ labels
74
+ }, ref) {
75
+ const reactId = React.useId();
76
+ const rid = id || reactId;
77
+ const listboxId = `${rid}-listbox`;
78
+ const copy = { ...TEXT[locale], ...labels };
79
+ const coarse = useCoarsePointer();
80
+ const inputRef = React.useRef(null);
81
+ const boxRef = React.useRef(null);
82
+ const panelRef = React.useRef(null);
83
+ const listRef = React.useRef(null);
84
+ const isControlled = valueProp !== void 0;
85
+ const [inner, setInner] = React.useState(defaultValue ?? null);
86
+ const value = isControlled ? valueProp : inner;
87
+ const valueLabel = value?.label ?? "";
88
+ const [draft, setDraft] = React.useState(null);
89
+ const text = draft ?? valueLabel;
90
+ const query = draft ?? "";
91
+ const [open, setOpen] = React.useState(false);
92
+ const [focused, setFocused] = React.useState(false);
93
+ const [activeKey, setActiveKey] = React.useState(null);
94
+ const activeFromOpen = React.useRef(false);
95
+ const pick = (key) => {
96
+ activeFromOpen.current = false;
97
+ setActiveKey(key);
98
+ };
99
+ const visible = React.useMemo(() => narrow(options, filter, query), [options, filter, query]);
100
+ const activeIndex = activeKey === null ? -1 : visible.findIndex((o) => o.value === activeKey && !o.disabled);
101
+ const activeId = activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null;
102
+ const rows = visible.length;
103
+ const status = loading ? copy.loading : rows === 0 ? copy.empty : null;
104
+ const onOpenChangeRef = useLatest(onOpenChange);
105
+ const toldOpen = React.useRef(false);
106
+ React.useEffect(() => {
107
+ if (toldOpen.current === open) return;
108
+ toldOpen.current = open;
109
+ onOpenChangeRef.current?.(open);
110
+ }, [open, onOpenChangeRef]);
111
+ const onSearchRef = useLatest(onSearch);
112
+ const searchTimer = React.useRef(void 0);
113
+ const toldQuery = React.useRef("");
114
+ React.useEffect(() => () => window.clearTimeout(searchTimer.current), []);
115
+ const search = (q, immediate) => {
116
+ window.clearTimeout(searchTimer.current);
117
+ const run = () => {
118
+ if (q === toldQuery.current) return;
119
+ toldQuery.current = q;
120
+ onSearchRef.current?.(q);
121
+ };
122
+ if (immediate) run();
123
+ else searchTimer.current = window.setTimeout(run, debounce);
124
+ };
125
+ const settle = () => {
126
+ setOpen(false);
127
+ setDraft(null);
128
+ search("", true);
129
+ };
130
+ const place = useMenuPlacement({
131
+ open,
132
+ anchorRef: boxRef,
133
+ panelRef,
134
+ itemCount: rows + (status ? 1 : 0),
135
+ onDismiss: () => settle()
136
+ });
137
+ useRevealActive(open, activeId, place, revealInList, (el) => !activeFromOpen.current || (el.parentElement?.scrollTop ?? 0) === 0);
138
+ const onReachEndRef = useLatest(onReachEnd);
139
+ const askedFor = React.useRef(null);
140
+ const shape = options.length + "|" + (options[0]?.value ?? "") + "|" + (options[options.length - 1]?.value ?? "");
141
+ useIsoLayoutEffect(() => {
142
+ if (!open) {
143
+ askedFor.current = null;
144
+ return;
145
+ }
146
+ const list2 = listRef.current;
147
+ if (!list2 || rows === 0) return;
148
+ const check = () => {
149
+ if (loading || !onReachEndRef.current || askedFor.current === shape) return;
150
+ const remaining = list2.scrollHeight - list2.scrollTop - list2.clientHeight;
151
+ if (remaining > list2.scrollHeight / rows * REACH_ROWS) return;
152
+ askedFor.current = shape;
153
+ onReachEndRef.current();
154
+ };
155
+ check();
156
+ list2.addEventListener("scroll", check, { passive: true });
157
+ return () => list2.removeEventListener("scroll", check);
158
+ }, [open, loading, shape, place, rows, onReachEndRef]);
159
+ const firstValue = options[0]?.value;
160
+ useIsoLayoutEffect(() => {
161
+ if (draft !== null && listRef.current) listRef.current.scrollTop = 0;
162
+ }, [draft, firstValue]);
163
+ const settleRef = useLatest(settle);
164
+ React.useEffect(() => {
165
+ if (!open) return;
166
+ const onDown = (e) => {
167
+ const target = e.target;
168
+ if (boxRef.current?.contains(target) || panelRef.current?.contains(target)) return;
169
+ settleRef.current();
170
+ };
171
+ document.addEventListener("pointerdown", onDown, true);
172
+ return () => document.removeEventListener("pointerdown", onDown, true);
173
+ }, [open, settleRef]);
174
+ const firstEnabledKey = () => visible.find((o) => !o.disabled)?.value ?? null;
175
+ const lastEnabledKey = () => {
176
+ for (let i = rows - 1; i >= 0; i--) if (!visible[i].disabled) return visible[i].value;
177
+ return null;
178
+ };
179
+ const move = (dir) => {
180
+ let i = activeIndex < 0 ? dir === 1 ? -1 : rows : activeIndex;
181
+ for (let step = 0; step < rows; step++) {
182
+ i += dir;
183
+ if (i < 0 || i >= rows) return;
184
+ if (!visible[i].disabled) {
185
+ pick(visible[i].value);
186
+ return;
187
+ }
188
+ }
189
+ };
190
+ const choose = (o) => {
191
+ if (o.disabled) return;
192
+ if (!isControlled) setInner(o);
193
+ onValueChange?.(o);
194
+ setOpen(false);
195
+ setDraft(null);
196
+ search("", true);
197
+ if (coarse) inputRef.current?.blur();
198
+ };
199
+ const clear = () => {
200
+ if (value) {
201
+ if (!isControlled) setInner(null);
202
+ onValueChange?.(null);
203
+ }
204
+ setDraft("");
205
+ search("", true);
206
+ inputRef.current?.focus();
207
+ };
208
+ const selectedKey = value?.value;
209
+ const startKey = (fallback) => selectedKey !== void 0 && (rows === 0 || visible.some((o) => o.value === selectedKey)) ? selectedKey : fallback;
210
+ const openFromPointer = () => {
211
+ activeFromOpen.current = true;
212
+ setActiveKey(startKey(null));
213
+ setOpen(true);
214
+ };
215
+ const openFromKey = () => {
216
+ activeFromOpen.current = true;
217
+ setActiveKey(startKey(firstEnabledKey()));
218
+ setOpen(true);
219
+ };
220
+ const onChange = (e) => {
221
+ const next = e.currentTarget.value;
222
+ setDraft(next);
223
+ pick(filter === false ? null : narrow(options, filter, next).find((o) => !o.disabled)?.value ?? null);
224
+ setOpen(true);
225
+ if (next === "" && clearable && value) {
226
+ if (!isControlled) setInner(null);
227
+ onValueChange?.(null);
228
+ }
229
+ search(next, false);
230
+ };
231
+ const onKeyDown = (e) => {
232
+ if (disabled || e.nativeEvent.isComposing) return;
233
+ switch (e.key) {
234
+ case "ArrowDown":
235
+ e.preventDefault();
236
+ if (!open) openFromKey();
237
+ else move(1);
238
+ return;
239
+ case "ArrowUp":
240
+ e.preventDefault();
241
+ if (!open) openFromKey();
242
+ else move(-1);
243
+ return;
244
+ case "Home":
245
+ case "End":
246
+ if (open) {
247
+ e.preventDefault();
248
+ pick(e.key === "Home" ? firstEnabledKey() : lastEnabledKey());
249
+ }
250
+ return;
251
+ case "Enter":
252
+ if (open) {
253
+ e.preventDefault();
254
+ if (activeIndex >= 0) choose(visible[activeIndex]);
255
+ }
256
+ return;
257
+ case "Escape":
258
+ if (open) {
259
+ e.preventDefault();
260
+ e.stopPropagation();
261
+ e.nativeEvent.stopImmediatePropagation();
262
+ settle();
263
+ }
264
+ return;
265
+ default:
266
+ }
267
+ };
268
+ const selectOnClick = React.useRef(false);
269
+ const fieldAria = fieldA11y(rid, { hint, error, required });
270
+ const rowPadY = menuRowPadY(coarse, size);
271
+ const fontSize = size === "sm" ? "var(--text-sm)" : "var(--text-base)";
272
+ const showClear = clearable && !disabled && text !== "";
273
+ const list = /* @__PURE__ */ jsxs(
274
+ "div",
275
+ {
276
+ ref: panelRef,
277
+ onMouseDown: (e) => e.preventDefault(),
278
+ style: sx({
279
+ ...menuSurfaceStyle(size),
280
+ display: "flex",
281
+ flexDirection: "column",
282
+ overflow: "hidden",
283
+ maxHeight: place?.maxH,
284
+ ...place?.strategy === "fixed" ? {
285
+ position: "fixed",
286
+ top: place.top,
287
+ left: place.left,
288
+ width: place.width,
289
+ ...place.above ? { transform: "translateY(-100%)" } : null,
290
+ zIndex: 1100
291
+ } : {
292
+ position: "absolute",
293
+ left: 0,
294
+ right: 0,
295
+ ...place?.above ? { bottom: "calc(100% + 6px)" } : { top: "calc(100% + 6px)" },
296
+ zIndex: 100
297
+ }
298
+ }),
299
+ children: [
300
+ /* @__PURE__ */ jsx(
301
+ "ul",
302
+ {
303
+ ref: listRef,
304
+ id: listboxId,
305
+ role: "listbox",
306
+ "aria-label": ariaLabel ?? label,
307
+ "aria-busy": loading || void 0,
308
+ tabIndex: -1,
309
+ style: sx({
310
+ ...menuListStyle,
311
+ position: "relative",
312
+ // so an option's offsetTop is measured from the list
313
+ flex: "1 1 auto",
314
+ minHeight: 0,
315
+ padding: rows ? "var(--space-1)" : 0,
316
+ overscrollBehavior: "contain"
317
+ // don't chain the list's scroll to the page
318
+ }),
319
+ children: visible.map((o, i) => /* @__PURE__ */ jsx(
320
+ MenuOption,
321
+ {
322
+ id: `${rid}-opt-${i}`,
323
+ label: o.label,
324
+ selected: o.value === selectedKey,
325
+ active: i === activeIndex,
326
+ disabled: o.disabled,
327
+ coarse,
328
+ padY: rowPadY,
329
+ onPointerMove: () => !o.disabled && pick(o.value),
330
+ onClick: () => choose(o)
331
+ },
332
+ o.value
333
+ ))
334
+ }
335
+ ),
336
+ status && // Loading is a lone spinner, no text and no rule above it: a screen reader gets the words from the
337
+ // live region below, and this is for the eye. "No results" is the same row with words.
338
+ /* @__PURE__ */ jsx(
339
+ "div",
340
+ {
341
+ "aria-hidden": "true",
342
+ style: sx({
343
+ flex: "0 0 auto",
344
+ display: "flex",
345
+ alignItems: "center",
346
+ justifyContent: "center",
347
+ minHeight: coarse ? 44 : void 0,
348
+ padding: "var(--space-3)",
349
+ color: "var(--text-muted)",
350
+ fontSize: coarse ? "var(--text-base)" : "var(--text-sm)"
351
+ }),
352
+ children: loading ? /* @__PURE__ */ jsx(
353
+ "span",
354
+ {
355
+ style: sx({
356
+ flex: "0 0 auto",
357
+ width: 18,
358
+ height: 18,
359
+ borderRadius: "999px",
360
+ border: "2px solid var(--border-default)",
361
+ borderTopColor: "var(--text-brand)",
362
+ animation: "sereno-spin .7s linear infinite"
363
+ })
364
+ }
365
+ ) : status
366
+ }
367
+ )
368
+ ]
369
+ }
370
+ );
371
+ return /* @__PURE__ */ jsxs(Field, { label, hint, error, required, requiredExposed: true, htmlFor: rid, style: containerStyle, preserveHelperSpace, children: [
372
+ /* @__PURE__ */ jsxs("div", { style: sx({ position: "relative", width: "100%" }), children: [
373
+ /* @__PURE__ */ jsxs(
374
+ "div",
375
+ {
376
+ ref: boxRef,
377
+ onMouseDown: (e) => {
378
+ if (e.target === inputRef.current || disabled) return;
379
+ e.preventDefault();
380
+ inputRef.current?.focus();
381
+ },
382
+ style: sx({ ...fieldBoxStyle(size, !!error, focused || open, !!disabled), cursor: disabled ? "not-allowed" : "text" }),
383
+ children: [
384
+ /* @__PURE__ */ jsx(
385
+ "input",
386
+ {
387
+ ref: inputRef,
388
+ id: rid,
389
+ type: "text",
390
+ role: "combobox",
391
+ "aria-haspopup": "listbox",
392
+ "aria-autocomplete": "list",
393
+ "aria-expanded": open,
394
+ "aria-controls": open ? listboxId : void 0,
395
+ "aria-activedescendant": open && activeId ? activeId : void 0,
396
+ "aria-label": ariaLabel,
397
+ ...fieldAria,
398
+ autoComplete: "off",
399
+ autoCorrect: "off",
400
+ autoCapitalize: "off",
401
+ spellCheck: false,
402
+ enterKeyHint: "done",
403
+ "data-1p-ignore": true,
404
+ "data-lpignore": "true",
405
+ "data-bwignore": "true",
406
+ "data-form-type": "other",
407
+ disabled,
408
+ placeholder: placeholder ?? copy.placeholder,
409
+ value: text,
410
+ onChange,
411
+ onKeyDown,
412
+ onFocus: (e) => {
413
+ setFocused(true);
414
+ selectOnClick.current = true;
415
+ e.currentTarget.select();
416
+ },
417
+ onBlur: (e) => {
418
+ setFocused(false);
419
+ if (boxRef.current?.contains(e.relatedTarget)) return;
420
+ settle();
421
+ },
422
+ onClick: (e) => {
423
+ const el = e.currentTarget;
424
+ if (selectOnClick.current && el.selectionStart === el.selectionEnd) el.select();
425
+ selectOnClick.current = false;
426
+ if (!open) openFromPointer();
427
+ },
428
+ style: sx({
429
+ flex: 1,
430
+ minWidth: 0,
431
+ margin: 0,
432
+ padding: 0,
433
+ // reset the UA input padding - the box's own padding insets it
434
+ border: "none",
435
+ outline: "none",
436
+ background: "transparent",
437
+ fontFamily: "var(--font-body)",
438
+ fontSize,
439
+ lineHeight: 1.2,
440
+ textOverflow: "ellipsis",
441
+ color: disabled ? "var(--text-disabled)" : "var(--text-primary)"
442
+ })
443
+ }
444
+ ),
445
+ showClear && /* @__PURE__ */ jsx(
446
+ "button",
447
+ {
448
+ type: "button",
449
+ className: "ds-affix-btn",
450
+ tabIndex: -1,
451
+ "aria-label": copy.clear,
452
+ onMouseDown: (e) => e.preventDefault(),
453
+ onClick: clear,
454
+ children: /* @__PURE__ */ jsx(X, { size: 16, strokeWidth: 2 })
455
+ }
456
+ ),
457
+ /* @__PURE__ */ jsx(
458
+ "button",
459
+ {
460
+ type: "button",
461
+ className: "ds-affix-btn",
462
+ tabIndex: -1,
463
+ disabled,
464
+ "aria-label": open ? copy.close : copy.open,
465
+ onMouseDown: (e) => e.preventDefault(),
466
+ onClick: () => {
467
+ inputRef.current?.focus({ preventScroll: true });
468
+ if (open) settle();
469
+ else openFromPointer();
470
+ },
471
+ style: sx({
472
+ transition: "transform var(--duration-fast) var(--ease-standard)",
473
+ transform: open ? "rotate(180deg)" : "none"
474
+ }),
475
+ children: /* @__PURE__ */ jsx(ChevronDown, { size: 16, strokeWidth: 1.75 })
476
+ }
477
+ )
478
+ ]
479
+ }
480
+ ),
481
+ open && place && place.strategy === "inline" && list,
482
+ open && place && place.strategy === "fixed" && createPortal(list, document.body),
483
+ /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", style: srOnlyStyle, children: open ? loading ? copy.loading : rows === 0 ? copy.empty : copy.results(rows) : "" })
484
+ ] }),
485
+ name && /* @__PURE__ */ jsx("input", { ref, type: "hidden", name, value: value?.value ?? "" })
486
+ ] });
487
+ });
488
+ Autocomplete.displayName = "Autocomplete";
489
+ export {
490
+ Autocomplete
491
+ };
492
+ //# sourceMappingURL=Autocomplete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/forms/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { srOnlyStyle } from '../_internal/srOnly';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useLatest } from '../_internal/useLatest';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { revealInList, useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface AutocompleteOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/** Every string the component says. Defaults come from `locale`; pass `labels` to change some. */\nexport interface AutocompleteLabels {\n /** Placeholder of the text box while nothing is chosen. */\n placeholder: string;\n /** aria-label of the clear (×) button. */\n clear: string;\n /** aria-label of the chevron button while the list is closed. */\n open: string;\n /** aria-label of the chevron button while the list is open. */\n close: string;\n /** What a screen reader hears while `loading` (the list itself shows only a spinner). */\n loading: string;\n /** The row shown when no option is left to show. */\n empty: string;\n /** What a screen reader hears when the list changes size. */\n results: (count: number) => string;\n}\n\nconst TEXT: Record<'pt-BR' | 'en', AutocompleteLabels> = {\n 'pt-BR': {\n placeholder: 'Buscar…',\n clear: 'Limpar seleção',\n open: 'Abrir lista',\n close: 'Fechar lista',\n loading: 'Carregando…',\n empty: 'Nenhum resultado',\n results: (n) => (n === 1 ? '1 resultado' : n + ' resultados'),\n },\n en: {\n placeholder: 'Search…',\n clear: 'Clear selection',\n open: 'Open list',\n close: 'Close list',\n loading: 'Loading…',\n empty: 'No results',\n results: (n) => (n === 1 ? '1 result' : n + ' results'),\n },\n};\n\n/**\n * Single choice from a list you search by typing. Like `Select`, but the box is a text field: type\n * to narrow the list, pick one row, and the value is that row. For a list too long to scroll\n * (past ~12 options), or one the server searches and pages (a thousand clients, fifty at a time).\n *\n * The value is the chosen option itself, `{ value, label }`, and it carries its own label. The\n * box shows `value.label` whether or not that option is in `options` right now, which is what\n * keeps the label when the page it came from is no longer loaded. `options` is only what the list\n * shows. `onValueChange` gives the option (or `null` when cleared), not a string.\n *\n * Two kinds of search, one prop apart:\n * - the default filters `options` itself, as you type (case and accents ignored);\n * - `filter={false}` leaves the list alone and tells you what was typed (`onSearch`, debounced),\n * for a list the server already filtered.\n *\n * It is a text box, not free text: what is typed never becomes the value. Leaving the box puts the\n * chosen label back.\n */\nexport interface AutocompleteProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n /** What the list shows now. Appending rows while it is open is fine: the list keeps its scroll. */\n options?: AutocompleteOption[];\n /** Controlled value: the chosen option, or `null` for none. */\n value?: AutocompleteOption | null;\n /** Uncontrolled initial value. */\n defaultValue?: AutocompleteOption | null;\n /** The chosen option, or `null` when the value is cleared. */\n onValueChange?: (option: AutocompleteOption | null) => void;\n /**\n * How typing narrows `options`. `true` (default): keep the rows whose label contains the text,\n * ignoring case and accents. `false`: show `options` as they are (the server did the filtering).\n * A function decides per row.\n */\n filter?: boolean | ((option: AutocompleteOption, query: string) => boolean);\n /**\n * The text to search for changed: fired as the user types (after `debounce`) and with `''` once\n * the box goes back to showing the chosen label (pick, clear, leave, Esc). Never with the label\n * itself, so it is safe to run the query here. Use it with `filter={false}`.\n */\n onSearch?: (query: string) => void;\n /** Debounce for `onSearch` while typing, in ms. */\n debounce?: number;\n /** The list is waiting for rows: a spinner under them (or alone), the list marked busy, and a screen reader told. */\n loading?: boolean;\n /**\n * The list was scrolled to within about five rows of its end. Fires once per list size, never\n * while `loading`. Pass it only while there is a next page, so a list that is complete asks for nothing.\n */\n onReachEnd?: () => void;\n /** The list opened or closed. For a list that loads when it opens. */\n onOpenChange?: (open: boolean) => void;\n /** A × button, and an emptied box clears the value. */\n clearable?: boolean;\n /** Shown in muted text while nothing is chosen. Defaults to the `locale` text. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Form field name - mirrored to a hidden input so the chosen value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the text box. Only needed when there's no visible `label`. Takes\n * precedence over `label` if both are set - don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set - stops the field from growing\n * the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /** Language of the built-in texts. */\n locale?: 'pt-BR' | 'en';\n /** Override any built-in text. */\n labels?: Partial<AutocompleteLabels>;\n}\n\n/** How close to the end of the list, in rows, `onReachEnd` fires. */\nconst REACH_ROWS = 5;\n\nconst MARKS = /[̀-ͯ]/g;\nconst plain = (s: string) => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\nfunction narrow(\n options: AutocompleteOption[],\n filter: AutocompleteProps['filter'],\n query: string,\n): AutocompleteOption[] {\n if (filter === false) return options;\n const q = query.trim();\n if (!q) return options;\n if (typeof filter === 'function') return options.filter((o) => filter(o, query));\n const needle = plain(q);\n return options.filter((o) => plain(o.label).includes(needle));\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the chosen value (rendered only\n * when `name` is set - pass it, as `register()` does), the same as `Select`. A plain\n * `{...register(name)}` spread still won't validate on change: wire it through `Controller`, or\n * call the registered `onChange` yourself from `onValueChange`.\n */\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>(function Autocomplete(\n {\n label,\n hint,\n error,\n required,\n options = [],\n value: valueProp,\n defaultValue,\n onValueChange,\n filter = true,\n onSearch,\n debounce = 250,\n loading = false,\n onReachEnd,\n onOpenChange,\n clearable = true,\n placeholder,\n size = 'md',\n disabled,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n locale = 'pt-BR',\n labels,\n },\n ref,\n) {\n const reactId = React.useId();\n const rid = id || reactId;\n const listboxId = `${rid}-listbox`;\n const copy: AutocompleteLabels = { ...TEXT[locale], ...labels };\n const coarse = useCoarsePointer();\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const panelRef = React.useRef<HTMLDivElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n\n // ── value: the chosen option, with its own label ──\n const isControlled = valueProp !== undefined;\n const [inner, setInner] = React.useState<AutocompleteOption | null>(defaultValue ?? null);\n const value = isControlled ? valueProp : inner;\n const valueLabel = value?.label ?? '';\n\n // ── the text box: the chosen label, until the user types (`draft`) ──\n const [draft, setDraft] = React.useState<string | null>(null);\n const text = draft ?? valueLabel;\n const query = draft ?? '';\n\n const [open, setOpen] = React.useState(false);\n const [focused, setFocused] = React.useState(false);\n const [activeKey, setActiveKey] = React.useState<string | null>(null);\n // The active row is the chosen one only because the list opened on it, not because the user went\n // there: set by opening, cleared by the first thing the user does to the highlight.\n const activeFromOpen = React.useRef(false);\n const pick = (key: string | null) => {\n activeFromOpen.current = false;\n setActiveKey(key);\n };\n\n const visible = React.useMemo(() => narrow(options, filter, query), [options, filter, query]);\n const activeIndex = activeKey === null ? -1 : visible.findIndex((o) => o.value === activeKey && !o.disabled);\n const activeId = activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null;\n\n const rows = visible.length;\n const status = loading ? copy.loading : rows === 0 ? copy.empty : null;\n\n // ── open / close, told to the app once per change ──\n const onOpenChangeRef = useLatest(onOpenChange);\n const toldOpen = React.useRef(false);\n React.useEffect(() => {\n if (toldOpen.current === open) return;\n toldOpen.current = open;\n onOpenChangeRef.current?.(open);\n }, [open, onOpenChangeRef]);\n\n // ── search: told to the app when the query changes, debounced while typing ──\n const onSearchRef = useLatest(onSearch);\n const searchTimer = React.useRef<number | undefined>(undefined);\n const toldQuery = React.useRef('');\n React.useEffect(() => () => window.clearTimeout(searchTimer.current), []);\n const search = (q: string, immediate: boolean) => {\n window.clearTimeout(searchTimer.current);\n const run = () => {\n if (q === toldQuery.current) return;\n toldQuery.current = q;\n onSearchRef.current?.(q);\n };\n if (immediate) run();\n else searchTimer.current = window.setTimeout(run, debounce);\n };\n\n /** The box goes back to the chosen label: closes the list, drops what was typed, resets the query. */\n const settle = () => {\n setOpen(false);\n setDraft(null);\n search('', true);\n };\n\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef,\n itemCount: rows + (status ? 1 : 0),\n onDismiss: () => settle(),\n });\n // The chosen row can arrive after the list opened (a list that loads when it opens, on the page around\n // the chosen row). It is brought into view then, unless the user has already scrolled the list away\n // from the top: a user paging down for the next page is not carried off to a row that just landed.\n useRevealActive(open, activeId, place, revealInList, (el) => !activeFromOpen.current || (el.parentElement?.scrollTop ?? 0) === 0);\n\n // ── pagination: ask for more once the list is near its end ──\n const onReachEndRef = useLatest(onReachEnd);\n const askedFor = React.useRef<string | null>(null);\n // What the list is, for \"once per size\": a new search that happens to return as many rows is a new list.\n const shape = options.length + '|' + (options[0]?.value ?? '') + '|' + (options[options.length - 1]?.value ?? '');\n useIsoLayoutEffect(() => {\n if (!open) {\n askedFor.current = null;\n return;\n }\n const list = listRef.current;\n if (!list || rows === 0) return;\n const check = () => {\n if (loading || !onReachEndRef.current || askedFor.current === shape) return;\n const remaining = list.scrollHeight - list.scrollTop - list.clientHeight;\n if (remaining > (list.scrollHeight / rows) * REACH_ROWS) return;\n askedFor.current = shape;\n onReachEndRef.current();\n };\n check();\n list.addEventListener('scroll', check, { passive: true });\n return () => list.removeEventListener('scroll', check);\n }, [open, loading, shape, place, rows, onReachEndRef]);\n\n // A new search starts at the top.\n const firstValue = options[0]?.value;\n useIsoLayoutEffect(() => {\n if (draft !== null && listRef.current) listRef.current.scrollTop = 0;\n }, [draft, firstValue]);\n\n // iOS keeps the keyboard (and the field) up when you tap on plain page: close on any press outside.\n const settleRef = useLatest(settle);\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n const target = e.target as Node;\n if (boxRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n settleRef.current();\n };\n document.addEventListener('pointerdown', onDown, true);\n return () => document.removeEventListener('pointerdown', onDown, true);\n }, [open, settleRef]);\n\n // ── choosing ──\n const firstEnabledKey = () => visible.find((o) => !o.disabled)?.value ?? null;\n const lastEnabledKey = () => {\n for (let i = rows - 1; i >= 0; i--) if (!visible[i].disabled) return visible[i].value;\n return null;\n };\n const move = (dir: 1 | -1) => {\n let i = activeIndex < 0 ? (dir === 1 ? -1 : rows) : activeIndex;\n for (let step = 0; step < rows; step++) {\n i += dir;\n if (i < 0 || i >= rows) return; // the ends are walls, not a loop: a paged list has no \"wrap\"\n if (!visible[i].disabled) {\n pick(visible[i].value);\n return;\n }\n }\n };\n\n const choose = (o: AutocompleteOption) => {\n if (o.disabled) return;\n if (!isControlled) setInner(o);\n onValueChange?.(o);\n setOpen(false);\n setDraft(null);\n search('', true);\n // On a phone the keyboard goes with the choice.\n if (coarse) inputRef.current?.blur();\n };\n const clear = () => {\n if (value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n setDraft(''); // empty at once, even if the app takes a moment to take the value away\n search('', true);\n inputRef.current?.focus();\n };\n\n const selectedKey = value?.value;\n // Opening starts on the chosen row. If it is not in the list *yet* because the list is empty (it\n // loads when it opens), it stays the active one so it is revealed when it arrives. With rows on screen\n // that do not include it, it is not chased: the list is not moved under the user later.\n const startKey = (fallback: string | null) =>\n selectedKey !== undefined && (rows === 0 || visible.some((o) => o.value === selectedKey)) ? selectedKey : fallback;\n const openFromPointer = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(null));\n setOpen(true);\n };\n const openFromKey = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(firstEnabledKey()));\n setOpen(true);\n };\n\n const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const next = e.currentTarget.value;\n setDraft(next);\n // Filtering here, the first match is ready for Enter. A server search has not answered yet:\n // an Enter now would pick a row of the old answer, so nothing is active until the user moves.\n pick(filter === false ? null : narrow(options, filter, next).find((o) => !o.disabled)?.value ?? null);\n setOpen(true);\n if (next === '' && clearable && value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n search(next, false);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.nativeEvent.isComposing) return; // an IME is still composing the text\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) openFromKey();\n else move(1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) openFromKey();\n else move(-1);\n return;\n case 'Home':\n case 'End':\n if (open) {\n e.preventDefault();\n pick(e.key === 'Home' ? firstEnabledKey() : lastEnabledKey());\n }\n return;\n case 'Enter':\n // Closed: let the form have its Enter. Open: it is for the list, never a submit.\n if (open) {\n e.preventDefault();\n if (activeIndex >= 0) choose(visible[activeIndex]);\n }\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n settle();\n }\n return;\n default:\n }\n };\n\n // Select the text on the way in, so typing replaces the label instead of appending to it. The click\n // that gave the focus would put the caret back, hence the second select.\n const selectOnClick = React.useRef(false);\n\n const fieldAria = fieldA11y(rid, { hint, error, required });\n const rowPadY = menuRowPadY(coarse, size);\n const fontSize = size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)';\n const showClear = clearable && !disabled && text !== '';\n\n const list = (\n <div\n ref={panelRef}\n // Keeps the focus in the text box: pressing the list (or its scrollbar) must not blur it.\n onMouseDown={(e) => e.preventDefault()}\n style={sx({\n ...menuSurfaceStyle(size),\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n maxHeight: place?.maxH,\n ...(place?.strategy === 'fixed'\n ? {\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n zIndex: 1100,\n }\n : {\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place?.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n zIndex: 100,\n }),\n })}\n >\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel ?? label}\n aria-busy={loading || undefined}\n tabIndex={-1}\n style={sx({\n ...menuListStyle,\n position: 'relative', // so an option's offsetTop is measured from the list\n flex: '1 1 auto',\n minHeight: 0,\n padding: rows ? 'var(--space-1)' : 0,\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {visible.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === selectedKey}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n // Pointer *move*, not enter: a list that scrolls under a still mouse (the keyboard\n // revealing a row) must not hand the highlight to whatever slid beneath it.\n onPointerMove={() => !o.disabled && pick(o.value)}\n onClick={() => choose(o)}\n />\n ))}\n </ul>\n {status && (\n // Loading is a lone spinner, no text and no rule above it: a screen reader gets the words from the\n // live region below, and this is for the eye. \"No results\" is the same row with words.\n <div\n aria-hidden=\"true\"\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: coarse ? 44 : undefined,\n padding: 'var(--space-3)',\n color: 'var(--text-muted)',\n fontSize: coarse ? 'var(--text-base)' : 'var(--text-sm)',\n })}\n >\n {loading ? (\n <span\n style={sx({\n flex: '0 0 auto',\n width: 18,\n height: 18,\n borderRadius: '999px',\n border: '2px solid var(--border-default)',\n borderTopColor: 'var(--text-brand)',\n animation: 'sereno-spin .7s linear infinite',\n })}\n />\n ) : (\n status\n )}\n </div>\n )}\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div style={sx({ position: 'relative', width: '100%' })}>\n <div\n ref={boxRef}\n // The padding around the text is part of the field: pressing it puts the caret in the box.\n onMouseDown={(e) => {\n if (e.target === inputRef.current || disabled) return;\n e.preventDefault();\n inputRef.current?.focus();\n }}\n style={sx({ ...fieldBoxStyle(size, !!error, focused || open, !!disabled), cursor: disabled ? 'not-allowed' : 'text' })}\n >\n <input\n ref={inputRef}\n id={rid}\n type=\"text\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeId ? activeId : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n // A text box that looks like a name or an address draws the browser's autofill and the\n // password managers. Best effort: Chrome ignores `autoComplete=\"off\"`, and Bitwarden only\n // honors its attribute when the user turned that option on.\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n enterKeyHint=\"done\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-bwignore=\"true\"\n data-form-type=\"other\"\n disabled={disabled}\n placeholder={placeholder ?? copy.placeholder}\n value={text}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onFocus={(e) => {\n setFocused(true);\n selectOnClick.current = true;\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n setFocused(false);\n if (boxRef.current?.contains(e.relatedTarget as Node | null)) return;\n settle();\n }}\n onClick={(e) => {\n const el = e.currentTarget;\n if (selectOnClick.current && el.selectionStart === el.selectionEnd) el.select();\n selectOnClick.current = false;\n if (!open) openFromPointer();\n }}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding - the box's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize,\n lineHeight: 1.2,\n textOverflow: 'ellipsis',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n })}\n />\n {showClear && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n aria-label={copy.clear}\n onMouseDown={(e) => e.preventDefault()}\n onClick={clear}\n >\n <X size={16} strokeWidth={2} />\n </button>\n )}\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={open ? copy.close : copy.open}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n inputRef.current?.focus({ preventScroll: true });\n if (open) settle();\n else openFromPointer();\n }}\n style={sx({\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </button>\n </div>\n\n {open && place && place.strategy === 'inline' && list}\n {open && place && place.strategy === 'fixed' && createPortal(list, document.body)}\n\n {/* Always rendered, so the change of its text is what a screen reader announces. */}\n <div role=\"status\" aria-live=\"polite\" style={srOnlyStyle}>\n {open ? (loading ? copy.loading : rows === 0 ? copy.empty : copy.results(rows)) : ''}\n </div>\n </div>\n {name && <input ref={ref} type=\"hidden\" name={name} value={value?.value ?? ''} />}\n </Field>\n );\n});\n\nAutocomplete.displayName = 'Autocomplete';\n"],"mappings":";AA2bI,SA6CM,KA7CN;AAzbJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa,SAAS;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,cAAc,uBAAuB;AAC9C,SAAS,YAAY,eAAe,aAAa,wBAAwB;A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