@zag-js/utils 1.21.6 → 1.21.8

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
@@ -60,7 +60,7 @@ declare const getMinValueAtIndex: (i: number, v: number[], vmin: number) => numb
60
60
  declare const getMaxValueAtIndex: (i: number, v: number[], vmax: number) => number;
61
61
  declare const isValueAtMax: (v: number, vmax: number) => boolean;
62
62
  declare const isValueAtMin: (v: number, vmin: number) => boolean;
63
- declare const isValueWithinRange: (v: number, vmin: number, vmax: number) => boolean;
63
+ declare const isValueWithinRange: (v: number, vmin: number | null | undefined, vmax: number | null | undefined) => boolean;
64
64
  declare const roundValue: (v: number, vmin: number, step: number) => number;
65
65
  declare const clampValue: (v: number, vmin: number, vmax: number) => number;
66
66
  declare const clampPercent: (v: number) => number;
package/dist/index.d.ts CHANGED
@@ -60,7 +60,7 @@ declare const getMinValueAtIndex: (i: number, v: number[], vmin: number) => numb
60
60
  declare const getMaxValueAtIndex: (i: number, v: number[], vmax: number) => number;
61
61
  declare const isValueAtMax: (v: number, vmax: number) => boolean;
62
62
  declare const isValueAtMin: (v: number, vmin: number) => boolean;
63
- declare const isValueWithinRange: (v: number, vmin: number, vmax: number) => boolean;
63
+ declare const isValueWithinRange: (v: number, vmin: number | null | undefined, vmax: number | null | undefined) => boolean;
64
64
  declare const roundValue: (v: number, vmin: number, step: number) => number;
65
65
  declare const clampValue: (v: number, vmin: number, vmax: number) => number;
66
66
  declare const clampPercent: (v: number) => number;
package/dist/index.js CHANGED
@@ -173,7 +173,7 @@ var tryCatch = (fn, fallback) => {
173
173
  function throttle(fn, wait = 0) {
174
174
  let lastCall = 0;
175
175
  let timeout = null;
176
- return (...args) => {
176
+ return ((...args) => {
177
177
  const now = Date.now();
178
178
  const timeSinceLastCall = now - lastCall;
179
179
  if (timeSinceLastCall >= wait) {
@@ -190,11 +190,11 @@ function throttle(fn, wait = 0) {
190
190
  timeout = null;
191
191
  }, wait - timeSinceLastCall);
192
192
  }
193
- };
193
+ });
194
194
  }
195
195
  function debounce(fn, wait = 0) {
196
196
  let timeout = null;
197
- return (...args) => {
197
+ return ((...args) => {
198
198
  if (timeout) {
199
199
  clearTimeout(timeout);
200
200
  timeout = null;
@@ -202,7 +202,7 @@ function debounce(fn, wait = 0) {
202
202
  timeout = setTimeout(() => {
203
203
  fn(...args);
204
204
  }, wait);
205
- };
205
+ });
206
206
  }
207
207
 
208
208
  // src/number.ts
@@ -215,7 +215,12 @@ var getMinValueAtIndex = (i, v, vmin) => i === 0 ? vmin : v[i - 1];
215
215
  var getMaxValueAtIndex = (i, v, vmax) => i === v.length - 1 ? vmax : v[i + 1];
216
216
  var isValueAtMax = (v, vmax) => nan(v) >= vmax;
217
217
  var isValueAtMin = (v, vmin) => nan(v) <= vmin;
218
- var isValueWithinRange = (v, vmin, vmax) => nan(v) >= vmin && nan(v) <= vmax;
218
+ var isValueWithinRange = (v, vmin, vmax) => {
219
+ const value = nan(v);
220
+ const minCheck = vmin == null || value >= vmin;
221
+ const maxCheck = vmax == null || value <= vmax;
222
+ return minCheck && maxCheck;
223
+ };
219
224
  var roundValue = (v, vmin, step) => round((nan(v) - vmin) / step) * step + vmin;
220
225
  var clampValue = (v, vmin, vmax) => min(max(nan(v), vmin), vmax);
221
226
  var clampPercent = (v) => clampValue(v, 0, 1);
package/dist/index.mjs CHANGED
@@ -171,7 +171,7 @@ var tryCatch = (fn, fallback) => {
171
171
  function throttle(fn, wait = 0) {
172
172
  let lastCall = 0;
173
173
  let timeout = null;
174
- return (...args) => {
174
+ return ((...args) => {
175
175
  const now = Date.now();
176
176
  const timeSinceLastCall = now - lastCall;
177
177
  if (timeSinceLastCall >= wait) {
@@ -188,11 +188,11 @@ function throttle(fn, wait = 0) {
188
188
  timeout = null;
189
189
  }, wait - timeSinceLastCall);
190
190
  }
191
- };
191
+ });
192
192
  }
193
193
  function debounce(fn, wait = 0) {
194
194
  let timeout = null;
195
- return (...args) => {
195
+ return ((...args) => {
196
196
  if (timeout) {
197
197
  clearTimeout(timeout);
198
198
  timeout = null;
@@ -200,7 +200,7 @@ function debounce(fn, wait = 0) {
200
200
  timeout = setTimeout(() => {
201
201
  fn(...args);
202
202
  }, wait);
203
- };
203
+ });
204
204
  }
205
205
 
206
206
  // src/number.ts
@@ -213,7 +213,12 @@ var getMinValueAtIndex = (i, v, vmin) => i === 0 ? vmin : v[i - 1];
213
213
  var getMaxValueAtIndex = (i, v, vmax) => i === v.length - 1 ? vmax : v[i + 1];
214
214
  var isValueAtMax = (v, vmax) => nan(v) >= vmax;
215
215
  var isValueAtMin = (v, vmin) => nan(v) <= vmin;
216
- var isValueWithinRange = (v, vmin, vmax) => nan(v) >= vmin && nan(v) <= vmax;
216
+ var isValueWithinRange = (v, vmin, vmax) => {
217
+ const value = nan(v);
218
+ const minCheck = vmin == null || value >= vmin;
219
+ const maxCheck = vmax == null || value <= vmax;
220
+ return minCheck && maxCheck;
221
+ };
217
222
  var roundValue = (v, vmin, step) => round((nan(v) - vmin) / step) * step + vmin;
218
223
  var clampValue = (v, vmin, vmax) => min(max(nan(v), vmin), vmax);
219
224
  var clampPercent = (v) => clampValue(v, 0, 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/utils",
3
- "version": "1.21.6",
3
+ "version": "1.21.8",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "js",