react-core-ts 1.1.30 → 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.
- package/dist/ReactAutoComplete.d.ts +3 -3
- package/dist/ReactAutoComplete.js +85 -84
- package/dist/ReactAutoComplete.js.map +1 -1
- package/dist/ReactTextArea.d.ts +1 -1
- package/dist/ReactTextArea.js +11 -6
- package/dist/ReactTextArea.js.map +1 -1
- package/dist/ReactTextField.js +8 -7
- package/dist/ReactTextField.js.map +1 -1
- package/docs/App.tsx +62 -50
- package/package.json +1 -1
- package/src/ReactAutoComplete.tsx +104 -104
- package/src/ReactTextArea.tsx +61 -53
- package/src/ReactTextField.tsx +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useRef, useState } from
|
|
2
|
-
import { FieldErrors } from
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { FieldErrors } from 'react-hook-form';
|
|
3
3
|
|
|
4
|
-
import CustomIcons from
|
|
5
|
-
import Spinner from
|
|
6
|
-
import Portal from
|
|
7
|
-
import { debounce } from
|
|
8
|
-
import { applyPositionClass } from
|
|
4
|
+
import CustomIcons from './components/customIcons';
|
|
5
|
+
import Spinner from './components/loader/Spinner';
|
|
6
|
+
import Portal from './components/portal';
|
|
7
|
+
import { debounce } from './utilities/debounce';
|
|
8
|
+
import { applyPositionClass } from './utilities/getPosition';
|
|
9
9
|
|
|
10
10
|
type valueProps = {
|
|
11
11
|
id?: string | number;
|
|
@@ -28,7 +28,7 @@ interface AutoSuggestionInputProps {
|
|
|
28
28
|
value?: valueProps;
|
|
29
29
|
onChange: (value?: valueProps) => void;
|
|
30
30
|
data?: any[];
|
|
31
|
-
type?:
|
|
31
|
+
type?: 'custom_select' | 'auto_complete' | 'custom_search_select';
|
|
32
32
|
placeholder?: string;
|
|
33
33
|
getData?: ((key?: string) => Promise<any>) | ((key?: string) => any);
|
|
34
34
|
errors?: FieldErrors;
|
|
@@ -64,7 +64,7 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
64
64
|
placeholder,
|
|
65
65
|
id,
|
|
66
66
|
className: propsClassName,
|
|
67
|
-
type =
|
|
67
|
+
type = 'custom_select',
|
|
68
68
|
readOnly,
|
|
69
69
|
disabled = false,
|
|
70
70
|
value,
|
|
@@ -81,7 +81,7 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
81
81
|
labelTitle,
|
|
82
82
|
isModern = true,
|
|
83
83
|
}) => {
|
|
84
|
-
const [inputValue, setInputValue] = useState<any>(value?.name ??
|
|
84
|
+
const [inputValue, setInputValue] = useState<any>(value?.name ?? '');
|
|
85
85
|
const [isHovered, setIsHovered] = useState<boolean>(false);
|
|
86
86
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
87
87
|
const [dropOpen, setDropOpen] = useState<boolean>(false);
|
|
@@ -113,8 +113,8 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
113
113
|
) => {
|
|
114
114
|
return substring &&
|
|
115
115
|
mainString &&
|
|
116
|
-
typeof mainString ===
|
|
117
|
-
typeof subString ===
|
|
116
|
+
typeof mainString === 'string' &&
|
|
117
|
+
typeof subString === 'string'
|
|
118
118
|
? mainString
|
|
119
119
|
.toString()
|
|
120
120
|
.toLowerCase()
|
|
@@ -129,13 +129,13 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
129
129
|
return (
|
|
130
130
|
checkIncludesIfExists(mainString, subString) ||
|
|
131
131
|
(!!checkParams &&
|
|
132
|
-
((checkArrayContains(checkParams,
|
|
132
|
+
((checkArrayContains(checkParams, 'param1') &&
|
|
133
133
|
checkIncludesIfExists(param1, subString)) ||
|
|
134
|
-
(checkArrayContains(checkParams,
|
|
134
|
+
(checkArrayContains(checkParams, 'param2') &&
|
|
135
135
|
checkIncludesIfExists(param2, subString)) ||
|
|
136
|
-
(checkArrayContains(checkParams,
|
|
136
|
+
(checkArrayContains(checkParams, 'param3') &&
|
|
137
137
|
checkIncludesIfExists(param3, subString)) ||
|
|
138
|
-
(checkArrayContains(checkParams,
|
|
138
|
+
(checkArrayContains(checkParams, 'param4') &&
|
|
139
139
|
checkIncludesIfExists(param4, subString))))
|
|
140
140
|
);
|
|
141
141
|
};
|
|
@@ -146,8 +146,8 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
146
146
|
setInputValue(value);
|
|
147
147
|
handleValChange(value);
|
|
148
148
|
if (!value) {
|
|
149
|
-
setInputValue(
|
|
150
|
-
onChange({ id: undefined, name:
|
|
149
|
+
setInputValue('');
|
|
150
|
+
onChange({ id: undefined, name: '' });
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
|
|
@@ -155,11 +155,11 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
155
155
|
debounce(
|
|
156
156
|
(value: string) => {
|
|
157
157
|
setDropOpen(true);
|
|
158
|
-
onChange({ id: undefined, name:
|
|
159
|
-
if (value.trim() ===
|
|
158
|
+
onChange({ id: undefined, name: '' });
|
|
159
|
+
if (value.trim() === '' && type === 'auto_complete') {
|
|
160
160
|
setSuggestions([]);
|
|
161
161
|
if (autoFilter) {
|
|
162
|
-
handleDropData(
|
|
162
|
+
handleDropData('*');
|
|
163
163
|
} else {
|
|
164
164
|
setDropOpen(false);
|
|
165
165
|
}
|
|
@@ -172,11 +172,11 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
172
172
|
[]
|
|
173
173
|
);
|
|
174
174
|
const handleDropData = (value?: string) => {
|
|
175
|
-
if (type ===
|
|
175
|
+
if (type === 'auto_complete') {
|
|
176
176
|
if (isStaticList) {
|
|
177
177
|
loadStaticData();
|
|
178
178
|
const filteredData =
|
|
179
|
-
value && value !==
|
|
179
|
+
value && value !== '*'
|
|
180
180
|
? data?.filter((item) =>
|
|
181
181
|
checkIncludes(
|
|
182
182
|
item.name,
|
|
@@ -190,13 +190,13 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
190
190
|
setSuggestions(filteredData);
|
|
191
191
|
} else handlePickSuggestions(value);
|
|
192
192
|
} else if (
|
|
193
|
-
(type ===
|
|
193
|
+
(type === 'custom_select' || type === 'custom_search_select') &&
|
|
194
194
|
(!data || data?.length === 0)
|
|
195
195
|
) {
|
|
196
196
|
handlePickSuggestions();
|
|
197
|
-
} else if (type ===
|
|
197
|
+
} else if (type === 'custom_search_select' && data && data?.length > 0) {
|
|
198
198
|
const filteredData =
|
|
199
|
-
value && value !==
|
|
199
|
+
value && value !== '*'
|
|
200
200
|
? data.filter((item) =>
|
|
201
201
|
checkIncludes(
|
|
202
202
|
item.name,
|
|
@@ -226,10 +226,10 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
226
226
|
const onLabelClick = () => {
|
|
227
227
|
if (!isDisabled) {
|
|
228
228
|
inputRef?.current?.focus();
|
|
229
|
-
if (autoFilter && inputValue ===
|
|
230
|
-
handleValChange(
|
|
229
|
+
if (autoFilter && inputValue === '') {
|
|
230
|
+
handleValChange('*');
|
|
231
231
|
} else if (
|
|
232
|
-
(type ===
|
|
232
|
+
(type === 'custom_select' || type === 'custom_search_select') &&
|
|
233
233
|
data &&
|
|
234
234
|
data?.length > 0
|
|
235
235
|
) {
|
|
@@ -256,8 +256,8 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
256
256
|
if (getData) {
|
|
257
257
|
try {
|
|
258
258
|
setIsLoading(true);
|
|
259
|
-
handlePickSuggestions(
|
|
260
|
-
const fetchedSuggestions = await getData?.(
|
|
259
|
+
handlePickSuggestions('*');
|
|
260
|
+
const fetchedSuggestions = await getData?.('*');
|
|
261
261
|
fetchedSuggestions?.forEach((element: any) => {
|
|
262
262
|
data?.push(element);
|
|
263
263
|
});
|
|
@@ -269,9 +269,9 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
useEffect(() => {
|
|
272
|
-
document.addEventListener(
|
|
272
|
+
document.addEventListener('click', handleClickOutside);
|
|
273
273
|
return () => {
|
|
274
|
-
document.removeEventListener(
|
|
274
|
+
document.removeEventListener('click', handleClickOutside);
|
|
275
275
|
};
|
|
276
276
|
}, []);
|
|
277
277
|
|
|
@@ -282,10 +282,10 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
282
282
|
}, [autoFocus]);
|
|
283
283
|
const onInputFocus = () => {
|
|
284
284
|
if (!isDisabled) {
|
|
285
|
-
if (autoFilter && inputValue ===
|
|
286
|
-
handleValChange(
|
|
285
|
+
if (autoFilter && inputValue === '') {
|
|
286
|
+
handleValChange('*');
|
|
287
287
|
} else if (
|
|
288
|
-
(type ===
|
|
288
|
+
(type === 'custom_select' || type === 'custom_search_select') &&
|
|
289
289
|
data &&
|
|
290
290
|
data?.length > 0
|
|
291
291
|
) {
|
|
@@ -304,14 +304,14 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
304
304
|
name: suggestion.name,
|
|
305
305
|
...(suggestion?.label ? { label: suggestion?.label } : {}),
|
|
306
306
|
});
|
|
307
|
-
if (type !==
|
|
307
|
+
if (type !== 'custom_select') setInputValue(suggestion.name);
|
|
308
308
|
setDropOpen(false);
|
|
309
309
|
};
|
|
310
310
|
const handleOpen = (e: any) => {
|
|
311
311
|
if (!suggestions || suggestions?.length === 0) handleDropData();
|
|
312
312
|
if (!isLoading) {
|
|
313
313
|
setDropOpen(!dropOpen);
|
|
314
|
-
if (type !==
|
|
314
|
+
if (type !== 'custom_select') setInputValue('');
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
|
|
@@ -321,25 +321,25 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
321
321
|
|
|
322
322
|
useEffect(() => {
|
|
323
323
|
if (!insideOpen) {
|
|
324
|
-
window.addEventListener(
|
|
324
|
+
window.addEventListener('scroll', handleScroll);
|
|
325
325
|
|
|
326
|
-
const mainElement = document.querySelector(
|
|
327
|
-
mainElement?.addEventListener(
|
|
326
|
+
const mainElement = document.querySelector('main');
|
|
327
|
+
mainElement?.addEventListener('scroll', handleScroll);
|
|
328
328
|
|
|
329
|
-
const gridElements = document.querySelectorAll(
|
|
329
|
+
const gridElements = document.querySelectorAll('.k-grid-content');
|
|
330
330
|
gridElements.forEach((gridElement: any) => {
|
|
331
|
-
gridElement.addEventListener(
|
|
331
|
+
gridElement.addEventListener('scroll', handleScroll);
|
|
332
332
|
});
|
|
333
|
-
window.addEventListener(
|
|
333
|
+
window.addEventListener('resize', getDropPosition);
|
|
334
334
|
getDropPosition();
|
|
335
335
|
return () => {
|
|
336
|
-
window.removeEventListener(
|
|
337
|
-
const mainElement = document.querySelector(
|
|
338
|
-
mainElement?.removeEventListener(
|
|
339
|
-
window.addEventListener(
|
|
340
|
-
const gridElements = document.querySelectorAll(
|
|
336
|
+
window.removeEventListener('scroll', handleScroll);
|
|
337
|
+
const mainElement = document.querySelector('main');
|
|
338
|
+
mainElement?.removeEventListener('scroll', handleScroll);
|
|
339
|
+
window.addEventListener('resize', getDropPosition);
|
|
340
|
+
const gridElements = document.querySelectorAll('.k-grid-content');
|
|
341
341
|
gridElements.forEach((gridElement: any) => {
|
|
342
|
-
gridElement.removeEventListener(
|
|
342
|
+
gridElement.removeEventListener('scroll', handleScroll);
|
|
343
343
|
});
|
|
344
344
|
};
|
|
345
345
|
}
|
|
@@ -347,13 +347,13 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
347
347
|
|
|
348
348
|
const handleClear = () => {
|
|
349
349
|
setDropOpen(false);
|
|
350
|
-
setInputValue(
|
|
351
|
-
onChange({ id: undefined, name:
|
|
350
|
+
setInputValue('');
|
|
351
|
+
onChange({ id: undefined, name: '' });
|
|
352
352
|
onLabelClick();
|
|
353
353
|
};
|
|
354
354
|
|
|
355
355
|
useEffect(() => {
|
|
356
|
-
setInputValue(value?.name ??
|
|
356
|
+
setInputValue(value?.name ?? '');
|
|
357
357
|
}, [value?.name]);
|
|
358
358
|
|
|
359
359
|
useEffect(() => {
|
|
@@ -361,7 +361,7 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
361
361
|
}, [data]);
|
|
362
362
|
|
|
363
363
|
const getErrors = (err: any) => {
|
|
364
|
-
let errMsg =
|
|
364
|
+
let errMsg = '';
|
|
365
365
|
if (err.message) {
|
|
366
366
|
errMsg = err?.message;
|
|
367
367
|
} else if (err?.id?.message) {
|
|
@@ -372,59 +372,59 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
372
372
|
return errMsg;
|
|
373
373
|
};
|
|
374
374
|
const generateClassName = (
|
|
375
|
-
type:
|
|
375
|
+
type: 'input' | 'label' | 'message' | 'adorement'
|
|
376
376
|
): string => {
|
|
377
377
|
let className = propsClassName;
|
|
378
378
|
switch (type) {
|
|
379
|
-
case
|
|
379
|
+
case 'input':
|
|
380
380
|
className += `block text-common text-input-text font-normal px-3.5 w-full text-sm text-gray-900 bg-transparent border appearance-none peer h-10 rounded-[4px] disabled:text-input-disabled bg-white disabled:bg-disabled ${
|
|
381
381
|
label && isModern
|
|
382
|
-
?
|
|
383
|
-
:
|
|
382
|
+
? 'placeholder-transparent'
|
|
383
|
+
: 'focus:placeholder-grey-secondary placeholder-input-label'
|
|
384
384
|
} focus:placeholder-grey-secondary`;
|
|
385
385
|
|
|
386
386
|
if (errors && errors[name]) {
|
|
387
387
|
className +=
|
|
388
|
-
|
|
388
|
+
' border-[#FDA29B] focus:border-error-[#FDA29B] focus:ring-[#FDA29B] focus:ring-3 focus:outline-[#FDA29B] input-outline';
|
|
389
389
|
} else {
|
|
390
390
|
className +=
|
|
391
|
-
|
|
391
|
+
' text-grey-dark border-input-light focus:border-blue-navy focus:outline-none focus:ring-0';
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
break;
|
|
395
|
-
case
|
|
395
|
+
case 'label':
|
|
396
396
|
className += ` modern-input-label peer-focus:modern-input-peer-focus-label-size
|
|
397
397
|
${
|
|
398
398
|
isDisabled
|
|
399
|
-
?
|
|
400
|
-
:
|
|
399
|
+
? 'cursor-pointer'
|
|
400
|
+
: 'cursor-text peer-focus:cursor-pointer'
|
|
401
401
|
} ${
|
|
402
402
|
!isDisabled || !checkIsEmptyField()
|
|
403
|
-
?
|
|
403
|
+
? 'active-input-label-bg'
|
|
404
404
|
: isDisabled && !checkIsEmptyField()
|
|
405
|
-
?
|
|
406
|
-
:
|
|
405
|
+
? 'disabled-input-label-bg'
|
|
406
|
+
: ''
|
|
407
407
|
} absolute duration-300 transform -translate-y-4 top-2 z-1 origin-[0] px-0 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-2 peer-focus:-translate-y-4 start-[14px] rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto ${
|
|
408
408
|
isDisabled
|
|
409
|
-
?
|
|
410
|
-
:
|
|
409
|
+
? 'cursor-pointer'
|
|
410
|
+
: 'cursor-text peer-focus:cursor-pointer'
|
|
411
411
|
}
|
|
412
412
|
${
|
|
413
413
|
checkIsEmptyField()
|
|
414
|
-
?
|
|
415
|
-
:
|
|
414
|
+
? 'modern-input-label-size'
|
|
415
|
+
: 'modern-input-peer-focus-label-size'
|
|
416
416
|
}`;
|
|
417
417
|
if (errors && errors[name]) {
|
|
418
|
-
className +=
|
|
418
|
+
className += ' text-error-light ';
|
|
419
419
|
} else {
|
|
420
|
-
className +=
|
|
420
|
+
className += ' text-grey-dark peer-focus:text-blue-navy';
|
|
421
421
|
}
|
|
422
422
|
break;
|
|
423
|
-
case
|
|
424
|
-
className =
|
|
423
|
+
case 'message':
|
|
424
|
+
className = ' text-error-icon ';
|
|
425
425
|
break;
|
|
426
|
-
case
|
|
427
|
-
className +=
|
|
426
|
+
case 'adorement':
|
|
427
|
+
className += ' absolute right-0 adorement gap-1 flex items-center ';
|
|
428
428
|
break;
|
|
429
429
|
default:
|
|
430
430
|
break;
|
|
@@ -449,27 +449,27 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
449
449
|
// return 'bottom'
|
|
450
450
|
// }
|
|
451
451
|
const filteredData =
|
|
452
|
-
inputValue !==
|
|
452
|
+
inputValue !== '*' && type !== 'custom_select' && !noLocalFilter
|
|
453
453
|
? suggestions?.filter((item: valueProps) =>
|
|
454
454
|
checkIncludes(
|
|
455
455
|
item.name,
|
|
456
456
|
inputValue,
|
|
457
|
-
item.param1 ??
|
|
458
|
-
item.param2 ??
|
|
459
|
-
item.param3 ??
|
|
460
|
-
item.param4 ??
|
|
457
|
+
item.param1 ?? '',
|
|
458
|
+
item.param2 ?? '',
|
|
459
|
+
item.param3 ?? '',
|
|
460
|
+
item.param4 ?? ''
|
|
461
461
|
)
|
|
462
462
|
)
|
|
463
463
|
: suggestions;
|
|
464
464
|
|
|
465
465
|
const handleError = (data: any) => {
|
|
466
466
|
if (
|
|
467
|
-
getErrors(data[name]) ===
|
|
468
|
-
getErrors(data[name]) ===
|
|
467
|
+
getErrors(data[name]) === 'required' ||
|
|
468
|
+
getErrors(data[name]) === 'Required'
|
|
469
469
|
) {
|
|
470
470
|
return `${label ?? labelTitle} is ${getErrors(data[name])}`;
|
|
471
471
|
} else {
|
|
472
|
-
return getErrors(data[name]) ??
|
|
472
|
+
return getErrors(data[name]) ?? '';
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
|
|
@@ -525,8 +525,8 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
525
525
|
<li
|
|
526
526
|
className={`${
|
|
527
527
|
value?.id === suggestion?.id
|
|
528
|
-
?
|
|
529
|
-
:
|
|
528
|
+
? 'bg-blue-navy text-white'
|
|
529
|
+
: 'hover:bg-table-hover'
|
|
530
530
|
} cursor-pointer p-1 text-xxs ps-3.5`}
|
|
531
531
|
key={suggestion?.id}
|
|
532
532
|
data-testid={suggestion.name}
|
|
@@ -565,12 +565,12 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
565
565
|
};
|
|
566
566
|
|
|
567
567
|
useEffect(() => {
|
|
568
|
-
applyPositionClass(dropdownref);
|
|
568
|
+
if (isHovered) applyPositionClass(dropdownref);
|
|
569
569
|
}, [isHovered]);
|
|
570
570
|
|
|
571
571
|
return (
|
|
572
572
|
<div
|
|
573
|
-
className={` flex-grow ${fullWidth ?
|
|
573
|
+
className={` flex-grow ${fullWidth ? 'w-full' : 'w-auto'}`}
|
|
574
574
|
ref={dropdownref}
|
|
575
575
|
>
|
|
576
576
|
{label && !isModern && (
|
|
@@ -587,15 +587,15 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
587
587
|
)}
|
|
588
588
|
|
|
589
589
|
<div
|
|
590
|
-
className={`flex relative ${fullWidth ?
|
|
590
|
+
className={`flex relative ${fullWidth ? 'w-full' : 'w-auto'}`}
|
|
591
591
|
style={{ width: width }}
|
|
592
592
|
>
|
|
593
593
|
<div className="relative w-full">
|
|
594
594
|
<input
|
|
595
595
|
id={id}
|
|
596
596
|
type="text"
|
|
597
|
-
readOnly={readOnly ?? type ===
|
|
598
|
-
value={inputValue ? inputValue :
|
|
597
|
+
readOnly={readOnly ?? type === 'custom_select'}
|
|
598
|
+
value={inputValue ? inputValue : ''}
|
|
599
599
|
onBlur={handleClearInputValue}
|
|
600
600
|
disabled={disabled}
|
|
601
601
|
ref={inputRef}
|
|
@@ -614,18 +614,18 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
614
614
|
}
|
|
615
615
|
: {}),
|
|
616
616
|
}}
|
|
617
|
-
className={` ${generateClassName(
|
|
617
|
+
className={` ${generateClassName('input')}`}
|
|
618
618
|
onChange={handleChange}
|
|
619
619
|
placeholder={
|
|
620
|
-
type ===
|
|
620
|
+
type === 'auto_complete'
|
|
621
621
|
? placeholder && isCustomPlaceholder
|
|
622
622
|
? placeholder
|
|
623
|
-
:
|
|
624
|
-
: placeholder ??
|
|
623
|
+
: 'Type to search'
|
|
624
|
+
: placeholder ?? '--Select--'
|
|
625
625
|
}
|
|
626
626
|
onFocus={onInputFocus}
|
|
627
627
|
onClick={(e) => {
|
|
628
|
-
if (type ===
|
|
628
|
+
if (type === 'custom_select') {
|
|
629
629
|
setDropOpen(!dropOpen);
|
|
630
630
|
handleOpen(e);
|
|
631
631
|
} else {
|
|
@@ -637,7 +637,7 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
637
637
|
<label
|
|
638
638
|
htmlFor={id}
|
|
639
639
|
onClick={() => onLabelClick()}
|
|
640
|
-
className={generateClassName(
|
|
640
|
+
className={generateClassName('label')}
|
|
641
641
|
>
|
|
642
642
|
{label}
|
|
643
643
|
{required && label ? (
|
|
@@ -651,12 +651,12 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
651
651
|
<div className="flex items-center justify-center ">
|
|
652
652
|
<div
|
|
653
653
|
ref={adorementRef}
|
|
654
|
-
className={`${generateClassName(
|
|
655
|
-
isLoading ?
|
|
654
|
+
className={`${generateClassName('adorement')} mr-[1px] ${
|
|
655
|
+
isLoading ? 'bg-white' : ''
|
|
656
656
|
}`}
|
|
657
657
|
>
|
|
658
658
|
{value?.name &&
|
|
659
|
-
(value?.id || String(value?.id) ===
|
|
659
|
+
(value?.id || String(value?.id) === '0') &&
|
|
660
660
|
!disabled &&
|
|
661
661
|
!readOnly &&
|
|
662
662
|
isClose && (
|
|
@@ -670,7 +670,7 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
670
670
|
</button>
|
|
671
671
|
)}
|
|
672
672
|
{isLoading && <Spinner />}
|
|
673
|
-
{type !==
|
|
673
|
+
{type !== 'auto_complete' && !disabled && !readOnly && (
|
|
674
674
|
<button
|
|
675
675
|
disabled={disabled ?? readOnly}
|
|
676
676
|
onClick={(e) => handleOpen(e)}
|
|
@@ -682,16 +682,16 @@ const ModernAutoComplete: React.FC<AutoSuggestionInputProps> = ({
|
|
|
682
682
|
>
|
|
683
683
|
<CustomIcons
|
|
684
684
|
onClick={(e) => handleOpen(e)}
|
|
685
|
-
name={`${dropOpen ?
|
|
685
|
+
name={`${dropOpen ? 'menu-up-arrow' : 'menu-down-arrow'}`}
|
|
686
686
|
type="large"
|
|
687
|
-
style={{ pointerEvents:
|
|
687
|
+
style={{ pointerEvents: 'none' }}
|
|
688
688
|
/>
|
|
689
689
|
</button>
|
|
690
690
|
)}
|
|
691
691
|
{errors && errors[name] && (
|
|
692
692
|
<div
|
|
693
693
|
className={` text-error-label relative cursor-pointer ${generateClassName(
|
|
694
|
-
|
|
694
|
+
'message'
|
|
695
695
|
)}`}
|
|
696
696
|
onMouseEnter={() => setIsHovered(true)}
|
|
697
697
|
onMouseLeave={() => setIsHovered(false)}
|