@madie/madie-design-system 1.2.57 → 1.2.59
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/AutoComplete/AutoComplete.jsx +5 -1
- package/components/MadieAlert/index.jsx +347 -297
- package/components/RichTextEditor/RichTextEditor.stories.js +21 -1
- package/components/RichTextEditor/index.jsx +26 -9
- package/components/Select/index.jsx +0 -9
- package/components/Tabs/Tabs.stories.js +39 -37
- package/components/Tabs/index.js +51 -30
- package/components/Tabs/tabs.scss +13 -0
- package/components/TextArea/index.jsx +2 -2
- package/components/TextField/index.jsx +1 -1
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +3 -3
- package/dist/react/index.js.LICENSE.txt +2 -0
- package/dist/react/index.js.map +1 -1
- package/package.json +2 -2
- package/styles/components/_madie-alert.scss +3 -2
- package/styles/qppds/components/_rich-text-editor.scss +1 -1
- package/test/components/MadieAlert.test.js +37 -25
- package/test/components/RichTextEditor.test.js +62 -0
|
@@ -13,7 +13,7 @@ export default {
|
|
|
13
13
|
export const TextEditor = () => {
|
|
14
14
|
const [value, setValue] = useState("test");
|
|
15
15
|
|
|
16
|
-
const handleChange = (
|
|
16
|
+
const handleChange = (selectedVal) => {
|
|
17
17
|
setValue(selectedVal);
|
|
18
18
|
};
|
|
19
19
|
return (
|
|
@@ -22,6 +22,26 @@ export const TextEditor = () => {
|
|
|
22
22
|
required={true}
|
|
23
23
|
onChange={handleChange}
|
|
24
24
|
content={value}
|
|
25
|
+
disabled={false}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const ReadOnlyTextEditor = () => {
|
|
31
|
+
const [value, setValue] = useState(
|
|
32
|
+
"<p>This is <strong>readonly</strong> content</p>"
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const handleChange = (selectedVal) => {
|
|
36
|
+
setValue(selectedVal);
|
|
37
|
+
};
|
|
38
|
+
return (
|
|
39
|
+
<RichTextEditor
|
|
40
|
+
label="Test Text Editor"
|
|
41
|
+
required={true}
|
|
42
|
+
onChange={handleChange}
|
|
43
|
+
content={value}
|
|
44
|
+
disabled={true}
|
|
25
45
|
/>
|
|
26
46
|
);
|
|
27
47
|
};
|
|
@@ -11,7 +11,6 @@ import TableHeader from "@tiptap/extension-table-header";
|
|
|
11
11
|
import TableRow from "@tiptap/extension-table-row";
|
|
12
12
|
import Underline from "@tiptap/extension-underline";
|
|
13
13
|
import StarterKit from "@tiptap/starter-kit";
|
|
14
|
-
import { Markdown } from "tiptap-markdown";
|
|
15
14
|
import { IconButton } from "@mui/material";
|
|
16
15
|
import FormatBoldIcon from "@mui/icons-material/FormatBold";
|
|
17
16
|
import FormatItalicIcon from "@mui/icons-material/FormatItalic";
|
|
@@ -21,13 +20,15 @@ import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted";
|
|
|
21
20
|
import FormatListNumberedIcon from "@mui/icons-material/FormatListNumbered";
|
|
22
21
|
import TableChartIcon from "@mui/icons-material/TableChart";
|
|
23
22
|
import { Tooltip } from "@mui/material";
|
|
23
|
+
import { kebabCase } from "lodash";
|
|
24
|
+
import DOMPurify from "dompurify";
|
|
24
25
|
|
|
25
26
|
const MenuBar = ({ editor }) => {
|
|
26
27
|
if (!editor) {
|
|
27
28
|
return null;
|
|
28
29
|
}
|
|
29
30
|
return (
|
|
30
|
-
<div className="control-group">
|
|
31
|
+
<div className="control-group" data-testid="rich-text-editor-toolbar">
|
|
31
32
|
<div className="button-group">
|
|
32
33
|
<Tooltip
|
|
33
34
|
data-testid="bold-tooltip"
|
|
@@ -174,12 +175,12 @@ const RichTextEditor = ({
|
|
|
174
175
|
label,
|
|
175
176
|
onChange,
|
|
176
177
|
content,
|
|
178
|
+
disabled,
|
|
177
179
|
}) => {
|
|
178
180
|
const editor = useEditor(
|
|
179
181
|
{
|
|
180
182
|
extensions: [
|
|
181
183
|
StarterKit,
|
|
182
|
-
Markdown,
|
|
183
184
|
Gapcursor,
|
|
184
185
|
Table.configure({
|
|
185
186
|
resizable: true,
|
|
@@ -192,21 +193,23 @@ const RichTextEditor = ({
|
|
|
192
193
|
shouldRerenderOnTransaction: false,
|
|
193
194
|
content,
|
|
194
195
|
onUpdate: ({ editor }) => {
|
|
195
|
-
const newValue = editor.
|
|
196
|
+
const newValue = editor.getHTML();
|
|
196
197
|
onChange(newValue);
|
|
197
|
-
console.log(newValue);
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
200
|
[content]
|
|
201
201
|
);
|
|
202
202
|
return (
|
|
203
|
-
<div
|
|
203
|
+
<div
|
|
204
|
+
className="rich-text-editor"
|
|
205
|
+
data-testid={`${kebabCase(label)}-rich-text-editor`}
|
|
206
|
+
>
|
|
204
207
|
<InputLabel
|
|
205
208
|
shrink
|
|
206
209
|
required={required}
|
|
207
210
|
error={error}
|
|
208
211
|
htmlFor={id}
|
|
209
|
-
style={{ marginBottom: 0, height: 16 }} // force a
|
|
212
|
+
style={{ marginBottom: 0, height: 16 }} // force a height
|
|
210
213
|
sx={[
|
|
211
214
|
{
|
|
212
215
|
backgroundColor: "transparent",
|
|
@@ -241,8 +244,21 @@ const RichTextEditor = ({
|
|
|
241
244
|
>
|
|
242
245
|
{label}
|
|
243
246
|
</InputLabel>
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
{disabled ? (
|
|
248
|
+
<p
|
|
249
|
+
data-testid={`${id}-value`}
|
|
250
|
+
aria-labelledby={label}
|
|
251
|
+
dangerouslySetInnerHTML={{
|
|
252
|
+
__html: content ? DOMPurify.sanitize(content) : "-",
|
|
253
|
+
}}
|
|
254
|
+
/>
|
|
255
|
+
|
|
256
|
+
) : (
|
|
257
|
+
<>
|
|
258
|
+
<MenuBar editor={editor}/>
|
|
259
|
+
<EditorContent editor={editor}/>
|
|
260
|
+
</>
|
|
261
|
+
)}
|
|
246
262
|
</div>
|
|
247
263
|
);
|
|
248
264
|
};
|
|
@@ -254,6 +270,7 @@ RichTextEditor.propTypes = {
|
|
|
254
270
|
label: PropTypes.string,
|
|
255
271
|
onChange: PropTypes.func,
|
|
256
272
|
content: PropTypes.any,
|
|
273
|
+
disabled: PropTypes.bool,
|
|
257
274
|
};
|
|
258
275
|
|
|
259
276
|
MenuBar.propTypes = {
|
|
@@ -31,15 +31,6 @@ const Select = ({
|
|
|
31
31
|
);
|
|
32
32
|
return (
|
|
33
33
|
<FormControl error={error} fullWidth>
|
|
34
|
-
{/* to deal with multiple height helper text in a single row*/}
|
|
35
|
-
<div
|
|
36
|
-
style={{
|
|
37
|
-
width: 1,
|
|
38
|
-
display: "flex",
|
|
39
|
-
flexDirection: "column",
|
|
40
|
-
flexGrow: 1,
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
34
|
<InputLabel
|
|
44
35
|
// {/* has init at .2rem/3.2 px bottom. passing sx breaks style. */}
|
|
45
36
|
id={`${id}-label`}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import { withKnobs } from "@storybook/addon-knobs";
|
|
3
|
-
|
|
3
|
+
import "./tabs.scss";
|
|
4
4
|
import Tabs from "./index";
|
|
5
5
|
import Tab from "./Tab";
|
|
6
6
|
|
|
@@ -147,44 +147,46 @@ export const TypeA = () => {
|
|
|
147
147
|
/>
|
|
148
148
|
</Tabs>
|
|
149
149
|
</div>
|
|
150
|
-
<div>
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
value={selected}
|
|
155
|
-
onChange={handleChange}
|
|
156
|
-
orientation="vertical"
|
|
157
|
-
>
|
|
158
|
-
<Tab
|
|
150
|
+
<div className={"vertical-standard-type-c-wrapper"}>
|
|
151
|
+
<div className={"vertical-standard-type-c"}>
|
|
152
|
+
<h4>Vertical Standard: C</h4>
|
|
153
|
+
<Tabs
|
|
159
154
|
type="C"
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
value={1}
|
|
155
|
+
value={selected}
|
|
156
|
+
onChange={handleChange}
|
|
163
157
|
orientation="vertical"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
158
|
+
>
|
|
159
|
+
<Tab
|
|
160
|
+
type="C"
|
|
161
|
+
size="standard"
|
|
162
|
+
label="Item One"
|
|
163
|
+
value={1}
|
|
164
|
+
orientation="vertical"
|
|
165
|
+
/>
|
|
166
|
+
<Tab
|
|
167
|
+
type="C"
|
|
168
|
+
size="standard"
|
|
169
|
+
label="Item Two"
|
|
170
|
+
value={2}
|
|
171
|
+
orientation="vertical"
|
|
172
|
+
/>
|
|
173
|
+
<Tab
|
|
174
|
+
type="C"
|
|
175
|
+
size="standard"
|
|
176
|
+
label="Item Three"
|
|
177
|
+
value={3}
|
|
178
|
+
orientation="vertical"
|
|
179
|
+
/>
|
|
180
|
+
<Tab
|
|
181
|
+
type="C"
|
|
182
|
+
size="standard"
|
|
183
|
+
label="disabled"
|
|
184
|
+
value={4}
|
|
185
|
+
disabled
|
|
186
|
+
orientation="vertical"
|
|
187
|
+
/>
|
|
188
|
+
</Tabs>
|
|
189
|
+
</div>
|
|
188
190
|
</div>
|
|
189
191
|
<div style={{ width: "fit-content" }}>
|
|
190
192
|
Standard: D
|
package/components/Tabs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import PropTypes from "prop-types";
|
|
2
3
|
import { Tabs as MuiTabs } from "@mui/material";
|
|
3
|
-
import React from "react";
|
|
4
4
|
|
|
5
5
|
const typeA = {
|
|
6
6
|
"& .MuiTabs-flexContainer": {
|
|
@@ -30,6 +30,15 @@ const typeC = {
|
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
const typeCVerticalSelected = {
|
|
34
|
+
"& .MuiTab-root.Mui-selected": {
|
|
35
|
+
borderTop: "solid 1px #8C8C8C",
|
|
36
|
+
borderBottom: "solid 1px #8C8C8C",
|
|
37
|
+
borderRight: "1px solid white",
|
|
38
|
+
width: "calc(100% + 1px)",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
33
42
|
const typeD = {
|
|
34
43
|
backgroundColor: "#FFF",
|
|
35
44
|
color: "#515151",
|
|
@@ -40,39 +49,51 @@ const typeD = {
|
|
|
40
49
|
},
|
|
41
50
|
};
|
|
42
51
|
|
|
43
|
-
const
|
|
44
|
-
|
|
52
|
+
const baseStyle = {
|
|
53
|
+
outline: "none",
|
|
54
|
+
fontFamily: "Rubik, sans Sarif",
|
|
55
|
+
fontWeight: 400,
|
|
56
|
+
lineHeight: 19,
|
|
57
|
+
backgroundColor: "transparent",
|
|
58
|
+
"& .Mui-selected": {
|
|
45
59
|
outline: "none",
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
fontWeight: 500,
|
|
61
|
+
color: "#333 !important",
|
|
62
|
+
backgroundColor: "#fff",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const Tabs = ({ type, size, orientation, ...rest }) => {
|
|
67
|
+
let style = { ...baseStyle };
|
|
68
|
+
|
|
69
|
+
switch (type) {
|
|
70
|
+
case "A":
|
|
71
|
+
style = { ...style, ...typeA };
|
|
72
|
+
break;
|
|
73
|
+
case "B":
|
|
74
|
+
style = { ...style, ...typeB };
|
|
75
|
+
break;
|
|
76
|
+
case "C":
|
|
77
|
+
if (orientation === "vertical") {
|
|
78
|
+
style = { ...style, ...typeC, ...typeCVerticalSelected };
|
|
79
|
+
} else {
|
|
80
|
+
style = { ...style, ...typeC };
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "D":
|
|
84
|
+
style = { ...style, ...typeD };
|
|
85
|
+
break;
|
|
86
|
+
default:
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<MuiTabs disableRipple orientation={orientation} sx={style} {...rest} />
|
|
92
|
+
);
|
|
72
93
|
};
|
|
73
94
|
|
|
74
95
|
Tabs.propTypes = {
|
|
75
|
-
|
|
96
|
+
orientation: PropTypes.string,
|
|
76
97
|
type: PropTypes.oneOf(["A", "B", "C", "D"]),
|
|
77
98
|
size: PropTypes.oneOf(["standard", "large"]),
|
|
78
99
|
ariaLabel: PropTypes.string,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Required to have OverFlow visible for parent component of Tabs
|
|
2
|
+
// in order to add styling for Mui.selected Tabs
|
|
3
|
+
.vertical-standard-type-c-wrapper * {
|
|
4
|
+
overflow: visible !important;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.vertical-standard-type-c {
|
|
8
|
+
> h4 {
|
|
9
|
+
padding-top: 16px;
|
|
10
|
+
}
|
|
11
|
+
width: 300px;
|
|
12
|
+
border-right: solid 1px #8C8C8C;
|
|
13
|
+
}
|
|
@@ -91,7 +91,7 @@ const TextArea = ({
|
|
|
91
91
|
</FormHelperText>
|
|
92
92
|
)}
|
|
93
93
|
<TextareaAutosize
|
|
94
|
-
style={{ marginTop: "8px", maxWidth: "100%"
|
|
94
|
+
style={{ marginTop: "8px", maxWidth: "100%" }}
|
|
95
95
|
className={
|
|
96
96
|
error ? "text-area-variable error" : "text-area-variable"
|
|
97
97
|
}
|
|
@@ -100,7 +100,7 @@ const TextArea = ({
|
|
|
100
100
|
id={id}
|
|
101
101
|
{...inputProps}
|
|
102
102
|
{...rest}
|
|
103
|
-
/>
|
|
103
|
+
/>
|
|
104
104
|
{maxLength && !disabled && (
|
|
105
105
|
<span
|
|
106
106
|
style={{
|