@zag-js/slider 0.82.2 → 1.0.1
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/index.d.mts +54 -28
- package/dist/index.d.ts +54 -28
- package/dist/index.js +430 -425
- package/dist/index.mjs +432 -427
- package/package.json +15 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import {
|
|
2
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
3
3
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import { Machine,
|
|
4
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
5
5
|
|
|
6
6
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "range" | "control" | "markerGroup" | "marker" | "draggingIndicator">;
|
|
7
7
|
|
|
@@ -27,9 +27,9 @@ type ElementIds = Partial<{
|
|
|
27
27
|
valueText: string;
|
|
28
28
|
marker(index: number): string;
|
|
29
29
|
}>;
|
|
30
|
-
interface
|
|
30
|
+
interface SliderProps extends DirectionProperty, CommonProperties {
|
|
31
31
|
/**
|
|
32
|
-
* The ids of the elements in the
|
|
32
|
+
* The ids of the elements in the slider. Useful for composition.
|
|
33
33
|
*/
|
|
34
34
|
ids?: ElementIds | undefined;
|
|
35
35
|
/**
|
|
@@ -49,9 +49,14 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
49
49
|
*/
|
|
50
50
|
form?: string | undefined;
|
|
51
51
|
/**
|
|
52
|
-
* The value of the
|
|
52
|
+
* The controlled value of the slider
|
|
53
53
|
*/
|
|
54
|
-
value
|
|
54
|
+
value?: number[] | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The initial value of the slider when rendered.
|
|
57
|
+
* Use when you don't need to control the value of the slider.
|
|
58
|
+
*/
|
|
59
|
+
defaultValue?: number[] | undefined;
|
|
55
60
|
/**
|
|
56
61
|
* Whether the slider is disabled
|
|
57
62
|
*/
|
|
@@ -84,27 +89,27 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
84
89
|
* The minimum value of the slider
|
|
85
90
|
* @default 0
|
|
86
91
|
*/
|
|
87
|
-
min
|
|
92
|
+
min?: number | undefined;
|
|
88
93
|
/**
|
|
89
94
|
* The maximum value of the slider
|
|
90
95
|
* @default 100
|
|
91
96
|
*/
|
|
92
|
-
max
|
|
97
|
+
max?: number | undefined;
|
|
93
98
|
/**
|
|
94
99
|
* The step value of the slider
|
|
95
100
|
* @default 1
|
|
96
101
|
*/
|
|
97
|
-
step
|
|
102
|
+
step?: number | undefined;
|
|
98
103
|
/**
|
|
99
104
|
* The minimum permitted steps between multiple thumbs.
|
|
100
105
|
* @default 0
|
|
101
106
|
*/
|
|
102
|
-
minStepsBetweenThumbs
|
|
107
|
+
minStepsBetweenThumbs?: number | undefined;
|
|
103
108
|
/**
|
|
104
109
|
* The orientation of the slider
|
|
105
110
|
* @default "horizontal"
|
|
106
111
|
*/
|
|
107
|
-
orientation
|
|
112
|
+
orientation?: "vertical" | "horizontal" | undefined;
|
|
108
113
|
/**
|
|
109
114
|
* The origin of the slider range
|
|
110
115
|
* - "start": Useful when the value represents an absolute value
|
|
@@ -124,13 +129,13 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
124
129
|
/**
|
|
125
130
|
* The slider thumbs dimensions
|
|
126
131
|
*/
|
|
127
|
-
thumbSize
|
|
132
|
+
thumbSize?: {
|
|
128
133
|
width: number;
|
|
129
134
|
height: number;
|
|
130
|
-
} |
|
|
135
|
+
} | undefined;
|
|
131
136
|
}
|
|
132
|
-
type
|
|
133
|
-
type
|
|
137
|
+
type PropsWithDefault = "dir" | "min" | "max" | "step" | "orientation" | "defaultValue" | "origin" | "thumbAlignment" | "minStepsBetweenThumbs";
|
|
138
|
+
type Computed = Readonly<{
|
|
134
139
|
/**
|
|
135
140
|
* @computed
|
|
136
141
|
* Whether the slider thumb has been measured
|
|
@@ -167,16 +172,37 @@ type ComputedContext = Readonly<{
|
|
|
167
172
|
*/
|
|
168
173
|
isDisabled: boolean;
|
|
169
174
|
}>;
|
|
170
|
-
interface
|
|
175
|
+
interface Context {
|
|
176
|
+
/**
|
|
177
|
+
* The active index of the range slider. This represents
|
|
178
|
+
* the currently dragged/focused thumb.
|
|
179
|
+
*/
|
|
180
|
+
focusedIndex: number;
|
|
181
|
+
/**
|
|
182
|
+
* The value of the range slider
|
|
183
|
+
*/
|
|
184
|
+
value: number[];
|
|
185
|
+
/**
|
|
186
|
+
* The size of the slider thumbs
|
|
187
|
+
*/
|
|
188
|
+
thumbSize: Size | null;
|
|
171
189
|
}
|
|
172
|
-
interface
|
|
190
|
+
interface SliderSchema {
|
|
191
|
+
state: "idle" | "dragging" | "focus";
|
|
192
|
+
props: RequiredBy<SliderProps, PropsWithDefault>;
|
|
193
|
+
context: Context;
|
|
194
|
+
computed: Computed;
|
|
195
|
+
event: EventObject;
|
|
196
|
+
action: string;
|
|
197
|
+
effect: string;
|
|
198
|
+
guard: string;
|
|
173
199
|
}
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
type SliderService = Service<SliderSchema>;
|
|
201
|
+
type SliderMachine = Machine<SliderSchema>;
|
|
202
|
+
interface Size {
|
|
203
|
+
width: number;
|
|
204
|
+
height: number;
|
|
176
205
|
}
|
|
177
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
178
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
179
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
180
206
|
interface MarkerProps {
|
|
181
207
|
value: number;
|
|
182
208
|
}
|
|
@@ -187,7 +213,7 @@ interface ThumbProps {
|
|
|
187
213
|
interface DraggingIndicatorProps {
|
|
188
214
|
index: number;
|
|
189
215
|
}
|
|
190
|
-
interface
|
|
216
|
+
interface SliderApi<T extends PropTypes = PropTypes> {
|
|
191
217
|
/**
|
|
192
218
|
* The value of the slider.
|
|
193
219
|
*/
|
|
@@ -261,13 +287,13 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
261
287
|
getDraggingIndicatorProps(props: DraggingIndicatorProps): T["element"];
|
|
262
288
|
}
|
|
263
289
|
|
|
264
|
-
declare function connect<T extends PropTypes>(
|
|
290
|
+
declare function connect<T extends PropTypes>(service: SliderService, normalize: NormalizeProps<T>): SliderApi<T>;
|
|
265
291
|
|
|
266
|
-
declare
|
|
292
|
+
declare const machine: _zag_js_core.Machine<SliderSchema>;
|
|
267
293
|
|
|
268
|
-
declare const props: (
|
|
269
|
-
declare const splitProps: <Props extends Partial<
|
|
294
|
+
declare const props: (keyof SliderProps)[];
|
|
295
|
+
declare const splitProps: <Props extends Partial<SliderProps>>(props: Props) => [Partial<SliderProps>, Omit<Props, keyof SliderProps>];
|
|
270
296
|
declare const thumbProps: (keyof ThumbProps)[];
|
|
271
297
|
declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
|
|
272
298
|
|
|
273
|
-
export { type
|
|
299
|
+
export { type SliderApi as Api, type DraggingIndicatorProps, type ElementIds, type FocusChangeDetails, type SliderMachine as Machine, type MarkerProps, type SliderProps as Props, type SliderService as Service, type ThumbProps, type ValueChangeDetails, type ValueTextDetails, anatomy, connect, machine, props, splitProps, splitThumbProps, thumbProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import {
|
|
2
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
3
3
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import { Machine,
|
|
4
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
5
5
|
|
|
6
6
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "range" | "control" | "markerGroup" | "marker" | "draggingIndicator">;
|
|
7
7
|
|
|
@@ -27,9 +27,9 @@ type ElementIds = Partial<{
|
|
|
27
27
|
valueText: string;
|
|
28
28
|
marker(index: number): string;
|
|
29
29
|
}>;
|
|
30
|
-
interface
|
|
30
|
+
interface SliderProps extends DirectionProperty, CommonProperties {
|
|
31
31
|
/**
|
|
32
|
-
* The ids of the elements in the
|
|
32
|
+
* The ids of the elements in the slider. Useful for composition.
|
|
33
33
|
*/
|
|
34
34
|
ids?: ElementIds | undefined;
|
|
35
35
|
/**
|
|
@@ -49,9 +49,14 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
49
49
|
*/
|
|
50
50
|
form?: string | undefined;
|
|
51
51
|
/**
|
|
52
|
-
* The value of the
|
|
52
|
+
* The controlled value of the slider
|
|
53
53
|
*/
|
|
54
|
-
value
|
|
54
|
+
value?: number[] | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* The initial value of the slider when rendered.
|
|
57
|
+
* Use when you don't need to control the value of the slider.
|
|
58
|
+
*/
|
|
59
|
+
defaultValue?: number[] | undefined;
|
|
55
60
|
/**
|
|
56
61
|
* Whether the slider is disabled
|
|
57
62
|
*/
|
|
@@ -84,27 +89,27 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
84
89
|
* The minimum value of the slider
|
|
85
90
|
* @default 0
|
|
86
91
|
*/
|
|
87
|
-
min
|
|
92
|
+
min?: number | undefined;
|
|
88
93
|
/**
|
|
89
94
|
* The maximum value of the slider
|
|
90
95
|
* @default 100
|
|
91
96
|
*/
|
|
92
|
-
max
|
|
97
|
+
max?: number | undefined;
|
|
93
98
|
/**
|
|
94
99
|
* The step value of the slider
|
|
95
100
|
* @default 1
|
|
96
101
|
*/
|
|
97
|
-
step
|
|
102
|
+
step?: number | undefined;
|
|
98
103
|
/**
|
|
99
104
|
* The minimum permitted steps between multiple thumbs.
|
|
100
105
|
* @default 0
|
|
101
106
|
*/
|
|
102
|
-
minStepsBetweenThumbs
|
|
107
|
+
minStepsBetweenThumbs?: number | undefined;
|
|
103
108
|
/**
|
|
104
109
|
* The orientation of the slider
|
|
105
110
|
* @default "horizontal"
|
|
106
111
|
*/
|
|
107
|
-
orientation
|
|
112
|
+
orientation?: "vertical" | "horizontal" | undefined;
|
|
108
113
|
/**
|
|
109
114
|
* The origin of the slider range
|
|
110
115
|
* - "start": Useful when the value represents an absolute value
|
|
@@ -124,13 +129,13 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
124
129
|
/**
|
|
125
130
|
* The slider thumbs dimensions
|
|
126
131
|
*/
|
|
127
|
-
thumbSize
|
|
132
|
+
thumbSize?: {
|
|
128
133
|
width: number;
|
|
129
134
|
height: number;
|
|
130
|
-
} |
|
|
135
|
+
} | undefined;
|
|
131
136
|
}
|
|
132
|
-
type
|
|
133
|
-
type
|
|
137
|
+
type PropsWithDefault = "dir" | "min" | "max" | "step" | "orientation" | "defaultValue" | "origin" | "thumbAlignment" | "minStepsBetweenThumbs";
|
|
138
|
+
type Computed = Readonly<{
|
|
134
139
|
/**
|
|
135
140
|
* @computed
|
|
136
141
|
* Whether the slider thumb has been measured
|
|
@@ -167,16 +172,37 @@ type ComputedContext = Readonly<{
|
|
|
167
172
|
*/
|
|
168
173
|
isDisabled: boolean;
|
|
169
174
|
}>;
|
|
170
|
-
interface
|
|
175
|
+
interface Context {
|
|
176
|
+
/**
|
|
177
|
+
* The active index of the range slider. This represents
|
|
178
|
+
* the currently dragged/focused thumb.
|
|
179
|
+
*/
|
|
180
|
+
focusedIndex: number;
|
|
181
|
+
/**
|
|
182
|
+
* The value of the range slider
|
|
183
|
+
*/
|
|
184
|
+
value: number[];
|
|
185
|
+
/**
|
|
186
|
+
* The size of the slider thumbs
|
|
187
|
+
*/
|
|
188
|
+
thumbSize: Size | null;
|
|
171
189
|
}
|
|
172
|
-
interface
|
|
190
|
+
interface SliderSchema {
|
|
191
|
+
state: "idle" | "dragging" | "focus";
|
|
192
|
+
props: RequiredBy<SliderProps, PropsWithDefault>;
|
|
193
|
+
context: Context;
|
|
194
|
+
computed: Computed;
|
|
195
|
+
event: EventObject;
|
|
196
|
+
action: string;
|
|
197
|
+
effect: string;
|
|
198
|
+
guard: string;
|
|
173
199
|
}
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
type SliderService = Service<SliderSchema>;
|
|
201
|
+
type SliderMachine = Machine<SliderSchema>;
|
|
202
|
+
interface Size {
|
|
203
|
+
width: number;
|
|
204
|
+
height: number;
|
|
176
205
|
}
|
|
177
|
-
type State = StateMachine.State<MachineContext, MachineState>;
|
|
178
|
-
type Send = StateMachine.Send<StateMachine.AnyEventObject>;
|
|
179
|
-
type Service = Machine<MachineContext, MachineState, StateMachine.AnyEventObject>;
|
|
180
206
|
interface MarkerProps {
|
|
181
207
|
value: number;
|
|
182
208
|
}
|
|
@@ -187,7 +213,7 @@ interface ThumbProps {
|
|
|
187
213
|
interface DraggingIndicatorProps {
|
|
188
214
|
index: number;
|
|
189
215
|
}
|
|
190
|
-
interface
|
|
216
|
+
interface SliderApi<T extends PropTypes = PropTypes> {
|
|
191
217
|
/**
|
|
192
218
|
* The value of the slider.
|
|
193
219
|
*/
|
|
@@ -261,13 +287,13 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
261
287
|
getDraggingIndicatorProps(props: DraggingIndicatorProps): T["element"];
|
|
262
288
|
}
|
|
263
289
|
|
|
264
|
-
declare function connect<T extends PropTypes>(
|
|
290
|
+
declare function connect<T extends PropTypes>(service: SliderService, normalize: NormalizeProps<T>): SliderApi<T>;
|
|
265
291
|
|
|
266
|
-
declare
|
|
292
|
+
declare const machine: _zag_js_core.Machine<SliderSchema>;
|
|
267
293
|
|
|
268
|
-
declare const props: (
|
|
269
|
-
declare const splitProps: <Props extends Partial<
|
|
294
|
+
declare const props: (keyof SliderProps)[];
|
|
295
|
+
declare const splitProps: <Props extends Partial<SliderProps>>(props: Props) => [Partial<SliderProps>, Omit<Props, keyof SliderProps>];
|
|
270
296
|
declare const thumbProps: (keyof ThumbProps)[];
|
|
271
297
|
declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
|
|
272
298
|
|
|
273
|
-
export { type
|
|
299
|
+
export { type SliderApi as Api, type DraggingIndicatorProps, type ElementIds, type FocusChangeDetails, type SliderMachine as Machine, type MarkerProps, type SliderProps as Props, type SliderService as Service, type ThumbProps, type ValueChangeDetails, type ValueTextDetails, anatomy, connect, machine, props, splitProps, splitThumbProps, thumbProps };
|