@pandacss/shared 1.0.1 → 1.1.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
@@ -98,6 +98,8 @@ declare const omit: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) =
98
98
 
99
99
  declare const PANDA_CONFIG_NAME: "__panda.config__";
100
100
 
101
+ declare const pick: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) => Partial<T>;
102
+
101
103
  declare function getPropertyPriority(key: string): number;
102
104
 
103
105
  declare const createRegex: (item: Array<string | RegExp>) => RegExp;
@@ -141,4 +143,4 @@ declare function toPx(value?: string | number): string | undefined;
141
143
  declare function toEm(value?: string, fontSize?: number): string | undefined;
142
144
  declare function toRem(value?: string): string | undefined;
143
145
 
144
- export { CacheMap, CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PANDA_CONFIG_NAME, 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, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
146
+ export { CacheMap, CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PANDA_CONFIG_NAME, 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, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, pick, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
package/dist/index.d.ts CHANGED
@@ -98,6 +98,8 @@ declare const omit: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) =
98
98
 
99
99
  declare const PANDA_CONFIG_NAME: "__panda.config__";
100
100
 
101
+ declare const pick: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) => Partial<T>;
102
+
101
103
  declare function getPropertyPriority(key: string): number;
102
104
 
103
105
  declare const createRegex: (item: Array<string | RegExp>) => RegExp;
@@ -141,4 +143,4 @@ declare function toPx(value?: string | number): string | undefined;
141
143
  declare function toEm(value?: string, fontSize?: number): string | undefined;
142
144
  declare function toRem(value?: string): string | undefined;
143
145
 
