@spaced-out/ui-design-system 0.1.6 → 0.1.7
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.7](https://github.com/spaced-out/ui-design-system/compare/v0.1.6...v0.1.7) (2023-04-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* added documentation for link ([b233ce2](https://github.com/spaced-out/ui-design-system/commit/b233ce236a2ef4d8297bf4a333cf280d24fb6c87))
|
|
11
|
+
* modal fix ([a8bcb31](https://github.com/spaced-out/ui-design-system/commit/a8bcb318f23006c502f74b569fa268c44856bb9c))
|
|
12
|
+
|
|
5
13
|
### [0.1.6](https://github.com/spaced-out/ui-design-system/compare/v0.1.5...v0.1.6) (2023-04-05)
|
|
6
14
|
|
|
7
15
|
|
|
@@ -10,6 +10,7 @@ var _reactDomInteractions = require("@floating-ui/react-dom-interactions");
|
|
|
10
10
|
var _useMountTransition = _interopRequireDefault(require("../../hooks/useMountTransition"));
|
|
11
11
|
var _motion = require("../../styles/variables/_motion");
|
|
12
12
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
13
|
+
var _helpers = require("../../utils/helpers");
|
|
13
14
|
var _Button = require("../Button/Button");
|
|
14
15
|
var _Truncate = require("../Truncate/Truncate");
|
|
15
16
|
var _ModalModule = _interopRequireDefault(require("./Modal.module.css"));
|
|
@@ -60,11 +61,12 @@ const ModalFooter = _ref3 => {
|
|
|
60
61
|
}, children)));
|
|
61
62
|
};
|
|
62
63
|
exports.ModalFooter = ModalFooter;
|
|
63
|
-
const createPortalRoot =
|
|
64
|
+
const createPortalRoot = id => {
|
|
64
65
|
const modalRoot = document.createElement('div');
|
|
65
|
-
modalRoot.setAttribute('id',
|
|
66
|
+
modalRoot.setAttribute('id', `modal-root-${id}`);
|
|
66
67
|
return modalRoot;
|
|
67
68
|
};
|
|
69
|
+
const getModalRoot = id => document.getElementById(`modal-root-${id}`);
|
|
68
70
|
const Modal = _ref4 => {
|
|
69
71
|
let {
|
|
70
72
|
classNames,
|
|
@@ -80,8 +82,9 @@ const Modal = _ref4 => {
|
|
|
80
82
|
floating,
|
|
81
83
|
context
|
|
82
84
|
} = (0, _reactDomInteractions.useFloating)();
|
|
85
|
+
const modalId = (0, _helpers.uuid)();
|
|
83
86
|
const bodyRef = React.useRef(document.querySelector('body'));
|
|
84
|
-
const portalRootRef = React.useRef(
|
|
87
|
+
const portalRootRef = React.useRef(getModalRoot(modalId) || createPortalRoot(modalId));
|
|
85
88
|
const isTransitioning = (0, _useMountTransition.default)(isOpen, parseInt(_motion.motionDurationNormal));
|
|
86
89
|
|
|
87
90
|
// Append portal root on mount
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import useMountTransition from '../../hooks/useMountTransition';
|
|
14
14
|
import {motionDurationNormal} from '../../styles/variables/_motion';
|
|
15
15
|
import classify from '../../utils/classify';
|
|
16
|
+
import {uuid} from '../../utils/helpers';
|
|
16
17
|
import {Button} from '../Button/Button';
|
|
17
18
|
import {Truncate} from '../Truncate/Truncate';
|
|
18
19
|
|
|
@@ -105,13 +106,16 @@ export const ModalFooter = ({
|
|
|
105
106
|
</>
|
|
106
107
|
);
|
|
107
108
|
|
|
108
|
-
const createPortalRoot = () => {
|
|
109
|
+
const createPortalRoot = (id: string) => {
|
|
109
110
|
const modalRoot = document.createElement('div');
|
|
110
|
-
modalRoot.setAttribute('id',
|
|
111
|
+
modalRoot.setAttribute('id', `modal-root-${id}`);
|
|
111
112
|
|
|
112
113
|
return modalRoot;
|
|
113
114
|
};
|
|
114
115
|
|
|
116
|
+
const getModalRoot = (id: string) =>
|
|
117
|
+
document.getElementById(`modal-root-${id}`);
|
|
118
|
+
|
|
115
119
|
export const Modal = ({
|
|
116
120
|
classNames,
|
|
117
121
|
children,
|
|
@@ -123,10 +127,11 @@ export const Modal = ({
|
|
|
123
127
|
initialFocus = -1,
|
|
124
128
|
}: ModalProps): React.Node => {
|
|
125
129
|
const {floating, context} = useFloating();
|
|
130
|
+
const modalId = uuid();
|
|
126
131
|
|
|
127
132
|
const bodyRef = React.useRef(document.querySelector('body'));
|
|
128
133
|
const portalRootRef = React.useRef(
|
|
129
|
-
|
|
134
|
+
getModalRoot(modalId) || createPortalRoot(modalId),
|
|
130
135
|
);
|
|
131
136
|
|
|
132
137
|
const isTransitioning = useMountTransition(
|