@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.
- package/dist/anta_helpers.d.ts +4 -0
- package/dist/anta_helpers.js +10 -0
- package/dist/box-types.d.ts +12 -1
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +140 -66
- package/dist/components/Box.d.ts +18 -6
- package/dist/components/Box.js +4 -0
- package/dist/components/Expander.d.ts +17 -9
- package/dist/components/Expander.js +14 -1
- package/dist/components/InputDate.js +2 -0
- package/dist/components/MenuItem.d.ts +9 -7
- package/dist/components/MenuItem.js +21 -2
- package/dist/components/Text.js +2 -3
- package/dist/components/Title.d.ts +8 -2
- package/dist/components/Title.js +17 -6
- package/dist/elements/a-box.css +1 -1
- package/dist/elements/a-box.d.ts +2 -0
- package/dist/elements/a-box.js +74 -32
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-button.d.ts +5 -2
- package/dist/elements/a-calendar.js +3 -1
- package/dist/elements/a-copy.js +23 -3
- package/dist/elements/a-dialog.js +2 -0
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.js +118 -39
- package/dist/elements/a-input-time.js +2 -1
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu.js +43 -3
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +1 -1
- package/dist/elements/a-radio-group.js +2 -2
- package/dist/elements/a-slider.js +2 -2
- package/dist/elements/a-tabs.js +2 -2
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-tooltip.js +1 -1
- package/dist/general_types.d.ts +22 -6
- package/dist/index.d.ts +1 -1
- package/dist/theme-antune.css +1 -1
- package/docs/changelog.md +64 -0
- package/docs/comparison.md +1 -1
- package/docs/components/box.md +81 -24
- package/docs/components/button.md +127 -381
- package/docs/components/expander.md +88 -47
- package/docs/components/menu.md +37 -15
- package/docs/components/panel.md +5 -6
- package/docs/components/select-faceted.md +25 -11
- package/docs/components/title.md +19 -0
- package/docs/credits.md +3 -0
- package/docs/packages/plot.md +234 -19
- package/package.json +2 -2
package/docs/components/box.md
CHANGED
|
@@ -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
|
|
48
|
-
them.
|
|
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
|
|
68
|
-
focus
|
|
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
|
|
95
|
-
since the last event; `current` is the full snapshot. Reporting pauses
|
|
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
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
`
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
<
|
|
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
|
|
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
|
|
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
|
|
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
|