@zag-js/slider 0.1.8 → 0.1.11
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 +21 -0
- package/dist/index.d.ts +228 -4
- package/dist/index.js +239 -245
- package/dist/index.mjs +237 -253
- package/package.json +15 -13
- package/dist/slider.connect.d.ts +0 -25
- package/dist/slider.dom.d.ts +0 -30
- package/dist/slider.machine.d.ts +0 -2
- package/dist/slider.style.d.ts +0 -23
- package/dist/slider.types.d.ts +0 -169
- package/dist/slider.utils.d.ts +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/slider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Core logic for the slider widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,20 +29,22 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/core": "0.1.
|
|
33
|
-
"@zag-js/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"@zag-js/
|
|
37
|
-
"@zag-js/utils": "0.1.
|
|
32
|
+
"@zag-js/core": "0.1.9",
|
|
33
|
+
"@zag-js/types": "0.2.3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@zag-js/dom-utils": "0.1.8",
|
|
37
|
+
"@zag-js/number-utils": "0.1.3",
|
|
38
|
+
"@zag-js/utils": "0.1.3"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
|
-
"build
|
|
41
|
-
"start": "
|
|
42
|
-
"build": "
|
|
41
|
+
"build-fast": "tsup src/index.ts --format=esm,cjs",
|
|
42
|
+
"start": "pnpm build --watch",
|
|
43
|
+
"build": "tsup src/index.ts --format=esm,cjs --dts",
|
|
43
44
|
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
|
|
44
45
|
"lint": "eslint src --ext .ts,.tsx",
|
|
45
|
-
"test
|
|
46
|
-
"test
|
|
46
|
+
"test-ci": "pnpm test --ci --runInBand",
|
|
47
|
+
"test-watch": "pnpm test --watch -u",
|
|
48
|
+
"typecheck": "tsc --noEmit"
|
|
47
49
|
}
|
|
48
|
-
}
|
|
50
|
+
}
|
package/dist/slider.connect.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { PropTypes, ReactPropTypes } from "@zag-js/types";
|
|
2
|
-
import type { Send, State } from "./slider.types";
|
|
3
|
-
export declare function connect<T extends PropTypes = ReactPropTypes>(state: State, send: Send, normalize?: import("@zag-js/types").NormalizeProps): {
|
|
4
|
-
isFocused: boolean;
|
|
5
|
-
isDragging: boolean;
|
|
6
|
-
value: number;
|
|
7
|
-
percent: number;
|
|
8
|
-
setValue(value: number): void;
|
|
9
|
-
getPercentValue(percent: number): number;
|
|
10
|
-
focus(): void;
|
|
11
|
-
increment(): void;
|
|
12
|
-
decrement(): void;
|
|
13
|
-
rootProps: T["element"];
|
|
14
|
-
labelProps: T["label"];
|
|
15
|
-
thumbProps: T["element"];
|
|
16
|
-
inputProps: T["input"];
|
|
17
|
-
outputProps: T["output"];
|
|
18
|
-
trackProps: T["element"];
|
|
19
|
-
rangeProps: T["element"];
|
|
20
|
-
controlProps: T["element"];
|
|
21
|
-
markerGroupProps: T["element"];
|
|
22
|
-
getMarkerProps({ value }: {
|
|
23
|
-
value: number;
|
|
24
|
-
}): T["element"];
|
|
25
|
-
};
|
package/dist/slider.dom.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Point } from "@zag-js/rect-utils";
|
|
2
|
-
import type { MachineContext as Ctx } from "./slider.types";
|
|
3
|
-
export declare const dom: {
|
|
4
|
-
getDoc: (ctx: Ctx) => Document;
|
|
5
|
-
getRootNode: (ctx: Ctx) => Document | ShadowRoot;
|
|
6
|
-
getRootId: (ctx: Ctx) => string;
|
|
7
|
-
getThumbId: (ctx: Ctx) => string;
|
|
8
|
-
getControlId: (ctx: Ctx) => string;
|
|
9
|
-
getInputId: (ctx: Ctx) => string;
|
|
10
|
-
getOutputId: (ctx: Ctx) => string;
|
|
11
|
-
getTrackId: (ctx: Ctx) => string;
|
|
12
|
-
getRangeId: (ctx: Ctx) => string;
|
|
13
|
-
getLabelId: (ctx: Ctx) => string;
|
|
14
|
-
getMarkerId: (ctx: Ctx, value: number) => string;
|
|
15
|
-
getRootEl: (ctx: Ctx) => HTMLElement;
|
|
16
|
-
getThumbEl: (ctx: Ctx) => HTMLElement;
|
|
17
|
-
getControlEl: (ctx: Ctx) => HTMLElement;
|
|
18
|
-
getInputEl: (ctx: Ctx) => HTMLInputElement;
|
|
19
|
-
getValueFromPoint(ctx: Ctx, point: Point): number | undefined;
|
|
20
|
-
dispatchChangeEvent(ctx: Ctx): void;
|
|
21
|
-
getThumbOffset: (ctx: import("./slider.types").SharedContext) => string;
|
|
22
|
-
getControlStyle: () => import("@zag-js/types").Style;
|
|
23
|
-
getThumbStyle: (ctx: import("./slider.types").SharedContext) => import("@zag-js/types").Style;
|
|
24
|
-
getRangeStyle: (ctx: Pick<import("./slider.types").SharedContext, "isVertical" | "isRtl">) => import("@zag-js/types").Style;
|
|
25
|
-
getRootStyle: (ctx: Ctx) => import("@zag-js/types").Style;
|
|
26
|
-
getMarkerStyle: (ctx: Pick<import("./slider.types").SharedContext, "isHorizontal" | "isRtl">, percent: number) => import("@zag-js/types").Style;
|
|
27
|
-
getLabelStyle: () => import("@zag-js/types").Style;
|
|
28
|
-
getTrackStyle: () => import("@zag-js/types").Style;
|
|
29
|
-
getMarkerGroupStyle: () => import("@zag-js/types").Style;
|
|
30
|
-
};
|
package/dist/slider.machine.d.ts
DELETED
package/dist/slider.style.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Style } from "@zag-js/types";
|
|
2
|
-
import type { MachineContext as Ctx, SharedContext } from "./slider.types";
|
|
3
|
-
declare function getThumbOffset(ctx: SharedContext): string;
|
|
4
|
-
declare function getThumbStyle(ctx: SharedContext): Style;
|
|
5
|
-
declare function getRangeStyle(ctx: Pick<SharedContext, "isVertical" | "isRtl">): Style;
|
|
6
|
-
declare function getControlStyle(): Style;
|
|
7
|
-
declare function getRootStyle(ctx: Ctx): Style;
|
|
8
|
-
declare function getMarkerStyle(ctx: Pick<SharedContext, "isHorizontal" | "isRtl">, percent: number): Style;
|
|
9
|
-
declare function getLabelStyle(): Style;
|
|
10
|
-
declare function getTrackStyle(): Style;
|
|
11
|
-
declare function getMarkerGroupStyle(): Style;
|
|
12
|
-
export declare const styles: {
|
|
13
|
-
getThumbOffset: typeof getThumbOffset;
|
|
14
|
-
getControlStyle: typeof getControlStyle;
|
|
15
|
-
getThumbStyle: typeof getThumbStyle;
|
|
16
|
-
getRangeStyle: typeof getRangeStyle;
|
|
17
|
-
getRootStyle: typeof getRootStyle;
|
|
18
|
-
getMarkerStyle: typeof getMarkerStyle;
|
|
19
|
-
getLabelStyle: typeof getLabelStyle;
|
|
20
|
-
getTrackStyle: typeof getTrackStyle;
|
|
21
|
-
getMarkerGroupStyle: typeof getMarkerGroupStyle;
|
|
22
|
-
};
|
|
23
|
-
export {};
|
package/dist/slider.types.d.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import type { StateMachine as S } from "@zag-js/core";
|
|
2
|
-
import type { Context, DirectionProperty } from "@zag-js/types";
|
|
3
|
-
declare type ElementIds = Partial<{
|
|
4
|
-
root: string;
|
|
5
|
-
thumb: string;
|
|
6
|
-
control: string;
|
|
7
|
-
track: string;
|
|
8
|
-
range: string;
|
|
9
|
-
label: string;
|
|
10
|
-
output: string;
|
|
11
|
-
}>;
|
|
12
|
-
declare type PublicContext = DirectionProperty & {
|
|
13
|
-
/**
|
|
14
|
-
* The ids of the elements in the slider. Useful for composition.
|
|
15
|
-
*/
|
|
16
|
-
ids?: ElementIds;
|
|
17
|
-
/**
|
|
18
|
-
* The value of the slider
|
|
19
|
-
*/
|
|
20
|
-
value: number;
|
|
21
|
-
/**
|
|
22
|
-
* The name associated with the slider (when used in a form)
|
|
23
|
-
*/
|
|
24
|
-
name?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Whether the slider is disabled
|
|
27
|
-
*/
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether the slider is read-only
|
|
31
|
-
*/
|
|
32
|
-
readonly?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Whether the slider value is invalid
|
|
35
|
-
*/
|
|
36
|
-
invalid?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* The minimum value of the slider
|
|
39
|
-
*/
|
|
40
|
-
min: number;
|
|
41
|
-
/**
|
|
42
|
-
* The maximum value of the slider
|
|
43
|
-
*/
|
|
44
|
-
max: number;
|
|
45
|
-
/**
|
|
46
|
-
* The step value of the slider
|
|
47
|
-
*/
|
|
48
|
-
step: number;
|
|
49
|
-
/**
|
|
50
|
-
* The orientation of the slider
|
|
51
|
-
*/
|
|
52
|
-
orientation?: "vertical" | "horizontal";
|
|
53
|
-
/**
|
|
54
|
-
* - "start": Useful when the value represents an absolute value
|
|
55
|
-
* - "center": Useful when the value represents an offset (relative)
|
|
56
|
-
*/
|
|
57
|
-
origin?: "start" | "center";
|
|
58
|
-
/**
|
|
59
|
-
* The aria-label of the slider. Useful for providing an accessible name to the slider
|
|
60
|
-
*/
|
|
61
|
-
"aria-label"?: string;
|
|
62
|
-
/**
|
|
63
|
-
* The `id` of the element that labels the slider. Useful for providing an accessible name to the slider
|
|
64
|
-
*/
|
|
65
|
-
"aria-labelledby"?: string;
|
|
66
|
-
/**
|
|
67
|
-
* Whether to focus the slider thumb after interaction (scrub and keyboard)
|
|
68
|
-
*/
|
|
69
|
-
focusThumbOnChange?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Function that returns a human readable value for the slider
|
|
72
|
-
*/
|
|
73
|
-
getAriaValueText?(value: number): string;
|
|
74
|
-
/**
|
|
75
|
-
* Function invoked when the value of the slider changes
|
|
76
|
-
*/
|
|
77
|
-
onChange?(details: {
|
|
78
|
-
value: number;
|
|
79
|
-
}): void;
|
|
80
|
-
/**
|
|
81
|
-
* Function invoked when the slider value change is done
|
|
82
|
-
*/
|
|
83
|
-
onChangeEnd?(details: {
|
|
84
|
-
value: number;
|
|
85
|
-
}): void;
|
|
86
|
-
/**
|
|
87
|
-
* Function invoked when the slider value change is started
|
|
88
|
-
*/
|
|
89
|
-
onChangeStart?(details: {
|
|
90
|
-
value: number;
|
|
91
|
-
}): void;
|
|
92
|
-
/**
|
|
93
|
-
* The alignment of the slider thumb relative to the track
|
|
94
|
-
* - `center`: the thumb will extend beyond the bounds of the slider track.
|
|
95
|
-
* - `contain`: the thumb will be contained within the bounds of the track.
|
|
96
|
-
*/
|
|
97
|
-
thumbAlignment?: "contain" | "center";
|
|
98
|
-
};
|
|
99
|
-
export declare type UserDefinedContext = Partial<PublicContext>;
|
|
100
|
-
declare type ComputedContext = Readonly<{
|
|
101
|
-
/**
|
|
102
|
-
* @computed
|
|
103
|
-
* Whether the slider is interactive
|
|
104
|
-
*/
|
|
105
|
-
readonly isInteractive: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* @computed
|
|
108
|
-
* Whether the thumb size has been measured
|
|
109
|
-
*/
|
|
110
|
-
readonly hasMeasuredThumbSize: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* @computed
|
|
113
|
-
* Whether the slider is horizontal
|
|
114
|
-
*/
|
|
115
|
-
readonly isHorizontal: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* @computed
|
|
118
|
-
* Whether the slider is vertical
|
|
119
|
-
*/
|
|
120
|
-
readonly isVertical: boolean;
|
|
121
|
-
/**
|
|
122
|
-
* @computed
|
|
123
|
-
* Whether the slider is in RTL mode
|
|
124
|
-
*/
|
|
125
|
-
readonly isRtl: boolean;
|
|
126
|
-
}>;
|
|
127
|
-
declare type PrivateContext = Context<{
|
|
128
|
-
/**
|
|
129
|
-
* @internal The move threshold of the slider thumb before it is considered to be moved
|
|
130
|
-
*/
|
|
131
|
-
threshold: number;
|
|
132
|
-
/**
|
|
133
|
-
* @internal The slider thumb dimensions
|
|
134
|
-
*/
|
|
135
|
-
thumbSize: {
|
|
136
|
-
width: number;
|
|
137
|
-
height: number;
|
|
138
|
-
} | null;
|
|
139
|
-
/**
|
|
140
|
-
* @internal
|
|
141
|
-
* The value of the slider when it was initially rendered.
|
|
142
|
-
* Used when the `form.reset(...)` is called.
|
|
143
|
-
*/
|
|
144
|
-
initialValue: number | null;
|
|
145
|
-
}>;
|
|
146
|
-
export declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
147
|
-
export declare type MachineState = {
|
|
148
|
-
value: "unknown" | "idle" | "dragging" | "focus";
|
|
149
|
-
};
|
|
150
|
-
export declare type State = S.State<MachineContext, MachineState>;
|
|
151
|
-
export declare type Send = S.Send<S.AnyEventObject>;
|
|
152
|
-
export declare type SharedContext = {
|
|
153
|
-
min: number;
|
|
154
|
-
max: number;
|
|
155
|
-
step: number;
|
|
156
|
-
dir?: "ltr" | "rtl";
|
|
157
|
-
isRtl: boolean;
|
|
158
|
-
isVertical: boolean;
|
|
159
|
-
isHorizontal: boolean;
|
|
160
|
-
value: number;
|
|
161
|
-
thumbSize: {
|
|
162
|
-
width: number;
|
|
163
|
-
height: number;
|
|
164
|
-
} | null;
|
|
165
|
-
thumbAlignment?: "contain" | "center";
|
|
166
|
-
orientation?: "horizontal" | "vertical";
|
|
167
|
-
readonly hasMeasuredThumbSize: boolean;
|
|
168
|
-
};
|
|
169
|
-
export {};
|
package/dist/slider.utils.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MachineContext as Ctx } from "./slider.types";
|
|
2
|
-
export declare const utils: {
|
|
3
|
-
fromPercent(ctx: Ctx, percent: number): number;
|
|
4
|
-
clamp(ctx: Ctx, value: number): number;
|
|
5
|
-
convert(ctx: Ctx, value: number): number;
|
|
6
|
-
decrement(ctx: Ctx, step?: number): number;
|
|
7
|
-
increment(ctx: Ctx, step?: number): number;
|
|
8
|
-
};
|