@pandacss/shared 0.35.0 → 0.36.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
@@ -1,9 +1,11 @@
1
- import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-4wnn7ulW.mjs';
2
- export { x as WalkObjectOptions, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, a as isBoolean, b as isFunction, j as isImportant, c as isObject, i as isString, z as mapObject, m as markImportant, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, w as withoutImportant, k as withoutSpace } from './shared-4wnn7ulW.mjs';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-5yRolXii.mjs';
2
+ export { x as WalkObjectOptions, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, j as hypenateProperty, g as isBaseCondition, a as isBoolean, b as isFunction, k as isImportant, c as isObject, i as isString, z as mapObject, m as markImportant, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, w as withoutImportant, l as withoutSpace } from './shared-5yRolXii.mjs';
3
3
  export { astish } from './astish.mjs';
4
4
 
5
5
  declare const getArbitraryValue: (_value: string) => string;
6
6
 
7
+ declare function assign(target: any, ...sources: any[]): any;
8
+
7
9
  type Operand = string | number | {
8
10
  ref: string;
9
11
  };
@@ -17,11 +19,6 @@ declare const capitalize: (s: string) => string;
17
19
  declare const dashCase: (s: string) => string;
18
20
  declare const uncapitalize: (s: string) => string;
19
21
 
20
- declare function getUnit(value?: string): string | undefined;
21
- declare function toPx(value?: string | number): string | undefined;
22
- declare function toEm(value?: string, fontSize?: number): string | undefined;
23
- declare function toRem(value?: string): string | undefined;
24
-
25
22
  interface CssVar {
26
23
  var: `--${string}`;
27
24
  ref: string;
@@ -69,10 +66,14 @@ declare const isCssUnit: (v: unknown) => boolean;
69
66
 
70
67
  declare const isCssVar: (v: unknown) => boolean;
71
68
 
69
+ declare function mergeWith(target: any, ...sources: any[]): any;
70
+
72
71
  type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
73
72
  declare function toResponsiveObject(values: string[], breakpoints: string[]): Record<string, string>;
74
73
  declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext, shorthand?: boolean): MappedObject<Record<string, any>, any>;
75
74
 
75
+ declare const omit: <T, K extends (string & {}) | keyof T>(obj: T, paths: K[]) => Omit<T, K>;
76
+
76
77
  declare const createRegex: (item: Array<string | RegExp>) => RegExp;
77
78
 
78
79
  declare const stringifyJson: (config: Record<string, any>) => string;
