@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.
Files changed (143) hide show
  1. package/assets/flags/alabama.svg +5 -0
  2. package/assets/flags/alaska.svg +14 -0
  3. package/assets/flags/arizona.svg +7 -0
  4. package/assets/flags/arkansas.svg +15 -0
  5. package/assets/flags/california.svg +8 -0
  6. package/assets/flags/colorado.svg +8 -0
  7. package/assets/flags/connecticut.svg +5 -0
  8. package/assets/flags/delaware.svg +7 -0
  9. package/assets/flags/florida.svg +5 -0
  10. package/assets/flags/georgia.svg +5 -0
  11. package/assets/flags/hawaii.svg +19 -0
  12. package/assets/flags/idaho.svg +5 -0
  13. package/assets/flags/illinois.svg +5 -0
  14. package/assets/flags/indiana.svg +15 -0
  15. package/assets/flags/iowa.svg +13 -0
  16. package/assets/flags/kansas.svg +5 -0
  17. package/assets/flags/kentucky.svg +16 -0
  18. package/assets/flags/louisiana.svg +14 -0
  19. package/assets/flags/maine.svg +12 -0
  20. package/assets/flags/maryland.svg +14 -0
  21. package/assets/flags/massachusetts.svg +15 -0
  22. package/assets/flags/michigan.svg +5 -0
  23. package/assets/flags/minnesota.svg +15 -0
  24. package/assets/flags/mississippi.svg +10 -0
  25. package/assets/flags/missouri.svg +16 -0
  26. package/assets/flags/montana.svg +11 -0
  27. package/assets/flags/nebraska.svg +13 -0
  28. package/assets/flags/nevada.svg +14 -0
  29. package/assets/flags/new_hampshire.svg +13 -0
  30. package/assets/flags/new_jersey.svg +13 -0
  31. package/assets/flags/new_mexico.svg +7 -0
  32. package/assets/flags/new_york.svg +13 -0
  33. package/assets/flags/north_carolina.svg +5 -0
  34. package/assets/flags/north_dakota.svg +13 -0
  35. package/assets/flags/ohio.svg +16 -0
  36. package/assets/flags/oklahoma.svg +12 -0
  37. package/assets/flags/oregon.svg +13 -0
  38. package/assets/flags/pennsylvania.svg +15 -0
  39. package/assets/flags/rhode_island.svg +13 -0
  40. package/assets/flags/south_carolina.svg +11 -0
  41. package/assets/flags/south_dakota.svg +15 -0
  42. package/assets/flags/tennessee.svg +13 -0
  43. package/assets/flags/texas.svg +8 -0
  44. package/assets/flags/utah.svg +9 -0
  45. package/assets/flags/vermont.svg +13 -0
  46. package/assets/flags/virginia.svg +5 -0
  47. package/assets/flags/washington.svg +5 -0
  48. package/assets/flags/west_virginia.svg +24 -0
  49. package/assets/flags/wisconsin.svg +5 -0
  50. package/assets/flags/wyoming.svg +5 -0
  51. package/package.json +13 -11
  52. package/src/lib/combo-box/combo-box-option/combo-box-option.element.ts +32 -13
  53. package/src/lib/combo-box/combo-box.element.ts +161 -43
  54. package/src/lib/combo-box/combo-box.stories.ts +202 -56
  55. package/src/lib/combo-box/combo-box.test.ts +140 -22
  56. package/target/lib/accordion/accordion.element.js +2 -86
  57. package/target/lib/accordion/accordion.stories.js +1 -26
  58. package/target/lib/accordion/accordion.test.js +5 -72
  59. package/target/lib/alert/alert.element.js +2 -71
  60. package/target/lib/alert/alert.stories.js +1 -41
  61. package/target/lib/alert/alert.test.js +1 -9
  62. package/target/lib/button/button.element.js +2 -142
  63. package/target/lib/button/button.stories.js +1 -6
  64. package/target/lib/button/button.test.js +1 -3
  65. package/target/lib/card/card-body/card-body.element.js +1 -8
  66. package/target/lib/card/card-footer/card-footer.element.js +1 -6
  67. package/target/lib/card/card-group/card-group.element.js +1 -12
  68. package/target/lib/card/card-header/card-header.element.js +1 -16
  69. package/target/lib/card/card-media/card-media.element.js +2 -33
  70. package/target/lib/card/card.element.js +1 -32
  71. package/target/lib/card/card.stories.js +2 -107
  72. package/target/lib/card/card.test.js +1 -20
  73. package/target/lib/checkbox/checkbox-group/checkbox-group.element.js +2 -10
  74. package/target/lib/checkbox/checkbox.element.js +2 -112
  75. package/target/lib/checkbox/checkbox.stories.js +2 -43
  76. package/target/lib/checkbox/checkbox.test.js +4 -28
  77. package/target/lib/collection/collection-item/collection-item.element.js +2 -40
  78. package/target/lib/collection/collection-item/collection-item.test.js +1 -3
  79. package/target/lib/collection/collection.element.js +2 -10
  80. package/target/lib/collection/collection.stories.js +1 -63
  81. package/target/lib/collection/collection.test.js +1 -3
  82. package/target/lib/combo-box/combo-box-option/combo-box-option.element.d.ts +0 -1
  83. package/target/lib/combo-box/combo-box-option/combo-box-option.element.js +21 -12
  84. package/target/lib/combo-box/combo-box-option/combo-box-option.element.js.map +1 -1
  85. package/target/lib/combo-box/combo-box.element.d.ts +9 -1
  86. package/target/lib/combo-box/combo-box.element.js +92 -86
  87. package/target/lib/combo-box/combo-box.element.js.map +1 -1
  88. package/target/lib/combo-box/combo-box.stories.js +1 -59
  89. package/target/lib/combo-box/combo-box.stories.js.map +1 -1
  90. package/target/lib/combo-box/combo-box.test.js +65 -22
  91. package/target/lib/combo-box/combo-box.test.js.map +1 -1
  92. package/target/lib/config/config.element.js +1 -5
  93. package/target/lib/config/config.test.js +1 -3
  94. package/target/lib/description/description.element.js +1 -7
  95. package/target/lib/description/description.test.js +1 -3
  96. package/target/lib/file-input/file-input-preview/file-input-preview.element.js +2 -61
  97. package/target/lib/file-input/file-input-preview/file-input-preview.test.js +5 -25
  98. package/target/lib/file-input/file-input.element.js +2 -82
  99. package/target/lib/file-input/file-input.stories.js +1 -13
  100. package/target/lib/file-input/file-input.test.js +2 -16
  101. package/target/lib/icon/icon.element.js +1 -14
  102. package/target/lib/icon/icon.stories.js +2 -13
  103. package/target/lib/input/input.element.js +2 -73
  104. package/target/lib/input/input.stories.js +2 -12
  105. package/target/lib/input/input.test.js +4 -24
  106. package/target/lib/input-mask/input-mask.element.js +1 -5
  107. package/target/lib/input-mask/input-mask.stories.js +1 -12
  108. package/target/lib/input-mask/input-mask.test.js +4 -24
  109. package/target/lib/link/link.element.js +2 -18
  110. package/target/lib/modal/modal-close/modal-close.element.js +2 -36
  111. package/target/lib/modal/modal-close/modal-close.test.js +1 -3
  112. package/target/lib/modal/modal-heading/modal-heading.element.js +2 -24
  113. package/target/lib/modal/modal-heading/modal-heading.test.js +1 -3
  114. package/target/lib/modal/modal.element.js +2 -33
  115. package/target/lib/modal/modal.stories.js +1 -18
  116. package/target/lib/modal/modal.test.js +1 -11
  117. package/target/lib/radio/radio-option/radio-option.element.js +2 -16
  118. package/target/lib/radio/radio-option/radio-option.test.js +1 -5
  119. package/target/lib/radio/radio.element.js +2 -98
  120. package/target/lib/radio/radio.stories.js +1 -26
  121. package/target/lib/radio/radio.test.js +5 -103
  122. package/target/lib/range-slider/range-slider.element.js +2 -52
  123. package/target/lib/range-slider/range-slider.test.js +3 -17
  124. package/target/lib/select/select-option/select-option.element.js +1 -5
  125. package/target/lib/select/select.element.js +2 -49
  126. package/target/lib/select/select.stories.js +1 -10
  127. package/target/lib/select/select.test.js +6 -64
  128. package/target/lib/side-nav/side-nav-item/side-nav-item.element.js +2 -67
  129. package/target/lib/side-nav/side-nav.element.js +1 -8
  130. package/target/lib/side-nav/side-nav.stories.js +1 -39
  131. package/target/lib/side-nav/side-nav.test.js +2 -78
  132. package/target/lib/step-indicator/step/step.element.js +2 -96
  133. package/target/lib/step-indicator/step-indicator.element.js +1 -9
  134. package/target/lib/step-indicator/step-indicator.stories.js +1 -21
  135. package/target/lib/step-indicator/step-indicator.test.js +1 -9
  136. package/target/lib/summary-box/summary-box.element.js +2 -14
  137. package/target/lib/summary-box/summary-box.stories.js +1 -1
  138. package/target/lib/summary-box/summary-box.test.js +1 -3
  139. package/target/lib/tag/tag.element.js +1 -22
  140. package/target/lib/tag/tag.stories.js +1 -1
  141. package/target/lib/tag/tag.test.js +1 -3
  142. package/target/lib/textarea/textarea.element.js +2 -49
  143. package/target/lib/textarea/textarea.test.js +4 -24
