@noctuatech/uswds 1.3.0 → 1.3.2

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 (56) hide show
  1. package/package.json +56 -21
  2. package/src/lib/accordion/accordion.element.ts +18 -26
  3. package/src/lib/alert/alert.element.ts +21 -20
  4. package/src/lib/alert/alert.stories.ts +10 -15
  5. package/src/lib/file-input/file-input-preview/file-input-preview.element.ts +17 -14
  6. package/src/lib/file-input/file-input.element.ts +56 -61
  7. package/src/lib/icon/icon.element.ts +37 -27
  8. package/src/lib/input/input.element.ts +30 -39
  9. package/src/lib/input/input.test.ts +14 -16
  10. package/src/lib/input-mask/input-mask.element.ts +13 -13
  11. package/src/lib/input-mask/input-mask.stories.ts +7 -12
  12. package/src/lib/input-mask/input-mask.test.ts +45 -50
  13. package/src/lib/services/icon.service.test.ts +14 -14
  14. package/src/lib/services/icon.service.ts +18 -17
  15. package/src/lib/textarea/textarea.element.ts +14 -18
  16. package/target/lib/accordion/accordion.element.d.ts +4 -3
  17. package/target/lib/accordion/accordion.element.js +20 -12
  18. package/target/lib/accordion/accordion.element.js.map +1 -1
  19. package/target/lib/alert/alert.element.d.ts +4 -4
  20. package/target/lib/alert/alert.element.js +20 -12
  21. package/target/lib/alert/alert.element.js.map +1 -1
  22. package/target/lib/alert/alert.stories.d.ts +2 -2
  23. package/target/lib/alert/alert.stories.js +3 -3
  24. package/target/lib/alert/alert.stories.js.map +1 -1
  25. package/target/lib/file-input/file-input-preview/file-input-preview.element.d.ts +2 -2
  26. package/target/lib/file-input/file-input-preview/file-input-preview.element.js +8 -8
  27. package/target/lib/file-input/file-input-preview/file-input-preview.element.js.map +1 -1
  28. package/target/lib/file-input/file-input.element.d.ts +2 -3
  29. package/target/lib/file-input/file-input.element.js +23 -31
  30. package/target/lib/file-input/file-input.element.js.map +1 -1
  31. package/target/lib/icon/icon.element.d.ts +4 -4
  32. package/target/lib/icon/icon.element.js +35 -25
  33. package/target/lib/icon/icon.element.js.map +1 -1
  34. package/target/lib/input/input.element.d.ts +5 -5
  35. package/target/lib/input/input.element.js +20 -22
  36. package/target/lib/input/input.element.js.map +1 -1
  37. package/target/lib/input/input.test.d.ts +1 -1
  38. package/target/lib/input/input.test.js +13 -13
  39. package/target/lib/input/input.test.js.map +1 -1
  40. package/target/lib/input-mask/input-mask.element.d.ts +1 -1
  41. package/target/lib/input-mask/input-mask.element.js +11 -11
  42. package/target/lib/input-mask/input-mask.element.js.map +1 -1
  43. package/target/lib/input-mask/input-mask.stories.d.ts +2 -2
  44. package/target/lib/input-mask/input-mask.stories.js +5 -5
  45. package/target/lib/input-mask/input-mask.stories.js.map +1 -1
  46. package/target/lib/input-mask/input-mask.test.d.ts +2 -2
  47. package/target/lib/input-mask/input-mask.test.js +43 -43
  48. package/target/lib/input-mask/input-mask.test.js.map +1 -1
  49. package/target/lib/services/icon.service.d.ts +2 -1
  50. package/target/lib/services/icon.service.js +15 -15
  51. package/target/lib/services/icon.service.js.map +1 -1
  52. package/target/lib/services/icon.service.test.js +14 -14
  53. package/target/lib/services/icon.service.test.js.map +1 -1
  54. package/target/lib/textarea/textarea.element.d.ts +1 -1
  55. package/target/lib/textarea/textarea.element.js +10 -10
  56. package/target/lib/textarea/textarea.element.js.map +1 -1
