@pagamio/frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
8 lines (7 loc) • 839 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from 'react';
import { Switch } from '../../../../components';
const ToggleSwitchInput = React.forwardRef(({ field, error, value, onChange, ...props }, ref) => {
return (_jsxs("div", { ref: ref, className: "flex flex-row flex-nowrap items-center justify-between", children: [_jsx("label", { htmlFor: field.name, className: "block text-sm font-medium text-gray-700", children: field.label }), _jsx(Switch, { ...props, checked: value || false, onChange: onChange, disabled: field.disabled, className: `react-switch ${error ? 'border-red-500' : 'border-gray-300'} disabled:text-gray-400 disabled:bg-gray-50`, id: field.name }), error && _jsx("p", { className: "mt-2 text-sm text-red-500", children: error.message })] }));
});
export default ToggleSwitchInput;