@pandacss/generator 0.0.0-dev-20231222115330 → 0.0.0-dev-20231223024151

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 CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
2
  import { UserConfig, PatternConfig, Dict, ArtifactFilters, ConfigResultWithHooks, RequiredBy, StudioOptions, HashOptions, PrefixOptions, Theme, CascadeLayers, TSConfig, ArtifactId, ParserResultType } from '@pandacss/types';
3
3
  import { Utility, Recipes, Conditions, Layers, Stylesheet, RecipeContext, RecipeNode } from '@pandacss/core';
4
+ import { mapObject } from '@pandacss/shared';
4
5
  import { TokenDictionary } from '@pandacss/token-dictionary';
5
6
 
6
7
  declare class FileEngine {
@@ -108,7 +109,15 @@ declare class Context {
108
109
  createLayers(layers: CascadeLayers): Layers;
109
110
  setupCompositions(theme: Theme): void;
110
111
  setupProperties(): void;
111
- private get baseSheetContext();
112
+ get baseSheetContext(): {
113
+ conditions: Conditions;
114
+ layers: Layers;
115
+ utility: Utility;
116
+ helpers: {
117
+ map: typeof mapObject;
118
+ };
119
+ hash: boolean | undefined;
120
+ };
112
121
  createSheet(): Stylesheet;
113
122
  createRecipes(theme: Theme, context: RecipeContext): Recipes;
114
123
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _pandacss_types from '@pandacss/types';
2
2
  import { UserConfig, PatternConfig, Dict, ArtifactFilters, ConfigResultWithHooks, RequiredBy, StudioOptions, HashOptions, PrefixOptions, Theme, CascadeLayers, TSConfig, ArtifactId, ParserResultType } from '@pandacss/types';
3
3
  import { Utility, Recipes, Conditions, Layers, Stylesheet, RecipeContext, RecipeNode } from '@pandacss/core';
4
+ import { mapObject } from '@pandacss/shared';
4
5
  import { TokenDictionary } from '@pandacss/token-dictionary';
5
6
 
6
7
  declare class FileEngine {
@@ -108,7 +109,15 @@ declare class Context {
108
109
  createLayers(layers: CascadeLayers): Layers;
109
110
  setupCompositions(theme: Theme): void;
110
111
  setupProperties(): void;
111
- private get baseSheetContext();
112
+ get baseSheetContext(): {
113
+ conditions: Conditions;
114
+ layers: Layers;
115
+ utility: Utility;
116
+ helpers: {
117
+ map: typeof mapObject;
118
+ };
119
+ hash: boolean | undefined;
120
+ };
112
121
  createSheet(): Stylesheet;
113
122
  createRecipes(theme: Theme, context: RecipeContext): Recipes;
114
123
  }
package/dist/index.js CHANGED
@@ -2832,7 +2832,7 @@ var selectors_d_ts_default = {
2832
2832
 
2833
2833
  // src/artifacts/generated/static-css.d.ts.json
2834
2834
  var static_css_d_ts_default = {
2835
- content: "interface CssRule {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: string[]\n }\n /**\n * The css conditions to generate utilities for.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n /**\n * Whether to generate responsive utilities.\n */\n responsive?: boolean\n}\n\nexport type RecipeRule =\n | '*'\n | ({\n conditions?: string[]\n responsive?: boolean\n } & { [variant: string]: boolean | string[] })\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?: {\n [recipe: string]: RecipeRule[]\n }\n}\n"
2835
+ content: "interface WithConditions {\n /**\n * The css conditions to generate for the rule.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n responsive?: boolean\n}\n\nexport interface CssRule extends WithConditions {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: Array<string | number>\n }\n}\n\ninterface RecipeRuleVariants {\n [variant: string]: boolean | string[]\n}\n\nexport type RecipeRule = '*' | (RecipeRuleVariants & WithConditions)\nexport type PatternRule = '*' | CssRule\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?: {\n [recipe: string]: RecipeRule[]\n }\n /**\n * The css patterns to generate.\n */\n patterns?: {\n [pattern: string]: PatternRule[]\n }\n}\n"
2836
2836
  };
2837
2837
 
2838
2838
  // src/artifacts/types/generated.ts
@@ -3857,21 +3857,49 @@ var generateStaticCss = (ctx) => {
3857
3857
  }
3858
3858
  });
3859
3859
  const getResult = (0, import_core3.getStaticCss)(staticCss);
3860
+ const getPropertyKeys = (prop) => {
3861
+ const propConfig = utility.config[prop];
3862
+ if (!propConfig)
3863
+ return [];
3864
+ const values = utility.getPropertyValues(propConfig);
3865
+ if (!values)
3866
+ return [];
3867
+ return Object.keys(values);
3868
+ };
3860
3869
  const results = getResult({
3861
3870
  breakpoints: Object.keys(theme.breakpoints ?? {}),
3862
- getPropertyKeys: (prop) => {
3863
- const propConfig = utility.config[prop];
3864
- if (!propConfig)
3865
- return [];
3866
- const values = utility.getPropertyValues(propConfig);
3867
- if (!values)
3871
+ getPropertyKeys,
3872
+ getRecipeKeys: (recipe) => {
3873
+ return recipes.details.find((detail) => detail.baseName === recipe)?.variantKeyMap ?? {};
3874
+ },
3875
+ getPatternPropValues: (patternName, property) => {
3876
+ const patternConfig = ctx.patterns.getConfig(patternName);
3877
+ if (!patternConfig)
3868
3878
  return [];
3869
- return Object.keys(values);
3879
+ const propType = patternConfig.properties?.[property];
3880
+ if (!propType)
3881
+ return;
3882
+ if (propType.type === "enum") {
3883
+ return propType.value;
3884
+ }
3885
+ if (propType.type === "boolean") {
3886
+ return ["true", "false"];
3887
+ }
3888
+ if (propType.type === "property") {
3889
+ return getPropertyKeys(propType.value || property);
3890
+ }
3891
+ if (propType.type === "token") {
3892
+ const values = ctx.tokens.getValue(propType.value);
3893
+ return Object.keys(values ?? {});
3894
+ }
3870
3895
  },
3871
- getRecipeKeys: (recipe) => {
3872
- const recipeConfig = recipes.details.find((detail) => detail.baseName === recipe);
3873
- return Object.assign({ __base: recipeConfig?.config.base }, recipeConfig?.variantKeyMap ?? {});
3874
- }
3896
+ getPatternKeys: (patternName) => {
3897
+ const details = ctx.patterns.details.find((d) => d.baseName === patternName);
3898
+ if (!details)
3899
+ return;
3900
+ return details.props ?? [];
3901
+ },
3902
+ getPatternTransform: ctx.patterns.transform.bind(ctx.patterns)
3875
3903
  });
3876
3904
  results.css.forEach((css2) => {
3877
3905
  ctx.stylesheet.processAtomic(css2);
@@ -3884,6 +3912,11 @@ var generateStaticCss = (ctx) => {
3884
3912
  ctx.stylesheet.processRecipe(name, recipeConfig, value);
3885
3913
  });
3886
3914
  });
3915
+ results.patterns.forEach((result) => {
3916
+ Object.entries(result).forEach(([name, value]) => {
3917
+ ctx.stylesheet.processAtomic({ [name]: value });
3918
+ });
3919
+ });
3887
3920
  void ctx.hooks.callHook("generator:css", "static.css", "");
3888
3921
  };
3889
3922
 
package/dist/index.mjs CHANGED
@@ -2801,7 +2801,7 @@ var selectors_d_ts_default = {
2801
2801
 
2802
2802
  // src/artifacts/generated/static-css.d.ts.json
2803
2803
  var static_css_d_ts_default = {
2804
- content: "interface CssRule {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: string[]\n }\n /**\n * The css conditions to generate utilities for.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n /**\n * Whether to generate responsive utilities.\n */\n responsive?: boolean\n}\n\nexport type RecipeRule =\n | '*'\n | ({\n conditions?: string[]\n responsive?: boolean\n } & { [variant: string]: boolean | string[] })\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?: {\n [recipe: string]: RecipeRule[]\n }\n}\n"
2804
+ content: "interface WithConditions {\n /**\n * The css conditions to generate for the rule.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n responsive?: boolean\n}\n\nexport interface CssRule extends WithConditions {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: Array<string | number>\n }\n}\n\ninterface RecipeRuleVariants {\n [variant: string]: boolean | string[]\n}\n\nexport type RecipeRule = '*' | (RecipeRuleVariants & WithConditions)\nexport type PatternRule = '*' | CssRule\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?: {\n [recipe: string]: RecipeRule[]\n }\n /**\n * The css patterns to generate.\n */\n patterns?: {\n [pattern: string]: PatternRule[]\n }\n}\n"
2805
2805
  };
2806
2806
 
2807
2807
  // src/artifacts/types/generated.ts
@@ -3826,21 +3826,49 @@ var generateStaticCss = (ctx) => {
3826
3826
  }
3827
3827
  });
