@dynamic-framework/ui-react 1.24.0 → 1.25.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.
- package/dist/css/dynamic-ui-non-root.css +1 -1
- package/dist/css/dynamic-ui-non-root.min.css +1 -1
- package/dist/css/dynamic-ui-root.css +1 -1
- package/dist/css/dynamic-ui-root.min.css +1 -1
- package/dist/css/dynamic-ui.css +1 -1
- package/dist/css/dynamic-ui.min.css +1 -1
- package/dist/index.esm.js +34 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -158,7 +158,35 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
|
|
|
158
158
|
openPortal,
|
|
159
159
|
closePortal,
|
|
160
160
|
}), [stack, openPortal, closePortal]);
|
|
161
|
-
|
|
161
|
+
const handleClose = React.useCallback((target) => {
|
|
162
|
+
if (target instanceof HTMLDivElement) {
|
|
163
|
+
if (target.classList.contains('portal')) {
|
|
164
|
+
if (!('bsBackdrop' in target.dataset)) {
|
|
165
|
+
closePortal();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}, [closePortal]);
|
|
170
|
+
React.useEffect(() => {
|
|
171
|
+
const keyEvent = (event) => {
|
|
172
|
+
if (event.key === 'Escape') {
|
|
173
|
+
const lastModal = document.querySelector(`#${portalName} > div > div:last-child`);
|
|
174
|
+
if (lastModal) {
|
|
175
|
+
handleClose(lastModal);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
if (stack.length !== 0) {
|
|
180
|
+
window.addEventListener('keydown', keyEvent);
|
|
181
|
+
}
|
|
182
|
+
return () => {
|
|
183
|
+
window.removeEventListener('keydown', keyEvent);
|
|
184
|
+
};
|
|
185
|
+
}, [handleClose, portalName, stack.length]);
|
|
186
|
+
return (jsxRuntime.jsxs(DPortalContext.Provider, { value: value, children: [children, created && reactDom.createPortal(
|
|
187
|
+
// eslint-disable-next-line max-len
|
|
188
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
189
|
+
jsxRuntime.jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: stack.map(({ Component, name, payload, }) => (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx("div", { className: "backdrop fade show" }), jsxRuntime.jsx(Component, { name: name, payload: payload })] }, name))) }), document.getElementById(portalName))] }));
|
|
162
190
|
}
|
|
163
191
|
function useDPortalContext() {
|
|
164
192
|
const context = React.useContext(DPortalContext);
|