@noctuatech/uswds 0.1.2 → 0.1.4

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.
Files changed (93) hide show
  1. package/package.json +13 -11
  2. package/src/lib/collection/collection.stories.ts +2 -2
  3. package/src/lib/combo-box/combo-box-option/combo-box-option.element.ts +4 -5
  4. package/src/lib/combo-box/combo-box.element.ts +132 -18
  5. package/src/lib/combo-box/combo-box.stories.ts +52 -60
  6. package/src/lib/combo-box/combo-box.test.ts +123 -15
  7. package/target/lib/accordion/accordion.element.js +2 -86
  8. package/target/lib/accordion/accordion.stories.js +1 -26
  9. package/target/lib/accordion/accordion.test.js +5 -72
  10. package/target/lib/alert/alert.element.js +2 -71
  11. package/target/lib/alert/alert.stories.js +1 -41
  12. package/target/lib/alert/alert.test.js +1 -9
  13. package/target/lib/button/button.element.js +2 -142
  14. package/target/lib/button/button.stories.js +1 -6
  15. package/target/lib/button/button.test.js +1 -3
  16. package/target/lib/card/card-body/card-body.element.js +1 -8
  17. package/target/lib/card/card-footer/card-footer.element.js +1 -6
  18. package/target/lib/card/card-group/card-group.element.js +1 -12
  19. package/target/lib/card/card-header/card-header.element.js +1 -16
  20. package/target/lib/card/card-media/card-media.element.js +2 -33
  21. package/target/lib/card/card.element.js +1 -32
  22. package/target/lib/card/card.stories.js +2 -107
  23. package/target/lib/card/card.test.js +1 -20
  24. package/target/lib/checkbox/checkbox-group/checkbox-group.element.js +2 -10
  25. package/target/lib/checkbox/checkbox.element.js +2 -112
  26. package/target/lib/checkbox/checkbox.stories.js +2 -43
  27. package/target/lib/checkbox/checkbox.test.js +4 -28
  28. package/target/lib/collection/collection-item/collection-item.element.js +2 -40
  29. package/target/lib/collection/collection-item/collection-item.test.js +1 -3
  30. package/target/lib/collection/collection.element.js +2 -10
  31. package/target/lib/collection/collection.stories.js +1 -63
  32. package/target/lib/collection/collection.test.js +1 -3
  33. package/target/lib/combo-box/combo-box-option/combo-box-option.element.js +4 -16
  34. package/target/lib/combo-box/combo-box-option/combo-box-option.element.js.map +1 -1
  35. package/target/lib/combo-box/combo-box.element.d.ts +8 -0
  36. package/target/lib/combo-box/combo-box.element.js +73 -64
  37. package/target/lib/combo-box/combo-box.element.js.map +1 -1
  38. package/target/lib/combo-box/combo-box.stories.js +1 -213
  39. package/target/lib/combo-box/combo-box.stories.js.map +1 -1
  40. package/target/lib/combo-box/combo-box.test.js +58 -15
  41. package/target/lib/combo-box/combo-box.test.js.map +1 -1
  42. package/target/lib/config/config.element.js +1 -5
  43. package/target/lib/config/config.test.js +1 -3
  44. package/target/lib/description/description.element.js +1 -7
  45. package/target/lib/description/description.test.js +1 -3
  46. package/target/lib/file-input/file-input-preview/file-input-preview.element.js +2 -61
  47. package/target/lib/file-input/file-input-preview/file-input-preview.test.js +5 -25
  48. package/target/lib/file-input/file-input.element.js +2 -82
  49. package/target/lib/file-input/file-input.stories.js +1 -13
  50. package/target/lib/file-input/file-input.test.js +2 -16
  51. package/target/lib/icon/icon.element.js +1 -14
  52. package/target/lib/icon/icon.stories.js +2 -13
  53. package/target/lib/input/input.element.js +2 -73
  54. package/target/lib/input/input.stories.js +2 -12
  55. package/target/lib/input/input.test.js +4 -24
  56. package/target/lib/input-mask/input-mask.element.js +1 -5
  57. package/target/lib/input-mask/input-mask.stories.js +1 -12
  58. package/target/lib/input-mask/input-mask.test.js +4 -24
  59. package/target/lib/link/link.element.js +2 -18
  60. package/target/lib/modal/modal-close/modal-close.element.js +2 -36
  61. package/target/lib/modal/modal-close/modal-close.test.js +1 -3
  62. package/target/lib/modal/modal-heading/modal-heading.element.js +2 -24
  63. package/target/lib/modal/modal-heading/modal-heading.test.js +1 -3
  64. package/target/lib/modal/modal.element.js +2 -33
  65. package/target/lib/modal/modal.stories.js +1 -18
  66. package/target/lib/modal/modal.test.js +1 -11
  67. package/target/lib/radio/radio-option/radio-option.element.js +2 -16
  68. package/target/lib/radio/radio-option/radio-option.test.js +1 -5
  69. package/target/lib/radio/radio.element.js +2 -98
  70. package/target/lib/radio/radio.stories.js +1 -26
  71. package/target/lib/radio/radio.test.js +5 -103
  72. package/target/lib/range-slider/range-slider.element.js +2 -52
  73. package/target/lib/range-slider/range-slider.test.js +3 -17
  74. package/target/lib/select/select-option/select-option.element.js +1 -5
  75. package/target/lib/select/select.element.js +2 -49
  76. package/target/lib/select/select.stories.js +1 -10
  77. package/target/lib/select/select.test.js +6 -64
  78. package/target/lib/side-nav/side-nav-item/side-nav-item.element.js +2 -67
  79. package/target/lib/side-nav/side-nav.element.js +1 -8
  80. package/target/lib/side-nav/side-nav.stories.js +1 -39
  81. package/target/lib/side-nav/side-nav.test.js +2 -78
  82. package/target/lib/step-indicator/step/step.element.js +2 -96
  83. package/target/lib/step-indicator/step-indicator.element.js +1 -9
  84. package/target/lib/step-indicator/step-indicator.stories.js +1 -21
  85. package/target/lib/step-indicator/step-indicator.test.js +1 -9
  86. package/target/lib/summary-box/summary-box.element.js +2 -14
  87. package/target/lib/summary-box/summary-box.stories.js +1 -1
  88. package/target/lib/summary-box/summary-box.test.js +1 -3
  89. package/target/lib/tag/tag.element.js +1 -22
  90. package/target/lib/tag/tag.stories.js +1 -1
  91. package/target/lib/tag/tag.test.js +1 -3
  92. package/target/lib/textarea/textarea.element.js +2 -49
  93. package/target/lib/textarea/textarea.test.js +4 -24
