@madie/madie-design-system 1.2.53 → 1.2.56

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.
@@ -5,6 +5,7 @@ import InfoIcon from "@mui/icons-material/Info"; // info
5
5
  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
+ import FullscreenExitRoundedIcon from '@mui/icons-material/FullscreenExitRounded';
8
9
  import Tooltip from "@mui/material/Tooltip";
9
10
  import { IconButton } from "@mui/material";
10
11
  import ClearIcon from "@mui/icons-material/Clear";
@@ -18,12 +19,14 @@ const MadieAlert = ({
18
19
  visible = true,
19
20
  content,
20
21
  canClose = true,
22
+ minimizeAlerts = false, // pass the minimizeAlerts featureflag for now, since it will be standard later
21
23
  alertProps, // props to pass to outer component
22
24
  closeButtonProps, // props to pass to close button
23
25
  copyButton,
24
26
  }) => {
25
27
  const [copyText, setCopyText] = useState("");
26
28
  const [toastOpen, setToastOpen] = useState(false);
29
+ const [minimized, setMinimized] = useState(false);
27
30
 
28
31
  const copyButtonBuilder = (content) => {
29
32
  const traversal = (contentNode, parentNode = true) => {
@@ -74,7 +77,7 @@ const MadieAlert = ({
74
77
  const iconClass = classNames("alert-icon", type);
75
78
 
76
79
  return (
77
- visible && (
80
+ visible && !minimized && (
78
81
  <div className={alertClass} {...alertProps}>
79
82
  <Toast
80
83
  toastKey="copy-success-toast"
@@ -89,24 +92,54 @@ const MadieAlert = ({
89
92
  />
90
93
  <Icon className={iconClass} />
91
94
  <div id="content">{content && content}</div>
95
+ {
96
+ // minimizeAlerts is a feature flag for now, since it will be standard later
97
+ }
98
+ {minimizeAlerts && (
99
+ <Tooltip title={"Minimize"} arrow>
100
+ <IconButton sx={{
101
+ marginLeft: "auto",
102
+ "&:after": {
103
+ content: `''`,
104
+ position: "absolute",
105
+ left: "0px",
106
+ width: "1px",
107
+ height: "40px",
108
+ backgroundColor: "#B0B0B0",
109
+ pointerEvents: "none",
110
+ },
111
+ }}
112
+ >
113
+ <FullscreenExitRoundedIcon
114
+ onClick={(e) => {
115
+ e.preventDefault();
116
+ setMinimized(true);
117
+ }}
118
+ sx={{ color: "#242424" }}
119
+ />
120
+ </IconButton>
121
+ </Tooltip>
122
+ )}
92
123
  {copyButton && (
93
124
  <Tooltip
94
125
  data-testid="copy-button-tooltip"
95
- title={"Copy Text"}
126
+ title={"Copy"}
96
127
  arrow
97
128
  >
98
129
  <IconButton
99
130
  sx={{
100
131
  marginLeft: "auto",
101
- "&:after": {
102
- content: `''`,
103
- position: "absolute",
104
- left: "0px",
105
- width: "1px",
106
- height: "40px",
107
- backgroundColor: "#B0B0B0",
108
- pointerEvents: "none",
109
- },
132
+ ...(!minimizeAlerts && {
133
+ "&:after": {
134
+ content: `''`,
135
+ position: "absolute",
136
+ left: "0px",
137
+ width: "1px",
138
+ height: "40px",
139
+ backgroundColor: "#B0B0B0",
140
+ pointerEvents: "none",
141
+ }
142
+ })
110
143
  }}
111
144
  >
112
145
  <ContentCopyIcon
@@ -120,6 +153,7 @@ const MadieAlert = ({
120
153
  </IconButton>
121
154
  </Tooltip>
122
155
  )}
156
+
123
157
  {canClose && (
124
158
  <IconButton
125
159
  sx={{
@@ -152,9 +186,11 @@ MadieAlert.propTypes = {
152
186
  alertProps: PropTypes.object,
153
187
  closeButtonProps: PropTypes.object,
154
188
  copyButton: PropTypes.bool,
189
+ minimizeAlerts: PropTypes.bool,
155
190
  };
156
191
  MadieAlert.defaultProps = {
157
192
  copyButton: false,
193
+ minimizeAlerts: false,
158
194
  };
159
195
 
160
196
  export default MadieAlert;
@@ -41,3 +41,27 @@ export const DeleteDialog = () => {
41
41
  </div>
42
42
  );
43
43
  };
44
+
45
+ export const DeleteDialogNoWarning = () => {
46
+ const [open, setOpen] = useState(false);
47
+ const onClose = () => {
48
+ setOpen(false);
49
+ };
50
+ const onContinue = () => {
51
+ setOpen(false);
52
+ };
53
+
54
+ return (
55
+ <div className="qpp-u-padding--16" style={{ width: 300 }}>
56
+ <Button variant="cyan" onClick={() => setOpen(true)}>
57
+ open Dialog
58
+ </Button>
59
+ <MadieDeleteDialog
60
+ open={open}
61
+ onContinue={onContinue}
62
+ onClose={onClose}
63
+ hideWarning={true}
64
+ />
65
+ </div>
66
+ );
67
+ };
@@ -37,10 +37,12 @@ const MadieDeleteDialog = ({
37
37
  <span className="strong">{otherDialogProps.name}</span>?
38
38
  </p>
39
39
  </section>
40
- <section className="dialog-warning-action">
41
- <ErrorIcon />
42
- <p>This Action cannot be undone.</p>
43
- </section>
40
+ {otherDialogProps.hideWarning !== true && (
41
+ <section className="dialog-warning-action">
42
+ <ErrorIcon />
43
+ <p>This Action cannot be undone.</p>
44
+ </section>
45
+ )}
44
46
  </div>
45
47
  </MadieDialog>
46
48
  );
@@ -0,0 +1,28 @@
1
+ import React, { useState } from "react";
2
+ import { withKnobs } from "@storybook/addon-knobs";
3
+ import RichTextEditor from "./index";
4
+ export default {
5
+ title: "RichTextEditor",
6
+ component: RichTextEditor,
7
+ decorators: [
8
+ withKnobs,
9
+ (storyFn) => <div style={{ padding: "120px" }}>{storyFn()}</div>,
10
+ ],
11
+ };
12
+
13
+ export const TextEditor = () => {
14
+ const [value, setValue] = useState("test");
15
+
16
+ const handleChange = (id, selectedVal) => {
17
+ setValue(selectedVal);
18
+ };
19
+ return (
20
+ <RichTextEditor
21
+ label={"Test Text Editor"}
22
+ required={true}
23
+ onChange={handleChange}
24
+ content={value}
25
+ />
26
+ );
27
+ };
28
+ TextEditor.storyName = "Rich Text Editor";
@@ -0,0 +1,263 @@
1
+ import React from "react";
2
+
3
+ import PropTypes from "prop-types";
4
+ import { EditorContent, useEditor } from "@tiptap/react";
5
+ import InputLabel from "../InputLabel";
6
+
7
+ import Gapcursor from "@tiptap/extension-gapcursor";
8
+ import Table from "@tiptap/extension-table";
9
+ import TableCell from "@tiptap/extension-table-cell";
10
+ import TableHeader from "@tiptap/extension-table-header";
11
+ import TableRow from "@tiptap/extension-table-row";
12
+ import Underline from "@tiptap/extension-underline";
13
+ import StarterKit from "@tiptap/starter-kit";
14
+ import { Markdown } from "tiptap-markdown";
15
+ import { IconButton } from "@mui/material";
16
+ import FormatBoldIcon from "@mui/icons-material/FormatBold";
17
+ import FormatItalicIcon from "@mui/icons-material/FormatItalic";
18
+ import FormatUnderlinedIcon from "@mui/icons-material/FormatUnderlined";
19
+ import StrikethroughSIcon from "@mui/icons-material/StrikethroughS";
20
+ import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted";
21
+ import FormatListNumberedIcon from "@mui/icons-material/FormatListNumbered";
22
+ import TableChartIcon from "@mui/icons-material/TableChart";
23
+ import { Tooltip } from "@mui/material";
24
+
25
+ const MenuBar = ({ editor }) => {
26
+ if (!editor) {
27
+ return null;
28
+ }
29
+ return (
30
+ <div className="control-group">
31
+ <div className="button-group">
32
+ <Tooltip
33
+ data-testid="bold-tooltip"
34
+ title="Bold"
35
+ placement="top"
36
+ enterDelay={1000}
37
+ arrow
38
+ >
39
+ <IconButton
40
+ key={"bold"}
41
+ onClick={() =>
42
+ editor.chain().focus().toggleBold().run()
43
+ }
44
+ className={editor.isActive("bold") ? "is-active" : ""}
45
+ >
46
+ <FormatBoldIcon />
47
+ </IconButton>
48
+ </Tooltip>
49
+ <Tooltip
50
+ data-testid="italic-tooltip"
51
+ title="Italic"
52
+ placement="top"
53
+ enterDelay={1000}
54
+ arrow
55
+ >
56
+ <IconButton
57
+ key={"italic"}
58
+ onClick={() =>
59
+ editor.chain().focus().toggleItalic().run()
60
+ }
61
+ className={editor.isActive("italic") ? "is-active" : ""}
62
+ >
63
+ <FormatItalicIcon />
64
+ </IconButton>
65
+ </Tooltip>
66
+ <Tooltip
67
+ data-testid="underline-tooltip"
68
+ title="Underline"
69
+ placement="top"
70
+ enterDelay={1000}
71
+ arrow
72
+ >
73
+ <IconButton
74
+ key={"underline"}
75
+ onClick={() =>
76
+ editor.chain().focus().toggleUnderline().run()
77
+ }
78
+ className={
79
+ editor.isActive("underline") ? "is-active" : ""
80
+ }
81
+ >
82
+ <FormatUnderlinedIcon />
83
+ </IconButton>
84
+ </Tooltip>
85
+ <Tooltip
86
+ data-testid="strikethrough-tooltip"
87
+ title="Strikethrough"
88
+ placement="top"
89
+ enterDelay={1000}
90
+ arrow
91
+ >
92
+ <IconButton
93
+ key={"strike"}
94
+ onClick={() =>
95
+ editor.chain().focus().toggleStrike().run()
96
+ }
97
+ className={editor.isActive("strike") ? "is-active" : ""}
98
+ style={{ borderRight: "solid 1px #9c9c9c" }}
99
+ >
100
+ <StrikethroughSIcon />
101
+ </IconButton>
102
+ </Tooltip>
103
+ <Tooltip
104
+ data-testid="orderedlist-tooltip"
105
+ title="Ordered List"
106
+ placement="top"
107
+ enterDelay={1000}
108
+ arrow
109
+ >
110
+ <IconButton
111
+ key={"orderedList"}
112
+ onClick={() =>
113
+ editor.chain().focus().toggleOrderedList().run()
114
+ }
115
+ className={
116
+ editor.isActive("orderedList") ? "is-active" : ""
117
+ }
118
+ >
119
+ <FormatListNumberedIcon />
120
+ </IconButton>
121
+ </Tooltip>
122
+ <Tooltip
123
+ data-testid="bulletedlist-tooltip"
124
+ title="Bulleted List"
125
+ placement="top"
126
+ enterDelay={1000}
127
+ arrow
128
+ >
129
+ <IconButton
130
+ key={"bulletList"}
131
+ onClick={() =>
132
+ editor.chain().focus().toggleBulletList().run()
133
+ }
134
+ className={
135
+ editor.isActive("bulletList") ? "is-active" : ""
136
+ }
137
+ style={{ borderRight: "solid 1px #9c9c9c" }}
138
+ >
139
+ <FormatListBulletedIcon />
140
+ </IconButton>
141
+ </Tooltip>
142
+ <Tooltip
143
+ data-testid="table-tooltip"
144
+ title="Table"
145
+ placement="top"
146
+ enterDelay={1000}
147
+ arrow
148
+ >
149
+ <IconButton
150
+ key={"insertTable"}
151
+ onClick={() =>
152
+ editor.commands.insertTable({
153
+ rows: 3,
154
+ cols: 3,
155
+ withHeaderRow: true,
156
+ })
157
+ }
158
+ className={
159
+ editor.isActive("insertTable") ? "is-active" : ""
160
+ }
161
+ >
162
+ <TableChartIcon />
163
+ </IconButton>
164
+ </Tooltip>
165
+ </div>
166
+ </div>
167
+ );
168
+ };
169
+
170
+ const RichTextEditor = ({
171
+ id,
172
+ error = false,
173
+ required = false,
174
+ label,
175
+ onChange,
176
+ content,
177
+ }) => {
178
+ const editor = useEditor(
179
+ {
180
+ extensions: [
181
+ StarterKit,
182
+ Gapcursor,
183
+ Table.configure({
184
+ resizable: true,
185
+ }),
186
+ TableRow,
187
+ TableHeader,
188
+ TableCell,
189
+ Underline,
190
+ Markdown,
191
+ ],
192
+ shouldRerenderOnTransaction: false,
193
+ content,
194
+ onUpdate: ({ editor }) => {
195
+ const newValue = editor.storage.markdown.getMarkdown();
196
+ onChange(newValue);
197
+ console.log(newValue);
198
+ },
199
+ },
200
+ [content]
201
+ );
202
+ return (
203
+ <>
204
+ <InputLabel
205
+ shrink
206
+ required={required}
207
+ error={error}
208
+ htmlFor={id}
209
+ style={{ marginBottom: 0, height: 16 }} // force a heignt
210
+ sx={[
211
+ {
212
+ backgroundColor: "transparent",
213
+ borderColor: "#8C8C8C",
214
+ display: "inline-flex",
215
+ flexDirection: "row-reverse",
216
+ alignSelf: "baseline",
217
+ textTransform: "none",
218
+ // force it outside the select box
219
+ position: "initial",
220
+ transform: "translateX(0px) translateY(0px)",
221
+ fontFamily: "Rubik",
222
+ fontWeight: 500,
223
+ fontSize: 14,
224
+ color: "#333",
225
+ "& .MuiInputLabel-asterisk": {
226
+ color: "#AE1C1C !important",
227
+ marginRight: "3px !important", //this was
228
+ },
229
+ },
230
+ required && {
231
+ transform: "translateX(-12px) translateY(0px)",
232
+ "& .MuiInputLabel-asterisk": {
233
+ color: "#D92F2",
234
+ marginRight: "3px !important", //this was
235
+ },
236
+ },
237
+ error && {
238
+ color: "#AE1C1C !important",
239
+ },
240
+ ]}
241
+ >
242
+ {label}
243
+ </InputLabel>
244
+ <MenuBar editor={editor} />
245
+ <EditorContent editor={editor} />
246
+ </>
247
+ );
248
+ };
249
+
250
+ RichTextEditor.propTypes = {
251
+ id: PropTypes.string,
252
+ error: PropTypes.bool,
253
+ required: PropTypes.bool,
254
+ label: PropTypes.string,
255
+ onChange: PropTypes.func,
256
+ content: PropTypes.any,
257
+ };
258
+
259
+ MenuBar.propTypes = {
260
+ editor: PropTypes.any,
261
+ };
262
+
263
+ export default RichTextEditor;
@@ -25,6 +25,7 @@ import Popover from "./Popover";
25
25
  import { Pagination } from "./Pagination";
26
26
  import RadioButton from "./RadioButton/RadioButton";
27
27
  import ReadOnlyTextField from "./ReadOnlyTextField";
28
+ import RichTextEditor from "./RichTextEditor";
28
29
  import Select from "./Select";
29
30
  import Spinner from "./UnwrappedSpinner";
30
31
  import TabPanel from "./Tabs/TabPanel";
@@ -42,7 +43,7 @@ import Dropdown from "./Dropdown";
42
43
  import DSLink from "./Link";
43
44
  import NumberInput from "./NumberInput";
44
45
  import TruncateText from "./TruncateText/index";
45
- import theme from "../themes/actionCenterTheme.js";
46
+ import theme from "../themes/actionCenterTheme.js";
46
47
  import {
47
48
  MyApplicationsIcon,
48
49
  UserSignInIcon,
@@ -156,6 +157,7 @@ export {
156
157
  Popover,
157
158
  RadioButton,
158
159
  ReadOnlyTextField,
160
+ RichTextEditor,
159
161
  Search,
160
162
  Select,
161
163
  Spinner,
@@ -172,5 +174,5 @@ export {
172
174
  Tooltip,
173
175
  DSLink,
174
176
  TruncateText,
175
- theme
177
+ theme,
176
178
  };