package/package.json CHANGED
@@ -1,15 +1,21 @@
1
1
  {
2
2
  "name": "@noctuatech/uswds",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "type": "module",
5
- "workspaces": ["packages/**"],
5
+ "workspaces": [
6
+ "packages/**"
7
+ ],
6
8
  "main": "./target/lib.js",
7
9
  "module": "./target/lib.js",
8
10
  "exports": {
9
11
  ".": "./target/lib.js",
10
12
  "./*": "./target/lib/*"
11
13
  },
12
- "files": ["src", "target", "assets"],
14
+ "files": [
15
+ "src",
16
+ "target",
17
+ "assets"
18
+ ],
13
19
  "scripts": {
14
20
  "test": "wireit",
15
21
  "build": "wireit",
@@ -22,14 +28,23 @@
22
28
  "wireit": {
23
29
  "prepare": {
24
30
  "command": "husky",
25
- "dependencies": ["copy_icons"]
31
+ "dependencies": [
32
+ "copy_icons"
33
+ ]
26
34
  },
27
35
  "test": {
28
36
  "command": "wtr",
29
- "dependencies": ["tsc", "build_testing_library"]
37
+ "dependencies": [
38
+ "tsc",
39
+ "build_testing_library"
40
+ ]
30
41
  },
31
42
  "build": {
32
- "dependencies": ["tsc", "build_storybook", "minify_html_literals"]
43
+ "dependencies": [
44
+ "tsc",
45
+ "build_storybook",
46
+ "minify_html_literals"
47
+ ]
33
48
  },
34
49
  "preview": {
35
50
  "command": "eleventy --serve --incremental",
@@ -46,39 +61,56 @@
46
61
  },
47
62
  "build_testing_library": {
48
63
  "command": "./scripts/build_testing_library.sh",
49
- "files": ["node_modules/@testing-library/**"],
50
- "output": ["testing-library/**"]
64
+ "files": [
65
+ "node_modules/@testing-library/**"
66
+ ],
67
+ "output": [
68
+ "testing-library/**"
69
+ ]
51
70
  },
52
71
  "tsc": {
53
72
  "command": "tsc --build --pretty",
54
73
  "clean": "if-file-deleted",
55
- "files": ["src/**", "tsconfig.json"],
56
- "output": ["target/**", "tsconfig.tsbuildinfo"]
74
+ "files": [
75
+ "src/**",
76
+ "tsconfig.json"
77
+ ],
78
+ "output": [
79
+ "target/**",
80
+ "tsconfig.tsbuildinfo"
81
+ ]
57
82
  },
58
83
  "copy_icons": {
59
84
  "command": "./scripts/copy_usa_icons.sh",
60
- "files": ["node_modules/@uswds/uswds/dist/img/usa-icons/**"],
61
- "output": ["assets/usa-icon/**"]
85
+ "files": [
86
+ "node_modules/@uswds/uswds/dist/img/usa-icons/**"
87
+ ],
88
+ "output": [
89
+ "assets/usa-icon/**"
90
+ ]
62
91
  },
63
92
  "minify_html_literals": {
64
93
  "command": "./scripts/minify_html_literals.js",
65
- "files": ["target/**/*.js"],
66
- "dependencies": ["tsc"]
94
+ "files": [
95
+ "target/**/*.js"
96
+ ],
97
+ "dependencies": [
98
+ "tsc"
99
+ ]
67
100
  }
68
101
  },
69
102
  "author": "",
70
103
  "license": "ISC",
71
104
  "description": "",
72
105
  "dependencies": {
73
- "@joist/di": "^4.2.3-next.14",
74
- "@joist/element": "^4.2.3-next.14",
75
- "@joist/observable": "^4.2.3-next.14",
76
- "@joist/templating": "^4.2.3-next.14",
106
+ "@joist/di": "^4.2.3",
107
+ "@joist/element": "^4.2.3",
108
+ "@joist/observable": "^4.2.3",
109
+ "@joist/templating": "^4.2.3",
77
110
  "tslib": "2.8.1"
78
111
  },
79
112
  "devDependencies": {
80
113
  "@11ty/eleventy": "^3.0.0",
81
- "@biomejs/biome": "1.9.4",
82
114
  "@open-wc/testing": "^4.0.0",
83
115
  "@storybook/addon-essentials": "^8.6.0",
84
116
  "@storybook/web-components": "^8.6.0",
@@ -92,16 +124,19 @@
92
124
  "@web/test-runner": "^0.20.0",
93
125
  "husky": "^9.0.11",
94
126
  "js-beautify": "^1.15.1",
95
- "lint-staged": "^15.2.2",
127
+ "lint-staged": "^16.0.0",
96
128
  "lit": "^3.2.1",
97
129
  "minify-literals": "^1.0.10",
98
130
  "mocha": "^11.0.0",
99
131
  "plop": "^4.0.1",
132
+ "prettier": "^3.5.3",
100
133
  "storybook": "^8.6.0",
101
134
  "typescript": "^5.8.0",
102
135
  "wireit": "^0.14.9"
103
136
  },
104
137
  "lint-staged": {
105
- "*": ["biome check --write --no-errors-on-unmatched"]
138
+ "*": [
139
+ "prettier --write --ignore-unknown"
140
+ ]
106
141
  }
107
142
  }
@@ -1,20 +1,20 @@
1
- import "@joist/templating/define.js";
1
+ import '@joist/templating/define.js';
2
2
 
3
- import { attr, css, element, html, listen } from "@joist/element";
4
- import { bind } from "@joist/templating";
3
+ import { attr, css, element, html, listen } from '@joist/element';
4
+ import { bind } from '@joist/templating';
5
5
 
6
- import { USAAccordionToggleEvent } from "./events.js";
6
+ import { USAAccordionToggleEvent } from './events.js';
7
7
 
8
8
  declare global {
9
9
  interface HTMLElementTagNameMap {
10
- "usa-accordion": USAAccordionElement;
10
+ 'usa-accordion': USAAccordionElement;
11
11
  }
12
12
  }
13
13
 
14
14
  @element({
15
- tagName: "usa-accordion",
15
+ tagName: 'usa-accordion',
16
16
  shadowDomOpts: {
17
- mode: "open",
17
+ mode: 'open',
18
18
  delegatesFocus: true,
19
19
  },
20
20
  shadowDom: [
@@ -54,12 +54,12 @@ declare global {
54
54
  display: none;
55
55
  }
56
56
 
57
- slot[name="heading"] {
57
+ slot[name='heading'] {
58
58
  display: block;
59
59
  flex: 1 1 auto;
60
60
  }
61
61
 
62
- slot[name="heading"]::slotted(*) {
62
+ slot[name='heading']::slotted(*) {
63
63
  margin: 0;
64
64
  }
65
65
 
@@ -69,18 +69,6 @@ declare global {
69
69
  padding-top: 1.5rem;
70
70
  }
71
71
 
72
- usa-icon[icon="remove"] {
73
- display: none;
74
- }
75
-
76
- details[open] usa-icon[icon="add"] {
77
- display: none;
78
- }
79
-
80
- details[open] usa-icon[icon="remove"] {
81
- display: block;
82
- }
83
-
84
72
  summary:hover {
85
73
  background-color: #e6e6e6;
86
74
  }
@@ -96,8 +84,9 @@ declare global {
96
84
  <summary>
97
85
  <slot name="heading"></slot>
98
86
 
99
- <usa-icon icon="add"></usa-icon>
100
- <usa-icon icon="remove"></usa-icon>
87
+ <j-props>
88
+ <usa-icon $.icon="icon"></usa-icon>
89
+ </j-props>
101
90
  </summary>
102
91
 
103
92
  <div class="content">
@@ -110,20 +99,23 @@ declare global {
110
99
  })
111
100
  export class USAAccordionElement extends HTMLElement {
112
101
  @attr()
113
- accessor name = "";
102
+ accessor name = '';
114
103
 
115
104
  @attr()
116
105
  @bind()
117
106
  accessor open = false;
118
107
 
119
- @listen("click", "summary")
108
+ @bind((i) => (i.open ? 'remove' : 'add'))
109
+ accessor icon: 'add' | 'remove' = 'add';
110
+
111
+ @listen('click', 'summary')
120
112
  onClick(e: Event) {
121
113
  e.preventDefault();
122
114
 
123
115
  this.dispatchEvent(new USAAccordionToggleEvent(!this.open));
124
116
  }
125
117
 
126
- @listen("usa::accordion::toggle", () => document.body)
118
+ @listen('usa::accordion::toggle', () => document.body)
127
119
  onAccordionToggle(e: USAAccordionToggleEvent) {
128
120
  if (e.target.name === this.name) {
129
121
  this.open = e.target === this && e.open;
@@ -1,17 +1,20 @@
1
- import { attr, css, element, html, query } from "@joist/element";
1
+ import { attr, css, element, html, query } from '@joist/element';
2
2
 
3
- import { type USAAlertType, USA_ALERT_CONFIG } from "./alert-types.js";
3
+ import { type USAAlertType, USA_ALERT_CONFIG } from './alert-types.js';
4
+ import { bind } from '@joist/templating';
5
+ import { USAIcon } from '../icon/icon-types.js';
6
+ import { observe } from '@joist/observable';
4
7
 
5
8
  declare global {
6
9
  interface HTMLElementTagNameMap {
7
- "usa-alert": USAAlertElement;
10
+ 'usa-alert': USAAlertElement;
8
11
  }
9
12
  }
10
13
 
11
14
  @element({
12
- tagName: "usa-alert",
15
+ tagName: 'usa-alert',
13
16
  shadowDomOpts: {
14
- mode: "open",
17
+ mode: 'open',
15
18
  delegatesFocus: true,
16
19
  },
17
20
  shadowDom: [
@@ -24,33 +27,33 @@ declare global {
24
27
  margin-bottom: 1rem;
25
28
  }
26
29
 
27
- :host([type="info"]) {
30
+ :host([type='info']) {
28
31
  border-left-color: #00bde3;
29
32
  background-color: #e7f6f8;
30
33
  }
31
34
 
32
- :host([type="warning"]) {
35
+ :host([type='warning']) {
33
36
  background-color: #faf3d1;
34
37
  border-left-color: #ffbe2e;
35
38
  }
36
39
 
37
- :host([type="success"]) {
40
+ :host([type='success']) {
38
41
  background-color: #ecf3ec;
39
42
  border-left-color: #00a91c;
40
43
  }
41
44
 
42
- :host([type="error"]) {
45
+ :host([type='error']) {
43
46
  background-color: #f4e3db;
44
47
  border-left-color: #d54309;
45
48
  }
46
49
 
47
- :host([type="emergency"]) {
50
+ :host([type='emergency']) {
48
51
  background-color: #9c3d10;
49
52
  border-left-color: #9c3d10;
50
53
  color: #fff;
51
54
  }
52
55
 
53
- :host([type="emergency"]) ::slotted(*) {
56
+ :host([type='emergency']) ::slotted(*) {
54
57
  color: #fff;
55
58
  }
56
59
 
@@ -73,7 +76,9 @@ declare global {
73
76
  `,
74
77
  html`
75
78
  <div class="alert-heading">
76
- <usa-icon icon="check_circle"></usa-icon>
79
+ <j-props>
80
+ <usa-icon $.icon="icon"></usa-icon>
81
+ </j-props>
77
82
 
78
83
  <div>
79
84
  <slot id="heading" name="heading"></slot>
@@ -90,13 +95,9 @@ declare global {
90
95
  })
91
96
  export class USAAlertElement extends HTMLElement {
92
97
  @attr()
93
- accessor type: USAAlertType = "info";
98
+ @observe()
99
+ accessor type: USAAlertType = 'info';
94
100
 
95
- #icon = query("usa-icon");
96
-
97
- attributeChangedCallback() {
98
- this.#icon({
99
- icon: USA_ALERT_CONFIG[this.type].icon,
100
- });
101
- }
101
+ @bind((i) => USA_ALERT_CONFIG[i.type].icon)
102
+ accessor icon: USAIcon = 'info';
102
103
  }
@@ -1,12 +1,12 @@
1
- import type { Meta, StoryObj } from "@storybook/web-components";
2
- import { html } from "lit";
1
+ import type { Meta, StoryObj } from '@storybook/web-components';
2
+ import { html } from 'lit';
3
3
 
4
- import type { USAAlertElement } from "./alert.element.js";
4
+ import type { USAAlertElement } from './alert.element.js';
5
5
 
6
6
  // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
7
  const meta = {
8
- title: "usa-alert",
9
- tags: ["autodocs"],
8
+ title: 'usa-alert',
9
+ tags: ['autodocs'],
10
10
  argTypes: {},
11
11
  args: {},
12
12
  } satisfies Meta<USAAlertElement>;
@@ -22,8 +22,7 @@ export const Info: Story = {
22
22
  <h3 slot="heading">Informative status</h3>
23
23
 
24
24
  Lorem ipsum dolor sit amet,&nbsp;
25
- <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do
26
- eiusmod.
25
+ <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do eiusmod.
27
26
  </usa-alert>
28
27
  `;
29
28
  },
@@ -36,8 +35,7 @@ export const Warning: Story = {
36
35
  <h3 slot="heading">Warning status</h3>
37
36
 
38
37
  Lorem ipsum dolor sit amet,&nbsp;
39
- <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do
40
- eiusmod.
38
+ <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do eiusmod.
41
39
  </usa-alert>
42
40
  `;
43
41
  },
@@ -50,8 +48,7 @@ export const Success: Story = {
50
48
  <h3 slot="heading">Success status</h3>
51
49
 
52
50
  Lorem ipsum dolor sit amet,&nbsp;
53
- <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do
54
- eiusmod.
51
+ <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do eiusmod.
55
52
  </usa-alert>
56
53
  `;
57
54
  },
@@ -65,8 +62,7 @@ export const Error: Story = {
65
62
  <h3 slot="heading">Error status</h3>
66
63
 
67
64
  Lorem ipsum dolor sit amet,&nbsp;
68
- <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do
69
- eiusmod.
65
+ <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do eiusmod.
70
66
  </usa-alert>
71
67
  `;
72
68
  },
@@ -79,8 +75,7 @@ export const Emergency: Story = {
79
75
  <h3 slot="heading">Emergency status</h3>
80
76
 
81
77
  Lorem ipsum dolor sit amet,&nbsp;
82
- <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do
83
- eiusmod.
78
+ <usa-link href="#">consectetur adipiscing</usa-link>&nbsp;elit, sed do eiusmod.
84
79
  </usa-alert>
85
80
  `;
86
81
  },
@@ -1,17 +1,17 @@
1
- import "@joist/templating/define.js";
1
+ import '@joist/templating/define.js';
2
2
 
3
- import { css, element, html } from "@joist/element";
4
- import { observe } from "@joist/observable";
5
- import { bind } from "@joist/templating";
3
+ import { css, element, html } from '@joist/element';
4
+ import { observe } from '@joist/observable';
5
+ import { bind } from '@joist/templating';
6
6
 
7
7
  declare global {
8
8
  interface HTMLElementTagNameMap {
9
- "usa-file-input-preview": USAFileInputPreviewElement;
9
+ 'usa-file-input-preview': USAFileInputPreviewElement;
10
10
  }
11
11
  }
12
12
 
13
13
  @element({
14
- tagName: "usa-file-input-preview",
14
+ tagName: 'usa-file-input-preview',
15
15
  shadowDom: [
16
16
  css`
17
17
  * {
@@ -26,7 +26,7 @@ declare global {
26
26
  text-align: left;
27
27
  word-wrap: anywhere;
28
28
  z-index: 3;
29
- border-radius: var(--usa-input-radius);
29
+ border-radius: 0;
30
30
  overflow: hidden;
31
31
  }
32
32
 
@@ -45,8 +45,8 @@ declare global {
45
45
  }
46
46
 
47
47
  .preview-heading {
48
+ background: #d9e8f6;
48
49
  align-items: center;
49
- background: var(--usa-input-bg-color);
50
50
  display: flex;
51
51
  pointer-events: none;
52
52
  position: relative;
@@ -55,23 +55,26 @@ declare global {
55
55
  justify-content: space-between;
56
56
  padding: 0.5rem;
57
57
  text-align: left;
58
+ font-size: 0.93rem;
59
+ line-height: 1.6;
58
60
  }
59
61
 
60
62
  .preview-item {
63
+ background: #d9e8f6;
61
64
  align-items: center;
62
- background: var(--usa-input-bg-color);
63
65
  display: flex;
64
66
  padding: 0.5rem;
65
67
  width: 100%;
66
68
  margin-top: 1px;
69
+ margin-bottom: 1px;
67
70
  }
68
71
  `,
69
72
  html`
70
- <slot class="preview-heading"></slot>
71
-
73
+ <slot class="preview-heading" part="heading"></slot>
74
+
72
75
  <j-for bind="fileEntries" key="src">
73
76
  <template>
74
- <div class="preview-item">
77
+ <div class="preview-item" part="item">
75
78
  <j-if bind="each.value.isImage">
76
79
  <template>
77
80
  <j-props>
@@ -83,7 +86,7 @@ declare global {
83
86
  <usa-icon icon="file_present"></usa-icon>
84
87
  </template>
85
88
  </j-if>
86
-
89
+
87
90
  <j-value bind="each.value.file.name"></j-value>
88
91
  </div>
89
92
  </template>
@@ -103,7 +106,7 @@ export class USAFileInputPreviewElement extends HTMLElement {
103
106
  return Array.from(i.files).map((file) => ({
104
107
  file,
105
108
  src: URL.createObjectURL(file),
106
- isImage: file.type.startsWith("image"),
109
+ isImage: file.type.startsWith('image'),
107
110
  }));
108
111
  })
109
112
  accessor fileEntries: FileEntry[] = [];