@noctuatech/uswds 0.0.28 → 0.0.30
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/assets/uswds.min.js +1 -0
- package/package.json +1 -1
- package/src/lib/button/button.element.ts +24 -33
- package/src/lib/file-input/file-input-preview/file-input-preview.test.ts +2 -2
- package/src/lib/file-input/file-input.element.ts +58 -20
- package/src/lib/input/input.element.ts +39 -19
- package/src/lib/input/input.stories.ts +1 -1
- package/src/lib/textarea/textarea.element.ts +4 -1
- package/target/lib/accordion/accordion.element.d.ts +19 -0
- package/target/lib/accordion/accordion.element.js +166 -0
- package/target/lib/accordion/accordion.element.js.map +1 -0
- package/target/lib/accordion/accordion.stories.d.ts +12 -0
- package/target/lib/accordion/accordion.stories.js +42 -0
- package/target/lib/accordion/accordion.stories.js.map +1 -0
- package/target/lib/accordion/accordion.test.d.ts +1 -0
- package/target/lib/accordion/accordion.test.js +113 -0
- package/target/lib/accordion/accordion.test.js.map +1 -0
- package/target/lib/alert/alert-types.d.ts +7 -0
- package/target/lib/alert/alert-types.js +25 -0
- package/target/lib/alert/alert-types.js.map +1 -0
- package/target/lib/alert/alert.element.d.ts +11 -0
- package/target/lib/alert/alert.element.js +122 -0
- package/target/lib/alert/alert.element.js.map +1 -0
- package/target/lib/alert/alert.stories.d.ts +11 -0
- package/target/lib/alert/alert.stories.js +56 -0
- package/target/lib/alert/alert.stories.js.map +1 -0
- package/target/lib/alert/alert.test.d.ts +1 -0
- package/target/lib/alert/alert.test.js +20 -0
- package/target/lib/alert/alert.test.js.map +1 -0
- package/target/lib/button/button.element.d.ts +19 -0
- package/target/lib/button/button.element.js +253 -0
- package/target/lib/button/button.element.js.map +1 -0
- package/target/lib/button/button.stories.d.ts +12 -0
- package/target/lib/button/button.stories.js +22 -0
- package/target/lib/button/button.stories.js.map +1 -0
- package/target/lib/button/button.test.d.ts +1 -0
- package/target/lib/button/button.test.js +14 -0
- package/target/lib/button/button.test.js.map +1 -0
- package/target/lib/card/card-body/card-body.element.d.ts +7 -0
- package/target/lib/card/card-body/card-body.element.js +35 -0
- package/target/lib/card/card-body/card-body.element.js.map +1 -0
- package/target/lib/card/card-footer/card-footer.element.d.ts +7 -0
- package/target/lib/card/card-footer/card-footer.element.js +33 -0
- package/target/lib/card/card-footer/card-footer.element.js.map +1 -0
- package/target/lib/card/card-group/card-group.element.d.ts +8 -0
- package/target/lib/card/card-group/card-group.element.js +51 -0
- package/target/lib/card/card-group/card-group.element.js.map +1 -0
- package/target/lib/card/card-header/card-header.element.d.ts +7 -0
- package/target/lib/card/card-header/card-header.element.js +43 -0
- package/target/lib/card/card-header/card-header.element.js.map +1 -0
- package/target/lib/card/card-media/card-media.element.d.ts +8 -0
- package/target/lib/card/card-media/card-media.element.js +71 -0
- package/target/lib/card/card-media/card-media.element.js.map +1 -0
- package/target/lib/card/card.element.d.ts +9 -0
- package/target/lib/card/card.element.js +79 -0
- package/target/lib/card/card.element.js.map +1 -0
- package/target/lib/card/card.stories.d.ts +12 -0
- package/target/lib/card/card.stories.js +126 -0
- package/target/lib/card/card.stories.js.map +1 -0
- package/target/lib/card/card.test.d.ts +6 -0
- package/target/lib/card/card.test.js +33 -0
- package/target/lib/card/card.test.js.map +1 -0
- package/target/lib/checkbox/checkbox.element.d.ts +17 -0
- package/target/lib/checkbox/checkbox.element.js +206 -0
- package/target/lib/checkbox/checkbox.element.js.map +1 -0
- package/target/lib/checkbox/checkbox.stories.d.ts +31 -0
- package/target/lib/checkbox/checkbox.stories.js +46 -0
- package/target/lib/checkbox/checkbox.stories.js.map +1 -0
- package/target/lib/checkbox/checkbox.test.d.ts +1 -0
- package/target/lib/checkbox/checkbox.test.js +52 -0
- package/target/lib/checkbox/checkbox.test.js.map +1 -0
- package/target/lib/config/config.element.d.ts +6 -0
- package/target/lib/config/config.element.js +53 -0
- package/target/lib/config/config.element.js.map +1 -0
- package/target/lib/config/config.test.d.ts +1 -0
- package/target/lib/config/config.test.js +11 -0
- package/target/lib/config/config.test.js.map +1 -0
- package/target/lib/define.d.ts +32 -0
- package/target/lib/define.js +33 -0
- package/target/lib/define.js.map +1 -0
- package/target/lib/description/description.element.d.ts +7 -0
- package/target/lib/description/description.element.js +34 -0
- package/target/lib/description/description.element.js.map +1 -0
- package/target/lib/description/description.test.d.ts +1 -0
- package/target/lib/description/description.test.js +11 -0
- package/target/lib/description/description.test.js.map +1 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.element.d.ts +12 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js +153 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js.map +1 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.test.d.ts +2 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.test.js +67 -0
- package/target/lib/file-input/file-input-preview/file-input-preview.test.js.map +1 -0
- package/target/lib/file-input/file-input.element.d.ts +19 -0
- package/target/lib/file-input/file-input.element.js +217 -0
- package/target/lib/file-input/file-input.element.js.map +1 -0
- package/target/lib/file-input/file-input.stories.d.ts +12 -0
- package/target/lib/file-input/file-input.stories.js +34 -0
- package/target/lib/file-input/file-input.stories.js.map +1 -0
- package/target/lib/file-input/file-input.test.d.ts +1 -0
- package/target/lib/file-input/file-input.test.js +37 -0
- package/target/lib/file-input/file-input.test.js.map +1 -0
- package/target/lib/icon/icon-types.d.ts +2 -0
- package/target/lib/icon/icon-types.js +262 -0
- package/target/lib/icon/icon-types.js.map +1 -0
- package/target/lib/icon/icon.element.d.ts +13 -0
- package/target/lib/icon/icon.element.js +72 -0
- package/target/lib/icon/icon.element.js.map +1 -0
- package/target/lib/icon/icon.stories.d.ts +12 -0
- package/target/lib/icon/icon.stories.js +39 -0
- package/target/lib/icon/icon.stories.js.map +1 -0
- package/target/lib/input/input.element.d.ts +25 -0
- package/target/lib/input/input.element.js +254 -0
- package/target/lib/input/input.element.js.map +1 -0
- package/target/lib/input/input.stories.d.ts +12 -0
- package/target/lib/input/input.stories.js +25 -0
- package/target/lib/input/input.stories.js.map +1 -0
- package/target/lib/input/input.test.d.ts +1 -0
- package/target/lib/input/input.test.js +50 -0
- package/target/lib/input/input.test.js.map +1 -0
- package/target/lib/input-mask/format.d.ts +15 -0
- package/target/lib/input-mask/format.js +47 -0
- package/target/lib/input-mask/format.js.map +1 -0
- package/target/lib/input-mask/input-mask.element.d.ts +12 -0
- package/target/lib/input-mask/input-mask.element.js +106 -0
- package/target/lib/input-mask/input-mask.element.js.map +1 -0
- package/target/lib/input-mask/input-mask.stories.d.ts +14 -0
- package/target/lib/input-mask/input-mask.stories.js +30 -0
- package/target/lib/input-mask/input-mask.stories.js.map +1 -0
- package/target/lib/input-mask/input-mask.test.d.ts +2 -0
- package/target/lib/input-mask/input-mask.test.js +89 -0
- package/target/lib/input-mask/input-mask.test.js.map +1 -0
- package/target/lib/input-mask/maskable.element.d.ts +5 -0
- package/target/lib/input-mask/maskable.element.js +2 -0
- package/target/lib/input-mask/maskable.element.js.map +1 -0
- package/target/lib/link/link.element.d.ts +13 -0
- package/target/lib/link/link.element.js +93 -0
- package/target/lib/link/link.element.js.map +1 -0
- package/target/lib/link/link.stories.d.ts +16 -0
- package/target/lib/link/link.stories.js +23 -0
- package/target/lib/link/link.stories.js.map +1 -0
- package/target/lib/modal/modal-close/modal-close.element.d.ts +8 -0
- package/target/lib/modal/modal-close/modal-close.element.js +76 -0
- package/target/lib/modal/modal-close/modal-close.element.js.map +1 -0
- package/target/lib/modal/modal-close/modal-close.test.d.ts +1 -0
- package/target/lib/modal/modal-close/modal-close.test.js +11 -0
- package/target/lib/modal/modal-close/modal-close.test.js.map +1 -0
- package/target/lib/modal/modal-heading/modal-heading.element.d.ts +7 -0
- package/target/lib/modal/modal-heading/modal-heading.element.js +50 -0
- package/target/lib/modal/modal-heading/modal-heading.element.js.map +1 -0
- package/target/lib/modal/modal-heading/modal-heading.test.d.ts +1 -0
- package/target/lib/modal/modal-heading/modal-heading.test.js +11 -0
- package/target/lib/modal/modal-heading/modal-heading.test.js.map +1 -0
- package/target/lib/modal/modal.element.d.ts +13 -0
- package/target/lib/modal/modal.element.js +91 -0
- package/target/lib/modal/modal.element.js.map +1 -0
- package/target/lib/modal/modal.stories.d.ts +12 -0
- package/target/lib/modal/modal.stories.js +34 -0
- package/target/lib/modal/modal.stories.js.map +1 -0
- package/target/lib/modal/modal.test.d.ts +3 -0
- package/target/lib/modal/modal.test.js +21 -0
- package/target/lib/modal/modal.test.js.map +1 -0
- package/target/lib/radio/context.d.ts +7 -0
- package/target/lib/radio/context.js +3 -0
- package/target/lib/radio/context.js.map +1 -0
- package/target/lib/radio/radio-option/radio-option.element.d.ts +12 -0
- package/target/lib/radio/radio-option/radio-option.element.js +89 -0
- package/target/lib/radio/radio-option/radio-option.element.js.map +1 -0
- package/target/lib/radio/radio-option/radio-option.test.d.ts +2 -0
- package/target/lib/radio/radio-option/radio-option.test.js +15 -0
- package/target/lib/radio/radio-option/radio-option.test.js.map +1 -0
- package/target/lib/radio/radio.element.d.ts +17 -0
- package/target/lib/radio/radio.element.js +169 -0
- package/target/lib/radio/radio.element.js.map +1 -0
- package/target/lib/radio/radio.stories.d.ts +17 -0
- package/target/lib/radio/radio.stories.js +46 -0
- package/target/lib/radio/radio.stories.js.map +1 -0
- package/target/lib/radio/radio.test.d.ts +2 -0
- package/target/lib/radio/radio.test.js +143 -0
- package/target/lib/radio/radio.test.js.map +1 -0
- package/target/lib/select/context.d.ts +6 -0
- package/target/lib/select/context.js +3 -0
- package/target/lib/select/context.js.map +1 -0
- package/target/lib/select/select-option/select-option.element.d.ts +14 -0
- package/target/lib/select/select-option/select-option.element.js +74 -0
- package/target/lib/select/select-option/select-option.element.js.map +1 -0
- package/target/lib/select/select.element.d.ts +17 -0
- package/target/lib/select/select.element.js +141 -0
- package/target/lib/select/select.element.js.map +1 -0
- package/target/lib/select/select.stories.d.ts +12 -0
- package/target/lib/select/select.stories.js +26 -0
- package/target/lib/select/select.stories.js.map +1 -0
- package/target/lib/select/select.test.d.ts +2 -0
- package/target/lib/select/select.test.js +105 -0
- package/target/lib/select/select.test.js.map +1 -0
- package/target/lib/services/http.service.d.ts +3 -0
- package/target/lib/services/http.service.js +24 -0
- package/target/lib/services/http.service.js.map +1 -0
- package/target/lib/services/icon.service.d.ts +4 -0
- package/target/lib/services/icon.service.js +60 -0
- package/target/lib/services/icon.service.js.map +1 -0
- package/target/lib/services/icon.service.test.d.ts +1 -0
- package/target/lib/services/icon.service.test.js +52 -0
- package/target/lib/services/icon.service.test.js.map +1 -0
- package/target/lib/side-nav/side-nav-item/side-nav-item.element.d.ts +8 -0
- package/target/lib/side-nav/side-nav-item/side-nav-item.element.js +107 -0
- package/target/lib/side-nav/side-nav-item/side-nav-item.element.js.map +1 -0
- package/target/lib/side-nav/side-nav.element.d.ts +8 -0
- package/target/lib/side-nav/side-nav.element.js +47 -0
- package/target/lib/side-nav/side-nav.element.js.map +1 -0
- package/target/lib/side-nav/side-nav.stories.d.ts +12 -0
- package/target/lib/side-nav/side-nav.stories.js +55 -0
- package/target/lib/side-nav/side-nav.stories.js.map +1 -0
- package/target/lib/side-nav/side-nav.test.d.ts +3 -0
- package/target/lib/side-nav/side-nav.test.js +93 -0
- package/target/lib/side-nav/side-nav.test.js.map +1 -0
- package/target/lib/step-indicator/step/step.element.d.ts +10 -0
- package/target/lib/step-indicator/step/step.element.js +151 -0
- package/target/lib/step-indicator/step/step.element.js.map +1 -0
- package/target/lib/step-indicator/step-indicator.element.d.ts +8 -0
- package/target/lib/step-indicator/step-indicator.element.js +48 -0
- package/target/lib/step-indicator/step-indicator.element.js.map +1 -0
- package/target/lib/step-indicator/step-indicator.stories.d.ts +21 -0
- package/target/lib/step-indicator/step-indicator.stories.js +45 -0
- package/target/lib/step-indicator/step-indicator.stories.js.map +1 -0
- package/target/lib/step-indicator/step-indicator.test.d.ts +2 -0
- package/target/lib/step-indicator/step-indicator.test.js +18 -0
- package/target/lib/step-indicator/step-indicator.test.js.map +1 -0
- package/target/lib/summary-box/summary-box.element.d.ts +7 -0
- package/target/lib/summary-box/summary-box.element.js +40 -0
- package/target/lib/summary-box/summary-box.element.js.map +1 -0
- package/target/lib/summary-box/summary-box.stories.d.ts +12 -0
- package/target/lib/summary-box/summary-box.stories.js +17 -0
- package/target/lib/summary-box/summary-box.stories.js.map +1 -0
- package/target/lib/summary-box/summary-box.test.d.ts +1 -0
- package/target/lib/summary-box/summary-box.test.js +11 -0
- package/target/lib/summary-box/summary-box.test.js.map +1 -0
- package/target/lib/tag/tag.element.d.ts +10 -0
- package/target/lib/tag/tag.element.js +57 -0
- package/target/lib/tag/tag.element.js.map +1 -0
- package/target/lib/tag/tag.stories.d.ts +19 -0
- package/target/lib/tag/tag.stories.js +25 -0
- package/target/lib/tag/tag.stories.js.map +1 -0
- package/target/lib/tag/tag.test.d.ts +1 -0
- package/target/lib/tag/tag.test.js +11 -0
- package/target/lib/tag/tag.test.js.map +1 -0
- package/target/lib/textarea/textarea.element.d.ts +19 -0
- package/target/lib/textarea/textarea.element.js +174 -0
- package/target/lib/textarea/textarea.element.js.map +1 -0
- package/target/lib/textarea/textarea.stories.d.ts +12 -0
- package/target/lib/textarea/textarea.stories.js +17 -0
- package/target/lib/textarea/textarea.stories.js.map +1 -0
- package/target/lib/textarea/textarea.test.d.ts +1 -0
- package/target/lib/textarea/textarea.test.js +50 -0
- package/target/lib/textarea/textarea.test.js.map +1 -0
- package/target/lib.d.ts +32 -0
- package/target/lib.js +33 -0
- package/target/lib.js.map +1 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { attr, css, element, html, listen, query } from "@joist/element";
|
|
3
|
+
let USAAccordionElement = (() => {
|
|
4
|
+
let _classDecorators = [element({
|
|
5
|
+
tagName: "usa-accordion",
|
|
6
|
+
shadowDomOpts: {
|
|
7
|
+
mode: "open",
|
|
8
|
+
delegatesFocus: true,
|
|
9
|
+
},
|
|
10
|
+
shadowDom: [
|
|
11
|
+
css `
|
|
12
|
+
* {
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host {
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:host(:not(:first-child)) summary {
|
|
21
|
+
margin-top: 0.5rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
summary {
|
|
25
|
+
align-items: center;
|
|
26
|
+
border: 0;
|
|
27
|
+
border-radius: 0;
|
|
28
|
+
box-shadow: none;
|
|
29
|
+
justify-content: normal;
|
|
30
|
+
text-align: left;
|
|
31
|
+
padding: 0;
|
|
32
|
+
color: #1b1b1b;
|
|
33
|
+
background-color: #f0f0f0;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
display: flex;
|
|
36
|
+
font-weight: 700;
|
|
37
|
+
margin: 0;
|
|
38
|
+
padding: 1rem 1.25rem 1rem 1.25rem;
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
summary::-webkit-details-marker {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
slot[name="heading"] {
|
|
48
|
+
display: block;
|
|
49
|
+
flex: 1 1 auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
slot[name="heading"]::slotted(*) {
|
|
53
|
+
margin: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.content {
|
|
57
|
+
padding-bottom: 1.5rem;
|
|
58
|
+
padding-left: 1rem;
|
|
59
|
+
padding-top: 1.5rem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
usa-icon[icon="remove"] {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
details[open] usa-icon[icon="add"] {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
details[open] usa-icon[icon="remove"] {
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
summary:hover {
|
|
75
|
+
background-color: #e6e6e6;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
summary:focus {
|
|
79
|
+
outline: 0.25rem solid #2491ff;
|
|
80
|
+
outline-offset: 0;
|
|
81
|
+
}
|
|
82
|
+
`,
|
|
83
|
+
html `
|
|
84
|
+
<details>
|
|
85
|
+
<summary>
|
|
86
|
+
<slot name="heading"></slot>
|
|
87
|
+
|
|
88
|
+
<usa-icon icon="add"></usa-icon>
|
|
89
|
+
<usa-icon icon="remove"></usa-icon>
|
|
90
|
+
</summary>
|
|
91
|
+
|
|
92
|
+
<div class="content">
|
|
93
|
+
<slot></slot>
|
|
94
|
+
</div>
|
|
95
|
+
</details>
|
|
96
|
+
`,
|
|
97
|
+
],
|
|
98
|
+
})];
|
|
99
|
+
let _classDescriptor;
|
|
100
|
+
let _classExtraInitializers = [];
|
|
101
|
+
let _classThis;
|
|
102
|
+
let _classSuper = HTMLElement;
|
|
103
|
+
let _instanceExtraInitializers = [];
|
|
104
|
+
let _name_decorators;
|
|
105
|
+
let _name_initializers = [];
|
|
106
|
+
let _name_extraInitializers = [];
|
|
107
|
+
let _open_decorators;
|
|
108
|
+
let _open_initializers = [];
|
|
109
|
+
let _open_extraInitializers = [];
|
|
110
|
+
let _onClick_decorators;
|
|
111
|
+
let _onAccordionToggle_decorators;
|
|
112
|
+
var USAAccordionElement = class extends _classSuper {
|
|
113
|
+
static { _classThis = this; }
|
|
114
|
+
static {
|
|
115
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
116
|
+
_name_decorators = [attr()];
|
|
117
|
+
_open_decorators = [attr()];
|
|
118
|
+
_onClick_decorators = [listen("click", "summary")];
|
|
119
|
+
_onAccordionToggle_decorators = [listen("usa::accordion::toggle", () => document.body)];
|
|
120
|
+
__esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
|
|
121
|
+
__esDecorate(this, null, _open_decorators, { kind: "accessor", name: "open", static: false, private: false, access: { has: obj => "open" in obj, get: obj => obj.open, set: (obj, value) => { obj.open = value; } }, metadata: _metadata }, _open_initializers, _open_extraInitializers);
|
|
122
|
+
__esDecorate(this, null, _onClick_decorators, { kind: "method", name: "onClick", static: false, private: false, access: { has: obj => "onClick" in obj, get: obj => obj.onClick }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
123
|
+
__esDecorate(this, null, _onAccordionToggle_decorators, { kind: "method", name: "onAccordionToggle", static: false, private: false, access: { has: obj => "onAccordionToggle" in obj, get: obj => obj.onAccordionToggle }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
124
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
125
|
+
USAAccordionElement = _classThis = _classDescriptor.value;
|
|
126
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
127
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
128
|
+
}
|
|
129
|
+
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers, ""));
|
|
130
|
+
get name() { return this.#name_accessor_storage; }
|
|
131
|
+
set name(value) { this.#name_accessor_storage = value; }
|
|
132
|
+
#open_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _open_initializers, false));
|
|
133
|
+
get open() { return this.#open_accessor_storage; }
|
|
134
|
+
set open(value) { this.#open_accessor_storage = value; }
|
|
135
|
+
#details = (__runInitializers(this, _open_extraInitializers), query("details"));
|
|
136
|
+
attributeChangedCallback() {
|
|
137
|
+
const details = this.#details();
|
|
138
|
+
details.open = this.open;
|
|
139
|
+
}
|
|
140
|
+
onClick(e) {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
this.dispatchEvent(new USAAccordionToggleEvent(!this.open));
|
|
143
|
+
}
|
|
144
|
+
onAccordionToggle(e) {
|
|
145
|
+
if (e.target.name === this.name) {
|
|
146
|
+
this.open = e.target === this && e.open;
|
|
147
|
+
}
|
|
148
|
+
else if (e.target === this) {
|
|
149
|
+
this.open = e.open;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
return USAAccordionElement = _classThis;
|
|
154
|
+
})();
|
|
155
|
+
export { USAAccordionElement };
|
|
156
|
+
class USAAccordionToggleEvent extends Event {
|
|
157
|
+
open;
|
|
158
|
+
get target() {
|
|
159
|
+
return super.target;
|
|
160
|
+
}
|
|
161
|
+
constructor(open) {
|
|
162
|
+
super("usa::accordion::toggle", { bubbles: true });
|
|
163
|
+
this.open = open;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=accordion.element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.element.js","sourceRoot":"","sources":["../../../src/lib/accordion/accordion.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;IAuG5D,mBAAmB;4BA/F/B,OAAO,CAAC;YACP,OAAO,EAAE,eAAe;YACxB,aAAa,EAAE;gBACb,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,IAAI;aACrB;YACD,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuEF;gBACD,IAAI,CAAA;;;;;;;;;;;;;KAaH;aACF;SACF,CAAC;;;;sBACuC,WAAW;;;;;;;;;;mCAAnB,SAAQ,WAAW;;;;gCACjD,IAAI,EAAE;gCAGN,IAAI,EAAE;mCAUN,MAAM,CAAC,OA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AEL,IAAI,MAAM;QACR,OAAO,KAAK,CAAC,MAA6B,CAAC;IAC7C,CAAC;IAED,YAAY,IAAa;QACvB,KAAK,CAAC,wBAAwB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/web-components";
|
|
2
|
+
import type { USAAccordionElement } from "./accordion.element.js";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
tags: string[];
|
|
6
|
+
render(args: USAAccordionElement): import("lit-html").TemplateResult<1>;
|
|
7
|
+
argTypes: {};
|
|
8
|
+
args: {};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<USAAccordionElement>;
|
|
12
|
+
export declare const Primary: Story;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "usa-accordion",
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
render(args) {
|
|
7
|
+
return html `
|
|
8
|
+
<usa-accordion id="first" name="ammendment">
|
|
9
|
+
<h4 slot="heading">First Ammendment</h4>
|
|
10
|
+
|
|
11
|
+
Congress shall make no law respecting an establishment of religion, or
|
|
12
|
+
prohibiting the free exercise thereof; or abridging the freedom of
|
|
13
|
+
speech, or of the press; or the right of the people peaceably to
|
|
14
|
+
assemble, and to petition the Government for a redress of grievances.
|
|
15
|
+
</usa-accordion>
|
|
16
|
+
|
|
17
|
+
<usa-accordion id="second" name="ammendment">
|
|
18
|
+
<h4 slot="heading">Second Ammendment</h4>
|
|
19
|
+
|
|
20
|
+
A well regulated Militia, being necessary to the security of a free
|
|
21
|
+
State, the right of the people to keep and bear Arms, shall not be
|
|
22
|
+
infringed.
|
|
23
|
+
</usa-accordion>
|
|
24
|
+
|
|
25
|
+
<usa-accordion id="third" name="ammendment">
|
|
26
|
+
<h4 slot="heading">Third Ammendment</h4>
|
|
27
|
+
|
|
28
|
+
No Soldier shall, in time of peace be quartered in any house, without
|
|
29
|
+
the consent of the Owner, nor in time of war, but in a manner to be
|
|
30
|
+
prescribed by law.
|
|
31
|
+
</usa-accordion>
|
|
32
|
+
`;
|
|
33
|
+
},
|
|
34
|
+
argTypes: {},
|
|
35
|
+
args: {},
|
|
36
|
+
};
|
|
37
|
+
export default meta;
|
|
38
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
39
|
+
export const Primary = {
|
|
40
|
+
args: {},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=accordion.stories.js.map
|
|
@@ -0,0 +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,CAAC,IAAI;QACT,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./accordion.element.js";
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import "./accordion.element.js";
|
|
2
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
3
|
+
describe("usa-accordion", () => {
|
|
4
|
+
it("should be accessible", async () => {
|
|
5
|
+
const accordion = await fixture(html `
|
|
6
|
+
<usa-accordion id="first" name="ammendment">
|
|
7
|
+
<h4 slot="heading">First Ammendment</h4>
|
|
8
|
+
|
|
9
|
+
<div class="content">
|
|
10
|
+
Congress shall make no law respecting an establishment of religion, or
|
|
11
|
+
prohibiting the free exercise thereof; or abridging the freedom of
|
|
12
|
+
speech, or of the press; or the right of the people peaceably to
|
|
13
|
+
assemble, and to petition the Government for a redress of grievances.
|
|
14
|
+
</div>
|
|
15
|
+
</usa-accordion>
|
|
16
|
+
`);
|
|
17
|
+
return assert.isAccessible(accordion);
|
|
18
|
+
});
|
|
19
|
+
it("should toggle the open state when clicked", async () => {
|
|
20
|
+
const accordion = await fixture(html `
|
|
21
|
+
<usa-accordion id="first" name="ammendment">
|
|
22
|
+
<h4 slot="heading">First Ammendment</h4>
|
|
23
|
+
|
|
24
|
+
<div class="content">
|
|
25
|
+
Congress shall make no law respecting an establishment of religion, or
|
|
26
|
+
prohibiting the free exercise thereof; or abridging the freedom of
|
|
27
|
+
speech, or of the press; or the right of the people peaceably to
|
|
28
|
+
assemble, and to petition the Government for a redress of grievances.
|
|
29
|
+
</div>
|
|
30
|
+
</usa-accordion>
|
|
31
|
+
`);
|
|
32
|
+
const heading = accordion.querySelector("h4");
|
|
33
|
+
const content = accordion.querySelector(".content");
|
|
34
|
+
heading?.click();
|
|
35
|
+
assert.isTrue(content?.checkVisibility());
|
|
36
|
+
});
|
|
37
|
+
it("should toggle the open state when clicked", async () => {
|
|
38
|
+
const accordion = await fixture(html `
|
|
39
|
+
<usa-accordion id="first" name="ammendment">
|
|
40
|
+
<h4 slot="heading">First Ammendment</h4>
|
|
41
|
+
|
|
42
|
+
<div class="content">
|
|
43
|
+
Congress shall make no law respecting an establishment of religion, or
|
|
44
|
+
prohibiting the free exercise thereof; or abridging the freedom of
|
|
45
|
+
speech, or of the press; or the right of the people peaceably to
|
|
46
|
+
assemble, and to petition the Government for a redress of grievances.
|
|
47
|
+
</div>
|
|
48
|
+
</usa-accordion>
|
|
49
|
+
`);
|
|
50
|
+
const heading = accordion.querySelector("h4");
|
|
51
|
+
const content = accordion.querySelector(".content");
|
|
52
|
+
assert.isFalse(content?.checkVisibility());
|
|
53
|
+
heading?.click();
|
|
54
|
+
assert.isTrue(content.checkVisibility());
|
|
55
|
+
});
|
|
56
|
+
it("should only allow a single accordion in a group to be open", async () => {
|
|
57
|
+
const el = await fixture(html `
|
|
58
|
+
<section>
|
|
59
|
+
<usa-accordion name="ammendment">
|
|
60
|
+
<h4 slot="heading">First Ammendment</h4>
|
|
61
|
+
<div class="content">Content for First</div>
|
|
62
|
+
</usa-accordion>
|
|
63
|
+
|
|
64
|
+
<usa-accordion name="ammendment">
|
|
65
|
+
<h4 slot="heading">Second Ammendment</h4>
|
|
66
|
+
<div class="content">Content for Second</div>
|
|
67
|
+
</usa-accordion>
|
|
68
|
+
|
|
69
|
+
<usa-accordion name="ammendment">
|
|
70
|
+
<h4 slot="heading">Third Ammendment</h4>
|
|
71
|
+
<div class="content">Content for Third</div>
|
|
72
|
+
</usa-accordion>
|
|
73
|
+
</section>
|
|
74
|
+
`);
|
|
75
|
+
const headings = el.querySelectorAll("h4");
|
|
76
|
+
const content = Array.from(el.querySelectorAll(".content"));
|
|
77
|
+
headings[0].click();
|
|
78
|
+
assert.deepEqual(content.map((el) => el.checkVisibility()), [true, false, false]);
|
|
79
|
+
headings[1].click();
|
|
80
|
+
assert.deepEqual(content.map((el) => el.checkVisibility()), [false, true, false]);
|
|
81
|
+
headings[2].click();
|
|
82
|
+
assert.deepEqual(content.map((el) => el.checkVisibility()), [false, false, true]);
|
|
83
|
+
});
|
|
84
|
+
it("should not close accordion not in the same group", async () => {
|
|
85
|
+
const el = await fixture(html `
|
|
86
|
+
<section>
|
|
87
|
+
<usa-accordion name="ammendment">
|
|
88
|
+
<h4 slot="heading">First Ammendment</h4>
|
|
89
|
+
<div class="content">Content for First</div>
|
|
90
|
+
</usa-accordion>
|
|
91
|
+
|
|
92
|
+
<usa-accordion name="ammendment">
|
|
93
|
+
<h4 slot="heading">Second Ammendment</h4>
|
|
94
|
+
<div class="content">Content for Second</div>
|
|
95
|
+
</usa-accordion>
|
|
96
|
+
|
|
97
|
+
<usa-accordion name="different">
|
|
98
|
+
<h4 slot="heading">Third Ammendment</h4>
|
|
99
|
+
<div class="content">Content for Third</div>
|
|
100
|
+
</usa-accordion>
|
|
101
|
+
</section>
|
|
102
|
+
`);
|
|
103
|
+
const headings = el.querySelectorAll("h4");
|
|
104
|
+
const content = Array.from(el.querySelectorAll(".content"));
|
|
105
|
+
headings[0].click();
|
|
106
|
+
assert.deepEqual(content.map((el) => el.checkVisibility()), [true, false, false]);
|
|
107
|
+
headings[1].click();
|
|
108
|
+
assert.deepEqual(content.map((el) => el.checkVisibility()), [false, true, false]);
|
|
109
|
+
headings[2].click();
|
|
110
|
+
assert.deepEqual(content.map((el) => el.checkVisibility()), [false, true, true]);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=accordion.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accordion.test.js","sourceRoot":"","sources":["../../../src/lib/accordion/accordion.test.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIzD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAsB,IAAI,CAAA;;;;;;;;;;;KAWxD,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,SAAS,GAAG,MAAM,OAAO,CAAsB,IAAI,CAAA;;;;;;;;;;;KA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AC,EAAE,CAAC,eAAe,EAAE,CAAC,EACzC,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CACrB,CAAC;QAEF,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAEpB,MAAM,CAAC,SAAS,CACd,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,EACzC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CACpB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { USAIcon } from "../icon/icon-types.js";
|
|
2
|
+
export declare const USA_ALERT_TYPES: readonly ["info", "warning", "success", "error", "emergency"];
|
|
3
|
+
export type USAAlertType = (typeof USA_ALERT_TYPES)[number];
|
|
4
|
+
export interface USAAlert {
|
|
5
|
+
icon: USAIcon;
|
|
6
|
+
}
|
|
7
|
+
export declare const USA_ALERT_CONFIG: Record<USAAlertType, USAAlert>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const USA_ALERT_TYPES = [
|
|
2
|
+
"info",
|
|
3
|
+
"warning",
|
|
4
|
+
"success",
|
|
5
|
+
"error",
|
|
6
|
+
"emergency",
|
|
7
|
+
];
|
|
8
|
+
export const USA_ALERT_CONFIG = {
|
|
9
|
+
info: {
|
|
10
|
+
icon: "info",
|
|
11
|
+
},
|
|
12
|
+
warning: {
|
|
13
|
+
icon: "warning",
|
|
14
|
+
},
|
|
15
|
+
success: {
|
|
16
|
+
icon: "check_circle",
|
|
17
|
+
},
|
|
18
|
+
error: {
|
|
19
|
+
icon: "error",
|
|
20
|
+
},
|
|
21
|
+
emergency: {
|
|
22
|
+
icon: "error",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=alert-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert-types.js","sourceRoot":"","sources":["../../../src/lib/alert/alert-types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;IACP,WAAW;CACH,CAAC;AAQX,MAAM,CAAC,MAAM,gBAAgB,GAAmC;IAC9D,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;KACb;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;KAChB;IACD,OAAO,EAAE;QACP,IAAI,EAAE,cAAc;KACrB;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;KACd;IACD,SAAS,EAAE;QACT,IAAI,EAAE,OAAO;KACd;CACF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type USAAlertType } from "./alert-types.js";
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
"usa-alert": USAAlertElement;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare class USAAlertElement extends HTMLElement {
|
|
8
|
+
#private;
|
|
9
|
+
accessor type: USAAlertType;
|
|
10
|
+
attributeChangedCallback(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { attr, css, element, html, query } from "@joist/element";
|
|
3
|
+
import { USA_ALERT_CONFIG } from "./alert-types.js";
|
|
4
|
+
let USAAlertElement = (() => {
|
|
5
|
+
let _classDecorators = [element({
|
|
6
|
+
tagName: "usa-alert",
|
|
7
|
+
shadowDomOpts: {
|
|
8
|
+
mode: "open",
|
|
9
|
+
delegatesFocus: true,
|
|
10
|
+
},
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css `
|
|
13
|
+
:host {
|
|
14
|
+
display: block;
|
|
15
|
+
border-left: 0.5rem solid #adadad;
|
|
16
|
+
padding: 1rem 1.2rem;
|
|
17
|
+
color: #1b1b1b;
|
|
18
|
+
margin-bottom: 1rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:host([type="info"]) {
|
|
22
|
+
border-left-color: #00bde3;
|
|
23
|
+
background-color: #e7f6f8;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([type="warning"]) {
|
|
27
|
+
background-color: #faf3d1;
|
|
28
|
+
border-left-color: #ffbe2e;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([type="success"]) {
|
|
32
|
+
background-color: #ecf3ec;
|
|
33
|
+
border-left-color: #00a91c;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
:host([type="error"]) {
|
|
37
|
+
background-color: #f4e3db;
|
|
38
|
+
border-left-color: #d54309;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host([type="emergency"]) {
|
|
42
|
+
background-color: #9c3d10;
|
|
43
|
+
border-left-color: #9c3d10;
|
|
44
|
+
color: #fff;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host([type="emergency"]) ::slotted(*) {
|
|
48
|
+
color: #fff;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.alert-heading {
|
|
52
|
+
display: grid;
|
|
53
|
+
grid-template-columns: auto 1fr;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
usa-icon {
|
|
58
|
+
margin: -0.28rem 0.75rem 0 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#heading::slotted(*) {
|
|
62
|
+
font-family:
|
|
63
|
+
Source Sans Pro Web,
|
|
64
|
+
Helvetica Neue,
|
|
65
|
+
Helvetica,
|
|
66
|
+
Roboto,
|
|
67
|
+
Arial,
|
|
68
|
+
sans-serif;
|
|
69
|
+
font-size: 1.33rem;
|
|
70
|
+
line-height: 0.9;
|
|
71
|
+
margin-top: 0;
|
|
72
|
+
margin-bottom: 0.5rem;
|
|
73
|
+
}
|
|
74
|
+
`,
|
|
75
|
+
html `
|
|
76
|
+
<div class="alert-heading">
|
|
77
|
+
<usa-icon icon="check_circle"></usa-icon>
|
|
78
|
+
|
|
79
|
+
<div>
|
|
80
|
+
<slot id="heading" name="heading"></slot>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div class="spacer"></div>
|
|
84
|
+
|
|
85
|
+
<div>
|
|
86
|
+
<slot></slot>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
`,
|
|
90
|
+
],
|
|
91
|
+
})];
|
|
92
|
+
let _classDescriptor;
|
|
93
|
+
let _classExtraInitializers = [];
|
|
94
|
+
let _classThis;
|
|
95
|
+
let _classSuper = HTMLElement;
|
|
96
|
+
let _type_decorators;
|
|
97
|
+
let _type_initializers = [];
|
|
98
|
+
let _type_extraInitializers = [];
|
|
99
|
+
var USAAlertElement = class extends _classSuper {
|
|
100
|
+
static { _classThis = this; }
|
|
101
|
+
static {
|
|
102
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
103
|
+
_type_decorators = [attr()];
|
|
104
|
+
__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);
|
|
105
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
106
|
+
USAAlertElement = _classThis = _classDescriptor.value;
|
|
107
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
108
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
109
|
+
}
|
|
110
|
+
#type_accessor_storage = __runInitializers(this, _type_initializers, "info");
|
|
111
|
+
get type() { return this.#type_accessor_storage; }
|
|
112
|
+
set type(value) { this.#type_accessor_storage = value; }
|
|
113
|
+
#icon = (__runInitializers(this, _type_extraInitializers), query("usa-icon"));
|
|
114
|
+
attributeChangedCallback() {
|
|
115
|
+
const icon = this.#icon();
|
|
116
|
+
icon.icon = USA_ALERT_CONFIG[this.type].icon;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
return USAAlertElement = _classThis;
|
|
120
|
+
})();
|
|
121
|
+
export { USAAlertElement };
|
|
122
|
+
//# sourceMappingURL=alert.element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.element.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAqB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;IA+F1D,eAAe;4BAvF3B,OAAO,CAAC;YACP,OAAO,EAAE,WAAW;YACpB,aAAa,EAAE;gBACb,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,IAAI;aACrB;YACD,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8DF;gBACD,IAAI,CAAA;;;;;;;;;;;;;;KAcH;aACF;SACF,CAAC;;;;sBACmC,WAAW;;;;+BAAnB,SAAQ,WAAW;;;;gCAC7C,IAAI,EAAE;YACP,iKAAS,IAAI,6BAAJ,IAAI,mFAAwB;YAFvC,6KAWC;;;YAXY,uDAAe;;QAE1B,qEAA8B,MAAM,EAAC;QAArC,IAAS,IAAI,0CAAwB;QAArC,IAAS,IAAI,gDAAwB;QAErC,KAAK,sDAAG,KAAK,CAAC,UAAU,CAAC,EAAC;QAE1B,wBAAwB;YACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE1B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QAC/C,CAAC;;;;SAVU,eAAe"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/web-components";
|
|
2
|
+
import type { USAAlertElement } from "./alert.element.js";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
tags: string[];
|
|
6
|
+
argTypes: {};
|
|
7
|
+
args: {};
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<USAAlertElement>;
|
|
11
|
+
export declare const Primary: Story;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "usa-alert",
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
argTypes: {},
|
|
7
|
+
args: {},
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
11
|
+
export const Primary = {
|
|
12
|
+
render() {
|
|
13
|
+
return html `
|
|
14
|
+
<usa-alert type="info">
|
|
15
|
+
<h3 slot="heading">Informative status</h3>
|
|
16
|
+
|
|
17
|
+
Lorem ipsum dolor sit amet,
|
|
18
|
+
<usa-link href="#">consectetur adipiscing</usa-link> elit, sed do
|
|
19
|
+
eiusmod.
|
|
20
|
+
</usa-alert>
|
|
21
|
+
|
|
22
|
+
<usa-alert type="warning">
|
|
23
|
+
<h3 slot="heading">Warning status</h3>
|
|
24
|
+
|
|
25
|
+
Lorem ipsum dolor sit amet,
|
|
26
|
+
<usa-link href="#">consectetur adipiscing</usa-link> elit, sed do
|
|
27
|
+
eiusmod.
|
|
28
|
+
</usa-alert>
|
|
29
|
+
|
|
30
|
+
<usa-alert type="success">
|
|
31
|
+
<h3 slot="heading">Success status</h3>
|
|
32
|
+
|
|
33
|
+
Lorem ipsum dolor sit amet,
|
|
34
|
+
<usa-link href="#">consectetur adipiscing</usa-link> elit, sed do
|
|
35
|
+
eiusmod.
|
|
36
|
+
</usa-alert>
|
|
37
|
+
|
|
38
|
+
<usa-alert type="error">
|
|
39
|
+
<h3 slot="heading">Error status</h3>
|
|
40
|
+
|
|
41
|
+
Lorem ipsum dolor sit amet,
|
|
42
|
+
<usa-link href="#">consectetur adipiscing</usa-link> elit, sed do
|
|
43
|
+
eiusmod.
|
|
44
|
+
</usa-alert>
|
|
45
|
+
|
|
46
|
+
<usa-alert type="emergency">
|
|
47
|
+
<h3 slot="heading">Emergency status</h3>
|
|
48
|
+
|
|
49
|
+
Lorem ipsum dolor sit amet,
|
|
50
|
+
<usa-link href="#">consectetur adipiscing</usa-link> elit, sed do
|
|
51
|
+
eiusmod.
|
|
52
|
+
</usa-alert>
|
|
53
|
+
`;
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=alert.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.stories.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAI3B,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACuB,CAAC;AAElC,eAAe,IAAI,CAAC;AAIpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAU;IAC5B,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwCV,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./alert.element.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "./alert.element.js";
|
|
2
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
3
|
+
import { USA_ALERT_TYPES } from "./alert-types.js";
|
|
4
|
+
describe("usa-alert", () => {
|
|
5
|
+
for (const alert of USA_ALERT_TYPES) {
|
|
6
|
+
it(`should be accessible: ${alert}`, async () => {
|
|
7
|
+
const form = await fixture(html `
|
|
8
|
+
<usa-alert type=${alert}>
|
|
9
|
+
<h3 slot="heading">Status</h3>
|
|
10
|
+
|
|
11
|
+
Lorem ipsum dolor sit amet,
|
|
12
|
+
<usa-link href="#">consectetur adipiscing</usa-link> elit, sed do
|
|
13
|
+
eiusmod.
|
|
14
|
+
</usa-alert>
|
|
15
|
+
`);
|
|
16
|
+
return assert.isAccessible(form);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=alert.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alert.test.js","sourceRoot":"","sources":["../../../src/lib/alert/alert.test.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,EAAE,CAAC,yBAAyB,KAAK,EAAE,EAAE,KAAK,IAAI,EAAE;YAC9C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA;0BACX,KAAK;;;;;;;OAOxB,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElementTagNameMap {
|
|
3
|
+
"usa-button": USAButtonElement;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export declare const BUTTON_VARIANTS: readonly ["primary", "secondary", "cool", "warm", "outline"];
|
|
7
|
+
export type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
|
|
8
|
+
export declare class USAButtonElement extends HTMLElement {
|
|
9
|
+
#private;
|
|
10
|
+
static formAssociated: boolean;
|
|
11
|
+
accessor type: "button" | "submit" | "reset";
|
|
12
|
+
accessor disabled: boolean;
|
|
13
|
+
accessor variant: ButtonVariant;
|
|
14
|
+
accessor value: string;
|
|
15
|
+
accessor tabIndex: number;
|
|
16
|
+
onReady(): void;
|
|
17
|
+
onInternalClick(): void;
|
|
18
|
+
attributeChangedCallback(): void;
|
|
19
|
+
}
|