@antadesign/anta 0.2.1 → 0.3.0

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 (85) 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 +12 -14
  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 +70 -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 +50 -0
  17. package/dist/components/MenuItem.js +41 -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/components/Tooltip.d.ts +19 -9
  32. package/dist/components/Tooltip.js +2 -2
  33. package/dist/elements/a-button.css +1 -1
  34. package/dist/elements/a-button.d.ts +56 -0
  35. package/dist/elements/a-button.js +13 -11
  36. package/dist/elements/a-checkbox.css +1 -0
  37. package/dist/elements/a-checkbox.d.ts +52 -0
  38. package/dist/elements/a-checkbox.js +130 -0
  39. package/dist/elements/a-expander.css +1 -0
  40. package/dist/elements/a-expander.d.ts +28 -0
  41. package/dist/elements/a-expander.js +237 -0
  42. package/dist/elements/a-icon.d.ts +14 -0
  43. package/dist/elements/a-icon.shapes.css +1 -1
  44. package/dist/elements/a-icon.shapes.d.ts +10 -2
  45. package/dist/elements/a-icon.shapes.js +12 -3
  46. package/dist/elements/a-input.css +1 -0
  47. package/dist/elements/a-input.d.ts +68 -0
  48. package/dist/elements/a-input.js +511 -0
  49. package/dist/elements/a-menu-group.css +1 -0
  50. package/dist/elements/a-menu-group.d.ts +13 -0
  51. package/dist/elements/a-menu-group.js +15 -0
  52. package/dist/elements/a-menu-item.css +1 -0
  53. package/dist/elements/a-menu-item.d.ts +47 -0
  54. package/dist/elements/a-menu-item.js +30 -0
  55. package/dist/elements/a-menu-separator.css +1 -0
  56. package/dist/elements/a-menu-separator.d.ts +13 -0
  57. package/dist/elements/a-menu-separator.js +15 -0
  58. package/dist/elements/a-menu.css +1 -0
  59. package/dist/elements/a-menu.d.ts +171 -0
  60. package/dist/elements/a-menu.js +714 -0
  61. package/dist/elements/a-progress.css +1 -1
  62. package/dist/elements/a-progress.d.ts +12 -0
  63. package/dist/elements/a-progress.js +1 -0
  64. package/dist/elements/a-radio-group.css +1 -0
  65. package/dist/elements/a-radio-group.d.ts +33 -0
  66. package/dist/elements/a-radio-group.js +160 -0
  67. package/dist/elements/a-radio.css +1 -0
  68. package/dist/elements/a-radio.d.ts +14 -0
  69. package/dist/elements/a-radio.js +46 -0
  70. package/dist/elements/a-tag.css +1 -1
  71. package/dist/elements/a-text.css +1 -1
  72. package/dist/elements/a-text.d.ts +42 -3
  73. package/dist/elements/a-text.js +73 -33
  74. package/dist/elements/a-title.css +1 -1
  75. package/dist/elements/a-tooltip.d.ts +65 -15
  76. package/dist/elements/a-tooltip.js +155 -115
  77. package/dist/elements/index.d.ts +9 -0
  78. package/dist/elements/index.js +27 -0
  79. package/dist/general_types.d.ts +471 -19
  80. package/dist/index.d.ts +16 -0
  81. package/dist/index.js +16 -0
  82. package/dist/jsx-runtime.d.ts +42 -7
  83. package/dist/jsx-runtime.js +14 -2
  84. package/dist/tokens.css +1 -1
  85. package/package.json +1 -1
@@ -0,0 +1,171 @@
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
+ /** Apply CLOSE to the DOM (no event). Closes this menu and everything stacked
113
+ * above it (its submenus). */
114
+ private hide;
115
+ /** Shadow-only show: open the popover and position it. `instant` positions
116
+ * synchronously (no rAF), so a menu opening over an already-visible one is
117
+ * placed before its first paint — it still fades in via the CSS transition.
118
+ * Relies on the Popover API without feature detection — see "Browser
119
+ * support" in README.md. */
120
+ _doShow(coord?: [number, number], instant?: boolean): void;
121
+ /** Shadow-only hide. */
122
+ _doHide(): void;
123
+ /** Mirror the open state onto a SUBMENU parent's `aria-expanded`. This is the
124
+ * one sanctioned light-DOM ARIA mutation (like `el.focus()`): the anchor is
125
+ * an `<a-menu-item>` the `MenuItem` wrapper renders WITH a resting
126
+ * `aria-expanded="false"` baseline, so a reactive re-render resets it to a
127
+ * valid value and the next open/close re-syncs.
128
+ *
129
+ * A ROOT menu's trigger is a consumer-owned sibling we don't render and have
130
+ * no baseline for — writing to it would mutate foreign DOM (and couldn't
131
+ * self-heal), so we leave its `aria-expanded` to the consumer. The menu is
132
+ * still announced and Esc-dismissable; consumers add `aria-haspopup="menu"`
133
+ * to their trigger themselves. (`context` menus aren't triggers either.) */
134
+ private reflectExpanded;
135
+ private position;
136
+ /**
137
+ * Fully declarative close contract — decided synchronously from the DOM, so
138
+ * it never depends on the consumer's click handler (which in a worker-thread
139
+ * runtime can't `preventDefault` on the UI thread). The menu never
140
+ * stops/prevents the click, so the consumer's selection handler always runs.
141
+ *
142
+ * Walk the click's composedPath outward to the surface; the NEAREST marker
143
+ * wins:
144
+ * - `data-menu-open` → keep the menu open (a Done button can still close
145
+ * from inside such a region — it's hit first).
146
+ * - `a-menu-item` (a choice) or `data-menu-close` → close the menu.
147
+ * - nothing → keep open (plain custom content doesn't dismiss).
148
+ */
149
+ private onSurfaceClick;
150
+ /** Close the whole open menu system from the root down. */
151
+ private closeSystem;
152
+ /** Called by the coordinator on the topmost open menu. Handles navigation;
153
+ * Enter / Space activation is handled by a-menu-item's own global keydown
154
+ * (which synthesizes a click → routed through onSurfaceClick). */
155
+ handleKey(e: KeyboardEvent): void;
156
+ private submenuOf;
157
+ private typeahead;
158
+ /** The item's own visible label for type-ahead. Prefers the
159
+ * `<a-menu-item-label>` text so it excludes a trailing `kbd` hint AND — for
160
+ * a submenu parent — the entire nested `<a-menu>` flyout's text (which is a
161
+ * light-DOM descendant, so it'd otherwise be folded into `textContent`). */
162
+ private itemLabel;
163
+ setupListeners(): void;
164
+ teardownListeners(): void;
165
+ private scheduleOpen;
166
+ private scheduleClose;
167
+ private cancelOpenTimer;
168
+ private cancelCloseTimer;
169
+ }
170
+ export declare function register_a_menu(): void;
171
+ export {};