react-core-ts 1.3.32 → 1.3.33

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,11 +1,4 @@
1
- import React, {
2
- forwardRef,
3
- useCallback,
4
- useEffect,
5
- useImperativeHandle,
6
- useRef,
7
- useState,
8
- } from 'react';
1
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
2
  import ReactDOM from 'react-dom';
10
3
 
11
4
  import { AutoSuggestionInputProps, TabPops, ValueProps } from './commontypes';
@@ -73,9 +66,9 @@ const AutoCompleteWithSelectedList = forwardRef<
73
66
  const dropdownRef = useRef<HTMLDivElement>(null);
74
67
  const dropdownSelectedRef = useRef<HTMLDivElement>(null);
75
68
  const tabRef = useRef<HTMLUListElement>(null);
69
+ const dropLevelRef = useRef<string>('bottom');
76
70
  // State Hooks Section
77
71
  const [isInitialRender, setIsInitialRender] = useState(true);
78
-
79
72
  const [inputValue, setInputValue] = useState<string>(value);
80
73
  const [searchValue, setSearchValue] = useState<string>('');
81
74
  const [searchOldValue, setSearchOldValue] = useState<string>('');
@@ -121,9 +114,11 @@ const AutoCompleteWithSelectedList = forwardRef<
121
114
  if (tabRef?.current) dropdownHeight += tabRef?.current?.clientHeight;
122
115
  }
123
116
  if (spaceBelow >= dropdownHeight) {
117
+ dropLevelRef.current = 'bottom';
124
118
  dropdownPosition.top =
125
119
  inputRect.top + window.scrollY + inputRect.height;
126
120
  } else {
121
+ dropLevelRef.current = 'top';
127
122
  dropdownPosition.top =
128
123
  inputRect.top + window.scrollY - dropdownHeight + 73 + topMargin;
129
124
  }
@@ -514,8 +509,8 @@ const AutoCompleteWithSelectedList = forwardRef<
514
509
  );
515
510
  };
516
511
  useEffect(() => {
517
- handleUpdateParent?.(dropOpen);
518
- }, [dropOpen]);
512
+ handleUpdateParent?.(dropOpen, dropLevelRef.current)
513
+ }, [dropOpen, dropLevelRef.current]);
519
514
  return (
520
515
  <div className={fullWidth ? 'fullWidth' : 'autoWidth'} ref={dropdownRef}>
521
516
  {label && (
@@ -1,11 +1,4 @@
1
- import React, {
2
- forwardRef,
3
- useCallback,
4
- useEffect,
5
- useImperativeHandle,
6
- useRef,
7
- useState,
8
- } from 'react';
1
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
9
2
  import ReactDOM from 'react-dom';
10
3
 
11
4
  import { AutoSuggestionInputProps } from './commontypes';
@@ -80,7 +73,7 @@ const AutoCompleteWithTreeStructure = forwardRef<
80
73
  const [dropDownData, setDropDownData] = useState<ValueProps[]>(data);
81
74
  const inputRef = useRef(null);
82
75
  const dropRef = useRef(null);
83
-
76
+ const dropLevelRef = useRef<string>('bottom');
84
77
  useEffect(() => {
85
78
  if (data) {
86
79
  if (flatArray) {
@@ -91,6 +84,7 @@ const AutoCompleteWithTreeStructure = forwardRef<
91
84
  }
92
85
  }, [data, dropOpen]);
93
86
  useImperativeHandle(ref, () => inputRef.current);
87
+
94
88
  const [dropdownStyle, setDropdownStyle] = useState({
95
89
  top: 0,
96
90
  left: 0,
@@ -113,9 +107,11 @@ const AutoCompleteWithTreeStructure = forwardRef<
113
107
  if (spaceBelow >= dropdownHeight) {
114
108
  dropdownPosition.top =
115
109
  inputRect.top + window.scrollY + inputRect.height;
110
+ dropLevelRef.current = 'bottom';
116
111
  } else {
117
112
  dropdownPosition.top =
118
113
  inputRect.top + window.scrollY - dropdownHeight + 73;
114
+ dropLevelRef.current = 'top';
119
115
  }
120
116
 
121
117
  setDropdownStyle({
@@ -210,8 +206,8 @@ const AutoCompleteWithTreeStructure = forwardRef<
210
206
  }
211
207
  };
212
208
  useEffect(() => {
213
- handleUpdateParent?.(dropOpen);
214
- }, [dropOpen]);
209
+ handleUpdateParent?.(dropOpen, dropLevelRef.current)
210
+ }, [dropOpen, dropLevelRef.current]);
215
211
  const generateClassName = useCallback(() => {
216
212
  return `qbs-textfield-default ${className} ${
217
213
  errors && errors?.message ? 'textfield-error' : 'tree-textfield'
@@ -63,7 +63,7 @@ export interface AutoSuggestionInputProps {
63
63
  currentTab?: number; // current active tab
64
64
  selectedLabel?: string; // Able to change the "Item selected" label
65
65
  viewMode?: boolean; // show only selected items
66
- handleUpdateParent?: (val:boolean) => void;
66
+ handleUpdateParent?: (val: boolean, level?: string) => void;
67
67
  }
68
68
  export interface IconsProps {
69
69
  name: any;