@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.
Files changed (184) hide show
  1. package/LICENSE.md +14 -1
  2. package/README.md +9 -0
  3. package/dist/anta_helpers.d.ts +46 -30
  4. package/dist/anta_helpers.js +66 -25
  5. package/dist/bundle.css +1 -1
  6. package/dist/bundle.js +2 -1333
  7. package/dist/components/Banner.d.ts +25 -40
  8. package/dist/components/Banner.js +15 -17
  9. package/dist/components/Button.js +1 -0
  10. package/dist/components/ButtonCopy.js +3 -2
  11. package/dist/components/Calendar.js +13 -13
  12. package/dist/components/Card.d.ts +9 -17
  13. package/dist/components/Card.js +50 -46
  14. package/dist/components/Dialog.d.ts +1 -0
  15. package/dist/components/Dialog.js +16 -10
  16. package/dist/components/Expander.d.ts +6 -21
  17. package/dist/components/Expander.js +24 -23
  18. package/dist/components/Icon.d.ts +8 -14
  19. package/dist/components/Input.d.ts +77 -96
  20. package/dist/components/Input.js +23 -27
  21. package/dist/components/InputAutocomplete.d.ts +29 -10
  22. package/dist/components/InputAutocomplete.js +25 -8
  23. package/dist/components/InputDate.js +2 -2
  24. package/dist/components/InputTime.d.ts +10 -4
  25. package/dist/components/InputTime.js +20 -16
  26. package/dist/components/Loader.d.ts +2 -2
  27. package/dist/components/Menu.d.ts +5 -4
  28. package/dist/components/Menu.js +13 -8
  29. package/dist/components/MenuItem.js +1 -14
  30. package/dist/components/MenuItemCopy.js +2 -2
  31. package/dist/components/Panel.d.ts +3 -1
  32. package/dist/components/Panel.js +17 -11
  33. package/dist/components/Progress.d.ts +21 -23
  34. package/dist/components/Progress.js +13 -9
  35. package/dist/components/RadioGroup.js +6 -8
  36. package/dist/components/{select-parts.css → Select.css} +1 -1
  37. package/dist/components/Select.d.ts +53 -35
  38. package/dist/components/Select.js +53 -97
  39. package/dist/components/SelectFaceted.d.ts +7 -3
  40. package/dist/components/SelectFaceted.js +21 -9
  41. package/dist/components/Slider.d.ts +28 -11
  42. package/dist/components/Slider.js +20 -20
  43. package/dist/components/Steps.css +1 -1
  44. package/dist/components/Steps.js +1 -11
  45. package/dist/components/Tabs.d.ts +17 -20
  46. package/dist/components/Tabs.js +5 -8
  47. package/dist/components/Text.d.ts +55 -36
  48. package/dist/components/Text.js +35 -22
  49. package/dist/components/Title.d.ts +16 -26
  50. package/dist/components/Title.js +2 -1
  51. package/dist/components/Toaster.js +9 -2
  52. package/dist/components/Tooltip.d.ts +10 -15
  53. package/dist/components/copy-props.d.ts +14 -3
  54. package/dist/components/copy-props.js +14 -3
  55. package/dist/components/select-tree.d.ts +24 -0
  56. package/dist/components/select-tree.js +35 -0
  57. package/dist/element-base.d.ts +10 -0
  58. package/dist/element-base.js +15 -0
  59. package/dist/elements/a-banner.css +1 -1
  60. package/dist/elements/a-banner.d.ts +4 -1
  61. package/dist/elements/a-banner.js +22 -112
  62. package/dist/elements/a-button.d.ts +2 -1
  63. package/dist/elements/a-button.js +18 -1
  64. package/dist/elements/a-calendar.d.ts +14 -13
  65. package/dist/elements/a-calendar.js +29 -24
  66. package/dist/elements/a-card.css +1 -1
  67. package/dist/elements/a-card.d.ts +0 -9
  68. package/dist/elements/a-card.js +0 -184
  69. package/dist/elements/a-checkbox.css +1 -1
  70. package/dist/elements/a-copy.css +1 -1
  71. package/dist/elements/a-copy.d.ts +1 -5
  72. package/dist/elements/a-copy.js +129 -108
  73. package/dist/elements/a-dialog.css +1 -1
  74. package/dist/elements/a-dialog.d.ts +1 -1
  75. package/dist/elements/a-dialog.js +66 -194
  76. package/dist/elements/a-expander.css +1 -1
  77. package/dist/elements/a-expander.d.ts +4 -30
  78. package/dist/elements/a-expander.js +85 -344
  79. package/dist/elements/a-icon.d.ts +5 -23
  80. package/dist/elements/a-icon.js +1 -2
  81. package/dist/elements/a-input-time.css +1 -1
  82. package/dist/elements/a-input-time.d.ts +2 -1
  83. package/dist/elements/a-input-time.js +101 -168
  84. package/dist/elements/a-input.css +1 -1
  85. package/dist/elements/a-input.d.ts +10 -8
  86. package/dist/elements/a-input.js +155 -230
  87. package/dist/elements/a-loader.d.ts +5 -8
  88. package/dist/elements/a-loader.js +1 -2
  89. package/dist/elements/a-menu-item.css +1 -1
  90. package/dist/elements/a-menu-item.d.ts +5 -3
  91. package/dist/elements/a-menu-item.js +5 -1
  92. package/dist/elements/a-menu.css +1 -1
  93. package/dist/elements/a-menu.d.ts +5 -7
  94. package/dist/elements/a-menu.js +383 -299
  95. package/dist/elements/a-panel.css +1 -1
  96. package/dist/elements/a-panel.js +19 -37
  97. package/dist/elements/a-progress.css +1 -1
  98. package/dist/elements/a-progress.d.ts +0 -22
  99. package/dist/elements/a-progress.js +0 -100
  100. package/dist/elements/a-radio-group.d.ts +1 -1
  101. package/dist/elements/a-radio-group.js +6 -4
  102. package/dist/elements/a-select-faceted.d.ts +1 -1
  103. package/dist/elements/a-select-faceted.js +1 -1
  104. package/dist/elements/a-select.d.ts +1 -1
  105. package/dist/elements/a-select.js +1 -1
  106. package/dist/elements/a-slider.css +1 -1
  107. package/dist/elements/a-slider.d.ts +11 -3
  108. package/dist/elements/a-slider.js +244 -242
  109. package/dist/elements/a-switch.css +1 -1
  110. package/dist/elements/a-tab.css +1 -1
  111. package/dist/elements/a-tabs.css +1 -1
  112. package/dist/elements/a-tabs.d.ts +1 -1
  113. package/dist/elements/a-tabs.js +6 -4
  114. package/dist/elements/a-tag.css +1 -1
  115. package/dist/elements/a-text.css +1 -1
  116. package/dist/elements/a-text.d.ts +6 -43
  117. package/dist/elements/a-text.js +110 -193
  118. package/dist/elements/a-title.css +1 -1
  119. package/dist/elements/a-toast.css +1 -1
  120. package/dist/elements/a-toast.d.ts +10 -45
  121. package/dist/elements/a-toast.js +80 -66
  122. package/dist/elements/a-toaster.css +1 -1
  123. package/dist/elements/a-toaster.js +9 -44
  124. package/dist/elements/a-tooltip.css +1 -1
  125. package/dist/elements/a-tooltip.d.ts +1 -1
  126. package/dist/elements/a-tooltip.js +142 -136
  127. package/dist/elements/copy-behavior.d.ts +1 -1
  128. package/dist/elements/copy-behavior.js +21 -21
  129. package/dist/elements/index.d.ts +3 -3
  130. package/dist/elements/index.js +3 -7
  131. package/dist/elements/input-focus-modality.d.ts +15 -0
  132. package/dist/elements/input-focus-modality.js +44 -0
  133. package/dist/elements/input-trailing-actions.d.ts +5 -0
  134. package/dist/elements/input-trailing-actions.js +38 -0
  135. package/dist/elements/shadow-aria.d.ts +2 -0
  136. package/dist/elements/shadow-aria.js +2 -1
  137. package/dist/elements/value-input.d.ts +3 -0
  138. package/dist/elements/value-input.js +12 -0
  139. package/dist/general_types.d.ts +103 -96
  140. package/dist/index.d.ts +1 -1
  141. package/dist/input-events.d.ts +4 -0
  142. package/dist/input-events.js +15 -0
  143. package/dist/jsx-runtime.d.ts +70 -23
  144. package/dist/jsx-runtime.js +26 -19
  145. package/dist/native-event-props.d.ts +2 -0
  146. package/dist/native-event-props.js +10 -0
  147. package/dist/reset.css +1 -1
  148. package/dist/theme-antithesis.css +10 -1
  149. package/dist/theme-antune.css +1 -1
  150. package/docs/accessibility.md +17 -3
  151. package/docs/changelog.md +348 -2
  152. package/docs/comparison.md +2 -2
  153. package/docs/components/avatar.md +5 -0
  154. package/docs/components/banner.md +117 -187
  155. package/docs/components/button.md +22 -0
  156. package/docs/components/card.md +74 -28
  157. package/docs/components/checkbox.md +9 -10
  158. package/docs/components/dialog.md +83 -32
  159. package/docs/components/expander.md +198 -435
  160. package/docs/components/icon.md +11 -17
  161. package/docs/components/input-autocomplete.md +152 -52
  162. package/docs/components/input-date.md +175 -148
  163. package/docs/components/input-time.md +81 -38
  164. package/docs/components/input.md +343 -349
  165. package/docs/components/loader.md +2 -1
  166. package/docs/components/menu.md +35 -6
  167. package/docs/components/panel.md +18 -0
  168. package/docs/components/progress.md +83 -49
  169. package/docs/components/radio.md +39 -43
  170. package/docs/components/select-faceted.md +54 -7
  171. package/docs/components/select.md +390 -386
  172. package/docs/components/slider.md +136 -19
  173. package/docs/components/steps.md +2 -1
  174. package/docs/components/switch.md +8 -9
  175. package/docs/components/tabs.md +110 -104
  176. package/docs/components/text.md +110 -86
  177. package/docs/components/title.md +47 -33
  178. package/docs/components/toaster.md +242 -84
  179. package/docs/components/tooltip.md +204 -113
  180. package/docs/install-config.md +183 -26
  181. package/docs/packages/plot.md +170 -148
  182. package/docs/theming.md +7 -0
  183. package/package.json +41 -3
  184. package/theme-antithesis-license.md +66 -0
