@antadesign/anta 0.3.18 → 0.3.19

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.
Files changed (59) hide show
  1. package/README.md +38 -242
  2. package/dist/components/Input.d.ts +4 -1
  3. package/dist/components/Input.js +2 -0
  4. package/dist/components/InputDate.css +1 -0
  5. package/dist/components/InputDate.d.ts +1 -0
  6. package/dist/components/InputDate.js +5 -5
  7. package/dist/components/Menu.d.ts +5 -1
  8. package/dist/components/Menu.js +3 -2
  9. package/dist/components/Select.d.ts +1 -0
  10. package/dist/components/Select.js +9 -13
  11. package/dist/components/SelectFaceted.d.ts +1 -0
  12. package/dist/components/SelectFaceted.js +29 -23
  13. package/dist/components/select-parts.css +1 -0
  14. package/dist/elements/a-input.css +1 -1
  15. package/dist/elements/a-menu.js +12 -0
  16. package/dist/elements/a-slider.css +1 -1
  17. package/dist/elements/a-tabs.css +1 -1
  18. package/dist/elements/a-tabs.d.ts +3 -0
  19. package/dist/elements/a-tabs.js +40 -1
  20. package/dist/general_types.d.ts +2 -0
  21. package/dist/jsx-runtime.d.ts +9 -0
  22. package/docs/accessibility.md +34 -0
  23. package/docs/changelog.md +551 -0
  24. package/docs/colors.md +42 -0
  25. package/docs/comparison.md +28 -0
  26. package/docs/components/banner.md +267 -0
  27. package/docs/components/button.md +603 -0
  28. package/docs/components/card.md +322 -0
  29. package/docs/components/checkbox.md +297 -0
  30. package/docs/components/dialog.md +314 -0
  31. package/docs/components/expander.md +529 -0
  32. package/docs/components/icon.md +155 -0
  33. package/docs/components/input-autocomplete.md +101 -0
  34. package/docs/components/input-date.md +406 -0
  35. package/docs/components/input-time.md +174 -0
  36. package/docs/components/input.md +610 -0
  37. package/docs/components/loader.md +139 -0
  38. package/docs/components/menu.md +447 -0
  39. package/docs/components/progress.md +182 -0
  40. package/docs/components/radio.md +369 -0
  41. package/docs/components/select-faceted.md +456 -0
  42. package/docs/components/select.md +931 -0
  43. package/docs/components/slider.md +142 -0
  44. package/docs/components/switch.md +198 -0
  45. package/docs/components/tabs.md +471 -0
  46. package/docs/components/tag.md +185 -0
  47. package/docs/components/text.md +148 -0
  48. package/docs/components/title.md +146 -0
  49. package/docs/components/toaster.md +313 -0
  50. package/docs/components/tooltip.md +177 -0
  51. package/docs/credits.md +22 -0
  52. package/docs/index.md +52 -0
  53. package/docs/install-config.md +240 -0
  54. package/docs/normalization.md +105 -0
  55. package/docs/overview.md +10 -0
  56. package/docs/packages/stickers.md +187 -0
  57. package/docs/packages/table.md +153 -0
  58. package/docs/theming.md +13 -0
  59. package/package.json +10 -6
