react-core-ts 1.1.31 → 1.1.32

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,9 +1,9 @@
1
- import { TextAreaProps } from './commontypes'
2
- import React, { useEffect, useRef, useState } from 'react'
1
+ import React, { useEffect, useRef, useState } from 'react';
3
2
 
4
- import { getInnerWidth } from './utilities/generateInnerWidth'
5
- import CustomIcons from './components/customIcons'
6
- import { applyPositionClass } from './utilities/getPosition'
3
+ import { TextAreaProps } from './commontypes';
4
+ import CustomIcons from './components/customIcons';
5
+ import { getInnerWidth } from './utilities/generateInnerWidth';
6
+ import { applyPositionClass } from './utilities/getPosition';
7
7
 
8
8
  const ModernTextArea: React.FC<TextAreaProps> = ({
9
9
  name,
@@ -26,13 +26,13 @@ const ModernTextArea: React.FC<TextAreaProps> = ({
26
26
  errors,
27
27
  onChange,
28
28
  value,
29
- hideLabel = false
29
+ hideLabel = false,
30
30
  }) => {
31
31
  // const [editState, setEditState] = useState<boolean>(false)
32
- const [isDisabled, setIsDisabled] = useState<boolean>(disabled)
33
- const [isHovered, setIsHovered] = useState<boolean>(false)
34
- const inputRef = useRef<HTMLInputElement>(null)
35
- const adorementRef = useRef<HTMLDivElement>(null)
32
+ const [isDisabled, setIsDisabled] = useState<boolean>(disabled);
33
+ const [isHovered, setIsHovered] = useState<boolean>(false);
34
+ const inputRef = useRef<HTMLInputElement>(null);
35
+ const adorementRef = useRef<HTMLDivElement>(null);
36
36
  // const onEditIconClick = () => {
37
37
  // setEditState(true)
38
38
  // setIsDisabled(false)
@@ -58,86 +58,94 @@ const ModernTextArea: React.FC<TextAreaProps> = ({
58
58
  // }, [editState, name])
59
59
  const onLabelClick = () => {
60
60
  if (!isDisabled) {
61
- inputRef?.current?.focus()
61
+ inputRef?.current?.focus();
62
62
  }
63
- }
63
+ };
64
64
 
65
65
  const checkIsEmptyField = (): boolean => {
66
- if (value === undefined) return true
67
- else return (value?.toString().length ?? 0) <= 0 ? true : false
68
- }
66
+ if (value === undefined) return true;
67
+ else return (value?.toString().length ?? 0) <= 0 ? true : false;
68
+ };
69
69
  useEffect(() => {
70
- setIsDisabled(disabled)
71
- }, [disabled])
70
+ setIsDisabled(disabled);
71
+ }, [disabled]);
72
72
  const getErrors = (err: any) => {
73
- let errMsg = ''
73
+ let errMsg = '';
74
74
  if (err.message) {
75
- errMsg = err?.message
75
+ errMsg = err?.message;
76
76
  }
77
- return errMsg
78
- }
77
+ return errMsg;
78
+ };
79
79
  const generateClassName = (
80
80
  type: 'input' | 'label' | 'message' | 'adorement'
81
81
  ): string => {
82
82
  let className = `resize-none ${propsClassName}`;
83
83
  switch (type) {
84
84
  case 'input':
85
- className += ` block text-common text-input-text font-normal px-3.5 py-2 w-full text-sm text-gray-900 bg-transparent border appearance-none focus:outline-none focus:ring-0 peer rounded-[4px] disabled:text-input-disabled disabled:bg-disabled ${hideLabel ? '' : 'placeholder-transparent'} focus:placeholder-grey-secondary`
85
+ className += ` block text-common text-input-text font-normal px-3.5 py-2 w-full text-sm text-gray-900 bg-transparent border appearance-none focus:outline-none focus:ring-0 peer rounded-[4px] disabled:text-input-disabled disabled:bg-disabled ${
86
+ hideLabel ? '' : 'placeholder-transparent'
87
+ } focus:placeholder-grey-secondary`;
86
88
  if (errors && errors[name]) {
87
89
  className +=
88
- ' border-[#FDA29B] focus:border-error-[#FDA29B] focus:ring-[#FDA29B] focus:ring-3 '
90
+ ' border-[#FDA29B] focus:border-error-[#FDA29B] focus:ring-[#FDA29B] focus:ring-3 ';
89
91
  } else {
90
92
  className +=
91
- ' text-grey-dark border-input-light focus:border-blue-navy focus:outline-none focus:ring-0'
93
+ ' text-grey-dark border-input-light focus:border-blue-navy focus:outline-none focus:ring-0';
92
94
  }
93
- break
95
+ break;
94
96
  case 'label':
95
97
  className += ` modern-input-label peer-focus:modern-input-peer-focus-label-size
96
98
  px-0
97
99
  absolute text-sm duration-300 transform -translate-y-4 top-2 z-1 origin-[0] peer-placeholder-shown:-translate-y-1 peer-placeholder-shown:top-[16px] peer-focus:top-2 peer-focus:-translate-y-4 start-[14px] rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto ${
98
- isDisabled ? 'cursor-pointer' : 'cursor-text peer-focus:cursor-pointer'
100
+ isDisabled
101
+ ? 'cursor-pointer'
102
+ : 'cursor-text peer-focus:cursor-pointer'
99
103
  } ${!isDisabled || !checkIsEmptyField() ? 'bg-white' : ''} ${
100
- checkIsEmptyField()
101
- ? 'modern-input-label-size'
102
- : 'modern-input-peer-focus-label-size'
103
- } `
104
+ checkIsEmptyField()
105
+ ? 'modern-input-label-size'
106
+ : 'modern-input-peer-focus-label-size'
107
+ } `;
104
108
  if (errors && errors[name]) {
105
- className += ' text-error-light '
109
+ className += ' text-error-light ';
106
110
  } else {
107
- className += ' text-grey-dark peer-focus:text-blue-navy'
111
+ className += ' text-grey-dark peer-focus:text-blue-navy';
108
112
  }
109
- break
113
+ break;
110
114
  case 'message':
111
- className = ' text-error-icon '
112
- break
115
+ className = ' text-error-icon ';
116
+ break;
113
117
  case 'adorement':
114
- className += ' absolute right-0 py-4 adorement gap-1 flex items-center '
115
- break
118
+ className +=
119
+ ' absolute right-0 py-4 adorement gap-1 flex items-center ';
120
+ break;
116
121
  default:
117
- break
122
+ break;
118
123
  }
119
- return className
120
- }
124
+ return className;
125
+ };
121
126
  useEffect(() => {
122
127
  if (autoFocus) {
123
- onLabelClick()
128
+ onLabelClick();
124
129
  }
125
- }, [autoFocus])
130
+ }, [autoFocus]);
126
131
  // const getPosition = () => {
127
132
  // return 'top'
128
133
  // }
129
134
  const handleError = (data: any) => {
130
- if (getErrors(data[name]) === 'required' || getErrors(data[name]) === 'Required') {
131
- return `${label} is ${getErrors(data[name])}`
135
+ if (
136
+ getErrors(data[name]) === 'required' ||
137
+ getErrors(data[name]) === 'Required'
138
+ ) {
139
+ return `${label} is ${getErrors(data[name])}`;
132
140
  } else {
133
- return getErrors(data[name]) ?? ''
141
+ return getErrors(data[name]) ?? '';
134
142
  }
135
- }
136
- const textFieldRef = useRef<HTMLDivElement>(null) // Ref for the text field div
143
+ };
144
+ const textFieldRef = useRef<HTMLDivElement>(null); // Ref for the text field div
137
145
 
138
146
  useEffect(() => {
139
- applyPositionClass(textFieldRef)
140
- }, [isHovered])
147
+ if (isHovered) applyPositionClass(textFieldRef);
148
+ }, [isHovered]);
141
149
  return (
142
150
  <div ref={textFieldRef} className={` ${fullwidth ? 'w-full' : 'w-auto'}`}>
143
151
  <div className="tooltip-container">
@@ -160,7 +168,7 @@ const ModernTextArea: React.FC<TextAreaProps> = ({
160
168
  style={{
161
169
  paddingRight: getInnerWidth(adorementRef, 11),
162
170
  height: boxHeight ?? undefined,
163
- minHeight: boxMinHeight ?? undefined
171
+ minHeight: boxMinHeight ?? undefined,
164
172
  }}
165
173
  autoComplete={autoComplete ? 'on' : 'off'}
166
174
  // autoFocus={autoFocus}
@@ -193,7 +201,7 @@ const ModernTextArea: React.FC<TextAreaProps> = ({
193
201
  </div>
194
202
  </div>
195
203
  </div>
196
- )
197
- }
204
+ );
205
+ };
198
206
 
199
- export default ModernTextArea
207
+ export default ModernTextArea;
@@ -33,7 +33,7 @@ const TextField: React.FC<TextFieldProps> = ({
33
33
  onStepUp, //new requirement number steper
34
34
  onStepDown, //new requirement number steper
35
35
  onChange,
36
- infoTitle = 'added for set background colour according to the form',
36
+ infoTitle = 'new requirement number steper',
37
37
  onBlur,
38
38
  showInfo = true,
39
39
  errors,
@@ -271,8 +271,8 @@ const TextField: React.FC<TextFieldProps> = ({
271
271
  const textFieldRef = useRef<HTMLDivElement>(null); // Ref for the text field div
272
272
 
273
273
  useEffect(() => {
274
- applyPositionClass(textFieldRef);
275
- }, []);
274
+ if (isHovered) applyPositionClass(textFieldRef);
275
+ }, [isHovered]);
276
276
  return (
277
277
  <div ref={textFieldRef} className={` ${fullwidth ? 'w-full' : 'w-auto'}`}>
278
278
  <div className="tooltip-container ">