@zag-js/slider 0.16.0 → 0.17.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.
@@ -97,61 +97,12 @@ type PublicContext = DirectionProperty &
97
97
  * - `contain`: the thumb will be contained within the bounds of the track.
98
98
  */
99
99
  thumbAlignment?: "contain" | "center"
100
+ /**
101
+ * The slider thumb dimensions.If not provided, the thumb size will be measured automatically.
102
+ */
103
+ thumbSize: { width: number; height: number } | null
100
104
  }
101
105
 
102
- export type PublicApi<T extends PropTypes = PropTypes> = {
103
- /**
104
- * Whether the slider is focused.
105
- */
106
- isFocused: boolean
107
- /**
108
- * Whether the slider is being dragged.
109
- */
110
- isDragging: boolean
111
- /**
112
- * The value of the slider.
113
- */
114
- value: number
115
- /**
116
- * The value of the slider as a percent.
117
- */
118
- percent: number
119
- /**
120
- * Function to set the value of the slider.
121
- */
122
- setValue(value: number): void
123
- /**
124
- * Returns the value of the slider at the given percent.
125
- */
126
- getPercentValue: (percent: number) => number
127
- /**
128
- * Returns the percent of the slider at the given value.
129
- */
130
- getValuePercent: (value: number) => number
131
- /**
132
- * Function to focus the slider.
133
- */
134
- focus(): void
135
- /**
136
- * Function to increment the value of the slider by the step.
137
- */
138
- increment(): void
139
- /**
140
- * Function to decrement the value of the slider by the step.
141
- */
142
- decrement(): void
143
- rootProps: T["element"]
144
- labelProps: T["label"]
145
- thumbProps: T["element"]
146
- hiddenInputProps: T["input"]
147
- outputProps: T["output"]
148
- trackProps: T["element"]
149
- rangeProps: T["element"]
150
- controlProps: T["element"]
151
- markerGroupProps: T["element"]
152
- getMarkerProps({ value }: { value: number }): T["element"]
153
- }
154
-
155
106
  export type UserDefinedContext = RequiredBy<PublicContext, "id">
156
107
 
157
108
  type ComputedContext = Readonly<{
@@ -159,49 +110,50 @@ type ComputedContext = Readonly<{
159
110
  * @computed
160
111
  * Whether the slider is interactive
161
112
  */
162
- readonly isInteractive: boolean
113
+ isInteractive: boolean
163
114
  /**
164
115
  * @computed
165
116
  * Whether the thumb size has been measured
166
117
  */
167
- readonly hasMeasuredThumbSize: boolean
118
+ hasMeasuredThumbSize: boolean
168
119
  /**
169
120
  * @computed
170
121
  * Whether the slider is horizontal
171
122
  */
172
- readonly isHorizontal: boolean
123
+ isHorizontal: boolean
173
124
  /**
174
125
  * @computed
175
126
  * Whether the slider is vertical
176
127
  */
177
- readonly isVertical: boolean
128
+ isVertical: boolean
178
129
  /**
179
130
  * @computed
180
131
  * Whether the slider is in RTL mode
181
132
  */
182
- readonly isRtl: boolean
133
+ isRtl: boolean
183
134
  /**
184
135
  * @computed
185
136
  * The value of the slider as a percentage
186
137
  */
187
- readonly valuePercent: number
138
+ valuePercent: number
139
+ /**
140
+ * @computed
141
+ * Whether the slider is disabled
142
+ */
143
+ isDisabled: boolean
188
144
  }>
189
145
 
190
146
  type PrivateContext = Context<{
191
147
  /**
192
- * @internal The move threshold of the slider thumb before it is considered to be moved
148
+ * @internal
149
+ * The move threshold of the slider thumb before it is considered to be moved
193
150
  */
194
151
  threshold: number
195
- /**
196
- * @internal The slider thumb dimensions
197
- */
198
- thumbSize: { width: number; height: number } | null
199
152
  /**
200
153
  * @internal
201
- * The value of the slider when it was initially rendered.
202
- * Used when the `form.reset(...)` is called.
154
+ * Whether the slider fieldset is disabled
203
155
  */
204
- initialValue: number | null
156
+ fieldsetDisabled: boolean
205
157
  }>
206
158
 
207
159
  export type MachineContext = PublicContext & ComputedContext & PrivateContext
@@ -233,3 +185,56 @@ export type Point = {
233
185
  x: number
234
186
  y: number
235
187
  }
188
+
189
+ export type MachineApi<T extends PropTypes = PropTypes> = {
190
+ /**
191
+ * Whether the slider is focused.
192
+ */
193
+ isFocused: boolean
194
+ /**
195
+ * Whether the slider is being dragged.
196
+ */
197
+ isDragging: boolean
198
+ /**
199
+ * The value of the slider.
200
+ */
201
+ value: number
202
+ /**
203
+ * The value of the slider as a percent.
204
+ */
205
+ percent: number
206
+ /**
207
+ * Function to set the value of the slider.
208
+ */
209
+ setValue(value: number): void
210
+ /**
211
+ * Returns the value of the slider at the given percent.
212
+ */
213
+ getPercentValue: (percent: number) => number
214
+ /**
215
+ * Returns the percent of the slider at the given value.
216
+ */
217
+ getValuePercent: (value: number) => number
218
+ /**
219
+ * Function to focus the slider.
220
+ */
221
+ focus(): void
222
+ /**
223
+ * Function to increment the value of the slider by the step.
224
+ */
225
+ increment(): void
226
+ /**
227
+ * Function to decrement the value of the slider by the step.
228
+ */
229
+ decrement(): void
230
+ rootProps: T["element"]
231
+ labelProps: T["label"]
232
+ thumbProps: T["element"]
233
+ hiddenInputProps: T["input"]
234
+ outputProps: T["output"]
235
+ trackProps: T["element"]
236
+ rangeProps: T["element"]
237
+ controlProps: T["element"]
238
+ markerGroupProps: T["element"]
239
+ getMarkerProps({ value }: { value: number }): T["element"]
240
+ }