@madie/madie-design-system 1.2.63 → 1.2.65
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 +4 -2
- package/components/AutoComplete/AutoComplete.stories.js +12 -0
- package/components/DateField/DateField.jsx +5 -3
- package/components/DateField/DateField.stories.jsx +16 -0
- package/components/DateTimeField/DateTimeField.jsx +10 -4
- package/components/DateTimeField/DateTimeField.stories.jsx +28 -0
- package/components/NumberInput/index.jsx +3 -0
- package/components/RadioButton/RadioButton.jsx +7 -3
- package/components/RadioButton/RadioButton.stories.jsx +21 -2
- package/components/ReadOnlyTextField/index.jsx +9 -3
- package/components/RichTextEditor/RichTextEditor.stories.js +21 -3
- package/components/RichTextEditor/index.jsx +29 -18
- package/components/Select/Select.stories.js +53 -0
- package/components/Select/index.jsx +4 -2
- package/components/TextArea/TextArea.stories.js +16 -0
- package/components/TextArea/index.jsx +5 -2
- package/components/TextField/TextField.stories.js +14 -0
- package/components/TextField/index.jsx +4 -2
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +5 -5
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/styles/components/_rich-text-editor.scss +5 -0
- package/styles/qppds/components/_rich-text-editor.scss +4 -0
- package/test/components/AutoComplete.test.js +25 -4
- package/test/components/DateField.test.js +26 -8
- package/test/components/DateTimeField.test.js +28 -7
- package/test/components/RadioButton.test.js +7 -5
- package/test/components/ReadOnlyTextField.test.js +4 -2
- package/test/components/RichTextEditor.test.js +59 -5
- package/test/components/Select.test.js +24 -4
- package/test/components/TextArea.test.js +27 -11
- package/test/components/TextField.test.js +21 -3
|
@@ -76,6 +76,7 @@ const AutoComplete = ({
|
|
|
76
76
|
dataTestId,
|
|
77
77
|
options = [],
|
|
78
78
|
disabled = false,
|
|
79
|
+
readOnly = false,
|
|
79
80
|
label,
|
|
80
81
|
placeholder,
|
|
81
82
|
multiple = false,
|
|
@@ -85,7 +86,7 @@ const AutoComplete = ({
|
|
|
85
86
|
onChange,
|
|
86
87
|
...rest
|
|
87
88
|
}) => {
|
|
88
|
-
if (
|
|
89
|
+
if (readOnly) {
|
|
89
90
|
return (
|
|
90
91
|
<ReadOnlyTextField
|
|
91
92
|
required={required}
|
|
@@ -95,7 +96,7 @@ const AutoComplete = ({
|
|
|
95
96
|
{...rest}
|
|
96
97
|
value={_.isEmpty(rest.value) ? "-" : rest.value}
|
|
97
98
|
/>
|
|
98
|
-
)
|
|
99
|
+
);
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
return (
|
|
@@ -250,6 +251,7 @@ AutoComplete.propTypes = {
|
|
|
250
251
|
placeholder: PropTypes.string,
|
|
251
252
|
required: PropTypes.bool,
|
|
252
253
|
disabled: PropTypes.bool,
|
|
254
|
+
readOnly: PropTypes.bool,
|
|
253
255
|
multiple: PropTypes.bool,
|
|
254
256
|
error: PropTypes.bool,
|
|
255
257
|
label: PropTypes.string,
|
|
@@ -39,6 +39,12 @@ AutoCompleteWithLabelDisabled.args = {
|
|
|
39
39
|
value: "Option1",
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
+
export const AutoCompleteWithLabelReadOnly = TemplateSingleSelect.bind({});
|
|
43
|
+
AutoCompleteWithLabelReadOnly.args = {
|
|
44
|
+
readOnly: true,
|
|
45
|
+
value: "Option1",
|
|
46
|
+
};
|
|
47
|
+
|
|
42
48
|
export const AutoCompleteWithHelperText = TemplateSingleSelect.bind({});
|
|
43
49
|
AutoCompleteWithHelperText.args = {
|
|
44
50
|
helperText: "Helper text goes here",
|
|
@@ -90,6 +96,12 @@ AutoCompleteMultipleDisabled.args = {
|
|
|
90
96
|
placeholder: "Start typing",
|
|
91
97
|
};
|
|
92
98
|
|
|
99
|
+
export const AutoCompleteMultipleReadOnly = TemplateMultipleSelect.bind({});
|
|
100
|
+
AutoCompleteMultipleReadOnly.args = {
|
|
101
|
+
readOnly: true,
|
|
102
|
+
value: "Option1",
|
|
103
|
+
};
|
|
104
|
+
|
|
93
105
|
export const AutoCompleteMultipleWithError = TemplateMultipleSelect.bind({});
|
|
94
106
|
AutoCompleteMultipleWithError.args = {
|
|
95
107
|
required: true,
|
|
@@ -48,7 +48,8 @@ const DateField = ({
|
|
|
48
48
|
label,
|
|
49
49
|
value,
|
|
50
50
|
handleDateChange,
|
|
51
|
-
disabled,
|
|
51
|
+
disabled = false,
|
|
52
|
+
readOnly = false,
|
|
52
53
|
error,
|
|
53
54
|
helperText,
|
|
54
55
|
required = false,
|
|
@@ -56,7 +57,7 @@ const DateField = ({
|
|
|
56
57
|
textFieldSx = {},
|
|
57
58
|
...rest
|
|
58
59
|
}) => {
|
|
59
|
-
if (
|
|
60
|
+
if (readOnly) {
|
|
60
61
|
return (
|
|
61
62
|
<ReadOnlyTextField
|
|
62
63
|
required={required}
|
|
@@ -66,7 +67,7 @@ const DateField = ({
|
|
|
66
67
|
{...rest}
|
|
67
68
|
value={value ? dayjs.utc(value).format("MM/DD/YYYY") : "-"}
|
|
68
69
|
/>
|
|
69
|
-
)
|
|
70
|
+
);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
if (containerSx === undefined || containerSx === null) {
|
|
@@ -117,6 +118,7 @@ DateField.propTypes = {
|
|
|
117
118
|
value: PropTypes.object,
|
|
118
119
|
handleDateChange: PropTypes.func.isRequired,
|
|
119
120
|
disabled: PropTypes.bool,
|
|
121
|
+
readOnly: PropTypes.bool,
|
|
120
122
|
id: PropTypes.string,
|
|
121
123
|
error: PropTypes.bool,
|
|
122
124
|
helperText: PropTypes.string,
|
|
@@ -39,3 +39,19 @@ export const DateFieldComponentDisabled = (args) => {
|
|
|
39
39
|
</div>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
|
+
|
|
43
|
+
export const DateFieldComponentReadOnly = (args) => {
|
|
44
|
+
const handleDateChange = (e) => {
|
|
45
|
+
console.log("Handle change triggered", e.target.value);
|
|
46
|
+
};
|
|
47
|
+
return (
|
|
48
|
+
<div className="qpp-u-padding--16">
|
|
49
|
+
<DateField
|
|
50
|
+
readOnly
|
|
51
|
+
label="Status Date"
|
|
52
|
+
handleDateChange={handleDateChange}
|
|
53
|
+
value="2023-10-01"
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -51,18 +51,23 @@ const DateTimeField = ({
|
|
|
51
51
|
label,
|
|
52
52
|
dateTimeValue,
|
|
53
53
|
handleDateTimeChange,
|
|
54
|
-
disabled,
|
|
54
|
+
disabled = false,
|
|
55
|
+
readOnly = false,
|
|
55
56
|
id = "default_dateTime-input",
|
|
56
57
|
}) => {
|
|
57
|
-
if (
|
|
58
|
+
if (readOnly) {
|
|
58
59
|
return (
|
|
59
60
|
<ReadOnlyTextField
|
|
60
61
|
label={label}
|
|
61
|
-
value={
|
|
62
|
+
value={
|
|
63
|
+
dateTimeValue
|
|
64
|
+
? dayjs.utc(dateTimeValue).format("MM/DD/YYYY hh:mm A")
|
|
65
|
+
: "-"
|
|
66
|
+
}
|
|
62
67
|
id={id}
|
|
63
68
|
size="small"
|
|
64
69
|
/>
|
|
65
|
-
)
|
|
70
|
+
);
|
|
66
71
|
}
|
|
67
72
|
return (
|
|
68
73
|
<FormControl>
|
|
@@ -95,6 +100,7 @@ DateTimeField.propTypes = {
|
|
|
95
100
|
handleDateTimeChange: PropTypes.func.isRequired,
|
|
96
101
|
label: PropTypes.string.isRequired,
|
|
97
102
|
disabled: PropTypes.bool,
|
|
103
|
+
readOnly: PropTypes.bool,
|
|
98
104
|
};
|
|
99
105
|
|
|
100
106
|
export default DateTimeField;
|
|
@@ -39,3 +39,31 @@ export const TimeDateFieldComponentDisabled = (args) => {
|
|
|
39
39
|
</div>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
|
+
|
|
43
|
+
export const TimeDateFieldComponentDisabledNoValue = (args) => {
|
|
44
|
+
return (
|
|
45
|
+
<div className="qpp-u-padding--16">
|
|
46
|
+
<DateTimeField
|
|
47
|
+
disabled={true}
|
|
48
|
+
id="status_date_time"
|
|
49
|
+
label="Status Date/Time"
|
|
50
|
+
handleDateTimeChange={(e) => {}}
|
|
51
|
+
dateTimeValue={null}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const TimeDateFieldComponentReadOnly = (args) => {
|
|
58
|
+
return (
|
|
59
|
+
<div className="qpp-u-padding--16">
|
|
60
|
+
<DateTimeField
|
|
61
|
+
readOnly
|
|
62
|
+
id="status_date_time"
|
|
63
|
+
label="Status Date/Time"
|
|
64
|
+
handleDateTimeChange={(e) => {}}
|
|
65
|
+
dateTimeValue="2023-10-01T12:00:00Z"
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -8,6 +8,7 @@ export default function NumberInput({
|
|
|
8
8
|
helperText = undefined,
|
|
9
9
|
required = false,
|
|
10
10
|
disabled = false,
|
|
11
|
+
readOnly = false,
|
|
11
12
|
label,
|
|
12
13
|
tooltipText,
|
|
13
14
|
inputProps,
|
|
@@ -42,6 +43,7 @@ export default function NumberInput({
|
|
|
42
43
|
helperText={helperText}
|
|
43
44
|
required={required}
|
|
44
45
|
disabled={disabled}
|
|
46
|
+
readOnly={readOnly}
|
|
45
47
|
label={label}
|
|
46
48
|
tooltipText={tooltipText}
|
|
47
49
|
inputProps={newInputProps}
|
|
@@ -68,6 +70,7 @@ NumberInput.propTypes = {
|
|
|
68
70
|
helperText: PropTypes.string,
|
|
69
71
|
required: PropTypes.bool,
|
|
70
72
|
disabled: PropTypes.bool,
|
|
73
|
+
readOnly: PropTypes.bool,
|
|
71
74
|
label: PropTypes.string,
|
|
72
75
|
tooltipText: PropTypes.string,
|
|
73
76
|
inputProps: PropTypes.object,
|
|
@@ -15,14 +15,17 @@ const RadioButton = ({
|
|
|
15
15
|
dataTestId,
|
|
16
16
|
options = [],
|
|
17
17
|
disabled = false,
|
|
18
|
+
readOnly = false,
|
|
18
19
|
label,
|
|
19
20
|
required = false,
|
|
20
21
|
error = false,
|
|
21
22
|
helperText,
|
|
22
23
|
...rest
|
|
23
24
|
}) => {
|
|
24
|
-
if (
|
|
25
|
-
const option = options?.find(
|
|
25
|
+
if (readOnly) {
|
|
26
|
+
const option = options?.find(
|
|
27
|
+
(option) => String(option.value) === String(rest.value)
|
|
28
|
+
);
|
|
26
29
|
return (
|
|
27
30
|
<ReadOnlyTextField
|
|
28
31
|
required={required}
|
|
@@ -32,7 +35,7 @@ const RadioButton = ({
|
|
|
32
35
|
{...rest}
|
|
33
36
|
value={option?.label}
|
|
34
37
|
/>
|
|
35
|
-
)
|
|
38
|
+
);
|
|
36
39
|
}
|
|
37
40
|
return (
|
|
38
41
|
<FormControl error={error} fullWidth>
|
|
@@ -124,6 +127,7 @@ RadioButton.propTypes = {
|
|
|
124
127
|
dataTestId: PropTypes.string,
|
|
125
128
|
required: PropTypes.bool,
|
|
126
129
|
disabled: PropTypes.bool,
|
|
130
|
+
readOnly: PropTypes.bool,
|
|
127
131
|
error: PropTypes.bool,
|
|
128
132
|
label: PropTypes.string,
|
|
129
133
|
helperText: PropTypes.string,
|
|
@@ -36,17 +36,36 @@ const TemplateRadioButton = (args) => {
|
|
|
36
36
|
export const RadioButtonWithLabel = TemplateRadioButton.bind({});
|
|
37
37
|
RadioButtonWithLabel.args = {};
|
|
38
38
|
|
|
39
|
-
export const RadioButtonWithLabelDisabledWithNoValue = TemplateRadioButton.bind(
|
|
39
|
+
export const RadioButtonWithLabelDisabledWithNoValue = TemplateRadioButton.bind(
|
|
40
|
+
{}
|
|
41
|
+
);
|
|
40
42
|
RadioButtonWithLabelDisabledWithNoValue.args = {
|
|
41
43
|
disabled: true,
|
|
42
44
|
};
|
|
43
45
|
|
|
44
|
-
export const RadioButtonWithLabelDisabledWithValue = TemplateRadioButton.bind(
|
|
46
|
+
export const RadioButtonWithLabelDisabledWithValue = TemplateRadioButton.bind(
|
|
47
|
+
{}
|
|
48
|
+
);
|
|
45
49
|
RadioButtonWithLabelDisabledWithValue.args = {
|
|
46
50
|
disabled: true,
|
|
47
51
|
value: "options 3",
|
|
48
52
|
};
|
|
49
53
|
|
|
54
|
+
export const RadioButtonWithLabelReadOnlyWithNoValue = TemplateRadioButton.bind(
|
|
55
|
+
{}
|
|
56
|
+
);
|
|
57
|
+
RadioButtonWithLabelReadOnlyWithNoValue.args = {
|
|
58
|
+
readOnly: true,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const RadioButtonWithLabelReadOnlyWithValue = TemplateRadioButton.bind(
|
|
62
|
+
{}
|
|
63
|
+
);
|
|
64
|
+
RadioButtonWithLabelReadOnlyWithValue.args = {
|
|
65
|
+
readOnly: true,
|
|
66
|
+
value: "options 3",
|
|
67
|
+
};
|
|
68
|
+
|
|
50
69
|
export const RadioButtonWithHelperText = TemplateRadioButton.bind({});
|
|
51
70
|
RadioButtonWithHelperText.args = {
|
|
52
71
|
helperText: "Helper text goes here",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {FormControl, TextareaAutosize} from "@mui/material";
|
|
2
|
+
import { FormControl, TextareaAutosize } from "@mui/material";
|
|
3
3
|
import InputLabel from "../InputLabel";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import _ from "lodash";
|
|
6
5
|
|
|
7
6
|
const ReadOnlyTextField = ({
|
|
8
7
|
id,
|
|
@@ -71,7 +70,14 @@ const ReadOnlyTextField = ({
|
|
|
71
70
|
disabled={disabled}
|
|
72
71
|
id={id}
|
|
73
72
|
{...rest}
|
|
74
|
-
value={
|
|
73
|
+
value={
|
|
74
|
+
rest?.value == null ||
|
|
75
|
+
rest.value === "" ||
|
|
76
|
+
(typeof rest.value === "object" &&
|
|
77
|
+
Object.keys(rest.value).length === 0)
|
|
78
|
+
? "-"
|
|
79
|
+
: rest.value
|
|
80
|
+
}
|
|
75
81
|
/>
|
|
76
82
|
</FormControl>
|
|
77
83
|
);
|
|
@@ -22,14 +22,13 @@ export const TextEditor = () => {
|
|
|
22
22
|
required={true}
|
|
23
23
|
onChange={handleChange}
|
|
24
24
|
content={value}
|
|
25
|
-
disabled={false}
|
|
26
25
|
/>
|
|
27
26
|
);
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
export const ReadOnlyTextEditor = () => {
|
|
31
30
|
const [value, setValue] = useState(
|
|
32
|
-
"<p>This is <strong>
|
|
31
|
+
"<p>This is <strong>read only</strong> content</p>"
|
|
33
32
|
);
|
|
34
33
|
|
|
35
34
|
const handleChange = (selectedVal) => {
|
|
@@ -41,7 +40,26 @@ export const ReadOnlyTextEditor = () => {
|
|
|
41
40
|
required={true}
|
|
42
41
|
onChange={handleChange}
|
|
43
42
|
content={value}
|
|
44
|
-
|
|
43
|
+
readOnly
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const DisabledTextEditor = () => {
|
|
49
|
+
const [value, setValue] = useState(
|
|
50
|
+
"<p>This is <strong>disabled</strong> content</p>"
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const handleChange = (selectedVal) => {
|
|
54
|
+
setValue(selectedVal);
|
|
55
|
+
};
|
|
56
|
+
return (
|
|
57
|
+
<RichTextEditor
|
|
58
|
+
label="Test Text Editor"
|
|
59
|
+
required={true}
|
|
60
|
+
onChange={handleChange}
|
|
61
|
+
content={value}
|
|
62
|
+
disabled
|
|
45
63
|
/>
|
|
46
64
|
);
|
|
47
65
|
};
|
|
@@ -23,7 +23,7 @@ import { Tooltip } from "@mui/material";
|
|
|
23
23
|
import { kebabCase } from "lodash";
|
|
24
24
|
import DOMPurify from "dompurify";
|
|
25
25
|
|
|
26
|
-
const MenuBar = ({ editor }) => {
|
|
26
|
+
const MenuBar = ({ editor, disabled }) => {
|
|
27
27
|
if (!editor) {
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
@@ -43,6 +43,7 @@ const MenuBar = ({ editor }) => {
|
|
|
43
43
|
editor.chain().focus().toggleBold().run()
|
|
44
44
|
}
|
|
45
45
|
className={editor.isActive("bold") ? "is-active" : ""}
|
|
46
|
+
disabled={disabled}
|
|
46
47
|
>
|
|
47
48
|
<FormatBoldIcon />
|
|
48
49
|
</IconButton>
|
|
@@ -60,6 +61,7 @@ const MenuBar = ({ editor }) => {
|
|
|
60
61
|
editor.chain().focus().toggleItalic().run()
|
|
61
62
|
}
|
|
62
63
|
className={editor.isActive("italic") ? "is-active" : ""}
|
|
64
|
+
disabled={disabled}
|
|
63
65
|
>
|
|
64
66
|
<FormatItalicIcon />
|
|
65
67
|
</IconButton>
|
|
@@ -79,6 +81,7 @@ const MenuBar = ({ editor }) => {
|
|
|
79
81
|
className={
|
|
80
82
|
editor.isActive("underline") ? "is-active" : ""
|
|
81
83
|
}
|
|
84
|
+
disabled={disabled}
|
|
82
85
|
>
|
|
83
86
|
<FormatUnderlinedIcon />
|
|
84
87
|
</IconButton>
|
|
@@ -97,6 +100,7 @@ const MenuBar = ({ editor }) => {
|
|
|
97
100
|
}
|
|
98
101
|
className={editor.isActive("strike") ? "is-active" : ""}
|
|
99
102
|
style={{ borderRight: "solid 1px #9c9c9c" }}
|
|
103
|
+
disabled={disabled}
|
|
100
104
|
>
|
|
101
105
|
<StrikethroughSIcon />
|
|
102
106
|
</IconButton>
|
|
@@ -116,6 +120,7 @@ const MenuBar = ({ editor }) => {
|
|
|
116
120
|
className={
|
|
117
121
|
editor.isActive("orderedList") ? "is-active" : ""
|
|
118
122
|
}
|
|
123
|
+
disabled={disabled}
|
|
119
124
|
>
|
|
120
125
|
<FormatListNumberedIcon />
|
|
121
126
|
</IconButton>
|
|
@@ -136,6 +141,7 @@ const MenuBar = ({ editor }) => {
|
|
|
136
141
|
editor.isActive("bulletList") ? "is-active" : ""
|
|
137
142
|
}
|
|
138
143
|
style={{ borderRight: "solid 1px #9c9c9c" }}
|
|
144
|
+
disabled={disabled}
|
|
139
145
|
>
|
|
140
146
|
<FormatListBulletedIcon />
|
|
141
147
|
</IconButton>
|
|
@@ -159,6 +165,7 @@ const MenuBar = ({ editor }) => {
|
|
|
159
165
|
className={
|
|
160
166
|
editor.isActive("insertTable") ? "is-active" : ""
|
|
161
167
|
}
|
|
168
|
+
disabled={disabled}
|
|
162
169
|
>
|
|
163
170
|
<TableChartIcon />
|
|
164
171
|
</IconButton>
|
|
@@ -175,7 +182,8 @@ const RichTextEditor = ({
|
|
|
175
182
|
label,
|
|
176
183
|
onChange,
|
|
177
184
|
content,
|
|
178
|
-
disabled,
|
|
185
|
+
disabled = false,
|
|
186
|
+
readOnly = false,
|
|
179
187
|
}) => {
|
|
180
188
|
const editor = useEditor(
|
|
181
189
|
{
|
|
@@ -199,8 +207,9 @@ const RichTextEditor = ({
|
|
|
199
207
|
const newValue = editor.getHTML();
|
|
200
208
|
onChange(newValue);
|
|
201
209
|
},
|
|
210
|
+
editable: !disabled,
|
|
202
211
|
},
|
|
203
|
-
[content]
|
|
212
|
+
[content, disabled]
|
|
204
213
|
);
|
|
205
214
|
return (
|
|
206
215
|
<div
|
|
@@ -247,21 +256,21 @@ const RichTextEditor = ({
|
|
|
247
256
|
>
|
|
248
257
|
{label}
|
|
249
258
|
</InputLabel>
|
|
250
|
-
{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
{readOnly ? (
|
|
260
|
+
<p
|
|
261
|
+
className="rich-text-editor_read_only"
|
|
262
|
+
data-testid={`${id}-value`}
|
|
263
|
+
aria-labelledby={label}
|
|
264
|
+
dangerouslySetInnerHTML={{
|
|
265
|
+
__html: content ? DOMPurify.sanitize(content) : "-",
|
|
266
|
+
}}
|
|
267
|
+
/>
|
|
268
|
+
) : (
|
|
269
|
+
<>
|
|
270
|
+
<MenuBar editor={editor} disabled={disabled} />
|
|
271
|
+
<EditorContent editor={editor} />
|
|
272
|
+
</>
|
|
273
|
+
)}
|
|
265
274
|
</div>
|
|
266
275
|
);
|
|
267
276
|
};
|
|
@@ -274,10 +283,12 @@ RichTextEditor.propTypes = {
|
|
|
274
283
|
onChange: PropTypes.func,
|
|
275
284
|
content: PropTypes.any,
|
|
276
285
|
disabled: PropTypes.bool,
|
|
286
|
+
readOnly: PropTypes.bool,
|
|
277
287
|
};
|
|
278
288
|
|
|
279
289
|
MenuBar.propTypes = {
|
|
280
290
|
editor: PropTypes.any,
|
|
291
|
+
disabled: PropTypes.bool,
|
|
281
292
|
};
|
|
282
293
|
|
|
283
294
|
export default RichTextEditor;
|
|
@@ -105,6 +105,59 @@ export const Disabled = () => (
|
|
|
105
105
|
</Wrapper>
|
|
106
106
|
);
|
|
107
107
|
|
|
108
|
+
export const ReadOnlyWithNoValue = () => (
|
|
109
|
+
<Wrapper>
|
|
110
|
+
<Select
|
|
111
|
+
placeHolder={{ name: "placeholder", value: "" }}
|
|
112
|
+
defaultValue=""
|
|
113
|
+
label="Text Label"
|
|
114
|
+
id="measureName"
|
|
115
|
+
inputProps={{ "data-testid": "measure-name-input" }}
|
|
116
|
+
data-testid="measure-name-text-field"
|
|
117
|
+
size="small"
|
|
118
|
+
readOnly
|
|
119
|
+
options={options.map(({ key, value, testId, name }) => {
|
|
120
|
+
return (
|
|
121
|
+
<MenuItem
|
|
122
|
+
key={key}
|
|
123
|
+
value={value}
|
|
124
|
+
data-testid={`option-${testId}`}
|
|
125
|
+
>
|
|
126
|
+
{name}
|
|
127
|
+
</MenuItem>
|
|
128
|
+
);
|
|
129
|
+
})}
|
|
130
|
+
/>
|
|
131
|
+
</Wrapper>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
export const ReadOnlyWithValue = () => (
|
|
135
|
+
<Wrapper>
|
|
136
|
+
<Select
|
|
137
|
+
placeHolder={{ name: "placeholder", value: "" }}
|
|
138
|
+
defaultValue=""
|
|
139
|
+
label="Text Label"
|
|
140
|
+
id="measureName"
|
|
141
|
+
inputProps={{ "data-testid": "measure-name-input" }}
|
|
142
|
+
data-testid="measure-name-text-field"
|
|
143
|
+
size="small"
|
|
144
|
+
readOnly
|
|
145
|
+
options={options.map(({ key, value, testId, name }) => {
|
|
146
|
+
return (
|
|
147
|
+
<MenuItem
|
|
148
|
+
key={key}
|
|
149
|
+
value={value}
|
|
150
|
+
data-testid={`option-${testId}`}
|
|
151
|
+
>
|
|
152
|
+
{name}
|
|
153
|
+
</MenuItem>
|
|
154
|
+
);
|
|
155
|
+
})}
|
|
156
|
+
value="name1"
|
|
157
|
+
/>
|
|
158
|
+
</Wrapper>
|
|
159
|
+
);
|
|
160
|
+
|
|
108
161
|
export const Required = () => (
|
|
109
162
|
<Wrapper>
|
|
110
163
|
<Select
|
|
@@ -10,6 +10,7 @@ const Select = ({
|
|
|
10
10
|
placeHolder = undefined, // expects placeholder objects of { name: value } and inserts into the render item function.
|
|
11
11
|
required = false,
|
|
12
12
|
disabled = false,
|
|
13
|
+
readOnly = false,
|
|
13
14
|
id,
|
|
14
15
|
error = false,
|
|
15
16
|
label,
|
|
@@ -25,7 +26,7 @@ const Select = ({
|
|
|
25
26
|
],
|
|
26
27
|
...rest
|
|
27
28
|
}) => {
|
|
28
|
-
if (
|
|
29
|
+
if (readOnly) {
|
|
29
30
|
return (
|
|
30
31
|
<ReadOnlyTextField
|
|
31
32
|
required={required}
|
|
@@ -34,7 +35,7 @@ const Select = ({
|
|
|
34
35
|
size="small"
|
|
35
36
|
{...rest}
|
|
36
37
|
/>
|
|
37
|
-
)
|
|
38
|
+
);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const placehold = (
|
|
@@ -182,6 +183,7 @@ Select.propTypes = {
|
|
|
182
183
|
}), // expects placeholder objects of { name: value } and inserts into the render item function.
|
|
183
184
|
required: PropTypes.bool,
|
|
184
185
|
disabled: PropTypes.bool,
|
|
186
|
+
readOnly: PropTypes.bool,
|
|
185
187
|
error: PropTypes.bool,
|
|
186
188
|
label: PropTypes.string,
|
|
187
189
|
helperText: PropTypes.string,
|
|
@@ -49,6 +49,22 @@ export const WithHelperText = () => (
|
|
|
49
49
|
</Wrapper>
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
+
export const ReadOnlyWithValue = () => (
|
|
53
|
+
<Wrapper>
|
|
54
|
+
<TextArea
|
|
55
|
+
placeholder="Placeholder"
|
|
56
|
+
label="Text Label"
|
|
57
|
+
id="measureName"
|
|
58
|
+
inputProps={{ "data-testid": "measure-name-input" }}
|
|
59
|
+
data-testid="measure-name-text-field"
|
|
60
|
+
size="small"
|
|
61
|
+
value="This is a read only text area"
|
|
62
|
+
readOnly
|
|
63
|
+
required
|
|
64
|
+
/>
|
|
65
|
+
</Wrapper>
|
|
66
|
+
);
|
|
67
|
+
|
|
52
68
|
export const DisabledWithValue = () => (
|
|
53
69
|
<Wrapper>
|
|
54
70
|
<TextArea
|
|
@@ -10,21 +10,23 @@ const TextArea = ({
|
|
|
10
10
|
helperText = undefined,
|
|
11
11
|
required = false,
|
|
12
12
|
disabled = false,
|
|
13
|
+
readOnly = false,
|
|
13
14
|
label,
|
|
14
15
|
inputProps,
|
|
15
16
|
maxLength = undefined,
|
|
16
17
|
...rest
|
|
17
18
|
}) => {
|
|
18
|
-
if (
|
|
19
|
+
if (readOnly) {
|
|
19
20
|
return (
|
|
20
21
|
<ReadOnlyTextField
|
|
21
22
|
required={required}
|
|
22
23
|
label={label}
|
|
23
24
|
id={id}
|
|
24
25
|
size="small"
|
|
26
|
+
{...inputProps}
|
|
25
27
|
{...rest}
|
|
26
28
|
/>
|
|
27
|
-
)
|
|
29
|
+
);
|
|
28
30
|
}
|
|
29
31
|
// coerce this to avoid issue passing props to dom.
|
|
30
32
|
// text area autosize is deprecated and only takes style rules
|
|
@@ -137,6 +139,7 @@ TextArea.propTypes = {
|
|
|
137
139
|
helperText: PropTypes.string,
|
|
138
140
|
required: PropTypes.bool,
|
|
139
141
|
disabled: PropTypes.bool,
|
|
142
|
+
readOnly: PropTypes.bool,
|
|
140
143
|
placeholder: PropTypes.string, // expects placeholder objects of { name: value } and inserts into the render item function.
|
|
141
144
|
label: PropTypes.string,
|
|
142
145
|
inputProps: PropTypes.any,
|
|
@@ -52,6 +52,20 @@ export const WithHelperText = () => (
|
|
|
52
52
|
</Wrapper>
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
+
export const ReadOnly = () => (
|
|
56
|
+
<Wrapper>
|
|
57
|
+
<TextField
|
|
58
|
+
placeholder="Placeholder"
|
|
59
|
+
label="ReadOnly Text Label"
|
|
60
|
+
id="measureName"
|
|
61
|
+
inputProps={{ "data-testid": "measure-name-input" }}
|
|
62
|
+
data-testid="measure-name-text-field"
|
|
63
|
+
size="small"
|
|
64
|
+
readOnly
|
|
65
|
+
/>
|
|
66
|
+
</Wrapper>
|
|
67
|
+
);
|
|
68
|
+
|
|
55
69
|
export const Disabled = () => (
|
|
56
70
|
<Wrapper>
|
|
57
71
|
<TextField
|