@pandacss/types 0.0.0-dev-20230614113002 → 0.0.0-dev-20230614152938

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/config.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Conditions } from './conditions'
2
+ import type { PandaHooks } from './hooks'
2
3
  import type { PatternConfig } from './pattern'
3
4
  import type { Extendable, RequiredBy, UnwrapExtend } from './shared'
4
5
  import type { StaticCssOptions } from './static-css'
@@ -193,13 +194,18 @@ type PresetOptions = {
193
194
  presets?: (string | Preset | Promise<Preset>)[]
194
195
  }
195
196
 
197
+ type HooksOptions = {
198
+ hooks?: Partial<PandaHooks>
199
+ }
200
+
196
201
  export type Config = StudioOptions &
197
202
  ExtendableOptions &
198
203
  CssgenOptions &
199
204
  CodegenOptions &
200
205
  FileSystemOptions &
201
206
  JsxOptions &
202
- PresetOptions
207
+ PresetOptions &
208
+ HooksOptions
203
209
 
204
210
  export type Preset = ExtendableOptions & PresetOptions
205
211
 
@@ -0,0 +1,45 @@
1
+ import type { TokenDictionary } from '@pandacss/token-dictionary'
2
+ import type { HookKeys, Hookable } from 'hookable'
3
+ import type { LoadConfigResult, UserConfig } from './config'
4
+ import type { ParserResultType } from './parser'
5
+
6
+ type MaybeAsyncReturn = Promise<void> | void
7
+
8
+ export interface PandaHooks {
9
+ /**
10
+ * Called when the config is resolved, after all the presets are loaded and merged.
11
+ */
12
+ 'config:resolved': (conf: LoadConfigResult) => MaybeAsyncReturn
13
+ /**
14
+ * Called when the config file or one of its dependencies (imports) has changed.
15
+ */
16
+ 'config:change': (ctx: UserConfig) => MaybeAsyncReturn
17
+ /**
18
+ * Called after creating the TokenDictionary from the resolved config.
19
+ */
20
+ 'generator:tokens': (tokenDictionary: TokenDictionary) => void
21
+ /**
22
+ * Called after reading the file content but before parsing it.
23
+ */
24
+ 'parser:before': (file: string, content: string) => void
25
+ /**
26
+ * Called after the file styles are extracted and processed into the resulting ParserResult object.
27
+ */
28
+ 'parser:after': (file: string, result: ParserResultType | undefined) => void
29
+ /**
30
+ * Called after the extracted ParserResult has been transformed to a CSS string
31
+ */
32
+ 'parser:css': (file: string, css: string | undefined) => void
33
+ /**
34
+ * Called before generating the design-system CSS files (global, static, preflight, tokens, keyframes)
35
+ */
36
+ 'generator:css': (
37
+ file: 'global.css' | 'static.css' | 'reset.css' | 'tokens.css' | 'keyframes.css',
38
+ css: string,
39
+ ) => void
40
+ }
41
+
42
+ export type PandaHookable = Hookable<PandaHooks, HookKeys<PandaHooks>>
43
+ export interface ConfigResultWithHooks extends LoadConfigResult {
44
+ hooks: PandaHookable
45
+ }
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export type {
10
10
  export type { CompositionStyles, LayerStyles, TextStyles } from './composition'
11
11
  export type { ConditionDetails, ConditionType, Conditions, RawCondition } from './conditions'
12
12
  export type { Config, LoadConfigResult, Preset, UserConfig } from './config'
13
+ export type { ConfigResultWithHooks, PandaHooks, PandaHookable } from './hooks'
13
14
  export type { ParserResultType, ResultItem } from './parser'
14
15
  export type { Part, Parts } from './parts'
15
16
  export type { PatternConfig, PatternHelpers, PatternProperty } from './pattern'
package/dist/parser.d.ts CHANGED
@@ -13,12 +13,14 @@ export type ParserResultType = {
13
13
  cva: Set<ResultItem>
14
14
  recipe: Map<string, Set<ResultItem>>
15
15
  pattern: Map<string, Set<ResultItem>>
16
+ filePath: string | undefined
16
17
  set: (name: 'cva' | 'css', result: ResultItem) => void
17
18
  setCva: (result: ResultItem) => void
18
19
  setJsx: (result: ResultItem) => void
19
20
  setRecipe: (name: string, result: ResultItem) => void
20
21
  setPattern: (name: string, result: ResultItem) => void
21
22
  isEmpty: () => boolean
23
+ setFilePath: (filePath: string) => ParserResultType
22
24
  toArray: () => Array<ResultItem>
23
25
  toJSON: () => {
24
26
  css: Array<ResultItem>
package/dist/pattern.d.ts CHANGED
@@ -14,7 +14,11 @@ export type PatternHelpers = {
14
14
  map: (value: any, fn: (value: string) => string | undefined) => any
15
15
  }
16
16
 
17
- export type PatternConfig<T = PatternProperty> = {
17
+ type PatternProperties = Record<string, PatternProperty>
18
+
19
+ type Props<T> = Record<LiteralUnion<keyof T>, any>
20
+
21
+ export type PatternConfig<T extends PatternProperties = PatternProperties> = {
18
22
  /**
19
23
  * The description of the pattern. This will be used in the JSDoc comment.
20
24
  */
@@ -27,14 +31,11 @@ export type PatternConfig<T = PatternProperty> = {
27
31
  /**
28
32
  * The properties of the pattern.
29
33
  */
30
- properties: T extends Record<string, PatternProperty> ? T : Record<string, PatternProperty>
34
+ properties: T
31
35
  /**
32
36
  * The css object this pattern will generate.
33
37
  */
34
- transform?: (
35
- props: T extends Record<infer Keys, PatternProperty> ? Record<Keys, any> : Record<string, PatternProperty>,
36
- helpers: PatternHelpers,
37
- ) => SystemStyleObject
38
+ transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject
38
39
  /**
39
40
  * The jsx element name this pattern will generate.
40
41
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.0.0-dev-20230614113002",
3
+ "version": "0.0.0-dev-20230614152938",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",
@@ -13,10 +13,10 @@
13
13
  ],
14
14
  "devDependencies": {
15
15
  "chokidar-cli": "^3.0.0",
16
- "csstype": "3.1.2"
17
- },
18
- "dependencies": {
19
- "@pandacss/extractor": "0.0.0-dev-20230614113002"
16
+ "csstype": "3.1.2",
17
+ "hookable": "5.5.3",
18
+ "@pandacss/extractor": "0.0.0-dev-20230614152938",
19
+ "@pandacss/token-dictionary": "0.0.0-dev-20230614152938"
20
20
  },
21
21
  "scripts": {
22
22
  "build": "tsx scripts/build.ts",