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C,EAClCC,QACEZ,IAAAA,cAACa,IAAQC,EAAA,CACP5C,SAAUA,GAAYQ,EACtBJ,KAAMA,QAAAA,OAAQqC,EACdxC,MAAOA,QAAAA,OAASwC,EAChBjB,QAASP,EAAa4B,SAASP,EAAOzC,OACtCK,SAAUiB,EACVxB,KAAM2C,EAAOzC,QACTiD,EAAAA,EAAAA,IAASnC,KAGjBf,MAAO0C,EAAO1C,OACd,KAGLS,IAASF,GAAS2B,IAAAA,cAACiB,IAAc,CAACC,GAAI,CAAEC,WAAY,QAAU5C,GAC9DF,GAAS2B,IAAAA,cAACiB,IAAc,CAACC,GAAI,CAAEC,WAAY,QAAU9C,GAG5D,GACA,CAAC,QAAS,QACV,CACEL,QAASoD,EAAAA,MAGbC,EAAAA,EAAAA,GAAM,4BAEN,W","sources":["webpack:///./react-material-ui/checkbox-group/index.js"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport _ from 'lodash';\nimport FormLabel from '@mui/material/FormLabel';\nimport Checkbox from '@mui/material/Checkbox';\nimport FormControl from '@mui/material/FormControl';\nimport FormGroup from '@mui/material/FormGroup';\nimport FormHelperText from '@mui/material/FormHelperText';\nimport FormControlLabel from '@mui/material/FormControlLabel';\n\nimport { I18N } from '../../components';\nimport { i18nOptions, passRest } from '../../helpers';\nimport { lfLog } from '../../helpers/lf-log';\n\n// DOCS: https://mui.com/material-ui/api/checkbox/\n\nconst CheckboxGroup = I18N(\n  ({\n    name,\n    label,\n    value,\n    options,\n    disabled = false,\n    color,\n    onChange,\n    error,\n    size,\n    row,\n    hint,\n    labelPlacement,\n    readOnly,\n    onBlur,\n    required,\n    ...rest\n  }) => {\n    const [currentValue, setCurrentValue] = useState(_.isArray(value) ? value : [])\n    const handleChange = useCallback(\n      e => {\n        let newValue;\n        if (e.target.checked) {\n          newValue = [...new Set(currentValue).add(e.target.name)];\n        } else {\n          const newSet = new Set(currentValue);\n          newSet.delete(e.target.name);\n          newValue = [...newSet];\n        }\n        setCurrentValue(newValue);\n        onChange(newValue);\n      },\n      [currentValue, onChange]\n    );\n\n    return (\n      <FormControl\n        data-lf-field-name={name}\n        className=\"lf-control-radio-group\"\n        required={required}\n        error={error != null}\n      >\n        <FormLabel id={`lf-control-radio-group-${name}`}>{label}</FormLabel>\n        <FormGroup\n          aria-labelledby={`lf-control-radio-group-${name}`}\n        >\n          {(options || []).map(option => (\n            <FormControlLabel\n              key={option.value}\n              value={option.value}\n              labelPlacement={labelPlacement ?? undefined}\n              control={\n                <Checkbox\n                  disabled={disabled || readOnly}\n                  size={size ?? undefined}\n                  color={color ?? undefined}\n                  checked={currentValue.includes(option.value)}\n                  onChange={handleChange}\n                  name={option.value}\n                  {...passRest(rest)}\n                />\n              }\n              label={option.label}\n            />\n          ))}\n        </FormGroup>\n        {hint && !error && <FormHelperText sx={{ marginLeft: '0px' }}>{hint}</FormHelperText>}\n        {error && <FormHelperText sx={{ marginLeft: '0px' }}>{error}</FormHelperText>}\n      </FormControl>\n    );\n  },\n  ['label', 'hint'],\n  {\n    options: i18nOptions\n  }\n);\nlfLog('Loaded MUI.CheckboxGroup');\n\nexport default CheckboxGroup;\n"],"names":["CheckboxGroup","I18N","_ref","name","label","value","options","_ref$disabled","disabled","color","onChange","error","size","hint","row","labelPlacement","readOnly","required","onBlur","rest","_objectWithoutProperties","_excluded","_useState2","useState","_isArray","currentValue","setCurrentValue","handleChange","useCallback","e","newValue","target","checked","_toConsumableArray","Set","add","newSet","delete","React","FormControl","className","FormLabel","id","concat","FormGroup","map","option","FormControlLabel","key","undefined","control","Checkbox","_extends","includes","passRest","FormHelperText","sx","marginLeft","i18nOptions","lfLog"],"sourceRoot":""}