@pandacss/shared 0.0.0-dev-20230801082734 → 0.0.0-dev-20230801084843

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 './split-props-3d8b55c4.js';
2
- export { n as WalkObjectOptions, c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, a as isFunction, j as isImportant, b as isObject, i as isString, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, w as withoutImportant, k as withoutSpace } from './split-props-3d8b55c4.js';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-6b55cbce.js';
2
+ export { p as WalkObjectOptions, c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, a as isFunction, j as isImportant, b as isObject, i as isString, r as mapObject, m as mergeProps, s as splitProps, t as toHash, q as walkObject, w as withoutImportant, k as withoutSpace } from './split-props-6b55cbce.js';
3
3
 
4
4
  type Operand = string | number | {
5
5
  ref: string;
@@ -40,6 +40,8 @@ type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
40
40
  declare function normalizeShorthand(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
41
41
  declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
42
42
 
43
+ declare const createRegex: (item: Array<string | RegExp>) => RegExp;
44
+
43
45
  declare function splitBy(value: string, separator?: string): any[];
44
46
  declare function splitDotPath(path: string): string[];
45
47
  declare function getNegativePath(path: string[]): string[];
@@ -50,6 +52,6 @@ type MapToRecord<K extends Map<string, any>> = {
50
52
  };
51
53
  declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
52
54
 
53
- declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
55
+ declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
54
56
 
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 };
57
+ export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, memo, normalizeShorthand, normalizeStyleObject, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-3d8b55c4.js';
2
- export { n as WalkObjectOptions, c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, a as isFunction, j as isImportant, b as isObject, i as isString, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, w as withoutImportant, k as withoutSpace } from './split-props-3d8b55c4.js';
1
+ import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './split-props-6b55cbce.js';
2
+ export { p as WalkObjectOptions, c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, a as isFunction, j as isImportant, b as isObject, i as isString, r as mapObject, m as mergeProps, s as splitProps, t as toHash, q as walkObject, w as withoutImportant, k as withoutSpace } from './split-props-6b55cbce.js';
3
3
 
4
4
  type Operand = string | number | {
5
5
  ref: string;
@@ -40,6 +40,8 @@ type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
40
40
  declare function normalizeShorthand(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
41
41
  declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
42
42
 
43
+ declare const createRegex: (item: Array<string | RegExp>) => RegExp;
44
+
43
45
  declare function splitBy(value: string, separator?: string): any[];
44
46
  declare function splitDotPath(path: string): string[];
45
47
  declare function getNegativePath(path: string[]): string[];
@@ -50,6 +52,6 @@ type MapToRecord<K extends Map<string, any>> = {
50
52
  };
51
53
  declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
52
54
 
53
- declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
55
+ declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
54
56
 
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 };
57
+ export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, memo, normalizeShorthand, normalizeStyleObject, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType };
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ __export(src_exports, {
27
27
  compact: () => compact,
28
28
  createCss: () => createCss,
29
29
  createMergeCss: () => createMergeCss,
30
+ createRegex: () => createRegex,
30
31
  cssVar: () => cssVar,
31
32
  dashCase: () => dashCase,
32
33
  esc: () => esc2,
@@ -34,6 +35,8 @@ __export(src_exports, {
34
35
  flatten: () => flatten,
35
36
  getDotPath: () => getDotPath,
36
37
  getNegativePath: () => getNegativePath,
38
+ getSlotCompoundVariant: () => getSlotCompoundVariant,
39
+ getSlotRecipes: () => getSlotRecipes,
37
40
  getUnit: () => getUnit,
38
41
  hypenateProperty: () => hypenateProperty,
39
42
  isBaseCondition: () => isBaseCondition,
@@ -435,6 +438,59 @@ var hypenateProperty = memo((property) => {
435
438
  return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
436
439
  });
437
440
 
441
+ // src/regex.ts
442
+ var createRegex = (item) => {
443
+ const regex2 = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
444
+ return new RegExp(`^${regex2}$`);
445
+ };
446
+
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];
489
+ });
490
+ return Object.fromEntries(parts);
491
+ };
492
+ var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
493
+
438
494
  // src/split.ts
439
495
  function splitBy(value, separator = ",") {
440
496
  const result = [];
@@ -531,6 +587,7 @@ function unionType(values) {
531
587
  compact,
532
588
  createCss,
533
589
  createMergeCss,
590
+ createRegex,
534
591
  cssVar,
535
592
  dashCase,
536
593
  esc,
@@ -538,6 +595,8 @@ function unionType(values) {
538
595
  flatten,
539
596
  getDotPath,
540
597
  getNegativePath,
598
+ getSlotCompoundVariant,
599
+ getSlotRecipes,
541
600
  getUnit,
542
601
  hypenateProperty,
543
602
  isBaseCondition,
package/dist/index.mjs CHANGED
@@ -371,6 +371,59 @@ var hypenateProperty = memo((property) => {
371
371
  return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
372
372
  });
373
373
 
374
+ // src/regex.ts
375
+ var createRegex = (item) => {
376
+ const regex2 = item.map((item2) => typeof item2 === "string" ? item2 : item2.source).join("|");
377
+ return new RegExp(`^${regex2}$`);
378
+ };
379
+
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];
422
+ });
423
+ return Object.fromEntries(parts);
424
+ };
425
+ var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
426
+
374
427
  // src/split.ts
