@pandacss/types 0.27.3 → 0.29.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.
@@ -1,3 +1,4 @@
1
+ import { type Difference } from 'microdiff'
1
2
  import type { Nullable } from './shared'
2
3
 
3
4
  export interface ArtifactContent {
@@ -25,11 +26,7 @@ export type ArtifactId =
25
26
  | 'jsx-patterns'
26
27
  | 'jsx-patterns-index'
27
28
  | 'css-index'
28
- | 'reset.css'
29
- | 'global.css'
30
- | 'static.css'
31
29
  | 'package.json'
32
- | 'styles.css'
33
30
  | (string & {})
34
31
 
35
32
  export type CssArtifactType = 'preflight' | 'tokens' | 'static' | 'global' | 'keyframes'
@@ -49,3 +46,9 @@ export interface ArtifactFilters {
49
46
  ids?: ArtifactId[]
50
47
  affecteds?: AffectedArtifacts
51
48
  }
49
+
50
+ export interface DiffConfigResult {
51
+ hasConfigChanged: boolean
52
+ artifacts: Set<ArtifactId>
53
+ diffs: Difference[]
54
+ }
package/dist/config.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface StudioOptions {
38
38
  }
39
39
  }
40
40
 
41
- interface Patterns {
41
+ export interface Patterns {
42
42
  [pattern: string]: PatternConfig
43
43
  }
44
44
 
@@ -155,6 +155,13 @@ interface FileSystemOptions {
155
155
  * @default []
156
156
  */
157
157
  exclude?: string[]
158
+ /**
159
+ * List of globs or files that will trigger a config reload when changed.
160
+ *
161
+ * We automatically track the config file and (transitive) files imported by the config file as much as possible, but sometimes we might miss some.
162
+ * Use this option as a workaround.
163
+ */
164
+ dependencies?: string[]
158
165
  /**
159
166
  * Whether to watch for changes and regenerate the css.
160
167
  * @default false
@@ -346,6 +353,15 @@ export interface Config
346
353
  * @default 'false'
347
354
  */
348
355
  eject?: boolean
356
+ /**
357
+ * The validation strcictnesss to use when validating the config.
358
+ * - When set to 'none', no validation will be performed.
359
+ * - When set to 'warn', warnings will be logged when validation fails.
360
+ * - When set to 'error', errors will be thrown when validation fails.
361
+ *
362
+ * @default 'error'
363
+ */
364
+ validation?: 'none' | 'warn' | 'error'
349
365
  }
350
366
 
351
367
  export interface Preset extends ExtendableOptions, PresetOptions {}
@@ -377,6 +393,7 @@ export interface LoadConfigResult extends LoadTsConfigResult {
377
393
  serialized: string
378
394
  deserialize: () => Config
379
395
  dependencies: string[]
396
+ hooks: Partial<PandaHooks>
380
397
  }
381
398
 
382
399
  export interface HashOptions {
@@ -0,0 +1,56 @@
1
+ import type { UserConfig } from './config'
2
+ import type { RecipeDefinition, RecipeVariantRecord, SlotRecipeDefinition, SlotRecipeVariantRecord } from './recipe'
3
+ import type { AtomicStyleResult, RecipeBaseResult } from './style-rules'
4
+ import type { SystemStyleObject } from './system-types'
5
+
6
+ export interface BaseRule {
7
+ getClassNames: () => string[]
8
+ toCss: () => string
9
+ }
10
+
11
+ export interface AtomicRule extends BaseRule {
12
+ styles: SystemStyleObject
13
+ }
14
+
15
+ export interface AtomicRecipeRule extends BaseRule {
16
+ config: RecipeDefinition<any> | SlotRecipeDefinition<string, any>
17
+ }
18
+
19
+ export interface RecipeVariantsRule extends BaseRule {
20
+ variants: RecipeVariantRecord
21
+ }
22
+
23
+ export interface ProcessorInterface {
24
+ css(styles: SystemStyleObject): AtomicRule
25
+ cva(recipeConfig: RecipeDefinition<RecipeVariantRecord>): AtomicRecipeRule
26
+ sva(recipeConfig: SlotRecipeDefinition<string, SlotRecipeVariantRecord<string>>): AtomicRecipeRule
27
+ recipe(name: string, variants?: RecipeVariantRecord): RecipeVariantsRule | undefined
28
+ }
29
+
30
+ export interface HooksApiInterface {
31
+ /**
32
+ * The resolved config (after all the presets are loaded and merged)
33
+ */
34
+ config: UserConfig
35
+ /**
36
+ * The path to the config file
37
+ */
38
+ configPath: string
39
+ /**
40
+ * The list of all the config dependencies (direct/transitive imports) filepaths
41
+ */
42
+ configDependencies: string[]
43
+ //
44
+ /**
45
+ * The processor can be used to generate atomic or recipe classes
46
+ */
47
+ processor: ProcessorInterface
48
+ /**
49
+ * Map that contains all the utility classNames
50
+ */
51
+ classNames: Map<string, string>
52
+ /**
53
+ * Map that contains all the classNames found (and therefore generated) in the app code
54
+ */
55
+ generatedClassNames: Map<string, AtomicStyleResult | RecipeBaseResult>
56
+ }
package/dist/hooks.d.ts CHANGED
@@ -1,44 +1,61 @@
1
- import type { HookKeys, Hookable } from 'hookable'
1
+ import type { ArtifactId, DiffConfigResult } from './artifact'
2
2
  import type { LoadConfigResult, UserConfig } from './config'
3
+ import type { HooksApiInterface } from './hooks-api'
3
4
  import type { ParserResultInterface } from './parser'
4
5
 
5
- type MaybeAsyncReturn = Promise<void> | void
6
+ type MaybeAsyncReturn<T = void> = Promise<T> | T
6
7
 
7
8
  export interface PandaHooks {
8
9
  /**
9
10
  * Called when the config is resolved, after all the presets are loaded and merged.
11
+ * This is the first hook called, you can use it to tweak the config before the context is created.
10
12
  */
11
- 'config:resolved': (conf: LoadConfigResult) => MaybeAsyncReturn
13
+ 'config:resolved': (args: { conf: LoadConfigResult }) => MaybeAsyncReturn
14
+ /**
15
+ * Called when the Panda context has been created and the API is ready to be used.
16
+ */
17
+ 'context:created': (args: { ctx: HooksApiInterface; logger: LoggerInterface }) => void
12
18
  /**
13
19
  * Called when the config file or one of its dependencies (imports) has changed.
14
20
  */
15
- 'config:change': (ctx: UserConfig) => MaybeAsyncReturn
21
+ 'config:change': (args: { config: UserConfig; changes: DiffConfigResult }) => MaybeAsyncReturn
16
22
  /**
17
23
  * Called after reading the file content but before parsing it.
24
+ * You can use this hook to transform the file content to a tsx-friendly syntax so that Panda's parser can parse it.
25
+ * You can also use this hook to parse the file's content on your side using a custom parser, in this case you don't have to return anything.
18
26
  */
19
- 'parser:before': (file: string, content: string) => void
27
+ 'parser:before': (args: { filePath: string; content: string }) => string | void
20
28
  /**
21
29
  * Called after the file styles are extracted and processed into the resulting ParserResult object.
30
+ * You can also use this hook to add your own extraction results from your custom parser to the ParserResult object.
22
31
  */
23
- 'parser:after': (file: string, result: ParserResultInterface | undefined) => void
24
- /**
25
- * Called after the extracted ParserResult has been transformed to a CSS string
26
- */
27
- 'parser:css': (file: string, css: string | undefined) => void
32
+ 'parser:after': (args: { filePath: string; result: ParserResultInterface | undefined }) => void
28
33
  /**
29
- * Called before generating the design-system CSS files (global, static, preflight, tokens, keyframes)
34
+ * Called after the codegen is completed
30
35
  */
31
- 'generator:css': (
32
- file: 'global.css' | 'static.css' | 'reset.css' | 'tokens.css' | 'keyframes.css' | 'styles.css',
33
- css: string,
34
- ) => void
36
+ 'codegen:done': (args: { changed: ArtifactId[] | undefined }) => MaybeAsyncReturn
35
37
  /**
36
- * Called after the codegen is completed
38
+ * Called right before adding the design-system CSS (global, static, preflight, tokens, keyframes) to the final CSS
39
+ * Called right before writing/injecting the final CSS (styles.css) that contains the design-system CSS and the parser CSS
40
+ * You can use it to tweak the CSS content before it's written to disk or injected through the postcss plugin.
37
41
  */
38
- 'generator:done': () => void | Promise<void>
42
+ 'cssgen:done': (args: {
43
+ artifact: 'global' | 'static' | 'reset' | 'tokens' | 'keyframes' | 'styles.css'
44
+ content: string
45
+ }) => string | void
39
46
  }
40
47
 
41
- export type PandaHookable = Hookable<PandaHooks, HookKeys<PandaHooks>>
42
- export interface ConfigResultWithHooks extends LoadConfigResult {
43
- hooks: PandaHookable
48
+ export interface LoggerInterface {
49
+ level: 'debug' | 'info' | 'warn' | 'error' | 'silent'
50
+ print(data: any): void
51
+ warn: (type: string, data: any) => void
52
+ info: (type: string, data: any) => void
53
+ debug: (type: string, data: any) => void
54
+ error: (type: string, data: any) => void
55
+ log: (data: string) => void
56
+ time: {
57
+ info: (msg: string) => (_msg?: string) => void
58
+ debug: (msg: string) => (_msg?: string) => void
59
+ }
60
+ isDebug: boolean
44
61
  }
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export type * from './composition'
4
4
  export type * from './conditions'
5
5
  export type * from './config'
6
6
  export type * from './hooks'
7
+ export type * from './hooks-api'
7
8
  export type * from './parser'
8
9
  export type * from './parts'
9
10
  export type * from './pattern'
package/dist/pattern.d.ts CHANGED
@@ -12,13 +12,20 @@ export type PatternProperty =
12
12
 
13
13
  export interface PatternHelpers {
14
14
  map: (value: any, fn: (value: string) => string | undefined) => any
15
+ isCssUnit: (value: any) => boolean
16
+ isCssVar: (value: any) => boolean
17
+ isCssFunction: (value: any) => boolean
15
18
  }
16
19
 
17
20
  export interface PatternProperties {
18
21
  [key: string]: PatternProperty
19
22
  }
20
23
 
21
- type Props<T> = Record<LiteralUnion<keyof T>, any>
24
+ type InferProps<T> = Record<LiteralUnion<keyof T>, any>
25
+
26
+ export type PatternDefaultValue<T> = Partial<InferProps<T>>
27
+
28
+ export type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>
22
29
 
23
30
  export interface PatternConfig<T extends PatternProperties = PatternProperties> {
24
31
  /**
@@ -34,10 +41,14 @@ export interface PatternConfig<T extends PatternProperties = PatternProperties>
34
41
  * The properties of the pattern.
35
42
  */
36
43
  properties?: T
44
+ /**
45
+ * The default values of the pattern.
46
+ */
47
+ defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>
37
48
  /**
38
49
  * The css object this pattern will generate.
39
50
  */
40
- transform?: (props: Props<T>, helpers: PatternHelpers) => SystemStyleObject
51
+ transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject
41
52
  /**
42
53
  * The jsx element name this pattern will generate.
43
54
  */
package/dist/theme.d.ts CHANGED
@@ -37,6 +37,14 @@ export interface Theme {
37
37
  * Multi-variant style definitions for component slots.
38
38
  */
39
39
  slotRecipes?: Record<string, SlotRecipeConfig>
40
+ /**
41
+ * The predefined container names for your project.
42
+ */
43
+ containerNames?: string[]
44
+ /**
45
+ * The predefined container sizes for your project.
46
+ */
47
+ containerSizes?: Record<string, string>
40
48
  }
41
49
 
42
50
  interface PartialTheme extends Omit<Theme, 'recipes' | 'slotRecipes'> {
package/dist/tokens.d.ts CHANGED
@@ -90,6 +90,7 @@ export interface TokenDataTypes {
90
90
  assets: string | Asset
91
91
  borderWidths: string
92
92
  aspectRatios: string
93
+ containerNames: string
93
94
  }
94
95
 
95
96
  export type Tokens = {
package/dist/utility.d.ts CHANGED
@@ -16,9 +16,20 @@ export type PropertyValues =
16
16
  | Record<string, string>
17
17
  | ThemeFn
18
18
 
19
- interface TransformArgs {
19
+ export interface ColorMixResult {
20
+ invalid: boolean
21
+ value: string
22
+ color?: string
23
+ }
24
+
25
+ export interface TransformUtils {
26
+ colorMix(value: string): ColorMixResult
27
+ }
28
+
29
+ export interface TransformArgs<T = any> {
20
30
  token: TokenFn
21
- raw: any
31
+ raw: T
32
+ utils: TransformUtils
22
33
  }
23
34
 
24
35
  export type PropertyTransform = (value: any, args: TransformArgs) => NestedCssProperties | undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.27.3",
3
+ "version": "0.29.0",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",
@@ -27,10 +27,10 @@
27
27
  ],
28
28
  "devDependencies": {
29
29
  "csstype": "3.1.3",
30
- "hookable": "5.5.3",
30
+ "microdiff": "^1.3.2",
31
31
  "ncp": "^2.0.0",
32
32
  "pkg-types": "1.0.3",
33
- "@pandacss/extractor": "0.27.3"
33
+ "@pandacss/extractor": "0.29.0"
34
34
  },
35
35
  "scripts": {
36
36
  "dev": "tsx scripts/watch.ts",