@antadesign/anta 0.3.30 → 0.3.32

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 (50) hide show
  1. package/dist/anta_helpers.d.ts +4 -0
  2. package/dist/anta_helpers.js +10 -0
  3. package/dist/box-types.d.ts +12 -1
  4. package/dist/bundle.css +1 -1
  5. package/dist/bundle.js +140 -66
  6. package/dist/components/Box.d.ts +18 -6
  7. package/dist/components/Box.js +4 -0
  8. package/dist/components/Expander.d.ts +17 -9
  9. package/dist/components/Expander.js +14 -1
  10. package/dist/components/InputDate.js +2 -0
  11. package/dist/components/MenuItem.d.ts +9 -7
  12. package/dist/components/MenuItem.js +21 -2
  13. package/dist/components/Text.js +2 -3
  14. package/dist/components/Title.d.ts +8 -2
  15. package/dist/components/Title.js +17 -6
  16. package/dist/elements/a-box.css +1 -1
  17. package/dist/elements/a-box.d.ts +2 -0
  18. package/dist/elements/a-box.js +74 -32
  19. package/dist/elements/a-button.css +1 -1
  20. package/dist/elements/a-button.d.ts +5 -2
  21. package/dist/elements/a-calendar.js +3 -1
  22. package/dist/elements/a-copy.js +23 -3
  23. package/dist/elements/a-dialog.js +2 -0
  24. package/dist/elements/a-expander.css +1 -1
  25. package/dist/elements/a-expander.js +118 -39
  26. package/dist/elements/a-input-time.js +2 -1
  27. package/dist/elements/a-menu-item.css +1 -1
  28. package/dist/elements/a-menu.js +43 -3
  29. package/dist/elements/a-panel.css +1 -1
  30. package/dist/elements/a-panel.js +1 -1
  31. package/dist/elements/a-radio-group.js +2 -2
  32. package/dist/elements/a-slider.js +2 -2
  33. package/dist/elements/a-tabs.js +2 -2
  34. package/dist/elements/a-title.css +1 -1
  35. package/dist/elements/a-tooltip.js +1 -1
  36. package/dist/general_types.d.ts +22 -6
  37. package/dist/index.d.ts +1 -1
  38. package/dist/theme-antune.css +1 -1
  39. package/docs/changelog.md +64 -0
  40. package/docs/comparison.md +1 -1
  41. package/docs/components/box.md +81 -24
  42. package/docs/components/button.md +127 -381
  43. package/docs/components/expander.md +88 -47
  44. package/docs/components/menu.md +37 -15
  45. package/docs/components/panel.md +5 -6
  46. package/docs/components/select-faceted.md +25 -11
  47. package/docs/components/title.md +19 -0
  48. package/docs/credits.md +3 -0
  49. package/docs/packages/plot.md +234 -19
  50. package/package.json +2 -2
@@ -10,6 +10,10 @@ pixels; strings accept CSS lengths. `padding` and `margin` also accept CSS
10
10
  shorthand, such as `padding="8px 16px"` or `margin="0 auto"`. Omission adds no
11
11
  spacing styles. A bare `round` fully rounds the corners.
12
12
 
13
+ Box uses `position: relative` by default. Absolutely positioned descendants
14
+ use it as their containing block. Set `position: static` on the Box if they
15
+ should use another positioned ancestor.
16
+
13
17
  ```tsx
14
18
  <Box round={8} padding={10}><span /></Box>
15
19
  <Box display="flex" round={8} gap={6} padding={10}><span /></Box>
@@ -44,8 +48,10 @@ edges hide content while scrolling. `fade` enables both automatically.
44
48
 
45
49
  ### Fading a clipped edge
46
50
 
47
- `fade` masks edges with hidden content and removes the mask as scrolling reveals
48
- them. `fadeSize` sets its depth. It measures on connection, even off screen.
51
+ `fade` masks edges with hidden content and eases the mask as scrolling reveals
52
+ them. The mask is removed after the last edge fades out, preserving shadows and
53
+ focus rings at rest. `fadeSize` sets its depth. It measures on connection, even
54
+ off screen.
49
55
 
50
56
  ```tsx
51
57
  const TAGS = ['frontend', 'design-system', 'a11y', 'performance']
@@ -64,8 +70,9 @@ const TAGS = ['frontend', 'design-system', 'a11y', 'performance']
64
70
  .fade-demo a-tag { flex: 0 0 auto; }
