@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
27 lines (26 loc) • 1.04 kB
TypeScript
import { type WhiteSpaceValue } from '../types';
/**
* Parses CSS white-space property values
*
* Syntax: normal | nowrap | pre | pre-wrap | pre-line | break-spaces | inherit | initial | unset | revert
*
* @param value - The CSS white-space value to parse
* @returns Parsed WhiteSpaceValue or null if invalid
*
* @example
* ```typescript
* parse('normal') // { type: 'keyword', keyword: 'normal' }
* parse('nowrap') // { type: 'keyword', keyword: 'nowrap' }
* parse('pre-wrap') // { type: 'keyword', keyword: 'pre-wrap' }
* parse('inherit') // { type: 'keyword', keyword: 'inherit' }
* parse('var(--my-whitespace)') // { type: 'css-variable', variable: 'my-whitespace' }
* ```
*/
export declare function parse(value: string): WhiteSpaceValue | null;
/**
* Converts a parsed WhiteSpaceValue back to its CSS string representation
*
* @param value - The parsed white-space value
* @returns CSS string representation or null if invalid
*/
export declare function toCSSValue(value: WhiteSpaceValue | null): string | null;