@@ -128,4 +129,9 @@ declare function traverse(obj: any, callback: CallbackFn, options?: TraverseOpti
128
129
 
129
130
  declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
130
131
 
131
- export { CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPropertyPriority, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, normalizeStyleObject, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
132
+ declare function getUnit(value?: string): string | undefined;
133
+ declare function toPx(value?: string | number): string | undefined;
134
+ declare function toEm(value?: string, fontSize?: number): string | undefined;
135
+ declare function toRem(value?: string): string | undefined;
136
+
137
+ export { CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, assign, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPropertyPriority, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-4wnn7ulW.js';
2
- export { x as WalkObjectOptions, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, a as isBoolean, b as isFunction, j as isImportant, c as isObject, i as isString, z as mapObject, m as markImportant, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, w as withoutImportant, k as withoutSpace } from './shared-4wnn7ulW.js';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-5yRolXii.js';
2
+ export { x as WalkObjectOptions, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, j as hypenateProperty, g as isBaseCondition, a as isBoolean, b as isFunction, k as isImportant, c as isObject, i as isString, z as mapObject, m as markImportant, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, w as withoutImportant, l as withoutSpace } from './shared-5yRolXii.js';
3
3
  export { astish } from './astish.js';
4
4
 
5
5
  declare const getArbitraryValue: (_value: string) => string;
6
6
 
7
+ declare function assign(target: any, ...sources: any[]): any;
8
+
7
9
  type Operand = string | number | {
8
10
  ref: string;
9
11
  };
@@ -17,11 +19,6 @@ declare const capitalize: (s: string) => string;
17
19
  declare const dashCase: (s: string) => string;
18
20
  declare const uncapitalize: (s: string) => string;
19
21
 
20
- declare function getUnit(value?: string): string | undefined;
21
- declare function toPx(value?: string | number): string | undefined;
22
- declare function toEm(value?: string, fontSize?: number): string | undefined;
23
- declare function toRem(value?: string): string | undefined;
24
-
25
22
  interface CssVar {
26
23
  var: `--${string}`;
27
24
  ref: string;
@@ -69,10 +66,14 @@ declare const isCssUnit: (v: unknown) => boolean;
69
66
 
70
67
  declare const isCssVar: (v: unknown) => boolean;
71
68
 
69
+ declare function mergeWith(target: any, ...sources: any[]): any;
70
+
72
71
  type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
73
72
  declare function toResponsiveObject(values: string[], breakpoints: string[]): Record<string, string>;
74
73
  declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext, shorthand?: boolean): MappedObject<Record<string, any>, any>;
75
74
 
75
+ declare const omit: <T, K extends (string & {}) | keyof T>(obj: T, paths: K[]) => Omit<T, K>;
76
+
76
77
  declare const createRegex: (item: Array<string | RegExp>) => RegExp;
77
78
 
78
79
  declare const stringifyJson: (config: Record<string, any>) => string;
@@ -128,4 +129,9 @@ declare function traverse(obj: any, callback: CallbackFn, options?: TraverseOpti
128
129
 
129
130
  declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
130
131
 
131
- export { CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPropertyPriority, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, normalizeStyleObject, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
132
+ declare function getUnit(value?: string): string | undefined;
133
+ declare function toPx(value?: string | number): string | undefined;
134
+ declare function toEm(value?: string, fontSize?: number): string | undefined;
135
+ declare function toRem(value?: string): string | undefined;
136
+
137
+ export { CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PandaError, type PandaErrorCode, WalkObjectStopFn, assign, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, deepSet, entries, esc, flatten, fromEntries, getArbitraryValue, getDotPath, getNegativePath, getOrCreateSet, getPropertyPriority, getUnit, isCssFunction, isCssUnit, isCssVar, isObjectOrArray, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  PandaError: () => PandaError,
24
+ assign: () => assign,
24
25
  astish: () => astish,
25
26
  calc: () => calc,
26
27
  camelCaseProperty: () => camelCaseProperty,
@@ -63,7 +64,9 @@ __export(src_exports, {
63
64
  markImportant: () => markImportant,
64
65
  memo: () => memo,
65
66
  mergeProps: () => mergeProps,
67
+ mergeWith: () => mergeWith,
66
68
  normalizeStyleObject: () => normalizeStyleObject,
69
+ omit: () => omit,
67
70
  parseJson: () => parseJson,
68
71
  patternFns: () => patternFns,
69
72
  splitBy: () => splitBy,
@@ -118,6 +121,18 @@ function isObject(value) {
118
121
  return typeof value === "object" && value != null && !Array.isArray(value);
119
122
  }
120
123
 
124
+ // src/assign.ts
125
+ function assign(target, ...sources) {
126
+ for (const source of sources) {
127
+ for (const key in source) {
128
+ if (!target?.hasOwnProperty?.(key)) {
129
+ target[key] = source[key];
130
+ }
131
+ }
132
+ }
133
+ return target;
134
+ }
135
+
121
136
  // src/astish.ts
122
137
  var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
123
138
  var ruleClean = /\/\*[^]*?\*\/| +/g;
@@ -393,60 +408,6 @@ function createMergeCss(context) {
393
408
  return { mergeCss: memo(mergeCss), assignCss };
394
409
  }
395
410
 
396
- // src/unit-conversion.ts
397
- var BASE_FONT_SIZE = 16;
398
- var UNIT_PX = "px";
399
- var UNIT_EM = "em";
400
- var UNIT_REM = "rem";
401
- function getUnit(value = "") {
402
- const DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
403
- const UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
404
- const unit = value.match(new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`));
405
- return unit?.[1];
406
- }
407
- function toPx(value = "") {
408
- if (typeof value === "number") {
409
- return `${value}px`;
410
- }
411
- const unit = getUnit(value);
412
- if (!unit)
413
- return value;
414
- if (unit === UNIT_PX) {
415
- return value;
416
- }
417
- if (unit === UNIT_EM || unit === UNIT_REM) {
418
- return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
419
- }
420
- }
421
- function toEm(value = "", fontSize = BASE_FONT_SIZE) {
422
- const unit = getUnit(value);
423
- if (!unit)
424
- return value;
425
- if (unit === UNIT_EM) {
426
- return value;
427
- }
428
- if (unit === UNIT_PX) {
429
- return `${parseFloat(value) / fontSize}${UNIT_EM}`;
430
- }
431
- if (unit === UNIT_REM) {
432
- return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
433
- }
434
- }
435
- function toRem(value = "") {
436
- const unit = getUnit(value);
437
- if (!unit)
438
- return value;
439
- if (unit === UNIT_REM) {
440
- return value;
441
- }
442
- if (unit === UNIT_EM) {
443
- return `${parseFloat(value)}${UNIT_REM}`;
444
- }
445
- if (unit === UNIT_PX) {
446
- return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
447
- }
448
- }
449
-
450
411
  // src/css-var.ts
451
412
  var escRegex = /[^a-zA-Z0-9_\u0081-\uffff-]/g;
452
413
  function esc(string) {
@@ -593,6 +554,75 @@ var isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
593
554
  // src/is-css-var.ts
594
555
  var isCssVar2 = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
595
556
 
557
+ // src/merge-with.ts
558
+ function mergeWith(target, ...sources) {
559
+ const customizer = sources.pop();
560
+ for (const source of sources) {
561
+ for (const key in source) {
562
+ const merged = customizer(target[key], source[key]);
563
+ if (merged === void 0) {
564
+ if (isObject(target[key]) && isObject(source[key])) {
565
+ target[key] = mergeWith({}, target[key], source[key], customizer);
566
+ } else {
567
+ target[key] = source[key];
568
+ }
569
+ } else {
570
+ target[key] = merged;
571
+ }
572
+ }
573
+ }
574
+ return target;
575
+ }
576
+
577
+ // src/traverse.ts
578
+ var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
579
+ var defaultOptions = {
580
+ separator: ".",
581
+ maxDepth: Infinity
582
+ };
583
+ function traverse(obj, callback2, options = defaultOptions) {
584
+ const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
585
+ const separator = options.separator ?? defaultOptions.separator;
586
+ const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
587
+ while (stack.length > 0) {
588
+ const currentItem = stack.pop();
589
+ if (currentItem.parent !== null) {
590
+ callback2(currentItem);
591
+ }
592
+ if (options.stop?.(currentItem)) {
593
+ continue;
594
+ }
595
+ if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
596
+ const keys = Object.keys(currentItem.value);
597
+ for (let i = keys.length - 1; i >= 0; i--) {
598
+ const key = keys[i];
599
+ const value = currentItem.value[key];
600
+ const path = currentItem.path ? currentItem.path + separator + key : key;
601
+ const paths = currentItem.paths.concat(key);
602
+ stack.push({
603
+ value,
604
+ path,
605
+ paths,
606
+ depth: currentItem.depth + 1,
607
+ parent: currentItem.value,
608
+ key
609
+ });
610
+ }
611
+ }
612
+ }
613
+ }
614
+
615
+ // src/omit.ts
616
+ var omit = (obj, paths) => {
617
+ const result = { ...obj };
618
+ traverse(result, ({ path, parent, key }) => {
619
+ if (paths.includes(path)) {
620
+ delete parent[key];
621
+ }
622
+ });
623
+ return result;
624
+ };
625
+
596
626
  // src/pattern-fns.ts
597
627
  var patternFns = {
598
628
  map: mapObject,
@@ -850,44 +880,6 @@ function mapToJson(map) {
850
880
  return obj;
851
881
  }
852
882
 
853
- // src/traverse.ts
854
- var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
855
- var defaultOptions = {
856
- separator: ".",
857
- maxDepth: Infinity
858
- };
859
- function traverse(obj, callback2, options = defaultOptions) {
860
- const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
861
- const separator = options.separator ?? defaultOptions.separator;
862
- const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
863
- while (stack.length > 0) {
864
- const currentItem = stack.pop();
865
- if (currentItem.parent !== null) {
866
- callback2(currentItem);
867
- }
868
- if (options.stop?.(currentItem)) {
869
- continue;
870
- }
871
- if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
872
- const keys = Object.keys(currentItem.value);
873
- for (let i = keys.length - 1; i >= 0; i--) {
874
- const key = keys[i];
875
- const value = currentItem.value[key];
876
- const path = currentItem.path ? currentItem.path + separator + key : key;
877
- const paths = currentItem.paths.concat(key);
878
- stack.push({
879
- value,
880
- path,
881
- paths,
882
- depth: currentItem.depth + 1,
883
- parent: currentItem.value,
884
- key
885
- });
886
- }
887
- }
888
- }
889
- }
890
-
891
883
  // src/typegen.ts
892
884
  function unionType(values) {
893
885
  return Array.from(values).map((value) => JSON.stringify(value)).join(" | ");
@@ -895,9 +887,64 @@ function unionType(values) {
895
887
 
896
888
  // src/uniq.ts
897
889
  var uniq = (...items) => items.filter(Boolean).reduce((acc, item) => Array.from(/* @__PURE__ */ new Set([...acc, ...item])), []);
890
+
891
+ // src/unit-conversion.ts
892
+ var BASE_FONT_SIZE = 16;
893
+ var UNIT_PX = "px";
894
+ var UNIT_EM = "em";
895
+ var UNIT_REM = "rem";
896
+ function getUnit(value = "") {
897
+ const DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
898
+ const UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
899
+ const unit = value.match(new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`));
900
+ return unit?.[1];
901
+ }
902
+ function toPx(value = "") {
903
+ if (typeof value === "number") {
904
+ return `${value}px`;
905
+ }
906
+ const unit = getUnit(value);
907
+ if (!unit)
908
+ return value;
909
+ if (unit === UNIT_PX) {
910
+ return value;
911
+ }
912
+ if (unit === UNIT_EM || unit === UNIT_REM) {
913
+ return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
914
+ }
915
+ }
916
+ function toEm(value = "", fontSize = BASE_FONT_SIZE) {
917
+ const unit = getUnit(value);
918
+ if (!unit)
919
+ return value;
920
+ if (unit === UNIT_EM) {
921
+ return value;
922
+ }
923
+ if (unit === UNIT_PX) {
924
+ return `${parseFloat(value) / fontSize}${UNIT_EM}`;
925
+ }
926
+ if (unit === UNIT_REM) {
927
+ return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
928
+ }
929
+ }
930
+ function toRem(value = "") {
931
+ const unit = getUnit(value);
932
+ if (!unit)
933
+ return value;
934
+ if (unit === UNIT_REM) {
935
+ return value;
936
+ }
937
+ if (unit === UNIT_EM) {
938
+ return `${parseFloat(value)}${UNIT_REM}`;
939
+ }
940
+ if (unit === UNIT_PX) {
941
+ return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
942
+ }
943
+ }
898
944
  // Annotate the CommonJS export names for ESM import in node:
899
945
  0 && (module.exports = {
900
946
  PandaError,
947
+ assign,
901
948
  astish,
902
949
  calc,
903
950
  camelCaseProperty,
@@ -940,7 +987,9 @@ var uniq = (...items) => items.filter(Boolean).reduce((acc, item) => Array.from(
940
987
  markImportant,
941
988
  memo,
942
989
  mergeProps,
990
+ mergeWith,
943
991
  normalizeStyleObject,
992
+ omit,
944
993
  parseJson,
945
994
  patternFns,
946
995
  splitBy,
package/dist/index.mjs CHANGED
@@ -31,6 +31,18 @@ function isObject(value) {
31
31
  return typeof value === "object" && value != null && !Array.isArray(value);
32
32
  }
33
33
 
34
+ // src/assign.ts
35
+ function assign(target, ...sources) {
36
+ for (const source of sources) {
37
+ for (const key in source) {
38
+ if (!target?.hasOwnProperty?.(key)) {
39
+ target[key] = source[key];
40
+ }
41
+ }
42
+ }
43
+ return target;
44
+ }
45
+
34
46
  // src/astish.ts
35
47
  var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
36
48
  var ruleClean = /\/\*[^]*?\*\/| +/g;
@@ -306,60 +318,6 @@ function createMergeCss(context) {
306
318
  return { mergeCss: memo(mergeCss), assignCss };
307
319
  }
308
320
 
309
- // src/unit-conversion.ts
310
- var BASE_FONT_SIZE = 16;
311
- var UNIT_PX = "px";
312
- var UNIT_EM = "em";
313
- var UNIT_REM = "rem";
314
- function getUnit(value = "") {
315
- const DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
316
- const UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
317
- const unit = value.match(new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`));
318
- return unit?.[1];
319
- }
320
- function toPx(value = "") {
321
- if (typeof value === "number") {
322
- return `${value}px`;
323
- }
324
- const unit = getUnit(value);
325
- if (!unit)
326
- return value;
327
- if (unit === UNIT_PX) {
328
- return value;
329
- }
330
- if (unit === UNIT_EM || unit === UNIT_REM) {
331
- return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
332
- }
333
- }
334
- function toEm(value = "", fontSize = BASE_FONT_SIZE) {
335
- const unit = getUnit(value);
336
- if (!unit)
337
- return value;
338
- if (unit === UNIT_EM) {
339
- return value;
340
- }
341
- if (unit === UNIT_PX) {
342
- return `${parseFloat(value) / fontSize}${UNIT_EM}`;
343
- }
344
- if (unit === UNIT_REM) {
345
- return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
346
- }
347
- }
348
- function toRem(value = "") {
349
- const unit = getUnit(value);
350
- if (!unit)
351
- return value;
352
- if (unit === UNIT_REM) {
353
- return value;
354
- }
355
- if (unit === UNIT_EM) {
356
- return `${parseFloat(value)}${UNIT_REM}`;
357
- }
358
- if (unit === UNIT_PX) {
359
- return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
360
- }
361
- }
362
-
363
321
  // src/css-var.ts
364
322
  var escRegex = /[^a-zA-Z0-9_\u0081-\uffff-]/g;
365
323
  function esc(string) {
@@ -506,6 +464,75 @@ var isCssUnit = (v) => typeof v === "string" && lengthRegExp.test(v);
506
464
  // src/is-css-var.ts
507
465
  var isCssVar2 = (v) => typeof v === "string" && /^var\(--.+\)$/.test(v);
508
466
 
467
+ // src/merge-with.ts
468
+ function mergeWith(target, ...sources) {
469
+ const customizer = sources.pop();
470
+ for (const source of sources) {
471
+ for (const key in source) {
472
+ const merged = customizer(target[key], source[key]);
473
+ if (merged === void 0) {
474
+ if (isObject(target[key]) && isObject(source[key])) {
475
+ target[key] = mergeWith({}, target[key], source[key], customizer);
476
+ } else {
477
+ target[key] = source[key];
478
+ }
479
+ } else {
480
+ target[key] = merged;
481
+ }
482
+ }
483
+ }
484
+ return target;
485
+ }
486
+
487
+ // src/traverse.ts
488
+ var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
489
+ var defaultOptions = {
490
+ separator: ".",
491
+ maxDepth: Infinity
492
+ };
493
+ function traverse(obj, callback2, options = defaultOptions) {
494
+ const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
495
+ const separator = options.separator ?? defaultOptions.separator;
496
+ const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
497
+ while (stack.length > 0) {
498
+ const currentItem = stack.pop();
499
+ if (currentItem.parent !== null) {
500
+ callback2(currentItem);
501
+ }
502
+ if (options.stop?.(currentItem)) {
503
+ continue;
504
+ }
505
+ if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
506
+ const keys = Object.keys(currentItem.value);
507
+ for (let i = keys.length - 1; i >= 0; i--) {
508
+ const key = keys[i];
509
+ const value = currentItem.value[key];
510
+ const path = currentItem.path ? currentItem.path + separator + key : key;
511
+ const paths = currentItem.paths.concat(key);
512
+ stack.push({
513
+ value,
514
+ path,
515
+ paths,
516
+ depth: currentItem.depth + 1,
517
+ parent: currentItem.value,
518
+ key
519
+ });
520
+ }
521
+ }
522
+ }
523
+ }
524
+
525
+ // src/omit.ts
526
+ var omit = (obj, paths) => {
527
+ const result = { ...obj };
528
+ traverse(result, ({ path, parent, key }) => {
529
+ if (paths.includes(path)) {
530
+ delete parent[key];
531
+ }
532
+ });
533
+ return result;
534
+ };
535
+
509
536
  // src/pattern-fns.ts
510
537
  var patternFns = {
511
538
  map: mapObject,
@@ -763,44 +790,6 @@ function mapToJson(map) {
763
790
  return obj;
764
791
  }
765
792
 
766
- // src/traverse.ts
767
- var isObjectOrArray = (obj) => typeof obj === "object" && obj !== null;
768
- var defaultOptions = {
769
- separator: ".",
770
- maxDepth: Infinity
771
- };
772
- function traverse(obj, callback2, options = defaultOptions) {
773
- const maxDepth = options.maxDepth ?? defaultOptions.maxDepth;
774
- const separator = options.separator ?? defaultOptions.separator;
775
- const stack = [{ value: obj, path: "", paths: [], depth: -1, parent: null, key: "" }];
776
- while (stack.length > 0) {
777
- const currentItem = stack.pop();
778
- if (currentItem.parent !== null) {
779
- callback2(currentItem);
780
- }
781
- if (options.stop?.(currentItem)) {
782
- continue;
783
- }
784
- if (isObjectOrArray(currentItem.value) && currentItem.depth < maxDepth) {
785
- const keys = Object.keys(currentItem.value);
786
- for (let i = keys.length - 1; i >= 0; i--) {
787
- const key = keys[i];
788
- const value = currentItem.value[key];
789
- const path = currentItem.path ? currentItem.path + separator + key : key;
790
- const paths = currentItem.paths.concat(key);
791
- stack.push({
792
- value,
793
- path,
794
- paths,
795
- depth: currentItem.depth + 1,
796
- parent: currentItem.value,
797
- key
798
- });
799
- }
800
- }
801
- }
802
- }
803
-
804
793
  // src/typegen.ts
805
794
  function unionType(values) {
806
795
  return Array.from(values).map((value) => JSON.stringify(value)).join(" | ");
@@ -808,8 +797,63 @@ function unionType(values) {
808
797
 
809
798
  // src/uniq.ts
810
799
  var uniq = (...items) => items.filter(Boolean).reduce((acc, item) => Array.from(/* @__PURE__ */ new Set([...acc, ...item])), []);
800
+
801
+ // src/unit-conversion.ts
802
+ var BASE_FONT_SIZE = 16;
803
+ var UNIT_PX = "px";
804
+ var UNIT_EM = "em";
805
+ var UNIT_REM = "rem";
806
+ function getUnit(value = "") {
807
+ const DIGIT_REGEX = new RegExp(String.raw`-?\d+(?:\.\d+|\d*)`);
808
+ const UNIT_REGEX = new RegExp(`${UNIT_PX}|${UNIT_EM}|${UNIT_REM}`);
809
+ const unit = value.match(new RegExp(`${DIGIT_REGEX.source}(${UNIT_REGEX.source})`));
810
+ return unit?.[1];
811
+ }
812
+ function toPx(value = "") {
813
+ if (typeof value === "number") {
814
+ return `${value}px`;
815
+ }
816
+ const unit = getUnit(value);
817
+ if (!unit)
818
+ return value;
819
+ if (unit === UNIT_PX) {
820
+ return value;
821
+ }
822
+ if (unit === UNIT_EM || unit === UNIT_REM) {
823
+ return `${parseFloat(value) * BASE_FONT_SIZE}${UNIT_PX}`;
824
+ }
825
+ }
826
+ function toEm(value = "", fontSize = BASE_FONT_SIZE) {
827
+ const unit = getUnit(value);
828
+ if (!unit)
829
+ return value;
830
+ if (unit === UNIT_EM) {
831
+ return value;
832
+ }
833
+ if (unit === UNIT_PX) {
834
+ return `${parseFloat(value) / fontSize}${UNIT_EM}`;
835
+ }
836
+ if (unit === UNIT_REM) {
837
+ return `${parseFloat(value) * BASE_FONT_SIZE / fontSize}${UNIT_EM}`;
838
+ }
839
+ }
840
+ function toRem(value = "") {
841
+ const unit = getUnit(value);
842
+ if (!unit)
843
+ return value;
844
+ if (unit === UNIT_REM) {
845
+ return value;
846
+ }
847
+ if (unit === UNIT_EM) {
848
+ return `${parseFloat(value)}${UNIT_REM}`;
849
+ }
850
+ if (unit === UNIT_PX) {
851
+ return `${parseFloat(value) / BASE_FONT_SIZE}${UNIT_REM}`;
852
+ }
853
+ }
811
854
  export {
812
855
  PandaError,
856
+ assign,
813
857
  astish,
814
858
  calc,
815
859
  camelCaseProperty,
@@ -852,7 +896,9 @@ export {
852
896
  markImportant,
853
897
  memo,
854
898
  mergeProps,
899
+ mergeWith,
855
900
  normalizeStyleObject,
901
+ omit,
856
902
  parseJson,
857
903
  patternFns,
858
904
  splitBy,
@@ -43,12 +43,6 @@ declare function compact<T extends Record<string, any>>(value: T): T;
43
43
  declare const isBaseCondition: (v: string) => boolean;
44
44
  declare function filterBaseConditions(c: string[]): string[];
45
45
 
46
- declare function isImportant<T extends string | number | boolean>(value: T): boolean;
47
- declare function withoutImportant<T extends string | number | boolean>(value: T): string | T;
48
- declare function withoutSpace<T extends string | number | boolean>(str: T): string | T;
49
- type Dict$1 = Record<string, unknown>;
50
- declare function markImportant(obj: Dict$1): {};
51
-
52
46
  type Predicate<R = any> = (value: any, path: string[]) => R;
53
47
  type MappedObject<T, K> = {
54
48
  [Prop in keyof T]: T[Prop] extends Array<any> ? MappedObject<T[Prop][number], K>[] : T[Prop] extends Record<string, unknown> ? MappedObject<T[Prop], K> : K;
@@ -65,6 +59,12 @@ declare function toHash(value: string): string;
65
59
 
66
60
  declare const hypenateProperty: (property: string) => string;
67
61
 
62
+ declare function isImportant<T extends string | number | boolean>(value: T): boolean;
63
+ declare function withoutImportant<T extends string | number | boolean>(value: T): string | T;
64
+ declare function withoutSpace<T extends string | number | boolean>(str: T): string | T;
65
+ type Dict$1 = Record<string, unknown>;
66
+ declare function markImportant(obj: Dict$1): {};
67
+
68
68
  declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
69
69
 
70
70
  declare function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T;
@@ -91,4 +91,4 @@ declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
91
91
 
92
92
  declare const uniq: <T>(...items: T[][]) => T[];
93
93
 
94
- export { type CreateCssContext as C, type MappedObject as M, type WalkObjectStopFn as W, isBoolean as a, isFunction as b, isObject 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, markImportant as m, memo as n, mergeProps as o, patternFns as p, getPatternStyles as q, getSlotRecipes as r, getSlotCompoundVariant as s, toHash as t, splitProps as u, uniq as v, withoutImportant as w, type WalkObjectOptions as x, walkObject as y, mapObject as z };
94
+ export { type CreateCssContext as C, type MappedObject as M, type WalkObjectStopFn as W, isBoolean as a, isFunction as b, isObject as c, createCss as d, createMergeCss as e, compact as f, isBaseCondition as g, filterBaseConditions as h, isString as i, hypenateProperty as j, isImportant as k, withoutSpace as l, markImportant as m, memo as n, mergeProps as o, patternFns as p, getPatternStyles as q, getSlotRecipes as r, getSlotCompoundVariant as s, toHash as t, splitProps as u, uniq as v, withoutImportant as w, type WalkObjectOptions as x, walkObject as y, mapObject as z };
@@ -43,12 +43,6 @@ declare function compact<T extends Record<string, any>>(value: T): T;
43
43
  declare const isBaseCondition: (v: string) => boolean;
44
44
  declare function filterBaseConditions(c: string[]): string[];
45
45
 
46
- declare function isImportant<T extends string | number | boolean>(value: T): boolean;
47
- declare function withoutImportant<T extends string | number | boolean>(value: T): string | T;
48
- declare function withoutSpace<T extends string | number | boolean>(str: T): string | T;
49
- type Dict$1 = Record<string, unknown>;
50
- declare function markImportant(obj: Dict$1): {};
51
-
52
46
  type Predicate<R = any> = (value: any, path: string[]) => R;
53
47
  type MappedObject<T, K> = {
54
48
  [Prop in keyof T]: T[Prop] extends Array<any> ? MappedObject<T[Prop][number], K>[] : T[Prop] extends Record<string, unknown> ? MappedObject<T[Prop], K> : K;
@@ -65,6 +59,12 @@ declare function toHash(value: string): string;
65
59
 
66
60
  declare const hypenateProperty: (property: string) => string;
67
61
 
62
+ declare function isImportant<T extends string | number | boolean>(value: T): boolean;
63
+ declare function withoutImportant<T extends string | number | boolean>(value: T): string | T;
64
+ declare function withoutSpace<T extends string | number | boolean>(str: T): string | T;
65
+ type Dict$1 = Record<string, unknown>;
66
+ declare function markImportant(obj: Dict$1): {};
67
+
68
68
  declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
69
69
 
70
70
  declare function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T;
@@ -91,4 +91,4 @@ declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
91
91
 
92
92
  declare const uniq: <T>(...items: T[][]) => T[];
93
93
 
94
- export { type CreateCssContext as C, type MappedObject as M, type WalkObjectStopFn as W, isBoolean as a, isFunction as b, isObject 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, markImportant as m, memo as n, mergeProps as o, patternFns as p, getPatternStyles as q, getSlotRecipes as r, getSlotCompoundVariant as s, toHash as t, splitProps as u, uniq as v, withoutImportant as w, type WalkObjectOptions as x, walkObject as y, mapObject as z };
94
+ export { type CreateCssContext as C, type MappedObject as M, type WalkObjectStopFn as W, isBoolean as a, isFunction as b, isObject as c, createCss as d, createMergeCss as e, compact as f, isBaseCondition as g, filterBaseConditions as h, isString as i, hypenateProperty as j, isImportant as k, withoutSpace as l, markImportant as m, memo as n, mergeProps as o, patternFns as p, getPatternStyles as q, getSlotRecipes as r, getSlotCompoundVariant as s, toHash as t, splitProps as u, uniq as v, withoutImportant as w, type WalkObjectOptions as x, walkObject as y, mapObject as z };
package/dist/shared.d.mts CHANGED
@@ -1 +1 @@
1
- export { f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, c as isObject, z as mapObject, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, k as withoutSpace } from './shared-4wnn7ulW.mjs';
1
+ export { f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, j as hypenateProperty, g as isBaseCondition, c as isObject, z as mapObject, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, l as withoutSpace } from './shared-5yRolXii.mjs';
package/dist/shared.d.ts CHANGED
@@ -1 +1 @@
1
- export { f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, c as isObject, z as mapObject, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, k as withoutSpace } from './shared-4wnn7ulW.js';
1
+ export { f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, q as getPatternStyles, s as getSlotCompoundVariant, r as getSlotRecipes, j as hypenateProperty, g as isBaseCondition, c as isObject, z as mapObject, n as memo, o as mergeProps, p as patternFns, u as splitProps, t as toHash, v as uniq, y as walkObject, l as withoutSpace } from './shared-5yRolXii.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",