@zohodesk/components 1.0.0-temp-220.5 → 1.0.0-temp-220.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/Popup/Popup.js CHANGED
@@ -12,6 +12,7 @@ import { addIntersectionObserver, removeIntersectionObserver } from "./intersect
12
12
  import { positionMapping } from "../DropBox/DropBoxPositionMapping.js";
13
13
  import isMobilePopover from "../DropBox/utils/isMobilePopover.js";
14
14
  import selectn from 'selectn';
15
+ import { getLibraryConfig } from "../Provider/Config.js";
15
16
  let lastOpenedGroup = [];
16
17
  let popups = {};
17
18
 
@@ -38,6 +39,51 @@ const defaultState = {
38
39
  //{height: ‘’, width: ‘’,}
39
40
  isAbsolutePositioningNeeded: true
40
41
  };
42
+ const SCROLL_BLOCK_EVENTS = Object.freeze([{
43
+ name: 'wheel',
44
+ handlerName: 'handleBlockScroll',
45
+ options: {
46
+ capture: true,
47
+ passive: false
48
+ }
49
+ }, {
50
+ name: 'touchmove',
51
+ handlerName: 'handleBlockScroll',
52
+ options: {
53
+ capture: true,
54
+ passive: false
55
+ }
56
+ }, {
57
+ name: 'scroll',
58
+ handlerName: 'handlePositionChange',
59
+ options: {
60
+ capture: true,
61
+ passive: false
62
+ }
63
+ }, {
64
+ name: 'keydown',
65
+ handlerName: 'preventKeyboardScroll',
66
+ options: {
67
+ capture: true,
68
+ passive: false
69
+ }
70
+ }]);
71
+ const IFRAME_SCROLL_BLOCK_EVENTS = Object.freeze(SCROLL_BLOCK_EVENTS.filter(event => event.name !== 'keydown'));
72
+ const CLICK_EVENTS = Object.freeze([{
73
+ name: 'click',
74
+ handlerName: 'documentClickHandler',
75
+ options: {
76
+ capture: false,
77
+ passive: false
78
+ }
79
+ }, {
80
+ name: 'click',
81
+ handlerName: 'documentClickHandler1',
82
+ options: {
83
+ capture: true,
84
+ passive: false
85
+ }
86
+ }]);
41
87
  /* eslint-disable react/no-deprecated */
42
88
 
43
89
  /* eslint-disable react/prop-types */
@@ -74,9 +120,8 @@ const Popup = function (Component) {
74
120
  isMobile: false
75
121
  };
76
122
  this.togglePopup = this.togglePopup.bind(this);
77
- this.closePopups = this.closePopups.bind(this);
78
- this.handleDocumentInteraction = this.handleDocumentInteraction.bind(this);
79
123
  this.documentClickHandler = this.documentClickHandler.bind(this);
124
+ this.documentClickHandler1 = this.documentClickHandler1.bind(this);
80
125
  this.removeClose = this.removeClose.bind(this);
81
126
  this.documentKeyupHandler = this.documentKeyupHandler.bind(this);
82
127
  this.openPopupOnly = this.openPopupOnly.bind(this);
