@pandacss/generator 1.7.0 → 1.7.2
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 +190 -185
- package/dist/index.mjs +171 -166
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/generator.ts
|
|
39
39
|
var import_core5 = require("@pandacss/core");
|
|
40
|
-
var
|
|
40
|
+
var import_shared17 = require("@pandacss/shared");
|
|
41
41
|
var import_ts_pattern14 = require("ts-pattern");
|
|
42
42
|
|
|
43
43
|
// src/artifacts/setup-artifacts.ts
|
|
@@ -629,11 +629,81 @@ defaultValues`)}
|
|
|
629
629
|
|
|
630
630
|
// src/artifacts/js/recipe.ts
|
|
631
631
|
var import_core = require("@pandacss/core");
|
|
632
|
-
var
|
|
632
|
+
var import_shared3 = require("@pandacss/shared");
|
|
633
633
|
var import_outdent11 = require("outdent");
|
|
634
634
|
var import_ts_pattern3 = require("ts-pattern");
|
|
635
|
-
|
|
635
|
+
|
|
636
|
+
// src/shared.ts
|
|
637
|
+
var import_shared2 = require("@pandacss/shared");
|
|
636
638
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
639
|
+
var formatFunctionValue = (value) => isBooleanValue(value) ? value : `'${value}'`;
|
|
640
|
+
var formatJsxValue = (value) => isBooleanValue(value) ? `{${value}}` : `"${value}"`;
|
|
641
|
+
var buildFunctionProps = (key, value) => `${key}: ${formatFunctionValue(value)}`;
|
|
642
|
+
var buildJsxProps = (key, value) => `${key}=${formatJsxValue(value)}`;
|
|
643
|
+
var formatProps = (props, options = {}) => {
|
|
644
|
+
const { keyValueSeparator = ": ", propSeparator = ", ", quoteStyle = "single" } = options;
|
|
645
|
+
const quote = quoteStyle === "single" ? "'" : quoteStyle === "double" ? '"' : "";
|
|
646
|
+
return Object.entries(props).filter(([_, value]) => value != null).map(([key, value]) => `${key}${keyValueSeparator}${quote}${value}${quote}`).join(propSeparator);
|
|
647
|
+
};
|
|
648
|
+
var formatJsxComponent = (component, props) => {
|
|
649
|
+
const formattedProps = formatProps(props, { keyValueSeparator: "=", propSeparator: " ", quoteStyle: "double" });
|
|
650
|
+
return `<${component}${formattedProps ? " " + formattedProps : ""} />`;
|
|
651
|
+
};
|
|
652
|
+
var collectCompositionStyles = (values) => {
|
|
653
|
+
const result = [];
|
|
654
|
+
(0, import_shared2.walkObject)(
|
|
655
|
+
values,
|
|
656
|
+
(token, paths) => {
|
|
657
|
+
if (token && (0, import_shared2.isObject)(token) && "value" in token) {
|
|
658
|
+
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
659
|
+
result.push({
|
|
660
|
+
name: filteredPaths.join("."),
|
|
661
|
+
description: token.description
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
stop: (v) => (0, import_shared2.isObject)(v) && "value" in v
|
|
667
|
+
}
|
|
668
|
+
);
|
|
669
|
+
return result;
|
|
670
|
+
};
|
|
671
|
+
var generateJsxExample = (props, jsxStyleProps2 = "all", component = "Box") => {
|
|
672
|
+
if (jsxStyleProps2 === "all") {
|
|
673
|
+
return formatJsxComponent(component, props);
|
|
674
|
+
}
|
|
675
|
+
if (jsxStyleProps2 === "minimal") {
|
|
676
|
+
return `<${component} css={{ ${formatProps(props)} }} />`;
|
|
677
|
+
}
|
|
678
|
+
return null;
|
|
679
|
+
};
|
|
680
|
+
var generateJsxExamples = (props, jsxStyleProps2 = "all", component = "Box") => {
|
|
681
|
+
const functionExamples = [`css({ ${formatProps(props)} })`];
|
|
682
|
+
const jsxExamples = [];
|
|
683
|
+
const jsxExample = generateJsxExample(props, jsxStyleProps2, component);
|
|
684
|
+
if (jsxExample) {
|
|
685
|
+
jsxExamples.push(jsxExample);
|
|
686
|
+
}
|
|
687
|
+
return { functionExamples, jsxExamples };
|
|
688
|
+
};
|
|
689
|
+
var COMPOSITION_STYLE_CONFIG = {
|
|
690
|
+
"text-styles": { prop: "textStyle", themeKey: "textStyles" },
|
|
691
|
+
"layer-styles": { prop: "layerStyle", themeKey: "layerStyles" },
|
|
692
|
+
"animation-styles": { prop: "animationStyle", themeKey: "animationStyles" }
|
|
693
|
+
};
|
|
694
|
+
function generateCompositionStyleSpec(type, theme, jsxStyleProps2) {
|
|
695
|
+
const { prop, themeKey } = COMPOSITION_STYLE_CONFIG[type];
|
|
696
|
+
const styles = collectCompositionStyles(theme?.[themeKey] ?? {});
|
|
697
|
+
const data = styles.map((style) => ({
|
|
698
|
+
name: style.name,
|
|
699
|
+
description: style.description,
|
|
700
|
+
...generateJsxExamples({ [prop]: style.name }, jsxStyleProps2)
|
|
701
|
+
}));
|
|
702
|
+
return { type, data };
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// src/artifacts/js/recipe.ts
|
|
706
|
+
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
637
707
|
var hasOwn = (obj, key) => {
|
|
638
708
|
if (!obj) return false;
|
|
639
709
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
@@ -741,7 +811,7 @@ function generateRecipes(ctx, filters) {
|
|
|
741
811
|
const getDefaultValueJsDoc = (key) => {
|
|
742
812
|
if (!hasOwn(defaultVariants, key)) return;
|
|
743
813
|
let defaultValue = defaultVariants[key];
|
|
744
|
-
if ((0,
|
|
814
|
+
if ((0, import_shared3.isBoolean)(defaultValue)) {
|
|
745
815
|
defaultValue = defaultValue ? `true` : `false`;
|
|
746
816
|
} else {
|
|
747
817
|
defaultValue = JSON.stringify(defaultValue);
|
|
@@ -820,7 +890,7 @@ function generateRecipes(ctx, filters) {
|
|
|
820
890
|
interface ${upperName}Variant {
|
|
821
891
|
${Object.keys(variantKeyMap).map((key) => {
|
|
822
892
|
const values = variantKeyMap[key];
|
|
823
|
-
const valueStr = values.every(isBooleanValue) ? `${key}: boolean` : `${key}: ${(0,
|
|
893
|
+
const valueStr = values.every(isBooleanValue) ? `${key}: boolean` : `${key}: ${(0, import_shared3.unionType)(values)}`;
|
|
824
894
|
return [getDefaultValueJsDoc(key), valueStr].filter(Boolean).join("\n");
|
|
825
895
|
}).join("\n")}
|
|
826
896
|
}
|
|
@@ -829,7 +899,7 @@ function generateRecipes(ctx, filters) {
|
|
|
829
899
|
[key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
|
|
830
900
|
}
|
|
831
901
|
|
|
832
|
-
${import_core.Recipes.isSlotRecipeConfig(config) ? `type ${upperName}Slot = ${(0,
|
|
902
|
+
${import_core.Recipes.isSlotRecipeConfig(config) ? `type ${upperName}Slot = ${(0, import_shared3.unionType)(config.slots)}` : ""}
|
|
833
903
|
|
|
834
904
|
export type ${upperName}VariantProps = {
|
|
835
905
|
[key in keyof ${upperName}Variant]?: ${compoundVariants?.length ? `${upperName}Variant[key]` : `ConditionalValue<${upperName}Variant[key]>`} | undefined
|
|
@@ -4678,12 +4748,12 @@ function generatePropTypes(ctx) {
|
|
|
4678
4748
|
|
|
4679
4749
|
// src/artifacts/types/style-props.ts
|
|
4680
4750
|
var import_is_valid_prop = require("@pandacss/is-valid-prop");
|
|
4681
|
-
var
|
|
4751
|
+
var import_shared5 = require("@pandacss/shared");
|
|
4682
4752
|
var import_outdent45 = __toESM(require("outdent"));
|
|
4683
4753
|
function generateStyleProps(ctx) {
|
|
4684
4754
|
const props = new Set(import_is_valid_prop.allCssProperties.concat(ctx.utility.keys()).filter(Boolean));
|
|
4685
4755
|
const propTypes = ctx.utility.getTypes();
|
|
4686
|
-
const cssVars = (0,
|
|
4756
|
+
const cssVars = (0, import_shared5.unionType)(ctx.globalVars.vars);
|
|
4687
4757
|
return import_outdent45.default`
|
|
4688
4758
|
${ctx.file.importType("ConditionalValue", "./conditions")}
|
|
4689
4759
|
${ctx.file.importType("OnlyKnown, UtilityValues, WithEscapeHatch", "./prop-type")}
|
|
@@ -4805,7 +4875,7 @@ var restrict = (key, value, config) => {
|
|
|
4805
4875
|
};
|
|
4806
4876
|
|
|
4807
4877
|
// src/artifacts/types/token-types.ts
|
|
4808
|
-
var
|
|
4878
|
+
var import_shared6 = require("@pandacss/shared");
|
|
4809
4879
|
var import_outdent46 = require("outdent");
|
|
4810
4880
|
var import_pluralize = __toESM(require("pluralize"));
|
|
4811
4881
|
var categories = [
|
|
@@ -4843,22 +4913,22 @@ function generateTokenTypes(ctx) {
|
|
|
4843
4913
|
} else {
|
|
4844
4914
|
const colorPaletteKeys = Array.from(tokens.view.colorPalettes.keys());
|
|
4845
4915
|
if (colorPaletteKeys.length) {
|
|
4846
|
-
set.add(`export type ColorPalette = ${(0,
|
|
4916
|
+
set.add(`export type ColorPalette = ${(0, import_shared6.unionType)(colorPaletteKeys)}`);
|
|
4847
4917
|
}
|
|
4848
4918
|
for (const [key, value] of tokens.view.categoryMap.entries()) {
|
|
4849
|
-
const typeName = (0,
|
|
4919
|
+
const typeName = (0, import_shared6.capitalize)(import_pluralize.default.singular(key));
|
|
4850
4920
|
const categoryName = `${typeName}Token`;
|
|
4851
|
-
set.add(`export type ${categoryName} = ${(0,
|
|
4921
|
+
set.add(`export type ${categoryName} = ${(0, import_shared6.unionType)(value.keys())}`);
|
|
4852
4922
|
tokenSet.add(`${key}.\${${categoryName}}`);
|
|
4853
4923
|
result.add(` ${key}: ${categoryName}`);
|
|
4854
4924
|
}
|
|
4855
4925
|
}
|
|
4856
4926
|
result.add("} & { [token: string]: never }");
|
|
4857
4927
|
set.add(Array.from(result).join("\n"));
|
|
4858
|
-
set.add(`export type TokenCategory = ${(0,
|
|
4928
|
+
set.add(`export type TokenCategory = ${(0, import_shared6.unionType)(categories)}`);
|
|
4859
4929
|
const arr = Array.from(set);
|
|
4860
4930
|
arr.unshift(
|
|
4861
|
-
`export type Token = ${(0,
|
|
4931
|
+
`export type Token = ${(0, import_shared6.unionType)(tokenSet, {
|
|
4862
4932
|
stringify: (t) => `\`${t}\``,
|
|
4863
4933
|
fallback: "string"
|
|
4864
4934
|
})}`
|
|
@@ -4867,7 +4937,7 @@ function generateTokenTypes(ctx) {
|
|
|
4867
4937
|
}
|
|
4868
4938
|
|
|
4869
4939
|
// src/artifacts/js/themes.ts
|
|
4870
|
-
var
|
|
4940
|
+
var import_shared7 = require("@pandacss/shared");
|
|
4871
4941
|
var import_outdent47 = __toESM(require("outdent"));
|
|
4872
4942
|
|
|
4873
4943
|
// src/artifacts/css/token-css.ts
|
|
@@ -5001,7 +5071,7 @@ function generateThemes(ctx) {
|
|
|
5001
5071
|
return Object.entries(themes).map(([name, _themeVariant]) => ({
|
|
5002
5072
|
name: `theme-${name}`,
|
|
5003
5073
|
json: JSON.stringify(
|
|
5004
|
-
(0,
|
|
5074
|
+
(0, import_shared7.compact)({
|
|
5005
5075
|
name,
|
|
5006
5076
|
id: getThemeId(name),
|
|
5007
5077
|
css: getThemeCss(ctx, name)
|
|
@@ -5543,10 +5613,10 @@ var generateParserCss = (ctx, decoder) => {
|
|
|
5543
5613
|
|
|
5544
5614
|
// src/artifacts/css/reset-css.ts
|
|
5545
5615
|
var import_core4 = require("@pandacss/core");
|
|
5546
|
-
var
|
|
5616
|
+
var import_shared8 = require("@pandacss/shared");
|
|
5547
5617
|
function generateResetCss(ctx, sheet) {
|
|
5548
5618
|
const { preflight } = ctx.config;
|
|
5549
|
-
const { scope = "", level = "parent" } = (0,
|
|
5619
|
+
const { scope = "", level = "parent" } = (0, import_shared8.isObject)(preflight) ? preflight : {};
|
|
5550
5620
|
let selector = "";
|
|
5551
5621
|
if (scope && level === "parent") {
|
|
5552
5622
|
selector = `${scope} `;
|
|
@@ -5695,7 +5765,7 @@ function generateResetCss(ctx, sheet) {
|
|
|
5695
5765
|
}
|
|
5696
5766
|
};
|
|
5697
5767
|
if (level === "element") {
|
|
5698
|
-
const modified = (0,
|
|
5768
|
+
const modified = (0, import_shared8.mapEntries)(scoped, (k, v) => {
|
|
5699
5769
|
const [trailingPseudo, rebuiltSelector] = (0, import_core4.extractTrailingPseudos)(k.toString());
|
|
5700
5770
|
if (trailingPseudo) {
|
|
5701
5771
|
const scopeClass = selector.replace("&", "");
|
|
@@ -5728,72 +5798,50 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
5728
5798
|
};
|
|
5729
5799
|
|
|
5730
5800
|
// src/spec/animation-styles.ts
|
|
5731
|
-
var import_shared7 = require("@pandacss/shared");
|
|
5732
|
-
var collectAnimationStyles = (values) => {
|
|
5733
|
-
const result = [];
|
|
5734
|
-
(0, import_shared7.walkObject)(
|
|
5735
|
-
values,
|
|
5736
|
-
(token, paths) => {
|
|
5737
|
-
if (token && (0, import_shared7.isObject)(token) && "value" in token) {
|
|
5738
|
-
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
5739
|
-
result.push({
|
|
5740
|
-
name: filteredPaths.join("."),
|
|
5741
|
-
description: token.description
|
|
5742
|
-
});
|
|
5743
|
-
}
|
|
5744
|
-
},
|
|
5745
|
-
{
|
|
5746
|
-
stop: (v) => (0, import_shared7.isObject)(v) && "value" in v
|
|
5747
|
-
}
|
|
5748
|
-
);
|
|
5749
|
-
return result;
|
|
5750
|
-
};
|
|
5751
5801
|
var generateAnimationStylesSpec = (ctx) => {
|
|
5752
|
-
|
|
5753
|
-
const animationStyles = collectAnimationStyles(ctx.config.theme?.animationStyles ?? {});
|
|
5754
|
-
const animationStylesSpec = animationStyles.map((style) => {
|
|
5755
|
-
const functionExamples = [`css({ animationStyle: '${style.name}' })`];
|
|
5756
|
-
const jsxExamples = [];
|
|
5757
|
-
if (jsxStyleProps2 === "all") {
|
|
5758
|
-
jsxExamples.push(`<Box animationStyle="${style.name}" />`);
|
|
5759
|
-
} else if (jsxStyleProps2 === "minimal") {
|
|
5760
|
-
jsxExamples.push(`<Box css={{ animationStyle: '${style.name}' }} />`);
|
|
5761
|
-
}
|
|
5762
|
-
return {
|
|
5763
|
-
name: style.name,
|
|
5764
|
-
description: style.description,
|
|
5765
|
-
functionExamples,
|
|
5766
|
-
jsxExamples
|
|
5767
|
-
};
|
|
5768
|
-
});
|
|
5769
|
-
return {
|
|
5770
|
-
type: "animation-styles",
|
|
5771
|
-
data: animationStylesSpec
|
|
5772
|
-
};
|
|
5802
|
+
return generateCompositionStyleSpec("animation-styles", ctx.config.theme, ctx.config.jsxStyleProps);
|
|
5773
5803
|
};
|
|
5774
5804
|
|
|
5775
5805
|
// src/spec/color-palette.ts
|
|
5806
|
+
var getColorPaletteExampleValues = (ctx, paletteValues) => {
|
|
5807
|
+
const examplePalette = paletteValues[0];
|
|
5808
|
+
const availableTokens = ctx.tokens.view.getColorPaletteValues(examplePalette);
|
|
5809
|
+
if (availableTokens.length === 0) {
|
|
5810
|
+
return { examplePalette, bgToken: null, colorToken: null };
|
|
5811
|
+
}
|
|
5812
|
+
if (availableTokens.length === 1) {
|
|
5813
|
+
return { examplePalette, bgToken: availableTokens[0], colorToken: null };
|
|
5814
|
+
}
|
|
5815
|
+
const bgToken = availableTokens[0];
|
|
5816
|
+
const colorToken = availableTokens[1];
|
|
5817
|
+
return { examplePalette, bgToken, colorToken };
|
|
5818
|
+
};
|
|
5776
5819
|
var generateColorPaletteSpec = (ctx) => {
|
|
5777
5820
|
const colorPaletteConfig = ctx.config.theme?.colorPalette;
|
|
5778
5821
|
if (colorPaletteConfig?.enabled === false) {
|
|
5779
5822
|
return null;
|
|
5780
5823
|
}
|
|
5781
|
-
const jsxStyleProps2 = ctx.config.jsxStyleProps
|
|
5824
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5782
5825
|
const values = Array.from(ctx.tokens.view.colorPalettes.keys()).sort();
|
|
5783
5826
|
if (!values.length) {
|
|
5784
5827
|
return null;
|
|
5785
5828
|
}
|
|
5786
|
-
const
|
|
5787
|
-
|
|
5788
|
-
`css({ colorPalette: 'blue', bg: 'colorPalette.500', color: 'colorPalette.50' })`
|
|
5789
|
-
];
|
|
5829
|
+
const { examplePalette, bgToken, colorToken } = getColorPaletteExampleValues(ctx, values);
|
|
5830
|
+
const functionExamples = [];
|
|
5790
5831
|
const jsxExamples = [];
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
jsxExamples.push(
|
|
5796
|
-
|
|
5832
|
+
const basicProps = { colorPalette: examplePalette };
|
|
5833
|
+
functionExamples.push(`css({ ${formatProps(basicProps)} })`);
|
|
5834
|
+
const basicJsx = generateJsxExample(basicProps, jsxStyleProps2);
|
|
5835
|
+
if (basicJsx) {
|
|
5836
|
+
jsxExamples.push(basicJsx);
|
|
5837
|
+
}
|
|
5838
|
+
if (bgToken || colorToken) {
|
|
5839
|
+
const extendedProps = { colorPalette: examplePalette, bg: bgToken, color: colorToken };
|
|
5840
|
+
functionExamples.push(`css({ ${formatProps(extendedProps)} })`);
|
|
5841
|
+
const extendedJsx = generateJsxExample(extendedProps, jsxStyleProps2);
|
|
5842
|
+
if (extendedJsx) {
|
|
5843
|
+
jsxExamples.push(extendedJsx);
|
|
5844
|
+
}
|
|
5797
5845
|
}
|
|
5798
5846
|
return {
|
|
5799
5847
|
type: "color-palette",
|
|
@@ -5806,7 +5854,23 @@ var generateColorPaletteSpec = (ctx) => {
|
|
|
5806
5854
|
};
|
|
5807
5855
|
|
|
5808
5856
|
// src/spec/conditions.ts
|
|
5857
|
+
var generateConditionJsxExamples = (conditionName, jsxStyleProps2 = "all") => {
|
|
5858
|
+
if (jsxStyleProps2 === "all") {
|
|
5859
|
+
return [
|
|
5860
|
+
`<Box margin={{ base: '2', ${conditionName}: '4' }} />`,
|
|
5861
|
+
`<Box margin="2" ${conditionName}={{ margin: '4' }} />`
|
|
5862
|
+
];
|
|
5863
|
+
}
|
|
5864
|
+
if (jsxStyleProps2 === "minimal") {
|
|
5865
|
+
return [
|
|
5866
|
+
`<Box css={{ margin: { base: '2', ${conditionName}: '4' } }} />`,
|
|
5867
|
+
`<Box css={{ margin: '2', ${conditionName}: { margin: '4' } }} />`
|
|
5868
|
+
];
|
|
5869
|
+
}
|
|
5870
|
+
return [];
|
|
5871
|
+
};
|
|
5809
5872
|
var generateConditionsSpec = (ctx) => {
|
|
5873
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5810
5874
|
const breakpointKeys = new Set(Object.keys(ctx.conditions.breakpoints.conditions));
|
|
5811
5875
|
const conditions = Object.entries(ctx.conditions.values).map(([name, detail]) => {
|
|
5812
5876
|
const value = Array.isArray(detail.raw) ? detail.raw.join(", ") : detail.raw;
|
|
@@ -5820,10 +5884,7 @@ var generateConditionsSpec = (ctx) => {
|
|
|
5820
5884
|
`css({ margin: { base: '2', ${conditionName}: '4' } })`,
|
|
5821
5885
|
`css({ margin: '2', ${conditionName}: { margin: '4' } })`
|
|
5822
5886
|
],
|
|
5823
|
-
jsxExamples:
|
|
5824
|
-
`<Box margin={{ base: '2', ${conditionName}: '4'}} />`,
|
|
5825
|
-
`<Box margin='2' ${conditionName}={{ margin: '4' }} />`
|
|
5826
|
-
]
|
|
5887
|
+
jsxExamples: generateConditionJsxExamples(conditionName, jsxStyleProps2)
|
|
5827
5888
|
};
|
|
5828
5889
|
});
|
|
5829
5890
|
return {
|
|
@@ -5833,11 +5894,25 @@ var generateConditionsSpec = (ctx) => {
|
|
|
5833
5894
|
};
|
|
5834
5895
|
|
|
5835
5896
|
// src/spec/keyframes.ts
|
|
5897
|
+
var generateKeyframeJsxExamples = (name, jsxStyleProps2 = "all") => {
|
|
5898
|
+
const jsxExamples = [];
|
|
5899
|
+
const example1 = generateJsxExample({ animationName: name }, jsxStyleProps2);
|
|
5900
|
+
if (example1) {
|
|
5901
|
+
jsxExamples.push(example1);
|
|
5902
|
+
}
|
|
5903
|
+
const animationValue = `${name} 1s ease-in-out infinite`;
|
|
5904
|
+
const example2 = generateJsxExample({ animation: animationValue }, jsxStyleProps2);
|
|
5905
|
+
if (example2) {
|
|
5906
|
+
jsxExamples.push(example2);
|
|
5907
|
+
}
|
|
5908
|
+
return jsxExamples;
|
|
5909
|
+
};
|
|
5836
5910
|
var generateKeyframesSpec = (ctx) => {
|
|
5911
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5837
5912
|
const keyframes = Object.keys(ctx.config.theme?.keyframes ?? {}).map((name) => ({
|
|
5838
5913
|
name,
|
|
5839
5914
|
functionExamples: [`css({ animationName: '${name}' })`, `css({ animation: '${name} 1s ease-in-out infinite' })`],
|
|
5840
|
-
jsxExamples:
|
|
5915
|
+
jsxExamples: generateKeyframeJsxExamples(name, jsxStyleProps2)
|
|
5841
5916
|
}));
|
|
5842
5917
|
return {
|
|
5843
5918
|
type: "keyframes",
|
|
@@ -5846,52 +5921,28 @@ var generateKeyframesSpec = (ctx) => {
|
|
|
5846
5921
|
};
|
|
5847
5922
|
|
|
5848
5923
|
// src/spec/layer-styles.ts
|
|
5849
|
-
var import_shared8 = require("@pandacss/shared");
|
|
5850
|
-
var collectLayerStyles = (values) => {
|
|
5851
|
-
const result = [];
|
|
5852
|
-
(0, import_shared8.walkObject)(
|
|
5853
|
-
values,
|
|
5854
|
-
(token, paths) => {
|
|
5855
|
-
if (token && (0, import_shared8.isObject)(token) && "value" in token) {
|
|
5856
|
-
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
5857
|
-
result.push({
|
|
5858
|
-
name: filteredPaths.join("."),
|
|
5859
|
-
description: token.description
|
|
5860
|
-
});
|
|
5861
|
-
}
|
|
5862
|
-
},
|
|
5863
|
-
{
|
|
5864
|
-
stop: (v) => (0, import_shared8.isObject)(v) && "value" in v
|
|
5865
|
-
}
|
|
5866
|
-
);
|
|
5867
|
-
return result;
|
|
5868
|
-
};
|
|
5869
5924
|
var generateLayerStylesSpec = (ctx) => {
|
|
5870
|
-
|
|
5871
|
-
const layerStyles = collectLayerStyles(ctx.config.theme?.layerStyles ?? {});
|
|
5872
|
-
const layerStylesSpec = layerStyles.map((style) => {
|
|
5873
|
-
const functionExamples = [`css({ layerStyle: '${style.name}' })`];
|
|
5874
|
-
const jsxExamples = [];
|
|
5875
|
-
if (jsxStyleProps2 === "all") {
|
|
5876
|
-
jsxExamples.push(`<Box layerStyle="${style.name}" />`);
|
|
5877
|
-
} else if (jsxStyleProps2 === "minimal") {
|
|
5878
|
-
jsxExamples.push(`<Box css={{ layerStyle: '${style.name}' }} />`);
|
|
5879
|
-
}
|
|
5880
|
-
return {
|
|
5881
|
-
name: style.name,
|
|
5882
|
-
description: style.description,
|
|
5883
|
-
functionExamples,
|
|
5884
|
-
jsxExamples
|
|
5885
|
-
};
|
|
5886
|
-
});
|
|
5887
|
-
return {
|
|
5888
|
-
type: "layer-styles",
|
|
5889
|
-
data: layerStylesSpec
|
|
5890
|
-
};
|
|
5925
|
+
return generateCompositionStyleSpec("layer-styles", ctx.config.theme, ctx.config.jsxStyleProps);
|
|
5891
5926
|
};
|
|
5892
5927
|
|
|
5893
5928
|
// src/spec/patterns.ts
|
|
5929
|
+
var getExampleValue = (prop) => {
|
|
5930
|
+
if (prop.type === "enum" && Array.isArray(prop.value) && prop.value.length > 0) {
|
|
5931
|
+
return `"${prop.value[0]}"`;
|
|
5932
|
+
}
|
|
5933
|
+
if (prop.type === "boolean") {
|
|
5934
|
+
return "true";
|
|
5935
|
+
}
|
|
5936
|
+
if (prop.type === "number") {
|
|
5937
|
+
return "4";
|
|
5938
|
+
}
|
|
5939
|
+
if (prop.type === "token") {
|
|
5940
|
+
return '"md"';
|
|
5941
|
+
}
|
|
5942
|
+
return "<value>";
|
|
5943
|
+
};
|
|
5894
5944
|
var generatePatternsSpec = (ctx) => {
|
|
5945
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5895
5946
|
const patterns = ctx.patterns.details.map((node) => {
|
|
5896
5947
|
const patternName = node.baseName;
|
|
5897
5948
|
const jsxName = node.jsxName;
|
|
@@ -5900,21 +5951,16 @@ var generatePatternsSpec = (ctx) => {
|
|
|
5900
5951
|
const jsxExamples = [];
|
|
5901
5952
|
if (properties.length === 0) {
|
|
5902
5953
|
functionExamples.push(`${patternName}()`);
|
|
5903
|
-
|
|
5954
|
+
if (jsxStyleProps2 !== "none") {
|
|
5955
|
+
jsxExamples.push(`<${jsxName} />`);
|
|
5956
|
+
}
|
|
5904
5957
|
} else {
|
|
5905
5958
|
properties.forEach(([propName, prop]) => {
|
|
5906
|
-
|
|
5907
|
-
if (prop.type === "enum" && prop.value?.length > 0) {
|
|
5908
|
-
exampleValue = `"${prop.value[0]}"`;
|
|
5909
|
-
} else if (prop.type === "boolean") {
|
|
5910
|
-
exampleValue = "true";
|
|
5911
|
-
} else if (prop.type === "number") {
|
|
5912
|
-
exampleValue = "4";
|
|
5913
|
-
} else if (prop.type === "token") {
|
|
5914
|
-
exampleValue = '"md"';
|
|
5915
|
-
}
|
|
5959
|
+
const exampleValue = getExampleValue(prop);
|
|
5916
5960
|
functionExamples.push(`${patternName}({ ${propName}: ${exampleValue} })`);
|
|
5917
|
-
|
|
5961
|
+
if (jsxStyleProps2 !== "none") {
|
|
5962
|
+
jsxExamples.push(`<${jsxName} ${propName}={${exampleValue}} />`);
|
|
5963
|
+
}
|
|
5918
5964
|
});
|
|
5919
5965
|
}
|
|
5920
5966
|
const defaultValues = typeof node.config.defaultValues === "object" ? node.config.defaultValues : {};
|
|
@@ -5963,13 +6009,13 @@ var generateRecipesSpec = (ctx) => {
|
|
|
5963
6009
|
variantKeys.forEach((variantKey) => {
|
|
5964
6010
|
const firstValue = getFirstVariantValue(node.variantKeyMap, variantKey);
|
|
5965
6011
|
if (firstValue) {
|
|
5966
|
-
functionExamples.push(`${recipeName}({ ${variantKey}:
|
|
5967
|
-
jsxExamples.push(`<${jsxName} ${variantKey}
|
|
6012
|
+
functionExamples.push(`${recipeName}({ ${variantKey}: ${formatFunctionValue(firstValue)} })`);
|
|
6013
|
+
jsxExamples.push(`<${jsxName} ${variantKey}=${formatJsxValue(firstValue)} />`);
|
|
5968
6014
|
}
|
|
5969
6015
|
});
|
|
5970
6016
|
if (variantKeys.length > 1) {
|
|
5971
|
-
const props = buildVariantProps(variantKeys, node.variantKeyMap,
|
|
5972
|
-
const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap,
|
|
6017
|
+
const props = buildVariantProps(variantKeys, node.variantKeyMap, buildFunctionProps, ", ");
|
|
6018
|
+
const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap, buildJsxProps, " ");
|
|
5973
6019
|
if (props && jsxProps) {
|
|
5974
6020
|
functionExamples.push(`${recipeName}({ ${props} })`);
|
|
5975
6021
|
jsxExamples.push(`<${jsxName} ${jsxProps} />`);
|
|
@@ -5992,52 +6038,12 @@ var generateRecipesSpec = (ctx) => {
|
|
|
5992
6038
|
};
|
|
5993
6039
|
|
|
5994
6040
|
// src/spec/text-styles.ts
|
|
5995
|
-
var import_shared9 = require("@pandacss/shared");
|
|
5996
|
-
var collectTextStyles = (values) => {
|
|
5997
|
-
const result = [];
|
|
5998
|
-
(0, import_shared9.walkObject)(
|
|
5999
|
-
values,
|
|
6000
|
-
(token, paths) => {
|
|
6001
|
-
if (token && (0, import_shared9.isObject)(token) && "value" in token) {
|
|
6002
|
-
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
6003
|
-
result.push({
|
|
6004
|
-
name: filteredPaths.join("."),
|
|
6005
|
-
description: token.description
|
|
6006
|
-
});
|
|
6007
|
-
}
|
|
6008
|
-
},
|
|
6009
|
-
{
|
|
6010
|
-
stop: (v) => (0, import_shared9.isObject)(v) && "value" in v
|
|
6011
|
-
}
|
|
6012
|
-
);
|
|
6013
|
-
return result;
|
|
6014
|
-
};
|
|
6015
6041
|
var generateTextStylesSpec = (ctx) => {
|
|
6016
|
-
|
|
6017
|
-
const textStyles = collectTextStyles(ctx.config.theme?.textStyles ?? {});
|
|
6018
|
-
const textStylesSpec = textStyles.map((style) => {
|
|
6019
|
-
const functionExamples = [`css({ textStyle: '${style.name}' })`];
|
|
6020
|
-
const jsxExamples = [];
|
|
6021
|
-
if (jsxStyleProps2 === "all") {
|
|
6022
|
-
jsxExamples.push(`<Box textStyle="${style.name}" />`);
|
|
6023
|
-
} else if (jsxStyleProps2 === "minimal") {
|
|
6024
|
-
jsxExamples.push(`<Box css={{ textStyle: '${style.name}' }} />`);
|
|
6025
|
-
}
|
|
6026
|
-
return {
|
|
6027
|
-
name: style.name,
|
|
6028
|
-
description: style.description,
|
|
6029
|
-
functionExamples,
|
|
6030
|
-
jsxExamples
|
|
6031
|
-
};
|
|
6032
|
-
});
|
|
6033
|
-
return {
|
|
6034
|
-
type: "text-styles",
|
|
6035
|
-
data: textStylesSpec
|
|
6036
|
-
};
|
|
6042
|
+
return generateCompositionStyleSpec("text-styles", ctx.config.theme, ctx.config.jsxStyleProps);
|
|
6037
6043
|
};
|
|
6038
6044
|
|
|
6039
6045
|
// src/spec/tokens.ts
|
|
6040
|
-
var
|
|
6046
|
+
var import_shared15 = require("@pandacss/shared");
|
|
6041
6047
|
var CATEGORY_PROPERTY_MAP = {
|
|
6042
6048
|
colors: "color",
|
|
6043
6049
|
spacing: "padding",
|
|
@@ -6070,10 +6076,9 @@ var generateTokenExamples = (token, jsxStyleProps2 = "all") => {
|
|
|
6070
6076
|
const functionExamples = [`css({ ${prop}: '${tokenName}' })`];
|
|
6071
6077
|
const tokenFunctionExamples = [`token('${fullTokenName}')`];
|
|
6072
6078
|
const jsxExamples = [];
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
jsxExamples.push(`<Box css={{ ${prop}: '${tokenName}' }} />`);
|
|
6079
|
+
const jsxExample = generateJsxExample({ [prop]: tokenName }, jsxStyleProps2);
|
|
6080
|
+
if (jsxExample) {
|
|
6081
|
+
jsxExamples.push(jsxExample);
|
|
6077
6082
|
}
|
|
6078
6083
|
if (token.extensions.varRef) {
|
|
6079
6084
|
tokenFunctionExamples.push(`token.var('${fullTokenName}')`);
|
|
@@ -6081,7 +6086,7 @@ var generateTokenExamples = (token, jsxStyleProps2 = "all") => {
|
|
|
6081
6086
|
return { functionExamples, tokenFunctionExamples, jsxExamples };
|
|
6082
6087
|
};
|
|
6083
6088
|
var generateTokensSpec = (ctx) => {
|
|
6084
|
-
const jsxStyleProps2 = ctx.config.jsxStyleProps
|
|
6089
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
6085
6090
|
const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
|
|
6086
6091
|
const typeTokens = Array.from(tokenMap.values()).filter(
|
|
6087
6092
|
(token) => !token.extensions.isSemantic && !token.extensions.isVirtual && !token.extensions.conditions && !token.extensions.isNegative
|
|
@@ -6110,7 +6115,7 @@ var generateTokensSpec = (ctx) => {
|
|
|
6110
6115
|
};
|
|
6111
6116
|
};
|
|
6112
6117
|
var generateSemanticTokensSpec = (ctx) => {
|
|
6113
|
-
const jsxStyleProps2 = ctx.config.jsxStyleProps
|
|
6118
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
6114
6119
|
const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
|
|
6115
6120
|
const typeTokens = Array.from(tokenMap.values()).filter(
|
|
6116
6121
|
(token) => (token.extensions.isSemantic || token.extensions.conditions) && !token.extensions.isVirtual
|
|
@@ -6120,7 +6125,7 @@ var generateSemanticTokensSpec = (ctx) => {
|
|
|
6120
6125
|
const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps2);
|
|
6121
6126
|
const values = typeTokens.map((token) => {
|
|
6122
6127
|
const conditions = [];
|
|
6123
|
-
(0,
|
|
6128
|
+
(0, import_shared15.walkObject)(token.extensions.rawValue, (value, path) => {
|
|
6124
6129
|
conditions.push({ value, condition: path.map((p) => p.replace(/^_/, "")).join(".") });
|
|
6125
6130
|
});
|
|
6126
6131
|
return {
|
|
@@ -6155,7 +6160,7 @@ var Generator = class extends import_core5.Context {
|
|
|
6155
6160
|
};
|
|
6156
6161
|
appendCssOfType = (type, sheet) => {
|
|
6157
6162
|
(0, import_ts_pattern14.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(() => {
|
|
6158
|
-
throw new
|
|
6163
|
+
throw new import_shared17.PandaError(
|
|
6159
6164
|
"UNKNOWN_ARTIFACT",
|
|
6160
6165
|
`Unknown CSS artifact type: "${type}". Expected one of: preflight, tokens, static, global, keyframes`
|
|
6161
6166
|
);
|
|
@@ -6236,7 +6241,7 @@ var Generator = class extends import_core5.Context {
|
|
|
6236
6241
|
recipes.push({
|
|
6237
6242
|
type: "recipe",
|
|
6238
6243
|
name: recipeName,
|
|
6239
|
-
file: `${(0,
|
|
6244
|
+
file: `${(0, import_shared17.dashCase)(recipeName)}.css`,
|
|
6240
6245
|
code,
|
|
6241
6246
|
dir: "recipes"
|
|
6242
6247
|
});
|
|
@@ -6250,7 +6255,7 @@ var Generator = class extends import_core5.Context {
|
|
|
6250
6255
|
themes.push({
|
|
6251
6256
|
type: "theme",
|
|
6252
6257
|
name: themeName,
|
|
6253
|
-
file: `${(0,
|
|
6258
|
+
file: `${(0, import_shared17.dashCase)(themeName)}.css`,
|
|
6254
6259
|
code: `@layer ${layerNames.tokens} {
|
|
6255
6260
|
${css}
|
|
6256
6261
|
}`,
|
package/dist/index.mjs
CHANGED
|
@@ -595,8 +595,78 @@ import { Recipes } from "@pandacss/core";
|
|
|
595
595
|
import { isBoolean, unionType } from "@pandacss/shared";
|
|
596
596
|
import { outdent as outdent11 } from "outdent";
|
|
597
597
|
import { match as match3 } from "ts-pattern";
|
|
598
|
-
|
|
598
|
+
|
|
599
|
+
// src/shared.ts
|
|
600
|
+
import { isObject, walkObject } from "@pandacss/shared";
|
|
599
601
|
var isBooleanValue = (value) => value === "true" || value === "false";
|
|
602
|
+
var formatFunctionValue = (value) => isBooleanValue(value) ? value : `'${value}'`;
|
|
603
|
+
var formatJsxValue = (value) => isBooleanValue(value) ? `{${value}}` : `"${value}"`;
|
|
604
|
+
var buildFunctionProps = (key, value) => `${key}: ${formatFunctionValue(value)}`;
|
|
605
|
+
var buildJsxProps = (key, value) => `${key}=${formatJsxValue(value)}`;
|
|
606
|
+
var formatProps = (props, options = {}) => {
|
|
607
|
+
const { keyValueSeparator = ": ", propSeparator = ", ", quoteStyle = "single" } = options;
|
|
608
|
+
const quote = quoteStyle === "single" ? "'" : quoteStyle === "double" ? '"' : "";
|
|
609
|
+
return Object.entries(props).filter(([_, value]) => value != null).map(([key, value]) => `${key}${keyValueSeparator}${quote}${value}${quote}`).join(propSeparator);
|
|
610
|
+
};
|
|
611
|
+
var formatJsxComponent = (component, props) => {
|
|
612
|
+
const formattedProps = formatProps(props, { keyValueSeparator: "=", propSeparator: " ", quoteStyle: "double" });
|
|
613
|
+
return `<${component}${formattedProps ? " " + formattedProps : ""} />`;
|
|
614
|
+
};
|
|
615
|
+
var collectCompositionStyles = (values) => {
|
|
616
|
+
const result = [];
|
|
617
|
+
walkObject(
|
|
618
|
+
values,
|
|
619
|
+
(token, paths) => {
|
|
620
|
+
if (token && isObject(token) && "value" in token) {
|
|
621
|
+
const filteredPaths = paths.filter((item) => item !== "DEFAULT");
|
|
622
|
+
result.push({
|
|
623
|
+
name: filteredPaths.join("."),
|
|
624
|
+
description: token.description
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
stop: (v) => isObject(v) && "value" in v
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
return result;
|
|
633
|
+
};
|
|
634
|
+
var generateJsxExample = (props, jsxStyleProps2 = "all", component = "Box") => {
|
|
635
|
+
if (jsxStyleProps2 === "all") {
|
|
636
|
+
return formatJsxComponent(component, props);
|
|
637
|
+
}
|
|
638
|
+
if (jsxStyleProps2 === "minimal") {
|
|
639
|
+
return `<${component} css={{ ${formatProps(props)} }} />`;
|
|
640
|
+
}
|
|
641
|
+
return null;
|
|
642
|
+
};
|
|
643
|
+
var generateJsxExamples = (props, jsxStyleProps2 = "all", component = "Box") => {
|
|
644
|
+
const functionExamples = [`css({ ${formatProps(props)} })`];
|
|
645
|
+
const jsxExamples = [];
|
|
646
|
+
const jsxExample = generateJsxExample(props, jsxStyleProps2, component);
|
|
647
|
+
if (jsxExample) {
|
|
648
|
+
jsxExamples.push(jsxExample);
|
|
649
|
+
}
|
|
650
|
+
return { functionExamples, jsxExamples };
|
|
651
|
+
};
|
|
652
|
+
var COMPOSITION_STYLE_CONFIG = {
|
|
653
|
+
"text-styles": { prop: "textStyle", themeKey: "textStyles" },
|
|
654
|
+
"layer-styles": { prop: "layerStyle", themeKey: "layerStyles" },
|
|
655
|
+
"animation-styles": { prop: "animationStyle", themeKey: "animationStyles" }
|
|
656
|
+
};
|
|
657
|
+
function generateCompositionStyleSpec(type, theme, jsxStyleProps2) {
|
|
658
|
+
const { prop, themeKey } = COMPOSITION_STYLE_CONFIG[type];
|
|
659
|
+
const styles = collectCompositionStyles(theme?.[themeKey] ?? {});
|
|
660
|
+
const data = styles.map((style) => ({
|
|
661
|
+
name: style.name,
|
|
662
|
+
description: style.description,
|
|
663
|
+
...generateJsxExamples({ [prop]: style.name }, jsxStyleProps2)
|
|
664
|
+
}));
|
|
665
|
+
return { type, data };
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// src/artifacts/js/recipe.ts
|
|
669
|
+
var stringify2 = (value) => JSON.stringify(value, null, 2);
|
|
600
670
|
var hasOwn = (obj, key) => {
|
|
601
671
|
if (!obj) return false;
|
|
602
672
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
@@ -5506,10 +5576,10 @@ var generateParserCss = (ctx, decoder) => {
|
|
|
5506
5576
|
|
|
5507
5577
|
// src/artifacts/css/reset-css.ts
|
|
5508
5578
|
import { extractTrailingPseudos } from "@pandacss/core";
|
|
5509
|
-
import { isObject, mapEntries } from "@pandacss/shared";
|
|
5579
|
+
import { isObject as isObject2, mapEntries } from "@pandacss/shared";
|
|
5510
5580
|
function generateResetCss(ctx, sheet) {
|
|
5511
5581
|
const { preflight } = ctx.config;
|
|
5512
|
-
const { scope = "", level = "parent" } =
|
|
5582
|
+
const { scope = "", level = "parent" } = isObject2(preflight) ? preflight : {};
|
|
5513
5583
|
let selector = "";
|
|
5514
5584
|
if (scope && level === "parent") {
|
|
5515
5585
|
selector = `${scope} `;
|
|
@@ -5691,72 +5761,50 @@ var generateStaticCss = (ctx, sheet) => {
|
|
|
5691
5761
|
};
|
|
5692
5762
|
|
|
5693
5763
|
// 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
5764
|
var generateAnimationStylesSpec = (ctx) => {
|
|
5715
|
-
|
|
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
|
-
};
|
|
5765
|
+
return generateCompositionStyleSpec("animation-styles", ctx.config.theme, ctx.config.jsxStyleProps);
|
|
5736
5766
|
};
|
|
5737
5767
|
|
|
5738
5768
|
// src/spec/color-palette.ts
|
|
5769
|
+
var getColorPaletteExampleValues = (ctx, paletteValues) => {
|
|
5770
|
+
const examplePalette = paletteValues[0];
|
|
5771
|
+
const availableTokens = ctx.tokens.view.getColorPaletteValues(examplePalette);
|
|
5772
|
+
if (availableTokens.length === 0) {
|
|
5773
|
+
return { examplePalette, bgToken: null, colorToken: null };
|
|
5774
|
+
}
|
|
5775
|
+
if (availableTokens.length === 1) {
|
|
5776
|
+
return { examplePalette, bgToken: availableTokens[0], colorToken: null };
|
|
5777
|
+
}
|
|
5778
|
+
const bgToken = availableTokens[0];
|
|
5779
|
+
const colorToken = availableTokens[1];
|
|
5780
|
+
return { examplePalette, bgToken, colorToken };
|
|
5781
|
+
};
|
|
5739
5782
|
var generateColorPaletteSpec = (ctx) => {
|
|
5740
5783
|
const colorPaletteConfig = ctx.config.theme?.colorPalette;
|
|
5741
5784
|
if (colorPaletteConfig?.enabled === false) {
|
|
5742
5785
|
return null;
|
|
5743
5786
|
}
|
|
5744
|
-
const jsxStyleProps2 = ctx.config.jsxStyleProps
|
|
5787
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5745
5788
|
const values = Array.from(ctx.tokens.view.colorPalettes.keys()).sort();
|
|
5746
5789
|
if (!values.length) {
|
|
5747
5790
|
return null;
|
|
5748
5791
|
}
|
|
5749
|
-
const
|
|
5750
|
-
|
|
5751
|
-
`css({ colorPalette: 'blue', bg: 'colorPalette.500', color: 'colorPalette.50' })`
|
|
5752
|
-
];
|
|
5792
|
+
const { examplePalette, bgToken, colorToken } = getColorPaletteExampleValues(ctx, values);
|
|
5793
|
+
const functionExamples = [];
|
|
5753
5794
|
const jsxExamples = [];
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
jsxExamples.push(
|
|
5759
|
-
|
|
5795
|
+
const basicProps = { colorPalette: examplePalette };
|
|
5796
|
+
functionExamples.push(`css({ ${formatProps(basicProps)} })`);
|
|
5797
|
+
const basicJsx = generateJsxExample(basicProps, jsxStyleProps2);
|
|
5798
|
+
if (basicJsx) {
|
|
5799
|
+
jsxExamples.push(basicJsx);
|
|
5800
|
+
}
|
|
5801
|
+
if (bgToken || colorToken) {
|
|
5802
|
+
const extendedProps = { colorPalette: examplePalette, bg: bgToken, color: colorToken };
|
|
5803
|
+
functionExamples.push(`css({ ${formatProps(extendedProps)} })`);
|
|
5804
|
+
const extendedJsx = generateJsxExample(extendedProps, jsxStyleProps2);
|
|
5805
|
+
if (extendedJsx) {
|
|
5806
|
+
jsxExamples.push(extendedJsx);
|
|
5807
|
+
}
|
|
5760
5808
|
}
|
|
5761
5809
|
return {
|
|
5762
5810
|
type: "color-palette",
|
|
@@ -5769,7 +5817,23 @@ var generateColorPaletteSpec = (ctx) => {
|
|
|
5769
5817
|
};
|
|
5770
5818
|
|
|
5771
5819
|
// src/spec/conditions.ts
|
|
5820
|
+
var generateConditionJsxExamples = (conditionName, jsxStyleProps2 = "all") => {
|
|
5821
|
+
if (jsxStyleProps2 === "all") {
|
|
5822
|
+
return [
|
|
5823
|
+
`<Box margin={{ base: '2', ${conditionName}: '4' }} />`,
|
|
5824
|
+
`<Box margin="2" ${conditionName}={{ margin: '4' }} />`
|
|
5825
|
+
];
|
|
5826
|
+
}
|
|
5827
|
+
if (jsxStyleProps2 === "minimal") {
|
|
5828
|
+
return [
|
|
5829
|
+
`<Box css={{ margin: { base: '2', ${conditionName}: '4' } }} />`,
|
|
5830
|
+
`<Box css={{ margin: '2', ${conditionName}: { margin: '4' } }} />`
|
|
5831
|
+
];
|
|
5832
|
+
}
|
|
5833
|
+
return [];
|
|
5834
|
+
};
|
|
5772
5835
|
var generateConditionsSpec = (ctx) => {
|
|
5836
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5773
5837
|
const breakpointKeys = new Set(Object.keys(ctx.conditions.breakpoints.conditions));
|
|
5774
5838
|
const conditions = Object.entries(ctx.conditions.values).map(([name, detail]) => {
|
|
5775
5839
|
const value = Array.isArray(detail.raw) ? detail.raw.join(", ") : detail.raw;
|
|
@@ -5783,10 +5847,7 @@ var generateConditionsSpec = (ctx) => {
|
|
|
5783
5847
|
`css({ margin: { base: '2', ${conditionName}: '4' } })`,
|
|
5784
5848
|
`css({ margin: '2', ${conditionName}: { margin: '4' } })`
|
|
5785
5849
|
],
|
|
5786
|
-
jsxExamples:
|
|
5787
|
-
`<Box margin={{ base: '2', ${conditionName}: '4'}} />`,
|
|
5788
|
-
`<Box margin='2' ${conditionName}={{ margin: '4' }} />`
|
|
5789
|
-
]
|
|
5850
|
+
jsxExamples: generateConditionJsxExamples(conditionName, jsxStyleProps2)
|
|
5790
5851
|
};
|
|
5791
5852
|
});
|
|
5792
5853
|
return {
|
|
@@ -5796,11 +5857,25 @@ var generateConditionsSpec = (ctx) => {
|
|
|
5796
5857
|
};
|
|
5797
5858
|
|
|
5798
5859
|
// src/spec/keyframes.ts
|
|
5860
|
+
var generateKeyframeJsxExamples = (name, jsxStyleProps2 = "all") => {
|
|
5861
|
+
const jsxExamples = [];
|
|
5862
|
+
const example1 = generateJsxExample({ animationName: name }, jsxStyleProps2);
|
|
5863
|
+
if (example1) {
|
|
5864
|
+
jsxExamples.push(example1);
|
|
5865
|
+
}
|
|
5866
|
+
const animationValue = `${name} 1s ease-in-out infinite`;
|
|
5867
|
+
const example2 = generateJsxExample({ animation: animationValue }, jsxStyleProps2);
|
|
5868
|
+
if (example2) {
|
|
5869
|
+
jsxExamples.push(example2);
|
|
5870
|
+
}
|
|
5871
|
+
return jsxExamples;
|
|
5872
|
+
};
|
|
5799
5873
|
var generateKeyframesSpec = (ctx) => {
|
|
5874
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5800
5875
|
const keyframes = Object.keys(ctx.config.theme?.keyframes ?? {}).map((name) => ({
|
|
5801
5876
|
name,
|
|
5802
5877
|
functionExamples: [`css({ animationName: '${name}' })`, `css({ animation: '${name} 1s ease-in-out infinite' })`],
|
|
5803
|
-
jsxExamples:
|
|
5878
|
+
jsxExamples: generateKeyframeJsxExamples(name, jsxStyleProps2)
|
|
5804
5879
|
}));
|
|
5805
5880
|
return {
|
|
5806
5881
|
type: "keyframes",
|
|
@@ -5809,52 +5884,28 @@ var generateKeyframesSpec = (ctx) => {
|
|
|
5809
5884
|
};
|
|
5810
5885
|
|
|
5811
5886
|
// 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
5887
|
var generateLayerStylesSpec = (ctx) => {
|
|
5833
|
-
|
|
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
|
-
};
|
|
5888
|
+
return generateCompositionStyleSpec("layer-styles", ctx.config.theme, ctx.config.jsxStyleProps);
|
|
5854
5889
|
};
|
|
5855
5890
|
|
|
5856
5891
|
// src/spec/patterns.ts
|
|
5892
|
+
var getExampleValue = (prop) => {
|
|
5893
|
+
if (prop.type === "enum" && Array.isArray(prop.value) && prop.value.length > 0) {
|
|
5894
|
+
return `"${prop.value[0]}"`;
|
|
5895
|
+
}
|
|
5896
|
+
if (prop.type === "boolean") {
|
|
5897
|
+
return "true";
|
|
5898
|
+
}
|
|
5899
|
+
if (prop.type === "number") {
|
|
5900
|
+
return "4";
|
|
5901
|
+
}
|
|
5902
|
+
if (prop.type === "token") {
|
|
5903
|
+
return '"md"';
|
|
5904
|
+
}
|
|
5905
|
+
return "<value>";
|
|
5906
|
+
};
|
|
5857
5907
|
var generatePatternsSpec = (ctx) => {
|
|
5908
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
5858
5909
|
const patterns = ctx.patterns.details.map((node) => {
|
|
5859
5910
|
const patternName = node.baseName;
|
|
5860
5911
|
const jsxName = node.jsxName;
|
|
@@ -5863,21 +5914,16 @@ var generatePatternsSpec = (ctx) => {
|
|
|
5863
5914
|
const jsxExamples = [];
|
|
5864
5915
|
if (properties.length === 0) {
|
|
5865
5916
|
functionExamples.push(`${patternName}()`);
|
|
5866
|
-
|
|
5917
|
+
if (jsxStyleProps2 !== "none") {
|
|
5918
|
+
jsxExamples.push(`<${jsxName} />`);
|
|
5919
|
+
}
|
|
5867
5920
|
} else {
|
|
5868
5921
|
properties.forEach(([propName, prop]) => {
|
|
5869
|
-
|
|
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
|
-
}
|
|
5922
|
+
const exampleValue = getExampleValue(prop);
|
|
5879
5923
|
functionExamples.push(`${patternName}({ ${propName}: ${exampleValue} })`);
|
|
5880
|
-
|
|
5924
|
+
if (jsxStyleProps2 !== "none") {
|
|
5925
|
+
jsxExamples.push(`<${jsxName} ${propName}={${exampleValue}} />`);
|
|
5926
|
+
}
|
|
5881
5927
|
});
|
|
5882
5928
|
}
|
|
5883
5929
|
const defaultValues = typeof node.config.defaultValues === "object" ? node.config.defaultValues : {};
|
|
@@ -5926,13 +5972,13 @@ var generateRecipesSpec = (ctx) => {
|
|
|
5926
5972
|
variantKeys.forEach((variantKey) => {
|
|
5927
5973
|
const firstValue = getFirstVariantValue(node.variantKeyMap, variantKey);
|
|
5928
5974
|
if (firstValue) {
|
|
5929
|
-
functionExamples.push(`${recipeName}({ ${variantKey}:
|
|
5930
|
-
jsxExamples.push(`<${jsxName} ${variantKey}
|
|
5975
|
+
functionExamples.push(`${recipeName}({ ${variantKey}: ${formatFunctionValue(firstValue)} })`);
|
|
5976
|
+
jsxExamples.push(`<${jsxName} ${variantKey}=${formatJsxValue(firstValue)} />`);
|
|
5931
5977
|
}
|
|
5932
5978
|
});
|
|
5933
5979
|
if (variantKeys.length > 1) {
|
|
5934
|
-
const props = buildVariantProps(variantKeys, node.variantKeyMap,
|
|
5935
|
-
const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap,
|
|
5980
|
+
const props = buildVariantProps(variantKeys, node.variantKeyMap, buildFunctionProps, ", ");
|
|
5981
|
+
const jsxProps = buildVariantProps(variantKeys, node.variantKeyMap, buildJsxProps, " ");
|
|
5936
5982
|
if (props && jsxProps) {
|
|
5937
5983
|
functionExamples.push(`${recipeName}({ ${props} })`);
|
|
5938
5984
|
jsxExamples.push(`<${jsxName} ${jsxProps} />`);
|
|
@@ -5955,52 +6001,12 @@ var generateRecipesSpec = (ctx) => {
|
|
|
5955
6001
|
};
|
|
5956
6002
|
|
|
5957
6003
|
// 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
6004
|
var generateTextStylesSpec = (ctx) => {
|
|
5979
|
-
|
|
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
|
-
};
|
|
6005
|
+
return generateCompositionStyleSpec("text-styles", ctx.config.theme, ctx.config.jsxStyleProps);
|
|
6000
6006
|
};
|
|
6001
6007
|
|
|
6002
6008
|
// src/spec/tokens.ts
|
|
6003
|
-
import { walkObject as
|
|
6009
|
+
import { walkObject as walkObject2 } from "@pandacss/shared";
|
|
6004
6010
|
var CATEGORY_PROPERTY_MAP = {
|
|
6005
6011
|
colors: "color",
|
|
6006
6012
|
spacing: "padding",
|
|
@@ -6033,10 +6039,9 @@ var generateTokenExamples = (token, jsxStyleProps2 = "all") => {
|
|
|
6033
6039
|
const functionExamples = [`css({ ${prop}: '${tokenName}' })`];
|
|
6034
6040
|
const tokenFunctionExamples = [`token('${fullTokenName}')`];
|
|
6035
6041
|
const jsxExamples = [];
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
jsxExamples.push(`<Box css={{ ${prop}: '${tokenName}' }} />`);
|
|
6042
|
+
const jsxExample = generateJsxExample({ [prop]: tokenName }, jsxStyleProps2);
|
|
6043
|
+
if (jsxExample) {
|
|
6044
|
+
jsxExamples.push(jsxExample);
|
|
6040
6045
|
}
|
|
6041
6046
|
if (token.extensions.varRef) {
|
|
6042
6047
|
tokenFunctionExamples.push(`token.var('${fullTokenName}')`);
|
|
@@ -6044,7 +6049,7 @@ var generateTokenExamples = (token, jsxStyleProps2 = "all") => {
|
|
|
6044
6049
|
return { functionExamples, tokenFunctionExamples, jsxExamples };
|
|
6045
6050
|
};
|
|
6046
6051
|
var generateTokensSpec = (ctx) => {
|
|
6047
|
-
const jsxStyleProps2 = ctx.config.jsxStyleProps
|
|
6052
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
6048
6053
|
const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
|
|
6049
6054
|
const typeTokens = Array.from(tokenMap.values()).filter(
|
|
6050
6055
|
(token) => !token.extensions.isSemantic && !token.extensions.isVirtual && !token.extensions.conditions && !token.extensions.isNegative
|
|
@@ -6073,7 +6078,7 @@ var generateTokensSpec = (ctx) => {
|
|
|
6073
6078
|
};
|
|
6074
6079
|
};
|
|
6075
6080
|
var generateSemanticTokensSpec = (ctx) => {
|
|
6076
|
-
const jsxStyleProps2 = ctx.config.jsxStyleProps
|
|
6081
|
+
const jsxStyleProps2 = ctx.config.jsxStyleProps;
|
|
6077
6082
|
const groupedData = Array.from(ctx.tokens.view.categoryMap.entries()).map(([category, tokenMap]) => {
|
|
6078
6083
|
const typeTokens = Array.from(tokenMap.values()).filter(
|
|
6079
6084
|
(token) => (token.extensions.isSemantic || token.extensions.conditions) && !token.extensions.isVirtual
|
|
@@ -6083,7 +6088,7 @@ var generateSemanticTokensSpec = (ctx) => {
|
|
|
6083
6088
|
const { functionExamples, tokenFunctionExamples, jsxExamples } = generateTokenExamples(firstToken, jsxStyleProps2);
|
|
6084
6089
|
const values = typeTokens.map((token) => {
|
|
6085
6090
|
const conditions = [];
|
|
6086
|
-
|
|
6091
|
+
walkObject2(token.extensions.rawValue, (value, path) => {
|
|
6087
6092
|
conditions.push({ value, condition: path.map((p) => p.replace(/^_/, "")).join(".") });
|
|
6088
6093
|
});
|
|
6089
6094
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/generator",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "The css generator for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"pluralize": "8.0.0",
|
|
39
39
|
"postcss": "8.5.6",
|
|
40
40
|
"ts-pattern": "5.9.0",
|
|
41
|
-
"@pandacss/core": "1.7.
|
|
42
|
-
"@pandacss/is-valid-prop": "^1.7.
|
|
43
|
-
"@pandacss/logger": "1.7.
|
|
44
|
-
"@pandacss/shared": "1.7.
|
|
45
|
-
"@pandacss/token-dictionary": "1.7.
|
|
46
|
-
"@pandacss/types": "1.7.
|
|
41
|
+
"@pandacss/core": "1.7.2",
|
|
42
|
+
"@pandacss/is-valid-prop": "^1.7.2",
|
|
43
|
+
"@pandacss/logger": "1.7.2",
|
|
44
|
+
"@pandacss/shared": "1.7.2",
|
|
45
|
+
"@pandacss/token-dictionary": "1.7.2",
|
|
46
|
+
"@pandacss/types": "1.7.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pluralize": "0.0.33"
|