@dreamcommerce/aurora 2.4.3-2 → 2.4.3-6
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/build/cjs/packages/aurora/src/components/dropdown/components/content.js +31 -26
- package/build/cjs/packages/aurora/src/components/dropdown/components/content.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/tooltip/index.js +1 -3
- package/build/cjs/packages/aurora/src/components/tooltip/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/components/content.js +31 -26
- package/build/esm/packages/aurora/src/components/dropdown/components/content.js.map +1 -1
- package/build/esm/packages/aurora/src/components/dropdown/types.d.ts +0 -1
- package/build/esm/packages/aurora/src/components/tooltip/index.js +1 -3
- package/build/esm/packages/aurora/src/components/tooltip/index.js.map +1 -1
- package/package.json +1 -1
- package/build/esm/packages/aurora/src/hooks/use_portal_child_position.d.ts +0 -9
- package/build/esm/packages/aurora/src/hooks/use_portal_child_position.js +0 -25
- package/build/esm/packages/aurora/src/hooks/use_portal_child_position.js.map +0 -1
|
@@ -30,7 +30,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
30
30
|
* @example
|
|
31
31
|
* <Dropdown.Content> ... </Dropdown.Content>
|
|
32
32
|
*/
|
|
33
|
-
const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children, arrowSide = 'left', horizontalPosition = 'left', verticalPosition = 'bottom',
|
|
33
|
+
const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children, arrowSide = 'left', horizontalPosition = 'left', verticalPosition = 'bottom', cssClass, portalContainer }) => {
|
|
34
34
|
const [t] = useTranslation.useTranslation();
|
|
35
35
|
const contentRef = React.useRef(null);
|
|
36
36
|
const { wrapperRef, toggleDropdown, isOpen, closeDropdown } = index.useDropdownContext();
|
|
@@ -75,49 +75,54 @@ const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children
|
|
|
75
75
|
});
|
|
76
76
|
React.useEffect(() => {
|
|
77
77
|
if ((wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) && contentRef.current) {
|
|
78
|
-
const { x, y, height } = wrapperRef.current.getBoundingClientRect();
|
|
78
|
+
const { x: wrapperXPosition, y: wrapperYPosition, width: wrapperWidth, height: wrapperHeight } = wrapperRef.current.getBoundingClientRect();
|
|
79
79
|
const { width: contentWidth } = contentRef.current.getBoundingClientRect();
|
|
80
|
-
const yOffset = 10;
|
|
81
80
|
const { xModifier, yModifier } = utilities.getXYModifiersForNestedDropdowns(portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.current);
|
|
82
|
-
const
|
|
83
|
-
const positionBottom = windowHeightMinusYOffset - y + yOffset;
|
|
84
|
-
const positionLeft = x - xModifier;
|
|
81
|
+
const yOffset = 10;
|
|
85
82
|
const isInModal = utilities.isChildOfModal(wrapperRef);
|
|
86
83
|
const zIndex = isInModal ? constants.DROPDOWN_ON_MODAL_Z_INDEX : constants.DROPDOWN_Z_INDEX;
|
|
84
|
+
const positionTop = wrapperHeight + wrapperYPosition + windowYScroll + yOffset - yModifier;
|
|
85
|
+
const positionBottom = windowHeightMinusYOffset - wrapperYPosition + yOffset;
|
|
86
|
+
const positionLeft = wrapperXPosition - xModifier;
|
|
87
87
|
let topPositionValue = '';
|
|
88
88
|
let bottomPositionValue = '';
|
|
89
89
|
let leftPositionValue = '';
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
const leftPositionStickedToRightBorderValue = wrapperXPosition + wrapperWidth - contentWidth;
|
|
91
|
+
const setTopPosition = () => {
|
|
92
|
+
topPositionValue = 'auto';
|
|
93
|
+
bottomPositionValue = `${positionBottom}px`;
|
|
94
|
+
};
|
|
95
|
+
const setBottomPosition = () => {
|
|
96
|
+
topPositionValue = `${positionTop}px`;
|
|
97
|
+
bottomPositionValue = 'auto';
|
|
98
|
+
};
|
|
97
99
|
horizontalPosition === 'left'
|
|
98
100
|
? (leftPositionValue = `${positionLeft}px`)
|
|
99
101
|
: (leftPositionValue = `${leftPositionStickedToRightBorderValue}px`);
|
|
100
102
|
if (verticalPosition === 'top') {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
topPositionValue = `${positionTop}px`;
|
|
105
|
-
bottomPositionValue = 'auto';
|
|
106
|
-
}
|
|
103
|
+
setTopPosition();
|
|
104
|
+
if (dropdownIsOutsideTopViewport)
|
|
105
|
+
setBottomPosition();
|
|
107
106
|
}
|
|
108
107
|
if (verticalPosition === 'bottom') {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
topPositionValue = 'auto';
|
|
113
|
-
bottomPositionValue = `${positionBottom}px`;
|
|
114
|
-
}
|
|
108
|
+
setBottomPosition();
|
|
109
|
+
if (dropdownIsOutsideBottomViewport)
|
|
110
|
+
setTopPosition();
|
|
115
111
|
}
|
|
116
112
|
screenWidthName === responsive_breakpoints.SCREEN_XS
|
|
117
113
|
? setStyles({ top: `0px`, bottom: 'auto', left: `0px`, zIndex })
|
|
118
114
|
: setStyles({ top: topPositionValue, bottom: bottomPositionValue, left: leftPositionValue, zIndex });
|
|
119
115
|
}
|
|
120
|
-
}, [
|
|
116
|
+
}, [
|
|
117
|
+
portalContainer,
|
|
118
|
+
screenWidthName,
|
|
119
|
+
wrapperRef,
|
|
120
|
+
isOpen,
|
|
121
|
+
dropdownIsOutsideTopViewport,
|
|
122
|
+
dropdownIsOutsideBottomViewport,
|
|
123
|
+
windowYScroll,
|
|
124
|
+
windowHeightMinusYOffset
|
|
125
|
+
]);
|
|
121
126
|
React.useEffect(() => {
|
|
122
127
|
var _a;
|
|
123
128
|
if (!(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) || !isOpen)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,oEAAwE;AACrG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,oEAAwE;AACrG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -14,11 +14,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
14
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
15
|
|
|
16
16
|
const Tooltip = ({ left, top, disabled, onToggle, children, content }) => {
|
|
17
|
-
var _a;
|
|
18
17
|
const wrapperRef = React.useRef(null);
|
|
19
18
|
const [isOpen, toggleDropdown] = use_toggle.useToggle(false, onToggle);
|
|
20
19
|
const value = React__default['default'].useMemo(() => ({ wrapperRef, isOpen, toggleDropdown }), [isOpen, toggleDropdown]);
|
|
21
|
-
const wrapperWidth = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
22
20
|
const handleOnMouseEnter = () => {
|
|
23
21
|
toggleDropdown();
|
|
24
22
|
};
|
|
@@ -28,7 +26,7 @@ const Tooltip = ({ left, top, disabled, onToggle, children, content }) => {
|
|
|
28
26
|
return (React__default['default'].createElement(index.DropdownContext.Provider, { value: value },
|
|
29
27
|
React__default['default'].createElement("span", { className: main_module['default'][css_classes.cssTooltip], ref: wrapperRef, onMouseEnter: handleOnMouseEnter, onMouseLeave: handleOnMouseLeave },
|
|
30
28
|
children,
|
|
31
|
-
!disabled && (React__default['default'].createElement(index$1['default'].Content, { cssClass: main_module['default'][css_classes.cssTooltipContainer], horizontalPosition: left ? 'left' : 'right', verticalPosition: top ? 'top' : 'bottom'
|
|
29
|
+
!disabled && (React__default['default'].createElement(index$1['default'].Content, { cssClass: main_module['default'][css_classes.cssTooltipContainer], horizontalPosition: left ? 'left' : 'right', verticalPosition: top ? 'top' : 'bottom' }, content)))));
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
exports.default = Tooltip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -22,7 +22,7 @@ import { UiDomUtils } from '@dreamcommerce/utilities';
|
|
|
22
22
|
* @example
|
|
23
23
|
* <Dropdown.Content> ... </Dropdown.Content>
|
|
24
24
|
*/
|
|
25
|
-
const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children, arrowSide = 'left', horizontalPosition = 'left', verticalPosition = 'bottom',
|
|
25
|
+
const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children, arrowSide = 'left', horizontalPosition = 'left', verticalPosition = 'bottom', cssClass, portalContainer }) => {
|
|
26
26
|
const [t] = useTranslation();
|
|
27
27
|
const contentRef = useRef(null);
|
|
28
28
|
const { wrapperRef, toggleDropdown, isOpen, closeDropdown } = useDropdownContext();
|
|
@@ -67,49 +67,54 @@ const Content = ({ headerComponent, headerGoBackText, headerGoBackIcon, children
|
|
|
67
67
|
});
|
|
68
68
|
useEffect(() => {
|
|
69
69
|
if ((wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) && contentRef.current) {
|
|
70
|
-
const { x, y, height } = wrapperRef.current.getBoundingClientRect();
|
|
70
|
+
const { x: wrapperXPosition, y: wrapperYPosition, width: wrapperWidth, height: wrapperHeight } = wrapperRef.current.getBoundingClientRect();
|
|
71
71
|
const { width: contentWidth } = contentRef.current.getBoundingClientRect();
|
|
72
|
-
const yOffset = 10;
|
|
73
72
|
const { xModifier, yModifier } = getXYModifiersForNestedDropdowns(portalContainer === null || portalContainer === void 0 ? void 0 : portalContainer.current);
|
|
74
|
-
const
|
|
75
|
-
const positionBottom = windowHeightMinusYOffset - y + yOffset;
|
|
76
|
-
const positionLeft = x - xModifier;
|
|
73
|
+
const yOffset = 10;
|
|
77
74
|
const isInModal = isChildOfModal(wrapperRef);
|
|
78
75
|
const zIndex = isInModal ? DROPDOWN_ON_MODAL_Z_INDEX : DROPDOWN_Z_INDEX;
|
|
76
|
+
const positionTop = wrapperHeight + wrapperYPosition + windowYScroll + yOffset - yModifier;
|
|
77
|
+
const positionBottom = windowHeightMinusYOffset - wrapperYPosition + yOffset;
|
|
78
|
+
const positionLeft = wrapperXPosition - xModifier;
|
|
79
79
|
let topPositionValue = '';
|
|
80
80
|
let bottomPositionValue = '';
|
|
81
81
|
let leftPositionValue = '';
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
const leftPositionStickedToRightBorderValue = wrapperXPosition + wrapperWidth - contentWidth;
|
|
83
|
+
const setTopPosition = () => {
|
|
84
|
+
topPositionValue = 'auto';
|
|
85
|
+
bottomPositionValue = `${positionBottom}px`;
|
|
86
|
+
};
|
|
87
|
+
const setBottomPosition = () => {
|
|
88
|
+
topPositionValue = `${positionTop}px`;
|
|
89
|
+
bottomPositionValue = 'auto';
|
|
90
|
+
};
|
|
89
91
|
horizontalPosition === 'left'
|
|
90
92
|
? (leftPositionValue = `${positionLeft}px`)
|
|
91
93
|
: (leftPositionValue = `${leftPositionStickedToRightBorderValue}px`);
|
|
92
94
|
if (verticalPosition === 'top') {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
topPositionValue = `${positionTop}px`;
|
|
97
|
-
bottomPositionValue = 'auto';
|
|
98
|
-
}
|
|
95
|
+
setTopPosition();
|
|
96
|
+
if (dropdownIsOutsideTopViewport)
|
|
97
|
+
setBottomPosition();
|
|
99
98
|
}
|
|
100
99
|
if (verticalPosition === 'bottom') {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
topPositionValue = 'auto';
|
|
105
|
-
bottomPositionValue = `${positionBottom}px`;
|
|
106
|
-
}
|
|
100
|
+
setBottomPosition();
|
|
101
|
+
if (dropdownIsOutsideBottomViewport)
|
|
102
|
+
setTopPosition();
|
|
107
103
|
}
|
|
108
104
|
screenWidthName === SCREEN_XS
|
|
109
105
|
? setStyles({ top: `0px`, bottom: 'auto', left: `0px`, zIndex })
|
|
110
106
|
: setStyles({ top: topPositionValue, bottom: bottomPositionValue, left: leftPositionValue, zIndex });
|
|
111
107
|
}
|
|
112
|
-
}, [
|
|
108
|
+
}, [
|
|
109
|
+
portalContainer,
|
|
110
|
+
screenWidthName,
|
|
111
|
+
wrapperRef,
|
|
112
|
+
isOpen,
|
|
113
|
+
dropdownIsOutsideTopViewport,
|
|
114
|
+
dropdownIsOutsideBottomViewport,
|
|
115
|
+
windowYScroll,
|
|
116
|
+
windowHeightMinusYOffset
|
|
117
|
+
]);
|
|
113
118
|
useEffect(() => {
|
|
114
119
|
var _a;
|
|
115
120
|
if (!(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current) || !isOpen)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,oEAAwE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,oEAAwE;AACvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -6,11 +6,9 @@ import { cssTooltip, cssTooltipContainer } from './css_classes.js';
|
|
|
6
6
|
import cssClasses from '../../css/tooltip/main.module.less.js';
|
|
7
7
|
|
|
8
8
|
const Tooltip = ({ left, top, disabled, onToggle, children, content }) => {
|
|
9
|
-
var _a;
|
|
10
9
|
const wrapperRef = useRef(null);
|
|
11
10
|
const [isOpen, toggleDropdown] = useToggle(false, onToggle);
|
|
12
11
|
const value = React.useMemo(() => ({ wrapperRef, isOpen, toggleDropdown }), [isOpen, toggleDropdown]);
|
|
13
|
-
const wrapperWidth = (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
|
|
14
12
|
const handleOnMouseEnter = () => {
|
|
15
13
|
toggleDropdown();
|
|
16
14
|
};
|
|
@@ -20,7 +18,7 @@ const Tooltip = ({ left, top, disabled, onToggle, children, content }) => {
|
|
|
20
18
|
return (React.createElement(DropdownContext.Provider, { value: value },
|
|
21
19
|
React.createElement("span", { className: cssClasses[cssTooltip], ref: wrapperRef, onMouseEnter: handleOnMouseEnter, onMouseLeave: handleOnMouseLeave },
|
|
22
20
|
children,
|
|
23
|
-
!disabled && (React.createElement(Dropdown.Content, { cssClass: cssClasses[cssTooltipContainer], horizontalPosition: left ? 'left' : 'right', verticalPosition: top ? 'top' : 'bottom'
|
|
21
|
+
!disabled && (React.createElement(Dropdown.Content, { cssClass: cssClasses[cssTooltipContainer], horizontalPosition: left ? 'left' : 'right', verticalPosition: top ? 'top' : 'bottom' }, content)))));
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
export default Tooltip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React, { RefObject } from 'react';
|
|
2
|
-
export declare const usePortalChildPosition: ({ childRef, vPosition, hPosition }: {
|
|
3
|
-
vPosition?: "top" | "bottom" | undefined;
|
|
4
|
-
hPosition?: "left" | "right" | "center" | undefined;
|
|
5
|
-
childRef?: React.RefObject<HTMLDivElement> | undefined;
|
|
6
|
-
}) => {
|
|
7
|
-
style: React.CSSProperties;
|
|
8
|
-
onMouseEnter: (event: React.MouseEvent) => void;
|
|
9
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
export const usePortalChildPosition = ({ childRef, vPosition, hPosition }) => {
|
|
3
|
-
const [position, setPosition] = useState({ top: 0, left: 0 });
|
|
4
|
-
const onMouseEnter = (event) => {
|
|
5
|
-
var _a, _b;
|
|
6
|
-
const $hoveredElement = event.target;
|
|
7
|
-
const parentBoundingRect = $hoveredElement.getBoundingClientRect();
|
|
8
|
-
const childBoundingRect = ((_a = childRef === null || childRef === void 0 ? void 0 : childRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || { width: 0, height: 0 };
|
|
9
|
-
console.log('parentBoundingRect', parentBoundingRect);
|
|
10
|
-
console.log('childRef', (_b = childRef === null || childRef === void 0 ? void 0 : childRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight);
|
|
11
|
-
console.log('childBoundingRect', childBoundingRect);
|
|
12
|
-
const top = vPosition === 'top' ? parentBoundingRect.top - childBoundingRect.height : parentBoundingRect.top + parentBoundingRect.height;
|
|
13
|
-
const left = hPosition === 'left' ? parentBoundingRect.left + parentBoundingRect.width - childBoundingRect.width : parentBoundingRect.left;
|
|
14
|
-
setPosition({ top, left });
|
|
15
|
-
};
|
|
16
|
-
const style = {
|
|
17
|
-
top: position.top,
|
|
18
|
-
left: position.left
|
|
19
|
-
};
|
|
20
|
-
return {
|
|
21
|
-
style,
|
|
22
|
-
onMouseEnter
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=use_portal_child_position.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use_portal_child_position.js","sourceRoot":"","sources":["../../../../../../src/hooks/use_portal_child_position.ts"],"names":[],"mappings":"AAAA,OAAc,EAAa,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,QAAQ,EACR,SAAS,EACT,SAAS,EAKZ,EAAmF,EAAE;IAClF,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;IAE9D,MAAM,YAAY,GAAG,CAAC,KAAuB,EAAE,EAAE;;QAC7C,MAAM,eAAe,GAAG,KAAK,CAAC,MAAqB,CAAC;QAEpD,MAAM,kBAAkB,GAAG,eAAe,CAAC,qBAAqB,EAAE,CAAC;QAEnE,MAAM,iBAAiB,GAAG,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,qBAAqB,EAAE,KAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAEhG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,YAAY,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;QAEpD,MAAM,GAAG,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC;QACzI,MAAM,IAAI,GACN,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,GAAG,kBAAkB,CAAC,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC;QAElI,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG;QACV,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;KACtB,CAAC;IAEF,OAAO;QACH,KAAK;QACL,YAAY;KACf,CAAC;AACN,CAAC,CAAC"}
|