@noctuatech/uswds 0.1.0 → 0.1.3
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/assets/flags/alabama.svg +5 -0
- package/assets/flags/alaska.svg +14 -0
- package/assets/flags/arizona.svg +7 -0
- package/assets/flags/arkansas.svg +15 -0
- package/assets/flags/california.svg +8 -0
- package/assets/flags/colorado.svg +8 -0
- package/assets/flags/connecticut.svg +5 -0
- package/assets/flags/delaware.svg +7 -0
- package/assets/flags/florida.svg +5 -0
- package/assets/flags/georgia.svg +5 -0
- package/assets/flags/hawaii.svg +19 -0
- package/assets/flags/idaho.svg +5 -0
- package/assets/flags/illinois.svg +5 -0
- package/assets/flags/indiana.svg +15 -0
- package/assets/flags/iowa.svg +13 -0
- package/assets/flags/kansas.svg +5 -0
- package/assets/flags/kentucky.svg +16 -0
- package/assets/flags/louisiana.svg +14 -0
- package/assets/flags/maine.svg +12 -0
- package/assets/flags/maryland.svg +14 -0
- package/assets/flags/massachusetts.svg +15 -0
- package/assets/flags/michigan.svg +5 -0
- package/assets/flags/minnesota.svg +15 -0
- package/assets/flags/mississippi.svg +10 -0
- package/assets/flags/missouri.svg +16 -0
- package/assets/flags/montana.svg +11 -0
- package/assets/flags/nebraska.svg +13 -0
- package/assets/flags/nevada.svg +14 -0
- package/assets/flags/new_hampshire.svg +13 -0
- package/assets/flags/new_jersey.svg +13 -0
- package/assets/flags/new_mexico.svg +7 -0
- package/assets/flags/new_york.svg +13 -0
- package/assets/flags/north_carolina.svg +5 -0
- package/assets/flags/north_dakota.svg +13 -0
- package/assets/flags/ohio.svg +16 -0
- package/assets/flags/oklahoma.svg +12 -0
- package/assets/flags/oregon.svg +13 -0
- package/assets/flags/pennsylvania.svg +15 -0
- package/assets/flags/rhode_island.svg +13 -0
- package/assets/flags/south_carolina.svg +11 -0
- package/assets/flags/south_dakota.svg +15 -0
- package/assets/flags/tennessee.svg +13 -0
- package/assets/flags/texas.svg +8 -0
- package/assets/flags/utah.svg +9 -0
- package/assets/flags/vermont.svg +13 -0
- package/assets/flags/virginia.svg +5 -0
- package/assets/flags/washington.svg +5 -0
- package/assets/flags/west_virginia.svg +24 -0
- package/assets/flags/wisconsin.svg +5 -0
- package/assets/flags/wyoming.svg +5 -0
- package/package.json +13 -11
- package/src/lib/combo-box/combo-box-option/combo-box-option.element.ts +32 -13
- package/src/lib/combo-box/combo-box.element.ts +161 -43
- package/src/lib/combo-box/combo-box.stories.ts +202 -56
- package/src/lib/combo-box/combo-box.test.ts +140 -22
- package/target/lib/accordion/accordion.element.js +2 -86
- package/target/lib/accordion/accordion.stories.js +1 -26
- package/target/lib/accordion/accordion.test.js +5 -72
- package/target/lib/alert/alert.element.js +2 -71
- package/target/lib/alert/alert.stories.js +1 -41
- package/target/lib/alert/alert.test.js +1 -9
- package/target/lib/button/button.element.js +2 -142
- package/target/lib/button/button.stories.js +1 -6
- package/target/lib/button/button.test.js +1 -3
- package/target/lib/card/card-body/card-body.element.js +1 -8
- package/target/lib/card/card-footer/card-footer.element.js +1 -6
- package/target/lib/card/card-group/card-group.element.js +1 -12
- package/target/lib/card/card-header/card-header.element.js +1 -16
- package/target/lib/card/card-media/card-media.element.js +2 -33
- package/target/lib/card/card.element.js +1 -32
- package/target/lib/card/card.stories.js +2 -107
- package/target/lib/card/card.test.js +1 -20
- package/target/lib/checkbox/checkbox-group/checkbox-group.element.js +2 -10
- package/target/lib/checkbox/checkbox.element.js +2 -112
- package/target/lib/checkbox/checkbox.stories.js +2 -43
- package/target/lib/checkbox/checkbox.test.js +4 -28
- package/target/lib/collection/collection-item/collection-item.element.js +2 -40
- package/target/lib/collection/collection-item/collection-item.test.js +1 -3
- package/target/lib/collection/collection.element.js +2 -10
- package/target/lib/collection/collection.stories.js +1 -63
- package/target/lib/collection/collection.test.js +1 -3
- package/target/lib/combo-box/combo-box-option/combo-box-option.element.d.ts +0 -1
- package/target/lib/combo-box/combo-box-option/combo-box-option.element.js +21 -12
- package/target/lib/combo-box/combo-box-option/combo-box-option.element.js.map +1 -1
- package/target/lib/combo-box/combo-box.element.d.ts +9 -1
- package/target/lib/combo-box/combo-box.element.js +92 -86
- package/target/lib/combo-box/combo-box.element.js.map +1 -1
- package/target/lib/combo-box/combo-box.stories.js +1 -59
- package/target/lib/combo-box/combo-box.stories.js.map +1 -1
- package/target/lib/combo-box/combo-box.test.js +65 -22
- package/target/lib/combo-box/combo-box.test.js.map +1 -1
- package/target/lib/config/config.element.js +1 -5
- package/target/lib/config/config.test.js +1 -3
- package/target/lib/description/description.element.js +1 -7
- package/target/lib/description/description.test.js +1 -3
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js +2 -61
- package/target/lib/file-input/file-input-preview/file-input-preview.test.js +5 -25
- package/target/lib/file-input/file-input.element.js +2 -82
- package/target/lib/file-input/file-input.stories.js +1 -13
- package/target/lib/file-input/file-input.test.js +2 -16
- package/target/lib/icon/icon.element.js +1 -14
- package/target/lib/icon/icon.stories.js +2 -13
- package/target/lib/input/input.element.js +2 -73
- package/target/lib/input/input.stories.js +2 -12
- package/target/lib/input/input.test.js +4 -24
- package/target/lib/input-mask/input-mask.element.js +1 -5
- package/target/lib/input-mask/input-mask.stories.js +1 -12
- package/target/lib/input-mask/input-mask.test.js +4 -24
- package/target/lib/link/link.element.js +2 -18
- package/target/lib/modal/modal-close/modal-close.element.js +2 -36
- package/target/lib/modal/modal-close/modal-close.test.js +1 -3
- package/target/lib/modal/modal-heading/modal-heading.element.js +2 -24
- package/target/lib/modal/modal-heading/modal-heading.test.js +1 -3
- package/target/lib/modal/modal.element.js +2 -33
- package/target/lib/modal/modal.stories.js +1 -18
- package/target/lib/modal/modal.test.js +1 -11
- package/target/lib/radio/radio-option/radio-option.element.js +2 -16
- package/target/lib/radio/radio-option/radio-option.test.js +1 -5
- package/target/lib/radio/radio.element.js +2 -98
- package/target/lib/radio/radio.stories.js +1 -26
- package/target/lib/radio/radio.test.js +5 -103
- package/target/lib/range-slider/range-slider.element.js +2 -52
- package/target/lib/range-slider/range-slider.test.js +3 -17
- package/target/lib/select/select-option/select-option.element.js +1 -5
- package/target/lib/select/select.element.js +2 -49
- package/target/lib/select/select.stories.js +1 -10
- package/target/lib/select/select.test.js +6 -64
- package/target/lib/side-nav/side-nav-item/side-nav-item.element.js +2 -67
- package/target/lib/side-nav/side-nav.element.js +1 -8
- package/target/lib/side-nav/side-nav.stories.js +1 -39
- package/target/lib/side-nav/side-nav.test.js +2 -78
- package/target/lib/step-indicator/step/step.element.js +2 -96
- package/target/lib/step-indicator/step-indicator.element.js +1 -9
- package/target/lib/step-indicator/step-indicator.stories.js +1 -21
- package/target/lib/step-indicator/step-indicator.test.js +1 -9
- package/target/lib/summary-box/summary-box.element.js +2 -14
- package/target/lib/summary-box/summary-box.stories.js +1 -1
- package/target/lib/summary-box/summary-box.test.js +1 -3
- package/target/lib/tag/tag.element.js +1 -22
- package/target/lib/tag/tag.stories.js +1 -1
- package/target/lib/tag/tag.test.js +1 -3
- package/target/lib/textarea/textarea.element.js +2 -49
- package/target/lib/textarea/textarea.test.js +4 -24
|
@@ -4,30 +4,8 @@ let USAModalHeadingElement = (() => {
|
|
|
4
4
|
let _classDecorators = [element({
|
|
5
5
|
tagName: "usa-modal-heading",
|
|
6
6
|
shadowDom: [
|
|
7
|
-
css
|
|
8
|
-
|
|
9
|
-
font-family:
|
|
10
|
-
Merriweather Web,
|
|
11
|
-
Georgia,
|
|
12
|
-
Cambria,
|
|
13
|
-
Times New Roman,
|
|
14
|
-
Times,
|
|
15
|
-
serif !important;
|
|
16
|
-
|
|
17
|
-
font-size: 1.22rem;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
h2 {
|
|
21
|
-
margin-top: 0;
|
|
22
|
-
line-height: 1.4;
|
|
23
|
-
font-size: 1.45rem;
|
|
24
|
-
}
|
|
25
|
-
`,
|
|
26
|
-
html `
|
|
27
|
-
<h2>
|
|
28
|
-
<slot></slot>
|
|
29
|
-
</h2>
|
|
30
|
-
`,
|
|
7
|
+
css `:host{font-family:Merriweather Web,Georgia,Cambria,Times New Roman,Times,serif!important;font-size:1.22rem}h2{margin-top:0;line-height:1.4;font-size:1.45rem}`,
|
|
8
|
+
html `<h2><slot></slot></h2>`,
|
|
31
9
|
],
|
|
32
10
|
})];
|
|
33
11
|
let _classDescriptor;
|
|
@@ -2,9 +2,7 @@ import "./modal-heading.element.js";
|
|
|
2
2
|
import { assert, fixture, html } from "@open-wc/testing";
|
|
3
3
|
describe("usa-modal-heading", () => {
|
|
4
4
|
it("should be accessible", async () => {
|
|
5
|
-
const modalHeading = await fixture(html
|
|
6
|
-
<usa-modal-heading>Hello World</usa-modal-heading>
|
|
7
|
-
`);
|
|
5
|
+
const modalHeading = await fixture(html `<usa-modal-heading>Hello World</usa-modal-heading>`);
|
|
8
6
|
return assert.isAccessible(modalHeading);
|
|
9
7
|
});
|
|
10
8
|
});
|
|
@@ -4,39 +4,8 @@ let USAModalElement = (() => {
|
|
|
4
4
|
let _classDecorators = [element({
|
|
5
5
|
tagName: "usa-modal",
|
|
6
6
|
shadowDom: [
|
|
7
|
-
css
|
|
8
|
-
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
:host {
|
|
13
|
-
display: contents;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
dialog {
|
|
17
|
-
border: none;
|
|
18
|
-
font-size: 1.06rem;
|
|
19
|
-
line-height: 1.5;
|
|
20
|
-
border-radius: 0.5rem;
|
|
21
|
-
background: #fff;
|
|
22
|
-
color: #1b1b1b;
|
|
23
|
-
max-width: 30rem;
|
|
24
|
-
padding-top: 4rem;
|
|
25
|
-
padding-left: 4rem;
|
|
26
|
-
padding-right: 4rem;
|
|
27
|
-
padding-bottom: 2rem;
|
|
28
|
-
width: 100%;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
::backdrop {
|
|
32
|
-
background: rgba(0, 0, 0, 0.7);
|
|
33
|
-
}
|
|
34
|
-
`,
|
|
35
|
-
html `
|
|
36
|
-
<dialog>
|
|
37
|
-
<slot></slot>
|
|
38
|
-
</dialog>
|
|
39
|
-
`,
|
|
7
|
+
css `*{box-sizing:border-box}:host{display:contents}dialog{border:none;font-size:1.06rem;line-height:1.5;border-radius:.5rem;background:#fff;color:#1b1b1b;max-width:30rem;padding-top:4rem;padding-left:4rem;padding-right:4rem;padding-bottom:2rem;width:100%}::backdrop{background:rgba(0,0,0,.7)}`,
|
|
8
|
+
html `<dialog><slot></slot></dialog>`,
|
|
40
9
|
],
|
|
41
10
|
})];
|
|
42
11
|
let _classDescriptor;
|
|
@@ -4,24 +4,7 @@ const meta = {
|
|
|
4
4
|
title: "usa-modal",
|
|
5
5
|
tags: ["autodocs"],
|
|
6
6
|
render() {
|
|
7
|
-
return html
|
|
8
|
-
<usa-button modal-target="mymodal">Open Modal</usa-button>
|
|
9
|
-
|
|
10
|
-
<usa-modal id="mymodal">
|
|
11
|
-
<usa-modal-close></usa-modal-close>
|
|
12
|
-
|
|
13
|
-
<usa-modal-heading>
|
|
14
|
-
Are you sure you want to continue?
|
|
15
|
-
</usa-modal-heading>
|
|
16
|
-
|
|
17
|
-
<usa-input placeholder="foo@email.com" autofocus>
|
|
18
|
-
Enter your email to continue
|
|
19
|
-
</usa-input>
|
|
20
|
-
|
|
21
|
-
<usa-button modal-action="confirm">Yes I am sure</usa-button>
|
|
22
|
-
<usa-button modal-action="cancel" variant="outline">Cancel</usa-button>
|
|
23
|
-
</usa-modal>
|
|
24
|
-
`;
|
|
7
|
+
return html `<usa-button modal-target="mymodal">Open Modal</usa-button><usa-modal id="mymodal"><usa-modal-close></usa-modal-close><usa-modal-heading>Are you sure you want to continue?</usa-modal-heading><usa-input placeholder="foo@email.com" autofocus>Enter your email to continue</usa-input><usa-button modal-action="confirm">Yes I am sure</usa-button><usa-button modal-action="cancel" variant="outline">Cancel</usa-button></usa-modal>`;
|
|
25
8
|
},
|
|
26
9
|
argTypes: {},
|
|
27
10
|
args: {},
|
|
@@ -4,17 +4,7 @@ import "./modal-close/modal-close.element.js";
|
|
|
4
4
|
import { assert, fixture, html } from "@open-wc/testing";
|
|
5
5
|
describe("usa-modal", () => {
|
|
6
6
|
it("should be accessible", async () => {
|
|
7
|
-
const modal = await fixture(html
|
|
8
|
-
<usa-modal open>
|
|
9
|
-
<usa-modal-close></usa-modal-close>
|
|
10
|
-
|
|
11
|
-
<usa-modal-heading>
|
|
12
|
-
Are you sure you want to continue?
|
|
13
|
-
</usa-modal-heading>
|
|
14
|
-
|
|
15
|
-
<p>This is some other example of content</p>
|
|
16
|
-
</usa-modal>
|
|
17
|
-
`);
|
|
7
|
+
const modal = await fixture(html `<usa-modal open><usa-modal-close></usa-modal-close><usa-modal-heading>Are you sure you want to continue?</usa-modal-heading><p>This is some other example of content</p></usa-modal>`);
|
|
18
8
|
return assert.isAccessible(modal);
|
|
19
9
|
});
|
|
20
10
|
});
|
|
@@ -8,22 +8,8 @@ let USARadioOptionElement = (() => {
|
|
|
8
8
|
}), element({
|
|
9
9
|
tagName: "usa-radio-option",
|
|
10
10
|
shadowDom: [
|
|
11
|
-
css
|
|
12
|
-
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
margin-top: 0.05rem;
|
|
16
|
-
}
|
|
17
|
-
`,
|
|
18
|
-
html `
|
|
19
|
-
<!-- This label will be moved to the shadow dom of its parent -->
|
|
20
|
-
<label>
|
|
21
|
-
<input type="radio" tabindex="0" />
|
|
22
|
-
<slot name="reserved"></slot>
|
|
23
|
-
</label>
|
|
24
|
-
|
|
25
|
-
<slot></slot>
|
|
26
|
-
`,
|
|
11
|
+
css `:host{display:flex;flex-direction:column;margin-top:.05rem}`,
|
|
12
|
+
html `<label><input type="radio" tabindex="0"><slot name="reserved"></slot></label><slot></slot>`,
|
|
27
13
|
],
|
|
28
14
|
})];
|
|
29
15
|
let _classDescriptor;
|
|
@@ -3,11 +3,7 @@ import "./radio-option.element.js";
|
|
|
3
3
|
import { assert, fixture, html } from "@open-wc/testing";
|
|
4
4
|
describe("usa-radio-option", () => {
|
|
5
5
|
it("should map value to slot", async () => {
|
|
6
|
-
const radio = await fixture(html
|
|
7
|
-
<usa-radio>
|
|
8
|
-
<usa-radio-option value="first">First</usa-radio-option>
|
|
9
|
-
</usa-radio>
|
|
10
|
-
`);
|
|
6
|
+
const radio = await fixture(html `<usa-radio><usa-radio-option value="first">First</usa-radio-option></usa-radio>`);
|
|
11
7
|
const option = radio.querySelectorAll("usa-radio-option");
|
|
12
8
|
assert.equal(option[0].value, option[0].slot);
|
|
13
9
|
});
|
|
@@ -9,104 +9,8 @@ let USARadioElement = (() => {
|
|
|
9
9
|
}), element({
|
|
10
10
|
tagName: "usa-radio",
|
|
11
11
|
shadowDom: [
|
|
12
|
-
css
|
|
13
|
-
|
|
14
|
-
--usa-radio-active-color: #005ea2;
|
|
15
|
-
--usa-radio-tiled-bg: rgba(0, 94, 162, 0.1);
|
|
16
|
-
--usa-radio-focus-color: #2491ff;
|
|
17
|
-
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
gap: 1rem;
|
|
21
|
-
max-width: 30rem;
|
|
22
|
-
margin-bottom: 1.5rem;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
label {
|
|
26
|
-
display: flex;
|
|
27
|
-
cursor: pointer;
|
|
28
|
-
gap: 0.5rem;
|
|
29
|
-
position: relative;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
input {
|
|
33
|
-
position: absolute;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
label::before {
|
|
37
|
-
content: " ";
|
|
38
|
-
display: block;
|
|
39
|
-
left: 0;
|
|
40
|
-
height: 1.25rem;
|
|
41
|
-
border-radius: 99rem;
|
|
42
|
-
width: 1.25rem;
|
|
43
|
-
background: #fff;
|
|
44
|
-
box-shadow: 0 0 0 2px #1b1b1b;
|
|
45
|
-
flex: 0 0 1.25rem;
|
|
46
|
-
position: relative;
|
|
47
|
-
z-index: 1000;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
label:has(input:checked)::before {
|
|
51
|
-
background-color: var(--usa-radio-active-color);
|
|
52
|
-
box-shadow:
|
|
53
|
-
0 0 0 2px var(--usa-radio-active-color),
|
|
54
|
-
inset 0 0 0 2px #fff;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
label:has(input:checked:is(:disabled))::before {
|
|
58
|
-
background-color: #757575;
|
|
59
|
-
box-shadow:
|
|
60
|
-
0 0 0 2px #757575,
|
|
61
|
-
inset 0 0 0 2px #fff;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
label:has(input:disabled) {
|
|
65
|
-
cursor: not-allowed;
|
|
66
|
-
color: #757575 !important;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
label:has(input:disabled)::before {
|
|
70
|
-
background-color: #fff;
|
|
71
|
-
box-shadow: 0 0 0 2px #757575;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
label:has(input:focus)::before {
|
|
75
|
-
outline: 0.25rem solid var(--usa-radio-focus-color);
|
|
76
|
-
outline-offset: 0.25rem;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
:host([tiled]) {
|
|
80
|
-
gap: 0.5rem;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
:host([tiled]) label {
|
|
84
|
-
background-color: #fff;
|
|
85
|
-
border: 2px solid #c9c9c9;
|
|
86
|
-
color: #1b1b1b;
|
|
87
|
-
border-radius: 0.25rem;
|
|
88
|
-
padding: 0.75rem 1rem 0.75rem 0.75rem;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
:host([tiled]) label:has(input:checked) {
|
|
92
|
-
background-color: var(--usa-radio-tiled-bg);
|
|
93
|
-
border-color: var(--usa-radio-active-color);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
:host([tiled]) label:has(input:checked:is(:disabled)) {
|
|
97
|
-
background-color: #fff;
|
|
98
|
-
border-color: #757575;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
slot {
|
|
102
|
-
display: flex;
|
|
103
|
-
}
|
|
104
|
-
`,
|
|
105
|
-
html `
|
|
106
|
-
<slot name="legend" id="legend" tabindex="-1"></slot>
|
|
107
|
-
|
|
108
|
-
<slot></slot>
|
|
109
|
-
`,
|
|
12
|
+
css `:host{--usa-radio-active-color:#005ea2;--usa-radio-tiled-bg:rgba(0, 94, 162, 0.1);--usa-radio-focus-color:#2491ff;display:flex;flex-direction:column;gap:1rem;max-width:30rem;margin-bottom:1.5rem}label{display:flex;cursor:pointer;gap:.5rem;position:relative}input{position:absolute}label::before{content:" ";display:block;left:0;height:1.25rem;border-radius:99rem;width:1.25rem;background:#fff;box-shadow:0 0 0 2px #1b1b1b;flex:0 0 1.25rem;position:relative;z-index:1000}label:has(input:checked)::before{background-color:var(--usa-radio-active-color);box-shadow:0 0 0 2px var(--usa-radio-active-color),inset 0 0 0 2px #fff}label:has(input:checked:is(:disabled))::before{background-color:#757575;box-shadow:0 0 0 2px #757575,inset 0 0 0 2px #fff}label:has(input:disabled){cursor:not-allowed;color:#757575!important}label:has(input:disabled)::before{background-color:#fff;box-shadow:0 0 0 2px #757575}label:has(input:focus)::before{outline:.25rem solid var(--usa-radio-focus-color);outline-offset:.25rem}:host([tiled]){gap:.5rem}:host([tiled]) label{background-color:#fff;border:2px solid #c9c9c9;color:#1b1b1b;border-radius:.25rem;padding:.75rem 1rem .75rem .75rem}:host([tiled]) label:has(input:checked){background-color:var(--usa-radio-tiled-bg);border-color:var(--usa-radio-active-color)}:host([tiled]) label:has(input:checked:is(:disabled)){background-color:#fff;border-color:#757575}slot{display:flex}`,
|
|
13
|
+
html `<slot name="legend" id="legend" tabindex="-1"></slot><slot></slot>`,
|
|
110
14
|
],
|
|
111
15
|
})];
|
|
112
16
|
let _classDescriptor;
|
|
@@ -4,32 +4,7 @@ const meta = {
|
|
|
4
4
|
title: "usa-radio",
|
|
5
5
|
tags: ["autodocs"],
|
|
6
6
|
render(args) {
|
|
7
|
-
return html
|
|
8
|
-
<usa-radio
|
|
9
|
-
name="historical-figures"
|
|
10
|
-
value="frederick-douglass"
|
|
11
|
-
?tiled=${args.tiled}
|
|
12
|
-
>
|
|
13
|
-
<legend>Select one historical figure</legend>
|
|
14
|
-
|
|
15
|
-
<usa-radio-option value="sojourner-truth">
|
|
16
|
-
Sojourner Truth
|
|
17
|
-
</usa-radio-option>
|
|
18
|
-
|
|
19
|
-
<usa-radio-option value="frederick-douglass">
|
|
20
|
-
Frederick Douglass
|
|
21
|
-
<usa-description>This is optional text that can be used to describe the label in more detail.</usa-description>
|
|
22
|
-
</usa-radio-option>
|
|
23
|
-
|
|
24
|
-
<usa-radio-option value="booker-t-washington">
|
|
25
|
-
Booker T. Washington
|
|
26
|
-
</usa-radio-option>
|
|
27
|
-
|
|
28
|
-
<usa-radio-option value="george-washington-carver" disabled>
|
|
29
|
-
George Washington Carver
|
|
30
|
-
</usa-radio-option>
|
|
31
|
-
</usa-radio>
|
|
32
|
-
`;
|
|
7
|
+
return html `<usa-radio name="historical-figures" value="frederick-douglass" ?tiled="${args.tiled}"><legend>Select one historical figure</legend><usa-radio-option value="sojourner-truth">Sojourner Truth</usa-radio-option><usa-radio-option value="frederick-douglass">Frederick Douglass<usa-description>This is optional text that can be used to describe the label in more detail.</usa-description></usa-radio-option><usa-radio-option value="booker-t-washington">Booker T. Washington</usa-radio-option><usa-radio-option value="george-washington-carver" disabled="disabled">George Washington Carver</usa-radio-option></usa-radio>`;
|
|
33
8
|
},
|
|
34
9
|
argTypes: {},
|
|
35
10
|
args: {
|
|
@@ -3,49 +3,11 @@ import "./radio-option/radio-option.element.js";
|
|
|
3
3
|
import { assert, fixture, html } from "@open-wc/testing";
|
|
4
4
|
describe("usa-radio", () => {
|
|
5
5
|
it("should be accessible", async () => {
|
|
6
|
-
const radio = await fixture(html
|
|
7
|
-
<usa-radio name="historical-figures" value="frederick-douglass" tiled>
|
|
8
|
-
<usa-radio-option value="sojourner-truth">
|
|
9
|
-
Sojourner Truth
|
|
10
|
-
</usa-radio-option>
|
|
11
|
-
|
|
12
|
-
<usa-radio-option value="frederick-douglass">
|
|
13
|
-
Frederick Douglass
|
|
14
|
-
</usa-radio-option>
|
|
15
|
-
|
|
16
|
-
<usa-radio-option value="booker-t-washington">
|
|
17
|
-
Booker T. Washington
|
|
18
|
-
</usa-radio-option>
|
|
19
|
-
|
|
20
|
-
<usa-radio-option value="george-washington-carver">
|
|
21
|
-
George Washington Carver
|
|
22
|
-
</usa-radio-option>
|
|
23
|
-
</usa-radio>
|
|
24
|
-
`);
|
|
6
|
+
const radio = await fixture(html `<usa-radio name="historical-figures" value="frederick-douglass" tiled><usa-radio-option value="sojourner-truth">Sojourner Truth</usa-radio-option><usa-radio-option value="frederick-douglass">Frederick Douglass</usa-radio-option><usa-radio-option value="booker-t-washington">Booker T. Washington</usa-radio-option><usa-radio-option value="george-washington-carver">George Washington Carver</usa-radio-option></usa-radio>`);
|
|
25
7
|
return assert.isAccessible(radio);
|
|
26
8
|
});
|
|
27
9
|
it("should create local inputs for each option", async () => {
|
|
28
|
-
const form = await fixture(html
|
|
29
|
-
<form>
|
|
30
|
-
<usa-radio name="historical-figures" value="frederick-douglass">
|
|
31
|
-
<usa-radio-option value="sojourner-truth">
|
|
32
|
-
Sojourner Truth
|
|
33
|
-
</usa-radio-option>
|
|
34
|
-
|
|
35
|
-
<usa-radio-option value="frederick-douglass">
|
|
36
|
-
Frederick Douglass
|
|
37
|
-
</usa-radio-option>
|
|
38
|
-
|
|
39
|
-
<usa-radio-option value="booker-t-washington">
|
|
40
|
-
Booker T. Washington
|
|
41
|
-
</usa-radio-option>
|
|
42
|
-
|
|
43
|
-
<usa-radio-option value="george-washington-carver">
|
|
44
|
-
George Washington Carver
|
|
45
|
-
</usa-radio-option>
|
|
46
|
-
</usa-radio>
|
|
47
|
-
</form>
|
|
48
|
-
`);
|
|
10
|
+
const form = await fixture(html `<form><usa-radio name="historical-figures" value="frederick-douglass"><usa-radio-option value="sojourner-truth">Sojourner Truth</usa-radio-option><usa-radio-option value="frederick-douglass">Frederick Douglass</usa-radio-option><usa-radio-option value="booker-t-washington">Booker T. Washington</usa-radio-option><usa-radio-option value="george-washington-carver">George Washington Carver</usa-radio-option></usa-radio></form>`);
|
|
49
11
|
const nativeInputs = form.querySelector("usa-radio")?.shadowRoot?.querySelectorAll("input") ??
|
|
50
12
|
[];
|
|
51
13
|
assert.deepEqual(Array.from(nativeInputs).map((input) => input.value), [
|
|
@@ -56,27 +18,7 @@ describe("usa-radio", () => {
|
|
|
56
18
|
]);
|
|
57
19
|
});
|
|
58
20
|
it("should remove inputs when options are removed", async () => {
|
|
59
|
-
const form = await fixture(html
|
|
60
|
-
<form>
|
|
61
|
-
<usa-radio name="historical-figures" value="frederick-douglass">
|
|
62
|
-
<usa-radio-option value="sojourner-truth">
|
|
63
|
-
Sojourner Truth
|
|
64
|
-
</usa-radio-option>
|
|
65
|
-
|
|
66
|
-
<usa-radio-option value="frederick-douglass">
|
|
67
|
-
Frederick Douglass
|
|
68
|
-
</usa-radio-option>
|
|
69
|
-
|
|
70
|
-
<usa-radio-option value="booker-t-washington">
|
|
71
|
-
Booker T. Washington
|
|
72
|
-
</usa-radio-option>
|
|
73
|
-
|
|
74
|
-
<usa-radio-option value="george-washington-carver">
|
|
75
|
-
George Washington Carver
|
|
76
|
-
</usa-radio-option>
|
|
77
|
-
</usa-radio>
|
|
78
|
-
</form>
|
|
79
|
-
`);
|
|
21
|
+
const form = await fixture(html `<form><usa-radio name="historical-figures" value="frederick-douglass"><usa-radio-option value="sojourner-truth">Sojourner Truth</usa-radio-option><usa-radio-option value="frederick-douglass">Frederick Douglass</usa-radio-option><usa-radio-option value="booker-t-washington">Booker T. Washington</usa-radio-option><usa-radio-option value="george-washington-carver">George Washington Carver</usa-radio-option></usa-radio></form>`);
|
|
80
22
|
const options = form.querySelectorAll("usa-radio-option");
|
|
81
23
|
options[2].remove();
|
|
82
24
|
const nativeInputs = form.querySelector("usa-radio")?.shadowRoot?.querySelectorAll("input") ??
|
|
@@ -84,27 +26,7 @@ describe("usa-radio", () => {
|
|
|
84
26
|
assert.deepEqual(Array.from(nativeInputs).map((input) => input.value), ["sojourner-truth", "frederick-douglass", "george-washington-carver"]);
|
|
85
27
|
});
|
|
86
28
|
it("should submit form with default values", async () => {
|
|
87
|
-
const form = await fixture(html
|
|
88
|
-
<form>
|
|
89
|
-
<usa-radio name="historical-figures" value="frederick-douglass">
|
|
90
|
-
<usa-radio-option value="sojourner-truth">
|
|
91
|
-
Sojourner Truth
|
|
92
|
-
</usa-radio-option>
|
|
93
|
-
|
|
94
|
-
<usa-radio-option value="frederick-douglass">
|
|
95
|
-
Frederick Douglass
|
|
96
|
-
</usa-radio-option>
|
|
97
|
-
|
|
98
|
-
<usa-radio-option value="booker-t-washington">
|
|
99
|
-
Booker T. Washington
|
|
100
|
-
</usa-radio-option>
|
|
101
|
-
|
|
102
|
-
<usa-radio-option value="george-washington-carver">
|
|
103
|
-
George Washington Carver
|
|
104
|
-
</usa-radio-option>
|
|
105
|
-
</usa-radio>
|
|
106
|
-
</form>
|
|
107
|
-
`);
|
|
29
|
+
const form = await fixture(html `<form><usa-radio name="historical-figures" value="frederick-douglass"><usa-radio-option value="sojourner-truth">Sojourner Truth</usa-radio-option><usa-radio-option value="frederick-douglass">Frederick Douglass</usa-radio-option><usa-radio-option value="booker-t-washington">Booker T. Washington</usa-radio-option><usa-radio-option value="george-washington-carver">George Washington Carver</usa-radio-option></usa-radio></form>`);
|
|
108
30
|
const value = new FormData(form);
|
|
109
31
|
const nativeInputs = form.querySelector("usa-radio")?.shadowRoot?.querySelectorAll("input") ??
|
|
110
32
|
[];
|
|
@@ -112,27 +34,7 @@ describe("usa-radio", () => {
|
|
|
112
34
|
assert.equal(value.get("historical-figures"), "frederick-douglass");
|
|
113
35
|
});
|
|
114
36
|
it("should submit form with changed value", async () => {
|
|
115
|
-
const form = await fixture(html
|
|
116
|
-
<form>
|
|
117
|
-
<usa-radio name="historical-figures" value="frederick-douglass">
|
|
118
|
-
<usa-radio-option value="sojourner-truth">
|
|
119
|
-
Sojourner Truth
|
|
120
|
-
</usa-radio-option>
|
|
121
|
-
|
|
122
|
-
<usa-radio-option value="frederick-douglass">
|
|
123
|
-
Frederick Douglass
|
|
124
|
-
</usa-radio-option>
|
|
125
|
-
|
|
126
|
-
<usa-radio-option value="booker-t-washington">
|
|
127
|
-
Booker T. Washington
|
|
128
|
-
</usa-radio-option>
|
|
129
|
-
|
|
130
|
-
<usa-radio-option value="george-washington-carver">
|
|
131
|
-
George Washington Carver
|
|
132
|
-
</usa-radio-option>
|
|
133
|
-
</usa-radio>
|
|
134
|
-
</form>
|
|
135
|
-
`);
|
|
37
|
+
const form = await fixture(html `<form><usa-radio name="historical-figures" value="frederick-douglass"><usa-radio-option value="sojourner-truth">Sojourner Truth</usa-radio-option><usa-radio-option value="frederick-douglass">Frederick Douglass</usa-radio-option><usa-radio-option value="booker-t-washington">Booker T. Washington</usa-radio-option><usa-radio-option value="george-washington-carver">George Washington Carver</usa-radio-option></usa-radio></form>`);
|
|
136
38
|
const nativeInputs = form.querySelector("usa-radio")?.shadowRoot?.querySelectorAll("input") ??
|
|
137
39
|
[];
|
|
138
40
|
nativeInputs[3].click();
|
|
@@ -4,58 +4,8 @@ let USARangeSliderElement = (() => {
|
|
|
4
4
|
let _classDecorators = [element({
|
|
5
5
|
tagName: "usa-range-slider",
|
|
6
6
|
shadowDom: [
|
|
7
|
-
css
|
|
8
|
-
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
max-width: 30rem;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
input {
|
|
15
|
-
height: 2.5rem;
|
|
16
|
-
-webkit-appearance: none; /* Hides the slider so that custom slider can be made */
|
|
17
|
-
width: 100%; /* Specific width is required for Firefox. */
|
|
18
|
-
background: transparent; /* Otherwise white in Chrome */
|
|
19
|
-
border-radius: 0;
|
|
20
|
-
color: #1b1b1b;
|
|
21
|
-
display: block;
|
|
22
|
-
margin-top: .5rem;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
input:focus {
|
|
26
|
-
outline: .25rem solid #2491ff;
|
|
27
|
-
outline-offset: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
input::-webkit-slider-thumb {
|
|
31
|
-
height: 1.25rem;
|
|
32
|
-
border-radius: 99rem;
|
|
33
|
-
width: 1.25rem;
|
|
34
|
-
background: #f0f0f0;
|
|
35
|
-
border: 0;
|
|
36
|
-
box-shadow: 0 0 0 2px #757575;
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
-webkit-appearance: none;
|
|
39
|
-
appearance: none;
|
|
40
|
-
margin-top: -.19rem;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
input::-webkit-slider-runnable-track {
|
|
44
|
-
background-color: #f0f0f0;
|
|
45
|
-
border-radius: 99rem;
|
|
46
|
-
border: 1px solid #757575;
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
height: 1rem;
|
|
49
|
-
width: 100%;
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
html `
|
|
53
|
-
<label>
|
|
54
|
-
<slot></slot>
|
|
55
|
-
</label>
|
|
56
|
-
|
|
57
|
-
<input type="range">
|
|
58
|
-
`,
|
|
7
|
+
css `:host{display:flex;flex-direction:column;max-width:30rem}input{height:2.5rem;-webkit-appearance:none;width:100%;background:0 0;border-radius:0;color:#1b1b1b;display:block;margin-top:.5rem}input:focus{outline:.25rem solid #2491ff;outline-offset:0}input::-webkit-slider-thumb{height:1.25rem;border-radius:99rem;width:1.25rem;background:#f0f0f0;border:0;box-shadow:0 0 0 2px #757575;cursor:pointer;-webkit-appearance:none;appearance:none;margin-top:-.19rem}input::-webkit-slider-runnable-track{background-color:#f0f0f0;border-radius:99rem;border:1px solid #757575;cursor:pointer;height:1rem;width:100%}`,
|
|
8
|
+
html `<label><slot></slot></label> <input type="range">`,
|
|
59
9
|
],
|
|
60
10
|
})];
|
|
61
11
|
let _classDescriptor;
|
|
@@ -2,30 +2,16 @@ import "./range-slider.element.js";
|
|
|
2
2
|
import { assert, fixture, html } from "@open-wc/testing";
|
|
3
3
|
describe("usa-range-slider", () => {
|
|
4
4
|
it("should be accessible", async () => {
|
|
5
|
-
const rangeSlider = await fixture(html
|
|
6
|
-
<usa-range-slider name="slider" value="0">Hello World</usa-range-slider>
|
|
7
|
-
`);
|
|
5
|
+
const rangeSlider = await fixture(html `<usa-range-slider name="slider" value="0">Hello World</usa-range-slider>`);
|
|
8
6
|
return assert.isAccessible(rangeSlider);
|
|
9
7
|
});
|
|
10
8
|
it("should submit form with default values", async () => {
|
|
11
|
-
const form = await fixture(html
|
|
12
|
-
<form>
|
|
13
|
-
<usa-range-slider name="slider" value="50">Hello World</usa-range-slider>
|
|
14
|
-
|
|
15
|
-
<button>Submit</button>
|
|
16
|
-
</form>
|
|
17
|
-
`);
|
|
9
|
+
const form = await fixture(html `<form><usa-range-slider name="slider" value="50">Hello World</usa-range-slider><button>Submit</button></form>`);
|
|
18
10
|
const value = new FormData(form);
|
|
19
11
|
assert.equal(value.get("slider"), "50");
|
|
20
12
|
});
|
|
21
13
|
it("should update form value as input value changed", async () => {
|
|
22
|
-
const form = await fixture(html
|
|
23
|
-
<form>
|
|
24
|
-
<usa-range-slider name="slider" value="50">Hello World</usa-range-slider>
|
|
25
|
-
|
|
26
|
-
<button>Submit</button>
|
|
27
|
-
</form>
|
|
28
|
-
`);
|
|
14
|
+
const form = await fixture(html `<form><usa-range-slider name="slider" value="50">Hello World</usa-range-slider><button>Submit</button></form>`);
|
|
29
15
|
const input = form.querySelector("usa-input");
|
|
30
16
|
const nativeInput = input?.shadowRoot?.querySelector("input");
|
|
31
17
|
if (nativeInput) {
|
|
@@ -9,55 +9,8 @@ let USASelectElement = (() => {
|
|
|
9
9
|
}), element({
|
|
10
10
|
tagName: "usa-select",
|
|
11
11
|
shadowDom: [
|
|
12
|
-
css
|
|
13
|
-
|
|
14
|
-
display: block;
|
|
15
|
-
line-height: 1.3;
|
|
16
|
-
position: relative;
|
|
17
|
-
width: 100%;
|
|
18
|
-
max-width: 30rem;
|
|
19
|
-
margin-bottom: 1.5rem;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
select {
|
|
23
|
-
font-size: 1.06rem;
|
|
24
|
-
appearance: none;
|
|
25
|
-
border-width: 1px;
|
|
26
|
-
border-color: #5c5c5c;
|
|
27
|
-
border-style: solid;
|
|
28
|
-
border-radius: 0;
|
|
29
|
-
color: #1b1b1b;
|
|
30
|
-
display: block;
|
|
31
|
-
height: 2.5rem;
|
|
32
|
-
margin-top: 0.5rem;
|
|
33
|
-
padding: 0.5rem;
|
|
34
|
-
width: 100%;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
select:not(:disabled):focus {
|
|
38
|
-
outline: 0.25rem solid #2491ff;
|
|
39
|
-
outline-offset: 0;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
usa-icon {
|
|
43
|
-
position: absolute;
|
|
44
|
-
right: 0.5rem;
|
|
45
|
-
bottom: 12%;
|
|
46
|
-
height: 1.5rem;
|
|
47
|
-
width: 1.5rem;
|
|
48
|
-
}
|
|
49
|
-
`,
|
|
50
|
-
html `
|
|
51
|
-
<usa-icon icon="unfold_more"></usa-icon>
|
|
52
|
-
|
|
53
|
-
<label>
|
|
54
|
-
<div class="label">
|
|
55
|
-
<slot></slot>
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<select></select>
|
|
59
|
-
</label>
|
|
60
|
-
`,
|
|
12
|
+
css `:host{display:block;line-height:1.3;position:relative;width:100%;max-width:30rem;margin-bottom:1.5rem}select{font-size:1.06rem;appearance:none;border-width:1px;border-color:#5c5c5c;border-style:solid;border-radius:0;color:#1b1b1b;display:block;height:2.5rem;margin-top:.5rem;padding:.5rem;width:100%}select:not(:disabled):focus{outline:.25rem solid #2491ff;outline-offset:0}usa-icon{position:absolute;right:.5rem;bottom:12%;height:1.5rem;width:1.5rem}`,
|
|
13
|
+
html `<usa-icon icon="unfold_more"></usa-icon><label><div class="label"><slot></slot></div><select></select></label>`,
|
|
61
14
|
],
|
|
62
15
|
})];
|
|
63
16
|
let _classDescriptor;
|
|
@@ -4,16 +4,7 @@ const meta = {
|
|
|
4
4
|
title: "usa-select",
|
|
5
5
|
tags: ["autodocs"],
|
|
6
6
|
render() {
|
|
7
|
-
return html
|
|
8
|
-
<usa-select value="third">
|
|
9
|
-
Hello World
|
|
10
|
-
|
|
11
|
-
<usa-select-option value="first">first</usa-select-option>
|
|
12
|
-
<usa-select-option value="second">second</usa-select-option>
|
|
13
|
-
<usa-select-option value="third">third</usa-select-option>
|
|
14
|
-
<usa-select-option value="fourth">fourth</usa-select-option>
|
|
15
|
-
</usa-select>
|
|
16
|
-
`;
|
|
7
|
+
return html `<usa-select value="third">Hello World<usa-select-option value="first">first</usa-select-option><usa-select-option value="second">second</usa-select-option><usa-select-option value="third">third</usa-select-option><usa-select-option value="fourth">fourth</usa-select-option></usa-select>`;
|
|
17
8
|
},
|
|
18
9
|
argTypes: {},
|
|
19
10
|
args: {},
|