@zag-js/utils 1.15.0 → 1.15.2
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -1
- package/dist/index.mjs +6 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ declare const remove: <T>(v: T[], ...items: T[]) => T[];
|
|
|
9
9
|
declare const removeAt: <T>(v: T[], i: number) => T[];
|
|
10
10
|
declare const insertAt: <T>(v: T[], i: number, ...items: T[]) => T[];
|
|
11
11
|
declare const uniq: <T>(v: T[]) => T[];
|
|
12
|
+
declare const diff: <T>(a: T[], b: T[]) => T[];
|
|
12
13
|
declare const addOrRemove: <T>(v: T[], item: T) => T[];
|
|
13
14
|
declare function clear<T>(v: T[]): T[];
|
|
14
15
|
type IndexOptions = {
|
|
@@ -113,4 +114,4 @@ declare function ensure<T>(c: T | null | undefined, m: () => string): asserts c
|
|
|
113
114
|
type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
114
115
|
declare function ensureProps<T, K extends keyof T>(props: T, keys: K[], scope?: string): asserts props is T & RequiredBy<T, K>;
|
|
115
116
|
|
|
116
|
-
export { type IndexOptions, type MaybeFunction, type Nullable, type RafIntervalOptions, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, debounce, decrementValue, 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, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
|
|
117
|
+
export { type IndexOptions, type MaybeFunction, type Nullable, type RafIntervalOptions, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, 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, 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
|
@@ -9,6 +9,7 @@ declare const remove: <T>(v: T[], ...items: T[]) => T[];
|
|
|
9
9
|
declare const removeAt: <T>(v: T[], i: number) => T[];
|
|
10
10
|
declare const insertAt: <T>(v: T[], i: number, ...items: T[]) => T[];
|
|
11
11
|
declare const uniq: <T>(v: T[]) => T[];
|
|
12
|
+
declare const diff: <T>(a: T[], b: T[]) => T[];
|
|
12
13
|
declare const addOrRemove: <T>(v: T[], item: T) => T[];
|
|
13
14
|
declare function clear<T>(v: T[]): T[];
|
|
14
15
|
type IndexOptions = {
|
|
@@ -113,4 +114,4 @@ declare function ensure<T>(c: T | null | undefined, m: () => string): asserts c
|
|
|
113
114
|
type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
114
115
|
declare function ensureProps<T, K extends keyof T>(props: T, keys: K[], scope?: string): asserts props is T & RequiredBy<T, K>;
|
|
115
116
|
|
|
116
|
-
export { type IndexOptions, type MaybeFunction, type Nullable, type RafIntervalOptions, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, debounce, decrementValue, 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, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
|
|
117
|
+
export { type IndexOptions, type MaybeFunction, type Nullable, type RafIntervalOptions, add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, 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, 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/array.ts
|
|
4
4
|
function toArray(v) {
|
|
5
|
-
if (
|
|
5
|
+
if (v == null) return [];
|
|
6
6
|
return Array.isArray(v) ? v : [v];
|
|
7
7
|
}
|
|
8
8
|
var fromLength = (length) => Array.from(Array(length).keys());
|
|
@@ -15,6 +15,10 @@ var remove = (v, ...items) => v.filter((t) => !items.includes(t));
|
|
|
15
15
|
var removeAt = (v, i) => v.filter((_, idx) => idx !== i);
|
|
16
16
|
var insertAt = (v, i, ...items) => [...v.slice(0, i), ...items, ...v.slice(i)];
|
|
17
17
|
var uniq = (v) => Array.from(new Set(v));
|
|
18
|
+
var diff = (a, b) => {
|
|
19
|
+
const set = new Set(b);
|
|
20
|
+
return a.filter((t) => !set.has(t));
|
|
21
|
+
};
|
|
18
22
|
var addOrRemove = (v, item) => {
|
|
19
23
|
if (has(v, item)) return remove(v, item);
|
|
20
24
|
return add(v, item);
|
|
@@ -423,6 +427,7 @@ exports.compact = compact;
|
|
|
423
427
|
exports.createSplitProps = createSplitProps;
|
|
424
428
|
exports.debounce = debounce;
|
|
425
429
|
exports.decrementValue = decrementValue;
|
|
430
|
+
exports.diff = diff;
|
|
426
431
|
exports.ensure = ensure;
|
|
427
432
|
exports.ensureProps = ensureProps;
|
|
428
433
|
exports.first = first;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/array.ts
|
|
2
2
|
function toArray(v) {
|
|
3
|
-
if (
|
|
3
|
+
if (v == null) return [];
|
|
4
4
|
return Array.isArray(v) ? v : [v];
|
|
5
5
|
}
|
|
6
6
|
var fromLength = (length) => Array.from(Array(length).keys());
|
|
@@ -13,6 +13,10 @@ var remove = (v, ...items) => v.filter((t) => !items.includes(t));
|
|
|
13
13
|
var removeAt = (v, i) => v.filter((_, idx) => idx !== i);
|
|
14
14
|
var insertAt = (v, i, ...items) => [...v.slice(0, i), ...items, ...v.slice(i)];
|
|
15
15
|
var uniq = (v) => Array.from(new Set(v));
|
|
16
|
+
var diff = (a, b) => {
|
|
17
|
+
const set = new Set(b);
|
|
18
|
+
return a.filter((t) => !set.has(t));
|
|
19
|
+
};
|
|
16
20
|
var addOrRemove = (v, item) => {
|
|
17
21
|
if (has(v, item)) return remove(v, item);
|
|
18
22
|
return add(v, item);
|
|
@@ -409,4 +413,4 @@ function ensureProps(props, keys, scope) {
|
|
|
409
413
|
throw new Error(`[zag-js${scope ? ` > ${scope}` : ""}] missing required props: ${missingKeys.join(", ")}`);
|
|
410
414
|
}
|
|
411
415
|
|
|
412
|
-
export { add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, debounce, decrementValue, 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, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
|
|
416
|
+
export { add, addOrRemove, callAll, cast, chunk, clampPercent, clampValue, clear, compact, createSplitProps, 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, pick, prev, prevIndex, remove, removeAt, roundToDpr, roundToStepPrecision, roundValue, runIfFn, setRafInterval, setRafTimeout, setValueAtIndex, snapValueToStep, splitProps, throttle, toArray, toFixedNumber, toPx, tryCatch, uniq, uuid, warn, wrap };
|