@@ -100,6 +145,7 @@ const Popup = function (Component) {
100
145
  this.handleBlockScroll = this.handleBlockScroll.bind(this);
101
146
  this.handlePositionChange = this.handlePositionChange.bind(this);
102
147
  this.preventKeyboardScroll = this.preventKeyboardScroll.bind(this);
148
+ this.updateListeners = this.updateListeners.bind(this);
103
149
  this.addScrollBlockListeners = this.addScrollBlockListeners.bind(this);
104
150
  this.removeScrollBlockListeners = this.removeScrollBlockListeners.bind(this);
105
151
  this.handleAddingScrollBlock = this.handleAddingScrollBlock.bind(this);
@@ -112,8 +158,11 @@ const Popup = function (Component) {
112
158
  this.setContainerDynamicPositioning = this.setContainerDynamicPositioning.bind(this);
113
159
  this.updatePopupState = this.updatePopupState.bind(this);
114
160
  this.handleScrollAndBlockEvents = this.handleScrollAndBlockEvents.bind(this);
161
+ this.handleIframeClickEvents = this.handleIframeClickEvents.bind(this);
115
162
  this.handleDropElementStyleUpdate = this.handleDropElementStyleUpdate.bind(this);
163
+ this.getParentContainerElement = this.getParentContainerElement.bind(this);
116
164
  this.positionRef = /*#__PURE__*/React.createRef();
165
+ this.parentContainerElement = this.getParentContainerElement();
117
166
  this.popupObserver = new ResizeObserver(this.handlePopupResize); //dropBoxSize
118
167
 
119
168
  this.size = null;
@@ -134,8 +183,7 @@ const Popup = function (Component) {
134
183
  popups[group] = groupPopups;
135
184
 
136
185
  if (Object.keys(popups).length === 1 && groupPopups.length === 1) {
137
- document.addEventListener('click', this.handleDocumentInteraction, true);
138
- document.addEventListener('click', this.documentClickHandler, false);
186
+ this.updateListeners(true, CLICK_EVENTS, document);
139
187
  document.addEventListener('keyup', this.documentKeyupHandler, false); // document.addEventListener('scroll', this.handleScroll, true);
140
188
 
141
189
  window.addEventListener('resize', this.handleResize);
@@ -157,8 +205,22 @@ const Popup = function (Component) {
157
205
  }
158
206
  }
159
207
 
160
- handleScrollAndBlockEvents(isPopupReady, isMobile) {
161
- if (isPopupReady && !isMobile) {
208
+ getParentContainerElement() {
209
+ const getParentContainer = getLibraryConfig('getParentContainer');
210
+
211
+ if (getParentContainer && typeof getParentContainer === 'function') {
212
+ const parent = getParentContainer();
213
+
214
+ if (parent) {
215
+ return parent;
216
+ }
217
+ }
218
+
219
+ return document;
220
+ }
221
+
222
+ handleScrollAndBlockEvents(shouldAdd) {
223
+ if (shouldAdd) {
162
224
  this.handleAddingScrollBlock();
163
225
  this.handleAddingScrollToUpdatePosition();
164
226
  } else {
@@ -167,6 +229,16 @@ const Popup = function (Component) {
167
229
  }
168
230
  }
169
231
 
232
+ handleIframeClickEvents(shouldAdd) {
233
+ this.parentContainerElement.querySelectorAll('iframe').forEach(frame => {
234
+ const frameDocument = frame.contentDocument;
235
+
236
+ if (frameDocument) {
237
+ this.updateListeners(shouldAdd, CLICK_EVENTS, frameDocument);
238
+ }
239
+ });
240
+ }
241
+
170
242
  componentDidUpdate(prevProps, prevState) {
171
243
  const {
172
244
  isPopupReady,
@@ -193,7 +265,8 @@ const Popup = function (Component) {
193
265
  }
194
266
 
195
267
  if (oldStateOpen !== isPopupReady && !isMobile || oldIsMobileState !== isMobile) {
196
- this.handleScrollAndBlockEvents(isPopupReady, isMobile);
268
+ this.handleScrollAndBlockEvents(isPopupReady && !isMobile);
269
+ this.handleIframeClickEvents(isPopupReady && !isMobile);
197
270
  }
198
271
  }
199
272
 
@@ -211,6 +284,7 @@ const Popup = function (Component) {
211
284
  }, popups);
212
285
  this.handleRemovingScrollBlock();
213
286
  this.handleRemovingScrollToUpdatePosition();
287
+ this.handleIframeClickEvents(false);
214
288
  let noPopups = true;
215
289
 
216
290
  for (const i in popups) {
@@ -225,8 +299,7 @@ const Popup = function (Component) {
225
299
  }
226
300
 
227
301
  if (noPopups) {
228
- document.removeEventListener('click', this.handleDocumentInteraction, true);
229
- document.removeEventListener('click', this.documentClickHandler, false);
302
+ this.updateListeners(false, CLICK_EVENTS, document);
230
303
  document.removeEventListener('keyup', this.documentKeyupHandler); // document.removeEventListener('scroll', this.handleScroll);
231
304
 
232
305
  window.removeEventListener('resize', this.handleResize);
@@ -347,41 +420,46 @@ const Popup = function (Component) {
347
420
  }
348
421
  }
349
422
 
350
- addScrollBlockListeners() {
351
- document.addEventListener('wheel', this.handleBlockScroll, {
352
- capture: true,
353
- passive: false
354
- });
355
- document.addEventListener('touchmove', this.handleBlockScroll, {
356
- capture: true,
357
- passive: false
358
- });
359
- document.addEventListener('scroll', this.handlePositionChange, {
360
- capture: true,
361
- passive: false
423
+ updateListeners() {
424
+ let add = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
425
+ let eventList = arguments.length > 1 ? arguments[1] : undefined;
426
+ let element = arguments.length > 2 ? arguments[2] : undefined;
427
+ const method = add ? 'addEventListener' : 'removeEventListener';
428
+ eventList.forEach(_ref2 => {
429
+ let {
430
+ name,
431
+ handlerName,
432
+ options
433
+ } = _ref2;
434
+ const handler = this[handlerName];
435
+
436
+ if (handler) {
437
+ element[method](name, handler, options);
438
+ }
362
439
  });
363
- document.addEventListener('keydown', this.preventKeyboardScroll, {
364
- capture: true,
365
- passive: false
440
+ }
441
+
442
+ addScrollBlockListeners() {
443
+ // Main document
444
+ this.updateListeners(true, SCROLL_BLOCK_EVENTS, document); // Attach event listeners to all iframes within parentContainerElement
445
+
446
+ this.parentContainerElement.querySelectorAll('iframe').forEach(frame => {
447
+ const frameDocument = frame.contentDocument;
448
+
449
+ if (frameDocument) {
450
+ this.updateListeners(true, IFRAME_SCROLL_BLOCK_EVENTS, frameDocument);
451
+ }
366
452
  });
367
453
  }
368
454
 
369
455
  removeScrollBlockListeners() {
370
- document.removeEventListener('wheel', this.handleBlockScroll, {
371
- capture: true,
372
- passive: false
373
- });
374
- document.removeEventListener('touchmove', this.handleBlockScroll, {
375
- capture: true,
376
- passive: false
377
- });
378
- document.removeEventListener('scroll', this.handlePositionChange, {
379
- capture: true,
380
- passive: false
381
- });
382
- document.removeEventListener('keydown', this.preventKeyboardScroll, {
383
- capture: true,
384
- passive: false
456
+ this.updateListeners(false, SCROLL_BLOCK_EVENTS, document);
457
+ this.parentContainerElement.querySelectorAll('iframe').forEach(frame => {
458
+ const frameDocument = frame.contentDocument;
459
+
460
+ if (frameDocument) {
461
+ this.updateListeners(false, IFRAME_SCROLL_BLOCK_EVENTS, frameDocument);
462
+ }
385
463
  });
386
464
  }
387
465
 
@@ -618,62 +696,29 @@ const Popup = function (Component) {
618
696
  return needPrevent;
619
697
  }
620
698
 
621
- closePopups(e) {
622
- let checkTarget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
623
-
624
- try {
625
- Object.keys(popups).forEach(groupName => {
626
- const openGroupPopups = (popups[groupName] || []).filter(popup => popup.state.isPopupOpen);
627
- openGroupPopups.forEach(popup => {
628
- const {
629
- dropElement,
630
- placeHolderElement
631
- } = popup;
632
- const {
633
- target
634
- } = e || {};
635
- const canClosePopup = !popup.props.checkBeforeClose || popup.props.checkBeforeClose && popup.props.checkBeforeClose() && !isTextSelected();
636
- const isOutsideClick = checkTarget && placeHolderElement && dropElement && placeHolderElement !== target && !placeHolderElement.contains(target) && dropElement !== target && !dropElement.contains(target);
637
-
638
- if (canClosePopup && (!checkTarget || isOutsideClick)) {
639
- popup.setState({
640
- isPopupOpen: false,
641
- isPopupReady: false
642
- });
643
- }
644
- });
645
- });
646
-
647
- if (!checkTarget) {
648
- lastOpenedGroup = [];
649
- }
650
- } catch (error) {// eslint-disable-next-line no-console
651
- //console.error('popup component not unmounted properly', error);
652
- }
653
- }
654
-
655
- documentClickHandler(e) {
656
- // Handles document click events to close all popups.
657
- // This function closes all popups without checking if the click occurred outside the popup.
658
- this.closePopups(e, false);
659
- }
660
-
661
- handleDocumentInteraction(e) {
662
- // Handles interactions with the document to determine whether to close the popup.
663
- // This function is specifically designed to close the popup when clicking outside of it.
664
- // Check if the click event should prevent popup closure.
699
+ documentClickHandler1(e) {
665
700
  const needPrevent = this.handleGetNeedPrevent(e);
666
701
 
667
702
  if (needPrevent) {
668
- // If the click event should prevent popup closure:
669
- // - Stop the event propagation.
670
- // - Close the last opened group of popups.
671
703
  this.removeClose(e);
672
704
  this.handleCloseLastOpenedGroup();
673
- } else {
674
- // If the click event does not need to prevent popup closure:
675
- // - Close all popups, but only if the click occurred outside the popup elements.
676
- this.closePopups(e, true);
705
+ }
706
+ }
707
+
708
+ documentClickHandler() {
709
+ try {
710
+ Object.keys(popups).forEach(groupName => {
711
+ const groupPopups = popups[groupName] || [];
712
+ groupPopups.forEach(popup => {
713
+ popup.state.isPopupOpen && (!popup.props.checkBeforeClose || popup.props.checkBeforeClose && popup.props.checkBeforeClose()) && !isTextSelected() && popup.setState({
714
+ isPopupOpen: false,
715
+ isPopupReady: false
716
+ });
717
+ });
718
+ });
719
+ lastOpenedGroup = [];
720
+ } catch (e) {// eslint-disable-next-line no-console
721
+ //console.error('popup component not unmounted properly', e);
677
722
  }
678
723
  }
679
724
 
@@ -8,7 +8,8 @@ let id = {
8
8
  direction: 'ltr',
9
9
  tooltipDebounce: 175,
10
10
  getTooltipContainer: () => {},
11
- autoComplete: false
11
+ autoComplete: false,
12
+ getParentContainer: () => {}
12
13
  };
13
14
  export function getLibraryConfig(key) {
14
15
  return id[key];
@@ -29,6 +29,8 @@ var _isMobilePopover = _interopRequireDefault(require("../DropBox/utils/isMobile
29
29
 
30
30
  var _selectn = _interopRequireDefault(require("selectn"));
31
31
 
32
+ var _Config = require("../Provider/Config.js");
33
+
32
34
  var _excluded = ["isMobile"];
33
35
 
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -97,6 +99,53 @@ var defaultState = {
97
99
  //{height: ‘’, width: ‘’,}
98
100
  isAbsolutePositioningNeeded: true
99
101
  };
102
+ var SCROLL_BLOCK_EVENTS = Object.freeze([{
103
+ name: 'wheel',
104
+ handlerName: 'handleBlockScroll',
105
+ options: {
106
+ capture: true,
107
+ passive: false
108
+ }
109
+ }, {
110
+ name: 'touchmove',
111
+ handlerName: 'handleBlockScroll',
112
+ options: {
113
+ capture: true,
114
+ passive: false
115
+ }
116
+ }, {
117
+ name: 'scroll',
118
+ handlerName: 'handlePositionChange',
119
+ options: {
120
+ capture: true,
121
+ passive: false
122
+ }
123
+ }, {
124
+ name: 'keydown',
125
+ handlerName: 'preventKeyboardScroll',
126
+ options: {
127
+ capture: true,
128
+ passive: false
129
+ }
130
+ }]);
131
+ var IFRAME_SCROLL_BLOCK_EVENTS = Object.freeze(SCROLL_BLOCK_EVENTS.filter(function (event) {
132
+ return event.name !== 'keydown';
133
+ }));
134
+ var CLICK_EVENTS = Object.freeze([{
135
+ name: 'click',
136
+ handlerName: 'documentClickHandler',
137
+ options: {
138
+ capture: false,
139
+ passive: false
140
+ }
141
+ }, {
142
+ name: 'click',
143
+ handlerName: 'documentClickHandler1',
144
+ options: {
145
+ capture: true,
146
+ passive: false
147
+ }
148
+ }]);
100
149
  /* eslint-disable react/no-deprecated */
101
150
 
102
151
  /* eslint-disable react/prop-types */
@@ -147,9 +196,8 @@ var Popup = function Popup(Component) {
147
196
  isMobile: false
148
197
  };
149
198
  _this.togglePopup = _this.togglePopup.bind(_assertThisInitialized(_this));
150
- _this.closePopups = _this.closePopups.bind(_assertThisInitialized(_this));
151
- _this.handleDocumentInteraction = _this.handleDocumentInteraction.bind(_assertThisInitialized(_this));
152
199
  _this.documentClickHandler = _this.documentClickHandler.bind(_assertThisInitialized(_this));
200
+ _this.documentClickHandler1 = _this.documentClickHandler1.bind(_assertThisInitialized(_this));
153
201
  _this.removeClose = _this.removeClose.bind(_assertThisInitialized(_this));
154
202
  _this.documentKeyupHandler = _this.documentKeyupHandler.bind(_assertThisInitialized(_this));
155
203
  _this.openPopupOnly = _this.openPopupOnly.bind(_assertThisInitialized(_this));
@@ -173,6 +221,7 @@ var Popup = function Popup(Component) {
173
221
  _this.handleBlockScroll = _this.handleBlockScroll.bind(_assertThisInitialized(_this));
174
222
  _this.handlePositionChange = _this.handlePositionChange.bind(_assertThisInitialized(_this));
175
223
  _this.preventKeyboardScroll = _this.preventKeyboardScroll.bind(_assertThisInitialized(_this));
224
+ _this.updateListeners = _this.updateListeners.bind(_assertThisInitialized(_this));
176
225
  _this.addScrollBlockListeners = _this.addScrollBlockListeners.bind(_assertThisInitialized(_this));
177
226
  _this.removeScrollBlockListeners = _this.removeScrollBlockListeners.bind(_assertThisInitialized(_this));
178
227
  _this.handleAddingScrollBlock = _this.handleAddingScrollBlock.bind(_assertThisInitialized(_this));
@@ -185,8 +234,11 @@ var Popup = function Popup(Component) {
185
234
  _this.setContainerDynamicPositioning = _this.setContainerDynamicPositioning.bind(_assertThisInitialized(_this));
186
235
  _this.updatePopupState = _this.updatePopupState.bind(_assertThisInitialized(_this));
187
236
  _this.handleScrollAndBlockEvents = _this.handleScrollAndBlockEvents.bind(_assertThisInitialized(_this));
237
+ _this.handleIframeClickEvents = _this.handleIframeClickEvents.bind(_assertThisInitialized(_this));
188
238
  _this.handleDropElementStyleUpdate = _this.handleDropElementStyleUpdate.bind(_assertThisInitialized(_this));
239
+ _this.getParentContainerElement = _this.getParentContainerElement.bind(_assertThisInitialized(_this));
189
240
  _this.positionRef = /*#__PURE__*/_react["default"].createRef();
241
+ _this.parentContainerElement = _this.getParentContainerElement();
190
242
  _this.popupObserver = new _ResizeObserver["default"](_this.handlePopupResize); //dropBoxSize
191
243
 
192
244
  _this.size = null;
@@ -211,8 +263,7 @@ var Popup = function Popup(Component) {
211
263
  popups[group] = groupPopups;
212
264
 
213
265
  if (Object.keys(popups).length === 1 && groupPopups.length === 1) {
214
- document.addEventListener('click', this.handleDocumentInteraction, true);
215
- document.addEventListener('click', this.documentClickHandler, false);
266
+ this.updateListeners(true, CLICK_EVENTS, document);
216
267
  document.addEventListener('keyup', this.documentKeyupHandler, false); // document.addEventListener('scroll', this.handleScroll, true);
217
268
 
218
269
  window.addEventListener('resize', this.handleResize);
@@ -232,10 +283,25 @@ var Popup = function Popup(Component) {
232
283
  });
233
284
  }
234
285
  }
286
+ }, {
287
+ key: "getParentContainerElement",
288
+ value: function getParentContainerElement() {
289
+ var getParentContainer = (0, _Config.getLibraryConfig)('getParentContainer');
290
+
291
+ if (getParentContainer && typeof getParentContainer === 'function') {
292
+ var parent = getParentContainer();
293
+
294
+ if (parent) {
295
+ return parent;
296
+ }
297
+ }
298
+
299
+ return document;
300
+ }
235
301
  }, {
236
302
  key: "handleScrollAndBlockEvents",
237
- value: function handleScrollAndBlockEvents(isPopupReady, isMobile) {
238
- if (isPopupReady && !isMobile) {
303
+ value: function handleScrollAndBlockEvents(shouldAdd) {
304
+ if (shouldAdd) {
239
305
  this.handleAddingScrollBlock();
240
306
  this.handleAddingScrollToUpdatePosition();
241
307
  } else {
@@ -243,6 +309,19 @@ var Popup = function Popup(Component) {
243
309
  this.handleRemovingScrollToUpdatePosition();
244
310
  }
245
311
  }
312
+ }, {
313
+ key: "handleIframeClickEvents",
314
+ value: function handleIframeClickEvents(shouldAdd) {
315
+ var _this2 = this;
316
+
317
+ this.parentContainerElement.querySelectorAll('iframe').forEach(function (frame) {
318
+ var frameDocument = frame.contentDocument;
319
+
320
+ if (frameDocument) {
321
+ _this2.updateListeners(shouldAdd, CLICK_EVENTS, frameDocument);
322
+ }
323
+ });
324
+ }
246
325
  }, {
247
326
  key: "componentDidUpdate",
248
327
  value: function componentDidUpdate(prevProps, prevState) {
@@ -268,20 +347,21 @@ var Popup = function Popup(Component) {
268
347
  }
269
348
 
270
349
  if (oldStateOpen !== isPopupReady && !isMobile || oldIsMobileState !== isMobile) {
271
- this.handleScrollAndBlockEvents(isPopupReady, isMobile);
350
+ this.handleScrollAndBlockEvents(isPopupReady && !isMobile);
351
+ this.handleIframeClickEvents(isPopupReady && !isMobile);
272
352
  }
273
353
  }
274
354
  }, {
275
355
  key: "componentWillUnmount",
276
356
  value: function componentWillUnmount() {
277
- var _this2 = this;
357
+ var _this3 = this;
278
358
 
279
359
  var group = this.getGroup();
280
360
  popups = Object.keys(popups).reduce(function (res, groupName) {
281
361
  if (groupName === group) {
282
362
  var groupPopups = popups[group];
283
363
  var newGroupPopups = groupPopups.filter(function (popup) {
284
- return popup !== _this2;
364
+ return popup !== _this3;
285
365
  });
286
366
  newGroupPopups.length === 0 && lastOpenedGroup.indexOf(group) >= 0 && lastOpenedGroup.splice(lastOpenedGroup.indexOf(group), 1);
287
367
  res[group] = newGroupPopups;
@@ -291,6 +371,7 @@ var Popup = function Popup(Component) {
291
371
  }, popups);
292
372
  this.handleRemovingScrollBlock();
293
373
  this.handleRemovingScrollToUpdatePosition();
374
+ this.handleIframeClickEvents(false);
294
375
  var noPopups = true;
295
376
 
296
377
  for (var i in popups) {
@@ -305,8 +386,7 @@ var Popup = function Popup(Component) {
305
386
  }
306
387
 
307
388
  if (noPopups) {
308
- document.removeEventListener('click', this.handleDocumentInteraction, true);
309
- document.removeEventListener('click', this.documentClickHandler, false);
389
+ this.updateListeners(false, CLICK_EVENTS, document);
310
390
  document.removeEventListener('keyup', this.documentKeyupHandler); // document.removeEventListener('scroll', this.handleScroll);
311
391
 
312
392
  window.removeEventListener('resize', this.handleResize);
@@ -428,44 +508,54 @@ var Popup = function Popup(Component) {
428
508
  this.handlePopupPosition(defaultPosition, true);
429
509
  }
430
510
  }
511
+ }, {
512
+ key: "updateListeners",
513
+ value: function updateListeners() {
514
+ var _this4 = this;
515
+
516
+ var add = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
517
+ var eventList = arguments.length > 1 ? arguments[1] : undefined;
518
+ var element = arguments.length > 2 ? arguments[2] : undefined;
519
+ var method = add ? 'addEventListener' : 'removeEventListener';
520
+ eventList.forEach(function (_ref5) {
521
+ var name = _ref5.name,
522
+ handlerName = _ref5.handlerName,
523
+ options = _ref5.options;
524
+ var handler = _this4[handlerName];
525
+
526
+ if (handler) {
527
+ element[method](name, handler, options);
528
+ }
529
+ });
530
+ }
431
531
  }, {
432
532
  key: "addScrollBlockListeners",
433
533
  value: function addScrollBlockListeners() {
434
- document.addEventListener('wheel', this.handleBlockScroll, {
435
- capture: true,
436
- passive: false
437
- });
438
- document.addEventListener('touchmove', this.handleBlockScroll, {
439
- capture: true,
440
- passive: false
441
- });
442
- document.addEventListener('scroll', this.handlePositionChange, {
443
- capture: true,
444
- passive: false
445
- });
446
- document.addEventListener('keydown', this.preventKeyboardScroll, {
447
- capture: true,
448
- passive: false
534
+ var _this5 = this;
535
+
536
+ // Main document
537
+ this.updateListeners(true, SCROLL_BLOCK_EVENTS, document); // Attach event listeners to all iframes within parentContainerElement
538
+
539
+ this.parentContainerElement.querySelectorAll('iframe').forEach(function (frame) {
540
+ var frameDocument = frame.contentDocument;
541
+
542
+ if (frameDocument) {
543
+ _this5.updateListeners(true, IFRAME_SCROLL_BLOCK_EVENTS, frameDocument);
544
+ }
449
545
  });
450
546
  }
451
547
  }, {
452
548
  key: "removeScrollBlockListeners",
453
549
  value: function removeScrollBlockListeners() {
454
- document.removeEventListener('wheel', this.handleBlockScroll, {
455
- capture: true,
456
- passive: false
457
- });
458
- document.removeEventListener('touchmove', this.handleBlockScroll, {
459
- capture: true,
460
- passive: false
461
- });
462
- document.removeEventListener('scroll', this.handlePositionChange, {
463
- capture: true,
464
- passive: false
465
- });
466
- document.removeEventListener('keydown', this.preventKeyboardScroll, {
467
- capture: true,
468
- passive: false
550
+ var _this6 = this;
551
+
552
+ this.updateListeners(false, SCROLL_BLOCK_EVENTS, document);
553
+ this.parentContainerElement.querySelectorAll('iframe').forEach(function (frame) {
554
+ var frameDocument = frame.contentDocument;
555
+
556
+ if (frameDocument) {
557
+ _this6.updateListeners(false, IFRAME_SCROLL_BLOCK_EVENTS, frameDocument);
558
+ }
469
559
  });
470
560
  }
471
561
  }, {
@@ -573,7 +663,7 @@ var Popup = function Popup(Component) {
573
663
  }, {
574
664
  key: "togglePopup",
575
665
  value: function togglePopup(e, defaultPosition) {
576
- var _this3 = this;
666
+ var _this7 = this;
577
667
 
578
668
  var group = this.getGroup();
579
669
  this.removeClose(e);
@@ -582,7 +672,7 @@ var Popup = function Popup(Component) {
582
672
  lastOpenedGroup = !isPopupOpen && lastOpenedGroup.indexOf(group) === -1 ? [group].concat(_toConsumableArray(lastOpenedGroup)) : lastOpenedGroup;
583
673
  isPopupOpen && lastOpenedGroup.splice(0, 1);
584
674
  groupPopups.forEach(function (popup) {
585
- if (popup !== _this3 && popup.state.isPopupOpen) {
675
+ if (popup !== _this7 && popup.state.isPopupOpen) {
586
676
  popup.setState({
587
677
  isPopupOpen: false,
588
678
  isPopupReady: false
@@ -690,66 +780,31 @@ var Popup = function Popup(Component) {
690
780
  return needPrevent;
691
781
  }
692
782
  }, {
693
- key: "closePopups",
694
- value: function closePopups(e) {
695
- var checkTarget = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
696
-
697
- try {
698
- Object.keys(popups).forEach(function (groupName) {
699
- var openGroupPopups = (popups[groupName] || []).filter(function (popup) {
700
- return popup.state.isPopupOpen;
701
- });
702
- openGroupPopups.forEach(function (popup) {
703
- var dropElement = popup.dropElement,
704
- placeHolderElement = popup.placeHolderElement;
705
-
706
- var _ref5 = e || {},
707
- target = _ref5.target;
708
-
709
- var canClosePopup = !popup.props.checkBeforeClose || popup.props.checkBeforeClose && popup.props.checkBeforeClose() && !(0, _Common.isTextSelected)();
710
- var isOutsideClick = checkTarget && placeHolderElement && dropElement && placeHolderElement !== target && !placeHolderElement.contains(target) && dropElement !== target && !dropElement.contains(target);
711
-
712
- if (canClosePopup && (!checkTarget || isOutsideClick)) {
713
- popup.setState({
714
- isPopupOpen: false,
715
- isPopupReady: false
716
- });
717
- }
718
- });
719
- });
720
-
721
- if (!checkTarget) {
722
- lastOpenedGroup = [];
723
- }
724
- } catch (error) {// eslint-disable-next-line no-console
725
- //console.error('popup component not unmounted properly', error);
726
- }
727
- }
728
- }, {
729
- key: "documentClickHandler",
730
- value: function documentClickHandler(e) {
731
- // Handles document click events to close all popups.
732
- // This function closes all popups without checking if the click occurred outside the popup.
733
- this.closePopups(e, false);
734
- }
735
- }, {
736
- key: "handleDocumentInteraction",
737
- value: function handleDocumentInteraction(e) {
738
- // Handles interactions with the document to determine whether to close the popup.
739
- // This function is specifically designed to close the popup when clicking outside of it.
740
- // Check if the click event should prevent popup closure.
783
+ key: "documentClickHandler1",
784
+ value: function documentClickHandler1(e) {
741
785
  var needPrevent = this.handleGetNeedPrevent(e);
742
786
 
743
787
  if (needPrevent) {
744
- // If the click event should prevent popup closure:
745
- // - Stop the event propagation.
746
- // - Close the last opened group of popups.
747
788
  this.removeClose(e);
748
789
  this.handleCloseLastOpenedGroup();
749
- } else {
750
- // If the click event does not need to prevent popup closure:
751
- // - Close all popups, but only if the click occurred outside the popup elements.
752
- this.closePopups(e, true);
790
+ }
791
+ }
792
+ }, {
793
+ key: "documentClickHandler",
794
+ value: function documentClickHandler() {
795
+ try {
796
+ Object.keys(popups).forEach(function (groupName) {
797
+ var groupPopups = popups[groupName] || [];
798
+ groupPopups.forEach(function (popup) {
799
+ popup.state.isPopupOpen && (!popup.props.checkBeforeClose || popup.props.checkBeforeClose && popup.props.checkBeforeClose()) && !(0, _Common.isTextSelected)() && popup.setState({
800
+ isPopupOpen: false,
801
+ isPopupReady: false
802
+ });
803
+ });
804
+ });
805
+ lastOpenedGroup = [];
806
+ } catch (e) {// eslint-disable-next-line no-console
807
+ //console.error('popup component not unmounted properly', e);
753
808
  }
754
809
  }
755
810
  }, {
@@ -787,7 +842,7 @@ var Popup = function Popup(Component) {
787
842
  }, {
788
843
  key: "handlePopupPosition",
789
844
  value: function handlePopupPosition() {
790
- var _this4 = this;
845
+ var _this8 = this;
791
846
 
792
847
  var defaultPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'bottomCenter';
793
848
  var isUpdatePosition = arguments.length > 1 ? arguments[1] : undefined;
@@ -820,11 +875,11 @@ var Popup = function Popup(Component) {
820
875
 
821
876
  var setPosition = function setPosition() {
822
877
  requestAnimationFrame(function () {
823
- var placeHolderElement = _this4.placeHolderElement,
824
- dropElement = _this4.dropElement;
825
- var _this4$state = _this4.state,
826
- position = _this4$state.position,
827
- isPopupReady = _this4$state.isPopupReady;
878
+ var placeHolderElement = _this8.placeHolderElement,
879
+ dropElement = _this8.dropElement;
880
+ var _this8$state = _this8.state,
881
+ position = _this8$state.position,
882
+ isPopupReady = _this8$state.isPopupReady;
828
883
  var scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
829
884
 
830
885
  var betterPosition = _viewPort["default"].betterView(dropElement, placeHolderElement, defaultPosition, scrollContainer, {
@@ -842,17 +897,17 @@ var Popup = function Popup(Component) {
842
897
 
843
898
  if (!isAbsolute) {
844
899
  if (!isPopupReady) {
845
- _this4.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
900
+ _this8.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
846
901
  }
847
902
 
848
903
  if (!dropElement) {
849
904
  return;
850
905
  }
851
906
 
852
- _this4.setContainerDynamicPositioning(betterPosition, needArrow);
907
+ _this8.setContainerDynamicPositioning(betterPosition, needArrow);
853
908
  } else {
854
909
  if (position !== view || !isPopupReady) {
855
- _this4.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
910
+ _this8.updatePopupState(view, views, viewsOffset, targetOffset, popupOffset, isAbsolute);
856
911
  }
857
912
  }
858
913
  });
@@ -871,7 +926,7 @@ var Popup = function Popup(Component) {
871
926
  }, {
872
927
  key: "handleOpenPopupPositionChange",
873
928
  value: function handleOpenPopupPositionChange() {
874
- var _this5 = this;
929
+ var _this9 = this;
875
930
 
876
931
  Object.keys(popups).forEach(function (groupName) {
877
932
  var groupPopups = popups[groupName] || [];
@@ -888,11 +943,11 @@ var Popup = function Popup(Component) {
888
943
  if (placeHolderElement && dropElement) {
889
944
  var scrollContainer = placeHolderElement.closest('[data-scroll=true]') || document.body;
890
945
  requestAnimationFrame(function () {
891
- var needArrow = _this5.getNeedArrow(popup);
946
+ var needArrow = _this9.getNeedArrow(popup);
892
947
 
893
- var isAbsolute = _this5.getIsAbsolutePopup(popup);
948
+ var isAbsolute = _this9.getIsAbsolutePopup(popup);
894
949
 
895
- var customOrder = _this5.getCustomPositionOrder(popup);
950
+ var customOrder = _this9.getCustomPositionOrder(popup);
896
951
 
897
952
  var isMobile = (0, _isMobilePopover["default"])(true);
898
953
 
@@ -15,7 +15,8 @@ var id = {
15
15
  direction: 'ltr',
16
16
  tooltipDebounce: 175,
17
17
  getTooltipContainer: function getTooltipContainer() {},
18
- autoComplete: false
18
+ autoComplete: false,
19
+ getParentContainer: function getParentContainer() {}
19
20
  };
20
21
 
21
22
  function getLibraryConfig(key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/components",
3
- "version": "1.0.0-temp-220.5",
3
+ "version": "1.0.0-temp-220.6",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "private": false,
@@ -71,7 +71,7 @@
71
71
  "@zohodesk/a11y": "2.3.4",
72
72
  "@zohodesk/docstool": "1.0.0-alpha-2",
73
73
  "@zohodesk/hooks": "2.0.5",
74
- "@zohodesk/icons": "1.0.74",
74
+ "@zohodesk/icons": "1.0.75",
75
75
  "@zohodesk/svg": "1.1.22",
76
76
  "@zohodesk/utils": "1.3.14",
77
77
  "@zohodesk/variables": "1.0.0",
@@ -86,7 +86,7 @@
86
86
  "selectn": "1.1.2"
87
87
  },
88
88
  "peerDependencies": {
89
- "@zohodesk/icons": "1.0.74",
89
+ "@zohodesk/icons": "1.0.75",
90
90
  "@zohodesk/variables": "1.0.0",
91
91
  "@zohodesk/svg": "1.1.22",
92
92
  "@zohodesk/virtualizer": "1.0.3",