@madie/madie-design-system 1.2.102 → 1.2.103
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/.babelrc +0 -1
- package/.storybook/main.mjs +38 -0
- package/README.md +18 -0
- package/components/Breadcrumb/Breadcrumb.stories.js +9 -8
- package/components/Button/Button.stories.js +0 -2
- package/components/CalloutBox/CalloutBox.stories.js +0 -2
- package/components/Card/Card.stories.js +0 -2
- package/components/DateField/DateField.stories.jsx +0 -2
- package/components/DateTimeField/DateTimeField.stories.jsx +0 -2
- package/components/Dropdown/Dropdown.stories.js +0 -2
- package/components/Footer/Footer.stories.js +11 -7
- package/components/HowItWorks/HowItWorks.stories.js +0 -2
- package/components/Infotip/Infotip.stories.js +3 -4
- package/components/Instant/Instant.stories.js +0 -2
- package/components/Link/Link.stories.js +0 -2
- package/components/MadieAlert/MadieAlert.stories.js +0 -2
- package/components/MadieConfirmDialog/MadieConfirmDialog.stories.js +0 -2
- package/components/MadieDeleteDialog/MadieDeleteDialog.stories.js +0 -2
- package/components/MadieDialog/MadieDialog.stories.js +0 -2
- package/components/MadieDiscardDialog/MadieDiscardDialog.stories.js +0 -2
- package/components/MadieSpinner/MadieSpinner.stories.js +0 -2
- package/components/MadieTable/MadieTable.stories.js +93 -0
- package/components/MadieTable/index.jsx +34 -8
- package/components/Modal/Modal.stories.js +19 -25
- package/components/NotificationBanner/NotificationBanner.stories.js +5 -4
- package/components/NumberInput/NumberInput.stories.js +0 -2
- package/components/Popover/Popover.stories.js +0 -2
- package/components/ReadOnlyTextField/ReadOnlyTextField.stories.js +0 -2
- package/components/RichTextEditor/RichTextEditor.stories.js +0 -2
- package/components/SearchAndFilter/index.jsx +1 -1
- package/components/Select/Select.stories.js +0 -2
- package/components/Tabs/Tabs.stories.js +0 -2
- package/components/TextArea/TextArea.stories.js +0 -2
- package/components/TextField/TextField.stories.js +0 -2
- package/components/TextInput/TextInput.stories.js +0 -2
- package/components/TimeField/TimeField.jsx +1 -1
- package/components/TimeField/TimeField.stories.js +0 -2
- package/components/Toast/Toast.stories.js +0 -2
- package/components/TruncateText/TruncateText.stories.js +0 -2
- package/components/TruncateText/index.js +12 -1
- package/components/index.js +0 -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.LICENSE.txt +1 -1
- package/dist/react/index.js.map +1 -1
- package/jest.config.js +0 -4
- package/package.json +15 -25
- package/styles/_main.scss +0 -6
- package/test/components/MadieTable.test.js +38 -0
- package/test/components/TruncateText.test.js +38 -0
- package/.storybook/main.js +0 -61
- package/components/Spinner/index.js +0 -9
- package/components/UnwrappedSpinner/index.js +0 -8
- package/test/__mocks__/styled-components-macro.js +0 -2
- package/test/__mocks__/twin.macro.js +0 -24
package/jest.config.js
CHANGED
|
@@ -6,10 +6,6 @@ module.exports = {
|
|
|
6
6
|
"^.+\\.(j|t)sx?$": "babel-jest",
|
|
7
7
|
},
|
|
8
8
|
setupFilesAfterEnv: ["@testing-library/jest-dom"],
|
|
9
|
-
moduleNameMapper: {
|
|
10
|
-
"^twin.macro$": "<rootDir>/test/__mocks__/twin.macro.js",
|
|
11
|
-
"^styled-components/macro$": "<rootDir>/test/__mocks__/styled-components-macro.js",
|
|
12
|
-
},
|
|
13
9
|
globals: {
|
|
14
10
|
"ts-jest": {
|
|
15
11
|
tsconfig: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madie/madie-design-system",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.103",
|
|
4
4
|
"description": "Shared style guide across the Madie program.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"homepage": "https://github.com/MeasureAuthoringTool/madie-design-system",
|
|
@@ -23,37 +23,26 @@
|
|
|
23
23
|
"stylelint": "stylelint 'styles/**/*.{css,scss}'",
|
|
24
24
|
"format-styles": "prettier 'styles/**/*.{css,scss}' --write --quiet",
|
|
25
25
|
"storybook": "storybook dev -p 6007",
|
|
26
|
-
"build-storybook": "storybook build"
|
|
27
|
-
"predeploy": "npm run build-storybook",
|
|
28
|
-
"deploy": "gh-pages -d storybook-static"
|
|
26
|
+
"build-storybook": "storybook build"
|
|
29
27
|
},
|
|
30
28
|
"devDependencies": {
|
|
31
|
-
"@babel/cli": "^7.25.6",
|
|
32
29
|
"@babel/core": "^7.25.2",
|
|
33
30
|
"@babel/preset-env": "^7.25.4",
|
|
34
31
|
"@babel/preset-react": "^7.24.7",
|
|
35
32
|
"@babel/register": "^7.24.6",
|
|
36
|
-
"@storybook/addon-a11y": "^
|
|
37
|
-
"@storybook/addon-
|
|
38
|
-
"@storybook/addon-
|
|
39
|
-
"@storybook/
|
|
40
|
-
"@storybook/
|
|
41
|
-
"@storybook/addon-links": "^8.3.0",
|
|
42
|
-
"@storybook/addon-storysource": "^8.3.0",
|
|
43
|
-
"@storybook/addon-viewport": "^8.3.0",
|
|
44
|
-
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
|
|
45
|
-
"@storybook/addons": "^7.6.17",
|
|
46
|
-
"@storybook/react": "^8.3.0",
|
|
47
|
-
"@storybook/react-webpack5": "^8.3.0",
|
|
33
|
+
"@storybook/addon-a11y": "^10.6.2",
|
|
34
|
+
"@storybook/addon-docs": "^10.6.2",
|
|
35
|
+
"@storybook/addon-links": "^10.6.2",
|
|
36
|
+
"@storybook/react": "^10.6.2",
|
|
37
|
+
"@storybook/react-vite": "^10.6.2",
|
|
48
38
|
"@testing-library/jest-dom": "^6.1.4",
|
|
49
39
|
"@testing-library/react": "^12.1.2",
|
|
50
40
|
"@testing-library/user-event": "^13.5.0",
|
|
51
41
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
|
|
52
42
|
"autoprefixer": "^10.4.2",
|
|
53
43
|
"babel-eslint": "^10.1.0",
|
|
54
|
-
"babel-jest": "^
|
|
44
|
+
"babel-jest": "^30.0.0",
|
|
55
45
|
"babel-loader": "^8.2.3",
|
|
56
|
-
"babel-plugin-macros": "^3.1.0",
|
|
57
46
|
"chai": "^4.3.4",
|
|
58
47
|
"css-loader": "^7.1.2",
|
|
59
48
|
"enzyme": "^3.11.0",
|
|
@@ -65,10 +54,9 @@
|
|
|
65
54
|
"eslint-plugin-react": "^7.28.0",
|
|
66
55
|
"feather-icons-react": "^0.4.3",
|
|
67
56
|
"file-loader": "^6.2.0",
|
|
68
|
-
"gh-pages": "^6.0.0",
|
|
69
57
|
"html-webpack-plugin": "^5.5.0",
|
|
70
|
-
"jest": "^
|
|
71
|
-
"jest-environment-jsdom": "^
|
|
58
|
+
"jest": "^30.0.0",
|
|
59
|
+
"jest-environment-jsdom": "^30.0.0",
|
|
72
60
|
"mini-css-extract-plugin": "^0.11.3",
|
|
73
61
|
"moxios": "^0.4.0",
|
|
74
62
|
"node-fetch": "^2.6.7",
|
|
@@ -83,8 +71,11 @@
|
|
|
83
71
|
"sass": "^1.48.0",
|
|
84
72
|
"sass-loader": "^10.2.1",
|
|
85
73
|
"sinon": "^12.0.1",
|
|
74
|
+
"storybook": "^10.6.2",
|
|
86
75
|
"style-loader": "^1.3.0",
|
|
87
76
|
"svgo-loader": "^4.0.0",
|
|
77
|
+
"terser-webpack-plugin": "^5.6.1",
|
|
78
|
+
"vite": "^7.3.7",
|
|
88
79
|
"webpack": "^5.70.0",
|
|
89
80
|
"webpack-cli": "^4.9.2"
|
|
90
81
|
},
|
|
@@ -106,7 +97,6 @@
|
|
|
106
97
|
"url": "https://github.com/MeasureAuthoringTool/madie-design-system/issues"
|
|
107
98
|
},
|
|
108
99
|
"dependencies": {
|
|
109
|
-
"@cmsgov/design-system": "^5.0.2",
|
|
110
100
|
"@emotion/react": "^11.8.2",
|
|
111
101
|
"@emotion/styled": "^11.8.1",
|
|
112
102
|
"@mui/icons-material": "^6.1.0",
|
|
@@ -144,8 +134,7 @@
|
|
|
144
134
|
"retry": "^0.13.1",
|
|
145
135
|
"styled-components": "^5.3.7",
|
|
146
136
|
"svgo": "^3.3.4",
|
|
147
|
-
"tailwindcss": "^3.
|
|
148
|
-
"twin.macro": "^3.4.0",
|
|
137
|
+
"tailwindcss": "^4.3.3",
|
|
149
138
|
"what-input": "^5.2.10",
|
|
150
139
|
"xss": "^1.0.10",
|
|
151
140
|
"yaml": "^2.9.0"
|
|
@@ -162,6 +151,7 @@
|
|
|
162
151
|
"glob-parent": "^6.0.1",
|
|
163
152
|
"semver": "^7.5.3",
|
|
164
153
|
"optionator": "0.9.3",
|
|
154
|
+
"webpack-dev-middleware": "^7.4.5",
|
|
165
155
|
"@cmsgov/design-system": {
|
|
166
156
|
"inquirer": {
|
|
167
157
|
"external-editor": {
|
package/styles/_main.scss
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
@charset "utf-8";
|
|
2
2
|
|
|
3
|
-
// TODO: Remove @cmsgov/design-system dependancies from shared package
|
|
4
|
-
$font-path: "~@cmsgov/design-system/dist/fonts";
|
|
5
|
-
$image-path: "~@cmsgov/design-system/dist/images";
|
|
6
|
-
|
|
7
|
-
@import "@cmsgov/design-system/dist/scss/index";
|
|
8
|
-
|
|
9
3
|
@import "paths";
|
|
10
4
|
|
|
11
5
|
@import "third-party/legacy-bootstrap";
|
|
@@ -15,6 +15,7 @@ const TestTableWrapper = ({
|
|
|
15
15
|
handleSort = jest.fn(),
|
|
16
16
|
renderExpandedRow,
|
|
17
17
|
emptyMessage,
|
|
18
|
+
ariaLabel,
|
|
18
19
|
}) => {
|
|
19
20
|
const table = useReactTable({
|
|
20
21
|
data,
|
|
@@ -30,6 +31,7 @@ const TestTableWrapper = ({
|
|
|
30
31
|
handleSort={handleSort}
|
|
31
32
|
renderExpandedRow={renderExpandedRow}
|
|
32
33
|
emptyMessage={emptyMessage}
|
|
34
|
+
ariaLabel={ariaLabel}
|
|
33
35
|
/>
|
|
34
36
|
);
|
|
35
37
|
};
|
|
@@ -188,4 +190,40 @@ it("renders descending sort icon when currentSort is DESC", () => {
|
|
|
188
190
|
).toBeInTheDocument();
|
|
189
191
|
});
|
|
190
192
|
|
|
193
|
+
it("exposes sort state through aria-sort on the column header", () => {
|
|
194
|
+
render(
|
|
195
|
+
<TestTableWrapper
|
|
196
|
+
data={data}
|
|
197
|
+
columns={columns}
|
|
198
|
+
currentSort="name"
|
|
199
|
+
currentDirection="ASC"
|
|
200
|
+
/>
|
|
201
|
+
);
|
|
202
|
+
expect(
|
|
203
|
+
screen.getByRole("columnheader", { name: /measure name/i })
|
|
204
|
+
).toHaveAttribute("aria-sort", "ascending");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("marks unsorted sortable headers with aria-sort none", () => {
|
|
208
|
+
render(<TestTableWrapper data={data} columns={columns} />);
|
|
209
|
+
expect(
|
|
210
|
+
screen.getByRole("columnheader", { name: /measure name/i })
|
|
211
|
+
).toHaveAttribute("aria-sort", "none");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("makes sortable headers keyboard focusable and shows the sort affordance on focus", () => {
|
|
215
|
+
render(<TestTableWrapper data={data} columns={columns} />);
|
|
216
|
+
const button = screen.getByRole("button", { name: /measure name/i });
|
|
217
|
+
button.focus();
|
|
218
|
+
expect(button).toHaveFocus();
|
|
219
|
+
expect(screen.getByTestId("unfold-more-icon")).toBeInTheDocument();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("applies an accessible name to the table", () => {
|
|
223
|
+
render(
|
|
224
|
+
<TestTableWrapper data={data} columns={columns} ariaLabel="Measures" />
|
|
225
|
+
);
|
|
226
|
+
expect(screen.getByRole("table", { name: "Measures" })).toBeInTheDocument();
|
|
227
|
+
});
|
|
228
|
+
|
|
191
229
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { TruncateText } from "../../components";
|
|
5
|
+
|
|
6
|
+
describe("TruncateText", () => {
|
|
7
|
+
const longText = "This is a long description that should be truncated";
|
|
8
|
+
|
|
9
|
+
it("renders full text without a toggle when within the limit", () => {
|
|
10
|
+
render(<TruncateText text="short" maxLength={10} dataTestId="t" />);
|
|
11
|
+
expect(screen.getByText("short")).toBeInTheDocument();
|
|
12
|
+
expect(screen.queryByRole("button")).not.toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("is reachable by keyboard and toggles with Enter", () => {
|
|
16
|
+
render(<TruncateText text={longText} maxLength={5} dataTestId="t" />);
|
|
17
|
+
userEvent.tab();
|
|
18
|
+
const button = screen.getByRole("button", { name: "Show more" });
|
|
19
|
+
expect(button).toHaveFocus();
|
|
20
|
+
expect(button).toHaveAttribute("type", "button");
|
|
21
|
+
expect(button).toHaveAttribute("aria-expanded", "false");
|
|
22
|
+
userEvent.keyboard("{enter}");
|
|
23
|
+
expect(screen.getByText(longText)).toBeInTheDocument();
|
|
24
|
+
expect(screen.getByRole("button", { name: "Show less" })).toHaveAttribute(
|
|
25
|
+
"aria-expanded",
|
|
26
|
+
"true"
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("links the toggle to the text it controls", () => {
|
|
31
|
+
render(<TruncateText text={longText} maxLength={5} dataTestId="t" />);
|
|
32
|
+
const button = screen.getByRole("button");
|
|
33
|
+
const target = document.getElementById(
|
|
34
|
+
button.getAttribute("aria-controls")
|
|
35
|
+
);
|
|
36
|
+
expect(target).toHaveTextContent("This");
|
|
37
|
+
});
|
|
38
|
+
});
|
package/.storybook/main.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
stories: [
|
|
3
|
-
"../components/**/*.@(mdx|stories.@(js|jsx))",
|
|
4
|
-
"../lib/**/*.@(mdx|stories.@(js|jsx))"
|
|
5
|
-
],
|
|
6
|
-
|
|
7
|
-
addons: [
|
|
8
|
-
"@storybook/addon-actions",
|
|
9
|
-
"@storybook/addon-links",
|
|
10
|
-
"@storybook/addon-storysource",
|
|
11
|
-
"@storybook/addon-knobs",
|
|
12
|
-
"@storybook/addon-a11y",
|
|
13
|
-
"@storybook/addon-docs",
|
|
14
|
-
"@storybook/addon-backgrounds",
|
|
15
|
-
"@storybook/addon-viewport",
|
|
16
|
-
"@storybook/addon-webpack5-compiler-babel"
|
|
17
|
-
],
|
|
18
|
-
|
|
19
|
-
webpackFinal: async (config) => {
|
|
20
|
-
// do mutation to the config
|
|
21
|
-
|
|
22
|
-
config.module.rules.push({
|
|
23
|
-
test: /\.scss$/,
|
|
24
|
-
resolve: {
|
|
25
|
-
extensions: [".scss", ".sass"],
|
|
26
|
-
},
|
|
27
|
-
use: [
|
|
28
|
-
{ loader: "style-loader" },
|
|
29
|
-
{
|
|
30
|
-
loader: "css-loader",
|
|
31
|
-
options: { sourceMap: true, importLoaders: 1 },
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
loader: "sass-loader",
|
|
35
|
-
options: {
|
|
36
|
-
sourceMap: true,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
// the below lines add hot reload, but somehow put CI/CD into a hanging state
|
|
42
|
-
// config.watchOptions = {
|
|
43
|
-
// aggregateTimeout: 300, // Delay before rebuilding after the first change
|
|
44
|
-
// poll: 1000, // Check for changes every second
|
|
45
|
-
// ignored: /node_modules/, // Ignore node_modules to improve performance
|
|
46
|
-
// };
|
|
47
|
-
|
|
48
|
-
return config;
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
framework: {
|
|
52
|
-
name: "@storybook/react-webpack5",
|
|
53
|
-
options: {}
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
docs: {},
|
|
57
|
-
|
|
58
|
-
typescript: {
|
|
59
|
-
reactDocgen: "react-docgen-typescript"
|
|
60
|
-
}
|
|
61
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const React = require("react");
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns a tagged-template function that
|
|
5
|
-
* produces a valid React component.
|
|
6
|
-
*/
|
|
7
|
-
const createMockTag = (tag) => {
|
|
8
|
-
return () =>
|
|
9
|
-
React.forwardRef(({ children, ...props }, ref) =>
|
|
10
|
-
React.createElement(tag, { ref, ...props }, children)
|
|
11
|
-
);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const proxy = new Proxy(
|
|
15
|
-
{},
|
|
16
|
-
{
|
|
17
|
-
get: (_target, key) => createMockTag(key),
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
module.exports = {
|
|
22
|
-
__esModule: true,
|
|
23
|
-
default: proxy,
|
|
24
|
-
};
|