@antadesign/anta 0.3.2 → 0.3.3

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 (92) hide show
  1. package/dist/anta_helpers.d.ts +101 -0
  2. package/dist/anta_helpers.js +77 -0
  3. package/dist/calendar-core.d.ts +126 -0
  4. package/dist/calendar-core.js +289 -0
  5. package/dist/components/Button.d.ts +9 -1
  6. package/dist/components/Button.js +5 -2
  7. package/dist/components/Calendar.d.ts +80 -0
  8. package/dist/components/Calendar.js +220 -0
  9. package/dist/components/Checkbox.d.ts +16 -11
  10. package/dist/components/Checkbox.js +13 -7
  11. package/dist/components/Expander.d.ts +7 -1
  12. package/dist/components/Expander.js +4 -2
  13. package/dist/components/Input.d.ts +13 -5
  14. package/dist/components/Input.js +14 -6
  15. package/dist/components/InputDate.d.ts +87 -0
  16. package/dist/components/InputDate.js +278 -0
  17. package/dist/components/InputDate.module.css +1 -0
  18. package/dist/components/Menu.d.ts +5 -1
  19. package/dist/components/Menu.js +6 -2
  20. package/dist/components/MenuItem.d.ts +48 -7
  21. package/dist/components/MenuItem.js +71 -7
  22. package/dist/components/MenuSeparator.d.ts +13 -2
  23. package/dist/components/MenuSeparator.js +12 -2
  24. package/dist/components/Progress.d.ts +4 -1
  25. package/dist/components/Progress.js +4 -3
  26. package/dist/components/RadioGroup.d.ts +12 -10
  27. package/dist/components/RadioGroup.js +5 -5
  28. package/dist/components/Select.d.ts +255 -0
  29. package/dist/components/Select.js +290 -0
  30. package/dist/components/Select.module.css +1 -0
  31. package/dist/components/Tab.d.ts +3 -0
  32. package/dist/components/Tab.js +2 -1
  33. package/dist/components/TabPanel.js +2 -1
  34. package/dist/components/Tabs.d.ts +18 -1
  35. package/dist/components/Tabs.js +8 -6
  36. package/dist/components/Tag.d.ts +10 -9
  37. package/dist/components/Tag.js +2 -2
  38. package/dist/components/Text.d.ts +6 -5
  39. package/dist/components/Title.d.ts +4 -2
  40. package/dist/components/Tooltip.d.ts +4 -1
  41. package/dist/components/Tooltip.js +5 -0
  42. package/dist/elements/a-button.css +1 -1
  43. package/dist/elements/a-calendar.css +1 -0
  44. package/dist/elements/a-calendar.d.ts +76 -0
  45. package/dist/elements/a-calendar.js +190 -0
  46. package/dist/elements/a-checkbox.css +1 -1
  47. package/dist/elements/a-checkbox.d.ts +1 -2
  48. package/dist/elements/a-checkbox.js +5 -5
  49. package/dist/elements/a-expander.css +1 -1
  50. package/dist/elements/a-expander.d.ts +16 -5
  51. package/dist/elements/a-expander.js +59 -8
  52. package/dist/elements/a-icon.shapes.css +1 -1
  53. package/dist/elements/a-icon.shapes.d.ts +6 -1
  54. package/dist/elements/a-icon.shapes.js +9 -0
  55. package/dist/elements/a-input.css +1 -1
  56. package/dist/elements/a-input.d.ts +6 -0
  57. package/dist/elements/a-input.js +27 -8
  58. package/dist/elements/a-menu-group.css +1 -1
  59. package/dist/elements/a-menu-item.css +1 -1
  60. package/dist/elements/a-menu-item.d.ts +14 -4
  61. package/dist/elements/a-menu-item.js +17 -0
  62. package/dist/elements/a-menu-separator.css +1 -1
  63. package/dist/elements/a-menu.css +1 -1
  64. package/dist/elements/a-menu.d.ts +51 -8
  65. package/dist/elements/a-menu.js +285 -42
  66. package/dist/elements/a-progress.css +1 -1
  67. package/dist/elements/a-radio-group.d.ts +1 -3
  68. package/dist/elements/a-radio-group.js +13 -13
  69. package/dist/elements/a-radio.css +1 -1
  70. package/dist/elements/a-radio.d.ts +3 -11
  71. package/dist/elements/a-radio.js +3 -34
  72. package/dist/elements/a-tab.css +1 -1
  73. package/dist/elements/a-tab.d.ts +3 -11
  74. package/dist/elements/a-tab.js +3 -34
  75. package/dist/elements/a-tabs.css +1 -1
  76. package/dist/elements/a-tabs.d.ts +1 -4
  77. package/dist/elements/a-tabs.js +14 -14
  78. package/dist/elements/a-tag.css +1 -1
  79. package/dist/elements/a-text.d.ts +14 -13
  80. package/dist/elements/a-text.js +53 -23
  81. package/dist/elements/a-tooltip.css +1 -1
  82. package/dist/elements/a-tooltip.d.ts +1 -11
  83. package/dist/elements/a-tooltip.js +20 -19
  84. package/dist/elements/index.d.ts +1 -0
  85. package/dist/elements/index.js +3 -0
  86. package/dist/general_types.d.ts +127 -31
  87. package/dist/index.d.ts +9 -1
  88. package/dist/index.js +37 -1
  89. package/dist/jsx-runtime.d.ts +16 -7
  90. package/dist/jsx-runtime.js +6 -0
  91. package/dist/reset.css +1 -1
  92. package/package.json +4 -2
