@antadesign/anta 0.2.2 → 0.3.1

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 (82) hide show
  1. package/README.md +14 -0
  2. package/dist/anta_helpers.d.ts +39 -1
  3. package/dist/anta_helpers.js +30 -2
  4. package/dist/components/Button.d.ts +7 -4
  5. package/dist/components/Button.js +6 -11
  6. package/dist/components/Checkbox.d.ts +97 -0
  7. package/dist/components/Checkbox.js +77 -0
  8. package/dist/components/Expander.d.ts +74 -0
  9. package/dist/components/Expander.js +53 -0
  10. package/dist/components/Input.d.ts +159 -0
  11. package/dist/components/Input.js +150 -0
  12. package/dist/components/Menu.d.ts +73 -0
  13. package/dist/components/Menu.js +42 -0
  14. package/dist/components/MenuGroup.d.ts +24 -0
  15. package/dist/components/MenuGroup.js +19 -0
  16. package/dist/components/MenuItem.d.ts +61 -0
  17. package/dist/components/MenuItem.js +50 -0
  18. package/dist/components/MenuSeparator.d.ts +14 -0
  19. package/dist/components/MenuSeparator.js +7 -0
  20. package/dist/components/Progress.d.ts +12 -6
  21. package/dist/components/Progress.js +7 -4
  22. package/dist/components/Radio.d.ts +37 -0
  23. package/dist/components/Radio.js +33 -0
  24. package/dist/components/RadioGroup.d.ts +119 -0
  25. package/dist/components/RadioGroup.js +108 -0
  26. package/dist/components/Tag.d.ts +38 -5
  27. package/dist/components/Tag.js +9 -5
  28. package/dist/components/Text.d.ts +27 -12
  29. package/dist/components/Text.js +6 -3
  30. package/dist/components/Title.d.ts +10 -1
  31. package/dist/elements/a-button.css +1 -1
  32. package/dist/elements/a-button.d.ts +56 -0
  33. package/dist/elements/a-button.js +13 -11
  34. package/dist/elements/a-checkbox.css +1 -0
  35. package/dist/elements/a-checkbox.d.ts +52 -0
  36. package/dist/elements/a-checkbox.js +130 -0
  37. package/dist/elements/a-expander.css +1 -0
  38. package/dist/elements/a-expander.d.ts +28 -0
  39. package/dist/elements/a-expander.js +237 -0
  40. package/dist/elements/a-icon.d.ts +14 -0
  41. package/dist/elements/a-icon.shapes.css +1 -1
  42. package/dist/elements/a-icon.shapes.d.ts +10 -1
  43. package/dist/elements/a-icon.shapes.js +11 -1
  44. package/dist/elements/a-input.css +1 -0
  45. package/dist/elements/a-input.d.ts +68 -0
  46. package/dist/elements/a-input.js +511 -0
  47. package/dist/elements/a-menu-group.css +1 -0
  48. package/dist/elements/a-menu-group.d.ts +13 -0
  49. package/dist/elements/a-menu-group.js +15 -0
  50. package/dist/elements/a-menu-item.css +1 -0
  51. package/dist/elements/a-menu-item.d.ts +47 -0
  52. package/dist/elements/a-menu-item.js +30 -0
  53. package/dist/elements/a-menu-separator.css +1 -0
  54. package/dist/elements/a-menu-separator.d.ts +13 -0
  55. package/dist/elements/a-menu-separator.js +15 -0
  56. package/dist/elements/a-menu.css +1 -0
  57. package/dist/elements/a-menu.d.ts +183 -0
  58. package/dist/elements/a-menu.js +763 -0
  59. package/dist/elements/a-progress.css +1 -1
  60. package/dist/elements/a-progress.d.ts +12 -0
  61. package/dist/elements/a-progress.js +1 -0
  62. package/dist/elements/a-radio-group.css +1 -0
  63. package/dist/elements/a-radio-group.d.ts +33 -0
  64. package/dist/elements/a-radio-group.js +160 -0
  65. package/dist/elements/a-radio.css +1 -0
  66. package/dist/elements/a-radio.d.ts +14 -0
  67. package/dist/elements/a-radio.js +46 -0
  68. package/dist/elements/a-tag.css +1 -1
  69. package/dist/elements/a-text.css +1 -1
  70. package/dist/elements/a-text.d.ts +42 -3
  71. package/dist/elements/a-text.js +73 -33
  72. package/dist/elements/a-tooltip.d.ts +43 -11
  73. package/dist/elements/a-tooltip.js +46 -51
  74. package/dist/elements/index.d.ts +9 -0
  75. package/dist/elements/index.js +27 -0
  76. package/dist/general_types.d.ts +468 -15
  77. package/dist/index.d.ts +16 -0
  78. package/dist/index.js +16 -0
  79. package/dist/jsx-runtime.d.ts +42 -7
  80. package/dist/jsx-runtime.js +14 -2
  81. package/dist/tokens.css +1 -1
  82. package/package.json +1 -1
