ab-ui-library 1.51.2 → 1.52.0
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/components/AdvancedTable/AdvancedPagination.js +1 -0
- package/components/AdvancedTable/index.js +1 -0
- package/components/FileUpload/FileUpload.js +6 -3
- package/components/Input/InputPassword.js +1 -0
- package/components/Input/types.d.ts +1 -0
- package/components/Select/Select/Select.js +9 -0
- package/components/Select/index.js +1 -0
- package/components/Select/types.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useRecalculateDropdownPosition.d.ts +9 -0
- package/hooks/useRecalculateDropdownPosition.js +30 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -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';
|
|
@@ -64,7 +64,8 @@ var FileUpload = function FileUpload(props) {
|
|
|
64
64
|
onError = props.onError,
|
|
65
65
|
fileAllowedSize = props.fileAllowedSize,
|
|
66
66
|
_props$mode = props.mode,
|
|
67
|
-
mode = _props$mode === void 0 ? FileUploadMode.attach : _props$mode
|
|
67
|
+
mode = _props$mode === void 0 ? FileUploadMode.attach : _props$mode,
|
|
68
|
+
dataId = props.dataId;
|
|
68
69
|
var files = value || uploadedFiles || [];
|
|
69
70
|
var fileInputRef = useRef(null);
|
|
70
71
|
var _useState = useState(false),
|
|
@@ -143,7 +144,8 @@ var FileUpload = function FileUpload(props) {
|
|
|
143
144
|
className: "hide",
|
|
144
145
|
ref: fileInputRef,
|
|
145
146
|
accept: allowedTypes,
|
|
146
|
-
onChange: handleChange
|
|
147
|
+
onChange: handleChange,
|
|
148
|
+
"data-id": dataId ? "".concat(dataId, "-input") : ''
|
|
147
149
|
}), mode === FileUploadMode.edit && /*#__PURE__*/React.createElement("div", {
|
|
148
150
|
className: "edit__icon",
|
|
149
151
|
onMouseEnter: onMouseEnterOrLeave,
|
|
@@ -163,7 +165,8 @@ var FileUpload = function FileUpload(props) {
|
|
|
163
165
|
Component: IconAttach
|
|
164
166
|
},
|
|
165
167
|
onClick: onUploadClick,
|
|
166
|
-
buttonText: buttonText
|
|
168
|
+
buttonText: buttonText,
|
|
169
|
+
"data-id": dataId ? "".concat(dataId, "-btn") : ''
|
|
167
170
|
}), /*#__PURE__*/React.createElement(UploadItems, {
|
|
168
171
|
handleFileClick: handleFileClick,
|
|
169
172
|
onRemove: handleFileRemove,
|
|
@@ -208,6 +208,7 @@ var InputPassword = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
208
208
|
size: 'small',
|
|
209
209
|
className: 'pl-4',
|
|
210
210
|
key: rule.label,
|
|
211
|
+
dataId: (rule === null || rule === void 0 ? void 0 : rule.dataId) || '',
|
|
211
212
|
type: getTextType(password, validationResults[rule.label], isFocused)
|
|
212
213
|
}, rule.label));
|
|
213
214
|
}), hasError && validations !== null && validations !== void 0 && validations.length ? /*#__PURE__*/React.createElement(Divider, {
|
|
@@ -47,6 +47,7 @@ export interface InputCustomProps extends IFormCompProps, Omit<InputHTMLAttribut
|
|
|
47
47
|
interface IPasswordValidationRule {
|
|
48
48
|
label: string;
|
|
49
49
|
test: (password: string) => boolean;
|
|
50
|
+
dataId?: string;
|
|
50
51
|
}
|
|
51
52
|
export interface InputPasswordsProps extends InputCustomProps {
|
|
52
53
|
validations: IPasswordValidationRule[];
|
|
@@ -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
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';
|