@kaizen/components 1.79.7 → 1.79.9
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/src/Modal/GenericModal/GenericModal.cjs +14 -6
- package/dist/esm/src/Modal/GenericModal/GenericModal.mjs +14 -6
- package/dist/styles.css +9275 -9275
- package/package.json +1 -1
- package/src/Modal/GenericModal/GenericModal.tsx +21 -6
- package/src/__next__/Button/_docs/Button--api-specification.mdx +6 -0
- package/src/__next__/Button/_docs/Button.docs.stories.tsx +29 -0
- package/src/__next__/Menu/_docs/Menu--api-specification.mdx +6 -0
- package/src/__next__/Menu/_docs/Menu.stories.tsx +29 -0
|
@@ -5,6 +5,7 @@ var ReactDOM = require('react-dom');
|
|
|
5
5
|
var react = require('@headlessui/react');
|
|
6
6
|
var classnames = require('classnames');
|
|
7
7
|
var FocusLock = require('react-focus-lock');
|
|
8
|
+
var useIsClientReady = require('../../utils/useIsClientReady/useIsClientReady.cjs');
|
|
8
9
|
var console = require('../util/console.cjs');
|
|
9
10
|
var ModalContext = require('./context/ModalContext.cjs');
|
|
10
11
|
var GenericModal_module = require('./GenericModal.module.scss.cjs');
|
|
@@ -31,6 +32,7 @@ var GenericModal = function (_a) {
|
|
|
31
32
|
var id = propsId !== null && propsId !== void 0 ? propsId : reactId;
|
|
32
33
|
var labelledByID = React.useId();
|
|
33
34
|
var describedByID = React.useId();
|
|
35
|
+
var isClientReady = useIsClientReady.useIsClientReady();
|
|
34
36
|
var _c = React.useState(null),
|
|
35
37
|
scrollLayer = _c[0],
|
|
36
38
|
setScrollLayer = _c[1];
|
|
@@ -52,6 +54,7 @@ var GenericModal = function (_a) {
|
|
|
52
54
|
}
|
|
53
55
|
};
|
|
54
56
|
var focusOnAccessibleLabel = function () {
|
|
57
|
+
if (!isClientReady) return;
|
|
55
58
|
// Check if focus already exists within the modal
|
|
56
59
|
if (modalLayer === null || modalLayer === void 0 ? void 0 : modalLayer.contains(document.activeElement)) {
|
|
57
60
|
return;
|
|
@@ -60,6 +63,7 @@ var GenericModal = function (_a) {
|
|
|
60
63
|
labelElement === null || labelElement === void 0 ? void 0 : labelElement.focus();
|
|
61
64
|
};
|
|
62
65
|
var a11yWarn = function () {
|
|
66
|
+
if (!isClientReady) return;
|
|
63
67
|
// Ensure that consumers have provided an element that labels the modal
|
|
64
68
|
// to meet ARIA accessibility guidelines.
|
|
65
69
|
if (!document.getElementById(labelledByID)) {
|
|
@@ -68,6 +72,7 @@ var GenericModal = function (_a) {
|
|
|
68
72
|
};
|
|
69
73
|
var preventBodyScroll = function () {
|
|
70
74
|
var _a;
|
|
75
|
+
if (!isClientReady) return;
|
|
71
76
|
var hasScrollbar = window.innerWidth > document.documentElement.clientWidth;
|
|
72
77
|
var scrollStyles = [GenericModal_module.unscrollable];
|
|
73
78
|
if (hasScrollbar) {
|
|
@@ -90,28 +95,31 @@ var GenericModal = function (_a) {
|
|
|
90
95
|
}, [onEscapeKeyup]);
|
|
91
96
|
var onBeforeEnterHandler = function () {
|
|
92
97
|
preventBodyScroll();
|
|
93
|
-
if (onEscapeKeyup) {
|
|
98
|
+
if (onEscapeKeyup && isClientReady) {
|
|
94
99
|
document.addEventListener('keyup', escapeKeyHandler);
|
|
95
100
|
}
|
|
96
101
|
};
|
|
97
|
-
var cleanUpAfterClose = function () {
|
|
102
|
+
var cleanUpAfterClose = React.useCallback(function () {
|
|
103
|
+
if (!isClientReady) return;
|
|
98
104
|
document.documentElement.classList.remove(GenericModal_module.unscrollable, GenericModal_module.pseudoScrollbar);
|
|
99
105
|
if (onEscapeKeyup) {
|
|
100
106
|
document.removeEventListener('keyup', escapeKeyHandler);
|
|
101
107
|
}
|
|
102
|
-
};
|
|
108
|
+
}, [escapeKeyHandler, onEscapeKeyup, isClientReady]);
|
|
103
109
|
/* Ensure sure add-on styles (e.g. unscrollable) and key event is cleaned up when the modal is unmounted*/
|
|
104
|
-
// @todo: Fix if possible - avoiding breaking in eslint upgrade
|
|
105
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
110
|
React.useEffect(function () {
|
|
107
111
|
return function () {
|
|
108
112
|
return cleanUpAfterClose();
|
|
109
113
|
};
|
|
110
|
-
}, []);
|
|
114
|
+
}, [cleanUpAfterClose]);
|
|
111
115
|
var onAfterLeaveHandler = function () {
|
|
112
116
|
cleanUpAfterClose();
|
|
113
117
|
propsOnAfterLeave === null || propsOnAfterLeave === void 0 ? void 0 : propsOnAfterLeave();
|
|
114
118
|
};
|
|
119
|
+
// Don't render portal during SSR
|
|
120
|
+
if (!isClientReady) {
|
|
121
|
+
return React__default.default.createElement(React__default.default.Fragment, null);
|
|
122
|
+
}
|
|
115
123
|
return ReactDOM.createPortal(React__default.default.createElement(react.Transition, {
|
|
116
124
|
appear: true,
|
|
117
125
|
show: isOpen,
|
|
@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom';
|
|
|
3
3
|
import { Transition } from '@headlessui/react';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import FocusLock from 'react-focus-lock';
|
|
6
|
+
import { useIsClientReady } from '../../utils/useIsClientReady/useIsClientReady.mjs';
|
|
6
7
|
import { warn } from '../util/console.mjs';
|
|
7
8
|
import { ModalContext } from './context/ModalContext.mjs';
|
|
8
9
|
import styles from './GenericModal.module.scss.mjs';
|
|
@@ -22,6 +23,7 @@ const GenericModal = /*#__PURE__*/function () {
|
|
|
22
23
|
var id = propsId !== null && propsId !== void 0 ? propsId : reactId;
|
|
23
24
|
var labelledByID = useId();
|
|
24
25
|
var describedByID = useId();
|
|
26
|
+
var isClientReady = useIsClientReady();
|
|
25
27
|
var _c = useState(null),
|
|
26
28
|
scrollLayer = _c[0],
|
|
27
29
|
setScrollLayer = _c[1];
|
|
@@ -43,6 +45,7 @@ const GenericModal = /*#__PURE__*/function () {
|
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
47
|
var focusOnAccessibleLabel = function () {
|
|
48
|
+
if (!isClientReady) return;
|
|
46
49
|
// Check if focus already exists within the modal
|
|
47
50
|
if (modalLayer === null || modalLayer === void 0 ? void 0 : modalLayer.contains(document.activeElement)) {
|
|
48
51
|
return;
|
|
@@ -51,6 +54,7 @@ const GenericModal = /*#__PURE__*/function () {
|
|
|
51
54
|
labelElement === null || labelElement === void 0 ? void 0 : labelElement.focus();
|
|
52
55
|
};
|
|
53
56
|
var a11yWarn = function () {
|
|
57
|
+
if (!isClientReady) return;
|
|
54
58
|
// Ensure that consumers have provided an element that labels the modal
|
|
55
59
|
// to meet ARIA accessibility guidelines.
|
|
56
60
|
if (!document.getElementById(labelledByID)) {
|
|
@@ -59,6 +63,7 @@ const GenericModal = /*#__PURE__*/function () {
|
|
|
59
63
|
};
|
|
60
64
|
var preventBodyScroll = function () {
|
|
61
65
|
var _a;
|
|
66
|
+
if (!isClientReady) return;
|
|
62
67
|
var hasScrollbar = window.innerWidth > document.documentElement.clientWidth;
|
|
63
68
|
var scrollStyles = [styles.unscrollable];
|
|
64
69
|
if (hasScrollbar) {
|
|
@@ -81,28 +86,31 @@ const GenericModal = /*#__PURE__*/function () {
|
|
|
81
86
|
}, [onEscapeKeyup]);
|
|
82
87
|
var onBeforeEnterHandler = function () {
|
|
83
88
|
preventBodyScroll();
|
|
84
|
-
if (onEscapeKeyup) {
|
|
89
|
+
if (onEscapeKeyup && isClientReady) {
|
|
85
90
|
document.addEventListener('keyup', escapeKeyHandler);
|
|
86
91
|
}
|
|
87
92
|
};
|
|
88
|
-
var cleanUpAfterClose = function () {
|
|
93
|
+
var cleanUpAfterClose = useCallback(function () {
|
|
94
|
+
if (!isClientReady) return;
|
|
89
95
|
document.documentElement.classList.remove(styles.unscrollable, styles.pseudoScrollbar);
|
|
90
96
|
if (onEscapeKeyup) {
|
|
91
97
|
document.removeEventListener('keyup', escapeKeyHandler);
|
|
92
98
|
}
|
|
93
|
-
};
|
|
99
|
+
}, [escapeKeyHandler, onEscapeKeyup, isClientReady]);
|
|
94
100
|
/* Ensure sure add-on styles (e.g. unscrollable) and key event is cleaned up when the modal is unmounted*/
|
|
95
|
-
// @todo: Fix if possible - avoiding breaking in eslint upgrade
|
|
96
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
101
|
useEffect(function () {
|
|
98
102
|
return function () {
|
|
99
103
|
return cleanUpAfterClose();
|
|
100
104
|
};
|
|
101
|
-
}, []);
|
|
105
|
+
}, [cleanUpAfterClose]);
|
|
102
106
|
var onAfterLeaveHandler = function () {
|
|
103
107
|
cleanUpAfterClose();
|
|
104
108
|
propsOnAfterLeave === null || propsOnAfterLeave === void 0 ? void 0 : propsOnAfterLeave();
|
|
105
109
|
};
|
|
110
|
+
// Don't render portal during SSR
|
|
111
|
+
if (!isClientReady) {
|
|
112
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
113
|
+
}
|
|
106
114
|
return /*#__PURE__*/createPortal(/*#__PURE__*/React.createElement(Transition, {
|
|
107
115
|
appear: true,
|
|
108
116
|
show: isOpen,
|