orcs-design-system 3.1.31 → 3.1.33
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/README.md +21 -0
- package/es/components/Modal/index.js +25 -11
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -42,6 +42,27 @@ As an alternative to `npm link` you can run `npm run dist` and then copy the `es
|
|
|
42
42
|
|
|
43
43
|
`cp -R es/ ../../../team-directory/node_modules/orcs-design-system/`
|
|
44
44
|
|
|
45
|
+
**_This has now been been made easier with using Nodemon and a custom script. Read on for how to set this up._**
|
|
46
|
+
|
|
47
|
+
### Working with orcs locally (hot reloading).
|
|
48
|
+
|
|
49
|
+
1. `cp .env.example .env`
|
|
50
|
+
2. OPTIONAL: Update `WORKING_DIR` in `.env` if orcs resides in a different working directory to your project. Else-wise Orcs will assume the project is one level up from itself.
|
|
51
|
+
3. Add any projects to `CONSUMERS` in `.env` separated by ',' e.g. `CONSUMERS=my-app,your-app,our-app`
|
|
52
|
+
4. IF APPLICABLE: Add the following to your webpack configuration
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
...
|
|
56
|
+
snapshot: {
|
|
57
|
+
managedPaths: [/^(.+?[\\/]node_modules)[\\/]((?!orcs-design-system)).*[\\/]*/]
|
|
58
|
+
}
|
|
59
|
+
...
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
5. Run `npm run dev`.
|
|
63
|
+
|
|
64
|
+
Now you can make any changes in orcs and it will build and then copy the es from the build into your project's node_modules. Run `npm install` in your project dir if you want to revert to the npm installation.
|
|
65
|
+
|
|
45
66
|
### Symlinking with `npm link`
|
|
46
67
|
|
|
47
68
|
##### We haven't had much success with this recently
|
|
@@ -4,7 +4,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
var _excluded = ["children", "width", "height", "maxWidth", "maxHeight", "minWidth", "minHeight", "overflow", "onClose", "theme", "visible", "overlayID", "modalID", "headerContent", "footerContent"];
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
6
6
|
import ReactDOM from "react-dom";
|
|
7
|
-
import useOnclickOutside from "react-cool-onclickoutside";
|
|
8
7
|
import PropTypes from "prop-types";
|
|
9
8
|
import styled, { keyframes, ThemeProvider } from "styled-components";
|
|
10
9
|
import FocusTrap from "focus-trap-react";
|
|
@@ -95,12 +94,6 @@ var Modal = function Modal(_ref) {
|
|
|
95
94
|
_useState2 = _slicedToArray(_useState, 2),
|
|
96
95
|
lastActiveElement = _useState2[0],
|
|
97
96
|
setLastActiveElement = _useState2[1];
|
|
98
|
-
var options = {
|
|
99
|
-
disabled: !visible
|
|
100
|
-
};
|
|
101
|
-
var modalRef = useOnclickOutside(function () {
|
|
102
|
-
onClose();
|
|
103
|
-
}, options);
|
|
104
97
|
var ariaLabel = useMemo(function () {
|
|
105
98
|
if (restProps.ariaLabel) {
|
|
106
99
|
return restProps.ariaLabel;
|
|
@@ -123,13 +116,35 @@ var Modal = function Modal(_ref) {
|
|
|
123
116
|
if (visible && !lastActiveElement) {
|
|
124
117
|
// Keep track of last clicked element to refocus to after dialog closes
|
|
125
118
|
setLastActiveElement(document.activeElement);
|
|
126
|
-
} else {
|
|
119
|
+
} else if (!visible) {
|
|
127
120
|
setLastActiveElement(null);
|
|
128
121
|
|
|
129
122
|
// Focus the last active element before modal open when modal is closed
|
|
130
123
|
focusLastActiveElement();
|
|
131
124
|
}
|
|
132
125
|
}, [visible, focusLastActiveElement, lastActiveElement]);
|
|
126
|
+
useEffect(function () {
|
|
127
|
+
if (!visible) return;
|
|
128
|
+
|
|
129
|
+
/* Adding onClick handler on the Overlay does not work.
|
|
130
|
+
* So we add a global listener and check if the element clicked is the
|
|
131
|
+
* overlay vida overlayID.
|
|
132
|
+
*/
|
|
133
|
+
var handler = function handler(e) {
|
|
134
|
+
if (e.target.id === overlayID) {
|
|
135
|
+
onClose();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
var eventTypes = ["touchstart", "click"];
|
|
139
|
+
eventTypes.map(function (type) {
|
|
140
|
+
window.addEventListener(type, handler, true);
|
|
141
|
+
});
|
|
142
|
+
return function () {
|
|
143
|
+
eventTypes.map(function (type) {
|
|
144
|
+
window.removeEventListener(type, handler, true);
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
}, [visible, onClose, overlayID]);
|
|
133
148
|
var component = /*#__PURE__*/React.createElement(Overlay, _extends({
|
|
134
149
|
alignItems: "center",
|
|
135
150
|
justifyContent: "center",
|
|
@@ -138,8 +153,7 @@ var Modal = function Modal(_ref) {
|
|
|
138
153
|
focusTrapOptions: {
|
|
139
154
|
onDeactivate: onClose
|
|
140
155
|
}
|
|
141
|
-
}, /*#__PURE__*/React.createElement("div",
|
|
142
|
-
ref: modalRef,
|
|
156
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
143
157
|
role: "dialog",
|
|
144
158
|
"aria-modal": "true",
|
|
145
159
|
"aria-label": ariaLabel
|
|
@@ -181,7 +195,7 @@ var Modal = function Modal(_ref) {
|
|
|
181
195
|
})), /*#__PURE__*/React.createElement(ScrollableContent, {
|
|
182
196
|
headerContent: headerContent,
|
|
183
197
|
overflow: overflow
|
|
184
|
-
}, children), footerContent && /*#__PURE__*/React.createElement(FooterContent, null, footerContent)))))
|
|
198
|
+
}, children), footerContent && /*#__PURE__*/React.createElement(FooterContent, null, footerContent)))));
|
|
185
199
|
var wrapper = visible && /*#__PURE__*/ReactDOM.createPortal(theme ? /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
186
200
|
theme: theme
|
|
187
201
|
}, component) : component, document.body);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orcs-design-system",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.33",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "18.17.1"
|
|
6
6
|
},
|
|
@@ -40,7 +40,8 @@
|
|
|
40
40
|
"build-storybook": "storybook build -s .storybook/static -o .build_storybook",
|
|
41
41
|
"deploy-storybook": "storybook-to-ghpages",
|
|
42
42
|
"playroom": "playroom start",
|
|
43
|
-
"build-playroom": "playroom build"
|
|
43
|
+
"build-playroom": "playroom build",
|
|
44
|
+
"dev": "nodemon --ignore es/ ./scripts/dev.js"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@styled-system/css": "^5.1.5",
|
|
@@ -109,7 +110,9 @@
|
|
|
109
110
|
"babel-loader": "^8.1.0",
|
|
110
111
|
"babel-plugin-react-docgen": "^4.1.0",
|
|
111
112
|
"babel-plugin-styled-components": "^1.10.7",
|
|
113
|
+
"chalk": "^4.1.0",
|
|
112
114
|
"css-loader": "^5.2.6",
|
|
115
|
+
"dotenv": "^16.4.5",
|
|
113
116
|
"eslint": "^7.16.0",
|
|
114
117
|
"eslint-config-prettier": "^7.1.0",
|
|
115
118
|
"eslint-config-react-app": "^6.0.0",
|
|
@@ -123,11 +126,13 @@
|
|
|
123
126
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
124
127
|
"identity-obj-proxy": "^3.0.0",
|
|
125
128
|
"jest": "^26.6.3",
|
|
129
|
+
"nodemon": "^3.1.0",
|
|
126
130
|
"npm-run-all": "^4.1.5",
|
|
127
131
|
"playroom": "^0.32.1",
|
|
128
132
|
"prettier": "^2.2.1",
|
|
129
133
|
"react": "^18.2.0",
|
|
130
134
|
"react-dom": "^18.2.0",
|
|
135
|
+
"shelljs": "^0.8.5",
|
|
131
136
|
"storybook": "^7.6.7",
|
|
132
137
|
"style-loader": "^2.0.0",
|
|
133
138
|
"styled-components": "^5.2.1",
|