65
71
  ```
66
72
 
67
- The mask clips to the padding box. It preserves the Box border, shadows, and
68
- focus ring when no edge is hidden.
73
+ The fade affects the padding box. The mask remains through its exit transition,
74
+ then disappears so shadows and focus rings are visible at rest. The easing is
75
+ disabled when reduced motion is requested.
69
76
 
70
77
  To style hidden edges without `fade`, use `observe="edges"` and the
71
78
  `hidden-start-x`, `hidden-end-x`, `hidden-start-y`, or `hidden-end-y` CSS states.
@@ -91,9 +98,14 @@ const TAGS = ['frontend', 'design-system', 'a11y', 'performance']
91
98
  ## Measurements
92
99
 
93
100
  By default, `onMeasureChange` reports one frame after observation starts, then when
94
- the border-box `width` or `height` changes. `changed` contains all fields changed
95
- since the last event; `current` is the full snapshot. Reporting pauses off screen
96
- and resumes with a fresh snapshot when Box returns.
101
+ the border-box `width` or `height` changes. `changed` contains fields
102
+ changed since the last event; `current` is the full snapshot. Reporting pauses
103
+ off screen and resumes with a fresh snapshot when Box returns.
104
+
105
+ Pass `observeOffscreen` when a virtualized layout needs measurement events or
106
+ clipping states while the Box is outside the viewport. It keeps the selected
107
+ observers active. Use `throttle` to limit reads when offscreen content changes
108
+ often.
97
109
 
98
110
  `observe` accepts one of the eight selections below, or a typed array combining
99
111
  them. `observe={['size', 'edges']}` and `observe={['edges', 'size']}` select the
@@ -134,19 +146,35 @@ When no measurement is selected, `onMeasureChange` adds `size`;
134
146
  Passing both handlers observes size and context without enabling scroll events.
135
147
  Without handlers or `fade`, omitting `observe` keeps Box idle.
136
148
 
137
- Set `throttle` to a minimum interval in milliseconds. The first report has no
138
- added delay; subsequent reports include a trailing update with the latest values.
139
- Omit it or pass `0` for frame-based reporting. Negative or non-finite values use
140
- `0`. The interval applies to `onMeasureChange`; context events are not throttled.
141
- Throttling limits event delivery; it does not reduce observer reads.
142
- `edges`, `scroll`, and `fade` continue measuring during scrolling so their
143
- CSS states remain current.
149
+ Set `throttle` to a minimum interval in milliseconds. The initial measurement
150
+ is immediate; later activity gets a trailing read with the latest values. Omit
151
+ it or pass `0` for frame-based updates. Negative or non-finite values use `0`.
152
+ The interval limits measurement reads, CSS state updates, and
153
+ `onMeasureChange` events; context events are not throttled. The
154
+ `box.measurement` getter still reads fresh values on demand.
144
155
 
145
156
  `Tooltip truncatedOnly` reads Box's clipping on demand. It works without
146
157
  `observe` or `onMeasureChange` and does not enable continuous observation.
147
158
 
148
- This readout observes `['size', 'overflow', 'edges', 'scroll']` with `throttle={100}`.
149
- Resize or scroll the Box to update it.
159
+ Pass `includeRectsFor` to add matching descendants to each measurement snapshot.
160
+ `current.rects` contains their border boxes in document order, with `top`,
161
+ `left`, `right`, and `bottom` measured from the Box's top-left border edge, plus
162
+ each match's `width` and `height`.
163
+
164
+ The selector does not start observation or add event triggers. Box reads the
165
+ rects when an existing `observe` selection reports a change. `current.rects`
166
+ always contains the latest array; `changed.rects` appears only when that array
167
+ differs from the previous report. For a fresh read at any time, use
168
+ `box.measurement.rects`.
169
+
170
+ With `observe="scroll"` and no throttle, Box can query, measure, and compare
171
+ every matching descendant on each reported frame. Keep the selector focused or
172
+ set `throttle` when many descendants match. A larger interval also delays the
173
+ fade as the reader reaches an edge.
174
+
175
+ This readout observes `['size', 'overflow', 'edges', 'scroll']` with `throttle={100}`
176
+ and `fade`. It includes the first content row in `rects`. Resize or scroll the
177
+ Box to update the values and edge mask.
150
178
 
151
179
  ```tsx title="measurechange"
152
180
  const [measurement, setMeasurement] = useState<BoxMeasurement | null>(null)
@@ -155,19 +183,25 @@ const [measurement, setMeasurement] = useState<BoxMeasurement | null>(null)
155
183
  round={8}