@@ -0,0 +1,183 @@
1
+ import { HTMLElementBase } from '../anta_helpers';
2
+ import './a-menu.css';
3
+ /** `statechange` event detail (see STATEFUL-COMPONENTS.md). `next` is the
4
+ * requested state, `prev` the current one — both in the `'open'|'closed'`
5
+ * vocabulary of the `state` attribute, so a controlled handler reads
6
+ * `setState(e.detail.next)`. `coord` (computed context placement) and
7
+ * `originEvent` (what triggered it) are derived results the caller can't
8
+ * recompute, so they belong in the payload. */
9
+ type MenuState = 'open' | 'closed';
10
+ /**
11
+ * `<a-menu>` — dropdown / context menu surface (shadow popover, JS
12
+ * positioning, keyboard nav, click delegation, open-stack coordination).
13
+ *
14
+ * Styling notes (`a-menu.css` ships comment-free):
15
+ * - `a-menu:not(:defined)` is hidden — before upgrade the host is an unknown
16
+ * inline element and its light-DOM items would flash in the page. Once
17
+ * defined, the shadow `:host { display: contents }` governs and content
18
+ * renders only inside the popover surface via the slot.
19
+ * - Only the surface "chrome" is tokenized (`--menu-*`): it lives inside the
20
+ * shadow popover, unreachable from plain consumer CSS; the custom
21
+ * properties inherit across the shadow boundary into the surface. Items are
22
+ * slotted light DOM (see `a-menu-item.css`), directly styleable.
23
+ */
24
+ export declare class AMenuElement extends HTMLElementBase {
25
+ static observedAttributes: string[];
26
+ /** Shadow-internal popover surface — the only thing we ever mutate. */
27
+ surface: HTMLDivElement;
28
+ listening: boolean;
29
+ private _shown;
30
+ private teardown?;
31
+ /** A controlled menu was told to dismiss (it emitted `statechange→'closed'`)
32
+ * but stays visible until the consumer flips `state`. The flag lets the
33
+ * `closeAll` backstop skip a duplicate emit. Cleared on every show. */
34
+ _dismissNotified: boolean;
35
+ private openTimer?;
36
+ private closeTimer?;
37
+ private typeBuffer;
38
+ private typeTimer?;
39
+ constructor();
40
+ connectedCallback(): void;
41
+ disconnectedCallback(): void;
42
+ attributeChangedCallback(name: string): void;
43
+ /** Apply the controlled `state` attribute to actual visibility, silently.
44
+ * Absent → uncontrolled (no-op here; triggers manage it). */
45
+ private syncState;
46
+ /** Controlled iff the consumer is managing the `state` attribute. */
47
+ get isControlled(): boolean;
48
+ /** A submenu is an `<a-menu>` nested inside an `<a-menu-item>` — derived from
49
+ * structure, no `submenu` attribute needed (the parent item is the anchor). */
50
+ get isSubmenu(): boolean;
51
+ private get isContext();
52
+ private get isCoord();
53
+ private get isHover();
54
+ private get offset();
55
+ private get placement();
56
+ /** Root menu: the previous element sibling is the trigger. Submenu: the
57
+ * enclosing menu item. One deterministic rule per case — no ambiguity. */
58
+ get triggerAnchor(): HTMLElement | null;
59
+ /** For a submenu: the menu that contains its anchor item. */
60
+ private get ownerMenu();
61
+ get isOpen(): boolean;
62
+ /** Skip elements that can't actually take focus — `display:none` (incl. a
63
+ * closed submenu's contents), `visibility:hidden`, `content-visibility`
64
+ * skipped — so navigation never lands on a hidden node (programmatic
65
+ * `.focus()` on one silently fails). `getClientRects` is the fallback where
66
+ * `checkVisibility` isn't available. */
67
+ private isVisible;
68
+ /** The subset of `focusables()` that are menu items (drives arrow / Home /
69
+ * End / type-ahead navigation). Same visibility / disabled / ownership
70
+ * filter — just narrowed to `a-menu-item`. */
71
+ private focusableItems;
72
+ /** Every tabbable element belonging to THIS menu (items + nested controls
73
+ * like inputs / sliders / buttons), in DOM order, visible and enabled —
74
+ * used to trap Tab within the open menu. Submenu contents are excluded
75
+ * (their nearest `a-menu` is the submenu). */
76
+ private focusables;
77
+ private focusFirstItem;
78
+ /** Public imperative API. Routes through the same intent path as the
79
+ * triggers, so it emits `statechange` and respects controlled mode. */
80
+ open(opts?: {
81
+ coord?: [number, number];
82
+ viaKeyboard?: boolean;
83
+ originEvent?: Event;
84
+ }): void;
85
+ close(originEvent?: Event): void;
86
+ toggle(opts?: {
87
+ coord?: [number, number];
88
+ viaKeyboard?: boolean;
89
+ originEvent?: Event;
90
+ }): void;
91
+ /** Dispatch the single `statechange` event (requested + previous state),
92
+ * `cancelable` and *before* applying. Returns `false` if a handler vetoed it
93
+ * via `preventDefault()` — the uncontrolled veto (see requestOpen/Close). */
94
+ emitChange(next: MenuState, opts?: {
95
+ coord?: [number, number];
96
+ originEvent?: Event;
97
+ }): boolean;
98
+ /** Intent to open (trigger / method / keyboard). Emits the cancelable
99
+ * `statechange`; applies the visibility itself ONLY when uncontrolled and
100
+ * not vetoed — a controlled menu waits for the consumer to flip `state`. */
101
+ requestOpen(opts?: {
102
+ coord?: [number, number];
103
+ viaKeyboard?: boolean;
104
+ originEvent?: Event;
105
+ }): void;
106
+ /** Intent to close. Emits the cancelable `statechange`; hides itself only when
107
+ * uncontrolled and not vetoed. */
108
+ requestClose(originEvent?: Event): void;
109
+ /** Apply OPEN to the DOM (no event) — used by uncontrolled intent and by the
110
+ * controlled `state` sync. */
111
+ private show;
112
+ /** Watch the root trigger and dismiss the system once it scrolls out of the
113
+ * spot it held at open (see trackPosition). Deferred a frame so the trigger's
114
+ * post-open layout has settled before the rect is snapshotted; guarded in case
115
+ * the menu closed in between. Tracks the root anchor only — submenus ride
116
+ * inside it, so if the root anchor goes, the whole system should go. */
117
+ private armPositionTracker;
118
+ /** Apply CLOSE to the DOM (no event). Closes this menu and everything stacked
119
+ * above it (its submenus). */
120
+ private hide;
121
+ /** Shadow-only show: open the popover and position it. `instant` positions
122
+ * synchronously (no rAF), so a menu opening over an already-visible one is
123
+ * placed before its first paint — it still fades in via the CSS transition.
124
+ * Relies on the Popover API without feature detection — see "Browser
125
+ * support" in README.md. */
126
+ _doShow(coord?: [number, number], instant?: boolean): void;
127
+ /** Dismiss any tooltip on the trigger as the menu opens, so the trigger's
128
+ * hover tooltip doesn't linger over the just-opened menu. `a-tooltip.hide()`
129
+ * mutates only its own shadow internals (like `el.focus()`), so this is
130
+ * allowed under the no-light-DOM-mutation rule. No-op when the trigger has no
131
+ * tooltip (or it hasn't upgraded). */
132
+ private hideAnchorTooltip;
133
+ /** Shadow-only hide. */
134
+ _doHide(): void;
135
+ /** Mirror the open state onto a SUBMENU parent's `aria-expanded`. This is the
136
+ * one sanctioned light-DOM ARIA mutation (like `el.focus()`): the anchor is
137
+ * an `<a-menu-item>` the `MenuItem` wrapper renders WITH a resting
138
+ * `aria-expanded="false"` baseline, so a reactive re-render resets it to a
139
+ * valid value and the next open/close re-syncs.
140
+ *
141
+ * A ROOT menu's trigger is a consumer-owned sibling we don't render and have
142
+ * no baseline for — writing to it would mutate foreign DOM (and couldn't
143
+ * self-heal), so we leave its `aria-expanded` to the consumer. The menu is
144
+ * still announced and Esc-dismissable; consumers add `aria-haspopup="menu"`
145
+ * to their trigger themselves. (`context` menus aren't triggers either.) */
146
+ private reflectExpanded;
147
+ private position;
148
+ /**
149
+ * Fully declarative close contract — decided synchronously from the DOM, so
150
+ * it never depends on the consumer's click handler (which in a worker-thread
151
+ * runtime can't `preventDefault` on the UI thread). The menu never
152
+ * stops/prevents the click, so the consumer's selection handler always runs.
153
+ *
154
+ * Walk the click's composedPath outward to the surface; the NEAREST marker
155
+ * wins:
156
+ * - `data-menu-open` → keep the menu open (a Done button can still close
157
+ * from inside such a region — it's hit first).
158
+ * - `a-menu-item` (a choice) or `data-menu-close` → close the menu.
159
+ * - nothing → keep open (plain custom content doesn't dismiss).
160
+ */
161
+ private onSurfaceClick;
162
+ /** Close the whole open menu system from the root down. */
163
+ private closeSystem;
164
+ /** Called by the coordinator on the topmost open menu. Handles navigation;
165
+ * Enter / Space activation is handled by a-menu-item's own global keydown
166
+ * (which synthesizes a click → routed through onSurfaceClick). */
167
+ handleKey(e: KeyboardEvent): void;
168
+ private submenuOf;
169
+ private typeahead;
170
+ /** The item's own visible label for type-ahead. Prefers the
171
+ * `<a-menu-item-label>` text so it excludes a trailing `kbd` hint AND — for
172
+ * a submenu parent — the entire nested `<a-menu>` flyout's text (which is a
173
+ * light-DOM descendant, so it'd otherwise be folded into `textContent`). */
174
+ private itemLabel;
175
+ setupListeners(): void;
176
+ teardownListeners(): void;
177
+ private scheduleOpen;
178
+ private scheduleClose;
179
+ private cancelOpenTimer;
180
+ private cancelCloseTimer;
181
+ }
182
+ export declare function register_a_menu(): void;
183
+ export {};