@madie/madie-design-system 1.2.89 → 1.2.91
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 +6 -2
- package/components/MadieTable/index.jsx +162 -0
- package/components/SearchAndFilter/index.jsx +123 -0
- package/components/SearchAndFilter/useFilterSearch.jsx +60 -0
- package/components/index.js +10 -2
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +26 -26
- package/dist/react/index.js.LICENSE.txt +23 -1
- package/dist/react/index.js.map +1 -1
- package/jest.config.js +4 -0
- package/package.json +8 -1
- package/styles/components/_search-and-filter.scss +13 -0
- package/styles/qppds/components/_search-and-filter.scss +13 -0
- package/test/__mocks__/styled-components-macro.js +2 -0
- package/test/__mocks__/twin.macro.js +24 -0
- package/test/components/MadieTable.test.js +176 -0
- package/test/components/SearchAndFilter.test.js +78 -0
- package/test/components/UseFilterSearch.test.js +164 -0
- package/webpack.config.js +4 -1
- package/webpack.config.react.js +1 -1
- package/components/Search/Search.stories.js +0 -21
- package/components/Search/index.js +0 -86
package/jest.config.js
CHANGED
|
@@ -6,6 +6,10 @@ 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
|
+
},
|
|
9
13
|
globals: {
|
|
10
14
|
"ts-jest": {
|
|
11
15
|
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.91",
|
|
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",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"babel-eslint": "^10.1.0",
|
|
55
55
|
"babel-jest": "^27.4.6",
|
|
56
56
|
"babel-loader": "^8.2.3",
|
|
57
|
+
"babel-plugin-macros": "^3.1.0",
|
|
57
58
|
"chai": "^4.3.4",
|
|
58
59
|
"copy-webpack-plugin": "^5.1.2",
|
|
59
60
|
"css-loader": "^7.1.2",
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
"mini-css-extract-plugin": "^0.11.3",
|
|
74
75
|
"moxios": "^0.4.0",
|
|
75
76
|
"node-fetch": "^2.6.7",
|
|
77
|
+
"path-browserify": "^1.0.1",
|
|
76
78
|
"prettier": "^2.5.1",
|
|
77
79
|
"raw-loader": "^4.0.2",
|
|
78
80
|
"react": "^17.0.2",
|
|
@@ -141,11 +143,16 @@
|
|
|
141
143
|
"react-draggable": "^4.4.6",
|
|
142
144
|
"react-modal": "^3.14.4",
|
|
143
145
|
"retry": "^0.13.1",
|
|
146
|
+
"styled-components": "^5.3.7",
|
|
144
147
|
"svgo": "^3.0.3",
|
|
148
|
+
"tailwindcss": "^3.4.10",
|
|
149
|
+
"twin.macro": "^3.4.0",
|
|
145
150
|
"what-input": "^5.2.10",
|
|
146
151
|
"xss": "^1.0.10"
|
|
147
152
|
},
|
|
148
153
|
"peerDependencies": {
|
|
154
|
+
"@tanstack/match-sorter-utils": "^8.8.4",
|
|
155
|
+
"@tanstack/react-table": "^8.10.3",
|
|
149
156
|
"classnames": "^2.3.1"
|
|
150
157
|
},
|
|
151
158
|
"overrides": {
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
|
|
3
|
+
import { createColumnHelper, useReactTable, getCoreRowModel } from "@tanstack/react-table";
|
|
4
|
+
import { MadieTable } from "../../components";
|
|
5
|
+
import userEvent from "@testing-library/user-event";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Test helper component to provide a real TanStack table instance
|
|
9
|
+
*/
|
|
10
|
+
const TestTableWrapper = ({
|
|
11
|
+
data,
|
|
12
|
+
columns,
|
|
13
|
+
currentSort,
|
|
14
|
+
currentDirection,
|
|
15
|
+
handleSort = jest.fn(),
|
|
16
|
+
renderExpandedRow,
|
|
17
|
+
}) => {
|
|
18
|
+
const table = useReactTable({
|
|
19
|
+
data,
|
|
20
|
+
columns,
|
|
21
|
+
getCoreRowModel: getCoreRowModel(),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<MadieTable
|
|
26
|
+
table={table}
|
|
27
|
+
currentSort={currentSort}
|
|
28
|
+
currentDirection={currentDirection}
|
|
29
|
+
handleSort={handleSort}
|
|
30
|
+
renderExpandedRow={renderExpandedRow}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe("MadieTable", () => {
|
|
36
|
+
const columnHelper = createColumnHelper();
|
|
37
|
+
|
|
38
|
+
const columns = [
|
|
39
|
+
columnHelper.accessor("name", {
|
|
40
|
+
header: "Measure Name",
|
|
41
|
+
cell: info => info.getValue(),
|
|
42
|
+
}),
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const data = [
|
|
46
|
+
{ id: "1", name: "Test Measure 1" },
|
|
47
|
+
{ id: "2", name: "Test Measure 2" },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
it("renders table headers", () => {
|
|
51
|
+
render(
|
|
52
|
+
<TestTableWrapper
|
|
53
|
+
data={data}
|
|
54
|
+
columns={columns}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(screen.getByText("Measure Name")).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("renders table rows", () => {
|
|
62
|
+
render(
|
|
63
|
+
<TestTableWrapper
|
|
64
|
+
data={data}
|
|
65
|
+
columns={columns}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(screen.getByText("Test Measure 1")).toBeInTheDocument();
|
|
70
|
+
expect(screen.getByText("Test Measure 2")).toBeInTheDocument();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("shows empty state when there are no rows", () => {
|
|
74
|
+
render(
|
|
75
|
+
<TestTableWrapper
|
|
76
|
+
data={[]}
|
|
77
|
+
columns={columns}
|
|
78
|
+
/>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect(
|
|
82
|
+
screen.getByText("No results were found")
|
|
83
|
+
).toBeInTheDocument();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("calls handleSort when sortable header is clicked", () => {
|
|
87
|
+
const handleSort = jest.fn();
|
|
88
|
+
|
|
89
|
+
render(
|
|
90
|
+
<TestTableWrapper
|
|
91
|
+
data={data}
|
|
92
|
+
columns={columns}
|
|
93
|
+
currentSort="name"
|
|
94
|
+
currentDirection="ASC"
|
|
95
|
+
handleSort={handleSort}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
fireEvent.click(screen.getByTestId("header-name"));
|
|
100
|
+
|
|
101
|
+
expect(handleSort).toHaveBeenCalledWith("name");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("renders expanded row content using renderExpandedRow", () => {
|
|
105
|
+
render(
|
|
106
|
+
<TestTableWrapper
|
|
107
|
+
data={data}
|
|
108
|
+
columns={columns}
|
|
109
|
+
renderExpandedRow={(row) => (
|
|
110
|
+
<tr data-testid={`expanded-${row.id}`}>
|
|
111
|
+
<td colSpan={1}>Expanded content for {row.original.name}</td>
|
|
112
|
+
</tr>
|
|
113
|
+
)}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
expect(
|
|
118
|
+
screen.getByText("Expanded content for Test Measure 1")
|
|
119
|
+
).toBeInTheDocument();
|
|
120
|
+
|
|
121
|
+
expect(
|
|
122
|
+
screen.getByText("Expanded content for Test Measure 2")
|
|
123
|
+
).toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
it("shows the hover icon on mouse enter", () => {
|
|
128
|
+
render(
|
|
129
|
+
<TestTableWrapper
|
|
130
|
+
data={data}
|
|
131
|
+
columns={columns}
|
|
132
|
+
/>
|
|
133
|
+
);
|
|
134
|
+
const headerCell = screen
|
|
135
|
+
.getByTestId("header-name")
|
|
136
|
+
.closest("th");
|
|
137
|
+
fireEvent.mouseEnter(headerCell);
|
|
138
|
+
|
|
139
|
+
expect(
|
|
140
|
+
screen.getByTestId("unfold-more-icon")
|
|
141
|
+
).toBeInTheDocument();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
it("renders ascending sort icon when currentSort is ASC", () => {
|
|
146
|
+
render(
|
|
147
|
+
<TestTableWrapper
|
|
148
|
+
data={data}
|
|
149
|
+
columns={columns}
|
|
150
|
+
currentSort="name"
|
|
151
|
+
currentDirection="ASC"
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
expect(
|
|
156
|
+
screen.getByTestId("KeyboardArrowUpIcon")
|
|
157
|
+
).toBeInTheDocument();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
it("renders descending sort icon when currentSort is DESC", () => {
|
|
162
|
+
render(
|
|
163
|
+
<TestTableWrapper
|
|
164
|
+
data={data}
|
|
165
|
+
columns={columns}
|
|
166
|
+
currentSort="name"
|
|
167
|
+
currentDirection="DESC"
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(
|
|
172
|
+
screen.getByTestId("KeyboardArrowDownIcon")
|
|
173
|
+
).toBeInTheDocument();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
|
+
import SearchAndFilter from "../../components/SearchAndFilter";
|
|
4
|
+
|
|
5
|
+
describe("MeasureSearchFilter", () => {
|
|
6
|
+
const defaultProps = {
|
|
7
|
+
filterBy: "",
|
|
8
|
+
searchField: "",
|
|
9
|
+
onFilterChange: jest.fn(),
|
|
10
|
+
onSearchChange: jest.fn(),
|
|
11
|
+
onSearchTrigger: jest.fn(),
|
|
12
|
+
onSearchClear: jest.fn(),
|
|
13
|
+
filterByOpts: ["Measure Name", "CMS ID"],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("renders filter select and search input", () => {
|
|
21
|
+
render(<SearchAndFilter {...defaultProps} />);
|
|
22
|
+
|
|
23
|
+
expect(screen.getByTestId("filter-by-select")).toBeInTheDocument();
|
|
24
|
+
expect(
|
|
25
|
+
screen.getByTestId("test-case-list-search")
|
|
26
|
+
).toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("calls onSearchChange when typing in the search field", () => {
|
|
30
|
+
render(<SearchAndFilter {...defaultProps} />);
|
|
31
|
+
|
|
32
|
+
const searchInput = screen.getByTestId(
|
|
33
|
+
"test-case-list-search-input"
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
fireEvent.change(searchInput, {
|
|
37
|
+
target: { value: "test search" },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(defaultProps.onSearchChange).toHaveBeenCalled();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("triggers search when pressing Enter in the search field", () => {
|
|
44
|
+
render(<SearchAndFilter {...defaultProps} />);
|
|
45
|
+
|
|
46
|
+
const searchInput = screen.getByTestId(
|
|
47
|
+
"test-case-list-search-input"
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
fireEvent.keyPress(searchInput, {
|
|
51
|
+
key: "Enter",
|
|
52
|
+
code: "Enter",
|
|
53
|
+
charCode: 13,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
expect(defaultProps.onSearchTrigger).toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("triggers search when clicking the search icon", () => {
|
|
60
|
+
render(<SearchAndFilter {...defaultProps} />);
|
|
61
|
+
|
|
62
|
+
fireEvent.click(
|
|
63
|
+
screen.getByTestId("test-case-trigger-search")
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(defaultProps.onSearchTrigger).toHaveBeenCalled();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("clears search when clicking the clear icon", () => {
|
|
70
|
+
render(<SearchAndFilter {...defaultProps} />);
|
|
71
|
+
|
|
72
|
+
fireEvent.click(
|
|
73
|
+
screen.getByTestId("test-case-clear-search")
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
expect(defaultProps.onSearchClear).toHaveBeenCalled();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { screen, fireEvent, render } from "@testing-library/react";
|
|
3
|
+
import {
|
|
4
|
+
useFilterSearch,
|
|
5
|
+
filterByOptions,
|
|
6
|
+
filterMap,
|
|
7
|
+
} from "../../components/SearchAndFilter/useFilterSearch";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Test harness to expose hook state & handlers
|
|
11
|
+
*/
|
|
12
|
+
const TestHarness = ({ onPageReset }) => {
|
|
13
|
+
const {
|
|
14
|
+
filterBy,
|
|
15
|
+
searchField,
|
|
16
|
+
finalSearchAndFilterby,
|
|
17
|
+
handleFilter,
|
|
18
|
+
handleSearch,
|
|
19
|
+
finalizeSearchCriteria,
|
|
20
|
+
blankSearchCriteria,
|
|
21
|
+
} = useFilterSearch(onPageReset);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<span data-testid="filterBy">{filterBy}</span>
|
|
26
|
+
<span data-testid="searchField">{searchField}</span>
|
|
27
|
+
<span data-testid="finalFilterBy">
|
|
28
|
+
{finalSearchAndFilterby.finalFilterBy}
|
|
29
|
+
</span>
|
|
30
|
+
<span data-testid="finalSearchField">
|
|
31
|
+
{finalSearchAndFilterby.finalSearchField}
|
|
32
|
+
</span>
|
|
33
|
+
|
|
34
|
+
<button
|
|
35
|
+
data-testid="set-filter"
|
|
36
|
+
onClick={() =>
|
|
37
|
+
handleFilter({ target: { value: "Measure" } })
|
|
38
|
+
}
|
|
39
|
+
/>
|
|
40
|
+
<button
|
|
41
|
+
data-testid="set-search"
|
|
42
|
+
onClick={() =>
|
|
43
|
+
handleSearch({ target: { value: "Diabetes" } })
|
|
44
|
+
}
|
|
45
|
+
/>
|
|
46
|
+
<button
|
|
47
|
+
data-testid="finalize"
|
|
48
|
+
onClick={finalizeSearchCriteria}
|
|
49
|
+
/>
|
|
50
|
+
<button
|
|
51
|
+
data-testid="clear"
|
|
52
|
+
onClick={blankSearchCriteria}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
describe("useFilterSearch", () => {
|
|
59
|
+
/**
|
|
60
|
+
* ✅ exported constants
|
|
61
|
+
*/
|
|
62
|
+
it("exports the correct filter options", () => {
|
|
63
|
+
expect(filterByOptions).toEqual([
|
|
64
|
+
"Measure",
|
|
65
|
+
"Version",
|
|
66
|
+
"CMS ID",
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("exports the correct filter map", () => {
|
|
71
|
+
expect(filterMap).toEqual({
|
|
72
|
+
Measure: "measureName",
|
|
73
|
+
Version: "version",
|
|
74
|
+
"CMS ID": "cmsId",
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* ✅ initialization
|
|
80
|
+
*/
|
|
81
|
+
it("initializes all state as empty strings", () => {
|
|
82
|
+
render(<TestHarness />);
|
|
83
|
+
|
|
84
|
+
expect(screen.getByTestId("filterBy")).toHaveTextContent("");
|
|
85
|
+
expect(screen.getByTestId("searchField")).toHaveTextContent("");
|
|
86
|
+
expect(screen.getByTestId("finalFilterBy")).toHaveTextContent("");
|
|
87
|
+
expect(screen.getByTestId("finalSearchField")).toHaveTextContent("");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* ✅ state updates
|
|
92
|
+
*/
|
|
93
|
+
it("updates filterBy and searchField independently", () => {
|
|
94
|
+
render(<TestHarness />);
|
|
95
|
+
|
|
96
|
+
fireEvent.click(screen.getByTestId("set-filter"));
|
|
97
|
+
expect(screen.getByTestId("filterBy")).toHaveTextContent("Measure");
|
|
98
|
+
|
|
99
|
+
fireEvent.click(screen.getByTestId("set-search"));
|
|
100
|
+
expect(screen.getByTestId("searchField")).toHaveTextContent("Diabetes");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* ✅ finalize logic
|
|
105
|
+
*/
|
|
106
|
+
it("finalizes the current filter and search values", () => {
|
|
107
|
+
render(<TestHarness />);
|
|
108
|
+
|
|
109
|
+
fireEvent.click(screen.getByTestId("set-filter"));
|
|
110
|
+
fireEvent.click(screen.getByTestId("set-search"));
|
|
111
|
+
fireEvent.click(screen.getByTestId("finalize"));
|
|
112
|
+
|
|
113
|
+
expect(screen.getByTestId("finalFilterBy")).toHaveTextContent("Measure");
|
|
114
|
+
expect(screen.getByTestId("finalSearchField")).toHaveTextContent("Diabetes");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* ✅ reset logic + callback
|
|
119
|
+
*/
|
|
120
|
+
it("clears all state and calls onPageReset when provided", () => {
|
|
121
|
+
const onPageReset = jest.fn();
|
|
122
|
+
|
|
123
|
+
render(<TestHarness onPageReset={onPageReset} />);
|
|
124
|
+
|
|
125
|
+
fireEvent.click(screen.getByTestId("set-filter"));
|
|
126
|
+
fireEvent.click(screen.getByTestId("set-search"));
|
|
127
|
+
fireEvent.click(screen.getByTestId("finalize"));
|
|
128
|
+
fireEvent.click(screen.getByTestId("clear"));
|
|
129
|
+
|
|
130
|
+
expect(screen.getByTestId("filterBy")).toHaveTextContent("");
|
|
131
|
+
expect(screen.getByTestId("searchField")).toHaveTextContent("");
|
|
132
|
+
expect(screen.getByTestId("finalFilterBy")).toHaveTextContent("");
|
|
133
|
+
expect(screen.getByTestId("finalSearchField")).toHaveTextContent("");
|
|
134
|
+
|
|
135
|
+
expect(onPageReset).toHaveBeenCalledTimes(1);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("clears state safely when onPageReset is not provided", () => {
|
|
139
|
+
render(<TestHarness />);
|
|
140
|
+
|
|
141
|
+
fireEvent.click(screen.getByTestId("clear"));
|
|
142
|
+
|
|
143
|
+
expect(screen.getByTestId("filterBy")).toHaveTextContent("");
|
|
144
|
+
expect(screen.getByTestId("searchField")).toHaveTextContent("");
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
describe("useFilterSearch", () => {
|
|
148
|
+
it("exposes the correct static filter options", () => {
|
|
149
|
+
expect(filterByOptions).toEqual([
|
|
150
|
+
"Measure",
|
|
151
|
+
"Version",
|
|
152
|
+
"CMS ID",
|
|
153
|
+
]);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("exposes the correct filter map", () => {
|
|
157
|
+
expect(filterMap).toEqual({
|
|
158
|
+
Measure: "measureName",
|
|
159
|
+
Version: "version",
|
|
160
|
+
"CMS ID": "cmsId",
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
});
|
package/webpack.config.js
CHANGED
|
@@ -74,11 +74,14 @@ const plugins = [
|
|
|
74
74
|
];
|
|
75
75
|
|
|
76
76
|
const resolve = {
|
|
77
|
-
extensions: [".js", ".jsx", ".json", ".svg"
|
|
77
|
+
extensions: [".js", ".jsx", ".json", ".svg"],
|
|
78
78
|
alias: {
|
|
79
79
|
react: "preact/compat",
|
|
80
80
|
"react-dom": "preact/compat",
|
|
81
81
|
},
|
|
82
|
+
fallback: {
|
|
83
|
+
path: require.resolve("path-browserify"),
|
|
84
|
+
}
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
const optimization = {
|
package/webpack.config.react.js
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Search from "./index";
|
|
3
|
-
import { withKnobs } from "@storybook/addon-knobs";
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: "Search",
|
|
7
|
-
component: Search,
|
|
8
|
-
decorators: [withKnobs],
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const ExampleSearch = () => (
|
|
12
|
-
<Search
|
|
13
|
-
id="Example id"
|
|
14
|
-
name="Example name"
|
|
15
|
-
placeholder="Example placeholder"
|
|
16
|
-
inputAriaLabel="Example input arial-label"
|
|
17
|
-
buttonAriaLabel="Example button arial-label"
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
ExampleSearch.storyName = "example Search";
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import SearchIcon from "@mui/icons-material/Search";
|
|
4
|
-
|
|
5
|
-
const Search = ({
|
|
6
|
-
id,
|
|
7
|
-
name,
|
|
8
|
-
placeholder,
|
|
9
|
-
disableSearchBtn,
|
|
10
|
-
disabled,
|
|
11
|
-
inputValue,
|
|
12
|
-
onClick,
|
|
13
|
-
onChange,
|
|
14
|
-
inputAriaLabel,
|
|
15
|
-
buttonAriaLabel,
|
|
16
|
-
inputWidth,
|
|
17
|
-
}) => {
|
|
18
|
-
const inputStyle = {
|
|
19
|
-
width: inputWidth,
|
|
20
|
-
borderColor: "#8C8C8C",
|
|
21
|
-
};
|
|
22
|
-
return (
|
|
23
|
-
<form role="search" className="qpp-c-search qpp-c-search--compact">
|
|
24
|
-
<label className="qpp-u-visually-hidden" htmlFor={id}>
|
|
25
|
-
Search
|
|
26
|
-
</label>
|
|
27
|
-
<div className="qpp-c-search__wrap">
|
|
28
|
-
<input
|
|
29
|
-
style={inputStyle}
|
|
30
|
-
className="qpp-c-text-input"
|
|
31
|
-
type="search"
|
|
32
|
-
id={id}
|
|
33
|
-
name={name}
|
|
34
|
-
placeholder={placeholder}
|
|
35
|
-
value={inputValue}
|
|
36
|
-
disabled={disabled}
|
|
37
|
-
onChange={onChange}
|
|
38
|
-
aria-label={inputAriaLabel}
|
|
39
|
-
/>
|
|
40
|
-
|
|
41
|
-
<button
|
|
42
|
-
data-testid="search-btn"
|
|
43
|
-
aria-label={buttonAriaLabel}
|
|
44
|
-
onClick={onClick}
|
|
45
|
-
disabled={disableSearchBtn}
|
|
46
|
-
id={`${id}-submit`}
|
|
47
|
-
type="submit"
|
|
48
|
-
className="qpp-c-search__submit qpp-c-button qpp-c-button--text"
|
|
49
|
-
>
|
|
50
|
-
<span className="qpp-u-visually-hidden">Search</span>
|
|
51
|
-
<SearchIcon classes={{ root: "qpp-icon-mat" }} />
|
|
52
|
-
</button>
|
|
53
|
-
</div>
|
|
54
|
-
</form>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
Search.propTypes = {
|
|
59
|
-
id: PropTypes.string,
|
|
60
|
-
name: PropTypes.string,
|
|
61
|
-
placeholder: PropTypes.string,
|
|
62
|
-
disableSearchBtn: PropTypes.bool,
|
|
63
|
-
disabled: PropTypes.bool,
|
|
64
|
-
inputValue: PropTypes.string,
|
|
65
|
-
onClick: PropTypes.func,
|
|
66
|
-
onChange: PropTypes.func,
|
|
67
|
-
inputAriaLabel: PropTypes.string,
|
|
68
|
-
buttonAriaLabel: PropTypes.string,
|
|
69
|
-
inputWidth: PropTypes.string,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
Search.defaultProps = {
|
|
73
|
-
id: "search-input",
|
|
74
|
-
name: "",
|
|
75
|
-
placeholder: "",
|
|
76
|
-
disableSearchBtn: false,
|
|
77
|
-
disabled: false,
|
|
78
|
-
inputValue: "",
|
|
79
|
-
onClick: () => null,
|
|
80
|
-
onChange: () => null,
|
|
81
|
-
inputAriaLabel: "",
|
|
82
|
-
buttonAriaLabel: "",
|
|
83
|
-
inputWidth: "auto",
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export default Search;
|