156
184
  className="measure-probe-box"
157
185
  observe={['size', 'overflow', 'edges', 'scroll']}
186
+ fade
187
+ includeRectsFor=".measure-probe-target"
158
188
  throttle={100}
159
189
  onMeasureChange={(_, { current }) => setMeasurement(current)}
160
190
  >
161
191
  <Text size="small" priority="tertiary">Resize or scroll this Box.</Text>
162
- <div className="measure-probe-wide">wide content, so both axes overflow</div>
192
+ <div className="measure-probe-wide measure-probe-target">wide content, so both axes overflow</div>
163
193
  <div className="measure-probe-wide">and a second line, so the vertical axis does too</div>
164
194
  <div className="measure-probe-wide">and a third</div>
165
195
  </Box>
166
196
 
167
197
  <div className="measure-probe-readout">
168
- {Object.entries(measurement ?? {}).map(([field, value]) => (
169
- <Tag key={field} size="small" label={field} value={String(value)} />
170
- ))}
198
+ {Object.entries(measurement ?? {}).map(([field, value]) => field === 'rects' && Array.isArray(value)
199
+ ? <div key={field} className="measure-probe-rects">
200
+ <Tag size="small" label="rects" value={`${value.length} match${value.length === 1 ? '' : 'es'}`} />
201
+ <pre><code>{JSON.stringify(value, null, 2)}</code></pre>
202
+ </div>
203
+ : <Tag key={field} size="small" label={field} value={String(value)} />
204
+ )}
171
205
  </div>
172
206
  ```
173
207
 
@@ -184,6 +218,8 @@ const [measurement, setMeasurement] = useState<BoxMeasurement | null>(null)
184
218
  }
185
219
  .measure-probe-wide { inline-size: 520px; padding-block: 6px; }
186
220
  .measure-probe-readout { display: flex; flex-wrap: wrap; gap: 6px; }
221
+ .measure-probe-rects { flex-basis: 100%; min-width: 0; }
222
+ .measure-probe-rects pre { margin: 4px 0 0; padding: 8px; border: 1px solid var(--border-4); border-radius: 4px; background: var(--bg-2); white-space: pre-wrap; overflow-wrap: anywhere; }
187
223
  ```
188
224
 
