UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

24 lines 1.48 kB
import { jsx as _jsx } from "react/jsx-runtime"; import React from 'react'; import { POSITIONS } from '../../types/positions/positions'; import { ToggleWithLabelControlled } from './toggleWithLabelControlled'; import { LABEL_POSITION } from './types/toggleWithLabel'; const THREE_POSITION_TOGGLE = 'YES_NO'; const ToggleWithLabelUncontrolledComponent = ({ toggleVariant, defaultTogglePosition = toggleVariant !== THREE_POSITION_TOGGLE ? POSITIONS.LEFT : POSITIONS.CENTER, togglePosition, displayRow, /* deprecated - deleted condition when the 'displayRow' prop is removed */ labelPosition = displayRow === undefined ? LABEL_POSITION.LEFT : undefined, onChange, ...props }, ref) => { const [_togglePosition, setTogglePosition] = React.useState(defaultTogglePosition); const handleChange = (newPosition) => { setTogglePosition(newPosition); onChange?.(newPosition); }; return (_jsx(ToggleWithLabelControlled, { ref: ref, labelPosition: labelPosition, togglePosition: togglePosition ?? _togglePosition, toggleVariant: toggleVariant, onChange: handleChange, ...props })); }; /** * @deprecated This component has been deprecated and will be removed in the next MAJOR release. Will include all this on the Toggle component */ export const ToggleWithLabelUncontrolled = React.forwardRef(ToggleWithLabelUncontrolledComponent); export { ToggleWithLabelUncontrolled as ToggleWithLabel }; //# sourceMappingURL=toggleWithLabelUncontrolled.js.map