@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,72 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { inject, injectable, injected } from "@joist/di";
|
|
3
|
+
import { attr, css, element } from "@joist/element";
|
|
4
|
+
import { IconService } from "../services/icon.service.js";
|
|
5
|
+
let USAIconElement = (() => {
|
|
6
|
+
let _classDecorators = [element({
|
|
7
|
+
tagName: "usa-icon",
|
|
8
|
+
shadowDom: [
|
|
9
|
+
css `
|
|
10
|
+
:host {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
height: 2rem;
|
|
13
|
+
position: relative;
|
|
14
|
+
width: 2rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
svg {
|
|
18
|
+
fill: currentColor;
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
],
|
|
24
|
+
}), injectable()];
|
|
25
|
+
let _classDescriptor;
|
|
26
|
+
let _classExtraInitializers = [];
|
|
27
|
+
let _classThis;
|
|
28
|
+
let _classSuper = HTMLElement;
|
|
29
|
+
let _instanceExtraInitializers = [];
|
|
30
|
+
let _icon_decorators;
|
|
31
|
+
let _icon_initializers = [];
|
|
32
|
+
let _icon_extraInitializers = [];
|
|
33
|
+
let _onInjected_decorators;
|
|
34
|
+
var USAIconElement = class extends _classSuper {
|
|
35
|
+
static { _classThis = this; }
|
|
36
|
+
static {
|
|
37
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
38
|
+
_icon_decorators = [attr()];
|
|
39
|
+
_onInjected_decorators = [injected()];
|
|
40
|
+
__esDecorate(this, null, _icon_decorators, { kind: "accessor", name: "icon", static: false, private: false, access: { has: obj => "icon" in obj, get: obj => obj.icon, set: (obj, value) => { obj.icon = value; } }, metadata: _metadata }, _icon_initializers, _icon_extraInitializers);
|
|
41
|
+
__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);
|
|
42
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
43
|
+
USAIconElement = _classThis = _classDescriptor.value;
|
|
44
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
45
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
46
|
+
}
|
|
47
|
+
#icon_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _icon_initializers, "accessibility_new"));
|
|
48
|
+
get icon() { return this.#icon_accessor_storage; }
|
|
49
|
+
set icon(value) { this.#icon_accessor_storage = value; }
|
|
50
|
+
ariaHidden = (__runInitializers(this, _icon_extraInitializers), "true");
|
|
51
|
+
#icon = inject(IconService);
|
|
52
|
+
#injected = false;
|
|
53
|
+
onInjected() {
|
|
54
|
+
this.#injected = true;
|
|
55
|
+
this.#updateIcon();
|
|
56
|
+
}
|
|
57
|
+
attributeChangedCallback() {
|
|
58
|
+
if (this.#injected) {
|
|
59
|
+
this.#updateIcon();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async #updateIcon() {
|
|
63
|
+
const icon = this.#icon();
|
|
64
|
+
if (this.shadowRoot) {
|
|
65
|
+
this.shadowRoot.append(await icon.getIcon(this.icon));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return USAIconElement = _classThis;
|
|
70
|
+
})();
|
|
71
|
+
export { USAIconElement };
|
|
72
|
+
//# sourceMappingURL=icon.element.js.map
|
|
@@ -0,0 +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,QAAQ,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;IA6B7C,cAAc;4BApB1B,OAAO,CAAC;YACP,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;KAaF;aACF;SACF,CAAC,EACD,UAAU,EAAE;;;;sBACuB,WAAW;;;;;;8BAAnB,SAAQ,WAAW;;;;gCAC5C,IAAI,EAAE;sCAQN,QAAQ,EAAE;YAPX,iKAAS,IAAI,6BAAJ,IAAI,mFAAgC;YAQ7C,iLAAA,UAAU,6DAGT;YAbH,6KA4BC;;;YA5BY,uDAAc;;QAEzB,0BAFW,mDAAc,8CAEA,mBAAmB,GAAC;QAA7C,IAAS,IAAI,0CAAgC;QAA7C,IAAS,IAAI,gDAAgC;QAE7C,UAAU,sDAAkB,MAAM,EAAC;QAEnC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5B,SAAS,GAAG,KAAK,CAAC;QAGlB,UAAU;YACR,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;QAED,wBAAwB;YACtB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,CAAC;QACH,CAAC;QAED,KAAK,CAAC,WAAW;YACf,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE1B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;;;;SA3BU,cAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/web-components";
|
|
2
|
+
import type { USAIconElement } from "./icon.element.js";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
tags: never[];
|
|
6
|
+
render(args: USAIconElement): import("lit-html").TemplateResult<1>;
|
|
7
|
+
argTypes: {};
|
|
8
|
+
args: {};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<USAIconElement>;
|
|
12
|
+
export declare const AllIcons: Story;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
import { ICON_TYPES } from "./icon-types.js";
|
|
3
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "usa-icon",
|
|
6
|
+
tags: [],
|
|
7
|
+
render(args) {
|
|
8
|
+
return html `<usa-icon icon=${args.icon}></usa-icon>`;
|
|
9
|
+
},
|
|
10
|
+
argTypes: {},
|
|
11
|
+
args: {},
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const AllIcons = {
|
|
15
|
+
render() {
|
|
16
|
+
async function copyIcon(icon) {
|
|
17
|
+
try {
|
|
18
|
+
await navigator.clipboard.writeText(`<usa-icon icon=${icon}></usa-icon>`);
|
|
19
|
+
alert(`copied markup for ${icon}`);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error("Failed to copy: ", err);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return html `<div style="display: flex; flex-wrap: wrap; gap: .75rem;">
|
|
26
|
+
${html `${ICON_TYPES.map((icon) => html `
|
|
27
|
+
<button
|
|
28
|
+
@click=${() => copyIcon(icon)}
|
|
29
|
+
style="padding: .5rem 1rem .5rem .5rem; cursor: pointer; background: #fff; border-radius: 4px; gap: .5rem; display: flex; align-items: center"
|
|
30
|
+
>
|
|
31
|
+
<usa-icon icon=${icon}></usa-icon>
|
|
32
|
+
|
|
33
|
+
${icon}
|
|
34
|
+
</button>
|
|
35
|
+
`)}`}
|
|
36
|
+
</div>`;
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=icon.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.stories.js","sourceRoot":"","sources":["../../../src/lib/icon/icon.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,kFAAkF;AAClF,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,EAAE;IACR,MAAM,CAAC,IAAI;QACT,OAAO,IAAI,CAAA,kBAAkB,IAAI,CAAC,IAAI,cAAc,CAAC;IACvD,CAAC;IACD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,EAAE;CACsB,CAAC;AAEjC,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,QAAQ,GAAU;IAC7B,MAAM;QACJ,KAAK,UAAU,QAAQ,CAAC,IAAY;YAClC,IAAI,CAAC;gBACH,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CACjC,kBAAkB,IAAI,cAAc,CACrC,CAAC;gBACF,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAA;QACP,IAAI,CAAA,GAAG,UAAU,CAAC,GAAG,CACrB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;;qBAED,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;;;6BAGZ,IAAI;;cAEnB,IAAI;;SAET,CACF,EAAE;WACE,CAAC;IACV,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Changes } from "@joist/observable";
|
|
2
|
+
import type { MaskableElement } from "../input-mask/maskable.element.js";
|
|
3
|
+
declare global {
|
|
4
|
+
interface HTMLElementTagNameMap {
|
|
5
|
+
"usa-input": USATextInputElement;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare class USATextInputElement extends HTMLElement implements MaskableElement {
|
|
9
|
+
#private;
|
|
10
|
+
static formAssociated: boolean;
|
|
11
|
+
accessor name: string;
|
|
12
|
+
accessor autocomplete: AutoFill;
|
|
13
|
+
accessor placeholder: string;
|
|
14
|
+
accessor required: boolean;
|
|
15
|
+
accessor detail: "pfx" | "sfx" | "";
|
|
16
|
+
accessor value: string;
|
|
17
|
+
accessor selectionStart: number | null;
|
|
18
|
+
accessor selectionEnd: number | null;
|
|
19
|
+
onReady(): void;
|
|
20
|
+
attributeChangedCallback(attr: string): void;
|
|
21
|
+
connectedCallback(): void;
|
|
22
|
+
onChange(changes: Changes<this>): void;
|
|
23
|
+
onKeyDown(e: KeyboardEvent): void;
|
|
24
|
+
onInputChange(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { attr, css, element, html, listen, query, ready } from "@joist/element";
|
|
3
|
+
import { effect, observe } from "@joist/observable";
|
|
4
|
+
let USATextInputElement = (() => {
|
|
5
|
+
let _classDecorators = [element({
|
|
6
|
+
tagName: "usa-input",
|
|
7
|
+
shadowDomOpts: {
|
|
8
|
+
mode: "open",
|
|
9
|
+
delegatesFocus: true,
|
|
10
|
+
},
|
|
11
|
+
shadowDom: [
|
|
12
|
+
css `
|
|
13
|
+
* {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host {
|
|
18
|
+
font-size: 1.06rem;
|
|
19
|
+
line-height: 1.3;
|
|
20
|
+
display: block;
|
|
21
|
+
font-weight: 400;
|
|
22
|
+
max-width: 30rem;
|
|
23
|
+
margin-bottom: 1.5rem;
|
|
24
|
+
position: relative;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
input {
|
|
28
|
+
border-width: 1px;
|
|
29
|
+
border-color: #5c5c5c;
|
|
30
|
+
border-style: solid;
|
|
31
|
+
border-radius: 0;
|
|
32
|
+
color: #1b1b1b;
|
|
33
|
+
display: block;
|
|
34
|
+
height: 2.5rem;
|
|
35
|
+
line-height: 1.3;
|
|
36
|
+
font-size: 1.06rem;
|
|
37
|
+
margin-top: 0.5rem;
|
|
38
|
+
padding: 0.5rem;
|
|
39
|
+
width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
input:not(:disabled):focus {
|
|
43
|
+
outline: 0.25rem solid #2491ff;
|
|
44
|
+
outline-offset: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
slot[name="detail"]::slotted(*) {
|
|
48
|
+
color: #757575;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
slot[name="detail"]::slotted(usa-icon) {
|
|
52
|
+
width: 1.5rem;
|
|
53
|
+
height: 1.5rem;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
slot[name="detail"] {
|
|
57
|
+
display: block;
|
|
58
|
+
position: absolute;
|
|
59
|
+
bottom: 0.21rem;
|
|
60
|
+
left: 0.5rem;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:host([detail="pfx"]) input {
|
|
64
|
+
padding-left: 2.5rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host([detail="sfx"]) input {
|
|
68
|
+
padding-right: 2.5rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([detail="sfx"]) slot[name="detail"] {
|
|
72
|
+
right: 0.5rem;
|
|
73
|
+
left: auto;
|
|
74
|
+
}
|
|
75
|
+
`,
|
|
76
|
+
html `
|
|
77
|
+
<label>
|
|
78
|
+
<slot name="detail"></slot>
|
|
79
|
+
|
|
80
|
+
<slot></slot>
|
|
81
|
+
|
|
82
|
+
<input tabindex="0" />
|
|
83
|
+
</label>
|
|
84
|
+
`,
|
|
85
|
+
],
|
|
86
|
+
})];
|
|
87
|
+
let _classDescriptor;
|
|
88
|
+
let _classExtraInitializers = [];
|
|
89
|
+
let _classThis;
|
|
90
|
+
let _classSuper = HTMLElement;
|
|
91
|
+
let _instanceExtraInitializers = [];
|
|
92
|
+
let _name_decorators;
|
|
93
|
+
let _name_initializers = [];
|
|
94
|
+
let _name_extraInitializers = [];
|
|
95
|
+
let _autocomplete_decorators;
|
|
96
|
+
let _autocomplete_initializers = [];
|
|
97
|
+
let _autocomplete_extraInitializers = [];
|
|
98
|
+
let _placeholder_decorators;
|
|
99
|
+
let _placeholder_initializers = [];
|
|
100
|
+
let _placeholder_extraInitializers = [];
|
|
101
|
+
let _required_decorators;
|
|
102
|
+
let _required_initializers = [];
|
|
103
|
+
let _required_extraInitializers = [];
|
|
104
|
+
let _detail_decorators;
|
|
105
|
+
let _detail_initializers = [];
|
|
106
|
+
let _detail_extraInitializers = [];
|
|
107
|
+
let _value_decorators;
|
|
108
|
+
let _value_initializers = [];
|
|
109
|
+
let _value_extraInitializers = [];
|
|
110
|
+
let _selectionStart_decorators;
|
|
111
|
+
let _selectionStart_initializers = [];
|
|
112
|
+
let _selectionStart_extraInitializers = [];
|
|
113
|
+
let _selectionEnd_decorators;
|
|
114
|
+
let _selectionEnd_initializers = [];
|
|
115
|
+
let _selectionEnd_extraInitializers = [];
|
|
116
|
+
let _onReady_decorators;
|
|
117
|
+
let _onChange_decorators;
|
|
118
|
+
let _onKeyDown_decorators;
|
|
119
|
+
let _onInputChange_decorators;
|
|
120
|
+
var USATextInputElement = class extends _classSuper {
|
|
121
|
+
static { _classThis = this; }
|
|
122
|
+
static {
|
|
123
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
124
|
+
_name_decorators = [attr()];
|
|
125
|
+
_autocomplete_decorators = [attr()];
|
|
126
|
+
_placeholder_decorators = [attr()];
|
|
127
|
+
_required_decorators = [attr()];
|
|
128
|
+
_detail_decorators = [attr({
|
|
129
|
+
observed: false,
|
|
130
|
+
})];
|
|
131
|
+
_value_decorators = [attr({
|
|
132
|
+
reflect: false,
|
|
133
|
+
}), observe()];
|
|
134
|
+
_selectionStart_decorators = [observe()];
|
|
135
|
+
_selectionEnd_decorators = [observe()];
|
|
136
|
+
_onReady_decorators = [ready()];
|
|
137
|
+
_onChange_decorators = [effect()];
|
|
138
|
+
_onKeyDown_decorators = [listen("keydown")];
|
|
139
|
+
_onInputChange_decorators = [listen("input")];
|
|
140
|
+
__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);
|
|
141
|
+
__esDecorate(this, null, _autocomplete_decorators, { kind: "accessor", name: "autocomplete", static: false, private: false, access: { has: obj => "autocomplete" in obj, get: obj => obj.autocomplete, set: (obj, value) => { obj.autocomplete = value; } }, metadata: _metadata }, _autocomplete_initializers, _autocomplete_extraInitializers);
|
|
142
|
+
__esDecorate(this, null, _placeholder_decorators, { kind: "accessor", name: "placeholder", static: false, private: false, access: { has: obj => "placeholder" in obj, get: obj => obj.placeholder, set: (obj, value) => { obj.placeholder = value; } }, metadata: _metadata }, _placeholder_initializers, _placeholder_extraInitializers);
|
|
143
|
+
__esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
|
|
144
|
+
__esDecorate(this, null, _detail_decorators, { kind: "accessor", name: "detail", static: false, private: false, access: { has: obj => "detail" in obj, get: obj => obj.detail, set: (obj, value) => { obj.detail = value; } }, metadata: _metadata }, _detail_initializers, _detail_extraInitializers);
|
|
145
|
+
__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);
|
|
146
|
+
__esDecorate(this, null, _selectionStart_decorators, { kind: "accessor", name: "selectionStart", static: false, private: false, access: { has: obj => "selectionStart" in obj, get: obj => obj.selectionStart, set: (obj, value) => { obj.selectionStart = value; } }, metadata: _metadata }, _selectionStart_initializers, _selectionStart_extraInitializers);
|
|
147
|
+
__esDecorate(this, null, _selectionEnd_decorators, { kind: "accessor", name: "selectionEnd", static: false, private: false, access: { has: obj => "selectionEnd" in obj, get: obj => obj.selectionEnd, set: (obj, value) => { obj.selectionEnd = value; } }, metadata: _metadata }, _selectionEnd_initializers, _selectionEnd_extraInitializers);
|
|
148
|
+
__esDecorate(this, null, _onReady_decorators, { kind: "method", name: "onReady", static: false, private: false, access: { has: obj => "onReady" in obj, get: obj => obj.onReady }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
149
|
+
__esDecorate(this, null, _onChange_decorators, { kind: "method", name: "onChange", static: false, private: false, access: { has: obj => "onChange" in obj, get: obj => obj.onChange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
150
|
+
__esDecorate(this, null, _onKeyDown_decorators, { kind: "method", name: "onKeyDown", static: false, private: false, access: { has: obj => "onKeyDown" in obj, get: obj => obj.onKeyDown }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
151
|
+
__esDecorate(this, null, _onInputChange_decorators, { kind: "method", name: "onInputChange", static: false, private: false, access: { has: obj => "onInputChange" in obj, get: obj => obj.onInputChange }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
152
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
153
|
+
USATextInputElement = _classThis = _classDescriptor.value;
|
|
154
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
155
|
+
}
|
|
156
|
+
static formAssociated = true;
|
|
157
|
+
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers, ""));
|
|
158
|
+
get name() { return this.#name_accessor_storage; }
|
|
159
|
+
set name(value) { this.#name_accessor_storage = value; }
|
|
160
|
+
#autocomplete_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _autocomplete_initializers, "on"));
|
|
161
|
+
get autocomplete() { return this.#autocomplete_accessor_storage; }
|
|
162
|
+
set autocomplete(value) { this.#autocomplete_accessor_storage = value; }
|
|
163
|
+
#placeholder_accessor_storage = (__runInitializers(this, _autocomplete_extraInitializers), __runInitializers(this, _placeholder_initializers, ""));
|
|
164
|
+
get placeholder() { return this.#placeholder_accessor_storage; }
|
|
165
|
+
set placeholder(value) { this.#placeholder_accessor_storage = value; }
|
|
166
|
+
#required_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _required_initializers, false));
|
|
167
|
+
get required() { return this.#required_accessor_storage; }
|
|
168
|
+
set required(value) { this.#required_accessor_storage = value; }
|
|
169
|
+
#detail_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _detail_initializers, ""));
|
|
170
|
+
get detail() { return this.#detail_accessor_storage; }
|
|
171
|
+
set detail(value) { this.#detail_accessor_storage = value; }
|
|
172
|
+
#value_accessor_storage = (__runInitializers(this, _detail_extraInitializers), __runInitializers(this, _value_initializers, ""));
|
|
173
|
+
get value() { return this.#value_accessor_storage; }
|
|
174
|
+
set value(value) { this.#value_accessor_storage = value; }
|
|
175
|
+
#selectionStart_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _selectionStart_initializers, null));
|
|
176
|
+
get selectionStart() { return this.#selectionStart_accessor_storage; }
|
|
177
|
+
set selectionStart(value) { this.#selectionStart_accessor_storage = value; }
|
|
178
|
+
#selectionEnd_accessor_storage = (__runInitializers(this, _selectionStart_extraInitializers), __runInitializers(this, _selectionEnd_initializers, null));
|
|
179
|
+
get selectionEnd() { return this.#selectionEnd_accessor_storage; }
|
|
180
|
+
set selectionEnd(value) { this.#selectionEnd_accessor_storage = value; }
|
|
181
|
+
#internals = (__runInitializers(this, _selectionEnd_extraInitializers), this.attachInternals());
|
|
182
|
+
#input = query("input");
|
|
183
|
+
onReady() {
|
|
184
|
+
const input = this.#input();
|
|
185
|
+
input.autofocus = this.autofocus;
|
|
186
|
+
}
|
|
187
|
+
attributeChangedCallback(attr) {
|
|
188
|
+
const input = this.#input();
|
|
189
|
+
switch (attr) {
|
|
190
|
+
case "autocomplete":
|
|
191
|
+
input.autocomplete = this.autocomplete;
|
|
192
|
+
break;
|
|
193
|
+
case "placeholder":
|
|
194
|
+
input.placeholder = this.placeholder;
|
|
195
|
+
break;
|
|
196
|
+
case "name":
|
|
197
|
+
input.name = this.name;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
connectedCallback() {
|
|
202
|
+
this.#syncFormState();
|
|
203
|
+
}
|
|
204
|
+
onChange(changes) {
|
|
205
|
+
const input = this.#input();
|
|
206
|
+
if (input.value !== this.value) {
|
|
207
|
+
input.value = this.value;
|
|
208
|
+
}
|
|
209
|
+
if (changes.has("selectionStart")) {
|
|
210
|
+
input.selectionStart = this.selectionStart;
|
|
211
|
+
}
|
|
212
|
+
if (changes.has("selectionEnd")) {
|
|
213
|
+
input.selectionEnd = this.selectionEnd;
|
|
214
|
+
}
|
|
215
|
+
this.#syncFormState();
|
|
216
|
+
}
|
|
217
|
+
onKeyDown(e) {
|
|
218
|
+
const form = this.#internals.form;
|
|
219
|
+
if (form) {
|
|
220
|
+
const hasModifier = e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
|
|
221
|
+
if (e.key.toUpperCase() === "ENTER" && !hasModifier) {
|
|
222
|
+
// this makes sure that the user has a chance to cancel the event before submitting
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
if (!e.defaultPrevented && !e.isComposing) {
|
|
225
|
+
form.submit();
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
onInputChange() {
|
|
232
|
+
const input = this.#input();
|
|
233
|
+
this.value = input.value;
|
|
234
|
+
this.selectionStart = input.selectionStart;
|
|
235
|
+
this.selectionEnd = input.selectionEnd;
|
|
236
|
+
}
|
|
237
|
+
#syncFormState() {
|
|
238
|
+
const input = this.#input();
|
|
239
|
+
this.#internals.setFormValue(input.value);
|
|
240
|
+
if (this.required && !input.value) {
|
|
241
|
+
this.#internals.setValidity({ valueMissing: true }, "Required", input);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
this.#internals.setValidity({});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
static {
|
|
248
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
return USATextInputElement = _classThis;
|
|
252
|
+
})();
|
|
253
|
+
export { USATextInputElement };
|
|
254
|
+
//# sourceMappingURL=input.element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.element.js","sourceRoot":"","sources":["../../../src/lib/input/input.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAgB,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;IA4FrD,mBAAmB;4BAlF/B,OAAO,CAAC;YACP,OAAO,EAAE,WAAW;YACpB,aAAa,EAAE;gBACb,IAAI,EAAE,MAAM;gBACZ,cAAc,EAAE,IAAI;aACrB;YACD,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+DF;gBACD,IAAI,CAAA;;;;;;;;KAQH;aACF;SACF,CAAC;;;;sBAEQ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAAnB,SAAQ,WAAW;;;;gCAKlB,IAAI,EAAE;wCAGN,IAAI,EAAE;uCAGN,IAAI,EAAE;oCAGN,IAAI,EAAE;kCAGN,IAAI,CAAC;oBACJ,QAAQ,EAAE,KAAK;iBAChB,CAAC;iCAGD,IAAI,CAAC;oBACJ,OAAO,EAAE,KAAK;iBACf,CAAC,EACD,OAAO,EAAE;0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AI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;;YA1HU,uDAAmB;;;;;SAAnB,mBAAmB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/web-components";
|
|
2
|
+
import type { USATextInputElement } from "./input.element.js";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
tags: string[];
|
|
6
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
7
|
+
argTypes: {};
|
|
8
|
+
args: {};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<USATextInputElement>;
|
|
12
|
+
export declare const Primary: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
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-input",
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
render() {
|
|
7
|
+
return html `
|
|
8
|
+
<form @submit=${(e) => e.preventDefault()}>
|
|
9
|
+
<usa-input name="fname" value="Danny" autocomplete="off" detail="pfx">
|
|
10
|
+
<usa-icon icon="credit_card" slot="detail"></usa-icon>
|
|
11
|
+
|
|
12
|
+
First name
|
|
13
|
+
</usa-input>
|
|
14
|
+
|
|
15
|
+
<usa-button type="submit">Submit</usa-button>
|
|
16
|
+
</form>
|
|
17
|
+
`;
|
|
18
|
+
},
|
|
19
|
+
argTypes: {},
|
|
20
|
+
args: {},
|
|
21
|
+
};
|
|
22
|
+
export default meta;
|
|
23
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
24
|
+
export const Primary = {};
|
|
25
|
+
//# sourceMappingURL=input.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.stories.js","sourceRoot":"","sources":["../../../src/lib/input/input.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,MAAM;QACJ,OAAO,IAAI,CAAA;sBACO,CAAC,CAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE;;;;;;;;;KASjD,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,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./input.element.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import "./input.element.js";
|
|
2
|
+
import { fireEvent } from "@noctuatech-uswds/testing";
|
|
3
|
+
import { assert, fixture, html } from "@open-wc/testing";
|
|
4
|
+
describe("usa-input", () => {
|
|
5
|
+
it("should be accessible", async () => {
|
|
6
|
+
const form = await fixture(html `
|
|
7
|
+
<usa-input name="fname" value="Foo">Hello World</usa-input>
|
|
8
|
+
`);
|
|
9
|
+
return assert.isAccessible(form);
|
|
10
|
+
});
|
|
11
|
+
it("should submit form with default values", async () => {
|
|
12
|
+
const form = await fixture(html `
|
|
13
|
+
<form>
|
|
14
|
+
<usa-input name="fname" value="Foo">Hello World</usa-input>
|
|
15
|
+
|
|
16
|
+
<button>Submit</button>
|
|
17
|
+
</form>
|
|
18
|
+
`);
|
|
19
|
+
const value = new FormData(form);
|
|
20
|
+
assert.equal(value.get("fname"), "Foo");
|
|
21
|
+
});
|
|
22
|
+
it("should update form value as input value changed", async () => {
|
|
23
|
+
const form = await fixture(html `
|
|
24
|
+
<form>
|
|
25
|
+
<usa-input name="fname">Hello World</usa-input>
|
|
26
|
+
|
|
27
|
+
<button>Submit</button>
|
|
28
|
+
</form>
|
|
29
|
+
`);
|
|
30
|
+
const input = form.querySelector("usa-input");
|
|
31
|
+
const nativeInput = input?.shadowRoot?.querySelector("input");
|
|
32
|
+
if (nativeInput) {
|
|
33
|
+
nativeInput.value = "Bar";
|
|
34
|
+
await fireEvent.input(nativeInput, { bubbles: true });
|
|
35
|
+
}
|
|
36
|
+
const value = new FormData(form);
|
|
37
|
+
assert.equal(value.get("fname"), "Bar");
|
|
38
|
+
});
|
|
39
|
+
it("should not submit when not valid", async () => {
|
|
40
|
+
const form = await fixture(html `
|
|
41
|
+
<form>
|
|
42
|
+
<usa-input name="fname" required>Hello World</usa-input>
|
|
43
|
+
|
|
44
|
+
<button>Submit</button>
|
|
45
|
+
</form>
|
|
46
|
+
`);
|
|
47
|
+
assert.equal(form.checkValidity(), false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=input.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.test.js","sourceRoot":"","sources":["../../../src/lib/input/input.test.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAkB,IAAI,CAAA;;KAE/C,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAkB,IAAI,CAAA;;;;;;KAM/C,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEjC,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
+
Numbers: RegExp;
|
|
10
|
+
};
|
|
11
|
+
export interface FormattedResult {
|
|
12
|
+
raw: string;
|
|
13
|
+
formatted: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function format(value: string, pattern: string): FormattedResult;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export var PatternChar;
|
|
2
|
+
(function (PatternChar) {
|
|
3
|
+
PatternChar["Any"] = "*";
|
|
4
|
+
PatternChar["Number"] = "9";
|
|
5
|
+
PatternChar["Letter"] = "A";
|
|
6
|
+
})(PatternChar || (PatternChar = {}));
|
|
7
|
+
export const PATTERN_CHARS = Object.values(PatternChar);
|
|
8
|
+
export const REG_EXPS = {
|
|
9
|
+
Letters: /^[a-z]/i,
|
|
10
|
+
Numbers: /^[0-9]/i,
|
|
11
|
+
};
|
|
12
|
+
export function format(value, pattern) {
|
|
13
|
+
const raw = value.replace(/[^a-z0-9]/gi, ""); // remove all special chars
|
|
14
|
+
const chars = raw.split("");
|
|
15
|
+
let count = 0;
|
|
16
|
+
let formatted = "";
|
|
17
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
18
|
+
const patternChar = pattern[i];
|
|
19
|
+
const char = chars[count];
|
|
20
|
+
if (char && patternChar) {
|
|
21
|
+
if (patternChar === PatternChar.Any) {
|
|
22
|
+
// Any letter or number
|
|
23
|
+
formatted += char;
|
|
24
|
+
count++;
|
|
25
|
+
}
|
|
26
|
+
else if (patternChar === PatternChar.Number) {
|
|
27
|
+
// Numbers only
|
|
28
|
+
if (/^[0-9]/i.test(char)) {
|
|
29
|
+
formatted += char;
|
|
30
|
+
}
|
|
31
|
+
count++;
|
|
32
|
+
}
|
|
33
|
+
else if (patternChar === PatternChar.Letter) {
|
|
34
|
+
// Letters only
|
|
35
|
+
if (/^[a-z]/i.test(char)) {
|
|
36
|
+
formatted += char;
|
|
37
|
+
}
|
|
38
|
+
count++;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
formatted += patternChar;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { raw, formatted };
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/lib/input-mask/format.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,wBAAS,CAAA;IACT,2BAAY,CAAA;IACZ,2BAAY,CAAA;AACd,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;CACnB,CAAC;AAOF,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,OAAe;IACnD,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,2BAA2B;IACzE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE5B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,SAAS,GAAG,EAAE,CAAC;IAEnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC;YACxB,IAAI,WAAW,KAAK,WAAW,CAAC,GAAG,EAAE,CAAC;gBACpC,uBAAuB;gBACvB,SAAS,IAAI,IAAI,CAAC;gBAClB,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,IAAI,WAAW,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;gBAC9C,eAAe;gBACf,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzB,SAAS,IAAI,IAAI,CAAC;gBACpB,CAAC;gBAED,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,IAAI,WAAW,KAAK,WAAW,CAAC,MAAM,EAAE,CAAC;gBAC9C,eAAe;gBACf,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;oBACzB,SAAS,IAAI,IAAI,CAAC;gBACpB,CAAC;gBAED,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,SAAS,IAAI,WAAW,CAAC;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElementTagNameMap {
|
|
3
|
+
"usa-input-mask": USAInputMaskElement;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export declare class USAInputMaskElement extends HTMLElement {
|
|
7
|
+
#private;
|
|
8
|
+
accessor mask: string;
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
onInput(e: Event): void;
|
|
11
|
+
onKeyDown(e: KeyboardEvent): void;
|
|
12
|
+
}
|