189
225
  See the [measurement fields](#boxmeasurement). Overflow fields map to kebab-case
@@ -284,13 +320,15 @@ const canvasRef = useRef<HTMLCanvasElement>(null)
284
320
  | `fade?` | boolean | — | Fades out every edge that currently hides clipped content, and drops the fade from an edge once the reader scrolls to it. |
285
321
  | `fadeSize?` | number \| string | 24 | Depth of the `fade` gradient. A `number` is pixels; a string is any CSS length. |
286
322
  | `gap?` | number \| string | — | Gap between children, matching the CSS `gap` property. A `number` is pixels; a string is any CSS length or two-value gap (`'1rem'`, `'8px 16px'`). Applies while the Box is a flex or grid container. |
323
+ | `includeRectsFor?` | string | — | CSS selector for descendants whose border boxes are included in `measurement.rects` when Box measures. Coordinates are relative to this Box's top-left border edge; matches are in document order. Box reads and compares matching rects for each measurement event. With `observe="scroll"`, use `throttle` when the selector matches many descendants; it also delays CSS state updates after the initial read. |
287
324
  | `margin?` | number \| string | — | Outer spacing, matching CSS `margin`. Numbers are pixels; strings accept CSS shorthand, `auto`, negative lengths, and custom properties. Omission adds no style. |
288
325
  | `observe?` | 'width' \| 'height' \| 'size' \| 'context' \| 'overflow' \| 'edges' \| 'scroll' \| 'all' \| readonly BoxObservation[] | — | One selection or an array of selections, in any order. `'size'` watches width and height; `'context'` watches rendering context; `'overflow'` watches content dimensions and clipping. `'edges'` reports which edges hide content; `'scroll'` reports offsets, potentially every frame; `'all'` selects everything. Selections are independent: use `['size', 'edges']` to combine them. A measurement handler implies `'size'` when no measurement is selected; a context handler adds `'context'`. Size skips content and scroll observers; overflow adds content observation; hidden edges and scroll add scroll reads. Without handlers or `fade`, omission stays idle. |
326
+ | `observeOffscreen?` | boolean | — | Keeps measurement events and CSS clipping states current outside the viewport. Has no effect unless `observe` or `fade` selects measurement. |
289
327
  | `onContextChange?` | (event, detail) => void | — | Fired after Box's browser and local rendering context changes. `detail` contains the changed fields and a full current snapshot. |
290
- | `onMeasureChange?` | (event, detail) => void | — | Fired when a selected measurement field changes. `detail` contains all fields changed since the last event and a full current snapshot. |
328
+ | `onMeasureChange?` | (event, detail) => void | — | Fired when a selected measurement field changes. `detail.changed` contains fields changed since the previous event; `detail.current` includes the full snapshot with matching rects. Rect changes alone do not trigger an event. |
291
329
  | `padding?` | number \| string | — | Inner spacing, matching CSS `padding`. Numbers are pixels; strings accept CSS shorthand, percentages, and custom properties. Omission adds no style. |
292
330
  | `round?` | boolean \| number \| string | — | Fully-round corners (`border-radius: 999px`, clamped to the box). Pass a `number` (px) or a CSS length string (`'1rem'`) for a custom radius. Omit for square corners. |
293
- | `throttle?` | number | 0 | Minimum interval between measurement events, in milliseconds. The first report has no added delay; a trailing report delivers the latest values. Active observers and CSS clipping states are not throttled. |
331
+ | `throttle?` | number | 0 | Minimum interval between measurements, in milliseconds. The initial measurement runs immediately; a trailing read updates CSS states and delivers the latest event. Descendant rects are read only for emitted events. The `measurement` getter always reads fresh values. |
294
332
 
295
333
  ### BoxMeasurement
296
334
 
@@ -307,6 +345,7 @@ const canvasRef = useRef<HTMLCanvasElement>(null)
307
345
  | `hiddenStartY` | boolean | — | |
308
346
  | `overflowX` | boolean | — | Content exceeds the padding box on this axis, regardless of CSS overflow. |
309
347
  | `overflowY` | boolean | — | |
348
+ | `rects` | BoxRect[] | — | Matches for `includeRectsFor`, in document order. Empty when omitted. |
310
349
  | `scrollableX` | boolean | — | The exceeded content can be scrolled by the reader on this axis. |
311
350
  | `scrollableY` | boolean | — | |
312
351
  | `scrollHeight` | number | — | |
@@ -315,6 +354,19 @@ const canvasRef = useRef<HTMLCanvasElement>(null)
315
354
  | `scrollWidth` | number | — | Full scrollable-content dimensions, matching `scrollWidth` / `scrollHeight`. |
316
355
  | `width` | number | — | Border-box width and height in CSS pixels. |
317
356
 
357
+ ### BoxRect
358
+
359
+ Coordinates and dimensions of a matched descendant's border box.
360
+
361
+ | Field | Type | Default | Description |
362
+ |------|------|---------|-------------|
363
+ | `bottom` | number | — | |
364
+ | `height` | number | — | |
365
+ | `left` | number | — | |
366
+ | `right` | number | — | |
367
+ | `top` | number | — | |
368
+ | `width` | number | — | |
369
+
318
370
  ### BoxContext
319
371
 
320
372
  | Field | Type | Default | Description |
@@ -381,7 +433,10 @@ Use `<a-box>` without JSX. Events are non-bubbling `CustomEvent`s with the same
381
433
  observation. Combine the eight selections with spaces, such as
382
434
  `observe="size edges"` or `observe="size scroll"`, in any order. Repeated tokens
383
435
  have no effect; unknown tokens are ignored. A bare `observe` means `"all"`.
384
- `throttle="100"` limits measurement events to a 100 ms interval.
436
+ `throttle="100"` limits measurement reads, CSS state updates, and measurement
437
+ events to a 100 ms interval.
438
+ Add `observe-offscreen` to keep measurement observation active outside the
439
+ viewport.
385
440
 
386
441
  ```html title="a-box"
387
442
  <a-box display="grid" gap="8px" round="12px" observe="all"
@@ -392,7 +447,9 @@ have no effect; unknown tokens are ignored. A bare `observe` means `"all"`.
392
447
  ```
393
448
 
394
449
  Import `@antadesign/anta/elements/a-box` to register the element. Listen for
395
- `measurechange` and `contextchange` with `addEventListener`.
450
+ `measurechange` and `contextchange` with `addEventListener`. Set
451
+ `include-rects-for=".marker"` to add matching descendant rects to each
452
+ measurement without changing the observation triggers.
396
453
  `box.measurement`, `box.context`, and `box.isTruncated` read values synchronously.
397
454
 
398
455
  ## Styling