UNPKG

@ozen-ui/kit

Version:

React component library

26 lines (25 loc) 894 B
import { useEffect } from 'react'; import { useStoredValue } from '../../../hooks/useStoredValue'; import { setCSSProperty } from '../../../utils/css'; export var useBottomSheetBaseCSSValue = function (_a) { var rootRef = _a.rootRef, defaultValue = _a.defaultValue, variableName = _a.variableName, formatValue = _a.formatValue; var value = useStoredValue(defaultValue); var setPropertyValue = function (value) { setCSSProperty({ element: rootRef.current, variableName: variableName, value: formatValue ? formatValue(value) : value, }); }; var setValue = function (newValue) { value.current = newValue; setPropertyValue(newValue); }; useEffect(function () { setPropertyValue(value.current); }, [rootRef.current]); return { value: value, setValue: setValue, }; };