@antadesign/anta 0.3.25 → 0.3.27

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 (104) hide show
  1. package/README.md +26 -28
  2. package/dist/anta_helpers.d.ts +4 -0
  3. package/dist/anta_helpers.js +17 -3
  4. package/dist/box-types.d.ts +161 -0
  5. package/dist/box-types.js +0 -0
  6. package/dist/bundle.css +1 -1
  7. package/dist/bundle.js +25 -25
  8. package/dist/capture-types.d.ts +156 -0
  9. package/dist/capture-types.js +0 -0
  10. package/dist/components/Box.d.ts +52 -0
  11. package/dist/components/Box.js +55 -0
  12. package/dist/components/Capture.d.ts +39 -0
  13. package/dist/components/Capture.js +36 -0
  14. package/dist/components/capture-props.d.ts +30 -0
  15. package/dist/components/capture-props.js +44 -0
  16. package/dist/elements/a-avatar.css +1 -1
  17. package/dist/elements/a-banner.css +1 -1
  18. package/dist/elements/a-banner.js +4 -4
  19. package/dist/elements/a-box.css +1 -0
  20. package/dist/elements/a-box.d.ts +41 -0
  21. package/dist/elements/a-box.js +584 -0
  22. package/dist/elements/a-button.css +1 -1
  23. package/dist/elements/a-calendar.js +2 -2
  24. package/dist/elements/a-capture.css +1 -0
  25. package/dist/elements/a-capture.d.ts +10 -0
  26. package/dist/elements/a-capture.js +24 -0
  27. package/dist/elements/a-card.css +1 -1
  28. package/dist/elements/a-checkbox.css +1 -1
  29. package/dist/elements/a-checkbox.js +4 -4
  30. package/dist/elements/a-dialog.css +1 -1
  31. package/dist/elements/a-expander.css +1 -1
  32. package/dist/elements/a-expander.js +2 -2
  33. package/dist/elements/a-input-time.css +1 -1
  34. package/dist/elements/a-input-time.js +3 -3
  35. package/dist/elements/a-input.css +1 -1
  36. package/dist/elements/a-input.js +6 -6
  37. package/dist/elements/a-menu-item.css +1 -1
  38. package/dist/elements/a-menu-item.js +3 -3
  39. package/dist/elements/a-menu.css +1 -1
  40. package/dist/elements/a-menu.js +2 -2
  41. package/dist/elements/a-radio-group.js +3 -3
  42. package/dist/elements/a-radio.css +1 -1
  43. package/dist/elements/a-slider.css +1 -1
  44. package/dist/elements/a-slider.js +6 -6
  45. package/dist/elements/a-switch.css +1 -1
  46. package/dist/elements/a-switch.js +2 -2
  47. package/dist/elements/a-tabpanel.js +2 -2
  48. package/dist/elements/a-tabs.css +1 -1
  49. package/dist/elements/a-tabs.js +6 -6
  50. package/dist/elements/a-tag.css +1 -1
  51. package/dist/elements/a-text.css +1 -1
  52. package/dist/elements/a-title.css +1 -1
  53. package/dist/elements/a-toast.js +2 -2
  54. package/dist/elements/a-tooltip.css +1 -1
  55. package/dist/elements/a-tooltip.d.ts +4 -3
  56. package/dist/elements/a-tooltip.js +9 -5
  57. package/dist/elements/capture-input.d.ts +5 -0
  58. package/dist/elements/capture-input.js +609 -0
  59. package/dist/elements/index.d.ts +2 -0
  60. package/dist/elements/index.js +6 -0
  61. package/dist/general_types.d.ts +70 -0
  62. package/dist/index.d.ts +6 -0
  63. package/dist/index.js +4 -0
  64. package/dist/jsx-runtime.d.ts +3 -1
  65. package/docs/accessibility.md +24 -0
  66. package/docs/changelog.md +45 -3
  67. package/docs/colors.md +141 -0
  68. package/docs/comparison.md +463 -28
  69. package/docs/components/avatar.md +364 -0
  70. package/docs/components/banner.md +13 -27
  71. package/docs/components/box.md +354 -0
  72. package/docs/components/breadcrumbs.md +7 -6
  73. package/docs/components/button.md +48 -37
  74. package/docs/components/capture.md +345 -0
  75. package/docs/components/card.md +17 -38
  76. package/docs/components/checkbox.md +16 -39
  77. package/docs/components/dialog.md +14 -36
  78. package/docs/components/expander.md +15 -40
  79. package/docs/components/icon.md +111 -9
  80. package/docs/components/input-autocomplete.md +9 -11
  81. package/docs/components/input-date.md +33 -23
  82. package/docs/components/input-time.md +15 -23
  83. package/docs/components/input.md +27 -76
  84. package/docs/components/loader.md +7 -5
  85. package/docs/components/menu.md +73 -77
  86. package/docs/components/progress.md +10 -14
  87. package/docs/components/radio.md +17 -36
  88. package/docs/components/select-faceted.md +7 -25
  89. package/docs/components/select.md +24 -97
  90. package/docs/components/slider.md +16 -21
  91. package/docs/components/steps.md +38 -8
  92. package/docs/components/switch.md +11 -14
  93. package/docs/components/tabs.md +52 -40
  94. package/docs/components/tag.md +11 -22
  95. package/docs/components/text.md +10 -23
  96. package/docs/components/title.md +7 -8
  97. package/docs/components/toaster.md +6 -3
  98. package/docs/components/tooltip.md +13 -23
  99. package/docs/index.md +6 -3
  100. package/docs/install-config.md +24 -0
  101. package/docs/normalization.md +45 -0
  102. package/docs/packages/stickers.md +56 -0
  103. package/docs/theming.md +270 -0
  104. package/package.json +3 -1