3828
3828
  const getResult = getStaticCss(staticCss);
3829
+ const getPropertyKeys = (prop) => {
3830
+ const propConfig = utility.config[prop];
3831
+ if (!propConfig)
3832
+ return [];
3833
+ const values = utility.getPropertyValues(propConfig);
3834
+ if (!values)
3835
+ return [];
3836
+ return Object.keys(values);
3837
+ };
3829
3838
  const results = getResult({
3830
3839
  breakpoints: Object.keys(theme.breakpoints ?? {}),
3831
- getPropertyKeys: (prop) => {
3832
- const propConfig = utility.config[prop];
3833
- if (!propConfig)
3834
- return [];
3835
- const values = utility.getPropertyValues(propConfig);
3836
- if (!values)
3840
+ getPropertyKeys,
3841
+ getRecipeKeys: (recipe) => {
3842
+ return recipes.details.find((detail) => detail.baseName === recipe)?.variantKeyMap ?? {};
3843
+ },
3844
+ getPatternPropValues: (patternName, property) => {
3845
+ const patternConfig = ctx.patterns.getConfig(patternName);
3846
+ if (!patternConfig)
3837
3847
  return [];
3838
- return Object.keys(values);
3848
+ const propType = patternConfig.properties?.[property];
3849
+ if (!propType)
3850
+ return;
3851
+ if (propType.type === "enum") {
3852
+ return propType.value;
3853
+ }
3854
+ if (propType.type === "boolean") {
3855
+ return ["true", "false"];
3856
+ }
3857
+ if (propType.type === "property") {
3858
+ return getPropertyKeys(propType.value || property);
3859
+ }
3860
+ if (propType.type === "token") {
3861
+ const values = ctx.tokens.getValue(propType.value);
3862
+ return Object.keys(values ?? {});
3863
+ }
3839
3864
  },
3840
- getRecipeKeys: (recipe) => {
3841
- const recipeConfig = recipes.details.find((detail) => detail.baseName === recipe);
3842
- return Object.assign({ __base: recipeConfig?.config.base }, recipeConfig?.variantKeyMap ?? {});
3843
- }
3865
+ getPatternKeys: (patternName) => {
3866
+ const details = ctx.patterns.details.find((d) => d.baseName === patternName);
3867
+ if (!details)
3868
+ return;
3869
+ return details.props ?? [];
3870
+ },
3871
+ getPatternTransform: ctx.patterns.transform.bind(ctx.patterns)
3844
3872
  });
3845
3873
  results.css.forEach((css2) => {
3846
3874
  ctx.stylesheet.processAtomic(css2);
@@ -3853,6 +3881,11 @@ var generateStaticCss = (ctx) => {
3853
3881
  ctx.stylesheet.processRecipe(name, recipeConfig, value);
3854
3882
  });
3855
3883
  });
