@pandacss/shared
Advanced tools
Comparing version 0.0.0-dev-20230117105201 to 0.0.0-dev-20230118102146
@@ -1,9 +0,4 @@ | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './hash-95bc50e7.js'; | ||
export { C as CreateCssContext, M as MappedObject, e as WalkObjectOptions, W as WalkObjectStopFn, a as compact, c as createCss, f as filterBaseConditions, i as isBaseCondition, b as isImportant, m as mapObject, t as toHash, g as walkObject, w as withoutImportant, d as withoutSpace } from './hash-95bc50e7.js'; | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './merge-e05e5f23.js'; | ||
export { C as CreateCssContext, M as MappedObject, k as WalkObjectOptions, W as WalkObjectStopFn, d as compact, c as createCss, j as deepMerge, f as filterBaseConditions, e as isBaseCondition, a as isFunction, g as isImportant, b as isObject, i as isString, m as mapObject, t as toHash, l as walkObject, w as withoutImportant, h as withoutSpace } from './merge-e05e5f23.js'; | ||
declare const isString: (v: any) => v is string; | ||
type AnyFunction = (...args: any[]) => any; | ||
declare const isFunction: (v: any) => v is AnyFunction; | ||
declare function isObject(value: any): value is Record<string, any>; | ||
type Operand = string | number | { | ||
@@ -60,2 +55,2 @@ ref: string; | ||
export { CssVar, CssVarOptions, calc, capitalize, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, isFunction, isObject, isString, mapToJson, memo, normalizeStyleObject, splitBy, splitDotPath, splitObject, toEm, toPx, toRem, uncapitalize, unionType }; | ||
export { CssVar, CssVarOptions, calc, capitalize, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, memo, normalizeStyleObject, splitBy, splitDotPath, splitObject, toEm, toPx, toRem, uncapitalize, unionType }; |
@@ -29,2 +29,3 @@ "use strict"; | ||
dashCase: () => dashCase, | ||
deepMerge: () => deepMerge, | ||
esc: () => esc2, | ||
@@ -64,3 +65,3 @@ filterBaseConditions: () => filterBaseConditions, | ||
function isObject(value) { | ||
return typeof value === "object" && value !== null && !Array.isArray(value); | ||
return typeof value === "object" && value != null && !Array.isArray(value); | ||
} | ||
@@ -327,2 +328,21 @@ | ||
// src/merge.ts | ||
function deepMerge(...sources) { | ||
const allSources = sources.filter(isObject); | ||
if (allSources.length === 1) { | ||
return allSources[0]; | ||
} | ||
const result = {}; | ||
for (const source of allSources) { | ||
for (const [key, value] of Object.entries(source)) { | ||
if (isObject(value)) { | ||
result[key] = deepMerge(result[key] || {}, value); | ||
} else { | ||
result[key] = value; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
// src/split.ts | ||
@@ -416,2 +436,3 @@ function splitBy(value, separator = ",") { | ||
dashCase, | ||
deepMerge, | ||
esc, | ||
@@ -418,0 +439,0 @@ filterBaseConditions, |
@@ -1,1 +0,1 @@ | ||
export { C as CreateCssContext, M as MappedObject, e as WalkObjectOptions, W as WalkObjectStopFn, a as compact, c as createCss, f as filterBaseConditions, i as isBaseCondition, m as mapObject, t as toHash, g as walkObject, d as withoutSpace } from './hash-95bc50e7.js'; | ||
export { d as compact, c as createCss, j as deepMerge, f as filterBaseConditions, e as isBaseCondition, b as isObject, m as mapObject, t as toHash, l as walkObject, h as withoutSpace } from './merge-e05e5f23.js'; |
@@ -25,4 +25,6 @@ "use strict"; | ||
createCss: () => createCss, | ||
deepMerge: () => deepMerge, | ||
filterBaseConditions: () => filterBaseConditions, | ||
isBaseCondition: () => isBaseCondition, | ||
isObject: () => isObject, | ||
mapObject: () => mapObject, | ||
@@ -35,2 +37,7 @@ toHash: () => toHash, | ||
// src/assert.ts | ||
function isObject(value) { | ||
return typeof value === "object" && value != null && !Array.isArray(value); | ||
} | ||
// src/condition.ts | ||
@@ -74,7 +81,2 @@ var isBaseCondition = (v) => v === "base"; | ||
// src/assert.ts | ||
function isObject(value) { | ||
return typeof value === "object" && value !== null && !Array.isArray(value); | ||
} | ||
// src/walk-object.ts | ||
@@ -168,2 +170,21 @@ function walkObject(target, predicate, options = {}) { | ||
} | ||
// src/merge.ts | ||
function deepMerge(...sources) { | ||
const allSources = sources.filter(isObject); | ||
if (allSources.length === 1) { | ||
return allSources[0]; | ||
} | ||
const result = {}; | ||
for (const source of allSources) { | ||
for (const [key, value] of Object.entries(source)) { | ||
if (isObject(value)) { | ||
result[key] = deepMerge(result[key] || {}, value); | ||
} else { | ||
result[key] = value; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -173,4 +194,6 @@ 0 && (module.exports = { | ||
createCss, | ||
deepMerge, | ||
filterBaseConditions, | ||
isBaseCondition, | ||
isObject, | ||
mapObject, | ||
@@ -177,0 +200,0 @@ toHash, |
{ | ||
"name": "@pandacss/shared", | ||
"version": "0.0.0-dev-20230117105201", | ||
"version": "0.0.0-dev-20230118102146", | ||
"description": "Shared utilities for css panda", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
39571
1257