@zag-js/slider 0.1.10 → 0.1.13
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 +308 -336
- package/dist/index.mjs +302 -339
- package/package.json +14 -12
- package/dist/slider.connect.d.ts +0 -25
- package/dist/slider.dom.d.ts +0 -43
- package/dist/slider.machine.d.ts +0 -2
- package/dist/slider.style.d.ts +0 -23
- package/dist/slider.types.d.ts +0 -173
- package/dist/slider.utils.d.ts +0 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Chakra UI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,228 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as _zag_js_types from '@zag-js/types';
|
|
2
|
+
import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
|
|
3
|
+
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
+
import { StateMachine } from '@zag-js/core';
|
|
5
|
+
|
|
6
|
+
declare type ElementIds = Partial<{
|
|
7
|
+
root: string;
|
|
8
|
+
thumb: string;
|
|
9
|
+
control: string;
|
|
10
|
+
track: string;
|
|
11
|
+
range: string;
|
|
12
|
+
label: string;
|
|
13
|
+
output: string;
|
|
14
|
+
}>;
|
|
15
|
+
declare type PublicContext = DirectionProperty & CommonProperties & {
|
|
16
|
+
/**
|
|
17
|
+
* The ids of the elements in the slider. Useful for composition.
|
|
18
|
+
*/
|
|
19
|
+
ids?: ElementIds;
|
|
20
|
+
/**
|
|
21
|
+
* The value of the slider
|
|
22
|
+
*/
|
|
23
|
+
value: number;
|
|
24
|
+
/**
|
|
25
|
+
* The name associated with the slider (when used in a form)
|
|
26
|
+
*/
|
|
27
|
+
name?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the slider is disabled
|
|
30
|
+
*/
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the slider is read-only
|
|
34
|
+
*/
|
|
35
|
+
readonly?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the slider value is invalid
|
|
38
|
+
*/
|
|
39
|
+
invalid?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The minimum value of the slider
|
|
42
|
+
*/
|
|
43
|
+
min: number;
|
|
44
|
+
/**
|
|
45
|
+
* The maximum value of the slider
|
|
46
|
+
*/
|
|
47
|
+
max: number;
|
|
48
|
+
/**
|
|
49
|
+
* The step value of the slider
|
|
50
|
+
*/
|
|
51
|
+
step: number;
|
|
52
|
+
/**
|
|
53
|
+
* The orientation of the slider
|
|
54
|
+
*/
|
|
55
|
+
orientation?: "vertical" | "horizontal";
|
|
56
|
+
/**
|
|
57
|
+
* - "start": Useful when the value represents an absolute value
|
|
58
|
+
* - "center": Useful when the value represents an offset (relative)
|
|
59
|
+
*/
|
|
60
|
+
origin?: "start" | "center";
|
|
61
|
+
/**
|
|
62
|
+
* The aria-label of the slider. Useful for providing an accessible name to the slider
|
|
63
|
+
*/
|
|
64
|
+
"aria-label"?: string;
|
|
65
|
+
/**
|
|
66
|
+
* The `id` of the element that labels the slider. Useful for providing an accessible name to the slider
|
|
67
|
+
*/
|
|
68
|
+
"aria-labelledby"?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to focus the slider thumb after interaction (scrub and keyboard)
|
|
71
|
+
*/
|
|
72
|
+
focusThumbOnChange?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Function that returns a human readable value for the slider
|
|
75
|
+
*/
|
|
76
|
+
getAriaValueText?(value: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* Function invoked when the value of the slider changes
|
|
79
|
+
*/
|
|
80
|
+
onChange?(details: {
|
|
81
|
+
value: number;
|
|
82
|
+
}): void;
|
|
83
|
+
/**
|
|
84
|
+
* Function invoked when the slider value change is done
|
|
85
|
+
*/
|
|
86
|
+
onChangeEnd?(details: {
|
|
87
|
+
value: number;
|
|
88
|
+
}): void;
|
|
89
|
+
/**
|
|
90
|
+
* Function invoked when the slider value change is started
|
|
91
|
+
*/
|
|
92
|
+
onChangeStart?(details: {
|
|
93
|
+
value: number;
|
|
94
|
+
}): void;
|
|
95
|
+
/**
|
|
96
|
+
* The alignment of the slider thumb relative to the track
|
|
97
|
+
* - `center`: the thumb will extend beyond the bounds of the slider track.
|
|
98
|
+
* - `contain`: the thumb will be contained within the bounds of the track.
|
|
99
|
+
*/
|
|
100
|
+
thumbAlignment?: "contain" | "center";
|
|
101
|
+
};
|
|
102
|
+
declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
103
|
+
declare type ComputedContext = Readonly<{
|
|
104
|
+
/**
|
|
105
|
+
* @computed
|
|
106
|
+
* Whether the slider is interactive
|
|
107
|
+
*/
|
|
108
|
+
readonly isInteractive: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* @computed
|
|
111
|
+
* Whether the thumb size has been measured
|
|
112
|
+
*/
|
|
113
|
+
readonly hasMeasuredThumbSize: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* @computed
|
|
116
|
+
* Whether the slider is horizontal
|
|
117
|
+
*/
|
|
118
|
+
readonly isHorizontal: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* @computed
|
|
121
|
+
* Whether the slider is vertical
|
|
122
|
+
*/
|
|
123
|
+
readonly isVertical: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* @computed
|
|
126
|
+
* Whether the slider is in RTL mode
|
|
127
|
+
*/
|
|
128
|
+
readonly isRtl: boolean;
|
|
129
|
+
}>;
|
|
130
|
+
declare type PrivateContext = Context<{}>;
|
|
131
|
+
declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
|
|
132
|
+
declare type MachineState = {
|
|
133
|
+
value: "unknown" | "idle" | "dragging" | "focus";
|
|
134
|
+
};
|
|
135
|
+
declare type State = StateMachine.State<MachineContext, MachineState>;
|
|
136
|
+
declare type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
137
|
+
declare type SharedContext = {
|
|
138
|
+
min: number;
|
|
139
|
+
max: number;
|
|
140
|
+
step: number;
|
|
141
|
+
dir?: "ltr" | "rtl";
|
|
142
|
+
isRtl: boolean;
|
|
143
|
+
isVertical: boolean;
|
|
144
|
+
isHorizontal: boolean;
|
|
145
|
+
value: number;
|
|
146
|
+
thumbSize: {
|
|
147
|
+
width: number;
|
|
148
|
+
height: number;
|
|
149
|
+
} | null;
|
|
150
|
+
thumbAlignment?: "contain" | "center";
|
|
151
|
+
orientation?: "horizontal" | "vertical";
|
|
152
|
+
readonly hasMeasuredThumbSize: boolean;
|
|
153
|
+
};
|
|
154
|
+
declare type Point = {
|
|
155
|
+
x: number;
|
|
156
|
+
y: number;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
declare const dom: {
|
|
160
|
+
getRootNode: (ctx: {
|
|
161
|
+
getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
|
|
162
|
+
}) => Document | ShadowRoot;
|
|
163
|
+
getDoc: (ctx: {
|
|
164
|
+
getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
|
|
165
|
+
}) => Document;
|
|
166
|
+
getWin: (ctx: {
|
|
167
|
+
getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
|
|
168
|
+
}) => Window & typeof globalThis;
|
|
169
|
+
getActiveElement: (ctx: {
|
|
170
|
+
getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
|
|
171
|
+
}) => HTMLElement | null;
|
|
172
|
+
getById: <T_1 = HTMLElement>(ctx: {
|
|
173
|
+
getRootNode?: (() => Document | Node | ShadowRoot) | undefined;
|
|
174
|
+
}, id: string) => T_1 | null;
|
|
175
|
+
} & {
|
|
176
|
+
getRootId: (ctx: MachineContext) => string;
|
|
177
|
+
getThumbId: (ctx: MachineContext) => string;
|
|
178
|
+
getControlId: (ctx: MachineContext) => string;
|
|
179
|
+
getInputId: (ctx: MachineContext) => string;
|
|
180
|
+
getOutputId: (ctx: MachineContext) => string;
|
|
181
|
+
getTrackId: (ctx: MachineContext) => string;
|
|
182
|
+
getRangeId: (ctx: MachineContext) => string;
|
|
183
|
+
getLabelId: (ctx: MachineContext) => string;
|
|
184
|
+
getMarkerId: (ctx: MachineContext, value: number) => string;
|
|
185
|
+
getRootEl: (ctx: MachineContext) => HTMLElement | null;
|
|
186
|
+
getThumbEl: (ctx: MachineContext) => HTMLElement | null;
|
|
187
|
+
getControlEl: (ctx: MachineContext) => HTMLElement | null;
|
|
188
|
+
getInputEl: (ctx: MachineContext) => HTMLInputElement | null;
|
|
189
|
+
getValueFromPoint(ctx: MachineContext, point: Point): number | undefined;
|
|
190
|
+
dispatchChangeEvent(ctx: MachineContext): void;
|
|
191
|
+
getThumbOffset: (ctx: SharedContext) => string;
|
|
192
|
+
getControlStyle: () => _zag_js_types.JSX.CSSProperties;
|
|
193
|
+
getThumbStyle: (ctx: SharedContext) => _zag_js_types.JSX.CSSProperties;
|
|
194
|
+
getRangeStyle: (ctx: Pick<SharedContext, "isVertical" | "isRtl">) => _zag_js_types.JSX.CSSProperties;
|
|
195
|
+
getRootStyle: (ctx: MachineContext) => _zag_js_types.JSX.CSSProperties;
|
|
196
|
+
getMarkerStyle: (ctx: Pick<SharedContext, "isHorizontal" | "isRtl">, percent: number) => _zag_js_types.JSX.CSSProperties;
|
|
197
|
+
getLabelStyle: () => _zag_js_types.JSX.CSSProperties;
|
|
198
|
+
getTrackStyle: () => _zag_js_types.JSX.CSSProperties;
|
|
199
|
+
getMarkerGroupStyle: () => _zag_js_types.JSX.CSSProperties;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
|
|
203
|
+
isFocused: boolean;
|
|
204
|
+
isDragging: boolean;
|
|
205
|
+
value: number;
|
|
206
|
+
percent: number;
|
|
207
|
+
setValue(value: number): void;
|
|
208
|
+
getPercentValue(percent: number): number;
|
|
209
|
+
focus(): void;
|
|
210
|
+
increment(): void;
|
|
211
|
+
decrement(): void;
|
|
212
|
+
rootProps: T["element"];
|
|
213
|
+
labelProps: T["label"];
|
|
214
|
+
thumbProps: T["element"];
|
|
215
|
+
inputProps: T["input"];
|
|
216
|
+
outputProps: T["output"];
|
|
217
|
+
trackProps: T["element"];
|
|
218
|
+
rangeProps: T["element"];
|
|
219
|
+
controlProps: T["element"];
|
|
220
|
+
markerGroupProps: T["element"];
|
|
221
|
+
getMarkerProps({ value }: {
|
|
222
|
+
value: number;
|
|
223
|
+
}): T["element"];
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
|
|
227
|
+
|
|
228
|
+
export { UserDefinedContext as Context, connect, machine, dom as unstable__dom };
|