3884
+ results.patterns.forEach((result) => {
3885
+ Object.entries(result).forEach(([name, value]) => {
3886
+ ctx.stylesheet.processAtomic({ [name]: value });
3887
+ });
3888
+ });
3856
3889
  void ctx.hooks.callHook("generator:css", "static.css", "");
3857
3890
  };
3858
3891
 
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@pandacss/generator",
3
- "version": "0.0.0-dev-20231222115330",
3
+ "version": "0.0.0-dev-20231223024151",
4
4
  "description": "The css generator for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "author": "Segun Adebayo <joseshegs@gmail.com>",
9
9
  "sideEffects": false,
10
+ "homepage": "https://panda-css.com",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/chakra-ui/panda.git",
14
+ "directory": "packages/generator"
15
+ },
10
16
  "publishConfig": {
11
17
  "access": "public"
12
18
  },
@@ -32,17 +38,16 @@
32
38
  "pluralize": "8.0.0",
33
39
  "postcss": "^8.4.31",
34
40
  "ts-pattern": "5.0.5",
35
- "@pandacss/core": "0.0.0-dev-20231222115330",
36
- "@pandacss/is-valid-prop": "0.0.0-dev-20231222115330",
37
- "@pandacss/logger": "0.0.0-dev-20231222115330",
38
- "@pandacss/shared": "0.0.0-dev-20231222115330",
39
- "@pandacss/token-dictionary": "0.0.0-dev-20231222115330",
40
- "@pandacss/types": "0.0.0-dev-20231222115330"
41
+ "@pandacss/core": "0.0.0-dev-20231223024151",
42
+ "@pandacss/is-valid-prop": "0.0.0-dev-20231223024151",
43
+ "@pandacss/logger": "0.0.0-dev-20231223024151",
44
+ "@pandacss/shared": "0.0.0-dev-20231223024151",
45
+ "@pandacss/token-dictionary": "0.0.0-dev-20231223024151",
46
+ "@pandacss/types": "0.0.0-dev-20231223024151"
41
47
  },
42
48
  "devDependencies": {
43
49
  "@types/pluralize": "0.0.33",
44
- "hookable": "5.5.3",
45
- "@pandacss/fixture": "0.0.0-dev-20231222115330"
50
+ "hookable": "5.5.3"
46
51
  },
47
52
  "scripts": {
48
53
  "build": "tsup src/index.ts --format=esm,cjs --dts",