tp-react-elements 1.1.2 → 1.1.3
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.esm12.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/FormComponents/Select/MultiSelectv1.esm.js +51 -96
- package/dist/node_modules/react-date-range/dist/components/Calendar/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRangePicker/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DefinedRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/InputRangeField/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/Month/index.esm.js +1 -1
- package/package.json +1 -1
|
@@ -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 DateRangePicker = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRangePicker as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateRange = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRange 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 Calendar = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Calendar as __exports };
|
|
@@ -7,7 +7,7 @@ import ListItemText from '@mui/material/ListItemText';
|
|
|
7
7
|
import MenuItem from '@mui/material/MenuItem';
|
|
8
8
|
import OutlinedInput from '@mui/material/OutlinedInput';
|
|
9
9
|
import Select from '@mui/material/Select';
|
|
10
|
-
import require$$0__default, { useState, useMemo } from 'react';
|
|
10
|
+
import require$$0__default, { useState, useRef, useMemo } from 'react';
|
|
11
11
|
import { useWatch } from 'react-hook-form';
|
|
12
12
|
import FormBottomField from '../FormBottomField/FormBottomField.esm.js';
|
|
13
13
|
import 'dayjs';
|
|
@@ -15,45 +15,25 @@ import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
|
|
|
15
15
|
|
|
16
16
|
const ITEM_HEIGHT = 48;
|
|
17
17
|
const ITEM_PADDING_TOP = 3;
|
|
18
|
-
const MenuProps = {
|
|
19
|
-
PaperProps: {
|
|
20
|
-
style: {
|
|
21
|
-
maxHeight: ITEM_HEIGHT * 5.5 + ITEM_PADDING_TOP,
|
|
22
|
-
// width: 250,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
autoFocus: false,
|
|
26
|
-
disableAutoFocusItem: true,
|
|
27
|
-
};
|
|
28
|
-
// const useStyles = makeStyles(() => ({
|
|
29
|
-
// option: {
|
|
30
|
-
// fontSize: "10px", // Adjust the font size as needed
|
|
31
|
-
// },
|
|
32
|
-
// option2: {
|
|
33
|
-
// fontSize: "11px",
|
|
34
|
-
// },
|
|
35
|
-
// }));
|
|
36
18
|
const extractValuesToArray = (inputString) => {
|
|
37
19
|
if (!inputString)
|
|
38
20
|
return [];
|
|
39
21
|
return inputString.split(',').map((value) => value.trim()).filter(Boolean);
|
|
40
22
|
};
|
|
41
23
|
function MultiSelectV1({ props, variant, }) {
|
|
42
|
-
const [personName, setPersonName] = require$$0__default.useState(props.getValues(props.item.name) ? extractValuesToArray(props.getValues(props.item.name)) : []);
|
|
43
24
|
const [searchText, setSearchText] = useState('');
|
|
44
25
|
const options = props.item?.options || [];
|
|
45
26
|
const [filterOptions, setFilterOptions] = useState(props.item.options || []);
|
|
46
|
-
const textfieldRef =
|
|
27
|
+
const textfieldRef = useRef(null);
|
|
28
|
+
// Ref to capture the width of the Select container
|
|
29
|
+
const containerRef = useRef(null);
|
|
47
30
|
const fieldValue = useWatch({ control: props.control, name: props.item.name });
|
|
48
|
-
// Calculate selectAll state based on actual selection
|
|
49
31
|
const selectAll = useMemo(() => {
|
|
50
32
|
if (!fieldValue || filterOptions.length === 0)
|
|
51
33
|
return false;
|
|
52
34
|
const selectedValues = fieldValue.split(',').filter(Boolean);
|
|
53
35
|
return filterOptions.every((option) => selectedValues.includes(String(option.value)));
|
|
54
36
|
}, [fieldValue, filterOptions]);
|
|
55
|
-
useMemo(() => filterOptions.map((item) => item.value), [filterOptions]);
|
|
56
|
-
useMemo(() => filterOptions.map((item) => item.value), [filterOptions]);
|
|
57
37
|
require$$0__default.useEffect(() => {
|
|
58
38
|
if (searchText !== '') {
|
|
59
39
|
setFilterOptions(options.filter((item) => item.label.toLowerCase().includes(searchText.toLowerCase())));
|
|
@@ -63,90 +43,65 @@ function MultiSelectV1({ props, variant, }) {
|
|
|
63
43
|
}
|
|
64
44
|
}, [options, searchText]);
|
|
65
45
|
const handleChange = (event) => {
|
|
66
|
-
const { target: { value }
|
|
67
|
-
|
|
68
|
-
props.setValue(props.item.name,
|
|
46
|
+
const { target: { value } } = event;
|
|
47
|
+
const finalValue = typeof value === 'string' ? value.split(',') : value;
|
|
48
|
+
props.setValue(props.item.name, finalValue.join(','));
|
|
69
49
|
};
|
|
70
50
|
const selectedOptions = useMemo(() => options.filter((item) => fieldValue?.split(',').some((value) => value === item.value)), [options, fieldValue]);
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
return (jsx(Box, { children: jsxs(FormControl, { fullWidth: true, sx: {
|
|
75
|
-
'& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy': {
|
|
76
|
-
top: '-10px',
|
|
77
|
-
},
|
|
78
|
-
'& .MuiFormLabel-root': {
|
|
79
|
-
top: -10,
|
|
80
|
-
},
|
|
81
|
-
'& .MuiInputLabel-shrink': {
|
|
82
|
-
top: 0,
|
|
83
|
-
},
|
|
84
|
-
}, children: [renderLabel(variant, props), variant !== 'standard' ? (jsxs(InputLabel, { error: isShowBorderError, id: `${props.item.name}-ms-labelId`, children: [props.item.label, props.item.required ? ' *' : ''] })) : (''), jsxs(Select, { labelId: `${props.item.name}-ms-labelId`, id: `${props.item.name}-ms-select`, multiple: true, displayEmpty: true, sx: {
|
|
85
|
-
'& .MuiTypography-root': {
|
|
86
|
-
fontSize: '5px !important',
|
|
87
|
-
},
|
|
88
|
-
}, error: isShowBorderError, disabled: props.item.disable, value: fieldValue ? extractValuesToArray(fieldValue) : [], onChange: handleChange, inputProps: {
|
|
89
|
-
'aria-labelledby': `${props.item.name}-label`,
|
|
90
|
-
'aria-describedby': `${props.item.name}-helper ${props.item.name}-error`,
|
|
91
|
-
'aria-required': props.item.required ? true : undefined,
|
|
92
|
-
}, onOpen: () => {
|
|
93
|
-
setTimeout(() => {
|
|
94
|
-
if (textfieldRef.current) {
|
|
95
|
-
textfieldRef.current?.focus();
|
|
96
|
-
}
|
|
97
|
-
}, 0);
|
|
98
|
-
}, onClose: () => {
|
|
51
|
+
const selectedValuesString = selectedOptions.map((item) => item.label).join(' , ');
|
|
52
|
+
const isShowBorderError = !!props.errors?.[props.item.name];
|
|
53
|
+
return (jsx(Box, { children: jsxs(FormControl, { fullWidth: true, ref: containerRef, sx: { '& .MuiFormLabel-root': { top: -10 }, '& .MuiInputLabel-shrink': { top: 0 } }, children: [renderLabel(variant, props), variant !== 'standard' && (jsxs(InputLabel, { error: isShowBorderError, id: `${props.item.name}-ms-labelId`, children: [props.item.label, props.item.required ? ' *' : ''] })), jsxs(Select, { labelId: `${props.item.name}-ms-labelId`, id: `${props.item.name}-ms-select`, multiple: true, displayEmpty: true, error: isShowBorderError, disabled: props.item.disable, value: fieldValue ? extractValuesToArray(fieldValue) : [], onChange: handleChange, onOpen: () => setTimeout(() => textfieldRef.current?.focus(), 0), onClose: () => {
|
|
99
54
|
setSearchText('');
|
|
100
55
|
props?.item?.onCloseMenu && props?.item?.onCloseMenu();
|
|
101
|
-
}, input: jsx(OutlinedInput, { label: variant !== 'standard' ? props.item.label : '' }), renderValue: (
|
|
56
|
+
}, input: jsx(OutlinedInput, { label: variant !== 'standard' ? props.item.label : '' }), renderValue: () => (jsx(Tooltip, { title: selectedValuesString, children: jsx("span", { style: { display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: props.item.placeholder && selectedOptions.length === 0 ? (jsx("span", { style: { color: '#0009' }, children: props.item.placeholder })) : (selectedOptions.length > (props.item.multiSelectLabelLength || 3)
|
|
102
57
|
? `${selectedOptions.length} Selected`
|
|
103
|
-
:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
58
|
+
: selectedValuesString) }) })), MenuProps: {
|
|
59
|
+
PaperProps: {
|
|
60
|
+
style: {
|
|
61
|
+
maxHeight: ITEM_HEIGHT * 5.5 + ITEM_PADDING_TOP,
|
|
62
|
+
// Match the container width dynamically
|
|
63
|
+
width: containerRef.current ? containerRef.current.clientWidth : 250,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
// Using 'as const' fixes the TS2322 string incompatibility error
|
|
67
|
+
anchorOrigin: {
|
|
68
|
+
vertical: 'bottom',
|
|
69
|
+
horizontal: 'left',
|
|
70
|
+
},
|
|
71
|
+
transformOrigin: {
|
|
72
|
+
vertical: 'top',
|
|
73
|
+
horizontal: 'left',
|
|
74
|
+
},
|
|
75
|
+
autoFocus: false,
|
|
76
|
+
disableAutoFocusItem: true,
|
|
77
|
+
}, children: [jsx(Box, { sx: { width: '100%', position: 'sticky', top: 0, padding: '7px', zIndex: 2, background: '#fff' }, children: jsx(TextField, { inputRef: textfieldRef, fullWidth: true, size: "small", placeholder: "Search...", value: searchText, onChange: (e) => setSearchText(e.target.value),
|
|
78
|
+
// Prevent space key from closing the select while typing in search
|
|
79
|
+
onKeyDown: (e) => e.key !== 'Escape' && e.stopPropagation() }) }), jsxs(MenuItem, { disabled: filterOptions.length === 0, sx: { py: 0.5 }, children: [jsx(Checkbox, { size: "small", checked: selectAll, onChange: () => {
|
|
80
|
+
const currentValues = fieldValue?.split(',').filter(Boolean) || [];
|
|
81
|
+
const filteredIds = filterOptions.map((opt) => String(opt.value));
|
|
121
82
|
if (selectAll) {
|
|
122
|
-
|
|
123
|
-
const currentValues = fieldValue?.split(',').filter(Boolean) || [];
|
|
124
|
-
const filteredValues = filterOptions.map((opt) => String(opt.value));
|
|
125
|
-
const newValues = currentValues.filter((v) => !filteredValues.includes(v));
|
|
126
|
-
props.setValue(props.item.name, newValues.join(','));
|
|
83
|
+
props.setValue(props.item.name, currentValues.filter((v) => !filteredIds.includes(v)).join(','));
|
|
127
84
|
}
|
|
128
85
|
else {
|
|
129
|
-
|
|
130
|
-
const currentValues = fieldValue?.split(',').filter(Boolean) || [];
|
|
131
|
-
const filteredValues = filterOptions.map((opt) => String(opt.value));
|
|
132
|
-
const newValues = [...new Set([...currentValues, ...filteredValues])];
|
|
133
|
-
props.setValue(props.item.name, newValues.join(','));
|
|
86
|
+
props.setValue(props.item.name, [...new Set([...currentValues, ...filteredIds])].join(','));
|
|
134
87
|
}
|
|
135
|
-
} }), jsx(ListItemText, { primary:
|
|
136
|
-
fontSize: '5px !important',
|
|
137
|
-
'& span': {
|
|
138
|
-
fontSize: '12px !important',
|
|
139
|
-
},
|
|
140
|
-
} })] }), filterOptions.length !== 0 ? (filterOptions.map((option) => {
|
|
88
|
+
} }), jsx(ListItemText, { primary: "Select All", primaryTypographyProps: { fontSize: '13px' } })] }), filterOptions.length !== 0 ? (filterOptions.map((option) => {
|
|
141
89
|
const selectedArray = fieldValue ? extractValuesToArray(fieldValue) : [];
|
|
142
90
|
const isChecked = selectedArray.includes(String(option.value));
|
|
143
|
-
return (jsxs(MenuItem, { value: `${option.value}`,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
91
|
+
return (jsxs(MenuItem, { value: `${option.value}`, sx: {
|
|
92
|
+
whiteSpace: 'normal',
|
|
93
|
+
wordBreak: 'break-all',
|
|
94
|
+
alignItems: 'flex-start',
|
|
95
|
+
py: 1,
|
|
96
|
+
}, children: [jsx(Checkbox, { checked: isChecked, size: "small", sx: { mt: -0.5, mr: 1 } }), jsx(ListItemText, { primary: option.label, primaryTypographyProps: {
|
|
97
|
+
fontSize: '13px',
|
|
98
|
+
style: {
|
|
99
|
+
whiteSpace: 'normal',
|
|
100
|
+
wordBreak: 'break-all',
|
|
101
|
+
lineHeight: '1.4'
|
|
102
|
+
}
|
|
148
103
|
} })] }, option.value));
|
|
149
|
-
})) : (jsx(MenuItem, { disabled: true,
|
|
104
|
+
})) : (jsx(MenuItem, { disabled: true, children: "No data Found" }))] }), jsx(FormBottomField, { ...props })] }) }, props.item.name));
|
|
150
105
|
}
|
|
151
106
|
|
|
152
107
|
export { MultiSelectV1 as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as Calendar } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as Calendar } from '../../../../../_virtual/index.esm7.js';
|
|
2
2
|
import require$$0__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDayCell } from '../DayCell/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DateRange } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DateRange } from '../../../../../_virtual/index.esm5.js';
|
|
2
2
|
import require$$0__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireCalendar } from '../Calendar/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DateRangePicker } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DateRangePicker } from '../../../../../_virtual/index.esm4.js';
|
|
2
2
|
import require$$0__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDateRange } from '../DateRange/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DefinedRange } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DefinedRange } from '../../../../../_virtual/index.esm6.js';
|
|
2
2
|
import require$$0__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireStyles } from '../../styles.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as InputRangeField } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as InputRangeField } from '../../../../../_virtual/index.esm12.js';
|
|
2
2
|
import require$$0__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as Month } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as Month } from '../../../../../_virtual/index.esm14.js';
|
|
2
2
|
import require$$0__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDayCell } from '../DayCell/index.esm.js';
|