@pandacss/generator 0.0.0-dev-20230810081426 → 0.0.0-dev-20230810090440
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.js +26 -16
- package/dist/index.mjs +26 -16
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -623,11 +623,7 @@ function generateCssFn(ctx) {
|
|
|
623
623
|
config: { hash, prefix },
|
|
624
624
|
conditions
|
|
625
625
|
} = ctx;
|
|
626
|
-
const { separator } = utility;
|
|
627
|
-
const shorthandsByProp = Array.from(utility.shorthands.entries()).reduce((acc, [shorthand, prop]) => {
|
|
628
|
-
acc[prop] = shorthand;
|
|
629
|
-
return acc;
|
|
630
|
-
}, {});
|
|
626
|
+
const { separator, getPropShorthands } = utility;
|
|
631
627
|
return {
|
|
632
628
|
dts: import_outdent4.outdent`
|
|
633
629
|
import type { SystemStyleObject } from '../types'
|
|
@@ -644,25 +640,39 @@ function generateCssFn(ctx) {
|
|
|
644
640
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
645
641
|
|
|
646
642
|
const utilities = "${utility.entries().map(([prop, className]) => {
|
|
647
|
-
const
|
|
648
|
-
|
|
643
|
+
const shorthandList = getPropShorthands(prop);
|
|
644
|
+
const result = [
|
|
645
|
+
prop,
|
|
646
|
+
[
|
|
647
|
+
className,
|
|
648
|
+
shorthandList.length ? (
|
|
649
|
+
// mark shorthand equal to className as 1 to save a few bytes
|
|
650
|
+
shorthandList.map((shorthand) => shorthand === className ? 1 : shorthand).join("/")
|
|
651
|
+
) : null
|
|
652
|
+
].filter(Boolean).join("/")
|
|
653
|
+
].join(":");
|
|
654
|
+
return result;
|
|
649
655
|
}).join(",")}"
|
|
650
656
|
|
|
651
|
-
const
|
|
657
|
+
const classNames = new Map()
|
|
652
658
|
${utility.hasShorthand ? import_outdent4.outdent`
|
|
653
|
-
const shorthands =
|
|
659
|
+
const shorthands = new Map()
|
|
654
660
|
utilities.split(',').forEach((utility) => {
|
|
655
661
|
const [prop, meta] = utility.split(':')
|
|
656
|
-
const [className,
|
|
657
|
-
|
|
658
|
-
if (
|
|
662
|
+
const [className, ...shorthandList] = meta.split('/')
|
|
663
|
+
classNames.set(prop, className)
|
|
664
|
+
if (shorthandList.length) {
|
|
665
|
+
shorthandList.forEach((shorthand) => {
|
|
666
|
+
shorthands.set(shorthand === '1' ? className : shorthand, prop)
|
|
667
|
+
})
|
|
668
|
+
}
|
|
659
669
|
})
|
|
660
670
|
|
|
661
|
-
const resolveShorthand = (prop) => shorthands
|
|
671
|
+
const resolveShorthand = (prop) => shorthands.get(prop) || prop
|
|
662
672
|
` : import_outdent4.outdent`
|
|
663
673
|
utilities.split(',').forEach((utility) => {
|
|
664
674
|
const [prop, className] = utility.split(':')
|
|
665
|
-
|
|
675
|
+
classNames.set(prop, className)
|
|
666
676
|
})
|
|
667
677
|
`}
|
|
668
678
|
|
|
@@ -677,9 +687,9 @@ function generateCssFn(ctx) {
|
|
|
677
687
|
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
678
688
|
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
679
689
|
const key = resolveShorthand(prop)
|
|
680
|
-
const propKey =
|
|
690
|
+
const propKey = classNames.get(key) || hypenateProperty(key)
|
|
681
691
|
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
682
|
-
}` : `(key, value) => ({ className: \`\${
|
|
692
|
+
}` : `(key, value) => ({ className: \`\${classNames.get(key) || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
683
693
|
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
684
694
|
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
685
695
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -592,11 +592,7 @@ function generateCssFn(ctx) {
|
|
|
592
592
|
config: { hash, prefix },
|
|
593
593
|
conditions
|
|
594
594
|
} = ctx;
|
|
595
|
-
const { separator } = utility;
|
|
596
|
-
const shorthandsByProp = Array.from(utility.shorthands.entries()).reduce((acc, [shorthand, prop]) => {
|
|
597
|
-
acc[prop] = shorthand;
|
|
598
|
-
return acc;
|
|
599
|
-
}, {});
|
|
595
|
+
const { separator, getPropShorthands } = utility;
|
|
600
596
|
return {
|
|
601
597
|
dts: outdent4`
|
|
602
598
|
import type { SystemStyleObject } from '../types'
|
|
@@ -613,25 +609,39 @@ function generateCssFn(ctx) {
|
|
|
613
609
|
${ctx.file.import("sortConditions, finalizeConditions", "./conditions")}
|
|
614
610
|
|
|
615
611
|
const utilities = "${utility.entries().map(([prop, className]) => {
|
|
616
|
-
const
|
|
617
|
-
|
|
612
|
+
const shorthandList = getPropShorthands(prop);
|
|
613
|
+
const result = [
|
|
614
|
+
prop,
|
|
615
|
+
[
|
|
616
|
+
className,
|
|
617
|
+
shorthandList.length ? (
|
|
618
|
+
// mark shorthand equal to className as 1 to save a few bytes
|
|
619
|
+
shorthandList.map((shorthand) => shorthand === className ? 1 : shorthand).join("/")
|
|
620
|
+
) : null
|
|
621
|
+
].filter(Boolean).join("/")
|
|
622
|
+
].join(":");
|
|
623
|
+
return result;
|
|
618
624
|
}).join(",")}"
|
|
619
625
|
|
|
620
|
-
const
|
|
626
|
+
const classNames = new Map()
|
|
621
627
|
${utility.hasShorthand ? outdent4`
|
|
622
|
-
const shorthands =
|
|
628
|
+
const shorthands = new Map()
|
|
623
629
|
utilities.split(',').forEach((utility) => {
|
|
624
630
|
const [prop, meta] = utility.split(':')
|
|
625
|
-
const [className,
|
|
626
|
-
|
|
627
|
-
if (
|
|
631
|
+
const [className, ...shorthandList] = meta.split('/')
|
|
632
|
+
classNames.set(prop, className)
|
|
633
|
+
if (shorthandList.length) {
|
|
634
|
+
shorthandList.forEach((shorthand) => {
|
|
635
|
+
shorthands.set(shorthand === '1' ? className : shorthand, prop)
|
|
636
|
+
})
|
|
637
|
+
}
|
|
628
638
|
})
|
|
629
639
|
|
|
630
|
-
const resolveShorthand = (prop) => shorthands
|
|
640
|
+
const resolveShorthand = (prop) => shorthands.get(prop) || prop
|
|
631
641
|
` : outdent4`
|
|
632
642
|
utilities.split(',').forEach((utility) => {
|
|
633
643
|
const [prop, className] = utility.split(':')
|
|
634
|
-
|
|
644
|
+
classNames.set(prop, className)
|
|
635
645
|
})
|
|
636
646
|
`}
|
|
637
647
|
|
|
@@ -646,9 +656,9 @@ function generateCssFn(ctx) {
|
|
|
646
656
|
${prefix ? "prefix: " + JSON.stringify(prefix) + "," : ""}
|
|
647
657
|
transform: ${utility.hasShorthand ? `(prop, value) => {
|
|
648
658
|
const key = resolveShorthand(prop)
|
|
649
|
-
const propKey =
|
|
659
|
+
const propKey = classNames.get(key) || hypenateProperty(key)
|
|
650
660
|
return { className: \`\${propKey}${separator}\${withoutSpace(value)}\` }
|
|
651
|
-
}` : `(key, value) => ({ className: \`\${
|
|
661
|
+
}` : `(key, value) => ({ className: \`\${classNames.get(key) || hypenateProperty(key)}${separator}\${withoutSpace(value)}\` })`},
|
|
652
662
|
${utility.hasShorthand ? "hasShorthand: true," : ""}
|
|
653
663
|
resolveShorthand: ${utility.hasShorthand ? "resolveShorthand" : "prop => prop"},
|
|
654
664
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230810090440",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
"pluralize": "8.0.0",
|
|
21
21
|
"postcss": "8.4.27",
|
|
22
22
|
"ts-pattern": "5.0.4",
|
|
23
|
-
"@pandacss/core": "0.0.0-dev-
|
|
24
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
25
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
26
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
27
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
28
|
-
"@pandacss/types": "0.0.0-dev-
|
|
23
|
+
"@pandacss/core": "0.0.0-dev-20230810090440",
|
|
24
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230810090440",
|
|
25
|
+
"@pandacss/logger": "0.0.0-dev-20230810090440",
|
|
26
|
+
"@pandacss/shared": "0.0.0-dev-20230810090440",
|
|
27
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230810090440",
|
|
28
|
+
"@pandacss/types": "0.0.0-dev-20230810090440"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/pluralize": "0.0.30",
|
|
32
32
|
"hookable": "5.5.3",
|
|
33
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
33
|
+
"@pandacss/fixture": "0.0.0-dev-20230810090440"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prebuild": "tsx scripts/prebuild.ts",
|