@pandacss/shared 0.5.0 → 0.6.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.
package/dist/index.d.mts CHANGED
@@ -8,6 +8,8 @@ declare const calc: {
8
8
  negate(x: Operand): string;
9
9
  };
10
10
 
11
+ declare const camelCaseProperty: (property: string) => string;
12
+
11
13
  declare const capitalize: (s: string) => string;
12
14
  declare const dashCase: (s: string) => string;
13
15
  declare const uncapitalize: (s: string) => string;
@@ -50,4 +52,4 @@ declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
50
52
 
51
53
  declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
52
54
 
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 };
55
+ export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, 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
@@ -8,6 +8,8 @@ declare const calc: {
8
8
  negate(x: Operand): string;
9
9
  };
10
10
 
11
+ declare const camelCaseProperty: (property: string) => string;
12
+
11
13
  declare const capitalize: (s: string) => string;
12
14
  declare const dashCase: (s: string) => string;
13
15
  declare const uncapitalize: (s: string) => string;
@@ -50,4 +52,4 @@ declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
50
52
 
51
53
  declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
52
54
 
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 };
55
+ export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, memo, normalizeShorthand, normalizeStyleObject, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType };
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ var src_exports = {};
22
22
  __export(src_exports, {
23
23
  astish: () => astish,
24
24
  calc: () => calc,
25
+ camelCaseProperty: () => camelCaseProperty,
25
26
  capitalize: () => capitalize,
26
27
  compact: () => compact,
27
28
  createCss: () => createCss,
@@ -72,7 +73,7 @@ function isObject(value) {
72
73
  var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
73
74
  var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
74
75
  var astish = (val, tree = [{}]) => {
75
- const block = newRule.exec(val.replace(ruleClean, ""));
76
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
76
77
  if (!block)
77
78
  return tree[0];
78
79
  if (block[4])
@@ -104,6 +105,32 @@ var calc = {
104
105
  }
105
106
  };
106
107
 
108
+ // src/memo.ts
109
+ var memo = (fn) => {
110
+ const cache = /* @__PURE__ */ new Map();
111
+ const get = (...args) => {
112
+ const key = JSON.stringify(args);
113
+ if (cache.has(key)) {
114
+ return cache.get(key);
115
+ }
116
+ const result = fn(...args);
117
+ cache.set(key, result);
118
+ return result;
119
+ };
120
+ return get;
121
+ };
122
+
123
+ // src/camelcase-property.ts
124
+ var regex = /-(\w|$)/g;
125
+ var callback = (_dashChar, char) => char.toUpperCase();
126
+ var camelCaseProperty = memo((property) => {
127
+ if (property.startsWith("--"))
128
+ return property;
129
+ let str = property.toLowerCase();
130
+ str = str.startsWith("-ms-") ? str.substring(1) : str;
131
+ return str.replace(regex, callback);
132
+ });
133
+
107
134
  // src/capitalize.ts
108
135
  var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
109
136
  var camelCaseRegex = /([a-z])([A-Z])/g;
@@ -170,6 +197,7 @@ function mergeProps(...sources) {
170
197
  }
171
198
 
172
199
  // src/walk-object.ts
200
+ var isNotNullish = (element) => element != null;
173
201
  function walkObject(target, predicate, options = {}) {
174
202
  const { stop, getKey } = options;
175
203
  function inner(value, path = []) {
@@ -181,7 +209,10 @@ function walkObject(target, predicate, options = {}) {
181
209
  if (stop?.(value, childPath)) {
182
210
  return predicate(value, path);
183
211
  }
184
- result[key] = inner(child, childPath);
212
+ const next = inner(child, childPath);
213
+ if (isNotNullish(next)) {
214
+ result[key] = next;
215
+ }
185
216
  }
186
217
  return result;
187
218
  }
@@ -395,27 +426,13 @@ function flatten(values, stop) {
395
426
  return result;
396
427
  }
397
428
 
398
- // src/memo.ts
399
- var memo = (fn) => {
400
- const cache = /* @__PURE__ */ new Map();
401
- const get = (...args) => {
402
- const key = JSON.stringify(args);
403
- if (cache.has(key)) {
404
- return cache.get(key);
405
- }
406
- const result = fn(...args);
407
- cache.set(key, result);
408
- return result;
409
- };
410
- return get;
411
- };
412
-
413
- // src/hypenate.ts
414
- var dashCaseRegex2 = /[A-Z]/g;
429
+ // src/hypenate-property.ts
430
+ var wordRegex = /([A-Z])/g;
431
+ var msRegex = /^ms-/;
415
432
  var hypenateProperty = memo((property) => {
416
433
  if (property.startsWith("--"))
417
434
  return property;
418
- return property.replace(dashCaseRegex2, (match) => `-${match.toLowerCase()}`);
435
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
419
436
  });
420
437
 
421
438
  // src/split.ts
@@ -509,6 +526,7 @@ function unionType(values) {
509
526
  0 && (module.exports = {
510
527
  astish,
511
528
  calc,
529
+ camelCaseProperty,
512
530
  capitalize,
513
531
  compact,
514
532
  createCss,
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ function isObject(value) {
9
9
  var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
10
10
  var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
11
11
  var astish = (val, tree = [{}]) => {
12
- const block = newRule.exec(val.replace(ruleClean, ""));
12
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
13
13
  if (!block)
14
14
  return tree[0];
15
15
  if (block[4])
@@ -41,6 +41,32 @@ var calc = {
41
41
  }
42
42
  };
43
43
 
44
+ // src/memo.ts
45
+ var memo = (fn) => {
46
+ const cache = /* @__PURE__ */ new Map();
47
+ const get = (...args) => {
48
+ const key = JSON.stringify(args);
49
+ if (cache.has(key)) {
50
+ return cache.get(key);
51
+ }
52
+ const result = fn(...args);
53
+ cache.set(key, result);
54
+ return result;
55
+ };
56
+ return get;
57
+ };
58
+
59
+ // src/camelcase-property.ts
60
+ var regex = /-(\w|$)/g;
61
+ var callback = (_dashChar, char) => char.toUpperCase();
62
+ var camelCaseProperty = memo((property) => {
63
+ if (property.startsWith("--"))
64
+ return property;
65
+ let str = property.toLowerCase();
66
+ str = str.startsWith("-ms-") ? str.substring(1) : str;
67
+ return str.replace(regex, callback);
68
+ });
69
+
44
70
  // src/capitalize.ts
45
71
  var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
46
72
  var camelCaseRegex = /([a-z])([A-Z])/g;
@@ -107,6 +133,7 @@ function mergeProps(...sources) {
107
133
  }
108
134
 
109
135
  // src/walk-object.ts
136
+ var isNotNullish = (element) => element != null;
110
137
  function walkObject(target, predicate, options = {}) {
111
138
  const { stop, getKey } = options;
112
139
  function inner(value, path = []) {
@@ -118,7 +145,10 @@ function walkObject(target, predicate, options = {}) {
118
145
  if (stop?.(value, childPath)) {
119
146
  return predicate(value, path);
120
147
  }
121
- result[key] = inner(child, childPath);
148
+ const next = inner(child, childPath);
149
+ if (isNotNullish(next)) {
150
+ result[key] = next;
151
+ }
122
152
  }
123
153
  return result;
124
154
  }
@@ -332,27 +362,13 @@ function flatten(values, stop) {
332
362
  return result;
333
363
  }
334
364
 
335
- // src/memo.ts
336
- var memo = (fn) => {
337
- const cache = /* @__PURE__ */ new Map();
338
- const get = (...args) => {
339
- const key = JSON.stringify(args);
340
- if (cache.has(key)) {
341
- return cache.get(key);
342
- }
343
- const result = fn(...args);
344
- cache.set(key, result);
345
- return result;
346
- };
347
- return get;
348
- };
349
-
350
- // src/hypenate.ts
351
- var dashCaseRegex2 = /[A-Z]/g;
365
+ // src/hypenate-property.ts
366
+ var wordRegex = /([A-Z])/g;
367
+ var msRegex = /^ms-/;
352
368
  var hypenateProperty = memo((property) => {
353
369
  if (property.startsWith("--"))
354
370
  return property;
355
- return property.replace(dashCaseRegex2, (match) => `-${match.toLowerCase()}`);
371
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
356
372
  });
357
373
 
358
374
  // src/split.ts
@@ -445,6 +461,7 @@ function unionType(values) {
445
461
  export {
446
462
  astish,
447
463
  calc,
464
+ camelCaseProperty,
448
465
  capitalize,
449
466
  compact,
450
467
  createCss,
package/dist/shared.js CHANGED
@@ -47,7 +47,7 @@ function isObject(value) {
47
47
  var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
48
48
  var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
49
49
  var astish = (val, tree = [{}]) => {
50
- const block = newRule.exec(val.replace(ruleClean, ""));
50
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
51
51
  if (!block)
52
52
  return tree[0];
53
53
  if (block[4])
@@ -119,6 +119,7 @@ function mergeProps(...sources) {
119
119
  }
120
120
 
121
121
  // src/walk-object.ts
122
+ var isNotNullish = (element) => element != null;
122
123
  function walkObject(target, predicate, options = {}) {
123
124
  const { stop, getKey } = options;
124
125
  function inner(value, path = []) {
@@ -130,7 +131,10 @@ function walkObject(target, predicate, options = {}) {
130
131
  if (stop?.(value, childPath)) {
131
132
  return predicate(value, path);
132
133
  }
133
- result[key] = inner(child, childPath);
134
+ const next = inner(child, childPath);
135
+ if (isNotNullish(next)) {
136
+ result[key] = next;
137
+ }
134
138
  }
135
139
  return result;
136
140
  }
@@ -252,12 +256,13 @@ var memo = (fn) => {
252
256
  return get;
253
257
  };
254
258
 
255
- // src/hypenate.ts
256
- var dashCaseRegex = /[A-Z]/g;
259
+ // src/hypenate-property.ts
260
+ var wordRegex = /([A-Z])/g;
261
+ var msRegex = /^ms-/;
257
262
  var hypenateProperty = memo((property) => {
258
263
  if (property.startsWith("--"))
259
264
  return property;
260
- return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
265
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
261
266
  });
262
267
 
263
268
  // src/normalize-html.ts
package/dist/shared.mjs CHANGED
@@ -7,7 +7,7 @@ function isObject(value) {
7
7
  var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
8
8
  var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
9
9
  var astish = (val, tree = [{}]) => {
10
- const block = newRule.exec(val.replace(ruleClean, ""));
10
+ const block = newRule.exec((val ?? "").replace(ruleClean, ""));
11
11
  if (!block)
12
12
  return tree[0];
13
13
  if (block[4])
@@ -79,6 +79,7 @@ function mergeProps(...sources) {
79
79
  }
80
80
 
81
81
  // src/walk-object.ts
82
+ var isNotNullish = (element) => element != null;
82
83
  function walkObject(target, predicate, options = {}) {
83
84
  const { stop, getKey } = options;
84
85
  function inner(value, path = []) {
@@ -90,7 +91,10 @@ function walkObject(target, predicate, options = {}) {
90
91
  if (stop?.(value, childPath)) {
91
92
  return predicate(value, path);
92
93
  }
93
- result[key] = inner(child, childPath);
94
+ const next = inner(child, childPath);
95
+ if (isNotNullish(next)) {
96
+ result[key] = next;
97
+ }
94
98
  }
95
99
  return result;
96
100
  }
@@ -212,12 +216,13 @@ var memo = (fn) => {
212
216
  return get;
213
217
  };
214
218
 
215
- // src/hypenate.ts
216
- var dashCaseRegex = /[A-Z]/g;
219
+ // src/hypenate-property.ts
220
+ var wordRegex = /([A-Z])/g;
221
+ var msRegex = /^ms-/;
217
222
  var hypenateProperty = memo((property) => {
218
223
  if (property.startsWith("--"))
219
224
  return property;
220
- return property.replace(dashCaseRegex, (match) => `-${match.toLowerCase()}`);
225
+ return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
221
226
  });
222
227
 
223
228
  // src/normalize-html.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",