@zag-js/utils 1.43.0 → 1.43.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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/object.d.mts +8 -1
- package/dist/object.d.ts +8 -1
- package/dist/object.js +12 -0
- package/dist/object.mjs +11 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { isEqual } from './equal.mjs';
|
|
|
3
3
|
export { MaybeFunction, Nullable, callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid } from './functions.mjs';
|
|
4
4
|
export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString } from './guard.mjs';
|
|
5
5
|
export { clampPercent, clampValue, decrementValue, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, incrementValue, isNaN, isValueAtMax, isValueAtMin, isValueWithinRange, mod, nan, roundToDpr, roundToStepPrecision, roundValue, setValueAtIndex, snapValueToStep, toFixedNumber, toPx, wrap } from './number.mjs';
|
|
6
|
-
export { compact, createSplitProps, json, keys, omit, pick, splitProps } from './object.mjs';
|
|
6
|
+
export { MergeWithDefault, compact, createSplitProps, json, keys, mergeWithDefault, omit, pick, splitProps } from './object.mjs';
|
|
7
7
|
export { Store, StoreCompareFn, StoreListener, createStore } from './store.mjs';
|
|
8
8
|
export { Timer, TimerBaseContext, TimerContextFn, setRafInterval, setRafTimeout } from './timers.mjs';
|
|
9
9
|
export { ensure, ensureProps, invariant, warn } from './warning.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { isEqual } from './equal.js';
|
|
|
3
3
|
export { MaybeFunction, Nullable, callAll, cast, debounce, hash, identity, match, noop, runIfFn, throttle, tryCatch, uuid } from './functions.js';
|
|
4
4
|
export { hasProp, isArray, isBoolean, isDev, isFunction, isNull, isNumber, isObject, isObjectLike, isPlainObject, isString } from './guard.js';
|
|
5
5
|
export { clampPercent, clampValue, decrementValue, getClosestValue, getClosestValueIndex, getMaxValueAtIndex, getMinValueAtIndex, getNextStepValue, getPercentValue, getPreviousStepValue, getValuePercent, getValueRanges, getValueSetterAtIndex, getValueTransformer, incrementValue, isNaN, isValueAtMax, isValueAtMin, isValueWithinRange, mod, nan, roundToDpr, roundToStepPrecision, roundValue, setValueAtIndex, snapValueToStep, toFixedNumber, toPx, wrap } from './number.js';
|
|
6
|
-
export { compact, createSplitProps, json, keys, omit, pick, splitProps } from './object.js';
|
|
6
|
+
export { MergeWithDefault, compact, createSplitProps, json, keys, mergeWithDefault, omit, pick, splitProps } from './object.js';
|
|
7
7
|
export { Store, StoreCompareFn, StoreListener, createStore } from './store.js';
|
|
8
8
|
export { Timer, TimerBaseContext, TimerContextFn, setRafInterval, setRafTimeout } from './timers.js';
|
|
9
9
|
export { ensure, ensureProps, invariant, warn } from './warning.js';
|
package/dist/object.d.mts
CHANGED
|
@@ -6,5 +6,12 @@ type Dict = Record<string | symbol, any>;
|
|
|
6
6
|
declare function splitProps<T extends Dict>(props: T, keys: (keyof T)[]): Dict[];
|
|
7
7
|
declare const createSplitProps: <T extends Dict>(keys: (keyof T)[]) => <Props extends T>(props: Props) => [T, Omit<Props, keyof T>];
|
|
8
8
|
declare function omit<T extends Record<string, any>>(obj: T, keys: string[]): Omit<T, string | number>;
|
|
9
|
+
type Defined<T> = {
|
|
10
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
11
|
+
};
|
|
12
|
+
type MergeWithDefault<D, O = unknown> = Defined<D> & ([NonNullable<O>] extends [never] ? unknown : Omit<NonNullable<O>, keyof D>);
|
|
13
|
+
declare function mergeWithDefault<D extends object, O extends {
|
|
14
|
+
[K in keyof D]?: D[K] | undefined;
|
|
15
|
+
} | undefined>(defaults: D, overrides?: O): MergeWithDefault<D, O>;
|
|
9
16
|
|
|
10
|
-
export { compact, createSplitProps, json, keys, omit, pick, splitProps };
|
|
17
|
+
export { type MergeWithDefault, compact, createSplitProps, json, keys, mergeWithDefault, omit, pick, splitProps };
|
package/dist/object.d.ts
CHANGED
|
@@ -6,5 +6,12 @@ type Dict = Record<string | symbol, any>;
|
|
|
6
6
|
declare function splitProps<T extends Dict>(props: T, keys: (keyof T)[]): Dict[];
|
|
7
7
|
declare const createSplitProps: <T extends Dict>(keys: (keyof T)[]) => <Props extends T>(props: Props) => [T, Omit<Props, keyof T>];
|
|
8
8
|
declare function omit<T extends Record<string, any>>(obj: T, keys: string[]): Omit<T, string | number>;
|
|
9
|
+
type Defined<T> = {
|
|
10
|
+
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
11
|
+
};
|
|
12
|
+
type MergeWithDefault<D, O = unknown> = Defined<D> & ([NonNullable<O>] extends [never] ? unknown : Omit<NonNullable<O>, keyof D>);
|
|
13
|
+
declare function mergeWithDefault<D extends object, O extends {
|
|
14
|
+
[K in keyof D]?: D[K] | undefined;
|
|
15
|
+
} | undefined>(defaults: D, overrides?: O): MergeWithDefault<D, O>;
|
|
9
16
|
|
|
10
|
-
export { compact, createSplitProps, json, keys, omit, pick, splitProps };
|
|
17
|
+
export { type MergeWithDefault, compact, createSplitProps, json, keys, mergeWithDefault, omit, pick, splitProps };
|
package/dist/object.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(object_exports, {
|
|
|
24
24
|
createSplitProps: () => createSplitProps,
|
|
25
25
|
json: () => json,
|
|
26
26
|
keys: () => keys,
|
|
27
|
+
mergeWithDefault: () => mergeWithDefault,
|
|
27
28
|
omit: () => omit,
|
|
28
29
|
pick: () => pick,
|
|
29
30
|
splitProps: () => splitProps
|
|
@@ -76,12 +77,23 @@ var createSplitProps = (keys2) => {
|
|
|
76
77
|
function omit(obj, keys2) {
|
|
77
78
|
return createSplitProps(keys2)(obj)[1];
|
|
78
79
|
}
|
|
80
|
+
function mergeWithDefault(defaults, overrides) {
|
|
81
|
+
if (!overrides) return defaults;
|
|
82
|
+
const result = { ...defaults };
|
|
83
|
+
const source = overrides;
|
|
84
|
+
for (const key in source) {
|
|
85
|
+
const value = source[key];
|
|
86
|
+
if (value !== void 0) result[key] = value;
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
79
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
80
91
|
0 && (module.exports = {
|
|
81
92
|
compact,
|
|
82
93
|
createSplitProps,
|
|
83
94
|
json,
|
|
84
95
|
keys,
|
|
96
|
+
mergeWithDefault,
|
|
85
97
|
omit,
|
|
86
98
|
pick,
|
|
87
99
|
splitProps
|
package/dist/object.mjs
CHANGED
|
@@ -48,11 +48,22 @@ var createSplitProps = (keys2) => {
|
|
|
48
48
|
function omit(obj, keys2) {
|
|
49
49
|
return createSplitProps(keys2)(obj)[1];
|
|
50
50
|
}
|
|
51
|
+
function mergeWithDefault(defaults, overrides) {
|
|
52
|
+
if (!overrides) return defaults;
|
|
53
|
+
const result = { ...defaults };
|
|
54
|
+
const source = overrides;
|
|
55
|
+
for (const key in source) {
|
|
56
|
+
const value = source[key];
|
|
57
|
+
if (value !== void 0) result[key] = value;
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
51
61
|
export {
|
|
52
62
|
compact,
|
|
53
63
|
createSplitProps,
|
|
54
64
|
json,
|
|
55
65
|
keys,
|
|
66
|
+
mergeWithDefault,
|
|
56
67
|
omit,
|
|
57
68
|
pick,
|
|
58
69
|
splitProps
|