@@ -1,4 +1,4 @@
1
- import { HTMLElementBase } from "../anta_helpers";
1
+ import { HTMLElementBase, anchorRect, isMenuOpen, isInsideOpenMenu } from "../anta_helpers";
2
2
  import { debounce } from "es-toolkit";
3
3
  import "./a-tooltip.css";
4
4
  const MARGIN = 4;
@@ -164,10 +164,10 @@ class ATooltipElement extends HTMLElementBase {
164
164
  this.bubble.setAttribute("part", "bubble");
165
165
  this.container.append(this.bubble);
166
166
  this.container.addEventListener("mouseenter", () => {
167
- if (this.isInteractive) this.cancelHide();
167
+ if (this.#isInteractive) this.cancelHide();
168
168
  });
169
169
  this.container.addEventListener("mouseleave", () => {
170
- if (this.isInteractive && this.shown) this.scheduleHide();
170
+ if (this.#isInteractive && this.shown) this.scheduleHide();
171
171
  });
172
172
  shadow.append(style, this.container);
173
173
  }
@@ -197,23 +197,23 @@ class ATooltipElement extends HTMLElementBase {
197
197
  * onto an anchor after the tooltip was dismissed re-arms it. */
198
198
  makeDebouncedShow() {
199
199
  this.debouncedShow?.cancel();
200
- this.debouncedShow = debounce((e) => this.show(e), this.delay);
200
+ this.debouncedShow = debounce((e) => this.show(e), this.#delay);
201
201
  }
202
- get isInteractive() {
202
+ get #isInteractive() {
203
203
  return this.hasAttribute("interactive");
204
204
  }
205
205
  /** Pinned under the anchor (no cursor-following) — the DEFAULT. Following the
206
206
  * cursor is opt-in via the `follow` attribute. `interactive` (you can't move
207
207
  * into a bubble that chases the cursor) and a touch long-press (a finger
208
208
  * can't track one) force pinned regardless of `follow`. */
209
- get isPinned() {
210
- if (this.isInteractive || this.touchOpen) return true;
209
+ get #isPinned() {
210
+ if (this.#isInteractive || this.touchOpen) return true;
211
211
  return !this.hasAttribute("follow");
212
212
  }
213
- get prefersTop() {
213
+ get #prefersTop() {
214
214
  return this.getAttribute("placement") === "top";
215
215
  }
216
- get delay() {
216
+ get #delay() {
217
217
  const attr = this.getAttribute("delay");
218
218
  if (attr == null) return DEFAULT_DELAY;
219
219
  const n = parseInt(attr, 10);
@@ -222,7 +222,7 @@ class ATooltipElement extends HTMLElementBase {
222
222
  // --- truncated-only gating (UI-thread layout READS — no mutation) ---
223
223
  /** When set, the tooltip only shows if its resolved target is actually
224
224
  * truncated/clipped; a fitting label gets no tooltip. */
225
- get truncatedOnly() {
225
+ get #truncatedOnly() {
226
226
  return this.hasAttribute("truncated-only");
227
227
  }
228
228
  /** The element whose overflow decides whether the tooltip shows: a
@@ -294,10 +294,10 @@ class ATooltipElement extends HTMLElementBase {
294
294
  positionToTarget = () => {
295
295
  this.schedulePosition(() => {
296
296
  if (!this.anchor || !this.shown) return;
297
- const a = this.anchor.getBoundingClientRect();
297
+ const a = anchorRect(this.anchor);
298
298
  const box = this.container.getBoundingClientRect();
299
299
  const { innerWidth: vw, innerHeight: vh } = this.view;
300
- const top = this.flipVertical(a.top - box.height - MARGIN, a.bottom + MARGIN, box.height, vh, this.prefersTop || this.touchOpen);
300
+ const top = this.flipVertical(a.top - box.height - MARGIN, a.bottom + MARGIN, box.height, vh, this.#prefersTop || this.touchOpen);
301
301
  this.place(a.left, top, box.width, vw);
302
302
  });
303
303
  };
@@ -306,12 +306,12 @@ class ATooltipElement extends HTMLElementBase {
306
306
  if (!this.shown && !this.fading) return;
307
307
  const box = this.container.getBoundingClientRect();
308
308
  const { innerWidth: vw, innerHeight: vh } = this.view;
309
- const top = this.flipVertical(e.clientY - box.height - MARGIN * 2, e.clientY + CURSOR_SIZE, box.height, vh, this.prefersTop);
309
+ const top = this.flipVertical(e.clientY - box.height - MARGIN * 2, e.clientY + CURSOR_SIZE, box.height, vh, this.#prefersTop);
310
310
  this.place(e.clientX - PADDING_X, top, box.width, vw);
311
311
  });
312
312
  };
313
313
  position(e) {
314
- if (!this.isPinned && e) this.positionToMouse(e);
314
+ if (!this.#isPinned && e) this.positionToMouse(e);
315
315
  else this.positionToTarget();
316
316
  }
317
317
  /** Opacity for the inner bubble from the cursor's distance to the anchor rect
@@ -319,7 +319,7 @@ class ATooltipElement extends HTMLElementBase {
319
319
  * Cursor-follow only — drives the "fade as you move away" behaviour. */
320
320
  proximityOpacity(e) {
321
321
  if (!this.anchor) return 1;
322
- const r = this.anchor.getBoundingClientRect();
322
+ const r = anchorRect(this.anchor);
323
323
  const dx = Math.max(r.left - e.clientX, 0, e.clientX - r.right);
324
324
  const dy = Math.max(r.top - e.clientY, 0, e.clientY - r.bottom);
325
325
  const dist = Math.hypot(dx, dy);
@@ -330,8 +330,9 @@ class ATooltipElement extends HTMLElementBase {
330
330
  // --- show / hide ---
331
331
  show = (e) => {
332
332
  if (!this.anchor) return;
333
+ if (isMenuOpen() && !isInsideOpenMenu(this.anchor)) return;
333
334
  if (this.isEmpty()) return;
334
- if (this.truncatedOnly && !this.isTargetTruncated()) return;
335
+ if (this.#truncatedOnly && !this.isTargetTruncated()) return;
335
336
  this.cancelHide();
336
337
  if (currentOpen && currentOpen !== this && this.anchor.contains(currentOpen.anchor)) {
337
338
  return;
@@ -408,7 +409,7 @@ class ATooltipElement extends HTMLElementBase {
408
409
  this.cleanup();
409
410
  return;
410
411
  }
411
- if (!(this.shown || this.fading) || this.isPinned) return;
412
+ if (!(this.shown || this.fading) || this.#isPinned) return;
412
413
  this.lastMouse = e;
413
414
  const o = this.proximityOpacity(e);
414
415
  if (o === 0) {
@@ -444,7 +445,7 @@ class ATooltipElement extends HTMLElementBase {
444
445
  * show with the latest cursor event. */
445
446
  trigger(e) {
446
447
  if (this.isEmpty()) return;
447
- if (this.truncatedOnly && !this.isTargetTruncated()) return;
448
+ if (this.#truncatedOnly && !this.isTargetTruncated()) return;
448
449
  if (isHot()) {
449
450
  this.debouncedShow?.cancel();
450
451
  this.show(e);
@@ -466,7 +467,7 @@ class ATooltipElement extends HTMLElementBase {
466
467
  if (e.pointerType !== "mouse") return;
467
468
  this.lastMouse = e;
468
469
  if (this.shown) {
469
- if (!this.isPinned) this.positionToMouse(e);
470
+ if (!this.#isPinned) this.positionToMouse(e);
470
471
  } else {
471
472
  this.trigger(e);
472
473
  }
@@ -21,6 +21,7 @@ export { ACheckboxElement, register_a_checkbox } from './a-checkbox';
21
21
  export { AExpanderElement, register_a_expander } from './a-expander';
22
22
  export { ATooltipElement, register_a_tooltip } from './a-tooltip';
23
23
  export { AInputElement, register_a_input } from './a-input';
24
+ export { ACalendarElement, register_a_calendar } from './a-calendar';
24
25
  export { ARadioElement, register_a_radio } from './a-radio';
25
26
  export { ARadioGroupElement, register_a_radio_group } from './a-radio-group';
26
27
  export { AMenuElement, register_a_menu } from './a-menu';
@@ -6,6 +6,7 @@ import { ACheckboxElement, register_a_checkbox } from "./a-checkbox";
6
6
  import { AExpanderElement, register_a_expander } from "./a-expander";
7
7
  import { ATooltipElement, register_a_tooltip } from "./a-tooltip";
8
8
  import { AInputElement, register_a_input } from "./a-input";
9
+ import { ACalendarElement, register_a_calendar } from "./a-calendar";
9
10
  import { ARadioElement, register_a_radio } from "./a-radio";
10
11
  import { ARadioGroupElement, register_a_radio_group } from "./a-radio-group";
11
12
  import { AMenuElement, register_a_menu } from "./a-menu";
@@ -19,6 +20,7 @@ import "./a-tag.css";
19
20
  import "./a-tabpanel.css";
20
21
  export {
21
22
  AButtonElement,
23
+ ACalendarElement,
22
24
  ACheckboxElement,
23
25
  AExpanderElement,
24
26
  AIconElement,
@@ -35,6 +37,7 @@ export {
35
37
  ATextElement,
36
38
  ATooltipElement,
37
39
  register_a_button,
40
+ register_a_calendar,
38
41
  register_a_checkbox,
39
42
  register_a_expander,
40
43
  register_a_icon,
@@ -13,6 +13,9 @@ export interface BaseProps {
13
13
  title?: string;
14
14
  /** Tab order. Set to `-1` to skip the element when tabbing. */
15
15
  tabIndex?: number;
16
+ /** React/Preact reconciliation key when rendered inside a list. Consumed by the
17
+ * JSX runtime (not forwarded as a DOM attribute). */
18
+ key?: string | number | null;
16
19
  /** Any `data-*` attribute is forwarded to the rendered element. */
17
20
  [key: `data-${string}`]: unknown;
18
21
  /** Any `aria-*` attribute is forwarded to the rendered element. */
@@ -145,6 +148,9 @@ export interface AProgressAttributes extends BaseAttributes {
145
148
  /** Colour variant, or any literal CSS colour for a custom tone (derived in
146
149
  * oklch). Named tones track light/dark automatically. */
147
150
  tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
151
+ /** Fully-round track (`border-radius: 999px`), or a custom radius via a length
152
+ * value (`round="6px"`). Presence-based for the boolean form. */
153
+ round?: boolean | number | string;
148
154
  /** ARIA role — the JSX wrapper sets this to `'progressbar'`. */
149
155
  role?: string;
150
156
  /** ARIA value-now (current). */
@@ -165,8 +171,9 @@ export interface AProgressAttributes extends BaseAttributes {
165
171
  export interface ATextAttributes extends BaseAttributes {
166
172
  /** Visual priority. Maps to text-1..text-5. */
167
173
  priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
168
- /** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
169
- tone?: 'brand' | 'info' | 'success' | 'warning' | 'critical';
174
+ /** Color tint. `neutral` (default) is the untinted `--text-{N}` scale;
175
+ * the others apply the matching `--text-{N}-{tone}` palette. */
176
+ tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical';
170
177
  /** Type scale. `small` = 13/16, `medium` (default) = 15/20, `large` = 17/24. */
171
178
  size?: 'small' | 'medium' | 'large';
172
179
  /** Render as inline-block instead of the default block. */
@@ -198,8 +205,9 @@ export interface ATitleAttributes extends BaseAttributes {
198
205
  level?: string;
199
206
  /** Visual priority. Maps to text-1..text-5. */
200
207
  priority?: 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary';
201
- /** Color tint. Applies the matching `--text-{N}-{tone}` palette. */
202
- tone?: 'brand' | 'info' | 'success' | 'warning' | 'critical';
208
+ /** Color tint. `neutral` (default) is the untinted `--text-{N}` scale;
209
+ * the others apply the matching `--text-{N}-{tone}` palette. */
210
+ tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical';
203
211
  /** ARIA role — the JSX wrapper sets this to `'heading'`. */
204
212
  role?: string;
205
213
  /** ARIA heading level — the JSX wrapper sets this to match `level`. */
@@ -224,9 +232,9 @@ export interface ATagAttributes extends BaseAttributes {
224
232
  /** Size variant. `small` = 16px tall, `medium` (default) = 20px,
225
233
  * `large` = 24px. */
226
234
  size?: 'small' | 'medium' | 'large';
227
- /** Render in normal case instead of the default uppercase.
235
+ /** Render in all-caps instead of the default normal (mixed) case.
228
236
  * Presence-based (`''` on, omit off). */
229
- nocaps?: boolean | '';
237
+ allcaps?: boolean | '';
230
238
  }
231
239
  /**
232
240
  * Attributes for the `<a-expander>` collapsible disclosure.
@@ -258,6 +266,11 @@ export interface AExpanderAttributes extends BaseAttributes {
258
266
  /** Disables the header: not clickable or focusable, hover affordance
259
267
  * off, text dimmed. The open state freezes as-is. Presence-based. */
260
268
  disabled?: boolean | '';
269
+ /** Round corners sized to half the folded (header) height — a pill when folded,
270
+ * the same radius when expanded (the element measures the header and publishes
271
+ * `--_expander-round-radius`). A length value (`round="12px"`) is a fixed radius
272
+ * that overrides the measurement. Presence-based for the boolean form. */
273
+ round?: boolean | number | string;
261
274
  /** Semantic tone, or any literal CSS color for a one-off custom tone.
262
275
  * Named tones re-point the text + filled surface palette; a custom
263
276
  * color keeps its hue with lightness/chroma pinned. `'neutral'` is the
@@ -326,6 +339,9 @@ export interface ATooltipAttributes extends BaseAttributes {
326
339
  * nearest Anta ellipsizing label part (`a-tab-label` / `a-button-label`) in the
327
340
  * anchor, then the anchor itself. Presence-based (`''` on, omit off). */
328
341
  'truncated-only'?: boolean | '';
342
+ /** Round the bubble (20px radius), or a custom radius via a length value
343
+ * (`round="12px"`). Presence-based for the boolean form. */
344
+ round?: boolean | number | string;
329
345
  /** CSS selector (resolved within the anchor) for the element whose overflow a
330
346
  * `truncated-only` tooltip measures. */
331
347
  'truncated-selector'?: string;
@@ -343,15 +359,15 @@ export interface ATooltipAttributes extends BaseAttributes {
343
359
  * `@antadesign/anta`.
344
360
  */
345
361
  export interface ACheckboxAttributes extends BaseAttributes {
346
- /** Mark colour (checked fill + unselected box border), or any literal CSS color
347
- * for a one-off custom tone. Named tones track light/dark mode automatically via
348
- * the theme-aware role tokens. `'neutral'` is the default (same as omitting it).
349
- * The label + hint stay neutral use `tone-text` for those. */
362
+ /** Mark colour in every state — checked fill *and* unselected box border or any
363
+ * literal CSS color for a one-off custom tone. Named tones track light/dark mode
364
+ * automatically. `'neutral'` is the default (same as omitting it). The label + hint
365
+ * stay neutral recolour them in plain CSS via the `--text-N-{tone}` tokens. */
350
366
  tone?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
351
- /** Text colour (label + hint), independent of `tone`. A named tone or any literal
352
- * CSS color; named tones track light/dark via the `--text-*` role tokens. Omit
353
- * (or `'neutral'`) to leave the text neutral. */
354
- 'tone-text'?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
367
+ /** Like `tone`, but coloured onto the checked mark only the empty box stays
368
+ * neutral grey. Same value set as `tone`; if both are set, `tone` governs the
369
+ * off-state border and `tone-selected` the checked fill. */
370
+ 'tone-selected'?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
355
371
  /** Size variant. `small` = 14px, `medium` (default) = 16px, `large` = 18px box. */
356
372
  size?: 'small' | 'medium' | 'large';
357
373
  /** Controlled state — the element reflects changes to this attribute. Use this
@@ -363,6 +379,9 @@ export interface ACheckboxAttributes extends BaseAttributes {
363
379
  'default-state'?: 'checked' | 'unchecked' | 'indeterminate';
364
380
  /** Disabled state. Presence-based (`''` on, omit off). */
365
381
  disabled?: boolean | '';
382
+ /** Round the mark to a circle (`::before` `border-radius: 999px`), or a rounded
383
+ * square via a length value (`round="5px"`). Presence-based for the boolean form. */
384
+ round?: boolean | number | string;
366
385
  /** Form field name — the key this checkbox submits under inside a `<form>`. */
367
386
  name?: string;
368
387
  /** Value submitted when checked. Defaults to `"on"`. */
@@ -423,6 +442,9 @@ export interface AInputAttributes extends BaseAttributes {
423
442
  /** Dim the leading/trailing adornments at rest (0.6); they brighten to full
424
443
  * when the field is hovered or focused. Presence-based. */
425
444
  'dim-actions'?: boolean | '';
445
+ /** Fully-round field (`border-radius: 999px`), or a custom radius via a length
446
+ * value (`round="10px"`). Presence-based for the boolean form. */
447
+ round?: boolean | number | string;
426
448
  /** Size variant. small=24px, medium (default)=28px, large=32px. */
427
449
  size?: 'small' | 'medium' | 'large';
428
450
  /** Single-line input type (ignored when multiline). `search` is intentionally
@@ -456,6 +478,60 @@ export interface AInputAttributes extends BaseAttributes {
456
478
  'aria-invalid'?: 'true' | 'false' | boolean;
457
479
  'aria-label'?: string;
458
480
  }
481
+ /**
482
+ * Attributes for the `<a-calendar>` custom element — a **light-DOM,
483
+ * form-associated** month grid, and the **interaction authority** for it. The
484
+ * element is the grid (a flat 7-column CSS grid whose children are the weekday
485
+ * headers + day cells), owns the submitted form value, and **dispatches the
486
+ * selection (`statechange` / `change`) and navigation (`navigate`) events** plus
487
+ * manages keyboard focus — so it works for a vanilla consumer, not only via the
488
+ * wrapper. It does **not** build or mutate its own contents: whoever renders into
489
+ * it (the `Calendar` JSX wrapper, or a vanilla consumer using the exported
490
+ * `buildMonth` engine) fills it with day cells and *re-renders on its events* —
491
+ * the `<a-radio-group>` model. Controlled by the presence of `value` (a pick only
492
+ * *requests* a change); uncontrolled with `defaultvalue` (a pick self-applies).
493
+ * For the typed, batteries-included wrapper use `Calendar` from `@antadesign/anta`.
494
+ *
495
+ * `:state(filled)` is the styling hook for "has a selection".
496
+ */
497
+ export interface ACalendarAttributes extends BaseAttributes {
498
+ /** Controlled selected date — ISO `YYYY-MM-DD`. Present → controlled (a pick
499
+ * only requests a change). Mirrored to the owning form via `ElementInternals`. */
500
+ value?: string;
501
+ /** Uncontrolled initial date / reset baseline — ISO `YYYY-MM-DD`. */
502
+ defaultvalue?: string;
503
+ /** Form field name — the selected ISO date submits under this key. */
504
+ name?: string;
505
+ /** Disable the whole calendar. Presence-based (`''` on, omit off). */
506
+ disabled?: boolean | '';
507
+ /** Focus signal — `"<iso>#<nonce>"`. When it changes, the element focuses the
508
+ * day cell whose `data-date` matches `<iso>` (set by the renderer after a
509
+ * month-changing keyboard move). */
510
+ 'data-focus'?: string;
511
+ /** Cancelable, bubbling `statechange` fired BEFORE a pick applies. `detail` is
512
+ * `{ next, prev, reason }` — ISO strings (or `null`); `reason` ∈
513
+ * `'user' | 'reset' | 'restore'`. `preventDefault()` vetoes a `'user'` pick in
514
+ * uncontrolled mode. */
515
+ onstatechange?: (e: CustomEvent<{
516
+ next: string | null;
517
+ prev: string | null;
518
+ reason: 'user' | 'reset' | 'restore';
519
+ }>) => void;
520
+ /** Native `change`, fired AFTER a selection applies (uncontrolled) and on
521
+ * reset/restore. */
522
+ onchange?: (e: Event) => void;
523
+ /** Keyboard navigation request — the element handles arrow / Home / End /
524
+ * PageUp / PageDown, focuses the target cell when it's rendered, and emits this
525
+ * bubbling `navigate` `CustomEvent` (`detail: { date }`, ISO) so the renderer can
526
+ * move the roving tab stop and flip the displayed month when needed. */
527
+ onnavigate?: (e: CustomEvent<{
528
+ date: string;
529
+ }>) => void;
530
+ /** ARIA — `role="group"` and the accessible name are set by the renderer (the
531
+ * `Calendar` wrapper wires `aria-labelledby` to the month heading). */
532
+ 'aria-label'?: string;
533
+ 'aria-labelledby'?: string;
534
+ }
459
535
  /**
460
536
  * Attributes for the `<a-menu>` custom element. Placed immediately after the
461
537
  * trigger it anchors to (root menu), or nested inside an `<a-menu-item>`
@@ -476,6 +552,10 @@ export interface AMenuAttributes extends BaseAttributes {
476
552
  * default; this opts out, making the submenu click-only. Presence-based
477
553
  * (`''` on, omit off). */
478
554
  nohover?: boolean | '';
555
+ /** Round: container softens to a 20px radius and its items go fully round. A
556
+ * length value (`round="12px"`) tunes the container radius only (items stay
557
+ * pills). Presence-based for the boolean form. */
558
+ round?: boolean | number | string;
479
559
  /** Gap in pixels between the trigger and the menu. Defaults to 4. */
480
560
  offset?: number | string;
481
561
  /** Controlled open state (`'open'` / `'closed'`). Omit for uncontrolled;
@@ -503,9 +583,15 @@ export interface AMenuAttributes extends BaseAttributes {
503
583
  export interface AMenuItemAttributes extends BaseAttributes {
504
584
  /** Disabled state. Presence-based (`''` on, omit off). */
505
585
  disabled?: boolean | '';
506
- /** Semantic tone. Colors the label, icon, and hover tint. `'neutral'`
507
- * (the default) is the same as omitting it. */
508
- tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical';
586
+ /** Marks the item as selected a persistent background tint (the same
587
+ * resting look a pressed row shows), for building single- / multi-select
588
+ * menus. Presence-based (`''` on, omit off). */
589
+ selected?: boolean | '';
590
+ /** Semantic tone. Colors the label, icon, and hover/selected tint. A named tone,
591
+ * or any literal CSS color for a one-off custom tone (resolved through
592
+ * `--menu-item-tone-source`, hue/chroma kept, lightness pinned to the brand
593
+ * text). `'neutral'` (the default) is the same as omitting it. */
594
+ tone?: 'neutral' | 'brand' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
509
595
  /** Keep the menu open after this item is chosen (toggles / multi-select),
510
596
  * instead of the default close-on-select. Presence-based (`''` on, omit
511
597
  * off). The universal form is `data-menu-open` (works on any element). */
@@ -554,6 +640,9 @@ export interface AButtonAttributes extends BaseAttributes {
554
640
  disabled?: boolean | '';
555
641
  /** Toggled-on / pressed state. Presence-based (`''` on, omit off). */
556
642
  selected?: boolean | '';
643
+ /** Fully-round (pill / circle) — `border-radius: 999px` — or a custom radius via
644
+ * a length value (`round="20px"`). Presence-based for the boolean form. */
645
+ round?: boolean | number | string;
557
646
  /** Submit/reset semantics. */
558
647
  type?: 'button' | 'submit' | 'reset';
559
648
  /** Associate with a form by id when not nested inside it. */
@@ -574,15 +663,15 @@ export interface AButtonAttributes extends BaseAttributes {
574
663
  export interface ARadioAttributes extends BaseAttributes {
575
664
  /** This option's identity / submitted value. */
576
665
  value?: string;
577
- /** Mark colour (selected ring fill + dot, unselected ring border), or any literal
578
- * CSS color for a one-off custom tone. Named tones track light/dark mode via the
579
- * theme-aware role tokens. `'neutral'` is the default. The label + hint stay
580
- * neutral use `tone-text` for those. */
666
+ /** Mark colour in every state — selected ring fill + dot *and* unselected ring
667
+ * border — or any literal CSS color for a one-off custom tone. Named tones track
668
+ * light/dark mode. `'neutral'` is the default. The label + hint stay neutral —
669
+ * recolour them in plain CSS via the `--text-N-{tone}` tokens. */
581
670
  tone?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
582
- /** Text colour (label + hint), independent of `tone`. A named tone or any literal
583
- * CSS color; named tones track light/dark via the `--text-*` role tokens. Omit
584
- * (or `'neutral'`) to leave the text neutral. */
585
- 'tone-text'?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
671
+ /** Like `tone`, but coloured onto the selected mark only an unselected ring stays
672
+ * neutral grey. Same value set as `tone`; if both are set, `tone` governs the
673
+ * off-state border and `tone-selected` the selected fill. */
674
+ 'tone-selected'?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
586
675
  /** Size variant. small=14px, medium=16px, large=18px control. */
587
676
  size?: 'small' | 'medium' | 'large';
588
677
  /** Disabled state. Presence-based (`''` on, omit off). */
@@ -625,13 +714,13 @@ export interface ARadioGroupAttributes extends BaseAttributes {
625
714
  /** Form field name — the group submits `name=value`. */
626
715
  name?: string;
627
716
  /** Mark tone cascaded to children that don't set their own, or any literal CSS
628
- * color for a one-off custom tone. Inherits through CSS so every child
629
- * `<a-radio>` picks up the same fill curve. The option text stays neutral —
630
- * use `tone-text`. */
717
+ * color for a one-off custom tone. Colours every child's ring fill + dot *and*
718
+ * unselected border. The option text stays neutral — recolour it in plain CSS via
719
+ * the `--text-N-{tone}` tokens. */
631
720
  tone?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
632
- /** Text tone cascaded to children's label + hint, independent of `tone`. A named
633
- * tone or any literal CSS color. Omit (or `'neutral'`) to leave the text neutral. */
634
- 'tone-text'?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
721
+ /** Like `tone`, but coloured onto the selected option only every unselected ring
722
+ * stays neutral grey. Cascaded to children that don't set their own. */
723
+ 'tone-selected'?: 'brand' | 'neutral' | 'info' | 'success' | 'warning' | 'critical' | (string & {});
635
724
  /** Size cascaded to children that don't set their own. */
636
725
  size?: 'small' | 'medium' | 'large';
637
726
  /** Validation/feedback tone for the group hint — same set as `<a-input>`'s
@@ -691,6 +780,9 @@ export interface ATabAttributes extends BaseAttributes {
691
780
  selected?: boolean | '';
692
781
  /** Disabled state. Presence-based (`''` on, omit off). */
693
782
  disabled?: boolean | '';
783
+ /** Fully-round this tab's box (`--tab-radius: 999px`). `<a-tabs round>` sets it
784
+ * strip-wide instead. Presence-based (`''` on, omit off) — no custom value. */
785
+ round?: boolean | '';
694
786
  /** ARIA — `role="tab"` is set by the consumer (`Tabs` on each tab, or a hand-author),
695
787
  * and `aria-controls` points at the paired panel. `aria-selected` is published by
696
788
  * the element through `ElementInternals` (off the DOM), driven by the `selected`
@@ -740,6 +832,10 @@ export interface ATabsAttributes extends BaseAttributes {
740
832
  noslide?: boolean | '';
741
833
  /** Disable the whole strip. Presence-based (`''` on, omit off). */
742
834
  disabled?: boolean | '';
835
+ /** Fully-round tabs + sliding indicator (via `--tab-radius: 999px`) and the primary
836
+ * track well. A length value (`round="10px"`) applies to the top-level track well
837
+ * only (pills + indicator stay full). Presence-based for the boolean form. */
838
+ round?: boolean | number | string;
743
839
  /** Fires whenever the active tab changes. `detail` carries `{ next, prev }` (values;
744
840
  * `null` = none). Cancelable: a synchronous `preventDefault()` vetoes the pick in
745
841
  * uncontrolled mode. All-lowercase to bind across both renderers (like
package/dist/index.d.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  export { Progress } from './components/Progress';
20
20
  export type { ProgressProps } from './components/Progress';
21
21
  export { Text } from './components/Text';
22
- export type { TextProps } from './components/Text';
22
+ export type { TextProps, ExpandMode } from './components/Text';
23
23
  export { Title } from './components/Title';
24
24
  export type { TitleProps } from './components/Title';
25
25
  export { Tag } from './components/Tag';
@@ -45,8 +45,16 @@ export { Expander } from './components/Expander';
45
45
  export type { ExpanderProps } from './components/Expander';
46
46
  export { Input } from './components/Input';
47
47
  export type { InputProps, InputChangeAttrs } from './components/Input';
48
+ export { Calendar } from './components/Calendar';
49
+ export type { CalendarProps, CalendarChangeAttrs } from './components/Calendar';
50
+ export { InputDate } from './components/InputDate';
51
+ export type { InputDateProps, InputDateChangeAttrs } from './components/InputDate';
52
+ export { buildMonth, getWeekdays, firstDayOfWeek, clampDate, isOutOfRange, parseISODate, parseDateInput, formatDateInput, dateFormatPattern, parseTimeInput, parseDateTimeInput, formatDateTimeInput, dateTimeFormatPattern, usesHour12, } from './calendar-core';
53
+ export type { CalendarDay, CalendarWeekday, CalendarMonth, BuildMonthOptions, ParseDateOptions, } from './calendar-core';
48
54
  export { RadioGroup } from './components/RadioGroup';
49
55
  export type { RadioGroupProps, RadioOption } from './components/RadioGroup';
56
+ export { Select } from './components/Select';
57
+ export type { SelectProps, SelectCommonProps, SelectOption, SelectGroup, SelectSubmenu, SelectItem, SelectChangeAttrs, OptionState, TriggerState, EmptyState, } from './components/Select';
50
58
  export { Tabs } from './components/Tabs';
51
59
  export type { TabsProps, TabsMounting, TabsChangeAttrs } from './components/Tabs';
52
60
  export { Tab } from './components/Tab';
package/dist/index.js CHANGED
@@ -13,25 +13,47 @@ import { MenuSeparator } from "./components/MenuSeparator";
13
13
  import { MenuGroup } from "./components/MenuGroup";
14
14
  import { Expander } from "./components/Expander";
15
15
  import { Input } from "./components/Input";
16
+ import { Calendar } from "./components/Calendar";
17
+ import { InputDate } from "./components/InputDate";
18
+ import {
19
+ buildMonth,
20
+ getWeekdays,
21
+ firstDayOfWeek,
22
+ clampDate,
23
+ isOutOfRange,
24
+ parseISODate,
25
+ parseDateInput,
26
+ formatDateInput,
27
+ dateFormatPattern,
28
+ parseTimeInput,
29
+ parseDateTimeInput,
30
+ formatDateTimeInput,
31
+ dateTimeFormatPattern,
32
+ usesHour12
33
+ } from "./calendar-core";
16
34
  import { RadioGroup } from "./components/RadioGroup";
35
+ import { Select } from "./components/Select";
17
36
  import { Tabs } from "./components/Tabs";
18
37
  import { Tab } from "./components/Tab";
19
38
  import { TabPanel } from "./components/TabPanel";
20
39
  import { configure } from "./jsx-runtime";
21
40
  export {
22
41
  Button,
42
+ Calendar,
23
43
  Checkbox,
24
44
  Expander,
25
45
  ICON_SHAPES,
26
46
  ICON_SYNONYMS,
27
47
  Icon,
28
48
  Input,
49
+ InputDate,
29
50
  Menu,
30
51
  MenuGroup,
31
52
  MenuItem,
32
53
  MenuSeparator,
33
54
  Progress,
34
55
  RadioGroup,
56
+ Select,
35
57
  Tab,
36
58
  TabPanel,
37
59
  Tabs,
@@ -39,5 +61,19 @@ export {
39
61
  Text,
40
62
  Title,
41
63
  Tooltip,
42
- configure
64
+ buildMonth,
65
+ clampDate,
66
+ configure,
67
+ dateFormatPattern,
68
+ dateTimeFormatPattern,
69
+ firstDayOfWeek,
70
+ formatDateInput,
71
+ formatDateTimeInput,
72
+ getWeekdays,
73
+ isOutOfRange,
74
+ parseDateInput,
75
+ parseDateTimeInput,
76
+ parseISODate,
77
+ parseTimeInput,
78
+ usesHour12
43
79
  };
@@ -3,10 +3,11 @@ type ComponentType = string | Function | symbol;
3
3
  type JsxFunction = {
4
4
  h(type: ComponentType, props: Record<string, unknown> | null, ...children: unknown[]): unknown;
5
5
  }['h'];
6
- /** The two hooks the stateful wrappers (currently only `RadioGroup`) need. Typed
7
- * loosely to stay renderer-agnostic — any React-compatible hook implementation. */
6
+ /** The hooks the stateful wrappers need. Typed loosely to stay renderer-agnostic —
7
+ * any React-compatible hook implementation. */
8
8
  type UseState = <S>(initial: S | (() => S)) => [S, (next: S | ((prev: S) => S)) => void];
9
9
  type UseId = () => string;
10
+ type UseMemo = <T>(factory: () => T, deps: unknown[]) => T;
10
11
  declare let _Fragment: ComponentType;
11
12
  /**
12
13
  * Swap the underlying JSX factory (and, optionally, the hooks) used by all anta
@@ -15,32 +16,37 @@ declare let _Fragment: ComponentType;
15
16
  * Not needed for React or Preact-with-compat — those work automatically. Call this
16
17
  * before rendering any anta components when using Preact without compat aliasing,
17
18
  * or a custom JSX runtime. Pass `hooks` when your runtime's hooks don't resolve via
18
- * the `react` specifier (the stateful wrappers — `RadioGroup` — need `useState` /
19
- * `useId`); omit it and they default to whatever `react` resolves to.
19
+ * the `react` specifier (the stateful wrappers — `RadioGroup`, `Calendar`,
20
+ * `InputDate` — need `useState` / `useId` / `useMemo`); omit it and they default
21
+ * to whatever `react` resolves to.
20
22
  *
21
23
  * @example Preact without compat
22
24
  * ```ts
23
25
  * import { configure } from '@antadesign/anta'
24
26
  * import { h, Fragment } from 'preact'
25
- * import { useState, useId } from 'preact/hooks'
26
- * configure(h, Fragment, { useState, useId })
27
+ * import { useState, useId, useMemo } from 'preact/hooks'
28
+ * configure(h, Fragment, { useState, useId, useMemo })
27
29
  * ```
28
30
  */
29
31
  export declare function configure(jsx: JsxFunction, Fragment?: ComponentType, hooks?: {
30
32
  useState?: UseState;
31
33
  useId?: UseId;
34
+ useMemo?: UseMemo;
32
35
  }): void;
33
36
  /** Hooks indirection so wrappers depend on the configured renderer, not a hard
34
37
  * `import … from 'react'`. Call these exactly like the React hooks. */
35
38
  export declare function useState<S>(initial: S | (() => S)): [S, (next: S | ((prev: S) => S)) => void];
36
39
  export declare function useId(): string;
40
+ export declare function useMemo<T>(factory: () => T, deps: unknown[]): T;
37
41
  export declare function jsx(type: ComponentType, props: Record<string, unknown> | null, key?: string | number): unknown;
38
42
  export declare function jsxs(type: ComponentType, props: Record<string, unknown> | null, key?: string | number): unknown;
39
43
  export { _Fragment as Fragment };
40
- import type { AProgressAttributes, ATextAttributes, ATitleAttributes, ATagAttributes, AExpanderAttributes, AIconAttributes, AButtonAttributes, ACheckboxAttributes, ATooltipAttributes, AInputAttributes, ARadioAttributes, ARadioGroupAttributes, AMenuAttributes, AMenuItemAttributes, AMenuGroupAttributes, ATabsAttributes, ATabAttributes, ATabpanelAttributes, BaseAttributes } from './general_types';
44
+ import type { AProgressAttributes, ATextAttributes, ATitleAttributes, ATagAttributes, AExpanderAttributes, AIconAttributes, AButtonAttributes, ACheckboxAttributes, ATooltipAttributes, AInputAttributes, ACalendarAttributes, ARadioAttributes, ARadioGroupAttributes, AMenuAttributes, AMenuItemAttributes, AMenuGroupAttributes, ATabsAttributes, ATabAttributes, ATabpanelAttributes, BaseAttributes } from './general_types';
41
45
  export declare namespace JSX {
42
46
  interface IntrinsicElements extends React.JSX.IntrinsicElements, AntaIntrinsicElements {
43
47
  }
48
+ interface IntrinsicAttributes extends React.JSX.IntrinsicAttributes {
49
+ }
44
50
  }
45
51
  export interface AntaIntrinsicElements {
46
52
  'a-progress': AProgressAttributes;
@@ -64,6 +70,7 @@ export interface AntaIntrinsicElements {
64
70
  'a-checkbox-hint': BaseAttributes;
65
71
  'a-tooltip': ATooltipAttributes;
66
72
  'a-input': AInputAttributes;
73
+ 'a-calendar': ACalendarAttributes;
67
74
  'a-radio': ARadioAttributes;
68
75
  'a-radio-group': ARadioGroupAttributes;
69
76
  'a-radio-group-label': BaseAttributes;
@@ -74,6 +81,8 @@ export interface AntaIntrinsicElements {
74
81
  'a-menu': AMenuAttributes;
75
82
  'a-menu-item': AMenuItemAttributes;
76
83
  'a-menu-item-label': BaseAttributes;
84
+ 'a-menu-item-hint': BaseAttributes;
85
+ 'a-menu-item-text': BaseAttributes;
77
86
  'a-menu-separator': BaseAttributes;
78
87
  'a-menu-group': AMenuGroupAttributes;
79
88
  'a-menu-group-label': BaseAttributes;