tp-react-elements-dev 1.12.35 → 1.13.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.
@@ -12,6 +12,7 @@ const useFormValidatingContext = (formArray) => {
12
12
  formArray.forEach((field) => {
13
13
  switch (field.inputType) {
14
14
  case 'text':
15
+ case 'input-select':
15
16
  initialValues[field.name] = '';
16
17
  if (field.required && field.errorMessage) {
17
18
  validationShape[field.name] = (validationShape[field.name] || Yup.string())
@@ -21,7 +21,7 @@ const FormRenderWrapper = ({ formArray, name = '', numberOfColumns = 3, form, va
21
21
  * Maps through the form array and renders each item with appropriate configuration
22
22
  */
23
23
  return (jsx(FormComponent, { container: true, margin: 'auto', children: formArray.map((item, i) => {
24
- return (item.inputType && (jsx(Formitem, { container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns, children: item.inputType === 'custom' ? (item.FormElement || jsx(Fragment, {})) : (jsx(RenderForm, { item: item, register: form.register, control: form.control, errors: errors, getValues: form.getValues, clearErrors: form.clearErrors, setValue: form.setValue, variant: variant, fieldError: fieldError })) }, `${name}_${i}`)));
24
+ return (item.inputType && (jsx(Formitem, { container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns, children: item.inputType === 'custom' ? (item.FormElement || jsx(Fragment, {})) : (jsx(RenderForm, { item: item, register: form.register, control: form.control, errors: errors, getValues: form.getValues, clearErrors: form.clearErrors, setValue: form.setValue, watch: form.watch, variant: variant, fieldError: fieldError })) }, `${name}_${i}`)));
25
25
  }) }));
26
26
  };
27
27
  /**
@@ -46,11 +46,10 @@ const FormTextFieldWithSelect = ({ props, variant, }) => {
46
46
  * For non-standard variants, appends an asterisk if the field is required
47
47
  */
48
48
  const label = variant !== 'standard' ? `${props.item.label}${props.item.required ? ' *' : ''}` : '';
49
- const SelectValue = props.getValues(props.item.name + 'SelectValue');
50
49
  /**
51
50
  * Handles input events with various text restrictions
52
51
  *
53
- * @param {any} e - The input event object
52
+ * @param {React.ChangeEvent<HTMLInputElement>} e - The input event object
54
53
  *
55
54
  * @remarks
56
55
  * - Removes spaces if donotAllowSpace is true
@@ -88,19 +87,16 @@ const FormTextFieldWithSelect = ({ props, variant, }) => {
88
87
  'aria-labelledby': `${props.item.name}-label`,
89
88
  'aria-describedby': `${props.item.name}-helper ${props.item.name}-error`,
90
89
  '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));
90
+ } }), jsx(Controller, { control: props.control, name: `${props.item.name}SelectValue`, render: ({ field: selectField }) => (jsx(Select, { ...selectField, value: selectField.value || '', size: "small", sx: {
91
+ // '& .MuiOutlinedInput-root': {
92
+ borderTopLeftRadius: 0,
93
+ borderBottomLeftRadius: 0,
94
+ minWidth: '120px',
95
+ borderLeft: 'none',
96
+ // },
97
+ }, disabled: props.item.disable, error: !!fieldState.error, children: props?.item?.options?.map((item) => {
98
+ return (jsx(MenuItem, { value: item.value, children: item.label }, item.value));
99
+ }) })) })] }), jsx(FormBottomField, { ...props })] })) }, props.item.name));
104
100
  };
105
101
 
106
102
  export { FormTextFieldWithSelect as default };
@@ -73,6 +73,7 @@ export interface FormRenderProps {
73
73
  getValues: any;
74
74
  clearErrors: any;
75
75
  setValue: any;
76
+ watch?: any;
76
77
  variant?: VariantProps;
77
78
  fieldError?: boolean;
78
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tp-react-elements-dev",
3
- "version": "1.12.35",
3
+ "version": "1.13.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "React form components library built with React Hook Form and Yup",