@zohodesk/components 1.2.4 → 1.2.5
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/README.md +4 -0
- package/coverage/Button/Button.js.html +1 -1
- package/coverage/Button/css/Button.module.css.html +1 -1
- package/coverage/Button/css/cssJSLogic.js.html +1 -1
- package/coverage/Button/css/index.html +1 -1
- package/coverage/Button/index.html +1 -1
- package/coverage/Button/props/defaultProps.js.html +1 -1
- package/coverage/Button/props/index.html +1 -1
- package/coverage/Button/props/propTypes.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.js.html +1 -1
- package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
- package/coverage/Buttongroup/index.html +1 -1
- package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
- package/coverage/Buttongroup/props/index.html +1 -1
- package/coverage/Buttongroup/props/propTypes.js.html +1 -1
- package/coverage/index.html +1 -1
- package/coverage/utils/dummyFunction.js.html +1 -1
- package/coverage/utils/index.html +1 -1
- package/es/v1/Accordion/Accordion.js +65 -0
- package/es/v1/Accordion/AccordionItem.js +57 -0
- package/es/v1/Accordion/index.js +2 -0
- package/es/v1/Animation/Animation.js +127 -0
- package/es/v1/AppContainer/AppContainer.js +134 -0
- package/es/v1/Avatar/Avatar.js +189 -0
- package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
- package/es/v1/Button/Button.js +68 -0
- package/es/v1/Buttongroup/Buttongroup.js +31 -0
- package/es/v1/Card/Card.js +271 -0
- package/es/v1/CheckBox/CheckBox.js +155 -0
- package/es/v1/DateTime/CalendarView.js +218 -0
- package/es/v1/DateTime/DateTime.js +783 -0
- package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
- package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
- package/es/v1/DateTime/DateWidget.js +1098 -0
- package/es/v1/DateTime/DaysRow.js +31 -0
- package/es/v1/DateTime/Time.js +166 -0
- package/es/v1/DateTime/YearView.js +264 -0
- package/es/v1/DateTime/index.js +1 -0
- package/es/v1/DropBox/DropBox.js +91 -0
- package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
- package/es/v1/DropDown/DropDown.js +73 -0
- package/es/v1/DropDown/DropDownHeading.js +44 -0
- package/es/v1/DropDown/DropDownItem.js +76 -0
- package/es/v1/DropDown/DropDownSearch.js +63 -0
- package/es/v1/DropDown/DropDownSeparator.js +15 -0
- package/es/v1/Heading/Heading.js +32 -0
- package/es/v1/Label/Label.js +40 -0
- package/es/v1/Layout/Box.js +115 -0
- package/es/v1/Layout/Container.js +132 -0
- package/es/v1/Layout/index.js +2 -0
- package/es/v1/ListItem/ListContainer.js +102 -0
- package/es/v1/ListItem/ListItem.js +124 -0
- package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
- package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
- package/es/v1/ListItem/ListItemWithIcon.js +127 -0
- package/es/v1/ListItem/ListItemWithRadio.js +105 -0
- package/es/v1/ListItem/index.js +6 -0
- package/es/v1/Modal/Modal.js +154 -0
- package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
- package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
- package/es/v1/MultiSelect/EmptyState.js +64 -0
- package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
- package/es/v1/MultiSelect/MultiSelect.js +1120 -0
- package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
- package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
- package/es/v1/MultiSelect/SelectedOptions.js +82 -0
- package/es/v1/MultiSelect/Suggestions.js +142 -0
- package/es/v1/MultiSelect/index.js +4 -0
- package/es/v1/PopOver/PopOver.js +211 -0
- package/es/v1/Popup/Popup.js +645 -0
- package/es/v1/Radio/Radio.js +115 -0
- package/es/v1/Responsive/CustomResponsive.js +195 -0
- package/es/v1/Responsive/RefWrapper.js +39 -0
- package/es/v1/Responsive/ResizeComponent.js +197 -0
- package/es/v1/Responsive/ResizeObserver.js +140 -0
- package/es/v1/Responsive/Responsive.js +194 -0
- package/es/v1/Responsive/index.js +9 -0
- package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
- package/es/v1/Ribbon/Ribbon.js +33 -0
- package/es/v1/RippleEffect/RippleEffect.js +24 -0
- package/es/v1/Select/GroupSelect.js +803 -0
- package/es/v1/Select/Select.js +969 -0
- package/es/v1/Select/SelectWithAvatar.js +344 -0
- package/es/v1/Select/SelectWithIcon.js +535 -0
- package/es/v1/Select/index.js +4 -0
- package/es/v1/Stencils/Stencils.js +26 -0
- package/es/v1/Switch/Switch.js +94 -0
- package/es/v1/Tab/Tab.js +108 -0
- package/es/v1/Tab/TabContent.js +30 -0
- package/es/v1/Tab/TabContentWrapper.js +29 -0
- package/es/v1/Tab/TabWrapper.js +57 -0
- package/es/v1/Tab/Tabs.js +612 -0
- package/es/v1/Tab/index.js +5 -0
- package/es/v1/Tag/Tag.js +134 -0
- package/es/v1/TextBox/TextBox.js +154 -0
- package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
- package/es/v1/Textarea/Textarea.js +102 -0
- package/es/v1/Tooltip/Tooltip.js +518 -0
- package/es/v1/Typography/Typography.js +38 -0
- package/es/v1/Typography/css/Typography.module.css +376 -0
- package/es/v1/Typography/css/cssJSLogic.js +46 -0
- package/es/v1/Typography/css/letterSpacingMap.js +12 -0
- package/es/v1/Typography/props/defaultProps.js +8 -0
- package/es/v1/Typography/props/propTypes.js +24 -0
- package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
- package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
- package/es/v1/semantic/Button/Button.js +53 -0
- package/es/v1/semantic/index.js +1 -0
- package/lib/v1/Accordion/Accordion.js +96 -0
- package/lib/v1/Accordion/AccordionItem.js +68 -0
- package/lib/v1/Accordion/index.js +23 -0
- package/lib/v1/Animation/Animation.js +143 -0
- package/lib/v1/AppContainer/AppContainer.js +204 -0
- package/lib/v1/Avatar/Avatar.js +246 -0
- package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
- package/lib/v1/Button/Button.js +82 -0
- package/lib/v1/Buttongroup/Buttongroup.js +44 -0
- package/lib/v1/Card/Card.js +365 -0
- package/lib/v1/CheckBox/CheckBox.js +166 -0
- package/lib/v1/DateTime/CalendarView.js +285 -0
- package/lib/v1/DateTime/DateTime.js +872 -0
- package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
- package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
- package/lib/v1/DateTime/DateWidget.js +1125 -0
- package/lib/v1/DateTime/DaysRow.js +80 -0
- package/lib/v1/DateTime/Time.js +254 -0
- package/lib/v1/DateTime/YearView.js +325 -0
- package/lib/v1/DateTime/index.js +15 -0
- package/lib/v1/DropBox/DropBox.js +119 -0
- package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
- package/lib/v1/DropDown/DropDown.js +170 -0
- package/lib/v1/DropDown/DropDownHeading.js +93 -0
- package/lib/v1/DropDown/DropDownItem.js +127 -0
- package/lib/v1/DropDown/DropDownSearch.js +113 -0
- package/lib/v1/DropDown/DropDownSeparator.js +64 -0
- package/lib/v1/Heading/Heading.js +49 -0
- package/lib/v1/Label/Label.js +51 -0
- package/lib/v1/Layout/Box.js +128 -0
- package/lib/v1/Layout/Container.js +145 -0
- package/lib/v1/Layout/index.js +23 -0
- package/lib/v1/ListItem/ListContainer.js +120 -0
- package/lib/v1/ListItem/ListItem.js +138 -0
- package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
- package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
- package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
- package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
- package/lib/v1/ListItem/index.js +55 -0
- package/lib/v1/Modal/Modal.js +212 -0
- package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
- package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
- package/lib/v1/MultiSelect/EmptyState.js +112 -0
- package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
- package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
- package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
- package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
- package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
- package/lib/v1/MultiSelect/Suggestions.js +195 -0
- package/lib/v1/MultiSelect/index.js +39 -0
- package/lib/v1/PopOver/PopOver.js +293 -0
- package/lib/v1/Popup/Popup.js +715 -0
- package/lib/v1/Radio/Radio.js +126 -0
- package/lib/v1/Responsive/CustomResponsive.js +242 -0
- package/lib/v1/Responsive/RefWrapper.js +57 -0
- package/lib/v1/Responsive/ResizeComponent.js +268 -0
- package/lib/v1/Responsive/ResizeObserver.js +168 -0
- package/lib/v1/Responsive/Responsive.js +274 -0
- package/lib/v1/Responsive/index.js +55 -0
- package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
- package/lib/v1/Ribbon/Ribbon.js +44 -0
- package/lib/v1/RippleEffect/RippleEffect.js +39 -0
- package/lib/v1/Select/GroupSelect.js +877 -0
- package/lib/v1/Select/Select.js +1013 -0
- package/lib/v1/Select/SelectWithAvatar.js +394 -0
- package/lib/v1/Select/SelectWithIcon.js +597 -0
- package/lib/v1/Select/index.js +39 -0
- package/lib/v1/Stencils/Stencils.js +43 -0
- package/lib/v1/Switch/Switch.js +108 -0
- package/lib/v1/Tab/Tab.js +132 -0
- package/lib/v1/Tab/TabContent.js +42 -0
- package/lib/v1/Tab/TabContentWrapper.js +42 -0
- package/lib/v1/Tab/TabWrapper.js +89 -0
- package/lib/v1/Tab/Tabs.js +680 -0
- package/lib/v1/Tab/index.js +47 -0
- package/lib/v1/Tag/Tag.js +154 -0
- package/lib/v1/TextBox/TextBox.js +168 -0
- package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
- package/lib/v1/Textarea/Textarea.js +118 -0
- package/lib/v1/Tooltip/Tooltip.js +586 -0
- package/lib/v1/Typography/Typography.js +56 -0
- package/lib/v1/Typography/css/Typography.module.css +376 -0
- package/lib/v1/Typography/css/cssJSLogic.js +41 -0
- package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
- package/lib/v1/Typography/props/defaultProps.js +15 -0
- package/lib/v1/Typography/props/propTypes.js +35 -0
- package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
- package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
- package/lib/v1/semantic/Button/Button.js +63 -0
- package/lib/v1/semantic/index.js +15 -0
- package/package.json +1 -1
- package/result.json +1 -1
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
15
|
+
|
|
16
|
+
var _Common = require("../../utils/Common.js");
|
|
17
|
+
|
|
18
|
+
var _viewPort = _interopRequireDefault(require("./viewPort"));
|
|
19
|
+
|
|
20
|
+
var _PositionMapping = require("../../Popup/PositionMapping.json");
|
|
21
|
+
|
|
22
|
+
var _ResizeObserver = _interopRequireDefault(require("@zohodesk/virtualizer/lib/commons/ResizeObserver.js"));
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
26
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
|
+
|
|
28
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
29
|
+
|
|
30
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
31
|
+
|
|
32
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
33
|
+
|
|
34
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
35
|
+
|
|
36
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
37
|
+
|
|
38
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
|
+
|
|
40
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
41
|
+
|
|
42
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
43
|
+
|
|
44
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
45
|
+
|
|
46
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
47
|
+
|
|
48
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
49
|
+
|
|
50
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
51
|
+
|
|
52
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
53
|
+
|
|
54
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
55
|
+
|
|
56
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
57
|
+
|
|
58
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
59
|
+
|
|
60
|
+
var lastOpenedGroup = [];
|
|
61
|
+
var popups = {};
|
|
62
|
+
|
|
63
|
+
global.closeGroupPopups = function (groupName) {
|
|
64
|
+
var groupPopups = popups[groupName] || [];
|
|
65
|
+
groupPopups.forEach(function (popup) {
|
|
66
|
+
popup.state.isPopupOpen && popup.setState({
|
|
67
|
+
isPopupOpen: false,
|
|
68
|
+
isPopupReady: false
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
var defaultState = {
|
|
74
|
+
position: 'bottomCenter',
|
|
75
|
+
height: '0px',
|
|
76
|
+
positions: {},
|
|
77
|
+
//{bottomCenter: true, bottomLeft: false, ...}
|
|
78
|
+
positionsOffset: {},
|
|
79
|
+
//{bottomCenter: {left: ‘’,top: ‘’ }, .....}
|
|
80
|
+
targetOffset: {},
|
|
81
|
+
//{height: ‘’, width: ‘’,}
|
|
82
|
+
popupOffset: {},
|
|
83
|
+
//{height: ‘’, width: ‘’,}
|
|
84
|
+
isAbsolutePositioningNeeded: true
|
|
85
|
+
};
|
|
86
|
+
/* eslint-disable react/no-deprecated */
|
|
87
|
+
|
|
88
|
+
/* eslint-disable react/prop-types */
|
|
89
|
+
|
|
90
|
+
var Popup = function Popup(Component) {
|
|
91
|
+
var group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'global';
|
|
92
|
+
var needResizeHandling = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
93
|
+
|
|
94
|
+
var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
|
|
95
|
+
_ref$isAbsolutePositi = _ref.isAbsolutePositioningNeeded,
|
|
96
|
+
isAbsolutePopup = _ref$isAbsolutePositi === void 0 ? true : _ref$isAbsolutePositi,
|
|
97
|
+
_ref$isArrow = _ref.isArrow,
|
|
98
|
+
needPopupArrow = _ref$isArrow === void 0 ? false : _ref$isArrow,
|
|
99
|
+
_ref$customOrder = _ref.customOrder,
|
|
100
|
+
customPositionOrder = _ref$customOrder === void 0 ? [] : _ref$customOrder,
|
|
101
|
+
_ref$scrollDebounceTi = _ref.scrollDebounceTime,
|
|
102
|
+
popupScrollDebounceTime = _ref$scrollDebounceTi === void 0 ? 0 : _ref$scrollDebounceTi,
|
|
103
|
+
_ref$closeOnScroll = _ref.closeOnScroll,
|
|
104
|
+
closeOnScrollPopup = _ref$closeOnScroll === void 0 ? false : _ref$closeOnScroll;
|
|
105
|
+
|
|
106
|
+
var Popup = /*#__PURE__*/function (_React$Component) {
|
|
107
|
+
_inherits(Popup, _React$Component);
|
|
108
|
+
|
|
109
|
+
var _super = _createSuper(Popup);
|
|
110
|
+
|
|
111
|
+
function Popup(props) {
|
|
112
|
+
var _this;
|
|
113
|
+
|
|
114
|
+
_classCallCheck(this, Popup);
|
|
115
|
+
|
|
116
|
+
_this = _super.call(this, props);
|
|
117
|
+
_this.state = {
|
|
118
|
+
isPopupOpen: props.isPopupOpen || false,
|
|
119
|
+
position: 'bottomCenter',
|
|
120
|
+
height: '0px',
|
|
121
|
+
isPopupReady: props.isPopupOpen || false,
|
|
122
|
+
positions: {},
|
|
123
|
+
//{bottomCenter: true, bottomLeft: false, ...}
|
|
124
|
+
positionsOffset: {},
|
|
125
|
+
//{bottomCenter: {left: ‘’,top: ‘’ }, .....}
|
|
126
|
+
targetOffset: {},
|
|
127
|
+
//{height: ‘’, width: ‘’,}
|
|
128
|
+
popupOffset: {},
|
|
129
|
+
//{height: ‘’, width: ‘’,}
|
|
130
|
+
isAbsolutePositioningNeeded: true
|
|
131
|
+
};
|
|
132
|
+
_this.togglePopup = _this.togglePopup.bind(_assertThisInitialized(_this));
|
|
133
|
+
_this.documentClickHandler = _this.documentClickHandler.bind(_assertThisInitialized(_this));
|
|
134
|
+
_this.documentClickHandler1 = _this.documentClickHandler1.bind(_assertThisInitialized(_this));
|
|
135
|
+
_this.removeClose = _this.removeClose.bind(_assertThisInitialized(_this));
|
|
136
|
+
_this.documentKeyupHandler = _this.documentKeyupHandler.bind(_assertThisInitialized(_this));
|
|
137
|
+
_this.openPopupOnly = _this.openPopupOnly.bind(_assertThisInitialized(_this));
|
|
138
|
+
_this.closePopupOnly = _this.closePopupOnly.bind(_assertThisInitialized(_this));
|
|
139
|
+
_this.getTargetRef = _this.getTargetRef.bind(_assertThisInitialized(_this));
|
|
140
|
+
_this.getContainerRef = _this.getContainerRef.bind(_assertThisInitialized(_this));
|
|
141
|
+
_this.handlePopupPosition = _this.handlePopupPosition.bind(_assertThisInitialized(_this));
|
|
142
|
+
_this.handleResize = (0, _Common.debounce)(_this.handleResize.bind(_assertThisInitialized(_this)), 300);
|
|
143
|
+
_this.handlePopupResize = _this.handlePopupResize.bind(_assertThisInitialized(_this));
|
|
144
|
+
_this.getIsAbsolutePopup = _this.getIsAbsolutePopup.bind(_assertThisInitialized(_this));
|
|
145
|
+
_this.getNeedArrow = _this.getNeedArrow.bind(_assertThisInitialized(_this));
|
|
146
|
+
_this.getCustomPositionOrder = _this.getCustomPositionOrder.bind(_assertThisInitialized(_this));
|
|
147
|
+
_this.handleOpenPopupPositionChange = _this.handleOpenPopupPositionChange.bind(_assertThisInitialized(_this));
|
|
148
|
+
_this.getScrollDebounceTime = _this.getScrollDebounceTime.bind(_assertThisInitialized(_this));
|
|
149
|
+
_this.getCloseOnScrollPopup = _this.getCloseOnScrollPopup.bind(_assertThisInitialized(_this));
|
|
150
|
+
_this.handleCloseLastOpenedGroup = _this.handleCloseLastOpenedGroup.bind(_assertThisInitialized(_this));
|
|
151
|
+
_this.handleDocumentMouseDown = _this.handleDocumentMouseDown.bind(_assertThisInitialized(_this));
|
|
152
|
+
_this.handleDocumentFocus = _this.handleDocumentFocus.bind(_assertThisInitialized(_this));
|
|
153
|
+
_this.handleGetNeedPrevent = _this.handleGetNeedPrevent.bind(_assertThisInitialized(_this));
|
|
154
|
+
_this.popupObserver = new _ResizeObserver["default"](_this.handlePopupResize); //dropBoxSize
|
|
155
|
+
|
|
156
|
+
_this.size = null;
|
|
157
|
+
_this.isAbsolutePopup = isAbsolutePopup;
|
|
158
|
+
_this.needPopupArrow = needPopupArrow;
|
|
159
|
+
_this.customPositionOrder = customPositionOrder;
|
|
160
|
+
_this.scrollDebounceTime = popupScrollDebounceTime;
|
|
161
|
+
_this.closeOnScroll = closeOnScrollPopup;
|
|
162
|
+
|
|
163
|
+
var _this$getScrollDeboun = _this.getScrollDebounceTime(_assertThisInitialized(_this)),
|
|
164
|
+
scrollDebounceTime = _this$getScrollDeboun.scrollDebounceTime;
|
|
165
|
+
|
|
166
|
+
_this.handleScroll = (0, _Common.debounce)(_this.handleScroll.bind(_assertThisInitialized(_this)), scrollDebounceTime);
|
|
167
|
+
return _this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
_createClass(Popup, [{
|
|
171
|
+
key: "componentDidMount",
|
|
172
|
+
value: function componentDidMount() {
|
|
173
|
+
var group = this.getGroup();
|
|
174
|
+
var groupPopups = popups[group] || [];
|
|
175
|
+
groupPopups.push(this);
|
|
176
|
+
popups[group] = groupPopups;
|
|
177
|
+
|
|
178
|
+
if (Object.keys(popups).length === 1 && groupPopups.length === 1) {
|
|
179
|
+
document.addEventListener('click', this.documentClickHandler, false);
|
|
180
|
+
document.addEventListener('keyup', this.documentKeyupHandler, false); // document.addEventListener('scroll', this.handleScroll, true);
|
|
181
|
+
|
|
182
|
+
window.addEventListener('resize', this.handleResize);
|
|
183
|
+
document.addEventListener('click', this.documentClickHandler1, true);
|
|
184
|
+
document.addEventListener('mousedown', this.handleDocumentMouseDown, true);
|
|
185
|
+
document.addEventListener('focus', this.handleDocumentFocus, true);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "componentWillReceiveProps",
|
|
190
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
191
|
+
var isPopupOpen = this.state.isPopupOpen;
|
|
192
|
+
|
|
193
|
+
if (typeof nextProps.isPopupOpen !== 'undefined' && nextProps.isPopupOpen !== isPopupOpen) {
|
|
194
|
+
this.setState({
|
|
195
|
+
isPopupOpen: nextProps.isPopupOpen,
|
|
196
|
+
isPopupReady: nextProps.isPopupOpen
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}, {
|
|
201
|
+
key: "componentDidUpdate",
|
|
202
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
203
|
+
var isPopupReady = this.state.isPopupReady;
|
|
204
|
+
|
|
205
|
+
var _ref2 = prevState || {},
|
|
206
|
+
_ref2$isPopupReady = _ref2.isPopupReady,
|
|
207
|
+
oldStateOpen = _ref2$isPopupReady === void 0 ? false : _ref2$isPopupReady;
|
|
208
|
+
|
|
209
|
+
var dropElement = this.dropElement;
|
|
210
|
+
var propResizeHandling = this.props.needResizeHandling;
|
|
211
|
+
|
|
212
|
+
if (oldStateOpen !== isPopupReady) {
|
|
213
|
+
if (isPopupReady && dropElement && (propResizeHandling !== undefined ? propResizeHandling : needResizeHandling)) {
|
|
214
|
+
this.popupObserver.replaceObservationElement(dropElement);
|
|
215
|
+
} else if (!isPopupReady) {
|
|
216
|
+
this.size = null;
|
|
217
|
+
this.popupObserver.disconnect();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "componentWillUnmount",
|
|
223
|
+
value: function componentWillUnmount() {
|
|
224
|
+
var _this2 = this;
|
|
225
|
+
|
|
226
|
+
var group = this.getGroup();
|
|
227
|
+
popups = Object.keys(popups).reduce(function (res, groupName) {
|
|
228
|
+
if (groupName === group) {
|
|
229
|
+
var groupPopups = popups[group];
|
|
230
|
+
var newGroupPopups = groupPopups.filter(function (popup) {
|
|
231
|
+
return popup !== _this2;
|
|
232
|
+
});
|
|
233
|
+
newGroupPopups.length === 0 && lastOpenedGroup.indexOf(group) >= 0 && lastOpenedGroup.splice(lastOpenedGroup.indexOf(group), 1);
|
|
234
|
+
res[group] = newGroupPopups;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return res;
|
|
238
|
+
}, popups);
|
|
239
|
+
var noPopups = true;
|
|
240
|
+
|
|
241
|
+
for (var i in popups) {
|
|
242
|
+
if (popups[i].length >= 1) {
|
|
243
|
+
noPopups = false;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (this.popupObserver) {
|
|
249
|
+
this.popupObserver.disconnect();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (noPopups) {
|
|
253
|
+
document.removeEventListener('click', this.documentClickHandler);
|
|
254
|
+
document.removeEventListener('keyup', this.documentKeyupHandler); // document.removeEventListener('scroll', this.handleScroll);
|
|
255
|
+
|
|
256
|
+
window.removeEventListener('resize', this.handleResize);
|
|
257
|
+
document.removeEventListener('click', this.documentClickHandler1, true);
|
|
258
|
+
document.removeEventListener('mousedown', this.handleDocumentMouseDown, true);
|
|
259
|
+
document.removeEventListener('focus', this.handleDocumentFocus, true);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "getGroup",
|
|
264
|
+
value: function getGroup() {
|
|
265
|
+
var popupGroup = this.props.popupGroup;
|
|
266
|
+
return popupGroup || group;
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "getNeedArrow",
|
|
270
|
+
value: function getNeedArrow(popup) {
|
|
271
|
+
var isArrow = popup.props.isArrow;
|
|
272
|
+
var needPopupArrow = popup.needPopupArrow;
|
|
273
|
+
return isArrow !== undefined ? isArrow : needPopupArrow;
|
|
274
|
+
}
|
|
275
|
+
}, {
|
|
276
|
+
key: "getScrollDebounceTime",
|
|
277
|
+
value: function getScrollDebounceTime(popup) {
|
|
278
|
+
var scrollDebounceTime = popup.props.scrollDebounceTime;
|
|
279
|
+
var popupScrollDebounceTime = popup.scrollDebounceTime;
|
|
280
|
+
return scrollDebounceTime !== undefined ? scrollDebounceTime : popupScrollDebounceTime;
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "getCloseOnScrollPopup",
|
|
284
|
+
value: function getCloseOnScrollPopup(popup) {
|
|
285
|
+
var closeOnScroll = popup.props.closeOnScroll;
|
|
286
|
+
var closeOnScrollPopup = popup.closeOnScroll;
|
|
287
|
+
return closeOnScroll !== undefined ? closeOnScroll : closeOnScrollPopup;
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
key: "getIsAbsolutePopup",
|
|
291
|
+
value: function getIsAbsolutePopup(popup) {
|
|
292
|
+
var isAbsolutePositioningNeeded = popup.props.isAbsolutePositioningNeeded;
|
|
293
|
+
var isAbsolutePopup = popup.isAbsolutePopup;
|
|
294
|
+
return isAbsolutePositioningNeeded !== undefined ? isAbsolutePositioningNeeded : isAbsolutePopup;
|
|
295
|
+
}
|
|
296
|
+
}, {
|
|
297
|
+
key: "getCustomPositionOrder",
|
|
298
|
+
value: function getCustomPositionOrder(popup) {
|
|
299
|
+
var _popup$props$customOr = popup.props.customOrder,
|
|
300
|
+
customOrder = _popup$props$customOr === void 0 ? [] : _popup$props$customOr;
|
|
301
|
+
var customPositionOrder = popup.customPositionOrder;
|
|
302
|
+
return customOrder.length !== 0 ? customOrder : customPositionOrder;
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "togglePopup",
|
|
306
|
+
value: function togglePopup(e, defaultPosition) {
|
|
307
|
+
var _this3 = this;
|
|
308
|
+
|
|
309
|
+
var group = this.getGroup();
|
|
310
|
+
this.removeClose(e);
|
|
311
|
+
var isPopupOpen = this.state.isPopupOpen;
|
|
312
|
+
var groupPopups = popups[group] || [];
|
|
313
|
+
lastOpenedGroup = !isPopupOpen && lastOpenedGroup.indexOf(group) === -1 ? [group].concat(_toConsumableArray(lastOpenedGroup)) : lastOpenedGroup;
|
|
314
|
+
isPopupOpen && lastOpenedGroup.splice(0, 1);
|
|
315
|
+
groupPopups.forEach(function (popup) {
|
|
316
|
+
if (popup !== _this3 && popup.state.isPopupOpen) {
|
|
317
|
+
popup.setState({
|
|
318
|
+
isPopupOpen: false,
|
|
319
|
+
isPopupReady: false
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
if (isPopupOpen) {
|
|
325
|
+
this.setState({
|
|
326
|
+
isPopupOpen: false,
|
|
327
|
+
isPopupReady: false
|
|
328
|
+
});
|
|
329
|
+
} else {
|
|
330
|
+
this.handlePopupPosition(defaultPosition);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}, {
|
|
334
|
+
key: "openPopupOnly",
|
|
335
|
+
value: function openPopupOnly(e, defaultPosition) {
|
|
336
|
+
var group = this.getGroup();
|
|
337
|
+
this.removeClose(e);
|
|
338
|
+
lastOpenedGroup = lastOpenedGroup.indexOf(group) === -1 ? [group].concat(_toConsumableArray(lastOpenedGroup)) : lastOpenedGroup;
|
|
339
|
+
this.handlePopupPosition(defaultPosition);
|
|
340
|
+
}
|
|
341
|
+
}, {
|
|
342
|
+
key: "closePopupOnly",
|
|
343
|
+
value: function closePopupOnly(e) {
|
|
344
|
+
this.removeClose(e);
|
|
345
|
+
lastOpenedGroup.splice(0, 1);
|
|
346
|
+
var isPopupOpen = this.state.isPopupOpen;
|
|
347
|
+
|
|
348
|
+
if (isPopupOpen) {
|
|
349
|
+
this.setState({
|
|
350
|
+
isPopupOpen: false,
|
|
351
|
+
isPopupReady: false
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}, {
|
|
356
|
+
key: "handleCloseLastOpenedGroup",
|
|
357
|
+
value: function handleCloseLastOpenedGroup() {
|
|
358
|
+
var groupPopups = lastOpenedGroup.length ? popups[lastOpenedGroup[0]] || [] : [];
|
|
359
|
+
lastOpenedGroup.splice(0, 1);
|
|
360
|
+
groupPopups.forEach(function (popup) {
|
|
361
|
+
popup.state.isPopupOpen && popup.setState({
|
|
362
|
+
isPopupOpen: false,
|
|
363
|
+
isPopupReady: false
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}, {
|
|
368
|
+
key: "handleDocumentMouseDown",
|
|
369
|
+
value: function handleDocumentMouseDown(e) {
|
|
370
|
+
var needPrevent = this.handleGetNeedPrevent(e);
|
|
371
|
+
|
|
372
|
+
if (needPrevent) {
|
|
373
|
+
this.removeClose(e);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}, {
|
|
377
|
+
key: "handleDocumentFocus",
|
|
378
|
+
value: function handleDocumentFocus(e) {
|
|
379
|
+
var needPrevent = this.handleGetNeedPrevent(e);
|
|
380
|
+
|
|
381
|
+
if (needPrevent) {
|
|
382
|
+
this.removeClose(e);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}, {
|
|
386
|
+
key: "handleGetNeedPrevent",
|
|
387
|
+
value: function handleGetNeedPrevent(e) {
|
|
388
|
+
var needPrevent = false;
|
|
389
|
+
|
|
390
|
+
if (lastOpenedGroup.length > 1) {
|
|
391
|
+
var target = e.target;
|
|
392
|
+
var groupPopups = lastOpenedGroup.length ? popups[lastOpenedGroup[0]] : [];
|
|
393
|
+
var openedPopup = null; // eslint-disable-next-line guard-for-in
|
|
394
|
+
|
|
395
|
+
for (var i in groupPopups) {
|
|
396
|
+
var isPopupOpen = groupPopups[i].state.isPopupOpen;
|
|
397
|
+
|
|
398
|
+
if (isPopupOpen) {
|
|
399
|
+
openedPopup = groupPopups[i];
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
if (openedPopup) {
|
|
405
|
+
var _openedPopup = openedPopup,
|
|
406
|
+
dropElement = _openedPopup.dropElement,
|
|
407
|
+
placeHolderElement = _openedPopup.placeHolderElement;
|
|
408
|
+
var isDropBoxChild = (0, _Common.isDescendant)(dropElement, target);
|
|
409
|
+
var isTargetChild = (0, _Common.isDescendant)(placeHolderElement, target); // const isPopupMassUpdateChild = isDescendant(
|
|
410
|
+
// massUpdateParent,
|
|
411
|
+
// dropElement
|
|
412
|
+
// );
|
|
413
|
+
|
|
414
|
+
if (!isDropBoxChild && !isTargetChild // && isPopupMassUpdateChild
|
|
415
|
+
) {
|
|
416
|
+
needPrevent = true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
return needPrevent;
|
|
422
|
+
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "documentClickHandler1",
|
|
425
|
+
value: function documentClickHandler1(e) {
|
|
426
|
+
var needPrevent = this.handleGetNeedPrevent(e);
|
|
427
|
+
|
|
428
|
+
if (needPrevent) {
|
|
429
|
+
this.removeClose(e);
|
|
430
|
+
this.handleCloseLastOpenedGroup();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}, {
|
|
434
|
+
key: "documentClickHandler",
|
|
435
|
+
value: function documentClickHandler() {
|
|
436
|
+
try {
|
|
437
|
+
Object.keys(popups).forEach(function (groupName) {
|
|
438
|
+
var groupPopups = popups[groupName] || [];
|
|
439
|
+
groupPopups.forEach(function (popup) {
|
|
440
|
+
popup.state.isPopupOpen && (!popup.props.checkBeforeClose || popup.props.checkBeforeClose && popup.props.checkBeforeClose()) && !(0, _Common.isTextSelected)() && popup.setState({
|
|
441
|
+
isPopupOpen: false,
|
|
442
|
+
isPopupReady: false
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
lastOpenedGroup = [];
|
|
447
|
+
} catch (e) {// eslint-disable-next-line no-console
|
|
448
|
+
//console.error('popup component not unmounted properly', e);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
key: "documentKeyupHandler",
|
|
453
|
+
value: function documentKeyupHandler(e) {
|
|
454
|
+
try {
|
|
455
|
+
if (e.keyCode === 27) {
|
|
456
|
+
this.handleCloseLastOpenedGroup();
|
|
457
|
+
}
|
|
458
|
+
} catch (e) {// eslint-disable-next-line no-console
|
|
459
|
+
//console.log('error', e);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}, {
|
|
463
|
+
key: "removeClose",
|
|
464
|
+
value: function removeClose(e) {
|
|
465
|
+
// e && e.preventDefault && e.preventDefault();
|
|
466
|
+
(0, _Common.cancelBubblingEffect)(e);
|
|
467
|
+
}
|
|
468
|
+
}, {
|
|
469
|
+
key: "handlePopupPosition",
|
|
470
|
+
value: function handlePopupPosition() {
|
|
471
|
+
var _this4 = this;
|
|
472
|
+
|
|
473
|
+
var defaultPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bottomCenter';
|
|
474
|
+
var isResizeHandling = arguments.length > 1 ? arguments[1] : undefined;
|
|
475
|
+
|
|
476
|
+
// isResizeHandling --->>> Window resize and dropBox resize
|
|
477
|
+
var _ref3 = this.context || {},
|
|
478
|
+
direction = _ref3.direction;
|
|
479
|
+
|
|
480
|
+
var placeHolderElement = this.placeHolderElement,
|
|
481
|
+
dropElement = this.dropElement;
|
|
482
|
+
var needArrow = this.getNeedArrow(this);
|
|
483
|
+
var isAbsolute = this.getIsAbsolutePopup(this);
|
|
484
|
+
var customOrder = this.getCustomPositionOrder(this);
|
|
485
|
+
|
|
486
|
+
if (direction === 'rtl') {
|
|
487
|
+
defaultPosition = isAbsolute ? _PositionMapping.rtlAbsolutePositionMapping[defaultPosition] : _PositionMapping.rtlFixedPositionMapping[defaultPosition];
|
|
488
|
+
} else {
|
|
489
|
+
defaultPosition = isAbsolute ? _PositionMapping.absolutePositionMapping[defaultPosition] : defaultPosition;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (!placeHolderElement && !dropElement) {
|
|
493
|
+
this.setState({
|
|
494
|
+
isPopupOpen: true,
|
|
495
|
+
isPopupReady: true
|
|
496
|
+
});
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
var setPosition = function setPosition() {
|
|
501
|
+
requestAnimationFrame(function () {
|
|
502
|
+
var placeHolderElement = _this4.placeHolderElement,
|
|
503
|
+
dropElement = _this4.dropElement;
|
|
504
|
+
var _this4$state = _this4.state,
|
|
505
|
+
position = _this4$state.position,
|
|
506
|
+
isPopupReady = _this4$state.isPopupReady;
|
|
507
|
+
var scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
|
|
508
|
+
|
|
509
|
+
var betterPosition = _viewPort["default"].betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
|
|
510
|
+
needArrow: needArrow,
|
|
511
|
+
isAbsolute: isAbsolute,
|
|
512
|
+
customOrder: customOrder
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
var _ref4 = betterPosition || {},
|
|
516
|
+
view = _ref4.view,
|
|
517
|
+
views = _ref4.views,
|
|
518
|
+
viewsOffset = _ref4.viewsOffset,
|
|
519
|
+
targetOffset = _ref4.targetOffset,
|
|
520
|
+
popupOffset = _ref4.popupOffset;
|
|
521
|
+
|
|
522
|
+
if (position !== view || !isPopupReady) {
|
|
523
|
+
_this4.setState({
|
|
524
|
+
isPopupReady: true,
|
|
525
|
+
position: view,
|
|
526
|
+
positions: views,
|
|
527
|
+
positionsOffset: viewsOffset,
|
|
528
|
+
targetOffset: targetOffset,
|
|
529
|
+
popupOffset: popupOffset,
|
|
530
|
+
isAbsolutePositioningNeeded: isAbsolute
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
if (isResizeHandling) {
|
|
537
|
+
setPosition();
|
|
538
|
+
} else {
|
|
539
|
+
this.defaultPosition = defaultPosition;
|
|
540
|
+
this.setState({
|
|
541
|
+
isPopupOpen: true,
|
|
542
|
+
isPopupReady: false
|
|
543
|
+
}, setPosition);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}, {
|
|
547
|
+
key: "handleOpenPopupPositionChange",
|
|
548
|
+
value: function handleOpenPopupPositionChange() {
|
|
549
|
+
var _this5 = this;
|
|
550
|
+
|
|
551
|
+
Object.keys(popups).forEach(function (groupName) {
|
|
552
|
+
var groupPopups = popups[groupName] || [];
|
|
553
|
+
groupPopups.forEach(function (popup) {
|
|
554
|
+
if (popup.state.isPopupOpen) {
|
|
555
|
+
var placeHolderElement = popup.placeHolderElement,
|
|
556
|
+
dropElement = popup.dropElement,
|
|
557
|
+
defaultPosition = popup.defaultPosition;
|
|
558
|
+
var _popup$state = popup.state,
|
|
559
|
+
position = _popup$state.position,
|
|
560
|
+
_popup$state$position = _popup$state.positionsOffset,
|
|
561
|
+
positionsOffset = _popup$state$position === void 0 ? {} : _popup$state$position;
|
|
562
|
+
|
|
563
|
+
if (placeHolderElement && dropElement) {
|
|
564
|
+
var scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
|
|
565
|
+
requestAnimationFrame(function () {
|
|
566
|
+
var needArrow = _this5.getNeedArrow(popup);
|
|
567
|
+
|
|
568
|
+
var isAbsolute = _this5.getIsAbsolutePopup(popup);
|
|
569
|
+
|
|
570
|
+
var customOrder = _this5.getCustomPositionOrder(popup);
|
|
571
|
+
|
|
572
|
+
var betterPosition = _viewPort["default"].betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
|
|
573
|
+
needArrow: needArrow,
|
|
574
|
+
isAbsolute: isAbsolute,
|
|
575
|
+
customOrder: customOrder
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
var _ref5 = betterPosition || {},
|
|
579
|
+
view = _ref5.view,
|
|
580
|
+
views = _ref5.views,
|
|
581
|
+
_ref5$viewsOffset = _ref5.viewsOffset,
|
|
582
|
+
viewsOffset = _ref5$viewsOffset === void 0 ? {} : _ref5$viewsOffset,
|
|
583
|
+
targetOffset = _ref5.targetOffset,
|
|
584
|
+
popupOffset = _ref5.popupOffset;
|
|
585
|
+
|
|
586
|
+
var _ref6 = positionsOffset[position] || {},
|
|
587
|
+
_ref6$left = _ref6.left,
|
|
588
|
+
oldLeft = _ref6$left === void 0 ? '' : _ref6$left,
|
|
589
|
+
_ref6$top = _ref6.top,
|
|
590
|
+
oldTop = _ref6$top === void 0 ? '' : _ref6$top;
|
|
591
|
+
|
|
592
|
+
var _ref7 = viewsOffset[view] || {},
|
|
593
|
+
_ref7$left = _ref7.left,
|
|
594
|
+
left = _ref7$left === void 0 ? '' : _ref7$left,
|
|
595
|
+
_ref7$top = _ref7.top,
|
|
596
|
+
top = _ref7$top === void 0 ? '' : _ref7$top;
|
|
597
|
+
|
|
598
|
+
var changeState = isAbsolute ? position !== view : oldLeft !== left || oldTop !== top; // let isInViewPort = viewPort.isInViewPort(
|
|
599
|
+
// placeHolderElement,
|
|
600
|
+
// scrollContainer
|
|
601
|
+
// );
|
|
602
|
+
|
|
603
|
+
if (changeState) {
|
|
604
|
+
popup.setState({
|
|
605
|
+
position: view,
|
|
606
|
+
positions: views,
|
|
607
|
+
positionsOffset: viewsOffset,
|
|
608
|
+
targetOffset: targetOffset,
|
|
609
|
+
popupOffset: popupOffset,
|
|
610
|
+
isAbsolutePositioningNeeded: isAbsolute
|
|
611
|
+
});
|
|
612
|
+
} // if (!isInViewPort && !isAbsolute) {
|
|
613
|
+
// popup.setState({ isPopupOpen: false, isPopupReady: false });
|
|
614
|
+
// } else if (view && changeState) {
|
|
615
|
+
// popup.setState({
|
|
616
|
+
// position: view,
|
|
617
|
+
// positions: views,
|
|
618
|
+
// positionsOffset: viewsOffset,
|
|
619
|
+
// targetOffset,
|
|
620
|
+
// popupOffset,
|
|
621
|
+
// isAbsolutePositioningNeeded: isAbsolute
|
|
622
|
+
// });
|
|
623
|
+
// }
|
|
624
|
+
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}, {
|
|
632
|
+
key: "handleResize",
|
|
633
|
+
value: function handleResize() {
|
|
634
|
+
this.handleOpenPopupPositionChange();
|
|
635
|
+
}
|
|
636
|
+
}, {
|
|
637
|
+
key: "handleScroll",
|
|
638
|
+
value: function handleScroll(e) {
|
|
639
|
+
// this.handleOpenPopupPositionChange();
|
|
640
|
+
var _this$getCloseOnScrol = this.getCloseOnScrollPopup(this),
|
|
641
|
+
closeOnScroll = _this$getCloseOnScrol.closeOnScroll;
|
|
642
|
+
|
|
643
|
+
var isPopupReady = this.state.isPopupReady;
|
|
644
|
+
|
|
645
|
+
if (isPopupReady) {
|
|
646
|
+
console.log('onscrollPopupREady');
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (isPopupReady && closeOnScroll) {
|
|
650
|
+
console.log(this, 'handle Scroll');
|
|
651
|
+
this.togglePopup(e);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}, {
|
|
655
|
+
key: "handlePopupResize",
|
|
656
|
+
value: function handlePopupResize(popupSize) {
|
|
657
|
+
var height = popupSize.height,
|
|
658
|
+
width = popupSize.width;
|
|
659
|
+
|
|
660
|
+
var _ref8 = this.size || {},
|
|
661
|
+
_ref8$height = _ref8.height,
|
|
662
|
+
oldHeight = _ref8$height === void 0 ? 0 : _ref8$height,
|
|
663
|
+
_ref8$width = _ref8.width,
|
|
664
|
+
oldWidth = _ref8$width === void 0 ? 0 : _ref8$width;
|
|
665
|
+
|
|
666
|
+
var _this$state = this.state,
|
|
667
|
+
isPopupReady = _this$state.isPopupReady,
|
|
668
|
+
position = _this$state.position;
|
|
669
|
+
|
|
670
|
+
if (isPopupReady && this.size && (oldHeight !== height || width !== oldWidth)) {
|
|
671
|
+
this.handlePopupPosition(position, true);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
this.size = popupSize;
|
|
675
|
+
}
|
|
676
|
+
}, {
|
|
677
|
+
key: "getTargetRef",
|
|
678
|
+
value: function getTargetRef(el) {
|
|
679
|
+
this.placeHolderElement = el;
|
|
680
|
+
}
|
|
681
|
+
}, {
|
|
682
|
+
key: "getContainerRef",
|
|
683
|
+
value: function getContainerRef(el) {
|
|
684
|
+
this.dropElement = el;
|
|
685
|
+
}
|
|
686
|
+
}, {
|
|
687
|
+
key: "render",
|
|
688
|
+
value: function render() {
|
|
689
|
+
var _this$state2 = this.state,
|
|
690
|
+
isPopupReady = _this$state2.isPopupReady,
|
|
691
|
+
isPopupOpen = _this$state2.isPopupOpen;
|
|
692
|
+
var localState = isPopupReady ? this.state : {};
|
|
693
|
+
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, this.props, this.state, {
|
|
694
|
+
openPopupOnly: this.openPopupOnly,
|
|
695
|
+
closePopupOnly: this.closePopupOnly,
|
|
696
|
+
togglePopup: this.togglePopup,
|
|
697
|
+
removeClose: this.removeClose,
|
|
698
|
+
getTargetRef: this.getTargetRef,
|
|
699
|
+
getContainerRef: this.getContainerRef
|
|
700
|
+
}));
|
|
701
|
+
}
|
|
702
|
+
}]);
|
|
703
|
+
|
|
704
|
+
return Popup;
|
|
705
|
+
}(_react["default"].Component);
|
|
706
|
+
|
|
707
|
+
Popup.displayName = Component.displayName || Component.name || Popup.name;
|
|
708
|
+
Popup.contextTypes = {
|
|
709
|
+
direction: _propTypes["default"].string
|
|
710
|
+
};
|
|
711
|
+
return (0, _hoistNonReactStatics["default"])(Popup, Component);
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
var _default = Popup;
|
|
715
|
+
exports["default"] = _default;
|