@@ -9,62 +9,208 @@ const meta = {
9
9
  tags: ["autodocs"],
10
10
  render() {
11
11
  return html`
12
- <usa-combo-box>
13
- <usa-input name="search" slot="input" autocomplete="off" detail="sfx">
14
- States
15
- <usa-icon slot="detail" icon="expand_more"></usa-icon>
16
- </usa-input>
17
-
18
- <usa-combo-box-option value="Alabama"></usa-combo-box-option>
19
- <usa-combo-box-option value="Alaska"></usa-combo-box-option>
20
- <usa-combo-box-option value="Arizona"></usa-combo-box-option>
21
- <usa-combo-box-option value="Arkansas"></usa-combo-box-option>
22
- <usa-combo-box-option value="California"></usa-combo-box-option>
23
- <usa-combo-box-option value="Colorado"></usa-combo-box-option>
24
- <usa-combo-box-option value="Connecticut"></usa-combo-box-option>
25
- <usa-combo-box-option value="Delaware"></usa-combo-box-option>
26
- <usa-combo-box-option value="Florida"></usa-combo-box-option>
27
- <usa-combo-box-option value="Georgia"></usa-combo-box-option>
28
- <usa-combo-box-option value="Hawaii"></usa-combo-box-option>
29
- <usa-combo-box-option value="Idaho"></usa-combo-box-option>
30
- <usa-combo-box-option value="Illinois"></usa-combo-box-option>
31
- <usa-combo-box-option value="Indiana"></usa-combo-box-option>
32
- <usa-combo-box-option value="Iowa"></usa-combo-box-option>
33
- <usa-combo-box-option value="Kansas"></usa-combo-box-option>
34
- <usa-combo-box-option value="Kentucky"></usa-combo-box-option>
35
- <usa-combo-box-option value="Louisiana"></usa-combo-box-option>
36
- <usa-combo-box-option value="Maine"></usa-combo-box-option>
37
- <usa-combo-box-option value="Maryland"></usa-combo-box-option>
38
- <usa-combo-box-option value="Massachusetts"></usa-combo-box-option>
39
- <usa-combo-box-option value="Michigan"></usa-combo-box-option>
40
- <usa-combo-box-option value="Minnesota"></usa-combo-box-option>
41
- <usa-combo-box-option value="Mississippi"></usa-combo-box-option>
42
- <usa-combo-box-option value="Missouri"></usa-combo-box-option>
43
- <usa-combo-box-option value="Montana"></usa-combo-box-option>
44
- <usa-combo-box-option value="Nebraska"></usa-combo-box-option>
45
- <usa-combo-box-option value="Nevada"></usa-combo-box-option>
46
- <usa-combo-box-option value="New Hampshire"></usa-combo-box-option>
47
- <usa-combo-box-option value="New Jersey"></usa-combo-box-option>
48
- <usa-combo-box-option value="New Mexico"></usa-combo-box-option>
49
- <usa-combo-box-option value="New York"></usa-combo-box-option>
50
- <usa-combo-box-option value="North Carolina"></usa-combo-box-option>
51
- <usa-combo-box-option value="North Dakota"></usa-combo-box-option>
52
- <usa-combo-box-option value="Ohio"></usa-combo-box-option>
53
- <usa-combo-box-option value="Oklahoma"></usa-combo-box-option>
54
- <usa-combo-box-option value="Oregon"></usa-combo-box-option>
55
- <usa-combo-box-option value="Pennsylvania"></usa-combo-box-option>
56
- <usa-combo-box-option value="Rhode Island"></usa-combo-box-option>
57
- <usa-combo-box-option value="South Carolina"></usa-combo-box-option>
58
- <usa-combo-box-option value="South Dakota"></usa-combo-box-option>
59
- <usa-combo-box-option value="Tennessee"></usa-combo-box-option>
60
- <usa-combo-box-option value="Texas"></usa-combo-box-option>
61
- <usa-combo-box-option value="Utah"></usa-combo-box-option>
62
- <usa-combo-box-option value="Vermont"></usa-combo-box-option>
63
- <usa-combo-box-option value="Virginia"></usa-combo-box-option>
64
- <usa-combo-box-option value="Washington"></usa-combo-box-option>
65
- <usa-combo-box-option value="West Virginia"></usa-combo-box-option>
66
- <usa-combo-box-option value="Wisconsin"></usa-combo-box-option>
67
- <usa-combo-box-option value="Wyoming"></usa-combo-box-option>
12
+ <usa-combo-box placeholder="Select a state" name="state">
13
+ <span slot="label">States</span>
14
+
15
+ <usa-combo-box-option value="Alabama">
16
+ <img loading="lazy" src="./flags/alabama.svg" alt="Alabama" height="20" /> Alabama
17
+ </usa-combo-box-option>
18
+
19
+ <usa-combo-box-option value="Alaska">
20
+ <img loading="lazy" src="./flags/alaska.svg" alt="Alaska" height="20" /> Alaska
21
+ </usa-combo-box-option>
22
+
23
+ <usa-combo-box-option value="Arizona">
24
+ <img loading="lazy" src="./flags/arizona.svg" alt="Arizona" height="20" /> Arizona
25
+ </usa-combo-box-option>
26
+
27
+ <usa-combo-box-option value="Arkansas">
28
+ <img loading="lazy" src="./flags/arkansas.svg" alt="Arkansas" height="20" /> Arkansas
29
+ </usa-combo-box-option>
30
+
31
+ <usa-combo-box-option value="California">
32
+ <img loading="lazy" src="./flags/california.svg" alt="California" height="20" /> California
33
+ </usa-combo-box-option>
34
+
35
+ <usa-combo-box-option value="Colorado">
36
+ <img loading="lazy" src="./flags/colorado.svg" alt="Colorado" height="20" /> Colorado
37
+ </usa-combo-box-option>
38
+
39
+ <usa-combo-box-option value="Connecticut">
40
+ <img loading="lazy" src="./flags/connecticut.svg" alt="Connecticut" height="20" /> Connecticut
41
+ </usa-combo-box-option>
42
+
43
+ <usa-combo-box-option value="Delaware">
44
+ <img loading="lazy" src="./flags/delaware.svg" alt="Delaware" height="20" /> Delaware
45
+ </usa-combo-box-option>
46
+
47
+ <usa-combo-box-option value="Florida">
48
+ <img loading="lazy" src="./flags/florida.svg" alt="Florida" height="20" /> Florida
49
+ </usa-combo-box-option>
50
+
51
+ <usa-combo-box-option value="Georgia">
52
+ <img loading="lazy" src="./flags/georgia.svg" alt="Georgia" height="20" /> Georgia
53
+ </usa-combo-box-option>
54
+
55
+ <usa-combo-box-option value="Hawaii">
56
+ <img loading="lazy" src="./flags/hawaii.svg" alt="Hawaii" height="20" /> Hawaii
57
+ </usa-combo-box-option>
58
+
59
+ <usa-combo-box-option value="Idaho">
60
+ <img loading="lazy" src="./flags/idaho.svg" alt="Idaho" height="20" /> Idaho
61
+ </usa-combo-box-option>
62
+
63
+ <usa-combo-box-option value="Illinois">
64
+ <img loading="lazy" src="./flags/illinois.svg" alt="Illinois" height="20" /> Illinois
65
+ </usa-combo-box-option>
66
+
67
+ <usa-combo-box-option value="Indiana">
68
+ <img loading="lazy" src="./flags/indiana.svg" alt="Indiana" height="20" /> Indiana
69
+ </usa-combo-box-option>
70
+
71
+ <usa-combo-box-option value="Iowa">
72
+ <img loading="lazy" src="./flags/iowa.svg" alt="Iowa" height="20" /> Iowa
73
+ </usa-combo-box-option>
74
+
75
+ <usa-combo-box-option value="Kansas">
76
+ <img loading="lazy" src="./flags/kansas.svg" alt="Kansas" height="20" /> Kansas
77
+ </usa-combo-box-option>
78
+
79
+ <usa-combo-box-option value="Kentucky">
80
+ <img loading="lazy" src="./flags/kentucky.svg" alt="Kentucky" height="20" /> Kentucky
81
+ </usa-combo-box-option>
82
+
83
+ <usa-combo-box-option value="Louisiana">
84
+ <img loading="lazy" src="./flags/louisiana.svg" alt="Louisiana" height="20" /> Louisiana
85
+ </usa-combo-box-option>
86
+
87
+ <usa-combo-box-option value="Maine">
88
+ <img loading="lazy" src="./flags/maine.svg" alt="Maine" height="20" /> Maine
89
+ </usa-combo-box-option>
90
+
91
+ <usa-combo-box-option value="Maryland">
92
+ <img loading="lazy" src="./flags/maryland.svg" alt="Maryland" height="20" /> Maryland
93
+ </usa-combo-box-option>
94
+
95
+ <usa-combo-box-option value="Massachusetts">
96
+ <img loading="lazy" src="./flags/massachusetts.svg" alt="Massachusetts" height="20" /> Massachusetts
97
+ </usa-combo-box-option>
98
+
99
+ <usa-combo-box-option value="Michigan">
100
+ <img loading="lazy" src="./flags/michigan.svg" alt="Michigan" height="20" /> Michigan
101
+ </usa-combo-box-option>
102
+
103
+ <usa-combo-box-option value="Minnesota">
104
+ <img loading="lazy" src="./flags/minnesota.svg" alt="Minnesota" height="20" /> Minnesota
105
+ </usa-combo-box-option>
106
+
107
+ <usa-combo-box-option value="Mississippi">
108
+ <img loading="lazy" src="./flags/mississippi.svg" alt="Mississippi" height="20" /> Mississippi
109
+ </usa-combo-box-option>
110
+
111
+ <usa-combo-box-option value="Missouri">
112
+ <img loading="lazy" src="./flags/missouri.svg" alt="Missouri" height="20" /> Missouri
113
+ </usa-combo-box-option>
114
+
115
+ <usa-combo-box-option value="Montana">
116
+ <img loading="lazy" src="./flags/montana.svg" alt="Montana" height="20" /> Montana
117
+ </usa-combo-box-option>
118
+
119
+ <usa-combo-box-option value="Nebraska">
120
+ <img loading="lazy" src="./flags/nebraska.svg" alt="Nebraska" height="20" /> Nebraska
121
+ </usa-combo-box-option>
122
+
123
+ <usa-combo-box-option value="Nevada">
124
+ <img loading="lazy" src="./flags/nevada.svg" alt="Nevada" height="20" /> Nevada
125
+ </usa-combo-box-option>
126
+
127
+ <usa-combo-box-option value="New Hampshire">
128
+ <img loading="lazy" src="./flags/new_hampshire.svg" alt="New Hampshire" height="20" /> New Hampshire
129
+ </usa-combo-box-option>
130
+
131
+ <usa-combo-box-option value="New Jersey">
132
+ <img loading="lazy" src="./flags/new_jersey.svg" alt="New Jersey" height="20" /> New Jersey
133
+ </usa-combo-box-option>
134
+
135
+ <usa-combo-box-option value="New Mexico">
136
+ <img loading="lazy" src="./flags/new_mexico.svg" alt="New Mexico" height="20" /> New Mexico
137
+ </usa-combo-box-option>
138
+
139
+ <usa-combo-box-option value="New York">
140
+ <img loading="lazy" src="./flags/new_york.svg" alt="New York" height="20" /> New York
141
+ </usa-combo-box-option>
142
+
143
+ <usa-combo-box-option value="North Carolina">
144
+ <img loading="lazy" src="./flags/north_carolina.svg" alt="North Carolina" height="20" /> North Carolina
145
+ </usa-combo-box-option>
146
+
147
+ <usa-combo-box-option value="North Dakota">
148
+ <img loading="lazy" src="./flags/north_dakota.svg" alt="North Dakota" height="20" /> North Dakota
149
+ </usa-combo-box-option>
150
+
151
+ <usa-combo-box-option value="Ohio">
152
+ <img loading="lazy" src="./flags/ohio.svg" alt="Ohio" height="20" /> Ohio
153
+ </usa-combo-box-option>
154
+
155
+ <usa-combo-box-option value="Oklahoma">
156
+ <img loading="lazy" src="./flags/oklahoma.svg" alt="Oklahoma" height="20" /> Oklahoma
157
+ </usa-combo-box-option>
158
+
159
+ <usa-combo-box-option value="Oregon">
160
+ <img loading="lazy" src="./flags/oregon.svg" alt="Oregon" height="20" /> Oregon
161
+ </usa-combo-box-option>
162
+
163
+ <usa-combo-box-option value="Pennsylvania">
164
+ <img loading="lazy" src="./flags/pennsylvania.svg" alt="Pennsylvania" height="20" /> Pennsylvania
165
+ </usa-combo-box-option>
166
+
167
+ <usa-combo-box-option value="Rhode Island">
168
+ <img loading="lazy" src="./flags/rhode_island.svg" alt="Rhode Island" height="20" /> Rhode Island
169
+ </usa-combo-box-option>
170
+
171
+ <usa-combo-box-option value="South Carolina">
172
+ <img loading="lazy" src="./flags/south_carolina.svg" alt="South Carolina" height="20" /> South Carolina
173
+ </usa-combo-box-option>
174
+
175
+ <usa-combo-box-option value="South Dakota">
176
+ <img loading="lazy" src="./flags/south_dakota.svg" alt="South Dakota" height="20" /> South Dakota
177
+ </usa-combo-box-option>
178
+
179
+ <usa-combo-box-option value="Tennessee">
180
+ <img loading="lazy" src="./flags/tennessee.svg" alt="Tennessee" height="20" /> Tennessee
181
+ </usa-combo-box-option>
182
+
183
+ <usa-combo-box-option value="Texas">
184
+ <img loading="lazy" src="./flags/texas.svg" alt="Texas" height="20" /> Texas
185
+ </usa-combo-box-option>
186
+
187
+ <usa-combo-box-option value="Utah">
188
+ <img loading="lazy" src="./flags/utah.svg" alt="Utah" height="20" /> Utah
189
+ </usa-combo-box-option>
190
+
191
+ <usa-combo-box-option value="Vermont">
192
+ <img loading="lazy" src="./flags/vermont.svg" alt="Vermont" height="20" /> Vermont
193
+ </usa-combo-box-option>
194
+
195
+ <usa-combo-box-option value="Virginia">
196
+ <img loading="lazy" src="./flags/virginia.svg" alt="Virginia" height="20" /> Virginia
197
+ </usa-combo-box-option>
198
+
199
+ <usa-combo-box-option value="Washington">
200
+ <img loading="lazy" src="./flags/washington.svg" alt="Washington" height="20" /> Washington
201
+ </usa-combo-box-option>
202
+
203
+ <usa-combo-box-option value="West Virginia">
204
+ <img loading="lazy" src="./flags/west_virginia.svg" alt="West Virginia" height="20" /> West Virginia
205
+ </usa-combo-box-option>
206
+
207
+ <usa-combo-box-option value="Wisconsin">
208
+ <img loading="lazy" src="./flags/wisconsin.svg" alt="Wisconsin" height="20" /> Wisconsin
209
+ </usa-combo-box-option>
210
+
211
+ <usa-combo-box-option value="Wyoming">
212
+ <img loading="lazy" src="./flags/wyoming.svg" alt="Wyoming" height="20" /> Wyoming
213
+ </usa-combo-box-option>
68
214
  </usa-combo-box>
69
215
  `;
70
216
  },
@@ -3,33 +3,27 @@ import "./combo-box-option/combo-box-option.element.js";
3
3
  import "../input/input.element.js";
4
4
 
5
5
  import { assert, fixture, html } from "@open-wc/testing";
6
+ import { userEvent } from "@testing-library/user-event";
6
7
 
7
- import type { USATextInputElement } from "../input/input.element.js";
8
8
  import type { USAComboBoxElement } from "./combo-box.element.js";
9
9
 
10
10
  describe("usa-combo-box", () => {
11
11
  let autocomplete: USAComboBoxElement;
12
- let input: USATextInputElement;
12
+ let input: HTMLInputElement;
13
13
 
14
14
  beforeEach(async () => {
15
15
  autocomplete = await fixture<USAComboBoxElement>(html`
16
- <usa-combo-box>
17
- <usa-input slot="input" name="search"></usa-input>
16
+ <usa-combo-box name="search" placeholder="Select a fruit">
17
+ <span slot="label">Fruits</span>
18
18
 
19
- <usa-combo-box-option value="Apple"></usa-combo-box-option>
20
- <usa-combo-box-option value="Banana"></usa-combo-box-option>
21
- <usa-combo-box-option value="Blueberry"></usa-combo-box-option>
22
- <usa-combo-box-option value="Cherry"></usa-combo-box-option>
19
+ <usa-combo-box-option value="Apple">Apple</usa-combo-box-option>
20
+ <usa-combo-box-option value="Banana">Banana</usa-combo-box-option>
21
+ <usa-combo-box-option value="Blueberry">Blueberry</usa-combo-box-option>
22
+ <usa-combo-box-option value="Cherry">Cherry</usa-combo-box-option>
23
23
  </usa-combo-box>
24
24
  `);
25
25
 
26
- const inputElement = autocomplete.querySelector("usa-input");
27
-
28
- if (!inputElement) {
29
- throw new Error("Input element not found");
30
- }
31
-
32
- input = inputElement;
26
+ input = autocomplete.input();
33
27
  });
34
28
 
35
29
  it("should filter items based on input", async () => {
@@ -37,9 +31,10 @@ describe("usa-combo-box", () => {
37
31
  input.dispatchEvent(new Event("input", { bubbles: true }));
38
32
 
39
33
  const suggestions = autocomplete.listItems();
34
+
40
35
  assert.equal(suggestions.length, 2);
41
- assert.equal(suggestions[0].textContent, "Banana");
42
- assert.equal(suggestions[1].textContent, "Blueberry");
36
+ assert.equal(suggestions[0].dataset.value, "Banana");
37
+ assert.equal(suggestions[1].dataset.value, "Blueberry");
43
38
  });
44
39
 
45
40
  it("should show all suggestions when input is empty", async () => {
@@ -56,8 +51,8 @@ describe("usa-combo-box", () => {
56
51
 
57
52
  const suggestions = autocomplete.listItems();
58
53
  assert.equal(suggestions.length, 2);
59
- assert.equal(suggestions[0].textContent, "Banana");
60
- assert.equal(suggestions[1].textContent, "Blueberry");
54
+ assert.equal(suggestions[0].dataset.value, "Banana");
55
+ assert.equal(suggestions[1].dataset.value, "Blueberry");
61
56
  });
62
57
 
63
58
  it("should navigate suggestions with arrow keys", async () => {
@@ -69,13 +64,19 @@ describe("usa-combo-box", () => {
69
64
  input.dispatchEvent(
70
65
  new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
71
66
  );
72
- assert.equal(autocomplete.currentItemEl?.textContent, "Banana");
67
+ assert.equal(
68
+ autocomplete.currentItemEl?.getAttribute("data-value"),
69
+ "Banana",
70
+ );
73
71
 
74
72
  // Arrow down again
75
73
  input.dispatchEvent(
76
74
  new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
77
75
  );
78
- assert.equal(autocomplete.currentItemEl?.textContent, "Blueberry");
76
+ assert.equal(
77
+ autocomplete.currentItemEl?.getAttribute("data-value"),
78
+ "Blueberry",
79
+ );
79
80
  });
80
81
 
81
82
  it("should select suggestion with enter key", async () => {
@@ -135,6 +136,123 @@ describe("usa-combo-box", () => {
135
136
  new KeyboardEvent("keydown", { key: "ArrowDown", bubbles: true }),
136
137
  );
137
138
 
138
- assert.equal(autocomplete.currentItemEl?.textContent, "Blueberry");
139
+ assert.equal(
140
+ autocomplete.currentItemEl?.getAttribute("data-value"),
141
+ "Blueberry",
142
+ );
143
+ });
144
+
145
+ it("should submit form with default values", async () => {
146
+ const form = await fixture<HTMLFormElement>(html`
147
+ <form>
148
+ <usa-combo-box name="search" value="Apple" placeholder="Select a fruit">
149
+ <span slot="label">Fruits</span>
150
+
151
+ <usa-combo-box-option value="Apple">Apple</usa-combo-box-option>
152
+ <usa-combo-box-option value="Banana">Banana</usa-combo-box-option>
153
+ <usa-combo-box-option value="Blueberry">Blueberry</usa-combo-box-option>
154
+ <usa-combo-box-option value="Cherry">Cherry</usa-combo-box-option>
155
+ </usa-combo-box>
156
+
157
+ <button>Submit</button>
158
+ </form>
159
+ `);
160
+
161
+ const value = new FormData(form);
162
+ assert.equal(value.get("search"), "Apple");
163
+ });
164
+
165
+ it("should update form value when an option is selected", async () => {
166
+ const form = await fixture<HTMLFormElement>(html`
167
+ <form>
168
+ <usa-combo-box name="search" placeholder="Select a fruit">
169
+ <span slot="label">Fruits</span>
170
+
171
+ <usa-combo-box-option value="Apple">Apple</usa-combo-box-option>
172
+ <usa-combo-box-option value="Banana">Banana</usa-combo-box-option>
173
+ <usa-combo-box-option value="Blueberry">Blueberry</usa-combo-box-option>
174
+ <usa-combo-box-option value="Cherry">Cherry</usa-combo-box-option>
175
+ </usa-combo-box>
176
+
177
+ <button>Submit</button>
178
+ </form>
179
+ `);
180
+
181
+ const comboBox = form.querySelector("usa-combo-box");
182
+
183
+ if (!comboBox) {
184
+ throw new Error("Combo box not found");
185
+ }
186
+
187
+ const input = comboBox.shadowRoot?.querySelector("input");
188
+
189
+ if (!input) {
190
+ throw new Error("input not found");
191
+ }
192
+
193
+ // Type to show suggestions
194
+ input.value = "Ban";
195
+ input.dispatchEvent(new Event("input", { bubbles: true }));
196
+
197
+ // Select the first suggestion
198
+ const suggestions = comboBox.listItems();
199
+
200
+ suggestions[0]
201
+ .querySelector("slot")
202
+ ?.assignedElements()[0]
203
+ .dispatchEvent(new MouseEvent("click", { bubbles: true }));
204
+
205
+ const value = new FormData(form);
206
+ assert.equal(value.get("search"), "Banana");
139
207
  });
208
+
209
+ it("should not submit when required and no value is selected", async () => {
210
+ const form = await fixture<HTMLFormElement>(html`
211
+ <form>
212
+ <usa-combo-box name="search" required placeholder="Select a fruit">
213
+ <span slot="label">Fruits</span>
214
+
215
+ <usa-combo-box-option value="Apple">Apple</usa-combo-box-option>
216
+ <usa-combo-box-option value="Banana">Banana</usa-combo-box-option>
217
+ <usa-combo-box-option value="Blueberry">Blueberry</usa-combo-box-option>
218
+ <usa-combo-box-option value="Cherry">Cherry</usa-combo-box-option>
219
+ </usa-combo-box>
220
+
221
+ <button>Submit</button>
222
+ </form>
223
+ `);
224
+
225
+ assert.equal(form.checkValidity(), false);
226
+ });
227
+
228
+ // it("should reset to default value when form is reset", async () => {
229
+ // const form = await fixture<HTMLFormElement>(html`
230
+ // <form>
231
+ // <usa-combo-box name="search" value="Apple" placeholder="Select a fruit">
232
+ // <span slot="label">Fruits</span>
233
+
234
+ // <usa-combo-box-option value="Apple">Apple</usa-combo-box-option>
235
+ // <usa-combo-box-option value="Banana">Banana</usa-combo-box-option>
236
+ // <usa-combo-box-option value="Blueberry">Blueberry</usa-combo-box-option>
237
+ // <usa-combo-box-option value="Cherry">Cherry</usa-combo-box-option>
238
+ // </usa-combo-box>
239
+
240
+ // <button type="submit">Submit</button>
241
+ // <button type="reset">Reset</button>
242
+ // </form>
243
+ // `);
244
+
245
+ // const comboBox = form.querySelector("usa-combo-box");
246
+ // if (comboBox) {
247
+ // // Change the value
248
+ // comboBox.value = "Banana";
249
+ // comboBox.dispatchEvent(new Event("input", { bubbles: true }));
250
+
251
+ // // Reset the form
252
+ // form.reset();
253
+
254
+ // // Check that the value was reset
255
+ // assert.equal(comboBox.value, "Apple");
256
+ // }
257
+ // });
140
258
  });
@@ -9,92 +9,8 @@ let USAAccordionElement = (() => {
9
9
  delegatesFocus: true,
10
10
  },
11
11
  shadowDom: [
12
- css `
13
- * {
14
- box-sizing: border-box;
15
- }
16
-
17
- :host {
18
- display: block;
19
- }
20
-
21
- :host(:not(:first-child)) summary {
22
- margin-top: 0.5rem;
23
- }
24
-
25
- summary {
26
- align-items: center;
27
- border: 0;
28
- border-radius: 0;
29
- box-shadow: none;
30
- justify-content: normal;
31
- text-align: left;
32
- padding: 0;
33
- color: #1b1b1b;
34
- background-color: #f0f0f0;
35
- cursor: pointer;
36
- display: flex;
37
- font-weight: 700;
38
- margin: 0;
39
- padding: 1rem 1.25rem 1rem 1.25rem;
40
- text-decoration: none;
41
- width: 100%;
42
- }
43
-
44
- summary::-webkit-details-marker {
45
- display: none;
46
- }
47
-
48
- slot[name="heading"] {
49
- display: block;
50
- flex: 1 1 auto;
51
- }
52
-
53
- slot[name="heading"]::slotted(*) {
54
- margin: 0;
55
- }
56
-
57
- .content {
58
- padding-bottom: 1.5rem;
59
- padding-left: 1rem;
60
- padding-top: 1.5rem;
61
- }
62
-
63
- usa-icon[icon="remove"] {
64
- display: none;
65
- }
66
-
67
- details[open] usa-icon[icon="add"] {
68
- display: none;
69
- }
70
-
71
- details[open] usa-icon[icon="remove"] {
72
- display: block;
73
- }
74
-
75
- summary:hover {
76
- background-color: #e6e6e6;
77
- }
78
-
79
- summary:focus {
80
- outline: 0.25rem solid #2491ff;
81
- outline-offset: 0;
82
- }
83
- `,
84
- html `
85
- <details>
86
- <summary>
87
- <slot name="heading"></slot>
88
-
89
- <usa-icon icon="add"></usa-icon>
90
- <usa-icon icon="remove"></usa-icon>
91
- </summary>
92
-
93
- <div class="content">
94
- <slot></slot>
95
- </div>
96
- </details>
97
- `,
12
+ css `*{box-sizing:border-box}:host{display:block}:host(:not(:first-child)) summary{margin-top:.5rem}summary{align-items:center;border:0;border-radius:0;box-shadow:none;justify-content:normal;text-align:left;padding:0;color:#1b1b1b;background-color:#f0f0f0;cursor:pointer;display:flex;font-weight:700;margin:0;padding:1rem 1.25rem 1rem 1.25rem;text-decoration:none;width:100%}summary::-webkit-details-marker{display:none}slot[name=heading]{display:block;flex:1 1 auto}slot[name=heading]::slotted(*){margin:0}.content{padding-bottom:1.5rem;padding-left:1rem;padding-top:1.5rem}usa-icon[icon=remove]{display:none}details[open] usa-icon[icon=add]{display:none}details[open] usa-icon[icon=remove]{display:block}summary:hover{background-color:#e6e6e6}summary:focus{outline:.25rem solid #2491ff;outline-offset:0}`,
13
+ html `<details><summary><slot name="heading"></slot><usa-icon icon="add"></usa-icon><usa-icon icon="remove"></usa-icon></summary><div class="content"><slot></slot></div></details>`,
98
14
  ],
99
15
  })];
100
16
  let _classDescriptor;
@@ -4,32 +4,7 @@ const meta = {
4
4
  title: "usa-accordion",
5
5
  tags: ["autodocs"],
6
6
  render() {
7
- return html `
8
- <usa-accordion id="first" name="ammendment">
9
- <h4 slot="heading">First Ammendment</h4>
10
-
11
- Congress shall make no law respecting an establishment of religion, or
12
- prohibiting the free exercise thereof; or abridging the freedom of
13
- speech, or of the press; or the right of the people peaceably to
14
- assemble, and to petition the Government for a redress of grievances.
15
- </usa-accordion>
16
-
17
- <usa-accordion id="second" name="ammendment">
18
- <h4 slot="heading">Second Ammendment</h4>
19
-
20
- A well regulated Militia, being necessary to the security of a free
21
- State, the right of the people to keep and bear Arms, shall not be
22
- infringed.
23
- </usa-accordion>
24
-
25
- <usa-accordion id="third" name="ammendment">
26
- <h4 slot="heading">Third Ammendment</h4>
27
-
28
- No Soldier shall, in time of peace be quartered in any house, without
29
- the consent of the Owner, nor in time of war, but in a manner to be
30
- prescribed by law.
31
- </usa-accordion>
32
- `;
7
+ return html `<usa-accordion id="first" name="ammendment"><h4 slot="heading">First Ammendment</h4>Congress shall make no law respecting an establishment of religion, or prohibiting the free exercise thereof; or abridging the freedom of speech, or of the press; or the right of the people peaceably to assemble, and to petition the Government for a redress of grievances.</usa-accordion><usa-accordion id="second" name="ammendment"><h4 slot="heading">Second Ammendment</h4>A well regulated Militia, being necessary to the security of a free State, the right of the people to keep and bear Arms, shall not be infringed.</usa-accordion><usa-accordion id="third" name="ammendment"><h4 slot="heading">Third Ammendment</h4>No Soldier shall, in time of peace be quartered in any house, without the consent of the Owner, nor in time of war, but in a manner to be prescribed by law.</usa-accordion>`;
33
8
  },
34
9
  argTypes: {},
35
10
  args: {},