import * as postcss from 'postcss'; import type { DeclarationRaws } from 'postcss/lib/declaration'; import { AnyExpression, ExpressionProps } from '../expression'; import { NodeProps } from '../node'; import { RawWithValue } from '../raw-with-value'; import * as sassInternal from '../sass-internal'; import { Statement, StatementWithChildren } from '.'; import { _Declaration } from './declaration-internal'; /** * The set of raws supported by {@link VariableDeclaration}. * * @category Statement */ export interface VariableDeclarationRaws extends Omit { /** * The variable's namespace. * * This may be different than {@link VariableDeclaration.namespace} if the * name contains escape codes. */ namespace?: RawWithValue; /** * The variable's name, not including the `$`. * * This may be different than {@link VariableDeclaration.variableName} if * the name contains escape codes or underscores. */ variableName?: RawWithValue; /** The whitespace and colon between the variable name and value. */ between?: string; /** The `!default` and/or `!global` flags, including preceding whitespace. */ flags?: RawWithValue<{ guarded: boolean; global: boolean; }>; /** * The space symbols between the end of the variable declaration and the * semicolon afterwards. Always empty for a variable that isn't followed by a * semicolon. */ afterValue?: string; } /** * The initializer properties for {@link VariableDeclaration}. * * @category Statement */ export type VariableDeclarationProps = NodeProps & { raws?: VariableDeclarationRaws; namespace?: string; variableName: string; guarded?: boolean; global?: boolean; } & ({ expression: AnyExpression | ExpressionProps; value?: never; } | { value: string; expression?: never; }); /** * A Sass variable declaration. Extends [`postcss.Declaration`]. * * [`postcss.Declaration`]: https://postcss.org/api/#declaration * * @category Statement */ export declare class VariableDeclaration extends _Declaration> implements Statement { readonly sassType: "variable-declaration"; parent: StatementWithChildren | undefined; raws: VariableDeclarationRaws; /** * The variable's namespace. * * This is the parsed value, with escapes resolved to the characters they * represent. */ namespace: string | undefined; /** * The variable name, not including `$`. * * This is the parsed and normalized value, with underscores converted to * hyphens and escapes resolved to the characters they represent. */ variableName: string; /** The variable's value. */ get expression(): AnyExpression; set expression(value: AnyExpression | ExpressionProps); private _expression; /** Whether the variable has a `!default` flag. */ guarded: boolean; /** Whether the variable has a `!global` flag. */ global: boolean; get prop(): string; set prop(value: string); get value(): string; set value(value: string); get important(): boolean; set important(value: boolean); get variable(): boolean; constructor(defaults: VariableDeclarationProps); /** @hidden */ constructor(_: undefined, inner: sassInternal.VariableDeclaration); clone(overrides?: Partial): this; toJSON(): object; /** @hidden */ toJSON(_: string, inputs: Map): object; /** @hidden */ toString(stringifier?: postcss.Stringifier | postcss.Syntax): string; /** @hidden */ get nonStatementChildren(): ReadonlyArray; }