@madie/madie-design-system 1.2.99 → 1.2.101

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.
@@ -0,0 +1,57 @@
1
+ import React, { useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { withKnobs } from "@storybook/addon-knobs";
4
+ import HowItWorks from "./index";
5
+
6
+ export default {
7
+ title: "HowItWorks",
8
+ component: HowItWorks,
9
+ decorators: [withKnobs],
10
+ };
11
+
12
+ const Wrapper = ({ children }) => (
13
+ <div className="qpp-u-padding--16" style={{ width: 600 }}>
14
+ {children}
15
+ </div>
16
+ );
17
+
18
+ Wrapper.propTypes = {
19
+ className: PropTypes.string,
20
+ children: PropTypes.node,
21
+ };
22
+
23
+ const body = (
24
+ <p>
25
+ The CQL Editor is where you create and maintain your measure&apos;s
26
+ Clinical Quality Language (CQL).
27
+ </p>
28
+ );
29
+
30
+ export const Default = () => (
31
+ <Wrapper>
32
+ <HowItWorks>{body}</HowItWorks>
33
+ </Wrapper>
34
+ );
35
+
36
+ Default.storyName = "left aligned (default)";
37
+
38
+ export const RightAligned = () => (
39
+ <Wrapper>
40
+ <HowItWorks align="right">{body}</HowItWorks>
41
+ </Wrapper>
42
+ );
43
+
44
+ RightAligned.storyName = "right aligned";
45
+
46
+ export const Controlled = () => {
47
+ const [open, setOpen] = useState(true);
48
+ return (
49
+ <Wrapper>
50
+ <HowItWorks isOpen={open} onOpenChange={setOpen}>
51
+ {body}
52
+ </HowItWorks>
53
+ </Wrapper>
54
+ );
55
+ };
56
+
57
+ Controlled.storyName = "controlled (starts open)";
@@ -0,0 +1,195 @@
1
+ import React, { useState } from "react";
2
+ import ClearIcon from "@mui/icons-material/Clear";
3
+ import PrivacyTipIcon from "@mui/icons-material/PrivacyTip";
4
+ import { Box, IconButton } from "@mui/material";
5
+ import PropTypes from "prop-types";
6
+
7
+ const containerSx = {
8
+ padding: "8px 16px",
9
+ display: "flex",
10
+ justifyContent: "flex-end",
11
+
12
+ "&.how-it-works-flush-left": {
13
+ paddingLeft: 0,
14
+ paddingRight: 0,
15
+ justifyContent: "flex-start",
16
+ width: "100%",
17
+ },
18
+
19
+ "& .how-it-works-link": {
20
+ background: "none",
21
+ border: "none",
22
+ color: "#0073c8",
23
+ cursor: "pointer",
24
+ fontSize: "14px",
25
+ fontWeight: 500,
26
+ padding: 0,
27
+ textDecoration: "none",
28
+ display: "inline-flex",
29
+ alignItems: "center",
30
+ gap: "4px",
31
+
32
+ "& .how-it-works-privacy-icon": {
33
+ fontSize: "18px",
34
+ },
35
+
36
+ "&:hover": {
37
+ color: "#005a9e",
38
+ },
39
+
40
+ "&:focus-visible": {
41
+ outline: "2px solid #0073c8",
42
+ outlineOffset: "2px",
43
+ borderRadius: "2px",
44
+ },
45
+ },
46
+
47
+ "& .how-it-works-info": {
48
+ display: "flex",
49
+ alignItems: "flex-start",
50
+ backgroundColor: "#e8f4fd",
51
+ border: "1px solid #b3d7f2",
52
+ borderLeft: "4px solid #0073c8",
53
+ borderRadius: "4px",
54
+ padding: "12px 16px",
55
+ gap: "12px",
56
+ width: "100%",
57
+ marginBottom: "8px",
58
+ },
59
+
60
+ "& .how-it-works-icon": {
61
+ color: "#0073c8",
62
+ flexShrink: 0,
63
+ marginTop: "2px",
64
+ },
65
+
66
+ "& .how-it-works-body": {
67
+ flex: 1,
68
+ fontSize: "14px",
69
+ color: "#333",
70
+
71
+ "& strong": {
72
+ display: "block",
73
+ marginBottom: "4px",
74
+ },
75
+
76
+ "& p": {
77
+ margin: "0 0 8px 0",
78
+ },
79
+
80
+ "& ol": {
81
+ margin: 0,
82
+ paddingLeft: "20px",
83
+ listStyleType: "decimal",
84
+
85
+ "& li": {
86
+ marginBottom: "2px",
87
+ display: "list-item",
88
+ },
89
+
90
+ "& .how-it-works-sub-list": {
91
+ margin: "4px 0 0",
92
+ paddingLeft: "20px",
93
+ listStyleType: "circle",
94
+ },
95
+ },
96
+ },
97
+
98
+ "& .how-it-works-close": {
99
+ flexShrink: 0,
100
+ color: "#333",
101
+ alignSelf: "stretch",
102
+ borderRadius: 0,
103
+ borderLeft: "1px solid #b0b0b0",
104
+ marginLeft: "auto",
105
+ },
106
+
107
+ "& .how-it-works-close-icon": {
108
+ color: "#d92f2f",
109
+ },
110
+ };
111
+
112
+ const HowItWorks = ({
113
+ children,
114
+ title = "How it Works",
115
+ contentId = "how-it-works-content",
116
+ align = "left",
117
+ isOpen: isOpenProp,
118
+ onOpenChange,
119
+ }) => {
120
+ const [internalOpen, setInternalOpen] = useState(false);
121
+ const isControlled = isOpenProp !== undefined;
122
+ const isOpen = isControlled ? isOpenProp : internalOpen;
123
+ const setIsOpen = (next) => {
124
+ if (!isControlled) setInternalOpen(next);
125
+ if (onOpenChange) onOpenChange(next);
126
+ };
127
+
128
+ const containerClass =
129
+ align === "left"
130
+ ? "how-it-works-container how-it-works-flush-left"
131
+ : "how-it-works-container";
132
+
133
+ if (!isOpen) {
134
+ return (
135
+ <Box
136
+ className={containerClass}
137
+ data-testid="how-it-works"
138
+ sx={containerSx}
139
+ >
140
+ <button
141
+ type="button"
142
+ className="how-it-works-link"
143
+ data-testid="how-it-works-link"
144
+ aria-expanded={false}
145
+ aria-controls={contentId}
146
+ onClick={() => setIsOpen(true)}
147
+ >
148
+ <PrivacyTipIcon className="how-it-works-privacy-icon" />
149
+ How it works
150
+ </button>
151
+ </Box>
152
+ );
153
+ }
154
+
155
+ return (
156
+ <Box
157
+ className={containerClass}
158
+ data-testid="how-it-works"
159
+ sx={containerSx}
160
+ >
161
+ <div
162
+ className="how-it-works-info"
163
+ id={contentId}
164
+ data-testid="how-it-works-content"
165
+ role="region"
166
+ aria-label="How it works information"
167
+ >
168
+ <PrivacyTipIcon className="how-it-works-icon" />
169
+ <div className="how-it-works-body">
170
+ <strong>{title}</strong>
171
+ {children}
172
+ </div>
173
+ <IconButton
174
+ data-testid="how-it-works-close"
175
+ aria-label="Close how it works"
176
+ onClick={() => setIsOpen(false)}
177
+ className="how-it-works-close"
178
+ >
179
+ <ClearIcon className="how-it-works-close-icon" />
180
+ </IconButton>
181
+ </div>
182
+ </Box>
183
+ );
184
+ };
185
+
186
+ HowItWorks.propTypes = {
187
+ children: PropTypes.node,
188
+ title: PropTypes.string,
189
+ contentId: PropTypes.string,
190
+ align: PropTypes.oneOf(["left", "right"]),
191
+ isOpen: PropTypes.bool,
192
+ onOpenChange: PropTypes.func,
193
+ };
194
+
195
+ export default HowItWorks;
@@ -13,6 +13,7 @@ const MadieTable = ({
13
13
  currentDirection,
14
14
  handleSort,
15
15
  renderExpandedRow,
16
+ emptyMessage = "No results were found",
16
17
  id="measureListTable",
17
18
  dataTestId = "measure-list-tbl"
18
19
  }) => {
@@ -112,7 +113,7 @@ const MadieTable = ({
112
113
  colSpan={table.getAllColumns().length}
113
114
  style={{ padding: "40px 0", textAlign: "center" }}
114
115
  >
115
- <span>No results were found</span>
116
+ <span>{emptyMessage}</span>
116
117
  </td>
117
118
  </tr>
118
119
  )}
@@ -153,6 +154,7 @@ MadieTable.propTypes = {
153
154
  currentDirection: PropTypes.oneOf(["ASC", "DESC"]),
154
155
  handleSort: PropTypes.func.isRequired,
155
156
  renderExpandedRow: PropTypes.func,
157
+ emptyMessage: PropTypes.node,
156
158
 
157
159
  id: PropTypes.string,
158
160
  dataTestId: PropTypes.string,
@@ -12,6 +12,7 @@ import Footer from "./Footer/FooterUI";
12
12
  import Instant from "./Instant";
13
13
  import InputLabel from "./InputLabel";
14
14
  import FormControlLabel from "./FormControlLabel";
15
+ import HowItWorks from "./HowItWorks";
15
16
  import MadieAlert from "./MadieAlert";
16
17
  import MadieDialog from "./MadieDialog";
17
18
  import MadieDiscardDialog from "./MadieDiscardDialog";
@@ -143,6 +144,7 @@ export {
143
144
  FlashNotification,
144
145
  Footer,
145
146
  FormControlLabel,
147
+ HowItWorks,
146
148
  InputLabel,
147
149
  Icons,
148
150
  Infotip,