react-core-ts 1.7.3 → 1.7.5

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,12 +1,12 @@
1
- import React, { useCallback, useEffect, useRef, useState } from "react";
2
- import { FieldErrors } from "react-hook-form";
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { FieldErrors } from 'react-hook-form';
3
3
 
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
- import { AllDropArrow, DropArrow } from "./utilities/icons";
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
+ import { AllDropArrow, DropArrow } from './utilities/icons';
10
10
 
11
11
  type valueProps = {
12
12
  id?: string | number;
@@ -30,7 +30,7 @@ interface AutoSuggestionInputProps {
30
30
  value?: valueProps;
31
31
  onChange: (value?: valueProps) => void;
32
32
  data?: any[];
33
- type?: "custom_select" | "auto_complete" | "custom_search_select";
33
+ type?: 'custom_select' | 'auto_complete' | 'custom_search_select';
34
34
  placeholder?: string;
35
35
  getData?: ((key?: string) => Promise<any>) | ((key?: string) => any);
36
36
  errors?: FieldErrors;
@@ -63,12 +63,12 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
63
63
  required = false,
64
64
  autoFocus,
65
65
  name,
66
- shortCode = "",
66
+ shortCode = '',
67
67
  fullWidth,
68
68
  placeholder,
69
69
  id,
70
70
  className: propsClassName,
71
- type = "custom_select",
71
+ type = 'custom_select',
72
72
  readOnly,
73
73
  disabled = false,
74
74
  value,
@@ -86,7 +86,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
86
86
  labelTitle,
87
87
  isModern = true,
88
88
  }) => {
89
- const [inputValue, setInputValue] = useState<any>(value?.name ?? "");
89
+ const [inputValue, setInputValue] = useState<any>(value?.name ?? '');
90
90
  const [isHovered, setIsHovered] = useState<boolean>(false);
91
91
  const [isLoading, setIsLoading] = useState<boolean>(false);
92
92
  const [dropOpen, setDropOpen] = useState<boolean>(false);
@@ -125,8 +125,8 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
125
125
  ) => {
126
126
  return substring &&
127
127
  mainString &&
128
- typeof mainString === "string" &&
129
- typeof subString === "string"
128
+ typeof mainString === 'string' &&
129
+ typeof subString === 'string'
130
130
  ? mainString
131
131
  .toString()
132
132
  .toLowerCase()
@@ -141,13 +141,13 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
141
141
  return (
142
142
  checkIncludesIfExists(mainString, subString) ||
143
143
  (!!checkParams &&
144
- ((checkArrayContains(checkParams, "param1") &&
144
+ ((checkArrayContains(checkParams, 'param1') &&
145
145
  checkIncludesIfExists(param1, subString)) ||
146
- (checkArrayContains(checkParams, "param2") &&
146
+ (checkArrayContains(checkParams, 'param2') &&
147
147
  checkIncludesIfExists(param2, subString)) ||
148
- (checkArrayContains(checkParams, "param3") &&
148
+ (checkArrayContains(checkParams, 'param3') &&
149
149
  checkIncludesIfExists(param3, subString)) ||
150
- (checkArrayContains(checkParams, "param4") &&
150
+ (checkArrayContains(checkParams, 'param4') &&
151
151
  checkIncludesIfExists(param4, subString))))
152
152
  );
153
153
  };
@@ -159,8 +159,8 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
159
159
  setInputValue(value);
160
160
  handleValChange(value);
161
161
  if (!value) {
162
- setInputValue("");
163
- onChange({ id: undefined, name: "", from: 2 });
162
+ setInputValue('');
163
+ onChange({ id: undefined, name: '', from: 2 });
164
164
  }
165
165
  };
166
166
 
@@ -168,11 +168,11 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
168
168
  debounce(
169
169
  (value: string) => {
170
170
  setDropOpen(true);
171
- onChange({ id: undefined, name: "", from: 1 });
172
- if (value.trim() === "" && type === "auto_complete") {
171
+ onChange({ id: undefined, name: '', from: 1 });
172
+ if (value.trim() === '' && type === 'auto_complete') {
173
173
  setSuggestions([]);
174
174
  if (autoFilter) {
175
- handleDropData("*");
175
+ handleDropData('*');
176
176
  } else {
177
177
  setDropOpen(false);
178
178
  }
@@ -188,11 +188,11 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
188
188
  []
189
189
  );
190
190
  const handleDropData = (value?: string) => {
191
- if (type === "auto_complete") {
191
+ if (type === 'auto_complete') {
192
192
  if (isStaticList) {
193
193
  loadStaticData();
194
194
  const filteredData =
195
- value && value !== "*"
195
+ value && value !== '*'
196
196
  ? data?.filter((item) =>
197
197
  checkIncludes(
198
198
  item.name,
@@ -208,13 +208,13 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
208
208
  handlePickSuggestions(value);
209
209
  }
210
210
  } else if (
211
- (type === "custom_select" || type === "custom_search_select") &&
211
+ (type === 'custom_select' || type === 'custom_search_select') &&
212
212
  (!data || data?.length === 0)
213
213
  ) {
214
214
  handlePickSuggestions();
215
- } else if (type === "custom_search_select" && data && data?.length > 0) {
215
+ } else if (type === 'custom_search_select' && data && data?.length > 0) {
216
216
  const filteredData =
217
- value && value !== "*"
217
+ value && value !== '*'
218
218
  ? data.filter((item) =>
219
219
  checkIncludes(
220
220
  item.name,
@@ -247,10 +247,10 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
247
247
  const onLabelClick = () => {
248
248
  if (!isDisabled) {
249
249
  inputRef?.current?.focus();
250
- if (autoFilter && inputValue === "") {
251
- handleValChange("*");
250
+ if (autoFilter && inputValue === '') {
251
+ handleValChange('*');
252
252
  } else if (
253
- (type === "custom_select" || type === "custom_search_select") &&
253
+ (type === 'custom_select' || type === 'custom_search_select') &&
254
254
  data &&
255
255
  data?.length > 0
256
256
  ) {
@@ -278,7 +278,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
278
278
  try {
279
279
  setIsLoading(true);
280
280
  //handlePickSuggestions('*');
281
- const fetchedSuggestions = await getData?.("*");
281
+ const fetchedSuggestions = await getData?.('*');
282
282
  fetchedSuggestions?.forEach((element: any) => {
283
283
  data?.push(element);
284
284
  });
@@ -294,9 +294,9 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
294
294
  }
295
295
  };
296
296
  useEffect(() => {
297
- document.addEventListener("click", handleClickOutside);
297
+ document.addEventListener('click', handleClickOutside);
298
298
  return () => {
299
- document.removeEventListener("click", handleClickOutside);
299
+ document.removeEventListener('click', handleClickOutside);
300
300
  };
301
301
  }, []);
302
302
 
@@ -307,10 +307,10 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
307
307
  }, [autoFocus]);
308
308
  const onInputFocus = () => {
309
309
  if (!isDisabled) {
310
- if (autoFilter && inputValue === "") {
311
- handleValChange("*");
310
+ if (autoFilter && inputValue === '') {
311
+ handleValChange('*');
312
312
  } else if (
313
- (type === "custom_select" || type === "custom_search_select") &&
313
+ (type === 'custom_select' || type === 'custom_search_select') &&
314
314
  data &&
315
315
  data?.length > 0
316
316
  ) {
@@ -329,7 +329,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
329
329
  name: suggestion.name,
330
330
  ...(suggestion?.label ? { label: suggestion?.label } : {}),
331
331
  });
332
- if (type !== "custom_select") setInputValue(suggestion.name);
332
+ if (type !== 'custom_select') setInputValue(suggestion.name);
333
333
  setDropOpen(false);
334
334
  setSelectedIndex(index);
335
335
  };
@@ -337,13 +337,13 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
337
337
  if (!suggestions || suggestions?.length === 0) handleDropData();
338
338
  if (!isLoading) {
339
339
  setDropOpen(!dropOpen);
340
- if (type !== "custom_select") setInputValue("");
340
+ if (type !== 'custom_select') setInputValue('');
341
341
  }
342
342
  };
343
343
 
344
344
  const handleOpenDropdown = (e: any) => {
345
345
  if (!suggestions || suggestions?.length === 0 || refetchData) {
346
- if (autoDropdown && (inputValue === "" || inputValue.trim() === "")) {
346
+ if (autoDropdown && (inputValue === '' || inputValue.trim() === '')) {
347
347
  setSuggestions([]);
348
348
  loadStaticData();
349
349
  } else if (!refetchData) {
@@ -362,28 +362,28 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
362
362
  useEffect(() => {
363
363
  if (!insideOpen) {
364
364
  setSelectedIndex(0);
365
- window.addEventListener("scroll", handleScroll);
365
+ window.addEventListener('scroll', handleScroll);
366
366
 
367
- const mainElement = document.querySelector("main");
368
- mainElement?.addEventListener("scroll", handleScroll);
367
+ const mainElement = document.querySelector('main');
368
+ mainElement?.addEventListener('scroll', handleScroll);
369
369
 
370
370
  const gridElements = document.querySelectorAll(
371
- ".k-grid-content, .overflow-auto, .overflow-y-auto, .overflow-x-auto"
371
+ '.k-grid-content, .overflow-auto, .overflow-y-auto, .overflow-x-auto'
372
372
  );
373
373
  gridElements.forEach((gridElement: any) => {
374
- gridElement.addEventListener("scroll", handleScroll);
374
+ gridElement.addEventListener('scroll', handleScroll);
375
375
  });
376
376
 
377
- window.addEventListener("resize", getDropPosition);
377
+ window.addEventListener('resize', getDropPosition);
378
378
  getDropPosition();
379
379
  return () => {
380
- window.removeEventListener("scroll", handleScroll);
381
- const mainElement = document.querySelector("main");
382
- mainElement?.removeEventListener("scroll", handleScroll);
383
- window.addEventListener("resize", getDropPosition);
384
- const gridElements = document.querySelectorAll(".k-grid-content");
380
+ window.removeEventListener('scroll', handleScroll);
381
+ const mainElement = document.querySelector('main');
382
+ mainElement?.removeEventListener('scroll', handleScroll);
383
+ window.addEventListener('resize', getDropPosition);
384
+ const gridElements = document.querySelectorAll('.k-grid-content');
385
385
  gridElements.forEach((gridElement: any) => {
386
- gridElement.removeEventListener("scroll", handleScroll);
386
+ gridElement.removeEventListener('scroll', handleScroll);
387
387
  });
388
388
  };
389
389
  }
@@ -391,8 +391,8 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
391
391
 
392
392
  const handleClear = () => {
393
393
  setDropOpen(false);
394
- setInputValue("");
395
- onChange({ id: undefined, name: "", from: 3 });
394
+ setInputValue('');
395
+ onChange({ id: undefined, name: '', from: 3 });
396
396
  onLabelClick();
397
397
  if (autoDropdown) {
398
398
  setRefetchData(true);
@@ -400,7 +400,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
400
400
  };
401
401
 
402
402
  useEffect(() => {
403
- setInputValue(value?.name ?? "");
403
+ setInputValue(value?.name ?? '');
404
404
  }, [value?.name]);
405
405
 
406
406
  useEffect(() => {
@@ -408,7 +408,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
408
408
  }, [data]);
409
409
 
410
410
  const getErrors = (err: any) => {
411
- let errMsg = "";
411
+ let errMsg = '';
412
412
  if (err.message) {
413
413
  errMsg = err?.message;
414
414
  } else if (err?.id?.message) {
@@ -419,59 +419,59 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
419
419
  return errMsg;
420
420
  };
421
421
  const generateClassName = (
422
- type: "input" | "label" | "message" | "adorement"
422
+ type: 'input' | 'label' | 'message' | 'adorement'
423
423
  ): string => {
424
424
  let className = propsClassName;
425
425
  switch (type) {
426
- case "input":
426
+ case 'input':
427
427
  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 ${
428
428
  label && isModern
429
- ? "placeholder-transparent"
430
- : "focus:placeholder-grey-secondary placeholder-input-label"
429
+ ? 'placeholder-transparent'
430
+ : 'focus:placeholder-grey-secondary placeholder-input-label'
431
431
  } focus:placeholder-grey-secondary`;
432
432
 
433
433
  if (errors && errors[name]) {
434
434
  className +=
435
- " border-[#FDA29B] focus:border-error-[#FDA29B] focus:ring-[#FDA29B] focus:ring-3 focus:outline-[#FDA29B] input-outline";
435
+ ' border-[#FDA29B] focus:border-error-[#FDA29B] focus:ring-[#FDA29B] focus:ring-3 focus:outline-[#FDA29B] input-outline';
436
436
  } else {
437
437
  className +=
438
- " text-grey-dark border-input-light focus:border-blue-navy focus:outline-none focus:ring-0";
438
+ ' text-grey-dark border-input-light focus:border-blue-navy focus:outline-none focus:ring-0';
439
439
  }
440
440
 
441
441
  break;
442
- case "label":
442
+ case 'label':
443
443
  className += ` flex modern-input-label-truncate peer-focus:modern-input-peer-focus-label-size
444
444
  ${
445
445
  isDisabled
446
- ? "cursor-pointer"
447
- : "cursor-text peer-focus:cursor-pointer"
446
+ ? 'cursor-pointer'
447
+ : 'cursor-text peer-focus:cursor-pointer'
448
448
  } ${
449
449
  isDisabled && !checkIsEmptyField()
450
- ? "disabled-input-label-bg"
450
+ ? 'disabled-input-label-bg'
451
451
  : !isDisabled || !checkIsEmptyField()
452
- ? "active-input-label-bg"
453
- : ""
452
+ ? 'active-input-label-bg'
453
+ : ''
454
454
  } 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 ${
455
455
  isDisabled
456
- ? "cursor-pointer"
457
- : "cursor-text peer-focus:cursor-pointer"
456
+ ? 'cursor-pointer'
457
+ : 'cursor-text peer-focus:cursor-pointer'
458
458
  }
459
459
  ${
460
460
  checkIsEmptyField()
461
- ? "modern-input-label-size"
462
- : "modern-input-peer-focus-label-size"
461
+ ? 'modern-input-label-size'
462
+ : 'modern-input-peer-focus-label-size'
463
463
  }`;
464
464
  if (errors && errors[name]) {
465
- className += " text-error-light ";
465
+ className += ' text-error-light ';
466
466
  } else {
467
- className += " text-grey-dark peer-focus:text-blue-navy";
467
+ className += ' text-grey-dark peer-focus:text-blue-navy';
468
468
  }
469
469
  break;
470
- case "message":
471
- className = " text-error-icon ";
470
+ case 'message':
471
+ className = ' text-error-icon ';
472
472
  break;
473
- case "adorement":
474
- className += " absolute right-0 adorement gap-1 flex items-center ";
473
+ case 'adorement':
474
+ className += ' absolute right-0 adorement gap-1 flex items-center ';
475
475
  break;
476
476
  default:
477
477
  break;
@@ -496,30 +496,30 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
496
496
  // return 'bottom'
497
497
  // }
498
498
  const filteredData =
499
- inputValue !== "*" &&
500
- inputValue !== "" &&
501
- type !== "custom_select" &&
499
+ inputValue !== '*' &&
500
+ inputValue !== '' &&
501
+ type !== 'custom_select' &&
502
502
  !noLocalFilter
503
503
  ? suggestions?.filter((item: valueProps) =>
504
504
  checkIncludes(
505
505
  item.name,
506
506
  inputValue,
507
- item.param1 ?? "",
508
- item.param2 ?? "",
509
- item.param3 ?? "",
510
- item.param4 ?? ""
507
+ item.param1 ?? '',
508
+ item.param2 ?? '',
509
+ item.param3 ?? '',
510
+ item.param4 ?? ''
511
511
  )
512
512
  )
513
513
  : suggestions;
514
514
 
515
515
  const handleError = (data: any) => {
516
516
  if (
517
- getErrors(data[name]) === "required" ||
518
- getErrors(data[name]) === "Required"
517
+ getErrors(data[name]) === 'required' ||
518
+ getErrors(data[name]) === 'Required'
519
519
  ) {
520
520
  return `${label ?? labelTitle} is ${getErrors(data[name])}`;
521
521
  } else {
522
- return getErrors(data[name]) ?? "";
522
+ return getErrors(data[name]) ?? '';
523
523
  }
524
524
  };
525
525
 
@@ -575,7 +575,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
575
575
  const atTop = selectedIndex === 0;
576
576
 
577
577
  switch (e.key) {
578
- case "ArrowDown":
578
+ case 'ArrowDown':
579
579
  e.preventDefault();
580
580
  if (itemRefs.current && scrollContainerRef.current) {
581
581
  if (!atBottom) {
@@ -588,7 +588,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
588
588
  setSelectedIndex((prev) => (prev + 1) % filteredData?.length);
589
589
  break;
590
590
 
591
- case "ArrowUp":
591
+ case 'ArrowUp':
592
592
  e.preventDefault();
593
593
  if (itemRefs.current && scrollContainerRef.current) {
594
594
  if (!atTop) {
@@ -603,12 +603,12 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
603
603
  );
604
604
  break;
605
605
 
606
- case "Enter":
606
+ case 'Enter':
607
607
  e.preventDefault();
608
608
  handleSuggestionClick(filteredData[selectedIndex], selectedIndex);
609
609
  break;
610
610
 
611
- case "Escape":
611
+ case 'Escape':
612
612
  e.preventDefault();
613
613
  setDropOpen(false);
614
614
  break;
@@ -619,9 +619,9 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
619
619
  };
620
620
 
621
621
  if (filteredData?.length > 0 && !isLoading) {
622
- window.addEventListener("keydown", handleKeyDown);
622
+ window.addEventListener('keydown', handleKeyDown);
623
623
  return () => {
624
- window.removeEventListener("keydown", handleKeyDown);
624
+ window.removeEventListener('keydown', handleKeyDown);
625
625
  };
626
626
  }
627
627
  }, [
@@ -647,9 +647,9 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
647
647
  <li
648
648
  className={`${
649
649
  value?.id === suggestion?.id
650
- ? "bg-blue-navy text-white"
650
+ ? 'bg-blue-navy text-white'
651
651
  : `${
652
- index === selectedIndex ? "is-selected" : ""
652
+ index === selectedIndex ? 'is-selected' : ''
653
653
  } hover:bg-table-hover`
654
654
  } cursor-pointer p-1 text-xxs ps-3.5 pl-[10px] qbs-autocomplete-suggections-items`}
655
655
  key={suggestion?.id}
@@ -708,7 +708,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
708
708
  useEffect(() => {
709
709
  const shouldShowClose =
710
710
  value?.name &&
711
- (value?.id || String(value?.id) === "0") &&
711
+ (value?.id || String(value?.id) === '0') &&
712
712
  !disabled &&
713
713
  !readOnly &&
714
714
  isClose;
@@ -722,7 +722,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
722
722
  if (inputRef.current) {
723
723
  const { scrollWidth, clientWidth, value } = inputRef.current;
724
724
  // Check for overflow only when there's content
725
- if (value.trim() !== "") {
725
+ if (value.trim() !== '') {
726
726
  setShowTooltip(scrollWidth > clientWidth + 2);
727
727
  } else {
728
728
  setShowTooltip(false); // No tooltip for empty input
@@ -731,13 +731,13 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
731
731
  };
732
732
 
733
733
  if (inputRef.current) {
734
- inputRef.current.addEventListener("input", checkOverflow);
734
+ inputRef.current.addEventListener('input', checkOverflow);
735
735
  checkOverflow(); // Initial check
736
736
  }
737
737
 
738
738
  return () => {
739
739
  if (inputRef.current) {
740
- inputRef.current.removeEventListener("input", checkOverflow);
740
+ inputRef.current.removeEventListener('input', checkOverflow);
741
741
  }
742
742
  };
743
743
  }, [inputValue]);
@@ -755,7 +755,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
755
755
  id={
756
756
  id ? `autocomplete-container-${id}` : `autocomplete-container-${name}`
757
757
  }
758
- className={` flex-grow ${fullWidth ? "w-full" : "w-auto"}`}
758
+ className={` flex-grow ${fullWidth ? 'w-full' : 'w-auto'}`}
759
759
  ref={dropdownref}
760
760
  >
761
761
  {label && !isModern && (
@@ -775,7 +775,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
775
775
  )}
776
776
 
777
777
  <div
778
- className={`flex relative ${fullWidth ? "w-full" : "w-auto"}`}
778
+ className={`flex relative ${fullWidth ? 'w-full' : 'w-auto'}`}
779
779
  style={{ width: width }}
780
780
  >
781
781
  <div
@@ -785,8 +785,8 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
785
785
  >
786
786
  <input
787
787
  type="text"
788
- readOnly={readOnly ?? type === "custom_select"}
789
- value={inputValue ? inputValue : ""}
788
+ readOnly={readOnly ?? type === 'custom_select'}
789
+ value={inputValue ? inputValue : ''}
790
790
  onBlur={handleClearInputValue}
791
791
  autoComplete="off"
792
792
  disabled={disabled}
@@ -809,18 +809,18 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
809
809
  }
810
810
  : {}),
811
811
  }}
812
- className={` ${generateClassName("input")}`}
812
+ className={` ${generateClassName('input')}`}
813
813
  onChange={handleChange}
814
814
  placeholder={
815
- type === "auto_complete"
815
+ type === 'auto_complete'
816
816
  ? placeholder && isCustomPlaceholder
817
817
  ? placeholder
818
- : "Type to search"
819
- : placeholder ?? "--Select--"
818
+ : 'Type to search'
819
+ : placeholder ?? '--Select--'
820
820
  }
821
821
  onFocus={onInputFocus}
822
822
  onClick={(e) => {
823
- if (type === "custom_select") {
823
+ if (type === 'custom_select') {
824
824
  setDropOpen(!dropOpen);
825
825
  handleOpen(e);
826
826
  } else {
@@ -833,20 +833,20 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
833
833
  <label
834
834
  htmlFor={id}
835
835
  onClick={() => onLabelClick()}
836
- className={generateClassName("label")}
836
+ className={generateClassName('label')}
837
837
  >
838
- {label ? <span className="truncate">{label}</span> : ""}
838
+ {label ? <span className="truncate">{label}</span> : ''}
839
839
  {required ? <span className="text-error"> *</span> : <></>}
840
840
  </label>
841
841
  )}
842
842
  </div>
843
- <div className="flex items-center justify-center ">
843
+ <div className="flex items-center justify-center autocomplete-adorement-wrapper">
844
844
  <div
845
845
  ref={adorementRef}
846
846
  className={`${generateClassName(
847
- "adorement"
847
+ 'adorement'
848
848
  )} qbs-autocomplete-adorement mr-[1px] ${
849
- isLoading ? "bg-white" : ""
849
+ isLoading ? 'bg-white' : ''
850
850
  }`}
851
851
  >
852
852
  {showClose && (
@@ -861,7 +861,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
861
861
  </button>
862
862
  )}
863
863
  {isLoading && <Spinner />}
864
- {(type !== "auto_complete" || autoDropdown) &&
864
+ {(type !== 'auto_complete' || autoDropdown) &&
865
865
  !disabled &&
866
866
  !readOnly && (
867
867
  <button
@@ -901,7 +901,7 @@ const ModernAutoCompleteDropdown: React.FC<AutoSuggestionInputProps> = ({
901
901
  {errors && errors[name] && (
902
902
  <div
903
903
  className={` text-error-label relative cursor-pointer ${generateClassName(
904
- "message"
904
+ 'message'
905
905
  )}`}
906
906
  onMouseEnter={() => setIsHovered(true)}
907
907
  onMouseLeave={() => setIsHovered(false)}
@@ -78,6 +78,7 @@ export interface AutoSuggestionInputProps {
78
78
  filterValue?: any;
79
79
  };
80
80
  shortCode?: string
81
+ tabInlineSearch?: boolean // tab dropdown search
81
82
  }
82
83
  export interface IconsProps {
83
84
  name: any;
@@ -387,13 +387,25 @@ ul {
387
387
  flex-wrap: wrap;
388
388
  }
389
389
 
390
+ .selected-items-counter-container {
391
+ display: flex;
392
+ gap: 12px;
393
+ align-items: center;
394
+ position: absolute;
395
+ right: 8px;
396
+ z-index: 99;
397
+ top: 6.5px;
398
+ flex-wrap: wrap;
399
+ }
400
+
390
401
  .qbs-expandable-container .selected-items-container {
391
402
  position: relative;
392
403
  top: 0;
393
404
  left: 0;
394
405
  }
395
406
 
396
- .selected-items-container .badge {
407
+ .selected-items-container .badge,
408
+ .selected-items-counter-container .badge {
397
409
  background-color: #c63a3a;
398
410
  color: #fff;
399
411
  }
@@ -30,6 +30,7 @@ type UseSuggestionsType = (
30
30
  append?: boolean,
31
31
  tabValue?: string | number
32
32
  ) => Promise<void>;
33
+ resetSuggections?: () => void
33
34
  };
34
35
 
35
36
  export const useSuggestions: UseSuggestionsType = (
@@ -48,6 +49,10 @@ export const useSuggestions: UseSuggestionsType = (
48
49
  const [suggestions, setSuggestions] = useState<ValueProps[]>(initialData);
49
50
  const [isLoading, setIsLoading] = useState<boolean>(false);
50
51
 
52
+ const resetSuggections = () => {
53
+ setSuggestions([]);
54
+ }
55
+
51
56
  const handlePickSuggestions = async (
52
57
  value?: string,
53
58
  nextPage?: number,
@@ -90,5 +95,5 @@ export const useSuggestions: UseSuggestionsType = (
90
95
  }
91
96
  }, [dropOpen]);
92
97
 
93
- return { suggestions, isLoading, handlePickSuggestions };
98
+ return { suggestions, isLoading, handlePickSuggestions, resetSuggections};
94
99
  };