@madie/madie-design-system 1.2.92 → 1.2.94
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/MadieDeleteDialog/index.jsx +1 -1
- package/components/Toggle/Toggle.jsx +75 -0
- package/components/Toggle/Toggle.stories.jsx +33 -0
- package/components/index.js +2 -0
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +6 -6
- package/dist/react/index.js.LICENSE.txt +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +5 -4
- package/styles/qppds/components/_toggle.scss +85 -0
- package/styles/qppds/components/index.scss +1 -0
- package/test/components/MadieDeleteDialog.test.js +4 -4
- package/test/components/Toggle.test.jsx +85 -0
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.94",
|
|
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",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"d3-selection": "^1.4.2",
|
|
135
135
|
"d3-shape": "^1.3.7",
|
|
136
136
|
"dayjs": "^1.11.7",
|
|
137
|
-
"dompurify": "^3.
|
|
137
|
+
"dompurify": "^3.4.12",
|
|
138
138
|
"html-react-parser": "^5.2.6",
|
|
139
139
|
"jwt-decode": "^3.1.2",
|
|
140
140
|
"lodash": "^4.18.1",
|
|
@@ -144,11 +144,12 @@
|
|
|
144
144
|
"react-modal": "^3.14.4",
|
|
145
145
|
"retry": "^0.13.1",
|
|
146
146
|
"styled-components": "^5.3.7",
|
|
147
|
-
"svgo": "^3.
|
|
147
|
+
"svgo": "^3.3.4",
|
|
148
148
|
"tailwindcss": "^3.4.10",
|
|
149
149
|
"twin.macro": "^3.4.0",
|
|
150
150
|
"what-input": "^5.2.10",
|
|
151
|
-
"xss": "^1.0.10"
|
|
151
|
+
"xss": "^1.0.10",
|
|
152
|
+
"yaml": "^2.9.0"
|
|
152
153
|
},
|
|
153
154
|
"peerDependencies": {
|
|
154
155
|
"@tanstack/match-sorter-utils": "^8.8.4",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
@import "../settings/index";
|
|
2
|
+
|
|
3
|
+
.qpp-c-toggle {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
font-family: $font-rubik;
|
|
7
|
+
font-size: $font-size-14;
|
|
8
|
+
line-height: $line-height-md;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.qpp-c-toggle__input {
|
|
12
|
+
height: 1px;
|
|
13
|
+
margin: -1px;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
position: absolute;
|
|
16
|
+
width: 1px;
|
|
17
|
+
clip: rect(0, 0, 0, 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.qpp-c-toggle__label {
|
|
21
|
+
align-items: center;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
display: inline-flex;
|
|
24
|
+
gap: $spacing-8;
|
|
25
|
+
min-height: rem(38px);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.qpp-c-toggle__control {
|
|
29
|
+
background-color: rgba($black, 0.38);
|
|
30
|
+
border-radius: rem(7px);
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
height: rem(14px);
|
|
33
|
+
margin: 0 rem(3px);
|
|
34
|
+
position: relative;
|
|
35
|
+
transition: background-color 0.2s ease-in-out;
|
|
36
|
+
width: rem(38px);
|
|
37
|
+
|
|
38
|
+
&::after {
|
|
39
|
+
background-color: $white;
|
|
40
|
+
box-shadow: 0 rem(1px) rem(3px) rgba($black, 0.35);
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
content: "";
|
|
43
|
+
height: rem(20px);
|
|
44
|
+
left: rem(-3px);
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: rem(-3px);
|
|
47
|
+
transition: transform 0.2s ease-in-out;
|
|
48
|
+
width: rem(20px);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.qpp-c-toggle__input:checked + .qpp-c-toggle__control {
|
|
53
|
+
background-color: rgba($blue-60, 0.5);
|
|
54
|
+
|
|
55
|
+
&::after {
|
|
56
|
+
background-color: $blue-60;
|
|
57
|
+
transform: translateX(rem(21px));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.qpp-c-toggle__input:focus-visible + .qpp-c-toggle__control {
|
|
62
|
+
box-shadow: 0 0 0 rem(4px) $blue-10;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.qpp-c-toggle--disabled .qpp-c-toggle__label {
|
|
66
|
+
color: $gray-60;
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.qpp-c-toggle__input:disabled + .qpp-c-toggle__control {
|
|
71
|
+
background-color: rgba($black, 0.12);
|
|
72
|
+
|
|
73
|
+
&::after {
|
|
74
|
+
background-color: $gray-20;
|
|
75
|
+
box-shadow: none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.qpp-c-toggle__input:disabled:checked + .qpp-c-toggle__control {
|
|
80
|
+
background-color: rgba($blue-60, 0.3);
|
|
81
|
+
|
|
82
|
+
&::after {
|
|
83
|
+
background-color: #9ecaea;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -40,7 +40,7 @@ describe("MadieDeleteDialog", () => {
|
|
|
40
40
|
queryByText("Are you sure you want to delete ?")
|
|
41
41
|
).toBeVisible();
|
|
42
42
|
expect(
|
|
43
|
-
queryByText("This
|
|
43
|
+
queryByText("This action cannot be undone.")
|
|
44
44
|
).toBeVisible();
|
|
45
45
|
});
|
|
46
46
|
});
|
|
@@ -103,7 +103,7 @@ describe("MadieDeleteDialog", () => {
|
|
|
103
103
|
queryByText("Are you sure you want to delete ?")
|
|
104
104
|
).toBeVisible();
|
|
105
105
|
expect(
|
|
106
|
-
queryByText("This
|
|
106
|
+
queryByText("This action cannot be undone.")
|
|
107
107
|
).not.toBeInTheDocument();
|
|
108
108
|
});
|
|
109
109
|
});
|
|
@@ -129,7 +129,7 @@ describe("MadieDeleteDialog", () => {
|
|
|
129
129
|
queryByText("Are you sure you want to delete ?")
|
|
130
130
|
).toBeVisible();
|
|
131
131
|
expect(
|
|
132
|
-
queryByText("This
|
|
132
|
+
queryByText("This action cannot be undone.")
|
|
133
133
|
).not.toBeInTheDocument();
|
|
134
134
|
expect(
|
|
135
135
|
queryByText("<p><strong>test &</strong></p><p>test2</p>")
|
|
@@ -162,7 +162,7 @@ describe("MadieDeleteDialog", () => {
|
|
|
162
162
|
)
|
|
163
163
|
).toBeTruthy();
|
|
164
164
|
expect(
|
|
165
|
-
queryByText("This
|
|
165
|
+
queryByText("This action cannot be undone.")
|
|
166
166
|
).not.toBeInTheDocument();
|
|
167
167
|
});
|
|
168
168
|
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import userEvent from "@testing-library/user-event";
|
|
5
|
+
import Toggle from "../../components/Toggle/Toggle";
|
|
6
|
+
|
|
7
|
+
describe("Toggle", () => {
|
|
8
|
+
test("renders an off switch with its label", () => {
|
|
9
|
+
render(<Toggle id="hide-invalid" label="Hide Invalid Test Cases" />);
|
|
10
|
+
|
|
11
|
+
const toggle = screen.getByRole("switch", {
|
|
12
|
+
name: "Hide Invalid Test Cases",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
expect(toggle).not.toBeChecked();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("updates its state when uncontrolled", () => {
|
|
19
|
+
render(<Toggle id="hide-invalid" label="Hide Invalid Test Cases" />);
|
|
20
|
+
|
|
21
|
+
const toggle = screen.getByRole("switch", {
|
|
22
|
+
name: "Hide Invalid Test Cases",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
fireEvent.click(toggle);
|
|
26
|
+
|
|
27
|
+
expect(toggle).toBeChecked();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("toggles the local control when another instance has the same id", () => {
|
|
31
|
+
render(
|
|
32
|
+
<>
|
|
33
|
+
<Toggle id="hide-invalid" label="Hide Invalid Test Cases" />
|
|
34
|
+
<Toggle id="hide-invalid" label="Hide Invalid Test Cases" />
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const toggles = screen.getAllByRole("switch");
|
|
39
|
+
fireEvent.click(screen.getAllByText("Hide Invalid Test Cases")[1]);
|
|
40
|
+
|
|
41
|
+
expect(toggles[0]).not.toBeChecked();
|
|
42
|
+
expect(toggles[1]).toBeChecked();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("reports changes when controlled", () => {
|
|
46
|
+
const onChange = jest.fn();
|
|
47
|
+
|
|
48
|
+
render(
|
|
49
|
+
<Toggle
|
|
50
|
+
checked={false}
|
|
51
|
+
id="hide-invalid"
|
|
52
|
+
label="Hide Invalid Test Cases"
|
|
53
|
+
onChange={onChange}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
fireEvent.click(
|
|
58
|
+
screen.getByRole("switch", { name: "Hide Invalid Test Cases" })
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(onChange).toHaveBeenCalledWith(expect.any(Object), true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test("does not change when disabled", () => {
|
|
65
|
+
const onChange = jest.fn();
|
|
66
|
+
|
|
67
|
+
render(
|
|
68
|
+
<Toggle
|
|
69
|
+
disabled
|
|
70
|
+
id="hide-invalid"
|
|
71
|
+
label="Hide Invalid Test Cases"
|
|
72
|
+
onChange={onChange}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const toggle = screen.getByRole("switch", {
|
|
77
|
+
name: "Hide Invalid Test Cases",
|
|
78
|
+
});
|
|
79
|
+
userEvent.click(toggle);
|
|
80
|
+
|
|
81
|
+
expect(toggle).toBeDisabled();
|
|
82
|
+
expect(toggle).not.toBeChecked();
|
|
83
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
});
|