tp-react-elements 1.2.8 → 1.2.10

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.
@@ -1,3 +1,3 @@
1
- var DateInput = {};
1
+ var Month = {};
2
2
 
3
- export { DateInput as __exports };
3
+ export { Month as __exports };
@@ -1,3 +1,3 @@
1
- var Month = {};
1
+ var DateInput = {};
2
2
 
3
- export { Month as __exports };
3
+ export { DateInput as __exports };
@@ -1,3 +1,3 @@
1
- var Calendar = {};
1
+ var DateRange = {};
2
2
 
3
- export { Calendar as __exports };
3
+ export { DateRange as __exports };
@@ -1,3 +1,3 @@
1
- var DateRange = {};
1
+ var Calendar = {};
2
2
 
3
- export { DateRange as __exports };
3
+ export { Calendar as __exports };
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
3
  import { Controller } from 'react-hook-form';
4
4
  import { d as distExports } from '../../_virtual/index.esm.js';
5
- import 'dayjs';
5
+ import dayjs from 'dayjs';
6
6
  import { renderLabel } from '../../utils/Constants/FormConstants.esm.js';
7
7
  import FormBottomField from '../FormComponents/FormBottomField/FormBottomField.esm.js';
8
8
  import { Box, TextField, Popover } from '@mui/material';
