@zag-js/slider 0.1.9 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/slider",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "Core logic for the slider widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,19 +29,23 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "0.1.7",
33
- "@zag-js/dom-utils": "0.1.6",
34
- "@zag-js/number-utils": "0.1.2",
35
- "@zag-js/types": "0.2.1",
36
- "@zag-js/utils": "0.1.2"
32
+ "@zag-js/core": "0.1.9",
33
+ "@zag-js/types": "0.2.3"
34
+ },
35
+ "devDependencies": {
36
+ "@zag-js/dom-utils": "0.1.9",
37
+ "@zag-js/form-utils": "0.1.0",
38
+ "@zag-js/number-utils": "0.1.3",
39
+ "@zag-js/utils": "0.1.3"
37
40
  },
38
41
  "scripts": {
39
- "build:fast": "zag build",
40
- "start": "zag build --watch",
41
- "build": "zag build --prod",
42
+ "build-fast": "tsup src/index.ts --format=esm,cjs",
43
+ "start": "pnpm build --watch",
44
+ "build": "tsup src/index.ts --format=esm,cjs --dts",
42
45
  "test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
43
46
  "lint": "eslint src --ext .ts,.tsx",
44
- "test:ci": "yarn test --ci --runInBand",
45
- "test:watch": "yarn test --watch --updateSnapshot"
47
+ "test-ci": "pnpm test --ci --runInBand",
48
+ "test-watch": "pnpm test --watch -u",
49
+ "typecheck": "tsc --noEmit"
46
50
  }
47
- }
51
+ }
@@ -1,25 +0,0 @@
1
- import type { NormalizeProps, PropTypes } from "@zag-js/types";
2
- import type { Send, State } from "./slider.types";
3
- export declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
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
- };
@@ -1,29 +0,0 @@
1
- import type { MachineContext as Ctx, Point } from "./slider.types";
2
- export declare const dom: {
3
- getDoc: (ctx: Ctx) => Document;
4
- getRootNode: (ctx: Ctx) => Document | ShadowRoot;
5
- getRootId: (ctx: Ctx) => string;
6
- getThumbId: (ctx: Ctx) => string;
7
- getControlId: (ctx: Ctx) => string;
8
- getInputId: (ctx: Ctx) => string;
9
- getOutputId: (ctx: Ctx) => string;
10
- getTrackId: (ctx: Ctx) => string;
11
- getRangeId: (ctx: Ctx) => string;
12
- getLabelId: (ctx: Ctx) => string;
13
- getMarkerId: (ctx: Ctx, value: number) => string;
14
- getRootEl: (ctx: Ctx) => HTMLElement;
15
- getThumbEl: (ctx: Ctx) => HTMLElement;
16
- getControlEl: (ctx: Ctx) => HTMLElement;
17
- getInputEl: (ctx: Ctx) => HTMLInputElement;
18
- getValueFromPoint(ctx: Ctx, point: Point): number | undefined;
19
- dispatchChangeEvent(ctx: Ctx): void;
20
- getThumbOffset: (ctx: import("./slider.types").SharedContext) => string;
21
- getControlStyle: () => JSX.CSSProperties;
22
- getThumbStyle: (ctx: import("./slider.types").SharedContext) => JSX.CSSProperties;
23
- getRangeStyle: (ctx: Pick<import("./slider.types").SharedContext, "isVertical" | "isRtl">) => JSX.CSSProperties;
24
- getRootStyle: (ctx: Ctx) => JSX.CSSProperties;
25
- getMarkerStyle: (ctx: Pick<import("./slider.types").SharedContext, "isHorizontal" | "isRtl">, percent: number) => JSX.CSSProperties;
26
- getLabelStyle: () => JSX.CSSProperties;
27
- getTrackStyle: () => JSX.CSSProperties;
28
- getMarkerGroupStyle: () => JSX.CSSProperties;
29
- };
@@ -1,2 +0,0 @@
1
- import type { MachineContext, MachineState, UserDefinedContext } from "./slider.types";
2
- export declare function machine(ctx?: UserDefinedContext): import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
@@ -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 {};
@@ -1,173 +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 declare type Point = {
170
- x: number;
171
- y: number;
172
- };
173
- export {};
@@ -1,8 +0,0 @@
1
- import type { 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
- };