@zag-js/slider 0.74.2 → 0.75.0

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 CHANGED
@@ -3,7 +3,7 @@ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizePr
3
3
  import * as _zag_js_core from '@zag-js/core';
4
4
  import { Machine, StateMachine } from '@zag-js/core';
5
5
 
6
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "range" | "control" | "markerGroup" | "marker">;
6
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "range" | "control" | "markerGroup" | "marker" | "draggingIndicator">;
7
7
 
8
8
  interface ValueChangeDetails {
9
9
  value: number[];
@@ -31,23 +31,23 @@ interface PublicContext extends DirectionProperty, CommonProperties {
31
31
  /**
32
32
  * The ids of the elements in the range slider. Useful for composition.
33
33
  */
34
- ids?: ElementIds;
34
+ ids?: ElementIds | undefined;
35
35
  /**
36
36
  * The aria-label of each slider thumb. Useful for providing an accessible name to the slider
37
37
  */
38
- "aria-label"?: string[];
38
+ "aria-label"?: string[] | undefined;
39
39
  /**
40
40
  * The `id` of the elements that labels each slider thumb. Useful for providing an accessible name to the slider
41
41
  */
42
- "aria-labelledby"?: string[];
42
+ "aria-labelledby"?: string[] | undefined;
43
43
  /**
44
44
  * The name associated with each slider thumb (when used in a form)
45
45
  */
46
- name?: string;
46
+ name?: string | undefined;
47
47
  /**
48
48
  * The associate form of the underlying input element.
49
49
  */
50
- form?: string;
50
+ form?: string | undefined;
51
51
  /**
52
52
  * The value of the range slider
53
53
  */
@@ -55,15 +55,15 @@ interface PublicContext extends DirectionProperty, CommonProperties {
55
55
  /**
56
56
  * Whether the slider is disabled
57
57
  */
58
- disabled?: boolean;
58
+ disabled?: boolean | undefined;
59
59
  /**
60
60
  * Whether the slider is read-only
61
61
  */
62
- readOnly?: boolean;
62
+ readOnly?: boolean | undefined;
63
63
  /**
64
64
  * Whether the slider is invalid
65
65
  */
66
- invalid?: boolean;
66
+ invalid?: boolean | undefined;
67
67
  /**
68
68
  * Function invoked when the value of the slider changes
69
69
  */
@@ -112,7 +112,7 @@ interface PublicContext extends DirectionProperty, CommonProperties {
112
112
  *
113
113
  * @default "start"
114
114
  */
115
- origin?: "start" | "center";
115
+ origin?: "start" | "center" | undefined;
116
116
  /**
117
117
  * The alignment of the slider thumb relative to the track
118
118
  * - `center`: the thumb will extend beyond the bounds of the slider track.
@@ -120,7 +120,7 @@ interface PublicContext extends DirectionProperty, CommonProperties {
120
120
  *
121
121
  * @default "contain"
122
122
  */
123
- thumbAlignment?: "contain" | "center";
123
+ thumbAlignment?: "contain" | "center" | undefined;
124
124
  /**
125
125
  * The slider thumbs dimensions
126
126
  */
@@ -182,7 +182,10 @@ interface MarkerProps {
182
182
  }
183
183
  interface ThumbProps {
184
184
  index: number;
185
- name?: string;
185
+ name?: string | undefined;
186
+ }
187
+ interface DraggingIndicatorProps {
188
+ index: number;
186
189
  }
187
190
  interface MachineApi<T extends PropTypes = PropTypes> {
188
191
  /**
@@ -255,6 +258,7 @@ interface MachineApi<T extends PropTypes = PropTypes> {
255
258
  getControlProps(): T["element"];
256
259
  getMarkerGroupProps(): T["element"];
257
260
  getMarkerProps(props: MarkerProps): T["element"];
261
+ getDraggingIndicatorProps(props: DraggingIndicatorProps): T["element"];
258
262
  }
259
263
 
260
264
  declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
@@ -266,4 +270,4 @@ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Pro
266
270
  declare const thumbProps: (keyof ThumbProps)[];
267
271
  declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
268
272
 
269
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type FocusChangeDetails, type MarkerProps, type Service, type ThumbProps, type ValueChangeDetails, type ValueTextDetails, anatomy, connect, machine, props, splitProps, splitThumbProps, thumbProps };
273
+ export { type MachineApi as Api, type UserDefinedContext as Context, type DraggingIndicatorProps, type ElementIds, type FocusChangeDetails, type MarkerProps, type Service, type ThumbProps, type ValueChangeDetails, type ValueTextDetails, anatomy, connect, machine, props, splitProps, splitThumbProps, thumbProps };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizePr
3
3
  import * as _zag_js_core from '@zag-js/core';
4
4
  import { Machine, StateMachine } from '@zag-js/core';
5
5
 
6
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "range" | "control" | "markerGroup" | "marker">;
6
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "label" | "thumb" | "valueText" | "track" | "range" | "control" | "markerGroup" | "marker" | "draggingIndicator">;
7
7
 
8
8
  interface ValueChangeDetails {
9
9
  value: number[];
@@ -31,23 +31,23 @@ interface PublicContext extends DirectionProperty, CommonProperties {
31
31
  /**
32
32
  * The ids of the elements in the range slider. Useful for composition.
33
33
  */
34
- ids?: ElementIds;
34
+ ids?: ElementIds | undefined;
35
35
  /**
36
36
  * The aria-label of each slider thumb. Useful for providing an accessible name to the slider
37
37
  */
38
- "aria-label"?: string[];
38
+ "aria-label"?: string[] | undefined;
39
39
  /**
40
40
  * The `id` of the elements that labels each slider thumb. Useful for providing an accessible name to the slider
41
41
  */
42
- "aria-labelledby"?: string[];
42
+ "aria-labelledby"?: string[] | undefined;
43
43
  /**
44
44
  * The name associated with each slider thumb (when used in a form)
45
45
  */
46
- name?: string;
46
+ name?: string | undefined;
47
47
  /**
48
48
  * The associate form of the underlying input element.
49
49
  */
50
- form?: string;
50
+ form?: string | undefined;
51
51
  /**
52
52
  * The value of the range slider
53
53
  */
@@ -55,15 +55,15 @@ interface PublicContext extends DirectionProperty, CommonProperties {
55
55
  /**
56
56
  * Whether the slider is disabled
57
57
  */
58
- disabled?: boolean;
58
+ disabled?: boolean | undefined;
59
59
  /**
60
60
  * Whether the slider is read-only
61
61
  */
62
- readOnly?: boolean;
62
+ readOnly?: boolean | undefined;
63
63
  /**
64
64
  * Whether the slider is invalid
65
65
  */
66
- invalid?: boolean;
66
+ invalid?: boolean | undefined;
67
67
  /**
68
68
  * Function invoked when the value of the slider changes
69
69
  */
@@ -112,7 +112,7 @@ interface PublicContext extends DirectionProperty, CommonProperties {
112
112
  *
113
113
  * @default "start"
114
114
  */
115
- origin?: "start" | "center";
115
+ origin?: "start" | "center" | undefined;
116
116
  /**
117
117
  * The alignment of the slider thumb relative to the track
118
118
  * - `center`: the thumb will extend beyond the bounds of the slider track.
@@ -120,7 +120,7 @@ interface PublicContext extends DirectionProperty, CommonProperties {
120
120
  *
121
121
  * @default "contain"
122
122
  */
123
- thumbAlignment?: "contain" | "center";
123
+ thumbAlignment?: "contain" | "center" | undefined;
124
124
  /**
125
125
  * The slider thumbs dimensions
126
126
  */
@@ -182,7 +182,10 @@ interface MarkerProps {
182
182
  }
183
183
  interface ThumbProps {
184
184
  index: number;
185
- name?: string;
185
+ name?: string | undefined;
186
+ }
187
+ interface DraggingIndicatorProps {
188
+ index: number;
186
189
  }
187
190
  interface MachineApi<T extends PropTypes = PropTypes> {
188
191
  /**
@@ -255,6 +258,7 @@ interface MachineApi<T extends PropTypes = PropTypes> {
255
258
  getControlProps(): T["element"];
256
259
  getMarkerGroupProps(): T["element"];
257
260
  getMarkerProps(props: MarkerProps): T["element"];
261
+ getDraggingIndicatorProps(props: DraggingIndicatorProps): T["element"];
258
262
  }
259
263
 
260
264
  declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T>;
@@ -266,4 +270,4 @@ declare const splitProps: <Props extends Partial<UserDefinedContext>>(props: Pro
266
270
  declare const thumbProps: (keyof ThumbProps)[];
267
271
  declare const splitThumbProps: <Props extends ThumbProps>(props: Props) => [ThumbProps, Omit<Props, keyof ThumbProps>];
268
272
 
269
- export { type MachineApi as Api, type UserDefinedContext as Context, type ElementIds, type FocusChangeDetails, type MarkerProps, type Service, type ThumbProps, type ValueChangeDetails, type ValueTextDetails, anatomy, connect, machine, props, splitProps, splitThumbProps, thumbProps };
273
+ export { type MachineApi as Api, type UserDefinedContext as Context, type DraggingIndicatorProps, type ElementIds, type FocusChangeDetails, type MarkerProps, type Service, type ThumbProps, type ValueChangeDetails, type ValueTextDetails, anatomy, connect, machine, props, splitProps, splitThumbProps, thumbProps };
package/dist/index.js CHANGED
@@ -20,7 +20,8 @@ var anatomy = anatomy$1.createAnatomy("slider").parts(
20
20
  "range",
21
21
  "control",
22
22
  "markerGroup",
23
- "marker"
23
+ "marker",
24
+ "draggingIndicator"
24
25
  );
25
26
  var parts = anatomy.build();
26
27
  function getBounds(value) {
@@ -509,6 +510,19 @@ function connect(state, send, normalize) {
509
510
  "data-state": markerState,
510
511
  style
511
512
  });
513
+ },
514
+ getDraggingIndicatorProps(props2) {
515
+ const { index = 0 } = props2;
516
+ const isDragging = index === state.context.focusedIndex && dragging;
517
+ return normalize.element({
518
+ ...parts.draggingIndicator.attrs,
519
+ role: "presentation",
520
+ dir: state.context.dir,
521
+ hidden: !isDragging,
522
+ "data-orientation": state.context.orientation,
523
+ "data-state": isDragging ? "open" : "closed",
524
+ style: dom.getThumbStyle(state.context, index)
525
+ });
512
526
  }
513
527
  };
514
528
  }
package/dist/index.mjs CHANGED
@@ -18,7 +18,8 @@ var anatomy = createAnatomy("slider").parts(
18
18
  "range",
19
19
  "control",
20
20
  "markerGroup",
21
- "marker"
21
+ "marker",
22
+ "draggingIndicator"
22
23
  );
23
24
  var parts = anatomy.build();
24
25
  function getBounds(value) {
@@ -507,6 +508,19 @@ function connect(state, send, normalize) {
507
508
  "data-state": markerState,
508
509
  style
509
510
  });
511
+ },
512
+ getDraggingIndicatorProps(props2) {
513
+ const { index = 0 } = props2;
514
+ const isDragging = index === state.context.focusedIndex && dragging;
515
+ return normalize.element({
516
+ ...parts.draggingIndicator.attrs,
517
+ role: "presentation",
518
+ dir: state.context.dir,
519
+ hidden: !isDragging,
520
+ "data-orientation": state.context.orientation,
521
+ "data-state": isDragging ? "open" : "closed",
522
+ style: dom.getThumbStyle(state.context, index)
523
+ });
510
524
  }
511
525
  };
512
526
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/slider",
3
- "version": "0.74.2",
3
+ "version": "0.75.0",
4
4
  "description": "Core logic for the slider widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -27,15 +27,15 @@
27
27
  "url": "https://github.com/chakra-ui/zag/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@zag-js/anatomy": "0.74.2",
31
- "@zag-js/core": "0.74.2",
32
- "@zag-js/form-utils": "0.74.2",
33
- "@zag-js/dom-query": "0.74.2",
34
- "@zag-js/dom-event": "0.74.2",
35
- "@zag-js/utils": "0.74.2",
36
- "@zag-js/numeric-range": "0.74.2",
37
- "@zag-js/element-size": "0.74.2",
38
- "@zag-js/types": "0.74.2"
30
+ "@zag-js/anatomy": "0.75.0",
31
+ "@zag-js/core": "0.75.0",
32
+ "@zag-js/form-utils": "0.75.0",
33
+ "@zag-js/dom-query": "0.75.0",
34
+ "@zag-js/dom-event": "0.75.0",
35
+ "@zag-js/utils": "0.75.0",
36
+ "@zag-js/numeric-range": "0.75.0",
37
+ "@zag-js/element-size": "0.75.0",
38
+ "@zag-js/types": "0.75.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "clean-package": "2.2.0"