@noctuatech/uswds 0.0.34 → 0.0.36
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 +12 -11
- package/src/lib/accordion/accordion.stories.ts +1 -1
- package/src/lib/button/button.stories.ts +1 -0
- package/src/lib/card/card.test.ts +1 -1
- package/src/lib/checkbox/checkbox-group/checkbox-group.element.ts +24 -0
- package/src/lib/checkbox/checkbox.element.ts +26 -13
- package/src/lib/checkbox/checkbox.stories.ts +73 -35
- package/src/lib/collection/collection-item/collection-item.element.ts +2 -2
- package/src/lib/collection/collection.stories.ts +19 -3
- package/src/lib/define.ts +1 -0
- package/src/lib/file-input/file-input.element.ts +27 -1
- package/src/lib/file-input/file-input.stories.ts +2 -2
- package/src/lib/icon/icon.element.ts +14 -4
- package/src/lib/input/input.element.ts +30 -7
- package/src/lib/radio/context.ts +1 -0
- package/src/lib/radio/radio-option/radio-option.element.ts +24 -15
- package/src/lib/radio/radio.element.ts +31 -11
- package/src/lib/radio/radio.stories.ts +2 -7
- package/src/lib/select/select.element.ts +16 -6
- package/src/lib/tag/tag.element.ts +12 -2
- package/src/lib/textarea/textarea.element.ts +18 -13
- package/src/lib.ts +1 -0
- package/target/lib/accordion/accordion.stories.d.ts +1 -1
- package/target/lib/accordion/accordion.stories.js +1 -1
- package/target/lib/accordion/accordion.stories.js.map +1 -1
- package/target/lib/button/button.stories.js +1 -0
- package/target/lib/button/button.stories.js.map +1 -1
- package/target/lib/card/card.test.js +1 -1
- package/target/lib/checkbox/checkbox-group/checkbox-group.element.d.ts +7 -0
- package/target/lib/checkbox/checkbox-group/checkbox-group.element.js +36 -0
- package/target/lib/checkbox/checkbox-group/checkbox-group.element.js.map +1 -0
- package/target/lib/checkbox/checkbox.element.js +23 -12
- package/target/lib/checkbox/checkbox.element.js.map +1 -1
- package/target/lib/checkbox/checkbox.stories.d.ts +4 -23
- package/target/lib/checkbox/checkbox.stories.js +72 -34
- package/target/lib/checkbox/checkbox.stories.js.map +1 -1
- package/target/lib/collection/collection-item/collection-item.element.js +2 -2
- package/target/lib/collection/collection.stories.d.ts +1 -1
- package/target/lib/collection/collection.stories.js +19 -3
- package/target/lib/collection/collection.stories.js.map +1 -1
- package/target/lib/define.d.ts +1 -0
- package/target/lib/define.js +1 -0
- package/target/lib/define.js.map +1 -1
- package/target/lib/file-input/file-input.element.d.ts +2 -0
- package/target/lib/file-input/file-input.element.js +23 -2
- package/target/lib/file-input/file-input.element.js.map +1 -1
- package/target/lib/file-input/file-input.stories.d.ts +1 -1
- package/target/lib/file-input/file-input.stories.js +2 -2
- package/target/lib/file-input/file-input.stories.js.map +1 -1
- package/target/lib/form/validation.d.ts +2 -0
- package/target/lib/form/validation.js +27 -0
- package/target/lib/form/validation.js.map +1 -0
- package/target/lib/icon/icon.element.d.ts +1 -1
- package/target/lib/icon/icon.element.js +14 -4
- package/target/lib/icon/icon.element.js.map +1 -1
- package/target/lib/input/input.element.d.ts +4 -0
- package/target/lib/input/input.element.js +47 -8
- package/target/lib/input/input.element.js.map +1 -1
- package/target/lib/radio/context.d.ts +1 -0
- package/target/lib/radio/context.js.map +1 -1
- package/target/lib/radio/radio-option/radio-option.element.d.ts +1 -0
- package/target/lib/radio/radio-option/radio-option.element.js +28 -16
- package/target/lib/radio/radio-option/radio-option.element.js.map +1 -1
- package/target/lib/radio/radio.element.d.ts +0 -1
- package/target/lib/radio/radio.element.js +29 -8
- package/target/lib/radio/radio.element.js.map +1 -1
- package/target/lib/radio/radio.stories.d.ts +0 -1
- package/target/lib/radio/radio.stories.js +2 -4
- package/target/lib/radio/radio.stories.js.map +1 -1
- package/target/lib/select/select.element.js +13 -4
- package/target/lib/select/select.element.js.map +1 -1
- package/target/lib/tag/tag.element.d.ts +3 -0
- package/target/lib/tag/tag.element.js +17 -3
- package/target/lib/tag/tag.element.js.map +1 -1
- package/target/lib/textarea/textarea.element.d.ts +1 -1
- package/target/lib/textarea/textarea.element.js +12 -11
- package/target/lib/textarea/textarea.element.js.map +1 -1
- package/target/lib.d.ts +1 -0
- package/target/lib.js +1 -0
- package/target/lib.js.map +1 -1
|
@@ -61,6 +61,23 @@ declare global {
|
|
|
61
61
|
inset 0 0 0 2px #fff;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
label:has(input:checked:is(:disabled))::before {
|
|
65
|
+
background-color: #757575;
|
|
66
|
+
box-shadow:
|
|
67
|
+
0 0 0 2px #757575,
|
|
68
|
+
inset 0 0 0 2px #fff;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
label:has(input:disabled) {
|
|
72
|
+
cursor: not-allowed;
|
|
73
|
+
color: #757575 !important;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
label:has(input:disabled)::before {
|
|
77
|
+
background-color: #fff;
|
|
78
|
+
box-shadow: 0 0 0 2px #757575;
|
|
79
|
+
}
|
|
80
|
+
|
|
64
81
|
label:has(input:focus)::before {
|
|
65
82
|
outline: 0.25rem solid var(--usa-radio-focus-color);
|
|
66
83
|
outline-offset: 0.25rem;
|
|
@@ -83,6 +100,11 @@ declare global {
|
|
|
83
100
|
border-color: var(--usa-radio-active-color);
|
|
84
101
|
}
|
|
85
102
|
|
|
103
|
+
:host([tiled]) label:has(input:checked:is(:disabled)) {
|
|
104
|
+
background-color: #fff;
|
|
105
|
+
border-color: #757575;
|
|
106
|
+
}
|
|
107
|
+
|
|
86
108
|
slot {
|
|
87
109
|
display: flex;
|
|
88
110
|
}
|
|
@@ -112,15 +134,15 @@ export class USARadioElement extends HTMLElement implements RadioContainer {
|
|
|
112
134
|
accessor tiled = false;
|
|
113
135
|
|
|
114
136
|
#internals = this.attachInternals();
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
connectedCallback() {
|
|
118
|
-
this.#syncFormState();
|
|
119
|
-
}
|
|
137
|
+
#firstInput: HTMLInputElement | null = null;
|
|
120
138
|
|
|
121
139
|
addRadioOption(el: HTMLElement) {
|
|
122
140
|
this.shadowRoot?.append(el);
|
|
123
141
|
|
|
142
|
+
if (this.#firstInput === null) {
|
|
143
|
+
this.#firstInput = el.querySelector("input");
|
|
144
|
+
}
|
|
145
|
+
|
|
124
146
|
this.#syncFormState();
|
|
125
147
|
}
|
|
126
148
|
|
|
@@ -139,13 +161,11 @@ export class USARadioElement extends HTMLElement implements RadioContainer {
|
|
|
139
161
|
this.#internals.setFormValue(this.value);
|
|
140
162
|
this.#internals.setValidity({});
|
|
141
163
|
|
|
142
|
-
if (this
|
|
143
|
-
const input = this.shadowRoot?.querySelector("input");
|
|
144
|
-
|
|
164
|
+
if (this.#firstInput?.validationMessage) {
|
|
145
165
|
this.#internals.setValidity(
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
{ customError: true },
|
|
167
|
+
this.#firstInput.validationMessage,
|
|
168
|
+
this.#firstInput,
|
|
149
169
|
);
|
|
150
170
|
}
|
|
151
171
|
}
|
|
@@ -23,17 +23,14 @@ const meta = {
|
|
|
23
23
|
|
|
24
24
|
<usa-radio-option value="frederick-douglass">
|
|
25
25
|
Frederick Douglass
|
|
26
|
-
|
|
27
|
-
args.description,
|
|
28
|
-
() => html`<usa-description>${args.description}</usa-description>`,
|
|
29
|
-
)}
|
|
26
|
+
<usa-description>This is optional text that can be used to describe the label in more detail.</usa-description>
|
|
30
27
|
</usa-radio-option>
|
|
31
28
|
|
|
32
29
|
<usa-radio-option value="booker-t-washington">
|
|
33
30
|
Booker T. Washington
|
|
34
31
|
</usa-radio-option>
|
|
35
32
|
|
|
36
|
-
<usa-radio-option value="george-washington-carver">
|
|
33
|
+
<usa-radio-option value="george-washington-carver" disabled>
|
|
37
34
|
George Washington Carver
|
|
38
35
|
</usa-radio-option>
|
|
39
36
|
</usa-radio>
|
|
@@ -42,8 +39,6 @@ const meta = {
|
|
|
42
39
|
argTypes: {},
|
|
43
40
|
args: {
|
|
44
41
|
tiled: true,
|
|
45
|
-
description:
|
|
46
|
-
"This is optional text that can be used to describe the label in more detail.",
|
|
47
42
|
},
|
|
48
43
|
} satisfies Meta<USARadioElement & { description: string }>;
|
|
49
44
|
|
|
@@ -83,13 +83,21 @@ export class USASelectElement extends HTMLElement implements SelectContainer {
|
|
|
83
83
|
#internals = this.attachInternals();
|
|
84
84
|
|
|
85
85
|
connectedCallback() {
|
|
86
|
-
this.#select({
|
|
86
|
+
this.#select({
|
|
87
|
+
value: this.value,
|
|
88
|
+
name: this.name,
|
|
89
|
+
required: this.required,
|
|
90
|
+
});
|
|
87
91
|
|
|
88
92
|
this.#syncFormState();
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
attributeChangedCallback() {
|
|
92
|
-
this.#select({
|
|
96
|
+
this.#select({
|
|
97
|
+
value: this.value,
|
|
98
|
+
name: this.name,
|
|
99
|
+
required: this.required,
|
|
100
|
+
});
|
|
93
101
|
|
|
94
102
|
this.#syncFormState();
|
|
95
103
|
}
|
|
@@ -109,14 +117,16 @@ export class USASelectElement extends HTMLElement implements SelectContainer {
|
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
#syncFormState() {
|
|
120
|
+
const select = this.#select();
|
|
121
|
+
|
|
112
122
|
this.#internals.setFormValue(this.value);
|
|
113
123
|
this.#internals.setValidity({});
|
|
114
124
|
|
|
115
|
-
if (
|
|
125
|
+
if (select.validationMessage) {
|
|
116
126
|
this.#internals.setValidity(
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
{ customError: true },
|
|
128
|
+
select.validationMessage,
|
|
129
|
+
select,
|
|
120
130
|
);
|
|
121
131
|
}
|
|
122
132
|
}
|
|
@@ -7,8 +7,10 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export const TAG_VARIANTS = ["default", "big"] as const;
|
|
10
|
+
export const TAG_TYPES = ["new", "default"] as const;
|
|
10
11
|
|
|
11
12
|
export type TagVariant = (typeof TAG_VARIANTS)[number];
|
|
13
|
+
export type TagType = (typeof TAG_TYPES)[number];
|
|
12
14
|
|
|
13
15
|
@element({
|
|
14
16
|
tagName: "usa-tag",
|
|
@@ -16,9 +18,9 @@ export type TagVariant = (typeof TAG_VARIANTS)[number];
|
|
|
16
18
|
css`
|
|
17
19
|
:host {
|
|
18
20
|
font-size: 0.93rem;
|
|
19
|
-
color: #
|
|
21
|
+
color: #1b1b1b;
|
|
20
22
|
text-transform: uppercase;
|
|
21
|
-
background-color: #
|
|
23
|
+
background-color: #e6e6e6;
|
|
22
24
|
border-radius: 2px;
|
|
23
25
|
margin-right: 0.25rem;
|
|
24
26
|
padding: 1px 0.5rem;
|
|
@@ -29,6 +31,11 @@ export type TagVariant = (typeof TAG_VARIANTS)[number];
|
|
|
29
31
|
padding-right: 0.5rem;
|
|
30
32
|
font-size: 1.06rem;
|
|
31
33
|
}
|
|
34
|
+
|
|
35
|
+
:host([type="new"]) {
|
|
36
|
+
background-color: #c05600;
|
|
37
|
+
color: #fff;
|
|
38
|
+
}
|
|
32
39
|
`,
|
|
33
40
|
html`<slot></slot>`,
|
|
34
41
|
],
|
|
@@ -36,4 +43,7 @@ export type TagVariant = (typeof TAG_VARIANTS)[number];
|
|
|
36
43
|
export class USATagElement extends HTMLElement {
|
|
37
44
|
@attr()
|
|
38
45
|
accessor variant: TagVariant = "default";
|
|
46
|
+
|
|
47
|
+
@attr()
|
|
48
|
+
accessor type: TagType = "default";
|
|
39
49
|
}
|
|
@@ -87,8 +87,16 @@ export class USATextareaElement extends HTMLElement {
|
|
|
87
87
|
|
|
88
88
|
@ready()
|
|
89
89
|
onReady() {
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
this.#input({ autofocus: this.autofocus });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
attributeChangedCallback() {
|
|
94
|
+
this.#input({
|
|
95
|
+
name: this.name,
|
|
96
|
+
placeholder: this.placeholder,
|
|
97
|
+
autocomplete: this.autocomplete,
|
|
98
|
+
required: this.required,
|
|
99
|
+
});
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
connectedCallback() {
|
|
@@ -107,21 +115,18 @@ export class USATextareaElement extends HTMLElement {
|
|
|
107
115
|
this.value = this.#input().value;
|
|
108
116
|
}
|
|
109
117
|
|
|
110
|
-
attributeChangedCallback() {
|
|
111
|
-
const { name, placeholder, autocomplete } = this;
|
|
112
|
-
|
|
113
|
-
this.#input({ name, placeholder, autocomplete });
|
|
114
|
-
}
|
|
115
|
-
|
|
116
118
|
#syncFormState() {
|
|
117
119
|
const input = this.#input();
|
|
118
120
|
|
|
119
121
|
this.#internals.setFormValue(input.value);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
this.#internals.setValidity({});
|
|
123
|
+
|
|
124
|
+
if (input.validationMessage) {
|
|
125
|
+
this.#internals.setValidity(
|
|
126
|
+
{ customError: true },
|
|
127
|
+
input.validationMessage,
|
|
128
|
+
input,
|
|
129
|
+
);
|
|
125
130
|
}
|
|
126
131
|
}
|
|
127
132
|
}
|
package/src/lib.ts
CHANGED
|
@@ -32,3 +32,4 @@ export { USACardGroupElement } from "./lib/card/card-group/card-group.element.js
|
|
|
32
32
|
export { USATextareaElement } from "./lib/textarea/textarea.element.js";
|
|
33
33
|
export { USACollectionElement } from "./lib/collection/collection.element.js";
|
|
34
34
|
export { USACollectionItemElement } from "./lib/collection/collection-item/collection-item.element.js";
|
|
35
|
+
export { USACheckboxGroupElement } from "./lib/checkbox/checkbox-group/checkbox-group.element.js";
|
|
@@ -3,7 +3,7 @@ import type { USAAccordionElement } from "./accordion.element.js";
|
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
5
|
tags: string[];
|
|
6
|
-
render(
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
7
7
|
argTypes: {};
|
|
8
8
|
args: {};
|
|
9
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.stories.js","sourceRoot":"","sources":["../../../src/lib/accordion/accordion.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAI3B,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,MAAM
|
|
1
|
+
{"version":3,"file":"accordion.stories.js","sourceRoot":"","sources":["../../../src/lib/accordion/accordion.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAI3B,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAyBV,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CAC2B,CAAC;AAEtC,eAAe,IAAI,CAAC;AAIpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -8,6 +8,7 @@ const meta = {
|
|
|
8
8
|
return html `
|
|
9
9
|
<div style="display: inline-flex; flex-direction: column; gap: 1rem">
|
|
10
10
|
${BUTTON_VARIANTS.map((variant, i) => html `<usa-button variant=${variant}>Hello World</usa-button> ${i === BUTTON_VARIANTS.length - 1 ? "" : "\n\n"}`)}
|
|
11
|
+
<usa-button disabled>Disabled</usa-button>
|
|
11
12
|
</div>
|
|
12
13
|
`;
|
|
13
14
|
},
|
|
@@ -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,CAAC,IAAI;QACT,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
|
|
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,CAAC,IAAI;QACT,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"}
|
|
@@ -11,7 +11,7 @@ describe("usa-card", () => {
|
|
|
11
11
|
<usa-card-group>
|
|
12
12
|
<usa-card>
|
|
13
13
|
<usa-card-media>
|
|
14
|
-
<img
|
|
14
|
+
<img alt="A placeholder image" />
|
|
15
15
|
</usa-card-media>
|
|
16
16
|
|
|
17
17
|
<usa-card-header>Card with media</usa-card-header>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { css, element, html } from "@joist/element";
|
|
3
|
+
let USACheckboxGroupElement = (() => {
|
|
4
|
+
let _classDecorators = [element({
|
|
5
|
+
tagName: "usa-checkbox-group",
|
|
6
|
+
shadowDom: [
|
|
7
|
+
css `
|
|
8
|
+
:host {
|
|
9
|
+
display: flex;
|
|
10
|
+
gap: 0.75rem;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
html `
|
|
15
|
+
<slot></slot>
|
|
16
|
+
`,
|
|
17
|
+
],
|
|
18
|
+
})];
|
|
19
|
+
let _classDescriptor;
|
|
20
|
+
let _classExtraInitializers = [];
|
|
21
|
+
let _classThis;
|
|
22
|
+
let _classSuper = HTMLElement;
|
|
23
|
+
var USACheckboxGroupElement = class extends _classSuper {
|
|
24
|
+
static { _classThis = this; }
|
|
25
|
+
static {
|
|
26
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
27
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
28
|
+
USACheckboxGroupElement = _classThis = _classDescriptor.value;
|
|
29
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
30
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return USACheckboxGroupElement = _classThis;
|
|
34
|
+
})();
|
|
35
|
+
export { USACheckboxGroupElement };
|
|
36
|
+
//# sourceMappingURL=checkbox-group.element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox-group.element.js","sourceRoot":"","sources":["../../../../src/lib/checkbox/checkbox-group/checkbox-group.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;IAuBvC,uBAAuB;4BAfnC,OAAO,CAAC;YACP,OAAO,EAAE,oBAAoB;YAC7B,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;KAMF;gBACD,IAAI,CAAA;;KAEH;aACF;SACF,CAAC;;;;sBAC2C,WAAW;uCAAnB,SAAQ,WAAW;;;;YAAxD,6KAA2D;;;YAA9C,uDAAuB;;;;;SAAvB,uBAAuB"}
|
|
@@ -28,7 +28,7 @@ let USACheckboxElement = (() => {
|
|
|
28
28
|
cursor: pointer;
|
|
29
29
|
font-size: 1.06rem;
|
|
30
30
|
line-height: 1.3;
|
|
31
|
-
|
|
31
|
+
width: 100%;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.checkbox {
|
|
@@ -38,19 +38,20 @@ let USACheckboxElement = (() => {
|
|
|
38
38
|
align-items: center;
|
|
39
39
|
justify-content: center;
|
|
40
40
|
height: 1.25rem;
|
|
41
|
-
width: 1.25rem;
|
|
41
|
+
min-width: 1.25rem;
|
|
42
|
+
max-width: 1.25rem;
|
|
42
43
|
border-radius: 2px;
|
|
43
44
|
position: relative;
|
|
44
45
|
margin-right: 0.75rem;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
input:
|
|
48
|
-
background-color: #
|
|
49
|
-
box-shadow: 0 0 0 2px #
|
|
48
|
+
input:disabled + .checkbox {
|
|
49
|
+
background-color: #fff;
|
|
50
|
+
box-shadow: 0 0 0 2px #757575;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
:
|
|
53
|
-
background-color: #
|
|
53
|
+
input:disabled:is(:checked) + .checkbox {
|
|
54
|
+
background-color: #757575;
|
|
54
55
|
box-shadow: 0 0 0 2px #757575;
|
|
55
56
|
}
|
|
56
57
|
|
|
@@ -58,6 +59,11 @@ let USACheckboxElement = (() => {
|
|
|
58
59
|
color: #757575;
|
|
59
60
|
cursor: not-allowed;
|
|
60
61
|
}
|
|
62
|
+
|
|
63
|
+
input:checked + .checkbox {
|
|
64
|
+
background-color: #005ea2;
|
|
65
|
+
box-shadow: 0 0 0 2px #005ea2;
|
|
66
|
+
}
|
|
61
67
|
|
|
62
68
|
input:checked + .checkbox::after {
|
|
63
69
|
content: " ";
|
|
@@ -93,6 +99,11 @@ let USACheckboxElement = (() => {
|
|
|
93
99
|
background-color: rgba(0, 94, 162, 0.1);
|
|
94
100
|
border-color: #005ea2;
|
|
95
101
|
}
|
|
102
|
+
|
|
103
|
+
:host([tiled]) label:has(input:checked:is(:disabled)) {
|
|
104
|
+
background-color: #fff;
|
|
105
|
+
border-color: #757575;
|
|
106
|
+
}
|
|
96
107
|
`,
|
|
97
108
|
html `
|
|
98
109
|
<label>
|
|
@@ -181,6 +192,7 @@ let USACheckboxElement = (() => {
|
|
|
181
192
|
checked: this.checked,
|
|
182
193
|
name: this.name,
|
|
183
194
|
disabled: this.disabled,
|
|
195
|
+
required: this.required,
|
|
184
196
|
});
|
|
185
197
|
this.#syncFormState();
|
|
186
198
|
}
|
|
@@ -189,6 +201,7 @@ let USACheckboxElement = (() => {
|
|
|
189
201
|
checked: this.checked,
|
|
190
202
|
name: this.name,
|
|
191
203
|
disabled: this.disabled,
|
|
204
|
+
required: this.required,
|
|
192
205
|
});
|
|
193
206
|
this.#syncFormState();
|
|
194
207
|
}
|
|
@@ -199,17 +212,15 @@ let USACheckboxElement = (() => {
|
|
|
199
212
|
}
|
|
200
213
|
#syncFormState() {
|
|
201
214
|
const checkbox = this.#checkbox();
|
|
215
|
+
this.#internals.setValidity({});
|
|
202
216
|
if (checkbox.checked) {
|
|
203
217
|
this.#internals.setFormValue(this.value);
|
|
204
218
|
}
|
|
205
219
|
else {
|
|
206
220
|
this.#internals.setFormValue(null);
|
|
207
221
|
}
|
|
208
|
-
if (
|
|
209
|
-
this.#internals.setValidity({
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
this.#internals.setValidity({});
|
|
222
|
+
if (checkbox.validationMessage) {
|
|
223
|
+
this.#internals.setValidity({ customError: true }, checkbox.validationMessage, checkbox);
|
|
213
224
|
}
|
|
214
225
|
}
|
|
215
226
|
static {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.element.js","sourceRoot":"","sources":["../../../src/lib/checkbox/checkbox.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"checkbox.element.js","sourceRoot":"","sources":["../../../src/lib/checkbox/checkbox.element.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,30 +3,11 @@ import type { USACheckboxElement } from "./checkbox.element.js";
|
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
5
|
tags: string[];
|
|
6
|
-
render(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
argTypes: {
|
|
10
|
-
name: {
|
|
11
|
-
control: "text";
|
|
12
|
-
};
|
|
13
|
-
value: {
|
|
14
|
-
control: "text";
|
|
15
|
-
};
|
|
16
|
-
description: {
|
|
17
|
-
control: "text";
|
|
18
|
-
};
|
|
19
|
-
tiled: {
|
|
20
|
-
control: "boolean";
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
args: {
|
|
24
|
-
name: string;
|
|
25
|
-
value: string;
|
|
26
|
-
tiled: false;
|
|
27
|
-
disabled: false;
|
|
28
|
-
};
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
argTypes: {};
|
|
8
|
+
args: {};
|
|
29
9
|
};
|
|
30
10
|
export default meta;
|
|
31
11
|
type Story = StoryObj<USACheckboxElement>;
|
|
32
12
|
export declare const Primary: Story;
|
|
13
|
+
export declare const Tiled: Story;
|
|
@@ -1,48 +1,86 @@
|
|
|
1
1
|
import { html } from "lit";
|
|
2
|
-
import { ifDefined } from "lit/directives/if-defined.js";
|
|
3
|
-
import { when } from "lit/directives/when.js";
|
|
4
2
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
5
3
|
const meta = {
|
|
6
4
|
title: "usa-checkbox",
|
|
7
5
|
tags: ["autodocs"],
|
|
8
|
-
render(
|
|
6
|
+
render() {
|
|
9
7
|
return html `
|
|
10
|
-
<usa-checkbox
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
<usa-checkbox-group>
|
|
9
|
+
<legend class="usa-legend">Select any historical figure</legend>
|
|
10
|
+
|
|
11
|
+
<usa-checkbox name="historical-figure" value="sojurner-truth" tiled>
|
|
12
|
+
Sojourner Truth
|
|
13
|
+
<usa-description>This is optional text that can be used to describe the label in more detail.</usa-description>
|
|
14
|
+
</usa-checkbox>
|
|
15
|
+
|
|
16
|
+
<usa-checkbox name="historical-figure" value="frederick-douglass" tiled>
|
|
17
|
+
Frederick Douglass
|
|
18
|
+
</usa-checkbox>
|
|
19
|
+
|
|
20
|
+
<usa-checkbox name="historical-figure" value="booker-t-washington" tiled>
|
|
21
|
+
Booker T. Washington
|
|
22
|
+
</usa-checkbox>
|
|
23
|
+
|
|
24
|
+
<usa-checkbox name="historical-figure" value="gw-carver" tiled disabled>
|
|
25
|
+
George Washington Carver
|
|
26
|
+
</usa-checkbox>
|
|
27
|
+
</usa-checkbox-group>
|
|
20
28
|
`;
|
|
21
29
|
},
|
|
22
|
-
argTypes: {
|
|
23
|
-
|
|
24
|
-
control: "text",
|
|
25
|
-
},
|
|
26
|
-
value: {
|
|
27
|
-
control: "text",
|
|
28
|
-
},
|
|
29
|
-
description: {
|
|
30
|
-
control: "text",
|
|
31
|
-
},
|
|
32
|
-
tiled: {
|
|
33
|
-
control: "boolean",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
args: {
|
|
37
|
-
name: "toc",
|
|
38
|
-
value: "agree",
|
|
39
|
-
tiled: false,
|
|
40
|
-
disabled: false,
|
|
41
|
-
},
|
|
30
|
+
argTypes: {},
|
|
31
|
+
args: {},
|
|
42
32
|
};
|
|
43
33
|
export default meta;
|
|
44
34
|
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
45
35
|
export const Primary = {
|
|
46
|
-
|
|
36
|
+
render() {
|
|
37
|
+
return html `
|
|
38
|
+
<usa-checkbox-group>
|
|
39
|
+
<legend class="usa-legend">Select any historical figure</legend>
|
|
40
|
+
|
|
41
|
+
<usa-checkbox name="historical-figure" value="sojurner-truth">
|
|
42
|
+
Sojourner Truth
|
|
43
|
+
</usa-checkbox>
|
|
44
|
+
|
|
45
|
+
<usa-checkbox name="historical-figure" value="frederick-douglass">
|
|
46
|
+
Frederick Douglass
|
|
47
|
+
</usa-checkbox>
|
|
48
|
+
|
|
49
|
+
<usa-checkbox name="historical-figure" value="booker-t-washington">
|
|
50
|
+
Booker T. Washington
|
|
51
|
+
</usa-checkbox>
|
|
52
|
+
|
|
53
|
+
<usa-checkbox name="historical-figure" value="gw-carver" disabled>
|
|
54
|
+
George Washington Carver
|
|
55
|
+
</usa-checkbox>
|
|
56
|
+
</usa-checkbox-group>
|
|
57
|
+
`;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export const Tiled = {
|
|
61
|
+
render() {
|
|
62
|
+
return html `
|
|
63
|
+
<usa-checkbox-group>
|
|
64
|
+
<legend class="usa-legend">Select any historical figure</legend>
|
|
65
|
+
|
|
66
|
+
<usa-checkbox name="historical-figure" value="sojurner-truth" tiled>
|
|
67
|
+
Sojourner Truth
|
|
68
|
+
<usa-description>This is optional text that can be used to describe the label in more detail.</usa-description>
|
|
69
|
+
</usa-checkbox>
|
|
70
|
+
|
|
71
|
+
<usa-checkbox name="historical-figure" value="frederick-douglass" tiled>
|
|
72
|
+
Frederick Douglass
|
|
73
|
+
</usa-checkbox>
|
|
74
|
+
|
|
75
|
+
<usa-checkbox name="historical-figure" value="booker-t-washington" tiled>
|
|
76
|
+
Booker T. Washington
|
|
77
|
+
</usa-checkbox>
|
|
78
|
+
|
|
79
|
+
<usa-checkbox name="historical-figure" value="gw-carver" tiled disabled>
|
|
80
|
+
George Washington Carver
|
|
81
|
+
</usa-checkbox>
|
|
82
|
+
</usa-checkbox-group>
|
|
83
|
+
`;
|
|
84
|
+
},
|
|
47
85
|
};
|
|
48
86
|
//# sourceMappingURL=checkbox.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.stories.js","sourceRoot":"","sources":["../../../src/lib/checkbox/checkbox.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"checkbox.stories.js","sourceRoot":"","sources":["../../../src/lib/checkbox/checkbox.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAO3B,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBV,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACoD,CAAC;AAE/D,eAAe,IAAI,CAAC;AAIpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;KAoBV,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAU;IAC1B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;KAqBV,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -3,7 +3,7 @@ import type { USACollectionElement } from "./collection.element.js";
|
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
5
|
tags: string[];
|
|
6
|
-
render(
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
7
7
|
argTypes: {};
|
|
8
8
|
args: {};
|
|
9
9
|
};
|