@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,6 +1,23 @@
1
1
  import { HTMLElementBase } from "../anta_helpers";
2
2
  import "./a-menu-item.css";
3
3
  class AMenuItemElement extends HTMLElementBase {
4
+ internals;
5
+ constructor() {
6
+ super();
7
+ this.internals = this.attachInternals?.();
8
+ }
9
+ /** The active (combobox) cursor. `a-menu` sets this **property** (never an
10
+ * attribute — no DOM mutation, same rule as `a-radio.selected`) as ArrowUp/Down
11
+ * move the cursor while focus stays in the filter input; the item mirrors it to
12
+ * `:state(active)` for CSS. Off-DOM, so a reactive re-render never churns it. */
13
+ set active(on) {
14
+ if (!this.internals) return;
15
+ if (on) this.internals.states.add("active");
16
+ else this.internals.states.delete("active");
17
+ }
18
+ get active() {
19
+ return this.internals?.states.has("active") ?? false;
20
+ }
4
21
  connectedCallback() {
5
22
  const doc = this.doc;
6
23
  if (!doc.hasKeyListenerForAMenuItem) {
@@ -1 +1 @@
1
- @layer anta{a-menu-separator:not(:defined){display:none}a-menu-separator{display:block;flex-shrink:0;height:1px;margin:2px 4px;background:var(--border-5)}}
1
+ @layer anta{a-menu-separator:not(:defined){display:none}a-menu-separator{--menu-separator-label-size: 13px;display:block;flex-shrink:0;height:1px;margin:2px 4px;background:var(--border-5)}a-menu-separator:not(:empty){height:auto;margin:0;padding:6px 8px;background:none;color:var(--text-3);font-size:var(--menu-separator-label-size);line-height:1.3;user-select:none}}
@@ -1 +1 @@
1
- @layer anta{a-menu:not(:defined){display:none}a-menu{--menu-bg: color-mix(in oklch, var(--bg-1) 90%, transparent);--menu-radius: var(--radius-md, 8px);--menu-border: 1px solid var(--border-3);--menu-shadow: 0 2px 6px color-mix(in oklch, var(--text-1) 8%, transparent), 0 8px 24px color-mix(in oklch, var(--text-1) 10%, transparent);--menu-padding: 4px;--menu-min-width: 88px;--menu-backdrop-filter: blur(20px)}.dark a-menu{--menu-bg: color-mix(in oklch, var(--bg-1) 78%, transparent);--menu-shadow: 0 2px 8px color-mix(in oklch, black 50%, transparent), 0 12px 32px color-mix(in oklch, black 40%, transparent), inset 0 0 0 1px color-mix(in oklch, white 8%, transparent)}}
1
+ @layer anta{a-menu:not(:defined){display:none}a-menu{--menu-bg: color-mix(in oklch, var(--bg-1) 90%, transparent);--menu-radius: var(--radius-md, 8px);--menu-border: 1px solid var(--border-3);--menu-shadow: 0 2px 6px color-mix(in oklch, var(--text-1) 8%, transparent), 0 8px 24px color-mix(in oklch, var(--text-1) 10%, transparent);--menu-padding: 4px;--menu-min-width: 88px;--menu-backdrop-filter: blur(20px)}a-menu[round]{--menu-radius: attr(round type(<length>), 20px)}.dark a-menu{--menu-bg: color-mix(in oklch, var(--bg-1) 78%, transparent);--menu-shadow: 0 2px 8px color-mix(in oklch, black 50%, transparent), 0 12px 32px color-mix(in oklch, black 40%, transparent), inset 0 0 0 1px color-mix(in oklch, white 8%, transparent)}}
@@ -22,9 +22,12 @@ type MenuState = 'open' | 'closed';
22
22
  * slotted light DOM (see `a-menu-item.css`), directly styleable.
23
23
  */
24
24
  export declare class AMenuElement extends HTMLElementBase {
25
+ #private;
25
26
  static observedAttributes: string[];
26
27
  /** Shadow-internal popover surface — the only thing we ever mutate. */
27
28
  surface: HTMLDivElement;
29
+ /** The scrolling body inside the surface (holds the items). */
30
+ private scrollEl;
28
31
  listening: boolean;
29
32
  private _shown;
30
33
  private teardown?;
@@ -36,6 +39,9 @@ export declare class AMenuElement extends HTMLElementBase {
36
39
  private closeTimer?;
37
40
  private typeBuffer;
38
41
  private typeTimer?;
42
+ private activeItem;
43
+ private comboObserver?;
44
+ private _flippedTop;
39
45
  constructor();
40
46
  connectedCallback(): void;
41
47
  disconnectedCallback(): void;
@@ -48,16 +54,13 @@ export declare class AMenuElement extends HTMLElementBase {
48
54
  /** A submenu is an `<a-menu>` nested inside an `<a-menu-item>` — derived from
49
55
  * structure, no `submenu` attribute needed (the parent item is the anchor). */
50
56
  get isSubmenu(): boolean;
51
- private get isContext();
52
- private get isCoord();
53
- private get isHover();
54
- private get offset();
55
- private get placement();
56
57
  /** Root menu: the previous element sibling is the trigger. Submenu: the
57
58
  * enclosing menu item. One deterministic rule per case — no ambiguity. */
58
59
  get triggerAnchor(): HTMLElement | null;
59
- /** For a submenu: the menu that contains its anchor item. */
60
- private get ownerMenu();
60
+ /** Return focus to the trigger. Focuses the first focusable in the anchor; if
61
+ * there is none (a mis-authored trigger — e.g. `renderTrigger` returning a
62
+ * fragment or a non-focusable node), warns instead of silently focusing air. */
63
+ private focusTrigger;
61
64
  get isOpen(): boolean;
62
65
  /** Skip elements that can't actually take focus — `display:none` (incl. a
63
66
  * closed submenu's contents), `visibility:hidden`, `content-visibility`
@@ -74,7 +77,41 @@ export declare class AMenuElement extends HTMLElementBase {
74
77
  * used to trap Tab within the open menu. Submenu contents are excluded
75
78
  * (their nearest `a-menu` is the submenu). */
76
79
  private focusables;
77
- private focusFirstItem;
80
+ /** On open, seat initial focus like a native `<select>` / macOS menu: a menu
81
+ * carrying a current value opens *at* that value, not at the top. Brings the
82
+ * first selected row into view and, when opened via keyboard, focuses it;
83
+ * with no selected row it focuses the first item (keyboard) and does nothing
84
+ * otherwise. "Selected" = a `selected` row (tint) or `aria-checked` /
85
+ * `aria-selected="true"` (checkable rows) — the first such visible item of
86
+ * THIS menu, so a leaf buried in a closed submenu (not visible) is skipped and
87
+ * a multi-select lands on its topmost checked row. */
88
+ private seatInitialFocus;
89
+ /** Scroll THIS menu's body so `item` sits inside the visible scroll viewport,
90
+ * touching only the internal `.scroll` container — never the document, whose
91
+ * scroll would trip the anchor-scrolled-out dismiss. No-op for a menu short
92
+ * enough not to scroll. */
93
+ private scrollItemIntoView;
94
+ /** Fade the scrolling body's content into the top / bottom edges — but only on the
95
+ * side that actually has more to scroll, so a short (non-scrolling) menu and the
96
+ * true top / bottom stay crisp. Drives the `--fade-*` / `--gap-top` vars the
97
+ * `.scroll` mask reads; runs on scroll and after every (re)position.
98
+ * Shadow-internal only. */
99
+ private updateScrollFade;
100
+ /** Move the combobox cursor. Sets the item's `active` **property** (off-DOM
101
+ * `:state(active)`, no attribute churn) and reflects `aria-activedescendant`
102
+ * onto the search field — the same ARIA-state-reflection latitude as
103
+ * `aria-expanded` on the anchor. `null` clears the cursor. */
104
+ private setActive;
105
+ /** Re-seat the cursor on the first option — but only once the filter has input.
106
+ * An empty filter (e.g. right after opening) shows NO active row, so the first
107
+ * ArrowDown is what steps onto the list; typing then keeps the top match active.
108
+ * Rows marked `data-menu-skip-active` (e.g. a Select-all action) are skipped as
109
+ * the seat target — the cursor lands on the first real option — but they stay
110
+ * arrow-reachable. */
111
+ private resetActive;
112
+ /** Combobox arrow / Home / End / Enter handling; returns true if it consumed the
113
+ * key (so `handleKey` stops). Any other key falls through to the input (typing). */
114
+ private handleComboKey;
78
115
  /** Public imperative API. Routes through the same intent path as the
79
116
  * triggers, so it emits `statechange` and respects controlled mode. */
80
117
  open(opts?: {
@@ -109,6 +146,12 @@ export declare class AMenuElement extends HTMLElementBase {
109
146
  /** Apply OPEN to the DOM (no event) — used by uncontrolled intent and by the
110
147
  * controlled `state` sync. */
111
148
  private show;
149
+ /** While a filter field is open, the visible option list changes as the user
150
+ * types (the consumer re-renders the matches); re-seat the cursor on the first
151
+ * match. `childList` only — an item toggling its own `selected` (multi-select)
152
+ * mutates deep in its subtree, not this menu's direct children, so it won't
153
+ * spuriously reset the cursor. */
154
+ private startComboObserver;
112
155
  /** Watch the root trigger and dismiss the system once it scrolls out of the
113
156
  * spot it held at open (see trackPosition). Deferred a frame so the trigger's
114
157
  * post-open layout has settled before the rect is snapshotted; guarded in case