@yamada-ui/utils
Advanced tools
Comparing version 0.3.0 to 0.3.1
import { Dict } from './index.types.js'; | ||
type ColorMode = 'light' | 'dark'; | ||
declare const hues: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950]; | ||
declare const isGray: (colorScheme: string) => boolean; | ||
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: 'light' | 'dark') => string; | ||
declare const getColor: (color: string, fallback?: string) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const lightenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const darkenColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const tintColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const shadeColor: (color: string, amount: number) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const transparentizeColor: (color: string, alpha: number) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const toneColor: (color: string, hue: (typeof hues)[number]) => (theme?: Dict, colorMode?: ColorMode) => string; | ||
declare const randomColor: ({ string, colors, }?: { | ||
@@ -16,6 +17,6 @@ string?: string | undefined; | ||
}) => string; | ||
declare const isTone: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => "light" | "dark"; | ||
declare const isLight: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean; | ||
declare const isDark: (color: string) => (theme?: Dict, colorMode?: 'light' | 'dark') => boolean; | ||
declare const isTone: (color: string) => (theme?: Dict, colorMode?: ColorMode) => "light" | "dark"; | ||
declare const isLight: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean; | ||
declare const isDark: (color: string) => (theme?: Dict, colorMode?: ColorMode) => boolean; | ||
export { darkenColor, getColor, hues, isDark, isGray, isLight, isTone, lightenColor, randomColor, shadeColor, tintColor, toneColor, transparentizeColor }; |
@@ -196,3 +196,3 @@ "use strict"; | ||
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0); | ||
var merge = (target, source, overrideArray = false) => { | ||
var merge = (target, source, mergeArray = false) => { | ||
let result = Object.assign({}, target); | ||
@@ -203,6 +203,6 @@ if (isObject(source)) { | ||
const targetValue = target[sourceKey]; | ||
if (overrideArray && isArray(sourceValue) && isArray(targetValue)) { | ||
if (mergeArray && isArray(sourceValue) && isArray(targetValue)) { | ||
result[sourceKey] = targetValue.concat(...sourceValue); | ||
} else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) { | ||
result[sourceKey] = merge(targetValue, sourceValue, overrideArray); | ||
result[sourceKey] = merge(targetValue, sourceValue, mergeArray); | ||
} else { | ||
@@ -218,8 +218,8 @@ Object.assign(result, { [sourceKey]: sourceValue }); | ||
}; | ||
var flattenObject = (obj, maxDepth = Infinity) => { | ||
var flattenObject = (obj, maxDepth = Infinity, omitKeys = []) => { | ||
if (!isObject(obj) && !isArray(obj) || !maxDepth) | ||
return obj; | ||
return Object.entries(obj).reduce((result, [key, value]) => { | ||
if (isObject(value)) { | ||
Object.entries(flattenObject(value, maxDepth - 1)).forEach( | ||
if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2))) { | ||
Object.entries(flattenObject(value, maxDepth - 1, omitKeys)).forEach( | ||
([childKey, childValue]) => { | ||
@@ -226,0 +226,0 @@ result[`${key}.${childKey}`] = childValue; |
@@ -8,4 +8,4 @@ import { Dict } from './index.types.js'; | ||
declare const filterUndefined: <T extends Dict>(obj: T) => T; | ||
declare const merge: <T extends Dict>(target: any, source: any, overrideArray?: boolean) => T; | ||
declare const flattenObject: <T extends Dict>(obj: any, maxDepth?: number) => T; | ||
declare const merge: <T extends Dict>(target: any, source: any, mergeArray?: boolean) => T; | ||
declare const flattenObject: <T extends Dict>(obj: any, maxDepth?: number, omitKeys?: string[]) => T; | ||
declare const objectFromEntries: <T extends Dict>(entries: any[][]) => T; | ||
@@ -12,0 +12,0 @@ declare const keysFormObject: <T extends Dict>(obj: T) => (keyof T)[]; |
@@ -85,3 +85,3 @@ "use strict"; | ||
var filterUndefined = (obj) => filterObject(obj, (_, val) => val !== null && val !== void 0); | ||
var merge = (target, source, overrideArray = false) => { | ||
var merge = (target, source, mergeArray = false) => { | ||
let result = Object.assign({}, target); | ||
@@ -92,6 +92,6 @@ if (isObject(source)) { | ||
const targetValue = target[sourceKey]; | ||
if (overrideArray && isArray(sourceValue) && isArray(targetValue)) { | ||
if (mergeArray && isArray(sourceValue) && isArray(targetValue)) { | ||
result[sourceKey] = targetValue.concat(...sourceValue); | ||
} else if (!isFunction(sourceValue) && isObject(sourceValue) && target.hasOwnProperty(sourceKey)) { | ||
result[sourceKey] = merge(targetValue, sourceValue, overrideArray); | ||
result[sourceKey] = merge(targetValue, sourceValue, mergeArray); | ||
} else { | ||
@@ -107,8 +107,8 @@ Object.assign(result, { [sourceKey]: sourceValue }); | ||
}; | ||
var flattenObject = (obj, maxDepth = Infinity) => { | ||
var flattenObject = (obj, maxDepth = Infinity, omitKeys = []) => { | ||
if (!isObject(obj) && !isArray(obj) || !maxDepth) | ||
return obj; | ||
return Object.entries(obj).reduce((result, [key, value]) => { | ||
if (isObject(value)) { | ||
Object.entries(flattenObject(value, maxDepth - 1)).forEach( | ||
if (isObject(value) && !Object.keys(value).some((key2) => omitKeys.includes(key2))) { | ||
Object.entries(flattenObject(value, maxDepth - 1, omitKeys)).forEach( | ||
([childKey, childValue]) => { | ||
@@ -115,0 +115,0 @@ result[`${key}.${childKey}`] = childValue; |
{ | ||
"name": "@yamada-ui/utils", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Yamada UI utils", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137231
3599