@pandacss/generator 0.0.0-dev-20240313103423 → 0.0.0-dev-20240315003802
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 +42 -17
- package/dist/index.mjs +38 -13
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
36
36
|
|
|
37
37
|
// src/generator.ts
|
|
38
38
|
var import_core5 = require("@pandacss/core");
|
|
39
|
-
var
|
|
39
|
+
var import_ts_pattern13 = require("ts-pattern");
|
|
40
40
|
|
|
41
41
|
// src/artifacts/setup-artifacts.ts
|
|
42
42
|
var import_outdent43 = __toESM(require("outdent"));
|
|
@@ -2834,7 +2834,7 @@ var static_css_d_ts_default = {
|
|
|
2834
2834
|
|
|
2835
2835
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2836
2836
|
var system_types_d_ts_default = {
|
|
2837
|
-
content: "import type { ConditionalValue,
|
|
2837
|
+
content: "import type { ConditionalValue, Nested } from './conditions'\nimport type { PropertiesFallback } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Nested<SystemProperties & CssVarProperties>\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\ntype FilterStyleObject<P extends string> = {\n [K in P]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject\n}\ntype StyleProps = SystemStyleObject & WithCss\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n"
|
|
2838
2838
|
};
|
|
2839
2839
|
|
|
2840
2840
|
// src/artifacts/types/generated.ts
|
|
@@ -2910,6 +2910,7 @@ var generateTypesEntry = (ctx, isJsxRequired) => {
|
|
|
2910
2910
|
};
|
|
2911
2911
|
|
|
2912
2912
|
// src/artifacts/types/prop-types.ts
|
|
2913
|
+
var import_shared3 = require("@pandacss/shared");
|
|
2913
2914
|
var import_outdent40 = require("outdent");
|
|
2914
2915
|
var import_ts_pattern11 = require("ts-pattern");
|
|
2915
2916
|
function generatePropTypes(ctx) {
|
|
@@ -2926,6 +2927,8 @@ function generatePropTypes(ctx) {
|
|
|
2926
2927
|
interface PropertyValueTypes {`
|
|
2927
2928
|
];
|
|
2928
2929
|
const types = utility.getTypes();
|
|
2930
|
+
const cssVars = ctx.globalVars;
|
|
2931
|
+
const withCssVars = !cssVars.isEmpty() ? " | CssVars" : "";
|
|
2929
2932
|
for (const [prop, values] of types.entries()) {
|
|
2930
2933
|
result.push(` ${prop}: ${values.join(" | ")};`);
|
|
2931
2934
|
}
|
|
@@ -2944,6 +2947,10 @@ function generatePropTypes(ctx) {
|
|
|
2944
2947
|
return import_outdent40.outdent`
|
|
2945
2948
|
${result.join("\n")}
|
|
2946
2949
|
|
|
2950
|
+
${!cssVars.isEmpty() ? import_outdent40.outdent`
|
|
2951
|
+
type CssVars = ${(0, import_shared3.unionType)(cssVars.vars)}
|
|
2952
|
+
` : ""}
|
|
2953
|
+
|
|
2947
2954
|
type StrictableProps =
|
|
2948
2955
|
| 'alignContent'
|
|
2949
2956
|
| 'alignItems'
|
|
@@ -3025,8 +3032,11 @@ function generatePropTypes(ctx) {
|
|
|
3025
3032
|
|
|
3026
3033
|
type PropOrCondition<Key, Value> = ${(0, import_ts_pattern11.match)(ctx.config).with(
|
|
3027
3034
|
{ strictTokens: true, strictPropertyValues: true },
|
|
3028
|
-
() =>
|
|
3029
|
-
).with({ strictTokens: true }, () =>
|
|
3035
|
+
() => `ConditionalValue<WithEscapeHatch<FilterVagueString<Key, Value>>${withCssVars}>`
|
|
3036
|
+
).with({ strictTokens: true }, () => `ConditionalValue<WithEscapeHatch<Value>${withCssVars}>`).with(
|
|
3037
|
+
{ strictPropertyValues: true },
|
|
3038
|
+
() => `ConditionalValue<WithEscapeHatch<FilterVagueString<Key, Value>>${withCssVars}>`
|
|
3039
|
+
).otherwise(() => `ConditionalValue<Value | (string & {})${withCssVars}>`)}
|
|
3030
3040
|
|
|
3031
3041
|
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
3032
3042
|
? PropOrCondition<T, ${(0, import_ts_pattern11.match)(ctx.config).with(
|
|
@@ -3052,7 +3062,9 @@ function generatePropTypes(ctx) {
|
|
|
3052
3062
|
|
|
3053
3063
|
// src/artifacts/types/style-props.ts
|
|
3054
3064
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
3065
|
+
var import_shared4 = require("@pandacss/shared");
|
|
3055
3066
|
var import_outdent41 = __toESM(require("outdent"));
|
|
3067
|
+
var import_ts_pattern12 = require("ts-pattern");
|
|
3056
3068
|
function generateStyleProps(ctx) {
|
|
3057
3069
|
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
3058
3070
|
return import_outdent41.default`
|
|
@@ -3060,10 +3072,23 @@ function generateStyleProps(ctx) {
|
|
|
3060
3072
|
${ctx.file.importType("PropertyValue", "./prop-type")}
|
|
3061
3073
|
${ctx.file.importType("Token", "../tokens/index")}
|
|
3062
3074
|
|
|
3063
|
-
|
|
3064
|
-
|
|
3075
|
+
type CssVarValue = ConditionalValue<Token | (string & {}) | (number & {})>
|
|
3076
|
+
|
|
3077
|
+
type GenericCssVarProperties = {
|
|
3078
|
+
[key in \`--$\{string & {}}\`]?: CssVarValue
|
|
3065
3079
|
}
|
|
3066
3080
|
|
|
3081
|
+
${(0, import_ts_pattern12.match)(ctx.globalVars.isEmpty()).with(
|
|
3082
|
+
false,
|
|
3083
|
+
() => import_outdent41.default`
|
|
3084
|
+
type CssVarName = ${(0, import_shared4.unionType)(ctx.globalVars.names)}
|
|
3085
|
+
|
|
3086
|
+
type CssVar = \`--\${CssVarName}\`
|
|
3087
|
+
|
|
3088
|
+
export type CssVarProperties = ConfigCssVarProperties & GenericCssVarProperties
|
|
3089
|
+
`
|
|
3090
|
+
).otherwise(() => import_outdent41.default`export type CssVarProperties = GenericCssVarProperties`)}
|
|
3091
|
+
|
|
3067
3092
|
export interface SystemProperties {
|
|
3068
3093
|
${Array.from(props).map((v) => ` ${v}?: PropertyValue<'${v}'>`).join("\n")}
|
|
3069
3094
|
}
|
|
@@ -3071,7 +3096,7 @@ function generateStyleProps(ctx) {
|
|
|
3071
3096
|
}
|
|
3072
3097
|
|
|
3073
3098
|
// src/artifacts/types/token-types.ts
|
|
3074
|
-
var
|
|
3099
|
+
var import_shared5 = require("@pandacss/shared");
|
|
3075
3100
|
var import_outdent42 = require("outdent");
|
|
3076
3101
|
var import_pluralize = __toESM(require("pluralize"));
|
|
3077
3102
|
var categories = [
|
|
@@ -3104,27 +3129,27 @@ function generateTokenTypes(ctx) {
|
|
|
3104
3129
|
config: { theme }
|
|
3105
3130
|
} = ctx;
|
|
3106
3131
|
const set = /* @__PURE__ */ new Set();
|
|
3107
|
-
set.add(`export type Token = ${tokens.isEmpty ? "string" : (0,
|
|
3132
|
+
set.add(`export type Token = ${tokens.isEmpty ? "string" : (0, import_shared5.unionType)(Array.from(tokens.byName.keys()))}`);
|
|
3108
3133
|
const result = /* @__PURE__ */ new Set(["export type Tokens = {"]);
|
|
3109
3134
|
if (tokens.isEmpty) {
|
|
3110
3135
|
result.add("[token: string]: string");
|
|
3111
3136
|
} else {
|
|
3112
3137
|
const colorPaletteKeys = Array.from(tokens.view.colorPalettes.keys());
|
|
3113
3138
|
if (colorPaletteKeys.length) {
|
|
3114
|
-
set.add(`export type ColorPalette = ${(0,
|
|
3139
|
+
set.add(`export type ColorPalette = ${(0, import_shared5.unionType)(colorPaletteKeys)}`);
|
|
3115
3140
|
}
|
|
3116
3141
|
for (const [key, value] of tokens.view.categoryMap.entries()) {
|
|
3117
|
-
const typeName = (0,
|
|
3118
|
-
set.add(`export type ${typeName}Token = ${(0,
|
|
3142
|
+
const typeName = (0, import_shared5.capitalize)(import_pluralize.default.singular(key));
|
|
3143
|
+
set.add(`export type ${typeName}Token = ${(0, import_shared5.unionType)(value.keys())}`);
|
|
3119
3144
|
result.add(` ${key}: ${typeName}Token`);
|
|
3120
3145
|
}
|
|
3121
3146
|
if (theme?.keyframes)
|
|
3122
|
-
set.add(`export type AnimationName = ${(0,
|
|
3147
|
+
set.add(`export type AnimationName = ${(0, import_shared5.unionType)(Object.keys(theme.keyframes))}`);
|
|
3123
3148
|
result.add(` animationName: AnimationName`);
|
|
3124
3149
|
}
|
|
3125
3150
|
result.add("} & { [token: string]: never }");
|
|
3126
3151
|
set.add(Array.from(result).join("\n"));
|
|
3127
|
-
set.add(`export type TokenCategory = ${(0,
|
|
3152
|
+
set.add(`export type TokenCategory = ${(0, import_shared5.unionType)(categories)}`);
|
|
3128
3153
|
return import_outdent42.outdent.string(Array.from(set).join("\n\n"));
|
|
3129
3154
|
}
|
|
3130
3155
|
|
|
@@ -3637,10 +3662,10 @@ var generateParserCss = (ctx, decoder) => {
|
|
|
3637
3662
|
|
|
3638
3663
|
// src/artifacts/css/reset-css.ts
|
|
3639
3664
|
var import_core3 = require("@pandacss/core");
|
|
3640
|
-
var
|
|
3665
|
+
var import_shared6 = require("@pandacss/shared");
|
|
3641
3666
|
function generateResetCss(ctx, sheet) {
|
|
3642
3667
|
const { preflight } = ctx.config;
|
|
3643
|
-
const { scope = "", level = "parent" } = (0,
|
|
3668
|
+
const { scope = "", level = "parent" } = (0, import_shared6.isObject)(preflight) ? preflight : {};
|
|
3644
3669
|
let selector = "";
|
|
3645
3670
|
if (scope && level === "parent") {
|
|
3646
3671
|
selector = `${scope} `;
|
|
@@ -3738,7 +3763,7 @@ function generateResetCss(ctx, sheet) {
|
|
|
3738
3763
|
}
|
|
3739
3764
|
};
|
|
3740
3765
|
if (level === "element") {
|
|
3741
|
-
const modified = (0,
|
|
3766
|
+
const modified = (0, import_shared6.mapEntries)(scoped, (k, v) => [k, { [selector]: v }]);
|
|
3742
3767
|
Object.assign(reset, modified);
|
|
3743
3768
|
} else if (selector) {
|
|
3744
3769
|
reset[selector] = scoped;
|
|
@@ -3871,7 +3896,7 @@ var Generator = class extends import_core5.Context {
|
|
|
3871
3896
|
return generateArtifacts(this, ids);
|
|
3872
3897
|
};
|
|
3873
3898
|
appendCssOfType = (type, sheet) => {
|
|
3874
|
-
(0,
|
|
3899
|
+
(0, import_ts_pattern13.match)(type).with("preflight", () => generateResetCss(this, sheet)).with("tokens", () => generateTokenCss(this, sheet)).with("static", () => generateStaticCss(this, sheet)).with("global", () => generateGlobalCss(this, sheet)).with("keyframes", () => generateKeyframeCss(this, sheet)).otherwise(() => {
|
|
3875
3900
|
throw new Error(`Unknown css artifact type <${type}>`);
|
|
3876
3901
|
});
|
|
3877
3902
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/generator.ts
|
|
2
2
|
import { Context as Context2 } from "@pandacss/core";
|
|
3
|
-
import { match as
|
|
3
|
+
import { match as match13 } from "ts-pattern";
|
|
4
4
|
|
|
5
5
|
// src/artifacts/setup-artifacts.ts
|
|
6
6
|
import outdent43 from "outdent";
|
|
@@ -2798,7 +2798,7 @@ var static_css_d_ts_default = {
|
|
|
2798
2798
|
|
|
2799
2799
|
// src/artifacts/generated/system-types.d.ts.json
|
|
2800
2800
|
var system_types_d_ts_default = {
|
|
2801
|
-
content: "import type { ConditionalValue,
|
|
2801
|
+
content: "import type { ConditionalValue, Nested } from './conditions'\nimport type { PropertiesFallback } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\nexport type CssProperty = keyof PropertiesFallback\n\nexport interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Nested<SystemProperties & CssVarProperties>\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\ntype FilterStyleObject<P extends string> = {\n [K in P]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject\n}\ntype StyleProps = SystemStyleObject & WithCss\n\nexport type JsxStyleProps = StyleProps & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n"
|
|
2802
2802
|
};
|
|
2803
2803
|
|
|
2804
2804
|
// src/artifacts/types/generated.ts
|
|
@@ -2874,6 +2874,7 @@ var generateTypesEntry = (ctx, isJsxRequired) => {
|
|
|
2874
2874
|
};
|
|
2875
2875
|
|
|
2876
2876
|
// src/artifacts/types/prop-types.ts
|
|
2877
|
+
import { unionType as unionType3 } from "@pandacss/shared";
|
|
2877
2878
|
import { outdent as outdent40 } from "outdent";
|
|
2878
2879
|
import { match as match11 } from "ts-pattern";
|
|
2879
2880
|
function generatePropTypes(ctx) {
|
|
@@ -2890,6 +2891,8 @@ function generatePropTypes(ctx) {
|
|
|
2890
2891
|
interface PropertyValueTypes {`
|
|
2891
2892
|
];
|
|
2892
2893
|
const types = utility.getTypes();
|
|
2894
|
+
const cssVars = ctx.globalVars;
|
|
2895
|
+
const withCssVars = !cssVars.isEmpty() ? " | CssVars" : "";
|
|
2893
2896
|
for (const [prop, values] of types.entries()) {
|
|
2894
2897
|
result.push(` ${prop}: ${values.join(" | ")};`);
|
|
2895
2898
|
}
|
|
@@ -2908,6 +2911,10 @@ function generatePropTypes(ctx) {
|
|
|
2908
2911
|
return outdent40`
|
|
2909
2912
|
${result.join("\n")}
|
|
2910
2913
|
|
|
2914
|
+
${!cssVars.isEmpty() ? outdent40`
|
|
2915
|
+
type CssVars = ${unionType3(cssVars.vars)}
|
|
2916
|
+
` : ""}
|
|
2917
|
+
|
|
2911
2918
|
type StrictableProps =
|
|
2912
2919
|
| 'alignContent'
|
|
2913
2920
|
| 'alignItems'
|
|
@@ -2989,8 +2996,11 @@ function generatePropTypes(ctx) {
|
|
|
2989
2996
|
|
|
2990
2997
|
type PropOrCondition<Key, Value> = ${match11(ctx.config).with(
|
|
2991
2998
|
{ strictTokens: true, strictPropertyValues: true },
|
|
2992
|
-
() =>
|
|
2993
|
-
).with({ strictTokens: true }, () =>
|
|
2999
|
+
() => `ConditionalValue<WithEscapeHatch<FilterVagueString<Key, Value>>${withCssVars}>`
|
|
3000
|
+
).with({ strictTokens: true }, () => `ConditionalValue<WithEscapeHatch<Value>${withCssVars}>`).with(
|
|
3001
|
+
{ strictPropertyValues: true },
|
|
3002
|
+
() => `ConditionalValue<WithEscapeHatch<FilterVagueString<Key, Value>>${withCssVars}>`
|
|
3003
|
+
).otherwise(() => `ConditionalValue<Value | (string & {})${withCssVars}>`)}
|
|
2994
3004
|
|
|
2995
3005
|
type PropertyTypeValue<T extends string> = T extends keyof PropertyTypes
|
|
2996
3006
|
? PropOrCondition<T, ${match11(ctx.config).with(
|
|
@@ -3016,7 +3026,9 @@ function generatePropTypes(ctx) {
|
|
|
3016
3026
|
|
|
3017
3027
|
// src/artifacts/types/style-props.ts
|
|
3018
3028
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
3029
|
+
import { unionType as unionType4 } from "@pandacss/shared";
|
|
3019
3030
|
import outdent41 from "outdent";
|
|
3031
|
+
import { match as match12 } from "ts-pattern";
|
|
3020
3032
|
function generateStyleProps(ctx) {
|
|
3021
3033
|
const props = new Set(allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
3022
3034
|
return outdent41`
|
|
@@ -3024,10 +3036,23 @@ function generateStyleProps(ctx) {
|
|
|
3024
3036
|
${ctx.file.importType("PropertyValue", "./prop-type")}
|
|
3025
3037
|
${ctx.file.importType("Token", "../tokens/index")}
|
|
3026
3038
|
|
|
3027
|
-
|
|
3028
|
-
|
|
3039
|
+
type CssVarValue = ConditionalValue<Token | (string & {}) | (number & {})>
|
|
3040
|
+
|
|
3041
|
+
type GenericCssVarProperties = {
|
|
3042
|
+
[key in \`--$\{string & {}}\`]?: CssVarValue
|
|
3029
3043
|
}
|
|
3030
3044
|
|
|
3045
|
+
${match12(ctx.globalVars.isEmpty()).with(
|
|
3046
|
+
false,
|
|
3047
|
+
() => outdent41`
|
|
3048
|
+
type CssVarName = ${unionType4(ctx.globalVars.names)}
|
|
3049
|
+
|
|
3050
|
+
type CssVar = \`--\${CssVarName}\`
|
|
3051
|
+
|
|
3052
|
+
export type CssVarProperties = ConfigCssVarProperties & GenericCssVarProperties
|
|
3053
|
+
`
|
|
3054
|
+
).otherwise(() => outdent41`export type CssVarProperties = GenericCssVarProperties`)}
|
|
3055
|
+
|
|
3031
3056
|
export interface SystemProperties {
|
|
3032
3057
|
${Array.from(props).map((v) => ` ${v}?: PropertyValue<'${v}'>`).join("\n")}
|
|
3033
3058
|
}
|
|
@@ -3035,7 +3060,7 @@ function generateStyleProps(ctx) {
|
|
|
3035
3060
|
}
|
|
3036
3061
|
|
|
3037
3062
|
// src/artifacts/types/token-types.ts
|
|
3038
|
-
import { capitalize, unionType as
|
|
3063
|
+
import { capitalize, unionType as unionType5 } from "@pandacss/shared";
|
|
3039
3064
|
import { outdent as outdent42 } from "outdent";
|
|
3040
3065
|
import pluralize from "pluralize";
|
|
3041
3066
|
var categories = [
|
|
@@ -3068,27 +3093,27 @@ function generateTokenTypes(ctx) {
|
|
|
3068
3093
|
config: { theme }
|
|
3069
3094
|
} = ctx;
|
|
3070
3095
|
const set = /* @__PURE__ */ new Set();
|
|
3071
|
-
set.add(`export type Token = ${tokens.isEmpty ? "string" :
|
|
3096
|
+
set.add(`export type Token = ${tokens.isEmpty ? "string" : unionType5(Array.from(tokens.byName.keys()))}`);
|
|
3072
3097
|
const result = /* @__PURE__ */ new Set(["export type Tokens = {"]);
|
|
3073
3098
|
if (tokens.isEmpty) {
|
|
3074
3099
|
result.add("[token: string]: string");
|
|
3075
3100
|
} else {
|
|
3076
3101
|
const colorPaletteKeys = Array.from(tokens.view.colorPalettes.keys());
|
|
3077
3102
|
if (colorPaletteKeys.length) {
|
|
3078
|
-
set.add(`export type ColorPalette = ${
|
|
3103
|
+
set.add(`export type ColorPalette = ${unionType5(colorPaletteKeys)}`);
|
|
3079
3104
|
}
|
|
3080
3105
|
for (const [key, value] of tokens.view.categoryMap.entries()) {
|
|
3081
3106
|
const typeName = capitalize(pluralize.singular(key));
|
|
3082
|
-
set.add(`export type ${typeName}Token = ${
|
|
3107
|
+
set.add(`export type ${typeName}Token = ${unionType5(value.keys())}`);
|
|
3083
3108
|
result.add(` ${key}: ${typeName}Token`);
|
|
3084
3109
|
}
|
|
3085
3110
|
if (theme?.keyframes)
|
|
3086
|
-
set.add(`export type AnimationName = ${
|
|
3111
|
+
set.add(`export type AnimationName = ${unionType5(Object.keys(theme.keyframes))}`);
|
|
3087
3112
|
result.add(` animationName: AnimationName`);
|
|
3088
3113
|
}
|
|
3089
3114
|
result.add("} & { [token: string]: never }");
|
|
3090
3115
|
set.add(Array.from(result).join("\n"));
|
|
3091
|
-
set.add(`export type TokenCategory = ${
|
|
3116
|
+
set.add(`export type TokenCategory = ${unionType5(categories)}`);
|
|
3092
3117
|
return outdent42.string(Array.from(set).join("\n\n"));
|
|
3093
3118
|
}
|
|
3094
3119
|
|
|
@@ -3835,7 +3860,7 @@ var Generator = class extends Context2 {
|
|
|
3835
3860
|
return generateArtifacts(this, ids);
|
|
3836
3861
|
};
|
|
3837
3862
|
appendCssOfType = (type, sheet) => {
|
|
3838
|
-
|
|
3863
|
+
match13(type).with("preflight", () => generateResetCss(this, sheet)).with("tokens", () => generateTokenCss(this, sheet)).with("static", () => generateStaticCss(this, sheet)).with("global", () => generateGlobalCss(this, sheet)).with("keyframes", () => generateKeyframeCss(this, sheet)).otherwise(() => {
|
|
3839
3864
|
throw new Error(`Unknown css artifact type <${type}>`);
|
|
3840
3865
|
});
|
|
3841
3866
|
};
|
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-20240315003802",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"pluralize": "8.0.0",
|
|
38
38
|
"postcss": "8.4.35",
|
|
39
39
|
"ts-pattern": "5.0.8",
|
|
40
|
-
"@pandacss/core": "0.0.0-dev-
|
|
41
|
-
"@pandacss/is-valid-prop": "^0.0.0-dev-
|
|
42
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
43
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
44
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
45
|
-
"@pandacss/types": "0.0.0-dev-
|
|
40
|
+
"@pandacss/core": "0.0.0-dev-20240315003802",
|
|
41
|
+
"@pandacss/is-valid-prop": "^0.0.0-dev-20240315003802",
|
|
42
|
+
"@pandacss/logger": "0.0.0-dev-20240315003802",
|
|
43
|
+
"@pandacss/shared": "0.0.0-dev-20240315003802",
|
|
44
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20240315003802",
|
|
45
|
+
"@pandacss/types": "0.0.0-dev-20240315003802"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/pluralize": "0.0.33"
|