UNPKG

rsuite

Version:

A suite of react components

44 lines (40 loc) 1.24 kB
'use client'; import camelCase from 'lodash/camelCase'; import { cssSystemPropAlias } from "../styled-system/css-alias.js"; import { supportedCSSProperties } from "../styled-system/css-properties.js"; const boxPropKeys = new Set(supportedCSSProperties); Object.entries(cssSystemPropAlias).forEach(([key, prop]) => { boxPropKeys.add(key); boxPropKeys.add(camelCase(prop.property)); }); const isBoxProp = key => boxPropKeys.has(key); /** * Extract box properties from props * @param props Original props object * @returns Object containing only box properties */ export const extractBoxProps = props => { const boxProps = {}; // Extract only box related properties Object.keys(props).forEach(key => { if (isBoxProp(key) && props[key] !== undefined) { boxProps[key] = props[key]; } }); return boxProps; }; /** * Filter out layout properties from props * @param props Original props object * @returns New object without layout properties */ export const omitBoxProps = props => { const filteredProps = {}; // Copy all properties except box related ones Object.keys(props).forEach(key => { if (!isBoxProp(key)) { filteredProps[key] = props[key]; } }); return filteredProps; };