@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
35 lines (34 loc) • 1.25 kB
TypeScript
import { type TextIndentValue } from '../types';
/**
* Parses CSS text-indent property values
*
* Syntax: <length> | <percentage> | [ each-line || hanging ] | inherit | initial | unset | revert
*
* @param value - The CSS text-indent value to parse
* @returns Parsed TextIndentValue or null if invalid
*
* @example
* ```typescript
* parse('2em') // { value: 2, unit: 'em' }
* parse('50%') // { value: 50, unit: '%' }
* parse('each-line') // { type: 'keyword', keyword: 'each-line' }
* parse('hanging') // { type: 'keyword', keyword: 'hanging' }
* parse('inherit') // { type: 'keyword', keyword: 'inherit' }
* parse('var(--my-indent)') // { type: 'variable', variable: 'my-indent' }
* ```
*/
export declare function parse(value: string): TextIndentValue | null;
/**
* Converts a parsed TextIndentValue back to a CSS string
*
* @param parsed - The parsed TextIndentValue to convert
* @returns CSS string representation or null if invalid
*
* @example
* ```typescript
* toCSSValue({ value: 2, unit: 'em' }) // '2em'
* toCSSValue({ value: 50, unit: '%' }) // '50%'
* toCSSValue({ type: 'keyword', keyword: 'each-line' }) // 'each-line'
* ```
*/
export declare function toCSSValue(parsed: TextIndentValue | null): string | null;