@pandacss/generator 1.6.0 → 1.7.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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +468 -43
- package/dist/index.mjs +475 -50
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/generator.ts
|
|
2
2
|
import { Context as Context2 } from "@pandacss/core";
|
|
3
3
|
import { dashCase, PandaError } from "@pandacss/shared";
|
|
4
|
-
import { match as
|
|
4
|
+
import { match as match14 } from "ts-pattern";
|
|
5
5
|
|
|
6
6
|
// src/artifacts/setup-artifacts.ts
|
|
7
7
|
import outdent48 from "outdent";
|
|
@@ -513,10 +513,9 @@ function generatedJsxHelpers(ctx) {
|
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
// src/artifacts/js/pattern.ts
|
|
516
|
-
import { compact
|
|
516
|
+
import { compact } from "@pandacss/shared";
|
|
517
517
|
import { stringify } from "javascript-stringify";
|
|
518
518
|
import { outdent as outdent10 } from "outdent";
|
|
519
|
-
import { match as match3 } from "ts-pattern";
|
|
520
519
|
function generatePattern(ctx, filters) {
|
|
521
520
|
if (ctx.patterns.isEmpty()) return;
|
|
522
521
|
const details = ctx.patterns.filterDetails(filters);
|
|
@@ -543,18 +542,8 @@ function generatePattern(ctx, filters) {
|
|
|
543
542
|
export interface ${upperName}Properties {
|
|
544
543
|
${Object.keys(properties ?? {}).map((key) => {
|
|
545
544
|
const value = properties[key];
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
}).with({ type: "token" }, (value2) => {
|
|
549
|
-
if (value2.property) {
|
|
550
|
-
return `${key}?: ConditionalValue<Tokens["${value2.value}"] | Properties["${value2.property}"]>`;
|
|
551
|
-
}
|
|
552
|
-
return `${key}?: ConditionalValue<Tokens["${value2.value}"]>`;
|
|
553
|
-
}).with({ type: "enum" }, (value2) => {
|
|
554
|
-
return `${key}?: ConditionalValue<${unionType(value2.value)}>`;
|
|
555
|
-
}).otherwise(() => {
|
|
556
|
-
return `${key}?: ConditionalValue<${value.type}>`;
|
|
557
|
-
});
|
|
545
|
+
const typeString = ctx.patterns.getPropertyType(value);
|
|
546
|
+
return `${key}?: ${typeString}`;
|
|
558
547
|
}).join("\n ")}
|
|
559
548
|
}
|
|
560
549
|
|
|
@@ -603,9 +592,9 @@ defaultValues`)}
|
|
|
603
592
|
|
|
604
593
|
// src/artifacts/js/recipe.ts
|
|
605
594
|
import { Recipes } from "@pandacss/core";
|
|
606
|
-
import { isBoolean, unionType
|
|
595
|
+
import { isBoolean, unionType } from "@pandacss/shared";
|
|
607
596
|
import { outdent as outdent11 } from "outdent";
|
|
608
|
-
import { match as
|
|
597
|
+
import { match as match3 } from "ts-pattern";
|
|
609
598
|
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
610
599
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
611
600
|
var hasOwn = (obj, key) => {
|
|
@@ -722,7 +711,7 @@ function generateRecipes(ctx, filters) {
|
|
|
722
711
|
}
|
|
723
712
|
return ctx.file.jsDocComment("", { default: defaultValue });
|
|
724
713
|
};
|
|
725
|
-
const jsCode =
|
|
714
|
+
const jsCode = match3(config).when(
|
|
726
715
|
Recipes.isSlotRecipeConfig,
|
|
727
716
|
(config2) => outdent11`
|
|
728
717
|
${ctx.file.import("compact, getSlotCompoundVariant, memo, splitProps", "../helpers")}
|
|
@@ -794,7 +783,7 @@ function generateRecipes(ctx, filters) {
|
|
|
794
783
|
interface ${upperName}Variant {
|
|
795
784
|
${Object.keys(variantKeyMap).map((key) => {
|
|
796
785
|
const values = variantKeyMap[key];
|
|
797
|
-
const valueStr = values.every(isBooleanValue) ? `${key}: boolean` : `${key}: ${
|
|
786
|
+
const valueStr = values.every(isBooleanValue) ? `${key}: boolean` : `${key}: ${unionType(values)}`;
|
|
798
787
|
return [getDefaultValueJsDoc(key), valueStr].filter(Boolean).join("\n");
|
|
799
788
|
}).join("\n")}
|
|
800
789
|
}
|
|
@@ -803,7 +792,7 @@ function generateRecipes(ctx, filters) {
|
|
|
803
792
|
[key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
|
|
804
793
|
}
|
|
805
794
|
|
|
806
|
-
${Recipes.isSlotRecipeConfig(config) ? `type ${upperName}Slot = ${
|
|
795
|
+
${Recipes.isSlotRecipeConfig(config) ? `type ${upperName}Slot = ${unionType(config.slots)}` : ""}
|
|
807
796
|
|
|
808
797
|
export type ${upperName}VariantProps = {
|
|
809
798
|
[key in keyof ${upperName}Variant]?: ${compoundVariants?.length ? `${upperName}Variant[key]` : `ConditionalValue<${upperName}Variant[key]>`} | undefined
|
|
@@ -1032,7 +1021,7 @@ function generatePreactJsxFactory(ctx) {
|
|
|
1032
1021
|
|
|
1033
1022
|
// src/artifacts/preact-jsx/pattern.ts
|
|
1034
1023
|
import { outdent as outdent15 } from "outdent";
|
|
1035
|
-
import { match as
|
|
1024
|
+
import { match as match4 } from "ts-pattern";
|
|
1036
1025
|
function generatePreactJsxPattern(ctx, filters) {
|
|
1037
1026
|
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1038
1027
|
const details = ctx.patterns.filterDetails(filters);
|
|
@@ -1050,7 +1039,7 @@ function generatePreactJsxPattern(ctx, filters) {
|
|
|
1050
1039
|
${ctx.file.import(factoryName, "./factory")}
|
|
1051
1040
|
|
|
1052
1041
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1053
|
-
${
|
|
1042
|
+
${match4(jsxStyleProps2).with(
|
|
1054
1043
|
"none",
|
|
1055
1044
|
() => outdent15`
|
|
1056
1045
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
@@ -1184,7 +1173,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
|
|
|
1184
1173
|
|
|
1185
1174
|
// src/artifacts/preact-jsx/create-style-context.ts
|
|
1186
1175
|
import { outdent as outdent17 } from "outdent";
|
|
1187
|
-
import { match as
|
|
1176
|
+
import { match as match5 } from "ts-pattern";
|
|
1188
1177
|
function generatePreactCreateStyleContext(ctx) {
|
|
1189
1178
|
const { factoryName } = ctx.jsx;
|
|
1190
1179
|
return {
|
|
@@ -1228,7 +1217,7 @@ function generatePreactCreateStyleContext(ctx) {
|
|
|
1228
1217
|
return { ...restProps, className: cx(slotStyles, restProps.className) }
|
|
1229
1218
|
}
|
|
1230
1219
|
${outdent17.string(
|
|
1231
|
-
|
|
1220
|
+
match5(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`)
|
|
1232
1221
|
)}
|
|
1233
1222
|
}
|
|
1234
1223
|
|
|
@@ -1581,7 +1570,7 @@ function generateQwikJsxFactory(ctx) {
|
|
|
1581
1570
|
|
|
1582
1571
|
// src/artifacts/qwik-jsx/pattern.ts
|
|
1583
1572
|
import { outdent as outdent21 } from "outdent";
|
|
1584
|
-
import { match as
|
|
1573
|
+
import { match as match6 } from "ts-pattern";
|
|
1585
1574
|
function generateQwikJsxPattern(ctx, filters) {
|
|
1586
1575
|
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1587
1576
|
const details = ctx.patterns.filterDetails(filters);
|
|
@@ -1598,7 +1587,7 @@ function generateQwikJsxPattern(ctx, filters) {
|
|
|
1598
1587
|
${ctx.file.import(factoryName, "./factory")}
|
|
1599
1588
|
|
|
1600
1589
|
export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
|
|
1601
|
-
${
|
|
1590
|
+
${match6(jsxStyleProps2).with(
|
|
1602
1591
|
"none",
|
|
1603
1592
|
() => outdent21`
|
|
1604
1593
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
@@ -1948,7 +1937,7 @@ function generateReactJsxFactory(ctx) {
|
|
|
1948
1937
|
|
|
1949
1938
|
// src/artifacts/react-jsx/pattern.ts
|
|
1950
1939
|
import { outdent as outdent26 } from "outdent";
|
|
1951
|
-
import { match as
|
|
1940
|
+
import { match as match7 } from "ts-pattern";
|
|
1952
1941
|
function generateReactJsxPattern(ctx, filters) {
|
|
1953
1942
|
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
1954
1943
|
const details = ctx.patterns.filterDetails(filters);
|
|
@@ -1965,7 +1954,7 @@ function generateReactJsxPattern(ctx, filters) {
|
|
|
1965
1954
|
${ctx.file.import(factoryName, "./factory")}
|
|
1966
1955
|
|
|
1967
1956
|
export const ${jsxName} = /* @__PURE__ */ forwardRef(function ${jsxName}(props, ref) {
|
|
1968
|
-
${
|
|
1957
|
+
${match7(jsxStyleProps2).with(
|
|
1969
1958
|
"none",
|
|
1970
1959
|
() => outdent26`
|
|
1971
1960
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
@@ -2101,7 +2090,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
|
|
|
2101
2090
|
|
|
2102
2091
|
// src/artifacts/react-jsx/create-style-context.ts
|
|
2103
2092
|
import { outdent as outdent28 } from "outdent";
|
|
2104
|
-
import { match as
|
|
2093
|
+
import { match as match8 } from "ts-pattern";
|
|
2105
2094
|
function generateReactCreateStyleContext(ctx) {
|
|
2106
2095
|
const { factoryName } = ctx.jsx;
|
|
2107
2096
|
return {
|
|
@@ -2143,7 +2132,7 @@ function generateReactCreateStyleContext(ctx) {
|
|
|
2143
2132
|
return { ...restProps, className: cx(slotStyles, restProps.className) }
|
|
2144
2133
|
}
|
|
2145
2134
|
${outdent28.string(
|
|
2146
|
-
|
|
2135
|
+
match8(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, className: cx(css(slotStyles), restProps.className) }`).otherwise(() => `return restProps`)
|
|
2147
2136
|
)}
|
|
2148
2137
|
}
|
|
2149
2138
|
|
|
@@ -2545,7 +2534,7 @@ function generateSolidJsxFactory(ctx) {
|
|
|
2545
2534
|
|
|
2546
2535
|
// src/artifacts/solid-jsx/pattern.ts
|
|
2547
2536
|
import { outdent as outdent32 } from "outdent";
|
|
2548
|
-
import { match as
|
|
2537
|
+
import { match as match9 } from "ts-pattern";
|
|
2549
2538
|
function generateSolidJsxPattern(ctx, filters) {
|
|
2550
2539
|
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
2551
2540
|
const details = ctx.patterns.filterDetails(filters);
|
|
@@ -2562,7 +2551,7 @@ function generateSolidJsxPattern(ctx, filters) {
|
|
|
2562
2551
|
${ctx.file.import(factoryName, "./factory")}
|
|
2563
2552
|
|
|
2564
2553
|
export const ${jsxName} = /* @__PURE__ */ function ${jsxName}(props) {
|
|
2565
|
-
${
|
|
2554
|
+
${match9(jsxStyleProps2).with(
|
|
2566
2555
|
"none",
|
|
2567
2556
|
() => outdent32`
|
|
2568
2557
|
const [patternProps, restProps] = splitProps(props, ${JSON.stringify(props)})
|
|
@@ -2702,7 +2691,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
|
|
|
2702
2691
|
|
|
2703
2692
|
// src/artifacts/solid-jsx/create-style-context.ts
|
|
2704
2693
|
import { outdent as outdent34 } from "outdent";
|
|
2705
|
-
import { match as
|
|
2694
|
+
import { match as match10 } from "ts-pattern";
|
|
2706
2695
|
function generateSolidCreateStyleContext(ctx) {
|
|
2707
2696
|
const { factoryName } = ctx.jsx;
|
|
2708
2697
|
return {
|
|
@@ -2745,7 +2734,7 @@ function generateSolidCreateStyleContext(ctx) {
|
|
|
2745
2734
|
return { ...restProps, class: cx(slotStyles, restProps.class) }
|
|
2746
2735
|
}
|
|
2747
2736
|
${outdent34.string(
|
|
2748
|
-
|
|
2737
|
+
match10(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`)
|
|
2749
2738
|
)}
|
|
2750
2739
|
}
|
|
2751
2740
|
|
|
@@ -3191,7 +3180,7 @@ function generateVueJsxFactory(ctx) {
|
|
|
3191
3180
|
|
|
3192
3181
|
// src/artifacts/vue-jsx/pattern.ts
|
|
3193
3182
|
import { outdent as outdent38 } from "outdent";
|
|
3194
|
-
import { match as
|
|
3183
|
+
import { match as match11 } from "ts-pattern";
|
|
3195
3184
|
function generateVueJsxPattern(ctx, filters) {
|
|
3196
3185
|
const { typeName, factoryName, styleProps: jsxStyleProps2 } = ctx.jsx;
|
|
3197
3186
|
const details = ctx.patterns.filterDetails(filters);
|
|
@@ -3211,7 +3200,7 @@ function generateVueJsxPattern(ctx, filters) {
|
|
|
3211
3200
|
inheritAttrs: false,
|
|
3212
3201
|
props: ${JSON.stringify(props)},
|
|
3213
3202
|
setup(props, { attrs, slots }) {
|
|
3214
|
-
${
|
|
3203
|
+
${match11(jsxStyleProps2).with(
|
|
3215
3204
|
"none",
|
|
3216
3205
|
() => outdent38`
|
|
3217
3206
|
const cssProps = computed(() => {
|
|
@@ -3360,7 +3349,7 @@ export type ${variantName}<T extends ${componentName}<any, any>> = T extends ${c
|
|
|
3360
3349
|
|
|
3361
3350
|
// src/artifacts/vue-jsx/create-style-context.ts
|
|
3362
3351
|
import { outdent as outdent40 } from "outdent";
|
|
3363
|
-
import { match as
|
|
3352
|
+
import { match as match12 } from "ts-pattern";
|
|
3364
3353
|
function generateVueCreateStyleContext(ctx) {
|
|
3365
3354
|
const { factoryName } = ctx.jsx;
|
|
3366
3355
|
return {
|
|
@@ -3397,7 +3386,7 @@ function generateVueCreateStyleContext(ctx) {
|
|
|
3397
3386
|
return { ...restProps, class: cx(slotStyles, restProps.class) }
|
|
3398
3387
|
}
|
|
3399
3388
|
${outdent40.string(
|
|
3400
|
-
|
|
3389
|
+
match12(ctx.config.jsxStyleProps).with("all", () => `return { ...slotStyles, ...restProps }`).with("minimal", () => `return { ...restProps, css: css.raw(slotStyles, restProps.css) }`).with("none", () => `return { ...restProps, class: cx(css(slotStyles), restProps.class) }`).otherwise(() => `return restProps`)
|
|
3401
3390
|
)}
|
|
3402
3391
|
}
|
|
3403
3392
|
|
|
@@ -3786,7 +3775,7 @@ function generateJsxCreateStyleContext(ctx) {
|
|
|
3786
3775
|
}
|
|
3787
3776
|
|
|
3788
3777
|
// src/artifacts/types/generated.ts
|
|
3789
|
-
import { match as
|
|
3778
|
+
import { match as match13 } from "ts-pattern";
|
|
3790
3779
|
|
|
3791
3780
|
// src/artifacts/generated/composition.d.ts.json
|
|
3792
3781
|
var composition_d_ts_default = {
|
|
@@ -4495,7 +4484,7 @@ var parts_d_ts_default = {
|
|
|
4495
4484
|
|
|
4496
4485
|
// src/artifacts/generated/pattern.d.ts.json
|
|
4497
4486
|
var pattern_d_ts_default = {
|
|
4498
|
-
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty }\n | { type: 'enum'; value: string[] }\n | { type: 'token'; value: TokenCategory; property?: CssProperty }\n | { type: 'string' | 'boolean' | 'number' }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
|
|
4487
|
+
content: "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The JSX element rendered by the pattern\n * @default 'div'\n */\n jsxElement?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The jsx element name this pattern will generate.\n */\n jsxName?: string\n /**\n * The jsx elements to track for this pattern. Can be string or Regexp.\n *\n * @default capitalize(pattern.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Whether to only generate types for the specified properties.\n * This will disallow css properties\n */\n strict?: boolean\n /**\n * @experimental\n * Disallow certain css properties for this pattern\n */\n blocklist?: LiteralUnion<CssProperty>[]\n}\n"
|
|
4499
4488
|
};
|
|
4500
4489
|
|
|
4501
4490
|
// src/artifacts/generated/recipe.d.ts.json
|
|
@@ -4534,7 +4523,7 @@ var jsxStyleProps = "export type JsxStyleProps = SystemStyleObject & WithCss";
|
|
|
4534
4523
|
function getGeneratedSystemTypes(ctx) {
|
|
4535
4524
|
return {
|
|
4536
4525
|
system: ctx.file.rewriteTypeImport(
|
|
4537
|
-
|
|
4526
|
+
match13(ctx.jsx.styleProps).with("all", () => system_types_d_ts_default.content).with(
|
|
4538
4527
|
"minimal",
|
|
4539
4528
|
() => system_types_d_ts_default.content.replace("WithHTMLProps<T>,", "T,").replace(jsxStyleProps, "export type JsxStyleProps = WithCss")
|
|
4540
4529
|
).with(
|
|
@@ -4652,12 +4641,12 @@ function generatePropTypes(ctx) {
|
|
|
4652
4641
|
|
|
4653
4642
|
// src/artifacts/types/style-props.ts
|
|
4654
4643
|
import { allCssProperties } from "@pandacss/is-valid-prop";
|
|
4655
|
-
import { unionType as
|
|
4644
|
+
import { unionType as unionType2 } from "@pandacss/shared";
|
|
4656
4645
|
import outdent45 from "outdent";
|
|
4657
4646
|
function generateStyleProps(ctx) {
|
|
4658
4647
|
const props = new Set(allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
4659
4648
|
const propTypes = ctx.utility.getTypes();
|
|
4660
|
-
const cssVars =
|
|
4649
|
+
const cssVars = unionType2(ctx.globalVars.vars);
|
|
4661
4650
|
return outdent45`
|
|
4662
4651
|
${ctx.file.importType("ConditionalValue", "./conditions")}
|
|
4663
4652
|
${ctx.file.importType("OnlyKnown, UtilityValues, WithEscapeHatch", "./prop-type")}
|
|
@@ -4779,7 +4768,7 @@ var restrict = (key, value, config) => {
|
|
|
4779
4768
|
};
|
|
4780
4769
|
|
|
4781
4770
|
// src/artifacts/types/token-types.ts
|
|
4782
|
-
import { capitalize, unionType as
|
|
4771
|
+
import { capitalize, unionType as unionType3 } from "@pandacss/shared";
|
|
4783
4772
|
import { outdent as outdent46 } from "outdent";
|
|
4784
4773
|
import pluralize from "pluralize";
|
|
4785
4774
|
var categories = [
|
|
@@ -4817,22 +4806,22 @@ function generateTokenTypes(ctx) {
|
|
|
4817
4806
|
} else {
|
|
4818
4807
|
const colorPaletteKeys = Array.from(tokens.view.colorPalettes.keys());
|
|
4819
4808
|
if (colorPaletteKeys.length) {
|
|
4820
|
-
set.add(`export type ColorPalette = ${
|
|
4809
|
+
set.add(`export type ColorPalette = ${unionType3(colorPaletteKeys)}`);
|
|
4821
4810
|
}
|
|
4822
4811
|
for (const [key, value] of tokens.view.categoryMap.entries()) {
|
|
4823
4812
|
const typeName = capitalize(pluralize.singular(key));
|
|
4824
4813
|
const categoryName = `${typeName}Token`;
|
|
4825
|
-
set.add(`export type ${categoryName} = ${
|
|
4814
|
+
set.add(`export type ${categoryName} = ${unionType3(value.keys())}`);
|
|
4826
4815
|
tokenSet.add(`${key}.\${${categoryName}}`);
|
|
4827
4816
|
result.add(` ${key}: ${categoryName}`);
|
|
4828
4817
|
}
|
|
4829
4818
|
}
|
|
4830
4819
|
result.add("} & { [token: string]: never }");
|
|
4831
4820
|
set.add(Array.from(result).join("\n"));
|
|
4832
|
-
set.add(`export type TokenCategory = ${
|
|
4821
|
+
set.add(`export type TokenCategory = ${unionType3(categories)}`);
|
|
4833
4822
|
const arr = Array.from(set);
|
|
4834
4823
|
arr.unshift(
|
|
4835
|
-
`export type Token = ${
|
|
4824
|
+
`export type Token = ${unionType3(tokenSet, {
|
|
4836
4825
|
stringify: (t) => `\`${t}\``,
|
|
4837
4826
|
fallback: "string"
|
|
4838
4827
|
})}`
|
|
@@ -5701,6 +5690,424 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
5701
5690
|
}
|
|
5702
5691
|
};
|
|
5703
5692
|
|
|
5693
|
+
// src/spec/animation-styles.ts
|
|
5694
|
+
import { isObject as isObject2, walkObject } from "@pandacss/shared";
|
|
5695
|
+
var collectAnimationStyles = (values) => {
|
|
5696
|
+
const result = [];
|
|
5697
|
+
walkObject(
|
|
5698
|
+
values,
|
|
5699
|
+
(token, paths) => {
|
|
5700
|
+
if (token && isObject2(token) && "value" in token) {
|
|
5701
|
+
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
5702
|
+
result.push({
|
|
5703
|
+
name: filteredPaths.join("."),
|
|
5704
|
+
description: token.description
|
|
5705
|
+
});
|
|
5706
|
+
}
|
|
5707
|
+
},
|
|
5708
|
+
{
|
|
5709
|
+
stop: (v) => isObject2(v) && "value" in v
|
|
5710
|
+
}
|
|
5711
|
+
);
|
|
5712
|
+
return result;
|
|
5713
|
+
};
|
|
5714
|
+
var generateAnimationStylesSpec = (ctx) => {
|
|
5715
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
|
|
5716
|
+
const animationStyles = collectAnimationStyles(ctx.config.theme?.animationStyles ?? {});
|
|
5717
|
+
const animationStylesSpec = animationStyles.map((style) => {
|
|
5718
|
+
const functionExamples = [`css({ animationStyle: '${style.name}' })`];
|
|
5719
|
+
const jsxExamples = [];
|
|
5720
|
+
if (jsxStyleProps2 === "all") {
|
|
5721
|
+
jsxExamples.push(`<Box animationStyle="${style.name}" />`);
|
|
5722
|
+
} else if (jsxStyleProps2 === "minimal") {
|
|
5723
|
+
jsxExamples.push(`<Box css={{ animationStyle: '${style.name}' }} />`);
|
|
5724
|
+
}
|
|
5725
|
+
return {
|
|
5726
|
+
name: style.name,
|
|
5727
|
+
description: style.description,
|
|
5728
|
+
functionExamples,
|
|
5729
|
+
jsxExamples
|
|
5730
|
+
};
|
|
5731
|
+
});
|
|
5732
|
+
return {
|
|
5733
|
+
type: "animation-styles",
|
|
5734
|
+
data: animationStylesSpec
|
|
5735
|
+
};
|
|
5736
|
+
};
|
|
5737
|
+
|
|
5738
|
+
// src/spec/color-palette.ts
|
|
5739
|
+
var generateColorPaletteSpec = (ctx) => {
|
|
5740
|
+
const colorPaletteConfig = ctx.config.theme?.colorPalette;
|
|
5741
|
+
if (colorPaletteConfig?.enabled === false) {
|
|
5742
|
+
return null;
|
|
5743
|
+
}
|
|
5744
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
|
|
5745
|
+
const values = Array.from(ctx.tokens.view.colorPalettes.keys()).sort();
|
|
5746
|
+
if (!values.length) {
|
|
5747
|
+
return null;
|
|
5748
|
+
}
|
|
5749
|
+
const functionExamples = [
|
|
5750
|
+
`css({ colorPalette: 'blue' })`,
|
|
5751
|
+
`css({ colorPalette: 'blue', bg: 'colorPalette.500', color: 'colorPalette.50' })`
|
|
5752
|
+
];
|
|
5753
|
+
const jsxExamples = [];
|
|
5754
|
+
if (jsxStyleProps2 === "all") {
|
|
5755
|
+
jsxExamples.push(`<Box colorPalette="blue" />`);
|
|
5756
|
+
jsxExamples.push(`<Box colorPalette="blue" bg="colorPalette.500" color="colorPalette.50" />`);
|
|
5757
|
+
} else if (jsxStyleProps2 === "minimal") {
|
|
5758
|
+
jsxExamples.push(`<Box css={{ colorPalette: 'blue' }} />`);
|
|
5759
|
+
jsxExamples.push(`<Box css={{ colorPalette: 'blue', bg: 'colorPalette.500', color: 'colorPalette.50' }} />`);
|
|
5760
|
+
}
|
|
5761
|
+
return {
|
|
5762
|
+
type: "color-palette",
|
|
5763
|
+
data: {
|
|
5764
|
+
values,
|
|
5765
|
+
functionExamples,
|
|
5766
|
+
jsxExamples
|
|
5767
|
+
}
|
|
5768
|
+
};
|
|
5769
|
+
};
|
|
5770
|
+
|
|
5771
|
+
// src/spec/conditions.ts
|
|
5772
|
+
var generateConditionsSpec = (ctx) => {
|
|
5773
|
+
const breakpointKeys = new Set(Object.keys(ctx.conditions.breakpoints.conditions));
|
|
5774
|
+
const conditions = Object.entries(ctx.conditions.values).map(([name, detail]) => {
|
|
5775
|
+
const value = Array.isArray(detail.raw) ? detail.raw.join(", ") : detail.raw;
|
|
5776
|
+
const nameWithoutUnderscore = name.startsWith("_") ? name.slice(1) : name;
|
|
5777
|
+
const isBreakpoint = breakpointKeys.has(name) || breakpointKeys.has(nameWithoutUnderscore);
|
|
5778
|
+
const conditionName = isBreakpoint ? nameWithoutUnderscore : name;
|
|
5779
|
+
return {
|
|
5780
|
+
name: conditionName,
|
|
5781
|
+
value: value ?? "",
|
|
5782
|
+
functionExamples: [
|
|
5783
|
+
`css({ margin: { base: '2', ${conditionName}: '4' } })`,
|
|
5784
|
+
`css({ margin: '2', ${conditionName}: { margin: '4' } })`
|
|
5785
|
+
],
|
|
5786
|
+
jsxExamples: [
|
|
5787
|
+
`<Box margin={{ base: '2', ${conditionName}: '4'}} />`,
|
|
5788
|
+
`<Box margin='2' ${conditionName}={{ margin: '4' }} />`
|
|
5789
|
+
]
|
|
5790
|
+
};
|
|
5791
|
+
});
|
|
5792
|
+
return {
|
|
5793
|
+
type: "conditions",
|
|
5794
|
+
data: conditions
|
|
5795
|
+
};
|
|
5796
|
+
};
|
|
5797
|
+
|
|
5798
|
+
// src/spec/keyframes.ts
|
|
5799
|
+
var generateKeyframesSpec = (ctx) => {
|
|
5800
|
+
const keyframes = Object.keys(ctx.config.theme?.keyframes ?? {}).map((name) => ({
|
|
5801
|
+
name,
|
|
5802
|
+
functionExamples: [`css({ animationName: '${name}' })`, `css({ animation: '${name} 1s ease-in-out infinite' })`],
|
|
5803
|
+
jsxExamples: [`<Box animationName="${name}" />`, `<Box animation="${name} 1s ease-in-out infinite" />`]
|
|
5804
|
+
}));
|
|
5805
|
+
return {
|
|
5806
|
+
type: "keyframes",
|
|
5807
|
+
data: keyframes
|
|
5808
|
+
};
|
|
5809
|
+
};
|
|
5810
|
+
|
|
5811
|
+
// src/spec/layer-styles.ts
|
|
5812
|
+
import { isObject as isObject3, walkObject as walkObject2 } from "@pandacss/shared";
|
|
5813
|
+
var collectLayerStyles = (values) => {
|
|
5814
|
+
const result = [];
|
|
5815
|
+
walkObject2(
|
|
5816
|
+
values,
|
|
5817
|
+
(token, paths) => {
|
|
5818
|
+
if (token && isObject3(token) && "value" in token) {
|
|
5819
|
+
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
5820
|
+
result.push({
|
|
5821
|
+
name: filteredPaths.join("."),
|
|
5822
|
+
description: token.description
|
|
5823
|
+
});
|
|
5824
|
+
}
|
|
5825
|
+
},
|
|
5826
|
+
{
|
|
5827
|
+
stop: (v) => isObject3(v) && "value" in v
|
|
5828
|
+
}
|
|
5829
|
+
);
|
|
5830
|
+
return result;
|
|
5831
|
+
};
|
|
5832
|
+
var generateLayerStylesSpec = (ctx) => {
|
|
5833
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
|
|
5834
|
+
const layerStyles = collectLayerStyles(ctx.config.theme?.layerStyles ?? {});
|
|
5835
|
+
const layerStylesSpec = layerStyles.map((style) => {
|
|
5836
|
+
const functionExamples = [`css({ layerStyle: '${style.name}' })`];
|
|
5837
|
+
const jsxExamples = [];
|
|
5838
|
+
if (jsxStyleProps2 === "all") {
|
|
5839
|
+
jsxExamples.push(`<Box layerStyle="${style.name}" />`);
|
|
5840
|
+
} else if (jsxStyleProps2 === "minimal") {
|
|
5841
|
+
jsxExamples.push(`<Box css={{ layerStyle: '${style.name}' }} />`);
|
|
5842
|
+
}
|
|
5843
|
+
return {
|
|
5844
|
+
name: style.name,
|
|
5845
|
+
description: style.description,
|
|
5846
|
+
functionExamples,
|
|
5847
|
+
jsxExamples
|
|
5848
|
+
};
|
|
5849
|
+
});
|
|
5850
|
+
return {
|
|
5851
|
+
type: "layer-styles",
|
|
5852
|
+
data: layerStylesSpec
|
|
5853
|
+
};
|
|
5854
|
+
};
|
|
5855
|
+
|
|
5856
|
+
// src/spec/patterns.ts
|
|
5857
|
+
var generatePatternsSpec = (ctx) => {
|
|
5858
|
+
const patterns = ctx.patterns.details.map((node) => {
|
|
5859
|
+
const patternName = node.baseName;
|
|
5860
|
+
const jsxName = node.jsxName;
|
|
5861
|
+
const properties = Object.entries(node.config.properties ?? {});
|
|
5862
|
+
const functionExamples = [];
|
|
5863
|
+
const jsxExamples = [];
|
|
5864
|
+
if (properties.length === 0) {
|
|
5865
|
+
functionExamples.push(`${patternName}()`);
|
|
5866
|
+
jsxExamples.push(`<${jsxName} />`);
|
|
5867
|
+
} else {
|
|
5868
|
+
properties.forEach(([propName, prop]) => {
|
|
5869
|
+
let exampleValue = "<value>";
|
|
5870
|
+
if (prop.type === "enum" && prop.value?.length > 0) {
|
|
5871
|
+
exampleValue = `"${prop.value[0]}"`;
|
|
5872
|
+
} else if (prop.type === "boolean") {
|
|
5873
|
+
exampleValue = "true";
|
|
5874
|
+
} else if (prop.type === "number") {
|
|
5875
|
+
exampleValue = "4";
|
|
5876
|
+
} else if (prop.type === "token") {
|
|
5877
|
+
exampleValue = '"md"';
|
|
5878
|
+
}
|
|
5879
|
+
functionExamples.push(`${patternName}({ ${propName}: ${exampleValue} })`);
|
|
5880
|
+
jsxExamples.push(`<${jsxName} ${propName}={${exampleValue}} />`);
|
|
5881
|
+
});
|
|
5882
|
+
}
|
|
5883
|
+
const defaultValues = typeof node.config.defaultValues === "object" ? node.config.defaultValues : {};
|
|
5884
|
+
return {
|
|
5885
|
+
name: patternName,
|
|
5886
|
+
description: node.config.description,
|
|
5887
|
+
properties: properties.map(([name, prop]) => ({
|
|
5888
|
+
name,
|
|
5889
|
+
type: ctx.patterns.getPropertyType(prop),
|
|
5890
|
+
description: prop.description,
|
|
5891
|
+
defaultValue: defaultValues[name]
|
|
5892
|
+
})),
|
|
5893
|
+
jsx: jsxName,
|
|
5894
|
+
functionExamples,
|
|
5895
|
+
jsxExamples
|
|
5896
|
+
};
|
|
5897
|
+
});
|
|
5898
|
+
return {
|
|
5899
|
+
type: "patterns",
|
|
5900
|
+
data: patterns
|
|
5901
|
+
};
|
|
5902
|
+
};
|
|
5903
|
+
|
|
5904
|
+
// src/spec/recipes.ts
|
|
5905
|
+
var getFirstVariantValue = (variantKeyMap, key) => {
|
|
5906
|
+
const values = variantKeyMap[key];
|
|
5907
|
+
return values && values.length > 0 ? values[0] : null;
|
|
5908
|
+
};
|
|
5909
|
+
var buildVariantProps = (variantKeys, variantKeyMap, formatFn, separator) => {
|
|
5910
|
+
return variantKeys.map((key) => {
|
|
5911
|
+
const value = getFirstVariantValue(variantKeyMap, key);
|
|
5912
|
+
return value ? formatFn(key, value) : null;
|
|
5913
|
+
}).filter(Boolean).join(separator);
|
|
5914
|
+
};
|
|
5915
|
+
var generateRecipesSpec = (ctx) => {
|
|
5916
|
+
const recipes = ctx.recipes.details.map((node) => {
|
|
5917
|
+
const recipeName = node.baseName;
|
|
5918
|
+
const jsxName = node.jsxName;
|
|
5919
|
+
const variantKeys = Object.keys(node.variantKeyMap);
|
|
5920
|
+
const functionExamples = [];
|
|
5921
|
+
const jsxExamples = [];
|
|
5922
|
+
if (variantKeys.length === 0) {
|
|
5923
|
+
functionExamples.push(`${recipeName}()`);
|
|
5924
|
+
jsxExamples.push(`<${jsxName} />`);
|
|
5925
|
+
} else {
|
|
5926
|
+
variantKeys.forEach((variantKey) => {
|
|
5927
|
+
const firstValue = getFirstVariantValue(node.variantKeyMap, variantKey);
|
|
5928
|
+
if (firstValue) {
|
|
5929
|
+
functionExamples.push(`${recipeName}({ ${variantKey}: '${firstValue}' })`);
|
|
5930
|
+
jsxExamples.push(`<${jsxName} ${variantKey}="${firstValue}" />`);
|
|
5931
|
+
}
|
|
5932
|
+
});
|
|
5933
|
+
if (variantKeys.length > 1) {
|
|
5934
|
+
const props = buildVariantProps(variantKeys, node.variantKeyMap, (key, value) => `${key}: '${value}'`, ", ");
|
|
5935
|
+
const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap, (key, value) => `${key}="${value}"`, " ");
|
|
5936
|
+
if (props && jsxProps) {
|
|
5937
|
+
functionExamples.push(`${recipeName}({ ${props} })`);
|
|
5938
|
+
jsxExamples.push(`<${jsxName} ${jsxProps} />`);
|
|
5939
|
+
}
|
|
5940
|
+
}
|
|
5941
|
+
}
|
|
5942
|
+
return {
|
|
5943
|
+
name: recipeName,
|
|
5944
|
+
description: node.config.description,
|
|
5945
|
+
variants: node.variantKeyMap,
|
|
5946
|
+
defaultVariants: node.config.defaultVariants ?? {},
|
|
5947
|
+
functionExamples,
|
|
5948
|
+
jsxExamples
|
|
5949
|
+
};
|
|
5950
|
+
});
|
|
5951
|
+
return {
|
|
5952
|
+
type: "recipes",
|
|
5953
|
+
data: recipes
|
|
5954
|
+
};
|
|
5955
|
+
};
|
|
5956
|
+
|
|
5957
|
+
// src/spec/text-styles.ts
|
|
5958
|
+
import { isObject as isObject4, walkObject as walkObject3 } from "@pandacss/shared";
|
|
5959
|
+
var collectTextStyles = (values) => {
|
|
5960
|
+
const result = [];
|
|
5961
|
+
walkObject3(
|
|
5962
|
+
values,
|
|
5963
|
+
(token, paths) => {
|
|
5964
|
+
if (token && isObject4(token) && "value" in token) {
|
|
5965
|
+
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
5966
|
+
result.push({
|
|
5967
|
+
name: filteredPaths.join("."),
|
|
5968
|
+
description: token.description
|
|
5969
|
+
});
|
|
5970
|
+
}
|
|
5971
|
+
},
|
|
5972
|
+
{
|
|
5973
|
+
stop: (v) => isObject4(v) && "value" in v
|
|
5974
|
+
}
|
|
5975
|
+
);
|
|
5976
|
+
return result;
|
|
5977
|
+
};
|
|
5978
|
+
var generateTextStylesSpec = (ctx) => {
|
|
5979
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
|
|
5980
|
+
const textStyles = collectTextStyles(ctx.config.theme?.textStyles ?? {});
|
|
5981
|
+
const textStylesSpec = textStyles.map((style) => {
|
|
5982
|
+
const functionExamples = [`css({ textStyle: '${style.name}' })`];
|
|
5983
|
+
const jsxExamples = [];
|
|
5984
|
+
if (jsxStyleProps2 === "all") {
|
|
5985
|
+
jsxExamples.push(`<Box textStyle="${style.name}" />`);
|
|
5986
|
+
} else if (jsxStyleProps2 === "minimal") {
|
|
5987
|
+
jsxExamples.push(`<Box css={{ textStyle: '${style.name}' }} />`);
|
|
5988
|
+
}
|
|
5989
|
+
return {
|
|
5990
|
+
name: style.name,
|
|
5991
|
+
description: style.description,
|
|
5992
|
+
functionExamples,
|
|
5993
|
+
jsxExamples
|
|
5994
|
+
};
|
|
5995
|
+
});
|
|
5996
|
+
return {
|
|
5997
|
+
type: "text-styles",
|
|
5998
|
+
data: textStylesSpec
|
|
5999
|
+
};
|
|
6000
|
+
};
|
|
6001
|
+
|
|
6002
|
+
// src/spec/tokens.ts
|
|
6003
|
+
import { walkObject as walkObject4 } from "@pandacss/shared";
|
|
6004
|
+
var CATEGORY_PROPERTY_MAP = {
|
|
6005
|
+
colors: "color",
|
|
6006
|
+
spacing: "padding",
|
|
6007
|
+
sizes: "width",
|
|
6008
|
+
fonts: "fontFamily",
|
|
6009
|
+
fontSizes: "fontSize",
|
|
6010
|
+
fontWeights: "fontWeight",
|
|
6011
|
+
letterSpacings: "letterSpacing",
|
|
6012
|
+
lineHeights: "lineHeight",
|
|
6013
|
+
shadows: "boxShadow",
|
|
6014
|
+
radii: "borderRadius",
|
|
6015
|
+
durations: "transitionDuration",
|
|
6016
|
+
easings: "transitionTimingFunction",
|
|
6017
|
+
gradients: "backgroundImage",
|
|
6018
|
+
aspectRatios: "aspectRatio",
|
|
6019
|
+
cursor: "cursor",
|
|
6020
|
+
borderWidths: "borderWidth",
|
|
6021
|
+
borders: "border",
|
|
6022
|
+
zIndex: "zIndex",
|
|
6023
|
+
opacity: "opacity",
|
|
6024
|
+
blurs: "filter"
|
|
6025
|
+
};
|
|
6026
|
+
var getCategoryProperty = (category) => {
|
|
6027
|
+
return category ? CATEGORY_PROPERTY_MAP[category] ?? "color" : "color";
|
|
6028
|
+
};
|
|
6029
|
+
var generateTokenExamples = (token, jsxStyleProps2 = "all") => {
|
|
6030
|
+
const prop = getCategoryProperty(token.extensions?.category);
|
|
6031
|
+
const tokenName = token.extensions.prop;
|
|
6032
|
+
const fullTokenName = token.name;
|
|
6033
|
+
const functionExamples = [`css({ ${prop}: '${tokenName}' })`];
|
|
6034
|
+
const tokenFunctionExamples = [`token('${fullTokenName}')`];
|
|
6035
|
+
const jsxExamples = [];
|
|
6036
|
+
if (jsxStyleProps2 === "all") {
|
|
6037
|
+
jsxExamples.push(`<Box ${prop}="${tokenName}" />`);
|
|
6038
|
+
} else if (jsxStyleProps2 === "minimal") {
|
|
6039
|
+
jsxExamples.push(`<Box css={{ ${prop}: '${tokenName}' }} />`);
|
|
6040
|
+
}
|
|
6041
|
+
if (token.extensions.varRef) {
|
|
6042
|
+
tokenFunctionExamples.push(`token.var('${fullTokenName}')`);
|
|
6043
|
+
}
|
|
6044
|
+
return { functionExamples, tokenFunctionExamples, jsxExamples };
|
|
6045
|
+
};
|
|
6046
|
+
var generateTokensSpec = (ctx) => {
|
|
6047
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
|
|
6048
|
+
const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
|
|
6049
|
+
const typeTokens = Array.from(tokenMap.values()).filter(
|
|
6050
|
+
(token) => !token.extensions.isSemantic && !token.extensions.isVirtual && !token.extensions.conditions && !token.extensions.isNegative
|
|
6051
|
+
);
|
|
6052
|
+
if (!typeTokens.length) return null;
|
|
6053
|
+
const firstToken = typeTokens[0];
|
|
6054
|
+
const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps2);
|
|
6055
|
+
const values = typeTokens.map((token) => ({
|
|
6056
|
+
name: token.extensions.prop || token.name,
|
|
6057
|
+
value: token.value,
|
|
6058
|
+
description: token.description,
|
|
6059
|
+
deprecated: token.deprecated,
|
|
6060
|
+
cssVar: token.extensions.varRef
|
|
6061
|
+
}));
|
|
6062
|
+
return {
|
|
6063
|
+
type: category,
|
|
6064
|
+
values,
|
|
6065
|
+
tokenFunctionExamples,
|
|
6066
|
+
functionExamples,
|
|
6067
|
+
jsxExamples
|
|
6068
|
+
};
|
|
6069
|
+
}).filter(Boolean);
|
|
6070
|
+
return {
|
|
6071
|
+
type: "tokens",
|
|
6072
|
+
data: groupedData
|
|
6073
|
+
};
|
|
6074
|
+
};
|
|
6075
|
+
var generateSemanticTokensSpec = (ctx) => {
|
|
6076
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps ?? "all";
|
|
6077
|
+
const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
|
|
6078
|
+
const typeTokens = Array.from(tokenMap.values()).filter(
|
|
6079
|
+
(token) => (token.extensions.isSemantic || token.extensions.conditions) && !token.extensions.isVirtual
|
|
6080
|
+
);
|
|
6081
|
+
if (!typeTokens.length) return null;
|
|
6082
|
+
const firstToken = typeTokens[0];
|
|
6083
|
+
const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps2);
|
|
6084
|
+
const values = typeTokens.map((token) => {
|
|
6085
|
+
const conditions = [];
|
|
6086
|
+
walkObject4(token.extensions.rawValue, (value, path) => {
|
|
6087
|
+
conditions.push({ value, condition: path.map((p) => p.replace(/^_/, "")).join(".") });
|
|
6088
|
+
});
|
|
6089
|
+
return {
|
|
6090
|
+
name: token.extensions.prop || token.name,
|
|
6091
|
+
values: conditions,
|
|
6092
|
+
description: token.description,
|
|
6093
|
+
deprecated: token.deprecated,
|
|
6094
|
+
cssVar: token.extensions.varRef
|
|
6095
|
+
};
|
|
6096
|
+
});
|
|
6097
|
+
return {
|
|
6098
|
+
type: category,
|
|
6099
|
+
values,
|
|
6100
|
+
tokenFunctionExamples,
|
|
6101
|
+
functionExamples,
|
|
6102
|
+
jsxExamples
|
|
6103
|
+
};
|
|
6104
|
+
}).filter(Boolean);
|
|
6105
|
+
return {
|
|
6106
|
+
type: "semantic-tokens",
|
|
6107
|
+
data: groupedData
|
|
6108
|
+
};
|
|
6109
|
+
};
|
|
6110
|
+
|
|
5704
6111
|
// src/generator.ts
|
|
5705
6112
|
var Generator = class extends Context2 {
|
|
5706
6113
|
constructor(conf) {
|
|
@@ -5710,7 +6117,7 @@ var Generator = class extends Context2 {
|
|
|
5710
6117
|
return generateArtifacts(this, ids);
|
|
5711
6118
|
};
|
|
5712
6119
|
appendCssOfType = (type, sheet) => {
|
|
5713
|
-
|
|
6120
|
+
match14(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(() => {
|
|
5714
6121
|
throw new PandaError(
|
|
5715
6122
|
"UNKNOWN_ARTIFACT",
|
|
5716
6123
|
`Unknown CSS artifact type: "${type}". Expected one of: preflight, tokens, static, global, keyframes`
|
|
@@ -5784,7 +6191,7 @@ var Generator = class extends Context2 {
|
|
|
5784
6191
|
code: l.css
|
|
5785
6192
|
}));
|
|
5786
6193
|
const recipes = [];
|
|
5787
|
-
for (const recipeName of
|
|
6194
|
+
for (const recipeName of this.recipes.keys) {
|
|
5788
6195
|
const recipeSheet = this.createSheet();
|
|
5789
6196
|
recipeSheet.processDecoderForRecipe(decoder, recipeName);
|
|
5790
6197
|
const code = recipeSheet.getLayerCss("recipes");
|
|
@@ -5832,6 +6239,24 @@ ${css}
|
|
|
5832
6239
|
index: imports.join("\n")
|
|
5833
6240
|
};
|
|
5834
6241
|
};
|
|
6242
|
+
getSpec = () => {
|
|
6243
|
+
const specs = [
|
|
6244
|
+
generateTokensSpec(this),
|
|
6245
|
+
generateRecipesSpec(this),
|
|
6246
|
+
generatePatternsSpec(this),
|
|
6247
|
+
generateConditionsSpec(this),
|
|
6248
|
+
generateKeyframesSpec(this),
|
|
6249
|
+
generateSemanticTokensSpec(this),
|
|
6250
|
+
generateTextStylesSpec(this),
|
|
6251
|
+
generateLayerStylesSpec(this),
|
|
6252
|
+
generateAnimationStylesSpec(this)
|
|
6253
|
+
];
|
|
6254
|
+
const colorPaletteSpec = generateColorPaletteSpec(this);
|
|
6255
|
+
if (colorPaletteSpec) {
|
|
6256
|
+
specs.push(colorPaletteSpec);
|
|
6257
|
+
}
|
|
6258
|
+
return specs;
|
|
6259
|
+
};
|
|
5835
6260
|
};
|
|
5836
6261
|
export {
|
|
5837
6262
|
Generator,
|