@geotab/zenith 3.6.2 → 3.6.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,5 +8,5 @@ export interface IDialog {
8
8
  }
9
9
  /**
10
10
  * @deprecated - use Modal instead
11
- */
11
+ */
12
12
  export declare const Dialog: ({ isOpen, children, isElementVisible }: IDialog) => import("react").ReactPortal | null;
@@ -8,16 +8,15 @@ const dialogHelpers_1 = require("./dialogHelpers");
8
8
  const themeContext_1 = require("../utils/theme/themeContext");
9
9
  const classNames_1 = require("../commonHelpers/classNames/classNames");
10
10
  const useBodyScroll_1 = require("../utils/useBodyScroll");
11
- const usePortal_1 = require("../commonHelpers/hooks/usePortal");
12
11
  const useClientReady_1 = require("../commonHelpers/hooks/useClientReady");
13
12
  const zen_1 = require("../utils/zen");
13
+ const react_dom_1 = require("react-dom");
14
14
  /**
15
15
  * @deprecated - use Modal instead
16
- */
16
+ */
17
17
  const Dialog = ({ isOpen, children, isElementVisible }) => {
18
18
  var _a, _b, _c;
19
19
  const lastActiveOutsideElement = (0, react_1.useRef)((_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.activeElement);
20
- const modalRoot = ((_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.fullscreenElement) || ((_c = zen_1.zen.document) === null || _c === void 0 ? void 0 : _c.body);
21
20
  const { dark } = (0, react_1.useContext)(themeContext_1.themeContext);
22
21
  const { resetScroll } = (0, useBodyScroll_1.useBodyScroll)();
23
22
  const isClientReady = (0, useClientReady_1.useClientReady)();
@@ -45,11 +44,11 @@ const Dialog = ({ isOpen, children, isElementVisible }) => {
45
44
  }, [isClientReady, isOpen, resetScroll]);
46
45
  const labeledId = (0, react_1.useId)();
47
46
  const darkClass = dark ? "zen-dark" : "";
48
- const createDialog = (id) => (0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-dialog", darkClass]), "aria-modal": "true", role: "dialog", "aria-labelledby": labeledId, style: { top: `${zen_1.zen.pageYOffset || 0}px` }, children: [(0, jsx_runtime_1.jsx)(dialogContent_1.DialogContent, Object.assign({}, children.props, { labeledId: id, isElementVisible: isElementVisible })), (0, jsx_runtime_1.jsx)("div", { className: "zen-dialog__shield" })] });
49
- const portal = (0, usePortal_1.usePortal)(isOpen && (0, react_1.isValidElement)(children) ? createDialog(labeledId) : null, modalRoot, "ModalPortal");
47
+ const createDialog = id => ((0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-dialog", darkClass]), "aria-modal": "true", role: "dialog", "aria-labelledby": labeledId, style: { top: `${zen_1.zen.pageYOffset || 0}px` }, children: [(0, jsx_runtime_1.jsx)(dialogContent_1.DialogContent, Object.assign({}, children.props, { labeledId: id, isElementVisible: isElementVisible })), (0, jsx_runtime_1.jsx)("div", { className: "zen-dialog__shield" })] }));
50
48
  if (!isClientReady) {
51
49
  return null;
52
50
  }
53
- return portal;
51
+ const modalRoot = ((_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.fullscreenElement) || ((_c = zen_1.zen.document) === null || _c === void 0 ? void 0 : _c.body);
52
+ return (0, react_dom_1.createPortal)(isOpen && (0, react_1.isValidElement)(children) ? createDialog(labeledId) : null, modalRoot);
54
53
  };
55
54
  exports.Dialog = Dialog;
@@ -33,9 +33,9 @@ const toastRaw_1 = require("../toastRaw/toastRaw");
33
33
  const classNames_1 = require("../commonHelpers/classNames/classNames");
34
34
  const getAlertAnimation_1 = require("./utils/getAlertAnimation");
35
35
  const getToastAnimation_1 = require("./utils/getToastAnimation");
36
- const usePortal_1 = require("../commonHelpers/hooks/usePortal");
37
36
  const useClientReady_1 = require("../commonHelpers/hooks/useClientReady");
38
37
  const zen_1 = require("../utils/zen");
38
+ const react_dom_1 = require("react-dom");
39
39
  const FeedbackContainer = () => {
40
40
  var _a, _b;
41
41
  const { alerts, removeAlert, toasts, removeToast, activeFeedback, removedAlertId, removedToastId, mode } = react_1.default.useContext(feedbackContext_1.FeedbackContext);
@@ -58,23 +58,23 @@ const FeedbackContainer = () => {
58
58
  prevAlertsLength.current = alerts.length;
59
59
  prevToastsLength.current = toasts.length;
60
60
  }, [alerts.length, toasts.length]);
61
- const alertsToRender = (0, react_1.useMemo)(() => alerts.map((alert, indx) => (0, jsx_runtime_1.jsx)(alertRaw_1.AlertRaw, { id: alert.id, header: alert.header, text: alert.text, isOpen: true, onClose: () => {
61
+ const alertsToRender = (0, react_1.useMemo)(() => alerts.map((alert, indx) => ((0, jsx_runtime_1.jsx)(alertRaw_1.AlertRaw, { id: alert.id, header: alert.header, text: alert.text, isOpen: true, onClose: () => {
62
62
  removeAlert(alert.id);
63
63
  removedAlertId.current = indx;
64
64
  alert.onClose();
65
- }, type: alert.type, animation: alert.animation || (sameAlertsLength ? null : (0, getAlertAnimation_1.getAlertAnimation)(isAlertAdded, indx, removedAlertId.current, isMobile, activeFeedback)), buttons: alert.buttons, className: alert.className }, alert.id)), [alerts, isMobile, isAlertAdded, removeAlert, activeFeedback, sameAlertsLength, removedAlertId]);
65
+ }, type: alert.type, animation: alert.animation || (sameAlertsLength ? null : (0, getAlertAnimation_1.getAlertAnimation)(isAlertAdded, indx, removedAlertId.current, isMobile, activeFeedback)), buttons: alert.buttons, className: alert.className }, alert.id))), [alerts, isMobile, isAlertAdded, removeAlert, activeFeedback, sameAlertsLength, removedAlertId]);
66
66
  const alertClasses = (0, react_1.useMemo)(() => (0, classNames_1.classNames)(["zen-alerts", isMobile ? "zen-alerts--mobile" : ""]), [isMobile]);
67
67
  const toastClasses = (0, react_1.useMemo)(() => (0, classNames_1.classNames)(["zen-toasts", isMobile ? "zen-toasts--mobile" : ""]), [isMobile]);
68
- const toastsToRender = (0, react_1.useMemo)(() => toasts.map((toast, indx, arr) => (0, jsx_runtime_1.jsx)(toastRaw_1.ToastRaw, { id: toast.id, animation: toast.animation || (sameToastsLength ? null : (0, getToastAnimation_1.getToastAnimation)(isToastAdded, indx, removedToastId.current, arr.length, isMobile, activeFeedback)), header: toast.header, showSeconds: toast.showSeconds, className: toast.className, isOpen: true, onClose: () => {
68
+ const toastsToRender = (0, react_1.useMemo)(() => toasts.map((toast, indx, arr) => ((0, jsx_runtime_1.jsx)(toastRaw_1.ToastRaw, { id: toast.id, animation: toast.animation || (sameToastsLength ? null : (0, getToastAnimation_1.getToastAnimation)(isToastAdded, indx, removedToastId.current, arr.length, isMobile, activeFeedback)), header: toast.header, showSeconds: toast.showSeconds, className: toast.className, isOpen: true, onClose: () => {
69
69
  removeToast(toast.id);
70
70
  removedToastId.current = indx;
71
71
  toast.onClose();
72
- }, type: toast.type, hasIcon: toast.hasIcon, action: toast.action }, toast.id)), [toasts, sameToastsLength, isToastAdded, removedToastId, isMobile, activeFeedback, removeToast]);
73
- const alertsPortal = (0, usePortal_1.usePortal)((0, jsx_runtime_1.jsx)("div", { className: alertClasses, children: alertsToRender }), (_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.body);
74
- const toastsPortal = (0, usePortal_1.usePortal)((0, jsx_runtime_1.jsx)("div", { className: toastClasses, children: toastsToRender }), (_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.body);
72
+ }, type: toast.type, hasIcon: toast.hasIcon, action: toast.action }, toast.id))), [toasts, sameToastsLength, isToastAdded, removedToastId, isMobile, activeFeedback, removeToast]);
75
73
  if (!isClientReady) {
76
74
  return null;
77
75
  }
78
- return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!isAPIMode && alertsPortal, !isAPIMode && toastsPortal] });
76
+ const alertsPortal = ((_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.body) ? (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { className: alertClasses, children: alertsToRender }), zen_1.zen.document.body) : null;
77
+ const toastsPortal = ((_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.body) ? (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { className: toastClasses, children: toastsToRender }), zen_1.zen.document.body) : null;
78
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!isAPIMode && alertsPortal, !isAPIMode && toastsPortal] }));
79
79
  };
