@antadesign/anta 0.3.25 → 0.3.27
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/README.md +26 -28
- package/dist/anta_helpers.d.ts +4 -0
- package/dist/anta_helpers.js +17 -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/capture-types.d.ts +156 -0
- package/dist/capture-types.js +0 -0
- package/dist/components/Box.d.ts +52 -0
- package/dist/components/Box.js +55 -0
- package/dist/components/Capture.d.ts +39 -0
- package/dist/components/Capture.js +36 -0
- package/dist/components/capture-props.d.ts +30 -0
- package/dist/components/capture-props.js +44 -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 +584 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-calendar.js +2 -2
- package/dist/elements/a-capture.css +1 -0
- package/dist/elements/a-capture.d.ts +10 -0
- package/dist/elements/a-capture.js +24 -0
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-checkbox.js +4 -4
- 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-slider.js +6 -6
- 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/capture-input.d.ts +5 -0
- package/dist/elements/capture-input.js +609 -0
- package/dist/elements/index.d.ts +2 -0
- package/dist/elements/index.js +6 -0
- package/dist/general_types.d.ts +70 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/jsx-runtime.d.ts +3 -1
- package/docs/accessibility.md +24 -0
- package/docs/changelog.md +45 -3
- package/docs/colors.md +141 -0
- package/docs/comparison.md +463 -28
- package/docs/components/avatar.md +364 -0
- package/docs/components/banner.md +13 -27
- package/docs/components/box.md +354 -0
- package/docs/components/breadcrumbs.md +7 -6
- package/docs/components/button.md +48 -37
- package/docs/components/capture.md +345 -0
- package/docs/components/card.md +17 -38
- package/docs/components/checkbox.md +16 -39
- package/docs/components/dialog.md +14 -36
- package/docs/components/expander.md +15 -40
- package/docs/components/icon.md +111 -9
- package/docs/components/input-autocomplete.md +9 -11
- package/docs/components/input-date.md +33 -23
- package/docs/components/input-time.md +15 -23
- package/docs/components/input.md +27 -76
- package/docs/components/loader.md +7 -5
- package/docs/components/menu.md +73 -77
- package/docs/components/progress.md +10 -14
- package/docs/components/radio.md +17 -36
- package/docs/components/select-faceted.md +7 -25
- package/docs/components/select.md +24 -97
- package/docs/components/slider.md +16 -21
- package/docs/components/steps.md +38 -8
- package/docs/components/switch.md +11 -14
- package/docs/components/tabs.md +52 -40
- package/docs/components/tag.md +11 -22
- package/docs/components/text.md +10 -23
- package/docs/components/title.md +7 -8
- package/docs/components/toaster.md +6 -3
- package/docs/components/tooltip.md +13 -23
- package/docs/index.md +6 -3
- package/docs/install-config.md +24 -0
- package/docs/normalization.md +45 -0
- package/docs/packages/stickers.md +56 -0
- package/docs/theming.md +270 -0
- package/package.json +3 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/** Directions of wheel or scroll deltas. Positive Y is down; positive X is right. */
|
|
2
|
+
export type CaptureInputDirection = 'up' | 'down' | 'left' | 'right';
|
|
3
|
+
/** `true` accepts every direction; omitted object entries decline that direction. */
|
|
4
|
+
export type CaptureInputDirections = boolean | Partial<Record<CaptureInputDirection, boolean>>;
|
|
5
|
+
/** `none` accepts unmodified input; a named modifier must be pressed. */
|
|
6
|
+
export type CaptureInputModifier = 'none' | 'any' | 'alt' | 'ctrl' | 'meta' | 'shift';
|
|
7
|
+
export type CaptureWheelActivation = 'hover' | 'settled' | 'focus' | 'settled-or-focus';
|
|
8
|
+
export type CaptureWheelActivationReason = 'immediate' | 'settled' | 'focus';
|
|
9
|
+
export interface CaptureWheelSettle {
|
|
10
|
+
/** Pointer dwell time in milliseconds.
|
|
11
|
+
* @defaultValue 150 */
|
|
12
|
+
delay?: number;
|
|
13
|
+
/** Maximum movement from the dwell anchor on either axis, in CSS pixels.
|
|
14
|
+
* @defaultValue 5 */
|
|
15
|
+
tolerance?: number;
|
|
16
|
+
/** Restart dwell after movement beyond tolerance, including after activation.
|
|
17
|
+
* @defaultValue false */
|
|
18
|
+
resetOnMove?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export type CapturePointerType = 'mouse' | 'pen' | 'touch';
|
|
21
|
+
export interface CapturePointerCapture {
|
|
22
|
+
/** Accepted pointer devices. One primary pointer is tracked per Capture.
|
|
23
|
+
* @defaultValue ['mouse', 'pen', 'touch'] */
|
|
24
|
+
pointerTypes?: readonly CapturePointerType[];
|
|
25
|
+
/** Accepted initiating buttons, using PointerEvent.button values.
|
|
26
|
+
* @defaultValue [0] */
|
|
27
|
+
buttons?: readonly number[];
|
|
28
|
+
/** Movement required before activation, in viewport CSS pixels.
|
|
29
|
+
* @defaultValue 0 */
|
|
30
|
+
threshold?: number;
|
|
31
|
+
/** Modifier required to start a capture session.
|
|
32
|
+
* @defaultValue any */
|
|
33
|
+
modifier?: CaptureInputModifier;
|
|
34
|
+
/** Allow capture to start on nested native or ARIA controls, links, or editable regions.
|
|
35
|
+
* @defaultValue false */
|
|
36
|
+
includeInteractive?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface CapturePanInertia {
|
|
39
|
+
/** Exponential velocity decay time constant in milliseconds.
|
|
40
|
+
* @defaultValue 325 */
|
|
41
|
+
timeConstant?: number;
|
|
42
|
+
/** Stop when speed on both axes falls below this value, in CSS pixels/ms.
|
|
43
|
+
* @defaultValue 0.02 */
|
|
44
|
+
minVelocity?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface CapturePan {
|
|
47
|
+
/** Accepted pointer devices.
|
|
48
|
+
* @defaultValue ['touch'] */
|
|
49
|
+
pointerTypes?: readonly CapturePointerType[];
|
|
50
|
+
/** Axes handled by custom panning. CSS touch-action leaves the other axis to the browser.
|
|
51
|
+
* @defaultValue both */
|
|
52
|
+
axis?: 'x' | 'y' | 'both';
|
|
53
|
+
/** Movement required before activation, in viewport CSS pixels.
|
|
54
|
+
* @defaultValue 3 */
|
|
55
|
+
threshold?: number;
|
|
56
|
+
/** Allowed scroll directions. Updating these can stop motion at application bounds.
|
|
57
|
+
* @defaultValue true */
|
|
58
|
+
directions?: CaptureInputDirections;
|
|
59
|
+
/** Continue panning after release with browser-side velocity decay.
|
|
60
|
+
* @defaultValue false */
|
|
61
|
+
inertia?: boolean | CapturePanInertia;
|
|
62
|
+
}
|
|
63
|
+
/** Plain event data. DOM targets, methods, and browser objects are excluded. */
|
|
64
|
+
export interface SerializedMouseEvent {
|
|
65
|
+
type: string;
|
|
66
|
+
timeStamp: number;
|
|
67
|
+
isTrusted: boolean;
|
|
68
|
+
cancelable: boolean;
|
|
69
|
+
defaultPrevented: boolean;
|
|
70
|
+
altKey: boolean;
|
|
71
|
+
ctrlKey: boolean;
|
|
72
|
+
metaKey: boolean;
|
|
73
|
+
shiftKey: boolean;
|
|
74
|
+
button: number;
|
|
75
|
+
buttons: number;
|
|
76
|
+
clientX: number;
|
|
77
|
+
clientY: number;
|
|
78
|
+
pageX: number;
|
|
79
|
+
pageY: number;
|
|
80
|
+
screenX: number;
|
|
81
|
+
screenY: number;
|
|
82
|
+
/** Coordinates relative to the original event target's padding edge. */
|
|
83
|
+
offsetX: number;
|
|
84
|
+
offsetY: number;
|
|
85
|
+
}
|
|
86
|
+
/** Original wheel values, including their original units and signs. */
|
|
87
|
+
export interface SerializedWheelEvent extends SerializedMouseEvent {
|
|
88
|
+
deltaX: number;
|
|
89
|
+
deltaY: number;
|
|
90
|
+
deltaZ: number;
|
|
91
|
+
deltaMode: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SerializedPointerEvent extends SerializedMouseEvent {
|
|
94
|
+
pointerId: number;
|
|
95
|
+
pointerType: string;
|
|
96
|
+
isPrimary: boolean;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
pressure: number;
|
|
100
|
+
tangentialPressure: number;
|
|
101
|
+
tiltX: number;
|
|
102
|
+
tiltY: number;
|
|
103
|
+
twist: number;
|
|
104
|
+
}
|
|
105
|
+
/** Geometry measured at delivery. CSS transforms are included in the viewport rectangle. */
|
|
106
|
+
export interface CaptureInputGeometry {
|
|
107
|
+
/** Pointer position relative to the viewport bounding rectangle's top-left, in CSS pixels. */
|
|
108
|
+
localX: number;
|
|
109
|
+
localY: number;
|
|
110
|
+
/** Dimensions of the same viewport bounding rectangle, in CSS pixels. */
|
|
111
|
+
boxWidth: number;
|
|
112
|
+
boxHeight: number;
|
|
113
|
+
/** Whether the pointer is inside that rectangle. Capture can continue outside it. */
|
|
114
|
+
inside: boolean;
|
|
115
|
+
focusWithin: boolean;
|
|
116
|
+
}
|
|
117
|
+
/** An accepted wheel input. Cancellation has already happened on the browser thread. */
|
|
118
|
+
export interface CaptureWheelInput extends CaptureInputGeometry {
|
|
119
|
+
wheelEvent: SerializedWheelEvent;
|
|
120
|
+
activationReason: CaptureWheelActivationReason;
|
|
121
|
+
}
|
|
122
|
+
export type CapturePointerActivationReason = 'pointer-down' | 'drag-threshold';
|
|
123
|
+
export type CaptureInputCancelReason = 'pointer-cancel' | 'lost-capture' | 'disabled' | 'disconnected' | 'blur' | 'interrupted';
|
|
124
|
+
export interface CapturePointerStart extends CaptureInputGeometry {
|
|
125
|
+
pointerEvent: SerializedPointerEvent;
|
|
126
|
+
}
|
|
127
|
+
/** A captured pointer session. Positive movement follows the pointer right/down. */
|
|
128
|
+
export interface CapturePointerInput extends CaptureInputGeometry {
|
|
129
|
+
phase: 'start' | 'move' | 'end' | 'cancel';
|
|
130
|
+
/** Null when cancellation comes from lifecycle or configuration changes. */
|
|
131
|
+
pointerEvent: SerializedPointerEvent | null;
|
|
132
|
+
start: CapturePointerStart;
|
|
133
|
+
/** Movement since the previous delivered sample, in viewport CSS pixels. */
|
|
134
|
+
deltaX: number;
|
|
135
|
+
deltaY: number;
|
|
136
|
+
/** Total movement from the initial press, in viewport CSS pixels. */
|
|
137
|
+
movementX: number;
|
|
138
|
+
movementY: number;
|
|
139
|
+
activationReason: CapturePointerActivationReason;
|
|
140
|
+
cancelReason?: CaptureInputCancelReason;
|
|
141
|
+
}
|
|
142
|
+
/** Custom scroll motion. Deltas have the opposite sign to finger movement. */
|
|
143
|
+
export interface CapturePanInput extends CaptureInputGeometry {
|
|
144
|
+
phase: 'start' | 'move' | 'release' | 'inertia' | 'end' | 'cancel';
|
|
145
|
+
/** Null during momentum or cancellation without a pointer event. */
|
|
146
|
+
pointerEvent: SerializedPointerEvent | null;
|
|
147
|
+
start: CapturePointerStart;
|
|
148
|
+
/** Incremental scroll motion in viewport CSS pixels. */
|
|
149
|
+
deltaX: number;
|
|
150
|
+
deltaY: number;
|
|
151
|
+
/** Scroll velocity in viewport CSS pixels/ms. */
|
|
152
|
+
velocityX: number;
|
|
153
|
+
velocityY: number;
|
|
154
|
+
activationReason: CapturePointerActivationReason;
|
|
155
|
+
cancelReason?: CaptureInputCancelReason;
|
|
156
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
/**
|
|
38
|
+
* A light-DOM CSS box with browser-owned observation. `Box` is deliberately a
|
|
39
|
+
* thin JSX projection: it never holds a DOM ref. The element measures itself,
|
|
40
|
+
* tracks clipping and focus within, and emits native custom events so this works
|
|
41
|
+
* with React, Preact, and DOMs reconciled outside the UI thread.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <Box display="grid" onMeasureChange={(event, { current }) => {
|
|
46
|
+
* console.log(current.width, current.clippedX)
|
|
47
|
+
* }}>
|
|
48
|
+
* <Text truncate>Long content</Text>
|
|
49
|
+
* </Box>
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const Box: ({ display, round, gap, observe, fade, fadeSize, onMeasureChange, onContextChange, className, style, children, ...rest }: BoxProps) => any;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
cssLength,
|
|
4
|
+
customEventHandler,
|
|
5
|
+
lengthStyle,
|
|
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
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"a-box",
|
|
33
|
+
{
|
|
34
|
+
display: display === "block" ? void 0 : display,
|
|
35
|
+
round: roundAttr(round),
|
|
36
|
+
gap: gap != null ? "" : void 0,
|
|
37
|
+
observe: observeAttr(observe, onMeasureChange, onContextChange),
|
|
38
|
+
fade: fade ? "" : void 0,
|
|
39
|
+
"fade-size": fade && fadeSize != null ? cssLength(fadeSize) : void 0,
|
|
40
|
+
onmeasurechange: customEventHandler(onMeasureChange),
|
|
41
|
+
oncontextchange: customEventHandler(onContextChange),
|
|
42
|
+
class: className,
|
|
43
|
+
style: lengthStyle(
|
|
44
|
+
fade ? fadeSize : void 0,
|
|
45
|
+
"--box-fade-size",
|
|
46
|
+
lengthStyle(gap, "--box-gap", roundStyle(round, "--box-round", style))
|
|
47
|
+
),
|
|
48
|
+
...rest,
|
|
49
|
+
children
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
Box
|
|
55
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BaseProps } from '../general_types';
|
|
2
|
+
import type { CaptureInputDirections, CaptureInputModifier, CapturePan, CapturePanInput, CapturePointerCapture, CapturePointerInput, CaptureWheelActivation, CaptureWheelInput, CaptureWheelSettle } from '../capture-types';
|
|
3
|
+
/** Opt-in input ownership for the light-DOM capture surface. */
|
|
4
|
+
export interface CaptureProps extends BaseProps {
|
|
5
|
+
/** Capture wheel input in the enabled directions and emit `onWheelInput`.
|
|
6
|
+
* `true` accepts all directions. Omit or pass `false` to leave wheel input alone.
|
|
7
|
+
* Nested native wheel controls and Anta menus are excluded.
|
|
8
|
+
* All-false direction bounds preserve pointer settling while declining input.
|
|
9
|
+
* A listener alone never enables capture. */
|
|
10
|
+
wheelCapture?: CaptureInputDirections;
|
|
11
|
+
/** Pointer or focus condition required before wheel input can be captured.
|
|
12
|
+
* Focus applies only to input targeted within this Capture.
|
|
13
|
+
* @defaultValue settled */
|
|
14
|
+
wheelActivation?: CaptureWheelActivation;
|
|
15
|
+
/** Required modifier for wheel capture. `none` preserves browser Ctrl/pinch zoom.
|
|
16
|
+
* @defaultValue none */
|
|
17
|
+
wheelModifier?: CaptureInputModifier;
|
|
18
|
+
/** Dwell delay, movement tolerance, and whether movement resets eligibility.
|
|
19
|
+
* @defaultValue { delay: 150, tolerance: 5, resetOnMove: false } */
|
|
20
|
+
wheelSettle?: CaptureWheelSettle;
|
|
21
|
+
/** Accepted wheel input, with a serialized original event, Capture-relative
|
|
22
|
+
* geometry, focus state, and activation reason. Cancellation is already complete. */
|
|
23
|
+
onWheelInput?: (event: CustomEvent<CaptureWheelInput>, detail: CaptureWheelInput) => void;
|
|
24
|
+
/** Emit raw data for a primary pointer until release or cancellation. An options object
|
|
25
|
+
* filters devices/buttons and configures activation. Nested interactive controls
|
|
26
|
+
* are excluded unless explicitly included. A listener alone enables nothing. */
|
|
27
|
+
pointerCapture?: boolean | CapturePointerCapture;
|
|
28
|
+
/** Start, movement, end, and cancellation of an opted-in pointer session. */
|
|
29
|
+
onPointerInput?: (event: CustomEvent<CapturePointerInput>, detail: CapturePointerInput) => void;
|
|
30
|
+
/** Emit custom pan motion. `true` enables touch panning on both axes without
|
|
31
|
+
* momentum. Options select devices, axes, bounds directions, and optional inertia.
|
|
32
|
+
* Captures the pointer internally; `pointerCapture` is not required.
|
|
33
|
+
* Sets CSS touch-action through attributes before the gesture starts. */
|
|
34
|
+
pan?: boolean | CapturePan;
|
|
35
|
+
/** Custom pan motion and its lifecycle. Inertial samples have no native pointer event. */
|
|
36
|
+
onPanInput?: (event: CustomEvent<CapturePanInput>, detail: CapturePanInput) => void;
|
|
37
|
+
}
|
|
38
|
+
/** A browser-thread input surface. Nothing is captured until a capability is enabled. */
|
|
39
|
+
export declare const Capture: ({ wheelCapture, wheelActivation, wheelModifier, wheelSettle, onWheelInput, pointerCapture, onPointerInput, pan, onPanInput, className, children, ...rest }: CaptureProps) => any;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
|
+
import { customEventHandler } from "../anta_helpers";
|
|
3
|
+
import { directionAttribute, panAttributes, pointerCaptureAttributes, wheelSettleAttributes } from "./capture-props";
|
|
4
|
+
const Capture = ({
|
|
5
|
+
wheelCapture,
|
|
6
|
+
wheelActivation,
|
|
7
|
+
wheelModifier,
|
|
8
|
+
wheelSettle,
|
|
9
|
+
onWheelInput,
|
|
10
|
+
pointerCapture,
|
|
11
|
+
onPointerInput,
|
|
12
|
+
pan,
|
|
13
|
+
onPanInput,
|
|
14
|
+
className,
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
}) => /* @__PURE__ */ jsx(
|
|
18
|
+
"a-capture",
|
|
19
|
+
{
|
|
20
|
+
"wheel-capture": directionAttribute(wheelCapture),
|
|
21
|
+
"wheel-activation": wheelCapture ? wheelActivation : void 0,
|
|
22
|
+
"wheel-modifier": wheelCapture ? wheelModifier : void 0,
|
|
23
|
+
...wheelSettleAttributes(wheelCapture ? wheelSettle : void 0),
|
|
24
|
+
...pointerCaptureAttributes(pointerCapture),
|
|
25
|
+
...panAttributes(pan),
|
|
26
|
+
onwheelinput: customEventHandler(onWheelInput),
|
|
27
|
+
onpointerinput: customEventHandler(onPointerInput),
|
|
28
|
+
onpaninput: customEventHandler(onPanInput),
|
|
29
|
+
class: className,
|
|
30
|
+
...rest,
|
|
31
|
+
children
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
export {
|
|
35
|
+
Capture
|
|
36
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CaptureInputDirections, CapturePan, CapturePointerCapture, CaptureWheelSettle } from '../capture-types';
|
|
2
|
+
/** The empty string enables every direction; `none` keeps an explicit empty set. */
|
|
3
|
+
export declare function directionAttribute(value: CaptureInputDirections | undefined): string | undefined;
|
|
4
|
+
export declare function wheelSettleAttributes(value: CaptureWheelSettle | undefined): {
|
|
5
|
+
'wheel-delay': number | undefined;
|
|
6
|
+
'wheel-tolerance': number | undefined;
|
|
7
|
+
'wheel-reset-on-move': "" | undefined;
|
|
8
|
+
} | undefined;
|
|
9
|
+
export declare function pointerCaptureAttributes(value: boolean | CapturePointerCapture | undefined): {
|
|
10
|
+
'pointer-capture': string;
|
|
11
|
+
'pointer-buttons'?: undefined;
|
|
12
|
+
'pointer-threshold'?: undefined;
|
|
13
|
+
'pointer-modifier'?: undefined;
|
|
14
|
+
'pointer-include-interactive'?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
'pointer-capture': string;
|
|
17
|
+
'pointer-buttons': string | undefined;
|
|
18
|
+
'pointer-threshold': number | undefined;
|
|
19
|
+
'pointer-modifier': import("@antadesign/anta").CaptureInputModifier | undefined;
|
|
20
|
+
'pointer-include-interactive': "" | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
export declare function panAttributes(value: boolean | CapturePan | undefined): {
|
|
23
|
+
pan: "both" | "x" | "y";
|
|
24
|
+
'pan-pointer-types': string | undefined;
|
|
25
|
+
'pan-threshold': number | undefined;
|
|
26
|
+
'pan-directions': string | undefined;
|
|
27
|
+
'pan-inertia': "" | undefined;
|
|
28
|
+
'pan-time-constant': number | undefined;
|
|
29
|
+
'pan-min-velocity': number | undefined;
|
|
30
|
+
} | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function directionAttribute(value) {
|
|
2
|
+
if (value === void 0 || value === false) return void 0;
|
|
3
|
+
if (value === true) return "";
|
|
4
|
+
return ["up", "down", "left", "right"].filter((direction) => value[direction]).join(" ") || "none";
|
|
5
|
+
}
|
|
6
|
+
function wheelSettleAttributes(value) {
|
|
7
|
+
if (!value) return void 0;
|
|
8
|
+
return {
|
|
9
|
+
"wheel-delay": value.delay,
|
|
10
|
+
"wheel-tolerance": value.tolerance,
|
|
11
|
+
"wheel-reset-on-move": value.resetOnMove ? "" : void 0
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function pointerCaptureAttributes(value) {
|
|
15
|
+
if (!value) return void 0;
|
|
16
|
+
if (value === true) return { "pointer-capture": "" };
|
|
17
|
+
return {
|
|
18
|
+
"pointer-capture": value.pointerTypes?.join(" ") || (value.pointerTypes ? "none" : ""),
|
|
19
|
+
"pointer-buttons": value.buttons?.join(" ") || (value.buttons ? "none" : void 0),
|
|
20
|
+
"pointer-threshold": value.threshold,
|
|
21
|
+
"pointer-modifier": value.modifier,
|
|
22
|
+
"pointer-include-interactive": value.includeInteractive ? "" : void 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function panAttributes(value) {
|
|
26
|
+
if (!value) return void 0;
|
|
27
|
+
const options = value === true ? {} : value;
|
|
28
|
+
const inertia = typeof options.inertia === "object" ? options.inertia : void 0;
|
|
29
|
+
return {
|
|
30
|
+
pan: options.axis ?? "both",
|
|
31
|
+
"pan-pointer-types": options.pointerTypes?.join(" ") || (options.pointerTypes ? "none" : void 0),
|
|
32
|
+
"pan-threshold": options.threshold,
|
|
33
|
+
"pan-directions": options.directions === false ? "none" : directionAttribute(options.directions),
|
|
34
|
+
"pan-inertia": options.inertia ? "" : void 0,
|
|
35
|
+
"pan-time-constant": inertia?.timeConstant,
|
|
36
|
+
"pan-min-velocity": inertia?.minVelocity
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
directionAttribute,
|
|
41
|
+
panAttributes,
|
|
42
|
+
pointerCaptureAttributes,
|
|
43
|
+
wheelSettleAttributes
|
|
44
|
+
};
|
|
@@ -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(name: string): 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;
|