orcs-design-system 3.2.4 → 3.2.6
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 +1 -31
- package/es/SystemThemeProvider.js +11 -5
- package/es/assets/Colour/Colour.stories.js +211 -0
- package/es/assets/Colour/index.js +3 -3
- package/es/components/ActionsMenu/ActionsMenu.stories.js +260 -233
- package/es/components/ActionsMenu/index.js +144 -229
- package/es/components/Avatar/Avatar.stories.js +212 -196
- package/es/components/Avatar/index.js +280 -307
- package/es/components/Badge/Badge.stories.js +71 -46
- package/es/components/Badge/index.js +71 -74
- package/es/components/Box/Box.stories.js +51 -35
- package/es/components/Box/index.js +33 -34
- package/es/components/Button/Button.stories.js +161 -145
- package/es/components/Button/ButtonLink.stories.js +152 -139
- package/es/components/Button/index.js +79 -99
- package/es/components/ButtonGroup/ButtonGroup.stories.js +43 -42
- package/es/components/ButtonGroup/ButtonGroupItem.stories.js +11 -13
- package/es/components/ButtonGroup/index.js +103 -99
- package/es/components/Card/Card.stories.js +94 -62
- package/es/components/Card/index.js +50 -71
- package/es/components/Checkbox/Checkbox.stories.js +37 -43
- package/es/components/Checkbox/index.js +61 -76
- package/es/components/DatePicker/DatePicker.stories.js +86 -118
- package/es/components/DatePicker/index.js +71 -187
- package/es/components/Divider/Divider.stories.js +39 -42
- package/es/components/Divider/index.js +21 -27
- package/es/components/Expandable/Expandable.stories.js +46 -36
- package/es/components/Expandable/index.js +55 -82
- package/es/components/Flex/Flex.stories.js +19 -5
- package/es/components/Flex/FlexItem.stories.js +10 -9
- package/es/components/Flex/index.js +34 -27
- package/es/components/Grid/Grid.stories.js +129 -55
- package/es/components/Grid/index.js +25 -24
- package/es/components/Header/Header.stories.js +101 -92
- package/es/components/Header/index.js +433 -436
- package/es/components/HeaderSimple/HeaderSimple.stories.js +23 -27
- package/es/components/HeaderSimple/index.js +73 -68
- package/es/components/Icon/Icon.stories.js +58 -57
- package/es/components/Icon/index.js +48 -46
- package/es/components/Loading/Loading.stories.js +32 -39
- package/es/components/Loading/index.js +44 -51
- package/es/components/Modal/Modal.stories.js +172 -153
- package/es/components/Modal/index.js +126 -134
- package/es/components/Notification/Notification.stories.js +59 -58
- package/es/components/Notification/index.js +123 -133
- package/es/components/Popover/Popover.stories.js +134 -102
- package/es/components/Popover/index.js +65 -111
- package/es/components/ProgressBar/ProgressBar.stories.js +36 -39
- package/es/components/ProgressBar/index.js +29 -34
- package/es/components/RadioButton/RadioButton.stories.js +32 -37
- package/es/components/RadioButton/index.js +170 -184
- package/es/components/Range/Range.stories.js +19 -19
- package/es/components/Range/index.js +35 -45
- package/es/components/Select/Select.stories.js +107 -128
- package/es/components/Select/index.js +324 -336
- package/es/components/SideNav/NavItem.js +112 -122
- package/es/components/SideNav/SideNav.stories.js +84 -57
- package/es/components/SideNav/index.js +161 -185
- package/es/components/Sidebar/Sidebar.stories.js +50 -33
- package/es/components/Sidebar/index.js +152 -155
- package/es/components/Spacer/Spacer.stories.js +35 -32
- package/es/components/Spacer/index.js +20 -20
- package/es/components/StatusDot/StatusDot.stories.js +103 -90
- package/es/components/StatusDot/index.js +36 -38
- package/es/components/StyledLink/StyledLink.stories.js +68 -69
- package/es/components/StyledLink/index.js +47 -48
- package/es/components/Table/Table.stories.js +118 -112
- package/es/components/Table/getExpandColumnConfig.js +67 -62
- package/es/components/Table/index.js +24 -27
- package/es/components/Table/muiStyleOverrides.js +10 -8
- package/es/components/Tabs/Tab.stories.js +55 -38
- package/es/components/Tabs/TabsContainer.stories.js +30 -22
- package/es/components/Tabs/index.js +95 -92
- package/es/components/Tag/Tag.stories.js +250 -220
- package/es/components/Tag/index.js +118 -190
- package/es/components/TextArea/TextArea.stories.js +76 -89
- package/es/components/TextArea/index.js +117 -115
- package/es/components/TextInput/TextInput.stories.js +41 -61
- package/es/components/TextInput/index.js +127 -171
- package/es/components/Toggle/Toggle.stories.js +63 -62
- package/es/components/Toggle/index.js +43 -77
- package/es/components/TreeNav/TreeNav.stories.js +7 -8
- package/es/components/TreeNav/index.js +72 -69
- package/es/components/Typography/Typography.stories.js +174 -0
- package/es/components/Typography/index.js +252 -308
- package/es/components.test.js +1 -1
- package/es/hooks/isVisible.js +6 -10
- package/es/hooks/keepInView.js +27 -32
- package/es/hooks/keypress.js +14 -14
- package/es/hooks/useInputFocus.js +5 -5
- package/es/hooks/usePrevious.js +3 -3
- package/es/systemThemeCollapsed.js +53 -53
- package/es/systemtheme.js +53 -53
- package/es/utils/selectUtil.js +1 -1
- package/es/utils/selectUtil.test.js +6 -6
- package/package.json +29 -38
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["alternate", "icon", "colour", "title", "subtitle", "changeIcon", "changeValue", "children", "fluid", "width", "center", "theme"];
|
|
4
1
|
import React from "react";
|
|
5
2
|
import styled, { css, ThemeProvider } from "styled-components";
|
|
6
3
|
import PropTypes from "prop-types";
|
|
@@ -9,50 +6,19 @@ import Box from "../Box/";
|
|
|
9
6
|
import { H3, H4 } from "../Typography";
|
|
10
7
|
import { space, layout } from "styled-system";
|
|
11
8
|
import { themeGet } from "@styled-system/theme-get";
|
|
12
|
-
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const Item = styled.div.withConfig({
|
|
13
11
|
displayName: "Card__Item",
|
|
14
12
|
componentId: "sc-yfq75p-0"
|
|
15
|
-
})(["", " ", " word-break:break-word;width:", ";height:", ";background:", ";border-radius:", ";padding:", ";box-shadow:", ";", ";", ";", ";"], space, layout,
|
|
16
|
-
|
|
17
|
-
}, function (props) {
|
|
18
|
-
return props.fluid ? "100%" : "auto";
|
|
19
|
-
}, function (props) {
|
|
20
|
-
return themeGet("colors.white")(props);
|
|
21
|
-
}, function (props) {
|
|
22
|
-
return themeGet("radii.2")(props);
|
|
23
|
-
}, function (props) {
|
|
24
|
-
return themeGet("space.4")(props);
|
|
25
|
-
}, function (props) {
|
|
26
|
-
return themeGet("shadows.boxDefault")(props);
|
|
27
|
-
}, function (props) {
|
|
28
|
-
return props.colour === "primary" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.primary")(props)) : props.colour === "success" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.success")(props)) : props.colour === "warning" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.warning")(props)) : props.colour === "danger" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.danger")(props)) : props.colour === "greyDark" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.greyDarker")(props)) : css(["border-top:0;"]);
|
|
29
|
-
}, function (props) {
|
|
30
|
-
return props.center ? css([",> *,> div > *{display:flex;flex-direction:column;align-items:center;}"]) : css([""]);
|
|
31
|
-
}, function (props) {
|
|
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
|
-
});
|
|
34
|
-
var ChangeIcon = styled.div.withConfig({
|
|
13
|
+
})(["", " ", " word-break:break-word;width:", ";height:", ";background:", ";border-radius:", ";padding:", ";box-shadow:", ";", ";", ";", ";"], space, layout, props => props.width ? props.width : props.fluid ? "100%" : "auto", props => props.fluid ? "100%" : "auto", props => themeGet("colors.white")(props), props => themeGet("radii.2")(props), props => themeGet("space.4")(props), props => themeGet("shadows.boxDefault")(props), props => props.colour === "primary" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.primary")(props)) : props.colour === "success" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.success")(props)) : props.colour === "warning" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.warning")(props)) : props.colour === "danger" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.danger")(props)) : props.colour === "greyDark" ? css(["border-radius:0 0 ", " ", ";border-top:solid 3px ", ";"], themeGet("radii.2")(props), themeGet("radii.2")(props), themeGet("colors.greyDarker")(props)) : css(["border-top:0;"]), props => props.center ? css([",> *,> div > *{display:flex;flex-direction:column;align-items:center;}"]) : css([""]), props => props.alternate ? css(["> div:first-of-type{display:flex;justify-content:flex-start;align-items:center;}h4{margin-left:auto;float:right;}"]) : css([""]));
|
|
14
|
+
const ChangeIcon = styled.div.withConfig({
|
|
35
15
|
displayName: "Card__ChangeIcon",
|
|
36
16
|
componentId: "sc-yfq75p-1"
|
|
37
|
-
})(["display:inline-block;width:14px;height:2px;background-size:14px 14px;background-color:", ";margin:0 0 0 ", ";", ""],
|
|
38
|
-
|
|
39
|
-
}, function (props) {
|
|
40
|
-
return themeGet("space.3")(props);
|
|
41
|
-
}, function (props) {
|
|
42
|
-
return props.changeIcon === "arrowUp" ? css(["background-color:transparent;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' version='1.1'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cg transform='translate(-1173.000000, -214.000000)' fill='%2378797D'%3E%3Cg transform='translate(1173.000000, 210.000000)'%3E%3Cpath d='M0.1 12.1L0.8 12.8C1 13 1.3 13 1.4 12.8L6.9 7.3 6.9 19.4C6.9 19.6 7.1 19.8 7.3 19.8L8.3 19.8C8.6 19.8 8.8 19.6 8.8 19.4L8.8 7.3 14.3 12.8C14.4 13 14.7 13 14.9 12.8L15.6 12.1C15.7 11.9 15.7 11.7 15.6 11.5L8.1 4.1C8 4 7.7 4 7.5 4.1L0.1 11.5C0 11.7 0 11.9 0.1 12.1Z'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");height:14px;"]) : props.changeIcon === "arrowDown" ? css(["background-color:transparent;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' version='1.1'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cg transform='translate(-1173.000000, -214.000000)' fill='%2378797D'%3E%3Cg transform='translate(1173.000000, 210.000000)'%3E%3Cpath d='M0.1 12.1L0.8 12.8C1 13 1.3 13 1.4 12.8L6.9 7.3 6.9 19.4C6.9 19.6 7.1 19.8 7.3 19.8L8.3 19.8C8.6 19.8 8.8 19.6 8.8 19.4L8.8 7.3 14.3 12.8C14.4 13 14.7 13 14.9 12.8L15.6 12.1C15.7 11.9 15.7 11.7 15.6 11.5L8.1 4.1C8 4 7.7 4 7.5 4.1L0.1 11.5C0 11.7 0 11.9 0.1 12.1Z'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");height:14px;transform:rotate(180deg);"]) : css([""]);
|
|
43
|
-
});
|
|
44
|
-
var ChangeValue = styled.small.withConfig({
|
|
17
|
+
})(["display:inline-block;width:14px;height:2px;background-size:14px 14px;background-color:", ";margin:0 0 0 ", ";", ""], props => themeGet("colors.greyDark")(props), props => themeGet("space.3")(props), props => props.changeIcon === "arrowUp" ? css(["background-color:transparent;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' version='1.1'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cg transform='translate(-1173.000000, -214.000000)' fill='%2378797D'%3E%3Cg transform='translate(1173.000000, 210.000000)'%3E%3Cpath d='M0.1 12.1L0.8 12.8C1 13 1.3 13 1.4 12.8L6.9 7.3 6.9 19.4C6.9 19.6 7.1 19.8 7.3 19.8L8.3 19.8C8.6 19.8 8.8 19.6 8.8 19.4L8.8 7.3 14.3 12.8C14.4 13 14.7 13 14.9 12.8L15.6 12.1C15.7 11.9 15.7 11.7 15.6 11.5L8.1 4.1C8 4 7.7 4 7.5 4.1L0.1 11.5C0 11.7 0 11.9 0.1 12.1Z'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");height:14px;"]) : props.changeIcon === "arrowDown" ? css(["background-color:transparent;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' version='1.1'%3E%3Cg stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cg transform='translate(-1173.000000, -214.000000)' fill='%2378797D'%3E%3Cg transform='translate(1173.000000, 210.000000)'%3E%3Cpath d='M0.1 12.1L0.8 12.8C1 13 1.3 13 1.4 12.8L6.9 7.3 6.9 19.4C6.9 19.6 7.1 19.8 7.3 19.8L8.3 19.8C8.6 19.8 8.8 19.6 8.8 19.4L8.8 7.3 14.3 12.8C14.4 13 14.7 13 14.9 12.8L15.6 12.1C15.7 11.9 15.7 11.7 15.6 11.5L8.1 4.1C8 4 7.7 4 7.5 4.1L0.1 11.5C0 11.7 0 11.9 0.1 12.1Z'/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");height:14px;transform:rotate(180deg);"]) : css([""]));
|
|
18
|
+
const ChangeValue = styled.small.withConfig({
|
|
45
19
|
displayName: "Card__ChangeValue",
|
|
46
20
|
componentId: "sc-yfq75p-2"
|
|
47
|
-
})(["display:flex;align-items:center;font-size:", ";font-weight:", ";color:", ";margin:0 0 0 ", ";"],
|
|
48
|
-
return themeGet("fontSizes.2")(props);
|
|
49
|
-
}, function (props) {
|
|
50
|
-
return themeGet("fontWeights.0")(props);
|
|
51
|
-
}, function (props) {
|
|
52
|
-
return themeGet("colors.greyDark")(props);
|
|
53
|
-
}, function (props) {
|
|
54
|
-
return themeGet("space.3")(props);
|
|
55
|
-
});
|
|
21
|
+
})(["display:flex;align-items:center;font-size:", ";font-weight:", ";color:", ";margin:0 0 0 ", ";"], props => themeGet("fontSizes.2")(props), props => themeGet("fontWeights.0")(props), props => themeGet("colors.greyDark")(props), props => themeGet("space.3")(props));
|
|
56
22
|
|
|
57
23
|
/**
|
|
58
24
|
* Example of basic, alternative and complex cards. Child elements can be anything, plain text, graphs, or other components. Subtitles, icons, change values, coloured borders are all optional, not mandatory.
|
|
@@ -61,40 +27,53 @@ var ChangeValue = styled.small.withConfig({
|
|
|
61
27
|
*/
|
|
62
28
|
|
|
63
29
|
export default function Card(_ref) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
30
|
+
let {
|
|
31
|
+
alternate,
|
|
32
|
+
icon,
|
|
33
|
+
colour,
|
|
34
|
+
title,
|
|
35
|
+
subtitle,
|
|
36
|
+
changeIcon,
|
|
37
|
+
changeValue,
|
|
38
|
+
children,
|
|
39
|
+
fluid,
|
|
40
|
+
width,
|
|
41
|
+
center,
|
|
42
|
+
theme,
|
|
43
|
+
...props
|
|
44
|
+
} = _ref;
|
|
45
|
+
const component = /*#__PURE__*/_jsxs(Item, {
|
|
78
46
|
alternate: alternate,
|
|
79
47
|
colour: colour,
|
|
80
48
|
fluid: fluid,
|
|
81
49
|
width: width,
|
|
82
|
-
center: center
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
50
|
+
center: center,
|
|
51
|
+
...props,
|
|
52
|
+
children: [!icon & !title & !subtitle ? null : /*#__PURE__*/_jsxs(Box, {
|
|
53
|
+
mb: "r",
|
|
54
|
+
children: [icon ? /*#__PURE__*/_jsx(Icon, {
|
|
55
|
+
icon: icon,
|
|
56
|
+
size: "lg",
|
|
57
|
+
mr: "s"
|
|
58
|
+
}) : null, title ? /*#__PURE__*/_jsx(H3, {
|
|
59
|
+
children: title
|
|
60
|
+
}) : null, changeIcon ? /*#__PURE__*/_jsx(ChangeIcon, {
|
|
61
|
+
changeIcon: changeIcon
|
|
62
|
+
}) : null, changeValue ? /*#__PURE__*/_jsx(ChangeValue, {
|
|
63
|
+
children: changeValue
|
|
64
|
+
}) : null, subtitle ? /*#__PURE__*/_jsx(H4, {
|
|
65
|
+
fontSize: "1",
|
|
66
|
+
color: "greyDark",
|
|
67
|
+
children: subtitle
|
|
68
|
+
}) : null]
|
|
69
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
70
|
+
children: children
|
|
71
|
+
})]
|
|
72
|
+
});
|
|
73
|
+
return theme ? /*#__PURE__*/_jsx(ThemeProvider, {
|
|
74
|
+
theme: theme,
|
|
75
|
+
children: component
|
|
76
|
+
}) : component;
|
|
98
77
|
}
|
|
99
78
|
Card.propTypes = {
|
|
100
79
|
/** Changes card styles to suit a card that holds alternate data */
|
|
@@ -2,69 +2,63 @@ import React from "react";
|
|
|
2
2
|
import Checkbox from ".";
|
|
3
3
|
import Box from "../Box";
|
|
4
4
|
import Spacer from "../Spacer";
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
6
|
export default {
|
|
6
7
|
title: "Components/Checkbox",
|
|
7
8
|
component: Checkbox
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
};
|
|
10
|
+
export const basicCheckbox = () => /*#__PURE__*/_jsx(Checkbox, {
|
|
11
|
+
onChange: () => {},
|
|
12
|
+
label: "Default checkbox"
|
|
13
|
+
});
|
|
15
14
|
basicCheckbox.storyName = "Default";
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
onChange: function onChange() {},
|
|
15
|
+
export const colourVariants = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
16
|
+
m: "3",
|
|
17
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
18
|
+
onChange: () => {},
|
|
21
19
|
label: "Primary colour checkbox",
|
|
22
20
|
colour: "primary"
|
|
23
|
-
}), /*#__PURE__*/
|
|
24
|
-
onChange:
|
|
21
|
+
}), /*#__PURE__*/_jsx(Checkbox, {
|
|
22
|
+
onChange: () => {},
|
|
25
23
|
label: "Success colour checkbox",
|
|
26
24
|
colour: "success"
|
|
27
|
-
}), /*#__PURE__*/
|
|
28
|
-
onChange:
|
|
25
|
+
}), /*#__PURE__*/_jsx(Checkbox, {
|
|
26
|
+
onChange: () => {},
|
|
29
27
|
label: "Warning colour checkbox",
|
|
30
28
|
colour: "warning"
|
|
31
|
-
}), /*#__PURE__*/
|
|
32
|
-
onChange:
|
|
29
|
+
}), /*#__PURE__*/_jsx(Checkbox, {
|
|
30
|
+
onChange: () => {},
|
|
33
31
|
label: "Danger colour checkbox",
|
|
34
32
|
colour: "danger"
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
onChange: function onChange() {},
|
|
33
|
+
})]
|
|
34
|
+
});
|
|
35
|
+
export const disabled = () => /*#__PURE__*/_jsxs(Spacer, {
|
|
36
|
+
m: "3",
|
|
37
|
+
children: [/*#__PURE__*/_jsx(Checkbox, {
|
|
38
|
+
onChange: () => {},
|
|
42
39
|
disabled: true,
|
|
43
40
|
label: "Disabled checkbox"
|
|
44
|
-
}), /*#__PURE__*/
|
|
45
|
-
onChange:
|
|
41
|
+
}), /*#__PURE__*/_jsx(Checkbox, {
|
|
42
|
+
onChange: () => {},
|
|
46
43
|
checked: true,
|
|
47
44
|
disabled: true,
|
|
48
45
|
label: "Disabled ticked checkbox"
|
|
49
|
-
})
|
|
50
|
-
};
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
p: "r"
|
|
62
|
-
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
63
|
-
onChange: function onChange() {},
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
export const checked = () => /*#__PURE__*/_jsx(Checkbox, {
|
|
49
|
+
onChange: () => {},
|
|
50
|
+
checked: true,
|
|
51
|
+
label: "Ticked checkbox"
|
|
52
|
+
});
|
|
53
|
+
export const inverted = () => /*#__PURE__*/_jsx(Box, {
|
|
54
|
+
bg: "greyDarker",
|
|
55
|
+
p: "r",
|
|
56
|
+
children: /*#__PURE__*/_jsx(Checkbox, {
|
|
57
|
+
onChange: () => {},
|
|
64
58
|
colour: "white",
|
|
65
59
|
label: "Inverted checkbox"
|
|
66
|
-
})
|
|
67
|
-
};
|
|
60
|
+
})
|
|
61
|
+
});
|
|
68
62
|
basicCheckbox.__docgenInfo = {
|
|
69
63
|
"description": "",
|
|
70
64
|
"methods": [],
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["name", "label", "colour", "disabled", "checked", "onClick", "onChange", "theme", "ariaLabel"];
|
|
5
1
|
import React, { useRef } from "react";
|
|
6
2
|
import PropTypes from "prop-types";
|
|
7
3
|
import styled, { keyframes, ThemeProvider } from "styled-components";
|
|
@@ -9,105 +5,94 @@ import { space, layout } from "styled-system";
|
|
|
9
5
|
import { themeGet } from "@styled-system/theme-get";
|
|
10
6
|
|
|
11
7
|
/* Animations */
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const checkboxOn = keyframes(["0%{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,15px 2px 0 11px;}50%{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,20px 2px 0 11px;}100%{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,20px -12px 0 11px;}"]);
|
|
10
|
+
const checkboxOff = keyframes(["0%{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,20px -12px 0 11px,0 0 0 0 inset;}25%{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,20px -12px 0 11px,0 0 0 0 inset;}50%{transform:rotate(45deg);margin-top:-4px;margin-left:6px;width:0px;height:0px;box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,15px 2px 0 11px,0 0 0 0 inset;}51%{transform:rotate(0deg);margin-top:-2px;margin-left:-2px;width:20px;height:20px;box-shadow:0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0px 0px 0 10px inset;}100%{transform:rotate(0deg);margin-top:-2px;margin-left:-2px;width:20px;height:20px;box-shadow:0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0px 0px 0 0px inset;}"]);
|
|
11
|
+
const rippleOn = keyframes(["0%{opacity:0.5;}100%{opacity:0;transform:scale(13,13);}"]);
|
|
12
|
+
const rippleOff = keyframes(["0%{opacity:0.5;}100%{opacity:0;transform:scale(13,13);}"]);
|
|
13
|
+
const Item = styled.div.withConfig({
|
|
17
14
|
displayName: "Checkbox__Item",
|
|
18
15
|
componentId: "sc-p4d19b-0"
|
|
19
|
-
})(["", " ", " display:block;transform:translateZ(0);color:", ";"], space, layout,
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
var Label = styled.label.withConfig({
|
|
16
|
+
})(["", " ", " display:block;transform:translateZ(0);color:", ";"], space, layout, props => props.colour === "white" ? themeGet("colors.white")(props) : themeGet("colors.greyDarkest")(props));
|
|
17
|
+
const Label = styled.label.withConfig({
|
|
23
18
|
displayName: "Checkbox__Label",
|
|
24
19
|
componentId: "sc-p4d19b-1"
|
|
25
|
-
})(["display:flex;align-items:center;cursor:", ";opacity:", ";"],
|
|
26
|
-
|
|
27
|
-
}, function (props) {
|
|
28
|
-
return props.disabled ? "0.5" : "1";
|
|
29
|
-
});
|
|
30
|
-
var Control = styled.input.attrs({
|
|
20
|
+
})(["display:flex;align-items:center;cursor:", ";opacity:", ";"], props => props.disabled ? "default" : "pointer", props => props.disabled ? "0.5" : "1");
|
|
21
|
+
const Control = styled.input.attrs({
|
|
31
22
|
type: "checkbox"
|
|
32
23
|
}).withConfig({
|
|
33
24
|
displayName: "Checkbox__Control",
|
|
34
25
|
componentId: "sc-p4d19b-2"
|
|
35
|
-
})(["opacity:0;position:absolute;margin:0;z-index:-1;width:0;height:0;overflow:hidden;pointer-events:none;&:focus{+ div{border-radius:2px;box-shadow:", ";}}+ div{transition:", ";&:before{background-color:", ";}> div{color:", ";}}:focus + div div:after{opacity:0.2;}:checked{+ div div:before{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,20px -12px 0 11px;.animate&{animation:", " 300ms forwards ease-out;}}}&:not(:checked) + div div:before{.animate&{animation:", " 300ms forwards ease-out;}}"],
|
|
36
|
-
|
|
37
|
-
}, themeGet("transition.transitionDefault"), function (props) {
|
|
38
|
-
return props.colour ? themeGet("colors.".concat(props.colour))(props) : themeGet("colors.greyDarker")(props);
|
|
39
|
-
}, function (props) {
|
|
40
|
-
return props.colour ? themeGet("colors.".concat(props.colour))(props) : themeGet("colors.greyDarker")(props);
|
|
41
|
-
}, checkboxOn, checkboxOff);
|
|
42
|
-
var Box = styled.div.withConfig({
|
|
26
|
+
})(["opacity:0;position:absolute;margin:0;z-index:-1;width:0;height:0;overflow:hidden;pointer-events:none;&:focus{+ div{border-radius:2px;box-shadow:", ";}}+ div{transition:", ";&:before{background-color:", ";}> div{color:", ";}}:focus + div div:after{opacity:0.2;}:checked{+ div div:before{box-shadow:0 0 0 10px,10px -10px 0 10px,32px 0px 0 20px,0px 32px 0 20px,-5px 5px 0 10px,20px -12px 0 11px;.animate&{animation:", " 300ms forwards ease-out;}}}&:not(:checked) + div div:before{.animate&{animation:", " 300ms forwards ease-out;}}"], props => props.colour ? themeGet("shadows.thickOutline")(props) + " " + themeGet("colors." + props.colour + "30")(props) : themeGet("shadows.thickOutline")(props) + " " + themeGet("colors.black20")(props), themeGet("transition.transitionDefault"), props => props.colour ? themeGet("colors.".concat(props.colour))(props) : themeGet("colors.greyDarker")(props), props => props.colour ? themeGet("colors.".concat(props.colour))(props) : themeGet("colors.greyDarker")(props), checkboxOn, checkboxOff);
|
|
27
|
+
const Box = styled.div.withConfig({
|
|
43
28
|
displayName: "Checkbox__Box",
|
|
44
29
|
componentId: "sc-p4d19b-3"
|
|
45
|
-
})(["position:relative;height:20px;width:20px;&:before{content:\"\";display:block;position:absolute;left:8px;top:8px;height:4px;width:4px;border-radius:100%;z-index:1;opacity:0;margin:0;pointer-events:none;background-color:", ";}"],
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
var Check = styled.div.withConfig({
|
|
30
|
+
})(["position:relative;height:20px;width:20px;&:before{content:\"\";display:block;position:absolute;left:8px;top:8px;height:4px;width:4px;border-radius:100%;z-index:1;opacity:0;margin:0;pointer-events:none;background-color:", ";}"], props => themeGet("colors.black50")(props));
|
|
31
|
+
const Check = styled.div.withConfig({
|
|
49
32
|
displayName: "Checkbox__Check",
|
|
50
33
|
componentId: "sc-p4d19b-4"
|
|
51
|
-
})(["position:relative;display:inline-block;width:20px;height:20px;border:2px solid;border-radius:", ";overflow:hidden;z-index:1;color:", ";&:before{content:\"\";position:absolute;transform:rotate(45deg);display:block;margin-top:-4px;margin-left:6px;width:0;height:0;box-shadow:0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0 inset;@media not all and (min-resolution:0.001dpcm){@supports (-webkit-appearance:none){width:1px;height:1px;}}}"],
|
|
52
|
-
|
|
53
|
-
}, function (props) {
|
|
54
|
-
return themeGet("colors.greyDarker")(props);
|
|
55
|
-
});
|
|
56
|
-
var Text = styled.div.withConfig({
|
|
34
|
+
})(["position:relative;display:inline-block;width:20px;height:20px;border:2px solid;border-radius:", ";overflow:hidden;z-index:1;color:", ";&:before{content:\"\";position:absolute;transform:rotate(45deg);display:block;margin-top:-4px;margin-left:6px;width:0;height:0;box-shadow:0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0,0 0 0 0 inset;@media not all and (min-resolution:0.001dpcm){@supports (-webkit-appearance:none){width:1px;height:1px;}}}"], props => themeGet("radii.1")(props), props => themeGet("colors.greyDarker")(props));
|
|
35
|
+
const Text = styled.div.withConfig({
|
|
57
36
|
displayName: "Checkbox__Text",
|
|
58
37
|
componentId: "sc-p4d19b-5"
|
|
59
|
-
})(["font-size:", ";padding-left:8px;"],
|
|
60
|
-
return themeGet("fontSizes.2")(props);
|
|
61
|
-
});
|
|
38
|
+
})(["font-size:", ";padding-left:8px;"], props => themeGet("fontSizes.2")(props));
|
|
62
39
|
/**
|
|
63
40
|
* The default checkbox (or inverted if on dark background) should be used for the majority of the UI; however, the coloured ones can be used in situations where the colour corresponds with some indication of status, e.g. in a task list, green could denote task completed, red could denote task overdue.
|
|
64
41
|
*/
|
|
65
42
|
export default function Checkbox(_ref) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
43
|
+
let {
|
|
44
|
+
name,
|
|
45
|
+
label,
|
|
46
|
+
colour,
|
|
47
|
+
disabled,
|
|
48
|
+
checked,
|
|
49
|
+
onClick,
|
|
50
|
+
onChange,
|
|
51
|
+
theme,
|
|
52
|
+
ariaLabel,
|
|
53
|
+
...props
|
|
54
|
+
} = _ref;
|
|
55
|
+
const inputRef = useRef(null);
|
|
56
|
+
const handleClick = () => {
|
|
78
57
|
if (!inputRef.current || disabled) {
|
|
79
58
|
return;
|
|
80
59
|
}
|
|
81
60
|
inputRef.current.classList.add("animate");
|
|
82
61
|
};
|
|
83
|
-
|
|
62
|
+
const handleAnimationEnd = () => {
|
|
84
63
|
if (!inputRef.current || disabled) {
|
|
85
64
|
return;
|
|
86
65
|
}
|
|
87
66
|
inputRef.current.classList.remove("animate");
|
|
88
67
|
};
|
|
89
|
-
|
|
90
|
-
colour: colour
|
|
91
|
-
}, props, {
|
|
92
|
-
onClick: handleClick,
|
|
93
|
-
onAnimationEnd: handleAnimationEnd
|
|
94
|
-
}), /*#__PURE__*/React.createElement(Label, {
|
|
95
|
-
disabled: disabled
|
|
96
|
-
}, /*#__PURE__*/React.createElement(Control, {
|
|
97
|
-
name: name,
|
|
98
|
-
colour: colour,
|
|
99
|
-
disabled: disabled,
|
|
100
|
-
checked: checked,
|
|
101
|
-
onChange: onChange,
|
|
102
|
-
ref: inputRef,
|
|
103
|
-
"aria-label": ariaLabel
|
|
104
|
-
}), /*#__PURE__*/React.createElement(Box, {
|
|
68
|
+
const component = /*#__PURE__*/_jsx(Item, {
|
|
105
69
|
colour: colour,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
70
|
+
...props,
|
|
71
|
+
onClick: handleClick,
|
|
72
|
+
onAnimationEnd: handleAnimationEnd,
|
|
73
|
+
children: /*#__PURE__*/_jsxs(Label, {
|
|
74
|
+
disabled: disabled,
|
|
75
|
+
children: [/*#__PURE__*/_jsx(Control, {
|
|
76
|
+
name: name,
|
|
77
|
+
colour: colour,
|
|
78
|
+
disabled: disabled,
|
|
79
|
+
checked: checked,
|
|
80
|
+
onChange: onChange,
|
|
81
|
+
ref: inputRef,
|
|
82
|
+
"aria-label": ariaLabel
|
|
83
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
84
|
+
colour: colour,
|
|
85
|
+
onClick: onClick,
|
|
86
|
+
children: /*#__PURE__*/_jsx(Check, {})
|
|
87
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
88
|
+
children: label
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
return theme ? /*#__PURE__*/_jsx(ThemeProvider, {
|
|
93
|
+
theme: theme,
|
|
94
|
+
children: component
|
|
95
|
+
}) : component;
|
|
111
96
|
}
|
|
112
97
|
Checkbox.propTypes = {
|
|
113
98
|
/** Sets the colour of the checkbox. Colours used are the design system standard colours. */
|
|
@@ -125,12 +110,12 @@ Checkbox.propTypes = {
|
|
|
125
110
|
/** Text label to display beside the checkbox */
|
|
126
111
|
label: PropTypes.string,
|
|
127
112
|
// ariaLabel prop must be specified if label is not provided
|
|
128
|
-
ariaLabel:
|
|
113
|
+
ariaLabel: (props, propName) => {
|
|
129
114
|
if (!props.label && (props[propName] == null || props[propName] === "")) {
|
|
130
115
|
return new Error("Missing prop `".concat(propName, "` not specified for Checkbox component. When `label` is not provided, `").concat(propName, "` is required."));
|
|
131
116
|
}
|
|
132
117
|
if (props[propName] && typeof props[propName] !== "string") {
|
|
133
|
-
return new Error("Invalid propType `".concat(propName, "` supplied to Checkbox component. Expected `string`, received `").concat(
|
|
118
|
+
return new Error("Invalid propType `".concat(propName, "` supplied to Checkbox component. Expected `string`, received `").concat(typeof props[propName], "`."));
|
|
134
119
|
}
|
|
135
120
|
return null;
|
|
136
121
|
},
|