🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@bamboocss/types

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bamboocss/types - npm Package Compare versions

Comparing version
1.11.1
to
1.11.2
+65
dist/artifact.d.ts
import { type Difference } from 'microdiff'
export interface ArtifactContent {
file: string
code: string | undefined
}
export type ArtifactId =
| 'helpers'
| 'keyframes'
| 'design-tokens'
| 'types'
| 'css-fn'
| 'cva'
| 'sva'
| 'cx'
| 'create-recipe'
| 'recipes'
| 'recipes-index'
| 'patterns'
| 'patterns-index'
| 'jsx-is-valid-prop'
| 'jsx-helpers'
| 'jsx-factory'
| 'jsx-patterns'
| 'jsx-create-style-context'
| 'jsx-patterns-index'
| 'css-index'
| 'themes'
| 'package.json'
| 'types-jsx'
| 'types-entry'
| 'types-styles'
| 'types-conditions'
| 'types-gen'
| 'types-gen-system'
| 'static-css'
| 'styles.css'
| 'styles'
| `recipes.${string}`
| `patterns.${string}`
export type CssArtifactType = 'preflight' | 'tokens' | 'static' | 'global' | 'keyframes'
export type Artifact = {
id: ArtifactId
dir?: string[]
files: ArtifactContent[]
}
export interface AffectedArtifacts {
recipes: string[]
patterns: string[]
}
export interface ArtifactFilters {
ids?: ArtifactId[]
affecteds?: AffectedArtifacts
}
export interface DiffConfigResult {
hasConfigChanged: boolean
artifacts: Set<ArtifactId>
diffs: Difference[]
}
import type { CompositionStyleObject } from './system-types'
interface Token<T> {
value: T
description?: string
}
interface Recursive<T> {
[key: string]: Recursive<T> | T
}
/* -----------------------------------------------------------------------------
* Text styles
* -----------------------------------------------------------------------------*/
type TextStyleProperty =
| 'color'
| 'direction'
| 'font'
| 'fontFamily'
| 'fontFeatureSettings'
| 'fontKerning'
| 'fontLanguageOverride'
| 'fontOpticalSizing'
| 'fontPalette'
| 'fontSize'
| 'fontSizeAdjust'
| 'fontStretch'
| 'fontStyle'
| 'fontSynthesis'
| 'fontVariant'
| 'fontVariantAlternates'
| 'fontVariantCaps'
| 'fontVariantLigatures'
| 'fontVariantNumeric'
| 'fontVariantPosition'
| 'fontVariationSettings'
| 'fontWeight'
| 'hangingPunctuation'
| 'hypens'
| 'hyphenateCharacter'
| 'hyphenateLimitChars'
| 'letterSpacing'
| 'lineBreak'
| 'lineHeight'
| 'quotes'
| 'overflowWrap'
| 'tabSize'
| 'textAlign'
| 'textAlignLast'
| 'textBox'
| 'textBoxEdge'
| 'textBoxTrim'
| 'textCombineUpright'
| 'textDecoration'
| 'textDecorationColor'
| 'textDecorationLine'
| 'textDecorationSkip'
| 'textDecorationSkipBox'
| 'textDecorationSkipInk'
| 'textDecorationSkipInset'
| 'textDecorationStyle'
| 'textDecorationThickness'
| 'textEmphasis'
| 'textEmphasisColor'
| 'textEmphasisPosition'
| 'textEmphasisStyle'
| 'textIndent'
| 'textJustify'
| 'textOrientation'
| 'textOverflow'
| 'textRendering'
| 'textShadow'
| 'textStroke'
| 'textStrokeColor'
| 'textStrokeWidth'
| 'textTransform'
| 'textUnderlineOffset'
| 'textUnderlinePosition'
| 'textWrap'
| 'textWrapMode'
| 'textWrapStyle'
| 'unicodeBidi'
| 'verticalAlign'
| 'whiteSpace'
| 'wordBreak'
| 'wordSpacing'
| 'writingMode'
export type TextStyle = CompositionStyleObject<TextStyleProperty>
export type TextStyles = Recursive<Token<TextStyle>>
/* -----------------------------------------------------------------------------
* Layer styles
* -----------------------------------------------------------------------------*/
type LogicalPlacement = 'Inline' | 'Block' | 'InlineStart' | 'InlineEnd' | 'BlockStart' | 'BlockEnd'
type PhysicalPlacement = 'Top' | 'Right' | 'Bottom' | 'Left'
type Placement = PhysicalPlacement | LogicalPlacement
type Radius =
| `Top${'Right' | 'Left'}`
| `Bottom${'Right' | 'Left'}`
| `Start${'Start' | 'End'}`
| `End${'Start' | 'End'}`
type LayerStyleProperty =
| 'aspectRatio'
| 'background'
| 'backgroundColor'
| 'backgroundImage'
| 'border'
| 'borderColor'
| 'borderImage'
| 'borderImageOutset'
| 'borderImageRepeat'
| 'borderImageSlice'
| 'borderImageSource'
| 'borderImageWidth'
| 'borderRadius'
| 'borderStyle'
| 'borderWidth'
| `border${Placement}`
| `border${Placement}Color`
| `border${Placement}Style`
| `border${Placement}Width`
| 'borderRadius'
| `border${Radius}Radius`
| 'boxShadow'
| 'boxShadowColor'
| 'clipPath'
| 'color'
| 'contain'
| 'content'
| 'contentVisibility'
| 'cursor'
| 'display'
| 'filter'
| 'backdropFilter'
| 'height'
| 'width'
| 'minHeight'
| 'minWidth'
| 'maxHeight'
| 'maxWidth'
| `margin${Placement}`
| 'inset'
| `inset${LogicalPlacement}`
| Lowercase<PhysicalPlacement>
| 'isolation'
| 'mask'
| 'maskClip'
| 'maskComposite'
| 'maskImage'
| 'maskMode'
| 'maskOrigin'
| 'maskPosition'
| 'maskRepeat'
| 'maskSize'
| 'mixBlendMode'
| 'objectFit'
| 'objectPosition'
| 'opacity'
| 'outline'
| 'outlineColor'
| 'outlineOffset'
| 'outlineStyle'
| 'outlineWidth'
| 'overflow'
| 'overflowX'
| 'overflowY'
| 'padding'
| `padding${Placement}`
| 'pointerEvents'
| 'position'
| 'resize'
| 'transform'
| 'transition'
| 'visibility'
| 'willChange'
| 'zIndex'
| 'backgroundBlendMode'
| 'backgroundAttachment'
| 'backgroundClip'
| 'backgroundOrigin'
| 'backgroundPosition'
| 'backgroundRepeat'
| 'backgroundSize'
export type LayerStyle = CompositionStyleObject<LayerStyleProperty>
export type LayerStyles = Recursive<Token<LayerStyle>>
/* -----------------------------------------------------------------------------
* Motion styles
* -----------------------------------------------------------------------------*/
type AnimationStyleProperty =
| 'animation'
| 'animationComposition'
| 'animationDelay'
| 'animationDirection'
| 'animationDuration'
| 'animationFillMode'
| 'animationIterationCount'
| 'animationName'
| 'animationPlayState'
| 'animationTimingFunction'
| 'animationRange'
| 'animationRangeStart'
| 'animationRangeEnd'
| 'animationTimeline'
| 'transformOrigin'
export type AnimationStyle = CompositionStyleObject<AnimationStyleProperty>
export type AnimationStyles = Recursive<Token<AnimationStyle>>
export interface CompositionStyles {
textStyles: TextStyles
layerStyles: LayerStyles
animationStyles: AnimationStyles
}
import type { AnySelector, Selectors } from './selectors'
export type ConditionType =
| 'at-rule'
| 'parent-nesting'
| 'self-nesting'
| 'combinator-nesting'
| 'mixed'
| 'multi-block'
export type ConditionDetails = AtRuleCondition | SelectorCondition | MixedCondition | MultiBlockCondition
export interface AtRuleCondition {
type: 'at-rule'
value: string
raw: string
name: string
params: string
}
export interface SelectorCondition {
type: 'self-nesting' | 'parent-nesting' | 'combinator-nesting'
value: string
raw: string
}
export interface MixedCondition {
type: 'mixed'
value: ConditionDetails[]
raw: string[]
}
export interface MultiBlockCondition {
type: 'multi-block'
value: MixedCondition[]
raw: Record<string, any>
}
/* -----------------------------------------------------------------------------
* Shadowed export (in CLI): DO NOT REMOVE
* -----------------------------------------------------------------------------*/
export type ConditionObjectQuery = {
[key: string]: ConditionObjectQuery | '@slot'
}
export type ConditionQuery = string | string[] | ConditionObjectQuery
export interface Conditions {
[condition: string]: ConditionQuery
}
export interface ExtendableConditions {
[condition: string]: ConditionQuery | Conditions | undefined
extend?: Conditions | undefined
}
export type Condition = string
export type ConditionalValue<V> =
| V
| Array<V | null>
| {
[K in keyof Conditions]?: ConditionalValue<V>
}
export type Nested<P> =
| (P & {
[K in Selectors]?: Nested<P>
} & {
[K in AnySelector]?: Nested<P>
})
| {
[K in Condition]?: Nested<P>
}
import type { TSConfig } from 'pkg-types'
import type { Conditions, ExtendableConditions } from './conditions'
import type { BambooHooks } from './hooks'
import type { PatternConfig } from './pattern'
import type { Keys, LiteralUnion, PathIn, RequiredBy } from './shared'
import type { StaticCssOptions } from './static-css'
import type {
ExtendableGlobalFontface,
ExtendableGlobalStyleObject,
GlobalFontface,
GlobalStyleObject,
SystemStyleObject,
} from './system-types'
import type { ExtendableTheme, Theme } from './theme'
import type { ExtendableUtilityConfig, UtilityConfig } from './utility'
export type { TSConfig }
export type CascadeLayer = 'reset' | 'base' | 'tokens' | 'recipes' | 'utilities'
export type CascadeLayers = Record<CascadeLayer, string>
export interface StudioOptions {
/**
* Used to customize the design system studio
* @default { title: 'Bamboo', logo: '🎋' }
*/
studio?: {
/**
* The output directory for the design system studio when the build command is run.
*/
outdir?: string
/**
* The logo url for the design system studio.
*/
logo?: string
/**
* Used to inject custom html into the head or body of the studio
*/
inject?: {
head?: string
body?: string
}
}
}
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
/**
* The global custom position try fallback option
*/
globalPositionTry?: GlobalPositionTry
/**
* 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<string, PatternConfig>
/**
* 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 CssPropertySyntax =
| '*'
| '<length>'
| '<number>'
| '<percentage>'
| '<length-percentage>'
| '<color>'
| '<image>'
| '<url>'
| '<integer>'
| '<angle>'
| '<time>'
| '<resolution>'
| '<transform-function>'
| '<length> | <percentage>'
export interface CssPropertyDefinition {
/**
* Controls whether the custom property registration specified by @property inherits by default.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/inherits
*/
inherits: boolean
/**
* Sets the initial value for the property.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/initial-value
*/
initialValue?: string
/**
* Describes the allowable syntax for the property.
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@property/syntax
*/
syntax: LiteralUnion<CssPropertySyntax>
}
export interface GlobalVarsDefinition {
[key: string]: string | CssPropertyDefinition
}
interface ExtendableGlobalVars {
[key: string]: string | CssPropertyDefinition | GlobalVarsDefinition | undefined
extend?: GlobalVarsDefinition
}
export interface GlobalPositionTry {
[key: string]: SystemStyleObject
}
interface ExtendableGlobalPositionTry {
[key: string]: SystemStyleObject | GlobalPositionTry | undefined
extend?: GlobalPositionTry | undefined
}
export interface ThemeVariant extends Pick<Theme, 'tokens' | 'semanticTokens'> {}
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
*/
globalPositionTry?: ExtendableGlobalPositionTry
/**
* 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[]
recipes?: string | string[]
patterns?: string | string[]
jsx?: string | string[]
tokens?: string | string[]
}
export interface ImportMapOutput<T = string> {
css: T[]
recipe: T[]
pattern: T[]
jsx: T[]
tokens: T[]
}
type ImportMapOption = string | ImportMapInput
interface FileSystemOptions {
/**
* Whether to clean the output directory before generating the css.
* @default false
*/
clean?: boolean
/**
* 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',
* }
* ```
*/
importMap?: ImportMapOption | Array<ImportMapOption>
/**
* 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[]
/**
* Whether to watch for changes and regenerate the css.
* @default false
*/
watch?: boolean
/**
* Whether to use polling instead of filesystem events when watching.
* @default false
*/
poll?: boolean
/**
* 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' | 'qwik'
interface JsxOptions {
/**
* The framework to use for generating supercharged elements.
*/
jsxFramework?: JsxFramework | (string & {})
/**
* The factory name of the element
* @default 'styled'
*
* @example
* ```jsx
* <styled.button marginTop="40px">Click me</styled.button>
* ```
*/
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 is allowed.
* - When set to 'none', no style props are allowed and therefore the jsxFactory will not be importable.
*
* @default 'all'
*
* @example with 'all':
* ```jsx
* <styled.button marginTop="40px">Click me</styled.button>
* ```
*
* @example with 'minimal':
* ```jsx
* <styled.button css={{ marginTop: "40px" }}>Click me</styled.button>
* ```
*
* @example with 'none':
* ```jsx
* <button className={css({ marginTop: "40px" })}>Click me</button>
* ```
*/
jsxStyleProps?: 'all' | 'minimal' | 'none'
}
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?: '_' | '=' | '-'
/**
* Whether to minify the generated css.
* @default false
*/
minify?: boolean
/**
* The root selector for the css variables.
* @default ':where(:host, :root)'
*/
cssVarRoot?: string
/**
* The css syntax kind to use
* @default 'object-literal'
*/
syntax?: 'template-literal' | 'object-literal'
/**
* Whether to use `lightningcss` instead of `postcss` for css optimization.
* @default false
*/
lightningcss?: boolean
/**
* Browserslist query to target specific browsers.
* @see https://www.npmjs.com/package/browserslist
*/
browserslist?: string[]
/**
* Layer mappings used in the generated css.
* @default 'true'
*/
layers?: Partial<CascadeLayers>
/**
* Polyfill CSS @layers at-rules for older browsers.
* @default 'false'
* @see https://www.npmjs.com/package/@csstools/postcss-cascade-layers
*/
polyfill?: boolean
}
interface CodegenOptions {
/**
* Whether to only emit the `tokens` directory
* @default false
*/
emitTokensOnly?: boolean
/**
* Whether to hash the generated class names / css variables.
* This is useful if want to shorten the class names or css variables.
* @default false
*/
hash?: boolean | { cssVar: boolean; className: boolean }
/**
* Change generated typescript definitions to be more strict for property 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
/**
* Whether to update the .gitignore file.
* @default 'true'
*/
gitignore?: boolean
/**
* Whether to allow shorthand properties
* @default 'true'
*/
shorthands?: boolean
/**
* File extension for generated javascript files.
* @default 'mjs'
*/
outExtension?: 'mjs' | 'js'
/**
* Whether to force consistent type extensions for generated typescript .d.ts files.
* If set to `true` and `outExtension` is set to `mjs`, the generated typescript .d.ts files will have the extension `.d.mts`.
* @default false
*/
forceConsistentTypeExtension?: boolean
/**
* Controls how CSS utility classes are generated.
* - `'atomic'` (default): one class per property (e.g. `c_red p_8px`)
* - `'grouped'`: one class per `css()` call, grouping all properties together
*
* Grouped mode reduces the number of classes in the HTML at the cost of potential CSS duplication.
* @default 'atomic'
*/
cssMode?: 'atomic' | 'grouped'
}
interface PresetOptions {
/**
* Used to create reusable config presets for your project or team.
*/
presets?: (string | Preset | Promise<Preset>)[]
}
export interface HooksOptions {
hooks?: Partial<BambooHooks>
}
export interface BambooPlugin extends HooksOptions {
name: string
}
export interface PluginsOptions {
plugins?: BambooPlugin[]
}
export interface Config
extends
StudioOptions,
ExtendableOptions,
CssgenOptions,
CodegenOptions,
FileSystemOptions,
JsxOptions,
PresetOptions,
HooksOptions,
PluginsOptions {
/**
* Whether to opt-out of the defaults config presets: [`@bamboocss/preset-base`, `@bamboocss/preset-bamboo`]
* @default 'false'
*/
eject?: boolean
/**
* 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 {
name: string
}
export interface UserConfig
extends Partial<PresetCore>, RequiredBy<Omit<Config, keyof PresetCore>, '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<BambooHooks>
}
export interface HashOptions {
tokens: boolean | undefined
className: boolean | undefined
}
export interface PrefixOptions {
tokens: string | undefined
className: string | undefined
}
type ReqConf = Required<UserConfig>
export type ConfigPath = Exclude<
| Exclude<NonNullable<Keys<ReqConf>>, 'theme'>
| PathIn<ReqConf, 'theme'>
| PathIn<ReqConf, 'patterns'>
| PathIn<ReqConf, 'staticCss'>
| (string & {}),
undefined
>

Sorry, the diff of this file is too big to display

import type { UserConfig } from './config'
import type { RecipeDefinition, RecipeVariantRecord, SlotRecipeDefinition, SlotRecipeVariantRecord } from './recipe'
import type { AtomicStyleResult, GroupedResult, RecipeBaseResult } from './style-rules'
import type { SystemStyleObject } from './system-types'
export interface BaseRule {
getClassNames: () => string[]
toCss: () => string
}
export interface AtomicRule extends BaseRule {
styles: SystemStyleObject
}
export interface GroupedRule extends BaseRule {
styles: SystemStyleObject
}
export interface AtomicRecipeRule extends BaseRule {
config: RecipeDefinition<any> | SlotRecipeDefinition<string, any>
}
export interface RecipeVariantsRule extends BaseRule {
variants: RecipeVariantRecord
}
export interface ProcessorInterface {
css(styles: SystemStyleObject): AtomicRule
grouped(styles: SystemStyleObject): GroupedRule
cva(recipeConfig: RecipeDefinition<RecipeVariantRecord>): AtomicRecipeRule
sva(recipeConfig: SlotRecipeDefinition<string, SlotRecipeVariantRecord<string>>): AtomicRecipeRule
recipe(name: string, variants?: RecipeVariantRecord): RecipeVariantsRule | undefined
}
export interface HooksApiInterface {
/**
* The resolved config (after all the presets are loaded and merged)
*/
config: UserConfig
/**
* The path to the config file
*/
configPath: string
/**
* The list of all the config dependencies (direct/transitive imports) filepaths
*/
configDependencies: string[]
//
/**
* The processor can be used to generate atomic or recipe classes
*/
processor: ProcessorInterface
/**
* Map that contains all the utility classNames
*/
classNames: Map<string, string>
/**
* Map that contains all the classNames found (and therefore generated) in the app code
*/
generatedClassNames: Map<string, AtomicStyleResult | RecipeBaseResult | GroupedResult>
}
import type { Artifact, ArtifactId, DiffConfigResult } from './artifact'
import type { LoadConfigResult, UserConfig } from './config'
import type { HooksApiInterface } from './hooks-api'
import type { LoggerInterface } from './logger'
import type { ParserResultInterface, ResultItem } from './parser'
export interface BambooHooks {
/**
* Called when the config is resolved, after all the presets are loaded and merged.
* This is the first hook called, you can use it to tweak the config before the context is created.
*/
'config:resolved': (args: ConfigResolvedHookArgs) => MaybeAsyncReturn<void | ConfigResolvedHookArgs['config']>
/**
* Called when each preset is resolved, allowing modification of individual presets.
* This hook is called for each preset during the resolution process, before they are merged together.
*/
'preset:resolved': (args: PresetResolvedHookArgs) => MaybeAsyncReturn<void | PresetResolvedHookArgs['preset']>
/**
* Called when the token engine has been created
*/
'tokens:created': (args: TokenCreatedHookArgs) => MaybeAsyncReturn
/**
* Called when the classname engine has been created
*/
'utility:created': (args: UtilityCreatedHookArgs) => MaybeAsyncReturn
/**
* Called when the Bamboo context has been created and the API is ready to be used.
*/
'context:created': (args: ContextCreatedHookArgs) => void
/**
* Called when the config file or one of its dependencies (imports) has changed.
*/
'config:change': (args: ConfigChangeHookArgs) => MaybeAsyncReturn
/**
* Called after reading the file content but before parsing it.
* You can use this hook to transform the file content to a tsx-friendly syntax so that Bamboo's parser can parse it.
* 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.
*/
'parser:before': (args: ParserResultBeforeHookArgs) => string | void
/**
* @private USE IT ONLY IF YOU KNOW WHAT YOU ARE DOING
*/
'parser:preprocess': JsxFactoryResultTransform['transform']
/**
* Called after the file styles are extracted and processed into the resulting ParserResult object.
* You can also use this hook to add your own extraction results from your custom parser to the ParserResult object.
*/
'parser:after': (args: ParserResultAfterHookArgs) => void
/**
* Called right before writing the codegen files to disk.
* You can use this hook to tweak the codegen files before they are written to disk.
*/
'codegen:prepare': (args: CodegenPrepareHookArgs) => MaybeAsyncReturn<void | Artifact[]>
/**
* Called after the codegen is completed
*/
'codegen:done': (args: CodegenDoneHookArgs) => MaybeAsyncReturn
/**
* Called right before adding the design-system CSS (global, static, preflight, tokens, keyframes) to the final CSS
* Called right before writing/injecting the final CSS (styles.css) that contains the design-system CSS and the parser CSS
* You can use it to tweak the CSS content before it's written to disk or injected through the postcss plugin.
*/
'cssgen:done': (args: CssgenDoneHookArgs) => string | void
/**
* Called when CSS needs to be optimized. Use this hook to replace the default PostCSS-based optimizer
* with a custom one (e.g. LightningCSS).
* Return the optimized CSS string, or void to fall through to the default PostCSS optimizer.
*/
'css:optimize': (args: CssOptimizeHookArgs) => string | void
}
type MaybeAsyncReturn<T = void> = Promise<T> | T
/* -----------------------------------------------------------------------------
* Token hooks
* -----------------------------------------------------------------------------*/
interface TokenCssVarOptions {
fallback?: string
prefix?: string
hash?: boolean
}
interface TokenCssVar {
var: `--${string}`
ref: string
}
export interface TokenConfigureOptions {
formatTokenName?: (path: string[]) => string
formatCssVar?: (path: string[], options: TokenCssVarOptions) => TokenCssVar
}
export interface TokenCreatedHookArgs {
configure(opts: TokenConfigureOptions): void
}
/* -----------------------------------------------------------------------------
* Utility hooks
* -----------------------------------------------------------------------------*/
export interface UtilityConfigureOptions {
toHash?(path: string[], toHash: (str: string) => string): string
}
export interface UtilityCreatedHookArgs {
configure(opts: UtilityConfigureOptions): void
}
/* -----------------------------------------------------------------------------
* Config hooks
* -----------------------------------------------------------------------------*/
interface CallbackItem {
value: any
path: string
depth: number
parent: any[] | Record<string, unknown>
key: string
}
type CallbackFn = (args: CallbackItem) => void
interface TraverseOptions {
separator: string
maxDepth?: number | undefined
}
interface TraverseFn {
(obj: any, callback: CallbackFn, options?: TraverseOptions): void
}
interface ConfigResolvedHookUtils {
omit: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) => Omit<T, K>
pick: <T, K extends keyof T | (string & {})>(obj: T, paths: K[]) => Partial<T>
traverse: TraverseFn
}
export interface ConfigResolvedHookArgs {
config: LoadConfigResult['config']
path: string
dependencies: string[]
utils: ConfigResolvedHookUtils
original?: LoadConfigResult['config']
}
export interface ConfigChangeHookArgs {
config: UserConfig
changes: DiffConfigResult
}
export interface PresetResolvedHookArgs {
preset: LoadConfigResult['config']
name: string
utils: ConfigResolvedHookUtils
original?: LoadConfigResult['config']
}
/* -----------------------------------------------------------------------------
* Parser hooks
* -----------------------------------------------------------------------------*/
export interface ParserResultConfigureOptions {
matchTag?: (tag: string, isBambooComponent: boolean) => boolean
matchTagMode?: 'extend' | 'override'
matchTagProp?: (tag: string, prop: string) => boolean
}
export interface ParserResultBeforeHookArgs {
filePath: string
content: string
configure: (opts: ParserResultConfigureOptions) => void
original?: string
}
export interface JsxFactoryResultTransform {
transform: (result: { type: 'jsx-factory'; data: ResultItem['data'] }) => ResultItem['data']
}
export interface ParserResultAfterHookArgs {
filePath: string
result: ParserResultInterface | undefined
}
/* -----------------------------------------------------------------------------
* Codegen hooks
* -----------------------------------------------------------------------------*/
export interface CodegenPrepareHookArgs {
artifacts: Artifact[]
/**
* The original state of the artifacts, as it was generated by Bamboo, without any modification from other preset hooks
*/
original?: Artifact[]
changed: ArtifactId[] | undefined
}
export interface CodegenDoneHookArgs {
changed: ArtifactId[] | undefined
}
/* -----------------------------------------------------------------------------
* Cssgen hooks
* -----------------------------------------------------------------------------*/
type CssgenArtifact = 'global' | 'static' | 'reset' | 'tokens' | 'keyframes' | 'styles.css'
export interface CssgenDoneHookArgs {
artifact: CssgenArtifact
/**
* The current state of the CSS, if any other preset hook has modified the CSS, this will be the modified state
*/
content: string
/**
* The original state of the CSS, as it was generated by Bamboo, without any modification from other preset hooks
*/
original?: string
}
/* -----------------------------------------------------------------------------
* CSS optimize hooks
* -----------------------------------------------------------------------------*/
export interface CssOptimizeHookArgs {
css: string
minify?: boolean
browserslist?: string[]
original?: string
}
/* -----------------------------------------------------------------------------
* Context hooks
* -----------------------------------------------------------------------------*/
export interface ContextCreatedHookArgs {
ctx: HooksApiInterface
logger: LoggerInterface
}
export type * from './artifact'
export type * from './composition'
export type * from './conditions'
export type * from './config'
export type * from './hooks'
export type * from './hooks-api'
export type * from './logger'
export type * from './parser'
export type * from './parts'
export type * from './pattern'
export type * from './recipe'
export type * from './reporter'
export type * from './runtime'
export type * from './shared'
export type * from './spec'
export type * from './static-css'
export type * from './style-rules'
export type * from './system-types'
export type * from './theme'
export type * from './tokens'
export type * from './utility'
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'
export interface LogEntry {
level: LogLevel | null
msg: string
[key: string]: any
}
export interface LoggerInterface {
level: 'debug' | 'info' | 'warn' | 'error' | 'silent'
print(data: any): void
onLog?: (entry: LogEntry) => void
warn: (type: string, data: any) => void
info: (type: string, data: any) => void
debug: (type: string, data: any) => void
error: (type: string, data: any) => void
/**
* Log a caught error with context. Extracts the message for the error level,
* and logs the full stack at debug level.
*/
caughtError: (type: string, context: string, error: unknown) => void
log: (data: string) => void
time: {
info: (msg: string) => (_msg?: string) => void
debug: (msg: string) => (_msg?: string) => void
}
isDebug: boolean
}
import type { BoxNodeArray, BoxNodeLiteral, BoxNodeMap, Unboxed } from '@bamboocss/extractor'
export interface ResultItem {
name?: string
data: Array<Unboxed['raw']>
type?: 'css' | 'cva' | 'sva' | 'token' | 'pattern' | 'recipe' | 'jsx-factory' | 'jsx-pattern' | 'jsx-recipe' | 'jsx'
box?: BoxNodeMap | BoxNodeLiteral | BoxNodeArray
}
export interface ParserResultInterface {
all: Array<ResultItem>
jsx: Set<ResultItem>
css: Set<ResultItem>
cva: Set<ResultItem>
sva: Set<ResultItem>
token: Set<ResultItem>
recipe: Map<string, Set<ResultItem>>
pattern: Map<string, Set<ResultItem>>
filePath: string | undefined
isEmpty: () => boolean
toArray: () => Array<ResultItem>
set: (name: 'cva' | 'css' | 'sva' | 'token', result: ResultItem) => void
setCss: (result: ResultItem) => void
setCva: (result: ResultItem) => void
setSva: (result: ResultItem) => void
setToken: (result: ResultItem) => void
setJsx: (result: ResultItem) => void
setPattern: (name: string, result: ResultItem) => void
setRecipe: (name: string, result: ResultItem) => void
}
export interface EncoderJson {
schemaVersion: string
styles: {
atomic?: string[]
recipes?: {
[name: string]: string[]
}
grouped?: {
[groupId: string]: string[]
}
}
}
export interface Part {
selector: string
}
export interface Parts {
[key: string]: Part
}
import type { CssProperty, SystemStyleObject } from './system-types'
import type { TokenCategory } from './tokens'
type Primitive = string | number | boolean | null | undefined
type LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)
export type PatternProperty =
| { type: 'property'; value: CssProperty; description?: string }
| { type: 'enum'; value: string[]; description?: string }
| { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }
| { type: 'string' | 'boolean' | 'number'; description?: string }
export interface PatternHelpers {
map: (value: any, fn: (value: string) => string | undefined) => any
isCssUnit: (value: any) => boolean
isCssVar: (value: any) => boolean
isCssFunction: (value: any) => boolean
}
export interface PatternProperties {
[key: string]: PatternProperty
}
type InferProps<T> = Record<LiteralUnion<keyof T>, any>
export type PatternDefaultValue<T> = Partial<InferProps<T>>
export type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>
export interface PatternConfig<T extends PatternProperties = PatternProperties> {
/**
* The description of the pattern. This will be used in the JSDoc comment.
*/
description?: string
/**
* The JSX element rendered by the pattern
* @default 'div'
*/
jsxElement?: string
/**
* The properties of the pattern.
*/
properties?: T
/**
* The default values of the pattern.
*/
defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>
/**
* The css object this pattern will generate.
*/
transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject
/**
* Whether the pattern is deprecated.
*/
deprecated?: boolean | string
/**
* The jsx element name this pattern will generate.
*/
jsxName?: string
/**
* The jsx elements to track for this pattern. Can be string or Regexp.
*
* @default capitalize(pattern.name)
* @example ['Button', 'Link', /Button$/]
*/
jsx?: Array<string | RegExp>
/**
* Whether to only generate types for the specified properties.
* This will disallow css properties
*/
strict?: boolean
/**
* @experimental
* Disallow certain css properties for this pattern
*/
blocklist?: LiteralUnion<CssProperty>[]
}
import type { ConditionalValue } from './conditions'
import type { CssProperties } from './system-types'
/* -----------------------------------------------------------------------------
* Shadowed export (in CLI): DO NOT REMOVE
* -----------------------------------------------------------------------------*/
export interface PropertyTypes {}
export type PropertyValue<K extends string> = K extends keyof PropertyTypes
? ConditionalValue<PropertyTypes[K]>
: K extends keyof CssProperties
? ConditionalValue<CssProperties[K]>
: never
import type { RecipeRule } from './static-css'
import type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
export type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>
export type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T
? {}
: {
[K in keyof T]?: StringToBoolean<keyof T[K]> | undefined
}
export type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string
/**
* Extract the variant as optional props from a `cva` function.
* Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.
*/
export type RecipeVariantProps<
T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,
> = Pretty<Parameters<T>[0]>
/**
* Extract the variants from a `cva` function.
*/
export type RecipeVariant<
T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,
> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>
type RecipeVariantMap<T extends RecipeVariantRecord> = {
[K in keyof T]: Array<keyof T[K]>
}
/* -----------------------------------------------------------------------------
* Recipe / Standard
* -----------------------------------------------------------------------------*/
export interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {
__type: RecipeSelection<T>
variantKeys: (keyof T)[]
variantMap: RecipeVariantMap<T>
raw: (props?: RecipeSelection<T>) => SystemStyleObject
config: RecipeConfig<T>
splitVariantProps<Props extends RecipeSelection<T>>(
props: Props,
): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]
getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>
}
type OneOrMore<T> = T | Array<T>
export type RecipeCompoundSelection<T> = {
[K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined
}
export type RecipeCompoundVariant<T> = T & {
css: SystemStyleObject
}
export interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {
/**
* The base styles of the recipe.
*/
base?: SystemStyleObject
/**
* Whether the recipe is deprecated.
*/
deprecated?: boolean | string
/**
* The multi-variant styles of the recipe.
*/
variants?: T
/**
* The default variants of the recipe.
*/
defaultVariants?: RecipeSelection<T>
/**
* The styles to apply when a combination of variants is selected.
*/
compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]
}
export type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>
interface RecipeConfigMeta {
/**
* The class name of the recipe.
*/
className: string
/**
* The description of the recipe. This will be used in the JSDoc comment.
*/
description?: string
/**
* The jsx elements to track for this recipe. Can be string or Regexp.
*
* @default capitalize(recipe.name)
* @example ['Button', 'Link', /Button$/]
*/
jsx?: Array<string | RegExp>
/**
* Variants to pre-generate, will be include in the final `config.staticCss`
*/
staticCss?: RecipeRule[]
}
export interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>
extends RecipeDefinition<T>, RecipeConfigMeta {}
/* -----------------------------------------------------------------------------
* Recipe / Slot
* -----------------------------------------------------------------------------*/
type SlotRecord<S extends string, T> = Partial<Record<S, T>>
export type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>
export type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (
props?: RecipeSelection<T>,
) => SlotRecord<S, string>
export interface SlotRecipeRuntimeFn<
S extends string,
T extends SlotRecipeVariantRecord<S>,
> extends SlotRecipeVariantFn<S, T> {
raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>
variantKeys: (keyof T)[]
variantMap: RecipeVariantMap<T>
splitVariantProps<Props extends RecipeSelection<T>>(
props: Props,
): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]
getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>
}
export type SlotRecipeCompoundVariant<S extends string, T> = T & {
css: SlotRecord<S, SystemStyleObject>
}
export interface SlotRecipeDefinition<
S extends string = string,
T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,
> {
/**
* An optional class name that can be used to target slots in the DOM.
*/
className?: string
/**
* Whether the recipe is deprecated.
*/
deprecated?: boolean | string
/**
* The parts/slots of the recipe.
*/
slots: S[] | Readonly<S[]>
/**
* The base styles of the recipe.
*/
base?: SlotRecord<S, SystemStyleObject>
/**
* The multi-variant styles of the recipe.
*/
variants?: T
/**
* The default variants of the recipe.
*/
defaultVariants?: RecipeSelection<T>
/**
* The styles to apply when a combination of variants is selected.
*/
compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]
}
export type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(
config: SlotRecipeDefinition<S, T>,
) => SlotRecipeRuntimeFn<S, T>
export type SlotRecipeConfig<
S extends string = string,
T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,
> = SlotRecipeDefinition<S, T> & RecipeConfigMeta
import type { ParserResultInterface } from './parser'
export type ReportItemType =
| 'css'
| 'cva'
| 'sva'
| 'token'
| 'pattern'
| 'recipe'
| 'jsx-factory'
| 'jsx-pattern'
| 'jsx-recipe'
| 'jsx'
type ComponentKind = 'component' | 'function'
interface PropertyLocationRange {
startPosition: number
startLineNumber: number
startColumn: number
endPosition: number
endLineNumber: number
endColumn: number
}
export interface PropertyReportItem {
index: string
componentIndex: ComponentReportItem['componentIndex']
componentName: ComponentReportItem['componentName']
reportItemKind: 'token' | 'utility'
reportItemType: ReportItemType
path: string[]
conditionName?: string | undefined
propName: string
value: string | number | boolean
tokenType?: string
isKnownValue: boolean
range: PropertyLocationRange | null
filepath: string
}
/**
* An component is either a component usage or a function usage
* @example an component name could be 'Button', 'css', 'bamboo.div', 'vstack', ...
*/
export interface ComponentReportItem extends Pick<PropertyReportItem, 'filepath'> {
componentIndex: string
componentName: string
reportItemType: ReportItemType
kind: ComponentKind
contains: Array<PropertyReportItem['index']>
value: Record<string, any>
range: PropertyLocationRange | null
debug?: boolean
}
export interface ReportDerivedMaps {
byComponentOfKind: Map<ComponentKind, Set<ComponentReportItem['componentIndex']>>
byPropertyName: Map<string, Set<PropertyReportItem['index']>>
byTokenType: Map<string, Set<PropertyReportItem['index']>>
byConditionName: Map<string, Set<PropertyReportItem['index']>>
byShorthand: Map<string, Set<PropertyReportItem['index']>>
byTokenName: Map<string, Set<PropertyReportItem['index']>>
byPropertyPath: Map<string, Set<PropertyReportItem['index']>>
fromKind: Map<ComponentKind, Set<PropertyReportItem['index']>>
byType: Map<string, Set<PropertyReportItem['index']>>
byComponentName: Map<string, Set<PropertyReportItem['index']>>
colorsUsed: Map<string, Set<PropertyReportItem['index']>>
}
interface ReportDerivedMapsJSON {
byComponentOfKind: Record<ComponentKind, Array<ComponentReportItem['componentIndex']>>
byPropertyName: Record<string, Array<PropertyReportItem['index']>>
byTokenType: Record<string, Array<PropertyReportItem['index']>>
byConditionName: Record<string, Array<PropertyReportItem['index']>>
byShorthand: Record<string, Array<PropertyReportItem['index']>>
byTokenName: Record<string, Array<PropertyReportItem['index']>>
byPropertyPath: Record<string, Array<PropertyReportItem['index']>>
fromKind: Record<ComponentKind, Array<PropertyReportItem['index']>>
byType: Record<string, Array<PropertyReportItem['index']>>
byComponentName: Record<string, Array<PropertyReportItem['index']>>
colorsUsed: Record<string, Array<PropertyReportItem['index']>>
}
export interface ReportCounts {
filesWithTokens: number
propNameUsed: number
tokenUsed: number
shorthandUsed: number
propertyPathUsed: number
typeUsed: number
componentNameUsed: number
kindUsed: number
componentOfKindUsed: number
colorsUsed: number
}
export interface MostUsedItem {
key: string
count: number
}
export interface ReportStats {
filesWithMostComponent: Record<string, number>
mostUseds: {
propNames: Array<MostUsedItem>
tokens: Array<MostUsedItem>
shorthands: Array<MostUsedItem>
categories: Array<MostUsedItem>
conditions: Array<MostUsedItem>
propertyPaths: Array<MostUsedItem>
types: Array<MostUsedItem>
componentNames: Array<MostUsedItem>
fromKinds: Array<MostUsedItem>
componentOfKinds: Array<MostUsedItem>
colors: Array<MostUsedItem>
}
}
export interface ReportDetails {
counts: ReportCounts
stats: ReportStats
}
export interface AnalysisOptions {
onResult?: (file: string, result: ParserResultInterface) => void
}
interface ReportDerivedMap {
byFilepath: Map<string, Set<PropertyReportItem['index']>>
byComponentInFilepath: Map<string, Set<ComponentReportItem['componentIndex']>>
globalMaps: ReportDerivedMaps
byFilePathMaps: Map<string, ReportDerivedMaps>
}
interface ReportDerivedMapJSON {
byFilepath: Record<string, Array<PropertyReportItem['index']>>
byComponentInFilepath: Record<string, Array<ComponentReportItem['componentIndex']>>
globalMaps: ReportDerivedMapsJSON
byFilePathMaps: Record<string, ReportDerivedMapsJSON>
}
export interface AnalysisReport {
schemaVersion: string
details: ReportDetails
propByIndex: Map<PropertyReportItem['index'], PropertyReportItem>
componentByIndex: Map<ComponentReportItem['componentIndex'], ComponentReportItem>
derived: ReportDerivedMap
}
export interface ReportSnapshotJSON extends Omit<AnalysisReport, 'propByIndex' | 'componentByIndex' | 'derived'> {
propByIndex: Record<PropertyReportItem['index'], PropertyReportItem>
componentByIndex: Record<ComponentReportItem['componentIndex'], ComponentReportItem>
derived: ReportDerivedMapJSON
}
export interface ClassifyReport {
propById: Map<string, PropertyReportItem>
componentById: Map<ComponentReportItem['componentIndex'], ComponentReportItem>
details: Pick<ReportDetails, 'counts' | 'stats'>
derived: ReportDerivedMap
}
interface Watcher {
on(event: 'add' | 'addDir' | 'change', listener: (path: string) => void): this
on(event: 'all', listener: (evt: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string) => void): this
close(): Promise<void>
}
interface InputOptions {
include: string[]
exclude?: string[]
cwd?: string
}
export type WatcherEventType = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'
export interface WatchOptions extends InputOptions {
poll?: boolean
}
interface FileSystem {
readDirSync(dir: string): string[]
existsSync(fileLike: string): boolean
glob(opts: InputOptions): string[]
readFileSync(filePath: string): string
rmDirSync(dirPath: string): void
writeFile(file: string, content: string): Promise<void>
rmFileSync(file: string): void
ensureDirSync(dirPath: string): void
writeFileSync(filePath: string, content: string): void
watch(options: WatchOptions): Watcher
}
interface Path {
join(...paths: string[]): string
dirname(path: string): string
resolve(...paths: string[]): string
extname(path: string): string
relative(from: string, to: string): string
isAbsolute(path: string): boolean
sep: string
abs(cwd: string, path: string): string
}
export interface Runtime {
fs: FileSystem
path: Path
cwd(): string
env(name: string): string | undefined
}
import type { Pseudos } from './csstype'
type AriaAttributes =
| '[aria-disabled]'
| '[aria-hidden]'
| '[aria-invalid]'
| '[aria-readonly]'
| '[aria-required]'
| '[aria-selected]'
| '[aria-checked]'
| '[aria-expanded]'
| '[aria-pressed]'
| `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`
| '[aria-invalid]'
| `[aria-sort=${'ascending' | 'descending'}]`
type DataAttributes =
| '[data-selected]'
| '[data-highlighted]'
| '[data-hover]'
| '[data-active]'
| '[data-checked]'
| '[data-disabled]'
| '[data-readonly]'
| '[data-focus]'
| '[data-focus-visible]'
| '[data-focus-visible-added]'
| '[data-invalid]'
| '[data-pressed]'
| '[data-expanded]'
| '[data-grabbed]'
| '[data-dragged]'
| '[data-orientation=horizontal]'
| '[data-orientation=vertical]'
| '[data-in-range]'
| '[data-out-of-range]'
| '[data-placeholder-shown]'
| `[data-part=${string}]`
| `[data-attr=${string}]`
| `[data-placement=${string}]`
| `[data-theme=${string}]`
| `[data-size=${string}]`
| `[data-state=${string}]`
| '[data-empty]'
| '[data-loading]'
| '[data-loaded]'
| '[data-enter]'
| '[data-entering]'
| '[data-exited]'
| '[data-exiting]'
type AttributeSelector = `&${Pseudos | DataAttributes | AriaAttributes}`
type ParentSelector = `${DataAttributes | AriaAttributes} &`
type AtRuleType = 'media' | 'layer' | 'container' | 'supports' | 'page' | 'scope' | 'starting-style'
export type AnySelector = `${string}&` | `&${string}` | `@${AtRuleType}${string}`
export type Selectors = AttributeSelector | ParentSelector
type Primitive = string | number | boolean | null | undefined
export type LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)
export interface Recursive<T> {
[key: string]: T | Recursive<T>
}
export type Dict<T = any> = Record<string, T>
export type RequiredBy<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>
export type AnyFunction<T = any> = (...args: T[]) => any
export type Nullable<T> = T | null | undefined
export type Keys<T> = keyof NonNullable<T>
type Subtract<T extends number, D extends number> = T extends D ? 0 : T extends D | any ? Exclude<T, D> : never
/**
* Get all the (nested) paths of an object until a certain depth
* e.g. Paths<{a: {b: {c: 1}}}, '', 2> => 'a' | 'a.b' | 'a.b.c'
*/
type Paths<T, Prefix extends string = '', Depth extends number = 0> = {
[K in keyof T]: Depth extends 0
? never
: T[K] extends object
? K extends string
? `${Prefix}${K}` | Paths<T[K], `${Prefix}${K}.`, Depth extends 1 ? 0 : Subtract<Depth, 1>>
: never
: K extends string | number
? `${Prefix}${K}`
: never
}[keyof T]
export type PathIn<T, Key extends keyof T> = Key extends string ? Paths<T[Key], `${Key}.`, 1> : never
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
export type SpecType =
| 'tokens'
| 'recipes'
| 'patterns'
| 'conditions'
| 'keyframes'
| 'semantic-tokens'
| 'text-styles'
| 'layer-styles'
| 'animation-styles'
| 'color-palette'
| 'themes'
interface Examples {
functionExamples: string[]
jsxExamples: string[]
}
export interface TokenValue {
name: string
value: any
description?: string
deprecated?: boolean | string
cssVar?: string
}
export interface TokenGroupDefinition extends Examples {
type: string
values: TokenValue[]
tokenFunctionExamples: string[]
}
export interface TokenSpec {
type: 'tokens'
data: TokenGroupDefinition[]
}
export interface SemanticTokenValue {
name: string
values: Array<{ value: string; condition?: string }>
description?: string
deprecated?: boolean | string
cssVar?: string
}
export interface SemanticTokenGroupDefinition extends Examples {
type: string
values: SemanticTokenValue[]
tokenFunctionExamples: string[]
}
export interface SemanticTokenSpec {
type: 'semantic-tokens'
data: SemanticTokenGroupDefinition[]
}
export interface RecipeSpecDefinition extends Examples {
name: string
description?: string
variants: Record<string, string[]>
defaultVariants: Record<string, any>
}
export interface RecipeSpec {
type: 'recipes'
data: RecipeSpecDefinition[]
}
export interface PatternSpecProperty {
name: string
type: string
description?: string
required?: boolean
defaultValue?: any
}
export interface PatternSpecDefinition extends Examples {
name: string
description?: string
properties: PatternSpecProperty[]
jsx?: string
}
export interface PatternSpec {
type: 'patterns'
data: PatternSpecDefinition[]
}
export interface ConditionSpecDefinition extends Examples {
name: string
value: string
}
export interface ConditionSpec {
type: 'conditions'
data: ConditionSpecDefinition[]
}
export interface KeyframeSpecDefinition extends Examples {
name: string
}
export interface KeyframeSpec {
type: 'keyframes'
data: KeyframeSpecDefinition[]
}
export interface TextStyleSpecDefinition extends Examples {
name: string
description?: string
}
export interface TextStyleSpec {
type: 'text-styles'
data: TextStyleSpecDefinition[]
}
export interface LayerStyleSpecDefinition extends Examples {
name: string
description?: string
}
export interface LayerStyleSpec {
type: 'layer-styles'
data: LayerStyleSpecDefinition[]
}
export interface AnimationStyleSpecDefinition extends Examples {
name: string
description?: string
}
export interface AnimationStyleSpec {
type: 'animation-styles'
data: AnimationStyleSpecDefinition[]
}
export interface ColorPaletteSpec {
type: 'color-palette'
data: {
values: string[]
functionExamples: string[]
jsxExamples: string[]
}
}
export interface ThemeTokenValue {
name: string
values: Array<{ value: string; condition?: string }>
description?: string
deprecated?: boolean | string
cssVar?: string
}
export interface ThemeTokenGroupDefinition extends Examples {
type: string
values: ThemeTokenValue[]
tokenFunctionExamples: string[]
}
export interface ThemeSpecDefinition {
name: string
tokens: ThemeTokenGroupDefinition[]
semanticTokens: ThemeTokenGroupDefinition[]
}
export interface ThemesSpec {
type: 'themes'
data: ThemeSpecDefinition[]
}
export type SpecFile =
| TokenSpec
| SemanticTokenSpec
| RecipeSpec
| PatternSpec
| ConditionSpec
| KeyframeSpec
| TextStyleSpec
| LayerStyleSpec
| AnimationStyleSpec
| ColorPaletteSpec
| ThemesSpec
export interface SpecTypeMap {
tokens: TokenSpec
'semantic-tokens': SemanticTokenSpec
recipes: RecipeSpec
patterns: PatternSpec
conditions: ConditionSpec
keyframes: KeyframeSpec
'text-styles': TextStyleSpec
'layer-styles': LayerStyleSpec
'animation-styles': AnimationStyleSpec
'color-palette': ColorPaletteSpec
themes: ThemesSpec
}
interface ConditionOptions {
/**
* The conditions to generate for the rule.
* @example ['hover', 'focus']
*/
conditions?: string[]
/**
* Whether to generate responsive styles for the rule.
*/
responsive?: boolean
}
export interface CssRule extends ConditionOptions {
/**
* The css properties to generate utilities for.
* @example ['margin', 'padding']
*/
properties: {
[property: string]: Array<string | number>
}
}
interface RecipeRuleVariants {
[variant: string]: boolean | string[]
}
export type RecipeRuleObject = RecipeRuleVariants & ConditionOptions
export type RecipeRule = '*' | RecipeRuleObject
export type PatternRule = '*' | CssRule
export interface StaticCssOptions {
/**
* The css utility classes to generate.
*/
css?: CssRule[]
/**
* The css recipes to generate.
*/
recipes?:
| '*'
| {
[recipe: string]: RecipeRule[]
}
/**
* The css patterns to generate.
*/
patterns?: {
[pattern: string]: PatternRule[]
}
/**
* The CSS themes to generate
*/
themes?: string[]
}
import type { ConditionalValue } from './conditions'
import type { PropertiesFallback } from './csstype'
import type { PropertyValue } from './prop-type'
type String = string & {}
type Number = number & {}
/* -----------------------------------------------------------------------------
* Shadowed export (in CLI): DO NOT REMOVE
* -----------------------------------------------------------------------------*/
type CssProperties = PropertiesFallback<String | Number>
export type CssVarProperties = {
[key in `--${string}`]?: ConditionalValue<string | number>
}
export type SystemProperties = {
[K in keyof CssProperties]?: PropertyValue<K>
}
import type { ConditionDetails } from './conditions'
export interface StyleResultObject {
[key: string]: any
}
export interface StyleProps extends StyleResultObject {
css?: StyleResultObject
}
export interface StyleEntry {
prop: string
value: string | number | boolean
cond: string
recipe?: string
slot?: string
layer?: string
variants?: boolean
}
export interface AtomicStyleResult {
result: StyleResultObject
entry: StyleEntry
hash: string
className: string
conditions?: ConditionDetails[]
layer?: string
}
export interface GroupedResult extends Pick<AtomicStyleResult, 'result' | 'className'> {
hashSet: Set<string>
details: GroupedStyleResultDetails[]
}
export interface RecipeBaseResult extends GroupedResult {
recipe: string
slot?: string
}
export interface GroupedStyleResultDetails extends Pick<AtomicStyleResult, 'hash' | 'entry' | 'conditions'> {
result: StyleResultObject
}
import type { ConditionalValue, Nested } from './conditions'
import type { AtRule, Globals, PropertiesFallback } from './csstype'
import type { SystemProperties, CssVarProperties } from './style-props'
type String = string & {}
type Number = number & {}
export type Pretty<T> = { [K in keyof T]: T[K] } & {}
export type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never
export type DistributiveUnion<T, U> = {
[K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]
} & DistributiveOmit<U, keyof T>
export type Assign<T, U> = {
[K in keyof T]: K extends keyof U ? U[K] : T[K]
} & U
/* -----------------------------------------------------------------------------
* Native css properties
* -----------------------------------------------------------------------------*/
type CornerShapeValue = 'round' | 'square' | 'bevel' | 'scoop' | 'notch' | 'squircle' | `superellipse(${number})`
export interface ModernCssProperties {
/**
* Controls whether the entire element should be draggable instead of its contents.
*/
WebkitUserDrag?: Globals | 'auto' | 'element' | 'none'
/**
* Specifies whether an element can be used to drag the entire app window (Electron).
*/
WebkitAppRegion?: Globals | 'drag' | 'no-drag'
/**
* Sets the horizontal spacing between table borders.
*/
WebkitBorderHorizontalSpacing?: Globals | String | Number
/**
* Sets the vertical spacing between table borders.
*/
WebkitBorderVerticalSpacing?: Globals | String | Number
/**
* Controls the display of text content for security purposes (e.g., password fields).
*/
WebkitTextSecurity?: Globals | 'none' | 'circle' | 'disc' | 'square'
/**
* Specifies the shape of a box's corners within the area defined by the border-radius property.
* @experimental
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/corner-shape
*/
cornerShape?:
| Globals
| CornerShapeValue
| `${CornerShapeValue} ${CornerShapeValue}`
| `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`
| `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`
| String
}
export type CssProperty = keyof PropertiesFallback
export interface CssProperties extends PropertiesFallback<String | Number>, CssVarProperties, ModernCssProperties {}
export interface CssKeyframes {
[name: string]: {
[time: string]: CssProperties
}
}
/* -----------------------------------------------------------------------------
* Conditional css properties
* -----------------------------------------------------------------------------*/
interface GenericProperties {
[key: string]: ConditionalValue<String | Number | boolean>
}
/* -----------------------------------------------------------------------------
* Native css props
* -----------------------------------------------------------------------------*/
export type NestedCssProperties = Nested<CssProperties>
export type SystemStyleObject = Nested<(SystemProperties | GenericProperties) & CssVarProperties>
export interface GlobalStyleObject {
[selector: string]: SystemStyleObject
}
export interface ExtendableGlobalStyleObject {
[selector: string]: SystemStyleObject | undefined
extend?: GlobalStyleObject | undefined
}
/* -----------------------------------------------------------------------------
* Composition (text styles, layer styles)
* -----------------------------------------------------------------------------*/
type FilterStyleObject<P extends string> = {
[K in P]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown
}
export type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>
/* -----------------------------------------------------------------------------
* Font face
* -----------------------------------------------------------------------------*/
export type GlobalFontfaceRule = Omit<AtRule.FontFaceFallback, 'src'> & Required<Pick<AtRule.FontFaceFallback, 'src'>>
export type FontfaceRule = Omit<GlobalFontfaceRule, 'fontFamily'>
export interface GlobalFontface {
[name: string]: FontfaceRule | FontfaceRule[]
}
export interface ExtendableGlobalFontface {
[name: string]: FontfaceRule | FontfaceRule[] | GlobalFontface | undefined
extend?: GlobalFontface | undefined
}
/* -----------------------------------------------------------------------------
* Jsx style props
* -----------------------------------------------------------------------------*/
interface WithCss {
css?: SystemStyleObject | SystemStyleObject[]
}
export type JsxStyleProps = SystemStyleObject & WithCss
export interface PatchedHTMLProps {
htmlWidth?: string | number
htmlHeight?: string | number
htmlTranslate?: 'yes' | 'no' | undefined
htmlContent?: string
}
export type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'
type WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps
export type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<
WithHTMLProps<T>,
P
>
import type { AnimationStyles, LayerStyles, TextStyles } from './composition'
import type { RecipeConfig, SlotRecipeConfig } from './recipe'
import type { CssKeyframes } from './system-types'
import type { SemanticTokens, Tokens } from './tokens'
export interface ColorPaletteOptions {
/**
* Whether to enable color palette generation.
* @default true
*/
enabled?: boolean
/**
* List of color names to include in color palette generation.
* When specified, only these colors will be used for color palettes.
*/
include?: string[]
/**
* List of color names to exclude from color palette generation.
* When specified, these colors will not be used for color palettes.
*/
exclude?: string[]
}
export interface Theme {
/**
* The breakpoints for your project.
*/
breakpoints?: Record<string, string>
/**
* The css animation keyframes definitions.
*/
keyframes?: CssKeyframes
/**
* The design tokens for your project.
*/
tokens?: Tokens
/**
* The semantic design tokens for your project.
*/
semanticTokens?: SemanticTokens
/**
* The typography styles for your project.
*/
textStyles?: TextStyles
/**
* The layer styles for your project.
*/
layerStyles?: LayerStyles
/**
* The animation styles for your project.
*/
animationStyles?: AnimationStyles
/**
* Multi-variant style definitions for your project.
* Useful for defining component styles.
*/
recipes?: Record<string, RecipeConfig>
/**
* Multi-variant style definitions for component slots.
*/
slotRecipes?: Record<string, SlotRecipeConfig>
/**
* The predefined container names for your project.
*/
containerNames?: string[]
/**
* The predefined container sizes for your project.
*/
containerSizes?: Record<string, string>
/**
* The color palette configuration for your project.
*/
colorPalette?: ColorPaletteOptions
}
interface PartialTheme extends Omit<Theme, 'recipes' | 'slotRecipes'> {
/**
* Multi-variant style definitions for your project.
* Useful for defining component styles.
*/
recipes?: Record<string, Partial<RecipeConfig>>
/**
* Multi-variant style definitions for component slots.
*/
slotRecipes?: Record<string, Partial<SlotRecipeConfig>>
/**
* The color palette configuration for your project.
*/
colorPalette?: Partial<ColorPaletteOptions>
}
export interface ExtendableTheme extends Theme {
extend?: PartialTheme | undefined
}
import type { Recursive } from './shared'
export interface Token<Value = any> {
value: Value
description?: string
type?: string
deprecated?: boolean | string
extensions?: {
[key: string]: any
}
}
type RecursiveToken<C extends string, V> =
| V
| {
[K in C]: RecursiveToken<C, V>
}
export interface SemanticToken<Value = string, Condition extends string = string> extends Token<
RecursiveToken<Condition, Value>
> {}
/* -----------------------------------------------------------------------------
* Token data types
* -----------------------------------------------------------------------------*/
type BorderStyle =
| 'dashed'
| 'dotted'
| 'double'
| 'groove'
| 'hidden'
| 'inset'
| 'none'
| 'outset'
| 'ridge'
| 'solid'
export interface Border {
color: string
width: string | number
style: BorderStyle
}
export interface Shadow {
offsetX: number | string
offsetY: number | string
blur: number | string
spread: number | string
color: string
inset?: boolean
}
export interface Gradient {
type: 'linear' | 'radial'
placement: string | number
stops:
| Array<{
color: string
position: number
}>
| Array<string>
}
export interface Asset {
type: 'url' | 'svg'
value: string
}
export interface TokenDataTypes {
cursor: string
zIndex: string | number
opacity: string | number
colors: string
fonts: string | string[]
fontSizes: string
fontWeights: string | number
lineHeights: string | number
letterSpacings: string
sizes: string
shadows: Shadow | Shadow[] | string | string[]
spacing: string | number
radii: string
borders: string | Border
durations: string
easings: string | number[]
animations: string
blurs: string
gradients: string | Gradient
assets: string | Asset
borderWidths: string
aspectRatios: string
containerNames: string
}
export type Tokens = {
[key in keyof TokenDataTypes]?: Recursive<Token<TokenDataTypes[key]>>
}
export type SemanticTokens<ConditionKey extends string = string> = {
[key in keyof TokenDataTypes]?: Recursive<SemanticToken<TokenDataTypes[key], ConditionKey>>
}
export type TokenCategory = keyof TokenDataTypes
import type { LiteralUnion } from './shared'
import type { CssProperty, NestedCssProperties } from './system-types'
import type { Token, TokenCategory } from './tokens'
interface TokenFn {
(path: string): string | undefined
raw: (path: string) => Token | undefined
}
type ThemeFn = (token: (path: string) => any) => Record<string, string>
export type PropertyValues =
| LiteralUnion<TokenCategory | 'keyframes'>
| string[]
| { type: string }
| Record<string, string>
| ThemeFn
export interface ColorMixResult {
invalid: boolean
value: string
color?: string
}
export interface TransformUtils {
colorMix(value: string): ColorMixResult
}
export interface TransformArgs<T = any> {
token: TokenFn
raw: T
utils: TransformUtils
}
export type PropertyTransform = (value: any, args: TransformArgs) => NestedCssProperties | undefined
export interface PropertyConfig {
/**
* @internal
* The cascade layer to which the property belongs
*/
layer?: string
/**
* The classname this property will generate.
*/
className?: string
/**
* The css style object this property will generate.
*/
transform?: PropertyTransform
/**
* The possible values this property can have.
*/
values?: PropertyValues
/**
* The css property this utility maps to.
*/
property?: CssProperty
/**
* The shorthand of the property.
*/
shorthand?: string | string[]
/**
* The CSS semantic group this property belongs
*/
group?: CssSemanticGroup
/**
* Whether this utility is deprecated or not.
*/
deprecated?: boolean
}
export type CssSemanticGroup =
| 'Animation'
| 'Background Gradient'
| 'Background'
| 'Border Radius'
| 'Border'
| 'Color'
| 'Container'
| 'Display'
| 'Focus Ring'
| 'Effect'
| 'Flex Layout'
| 'Grid Layout'
| 'Height'
| 'Interactivity'
| 'Layout'
| 'List'
| 'Margin'
| 'Other'
| 'Padding'
| 'Position'
| 'Scroll'
| 'Shadow'
| 'System'
| 'Table'
| 'Transform'
| 'Transition'
| 'Typography'
| 'Visibility'
| 'Width'
export type UtilityConfig = {
[property in LiteralUnion<CssProperty>]?: PropertyConfig
}
type UtilityConfigWithExtend = {
[pattern in LiteralUnion<CssProperty>]?: PropertyConfig | UtilityConfig | undefined
}
export type ExtendableUtilityConfig = UtilityConfigWithExtend & {
extend?: UtilityConfig | undefined
}
+6
-6
{
"name": "@bamboocss/types",
"version": "1.11.1",
"version": "1.11.2",
"description": "The types for css bamboo",

@@ -10,3 +10,3 @@ "homepage": "https://bamboo-css.com",

"type": "git",
"url": "git+https://github.com/chakra-ui/bamboo.git",
"url": "git+https://github.com/bamboocss/bamboo.git",
"directory": "packages/types"

@@ -18,8 +18,8 @@ },

"sideEffects": false,
"main": "dist/index.d.ts",
"main": "dist/index.d.cts",
"exports": {
".": {
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"default": "./dist/index.d.ts"
"types": "./dist/index.d.cts",
"default": "./dist/index.d.cts"
},

@@ -37,3 +37,3 @@ "./package.json": "./package.json"

"ts-morph": "28.0.0",
"@bamboocss/extractor": "1.11.1"
"@bamboocss/extractor": "1.11.2"
},

@@ -40,0 +40,0 @@ "scripts": {