@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.
- package/package.json +56 -21
- package/src/lib/accordion/accordion.element.ts +18 -26
- package/src/lib/alert/alert.element.ts +21 -20
- package/src/lib/alert/alert.stories.ts +10 -15
- package/src/lib/file-input/file-input-preview/file-input-preview.element.ts +17 -14
- package/src/lib/file-input/file-input.element.ts +56 -61
- package/src/lib/icon/icon.element.ts +37 -27
- package/src/lib/input/input.element.ts +30 -39
- package/src/lib/input/input.test.ts +14 -16
- package/src/lib/input-mask/input-mask.element.ts +13 -13
- package/src/lib/input-mask/input-mask.stories.ts +7 -12
- package/src/lib/input-mask/input-mask.test.ts +45 -50
- package/src/lib/services/icon.service.test.ts +14 -14
- package/src/lib/services/icon.service.ts +18 -17
- package/src/lib/textarea/textarea.element.ts +14 -18
- package/target/lib/accordion/accordion.element.d.ts +4 -3
- package/target/lib/accordion/accordion.element.js +20 -12
- package/target/lib/accordion/accordion.element.js.map +1 -1
- package/target/lib/alert/alert.element.d.ts +4 -4
- package/target/lib/alert/alert.element.js +20 -12
- package/target/lib/alert/alert.element.js.map +1 -1
- package/target/lib/alert/alert.stories.d.ts +2 -2
- package/target/lib/alert/alert.stories.js +3 -3
- package/target/lib/alert/alert.stories.js.map +1 -1
- package/target/lib/file-input/file-input-preview/file-input-preview.element.d.ts +2 -2
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js +8 -8
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js.map +1 -1
- package/target/lib/file-input/file-input.element.d.ts +2 -3
- package/target/lib/file-input/file-input.element.js +23 -31
- package/target/lib/file-input/file-input.element.js.map +1 -1
- package/target/lib/icon/icon.element.d.ts +4 -4
- package/target/lib/icon/icon.element.js +35 -25
- package/target/lib/icon/icon.element.js.map +1 -1
- package/target/lib/input/input.element.d.ts +5 -5
- package/target/lib/input/input.element.js +20 -22
- package/target/lib/input/input.element.js.map +1 -1
- package/target/lib/input/input.test.d.ts +1 -1
- package/target/lib/input/input.test.js +13 -13
- package/target/lib/input/input.test.js.map +1 -1
- package/target/lib/input-mask/input-mask.element.d.ts +1 -1
- package/target/lib/input-mask/input-mask.element.js +11 -11
- package/target/lib/input-mask/input-mask.element.js.map +1 -1
- package/target/lib/input-mask/input-mask.stories.d.ts +2 -2
- package/target/lib/input-mask/input-mask.stories.js +5 -5
- package/target/lib/input-mask/input-mask.stories.js.map +1 -1
- package/target/lib/input-mask/input-mask.test.d.ts +2 -2
- package/target/lib/input-mask/input-mask.test.js +43 -43
- package/target/lib/input-mask/input-mask.test.js.map +1 -1
- package/target/lib/services/icon.service.d.ts +2 -1
- package/target/lib/services/icon.service.js +15 -15
- package/target/lib/services/icon.service.js.map +1 -1
- package/target/lib/services/icon.service.test.js +14 -14
- package/target/lib/services/icon.service.test.js.map +1 -1
- package/target/lib/textarea/textarea.element.d.ts +1 -1
- package/target/lib/textarea/textarea.element.js +10 -10
- package/target/lib/textarea/textarea.element.js.map +1 -1
|
@@ -1,110 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import './input-mask.element.js';
|
|
2
|
+
import '../input/input.element.js';
|
|
3
3
|
|
|
4
|
-
import { assert, fixture, html } from
|
|
4
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
5
5
|
|
|
6
|
-
import { format } from
|
|
7
|
-
import type { USAInputMaskElement } from
|
|
6
|
+
import { format } from './format.js';
|
|
7
|
+
import type { USAInputMaskElement } from './input-mask.element.js';
|
|
8
8
|
|
|
9
|
-
describe(
|
|
10
|
-
it(
|
|
11
|
-
assert.deepEqual(format(
|
|
12
|
-
raw:
|
|
13
|
-
formatted:
|
|
9
|
+
describe('format', () => {
|
|
10
|
+
it('should retrn the correct raw value', () => {
|
|
11
|
+
assert.deepEqual(format('(123) 456 7890', '(***) ***-****'), {
|
|
12
|
+
raw: '1234567890',
|
|
13
|
+
formatted: '(123) 456-7890',
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
it(
|
|
18
|
-
assert.deepEqual(format(
|
|
19
|
-
raw:
|
|
20
|
-
formatted:
|
|
17
|
+
it('should return a formatted phone number (***) ***-****', () => {
|
|
18
|
+
assert.deepEqual(format('1234567890', '(***) ***-****'), {
|
|
19
|
+
raw: '1234567890',
|
|
20
|
+
formatted: '(123) 456-7890',
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it(
|
|
25
|
-
assert.deepEqual(format(
|
|
26
|
-
raw:
|
|
27
|
-
formatted:
|
|
24
|
+
it('should return a formatted phone number ***-***-****', () => {
|
|
25
|
+
assert.deepEqual(format('1234567890', '***-***-****'), {
|
|
26
|
+
raw: '1234567890',
|
|
27
|
+
formatted: '123-456-7890',
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
it(
|
|
32
|
-
assert.deepEqual(format(
|
|
33
|
-
raw:
|
|
34
|
-
formatted:
|
|
31
|
+
it('should only allow numbers', () => {
|
|
32
|
+
assert.deepEqual(format('304213abcd', '999-999-9999'), {
|
|
33
|
+
raw: '304213abcd',
|
|
34
|
+
formatted: '304-213-',
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it(
|
|
39
|
-
assert.deepEqual(format(
|
|
40
|
-
raw:
|
|
41
|
-
formatted:
|
|
38
|
+
it('should only allow a mix of letters and numbers', () => {
|
|
39
|
+
assert.deepEqual(format('C94749', 'A-99999'), {
|
|
40
|
+
raw: 'C94749',
|
|
41
|
+
formatted: 'C-94749',
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
describe(
|
|
47
|
-
it(
|
|
46
|
+
describe('usa-input-mask', () => {
|
|
47
|
+
it('should format default value', async () => {
|
|
48
48
|
const el = await fixture<USAInputMaskElement>(html`
|
|
49
49
|
<usa-input-mask mask="(999) 999-9999">
|
|
50
50
|
<input name="phone" value="1234567890" mask />
|
|
51
51
|
</usa-input-mask>
|
|
52
52
|
`);
|
|
53
53
|
|
|
54
|
-
const input = el.querySelector(
|
|
54
|
+
const input = el.querySelector('input');
|
|
55
55
|
|
|
56
|
-
assert.equal(input?.value,
|
|
56
|
+
assert.equal(input?.value, '(123) 456-7890');
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it(
|
|
59
|
+
it('should update value when on input event', async () => {
|
|
60
60
|
const el = await fixture<USAInputMaskElement>(html`
|
|
61
61
|
<usa-input-mask>
|
|
62
62
|
<input name="phone" mask="(999) 999-9999" />
|
|
63
63
|
</usa-input-mask>
|
|
64
64
|
`);
|
|
65
65
|
|
|
66
|
-
const input = el.querySelector(
|
|
66
|
+
const input = el.querySelector('input');
|
|
67
67
|
|
|
68
68
|
if (input) {
|
|
69
|
-
input.value =
|
|
70
|
-
input.dispatchEvent(new Event(
|
|
69
|
+
input.value = '8888888888';
|
|
70
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
71
71
|
}
|
|
72
|
-
|
|
73
|
-
assert.equal(input?.value, "(888) 888-8888");
|
|
72
|
+
assert.equal(input?.value, '(888) 888-8888');
|
|
74
73
|
});
|
|
75
74
|
});
|
|
76
75
|
|
|
77
|
-
describe(
|
|
78
|
-
it(
|
|
76
|
+
describe('usa-input-mask with usa-input', () => {
|
|
77
|
+
it('should format default value', async () => {
|
|
79
78
|
const el = await fixture<USAInputMaskElement>(html`
|
|
80
79
|
<usa-input-mask mask="(999) 999-9999">
|
|
81
80
|
<usa-input name="phone" value="1234567890" id="TEST" mask></usa-input>
|
|
82
81
|
</usa-input-mask>
|
|
83
82
|
`);
|
|
84
83
|
|
|
85
|
-
const input = el.querySelector(
|
|
84
|
+
const input = el.querySelector('usa-input');
|
|
86
85
|
|
|
87
|
-
assert.equal(input?.value,
|
|
86
|
+
assert.equal(input?.value, '(123) 456-7890');
|
|
88
87
|
});
|
|
89
88
|
|
|
90
|
-
it(
|
|
89
|
+
it('should update value when on input event', async () => {
|
|
91
90
|
const el = await fixture<USAInputMaskElement>(html`
|
|
92
91
|
<usa-input-mask>
|
|
93
|
-
<usa-input
|
|
94
|
-
name="phone"
|
|
95
|
-
value="1234567890"
|
|
96
|
-
mask="(999) 999-9999"
|
|
97
|
-
></usa-input>
|
|
92
|
+
<usa-input name="phone" value="1234567890" mask="(999) 999-9999"></usa-input>
|
|
98
93
|
</usa-input-mask>
|
|
99
94
|
`);
|
|
100
95
|
|
|
101
|
-
const input = el.querySelector(
|
|
96
|
+
const input = el.querySelector('usa-input');
|
|
102
97
|
|
|
103
98
|
if (input) {
|
|
104
|
-
input.value =
|
|
105
|
-
input.dispatchEvent(new Event(
|
|
99
|
+
input.value = '8888888888';
|
|
100
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
106
101
|
}
|
|
107
102
|
|
|
108
|
-
assert.equal(input?.value,
|
|
103
|
+
assert.equal(input?.value, '(888) 888-8888');
|
|
109
104
|
});
|
|
110
105
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Injector } from
|
|
2
|
-
import { assert } from
|
|
1
|
+
import { Injector } from '@joist/di';
|
|
2
|
+
import { assert } from '@open-wc/testing';
|
|
3
3
|
|
|
4
|
-
import { HttpService } from
|
|
5
|
-
import { IconService } from
|
|
4
|
+
import { HttpService } from './http.service.js';
|
|
5
|
+
import { IconService } from './icon.service.js';
|
|
6
6
|
|
|
7
|
-
describe(
|
|
8
|
-
it(
|
|
7
|
+
describe('IconService', () => {
|
|
8
|
+
it('should fetch icon if not in cache', async () => {
|
|
9
9
|
let callCount = 0;
|
|
10
10
|
|
|
11
11
|
const app = new Injector({
|
|
@@ -16,7 +16,7 @@ describe("IconService", () => {
|
|
|
16
16
|
use: class extends HttpService {
|
|
17
17
|
async fetch(): Promise<Response> {
|
|
18
18
|
callCount++;
|
|
19
|
-
return new Response(
|
|
19
|
+
return new Response('<svg></svg>');
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
},
|
|
@@ -26,13 +26,13 @@ describe("IconService", () => {
|
|
|
26
26
|
|
|
27
27
|
const icon = app.inject(IconService);
|
|
28
28
|
|
|
29
|
-
const res = await icon.getIcon(
|
|
29
|
+
const res = await icon.getIcon('test' as any);
|
|
30
30
|
|
|
31
|
-
assert.equal(res.nodeName,
|
|
31
|
+
assert.equal(res.nodeName, 'svg');
|
|
32
32
|
assert.equal(callCount, 1);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
it(
|
|
35
|
+
it('should not fetch new icon if the icon is found in the cache', async () => {
|
|
36
36
|
let callCount = 0;
|
|
37
37
|
|
|
38
38
|
const app = new Injector({
|
|
@@ -43,7 +43,7 @@ describe("IconService", () => {
|
|
|
43
43
|
use: class extends HttpService {
|
|
44
44
|
async fetch(): Promise<Response> {
|
|
45
45
|
callCount++;
|
|
46
|
-
return new Response(
|
|
46
|
+
return new Response('<svg></svg>');
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -53,11 +53,11 @@ describe("IconService", () => {
|
|
|
53
53
|
|
|
54
54
|
const icon = app.inject(IconService);
|
|
55
55
|
|
|
56
|
-
await icon.getIcon(
|
|
56
|
+
await icon.getIcon('accessibility_new');
|
|
57
57
|
|
|
58
|
-
const res = await icon.getIcon(
|
|
58
|
+
const res = await icon.getIcon('accessibility_new');
|
|
59
59
|
|
|
60
|
-
assert.equal(res.nodeName,
|
|
60
|
+
assert.equal(res.nodeName, 'svg');
|
|
61
61
|
assert.equal(callCount, 1);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
import { inject, injectable } from
|
|
1
|
+
import { inject, injectable } from '@joist/di';
|
|
2
2
|
|
|
3
|
-
import { USAConfig } from
|
|
4
|
-
import { HttpService } from
|
|
3
|
+
import { USAConfig } from '../config/config.element.js';
|
|
4
|
+
import { HttpService } from './http.service.js';
|
|
5
|
+
import { USAIcon } from '../icon/icon-types.js';
|
|
5
6
|
|
|
6
7
|
@injectable()
|
|
7
8
|
export class IconService {
|
|
8
9
|
#config = inject(USAConfig);
|
|
9
10
|
#http = inject(HttpService);
|
|
10
|
-
#iconCache: Map<
|
|
11
|
+
#iconCache: Map<USAIcon, HTMLTemplateElement> = new Map();
|
|
11
12
|
|
|
12
|
-
async getIcon(icon:
|
|
13
|
+
async getIcon(icon: USAIcon, abortSignal?: AbortSignal): Promise<Node> {
|
|
13
14
|
const config = this.#config();
|
|
14
15
|
const http = this.#http();
|
|
15
16
|
|
|
16
17
|
const cached = this.#iconCache.get(icon);
|
|
17
18
|
|
|
18
19
|
if (cached) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
20
|
+
if (!cached.content.firstElementChild) {
|
|
21
|
+
throw Error('cached value is not valid');
|
|
22
|
+
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
});
|
|
24
|
+
return cached.content.firstElementChild.cloneNode(true);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
const svg = http
|
|
29
|
-
.fetch(`${config.iconPath}${icon}.svg
|
|
28
|
+
.fetch(`${config.iconPath}${icon}.svg`, {
|
|
29
|
+
signal: abortSignal,
|
|
30
|
+
})
|
|
30
31
|
.then((res) => {
|
|
31
32
|
switch (res.status) {
|
|
32
33
|
case 200:
|
|
33
34
|
return res.text();
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
return
|
|
37
|
+
return '';
|
|
37
38
|
})
|
|
38
39
|
.then((res) => {
|
|
39
|
-
const template = document.createElement(
|
|
40
|
+
const template = document.createElement('template');
|
|
40
41
|
template.innerHTML = res;
|
|
41
42
|
|
|
43
|
+
this.#iconCache.set(icon, template);
|
|
44
|
+
|
|
42
45
|
return template;
|
|
43
46
|
});
|
|
44
47
|
|
|
45
|
-
this.#iconCache.set(icon, svg);
|
|
46
|
-
|
|
47
48
|
return svg.then((res) => {
|
|
48
49
|
if (!res.content.firstElementChild) {
|
|
49
|
-
throw Error(
|
|
50
|
+
throw Error('ICON is not valid');
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
return res.content.firstElementChild.cloneNode(true);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { attr, css, element, html, listen, query, ready } from
|
|
2
|
-
import { effect, observe } from
|
|
1
|
+
import { attr, css, element, html, listen, query, ready } from '@joist/element';
|
|
2
|
+
import { effect, observe } from '@joist/observable';
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
interface HTMLElementTagNameMap {
|
|
6
|
-
|
|
6
|
+
'usa-textarea': USATextareaElement;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
@element({
|
|
11
|
-
tagName:
|
|
11
|
+
tagName: 'usa-textarea',
|
|
12
12
|
shadowDom: [
|
|
13
13
|
css`
|
|
14
14
|
* {
|
|
@@ -34,7 +34,7 @@ declare global {
|
|
|
34
34
|
border-radius: 0;
|
|
35
35
|
color: #1b1b1b;
|
|
36
36
|
display: block;
|
|
37
|
-
padding: .5rem;
|
|
37
|
+
padding: 0.5rem;
|
|
38
38
|
border-width: 1px;
|
|
39
39
|
border-color: #5c5c5c;
|
|
40
40
|
border-style: solid;
|
|
@@ -62,7 +62,7 @@ declare global {
|
|
|
62
62
|
<label for="textarea" part="label">
|
|
63
63
|
<slot></slot>
|
|
64
64
|
</label>
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
<textarea id="textarea" part="textarea"></textarea>
|
|
67
67
|
`,
|
|
68
68
|
],
|
|
@@ -71,13 +71,13 @@ export class USATextareaElement extends HTMLElement {
|
|
|
71
71
|
static formAssociated = true;
|
|
72
72
|
|
|
73
73
|
@attr()
|
|
74
|
-
accessor name =
|
|
74
|
+
accessor name = '';
|
|
75
75
|
|
|
76
76
|
@attr()
|
|
77
|
-
accessor autocomplete: AutoFill =
|
|
77
|
+
accessor autocomplete: AutoFill = 'on';
|
|
78
78
|
|
|
79
79
|
@attr()
|
|
80
|
-
accessor placeholder =
|
|
80
|
+
accessor placeholder = '';
|
|
81
81
|
|
|
82
82
|
@attr()
|
|
83
83
|
accessor required = false;
|
|
@@ -86,10 +86,10 @@ export class USATextareaElement extends HTMLElement {
|
|
|
86
86
|
reflect: false,
|
|
87
87
|
})
|
|
88
88
|
@observe()
|
|
89
|
-
accessor value =
|
|
89
|
+
accessor value = '';
|
|
90
90
|
|
|
91
91
|
#internals = this.attachInternals();
|
|
92
|
-
#input = query(
|
|
92
|
+
#input = query('textarea');
|
|
93
93
|
|
|
94
94
|
@ready()
|
|
95
95
|
onReady() {
|
|
@@ -116,7 +116,7 @@ export class USATextareaElement extends HTMLElement {
|
|
|
116
116
|
this.#syncFormState();
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
@listen(
|
|
119
|
+
@listen('input')
|
|
120
120
|
onInputChange() {
|
|
121
121
|
this.value = this.#input().value;
|
|
122
122
|
}
|
|
@@ -124,15 +124,11 @@ export class USATextareaElement extends HTMLElement {
|
|
|
124
124
|
#syncFormState() {
|
|
125
125
|
const input = this.#input();
|
|
126
126
|
|
|
127
|
-
this.#internals.setFormValue(
|
|
127
|
+
this.#internals.setFormValue(this.value);
|
|
128
128
|
this.#internals.setValidity({});
|
|
129
129
|
|
|
130
130
|
if (input.validationMessage) {
|
|
131
|
-
this.#internals.setValidity(
|
|
132
|
-
{ customError: true },
|
|
133
|
-
input.validationMessage,
|
|
134
|
-
input,
|
|
135
|
-
);
|
|
131
|
+
this.#internals.setValidity({ customError: true }, input.validationMessage, input);
|
|
136
132
|
}
|
|
137
133
|
}
|
|
138
134
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { USAAccordionToggleEvent } from
|
|
1
|
+
import '@joist/templating/define.js';
|
|
2
|
+
import { USAAccordionToggleEvent } from './events.js';
|
|
3
3
|
declare global {
|
|
4
4
|
interface HTMLElementTagNameMap {
|
|
5
|
-
|
|
5
|
+
'usa-accordion': USAAccordionElement;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
export declare class USAAccordionElement extends HTMLElement {
|
|
9
9
|
accessor name: string;
|
|
10
10
|
accessor open: boolean;
|
|
11
|
+
accessor icon: 'add' | 'remove';
|
|
11
12
|
onClick(e: Event): void;
|
|
12
13
|
onAccordionToggle(e: USAAccordionToggleEvent): void;
|
|
13
14
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import
|
|
3
|
-
import { attr, css, element, html, listen } from
|
|
4
|
-
import { bind } from
|
|
5
|
-
import { USAAccordionToggleEvent } from
|
|
2
|
+
import '@joist/templating/define.js';
|
|
3
|
+
import { attr, css, element, html, listen } from '@joist/element';
|
|
4
|
+
import { bind } from '@joist/templating';
|
|
5
|
+
import { USAAccordionToggleEvent } from './events.js';
|
|
6
6
|
let USAAccordionElement = (() => {
|
|
7
7
|
let _classDecorators = [element({
|
|
8
|
-
tagName:
|
|
8
|
+
tagName: 'usa-accordion',
|
|
9
9
|
shadowDomOpts: {
|
|
10
|
-
mode:
|
|
10
|
+
mode: 'open',
|
|
11
11
|
delegatesFocus: true,
|
|
12
12
|
},
|
|
13
13
|
shadowDom: [
|
|
14
|
-
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}
|
|
15
|
-
html `<j-props><details $.open="open"><summary><slot name="heading"></slot><
|
|
14
|
+
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}summary:hover{background-color:#e6e6e6}summary:focus{outline:.25rem solid #2491ff;outline-offset:0}`,
|
|
15
|
+
html `<j-props><details $.open="open"><summary><slot name="heading"></slot><j-props><usa-icon $.icon="icon"></usa-icon></j-props></summary><div class="content"><slot></slot></div></details></j-props>`,
|
|
16
16
|
],
|
|
17
17
|
})];
|
|
18
18
|
let _classDescriptor;
|
|
@@ -26,6 +26,9 @@ let USAAccordionElement = (() => {
|
|
|
26
26
|
let _open_decorators;
|
|
27
27
|
let _open_initializers = [];
|
|
28
28
|
let _open_extraInitializers = [];
|
|
29
|
+
let _icon_decorators;
|
|
30
|
+
let _icon_initializers = [];
|
|
31
|
+
let _icon_extraInitializers = [];
|
|
29
32
|
let _onClick_decorators;
|
|
30
33
|
let _onAccordionToggle_decorators;
|
|
31
34
|
var USAAccordionElement = class extends _classSuper {
|
|
@@ -34,10 +37,12 @@ let USAAccordionElement = (() => {
|
|
|
34
37
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
35
38
|
_name_decorators = [attr()];
|
|
36
39
|
_open_decorators = [attr(), bind()];
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
_icon_decorators = [bind((i) => (i.open ? 'remove' : 'add'))];
|
|
41
|
+
_onClick_decorators = [listen('click', 'summary')];
|
|
42
|
+
_onAccordionToggle_decorators = [listen('usa::accordion::toggle', () => document.body)];
|
|
39
43
|
__esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
40
44
|
__esDecorate(this, null, _open_decorators, { kind: "accessor", name: "open", static: false, private: false, access: { has: obj => "open" in obj, get: obj => obj.open, set: (obj, value) => { obj.open = value; } }, metadata: _metadata }, _open_initializers, _open_extraInitializers);
|
|
45
|
+
__esDecorate(this, null, _icon_decorators, { kind: "accessor", name: "icon", static: false, private: false, access: { has: obj => "icon" in obj, get: obj => obj.icon, set: (obj, value) => { obj.icon = value; } }, metadata: _metadata }, _icon_initializers, _icon_extraInitializers);
|
|
41
46
|
__esDecorate(this, null, _onClick_decorators, { kind: "method", name: "onClick", static: false, private: false, access: { has: obj => "onClick" in obj, get: obj => obj.onClick }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
42
47
|
__esDecorate(this, null, _onAccordionToggle_decorators, { kind: "method", name: "onAccordionToggle", static: false, private: false, access: { has: obj => "onAccordionToggle" in obj, get: obj => obj.onAccordionToggle }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
43
48
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
@@ -45,12 +50,15 @@ let USAAccordionElement = (() => {
|
|
|
45
50
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
46
51
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
47
52
|
}
|
|
48
|
-
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers,
|
|
53
|
+
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers, ''));
|
|
49
54
|
get name() { return this.#name_accessor_storage; }
|
|
50
55
|
set name(value) { this.#name_accessor_storage = value; }
|
|
51
56
|
#open_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _open_initializers, false));
|
|
52
57
|
get open() { return this.#open_accessor_storage; }
|
|
53
58
|
set open(value) { this.#open_accessor_storage = value; }
|
|
59
|
+
#icon_accessor_storage = (__runInitializers(this, _open_extraInitializers), __runInitializers(this, _icon_initializers, 'add'));
|
|
60
|
+
get icon() { return this.#icon_accessor_storage; }
|
|
61
|
+
set icon(value) { this.#icon_accessor_storage = value; }
|
|
54
62
|
onClick(e) {
|
|
55
63
|
e.preventDefault();
|
|
56
64
|
this.dispatchEvent(new USAAccordionToggleEvent(!this.open));
|
|
@@ -65,7 +73,7 @@ let USAAccordionElement = (() => {
|
|
|
65
73
|
}
|
|
66
74
|
constructor() {
|
|
67
75
|
super(...arguments);
|
|
68
|
-
__runInitializers(this,
|
|
76
|
+
__runInitializers(this, _icon_extraInitializers);
|
|
69
77
|
}
|
|
70
78
|
};
|
|
71
79
|
return USAAccordionElement = _classThis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.element.js","sourceRoot":"","sources":["../../../src/lib/accordion/accordion.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"accordion.element.js","sourceRoot":"","sources":["../../../src/lib/accordion/accordion.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;IA8FzC,mBAAmB;4BAtF/B,OAAO,CAAC;YACP,OAAO,EAAE,eAAe;YACxB,aAAa,EAAE;gBACb,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,IAAI;aACrB;YACD,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2DF;gBACD,IAAI,CAAA;;;;;;;;;;;;;;;;KAgBH;aACF;SACF,CAAC;;;;sBACuC,WAAW;;;;;;;;;;;;;mCAAnB,SAAQ,WAAW;;;;gCACjD,IAAI,EAAE;gCAGN,IAAI,EAAE,EACN,IAAI,EAAE;gCAGN,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;mCAGxC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;6CAO1B,MAAM,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;YAhBtD,iKAAS,IAAI,6BAAJ,IAAI,mFAAM;YAInB,iKAAS,IAAI,6BAAJ,IAAI,mFAAS;YAGtB,iKAAS,IAAI,6BAAJ,IAAI,mFAA2B;YAGxC,wKAAA,OAAO,6DAIN;YAGD,sMAAA,iBAAiB,6DAMhB;YAzBH,6KA0BC;;;YA1BY,uDAAmB;;QAE9B,0BAFW,mDAAmB,8CAEd,EAAE,GAAC;QAAnB,IAAS,IAAI,0CAAM;QAAnB,IAAS,IAAI,gDAAM;QAInB,wHAAgB,KAAK,GAAC;QAAtB,IAAS,IAAI,0CAAS;QAAtB,IAAS,IAAI,gDAAS;QAGtB,wHAAkC,KAAK,GAAC;QAAxC,IAAS,IAAI,0CAA2B;QAAxC,IAAS,IAAI,gDAA2B;QAGxC,OAAO,CAAC,CAAQ;YACd,CAAC,CAAC,cAAc,EAAE,CAAC;YAEnB,IAAI,CAAC,aAAa,CAAC,IAAI,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,CAAC;QAGD,iBAAiB,CAAC,CAA0B;YAC1C,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,MAAM,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC;YAC1C,CAAC;iBAAM,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;gBAC7B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;YACrB,CAAC;QACH,CAAC;;;;;;;;SAzBU,mBAAmB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type USAAlertType } from
|
|
1
|
+
import { type USAAlertType } from './alert-types.js';
|
|
2
|
+
import { USAIcon } from '../icon/icon-types.js';
|
|
2
3
|
declare global {
|
|
3
4
|
interface HTMLElementTagNameMap {
|
|
4
|
-
|
|
5
|
+
'usa-alert': USAAlertElement;
|
|
5
6
|
}
|
|
6
7
|
}
|
|
7
8
|
export declare class USAAlertElement extends HTMLElement {
|
|
8
|
-
#private;
|
|
9
9
|
accessor type: USAAlertType;
|
|
10
|
-
|
|
10
|
+
accessor icon: USAIcon;
|
|
11
11
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { attr, css, element, html
|
|
3
|
-
import { USA_ALERT_CONFIG } from
|
|
2
|
+
import { attr, css, element, html } from '@joist/element';
|
|
3
|
+
import { USA_ALERT_CONFIG } from './alert-types.js';
|
|
4
|
+
import { bind } from '@joist/templating';
|
|
5
|
+
import { observe } from '@joist/observable';
|
|
4
6
|
let USAAlertElement = (() => {
|
|
5
7
|
let _classDecorators = [element({
|
|
6
|
-
tagName:
|
|
8
|
+
tagName: 'usa-alert',
|
|
7
9
|
shadowDomOpts: {
|
|
8
|
-
mode:
|
|
10
|
+
mode: 'open',
|
|
9
11
|
delegatesFocus: true,
|
|
10
12
|
},
|
|
11
13
|
shadowDom: [
|
|
12
14
|
css `:host{display:block;border-left:.5rem solid #adadad;padding:1rem 1.2rem;color:#1b1b1b;margin-bottom:1rem}:host([type=info]){border-left-color:#00bde3;background-color:#e7f6f8}:host([type=warning]){background-color:#faf3d1;border-left-color:#ffbe2e}:host([type=success]){background-color:#ecf3ec;border-left-color:#00a91c}:host([type=error]){background-color:#f4e3db;border-left-color:#d54309}:host([type=emergency]){background-color:#9c3d10;border-left-color:#9c3d10;color:#fff}:host([type=emergency]) ::slotted(*){color:#fff}.alert-heading{display:grid;grid-template-columns:auto 1fr;align-items:center}usa-icon{margin:-.28rem .75rem 0 0}#heading::slotted(*){font-size:1.33rem;line-height:.9;margin-top:0;margin-bottom:.5rem}`,
|
|
13
|
-
html `<div class="alert-heading"><usa-icon icon="
|
|
15
|
+
html `<div class="alert-heading"><j-props><usa-icon $.icon="icon"></usa-icon></j-props><div><slot id="heading" name="heading"></slot></div><div class="spacer"></div><div><slot></slot></div></div>`,
|
|
14
16
|
],
|
|
15
17
|
})];
|
|
16
18
|
let _classDescriptor;
|
|
@@ -20,25 +22,31 @@ let USAAlertElement = (() => {
|
|
|
20
22
|
let _type_decorators;
|
|
21
23
|
let _type_initializers = [];
|
|
22
24
|
let _type_extraInitializers = [];
|
|
25
|
+
let _icon_decorators;
|
|
26
|
+
let _icon_initializers = [];
|
|
27
|
+
let _icon_extraInitializers = [];
|
|
23
28
|
var USAAlertElement = class extends _classSuper {
|
|
24
29
|
static { _classThis = this; }
|
|
25
30
|
static {
|
|
26
31
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
27
|
-
_type_decorators = [attr()];
|
|
32
|
+
_type_decorators = [attr(), observe()];
|
|
33
|
+
_icon_decorators = [bind((i) => USA_ALERT_CONFIG[i.type].icon)];
|
|
28
34
|
__esDecorate(this, null, _type_decorators, { kind: "accessor", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
35
|
+
__esDecorate(this, null, _icon_decorators, { kind: "accessor", name: "icon", static: false, private: false, access: { has: obj => "icon" in obj, get: obj => obj.icon, set: (obj, value) => { obj.icon = value; } }, metadata: _metadata }, _icon_initializers, _icon_extraInitializers);
|
|
29
36
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
30
37
|
USAAlertElement = _classThis = _classDescriptor.value;
|
|
31
38
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
32
39
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
33
40
|
}
|
|
34
|
-
#type_accessor_storage = __runInitializers(this, _type_initializers,
|
|
41
|
+
#type_accessor_storage = __runInitializers(this, _type_initializers, 'info');
|
|
35
42
|
get type() { return this.#type_accessor_storage; }
|
|
36
43
|
set type(value) { this.#type_accessor_storage = value; }
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
#icon_accessor_storage = (__runInitializers(this, _type_extraInitializers), __runInitializers(this, _icon_initializers, 'info'));
|
|
45
|
+
get icon() { return this.#icon_accessor_storage; }
|
|
46
|
+
set icon(value) { this.#icon_accessor_storage = value; }
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments);
|
|
49
|
+
__runInitializers(this, _icon_extraInitializers);
|
|
42
50
|
}
|
|
43
51
|
};
|
|
44
52
|
return USAAlertElement = _classThis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.element.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"alert.element.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAS,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAqB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;IA0F/B,eAAe;4BAlF3B,OAAO,CAAC;YACP,OAAO,EAAE,WAAW;YACpB,aAAa,EAAE;gBACb,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,IAAI;aACrB;YACD,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuDF;gBACD,IAAI,CAAA;;;;;;;;;;;;;;;;KAgBH;aACF;SACF,CAAC;;;;sBACmC,WAAW;;;;;;;+BAAnB,SAAQ,WAAW;;;;gCAC7C,IAAI,EAAE,EACN,OAAO,EAAE;gCAGT,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;YAF3C,iKAAS,IAAI,6BAAJ,IAAI,mFAAwB;YAGrC,iKAAS,IAAI,6BAAJ,IAAI,mFAAmB;YANlC,6KAOC;;;YAPY,uDAAe;;QAG1B,qEAA8B,MAAM,EAAC;QAArC,IAAS,IAAI,0CAAwB;QAArC,IAAS,IAAI,gDAAwB;QAGrC,wHAAyB,MAAM,GAAC;QAAhC,IAAS,IAAI,0CAAmB;QAAhC,IAAS,IAAI,gDAAmB;;;;;;;;SANrB,eAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StoryObj } from
|
|
2
|
-
import type { USAAlertElement } from
|
|
1
|
+
import type { StoryObj } from '@storybook/web-components';
|
|
2
|
+
import type { USAAlertElement } from './alert.element.js';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
5
|
tags: string[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { html } from
|
|
1
|
+
import { html } from 'lit';
|
|
2
2
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
3
3
|
const meta = {
|
|
4
|
-
title:
|
|
5
|
-
tags: [
|
|
4
|
+
title: 'usa-alert',
|
|
5
|
+
tags: ['autodocs'],
|
|
6
6
|
argTypes: {},
|
|
7
7
|
args: {},
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.stories.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAI3B,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACuB,CAAC;AAElC,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,IAAI,GAAU;IACzB,MAAM;QACJ,OAAO,IAAI,CAAA
|
|
1
|
+
{"version":3,"file":"alert.stories.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAI3B,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACuB,CAAC;AAElC,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,IAAI,GAAU;IACzB,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;KAOV,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;KAOV,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;KAOV,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,sEAAsE;AACtE,MAAM,CAAC,MAAM,KAAK,GAAU;IAC1B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;KAOV,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAU;IAC9B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;KAOV,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@joist/templating/define.js';
|
|
2
2
|
declare global {
|
|
3
3
|
interface HTMLElementTagNameMap {
|
|
4
|
-
|
|
4
|
+
'usa-file-input-preview': USAFileInputPreviewElement;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export declare class USAFileInputPreviewElement extends HTMLElement {
|