@pandacss/shared 0.0.0-dev-20221126091729 → 0.0.0-dev-20221126121755

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WalkObjectStopFn } from './walk-styles-622088f0.js';
2
- 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';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './walk-styles-4fcd344a.js';
2
+ 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';
3
3
 
4
4
  declare const isString: (v: any) => v is string;
5
5
  type AnyFunction = (...args: any[]) => any;
@@ -40,6 +40,9 @@ declare function flatten(values: Record<string, Record<string, any>>, stop?: Wal
40
40
 
41
41
  declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
42
42
 
43
+ type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
44
+ declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
45
+
43
46
  declare function splitBy(value: string, separator?: string): string[];
44
47
  declare function splitDotPath(path: string): string[];
45
48
  declare function getNegativePath(path: string[]): string[];
@@ -52,4 +55,4 @@ declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
52
55
 
53
56
  declare function unionType(values: IterableIterator<string> | string[]): string;
54
57
 
55
- 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 };
58
+ 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 };
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ __export(src_exports, {
40
40
  mapObject: () => mapObject,
41
41
  mapToJson: () => mapToJson,
42
42
  memo: () => memo,
43
+ normalizeStyleObject: () => normalizeStyleObject,
43
44
  splitBy: () => splitBy,
44
45
  splitDotPath: () => splitDotPath,
45
46
  toEm: () => toEm,
@@ -174,17 +175,43 @@ function walkStyles(mixedStyles, fn, scopes = []) {
174
175
  }
175
176
  }
176
177
 
178
+ // src/normalize-style-object.ts
179
+ function toResponsiveObject(values, breakpoints) {
180
+ return values.reduce((acc, current, index) => {
181
+ const key = breakpoints[index];
182
+ if (current != null) {
183
+ acc[key] = current;
184
+ }
185
+ return acc;
186
+ }, {});
187
+ }
188
+ function normalizeStyleObject(styles, context) {
189
+ const { utility, conditions } = context;
190
+ const { hasShorthand, resolveShorthand } = utility;
191
+ return walkObject(
192
+ styles,
193
+ (value) => {
194
+ return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
195
+ },
196
+ {
197
+ stop: (value) => Array.isArray(value),
198
+ getKey: (prop) => {
199
+ return hasShorthand ? resolveShorthand(prop) : prop;
200
+ }
201
+ }
202
+ );
203
+ }
204
+
177
205
  // src/classname.ts
206
+ var fallbackCondition = {
207
+ shift: (v) => v,
208
+ finalize: (v) => v,
209
+ breakpoints: { keys: [] }
210
+ };
178
211
  function createCss(context) {
179
- const {
180
- transform,
181
- hash,
182
- conditions: conds = { shift: (v) => v, finalize: (v) => v },
183
- resolveShorthand,
184
- hasShorthand
185
- } = context;
212
+ const { utility, hash, conditions: conds = fallbackCondition } = context;
186
213
  return (styleObject) => {
187
- const normalizedObject = hasShorthand ? walkObject(styleObject, (v) => v, { getKey: resolveShorthand }) : styleObject;
214
+ const normalizedObject = normalizeStyleObject(styleObject, context);
188
215
  const classNames = /* @__PURE__ */ new Set();
189
216
  walkStyles(normalizedObject, (props, scope) => {
190
217
  walkObject(props, (value, paths) => {
@@ -193,7 +220,7 @@ function createCss(context) {
193
220
  return;
194
221
  const [prop, ...allConditions] = conds.shift(paths);
195
222
  const conditions = filterBaseConditions(allConditions);
196
- const transformed = transform(prop, withoutImportant(value));
223
+ const transformed = utility.transform(prop, withoutImportant(value));
197
224
  let transformedClassName = transformed.className;
198
225
  if (important) {
199
226
  transformedClassName = `${transformedClassName}!`;
@@ -411,6 +438,7 @@ function unionType(values) {
411
438
  mapObject,
412
439
  mapToJson,
413
440
  memo,
441
+ normalizeStyleObject,
414
442
  splitBy,
415
443
  splitDotPath,
416
444
  toEm,
package/dist/index.mjs CHANGED
@@ -117,17 +117,43 @@ function walkStyles(mixedStyles, fn, scopes = []) {
117
117
  }
118
118
  }
119
119
 
120
+ // src/normalize-style-object.ts
121
+ function toResponsiveObject(values, breakpoints) {
122
+ return values.reduce((acc, current, index) => {
123
+ const key = breakpoints[index];
124
+ if (current != null) {
125
+ acc[key] = current;
126
+ }
127
+ return acc;
128
+ }, {});
129
+ }
130
+ function normalizeStyleObject(styles, context) {
131
+ const { utility, conditions } = context;
132
+ const { hasShorthand, resolveShorthand } = utility;
133
+ return walkObject(
134
+ styles,
135
+ (value) => {
136
+ return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
137
+ },
138
+ {
139
+ stop: (value) => Array.isArray(value),
140
+ getKey: (prop) => {
141
+ return hasShorthand ? resolveShorthand(prop) : prop;
142
+ }
143
+ }
144
+ );
145
+ }
146
+
120
147
  // src/classname.ts
148
+ var fallbackCondition = {
149
+ shift: (v) => v,
150
+ finalize: (v) => v,
151
+ breakpoints: { keys: [] }
152
+ };
121
153
  function createCss(context) {
122
- const {
123
- transform,
124
- hash,
125
- conditions: conds = { shift: (v) => v, finalize: (v) => v },
126
- resolveShorthand,
127
- hasShorthand
128
- } = context;
154
+ const { utility, hash, conditions: conds = fallbackCondition } = context;
129
155
  return (styleObject) => {
130
- const normalizedObject = hasShorthand ? walkObject(styleObject, (v) => v, { getKey: resolveShorthand }) : styleObject;
156
+ const normalizedObject = normalizeStyleObject(styleObject, context);
131
157
  const classNames = /* @__PURE__ */ new Set();
132
158
  walkStyles(normalizedObject, (props, scope) => {
133
159
  walkObject(props, (value, paths) => {
@@ -136,7 +162,7 @@ function createCss(context) {
136
162
  return;
137
163
  const [prop, ...allConditions] = conds.shift(paths);
138
164
  const conditions = filterBaseConditions(allConditions);
139
- const transformed = transform(prop, withoutImportant(value));
165
+ const transformed = utility.transform(prop, withoutImportant(value));
140
166
  let transformedClassName = transformed.className;
141
167
  if (important) {
142
168
  transformedClassName = `${transformedClassName}!`;
@@ -353,6 +379,7 @@ export {
353
379
  mapObject,
354
380
  mapToJson,
355
381
  memo,
382
+ normalizeStyleObject,
356
383
  splitBy,
357
384
  splitDotPath,
358
385
  toEm,
package/dist/shared.d.ts CHANGED
@@ -1 +1 @@
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';
1
+ 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';
package/dist/shared.js CHANGED
@@ -124,17 +124,43 @@ function walkStyles(mixedStyles, fn, scopes = []) {
124
124
  }
125
125
  }
126
126
 
127
+ // src/normalize-style-object.ts
128
+ function toResponsiveObject(values, breakpoints) {
129
+ return values.reduce((acc, current, index) => {
130
+ const key = breakpoints[index];
131
+ if (current != null) {
132
+ acc[key] = current;
133
+ }
134
+ return acc;
135
+ }, {});
136
+ }
137
+ function normalizeStyleObject(styles, context) {
138
+ const { utility, conditions } = context;
139
+ const { hasShorthand, resolveShorthand } = utility;
140
+ return walkObject(
141
+ styles,
142
+ (value) => {
143
+ return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
144
+ },
145
+ {
146
+ stop: (value) => Array.isArray(value),
147
+ getKey: (prop) => {
148
+ return hasShorthand ? resolveShorthand(prop) : prop;
149
+ }
150
+ }
151
+ );
152
+ }
153
+
127
154
  // src/classname.ts
155
+ var fallbackCondition = {
156
+ shift: (v) => v,
157
+ finalize: (v) => v,
158
+ breakpoints: { keys: [] }
159
+ };
128
160
  function createCss(context) {
129
- const {
130
- transform,
131
- hash,
132
- conditions: conds = { shift: (v) => v, finalize: (v) => v },
133
- resolveShorthand,
134
- hasShorthand
135
- } = context;
161
+ const { utility, hash, conditions: conds = fallbackCondition } = context;
136
162
  return (styleObject) => {
137
- const normalizedObject = hasShorthand ? walkObject(styleObject, (v) => v, { getKey: resolveShorthand }) : styleObject;
163
+ const normalizedObject = normalizeStyleObject(styleObject, context);
138
164
  const classNames = /* @__PURE__ */ new Set();
139
165
  walkStyles(normalizedObject, (props, scope) => {
140
166
  walkObject(props, (value, paths) => {
@@ -143,7 +169,7 @@ function createCss(context) {
143
169
  return;
144
170
  const [prop, ...allConditions] = conds.shift(paths);
145
171
  const conditions = filterBaseConditions(allConditions);
146
- const transformed = transform(prop, withoutImportant(value));
172
+ const transformed = utility.transform(prop, withoutImportant(value));
147
173
  let transformedClassName = transformed.className;
148
174
  if (important) {
149
175
  transformedClassName = `${transformedClassName}!`;
package/dist/shared.mjs CHANGED
@@ -91,17 +91,43 @@ function walkStyles(mixedStyles, fn, scopes = []) {
91
91
  }
92
92
  }
93
93
 
94
+ // src/normalize-style-object.ts
95
+ function toResponsiveObject(values, breakpoints) {
96
+ return values.reduce((acc, current, index) => {
97
+ const key = breakpoints[index];
98
+ if (current != null) {
99
+ acc[key] = current;
100
+ }
101
+ return acc;
102
+ }, {});
103
+ }
104
+ function normalizeStyleObject(styles, context) {
105
+ const { utility, conditions } = context;
106
+ const { hasShorthand, resolveShorthand } = utility;
107
+ return walkObject(
108
+ styles,
109
+ (value) => {
110
+ return Array.isArray(value) ? toResponsiveObject(value, conditions.breakpoints.keys) : value;
111
+ },
112
+ {
113
+ stop: (value) => Array.isArray(value),
114
+ getKey: (prop) => {
115
+ return hasShorthand ? resolveShorthand(prop) : prop;
116
+ }
117
+ }
118
+ );
119
+ }
120
+
94
121
  // src/classname.ts
122
+ var fallbackCondition = {
123
+ shift: (v) => v,
124
+ finalize: (v) => v,
125
+ breakpoints: { keys: [] }
126
+ };
95
127
  function createCss(context) {
96
- const {
97
- transform,
98
- hash,
99
- conditions: conds = { shift: (v) => v, finalize: (v) => v },
100
- resolveShorthand,
101
- hasShorthand
102
- } = context;
128
+ const { utility, hash, conditions: conds = fallbackCondition } = context;
103
129
  return (styleObject) => {
104
- const normalizedObject = hasShorthand ? walkObject(styleObject, (v) => v, { getKey: resolveShorthand }) : styleObject;
130
+ const normalizedObject = normalizeStyleObject(styleObject, context);
105
131
  const classNames = /* @__PURE__ */ new Set();
106
132
  walkStyles(normalizedObject, (props, scope) => {
107
133
  walkObject(props, (value, paths) => {
@@ -110,7 +136,7 @@ function createCss(context) {
110
136
  return;
111
137
  const [prop, ...allConditions] = conds.shift(paths);
112
138
  const conditions = filterBaseConditions(allConditions);
113
- const transformed = transform(prop, withoutImportant(value));
139
+ const transformed = utility.transform(prop, withoutImportant(value));
114
140
  let transformedClassName = transformed.className;
115
141
  if (important) {
116
142
  transformedClassName = `${transformedClassName}!`;
@@ -1,16 +1,27 @@
1
- type Context = {
2
- hasShorthand: boolean;
3
- resolveShorthand: (prop: string) => string;
4
- transform: (prop: string, value: any) => {
5
- className: string;
6
- };
1
+ type CreateCssContext = {
7
2
  hash?: boolean;
3
+ /**
4
+ * Partial properties from the Utility class
5
+ */
6
+ utility: {
7
+ hasShorthand: boolean;
8
+ resolveShorthand: (prop: string) => string;
9
+ transform: (prop: string, value: any) => {
10
+ className: string;
11
+ };
12
+ };
13
+ /**
14
+ * Partial properties from the Condition class
15
+ */
8
16
  conditions?: {
17
+ breakpoints: {
18
+ keys: string[];
19
+ };
9
20
  shift: (paths: string[]) => string[];
10
21
  finalize: (paths: string[]) => string[];
11
22
  };
12
23
  };
13
- declare function createCss(context: Context): (styleObject: Record<string, any>) => string;
24
+ declare function createCss(context: CreateCssContext): (styleObject: Record<string, any>) => string;
14
25
 
15
26
  declare const isBaseCondition: (c: string) => boolean;
16
27
  declare function filterBaseConditions(c: string[]): string[];
@@ -36,4 +47,4 @@ declare function toHash(value: string): string;
36
47
  type Dict = Record<string, any>;
37
48
  declare function walkStyles(mixedStyles: Dict, fn: (style: Dict, scope?: string[]) => void, scopes?: string[]): void;
38
49
 
39
- export { MappedObject as M, WalkObjectStopFn as W, isImportant as a, withoutSpace as b, createCss as c, WalkObjectOptions as d, walkObject as e, filterBaseConditions as f, walkStyles as g, isBaseCondition as i, mapObject as m, toHash as t, withoutImportant as w };
50
+ export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isImportant as a, withoutSpace as b, createCss as c, WalkObjectOptions as d, walkObject as e, filterBaseConditions as f, walkStyles as g, isBaseCondition as i, mapObject as m, toHash as t, withoutImportant as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "0.0.0-dev-20221126091729",
3
+ "version": "0.0.0-dev-20221126121755",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",