tp-react-elements-dev 1.12.33 → 1.12.35
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/assets/icons/flaticon_hvc.css +195 -195
- package/dist/assets/icons/flaticon_hvc.scss +243 -243
- package/dist/components/Form/FormRender.esm.js +3 -0
- package/dist/components/FormComponents/FileUpload/MultiFileWithPreview.esm.js +43 -19
- package/dist/components/FormComponents/FormTextFieldWithSelect/FormTextFieldWithSelect.d.ts +43 -0
- package/dist/components/FormComponents/FormTextFieldWithSelect/FormTextFieldWithSelect.esm.js +106 -0
- package/dist/components/FormComponents/index.esm.js +3 -0
- package/dist/components/Global.styles.esm.js +64 -64
- package/dist/components/TextFieldWithSelect/index.d.ts +1 -0
- package/dist/components/TextFieldWithSelect/index.esm.js +1 -0
- package/dist/utils/Interface/FormInterface.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Controller } from 'react-hook-form';
|
|
3
|
+
import FormBottomField from '../FormBottomField/FormBottomField.esm.js';
|
|
4
|
+
import 'dayjs';
|
|
5
|
+
import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
|
|
6
|
+
import { Box, TextField, Select, MenuItem } from '@mui/material';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* FormTextField Component
|
|
10
|
+
*
|
|
11
|
+
* A text input field component that integrates with react-hook-form for form state management.
|
|
12
|
+
* This component is used for standard text inputs, email inputs, and multi-email inputs.
|
|
13
|
+
*
|
|
14
|
+
* @component
|
|
15
|
+
* @param {Object} props - The component props
|
|
16
|
+
* @param {FormRenderProps} props.props - Form rendering properties from parent form
|
|
17
|
+
* @param {VariantProps} props.variant - UI variant style ('standard', 'outlined', etc.)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Basic usage in FormRender
|
|
21
|
+
* <FormTextField props={formRenderProps} variant="outlined" />
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Usage with specific configuration
|
|
25
|
+
* const formItem = {
|
|
26
|
+
* name: "email",
|
|
27
|
+
* label: "Email Address",
|
|
28
|
+
* inputType: "email",
|
|
29
|
+
* required: true,
|
|
30
|
+
* placeholder: "Enter your email"
|
|
31
|
+
* };
|
|
32
|
+
* <FormTextField
|
|
33
|
+
* props={{
|
|
34
|
+
* item: formItem,
|
|
35
|
+
* control: formMethods.control,
|
|
36
|
+
* errors: formMethods.formState.errors
|
|
37
|
+
* }}
|
|
38
|
+
* variant="outlined"
|
|
39
|
+
* />
|
|
40
|
+
*/
|
|
41
|
+
const FormTextFieldWithSelect = ({ props, variant, }) => {
|
|
42
|
+
// Using fieldState.error directly from Controller render; no local isError needed
|
|
43
|
+
// Removed fieldError gating: error border now shows whenever there is a validation error
|
|
44
|
+
/**
|
|
45
|
+
* Generates the field label based on variant type
|
|
46
|
+
* For non-standard variants, appends an asterisk if the field is required
|
|
47
|
+
*/
|
|
48
|
+
const label = variant !== 'standard' ? `${props.item.label}${props.item.required ? ' *' : ''}` : '';
|
|
49
|
+
const SelectValue = props.getValues(props.item.name + 'SelectValue');
|
|
50
|
+
/**
|
|
51
|
+
* Handles input events with various text restrictions
|
|
52
|
+
*
|
|
53
|
+
* @param {any} e - The input event object
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* - Removes spaces if donotAllowSpace is true
|
|
57
|
+
* - Removes special characters if allowSpecialChars is false
|
|
58
|
+
* - Prevents input that starts with a space
|
|
59
|
+
* - Calls custom onInputProps handler if provided
|
|
60
|
+
*/
|
|
61
|
+
const onInput = (e) => {
|
|
62
|
+
const filteredValue = e.target.value.replace(/[^a-zA-Z0-9.]/g, '');
|
|
63
|
+
e.target.value = filteredValue;
|
|
64
|
+
props.item.onInputProps && props.item.onInputProps(e);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Renders the text field component using react-hook-form's Controller
|
|
68
|
+
* for controlled form state management
|
|
69
|
+
*/
|
|
70
|
+
return (jsx(Controller, { control: props.control, name: props.item.name, render: ({ field, fieldState }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsxs(Box, { sx: { display: 'flex', width: '100%' }, children: [jsx(TextField, { ...field, fullWidth: true, autoFocus: props.item.autoFocus, error: !!fieldState.error, label: label, placeholder: props.item.placeholder || '', autoComplete: "off", sx: {
|
|
71
|
+
...props.item.sx,
|
|
72
|
+
'& .MuiOutlinedInput-root': {
|
|
73
|
+
borderTopRightRadius: 0,
|
|
74
|
+
borderBottomRightRadius: 0,
|
|
75
|
+
borderRight: 'none',
|
|
76
|
+
},
|
|
77
|
+
}, value: field.value || '', size: "small", disabled: props.item.disable, onBlur: (e) => {
|
|
78
|
+
props?.item?.onBlurFn && props?.item?.onBlurFn(e);
|
|
79
|
+
}, inputProps: {
|
|
80
|
+
...{
|
|
81
|
+
maxLength: props.item.maxLength || 100,
|
|
82
|
+
onInput: onInput,
|
|
83
|
+
onPaste: (e) => {
|
|
84
|
+
if (props.item.doNotAllowPaste)
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
'aria-labelledby': `${props.item.name}-label`,
|
|
89
|
+
'aria-describedby': `${props.item.name}-helper ${props.item.name}-error`,
|
|
90
|
+
'aria-required': props.item.required ? true : undefined,
|
|
91
|
+
} }), jsx(Select, { value: SelectValue, onChange: (_, newValue) => {
|
|
92
|
+
// eslint-disable-next-line react/prop-types
|
|
93
|
+
props.setValue(props.item.name + 'SelectValue', newValue);
|
|
94
|
+
}, size: "small", sx: {
|
|
95
|
+
// '& .MuiOutlinedInput-root': {
|
|
96
|
+
borderTopLeftRadius: 0,
|
|
97
|
+
borderBottomLeftRadius: 0,
|
|
98
|
+
minWidth: '120px',
|
|
99
|
+
borderLeft: 'none',
|
|
100
|
+
// },
|
|
101
|
+
}, disabled: props.item.disable, error: !!fieldState.error, children: props?.item?.options?.map((item) => {
|
|
102
|
+
return jsx(MenuItem, { value: item.value, children: item.label });
|
|
103
|
+
}) })] }), jsx(FormBottomField, { ...props })] })) }, props.item.name));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { FormTextFieldWithSelect as default };
|
|
@@ -29,6 +29,9 @@ import '@mui/icons-material/NavigateBefore';
|
|
|
29
29
|
import '@mui/icons-material/NavigateNext';
|
|
30
30
|
import '@mui/icons-material/Delete';
|
|
31
31
|
import '@mui/icons-material/UploadFile';
|
|
32
|
+
import '@mui/icons-material/PictureAsPdf';
|
|
33
|
+
import '@mui/icons-material/TableChart';
|
|
34
|
+
import '@mui/icons-material/Description';
|
|
32
35
|
export { default as RichTextEditor } from './RichTextEditor/RichTextEditor.esm.js';
|
|
33
36
|
export { default as RichTextEditorWrapper } from './RichTextEditor/RichTextEditorWrapper.esm.js';
|
|
34
37
|
export { default as FormErrorField } from './FormErrorField/FormErrorField.esm.js';
|
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
import { styled } from '@mui/material/styles';
|
|
2
2
|
import { Button, Typography, Grid, Dialog, DialogTitle } from '@mui/material';
|
|
3
3
|
|
|
4
|
-
styled(Button) `
|
|
5
|
-
border: 0;
|
|
6
|
-
color: #fff;
|
|
7
|
-
position: absolute;
|
|
8
|
-
text-align: center;
|
|
9
|
-
padding: 5px 12px;
|
|
10
|
-
font-size: 13px;
|
|
11
|
-
height: 30px;
|
|
12
|
-
right: -38px;
|
|
13
|
-
text-transform: none;
|
|
14
|
-
z-index: 2;
|
|
15
|
-
border-radius: 10px 0px 0px 10px;
|
|
16
|
-
&:hover {
|
|
17
|
-
right: 0px;
|
|
18
|
-
}
|
|
4
|
+
styled(Button) `
|
|
5
|
+
border: 0;
|
|
6
|
+
color: #fff;
|
|
7
|
+
position: absolute;
|
|
8
|
+
text-align: center;
|
|
9
|
+
padding: 5px 12px;
|
|
10
|
+
font-size: 13px;
|
|
11
|
+
height: 30px;
|
|
12
|
+
right: -38px;
|
|
13
|
+
text-transform: none;
|
|
14
|
+
z-index: 2;
|
|
15
|
+
border-radius: 10px 0px 0px 10px;
|
|
16
|
+
&:hover {
|
|
17
|
+
right: 0px;
|
|
18
|
+
}
|
|
19
19
|
`;
|
|
20
|
-
const SubmitButton = styled(Button) `
|
|
21
|
-
text-transform: none;
|
|
20
|
+
const SubmitButton = styled(Button) `
|
|
21
|
+
text-transform: none;
|
|
22
22
|
`;
|
|
23
|
-
const CancelButton = styled(Button) `
|
|
24
|
-
text-transform: none;
|
|
25
|
-
color: #000;
|
|
26
|
-
background: #ececee;
|
|
27
|
-
&:hover {
|
|
28
|
-
background: #0009;
|
|
29
|
-
color: #fff;
|
|
30
|
-
}
|
|
23
|
+
const CancelButton = styled(Button) `
|
|
24
|
+
text-transform: none;
|
|
25
|
+
color: #000;
|
|
26
|
+
background: #ececee;
|
|
27
|
+
&:hover {
|
|
28
|
+
background: #0009;
|
|
29
|
+
color: #fff;
|
|
30
|
+
}
|
|
31
31
|
`;
|
|
32
|
-
const SaveAsDraftButton = styled(Button) `
|
|
33
|
-
text-transform: none;
|
|
34
|
-
font-size: 12px;
|
|
35
|
-
background: orange;
|
|
36
|
-
&:hover {
|
|
37
|
-
background: orange;
|
|
38
|
-
}
|
|
32
|
+
const SaveAsDraftButton = styled(Button) `
|
|
33
|
+
text-transform: none;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
background: orange;
|
|
36
|
+
&:hover {
|
|
37
|
+
background: orange;
|
|
38
|
+
}
|
|
39
39
|
`;
|
|
40
40
|
styled(Typography) ``;
|
|
41
41
|
styled(Grid, {
|
|
42
42
|
shouldForwardProp: (prop) => prop !== 'isActive' && prop !== 'noOfColumn',
|
|
43
|
-
}) `
|
|
44
|
-
flex-direction: column;
|
|
45
|
-
margin-bottom: 8px;
|
|
46
|
-
min-width: 10%;
|
|
47
|
-
padding-left: 0px;
|
|
48
|
-
z-index: 2;
|
|
49
|
-
padding-right: 0px;
|
|
50
|
-
border: 1px solid #0003;
|
|
51
|
-
font-size: 12px;
|
|
52
|
-
padding: 6px;
|
|
53
|
-
text-align: center;
|
|
54
|
-
&:hover {
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
}
|
|
43
|
+
}) `
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
margin-bottom: 8px;
|
|
46
|
+
min-width: 10%;
|
|
47
|
+
padding-left: 0px;
|
|
48
|
+
z-index: 2;
|
|
49
|
+
padding-right: 0px;
|
|
50
|
+
border: 1px solid #0003;
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
padding: 6px;
|
|
53
|
+
text-align: center;
|
|
54
|
+
&:hover {
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
}
|
|
57
57
|
`;
|
|
58
|
-
const DialogContainer = styled(Dialog) `
|
|
59
|
-
position: fixed;
|
|
60
|
-
top: -16px;
|
|
61
|
-
left: 0;
|
|
62
|
-
right: 0;
|
|
63
|
-
bottom: auto;
|
|
64
|
-
& .css-tlc64q-MuiPaper-root-MuiDialog-paper,
|
|
65
|
-
.css-mbdu2s {
|
|
66
|
-
max-width: 900px;
|
|
67
|
-
}
|
|
58
|
+
const DialogContainer = styled(Dialog) `
|
|
59
|
+
position: fixed;
|
|
60
|
+
top: -16px;
|
|
61
|
+
left: 0;
|
|
62
|
+
right: 0;
|
|
63
|
+
bottom: auto;
|
|
64
|
+
& .css-tlc64q-MuiPaper-root-MuiDialog-paper,
|
|
65
|
+
.css-mbdu2s {
|
|
66
|
+
max-width: 900px;
|
|
67
|
+
}
|
|
68
68
|
`;
|
|
69
|
-
const DialogTitleWrapper = styled(DialogTitle) `
|
|
70
|
-
padding: 8px 16px;
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: space-between;
|
|
74
|
-
font-size: 14px;
|
|
75
|
-
cursor: move;
|
|
76
|
-
border-bottom: 1px solid rgb(229 231 235 / 1);
|
|
69
|
+
const DialogTitleWrapper = styled(DialogTitle) `
|
|
70
|
+
padding: 8px 16px;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: space-between;
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
cursor: move;
|
|
76
|
+
border-bottom: 1px solid rgb(229 231 235 / 1);
|
|
77
77
|
`;
|
|
78
78
|
|
|
79
79
|
export { CancelButton, DialogContainer, DialogTitleWrapper, SaveAsDraftButton, SubmitButton };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormTextFieldWithSelect } from '../FormComponents/FormTextFieldWithSelect/FormTextFieldWithSelect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FormTextFieldWithSelect } from '../FormComponents/FormTextFieldWithSelect/FormTextFieldWithSelect.esm.js';
|
|
@@ -10,7 +10,7 @@ export interface TextFieldInputProps {
|
|
|
10
10
|
export interface FormSectionPropsItem {
|
|
11
11
|
name: string;
|
|
12
12
|
label: string;
|
|
13
|
-
inputType: 'text' | 'password' | 'number' | 'select' | 'autocomplete-select' | 'autocomplete-multi-select' | 'datepicker' | 'multiselect' | 'select-v2' | 'basic-select' | 'decimal' | 'alpha-numerical' | 'yearpicker' | 'dateRangePicker' | 'monthpicker' | 'multiselect' | 'file' | 'multifile' | 'multifile-with-preview' | 'textarea' | 'phoneNumber' | 'pincode' | 'email' | 'toggleSwitch' | 'rich-text-editor' | 'multiEmail' | 'timepicker' | 'checkbox-group' | 'radio-group' | 'checkbox' | 'custom' | '';
|
|
13
|
+
inputType: 'text' | 'password' | 'number' | 'select' | 'autocomplete-select' | 'autocomplete-multi-select' | 'datepicker' | 'multiselect' | 'select-v2' | 'basic-select' | 'decimal' | 'alpha-numerical' | 'yearpicker' | 'dateRangePicker' | 'monthpicker' | 'multiselect' | 'file' | 'multifile' | 'multifile-with-preview' | 'textarea' | 'phoneNumber' | 'pincode' | 'email' | 'toggleSwitch' | 'rich-text-editor' | 'multiEmail' | 'timepicker' | 'checkbox-group' | 'radio-group' | 'checkbox' | 'custom' | 'input-select' | '';
|
|
14
14
|
options?: OptionsProps[];
|
|
15
15
|
required?: boolean;
|
|
16
16
|
errorMessage?: string;
|