@geneui/components 3.0.0-next-9ffcb93-16102024 → 3.0.0-next-48d0ef7-31102024
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/Avatar.js +63 -0
- package/CHANGELOG.md +7 -0
- package/Divider.js +23 -0
- package/{GeneUIProvider/index.js → GeneUIProvider.js} +52 -65
- package/HelperText.js +69 -0
- package/Info.js +64 -0
- package/Label.js +38 -0
- package/Loader.js +21 -0
- package/Pill.js +64 -0
- package/TextLink.js +20 -0
- package/{index-65217440.js → Tooltip.js} +104 -80
- package/{lib → components}/atoms/Avatar/Avatar.d.ts +7 -6
- package/components/atoms/Avatar/index.d.ts +1 -0
- package/{lib → components}/atoms/Divider/Divider.d.ts +5 -5
- package/components/atoms/Divider/index.d.ts +1 -0
- package/{lib → components}/atoms/HelperText/HelperText.d.ts +6 -5
- package/components/atoms/HelperText/index.d.ts +1 -0
- package/{lib → components}/atoms/Info/Info.d.ts +5 -5
- package/components/atoms/Info/index.d.ts +1 -0
- package/{lib → components}/atoms/Label/Label.d.ts +3 -3
- package/components/atoms/Label/index.d.ts +1 -0
- package/{lib → components}/atoms/Loader/Loader.d.ts +5 -5
- package/components/atoms/Loader/index.d.ts +1 -0
- package/{lib → components}/atoms/Pill/Pill.d.ts +7 -6
- package/components/atoms/Pill/index.d.ts +1 -0
- package/{lib → components}/atoms/TextLink/TextLink.d.ts +5 -5
- package/components/atoms/TextLink/index.d.ts +1 -0
- package/{lib → components}/molecules/Tooltip/Tooltip.d.ts +26 -21
- package/components/molecules/Tooltip/index.d.ts +1 -0
- package/components/providers/GeneUIProvider/GeneUIProvider.d.ts +30 -0
- package/components/providers/GeneUIProvider/index.d.ts +1 -0
- package/hooks/index.d.ts +2 -20
- package/hooks/useDebounceCallback/index.d.ts +1 -0
- package/hooks/useDebounceCallback/useDebounceCallback.d.ts +2 -0
- package/hooks/useEllipsisDetection/index.d.ts +1 -1
- package/hooks/useEllipsisDetection/useEllipsisDetection.d.ts +2 -2
- package/{index-031ff73c.js → index-ce02421b.js} +4 -4
- package/index.d.ts +11 -121
- package/index.js +12 -159
- package/package.json +24 -43
- package/tokens-0abb4e1b.js +6 -0
- package/types/index.d.ts +0 -3
- package/useEllipsisDetection-46d712b6.js +34 -0
- package/ActionableList/index.js +0 -1694
- package/AdvancedSearch/index.js +0 -892
- package/Alert/index.js +0 -98
- package/Avatar/index.js +0 -58
- package/Badge/index.js +0 -29
- package/Breadcrumb/index.js +0 -130
- package/BusyLoader/index.js +0 -31
- package/Button/index.js +0 -30
- package/Card/index.js +0 -502
- package/CardList/index.js +0 -662
- package/CellMeasurerCache-80be385d.js +0 -229
- package/Charts/index.js +0 -17662
- package/Checkbox/index.js +0 -229
- package/CheckboxGroup/index.js +0 -203
- package/CheckboxGroupWithSearch/index.js +0 -280
- package/Collapse/index.js +0 -195
- package/ColorPicker/index.js +0 -210
- package/ComboBox/index.js +0 -524
- package/Copy/index.js +0 -56
- package/Counter/index.js +0 -312
- package/DateFilter/index.js +0 -183
- package/DatePicker/index.js +0 -1229
- package/DatePickerInput/index.js +0 -883
- package/Divider/index.js +0 -23
- package/Drawer/index.js +0 -261
- package/Dropdown/index.js +0 -43
- package/Editor/index.js +0 -22975
- package/Empty/index.js +0 -76
- package/ExtendedInput/index.js +0 -590
- package/Form/index.js +0 -85
- package/FormContainer/index.js +0 -189
- package/FormableCheckbox/index.js +0 -24
- package/FormableDatePicker/index.js +0 -43
- package/FormableDropdown/index.js +0 -50
- package/FormableEditor/index.js +0 -26
- package/FormableHOC-85f89a81.js +0 -83
- package/FormableMultiSelectDropdown/index.js +0 -50
- package/FormableNumberInput/index.js +0 -34
- package/FormableRadio/index.js +0 -22
- package/FormableSwitcher/index.js +0 -22
- package/FormableTextInput/index.js +0 -34
- package/FormableUploader/index.js +0 -44
- package/Grid/index.js +0 -167
- package/HelperText/index.js +0 -86
- package/Holder/index.js +0 -261
- package/Icon/index.js +0 -62
- package/Image/index.js +0 -45
- package/ImagePreview/index.js +0 -217
- package/Info/index.js +0 -41
- package/InfoOutline-dd2e89d9.js +0 -29
- package/InteractiveWidget/index.js +0 -78
- package/KeyValue/index.js +0 -22
- package/Label/index.js +0 -48
- package/LinkButton/index.js +0 -34
- package/Loader/index.js +0 -23
- package/Menu/index.js +0 -281
- package/MobileNavigation/index.js +0 -94
- package/MobilePopup/index.js +0 -182
- package/Modal/index.js +0 -251
- package/ModuleTitle/index.js +0 -141
- package/NavigationMenu/index.js +0 -222
- package/Notification/index.js +0 -120
- package/Option/index.js +0 -184
- package/Overlay/index.js +0 -187
- package/Overspread/index.js +0 -291
- package/Pagination/index.js +0 -261
- package/Paper/index.js +0 -96
- package/Pill/index.js +0 -67
- package/Popover/index.js +0 -725
- package/PopoverV2/index.js +0 -19
- package/Portal/index.js +0 -58
- package/Products/index.js +0 -115
- package/Profile/index.js +0 -589
- package/Progress/index.js +0 -200
- package/QRCode/index.js +0 -814
- package/Radio/index.js +0 -151
- package/RadioGroup/index.js +0 -104
- package/Range/index.js +0 -191
- package/Rating/index.js +0 -174
- package/RichEditor/index.js +0 -13
- package/RichEditor-78c2617e.js +0 -228
- package/Scrollbar/index.js +0 -1585
- package/Search/index.js +0 -75
- package/SearchWithDropdown/index.js +0 -140
- package/Section/index.js +0 -61
- package/SkeletonLoader/index.js +0 -81
- package/Slider/index.js +0 -261
- package/Status/index.js +0 -97
- package/Steps/index.js +0 -314
- package/SuggestionList/index.js +0 -385
- package/Switcher/index.js +0 -193
- package/Table/index.js +0 -57
- package/TableCompositions/index.js +0 -16995
- package/Tabs/index.js +0 -235
- package/Tag/index.js +0 -102
- package/TextLink/index.js +0 -20
- package/Textarea/index.js +0 -242
- package/Time/index.js +0 -62
- package/TimePicker/index.js +0 -575
- package/Timeline/index.js +0 -113
- package/Title/index.js +0 -65
- package/Toaster/index.js +0 -116
- package/Tooltip/index.js +0 -6
- package/TransferList/index.js +0 -493
- package/Uploader/index.js +0 -992
- package/ValidatableCheckbox/index.js +0 -123
- package/ValidatableDatePicker/index.js +0 -316
- package/ValidatableDropdown/index.js +0 -141
- package/ValidatableElements/index.js +0 -67
- package/ValidatableMultiSelectDropdown/index.js +0 -152
- package/ValidatableNumberInput/index.js +0 -204
- package/ValidatableRadio/index.js +0 -116
- package/ValidatableSwitcher/index.js +0 -93
- package/ValidatableTextInput/index.js +0 -167
- package/ValidatableTimeInput/index.js +0 -174
- package/ValidatableUploader/index.js +0 -98
- package/Widget/index.js +0 -225
- package/_commonjsHelpers-24198af3.js +0 -35
- package/_rollupPluginBabelHelpers-a83240e1.js +0 -11
- package/callAfterDelay-7272faca.js +0 -12
- package/checkTimeValidation-e56771be.js +0 -16
- package/checkboxRadioSwitcher-5b69d7bd.js +0 -4
- package/clsx.m-2bb6df4b.js +0 -3
- package/config-1053d64d.js +0 -20
- package/configs-00612ce0.js +0 -103
- package/configs.js +0 -111
- package/dateValidation-67caec66.js +0 -225
- package/debounce-4419bc2f.js +0 -17
- package/guid-8ddf77b3.js +0 -16
- package/hooks/useBodyScroll.js +0 -16
- package/hooks/useClick.js +0 -18
- package/hooks/useClickOutside.js +0 -25
- package/hooks/useDebounce.js +0 -28
- package/hooks/useDeviceType.js +0 -17
- package/hooks/useDidMount.js +0 -15
- package/hooks/useForceUpdate.js +0 -8
- package/hooks/useHover.js +0 -20
- package/hooks/useImgDownload.js +0 -18
- package/hooks/useKeyDown.js +0 -21
- package/hooks/useMount.js +0 -13
- package/hooks/useMutationObserver.js +0 -21
- package/hooks/usePrevious.js +0 -10
- package/hooks/useThrottle.js +0 -16
- package/hooks/useToggle.js +0 -11
- package/hooks/useUpdatableRef.js +0 -14
- package/hooks/useUpdate.js +0 -10
- package/hooks/useWidth.js +0 -16
- package/hooks/useWindowSize.js +0 -40
- package/index-122432cd.js +0 -270
- package/index-262edd7a.js +0 -77
- package/index-2f5aa51e.js +0 -6483
- package/index-370f9acd.js +0 -4
- package/index-45eafea6.js +0 -90
- package/index-480fd7d9.js +0 -10032
- package/index-5f37f281.js +0 -168
- package/index-73aaa093.js +0 -1940
- package/index.mobile.d.ts +0 -14
- package/lib/atoms/Avatar/index.d.ts +0 -1
- package/lib/atoms/Badge/Badge.d.ts +0 -36
- package/lib/atoms/Badge/index.d.ts +0 -1
- package/lib/atoms/BusyLoader/BusyLoader.d.ts +0 -32
- package/lib/atoms/BusyLoader/BusyLoaderHolderHOC.d.ts +0 -8
- package/lib/atoms/BusyLoader/index.d.ts +0 -1
- package/lib/atoms/Button/Button.d.ts +0 -70
- package/lib/atoms/Button/index.d.ts +0 -1
- package/lib/atoms/Divider/index.d.ts +0 -1
- package/lib/atoms/Empty/Empty.d.ts +0 -39
- package/lib/atoms/Empty/index.d.ts +0 -1
- package/lib/atoms/Empty/utils.d.ts +0 -9
- package/lib/atoms/HelperText/index.d.ts +0 -1
- package/lib/atoms/Image/Image.d.ts +0 -51
- package/lib/atoms/Image/index.d.ts +0 -1
- package/lib/atoms/ImagePreview/ImagePreview.d.ts +0 -56
- package/lib/atoms/ImagePreview/ImagePreviewHOC.d.ts +0 -4
- package/lib/atoms/ImagePreview/Magnifier.d.ts +0 -40
- package/lib/atoms/ImagePreview/index.d.ts +0 -1
- package/lib/atoms/Info/index.d.ts +0 -1
- package/lib/atoms/KeyValue/KeyValue.d.ts +0 -29
- package/lib/atoms/KeyValue/index.d.ts +0 -1
- package/lib/atoms/Label/index.d.ts +0 -1
- package/lib/atoms/LinkButton/LinkButton.d.ts +0 -46
- package/lib/atoms/LinkButton/index.d.ts +0 -1
- package/lib/atoms/Loader/index.d.ts +0 -1
- package/lib/atoms/Pill/index.d.ts +0 -1
- package/lib/atoms/Rating/DefaultSvg.d.ts +0 -3
- package/lib/atoms/Rating/Rating.d.ts +0 -49
- package/lib/atoms/Rating/index.d.ts +0 -1
- package/lib/atoms/TextLink/index.d.ts +0 -1
- package/lib/molecules/Copy/Copy.d.ts +0 -38
- package/lib/molecules/Copy/index.d.ts +0 -1
- package/lib/molecules/InteractiveWidget/InteractiveWidget.d.ts +0 -70
- package/lib/molecules/InteractiveWidget/InteractiveWidgetIcon.d.ts +0 -8
- package/lib/molecules/InteractiveWidget/index.d.ts +0 -1
- package/lib/molecules/Tooltip/index.d.ts +0 -1
- package/lib/providers/GeneUIProvider/GeneUIProvider.d.ts +0 -30
- package/lib/providers/GeneUIProvider/index.d.ts +0 -1
- package/localization-4ba17032.js +0 -46
- package/objectWithoutPropertiesLoose-e1596bdb.js +0 -62
- package/rangeAndSlider-693a3d41.js +0 -8684
- package/react-beautiful-dnd.esm-b637016a.js +0 -10116
- package/react-lifecycles-compat.es-6e1f3768.js +0 -158
- package/redux-e591c1b8.js +0 -536
- package/tokens-8ab1179c.js +0 -6
- package/tslib.es6-f211516f.js +0 -35
- package/useEllipsisDetection-c1c9ad94.js +0 -38
package/Popover/index.js
DELETED
|
@@ -1,725 +0,0 @@
|
|
|
1
|
-
import { _ as _extends } from '../_rollupPluginBabelHelpers-a83240e1.js';
|
|
2
|
-
import React__default, { forwardRef, useRef, useState, useContext, useCallback, useMemo, Children, useEffect } from 'react';
|
|
3
|
-
import { c as commonjsGlobal } from '../_commonjsHelpers-24198af3.js';
|
|
4
|
-
import ReactDOM__default from 'react-dom';
|
|
5
|
-
import { u as useSwipeable } from '../index-122432cd.js';
|
|
6
|
-
import { c as classnames } from '../index-031ff73c.js';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import { n as noop, s as stopEvent } from '../index-5f37f281.js';
|
|
9
|
-
import useDeviceType from '../hooks/useDeviceType.js';
|
|
10
|
-
import useUpdatableRef from '../hooks/useUpdatableRef.js';
|
|
11
|
-
import { g as popoverConfig, s as screenTypes } from '../configs-00612ce0.js';
|
|
12
|
-
import { GeneUIDesignSystemContext } from '../GeneUIProvider/index.js';
|
|
13
|
-
import Portal from '../Portal/index.js';
|
|
14
|
-
import CustomScrollbar from '../Scrollbar/index.js';
|
|
15
|
-
import { s as styleInject } from '../style-inject.es-746bb8ed.js';
|
|
16
|
-
import { g as guid } from '../guid-8ddf77b3.js';
|
|
17
|
-
import '../dateValidation-67caec66.js';
|
|
18
|
-
import '../hooks/useWindowSize.js';
|
|
19
|
-
import '../hooks/useDebounce.js';
|
|
20
|
-
import '../hooks/useForceUpdate.js';
|
|
21
|
-
|
|
22
|
-
var Popover$2 = {};
|
|
23
|
-
|
|
24
|
-
var util = {};
|
|
25
|
-
|
|
26
|
-
Object.defineProperty(util, "__esModule", { value: true });
|
|
27
|
-
util.Constants = {
|
|
28
|
-
POPOVER_CONTAINER_CLASS_NAME: 'react-tiny-popover-container',
|
|
29
|
-
DEFAULT_PADDING: 6,
|
|
30
|
-
DEFAULT_WINDOW_PADDING: 6,
|
|
31
|
-
FADE_TRANSITION: 0.35,
|
|
32
|
-
DEFAULT_ARROW_COLOR: 'black',
|
|
33
|
-
DEFAULT_POSITIONS: ['top', 'left', 'right', 'bottom'],
|
|
34
|
-
EMPTY_CLIENT_RECT: {
|
|
35
|
-
top: 0,
|
|
36
|
-
left: 0,
|
|
37
|
-
bottom: 0,
|
|
38
|
-
height: 0,
|
|
39
|
-
right: 0,
|
|
40
|
-
width: 0,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
util.arrayUnique = function (array) { return array.filter(function (value, index, self) { return self.indexOf(value) === index; }); };
|
|
44
|
-
|
|
45
|
-
var ArrowContainer$1 = {};
|
|
46
|
-
|
|
47
|
-
var __assign = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
48
|
-
__assign = Object.assign || function(t) {
|
|
49
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
50
|
-
s = arguments[i];
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
52
|
-
t[p] = s[p];
|
|
53
|
-
}
|
|
54
|
-
return t;
|
|
55
|
-
};
|
|
56
|
-
return __assign.apply(this, arguments);
|
|
57
|
-
};
|
|
58
|
-
Object.defineProperty(ArrowContainer$1, "__esModule", { value: true });
|
|
59
|
-
var React$1 = React__default;
|
|
60
|
-
var util_1$1 = util;
|
|
61
|
-
var ArrowContainer = function (_a) {
|
|
62
|
-
var position = _a.position, children = _a.children, style = _a.style, _b = _a.arrowColor, arrowColor = _b === void 0 ? util_1$1.Constants.DEFAULT_ARROW_COLOR : _b, _c = _a.arrowSize, arrowSize = _c === void 0 ? 10 : _c, arrowStyle = _a.arrowStyle, popoverRect = _a.popoverRect, targetRect = _a.targetRect;
|
|
63
|
-
return (React$1.createElement("div", { style: __assign({ paddingLeft: position === 'right' ? arrowSize : 0, paddingTop: position === 'bottom' ? arrowSize : 0, paddingBottom: position === 'top' ? arrowSize : 0, paddingRight: position === 'left' ? arrowSize : 0 }, style) },
|
|
64
|
-
React$1.createElement("div", { style: __assign({ position: 'absolute' }, (function () {
|
|
65
|
-
var arrowWidth = arrowSize * 2;
|
|
66
|
-
var top = (targetRect.top - popoverRect.top) + (targetRect.height / 2) - (arrowWidth / 2);
|
|
67
|
-
var left = (targetRect.left - popoverRect.left) + (targetRect.width / 2) - (arrowWidth / 2);
|
|
68
|
-
left = left < 0 ? 0 : left;
|
|
69
|
-
left = left + arrowWidth > popoverRect.width ? popoverRect.width - arrowWidth : left;
|
|
70
|
-
top = top < 0 ? 0 : top;
|
|
71
|
-
top = top + arrowWidth > popoverRect.height ? popoverRect.height - arrowWidth : top;
|
|
72
|
-
switch (position) {
|
|
73
|
-
case 'right':
|
|
74
|
-
return {
|
|
75
|
-
borderTop: arrowSize + "px solid transparent",
|
|
76
|
-
borderBottom: arrowSize + "px solid transparent",
|
|
77
|
-
borderRight: arrowSize + "px solid " + arrowColor,
|
|
78
|
-
left: 0,
|
|
79
|
-
top: top,
|
|
80
|
-
};
|
|
81
|
-
case 'left':
|
|
82
|
-
return {
|
|
83
|
-
borderTop: arrowSize + "px solid transparent",
|
|
84
|
-
borderBottom: arrowSize + "px solid transparent",
|
|
85
|
-
borderLeft: arrowSize + "px solid " + arrowColor,
|
|
86
|
-
right: 0,
|
|
87
|
-
top: top,
|
|
88
|
-
};
|
|
89
|
-
case 'bottom':
|
|
90
|
-
return {
|
|
91
|
-
borderLeft: arrowSize + "px solid transparent",
|
|
92
|
-
borderRight: arrowSize + "px solid transparent",
|
|
93
|
-
borderBottom: arrowSize + "px solid " + arrowColor,
|
|
94
|
-
top: 0,
|
|
95
|
-
left: left,
|
|
96
|
-
};
|
|
97
|
-
case 'top':
|
|
98
|
-
default:
|
|
99
|
-
return {
|
|
100
|
-
borderLeft: arrowSize + "px solid transparent",
|
|
101
|
-
borderRight: arrowSize + "px solid transparent",
|
|
102
|
-
borderTop: arrowSize + "px solid " + arrowColor,
|
|
103
|
-
bottom: 0,
|
|
104
|
-
left: left,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
})(), arrowStyle) }),
|
|
108
|
-
children));
|
|
109
|
-
};
|
|
110
|
-
ArrowContainer$1.ArrowContainer = ArrowContainer;
|
|
111
|
-
|
|
112
|
-
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
113
|
-
var extendStatics = function (d, b) {
|
|
114
|
-
extendStatics = Object.setPrototypeOf ||
|
|
115
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
116
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
117
|
-
return extendStatics(d, b);
|
|
118
|
-
};
|
|
119
|
-
return function (d, b) {
|
|
120
|
-
extendStatics(d, b);
|
|
121
|
-
function __() { this.constructor = d; }
|
|
122
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
123
|
-
};
|
|
124
|
-
})();
|
|
125
|
-
Object.defineProperty(Popover$2, "__esModule", { value: true });
|
|
126
|
-
var React = React__default;
|
|
127
|
-
var react_dom_1 = ReactDOM__default;
|
|
128
|
-
var util_1 = util;
|
|
129
|
-
var ArrowContainer_1 = ArrowContainer$1;
|
|
130
|
-
Popover$2.ArrowContainer = ArrowContainer_1.ArrowContainer;
|
|
131
|
-
var Popover$1 = /** @class */ (function (_super) {
|
|
132
|
-
__extends(Popover, _super);
|
|
133
|
-
function Popover() {
|
|
134
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
135
|
-
_this.target = null;
|
|
136
|
-
_this.targetRect = null;
|
|
137
|
-
_this.targetPositionIntervalHandler = null;
|
|
138
|
-
_this.popoverDiv = null;
|
|
139
|
-
_this.positionOrder = null;
|
|
140
|
-
_this.willUnmount = false;
|
|
141
|
-
_this.willMount = false;
|
|
142
|
-
_this.onResize = function (e) {
|
|
143
|
-
_this.renderPopover();
|
|
144
|
-
};
|
|
145
|
-
_this.onClick = function (e) {
|
|
146
|
-
var _a = _this.props, onClickOutside = _a.onClickOutside, isOpen = _a.isOpen;
|
|
147
|
-
if (!_this.willUnmount && !_this.willMount && !_this.popoverDiv.contains(e.target) && !_this.target.contains(e.target) && onClickOutside && isOpen) {
|
|
148
|
-
onClickOutside(e);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
return _this;
|
|
152
|
-
}
|
|
153
|
-
Popover.prototype.componentDidMount = function () {
|
|
154
|
-
var _this = this;
|
|
155
|
-
window.setTimeout(function () { return _this.willMount = false; });
|
|
156
|
-
var _a = this.props, position = _a.position, isOpen = _a.isOpen;
|
|
157
|
-
this.target = react_dom_1.findDOMNode(this);
|
|
158
|
-
this.positionOrder = this.getPositionPriorityOrder(position);
|
|
159
|
-
this.updatePopover(isOpen);
|
|
160
|
-
};
|
|
161
|
-
Popover.prototype.componentDidUpdate = function (prevProps) {
|
|
162
|
-
if (this.target == null) {
|
|
163
|
-
this.target = react_dom_1.findDOMNode(this);
|
|
164
|
-
}
|
|
165
|
-
var prevIsOpen = prevProps.isOpen, prevPosition = prevProps.position, prevBody = prevProps.content;
|
|
166
|
-
var _a = this.props, isOpen = _a.isOpen, content = _a.content, position = _a.position;
|
|
167
|
-
this.positionOrder = this.getPositionPriorityOrder(this.props.position);
|
|
168
|
-
var hasNewDestination = prevProps.contentDestination !== this.props.contentDestination;
|
|
169
|
-
if (prevIsOpen !== isOpen ||
|
|
170
|
-
prevBody !== content ||
|
|
171
|
-
prevPosition !== position ||
|
|
172
|
-
hasNewDestination) {
|
|
173
|
-
if (hasNewDestination) {
|
|
174
|
-
this.removePopover();
|
|
175
|
-
this.popoverDiv.remove();
|
|
176
|
-
}
|
|
177
|
-
this.updatePopover(isOpen);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
Popover.prototype.componentWillMount = function () {
|
|
181
|
-
this.willUnmount = false;
|
|
182
|
-
this.willMount = true;
|
|
183
|
-
};
|
|
184
|
-
Popover.prototype.componentWillUnmount = function () {
|
|
185
|
-
this.willUnmount = true;
|
|
186
|
-
this.removePopover();
|
|
187
|
-
};
|
|
188
|
-
Popover.prototype.render = function () {
|
|
189
|
-
return this.props.children;
|
|
190
|
-
};
|
|
191
|
-
Popover.prototype.updatePopover = function (isOpen) {
|
|
192
|
-
if (isOpen && this.target != null) {
|
|
193
|
-
if (!this.popoverDiv || !this.popoverDiv.parentNode) {
|
|
194
|
-
var transitionDuration = this.props.transitionDuration;
|
|
195
|
-
this.popoverDiv = this.createContainer();
|
|
196
|
-
this.popoverDiv.style.opacity = '0';
|
|
197
|
-
this.popoverDiv.style.transition = "opacity " + (transitionDuration || util_1.Constants.FADE_TRANSITION) + "s";
|
|
198
|
-
(this.props.contentDestination || window.document.body).appendChild(this.popoverDiv);
|
|
199
|
-
window.addEventListener('resize', this.onResize);
|
|
200
|
-
window.addEventListener('click', this.onClick);
|
|
201
|
-
}
|
|
202
|
-
this.renderPopover();
|
|
203
|
-
}
|
|
204
|
-
else if (this.popoverDiv && this.popoverDiv.parentNode) {
|
|
205
|
-
this.removePopover();
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
Popover.prototype.renderPopover = function (positionIndex) {
|
|
209
|
-
var _this = this;
|
|
210
|
-
if (positionIndex === void 0) { positionIndex = 0; }
|
|
211
|
-
if (positionIndex >= this.positionOrder.length) {
|
|
212
|
-
this.removePopover();
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
this.renderWithPosition({ position: this.positionOrder[positionIndex], targetRect: this.target.getBoundingClientRect() }, function (violation, rect) {
|
|
216
|
-
var _a;
|
|
217
|
-
var _b = _this.props, disableReposition = _b.disableReposition, contentLocation = _b.contentLocation;
|
|
218
|
-
if (violation && !disableReposition && !(typeof contentLocation === 'object')) {
|
|
219
|
-
_this.renderPopover(positionIndex + 1);
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
var _c = _this.props, contentLocation_1 = _c.contentLocation, align = _c.align;
|
|
223
|
-
var _d = _this.getNudgedPopoverPosition(rect), nudgedTop = _d.top, nudgedLeft = _d.left;
|
|
224
|
-
var rectTop = rect.top, rectLeft = rect.left;
|
|
225
|
-
var position = _this.positionOrder[positionIndex];
|
|
226
|
-
var _e = disableReposition ? { top: rectTop, left: rectLeft } : { top: nudgedTop, left: nudgedLeft }, top_1 = _e.top, left = _e.left;
|
|
227
|
-
if (contentLocation_1) {
|
|
228
|
-
var targetRect = _this.target.getBoundingClientRect();
|
|
229
|
-
var popoverRect = _this.popoverDiv.getBoundingClientRect();
|
|
230
|
-
(_a = typeof contentLocation_1 === 'function' ? contentLocation_1({ targetRect: targetRect, popoverRect: popoverRect, position: position, align: align, nudgedLeft: nudgedLeft, nudgedTop: nudgedTop }) : contentLocation_1, top_1 = _a.top, left = _a.left);
|
|
231
|
-
_this.popoverDiv.style.left = left.toFixed() + "px";
|
|
232
|
-
_this.popoverDiv.style.top = top_1.toFixed() + "px";
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
var destinationTopOffset = 0;
|
|
236
|
-
var destinationLeftOffset = 0;
|
|
237
|
-
if (_this.props.contentDestination) {
|
|
238
|
-
var destRect = _this.props.contentDestination.getBoundingClientRect();
|
|
239
|
-
destinationTopOffset = -destRect.top;
|
|
240
|
-
destinationLeftOffset = -destRect.left;
|
|
241
|
-
}
|
|
242
|
-
var _f = [top_1 + window.pageYOffset, left + window.pageXOffset], absoluteTop = _f[0], absoluteLeft = _f[1];
|
|
243
|
-
var finalLeft = absoluteLeft + destinationTopOffset;
|
|
244
|
-
var finalTop = absoluteTop + destinationLeftOffset;
|
|
245
|
-
_this.popoverDiv.style.left = finalLeft.toFixed() + "px";
|
|
246
|
-
_this.popoverDiv.style.top = finalTop.toFixed() + "px";
|
|
247
|
-
}
|
|
248
|
-
_this.popoverDiv.style.width = null;
|
|
249
|
-
_this.popoverDiv.style.height = null;
|
|
250
|
-
_this.renderWithPosition({
|
|
251
|
-
position: position,
|
|
252
|
-
nudgedTop: nudgedTop - rect.top,
|
|
253
|
-
nudgedLeft: nudgedLeft - rect.left,
|
|
254
|
-
targetRect: _this.target.getBoundingClientRect(),
|
|
255
|
-
popoverRect: _this.popoverDiv.getBoundingClientRect(),
|
|
256
|
-
}, function () {
|
|
257
|
-
_this.startTargetPositionListener(10);
|
|
258
|
-
if (_this.popoverDiv.style.opacity !== '1') {
|
|
259
|
-
_this.popoverDiv.style.opacity = '1';
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
Popover.prototype.startTargetPositionListener = function (checkInterval) {
|
|
266
|
-
var _this = this;
|
|
267
|
-
if (this.targetPositionIntervalHandler === null) {
|
|
268
|
-
this.targetPositionIntervalHandler = window.setInterval(function () {
|
|
269
|
-
var newTargetRect = _this.target.getBoundingClientRect();
|
|
270
|
-
if (_this.targetPositionHasChanged(_this.targetRect, newTargetRect)) {
|
|
271
|
-
_this.renderPopover();
|
|
272
|
-
}
|
|
273
|
-
_this.targetRect = newTargetRect;
|
|
274
|
-
}, checkInterval);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
Popover.prototype.renderWithPosition = function (_a, callback) {
|
|
278
|
-
var _this = this;
|
|
279
|
-
var position = _a.position, _b = _a.nudgedLeft, nudgedLeft = _b === void 0 ? 0 : _b, _c = _a.nudgedTop, nudgedTop = _c === void 0 ? 0 : _c, _d = _a.targetRect, targetRect = _d === void 0 ? util_1.Constants.EMPTY_CLIENT_RECT : _d, _e = _a.popoverRect, popoverRect = _e === void 0 ? util_1.Constants.EMPTY_CLIENT_RECT : _e;
|
|
280
|
-
var _f = this.props, padding = _f.windowBorderPadding, content = _f.content, align = _f.align;
|
|
281
|
-
var getContent = function (args) {
|
|
282
|
-
return typeof content === 'function'
|
|
283
|
-
? content(args)
|
|
284
|
-
: content;
|
|
285
|
-
};
|
|
286
|
-
react_dom_1.unstable_renderSubtreeIntoContainer(this, getContent({ position: position, nudgedLeft: nudgedLeft, nudgedTop: nudgedTop, targetRect: targetRect, popoverRect: popoverRect, align: align }), this.popoverDiv, function () {
|
|
287
|
-
if (_this.willUnmount) {
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
var targetRect = _this.target.getBoundingClientRect();
|
|
291
|
-
var popoverRect = _this.popoverDiv.getBoundingClientRect();
|
|
292
|
-
var _a = _this.getLocationForPosition(position, targetRect, popoverRect), top = _a.top, left = _a.left;
|
|
293
|
-
callback(position === 'top' && top < padding ||
|
|
294
|
-
position === 'left' && left < padding ||
|
|
295
|
-
position === 'right' && left + popoverRect.width > window.innerWidth - padding ||
|
|
296
|
-
position === 'bottom' && top + popoverRect.height > window.innerHeight - padding, { width: popoverRect.width, height: popoverRect.height, top: top, left: left });
|
|
297
|
-
});
|
|
298
|
-
};
|
|
299
|
-
Popover.prototype.getNudgedPopoverPosition = function (_a) {
|
|
300
|
-
var top = _a.top, left = _a.left, width = _a.width, height = _a.height;
|
|
301
|
-
var padding = this.props.windowBorderPadding;
|
|
302
|
-
top = top < padding ? padding : top;
|
|
303
|
-
top = top + height > window.innerHeight - padding ? window.innerHeight - padding - height : top;
|
|
304
|
-
left = left < padding ? padding : left;
|
|
305
|
-
left = left + width > window.innerWidth - padding ? window.innerWidth - padding - width : left;
|
|
306
|
-
return { top: top, left: left };
|
|
307
|
-
};
|
|
308
|
-
Popover.prototype.removePopover = function () {
|
|
309
|
-
var _this = this;
|
|
310
|
-
if (this.popoverDiv) {
|
|
311
|
-
var transitionDuration = this.props.transitionDuration;
|
|
312
|
-
this.popoverDiv.style.opacity = '0';
|
|
313
|
-
var remove = function () {
|
|
314
|
-
if (_this.willUnmount || !_this.props.isOpen || !_this.popoverDiv.parentNode) {
|
|
315
|
-
window.clearInterval(_this.targetPositionIntervalHandler);
|
|
316
|
-
window.removeEventListener('resize', _this.onResize);
|
|
317
|
-
window.removeEventListener('click', _this.onClick);
|
|
318
|
-
_this.targetPositionIntervalHandler = null;
|
|
319
|
-
if (_this.popoverDiv.parentNode) {
|
|
320
|
-
_this.popoverDiv.parentNode.removeChild(_this.popoverDiv);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
if (!this.willUnmount) {
|
|
325
|
-
window.setTimeout(remove, (transitionDuration || util_1.Constants.FADE_TRANSITION) * 1000);
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
remove();
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
Popover.prototype.getPositionPriorityOrder = function (position) {
|
|
333
|
-
if (position && typeof position !== 'string') {
|
|
334
|
-
if (util_1.Constants.DEFAULT_POSITIONS.every(function (defaultPosition) { return position.find(function (p) { return p === defaultPosition; }) !== undefined; })) {
|
|
335
|
-
return util_1.arrayUnique(position);
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
var remainingPositions = util_1.Constants.DEFAULT_POSITIONS.filter(function (defaultPosition) { return position.find(function (p) { return p === defaultPosition; }) === undefined; });
|
|
339
|
-
return util_1.arrayUnique(position.concat(remainingPositions));
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
else if (position && typeof position === 'string') {
|
|
343
|
-
var remainingPositions = util_1.Constants.DEFAULT_POSITIONS.filter(function (defaultPosition) { return defaultPosition !== position; });
|
|
344
|
-
return util_1.arrayUnique([position].concat(remainingPositions));
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
Popover.prototype.createContainer = function () {
|
|
348
|
-
var _a = this.props, containerStyle = _a.containerStyle, containerClassName = _a.containerClassName;
|
|
349
|
-
var container = window.document.createElement('div');
|
|
350
|
-
container.style.overflow = 'hidden';
|
|
351
|
-
if (containerStyle) {
|
|
352
|
-
Object.keys(containerStyle).forEach(function (key) { return container.style[key] = containerStyle[key]; });
|
|
353
|
-
}
|
|
354
|
-
container.className = containerClassName;
|
|
355
|
-
container.style.position = 'absolute';
|
|
356
|
-
container.style.top = '0';
|
|
357
|
-
container.style.left = '0';
|
|
358
|
-
return container;
|
|
359
|
-
};
|
|
360
|
-
Popover.prototype.getLocationForPosition = function (position, newTargetRect, popoverRect) {
|
|
361
|
-
var _a = this.props, padding = _a.padding, align = _a.align;
|
|
362
|
-
var targetMidX = newTargetRect.left + (newTargetRect.width / 2);
|
|
363
|
-
var targetMidY = newTargetRect.top + (newTargetRect.height / 2);
|
|
364
|
-
var top;
|
|
365
|
-
var left;
|
|
366
|
-
switch (position) {
|
|
367
|
-
case 'top':
|
|
368
|
-
top = newTargetRect.top - popoverRect.height - padding;
|
|
369
|
-
left = targetMidX - (popoverRect.width / 2);
|
|
370
|
-
if (align === 'start') {
|
|
371
|
-
left = newTargetRect.left;
|
|
372
|
-
}
|
|
373
|
-
if (align === 'end') {
|
|
374
|
-
left = newTargetRect.right - popoverRect.width;
|
|
375
|
-
}
|
|
376
|
-
break;
|
|
377
|
-
case 'left':
|
|
378
|
-
top = targetMidY - (popoverRect.height / 2);
|
|
379
|
-
left = newTargetRect.left - padding - popoverRect.width;
|
|
380
|
-
if (align === 'start') {
|
|
381
|
-
top = newTargetRect.top;
|
|
382
|
-
}
|
|
383
|
-
if (align === 'end') {
|
|
384
|
-
top = newTargetRect.bottom - popoverRect.height;
|
|
385
|
-
}
|
|
386
|
-
break;
|
|
387
|
-
case 'bottom':
|
|
388
|
-
top = newTargetRect.bottom + padding;
|
|
389
|
-
left = targetMidX - (popoverRect.width / 2);
|
|
390
|
-
if (align === 'start') {
|
|
391
|
-
left = newTargetRect.left;
|
|
392
|
-
}
|
|
393
|
-
if (align === 'end') {
|
|
394
|
-
left = newTargetRect.right - popoverRect.width;
|
|
395
|
-
}
|
|
396
|
-
break;
|
|
397
|
-
case 'right':
|
|
398
|
-
top = targetMidY - (popoverRect.height / 2);
|
|
399
|
-
left = newTargetRect.right + padding;
|
|
400
|
-
if (align === 'start') {
|
|
401
|
-
top = newTargetRect.top;
|
|
402
|
-
}
|
|
403
|
-
if (align === 'end') {
|
|
404
|
-
top = newTargetRect.bottom - popoverRect.height;
|
|
405
|
-
}
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
408
|
-
return { top: top, left: left };
|
|
409
|
-
};
|
|
410
|
-
Popover.prototype.targetPositionHasChanged = function (oldTargetRect, newTargetRect) {
|
|
411
|
-
return oldTargetRect === null
|
|
412
|
-
|| oldTargetRect.left !== newTargetRect.left
|
|
413
|
-
|| oldTargetRect.top !== newTargetRect.top
|
|
414
|
-
|| oldTargetRect.width !== newTargetRect.width
|
|
415
|
-
|| oldTargetRect.height !== newTargetRect.height;
|
|
416
|
-
};
|
|
417
|
-
Popover.defaultProps = {
|
|
418
|
-
padding: util_1.Constants.DEFAULT_PADDING,
|
|
419
|
-
windowBorderPadding: util_1.Constants.DEFAULT_WINDOW_PADDING,
|
|
420
|
-
position: ['top', 'right', 'left', 'bottom'],
|
|
421
|
-
align: 'center',
|
|
422
|
-
containerClassName: util_1.Constants.POPOVER_CONTAINER_CLASS_NAME,
|
|
423
|
-
};
|
|
424
|
-
return Popover;
|
|
425
|
-
}(React.Component));
|
|
426
|
-
var _default = Popover$2.default = Popover$1;
|
|
427
|
-
|
|
428
|
-
var css_248z = "[data-gene-ui-version=\"2.16.3\"] .popover-positioner{--popover-border-radius:1rem;--popover-shadow:0 0.2rem 0.4rem 0 #0000000d,0 0 0 1px rgba(var(--background-sc-rgb),0.08);z-index:400}[data-gene-ui-version=\"2.16.3\"] .popover-positioner.cr-smooth-radius{--popover-border-radius:0.4rem}[data-gene-ui-version=\"2.16.3\"] .popover-positioner.mobile-view{--popover-border-radius:0.8rem 0.8rem 0 0;--popover-shadow:0 -1px 0.2rem 0 #0000000d;bottom:0;left:0!important;overflow:hidden;position:fixed!important;top:0!important;width:100%}[data-gene-ui-version=\"2.16.3\"] .popover-positioner .popover-top-bottom-padding{padding:1rem 0;width:100%}[data-gene-ui-version=\"2.16.3\"] .popover-positioner .popover-top-bottom-padding>div[style*=width]{width:100%!important}[data-gene-ui-version=\"2.16.3\"] .popover{width:100%}[data-gene-ui-version=\"2.16.3\"] .popover-positioner.mobile-view .popover{height:100%;position:relative}[data-gene-ui-version=\"2.16.3\"] .popover-content{background:var(--background);border-radius:var(--popover-border-radius);box-shadow:var(--popover-shadow);overflow:hidden;padding:0 0 env(safe-area-inset-bottom);transition:padding .4s;width:100%}[data-gene-ui-version=\"2.16.3\"] .popover-positioner.mobile-view .popover-content{-webkit-overflow-scrolling:auto;bottom:0;left:0;max-height:calc(100% - 10rem);overflow-x:hidden;overflow-y:auto;position:absolute;z-index:1}[data-gene-ui-version=\"2.16.3\"] .popover-positioner.mobile-view[style*=\"opacity: 0\"] .popover-content{transform:translateY(100%)}[data-gene-ui-version=\"2.16.3\"] .popover-positioner.mobile-view .popover-content{transform:translateY(0)}[data-gene-ui-version=\"2.16.3\"] .fullHeight{height:100%}[data-gene-ui-version=\"2.16.3\"] .popover-mobile-backdrop{background:#0003;height:100%;left:0;opacity:1;position:absolute;top:0;width:100%;z-index:0}[data-gene-ui-version=\"2.16.3\"] .popover-footer,[data-gene-ui-version=\"2.16.3\"] .popover-header{background:var(--background);position:-webkit-sticky;position:sticky;z-index:1}[data-gene-ui-version=\"2.16.3\"] .popover-header{border-bottom:1px solid rgba(var(--background-sc-rgb),.1);top:0}[data-gene-ui-version=\"2.16.3\"] .popover-footer{align-items:stretch;border-top:1px solid rgba(var(--background-sc-rgb),.1);bottom:calc(env(safe-area-inset-bottom)*-1);display:flex;padding:0 0 env(safe-area-inset-bottom);transition:padding .4s}[data-gene-ui-version=\"2.16.3\"] .popover-body{position:relative;z-index:0}[data-gene-ui-version=\"2.16.3\"] .popover-search{padding:1.4rem 1.5rem}[data-gene-ui-version=\"2.16.3\"] .empty-data-holder{align-items:center;display:flex;height:19rem;justify-content:center;width:100%}[data-gene-ui-version=\"2.16.3\"] .popover-disabled{opacity:.5;pointer-events:none;transition:opacity .5s}";
|
|
429
|
-
styleInject(css_248z);
|
|
430
|
-
|
|
431
|
-
const setRef = (ref, currentRef) => {
|
|
432
|
-
if (!ref) return;
|
|
433
|
-
if (typeof ref === 'function') {
|
|
434
|
-
ref(currentRef);
|
|
435
|
-
} else {
|
|
436
|
-
ref.current = currentRef;
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
const Popover = /*#__PURE__*/forwardRef((props, ref) => {
|
|
440
|
-
const {
|
|
441
|
-
extendTargetWidth,
|
|
442
|
-
disableReposition,
|
|
443
|
-
toggleHandler,
|
|
444
|
-
cornerRadius,
|
|
445
|
-
screenType,
|
|
446
|
-
minHeight,
|
|
447
|
-
maxHeight,
|
|
448
|
-
className,
|
|
449
|
-
children,
|
|
450
|
-
position,
|
|
451
|
-
disabled,
|
|
452
|
-
Content,
|
|
453
|
-
padding,
|
|
454
|
-
behave,
|
|
455
|
-
Header,
|
|
456
|
-
Footer,
|
|
457
|
-
align,
|
|
458
|
-
scrollbarNeeded,
|
|
459
|
-
contentRef,
|
|
460
|
-
isOpen,
|
|
461
|
-
getScrollRef,
|
|
462
|
-
swipeable,
|
|
463
|
-
onSwipedDown,
|
|
464
|
-
scrollbarProps,
|
|
465
|
-
fullHeight,
|
|
466
|
-
...restProps
|
|
467
|
-
} = props;
|
|
468
|
-
const id = guid();
|
|
469
|
-
const popoverBodyRef = useRef(null);
|
|
470
|
-
const [popoverOpened, setPopoverOpened] = useState(false);
|
|
471
|
-
const isControlled = ('isOpen' in props);
|
|
472
|
-
const popoverState = isControlled ? isOpen : popoverOpened;
|
|
473
|
-
const {
|
|
474
|
-
isMobile
|
|
475
|
-
} = useDeviceType(screenType);
|
|
476
|
-
const isToggle = behave === 'toggle';
|
|
477
|
-
const [targetWidth, setTargetWidth] = useState(null);
|
|
478
|
-
const [swipingPosition, setSwipingPosition] = useState(0);
|
|
479
|
-
const [portalContainerRef, updatePortalContainerRef] = useUpdatableRef(null);
|
|
480
|
-
const {
|
|
481
|
-
geneUIProviderRef
|
|
482
|
-
} = useContext(GeneUIDesignSystemContext);
|
|
483
|
-
const checkBodyContains = event => popoverBodyRef.current.contains(event.target);
|
|
484
|
-
const handleSwiped = event => setSwipingPosition(0);
|
|
485
|
-
const handleSwipedDown = touchEvent => {
|
|
486
|
-
!checkBodyContains(touchEvent.event) && onSwipedDown(touchEvent);
|
|
487
|
-
};
|
|
488
|
-
const handleSwiping = useCallback(_ref => {
|
|
489
|
-
let {
|
|
490
|
-
deltaY,
|
|
491
|
-
event
|
|
492
|
-
} = _ref;
|
|
493
|
-
if (checkBodyContains(event)) {
|
|
494
|
-
stopEvent(event);
|
|
495
|
-
} else if (deltaY >= 0) {
|
|
496
|
-
setSwipingPosition(deltaY * -1);
|
|
497
|
-
}
|
|
498
|
-
}, [popoverBodyRef, setSwipingPosition]);
|
|
499
|
-
const swipeHandlers = useSwipeable(useMemo(() => swipeable ? {
|
|
500
|
-
onSwipedDown: handleSwipedDown,
|
|
501
|
-
onSwiping: handleSwiping,
|
|
502
|
-
onSwiped: handleSwiped
|
|
503
|
-
} : {}, [swipeable, handleSwipedDown, handleSwiping, handleSwiped]));
|
|
504
|
-
const popoverStateChange = useCallback(event => {
|
|
505
|
-
stopEvent(event);
|
|
506
|
-
if (isControlled) {
|
|
507
|
-
toggleHandler(event, isOpen);
|
|
508
|
-
} else {
|
|
509
|
-
setPopoverOpened(isPopoverOpened => {
|
|
510
|
-
toggleHandler(event, !isPopoverOpened);
|
|
511
|
-
return !isPopoverOpened;
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
}, [isControlled, toggleHandler, isOpen]);
|
|
515
|
-
const handlePopoverStateChange = useCallback(event => {
|
|
516
|
-
Children.map(children, child => child.props.onClick && child.props.onClick(event));
|
|
517
|
-
popoverStateChange(event);
|
|
518
|
-
}, [children, popoverStateChange]);
|
|
519
|
-
const setPopoverRef = popoverRef => {
|
|
520
|
-
setRef(ref, popoverRef);
|
|
521
|
-
const rect = popoverRef && popoverRef.target.getBoundingClientRect();
|
|
522
|
-
setTargetWidth(rect && rect.width);
|
|
523
|
-
};
|
|
524
|
-
const handleClick = useCallback(e => {
|
|
525
|
-
if (!disabled) {
|
|
526
|
-
popoverState ? isToggle && handlePopoverStateChange(e) : handlePopoverStateChange(e);
|
|
527
|
-
}
|
|
528
|
-
}, [popoverState, isToggle, disabled, handlePopoverStateChange]);
|
|
529
|
-
const generateContentRef = useCallback(element => {
|
|
530
|
-
isMobile && getScrollRef(element);
|
|
531
|
-
if (contentRef) {
|
|
532
|
-
typeof contentRef === 'function' ? contentRef(element) : contentRef.current = element;
|
|
533
|
-
}
|
|
534
|
-
}, [isMobile, contentRef, getScrollRef]);
|
|
535
|
-
const portalContent = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("ul", {
|
|
536
|
-
onClick: stopEvent,
|
|
537
|
-
ref: generateContentRef,
|
|
538
|
-
className: classnames('popover-content', {
|
|
539
|
-
fullHeight: fullHeight && isMobile
|
|
540
|
-
}),
|
|
541
|
-
style: {
|
|
542
|
-
bottom: swipingPosition
|
|
543
|
-
}
|
|
544
|
-
}, Header && /*#__PURE__*/React__default.createElement("li", {
|
|
545
|
-
className: "popover-header"
|
|
546
|
-
}, Header), /*#__PURE__*/React__default.createElement("li", {
|
|
547
|
-
ref: popoverBodyRef,
|
|
548
|
-
className: "popover-body"
|
|
549
|
-
}, scrollbarNeeded && !isMobile ? /*#__PURE__*/React__default.createElement(CustomScrollbar, _extends({
|
|
550
|
-
ref: scrollbar => {
|
|
551
|
-
scrollbar && getScrollRef(scrollbar.view);
|
|
552
|
-
},
|
|
553
|
-
autoHeight: true,
|
|
554
|
-
autoHeightMax: maxHeight,
|
|
555
|
-
autoHeightMin: minHeight
|
|
556
|
-
}, scrollbarProps), Content) : Content), Footer && /*#__PURE__*/React__default.createElement("li", {
|
|
557
|
-
className: "popover-footer"
|
|
558
|
-
}, Footer)), isMobile && /*#__PURE__*/React__default.createElement("div", {
|
|
559
|
-
className: "popover-mobile-backdrop",
|
|
560
|
-
onClick: popoverStateChange
|
|
561
|
-
}));
|
|
562
|
-
const getChild = useCallback((child, index) => /*#__PURE__*/React__default.cloneElement(child, {
|
|
563
|
-
key: index,
|
|
564
|
-
onClick: e => handleClick(e),
|
|
565
|
-
className: classnames(child.props.className, 'cursor-pointer', {
|
|
566
|
-
'popover-opened': popoverState,
|
|
567
|
-
'popover-disabled': disabled
|
|
568
|
-
})
|
|
569
|
-
}), [handleClick, popoverState, disabled]);
|
|
570
|
-
const childElements = useMemo(() => Children.map(children, getChild), [getChild, children]);
|
|
571
|
-
useEffect(() => {
|
|
572
|
-
!popoverState && updatePortalContainerRef(null);
|
|
573
|
-
}, [popoverState]);
|
|
574
|
-
return Content ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_default, _extends({
|
|
575
|
-
contentDestination: geneUIProviderRef.current,
|
|
576
|
-
disableReposition: disableReposition,
|
|
577
|
-
ref: setPopoverRef,
|
|
578
|
-
isOpen: popoverState,
|
|
579
|
-
position: position,
|
|
580
|
-
align: align,
|
|
581
|
-
onClickOutside: handlePopoverStateChange,
|
|
582
|
-
containerClassName: classnames("popover-positioner", "cr-".concat(cornerRadius), className, {
|
|
583
|
-
'mobile-view': isMobile
|
|
584
|
-
}),
|
|
585
|
-
transitionDuration: -1,
|
|
586
|
-
padding: padding,
|
|
587
|
-
content: /*#__PURE__*/React__default.createElement("div", swipeHandlers, /*#__PURE__*/React__default.createElement("div", {
|
|
588
|
-
ref: updatePortalContainerRef,
|
|
589
|
-
id: id,
|
|
590
|
-
style: {
|
|
591
|
-
width: extendTargetWidth && !isMobile && targetWidth || null
|
|
592
|
-
}
|
|
593
|
-
})),
|
|
594
|
-
containerStyle: {
|
|
595
|
-
overflow: null
|
|
596
|
-
}
|
|
597
|
-
}, restProps), childElements), portalContainerRef.current && /*#__PURE__*/React__default.createElement(Portal, {
|
|
598
|
-
isOpen: true,
|
|
599
|
-
container: portalContainerRef.current
|
|
600
|
-
}, portalContent)) : childElements;
|
|
601
|
-
});
|
|
602
|
-
Popover.propTypes = {
|
|
603
|
-
/**
|
|
604
|
-
* The component that need to be displayed in the Popover. Any valid React node
|
|
605
|
-
*/
|
|
606
|
-
Content: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
607
|
-
/**
|
|
608
|
-
* The component that need to be displayed as Popover header. Any valid React node
|
|
609
|
-
*/
|
|
610
|
-
Header: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
611
|
-
/**
|
|
612
|
-
* The component that need to be displayed as Popover footer. Any valid React node
|
|
613
|
-
*/
|
|
614
|
-
Footer: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
615
|
-
/**
|
|
616
|
-
* The component which click needs to trigger the Popover to open. Need to passed as child to Popover. Any valid React node
|
|
617
|
-
*/
|
|
618
|
-
children: PropTypes.node,
|
|
619
|
-
/**
|
|
620
|
-
* The Popover will get the width of its child. The property will not work when "width" prop is specified
|
|
621
|
-
*/
|
|
622
|
-
extendTargetWidth: PropTypes.bool,
|
|
623
|
-
/**
|
|
624
|
-
* The Popover "Content" minimum scroll height
|
|
625
|
-
*/
|
|
626
|
-
minHeight: PropTypes.number,
|
|
627
|
-
/**
|
|
628
|
-
* The Popover "Content" maximum scroll height. Will not work when the "screenType" is "mobile"
|
|
629
|
-
*/
|
|
630
|
-
maxHeight: PropTypes.number,
|
|
631
|
-
/**
|
|
632
|
-
* Use this prop to control the Popover. Note the component will start not to open and close automatically
|
|
633
|
-
*/
|
|
634
|
-
isOpen: PropTypes.bool,
|
|
635
|
-
/**
|
|
636
|
-
* Popover position to be displayed
|
|
637
|
-
*/
|
|
638
|
-
position: PropTypes.oneOfType([PropTypes.oneOf(popoverConfig.position), PropTypes.arrayOf(PropTypes.oneOf(popoverConfig.position))]),
|
|
639
|
-
/**
|
|
640
|
-
* Will called each time the popover need to be toggled(child click, close button click, backdrop click).
|
|
641
|
-
* (event: Event, isOpen: bool) => void
|
|
642
|
-
*/
|
|
643
|
-
toggleHandler: PropTypes.func,
|
|
644
|
-
/**
|
|
645
|
-
* Possible values are start, center, and end.
|
|
646
|
-
* If start is specified, the popover content's top or left location is aligned with its target's.
|
|
647
|
-
* With end specified, the content's bottom or right location is aligned with its target's.
|
|
648
|
-
* If center is specified, the popover content and target's centers are aligned.
|
|
649
|
-
*/
|
|
650
|
-
align: PropTypes.oneOf(popoverConfig.align),
|
|
651
|
-
/**
|
|
652
|
-
* If you'd like to apply styles to the single container div that your popover content is rendered within via stylesheets,
|
|
653
|
-
* you can specify a custom className for the container here.
|
|
654
|
-
*/
|
|
655
|
-
className: PropTypes.string,
|
|
656
|
-
/**
|
|
657
|
-
* This number determines the gap, in pixels, between your target content and your popover content
|
|
658
|
-
*/
|
|
659
|
-
padding: PropTypes.number,
|
|
660
|
-
/**
|
|
661
|
-
* If this property is enabled, rather than the popover content repositioning on a boundary collision,
|
|
662
|
-
* the popover content container will move beyond the window's bounds.
|
|
663
|
-
* You are, however, supplied with nudgedLeft and nudgedTop values, so you may choose to handle content overflow as you wish.
|
|
664
|
-
*/
|
|
665
|
-
disableReposition: PropTypes.bool,
|
|
666
|
-
/**
|
|
667
|
-
* Popover corner radius
|
|
668
|
-
*/
|
|
669
|
-
cornerRadius: PropTypes.oneOf(popoverConfig.cornerRadius),
|
|
670
|
-
/**
|
|
671
|
-
* The switch between mobile and desktop version of Popover will be applied automatically, when the prop is not specified.
|
|
672
|
-
* When the prop is present it must be changed from outside.
|
|
673
|
-
*/
|
|
674
|
-
screenType: PropTypes.oneOf(screenTypes),
|
|
675
|
-
/**
|
|
676
|
-
* Specify does Popover needs to be toggled on child click
|
|
677
|
-
*/
|
|
678
|
-
behave: PropTypes.oneOf(popoverConfig.behave),
|
|
679
|
-
/**
|
|
680
|
-
* Given content prop can have its own scroll, and with this props we can use/not use default scroll that has popover
|
|
681
|
-
*/
|
|
682
|
-
scrollbarNeeded: PropTypes.bool,
|
|
683
|
-
/**
|
|
684
|
-
* Popover content ref
|
|
685
|
-
*/
|
|
686
|
-
contentRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
687
|
-
current: PropTypes.any
|
|
688
|
-
})]),
|
|
689
|
-
disabled: PropTypes.bool,
|
|
690
|
-
getScrollRef: PropTypes.func,
|
|
691
|
-
/*
|
|
692
|
-
* After DOWN swipe (SwipeEventData) => void
|
|
693
|
-
*/
|
|
694
|
-
onSwipedDown: PropTypes.func,
|
|
695
|
-
/*
|
|
696
|
-
* props for scrollbar
|
|
697
|
-
*/
|
|
698
|
-
scrollbarProps: PropTypes.shape({
|
|
699
|
-
...CustomScrollbar.propTypes
|
|
700
|
-
}),
|
|
701
|
-
/*
|
|
702
|
-
* Popup content opens with full height. Mobile only property.
|
|
703
|
-
*/
|
|
704
|
-
fullHeight: PropTypes.bool,
|
|
705
|
-
swipeable: PropTypes.bool
|
|
706
|
-
};
|
|
707
|
-
Popover.defaultProps = {
|
|
708
|
-
cornerRadius: popoverConfig.cornerRadius[0],
|
|
709
|
-
position: popoverConfig.position,
|
|
710
|
-
align: popoverConfig.align[0],
|
|
711
|
-
toggleHandler: noop,
|
|
712
|
-
behave: popoverConfig.behave[0],
|
|
713
|
-
fullHeight: false,
|
|
714
|
-
extendTargetWidth: true,
|
|
715
|
-
disableReposition: true,
|
|
716
|
-
minHeight: 0,
|
|
717
|
-
maxHeight: 510,
|
|
718
|
-
padding: 10,
|
|
719
|
-
getScrollRef: noop,
|
|
720
|
-
scrollbarNeeded: true,
|
|
721
|
-
swipeable: false,
|
|
722
|
-
onSwipedDown: noop
|
|
723
|
-
};
|
|
724
|
-
|
|
725
|
-
export { Popover as default };
|