@antadesign/anta 0.3.34 → 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 -1333
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- 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.js +2 -2
- 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 -35
- package/dist/components/Select.js +53 -97
- package/dist/components/SelectFaceted.d.ts +7 -3
- package/dist/components/SelectFaceted.js +21 -9
- 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.js +1 -11
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +5 -8
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +16 -26
- 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-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-button.d.ts +2 -1
- 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 +66 -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-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 -1
- package/dist/elements/a-select-faceted.js +1 -1
- package/dist/elements/a-select.d.ts +1 -1
- package/dist/elements/a-select.js +1 -1
- 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-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- 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-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-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 +3 -3
- package/dist/elements/index.js +3 -7
- 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 +348 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- 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 +2 -1
- 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 +183 -26
- package/docs/packages/plot.md +170 -148
- package/docs/theming.md +7 -0
- package/package.json +41 -3
- package/theme-antithesis-license.md +66 -0
|
@@ -1,9 +1,79 @@
|
|
|
1
1
|
# Slider
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
`Slider` selects a number or an interval within a numeric range. Use it for
|
|
4
|
+
settings such as volume, playback speed, or price limits when dragging helps
|
|
5
|
+
people choose a value. Use a separate numeric input when precise text entry is
|
|
6
|
+
also useful.
|
|
7
|
+
|
|
8
|
+
Give every slider a visible `label` or an accessible name. A string label supplies
|
|
9
|
+
the name; pair a rich label with `aria-label` or `aria-labelledby`.
|
|
10
|
+
|
|
11
|
+
## Managing the value
|
|
12
|
+
|
|
13
|
+
Pass `defaultValue` for an uncontrolled slider, or use `value` with
|
|
14
|
+
`onValueChange` when the application owns the number. A controlled slider changes
|
|
15
|
+
only when you update `value`. Turn off **Accept changes** in this example to see
|
|
16
|
+
requests without applying them. **Reset to 35%** changes the application value
|
|
17
|
+
without requesting another change.
|
|
18
|
+
|
|
19
|
+
```tsx title="Accept or reject a requested value"
|
|
20
|
+
import { useState } from 'preact/hooks'
|
|
21
|
+
import { Button, Checkbox, Slider } from '@antadesign/anta'
|
|
22
|
+
|
|
23
|
+
function SliderOwnershipDemo() {
|
|
24
|
+
const [value, setValue] = useState(35)
|
|
25
|
+
const [accept, setAccept] = useState(true)
|
|
26
|
+
const [requested, setRequested] = useState(35)
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<Checkbox label="Accept changes" checked={accept} onStateChange={(_, { next }) => setAccept(next === true)} />
|
|
31
|
+
<Slider
|
|
32
|
+
label="Volume"
|
|
33
|
+
value={value}
|
|
34
|
+
valueSuffix="%"
|
|
35
|
+
onValueChange={(_, { value: next }) => {
|
|
36
|
+
setRequested(next)
|
|
37
|
+
if (accept) setValue(next)
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
<Button onClick={() => setValue(35)}>Reset to 35%</Button>
|
|
41
|
+
<p>Applied: {value}%. Requested: {requested}%.</p>
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`0` is a controlled numeric value. Omitting `value` or passing `undefined` selects
|
|
48
|
+
uncontrolled use. Releasing control retains the last applied number until
|
|
49
|
+
interaction or reset changes it. A numeric slider has no empty value.
|
|
50
|
+
|
|
51
|
+
`onValueChange` reports requested values while dragging. `onValueCommit` reports
|
|
52
|
+
the final request when the gesture ends, including cancellation or capture loss,
|
|
53
|
+
and after each keyboard step. Its value can differ from the applied value when
|
|
54
|
+
the application rejects a controlled request. `onInput` runs before
|
|
55
|
+
`onValueChange`; `onChange` runs before `onValueCommit`. Cancel a keyboard or
|
|
56
|
+
pointer default in `onKeyDown` or `onPointerDown`; the value notifications are
|
|
57
|
+
noncancelable. See the prop reference for callback snapshots and reset behavior.
|
|
58
|
+
|
|
59
|
+
## Forms
|
|
60
|
+
|
|
61
|
+
Pass `name` to include the applied number in form submission. A range submits two
|
|
62
|
+
entries under the same name; read them with `FormData.getAll(name)`. Disabled
|
|
63
|
+
sliders submit nothing.
|
|
64
|
+
|
|
65
|
+
Form reset restores an uncontrolled slider's `defaultValue`. Without one, it
|
|
66
|
+
restores `min`, or `[min, max]` for a range. A changed uncontrolled reset emits
|
|
67
|
+
both value callbacks. Controlled reset retains the application's value, and
|
|
68
|
+
restoration does not overwrite a controlled value. Restoration of an uncontrolled
|
|
69
|
+
value is silent.
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
<form>
|
|
73
|
+
<Slider label="Brightness" name="brightness" defaultValue={60} valueSuffix="%" />
|
|
74
|
+
<Button type="reset">Reset brightness</Button>
|
|
75
|
+
</form>
|
|
76
|
+
```
|
|
7
77
|
|
|
8
78
|
## Relative dragging
|
|
9
79
|
|
|
@@ -17,7 +87,13 @@ dragging, as a native range input does.
|
|
|
17
87
|
Releasing the pointer or losing pointer capture ends the drag. Moving back over
|
|
18
88
|
the slider without pressing leaves its value unchanged.
|
|
19
89
|
|
|
20
|
-
|
|
90
|
+
Slider is horizontal. In inherited RTL, its minimum is at the right edge and
|
|
91
|
+
horizontal pointer and arrow movement follow that direction. Up and Down still
|
|
92
|
+
increase and decrease the value. Vertical orientation and readonly mode are not
|
|
93
|
+
part of its API. The control reserves touch gestures for dragging.
|
|
94
|
+
|
|
95
|
+
Arrow keys change by `step`. Home selects the minimum; End selects the nearest allowed
|
|
96
|
+
step to the maximum. PageUp and PageDown move by one tenth of the range.
|
|
21
97
|
|
|
22
98
|
```tsx
|
|
23
99
|
<Slider label="Relative drag" defaultValue={35} />
|
|
@@ -35,7 +111,7 @@ cross.
|
|
|
35
111
|
|
|
36
112
|
`onValueChange` receives a number for a single-value slider and an ordered
|
|
37
113
|
`[number, number]` tuple for a range slider. `onValueCommit` uses the same shape.
|
|
38
|
-
|
|
114
|
+
For an uncontrolled range without `defaultValue`, form reset selects `[min, max]`.
|
|
39
115
|
|
|
40
116
|
```tsx title="Controlled range"
|
|
41
117
|
import { useState } from 'preact/hooks'
|
|
@@ -78,15 +154,19 @@ thumb movement and keyboard controls stay the same.
|
|
|
78
154
|
`valueDisplay="end"` is the default. Use `inline` for `Label: value`, `thumb` to keep a value above the thumb, or `none` to omit it. `valuePrefix` and `valueSuffix` add text to every live value display.
|
|
79
155
|
|
|
80
156
|
```tsx
|
|
81
|
-
<Slider label="
|
|
82
|
-
<Slider label="
|
|
83
|
-
<Slider label="
|
|
157
|
+
<Slider label="End" defaultValue={48} valueSuffix="%" />
|
|
158
|
+
<Slider label="Inline" defaultValue={48} valueDisplay="inline" valueSuffix="%" />
|
|
159
|
+
<Slider label="Thumb" defaultValue={48} valueDisplay="thumb" valueSuffix="%" />
|
|
84
160
|
```
|
|
85
161
|
|
|
86
162
|
## Size, tones, and radius
|
|
87
163
|
|
|
88
164
|
`size` follows the input height scale: 24px, 28px, and 32px. `trackSize` sets the thickness of both rail segments without changing the control height; numbers use pixels and strings accept CSS lengths. `thumbSize` controls the thumb diameter, and `thumbFill` fills it with its resolved border color. `tone` colors the filled rail. `thumbTone` separately colors the thumb stroke. The unfilled rail stays neutral. `round` shapes both the rail and thumb. Pass `true` for fully round corners or a number or CSS length for a shared custom radius.
|
|
89
165
|
|
|
166
|
+
In the Antithesis theme, an omitted `thumbTone` follows the filled rail's color.
|
|
167
|
+
Other themes keep the thumb neutral. Pass `thumbTone="neutral"` to keep a neutral
|
|
168
|
+
thumb in every theme. The native range uses the same rule for `thumb-tone`.
|
|
169
|
+
|
|
90
170
|
```tsx
|
|
91
171
|
<Slider size="small" tone="info" label="Small" defaultValue={32} />
|
|
92
172
|
<Slider tone="brand" thumbTone="success" trackSize={4} thumbSize={20} thumbFill label="Medium, filled thumb" defaultValue={52} />
|
|
@@ -104,6 +184,7 @@ thumb movement and keyboard controls stay the same.
|
|
|
104
184
|
max={2}
|
|
105
185
|
step={0.25}
|
|
106
186
|
defaultValue={1}
|
|
187
|
+
valueSuffix="×"
|
|
107
188
|
markers={[
|
|
108
189
|
{ value: 0.5, label: '0.5×' },
|
|
109
190
|
{ value: 1, label: 'Normal' },
|
|
@@ -116,33 +197,47 @@ thumb movement and keyboard controls stay the same.
|
|
|
116
197
|
|
|
117
198
|
| Prop | Type | Default | Description |
|
|
118
199
|
|------|------|---------|-------------|
|
|
119
|
-
| `defaultValue?` | number \| SliderRangeValue |
|
|
200
|
+
| `defaultValue?` | number \| SliderRangeValue | min | Initial uncontrolled value and form-reset baseline. Changes while pristine update the value; after interaction they affect the next reset. Without a default, scalar reset uses `min` and range reset uses `[min, max]`. |
|
|
120
201
|
| `disabled?` | boolean | — | Disables pointer and keyboard interaction. |
|
|
121
202
|
| `inverted?` | boolean | — | Fill the rail outside the selected value or range. |
|
|
122
203
|
| `label?` | ReactNode | — | Visible field label, shown above the rail. A string supplies the slider's accessible name; give a rich label an explicit `aria-label`. |
|
|
123
204
|
| `markers?` | SliderMarker[] | — | Compact text labels positioned below the rail. They do not add dots or ticks to the rail. |
|
|
124
|
-
| `max?` | number | 100 | Highest permitted value. |
|
|
125
|
-
| `min?` | number | 0 | Lowest permitted value. |
|
|
205
|
+
| `max?` | number | 100 | Highest permitted value. A lower bound than `min` collapses the range to `min`. Nonfinite values use 100. |
|
|
206
|
+
| `min?` | number | 0 | Lowest permitted value and step origin. Nonfinite values use 0. |
|
|
126
207
|
| `name?` | string | — | Form field name. A range submits two values under this name. |
|
|
127
|
-
| `onValueChange?` | (event, attrs) => void | — |
|
|
128
|
-
| `onValueCommit?` | (event, attrs) => void | — |
|
|
208
|
+
| `onValueChange?` | (event, attrs) => void | — | Reports each distinct requested value during a drag and each keyboard step. `onInput` runs first. The snapshot contains the requested value and effective constraints; the element's `value` remains the applied value. Controlled sliders accept by updating `value` and reject by leaving it unchanged. Events are notifications; `preventDefault()` does not veto a value request. |
|
|
209
|
+
| `onValueCommit?` | (event, attrs) => void | — | Reports the final requested value after a drag, cancellation, or capture loss, and after each keyboard step. `onChange` runs first. A drag ending at its starting value is silent. Controlled requests can commit without being accepted. Uncontrolled form reset emits both callbacks when it changes the value; state restoration and application updates are silent. |
|
|
129
210
|
| `round?` | boolean \| number \| string | — | Fully round the rail and thumb. Pass a number (px) or CSS length string for a shared custom radius. |
|
|
130
211
|
| `size?` | 'small' \| 'medium' \| 'large' | 'medium' | Size variant. small=24px, medium=28px, large=32px tall. |
|
|
131
|
-
| `step?` | number | 1 | Smallest keyboard and drag increment. |
|
|
212
|
+
| `step?` | number | 1 | Smallest keyboard and drag increment. Nonpositive and nonfinite values use 1. Page keys move by at least one step, or one tenth of the range. |
|
|
132
213
|
| `thumbFill?` | boolean | false | Fill the thumb with its resolved border color. This follows `thumbTone` and interactive states. |
|
|
133
214
|
| `thumbSize?` | number \| string | 16 | Diameter of the thumb. Numbers use pixels; strings are CSS lengths. Keep it at least as large as `trackSize`. |
|
|
134
|
-
| `thumbTone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Color of the thumb stroke. Pass a named tone or a literal CSS color for a one-off custom tone.
|
|
215
|
+
| `thumbTone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' (the Antithesis theme follows `tone`) | Color of the thumb stroke. Pass a named tone or a literal CSS color for a one-off custom tone. An explicit `neutral` keeps the thumb neutral in every theme. |
|
|
135
216
|
| `tone?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' \| (string & {}) | 'neutral' | Color of the filled rail. Pass a named tone or a literal CSS color for a one-off custom tone. The unfilled rail stays neutral. |
|
|
136
217
|
| `trackClick?` | 'drag-only' \| 'jump' | 'drag-only' | Controls what happens when the rail is pressed. `drag-only` starts dragging from the current value. `jump` first moves to the pressed position. |
|
|
137
218
|
| `trackSize?` | number \| string | 2 | Thickness of both rail segments. Numbers use pixels; strings are CSS lengths. Keep it no larger than the thumb diameter. |
|
|
138
|
-
| `value?` | number \| SliderRangeValue | — | Controlled value. A pair
|
|
219
|
+
| `value?` | number \| SliderRangeValue | — | Controlled numeric value. A pair selects a range, ordered low to high. Omit or pass `undefined` for uncontrolled use; `0` stays controlled. Runtime `null` is treated as omission; it is not a controlled empty value. Takes precedence over `defaultValue`, including on form reset. Values are clamped to the bounds and rounded to a step measured from `min`. Releasing control retains the last applied value. There is no empty numeric state. |
|
|
139
220
|
| `valueDisplay?` | 'end' \| 'inline' \| 'thumb' \| 'none' | 'end' | Where the live value appears. `end` puts it at the right edge of the label row. `inline` renders `Label: value`. `thumb` keeps it above the thumb. |
|
|
140
221
|
| `valuePrefix?` | string | — | Text inserted before the live numeric value, such as `$`. |
|
|
141
222
|
| `valueSuffix?` | string | — | Text inserted after the live numeric value, such as `%` or `°C`. |
|
|
142
223
|
|
|
143
224
|
## Web Component
|
|
144
225
|
|
|
145
|
-
Use `<a-slider>`
|
|
226
|
+
Use `<a-slider>` with `value` for a controlled value or `defaultvalue` for an
|
|
227
|
+
uncontrolled initial value. Reading the `value` property returns the applied
|
|
228
|
+
number or sorted pair. `input` and `change` events carry request snapshots in
|
|
229
|
+
`event.detail`; accept a controlled request by assigning `event.detail.value` to
|
|
230
|
+
the `value` property. Application updates are silent. See
|
|
231
|
+
[Install and configure](../install-config.md) for imports and hydration setup.
|
|
232
|
+
|
|
233
|
+
Setting the `value` property reflects the controlled `value` attribute. Removing
|
|
234
|
+
that attribute, or assigning `null` or `undefined` to the property, releases
|
|
235
|
+
control and retains the last applied number. Assigning `defaultValue` reflects
|
|
236
|
+
`defaultvalue`. Uncontrolled interaction, reset, and restoration never rewrite
|
|
237
|
+
these attributes. The applied value stays in internal state and form submission.
|
|
238
|
+
|
|
239
|
+
Add `tabindex="0"` to a scalar slider, and supply its accessible name. The element
|
|
240
|
+
provides the default slider or group role through `ElementInternals`.
|
|
146
241
|
|
|
147
242
|
For a range, separate the two numbers with a space in `value` or `defaultvalue`.
|
|
148
243
|
Use `role="group"` and give the range an accessible name. Each thumb receives
|
|
@@ -192,7 +287,29 @@ as `Slider`. In raw HTML, `round` needs a CSS length such as `"4px"`; JSX
|
|
|
192
287
|
|
|
193
288
|
## Styling
|
|
194
289
|
|
|
195
|
-
`Slider` renders an `<a-slider>` with a circular thumb. `tone` and `thumbTone` accept named or custom CSS colors; custom values use the public `--slider-tone-source` and `--slider-thumb-tone-source` knobs. Use `round` to shape the rail and thumb together. Target its shadow parts to change their presentation without taking on the interaction code: `::part(thumb)` customizes the thumb’s surface and stroke.
|
|
290
|
+
`Slider` renders an `<a-slider>` with a circular thumb. `tone` and `thumbTone` accept named or custom CSS colors; custom values use the public `--slider-tone-source` and `--slider-thumb-tone-source` knobs. Use `round` to shape the rail and thumb together. Target its shadow parts to change their presentation without taking on the interaction code: `::part(thumb)` customizes the thumb’s surface and stroke. Existing parts remain available: `header`, `label`, `value`, `control`, `track`,
|
|
291
|
+
`fill`, `thumb`, `thumb-value`, `markers`, and `extras`. `thumb-1` and `thumb-2`
|
|
292
|
+
identify physical thumbs and retain their identity when crossing. Additional parts
|
|
293
|
+
include `rail-area`, `inline-value`, `end-value`, `value-separator`, `value-affix`,
|
|
294
|
+
`fill-start`, `fill-end`, `thumb-value-1`, and `thumb-value-2`.
|
|
295
|
+
|
|
296
|
+
Defaults load from external CSS, including styles for these shadow parts. Place
|
|
297
|
+
consumer overrides in `components`, `utilities`, or unlayered CSS; earlier `base`
|
|
298
|
+
rules lose to Anta defaults. Load Slider CSS in the same root as the host when
|
|
299
|
+
rendering inside a consumer shadow root. Existing part names may have additional
|
|
300
|
+
tokens, so use `[part~="thumb"]` for shadow queries.
|
|
301
|
+
|
|
302
|
+
Public host states describe applied presentation: `range`, `dragging`,
|
|
303
|
+
`pointer-focus`, `thumb-1-active`, and `thumb-2-active`. The active-thumb states
|
|
304
|
+
identify the most recently focused or pressed physical thumb. Region states
|
|
305
|
+
`has-header`, `has-markers`, `has-extras`, `has-fill`, `has-fill-end`,
|
|
306
|
+
`has-thumb-value`, and `has-thumb-value-end` indicate visible regions, including
|
|
307
|
+
coincident range bubbles.
|
|
308
|
+
|
|
309
|
+
Custom colors, radius, sizing, marker positions, and application `style` props can
|
|
310
|
+
serialize inline style attributes during SSR. Under `style-src-attr 'none'`, use
|
|
311
|
+
external consumer CSS for those values; see [CSP guidance](../install-config.md#content-security-policy).
|
|
312
|
+
Default external styling does not remove that separate inline-style constraint.
|
|
196
313
|
|
|
197
314
|
```css
|
|
198
315
|
/* The class is only for the demo. Use your own selector. */
|
package/docs/components/steps.md
CHANGED
|
@@ -208,7 +208,8 @@ const index = options.findIndex((option) => option.value === phase)
|
|
|
208
208
|
## Orientation
|
|
209
209
|
|
|
210
210
|
Horizontal steps scroll when needed. Vertical steps place the active panel before
|
|
211
|
-
the next step.
|
|
211
|
+
the next step. This layout uses external CSS and needs no inline style attributes
|
|
212
|
+
under a strict [Content Security Policy](../install-config.md#content-security-policy).
|
|
212
213
|
|
|
213
214
|
```tsx
|
|
214
215
|
<Steps
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Switches change a single setting immediately. Use a checkbox when people select one or more values to submit together.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Use `defaultChecked` for an initial setting, or pair `checked` with
|
|
6
|
+
`onStateChange` when the application controls the setting.
|
|
6
7
|
|
|
7
8
|
## Tone
|
|
8
9
|
|
|
@@ -121,10 +122,9 @@ Use **`onStateChange`** to intercept a toggle or drive a controlled switch. Use
|
|
|
121
122
|
|
|
122
123
|
## Accessibility
|
|
123
124
|
|
|
124
|
-
The
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
IDs are needed. For a label-less switch, pass `aria-label`.
|
|
125
|
+
The label names the switch for screen readers, and the hint supplies its
|
|
126
|
+
description. Without a visible label, pass `aria-label`. Screen readers
|
|
127
|
+
announce the current state.
|
|
128
128
|
|
|
129
129
|
Space toggles the switch. It follows the [WAI-ARIA switch pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/).
|
|
130
130
|
|
|
@@ -150,10 +150,9 @@ Space toggles the switch. It follows the [WAI-ARIA switch pattern](https://www.w
|
|
|
150
150
|
|
|
151
151
|
## Web Component
|
|
152
152
|
|
|
153
|
-
Use
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
the element exposes as its accessible name and description.
|
|
153
|
+
Use `<a-switch>` directly outside JSX. Set `role="switch"` and `tabindex="0"`
|
|
154
|
+
for keyboard access. Its label and hint supply the accessible name and
|
|
155
|
+
description.
|
|
157
156
|
|
|
158
157
|
```html
|
|
159
158
|
<a-switch role="switch" tabindex="0" name="updates" default-state="checked">
|