ab-ui-library 1.51.1 → 1.51.3

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.
@@ -54,6 +54,7 @@ import '../Button/consts.js';
54
54
  import '../../hooks/useHideOnResize.js';
55
55
  import '../../utils/helpers.js';
56
56
  import '../../hooks/useGetHasBottomSpace.js';
57
+ import '../../hooks/useRecalculateDropdownPosition.js';
57
58
  import '../../helperComponents/OptionItem/OptionItem.js';
58
59
  import '../Avatar/Avatar.js';
59
60
  import '../FileUpload/FileUpload.js';
@@ -86,6 +86,7 @@ import '../Divider/Divider.js';
86
86
  import '../Select/Select/Select.js';
87
87
  import '../../hooks/useHideOnResize.js';
88
88
  import '../../hooks/useGetHasBottomSpace.js';
89
+ import '../../hooks/useRecalculateDropdownPosition.js';
89
90
  import '../Select/SharedComponents/ContentTop.js';
90
91
  import '../Select/SharedComponents/Actions.js';
91
92
  import '../SVGIcons/IconMore.js';
@@ -11,7 +11,8 @@ var IconDismiss = function IconDismiss(_ref) {
11
11
  onClick = _ref.onClick,
12
12
  refHandler = _ref.refHandler,
13
13
  id = _ref.id,
14
- dataId = _ref.dataId;
14
+ _ref$dataId = _ref.dataId,
15
+ dataId = _ref$dataId === void 0 ? 'dismiss' : _ref$dataId;
15
16
  return /*#__PURE__*/React.createElement("svg", {
16
17
  xmlns: "http://www.w3.org/2000/svg",
17
18
  className: classNames('svg-icon', _defineProperty(_defineProperty(_defineProperty({}, "svg-icon__size-".concat(size), size), "svg-icon__type-".concat(type), type), className, className)),
@@ -20,7 +21,7 @@ var IconDismiss = function IconDismiss(_ref) {
20
21
  onClick: onClick,
21
22
  ref: refHandler,
22
23
  id: id,
23
- "data-id": dataId ? "".concat(dataId, "-svg-icon") : ''
24
+ "data-id": "".concat(dataId, "-svg-icon")
24
25
  }, /*#__PURE__*/React.createElement("path", {
25
26
  d: "M4.39705 4.55379L4.46967 4.46967C4.73594 4.2034 5.1526 4.1792 5.44621 4.39705L5.53033 4.46967L12 10.939L18.4697 4.46967C18.7626 4.17678 19.2374 4.17678 19.5303 4.46967C19.8232 4.76256 19.8232 5.23744 19.5303 5.53033L13.061 12L19.5303 18.4697C19.7966 18.7359 19.8208 19.1526 19.6029 19.4462L19.5303 19.5303C19.2641 19.7966 18.8474 19.8208 18.5538 19.6029L18.4697 19.5303L12 13.061L5.53033 19.5303C5.23744 19.8232 4.76256 19.8232 4.46967 19.5303C4.17678 19.2374 4.17678 18.7626 4.46967 18.4697L10.939 12L4.46967 5.53033C4.2034 5.26406 4.1792 4.8474 4.39705 4.55379L4.46967 4.46967L4.39705 4.55379Z",
26
27
  fill: "#222222"
@@ -11,6 +11,7 @@ import { useOnOutsideClick } from '../../../hooks/useOnOutsideClick.js';
11
11
  import '../../../hooks/useScreenSize.js';
12
12
  import { useGetHasBottomSpace, useGetHasTopSpace } from '../../../hooks/useGetHasBottomSpace.js';
13
13
  import 'react-hook-form';
14
+ import { useRecalculateDropdownPosition } from '../../../hooks/useRecalculateDropdownPosition.js';
14
15
  import { Input } from '../../Input/Input.js';
15
16
  import '../../Input/InputPassword.js';
16
17
  import { Text } from '../../Text/Text.js';
@@ -96,6 +97,8 @@ var Select = function Select(props) {
96
97
  isDynamicSearchable = _props$isDynamicSearc === void 0 ? false : _props$isDynamicSearc,
97
98
  _props$trimSearchValu = props.trimSearchValue,
98
99
  trimSearchValue = _props$trimSearchValu === void 0 ? false : _props$trimSearchValu,
100
+ _props$shouldRecalcul = props.shouldRecalculateDropdownPosition,
101
+ shouldRecalculateDropdownPosition = _props$shouldRecalcul === void 0 ? false : _props$shouldRecalcul,
99
102
  disabled = props.disabled,
100
103
  _props$dataId = props.dataId,
101
104
  dataId = _props$dataId === void 0 ? '' : _props$dataId,
@@ -205,6 +208,12 @@ var Select = function Select(props) {
205
208
  closeDropdown();
206
209
  };
207
210
  useOnOutsideClick([inputRef.current, dropdownRef], handleOutsideClick, isOpen, useId());
211
+ useRecalculateDropdownPosition({
212
+ shouldRecalculateDropdownPosition: shouldRecalculateDropdownPosition,
213
+ isOpen: isOpen,
214
+ inputRef: inputRef,
215
+ dropdownRef: dropdownRef
216
+ });
208
217
  var _useGetElemPositions = useGetElemPositions(inputRef.current),
209
218
  bottom = _useGetElemPositions.bottom,
210
219
  left = _useGetElemPositions.left,
@@ -18,6 +18,7 @@ import '../../hooks/useOnOutsideClick.js';
18
18
  import '../../hooks/useScreenSize.js';
19
19
  import '../../hooks/useGetHasBottomSpace.js';
20
20
  import 'react-hook-form';
21
+ import '../../hooks/useRecalculateDropdownPosition.js';
21
22
  import '../Input/Input.js';
22
23
  import '../../extends-bb24d21e.js';
23
24
  import '../../objectWithoutProperties-7d059ace.js';
@@ -141,6 +141,7 @@ export interface TSingleSelectPropTypes extends IFormCompProps, TSelectBaseProps
141
141
  }) => boolean;
142
142
  renderOptions?: (props: IRenderOptionItemProps) => JSX.Element;
143
143
  defaultValue?: string;
144
+ shouldRecalculateDropdownPosition?: boolean;
144
145
  }
145
146
  export type TSelectFooterPropTypes = {
146
147
  checkboxInfo?: TCheckboxInfo;
package/hooks/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export * from './useScreenSize';
11
11
  export * from './useHideBodyScroll';
12
12
  export * from './useGetHasBottomSpace';
13
13
  export * from './useFieldArray';
14
+ export * from './useRecalculateDropdownPosition';
package/hooks/index.js CHANGED
@@ -11,6 +11,7 @@ export { useScreenSize } from './useScreenSize.js';
11
11
  export { useHideBodyScroll } from './useHideBodyScroll.js';
12
12
  export { useGetHasBottomSpace, useGetHasTopSpace } from './useGetHasBottomSpace.js';
13
13
  export { useFieldArray } from 'react-hook-form';
14
+ export { useRecalculateDropdownPosition } from './useRecalculateDropdownPosition.js';
14
15
  import 'react';
15
16
  import '../components/Tooltip/types.js';
16
17
  import '../consts/index.js';
@@ -0,0 +1,9 @@
1
+ import { type RefObject } from 'react';
2
+ interface Props {
3
+ inputRef: RefObject<HTMLInputElement | null>;
4
+ dropdownRef: HTMLDivElement | null;
5
+ shouldRecalculateDropdownPosition: boolean;
6
+ isOpen: boolean;
7
+ }
8
+ export declare const useRecalculateDropdownPosition: ({ isOpen, inputRef, dropdownRef, shouldRecalculateDropdownPosition }: Props) => void;
9
+ export {};
@@ -0,0 +1,30 @@
1
+ import { useEffect } from 'react';
2
+
3
+ var useRecalculateDropdownPosition = function useRecalculateDropdownPosition(_ref) {
4
+ var isOpen = _ref.isOpen,
5
+ inputRef = _ref.inputRef,
6
+ dropdownRef = _ref.dropdownRef,
7
+ shouldRecalculateDropdownPosition = _ref.shouldRecalculateDropdownPosition;
8
+ useEffect(function () {
9
+ if (!isOpen || !shouldRecalculateDropdownPosition) return;
10
+ var update = function update() {
11
+ if (!inputRef.current || !dropdownRef) return;
12
+ var rect = inputRef.current.getBoundingClientRect();
13
+ dropdownRef.style.left = "".concat(rect.left, "px");
14
+ dropdownRef.style.width = "".concat(rect.width, "px");
15
+ dropdownRef.style.top = "".concat(rect.bottom, "px");
16
+ };
17
+ update();
18
+ var rafId;
19
+ var _loop = function loop() {
20
+ update();
21
+ rafId = requestAnimationFrame(_loop);
22
+ };
23
+ _loop();
24
+ return function () {
25
+ cancelAnimationFrame(rafId);
26
+ };
27
+ }, [isOpen, inputRef.current, dropdownRef]);
28
+ };
29
+
30
+ export { useRecalculateDropdownPosition };
package/index.js CHANGED
@@ -546,6 +546,7 @@ import 'react-input-mask';
546
546
  import 'react-number-format';
547
547
  import './hooks/useHideOnResize.js';
548
548
  import './hooks/useGetHasBottomSpace.js';
549
+ import './hooks/useRecalculateDropdownPosition.js';
549
550
  import './components/Select/SharedComponents/Loading.js';
550
551
  import './hooks/useChangePositionsOnScroll.js';
551
552
  import './components/Badge/consts.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-ui-library",
3
- "version": "1.51.1",
3
+ "version": "1.51.3",
4
4
  "description": "UI library for AM",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",