@pandacss/shared 0.8.0 → 0.10.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/astish.d.mts +3 -0
- package/dist/astish.d.ts +3 -0
- package/dist/astish.js +43 -0
- package/dist/astish.mjs +18 -0
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +59 -0
- package/dist/index.mjs +56 -0
- package/dist/normalize-html.d.mts +8 -0
- package/dist/normalize-html.d.ts +8 -0
- package/dist/normalize-html.js +37 -0
- package/dist/normalize-html.mjs +12 -0
- package/dist/{split-props-3d8b55c4.d.ts → shared-2763c513.d.ts} +12 -3
- package/dist/shared.d.mts +1 -10
- package/dist/shared.d.ts +1 -10
- package/dist/shared.js +52 -29
- package/dist/shared.mjs +49 -27
- package/package.json +1 -1
package/dist/astish.d.ts
ADDED
package/dist/astish.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/astish.ts
|
|
21
|
+
var astish_exports = {};
|
|
22
|
+
__export(astish_exports, {
|
|
23
|
+
astish: () => astish
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(astish_exports);
|
|
26
|
+
var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
|
|
27
|
+
var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
|
|
28
|
+
var astish = (val, tree = [{}]) => {
|
|
29
|
+
const block = newRule.exec((val ?? "").replace(ruleClean, ""));
|
|
30
|
+
if (!block)
|
|
31
|
+
return tree[0];
|
|
32
|
+
if (block[4])
|
|
33
|
+
tree.shift();
|
|
34
|
+
else if (block[3])
|
|
35
|
+
tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
|
|
36
|
+
else
|
|
37
|
+
tree[0][block[1]] = block[2];
|
|
38
|
+
return astish(val, tree);
|
|
39
|
+
};
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
astish
|
|
43
|
+
});
|
package/dist/astish.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/astish.ts
|
|
2
|
+
var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
|
|
3
|
+
var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
|
|
4
|
+
var astish = (val, tree = [{}]) => {
|
|
5
|
+
const block = newRule.exec((val ?? "").replace(ruleClean, ""));
|
|
6
|
+
if (!block)
|
|
7
|
+
return tree[0];
|
|
8
|
+
if (block[4])
|
|
9
|
+
tree.shift();
|
|
10
|
+
else if (block[3])
|
|
11
|
+
tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
|
|
12
|
+
else
|
|
13
|
+
tree[0][block[1]] = block[2];
|
|
14
|
+
return astish(val, tree);
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
astish
|
|
18
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './
|
|
2
|
-
export {
|
|
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';
|
|
3
|
+
export { astish } from './astish.mjs';
|
|
3
4
|
|
|
4
5
|
type Operand = string | number | {
|
|
5
6
|
ref: string;
|
|
@@ -34,12 +35,12 @@ declare const esc: (sel: string) => string;
|
|
|
34
35
|
|
|
35
36
|
declare function flatten(values: Record<string, Record<string, any>>, stop?: WalkObjectStopFn): Record<string, any>;
|
|
36
37
|
|
|
37
|
-
declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
|
|
38
|
-
|
|
39
38
|
type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
|
|
40
39
|
declare function normalizeShorthand(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
|
|
41
40
|
declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
|
|
42
41
|
|
|
42
|
+
declare const createRegex: (item: Array<string | RegExp>) => RegExp;
|
|
43
|
+
|
|
43
44
|
declare function splitBy(value: string, separator?: string): any[];
|
|
44
45
|
declare function splitDotPath(path: string): string[];
|
|
45
46
|
declare function getNegativePath(path: string[]): string[];
|
|
@@ -50,6 +51,6 @@ type MapToRecord<K extends Map<string, any>> = {
|
|
|
50
51
|
};
|
|
51
52
|
declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
|
|
52
53
|
|
|
53
|
-
declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
|
|
54
|
+
declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
|
|
54
55
|
|
|
55
|
-
export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson,
|
|
56
|
+
export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, normalizeShorthand, normalizeStyleObject, splitBy, splitDotPath, toEm, toPx, toRem, uncapitalize, unionType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { W as WalkObjectStopFn, M as MappedObject, C as CreateCssContext } from './
|
|
2
|
-
export {
|
|
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';
|
|
3
|
+
export { astish } from './astish.js';
|
|
3
4
|
|
|
4
5
|
type Operand = string | number | {
|
|
5
6
|
ref: string;
|
|
@@ -34,12 +35,12 @@ declare const esc: (sel: string) => string;
|
|
|
34
35
|
|
|
35
36
|
declare function flatten(values: Record<string, Record<string, any>>, stop?: WalkObjectStopFn): Record<string, any>;
|
|
36
37
|
|
|
37
|
-
declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
|
|
38
|
-
|
|
39
38
|
type NormalizeContext = Pick<CreateCssContext, 'utility' | 'conditions'>;
|
|
40
39
|
declare function normalizeShorthand(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
|
|
41
40
|
declare function normalizeStyleObject(styles: Record<string, any>, context: NormalizeContext): MappedObject<Record<string, any>, any>;
|
|
42
41
|
|
|
42
|
+
declare const createRegex: (item: Array<string | RegExp>) => RegExp;
|
|
43
|
+
|
|
43
44
|
declare function splitBy(value: string, separator?: string): any[];
|
|
44
45
|
declare function splitDotPath(path: string): string[];
|
|
45
46
|
declare function getNegativePath(path: string[]): string[];
|
|
@@ -50,6 +51,6 @@ type MapToRecord<K extends Map<string, any>> = {
|
|
|
50
51
|
};
|
|
51
52
|
declare function mapToJson<T extends Map<string, any>>(map: T): MapToRecord<T>;
|
|
52
53
|
|
|
53
|
-
declare function unionType(values: IterableIterator<string> | string[] | Set<string>): string;
|
|
54
|
+
declare function unionType(values: IterableIterator<string> | string[] | readonly string[] | Set<string>): string;
|
|
54
55
|
|
|
55
|
-
export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson,
|
|
56
|
+
export { CreateCssContext, CssVar, CssVarOptions, MappedObject, WalkObjectStopFn, calc, camelCaseProperty, capitalize, createRegex, cssVar, dashCase, esc, flatten, getDotPath, getNegativePath, getUnit, mapToJson, 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,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/normalize-html.ts
|
|
21
|
+
var normalize_html_exports = {};
|
|
22
|
+
__export(normalize_html_exports, {
|
|
23
|
+
normalizeHTMLProps: () => normalizeHTMLProps
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(normalize_html_exports);
|
|
26
|
+
var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
|
|
27
|
+
function convert(key) {
|
|
28
|
+
return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;
|
|
29
|
+
}
|
|
30
|
+
function normalizeHTMLProps(props) {
|
|
31
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));
|
|
32
|
+
}
|
|
33
|
+
normalizeHTMLProps.keys = htmlProps;
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
normalizeHTMLProps
|
|
37
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/normalize-html.ts
|
|
2
|
+
var htmlProps = ["htmlSize", "htmlTranslate", "htmlWidth", "htmlHeight"];
|
|
3
|
+
function convert(key) {
|
|
4
|
+
return htmlProps.includes(key) ? key.replace("html", "").toLowerCase() : key;
|
|
5
|
+
}
|
|
6
|
+
function normalizeHTMLProps(props) {
|
|
7
|
+
return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]));
|
|
8
|
+
}
|
|
9
|
+
normalizeHTMLProps.keys = htmlProps;
|
|
10
|
+
export {
|
|
11
|
+
normalizeHTMLProps
|
|
12
|
+
};
|
|
@@ -3,8 +3,6 @@ type AnyFunction = (...args: any[]) => any;
|
|
|
3
3
|
declare const isFunction: (v: any) => v is AnyFunction;
|
|
4
4
|
declare function isObject(value: any): value is Record<string, any>;
|
|
5
5
|
|
|
6
|
-
declare const astish: (val: string, tree?: any[]) => Record<string, any>;
|
|
7
|
-
|
|
8
6
|
type CreateCssContext = {
|
|
9
7
|
hash?: boolean;
|
|
10
8
|
/**
|
|
@@ -61,11 +59,22 @@ declare function toHash(value: string): string;
|
|
|
61
59
|
|
|
62
60
|
declare const hypenateProperty: (property: string) => string;
|
|
63
61
|
|
|
62
|
+
declare const memo: <T extends (...args: any[]) => any>(fn: T) => T;
|
|
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,
|
|
80
|
+
export { CreateCssContext as C, MappedObject as M, WalkObjectStopFn as W, isFunction as a, isObject as b, createCss as c, createMergeCss as d, compact as e, isBaseCondition as f, filterBaseConditions as g, isImportant as h, isString as i, withoutSpace as j, hypenateProperty as k, mergeProps as l, memo 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/dist/shared.d.mts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
declare function normalizeHTMLProps(props: Record<string, any>): {
|
|
4
|
-
[k: string]: any;
|
|
5
|
-
};
|
|
6
|
-
declare namespace normalizeHTMLProps {
|
|
7
|
-
var keys: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { normalizeHTMLProps };
|
|
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';
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
declare function normalizeHTMLProps(props: Record<string, any>): {
|
|
4
|
-
[k: string]: any;
|
|
5
|
-
};
|
|
6
|
-
declare namespace normalizeHTMLProps {
|
|
7
|
-
var keys: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { normalizeHTMLProps };
|
|
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';
|
package/dist/shared.js
CHANGED
|
@@ -20,17 +20,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/shared.ts
|
|
21
21
|
var shared_exports = {};
|
|
22
22
|
__export(shared_exports, {
|
|
23
|
-
astish: () => astish,
|
|
24
23
|
compact: () => compact,
|
|
25
24
|
createCss: () => createCss,
|
|
26
25
|
createMergeCss: () => createMergeCss,
|
|
27
26
|
filterBaseConditions: () => filterBaseConditions,
|
|
27
|
+
getSlotCompoundVariant: () => getSlotCompoundVariant,
|
|
28
|
+
getSlotRecipes: () => getSlotRecipes,
|
|
28
29
|
hypenateProperty: () => hypenateProperty,
|
|
29
30
|
isBaseCondition: () => isBaseCondition,
|
|
30
31
|
isObject: () => isObject,
|
|
31
32
|
mapObject: () => mapObject,
|
|
33
|
+
memo: () => memo,
|
|
32
34
|
mergeProps: () => mergeProps,
|
|
33
|
-
normalizeHTMLProps: () => normalizeHTMLProps,
|
|
34
35
|
splitProps: () => splitProps,
|
|
35
36
|
toHash: () => toHash,
|
|
36
37
|
walkObject: () => walkObject,
|
|
@@ -43,22 +44,6 @@ function isObject(value) {
|
|
|
43
44
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
// src/astish.ts
|
|
47
|
-
var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
|
|
48
|
-
var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
|
|
49
|
-
var astish = (val, tree = [{}]) => {
|
|
50
|
-
const block = newRule.exec((val ?? "").replace(ruleClean, ""));
|
|
51
|
-
if (!block)
|
|
52
|
-
return tree[0];
|
|
53
|
-
if (block[4])
|
|
54
|
-
tree.shift();
|
|
55
|
-
else if (block[3])
|
|
56
|
-
tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
|
|
57
|
-
else
|
|
58
|
-
tree[0][block[1]] = block[2];
|
|
59
|
-
return astish(val, tree);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
47
|
// src/compact.ts
|
|
63
48
|
function compact(value) {
|
|
64
49
|
return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
|
|
@@ -265,15 +250,52 @@ var hypenateProperty = memo((property) => {
|
|
|
265
250
|
return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
|
|
266
251
|
});
|
|
267
252
|
|
|
268
|
-
// src/
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
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];
|
|
295
|
+
});
|
|
296
|
+
return Object.fromEntries(parts);
|
|
297
|
+
};
|
|
298
|
+
var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
|
|
277
299
|
|
|
278
300
|
// src/split-props.ts
|
|
279
301
|
function splitProps(props, ...keys) {
|
|
@@ -295,17 +317,18 @@ function splitProps(props, ...keys) {
|
|
|
295
317
|
}
|
|
296
318
|
// Annotate the CommonJS export names for ESM import in node:
|
|
297
319
|
0 && (module.exports = {
|
|
298
|
-
astish,
|
|
299
320
|
compact,
|
|
300
321
|
createCss,
|
|
301
322
|
createMergeCss,
|
|
302
323
|
filterBaseConditions,
|
|
324
|
+
getSlotCompoundVariant,
|
|
325
|
+
getSlotRecipes,
|
|
303
326
|
hypenateProperty,
|
|
304
327
|
isBaseCondition,
|
|
305
328
|
isObject,
|
|
306
329
|
mapObject,
|
|
330
|
+
memo,
|
|
307
331
|
mergeProps,
|
|
308
|
-
normalizeHTMLProps,
|
|
309
332
|
splitProps,
|
|
310
333
|
toHash,
|
|
311
334
|
walkObject,
|
package/dist/shared.mjs
CHANGED
|
@@ -3,22 +3,6 @@ function isObject(value) {
|
|
|
3
3
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
// src/astish.ts
|
|
7
|
-
var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g;
|
|
8
|
-
var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g;
|
|
9
|
-
var astish = (val, tree = [{}]) => {
|
|
10
|
-
const block = newRule.exec((val ?? "").replace(ruleClean, ""));
|
|
11
|
-
if (!block)
|
|
12
|
-
return tree[0];
|
|
13
|
-
if (block[4])
|
|
14
|
-
tree.shift();
|
|
15
|
-
else if (block[3])
|
|
16
|
-
tree.unshift(tree[0][block[3]] = tree[0][block[3]] || {});
|
|
17
|
-
else
|
|
18
|
-
tree[0][block[1]] = block[2];
|
|
19
|
-
return astish(val, tree);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
6
|
// src/compact.ts
|
|
23
7
|
function compact(value) {
|
|
24
8
|
return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0));
|
|
@@ -225,15 +209,52 @@ var hypenateProperty = memo((property) => {
|
|
|
225
209
|
return property.replace(wordRegex, "-$1").replace(msRegex, "-ms-").toLowerCase();
|
|
226
210
|
});
|
|
227
211
|
|
|
228
|
-
// src/
|
|
229
|
-
var
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
|
|
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];
|
|
254
|
+
});
|
|
255
|
+
return Object.fromEntries(parts);
|
|
256
|
+
};
|
|
257
|
+
var getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant.css[slotName]).map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }));
|
|
237
258
|
|
|
238
259
|
// src/split-props.ts
|
|
239
260
|
function splitProps(props, ...keys) {
|
|
@@ -254,17 +275,18 @@ function splitProps(props, ...keys) {
|
|
|
254
275
|
return keys.map(fn).concat(split(dKeys));
|
|
255
276
|
}
|
|
256
277
|
export {
|
|
257
|
-
astish,
|
|
258
278
|
compact,
|
|
259
279
|
createCss,
|
|
260
280
|
createMergeCss,
|
|
261
281
|
filterBaseConditions,
|
|
282
|
+
getSlotCompoundVariant,
|
|
283
|
+
getSlotRecipes,
|
|
262
284
|
hypenateProperty,
|
|
263
285
|
isBaseCondition,
|
|
264
286
|
isObject,
|
|
265
287
|
mapObject,
|
|
288
|
+
memo,
|
|
266
289
|
mergeProps,
|
|
267
|
-
normalizeHTMLProps,
|
|
268
290
|
splitProps,
|
|
269
291
|
toHash,
|
|
270
292
|
walkObject,
|