@madie/madie-design-system 1.2.62 → 2.0.1
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/.babelrc +14 -2
- package/.eslintrc.js +1 -1
- package/.storybook/.babelrc +2 -1
- package/.storybook/main.js +3 -11
- package/.storybook/preview.js +1 -1
- package/components/Accordion/index.jsx +32 -36
- package/components/AutoComplete/AutoComplete.jsx +2 -17
- package/components/Button/Button.stories.js +0 -7
- package/components/Button/index.js +34 -44
- package/components/DateField/DateField.jsx +2 -15
- package/components/DateField/DateField.stories.jsx +23 -10
- package/components/DateTimeField/DateTimeField.jsx +7 -11
- package/components/DateTimeField/DateTimeField.stories.jsx +29 -19
- package/components/InputLabel/index.jsx +1 -6
- package/components/Instant/Instant.stories.js +14 -6
- package/components/Instant/index.jsx +0 -16
- package/components/Link/index.js +14 -33
- package/components/MadieAlert/MadieAlert.stories.js +35 -29
- package/components/MadieAlert/index.jsx +5 -44
- package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +17 -32
- package/components/MadieConfirmDialog/index.jsx +0 -8
- package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +9 -24
- package/components/MadieDeleteDialog/index.jsx +0 -7
- package/components/MadieDialog/MadieDialog.stories.js +45 -121
- package/components/MadieDialog/index.jsx +4 -23
- package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +5 -12
- package/components/MadieDiscardDialog/index.jsx +0 -7
- package/components/MadieSpinner/MadieSpinner.stories.js +1 -9
- package/components/MadieSpinner/index.jsx +0 -5
- package/components/MadieTooltip/MadieTooltip.stories.js +7 -2
- package/components/MadieTooltip/index.jsx +0 -6
- package/components/MadieTooltipIcon/index.jsx +0 -5
- package/components/Modal/Modal.jsx +31 -43
- package/components/Modal/Modal.stories.js +18 -89
- package/components/Modal/index.jsx +6 -8
- package/components/NumberInput/NumberInput.stories.js +50 -67
- package/components/NumberInput/index.jsx +0 -13
- package/components/Pagination/index.jsx +0 -17
- package/components/Popover/Popover.stories.js +6 -14
- package/components/Popover/index.js +0 -23
- package/components/RadioButton/RadioButton.jsx +5 -15
- package/components/RadioButton/RadioButton.stories.jsx +6 -2
- package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +3 -8
- package/components/ReadOnlyTextField/index.jsx +1 -9
- package/components/RichTextEditor/RichTextEditor.stories.js +10 -8
- package/components/RichTextEditor/index.jsx +14 -30
- package/components/SanitizedContent/index.jsx +0 -8
- package/components/Search/Search.stories.js +2 -4
- package/components/Search/index.js +26 -40
- package/components/Select/Select.stories.js +59 -164
- package/components/Select/index.jsx +2 -17
- package/components/Tabs/Tab.js +29 -25
- package/components/Tabs/TabPanel.js +15 -19
- package/components/Tabs/Tabs.stories.js +43 -211
- package/components/Tabs/index.js +10 -28
- package/components/TextArea/TextArea.stories.js +87 -113
- package/components/TextArea/index.jsx +2 -14
- package/components/TextField/TextField.stories.js +100 -129
- package/components/TextField/index.jsx +2 -17
- package/components/TimeField/TimeField.jsx +0 -10
- package/components/TimeField/TimeField.stories.js +18 -8
- package/components/Toast/Toast.stories.js +42 -102
- package/components/Toast/index.jsx +0 -14
- package/components/TruncateText/TruncateText.stories.js +22 -17
- package/components/TruncateText/index.js +0 -8
- package/components/hooks/useGetConfig.js +2 -2
- package/components/{index.js → index.mjs} +37 -57
- package/dist/index.js +3 -1
- package/dist/index.js.LICENSE.txt +16 -0
- package/dist/index.js.map +1 -0
- package/dist/react/index.html +1 -1
- package/dist/react/index.mjs +103 -0
- package/dist/react/{index.js.LICENSE.txt → index.mjs.LICENSE.txt} +3 -52
- package/dist/react/index.mjs.map +1 -0
- package/dist/react/package.json +1 -0
- package/eslint.config.cjs +59 -0
- package/index.js +7 -9
- package/jest.config.mjs +10 -0
- package/lib/Chevron.jsx +2 -10
- package/package.json +57 -82
- package/styles/_main.scss +4 -3
- package/test/components/Accordion.test.js +1 -1
- package/test/components/AutoComplete.test.js +11 -6
- package/test/components/Button.test.js +13 -19
- package/test/components/DateField.test.js +25 -29
- package/test/components/DateTimeField.test.js +21 -25
- package/test/components/Instant.test.js +1 -1
- package/test/components/MadieAlert.test.js +22 -22
- package/test/components/MadieConfirmDialog.test.js +42 -64
- package/test/components/MadieDeleteDialog.test.js +51 -69
- package/test/components/MadieDialog.test.js +13 -13
- package/test/components/MadieDiscardDialog.test.js +28 -45
- package/test/components/MadieSpinner.test.js +12 -17
- package/test/components/Modal.test.js +115 -0
- package/test/components/Pagination.test.js +2 -2
- package/test/components/RadioButton.test.js +7 -7
- package/test/components/ReadOnlyTextField.test.js +4 -2
- package/test/components/RichTextEditor.test.js +90 -6
- package/test/components/Search.test.js +75 -0
- package/test/components/Select.test.js +97 -107
- package/test/components/Tabs.test.js +22 -24
- package/test/components/TextArea.test.js +78 -92
- package/test/components/TextField.test.js +128 -147
- package/test/components/Toast.test.js +67 -78
- package/test/components/TruncateText.test.js +75 -0
- package/test/components/index.test.js +23 -0
- package/webpack.config.mjs +79 -0
- package/webpack.config.react.mjs +72 -0
- package/.eslintignore +0 -5
- package/components/Alert/Alert.stories.js +0 -70
- package/components/Alert/index.js +0 -55
- package/components/Breadcrumb/Breadcrumb.md +0 -28
- package/components/Breadcrumb/Breadcrumb.stories.js +0 -76
- package/components/Breadcrumb/index.js +0 -92
- package/components/CalloutBox/CalloutBox.stories.js +0 -94
- package/components/CalloutBox/index.js +0 -109
- package/components/Card/Card.stories.js +0 -163
- package/components/Card/index.js +0 -144
- package/components/Dropdown/Dropdown.stories.js +0 -94
- package/components/Dropdown/index.js +0 -85
- package/components/Error/Collapsible.jsx +0 -93
- package/components/Error/ErrorUI.jsx +0 -31
- package/components/Error/error.js +0 -26
- package/components/FlashNotification/FlashNotificationUI.jsx +0 -91
- package/components/FlashNotification/index.js +0 -30
- package/components/Footer/Footer.stories.js +0 -20
- package/components/Footer/FooterUI.jsx +0 -137
- package/components/Footer/LegacyFooterUI.jsx +0 -204
- package/components/Footer/SocialLinks.jsx +0 -63
- package/components/Footer/Subscribe.jsx +0 -34
- package/components/Footer/footer.js +0 -30
- package/components/Infotip/Infotip.jsx +0 -75
- package/components/Infotip/Infotip.stories.js +0 -52
- package/components/Infotip/InfotipIcon.jsx +0 -41
- package/components/Infotip/index.js +0 -3
- package/components/Link/Link.stories.js +0 -82
- package/components/NotificationBanner/NotificationBanner.stories.js +0 -23
- package/components/NotificationBanner/index.js +0 -279
- package/components/Spinner/index.js +0 -9
- package/components/TextInput/TextInput.stories.js +0 -118
- package/components/TextInput/index.js +0 -137
- package/components/Tooltip/Tooltip.jsx +0 -88
- package/components/Tooltip/Tooltip.stories.js +0 -80
- package/components/Tooltip/index.js +0 -3
- package/components/Tooltip/position.js +0 -76
- package/components/UnwrappedSpinner/index.js +0 -8
- package/dist/browser.js +0 -1
- package/dist/react/index.js +0 -185
- package/dist/react/index.js.map +0 -1
- package/jest.config.js +0 -17
- package/test/components/ErrorUI.test.js +0 -32
- package/test/components/FooterUI.test.js +0 -122
- package/test/components/Infotip.test.js +0 -76
- package/test/components/Tooltip.test.js +0 -147
- package/webpack.config.js +0 -124
- package/webpack.config.react.js +0 -104
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { withKnobs } from "@storybook/addon-knobs";
|
|
4
2
|
import MadieDialog from "./index";
|
|
5
|
-
import TextArea from "../TextArea
|
|
6
|
-
import Select from "../Select
|
|
3
|
+
import TextArea from "../TextArea";
|
|
4
|
+
import Select from "../Select";
|
|
7
5
|
import Button from "../Button";
|
|
8
6
|
import { Switch, FormGroup, FormControlLabel } from "@mui/material";
|
|
9
7
|
import { DialogContent, Typography } from "@mui/material";
|
|
@@ -11,7 +9,6 @@ import { DialogContent, Typography } from "@mui/material";
|
|
|
11
9
|
export default {
|
|
12
10
|
title: "MadieDialog",
|
|
13
11
|
component: MadieDialog,
|
|
14
|
-
decorators: [withKnobs],
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
const Wrapper = ({ children }) => (
|
|
@@ -19,46 +16,32 @@ const Wrapper = ({ children }) => (
|
|
|
19
16
|
{children}
|
|
20
17
|
</div>
|
|
21
18
|
);
|
|
22
|
-
Wrapper.propTypes = {
|
|
23
|
-
className: PropTypes.string,
|
|
24
|
-
children: PropTypes.node,
|
|
25
|
-
};
|
|
26
19
|
|
|
27
20
|
export const Dialog = () => {
|
|
28
21
|
const [open, setOpen] = useState(false);
|
|
29
|
-
const onClose = () => {
|
|
30
|
-
setOpen(false);
|
|
31
|
-
};
|
|
32
|
-
const onContinue = () => {
|
|
33
|
-
setOpen(false);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
22
|
const [form, setForm] = useState(false);
|
|
37
23
|
const [required, setRequired] = useState(false);
|
|
38
24
|
const [showDialogActions, setShowDialogActions] = useState(false);
|
|
39
25
|
|
|
26
|
+
const onClose = () => setOpen(false);
|
|
27
|
+
const onContinue = () => setOpen(false);
|
|
28
|
+
|
|
40
29
|
const cancelButtonProps = showDialogActions
|
|
41
|
-
? {
|
|
42
|
-
cancelText: "Discard Changes",
|
|
43
|
-
"data-testid": "cancel-button",
|
|
44
|
-
}
|
|
30
|
+
? { cancelText: "Discard Changes", "data-testid": "cancel-button" }
|
|
45
31
|
: undefined;
|
|
32
|
+
|
|
46
33
|
const continueButtonProps = showDialogActions
|
|
47
|
-
? {
|
|
48
|
-
continueText: "Save",
|
|
49
|
-
"data-testid": "save-button",
|
|
50
|
-
}
|
|
34
|
+
? { continueText: "Save", "data-testid": "save-button" }
|
|
51
35
|
: undefined;
|
|
52
36
|
|
|
53
37
|
return (
|
|
54
|
-
<
|
|
38
|
+
<Wrapper>
|
|
55
39
|
<FormGroup>
|
|
56
40
|
<FormControlLabel
|
|
57
41
|
control={
|
|
58
42
|
<Switch
|
|
59
43
|
checked={form}
|
|
60
44
|
onChange={(e) => setForm(e.target.checked)}
|
|
61
|
-
name="Form"
|
|
62
45
|
/>
|
|
63
46
|
}
|
|
64
47
|
label="Form"
|
|
@@ -68,7 +51,6 @@ export const Dialog = () => {
|
|
|
68
51
|
<Switch
|
|
69
52
|
checked={required}
|
|
70
53
|
onChange={(e) => setRequired(e.target.checked)}
|
|
71
|
-
name="Required"
|
|
72
54
|
/>
|
|
73
55
|
}
|
|
74
56
|
label="Required"
|
|
@@ -80,10 +62,9 @@ export const Dialog = () => {
|
|
|
80
62
|
onChange={(e) =>
|
|
81
63
|
setShowDialogActions(e.target.checked)
|
|
82
64
|
}
|
|
83
|
-
name="actions"
|
|
84
65
|
/>
|
|
85
66
|
}
|
|
86
|
-
label="
|
|
67
|
+
label="Show Actions"
|
|
87
68
|
/>
|
|
88
69
|
</FormGroup>
|
|
89
70
|
<Button variant="cyan" onClick={() => setOpen(true)}>
|
|
@@ -93,52 +74,40 @@ export const Dialog = () => {
|
|
|
93
74
|
form={form}
|
|
94
75
|
required={required}
|
|
95
76
|
title="Madie Dialog"
|
|
96
|
-
dialogProps={{
|
|
97
|
-
open,
|
|
98
|
-
onClose,
|
|
99
|
-
onSubmit: onContinue,
|
|
100
|
-
}}
|
|
77
|
+
dialogProps={{ open, onClose, onSubmit: onContinue }}
|
|
101
78
|
cancelButtonProps={cancelButtonProps}
|
|
102
79
|
continueButtonProps={continueButtonProps}
|
|
103
80
|
>
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"data-testid": "measure-referenceText-input",
|
|
127
|
-
"aria-describedby":
|
|
128
|
-
"measure-referenceText-helper-text",
|
|
129
|
-
}}
|
|
130
|
-
/>
|
|
131
|
-
</div>
|
|
81
|
+
<Select
|
|
82
|
+
id="measure-referenceType"
|
|
83
|
+
label="Type"
|
|
84
|
+
placeHolder={{ name: "Select", value: "" }}
|
|
85
|
+
inputProps={{
|
|
86
|
+
"data-testid": "measure-referenceType-input",
|
|
87
|
+
}}
|
|
88
|
+
data-testid="measure-referenceType"
|
|
89
|
+
required
|
|
90
|
+
SelectDisplayProps={{ "aria-required": "true" }}
|
|
91
|
+
/>
|
|
92
|
+
<TextArea
|
|
93
|
+
required
|
|
94
|
+
label="Reference"
|
|
95
|
+
placeholder="Enter"
|
|
96
|
+
id="measure-referenceText"
|
|
97
|
+
data-testid="measure-referenceText"
|
|
98
|
+
inputProps={{
|
|
99
|
+
"data-testid": "measure-referenceText-input",
|
|
100
|
+
"aria-describedby": "measure-referenceText-helper-text",
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
132
103
|
</MadieDialog>
|
|
133
|
-
</
|
|
104
|
+
</Wrapper>
|
|
134
105
|
);
|
|
135
106
|
};
|
|
136
107
|
|
|
137
108
|
export const DialogWithActionButtons = () => {
|
|
138
109
|
const [open, setOpen] = useState(false);
|
|
139
|
-
const onClose = () =>
|
|
140
|
-
setOpen(false);
|
|
141
|
-
};
|
|
110
|
+
const onClose = () => setOpen(false);
|
|
142
111
|
|
|
143
112
|
return (
|
|
144
113
|
<>
|
|
@@ -147,19 +116,8 @@ export const DialogWithActionButtons = () => {
|
|
|
147
116
|
</Button>
|
|
148
117
|
<MadieDialog
|
|
149
118
|
title="Human Readable"
|
|
150
|
-
sx={{
|
|
151
|
-
|
|
152
|
-
h2: {
|
|
153
|
-
borderTop: "1px solid black",
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
}}
|
|
157
|
-
dialogProps={{
|
|
158
|
-
onClose,
|
|
159
|
-
open,
|
|
160
|
-
maxWidth: "lg",
|
|
161
|
-
fullWidth: true,
|
|
162
|
-
}}
|
|
119
|
+
sx={{ "#modal-body h2": { borderTop: "1px solid black" } }}
|
|
120
|
+
dialogProps={{ onClose, open, maxWidth: "lg", fullWidth: true }}
|
|
163
121
|
cancelButtonProps={{
|
|
164
122
|
variant: "secondary",
|
|
165
123
|
cancelText: "Cancel",
|
|
@@ -186,9 +144,7 @@ export const DialogWithActionButtons = () => {
|
|
|
186
144
|
|
|
187
145
|
export const DialogWithActionButtonsHideContinueButton = () => {
|
|
188
146
|
const [open, setOpen] = useState(false);
|
|
189
|
-
const onClose = () =>
|
|
190
|
-
setOpen(false);
|
|
191
|
-
};
|
|
147
|
+
const onClose = () => setOpen(false);
|
|
192
148
|
|
|
193
149
|
return (
|
|
194
150
|
<>
|
|
@@ -197,19 +153,8 @@ export const DialogWithActionButtonsHideContinueButton = () => {
|
|
|
197
153
|
</Button>
|
|
198
154
|
<MadieDialog
|
|
199
155
|
title="Human Readable"
|
|
200
|
-
sx={{
|
|
201
|
-
|
|
202
|
-
h2: {
|
|
203
|
-
borderTop: "1px solid black",
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
}}
|
|
207
|
-
dialogProps={{
|
|
208
|
-
onClose,
|
|
209
|
-
open,
|
|
210
|
-
maxWidth: "lg",
|
|
211
|
-
fullWidth: true,
|
|
212
|
-
}}
|
|
156
|
+
sx={{ "#modal-body h2": { borderTop: "1px solid black" } }}
|
|
157
|
+
dialogProps={{ onClose, open, maxWidth: "lg", fullWidth: true }}
|
|
213
158
|
cancelButtonProps={{
|
|
214
159
|
variant: "secondary",
|
|
215
160
|
cancelText: "Cancel",
|
|
@@ -231,9 +176,7 @@ export const DialogWithActionButtonsHideContinueButton = () => {
|
|
|
231
176
|
|
|
232
177
|
export const DialogWithActionButtonsContinueButtonDisabledWithTooltip = () => {
|
|
233
178
|
const [open, setOpen] = useState(false);
|
|
234
|
-
const onClose = () =>
|
|
235
|
-
setOpen(false);
|
|
236
|
-
};
|
|
179
|
+
const onClose = () => setOpen(false);
|
|
237
180
|
|
|
238
181
|
return (
|
|
239
182
|
<>
|
|
@@ -242,19 +185,8 @@ export const DialogWithActionButtonsContinueButtonDisabledWithTooltip = () => {
|
|
|
242
185
|
</Button>
|
|
243
186
|
<MadieDialog
|
|
244
187
|
title="Human Readable"
|
|
245
|
-
sx={{
|
|
246
|
-
|
|
247
|
-
h2: {
|
|
248
|
-
borderTop: "1px solid black",
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
}}
|
|
252
|
-
dialogProps={{
|
|
253
|
-
onClose,
|
|
254
|
-
open,
|
|
255
|
-
maxWidth: "lg",
|
|
256
|
-
fullWidth: true,
|
|
257
|
-
}}
|
|
188
|
+
sx={{ "#modal-body h2": { borderTop: "1px solid black" } }}
|
|
189
|
+
dialogProps={{ onClose, open, maxWidth: "lg", fullWidth: true }}
|
|
258
190
|
cancelButtonProps={{
|
|
259
191
|
variant: "secondary",
|
|
260
192
|
cancelText: "Cancel",
|
|
@@ -283,9 +215,7 @@ export const DialogWithActionButtonsContinueButtonDisabledWithTooltip = () => {
|
|
|
283
215
|
|
|
284
216
|
export const DialogWithPopoverActionButtons = () => {
|
|
285
217
|
const [open, setOpen] = useState(false);
|
|
286
|
-
const onClose = () =>
|
|
287
|
-
setOpen(false);
|
|
288
|
-
};
|
|
218
|
+
const onClose = () => setOpen(false);
|
|
289
219
|
|
|
290
220
|
return (
|
|
291
221
|
<>
|
|
@@ -294,13 +224,7 @@ export const DialogWithPopoverActionButtons = () => {
|
|
|
294
224
|
</Button>
|
|
295
225
|
<MadieDialog
|
|
296
226
|
title="Dialog with popover action buttons"
|
|
297
|
-
sx={{
|
|
298
|
-
"#modal-body": {
|
|
299
|
-
h2: {
|
|
300
|
-
borderTop: "1px solid black",
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
}}
|
|
227
|
+
sx={{ "#modal-body h2": { borderTop: "1px solid black" } }}
|
|
304
228
|
dialogProps={{
|
|
305
229
|
onClose,
|
|
306
230
|
open,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
1
|
+
import React, { useState, useRef } from "react";
|
|
3
2
|
import Draggable from "react-draggable";
|
|
4
3
|
import CloseIcon from "@mui/icons-material/Close";
|
|
5
4
|
import {
|
|
@@ -17,14 +16,16 @@ import Button from "../Button";
|
|
|
17
16
|
import Popover from "../Popover";
|
|
18
17
|
|
|
19
18
|
const DraggablePaper = (props) => {
|
|
19
|
+
const nodeRef = useRef(null);
|
|
20
20
|
const { children, ...rest } = props;
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
23
|
<Draggable
|
|
24
24
|
handle="#draggable-dialog-title"
|
|
25
25
|
cancel={'[class*="MuiDialogContent-root"]'} // Prevent dragging when interacting with content
|
|
26
|
+
nodeRef={nodeRef}
|
|
26
27
|
>
|
|
27
|
-
<div style={{ backgroundColor: "#fff" }}
|
|
28
|
+
<div ref={nodeRef} {...rest} style={{ backgroundColor: "#fff" }}>
|
|
28
29
|
{children}
|
|
29
30
|
</div>
|
|
30
31
|
</Draggable>
|
|
@@ -335,24 +336,4 @@ const MadieDialog = ({
|
|
|
335
336
|
);
|
|
336
337
|
};
|
|
337
338
|
|
|
338
|
-
MadieDialog.propTypes = {
|
|
339
|
-
required: PropTypes.bool,
|
|
340
|
-
form: PropTypes.bool,
|
|
341
|
-
title: PropTypes.string,
|
|
342
|
-
dialogProps: PropTypes.object,
|
|
343
|
-
cancelButtonProps: PropTypes.object,
|
|
344
|
-
continueButtonProps: PropTypes.object,
|
|
345
|
-
children: PropTypes.object,
|
|
346
|
-
maxWidth: PropTypes.string,
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
DraggablePaper.propTypes = {
|
|
350
|
-
children: PropTypes.object,
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
Actions.propTypes = {
|
|
354
|
-
onClose: PropTypes.any,
|
|
355
|
-
cancelButtonProps: PropTypes.object,
|
|
356
|
-
continueButtonProps: PropTypes.object,
|
|
357
|
-
};
|
|
358
339
|
export default MadieDialog;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { withKnobs } from "@storybook/addon-knobs";
|
|
4
2
|
import MadieDiscardDialog from "./index";
|
|
5
3
|
import Button from "../Button";
|
|
4
|
+
|
|
6
5
|
export default {
|
|
7
6
|
title: "MadieDiscardDialog",
|
|
8
7
|
component: MadieDiscardDialog,
|
|
9
|
-
decorators: [withKnobs],
|
|
10
8
|
};
|
|
11
9
|
|
|
12
10
|
const Wrapper = ({ children }) => (
|
|
@@ -14,24 +12,19 @@ const Wrapper = ({ children }) => (
|
|
|
14
12
|
{children}
|
|
15
13
|
</div>
|
|
16
14
|
);
|
|
17
|
-
Wrapper.propTypes = {
|
|
18
|
-
className: PropTypes.string,
|
|
19
|
-
children: PropTypes.node,
|
|
20
|
-
};
|
|
21
15
|
|
|
22
16
|
export const DiscardDialog = () => {
|
|
23
17
|
const [open, setOpen] = useState(false);
|
|
24
18
|
const [text, setText] = useState("I'm some text that you may discard");
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
19
|
+
|
|
20
|
+
const onClose = () => setOpen(false);
|
|
28
21
|
const onContinue = () => {
|
|
29
22
|
setText("");
|
|
30
23
|
setOpen(false);
|
|
31
24
|
};
|
|
32
25
|
|
|
33
26
|
return (
|
|
34
|
-
<
|
|
27
|
+
<Wrapper>
|
|
35
28
|
<p>{text}</p>
|
|
36
29
|
<Button variant="cyan" onClick={() => setOpen(true)}>
|
|
37
30
|
open Dialog
|
|
@@ -41,6 +34,6 @@ export const DiscardDialog = () => {
|
|
|
41
34
|
onContinue={onContinue}
|
|
42
35
|
onClose={onClose}
|
|
43
36
|
/>
|
|
44
|
-
</
|
|
37
|
+
</Wrapper>
|
|
45
38
|
);
|
|
46
39
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import ErrorIcon from "@mui/icons-material/Error";
|
|
4
3
|
import MadieDialog from "../MadieDialog";
|
|
5
4
|
|
|
@@ -40,10 +39,4 @@ const MadieDiscardDialog = ({ open, onClose, onContinue }) => (
|
|
|
40
39
|
</MadieDialog>
|
|
41
40
|
);
|
|
42
41
|
|
|
43
|
-
MadieDiscardDialog.propTypes = {
|
|
44
|
-
open: PropTypes.bool,
|
|
45
|
-
onClose: PropTypes.func,
|
|
46
|
-
onContinue: PropTypes.func,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
42
|
export default MadieDiscardDialog;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { withKnobs } from "@storybook/addon-knobs";
|
|
4
2
|
import MadieSpinner from "./index";
|
|
5
3
|
|
|
6
4
|
export default {
|
|
7
5
|
title: "MadieSpinner",
|
|
8
6
|
component: MadieSpinner,
|
|
9
|
-
decorators: [withKnobs],
|
|
10
7
|
};
|
|
11
8
|
|
|
12
9
|
const Wrapper = ({ children }) => (
|
|
@@ -15,15 +12,10 @@ const Wrapper = ({ children }) => (
|
|
|
15
12
|
</div>
|
|
16
13
|
);
|
|
17
14
|
|
|
18
|
-
Wrapper.propTypes = {
|
|
19
|
-
className: PropTypes.string,
|
|
20
|
-
children: PropTypes.node,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
15
|
export const ExampleSpinner = () => (
|
|
24
16
|
<Wrapper>
|
|
25
17
|
<MadieSpinner />
|
|
26
18
|
</Wrapper>
|
|
27
19
|
);
|
|
28
20
|
|
|
29
|
-
ExampleSpinner.storyName = "
|
|
21
|
+
ExampleSpinner.storyName = "Example Madie Spinner";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { CircularProgress } from "@mui/material";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
3
|
|
|
5
4
|
// To change the spinner size you have to pass style props for height and width.
|
|
6
5
|
const MadieSpinner = (props) => {
|
|
@@ -28,8 +27,4 @@ const MadieSpinner = (props) => {
|
|
|
28
27
|
);
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
MadieSpinner.propTypes = {
|
|
32
|
-
thickness: PropTypes.number,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
30
|
export default MadieSpinner;
|
|
@@ -11,9 +11,14 @@ export default {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const ExampleTooltip = () => (
|
|
14
|
-
<div
|
|
14
|
+
<div
|
|
15
|
+
style={{
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
15
20
|
<div>
|
|
16
|
-
<MadieTooltip
|
|
21
|
+
<MadieTooltip tooltipText="Input the new version #" />
|
|
17
22
|
</div>
|
|
18
23
|
<div style={{ marginLeft: 200 }}>
|
|
19
24
|
<MadieTooltip color="#000" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import TooltipIcon from "../MadieTooltipIcon";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
3
|
|
|
5
4
|
// https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tooltip_role
|
|
6
5
|
const MadieToolTip = ({ tooltipText = "informational text", id }) => {
|
|
@@ -41,9 +40,4 @@ const MadieToolTip = ({ tooltipText = "informational text", id }) => {
|
|
|
41
40
|
);
|
|
42
41
|
};
|
|
43
42
|
|
|
44
|
-
MadieToolTip.propTypes = {
|
|
45
|
-
tooltipText: PropTypes.string,
|
|
46
|
-
id: PropTypes.string,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
43
|
export default MadieToolTip;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
|
|
4
3
|
const TooltipIcon = ({ color = "#0073C8", ...props }) => (
|
|
5
4
|
<svg
|
|
@@ -25,7 +24,3 @@ const TooltipIcon = ({ color = "#0073C8", ...props }) => (
|
|
|
25
24
|
);
|
|
26
25
|
|
|
27
26
|
export default TooltipIcon;
|
|
28
|
-
|
|
29
|
-
TooltipIcon.propTypes = {
|
|
30
|
-
color: PropTypes.string,
|
|
31
|
-
};
|
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
import React, { useRef, useState, useEffect } from "react";
|
|
2
2
|
import ReactModal from "react-modal";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
|
|
5
3
|
import { CloseXIcon2 } from "../../lib/SvgComponents.jsx";
|
|
6
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @param {{
|
|
7
|
+
* title?: string,
|
|
8
|
+
* children: React.ReactNode,
|
|
9
|
+
* primary?: {
|
|
10
|
+
* title: string | React.ReactElement,
|
|
11
|
+
* onClick?: () => void,
|
|
12
|
+
* loading?: boolean,
|
|
13
|
+
* loadingText?: string,
|
|
14
|
+
* } | null,
|
|
15
|
+
* secondary?: {
|
|
16
|
+
* title: string | React.ReactElement,
|
|
17
|
+
* onClick?: () => void,
|
|
18
|
+
* loading?: boolean,
|
|
19
|
+
* loadingText?: string,
|
|
20
|
+
* } | null,
|
|
21
|
+
* onRequestClose?: () => void,
|
|
22
|
+
* appElement?: string,
|
|
23
|
+
* isOpen?: boolean,
|
|
24
|
+
* width?: string,
|
|
25
|
+
* [key: string]: any
|
|
26
|
+
* }} props
|
|
27
|
+
*/
|
|
7
28
|
const Modal = ({
|
|
8
29
|
children,
|
|
9
|
-
onRequestClose,
|
|
30
|
+
onRequestClose = () => {},
|
|
10
31
|
title,
|
|
11
|
-
primary,
|
|
12
|
-
secondary,
|
|
13
|
-
appElement,
|
|
14
|
-
isOpen,
|
|
32
|
+
primary = null,
|
|
33
|
+
secondary = null,
|
|
34
|
+
appElement = "body > *:not(.qpp-c-modal)",
|
|
35
|
+
isOpen = false,
|
|
15
36
|
...props
|
|
16
37
|
}) => {
|
|
17
38
|
const [overflowSeparator, setOverflowSeparator] = useState(false);
|
|
@@ -29,9 +50,8 @@ const Modal = ({
|
|
|
29
50
|
maxWidth: "calc(100vw - 2rem)",
|
|
30
51
|
maxHeight: "calc(100vh - 2rem)",
|
|
31
52
|
};
|
|
32
|
-
} else {
|
|
33
|
-
return {};
|
|
34
53
|
}
|
|
54
|
+
return {};
|
|
35
55
|
};
|
|
36
56
|
|
|
37
57
|
return (
|
|
@@ -46,7 +66,6 @@ const Modal = ({
|
|
|
46
66
|
content: getWidth(),
|
|
47
67
|
}}
|
|
48
68
|
onAfterOpen={() => {
|
|
49
|
-
// Add heading separator based on overflow
|
|
50
69
|
if (
|
|
51
70
|
contentRef.current?.scrollHeight >
|
|
52
71
|
document.documentElement.clientHeight * 0.6
|
|
@@ -56,7 +75,6 @@ const Modal = ({
|
|
|
56
75
|
setOverflowSeparator(false);
|
|
57
76
|
}
|
|
58
77
|
|
|
59
|
-
// Set default focus
|
|
60
78
|
if (closeButtonRef?.current) {
|
|
61
79
|
closeButtonRef.current.focus();
|
|
62
80
|
}
|
|
@@ -98,7 +116,7 @@ const Modal = ({
|
|
|
98
116
|
className={`qpp-c-button qpp-c-button--secondary ${
|
|
99
117
|
primary ? "qpp-u-margin-right--16" : ""
|
|
100
118
|
}`}
|
|
101
|
-
|
|
119
|
+
disabled={secondary.loading}
|
|
102
120
|
onClick={secondary.onClick || onRequestClose}
|
|
103
121
|
aria-label={secondary.title}
|
|
104
122
|
data-testid="modal-secondary-btn"
|
|
@@ -109,7 +127,7 @@ const Modal = ({
|
|
|
109
127
|
{primary && (
|
|
110
128
|
<button
|
|
111
129
|
className="qpp-c-button"
|
|
112
|
-
|
|
130
|
+
disabled={primary.loading}
|
|
113
131
|
onClick={primary.onClick}
|
|
114
132
|
data-testid="modal-primary-btn"
|
|
115
133
|
aria-label={primary.title}
|
|
@@ -123,34 +141,4 @@ const Modal = ({
|
|
|
123
141
|
);
|
|
124
142
|
};
|
|
125
143
|
|
|
126
|
-
Modal.propTypes = {
|
|
127
|
-
title: PropTypes.string,
|
|
128
|
-
children: PropTypes.node.isRequired,
|
|
129
|
-
primary: PropTypes.shape({
|
|
130
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
131
|
-
onClick: PropTypes.func,
|
|
132
|
-
loading: PropTypes.bool,
|
|
133
|
-
loadingText: PropTypes.string,
|
|
134
|
-
}),
|
|
135
|
-
secondary: PropTypes.shape({
|
|
136
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
137
|
-
onClick: PropTypes.func,
|
|
138
|
-
loading: PropTypes.bool,
|
|
139
|
-
loadingText: PropTypes.string,
|
|
140
|
-
}),
|
|
141
|
-
onRequestClose: PropTypes.func,
|
|
142
|
-
appElement: PropTypes.string,
|
|
143
|
-
isOpen: PropTypes.bool,
|
|
144
|
-
width: PropTypes.string,
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
Modal.defaultProps = {
|
|
148
|
-
onRequestClose: () => {},
|
|
149
|
-
title: undefined,
|
|
150
|
-
primary: null,
|
|
151
|
-
secondary: null,
|
|
152
|
-
appElement: "body > *:not(.qpp-c-modal)",
|
|
153
|
-
isOpen: false,
|
|
154
|
-
};
|
|
155
|
-
|
|
156
144
|
export default Modal;
|