@bamboocss/generator 1.56.7 → 1.57.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.
- package/dist/index.cjs +85 -27
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +86 -28
- package/package.json +10 -7
package/dist/index.cjs
CHANGED
|
@@ -52,15 +52,15 @@ function generateConditions(ctx) {
|
|
|
52
52
|
export type ConditionalValue<V> =
|
|
53
53
|
| V
|
|
54
54
|
| {
|
|
55
|
-
[K in keyof Conditions]?: ConditionalValue<V>
|
|
55
|
+
[K in keyof Conditions]?: ConditionalValue<V> | undefined
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export type Nested<P> = P & {
|
|
59
|
-
[K in Selectors]?: Nested<P>
|
|
59
|
+
[K in Selectors]?: Nested<P> | undefined
|
|
60
60
|
} & {
|
|
61
|
-
[K in AnySelector]?: Nested<P>
|
|
61
|
+
[K in AnySelector]?: Nested<P> | undefined
|
|
62
62
|
} & {
|
|
63
|
-
[K in keyof Conditions]?: Nested<P>
|
|
63
|
+
[K in keyof Conditions]?: Nested<P> | undefined
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
` };
|
|
@@ -541,7 +541,7 @@ function generatePattern(ctx, filters) {
|
|
|
541
541
|
export interface ${upperName}Properties {
|
|
542
542
|
${Object.keys(properties ?? {}).map((key) => {
|
|
543
543
|
const value = properties[key];
|
|
544
|
-
return `${key}?: ${ctx.patterns.getPropertyType(value)}`;
|
|
544
|
+
return `${key}?: ${ctx.patterns.getPropertyType(value)} | undefined`;
|
|
545
545
|
}).join("\n ")}
|
|
546
546
|
}
|
|
547
547
|
|
|
@@ -1553,7 +1553,7 @@ var comments = {
|
|
|
1553
1553
|
var content$4 = "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n /**\n * The css variable reference for a token path, or `fallback` when the path names no token.\n *\n * `token('spacing.4', '4')` is `var(--spacing-4)` where that token exists and `'4'` where it\n * does not — so a pattern can accept either a token name or a raw css value without knowing\n * the theme.\n */\n token: (path: string, fallback?: string) => string | undefined\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * Which css properties this pattern accepts alongside its own `properties`.\n *\n * - `all` accepts any css property.\n * - `none` accepts only the pattern's declared `properties`.\n * - `{ except }` accepts any css property but the ones listed.\n *\n * One option because these were two — `strict: true` for \"none\" and an `@experimental`\n * `blocklist` for \"all but these\" — and the pair had an unrepresentable combination that\n * silently did nothing: the blocklist is applied only to the type that lists css\n * properties, which `strict: true` does not emit, so setting both dropped the blocklist.\n *\n * Types only. Nothing strips a blocked property at runtime — one passed anyway reaches\n * `transform` and emits css.\n *\n * @default 'all'\n */\n cssProps?: 'all' | 'none' | { except: LiteralUnion<CssProperty>[] }\n}\n";
|
|
1554
1554
|
//#endregion
|
|
1555
1555
|
//#region src/artifacts/generated/recipe.d.ts.json
|
|
1556
|
-
var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\n/**\n * What a compiled build lets you do with a recipe: call it, or split its variant props.\n *\n * Nothing else is declared, because nothing else compiles. The compiler rewrites a call into\n * the classes it selects and erases the recipe, so any other read of the binding — `raw`,\n * `variantMap`, `config`, `merge`, `getVariantProps` — would see a value that is no longer\n * there, and fails the build with `runtime-binding` or `raw-call`. Declaring them only let\n * that failure type-check.\n */\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe identity\n * is not style identity, so identical declarations share one class across recipes.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T
|
|
1556
|
+
var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\n/**\n * What a compiled build lets you do with a recipe: call it, or split its variant props.\n *\n * Nothing else is declared, because nothing else compiles. The compiler rewrites a call into\n * the classes it selects and erases the recipe, so any other read of the binding — `raw`,\n * `variantMap`, `config`, `merge`, `getVariantProps` — would see a value that is no longer\n * there, and fails the build with `runtime-binding` or `raw-call`. Declaring them only let\n * that failure type-check.\n */\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject | undefined\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe identity\n * is not style identity, so identical declarations share one class across recipes.\n */\n className?: string | undefined\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string | undefined\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | undefined\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T> | undefined\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[] | undefined\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string | undefined\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp> | undefined\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[] | undefined\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>, RecipeConfigMeta {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.recipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\n// Not `Partial<Record<S, T>>`, which under `exactOptionalPropertyTypes` takes no `undefined` for a slot.\ntype SlotRecord<S extends string, T> = { [K in S]?: T | undefined }\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\n/**\n * A slot recipe as a compiled build allows it: call it, or split its variant props. See\n * `RecipeRuntimeFn` for why nothing else is declared.\n */\nexport interface SlotRecipeRuntimeFn<\n S extends string,\n T extends SlotRecipeVariantRecord<S>,\n> extends SlotRecipeVariantFn<S, T> {\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> {\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.slotRecipes`, where it is the key it is\n * declared under. Optional for an inline `sva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe and slot\n * identity do not enter generated class names.\n */\n className?: string | undefined\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string | undefined\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * Accepted and ignored.\n *\n * Older extraction-only releases scoped a slot's variant styles with `@scope` rules anchored\n * at the slots named here. The Vite compiler returns complete atoms for every selected slot\n * and emits no `@scope`, so this has no effect on output; it is still accepted so existing\n * configs keep loading.\n *\n * @deprecated Has no effect on compiled output.\n */\n scopeRoots?: S[] | Readonly<S[]> | undefined\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject> | undefined\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | undefined\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T> | undefined\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[] | undefined\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> &\n RecipeConfigMeta & {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.slotRecipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n }\n";
|
|
1557
1557
|
//#endregion
|
|
1558
1558
|
//#region src/artifacts/generated/selectors.d.ts.json
|
|
1559
1559
|
var content$2 = "import type { Pseudos } from './csstype'\n\ntype AriaAttributes =\n | '[aria-disabled]'\n | '[aria-hidden]'\n | '[aria-invalid]'\n | '[aria-readonly]'\n | '[aria-required]'\n | '[aria-selected]'\n | '[aria-checked]'\n | '[aria-expanded]'\n | '[aria-pressed]'\n | `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`\n | '[aria-invalid]'\n | `[aria-sort=${'ascending' | 'descending'}]`\n\ntype DataAttributes =\n | '[data-selected]'\n | '[data-highlighted]'\n | '[data-hover]'\n | '[data-active]'\n | '[data-checked]'\n | '[data-disabled]'\n | '[data-readonly]'\n | '[data-focus]'\n | '[data-focus-visible]'\n | '[data-focus-visible-added]'\n | '[data-invalid]'\n | '[data-pressed]'\n | '[data-expanded]'\n | '[data-grabbed]'\n | '[data-dragged]'\n | '[data-orientation=horizontal]'\n | '[data-orientation=vertical]'\n | '[data-in-range]'\n | '[data-out-of-range]'\n | '[data-placeholder-shown]'\n | `[data-part=${string}]`\n | `[data-attr=${string}]`\n | `[data-placement=${string}]`\n | `[data-theme=${string}]`\n | `[data-size=${string}]`\n | `[data-state=${string}]`\n | '[data-empty]'\n | '[data-loading]'\n | '[data-loaded]'\n | '[data-enter]'\n | '[data-entering]'\n | '[data-exited]'\n | '[data-exiting]'\n\ntype AttributeSelector = `&${Pseudos | DataAttributes | AriaAttributes}`\ntype ParentSelector = `${DataAttributes | AriaAttributes} &`\n\ntype AtRuleType = 'media' | 'layer' | 'container' | 'supports' | 'page' | 'scope' | 'starting-style'\n\nexport type AnySelector = `${string}&` | `&${string}` | `@${AtRuleType}${string}`\nexport type Selectors = AttributeSelector | ParentSelector\n";
|
|
@@ -1562,7 +1562,7 @@ var content$2 = "import type { Pseudos } from './csstype'\n\ntype AriaAttributes
|
|
|
1562
1562
|
var content$1 = "interface ConditionOptions {\n /**\n * The conditions to generate for the rule.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n /**\n * Whether to generate responsive styles for the rule.\n */\n responsive?: boolean\n}\n\nexport interface CssRule extends ConditionOptions {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: Array<string | number>\n }\n}\n\ninterface RecipeRuleVariants {\n [variant: string]: boolean | string[]\n}\n\nexport type RecipeRuleObject = RecipeRuleVariants & ConditionOptions\nexport type RecipeRule = '*' | RecipeRuleObject\n\nexport type PatternRule = '*' | CssRule\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?:\n | '*'\n | {\n [recipe: string]: RecipeRule[]\n }\n /**\n * The css patterns to generate.\n */\n patterns?: {\n [pattern: string]: PatternRule[]\n }\n /**\n * The CSS themes to generate\n */\n themes?: string[]\n}\n";
|
|
1563
1563
|
//#endregion
|
|
1564
1564
|
//#region src/artifacts/generated/system-types.d.ts.json
|
|
1565
|
-
var content = "import type { ConditionalValue, Nested } from './conditions'\nimport type { AtRule, Globals, Properties } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\ntype CornerShapeValue = 'round' | 'square' | 'bevel' | 'scoop' | 'notch' | 'squircle' | `superellipse(${number})`\n\nexport interface ModernCssProperties {\n /**\n * Controls whether the entire element should be draggable instead of its contents.\n */\n WebkitUserDrag?: Globals | 'auto' | 'element' | 'none'\n\n /**\n * Specifies whether an element can be used to drag the entire app window (Electron).\n */\n WebkitAppRegion?: Globals | 'drag' | 'no-drag'\n\n /**\n * Sets the horizontal spacing between table borders.\n */\n WebkitBorderHorizontalSpacing?: Globals | String | Number\n\n /**\n * Sets the vertical spacing between table borders.\n */\n WebkitBorderVerticalSpacing?: Globals | String | Number\n\n /**\n * Controls the display of text content for security purposes (e.g., password fields).\n */\n WebkitTextSecurity?: Globals | 'none' | 'circle' | 'disc' | 'square'\n\n /**\n * Specifies the shape of a box's corners within the area defined by the border-radius property.\n * @experimental\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/corner-shape\n */\n cornerShape?:\n | Globals\n | CornerShapeValue\n | `${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | String\n}\n\nexport type CssProperty = keyof Properties\n\nexport interface CssProperties extends Properties<String | Number>, CssVarProperties, ModernCssProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Omit<Nested<SystemProperties & CssVarProperties>, 'base'>\n\n/**\n * The four `::view-transition-*` pseudo-elements a `viewTransition()` bag can style.\n *\n * `imagePair` is camelCase here and emitted as `::view-transition-image-pair`, matching\n * how every other property in a style object is authored.\n */\nexport interface ViewTransitionStyleObject {\n group?: SystemStyleObject\n imagePair?: SystemStyleObject\n old?: SystemStyleObject\n new?: SystemStyleObject\n}\n\nexport type ViewTransitionFn = (options: ViewTransitionStyleObject) => string\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Composition (text styles, layer styles)\n * -----------------------------------------------------------------------------*/\n\ntype FilterStyleObject<P extends string> = {\n [K in P]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>\n\n/* -----------------------------------------------------------------------------\n * Font face\n * -----------------------------------------------------------------------------*/\n\nexport type GlobalFontfaceRule = Omit<AtRule.FontFaceFallback, 'src'> & Required<Pick<AtRule.FontFaceFallback, 'src'>>\n\nexport type FontfaceRule = Omit<GlobalFontfaceRule, 'fontFamily'>\n\nexport interface GlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[]\n}\n\nexport interface ExtendableGlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[] | GlobalFontface | undefined\n extend?: GlobalFontface | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject | SystemStyleObject[]\n}\n\nexport type JsxStyleProps = SystemStyleObject & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n";
|
|
1565
|
+
var content = "import type { ConditionalValue, Nested } from './conditions'\nimport type { AtRule, Globals, Properties } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\ntype CornerShapeValue = 'round' | 'square' | 'bevel' | 'scoop' | 'notch' | 'squircle' | `superellipse(${number})`\n\nexport interface ModernCssProperties {\n /**\n * Controls whether the entire element should be draggable instead of its contents.\n */\n WebkitUserDrag?: Globals | 'auto' | 'element' | 'none' | undefined\n\n /**\n * Specifies whether an element can be used to drag the entire app window (Electron).\n */\n WebkitAppRegion?: Globals | 'drag' | 'no-drag' | undefined\n\n /**\n * Sets the horizontal spacing between table borders.\n */\n WebkitBorderHorizontalSpacing?: Globals | String | Number | undefined\n\n /**\n * Sets the vertical spacing between table borders.\n */\n WebkitBorderVerticalSpacing?: Globals | String | Number | undefined\n\n /**\n * Controls the display of text content for security purposes (e.g., password fields).\n */\n WebkitTextSecurity?: Globals | 'none' | 'circle' | 'disc' | 'square' | undefined\n\n /**\n * Specifies the shape of a box's corners within the area defined by the border-radius property.\n * @experimental\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/corner-shape\n */\n cornerShape?:\n | Globals\n | CornerShapeValue\n | `${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | String\n | undefined\n}\n\nexport type CssProperty = keyof Properties\n\nexport interface CssProperties extends Properties<String | Number>, CssVarProperties, ModernCssProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Omit<Nested<SystemProperties & CssVarProperties>, 'base'>\n\n/**\n * The four `::view-transition-*` pseudo-elements a `viewTransition()` bag can style.\n *\n * `imagePair` is camelCase here and emitted as `::view-transition-image-pair`, matching\n * how every other property in a style object is authored.\n */\nexport interface ViewTransitionStyleObject {\n group?: SystemStyleObject | undefined\n imagePair?: SystemStyleObject | undefined\n old?: SystemStyleObject | undefined\n new?: SystemStyleObject | undefined\n}\n\nexport type ViewTransitionFn = (options: ViewTransitionStyleObject) => string\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Composition (text styles, layer styles)\n * -----------------------------------------------------------------------------*/\n\ntype FilterStyleObject<P extends string> = {\n [K in P]?: (K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown) | undefined\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>\n\n/* -----------------------------------------------------------------------------\n * Font face\n * -----------------------------------------------------------------------------*/\n\nexport type GlobalFontfaceRule = Omit<AtRule.FontFaceFallback, 'src'> & Required<Pick<AtRule.FontFaceFallback, 'src'>>\n\nexport type FontfaceRule = Omit<GlobalFontfaceRule, 'fontFamily'>\n\nexport interface GlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[]\n}\n\nexport interface ExtendableGlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[] | GlobalFontface | undefined\n extend?: GlobalFontface | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject | SystemStyleObject[] | undefined\n}\n\nexport type JsxStyleProps = SystemStyleObject & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number | undefined\n htmlHeight?: string | number | undefined\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string | undefined\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n";
|
|
1566
1566
|
//#endregion
|
|
1567
1567
|
//#region src/artifacts/types/generated.ts
|
|
1568
1568
|
function getGeneratedTypes(ctx) {
|
|
@@ -1647,7 +1647,7 @@ function generatePropTypes(ctx) {
|
|
|
1647
1647
|
* A template literal distributes over a union in any placeholder, so \`\${T}\` against a
|
|
1648
1648
|
* 258-token colour palette is 258 members, and the old \`\${T}\${Important}\` was four times
|
|
1649
1649
|
* that. Between them the two modifier forms were 5N of a ~1,560-member union for \`color\`
|
|
1650
|
-
* alone, and half the cost of type-checking a \`css()\` call
|
|
1650
|
+
* alone, and half the cost of type-checking a \`css()\` call with the union narrowed. Folding
|
|
1651
1651
|
* them into one 3N tail is 14.5% off that — 7.09s against 8.29s over the same 4,000 call
|
|
1652
1652
|
* sites, with a control repeat agreeing to 3.5%.
|
|
1653
1653
|
*
|
|
@@ -1680,7 +1680,7 @@ function generatePropTypes(ctx) {
|
|
|
1680
1680
|
type FallbackValue = \`fallback(\${string})\`
|
|
1681
1681
|
|
|
1682
1682
|
/**
|
|
1683
|
-
* Only relevant when using \`
|
|
1683
|
+
* Only relevant when using \`strictPropertyValues\` in your config, which narrows the types this widens.
|
|
1684
1684
|
* - Allows you to use an escape hatch (e.g. \`[123px]\`) to use any string as a value.
|
|
1685
1685
|
* - Allows you to use a color opacity modifier (e.g. \`red/300\`) with known color values.
|
|
1686
1686
|
* - Allows you to use an important mark (e.g. \`!\` or \`!important\`) in the value.
|
|
@@ -1693,7 +1693,6 @@ function generatePropTypes(ctx) {
|
|
|
1693
1693
|
* fontSize: '[123px]', // ⚠️ will not throw even if you haven't defined 123px as a token
|
|
1694
1694
|
* })
|
|
1695
1695
|
*
|
|
1696
|
-
* @see https://bamboocss.com/docs/concepts/writing-styles#stricttokens
|
|
1697
1696
|
* @see https://bamboocss.com/docs/concepts/writing-styles#strictpropertyvalues
|
|
1698
1697
|
*/
|
|
1699
1698
|
export type WithEscapeHatch<T> =
|
|
@@ -1737,7 +1736,7 @@ function generateStyleProps(ctx) {
|
|
|
1737
1736
|
type CssVarKeys = ${[...ctx.globalVars.names.map((name) => `"--${name}"`), "`--${string}` & {}"].filter(Boolean).join(" | ")}
|
|
1738
1737
|
|
|
1739
1738
|
export type CssVarProperties = {
|
|
1740
|
-
[key in CssVarKeys]?: CssVarValue
|
|
1739
|
+
[key in CssVarKeys]?: CssVarValue | undefined
|
|
1741
1740
|
}
|
|
1742
1741
|
|
|
1743
1742
|
export interface SystemProperties {
|
|
@@ -1771,7 +1770,7 @@ function generateStyleProps(ctx) {
|
|
|
1771
1770
|
if (!filtered.length) filtered.push("string | number");
|
|
1772
1771
|
let comment = comments?.[prop] || "";
|
|
1773
1772
|
if (ctx.utility.isDeprecated(prop)) comment = comment ? comment.replace("@see", "@deprecated\n@see") : "/** @deprecated */";
|
|
1774
|
-
const line = `${key}?: ${restrict(prop, filtered.filter(Boolean).join(" | "), ctx.config)}`;
|
|
1773
|
+
const line = `${key}?: ${restrict(prop, filtered.filter(Boolean).join(" | "), ctx.config)} | undefined`;
|
|
1775
1774
|
return " " + [comment, line].filter(Boolean).join("\n");
|
|
1776
1775
|
}).join("\n")}
|
|
1777
1776
|
}
|
|
@@ -2155,10 +2154,10 @@ function generateTokenCss(ctx, sheet) {
|
|
|
2155
2154
|
const keys = Object.keys(config.theme?.variants ?? {});
|
|
2156
2155
|
themeVariants = allowed.includes("*") ? keys : keys.filter((key) => allowed.includes(key));
|
|
2157
2156
|
}
|
|
2158
|
-
const themeConds = themeVariants.map((key) => conditions.getThemeName(key));
|
|
2159
|
-
const themePrefix = ctx.conditions.getThemeName("");
|
|
2157
|
+
const themeConds = new Set(themeVariants.map((key) => conditions.getThemeName(key)));
|
|
2160
2158
|
for (const [key, values] of tokenVars.entries()) {
|
|
2161
|
-
|
|
2159
|
+
const first = key.split(":")[0];
|
|
2160
|
+
if (conditions.isThemeCondition(first) && !themeConds.has(first)) continue;
|
|
2162
2161
|
const css = stringifyVars({
|
|
2163
2162
|
values,
|
|
2164
2163
|
conditionKey: key,
|
|
@@ -2191,8 +2190,9 @@ function stringifyVars(options) {
|
|
|
2191
2190
|
for (const partial of combos) for (const alt of alts) next.push([...partial, ...alt]);
|
|
2192
2191
|
combos = next;
|
|
2193
2192
|
}
|
|
2193
|
+
const anyTheme = conditions.isThemeCondition(keys[0]) ? conditions.getThemeSelector() : void 0;
|
|
2194
2194
|
const rules = combos.map((segments) => {
|
|
2195
|
-
const rule = getDeepestRule(root, segments.map(transformSegment).filter(Boolean));
|
|
2195
|
+
const rule = getDeepestRule(root, segments.map((segment, index) => anyTheme && index > 0 ? transformThemeSegment(segment, anyTheme) : transformSegment(segment)).filter(Boolean));
|
|
2196
2196
|
if (!rule) return;
|
|
2197
2197
|
getDeepestNode(rule)?.append(css);
|
|
2198
2198
|
return (0, _bamboocss_core.expandNestedCss)(rule.toString());
|
|
@@ -2233,6 +2233,57 @@ function transformSegment(seg) {
|
|
|
2233
2233
|
return parent ? `&${parent}` : seg;
|
|
2234
2234
|
}
|
|
2235
2235
|
/**
|
|
2236
|
+
* A condition inside a theme, as the selector nested under the theme's root.
|
|
2237
|
+
*
|
|
2238
|
+
* A theme's tokens are declared on its root, `[data-bamboo-theme=pastel]`, and inherit from there.
|
|
2239
|
+
* `.dark &` was compounded onto that root, as `transformSegment` writes it, and so held only where
|
|
2240
|
+
* the theme attribute and the dark class share an element: a theme in a page that `<html
|
|
2241
|
+
* class="dark">` puts in dark mode kept its light values, and a dark panel inside the theme took
|
|
2242
|
+
* the default dark values instead of the theme's.
|
|
2243
|
+
*
|
|
2244
|
+
* So each `P &` in it meets the root wherever the two can, as `themeBoundaries` writes it. Anything
|
|
2245
|
+
* else is nested as it is written: `&:hover` on the root, `.dark > &` above it alone, and
|
|
2246
|
+
* `.dark & .panel` around it.
|
|
2247
|
+
*/
|
|
2248
|
+
function transformThemeSegment(segment, anyTheme) {
|
|
2249
|
+
if (segment.startsWith("@")) return segment;
|
|
2250
|
+
const selectors = (0, _bamboocss_core.splitSelectors)(segment);
|
|
2251
|
+
const parents = selectors.map(_bamboocss_core.nestingParent);
|
|
2252
|
+
if (parents.some((parent) => parent !== void 0 && hasPseudoElement(parent))) return transformSegment(segment);
|
|
2253
|
+
const meeting = selectors.flatMap((selector, index) => {
|
|
2254
|
+
const parent = parents[index];
|
|
2255
|
+
return parent === void 0 ? [selector] : themeBoundaries(parent, anyTheme);
|
|
2256
|
+
});
|
|
2257
|
+
return [...new Set(meeting)].join(", ");
|
|
2258
|
+
}
|
|
2259
|
+
/** Whether a selector names a pseudo-element, `::part(x)`, outside a quoted value. */
|
|
2260
|
+
const hasPseudoElement = (selector) => withoutQuotes(selector).includes("::");
|
|
2261
|
+
/** A selector without what its quoted values hold, so a `::` in one is not read as its own. */
|
|
2262
|
+
const withoutQuotes = (selector) => selector.replace(/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g, "\"\"");
|
|
2263
|
+
/**
|
|
2264
|
+
* Where `P` in `P &` meets a theme's root, `&`: above it, on it, and inside it, where the theme's
|
|
2265
|
+
* values are declared on the element `P` names.
|
|
2266
|
+
*
|
|
2267
|
+
* Each is more specific than the theme's values alone and than the default `P` rule, so it wins
|
|
2268
|
+
* over both in whichever order they are written — but for the root of another theme nested in this
|
|
2269
|
+
* one. There the nested theme's own `P` values have to win, and this one's only fill in what it
|
|
2270
|
+
* leaves out, so the rule for that root is no more specific than the root's own. It wins over the
|
|
2271
|
+
* default rule by coming after it, and against a value the nested theme sets for every condition,
|
|
2272
|
+
* the order of the two themes decides.
|
|
2273
|
+
*/
|
|
2274
|
+
function themeBoundaries(parent, anyTheme) {
|
|
2275
|
+
if (parent === "*") return ["* &"];
|
|
2276
|
+
const compound = (0, _bamboocss_core.isCompound)(parent);
|
|
2277
|
+
const on = compound && /^[.[:#]/.test(parent) ? parent : `:is(${parent})`;
|
|
2278
|
+
const inside = compound ? parent : `:is(${parent})`;
|
|
2279
|
+
return [
|
|
2280
|
+
`${parent} &`,
|
|
2281
|
+
`&${on}`,
|
|
2282
|
+
`& ${inside}:not(${anyTheme})`,
|
|
2283
|
+
`& :where(${anyTheme}${on})`
|
|
2284
|
+
];
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2236
2287
|
* Build the nesting chain for one condition path.
|
|
2237
2288
|
*
|
|
2238
2289
|
* The outermost node is a `Root`, so the first segment has no enclosing rule and
|
|
@@ -2263,7 +2314,7 @@ function getDeepestRule(root, selectors) {
|
|
|
2263
2314
|
return container;
|
|
2264
2315
|
}
|
|
2265
2316
|
function withoutParentSelector(selector) {
|
|
2266
|
-
return
|
|
2317
|
+
return (0, _bamboocss_core.withoutParents)(selector).trim();
|
|
2267
2318
|
}
|
|
2268
2319
|
function getDeepestNode(node) {
|
|
2269
2320
|
if (node.nodes && node.nodes.length) return getDeepestNode(node.nodes[node.nodes.length - 1]);
|
|
@@ -2304,7 +2355,7 @@ function getThemeCss(ctx, themeName) {
|
|
|
2304
2355
|
const { tokens, conditions } = ctx;
|
|
2305
2356
|
const results = [];
|
|
2306
2357
|
const condName = conditions.getThemeName(themeName);
|
|
2307
|
-
for (const [key, values] of tokens.view.vars.entries()) if (key.startsWith(condName)) {
|
|
2358
|
+
for (const [key, values] of tokens.view.vars.entries()) if (key === condName || key.startsWith(condName + ":")) {
|
|
2308
2359
|
const css = stringifyVars({
|
|
2309
2360
|
values,
|
|
2310
2361
|
conditionKey: key,
|
|
@@ -2945,7 +2996,7 @@ function generateResetCss(ctx, sheet) {
|
|
|
2945
2996
|
const modified = (0, _bamboocss_shared.mapEntries)(scoped, (k, v) => {
|
|
2946
2997
|
const [trailingPseudo, rebuiltSelector] = (0, _bamboocss_core.extractTrailingPseudos)(k.toString());
|
|
2947
2998
|
if (trailingPseudo) {
|
|
2948
|
-
const scopeClass =
|
|
2999
|
+
const scopeClass = (0, _bamboocss_core.withoutFirstParent)(selector);
|
|
2949
3000
|
return [rebuiltSelector ? `${scopeClass} ${rebuiltSelector}${trailingPseudo}` : `${scopeClass} ${trailingPseudo}`, v];
|
|
2950
3001
|
}
|
|
2951
3002
|
return [k, { [selector]: v }];
|
|
@@ -3624,15 +3675,22 @@ var Generator = class extends _bamboocss_core.Context {
|
|
|
3624
3675
|
});
|
|
3625
3676
|
}
|
|
3626
3677
|
if (!found.size) return;
|
|
3627
|
-
const
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3678
|
+
const describe = (values, count) => {
|
|
3679
|
+
return `${count} style value(s) are raw css rather than tokens:\n\n${(0, _bamboocss_shared.truncateList)(Array.from(values, ({ prop, value }) => `- \`${prop}: ${value}\` — write \`[${value}]\` to mean it.`), {
|
|
3680
|
+
limit: 25,
|
|
3681
|
+
unit: "value",
|
|
3682
|
+
separator: "\n"
|
|
3683
|
+
})}\n\n\`strictValues\` asks every value to come from the theme, so reaching outside it is visible in the source. Write \`[value]\` to mean one literally, or add it to your tokens.`;
|
|
3684
|
+
};
|
|
3685
|
+
if (this.config.validation === "error") throw new _bamboocss_shared.BambooError("STRICT_VALUES", describe(found.values(), `${found.size}`));
|
|
3686
|
+
const fresh = [...found].filter(([id]) => !this.reportedRawValues.has(id));
|
|
3687
|
+
if (!fresh.length) return;
|
|
3688
|
+
for (const [id] of fresh) this.reportedRawValues.add(id);
|
|
3689
|
+
const count = fresh.length < found.size ? `${fresh.length} more, of ${found.size},` : `${fresh.length}`;
|
|
3690
|
+
_bamboocss_logger.logger.warn("strict-values", describe(fresh.map(([, finding]) => finding), count));
|
|
3635
3691
|
};
|
|
3692
|
+
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
3693
|
+
reportedRawValues = /* @__PURE__ */ new Set();
|
|
3636
3694
|
assertNoUnresolvedTokens = () => {
|
|
3637
3695
|
const severity = this.utility.unresolvedToken;
|
|
3638
3696
|
if (severity.token !== "error" && severity.grammar !== "error") return;
|
package/dist/index.d.cts
CHANGED
|
@@ -198,6 +198,8 @@ declare class Generator extends Context {
|
|
|
198
198
|
* and is what the type-level version of this setting could never draw.
|
|
199
199
|
*/
|
|
200
200
|
reportRawValues: () => void;
|
|
201
|
+
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
202
|
+
private reportedRawValues;
|
|
201
203
|
assertNoUnresolvedTokens: () => void;
|
|
202
204
|
/**
|
|
203
205
|
* The findings `warn` has already printed, keyed `property:value`.
|
package/dist/index.d.mts
CHANGED
|
@@ -198,6 +198,8 @@ declare class Generator extends Context {
|
|
|
198
198
|
* and is what the type-level version of this setting could never draw.
|
|
199
199
|
*/
|
|
200
200
|
reportRawValues: () => void;
|
|
201
|
+
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
202
|
+
private reportedRawValues;
|
|
201
203
|
assertNoUnresolvedTokens: () => void;
|
|
202
204
|
/**
|
|
203
205
|
* The findings `warn` has already printed, keyed `property:value`.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Context, Recipes, expandNestedCss, extractParentSelectors, extractTrailingPseudos, pruneKeyframes, prunePreflight, pruneTokenVars, prunesPreflight, stringify } from "@bamboocss/core";
|
|
1
|
+
import { Context, Recipes, expandNestedCss, extractParentSelectors, extractTrailingPseudos, isCompound, nestingParent, pruneKeyframes, prunePreflight, pruneTokenVars, prunesPreflight, splitSelectors, stringify, withoutFirstParent, withoutParents } from "@bamboocss/core";
|
|
2
2
|
import { logger } from "@bamboocss/logger";
|
|
3
3
|
import { BambooError, capitalize, compact, cssVarRefs, dashCase, isBoolean, isObject, mapEntries, truncateList, unionType, walkObject } from "@bamboocss/shared";
|
|
4
4
|
import { match } from "ts-pattern";
|
|
@@ -26,15 +26,15 @@ function generateConditions(ctx) {
|
|
|
26
26
|
export type ConditionalValue<V> =
|
|
27
27
|
| V
|
|
28
28
|
| {
|
|
29
|
-
[K in keyof Conditions]?: ConditionalValue<V>
|
|
29
|
+
[K in keyof Conditions]?: ConditionalValue<V> | undefined
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export type Nested<P> = P & {
|
|
33
|
-
[K in Selectors]?: Nested<P>
|
|
33
|
+
[K in Selectors]?: Nested<P> | undefined
|
|
34
34
|
} & {
|
|
35
|
-
[K in AnySelector]?: Nested<P>
|
|
35
|
+
[K in AnySelector]?: Nested<P> | undefined
|
|
36
36
|
} & {
|
|
37
|
-
[K in keyof Conditions]?: Nested<P>
|
|
37
|
+
[K in keyof Conditions]?: Nested<P> | undefined
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
` };
|
|
@@ -515,7 +515,7 @@ function generatePattern(ctx, filters) {
|
|
|
515
515
|
export interface ${upperName}Properties {
|
|
516
516
|
${Object.keys(properties ?? {}).map((key) => {
|
|
517
517
|
const value = properties[key];
|
|
518
|
-
return `${key}?: ${ctx.patterns.getPropertyType(value)}`;
|
|
518
|
+
return `${key}?: ${ctx.patterns.getPropertyType(value)} | undefined`;
|
|
519
519
|
}).join("\n ")}
|
|
520
520
|
}
|
|
521
521
|
|
|
@@ -1527,7 +1527,7 @@ var comments = {
|
|
|
1527
1527
|
var content$4 = "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n /**\n * The css variable reference for a token path, or `fallback` when the path names no token.\n *\n * `token('spacing.4', '4')` is `var(--spacing-4)` where that token exists and `'4'` where it\n * does not — so a pattern can accept either a token name or a raw css value without knowing\n * the theme.\n */\n token: (path: string, fallback?: string) => string | undefined\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * Which css properties this pattern accepts alongside its own `properties`.\n *\n * - `all` accepts any css property.\n * - `none` accepts only the pattern's declared `properties`.\n * - `{ except }` accepts any css property but the ones listed.\n *\n * One option because these were two — `strict: true` for \"none\" and an `@experimental`\n * `blocklist` for \"all but these\" — and the pair had an unrepresentable combination that\n * silently did nothing: the blocklist is applied only to the type that lists css\n * properties, which `strict: true` does not emit, so setting both dropped the blocklist.\n *\n * Types only. Nothing strips a blocked property at runtime — one passed anyway reaches\n * `transform` and emits css.\n *\n * @default 'all'\n */\n cssProps?: 'all' | 'none' | { except: LiteralUnion<CssProperty>[] }\n}\n";
|
|
1528
1528
|
//#endregion
|
|
1529
1529
|
//#region src/artifacts/generated/recipe.d.ts.json
|
|
1530
|
-
var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\n/**\n * What a compiled build lets you do with a recipe: call it, or split its variant props.\n *\n * Nothing else is declared, because nothing else compiles. The compiler rewrites a call into\n * the classes it selects and erases the recipe, so any other read of the binding — `raw`,\n * `variantMap`, `config`, `merge`, `getVariantProps` — would see a value that is no longer\n * there, and fails the build with `runtime-binding` or `raw-call`. Declaring them only let\n * that failure type-check.\n */\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe identity\n * is not style identity, so identical declarations share one class across recipes.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T
|
|
1530
|
+
var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\n/**\n * What a compiled build lets you do with a recipe: call it, or split its variant props.\n *\n * Nothing else is declared, because nothing else compiles. The compiler rewrites a call into\n * the classes it selects and erases the recipe, so any other read of the binding — `raw`,\n * `variantMap`, `config`, `merge`, `getVariantProps` — would see a value that is no longer\n * there, and fails the build with `runtime-binding` or `raw-call`. Declaring them only let\n * that failure type-check.\n */\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject | undefined\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe identity\n * is not style identity, so identical declarations share one class across recipes.\n */\n className?: string | undefined\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string | undefined\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | undefined\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T> | undefined\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[] | undefined\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string | undefined\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp> | undefined\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[] | undefined\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>, RecipeConfigMeta {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.recipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\n// Not `Partial<Record<S, T>>`, which under `exactOptionalPropertyTypes` takes no `undefined` for a slot.\ntype SlotRecord<S extends string, T> = { [K in S]?: T | undefined }\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\n/**\n * A slot recipe as a compiled build allows it: call it, or split its variant props. See\n * `RecipeRuntimeFn` for why nothing else is declared.\n */\nexport interface SlotRecipeRuntimeFn<\n S extends string,\n T extends SlotRecipeVariantRecord<S>,\n> extends SlotRecipeVariantFn<S, T> {\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> {\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.slotRecipes`, where it is the key it is\n * declared under. Optional for an inline `sva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe and slot\n * identity do not enter generated class names.\n */\n className?: string | undefined\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string | undefined\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * Accepted and ignored.\n *\n * Older extraction-only releases scoped a slot's variant styles with `@scope` rules anchored\n * at the slots named here. The Vite compiler returns complete atoms for every selected slot\n * and emits no `@scope`, so this has no effect on output; it is still accepted so existing\n * configs keep loading.\n *\n * @deprecated Has no effect on compiled output.\n */\n scopeRoots?: S[] | Readonly<S[]> | undefined\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject> | undefined\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T | undefined\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T> | undefined\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[] | undefined\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> &\n RecipeConfigMeta & {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.slotRecipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n }\n";
|
|
1531
1531
|
//#endregion
|
|
1532
1532
|
//#region src/artifacts/generated/selectors.d.ts.json
|
|
1533
1533
|
var content$2 = "import type { Pseudos } from './csstype'\n\ntype AriaAttributes =\n | '[aria-disabled]'\n | '[aria-hidden]'\n | '[aria-invalid]'\n | '[aria-readonly]'\n | '[aria-required]'\n | '[aria-selected]'\n | '[aria-checked]'\n | '[aria-expanded]'\n | '[aria-pressed]'\n | `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`\n | '[aria-invalid]'\n | `[aria-sort=${'ascending' | 'descending'}]`\n\ntype DataAttributes =\n | '[data-selected]'\n | '[data-highlighted]'\n | '[data-hover]'\n | '[data-active]'\n | '[data-checked]'\n | '[data-disabled]'\n | '[data-readonly]'\n | '[data-focus]'\n | '[data-focus-visible]'\n | '[data-focus-visible-added]'\n | '[data-invalid]'\n | '[data-pressed]'\n | '[data-expanded]'\n | '[data-grabbed]'\n | '[data-dragged]'\n | '[data-orientation=horizontal]'\n | '[data-orientation=vertical]'\n | '[data-in-range]'\n | '[data-out-of-range]'\n | '[data-placeholder-shown]'\n | `[data-part=${string}]`\n | `[data-attr=${string}]`\n | `[data-placement=${string}]`\n | `[data-theme=${string}]`\n | `[data-size=${string}]`\n | `[data-state=${string}]`\n | '[data-empty]'\n | '[data-loading]'\n | '[data-loaded]'\n | '[data-enter]'\n | '[data-entering]'\n | '[data-exited]'\n | '[data-exiting]'\n\ntype AttributeSelector = `&${Pseudos | DataAttributes | AriaAttributes}`\ntype ParentSelector = `${DataAttributes | AriaAttributes} &`\n\ntype AtRuleType = 'media' | 'layer' | 'container' | 'supports' | 'page' | 'scope' | 'starting-style'\n\nexport type AnySelector = `${string}&` | `&${string}` | `@${AtRuleType}${string}`\nexport type Selectors = AttributeSelector | ParentSelector\n";
|
|
@@ -1536,7 +1536,7 @@ var content$2 = "import type { Pseudos } from './csstype'\n\ntype AriaAttributes
|
|
|
1536
1536
|
var content$1 = "interface ConditionOptions {\n /**\n * The conditions to generate for the rule.\n * @example ['hover', 'focus']\n */\n conditions?: string[]\n /**\n * Whether to generate responsive styles for the rule.\n */\n responsive?: boolean\n}\n\nexport interface CssRule extends ConditionOptions {\n /**\n * The css properties to generate utilities for.\n * @example ['margin', 'padding']\n */\n properties: {\n [property: string]: Array<string | number>\n }\n}\n\ninterface RecipeRuleVariants {\n [variant: string]: boolean | string[]\n}\n\nexport type RecipeRuleObject = RecipeRuleVariants & ConditionOptions\nexport type RecipeRule = '*' | RecipeRuleObject\n\nexport type PatternRule = '*' | CssRule\n\nexport interface StaticCssOptions {\n /**\n * The css utility classes to generate.\n */\n css?: CssRule[]\n /**\n * The css recipes to generate.\n */\n recipes?:\n | '*'\n | {\n [recipe: string]: RecipeRule[]\n }\n /**\n * The css patterns to generate.\n */\n patterns?: {\n [pattern: string]: PatternRule[]\n }\n /**\n * The CSS themes to generate\n */\n themes?: string[]\n}\n";
|
|
1537
1537
|
//#endregion
|
|
1538
1538
|
//#region src/artifacts/generated/system-types.d.ts.json
|
|
1539
|
-
var content = "import type { ConditionalValue, Nested } from './conditions'\nimport type { AtRule, Globals, Properties } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\ntype CornerShapeValue = 'round' | 'square' | 'bevel' | 'scoop' | 'notch' | 'squircle' | `superellipse(${number})`\n\nexport interface ModernCssProperties {\n /**\n * Controls whether the entire element should be draggable instead of its contents.\n */\n WebkitUserDrag?: Globals | 'auto' | 'element' | 'none'\n\n /**\n * Specifies whether an element can be used to drag the entire app window (Electron).\n */\n WebkitAppRegion?: Globals | 'drag' | 'no-drag'\n\n /**\n * Sets the horizontal spacing between table borders.\n */\n WebkitBorderHorizontalSpacing?: Globals | String | Number\n\n /**\n * Sets the vertical spacing between table borders.\n */\n WebkitBorderVerticalSpacing?: Globals | String | Number\n\n /**\n * Controls the display of text content for security purposes (e.g., password fields).\n */\n WebkitTextSecurity?: Globals | 'none' | 'circle' | 'disc' | 'square'\n\n /**\n * Specifies the shape of a box's corners within the area defined by the border-radius property.\n * @experimental\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/corner-shape\n */\n cornerShape?:\n | Globals\n | CornerShapeValue\n | `${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | String\n}\n\nexport type CssProperty = keyof Properties\n\nexport interface CssProperties extends Properties<String | Number>, CssVarProperties, ModernCssProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Omit<Nested<SystemProperties & CssVarProperties>, 'base'>\n\n/**\n * The four `::view-transition-*` pseudo-elements a `viewTransition()` bag can style.\n *\n * `imagePair` is camelCase here and emitted as `::view-transition-image-pair`, matching\n * how every other property in a style object is authored.\n */\nexport interface ViewTransitionStyleObject {\n group?: SystemStyleObject\n imagePair?: SystemStyleObject\n old?: SystemStyleObject\n new?: SystemStyleObject\n}\n\nexport type ViewTransitionFn = (options: ViewTransitionStyleObject) => string\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Composition (text styles, layer styles)\n * -----------------------------------------------------------------------------*/\n\ntype FilterStyleObject<P extends string> = {\n [K in P]?: K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>\n\n/* -----------------------------------------------------------------------------\n * Font face\n * -----------------------------------------------------------------------------*/\n\nexport type GlobalFontfaceRule = Omit<AtRule.FontFaceFallback, 'src'> & Required<Pick<AtRule.FontFaceFallback, 'src'>>\n\nexport type FontfaceRule = Omit<GlobalFontfaceRule, 'fontFamily'>\n\nexport interface GlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[]\n}\n\nexport interface ExtendableGlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[] | GlobalFontface | undefined\n extend?: GlobalFontface | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject | SystemStyleObject[]\n}\n\nexport type JsxStyleProps = SystemStyleObject & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number\n htmlHeight?: string | number\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n";
|
|
1539
|
+
var content = "import type { ConditionalValue, Nested } from './conditions'\nimport type { AtRule, Globals, Properties } from './csstype'\nimport type { SystemProperties, CssVarProperties } from './style-props'\n\ntype String = string & {}\ntype Number = number & {}\n\nexport type Pretty<T> = { [K in keyof T]: T[K] } & {}\n\nexport type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never\n\nexport type DistributiveUnion<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] | T[K] : T[K]\n} & DistributiveOmit<U, keyof T>\n\nexport type Assign<T, U> = {\n [K in keyof T]: K extends keyof U ? U[K] : T[K]\n} & U\n\n/* -----------------------------------------------------------------------------\n * Native css properties\n * -----------------------------------------------------------------------------*/\n\ntype CornerShapeValue = 'round' | 'square' | 'bevel' | 'scoop' | 'notch' | 'squircle' | `superellipse(${number})`\n\nexport interface ModernCssProperties {\n /**\n * Controls whether the entire element should be draggable instead of its contents.\n */\n WebkitUserDrag?: Globals | 'auto' | 'element' | 'none' | undefined\n\n /**\n * Specifies whether an element can be used to drag the entire app window (Electron).\n */\n WebkitAppRegion?: Globals | 'drag' | 'no-drag' | undefined\n\n /**\n * Sets the horizontal spacing between table borders.\n */\n WebkitBorderHorizontalSpacing?: Globals | String | Number | undefined\n\n /**\n * Sets the vertical spacing between table borders.\n */\n WebkitBorderVerticalSpacing?: Globals | String | Number | undefined\n\n /**\n * Controls the display of text content for security purposes (e.g., password fields).\n */\n WebkitTextSecurity?: Globals | 'none' | 'circle' | 'disc' | 'square' | undefined\n\n /**\n * Specifies the shape of a box's corners within the area defined by the border-radius property.\n * @experimental\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/corner-shape\n */\n cornerShape?:\n | Globals\n | CornerShapeValue\n | `${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | `${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue} ${CornerShapeValue}`\n | String\n | undefined\n}\n\nexport type CssProperty = keyof Properties\n\nexport interface CssProperties extends Properties<String | Number>, CssVarProperties, ModernCssProperties {}\n\nexport interface CssKeyframes {\n [name: string]: {\n [time: string]: CssProperties\n }\n}\n\n/* -----------------------------------------------------------------------------\n * Conditional css properties\n * -----------------------------------------------------------------------------*/\n\ninterface GenericProperties {\n [key: string]: ConditionalValue<String | Number | boolean>\n}\n\n/* -----------------------------------------------------------------------------\n * Native css props\n * -----------------------------------------------------------------------------*/\n\nexport type NestedCssProperties = Nested<CssProperties>\n\nexport type SystemStyleObject = Omit<Nested<SystemProperties & CssVarProperties>, 'base'>\n\n/**\n * The four `::view-transition-*` pseudo-elements a `viewTransition()` bag can style.\n *\n * `imagePair` is camelCase here and emitted as `::view-transition-image-pair`, matching\n * how every other property in a style object is authored.\n */\nexport interface ViewTransitionStyleObject {\n group?: SystemStyleObject | undefined\n imagePair?: SystemStyleObject | undefined\n old?: SystemStyleObject | undefined\n new?: SystemStyleObject | undefined\n}\n\nexport type ViewTransitionFn = (options: ViewTransitionStyleObject) => string\n\nexport interface GlobalStyleObject {\n [selector: string]: SystemStyleObject\n}\nexport interface ExtendableGlobalStyleObject {\n [selector: string]: SystemStyleObject | undefined\n extend?: GlobalStyleObject | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Composition (text styles, layer styles)\n * -----------------------------------------------------------------------------*/\n\ntype FilterStyleObject<P extends string> = {\n [K in P]?: (K extends keyof SystemStyleObject ? SystemStyleObject[K] : unknown) | undefined\n}\n\nexport type CompositionStyleObject<Property extends string> = Nested<FilterStyleObject<Property> & CssVarProperties>\n\n/* -----------------------------------------------------------------------------\n * Font face\n * -----------------------------------------------------------------------------*/\n\nexport type GlobalFontfaceRule = Omit<AtRule.FontFaceFallback, 'src'> & Required<Pick<AtRule.FontFaceFallback, 'src'>>\n\nexport type FontfaceRule = Omit<GlobalFontfaceRule, 'fontFamily'>\n\nexport interface GlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[]\n}\n\nexport interface ExtendableGlobalFontface {\n [name: string]: FontfaceRule | FontfaceRule[] | GlobalFontface | undefined\n extend?: GlobalFontface | undefined\n}\n\n/* -----------------------------------------------------------------------------\n * Jsx style props\n * -----------------------------------------------------------------------------*/\ninterface WithCss {\n css?: SystemStyleObject | SystemStyleObject[] | undefined\n}\n\nexport type JsxStyleProps = SystemStyleObject & WithCss\n\nexport interface PatchedHTMLProps {\n htmlWidth?: string | number | undefined\n htmlHeight?: string | number | undefined\n htmlTranslate?: 'yes' | 'no' | undefined\n htmlContent?: string | undefined\n}\n\nexport type OmittedHTMLProps = 'color' | 'translate' | 'transition' | 'width' | 'height' | 'content'\n\ntype WithHTMLProps<T> = DistributiveOmit<T, OmittedHTMLProps> & PatchedHTMLProps\n\nexport type JsxHTMLProps<T extends Record<string, any>, P extends Record<string, any> = {}> = Assign<\n WithHTMLProps<T>,\n P\n>\n";
|
|
1540
1540
|
//#endregion
|
|
1541
1541
|
//#region src/artifacts/types/generated.ts
|
|
1542
1542
|
function getGeneratedTypes(ctx) {
|
|
@@ -1621,7 +1621,7 @@ function generatePropTypes(ctx) {
|
|
|
1621
1621
|
* A template literal distributes over a union in any placeholder, so \`\${T}\` against a
|
|
1622
1622
|
* 258-token colour palette is 258 members, and the old \`\${T}\${Important}\` was four times
|
|
1623
1623
|
* that. Between them the two modifier forms were 5N of a ~1,560-member union for \`color\`
|
|
1624
|
-
* alone, and half the cost of type-checking a \`css()\` call
|
|
1624
|
+
* alone, and half the cost of type-checking a \`css()\` call with the union narrowed. Folding
|
|
1625
1625
|
* them into one 3N tail is 14.5% off that — 7.09s against 8.29s over the same 4,000 call
|
|
1626
1626
|
* sites, with a control repeat agreeing to 3.5%.
|
|
1627
1627
|
*
|
|
@@ -1654,7 +1654,7 @@ function generatePropTypes(ctx) {
|
|
|
1654
1654
|
type FallbackValue = \`fallback(\${string})\`
|
|
1655
1655
|
|
|
1656
1656
|
/**
|
|
1657
|
-
* Only relevant when using \`
|
|
1657
|
+
* Only relevant when using \`strictPropertyValues\` in your config, which narrows the types this widens.
|
|
1658
1658
|
* - Allows you to use an escape hatch (e.g. \`[123px]\`) to use any string as a value.
|
|
1659
1659
|
* - Allows you to use a color opacity modifier (e.g. \`red/300\`) with known color values.
|
|
1660
1660
|
* - Allows you to use an important mark (e.g. \`!\` or \`!important\`) in the value.
|
|
@@ -1667,7 +1667,6 @@ function generatePropTypes(ctx) {
|
|
|
1667
1667
|
* fontSize: '[123px]', // ⚠️ will not throw even if you haven't defined 123px as a token
|
|
1668
1668
|
* })
|
|
1669
1669
|
*
|
|
1670
|
-
* @see https://bamboocss.com/docs/concepts/writing-styles#stricttokens
|
|
1671
1670
|
* @see https://bamboocss.com/docs/concepts/writing-styles#strictpropertyvalues
|
|
1672
1671
|
*/
|
|
1673
1672
|
export type WithEscapeHatch<T> =
|
|
@@ -1711,7 +1710,7 @@ function generateStyleProps(ctx) {
|
|
|
1711
1710
|
type CssVarKeys = ${[...ctx.globalVars.names.map((name) => `"--${name}"`), "`--${string}` & {}"].filter(Boolean).join(" | ")}
|
|
1712
1711
|
|
|
1713
1712
|
export type CssVarProperties = {
|
|
1714
|
-
[key in CssVarKeys]?: CssVarValue
|
|
1713
|
+
[key in CssVarKeys]?: CssVarValue | undefined
|
|
1715
1714
|
}
|
|
1716
1715
|
|
|
1717
1716
|
export interface SystemProperties {
|
|
@@ -1745,7 +1744,7 @@ function generateStyleProps(ctx) {
|
|
|
1745
1744
|
if (!filtered.length) filtered.push("string | number");
|
|
1746
1745
|
let comment = comments?.[prop] || "";
|
|
1747
1746
|
if (ctx.utility.isDeprecated(prop)) comment = comment ? comment.replace("@see", "@deprecated\n@see") : "/** @deprecated */";
|
|
1748
|
-
const line = `${key}?: ${restrict(prop, filtered.filter(Boolean).join(" | "), ctx.config)}`;
|
|
1747
|
+
const line = `${key}?: ${restrict(prop, filtered.filter(Boolean).join(" | "), ctx.config)} | undefined`;
|
|
1749
1748
|
return " " + [comment, line].filter(Boolean).join("\n");
|
|
1750
1749
|
}).join("\n")}
|
|
1751
1750
|
}
|
|
@@ -2129,10 +2128,10 @@ function generateTokenCss(ctx, sheet) {
|
|
|
2129
2128
|
const keys = Object.keys(config.theme?.variants ?? {});
|
|
2130
2129
|
themeVariants = allowed.includes("*") ? keys : keys.filter((key) => allowed.includes(key));
|
|
2131
2130
|
}
|
|
2132
|
-
const themeConds = themeVariants.map((key) => conditions.getThemeName(key));
|
|
2133
|
-
const themePrefix = ctx.conditions.getThemeName("");
|
|
2131
|
+
const themeConds = new Set(themeVariants.map((key) => conditions.getThemeName(key)));
|
|
2134
2132
|
for (const [key, values] of tokenVars.entries()) {
|
|
2135
|
-
|
|
2133
|
+
const first = key.split(":")[0];
|
|
2134
|
+
if (conditions.isThemeCondition(first) && !themeConds.has(first)) continue;
|
|
2136
2135
|
const css = stringifyVars({
|
|
2137
2136
|
values,
|
|
2138
2137
|
conditionKey: key,
|
|
@@ -2165,8 +2164,9 @@ function stringifyVars(options) {
|
|
|
2165
2164
|
for (const partial of combos) for (const alt of alts) next.push([...partial, ...alt]);
|
|
2166
2165
|
combos = next;
|
|
2167
2166
|
}
|
|
2167
|
+
const anyTheme = conditions.isThemeCondition(keys[0]) ? conditions.getThemeSelector() : void 0;
|
|
2168
2168
|
const rules = combos.map((segments) => {
|
|
2169
|
-
const rule = getDeepestRule(root, segments.map(transformSegment).filter(Boolean));
|
|
2169
|
+
const rule = getDeepestRule(root, segments.map((segment, index) => anyTheme && index > 0 ? transformThemeSegment(segment, anyTheme) : transformSegment(segment)).filter(Boolean));
|
|
2170
2170
|
if (!rule) return;
|
|
2171
2171
|
getDeepestNode(rule)?.append(css);
|
|
2172
2172
|
return expandNestedCss(rule.toString());
|
|
@@ -2207,6 +2207,57 @@ function transformSegment(seg) {
|
|
|
2207
2207
|
return parent ? `&${parent}` : seg;
|
|
2208
2208
|
}
|
|
2209
2209
|
/**
|
|
2210
|
+
* A condition inside a theme, as the selector nested under the theme's root.
|
|
2211
|
+
*
|
|
2212
|
+
* A theme's tokens are declared on its root, `[data-bamboo-theme=pastel]`, and inherit from there.
|
|
2213
|
+
* `.dark &` was compounded onto that root, as `transformSegment` writes it, and so held only where
|
|
2214
|
+
* the theme attribute and the dark class share an element: a theme in a page that `<html
|
|
2215
|
+
* class="dark">` puts in dark mode kept its light values, and a dark panel inside the theme took
|
|
2216
|
+
* the default dark values instead of the theme's.
|
|
2217
|
+
*
|
|
2218
|
+
* So each `P &` in it meets the root wherever the two can, as `themeBoundaries` writes it. Anything
|
|
2219
|
+
* else is nested as it is written: `&:hover` on the root, `.dark > &` above it alone, and
|
|
2220
|
+
* `.dark & .panel` around it.
|
|
2221
|
+
*/
|
|
2222
|
+
function transformThemeSegment(segment, anyTheme) {
|
|
2223
|
+
if (segment.startsWith("@")) return segment;
|
|
2224
|
+
const selectors = splitSelectors(segment);
|
|
2225
|
+
const parents = selectors.map(nestingParent);
|
|
2226
|
+
if (parents.some((parent) => parent !== void 0 && hasPseudoElement(parent))) return transformSegment(segment);
|
|
2227
|
+
const meeting = selectors.flatMap((selector, index) => {
|
|
2228
|
+
const parent = parents[index];
|
|
2229
|
+
return parent === void 0 ? [selector] : themeBoundaries(parent, anyTheme);
|
|
2230
|
+
});
|
|
2231
|
+
return [...new Set(meeting)].join(", ");
|
|
2232
|
+
}
|
|
2233
|
+
/** Whether a selector names a pseudo-element, `::part(x)`, outside a quoted value. */
|
|
2234
|
+
const hasPseudoElement = (selector) => withoutQuotes(selector).includes("::");
|
|
2235
|
+
/** A selector without what its quoted values hold, so a `::` in one is not read as its own. */
|
|
2236
|
+
const withoutQuotes = (selector) => selector.replace(/"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'/g, "\"\"");
|
|
2237
|
+
/**
|
|
2238
|
+
* Where `P` in `P &` meets a theme's root, `&`: above it, on it, and inside it, where the theme's
|
|
2239
|
+
* values are declared on the element `P` names.
|
|
2240
|
+
*
|
|
2241
|
+
* Each is more specific than the theme's values alone and than the default `P` rule, so it wins
|
|
2242
|
+
* over both in whichever order they are written — but for the root of another theme nested in this
|
|
2243
|
+
* one. There the nested theme's own `P` values have to win, and this one's only fill in what it
|
|
2244
|
+
* leaves out, so the rule for that root is no more specific than the root's own. It wins over the
|
|
2245
|
+
* default rule by coming after it, and against a value the nested theme sets for every condition,
|
|
2246
|
+
* the order of the two themes decides.
|
|
2247
|
+
*/
|
|
2248
|
+
function themeBoundaries(parent, anyTheme) {
|
|
2249
|
+
if (parent === "*") return ["* &"];
|
|
2250
|
+
const compound = isCompound(parent);
|
|
2251
|
+
const on = compound && /^[.[:#]/.test(parent) ? parent : `:is(${parent})`;
|
|
2252
|
+
const inside = compound ? parent : `:is(${parent})`;
|
|
2253
|
+
return [
|
|
2254
|
+
`${parent} &`,
|
|
2255
|
+
`&${on}`,
|
|
2256
|
+
`& ${inside}:not(${anyTheme})`,
|
|
2257
|
+
`& :where(${anyTheme}${on})`
|
|
2258
|
+
];
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2210
2261
|
* Build the nesting chain for one condition path.
|
|
2211
2262
|
*
|
|
2212
2263
|
* The outermost node is a `Root`, so the first segment has no enclosing rule and
|
|
@@ -2237,7 +2288,7 @@ function getDeepestRule(root, selectors) {
|
|
|
2237
2288
|
return container;
|
|
2238
2289
|
}
|
|
2239
2290
|
function withoutParentSelector(selector) {
|
|
2240
|
-
return selector
|
|
2291
|
+
return withoutParents(selector).trim();
|
|
2241
2292
|
}
|
|
2242
2293
|
function getDeepestNode(node) {
|
|
2243
2294
|
if (node.nodes && node.nodes.length) return getDeepestNode(node.nodes[node.nodes.length - 1]);
|
|
@@ -2278,7 +2329,7 @@ function getThemeCss(ctx, themeName) {
|
|
|
2278
2329
|
const { tokens, conditions } = ctx;
|
|
2279
2330
|
const results = [];
|
|
2280
2331
|
const condName = conditions.getThemeName(themeName);
|
|
2281
|
-
for (const [key, values] of tokens.view.vars.entries()) if (key.startsWith(condName)) {
|
|
2332
|
+
for (const [key, values] of tokens.view.vars.entries()) if (key === condName || key.startsWith(condName + ":")) {
|
|
2282
2333
|
const css = stringifyVars({
|
|
2283
2334
|
values,
|
|
2284
2335
|
conditionKey: key,
|
|
@@ -2919,7 +2970,7 @@ function generateResetCss(ctx, sheet) {
|
|
|
2919
2970
|
const modified = mapEntries(scoped, (k, v) => {
|
|
2920
2971
|
const [trailingPseudo, rebuiltSelector] = extractTrailingPseudos(k.toString());
|
|
2921
2972
|
if (trailingPseudo) {
|
|
2922
|
-
const scopeClass = selector
|
|
2973
|
+
const scopeClass = withoutFirstParent(selector);
|
|
2923
2974
|
return [rebuiltSelector ? `${scopeClass} ${rebuiltSelector}${trailingPseudo}` : `${scopeClass} ${trailingPseudo}`, v];
|
|
2924
2975
|
}
|
|
2925
2976
|
return [k, { [selector]: v }];
|
|
@@ -3598,15 +3649,22 @@ var Generator = class extends Context {
|
|
|
3598
3649
|
});
|
|
3599
3650
|
}
|
|
3600
3651
|
if (!found.size) return;
|
|
3601
|
-
const
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3652
|
+
const describe = (values, count) => {
|
|
3653
|
+
return `${count} style value(s) are raw css rather than tokens:\n\n${truncateList(Array.from(values, ({ prop, value }) => `- \`${prop}: ${value}\` — write \`[${value}]\` to mean it.`), {
|
|
3654
|
+
limit: 25,
|
|
3655
|
+
unit: "value",
|
|
3656
|
+
separator: "\n"
|
|
3657
|
+
})}\n\n\`strictValues\` asks every value to come from the theme, so reaching outside it is visible in the source. Write \`[value]\` to mean one literally, or add it to your tokens.`;
|
|
3658
|
+
};
|
|
3659
|
+
if (this.config.validation === "error") throw new BambooError("STRICT_VALUES", describe(found.values(), `${found.size}`));
|
|
3660
|
+
const fresh = [...found].filter(([id]) => !this.reportedRawValues.has(id));
|
|
3661
|
+
if (!fresh.length) return;
|
|
3662
|
+
for (const [id] of fresh) this.reportedRawValues.add(id);
|
|
3663
|
+
const count = fresh.length < found.size ? `${fresh.length} more, of ${found.size},` : `${fresh.length}`;
|
|
3664
|
+
logger.warn("strict-values", describe(fresh.map(([, finding]) => finding), count));
|
|
3609
3665
|
};
|
|
3666
|
+
/** The raw values `warn` has already reported, keyed `property:value`, for the life of the context. */
|
|
3667
|
+
reportedRawValues = /* @__PURE__ */ new Set();
|
|
3610
3668
|
assertNoUnresolvedTokens = () => {
|
|
3611
3669
|
const severity = this.utility.unresolvedToken;
|
|
3612
3670
|
if (severity.token !== "error" && severity.grammar !== "error") return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"description": "The css generator for css bamboo",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,16 +38,19 @@
|
|
|
38
38
|
"pluralize": "8.0.0",
|
|
39
39
|
"postcss": "8.5.26",
|
|
40
40
|
"ts-pattern": "5.9.0",
|
|
41
|
-
"@bamboocss/core": "1.
|
|
42
|
-
"@bamboocss/is-valid-prop": "^1.
|
|
43
|
-
"@bamboocss/logger": "1.
|
|
44
|
-
"@bamboocss/shared": "1.
|
|
45
|
-
"@bamboocss/token-dictionary": "1.
|
|
46
|
-
"@bamboocss/types": "1.
|
|
41
|
+
"@bamboocss/core": "1.57.0",
|
|
42
|
+
"@bamboocss/is-valid-prop": "^1.57.0",
|
|
43
|
+
"@bamboocss/logger": "1.57.0",
|
|
44
|
+
"@bamboocss/shared": "1.57.0",
|
|
45
|
+
"@bamboocss/token-dictionary": "1.57.0",
|
|
46
|
+
"@bamboocss/types": "1.57.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pluralize": "0.0.33"
|
|
50
50
|
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=22.12.0"
|
|
53
|
+
},
|
|
51
54
|
"scripts": {
|
|
52
55
|
"build": "tsdown src/index.ts --format=esm,cjs --dts",
|
|
53
56
|
"build-fast": "tsdown --dts=false src/index.ts --format=esm,cjs",
|