@@ -2,7 +2,9 @@
2
2
 
3
3
  Checkboxes let users select one or more items from a set, or toggle an option on or off. Use them for multiple independent choices; for a single immediate setting, use a switch instead.
4
4
 
5
- The `Checkbox` wrapper renders an `<a-checkbox>` element that manages its own state. It works both controlled and uncontrolled with `checked` / `defaultChecked` (boolean or `'indeterminate'`) and `onStateChange` for updates.
5
+ Use `defaultChecked` for an initial choice, or pair `checked` with
6
+ `onStateChange` to control it. Pass `'indeterminate'` for a mixed selection,
7
+ such as a parent checkbox whose children have different states.
6
8
 
7
9
  ## Tone
8
10
 
@@ -163,11 +165,9 @@ function ParentChild() {
163
165
 
164
166
  ## Accessibility
165
167
 
166
- The wrapper sets `role="checkbox"`, and the element keeps `aria-checked`
167
- (`"true"` / `"false"` / `"mixed"`) in sync. Its light-DOM label supplies the
168
- accessible name and its hint supplies the accessible description through
169
- `ElementInternals`; no generated IDs are needed. For a label-less checkbox, pass
170
- `aria-label`.
168
+ The label names the checkbox for screen readers, and the hint supplies its
169
+ description. Without a visible label, pass `aria-label`. Screen readers
170
+ announce the current state.
171
171
 
172
172
  Space toggles the checkbox. Follows the [WAI-ARIA checkbox pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/).
173
173
 
@@ -192,10 +192,9 @@ Space toggles the checkbox. Follows the [WAI-ARIA checkbox pattern](https://www.
192
192
 
193
193
  ## Web Component
194
194
 
195
- Use the web component directly when you are not using React or Preact and a native control does not fit.
196
-
197
- The focusable host carries the state. Label and hint are light-DOM children that
198
- the element exposes as its accessible name and description.
195
+ Use `<a-checkbox>` directly outside JSX. Set `role="checkbox"` and `tabindex="0"`
196
+ for keyboard access. Its label and hint supply the accessible name and
197
+ description.
199
198
 
200
199
  ```html
201
200
  <a-checkbox role="checkbox" tabindex="0" name="updates" default-state="checked">
@@ -1,14 +1,8 @@
1
1
  # Dialog
2
2
 
3
- A modal dialog: content that opens above a dimmed overlay and holds focus until
4
- it's dismissed. The `Dialog` wrapper renders an `<a-dialog>` whose shadow DOM
5
- wraps a native `<dialog>`, so the top layer (which escapes any `overflow` or
6
- stacking context on the page), the focus trap, focus return on close, the
7
- backdrop, and Esc all come from the platform.
8
-
9
- It has three optional zones: a `header`, the body (`children`), and a `footer`,
10
- plus a close button in the top-right corner. Set `position` to make it an edge
11
- drawer instead.
3
+ Dialog opens content above a dimmed backdrop and keeps focus inside until it
4
+ closes. It has optional header and footer regions, a scrollable body, and a close
5
+ button. Set `position` to use an edge drawer.
12
6
 
13
7
  ## Zones
14
8
 
@@ -19,21 +13,21 @@ when there are no actions. The footer lays its content out in a right-aligned
19
13
  row.
20
14
 
21
15
  ```tsx
22
- const [open, setOpen] = useState(false)
23
-
24
- <Button onClick={() => setOpen(true)}>Open dialog</Button>
16
+ <Button data-dialog-open="zones">Open dialog</Button>
25
17
  <Dialog
26
- open={open}
27
- onStateChange={(_e, { next }) => setOpen(next)}
18
+ name="zones"
28
19
  header={<Title level={4}>Enable telemetry?</Title>}
29
20
  footer={
30
21
  <>
31
- <Button onClick={() => setOpen(false)}>Not now</Button>
32
- <Button priority="primary" onClick={() => setOpen(false)}>Enable</Button>
22
+ <Button data-dialog-close="zones">Not now</Button>
23
+ <Button priority="primary" data-dialog-close="zones">Enable</Button>
33
24
  </>
34
25
  }
35
26
  >
36
- <Text>Anonymous usage data helps us find the bugs that matter.</Text>
27
+ <Text>
28
+ Anonymous usage data helps us find the bugs that matter. You can change
29
+ this any time in settings.
30
+ </Text>
37
31
  </Dialog>
38
32
  ```
39
33
 
@@ -64,10 +58,9 @@ that thickness. Resize it with a position-scoped `::part(dialog)` rule (see
64
58
 
65
59
  ## Rounding corners
66
60
 
67
- The centered modal is rounded by default (10px) and drawers are square. `round`
68
- overrides that. A **side keyword** rounds only that edge's two corners, which
69
- pairs with a drawer's exposed edge: a bottom sheet takes `round="top"`, a right
70
- drawer `round="left"`.
61
+ The theme sets the centered modal's default corners. Drawers are square unless
62
+ you pass `round`. A **side keyword** rounds only that edge's two corners: a bottom
63
+ sheet takes `round="top"`, a right drawer `round="left"`.
71
64
 
72
65
  ```tsx
73
66
  <Dialog round={0}>…</Dialog> {/* unrounded centered modal */}
@@ -79,10 +72,9 @@ drawer `round="left"`.
79
72
 
80
73
  A `number` or CSS string sets the amount on all corners; the string may be a full
81
74
  `border-radius` shorthand, so `round="12px 12px 0 0"` rounds just the top by 12px
82
- (a side keyword with a custom amount). Bare `round` rounds all corners at the
83
- default 10px, handy to round an otherwise-square drawer. Authoring the raw
84
- `<a-dialog>`, a single length works through the typed `attr()` (`round="20px"`);
85
- shorthands go through the wrapper's `round` prop.
75
+ (a side keyword with a custom amount). Bare `round` rounds all corners, including
76
+ on a drawer. For raw `<a-dialog>`, use a single length (`round="20px"`). Use the
77
+ wrapper's `round` prop for shorthands.
86
78
 
87
79
  ## Close button
88
80
 
@@ -174,10 +166,22 @@ state: the dialog reopens if `open` is still true. Drive closing through your
174
166
  state, setting `open` to `false` in `onStateChange`.
175
167
 
176
168
  ```tsx
177
- // controlled
178
169
  const [open, setOpen] = useState(false)
179
- <Button onClick={() => setOpen(true)}>Open</Button>
180
- <Dialog open={open} onStateChange={(_e, { next }) => setOpen(next)}>…</Dialog>
170
+
171
+ <Button onClick={() => setOpen(true)}>Open dialog</Button>
172
+ <Dialog
173
+ open={open}
174
+ onStateChange={(_e, { next }) => setOpen(next)}
175
+ header={<Title level={4}>Enable telemetry?</Title>}
176
+ footer={
177
+ <>
178
+ <Button onClick={() => setOpen(false)}>Not now</Button>
179
+ <Button priority="primary" onClick={() => setOpen(false)}>Enable</Button>
180
+ </>
181
+ }
182
+ >
183
+ <Text>Anonymous usage data helps us find the bugs that matter.</Text>
184
+ </Dialog>
181
185
 
182
186
  // uncontrolled, veto the close while there are unsaved changes
183
187
  <Dialog defaultOpen onStateChange={(e, { next }) => {
@@ -223,8 +227,23 @@ On close, focus returns to whatever opened the dialog, from the native `<dialog>
223
227
 
224
228
  Use the web component directly when you are not using React or Preact and a native control does not fit.
225
229
 
226
- Slots hold the header, footer, and close control. Add `tabindex="0"` to every
227
- raw `<a-button>`.
230
+ Slots hold the header, footer, and close control. JSX uses boxless
231
+ `a-dialog-footer` and `a-dialog-close` groups. Raw authors can use those groups
232
+ or assign controls directly to the slots. Existing slot markup remains supported.
233
+
234
+ The element owns the shadow-native dialog and its runtime state. The native
235
+ `<dialog>` supplies top-layer placement, backdrop, focus containment, focus
236
+ restoration, and Escape handling. It escapes ancestor clipping and stacking
237
+ contexts. The element leaves host attributes and authored children unchanged. Load the element stylesheet
238
+ with the granular entry or load `bundle.css` with the full bundle. Default
239
+ layout and transitions require no injected styles or fixed inline styles.
240
+ Load CSS before opening a dialog, including one with `defaultOpen`. Without it,
241
+ the native modal remains visible and closable, but Anta's layout, boxless region
242
+ groups, close-control placement, and animations are unavailable.
243
+ Application-supplied `style` props and custom `round` amounts can still produce
244
+ style attributes blocked by `style-src-attr 'none'`.
245
+
246
+ Add `tabindex="0"` to every raw `<a-button>`.
228
247
 
229
248
  ```html
230
249
  <a-button role="button" tabindex="0" data-dialog-open="invite"><a-button-label>Invite teammates</a-button-label></a-button>
@@ -246,9 +265,38 @@ radius). For everything else, style the shadow **parts** in plain CSS.
246
265
 
247
266
  `<a-dialog>` exposes `::part(dialog)` (the surface), `::part(header)`,
248
267
  `::part(body)`, `::part(footer)`, `::part(close)`, and `::part(dialog)::backdrop`
249
- (the overlay). A `::part` rule wins over the element's internal styles with no
268
+ (the overlay). Defaults live in external CSS. An unlayered consumer rule
269
+ overrides them with no
250
270
  `!important`, so the surface, size, radius, shadow, overlay, and zone padding are
251
- all reachable.
271
+ all reachable. Keep visibility and motion overrides scoped to
272
+ `::part(dialog):modal`; setting `display` on the base part can reveal a closed
273
+ dialog. The native dialog controls closing independently of CSS transitions.
274
+ Entry and exit effects follow the browser's existing `@starting-style`, display,
275
+ and overlay-transition support; reduced motion disables Anta's transitions.
276
+ Surface fades require `::part(dialog):open` support; otherwise the surface stays
277
+ visible without fading. Backdrop fades separately require
278
+ `::part(dialog):modal::backdrop`, keeping static styling when unavailable.
279
+
280
+ Defaults belong to `anta.components`, within the layer order
281
+ `base, anta, components, utilities`. Put consumer overrides in `components`,
282
+ `utilities`, or unlayered CSS. Overrides in the earlier `base` layer lose to
283
+ Anta's defaults. Previously, outer part rules took precedence over the internal
284
+ shadow stylesheet regardless of their layer.
285
+
286
+ Optional regions expose CSS states on the host without adding attributes or
287
+ changing part names. Each state is present when its slot has assigned nodes:
288
+
289
+ | State selector | Assigned slot |
290
+ | --- | --- |
291
+ | `a-dialog:state(has-header)` | `header` |
292
+ | `a-dialog:state(has-footer)` | `footer` |
293
+
294
+ The header, or the body when no header is present, reserves `52px` of inline-end
295
+ padding for a close control. The example increases the header clearance to
296
+ `64px` when `:has(> [slot="close"])` matches. This selector reads the authored
297
+ close-slot markup directly. Firefox can leave clearance stale when an existing
298
+ child's `slot` attribute changes into or out of `close`; adding or removing a
299
+ close child updates normally.
252
300
 
253
301
  **Scope the rule to a position (or a class).** A bare `a-dialog::part(dialog)`
254
302
  hits every dialog, drawers included, where a `width` override would collapse a
@@ -266,6 +314,9 @@ a-dialog.styled-dialog::part(dialog) {
266
314
  a-dialog.styled-dialog::part(dialog)::backdrop {
267
315
  background: color-mix(in oklch, black 60%, transparent);
268
316
  }
317
+ a-dialog.styled-dialog:has(> [slot="close"])::part(header) {
318
+ padding-inline-end: 64px;
319
+ }
269
320
  ```
270
321
 
271
322
  More recipes. The centered modal's max size is the viewport minus a 32px edge