@yamada-ui/utils 0.3.0 → 0.3.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.
@@ -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, overrideArray = false) => {
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 (overrideArray && isArray(sourceValue) && isArray(targetValue)) {
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, overrideArray);
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?: 'light' | 'dark') => string;
6
- declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
7
- declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
8
- declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
9
- declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
10
- declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
11
- declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
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?: 'light' | 'dark') => "light" | "dark";
17
- declare const isLight: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
18
- declare const isDark: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
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?: 'light' | 'dark') => string;
6
- declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
7
- declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
8
- declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
9
- declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
10
- declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
11
- declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: 'light' | 'dark') => string;
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?: 'light' | 'dark') => "light" | "dark";
17
- declare const isLight: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
18
- declare const isDark: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean;
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
@@ -12,7 +12,7 @@ import {
12
12
  tintColor,
13
13
  toneColor,
14
14
  transparentizeColor
15
- } from "./chunk-OL4TBQN7.mjs";
15
+ } from "./chunk-5OQGKXOK.mjs";
16
16
  import "./chunk-SLJ4M7XC.mjs";
17
17
  import "./chunk-VYMGBE25.mjs";
18
18
  import "./chunk-BZAW2D6U.mjs";
package/dist/function.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  handlerAll,
4
4
  noop,
5
5
  runIfFunc
6
- } from "./chunk-OL4TBQN7.mjs";
6
+ } from "./chunk-5OQGKXOK.mjs";
7
7
  import "./chunk-SLJ4M7XC.mjs";
8
8
  import "./chunk-VYMGBE25.mjs";
9
9
  import "./chunk-BZAW2D6U.mjs";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { Dict, Length, Path, StringLiteral, Union } from './index.types.mjs';
1
+ export { Dict, Length, Path, Primitive, StringLiteral, Union } from './index.types.mjs';
2
2
  export { cast, isArray, isEmpty, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isString, isUndefined, isUnit } from './assertion.mjs';
3
3
  export { assignAfter, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, keysFormObject, memoizeObject, merge, objectFromEntries, omitObject, pickObject, replaceObject, splitObject } from './object.mjs';
4
4
  export { funcAll, handlerAll, noop, runIfFunc } from './function.mjs';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Dict, Length, Path, StringLiteral, Union } from './index.types.js';
1
+ export { Dict, Length, Path, Primitive, StringLiteral, Union } from './index.types.js';
2
2
  export { cast, isArray, isEmpty, isFunction, isNotNumber, isNull, isNumber, isNumeric, isObject, isString, isUndefined, isUnit } from './assertion.js';
3
3
  export { assignAfter, filterObject, filterUndefined, flattenObject, getMemoizedObject, getObject, keysFormObject, memoizeObject, merge, objectFromEntries, omitObject, pickObject, replaceObject, splitObject } from './object.js';
4
4
  export { funcAll, handlerAll, noop, runIfFunc } from './function.js';
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, overrideArray = false) => {
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 (overrideArray && isArray(sourceValue) && isArray(targetValue)) {
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, overrideArray);
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
@@ -50,7 +50,7 @@ import {
50
50
  useSafeLayoutEffect,
51
51
  useUnmountEffect,
52
52
  useUpdateEffect
53
- } from "./chunk-OL4TBQN7.mjs";
53
+ } from "./chunk-5OQGKXOK.mjs";
54
54
  import "./chunk-SLJ4M7XC.mjs";
55
55
  import {
56
56
  clampNumber,
@@ -8,4 +8,4 @@ type StringLiteral = string & {};
8
8
  type Union<T> = T | StringLiteral;
9
9
  type Length = string | 0 | number;
10
10
 
11
- export { Dict, Length, Path, StringLiteral, Union };
11
+ export { Dict, Length, Path, Primitive, StringLiteral, Union };
@@ -8,4 +8,4 @@ type StringLiteral = string & {};
8
8
  type Union<T> = T | StringLiteral;
9
9
  type Length = string | 0 | number;
10
10
 
11
- export { Dict, Length, Path, StringLiteral, Union };
11
+ export { Dict, Length, Path, Primitive, StringLiteral, Union };
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, overrideArray?: boolean) => T;
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, overrideArray?: boolean) => T;
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, overrideArray = false) => {
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 (overrideArray && isArray(sourceValue) && isArray(targetValue)) {
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, overrideArray);
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
@@ -13,7 +13,7 @@ import {
13
13
  pickObject,
14
14
  replaceObject,
15
15
  splitObject
16
- } from "./chunk-OL4TBQN7.mjs";
16
+ } from "./chunk-5OQGKXOK.mjs";
17
17
  import "./chunk-SLJ4M7XC.mjs";
18
18
  import "./chunk-VYMGBE25.mjs";
19
19
  import "./chunk-BZAW2D6U.mjs";
package/dist/react.mjs CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  useSafeLayoutEffect,
20
20
  useUnmountEffect,
21
21
  useUpdateEffect
22
- } from "./chunk-OL4TBQN7.mjs";
22
+ } from "./chunk-5OQGKXOK.mjs";
23
23
  import "./chunk-SLJ4M7XC.mjs";
24
24
  import "./chunk-VYMGBE25.mjs";
25
25
  import "./chunk-BZAW2D6U.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/utils",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Yamada UI utils",
5
5
  "keywords": [
6
6
  "utils",