@pandacss/shared 0.14.0 → 0.15.1

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,5 +1,5 @@
1
- import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-2763c513.js';
2
- export { p as WalkObjectOptions, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, w as withoutImportant, j as withoutSpace } from './shared-2763c513.js';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-b874b673.js';
2
+ export { p as WalkObjectOptions, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, w as withoutImportant, j as withoutSpace } from './shared-b874b673.js';
3
3
  export { astish } from './astish.mjs';
4
4
 
5
5
  type Operand = string | number | {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-2763c513.js';
2
- export { p as WalkObjectOptions, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, w as withoutImportant, j as withoutSpace } from './shared-2763c513.js';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './shared-b874b673.js';
2
+ export { p as WalkObjectOptions, e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, a as isFunction, h as isImportant, b as isObject, i as isString, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, w as withoutImportant, j as withoutSpace } from './shared-b874b673.js';
3
3
  export { astish } from './astish.js';
4
4
 
5
5
  type Operand = string | number | {
package/dist/index.js CHANGED
@@ -440,54 +440,30 @@ var hypenateProperty = memo((property) => {
440
440
 
441
441
  // src/regex.ts
442
442
  var createRegex = (item) => {
443
- const regex2 = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
444
- return new RegExp(`^${regex2}$`);
443
+ const regex2 = item.map((item2) => typeof item2 === "string" ? `^${item2}$` : item2.source).join("|");
444
+ return new RegExp(regex2);
445
445
  };
446
446
 
447
447
  // src/slot.ts
448
- var assign = (obj, path, value) => {
449
- const last = path.pop();
450
- const target = path.reduce((acc, key) => {
451
- if (acc[key] == null)
452
- acc[key] = {};
453
- return acc[key];
454
- }, obj);
455
- if (last != null)
456
- target[last] = value;
457
- };
458
- var getSlotRecipes = (recipe) => {
459
- const parts = recipe.slots.map((slot) => [
460
- slot,
461
- // setup base recipe
462
- {
463
- // create class-base on BEM
464
- className: [recipe.className ?? "", slot].join("__"),
465
- base: {},
466
- variants: {},
467
- defaultVariants: recipe.defaultVariants ?? {},
468
- compoundVariants: []
469
- }
470
- ]).map(([slot, cva]) => {
471
- const base = recipe.base[slot];
472
- if (base)
473
- cva.base = base;
474
- walkObject(
475
- recipe.variants ?? {},
476
- (variant, path) => {
477
- if (!variant[slot])
478
- return;
479
- assign(cva, ["variants", ...path], variant[slot]);
480
- },
481
- {
482
- stop: (_value, path) => path.includes(slot)
483
- }
484
- );
485
- if (recipe.compoundVariants) {
486
- cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);
487
- }
488
- return [slot, cva];
448
+ var getSlotRecipes = (recipe = {}) => {
449
+ const init = (slot) => ({
450
+ className: [recipe.className, slot].filter(Boolean).join("__"),
451
+ base: recipe.base?.[slot] ?? {},
452
+ variants: {},
453
+ defaultVariants: recipe.defaultVariants ?? {},
454
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
489
455
  });
490
- return Object.fromEntries(parts);
456
+ const slots = recipe.slots ?? [];
457
+ const recipeParts = slots.map((slot) => [slot, init(slot)]);
458
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
459
+ for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
460
+ recipeParts.forEach(([slot, slotRecipe]) => {
461
+ slotRecipe.variants[variantsKey] ??= {};
462
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
463
+ });
464
+ }
465
+ }
466
+ return Object.fromEntries(recipeParts);
491
467
  };
492
468
  var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
493
469
 
package/dist/index.mjs CHANGED
@@ -373,54 +373,30 @@ var hypenateProperty = memo((property) => {
373
373
 
374
374
  // src/regex.ts
375
375
  var createRegex = (item) => {
376
- const regex2 = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
377
- return new RegExp(`^${regex2}$`);
376
+ const regex2 = item.map((item2) => typeof item2 === "string" ? `^${item2}$` : item2.source).join("|");
377
+ return new RegExp(regex2);
378
378
  };
379
379
 
380
380
  // src/slot.ts
381
- var assign = (obj, path, value) => {
382
- const last = path.pop();
383
- const target = path.reduce((acc, key) => {
384
- if (acc[key] == null)
385
- acc[key] = {};
386
- return acc[key];
387
- }, obj);
388
- if (last != null)
389
- target[last] = value;
390
- };
391
- var getSlotRecipes = (recipe) => {
392
- const parts = recipe.slots.map((slot) => [
393
- slot,
394
- // setup base recipe
395
- {
396
- // create class-base on BEM
397
- className: [recipe.className ?? "", slot].join("__"),
398
- base: {},
399
- variants: {},
400
- defaultVariants: recipe.defaultVariants ?? {},
401
- compoundVariants: []
402
- }
403
- ]).map(([slot, cva]) => {
404
- const base = recipe.base[slot];
405
- if (base)
406
- cva.base = base;
407
- walkObject(
408
- recipe.variants ?? {},
409
- (variant, path) => {
410
- if (!variant[slot])
411
- return;
412
- assign(cva, ["variants", ...path], variant[slot]);
413
- },
414
- {
415
- stop: (_value, path) => path.includes(slot)
416
- }
417
- );
418
- if (recipe.compoundVariants) {
419
- cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);
420
- }
421
- return [slot, cva];
381
+ var getSlotRecipes = (recipe = {}) => {
382
+ const init = (slot) => ({
383
+ className: [recipe.className, slot].filter(Boolean).join("__"),
384
+ base: recipe.base?.[slot] ?? {},
385
+ variants: {},
386
+ defaultVariants: recipe.defaultVariants ?? {},
387
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
422
388
  });
423
- return Object.fromEntries(parts);
389
+ const slots = recipe.slots ?? [];
390
+ const recipeParts = slots.map((slot) => [slot, init(slot)]);
391
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
392
+ for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
393
+ recipeParts.forEach(([slot, slotRecipe]) => {
394
+ slotRecipe.variants[variantsKey] ??= {};
395
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
396
+ });
397
+ }
398
+ }
399
+ return Object.fromEntries(recipeParts);
424
400
  };
425
401
  var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
426
402
 
@@ -63,9 +63,7 @@ declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
63
63
 
64
64
  declare function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T;
65
65
 
66
- declare const getSlotRecipes: (recipe: any) => {
67
- [k: string]: any;
68
- };
66
+ declare const getSlotRecipes: (recipe?: Record<string, any>) => Record<string, any>;
69
67
  declare const getSlotCompoundVariant: <T extends {
70
68
  css: any;
71
69
  }>(compoundVariants: T[], slotName: string) => (T & {
package/dist/shared.d.mts CHANGED
@@ -1 +1 @@
1
- export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, b as isObject, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, j as withoutSpace } from './shared-2763c513.js';
1
+ export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, b as isObject, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, j as withoutSpace } from './shared-b874b673.js';
package/dist/shared.d.ts CHANGED
@@ -1 +1 @@
1
- export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, b as isObject, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, j as withoutSpace } from './shared-2763c513.js';
1
+ export { e as compact, c as createCss, d as createMergeCss, g as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, k as hypenateProperty, f as isBaseCondition, b as isObject, r as mapObject, m as memo, l as mergeProps, s as splitProps, t as toHash, q as walkObject, j as withoutSpace } from './shared-b874b673.js';
package/dist/shared.js CHANGED
@@ -251,49 +251,25 @@ var hypenateProperty = memo((property) => {
251
251
  });
252
252
 
253
253
  // src/slot.ts
254
- var assign = (obj, path, value) => {
255
- const last = path.pop();
256
- const target = path.reduce((acc, key) => {
257
- if (acc[key] == null)
258
- acc[key] = {};
259
- return acc[key];
260
- }, obj);
261
- if (last != null)
262
- target[last] = value;
263
- };
264
- var getSlotRecipes = (recipe) => {
265
- const parts = recipe.slots.map((slot) => [
266
- slot,
267
- // setup base recipe
268
- {
269
- // create class-base on BEM
270
- className: [recipe.className ?? "", slot].join("__"),
271
- base: {},
272
- variants: {},
273
- defaultVariants: recipe.defaultVariants ?? {},
274
- compoundVariants: []
275
- }
276
- ]).map(([slot, cva]) => {
277
- const base = recipe.base[slot];
278
- if (base)
279
- cva.base = base;
280
- walkObject(
281
- recipe.variants ?? {},
282
- (variant, path) => {
283
- if (!variant[slot])
284
- return;
285
- assign(cva, ["variants", ...path], variant[slot]);
286
- },
287
- {
288
- stop: (_value, path) => path.includes(slot)
289
- }
290
- );
291
- if (recipe.compoundVariants) {
292
- cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);
293
- }
294
- return [slot, cva];
254
+ var getSlotRecipes = (recipe = {}) => {
255
+ const init = (slot) => ({
256
+ className: [recipe.className, slot].filter(Boolean).join("__"),
257
+ base: recipe.base?.[slot] ?? {},
258
+ variants: {},
259
+ defaultVariants: recipe.defaultVariants ?? {},
260
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
295
261
  });
296
- return Object.fromEntries(parts);
262
+ const slots = recipe.slots ?? [];
263
+ const recipeParts = slots.map((slot) => [slot, init(slot)]);
264
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
265
+ for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
266
+ recipeParts.forEach(([slot, slotRecipe]) => {
267
+ slotRecipe.variants[variantsKey] ??= {};
268
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
269
+ });
270
+ }
271
+ }
272
+ return Object.fromEntries(recipeParts);
297
273
  };
298
274
  var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
299
275
 
package/dist/shared.mjs CHANGED
@@ -210,49 +210,25 @@ var hypenateProperty = memo((property) => {
210
210
  });
211
211
 
212
212
  // src/slot.ts
213
- var assign = (obj, path, value) => {
214
- const last = path.pop();
215
- const target = path.reduce((acc, key) => {
216
- if (acc[key] == null)
217
- acc[key] = {};
218
- return acc[key];
219
- }, obj);
220
- if (last != null)
221
- target[last] = value;
222
- };
223
- var getSlotRecipes = (recipe) => {
224
- const parts = recipe.slots.map((slot) => [
225
- slot,
226
- // setup base recipe
227
- {
228
- // create class-base on BEM
229
- className: [recipe.className ?? "", slot].join("__"),
230
- base: {},
231
- variants: {},
232
- defaultVariants: recipe.defaultVariants ?? {},
233
- compoundVariants: []
234
- }
235
- ]).map(([slot, cva]) => {
236
- const base = recipe.base[slot];
237
- if (base)
238
- cva.base = base;
239
- walkObject(
240
- recipe.variants ?? {},
241
- (variant, path) => {
242
- if (!variant[slot])
243
- return;
244
- assign(cva, ["variants", ...path], variant[slot]);
245
- },
246
- {
247
- stop: (_value, path) => path.includes(slot)
248
- }
249
- );
250
- if (recipe.compoundVariants) {
251
- cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);
252
- }
253
- return [slot, cva];
213
+ var getSlotRecipes = (recipe = {}) => {
214
+ const init = (slot) => ({
215
+ className: [recipe.className, slot].filter(Boolean).join("__"),
216
+ base: recipe.base?.[slot] ?? {},
217
+ variants: {},
218
+ defaultVariants: recipe.defaultVariants ?? {},
219
+ compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []
254
220
  });
255
- return Object.fromEntries(parts);
221
+ const slots = recipe.slots ?? [];
222
+ const recipeParts = slots.map((slot) => [slot, init(slot)]);
223
+ for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) {
224
+ for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) {
225
+ recipeParts.forEach(([slot, slotRecipe]) => {
226
+ slotRecipe.variants[variantsKey] ??= {};
227
+ slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};
228
+ });
229
+ }
230
+ }
231
+ return Object.fromEntries(recipeParts);
256
232
  };
257
233
  var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
258
234
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",