@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
@@ -5,67 +5,8 @@ let USAFileInputPreviewElement = (() => {
5
5
  let _classDecorators = [element({
6
6
  tagName: "usa-file-input-preview",
7
7
  shadowDom: [
8
- css `
9
- * {
10
- box-sizing: border-box;
11
- }
12
-
13
- :host {
14
- display: block;
15
- font-size: 0.87rem;
16
- pointer-events: none;
17
- position: relative;
18
- text-align: left;
19
- word-wrap: anywhere;
20
- z-index: 3;
21
- }
22
-
23
- :host([hidden]) {
24
- display: none;
25
- }
26
-
27
- img {
28
- border: 0;
29
- display: block;
30
- height: 2.5rem;
31
- margin-right: 0.5rem;
32
- -o-object-fit: contain;
33
- object-fit: contain;
34
- width: 2.5rem;
35
- }
36
-
37
- .preview-heading {
38
- align-items: center;
39
- background: #d9e8f6;
40
- display: flex;
41
- pointer-events: none;
42
- position: relative;
43
- z-index: 3;
44
- font-weight: 700;
45
- justify-content: space-between;
46
- padding: 0.5rem;
47
- text-align: left;
48
- }
49
-
50
- .preview-item {
51
- align-items: center;
52
- background: #d9e8f6;
53
- display: flex;
54
- padding: 0.5rem;
55
- width: 100%;
56
- margin-top: 1px;
57
- }
58
- `,
59
- html `
60
- <template>
61
- <div class="preview-item">
62
- <img height="40" width="40" aria-hidden="true" style="display: none" />
63
- <usa-icon icon="file_present" style="display: none"></usa-icon>
64
- </div>
65
- </template>
66
-
67
- <slot class="preview-heading"></slot>
68
- `,
8
+ css `*{box-sizing:border-box}:host{display:block;font-size:.87rem;pointer-events:none;position:relative;text-align:left;word-wrap:anywhere;z-index:3}:host([hidden]){display:none}img{border:0;display:block;height:2.5rem;margin-right:.5rem;-o-object-fit:contain;object-fit:contain;width:2.5rem}.preview-heading{align-items:center;background:#d9e8f6;display:flex;pointer-events:none;position:relative;z-index:3;font-weight:700;justify-content:space-between;padding:.5rem;text-align:left}.preview-item{align-items:center;background:#d9e8f6;display:flex;padding:.5rem;width:100%;margin-top:1px}`,
9
+ html `<template><div class="preview-item"><img height="40" width="40" aria-hidden="true" style="display:none"><usa-icon icon="file_present" style="display:none"></usa-icon></div></template><slot class="preview-heading"></slot>`,
69
10
  ],
70
11
  })];
71
12
  let _classDescriptor;
@@ -3,33 +3,21 @@ import "../../link/link.element.js";
3
3
  import { assert, fixture, html } from "@open-wc/testing";
4
4
  describe("usa-file-input-preview", () => {
5
5
  it("should be accessible with no files", async () => {
6
- const fileInputPreview = await fixture(html `
7
- <usa-file-input-preview>
8
- Selected file <usa-link>Change file</usa-link>
9
- </usa-file-input-preview>
10
- `);
6
+ const fileInputPreview = await fixture(html `<usa-file-input-preview>Selected file<usa-link>Change file</usa-link></usa-file-input-preview>`);
11
7
  return assert.isAccessible(fileInputPreview);
12
8
  });
13
9
  it("should be accessible with files", async () => {
14
10
  const data = new DataTransfer();
15
11
  data.items.add(new File([], "image1.jpg"));
16
12
  data.items.add(new File([], "image2.jpg"));
17
- const fileInputPreview = await fixture(html `
18
- <usa-file-input-preview .files=${data.files}>
19
- Selected file <usa-link>Change file</usa-link>
20
- </usa-file-input-preview>
21
- `);
13
+ const fileInputPreview = await fixture(html `<usa-file-input-preview .files="${data.files}">Selected file<usa-link>Change file</usa-link></usa-file-input-preview>`);
22
14
  return assert.isAccessible(fileInputPreview);
23
15
  });
24
16
  it("should display file preview for images", async () => {
25
17
  const data = new DataTransfer();
26
18
  data.items.add(new File([], "image1.jpg"));
27
19
  data.items.add(new File([], "image2.jpg"));
28
- const { shadowRoot } = await fixture(html `
29
- <usa-file-input-preview .files=${data.files}>
30
- Selected file <usa-link>Change file</usa-link>
31
- </usa-file-input-preview>
32
- `);
20
+ const { shadowRoot } = await fixture(html `<usa-file-input-preview .files="${data.files}">Selected file<usa-link>Change file</usa-link></usa-file-input-preview>`);
33
21
  const previewItems = Array.from(shadowRoot?.querySelectorAll(".preview-item") ?? []).map((item) => item.textContent?.trim());
34
22
  assert.deepEqual(previewItems, ["image1.jpg", "image2.jpg"]);
35
23
  });
@@ -37,11 +25,7 @@ describe("usa-file-input-preview", () => {
37
25
  const data = new DataTransfer();
38
26
  data.items.add(new File([], "image1.jpg"));
39
27
  data.items.add(new File([], "image2.jpg"));
40
- const fileInputPreview = await fixture(html `
41
- <usa-file-input-preview .files=${data.files}>
42
- Selected file <usa-link>Change file</usa-link>
43
- </usa-file-input-preview>
44
- `);
28
+ const fileInputPreview = await fixture(html `<usa-file-input-preview .files="${data.files}">Selected file<usa-link>Change file</usa-link></usa-file-input-preview>`);
45
29
  const data2 = new DataTransfer();
46
30
  data2.items.add(new File([], "image1.jpg"));
47
31
  fileInputPreview.files = data2.files;
@@ -54,11 +38,7 @@ describe("usa-file-input-preview", () => {
54
38
  const data = new DataTransfer();
55
39
  data.items.add(new File(["Image1"], "image1.jpg", { type: "image/jpg" }));
56
40
  data.items.add(new File(["Image2"], "image2.jpg", { type: "image/jpg" }));
57
- const { shadowRoot } = await fixture(html `
58
- <usa-file-input-preview .files=${data.files}>
59
- Selected file <usa-link>Change file</usa-link>
60
- </usa-file-input-preview>
61
- `);
41
+ const { shadowRoot } = await fixture(html `<usa-file-input-preview .files="${data.files}">Selected file<usa-link>Change file</usa-link></usa-file-input-preview>`);
62
42
  const [first, second] = Array.from(shadowRoot?.querySelectorAll(".preview-item img") ?? []).map((item) => item.src.substring(29));
63
43
  // we are just testing that the two hashes are in fact different
64
44
  assert.isFalse(first === second);
@@ -5,88 +5,8 @@ let USAFileInputElement = (() => {
5
5
  let _classDecorators = [element({
6
6
  tagName: "usa-file-input",
7
7
  shadowDom: [
8
- css `
9
- * {
10
- box-sizing: border-box;
11
- }
12
-
13
- :host {
14
- display: block;
15
- max-width: 30rem;
16
- position: relative;
17
- margin-bottom: 1.5rem;
18
- }
19
-
20
- label {
21
- display: block;
22
- }
23
-
24
- input {
25
- cursor: pointer;
26
- left: 0;
27
- margin: 0;
28
- max-width: none;
29
- position: absolute;
30
- text-indent: -999em;
31
- width: 100%;
32
- z-index: 1;
33
- bottom: 0;
34
- top: 0;
35
- }
36
-
37
- input:focus {
38
- outline: 0.25rem solid #2491ff;
39
- outline-offset: 0;
40
- }
41
-
42
- label slot.label {
43
- font-size: 1.06rem;
44
- line-height: 1.3;
45
- display: block;
46
- font-weight: 400;
47
- margin-bottom: 0.5rem;
48
- }
49
-
50
- :host(.dragenter) .box {
51
- border-color: #2491ff;
52
- }
53
-
54
- .box {
55
- border: 1px dashed #adadad;
56
- display: flex;
57
- font-size: 0.93rem;
58
- position: relative;
59
- text-align: center;
60
- width: 100%;
61
- max-width: 30rem;
62
- height: 5.2rem;
63
- align-items: center;
64
- justify-content: center;
65
- }
66
-
67
- .container {
68
- position: relative;
69
- }
70
- `,
71
- html `
72
- <label>
73
- <slot class="label"></slot>
74
-
75
- <div class="container">
76
- <input type="file" tabindex="0"/>
77
-
78
- <div class="box">
79
- <slot name="description">
80
- Drag file here or <usa-link>choose from folder</usa-link>
81
- </slot>
82
- </div>
83
-
84
- <usa-file-input-preview>
85
- Selected file <usa-link>Change file</usa-link>
86
- </usa-file-input-preview>
87
- </div>
88
- </label>
89
- `,
8
+ css `*{box-sizing:border-box}:host{display:block;max-width:30rem;position:relative;margin-bottom:1.5rem}label{display:block}input{cursor:pointer;left:0;margin:0;max-width:none;position:absolute;text-indent:-999em;width:100%;z-index:1;bottom:0;top:0}input:focus{outline:.25rem solid #2491ff;outline-offset:0}label slot.label{font-size:1.06rem;line-height:1.3;display:block;font-weight:400;margin-bottom:.5rem}:host(.dragenter) .box{border-color:#2491ff}.box{border:1px dashed #adadad;display:flex;font-size:.93rem;position:relative;text-align:center;width:100%;max-width:30rem;height:5.2rem;align-items:center;justify-content:center}.container{position:relative}`,
9
+ html `<label><slot class="label"></slot><div class="container"><input type="file" tabindex="0"><div class="box"><slot name="description">Drag file here or<usa-link>choose from folder</usa-link></slot></div><usa-file-input-preview>Selected file<usa-link>Change file</usa-link></usa-file-input-preview></div></label>`,
90
10
  ],
91
11
  })];
92
12
  let _classDescriptor;
@@ -9,19 +9,7 @@ const meta = {
9
9
  const data = new FormData(e.target);
10
10
  console.log(data.getAll("upload"));
11
11
  }
12
- return html `
13
- <form @submit=${onSubmit}>
14
- <usa-file-input name="upload" required>
15
- Input accepts a single file
16
-
17
- <div slot="description">
18
- Drag file here or <usa-link>choose from folder</usa-link>
19
- </div>
20
- </usa-file-input>
21
-
22
- <usa-button type="submit">SUBMIT</usa-button>
23
- </form>
24
- `;
12
+ return html `<form @submit="${onSubmit}"><usa-file-input name="upload" required>Input accepts a single file<div slot="description">Drag file here or<usa-link>choose from folder</usa-link></div></usa-file-input><usa-button type="submit">SUBMIT</usa-button></form>`;
25
13
  },
26
14
  argTypes: {},
27
15
  args: {},
@@ -2,28 +2,14 @@ import "./file-input.element.js";
2
2
  import { assert, fixture, html } from "@open-wc/testing";
3
3
  describe("usa-file-input", () => {
4
4
  it("should be accessible", async () => {
5
- const fileInput = await fixture(html `
6
- <usa-file-input>Hello World</usa-file-input>
7
- `);
5
+ const fileInput = await fixture(html `<usa-file-input>Hello World</usa-file-input>`);
8
6
  return assert.isAccessible(fileInput);
9
7
  });
10
8
  it("should submit files with the form", async () => {
11
9
  const data = new DataTransfer();
12
10
  data.items.add(new File([], "first.txt"));
13
11
  data.items.add(new File([], "second.txt"));
14
- const form = await fixture(html `
15
- <form>
16
- <usa-file-input name="upload" .files=${data.files}>
17
- Input accepts a single file
18
-
19
- <div slot="description">
20
- Drag file here or <usa-link>choose from folder</usa-link>
21
- </div>
22
- </usa-file-input>
23
-
24
- <button>Submit</button>
25
- </form>
26
- `);
12
+ const form = await fixture(html `<form><usa-file-input name="upload" .files="${data.files}">Input accepts a single file<div slot="description">Drag file here or<usa-link>choose from folder</usa-link></div></usa-file-input><button>Submit</button></form>`);
27
13
  const formData = new FormData(form);
28
14
  const fileNames = formData.getAll("upload").map((file) => {
29
15
  if (file instanceof File) {
@@ -6,20 +6,7 @@ let USAIconElement = (() => {
6
6
  let _classDecorators = [element({
7
7
  tagName: "usa-icon",
8
8
  shadowDom: [
9
- css `
10
- :host {
11
- display: inline-block;
12
- height: 2rem;
13
- position: relative;
14
- width: 2rem;
15
- }
16
-
17
- svg {
18
- fill: currentColor;
19
- height: 100%;
20
- width: 100%;
21
- }
22
- `,
9
+ css `:host{display:inline-block;height:2rem;position:relative;width:2rem}svg{fill:currentColor;height:100%;width:100%}`,
23
10
  ],
24
11
  }), injectable({
25
12
  name: "usa-icon-ctx",
@@ -5,7 +5,7 @@ const meta = {
5
5
  title: "usa-icon",
6
6
  tags: [],
7
7
  render(args) {
8
- return html `<usa-icon icon=${args.icon}></usa-icon>`;
8
+ return html `<usa-icon icon="${args.icon}"></usa-icon>`;
9
9
  },
10
10
  argTypes: {},
11
11
  args: {},
@@ -22,18 +22,7 @@ export const AllIcons = {
22
22
  console.error("Failed to copy: ", err);
23
23
  }
24
24
  }
25
- return html `<div style="display: flex; flex-wrap: wrap; gap: .75rem;">
26
- ${html `${ICON_TYPES.map((icon) => html `
27
- <button
28
- @click=${() => copyIcon(icon)}
29
- style="padding: .5rem 1rem .5rem .5rem; cursor: pointer; background: #fff; border-radius: 4px; gap: .5rem; display: flex; align-items: center"
30
- >
31
- <usa-icon icon=${icon}></usa-icon>
32
-
33
- ${icon}
34
- </button>
35
- `)}`}
36
- </div>`;
25
+ return html `<div style="display:flex;flex-wrap:wrap;gap:.75rem">${html `${ICON_TYPES.map((icon) => html `<button @click="${() => copyIcon(icon)}" style="padding:.5rem 1rem .5rem .5rem;cursor:pointer;background:#fff;border-radius:4px;gap:.5rem;display:flex;align-items:center"><usa-icon icon="${icon}"></usa-icon>${icon}</button>`)}`}</div>`;
37
26
  },
38
27
  };
39
28
  //# sourceMappingURL=icon.stories.js.map
@@ -5,79 +5,8 @@ let USATextInputElement = (() => {
5
5
  let _classDecorators = [element({
6
6
  tagName: "usa-input",
7
7
  shadowDom: [
8
- css `
9
- * {
10
- box-sizing: border-box;
11
- }
12
-
13
- :host {
14
- font-size: 1.06rem;
15
- line-height: 1.3;
16
- display: block;
17
- font-weight: 400;
18
- max-width: 30rem;
19
- margin-bottom: 1.5rem;
20
- position: relative;
21
- }
22
-
23
- input {
24
- border-width: 1px;
25
- border-color: #5c5c5c;
26
- border-style: solid;
27
- border-radius: 0;
28
- color: #1b1b1b;
29
- display: block;
30
- height: 2.5rem;
31
- line-height: 1.3;
32
- font-size: 1.06rem;
33
- margin-top: 0.5rem;
34
- padding: 0.5rem;
35
- width: 100%;
36
- }
37
-
38
- input:not(:disabled):focus {
39
- outline: 0.25rem solid #2491ff;
40
- outline-offset: 0;
41
- }
42
-
43
- slot[name="detail"]::slotted(*) {
44
- color: #757575;
45
- }
46
-
47
- slot[name="detail"]::slotted(usa-icon) {
48
- width: 1.5rem;
49
- height: 1.5rem;
50
- }
51
-
52
- slot[name="detail"] {
53
- display: block;
54
- position: absolute;
55
- bottom: 0.21rem;
56
- left: 0.5rem;
57
- }
58
-
59
- :host([detail="pfx"]) input {
60
- padding-left: 2.5rem;
61
- }
62
-
63
- :host([detail="sfx"]) input {
64
- padding-right: 2.5rem;
65
- }
66
-
67
- :host([detail="sfx"]) slot[name="detail"] {
68
- right: 0.5rem;
69
- left: auto;
70
- }
71
- `,
72
- html `
73
- <label>
74
- <slot name="detail"></slot>
75
-
76
- <slot></slot>
77
-
78
- <input tabindex="0" />
79
- </label>
80
- `,
8
+ css `*{box-sizing:border-box}:host{font-size:1.06rem;line-height:1.3;display:block;font-weight:400;max-width:30rem;margin-bottom:1.5rem;position:relative}input{border-width:1px;border-color:#5c5c5c;border-style:solid;border-radius:0;color:#1b1b1b;display:block;height:2.5rem;line-height:1.3;font-size:1.06rem;margin-top:.5rem;padding:.5rem;width:100%}input:not(:disabled):focus{outline:.25rem solid #2491ff;outline-offset:0}slot[name=detail]::slotted(*){color:#757575}slot[name=detail]::slotted(usa-icon){width:1.5rem;height:1.5rem}slot[name=detail]{display:block;position:absolute;bottom:.21rem;left:.5rem}:host([detail=pfx]) input{padding-left:2.5rem}:host([detail=sfx]) input{padding-right:2.5rem}:host([detail=sfx]) slot[name=detail]{right:.5rem;left:auto}`,
9
+ html `<label><slot name="detail"></slot><slot></slot><input tabindex="0"></label>`,
81
10
  ],
82
11
  })];
83
12
  let _classDescriptor;
@@ -4,21 +4,11 @@ const meta = {
4
4
  title: "usa-input",
5
5
  tags: ["autodocs"],
6
6
  render() {
7
- return html `
8
- <form @submit=${(e) => {
7
+ return html `<form @submit="${(e) => {
9
8
  e.preventDefault();
10
9
  const data = new FormData(e.target);
11
10
  console.log(Array.from(data.entries()));
12
- }}>
13
- <usa-input name="fname" autocomplete="off" detail="pfx">
14
- <usa-icon icon="credit_card" slot="detail"></usa-icon>
15
-
16
- First name
17
- </usa-input>
18
-
19
- <usa-button type="submit">Submit</usa-button>
20
- </form>
21
- `;
11
+ }}"><usa-input name="fname" autocomplete="off" detail="pfx"><usa-icon icon="credit_card" slot="detail"></usa-icon>First name</usa-input><usa-button type="submit">Submit</usa-button></form>`;
22
12
  },
23
13
  argTypes: {},
24
14
  args: {},
@@ -3,30 +3,16 @@ import { assert, fixture, html } from "@open-wc/testing";
3
3
  import { userEvent } from "@testing-library/user-event";
4
4
  describe("usa-input", () => {
5
5
  it("should be accessible", async () => {
6
- const form = await fixture(html `
7
- <usa-input name="fname" value="Foo">Hello World</usa-input>
8
- `);
6
+ const form = await fixture(html `<usa-input name="fname" value="Foo">Hello World</usa-input>`);
9
7
  return assert.isAccessible(form);
10
8
  });
11
9
  it("should submit form with default values", async () => {
12
- const form = await fixture(html `
13
- <form>
14
- <usa-input name="fname" value="Foo">Hello World</usa-input>
15
-
16
- <button>Submit</button>
17
- </form>
18
- `);
10
+ const form = await fixture(html `<form><usa-input name="fname" value="Foo">Hello World</usa-input><button>Submit</button></form>`);
19
11
  const value = new FormData(form);
20
12
  assert.equal(value.get("fname"), "Foo");
21
13
  });
22
14
  it("should update form value as input value changed", async () => {
23
- const form = await fixture(html `
24
- <form>
25
- <usa-input name="fname">Hello World</usa-input>
26
-
27
- <button>Submit</button>
28
- </form>
29
- `);
15
+ const form = await fixture(html `<form><usa-input name="fname">Hello World</usa-input><button>Submit</button></form>`);
30
16
  const input = form.querySelector("usa-input");
31
17
  const nativeInput = input?.shadowRoot?.querySelector("input");
32
18
  if (nativeInput) {
@@ -36,13 +22,7 @@ describe("usa-input", () => {
36
22
  assert.equal(value.get("fname"), "Bar");
37
23
  });
38
24
  it("should not submit when not valid", async () => {
39
- const form = await fixture(html `
40
- <form>
41
- <usa-input name="fname" required>Hello World</usa-input>
42
-
43
- <button>Submit</button>
44
- </form>
45
- `);
25
+ const form = await fixture(html `<form><usa-input name="fname" required>Hello World</usa-input><button>Submit</button></form>`);
46
26
  assert.equal(form.checkValidity(), false);
47
27
  });
48
28
  });
@@ -5,11 +5,7 @@ let USAInputMaskElement = (() => {
5
5
  let _classDecorators = [element({
6
6
  tagName: "usa-input-mask",
7
7
  shadowDom: [
8
- css `
9
- :host {
10
- display: contents;
11
- }
12
- `,
8
+ css `:host{display:contents}`,
13
9
  html `<slot></slot>`,
14
10
  ],
15
11
  })];
@@ -4,18 +4,7 @@ const meta = {
4
4
  title: "input-mask",
5
5
  tags: ["autodocs"],
6
6
  render(args) {
7
- return html `
8
- <usa-input-mask>
9
- <usa-input
10
- name="phone"
11
- placeholder=${args.mask}
12
- autocomplete="off"
13
- mask=${args.mask}
14
- >
15
- Phone:
16
- </usa-input>
17
- </usa-input-mask>
18
- `;
7
+ return html `<usa-input-mask><usa-input name="phone" placeholder="${args.mask}" autocomplete="off" mask="${args.mask}">Phone:</usa-input></usa-input-mask>`;
19
8
  },
20
9
  argTypes: {},
21
10
  args: {
@@ -36,20 +36,12 @@ describe("format", () => {
36
36
  });
37
37
  describe("usa-input-mask", () => {
38
38
  it("should format default value", async () => {
39
- const el = await fixture(html `
40
- <usa-input-mask mask="(999) 999-9999">
41
- <input name="phone" value="1234567890" mask />
42
- </usa-input-mask>
43
- `);
39
+ const el = await fixture(html `<usa-input-mask mask="(999) 999-9999"><input name="phone" value="1234567890" mask></usa-input-mask>`);
44
40
  const input = el.querySelector("input");
45
41
  assert.equal(input?.value, "(123) 456-7890");
46
42
  });
47
43
  it("should update value when on input event", async () => {
48
- const el = await fixture(html `
49
- <usa-input-mask>
50
- <input name="phone" mask="(999) 999-9999" />
51
- </usa-input-mask>
52
- `);
44
+ const el = await fixture(html `<usa-input-mask><input name="phone" mask="(999) 999-9999"></usa-input-mask>`);
53
45
  const input = el.querySelector("input");
54
46
  if (input) {
55
47
  input.value = "8888888888";
@@ -60,24 +52,12 @@ describe("usa-input-mask", () => {
60
52
  });
61
53
  describe("usa-input-mask with usa-input", () => {
62
54
  it("should format default value", async () => {
63
- const el = await fixture(html `
64
- <usa-input-mask mask="(999) 999-9999">
65
- <usa-input name="phone" value="1234567890" id="TEST" mask></usa-input>
66
- </usa-input-mask>
67
- `);
55
+ const el = await fixture(html `<usa-input-mask mask="(999) 999-9999"><usa-input name="phone" value="1234567890" id="TEST" mask></usa-input></usa-input-mask>`);
68
56
  const input = el.querySelector("usa-input");
69
57
  assert.equal(input?.value, "(123) 456-7890");
70
58
  });
71
59
  it("should update value when on input event", async () => {
72
- const el = await fixture(html `
73
- <usa-input-mask>
74
- <usa-input
75
- name="phone"
76
- value="1234567890"
77
- mask="(999) 999-9999"
78
- ></usa-input>
79
- </usa-input-mask>
80
- `);
60
+ const el = await fixture(html `<usa-input-mask><usa-input name="phone" value="1234567890" mask="(999) 999-9999"></usa-input></usa-input-mask>`);
81
61
  const input = el.querySelector("usa-input");
82
62
  if (input) {
83
63
  input.value = "8888888888";
@@ -4,24 +4,8 @@ let USALinkElement = (() => {
4
4
  let _classDecorators = [element({
5
5
  tagName: "usa-link",
6
6
  shadowDom: [
7
- css `
8
- :host {
9
- display: inline-flex;
10
- color: #005ea2;
11
- text-decoration: underline;
12
- }
13
-
14
- a {
15
- color: inherit;
16
- text-decoration: inherit;
17
- display: inherit;
18
- }
19
- `,
20
- html `
21
- <a>
22
- <slot></slot>
23
- </a>
24
- `,
7
+ css `:host{display:inline-flex;color:#005ea2;text-decoration:underline}a{color:inherit;text-decoration:inherit;display:inherit}`,
8
+ html `<a><slot></slot></a>`,
25
9
  ],
26
10
  })];
27
11
  let _classDescriptor;
@@ -4,42 +4,8 @@ let USAModalCloseElement = (() => {
4
4
  let _classDecorators = [element({
5
5
  tagName: "usa-modal-close",
6
6
  shadowDom: [
7
- css `
8
- * {
9
- box-sizing: border-box;
10
- }
11
-
12
- :host {
13
- display: block;
14
- position: absolute;
15
- top: 1rem;
16
- right: 1rem;
17
- }
18
-
19
- button {
20
- display: flex;
21
- align-items: center;
22
- justify-content: center;
23
- background: none;
24
- border: none;
25
- cursor: pointer;
26
- height: 100%;
27
- width: 100%;
28
- border-radius: 100%;
29
- padding: 0;
30
- margin: 0;
31
- }
32
-
33
- button:focus {
34
- outline: 0.25rem solid #2491ff;
35
- outline-offset: 0;
36
- }
37
- `,
38
- html `
39
- <button aria-label="close modal">
40
- <usa-icon icon="close"></usa-icon>
41
- </button>
42
- `,
7
+ css `*{box-sizing:border-box}:host{display:block;position:absolute;top:1rem;right:1rem}button{display:flex;align-items:center;justify-content:center;background:0 0;border:none;cursor:pointer;height:100%;width:100%;border-radius:100%;padding:0;margin:0}button:focus{outline:.25rem solid #2491ff;outline-offset:0}`,
8
+ html `<button aria-label="close modal"><usa-icon icon="close"></usa-icon></button>`,
43
9
  ],
44
10
  })];
45
11
  let _classDescriptor;
@@ -2,9 +2,7 @@ import "./modal-close.element.js";
2
2
  import { assert, fixture, html } from "@open-wc/testing";
3
3
  describe("usa-modal-close", () => {
4
4
  it("should be accessible", async () => {
5
- const modalClose = await fixture(html `
6
- <usa-modal-close>Hello World</usa-modal-close>
7
- `);
5
+ const modalClose = await fixture(html `<usa-modal-close>Hello World</usa-modal-close>`);
8
6
  return assert.isAccessible(modalClose);
9
7
  });
10
8
  });