@noctuatech/uswds 0.1.3 → 0.2.0
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/README.md +48 -0
- package/package.json +7 -7
- package/src/lib/button/button.element.ts +11 -3
- package/src/lib/collection/collection.stories.ts +2 -2
- package/src/lib/combo-box/combo-box-option/combo-box-option.element.ts +2 -4
- package/src/lib/combo-box/combo-box.element.ts +20 -0
- package/src/lib/combo-box/combo-box.test.ts +18 -31
- package/src/lib/define.ts +5 -0
- package/src/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.ts +81 -0
- package/src/lib/in-page-nav/in-page-nav.element.ts +58 -0
- package/src/lib/in-page-nav/in-page-nav.stories.ts +67 -0
- package/src/lib/in-page-nav/in-page-nav.test.ts +15 -0
- package/src/lib/input/input.element.ts +9 -1
- package/src/lib/process-list/process-list-item/process-list-item.element.ts +80 -0
- package/src/lib/process-list/process-list.element.ts +27 -0
- package/src/lib/process-list/process-list.stories.ts +61 -0
- package/src/lib/process-list/process-list.test.ts +41 -0
- package/src/lib/search/search.element.ts +94 -0
- package/src/lib/search/search.event.ts +15 -0
- package/src/lib/search/search.stories.ts +31 -0
- package/src/lib/search/search.test.ts +81 -0
- package/src/lib.ts +5 -0
- package/target/lib/button/button.element.js +1 -1
- package/target/lib/button/button.element.js.map +1 -1
- package/target/lib/checkbox/checkbox.element.js +1 -1
- package/target/lib/collection/collection.stories.js +1 -1
- package/target/lib/combo-box/combo-box-option/combo-box-option.element.js +2 -7
- package/target/lib/combo-box/combo-box-option/combo-box-option.element.js.map +1 -1
- package/target/lib/combo-box/combo-box.element.d.ts +3 -0
- package/target/lib/combo-box/combo-box.element.js +23 -2
- package/target/lib/combo-box/combo-box.element.js.map +1 -1
- package/target/lib/combo-box/combo-box.test.js +7 -25
- package/target/lib/combo-box/combo-box.test.js.map +1 -1
- package/target/lib/define.d.ts +5 -0
- package/target/lib/define.js +5 -0
- package/target/lib/define.js.map +1 -1
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.d.ts +15 -0
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js +78 -0
- package/target/lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js.map +1 -0
- package/target/lib/in-page-nav/in-page-nav.element.d.ts +10 -0
- package/target/lib/in-page-nav/in-page-nav.element.js +50 -0
- package/target/lib/in-page-nav/in-page-nav.element.js.map +1 -0
- package/target/lib/in-page-nav/in-page-nav.stories.d.ts +12 -0
- package/target/lib/in-page-nav/in-page-nav.stories.js +17 -0
- package/target/lib/in-page-nav/in-page-nav.stories.js.map +1 -0
- package/target/lib/in-page-nav/in-page-nav.test.d.ts +1 -0
- package/target/lib/in-page-nav/in-page-nav.test.js +9 -0
- package/target/lib/in-page-nav/in-page-nav.test.js.map +1 -0
- package/target/lib/input/input.element.d.ts +3 -1
- package/target/lib/input/input.element.js +14 -2
- package/target/lib/input/input.element.js.map +1 -1
- package/target/lib/process-list/process-list-item/process-list-item.element.d.ts +8 -0
- package/target/lib/process-list/process-list-item/process-list-item.element.js +40 -0
- package/target/lib/process-list/process-list-item/process-list-item.element.js.map +1 -0
- package/target/lib/process-list/process-list.element.d.ts +8 -0
- package/target/lib/process-list/process-list.element.js +40 -0
- package/target/lib/process-list/process-list.element.js.map +1 -0
- package/target/lib/process-list/process-list.stories.d.ts +12 -0
- package/target/lib/process-list/process-list.stories.js +17 -0
- package/target/lib/process-list/process-list.stories.js.map +1 -0
- package/target/lib/process-list/process-list.test.d.ts +2 -0
- package/target/lib/process-list/process-list.test.js +10 -0
- package/target/lib/process-list/process-list.test.js.map +1 -0
- package/target/lib/radio/radio.element.js +1 -1
- package/target/lib/search/search.element.d.ts +16 -0
- package/target/lib/search/search.element.js +99 -0
- package/target/lib/search/search.element.js.map +1 -0
- package/target/lib/search/search.event.d.ts +9 -0
- package/target/lib/search/search.event.js +8 -0
- package/target/lib/search/search.event.js.map +1 -0
- package/target/lib/search/search.stories.d.ts +12 -0
- package/target/lib/search/search.stories.js +21 -0
- package/target/lib/search/search.stories.js.map +1 -0
- package/target/lib/search/search.test.d.ts +3 -0
- package/target/lib/search/search.test.js +52 -0
- package/target/lib/search/search.test.js.map +1 -0
- package/target/lib.d.ts +5 -0
- package/target/lib.js +5 -0
- package/target/lib.js.map +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { attr, css, element, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-process-list-item": USAProcessListItemElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-process-list-item",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
* {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host {
|
|
18
|
+
display: flex;
|
|
19
|
+
gap: .5rem;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
position: relative;
|
|
22
|
+
padding-left: 3rem;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.number {
|
|
26
|
+
background: #fff;
|
|
27
|
+
box-shadow: 0 0 0 .25rem #fff;
|
|
28
|
+
border: .25rem solid #1b1b1b;
|
|
29
|
+
position: absolute;
|
|
30
|
+
height: 2.5rem;
|
|
31
|
+
width: 2.5rem;
|
|
32
|
+
border-radius: 50%;
|
|
33
|
+
left: 0;
|
|
34
|
+
top: -11px;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
font-weight: bold;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.line {
|
|
43
|
+
background: #d9e8f6;
|
|
44
|
+
width: 0.5rem;
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: 0;
|
|
47
|
+
bottom: -2rem;
|
|
48
|
+
left: calc(2.5rem / 2 - .25rem);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#title::slotted(*) {
|
|
52
|
+
margin-top: 0;
|
|
53
|
+
margin-bottom: 0;
|
|
54
|
+
padding-top: 0;
|
|
55
|
+
padding-bottom: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host(:last-child) .line {
|
|
59
|
+
display: none;
|
|
60
|
+
}
|
|
61
|
+
`,
|
|
62
|
+
html`
|
|
63
|
+
<div class="number">
|
|
64
|
+
<slot name="count">1</slot>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div class="line"></div>
|
|
68
|
+
|
|
69
|
+
<slot id="title" name="title"></slot>
|
|
70
|
+
|
|
71
|
+
<div class="content">
|
|
72
|
+
<slot></slot>
|
|
73
|
+
</div>
|
|
74
|
+
`,
|
|
75
|
+
],
|
|
76
|
+
})
|
|
77
|
+
export class USAProcessListItemElement extends HTMLElement {
|
|
78
|
+
@attr()
|
|
79
|
+
accessor role = "listitem";
|
|
80
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { attr, css, element, html } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-process-list": USAProcessListElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@element({
|
|
10
|
+
tagName: "usa-process-list",
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: 1rem;
|
|
17
|
+
}
|
|
18
|
+
`,
|
|
19
|
+
html`
|
|
20
|
+
<slot></slot>
|
|
21
|
+
`,
|
|
22
|
+
],
|
|
23
|
+
})
|
|
24
|
+
export class USAProcessListElement extends HTMLElement {
|
|
25
|
+
@attr()
|
|
26
|
+
accessor role = "list";
|
|
27
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/web-components";
|
|
2
|
+
import { html } from "lit";
|
|
3
|
+
|
|
4
|
+
import type { USAProcessListElement } from "./process-list.element.js";
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const meta = {
|
|
8
|
+
title: "usa-process-list",
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
render() {
|
|
11
|
+
return html`
|
|
12
|
+
<usa-process-list>
|
|
13
|
+
<usa-process-list-item>
|
|
14
|
+
<span slot="count">1</span>
|
|
15
|
+
<h4 slot="title">Start a process</h4>
|
|
16
|
+
|
|
17
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
|
18
|
+
Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque.
|
|
19
|
+
|
|
20
|
+
<ul>
|
|
21
|
+
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
|
|
22
|
+
<li>Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis.</li>
|
|
23
|
+
<li>Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum.</li>
|
|
24
|
+
<li>Aliquam erat volutpat. Sed quis velit.</li>
|
|
25
|
+
</ul>
|
|
26
|
+
</usa-process-list-item>
|
|
27
|
+
|
|
28
|
+
<usa-process-list-item>
|
|
29
|
+
<span slot="count">2</span>
|
|
30
|
+
<h4 slot="title">Proceed to the second step</h4>
|
|
31
|
+
|
|
32
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
|
33
|
+
Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis.
|
|
34
|
+
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat.
|
|
35
|
+
Sed quis velit. Nulla facilisi.
|
|
36
|
+
Nulla libero. Vivamus pharetra posuere sapien.
|
|
37
|
+
</usa-process-list-item>
|
|
38
|
+
|
|
39
|
+
<usa-process-list-item>
|
|
40
|
+
<span slot="count">3</span>
|
|
41
|
+
<h4 slot="title">Complete the step-by-step process</h4>
|
|
42
|
+
|
|
43
|
+
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum.
|
|
44
|
+
Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero.
|
|
45
|
+
Vivamus pharetra posuere sapien.
|
|
46
|
+
</usa-process-list-item>
|
|
47
|
+
</usa-process-list>
|
|
48
|
+
`;
|
|
49
|
+
},
|
|
50
|
+
argTypes: {},
|
|
51
|
+
args: {},
|
|
52
|
+
} satisfies Meta<USAProcessListElement>;
|
|
53
|
+
|
|
54
|
+
export default meta;
|
|
55
|
+
|
|
56
|
+
type Story = StoryObj<USAProcessListElement>;
|
|
57
|
+
|
|
58
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
59
|
+
export const Primary: Story = {
|
|
60
|
+
args: {},
|
|
61
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import "./process-list.element.js";
|
|
2
|
+
import "./process-list-item/process-list-item.element.js";
|
|
3
|
+
|
|
4
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
5
|
+
|
|
6
|
+
import type { USAProcessListElement } from "./process-list.element.js";
|
|
7
|
+
|
|
8
|
+
describe("usa-process-list", () => {
|
|
9
|
+
it("should be accessible", async () => {
|
|
10
|
+
const processList = await fixture<USAProcessListElement>(html`
|
|
11
|
+
<usa-process-list>
|
|
12
|
+
<usa-process-list-item>
|
|
13
|
+
<h4 slot="title">Start a process</h4>
|
|
14
|
+
|
|
15
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque.
|
|
16
|
+
|
|
17
|
+
<ul>
|
|
18
|
+
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
|
|
19
|
+
<li>Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis.</li>
|
|
20
|
+
<li>Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum.</li>
|
|
21
|
+
<li>Aliquam erat volutpat. Sed quis velit.</li>
|
|
22
|
+
</ul>
|
|
23
|
+
</usa-process-list-item>
|
|
24
|
+
|
|
25
|
+
<usa-process-list-item>
|
|
26
|
+
<h4 slot="title">Proceed to the second step</h4>
|
|
27
|
+
|
|
28
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien.
|
|
29
|
+
</usa-process-list-item>
|
|
30
|
+
|
|
31
|
+
<usa-process-list-item>
|
|
32
|
+
<h4 slot="title">Complete the step-by-step process</h4>
|
|
33
|
+
|
|
34
|
+
Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien.
|
|
35
|
+
</usa-process-list-item>
|
|
36
|
+
</usa-process-list>
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
return assert.isAccessible(processList);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { attr, css, element, html, listen, query } from "@joist/element";
|
|
2
|
+
|
|
3
|
+
import { USASearchEvent } from "./search.event.js";
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
"usa-search": USASearchElement;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@element({
|
|
12
|
+
tagName: "usa-search",
|
|
13
|
+
shadowDom: [
|
|
14
|
+
css`
|
|
15
|
+
* {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
form {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: flex-end
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
usa-input {
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
usa-button {
|
|
34
|
+
margin-bottom: 1.5rem;
|
|
35
|
+
height: 2.5rem;
|
|
36
|
+
border-top-left-radius: 0;
|
|
37
|
+
border-bottom-left-radius: 0;
|
|
38
|
+
position: relative;
|
|
39
|
+
}
|
|
40
|
+
`,
|
|
41
|
+
html`
|
|
42
|
+
<form>
|
|
43
|
+
<usa-input>
|
|
44
|
+
<slot></slot>
|
|
45
|
+
</usa-input>
|
|
46
|
+
|
|
47
|
+
<usa-button type="submit">Search</usa-button>
|
|
48
|
+
</form>
|
|
49
|
+
`,
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
export class USASearchElement extends HTMLElement {
|
|
53
|
+
@attr()
|
|
54
|
+
accessor name = "search";
|
|
55
|
+
|
|
56
|
+
@attr()
|
|
57
|
+
accessor placeholder = "Search";
|
|
58
|
+
|
|
59
|
+
@attr()
|
|
60
|
+
accessor required = false;
|
|
61
|
+
|
|
62
|
+
@attr()
|
|
63
|
+
accessor disabled = false;
|
|
64
|
+
|
|
65
|
+
@attr()
|
|
66
|
+
accessor autocomplete: AutoFill = "off";
|
|
67
|
+
|
|
68
|
+
@attr()
|
|
69
|
+
accessor value = "";
|
|
70
|
+
|
|
71
|
+
#input = query("usa-input");
|
|
72
|
+
|
|
73
|
+
attributeChangedCallback() {
|
|
74
|
+
this.#input({
|
|
75
|
+
name: this.name,
|
|
76
|
+
placeholder: this.placeholder,
|
|
77
|
+
required: this.required,
|
|
78
|
+
disabled: this.disabled,
|
|
79
|
+
autocomplete: this.autocomplete,
|
|
80
|
+
value: this.value,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@listen("submit", "form")
|
|
85
|
+
onSubmit(e: Event) {
|
|
86
|
+
const searchEvent = new USASearchEvent(this.value);
|
|
87
|
+
|
|
88
|
+
this.dispatchEvent(searchEvent);
|
|
89
|
+
|
|
90
|
+
if (searchEvent.defaultPrevented) {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElementEventMap {
|
|
3
|
+
"usa::search": USASearchEvent;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export class USASearchEvent extends Event {
|
|
8
|
+
value: string;
|
|
9
|
+
|
|
10
|
+
constructor(value: string) {
|
|
11
|
+
super("usa::search", { bubbles: true, composed: true, cancelable: true });
|
|
12
|
+
|
|
13
|
+
this.value = value;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/web-components";
|
|
2
|
+
import { html } from "lit";
|
|
3
|
+
|
|
4
|
+
import type { USASearchElement } from "./search.element.js";
|
|
5
|
+
import type { USASearchEvent } from "./search.event.js";
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "usa-search",
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
render() {
|
|
12
|
+
function onSubmit(e: USASearchEvent) {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
|
|
15
|
+
console.log("SUBMIT", e.value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return html`<usa-search @usa::search=${onSubmit}>Search</usa-search>`;
|
|
19
|
+
},
|
|
20
|
+
argTypes: {},
|
|
21
|
+
args: {},
|
|
22
|
+
} satisfies Meta<USASearchElement>;
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
|
|
26
|
+
type Story = StoryObj<USASearchElement>;
|
|
27
|
+
|
|
28
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
29
|
+
export const Primary: Story = {
|
|
30
|
+
args: {},
|
|
31
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import "./search.element.js";
|
|
2
|
+
import "../input/input.element.js";
|
|
3
|
+
import "../button/button.element.js";
|
|
4
|
+
|
|
5
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
6
|
+
|
|
7
|
+
import { userEvent } from "@testing-library/user-event";
|
|
8
|
+
import type { USASearchElement } from "./search.element.js";
|
|
9
|
+
|
|
10
|
+
describe("usa-search", () => {
|
|
11
|
+
it("should be accessible", async () => {
|
|
12
|
+
const search = await fixture<USASearchElement>(html`
|
|
13
|
+
<usa-search name="search">Hello World</usa-search>
|
|
14
|
+
`);
|
|
15
|
+
|
|
16
|
+
return assert.isAccessible(search);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should have default attribute values", async () => {
|
|
20
|
+
const search = await fixture<USASearchElement>(html`
|
|
21
|
+
<usa-search></usa-search>
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
assert.equal(search.name, "search");
|
|
25
|
+
assert.equal(search.placeholder, "Search");
|
|
26
|
+
assert.equal(search.required, false);
|
|
27
|
+
assert.equal(search.disabled, false);
|
|
28
|
+
assert.equal(search.autocomplete, "off");
|
|
29
|
+
assert.equal(search.value, "");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should update attributes when changed", async () => {
|
|
33
|
+
const search = await fixture<USASearchElement>(html`
|
|
34
|
+
<usa-search></usa-search>
|
|
35
|
+
`);
|
|
36
|
+
|
|
37
|
+
search.name = "custom-name";
|
|
38
|
+
search.placeholder = "Custom Placeholder";
|
|
39
|
+
search.required = true;
|
|
40
|
+
search.disabled = true;
|
|
41
|
+
search.autocomplete = "on";
|
|
42
|
+
search.value = "test value";
|
|
43
|
+
|
|
44
|
+
assert.equal(search.name, "custom-name");
|
|
45
|
+
assert.equal(search.placeholder, "Custom Placeholder");
|
|
46
|
+
assert.equal(search.required, true);
|
|
47
|
+
assert.equal(search.disabled, true);
|
|
48
|
+
assert.equal(search.autocomplete, "on");
|
|
49
|
+
assert.equal(search.value, "test value");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should handle form submission", async () => {
|
|
53
|
+
const search = await fixture<USASearchElement>(html`
|
|
54
|
+
<usa-search></usa-search>
|
|
55
|
+
`);
|
|
56
|
+
|
|
57
|
+
let submitted = false;
|
|
58
|
+
|
|
59
|
+
search.addEventListener("submit", (e) => {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
|
|
62
|
+
submitted = true;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const form = search.shadowRoot?.querySelector("form");
|
|
66
|
+
form?.dispatchEvent(new Event("submit", { bubbles: true, composed: true }));
|
|
67
|
+
|
|
68
|
+
assert.isTrue(submitted);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should update value on input change", async () => {
|
|
72
|
+
const search = await fixture<USASearchElement>(html`
|
|
73
|
+
<usa-search></usa-search>
|
|
74
|
+
`);
|
|
75
|
+
|
|
76
|
+
const input = search.shadowRoot?.querySelector("usa-input");
|
|
77
|
+
input?.dispatchEvent(new Event("input", { bubbles: true }));
|
|
78
|
+
|
|
79
|
+
assert.equal(search.value, "");
|
|
80
|
+
});
|
|
81
|
+
});
|
package/src/lib.ts
CHANGED
|
@@ -36,3 +36,8 @@ export { USACheckboxGroupElement } from "./lib/checkbox/checkbox-group/checkbox-
|
|
|
36
36
|
export { USARangeSliderElement } from "./lib/range-slider/range-slider.element.js";
|
|
37
37
|
export { USAComboBoxElement as USAAutocompleteElement } from "./lib/combo-box/combo-box.element.js";
|
|
38
38
|
export { USAComboBoxOptionElement } from "./lib/combo-box/combo-box-option/combo-box-option.element.js";
|
|
39
|
+
export { USASearchElement } from "./lib/search/search.element.js";
|
|
40
|
+
export { USAProcessListElement } from "./lib/process-list/process-list.element.js";
|
|
41
|
+
export { USAProcessListItemElement } from "./lib/process-list/process-list-item/process-list-item.element.js";
|
|
42
|
+
export { USAInPageNavElement } from "./lib/in-page-nav/in-page-nav.element.js";
|
|
43
|
+
export { USAInPageNavItemElement } from "./lib/in-page-nav/in-page-nav-item/in-page-nav-item.element.js";
|
|
@@ -15,7 +15,7 @@ let USAButtonElement = (() => {
|
|
|
15
15
|
delegatesFocus: true,
|
|
16
16
|
},
|
|
17
17
|
shadowDom: [
|
|
18
|
-
css `:host{display:
|
|
18
|
+
css `:host{display:inline-block;border-top-right-radius:.25rem;border-bottom-right-radius:.25rem;border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}button{box-sizing:border-box;font-size:1.06rem;line-height:.9;color:#fff;background-color:#005ea2;-webkit-appearance:none;-moz-appearance:none;appearance:none;align-items:center;border:0;border-top-right-radius:inherit;border-bottom-right-radius:inherit;border-top-left-radius:inherit;border-bottom-left-radius:inherit;cursor:pointer;-moz-column-gap:0.5rem;column-gap:.5rem;display:inline-flex;font-weight:700;justify-content:center;padding:.75rem 1.25rem;text-align:center;text-decoration:none;width:100%;height:100%;cursor:pointer}@media all and (min-width:30em){:host{width:auto}}button:visited{color:#fff}button:hover{color:#fff;background-color:#1a4480;border-bottom:0;text-decoration:none}button:active{color:#fff;background-color:#162e51}button:not([disabled]):focus{outline-offset:0.25rem}button:disabled{color:#454545;background-color:#c9c9c9;cursor:not-allowed;opacity:1}button:disabled:active,button:disabled:focus,button:disabled:hover{color:#454545;background-color:#c9c9c9}button:focus{outline:.25rem solid #2491ff;outline-offset:0}:host([variant=secondary]) button{color:#fff;background-color:#d83933}:host([variant=secondary]) button:hover{background-color:#b50909}:host([variant=secondary]) button:active{background-color:#8b0a03}:host([variant=cool]) button{color:#1b1b1b;background-color:#00bde3}:host([variant=cool]) button:hover{background-color:#28a0cb}:host([variant=cool]) button:active{color:#fff;background-color:#07648d}:host([variant=warm]) button{color:#1b1b1b;background-color:#fa9441}:host([variant=warm]) button:hover{color:#fff;background-color:#c05600}:host([variant=warm]) button:active{color:#fff;background-color:#775540}:host([variant=outline]) button{background-color:transparent;box-shadow:inset 0 0 0 2px #005ea2;color:#005ea2}:host([variant=outline]) button:hover{box-shadow:inset 0 0 0 2px #1a4480;color:#1a4480}:host([variant=outline]) button:active{box-shadow:inset 0 0 0 2px #162e51;color:#162e51}`,
|
|
19
19
|
html `<button tabindex="0"><slot></slot></button>`,
|
|
20
20
|
],
|
|
21
21
|
})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.element.js","sourceRoot":"","sources":["../../../src/lib/button/button.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAQhF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS;IACT,WAAW;IACX,MAAM;IACN,MAAM;IACN,SAAS;CACD,CAAC;
|
|
1
|
+
{"version":3,"file":"button.element.js","sourceRoot":"","sources":["../../../src/lib/button/button.element.ts"],"names":[],"mappings":"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"}
|
|
@@ -4,7 +4,7 @@ let USACheckboxElement = (() => {
|
|
|
4
4
|
let _classDecorators = [element({
|
|
5
5
|
tagName: "usa-checkbox",
|
|
6
6
|
shadowDom: [
|
|
7
|
-
css `*{box-sizing:border-box}:host{display:inline-block;max-width:30rem;position:relative}:host([tiled]) label{background-color:#fff;border:2px solid #c9c9c9;border-radius:.25rem;color:#1b1b1b;padding:.75rem 1rem .75rem .75rem}label{display:inline-flex;cursor:pointer;font-size:1.06rem;line-height:1.3;width:100%}.checkbox{background:#fff;box-shadow:0 0 0 2px #1b1b1b;display:flex;align-items:center;justify-content:center;height:1.25rem;min-width:1.25rem;max-width:1.25rem;border-radius:2px;position:relative;margin-right:.75rem}input:disabled+.checkbox{background-color:#fff;box-shadow:0 0 0 2px #757575}input:disabled:is(:checked)+.checkbox{background-color:#757575;box-shadow:0 0 0 2px #757575}:host([disabled]) label{color:#757575;cursor:not-allowed}input:checked+.checkbox{background-color:#005ea2;box-shadow:0 0 0 2px #005ea2}input:checked+.checkbox::after{content:" ";display:block;height:1rem;width:.5rem;border-right:4px solid #fff;border-bottom:4px solid #fff;transform:rotate(45deg) scale(.65)}input{position:absolute}input:focus+.checkbox{outline:.25rem solid #2491ff;outline-offset
|
|
7
|
+
css `*{box-sizing:border-box}:host{display:inline-block;max-width:30rem;position:relative}:host([tiled]) label{background-color:#fff;border:2px solid #c9c9c9;border-radius:.25rem;color:#1b1b1b;padding:.75rem 1rem .75rem .75rem}label{display:inline-flex;cursor:pointer;font-size:1.06rem;line-height:1.3;width:100%}.checkbox{background:#fff;box-shadow:0 0 0 2px #1b1b1b;display:flex;align-items:center;justify-content:center;height:1.25rem;min-width:1.25rem;max-width:1.25rem;border-radius:2px;position:relative;margin-right:.75rem}input:disabled+.checkbox{background-color:#fff;box-shadow:0 0 0 2px #757575}input:disabled:is(:checked)+.checkbox{background-color:#757575;box-shadow:0 0 0 2px #757575}:host([disabled]) label{color:#757575;cursor:not-allowed}input:checked+.checkbox{background-color:#005ea2;box-shadow:0 0 0 2px #005ea2}input:checked+.checkbox::after{content:" ";display:block;height:1rem;width:.5rem;border-right:4px solid #fff;border-bottom:4px solid #fff;transform:rotate(45deg) scale(.65)}input{position:absolute}input:focus+.checkbox{outline:.25rem solid #2491ff;outline-offset:0.25rem}.description{display:block;font-size:.93rem;margin-top:.5rem}.break{flex-basis:100%;height:0}:host([tiled]) label:has(input:checked){background-color:rgba(0,94,162,.1);border-color:#005ea2}:host([tiled]) label:has(input:checked:is(:disabled)){background-color:#fff;border-color:#757575}`,
|
|
8
8
|
html `<label><input type="checkbox" tabindex="0"><div class="checkbox"></div><div class="title"><slot></slot></div></label>`,
|
|
9
9
|
],
|
|
10
10
|
})];
|
|
@@ -4,7 +4,7 @@ const meta = {
|
|
|
4
4
|
title: "usa-collection",
|
|
5
5
|
tags: ["autodocs"],
|
|
6
6
|
render() {
|
|
7
|
-
return html `<usa-collection><usa-collection-item><h4 slot="heading"><usa-link href="#">Gears of Government President's Award winners</usa-link></h4><div slot="description">Today, the Administration announces the winners of the Gears of Government President's Award. This program recognizes the contributions of individuals and teams across the federal workforce who make a profound difference in the lives of the American people.</div><usa-tag slot="tags" type="new">NEW</usa-tag><usa-tag slot="tags">PMA</usa-tag><usa-tag slot="tags">OMB</usa-tag></usa-collection-item><usa-collection-item><img height="80" width="80" src="
|
|
7
|
+
return html `<usa-collection><usa-collection-item><h4 slot="heading"><usa-link href="#">Gears of Government President's Award winners</usa-link></h4><div slot="description">Today, the Administration announces the winners of the Gears of Government President's Award. This program recognizes the contributions of individuals and teams across the federal workforce who make a profound difference in the lives of the American people.</div><usa-tag slot="tags" type="new">NEW</usa-tag><usa-tag slot="tags">PMA</usa-tag><usa-tag slot="tags">OMB</usa-tag></usa-collection-item><usa-collection-item><img height="80" width="80" src="./img/gog-logo.png" slot="img"><h4 slot="heading"><usa-link href="#">Gears of Government President's Award winners</usa-link></h4><div slot="description">Today, the Administration announces the winners of the Gears of Government President's Award. This program recognizes the contributions of individuals and teams across the federal workforce who make a profound difference in the lives of the American people.</div><usa-tag slot="tags" type="new">NEW</usa-tag><usa-tag slot="tags">PMA</usa-tag><usa-tag slot="tags">OMB</usa-tag></usa-collection-item><usa-collection-item><h4 slot="heading"><usa-link href="#">Women-owned small business dashboard</usa-link></h4><div slot="description">In honor of National Women's Small Business Month, we've partnered with SBA's Office of Government Contracting and Business Development and Office of Program Performance, Analysis, and Evaluation to highlight the Women-Owned Small Businesses (WOSBs) data dashboard!</div><usa-tag slot="tags" type="new">NEW</usa-tag><usa-tag slot="tags">PMA</usa-tag><usa-tag slot="tags">OMB</usa-tag></usa-collection-item><usa-collection-item><img height="52" width="80" src="./img/wosb1.jpg" slot="img"><h4 slot="heading"><usa-link href="#">Women-owned small business dashboard</usa-link></h4><div slot="description">In honor of National Women's Small Business Month, we've partnered with SBA's Office of Government Contracting and Business Development and Office of Program Performance, Analysis, and Evaluation to highlight the Women-Owned Small Businesses (WOSBs) data dashboard!</div><usa-tag slot="tags" type="new">NEW</usa-tag><usa-tag slot="tags">PMA</usa-tag><usa-tag slot="tags">OMB</usa-tag></usa-collection-item></usa-collection>`;
|
|
8
8
|
},
|
|
9
9
|
argTypes: {},
|
|
10
10
|
args: {},
|
|
@@ -2,12 +2,7 @@ import { __esDecorate, __runInitializers } from "tslib";
|
|
|
2
2
|
import { inject, injectable } from "@joist/di";
|
|
3
3
|
import { attr, css, element, html, query } from "@joist/element";
|
|
4
4
|
import { COMBO_BOX_CTX } from "../context.js";
|
|
5
|
-
const
|
|
6
|
-
template.innerHTML = /*html*/ `
|
|
7
|
-
<li tabindex="-1" role="option">
|
|
8
|
-
<slot></slot>
|
|
9
|
-
</li>
|
|
10
|
-
`;
|
|
5
|
+
const listTemplate = html `<li tabindex="-1" role="option"><slot></slot></li>`;
|
|
11
6
|
let USAComboBoxOptionElement = (() => {
|
|
12
7
|
let _classDecorators = [injectable({
|
|
13
8
|
name: "usa-combo-box-option-ctx",
|
|
@@ -39,7 +34,7 @@ let USAComboBoxOptionElement = (() => {
|
|
|
39
34
|
#value_accessor_storage = __runInitializers(this, _value_initializers, "");
|
|
40
35
|
get value() { return this.#value_accessor_storage; }
|
|
41
36
|
set value(value) { this.#value_accessor_storage = value; }
|
|
42
|
-
#listItem = (__runInitializers(this, _value_extraInitializers),
|
|
37
|
+
#listItem = (__runInitializers(this, _value_extraInitializers), listTemplate.createNode());
|
|
43
38
|
#li = query("li", this.#listItem);
|
|
44
39
|
#slot = query("slot", this.#listItem);
|
|
45
40
|
#ctx = inject(COMBO_BOX_CTX);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo-box-option.element.js","sourceRoot":"","sources":["../../../../src/lib/combo-box/combo-box-option/combo-box-option.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAQ9C,MAAM,
|
|
1
|
+
{"version":3,"file":"combo-box-option.element.js","sourceRoot":"","sources":["../../../../src/lib/combo-box/combo-box-option/combo-box-option.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAQ9C,MAAM,YAAY,GAAG,IAAI,CAAA;;;;CAIxB,CAAC;IAmBW,wBAAwB;4BAjBpC,UAAU,CAAC;YACV,IAAI,EAAE,0BAA0B;SACjC,CAAC,EACD,OAAO,CAAC;YACP,OAAO,EAAE,sBAAsB;YAC/B,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;KAOF;gBACD,IAAI,CAAA,eAAe;aACpB;SACF,CAAC;;;;sBAC4C,WAAW;;;;wCAAnB,SAAQ,WAAW;;;;iCACtD,IAAI,EAAE;YACP,oKAAS,KAAK,6BAAL,KAAK,qFAAM;YAFtB,6KAgCC;;;YAhCY,uDAAwB;;QAEnC,uEAAiB,EAAE,EAAC;QAApB,IAAS,KAAK,2CAAM;QAApB,IAAS,KAAK,iDAAM;QAEpB,SAAS,uDAAG,YAAY,CAAC,UAAU,EAAiB,EAAC;QACrD,GAAG,GAAG,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAClC,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;QAE7B,wBAAwB;YACtB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC;YAElE,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAEtC,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YAE5B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC;QAED,iBAAiB;YACf,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAExB,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5B,CAAC;QAED,oBAAoB;YAClB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAExB,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAE7B,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;;;;SA/BU,wBAAwB"}
|
|
@@ -11,6 +11,7 @@ export declare class USAComboBoxElement extends HTMLElement implements ComboBoxC
|
|
|
11
11
|
accessor required: boolean;
|
|
12
12
|
accessor value: string;
|
|
13
13
|
accessor placeholder: string;
|
|
14
|
+
accessor disabled: boolean;
|
|
14
15
|
list: (updates?: (Partial<HTMLUListElement> | ((node: HTMLUListElement) => Partial<HTMLUListElement>)) | undefined) => HTMLUListElement;
|
|
15
16
|
input: (updates?: (Partial<HTMLInputElement> | ((node: HTMLInputElement) => Partial<HTMLInputElement>)) | undefined) => HTMLInputElement;
|
|
16
17
|
currentItemEl: Element | null;
|
|
@@ -21,6 +22,8 @@ export declare class USAComboBoxElement extends HTMLElement implements ComboBoxC
|
|
|
21
22
|
addOption(el: HTMLLIElement): void;
|
|
22
23
|
removeOption(el: HTMLLIElement): void;
|
|
23
24
|
onFocusIn(): void;
|
|
25
|
+
focus(options?: FocusOptions): void;
|
|
26
|
+
blur(): void;
|
|
24
27
|
onInput(): Promise<void>;
|
|
25
28
|
onFocusOut(): void;
|
|
26
29
|
onArrowDown(e: KeyboardEvent): void;
|
|
@@ -9,7 +9,7 @@ let USAComboBoxElement = (() => {
|
|
|
9
9
|
}), element({
|
|
10
10
|
tagName: "usa-combo-box",
|
|
11
11
|
shadowDom: [
|
|
12
|
-
css `*{box-sizing:border-box}:host{--usa-combo-max-height:12.5em;display:block;max-width:30rem;position:relative;margin-bottom:1.5rem}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%;padding-right:2.8rem}input:not(:disabled):focus{outline:.25rem solid #2491ff;outline-offset:0}ul{padding:0;position:absolute;bottom:0;width:100%;transform:translateY(100%);margin:0;border:1px solid #5c5c5c;max-height:var(--usa-combo-max-height);overflow-y:scroll;z-index:1001}ul:empty{border:none}ul li{background:#ffff;list-style:none;border-bottom:1px solid #e6e6e6;cursor:pointer;display:block}ul li:hover{background-color:#f0f0f0}li:focus{outline:.25rem solid #2491ff;outline-offset
|
|
12
|
+
css `*{box-sizing:border-box}:host{--usa-combo-max-height:12.5em;display:block;max-width:30rem;position:relative;margin-bottom:1.5rem}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%;padding-right:2.8rem}input:not(:disabled):focus{outline:.25rem solid #2491ff;outline-offset:0}ul{padding:0;position:absolute;bottom:0;width:100%;transform:translateY(100%);margin:0;border:1px solid #5c5c5c;max-height:var(--usa-combo-max-height);overflow-y:scroll;z-index:1001}ul:empty{border:none}ul li{background:#ffff;list-style:none;border-bottom:1px solid #e6e6e6;cursor:pointer;display:block}ul li:hover{background-color:#f0f0f0}li:focus{outline:.25rem solid #2491ff;outline-offset:-0.25rem}.usa-combo-box-icon{display:block;position:absolute;bottom:0;right:.5rem;cursor:pointer}.usa-combo-box-icon .line{width:1px;top:.3rem;bottom:.5rem;left:-.3rem;position:absolute;background-color:#c6cace}`,
|
|
13
13
|
html `<label><slot name="label"></slot><input tabindex="0" role="combobox" autocomplete="off" aria-controls="combo-box-list" aria-expanded="false"><div class="usa-combo-box-icon"><div class="line"></div><usa-icon icon="expand_more"></usa-icon></div></label><ul tabindex="-1" role="listbox" id="combo-box-list"></ul>`,
|
|
14
14
|
],
|
|
15
15
|
})];
|
|
@@ -30,6 +30,9 @@ let USAComboBoxElement = (() => {
|
|
|
30
30
|
let _placeholder_decorators;
|
|
31
31
|
let _placeholder_initializers = [];
|
|
32
32
|
let _placeholder_extraInitializers = [];
|
|
33
|
+
let _disabled_decorators;
|
|
34
|
+
let _disabled_initializers = [];
|
|
35
|
+
let _disabled_extraInitializers = [];
|
|
33
36
|
let _onValueChanged_decorators;
|
|
34
37
|
let _onFocusIn_decorators;
|
|
35
38
|
let _onInput_decorators;
|
|
@@ -46,6 +49,7 @@ let USAComboBoxElement = (() => {
|
|
|
46
49
|
_required_decorators = [attr()];
|
|
47
50
|
_value_decorators = [attr()];
|
|
48
51
|
_placeholder_decorators = [attr()];
|
|
52
|
+
_disabled_decorators = [attr()];
|
|
49
53
|
_onValueChanged_decorators = [attrChanged("value", "required")];
|
|
50
54
|
_onFocusIn_decorators = [listen("focus", (host) => host.input())];
|
|
51
55
|
_onInput_decorators = [listen("input")];
|
|
@@ -58,6 +62,7 @@ let USAComboBoxElement = (() => {
|
|
|
58
62
|
__esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
|
|
59
63
|
__esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
|
|
60
64
|
__esDecorate(this, null, _placeholder_decorators, { kind: "accessor", name: "placeholder", static: false, private: false, access: { has: obj => "placeholder" in obj, get: obj => obj.placeholder, set: (obj, value) => { obj.placeholder = value; } }, metadata: _metadata }, _placeholder_initializers, _placeholder_extraInitializers);
|
|
65
|
+
__esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
|
|
61
66
|
__esDecorate(this, null, _onValueChanged_decorators, { kind: "method", name: "onValueChanged", static: false, private: false, access: { has: obj => "onValueChanged" in obj, get: obj => obj.onValueChanged }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
62
67
|
__esDecorate(this, null, _onFocusIn_decorators, { kind: "method", name: "onFocusIn", static: false, private: false, access: { has: obj => "onFocusIn" in obj, get: obj => obj.onFocusIn }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
63
68
|
__esDecorate(this, null, _onInput_decorators, { kind: "method", name: "onInput", static: false, private: false, access: { has: obj => "onInput" in obj, get: obj => obj.onInput }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
@@ -83,7 +88,10 @@ let USAComboBoxElement = (() => {
|
|
|
83
88
|
#placeholder_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _placeholder_initializers, ""));
|
|
84
89
|
get placeholder() { return this.#placeholder_accessor_storage; }
|
|
85
90
|
set placeholder(value) { this.#placeholder_accessor_storage = value; }
|
|
86
|
-
|
|
91
|
+
#disabled_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _disabled_initializers, false));
|
|
92
|
+
get disabled() { return this.#disabled_accessor_storage; }
|
|
93
|
+
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
94
|
+
list = (__runInitializers(this, _disabled_extraInitializers), query("ul"));
|
|
87
95
|
input = query("input");
|
|
88
96
|
currentItemEl = null;
|
|
89
97
|
#allListItems = new Set();
|
|
@@ -93,6 +101,7 @@ let USAComboBoxElement = (() => {
|
|
|
93
101
|
name: this.name,
|
|
94
102
|
placeholder: this.placeholder,
|
|
95
103
|
required: this.required,
|
|
104
|
+
disabled: this.disabled,
|
|
96
105
|
});
|
|
97
106
|
}
|
|
98
107
|
onValueChanged() {
|
|
@@ -111,6 +120,9 @@ let USAComboBoxElement = (() => {
|
|
|
111
120
|
this.#allListItems.delete(el);
|
|
112
121
|
}
|
|
113
122
|
onFocusIn() {
|
|
123
|
+
if (this.disabled) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
114
126
|
this.currentItemEl = null;
|
|
115
127
|
const list = this.list();
|
|
116
128
|
this.input({ ariaExpanded: "true" });
|
|
@@ -120,7 +132,16 @@ let USAComboBoxElement = (() => {
|
|
|
120
132
|
}
|
|
121
133
|
list.replaceChildren(fragment);
|
|
122
134
|
}
|
|
135
|
+
focus(options) {
|
|
136
|
+
this.input().focus(options);
|
|
137
|
+
}
|
|
138
|
+
blur() {
|
|
139
|
+
this.input().blur();
|
|
140
|
+
}
|
|
123
141
|
async onInput() {
|
|
142
|
+
if (this.disabled) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
124
145
|
const input = this.input();
|
|
125
146
|
const list = this.list();
|
|
126
147
|
this.currentItemEl = null;
|