diginet-core-ui 1.3.61-beta.1 → 1.3.61-beta.2

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.
@@ -121,13 +121,13 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
121
121
  arrow,
122
122
  bgColor,
123
123
  children,
124
+ clickOutsideToClose,
124
125
  direction,
125
126
  fullScreen,
126
127
  height,
127
128
  onClose,
128
129
  open,
129
130
  pressESCToClose,
130
- clickOutsideToClose,
131
131
  style,
132
132
  transformOrigin,
133
133
  trigger,
@@ -167,14 +167,16 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
167
167
  };
168
168
 
169
169
  const onClickOutside = event => {
170
- var _ref$current, _ref$current2, _ref$current2$parentN, _anchor;
170
+ var _anchor2, _anchor2$current, _anchor3, _ref$current, _ref$current2, _ref$current2$parentN;
171
171
 
172
172
  if (!ref.current) {
173
173
  document.removeEventListener('click', onClickOutside);
174
174
  return;
175
175
  }
176
176
 
177
- if (clickOutsideToClose && !((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(event === null || event === void 0 ? void 0 : event.target)) && (!fullScreen || (_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && (_ref$current2$parentN = _ref$current2.parentNode) !== null && _ref$current2$parentN !== void 0 && _ref$current2$parentN.contains(event === null || event === void 0 ? void 0 : event.target)) && !((_anchor = anchor) !== null && _anchor !== void 0 && _anchor.contains(event === null || event === void 0 ? void 0 : event.target)) && openState) {
177
+ const _anchor = ((_anchor2 = anchor) === null || _anchor2 === void 0 ? void 0 : (_anchor2$current = _anchor2.current) === null || _anchor2$current === void 0 ? void 0 : _anchor2$current.element) || ((_anchor3 = anchor) === null || _anchor3 === void 0 ? void 0 : _anchor3.current) || anchor;
178
+
179
+ if (clickOutsideToClose && !((_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(event === null || event === void 0 ? void 0 : event.target)) && (!fullScreen || (_ref$current2 = ref.current) !== null && _ref$current2 !== void 0 && (_ref$current2$parentN = _ref$current2.parentNode) !== null && _ref$current2$parentN !== void 0 && _ref$current2$parentN.contains(event === null || event === void 0 ? void 0 : event.target)) && !(_anchor !== null && _anchor !== void 0 && _anchor.contains(event === null || event === void 0 ? void 0 : event.target)) && openState) {
178
180
  onClosePopover();
179
181
  }
180
182
  };
@@ -208,9 +210,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
208
210
 
209
211
  if (element || anchor) {
210
212
  if (element) anchor = element;else if (anchor && !(anchor instanceof Element)) {
211
- var _anchor2, _anchor$current;
213
+ var _anchor4, _anchor$current;
212
214
 
213
- anchor = ((_anchor2 = anchor) === null || _anchor2 === void 0 ? void 0 : _anchor2.element) || ((_anchor$current = anchor.current) === null || _anchor$current === void 0 ? void 0 : _anchor$current.element) || anchor.current;
215
+ anchor = ((_anchor4 = anchor) === null || _anchor4 === void 0 ? void 0 : _anchor4.element) || ((_anchor$current = anchor.current) === null || _anchor$current === void 0 ? void 0 : _anchor$current.element) || anchor.current;
214
216
  }
215
217
 
216
218
  if (anchorOrigin === 'center') {
@@ -322,9 +324,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
322
324
  };
323
325
  }, []);
324
326
  useEffect(() => {
325
- var _anchor3, _anchor4;
327
+ var _anchor5, _anchor6;
326
328
 
327
- const anchorEl = ((_anchor3 = anchor) === null || _anchor3 === void 0 ? void 0 : _anchor3.element) || ((_anchor4 = anchor) === null || _anchor4 === void 0 ? void 0 : _anchor4.current) || anchor;
329
+ const anchorEl = ((_anchor5 = anchor) === null || _anchor5 === void 0 ? void 0 : _anchor5.element) || ((_anchor6 = anchor) === null || _anchor6 === void 0 ? void 0 : _anchor6.current) || anchor;
328
330
  const eventArr = eventMap.get(trigger) || [];
329
331
 
330
332
  if (anchorEl && open === undefined && (eventArr === null || eventArr === void 0 ? void 0 : eventArr.length) > 0) {
@@ -362,6 +364,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
362
364
  document.documentElement.style.overflow = 'auto';
363
365
  }
364
366
  }, [openState]);
367
+ useEffect(() => {
368
+ clickOutsideToClose ? document.addEventListener('click', onClickOutside) : document.removeEventListener('click', onClickOutside);
369
+ }, [clickOutsideToClose]);
365
370
  useImperativeHandle(reference, () => ({
366
371
  element: ref.current,
367
372
  instance: {
@@ -375,9 +380,9 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
375
380
  }));
376
381
 
377
382
  const renderAnchor = () => {
378
- var _anchor5;
383
+ var _anchor7;
379
384
 
380
- if (!((_anchor5 = anchor) !== null && _anchor5 !== void 0 && _anchor5.type)) return null;
385
+ if (!((_anchor7 = anchor) !== null && _anchor7 !== void 0 && _anchor7.type)) return null;
381
386
  const AnchorTag = /*#__PURE__*/React.cloneElement(anchor, {
382
387
  // onClick: () => {
383
388
  // setOpenState(true);
@@ -409,7 +414,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
409
414
  }
410
415
 
411
416
  return null;
412
- }, [openState, zIndex, fullScreen, style, arrow, children, width, height, bgColor]);
417
+ }, [openState, zIndex, fullScreen, style, arrow, children, width, height, bgColor, clickOutsideToClose]);
413
418
  return jsx(React.Fragment, null, renderAnchor(), PopoverView);
414
419
  }));
415
420
 
@@ -501,6 +506,9 @@ Popover.propTypes = {
501
506
  /** The content of the component. */
502
507
  children: PropTypes.node,
503
508
 
509
+ /** If `true`, click outside will close component. */
510
+ clickOutsideToClose: PropTypes.bool,
511
+
504
512
  /**
505
513
  * Direction when Popover shown.
506
514
  * Note: This prop will overwrite anchorOrigin & transformOrigin.
@@ -521,9 +529,6 @@ Popover.propTypes = {
521
529
  /** If `true`, hitting escape will close component. */
522
530
  pressESCToClose: PropTypes.bool,
523
531
 
524
- /** If `true`, click outside will close component. */
525
- clickOutsideToClose: PropTypes.bool,
526
-
527
532
  /** Style inline of component. */
528
533
  style: PropTypes.object,
529
534
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.3.61-beta.1",
3
+ "version": "1.3.61-beta.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",