@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
36 lines (35 loc) • 1.35 kB
TypeScript
import { type OverflowWrapValue } from '../types';
/**
* Parses CSS overflow-wrap property values
*
* Syntax: normal | anywhere | break-word | inherit | initial | unset | revert
*
* @param value - The CSS overflow-wrap value to parse
* @returns Parsed OverflowWrapValue or null if invalid
*
* @example
* ```typescript
* parse('normal') // { type: 'keyword', keyword: 'normal' }
* parse('anywhere') // { type: 'keyword', keyword: 'anywhere' }
* parse('break-word') // { type: 'keyword', keyword: 'break-word' }
* parse('inherit') // { type: 'keyword', keyword: 'inherit' }
* parse('var(--wrap)') // { type: 'variable', variable: 'wrap' }
* parse('invalid') // null
* ```
*/
export declare function parse(value: string): OverflowWrapValue | null;
/**
* Converts a parsed OverflowWrapValue back to a CSS string
*
* @param parsed - The parsed OverflowWrapValue to convert
* @returns CSS string representation or null if invalid
*
* @example
* ```typescript
* toCSSValue({ type: 'keyword', keyword: 'normal' }) // 'normal'
* toCSSValue({ type: 'keyword', keyword: 'anywhere' }) // 'anywhere'
* toCSSValue({ type: 'keyword', keyword: 'break-word' }) // 'break-word'
* toCSSValue({ type: 'keyword', keyword: 'inherit' }) // 'inherit'
* ```
*/
export declare function toCSSValue(parsed: OverflowWrapValue | null): string | null;