@madie/madie-design-system 1.2.103 → 1.2.105
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/components/DateField/DateField.jsx +6 -1
- package/components/MadieAlert/MadieAlert.stories.js +48 -2
- package/components/MadieAlert/index.jsx +30 -36
- package/components/MadieTooltip/index.jsx +10 -4
- package/components/MadieTooltipIcon/index.jsx +2 -2
- package/components/MinimizedAlert/index.jsx +29 -0
- package/components/RichTextEditor/index.jsx +3 -3
- package/components/index.js +2 -0
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +3 -3
- package/dist/react/index.js.map +1 -1
- package/package.json +5 -1
- package/test/components/DateField.test.js +24 -0
- package/test/components/MadieAlert.test.js +97 -1
- package/test/components/MadieTooltip.test.js +33 -0
- package/test/components/RichTextEditor.test.js +54 -0
|
@@ -89,9 +89,14 @@ const DateField = ({
|
|
|
89
89
|
textField: (params) => {
|
|
90
90
|
const { InputProps } = params;
|
|
91
91
|
InputProps["data-testid"] = id;
|
|
92
|
-
InputProps["aria-required"] = required;
|
|
93
92
|
return {
|
|
94
93
|
id: id,
|
|
94
|
+
inputProps: {
|
|
95
|
+
...params.inputProps,
|
|
96
|
+
...rest.inputProps,
|
|
97
|
+
"aria-required": required,
|
|
98
|
+
required,
|
|
99
|
+
},
|
|
95
100
|
label,
|
|
96
101
|
sx: { ...dateTextFieldStyle, ...textFieldSx },
|
|
97
102
|
value: value ? dayjs.utc(value) : null,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import MadieAlert from "./index";
|
|
3
|
+
import MinimizedAlert from "../MinimizedAlert";
|
|
3
4
|
|
|
4
5
|
export default {
|
|
5
6
|
title: "Madie Alert",
|
|
6
7
|
component: MadieAlert,
|
|
7
8
|
decorators: [
|
|
8
9
|
(storyFn) => (
|
|
9
|
-
<div
|
|
10
|
+
<div
|
|
11
|
+
style={{ padding: "min(120px, 5vw)", backgroundColor: "gray" }}
|
|
12
|
+
>
|
|
10
13
|
{storyFn()}
|
|
11
14
|
</div>
|
|
12
15
|
),
|
|
@@ -76,3 +79,46 @@ export const MadieAlertSuccess = () => (
|
|
|
76
79
|
/>
|
|
77
80
|
);
|
|
78
81
|
MadieAlertSuccess.storyName = "MadieAlertSuccess";
|
|
82
|
+
|
|
83
|
+
export const IndependentlyPositionedMinimizedAlert = () => {
|
|
84
|
+
const [minimizedAlerts, setMinimizedAlerts] = useState({});
|
|
85
|
+
const [errorCount, setErrorCount] = useState(0);
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<>
|
|
89
|
+
<header
|
|
90
|
+
style={{
|
|
91
|
+
display: "flex",
|
|
92
|
+
flexWrap: "wrap",
|
|
93
|
+
alignItems: "center",
|
|
94
|
+
justifyContent: "space-between",
|
|
95
|
+
gap: "16px",
|
|
96
|
+
marginBottom: "16px",
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<h2 style={{ margin: 0, lineHeight: 1.3 }}>Measure Details</h2>
|
|
100
|
+
{Object.values(minimizedAlerts).some(Boolean) && (
|
|
101
|
+
<MinimizedAlert
|
|
102
|
+
errorCount={errorCount}
|
|
103
|
+
onClick={() => setMinimizedAlerts({})}
|
|
104
|
+
/>
|
|
105
|
+
)}
|
|
106
|
+
</header>
|
|
107
|
+
<MadieAlert
|
|
108
|
+
type="warning"
|
|
109
|
+
canClose={false}
|
|
110
|
+
minimizedAlerts={minimizedAlerts}
|
|
111
|
+
onMinimizedAlertsChange={(nextMinimizedAlerts, count) => {
|
|
112
|
+
setMinimizedAlerts(nextMinimizedAlerts);
|
|
113
|
+
setErrorCount(count);
|
|
114
|
+
}}
|
|
115
|
+
content={
|
|
116
|
+
<ul>
|
|
117
|
+
<li>Your measure needs a CMS ID.</li>
|
|
118
|
+
<li>Please complete the CQL Editor process.</li>
|
|
119
|
+
</ul>
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
122
|
+
</>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
@@ -6,10 +6,10 @@ import CancelIcon from "@mui/icons-material/Cancel"; // error
|
|
|
6
6
|
import CheckCircleIcon from "@mui/icons-material/CheckCircle"; //success
|
|
7
7
|
import ContentCopyIcon from "@mui/icons-material/ContentCopy"; //copy
|
|
8
8
|
import FullscreenExitRoundedIcon from "@mui/icons-material/FullscreenExitRounded";
|
|
9
|
-
import WarningRoundedIcon from "@mui/icons-material/WarningRounded";
|
|
10
9
|
import Tooltip from "@mui/material/Tooltip";
|
|
11
10
|
import { IconButton } from "@mui/material";
|
|
12
11
|
import ClearIcon from "@mui/icons-material/Clear";
|
|
12
|
+
import MinimizedAlert from "../MinimizedAlert";
|
|
13
13
|
import Toast from "../Toast/index";
|
|
14
14
|
import classNames from "classnames";
|
|
15
15
|
import PropTypes from "prop-types";
|
|
@@ -163,6 +163,8 @@ const MadieAlert = ({
|
|
|
163
163
|
closeButtonProps,
|
|
164
164
|
copyButton,
|
|
165
165
|
alerts = null,
|
|
166
|
+
minimizedAlerts: controlledMinimizedAlerts,
|
|
167
|
+
onMinimizedAlertsChange,
|
|
166
168
|
}) => {
|
|
167
169
|
// Consolidate related state
|
|
168
170
|
const [state, setState] = useState({
|
|
@@ -173,7 +175,8 @@ const MadieAlert = ({
|
|
|
173
175
|
});
|
|
174
176
|
|
|
175
177
|
// Create alias for readability
|
|
176
|
-
const { toastOpen, copyText,
|
|
178
|
+
const { toastOpen, copyText, individualErrors } = state;
|
|
179
|
+
const minimizedAlerts = controlledMinimizedAlerts ?? state.minimizedAlerts;
|
|
177
180
|
|
|
178
181
|
// Use a single update function
|
|
179
182
|
const updateState = (updates) => {
|
|
@@ -229,14 +232,27 @@ const MadieAlert = ({
|
|
|
229
232
|
}, [alertsArray]);
|
|
230
233
|
|
|
231
234
|
// Utility functions for managing minimized state
|
|
235
|
+
const changeMinimizedAlerts = (nextMinimizedAlerts) => {
|
|
236
|
+
updateState({ minimizedAlerts: nextMinimizedAlerts });
|
|
237
|
+
if (onMinimizedAlertsChange) {
|
|
238
|
+
const errorCount = Object.keys(nextMinimizedAlerts).reduce(
|
|
239
|
+
(sum, index) =>
|
|
240
|
+
sum +
|
|
241
|
+
(nextMinimizedAlerts[index]
|
|
242
|
+
? individualErrors[index] || 0
|
|
243
|
+
: 0),
|
|
244
|
+
0
|
|
245
|
+
);
|
|
246
|
+
onMinimizedAlertsChange(nextMinimizedAlerts, errorCount);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
232
250
|
const minimizeAlert = (index) => {
|
|
233
|
-
|
|
234
|
-
minimizedAlerts: { ...minimizedAlerts, [index]: true },
|
|
235
|
-
});
|
|
251
|
+
changeMinimizedAlerts({ ...minimizedAlerts, [index]: true });
|
|
236
252
|
};
|
|
237
253
|
|
|
238
254
|
const restoreAllAlerts = () => {
|
|
239
|
-
|
|
255
|
+
changeMinimizedAlerts({});
|
|
240
256
|
};
|
|
241
257
|
|
|
242
258
|
// Calculate minimized alerts info
|
|
@@ -335,37 +351,13 @@ const MadieAlert = ({
|
|
|
335
351
|
{alertsArray.map((alert, index) => renderAlert(alert, index))}
|
|
336
352
|
|
|
337
353
|
{/* Show minimized indicator if any alerts are minimized */}
|
|
338
|
-
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
top: "10px",
|
|
344
|
-
display: "flex",
|
|
345
|
-
alignItems: "center",
|
|
346
|
-
cursor: "pointer",
|
|
347
|
-
}}
|
|
348
|
-
data-testid="minimized-alert"
|
|
349
|
-
className="minimized-alert"
|
|
350
|
-
onClick={(e) => {
|
|
351
|
-
e.preventDefault();
|
|
352
|
-
restoreAllAlerts();
|
|
353
|
-
}}
|
|
354
|
-
>
|
|
355
|
-
<WarningRoundedIcon
|
|
356
|
-
sx={{ color: "yellow", marginRight: "5px" }}
|
|
354
|
+
{controlledMinimizedAlerts === undefined &&
|
|
355
|
+
minimizedIndices.length > 0 && (
|
|
356
|
+
<MinimizedAlert
|
|
357
|
+
errorCount={totalMinimizedErrors}
|
|
358
|
+
onClick={restoreAllAlerts}
|
|
357
359
|
/>
|
|
358
|
-
|
|
359
|
-
data-testid="minimized-alert-text"
|
|
360
|
-
style={{ color: "white", fontSize: "16px" }}
|
|
361
|
-
>
|
|
362
|
-
Display Alerts{" "}
|
|
363
|
-
{totalMinimizedErrors > 0
|
|
364
|
-
? `(${totalMinimizedErrors})`
|
|
365
|
-
: ""}
|
|
366
|
-
</span>
|
|
367
|
-
</div>
|
|
368
|
-
)}
|
|
360
|
+
)}
|
|
369
361
|
</div>
|
|
370
362
|
);
|
|
371
363
|
};
|
|
@@ -380,6 +372,8 @@ MadieAlert.propTypes = {
|
|
|
380
372
|
closeButtonProps: PropTypes.object,
|
|
381
373
|
copyButton: PropTypes.bool,
|
|
382
374
|
minimizeAlerts: PropTypes.bool,
|
|
375
|
+
minimizedAlerts: PropTypes.objectOf(PropTypes.bool),
|
|
376
|
+
onMinimizedAlertsChange: PropTypes.func,
|
|
383
377
|
alerts: PropTypes.arrayOf(
|
|
384
378
|
PropTypes.shape({
|
|
385
379
|
type: PropTypes.string,
|
|
@@ -6,8 +6,8 @@ import TooltipIcon from "../MadieTooltipIcon";
|
|
|
6
6
|
const MadieToolTip =
|
|
7
7
|
({
|
|
8
8
|
id,
|
|
9
|
-
widthContainer =
|
|
10
|
-
heightContainer =
|
|
9
|
+
widthContainer = 24,
|
|
10
|
+
heightContainer = 24,
|
|
11
11
|
...rest
|
|
12
12
|
}) => {
|
|
13
13
|
return (
|
|
@@ -28,9 +28,15 @@ const MadieToolTip =
|
|
|
28
28
|
{...rest}
|
|
29
29
|
>
|
|
30
30
|
<div
|
|
31
|
-
aria-describedby={id}
|
|
31
|
+
aria-describedby={id}
|
|
32
|
+
role="img"
|
|
32
33
|
tabIndex={0}
|
|
33
|
-
style={{
|
|
34
|
+
style={{
|
|
35
|
+
width: widthContainer,
|
|
36
|
+
height: heightContainer,
|
|
37
|
+
flexShrink: 0,
|
|
38
|
+
display: "inline-flex",
|
|
39
|
+
}}
|
|
34
40
|
data-testId={id}
|
|
35
41
|
id={id}
|
|
36
42
|
>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import Button from "@mui/material/Button";
|
|
4
|
+
import WarningRoundedIcon from "@mui/icons-material/WarningRounded";
|
|
5
|
+
|
|
6
|
+
const MinimizedAlert = ({ errorCount = 0, onClick, ...buttonProps }) => (
|
|
7
|
+
<Button
|
|
8
|
+
type="button"
|
|
9
|
+
variant="text"
|
|
10
|
+
color="inherit"
|
|
11
|
+
className="minimized-alert"
|
|
12
|
+
data-testid="minimized-alert"
|
|
13
|
+
startIcon={<WarningRoundedIcon sx={{ color: "yellow" }} />}
|
|
14
|
+
sx={{ fontSize: "16px", textTransform: "none" }}
|
|
15
|
+
{...buttonProps}
|
|
16
|
+
onClick={onClick}
|
|
17
|
+
>
|
|
18
|
+
<span data-testid="minimized-alert-text">
|
|
19
|
+
Display Alerts{errorCount > 0 ? ` (${errorCount})` : ""}
|
|
20
|
+
</span>
|
|
21
|
+
</Button>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
MinimizedAlert.propTypes = {
|
|
25
|
+
errorCount: PropTypes.number,
|
|
26
|
+
onClick: PropTypes.func.isRequired,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default MinimizedAlert;
|
|
@@ -479,11 +479,11 @@ const RichTextEditor = ({
|
|
|
479
479
|
role: 'textbox',
|
|
480
480
|
id,
|
|
481
481
|
'data-testid': `${id}-rich-text-editor-content`,
|
|
482
|
-
'aria-invalid': error ? "true" :
|
|
482
|
+
'aria-invalid': error ? "true" : "false",
|
|
483
483
|
'aria-labelledby': `${id}-label`,
|
|
484
|
-
'aria-describedby':
|
|
484
|
+
...(helperText ? { 'aria-describedby': `${id}-helper-text` } : {}),
|
|
485
485
|
'aria-multiline': "true",
|
|
486
|
-
'aria-required': required ? "true" :
|
|
486
|
+
'aria-required': required ? "true" : "false",
|
|
487
487
|
'className': `${error ? "has-error" : ""}`
|
|
488
488
|
},
|
|
489
489
|
},
|
package/components/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import InputLabel from "./InputLabel";
|
|
|
14
14
|
import FormControlLabel from "./FormControlLabel";
|
|
15
15
|
import HowItWorks from "./HowItWorks";
|
|
16
16
|
import MadieAlert from "./MadieAlert";
|
|
17
|
+
import MinimizedAlert from "./MinimizedAlert";
|
|
17
18
|
import MadieDialog from "./MadieDialog";
|
|
18
19
|
import MadieDiscardDialog from "./MadieDiscardDialog";
|
|
19
20
|
import MadieDeleteDialog from "./MadieDeleteDialog";
|
|
@@ -150,6 +151,7 @@ export {
|
|
|
150
151
|
Instant,
|
|
151
152
|
Modal,
|
|
152
153
|
MadieAlert,
|
|
154
|
+
MinimizedAlert,
|
|
153
155
|
MadieDialog,
|
|
154
156
|
MadieDiscardDialog,
|
|
155
157
|
MadieDeleteDialog,
|