@madie/madie-design-system 1.2.95 → 1.2.97
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/.storybook/main.js +0 -1
- package/components/MadieTooltip/index.jsx +7 -1
- package/components/RichTextEditor/index.jsx +7 -6
- package/components/TextField/TextField.stories.js +19 -0
- package/components/TextField/index.jsx +69 -22
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +5 -5
- package/dist/react/index.js.LICENSE.txt +21 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +13 -14
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/index.html +169 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/a11y-5/manager-bundle.js +220 -0
- package/storybook-static/sb-addons/actions-1/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/backgrounds-7/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/docs-6/manager-bundle.js +245 -0
- package/storybook-static/sb-addons/knobs-4/register-bundle.js +23 -0
- package/storybook-static/sb-addons/knobs-4/register-bundle.js.LEGAL.txt +11 -0
- package/storybook-static/sb-addons/links-2/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook-static/sb-addons/storysource-3/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/viewport-8/manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +1052 -0
- package/storybook-static/sb-manager/globals-runtime.js +41775 -0
- package/storybook-static/sb-manager/globals.js +48 -0
- package/storybook-static/sb-manager/runtime.js +12048 -0
- package/storybook-static/sb-preview/globals.js +33 -0
- package/storybook-static/sb-preview/runtime.js +7745 -0
- package/test/components/TextField.test.js +45 -0
- package/webpack.config.js +0 -1
package/.storybook/main.js
CHANGED
|
@@ -27,7 +27,13 @@ const MadieToolTip =
|
|
|
27
27
|
}}
|
|
28
28
|
{...rest}
|
|
29
29
|
>
|
|
30
|
-
<div
|
|
30
|
+
<div
|
|
31
|
+
aria-describedby={id}
|
|
32
|
+
tabIndex={0}
|
|
33
|
+
style={{ width: widthContainer, height: heightContainer}}
|
|
34
|
+
data-testId={id}
|
|
35
|
+
id={id}
|
|
36
|
+
>
|
|
31
37
|
<TooltipIcon />
|
|
32
38
|
</div>
|
|
33
39
|
</Tooltip>
|
|
@@ -3,12 +3,13 @@ import React from "react";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
5
5
|
import InputLabel from "../InputLabel";
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
import { Gapcursor } from "@tiptap/extensions";
|
|
7
|
+
import {
|
|
8
|
+
Table,
|
|
9
|
+
TableCell,
|
|
10
|
+
TableHeader,
|
|
11
|
+
TableRow,
|
|
12
|
+
} from "@tiptap/extension-table";
|
|
12
13
|
import Underline from "@tiptap/extension-underline";
|
|
13
14
|
import StarterKit from "@tiptap/starter-kit";
|
|
14
15
|
import { IconButton, FormHelperText } from "@mui/material";
|
|
@@ -212,6 +212,25 @@ export const TextfieldDifferentLabel = () => (
|
|
|
212
212
|
inputProps={{ "data-testid": "measure-name-input" }}
|
|
213
213
|
data-testid="measure-name-text-field"
|
|
214
214
|
size="small"
|
|
215
|
+
value="This is a test value"
|
|
216
|
+
maxLength={500}
|
|
217
|
+
/>
|
|
218
|
+
</Wrapper>
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
export const TextFieldWithRecommendationText = () => (
|
|
222
|
+
<Wrapper>
|
|
223
|
+
<TextField
|
|
224
|
+
placeholder="Placeholder"
|
|
225
|
+
label="With recommendation text"
|
|
226
|
+
id="measureName"
|
|
227
|
+
inputProps={{ "data-testid": "measure-name-input" }}
|
|
228
|
+
data-testid="measure-name-text-field"
|
|
229
|
+
size="small"
|
|
230
|
+
value="This is a test value"
|
|
231
|
+
maxLength={500}
|
|
232
|
+
helperText="Must contain at least one letter and must not contain special characters and underscores"
|
|
233
|
+
recommendation="Strongly recommend to have under 30 characters"
|
|
215
234
|
/>
|
|
216
235
|
</Wrapper>
|
|
217
236
|
);
|
|
@@ -22,6 +22,7 @@ const TextField = ({
|
|
|
22
22
|
labelColor = undefined,
|
|
23
23
|
textFieldStyles = {},
|
|
24
24
|
maxLength = undefined,
|
|
25
|
+
recommendation = undefined,
|
|
25
26
|
...rest
|
|
26
27
|
}) => {
|
|
27
28
|
if (readOnly) {
|
|
@@ -35,24 +36,31 @@ const TextField = ({
|
|
|
35
36
|
/>
|
|
36
37
|
);
|
|
37
38
|
}
|
|
39
|
+
const showMaxLength = Boolean(maxLength) && !disabled;
|
|
40
|
+
const showRecommendation = Boolean(recommendation) && !disabled;
|
|
38
41
|
// get a copy of input props
|
|
39
42
|
const newInputProps = { ...inputProps } || {};
|
|
40
43
|
|
|
41
44
|
if (!newInputProps["data-testid"]) {
|
|
42
45
|
newInputProps["data-testid"] = `${id}-input`;
|
|
43
46
|
}
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
// Build aria-describedby ids so helper, tooltip, and recommendation are announced on input focus.
|
|
48
|
+
const describedByIds = new Set(
|
|
49
|
+
`${newInputProps["aria-describedby"] || ""}`
|
|
50
|
+
.split(/\s+/)
|
|
51
|
+
.filter(Boolean)
|
|
52
|
+
);
|
|
53
|
+
if (helperText) {
|
|
54
|
+
describedByIds.add(`${id}-helper-text`);
|
|
55
|
+
}
|
|
56
|
+
if (tooltipText) {
|
|
57
|
+
describedByIds.add(`${id}-tooltip`);
|
|
58
|
+
}
|
|
59
|
+
if (showRecommendation) {
|
|
60
|
+
describedByIds.add(`${id}-recommendation-text`);
|
|
61
|
+
}
|
|
62
|
+
if (describedByIds.size) {
|
|
63
|
+
newInputProps["aria-describedby"] = Array.from(describedByIds).join(" ");
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
const extendedTextFieldStyles = {
|
|
@@ -89,6 +97,7 @@ const TextField = ({
|
|
|
89
97
|
},
|
|
90
98
|
...textFieldStyles,
|
|
91
99
|
};
|
|
100
|
+
|
|
92
101
|
return (
|
|
93
102
|
<FormControl fullWidth error={error}>
|
|
94
103
|
<div
|
|
@@ -187,19 +196,56 @@ const TextField = ({
|
|
|
187
196
|
}}
|
|
188
197
|
{...rest}
|
|
189
198
|
/>
|
|
190
|
-
|
|
191
|
-
|
|
199
|
+
|
|
200
|
+
{(showRecommendation || showMaxLength) && (
|
|
201
|
+
<div
|
|
192
202
|
style={{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
203
|
+
display: "flex",
|
|
204
|
+
justifyContent: "space-between",
|
|
205
|
+
alignItems: "flex-start",
|
|
206
|
+
gap: 8,
|
|
207
|
+
marginTop: 4,
|
|
208
|
+
width: "100%",
|
|
199
209
|
}}
|
|
200
210
|
>
|
|
201
|
-
{
|
|
202
|
-
|
|
211
|
+
<div style={{ flex: 1, minWidth: 0 }}>
|
|
212
|
+
{showRecommendation && (
|
|
213
|
+
<FormHelperText
|
|
214
|
+
aria-live="polite"
|
|
215
|
+
id={`${id}-recommendation-text`}
|
|
216
|
+
data-testid={`${id}-recommendation-text`}
|
|
217
|
+
sx={[
|
|
218
|
+
{
|
|
219
|
+
margin: 0,
|
|
220
|
+
color: "#515151",
|
|
221
|
+
lineHeight: 1.2,
|
|
222
|
+
overflowWrap: "anywhere",
|
|
223
|
+
},
|
|
224
|
+
error && {
|
|
225
|
+
color: "#AE1C1C !important",
|
|
226
|
+
},
|
|
227
|
+
]}
|
|
228
|
+
>
|
|
229
|
+
{recommendation}
|
|
230
|
+
</FormHelperText>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
{showMaxLength && (
|
|
235
|
+
<span
|
|
236
|
+
style={{
|
|
237
|
+
fontFamily: "Rubik",
|
|
238
|
+
fontSize: 12,
|
|
239
|
+
color: "#717171",
|
|
240
|
+
whiteSpace: "nowrap",
|
|
241
|
+
flexShrink: 0,
|
|
242
|
+
alignSelf: "flex-start",
|
|
243
|
+
}}
|
|
244
|
+
>
|
|
245
|
+
{rest.value?.length}/{maxLength} Characters
|
|
246
|
+
</span>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
203
249
|
)}
|
|
204
250
|
</FormControl>
|
|
205
251
|
);
|
|
@@ -219,5 +265,6 @@ TextField.propTypes = {
|
|
|
219
265
|
inputProps: PropTypes.object,
|
|
220
266
|
labelColor: PropTypes.string,
|
|
221
267
|
maxLength: PropTypes.number,
|
|
268
|
+
recommendation: PropTypes.string,
|
|
222
269
|
};
|
|
223
270
|
export default TextField;
|