@yamada-ui/utils 0.3.0 → 0.3.1
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/{chunk-OL4TBQN7.mjs → chunk-5OQGKXOK.mjs} +6 -6
- package/dist/color.d.mts +11 -10
- package/dist/color.d.ts +11 -10
- package/dist/color.mjs +1 -1
- package/dist/function.mjs +1 -1
- package/dist/index.js +6 -6
- package/dist/index.mjs +1 -1
- package/dist/object.d.mts +2 -2
- package/dist/object.d.ts +2 -2
- package/dist/object.js +6 -6
- package/dist/object.mjs +1 -1
- package/dist/react.mjs +1 -1
- package/package.json +1 -1
|
@@ -339,16 +339,16 @@ var filterObject = (obj, func) => {
|
|
|
339
339
|
return result;
|
|
340
340
|
};
|
|
341
341
|
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
|
|
342
|
-
var merge = (target, source,
|
|
342
|
+
var merge = (target, source, mergeArray = false) => {
|
|
343
343
|
let result = Object.assign({}, target);
|
|
344
344
|
if (isObject(source)) {
|
|
345
345
|
if (isObject(target)) {
|
|
346
346
|
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
347
347
|
const targetValue = target[sourceKey];
|
|
348
|
-
if (
|
|
348
|
+
if (mergeArray && isArray(sourceValue) && isArray(targetValue)) {
|
|
349
349
|
result[sourceKey] = targetValue.concat(...sourceValue);
|
|
350
350
|
} else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
|
|
351
|
-
result[sourceKey] = merge(targetValue, sourceValue,
|
|
351
|
+
result[sourceKey] = merge(targetValue, sourceValue, mergeArray);
|
|
352
352
|
} else {
|
|
353
353
|
Object.assign(result, { [sourceKey]: sourceValue });
|
|
354
354
|
}
|
|
@@ -359,12 +359,12 @@ var merge = (target, source, overrideArray = false) => {
|
|
|
359
359
|
}
|
|
360
360
|
return result;
|
|
361
361
|
};
|
|
362
|
-
var flattenObject = (obj, maxDepth = Infinity) => {
|
|
362
|
+
var flattenObject = (obj, maxDepth = Infinity, omitKeys = []) => {
|
|
363
363
|
if (!isObject(obj) && !isArray(obj) || !maxDepth)
|
|
364
364
|
return obj;
|
|
365
365
|
return Object.entries(obj).reduce((result, [key, value]) => {
|
|
366
|
-
if (isObject(value)) {
|
|
367
|
-
Object.entries(flattenObject(value, maxDepth - 1)).forEach(
|
|
366
|
+
if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2))) {
|
|
367
|
+
Object.entries(flattenObject(value, maxDepth - 1, omitKeys)).forEach(
|
|
368
368
|
([childKey, childValue]) => {
|
|
369
369
|
result[`${key}.${childKey}`] = childValue;
|
|
370
370
|
}
|
package/dist/color.d.mts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { Dict } from './index.types.mjs';
|
|
2
2
|
|
|
3
|
+
type ColorMode = 'light' | 'dark';
|
|
3
4
|
declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
4
5
|
declare const isGray: (colorScheme: string) => boolean;
|
|
5
|
-
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?:
|
|
6
|
-
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
7
|
-
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
8
|
-
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
9
|
-
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
10
|
-
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?:
|
|
11
|
-
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?:
|
|
6
|
+
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
7
|
+
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
8
|
+
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
9
|
+
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
10
|
+
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
11
|
+
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
12
|
+
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
12
13
|
declare const randomColor: ({ string, colors, }?: {
|
|
13
14
|
string?: string | undefined;
|
|
14
15
|
colors?: string[] | undefined;
|
|
15
16
|
}) => string;
|
|
16
|
-
declare const isTone: (color: string) => (theme?: Dict, colorMode?:
|
|
17
|
-
declare const isLight: (color: string) => (theme?: Dict, colorMode?:
|
|
18
|
-
declare const isDark: (color: string) => (theme?: Dict, colorMode?:
|
|
17
|
+
declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) => "light" | "dark";
|
|
18
|
+
declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
19
|
+
declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
19
20
|
|
|
20
21
|
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
|
package/dist/color.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { Dict } from './index.types.js';
|
|
2
2
|
|
|
3
|
+
type ColorMode = 'light' | 'dark';
|
|
3
4
|
declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
4
5
|
declare const isGray: (colorScheme: string) => boolean;
|
|
5
|
-
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?:
|
|
6
|
-
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
7
|
-
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
8
|
-
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
9
|
-
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?:
|
|
10
|
-
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?:
|
|
11
|
-
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?:
|
|
6
|
+
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
7
|
+
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
8
|
+
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
9
|
+
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
10
|
+
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
11
|
+
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
12
|
+
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: ColorMode) => string;
|
|
12
13
|
declare const randomColor: ({ string, colors, }?: {
|
|
13
14
|
string?: string | undefined;
|
|
14
15
|
colors?: string[] | undefined;
|
|
15
16
|
}) => string;
|
|
16
|
-
declare const isTone: (color: string) => (theme?: Dict, colorMode?:
|
|
17
|
-
declare const isLight: (color: string) => (theme?: Dict, colorMode?:
|
|
18
|
-
declare const isDark: (color: string) => (theme?: Dict, colorMode?:
|
|
17
|
+
declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) => "light" | "dark";
|
|
18
|
+
declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
19
|
+
declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean;
|
|
19
20
|
|
|
20
21
|
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor };
|
package/dist/color.mjs
CHANGED
package/dist/function.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -193,16 +193,16 @@ var filterObject = (obj, func) => {
|
|
|
193
193
|
return result;
|
|
194
194
|
};
|
|
195
195
|
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
|
|
196
|
-
var merge = (target, source,
|
|
196
|
+
var merge = (target, source, mergeArray = false) => {
|
|
197
197
|
let result = Object.assign({}, target);
|
|
198
198
|
if (isObject(source)) {
|
|
199
199
|
if (isObject(target)) {
|
|
200
200
|
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
201
201
|
const targetValue = target[sourceKey];
|
|
202
|
-
if (
|
|
202
|
+
if (mergeArray && isArray(sourceValue) && isArray(targetValue)) {
|
|
203
203
|
result[sourceKey] = targetValue.concat(...sourceValue);
|
|
204
204
|
} else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
|
|
205
|
-
result[sourceKey] = merge(targetValue, sourceValue,
|
|
205
|
+
result[sourceKey] = merge(targetValue, sourceValue, mergeArray);
|
|
206
206
|
} else {
|
|
207
207
|
Object.assign(result, { [sourceKey]: sourceValue });
|
|
208
208
|
}
|
|
@@ -213,12 +213,12 @@ var merge = (target, source, overrideArray = false) => {
|
|
|
213
213
|
}
|
|
214
214
|
return result;
|
|
215
215
|
};
|
|
216
|
-
var flattenObject = (obj, maxDepth = Infinity) => {
|
|
216
|
+
var flattenObject = (obj, maxDepth = Infinity, omitKeys = []) => {
|
|
217
217
|
if (!isObject(obj) && !isArray(obj) || !maxDepth)
|
|
218
218
|
return obj;
|
|
219
219
|
return Object.entries(obj).reduce((result, [key, value]) => {
|
|
220
|
-
if (isObject(value)) {
|
|
221
|
-
Object.entries(flattenObject(value, maxDepth - 1)).forEach(
|
|
220
|
+
if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2))) {
|
|
221
|
+
Object.entries(flattenObject(value, maxDepth - 1, omitKeys)).forEach(
|
|
222
222
|
([childKey, childValue]) => {
|
|
223
223
|
result[`${key}.${childKey}`] = childValue;
|
|
224
224
|
}
|
package/dist/index.mjs
CHANGED
package/dist/object.d.mts
CHANGED
|
@@ -5,8 +5,8 @@ declare const pickObject: <T extends Dict, K extends keyof T>(obj: T, keys: K[])
|
|
|
5
5
|
declare const splitObject: <T extends Dict, K extends keyof T>(obj: T, keys: K[]) => [{ [P in K]: T[P]; }, Omit<T, K>];
|
|
6
6
|
declare const filterObject: <T extends Dict, K extends Dict>(obj: T, func: (key: keyof T, value: T[keyof T], obj: T) => boolean) => K;
|
|
7
7
|
declare const filterUndefined: <T extends Dict>(obj: T) => T;
|
|
8
|
-
declare const merge: <T extends Dict>(target: any, source: any,
|
|
9
|
-
declare const flattenObject: <T extends Dict>(obj: any, maxDepth?: number) => T;
|
|
8
|
+
declare const merge: <T extends Dict>(target: any, source: any, mergeArray?: boolean) => T;
|
|
9
|
+
declare const flattenObject: <T extends Dict>(obj: any, maxDepth?: number, omitKeys?: string[]) => T;
|
|
10
10
|
declare const objectFromEntries: <T extends Dict>(entries: any[][]) => T;
|
|
11
11
|
declare const keysFormObject: <T extends Dict>(obj: T) => (keyof T)[];
|
|
12
12
|
declare const replaceObject: <T extends unknown>(objOrArray: T, callBack: (value: any) => any) => T;
|
package/dist/object.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ declare const pickObject: <T extends Dict, K extends keyof T>(obj: T, keys: K[])
|
|
|
5
5
|
declare const splitObject: <T extends Dict, K extends keyof T>(obj: T, keys: K[]) => [{ [P in K]: T[P]; }, Omit<T, K>];
|
|
6
6
|
declare const filterObject: <T extends Dict, K extends Dict>(obj: T, func: (key: keyof T, value: T[keyof T], obj: T) => boolean) => K;
|
|
7
7
|
declare const filterUndefined: <T extends Dict>(obj: T) => T;
|
|
8
|
-
declare const merge: <T extends Dict>(target: any, source: any,
|
|
9
|
-
declare const flattenObject: <T extends Dict>(obj: any, maxDepth?: number) => T;
|
|
8
|
+
declare const merge: <T extends Dict>(target: any, source: any, mergeArray?: boolean) => T;
|
|
9
|
+
declare const flattenObject: <T extends Dict>(obj: any, maxDepth?: number, omitKeys?: string[]) => T;
|
|
10
10
|
declare const objectFromEntries: <T extends Dict>(entries: any[][]) => T;
|
|
11
11
|
declare const keysFormObject: <T extends Dict>(obj: T) => (keyof T)[];
|
|
12
12
|
declare const replaceObject: <T extends unknown>(objOrArray: T, callBack: (value: any) => any) => T;
|
package/dist/object.js
CHANGED
|
@@ -82,16 +82,16 @@ var filterObject = (obj, func) => {
|
|
|
82
82
|
return result;
|
|
83
83
|
};
|
|
84
84
|
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0);
|
|
85
|
-
var merge = (target, source,
|
|
85
|
+
var merge = (target, source, mergeArray = false) => {
|
|
86
86
|
let result = Object.assign({}, target);
|
|
87
87
|
if (isObject(source)) {
|
|
88
88
|
if (isObject(target)) {
|
|
89
89
|
for (const [sourceKey, sourceValue] of Object.entries(source)) {
|
|
90
90
|
const targetValue = target[sourceKey];
|
|
91
|
-
if (
|
|
91
|
+
if (mergeArray && isArray(sourceValue) && isArray(targetValue)) {
|
|
92
92
|
result[sourceKey] = targetValue.concat(...sourceValue);
|
|
93
93
|
} else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) {
|
|
94
|
-
result[sourceKey] = merge(targetValue, sourceValue,
|
|
94
|
+
result[sourceKey] = merge(targetValue, sourceValue, mergeArray);
|
|
95
95
|
} else {
|
|
96
96
|
Object.assign(result, { [sourceKey]: sourceValue });
|
|
97
97
|
}
|
|
@@ -102,12 +102,12 @@ var merge = (target, source, overrideArray = false) => {
|
|
|
102
102
|
}
|
|
103
103
|
return result;
|
|
104
104
|
};
|
|
105
|
-
var flattenObject = (obj, maxDepth = Infinity) => {
|
|
105
|
+
var flattenObject = (obj, maxDepth = Infinity, omitKeys = []) => {
|
|
106
106
|
if (!isObject(obj) && !isArray(obj) || !maxDepth)
|
|
107
107
|
return obj;
|
|
108
108
|
return Object.entries(obj).reduce((result, [key, value]) => {
|
|
109
|
-
if (isObject(value)) {
|
|
110
|
-
Object.entries(flattenObject(value, maxDepth - 1)).forEach(
|
|
109
|
+
if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2))) {
|
|
110
|
+
Object.entries(flattenObject(value, maxDepth - 1, omitKeys)).forEach(
|
|
111
111
|
([childKey, childValue]) => {
|
|
112
112
|
result[`${key}.${childKey}`] = childValue;
|
|
113
113
|
}
|
package/dist/object.mjs
CHANGED
package/dist/react.mjs
CHANGED