@pandacss/shared
Advanced tools
Comparing version 0.0.0-dev-20230124104736 to 0.0.0-dev-20230125073613
@@ -1,3 +0,3 @@ | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-29274d16.js'; | ||
export { C as CreateCssContext, M as MappedObject, k as WalkObjectOptions, W as WalkObjectStopFn, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, n as mapObject, m as mergeProps, s as splitProps, t as toHash, l as walkObject, w as withoutImportant, j as withoutSpace } from './split-props-29274d16.js'; | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-6eb4eecb.js'; | ||
export { C as CreateCssContext, M as MappedObject, l as WalkObjectOptions, W as WalkObjectStopFn, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, k as hypenateProperty, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, o as mapObject, m as mergeProps, s as splitProps, t as toHash, n as walkObject, w as withoutImportant, j as withoutSpace } from './split-props-6eb4eecb.js'; | ||
@@ -4,0 +4,0 @@ type Operand = string | number | { |
@@ -36,2 +36,3 @@ "use strict"; | ||
getUnit: () => getUnit, | ||
hypenateProperty: () => hypenateProperty, | ||
isBaseCondition: () => isBaseCondition, | ||
@@ -210,2 +211,14 @@ isFunction: () => isFunction, | ||
const { utility, hash, conditions: conds = fallbackCondition } = context; | ||
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-"); | ||
const hashFn = (conditions, className) => { | ||
let result; | ||
if (hash) { | ||
const baseArray = [...conds.finalize(conditions), className]; | ||
result = formatClassName(toHash(baseArray.join(":"))); | ||
} else { | ||
const baseArray = [...conds.finalize(conditions), formatClassName(className)]; | ||
result = baseArray.join(":"); | ||
} | ||
return result; | ||
}; | ||
return (styleObject = {}) => { | ||
@@ -221,8 +234,5 @@ const normalizedObject = normalizeStyleObject(styleObject, context); | ||
const transformed = utility.transform(prop, withoutImportant(sanitize(value))); | ||
let transformedClassName = transformed.className; | ||
if (important) { | ||
transformedClassName = `${transformedClassName}!`; | ||
} | ||
const baseArray = [...conds.finalize(conditions), transformedClassName]; | ||
const className = hash ? toHash(baseArray.join(":")) : baseArray.join(":"); | ||
let className = hashFn(conditions, transformed.className); | ||
if (important) | ||
className = `${className}!`; | ||
classNames.add(className); | ||
@@ -360,2 +370,9 @@ }); | ||
// src/hypenate.ts | ||
var hypenateProperty = memo((property) => { | ||
if (property.startsWith("--")) | ||
return property; | ||
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); | ||
}); | ||
// src/split.ts | ||
@@ -461,2 +478,3 @@ function splitBy(value, separator = ",") { | ||
getUnit, | ||
hypenateProperty, | ||
isBaseCondition, | ||
@@ -463,0 +481,0 @@ isFunction, |
@@ -1,2 +0,2 @@ | ||
export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, f as isBaseCondition, b as isObject, n as mapObject, m as mergeProps, s as splitProps, t as toHash, l as walkObject, j as withoutSpace } from './split-props-29274d16.js'; | ||
export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, k as hypenateProperty, f as isBaseCondition, b as isObject, o as mapObject, m as mergeProps, s as splitProps, t as toHash, n as walkObject, j as withoutSpace } from './split-props-6eb4eecb.js'; | ||
@@ -3,0 +3,0 @@ declare function normalizeHTMLProps(props: Record<string, any>): { |
@@ -27,2 +27,3 @@ "use strict"; | ||
filterBaseConditions: () => filterBaseConditions, | ||
hypenateProperty: () => hypenateProperty, | ||
isBaseCondition: () => isBaseCondition, | ||
@@ -161,2 +162,14 @@ isObject: () => isObject, | ||
const { utility, hash, conditions: conds = fallbackCondition } = context; | ||
const formatClassName = (str) => [utility.prefix, str].filter(Boolean).join("-"); | ||
const hashFn = (conditions, className) => { | ||
let result; | ||
if (hash) { | ||
const baseArray = [...conds.finalize(conditions), className]; | ||
result = formatClassName(toHash(baseArray.join(":"))); | ||
} else { | ||
const baseArray = [...conds.finalize(conditions), formatClassName(className)]; | ||
result = baseArray.join(":"); | ||
} | ||
return result; | ||
}; | ||
return (styleObject = {}) => { | ||
@@ -172,8 +185,5 @@ const normalizedObject = normalizeStyleObject(styleObject, context); | ||
const transformed = utility.transform(prop, withoutImportant(sanitize(value))); | ||
let transformedClassName = transformed.className; | ||
if (important) { | ||
transformedClassName = `${transformedClassName}!`; | ||
} | ||
const baseArray = [...conds.finalize(conditions), transformedClassName]; | ||
const className = hash ? toHash(baseArray.join(":")) : baseArray.join(":"); | ||
let className = hashFn(conditions, transformed.className); | ||
if (important) | ||
className = `${className}!`; | ||
classNames.add(className); | ||
@@ -231,2 +241,24 @@ }); | ||
} | ||
// src/memo.ts | ||
var memo = (fn) => { | ||
const cache = /* @__PURE__ */ new Map(); | ||
const get = (...args) => { | ||
const key = JSON.stringify(args); | ||
if (cache.has(key)) { | ||
return cache.get(key); | ||
} | ||
const result = fn(...args); | ||
cache.set(key, result); | ||
return result; | ||
}; | ||
return get; | ||
}; | ||
// src/hypenate.ts | ||
var hypenateProperty = memo((property) => { | ||
if (property.startsWith("--")) | ||
return property; | ||
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); | ||
}); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -238,2 +270,3 @@ 0 && (module.exports = { | ||
filterBaseConditions, | ||
hypenateProperty, | ||
isBaseCondition, | ||
@@ -240,0 +273,0 @@ isObject, |
{ | ||
"name": "@pandacss/shared", | ||
"version": "0.0.0-dev-20230124104736", | ||
"version": "0.0.0-dev-20230125073613", | ||
"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
47752
1486