80
80
  exports.FeedbackContainer = FeedbackContainer;
package/dist/index.css CHANGED
@@ -15466,6 +15466,9 @@ button.zen-summary__clickable {
15466
15466
  align-items: center;
15467
15467
  gap: 4px;
15468
15468
  }
15469
+ .zen-nav-item__dnd {
15470
+ touch-action: none;
15471
+ }
15469
15472
  .zen-nav-item__action {
15470
15473
  display: flex;
15471
15474
  flex: 0 0 auto;
@@ -103,7 +103,7 @@ const useDragAndDrop = (containerRef, onChangeOrder, marksClassNames, onBeforeDr
103
103
  }
104
104
  }, [containerRef, getPlaceholder, removePlaceholders, onBeforeDragOver, cssMarks.general, cssMarks.placeholder, cssMarks.dragging]);
105
105
  const onDragStart = (0, react_1.useCallback)((e) => {
106
- var _a, _b, _c, _d;
106
+ var _a, _b, _c, _d, _e;
107
107
  e.preventDefault();
108
108
  const listItemElement = (0, findElement_1.findElement)(e.currentTarget, cssMarks.general);
109
109
  if (!listItemElement) {
@@ -147,7 +147,7 @@ const useDragAndDrop = (containerRef, onChangeOrder, marksClassNames, onBeforeDr
147
147
  }
148
148
  };
149
149
  const onDragEnd = () => {
150
- var _a, _b, _c, _d;
150
+ var _a, _b, _c, _d, _e;
151
151
  if (dragImageRef.current) {
152
152
  dragImageRef.current.remove();
153
153
  dragImageRef.current = null;
@@ -167,11 +167,13 @@ const useDragAndDrop = (containerRef, onChangeOrder, marksClassNames, onBeforeDr
167
167
  onChangeOrder(startPosition, endPosition);
168
168
  }
169
169
  (_c = zen_1.zen.document) === null || _c === void 0 ? void 0 : _c.body.removeEventListener("pointerup", onDragEnd, false);
170
- (_d = zen_1.zen.document) === null || _d === void 0 ? void 0 : _d.removeEventListener("mouseleave", onDragEnd);
170
+ (_d = zen_1.zen.document) === null || _d === void 0 ? void 0 : _d.body.removeEventListener("pointercancel", onDragEnd, false);
171
+ (_e = zen_1.zen.document) === null || _e === void 0 ? void 0 : _e.removeEventListener("mouseleave", onDragEnd);
171
172
  };
172
173
  (_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.body.addEventListener("pointermove", dragMoveRef.current, false);
173
174
  (_c = zen_1.zen.document) === null || _c === void 0 ? void 0 : _c.body.addEventListener("pointerup", onDragEnd, false);
174
- (_d = zen_1.zen.document) === null || _d === void 0 ? void 0 : _d.addEventListener("mouseleave", onDragEnd);
175
+ (_d = zen_1.zen.document) === null || _d === void 0 ? void 0 : _d.body.addEventListener("pointercancel", onDragEnd, false);
176
+ (_e = zen_1.zen.document) === null || _e === void 0 ? void 0 : _e.addEventListener("mouseleave", onDragEnd);
175
177
  }, [cancelMoveScroll, containerRef, moveScroll, onChangeOrder, removePlaceholders, setPlaceholder, cssMarks.general, cssMarks.placeholder, cssMarks.dragging, cssMarks.dragged]);
176
178
  return { onDragStart };
177
179
  };
package/dist/nav/nav.js CHANGED
@@ -86,7 +86,7 @@ const Nav = ({ children, className, collapsed = false, onCollapseToggle, onMenuV
86
86
  const primaryFooter = footer && (0, navUtils_1.filterPrimaryNavItems)(footer, false);
87
87
  const footerToRender = isEditState ? editFooter : (isMobile ? secondaryFooter : footer);
88
88
  const primaryItems = [...primarySections, ...(primaryFooter ? [primaryFooter] : [])].flatMap(e => (0, navUtils_1.collectNavItems)(e));
89
- const editListItems = childrenArray.find(child => { var _a; return ((_a = child.type) === null || _a === void 0 ? void 0 : _a.name) === "NavEditSection"; });
89
+ const editListItems = childrenArray.find(child => { var _a; return ((_a = child.type) === null || _a === void 0 ? void 0 : _a.displayName) === "NavEditSection"; });
90
90
  const onSearchOpen = (0, react_1.useCallback)((isOpen) => {
91
91
  isOpen && onCollapseToggle && onCollapseToggle(false);
92
92
  setIsSearchOpen(isOpen || isMobile);
@@ -95,9 +95,9 @@ const Nav = ({ children, className, collapsed = false, onCollapseToggle, onMenuV
95
95
  onIsMobileMenuOpenToggle && onIsMobileMenuOpenToggle(!isMobileMenuOpen);
96
96
  }, [isMobileMenuOpen, onIsMobileMenuOpenToggle]);
97
97
  const onEditStateToggle = (0, react_1.useCallback)((isEdit) => {
98
- isEdit && onCollapseToggle && onCollapseToggle(false);
98
+ isEdit && !isMobile && onCollapseToggle && onCollapseToggle(false);
99
99
  editListItems && editFooter && setIsEditState(isEdit);
100
- }, [onCollapseToggle, setIsEditState, editListItems, editFooter]);
100
+ }, [onCollapseToggle, setIsEditState, editListItems, editFooter, isMobile]);
101
101
  (0, react_1.useEffect)(() => {
102
102
  const wasMobile = prevIsMobileRef.current;
103
103
  prevIsMobileRef.current = isMobile;
@@ -144,6 +144,6 @@ const Nav = ({ children, className, collapsed = false, onCollapseToggle, onMenuV
144
144
  : sectionsToRender.map((section, index) => ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [(0, react_1.cloneElement)(section, {
145
145
  className: (0, classNames_1.classNames)(["zen-nav__section", section.props.className || ""])
146
146
  }), isMobile || index < sectionsToRender.length - 1 ? (0, jsx_runtime_1.jsx)(navDivider_1.NavDivider, {}) : null] }, index))) }), footerToRender] })
