@antadesign/anta 0.3.34 → 0.3.35
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/LICENSE.md +14 -1
- package/README.md +9 -0
- package/dist/anta_helpers.d.ts +46 -30
- package/dist/anta_helpers.js +66 -25
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -1333
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- package/dist/components/Button.js +1 -0
- package/dist/components/ButtonCopy.js +3 -2
- package/dist/components/Calendar.js +13 -13
- package/dist/components/Card.d.ts +9 -17
- package/dist/components/Card.js +50 -46
- package/dist/components/Dialog.d.ts +1 -0
- package/dist/components/Dialog.js +16 -10
- package/dist/components/Expander.d.ts +6 -21
- package/dist/components/Expander.js +24 -23
- package/dist/components/Icon.d.ts +8 -14
- package/dist/components/Input.d.ts +77 -96
- package/dist/components/Input.js +23 -27
- package/dist/components/InputAutocomplete.d.ts +29 -10
- package/dist/components/InputAutocomplete.js +25 -8
- package/dist/components/InputDate.js +2 -2
- package/dist/components/InputTime.d.ts +10 -4
- package/dist/components/InputTime.js +20 -16
- package/dist/components/Loader.d.ts +2 -2
- package/dist/components/Menu.d.ts +5 -4
- package/dist/components/Menu.js +13 -8
- package/dist/components/MenuItem.js +1 -14
- package/dist/components/MenuItemCopy.js +2 -2
- package/dist/components/Panel.d.ts +3 -1
- package/dist/components/Panel.js +17 -11
- package/dist/components/Progress.d.ts +21 -23
- package/dist/components/Progress.js +13 -9
- package/dist/components/RadioGroup.js +6 -8
- package/dist/components/{select-parts.css → Select.css} +1 -1
- package/dist/components/Select.d.ts +53 -35
- package/dist/components/Select.js +53 -97
- package/dist/components/SelectFaceted.d.ts +7 -3
- package/dist/components/SelectFaceted.js +21 -9
- package/dist/components/Slider.d.ts +28 -11
- package/dist/components/Slider.js +20 -20
- package/dist/components/Steps.css +1 -1
- package/dist/components/Steps.js +1 -11
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +5 -8
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +16 -26
- package/dist/components/Title.js +2 -1
- package/dist/components/Toaster.js +9 -2
- package/dist/components/Tooltip.d.ts +10 -15
- package/dist/components/copy-props.d.ts +14 -3
- package/dist/components/copy-props.js +14 -3
- package/dist/components/select-tree.d.ts +24 -0
- package/dist/components/select-tree.js +35 -0
- package/dist/element-base.d.ts +10 -0
- package/dist/element-base.js +15 -0
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.d.ts +4 -1
- package/dist/elements/a-banner.js +22 -112
- package/dist/elements/a-button.d.ts +2 -1
- package/dist/elements/a-button.js +18 -1
- package/dist/elements/a-calendar.d.ts +14 -13
- package/dist/elements/a-calendar.js +29 -24
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-card.d.ts +0 -9
- package/dist/elements/a-card.js +0 -184
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-copy.d.ts +1 -5
- package/dist/elements/a-copy.js +129 -108
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-dialog.d.ts +1 -1
- package/dist/elements/a-dialog.js +66 -194
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +4 -30
- package/dist/elements/a-expander.js +85 -344
- package/dist/elements/a-icon.d.ts +5 -23
- package/dist/elements/a-icon.js +1 -2
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +2 -1
- package/dist/elements/a-input-time.js +101 -168
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +10 -8
- package/dist/elements/a-input.js +155 -230
- package/dist/elements/a-loader.d.ts +5 -8
- package/dist/elements/a-loader.js +1 -2
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +5 -3
- package/dist/elements/a-menu-item.js +5 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +5 -7
- package/dist/elements/a-menu.js +383 -299
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +19 -37
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-progress.d.ts +0 -22
- package/dist/elements/a-progress.js +0 -100
- package/dist/elements/a-radio-group.d.ts +1 -1
- package/dist/elements/a-radio-group.js +6 -4
- package/dist/elements/a-select-faceted.d.ts +1 -1
- package/dist/elements/a-select-faceted.js +1 -1
- package/dist/elements/a-select.d.ts +1 -1
- package/dist/elements/a-select.js +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +11 -3
- package/dist/elements/a-slider.js +244 -242
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -1
- package/dist/elements/a-tabs.js +6 -4
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.d.ts +6 -43
- package/dist/elements/a-text.js +110 -193
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toast.d.ts +10 -45
- package/dist/elements/a-toast.js +80 -66
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-toaster.js +9 -44
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -1
- package/dist/elements/a-tooltip.js +142 -136
- package/dist/elements/copy-behavior.d.ts +1 -1
- package/dist/elements/copy-behavior.js +21 -21
- package/dist/elements/index.d.ts +3 -3
- package/dist/elements/index.js +3 -7
- package/dist/elements/input-focus-modality.d.ts +15 -0
- package/dist/elements/input-focus-modality.js +44 -0
- package/dist/elements/input-trailing-actions.d.ts +5 -0
- package/dist/elements/input-trailing-actions.js +38 -0
- package/dist/elements/shadow-aria.d.ts +2 -0
- package/dist/elements/shadow-aria.js +2 -1
- package/dist/elements/value-input.d.ts +3 -0
- package/dist/elements/value-input.js +12 -0
- package/dist/general_types.d.ts +103 -96
- package/dist/index.d.ts +1 -1
- package/dist/input-events.d.ts +4 -0
- package/dist/input-events.js +15 -0
- package/dist/jsx-runtime.d.ts +70 -23
- package/dist/jsx-runtime.js +26 -19
- package/dist/native-event-props.d.ts +2 -0
- package/dist/native-event-props.js +10 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +10 -1
- package/dist/theme-antune.css +1 -1
- package/docs/accessibility.md +17 -3
- package/docs/changelog.md +348 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- package/docs/components/button.md +22 -0
- package/docs/components/card.md +74 -28
- package/docs/components/checkbox.md +9 -10
- package/docs/components/dialog.md +83 -32
- package/docs/components/expander.md +198 -435
- package/docs/components/icon.md +11 -17
- package/docs/components/input-autocomplete.md +152 -52
- package/docs/components/input-date.md +175 -148
- package/docs/components/input-time.md +81 -38
- package/docs/components/input.md +343 -349
- package/docs/components/loader.md +2 -1
- package/docs/components/menu.md +35 -6
- package/docs/components/panel.md +18 -0
- package/docs/components/progress.md +83 -49
- package/docs/components/radio.md +39 -43
- package/docs/components/select-faceted.md +54 -7
- package/docs/components/select.md +390 -386
- package/docs/components/slider.md +136 -19
- package/docs/components/steps.md +2 -1
- package/docs/components/switch.md +8 -9
- package/docs/components/tabs.md +110 -104
- package/docs/components/text.md +110 -86
- package/docs/components/title.md +47 -33
- package/docs/components/toaster.md +242 -84
- package/docs/components/tooltip.md +204 -113
- package/docs/install-config.md +183 -26
- package/docs/packages/plot.md +170 -148
- package/docs/theming.md +7 -0
- package/package.json +41 -3
- package/theme-antithesis-license.md +66 -0
package/LICENSE.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
# Licensing scope
|
|
2
|
+
|
|
3
|
+
The MIT license below applies to Anta except for the Antithesis theme in
|
|
4
|
+
`src/theme-antithesis.css`, its built copy `dist/theme-antithesis.css`
|
|
5
|
+
(exported as `@antadesign/anta/theme-antithesis.css`), and copies or
|
|
6
|
+
modifications of that theme. The theme is licensed separately under
|
|
7
|
+
[the Antithesis theme license](./theme-antithesis-license.md): noncommercial use is
|
|
8
|
+
free, and commercial use requires prior written permission from Antithesis
|
|
9
|
+
Operations LLC. That exception does not restrict rights already granted in
|
|
10
|
+
earlier MIT-licensed copies of the theme.
|
|
11
|
+
|
|
12
|
+
Third-party notices and licenses appear in [NOTICES.md](./NOTICES.md).
|
|
13
|
+
|
|
14
|
+
## MIT License
|
|
2
15
|
|
|
3
16
|
Copyright (c) 2026 Antithesis
|
|
4
17
|
|
package/README.md
CHANGED
|
@@ -5,6 +5,15 @@ design tokens, declarative web components, and typed JSX wrappers. Use the same
|
|
|
5
5
|
components in React, Preact via compat, plain HTML, and custom JSX runtimes via
|
|
6
6
|
`configure()`.
|
|
7
7
|
|
|
8
|
+
## License
|
|
9
|
+
|
|
10
|
+
Anta is [MIT licensed](./LICENSE.md), with one exception: the Antithesis theme
|
|
11
|
+
(`@antadesign/anta/theme-antithesis.css`) is copyright Antithesis Operations LLC
|
|
12
|
+
and has a [separate license](./theme-antithesis-license.md). Noncommercial use is
|
|
13
|
+
free. Commercial use of the theme requires prior written permission through
|
|
14
|
+
the [Antithesis contact page](https://antithesis.com/company/contact/).
|
|
15
|
+
Antune and the default styles remain available under MIT.
|
|
16
|
+
|
|
8
17
|
## Documentation for coding agents
|
|
9
18
|
|
|
10
19
|
The package includes version-matched Markdown documentation. Start with the
|
package/dist/anta_helpers.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { HTMLElementBase } from './element-base';
|
|
2
|
+
export { HTMLElementBase } from './element-base';
|
|
1
3
|
import type { IconShape } from "./elements/a-icon.shapes";
|
|
2
4
|
import type { OptionPresentationProps } from "./general_types";
|
|
5
|
+
/** @internal Check the native Node brand across realms without reading a document. */
|
|
6
|
+
export declare function isDOMNode(value: unknown): value is Node;
|
|
3
7
|
export declare function hasChildren(children: React.ReactNode): boolean;
|
|
8
|
+
/** @internal Mirror selection for declarative rendering, retaining the latest
|
|
9
|
+
* controlled value when ownership is released. Update the mirror only for
|
|
10
|
+
* accepted uncontrolled changes. */
|
|
11
|
+
export declare function useSelectionMirror(value: string | undefined, defaultValue?: string): readonly [string | undefined, (next: string | ((prev: string | undefined) => string | undefined) | undefined) => void];
|
|
4
12
|
/**
|
|
5
13
|
* Select the safe presentation attributes from a data-rendered option. Option
|
|
6
14
|
* objects often carry application data, so wrappers must never spread them onto
|
|
@@ -48,6 +56,10 @@ export declare function wrapLabel(kids: React.ReactNode, tag: string): React.Rea
|
|
|
48
56
|
export type StateChangeEvent<D> = CustomEvent<D> | {
|
|
49
57
|
nativeEvent: CustomEvent<D>;
|
|
50
58
|
};
|
|
59
|
+
/** @internal Return the raw event from native or renderer-wrapped callbacks. */
|
|
60
|
+
export declare function unwrapNativeEvent<E extends object>(event: E | {
|
|
61
|
+
nativeEvent: E;
|
|
62
|
+
}): E;
|
|
51
63
|
export declare function nativeStateChange<D>(e: StateChangeEvent<D>): {
|
|
52
64
|
event: CustomEvent<D>;
|
|
53
65
|
detail?: D;
|
|
@@ -59,6 +71,11 @@ export declare function customEventHandler<D>(handler?: (event: CustomEvent<D>,
|
|
|
59
71
|
export declare function finiteNumber(value: string | number | null, fallback: number): number;
|
|
60
72
|
/** Normalize the JSX `truncate` shorthand to a positive CSS line count. */
|
|
61
73
|
export declare function lineClamp(truncate: boolean | number | undefined): number | undefined;
|
|
74
|
+
/** Leave candidate navigation and confirmation with the input method, including
|
|
75
|
+
* browsers that report the final composing key only through legacy code 229. */
|
|
76
|
+
export declare function isComposingKey(event: Pick<KeyboardEvent, 'isComposing' | 'keyCode'> | {
|
|
77
|
+
nativeEvent: Pick<KeyboardEvent, 'isComposing' | 'keyCode'>;
|
|
78
|
+
}): boolean;
|
|
62
79
|
/** Leave modified navigation to the browser, OS, or text field. Shift+Tab remains focus navigation. */
|
|
63
80
|
export declare function isModifiedNavigationKey(event: Pick<KeyboardEvent, 'key' | 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'>): boolean;
|
|
64
81
|
export declare const IS_MAC: boolean;
|
|
@@ -146,21 +163,22 @@ export declare function anchorRect(el: Element): DOMRect;
|
|
|
146
163
|
* (Menu and tooltip are both top-layer popovers, stacked by show order, so a
|
|
147
164
|
* tooltip opened while a menu is up would paint over it — z-index can't reorder
|
|
148
165
|
* the top layer.) Decoupled on purpose: neither element imports the other, and
|
|
149
|
-
* if `a-menu` never loads
|
|
166
|
+
* if `a-menu` never loads there are no providers and tooltips remain available.
|
|
150
167
|
*/
|
|
151
168
|
export interface MenuPresence {
|
|
152
169
|
/** Is any `a-menu` open? */
|
|
153
|
-
isOpen(): boolean;
|
|
170
|
+
isOpen(doc?: Document): boolean;
|
|
154
171
|
/** Is `node` inside the open menu system — a menu surface, a slotted item, or
|
|
155
172
|
* an open trigger? (A tooltip there is a menu-item tooltip and still shows,
|
|
156
173
|
* above the menu.) */
|
|
157
174
|
contains(node: Node): boolean;
|
|
158
175
|
}
|
|
159
|
-
/**
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
176
|
+
/** Register every compiled provider; a later unused class must not replace the
|
|
177
|
+
* provider belonging to the class retained by the custom-element registry. */
|
|
178
|
+
export declare function setMenuPresence(p: MenuPresence | null, doc?: Document | undefined): void;
|
|
179
|
+
/** True while a menu is open in this document. */
|
|
180
|
+
export declare function isMenuOpen(doc?: Document | undefined): boolean;
|
|
181
|
+
/** True if `node` sits inside an open menu in its document. */
|
|
164
182
|
export declare function isInsideOpenMenu(node: Node): boolean;
|
|
165
183
|
/** Internal element protocol used by a popup to associate itself and its active
|
|
166
184
|
* item with an Anta-owned focus target without serializing cross-root IDs. */
|
|
@@ -175,29 +193,18 @@ export interface PopupAriaReceiver extends Element {
|
|
|
175
193
|
[SYNC_POPUP_ARIA](relations: PopupAriaRelations): void;
|
|
176
194
|
}
|
|
177
195
|
export declare function isPopupAriaReceiver(element: Element | null): element is PopupAriaReceiver;
|
|
178
|
-
/**
|
|
179
|
-
*
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
declare const NativeHTMLElement: typeof HTMLElement;
|
|
186
|
-
/**
|
|
187
|
-
* Base for Anta custom elements. Adds realm-correct `view` / `doc` getters:
|
|
188
|
-
* the class may be defined in one realm while the element lives in another
|
|
189
|
-
* (the docs playground renders into an iframe but reuses the parent page's
|
|
190
|
-
* element class), so the module-global `window` / `document` can point at the
|
|
191
|
-
* wrong frame. Anything viewport- or document-scoped — clamping,
|
|
192
|
-
* `getComputedStyle`, scroll / key / pointer listeners — must go through these
|
|
193
|
-
* so it's correct in any frame. Shared by a-tooltip and a-menu.
|
|
194
|
-
*/
|
|
195
|
-
export declare class HTMLElementBase extends NativeHTMLElement {
|
|
196
|
-
/** This element's own window (the iframe's window when nested). */
|
|
197
|
-
protected get view(): Window & typeof globalThis;
|
|
198
|
-
/** This element's own document (the iframe's document when nested). */
|
|
199
|
-
protected get doc(): Document;
|
|
196
|
+
/** Internal Text-to-Button protocol. The receiver publishes accessibility
|
|
197
|
+
* defaults through its own ElementInternals without changing authored DOM. */
|
|
198
|
+
export declare const SYNC_TEXT_TOGGLE: unique symbol;
|
|
199
|
+
export interface TextToggleAria {
|
|
200
|
+
source: Element;
|
|
201
|
+
expanded?: boolean;
|
|
202
|
+
clear?: boolean;
|
|
200
203
|
}
|
|
204
|
+
export interface TextToggleReceiver extends Element {
|
|
205
|
+
[SYNC_TEXT_TOGGLE](state: TextToggleAria): void;
|
|
206
|
+
}
|
|
207
|
+
export declare function isTextToggleReceiver(element: Element | null): element is TextToggleReceiver;
|
|
201
208
|
/** Apply default accessible names and descriptions through element references. */
|
|
202
209
|
export declare function applyAccessibilityRelations(internals: ElementInternals | undefined, labels: Element[], descriptions: Element[]): void;
|
|
203
210
|
/**
|
|
@@ -254,4 +261,13 @@ export declare class SelectableChildElement extends HTMLElementBase {
|
|
|
254
261
|
* without exposing IDs or the shared ElementInternals instance. */
|
|
255
262
|
protected applyAccessibilityRelations(labels: Element[], descriptions: Element[]): void;
|
|
256
263
|
}
|
|
257
|
-
|
|
264
|
+
/** @internal Project value inputs through HTML attributes in every renderer.
|
|
265
|
+
* HTML attribute names are case-insensitive. `VALUE` avoids React's property
|
|
266
|
+
* assignment and Preact's special live-value comparison/removal, while producing
|
|
267
|
+
* the ordinary `value` attribute in the DOM and parsed SSR HTML. In particular,
|
|
268
|
+
* an empty-string option stays distinct from removing controlled ownership.
|
|
269
|
+
* Keep this projection serializable for server and worker renderers. */
|
|
270
|
+
export declare const valueAttributes: (value: string | undefined, defaultValue?: string) => {
|
|
271
|
+
VALUE: string | undefined;
|
|
272
|
+
defaultvalue: string | undefined;
|
|
273
|
+
};
|
package/dist/anta_helpers.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HTMLElementBase } from "./element-base";
|
|
2
|
+
import { HTMLElementBase as HTMLElementBase2 } from "./element-base";
|
|
3
|
+
import { jsx, useState, useMemo, useOptionalClientLayoutEffect } from "./jsx-runtime";
|
|
4
|
+
function isDOMNode(value) {
|
|
5
|
+
if (typeof Node === "undefined" || value == null || typeof value !== "object") return false;
|
|
6
|
+
try {
|
|
7
|
+
return Node.prototype.isSameNode.call(value, value);
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
2
12
|
function hasChildren(children) {
|
|
3
13
|
return Array.isArray(children) ? children.length > 0 : children != null;
|
|
4
14
|
}
|
|
15
|
+
function useSelectionMirror(value, defaultValue) {
|
|
16
|
+
const [internalValue, setInternalValue] = useState(value ?? defaultValue);
|
|
17
|
+
const [lastValue, setLastValue] = useState(value);
|
|
18
|
+
if (value !== lastValue) {
|
|
19
|
+
setLastValue(value);
|
|
20
|
+
if (value !== void 0) setInternalValue(value);
|
|
21
|
+
}
|
|
22
|
+
return [value !== void 0 ? value : internalValue, setInternalValue];
|
|
23
|
+
}
|
|
5
24
|
function optionPresentationAttrs(option, menu = false) {
|
|
6
25
|
const attrs = {};
|
|
7
26
|
for (const [name, value] of Object.entries(option)) {
|
|
@@ -20,8 +39,11 @@ function wrapLabel(kids, tag) {
|
|
|
20
39
|
return child;
|
|
21
40
|
});
|
|
22
41
|
}
|
|
42
|
+
function unwrapNativeEvent(event) {
|
|
43
|
+
return "nativeEvent" in event ? event.nativeEvent : event;
|
|
44
|
+
}
|
|
23
45
|
function nativeStateChange(e) {
|
|
24
|
-
const event =
|
|
46
|
+
const event = unwrapNativeEvent(e);
|
|
25
47
|
return { event, detail: event?.detail, isOwn: !event || event.target === event.currentTarget };
|
|
26
48
|
}
|
|
27
49
|
function customEventHandler(handler) {
|
|
@@ -41,6 +63,10 @@ function lineClamp(truncate) {
|
|
|
41
63
|
return lines != null && lines >= 1 ? lines : void 0;
|
|
42
64
|
}
|
|
43
65
|
const NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown", "Tab"]);
|
|
66
|
+
function isComposingKey(event) {
|
|
67
|
+
const native = unwrapNativeEvent(event);
|
|
68
|
+
return native.isComposing || native.keyCode === 229;
|
|
69
|
+
}
|
|
44
70
|
function isModifiedNavigationKey(event) {
|
|
45
71
|
return NAVIGATION_KEYS.has(event.key) && (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey && event.key !== "Tab");
|
|
46
72
|
}
|
|
@@ -52,10 +78,16 @@ function parseOpenState(v) {
|
|
|
52
78
|
}
|
|
53
79
|
function installDismissTrigger(host, attr, onDismiss) {
|
|
54
80
|
host.addEventListener("click", (e) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
let triggered = false;
|
|
82
|
+
for (const target of e.composedPath()) {
|
|
83
|
+
const element = target;
|
|
84
|
+
if (element.nodeType !== 1) continue;
|
|
85
|
+
if (element.localName === host.localName) {
|
|
86
|
+
if (element === host && (triggered || element.hasAttribute(attr))) onDismiss();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (element.hasAttribute(attr)) triggered = true;
|
|
90
|
+
}
|
|
59
91
|
});
|
|
60
92
|
}
|
|
61
93
|
const NAMED_TONES = /* @__PURE__ */ new Set([
|
|
@@ -90,6 +122,7 @@ const COPY_FEEDBACK_MS = 2e3;
|
|
|
90
122
|
function useCopyFeedback(icon, tone, onCopied) {
|
|
91
123
|
const [status, setStatus] = useState("idle");
|
|
92
124
|
const box = useMemo(() => ({ timer: void 0 }), []);
|
|
125
|
+
useOptionalClientLayoutEffect(() => () => clearTimeout(box.timer), [box]);
|
|
93
126
|
const handleCopied = (ok) => {
|
|
94
127
|
clearTimeout(box.timer);
|
|
95
128
|
setStatus(ok ? "ok" : "fail");
|
|
@@ -104,31 +137,28 @@ function anchorRect(el) {
|
|
|
104
137
|
const fn = el.getAnchorRect;
|
|
105
138
|
return typeof fn === "function" ? fn.call(el) : el.getBoundingClientRect();
|
|
106
139
|
}
|
|
107
|
-
|
|
108
|
-
function setMenuPresence(p) {
|
|
109
|
-
|
|
140
|
+
const MENU_PRESENCE = /* @__PURE__ */ Symbol.for("anta.menu-presence");
|
|
141
|
+
function setMenuPresence(p, doc = typeof document === "undefined" ? void 0 : document) {
|
|
142
|
+
if (!doc) return;
|
|
143
|
+
const providers = doc[MENU_PRESENCE] ??= /* @__PURE__ */ new Set();
|
|
144
|
+
if (p) providers.add(p);
|
|
145
|
+
else providers.clear();
|
|
110
146
|
}
|
|
111
|
-
function isMenuOpen() {
|
|
112
|
-
|
|
147
|
+
function isMenuOpen(doc = typeof document === "undefined" ? void 0 : document) {
|
|
148
|
+
if (!doc) return false;
|
|
149
|
+
return [...doc[MENU_PRESENCE] ?? []].some((provider) => provider.isOpen(doc));
|
|
113
150
|
}
|
|
114
151
|
function isInsideOpenMenu(node) {
|
|
115
|
-
|
|
152
|
+
const doc = node.ownerDocument;
|
|
153
|
+
return doc != null && [...doc[MENU_PRESENCE] ?? []].some((provider) => provider.contains(node));
|
|
116
154
|
}
|
|
117
|
-
const SYNC_POPUP_ARIA = /* @__PURE__ */ Symbol("anta.sync-popup-aria");
|
|
155
|
+
const SYNC_POPUP_ARIA = /* @__PURE__ */ Symbol.for("anta.sync-popup-aria");
|
|
118
156
|
function isPopupAriaReceiver(element) {
|
|
119
157
|
return element != null && typeof element[SYNC_POPUP_ARIA] === "function";
|
|
120
158
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
/** This element's own window (the iframe's window when nested). */
|
|
125
|
-
get view() {
|
|
126
|
-
return this.ownerDocument?.defaultView ?? window;
|
|
127
|
-
}
|
|
128
|
-
/** This element's own document (the iframe's document when nested). */
|
|
129
|
-
get doc() {
|
|
130
|
-
return this.ownerDocument ?? document;
|
|
131
|
-
}
|
|
159
|
+
const SYNC_TEXT_TOGGLE = /* @__PURE__ */ Symbol.for("anta.sync-text-toggle");
|
|
160
|
+
function isTextToggleReceiver(element) {
|
|
161
|
+
return element != null && typeof element[SYNC_TEXT_TOGGLE] === "function";
|
|
132
162
|
}
|
|
133
163
|
function applyAccessibilityRelations(internals, labels, descriptions) {
|
|
134
164
|
if (!internals) return;
|
|
@@ -195,13 +225,18 @@ class SelectableChildElement extends HTMLElementBase {
|
|
|
195
225
|
applyAccessibilityRelations(this.internals, labels, descriptions);
|
|
196
226
|
}
|
|
197
227
|
}
|
|
228
|
+
const valueAttributes = (value, defaultValue) => ({
|
|
229
|
+
VALUE: value,
|
|
230
|
+
defaultvalue: value === void 0 ? defaultValue : void 0
|
|
231
|
+
});
|
|
198
232
|
export {
|
|
199
|
-
HTMLElementBase,
|
|
233
|
+
HTMLElementBase2 as HTMLElementBase,
|
|
200
234
|
ISOLATE_HINT,
|
|
201
235
|
ISOLATE_HINT_DELAY,
|
|
202
236
|
IS_MAC,
|
|
203
237
|
NAMED_TONES,
|
|
204
238
|
SYNC_POPUP_ARIA,
|
|
239
|
+
SYNC_TEXT_TOGGLE,
|
|
205
240
|
SelectableChildElement,
|
|
206
241
|
anchorRect,
|
|
207
242
|
applyAccessibilityRelations,
|
|
@@ -210,10 +245,13 @@ export {
|
|
|
210
245
|
finiteNumber,
|
|
211
246
|
hasChildren,
|
|
212
247
|
installDismissTrigger,
|
|
248
|
+
isComposingKey,
|
|
249
|
+
isDOMNode,
|
|
213
250
|
isInsideOpenMenu,
|
|
214
251
|
isMenuOpen,
|
|
215
252
|
isModifiedNavigationKey,
|
|
216
253
|
isPopupAriaReceiver,
|
|
254
|
+
isTextToggleReceiver,
|
|
217
255
|
lengthStyle,
|
|
218
256
|
lineClamp,
|
|
219
257
|
nativeStateChange,
|
|
@@ -224,6 +262,9 @@ export {
|
|
|
224
262
|
roundStyle,
|
|
225
263
|
setMenuPresence,
|
|
226
264
|
toneStyle,
|
|
265
|
+
unwrapNativeEvent,
|
|
227
266
|
useCopyFeedback,
|
|
267
|
+
useSelectionMirror,
|
|
268
|
+
valueAttributes,
|
|
228
269
|
wrapLabel
|
|
229
270
|
};
|