@@ -9,104 +9,8 @@ let USARadioElement = (() => {
9
9
  }), element({
10
10
  tagName: "usa-radio",
11
11
  shadowDom: [
12
- css `
13
- :host {
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
- :host {
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) {
@@ -6,11 +6,7 @@ let USASelecOptionElement = (() => {
6
6
  let _classDecorators = [element({
7
7
  tagName: "usa-select-option",
8
8
  shadowDom: [
9
- css `
10
- :host {
11
- display: none;
12
- }
13
- `,
9
+ css `:host{display:none}`,
14
10
  html `<slot></slot>`,
15
11
  ],
16
12
  }), injectable({
@@ -9,55 +9,8 @@ let USASelectElement = (() => {
9
9
  }), element({
10
10
  tagName: "usa-select",
11
11
  shadowDom: [
12
- css `
13
- :host {
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: {},
@@ -4,46 +4,18 @@ import { assert, fixture, html } from "@open-wc/testing";
4
4
  import { userEvent } from "@testing-library/user-event";
5
5
  describe("usa-select", () => {
6
6
  it("should be accessible", async () => {
7
- const el = await fixture(html `
8
- <usa-select name="example">
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>
15
- `);
7
+ const el = await fixture(html `<usa-select name="example">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>`);
16
8
  return assert.isAccessible(el);
17
9
  });
18
10
  it("should create local select options", async () => {
19
- const form = await fixture(html `
20
- <form>
21
- <usa-select name="example">
22
- Hello World
23
-
24
- <usa-select-option value="first">First</usa-select-option>
25
- <usa-select-option value="second">Second</usa-select-option>
26
- <usa-select-option value="third">Third</usa-select-option>
27
- </usa-select>
28
- </form>
29
- `);
11
+ const form = await fixture(html `<form><usa-select name="example">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></form>`);
30
12
  const nativeInputs = form
31
13
  .querySelector("usa-select")
32
14
  ?.shadowRoot?.querySelectorAll("option");
33
15
  assert.deepEqual(Array.from(nativeInputs ?? []).map((input) => input.value), ["first", "second", "third"]);
34
16
  });
35
17
  it("should remove select options when options are removed", async () => {
36
- const form = await fixture(html `
37
- <form>
38
- <usa-select name="example">
39
- Hello World
40
-
41
- <usa-select-option value="first">First</usa-select-option>
42
- <usa-select-option value="second">Second</usa-select-option>
43
- <usa-select-option value="third">Third</usa-select-option>
44
- </usa-select>
45
- </form>
46
- `);
18
+ const form = await fixture(html `<form><usa-select name="example">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></form>`);
47
19
  const options = form.querySelectorAll("usa-select-option");
48
20
  options[1].remove();
49
21
  const nativeInputs = form
@@ -52,32 +24,12 @@ describe("usa-select", () => {
52
24
  assert.deepEqual(Array.from(nativeInputs ?? []).map((input) => input.value), ["first", "third"]);
53
25
  });
54
26
  it("should submit form with default values", async () => {
55
- const form = await fixture(html `
56
- <form>
57
- <usa-select name="example" value="second">
58
- Hello World
59
-
60
- <usa-select-option value="first">First</usa-select-option>
61
- <usa-select-option value="second">Second</usa-select-option>
62
- <usa-select-option value="third">Third</usa-select-option>
63
- </usa-select>
64
- </form>
65
- `);
27
+ const form = await fixture(html `<form><usa-select name="example" value="second">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></form>`);
66
28
  const value = new FormData(form);
67
29
  assert.equal(value.get("example"), "second");
68
30
  });
69
31
  it("should update form value as select value changed", async () => {
70
- const form = await fixture(html `
71
- <form>
72
- <usa-select name="example" value="second">
73
- Hello World
74
-
75
- <usa-select-option value="first">First</usa-select-option>
76
- <usa-select-option value="second">Second</usa-select-option>
77
- <usa-select-option value="third">Third</usa-select-option>
78
- </usa-select>
79
- </form>
80
- `);
32
+ const form = await fixture(html `<form><usa-select name="example" value="second">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></form>`);
81
33
  const select = form.querySelector("usa-select");
82
34
  const nativeSelect = select?.shadowRoot?.querySelector("select");
83
35
  if (nativeSelect) {
@@ -87,17 +39,7 @@ describe("usa-select", () => {
87
39
  assert.equal(value.get("example"), "third");
88
40
  });
89
41
  it("should not submit when not valid", async () => {
90
- const form = await fixture(html `
91
- <form>
92
- <usa-select name="example" required>
93
- Hello World
94
-
95
- <usa-select-option value="first">First</usa-select-option>
96
- <usa-select-option value="second">Second</usa-select-option>
97
- <usa-select-option value="third">Third</usa-select-option>
98
- </usa-select>
99
- </form>
100
- `);
42
+ const form = await fixture(html `<form><usa-select name="example" required>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></form>`);
101
43
  assert.equal(form.checkValidity(), false);
102
44
  });
103
45
  });
@@ -4,73 +4,8 @@ let USASideNavItemElement = (() => {
4
4
  let _classDecorators = [element({
5
5
  tagName: "usa-side-nav-item",
6
6
  shadowDom: [
7
- css `
8
- :host {
9
- --usa-nav-item-padding-left: 2rem;
10
-
11
- display: block;
12
- border-top: 1px solid #e6e6e6;
13
- }
14
-
15
- .side-nav-item {
16
- display: flex;
17
- padding: 0.5rem 1rem;
18
- text-decoration: none;
19
- position: relative;
20
- }
21
-
22
- .side-nav-item:hover {
23
- background-color: #f0f0f0;
24
- color: #005ea2;
25
- }
26
-
27
- ::slotted(*) {
28
- color: #5c5c5c;
29
- text-decoration: none;
30
- display: block;
31
- width: 100%;
32
- }
33
-
34
- :host(:hover) ::slotted(*) {
35
- color: #005ea2;
36
- }
37
-
38
- :host([current]) ::slotted(*:not(usa-side-nav-item)) {
39
- color: #005ea2;
40
- font-weight: 700;
41
- }
42
-
43
- :host([current]) .side-nav-item::after {
44
- background-color: #005ea2;
45
- border-radius: 99rem;
46
- content: "";
47
- display: block;
48
- position: absolute;
49
- bottom: 0.25rem;
50
- top: 0.25rem;
51
- width: 0.25rem;
52
- left: 0;
53
- }
54
-
55
- :host([slot="children"]) .side-nav-item {
56
- padding-left: var(--usa-nav-item-padding-left);
57
- }
58
-
59
- :host([slot="children"]) ::slotted(usa-side-nav-item) {
60
- --usa-nav-item-padding-left: 3rem;
61
- }
62
-
63
- :host([slot="children"]) .side-nav-item::after {
64
- display: none;
65
- }
66
- `,
67
- html `
68
- <div class="side-nav-item">
69
- <slot></slot>
70
- </div>
71
-
72
- <slot name="children"></slot>
73
- `,
7
+ css `:host{--usa-nav-item-padding-left:2rem;display:block;border-top:1px solid #e6e6e6}.side-nav-item{display:flex;padding:.5rem 1rem;text-decoration:none;position:relative}.side-nav-item:hover{background-color:#f0f0f0;color:#005ea2}::slotted(*){color:#5c5c5c;text-decoration:none;display:block;width:100%}:host(:hover) ::slotted(*){color:#005ea2}:host([current]) ::slotted(:not(usa-side-nav-item)){color:#005ea2;font-weight:700}:host([current]) .side-nav-item::after{background-color:#005ea2;border-radius:99rem;content:"";display:block;position:absolute;bottom:.25rem;top:.25rem;width:.25rem;left:0}:host([slot=children]) .side-nav-item{padding-left:var(--usa-nav-item-padding-left)}:host([slot=children]) ::slotted(usa-side-nav-item){--usa-nav-item-padding-left:3rem}:host([slot=children]) .side-nav-item::after{display:none}`,
8
+ html `<div class="side-nav-item"><slot></slot></div><slot name="children"></slot>`,
74
9
  ],
75
10
  })];
76
11
  let _classDescriptor;
@@ -4,14 +4,7 @@ let USASideNavElement = (() => {
4
4
  let _classDecorators = [element({
5
5
  tagName: "usa-side-nav",
6
6
  shadowDom: [
7
- css `
8
- :host {
9
- display: block;
10
- font-size: 1.06rem;
11
- line-height: 1.3;
12
- border-bottom: 1px solid #e6e6e6;
13
- }
14
- `,
7
+ css `:host{display:block;font-size:1.06rem;line-height:1.3;border-bottom:1px solid #e6e6e6}`,
15
8
  html `<slot></slot>`,
16
9
  ],
17
10
  })];