@@ -0,0 +1,174 @@
1
+ # InputTime
2
+
3
+ **`InputTime`** is a segmented wall-clock field: one boxed input, like the others,
4
+ holding separate **hour** and **minute** sections — plus an **AM/PM** section in
5
+ 12-hour locales — that behave as a single control. Each section is a native text
6
+ input:
7
+ ↑/↓ steps its value (wrapping 59 → 00), ←/→
8
+ moves between sections at the caret boundary, and typing a digit fills the section
9
+ and advances to the next once it can't hold more. AM/PM accepts its locale text or
10
+ `a` / `p`.
11
+
12
+ A leading clock icon marks the affordance (change it with `icon`). Unlike a text
13
+ `Input` (which fills its container), the field **sizes to its content** — a time
14
+ is a small, fixed control — so set a `width` (e.g. `style={{ width: '100%' }}`) if
15
+ you want it to fill. The value is a 24-hour `"HH:mm"` string (`''` until both hour
16
+ and minute are set), never a `Date`. It works controlled (`value` + `onValueChange`)
17
+ or uncontrolled (`defaultValue`), and submits under `name` via the native form APIs.
18
+
19
+ ## The field
20
+
21
+ Focus a section and edit it with the keyboard: ↑/↓ to step (it
22
+ wraps), PageUp/PageDown for a larger jump on minutes,
23
+ or just type the digits. Home/End, selection, deletion, and
24
+ paste behave as they do in a native text input. Typing
25
+ `9` then `3` `0` lands `09:30` and moves across the sections on its own; an
26
+ out-of-range digit (a `6` in the minutes) commits and advances immediately.
27
+ Backspace on an empty section selects the previous one. The whole thing
28
+ reads as one field while preserving native caret behavior. In a
29
+ 12-hour field, typing a 24-hour hour converts it and flips AM/PM — `18` becomes
30
+ `6 PM` — so pasting a 24-hour time just works.
31
+
32
+ ```tsx
33
+ <InputTime label="Start time" defaultValue="09:30" onValueChange={(_, { value }) => save(value)} />
34
+ ```
35
+
36
+ ## Locale
37
+
38
+ The clock follows the locale: `en-US` shows 12-hour with an AM/PM section, most
39
+ others show 24-hour with none. It's derived from `Intl` (the resolved `hourCycle`),
40
+ and the section **order**, the **separator**, and the **AM/PM text** all come from
41
+ the locale too — Japanese renders the period first (`午後2:05`), Finnish separates
42
+ with a dot (`14.05`), and 24-hour locales drop the AM/PM section entirely. Set
43
+ `hour12` to force one clock regardless of locale.
44
+
45
+ ```tsx
46
+ <InputTime label="US English" locale="en-US" defaultValue="14:05" /> {/* 12-hour: 02 : 05 PM */}
47
+ <InputTime label="German" locale="de-DE" defaultValue="14:05" /> {/* 24-hour: 14 : 05 */}
48
+ <InputTime label="Japanese" locale="ja-JP" hour12 defaultValue="14:05" /> {/* 午後 02:05 — period first */}
49
+ <InputTime label="Force 24h" hour12={false} defaultValue="14:05" />
50
+ ```
51
+
52
+ ## Size, status, and clearing
53
+
54
+ `size` (`small` / `medium` / `large`) matches the other inputs' scale; `status`
55
+ recolors the box and hint (only `critical` marks it invalid); `clearable` adds a
56
+ clear button once a value is set — clearing empties every section back to the
57
+ placeholder dashes. `disabled` behaves as it does on `Input`.
58
+
59
+ `min` and `max` (24-hour `"HH:mm"`) bound the value: a complete time outside the
60
+ range is clamped to the nearest bound as you step or leave the field, and flags
61
+ `rangeUnderflow` / `rangeOverflow` for form validity in the meantime.
62
+
63
+ ```tsx
64
+ <InputTime label="Meeting" size="small" defaultValue="10:00" clearable />
65
+ <InputTime label="Deadline" status="critical" hint="Pick a time in the future." />
66
+ <InputTime label="Office hours" size="large" min="09:00" max="17:00" defaultValue="09:30" />
67
+ ```
68
+
69
+ | Prop | Type | Default | Description |
70
+ |------|------|---------|-------------|
71
+ | `children?` | ReactNode | — | Extra content rendered under the field, above the hint (a no-box child like
72
+ a `<Tooltip>` takes no space and just anchors to the field). |
73
+ | `clearable?` | boolean | — | Show a clear button once the field has a value. |
74
+ | `defaultValue?` | string | — | Initial value for the uncontrolled case (24-hour `"HH:mm"`). |
75
+ | `dimActions?` | boolean | — | Dim the trailing adornments at rest; they brighten on hover / focus. |
76
+ | `disabled?` | boolean | — | Disable the field. |
77
+ | `hint?` | ReactNode | — | Message below the field. `status` recolors it and prefixes a glyph. |
78
+ | `hour12?` | boolean | — | Force the clock: `true` = 12-hour (AM/PM), `false` = 24-hour. Omit to follow
79
+ the locale. |
80
+ | `icon?` | false \| IconShape | clock | Leading icon at the start of the field — the clock affordance. Pass another
81
+ shape to change it, or `false` to drop it. |
82
+ | `label?` | ReactNode | — | Field label, shown above the control and used as the segment group's
83
+ accessible name. |
84
+ | `locale?` | string | navigator.language | BCP-47 locale driving the clock (12h vs 24h), segment order, separator, and
85
+ the AM/PM text. |
86
+ | `max?` | string | — | Latest allowed time, 24-hour `"HH:mm"`. A complete value above it is clamped
87
+ down (on step / blur) and flagged `rangeOverflow`. |
88
+ | `min?` | string | — | Earliest allowed time, 24-hour `"HH:mm"`. A complete value below it is
89
+ clamped up (on step / blur) and flagged `rangeUnderflow` for form validity. |
90
+ | `name?` | string | — | Form field name — the 24-hour value submits under this key. |
91
+ | `onBlur?` | (e) => void | — | Fires when the field loses focus. |
92
+ | `onClearInput?` | (e) => void | — | Fires after the built-in clear button has cleared the field. |
93
+ | `onFocus?` | (e) => void | — | Fires when the field gains focus. |
94
+ | `onValueChange?` | (event, attrs) => void | — | Fires on every edit (`input`), with the native event + an `attrs` snapshot
95
+ (`value`, `name`, `empty`, `valid`, `validationMessage`). Also fires on
96
+ `change` (blur) and on clear. |
97
+ | `required?` | boolean | — | Mark the field required (drives native validity). |
98
+ | `round?` | boolean \| number \| string | — | Fully-round the field, or a custom radius (`number` px / CSS length). |
99
+ | `size?` | 'small' \| 'medium' \| 'large' | medium | Size variant. small=24px, medium=28px, large=32px tall. |
100
+ | `status?` | 'neutral' \| 'brand' \| 'info' \| 'success' \| 'warning' \| 'critical' | — | Validation / feedback tone. Only `critical` marks the field invalid; the
101
+ others are advisory. Omit (or `neutral`) for a plain field. |
102
+ | `statusIcon?` | (string & {}) \| false \| IconShape | — | Glyph before the `hint` when `status` is set (per-status default; pass a
103
+ shape to override, or `false` to drop it). |
104
+ | `tone?` | string | — | Custom accent colour — any literal CSS colour tints the resting + hover
105
+ border (focus ring stays `--focus-ring`); `status` overrides for validation. |
106
+ | `trailing?` | ReactNode | — | Content pinned to the end of the field (after the clear button). |
107
+ | `value?` | string | — | Controlled value — 24-hour `"HH:mm"`. Pair with `onValueChange`. |
108
+
109
+ Use this when you are not using the React or Preact wrapper and a native HTML control does not fit: construct the equivalent Anta web component from the elements below.
110
+
111
+ Slots supply the field label and leading icon.
112
+
113
+ ```html
114
+ <a-input-time name="start-time" defaultvalue="09:30">
115
+ <span slot="label">Start time</span>
116
+ <a-icon slot="leading" shape="clock" aria-hidden="true"></a-icon>
117
+ </a-input-time>
118
+ ```
119
+
120
+ ### Native HTML time input
121
+
122
+ For a form that can use the browser's time picker, add `data-anta` to a regular
123
+ time input. It gives the field Anta's resting chrome while the browser keeps its
124
+ own picker, validation, and keyboard behavior.
125
+
126
+ `data-anta-size`, `round`, and a custom-color `tone` use the matching Input
127
+ field treatments.
128
+
129
+ ```html
130
+ <input data-anta type="time" name="reminder-at" value="09:00">
131
+ ```
132
+
133
+ ## Styling
134
+
135
+ `InputTime` renders an `<a-input-time>` whose field chrome mirrors `<a-input>`.
136
+ Route feedback color through `status`; everything else is reachable as plain CSS on
137
+ the host or through `::part()`. `segment` targets every editable input. `hour`,
138
+ `minute`, and `period` target one segment type regardless of locale order. `literal`
139
+ targets the localized separator. The element also exposes `field`, `segments`,
140
+ `leading`, `label`, `hint`, `clear`, and `trailing`. Don't override the internal
141
+ `--input-time-*` values directly; they are defaults, not a styling API.
142
+
143
+ ```css
144
+ /* Make one field fill its container (the default is content-width). Style all
145
+ editable segments, then keep AM/PM and the locale separator quieter. */
146
+ .my-time { width: 100%; }
147
+ .my-time::part(segments) { color: #e5484d; }
148
+ .my-time::part(period) { color: var(--text-3); }
149
+ .my-time::part(literal) { color: var(--text-4); }
150
+ ```
151
+
152
+ Drop the clock icon with the `icon={false}` prop, and point the `segments` part at
153
+ a monospaced family for fixed-width digits — a small `padding-top` re-centers the
154
+ tighter `1em` line:
155
+
156
+ ```tsx
157
+ <InputTime icon={false} className="plain-time" defaultValue="09:30" />
158
+
159
+ <style>{`
160
+ .plain-time::part(segments) {
161
+ font-family: var(--monospace, ui-monospace, monospace);
162
+ line-height: 1em;
163
+ padding-top: 2px;
164
+ }
165
+ `}</style>
166
+ ```
167
+
168
+ For a one-off accent, `tone` takes **any literal CSS colour** (e.g. `#7c3aed`) and
169
+ tints the resting + hover border — the focus ring stays the global ring. It's a
170
+ colour, not a named tone; the named feedback tones live on `status`.
171
+
172
+ ```tsx
173
+ <InputTime label="Accent" tone="#7c3aed" defaultValue="09:30" />
174
+ ```