@pandacss/config 0.37.1 → 0.38.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.
@@ -1,5 +1,5 @@
1
1
  // src/merge-config.ts
2
- import { assign, isObject, mergeWith, traverse } from "@pandacss/shared";
2
+ import { assign, mergeWith, walkObject } from "@pandacss/shared";
3
3
  import { mergeAndConcat } from "merge-anything";
4
4
 
5
5
  // src/merge-hooks.ts
@@ -115,6 +115,37 @@ var tryCatch = (name, fn) => {
115
115
  };
116
116
  };
117
117
 
118
+ // src/validation/utils.ts
119
+ import { isObject, isString } from "@pandacss/shared";
120
+ var REFERENCE_REGEX = /({([^}]*)})/g;
121
+ var curlyBracketRegex = /[{}]/g;
122
+ var isValidToken = (token) => isObject(token) && Object.hasOwnProperty.call(token, "value");
123
+ var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
124
+ var formatPath = (path) => path;
125
+ var SEP = ".";
126
+ function getReferences(value) {
127
+ if (typeof value !== "string")
128
+ return [];
129
+ const matches = value.match(REFERENCE_REGEX);
130
+ if (!matches)
131
+ return [];
132
+ return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
133
+ return value2.trim().split("/")[0];
134
+ });
135
+ }
136
+ var serializeTokenValue = (value) => {
137
+ if (isString(value)) {
138
+ return value;
139
+ }
140
+ if (isObject(value)) {
141
+ return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
142
+ }
143
+ if (Array.isArray(value)) {
144
+ return value.map((v) => serializeTokenValue(v)).join(" ");
145
+ }
146
+ return value.toString();
147
+ };
148
+
118
149
  // src/merge-config.ts
