UNPKG

@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.67 kB
import type { BorderTopLeftRadiusValue, BorderTopRightRadiusValue, BorderBottomRightRadiusValue, BorderBottomLeftRadiusValue } from '../types'; /** * Union type for all physical border radius property values */ export type PhysicalBorderRadiusValue = BorderTopLeftRadiusValue | BorderTopRightRadiusValue | BorderBottomRightRadiusValue | BorderBottomLeftRadiusValue; /** * Shared parser for all physical 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 * parsePhysicalBorderRadiusProperty('10px') // { type: 'length', value: 10, unit: 'px' } * parsePhysicalBorderRadiusProperty('50%') // { type: 'percentage', value: 50, unit: '%' } * parsePhysicalBorderRadiusProperty('inherit') // { type: 'keyword', keyword: 'inherit' } */ export declare function parsePhysicalBorderRadiusProperty<T extends PhysicalBorderRadiusValue>(value: string): T | null; /** * Shared toCSSValue function for all physical 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 * physicalBorderRadiusToCSSValue({ type: 'length', value: 10, unit: 'px' }) // '10px' * physicalBorderRadiusToCSSValue({ type: 'percentage', value: 50, unit: '%' }) // '50%' * physicalBorderRadiusToCSSValue({ type: 'keyword', keyword: 'inherit' }) // 'inherit' */ export declare function physicalBorderRadiusToCSSValue<T extends PhysicalBorderRadiusValue>(parsed: T | null): string | null;