@pandacss/shared 0.4.0 → 0.5.1

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.
@@ -0,0 +1,53 @@
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-3d8b55c4.js';
2
+ export { n as WalkObjectOptions, c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, a as isFunction, j as isImportant, b as isObject, i as isString, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, w as withoutImportant, k as withoutSpace } from './split-props-3d8b55c4.js';
3
+
4
+ type Operand = string | number | {
5
+ ref: string;
6
+ };
7
+ declare const calc: {
8
+ negate(x: Operand): string;
9
+ };
10
+
11
+ declare const capitalize: (s: string) => string;
12
+ declare const dashCase: (s: string) => string;
13
+ declare const uncapitalize: (s: string) => string;
14
+
15
+ declare function getUnit(value?: string): string | undefined;
16
+ declare function toPx(value?: string | number): string | undefined;
17
+ declare function toEm(value?: string, fontSize?: number): string | undefined;
18
+ declare function toRem(value?: string): string | undefined;
19
+
20
+ type CssVar = {
21
+ var: `--${string}`;
22
+ ref: string;
23
+ };
24
+ type CssVarOptions = {
25
+ fallback?: string;
26
+ prefix?: string;
27
+ hash?: boolean;
28
+ };
29
+ declare function cssVar(name: string, options?: CssVarOptions): CssVar;
30
+
31
+ declare const esc: (sel: string) => string;
32
+
33
+ declare function flatten(values: Record<string, Record<string, any>>, stop?: WalkObjectStopFn): Record<string, any>;
34
+
35
+ declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
36
+
37
+ type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
38
+ declare function normalizeShorthand(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
39
+ declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
40
+
41
+ declare function splitBy(value: string, separator?: string): any[];
42
+ declare function splitDotPath(path: string): string[];
43
+ declare function getNegativePath(path: string[]): string[];
44
+ declare function getDotPath(obj: any, path: string, fallback?: any): any;
45
+
46
+ type MapToRecord<K extends Map<string, any>> = {
47
+ [P in keyof K]: K[P] extends Map<string, infer V> ? Record<string, V> : never;
48
+ };
49
+ declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
50
+
51
+ declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
52
+
53
+ export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, capitalize, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, memo, normalizeShorthand, normalizeStyleObject, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-6820d5c1.js';
2
- export { l as WalkObjectOptions, 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-6820d5c1.js';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-3d8b55c4.js';
2
+ export { n as WalkObjectOptions, c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, a as isFunction, j as isImportant, b as isObject, i as isString, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, w as withoutImportant, k as withoutSpace } from './split-props-3d8b55c4.js';
3
3
 
4
4
  type Operand = string | number | {
5
5
  ref: string;
@@ -28,7 +28,7 @@ type CssVarOptions = {
28
28
  };
29
29
  declare function cssVar(name: string, options?: CssVarOptions): CssVar;
30
30
 
31
- declare function esc(str: string): string;
31
+ declare const esc: (sel: string) => string;
32
32
 
33
33
  declare function flatten(values: Record<string, Record<string, any>>, stop?: WalkObjectStopFn): Record<string, any>;
34
34
 
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ astish: () => astish,
23
24
  calc: () => calc,
24
25
  capitalize: () => capitalize,
25
26
  compact: () => compact,
@@ -67,6 +68,22 @@ function isObject(value) {
67
68
  return typeof value === "object" && value != null && !Array.isArray(value);
68
69
  }
69
70
 
71
+ // src/astish.ts
72
+ var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
73
+ var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
74
+ var astish = (val, tree = [{}]) => {
75
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
76
+ if (!block)
77
+ return tree[0];
78
+ if (block[4])
79
+ tree.shift();
80
+ else if (block[3])
81
+ tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
82
+ else
83
+ tree[0][block[1]] = block[2];
84
+ return astish(val, tree);
85
+ };
86
+
70
87
  // src/calc.ts
71
88
  function isCssVar(value) {
72
89
  return isObject(value) && "ref" in value;
@@ -153,6 +170,7 @@ function mergeProps(...sources) {
153
170
  }
154
171
 
155
172
  // src/walk-object.ts
173
+ var isNotNullish = (element) => element != null;
156
174
  function walkObject(target, predicate, options = {}) {
157
175
  const { stop, getKey } = options;
158
176
  function inner(value, path = []) {
@@ -164,7 +182,10 @@ function walkObject(target, predicate, options = {}) {
164
182
  if (stop?.(value, childPath)) {
165
183
  return predicate(value, path);
166
184
  }
167
- result[key] = inner(child, childPath);
185
+ const next = inner(child, childPath);
186
+ if (isNotNullish(next)) {
187
+ result[key] = next;
188
+ }
168
189
  }
169
190
  return result;
170
191
  }
@@ -345,10 +366,19 @@ function cssVar(name, options = {}) {
345
366
  }
346
367
 
347
368
  // src/esc.ts
348
- var escapeRegExp = /(^[^_a-zA-Z\u00a0-\uffff]|[^-_a-zA-Z0-9\u00a0-\uffff])/g;
349
- function esc2(str) {
350
- return "".replace.call(str, escapeRegExp, "\\$1");
351
- }
369
+ var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
370
+ var fcssescape = function(ch, asCodePoint) {
371
+ if (!asCodePoint)
372
+ return "\\" + ch;
373
+ if (ch === "\0")
374
+ return "\uFFFD";
375
+ if (ch === "-" && ch.length === 1)
376
+ return "\\-";
377
+ return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
378
+ };
379
+ var esc2 = (sel) => {
380
+ return (sel + "").replace(rcssescape, fcssescape);
381
+ };
352
382
 
353
383
  // src/flatten.ts
354
384
  function flatten(values, stop) {
@@ -481,6 +511,7 @@ function unionType(values) {
481
511
  }
482
512
  // Annotate the CommonJS export names for ESM import in node:
483
513
  0 && (module.exports = {
514
+ astish,
484
515
  calc,
485
516
  capitalize,
486
517
  compact,
package/dist/index.mjs CHANGED
@@ -5,6 +5,22 @@ function isObject(value) {
5
5
  return typeof value === "object" && value != null && !Array.isArray(value);
6
6
  }
7
7
 
8
+ // src/astish.ts
9
+ var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
10
+ var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
11
+ var astish = (val, tree = [{}]) => {
12
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
13
+ if (!block)
14
+ return tree[0];
15
+ if (block[4])
16
+ tree.shift();
17
+ else if (block[3])
18
+ tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
19
+ else
20
+ tree[0][block[1]] = block[2];
21
+ return astish(val, tree);
22
+ };
23
+
8
24
  // src/calc.ts
9
25
  function isCssVar(value) {
10
26
  return isObject(value) && "ref" in value;
@@ -91,6 +107,7 @@ function mergeProps(...sources) {
91
107
  }
92
108
 
93
109
  // src/walk-object.ts
110
+ var isNotNullish = (element) => element != null;
94
111
  function walkObject(target, predicate, options = {}) {
95
112
  const { stop, getKey } = options;
96
113
  function inner(value, path = []) {
@@ -102,7 +119,10 @@ function walkObject(target, predicate, options = {}) {
102
119
  if (stop?.(value, childPath)) {
103
120
  return predicate(value, path);
104
121
  }
105
- result[key] = inner(child, childPath);
122
+ const next = inner(child, childPath);
123
+ if (isNotNullish(next)) {
124
+ result[key] = next;
125
+ }
106
126
  }
107
127
  return result;
108
128
  }
@@ -283,10 +303,19 @@ function cssVar(name, options = {}) {
283
303
  }
284
304
 
285
305
  // src/esc.ts
286
- var escapeRegExp = /(^[^_a-zA-Z\u00a0-\uffff]|[^-_a-zA-Z0-9\u00a0-\uffff])/g;
287
- function esc2(str) {
288
- return "".replace.call(str, escapeRegExp, "\\$1");
289
- }
306
+ var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
307
+ var fcssescape = function(ch, asCodePoint) {
308
+ if (!asCodePoint)
309
+ return "\\" + ch;
310
+ if (ch === "\0")
311
+ return "\uFFFD";
312
+ if (ch === "-" && ch.length === 1)
313
+ return "\\-";
314
+ return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
315
+ };
316
+ var esc2 = (sel) => {
317
+ return (sel + "").replace(rcssescape, fcssescape);
318
+ };
290
319
 
291
320
  // src/flatten.ts
292
321
  function flatten(values, stop) {
@@ -418,6 +447,7 @@ function unionType(values) {
418
447
  return Array.from(values).map((value) => JSON.stringify(value)).join(" | ");
419
448
  }
420
449
  export {
450
+ astish,
421
451
  calc,
422
452
  capitalize,
423
453
  compact,
@@ -0,0 +1,10 @@
1
+ export { c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, b as isObject, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, k as withoutSpace } from './split-props-3d8b55c4.js';
2
+
3
+ declare function normalizeHTMLProps(props: Record<string, any>): {
4
+ [k: string]: any;
5
+ };
6
+ declare namespace normalizeHTMLProps {
7
+ var keys: string[];
8
+ }
9
+
10
+ export { normalizeHTMLProps };
package/dist/shared.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- 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-6820d5c1.js';
1
+ export { c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, b as isObject, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, k as withoutSpace } from './split-props-3d8b55c4.js';
2
2
 
3
3
  declare function normalizeHTMLProps(props: Record<string, any>): {
4
4
  [k: string]: any;
package/dist/shared.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/shared.ts
21
21
  var shared_exports = {};
22
22
  __export(shared_exports, {
23
+ astish: () => astish,
23
24
  compact: () => compact,
24
25
  createCss: () => createCss,
25
26
  createMergeCss: () => createMergeCss,
@@ -42,6 +43,22 @@ function isObject(value) {
42
43
  return typeof value === "object" && value != null && !Array.isArray(value);
43
44
  }
44
45
 
46
+ // src/astish.ts
47
+ var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
48
+ var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
49
+ var astish = (val, tree = [{}]) => {
50
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
51
+ if (!block)
52
+ return tree[0];
53
+ if (block[4])
54
+ tree.shift();
55
+ else if (block[3])
56
+ tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
57
+ else
58
+ tree[0][block[1]] = block[2];
59
+ return astish(val, tree);
60
+ };
61
+
45
62
  // src/compact.ts
46
63
  function compact(value) {
47
64
  return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
@@ -102,6 +119,7 @@ function mergeProps(...sources) {
102
119
  }
103
120
 
104
121
  // src/walk-object.ts
122
+ var isNotNullish = (element) => element != null;
105
123
  function walkObject(target, predicate, options = {}) {
106
124
  const { stop, getKey } = options;
107
125
  function inner(value, path = []) {
@@ -113,7 +131,10 @@ function walkObject(target, predicate, options = {}) {
113
131
  if (stop?.(value, childPath)) {
114
132
  return predicate(value, path);
115
133
  }
116
- result[key] = inner(child, childPath);
134
+ const next = inner(child, childPath);
135
+ if (isNotNullish(next)) {
136
+ result[key] = next;
137
+ }
117
138
  }
118
139
  return result;
119
140
  }
@@ -220,6 +241,29 @@ function createMergeCss(context) {
220
241
  return { mergeCss, assignCss };
221
242
  }
222
243
 
244
+ // src/memo.ts
245
+ var memo = (fn) => {
246
+ const cache = /* @__PURE__ */ new Map();
247
+ const get = (...args) => {
248
+ const key = JSON.stringify(args);
249
+ if (cache.has(key)) {
250
+ return cache.get(key);
251
+ }
252
+ const result = fn(...args);
253
+ cache.set(key, result);
254
+ return result;
255
+ };
256
+ return get;
257
+ };
258
+
259
+ // src/hypenate.ts
260
+ var dashCaseRegex = /[A-Z]/g;
261
+ var hypenateProperty = memo((property) => {
262
+ if (property.startsWith("--"))
263
+ return property;
264
+ return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
265
+ });
266
+
223
267
  // src/normalize-html.ts
224
268
  var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
225
269
  function convert(key) {
@@ -248,31 +292,9 @@ function splitProps(props, ...keys) {
248
292
  const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
249
293
  return keys.map(fn).concat(split(dKeys));
250
294
  }
251
-
252
- // src/memo.ts
253
- var memo = (fn) => {
254
- const cache = /* @__PURE__ */ new Map();
255
- const get = (...args) => {
256
- const key = JSON.stringify(args);
257
- if (cache.has(key)) {
258
- return cache.get(key);
259
- }
260
- const result = fn(...args);
261
- cache.set(key, result);
262
- return result;
263
- };
264
- return get;
265
- };
266
-
267
- // src/hypenate.ts
268
- var dashCaseRegex = /[A-Z]/g;
269
- var hypenateProperty = memo((property) => {
270
- if (property.startsWith("--"))
271
- return property;
272
- return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
273
- });
274
295
  // Annotate the CommonJS export names for ESM import in node:
275
296
  0 && (module.exports = {
297
+ astish,
276
298
  compact,
277
299
  createCss,
278
300
  createMergeCss,
package/dist/shared.mjs CHANGED
@@ -3,6 +3,22 @@ function isObject(value) {
3
3
  return typeof value === "object" && value != null && !Array.isArray(value);
4
4
  }
5
5
 
6
+ // src/astish.ts
7
+ var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
8
+ var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
9
+ var astish = (val, tree = [{}]) => {
10
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
11
+ if (!block)
12
+ return tree[0];
13
+ if (block[4])
14
+ tree.shift();
15
+ else if (block[3])
16
+ tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
17
+ else
18
+ tree[0][block[1]] = block[2];
19
+ return astish(val, tree);
20
+ };
21
+
6
22
  // src/compact.ts
7
23
  function compact(value) {
8
24
  return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
@@ -63,6 +79,7 @@ function mergeProps(...sources) {
63
79
  }
64
80
 
65
81
  // src/walk-object.ts
82
+ var isNotNullish = (element) => element != null;
66
83
  function walkObject(target, predicate, options = {}) {
67
84
  const { stop, getKey } = options;
68
85
  function inner(value, path = []) {
@@ -74,7 +91,10 @@ function walkObject(target, predicate, options = {}) {
74
91
  if (stop?.(value, childPath)) {
75
92
  return predicate(value, path);
76
93
  }
77
- result[key] = inner(child, childPath);
94
+ const next = inner(child, childPath);
95
+ if (isNotNullish(next)) {
96
+ result[key] = next;
97
+ }
78
98
  }
79
99
  return result;
80
100
  }
@@ -181,6 +201,29 @@ function createMergeCss(context) {
181
201
  return { mergeCss, assignCss };
182
202
  }
183
203
 
204
+ // src/memo.ts
205
+ var memo = (fn) => {
206
+ const cache = /* @__PURE__ */ new Map();
207
+ const get = (...args) => {
208
+ const key = JSON.stringify(args);
209
+ if (cache.has(key)) {
210
+ return cache.get(key);
211
+ }
212
+ const result = fn(...args);
213
+ cache.set(key, result);
214
+ return result;
215
+ };
216
+ return get;
217
+ };
218
+
219
+ // src/hypenate.ts
220
+ var dashCaseRegex = /[A-Z]/g;
221
+ var hypenateProperty = memo((property) => {
222
+ if (property.startsWith("--"))
223
+ return property;
224
+ return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
225
+ });
226
+
184
227
  // src/normalize-html.ts
185
228
  var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
186
229
  function convert(key) {
@@ -209,30 +252,8 @@ function splitProps(props, ...keys) {
209
252
  const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
210
253
  return keys.map(fn).concat(split(dKeys));
211
254
  }
212
-
213
- // src/memo.ts
214
- var memo = (fn) => {
215
- const cache = /* @__PURE__ */ new Map();
216
- const get = (...args) => {
217
- const key = JSON.stringify(args);
218
- if (cache.has(key)) {
219
- return cache.get(key);
220
- }
221
- const result = fn(...args);
222
- cache.set(key, result);
223
- return result;
224
- };
225
- return get;
226
- };
227
-
228
- // src/hypenate.ts
229
- var dashCaseRegex = /[A-Z]/g;
230
- var hypenateProperty = memo((property) => {
231
- if (property.startsWith("--"))
232
- return property;
233
- return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
234
- });
235
255
  export {
256
+ astish,
236
257
  compact,
237
258
  createCss,
238
259
  createMergeCss,
@@ -3,6 +3,8 @@ type AnyFunction = (...args: any[]) => any;
3
3
  declare const isFunction: (v: any) => v is AnyFunction;
4
4
  declare function isObject(value: any): value is Record<string, any>;
5
5
 
6
+ declare const astish: (val: string, tree?: any[]) => Record<string, any>;
7
+
6
8
  type CreateCssContext = {
7
9
  hash?: boolean;
8
10
  /**
@@ -66,4 +68,4 @@ type PredicateFn = (key: string) => boolean;
66
68
  type Key = PredicateFn | string[];
67
69
  declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
68
70
 
69
- export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, createCss as c, createMergeCss as d, compact as e, isBaseCondition as f, filterBaseConditions as g, isImportant as h, isString as i, withoutSpace as j, hypenateProperty as k, WalkObjectOptions as l, mergeProps as m, walkObject as n, mapObject as o, splitProps as s, toHash as t, withoutImportant as w };
71
+ export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, astish as c, createCss as d, createMergeCss as e, compact as f, isBaseCondition as g, filterBaseConditions as h, isString as i, isImportant as j, withoutSpace as k, hypenateProperty as l, mergeProps as m, WalkObjectOptions as n, walkObject as o, mapObject as p, splitProps as s, toHash as t, withoutImportant as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",