@@ -89,12 +89,19 @@ const DateRangePickerComponent = ({ item, control, watch, setValue, getValues, c
89
89
  if (selection.startDate &&
90
90
  selection.endDate &&
91
91
  selection.startDate?.getTime() !== selection.endDate?.getTime()) {
92
- const dateObject = { startDate: format(selection.startDate, 'dd/MM/yyyy'), endDate: format(selection.endDate, 'dd/MM/yyyy') };
92
+ const dateObject = {
93
+ startDate: format(selection.startDate, 'dd/MM/yyyy'),
94
+ endDate: format(selection.endDate, 'dd/MM/yyyy'),
95
+ };
93
96
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
94
97
  item.onChangeFn && item.onChangeFn(dateObject || null);
95
98
  handleClose();
96
99
  }
97
- }, moveRangeOnFirstSelection: false, ranges: state, months: 2, direction: "horizontal", showDateDisplay: false, dateDisplayFormat: "dd/MM/yyyy", rangeColors: ['#4d73b1ff'] }) }), jsx(FormBottomField, { item,
100
+ }, moveRangeOnFirstSelection: false, ranges: state, minDate: item?.minDate
101
+ ? dayjs(item?.minDate, item.DateFormat || 'DD/MM/YYYY').toDate()
102
+ : undefined, maxDate: item?.maxDate
103
+ ? dayjs(item?.maxDate, item.DateFormat || 'DD/MM/YYYY').toDate()
104
+ : undefined, months: 2, direction: "horizontal", showDateDisplay: false, dateDisplayFormat: "dd/MM/yyyy", rangeColors: ['#4d73b1ff'] }) }), jsx(FormBottomField, { item,
98
105
  control,
99
106
  errors,
100
107
  getValues,
@@ -129,6 +129,7 @@ const useFormValidatingContext = (formArray) => {
129
129
  renderCustomError(field);
130
130
  break;
131
131
  case 'number':
132
+ case 'decimal':
132
133
  initialValues[field.name] = null;
133
134
  if (field.required && field.errorMessage) {
134
135
  validationShape[field.name] = (validationShape[field.name] || Yup.number())
@@ -21,9 +21,9 @@ const FormNumberFieldDecimal = ({ props, variant, }) => {
21
21
  const label = variant !== 'standard' ? `${props.item.label}${props.item.required ? ' *' : ''}` : '';
22
22
  const isError = !!props.errors?.[props.item.name];
23
23
  const isShowBorderError = isError;
24
- return (jsx(Controller, { name: props.item.name, control: props.control, disabled: props.item?.disable, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(TextField, { type: "text", size: "small", label: label, error: isShowBorderError, ...field, onChange: (e) => {
24
+ return (jsx(Controller, { name: props.item.name, control: props.control, disabled: props.item?.disable, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(TextField, { type: "text", size: "small", label: label, error: isShowBorderError, ...field, value: field.value ?? '', onChange: (e) => {
25
25
  const sanitized = sanitizeDecimal(e.target.value ?? '');
26
- const value = sanitized === '' ? '' : sanitized;
26
+ const value = sanitized === '' ? null : sanitized;
27
27
  field.onChange(value);
28
28
  props?.clearErrors && props?.clearErrors(props.item.name);
29
29
  }, sx: {
@@ -22,23 +22,21 @@ import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
22
22
  * <FormTextAreaField props={formRenderProps} variant="outlined" />
23
23
  */
24
24
  const FormTextAreaField = ({ props, variant, }) => {
25
- /**
26
- * Determines if the field has an error based on form validation
27
- */
28
- const isError = !!props.errors?.[props.item.name];
29
- const isShowBorderError = isError;
30
25
  /**
31
26
  * Renders the textarea component with validation support
32
27
  */
33
- return (jsx(Fragment, { children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Tooltip, { title: props.item.isTooltipEnable ? (field.value || '') : '', placement: "bottom-start", children: jsxs(Box, { sx: { width: '100%', position: 'relative' }, children: [jsx(TextAreaField, { multiline: true, size: "small", InputProps: {
28
+ return (jsx(Fragment, { children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field, fieldState }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Tooltip, { title: props.item.isTooltipEnable ? field.value || '' : '', placement: "bottom-start", children: jsxs(Box, { sx: { width: '100%', position: 'relative' }, children: [jsx(TextAreaField, { multiline: true, size: "small", InputProps: {
34
29
  style: {
35
30
  border: 'none',
36
31
  },
37
32
  }, sx: {
38
33
  ...props.item.sx,
39
- }, minRows: props.item.minRows || 1, maxRows: props.item.maxRows || 100, placeholder: props.item.placeholder || 'Type Something...', ...field, label: variant !== 'standard'
34
+ }, minRows: props.item.minRows || 1, maxRows: props.item.maxRows || 100, placeholder: props.item.placeholder || 'Type Something...', ...field, onChange: (e) => {
35
+ field.onChange(e);
36
+ props?.clearErrors && props?.clearErrors(props.item.name);
37
+ }, label: variant !== 'standard'
40
38
  ? `${props.item.label}${props.item.required ? ' *' : ''}`
41
- : '', error: isShowBorderError, value: field.value || '', disabled: props.item.disable, inputProps: {
39
+ : '', error: !!fieldState.error, value: field.value || '', disabled: props.item.disable, inputProps: {
42
40
  /**
43
41
  * Handles input events with text restrictions
44
42
  *
@@ -46,46 +46,46 @@ const PasswordField = ({ props, variant }) => {
46
46
  /**
47
47
  * Renders the password field component with visibility toggle
48
48
  */
49
- return (jsx(Box, { position: 'relative', children: jsx(FormControl, { fullWidth: true, children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [jsxs(Box, { sx: { position: 'relative' }, children: [renderLabel(variant, props), jsx(TextField, { size: "small", error: isShowBorderError, type: showPassword ? 'text' : 'password', autoComplete: props.item?.InputProps?.autoComplete || 'off', placeholder: props.item.placeholder || '', ...field, label: label, sx: {
50
- width: '100%',
51
- '& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy': {
52
- top: '-8px',
53
- },
54
- }, inputProps: {
55
- maxLength: props.item.maxLength || 100,
56
- /**
57
- * Handles input events
58
- * Calls custom onInputProps handler if provided
59
- *
60
- * @param {any} e - The input event object
61
- */
62
- onInput: (e) => {
63
- props.item.onInputProps && props.item.onInputProps(e);
64
- },
65
- /**
66
- * Handles paste events
67
- * Prevents paste action if configured
68
- *
69
- * @param {React.ClipboardEvent} e - The paste event object
70
- */
71
- onPaste: (e) => {
72
- if (props.item?.doNotAllowPaste) {
73
- e.preventDefault();
74
- }
75
- },
76
- }, value: field.value || null, disabled: props.item.disable }), jsx(IconButton, { sx: {
77
- position: 'absolute',
78
- right: '14px',
79
- top: variant === 'standard' ? '70%' : '50%',
80
- transform: 'translateY(-50%)',
81
- width: '25px',
82
- }, "aria-label": showPassword ? 'Hide password' : 'Show password', "aria-pressed": showPassword, onClick: handleTogglePasswordVisibility, edge: "end", children: showPassword ? (jsx(Visibility, { sx: {
83
- fontSize: '12px',
84
- position: 'absolute',
85
- } })) : (jsx(VisibilityOff, { sx: {
86
- fontSize: '12px',
87
- position: 'absolute',
88
- } })) })] }), jsx(FormBottomField, { ...props })] })) }) }) }, props.item.name));
49
+ return (jsx(Box, { position: 'relative', children: jsx(FormControl, { fullWidth: true, children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(TextField, { size: "small", error: isShowBorderError, type: showPassword ? 'text' : 'password', autoComplete: props.item?.InputProps?.autoComplete || 'off', placeholder: props.item.placeholder || '', ...field, label: label, sx: {
50
+ width: '100%',
51
+ '& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy': {
52
+ top: '-8px',
53
+ },
54
+ }, inputProps: {
55
+ maxLength: props.item.maxLength || 100,
56
+ /**
57
+ * Handles input events
58
+ * Calls custom onInputProps handler if provided
59
+ *
60
+ * @param {any} e - The input event object
61
+ */
62
+ onInput: (e) => {
63
+ props.item.onInputProps && props.item.onInputProps(e);
64
+ },
65
+ /**
66
+ * Handles paste events
67
+ * Prevents paste action if configured
68
+ *
69
+ * @param {React.ClipboardEvent} e - The paste event object
70
+ */
71
+ onPaste: (e) => {
72
+ if (props.item?.doNotAllowPaste) {
73
+ e.preventDefault();
74
+ }
75
+ },
76
+ }, value: field.value || null, disabled: props.item.disable }), jsx(IconButton, { sx: {
77
+ position: 'absolute',
78
+ right: '14px',
79
+ top: variant === 'standard' ? '65%' : '45%',
80
+ transform: 'translateY(-50%)',
81
+ width: '25px',
82
+ }, "aria-label": showPassword ? 'Hide password' : 'Show password', "aria-pressed": showPassword, onClick: handleTogglePasswordVisibility, edge: "end", children: showPassword ? (jsx(Visibility, { sx: {
83
+ fontSize: '12px',
84
+ position: 'absolute',
85
+ } })) : (jsx(VisibilityOff, { sx: {
86
+ fontSize: '12px',
87
+ position: 'absolute',
88
+ } })) }), jsx(FormBottomField, { ...props })] })) }) }) }, props.item.name));
89
89
  };
90
90
 
91
91
  export { PasswordField as default };
@@ -1,4 +1,4 @@
1
- import { __exports as Calendar } from '../../../../../_virtual/index.esm4.js';
1
+ import { __exports as Calendar } from '../../../../../_virtual/index.esm6.js';
2
2
  import React__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 DateInput } from '../../../../../_virtual/index.esm13.js';
1
+ import { __exports as DateInput } from '../../../../../_virtual/index.esm14.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireClassnames } from '../../../../classnames/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DateRange } from '../../../../../_virtual/index.esm6.js';
1
+ import { __exports as DateRange } from '../../../../../_virtual/index.esm4.js';
2
2
  import React__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 Month } from '../../../../../_virtual/index.esm14.js';
1
+ import { __exports as Month } from '../../../../../_virtual/index.esm13.js';
2
2
  import React__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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tp-react-elements",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "React form components library built with React Hook Form and Yup",