@pandacss/shared 0.4.0 → 0.5.0

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;
@@ -345,10 +362,19 @@ function cssVar(name, options = {}) {
345
362
  }
346
363
 
347
364
  // 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
- }
365
+ var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
366
+ var fcssescape = function(ch, asCodePoint) {
367
+ if (!asCodePoint)
368
+ return "\\" + ch;
369
+ if (ch === "\0")
370
+ return "\uFFFD";
371
+ if (ch === "-" && ch.length === 1)
372
+ return "\\-";
373
+ return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
374
+ };
375
+ var esc2 = (sel) => {
376
+ return (sel + "").replace(rcssescape, fcssescape);
377
+ };
352
378
 
353
379
  // src/flatten.ts
354
380
  function flatten(values, stop) {
@@ -481,6 +507,7 @@ function unionType(values) {
481
507
  }
482
508
  // Annotate the CommonJS export names for ESM import in node:
483
509
  0 && (module.exports = {
510
+ astish,
484
511
  calc,
485
512
  capitalize,
486
513
  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;
@@ -283,10 +299,19 @@ function cssVar(name, options = {}) {
283
299
  }
284
300
 
285
301
  // 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
- }
302
+ var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|^-|[^\x80-\uFFFF\w-]/g;
303
+ var fcssescape = function(ch, asCodePoint) {
304
+ if (!asCodePoint)
305
+ return "\\" + ch;
306
+ if (ch === "\0")
307
+ return "\uFFFD";
308
+ if (ch === "-" && ch.length === 1)
309
+ return "\\-";
310
+ return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16);
311
+ };
312
+ var esc2 = (sel) => {
313
+ return (sel + "").replace(rcssescape, fcssescape);
314
+ };
290
315
 
291
316
  // src/flatten.ts
292
317
  function flatten(values, stop) {
@@ -418,6 +443,7 @@ function unionType(values) {
418
443
  return Array.from(values).map((value) => JSON.stringify(value)).join(" | ");
419
444
  }
420
445
  export {
446
+ astish,
421
447
  calc,
422
448
  capitalize,
423
449
  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));
@@ -220,6 +237,29 @@ function createMergeCss(context) {
220
237
  return { mergeCss, assignCss };
221
238
  }
222
239
 
240
+ // src/memo.ts
241
+ var memo = (fn) => {
242
+ const cache = /* @__PURE__ */ new Map();
243
+ const get = (...args) => {
244
+ const key = JSON.stringify(args);
245
+ if (cache.has(key)) {
246
+ return cache.get(key);
247
+ }
248
+ const result = fn(...args);
249
+ cache.set(key, result);
250
+ return result;
251
+ };
252
+ return get;
253
+ };
254
+
255
+ // src/hypenate.ts
256
+ var dashCaseRegex = /[A-Z]/g;
257
+ var hypenateProperty = memo((property) => {
258
+ if (property.startsWith("--"))
259
+ return property;
260
+ return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
261
+ });
262
+
223
263
  // src/normalize-html.ts
224
264
  var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
225
265
  function convert(key) {
@@ -248,31 +288,9 @@ function splitProps(props, ...keys) {
248
288
  const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
249
289
  return keys.map(fn).concat(split(dKeys));
250
290
  }
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
291
  // Annotate the CommonJS export names for ESM import in node:
275
292
  0 && (module.exports = {
293
+ astish,
276
294
  compact,
277
295
  createCss,
278
296
  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));
@@ -181,6 +197,29 @@ function createMergeCss(context) {
181
197
  return { mergeCss, assignCss };
182
198
  }
183
199
 
200
+ // src/memo.ts
201
+ var memo = (fn) => {
202
+ const cache = /* @__PURE__ */ new Map();
203
+ const get = (...args) => {
204
+ const key = JSON.stringify(args);
205
+ if (cache.has(key)) {
206
+ return cache.get(key);
207
+ }
208
+ const result = fn(...args);
209
+ cache.set(key, result);
210
+ return result;
211
+ };
212
+ return get;
213
+ };
214
+
215
+ // src/hypenate.ts
216
+ var dashCaseRegex = /[A-Z]/g;
217
+ var hypenateProperty = memo((property) => {
218
+ if (property.startsWith("--"))
219
+ return property;
220
+ return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
221
+ });
222
+
184
223
  // src/normalize-html.ts
185
224
  var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
186
225
  function convert(key) {
@@ -209,30 +248,8 @@ function splitProps(props, ...keys) {
209
248
  const fn = (key) => split(Array.isArray(key) ? key : dKeys.filter(key));
210
249
  return keys.map(fn).concat(split(dKeys));
211
250
  }
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
251
  export {
252
+ astish,
236
253
  compact,
237
254
  createCss,
238
255
  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.0",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",