@pandacss/generator 0.10.0 → 0.11.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.js +31 -19
- package/dist/index.mjs +31 -19
- 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
|
}
|
|
@@ -2990,9 +3000,9 @@ function generatePropTypes(ctx) {
|
|
|
2990
3000
|
${result.join("\n")}
|
|
2991
3001
|
|
|
2992
3002
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2993
|
-
? ConditionalValue<PropertyTypes[T]${strictText}>
|
|
3003
|
+
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
2994
3004
|
: T extends keyof CssProperties
|
|
2995
|
-
? ConditionalValue<CssProperties[T]>
|
|
3005
|
+
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
2996
3006
|
: ConditionalValue<string | number>
|
|
2997
3007
|
`;
|
|
2998
3008
|
}
|
|
@@ -3341,7 +3351,9 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3341
3351
|
].filter(Boolean).join("\n\n") : unresolved
|
|
3342
3352
|
});
|
|
3343
3353
|
sheet.append(...files);
|
|
3344
|
-
|
|
3354
|
+
const output = sheet.toCss({ optimize: true, minify });
|
|
3355
|
+
ctx.hooks.callHook("generator:css", "styles.css", output);
|
|
3356
|
+
return output;
|
|
3345
3357
|
};
|
|
3346
3358
|
|
|
3347
3359
|
// src/artifacts/css/parser-css.ts
|
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
|
}
|
|
@@ -2959,9 +2969,9 @@ function generatePropTypes(ctx) {
|
|
|
2959
2969
|
${result.join("\n")}
|
|
2960
2970
|
|
|
2961
2971
|
export type PropertyValue<T extends string> = T extends keyof PropertyTypes
|
|
2962
|
-
? ConditionalValue<PropertyTypes[T]${strictText}>
|
|
2972
|
+
? ConditionalValue<PropertyTypes[T]${strictText} | (string & {})>
|
|
2963
2973
|
: T extends keyof CssProperties
|
|
2964
|
-
? ConditionalValue<CssProperties[T]>
|
|
2974
|
+
? ConditionalValue<CssProperties[T] | (string & {})>
|
|
2965
2975
|
: ConditionalValue<string | number>
|
|
2966
2976
|
`;
|
|
2967
2977
|
}
|
|
@@ -3310,7 +3320,9 @@ var generateFlattenedCss = (ctx) => (options) => {
|
|
|
3310
3320
|
].filter(Boolean).join("\n\n") : unresolved
|
|
3311
3321
|
});
|
|
3312
3322
|
sheet.append(...files);
|
|
3313
|
-
|
|
3323
|
+
const output = sheet.toCss({ optimize: true, minify });
|
|
3324
|
+
ctx.hooks.callHook("generator:css", "styles.css", output);
|
|
3325
|
+
return output;
|
|
3314
3326
|
};
|
|
3315
3327
|
|
|
3316
3328
|
// src/artifacts/css/parser-css.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
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.
|
|
24
|
-
"@pandacss/is-valid-prop": "0.
|
|
25
|
-
"@pandacss/logger": "0.
|
|
26
|
-
"@pandacss/shared": "0.
|
|
27
|
-
"@pandacss/token-dictionary": "0.
|
|
28
|
-
"@pandacss/types": "0.
|
|
23
|
+
"@pandacss/core": "0.11.0",
|
|
24
|
+
"@pandacss/is-valid-prop": "0.11.0",
|
|
25
|
+
"@pandacss/logger": "0.11.0",
|
|
26
|
+
"@pandacss/shared": "0.11.0",
|
|
27
|
+
"@pandacss/token-dictionary": "0.11.0",
|
|
28
|
+
"@pandacss/types": "0.11.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/pluralize": "0.0.30",
|
|
32
32
|
"hookable": "5.5.3",
|
|
33
|
-
"@pandacss/fixture": "0.
|
|
33
|
+
"@pandacss/fixture": "0.11.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"prebuild": "tsx scripts/prebuild.ts",
|