@activecollab/components 2.0.528 → 2.0.530
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/dist/cjs/components/ConfirmDialog/ConfirmDialog.js +1 -1
- package/dist/cjs/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/cjs/components/GlobalPortal/GlobalPortal.js +10 -4
- package/dist/cjs/components/GlobalPortal/GlobalPortal.js.map +1 -1
- package/dist/cjs/components/ModalRoot/ModalRoot.js +5 -4
- package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/cjs/components/ModalRoot/modalRootStack.js +21 -13
- package/dist/cjs/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/cjs/components/ModalRoot/useModalStackHost.js +43 -5
- package/dist/cjs/components/ModalRoot/useModalStackHost.js.map +1 -1
- package/dist/cjs/components/Window/Window.js +9 -1
- package/dist/cjs/components/Window/Window.js.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js +1 -1
- package/dist/esm/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts +6 -4
- package/dist/esm/components/GlobalPortal/GlobalPortal.d.ts.map +1 -1
- package/dist/esm/components/GlobalPortal/GlobalPortal.js +9 -4
- package/dist/esm/components/GlobalPortal/GlobalPortal.js.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/ModalRoot.js +5 -4
- package/dist/esm/components/ModalRoot/ModalRoot.js.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts +8 -4
- package/dist/esm/components/ModalRoot/modalRootStack.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/modalRootStack.js +15 -11
- package/dist/esm/components/ModalRoot/modalRootStack.js.map +1 -1
- package/dist/esm/components/ModalRoot/useModalStackHost.d.ts +4 -2
- package/dist/esm/components/ModalRoot/useModalStackHost.d.ts.map +1 -1
- package/dist/esm/components/ModalRoot/useModalStackHost.js +36 -5
- package/dist/esm/components/ModalRoot/useModalStackHost.js.map +1 -1
- package/dist/esm/components/Window/Window.d.ts.map +1 -1
- package/dist/esm/components/Window/Window.js +9 -1
- package/dist/esm/components/Window/Window.js.map +1 -1
- package/dist/index.js +86 -27
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17163,13 +17163,21 @@
|
|
|
17163
17163
|
return document.removeEventListener("keydown", handleBodyKeyDown);
|
|
17164
17164
|
};
|
|
17165
17165
|
}, [disableCloseOnEsc, onClose]);
|
|
17166
|
+
|
|
17167
|
+
// A native modal dialog this window is not inside sits above it in the top layer and leaves it inert, such as a
|
|
17168
|
+
// confirmation rendered outside the window's React tree. Focus in that dialog is the dialog's, so the lock lets it be.
|
|
17169
|
+
var isFocusForLock = React.useCallback(function (node) {
|
|
17170
|
+
var modalDialog = node.closest("dialog[open]");
|
|
17171
|
+
return !modalDialog || modalDialog.contains(innerRef.current);
|
|
17172
|
+
}, []);
|
|
17166
17173
|
var handleClick = React.useCallback(function (event) {
|
|
17167
17174
|
event === null || event === void 0 || event.stopPropagation();
|
|
17168
17175
|
typeof onClick === "function" && onClick(event);
|
|
17169
17176
|
}, [onClick]);
|
|
17170
17177
|
return /*#__PURE__*/React__default["default"].createElement(Portal, null, /*#__PURE__*/React__default["default"].createElement(FocusLock__default["default"], {
|
|
17171
17178
|
returnFocus: disableReturnFocus ? false : returnFocus,
|
|
17172
|
-
disabled: disableFocusLock
|
|
17179
|
+
disabled: disableFocusLock,
|
|
17180
|
+
whiteList: isFocusForLock
|
|
17173
17181
|
}, /*#__PURE__*/React__default["default"].createElement(reactRemoveScroll.RemoveScroll, {
|
|
17174
17182
|
forwardProps: true,
|
|
17175
17183
|
ref: handleRef,
|
|
@@ -19125,26 +19133,34 @@
|
|
|
19125
19133
|
var _stack;
|
|
19126
19134
|
return ((_stack = stack[stack.length - 1]) === null || _stack === void 0 ? void 0 : _stack.id) === id;
|
|
19127
19135
|
};
|
|
19136
|
+
var isInside = function isInside(entry, outside) {
|
|
19137
|
+
return !!outside && !!entry.overlayRoot && outside.contains(entry.overlayRoot);
|
|
19138
|
+
};
|
|
19128
19139
|
|
|
19129
|
-
/**
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
|
|
19140
|
+
/**
|
|
19141
|
+
* The overlay root of the top open modal root, where content that must stay above every modal goes. A modal root
|
|
19142
|
+
* whose overlay root sits inside outside, one opened from that content, is skipped, since content cannot move into
|
|
19143
|
+
* itself.
|
|
19144
|
+
*/
|
|
19145
|
+
var getTopModalOverlayRoot = function getTopModalOverlayRoot(outside) {
|
|
19146
|
+
var _stack$filter$pop$ove, _stack$filter$pop;
|
|
19147
|
+
return (_stack$filter$pop$ove = (_stack$filter$pop = stack.filter(function (entry) {
|
|
19148
|
+
return !isInside(entry, outside);
|
|
19149
|
+
}).pop()) === null || _stack$filter$pop === void 0 ? void 0 : _stack$filter$pop.overlayRoot) !== null && _stack$filter$pop$ove !== void 0 ? _stack$filter$pop$ove : null;
|
|
19133
19150
|
};
|
|
19134
19151
|
|
|
19135
19152
|
/** The id of the top open modal root, or undefined when none is open. */
|
|
19136
19153
|
var getTopModalRootId = function getTopModalRootId() {
|
|
19137
|
-
var
|
|
19138
|
-
return (
|
|
19154
|
+
var _stack2;
|
|
19155
|
+
return (_stack2 = stack[stack.length - 1]) === null || _stack2 === void 0 ? void 0 : _stack2.id;
|
|
19139
19156
|
};
|
|
19140
19157
|
|
|
19141
|
-
/** The overlay root of the top modal root among those opened no later than the given one. */
|
|
19142
|
-
var getModalOverlayRootUpTo = function getModalOverlayRootUpTo(id) {
|
|
19143
|
-
var
|
|
19144
|
-
|
|
19145
|
-
return entry.id <= id;
|
|
19146
|
-
});
|
|
19147
|
-
return (_entries$overlayRoot = (_entries = entries[entries.length - 1]) === null || _entries === void 0 ? void 0 : _entries.overlayRoot) !== null && _entries$overlayRoot !== void 0 ? _entries$overlayRoot : null;
|
|
19158
|
+
/** The overlay root of the top modal root among those opened no later than the given one, skipping as above. */
|
|
19159
|
+
var getModalOverlayRootUpTo = function getModalOverlayRootUpTo(id, outside) {
|
|
19160
|
+
var _stack$filter$pop$ove2, _stack$filter$pop2;
|
|
19161
|
+
return (_stack$filter$pop$ove2 = (_stack$filter$pop2 = stack.filter(function (entry) {
|
|
19162
|
+
return entry.id <= id && !isInside(entry, outside);
|
|
19163
|
+
}).pop()) === null || _stack$filter$pop2 === void 0 ? void 0 : _stack$filter$pop2.overlayRoot) !== null && _stack$filter$pop$ove2 !== void 0 ? _stack$filter$pop$ove2 : null;
|
|
19148
19164
|
};
|
|
19149
19165
|
var subscribeToModalRoots = function subscribeToModalRoots(listener) {
|
|
19150
19166
|
listeners.add(listener);
|
|
@@ -19221,17 +19237,18 @@
|
|
|
19221
19237
|
}, [onClose]);
|
|
19222
19238
|
|
|
19223
19239
|
// The entry joins the stack with every showModal, so an owner that opens the dialog again from onClose, on the
|
|
19224
|
-
// same node, gets it back.
|
|
19240
|
+
// same node, gets it back. It joins after showModal, so content that moves into the overlay root lands where it
|
|
19241
|
+
// is rendered and can get its scroll positions back.
|
|
19225
19242
|
React.useLayoutEffect(function () {
|
|
19226
19243
|
if (!open || !dialog) {
|
|
19227
19244
|
return;
|
|
19228
19245
|
}
|
|
19229
|
-
if (stackIdRef.current === undefined) {
|
|
19230
|
-
stackIdRef.current = pushModalRoot(overlayRootRef.current);
|
|
19231
|
-
}
|
|
19232
19246
|
if (!dialog.open) {
|
|
19233
19247
|
dialog.showModal();
|
|
19234
19248
|
}
|
|
19249
|
+
if (stackIdRef.current === undefined) {
|
|
19250
|
+
stackIdRef.current = pushModalRoot(overlayRootRef.current);
|
|
19251
|
+
}
|
|
19235
19252
|
}, [open, dialog]);
|
|
19236
19253
|
|
|
19237
19254
|
// A layout effect, so the entry leaves the stack before an unmount removes the dialog and its overlay root.
|
|
@@ -19794,7 +19811,7 @@
|
|
|
19794
19811
|
size = _ref.size,
|
|
19795
19812
|
height = _ref.height,
|
|
19796
19813
|
_ref$native = _ref.native,
|
|
19797
|
-
native = _ref$native === void 0 ?
|
|
19814
|
+
native = _ref$native === void 0 ? true : _ref$native;
|
|
19798
19815
|
var _useState = React.useState(false),
|
|
19799
19816
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19800
19817
|
confirmed = _useState2[0],
|
|
@@ -28586,10 +28603,48 @@
|
|
|
28586
28603
|
})(["@media (min-width:640px){display:none;}"]);
|
|
28587
28604
|
StyledHeader$2.displayName = "StyledHeader";
|
|
28588
28605
|
|
|
28606
|
+
var getScrollPositions = function getScrollPositions(host) {
|
|
28607
|
+
return Array.from(host.querySelectorAll("*")).filter(function (element) {
|
|
28608
|
+
return element.scrollTop || element.scrollLeft;
|
|
28609
|
+
}).map(function (element) {
|
|
28610
|
+
return {
|
|
28611
|
+
element,
|
|
28612
|
+
top: element.scrollTop,
|
|
28613
|
+
left: element.scrollLeft
|
|
28614
|
+
};
|
|
28615
|
+
});
|
|
28616
|
+
};
|
|
28617
|
+
|
|
28618
|
+
/**
|
|
28619
|
+
* moveBefore keeps the state of the moved content. appendChild resets the scroll positions inside the host and drops
|
|
28620
|
+
* the focus, so without moveBefore they are put back after the move.
|
|
28621
|
+
*/
|
|
28622
|
+
var moveHost = function moveHost(host, target) {
|
|
28623
|
+
if (host.isConnected && target.moveBefore) {
|
|
28624
|
+
target.moveBefore(host, null);
|
|
28625
|
+
return;
|
|
28626
|
+
}
|
|
28627
|
+
var scrollPositions = host.isConnected ? getScrollPositions(host) : [];
|
|
28628
|
+
var focused = host.contains(document.activeElement) ? document.activeElement : null;
|
|
28629
|
+
target.appendChild(host);
|
|
28630
|
+
scrollPositions.forEach(function (_ref) {
|
|
28631
|
+
var element = _ref.element,
|
|
28632
|
+
top = _ref.top,
|
|
28633
|
+
left = _ref.left;
|
|
28634
|
+
element.scrollTop = top;
|
|
28635
|
+
element.scrollLeft = left;
|
|
28636
|
+
});
|
|
28637
|
+
focused === null || focused === void 0 || focused.focus({
|
|
28638
|
+
preventScroll: true
|
|
28639
|
+
});
|
|
28640
|
+
};
|
|
28641
|
+
|
|
28589
28642
|
/**
|
|
28590
28643
|
* Keeps a host node in the overlay root of the top open modal, or of the top one opened no later than
|
|
28591
|
-
* upToModalRootId, and in document.body while there is none.
|
|
28592
|
-
*
|
|
28644
|
+
* upToModalRootId, and in document.body while there is none. A modal opened from the content of the host is not
|
|
28645
|
+
* counted, since its overlay root is inside the host. The node moves as modals open and close, so content
|
|
28646
|
+
* portalled into it never remounts and keeps its scroll positions and focus, and it leaves the page on unmount or
|
|
28647
|
+
* when the host changes. Returns whether the
|
|
28593
28648
|
* host is in the page, which it is from a layout effect after the first render with it.
|
|
28594
28649
|
*/
|
|
28595
28650
|
var useModalStackHost = function useModalStackHost(host, upToModalRootId) {
|
|
@@ -28602,10 +28657,10 @@
|
|
|
28602
28657
|
return undefined;
|
|
28603
28658
|
}
|
|
28604
28659
|
var place = function place() {
|
|
28605
|
-
var
|
|
28606
|
-
var target = (
|
|
28660
|
+
var _ref2;
|
|
28661
|
+
var target = (_ref2 = upToModalRootId === undefined ? getTopModalOverlayRoot(host) : getModalOverlayRootUpTo(upToModalRootId, host)) !== null && _ref2 !== void 0 ? _ref2 : document.body;
|
|
28607
28662
|
if (host.parentElement !== target) {
|
|
28608
|
-
|
|
28663
|
+
moveHost(host, target);
|
|
28609
28664
|
}
|
|
28610
28665
|
};
|
|
28611
28666
|
place();
|
|
@@ -32296,9 +32351,11 @@
|
|
|
32296
32351
|
};
|
|
32297
32352
|
|
|
32298
32353
|
/**
|
|
32299
|
-
* Renders content that must stay above every modal, such as toasts
|
|
32300
|
-
* so the content follows the top open modal into its overlay root and comes back to
|
|
32354
|
+
* Renders content that must stay above every modal, such as toasts, a chat or a feedback prompt. Everything outside
|
|
32355
|
+
* an open native modal is inert, so the content follows the top open modal into its overlay root and comes back to
|
|
32356
|
+
* document.body once none is open.
|
|
32301
32357
|
* The host node moves instead of the content being portalled again, so the content never remounts on the way.
|
|
32358
|
+
* Portals from the content, such as a menu or a tooltip, render into the host too, so they move along with it.
|
|
32302
32359
|
* The host is attached in a layout effect after the content mounts, so content that measures itself on mount reads
|
|
32303
32360
|
* no size there, and a transition that runs while the host moves restarts.
|
|
32304
32361
|
*/
|
|
@@ -32308,7 +32365,9 @@
|
|
|
32308
32365
|
_useState2 = _slicedToArray(_useState, 1),
|
|
32309
32366
|
host = _useState2[0];
|
|
32310
32367
|
useModalStackHost(host);
|
|
32311
|
-
return /*#__PURE__*/ReactDOM__default["default"].createPortal(
|
|
32368
|
+
return /*#__PURE__*/ReactDOM__default["default"].createPortal(/*#__PURE__*/React__default["default"].createElement(PortalContainerProvider, {
|
|
32369
|
+
value: host
|
|
32370
|
+
}, children), host);
|
|
32312
32371
|
};
|
|
32313
32372
|
GlobalPortal.displayName = "GlobalPortal";
|
|
32314
32373
|
|