@wix/css-property-parser
Version:
A comprehensive TypeScript library for parsing and serializing CSS property values with full MDN specification compliance
32 lines (31 loc) • 1.65 kB
TypeScript
import type { BorderStartStartRadiusValue, BorderStartEndRadiusValue, BorderEndStartRadiusValue, BorderEndEndRadiusValue } from '../types';
/**
* Union type for all logical border radius property values
*/
export type LogicalBorderRadiusValue = BorderStartStartRadiusValue | BorderStartEndRadiusValue | BorderEndStartRadiusValue | BorderEndEndRadiusValue;
/**
* Shared parser for all logical border radius properties
* Handles length, percentage, CSS functions, keywords, and variables with non-negative validation
*
* @param value - The CSS value to parse
* @returns Parsed value or null if invalid
*
* @example
* parseLogicalBorderRadiusProperty('10px') // { type: 'length', value: 10, unit: 'px' }
* parseLogicalBorderRadiusProperty('50%') // { type: 'percentage', value: 50, unit: '%' }
* parseLogicalBorderRadiusProperty('inherit') // { type: 'keyword', keyword: 'inherit' }
*/
export declare function parseLogicalBorderRadiusProperty<T extends LogicalBorderRadiusValue>(value: string): T | null;
/**
* Shared toCSSValue function for all logical border radius properties
* Converts parsed values back to CSS string representation
*
* @param parsed - The parsed value to convert
* @returns CSS string or null if invalid
*
* @example
* logicalBorderRadiusToCSSValue({ type: 'length', value: 10, unit: 'px' }) // '10px'
* logicalBorderRadiusToCSSValue({ type: 'percentage', value: 50, unit: '%' }) // '50%'
* logicalBorderRadiusToCSSValue({ type: 'keyword', keyword: 'inherit' }) // 'inherit'
*/
export declare function logicalBorderRadiusToCSSValue<T extends LogicalBorderRadiusValue>(parsed: T | null): string | null;