@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.
- package/dist/anta_helpers.d.ts +101 -0
- package/dist/anta_helpers.js +77 -0
- package/dist/calendar-core.d.ts +126 -0
- package/dist/calendar-core.js +289 -0
- package/dist/components/Button.d.ts +9 -1
- package/dist/components/Button.js +5 -2
- package/dist/components/Calendar.d.ts +80 -0
- package/dist/components/Calendar.js +220 -0
- package/dist/components/Checkbox.d.ts +16 -11
- package/dist/components/Checkbox.js +13 -7
- package/dist/components/Expander.d.ts +7 -1
- package/dist/components/Expander.js +4 -2
- package/dist/components/Input.d.ts +13 -5
- package/dist/components/Input.js +14 -6
- package/dist/components/InputDate.d.ts +87 -0
- package/dist/components/InputDate.js +278 -0
- package/dist/components/InputDate.module.css +1 -0
- package/dist/components/Menu.d.ts +5 -1
- package/dist/components/Menu.js +6 -2
- package/dist/components/MenuItem.d.ts +48 -7
- package/dist/components/MenuItem.js +71 -7
- package/dist/components/MenuSeparator.d.ts +13 -2
- package/dist/components/MenuSeparator.js +12 -2
- package/dist/components/Progress.d.ts +4 -1
- package/dist/components/Progress.js +4 -3
- package/dist/components/RadioGroup.d.ts +12 -10
- package/dist/components/RadioGroup.js +5 -5
- package/dist/components/Select.d.ts +255 -0
- package/dist/components/Select.js +290 -0
- package/dist/components/Select.module.css +1 -0
- package/dist/components/Tab.d.ts +3 -0
- package/dist/components/Tab.js +2 -1
- package/dist/components/TabPanel.js +2 -1
- package/dist/components/Tabs.d.ts +18 -1
- package/dist/components/Tabs.js +8 -6
- package/dist/components/Tag.d.ts +10 -9
- package/dist/components/Tag.js +2 -2
- package/dist/components/Text.d.ts +6 -5
- package/dist/components/Title.d.ts +4 -2
- package/dist/components/Tooltip.d.ts +4 -1
- package/dist/components/Tooltip.js +5 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-calendar.css +1 -0
- package/dist/elements/a-calendar.d.ts +76 -0
- package/dist/elements/a-calendar.js +190 -0
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-checkbox.d.ts +1 -2
- package/dist/elements/a-checkbox.js +5 -5
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +16 -5
- package/dist/elements/a-expander.js +59 -8
- package/dist/elements/a-icon.shapes.css +1 -1
- package/dist/elements/a-icon.shapes.d.ts +6 -1
- package/dist/elements/a-icon.shapes.js +9 -0
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +6 -0
- package/dist/elements/a-input.js +27 -8
- package/dist/elements/a-menu-group.css +1 -1
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +14 -4
- package/dist/elements/a-menu-item.js +17 -0
- package/dist/elements/a-menu-separator.css +1 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +51 -8
- package/dist/elements/a-menu.js +285 -42
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-radio-group.d.ts +1 -3
- package/dist/elements/a-radio-group.js +13 -13
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-radio.d.ts +3 -11
- package/dist/elements/a-radio.js +3 -34
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tab.d.ts +3 -11
- package/dist/elements/a-tab.js +3 -34
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -4
- package/dist/elements/a-tabs.js +14 -14
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.d.ts +14 -13
- package/dist/elements/a-text.js +53 -23
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -11
- package/dist/elements/a-tooltip.js +20 -19
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/general_types.d.ts +127 -31
- package/dist/index.d.ts +9 -1
- package/dist/index.js +37 -1
- package/dist/jsx-runtime.d.ts +16 -7
- package/dist/jsx-runtime.js +6 -0
- package/dist/reset.css +1 -1
- 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}}
|
package/dist/elements/a-menu.css
CHANGED
|
@@ -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
|
-
/**
|
|
60
|
-
|
|
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
|
-
|
|
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
|