@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
30 lines • 1.91 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleWithLabel = exports.ToggleWithLabelUncontrolled = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const positions_1 = require("../../types/positions/positions");
const toggleWithLabelControlled_1 = require("./toggleWithLabelControlled");
const toggleWithLabel_1 = require("./types/toggleWithLabel");
const THREE_POSITION_TOGGLE = 'YES_NO';
const ToggleWithLabelUncontrolledComponent = ({ toggleVariant, defaultTogglePosition = toggleVariant !== THREE_POSITION_TOGGLE
? positions_1.POSITIONS.LEFT
: positions_1.POSITIONS.CENTER, togglePosition, displayRow,
/* deprecated - deleted condition when the 'displayRow' prop is removed */
labelPosition = displayRow === undefined ? toggleWithLabel_1.LABEL_POSITION.LEFT : undefined, onChange, ...props }, ref) => {
const [_togglePosition, setTogglePosition] = react_1.default.useState(defaultTogglePosition);
const handleChange = (newPosition) => {
setTogglePosition(newPosition);
onChange?.(newPosition);
};
return ((0, jsx_runtime_1.jsx)(toggleWithLabelControlled_1.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
*/
exports.ToggleWithLabelUncontrolled = react_1.default.forwardRef(ToggleWithLabelUncontrolledComponent);
exports.ToggleWithLabel = exports.ToggleWithLabelUncontrolled;
//# sourceMappingURL=toggleWithLabelUncontrolled.js.map