@antadesign/anta 0.3.25 → 0.3.26
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.js +3 -3
- package/dist/box-types.d.ts +161 -0
- package/dist/box-types.js +0 -0
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +25 -25
- package/dist/components/Box.d.ts +37 -0
- package/dist/components/Box.js +63 -0
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.js +4 -4
- package/dist/elements/a-box.css +1 -0
- package/dist/elements/a-box.d.ts +41 -0
- package/dist/elements/a-box.js +576 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-calendar.js +2 -2
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.js +2 -2
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.js +3 -3
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.js +6 -6
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.js +3 -3
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.js +2 -2
- package/dist/elements/a-radio-group.js +3 -3
- package/dist/elements/a-radio.css +1 -1
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-switch.js +2 -2
- package/dist/elements/a-tabpanel.js +2 -2
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.js +6 -6
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-toast.js +2 -2
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +4 -3
- package/dist/elements/a-tooltip.js +9 -5
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/general_types.d.ts +36 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/jsx-runtime.d.ts +2 -1
- package/docs/changelog.md +23 -3
- package/docs/components/avatar.md +368 -0
- package/docs/components/box.md +282 -0
- package/docs/index.md +4 -3
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { BoxContextChange, BoxDisplay, BoxMeasurementChange } from '../box-types';
|
|
2
|
+
import type { BaseProps } from '../general_types';
|
|
3
|
+
/** JSX props for the observing light-DOM `<a-box>` container. */
|
|
4
|
+
export interface BoxProps extends BaseProps {
|
|
5
|
+
/** Layout model for the host. All other layout, sizing, mask, and shadow
|
|
6
|
+
* properties stay ordinary `className` / `style` CSS on the Box itself.
|
|
7
|
+
* @defaultValue block */
|
|
8
|
+
display?: BoxDisplay;
|
|
9
|
+
/** Fully-round corners (`border-radius: 999px`, clamped to the box). Pass a
|
|
10
|
+
* `number` (px) or a CSS length string (`'1rem'`) for a custom radius. Omit
|
|
11
|
+
* for square corners. */
|
|
12
|
+
round?: boolean | number | string;
|
|
13
|
+
/** Gap between children, matching the CSS `gap` property. A `number` is
|
|
14
|
+
* pixels; a string is any CSS length or two-value gap (`'1rem'`,
|
|
15
|
+
* `'8px 16px'`). Applies while the Box is a flex or grid container. */
|
|
16
|
+
gap?: number | string;
|
|
17
|
+
/** What the Box watches, when a handler is not what turns it on. `'size'`
|
|
18
|
+
* keeps the overflow CSS states (`:state(clipped-x)`, `:state(scrollable-y)`,
|
|
19
|
+
* …) current — reach for it when your own CSS is the only reader. `'context'`
|
|
20
|
+
* and `'all'` are there for symmetry; passing `onMeasureChange` or
|
|
21
|
+
* `onContextChange` already turns the matching half on. */
|
|
22
|
+
observe?: 'size' | 'context' | 'all';
|
|
23
|
+
/** Fades out every edge that currently hides clipped content, and drops the
|
|
24
|
+
* fade from an edge once the reader scrolls to it. */
|
|
25
|
+
fade?: boolean;
|
|
26
|
+
/** Depth of the `fade` gradient. A `number` is pixels; a string is any CSS
|
|
27
|
+
* length.
|
|
28
|
+
* @defaultValue 24 */
|
|
29
|
+
fadeSize?: number | string;
|
|
30
|
+
/** Fired after Box geometry or its content-overflow state changes. `detail`
|
|
31
|
+
* contains the changed fields and a full current snapshot. */
|
|
32
|
+
onMeasureChange?: (event: CustomEvent<BoxMeasurementChange>, detail: BoxMeasurementChange) => void;
|
|
33
|
+
/** Fired after Box's browser and local rendering context changes. `detail`
|
|
34
|
+
* contains the changed fields and a full current snapshot. */
|
|
35
|
+
onContextChange?: (event: CustomEvent<BoxContextChange>, detail: BoxContextChange) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare const Box: ({ display, round, gap, observe, fade, fadeSize, onMeasureChange, onContextChange, className, style, children, ...rest }: BoxProps) => any;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
cssLength,
|
|
4
|
+
lengthStyle,
|
|
5
|
+
nativeStateChange,
|
|
6
|
+
roundAttr,
|
|
7
|
+
roundStyle
|
|
8
|
+
} from "../anta_helpers";
|
|
9
|
+
function observeAttr(observe, onMeasureChange, onContextChange) {
|
|
10
|
+
const size = observe === "size" || observe === "all" || onMeasureChange != null;
|
|
11
|
+
const context = observe === "context" || observe === "all" || onContextChange != null;
|
|
12
|
+
if (size && context) return "all";
|
|
13
|
+
if (size) return "size";
|
|
14
|
+
if (context) return "context";
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
const Box = ({
|
|
18
|
+
display,
|
|
19
|
+
round,
|
|
20
|
+
gap,
|
|
21
|
+
observe,
|
|
22
|
+
fade,
|
|
23
|
+
fadeSize,
|
|
24
|
+
onMeasureChange,
|
|
25
|
+
onContextChange,
|
|
26
|
+
className,
|
|
27
|
+
style,
|
|
28
|
+
children,
|
|
29
|
+
...rest
|
|
30
|
+
}) => {
|
|
31
|
+
const measureHandler = onMeasureChange ? (input) => {
|
|
32
|
+
const { event, detail } = nativeStateChange(input);
|
|
33
|
+
if (detail) onMeasureChange(event, detail);
|
|
34
|
+
} : void 0;
|
|
35
|
+
const contextHandler = onContextChange ? (input) => {
|
|
36
|
+
const { event, detail } = nativeStateChange(input);
|
|
37
|
+
if (detail) onContextChange(event, detail);
|
|
38
|
+
} : void 0;
|
|
39
|
+
return /* @__PURE__ */ jsx(
|
|
40
|
+
"a-box",
|
|
41
|
+
{
|
|
42
|
+
display: display === "block" ? void 0 : display,
|
|
43
|
+
round: roundAttr(round),
|
|
44
|
+
gap: gap != null ? "" : void 0,
|
|
45
|
+
observe: observeAttr(observe, onMeasureChange, onContextChange),
|
|
46
|
+
fade: fade ? "" : void 0,
|
|
47
|
+
"fade-size": fade && fadeSize != null ? cssLength(fadeSize) : void 0,
|
|
48
|
+
onmeasurechange: measureHandler,
|
|
49
|
+
oncontextchange: contextHandler,
|
|
50
|
+
class: className,
|
|
51
|
+
style: lengthStyle(
|
|
52
|
+
fade ? fadeSize : void 0,
|
|
53
|
+
"--box-fade-size",
|
|
54
|
+
lengthStyle(gap, "--box-gap", roundStyle(round, "--box-round", style))
|
|
55
|
+
),
|
|
56
|
+
...rest,
|
|
57
|
+
children
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
Box
|
|
63
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta.components{a-avatar{--avatar-size: 44px;--avatar-radius: 22%;--avatar-placeholder-bg: var(--bg-3);--avatar-badge-ratio: .24;--avatar-badge-size: calc(var(--avatar-size) * var(--avatar-badge-ratio));--avatar-badge-inset: 0px;--avatar-badge-gap: 2px;--avatar-badge-mask: none;--avatar-badge-tone-source: var(--anta-seed-neutral);--avatar-badge-chroma: .17;--avatar-badge-color: oklch(from var(--avatar-badge-tone-source) .62 var(--avatar-badge-chroma) h);display:inline-block;inline-size:var(--avatar-size);block-size:var(--avatar-size);vertical-align:middle}a-avatar[round]{--avatar-
|
|
1
|
+
@layer anta.components{a-avatar{--avatar-size: 44px;--avatar-radius: 22%;--avatar-placeholder-bg: var(--bg-3);--avatar-badge-ratio: .24;--avatar-badge-size: calc(var(--avatar-size) * var(--avatar-badge-ratio));--avatar-badge-inset: 0px;--avatar-badge-gap: 2px;--avatar-badge-mask: none;--avatar-badge-tone-source: var(--anta-seed-neutral);--avatar-badge-chroma: .17;--avatar-badge-color: oklch(from var(--avatar-badge-tone-source) .62 var(--avatar-badge-chroma) h);display:inline-block;inline-size:var(--avatar-size);block-size:var(--avatar-size);vertical-align:middle}a-avatar[round]{--avatar-radius: var(--avatar-round, 50%);--avatar-badge-inset: calc(var(--avatar-size) * .03);@supports (border-radius: attr(probe type(<length>),1px)){--avatar-round: attr(round type(<length>))}}a-avatar[size=small]{--avatar-size: 32px;--avatar-badge-gap: 1.5px}a-avatar[size=large]{--avatar-size: 64px;--avatar-badge-gap: 2.5px}a-avatar[badge]:not([badge=""],[badge=none]){--avatar-badge-mask: radial-gradient( circle calc(var(--avatar-badge-size) / 2 + var(--avatar-badge-gap)) at calc(100% - var(--avatar-badge-inset) - var(--avatar-badge-size) / 2) calc(100% - var(--avatar-badge-inset) - var(--avatar-badge-size) / 2), transparent 99%, #000 100% )}a-avatar:not(:defined){display:inline-block;inline-size:var(--avatar-size);block-size:var(--avatar-size);border-radius:var(--avatar-radius);background:var(--avatar-placeholder-bg);vertical-align:middle}a-avatar[badge=neutral]{--avatar-badge-chroma: .005}a-avatar[badge=brand]{--avatar-badge-tone-source: var(--anta-seed-brand)}a-avatar[badge=info]{--avatar-badge-tone-source: var(--anta-seed-info)}a-avatar[badge=success]{--avatar-badge-tone-source: var(--anta-seed-success)}a-avatar[badge=warning]{--avatar-badge-tone-source: var(--anta-seed-warning)}a-avatar[badge=critical]{--avatar-badge-tone-source: var(--anta-seed-critical)}@supports (color: attr(badge type(<color>),transparent)){a-avatar[badge]:not([badge=""],[badge=neutral],[badge=brand],[badge=info],[badge=success],[badge=warning],[badge=critical]){--avatar-badge-tone-source: attr(badge type(<color>), transparent)}}.dark a-avatar{--avatar-badge-color: oklch(from var(--avatar-badge-tone-source) .68 var(--avatar-badge-chroma) h)}.dark a-avatar[badge=neutral]{--avatar-badge-chroma: .008}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer anta.components{a-banner{--banner-bg: var(--bg-4);--banner-border: var(--border-4);--banner-text: var(--text-2);display:flex;align-items:center;justify-content:flex-start;flex-wrap:wrap;gap:4px 1ch;position:relative;box-sizing:border-box;width:100%;min-height:40px;padding-block:6px;padding-inline:16px 48px;color:var(--banner-text);background:var(--banner-bg);border:0 solid var(--banner-border);border-radius:0;overflow:clip;overflow-clip-margin:3px;interpolate-size:allow-keywords;transition:opacity .16s ease,block-size .2s ease,padding-block .2s ease,border-block-width .2s ease,display .2s allow-discrete}a-banner[align=center]{justify-content:center;padding-inline:48px}a-banner[round]{--banner-round: attr(
|
|
1
|
+
@layer anta.components{a-banner{--banner-bg: var(--bg-4);--banner-border: var(--border-4);--banner-text: var(--text-2);display:flex;align-items:center;justify-content:flex-start;flex-wrap:wrap;gap:4px 1ch;position:relative;box-sizing:border-box;width:100%;min-height:40px;padding-block:6px;padding-inline:16px 48px;color:var(--banner-text);background:var(--banner-bg);border:0 solid var(--banner-border);border-radius:0;overflow:clip;overflow-clip-margin:3px;interpolate-size:allow-keywords;transition:opacity .16s ease,block-size .2s ease,padding-block .2s ease,border-block-width .2s ease,display .2s allow-discrete}a-banner[align=center]{justify-content:center;padding-inline:48px}a-banner[round]{border-radius:var(--banner-round, 999px);@supports (border-radius: attr(probe type(<length>),1px)){--banner-round: attr(round type(<length>))}}a-banner [slot=close] a-button,a-banner a-button[slot=close]{height:100%;width:40px}a-banner-message{font-size:14px;line-height:20px;font-weight:475;text-align:start}a-banner[align=center] a-banner-message{text-align:center}a-banner[tone=brand]{--banner-bg: var(--bg-4-brand);--banner-border: var(--border-4-brand);--banner-text: var(--text-2-brand)}a-banner[tone=info]{--banner-bg: var(--bg-4-info);--banner-border: var(--border-4-info);--banner-text: var(--text-2-info)}a-banner[tone=success]{--banner-bg: var(--bg-4-success);--banner-border: var(--border-4-success);--banner-text: var(--text-2-success)}a-banner[tone=warning]{--banner-bg: var(--bg-4-warning);--banner-border: var(--border-4-warning);--banner-text: var(--text-2-warning)}a-banner[tone=critical]{--banner-bg: var(--bg-4-critical);--banner-border: var(--border-4-critical);--banner-text: var(--text-2-critical)}a-banner[tone]:not([tone=""],[tone=neutral],[tone=brand],[tone=info],[tone=success],[tone=warning],[tone=critical]){--banner-tone-source: currentColor;--banner-text: oklch(from var(--banner-tone-source) .5 .125 h);--banner-bg: oklch(from var(--banner-tone-source) .955 .02 h);--banner-border: oklch(from var(--banner-tone-source) .9 .04 h);.dark &{--banner-text: oklch(from var(--banner-tone-source) .77 .11 h);--banner-bg: oklch(from var(--banner-tone-source) .185 .05 h);--banner-border: oklch(from var(--banner-tone-source) .26 .06 h)}@supports (color: attr(probe type(<color>),red)){--banner-tone-source: attr(tone type(<color>), currentColor)}}a-banner:not(:defined){opacity:0}a-banner[state=closed],a-banner[default-state=closed],a-banner:state(closed){display:none;block-size:0;min-block-size:0;padding-block:0;border-block-width:0;opacity:0}@media(forced-colors:active){a-banner{border-width:1px;border-color:CanvasText}}@media(prefers-reduced-motion:reduce){a-banner{transition:none}}}
|
|
@@ -114,11 +114,11 @@ class ABannerElement extends HTMLElementBase {
|
|
|
114
114
|
if (!this.#internals) return;
|
|
115
115
|
try {
|
|
116
116
|
if (state === "closed") {
|
|
117
|
-
this.#internals
|
|
118
|
-
this.#internals
|
|
117
|
+
this.#internals?.states?.add("closed");
|
|
118
|
+
this.#internals?.states?.delete("open");
|
|
119
119
|
} else {
|
|
120
|
-
this.#internals
|
|
121
|
-
this.#internals
|
|
120
|
+
this.#internals?.states?.add("open");
|
|
121
|
+
this.#internals?.states?.delete("closed");
|
|
122
122
|
}
|
|
123
123
|
} catch {
|
|
124
124
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer anta.components{a-box{display:block;min-width:0}a-box[display=inline-block]{display:inline-block}a-box[display=flex]{display:flex}a-box[display=inline-flex]{display:inline-flex}a-box[display=grid]{display:grid}a-box[display=inline-grid]{display:inline-grid}a-box[gap]{gap:var(--box-gap, normal);@supports (border-radius: attr(probe type(<length>),1px)){--box-gap: attr(gap type(<length>))}}a-box[round]{border-radius:var(--box-round, 999px);@supports (border-radius: attr(probe type(<length>),1px)){--box-round: attr(round type(<length>))}}a-box[fade]{--box-fade-size: 24px;--box-fade-x: linear-gradient(transparent, transparent);--box-fade-y: linear-gradient(transparent, transparent);--box-fade-to-start: to left;--box-fade-to-end: to right}a-box[fade]:is(:state(hidden-start-x),:state(hidden-end-x),:state(hidden-start-y),:state(hidden-end-y)){mask-image:linear-gradient(#000,#000),var(--box-fade-x),var(--box-fade-y);mask-clip:border-box,padding-box,padding-box;mask-origin:border-box,padding-box,padding-box;mask-composite:exclude,add,add;mask-repeat:no-repeat;mask-size:100% 100%}a-box[fade][fade-size]{--box-fade-size: 24px;@supports (border-radius: attr(probe type(<length>),1px)){--box-fade-size: attr(fade-size type(<length>), 24px)}}a-box[fade]:dir(rtl){--box-fade-to-start: to right;--box-fade-to-end: to left}a-box[fade]:state(hidden-end-x){--box-fade-x: linear-gradient(var(--box-fade-to-end), transparent calc(100% - var(--box-fade-size)), black)}a-box[fade]:state(hidden-start-x){--box-fade-x: linear-gradient(var(--box-fade-to-start), transparent calc(100% - var(--box-fade-size)), black)}a-box[fade]:state(hidden-start-x):state(hidden-end-x){--box-fade-x: linear-gradient( to right, black, transparent var(--box-fade-size), transparent calc(100% - var(--box-fade-size)), black )}a-box[fade]:state(hidden-end-y){--box-fade-y: linear-gradient(to bottom, transparent calc(100% - var(--box-fade-size)), black)}a-box[fade]:state(hidden-start-y){--box-fade-y: linear-gradient(to top, transparent calc(100% - var(--box-fade-size)), black)}a-box[fade]:state(hidden-start-y):state(hidden-end-y){--box-fade-y: linear-gradient( to bottom, black, transparent var(--box-fade-size), transparent calc(100% - var(--box-fade-size)), black )}}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HTMLElementBase } from '../anta_helpers';
|
|
2
|
+
import type { BoxContext, BoxMeasurement } from '../box-types';
|
|
3
|
+
import './a-box.css';
|
|
4
|
+
/**
|
|
5
|
+
* `<a-box>` is a light-DOM container that observes itself. It leaves the host
|
|
6
|
+
* and its children entirely to the renderer: all output is read-only getters,
|
|
7
|
+
* `measurechange` / `contextchange` events, and private `ElementInternals`
|
|
8
|
+
* states. This keeps measurement usable when JSX itself cannot access the DOM.
|
|
9
|
+
*
|
|
10
|
+
* Observation is opt-in by attribute and pauses off screen. `fade` or
|
|
11
|
+
* `observe="size"` turns measurement on, `observe="context"` turns
|
|
12
|
+
* `contextchange` on, `observe="all"` (or a bare `observe`) turns on both, and a box
|
|
13
|
+
* with neither runs no observers at all — not even the shared visibility one.
|
|
14
|
+
* The `measurement` / `context` / `isTruncated` getters still read on demand.
|
|
15
|
+
*
|
|
16
|
+
* Attributes rather than "is a listener attached" on purpose. A listener tally
|
|
17
|
+
* cannot see listeners added before the element upgrades (the SSR pattern in
|
|
18
|
+
* AGENTS.md), cannot see `once` or `AbortSignal` removals, and churns on every
|
|
19
|
+
* React 19 render, because React removes and re-adds an `on*` prop whenever its
|
|
20
|
+
* identity changes. The JSX wrapper stamps both attributes from its handler
|
|
21
|
+
* props, so this is invisible to anyone using `Box`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ABoxElement extends HTMLElementBase {
|
|
24
|
+
#private;
|
|
25
|
+
static observedAttributes: string[];
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
attributeChangedCallback(): void;
|
|
29
|
+
/** A fresh measurement snapshot. For notifications, prefer `measurechange`:
|
|
30
|
+
* it batches browser observers and includes the field-level delta. */
|
|
31
|
+
get measurement(): BoxMeasurement;
|
|
32
|
+
/** A fresh context snapshot. For changes, prefer `contextchange`. */
|
|
33
|
+
get context(): BoxContext;
|
|
34
|
+
/** Allows a nested `Tooltip truncatedOnly` to use Box's clipping decision. */
|
|
35
|
+
get isTruncated(): boolean;
|
|
36
|
+
/** Called by the per-window context cache. It is intentionally not a JSX prop. */
|
|
37
|
+
contextStoreDidChange(): void;
|
|
38
|
+
/** Called by the per-window visibility observer. Also not a JSX prop. */
|
|
39
|
+
visibilityDidChange(visible: boolean): void;
|
|
40
|
+
}
|
|
41
|
+
export declare function register_a_box(): void;
|