import { StyleRule } from '@vanilla-extract/css'; import { Properties, Property, NonNullableString } from '@mincho-js/csstype'; import { CamelPseudos, SpacePropertiesKey, CommaPropertiesKey, NestedPropertiesMap } from '@mincho-js/css-additional-types'; import { GlobalFontFaceRule } from './fontface-rule.cjs' import { IntRange, Spread } from './utils.cjs' export type VanillaStyleRuleKey = keyof StyleRule; export type VanillaStyleRuleValue = StyleRule[VanillaStyleRuleKey]; export type VanillaStyleArray = Array; export type VanillaClassNames = ClassNames; export type ComplexCSSRule = CSSRule | Array; export type ComplexCSSItem = CSSRule | ClassNames | ((...args: any[]) => ClassNames | CSSRule); export interface CSSRule extends CSSPropertiesWithConditions, SelectorProperty { } export interface GlobalCSSRule extends CSSPropertiesWithConditions { } export type CSSRuleKey = keyof CSSRule; export type CSSRuleValue = CSSRule[CSSRuleKey]; export type ClassNames = string | Array; export interface CSSPropertiesWithConditions extends CSSPropertiesWithVars, WithConditions { } export interface CSSPropertiesWithVars extends CSSComplexProperties, VarProperty, TopLevelVar { } export interface CSSComplexProperties extends CSSProperties, CSSMergeProperties { } export type CSSProperties = { [Property in keyof WithAnonymousCSSProperties]: AnonymousCSSPropertyValue | (Property extends KeyofNestedPropertiesMap ? Spread<[ NestedProperty, PropertyBasedCondition | NestedProperty> ]> : PropertyBasedCondition>); }; type KeyofAnonymousCSSProperties = keyof WithAnonymousCSSProperties; type KeyofNestedPropertiesMap = keyof NestedPropertiesMap; type AnonymousCSSPropertyValue = CSSPropertyValue; type CSSPropertyValue = PropertyValue | CSSVarFunction | Array; type NestedPropertyValue = PropertyValue | PropertyBasedCondition; type NestedProperty = { [NestedProperty in keyof NestedPropertiesMap[Property]]?: NestedPropertyValue>>; }; export interface PropertyBasedCondition extends CSSPropertyConditions> { } interface CSSPropertyConditions extends CSSConditions { base?: PropertyValue; } interface SelectorProperty { /** * More complex rules can be written using the `selectors` key. * * @see https://vanilla-extract.style/documentation/styling/#complex-selectors */ selectors?: ComplexSelectors; } export interface VarProperty { /** * Custom properties are scoped to the element(s) they are declared on, and participate in the cascade: the value of such a custom property is that from the declaration decided by the cascading algorithm. * * @see https://developer.mozilla.org/en-US/docs/Web/CSS/--* */ vars?: TopLevelVar; } interface TopLevelVar { [key: CSSVarKey]: CSSVarValue; } export type PureCSSVarKey = `--${string}`; export type CSSVarKey = PureCSSVarKey | `$${string}`; export type CSSVarValue = `${string | number}`; export type PureCSSVarFunction = `var(--${string})` | `var(--${string}, ${CSSVarValue})`; export type CSSVarFunction = PureCSSVarFunction | `$${string}` | `$${string}(${CSSVarValue})`; interface SpaceProperties extends Pick { } interface CommaProperties extends Pick { } type SpaceMergeProperties = { [SpaceProperty in keyof SpaceProperties as `${SpaceProperty}_`]: Array; }; type CommaMergeProperties = { [CommaProperty in keyof CommaProperties as `${CommaProperty}$`]: Array; }; export interface CSSMergeProperties extends SpaceMergeProperties, CommaMergeProperties { } export type WithConditions = StyleType & NestedConditions; interface NestedConditions extends CSSConditions> { } interface CSSConditions extends AtRules, ToplevelSelectors { } export interface ToplevelSelectors extends ComplexSelectors, SimplyNestedSelectors, PseudoSelectorMap { } interface ComplexSelectors { /** * Toplevel complex selector. * * @see https://vanilla-extract.style/documentation/styling/#complex-selectors */ [selector: `${string}&${string}`]: StyleType; } interface SimplyNestedSelectors { [selector: `:${string}` | `[${string}`]: StyleType; } type PseudoSelectorMap = { [key in CamelPseudos]?: StyleType; }; export type AtRulesKeywords = "media" | "supports" | "container" | "layer"; interface AtRules extends NestedAtRules, TopLevelAtRules { } type NestedAtRules = { [key in AtRulesKeywords as `@${key}`]?: { [query: string]: StyleType; }; }; type TopLevelAtRules = { [key in AtRulesKeywords as `@${key} ${string}`]?: StyleType; }; interface WithAnonymousCSSProperties extends Omit, AnonymousProperty { } export interface AnonymousProperty { /** * The **`animation-name`** CSS property specifies the names of one or more `@keyframes` at-rules that describe the animation to apply to an element. Multiple `@keyframe` at-rules are specified as a comma-separated list of names. If the specified name does not match any `@keyframe` at-rule, no properties are animated. * * **Syntax**: `[ none | ]#` * * **Initial value**: `none` * * | Chrome | Firefox | Safari | Edge | IE | * | :-----: | :-----: | :-----: | :----: | :----: | * | **43** | **16** | **9** | **12** | **10** | * | 3 _-x-_ | 5 _-x-_ | 4 _-x-_ | | | * * @see https://developer.mozilla.org/docs/Web/CSS/animation-name */ animationName?: Property.AnimationName | { [key in CSSKeyframeFromTo]?: CSSComplexProperties; }; /** * The **`font-family`** CSS property specifies a prioritized list of one or more font family names and/or generic family names for the selected element. * * **Syntax**: `[ | ]#` * * **Initial value**: depends on user agent * * | Chrome | Firefox | Safari | Edge | IE | * | :----: | :-----: | :----: | :----: | :---: | * | **1** | **1** | **1** | **12** | **3** | * * @see https://developer.mozilla.org/docs/Web/CSS/font-family */ fontFamily?: Property.FontFamily | GlobalFontFaceRule; } export type AnonymousPropertyKey = keyof AnonymousProperty; export interface ResolvedProperties extends Properties { } type CSSKeyframeFromTo = "from" | "to" | `${IntRange<1, 10>}0%` | `${number & NonNullable}%`; export {};