@orfium/ictinus 4.56.0 → 4.57.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/dist/components/DatePicker/DatePicker.js +11 -13
- package/dist/components/DatePicker/utils.js +8 -2
- package/dist/components/Select/Select.js +24 -17
- package/dist/components/utils/PositionInScreen/PositionInScreen.d.ts +8 -1
- package/dist/components/utils/PositionInScreen/PositionInScreen.js +19 -66
- package/dist/components/utils/PositionInScreen/PositionInScreen.style.d.ts +2 -3
- package/dist/components/utils/PositionInScreen/PositionInScreen.style.js +7 -5
- package/dist/components/utils/PositionInScreen/hooks.d.ts +5 -0
- package/dist/components/utils/PositionInScreen/hooks.js +98 -0
- package/package.json +1 -1
|
@@ -207,19 +207,17 @@ var DatePicker = function DatePicker(_ref) {
|
|
|
207
207
|
onClick: onCancel
|
|
208
208
|
}, (0, _react2.jsx)(_PositionInScreen["default"], {
|
|
209
209
|
visible: isOpen,
|
|
210
|
-
parent:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
});
|
|
222
|
-
}
|
|
210
|
+
parent: (0, _react2.jsx)(_DatePickInput["default"], {
|
|
211
|
+
filterConfig: filterConfig,
|
|
212
|
+
isRangePicker: isRangePicker,
|
|
213
|
+
selectedDay: selectedRange,
|
|
214
|
+
inputProps: inputProps,
|
|
215
|
+
dateFormatOverride: dateFormatOverride,
|
|
216
|
+
handleFocus: handleFocus,
|
|
217
|
+
handleClear: handleClear,
|
|
218
|
+
isOpen: isOpen,
|
|
219
|
+
dataTestId: dataTestId
|
|
220
|
+
})
|
|
223
221
|
}, (0, _react2.jsx)("div", {
|
|
224
222
|
css: (0, _DatePicker.datePickerStyles)()
|
|
225
223
|
}, (0, _react2.jsx)(_OverlayComponent["default"], {
|
|
@@ -7,9 +7,15 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
|
7
7
|
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var fakeDate = (0, _dayjs["default"])('11-03-2020 12:00:00');
|
|
11
|
+
|
|
12
|
+
var getDefaultDate = function getDefaultDate(date) {
|
|
13
|
+
return process.env.NODE_ENV !== 'test' ? date : fakeDate;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
var currentDay = process.env.STORYBOOK_ENV === 'true' ? fakeDate : getDefaultDate((0, _dayjs["default"])());
|
|
11
17
|
exports.currentDay = currentDay;
|
|
12
|
-
var datepickerPropValue =
|
|
18
|
+
var datepickerPropValue = getDefaultDate();
|
|
13
19
|
exports.datepickerPropValue = datepickerPropValue;
|
|
14
20
|
|
|
15
21
|
var initDates = function initDates(value, isDefaultNow) {
|
|
@@ -27,6 +27,8 @@ var _Select = require("./Select.style");
|
|
|
27
27
|
|
|
28
28
|
var _Loader = _interopRequireDefault(require("../Loader"));
|
|
29
29
|
|
|
30
|
+
var _PositionInScreen = _interopRequireDefault(require("../utils/PositionInScreen"));
|
|
31
|
+
|
|
30
32
|
var _react2 = require("@emotion/react");
|
|
31
33
|
|
|
32
34
|
var _excluded = ["handleSelectedOption", "defaultValue", "selectedOption", "multi", "options", "isAsync", "isLoading", "asyncSearch", "status", "minCharactersToSearch", "highlightSearch", "isSearchable", "isVirtualized", "styleType", "disabled", "locked", "dataTestId", "onClear"];
|
|
@@ -220,22 +222,27 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
220
222
|
css: (0, _Select.selectWrapper)({
|
|
221
223
|
isSearchable: isSearchable
|
|
222
224
|
})
|
|
223
|
-
}), (0, _react2.jsx)(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
225
|
+
}), (0, _react2.jsx)(_PositionInScreen["default"], {
|
|
226
|
+
visible: open,
|
|
227
|
+
hasWrapperWidth: true,
|
|
228
|
+
offsetY: 8,
|
|
229
|
+
parent: (0, _react2.jsx)(_TextField["default"], _extends({
|
|
230
|
+
styleType: styleType,
|
|
231
|
+
rightIcon: rightIconRender,
|
|
232
|
+
onKeyDown: handleOnKeyDown,
|
|
233
|
+
onInput: handleOnInput,
|
|
234
|
+
onChange: ON_CHANGE_MOCK,
|
|
235
|
+
readOnly: !isSearchable,
|
|
236
|
+
disabled: disabled,
|
|
237
|
+
locked: locked,
|
|
238
|
+
dataTestId: (0, _helpers.generateTestDataId)('select-input', dataTestId)
|
|
239
|
+
}, restInputProps, {
|
|
240
|
+
status: status,
|
|
241
|
+
value: searchValue || inputValue.label,
|
|
242
|
+
ref: combinedRefs,
|
|
243
|
+
autoComplete: "off"
|
|
244
|
+
}))
|
|
245
|
+
}, (0, _react2.jsx)(_SelectMenu["default"], {
|
|
239
246
|
filteredOptions: filteredOptions,
|
|
240
247
|
handleOptionClick: handleOptionClick,
|
|
241
248
|
selectedOption: inputValue.value,
|
|
@@ -244,7 +251,7 @@ var Select = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
244
251
|
isLoading: isLoading,
|
|
245
252
|
isVirtualized: isVirtualized,
|
|
246
253
|
searchTerm: highlightSearch ? searchValue : undefined
|
|
247
|
-
})));
|
|
254
|
+
}))));
|
|
248
255
|
});
|
|
249
256
|
|
|
250
257
|
Select.displayName = 'Select';
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
declare type Props = {
|
|
3
|
+
/** Whether the item to be positioned is visible */
|
|
3
4
|
visible: boolean;
|
|
5
|
+
/** Configures the container's overflow */
|
|
4
6
|
withOverflow?: boolean;
|
|
7
|
+
/** Whether the item to be positioned uses the parent's wrapper width */
|
|
8
|
+
hasWrapperWidth?: boolean;
|
|
9
|
+
/** Additional offset-x */
|
|
5
10
|
offsetX?: number;
|
|
11
|
+
/** Additional offset-y */
|
|
6
12
|
offsetY?: number;
|
|
7
|
-
parent
|
|
13
|
+
/** The parent element */
|
|
14
|
+
parent: JSX.Element;
|
|
8
15
|
};
|
|
9
16
|
declare const PositionInScreen: React.FC<Props>;
|
|
10
17
|
export default PositionInScreen;
|
|
@@ -5,6 +5,8 @@ exports["default"] = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
|
+
var _hooks = require("./hooks");
|
|
9
|
+
|
|
8
10
|
var _PositionInScreen = require("./PositionInScreen.style");
|
|
9
11
|
|
|
10
12
|
var _react2 = require("@emotion/react");
|
|
@@ -13,82 +15,33 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
13
15
|
|
|
14
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
17
|
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _ref = parentRef != null && parentRef.current ? parentRef == null ? void 0 : (_parentRef$current = parentRef.current) == null ? void 0 : _parentRef$current.getBoundingClientRect() : {
|
|
28
|
-
x: 0,
|
|
29
|
-
y: 0
|
|
30
|
-
},
|
|
31
|
-
itemX = _ref.x,
|
|
32
|
-
itemY = _ref.y;
|
|
33
|
-
|
|
34
|
-
var parrentOffsetHeight = (parentRef == null ? void 0 : (_parentRef$current2 = parentRef.current) == null ? void 0 : _parentRef$current2.offsetHeight) || 0;
|
|
35
|
-
|
|
36
|
-
var _ref2 = itemRef != null && itemRef.current ? itemRef == null ? void 0 : (_itemRef$current = itemRef.current) == null ? void 0 : (_itemRef$current$chil = _itemRef$current.children[0]) == null ? void 0 : _itemRef$current$chil.getBoundingClientRect() : {
|
|
37
|
-
width: 0,
|
|
38
|
-
height: 0
|
|
39
|
-
},
|
|
40
|
-
width = _ref2.width,
|
|
41
|
-
height = _ref2.height;
|
|
42
|
-
|
|
43
|
-
var itemYOutOfScreenHeight = itemY + parrentOffsetHeight + height > window.innerHeight;
|
|
44
|
-
|
|
45
|
-
if (itemYOutOfScreenHeight) {
|
|
46
|
-
itemY -= height;
|
|
47
|
-
|
|
48
|
-
if (itemY < 0) {
|
|
49
|
-
itemY = 0;
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
itemY += parrentOffsetHeight;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var itemXOutOfScreenWidth = itemX + width > window.innerWidth;
|
|
56
|
-
|
|
57
|
-
if (itemXOutOfScreenWidth) {
|
|
58
|
-
itemX = window.innerWidth - width;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
setPosition({
|
|
62
|
-
x: itemX,
|
|
63
|
-
y: itemY
|
|
64
|
-
});
|
|
65
|
-
}, [parentRef, itemRef, visible]);
|
|
66
|
-
return position;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var PositionInScreen = function PositionInScreen(_ref3) {
|
|
70
|
-
var visible = _ref3.visible,
|
|
71
|
-
parent = _ref3.parent,
|
|
72
|
-
withOverflow = _ref3.withOverflow,
|
|
73
|
-
_ref3$offsetX = _ref3.offsetX,
|
|
74
|
-
offsetX = _ref3$offsetX === void 0 ? 0 : _ref3$offsetX,
|
|
75
|
-
_ref3$offsetY = _ref3.offsetY,
|
|
76
|
-
offsetY = _ref3$offsetY === void 0 ? 0 : _ref3$offsetY,
|
|
77
|
-
children = _ref3.children;
|
|
18
|
+
var PositionInScreen = function PositionInScreen(_ref) {
|
|
19
|
+
var visible = _ref.visible,
|
|
20
|
+
parent = _ref.parent,
|
|
21
|
+
withOverflow = _ref.withOverflow,
|
|
22
|
+
_ref$hasWrapperWidth = _ref.hasWrapperWidth,
|
|
23
|
+
hasWrapperWidth = _ref$hasWrapperWidth === void 0 ? false : _ref$hasWrapperWidth,
|
|
24
|
+
_ref$offsetX = _ref.offsetX,
|
|
25
|
+
offsetX = _ref$offsetX === void 0 ? 0 : _ref$offsetX,
|
|
26
|
+
_ref$offsetY = _ref.offsetY,
|
|
27
|
+
offsetY = _ref$offsetY === void 0 ? 0 : _ref$offsetY,
|
|
28
|
+
children = _ref.children;
|
|
78
29
|
var wrapperRef = (0, _react.useRef)(null);
|
|
79
30
|
var itemRef = (0, _react.useRef)(null);
|
|
80
31
|
|
|
81
|
-
var
|
|
32
|
+
var _useWrapperWidth = (0, _hooks.useWrapperWidth)(hasWrapperWidth, wrapperRef),
|
|
33
|
+
wrapperWidth = _useWrapperWidth[0];
|
|
34
|
+
|
|
35
|
+
var _usePositionInScreen = (0, _hooks.usePositionInScreen)(wrapperRef, itemRef, offsetX, offsetY, visible),
|
|
82
36
|
x = _usePositionInScreen.x,
|
|
83
37
|
y = _usePositionInScreen.y;
|
|
84
38
|
|
|
85
39
|
var showTooltip = visible && x !== -1 && y !== -1;
|
|
86
|
-
var ParentComp = parent;
|
|
87
40
|
return (0, _react2.jsx)("div", {
|
|
88
41
|
css: (0, _PositionInScreen.container)(withOverflow, showTooltip),
|
|
89
42
|
ref: wrapperRef
|
|
90
|
-
},
|
|
91
|
-
css: (0, _PositionInScreen.itemContainer)(x
|
|
43
|
+
}, parent, showTooltip && (0, _react2.jsx)("div", {
|
|
44
|
+
css: (0, _PositionInScreen.itemContainer)(x, y, wrapperWidth),
|
|
92
45
|
id: 'unique-tooltip-id',
|
|
93
46
|
ref: itemRef
|
|
94
47
|
}, children));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const itemContainer: (clientX: number, clientY: number) => (theme: Theme) => SerializedStyles;
|
|
2
|
+
export declare const container: (withOverflow?: boolean | undefined, visible?: boolean | undefined) => () => SerializedStyles;
|
|
3
|
+
export declare const itemContainer: (clientX: number, clientY: number, width?: number | undefined) => () => SerializedStyles;
|
|
@@ -5,26 +5,28 @@ exports.itemContainer = exports.container = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _react = require("@emotion/react");
|
|
7
7
|
|
|
8
|
+
var _polished = require("polished");
|
|
9
|
+
|
|
8
10
|
var container = function container(withOverflow, visible) {
|
|
9
|
-
return function (
|
|
11
|
+
return function () {
|
|
10
12
|
return (
|
|
11
13
|
/*#__PURE__*/
|
|
12
14
|
|
|
13
15
|
/*#__PURE__*/
|
|
14
|
-
(0, _react.css)("overflow:", withOverflow ? 'hidden' : 'inherit', ";text-overflow:", withOverflow ? 'ellipsis' : 'inherit', ";width:100%;height:inherit;#unique-tooltip-id{display:", visible ? 'block !important' : 'none !important', ";}" + (process.env.NODE_ENV === "production" ? "" : ";label:container;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
16
|
+
(0, _react.css)("overflow:", withOverflow ? 'hidden' : 'inherit', ";text-overflow:", withOverflow ? 'ellipsis' : 'inherit', ";width:100%;height:inherit;position:relative;#unique-tooltip-id{display:", visible ? 'block !important' : 'none !important', ";}" + (process.env.NODE_ENV === "production" ? "" : ";label:container;"), process.env.NODE_ENV === "production" ? "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RZOiBudW1iZXIsIHdpZHRoPzogbnVtYmVyKSA9PiAoKTogU2VyaWFsaXplZFN0eWxlcyA9PlxuICAgIGNzc2BcbiAgICAgIHBvc2l0aW9uOiBhYnNvbHV0ZTtcbiAgICAgIG9wYWNpdHk6IDEgIWltcG9ydGFudDtcbiAgICAgIHRvcDogJHtjbGllbnRZICsgJ3B4J307XG4gICAgICBsZWZ0OiAke2NsaWVudFggKyAncHgnfTtcbiAgICAgIHotaW5kZXg6IDk5OTk5OTk5OTtcbiAgICAgIHdpZHRoOiAke3dpZHRoID8gcmVtKHdpZHRoKSA6IGBmaXQtY29udGVudGB9O1xuICAgICAgaGVpZ2h0OiBmaXQtY29udGVudDtcbiAgICBgO1xuIl19 */", process.env.NODE_ENV === "production" ? "" : ";label:container;")
|
|
15
17
|
);
|
|
16
18
|
};
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
exports.container = container;
|
|
20
22
|
|
|
21
|
-
var itemContainer = function itemContainer(clientX, clientY) {
|
|
22
|
-
return function (
|
|
23
|
+
var itemContainer = function itemContainer(clientX, clientY, width) {
|
|
24
|
+
return function () {
|
|
23
25
|
return (
|
|
24
26
|
/*#__PURE__*/
|
|
25
27
|
|
|
26
28
|
/*#__PURE__*/
|
|
27
|
-
(0, _react.css)("position:
|
|
29
|
+
(0, _react.css)("position:absolute;opacity:1!important;top:", clientY + 'px', ";left:", clientX + 'px', ";z-index:999999999;width:", width ? (0, _polished.rem)(width) : "fit-content", ";height:fit-content;" + (process.env.NODE_ENV === "production" ? "" : ";label:itemContainer;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb21wb25lbnRzL3V0aWxzL1Bvc2l0aW9uSW5TY3JlZW4vUG9zaXRpb25JblNjcmVlbi5zdHlsZS50c3giXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBa0JPIi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DogJHtjbGllbnRYICsgJ3B4J307XG4gICAgICB6LWluZGV4OiA5OTk5OTk5OTk7XG4gICAgICB3aWR0aDogJHt3aWR0aCA/IHJlbSh3aWR0aCkgOiBgZml0LWNvbnRlbnRgfTtcbiAgICAgIGhlaWdodDogZml0LWNvbnRlbnQ7XG4gICAgYDtcbiJdfQ== */", process.env.NODE_ENV === "production" ? "" : ";label:itemContainer;")
|
|
28
30
|
);
|
|
29
31
|
};
|
|
30
32
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const usePositionInScreen: (parentRef: React.MutableRefObject<any>, itemRef: React.MutableRefObject<any>, offsetX: number, offsetY: number, visible?: boolean | undefined) => {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
export declare const useWrapperWidth: (hasWrapperWidth: boolean, wrapperRef: React.MutableRefObject<any>) => (number | undefined)[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useWrapperWidth = exports.usePositionInScreen = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
var usePositionInScreen = function usePositionInScreen(parentRef, itemRef, offsetX, offsetY, visible) {
|
|
9
|
+
var _useState = (0, _react.useState)({
|
|
10
|
+
x: -1,
|
|
11
|
+
y: -1
|
|
12
|
+
}),
|
|
13
|
+
position = _useState[0],
|
|
14
|
+
setPosition = _useState[1];
|
|
15
|
+
|
|
16
|
+
(0, _react.useEffect)(function () {
|
|
17
|
+
var _parentRef$current, _itemRef$current, _itemRef$current$chil;
|
|
18
|
+
|
|
19
|
+
// x,y are cordinates in screen
|
|
20
|
+
// width, height are wrapper elements dimensions
|
|
21
|
+
var _ref = parentRef != null && parentRef.current ? parentRef == null ? void 0 : (_parentRef$current = parentRef.current) == null ? void 0 : _parentRef$current.getBoundingClientRect() : {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
24
|
+
width: 0,
|
|
25
|
+
height: 0
|
|
26
|
+
},
|
|
27
|
+
parentX = _ref.x,
|
|
28
|
+
parentY = _ref.y,
|
|
29
|
+
parentWidth = _ref.width,
|
|
30
|
+
parentHeight = _ref.height; // width, height are the element's that's going to be positioned dimensions
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
var _ref2 = itemRef != null && itemRef.current ? itemRef == null ? void 0 : (_itemRef$current = itemRef.current) == null ? void 0 : (_itemRef$current$chil = _itemRef$current.children[0]) == null ? void 0 : _itemRef$current$chil.getBoundingClientRect() : {
|
|
34
|
+
width: 0,
|
|
35
|
+
height: 0
|
|
36
|
+
},
|
|
37
|
+
width = _ref2.width,
|
|
38
|
+
height = _ref2.height; // If the item-to-be-positioned is out of screen height
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
var itemYOutOfScreenHeight = parentY + parentHeight + height > window.innerHeight; // The element that we are positioning is absolutely positioned inside the relative
|
|
42
|
+
// container. So x,y are zero means the element will be positioned exactly on top
|
|
43
|
+
// of the parent element.
|
|
44
|
+
|
|
45
|
+
var x = 0;
|
|
46
|
+
var y = 0;
|
|
47
|
+
|
|
48
|
+
if (itemYOutOfScreenHeight) {
|
|
49
|
+
// We place the element height+offsetY (px) above the parent
|
|
50
|
+
y = y - height - offsetY;
|
|
51
|
+
|
|
52
|
+
if (parentY + y < 0) {
|
|
53
|
+
// Rare case where client height is super small. We don't exactly support this.
|
|
54
|
+
// So we render it as if it was inside the screen height
|
|
55
|
+
y = parentHeight + offsetY;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
// We place the element offsetY (px) under the parent
|
|
59
|
+
y = parentHeight + offsetY;
|
|
60
|
+
} // If the item-to-be-positioned is out of screen width
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
var itemXOutOfScreenWidth = parentX + width > window.innerWidth;
|
|
64
|
+
|
|
65
|
+
if (itemXOutOfScreenWidth) {
|
|
66
|
+
// We place the element parentWidth-width-offsetX (px) at the left of the parent
|
|
67
|
+
x = x + parentWidth - width - offsetX;
|
|
68
|
+
} else {
|
|
69
|
+
// We place the element offset (px) at the right of the parent
|
|
70
|
+
x = offsetX;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setPosition({
|
|
74
|
+
x: x,
|
|
75
|
+
y: y
|
|
76
|
+
});
|
|
77
|
+
}, [parentRef, itemRef, visible, offsetY, offsetX]);
|
|
78
|
+
return position;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.usePositionInScreen = usePositionInScreen;
|
|
82
|
+
|
|
83
|
+
var useWrapperWidth = function useWrapperWidth(hasWrapperWidth, wrapperRef) {
|
|
84
|
+
var _useState2 = (0, _react.useState)(),
|
|
85
|
+
width = _useState2[0],
|
|
86
|
+
setWidth = _useState2[1];
|
|
87
|
+
|
|
88
|
+
(0, _react.useEffect)(function () {
|
|
89
|
+
if (hasWrapperWidth) {
|
|
90
|
+
var _wrapperRef$current, _wrapperRef$current$g;
|
|
91
|
+
|
|
92
|
+
setWidth(wrapperRef == null ? void 0 : (_wrapperRef$current = wrapperRef.current) == null ? void 0 : (_wrapperRef$current$g = _wrapperRef$current.getBoundingClientRect()) == null ? void 0 : _wrapperRef$current$g.width);
|
|
93
|
+
}
|
|
94
|
+
}, [hasWrapperWidth, wrapperRef]);
|
|
95
|
+
return [width];
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
exports.useWrapperWidth = useWrapperWidth;
|