orcs-design-system 3.1.11 → 3.1.13
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/es/components/Avatar/Avatar.stories.js +26 -17
- package/es/components/Avatar/index.js +2 -2
- package/es/components/Badge/index.js +1 -1
- package/es/components/Button/index.js +1 -1
- package/es/components/Card/index.js +9 -6
- package/es/components/Loading/index.js +1 -1
- package/es/components/Modal/Modal.stories.js +46 -5
- package/es/components/Modal/index.js +95 -8
- package/es/components/Notification/Notification.stories.js +8 -20
- package/es/components/Notification/index.js +22 -25
- package/es/components/Select/index.js +17 -0
- package/es/components/SideNav/index.js +2 -2
- package/es/components/StatusDot/index.js +12 -23
- package/es/components/StyledLink/StyledLink.stories.js +1 -1
- package/es/components/Tabs/index.js +1 -1
- package/es/components/Tag/Tag.stories.js +2 -4
- package/es/components/Tag/index.js +39 -25
- package/es/components/TextInput/index.js +1 -1
- package/es/components/Toggle/index.js +2 -2
- package/es/components/Typography/index.js +1 -1
- package/es/systemThemeCollapsed.js +31 -29
- package/es/systemtheme.js +32 -30
- package/package.json +1 -1
|
@@ -83,6 +83,7 @@ export var small = function small() {
|
|
|
83
83
|
href: "#"
|
|
84
84
|
}, "Ayden Lundgre"),
|
|
85
85
|
subtitle: "Senior Business Analyst",
|
|
86
|
+
imageAlt: "Avatar for Ayden Lundgre",
|
|
86
87
|
initials: "AL",
|
|
87
88
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png"
|
|
88
89
|
}));
|
|
@@ -93,7 +94,7 @@ export var large = function large() {
|
|
|
93
94
|
my: 4
|
|
94
95
|
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
95
96
|
sizing: "large",
|
|
96
|
-
title: "Ayden Lundgre
|
|
97
|
+
title: "Ayden Lundgre",
|
|
97
98
|
titleLevel: "H1",
|
|
98
99
|
subtitle: "Senior Business Analyst",
|
|
99
100
|
initials: "AL"
|
|
@@ -109,6 +110,7 @@ export var large = function large() {
|
|
|
109
110
|
href: "#"
|
|
110
111
|
}, "Ayden Lundgre"),
|
|
111
112
|
subtitle: "Senior Business Analyst",
|
|
113
|
+
imageAlt: "Avatar for Ayden Lundgre",
|
|
112
114
|
initials: "AL",
|
|
113
115
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png"
|
|
114
116
|
}));
|
|
@@ -134,6 +136,7 @@ export var subtitleContent = function subtitleContent() {
|
|
|
134
136
|
title: /*#__PURE__*/React.createElement(StyledLink, {
|
|
135
137
|
href: "#"
|
|
136
138
|
}, "Ayden Lundgre"),
|
|
139
|
+
imageAlt: "Avatar for Ayden Lundgre",
|
|
137
140
|
initials: "AL",
|
|
138
141
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png",
|
|
139
142
|
subtitleContent: /*#__PURE__*/React.createElement(Badge, {
|
|
@@ -146,7 +149,7 @@ export var subtitleContent = function subtitleContent() {
|
|
|
146
149
|
}, "Ayden Lundgre"),
|
|
147
150
|
initials: "AL",
|
|
148
151
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png",
|
|
149
|
-
imageAlt: "Ayden Lundgre",
|
|
152
|
+
imageAlt: "Avatar for Ayden Lundgre",
|
|
150
153
|
subtitleContent: /*#__PURE__*/React.createElement(Flex, {
|
|
151
154
|
flexWrap: "wrap"
|
|
152
155
|
}, /*#__PURE__*/React.createElement(Spacer, {
|
|
@@ -168,7 +171,7 @@ export var localTime = function localTime() {
|
|
|
168
171
|
}, "Ayden Lundgre"),
|
|
169
172
|
initials: "AL",
|
|
170
173
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png",
|
|
171
|
-
imageAlt: "Ayden Lundgre",
|
|
174
|
+
imageAlt: "Avatar for Ayden Lundgre",
|
|
172
175
|
subtitleContent: /*#__PURE__*/React.createElement(Badge, {
|
|
173
176
|
mt: "xs"
|
|
174
177
|
}, "Senior Business Analyst"),
|
|
@@ -196,7 +199,7 @@ export var inverted = function inverted() {
|
|
|
196
199
|
subtitle: "Senior Business Analyst",
|
|
197
200
|
initials: "AL",
|
|
198
201
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png",
|
|
199
|
-
imageAlt: "Ayden Lundgre"
|
|
202
|
+
imageAlt: "Avatar for Ayden Lundgre"
|
|
200
203
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
201
204
|
type: "inverted",
|
|
202
205
|
sizing: "small",
|
|
@@ -214,7 +217,7 @@ export var inverted = function inverted() {
|
|
|
214
217
|
subtitle: "Senior Business Analyst",
|
|
215
218
|
initials: "AL",
|
|
216
219
|
image: "https://uploads-ssl.webflow.com/5f4852427e784b4cada3e0d0/65389e85f6932722401c73ad_ethan.png",
|
|
217
|
-
imageAlt: "Ayden Lundgre"
|
|
220
|
+
imageAlt: "Avatar for Ayden Lundgre"
|
|
218
221
|
})));
|
|
219
222
|
};
|
|
220
223
|
inverted.storyName = "Inverted";
|
|
@@ -228,7 +231,7 @@ export var alternateShapes = function alternateShapes() {
|
|
|
228
231
|
}, "Innovation Lab"),
|
|
229
232
|
subtitle: "15 team members",
|
|
230
233
|
image: "https://images.unsplash.com/photo-1582213782179-e0d53f98f2ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80",
|
|
231
|
-
imageAlt: "
|
|
234
|
+
imageAlt: "Avatar for Innovation Lab",
|
|
232
235
|
sizing: "large"
|
|
233
236
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
234
237
|
shape: "square",
|
|
@@ -237,7 +240,7 @@ export var alternateShapes = function alternateShapes() {
|
|
|
237
240
|
}, "Innovation Lab"),
|
|
238
241
|
subtitle: "15 team members",
|
|
239
242
|
image: "https://images.unsplash.com/photo-1582213782179-e0d53f98f2ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80",
|
|
240
|
-
imageAlt: "
|
|
243
|
+
imageAlt: "Avatar for Innovation Lab"
|
|
241
244
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
242
245
|
shape: "square",
|
|
243
246
|
sizing: "small",
|
|
@@ -245,14 +248,16 @@ export var alternateShapes = function alternateShapes() {
|
|
|
245
248
|
href: "#"
|
|
246
249
|
}, "Innovation Lab"),
|
|
247
250
|
subtitle: "15 team members",
|
|
248
|
-
initials: "IL"
|
|
251
|
+
initials: "IL",
|
|
252
|
+
imageAlt: "Avatar for Innovation Lab"
|
|
249
253
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
250
254
|
shape: "square",
|
|
251
255
|
sizing: "small",
|
|
252
256
|
title: /*#__PURE__*/React.createElement(StyledLink, {
|
|
253
257
|
href: "#"
|
|
254
258
|
}, "Innovation Lab"),
|
|
255
|
-
subtitle: "15 team members"
|
|
259
|
+
subtitle: "15 team members",
|
|
260
|
+
imageAlt: "Avatar for Innovation Lab"
|
|
256
261
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
257
262
|
shape: "hexagon",
|
|
258
263
|
title: /*#__PURE__*/React.createElement(StyledLink, {
|
|
@@ -260,7 +265,7 @@ export var alternateShapes = function alternateShapes() {
|
|
|
260
265
|
}, "Innovation Lab"),
|
|
261
266
|
subtitle: "15 team members",
|
|
262
267
|
image: "https://images.unsplash.com/photo-1582213782179-e0d53f98f2ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80",
|
|
263
|
-
imageAlt: "
|
|
268
|
+
imageAlt: "Avatar for Innovation Lab",
|
|
264
269
|
sizing: "large"
|
|
265
270
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
266
271
|
shape: "hexagon",
|
|
@@ -269,7 +274,7 @@ export var alternateShapes = function alternateShapes() {
|
|
|
269
274
|
}, "Innovation Lab"),
|
|
270
275
|
subtitle: "15 team members",
|
|
271
276
|
image: "https://images.unsplash.com/photo-1582213782179-e0d53f98f2ca?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2370&q=80",
|
|
272
|
-
imageAlt: "
|
|
277
|
+
imageAlt: "Avatar for Innovation Lab"
|
|
273
278
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
274
279
|
shape: "hexagon",
|
|
275
280
|
sizing: "small",
|
|
@@ -277,14 +282,16 @@ export var alternateShapes = function alternateShapes() {
|
|
|
277
282
|
href: "#"
|
|
278
283
|
}, "Innovation Lab"),
|
|
279
284
|
subtitle: "15 team members",
|
|
280
|
-
initials: "IL"
|
|
285
|
+
initials: "IL",
|
|
286
|
+
imageAlt: "Avatar for Innovation Lab"
|
|
281
287
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
282
288
|
shape: "hexagon",
|
|
283
289
|
sizing: "small",
|
|
284
290
|
title: /*#__PURE__*/React.createElement(StyledLink, {
|
|
285
291
|
href: "#"
|
|
286
292
|
}, "Innovation Lab"),
|
|
287
|
-
subtitle: "15 team members"
|
|
293
|
+
subtitle: "15 team members",
|
|
294
|
+
imageAlt: "Avatar for Innovation Lab"
|
|
288
295
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
289
296
|
shape: "tag",
|
|
290
297
|
title: /*#__PURE__*/React.createElement(StyledLink, {
|
|
@@ -292,7 +299,7 @@ export var alternateShapes = function alternateShapes() {
|
|
|
292
299
|
}, "Javascript"),
|
|
293
300
|
subtitle: "Tagged 123 times",
|
|
294
301
|
image: "https://images.unsplash.com/photo-1627398242454-45a1465c2479?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2148&q=80",
|
|
295
|
-
imageAlt: "
|
|
302
|
+
imageAlt: "Avatar for Javascript",
|
|
296
303
|
sizing: "large"
|
|
297
304
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
298
305
|
shape: "tag",
|
|
@@ -301,7 +308,7 @@ export var alternateShapes = function alternateShapes() {
|
|
|
301
308
|
}, "Javascript"),
|
|
302
309
|
subtitle: "Tagged 123 times",
|
|
303
310
|
image: "https://images.unsplash.com/photo-1627398242454-45a1465c2479?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2148&q=80",
|
|
304
|
-
imageAlt: "
|
|
311
|
+
imageAlt: "Avatar for Javascript"
|
|
305
312
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
306
313
|
shape: "tag",
|
|
307
314
|
sizing: "small",
|
|
@@ -309,14 +316,16 @@ export var alternateShapes = function alternateShapes() {
|
|
|
309
316
|
href: "#"
|
|
310
317
|
}, "Javascript"),
|
|
311
318
|
subtitle: "Tagged 123 times",
|
|
312
|
-
initials: "JS"
|
|
319
|
+
initials: "JS",
|
|
320
|
+
imageAlt: "Avatar for Javascript"
|
|
313
321
|
}), /*#__PURE__*/React.createElement(Avatar, {
|
|
314
322
|
shape: "tag",
|
|
315
323
|
sizing: "small",
|
|
316
324
|
title: /*#__PURE__*/React.createElement(StyledLink, {
|
|
317
325
|
href: "#"
|
|
318
326
|
}, "Javascript"),
|
|
319
|
-
subtitle: "Tagged 123 times"
|
|
327
|
+
subtitle: "Tagged 123 times",
|
|
328
|
+
imageAlt: "Avatar for Javascript"
|
|
320
329
|
}));
|
|
321
330
|
};
|
|
322
331
|
alternateShapes.storyName = "Alternate Shapes";
|
|
@@ -251,7 +251,7 @@ var Subtitle = styled(Text).withConfig({
|
|
|
251
251
|
componentId: "sc-1wtet2j-5"
|
|
252
252
|
})(function (props) {
|
|
253
253
|
return css({
|
|
254
|
-
color: themeGet("colors.
|
|
254
|
+
color: themeGet("colors.greyDark")(props),
|
|
255
255
|
fontSize: themeGet("fontSizes.1")(props)
|
|
256
256
|
});
|
|
257
257
|
}, function (props) {
|
|
@@ -308,7 +308,7 @@ var Avatar = function Avatar(_ref2) {
|
|
|
308
308
|
if (imageAlt) {
|
|
309
309
|
return imageAlt;
|
|
310
310
|
} else if (typeof title === "string") {
|
|
311
|
-
return title;
|
|
311
|
+
return "Avatar for ".concat(title);
|
|
312
312
|
}
|
|
313
313
|
}, [imageAlt, title]);
|
|
314
314
|
var component = /*#__PURE__*/React.createElement(AvatarWrapper, _extends({}, props, {
|
|
@@ -47,7 +47,7 @@ var Item = styled("span").withConfig({
|
|
|
47
47
|
},
|
|
48
48
|
warning: {
|
|
49
49
|
color: themeGet("colors.warningDarkest")(props),
|
|
50
|
-
bg: themeGet("colors.
|
|
50
|
+
bg: themeGet("colors.warningLighter")(props)
|
|
51
51
|
},
|
|
52
52
|
danger: {
|
|
53
53
|
color: themeGet("colors.dangerDarkest")(props),
|
|
@@ -126,7 +126,7 @@ var StyledButton = styled("button").withConfig({
|
|
|
126
126
|
},
|
|
127
127
|
ghost: {
|
|
128
128
|
bg: themeGet("colors.primaryLightest")(props),
|
|
129
|
-
color: themeGet("colors.
|
|
129
|
+
color: themeGet("colors.primaryDark")(props),
|
|
130
130
|
borderColor: themeGet("colors.primaryLightest")(props),
|
|
131
131
|
"&:hover": {
|
|
132
132
|
bg: themeGet("colors.primaryLighter")(props),
|
|
@@ -6,7 +6,7 @@ import styled, { css, ThemeProvider } from "styled-components";
|
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
import Icon from "../Icon/";
|
|
8
8
|
import Box from "../Box/";
|
|
9
|
-
import { H3,
|
|
9
|
+
import { H3, H4 } from "../Typography";
|
|
10
10
|
import { space, layout } from "styled-system";
|
|
11
11
|
import { themeGet } from "@styled-system/theme-get";
|
|
12
12
|
var Item = styled.div.withConfig({
|
|
@@ -29,13 +29,13 @@ var Item = styled.div.withConfig({
|
|
|
29
29
|
}, function (props) {
|
|
30
30
|
return props.center ? css([",> *,> div > *{display:flex;flex-direction:column;align-items:center;}"]) : css([""]);
|
|
31
31
|
}, function (props) {
|
|
32
|
-
return props.alternate ? css(["> div:first-of-type{display:flex;justify-content:flex-start;align-items:center;}
|
|
32
|
+
return props.alternate ? css(["> div:first-of-type{display:flex;justify-content:flex-start;align-items:center;}h4{margin-left:auto;float:right;}"]) : css([""]);
|
|
33
33
|
});
|
|
34
34
|
var ChangeIcon = styled.div.withConfig({
|
|
35
35
|
displayName: "Card__ChangeIcon",
|
|
36
36
|
componentId: "sc-yfq75p-1"
|
|
37
37
|
})(["display:inline-block;width:14px;height:2px;background-size:14px 14px;background-color:", ";margin:0 0 0 ", ";", ""], function (props) {
|
|
38
|
-
return themeGet("colors.
|
|
38
|
+
return themeGet("colors.greyDark")(props);
|
|
39
39
|
}, function (props) {
|
|
40
40
|
return themeGet("space.3")(props);
|
|
41
41
|
}, function (props) {
|
|
@@ -45,11 +45,11 @@ var ChangeValue = styled.small.withConfig({
|
|
|
45
45
|
displayName: "Card__ChangeValue",
|
|
46
46
|
componentId: "sc-yfq75p-2"
|
|
47
47
|
})(["display:flex;align-items:center;font-size:", ";font-weight:", ";color:", ";margin:0 0 0 ", ";"], function (props) {
|
|
48
|
-
return themeGet("fontSizes.
|
|
48
|
+
return themeGet("fontSizes.2")(props);
|
|
49
49
|
}, function (props) {
|
|
50
50
|
return themeGet("fontWeights.0")(props);
|
|
51
51
|
}, function (props) {
|
|
52
|
-
return themeGet("colors.
|
|
52
|
+
return themeGet("colors.greyDark")(props);
|
|
53
53
|
}, function (props) {
|
|
54
54
|
return themeGet("space.3")(props);
|
|
55
55
|
});
|
|
@@ -88,7 +88,10 @@ export default function Card(_ref) {
|
|
|
88
88
|
mr: "s"
|
|
89
89
|
}) : null, title ? /*#__PURE__*/React.createElement(H3, null, title) : null, changeIcon ? /*#__PURE__*/React.createElement(ChangeIcon, {
|
|
90
90
|
changeIcon: changeIcon
|
|
91
|
-
}) : null, changeValue ? /*#__PURE__*/React.createElement(ChangeValue, null, changeValue) : null, subtitle ? /*#__PURE__*/React.createElement(
|
|
91
|
+
}) : null, changeValue ? /*#__PURE__*/React.createElement(ChangeValue, null, changeValue) : null, subtitle ? /*#__PURE__*/React.createElement(H4, {
|
|
92
|
+
fontSize: "1",
|
|
93
|
+
color: "greyDark"
|
|
94
|
+
}, subtitle) : null), /*#__PURE__*/React.createElement(Box, null, children));
|
|
92
95
|
return theme ? /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
93
96
|
theme: theme
|
|
94
97
|
}, component) : component;
|
|
@@ -45,7 +45,7 @@ export default function Loading(_ref) {
|
|
|
45
45
|
var component = /*#__PURE__*/React.createElement(LoadingWrapper, _extends({}, props, {
|
|
46
46
|
centered: centered
|
|
47
47
|
}), /*#__PURE__*/React.createElement(LoadingIcon, {
|
|
48
|
-
role: "
|
|
48
|
+
role: "img",
|
|
49
49
|
"aria-label": ariaLabel,
|
|
50
50
|
large: large,
|
|
51
51
|
inverted: inverted,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import React, { useState } from "react";
|
|
2
|
+
import React, { useRef, useState } from "react";
|
|
3
3
|
import Button from "../Button";
|
|
4
4
|
import Modal from ".";
|
|
5
5
|
import { H3, P } from "../Typography";
|
|
@@ -17,6 +17,7 @@ var Basic = function Basic() {
|
|
|
17
17
|
_useState2 = _slicedToArray(_useState, 2),
|
|
18
18
|
visible = _useState2[0],
|
|
19
19
|
setVisible = _useState2[1];
|
|
20
|
+
var button = useRef();
|
|
20
21
|
var handleOnButtonClick = function handleOnButtonClick() {
|
|
21
22
|
setVisible(true);
|
|
22
23
|
};
|
|
@@ -29,11 +30,14 @@ var Basic = function Basic() {
|
|
|
29
30
|
};
|
|
30
31
|
};
|
|
31
32
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
33
|
+
ref: button,
|
|
32
34
|
onClick: handleOnButtonClick
|
|
33
35
|
}, "Open basic modal"), /*#__PURE__*/React.createElement(Modal, {
|
|
36
|
+
ariaLabel: "Modal Name",
|
|
34
37
|
visible: visible,
|
|
35
38
|
handleOnConfirm: handleOnConfirm,
|
|
36
|
-
onClose: onToggleModal(false)
|
|
39
|
+
onClose: onToggleModal(false),
|
|
40
|
+
triggerRef: button
|
|
37
41
|
}, /*#__PURE__*/React.createElement(Spacer, {
|
|
38
42
|
mb: "r"
|
|
39
43
|
}, /*#__PURE__*/React.createElement(H3, null, "Modal Title"), /*#__PURE__*/React.createElement(P, null, "Content of the modal. Modal accepts any child components or content."))));
|
|
@@ -41,11 +45,19 @@ var Basic = function Basic() {
|
|
|
41
45
|
export var basicModal = function basicModal() {
|
|
42
46
|
return /*#__PURE__*/React.createElement(Basic, null);
|
|
43
47
|
};
|
|
48
|
+
basicModal.parameters = {
|
|
49
|
+
docs: {
|
|
50
|
+
source: {
|
|
51
|
+
code: "\nconst Basic = () => {\n const [visible, setVisible] = useState(false);\n const button = useRef();\n\n const handleOnButtonClick = () => {\n setVisible(true);\n };\n\n const handleOnConfirm = () => {\n setVisible(false);\n };\n\n const onToggleModal = (visible) => () => {\n setVisible(visible);\n };\n\n return (\n <>\n <Button ref={button} onClick={handleOnButtonClick}>\n Open basic modal\n </Button>\n <Modal\n ariaLabel=\"Modal Title\"\n visible={visible}\n handleOnConfirm={handleOnConfirm}\n onClose={onToggleModal(false)}\n triggerRef={button}\n >\n <Spacer mb=\"r\">\n <H3>Modal Title</H3>\n <P>\n Content of the modal. Modal accepts any child components or content.\n </P>\n </Spacer>\n </Modal>\n </>\n );\n};"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
44
55
|
var Advanced = function Advanced() {
|
|
45
56
|
var _useState3 = useState(false),
|
|
46
57
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
58
|
visible = _useState4[0],
|
|
48
59
|
setVisible = _useState4[1];
|
|
60
|
+
var button = useRef();
|
|
49
61
|
var handleOnButtonClick = function handleOnButtonClick() {
|
|
50
62
|
setVisible(true);
|
|
51
63
|
};
|
|
@@ -62,6 +74,7 @@ var Advanced = function Advanced() {
|
|
|
62
74
|
onClick: handleOnConfirm
|
|
63
75
|
}, "Go to full article");
|
|
64
76
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
77
|
+
ref: button,
|
|
65
78
|
onClick: handleOnButtonClick
|
|
66
79
|
}, "Open advanced modal"), /*#__PURE__*/React.createElement(Modal, {
|
|
67
80
|
maxWidth: "500px",
|
|
@@ -72,7 +85,8 @@ var Advanced = function Advanced() {
|
|
|
72
85
|
handleOnConfirm: handleOnConfirm,
|
|
73
86
|
onClose: onToggleModal(false),
|
|
74
87
|
headerContent: modalHeader,
|
|
75
|
-
footerContent: modalFooter
|
|
88
|
+
footerContent: modalFooter,
|
|
89
|
+
triggerRef: button
|
|
76
90
|
}, /*#__PURE__*/React.createElement(Spacer, {
|
|
77
91
|
my: "r"
|
|
78
92
|
}, /*#__PURE__*/React.createElement(P, null, "Content of the modal. Modal accepts any child components or content. This content will be scrollable if it exeeds the height of the modal."), /*#__PURE__*/React.createElement(P, null, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."), /*#__PURE__*/React.createElement(P, null, "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"))));
|
|
@@ -80,11 +94,19 @@ var Advanced = function Advanced() {
|
|
|
80
94
|
export var advancedModal = function advancedModal() {
|
|
81
95
|
return /*#__PURE__*/React.createElement(Advanced, null);
|
|
82
96
|
};
|
|
97
|
+
advancedModal.parameters = {
|
|
98
|
+
docs: {
|
|
99
|
+
source: {
|
|
100
|
+
code: "\nconst Advanced = () => {\n const [visible, setVisible] = useState(false);\n const button = useRef();\n\n const handleOnButtonClick = () => {\n setVisible(true);\n };\n\n const handleOnConfirm = () => {\n setVisible(false);\n };\n\n const onToggleModal = (visible) => () => {\n setVisible(visible);\n };\n\n const modalHeader = <H3>Modal Title</H3>;\n\n const modalFooter = (\n <Button onClick={handleOnConfirm}>Go to full article</Button>\n );\n\n return (\n <>\n <Button ref={button} onClick={handleOnButtonClick}>\n Open advanced modal\n </Button>\n <Modal\n maxWidth=\"500px\"\n maxHeight=\"400px\"\n height=\"90vh\"\n width=\"90vw\"\n visible={visible}\n handleOnConfirm={handleOnConfirm}\n onClose={onToggleModal(false)}\n headerContent={modalHeader}\n footerContent={modalFooter}\n triggerRef={button}\n >\n <Spacer my=\"r\">\n <P>\n Content of the modal. Modal accepts any child components or content.\n This content will be scrollable if it exeeds the height of the\n modal.\n </P>\n <P>\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do\n eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim\n ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\n aliquip ex ea commodo consequat. Duis aute irure dolor in\n reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\n culpa qui officia deserunt mollit anim id est laborum.\n </P>\n <P>\n Sed ut perspiciatis unde omnis iste natus error sit voluptatem\n accusantium doloremque laudantium, totam rem aperiam, eaque ipsa\n quae ab illo inventore veritatis et quasi architecto beatae vitae\n dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit\n aspernatur aut odit aut fugit, sed quia consequuntur magni dolores\n eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est,\n qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit,\n sed quia non numquam eius modi tempora incidunt ut labore et dolore\n magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis\n nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut\n aliquid ex ea commodi consequatur? Quis autem vel eum iure\n reprehenderit qui in ea voluptate velit esse quam nihil molestiae\n consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla\n pariatur?\n </P>\n </Spacer>\n </Modal>\n </>\n );\n};"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
83
104
|
var BasicDialogue = function BasicDialogue() {
|
|
84
105
|
var _useState5 = useState(false),
|
|
85
106
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
86
107
|
visible = _useState6[0],
|
|
87
108
|
setVisible = _useState6[1];
|
|
109
|
+
var button = useRef();
|
|
88
110
|
var handleOnButtonClick = function handleOnButtonClick() {
|
|
89
111
|
setVisible(true);
|
|
90
112
|
};
|
|
@@ -106,6 +128,7 @@ var BasicDialogue = function BasicDialogue() {
|
|
|
106
128
|
onClick: onToggleModal(false)
|
|
107
129
|
}, "Cancel")));
|
|
108
130
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
131
|
+
ref: button,
|
|
109
132
|
onClick: handleOnButtonClick,
|
|
110
133
|
variant: "danger",
|
|
111
134
|
iconLeft: true
|
|
@@ -115,7 +138,8 @@ var BasicDialogue = function BasicDialogue() {
|
|
|
115
138
|
visible: visible,
|
|
116
139
|
handleOnConfirm: handleOnConfirm,
|
|
117
140
|
onClose: onToggleModal(false),
|
|
118
|
-
footerContent: modalFooter
|
|
141
|
+
footerContent: modalFooter,
|
|
142
|
+
triggerRef: button
|
|
119
143
|
}, /*#__PURE__*/React.createElement(Spacer, {
|
|
120
144
|
mb: "r"
|
|
121
145
|
}, /*#__PURE__*/React.createElement(P, {
|
|
@@ -126,11 +150,19 @@ var BasicDialogue = function BasicDialogue() {
|
|
|
126
150
|
export var basicDialogueModal = function basicDialogueModal() {
|
|
127
151
|
return /*#__PURE__*/React.createElement(BasicDialogue, null);
|
|
128
152
|
};
|
|
153
|
+
basicDialogueModal.parameters = {
|
|
154
|
+
docs: {
|
|
155
|
+
source: {
|
|
156
|
+
code: "\nconst BasicDialogue = () => {\n const [visible, setVisible] = useState(false);\n const button = useRef();\n\n const handleOnButtonClick = () => {\n setVisible(true);\n };\n\n const handleOnConfirm = () => {\n setVisible(false);\n };\n\n const onToggleModal = (visible) => () => {\n setVisible(visible);\n };\n\n const modalFooter = (\n <Flex>\n <Spacer mr=\"s\">\n <Button onClick={handleOnConfirm} px=\"l\">\n OK\n </Button>\n <Button variant=\"ghost\" onClick={onToggleModal(false)}>\n Cancel\n </Button>\n </Spacer>\n </Flex>\n );\n\n return (\n <>\n <Button\n ref={button}\n onClick={handleOnButtonClick}\n variant=\"danger\"\n iconLeft\n >\n <Icon icon={[\"fas\", \"trash\"]} />\n Delete data\n </Button>\n <Modal\n visible={visible}\n handleOnConfirm={handleOnConfirm}\n onClose={onToggleModal(false)}\n footerContent={modalFooter}\n triggerRef={button}\n >\n <Spacer mb=\"r\">\n <P weight=\"bold\" marginBottom=\"sm\">\n This will remove all data from the application.\n </P>\n <P>Do you wish to continue?</P>\n </Spacer>\n </Modal>\n </>\n );\n};"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
129
160
|
var EditDialogue = function EditDialogue() {
|
|
130
161
|
var _useState7 = useState(false),
|
|
131
162
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
132
163
|
visible = _useState8[0],
|
|
133
164
|
setVisible = _useState8[1];
|
|
165
|
+
var button = useRef();
|
|
134
166
|
var handleOnButtonClick = function handleOnButtonClick() {
|
|
135
167
|
setVisible(true);
|
|
136
168
|
};
|
|
@@ -159,6 +191,7 @@ var EditDialogue = function EditDialogue() {
|
|
|
159
191
|
icon: ["fas", "times"]
|
|
160
192
|
}), "Cancel")));
|
|
161
193
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
|
|
194
|
+
ref: button,
|
|
162
195
|
onClick: handleOnButtonClick,
|
|
163
196
|
iconLeft: true
|
|
164
197
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -168,7 +201,8 @@ var EditDialogue = function EditDialogue() {
|
|
|
168
201
|
handleOnConfirm: handleOnConfirm,
|
|
169
202
|
onClose: onToggleModal(false),
|
|
170
203
|
headerContent: modalHeader,
|
|
171
|
-
footerContent: modalFooter
|
|
204
|
+
footerContent: modalFooter,
|
|
205
|
+
triggerRef: button
|
|
172
206
|
}, /*#__PURE__*/React.createElement(Spacer, {
|
|
173
207
|
my: "r"
|
|
174
208
|
}, /*#__PURE__*/React.createElement(TextInput, {
|
|
@@ -187,6 +221,13 @@ var EditDialogue = function EditDialogue() {
|
|
|
187
221
|
export var editDialogueModal = function editDialogueModal() {
|
|
188
222
|
return /*#__PURE__*/React.createElement(EditDialogue, null);
|
|
189
223
|
};
|
|
224
|
+
editDialogueModal.parameters = {
|
|
225
|
+
docs: {
|
|
226
|
+
source: {
|
|
227
|
+
code: "\nconst EditDialogue = () => {\n const [visible, setVisible] = useState(false);\n const button = useRef();\n\n const handleOnButtonClick = () => {\n setVisible(true);\n };\n\n const handleOnConfirm = () => {\n setVisible(false);\n };\n\n const onToggleModal = (visible) => () => {\n setVisible(visible);\n };\n\n const modalHeader = <H3>Modify Details</H3>;\n\n const modalFooter = (\n <Flex>\n <Spacer mr=\"s\">\n <Button onClick={handleOnConfirm} variant=\"success\" iconLeft>\n <Icon icon={[\"fas\", \"save\"]} />\n Save\n </Button>\n <Button variant=\"ghost\" onClick={onToggleModal(false)} iconLeft>\n <Icon icon={[\"fas\", \"times\"]} />\n Cancel\n </Button>\n </Spacer>\n </Flex>\n );\n return (\n <>\n <Button ref={button} onClick={handleOnButtonClick} iconLeft>\n <Icon icon={[\"fas\", \"edit\"]} />\n Modify Details\n </Button>\n <Modal\n visible={visible}\n handleOnConfirm={handleOnConfirm}\n onClose={onToggleModal(false)}\n headerContent={modalHeader}\n footerContent={modalFooter}\n triggerRef={button}\n >\n <Spacer my=\"r\">\n <TextInput\n id=\"textInput1\"\n key=\"textInput1\"\n type=\"text\"\n fullWidth\n label=\"Name\"\n placeholder=\"E.g. Awesome Project\"\n />\n <TextArea id=\"TextArea01\" label=\"Description\" fullWidth />\n </Spacer>\n </Modal>\n </>\n );\n};"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
190
231
|
basicModal.__docgenInfo = {
|
|
191
232
|
"description": "",
|
|
192
233
|
"methods": [],
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["children", "width", "height", "maxWidth", "maxHeight", "minWidth", "minHeight", "overflow", "onClose", "theme", "visible", "overlayID", "modalID", "headerContent", "footerContent"];
|
|
4
|
-
import React from "react";
|
|
4
|
+
var _excluded = ["children", "width", "height", "maxWidth", "maxHeight", "minWidth", "minHeight", "overflow", "onClose", "triggerRef", "theme", "visible", "overlayID", "modalID", "headerContent", "footerContent"];
|
|
5
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
5
6
|
import ReactDOM from "react-dom";
|
|
6
7
|
import useOnclickOutside from "react-cool-onclickoutside";
|
|
7
8
|
import PropTypes from "prop-types";
|
|
@@ -80,6 +81,7 @@ var Modal = function Modal(_ref) {
|
|
|
80
81
|
minHeight = _ref.minHeight,
|
|
81
82
|
overflow = _ref.overflow,
|
|
82
83
|
onClose = _ref.onClose,
|
|
84
|
+
triggerRef = _ref.triggerRef,
|
|
83
85
|
theme = _ref.theme,
|
|
84
86
|
visible = _ref.visible,
|
|
85
87
|
overlayID = _ref.overlayID,
|
|
@@ -93,14 +95,56 @@ var Modal = function Modal(_ref) {
|
|
|
93
95
|
var modalRef = useOnclickOutside(function () {
|
|
94
96
|
onClose();
|
|
95
97
|
}, options);
|
|
98
|
+
var ariaLabel = useMemo(function () {
|
|
99
|
+
if (restProps.ariaLabel) {
|
|
100
|
+
return restProps.ariaLabel;
|
|
101
|
+
} else if (typeof headerContent === "string") {
|
|
102
|
+
return headerContent;
|
|
103
|
+
}
|
|
104
|
+
}, [restProps.ariaLabel, headerContent]);
|
|
96
105
|
useKeyPress(commonKeys.ESCAPE, onClose, options);
|
|
97
106
|
useKeyPress(commonKeys.ESC, onClose, options);
|
|
107
|
+
|
|
108
|
+
// Initial focus point for keyboard navigation
|
|
109
|
+
var top = useRef();
|
|
110
|
+
|
|
111
|
+
// If bottom becomes focused then re-focus the close button
|
|
112
|
+
var bottom = useRef();
|
|
113
|
+
|
|
114
|
+
// Ref to close button
|
|
115
|
+
var button = useRef();
|
|
116
|
+
|
|
117
|
+
// Keep trak on whether its been visible
|
|
118
|
+
var _useState = useState(visible),
|
|
119
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
120
|
+
hasOpened = _useState2[0],
|
|
121
|
+
setHasOpened = _useState2[1];
|
|
122
|
+
|
|
123
|
+
// On becoming visible focus the top
|
|
124
|
+
useEffect(function () {
|
|
125
|
+
if (visible) {
|
|
126
|
+
top.current.focus();
|
|
127
|
+
setHasOpened(true);
|
|
128
|
+
} else if (hasOpened) {
|
|
129
|
+
triggerRef && triggerRef.current.focus();
|
|
130
|
+
}
|
|
131
|
+
}, [visible, hasOpened, top, triggerRef]);
|
|
98
132
|
var component = /*#__PURE__*/React.createElement(Overlay, _extends({
|
|
99
133
|
alignItems: "center",
|
|
100
134
|
justifyContent: "center",
|
|
101
135
|
id: overlayID
|
|
102
|
-
}, restProps), /*#__PURE__*/React.createElement("
|
|
103
|
-
|
|
136
|
+
}, restProps), /*#__PURE__*/React.createElement("span", {
|
|
137
|
+
tabIndex: "0",
|
|
138
|
+
ref: top,
|
|
139
|
+
onFocus: function onFocus() {
|
|
140
|
+
return bottom.current.focus();
|
|
141
|
+
}
|
|
142
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
ref: modalRef,
|
|
144
|
+
role: "dialog",
|
|
145
|
+
"aria-modal": "true",
|
|
146
|
+
"aria-label": ariaLabel,
|
|
147
|
+
tabIndex: "-1"
|
|
104
148
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
105
149
|
width: width,
|
|
106
150
|
height: height,
|
|
@@ -117,19 +161,23 @@ var Modal = function Modal(_ref) {
|
|
|
117
161
|
mr: "xl",
|
|
118
162
|
width: "100%"
|
|
119
163
|
}, headerContent), /*#__PURE__*/React.createElement(CloseButton, {
|
|
164
|
+
ref: button,
|
|
120
165
|
onClick: onClose,
|
|
121
166
|
className: "modal-close",
|
|
122
167
|
small: true,
|
|
123
|
-
px: "6px"
|
|
168
|
+
px: "6px",
|
|
169
|
+
"aria-label": "Close dialog"
|
|
124
170
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
125
171
|
icon: ["fas", "times"],
|
|
126
172
|
color: "greyDark",
|
|
127
173
|
size: "lg"
|
|
128
174
|
}))) : /*#__PURE__*/React.createElement(CloseButton, {
|
|
175
|
+
ref: button,
|
|
129
176
|
onClick: onClose,
|
|
130
177
|
className: "modal-close",
|
|
131
178
|
small: true,
|
|
132
|
-
px: "6px"
|
|
179
|
+
px: "6px",
|
|
180
|
+
"aria-label": "Close dialog"
|
|
133
181
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
134
182
|
icon: ["fas", "times"],
|
|
135
183
|
color: "greyDark",
|
|
@@ -137,7 +185,15 @@ var Modal = function Modal(_ref) {
|
|
|
137
185
|
})), /*#__PURE__*/React.createElement(ScrollableContent, {
|
|
138
186
|
headerContent: headerContent,
|
|
139
187
|
overflow: overflow
|
|
140
|
-
}, children), footerContent && /*#__PURE__*/React.createElement(FooterContent, null, footerContent)))
|
|
188
|
+
}, children), footerContent && /*#__PURE__*/React.createElement(FooterContent, null, footerContent))), /*#__PURE__*/React.createElement("span", {
|
|
189
|
+
ref: bottom,
|
|
190
|
+
tabIndex: "-1"
|
|
191
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
192
|
+
tabIndex: "0",
|
|
193
|
+
onFocus: function onFocus() {
|
|
194
|
+
return button.current.focus();
|
|
195
|
+
}
|
|
196
|
+
}));
|
|
141
197
|
var wrapper = visible && /*#__PURE__*/ReactDOM.createPortal(theme ? /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
142
198
|
theme: theme
|
|
143
199
|
}, component) : component, document.body);
|
|
@@ -168,6 +224,10 @@ Modal.propTypes = {
|
|
|
168
224
|
visible: PropTypes.bool,
|
|
169
225
|
/** Specifies the function to run on clicking X icon. Ensure that this function will close Modal through the `visible` prop */
|
|
170
226
|
onClose: PropTypes.func,
|
|
227
|
+
/** Required to re-focus keyboard navigation after closing a modal, generally a ref to the button */
|
|
228
|
+
triggerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
229
|
+
current: PropTypes.any
|
|
230
|
+
})]),
|
|
171
231
|
/** Specifies whether the Modal overflow is visible or not, default is `hidden`. If height is not enough, vertical scrollbar will be displayed (`overflow-y: auto`) */
|
|
172
232
|
overflow: PropTypes.string,
|
|
173
233
|
/** Specifies the id of the overlay element for targeting */
|
|
@@ -175,7 +235,9 @@ Modal.propTypes = {
|
|
|
175
235
|
/** Specifies the id of the modal element for targeting */
|
|
176
236
|
modalID: PropTypes.string,
|
|
177
237
|
/** Sets the theme for the Modal */
|
|
178
|
-
theme: PropTypes.object
|
|
238
|
+
theme: PropTypes.object,
|
|
239
|
+
/** Specifies the aria-label for the modal. Set this if headerContent is not defined as a string. */
|
|
240
|
+
ariaLabel: PropTypes.string
|
|
179
241
|
};
|
|
180
242
|
Modal.defaultProps = {
|
|
181
243
|
width: "350px",
|
|
@@ -322,6 +384,24 @@ Modal.__docgenInfo = {
|
|
|
322
384
|
},
|
|
323
385
|
"required": false
|
|
324
386
|
},
|
|
387
|
+
"triggerRef": {
|
|
388
|
+
"description": "Required to re-focus keyboard navigation after closing a modal, generally a ref to the button",
|
|
389
|
+
"type": {
|
|
390
|
+
"name": "union",
|
|
391
|
+
"value": [{
|
|
392
|
+
"name": "func"
|
|
393
|
+
}, {
|
|
394
|
+
"name": "shape",
|
|
395
|
+
"value": {
|
|
396
|
+
"current": {
|
|
397
|
+
"name": "any",
|
|
398
|
+
"required": false
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}]
|
|
402
|
+
},
|
|
403
|
+
"required": false
|
|
404
|
+
},
|
|
325
405
|
"overflow": {
|
|
326
406
|
"description": "Specifies whether the Modal overflow is visible or not, default is `hidden`. If height is not enough, vertical scrollbar will be displayed (`overflow-y: auto`)",
|
|
327
407
|
"type": {
|
|
@@ -335,6 +415,13 @@ Modal.__docgenInfo = {
|
|
|
335
415
|
"name": "object"
|
|
336
416
|
},
|
|
337
417
|
"required": false
|
|
418
|
+
},
|
|
419
|
+
"ariaLabel": {
|
|
420
|
+
"description": "Specifies the aria-label for the modal. Set this if headerContent is not defined as a string.",
|
|
421
|
+
"type": {
|
|
422
|
+
"name": "string"
|
|
423
|
+
},
|
|
424
|
+
"required": false
|
|
338
425
|
}
|
|
339
426
|
}
|
|
340
427
|
};
|