@zag-js/utils 1.31.0 → 1.32.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
@@ -38,6 +38,7 @@ declare function match<V extends string | number = string, R = unknown>(key: V,
38
38
  declare const tryCatch: <R>(fn: () => R, fallback: () => R) => R;
39
39
  declare function throttle<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
40
40
  declare function debounce<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
41
+ declare const hash: (value: string) => string;
41
42
 
42
43
  type AnyFunction = (...args: any[]) => any;
43
44
  declare const isDev: () => boolean;
@@ -144,4 +145,4 @@ declare function ensure<T>(c: T | null | undefined, m: () => string): asserts c
144
145
  type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
145
146
  declare function ensureProps<T, K extends keyof T>(props: T, keys: K[], scope?: string): asserts props is T & RequiredBy<T, K>;
146
147
 
147
- export { type IndexOptions, type MaybeFunction, type Nullable, type Store, type StoreCompareFn, type StoreListener, Timer, type TimerBaseContext, type TimerContextFn, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, createStore, debounce, decrementValue, diff, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, partition, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
148
+ export { type IndexOptions, type MaybeFunction, type Nullable, type Store, type StoreCompareFn, type StoreListener, Timer, type TimerBaseContext, type TimerContextFn, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, createStore, debounce, decrementValue, diff, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, hash, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, partition, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
package/dist/index.d.ts CHANGED
@@ -38,6 +38,7 @@ declare function match<V extends string | number = string, R = unknown>(key: V,
38
38
  declare const tryCatch: <R>(fn: () => R, fallback: () => R) => R;
39
39
  declare function throttle<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
40
40
  declare function debounce<T extends (...args: any[]) => void>(fn: T, wait?: number): T;
41
+ declare const hash: (value: string) => string;
41
42
 
42
43
  type AnyFunction = (...args: any[]) => any;
43
44
  declare const isDev: () => boolean;
@@ -144,4 +145,4 @@ declare function ensure<T>(c: T | null | undefined, m: () => string): asserts c
144
145
  type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
145
146
  declare function ensureProps<T, K extends keyof T>(props: T, keys: K[], scope?: string): asserts props is T & RequiredBy<T, K>;
146
147
 
147
- export { type IndexOptions, type MaybeFunction, type Nullable, type Store, type StoreCompareFn, type StoreListener, Timer, type TimerBaseContext, type TimerContextFn, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, createStore, debounce, decrementValue, diff, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, partition, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
148
+ export { type IndexOptions, type MaybeFunction, type Nullable, type Store, type StoreCompareFn, type StoreListener, Timer, type TimerBaseContext, type TimerContextFn, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, createStore, debounce, decrementValue, diff, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, hash, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, partition, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
package/dist/index.js CHANGED
@@ -214,6 +214,19 @@ function debounce(fn, wait = 0) {
214
214
  }, wait);
215
215
  });
216
216
  }
217
+ var toChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
218
+ function toName(code) {
219
+ let name = "";
220
+ let x;
221
+ for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
222
+ return toChar(x % 52) + name;
223
+ }
224
+ function toPhash(h, x) {
225
+ let i = x.length;
226
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
227
+ return h;
228
+ }
229
+ var hash = (value) => toName(toPhash(5381, value) >>> 0);
217
230
 
218
231
  // src/number.ts
219
232
  var { floor, abs, round, min, max, pow, sign } = Math;
@@ -564,6 +577,7 @@ exports.getValueSetterAtIndex = getValueSetterAtIndex;
564
577
  exports.getValueTransformer = getValueTransformer;
565
578
  exports.has = has;
566
579
  exports.hasProp = hasProp;
580
+ exports.hash = hash;
567
581
  exports.identity = identity;
568
582
  exports.incrementValue = incrementValue;
569
583
  exports.insertAt = insertAt;
package/dist/index.mjs CHANGED
@@ -212,6 +212,19 @@ function debounce(fn, wait = 0) {
212
212
  }, wait);
213
213
  });
214
214
  }
215
+ var toChar = (code) => String.fromCharCode(code + (code > 25 ? 39 : 97));
216
+ function toName(code) {
217
+ let name = "";
218
+ let x;
219
+ for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;
220
+ return toChar(x % 52) + name;
221
+ }
222
+ function toPhash(h, x) {
223
+ let i = x.length;
224
+ while (i) h = h * 33 ^ x.charCodeAt(--i);
225
+ return h;
226
+ }
227
+ var hash = (value) => toName(toPhash(5381, value) >>> 0);
215
228
 
216
229
  // src/number.ts
217
230
  var { floor, abs, round, min, max, pow, sign } = Math;
@@ -529,4 +542,4 @@ function ensureProps(props, keys, scope) {
529
542
  throw new Error(`[zag-js${scope ? ` > ${scope}` : ""}] missing required props: ${missingKeys.join(", ")}`);
530
543
  }
531
544
 
532
- export { Timer, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, createStore, debounce, decrementValue, diff, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, partition, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
545
+ export { Timer, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, createStore, debounce, decrementValue, diff, ensure, ensureProps, first, flatArray, fromLength, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, has, hasProp, hash, identity, incrementValue, insertAt, invariant, isArray, isBoolean, isDev, isEmpty, isEqual, isFunction, isNaN, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString, isValueAtMax, isValueAtMin, isValueWithinRange, json, last, match, mod, nan, next, nextIndex, noop, omit, partition, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/utils",
3
- "version": "1.31.0",
3
+ "version": "1.32.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "js",