orcs-design-system 2.1.31 → 3.0.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/es/GlobalStyles.js +4 -13
- package/es/SystemThemeProvider.js +0 -2
- package/es/assets/Colour/index.js +1 -1
- package/es/components/ActionsMenu/ActionsMenu.stories.js +17 -53
- package/es/components/ActionsMenu/index.js +48 -67
- package/es/components/Avatar/Avatar.stories.js +0 -6
- package/es/components/Avatar/index.js +19 -34
- package/es/components/Badge/Badge.stories.js +0 -6
- package/es/components/Badge/index.js +4 -7
- package/es/components/Box/Box.stories.js +1 -7
- package/es/components/Box/index.js +4 -13
- package/es/components/Button/Button.stories.js +0 -6
- package/es/components/Button/index.js +14 -29
- package/es/components/ButtonGroup/ButtonGroup.stories.js +0 -6
- package/es/components/ButtonGroup/ButtonGroupItem.stories.js +28 -0
- package/es/components/ButtonGroup/index.js +10 -9
- package/es/components/Card/Card.stories.js +0 -6
- package/es/components/Card/index.js +14 -24
- package/es/components/Checkbox/Checkbox.stories.js +0 -6
- package/es/components/Checkbox/index.js +10 -23
- package/es/components/DatePicker/DatePicker.stories.js +13 -43
- package/es/components/DatePicker/index.js +12 -36
- package/es/components/Divider/Divider.stories.js +0 -6
- package/es/components/Divider/index.js +6 -10
- package/es/components/Expandable/Expandable.stories.js +0 -6
- package/es/components/Expandable/index.js +16 -26
- package/es/components/Flex/Flex.stories.js +1 -34
- package/es/components/Flex/FlexItem.stories.js +23 -0
- package/es/components/Flex/index.js +5 -10
- package/es/components/Grid/Grid.stories.js +0 -6
- package/es/components/Grid/index.js +3 -6
- package/es/components/Header/Header.stories.js +7 -15
- package/es/components/Header/index.js +31 -63
- package/es/components/HeaderSimple/HeaderSimple.stories.js +0 -6
- package/es/components/HeaderSimple/index.js +9 -18
- package/es/components/Icon/Icon.stories.js +0 -6
- package/es/components/Icon/index.js +20 -35
- package/es/components/Loading/Loading.stories.js +0 -6
- package/es/components/Loading/index.js +9 -14
- package/es/components/Modal/Modal.stories.js +12 -70
- package/es/components/Modal/index.js +16 -32
- package/es/components/Notification/Notification.stories.js +0 -6
- package/es/components/Notification/index.js +18 -40
- package/es/components/Popover/Popover.stories.js +1 -7
- package/es/components/Popover/index.js +21 -30
- package/es/components/ProgressBar/ProgressBar.stories.js +0 -6
- package/es/components/ProgressBar/index.js +8 -11
- package/es/components/RadioButton/RadioButton.stories.js +0 -6
- package/es/components/RadioButton/index.js +9 -16
- package/es/components/Range/Range.stories.js +0 -6
- package/es/components/Range/index.js +7 -16
- package/es/components/Select/Select.stories.js +7 -18
- package/es/components/Select/index.js +6 -25
- package/es/components/SideNav/SideNav.stories.js +5 -20
- package/es/components/SideNav/index.js +32 -49
- package/es/components/Sidebar/Sidebar.stories.js +1 -6
- package/es/components/Sidebar/index.js +7 -17
- package/es/components/Spacer/Spacer.stories.js +82 -0
- package/es/components/Spacer/index.js +5 -10
- package/es/components/StatusDot/StatusDot.stories.js +1 -7
- package/es/components/StatusDot/index.js +4 -7
- package/es/components/StyledLink/StyledLink.stories.js +0 -6
- package/es/components/StyledLink/index.js +11 -25
- package/es/components/Tabs/Tab.stories.js +74 -0
- package/es/components/Tabs/{Tabs.stories.js → TabsContainer.stories.js} +0 -6
- package/es/components/Tabs/index.js +8 -12
- package/es/components/Tag/Tag.stories.js +6 -14
- package/es/components/Tag/index.js +16 -28
- package/es/components/TextArea/TextArea.stories.js +0 -6
- package/es/components/TextArea/index.js +18 -39
- package/es/components/TextInput/TextInput.stories.js +0 -6
- package/es/components/TextInput/index.js +14 -32
- package/es/components/Toggle/Toggle.stories.js +0 -6
- package/es/components/Toggle/index.js +10 -16
- package/es/components.test.js +1 -1
- package/es/hooks/keepInView.js +22 -30
- package/es/hooks/keypress.js +10 -14
- package/es/index.js +3 -1
- package/es/interplayIndex.js +6 -3
- package/es/systemThemeCollapsed.js +24 -20
- package/es/systemtheme.js +23 -19
- package/package.json +36 -29
package/es/GlobalStyles.js
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
|
|
3
|
-
function _templateObject() {
|
|
4
|
-
var data = _taggedTemplateLiteral(["\n/* apply a natural box layout model to all elements, but allowing components to change */\nhtml {\n box-sizing: border-box;\n line-height: 1.15;\n line-height: calc(2px + 2ex + 2px);\n}\nhtml * {\n line-height: calc(2px + 2ex + 2px);\n}\n*, *:before, *:after {\n box-sizing: inherit;\n}\nhtml,\nbody {\n height: 100%;\n width: 100%;\n margin: ", ";\n}\nbody {\n font-family: ", ";\n color: ", ";\n}\n/* set rem text size and styling */\nhtml { font-size: 62.5%; }\nbody {\n font-size: ", "; // equivalent to 16px (or 14px with collapsed theme) because of % change to html font size above\n}\nmain {\n display: flex;\n\talign-items: stretch;\n\talign-content: stretch;\n\twidth: 100%;\n}\nsection {\n height: ", ";\n width: 100%;\n overflow-y: scroll;\n}\nimg {\n border-style: none;\n}\nsmall {\n font-size: 80%;\n}\np {\n margin: ", ";\n}\nh1, h2, h3, h4, h5, h6 {\n font-weight: ", ";\n font-family: ", ";\n margin: ", ";\n}\nh1 {\n font-size: ", "\n}\nh2 {\n font-size: ", "\n}\nh3 {\n font-size: ", "\n}\nh4 {\n font-size: ", "\n}\nh5 {\n font-size: ", "\n}\nh6 {\n font-size: ", "\n}\na,\np,\nsmall,\nli,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n word-break: break-word;\n}\n"]);
|
|
5
|
-
|
|
6
|
-
_templateObject = function _templateObject() {
|
|
7
|
-
return data;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
return data;
|
|
11
|
-
}
|
|
12
|
-
|
|
2
|
+
var _templateObject;
|
|
13
3
|
import { createGlobalStyle } from "styled-components";
|
|
14
|
-
import { themeGet } from "@styled-system/theme-get";
|
|
4
|
+
import { themeGet } from "@styled-system/theme-get";
|
|
5
|
+
// GLOBAL STYLES
|
|
15
6
|
// For browser reset, setting global box sizing and font sizing etc.
|
|
16
7
|
|
|
17
|
-
var GlobalStyles = createGlobalStyle(_templateObject(), function (props) {
|
|
8
|
+
var GlobalStyles = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n/* apply a natural box layout model to all elements, but allowing components to change */\nhtml {\n box-sizing: border-box;\n line-height: 1.15;\n line-height: calc(2px + 2ex + 2px);\n}\nhtml * {\n line-height: calc(2px + 2ex + 2px);\n}\n*, *:before, *:after {\n box-sizing: inherit;\n}\nhtml,\nbody {\n height: 100%;\n width: 100%;\n margin: ", ";\n}\nbody {\n font-family: ", ";\n color: ", ";\n}\n/* set rem text size and styling */\nhtml { font-size: 62.5%; }\nbody {\n font-size: ", "; // equivalent to 16px (or 14px with collapsed theme) because of % change to html font size above\n}\nmain {\n display: flex;\n\talign-items: stretch;\n\talign-content: stretch;\n\twidth: 100%;\n}\nsection {\n height: ", ";\n width: 100%;\n overflow-y: scroll;\n}\nimg {\n border-style: none;\n}\nsmall {\n font-size: 80%;\n}\np {\n margin: ", ";\n}\nh1, h2, h3, h4, h5, h6 {\n font-weight: ", ";\n font-family: ", ";\n margin: ", ";\n}\nh1 {\n font-size: ", "\n}\nh2 {\n font-size: ", "\n}\nh3 {\n font-size: ", "\n}\nh4 {\n font-size: ", "\n}\nh5 {\n font-size: ", "\n}\nh6 {\n font-size: ", "\n}\na,\np,\nsmall,\nli,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n word-break: break-word;\n}\n"])), function (props) {
|
|
18
9
|
return themeGet("space.0")(props);
|
|
19
10
|
}, function (props) {
|
|
20
11
|
return themeGet("fonts.main")(props);
|
|
@@ -3,14 +3,12 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import { ThemeProvider } from "styled-components";
|
|
4
4
|
import { default as GlobalStyles } from "./GlobalStyles";
|
|
5
5
|
import systemtheme from "./systemtheme";
|
|
6
|
-
|
|
7
6
|
var SystemThemeProvider = function SystemThemeProvider(_ref) {
|
|
8
7
|
var children = _ref.children;
|
|
9
8
|
return /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
10
9
|
theme: systemtheme
|
|
11
10
|
}, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, null), children));
|
|
12
11
|
};
|
|
13
|
-
|
|
14
12
|
SystemThemeProvider.propTypes = {
|
|
15
13
|
children: PropTypes.node
|
|
16
14
|
};
|
|
@@ -11,7 +11,6 @@ import Icon from "../Icon";
|
|
|
11
11
|
import Box from "../Box";
|
|
12
12
|
import Button from "../Button";
|
|
13
13
|
import TextArea from "../TextArea";
|
|
14
|
-
import mdx from "./ActionsMenu.mdx";
|
|
15
14
|
export default {
|
|
16
15
|
title: "Components/ActionsMenu",
|
|
17
16
|
decorators: [function (storyFn) {
|
|
@@ -19,11 +18,6 @@ export default {
|
|
|
19
18
|
pb: "150px"
|
|
20
19
|
}, storyFn());
|
|
21
20
|
}],
|
|
22
|
-
parameters: {
|
|
23
|
-
docs: {
|
|
24
|
-
page: mdx
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
21
|
component: ActionsMenu
|
|
28
22
|
};
|
|
29
23
|
export var defaultActionsMenu = function defaultActionsMenu() {
|
|
@@ -55,43 +49,35 @@ export var leftOffsetActionsMenu = function leftOffsetActionsMenu() {
|
|
|
55
49
|
leftOffsetActionsMenu.storyName = "Left offset";
|
|
56
50
|
var MenuItems = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
57
51
|
var closeMenu = _ref.closeMenu,
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
reasons = _ref.reasons;
|
|
60
53
|
var _useState = useState(false),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
showOther = _useState2[0],
|
|
56
|
+
setShowOther = _useState2[1];
|
|
65
57
|
var _useState3 = useState(null),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
+
selectedReason = _useState4[0],
|
|
60
|
+
setSelectedReason = _useState4[1];
|
|
70
61
|
var _useState5 = useState(""),
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
+
otherReason = _useState6[0],
|
|
64
|
+
setOtherReason = _useState6[1];
|
|
75
65
|
var reset = function reset() {
|
|
76
66
|
setShowOther(false);
|
|
77
67
|
};
|
|
78
|
-
|
|
79
68
|
var resetAndCloseMenu = function resetAndCloseMenu() {
|
|
80
69
|
reset();
|
|
81
70
|
closeMenu();
|
|
82
71
|
};
|
|
83
|
-
|
|
84
72
|
useImperativeHandle(ref, function () {
|
|
85
73
|
return {
|
|
86
74
|
reset: reset
|
|
87
75
|
};
|
|
88
76
|
});
|
|
89
|
-
|
|
90
77
|
var clickOther = function clickOther() {
|
|
91
78
|
setSelectedReason("other");
|
|
92
79
|
setShowOther(true);
|
|
93
80
|
};
|
|
94
|
-
|
|
95
81
|
var setReason = function setReason(id) {
|
|
96
82
|
return function () {
|
|
97
83
|
// TODO: Make the call to back end
|
|
@@ -100,11 +86,9 @@ var MenuItems = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
100
86
|
resetAndCloseMenu();
|
|
101
87
|
};
|
|
102
88
|
};
|
|
103
|
-
|
|
104
89
|
var onOtherReasonChange = function onOtherReasonChange(e) {
|
|
105
90
|
setOtherReason(e.target.value);
|
|
106
91
|
};
|
|
107
|
-
|
|
108
92
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ActionsMenuHeading, {
|
|
109
93
|
onClick: reset,
|
|
110
94
|
canClick: showOther
|
|
@@ -113,8 +97,7 @@ var MenuItems = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
113
97
|
mr: "xs"
|
|
114
98
|
}), " Select reason"), !showOther && /*#__PURE__*/React.createElement(React.Fragment, null, reasons.map(function (_ref2) {
|
|
115
99
|
var id = _ref2.id,
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
label = _ref2.label;
|
|
118
101
|
if (id === "other") {
|
|
119
102
|
return /*#__PURE__*/React.createElement(ActionsMenuItem, {
|
|
120
103
|
key: id,
|
|
@@ -129,7 +112,6 @@ var MenuItems = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
129
112
|
size: "sm"
|
|
130
113
|
})));
|
|
131
114
|
}
|
|
132
|
-
|
|
133
115
|
return /*#__PURE__*/React.createElement(ActionsMenuItem, {
|
|
134
116
|
key: id,
|
|
135
117
|
type: "button",
|
|
@@ -173,13 +155,11 @@ var Reasons = [{
|
|
|
173
155
|
}];
|
|
174
156
|
export var advancedActionsMenu = function advancedActionsMenu() {
|
|
175
157
|
var ref = /*#__PURE__*/React.createRef(null);
|
|
176
|
-
|
|
177
158
|
var closeMenu = function closeMenu() {
|
|
178
159
|
if (ref.current) {
|
|
179
160
|
ref.current.closeMenu();
|
|
180
161
|
}
|
|
181
162
|
};
|
|
182
|
-
|
|
183
163
|
return /*#__PURE__*/React.createElement(Flex, {
|
|
184
164
|
justifyContent: "flex-end"
|
|
185
165
|
}, /*#__PURE__*/React.createElement(ActionsMenu, {
|
|
@@ -206,33 +186,26 @@ advancedActionsMenu.storyName = "Advanced Actions Menu";
|
|
|
206
186
|
export var customActionsMenu = function customActionsMenu() {
|
|
207
187
|
var AdvancedActionsMenu = function AdvancedActionsMenu() {
|
|
208
188
|
var _useState7 = useState(false),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
189
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
190
|
+
toggleState = _useState8[0],
|
|
191
|
+
setToggle = _useState8[1];
|
|
213
192
|
var menuItemsRef = useRef(null);
|
|
214
|
-
|
|
215
193
|
var closeMenu = function closeMenu() {
|
|
216
194
|
setToggle(false);
|
|
217
195
|
};
|
|
218
|
-
|
|
219
196
|
var resetAndCloseMenu = function resetAndCloseMenu() {
|
|
220
197
|
if (menuItemsRef.current) {
|
|
221
198
|
menuItemsRef.current.reset();
|
|
222
199
|
}
|
|
223
|
-
|
|
224
200
|
closeMenu();
|
|
225
201
|
};
|
|
226
|
-
|
|
227
202
|
var menuRef = useOnclickOutside(resetAndCloseMenu, {
|
|
228
203
|
disabled: !toggleState
|
|
229
204
|
});
|
|
230
|
-
|
|
231
205
|
var onToggle = function onToggle(e) {
|
|
232
206
|
e.stopPropagation();
|
|
233
207
|
setToggle(!toggleState);
|
|
234
208
|
};
|
|
235
|
-
|
|
236
209
|
return /*#__PURE__*/React.createElement("div", {
|
|
237
210
|
ref: menuRef
|
|
238
211
|
}, /*#__PURE__*/React.createElement(Flex, {
|
|
@@ -256,40 +229,32 @@ export var customActionsMenu = function customActionsMenu() {
|
|
|
256
229
|
reasons: Reasons
|
|
257
230
|
}))));
|
|
258
231
|
};
|
|
259
|
-
|
|
260
232
|
return /*#__PURE__*/React.createElement(AdvancedActionsMenu, null);
|
|
261
233
|
};
|
|
262
234
|
customActionsMenu.storyName = "Custom Actions Menu";
|
|
263
235
|
export var textButtonActionsMenu = function textButtonActionsMenu() {
|
|
264
236
|
var TextButtonActionsMenu = function TextButtonActionsMenu() {
|
|
265
237
|
var _useState9 = useState(false),
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
238
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
239
|
+
toggleState = _useState10[0],
|
|
240
|
+
setToggle = _useState10[1];
|
|
270
241
|
var menuItemsRef = useRef(null);
|
|
271
|
-
|
|
272
242
|
var closeMenu = function closeMenu() {
|
|
273
243
|
setToggle(false);
|
|
274
244
|
};
|
|
275
|
-
|
|
276
245
|
var resetAndCloseMenu = function resetAndCloseMenu() {
|
|
277
246
|
if (menuItemsRef.current) {
|
|
278
247
|
menuItemsRef.current.reset();
|
|
279
248
|
}
|
|
280
|
-
|
|
281
249
|
closeMenu();
|
|
282
250
|
};
|
|
283
|
-
|
|
284
251
|
var menuRef = useOnclickOutside(resetAndCloseMenu, {
|
|
285
252
|
disabled: !toggleState
|
|
286
253
|
});
|
|
287
|
-
|
|
288
254
|
var onToggle = function onToggle(e) {
|
|
289
255
|
e.stopPropagation();
|
|
290
256
|
setToggle(!toggleState);
|
|
291
257
|
};
|
|
292
|
-
|
|
293
258
|
return /*#__PURE__*/React.createElement("div", {
|
|
294
259
|
ref: menuRef
|
|
295
260
|
}, /*#__PURE__*/React.createElement(ActionsMenuBody, {
|
|
@@ -316,7 +281,6 @@ export var textButtonActionsMenu = function textButtonActionsMenu() {
|
|
|
316
281
|
href: "#"
|
|
317
282
|
}, "Slack")));
|
|
318
283
|
};
|
|
319
|
-
|
|
320
284
|
return /*#__PURE__*/React.createElement(TextButtonActionsMenu, null);
|
|
321
285
|
};
|
|
322
286
|
textButtonActionsMenu.storyName = "Text Button Actions Menu";
|
|
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
5
|
+
var _excluded = ["as"],
|
|
6
|
+
_excluded2 = ["theme", "onToggle", "toggleState", "direction", "menuTopPosition", "menuLeftPosition", "menuRightPosition", "menuWidth", "customTriggerComponent", "children", "ariaLabel"],
|
|
7
|
+
_excluded3 = ["children", "customTriggerComponent", "direction", "isOpen", "theme", "closeOnClick", "ariaLabel"];
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
import React, { useState, useEffect, useImperativeHandle, useCallback } from "react";
|
|
11
11
|
import styled, { css, keyframes, ThemeProvider } from "styled-components";
|
|
12
12
|
import PropTypes from "prop-types";
|
|
@@ -81,17 +81,14 @@ export var ActionsMenuHeading = styled.div.withConfig({
|
|
|
81
81
|
});
|
|
82
82
|
export var ActionsMenuItem = styled(function (props) {
|
|
83
83
|
var as = props.as,
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
86
85
|
var Component = as ? as : others.href ? "a" : "button";
|
|
87
86
|
var newProps = others;
|
|
88
|
-
|
|
89
87
|
if (Component === "button") {
|
|
90
88
|
newProps = _objectSpread(_objectSpread({}, others), {}, {
|
|
91
89
|
type: "button"
|
|
92
90
|
});
|
|
93
91
|
}
|
|
94
|
-
|
|
95
92
|
return /*#__PURE__*/React.createElement(Component, newProps);
|
|
96
93
|
}).attrs({
|
|
97
94
|
role: "listitem"
|
|
@@ -129,31 +126,28 @@ export var ActionsMenuItem = styled(function (props) {
|
|
|
129
126
|
});
|
|
130
127
|
export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
131
128
|
var theme = _ref.theme,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
129
|
+
onToggle = _ref.onToggle,
|
|
130
|
+
toggleState = _ref.toggleState,
|
|
131
|
+
direction = _ref.direction,
|
|
132
|
+
menuTopPosition = _ref.menuTopPosition,
|
|
133
|
+
menuLeftPosition = _ref.menuLeftPosition,
|
|
134
|
+
menuRightPosition = _ref.menuRightPosition,
|
|
135
|
+
menuWidth = _ref.menuWidth,
|
|
136
|
+
customTriggerComponent = _ref.customTriggerComponent,
|
|
137
|
+
children = _ref.children,
|
|
138
|
+
ariaLabel = _ref.ariaLabel,
|
|
139
|
+
props = _objectWithoutProperties(_ref, _excluded2);
|
|
144
140
|
var _useState = useState({
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
141
|
+
menuLeftPosition: menuLeftPosition,
|
|
142
|
+
menuRightPosition: menuRightPosition,
|
|
143
|
+
menuTopPosition: menuTopPosition
|
|
144
|
+
}),
|
|
145
|
+
_useState2 = _slicedToArray(_useState, 1),
|
|
146
|
+
menuPosition = _useState2[0];
|
|
152
147
|
var _useState3 = useState(direction),
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
149
|
+
inViewDirection = _useState4[0],
|
|
150
|
+
setInViewDirection = _useState4[1];
|
|
157
151
|
var setMenuPosition = useCallback(function (newDirection) {
|
|
158
152
|
if (typeof menuLeftPosition !== "undefined" || typeof menuRightPosition !== "undefined") {
|
|
159
153
|
if (menuPosition.menuLeftPosition) {
|
|
@@ -164,25 +158,20 @@ export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
|
164
158
|
menuPosition.menuRightPosition = null;
|
|
165
159
|
}
|
|
166
160
|
}
|
|
167
|
-
|
|
168
161
|
setInViewDirection(newDirection);
|
|
169
162
|
}, [menuLeftPosition, menuRightPosition, menuPosition, setInViewDirection]);
|
|
170
|
-
|
|
171
163
|
var _useKeepInView = useKeepInView({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
164
|
+
direction: direction,
|
|
165
|
+
callback: setMenuPosition
|
|
166
|
+
}),
|
|
167
|
+
_useKeepInView2 = _slicedToArray(_useKeepInView, 2),
|
|
168
|
+
ref = _useKeepInView2[0],
|
|
169
|
+
setIsShown = _useKeepInView2[1];
|
|
179
170
|
var onToggleInView = function onToggleInView(e) {
|
|
180
171
|
setIsShown(!toggleState);
|
|
181
172
|
onToggle(e);
|
|
182
173
|
};
|
|
183
|
-
|
|
184
174
|
var triggerBtn = null;
|
|
185
|
-
|
|
186
175
|
if (customTriggerComponent) {
|
|
187
176
|
triggerBtn = /*#__PURE__*/React.cloneElement(customTriggerComponent, {
|
|
188
177
|
onClick: onToggleInView,
|
|
@@ -198,7 +187,6 @@ export var ActionsMenuBody = function ActionsMenuBody(_ref) {
|
|
|
198
187
|
isOpen: toggleState
|
|
199
188
|
}));
|
|
200
189
|
}
|
|
201
|
-
|
|
202
190
|
var component = /*#__PURE__*/React.createElement(Wrapper, props, triggerBtn, /*#__PURE__*/React.createElement(Menu, {
|
|
203
191
|
isOpen: toggleState,
|
|
204
192
|
direction: inViewDirection,
|
|
@@ -228,22 +216,20 @@ ActionsMenuBody.propTypes = {
|
|
|
228
216
|
};
|
|
229
217
|
var ActionsMenu = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
230
218
|
var children = _ref2.children,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
219
|
+
customTriggerComponent = _ref2.customTriggerComponent,
|
|
220
|
+
direction = _ref2.direction,
|
|
221
|
+
_ref2$isOpen = _ref2.isOpen,
|
|
222
|
+
isOpen = _ref2$isOpen === void 0 ? false : _ref2$isOpen,
|
|
223
|
+
theme = _ref2.theme,
|
|
224
|
+
_ref2$closeOnClick = _ref2.closeOnClick,
|
|
225
|
+
closeOnClick = _ref2$closeOnClick === void 0 ? true : _ref2$closeOnClick,
|
|
226
|
+
_ref2$ariaLabel = _ref2.ariaLabel,
|
|
227
|
+
ariaLabel = _ref2$ariaLabel === void 0 ? "Options Menu" : _ref2$ariaLabel,
|
|
228
|
+
props = _objectWithoutProperties(_ref2, _excluded3);
|
|
242
229
|
var _useState5 = useState(isOpen),
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
230
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
231
|
+
toggleState = _useState6[0],
|
|
232
|
+
setToggle = _useState6[1];
|
|
247
233
|
useImperativeHandle(ref, function () {
|
|
248
234
|
return {
|
|
249
235
|
closeMenu: function closeMenu() {
|
|
@@ -255,29 +241,26 @@ var ActionsMenu = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
255
241
|
if (!closeOnClick || !toggleState) {
|
|
256
242
|
return;
|
|
257
243
|
}
|
|
258
|
-
|
|
259
244
|
var handleClicked = function handleClicked() {
|
|
260
245
|
// As the event listener is attached in capture phase, need to do this make sure the sate change are after react event cycle.
|
|
261
246
|
setTimeout(function () {
|
|
262
247
|
return setToggle(false);
|
|
263
248
|
}, 0);
|
|
264
|
-
};
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// handle click to hide menu
|
|
265
252
|
// If any of the actions are using stopPropagation(), the event will stop in the react mounting root.
|
|
266
253
|
// So use capture phase to detect anything clicked.
|
|
267
|
-
|
|
268
|
-
|
|
269
254
|
document.addEventListener("click", handleClicked, true);
|
|
270
255
|
return function () {
|
|
271
256
|
// If menu closed, unregister event listener to prevent memory leaks
|
|
272
257
|
document.removeEventListener("click", handleClicked, true);
|
|
273
258
|
};
|
|
274
259
|
}, [closeOnClick, toggleState]);
|
|
275
|
-
|
|
276
260
|
var onToggle = function onToggle(e) {
|
|
277
261
|
e.stopPropagation();
|
|
278
262
|
setToggle(!toggleState);
|
|
279
263
|
};
|
|
280
|
-
|
|
281
264
|
return /*#__PURE__*/React.createElement(ActionsMenuBody, _extends({
|
|
282
265
|
onToggle: onToggle,
|
|
283
266
|
toggleState: toggleState,
|
|
@@ -293,10 +276,8 @@ ActionsMenu.propTypes = {
|
|
|
293
276
|
customTriggerComponent: PropTypes.node,
|
|
294
277
|
closeOnClick: PropTypes.bool,
|
|
295
278
|
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
|
|
296
|
-
|
|
297
279
|
/** Specifies the colour theme */
|
|
298
280
|
theme: PropTypes.object,
|
|
299
|
-
|
|
300
281
|
/** Specifies the aria-label for the button */
|
|
301
282
|
ariaLabel: PropTypes.object
|
|
302
283
|
};
|
|
@@ -5,14 +5,8 @@ import Box from "../Box";
|
|
|
5
5
|
import Spacer from "../Spacer";
|
|
6
6
|
import StyledLink from "../StyledLink";
|
|
7
7
|
import Avatar from ".";
|
|
8
|
-
import mdx from "./Avatar.mdx";
|
|
9
8
|
export default {
|
|
10
9
|
title: "Components/Avatar",
|
|
11
|
-
parameters: {
|
|
12
|
-
docs: {
|
|
13
|
-
page: mdx
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
10
|
component: Avatar
|
|
17
11
|
};
|
|
18
12
|
export var defaultAvatar = function defaultAvatar() {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["titleLevel"],
|
|
4
|
+
_excluded2 = ["sizing", "image", "imageAlt", "initials", "title", "titleLevel", "subtitle", "subtitleContent", "type", "theme", "shape", "localTime", "uppercase", "whiteInitials"];
|
|
3
5
|
import React, { useMemo } from "react";
|
|
4
6
|
import styled, { ThemeProvider } from "styled-components";
|
|
5
7
|
import { space, layout, variant } from "styled-system";
|
|
@@ -185,8 +187,7 @@ var Shape = styled("div").withConfig({
|
|
|
185
187
|
});
|
|
186
188
|
var Title = styled(function (_ref) {
|
|
187
189
|
var titleLevel = _ref.titleLevel,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
190
191
|
var Heading = Header[titleLevel];
|
|
191
192
|
return /*#__PURE__*/React.cloneElement( /*#__PURE__*/React.createElement(Heading, null), props);
|
|
192
193
|
}).withConfig({
|
|
@@ -282,26 +283,24 @@ var LocalTime = styled(Popover).withConfig({
|
|
|
282
283
|
displayName: "Avatar__LocalTime",
|
|
283
284
|
componentId: "sc-1wtet2j-6"
|
|
284
285
|
})(["position:absolute;top:0;left:0;"]);
|
|
285
|
-
|
|
286
286
|
var Avatar = function Avatar(_ref2) {
|
|
287
287
|
var sizing = _ref2.sizing,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
288
|
+
image = _ref2.image,
|
|
289
|
+
imageAlt = _ref2.imageAlt,
|
|
290
|
+
initials = _ref2.initials,
|
|
291
|
+
title = _ref2.title,
|
|
292
|
+
_ref2$titleLevel = _ref2.titleLevel,
|
|
293
|
+
titleLevel = _ref2$titleLevel === void 0 ? "H3" : _ref2$titleLevel,
|
|
294
|
+
subtitle = _ref2.subtitle,
|
|
295
|
+
subtitleContent = _ref2.subtitleContent,
|
|
296
|
+
type = _ref2.type,
|
|
297
|
+
theme = _ref2.theme,
|
|
298
|
+
shape = _ref2.shape,
|
|
299
|
+
localTime = _ref2.localTime,
|
|
300
|
+
_ref2$uppercase = _ref2.uppercase,
|
|
301
|
+
uppercase = _ref2$uppercase === void 0 ? true : _ref2$uppercase,
|
|
302
|
+
whiteInitials = _ref2.whiteInitials,
|
|
303
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
305
304
|
var hasTitle = !!title;
|
|
306
305
|
var hasSubtitle = !!subtitle;
|
|
307
306
|
var hasSubtitleContent = !!subtitleContent;
|
|
@@ -364,47 +363,33 @@ var Avatar = function Avatar(_ref2) {
|
|
|
364
363
|
theme: theme
|
|
365
364
|
}, component) : component;
|
|
366
365
|
};
|
|
367
|
-
|
|
368
366
|
Avatar.propTypes = {
|
|
369
367
|
/** Changes the sizing of the Avatar component */
|
|
370
368
|
sizing: PropTypes.oneOf(["small", "large", "default"]),
|
|
371
|
-
|
|
372
369
|
/** Changes the shape of the Avatar component */
|
|
373
370
|
shape: PropTypes.oneOf(["square", "hexagon", "tag", "default"]),
|
|
374
|
-
|
|
375
371
|
/** Specifies the inverted type for dark backgrounds */
|
|
376
372
|
type: PropTypes.oneOf(["inverted", "default"]),
|
|
377
|
-
|
|
378
373
|
/** Specifies a source path for an image */
|
|
379
374
|
image: PropTypes.string,
|
|
380
|
-
|
|
381
375
|
/** Specifies the alt text for an image */
|
|
382
376
|
imageAlt: PropTypes.string,
|
|
383
|
-
|
|
384
377
|
/** Specifies initials of person if available */
|
|
385
378
|
initials: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
386
|
-
|
|
387
379
|
/** Specifies custom content for avatar subtitle */
|
|
388
380
|
subtitleContent: PropTypes.oneOfType([PropTypes.element, PropTypes.node]),
|
|
389
|
-
|
|
390
381
|
/** Turns white initials on for custom `Circle` backgrounds */
|
|
391
382
|
whiteInitials: PropTypes.bool,
|
|
392
|
-
|
|
393
383
|
/** Specifies whether to use uppercase for initials */
|
|
394
384
|
uppercase: PropTypes.bool,
|
|
395
|
-
|
|
396
385
|
/** Specifies title / name as just plain text, or an element like a hyperlink or react router link */
|
|
397
386
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
398
|
-
|
|
399
387
|
/** Specifies the component to wrap the heading, defaults to H3 */
|
|
400
388
|
titleLevel: PropTypes.oneOf(["H1", "H2", "H3", "H4", "H5", "H6"]),
|
|
401
|
-
|
|
402
389
|
/** Specifies subtitle / role */
|
|
403
390
|
subtitle: PropTypes.string,
|
|
404
|
-
|
|
405
391
|
/** Specifies local time */
|
|
406
392
|
localTime: PropTypes.string,
|
|
407
|
-
|
|
408
393
|
/** Specifies the colour theme */
|
|
409
394
|
theme: PropTypes.object
|
|
410
395
|
};
|
|
@@ -3,14 +3,8 @@ import Box from "../Box";
|
|
|
3
3
|
import Spacer from "../Spacer";
|
|
4
4
|
import Flex from "../Flex";
|
|
5
5
|
import Badge from ".";
|
|
6
|
-
import mdx from "./Badge.mdx";
|
|
7
6
|
export default {
|
|
8
7
|
title: "Components/Badge",
|
|
9
|
-
parameters: {
|
|
10
|
-
docs: {
|
|
11
|
-
page: mdx
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
8
|
component: Badge
|
|
15
9
|
};
|
|
16
10
|
export var defaultBadge = function defaultBadge() {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["noWrap", "children", "theme"];
|
|
3
4
|
import React from "react";
|
|
4
5
|
import styled, { ThemeProvider } from "styled-components";
|
|
5
6
|
import PropTypes from "prop-types";
|
|
@@ -78,10 +79,9 @@ var Item = styled("span").withConfig({
|
|
|
78
79
|
}, BadgeStyles);
|
|
79
80
|
export default function Badge(_ref) {
|
|
80
81
|
var noWrap = _ref.noWrap,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
children = _ref.children,
|
|
83
|
+
theme = _ref.theme,
|
|
84
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
85
85
|
var component = /*#__PURE__*/React.createElement(Item, _extends({
|
|
86
86
|
noWrap: noWrap
|
|
87
87
|
}, props), children);
|
|
@@ -92,13 +92,10 @@ export default function Badge(_ref) {
|
|
|
92
92
|
Badge.propTypes = {
|
|
93
93
|
/** Specifies badge colour. Colours are taken from the standard design system colours. */
|
|
94
94
|
variant: PropTypes.oneOf(["success", "warning", "danger", "primaryLight", "primary", "primaryDark", "secondary"]),
|
|
95
|
-
|
|
96
95
|
/** Specified whether the badge text should be able to wrap or not */
|
|
97
96
|
noWrap: PropTypes.bool,
|
|
98
|
-
|
|
99
97
|
/** The label text on the badge is passed as a child element. */
|
|
100
98
|
children: PropTypes.node,
|
|
101
|
-
|
|
102
99
|
/** Specifies the system theme. */
|
|
103
100
|
theme: PropTypes.object
|
|
104
101
|
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Box from "../Box";
|
|
3
3
|
import { P } from "../Typography";
|
|
4
|
-
import mdx from "./Box.mdx";
|
|
5
4
|
export default {
|
|
6
5
|
title: "Components/Box",
|
|
7
|
-
parameters: {
|
|
8
|
-
docs: {
|
|
9
|
-
page: mdx
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
6
|
component: Box
|
|
13
7
|
};
|
|
14
8
|
export var basicBox = function basicBox() {
|
|
@@ -57,7 +51,7 @@ export var borderRadius = function borderRadius() {
|
|
|
57
51
|
boxBorder: "default",
|
|
58
52
|
shadow: "default",
|
|
59
53
|
p: "r"
|
|
60
|
-
}, /*#__PURE__*/React.createElement(P, null, "This is a bordered Box variant with rounded corners.",
|
|
54
|
+
}, /*#__PURE__*/React.createElement(P, null, "This is a bordered Box variant with rounded corners.", /*#__PURE__*/React.createElement("code", null, "borderRadius"), " is taken from the ", /*#__PURE__*/React.createElement("code", null, "radii"), " array in", /*#__PURE__*/React.createElement("code", null, "systemtheme.js"), "."));
|
|
61
55
|
};
|
|
62
56
|
borderRadius.story = {
|
|
63
57
|
name: "Rounded corners"
|