import type { TSConfig } from 'pkg-types' import type { Conditions, ExtendableConditions } from './conditions' import type { HookRegistry } from './hooks' import type { PatternConfig } from './pattern' import type { Keys, PathIn, RequiredBy } from './shared' import type { StaticCssOptions } from './static-css' import type { ExtendableGlobalFontface, ExtendableGlobalStyleObject, GlobalFontface, GlobalStyleObject, } from './system-types' import type { ExtendableTheme, Theme } from './theme' import type { CssPropertyDefinition, GlobalVarsDefinition } from './global-vars' import type { ExtendableUtilityConfig, UtilityConfig } from './utility' export type { TSConfig } /** The five cascade layers, in emit order. */ export type StylesheetLayerName = 'reset' | 'base' | 'tokens' | 'recipes' | 'utilities' export type StylesheetLayers = Record export interface Patterns { [pattern: string]: PatternConfig } export interface PresetCore { /** * The css selectors or media queries shortcuts. * @example `{ hover: "&:hover" }` */ conditions: Conditions /** * The global styles for your project. */ globalCss: GlobalStyleObject /** * The global fontface for your project. */ globalFontface?: GlobalFontface /** * Used to generate css utility classes for your project. */ staticCss: StaticCssOptions /** * The theme configuration for your project. */ theme: Theme /** * The css utility definitions. */ utilities: UtilityConfig /** * Common styling or layout patterns for your project. */ patterns: Record /** * Multiple themes for your project. */ themes?: ThemeVariantsMap } interface ExtendablePatterns { [pattern: string]: PatternConfig | Patterns | undefined extend?: Patterns | undefined } interface ExtendableStaticCssOptions extends StaticCssOptions { extend?: StaticCssOptions | undefined } export type { CssPropertyDefinition, CssPropertySyntax, GlobalVarsDefinition } from './global-vars' interface ExtendableGlobalVars { [key: string]: string | CssPropertyDefinition | GlobalVarsDefinition | undefined extend?: GlobalVarsDefinition } export interface ThemeVariant extends Pick {} export interface ThemeVariantsMap { [name: string]: ThemeVariant } interface ExtendableThemeVariantsMap { [name: string]: ThemeVariantsMap | ThemeVariant | undefined extend?: ThemeVariantsMap | undefined } export interface ExtendableOptions { /** * The css selectors or media queries shortcuts. * @example `{ hover: "&:hover" }` */ conditions?: ExtendableConditions /** * The global styles for your project. */ globalCss?: ExtendableGlobalStyleObject /** * The global fontface for your project. */ globalFontface?: ExtendableGlobalFontface /** * The global custom position try fallback option */ /** * Used to generate css utility classes for your project. */ staticCss?: ExtendableStaticCssOptions /** * The theme configuration for your project. */ theme?: ExtendableTheme /** * The css utility definitions. */ utilities?: ExtendableUtilityConfig /** * Common styling or layout patterns for your project. */ patterns?: ExtendablePatterns /** * The css variables for your project. */ globalVars?: ExtendableGlobalVars /** * The theme variants for your project. */ themes?: ExtendableThemeVariantsMap } export interface ImportMapInput { css?: string | string[] recipe?: string | string[] recipes?: string | string[] pattern?: string | string[] patterns?: string | string[] jsx?: string | string[] tokens?: string | string[] } export interface ImportMapOutput { css: T[] recipe: T[] pattern: T[] jsx: T[] tokens: T[] } export type ImportMapOption = string | ImportMapInput interface FileSystemOptions { /** * The output directory. * @default 'styled-system' */ outdir?: string /** * Allows you to customize the import paths for the generated outdir. * @default * ```js * { * css: 'styled-system/css', * recipes: 'styled-system/recipes', * patterns: 'styled-system/patterns', * jsx: 'styled-system/jsx', * tokens: 'styled-system/tokens', * } * ``` */ importMap?: ImportMapOption | Array designSystem?: string /** * List of files glob to watch for changes. * @default [] */ include?: string[] /** * List of files glob to ignore. * @default [] */ exclude?: string[] /** * List of globs or files that will trigger a config reload when changed. * * We automatically track the config file and (transitive) files imported by the config file as much as possible, but sometimes we might miss some. * Use this option as a workaround. */ dependencies?: string[] /** * The current working directory. * @default 'process.cwd()' */ cwd?: string /** * The log level for the built-in logger. * @default 'info' */ logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent' } export type JsxFramework = 'react' | 'solid' | 'preact' | 'vue' interface JsxOptions { /** * The framework to use for generating supercharged elements. */ jsxFramework?: JsxFramework | (string & {}) /** * The factory name of the element * @default 'styled' * * @example * ```jsx * Click me * ``` */ jsxFactory?: string /** * The style props allowed on generated JSX components * - When set to 'all', all style props are allowed. * - When set to 'minimal', only the `css` prop, props ending in `Css`, and a pattern's or recipe's own props are allowed. * - When set to 'none', no style props are allowed and therefore the jsxFactory will not be importable. * * @default 'all' * * @example with 'all': * ```jsx * Click me * ``` * * @example with 'minimal': * ```jsx * Click me * ``` * * @example with 'none': * ```jsx * * ``` */ jsxStyleProps?: 'all' | 'minimal' | 'none' /** * Rules for which JSX components Panda extracts style props from. * The last rule matching a component wins, over Panda's own detection. * * @example * ```js * jsxMatchTag: [ * { from: '@tanstack/react-table', ignore: true }, * { tag: /Button$/ }, * { tag: 'Card', props: ['padding', 'color'] }, * ] * ``` */ jsxMatchTag?: JsxMatchTagRule[] } export interface JsxMatchTagRule { /** * The component name as written in source, such as `Button` or `UI.Button`. */ tag?: string | RegExp /** * The import path the component comes from, as written in source. */ from?: string | RegExp /** * Extract only these style props. */ props?: string[] /** * Never extract style props from matching components. */ ignore?: boolean } interface CssgenOptions { /** * Whether to include css reset styles in the generated css. * @default false */ preflight?: boolean | { scope: string; level?: 'element' | 'parent' } /** * The namespace prefix for the generated css classes and css variables. * @default '' */ prefix?: string | { cssVar?: string; className?: string } /** * The value separator used in the generated class names. * @default '_' */ separator?: '_' | '=' | '-' /** * The root selector for the css variables. * @default ':where(:host, :root)' */ cssVarRoot?: string /** * Layer mappings used in the generated css. * @default 'true' */ layers?: Partial /** * Whether to minify the emitted css. The `--minify` CLI flag overrides this. * @default false */ minify?: boolean /** * Polyfill cascade layers for older browsers. `--polyfill` overrides this. * @default false */ polyfill?: boolean } export interface OptimizeOptions { /** * Remove unused token declarations based on extracted project usage. */ removeUnusedTokens?: boolean /** * Remove unused keyframes based on extracted project usage. */ removeUnusedKeyframes?: boolean /** * Narrow compound variant CSS to statically selected variant combinations. */ smartCompoundVariants?: boolean /** * Hydrate only build-info modules for design-system exports the app imports. * Off by default. Namespace / side-effect imports still hydrate everything. */ treeshakeDesignSystem?: boolean /** * Also seed `@property` registrations as plain declarations, for engines that ignore * `@property` (Safari < 16.4, Firefox < 128) and would otherwise drop any declaration * reading an unregistered variable. Off by default — modern engines don't need it. */ propertyFallback?: boolean } interface CodegenOptions { /** * Whether to hash the generated class names / css variables. * This is useful if you want to shorten the class names or css variables. * @default false */ hash?: boolean | { cssVar: boolean; className: boolean } /** * Whether to resolve configured utility shorthands like `p` -> `padding`. * @default true */ shorthands?: boolean /** * Change generated TypeScript definitions to be more strict for properties * having a token or utility. */ strictTokens?: boolean /** * Change generated TypeScript definitions to be more strict for built-in CSS * properties to only allow valid CSS values. */ strictPropertyValues?: boolean /** * Generated runtime file extension. * @default 'js' */ outExtension?: 'ts' | 'js' | 'mjs' /** * Whether generated import specifiers include runtime file extensions. * When `outExtension` is `mjs`, this also emits `.d.mts` instead of `.d.ts`. * @default false */ forceImportExtension?: boolean /** * CSS emission optimizations. All optimizations are opt-in. */ optimize?: OptimizeOptions } interface PresetOptions { /** * Used to create reusable config presets for your project or team. */ presets?: (string | Preset | Promise)[] } export interface PandaPlugin { name: string hooks?: Partial } export interface PluginsOptions { plugins?: PandaPlugin[] } export interface Config extends ExtendableOptions, CssgenOptions, CodegenOptions, FileSystemOptions, JsxOptions, PresetOptions, PluginsOptions { /** * The validation strictness to use when validating the config. * - When set to 'none', no validation will be performed. * - When set to 'warn', warnings will be logged when validation fails. * - When set to 'error', errors will be thrown when validation fails. * * @default 'warn' */ validation?: 'none' | 'warn' | 'error' } export interface Preset extends ExtendableOptions, PresetOptions, PluginsOptions { name: string } export interface UserConfig extends Partial, RequiredBy, 'outdir' | 'cwd' | 'include'> {} export interface PathMapping { pattern: RegExp paths: string[] } export interface ConfigTsOptions { baseUrl?: string | undefined pathMappings: PathMapping[] } export interface LoadTsConfigResult { tsconfig?: TSConfig tsOptions?: ConfigTsOptions tsconfigFile?: string } export interface LoadConfigResult extends LoadTsConfigResult { /** Config path */ path: string config: UserConfig serialized: string deserialize: () => Config dependencies: string[] hooks: Partial } export interface HashOptions { tokens: boolean | undefined className: boolean | undefined } export interface PrefixOptions { tokens: string | undefined className: string | undefined } type ReqConf = Required export type ConfigPath = Exclude< | Exclude>, 'theme'> | PathIn | PathIn | PathIn | (string & {}), undefined >