UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

21 lines (20 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const material_1 = require("@mui/material"); const react_1 = require("react"); const react_intl_1 = require("react-intl"); function SwitchForm(props) { // PROPS const { name, title, description, checked, handleChangeOptions } = props; // STATES const [value, setValue] = (0, react_1.useState)(checked); // HANDLERS const handleChange = (0, react_1.useCallback)((e) => { const _checked = e.target.checked; setValue(_checked); handleChangeOptions(name, _checked); }, [setValue]); return ((0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ component: "fieldset", variant: "standard" }, { children: [(0, jsx_runtime_1.jsx)(material_1.FormLabel, Object.assign({ component: "legend" }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: title, defaultMessage: title }) })) })), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { color: "primary", checked: value, name: name, onChange: handleChange }), label: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: description, defaultMessage: description }) })) })] }))); } exports.default = (0, react_1.memo)(SwitchForm);