@pandacss/shared
Advanced tools
Comparing version 0.0.0-dev-20221126091729 to 0.0.0-dev-20221126121755
@@ -1,3 +0,3 @@ | ||
import { W as WalkObjectStopFn } from './walk-styles-622088f0.js'; | ||
export { M as MappedObject, d as WalkObjectOptions, W as WalkObjectStopFn, c as createCss, f as filterBaseConditions, i as isBaseCondition, a as isImportant, m as mapObject, t as toHash, e as walkObject, g as walkStyles, w as withoutImportant, b as withoutSpace } from './walk-styles-622088f0.js'; | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './walk-styles-4fcd344a.js'; | ||
export { C as CreateCssContext, M as MappedObject, d as WalkObjectOptions, W as WalkObjectStopFn, c as createCss, f as filterBaseConditions, i as isBaseCondition, a as isImportant, m as mapObject, t as toHash, e as walkObject, g as walkStyles, w as withoutImportant, b as withoutSpace } from './walk-styles-4fcd344a.js'; | ||
@@ -43,2 +43,5 @@ declare const isString: (v: any) => v is string; | ||
type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>; | ||
declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>; | ||
declare function splitBy(value: string, separator?: string): string[]; | ||
@@ -56,2 +59,2 @@ declare function splitDotPath(path: string): string[]; | ||
export { CssVar, CssVarOptions, calc, capitalize, compact, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, isFunction, isObject, isString, mapToJson, memo, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType }; | ||
export { CssVar, CssVarOptions, calc, capitalize, compact, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, isFunction, isObject, isString, mapToJson, memo, normalizeStyleObject, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType }; |
@@ -43,2 +43,3 @@ "use strict"; | ||
memo: () => memo, | ||
normalizeStyleObject: () => normalizeStyleObject, | ||
splitBy: () => splitBy, | ||
@@ -178,13 +179,39 @@ splitDotPath: () => splitDotPath, | ||
// src/normalize-style-object.ts | ||
function toResponsiveObject(values, breakpoints) { | ||
return values.reduce((acc, current, index) => { | ||
const key = breakpoints[index]; | ||
if (current != null) { | ||
acc[key] = current; | ||
} | ||
return acc; | ||
}, {}); | ||
} | ||
function normalizeStyleObject(styles, context) { | ||
const { utility, conditions } = context; | ||
const { hasShorthand, resolveShorthand } = utility; | ||
return walkObject( | ||
styles, | ||
(value) => { | ||
return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value; | ||
}, | ||
{ | ||
stop: (value) => Array.isArray(value), | ||
getKey: (prop) => { | ||
return hasShorthand ? resolveShorthand(prop) : prop; | ||
} | ||
} | ||
); | ||
} | ||
// src/classname.ts | ||
var fallbackCondition = { | ||
shift: (v) => v, | ||
finalize: (v) => v, | ||
breakpoints: { keys: [] } | ||
}; | ||
function createCss(context) { | ||
const { | ||
transform, | ||
hash, | ||
conditions: conds = { shift: (v) => v, finalize: (v) => v }, | ||
resolveShorthand, | ||
hasShorthand | ||
} = context; | ||
const { utility, hash, conditions: conds = fallbackCondition } = context; | ||
return (styleObject) => { | ||
const normalizedObject = hasShorthand ? walkObject(styleObject, (v) => v, { getKey: resolveShorthand }) : styleObject; | ||
const normalizedObject = normalizeStyleObject(styleObject, context); | ||
const classNames = /* @__PURE__ */ new Set(); | ||
@@ -198,3 +225,3 @@ walkStyles(normalizedObject, (props, scope) => { | ||
const conditions = filterBaseConditions(allConditions); | ||
const transformed = transform(prop, withoutImportant(value)); | ||
const transformed = utility.transform(prop, withoutImportant(value)); | ||
let transformedClassName = transformed.className; | ||
@@ -417,2 +444,3 @@ if (important) { | ||
memo, | ||
normalizeStyleObject, | ||
splitBy, | ||
@@ -419,0 +447,0 @@ splitDotPath, |
@@ -1,1 +0,1 @@ | ||
export { M as MappedObject, d as WalkObjectOptions, W as WalkObjectStopFn, c as createCss, f as filterBaseConditions, i as isBaseCondition, m as mapObject, t as toHash, e as walkObject, g as walkStyles, b as withoutSpace } from './walk-styles-622088f0.js'; | ||
export { C as CreateCssContext, M as MappedObject, d as WalkObjectOptions, W as WalkObjectStopFn, c as createCss, f as filterBaseConditions, i as isBaseCondition, m as mapObject, t as toHash, e as walkObject, g as walkStyles, b as withoutSpace } from './walk-styles-4fcd344a.js'; |
@@ -127,13 +127,39 @@ "use strict"; | ||
// src/normalize-style-object.ts | ||
function toResponsiveObject(values, breakpoints) { | ||
return values.reduce((acc, current, index) => { | ||
const key = breakpoints[index]; | ||
if (current != null) { | ||
acc[key] = current; | ||
} | ||
return acc; | ||
}, {}); | ||
} | ||
function normalizeStyleObject(styles, context) { | ||
const { utility, conditions } = context; | ||
const { hasShorthand, resolveShorthand } = utility; | ||
return walkObject( | ||
styles, | ||
(value) => { | ||
return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value; | ||
}, | ||
{ | ||
stop: (value) => Array.isArray(value), | ||
getKey: (prop) => { | ||
return hasShorthand ? resolveShorthand(prop) : prop; | ||
} | ||
} | ||
); | ||
} | ||
// src/classname.ts | ||
var fallbackCondition = { | ||
shift: (v) => v, | ||
finalize: (v) => v, | ||
breakpoints: { keys: [] } | ||
}; | ||
function createCss(context) { | ||
const { | ||
transform, | ||
hash, | ||
conditions: conds = { shift: (v) => v, finalize: (v) => v }, | ||
resolveShorthand, | ||
hasShorthand | ||
} = context; | ||
const { utility, hash, conditions: conds = fallbackCondition } = context; | ||
return (styleObject) => { | ||
const normalizedObject = hasShorthand ? walkObject(styleObject, (v) => v, { getKey: resolveShorthand }) : styleObject; | ||
const normalizedObject = normalizeStyleObject(styleObject, context); | ||
const classNames = /* @__PURE__ */ new Set(); | ||
@@ -147,3 +173,3 @@ walkStyles(normalizedObject, (props, scope) => { | ||
const conditions = filterBaseConditions(allConditions); | ||
const transformed = transform(prop, withoutImportant(value)); | ||
const transformed = utility.transform(prop, withoutImportant(value)); | ||
let transformedClassName = transformed.className; | ||
@@ -150,0 +176,0 @@ if (important) { |
{ | ||
"name": "@pandacss/shared", | ||
"version": "0.0.0-dev-20221126091729", | ||
"version": "0.0.0-dev-20221126121755", | ||
"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
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
40752
1247