119
150
  function getExtends(items) {
120
151
  return items.reduce((merged, { extend }) => {
@@ -155,7 +186,7 @@ var compact = (obj) => {
155
186
  return acc;
156
187
  }, {});
157
188
  };
158
- var tokenKeys = ["description", "extensions", "type", "value"];
189
+ var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
159
190
  function mergeConfigs(configs) {
160
191
  const [userConfig] = configs;
161
192
  const pluginHooks = userConfig.plugins ?? [];
@@ -178,18 +209,23 @@ function mergeConfigs(configs) {
178
209
  );
179
210
  const withoutEmpty = compact(mergedResult);
180
211
  if (withoutEmpty.theme?.tokens) {
181
- traverse(withoutEmpty.theme.tokens, (args) => args, {
182
- stop(args) {
183
- if (isObject(args.value) && "value" in args.value) {
184
- const keys = Object.keys(args.value);
185
- if (keys.filter((k) => !tokenKeys.includes(k)).length) {
186
- const { type: _type, description: _description, extensions: _extensions, value, DEFAULT } = args.value;
187
- args.value.DEFAULT = { value: DEFAULT?.value ?? value };
188
- delete args.value.value;
189
- }
190
- return true;
212
+ walkObject(withoutEmpty.theme.tokens, (args) => args, {
213
+ stop(token) {
214
+ if (!isValidToken(token))
215
+ return false;
216
+ const keys = Object.keys(token);
217
+ const nestedKeys = keys.filter((k) => !tokenKeys.includes(k));
218
+ const nested = nestedKeys.length > 0;
219
+ if (nested) {
220
+ token.DEFAULT ||= {};
221
+ tokenKeys.forEach((key) => {
222
+ if (token[key] == null)
223
+ return;
224
+ token.DEFAULT[key] ||= token[key];
225
+ delete token[key];
226
+ });
191
227
  }
192
- return false;
228
+ return true;
193
229
  }
194
230
  });
195
231
  }
@@ -197,5 +233,11 @@ function mergeConfigs(configs) {
197
233
  }
198
234
 
199
235
  export {
236
+ isValidToken,
237
+ isTokenReference,
238
+ formatPath,
239
+ SEP,
240
+ getReferences,
241
+ serializeTokenValue,
200
242
  mergeConfigs
201
243
  };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
2
  import { Config, ConfigTsOptions, LoadConfigResult } from '@pandacss/types';
3
3
  export { diffConfigs } from './diff-config.mjs';
4
- import { P as PathMapping } from './ts-config-paths-2lh9mwzL.mjs';
5
- export { c as convertTsPathsToRegexes } from './ts-config-paths-2lh9mwzL.mjs';
4
+ import { P as PathMapping } from './ts-config-paths-qwrwgu2Q.mjs';
5
+ export { c as convertTsPathsToRegexes } from './ts-config-paths-qwrwgu2Q.mjs';
6
6
  import { TSConfig } from 'pkg-types';
7
7
  export { mergeConfigs } from './merge-config.mjs';
8
8
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
2
  import { Config, ConfigTsOptions, LoadConfigResult } from '@pandacss/types';
3
3
  export { diffConfigs } from './diff-config.js';
4
- import { P as PathMapping } from './ts-config-paths-2lh9mwzL.js';
5
- export { c as convertTsPathsToRegexes } from './ts-config-paths-2lh9mwzL.js';
4
+ import { P as PathMapping } from './ts-config-paths-qwrwgu2Q.js';
5
+ export { c as convertTsPathsToRegexes } from './ts-config-paths-qwrwgu2Q.js';
6
6
  import { TSConfig } from 'pkg-types';
7
7
  export { mergeConfigs } from './merge-config.js';
8
8
 
package/dist/index.js CHANGED
@@ -382,7 +382,7 @@ function getConfigDependencies(filePath, tsOptions = { pathMappings: [] }, compi
382
382
  }
383
383
 
384
384
  // src/merge-config.ts
385
- var import_shared4 = require("@pandacss/shared");
385
+ var import_shared5 = require("@pandacss/shared");
386
386
  var import_merge_anything = require("merge-anything");
387
387
 
388
388
  // src/merge-hooks.ts
@@ -498,12 +498,43 @@ var tryCatch = (name, fn) => {
498
498
  };
499
499
  };
500
500
 
501
+ // src/validation/utils.ts
502
+ var import_shared4 = require("@pandacss/shared");
503
+ var REFERENCE_REGEX = /({([^}]*)})/g;
504
+ var curlyBracketRegex = /[{}]/g;
505
+ var isValidToken = (token) => (0, import_shared4.isObject)(token) && Object.hasOwnProperty.call(token, "value");
506
+ var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
507
+ var formatPath = (path2) => path2;
508
+ var SEP = ".";
509
+ function getReferences(value) {
510
+ if (typeof value !== "string")
511
+ return [];
512
+ const matches = value.match(REFERENCE_REGEX);
513
+ if (!matches)
514
+ return [];
515
+ return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
516
+ return value2.trim().split("/")[0];
517
+ });
518
+ }
519
+ var serializeTokenValue = (value) => {
520
+ if ((0, import_shared4.isString)(value)) {
521
+ return value;
522
+ }
523
+ if ((0, import_shared4.isObject)(value)) {
524
+ return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
525
+ }
526
+ if (Array.isArray(value)) {
527
+ return value.map((v) => serializeTokenValue(v)).join(" ");
528
+ }
529
+ return value.toString();
530
+ };
531
+
501
532
  // src/merge-config.ts
502
533
  function getExtends(items) {
503
534
  return items.reduce((merged, { extend }) => {
504
535
  if (!extend)
505
536
  return merged;
506
- return (0, import_shared4.mergeWith)(merged, extend, (originalValue, newValue) => {
537
+ return (0, import_shared5.mergeWith)(merged, extend, (originalValue, newValue) => {
507
538
  if (newValue === void 0) {
508
539
  return originalValue ?? [];
509
540
  }
@@ -519,13 +550,13 @@ function getExtends(items) {
519
550
  }
520
551
  function mergeRecords(records) {
521
552
  return {
522
- ...records.reduce((acc, record) => (0, import_shared4.assign)(acc, record), {}),
553
+ ...records.reduce((acc, record) => (0, import_shared5.assign)(acc, record), {}),
523
554
  extend: getExtends(records)
524
555
  };
525
556
  }
526
557
  function mergeExtensions(records) {
527
558
  const { extend = [], ...restProps } = mergeRecords(records);
528
- return (0, import_shared4.mergeWith)(restProps, extend, (obj, extensions) => {
559
+ return (0, import_shared5.mergeWith)(restProps, extend, (obj, extensions) => {
529
560
  return (0, import_merge_anything.mergeAndConcat)({}, obj, ...extensions);
530
561
  });
531
562
  }
@@ -538,14 +569,14 @@ var compact = (obj) => {
538
569
  return acc;
539
570
  }, {});
540
571
  };
541
- var tokenKeys = ["description", "extensions", "type", "value"];
572
+ var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
542
573
  function mergeConfigs(configs2) {
543
574
  const [userConfig] = configs2;
544
575
  const pluginHooks = userConfig.plugins ?? [];
545
576
  if (userConfig.hooks) {
546
577
  pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
547
578
  }
548
- const mergedResult = (0, import_shared4.assign)(
579
+ const mergedResult = (0, import_shared5.assign)(
549
580
  {
550
581
  conditions: mergeExtensions(configs2.map((config) => config.conditions ?? {})),
551
582
  theme: mergeExtensions(configs2.map((config) => config.theme ?? {})),
@@ -561,18 +592,23 @@ function mergeConfigs(configs2) {
561
592
  );
562
593
  const withoutEmpty = compact(mergedResult);
563
594
  if (withoutEmpty.theme?.tokens) {
564
- (0, import_shared4.traverse)(withoutEmpty.theme.tokens, (args) => args, {
565
- stop(args) {
566
- if ((0, import_shared4.isObject)(args.value) && "value" in args.value) {
567
- const keys = Object.keys(args.value);
568
- if (keys.filter((k) => !tokenKeys.includes(k)).length) {
569
- const { type: _type, description: _description, extensions: _extensions, value, DEFAULT } = args.value;
570
- args.value.DEFAULT = { value: DEFAULT?.value ?? value };
571
- delete args.value.value;
572
- }
573
- return true;
595
+ (0, import_shared5.walkObject)(withoutEmpty.theme.tokens, (args) => args, {
596
+ stop(token) {
597
+ if (!isValidToken(token))
598
+ return false;
599
+ const keys = Object.keys(token);
600
+ const nestedKeys = keys.filter((k) => !tokenKeys.includes(k));
601
+ const nested = nestedKeys.length > 0;
602
+ if (nested) {
603
+ token.DEFAULT ||= {};
604
+ tokenKeys.forEach((key) => {
605
+ if (token[key] == null)
606
+ return;
607
+ token.DEFAULT[key] ||= token[key];
608
+ delete token[key];
609
+ });
574
610
  }
575
- return false;
611
+ return true;
576
612
  }
577
613
  });
578
614
  }
@@ -638,14 +674,14 @@ var validateArtifactNames = (names, addError) => {
638
674
  };
639
675
 
640
676
  // src/validation/validate-breakpoints.ts
641
- var import_shared5 = require("@pandacss/shared");
677
+ var import_shared6 = require("@pandacss/shared");
642
678
  var validateBreakpoints = (breakpoints, addError) => {
643
679
  if (!breakpoints)
644
680
  return;
645
681
  const units = /* @__PURE__ */ new Set();
646
682
  const values = Object.values(breakpoints);
647
683
  for (const value of values) {
648
- const unit = (0, import_shared5.getUnit)(value) ?? "px";
684
+ const unit = (0, import_shared6.getUnit)(value) ?? "px";
649
685
  units.add(unit);
650
686
  }
651
687
  if (units.size > 1) {
@@ -654,12 +690,12 @@ var validateBreakpoints = (breakpoints, addError) => {
654
690
  };
655
691
 
656
692
  // src/validation/validate-condition.ts
657
- var import_shared6 = require("@pandacss/shared");
693
+ var import_shared7 = require("@pandacss/shared");
658
694
  var validateConditions = (conditions, addError) => {
659
695
  if (!conditions)
660
696
  return;
661
697
  Object.values(conditions).forEach((condition) => {
662
- if ((0, import_shared6.isString)(condition)) {
698
+ if ((0, import_shared7.isString)(condition)) {
663
699
  if (!condition.startsWith("@") && !condition.includes("&")) {
664
700
  addError("conditions", `Selectors should contain the \`&\` character: \`${condition}\``);
665
701
  }
@@ -706,37 +742,6 @@ var validateRecipes = (options) => {
706
742
  // src/validation/validate-tokens.ts
707
743
  var import_shared8 = require("@pandacss/shared");
708
744
 
709
- // src/validation/utils.ts
710
- var import_shared7 = require("@pandacss/shared");
711
- var REFERENCE_REGEX = /({([^}]*)})/g;
712
- var curlyBracketRegex = /[{}]/g;
713
- var isValidToken = (token) => Object.hasOwnProperty.call(token, "value");
714
- var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
715
- var formatPath = (path2) => path2;
716
- var SEP = ".";
717
- function getReferences(value) {
718
- if (typeof value !== "string")
719
- return [];
720
- const matches = value.match(REFERENCE_REGEX);
721
- if (!matches)
722
- return [];
723
- return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
724
- return value2.trim().split("/")[0];
725
- });
726
- }
727
- var serializeTokenValue = (value) => {
728
- if ((0, import_shared7.isString)(value)) {
729
- return value;
730
- }
731
- if ((0, import_shared7.isObject)(value)) {
732
- return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
733
- }
734
- if (Array.isArray(value)) {
735
- return value.map((v) => serializeTokenValue(v)).join(" ");
736
- }
737
- return value.toString();
738
- };
739
-
740
745
  // src/validation/validate-token-references.ts
741
746
  var validateTokenReferences = (props) => {
742
747
  const { valueAtPath, refsByPath, addError, typeByPath } = props;
package/dist/index.mjs CHANGED
@@ -1,6 +1,12 @@
1
1
  import {
2
- mergeConfigs
3
- } from "./chunk-GR4POVOJ.mjs";
2
+ SEP,
3
+ formatPath,
4
+ getReferences,
5
+ isTokenReference,
6
+ isValidToken,
7
+ mergeConfigs,
8
+ serializeTokenValue
9
+ } from "./chunk-F5ESIWB7.mjs";
4
10
  import {
5
11
  diffConfigs
6
12
  } from "./chunk-D3CL3VYD.mjs";
@@ -318,38 +324,7 @@ var validateRecipes = (options) => {
318
324
  };
319
325
 
320
326
  // src/validation/validate-tokens.ts
321
- import { isObject as isObject2, walkObject } from "@pandacss/shared";
322
-
323
- // src/validation/utils.ts
324
- import { isObject, isString as isString2 } from "@pandacss/shared";
325
- var REFERENCE_REGEX = /({([^}]*)})/g;
326
- var curlyBracketRegex = /[{}]/g;
327
- var isValidToken = (token) => Object.hasOwnProperty.call(token, "value");
328
- var isTokenReference = (value) => typeof value === "string" && REFERENCE_REGEX.test(value);
329
- var formatPath = (path2) => path2;
330
- var SEP = ".";
331
- function getReferences(value) {
332
- if (typeof value !== "string")
333
- return [];
334
- const matches = value.match(REFERENCE_REGEX);
335
- if (!matches)
336
- return [];
337
- return matches.map((match) => match.replace(curlyBracketRegex, "")).map((value2) => {
338
- return value2.trim().split("/")[0];
339
- });
340
- }
341
- var serializeTokenValue = (value) => {
342
- if (isString2(value)) {
343
- return value;
344
- }
345
- if (isObject(value)) {
346
- return Object.values(value).map((v) => serializeTokenValue(v)).join(" ");
347
- }
348
- if (Array.isArray(value)) {
349
- return value.map((v) => serializeTokenValue(v)).join(" ");
350
- }
351
- return value.toString();
352
- };
327
+ import { isObject, walkObject } from "@pandacss/shared";
353
328
 
354
329
  // src/validation/validate-token-references.ts
355
330
  var validateTokenReferences = (props) => {
@@ -488,7 +463,7 @@ var validateTokens = (options) => {
488
463
  addError("tokens", `Token key must not contain spaces: \`theme.tokens.${formattedPath}\``);
489
464
  return;
490
465
  }
491
- if (!isObject2(value) && !path2.includes("value")) {
466
+ if (!isObject(value) && !path2.includes("value")) {
492
467
  addError("tokens", `Token must contain 'value': \`theme.semanticTokens.${formattedPath}\``);
493
468
  }
494
469
  });
@@ -23,7 +23,7 @@ __export(merge_config_exports, {
23
23
  mergeConfigs: () => mergeConfigs
24
24
  });
25
25
  module.exports = __toCommonJS(merge_config_exports);
26
- var import_shared = require("@pandacss/shared");
26
+ var import_shared2 = require("@pandacss/shared");
27
27
  var import_merge_anything = require("merge-anything");
28
28
 
29
29
  // src/merge-hooks.ts
@@ -139,12 +139,16 @@ var tryCatch = (name, fn) => {
139
139
  };
140
140
  };
141
141
 
142
+ // src/validation/utils.ts
143
+ var import_shared = require("@pandacss/shared");
144
+ var isValidToken = (token) => (0, import_shared.isObject)(token) && Object.hasOwnProperty.call(token, "value");
145
+
142
146
  // src/merge-config.ts
143
147
  function getExtends(items) {
144
148
  return items.reduce((merged, { extend }) => {
145
149
  if (!extend)
146
150
  return merged;
147
- return (0, import_shared.mergeWith)(merged, extend, (originalValue, newValue) => {
151
+ return (0, import_shared2.mergeWith)(merged, extend, (originalValue, newValue) => {
148
152
  if (newValue === void 0) {
149
153
  return originalValue ?? [];
150
154
  }
@@ -160,13 +164,13 @@ function getExtends(items) {
160
164
  }
161
165
  function mergeRecords(records) {
162
166
  return {
163
- ...records.reduce((acc, record) => (0, import_shared.assign)(acc, record), {}),
167
+ ...records.reduce((acc, record) => (0, import_shared2.assign)(acc, record), {}),
164
168
  extend: getExtends(records)
165
169
  };
166
170
  }
167
171
  function mergeExtensions(records) {
168
172
  const { extend = [], ...restProps } = mergeRecords(records);
169
- return (0, import_shared.mergeWith)(restProps, extend, (obj, extensions) => {
173
+ return (0, import_shared2.mergeWith)(restProps, extend, (obj, extensions) => {
170
174
  return (0, import_merge_anything.mergeAndConcat)({}, obj, ...extensions);
171
175
  });
172
176
  }
@@ -179,14 +183,14 @@ var compact = (obj) => {
179
183
  return acc;
180
184
  }, {});
181
185
  };
182
- var tokenKeys = ["description", "extensions", "type", "value"];
186
+ var tokenKeys = ["description", "extensions", "type", "value", "deprecated"];
183
187
  function mergeConfigs(configs) {
184
188
  const [userConfig] = configs;
185
189
  const pluginHooks = userConfig.plugins ?? [];
186
190
  if (userConfig.hooks) {
187
191
  pluginHooks.push({ name: "__panda.config__", hooks: userConfig.hooks });
188
192
  }
189
- const mergedResult = (0, import_shared.assign)(
193
+ const mergedResult = (0, import_shared2.assign)(
190
194
  {
191
195
  conditions: mergeExtensions(configs.map((config) => config.conditions ?? {})),
192
196
  theme: mergeExtensions(configs.map((config) => config.theme ?? {})),
@@ -202,18 +206,23 @@ function mergeConfigs(configs) {
202
206
  );
203
207
  const withoutEmpty = compact(mergedResult);
204
208
  if (withoutEmpty.theme?.tokens) {
205
- (0, import_shared.traverse)(withoutEmpty.theme.tokens, (args) => args, {
206
- stop(args) {
207
- if ((0, import_shared.isObject)(args.value) && "value" in args.value) {
208
- const keys = Object.keys(args.value);
209
- if (keys.filter((k) => !tokenKeys.includes(k)).length) {
210
- const { type: _type, description: _description, extensions: _extensions, value, DEFAULT } = args.value;
211
- args.value.DEFAULT = { value: DEFAULT?.value ?? value };
212
- delete args.value.value;
213
- }
214
- return true;
209
+ (0, import_shared2.walkObject)(withoutEmpty.theme.tokens, (args) => args, {
210
+ stop(token) {
211
+ if (!isValidToken(token))
212
+ return false;
213
+ const keys = Object.keys(token);
214
+ const nestedKeys = keys.filter((k) => !tokenKeys.includes(k));
215
+ const nested = nestedKeys.length > 0;
216
+ if (nested) {
217
+ token.DEFAULT ||= {};
218
+ tokenKeys.forEach((key) => {
219
+ if (token[key] == null)
220
+ return;
221
+ token.DEFAULT[key] ||= token[key];
222
+ delete token[key];
223
+ });
215
224
  }
216
- return false;
225
+ return true;
217
226
  }
218
227
  });
219
228
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mergeConfigs
3
- } from "./chunk-GR4POVOJ.mjs";
3
+ } from "./chunk-F5ESIWB7.mjs";
4
4
  export {
5
5
  mergeConfigs
6
6
  };
@@ -1,4 +1,4 @@
1
- import { P as PathMapping } from './ts-config-paths-2lh9mwzL.mjs';
1
+ import { P as PathMapping } from './ts-config-paths-qwrwgu2Q.mjs';
2
2
 
3
3
  /**
4
4
  * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
@@ -1,4 +1,4 @@
1
- import { P as PathMapping } from './ts-config-paths-2lh9mwzL.js';
1
+ import { P as PathMapping } from './ts-config-paths-qwrwgu2Q.js';
2
2
 
3
3
  /**
4
4
  * @see https://github.com/aleclarson/vite-tsconfig-paths/blob/e8f0acf7adfcfbf77edbe937f64b4e5d39557ad0/src/index.ts#LL231C57-L231C57
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/config",
3
- "version": "0.37.1",
3
+ "version": "0.38.0",
4
4
  "description": "Find and load panda config",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -73,11 +73,11 @@
73
73
  "merge-anything": "5.1.7",
74
74
  "microdiff": "1.3.2",
75
75
  "typescript": "5.3.3",
76
- "@pandacss/logger": "0.37.1",
77
- "@pandacss/preset-base": "0.37.1",
78
- "@pandacss/preset-panda": "0.37.1",
79
- "@pandacss/shared": "0.37.1",
80
- "@pandacss/types": "0.37.1"
76
+ "@pandacss/logger": "0.38.0",
77
+ "@pandacss/preset-base": "0.38.0",
78
+ "@pandacss/preset-panda": "0.38.0",
79
+ "@pandacss/shared": "0.38.0",
80
+ "@pandacss/types": "0.38.0"
81
81
  },
82
82
  "devDependencies": {
83
83
  "pkg-types": "1.0.3"