@antadesign/anta 0.3.33 → 0.3.35
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/LICENSE.md +14 -1
- package/README.md +9 -0
- package/dist/anta_helpers.d.ts +46 -30
- package/dist/anta_helpers.js +66 -25
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -1353
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- package/dist/components/Breadcrumbs.d.ts +0 -1
- package/dist/components/Breadcrumbs.js +0 -1
- package/dist/components/Button.d.ts +2 -3
- package/dist/components/Button.js +1 -0
- package/dist/components/ButtonCopy.js +3 -2
- package/dist/components/Calendar.js +13 -13
- package/dist/components/Card.d.ts +9 -17
- package/dist/components/Card.js +50 -46
- package/dist/components/Dialog.d.ts +1 -0
- package/dist/components/Dialog.js +16 -10
- package/dist/components/Expander.d.ts +6 -21
- package/dist/components/Expander.js +24 -23
- package/dist/components/Icon.d.ts +8 -14
- package/dist/components/Input.d.ts +77 -96
- package/dist/components/Input.js +23 -27
- package/dist/components/InputAutocomplete.d.ts +29 -10
- package/dist/components/InputAutocomplete.js +25 -8
- package/dist/components/InputDate.d.ts +0 -1
- package/dist/components/InputDate.js +2 -3
- package/dist/components/InputTime.d.ts +10 -4
- package/dist/components/InputTime.js +20 -16
- package/dist/components/Loader.d.ts +2 -2
- package/dist/components/Menu.d.ts +5 -4
- package/dist/components/Menu.js +13 -8
- package/dist/components/MenuItem.js +1 -14
- package/dist/components/MenuItemCopy.js +2 -2
- package/dist/components/Panel.d.ts +3 -1
- package/dist/components/Panel.js +17 -11
- package/dist/components/Progress.d.ts +21 -23
- package/dist/components/Progress.js +13 -9
- package/dist/components/RadioGroup.js +6 -8
- package/dist/components/{select-parts.css → Select.css} +1 -1
- package/dist/components/Select.d.ts +53 -36
- package/dist/components/Select.js +53 -98
- package/dist/components/SelectFaceted.d.ts +7 -4
- package/dist/components/SelectFaceted.js +21 -10
- package/dist/components/Slider.d.ts +28 -11
- package/dist/components/Slider.js +20 -20
- package/dist/components/Steps.css +1 -1
- package/dist/components/Steps.d.ts +0 -1
- package/dist/components/Steps.js +1 -12
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +7 -9
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +19 -27
- package/dist/components/Title.js +2 -1
- package/dist/components/Toaster.js +9 -2
- package/dist/components/Tooltip.d.ts +10 -15
- package/dist/components/copy-props.d.ts +14 -3
- package/dist/components/copy-props.js +14 -3
- package/dist/components/select-tree.d.ts +24 -0
- package/dist/components/select-tree.js +35 -0
- package/dist/element-base.d.ts +10 -0
- package/dist/element-base.js +15 -0
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-avatar.js +2 -28
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.d.ts +4 -1
- package/dist/elements/a-banner.js +22 -112
- package/dist/elements/a-breadcrumbs.d.ts +1 -0
- package/dist/elements/a-breadcrumbs.js +1 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-button.d.ts +10 -7
- package/dist/elements/a-button.js +18 -1
- package/dist/elements/a-calendar.d.ts +14 -13
- package/dist/elements/a-calendar.js +29 -24
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-card.d.ts +0 -9
- package/dist/elements/a-card.js +0 -184
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-copy.d.ts +1 -5
- package/dist/elements/a-copy.js +129 -108
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-dialog.d.ts +1 -1
- package/dist/elements/a-dialog.js +68 -194
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +4 -30
- package/dist/elements/a-expander.js +85 -344
- package/dist/elements/a-icon.d.ts +5 -23
- package/dist/elements/a-icon.js +1 -2
- package/dist/elements/a-input-date.d.ts +1 -0
- package/dist/elements/a-input-date.js +1 -0
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +2 -1
- package/dist/elements/a-input-time.js +101 -168
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +10 -8
- package/dist/elements/a-input.js +155 -230
- package/dist/elements/a-loader.d.ts +5 -8
- package/dist/elements/a-loader.js +1 -2
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +5 -3
- package/dist/elements/a-menu-item.js +5 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +5 -7
- package/dist/elements/a-menu.js +383 -299
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +19 -37
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-progress.d.ts +0 -22
- package/dist/elements/a-progress.js +0 -100
- package/dist/elements/a-radio-group.d.ts +1 -1
- package/dist/elements/a-radio-group.js +6 -4
- package/dist/elements/a-select-faceted.d.ts +1 -0
- package/dist/elements/a-select-faceted.js +1 -0
- package/dist/elements/a-select.d.ts +1 -0
- package/dist/elements/a-select.js +1 -0
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +11 -3
- package/dist/elements/a-slider.js +244 -242
- package/dist/elements/a-steps.d.ts +1 -0
- package/dist/elements/a-steps.js +1 -0
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabpanel.d.ts +2 -2
- package/dist/elements/a-tabpanel.js +13 -3
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -1
- package/dist/elements/a-tabs.js +6 -4
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-tag.d.ts +1 -0
- package/dist/elements/a-tag.js +1 -0
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.d.ts +6 -43
- package/dist/elements/a-text.js +110 -193
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-title.d.ts +1 -0
- package/dist/elements/a-title.js +1 -0
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toast.d.ts +10 -45
- package/dist/elements/a-toast.js +80 -66
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-toaster.js +9 -44
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -1
- package/dist/elements/a-tooltip.js +142 -136
- package/dist/elements/copy-behavior.d.ts +1 -1
- package/dist/elements/copy-behavior.js +21 -21
- package/dist/elements/index.d.ts +9 -3
- package/dist/elements/index.js +6 -6
- package/dist/elements/input-focus-modality.d.ts +15 -0
- package/dist/elements/input-focus-modality.js +44 -0
- package/dist/elements/input-trailing-actions.d.ts +5 -0
- package/dist/elements/input-trailing-actions.js +38 -0
- package/dist/elements/shadow-aria.d.ts +2 -0
- package/dist/elements/shadow-aria.js +2 -1
- package/dist/elements/value-input.d.ts +3 -0
- package/dist/elements/value-input.js +12 -0
- package/dist/general_types.d.ts +103 -96
- package/dist/index.d.ts +1 -1
- package/dist/input-events.d.ts +4 -0
- package/dist/input-events.js +15 -0
- package/dist/jsx-runtime.d.ts +70 -23
- package/dist/jsx-runtime.js +26 -19
- package/dist/native-event-props.d.ts +2 -0
- package/dist/native-event-props.js +10 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +10 -1
- package/dist/theme-antune.css +1 -1
- package/docs/accessibility.md +17 -3
- package/docs/changelog.md +384 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- package/docs/components/breadcrumbs.md +9 -6
- package/docs/components/button.md +22 -0
- package/docs/components/card.md +74 -28
- package/docs/components/checkbox.md +9 -10
- package/docs/components/dialog.md +83 -32
- package/docs/components/expander.md +198 -435
- package/docs/components/icon.md +11 -17
- package/docs/components/input-autocomplete.md +152 -52
- package/docs/components/input-date.md +175 -148
- package/docs/components/input-time.md +81 -38
- package/docs/components/input.md +343 -349
- package/docs/components/loader.md +2 -1
- package/docs/components/menu.md +35 -6
- package/docs/components/panel.md +18 -0
- package/docs/components/progress.md +83 -49
- package/docs/components/radio.md +39 -43
- package/docs/components/select-faceted.md +54 -7
- package/docs/components/select.md +390 -386
- package/docs/components/slider.md +136 -19
- package/docs/components/steps.md +6 -3
- package/docs/components/switch.md +8 -9
- package/docs/components/tabs.md +110 -104
- package/docs/components/text.md +110 -86
- package/docs/components/title.md +47 -33
- package/docs/components/toaster.md +242 -84
- package/docs/components/tooltip.md +204 -113
- package/docs/install-config.md +461 -96
- package/docs/packages/plot.md +228 -143
- package/docs/theming.md +29 -13
- package/package.json +43 -4
- package/theme-antithesis-license.md +66 -0
package/docs/components/icon.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# Icon
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
`
|
|
5
|
-
|
|
6
|
-
any custom icons you generate yourself.
|
|
3
|
+
Use Icon for standalone symbols, such as a warning beside a message. Pass a
|
|
4
|
+
`shape` from Anta's built-in set or your generated icons. Color follows the
|
|
5
|
+
surrounding text, and the default size is 16×16 pixels.
|
|
7
6
|
|
|
8
7
|
`shape="loader"` is the exception: it is Anta's animated loading alias for
|
|
9
8
|
string-only icon props. Use `Loader` when you need a progress value, speed, or
|
|
@@ -135,8 +134,9 @@ accessible loading status.
|
|
|
135
134
|
|
|
136
135
|
Use the web component directly when you are not using React or Preact and a native control does not fit.
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
Icon needs its stylesheet without JavaScript registration. Set an accessible
|
|
138
|
+
name when the icon conveys meaning, or `aria-hidden="true"` when decorative.
|
|
139
|
+
Use `--icon-size` for custom dimensions.
|
|
140
140
|
|
|
141
141
|
```html
|
|
142
142
|
<a-icon
|
|
@@ -158,22 +158,16 @@ together. Default is `16`. Color always follows `currentColor`.
|
|
|
158
158
|
<Text tone="critical"><Icon shape="warning-triangle" /></Text> {/* tinted */}
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
on the rendered `<a-icon>`. The base CSS rule reads it as
|
|
163
|
-
`width: var(--icon-size, 16px); height: var(--icon-size, 16px)`. That
|
|
164
|
-
means consumer CSS (or a parent's variable cascade) can drive icon
|
|
165
|
-
size too — useful for sizing whole regions of UI at once:
|
|
161
|
+
Set `--icon-size` on a container to size its icons together:
|
|
166
162
|
|
|
167
163
|
```css
|
|
168
164
|
.toolbar { --icon-size: 18px; }
|
|
169
165
|
```
|
|
170
166
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
> and the icon falls back to the 16px default. Prefer `<Icon size>` for
|
|
176
|
-
> exact custom sizes.
|
|
167
|
+
For a raw `<a-icon>`, use `--icon-size` for custom dimensions. Its `size`
|
|
168
|
+
attribute requires typed CSS `attr()` support. See
|
|
169
|
+
[Content Security Policy](../install-config.md#content-security-policy) when your policy
|
|
170
|
+
blocks inline styles from custom size props.
|
|
177
171
|
|
|
178
172
|
## The `blank` spacer
|
|
179
173
|
|
|
@@ -1,47 +1,135 @@
|
|
|
1
1
|
# InputAutocomplete
|
|
2
2
|
|
|
3
|
-
`InputAutocomplete`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value
|
|
3
|
+
`InputAutocomplete` offers suggestions while people enter text. Use it for
|
|
4
|
+
package names, search queries, or other fields where common entries help but
|
|
5
|
+
people can also enter their own value. Choosing a suggestion fills the field
|
|
6
|
+
with its value. Use [Select](./select.md) when an option's identity is the value.
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
after someone chooses a suggestion. Use `value` to control it, or `defaultValue`
|
|
11
|
-
for uncontrolled use.
|
|
8
|
+
Give the field a visible `label`. If you omit it, provide `aria-label` or
|
|
9
|
+
`aria-labelledby`. A placeholder alone does not name the field.
|
|
12
10
|
|
|
13
11
|
## Free text is the point
|
|
14
12
|
|
|
15
|
-
The
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
the list only *suggests* and the user may commit something you didn't list.
|
|
13
|
+
The field keeps whatever someone types, including text absent from the list.
|
|
14
|
+
`onValueChange` reports that text as it changes. Use `onSelect` when the
|
|
15
|
+
application also needs to know that someone chose a suggestion.
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
```tsx
|
|
18
|
+
const frameworks = ['React', 'Preact', 'Solid', 'Svelte', 'Vue', 'Angular', 'Qwik', 'Lit', 'Astro']
|
|
19
|
+
const [value, setValue] = useState('')
|
|
20
|
+
|
|
21
|
+
<InputAutocomplete
|
|
22
|
+
label="Framework"
|
|
23
|
+
placeholder="Type to search…"
|
|
24
|
+
clearable
|
|
25
|
+
suggestions={frameworks}
|
|
26
|
+
value={value}
|
|
27
|
+
onValueChange={setValue}
|
|
28
|
+
/>
|
|
29
|
+
<div>Value: <code>{value || '(empty)'}</code></div>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Suggestions
|
|
33
|
+
|
|
34
|
+
Use strings for a simple list, or option objects to show a readable `label`, a
|
|
35
|
+
supporting `hint`, or an `icon`. Choosing a row fills the field with its `value`,
|
|
36
|
+
so the **Anta** suggestion here fills in `@antadesign/anta`. Disabled suggestions
|
|
37
|
+
remain visible and are skipped during keyboard navigation.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<InputAutocomplete
|
|
41
|
+
label="Package"
|
|
42
|
+
hint="Choose a package name or enter another."
|
|
43
|
+
suggestions={[
|
|
44
|
+
{ value: '@antadesign/anta', label: 'Anta', hint: 'UI components', icon: 'cube' },
|
|
45
|
+
{ value: '@antadesign/plot', label: 'Plot', hint: 'Canvas charts', icon: 'workflow' },
|
|
46
|
+
{ value: '@antadesign/stickers', label: 'Stickers', hint: 'Illustrations', icon: 'asterisk' },
|
|
47
|
+
{ value: '@antadesign/archived', label: 'Archived', hint: 'Unavailable', disabled: true },
|
|
48
|
+
]}
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Managing the value
|
|
25
53
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
54
|
+
Pass `value` and update it through `onValueChange` when another part of your
|
|
55
|
+
application needs the text. Reset controlled text with `''`. For a field that
|
|
56
|
+
keeps its own text, use `defaultValue`; a form reset restores that default without
|
|
57
|
+
opening an unfocused field's suggestions or moving focus.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
const [value, setValue] = useState('React')
|
|
61
|
+
|
|
62
|
+
<InputAutocomplete label="Framework" suggestions={frameworks}
|
|
63
|
+
value={value} onValueChange={setValue} clearable />
|
|
64
|
+
<Button label="Reset text" onClick={() => setValue('')} />
|
|
65
|
+
```
|
|
31
66
|
|
|
32
67
|
## Filtering
|
|
33
68
|
|
|
34
|
-
|
|
69
|
+
The built-in filter matches the value, label, and hint without case sensitivity,
|
|
70
|
+
and highlights matching label and hint text. Use a function when your
|
|
71
|
+
application needs a different rule, such as matching word prefixes. It receives
|
|
72
|
+
the original field text, including whitespace; decide whether to trim it in
|
|
73
|
+
your matcher.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<InputAutocomplete
|
|
77
|
+
label="Framework prefix"
|
|
78
|
+
suggestions={frameworks}
|
|
79
|
+
filter={(option, query) => option.value.toLowerCase().startsWith(query.trim().toLowerCase())}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Application-provided results
|
|
84
|
+
|
|
85
|
+
Pass `filter={false}` when your application already selects or ranks the
|
|
86
|
+
suggestions. This preserves their order and skips local highlighting. The
|
|
87
|
+
example supplies matching projects in reverse order; fetched results use the
|
|
88
|
+
same pattern.
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
const projects = ['Billing service', 'Billing dashboard', 'Build tools', 'Customer portal']
|
|
92
|
+
const [value, setValue] = useState('')
|
|
93
|
+
const results = projects.filter(name => name.toLowerCase().includes(value.toLowerCase())).reverse()
|
|
94
|
+
|
|
95
|
+
<InputAutocomplete
|
|
96
|
+
label="Project"
|
|
97
|
+
hint="Results use the application's order. You can also enter a new project."
|
|
98
|
+
suggestions={results}
|
|
99
|
+
filter={false}
|
|
100
|
+
value={value}
|
|
101
|
+
onValueChange={setValue}
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Replace `suggestions` as results arrive. New results update an open list; they
|
|
106
|
+
do not reopen it after Escape or focus loss. Your application owns loading,
|
|
107
|
+
request cancellation, and discarding responses for older queries.
|
|
108
|
+
|
|
109
|
+
## Keyboard interaction
|
|
110
|
+
|
|
111
|
+
Typing leaves every suggestion inactive, so Enter keeps the typed text and
|
|
112
|
+
closes the list. Arrow Down highlights the first enabled suggestion; Arrow Up
|
|
113
|
+
and Arrow Down move through the list. Enter on an active suggestion fills the
|
|
114
|
+
field. Editing again clears that active suggestion. Input-method composition
|
|
115
|
+
keeps its own candidate navigation and confirmation keys.
|
|
35
116
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`suggestions`.
|
|
117
|
+
Escape closes the list and keeps focus in the field. Tab closes it and moves
|
|
118
|
+
to the next control. Selecting a suggestion or clicking the list's padding keeps
|
|
119
|
+
focus in the field. Clicking within an open field leaves the list open while
|
|
120
|
+
placing the caret. The field exposes combobox semantics, the popup is a listbox,
|
|
121
|
+
and the active suggestion is associated directly with the focused input.
|
|
42
122
|
|
|
43
|
-
|
|
44
|
-
|
|
123
|
+
## Events
|
|
124
|
+
|
|
125
|
+
Use `onValueChange` for application text state. `onInput`, `onFocus`, `onBlur`,
|
|
126
|
+
and `onKeyDown` also receive their field events. An input event reports an edit
|
|
127
|
+
that already happened; `preventDefault()` does not reject the text.
|
|
128
|
+
|
|
129
|
+
A consumer `onKeyDown` can prevent the wrapper's plain-Enter dismissal.
|
|
130
|
+
Menu handles active suggestions and navigation earlier in document capture.
|
|
131
|
+
Those actions cannot be canceled from the field callback, and Escape is
|
|
132
|
+
consumed before it reaches the field. See the callback reference for ordering.
|
|
45
133
|
|
|
46
134
|
## Component props
|
|
47
135
|
|
|
@@ -49,41 +137,43 @@ Suggestions are bare strings or `SelectOption`s, the same option shape
|
|
|
49
137
|
|------|------|---------|-------------|
|
|
50
138
|
| `suggestions` | string \| SelectOption[] | — | The suggestions: bare strings or `SelectOption`s (`value` / `label` / `hint` / `icon` / `tone` / `disabled`). A flat list; picking one fills the field. |
|
|
51
139
|
| `clearable?` | boolean | — | Show a clear button while the field has text. |
|
|
52
|
-
| `defaultValue?` | string | — | Initial value
|
|
140
|
+
| `defaultValue?` | string | — | Initial uncontrolled text and the value restored by a form reset. Resetting an unfocused field does not open suggestions or move focus. |
|
|
53
141
|
| `disabled?` | boolean | — | Disable the field. |
|
|
54
|
-
| `filter?` | boolean \| (option, query) => boolean | true | How suggestions match the text. `true` uses the built-in case-insensitive substring match on `value` / `label` / `hint`; a function `(option, query) => boolean`
|
|
142
|
+
| `filter?` | boolean \| (option, query) => boolean | true | How suggestions match the text. `true` uses the built-in case-insensitive substring match on `value` / `label` / `hint`; a function `(option, query) => boolean` receives the original field text, including whitespace, once per option on each render, including when empty. Custom matching has no automatic highlighting. `false` shows `suggestions` unchanged for application-provided async or remote filtering, without automatic highlighting. Replacing results updates an open list but does not reopen a dismissed list. |
|
|
55
143
|
| `hint?` | ReactNode | — | Hint under the field. |
|
|
56
144
|
| `label?` | ReactNode | — | Field label. |
|
|
57
145
|
| `leading?` | ReactNode | — | Leading adornment inside the field. |
|
|
58
146
|
| `name?` | string | — | Form field name. |
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
147
|
+
| `onBlur?` | (event) => void | — | Observe focus loss. The suggestion list closes without changing the text. |
|
|
148
|
+
| `onFocus?` | (event) => void | — | Observe focus before the suggestion list opens. |
|
|
149
|
+
| `onInput?` | (event) => void | — | Observe editing before `onValueChange`. The input event reports text that has already changed; `preventDefault()` does not reject that text. |
|
|
150
|
+
| `onKeyDown?` | (event) => void | — | Observe keys before the wrapper's plain-Enter dismissal. `preventDefault()` keeps that dismissal from running. Menu handles navigation and active-option activation earlier, in document capture; this callback cannot veto those actions. Composing keys remain with the input method. |
|
|
151
|
+
| `onSelect?` | (option) => void | — | Fires after `onValueChange` when a suggestion is chosen, with the normalized option. This reports the choice even if a controlled parent rejects the value. Typing and clearing do not call it. |
|
|
152
|
+
| `onValueChange?` | (value) => void | — | Reports text changes from typing, picking a suggestion, clearing, or form reset. |
|
|
61
153
|
| `placeholder?` | string | — | Placeholder text. |
|
|
62
154
|
| `size?` | 'small' \| 'medium' \| 'large' | medium | Field size. |
|
|
63
155
|
| `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | — | Validation status. |
|
|
64
156
|
| `statusIcon?` | (string & {}) \| false \| IconShape | — | Status icon override, or `false` to drop it. |
|
|
65
157
|
| `tone?` | string | — | Custom accent color — a named tone or any CSS color. |
|
|
66
158
|
| `trailing?` | ReactNode | — | Trailing adornment inside the field. |
|
|
67
|
-
| `value?` | string | — |
|
|
159
|
+
| `value?` | string | — | The controlled field text. Any string is valid, including `''` for an empty field. Omit or pass `undefined` for uncontrolled use. Parent updates do not call `onValueChange`. Releasing control retains the latest controlled text. |
|
|
68
160
|
|
|
69
161
|
## Web Component
|
|
70
162
|
|
|
71
|
-
`InputAutocomplete`
|
|
72
|
-
|
|
73
|
-
|
|
163
|
+
`InputAutocomplete` composes [Input](./input.md) and [Menu](./menu.md). It has no
|
|
164
|
+
`a-input-autocomplete` element or registration entry. Raw authors own the text,
|
|
165
|
+
filtering, popup state, and equivalent ARIA declarations. See
|
|
166
|
+
[Install and configure](../install-config.md) for imports, renderer setup, and CSP guidance.
|
|
74
167
|
|
|
75
168
|
### Native HTML input with autocomplete
|
|
76
169
|
|
|
77
|
-
For browser-native suggestions, pair a native input with a
|
|
78
|
-
keeps free-form entry
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
The browser renders the suggestions popup. Use `InputAutocomplete` for custom
|
|
82
|
-
option content, popup styling, or consistent behavior across browsers.
|
|
170
|
+
For browser-native suggestions, pair a native input with a `datalist`. The
|
|
171
|
+
browser supplies the popup and keeps free-form entry. Use InputAutocomplete
|
|
172
|
+
when you need Anta's suggestion rows and popup styling.
|
|
83
173
|
|
|
84
174
|
```html
|
|
85
|
-
<
|
|
86
|
-
|
|
175
|
+
<label for="autocomplete-people">Person</label>
|
|
176
|
+
<input id="autocomplete-people" data-anta type="text" list="people" placeholder="Search people">
|
|
87
177
|
<datalist id="people">
|
|
88
178
|
<option value="Maya Chen">
|
|
89
179
|
<option value="Noah Williams">
|
|
@@ -94,11 +184,21 @@ option content, popup styling, or consistent behavior across browsers.
|
|
|
94
184
|
|
|
95
185
|
## Styling
|
|
96
186
|
|
|
97
|
-
|
|
98
|
-
`
|
|
99
|
-
|
|
187
|
+
Use Input's `size`, `status`, `tone`, and adornment props to configure the field.
|
|
188
|
+
`className` and `style` apply to its `a-input`. Target Input's parts for field
|
|
189
|
+
styles and the adjacent Menu's `::part(menu)` for the suggestion popup. Option
|
|
190
|
+
objects accept `className`, `style`, and application data attributes on their
|
|
191
|
+
rows.
|
|
192
|
+
|
|
193
|
+
The `package-field` class below belongs to this example. Replace it with your
|
|
194
|
+
own selector.
|
|
100
195
|
|
|
101
196
|
```tsx
|
|
102
|
-
|
|
103
|
-
|
|
197
|
+
<InputAutocomplete className="package-field" label="Package" suggestions={packages} tone="info" />
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```css
|
|
201
|
+
.package-field { width: 260px; }
|
|
202
|
+
.package-field::part(field) { border-radius: 12px; }
|
|
203
|
+
.package-field + a-menu::part(menu) { border-radius: 12px; }
|
|
104
204
|
```
|