147
- : null, mobileBarContainer && isMobile && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(navMobileBar_1.NavMobileBar, { onMenuToggle: onMobileMenuToggle, isMenuOpen: isMobileMenuOpen, children: editListItems ? editListItems : primaryItems }), mobileBarContainer)] });
147
+ : null, mobileBarContainer && isMobile && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(navMobileBar_1.NavMobileBar, { onMenuToggle: onMobileMenuToggle, isMenuOpen: isMobileMenuOpen, children: isEditState ? editListItems : primaryItems }), mobileBarContainer)] });
148
148
  };
149
149
  exports.Nav = Nav;
@@ -1,3 +1,6 @@
1
1
  import "./navEditSection.less";
2
2
  import { IZenComponentProps } from "../../commonHelpers/zenComponent";
3
- export declare const NavEditSection: ({ children, className }: IZenComponentProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const NavEditSection: {
4
+ ({ children, className }: IZenComponentProps): import("react/jsx-runtime").JSX.Element;
5
+ displayName: string;
6
+ };
@@ -5,3 +5,4 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const classNames_1 = require("../../commonHelpers/classNames/classNames");
6
6
  const NavEditSection = ({ children, className }) => (0, jsx_runtime_1.jsx)("div", { className: (0, classNames_1.classNames)(["zen-nav-edit-section", className || ""]), children: children });
7
7
  exports.NavEditSection = NavEditSection;
8
+ exports.NavEditSection.displayName = "NavEditSection";
@@ -14,8 +14,10 @@ const collapsedItemsControl_1 = require("../header/components/collapsedItemsCont
14
14
  const pageHeaderButton_1 = require("./pageHeaderButton");
15
15
  const pageHeaderMenu_1 = require("./pageHeaderMenu");
16
16
  const pageHeaderHelpers_1 = require("./pageHeaderHelpers");
17
- const usePortal_1 = require("../commonHelpers/hooks/usePortal");
17
+ const react_dom_1 = require("react-dom");
18
+ const zen_1 = require("../utils/zen");
18
19
  const PageHeaderActions = ({ className = "", children }) => {
20
+ var _a, _b;
19
21
  const isMobile = (0, useMobile_1.useMobile)();
20
22
  const childrenArray = (0, react_1.useMemo)(() => (0, pageHeaderHelpers_1.getItemsFromFragments)(
21
23
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -32,10 +34,10 @@ const PageHeaderActions = ({ className = "", children }) => {
32
34
  }), [childrenArray]);
33
35
  const moreButton = (0, react_1.useMemo)(() => ((0, jsx_runtime_1.jsx)(collapsedItemsControl_1.PageToolbarCollapsedItemsControl, { className: "zen-page-header-component__actions-more", children: nonFittingElements }, "page-header-more-actions-key")), [nonFittingElements]);
34
36
  const actionsContent = childrenArray.length ? ((0, jsx_runtime_1.jsxs)("div", { className: (0, classNames_1.classNames)(["zen-page-header-component__actions", isMobile ? "zen-page-header-component__actions--mobile-portal" : "", className]), children: [nonFittingElements.length > 0 ? moreButton : null, fittingElements] })) : null;
35
- const portal = (0, usePortal_1.usePortal)(actionsContent);
36
37
  // For mobile, render actions in a portal at the bottom center of viewport
37
38
  if (isMobile && actionsContent) {
38
- return portal;
39
+ const modalRoot = ((_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.fullscreenElement) || ((_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.body);
40
+ return (0, react_dom_1.createPortal)(actionsContent, modalRoot);
39
41
  }
40
42
  return actionsContent;
41
43
  };
@@ -17,9 +17,9 @@ const useFadeComponent_1 = require("../utils/useFadeComponent");
17
17
  const useMobile_1 = require("../commonHelpers/hooks/useMobile");
18
18
  const isAlertTarget_1 = require("../alert/utils/isAlertTarget");
19
19
  const isToastTarget_1 = require("../toast/utils/isToastTarget");
20
- const usePortal_1 = require("../commonHelpers/hooks/usePortal");
21
20
  const useClientReady_1 = require("../commonHelpers/hooks/useClientReady");
22
21
  const zen_1 = require("../utils/zen");
22
+ const react_dom_1 = require("react-dom");
23
23
  /* eslint-enable @typescript-eslint/naming-convention */
24
24
  const isChildPopup = (target, stopElement) => {
25
25
  var _a;
@@ -31,9 +31,7 @@ const isChildPopup = (target, stopElement) => {
31
31
  if (parentPopup === stopElement || parentSidePanel === stopElement) {
32
32
  return true;
33
33
  }
34
- const popupTrigger = parentPopup
35
- ? (_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-popup-id='${parentPopup.id}']`)
36
- : undefined;
34
+ const popupTrigger = parentPopup ? (_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-popup-id='${parentPopup.id}']`) : undefined;
37
35
  if (!popupTrigger) {
38
36
  return false;
39
37
  }
@@ -106,31 +104,21 @@ const SidePanel = ({ label, className, id, isOpen, onHidePanel, children, trigge
106
104
  onHidePanel(SidePanelCloseReason.ClickOutside, dataShieldId);
107
105
  return;
108
106
  }
109
- const isGroupsFilterBackButton = [
110
- "zen-groups-filter-menu__currently-selected-button",
111
- "zen-groups-filter-menu__action-button-back"
112
- ]
113
- .some((groupsFilterButton) => e.target.classList.contains(groupsFilterButton));
107
+ const isGroupsFilterBackButton = ["zen-groups-filter-menu__currently-selected-button", "zen-groups-filter-menu__action-button-back"].some(groupsFilterButton => e.target.classList.contains(groupsFilterButton));
114
108
  const isOpenAdvancedDialog = ((_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.querySelector(".zen-advanced-groups-filter")) !== null;
115
109
  const isOpenDropdownMobile = (_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.querySelector(".zen-dropdown--mobile");
116
110
  const isOpenPeriodPicker = (_c = zen_1.zen.document) === null || _c === void 0 ? void 0 : _c.querySelector(".zen-filters-bar-period-picker__popup");
117
111
  const isOpenTimePicker = (_d = zen_1.zen.document) === null || _d === void 0 ? void 0 : _d.querySelector(".zen-time-picker__popup");
118
112
  const isOpenYearPicker = (_e = zen_1.zen.document) === null || _e === void 0 ? void 0 : _e.querySelector(".zen-parallel-selection-popup");
119
113
  const openedCustomComponents = (_f = zen_1.zen.document) === null || _f === void 0 ? void 0 : _f.querySelectorAll(`.${exports.CUSTOM_POPUP_COMPONENT_CLASSNAME}`);
120
- const isClickInChildPopup = (0, exports.isChildPopup)(e.target, sidePanelRef.current)
121
- || isOpenDropdownMobile && (0, isChildOf_1.isChildOf)(e.target, isOpenDropdownMobile)
122
- || isOpenPeriodPicker && (0, isChildOf_1.isChildOf)(e.target, isOpenPeriodPicker)
123
- || isOpenPeriodPicker && isOpenTimePicker && (0, isChildOf_1.isChildOf)(e.target, isOpenTimePicker)
124
- || isOpenPeriodPicker && isOpenYearPicker && (0, isChildOf_1.isChildOf)(e.target, isOpenYearPicker)
125
- || (openedCustomComponents === null || openedCustomComponents === void 0 ? void 0 : openedCustomComponents.length) && Array.from(openedCustomComponents).some(el => (0, isChildOf_1.isChildOf)(e.target, el));
126
- const isClickInPopup = !isClickInChildPopup
127
- ? false
128
- : isClickInChildPopup;
129
- const isClickOnTrigger = triggerRef
130
- ? triggerRef.current
131
- ? e.target === triggerRef.current || (0, isChildOf_1.isChildOf)(e.target, triggerRef.current)
132
- : false
133
- : false;
114
+ const isClickInChildPopup = (0, exports.isChildPopup)(e.target, sidePanelRef.current) ||
115
+ (isOpenDropdownMobile && (0, isChildOf_1.isChildOf)(e.target, isOpenDropdownMobile)) ||
116
+ (isOpenPeriodPicker && (0, isChildOf_1.isChildOf)(e.target, isOpenPeriodPicker)) ||
117
+ (isOpenPeriodPicker && isOpenTimePicker && (0, isChildOf_1.isChildOf)(e.target, isOpenTimePicker)) ||
118
+ (isOpenPeriodPicker && isOpenYearPicker && (0, isChildOf_1.isChildOf)(e.target, isOpenYearPicker)) ||
119
+ ((openedCustomComponents === null || openedCustomComponents === void 0 ? void 0 : openedCustomComponents.length) && Array.from(openedCustomComponents).some(el => (0, isChildOf_1.isChildOf)(e.target, el)));
120
+ const isClickInPopup = !isClickInChildPopup ? false : isClickInChildPopup;
121
+ const isClickOnTrigger = triggerRef ? (triggerRef.current ? e.target === triggerRef.current || (0, isChildOf_1.isChildOf)(e.target, triggerRef.current) : false) : false;
134
122
  const isAlert = (0, isAlertTarget_1.isAlertTarget)(e);
135
123
  const isToast = (0, isToastTarget_1.isToastTarget)(e);
136
124
  if (isClickInPopup || isClickOnTrigger || isGroupsFilterBackButton || isOpenAdvancedDialog || isAlert || isToast) {
@@ -156,32 +144,22 @@ const SidePanel = ({ label, className, id, isOpen, onHidePanel, children, trigge
156
144
  (0, react_1.useEffect)(() => {
157
145
  setIsOpen(isOpen);
158
146
  }, [isOpen, setIsOpen]);
159
- const positioningClass = panelPosition === "left"
160
- ? "zen-side-panel--left-positioned"
161
- : panelPosition === "right" ? "zen-side-panel--right-positioned" : "zen-side-panel--bottom-positioned";
162
- const memoizedChildForRender = (0, react_1.useMemo)(() => isOpen || renderComponent ? children : null, [children, isOpen, renderComponent]);
147
+ const positioningClass = panelPosition === "left" ? "zen-side-panel--left-positioned" : panelPosition === "right" ? "zen-side-panel--right-positioned" : "zen-side-panel--bottom-positioned";
148
+ const memoizedChildForRender = (0, react_1.useMemo)(() => (isOpen || renderComponent ? children : null), [children, isOpen, renderComponent]);
163
149
  const memoizedStyles = (0, react_1.useMemo)(() => {
164
150
  if (width && !isMobile && panelPosition !== "bottom") {
165
151
  return { style: { width: (0, exports.formatWidth)(width) } };
166
152
  }
167
153
  return {};
168
154
  }, [width, isMobile, panelPosition]);
169
- const portalContainer = ((_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.fullscreenElement) || ((_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.body);
170
- const portal = (0, usePortal_1.usePortal)((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: sidePanelRef, id: popupId }, memoizedStyles, { role: "dialog", "aria-label": label, onTransitionEnd: handleTransitionEnd, className: (0, classNames_1.classNames)([
171
- "zen-side-panel",
172
- driveClassName || "",
173
- dark ? "zen-dark" : "",
174
- showContent ? "zen-side-panel--shown" : "",
175
- positioningClass,
176
- className !== null && className !== void 0 ? className : ""
177
- ]), children: memoizedChildForRender })), portalContainer);
178
155
  if (!renderComponent && !isOpen) {
179
156
  return null;
180
157
  }
181
158
  if (!isClientReady) {
182
159
  return undefined;
183
160
  }
184
- return portal;
161
+ const portalContainer = ((_a = zen_1.zen.document) === null || _a === void 0 ? void 0 : _a.fullscreenElement) || ((_b = zen_1.zen.document) === null || _b === void 0 ? void 0 : _b.body);
162
+ return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", Object.assign({ ref: sidePanelRef, id: popupId }, memoizedStyles, { role: "dialog", "aria-label": label, onTransitionEnd: handleTransitionEnd, className: (0, classNames_1.classNames)(["zen-side-panel", driveClassName || "", dark ? "zen-dark" : "", showContent ? "zen-side-panel--shown" : "", positioningClass, className !== null && className !== void 0 ? className : ""]), children: memoizedChildForRender })), portalContainer);
185
163
  };
186
164
  exports.SidePanel = SidePanel;
187
165
  exports.SidePanel.Cell = sidePanelCell_1.SidePanelCell;
@@ -8,5 +8,5 @@ export interface IDialog {
8
8
  }
9
9
  /**
10
10
  * @deprecated - use Modal instead
11
- */
11
+ */
12
12
  export declare const Dialog: ({ isOpen, children, isElementVisible }: IDialog) => import("react").ReactPortal | null;
@@ -5,16 +5,15 @@ import { isFocusable } from "./dialogHelpers";
5
5
  import { themeContext } from "../utils/theme/themeContext";
6
6
  import { classNames } from "../commonHelpers/classNames/classNames";
7
7
  import { useBodyScroll } from "../utils/useBodyScroll";
8
- import { usePortal } from "../commonHelpers/hooks/usePortal";
9
8
  import { useClientReady } from "../commonHelpers/hooks/useClientReady";
10
9
  import { zen } from "../utils/zen";
10
+ import { createPortal } from "react-dom";
11
11
  /**
12
12
  * @deprecated - use Modal instead
13
- */
13
+ */
14
14
  export const Dialog = ({ isOpen, children, isElementVisible }) => {
15
15
  var _a, _b, _c;
16
16
  const lastActiveOutsideElement = useRef((_a = zen.document) === null || _a === void 0 ? void 0 : _a.activeElement);
17
- const modalRoot = ((_b = zen.document) === null || _b === void 0 ? void 0 : _b.fullscreenElement) || ((_c = zen.document) === null || _c === void 0 ? void 0 : _c.body);
18
17
  const { dark } = useContext(themeContext);
19
18
  const { resetScroll } = useBodyScroll();
20
19
  const isClientReady = useClientReady();
@@ -42,10 +41,10 @@ export const Dialog = ({ isOpen, children, isElementVisible }) => {
42
41
  }, [isClientReady, isOpen, resetScroll]);
43
42
  const labeledId = useId();
44
43
  const darkClass = dark ? "zen-dark" : "";
45
- const createDialog = (id) => _jsxs("div", { className: classNames(["zen-dialog", darkClass]), "aria-modal": "true", role: "dialog", "aria-labelledby": labeledId, style: { top: `${zen.pageYOffset || 0}px` }, children: [_jsx(DialogContent, Object.assign({}, children.props, { labeledId: id, isElementVisible: isElementVisible })), _jsx("div", { className: "zen-dialog__shield" })] });
46
- const portal = usePortal(isOpen && isValidElement(children) ? createDialog(labeledId) : null, modalRoot, "ModalPortal");
44
+ const createDialog = id => (_jsxs("div", { className: classNames(["zen-dialog", darkClass]), "aria-modal": "true", role: "dialog", "aria-labelledby": labeledId, style: { top: `${zen.pageYOffset || 0}px` }, children: [_jsx(DialogContent, Object.assign({}, children.props, { labeledId: id, isElementVisible: isElementVisible })), _jsx("div", { className: "zen-dialog__shield" })] }));
47
45
  if (!isClientReady) {
48
46
  return null;
49
47
  }
50
- return portal;
48
+ const modalRoot = ((_b = zen.document) === null || _b === void 0 ? void 0 : _b.fullscreenElement) || ((_c = zen.document) === null || _c === void 0 ? void 0 : _c.body);
49
+ return createPortal(isOpen && isValidElement(children) ? createDialog(labeledId) : null, modalRoot);
51
50
  };
@@ -7,9 +7,9 @@ import { ToastRaw } from "../toastRaw/toastRaw";
7
7
  import { classNames } from "../commonHelpers/classNames/classNames";
8
8
  import { getAlertAnimation } from "./utils/getAlertAnimation";
9
9
  import { getToastAnimation } from "./utils/getToastAnimation";
10
- import { usePortal } from "../commonHelpers/hooks/usePortal";
11
10
  import { useClientReady } from "../commonHelpers/hooks/useClientReady";
12
11
  import { zen } from "../utils/zen";
12
+ import { createPortal } from "react-dom";
13
13
  export const FeedbackContainer = () => {
14
14
  var _a, _b;
15
15
  const { alerts, removeAlert, toasts, removeToast, activeFeedback, removedAlertId, removedToastId, mode } = React.useContext(FeedbackContext);
@@ -32,22 +32,22 @@ export const FeedbackContainer = () => {
32
32
  prevAlertsLength.current = alerts.length;
33
33
  prevToastsLength.current = toasts.length;
34
34
  }, [alerts.length, toasts.length]);
35
- const alertsToRender = useMemo(() => alerts.map((alert, indx) => _jsx(AlertRaw, { id: alert.id, header: alert.header, text: alert.text, isOpen: true, onClose: () => {
35
+ const alertsToRender = useMemo(() => alerts.map((alert, indx) => (_jsx(AlertRaw, { id: alert.id, header: alert.header, text: alert.text, isOpen: true, onClose: () => {
36
36
  removeAlert(alert.id);
37
37
  removedAlertId.current = indx;
38
38
  alert.onClose();
39
- }, type: alert.type, animation: alert.animation || (sameAlertsLength ? null : getAlertAnimation(isAlertAdded, indx, removedAlertId.current, isMobile, activeFeedback)), buttons: alert.buttons, className: alert.className }, alert.id)), [alerts, isMobile, isAlertAdded, removeAlert, activeFeedback, sameAlertsLength, removedAlertId]);
39
+ }, type: alert.type, animation: alert.animation || (sameAlertsLength ? null : getAlertAnimation(isAlertAdded, indx, removedAlertId.current, isMobile, activeFeedback)), buttons: alert.buttons, className: alert.className }, alert.id))), [alerts, isMobile, isAlertAdded, removeAlert, activeFeedback, sameAlertsLength, removedAlertId]);
40
40
  const alertClasses = useMemo(() => classNames(["zen-alerts", isMobile ? "zen-alerts--mobile" : ""]), [isMobile]);
41
41
  const toastClasses = useMemo(() => classNames(["zen-toasts", isMobile ? "zen-toasts--mobile" : ""]), [isMobile]);
42
- const toastsToRender = useMemo(() => toasts.map((toast, indx, arr) => _jsx(ToastRaw, { id: toast.id, animation: toast.animation || (sameToastsLength ? null : getToastAnimation(isToastAdded, indx, removedToastId.current, arr.length, isMobile, activeFeedback)), header: toast.header, showSeconds: toast.showSeconds, className: toast.className, isOpen: true, onClose: () => {
42
+ const toastsToRender = useMemo(() => toasts.map((toast, indx, arr) => (_jsx(ToastRaw, { id: toast.id, animation: toast.animation || (sameToastsLength ? null : getToastAnimation(isToastAdded, indx, removedToastId.current, arr.length, isMobile, activeFeedback)), header: toast.header, showSeconds: toast.showSeconds, className: toast.className, isOpen: true, onClose: () => {
43
43
  removeToast(toast.id);
44
44
  removedToastId.current = indx;
45
45
  toast.onClose();
46
- }, type: toast.type, hasIcon: toast.hasIcon, action: toast.action }, toast.id)), [toasts, sameToastsLength, isToastAdded, removedToastId, isMobile, activeFeedback, removeToast]);
47
- const alertsPortal = usePortal(_jsx("div", { className: alertClasses, children: alertsToRender }), (_a = zen.document) === null || _a === void 0 ? void 0 : _a.body);
48
- const toastsPortal = usePortal(_jsx("div", { className: toastClasses, children: toastsToRender }), (_b = zen.document) === null || _b === void 0 ? void 0 : _b.body);
46
+ }, type: toast.type, hasIcon: toast.hasIcon, action: toast.action }, toast.id))), [toasts, sameToastsLength, isToastAdded, removedToastId, isMobile, activeFeedback, removeToast]);
49
47
  if (!isClientReady) {
50
48
  return null;
51
49
  }
52
- return _jsxs(_Fragment, { children: [!isAPIMode && alertsPortal, !isAPIMode && toastsPortal] });
50
+ const alertsPortal = ((_a = zen.document) === null || _a === void 0 ? void 0 : _a.body) ? createPortal(_jsx("div", { className: alertClasses, children: alertsToRender }), zen.document.body) : null;
51
+ const toastsPortal = ((_b = zen.document) === null || _b === void 0 ? void 0 : _b.body) ? createPortal(_jsx("div", { className: toastClasses, children: toastsToRender }), zen.document.body) : null;
52
+ return (_jsxs(_Fragment, { children: [!isAPIMode && alertsPortal, !isAPIMode && toastsPortal] }));
53
53
  };
@@ -100,7 +100,7 @@ export const useDragAndDrop = (containerRef, onChangeOrder, marksClassNames, onB
100
100
  }
101
101
  }, [containerRef, getPlaceholder, removePlaceholders, onBeforeDragOver, cssMarks.general, cssMarks.placeholder, cssMarks.dragging]);
102
102
  const onDragStart = useCallback((e) => {
103
- var _a, _b, _c, _d;
103
+ var _a, _b, _c, _d, _e;
104
104
  e.preventDefault();
105
105
  const listItemElement = findElement(e.currentTarget, cssMarks.general);
106
106
  if (!listItemElement) {
@@ -144,7 +144,7 @@ export const useDragAndDrop = (containerRef, onChangeOrder, marksClassNames, onB
144
144
  }
145
145
  };
146
146
  const onDragEnd = () => {
147
- var _a, _b, _c, _d;
147
+ var _a, _b, _c, _d, _e;
148
148
  if (dragImageRef.current) {
149
149
  dragImageRef.current.remove();
150
150
  dragImageRef.current = null;
@@ -164,11 +164,13 @@ export const useDragAndDrop = (containerRef, onChangeOrder, marksClassNames, onB
164
164
  onChangeOrder(startPosition, endPosition);
165
165
  }
166
166
  (_c = zen.document) === null || _c === void 0 ? void 0 : _c.body.removeEventListener("pointerup", onDragEnd, false);
167
- (_d = zen.document) === null || _d === void 0 ? void 0 : _d.removeEventListener("mouseleave", onDragEnd);
167
+ (_d = zen.document) === null || _d === void 0 ? void 0 : _d.body.removeEventListener("pointercancel", onDragEnd, false);
168
+ (_e = zen.document) === null || _e === void 0 ? void 0 : _e.removeEventListener("mouseleave", onDragEnd);
168
169
  };
169
170
  (_b = zen.document) === null || _b === void 0 ? void 0 : _b.body.addEventListener("pointermove", dragMoveRef.current, false);
170
171
  (_c = zen.document) === null || _c === void 0 ? void 0 : _c.body.addEventListener("pointerup", onDragEnd, false);
171
- (_d = zen.document) === null || _d === void 0 ? void 0 : _d.addEventListener("mouseleave", onDragEnd);
172
+ (_d = zen.document) === null || _d === void 0 ? void 0 : _d.body.addEventListener("pointercancel", onDragEnd, false);
173
+ (_e = zen.document) === null || _e === void 0 ? void 0 : _e.addEventListener("mouseleave", onDragEnd);
172
174
  }, [cancelMoveScroll, containerRef, moveScroll, onChangeOrder, removePlaceholders, setPlaceholder, cssMarks.general, cssMarks.placeholder, cssMarks.dragging, cssMarks.dragged]);
173
175
  return { onDragStart };
174
176
  };
package/esm/nav/nav.js CHANGED
@@ -83,7 +83,7 @@ export const Nav = ({ children, className, collapsed = false, onCollapseToggle,
83
83
  const primaryFooter = footer && filterPrimaryNavItems(footer, false);
84
84
  const footerToRender = isEditState ? editFooter : (isMobile ? secondaryFooter : footer);
85
85
  const primaryItems = [...primarySections, ...(primaryFooter ? [primaryFooter] : [])].flatMap(e => collectNavItems(e));
86
- const editListItems = childrenArray.find(child => { var _a; return ((_a = child.type) === null || _a === void 0 ? void 0 : _a.name) === "NavEditSection"; });
86
+ const editListItems = childrenArray.find(child => { var _a; return ((_a = child.type) === null || _a === void 0 ? void 0 : _a.displayName) === "NavEditSection"; });
87
87
  const onSearchOpen = useCallback((isOpen) => {
88
88
  isOpen && onCollapseToggle && onCollapseToggle(false);
89
89
  setIsSearchOpen(isOpen || isMobile);
@@ -92,9 +92,9 @@ export const Nav = ({ children, className, collapsed = false, onCollapseToggle,
92
92
  onIsMobileMenuOpenToggle && onIsMobileMenuOpenToggle(!isMobileMenuOpen);
93
93
  }, [isMobileMenuOpen, onIsMobileMenuOpenToggle]);
94
94
  const onEditStateToggle = useCallback((isEdit) => {
95
- isEdit && onCollapseToggle && onCollapseToggle(false);
95
+ isEdit && !isMobile && onCollapseToggle && onCollapseToggle(false);
96
96
  editListItems && editFooter && setIsEditState(isEdit);
97
- }, [onCollapseToggle, setIsEditState, editListItems, editFooter]);
97
+ }, [onCollapseToggle, setIsEditState, editListItems, editFooter, isMobile]);
98
98
  useEffect(() => {
99
99
  const wasMobile = prevIsMobileRef.current;
100
100
  prevIsMobileRef.current = isMobile;
@@ -141,5 +141,5 @@ export const Nav = ({ children, className, collapsed = false, onCollapseToggle,
141
141
  : sectionsToRender.map((section, index) => (_jsxs(Fragment, { children: [cloneElement(section, {
142
142
  className: classNames(["zen-nav__section", section.props.className || ""])
143
143
  }), isMobile || index < sectionsToRender.length - 1 ? _jsx(NavDivider, {}) : null] }, index))) }), footerToRender] })
144
- : null, mobileBarContainer && isMobile && createPortal(_jsx(NavMobileBar, { onMenuToggle: onMobileMenuToggle, isMenuOpen: isMobileMenuOpen, children: editListItems ? editListItems : primaryItems }), mobileBarContainer)] });
144
+ : null, mobileBarContainer && isMobile && createPortal(_jsx(NavMobileBar, { onMenuToggle: onMobileMenuToggle, isMenuOpen: isMobileMenuOpen, children: isEditState ? editListItems : primaryItems }), mobileBarContainer)] });
145
145
  };