375
428
  function splitBy(value, separator = ",") {
376
429
  const result = [];
@@ -466,6 +519,7 @@ export {
466
519
  compact,
467
520
  createCss,
468
521
  createMergeCss,
522
+ createRegex,
469
523
  cssVar,
470
524
  dashCase,
471
525
  esc2 as esc,
@@ -473,6 +527,8 @@ export {
473
527
  flatten,
474
528
  getDotPath,
475
529
  getNegativePath,
530
+ getSlotCompoundVariant,
531
+ getSlotRecipes,
476
532
  getUnit,
477
533
  hypenateProperty,
478
534
  isBaseCondition,
package/dist/shared.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, b as isObject, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, k as withoutSpace } from './split-props-3d8b55c4.js';
1
+ export { c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, b as isObject, r as mapObject, m as mergeProps, s as splitProps, t as toHash, q as walkObject, k as withoutSpace } from './split-props-6b55cbce.js';
2
2
 
3
3
  declare function normalizeHTMLProps(props: Record<string, any>): {
4
4
  [k: string]: any;
package/dist/shared.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, l as hypenateProperty, g as isBaseCondition, b as isObject, p as mapObject, m as mergeProps, s as splitProps, t as toHash, o as walkObject, k as withoutSpace } from './split-props-3d8b55c4.js';
1
+ export { c as astish, f as compact, d as createCss, e as createMergeCss, h as filterBaseConditions, o as getSlotCompoundVariant, n as getSlotRecipes, l as hypenateProperty, g as isBaseCondition, b as isObject, r as mapObject, m as mergeProps, s as splitProps, t as toHash, q as walkObject, k as withoutSpace } from './split-props-6b55cbce.js';
2
2
 
3
3
  declare function normalizeHTMLProps(props: Record<string, any>): {
4
4
  [k: string]: any;
package/dist/shared.js CHANGED
@@ -25,6 +25,8 @@ __export(shared_exports, {
25
25
  createCss: () => createCss,
26
26
  createMergeCss: () => createMergeCss,
27
27
  filterBaseConditions: () => filterBaseConditions,
28
+ getSlotCompoundVariant: () => getSlotCompoundVariant,
29
+ getSlotRecipes: () => getSlotRecipes,
28
30
  hypenateProperty: () => hypenateProperty,
29
31
  isBaseCondition: () => isBaseCondition,
30
32
  isObject: () => isObject,
@@ -275,6 +277,53 @@ function normalizeHTMLProps(props) {
275
277
  }
276
278
  normalizeHTMLProps.keys = htmlProps;
277
279
 
280
+ // src/slot.ts
281
+ var assign = (obj, path, value) => {
282
+ const last = path.pop();
283
+ const target = path.reduce((acc, key) => {
284
+ if (acc[key] == null)
285
+ acc[key] = {};
286
+ return acc[key];
287
+ }, obj);
288
+ if (last != null)
289
+ target[last] = value;
290
+ };
291
+ var getSlotRecipes = (recipe) => {
292
+ const parts = recipe.slots.map((slot) => [
293
+ slot,
294
+ // setup base recipe
295
+ {
296
+ // create class-base on BEM
297
+ className: [recipe.className ?? "", slot].join("__"),
298
+ base: {},
299
+ variants: {},
300
+ defaultVariants: recipe.defaultVariants ?? {},
301
+ compoundVariants: []
302
+ }
303
+ ]).map(([slot, cva]) => {
304
+ const base = recipe.base[slot];
305
+ if (base)
306
+ cva.base = base;
307
+ walkObject(
308
+ recipe.variants ?? {},
309
+ (variant, path) => {
310
+ if (!variant[slot])
311
+ return;
312
+ assign(cva, ["variants", ...path], variant[slot]);
313
+ },
314
+ {
315
+ stop: (_value, path) => path.includes(slot)
316
+ }
317
+ );
318
+ if (recipe.compoundVariants) {
319
+ cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);
320
+ }
321
+ return [slot, cva];
322
+ });
323
+ return Object.fromEntries(parts);
324
+ };
325
+ var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
326
+
278
327
  // src/split-props.ts
279
328
  function splitProps(props, ...keys) {
280
329
  const descriptors = Object.getOwnPropertyDescriptors(props);
@@ -300,6 +349,8 @@ function splitProps(props, ...keys) {
300
349
  createCss,
301
350
  createMergeCss,
302
351
  filterBaseConditions,
352
+ getSlotCompoundVariant,
353
+ getSlotRecipes,
303
354
  hypenateProperty,
304
355
  isBaseCondition,
305
356
  isObject,
package/dist/shared.mjs CHANGED
@@ -235,6 +235,53 @@ function normalizeHTMLProps(props) {
235
235
  }
236
236
  normalizeHTMLProps.keys = htmlProps;
237
237
 
238
+ // src/slot.ts
239
+ var assign = (obj, path, value) => {
240
+ const last = path.pop();
241
+ const target = path.reduce((acc, key) => {
242
+ if (acc[key] == null)
243
+ acc[key] = {};
244
+ return acc[key];
245
+ }, obj);
246
+ if (last != null)
247
+ target[last] = value;
248
+ };
249
+ var getSlotRecipes = (recipe) => {
250
+ const parts = recipe.slots.map((slot) => [
251
+ slot,
252
+ // setup base recipe
253
+ {
254
+ // create class-base on BEM
255
+ className: [recipe.className ?? "", slot].join("__"),
256
+ base: {},
257
+ variants: {},
258
+ defaultVariants: recipe.defaultVariants ?? {},
259
+ compoundVariants: []
260
+ }
261
+ ]).map(([slot, cva]) => {
262
+ const base = recipe.base[slot];
263
+ if (base)
264
+ cva.base = base;
265
+ walkObject(
266
+ recipe.variants ?? {},
267
+ (variant, path) => {
268
+ if (!variant[slot])
269
+ return;
270
+ assign(cva, ["variants", ...path], variant[slot]);
271
+ },
272
+ {
273
+ stop: (_value, path) => path.includes(slot)
274
+ }
275
+ );
276
+ if (recipe.compoundVariants) {
277
+ cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot);
278
+ }
279
+ return [slot, cva];
280
+ });
281
+ return Object.fromEntries(parts);
282
+ };
283
+ var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
284
+
238
285
  // src/split-props.ts
239
286
  function splitProps(props, ...keys) {
240
287
  const descriptors = Object.getOwnPropertyDescriptors(props);
@@ -259,6 +306,8 @@ export {
259
306
  createCss,
260
307
  createMergeCss,
261
308
  filterBaseConditions,
309
+ getSlotCompoundVariant,
310
+ getSlotRecipes,
262
311
  hypenateProperty,
263
312
  isBaseCondition,
264
313
  isObject,
@@ -63,9 +63,18 @@ declare const hypenateProperty: (property: string) => string;
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
+ };
69
+ declare const getSlotCompoundVariant: <T extends {
70
+ css: any;
71
+ }>(compoundVariants: T[], slotName: string) => (T & {
72
+ css: any;
73
+ })[];
74
+
66
75
  type Dict = Record<string, unknown>;
67
76
  type PredicateFn = (key: string) => boolean;
68
77
  type Key = PredicateFn | string[];
69
78
  declare function splitProps(props: Dict, ...keys: Key[]): Dict[];
70
79
 
71
- export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, astish 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, mergeProps as m, WalkObjectOptions as n, walkObject as o, mapObject as p, splitProps as s, toHash as t, withoutImportant as w };
80
+ export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, astish 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, mergeProps as m, getSlotRecipes as n, getSlotCompoundVariant as o, WalkObjectOptions as p, walkObject as q, mapObject as r, splitProps as s, toHash as t, withoutImportant as w };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/shared",
3
- "version": "0.0.0-dev-20230801082734",
3
+ "version": "0.0.0-dev-20230801084843",
4
4
  "description": "Shared utilities for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",