react-core-ts 1.3.44 → 1.3.46
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/AutoCompleteWithSelectedList.js +3 -4
- package/dist/AutoCompleteWithSelectedList.js.map +1 -1
- package/dist/AutoCompleteWithTreeStructure.js +3 -4
- package/dist/AutoCompleteWithTreeStructure.js.map +1 -1
- package/dist/ExpandableAutoComplete.d.ts +2 -2
- package/dist/ExpandableAutoComplete.js +38 -39
- package/dist/ExpandableAutoComplete.js.map +1 -1
- package/dist/ReactTextField.d.ts +2 -2
- package/dist/ReactTextField.js +48 -48
- package/dist/ReactTextField.js.map +1 -1
- package/dist/dummyAutoCompleteWithSelectedList.js +2 -1
- package/dist/dummyAutoCompleteWithSelectedList.js.map +1 -1
- package/dist/utilities/expandableTootltip.js.map +1 -1
- package/dist/utilities/icons.js +1 -1
- package/dist/utilities/icons.js.map +1 -1
- package/package.json +1 -1
- package/src/AutoCompleteWithSelectedList.tsx +4 -4
- package/src/AutoCompleteWithTreeStructure.tsx +11 -5
- package/src/ExpandableAutoComplete.tsx +57 -58
- package/src/ReactTextField.tsx +73 -73
- package/src/dummyAutoCompleteWithSelectedList.tsx +1 -1
- package/src/utilities/expandableTootltip.tsx +1 -0
- package/src/utilities/icons.tsx +1 -0
|
@@ -5,18 +5,18 @@ import React, {
|
|
|
5
5
|
useImperativeHandle,
|
|
6
6
|
useRef,
|
|
7
7
|
useState,
|
|
8
|
-
} from
|
|
9
|
-
import ReactDOM from
|
|
10
|
-
|
|
11
|
-
import { AutoSuggestionInputProps } from
|
|
12
|
-
import DropdownList from
|
|
13
|
-
import InputActions from
|
|
14
|
-
import { useSuggestions } from
|
|
15
|
-
import { debounce } from
|
|
16
|
-
import { deepEqual } from
|
|
17
|
-
import { default as Tooltip } from
|
|
18
|
-
import { filterSuggestions } from
|
|
19
|
-
import { Search, Spinner } from
|
|
8
|
+
} from 'react';
|
|
9
|
+
import ReactDOM from 'react-dom';
|
|
10
|
+
|
|
11
|
+
import { AutoSuggestionInputProps } from './commontypes';
|
|
12
|
+
import DropdownList from './components/DropdownList';
|
|
13
|
+
import InputActions from './components/InputActions';
|
|
14
|
+
import { useSuggestions } from './utilities/autosuggestions';
|
|
15
|
+
import { debounce } from './utilities/debounce';
|
|
16
|
+
import { deepEqual } from './utilities/deepEqual';
|
|
17
|
+
import { default as Tooltip } from './utilities/expandableTootltip';
|
|
18
|
+
import { filterSuggestions } from './utilities/filterSuggestions';
|
|
19
|
+
import { Search, Spinner } from './utilities/icons';
|
|
20
20
|
|
|
21
21
|
type ValueProps = {
|
|
22
22
|
[key: string]: string;
|
|
@@ -37,14 +37,14 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
37
37
|
fullWidth = false,
|
|
38
38
|
placeholder,
|
|
39
39
|
id,
|
|
40
|
-
type =
|
|
40
|
+
type = 'custom_select',
|
|
41
41
|
selectedItems: propsSeelctedItems = [],
|
|
42
42
|
readOnly = false,
|
|
43
43
|
disabled = false,
|
|
44
44
|
value,
|
|
45
45
|
isMultiple = false,
|
|
46
|
-
desc =
|
|
47
|
-
descId =
|
|
46
|
+
desc = 'name',
|
|
47
|
+
descId = 'id',
|
|
48
48
|
singleSelect,
|
|
49
49
|
className,
|
|
50
50
|
async = false,
|
|
@@ -68,7 +68,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
68
68
|
const [isInitialRender, setIsInitialRender] = useState(true);
|
|
69
69
|
|
|
70
70
|
const [inputValue, setInputValue] = useState<string>(value);
|
|
71
|
-
const [searchValue, setSearchValue] = useState<string>(
|
|
71
|
+
const [searchValue, setSearchValue] = useState<string>('');
|
|
72
72
|
const [nextPage, setNextPage] = useState<number | undefined>(1);
|
|
73
73
|
const [dropOpen, setDropOpen] = useState<boolean>(false);
|
|
74
74
|
const [selectedItems, setSelectedItems] = useState<ValueProps[]>([]);
|
|
@@ -110,11 +110,11 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
useEffect(() => {
|
|
113
|
-
window.addEventListener(
|
|
113
|
+
window.addEventListener('resize', adjustDropdownPosition);
|
|
114
114
|
adjustDropdownPosition();
|
|
115
115
|
|
|
116
116
|
return () => {
|
|
117
|
-
window.removeEventListener(
|
|
117
|
+
window.removeEventListener('resize', adjustDropdownPosition);
|
|
118
118
|
};
|
|
119
119
|
}, [dropOpen, selectedItems]);
|
|
120
120
|
|
|
@@ -147,7 +147,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
147
147
|
});
|
|
148
148
|
} else {
|
|
149
149
|
setInputValue(suggestion[desc]);
|
|
150
|
-
setSearchValue(
|
|
150
|
+
setSearchValue('');
|
|
151
151
|
onChange(suggestion);
|
|
152
152
|
setDropOpen(false);
|
|
153
153
|
}
|
|
@@ -155,7 +155,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
155
155
|
|
|
156
156
|
// Adding debounce to avoid making API calls on every keystroke
|
|
157
157
|
const handleChangeWithDebounce = debounce((value) => {
|
|
158
|
-
if ((type ===
|
|
158
|
+
if ((type === 'auto_complete' || type === 'auto_suggestion') && async) {
|
|
159
159
|
handlePickSuggestions(value, 1);
|
|
160
160
|
}
|
|
161
161
|
}, 1000);
|
|
@@ -177,7 +177,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
177
177
|
setInputValue(suggestion[desc]);
|
|
178
178
|
onChange(suggestion);
|
|
179
179
|
} else {
|
|
180
|
-
setInputValue(
|
|
180
|
+
setInputValue('');
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
};
|
|
@@ -187,7 +187,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
187
187
|
}, [propsSeelctedItems]);
|
|
188
188
|
// Effect to set the input value whenever `value` prop changes
|
|
189
189
|
useEffect(() => {
|
|
190
|
-
setInputValue(value ??
|
|
190
|
+
setInputValue(value ?? '');
|
|
191
191
|
}, [value]);
|
|
192
192
|
|
|
193
193
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -196,7 +196,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
196
196
|
setSearchValue(value);
|
|
197
197
|
handleChangeWithDebounce(value);
|
|
198
198
|
if (!value) {
|
|
199
|
-
setInputValue(
|
|
199
|
+
setInputValue('');
|
|
200
200
|
// onChange({ [descId]: '', [desc]: '' });
|
|
201
201
|
}
|
|
202
202
|
};
|
|
@@ -215,19 +215,19 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
215
215
|
|
|
216
216
|
const handleClear = () => {
|
|
217
217
|
if (searchValue) {
|
|
218
|
-
setSearchValue(
|
|
218
|
+
setSearchValue('');
|
|
219
219
|
setDropOpen(false);
|
|
220
220
|
} else {
|
|
221
|
-
setInputValue(
|
|
222
|
-
onChange({ [descId]:
|
|
221
|
+
setInputValue('');
|
|
222
|
+
onChange({ [descId]: '', [desc]: '' });
|
|
223
223
|
setDropOpen(false);
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
|
|
227
227
|
const generateClassName = useCallback(() => {
|
|
228
228
|
return `qbs-textfield-default ${className} ${
|
|
229
|
-
errors && errors?.message ?
|
|
230
|
-
} ${expandable ?
|
|
229
|
+
errors && errors?.message ? 'textfield-error' : 'textfield'
|
|
230
|
+
} ${expandable ? 'expandable' : ''}`;
|
|
231
231
|
}, [errors, name]);
|
|
232
232
|
const handleRemoveSelectedItem = (index: number) => {
|
|
233
233
|
setSelectedItems((prev) => {
|
|
@@ -248,37 +248,36 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
248
248
|
if (
|
|
249
249
|
dropRef.current &&
|
|
250
250
|
event.target instanceof Node &&
|
|
251
|
-
!dropRef.current.contains(event.target)
|
|
252
|
-
|
|
253
|
-
// event.target.nodeName !== "svg"
|
|
251
|
+
!dropRef.current.contains(event.target) &&
|
|
252
|
+
event.target?.id !== 'drop-arrow-icon'
|
|
254
253
|
) {
|
|
255
254
|
setTimeout(() => {
|
|
256
255
|
setDropOpen(false);
|
|
257
|
-
setSearchValue(
|
|
256
|
+
setSearchValue('');
|
|
258
257
|
}, 200);
|
|
259
258
|
}
|
|
260
259
|
};
|
|
261
|
-
document.addEventListener(
|
|
262
|
-
window.addEventListener(
|
|
260
|
+
document.addEventListener('mousedown', handleClickOutside as any);
|
|
261
|
+
window.addEventListener('scroll', handleClickOutside as any);
|
|
263
262
|
|
|
264
263
|
const scrollableDivs = document.querySelectorAll(
|
|
265
264
|
'div[style*="overflow"], .overflow-auto, .overflow-y-auto, .overflow-x-auto'
|
|
266
265
|
);
|
|
267
266
|
scrollableDivs.forEach((div) =>
|
|
268
|
-
div.addEventListener(
|
|
267
|
+
div.addEventListener('scroll', handleClickOutside as any)
|
|
269
268
|
);
|
|
270
269
|
if (scrollRef && scrollRef.current && scrollRef.current !== null) {
|
|
271
|
-
scrollRef.current.addEventListener(
|
|
270
|
+
scrollRef.current.addEventListener('scroll', handleClickOutside as any);
|
|
272
271
|
}
|
|
273
272
|
return () => {
|
|
274
|
-
document.removeEventListener(
|
|
275
|
-
window.removeEventListener(
|
|
273
|
+
document.removeEventListener('mousedown', handleClickOutside as any);
|
|
274
|
+
window.removeEventListener('scroll', handleClickOutside as any);
|
|
276
275
|
scrollableDivs.forEach((div) =>
|
|
277
|
-
div.removeEventListener(
|
|
276
|
+
div.removeEventListener('scroll', handleClickOutside as any)
|
|
278
277
|
);
|
|
279
278
|
if (scrollRef && scrollRef.current && scrollRef.current !== null) {
|
|
280
279
|
scrollRef.current.removeEventListener(
|
|
281
|
-
|
|
280
|
+
'scroll',
|
|
282
281
|
handleClickOutside as any
|
|
283
282
|
);
|
|
284
283
|
}
|
|
@@ -317,7 +316,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
317
316
|
};
|
|
318
317
|
|
|
319
318
|
const handleOnClick = () => {
|
|
320
|
-
!disabled && !readOnly ? setDropOpen(true) :
|
|
319
|
+
!disabled && !readOnly ? setDropOpen(true) : '';
|
|
321
320
|
};
|
|
322
321
|
const onInputFocus = () => {
|
|
323
322
|
if (inputRef.current) inputRef.current.focus();
|
|
@@ -329,8 +328,8 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
329
328
|
? selectedItems
|
|
330
329
|
?.slice(itemCount)
|
|
331
330
|
.map((item) => item[desc])
|
|
332
|
-
.join(
|
|
333
|
-
:
|
|
331
|
+
.join(', ')
|
|
332
|
+
: '';
|
|
334
333
|
|
|
335
334
|
const handleDropOpen = (e: any) => {
|
|
336
335
|
if (!dropOpen) setDropOpen(true);
|
|
@@ -347,13 +346,13 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
347
346
|
};
|
|
348
347
|
|
|
349
348
|
return (
|
|
350
|
-
<div className={fullWidth ?
|
|
349
|
+
<div className={fullWidth ? 'fullWidth' : 'autoWidth'} ref={dropdownRef}>
|
|
351
350
|
{label && (
|
|
352
351
|
<div
|
|
353
352
|
style={{
|
|
354
353
|
marginBottom: 5,
|
|
355
|
-
display:
|
|
356
|
-
justifyContent:
|
|
354
|
+
display: 'flex',
|
|
355
|
+
justifyContent: 'space-between',
|
|
357
356
|
}}
|
|
358
357
|
>
|
|
359
358
|
<label className={`labels label-text`}>
|
|
@@ -369,9 +368,9 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
369
368
|
|
|
370
369
|
<div
|
|
371
370
|
className={`${
|
|
372
|
-
expandable ?
|
|
371
|
+
expandable ? 'qbs-expandable-container' : 'qbs-container'
|
|
373
372
|
}`}
|
|
374
|
-
style={{ position:
|
|
373
|
+
style={{ position: 'relative' }}
|
|
375
374
|
>
|
|
376
375
|
{selectedItems?.length > 0 && (
|
|
377
376
|
<>
|
|
@@ -418,12 +417,12 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
418
417
|
|
|
419
418
|
<div
|
|
420
419
|
className={`qbs-textfield-expandable ${
|
|
421
|
-
!expandable ?
|
|
420
|
+
!expandable ? 'qbs-normal' : ''
|
|
422
421
|
}`}
|
|
423
422
|
data-value={
|
|
424
423
|
selectedItems?.length > 0 || searchValue
|
|
425
424
|
? searchValue
|
|
426
|
-
: placeholder ??
|
|
425
|
+
: placeholder ?? ''
|
|
427
426
|
}
|
|
428
427
|
onClick={() => onInputFocus()}
|
|
429
428
|
>
|
|
@@ -432,7 +431,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
432
431
|
ref={inputRef}
|
|
433
432
|
type="text"
|
|
434
433
|
value={
|
|
435
|
-
type ===
|
|
434
|
+
type === 'auto_suggestion' && !expandable
|
|
436
435
|
? inputValue
|
|
437
436
|
: searchValue || inputValue
|
|
438
437
|
}
|
|
@@ -441,11 +440,11 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
441
440
|
onFocus={onFocus}
|
|
442
441
|
onClick={() => handleOnClick()}
|
|
443
442
|
className={generateClassName()}
|
|
444
|
-
placeholder={selectedItems?.length > 0 ?
|
|
443
|
+
placeholder={selectedItems?.length > 0 ? '' : placeholder ?? ''}
|
|
445
444
|
readOnly={
|
|
446
445
|
readOnly ||
|
|
447
|
-
type ===
|
|
448
|
-
(type ==
|
|
446
|
+
type === 'custom_select' ||
|
|
447
|
+
(type == 'auto_suggestion' && !expandable)
|
|
449
448
|
}
|
|
450
449
|
disabled={disabled}
|
|
451
450
|
data-testid="custom-autocomplete"
|
|
@@ -485,9 +484,9 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
485
484
|
style={{ ...dropdownStyle, minHeight: 192 }}
|
|
486
485
|
className={`qbs-autocomplete-suggestions`}
|
|
487
486
|
>
|
|
488
|
-
{type ==
|
|
487
|
+
{type == 'auto_suggestion' && !expandable && (
|
|
489
488
|
<div
|
|
490
|
-
style={{ position:
|
|
489
|
+
style={{ position: 'relative' }}
|
|
491
490
|
className="react-core-ts-search-container"
|
|
492
491
|
>
|
|
493
492
|
<span className="dropdown-search-icon">
|
|
@@ -521,7 +520,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
521
520
|
<>
|
|
522
521
|
{isLoading ? (
|
|
523
522
|
<div
|
|
524
|
-
style={{ display:
|
|
523
|
+
style={{ display: 'flex', justifyContent: 'center' }}
|
|
525
524
|
className="qbs-autocomplete-loader"
|
|
526
525
|
>
|
|
527
526
|
<span>
|
|
@@ -533,7 +532,7 @@ const ExpandableAutoComplete = forwardRef<
|
|
|
533
532
|
className="qbs-autocomplete-notfound"
|
|
534
533
|
onClick={handleBlur}
|
|
535
534
|
>
|
|
536
|
-
{notDataMessage ??
|
|
535
|
+
{notDataMessage ?? 'No Results Found'}
|
|
537
536
|
</li>
|
|
538
537
|
)}
|
|
539
538
|
</>
|
package/src/ReactTextField.tsx
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { TextFieldProps } from
|
|
4
|
-
import CustomIcons from
|
|
5
|
-
import ModernAutoComplete from
|
|
6
|
-
import { applyPositionClass } from
|
|
3
|
+
import { TextFieldProps } from "./commontypes";
|
|
4
|
+
import CustomIcons from "./components/customIcons";
|
|
5
|
+
import ModernAutoComplete from "./ReactAutoComplete";
|
|
6
|
+
import { applyPositionClass } from "./utilities/getPosition";
|
|
7
7
|
|
|
8
8
|
const TextField: React.FC<TextFieldProps> = ({
|
|
9
9
|
name,
|
|
10
10
|
id,
|
|
11
11
|
label,
|
|
12
|
-
type =
|
|
12
|
+
type = "text",
|
|
13
13
|
disabled = false,
|
|
14
14
|
readOnly = false,
|
|
15
15
|
fullwidth = true,
|
|
16
16
|
uppercase = false,
|
|
17
|
-
adorementPosition =
|
|
17
|
+
adorementPosition = "end",
|
|
18
18
|
register,
|
|
19
19
|
adorement,
|
|
20
20
|
className: propsClassName,
|
|
21
21
|
value,
|
|
22
|
-
placeholder =
|
|
22
|
+
placeholder = "",
|
|
23
23
|
min,
|
|
24
24
|
max,
|
|
25
|
-
size =
|
|
25
|
+
size = "md",
|
|
26
26
|
required = false,
|
|
27
27
|
autoComplete = false,
|
|
28
28
|
isValid,
|
|
@@ -77,9 +77,9 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
77
77
|
? adorementRef.current.offsetWidth
|
|
78
78
|
: 15;
|
|
79
79
|
setWidth(innerwidth);
|
|
80
|
-
}, [adorement]);
|
|
80
|
+
}, [adorement, infoTitle, showInfo]);
|
|
81
81
|
const getErrors = (err?: any) => {
|
|
82
|
-
let errMsg =
|
|
82
|
+
let errMsg = "";
|
|
83
83
|
if (err?.message) {
|
|
84
84
|
errMsg = err?.message;
|
|
85
85
|
}
|
|
@@ -93,76 +93,76 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
93
93
|
|
|
94
94
|
const getHeight = () => {
|
|
95
95
|
switch (size) {
|
|
96
|
-
case
|
|
97
|
-
return
|
|
98
|
-
case
|
|
99
|
-
return
|
|
100
|
-
case
|
|
101
|
-
return
|
|
102
|
-
case
|
|
103
|
-
return
|
|
104
|
-
case
|
|
105
|
-
return
|
|
96
|
+
case "xs":
|
|
97
|
+
return " h-10 ";
|
|
98
|
+
case "xxs":
|
|
99
|
+
return " h-[25px] ";
|
|
100
|
+
case "sm":
|
|
101
|
+
return " h-[34px] ";
|
|
102
|
+
case "md":
|
|
103
|
+
return " h-10 ";
|
|
104
|
+
case "lg":
|
|
105
|
+
return " h-10 ";
|
|
106
106
|
default:
|
|
107
|
-
return
|
|
107
|
+
return " h-10 ";
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
-
const getBg = () => backGround ||
|
|
110
|
+
const getBg = () => backGround || "bg-transparent"; //added for set background colour according to the form
|
|
111
111
|
const generateClassName = (
|
|
112
|
-
from:
|
|
112
|
+
from: "input" | "label" | "message" | "adorement"
|
|
113
113
|
): string => {
|
|
114
114
|
let className = `${propsClassName} `;
|
|
115
115
|
|
|
116
116
|
switch (from) {
|
|
117
|
-
case
|
|
117
|
+
case "input":
|
|
118
118
|
className += `block ${
|
|
119
|
-
size ===
|
|
119
|
+
size === "xxs" ? " text-xxs" : "text-common"
|
|
120
120
|
} text-input-text font-normal ${
|
|
121
|
-
step && adorement ?
|
|
121
|
+
step && adorement ? "px-2.5" : "px-3.5"
|
|
122
122
|
} w-full text-sm text-gray-900 ${getBg()} border appearance-none peer rounded-[4px] disabled:text-input-disabled bg-white disabled:bg-disabled ${
|
|
123
|
-
hideLabel ?
|
|
123
|
+
hideLabel ? "" : "placeholder-transparent"
|
|
124
124
|
} focus:placeholder-grey-secondary ${
|
|
125
|
-
adorementPosition ===
|
|
125
|
+
adorementPosition === "start" && " !pl-[45px] "
|
|
126
126
|
} ${getHeight()}`;
|
|
127
127
|
|
|
128
128
|
if (errors && errors[name]) {
|
|
129
129
|
className +=
|
|
130
|
-
|
|
130
|
+
" border-[#FDA29B] focus:border-error-[#FDA29B] focus:ring-[#FDA29B] focus:ring-3 focus:outline-[#FDA29B] input-outline";
|
|
131
131
|
} else {
|
|
132
132
|
className +=
|
|
133
|
-
|
|
133
|
+
" text-grey-dark border-input-light focus:border-blue-navy focus:outline-none focus:ring-0";
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
break;
|
|
137
|
-
case
|
|
137
|
+
case "label": // changes made for remove bg-white from placeolder is field disable and or with data
|
|
138
138
|
className += ` modern-input-label peer-focus:modern-input-peer-focus-label-size absolute duration-300 transform -translate-y-4 top-2 z-1 origin-[0] px-0
|
|
139
139
|
peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2
|
|
140
140
|
peer-focus:-translate-y-4 start-[14px] rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto ${
|
|
141
|
-
isDisabled ?
|
|
141
|
+
isDisabled ? "cursor-pointer" : "cursor-text peer-focus:cursor-pointer"
|
|
142
142
|
} ${
|
|
143
143
|
isDisabled && !checkIsEmptyField()
|
|
144
|
-
?
|
|
144
|
+
? "disabled-input-label-bg"
|
|
145
145
|
: !isDisabled || !checkIsEmptyField()
|
|
146
|
-
?
|
|
147
|
-
:
|
|
146
|
+
? "active-input-label-bg"
|
|
147
|
+
: ""
|
|
148
148
|
} ${
|
|
149
149
|
checkIsEmptyField()
|
|
150
|
-
?
|
|
151
|
-
:
|
|
150
|
+
? "modern-input-label-size"
|
|
151
|
+
: "modern-input-peer-focus-label-size"
|
|
152
152
|
}`;
|
|
153
153
|
|
|
154
154
|
if (errors && errors[name]) {
|
|
155
|
-
className +=
|
|
155
|
+
className += " text-error-light ";
|
|
156
156
|
} else {
|
|
157
|
-
className +=
|
|
157
|
+
className += " text-grey-dark peer-focus:text-blue-navy";
|
|
158
158
|
}
|
|
159
159
|
break;
|
|
160
|
-
case
|
|
161
|
-
className =
|
|
160
|
+
case "message":
|
|
161
|
+
className = " text-error-icon ";
|
|
162
162
|
break;
|
|
163
|
-
case
|
|
163
|
+
case "adorement":
|
|
164
164
|
className += `${
|
|
165
|
-
isDisabled ?
|
|
165
|
+
isDisabled ? "bg-bodyBG" : "bg-white"
|
|
166
166
|
} absolute right-0 adorement gap-1 flex items-center`;
|
|
167
167
|
break;
|
|
168
168
|
|
|
@@ -174,18 +174,18 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
174
174
|
|
|
175
175
|
const handleError = (data: any) => {
|
|
176
176
|
if (
|
|
177
|
-
getErrors(data[name]) ===
|
|
178
|
-
getErrors(data[name]) ===
|
|
177
|
+
getErrors(data[name]) === "required" ||
|
|
178
|
+
getErrors(data[name]) === "Required"
|
|
179
179
|
) {
|
|
180
180
|
return `${label ?? labelTitle} is ${getErrors(data[name])}`;
|
|
181
181
|
} else {
|
|
182
|
-
return getErrors(data[name]) ??
|
|
182
|
+
return getErrors(data[name]) ?? "";
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
|
|
186
186
|
// Added handle key press function on textfield to restrict typing letter 'e' on number type
|
|
187
187
|
const handleKeyPress = (e: any) => {
|
|
188
|
-
if (type ===
|
|
188
|
+
if (type === "number" && e.key === "e") e.preventDefault();
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -201,14 +201,14 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
201
201
|
const renderPrefix = () => {
|
|
202
202
|
if (prefixes) {
|
|
203
203
|
switch (prefixes?.type) {
|
|
204
|
-
case
|
|
204
|
+
case "custom_select":
|
|
205
205
|
return (
|
|
206
206
|
<ModernAutoComplete
|
|
207
207
|
key={prefixes.name}
|
|
208
208
|
placeholder={prefixes.placeholder}
|
|
209
209
|
onChange={(e: any) => onPrefixChange?.(e)}
|
|
210
210
|
name={prefixes.name}
|
|
211
|
-
value={prefixValue ?? { id:
|
|
211
|
+
value={prefixValue ?? { id: "", name: "" }}
|
|
212
212
|
type="custom_select"
|
|
213
213
|
isCustomPlaceholder
|
|
214
214
|
fullWidth={false}
|
|
@@ -240,7 +240,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
240
240
|
return undefined;
|
|
241
241
|
};
|
|
242
242
|
|
|
243
|
-
const handleMouseDown = (type:
|
|
243
|
+
const handleMouseDown = (type: "up" | "down") => {
|
|
244
244
|
setIsHolding(true);
|
|
245
245
|
//handleAction(type)
|
|
246
246
|
intervalRef.current = setInterval(() => handleAction(type), 100);
|
|
@@ -249,8 +249,8 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
|
|
252
|
-
const handleAction = (type:
|
|
253
|
-
if (type ===
|
|
252
|
+
const handleAction = (type: "up" | "down") => {
|
|
253
|
+
if (type === "up") onStepUp?.();
|
|
254
254
|
else onStepDown?.();
|
|
255
255
|
};
|
|
256
256
|
|
|
@@ -261,7 +261,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
const handleClick = (type:
|
|
264
|
+
const handleClick = (type: "up" | "down") => {
|
|
265
265
|
if (!isHolding) {
|
|
266
266
|
clickTimeoutRef.current = setTimeout(() => {
|
|
267
267
|
handleAction(type);
|
|
@@ -274,7 +274,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
274
274
|
applyPositionClass(textFieldRef, isHovered);
|
|
275
275
|
}, [isHovered]);
|
|
276
276
|
return (
|
|
277
|
-
<div ref={textFieldRef} className={` ${fullwidth ?
|
|
277
|
+
<div ref={textFieldRef} className={` ${fullwidth ? "w-full" : "w-auto"}`}>
|
|
278
278
|
<div className="tooltip-container ">
|
|
279
279
|
{isHovered && errors && errors[name] && (
|
|
280
280
|
<span className="tooltip">{handleError(errors)} </span>
|
|
@@ -282,10 +282,10 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
282
282
|
{isHovered && infoTitle && (
|
|
283
283
|
<span className="tooltip-info">{infoTitle} </span>
|
|
284
284
|
)}
|
|
285
|
-
<div className={`w-full ${prefixes ?
|
|
285
|
+
<div className={`w-full ${prefixes ? "flex" : ""}`}>
|
|
286
286
|
{prefixes && renderPrefix()}
|
|
287
287
|
<div
|
|
288
|
-
className={`flex relative ${fullwidth ?
|
|
288
|
+
className={`flex relative ${fullwidth ? "w-full" : "w-auto"}`}
|
|
289
289
|
style={{ width: width }}
|
|
290
290
|
>
|
|
291
291
|
<div className="relative w-full ">
|
|
@@ -312,15 +312,15 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
312
312
|
}
|
|
313
313
|
: {}),
|
|
314
314
|
}}
|
|
315
|
-
className={` ${generateClassName(
|
|
316
|
-
uppercase ?
|
|
315
|
+
className={` ${generateClassName("input")} ${
|
|
316
|
+
uppercase ? "uppercase placeholder:normal-case" : ""
|
|
317
317
|
} ''}`}
|
|
318
318
|
placeholder={placeholder}
|
|
319
319
|
onChange={(e) => {
|
|
320
320
|
handleChange(e);
|
|
321
321
|
}}
|
|
322
322
|
onKeyDown={handleKeyPress}
|
|
323
|
-
autoComplete={autoComplete ?
|
|
323
|
+
autoComplete={autoComplete ? "on" : "off"}
|
|
324
324
|
onBlur={(e) => onBlur?.(e)}
|
|
325
325
|
// autoFocus={autoFocus}
|
|
326
326
|
value={value}
|
|
@@ -329,7 +329,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
329
329
|
<label
|
|
330
330
|
htmlFor={id}
|
|
331
331
|
onClick={() => onLabelClick()}
|
|
332
|
-
className={generateClassName(
|
|
332
|
+
className={generateClassName("label")}
|
|
333
333
|
>
|
|
334
334
|
{label}
|
|
335
335
|
{required ? <span className="text-error"> *</span> : <></>}
|
|
@@ -342,10 +342,10 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
342
342
|
(!isValid && isTooltip && errors && errors[name]) ||
|
|
343
343
|
isValid) && (
|
|
344
344
|
<div className="flex items-center justify-center gap-1 ">
|
|
345
|
-
{adorement && adorementPosition ===
|
|
345
|
+
{adorement && adorementPosition === "start" && (
|
|
346
346
|
<div
|
|
347
347
|
className={` ${
|
|
348
|
-
isDisabled ?
|
|
348
|
+
isDisabled ? "text-zinc-500" : "text-grey-medium"
|
|
349
349
|
} absolute adorement left-0 `} // adorement position added for start
|
|
350
350
|
>
|
|
351
351
|
<>{adorement}</>
|
|
@@ -354,14 +354,14 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
354
354
|
|
|
355
355
|
<div
|
|
356
356
|
className={`${generateClassName(
|
|
357
|
-
|
|
357
|
+
"adorement"
|
|
358
358
|
)} h-[20px] right-[1px]`} //added adorment bg color
|
|
359
359
|
ref={adorementRef}
|
|
360
360
|
>
|
|
361
|
-
{adorement && adorementPosition ===
|
|
361
|
+
{adorement && adorementPosition === "end" && (
|
|
362
362
|
<div
|
|
363
363
|
className={` ${
|
|
364
|
-
isDisabled ?
|
|
364
|
+
isDisabled ? "text-zinc-500" : "text-grey-medium"
|
|
365
365
|
} `} // changed for adorment text blurness while disabled
|
|
366
366
|
>
|
|
367
367
|
<>{adorement}</>
|
|
@@ -373,13 +373,13 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
373
373
|
<CustomIcons
|
|
374
374
|
name="TreeUp_Arrow"
|
|
375
375
|
className={`text-gray-500 hover:text-dark cursor-pointer ${
|
|
376
|
-
isDisabled ?
|
|
376
|
+
isDisabled ? "hidden" : "block"
|
|
377
377
|
}`}
|
|
378
378
|
type="medium"
|
|
379
379
|
onClick={() => {
|
|
380
|
-
handleClick(
|
|
380
|
+
handleClick("up");
|
|
381
381
|
}}
|
|
382
|
-
onMouseDown={() => handleMouseDown(
|
|
382
|
+
onMouseDown={() => handleMouseDown("up")}
|
|
383
383
|
onMouseUp={handleMouseUp}
|
|
384
384
|
onMouseLeave={handleMouseUp}
|
|
385
385
|
viewBox={true}
|
|
@@ -387,13 +387,13 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
387
387
|
<CustomIcons
|
|
388
388
|
name="TreeDown_Arrow"
|
|
389
389
|
className={`text-gray-500 hover:text-dark cursor-pointer ${
|
|
390
|
-
isDisabled ?
|
|
390
|
+
isDisabled ? "hidden" : "block"
|
|
391
391
|
}`}
|
|
392
392
|
type="medium"
|
|
393
393
|
onClick={() => {
|
|
394
|
-
handleClick(
|
|
394
|
+
handleClick("down");
|
|
395
395
|
}}
|
|
396
|
-
onMouseDown={() => handleMouseDown(
|
|
396
|
+
onMouseDown={() => handleMouseDown("down")}
|
|
397
397
|
onMouseUp={handleMouseUp}
|
|
398
398
|
onMouseLeave={handleMouseUp}
|
|
399
399
|
viewBox={true}
|
|
@@ -404,7 +404,7 @@ const TextField: React.FC<TextFieldProps> = ({
|
|
|
404
404
|
{!isValid && isTooltip && errors && errors[name] && (
|
|
405
405
|
<div
|
|
406
406
|
className={` text-error-label relative bg-white cursor-pointer ${generateClassName(
|
|
407
|
-
|
|
407
|
+
"message"
|
|
408
408
|
)}`}
|
|
409
409
|
onMouseEnter={() => setIsHovered(true)}
|
|
410
410
|
onMouseLeave={() => setIsHovered(false)}
|