tp-react-elements 2.0.5 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/index.esm11.js +2 -2
- package/dist/_virtual/index.esm12.js +2 -2
- package/dist/_virtual/index.esm13.js +2 -2
- package/dist/_virtual/index.esm14.js +2 -2
- package/dist/_virtual/index.esm4.js +2 -2
- package/dist/_virtual/index.esm5.js +2 -2
- package/dist/_virtual/index.esm6.js +2 -2
- package/dist/_virtual/index.esm7.js +2 -2
- package/dist/components/Button/Button.esm.js +9 -5
- package/dist/components/DeleteComponent/DeleteField.esm.js +20 -14
- package/dist/components/Form/FormActiveSwitch.esm.js +5 -1
- package/dist/components/Form/FormRender.esm.js +9 -9
- package/dist/components/Form/FormRenderWrapper.esm.js +2 -2
- package/dist/components/FormComponents/DatePicker/Monthpickerrender.esm.js +6 -4
- package/dist/components/FormComponents/FileUpload/MultiFileWithPreview.esm.js +38 -6
- package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js +11 -8
- package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.esm.js +14 -12
- package/dist/components/FormComponents/Select/MultiSelectTable.esm.js +176 -160
- package/dist/components/FormComponents/Select/MultiSelectv1.esm.js +2 -2
- package/dist/components/FormComponents/index.esm.js +10 -24
- package/dist/components/ModalField/ConfirmationDialog.esm.js +37 -37
- package/dist/components/ModalField/ModalField.esm.js +19 -16
- package/dist/components/PaginatedGrid/GenericPaginatedGrid.d.ts +31 -2
- package/dist/components/PaginatedGrid/GenericPaginatedGrid.esm.js +156 -32
- package/dist/components/PaginatedGrid/types.d.ts +25 -0
- package/dist/components/SelectField/MultiSelectFieldComponent.esm.js +19 -21
- package/dist/node_modules/react-date-range/dist/components/Calendar/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/DateInput/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/DateRange/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/DateRangePicker/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/DayCell/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/DefinedRange/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/InputRangeField/index.esm.js +3 -3
- package/dist/node_modules/react-date-range/dist/components/Month/index.esm.js +3 -3
- package/dist/node_modules/react-list/react-list.esm.js +2 -2
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DayCell = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DayCell as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var InputRangeField = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { InputRangeField as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Month = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Month as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateInput = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateInput as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DefinedRange = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DefinedRange as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateRangePicker = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRangePicker as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Calendar = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Calendar as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateRange = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRange as __exports };
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useAuth } from '../../auth/authContext.esm.js';
|
|
3
3
|
import { Button } from '@mui/material';
|
|
4
|
+
import { useMemo, useCallback } from 'react';
|
|
4
5
|
|
|
5
6
|
const ButtonStyled = ({ name }) => {
|
|
6
7
|
const { projectTheme } = useAuth();
|
|
7
8
|
const ButtonConfig = projectTheme?.Styles.Component.TPButton.find((item) => item.name === name);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const commonSx = projectTheme?.Styles.Component.TPButtonCommonSx;
|
|
10
|
+
const sx = useMemo(() => ({ ...commonSx }), [commonSx]);
|
|
11
|
+
const handleClick = useCallback(() => {
|
|
12
|
+
if (ButtonConfig?.isEnableConfirmDialog) {
|
|
13
|
+
alert('Congirm');
|
|
14
|
+
}
|
|
15
|
+
}, [ButtonConfig?.isEnableConfirmDialog]);
|
|
16
|
+
return (jsx(Button, { sx: sx, onClick: handleClick, children: name }));
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export { ButtonStyled as default };
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Tooltip, Grid, Typography } from '@mui/material';
|
|
3
3
|
import ConfirmationDialog from '../ModalField/ConfirmationDialog.esm.js';
|
|
4
|
-
import { useState } from 'react';
|
|
4
|
+
import { useState, useCallback } from 'react';
|
|
5
5
|
|
|
6
|
+
// ─── Module-level static style objects ─────────────────────────────────────
|
|
7
|
+
const TOOLTIP_TEXT_SX = { fontSize: '8px' };
|
|
8
|
+
const GRID_SX = { ':hover': { cursor: 'pointer' } };
|
|
9
|
+
const TRASH_ICON_STYLE = {
|
|
10
|
+
lineHeight: 1,
|
|
11
|
+
fontSize: '11px',
|
|
12
|
+
color: 'var(--mui-palette-error-main, #B3261E)',
|
|
13
|
+
marginTop: '10px',
|
|
14
|
+
};
|
|
6
15
|
const DeleteField = ({ onClickFn, tooltip = 'Delete', text }) => {
|
|
7
16
|
const [openDialog, setOpenDialog] = useState(false);
|
|
8
|
-
const handleCancel = () => {
|
|
17
|
+
const handleCancel = useCallback(() => {
|
|
9
18
|
setOpenDialog(false);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
handleCancel();
|
|
20
|
-
onClickFn();
|
|
21
|
-
}, text: text })] }));
|
|
19
|
+
}, []);
|
|
20
|
+
const handleOpen = useCallback(() => {
|
|
21
|
+
setOpenDialog(true);
|
|
22
|
+
}, []);
|
|
23
|
+
const handleSubmit = useCallback(() => {
|
|
24
|
+
handleCancel();
|
|
25
|
+
onClickFn();
|
|
26
|
+
}, [handleCancel, onClickFn]);
|
|
27
|
+
return (jsxs(Fragment, { children: [jsx(Tooltip, { title: jsx(Typography, { sx: TOOLTIP_TEXT_SX, children: tooltip }), children: jsx(Grid, { sx: GRID_SX, onClick: handleOpen, children: jsx("i", { className: "flaticon-trash", style: TRASH_ICON_STYLE }) }) }), jsx(ConfirmationDialog, { openConfirmDialog: openDialog, handleCancel: handleCancel, onClickSubmit: handleSubmit, text: text })] }));
|
|
22
28
|
};
|
|
23
29
|
|
|
24
30
|
export { DeleteField as default };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Controller } from 'react-hook-form';
|
|
3
3
|
|
|
4
|
+
// Static — hoisted so they aren't rebuilt on every render.
|
|
5
|
+
const FIELDSET_STYLE = { border: 'none', padding: 0, margin: 0 };
|
|
6
|
+
const LEGEND_STYLE = { fontSize: '12px', paddingRight: 10 };
|
|
7
|
+
const LABEL_STYLE = { textTransform: 'none' };
|
|
4
8
|
const FormActiveSwitch = ({ props }) => {
|
|
5
9
|
const { control, item } = props;
|
|
6
10
|
const valueActive = item.value1 ?? 'A';
|
|
7
11
|
const valueInactive = item.value2 ?? 'I';
|
|
8
|
-
return (jsxs("fieldset", { className: "m-form__input", style:
|
|
12
|
+
return (jsxs("fieldset", { className: "m-form__input", style: FIELDSET_STYLE, children: [item.label && (jsx("legend", { id: `${item.name}-label`, style: LEGEND_STYLE, children: item.label })), jsx(Controller, { name: item.name, control: control, render: ({ field }) => (jsxs("span", { className: "switch prestashop-switch fixed-width-lg", role: "radiogroup", "aria-labelledby": `${item.name}-label`, children: [jsx("input", { id: `${item.name}_on`, name: item.name, type: "radio", value: valueActive, checked: field.value === valueActive, onChange: () => field.onChange(valueActive), "aria-checked": field.value === valueActive }), jsx("label", { htmlFor: `${item.name}_on`, style: LABEL_STYLE, children: item.label1 ?? 'Active' }), jsx("input", { id: `${item.name}_off`, name: item.name, type: "radio", value: valueInactive, checked: field.value === valueInactive, onChange: () => field.onChange(valueInactive), "aria-checked": field.value === valueInactive }), jsx("label", { htmlFor: `${item.name}_off`, style: LABEL_STYLE, children: item.label2 ?? 'In Active' }), jsx("span", { className: "slide-button btn", "aria-hidden": "true" })] })) })] }));
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
export { FormActiveSwitch as default };
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import FormCheckBox from '../FormComponents/FormCheckBox/FormCheckBox.esm.js';
|
|
4
|
-
import FormCheckBoxGroup from '../FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
|
|
5
|
-
import FormNumberField from '../FormComponents/FormNumberField/FormNumberField.esm.js';
|
|
6
|
-
import FormNumberFieldDecimal from '../FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js';
|
|
7
|
-
import FormRadioGroup from '../FormComponents/FormRadioGroup/FormRadioGroup.esm.js';
|
|
8
|
-
import FormTextAreaField from '../FormComponents/FormTextAreaField/FormTextAreaField.esm.js';
|
|
9
|
-
import PasswordField from '../FormComponents/PasswordField/PasswordField.esm.js';
|
|
2
|
+
import require$$0__default, { lazy, Suspense } from 'react';
|
|
10
3
|
import SingleSelect from '../FormComponents/Select/SingleSelect.esm.js';
|
|
11
4
|
import MultiSelectAutocomplete from '../FormComponents/Select/MultiSelectAutocomplete.esm.js';
|
|
12
5
|
import SingleSelectNonAutoComplete from '../FormComponents/Select/SingleSelectNonAutoComplete.esm.js';
|
|
@@ -17,6 +10,13 @@ import DateRangePickerComponent from '../DateRangePicker/DateRangePicker.esm.js'
|
|
|
17
10
|
import RichTextEditorWrapper from '../FormComponents/RichTextEditor/RichTextEditorWrapper.esm.js';
|
|
18
11
|
import SingleSelectSearchApi from '../FormComponents/Select/SingleSelectSearchApi.esm.js';
|
|
19
12
|
import DatetimepickerWrapper from '../FormComponents/DatePicker/DatetimepickerWrapper.esm.js';
|
|
13
|
+
import FormTextAreaField from '../FormComponents/FormTextAreaField/FormTextAreaField.esm.js';
|
|
14
|
+
import FormCheckBox from '../FormComponents/FormCheckBox/FormCheckBox.esm.js';
|
|
15
|
+
import FormRadioGroup from '../FormComponents/FormRadioGroup/FormRadioGroup.esm.js';
|
|
16
|
+
import FormCheckBoxGroup from '../FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
|
|
17
|
+
import FormNumberFieldDecimal from '../FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js';
|
|
18
|
+
import FormNumberField from '../FormComponents/FormNumberField/FormNumberField.esm.js';
|
|
19
|
+
import PasswordField from '../FormComponents/PasswordField/PasswordField.esm.js';
|
|
20
20
|
import FormTextField from '../FormComponents/FormTextField/FormTextField.esm.js';
|
|
21
21
|
|
|
22
22
|
// Lazy-loaded heavy components
|
|
@@ -161,6 +161,6 @@ const RenderForm = (props) => {
|
|
|
161
161
|
*
|
|
162
162
|
* @see FormRenderWrapper
|
|
163
163
|
*/
|
|
164
|
-
var RenderForm$1 =
|
|
164
|
+
var RenderForm$1 = require$$0__default.memo(RenderForm);
|
|
165
165
|
|
|
166
166
|
export { RenderForm$1 as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import require$$0__default from 'react';
|
|
3
3
|
import { useFormState } from 'react-hook-form';
|
|
4
4
|
import { FormComponent, Formitem } from './Form.styles.esm.js';
|
|
5
5
|
import RenderForm from './FormRender.esm.js';
|
|
@@ -28,6 +28,6 @@ const FormRenderWrapper = ({ formArray, name = '', numberOfColumns = 3, form, va
|
|
|
28
28
|
* Export the FormRenderWrapper component for use in form containers
|
|
29
29
|
* This component is the main entry point for rendering form fields
|
|
30
30
|
*/
|
|
31
|
-
var FormRenderWrapper_default =
|
|
31
|
+
var FormRenderWrapper_default = require$$0__default.memo(FormRenderWrapper);
|
|
32
32
|
|
|
33
33
|
export { FormRenderWrapper_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { useRef, useState, useEffect, useCallback } from 'react';
|
|
3
3
|
import { getDatePicker } from '../../../utils/Constants/date-pickers.esm.js';
|
|
4
4
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
5
5
|
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
@@ -23,13 +23,15 @@ const Monthpickerrender = ({ props, variant, }) => {
|
|
|
23
23
|
};
|
|
24
24
|
loadComponents();
|
|
25
25
|
}, []);
|
|
26
|
-
|
|
26
|
+
// Stable toggle — mirrors the DatepickerWrapperV2 pattern so onClick/onOpen
|
|
27
|
+
// don't hand the picker a new function reference on every render.
|
|
28
|
+
const handleToggle = useCallback(() => {
|
|
27
29
|
if (!open) {
|
|
28
30
|
ref.current?.blur();
|
|
29
31
|
}
|
|
30
32
|
document.activeElement?.blur();
|
|
31
33
|
setOpen(!open);
|
|
32
|
-
};
|
|
34
|
+
}, [open]);
|
|
33
35
|
const isError = !!props.errors?.[props.item.name];
|
|
34
36
|
const isShowBorderError = isError;
|
|
35
37
|
if (isLoading) {
|
|
@@ -38,7 +40,7 @@ const Monthpickerrender = ({ props, variant, }) => {
|
|
|
38
40
|
return (jsx(Fragment, { children: DatePicker && (jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [jsxs(LocalizationProvider, { dateAdapter: AdapterDayjs, children: [renderLabel(variant, props), jsx(DatePicker, { ref: ref, label: variant !== 'standard' &&
|
|
39
41
|
`${props.item.label}${props.item.required ? ' *' : ''}`, views: ['year', 'month'], openTo: "month", view: view, onViewChange: (newView) => setView(newView), disabled: props.item.disable, value: field.value ? dayjs(formatDateMonthAndYear(field.value || null)) : null, slotProps: {
|
|
40
42
|
textField: {
|
|
41
|
-
onClick:
|
|
43
|
+
onClick: handleToggle,
|
|
42
44
|
inputRef: ref,
|
|
43
45
|
error: isShowBorderError,
|
|
44
46
|
inputProps: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Box, Button, IconButton, Modal, Typography } from '@mui/material';
|
|
3
|
-
import { useRef, useState, useEffect, useMemo
|
|
3
|
+
import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
|
|
4
4
|
import { useWatch } from 'react-hook-form';
|
|
5
5
|
import 'dayjs';
|
|
6
6
|
import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
|
|
@@ -51,11 +51,6 @@ const isWordFile = (file) => {
|
|
|
51
51
|
const name = typeof file === 'string' ? file : (file.name || '');
|
|
52
52
|
return /\.(doc|docx)$/.test(name.toLowerCase());
|
|
53
53
|
};
|
|
54
|
-
const getObjectUrl = (file) => {
|
|
55
|
-
if (!file)
|
|
56
|
-
return '';
|
|
57
|
-
return typeof file === 'string' ? file : URL.createObjectURL(file);
|
|
58
|
-
};
|
|
59
54
|
// ─── Component ────────────────────────────────────────────────────────────────
|
|
60
55
|
const MultiFileWithPreview = ({ props, variant, }) => {
|
|
61
56
|
const inputRef = useRef(null);
|
|
@@ -64,6 +59,43 @@ const MultiFileWithPreview = ({ props, variant, }) => {
|
|
|
64
59
|
const [open, setOpen] = useState(false);
|
|
65
60
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
66
61
|
const [currentFileIndex, setCurrentFileIndex] = useState(0);
|
|
62
|
+
// Blob URL cache, keyed by File reference — createObjectURL was previously
|
|
63
|
+
// called fresh on every render for the same File, leaking a blob URL each
|
|
64
|
+
// time (never revoked). Now a URL is created once per File and reused;
|
|
65
|
+
// stale/unmounted entries are revoked below.
|
|
66
|
+
const objectUrlCacheRef = useRef(new Map());
|
|
67
|
+
const getObjectUrl = useCallback((file) => {
|
|
68
|
+
if (!file)
|
|
69
|
+
return '';
|
|
70
|
+
if (typeof file === 'string')
|
|
71
|
+
return file;
|
|
72
|
+
const cache = objectUrlCacheRef.current;
|
|
73
|
+
const cached = cache.get(file);
|
|
74
|
+
if (cached)
|
|
75
|
+
return cached;
|
|
76
|
+
const url = URL.createObjectURL(file);
|
|
77
|
+
cache.set(file, url);
|
|
78
|
+
return url;
|
|
79
|
+
}, []);
|
|
80
|
+
// Revoke blob URLs for files that are no longer selected (removed/replaced).
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const cache = objectUrlCacheRef.current;
|
|
83
|
+
const currentFiles = new Set(selectedFiles.filter((f) => f instanceof File));
|
|
84
|
+
cache.forEach((url, file) => {
|
|
85
|
+
if (!currentFiles.has(file)) {
|
|
86
|
+
URL.revokeObjectURL(url);
|
|
87
|
+
cache.delete(file);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}, [selectedFiles]);
|
|
91
|
+
// Revoke everything on unmount.
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const cache = objectUrlCacheRef.current;
|
|
94
|
+
return () => {
|
|
95
|
+
cache.forEach((url) => URL.revokeObjectURL(url));
|
|
96
|
+
cache.clear();
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
67
99
|
// Clamp preview index when selection changes
|
|
68
100
|
useEffect(() => {
|
|
69
101
|
if (selectedFiles.length === 0) {
|
|
@@ -5,6 +5,16 @@ import FormBottomField from '../FormBottomField/FormBottomField.esm.js';
|
|
|
5
5
|
import 'dayjs';
|
|
6
6
|
import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
|
|
7
7
|
|
|
8
|
+
// Identical for every checkbox in the group — hoisted so it isn't rebuilt
|
|
9
|
+
// per option on every render.
|
|
10
|
+
const CHECKBOX_LABEL_SX = {
|
|
11
|
+
'.MuiCheckbox-root': {
|
|
12
|
+
padding: '6px 2px 6px 8px',
|
|
13
|
+
'.css-imrjgg-MuiButtonBase-root-MuiCheckbox-root': {
|
|
14
|
+
color: 'rgb(0, 0, 0) !important',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
8
18
|
/**
|
|
9
19
|
* FormCheckBoxGroup Component
|
|
10
20
|
*
|
|
@@ -27,14 +37,7 @@ const FormCheckBoxGroup = ({ props, variant, }) => {
|
|
|
27
37
|
return (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(FormControl, { component: "fieldset", children: jsx(FormGroup, { row: true, children: props.item?.settings &&
|
|
28
38
|
props.item.settings.map((settings, i) => {
|
|
29
39
|
return (jsx(Controller, { name: settings.name, control: props.control, render: ({ field }) => {
|
|
30
|
-
return (jsx(FormControlLabel, { control: jsx(Checkbox, { ...field, checked: field.value }), sx: {
|
|
31
|
-
'.MuiCheckbox-root': {
|
|
32
|
-
padding: '6px 2px 6px 8px',
|
|
33
|
-
'.css-imrjgg-MuiButtonBase-root-MuiCheckbox-root': {
|
|
34
|
-
color: 'rgb(0, 0, 0) !important',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
}, label: jsx(Typography, { variant: "subtitle2", fontSize: '11px', fontWeight: 'normal !important', children: settings.label }), labelPlacement: "end" }));
|
|
40
|
+
return (jsx(FormControlLabel, { control: jsx(Checkbox, { ...field, checked: field.value }), sx: CHECKBOX_LABEL_SX, label: jsx(Typography, { variant: "subtitle2", fontSize: '11px', fontWeight: 'normal !important', children: settings.label }), labelPlacement: "end" }));
|
|
38
41
|
} }, i));
|
|
39
42
|
}) }) }), jsx(FormBottomField, { ...props })] }));
|
|
40
43
|
};
|
|
@@ -5,6 +5,19 @@ import FormBottomField from '../FormBottomField/FormBottomField.esm.js';
|
|
|
5
5
|
import 'dayjs';
|
|
6
6
|
import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
|
|
7
7
|
|
|
8
|
+
// Static — same for the group and for every radio option — hoisted so they
|
|
9
|
+
// aren't rebuilt on every render/option.
|
|
10
|
+
const RADIO_GROUP_SX = { gap: '8px' };
|
|
11
|
+
const RADIO_SX = {
|
|
12
|
+
padding: '6px 2px 6px 8px',
|
|
13
|
+
color: 'black',
|
|
14
|
+
'&.Mui-checked': {
|
|
15
|
+
color: '#1976d2', // blue when selected
|
|
16
|
+
},
|
|
17
|
+
'& .MuiSvgIcon-root': {
|
|
18
|
+
fontSize: 16, // controls the radio icon size
|
|
19
|
+
},
|
|
20
|
+
};
|
|
8
21
|
/**
|
|
9
22
|
* FormRadioGroup Component
|
|
10
23
|
*
|
|
@@ -27,18 +40,7 @@ const FormRadioGroup = ({ props, variant }) => {
|
|
|
27
40
|
return (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(FormControl, { component: "fieldset", children: jsx(Controller, { name: props.item.name, control: props.control, render: ({ field }) => (jsx(RadioGroup, { value: field.value || '', onChange: (e) => {
|
|
28
41
|
field.onChange(e.target.value); // update form state
|
|
29
42
|
props.item.onChangeFn && props.item.onChangeFn(e.target.value); // optional handler
|
|
30
|
-
}, row: true, sx: {
|
|
31
|
-
gap: '8px',
|
|
32
|
-
}, children: props.item?.settings?.map((option, i) => (jsx(FormControlLabel, { value: option.name, control: jsx(Radio, { sx: {
|
|
33
|
-
padding: '6px 2px 6px 8px',
|
|
34
|
-
color: 'black',
|
|
35
|
-
'&.Mui-checked': {
|
|
36
|
-
color: '#1976d2', // blue when selected
|
|
37
|
-
},
|
|
38
|
-
'& .MuiSvgIcon-root': {
|
|
39
|
-
fontSize: 16, // controls the radio icon size
|
|
40
|
-
},
|
|
41
|
-
} }), label: jsx(Typography, { fontSize: '11px', fontWeight: 'normal !important', children: option.label }) }, i))) })) }) }), jsx(FormBottomField, { ...props })] }));
|
|
43
|
+
}, row: true, sx: RADIO_GROUP_SX, children: props.item?.settings?.map((option, i) => (jsx(FormControlLabel, { value: option.name, control: jsx(Radio, { sx: RADIO_SX }), label: jsx(Typography, { fontSize: '11px', fontWeight: 'normal !important', children: option.label }) }, i))) })) }) }), jsx(FormBottomField, { ...props })] }));
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
export { FormRadioGroup as default };
|