@noctuatech/uswds 1.1.9 → 1.2.1
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 +1 -1
- package/src/lib/button/button.element.ts +55 -40
- package/src/lib/button/button.stories.ts +6 -0
- package/src/lib/file-input/file-input.element.ts +11 -10
- package/src/lib/file-input/file-input.test.ts +32 -0
- package/src/lib/icon/icon.element.ts +6 -7
- package/target/lib/button/button.element.d.ts +3 -2
- package/target/lib/button/button.element.js +25 -17
- package/target/lib/button/button.element.js.map +1 -1
- package/target/lib/button/button.stories.js +1 -1
- package/target/lib/button/button.stories.js.map +1 -1
- package/target/lib/file-input/file-input.element.js +2 -1
- package/target/lib/file-input/file-input.element.js.map +1 -1
- package/target/lib/file-input/file-input.test.js +20 -0
- package/target/lib/file-input/file-input.test.js.map +1 -1
- package/target/lib/icon/icon.element.d.ts +1 -1
- package/target/lib/icon/icon.element.js +6 -10
- package/target/lib/icon/icon.element.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@joist/templating/define.js";
|
|
2
|
+
|
|
3
|
+
import { attr, css, element, html, listen } from "@joist/element";
|
|
4
|
+
import { bind } from "@joist/templating";
|
|
2
5
|
|
|
3
6
|
declare global {
|
|
4
7
|
interface HTMLElementTagNameMap {
|
|
@@ -30,9 +33,10 @@ export type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
|
|
|
30
33
|
border-bottom-right-radius: 0.25rem;
|
|
31
34
|
border-top-left-radius: 0.25rem;
|
|
32
35
|
border-bottom-left-radius: 0.25rem;
|
|
36
|
+
overflow: hidden;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
button {
|
|
39
|
+
button, a {
|
|
36
40
|
box-sizing: border-box;
|
|
37
41
|
font-size: 1.06rem;
|
|
38
42
|
line-height: 0.9;
|
|
@@ -43,10 +47,6 @@ export type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
|
|
|
43
47
|
appearance: none;
|
|
44
48
|
align-items: center;
|
|
45
49
|
border: 0;
|
|
46
|
-
border-top-right-radius: inherit;
|
|
47
|
-
border-bottom-right-radius: inherit;
|
|
48
|
-
border-top-left-radius: inherit;
|
|
49
|
-
border-bottom-left-radius: inherit;
|
|
50
50
|
cursor: pointer;
|
|
51
51
|
-moz-column-gap: 0.5rem;
|
|
52
52
|
column-gap: 0.5rem;
|
|
@@ -67,111 +67,125 @@ export type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
button:visited {
|
|
70
|
+
:is(button, a):visited {
|
|
71
71
|
color: white;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
button:hover {
|
|
74
|
+
:is(button, a):hover {
|
|
75
75
|
color: white;
|
|
76
76
|
background-color: #1a4480;
|
|
77
77
|
border-bottom: 0;
|
|
78
78
|
text-decoration: none;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
button:active {
|
|
81
|
+
:is(button, a):active {
|
|
82
82
|
color: white;
|
|
83
83
|
background-color: #162e51;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
button:not([disabled]):focus {
|
|
86
|
+
:is(button, a):not([disabled]):focus {
|
|
87
87
|
outline-offset: 0.25rem;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
button:disabled {
|
|
90
|
+
:is(button, a):disabled {
|
|
91
91
|
color: #454545;
|
|
92
92
|
background-color: #c9c9c9;
|
|
93
93
|
cursor: not-allowed;
|
|
94
94
|
opacity: 1;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
button:disabled:hover,
|
|
98
|
-
button:disabled:active,
|
|
99
|
-
button:disabled:focus {
|
|
97
|
+
:is(button, a):disabled:hover,
|
|
98
|
+
:is(button, a):disabled:active,
|
|
99
|
+
:is(button, a):disabled:focus {
|
|
100
100
|
color: #454545;
|
|
101
101
|
background-color: #c9c9c9;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
button:focus {
|
|
104
|
+
:is(button, a):focus {
|
|
105
105
|
outline: 0.25rem solid #2491ff;
|
|
106
106
|
outline-offset: 0;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/** Secondary */
|
|
110
|
-
:host([variant="secondary"]) button {
|
|
110
|
+
:host([variant="secondary"]) :is(button, a) {
|
|
111
111
|
color: #fff;
|
|
112
112
|
background-color: #d83933;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
:host([variant="secondary"]) button:hover {
|
|
115
|
+
:host([variant="secondary"]) :is(button, a):hover {
|
|
116
116
|
background-color: #b50909;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
:host([variant="secondary"]) button:active {
|
|
119
|
+
:host([variant="secondary"]) :is(button, a):active {
|
|
120
120
|
background-color: #8b0a03;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/** cool */
|
|
124
|
-
:host([variant="cool"]) button {
|
|
124
|
+
:host([variant="cool"]) :is(button, a) {
|
|
125
125
|
color: #1b1b1b;
|
|
126
126
|
background-color: #00bde3;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
:host([variant="cool"]) button:hover {
|
|
129
|
+
:host([variant="cool"]) :is(button, a):hover {
|
|
130
130
|
background-color: #28a0cb;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
:host([variant="cool"]) button:active {
|
|
133
|
+
:host([variant="cool"]) :is(button, a):active {
|
|
134
134
|
color: #fff;
|
|
135
135
|
background-color: #07648d;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/** warm */
|
|
139
|
-
:host([variant="warm"]) button {
|
|
139
|
+
:host([variant="warm"]) :is(button, a) {
|
|
140
140
|
color: #1b1b1b;
|
|
141
141
|
background-color: #fa9441;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
:host([variant="warm"]) button:hover {
|
|
144
|
+
:host([variant="warm"]) :is(button, a):hover {
|
|
145
145
|
color: #fff;
|
|
146
146
|
background-color: #c05600;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
:host([variant="warm"]) button:active {
|
|
149
|
+
:host([variant="warm"]) :is(button, a):active {
|
|
150
150
|
color: #fff;
|
|
151
151
|
background-color: #775540;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/** outline */
|
|
155
|
-
:host([variant="outline"]) button {
|
|
155
|
+
:host([variant="outline"]) :is(button, a) {
|
|
156
156
|
background-color: transparent;
|
|
157
157
|
box-shadow: inset 0 0 0 2px #005ea2;
|
|
158
158
|
color: #005ea2;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
:host([variant="outline"]) button:hover {
|
|
161
|
+
:host([variant="outline"]) :is(button, a):hover {
|
|
162
162
|
box-shadow: inset 0 0 0 2px #1a4480;
|
|
163
163
|
color: #1a4480;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
:host([variant="outline"]) button:active {
|
|
166
|
+
:host([variant="outline"]) :is(button, a):active {
|
|
167
167
|
box-shadow: inset 0 0 0 2px #162e51;
|
|
168
168
|
color: #162e51;
|
|
169
169
|
}
|
|
170
170
|
`,
|
|
171
171
|
html`
|
|
172
|
-
<
|
|
173
|
-
<
|
|
174
|
-
|
|
172
|
+
<j-if bind="href">
|
|
173
|
+
<template>
|
|
174
|
+
<j-props>
|
|
175
|
+
<a $href="href" $disabled="disabled" $target="target">
|
|
176
|
+
<slot></slot>
|
|
177
|
+
</a>
|
|
178
|
+
</j-props>
|
|
179
|
+
</template>
|
|
180
|
+
|
|
181
|
+
<template else>
|
|
182
|
+
<j-props>
|
|
183
|
+
<button tabindex="0" $type="type" $disabled="disabled" $value="value">
|
|
184
|
+
<slot></slot>
|
|
185
|
+
</button>
|
|
186
|
+
</j-props>
|
|
187
|
+
</template>
|
|
188
|
+
</j-if>
|
|
175
189
|
`,
|
|
176
190
|
],
|
|
177
191
|
})
|
|
@@ -179,36 +193,37 @@ export class USAButtonElement extends HTMLElement {
|
|
|
179
193
|
static formAssociated = true;
|
|
180
194
|
|
|
181
195
|
@attr()
|
|
196
|
+
@bind()
|
|
182
197
|
accessor type: "button" | "submit" | "reset" = "button";
|
|
183
198
|
|
|
184
199
|
@attr()
|
|
200
|
+
@bind()
|
|
185
201
|
accessor disabled = false;
|
|
186
202
|
|
|
187
203
|
@attr()
|
|
188
204
|
accessor variant: ButtonVariant = "primary";
|
|
189
205
|
|
|
190
206
|
@attr()
|
|
207
|
+
@bind()
|
|
191
208
|
accessor value = "";
|
|
192
209
|
|
|
210
|
+
@attr()
|
|
211
|
+
@bind()
|
|
212
|
+
accessor href = "";
|
|
213
|
+
|
|
214
|
+
@attr()
|
|
215
|
+
@bind()
|
|
216
|
+
accessor target = "";
|
|
217
|
+
|
|
193
218
|
accessor tabIndex = 0;
|
|
194
219
|
|
|
195
220
|
#internals = this.attachInternals();
|
|
196
|
-
#button = query("button");
|
|
197
|
-
|
|
198
|
-
@ready()
|
|
199
|
-
onReady() {
|
|
200
|
-
this.#button({ autofocus: this.autofocus });
|
|
201
|
-
}
|
|
202
221
|
|
|
203
222
|
@listen("click")
|
|
204
223
|
onInternalClick() {
|
|
205
224
|
this.#handleForm();
|
|
206
225
|
}
|
|
207
226
|
|
|
208
|
-
attributeChangedCallback() {
|
|
209
|
-
this.#button({ type: this.type, disabled: this.disabled });
|
|
210
|
-
}
|
|
211
|
-
|
|
212
227
|
#handleForm() {
|
|
213
228
|
const { form } = this.#internals;
|
|
214
229
|
|
|
@@ -16,6 +16,12 @@ const meta = {
|
|
|
16
16
|
i === BUTTON_VARIANTS.length - 1 ? "" : "\n\n"
|
|
17
17
|
}`,
|
|
18
18
|
)}
|
|
19
|
+
${BUTTON_VARIANTS.map(
|
|
20
|
+
(variant, i) =>
|
|
21
|
+
html`<usa-button href="#" variant=${variant}>Hello World (Link)</usa-button> ${
|
|
22
|
+
i === BUTTON_VARIANTS.length - 1 ? "" : "\n\n"
|
|
23
|
+
}`,
|
|
24
|
+
)}
|
|
19
25
|
<usa-button disabled>Disabled</usa-button>
|
|
20
26
|
</div>
|
|
21
27
|
`;
|
|
@@ -86,22 +86,22 @@ declare global {
|
|
|
86
86
|
<div class="container">
|
|
87
87
|
<input type="file" tabindex="0"/>
|
|
88
88
|
|
|
89
|
-
<j-if bind="
|
|
90
|
-
|
|
89
|
+
<j-if bind="filesVisible">
|
|
90
|
+
<template>
|
|
91
|
+
<j-props>
|
|
92
|
+
<usa-file-input-preview $.files="files">
|
|
93
|
+
Selected file <usa-link>Change file</usa-link>
|
|
94
|
+
</usa-file-input-preview>
|
|
95
|
+
</j-props>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<template else>
|
|
91
99
|
<div class="box">
|
|
92
100
|
<slot name="description">
|
|
93
101
|
Drag file here or <usa-link>choose from folder</usa-link>
|
|
94
102
|
</slot>
|
|
95
103
|
</div>
|
|
96
104
|
</template>
|
|
97
|
-
|
|
98
|
-
<template else>
|
|
99
|
-
<j-props>
|
|
100
|
-
<usa-file-input-preview $.files="files">
|
|
101
|
-
Selected file <usa-link>Change file</usa-link>
|
|
102
|
-
</usa-file-input-preview>
|
|
103
|
-
</j-props>
|
|
104
|
-
</template>
|
|
105
105
|
</j-if>
|
|
106
106
|
</div>
|
|
107
107
|
</label>
|
|
@@ -218,6 +218,7 @@ export class USAFileInputElement extends HTMLElement {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
this.files = data.files;
|
|
221
|
+
this.filesVisible = !!this.files?.length;
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
}
|
|
@@ -44,4 +44,36 @@ describe("usa-file-input", () => {
|
|
|
44
44
|
|
|
45
45
|
assert.deepEqual(fileNames, ["first.txt", "second.txt"]);
|
|
46
46
|
});
|
|
47
|
+
|
|
48
|
+
it("should show file preview after drag and drop", async () => {
|
|
49
|
+
const fileInput = await fixture<USAFileInputElement>(html`
|
|
50
|
+
<usa-file-input>
|
|
51
|
+
Input accepts a single file
|
|
52
|
+
</usa-file-input>
|
|
53
|
+
`);
|
|
54
|
+
|
|
55
|
+
const nativeInput = fileInput.shadowRoot?.querySelector("input");
|
|
56
|
+
|
|
57
|
+
assert.isOk(nativeInput);
|
|
58
|
+
|
|
59
|
+
// Simulate drag and drop with a file
|
|
60
|
+
const data = new DataTransfer();
|
|
61
|
+
data.items.add(new File([], "test.txt"));
|
|
62
|
+
|
|
63
|
+
const dropEvent = new DragEvent("drop", {
|
|
64
|
+
dataTransfer: data,
|
|
65
|
+
bubbles: true,
|
|
66
|
+
cancelable: true,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
nativeInput.dispatchEvent(dropEvent);
|
|
70
|
+
|
|
71
|
+
// Wait for effects to resolve
|
|
72
|
+
await Promise.resolve();
|
|
73
|
+
|
|
74
|
+
// Verify that filesVisible is true and files are set
|
|
75
|
+
assert.isTrue(fileInput.filesVisible);
|
|
76
|
+
assert.equal(fileInput.files?.length, 1);
|
|
77
|
+
assert.equal(fileInput.files?.[0].name, "test.txt");
|
|
78
|
+
});
|
|
47
79
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, injectable
|
|
1
|
+
import { inject, injectable } from "@joist/di";
|
|
2
2
|
import { attr, css, element } from "@joist/element";
|
|
3
3
|
|
|
4
4
|
import { IconService } from "../services/icon.service.js";
|
|
@@ -41,12 +41,6 @@ export class USAIconElement extends HTMLElement {
|
|
|
41
41
|
#icon = inject(IconService);
|
|
42
42
|
#injected = false;
|
|
43
43
|
|
|
44
|
-
@injected()
|
|
45
|
-
onInjected() {
|
|
46
|
-
this.#injected = true;
|
|
47
|
-
this.#updateIcon();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
44
|
attributeChangedCallback(_: string, newVal: string, oldVal: string) {
|
|
51
45
|
if (this.#injected) {
|
|
52
46
|
if (newVal !== oldVal) {
|
|
@@ -55,6 +49,11 @@ export class USAIconElement extends HTMLElement {
|
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
51
|
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
this.#injected = true;
|
|
54
|
+
this.#updateIcon();
|
|
55
|
+
}
|
|
56
|
+
|
|
58
57
|
async #updateIcon() {
|
|
59
58
|
const icon = this.#icon();
|
|
60
59
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "@joist/templating/define.js";
|
|
1
2
|
declare global {
|
|
2
3
|
interface HTMLElementTagNameMap {
|
|
3
4
|
"usa-button": USAButtonElement;
|
|
@@ -12,8 +13,8 @@ export declare class USAButtonElement extends HTMLElement {
|
|
|
12
13
|
accessor disabled: boolean;
|
|
13
14
|
accessor variant: ButtonVariant;
|
|
14
15
|
accessor value: string;
|
|
16
|
+
accessor href: string;
|
|
17
|
+
accessor target: string;
|
|
15
18
|
accessor tabIndex: number;
|
|
16
|
-
onReady(): void;
|
|
17
19
|
onInternalClick(): void;
|
|
18
|
-
attributeChangedCallback(): void;
|
|
19
20
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import
|
|
2
|
+
import "@joist/templating/define.js";
|
|
3
|
+
import { attr, css, element, html, listen } from "@joist/element";
|
|
4
|
+
import { bind } from "@joist/templating";
|
|
3
5
|
export const BUTTON_VARIANTS = [
|
|
4
6
|
"primary",
|
|
5
7
|
"secondary",
|
|
@@ -15,8 +17,8 @@ let USAButtonElement = (() => {
|
|
|
15
17
|
delegatesFocus: true,
|
|
16
18
|
},
|
|
17
19
|
shadowDom: [
|
|
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;
|
|
19
|
-
html `<button tabindex="0"><slot></slot></button>`,
|
|
20
|
+
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;overflow:hidden}a,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;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}}:is(button,a):visited{color:#fff}:is(button,a):hover{color:#fff;background-color:#1a4480;border-bottom:0;text-decoration:none}:is(button,a):active{color:#fff;background-color:#162e51}:is(button,a):not([disabled]):focus{outline-offset:0.25rem}:is(button,a):disabled{color:#454545;background-color:#c9c9c9;cursor:not-allowed;opacity:1}:is(button,a):disabled:active,:is(button,a):disabled:focus,:is(button,a):disabled:hover{color:#454545;background-color:#c9c9c9}:is(button,a):focus{outline:.25rem solid #2491ff;outline-offset:0}:host([variant=secondary]) :is(button,a){color:#fff;background-color:#d83933}:host([variant=secondary]) :is(button,a):hover{background-color:#b50909}:host([variant=secondary]) :is(button,a):active{background-color:#8b0a03}:host([variant=cool]) :is(button,a){color:#1b1b1b;background-color:#00bde3}:host([variant=cool]) :is(button,a):hover{background-color:#28a0cb}:host([variant=cool]) :is(button,a):active{color:#fff;background-color:#07648d}:host([variant=warm]) :is(button,a){color:#1b1b1b;background-color:#fa9441}:host([variant=warm]) :is(button,a):hover{color:#fff;background-color:#c05600}:host([variant=warm]) :is(button,a):active{color:#fff;background-color:#775540}:host([variant=outline]) :is(button,a){background-color:transparent;box-shadow:inset 0 0 0 2px #005ea2;color:#005ea2}:host([variant=outline]) :is(button,a):hover{box-shadow:inset 0 0 0 2px #1a4480;color:#1a4480}:host([variant=outline]) :is(button,a):active{box-shadow:inset 0 0 0 2px #162e51;color:#162e51}`,
|
|
21
|
+
html `<j-if bind="href"><template><j-props><a $href="href" $disabled="disabled" $target="target"><slot></slot></a></j-props></template><template else><j-props><button tabindex="0" $type="type" $disabled="disabled" $value="value"><slot></slot></button></j-props></template></j-if>`,
|
|
20
22
|
],
|
|
21
23
|
})];
|
|
22
24
|
let _classDescriptor;
|
|
@@ -36,23 +38,30 @@ let USAButtonElement = (() => {
|
|
|
36
38
|
let _value_decorators;
|
|
37
39
|
let _value_initializers = [];
|
|
38
40
|
let _value_extraInitializers = [];
|
|
39
|
-
let
|
|
41
|
+
let _href_decorators;
|
|
42
|
+
let _href_initializers = [];
|
|
43
|
+
let _href_extraInitializers = [];
|
|
44
|
+
let _target_decorators;
|
|
45
|
+
let _target_initializers = [];
|
|
46
|
+
let _target_extraInitializers = [];
|
|
40
47
|
let _onInternalClick_decorators;
|
|
41
48
|
var USAButtonElement = class extends _classSuper {
|
|
42
49
|
static { _classThis = this; }
|
|
43
50
|
static {
|
|
44
51
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
45
|
-
_type_decorators = [attr()];
|
|
46
|
-
_disabled_decorators = [attr()];
|
|
52
|
+
_type_decorators = [attr(), bind()];
|
|
53
|
+
_disabled_decorators = [attr(), bind()];
|
|
47
54
|
_variant_decorators = [attr()];
|
|
48
|
-
_value_decorators = [attr()];
|
|
49
|
-
|
|
55
|
+
_value_decorators = [attr(), bind()];
|
|
56
|
+
_href_decorators = [attr(), bind()];
|
|
57
|
+
_target_decorators = [attr(), bind()];
|
|
50
58
|
_onInternalClick_decorators = [listen("click")];
|
|
51
59
|
__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);
|
|
52
60
|
__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);
|
|
53
61
|
__esDecorate(this, null, _variant_decorators, { kind: "accessor", name: "variant", static: false, private: false, access: { has: obj => "variant" in obj, get: obj => obj.variant, set: (obj, value) => { obj.variant = value; } }, metadata: _metadata }, _variant_initializers, _variant_extraInitializers);
|
|
54
62
|
__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);
|
|
55
|
-
__esDecorate(this, null,
|
|
63
|
+
__esDecorate(this, null, _href_decorators, { kind: "accessor", name: "href", static: false, private: false, access: { has: obj => "href" in obj, get: obj => obj.href, set: (obj, value) => { obj.href = value; } }, metadata: _metadata }, _href_initializers, _href_extraInitializers);
|
|
64
|
+
__esDecorate(this, null, _target_decorators, { kind: "accessor", name: "target", static: false, private: false, access: { has: obj => "target" in obj, get: obj => obj.target, set: (obj, value) => { obj.target = value; } }, metadata: _metadata }, _target_initializers, _target_extraInitializers);
|
|
56
65
|
__esDecorate(this, null, _onInternalClick_decorators, { kind: "method", name: "onInternalClick", static: false, private: false, access: { has: obj => "onInternalClick" in obj, get: obj => obj.onInternalClick }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
57
66
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
58
67
|
USAButtonElement = _classThis = _classDescriptor.value;
|
|
@@ -71,20 +80,19 @@ let USAButtonElement = (() => {
|
|
|
71
80
|
#value_accessor_storage = (__runInitializers(this, _variant_extraInitializers), __runInitializers(this, _value_initializers, ""));
|
|
72
81
|
get value() { return this.#value_accessor_storage; }
|
|
73
82
|
set value(value) { this.#value_accessor_storage = value; }
|
|
74
|
-
#
|
|
83
|
+
#href_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _href_initializers, ""));
|
|
84
|
+
get href() { return this.#href_accessor_storage; }
|
|
85
|
+
set href(value) { this.#href_accessor_storage = value; }
|
|
86
|
+
#target_accessor_storage = (__runInitializers(this, _href_extraInitializers), __runInitializers(this, _target_initializers, ""));
|
|
87
|
+
get target() { return this.#target_accessor_storage; }
|
|
88
|
+
set target(value) { this.#target_accessor_storage = value; }
|
|
89
|
+
#tabIndex_accessor_storage = (__runInitializers(this, _target_extraInitializers), 0);
|
|
75
90
|
get tabIndex() { return this.#tabIndex_accessor_storage; }
|
|
76
91
|
set tabIndex(value) { this.#tabIndex_accessor_storage = value; }
|
|
77
92
|
#internals = this.attachInternals();
|
|
78
|
-
#button = query("button");
|
|
79
|
-
onReady() {
|
|
80
|
-
this.#button({ autofocus: this.autofocus });
|
|
81
|
-
}
|
|
82
93
|
onInternalClick() {
|
|
83
94
|
this.#handleForm();
|
|
84
95
|
}
|
|
85
|
-
attributeChangedCallback() {
|
|
86
|
-
this.#button({ type: this.type, disabled: this.disabled });
|
|
87
|
-
}
|
|
88
96
|
#handleForm() {
|
|
89
97
|
const { form } = this.#internals;
|
|
90
98
|
if (form) {
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"button.element.js","sourceRoot":"","sources":["../../../src/lib/button/button.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;AAQzC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS;IACT,WAAW;IACX,MAAM;IACN,MAAM;IACN,SAAS;CACD,CAAC;IA8KE,gBAAgB;4BA1K5B,OAAO,CAAC;YACP,OAAO,EAAE,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line-flex;flex-direction:column;gap:1rem">${BUTTON_VARIANTS.map((variant, i) => html `<usa-button variant="${variant}">Hello World</usa-button>${i === BUTTON_VARIANTS.length - 1 ? "" : "\n\n"}`)}<usa-button disabled="disabled">Disabled</usa-button></div>`;
|
|
8
|
+
return html `<div style="display:inline-flex;flex-direction:column;gap:1rem">${BUTTON_VARIANTS.map((variant, i) => html `<usa-button variant="${variant}">Hello World</usa-button>${i === BUTTON_VARIANTS.length - 1 ? "" : "\n\n"}`)} ${BUTTON_VARIANTS.map((variant, i) => html `<usa-button href="#" variant="${variant}">Hello World (Link)</usa-button>${i === BUTTON_VARIANTS.length - 1 ? "" : "\n\n"}`)}<usa-button disabled="disabled">Disabled</usa-button></div>`;
|
|
9
9
|
},
|
|
10
10
|
argTypes: {},
|
|
11
11
|
args: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.stories.js","sourceRoot":"","sources":["../../../src/lib/button/button.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AAE7E,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;;UAEL,eAAe,CAAC,GAAG,CACnB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CACb,IAAI,CAAA,uBAAuB,OAAO,6BAChC,CAAC,KAAK,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAC1C,EAAE,CACL;;;KAGJ,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACwB,CAAC;AAEnC,eAAe,IAAI,CAAC;AAIpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
1
|
+
{"version":3,"file":"button.stories.js","sourceRoot":"","sources":["../../../src/lib/button/button.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAyB,MAAM,qBAAqB,CAAC;AAE7E,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;;UAEL,eAAe,CAAC,GAAG,CACnB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CACb,IAAI,CAAA,uBAAuB,OAAO,6BAChC,CAAC,KAAK,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAC1C,EAAE,CACL;UACC,eAAe,CAAC,GAAG,CACnB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CACb,IAAI,CAAA,gCAAgC,OAAO,oCACzC,CAAC,KAAK,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAC1C,EAAE,CACL;;;KAGJ,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACwB,CAAC;AAEnC,eAAe,IAAI,CAAC;AAIpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -8,7 +8,7 @@ let USAFileInputElement = (() => {
|
|
|
8
8
|
tagName: "usa-file-input",
|
|
9
9
|
shadowDom: [
|
|
10
10
|
css `*{box-sizing:border-box}:host{--usa-input-radius:0;--usa-input-bg-color:#d9e8f6;display:block;max-width:30rem;position:relative;margin-bottom:1.5rem}label{display:block}input{cursor:pointer;left:0;margin:0;max-width:none;position:absolute;text-indent:-999em;width:100%;z-index:1;bottom:0;top:0}input:focus{outline:.25rem solid #2491ff;outline-offset:0}label slot.label{font-size:1.06rem;line-height:1.3;display:block;font-weight:400;margin-bottom:.5rem}:host(.dragenter) .box{border-color:#2491ff}.box{border:1px dashed #adadad;border-radius:var(--usa-input-radius);display:flex;font-size:.93rem;position:relative;text-align:center;width:100%;height:5.2rem;align-items:center;justify-content:center}.container{position:relative}`,
|
|
11
|
-
html `<label><slot class="label"></slot><div class="container"><input type="file" tabindex="0"><j-if bind="
|
|
11
|
+
html `<label><slot class="label"></slot><div class="container"><input type="file" tabindex="0"><j-if bind="filesVisible"><template><j-props><usa-file-input-preview $.files="files">Selected file<usa-link>Change file</usa-link></usa-file-input-preview></j-props></template><template else><div class="box"><slot name="description">Drag file here or<usa-link>choose from folder</usa-link></slot></div></template></j-if></div></label>`,
|
|
12
12
|
],
|
|
13
13
|
})];
|
|
14
14
|
let _classDescriptor;
|
|
@@ -146,6 +146,7 @@ let USAFileInputElement = (() => {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
this.files = data.files;
|
|
149
|
+
this.filesVisible = !!this.files?.length;
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
static {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.element.js","sourceRoot":"","sources":["../../../src/lib/file-input/file-input.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;IA0G5B,mBAAmB;4BAlG/B,OAAO,CAAC;YACP,OAAO,EAAE,gBAAgB;YACzB,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBACvB,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBACxB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC;YAC3C,CAAC;QACH,CAAC;;YAhHU,uDAAmB;;;;;SAAnB,mBAAmB"}
|
|
@@ -19,5 +19,25 @@ describe("usa-file-input", () => {
|
|
|
19
19
|
});
|
|
20
20
|
assert.deepEqual(fileNames, ["first.txt", "second.txt"]);
|
|
21
21
|
});
|
|
22
|
+
it("should show file preview after drag and drop", async () => {
|
|
23
|
+
const fileInput = await fixture(html `<usa-file-input>Input accepts a single file</usa-file-input>`);
|
|
24
|
+
const nativeInput = fileInput.shadowRoot?.querySelector("input");
|
|
25
|
+
assert.isOk(nativeInput);
|
|
26
|
+
// Simulate drag and drop with a file
|
|
27
|
+
const data = new DataTransfer();
|
|
28
|
+
data.items.add(new File([], "test.txt"));
|
|
29
|
+
const dropEvent = new DragEvent("drop", {
|
|
30
|
+
dataTransfer: data,
|
|
31
|
+
bubbles: true,
|
|
32
|
+
cancelable: true,
|
|
33
|
+
});
|
|
34
|
+
nativeInput.dispatchEvent(dropEvent);
|
|
35
|
+
// Wait for effects to resolve
|
|
36
|
+
await Promise.resolve();
|
|
37
|
+
// Verify that filesVisible is true and files are set
|
|
38
|
+
assert.isTrue(fileInput.filesVisible);
|
|
39
|
+
assert.equal(fileInput.files?.length, 1);
|
|
40
|
+
assert.equal(fileInput.files?.[0].name, "test.txt");
|
|
41
|
+
});
|
|
22
42
|
});
|
|
23
43
|
//# sourceMappingURL=file-input.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.test.js","sourceRoot":"","sources":["../../../src/lib/file-input/file-input.test.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAAE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,EAAE;QAC5D,MAAM,SAAS,GAAG,MAAM,OAAO,CAAsB,IAAI,CAAA;;;;KAIxD,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;QAEjE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEzB,qCAAqC;QACrC,MAAM,IAAI,GAAG,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC;QAEzC,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,EAAE;YACtC,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;QAErC,8BAA8B;QAC9B,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QAExB,qDAAqD;QACrD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { inject, injectable
|
|
2
|
+
import { inject, injectable } from "@joist/di";
|
|
3
3
|
import { attr, css, element } from "@joist/element";
|
|
4
4
|
import { IconService } from "../services/icon.service.js";
|
|
5
5
|
let USAIconElement = (() => {
|
|
@@ -15,34 +15,26 @@ let USAIconElement = (() => {
|
|
|
15
15
|
let _classExtraInitializers = [];
|
|
16
16
|
let _classThis;
|
|
17
17
|
let _classSuper = HTMLElement;
|
|
18
|
-
let _instanceExtraInitializers = [];
|
|
19
18
|
let _icon_decorators;
|
|
20
19
|
let _icon_initializers = [];
|
|
21
20
|
let _icon_extraInitializers = [];
|
|
22
|
-
let _onInjected_decorators;
|
|
23
21
|
var USAIconElement = class extends _classSuper {
|
|
24
22
|
static { _classThis = this; }
|
|
25
23
|
static {
|
|
26
24
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
27
25
|
_icon_decorators = [attr()];
|
|
28
|
-
_onInjected_decorators = [injected()];
|
|
29
26
|
__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);
|
|
30
|
-
__esDecorate(this, null, _onInjected_decorators, { kind: "method", name: "onInjected", static: false, private: false, access: { has: obj => "onInjected" in obj, get: obj => obj.onInjected }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
31
27
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
32
28
|
USAIconElement = _classThis = _classDescriptor.value;
|
|
33
29
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
34
30
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
35
31
|
}
|
|
36
|
-
#icon_accessor_storage =
|
|
32
|
+
#icon_accessor_storage = __runInitializers(this, _icon_initializers, "accessibility_new");
|
|
37
33
|
get icon() { return this.#icon_accessor_storage; }
|
|
38
34
|
set icon(value) { this.#icon_accessor_storage = value; }
|
|
39
35
|
ariaHidden = (__runInitializers(this, _icon_extraInitializers), "true");
|
|
40
36
|
#icon = inject(IconService);
|
|
41
37
|
#injected = false;
|
|
42
|
-
onInjected() {
|
|
43
|
-
this.#injected = true;
|
|
44
|
-
this.#updateIcon();
|
|
45
|
-
}
|
|
46
38
|
attributeChangedCallback(_, newVal, oldVal) {
|
|
47
39
|
if (this.#injected) {
|
|
48
40
|
if (newVal !== oldVal) {
|
|
@@ -50,6 +42,10 @@ let USAIconElement = (() => {
|
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
}
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
this.#injected = true;
|
|
47
|
+
this.#updateIcon();
|
|
48
|
+
}
|
|
53
49
|
async #updateIcon() {
|
|
54
50
|
const icon = this.#icon();
|
|
55
51
|
if (this.shadowRoot) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.element.js","sourceRoot":"","sources":["../../../src/lib/icon/icon.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"icon.element.js","sourceRoot":"","sources":["../../../src/lib/icon/icon.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;IA+B7C,cAAc;4BAtB1B,OAAO,CAAC;YACP,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;KAaF;aACF;SACF,CAAC,EACD,UAAU,CAAC;YACV,IAAI,EAAE,cAAc;SACrB,CAAC;;;;sBACkC,WAAW;;;;8BAAnB,SAAQ,WAAW;;;;gCAC5C,IAAI,EAAE;YACP,iKAAS,IAAI,6BAAJ,IAAI,mFAAgC;YAF/C,6KAmCC;;;YAnCY,uDAAc;;QAEzB,qEAAyB,mBAAmB,EAAC;QAA7C,IAAS,IAAI,0CAAgC;QAA7C,IAA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