@@ -1,3 +1,6 @@
1
1
  import "./navEditSection.less";
2
2
  import { IZenComponentProps } from "../../commonHelpers/zenComponent";
3
- export declare const NavEditSection: ({ children, className }: IZenComponentProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const NavEditSection: {
4
+ ({ children, className }: IZenComponentProps): import("react/jsx-runtime").JSX.Element;
5
+ displayName: string;
6
+ };
@@ -1,3 +1,4 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { classNames } from "../../commonHelpers/classNames/classNames";
3
3
  export const NavEditSection = ({ children, className }) => _jsx("div", { className: classNames(["zen-nav-edit-section", className || ""]), children: children });
4
+ NavEditSection.displayName = "NavEditSection";
@@ -8,8 +8,10 @@ import { PageToolbarCollapsedItemsControl } from "../header/components/collapsed
8
8
  import { PageHeaderButtonDisplayName } from "./pageHeaderButton";
9
9
  import { PageHeaderMenuDisplayName } from "./pageHeaderMenu";
10
10
  import { getItemsFromFragments } from "./pageHeaderHelpers";
11
- import { usePortal } from "../commonHelpers/hooks/usePortal";
11
+ import { createPortal } from "react-dom";
12
+ import { zen } from "../utils/zen";
12
13
  export const PageHeaderActions = ({ className = "", children }) => {
14
+ var _a, _b;
13
15
  const isMobile = useMobile();
14
16
  const childrenArray = useMemo(() => getItemsFromFragments(
15
17
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -26,10 +28,10 @@ export const PageHeaderActions = ({ className = "", children }) => {
26
28
  }), [childrenArray]);
27
29
  const moreButton = useMemo(() => (_jsx(PageToolbarCollapsedItemsControl, { className: "zen-page-header-component__actions-more", children: nonFittingElements }, "page-header-more-actions-key")), [nonFittingElements]);
28
30
  const actionsContent = childrenArray.length ? (_jsxs("div", { className: classNames(["zen-page-header-component__actions", isMobile ? "zen-page-header-component__actions--mobile-portal" : "", className]), children: [nonFittingElements.length > 0 ? moreButton : null, fittingElements] })) : null;
29
- const portal = usePortal(actionsContent);
30
31
  // For mobile, render actions in a portal at the bottom center of viewport
31
32
  if (isMobile && actionsContent) {
32
- return portal;
33
+ const modalRoot = ((_a = zen.document) === null || _a === void 0 ? void 0 : _a.fullscreenElement) || ((_b = zen.document) === null || _b === void 0 ? void 0 : _b.body);
34
+ return createPortal(actionsContent, modalRoot);
33
35
  }
34
36
  return actionsContent;
35
37
  };
@@ -14,9 +14,9 @@ import { useFadeComponent } from "../utils/useFadeComponent";
14
14
  import { useMobile } from "../commonHelpers/hooks/useMobile";
15
15
  import { isAlertTarget } from "../alert/utils/isAlertTarget";
16
16
  import { isToastTarget } from "../toast/utils/isToastTarget";
17
- import { usePortal } from "../commonHelpers/hooks/usePortal";
18
17
  import { useClientReady } from "../commonHelpers/hooks/useClientReady";
19
18
  import { zen } from "../utils/zen";
19
+ import { createPortal } from "react-dom";
20
20
  /* eslint-enable @typescript-eslint/naming-convention */
21
21
  export const isChildPopup = (target, stopElement) => {
22
22
  var _a;
@@ -28,9 +28,7 @@ export const isChildPopup = (target, stopElement) => {
28
28
  if (parentPopup === stopElement || parentSidePanel === stopElement) {
29
29
  return true;
30
30
  }
31
- const popupTrigger = parentPopup
32
- ? (_a = zen.document) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-popup-id='${parentPopup.id}']`)
33
- : undefined;
31
+ const popupTrigger = parentPopup ? (_a = zen.document) === null || _a === void 0 ? void 0 : _a.querySelector(`[data-popup-id='${parentPopup.id}']`) : undefined;
34
32
  if (!popupTrigger) {
35
33
  return false;
36
34
  }
@@ -101,31 +99,21 @@ export const SidePanel = ({ label, className, id, isOpen, onHidePanel, children,
101
99
  onHidePanel(SidePanelCloseReason.ClickOutside, dataShieldId);
102
100
  return;
103
101
  }
104
- const isGroupsFilterBackButton = [
105
- "zen-groups-filter-menu__currently-selected-button",
106
- "zen-groups-filter-menu__action-button-back"
107
- ]
108
- .some((groupsFilterButton) => e.target.classList.contains(groupsFilterButton));
102
+ const isGroupsFilterBackButton = ["zen-groups-filter-menu__currently-selected-button", "zen-groups-filter-menu__action-button-back"].some(groupsFilterButton => e.target.classList.contains(groupsFilterButton));
109
103
  const isOpenAdvancedDialog = ((_a = zen.document) === null || _a === void 0 ? void 0 : _a.querySelector(".zen-advanced-groups-filter")) !== null;
110
104
  const isOpenDropdownMobile = (_b = zen.document) === null || _b === void 0 ? void 0 : _b.querySelector(".zen-dropdown--mobile");
111
105
  const isOpenPeriodPicker = (_c = zen.document) === null || _c === void 0 ? void 0 : _c.querySelector(".zen-filters-bar-period-picker__popup");
112
106
  const isOpenTimePicker = (_d = zen.document) === null || _d === void 0 ? void 0 : _d.querySelector(".zen-time-picker__popup");
113
107
  const isOpenYearPicker = (_e = zen.document) === null || _e === void 0 ? void 0 : _e.querySelector(".zen-parallel-selection-popup");
114
108
  const openedCustomComponents = (_f = zen.document) === null || _f === void 0 ? void 0 : _f.querySelectorAll(`.${CUSTOM_POPUP_COMPONENT_CLASSNAME}`);
115
- const isClickInChildPopup = isChildPopup(e.target, sidePanelRef.current)
116
- || isOpenDropdownMobile && isChildOf(e.target, isOpenDropdownMobile)
117
- || isOpenPeriodPicker && isChildOf(e.target, isOpenPeriodPicker)
118
- || isOpenPeriodPicker && isOpenTimePicker && isChildOf(e.target, isOpenTimePicker)
119
- || isOpenPeriodPicker && isOpenYearPicker && isChildOf(e.target, isOpenYearPicker)
120
- || (openedCustomComponents === null || openedCustomComponents === void 0 ? void 0 : openedCustomComponents.length) && Array.from(openedCustomComponents).some(el => isChildOf(e.target, el));
121
- const isClickInPopup = !isClickInChildPopup
122
- ? false
123
- : isClickInChildPopup;
124
- const isClickOnTrigger = triggerRef
125
- ? triggerRef.current
126
- ? e.target === triggerRef.current || isChildOf(e.target, triggerRef.current)
127
- : false
128
- : false;
109
+ const isClickInChildPopup = isChildPopup(e.target, sidePanelRef.current) ||
110
+ (isOpenDropdownMobile && isChildOf(e.target, isOpenDropdownMobile)) ||
111
+ (isOpenPeriodPicker && isChildOf(e.target, isOpenPeriodPicker)) ||
112
+ (isOpenPeriodPicker && isOpenTimePicker && isChildOf(e.target, isOpenTimePicker)) ||
113
+ (isOpenPeriodPicker && isOpenYearPicker && isChildOf(e.target, isOpenYearPicker)) ||
114
+ ((openedCustomComponents === null || openedCustomComponents === void 0 ? void 0 : openedCustomComponents.length) && Array.from(openedCustomComponents).some(el => isChildOf(e.target, el)));
115
+ const isClickInPopup = !isClickInChildPopup ? false : isClickInChildPopup;
116
+ const isClickOnTrigger = triggerRef ? (triggerRef.current ? e.target === triggerRef.current || isChildOf(e.target, triggerRef.current) : false) : false;
129
117
  const isAlert = isAlertTarget(e);
130
118
  const isToast = isToastTarget(e);
131
119
  if (isClickInPopup || isClickOnTrigger || isGroupsFilterBackButton || isOpenAdvancedDialog || isAlert || isToast) {
@@ -151,31 +139,21 @@ export const SidePanel = ({ label, className, id, isOpen, onHidePanel, children,
151
139
  useEffect(() => {
152
140
  setIsOpen(isOpen);
153
141
  }, [isOpen, setIsOpen]);
154
- const positioningClass = panelPosition === "left"
155
- ? "zen-side-panel--left-positioned"
156
- : panelPosition === "right" ? "zen-side-panel--right-positioned" : "zen-side-panel--bottom-positioned";
157
- const memoizedChildForRender = useMemo(() => isOpen || renderComponent ? children : null, [children, isOpen, renderComponent]);
142
+ const positioningClass = panelPosition === "left" ? "zen-side-panel--left-positioned" : panelPosition === "right" ? "zen-side-panel--right-positioned" : "zen-side-panel--bottom-positioned";
143
+ const memoizedChildForRender = useMemo(() => (isOpen || renderComponent ? children : null), [children, isOpen, renderComponent]);
158
144
  const memoizedStyles = useMemo(() => {
159
145
  if (width && !isMobile && panelPosition !== "bottom") {
160
146
  return { style: { width: formatWidth(width) } };
161
147
  }
162
148
  return {};
163
149
  }, [width, isMobile, panelPosition]);
164
- const portalContainer = ((_a = zen.document) === null || _a === void 0 ? void 0 : _a.fullscreenElement) || ((_b = zen.document) === null || _b === void 0 ? void 0 : _b.body);
165
- const portal = usePortal(_jsx("div", Object.assign({ ref: sidePanelRef, id: popupId }, memoizedStyles, { role: "dialog", "aria-label": label, onTransitionEnd: handleTransitionEnd, className: classNames([
166
- "zen-side-panel",
167
- driveClassName || "",
168
- dark ? "zen-dark" : "",
169
- showContent ? "zen-side-panel--shown" : "",
170
- positioningClass,
171
- className !== null && className !== void 0 ? className : ""
172
- ]), children: memoizedChildForRender })), portalContainer);
173
150
  if (!renderComponent && !isOpen) {
174
151
  return null;
175
152
  }
176
153
  if (!isClientReady) {
177
154
  return undefined;
178
155
  }
179
- return portal;
156
+ const portalContainer = ((_a = zen.document) === null || _a === void 0 ? void 0 : _a.fullscreenElement) || ((_b = zen.document) === null || _b === void 0 ? void 0 : _b.body);
157
+ return createPortal(_jsx("div", Object.assign({ ref: sidePanelRef, id: popupId }, memoizedStyles, { role: "dialog", "aria-label": label, onTransitionEnd: handleTransitionEnd, className: classNames(["zen-side-panel", driveClassName || "", dark ? "zen-dark" : "", showContent ? "zen-side-panel--shown" : "", positioningClass, className !== null && className !== void 0 ? className : ""]), children: memoizedChildForRender })), portalContainer);
180
158
  };
181
159
  SidePanel.Cell = SidePanelCell;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geotab/zenith",
3
- "version": "3.6.2",
3
+ "version": "3.6.3-beta.0",
4
4
  "description": "Zenith components library on React",
5
5
  "main": "dist/index.js",
6
6
  "types": "esm/index.d.ts",