@acronis-platform/ui-react 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/accordion-container/accordion-container.js +14 -14
- package/dist/components/ui/accordion-container/accordion-container.js.map +1 -1
- package/dist/components/ui/app-shell-chat/app-shell-chat.js.map +1 -1
- package/dist/components/ui/area-chart/area-chart.js +141 -139
- package/dist/components/ui/area-chart/area-chart.js.map +1 -1
- package/dist/components/ui/bar-chart/bar-chart.js +295 -293
- package/dist/components/ui/bar-chart/bar-chart.js.map +1 -1
- package/dist/components/ui/category-bar/category-bar.js +109 -93
- package/dist/components/ui/category-bar/category-bar.js.map +1 -1
- package/dist/components/ui/chart/chart-palette.js +113 -0
- package/dist/components/ui/chart/chart-palette.js.map +1 -0
- package/dist/components/ui/chart/chart.js +176 -129
- package/dist/components/ui/chart/chart.js.map +1 -1
- package/dist/components/ui/chart-state/chart-state-illustrations.js +310 -0
- package/dist/components/ui/chart-state/chart-state-illustrations.js.map +1 -0
- package/dist/components/ui/chart-state/chart-state.js +48 -34
- package/dist/components/ui/chart-state/chart-state.js.map +1 -1
- package/dist/components/ui/chart-widget/chart-widget.js +87 -0
- package/dist/components/ui/chart-widget/chart-widget.js.map +1 -0
- package/dist/components/ui/composed-chart/composed-chart.js +117 -115
- package/dist/components/ui/composed-chart/composed-chart.js.map +1 -1
- package/dist/components/ui/confidence-cone/confidence-cone.js +166 -158
- package/dist/components/ui/confidence-cone/confidence-cone.js.map +1 -1
- package/dist/components/ui/funnel-chart/funnel-chart.js +162 -161
- package/dist/components/ui/funnel-chart/funnel-chart.js.map +1 -1
- package/dist/components/ui/histogram/histogram.js +94 -92
- package/dist/components/ui/histogram/histogram.js.map +1 -1
- package/dist/components/ui/input/input.js.map +1 -1
- package/dist/components/ui/label/label.js +2 -9
- package/dist/components/ui/label/label.js.map +1 -1
- package/dist/components/ui/line-chart/line-chart.js +143 -141
- package/dist/components/ui/line-chart/line-chart.js.map +1 -1
- package/dist/components/ui/metric/metric.js +74 -185
- package/dist/components/ui/metric/metric.js.map +1 -1
- package/dist/components/ui/page-content/page-content.js.map +1 -1
- package/dist/components/ui/pie-chart/pie-chart.js +201 -195
- package/dist/components/ui/pie-chart/pie-chart.js.map +1 -1
- package/dist/components/ui/radar-chart/radar-chart.js +133 -131
- package/dist/components/ui/radar-chart/radar-chart.js.map +1 -1
- package/dist/components/ui/radial-bar-chart/radial-bar-chart.js +297 -265
- package/dist/components/ui/radial-bar-chart/radial-bar-chart.js.map +1 -1
- package/dist/components/ui/sankey-chart/sankey-chart.js +123 -101
- package/dist/components/ui/sankey-chart/sankey-chart.js.map +1 -1
- package/dist/components/ui/scatter-chart/scatter-chart.js +76 -74
- package/dist/components/ui/scatter-chart/scatter-chart.js.map +1 -1
- package/dist/components/ui/section/section.js +157 -31
- package/dist/components/ui/section/section.js.map +1 -1
- package/dist/components/ui/stepper/stepper.js +24 -24
- package/dist/components/ui/stepper/stepper.js.map +1 -1
- package/dist/components/ui/stepper-item/stepper-item.js +43 -24
- package/dist/components/ui/stepper-item/stepper-item.js.map +1 -1
- package/dist/components/ui/treemap/treemap.js +133 -124
- package/dist/components/ui/treemap/treemap.js.map +1 -1
- package/dist/components/ui/trend-indicator/trend-indicator.js +34 -69
- package/dist/components/ui/trend-indicator/trend-indicator.js.map +1 -1
- package/dist/components/ui/wizard/wizard.js +59 -0
- package/dist/components/ui/wizard/wizard.js.map +1 -0
- package/dist/hooks/use-wizard.js +75 -0
- package/dist/hooks/use-wizard.js.map +1 -0
- package/dist/index.js +502 -497
- package/dist/index.js.map +1 -1
- package/dist/llms/accordion-container.md +181 -0
- package/dist/llms/accordion.md +124 -0
- package/dist/llms/alert.md +225 -0
- package/dist/llms/app-shell-chat.md +415 -0
- package/dist/llms/area-chart.md +355 -0
- package/dist/llms/avatar.md +208 -0
- package/dist/llms/bar-chart.md +406 -0
- package/dist/llms/breadcrumb.md +326 -0
- package/dist/llms/button-group.md +298 -0
- package/dist/llms/button-icon-input.md +142 -0
- package/dist/llms/button-icon-menu.md +209 -0
- package/dist/llms/button-icon.md +128 -0
- package/dist/llms/button-menu.md +172 -0
- package/dist/llms/button.md +185 -0
- package/dist/llms/calendar-panel.md +733 -0
- package/dist/llms/calendar.md +188 -0
- package/dist/llms/card-filter.md +214 -0
- package/dist/llms/card-section.md +293 -0
- package/dist/llms/card.md +447 -0
- package/dist/llms/carousel-dialog.md +156 -0
- package/dist/llms/category-bar.md +193 -0
- package/dist/llms/chart-state.md +190 -0
- package/dist/llms/chart-widget.md +209 -0
- package/dist/llms/chart.md +182 -0
- package/dist/llms/checkbox.md +257 -0
- package/dist/llms/chip.md +195 -0
- package/dist/llms/combobox.md +164 -0
- package/dist/llms/composed-chart.md +508 -0
- package/dist/llms/confidence-cone.md +277 -0
- package/dist/llms/data-table.md +474 -0
- package/dist/llms/date-range-picker.md +272 -0
- package/dist/llms/description-list.md +131 -0
- package/dist/llms/dialog-footer-carousel.md +147 -0
- package/dist/llms/dialog-footer-default.md +142 -0
- package/dist/llms/dialog-root.md +246 -0
- package/dist/llms/dialog-welcome.md +223 -0
- package/dist/llms/dialog.md +403 -0
- package/dist/llms/dropdown-menu.md +193 -0
- package/dist/llms/empty-overlay.md +146 -0
- package/dist/llms/empty.md +156 -0
- package/dist/llms/field.md +185 -0
- package/dist/llms/filter-cards.md +157 -0
- package/dist/llms/filter-chips.md +323 -0
- package/dist/llms/filter-search.md +512 -0
- package/dist/llms/form.md +154 -0
- package/dist/llms/funnel-chart.md +333 -0
- package/dist/llms/grid.md +80 -0
- package/dist/llms/histogram.md +190 -0
- package/dist/llms/input-date-picker.md +203 -0
- package/dist/llms/input-otp.md +173 -0
- package/dist/llms/input-password.md +197 -0
- package/dist/llms/input-search.md +170 -0
- package/dist/llms/input-select.md +278 -0
- package/dist/llms/input-text-area.md +271 -0
- package/dist/llms/input-text.md +192 -0
- package/dist/llms/line-chart.md +369 -0
- package/dist/llms/link.md +209 -0
- package/dist/llms/loading.md +130 -0
- package/dist/llms/meter.md +177 -0
- package/dist/llms/metric.md +204 -0
- package/dist/llms/number-field.md +122 -0
- package/dist/llms/page-content.md +69 -0
- package/dist/llms/page-header.md +182 -0
- package/dist/llms/pagination.md +133 -0
- package/dist/llms/pie-chart.md +307 -0
- package/dist/llms/popover.md +252 -0
- package/dist/llms/progress-circle.md +126 -0
- package/dist/llms/progress.md +111 -0
- package/dist/llms/radar-chart.md +316 -0
- package/dist/llms/radial-bar-chart.md +319 -0
- package/dist/llms/radio.md +255 -0
- package/dist/llms/resizable.md +195 -0
- package/dist/llms/sankey-chart.md +208 -0
- package/dist/llms/scatter-chart.md +239 -0
- package/dist/llms/scroll-area.md +183 -0
- package/dist/llms/section.md +401 -0
- package/dist/llms/select.md +210 -0
- package/dist/llms/separator.md +87 -0
- package/dist/llms/sheet.md +202 -0
- package/dist/llms/sidebar-primary.md +360 -0
- package/dist/llms/sidebar-secondary.md +417 -0
- package/dist/llms/skeleton.md +81 -0
- package/dist/llms/slider.md +97 -0
- package/dist/llms/spinner.md +100 -0
- package/dist/llms/stack.md +80 -0
- package/dist/llms/stepper-item.md +309 -0
- package/dist/llms/stepper.md +251 -0
- package/dist/llms/switch.md +140 -0
- package/dist/llms/table.md +436 -0
- package/dist/llms/tabs.md +197 -0
- package/dist/llms/tag.md +139 -0
- package/dist/llms/timeline.md +361 -0
- package/dist/llms/timer.md +259 -0
- package/dist/llms/toast.md +241 -0
- package/dist/llms/toggle-group.md +121 -0
- package/dist/llms/toolbar.md +453 -0
- package/dist/llms/tooltip.md +164 -0
- package/dist/llms/treemap.md +254 -0
- package/dist/llms/trend-indicator.md +132 -0
- package/dist/llms/widget-placeholder.md +169 -0
- package/dist/llms/wizard.md +412 -0
- package/dist/llms.txt +142 -0
- package/dist/react.js +502 -497
- package/dist/react.js.map +1 -1
- package/dist/src/components/ui/area-chart/area-chart.d.ts +9 -4
- package/dist/src/components/ui/avatar/avatar.d.ts +1 -1
- package/dist/src/components/ui/bar-chart/bar-chart.d.ts +9 -4
- package/dist/src/components/ui/category-bar/category-bar.d.ts +10 -4
- package/dist/src/components/ui/chart/__stories__/palette-control.d.ts +48 -0
- package/dist/src/components/ui/chart/__tests__/chart-palette.test.d.ts +1 -0
- package/dist/src/components/ui/chart/chart-palette.d.ts +128 -0
- package/dist/src/components/ui/chart/chart.d.ts +66 -15
- package/dist/src/components/ui/chart/index.d.ts +4 -2
- package/dist/src/components/ui/chart-state/chart-state-illustrations.d.ts +6 -0
- package/dist/src/components/ui/chart-state/chart-state.d.ts +13 -2
- package/dist/src/components/ui/chart-state/index.d.ts +1 -0
- package/dist/src/components/ui/chart-widget/chart-widget.d.ts +64 -0
- package/dist/src/components/ui/chart-widget/index.d.ts +1 -0
- package/dist/src/components/ui/composed-chart/composed-chart.d.ts +12 -7
- package/dist/src/components/ui/confidence-cone/confidence-cone.d.ts +10 -5
- package/dist/src/components/ui/empty-overlay/empty-overlay.d.ts +1 -1
- package/dist/src/components/ui/funnel-chart/funnel-chart.d.ts +11 -5
- package/dist/src/components/ui/histogram/histogram.d.ts +10 -4
- package/dist/src/components/ui/label/index.d.ts +1 -1
- package/dist/src/components/ui/label/label.d.ts +1 -5
- package/dist/src/components/ui/line-chart/line-chart.d.ts +9 -4
- package/dist/src/components/ui/metric/metric.d.ts +13 -14
- package/dist/src/components/ui/pie-chart/pie-chart.d.ts +17 -8
- package/dist/src/components/ui/radar-chart/radar-chart.d.ts +10 -5
- package/dist/src/components/ui/radial-bar-chart/radial-bar-chart.d.ts +17 -6
- package/dist/src/components/ui/sankey-chart/sankey-chart.d.ts +10 -5
- package/dist/src/components/ui/scatter-chart/scatter-chart.d.ts +10 -5
- package/dist/src/components/ui/section/index.d.ts +1 -1
- package/dist/src/components/ui/section/section.d.ts +75 -6
- package/dist/src/components/ui/stepper-item/stepper-item.d.ts +6 -5
- package/dist/src/components/ui/tag/tag.d.ts +1 -1
- package/dist/src/components/ui/treemap/treemap.d.ts +11 -5
- package/dist/src/components/ui/trend-indicator/trend-indicator.d.ts +3 -7
- package/dist/src/components/ui/wizard/index.d.ts +1 -0
- package/dist/src/components/ui/wizard/wizard.d.ts +6 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/use-wizard.d.ts +80 -0
- package/dist/src/index.d.ts +2 -3
- package/dist/ui-react.css +1 -1
- package/package.json +9 -3
- package/dist/components/ui/app-shell/app-shell.js +0 -75
- package/dist/components/ui/app-shell/app-shell.js.map +0 -1
- package/dist/components/ui/auth-layout/auth-layout.js +0 -56
- package/dist/components/ui/auth-layout/auth-layout.js.map +0 -1
- package/dist/components/ui/collapsible/collapsible.js +0 -22
- package/dist/components/ui/collapsible/collapsible.js.map +0 -1
- package/dist/src/components/ui/app-shell/app-shell.d.ts +0 -8
- package/dist/src/components/ui/app-shell/index.d.ts +0 -1
- package/dist/src/components/ui/auth-layout/auth-layout.d.ts +0 -6
- package/dist/src/components/ui/auth-layout/index.d.ts +0 -1
- package/dist/src/components/ui/collapsible/collapsible.d.ts +0 -5
- package/dist/src/components/ui/collapsible/index.d.ts +0 -1
- package/dist/src/components/ui/label/label.docs.d.ts +0 -10
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# InputDatePicker
|
|
2
|
+
|
|
3
|
+
> The date-field trigger: a button box that displays a formatted date (or a start–end range when `pickerType="dateRange"`) and a trailing calendar icon, with an optional label (and required marker) and an optional description or error message. Opens a consumer-owned calendar. Themed by the `--ui-input-date-picker-*` token tier.
|
|
4
|
+
|
|
5
|
+
**Status:** ready · **Category:** forms · **Since:** v0.30.0
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { InputDatePicker } from '@acronis-platform/ui-react'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick example
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<InputDatePicker
|
|
17
|
+
label="Due date"
|
|
18
|
+
placeholder="Pick a date"
|
|
19
|
+
value={selected && format(selected, 'MMM d, yyyy')}
|
|
20
|
+
open={open}
|
|
21
|
+
onClick={() => setOpen(true)}
|
|
22
|
+
description="When the task is due"
|
|
23
|
+
/>
|
|
24
|
+
|
|
25
|
+
{/* Range */}
|
|
26
|
+
<InputDatePicker
|
|
27
|
+
label="Period"
|
|
28
|
+
pickerType="dateRange"
|
|
29
|
+
startDate={start && format(start, 'MMM d')}
|
|
30
|
+
endDate={end && format(end, 'MMM d')}
|
|
31
|
+
/>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The date-field **trigger**: a button box that displays a formatted date (or a
|
|
35
|
+
`start – end` range when `pickerType="dateRange"`) and a trailing calendar icon,
|
|
36
|
+
with a label (and optional required marker) and an optional description or error.
|
|
37
|
+
Themed by the `--ui-input-date-picker-*` token tier.
|
|
38
|
+
|
|
39
|
+
> **Scope:** this is the trigger field only. The calendar popup is not part of the
|
|
40
|
+
> Figma design or the token tier yet — the consumer formats the date `value` / range
|
|
41
|
+
> as strings and wires their own calendar to `open` / `onClick` (e.g. a popover).
|
|
42
|
+
|
|
43
|
+
## When to use
|
|
44
|
+
|
|
45
|
+
- A labelled date or date-range entry that opens a calendar, where you bring your own
|
|
46
|
+
calendar/popover and date formatting.
|
|
47
|
+
|
|
48
|
+
## When not to use
|
|
49
|
+
|
|
50
|
+
- For free text — use `InputText`; for choosing from a fixed list — use `InputSelect`.
|
|
51
|
+
- If you need a built-in calendar grid — that's a separate, not-yet-designed component.
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { InputDatePicker } from '@acronis-platform/ui-react';
|
|
57
|
+
import { format } from 'date-fns';
|
|
58
|
+
|
|
59
|
+
// Single date
|
|
60
|
+
<InputDatePicker
|
|
61
|
+
label="Due date"
|
|
62
|
+
placeholder="Pick a date"
|
|
63
|
+
value={selected && format(selected, 'MMM d, yyyy')}
|
|
64
|
+
open={open}
|
|
65
|
+
onClick={() => setOpen(true)}
|
|
66
|
+
description="When the task is due"
|
|
67
|
+
/>;
|
|
68
|
+
|
|
69
|
+
// Range
|
|
70
|
+
<InputDatePicker
|
|
71
|
+
label="Period"
|
|
72
|
+
pickerType="dateRange"
|
|
73
|
+
startDate={start && format(start, 'MMM d')}
|
|
74
|
+
endDate={end && format(end, 'MMM d')}
|
|
75
|
+
/>;
|
|
76
|
+
|
|
77
|
+
// Error
|
|
78
|
+
<InputDatePicker label="Due date" error="Pick a valid date" />;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Parts
|
|
82
|
+
|
|
83
|
+
| Part | Element | Description |
|
|
84
|
+
| ------------- | ---------- | --------------------------------------------------------- |
|
|
85
|
+
| `label` | `<label>` | Field label (associated via `htmlFor`/`id`). |
|
|
86
|
+
| `required` | `<span>` | Required `*` marker (decorative; `aria-hidden`). |
|
|
87
|
+
| `trigger` | `<button>` | The box; opens the calendar; `aria-invalid` → error look. |
|
|
88
|
+
| `value` | `<span>` | Selected date / range, or the placeholder. |
|
|
89
|
+
| `separator` | `<span>` | The `–` between range dates. |
|
|
90
|
+
| `icon` | `<span>` | Trailing calendar icon. |
|
|
91
|
+
| `description` | `<p>` | Helper text (normal state). |
|
|
92
|
+
| `error` | `<p>` | Error message; replaces the description. |
|
|
93
|
+
|
|
94
|
+
## Props
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Default | Required | Description |
|
|
97
|
+
|------|------|---------|----------|-------------|
|
|
98
|
+
| `label` | `ReactNode` | — | no | Field label rendered above the box, associated via `htmlFor`/`id`. |
|
|
99
|
+
| `required` | `boolean` | `false` | no | Appends a required marker (`*`) and sets `aria-required` on the trigger. |
|
|
100
|
+
| `description` | `ReactNode` | — | no | Helper text below the box. Hidden while `error` is set. |
|
|
101
|
+
| `error` | `ReactNode` | — | no | Error message below the box. Its presence switches the field to the error treatment (red box border via `aria-invalid`, red message replacing the description). |
|
|
102
|
+
| `picker-type` | `'date' | 'dateRange'` | `date` | no | Whether the field holds a single date or a start–end range. |
|
|
103
|
+
| `placeholder` | `ReactNode` | — | no | Hint shown when no value is selected. |
|
|
104
|
+
| `value` | `ReactNode` | — | no | Formatted selected date (`picker-type="date"`). |
|
|
105
|
+
| `start-date` | `ReactNode` | — | no | Formatted range start (`picker-type="dateRange"`). |
|
|
106
|
+
| `end-date` | `ReactNode` | — | no | Formatted range end (`picker-type="dateRange"`). |
|
|
107
|
+
| `separator` | `ReactNode` | `–` | no | Separator rendered between the range dates. |
|
|
108
|
+
| `open` | `boolean` | `false` | no | Whether the consumer-owned calendar is open — paints the active border and sets `aria-expanded`. |
|
|
109
|
+
| `disabled` | `boolean` | `false` | no | Disables the trigger; applies the disabled tokens. |
|
|
110
|
+
|
|
111
|
+
## Events
|
|
112
|
+
|
|
113
|
+
| Event | Payload | Description |
|
|
114
|
+
|-------|---------|-------------|
|
|
115
|
+
| `click` | `MouseEvent` | Fired when the trigger is activated (React: native `onClick`). Open your calendar here. |
|
|
116
|
+
|
|
117
|
+
## Content slots
|
|
118
|
+
|
|
119
|
+
| Slot | Description |
|
|
120
|
+
|------|-------------|
|
|
121
|
+
| `label` | The label content. |
|
|
122
|
+
| `description` | The helper text. |
|
|
123
|
+
| `error` | The error message. |
|
|
124
|
+
|
|
125
|
+
## Behavior
|
|
126
|
+
|
|
127
|
+
### Rendering
|
|
128
|
+
|
|
129
|
+
**Given** a `label`
|
|
130
|
+
**When** the field renders
|
|
131
|
+
**Then** the label appears above the trigger and is associated with it via
|
|
132
|
+
`htmlFor`/`id`; a `*` follows it when `required` (which also sets `aria-required`).
|
|
133
|
+
|
|
134
|
+
**Given** `picker-type="date"`
|
|
135
|
+
**When** a `value` is set
|
|
136
|
+
**Then** the trigger shows the formatted value; otherwise it shows the `placeholder`.
|
|
137
|
+
|
|
138
|
+
**Given** `picker-type="dateRange"`
|
|
139
|
+
**When** `start-date` / `end-date` are set
|
|
140
|
+
**Then** the trigger shows `start separator end` (default separator `–`); otherwise
|
|
141
|
+
the range `placeholder`.
|
|
142
|
+
|
|
143
|
+
**Given** a `description` and no `error`
|
|
144
|
+
**Then** the helper text shows below the box (associated via `aria-describedby`);
|
|
145
|
+
**given** an `error`, it replaces the description and the box takes the error border.
|
|
146
|
+
|
|
147
|
+
### Interaction
|
|
148
|
+
|
|
149
|
+
**Given** the trigger
|
|
150
|
+
**When** it is activated (click, Enter, or Space)
|
|
151
|
+
**Then** `click` fires — the consumer opens its calendar.
|
|
152
|
+
|
|
153
|
+
**Given** `open` is true (the consumer-owned calendar is shown)
|
|
154
|
+
**Then** the box paints the active border, the trigger sets `aria-expanded="true"`,
|
|
155
|
+
and the label / value / placeholder / separator / description / icon colors
|
|
156
|
+
switch to their `-hover` token — the Figma design groups hover and the open
|
|
157
|
+
(active) state under one visual treatment for these parts.
|
|
158
|
+
|
|
159
|
+
**Given** the trigger
|
|
160
|
+
**When** the pointer hovers
|
|
161
|
+
**Then** the border shifts to its hover token and the label / value /
|
|
162
|
+
placeholder / separator / description / icon colors switch to their `-hover`
|
|
163
|
+
token too.
|
|
164
|
+
|
|
165
|
+
**Given** the trigger
|
|
166
|
+
**When** it receives keyboard focus
|
|
167
|
+
**Then** the border shifts to its active token and a 3px ring is painted —
|
|
168
|
+
`--ui-focus-primary` normally, `--ui-focus-error` while in the error state; the
|
|
169
|
+
label / value / placeholder / separator / description / icon colors are
|
|
170
|
+
**not** affected by focus alone.
|
|
171
|
+
|
|
172
|
+
**Given** the field is `disabled`
|
|
173
|
+
**Then** the trigger is inert (does not open) and uses the disabled token set.
|
|
174
|
+
|
|
175
|
+
### Scope
|
|
176
|
+
|
|
177
|
+
The calendar popup itself is **not** part of this component (not in the Figma design
|
|
178
|
+
or the token tier). The consumer renders the date `value` / range as formatted
|
|
179
|
+
strings and wires their own calendar to `open` / `onClick`.
|
|
180
|
+
|
|
181
|
+
## Accessibility
|
|
182
|
+
|
|
183
|
+
- **Trigger role:** the trigger is a native `<button>` (`role="button"`) with
|
|
184
|
+
`aria-haspopup="dialog"` — it announces that activating it opens a calendar.
|
|
185
|
+
- **Label association:** the `label` is a real `<label htmlFor>` tied to the trigger's
|
|
186
|
+
`id` (auto-generated when not supplied), so clicking it focuses the trigger and
|
|
187
|
+
screen readers announce the field name.
|
|
188
|
+
- **Required:** `required` sets `aria-required="true"`; the visual `*` is `aria-hidden`.
|
|
189
|
+
- **Open state:** while the consumer's calendar is open, pass `open` so the trigger
|
|
190
|
+
reflects `aria-expanded="true"` (and paints the active border).
|
|
191
|
+
- **Error:** set `error` (or `aria-invalid`); the message is associated via
|
|
192
|
+
`aria-describedby` and the trigger gets `aria-invalid="true"` + the error border.
|
|
193
|
+
- **Keyboard:** the trigger is reachable by Tab and activated by Enter / Space; the
|
|
194
|
+
consumer's calendar owns its own focus management and Escape-to-close.
|
|
195
|
+
- **Focus visible:** keyboard focus paints a 3px ring flush to the box —
|
|
196
|
+
`--ui-focus-primary` normally, `--ui-focus-error` in the error state.
|
|
197
|
+
- **Disabled:** native `disabled` removes the trigger from the tab order and blocks
|
|
198
|
+
opening; state is not conveyed by color alone (the control is also inert).
|
|
199
|
+
- **Value text:** the trigger displays consumer-formatted, human-readable dates (not
|
|
200
|
+
raw ISO) so the announced name is meaningful.
|
|
201
|
+
- **Contrast:** label / value / placeholder / border / icon pairs come from the design
|
|
202
|
+
tokens, authored to meet WCAG contrast.
|
|
203
|
+
- **WCAG:** 1.3.1, 2.1.1, 2.4.7, 1.4.3 / 1.4.11, 3.3.1 / 3.3.2, 4.1.2.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# InputOTP
|
|
2
|
+
|
|
3
|
+
> A bare row of single-character boxes for entering a one-time code. No label/description — like `Input`, field furniture is a future `Field` wrapper. Typing a digit advances focus to the next slot; Backspace on an empty slot clears and moves back; pasting a full code distributes it across the slots.
|
|
4
|
+
|
|
5
|
+
**Status:** ready · **Category:** forms · **Since:** v0.58.0
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { InputOTP } from '@acronis-platform/ui-react'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick example
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<InputOTP length={6} onComplete={(code) => submit(code)} />
|
|
17
|
+
|
|
18
|
+
{/* Error */}
|
|
19
|
+
<InputOTP error defaultValue="123456" />
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
A bare row of single-character boxes for entering a one-time code (e.g. a
|
|
23
|
+
6-digit SMS/authenticator code). Like [`Input`](../input/README.md), it has no
|
|
24
|
+
label/description — a `Field` wrapper composes those around it.
|
|
25
|
+
|
|
26
|
+
## When to use
|
|
27
|
+
|
|
28
|
+
- Entering a fixed-length numeric one-time code (e.g. an SMS/authenticator
|
|
29
|
+
code), with auto-advance between digits and paste support. Input is
|
|
30
|
+
digit-only — a non-digit keystroke is rejected and non-digit characters are
|
|
31
|
+
stripped from a paste.
|
|
32
|
+
|
|
33
|
+
## When not to use
|
|
34
|
+
|
|
35
|
+
- A general single-line text field — use `InputText`.
|
|
36
|
+
- A field that needs its own label/description/error message wired in — wrap
|
|
37
|
+
`InputOTP` the same way a future `Field` wraps `Input`.
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { InputOTP } from '@acronis-platform/ui-react';
|
|
43
|
+
|
|
44
|
+
// Basic 6-digit code, auto-focused, submits once complete
|
|
45
|
+
<InputOTP autoFocus onComplete={(code) => verify(code)} />;
|
|
46
|
+
|
|
47
|
+
// A shorter code
|
|
48
|
+
<InputOTP length={4} />;
|
|
49
|
+
|
|
50
|
+
// Error (e.g. after a failed verification)
|
|
51
|
+
<InputOTP error defaultValue="123456" />;
|
|
52
|
+
|
|
53
|
+
// Disabled
|
|
54
|
+
<InputOTP disabled defaultValue="123456" />;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Parts
|
|
58
|
+
|
|
59
|
+
| Part | Element | Description |
|
|
60
|
+
| ------ | --------- | ------------------------------------------------------------------------------------------------- |
|
|
61
|
+
| `root` | `<div>` | The `role="group"` row container for the slots. |
|
|
62
|
+
| `slot` | `<input>` | A single-character box, repeated `length` times; shows its position as a placeholder while empty. |
|
|
63
|
+
|
|
64
|
+
## Props
|
|
65
|
+
|
|
66
|
+
| Prop | Type | Default | Required | Description |
|
|
67
|
+
|------|------|---------|----------|-------------|
|
|
68
|
+
| `length` | `number` | `6` | no | Number of single-character slots. |
|
|
69
|
+
| `value` | `string` | — | no | Controlled value (the digits entered so far, left to right). |
|
|
70
|
+
| `defaultValue` | `string` | — | no | Initial value for uncontrolled usage. |
|
|
71
|
+
| `disabled` | `boolean` | `false` | no | Disables every slot. |
|
|
72
|
+
| `error` | `boolean` | `false` | no | Switches every slot to the error treatment. |
|
|
73
|
+
| `autoFocus` | `boolean` | `false` | no | Focuses the first slot on mount. |
|
|
74
|
+
| `slotAriaLabel` | `(index: number, length: number) => string` | `(index, length) => `Digit ${index} of ${length}`` | no | Builds the accessible name for a slot from its 1-based index and the total length. |
|
|
75
|
+
|
|
76
|
+
## Events
|
|
77
|
+
|
|
78
|
+
| Event | Payload | Description |
|
|
79
|
+
|-------|---------|-------------|
|
|
80
|
+
| `change` | `string` | Fires with the full value on every change. |
|
|
81
|
+
| `complete` | `string` | Fires once, the moment the value reaches `length` characters. |
|
|
82
|
+
|
|
83
|
+
## Behavior
|
|
84
|
+
|
|
85
|
+
### Rendering
|
|
86
|
+
|
|
87
|
+
**Given** `length` (default 6)
|
|
88
|
+
**When** the field renders
|
|
89
|
+
**Then** it shows that many single-character boxes in a row, each labelled
|
|
90
|
+
`Digit N of length`, each showing its own 1-based position as a placeholder
|
|
91
|
+
while empty.
|
|
92
|
+
|
|
93
|
+
### Typing
|
|
94
|
+
|
|
95
|
+
**Given** a slot with focus
|
|
96
|
+
**When** a digit is entered
|
|
97
|
+
**Then** the value updates, `onChange` fires with the full value, and focus
|
|
98
|
+
advances to the next slot (if any).
|
|
99
|
+
|
|
100
|
+
**Given** the value reaches `length` characters
|
|
101
|
+
**When** the last digit is entered
|
|
102
|
+
**Then** `onComplete` fires once with the full value. It does not fire again
|
|
103
|
+
until the value drops below `length` and reaches it again.
|
|
104
|
+
|
|
105
|
+
### Backspace / navigation
|
|
106
|
+
|
|
107
|
+
**Given** an empty slot (not the first)
|
|
108
|
+
**When** Backspace is pressed
|
|
109
|
+
**Then** the previous slot is cleared and receives focus.
|
|
110
|
+
|
|
111
|
+
**Given** any slot
|
|
112
|
+
**When** ArrowLeft / ArrowRight is pressed
|
|
113
|
+
**Then** focus moves to the previous / next slot (clamped at the ends).
|
|
114
|
+
|
|
115
|
+
### Paste
|
|
116
|
+
|
|
117
|
+
**Given** a slot with focus
|
|
118
|
+
**When** text is pasted
|
|
119
|
+
**Then** the code is distributed across the slots starting at the focused
|
|
120
|
+
slot, extra characters beyond `length` are discarded, and focus lands on the
|
|
121
|
+
last filled slot (or the last slot).
|
|
122
|
+
|
|
123
|
+
### Validation
|
|
124
|
+
|
|
125
|
+
**Given** a slot with focus
|
|
126
|
+
**When** a non-digit character is typed
|
|
127
|
+
**Then** the keystroke is rejected — the slot's value and focus are unchanged.
|
|
128
|
+
|
|
129
|
+
**Given** a slot with focus
|
|
130
|
+
**When** text containing non-digit characters is pasted
|
|
131
|
+
**Then** only the digit characters are distributed across the slots; all
|
|
132
|
+
other characters (letters, symbols, whitespace) are discarded.
|
|
133
|
+
|
|
134
|
+
### Error / disabled
|
|
135
|
+
|
|
136
|
+
**Given** `error`
|
|
137
|
+
**When** the field renders
|
|
138
|
+
**Then** every slot shows the error border and its focus ring switches to
|
|
139
|
+
`--ui-focus-error`.
|
|
140
|
+
|
|
141
|
+
**Given** `disabled`
|
|
142
|
+
**When** the field renders
|
|
143
|
+
**Then** every slot is a native disabled `<input>` (out of the tab order, no
|
|
144
|
+
interaction).
|
|
145
|
+
|
|
146
|
+
## Accessibility
|
|
147
|
+
|
|
148
|
+
- **Grouping:** the root is `role="group"`, so assistive tech announces the
|
|
149
|
+
slots as a related set. Pass `aria-label`/`aria-labelledby` on the root (it
|
|
150
|
+
forwards arbitrary `div` props) to name the group — e.g. from an external
|
|
151
|
+
`Field` label, since InputOTP itself renders no label.
|
|
152
|
+
- **Per-slot name:** each slot is a native `<input>` with its own
|
|
153
|
+
`aria-label` (default `Digit N of length`, overridable via `slotAriaLabel`).
|
|
154
|
+
- **Keyboard:** digits type normally; ArrowLeft/ArrowRight move focus between
|
|
155
|
+
slots; Backspace on an empty slot moves back and clears the previous one.
|
|
156
|
+
Standard Tab/Shift+Tab also move between slots.
|
|
157
|
+
- **Autofill:** each slot carries `autocomplete="one-time-code"`,
|
|
158
|
+
`inputMode="numeric"`, and `pattern="[0-9]*"` so browsers/password managers
|
|
159
|
+
can offer OTP autofill and mobile keyboards default to numeric.
|
|
160
|
+
- **Numeric-only:** `inputMode`/`pattern` are keyboard hints only, not
|
|
161
|
+
enforcement — both typed and pasted input are filtered to digits in JS. A
|
|
162
|
+
non-digit keystroke is rejected outright; non-digit characters are stripped
|
|
163
|
+
from a paste.
|
|
164
|
+
- **Error:** `error` sets `aria-invalid="true"` on every slot; the message
|
|
165
|
+
itself is expected to live in a wrapping `Field` (not part of this bare
|
|
166
|
+
component), same as `Input`.
|
|
167
|
+
- **Focus visible:** keyboard focus paints a 3px ring on the focused slot —
|
|
168
|
+
`--ui-focus-primary` normally, `--ui-focus-error` while `error` is set.
|
|
169
|
+
- **Disabled:** native `disabled` removes each slot from the tab order.
|
|
170
|
+
- **Contrast:** value/placeholder/border pairs come from the design tokens,
|
|
171
|
+
authored to meet WCAG contrast.
|
|
172
|
+
- **WCAG:** 1.3.1 (info/relationships), 2.1.1 (keyboard), 2.4.7 (focus
|
|
173
|
+
visible), 1.4.3 / 1.4.11 (contrast), 4.1.2.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# InputPassword
|
|
2
|
+
|
|
3
|
+
> A single-line password field: an optional label (with an optional required marker), the value box with a built-in show/hide toggle, and an optional description or error message. Its own `--ui-input-password-*` token tier covers the box down to fill/border (unlike `InputText`, it doesn't build on the bare `Input` primitive).
|
|
4
|
+
|
|
5
|
+
**Status:** ready · **Category:** forms · **Since:** v0.58.0
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { InputPassword } from '@acronis-platform/ui-react'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick example
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<InputPassword label="Password" description="At least 8 characters" />
|
|
17
|
+
|
|
18
|
+
{/* Error */}
|
|
19
|
+
<InputPassword
|
|
20
|
+
label="Password"
|
|
21
|
+
value={value}
|
|
22
|
+
error="Too short"
|
|
23
|
+
onChange={onChange}
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A single-line password field: a label, a themed value box with a built-in
|
|
28
|
+
show/hide toggle, and an optional description or error message. Unlike
|
|
29
|
+
[`InputText`](../input-text/README.md), the box isn't the bare `Input`
|
|
30
|
+
primitive — it has its own `--ui-input-password-*` token tier, and the toggle
|
|
31
|
+
is a [`ButtonIconInput`](../button-icon-input/README.md).
|
|
32
|
+
|
|
33
|
+
## When to use
|
|
34
|
+
|
|
35
|
+
- Any password / secret entry field that should let the user reveal what
|
|
36
|
+
they've typed.
|
|
37
|
+
|
|
38
|
+
## When not to use
|
|
39
|
+
|
|
40
|
+
- A general single-line text field — use `InputText`.
|
|
41
|
+
- A one-time verification code — use `InputOTP`.
|
|
42
|
+
|
|
43
|
+
## Examples
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { InputPassword } from '@acronis-platform/ui-react';
|
|
47
|
+
|
|
48
|
+
// Basic field with helper text
|
|
49
|
+
<InputPassword label="Password" description="At least 8 characters" />;
|
|
50
|
+
|
|
51
|
+
// Required
|
|
52
|
+
<InputPassword label="Password" required />;
|
|
53
|
+
|
|
54
|
+
// Error
|
|
55
|
+
<InputPassword
|
|
56
|
+
label="Password"
|
|
57
|
+
value={value}
|
|
58
|
+
error="Enter at least 8 characters"
|
|
59
|
+
onChange={onChange}
|
|
60
|
+
/>;
|
|
61
|
+
|
|
62
|
+
// Localized toggle labels
|
|
63
|
+
<InputPassword
|
|
64
|
+
label="Contraseña"
|
|
65
|
+
showPasswordLabel="Mostrar contraseña"
|
|
66
|
+
hidePasswordLabel="Ocultar contraseña"
|
|
67
|
+
/>;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Parts
|
|
71
|
+
|
|
72
|
+
| Part | Element | Description |
|
|
73
|
+
| ------------- | ---------- | ---------------------------------------------------------------- |
|
|
74
|
+
| `label` | `<label>` | Field label (associated via `htmlFor`/`id`). |
|
|
75
|
+
| `required` | `<span>` | Required `*` marker. |
|
|
76
|
+
| `box` | `<div>` | The themed container (border, fill) around the input + toggle. |
|
|
77
|
+
| `input` | `<input>` | The borderless value input; toggles `type="password" \| "text"`. |
|
|
78
|
+
| `toggle` | `<button>` | Show/hide button (`ButtonIconInput`). |
|
|
79
|
+
| `description` | `<p>` | Helper text (normal state). |
|
|
80
|
+
| `error` | `<p>` | Error message; replaces the description when `error`. |
|
|
81
|
+
|
|
82
|
+
## Props
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Default | Required | Description |
|
|
85
|
+
|------|------|---------|----------|-------------|
|
|
86
|
+
| `label` | `ReactNode` | — | no | Field label rendered above the box, associated via `htmlFor`/`id`. |
|
|
87
|
+
| `required` | `boolean` | `false` | no | Appends a required marker (`*`) after the label and sets `aria-required` on the input. |
|
|
88
|
+
| `description` | `ReactNode` | — | no | Helper text below the box. Hidden while `error` is set. |
|
|
89
|
+
| `error` | `ReactNode` | — | no | Error message below the box. Its presence switches the field to the error treatment (red box border + red message + error-toned toggle). |
|
|
90
|
+
| `disabled` | `boolean` | `false` | no | Disables the field and the toggle button (native `<input disabled>`). |
|
|
91
|
+
| `showPasswordLabel` | `string` | `'Show password'` | no | Accessible name for the toggle button while the password is hidden. |
|
|
92
|
+
| `hidePasswordLabel` | `string` | `'Hide password'` | no | Accessible name for the toggle button while the password is shown. |
|
|
93
|
+
| `value` | `string` | — | no | Controlled value. |
|
|
94
|
+
|
|
95
|
+
## Events
|
|
96
|
+
|
|
97
|
+
| Event | Payload | Description |
|
|
98
|
+
|-------|---------|-------------|
|
|
99
|
+
| `change` | `ChangeEvent<HTMLInputElement>` | Native input change — forwarded to the underlying `<input>`. |
|
|
100
|
+
|
|
101
|
+
## Content slots
|
|
102
|
+
|
|
103
|
+
| Slot | Description |
|
|
104
|
+
|------|-------------|
|
|
105
|
+
| `label` | The label content. |
|
|
106
|
+
| `description` | The helper text. |
|
|
107
|
+
| `error` | The error message. |
|
|
108
|
+
|
|
109
|
+
## Behavior
|
|
110
|
+
|
|
111
|
+
### Rendering
|
|
112
|
+
|
|
113
|
+
**Given** a `label`
|
|
114
|
+
**When** the field renders
|
|
115
|
+
**Then** the label appears above the box and is associated with the input via
|
|
116
|
+
`htmlFor`/`id` (clicking the label focuses the input).
|
|
117
|
+
|
|
118
|
+
**Given** `required`
|
|
119
|
+
**When** the field renders
|
|
120
|
+
**Then** a `*` marker is appended after the label and the input gets
|
|
121
|
+
`aria-required="true"`.
|
|
122
|
+
|
|
123
|
+
**Given** a `description`
|
|
124
|
+
**When** no `error` is set
|
|
125
|
+
**Then** the helper text shows below the box, associated via
|
|
126
|
+
`aria-describedby`.
|
|
127
|
+
|
|
128
|
+
### Show / hide toggle
|
|
129
|
+
|
|
130
|
+
**Given** the field
|
|
131
|
+
**When** it first renders
|
|
132
|
+
**Then** the value is masked (`type="password"`) and the toggle shows the
|
|
133
|
+
crossed-eye icon with accessible name `showPasswordLabel` ("Show password").
|
|
134
|
+
|
|
135
|
+
**Given** the toggle button
|
|
136
|
+
**When** it is activated
|
|
137
|
+
**Then** the input's `type` flips to `"text"`, the icon becomes the plain eye,
|
|
138
|
+
and the accessible name becomes `hidePasswordLabel` ("Hide password").
|
|
139
|
+
Activating it again reverts both.
|
|
140
|
+
|
|
141
|
+
### Error
|
|
142
|
+
|
|
143
|
+
**Given** `error` is set
|
|
144
|
+
**When** the field renders
|
|
145
|
+
**Then** the box shows the error border, the toggle switches to its error
|
|
146
|
+
tone, the error message replaces the description below the box, and the
|
|
147
|
+
message is associated via `aria-describedby`. The input also gets
|
|
148
|
+
`aria-invalid="true"`.
|
|
149
|
+
|
|
150
|
+
### Interaction
|
|
151
|
+
|
|
152
|
+
**Given** the box
|
|
153
|
+
**When** the pointer hovers / the input receives keyboard focus
|
|
154
|
+
**Then** the box border shifts to its hover token and keyboard focus paints a
|
|
155
|
+
3px ring — `--ui-focus-primary` normally, `--ui-focus-error` in the error
|
|
156
|
+
state.
|
|
157
|
+
|
|
158
|
+
**Given** any typing
|
|
159
|
+
**When** the value changes
|
|
160
|
+
**Then** the native `change` event is forwarded to the consumer.
|
|
161
|
+
|
|
162
|
+
### Disabled
|
|
163
|
+
|
|
164
|
+
**Given** `disabled`
|
|
165
|
+
**When** the field renders
|
|
166
|
+
**Then** the input and the toggle button are both disabled (native
|
|
167
|
+
`disabled`), and the box/label/description use their disabled tokens.
|
|
168
|
+
|
|
169
|
+
## Accessibility
|
|
170
|
+
|
|
171
|
+
- **Label association:** the `label` is a real `<label htmlFor>` tied to the
|
|
172
|
+
input's `id` (auto-generated when not supplied), so clicking it focuses the
|
|
173
|
+
input and screen readers announce the field name.
|
|
174
|
+
- **Required:** `required` sets `aria-required="true"` on the input; the visual
|
|
175
|
+
`*` marker is decorative (no `aria-hidden` needed beyond styling — the
|
|
176
|
+
required semantics come from the attribute).
|
|
177
|
+
- **Description / error:** whichever message is shown is linked to the input
|
|
178
|
+
via `aria-describedby`, so it is announced with the field. The error message
|
|
179
|
+
also drives `aria-invalid="true"` on the input.
|
|
180
|
+
- **Toggle button:** a native `<button>` (`ButtonIconInput`) with an explicit
|
|
181
|
+
`aria-label` that tracks its state ("Show password" / "Hide password",
|
|
182
|
+
overridable via `showPasswordLabel`/`hidePasswordLabel`) and `aria-pressed`
|
|
183
|
+
reflecting whether the value is currently shown. Reachable by Tab and
|
|
184
|
+
activated by Enter / Space.
|
|
185
|
+
- **Keyboard:** the input is a native text field (`type` toggles between
|
|
186
|
+
`password`/`text`); the toggle button is a separate tab stop after it.
|
|
187
|
+
- **Focus visible:** keyboard focus on the input paints a 3px ring on the box —
|
|
188
|
+
`--ui-focus-primary` normally and `--ui-focus-error` in the error state; the
|
|
189
|
+
toggle button has its own focus ring (see `ButtonIconInput`).
|
|
190
|
+
- **Disabled:** native `disabled` removes both the input and the toggle button
|
|
191
|
+
from the tab order; not used to convey state by color alone (the field is
|
|
192
|
+
also inert).
|
|
193
|
+
- **Contrast:** label / value / placeholder / message / border pairs come from
|
|
194
|
+
the design tokens, authored to meet WCAG contrast.
|
|
195
|
+
- **WCAG:** 1.3.1 (info/relationships), 2.1.1 (keyboard), 2.4.7 (focus
|
|
196
|
+
visible), 1.4.3 / 1.4.11 (contrast), 3.3.1 / 3.3.2 (error identification +
|
|
197
|
+
labels), 4.1.2.
|