@pandacss/shared
Advanced tools
Comparing version 0.29.1 to 0.30.0
@@ -1,3 +0,3 @@ | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-bFj3Wgxk.js'; | ||
export { x as WalkObjectOptions, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, a as isBoolean, b as isFunction, j as isImportant, c as isObject, i as isString, z as mapObject, m as markImportant, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, w as withoutImportant, k as withoutSpace } from './shared-bFj3Wgxk.js'; | ||
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-z3agWt4M.js'; | ||
export { x as WalkObjectOptions, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, a as isBoolean, b as isFunction, j as isImportant, c as isObject, i as isString, z as mapObject, m as markImportant, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, w as withoutImportant, k as withoutSpace } from './shared-z3agWt4M.js'; | ||
export { astish } from './astish.js'; | ||
@@ -74,3 +74,2 @@ | ||
declare function toResponsiveObject(values: string[], breakpoints: string[]): Record<string, string>; | ||
declare function normalizeShorthand(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>; | ||
declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext, shorthand?: boolean): MappedObject<Record<string, any>, any>; | ||
@@ -109,2 +108,2 @@ | ||
export { CreateCssContext, type CssVar, type CssVarOptions, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, normalizeShorthand, normalizeStyleObject, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType }; | ||
export { CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, normalizeStyleObject, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType }; |
@@ -65,3 +65,2 @@ "use strict"; | ||
mergeProps: () => mergeProps, | ||
normalizeShorthand: () => normalizeShorthand, | ||
normalizeStyleObject: () => normalizeStyleObject, | ||
@@ -206,2 +205,23 @@ parseJson: () => parseJson, | ||
// src/hash.ts | ||
function toChar(code) { | ||
return String.fromCharCode(code + (code > 25 ? 39 : 97)); | ||
} | ||
function toName(code) { | ||
let name = ""; | ||
let x; | ||
for (x = Math.abs(code); x > 52; x = x / 52 | 0) | ||
name = toChar(x % 52) + name; | ||
return toChar(x % 52) + name; | ||
} | ||
function toPhash(h, x) { | ||
let i = x.length; | ||
while (i) | ||
h = h * 33 ^ x.charCodeAt(--i); | ||
return h; | ||
} | ||
function toHash(value) { | ||
return toName(toPhash(5381, value) >>> 0); | ||
} | ||
// src/important.ts | ||
@@ -241,23 +261,2 @@ var importantRegex = /\s*!(important)?/i; | ||
// src/hash.ts | ||
function toChar(code) { | ||
return String.fromCharCode(code + (code > 25 ? 39 : 97)); | ||
} | ||
function toName(code) { | ||
let name = ""; | ||
let x; | ||
for (x = Math.abs(code); x > 52; x = x / 52 | 0) | ||
name = toChar(x % 52) + name; | ||
return toChar(x % 52) + name; | ||
} | ||
function toPhash(h, x) { | ||
let i = x.length; | ||
while (i) | ||
h = h * 33 ^ x.charCodeAt(--i); | ||
return h; | ||
} | ||
function toHash(value) { | ||
return toName(toPhash(5381, value) >>> 0); | ||
} | ||
// src/merge-props.ts | ||
@@ -288,3 +287,3 @@ function mergeProps(...sources) { | ||
for (const [prop, child] of Object.entries(value)) { | ||
const key = getKey?.(prop) ?? prop; | ||
const key = getKey?.(prop, child) ?? prop; | ||
const childPath = [...path, key]; | ||
@@ -323,10 +322,2 @@ if (stop?.(value, childPath)) { | ||
} | ||
function normalizeShorthand(styles, context) { | ||
const { hasShorthand, resolveShorthand } = context.utility; | ||
return walkObject(styles, (v) => v, { | ||
getKey: (prop) => { | ||
return hasShorthand ? resolveShorthand(prop) : prop; | ||
} | ||
}); | ||
} | ||
function normalizeStyleObject(styles, context, shorthand = true) { | ||
@@ -361,3 +352,3 @@ const { utility, conditions } = context; | ||
const baseArray = [...conds.finalize(conditions), className]; | ||
result = formatClassName(toHash(baseArray.join(":"))); | ||
result = formatClassName(utility.toHash(baseArray, toHash)); | ||
} else { | ||
@@ -395,3 +386,3 @@ const baseArray = [...conds.finalize(conditions), formatClassName(className)]; | ||
return allStyles; | ||
return allStyles.map((style) => normalizeShorthand(style, context)); | ||
return allStyles.map((style) => normalizeStyleObject(style, context)); | ||
} | ||
@@ -820,3 +811,2 @@ function mergeCss(...styles) { | ||
mergeProps, | ||
normalizeShorthand, | ||
normalizeStyleObject, | ||
@@ -823,0 +813,0 @@ parseJson, |
@@ -1,1 +0,1 @@ | ||
export { f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, c as isObject, z as mapObject, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, k as withoutSpace } from './shared-bFj3Wgxk.js'; | ||
export { f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, c as isObject, z as mapObject, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, k as withoutSpace } from './shared-z3agWt4M.js'; |
@@ -61,14 +61,2 @@ "use strict"; | ||
// src/important.ts | ||
var importantRegex = /\s*!(important)?/i; | ||
function isImportant(value) { | ||
return typeof value === "string" ? importantRegex.test(value) : false; | ||
} | ||
function withoutImportant(value) { | ||
return typeof value === "string" ? value.replace(importantRegex, "").trim() : value; | ||
} | ||
function withoutSpace(str) { | ||
return typeof str === "string" ? str.replaceAll(" ", "_") : str; | ||
} | ||
// src/hash.ts | ||
@@ -95,2 +83,29 @@ function toChar(code) { | ||
// src/important.ts | ||
var importantRegex = /\s*!(important)?/i; | ||
function isImportant(value) { | ||
return typeof value === "string" ? importantRegex.test(value) : false; | ||
} | ||
function withoutImportant(value) { | ||
return typeof value === "string" ? value.replace(importantRegex, "").trim() : value; | ||
} | ||
function withoutSpace(str) { | ||
return typeof str === "string" ? str.replaceAll(" ", "_") : str; | ||
} | ||
// 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/merge-props.ts | ||
@@ -113,17 +128,2 @@ function mergeProps(...sources) { | ||
// 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/walk-object.ts | ||
@@ -137,3 +137,3 @@ var isNotNullish = (element) => element != null; | ||
for (const [prop, child] of Object.entries(value)) { | ||
const key = getKey?.(prop) ?? prop; | ||
const key = getKey?.(prop, child) ?? prop; | ||
const childPath = [...path, key]; | ||
@@ -172,10 +172,2 @@ if (stop?.(value, childPath)) { | ||
} | ||
function normalizeShorthand(styles, context) { | ||
const { hasShorthand, resolveShorthand } = context.utility; | ||
return walkObject(styles, (v) => v, { | ||
getKey: (prop) => { | ||
return hasShorthand ? resolveShorthand(prop) : prop; | ||
} | ||
}); | ||
} | ||
function normalizeStyleObject(styles, context, shorthand = true) { | ||
@@ -210,3 +202,3 @@ const { utility, conditions } = context; | ||
const baseArray = [...conds.finalize(conditions), className]; | ||
result = formatClassName(toHash(baseArray.join(":"))); | ||
result = formatClassName(utility.toHash(baseArray, toHash)); | ||
} else { | ||
@@ -244,3 +236,3 @@ const baseArray = [...conds.finalize(conditions), formatClassName(className)]; | ||
return allStyles; | ||
return allStyles.map((style) => normalizeShorthand(style, context)); | ||
return allStyles.map((style) => normalizeStyleObject(style, context)); | ||
} | ||
@@ -247,0 +239,0 @@ function mergeCss(...styles) { |
{ | ||
"name": "@pandacss/shared", | ||
"version": "0.29.1", | ||
"version": "0.30.0", | ||
"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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
89544
2386