package/README.md CHANGED
@@ -7,34 +7,32 @@ components in React, Preact via compat, plain HTML, and custom JSX runtimes via
7
7
 
8
8
  ## Documentation for coding agents
9
9
 
10
- Start with [`./docs/index.md`](./docs/index.md). This path is relative to the
11
- root of the installed Anta package, not to the consuming application.
12
-
13
- This package includes version-specific documentation inside the installed npm
14
- package.
15
-
16
- Example:
17
-
18
- ```text
19
- node_modules/
20
- └── @antadesign/
21
- └── anta/
22
- ├── README.md
23
- ├── docs/
24
- │ ├── index.md
25
- │ ├── install-config.md
26
- │ ├── theming.md
27
- │ └── components/
28
- │ ├── button.md
29
- │ ├── dialog.md
30
- │ └── ...
31
- └── dist/
10
+ The package includes version-matched Markdown documentation. Start with the
11
+ [documentation index](./docs/index.md) and open the pages relevant to your task.
12
+ Agents with filesystem access can read these files offline.
13
+
14
+ ### AI setup
15
+
16
+ Append this section to your application's agent instruction file, such as
17
+ `AGENTS.md`, `CLAUDE.md`, or your tool's equivalent. Keep existing project rules:
18
+
19
+ ```md
20
+ ## Anta
21
+
22
+ Before Anta UI work, read
23
+ `node_modules/@antadesign/anta/docs/index.md`
24
+ and the pages relevant to the task.
25
+ Verify component names, imports, props, and event signatures against the
26
+ installed documentation and TypeScript declarations. Do not infer Anta APIs
27
+ from similarly named components in other libraries.
32
28
  ```
33
29
 
34
- When working with Anta components:
30
+ The path is relative to the application directory where Anta is installed.
31
+ Adjust it for your workspace or package-manager layout. Installing Anta does
32
+ not modify your agent configuration.
33
+
34
+ If a documented type differs from the installed `.d.ts` declarations, use the
35
+ declarations for the installed API.
35
36
 
36
- 1. Read `./docs/index.md` from the installed `@antadesign/anta` package.
37
- 2. Open only the documentation relevant to the component or feature you are using.
38
- 3. Do **not** guess component names, props, or behavior from similarly named component libraries (e.g. MUI, Chakra UI, Radix UI, Mantine, shadcn/ui, Ant Design, etc.).
39
- 4. Use the installed package's TypeScript declarations (`*.d.ts`) as the source of truth for the installed package version.
40
- 5. If the Markdown documentation and TypeScript declarations disagree, prefer the TypeScript declarations, as they always correspond to the installed version.
37
+ For tools without local file access, provide the [web documentation index](https://anta.design/llms.txt)
38
+ and your installed Anta version. Web documentation may describe a newer release.
@@ -53,6 +53,10 @@ export declare function nativeStateChange<D>(e: StateChangeEvent<D>): {
53
53
  detail?: D;
54
54
  isOwn: boolean;
55
55
  };
56
+ /** Adapt a callback to native or renderer-wrapped custom events with non-null detail. */
57
+ export declare function customEventHandler<D>(handler?: (event: CustomEvent<D>, detail: D) => void): ((input: StateChangeEvent<D>) => void) | undefined;
58
+ /** Parse a finite number, falling back for missing, empty, or invalid values. */
59
+ export declare function finiteNumber(value: string | number | null, fallback: number): number;
56
60
  export declare const IS_MAC: boolean;
57
61
  /** Default row hint teaching the Alt/⌥-click "select only this" accelerator on
58
62
  * bulk-select rows (`Select` multiple, `SelectFaceted` multiple facets). Shared
@@ -24,6 +24,18 @@ function nativeStateChange(e) {
24
24
  const event = "nativeEvent" in e ? e.nativeEvent : e;
25
25
  return { event, detail: event?.detail, isOwn: !event || event.target === event.currentTarget };
26
26
  }
27
+ function customEventHandler(handler) {
28
+ if (!handler) return void 0;
29
+ return (input) => {
30
+ const { event, detail } = nativeStateChange(input);
31
+ if (detail != null) handler(event, detail);
32
+ };
33
+ }
34
+ function finiteNumber(value, fallback) {
35
+ if (value == null || value === "") return fallback;
36
+ const number = Number(value);
37
+ return Number.isFinite(number) ? number : fallback;
38
+ }
27
39
  const IS_MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/i.test(navigator.userAgent || "");
28
40
  const ISOLATE_HINT = IS_MAC ? "\u2325+Click to select only this" : "Alt+Click to select only this";
29
41
  function parseOpenState(v) {
@@ -119,7 +131,7 @@ class SelectableChildElement extends HTMLElementBase {
119
131
  if (name === "selected") this.applyState(this.hasAttribute("selected"));
120
132
  }
121
133
  get selected() {
122
- return this.internals?.states.has("selected") ?? false;
134
+ return this.internals?.states?.has("selected") ?? false;
123
135
  }
124
136
  /**
125
137
  * Live selection, held off the DOM as `:state(selected)` (mirrored to `ariaProp`).
@@ -147,8 +159,8 @@ class SelectableChildElement extends HTMLElementBase {
147
159
  }
148
160
  applyState(on) {
149
161
  if (!this.internals) return;
150
- if (on) this.internals.states.add("selected");
151
- else this.internals.states.delete("selected");
162
+ if (on) this.internals?.states?.add("selected");
163
+ else this.internals?.states?.delete("selected");
152
164
  this.internals[this.ariaProp] = on ? "true" : "false";
153
165
  }
154
166
  }
@@ -160,6 +172,8 @@ export {
160
172
  SelectableChildElement,
161
173
  anchorRect,
162
174
  cssLength,
175
+ customEventHandler,
176
+ finiteNumber,
163
177
  hasChildren,
164
178
  installDismissTrigger,
165
179
  isInsideOpenMenu,
@@ -0,0 +1,161 @@
1
+ /** Display modes supplied by `Box`. The element is a real light-DOM CSS box,
2
+ * so every other layout property remains ordinary CSS on the host. */
3
+ export type BoxDisplay = 'block' | 'inline-block' | 'flex' | 'inline-flex' | 'grid' | 'inline-grid';
4
+ /** Color mode resolved from the closest `.light` or `.dark` ancestor. */
5
+ export type BoxMode = 'light' | 'dark';
6
+ /** Operating-system family. Anta deliberately does not expose a user-agent string. */
7
+ export type BoxOS = 'android' | 'ios' | 'linux' | 'macos' | 'windows' | 'unknown';
8
+ /** Browser family. */
9
+ export type BoxBrowser = 'chrome' | 'edge' | 'firefox' | 'opera' | 'safari' | 'unknown';
10
+ /** Primary pointing-device capability reported by the browser. */
11
+ export type BoxPointer = 'fine' | 'coarse' | 'none';
12
+ /** Current state that affects a box's rendering or interaction decisions. */
13
+ /**
14
+ * Distance from the box's border edge to its content edge, in CSS pixels.
15
+ *
16
+ * Not derivable from `BoxMeasurement`: `width` / `height` are the border box and
17
+ * `clientWidth` / `clientHeight` are the padding box, so neither the padding nor
18
+ * the border thickness can be recovered from them. Add a padding and its border
19
+ * to place content relative to the border box.
20
+ */
21
+ export interface BoxInset {
22
+ paddingTop: number;
23
+ paddingRight: number;
24
+ paddingBottom: number;
25
+ paddingLeft: number;
26
+ borderTop: number;
27
+ borderRight: number;
28
+ borderBottom: number;
29
+ borderLeft: number;
30
+ }
31
+ /**
32
+ * The box's resolved text style, shaped to configure a canvas 2D context.
33
+ *
34
+ * Assign `shorthand` to `ctx.font` **first**: Chromium and Firefox reset
35
+ * `fontStretch`, `fontVariantCaps`, `fontKerning` and `textRendering` when
36
+ * `font` is assigned, so setting those before it loses them.
37
+ */
38
+ export interface BoxFont {
39
+ /** CSS `font` shorthand, assembled here because every engine returns an empty
40
+ * string for the computed shorthand. `stretch` and `variantCaps` are left out
41
+ * of it deliberately: a percentage `font-stretch` makes every engine reject
42
+ * the whole string and fall back to `10px sans-serif`. Apply those through
43
+ * `ctx.fontStretch` / `ctx.fontVariantCaps` after setting `ctx.font`. */
44
+ shorthand: string;
45
+ /** Resolved family list, quoted as the engine reports it. */
46
+ family: string;
47
+ /** Font size in CSS pixels. */
48
+ size: number;
49
+ /** Numeric weight, 1-1000. */
50
+ weight: number;
51
+ /** `normal`, `italic`, or an `oblique <angle>`. */
52
+ style: string;
53
+ /** Computed `font-stretch`, a percentage such as `88%`. Canvas: `ctx.fontStretch`. */
54
+ stretch: string;
55
+ /** Line height in CSS pixels, or `null` when it computes to `normal`. Canvas
56
+ * ignores line height in `ctx.font`; this is for laying text out yourself. */
57
+ lineHeight: number | null;
58
+ /** A length, never `normal` - `normal` is reported as `0px`, which is what
59
+ * `ctx.letterSpacing` accepts. */
60
+ letterSpacing: string;
61
+ /** Same normalization as `letterSpacing`. Canvas: `ctx.wordSpacing`. */
62
+ wordSpacing: string;
63
+ /** Resolved text color. Canvas: `ctx.fillStyle`. */
64
+ color: string;
65
+ /** Canvas 2D consumes neither of these. They are here for text you measure or
66
+ * draw some other way. */
67
+ featureSettings: string;
68
+ variationSettings: string;
69
+ /** Canvas: `ctx.fontKerning`. */
70
+ kerning: string;
71
+ /** Canvas: `ctx.fontVariantCaps`. */
72
+ variantCaps: string;
73
+ /** Canvas: `ctx.textRendering`, which WebKit does not implement. */
74
+ textRendering: string;
75
+ /** Canvas: `ctx.direction`. */
76
+ direction: string;
77
+ }
78
+ export interface BoxContext {
79
+ /** Closest scoped Anta mode. A local `.light` can override a dark document. */
80
+ mode: BoxMode;
81
+ /** Mode on `<html>`, independent of an enclosing local scope. */
82
+ globalMode: BoxMode;
83
+ /** Browser / operating-system color preference, independent of Anta classes. */
84
+ systemAppearance: BoxMode;
85
+ /** Whether focus is on the box or any of its descendants, read from the
86
+ * native `:focus-within`. For CSS, use that pseudo-class directly; this field
87
+ * is for logic that cannot query the DOM. */
88
+ focusWithin: boolean;
89
+ /** Operating-system family. */
90
+ os: BoxOS;
91
+ /** Operating-system major version, or `0` when the browser withholds it.
92
+ * Browsers freeze this: every engine reports macOS as `10.15.7` and Windows 11
93
+ * as `10.0`, so only Android and iOS carry a real number. Treat it as a hint,
94
+ * never as a gate. */
95
+ osVersion: number;
96
+ /** Browser family. */
97
+ browser: BoxBrowser;
98
+ /** Browser major version, or `0` when unknown. Minor and patch digits are
99
+ * frozen by every engine, so only the major number is reported. */
100
+ browserVersion: number;
101
+ /** Whether the browser reports a mobile device. */
102
+ mobile: boolean;
103
+ /** Most precise available primary pointer. */
104
+ pointer: BoxPointer;
105
+ /** Whether ordinary hover interaction is available. */
106
+ hover: boolean;
107
+ /** Whether the reader asks for reduced motion. */
108
+ reducedMotion: boolean;
109
+ /** `window.devicePixelRatio`: CSS pixels per device pixel. `1` on a standard
110
+ * display, `2` on most Retina screens, and a fraction under OS or browser
111
+ * zoom. Live — it re-reports on zoom and when the window moves to a monitor
112
+ * with a different density. */
113
+ devicePixelRatio: number;
114
+ /** Resolved text style, ready to hand to a canvas 2D context. */
115
+ font: BoxFont;
116
+ /** Padding and border widths, for placing content inside the border box. */
117
+ inset: BoxInset;
118
+ /** Resolved `background-color`. Needed when the box's content is drawn
119
+ * somewhere else — an offscreen canvas, a worker, an export — where the box's
120
+ * own background is not behind it. */
121
+ backgroundColor: string;
122
+ }
123
+ /** Current box dimensions and its content-overflow state. */
124
+ export interface BoxMeasurement {
125
+ /** Border-box width and height in CSS pixels. */
126
+ width: number;
127
+ height: number;
128
+ /** Padding-box dimensions, matching the browser's `clientWidth` / `clientHeight`. */
129
+ clientWidth: number;
130
+ clientHeight: number;
131
+ /** Full scrollable-content dimensions, matching `scrollWidth` / `scrollHeight`. */
132
+ scrollWidth: number;
133
+ scrollHeight: number;
134
+ /** Content exceeds the padding box on this axis, regardless of CSS overflow. */
135
+ overflowX: boolean;
136
+ overflowY: boolean;
137
+ /** The exceeded content is visually clipped on this axis. */
138
+ clippedX: boolean;
139
+ clippedY: boolean;
140
+ /** The exceeded content can be scrolled by the reader on this axis. */
141
+ scrollableX: boolean;
142
+ scrollableY: boolean;
143
+ /** Current scroll offset, matching `scrollLeft` / `scrollTop`. */
144
+ scrollLeft: number;
145
+ scrollTop: number;
146
+ /** Clipped content sits past this specific edge, in logical writing-mode
147
+ * terms. A clipped box that has not been scrolled hides content past its end
148
+ * edge only; scroll it to the end and the hidden content moves to the start.
149
+ * These drive the `fade` mask. */
150
+ hiddenStartX: boolean;
151
+ hiddenEndX: boolean;
152
+ hiddenStartY: boolean;
153
+ hiddenEndY: boolean;
154
+ }
155
+ /** Box observation events include changed fields and a complete current snapshot. */
156
+ export interface BoxChange<T> {
157
+ changed: Partial<T>;
158
+ current: T;
159
+ }
160
+ export type BoxContextChange = BoxChange<BoxContext>;
161
+ export type BoxMeasurementChange = BoxChange<BoxMeasurement>;
File without changes