@antadesign/anta 0.3.26 → 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 +14 -0
- package/dist/box-types.d.ts +1 -1
- 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 +15 -0
- package/dist/components/Box.js +3 -11
- 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-box.d.ts +1 -1
- package/dist/elements/a-box.js +11 -3
- 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-checkbox.js +4 -4
- package/dist/elements/a-slider.js +6 -6
- package/dist/elements/capture-input.d.ts +5 -0
- package/dist/elements/capture-input.js +609 -0
- package/dist/elements/index.d.ts +1 -0
- package/dist/elements/index.js +3 -0
- package/dist/general_types.d.ts +34 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/jsx-runtime.d.ts +2 -1
- package/docs/accessibility.md +24 -0
- package/docs/changelog.md +22 -0
- package/docs/colors.md +141 -0
- package/docs/comparison.md +463 -28
- package/docs/components/avatar.md +13 -17
- package/docs/components/banner.md +13 -27
- package/docs/components/box.md +226 -154
- 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 +3 -1
- 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
|
package/dist/components/Box.d.ts
CHANGED
|
@@ -34,4 +34,19 @@ export interface BoxProps extends BaseProps {
|
|
|
34
34
|
* contains the changed fields and a full current snapshot. */
|
|
35
35
|
onContextChange?: (event: CustomEvent<BoxContextChange>, detail: BoxContextChange) => void;
|
|
36
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
|
+
*/
|
|
37
52
|
export declare const Box: ({ display, round, gap, observe, fade, fadeSize, onMeasureChange, onContextChange, className, style, children, ...rest }: BoxProps) => any;
|
package/dist/components/Box.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from "@antadesign/anta/jsx-runtime";
|
|
2
2
|
import {
|
|
3
3
|
cssLength,
|
|
4
|
+
customEventHandler,
|
|
4
5
|
lengthStyle,
|
|
5
|
-
nativeStateChange,
|
|
6
6
|
roundAttr,
|
|
7
7
|
roundStyle
|
|
8
8
|
} from "../anta_helpers";
|
|
@@ -28,14 +28,6 @@ const Box = ({
|
|
|
28
28
|
children,
|
|
29
29
|
...rest
|
|
30
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
31
|
return /* @__PURE__ */ jsx(
|
|
40
32
|
"a-box",
|
|
41
33
|
{
|
|
@@ -45,8 +37,8 @@ const Box = ({
|
|
|
45
37
|
observe: observeAttr(observe, onMeasureChange, onContextChange),
|
|
46
38
|
fade: fade ? "" : void 0,
|
|
47
39
|
"fade-size": fade && fadeSize != null ? cssLength(fadeSize) : void 0,
|
|
48
|
-
onmeasurechange:
|
|
49
|
-
oncontextchange:
|
|
40
|
+
onmeasurechange: customEventHandler(onMeasureChange),
|
|
41
|
+
oncontextchange: customEventHandler(onContextChange),
|
|
50
42
|
class: className,
|
|
51
43
|
style: lengthStyle(
|
|
52
44
|
fade ? fadeSize : void 0,
|
|
@@ -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
|
+
};
|
package/dist/elements/a-box.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare class ABoxElement extends HTMLElementBase {
|
|
|
25
25
|
static observedAttributes: string[];
|
|
26
26
|
connectedCallback(): void;
|
|
27
27
|
disconnectedCallback(): void;
|
|
28
|
-
attributeChangedCallback(): void;
|
|
28
|
+
attributeChangedCallback(name: string): void;
|
|
29
29
|
/** A fresh measurement snapshot. For notifications, prefer `measurechange`:
|
|
30
30
|
* it batches browser observers and includes the field-level delta. */
|
|
31
31
|
get measurement(): BoxMeasurement;
|
package/dist/elements/a-box.js
CHANGED
|
@@ -119,8 +119,15 @@ class BoxWindowStore {
|
|
|
119
119
|
this.#classObserver?.disconnect();
|
|
120
120
|
this.#classObserver = void 0;
|
|
121
121
|
}
|
|
122
|
+
/* Only the store the map currently points at may remove that entry. A box
|
|
123
|
+
that was connected while its store went empty keeps a direct reference to
|
|
124
|
+
it, so an evicted store can be re-subscribed and later empty again — by
|
|
125
|
+
which time the map holds a live store with its own document observer.
|
|
126
|
+
Deleting blind would drop that live store and leave its observer running
|
|
127
|
+
while the next connect built a second one. */
|
|
122
128
|
#collect() {
|
|
123
|
-
if (this.#contextBoxes.size
|
|
129
|
+
if (this.#contextBoxes.size > 0 || this.#observedBoxes.size > 0) return;
|
|
130
|
+
if (stores.get(this.view) === this) stores.delete(this.view);
|
|
124
131
|
}
|
|
125
132
|
/* Only `dark` and `light` change what a box reports. Every other class toggle
|
|
126
133
|
on the page — a route class, a scroll lock, a theme-unrelated modifier —
|
|
@@ -292,8 +299,9 @@ class ABoxElement extends HTMLElementBase {
|
|
|
292
299
|
connectedCallback, when there is no store yet. Syncing then would flip the
|
|
293
300
|
started flags while `this.#store?.subscribeContext` silently did nothing,
|
|
294
301
|
and the later connect would see the flags already set and skip it. */
|
|
295
|
-
attributeChangedCallback() {
|
|
296
|
-
if (this.#store)
|
|
302
|
+
attributeChangedCallback(name) {
|
|
303
|
+
if (!this.#store) return;
|
|
304
|
+
if (name === "fade" || name === "observe") this.#sync();
|
|
297
305
|
}
|
|
298
306
|
/** A fresh measurement snapshot. For notifications, prefer `measurechange`:
|
|
299
307
|
* it batches browser observers and includes the field-level delta. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer anta.components{a-capture{display:block;min-width:0}a-capture[pointer-capture]:not([pointer-capture=none],[pointer-buttons=none]),a-capture[pan]:is([pan=""],[pan=both],[pan=x],[pan=y]):not([pan-pointer-types=none]){user-select:none}a-capture:where(:not([pan-pointer-types]),[pan-pointer-types=""],[pan-pointer-types=all],[pan-pointer-types~=touch]){&[pan=x]{touch-action:pan-y pinch-zoom}&[pan=y]{touch-action:pan-x pinch-zoom}&[pan=""],&[pan=both]{touch-action:none}}a-capture:is([pointer-capture=""],[pointer-capture=all],[pointer-capture~=touch]):not(:where([pointer-buttons=none])){touch-action:none}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './a-capture.css';
|
|
2
|
+
import { HTMLElementBase } from '../anta_helpers';
|
|
3
|
+
/** A light-DOM input surface with no enabled capabilities by default. */
|
|
4
|
+
export declare class ACaptureElement extends HTMLElementBase {
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(name: string): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function register_a_capture(): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./a-capture.css";
|
|
2
|
+
import { HTMLElementBase } from "../anta_helpers";
|
|
3
|
+
import { CAPTURE_INPUT_ATTRIBUTES, disconnectCaptureInput, syncCaptureInput } from "./capture-input";
|
|
4
|
+
class ACaptureElement extends HTMLElementBase {
|
|
5
|
+
static observedAttributes = CAPTURE_INPUT_ATTRIBUTES;
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
syncCaptureInput(this);
|
|
8
|
+
}
|
|
9
|
+
disconnectedCallback() {
|
|
10
|
+
disconnectCaptureInput(this);
|
|
11
|
+
}
|
|
12
|
+
attributeChangedCallback(name) {
|
|
13
|
+
syncCaptureInput(this, name);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function register_a_capture() {
|
|
17
|
+
if (typeof customElements === "undefined") return;
|
|
18
|
+
if (!customElements.get("a-capture")) customElements.define("a-capture", ACaptureElement);
|
|
19
|
+
}
|
|
20
|
+
register_a_capture();
|
|
21
|
+
export {
|
|
22
|
+
ACaptureElement,
|
|
23
|
+
register_a_capture
|
|
24
|
+
};
|
|
@@ -94,10 +94,10 @@ class ACheckboxElement extends HTMLElementBase {
|
|
|
94
94
|
paint() {
|
|
95
95
|
const i = this.internals;
|
|
96
96
|
if (!i) return;
|
|
97
|
-
i.states
|
|
98
|
-
i.states
|
|
99
|
-
if (this.currentState === "indeterminate") i.states
|
|
100
|
-
else if (this.currentState === "checked") i.states
|
|
97
|
+
i.states?.delete("checked");
|
|
98
|
+
i.states?.delete("indeterminate");
|
|
99
|
+
if (this.currentState === "indeterminate") i.states?.add("indeterminate");
|
|
100
|
+
else if (this.currentState === "checked") i.states?.add("checked");
|
|
101
101
|
i.ariaChecked = this.currentState === "indeterminate" ? "mixed" : this.currentState === "checked" ? "true" : "false";
|
|
102
102
|
i.setFormValue?.(
|
|
103
103
|
this.currentState === "checked" ? this.getAttribute("value") ?? "on" : null,
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { HTMLElementBase } from "../anta_helpers";
|
|
1
|
+
import { finiteNumber, HTMLElementBase } from "../anta_helpers";
|
|
2
2
|
import "./a-slider.css";
|
|
3
|
-
const finiteNumber = (value, fallback) => {
|
|
4
|
-
if (value == null || value === "") return fallback;
|
|
5
|
-
const number = Number(value);
|
|
6
|
-
return Number.isFinite(number) ? number : fallback;
|
|
7
|
-
};
|
|
8
3
|
const precisionOf = (value) => {
|
|
9
4
|
const exponent = value.toString().match(/(?:\.(\d+))?(?:e([+-]?\d+))?$/i);
|
|
10
5
|
return Math.max(0, (exponent?.[1]?.length ?? 0) - Number(exponent?.[2] ?? 0));
|
|
@@ -281,6 +276,7 @@ class ASliderElement extends HTMLElementBase {
|
|
|
281
276
|
this.#control.addEventListener("pointermove", (event) => this.#moveDrag(event));
|
|
282
277
|
this.#control.addEventListener("pointerup", (event) => this.#finishDrag(event));
|
|
283
278
|
this.#control.addEventListener("pointercancel", (event) => this.#finishDrag(event));
|
|
279
|
+
this.#control.addEventListener("lostpointercapture", (event) => this.#finishDrag(event));
|
|
284
280
|
this.addEventListener("keydown", (event) => this.#handleKeydown(event));
|
|
285
281
|
this.addEventListener("blur", () => delete this.#control.dataset.pointerFocus);
|
|
286
282
|
shadow.append(style, this.#header, this.#control, this.#markers, this.#extras);
|
|
@@ -423,6 +419,10 @@ class ASliderElement extends HTMLElementBase {
|
|
|
423
419
|
#moveDrag(event) {
|
|
424
420
|
const drag = this.#drag;
|
|
425
421
|
if (!drag || drag.pointerId !== event.pointerId) return;
|
|
422
|
+
if (!(event.buttons & 1)) {
|
|
423
|
+
this.#finishDrag(event);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
426
|
const next = this.getAttribute("track-click") === "jump" ? this.#valueAt(event.clientX) : drag.startValue + (event.clientX - drag.startX) / this.#railArea.getBoundingClientRect().width * (this.#max - this.#min);
|
|
427
427
|
this.#setValue(next);
|
|
428
428
|
event.preventDefault();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CaptureInputCancelReason } from '../capture-types';
|
|
2
|
+
export declare const CAPTURE_INPUT_ATTRIBUTES: string[];
|
|
3
|
+
/** Read declarative attributes, allocating input resources only for enabled capabilities. */
|
|
4
|
+
export declare function syncCaptureInput(surface: HTMLElement, attribute?: string): void;
|
|
5
|
+
export declare function disconnectCaptureInput(surface: HTMLElement, reason?: CaptureInputCancelReason): void;
|