@zag-js/slider 0.0.0-dev-20220415160434 → 0.0.0-dev-20220417135151

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.
@@ -1,7 +1,6 @@
1
- import type { StateMachine as S } from "@zag-js/core";
2
1
  import { PropTypes, ReactPropTypes } from "@zag-js/types";
3
- import type { MachineContext, MachineState } from "./slider.types";
4
- export declare function connect<T extends PropTypes = ReactPropTypes>(state: S.State<MachineContext, MachineState>, send: (event: S.Event<S.AnyEventObject>) => void, normalize?: import("@zag-js/types").NormalizeProps): {
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): {
5
4
  isFocused: boolean;
6
5
  isDragging: boolean;
7
6
  value: number;
@@ -1 +1 @@
1
- {"version":3,"file":"slider.connect.d.ts","sourceRoot":"","sources":["../src/slider.connect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,IAAI,CAAC,EAAE,MAAM,cAAc,CAAA;AAIrD,OAAO,EAAiB,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGxE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElE,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,GAAG,cAAc,EAC1D,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE,YAAY,CAAC,EAC5C,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,IAAI,EAChD,SAAS,yCAAgB;;;;;oBAgBP,MAAM;6BAGG,MAAM;;;;;;;;;;;;;;eAwLI,MAAM;;EAiB5C"}
1
+ {"version":3,"file":"slider.connect.d.ts","sourceRoot":"","sources":["../src/slider.connect.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,SAAS,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGxE,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEjD,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,GAAG,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,yCAAgB;;;;;oBAe7F,MAAM;6BAGG,MAAM;;;;;;;;;;;;;;eAwLI,MAAM;;EAiB5C"}
@@ -1,3 +1,3 @@
1
- import { MachineContext, MachineState } from "./slider.types";
2
- export declare const machine: import("@zag-js/core").Machine<MachineContext, MachineState, import("@zag-js/core").StateMachine.AnyEventObject>;
1
+ import { 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>;
3
3
  //# sourceMappingURL=slider.machine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slider.machine.d.ts","sourceRoot":"","sources":["../src/slider.machine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7D,eAAO,MAAM,OAAO,kHA0NnB,CAAA"}
1
+ {"version":3,"file":"slider.machine.d.ts","sourceRoot":"","sources":["../src/slider.machine.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGjF,wBAAgB,OAAO,CAAC,GAAG,GAAE,kBAAuB,oHA6NnD"}
@@ -1,5 +1,6 @@
1
- import { Context } from "@zag-js/types";
2
- declare type IdMap = Partial<{
1
+ import type { StateMachine as S } from "@zag-js/core";
2
+ import type { Context, DirectionProperty } from "@zag-js/types";
3
+ declare type ElementIds = Partial<{
3
4
  root: string;
4
5
  thumb: string;
5
6
  control: string;
@@ -8,11 +9,11 @@ declare type IdMap = Partial<{
8
9
  label: string;
9
10
  output: string;
10
11
  }>;
11
- export declare type MachineContext = Context<{
12
+ declare type PublicContext = DirectionProperty & {
12
13
  /**
13
14
  * The ids of the elements in the slider. Useful for composition.
14
15
  */
15
- ids?: IdMap;
16
+ ids?: ElementIds;
16
17
  /**
17
18
  * The value of the slider
18
19
  */
@@ -38,10 +39,6 @@ export declare type MachineContext = Context<{
38
39
  * Whether the slider value is invalid
39
40
  */
40
41
  invalid?: boolean;
41
- /**
42
- * @computed Whether the slider is interactive
43
- */
44
- readonly isInteractive: boolean;
45
42
  /**
46
43
  * The minimum value of the slider
47
44
  */
@@ -54,10 +51,6 @@ export declare type MachineContext = Context<{
54
51
  * The step value of the slider
55
52
  */
56
53
  step: number;
57
- /**
58
- * @internal The move threshold of the slider thumb before it is considered to be moved
59
- */
60
- threshold: number;
61
54
  /**
62
55
  * The orientation of the slider
63
56
  */
@@ -101,30 +94,54 @@ export declare type MachineContext = Context<{
101
94
  onChangeStart?(details: {
102
95
  value: number;
103
96
  }): void;
97
+ };
98
+ export declare type UserDefinedContext = Partial<PublicContext>;
99
+ declare type ComputedContext = Readonly<{
104
100
  /**
105
- * @internal The slider thumb dimensions
101
+ * @computed
102
+ * Whether the slider is interactive
106
103
  */
107
- thumbSize: {
108
- width: number;
109
- height: number;
110
- } | null;
104
+ readonly isInteractive: boolean;
111
105
  /**
112
- * @internal Whether the thumb size has been measured
106
+ * @computed
107
+ * Whether the thumb size has been measured
113
108
  */
114
109
  readonly hasMeasuredThumbSize: boolean;
115
110
  /**
116
- * @computed Whether the slider is horizontal
111
+ * @computed
112
+ * Whether the slider is horizontal
117
113
  */
118
114
  readonly isHorizontal: boolean;
119
115
  /**
120
- * @computed Whether the slider is vertical
116
+ * @computed
117
+ * Whether the slider is vertical
121
118
  */
122
119
  readonly isVertical: boolean;
123
120
  /**
124
- * @computed Whether the slider is in RTL mode
121
+ * @computed
122
+ * Whether the slider is in RTL mode
125
123
  */
126
124
  readonly isRtl: boolean;
127
125
  }>;
126
+ declare type PrivateContext = Context<{
127
+ /**
128
+ * @internal The move threshold of the slider thumb before it is considered to be moved
129
+ */
130
+ threshold: number;
131
+ /**
132
+ * @internal The slider thumb dimensions
133
+ */
134
+ thumbSize: {
135
+ width: number;
136
+ height: number;
137
+ } | null;
138
+ }>;
139
+ export declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
140
+ export declare type MachineState = {
141
+ value: "unknown" | "idle" | "dragging" | "focus";
142
+ };
143
+ export declare type State = S.State<MachineContext, MachineState>;
144
+ export declare type Send = S.Send<S.AnyEventObject>;
128
145
  export declare type SharedContext = {
129
146
  min: number;
130
147
  max: number;
@@ -141,8 +158,5 @@ export declare type SharedContext = {
141
158
  orientation?: "horizontal" | "vertical";
142
159
  readonly hasMeasuredThumbSize: boolean;
143
160
  };
144
- export declare type MachineState = {
145
- value: "unknown" | "idle" | "dragging" | "focus";
146
- };
147
161
  export {};
148
162
  //# sourceMappingURL=slider.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slider.types.d.ts","sourceRoot":"","sources":["../src/slider.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,aAAK,KAAK,GAAG,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAAA;AAEF,oBAAY,cAAc,GAAG,OAAO,CAAC;IACnC;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,CAAA;IACX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,QAAQ,CA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,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IACvC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAA;CACvC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/slider",
3
- "version": "0.0.0-dev-20220415160434",
3
+ "version": "0.0.0-dev-20220417135151",
4
4
  "description": "Core logic for the slider widget implemented as a state machine",
5
5
  "keywords": [
6
6
  "js",
@@ -29,12 +29,12 @@
29
29
  "url": "https://github.com/chakra-ui/zag/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@zag-js/core": "^0.0.0-dev-20220415160434",
33
- "@zag-js/dom-utils": "^0.0.0-dev-20220415160434",
34
- "@zag-js/number-utils": "^0.0.0-dev-20220415160434",
35
- "@zag-js/rect-utils": "^0.0.0-dev-20220415160434",
36
- "@zag-js/types": "^0.0.0-dev-20220415160434",
37
- "@zag-js/utils": "^0.0.0-dev-20220415160434"
32
+ "@zag-js/core": "^0.0.0-dev-20220417135151",
33
+ "@zag-js/dom-utils": "^0.0.0-dev-20220417135151",
34
+ "@zag-js/number-utils": "^0.0.0-dev-20220417135151",
35
+ "@zag-js/rect-utils": "^0.0.0-dev-20220417135151",
36
+ "@zag-js/types": "^0.0.0-dev-20220417135151",
37
+ "@zag-js/utils": "^0.0.0-dev-20220417135151"
38
38
  },
39
39
  "scripts": {
40
40
  "build:fast": "zag build",