144
- export { CacheMap, CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PANDA_CONFIG_NAME, 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, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
146
+ export { CacheMap, CreateCssContext, type CssVar, type CssVarOptions, type MapToRecord, MappedObject, PANDA_CONFIG_NAME, 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, mapEntries, mapToJson, mergeWith, normalizeStyleObject, omit, parseJson, pick, splitBy, splitDotPath, stringifyJson, toEm, toPx, toRem, toResponsiveObject, traverse, uncapitalize, unionType };
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ __export(index_exports, {
71
71
  omit: () => omit,
72
72
  parseJson: () => parseJson,
73
73
  patternFns: () => patternFns,
74
+ pick: () => pick,
74
75
  splitBy: () => splitBy,
75
76
  splitDotPath: () => splitDotPath,
76
77
  splitProps: () => splitProps,
@@ -697,6 +698,68 @@ var omit = (obj, paths) => {
697
698
  // src/panda-config-name.ts
698
699
  var PANDA_CONFIG_NAME = "__panda.config__";
699
700
 
701
+ // src/split.ts
702
+ function splitBy(value, separator = ",") {
703
+ const result = [];
704
+ let current = "";
705
+ let depth = 0;
706
+ for (let i = 0; i < value.length; i++) {
707
+ const char = value[i];
708
+ if (char === "(") {
709
+ depth++;
710
+ } else if (char === ")") {
711
+ depth--;
712
+ } else if (char === separator && depth === 0) {
713
+ result.push(current);
714
+ current = "";
715
+ continue;
716
+ }
717
+ current += char;
718
+ }
719
+ result.push(current);
720
+ return result;
721
+ }
722
+ function splitDotPath(path) {
723
+ return path.split(".").reduce((acc, curr) => {
724
+ const last = acc[acc.length - 1];
725
+ if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) {
726
+ acc[acc.length - 1] = `${last}.${curr}`;
727
+ } else {
728
+ acc.push(curr);
729
+ }
730
+ return acc;
731
+ }, []);
732
+ }
733
+ function getNegativePath(path) {
734
+ return path.slice(0, -1).concat(`-${path.at(-1)}`);
735
+ }
736
+ function getDotPath(obj, path, fallback) {
737
+ if (typeof path !== "string") return fallback;
738
+ const idx = path.indexOf(".");
739
+ if (idx === -1) {
740
+ return obj?.[path] ?? fallback;
741
+ }
742
+ const key = path.slice(0, idx);
743
+ const nextPath = path.slice(idx + 1);
744
+ const checkValue = obj?.[key]?.[nextPath];
745
+ if (checkValue) {
746
+ return checkValue;
747
+ }
748
+ return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
749
+ }
750
+
751
+ // src/pick.ts
752
+ var pick = (obj, paths) => {
753
+ const result = {};
754
+ traverse(obj, ({ path, value }) => {
755
+ if (paths.includes(path)) {
756
+ const pathParts = splitDotPath(path);
757
+ deepSet(result, pathParts, value);
758
+ }
759
+ });
760
+ return result;
761
+ };
762
+
700
763
  // src/pattern-fns.ts
701
764
  var patternFns = {
702
765
  map: mapObject,
@@ -1212,56 +1275,6 @@ var getSlotRecipes = (recipe = {}) => {
1212
1275
  };
1213
1276
  var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
1214
1277
 
1215
- // src/split.ts
1216
- function splitBy(value, separator = ",") {
1217
- const result = [];
1218
- let current = "";
1219
- let depth = 0;
1220
- for (let i = 0; i < value.length; i++) {
1221
- const char = value[i];
1222
- if (char === "(") {
1223
- depth++;
1224
- } else if (char === ")") {
1225
- depth--;
1226
- } else if (char === separator && depth === 0) {
1227
- result.push(current);
1228
- current = "";
1229
- continue;
1230
- }
1231
- current += char;
1232
- }
1233
- result.push(current);
1234
- return result;
1235
- }
1236
- function splitDotPath(path) {
1237
- return path.split(".").reduce((acc, curr) => {
1238
- const last = acc[acc.length - 1];
1239
- if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) {
1240
- acc[acc.length - 1] = `${last}.${curr}`;
1241
- } else {
1242
- acc.push(curr);
1243
- }
1244
- return acc;
1245
- }, []);
1246
- }
1247
- function getNegativePath(path) {
1248
- return path.slice(0, -1).concat(`-${path.at(-1)}`);
1249
- }
1250
- function getDotPath(obj, path, fallback) {
1251
- if (typeof path !== "string") return fallback;
1252
- const idx = path.indexOf(".");
1253
- if (idx === -1) {
1254
- return obj?.[path] ?? fallback;
1255
- }
1256
- const key = path.slice(0, idx);
1257
- const nextPath = path.slice(idx + 1);
1258
- const checkValue = obj?.[key]?.[nextPath];
1259
- if (checkValue) {
1260
- return checkValue;
1261
- }
1262
- return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
1263
- }
1264
-
1265
1278
  // src/split-props.ts
1266
1279
  function splitProps(props, ...keys) {
1267
1280
  const descriptors = Object.getOwnPropertyDescriptors(props);
@@ -1417,6 +1430,7 @@ function toRem(value = "") {
1417
1430
  omit,
1418
1431
  parseJson,
1419
1432
  patternFns,
1433
+ pick,
1420
1434
  splitBy,
1421
1435
  splitDotPath,
1422
1436
  splitProps,
package/dist/index.mjs CHANGED
@@ -605,6 +605,68 @@ var omit = (obj, paths) => {
605
605
  // src/panda-config-name.ts
606
606
  var PANDA_CONFIG_NAME = "__panda.config__";
607
607
 
608
+ // src/split.ts
609
+ function splitBy(value, separator = ",") {
610
+ const result = [];
611
+ let current = "";
612
+ let depth = 0;
613
+ for (let i = 0; i < value.length; i++) {
614
+ const char = value[i];
615
+ if (char === "(") {
616
+ depth++;
617
+ } else if (char === ")") {
618
+ depth--;
619
+ } else if (char === separator && depth === 0) {
620
+ result.push(current);
621
+ current = "";
622
+ continue;
623
+ }
624
+ current += char;
625
+ }
626
+ result.push(current);
627
+ return result;
628
+ }
629
+ function splitDotPath(path) {
630
+ return path.split(".").reduce((acc, curr) => {
631
+ const last = acc[acc.length - 1];
632
+ if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) {
633
+ acc[acc.length - 1] = `${last}.${curr}`;
634
+ } else {
635
+ acc.push(curr);
636
+ }
637
+ return acc;
638
+ }, []);
639
+ }
640
+ function getNegativePath(path) {
641
+ return path.slice(0, -1).concat(`-${path.at(-1)}`);
642
+ }
643
+ function getDotPath(obj, path, fallback) {
644
+ if (typeof path !== "string") return fallback;
645
+ const idx = path.indexOf(".");
646
+ if (idx === -1) {
647
+ return obj?.[path] ?? fallback;
648
+ }
649
+ const key = path.slice(0, idx);
650
+ const nextPath = path.slice(idx + 1);
651
+ const checkValue = obj?.[key]?.[nextPath];
652
+ if (checkValue) {
653
+ return checkValue;
654
+ }
655
+ return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
656
+ }
657
+
658
+ // src/pick.ts
659
+ var pick = (obj, paths) => {
660
+ const result = {};
661
+ traverse(obj, ({ path, value }) => {
662
+ if (paths.includes(path)) {
663
+ const pathParts = splitDotPath(path);
664
+ deepSet(result, pathParts, value);
665
+ }
666
+ });
667
+ return result;
668
+ };
669
+
608
670
  // src/pattern-fns.ts
609
671
  var patternFns = {
610
672
  map: mapObject,
@@ -1120,56 +1182,6 @@ var getSlotRecipes = (recipe = {}) => {
1120
1182
  };
1121
1183
  var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
1122
1184
 
1123
- // src/split.ts
1124
- function splitBy(value, separator = ",") {
1125
- const result = [];
1126
- let current = "";
1127
- let depth = 0;
1128
- for (let i = 0; i < value.length; i++) {
1129
- const char = value[i];
1130
- if (char === "(") {
1131
- depth++;
1132
- } else if (char === ")") {
1133
- depth--;
1134
- } else if (char === separator && depth === 0) {
1135
- result.push(current);
1136
- current = "";
1137
- continue;
1138
- }
1139
- current += char;
1140
- }
1141
- result.push(current);
1142
- return result;
1143
- }
1144
- function splitDotPath(path) {
1145
- return path.split(".").reduce((acc, curr) => {
1146
- const last = acc[acc.length - 1];
1147
- if (last != null && !isNaN(Number(last)) && !isNaN(Number(curr))) {
1148
- acc[acc.length - 1] = `${last}.${curr}`;
1149
- } else {
1150
- acc.push(curr);
1151
- }
1152
- return acc;
1153
- }, []);
1154
- }
1155
- function getNegativePath(path) {
1156
- return path.slice(0, -1).concat(`-${path.at(-1)}`);
1157
- }
1158
- function getDotPath(obj, path, fallback) {
1159
- if (typeof path !== "string") return fallback;
1160
- const idx = path.indexOf(".");
1161
- if (idx === -1) {
1162
- return obj?.[path] ?? fallback;
1163
- }
1164
- const key = path.slice(0, idx);
1165
- const nextPath = path.slice(idx + 1);
1166
- const checkValue = obj?.[key]?.[nextPath];
1167
- if (checkValue) {
1168
- return checkValue;
1169
- }
1170
- return getDotPath(obj?.[key], nextPath, fallback) ?? fallback;
1171
- }
1172
-
1173
1185
  // src/split-props.ts
1174
1186
  function splitProps(props, ...keys) {
1175
1187
  const descriptors = Object.getOwnPropertyDescriptors(props);
@@ -1324,6 +1336,7 @@ export {
1324
1336
  omit,
1325
1337
  parseJson,
1326
1338
  patternFns,
1339
+ pick,
1327
1340
  splitBy,
1328
1341
  splitDotPath,
1329
1342
  splitProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",