@pandacss/core
Advanced tools
Comparing version 0.0.0-dev-20221126091729 to 0.0.0-dev-20221126121755
@@ -18,2 +18,3 @@ import { RawCondition, Dict, UtilityConfig, PropertyConfig, TransformHelpers, CssKeyframes, RecipeConfig } from '@pandacss/types'; | ||
}; | ||
get keys(): string[]; | ||
get: (name: string) => { | ||
@@ -90,3 +91,3 @@ name: string; | ||
constructor(options: UtilityOptions); | ||
register(property: string, config: PropertyConfig): void; | ||
register: (property: string, config: PropertyConfig) => void; | ||
private assignShorthands; | ||
@@ -97,3 +98,3 @@ private assignPaletteProperty; | ||
get isEmpty(): boolean; | ||
entries(): [string, string][]; | ||
entries: () => [string, string][]; | ||
private getPropKey; | ||
@@ -105,7 +106,7 @@ private hash; | ||
private getPropertyValues; | ||
getToken(path: string): any; | ||
getToken: (path: string) => any; | ||
/** | ||
* Normalize the property config | ||
*/ | ||
normalize(value: PropertyConfig | undefined): PropertyConfig | undefined; | ||
normalize: (value: PropertyConfig | undefined) => PropertyConfig | undefined; | ||
private assignProperty; | ||
@@ -118,3 +119,3 @@ private assignProperties; | ||
*/ | ||
getTypes(): Map<string, string[]>; | ||
getTypes: () => Map<string, string[]>; | ||
defaultTransform: (value: string, prop: string) => { | ||
@@ -141,7 +142,7 @@ [x: string]: string; | ||
*/ | ||
resolve(prop: string, value: string | undefined): TransformResult; | ||
transform: (prop: string, value: string | undefined) => TransformResult; | ||
/** | ||
* All keys including shorthand keys | ||
*/ | ||
keys(): string[]; | ||
keys: () => string[]; | ||
} | ||
@@ -158,8 +159,5 @@ | ||
conditions: Conditions; | ||
breakpoints: Record<string, string>; | ||
helpers: TransformHelpers; | ||
hasShorthand: boolean; | ||
resolveShorthand: (prop: string) => string; | ||
transform: (prop: string, value: string) => TransformResult; | ||
hash?: boolean; | ||
transform?: (prop: string, value: any) => TransformResult; | ||
}; | ||
@@ -188,2 +186,3 @@ | ||
values: Record<string, RawCondition>; | ||
breakpoints: Breakpoints; | ||
constructor(options: Options); | ||
@@ -190,0 +189,0 @@ finalize: (paths: string[]) => string[]; |
@@ -55,2 +55,5 @@ "use strict"; | ||
} | ||
get keys() { | ||
return ["base", ...Object.keys(this.values)]; | ||
} | ||
get = (name) => { | ||
@@ -374,3 +377,3 @@ return this.values[name]; | ||
const hasConditions = conds.length > 0; | ||
let { styles } = utility.resolve(prop, (0, import_shared2.withoutImportant)(value)); | ||
let { styles } = utility.transform(prop, (0, import_shared2.withoutImportant)(value)); | ||
const cssResult = toCss(styles, { important }); | ||
@@ -503,11 +506,13 @@ if (hasConditions) { | ||
this.options = options; | ||
const { breakpoints = {}, conditions } = this.options; | ||
const instance = new Breakpoints(breakpoints); | ||
const { breakpoints: breakpointValues = {}, conditions } = this.options; | ||
const breakpoints = new Breakpoints(breakpointValues); | ||
this.breakpoints = breakpoints; | ||
const entries = Object.entries(conditions).map(([key, value]) => [key, parseCondition(value)]); | ||
this.values = { | ||
...Object.fromEntries(entries), | ||
...instance.conditions | ||
...breakpoints.conditions | ||
}; | ||
} | ||
values; | ||
breakpoints; | ||
finalize = (paths) => { | ||
@@ -707,3 +712,3 @@ return paths.map((path) => { | ||
// src/recipe.ts | ||
var import_shared6 = require("@pandacss/shared"); | ||
var import_shared7 = require("@pandacss/shared"); | ||
var import_lodash2 = __toESM(require("lodash.merge")); | ||
@@ -714,2 +719,3 @@ | ||
var import_postcss8 = __toESM(require("postcss")); | ||
var import_shared6 = require("@pandacss/shared"); | ||
var AtomicRule = class { | ||
@@ -728,8 +734,9 @@ constructor(context) { | ||
} | ||
get transform() { | ||
return this.context?.transform ?? this.context.utility.transform; | ||
} | ||
process = (options) => { | ||
const { scope, styles } = options; | ||
const { utility, conditions: cond } = this.context; | ||
const styleObject = utility.hasShorthand ? (0, import_shared5.walkObject)(styles, (v) => v, { | ||
getKey: (prop) => utility.resolveShorthand(prop) | ||
}) : styles; | ||
const { conditions: cond } = this.context; | ||
const styleObject = (0, import_shared6.normalizeStyleObject)(styles, this.context); | ||
const rule = this.rule; | ||
@@ -742,3 +749,3 @@ (0, import_shared5.walkObject)(styleObject, (value, paths) => { | ||
const conditions = (0, import_shared5.filterBaseConditions)(allConditions); | ||
const transformed = this.context.transform(prop, (0, import_shared5.withoutImportant)(value)); | ||
const transformed = this.transform(prop, (0, import_shared5.withoutImportant)(value)); | ||
const cssRoot = toCss(transformed.styles, { important }); | ||
@@ -821,3 +828,3 @@ rule.nodes = cssRoot.root.nodes; | ||
const transformed = {}; | ||
(0, import_shared6.walkStyles)(styleObject, (styles, scopes) => { | ||
(0, import_shared7.walkStyles)(styleObject, (styles, scopes) => { | ||
const [selector] = scopes || []; | ||
@@ -852,4 +859,6 @@ const result = {}; | ||
const { name, defaultVariants = {} } = this.config; | ||
const ctx = { ...this.context, transform: this.transform }; | ||
const rule = new AtomicRule(ctx); | ||
const rule = new AtomicRule({ | ||
...this.context, | ||
transform: this.transform | ||
}); | ||
rule.layer = "recipes"; | ||
@@ -870,3 +879,3 @@ rule.process({ | ||
// src/stylesheet.ts | ||
var import_shared7 = require("@pandacss/shared"); | ||
var import_shared8 = require("@pandacss/shared"); | ||
var import_postcss9 = __toESM(require("postcss")); | ||
@@ -909,3 +918,3 @@ var Stylesheet = class { | ||
const ruleset = new AtomicRule(this.context); | ||
(0, import_shared7.walkStyles)(styleObject, (styles, scope) => { | ||
(0, import_shared8.walkStyles)(styleObject, (styles, scope) => { | ||
ruleset.process({ scope, styles }); | ||
@@ -919,4 +928,6 @@ }); | ||
toCss = ({ optimize = true, minify } = {}) => { | ||
const breakpoint = new Breakpoints(this.context.breakpoints); | ||
breakpoint.expandScreenAtRule(this.context.root); | ||
const { | ||
conditions: { breakpoints } | ||
} = this.context; | ||
breakpoints.expandScreenAtRule(this.context.root); | ||
let css = this.context.root.toString(); | ||
@@ -942,3 +953,3 @@ if (optimize) { | ||
// src/utility.ts | ||
var import_shared8 = require("@pandacss/shared"); | ||
var import_shared9 = require("@pandacss/shared"); | ||
var Utility = class { | ||
@@ -967,8 +978,8 @@ tokens; | ||
} | ||
register(property, config) { | ||
register = (property, config) => { | ||
this.assignProperty(property, config); | ||
this.assignPropertyType(property, config); | ||
this.config[property] = config; | ||
} | ||
assignShorthands() { | ||
}; | ||
assignShorthands = () => { | ||
for (const [property, config] of Object.entries(this.config)) { | ||
@@ -980,4 +991,4 @@ const { shorthand } = this.normalize(config) ?? {}; | ||
} | ||
} | ||
assignPaletteProperty() { | ||
}; | ||
assignPaletteProperty = () => { | ||
const values = this.tokens.palettes; | ||
@@ -990,3 +1001,3 @@ this.config.palette = { | ||
}; | ||
} | ||
}; | ||
resolveShorthand = (prop) => { | ||
@@ -1001,15 +1012,15 @@ return this.shorthands.get(prop) ?? prop; | ||
} | ||
entries() { | ||
entries = () => { | ||
const value = Object.entries(this.config).filter(([, value2]) => !!value2?.className).map(([key, value2]) => [key, value2.className]); | ||
return value; | ||
} | ||
getPropKey(prop, value) { | ||
}; | ||
getPropKey = (prop, value) => { | ||
return `(${prop} = ${value})`; | ||
} | ||
hash(prop, value) { | ||
}; | ||
hash = (prop, value) => { | ||
return `${prop}${this.separator}${value}`; | ||
} | ||
getPropertyValues(config) { | ||
}; | ||
getPropertyValues = (config) => { | ||
const { values } = config; | ||
if ((0, import_shared8.isString)(values)) { | ||
if ((0, import_shared9.isString)(values)) { | ||
return this.tokens.getValue(values) ?? {}; | ||
@@ -1023,14 +1034,14 @@ } | ||
} | ||
if ((0, import_shared8.isFunction)(values)) { | ||
if ((0, import_shared9.isFunction)(values)) { | ||
return values(this.getToken.bind(this)); | ||
} | ||
return values; | ||
} | ||
getToken(path) { | ||
}; | ||
getToken = (path) => { | ||
return this.tokens.get(path); | ||
} | ||
normalize(value) { | ||
}; | ||
normalize = (value) => { | ||
return value; | ||
} | ||
assignProperty(property, propertyConfig) { | ||
}; | ||
assignProperty = (property, propertyConfig) => { | ||
const config = this.normalize(propertyConfig); | ||
@@ -1049,4 +1060,4 @@ this.setTransform(property, config?.transform); | ||
} | ||
} | ||
assignProperties() { | ||
}; | ||
assignProperties = () => { | ||
for (const [property, propertyConfig] of Object.entries(this.config)) { | ||
@@ -1057,4 +1068,4 @@ if (!propertyConfig) | ||
} | ||
} | ||
assignPropertyType(property, propertyConfig) { | ||
}; | ||
assignPropertyType = (property, propertyConfig) => { | ||
const config = this.normalize(propertyConfig); | ||
@@ -1075,4 +1086,4 @@ if (!config) | ||
} | ||
} | ||
assignPropertyTypes() { | ||
}; | ||
assignPropertyTypes = () => { | ||
for (const [property, propertyConfig] of Object.entries(this.config)) { | ||
@@ -1083,4 +1094,4 @@ if (!propertyConfig) | ||
} | ||
} | ||
getTypes() { | ||
}; | ||
getTypes = () => { | ||
const map = /* @__PURE__ */ new Map(); | ||
@@ -1102,3 +1113,3 @@ for (const [prop, tokens] of this.types.entries()) { | ||
return map; | ||
} | ||
}; | ||
defaultTransform = (value, prop) => { | ||
@@ -1112,3 +1123,3 @@ const isCssVar = prop.startsWith("--"); | ||
}; | ||
setTransform(property, transform) { | ||
setTransform = (property, transform) => { | ||
const defaultTransform = (value) => this.defaultTransform(value, property); | ||
@@ -1118,4 +1129,4 @@ const transformFn = transform ?? defaultTransform; | ||
return this; | ||
} | ||
setStyles(property, raw, propKey) { | ||
}; | ||
setStyles = (property, raw, propKey) => { | ||
propKey = propKey ?? this.getPropKey(property, raw); | ||
@@ -1126,4 +1137,4 @@ const defaultTransform = (value) => this.defaultTransform(value, property); | ||
return this; | ||
} | ||
setClassName(property, raw) { | ||
}; | ||
setClassName = (property, raw) => { | ||
const propKey = this.getPropKey(property, raw); | ||
@@ -1139,7 +1150,7 @@ const config = this.configs.get(property); | ||
return this; | ||
} | ||
isProperty(prop) { | ||
}; | ||
isProperty = (prop) => { | ||
return this.configs.has(prop); | ||
} | ||
getOrCreateClassName(prop, value) { | ||
}; | ||
getOrCreateClassName = (prop, value) => { | ||
const inner = (prop2, value2) => { | ||
@@ -1156,9 +1167,9 @@ const propKey = this.getPropKey(prop2, value2); | ||
return inner(prop, value); | ||
} | ||
getOrCreateStyle(prop, value) { | ||
}; | ||
getOrCreateStyle = (prop, value) => { | ||
const propKey = this.getPropKey(prop, value); | ||
this.styles.get(propKey) ?? this.setStyles(prop, value, propKey); | ||
return this.styles.get(propKey); | ||
} | ||
resolve(prop, value) { | ||
}; | ||
transform = (prop, value) => { | ||
if (value == null) { | ||
@@ -1168,13 +1179,13 @@ return { className: "", styles: {} }; | ||
const key = this.resolveShorthand(prop); | ||
return (0, import_shared8.compact)({ | ||
return (0, import_shared9.compact)({ | ||
layer: this.configs.get(key)?.layer, | ||
className: this.getOrCreateClassName(key, (0, import_shared8.withoutSpace)(value)), | ||
className: this.getOrCreateClassName(key, (0, import_shared9.withoutSpace)(value)), | ||
styles: this.getOrCreateStyle(key, value) | ||
}); | ||
} | ||
keys() { | ||
}; | ||
keys = () => { | ||
const shorthands = Array.from(this.shorthands.keys()); | ||
const properties = Object.keys(this.config); | ||
return [...shorthands, ...properties]; | ||
} | ||
}; | ||
}; | ||
@@ -1181,0 +1192,0 @@ // Annotate the CommonJS export names for ESM import in node: |
{ | ||
"name": "@pandacss/core", | ||
"version": "0.0.0-dev-20221126091729", | ||
"version": "0.0.0-dev-20221126121755", | ||
"description": "core functions for extract-it", | ||
@@ -26,11 +26,11 @@ "main": "dist/index.js", | ||
"lodash.merge": "4.6.2", | ||
"@pandacss/error": "0.0.0-dev-20221126091729", | ||
"@pandacss/types": "0.0.0-dev-20221126091729", | ||
"@pandacss/shared": "0.0.0-dev-20221126091729", | ||
"@pandacss/logger": "0.0.0-dev-20221126091729", | ||
"@pandacss/token-dictionary": "0.0.0-dev-20221126091729" | ||
"@pandacss/error": "0.0.0-dev-20221126121755", | ||
"@pandacss/types": "0.0.0-dev-20221126121755", | ||
"@pandacss/shared": "0.0.0-dev-20221126121755", | ||
"@pandacss/logger": "0.0.0-dev-20221126121755", | ||
"@pandacss/token-dictionary": "0.0.0-dev-20221126121755" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash.merge": "4.6.7", | ||
"@pandacss/fixture": "0.0.0-dev-20221126091729" | ||
"@pandacss/fixture": "0.0.0-dev-20221126121755" | ||
}, | ||
@@ -37,0 +37,0 @@ "scripts": { |
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
76015
2506
+ Added@pandacss/error@0.0.0-dev-20221126121755(transitive)
+ Added@pandacss/logger@0.0.0-dev-20221126121755(transitive)
+ Added@pandacss/shared@0.0.0-dev-20221126121755(transitive)
+ Added@pandacss/token-dictionary@0.0.0-dev-20221126121755(transitive)
+ Added@pandacss/types@0.0.0-dev-20221126121755(transitive)
- Removed@pandacss/error@0.0.0-dev-20221126091729(transitive)
- Removed@pandacss/logger@0.0.0-dev-20221126091729(transitive)
- Removed@pandacss/shared@0.0.0-dev-20221126091729(transitive)
- Removed@pandacss/token-dictionary@0.0.0-dev-20221126091729(transitive)
- Removed@pandacss/types@0.0.0-dev-20221126091729(transitive)