@noctuatech/uswds 1.3.0 → 1.3.2
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 +56 -21
- package/src/lib/accordion/accordion.element.ts +18 -26
- package/src/lib/alert/alert.element.ts +21 -20
- package/src/lib/alert/alert.stories.ts +10 -15
- package/src/lib/file-input/file-input-preview/file-input-preview.element.ts +17 -14
- package/src/lib/file-input/file-input.element.ts +56 -61
- package/src/lib/icon/icon.element.ts +37 -27
- package/src/lib/input/input.element.ts +30 -39
- package/src/lib/input/input.test.ts +14 -16
- package/src/lib/input-mask/input-mask.element.ts +13 -13
- package/src/lib/input-mask/input-mask.stories.ts +7 -12
- package/src/lib/input-mask/input-mask.test.ts +45 -50
- package/src/lib/services/icon.service.test.ts +14 -14
- package/src/lib/services/icon.service.ts +18 -17
- package/src/lib/textarea/textarea.element.ts +14 -18
- package/target/lib/accordion/accordion.element.d.ts +4 -3
- package/target/lib/accordion/accordion.element.js +20 -12
- package/target/lib/accordion/accordion.element.js.map +1 -1
- package/target/lib/alert/alert.element.d.ts +4 -4
- package/target/lib/alert/alert.element.js +20 -12
- package/target/lib/alert/alert.element.js.map +1 -1
- package/target/lib/alert/alert.stories.d.ts +2 -2
- package/target/lib/alert/alert.stories.js +3 -3
- package/target/lib/alert/alert.stories.js.map +1 -1
- package/target/lib/file-input/file-input-preview/file-input-preview.element.d.ts +2 -2
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js +8 -8
- package/target/lib/file-input/file-input-preview/file-input-preview.element.js.map +1 -1
- package/target/lib/file-input/file-input.element.d.ts +2 -3
- package/target/lib/file-input/file-input.element.js +23 -31
- package/target/lib/file-input/file-input.element.js.map +1 -1
- package/target/lib/icon/icon.element.d.ts +4 -4
- package/target/lib/icon/icon.element.js +35 -25
- package/target/lib/icon/icon.element.js.map +1 -1
- package/target/lib/input/input.element.d.ts +5 -5
- package/target/lib/input/input.element.js +20 -22
- package/target/lib/input/input.element.js.map +1 -1
- package/target/lib/input/input.test.d.ts +1 -1
- package/target/lib/input/input.test.js +13 -13
- package/target/lib/input/input.test.js.map +1 -1
- package/target/lib/input-mask/input-mask.element.d.ts +1 -1
- package/target/lib/input-mask/input-mask.element.js +11 -11
- package/target/lib/input-mask/input-mask.element.js.map +1 -1
- package/target/lib/input-mask/input-mask.stories.d.ts +2 -2
- package/target/lib/input-mask/input-mask.stories.js +5 -5
- package/target/lib/input-mask/input-mask.stories.js.map +1 -1
- package/target/lib/input-mask/input-mask.test.d.ts +2 -2
- package/target/lib/input-mask/input-mask.test.js +43 -43
- package/target/lib/input-mask/input-mask.test.js.map +1 -1
- package/target/lib/services/icon.service.d.ts +2 -1
- package/target/lib/services/icon.service.js +15 -15
- package/target/lib/services/icon.service.js.map +1 -1
- package/target/lib/services/icon.service.test.js +14 -14
- package/target/lib/services/icon.service.test.js.map +1 -1
- package/target/lib/textarea/textarea.element.d.ts +1 -1
- package/target/lib/textarea/textarea.element.js +10 -10
- package/target/lib/textarea/textarea.element.js.map +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import
|
|
3
|
-
import { css, element, html } from
|
|
4
|
-
import { observe } from
|
|
5
|
-
import { bind } from
|
|
2
|
+
import '@joist/templating/define.js';
|
|
3
|
+
import { css, element, html } from '@joist/element';
|
|
4
|
+
import { observe } from '@joist/observable';
|
|
5
|
+
import { bind } from '@joist/templating';
|
|
6
6
|
let USAFileInputPreviewElement = (() => {
|
|
7
7
|
let _classDecorators = [element({
|
|
8
|
-
tagName:
|
|
8
|
+
tagName: 'usa-file-input-preview',
|
|
9
9
|
shadowDom: [
|
|
10
|
-
css `*{box-sizing:border-box}:host{display:block;font-size:.87rem;pointer-events:none;position:relative;text-align:left;word-wrap:anywhere;z-index:3;border-radius:
|
|
11
|
-
html `<slot class="preview-heading"></slot><j-for bind="fileEntries" key="src"><template><div class="preview-item"><j-if bind="each.value.isImage"><template><j-props><img height="40" width="40" aria-hidden="true" $.src="each.value.src"></j-props></template><template else><usa-icon icon="file_present"></usa-icon></template></j-if><j-value bind="each.value.file.name"></j-value></div></template></j-for>`,
|
|
10
|
+
css `*{box-sizing:border-box}:host{display:block;font-size:.87rem;pointer-events:none;position:relative;text-align:left;word-wrap:anywhere;z-index:3;border-radius:0;overflow:hidden}:host([hidden]){display:none}img{border:0;display:block;height:2.5rem;margin-right:.5rem;-o-object-fit:contain;object-fit:contain;width:2.5rem}.preview-heading{background:#d9e8f6;align-items:center;display:flex;pointer-events:none;position:relative;z-index:3;font-weight:700;justify-content:space-between;padding:.5rem;text-align:left;font-size:.93rem;line-height:1.6}.preview-item{background:#d9e8f6;align-items:center;display:flex;padding:.5rem;width:100%;margin-top:1px;margin-bottom:1px}`,
|
|
11
|
+
html `<slot class="preview-heading" part="heading"></slot><j-for bind="fileEntries" key="src"><template><div class="preview-item" part="item"><j-if bind="each.value.isImage"><template><j-props><img height="40" width="40" aria-hidden="true" $.src="each.value.src"></j-props></template><template else><usa-icon icon="file_present"></usa-icon></template></j-if><j-value bind="each.value.file.name"></j-value></div></template></j-for>`,
|
|
12
12
|
],
|
|
13
13
|
})];
|
|
14
14
|
let _classDescriptor;
|
|
@@ -33,7 +33,7 @@ let USAFileInputPreviewElement = (() => {
|
|
|
33
33
|
return Array.from(i.files).map((file) => ({
|
|
34
34
|
file,
|
|
35
35
|
src: URL.createObjectURL(file),
|
|
36
|
-
isImage: file.type.startsWith(
|
|
36
|
+
isImage: file.type.startsWith('image'),
|
|
37
37
|
}));
|
|
38
38
|
})];
|
|
39
39
|
__esDecorate(this, null, _files_decorators, { kind: "accessor", name: "files", static: false, private: false, access: { has: obj => "files" in obj, get: obj => obj.files, set: (obj, value) => { obj.files = value; } }, metadata: _metadata }, _files_initializers, _files_extraInitializers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input-preview.element.js","sourceRoot":"","sources":["../../../../src/lib/file-input/file-input-preview/file-input-preview.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-input-preview.element.js","sourceRoot":"","sources":["../../../../src/lib/file-input/file-input-preview/file-input-preview.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;IA4F5B,0BAA0B;4BApFtC,OAAO,CAAC;YACP,OAAO,EAAE,wBAAwB;YACjC,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuDF;gBACD,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;KAsBH;aACF;SACF,CAAC;;;;sBAC8C,WAAW;;;;;;;0CAAnB,SAAQ,WAAW;;;;iCACxD,OAAO,EAAE;uCAGT,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBACV,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACrC,OAAO,EAAE,CAAC;oBACZ,CAAC;oBAED,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;wBACxC,IAAI;wBACJ,GAAG,EAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;wBAC9B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;qBACvC,CAAC,CAAC,CAAC;gBACN,CAAC,CAAC;YAZF,oKAAS,KAAK,6BAAL,KAAK,qFAAyB;YAavC,sLAAS,WAAW,6BAAX,WAAW,iGAAmB;YAfzC,6KAgBC;;;YAhBY,uDAA0B;;QAErC,uEAAkC,IAAI,EAAC;QAAvC,IAAS,KAAK,2CAAyB;QAAvC,IAAS,KAAK,iDAAyB;QAavC,uIAAoC,EAAE,GAAC;QAAvC,IAAS,WAAW,iDAAmB;QAAvC,IAAS,WAAW,uDAAmB;;;;;;;;SAf5B,0BAA0B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@joist/templating/define.js';
|
|
2
2
|
declare global {
|
|
3
3
|
interface HTMLElementTagNameMap {
|
|
4
|
-
|
|
4
|
+
'usa-file-input': USAFileInputElement;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export declare class USAFileInputElement extends HTMLElement {
|
|
@@ -13,7 +13,6 @@ export declare class USAFileInputElement extends HTMLElement {
|
|
|
13
13
|
accessor required: boolean;
|
|
14
14
|
accessor files: FileList | null;
|
|
15
15
|
accessor filesVisible: boolean;
|
|
16
|
-
attributeChangedCallback(): void;
|
|
17
16
|
connectedCallback(): void;
|
|
18
17
|
syncFormValues(): void;
|
|
19
18
|
onInputChange(): void;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import
|
|
3
|
-
import { attr, css, element, html, listen, query } from
|
|
4
|
-
import { effect } from
|
|
5
|
-
import { bind } from
|
|
2
|
+
import '@joist/templating/define.js';
|
|
3
|
+
import { attr, css, element, html, listen, query } from '@joist/element';
|
|
4
|
+
import { effect } from '@joist/observable';
|
|
5
|
+
import { bind } from '@joist/templating';
|
|
6
6
|
let USAFileInputElement = (() => {
|
|
7
7
|
let _classDecorators = [element({
|
|
8
|
-
tagName:
|
|
8
|
+
tagName: 'usa-file-input',
|
|
9
9
|
shadowDom: [
|
|
10
10
|
css `*{box-sizing:border-box}:host{display:block;max-width:30rem;position:relative;margin-bottom:1.5rem}label{display:block}input{cursor:pointer;left:0;margin:0;max-width:none;position:absolute;text-indent:-999em;width:100%;z-index:1;bottom:0;top:0}input:focus{outline:.25rem solid #2491ff;outline-offset:0}label slot.label{font-size:1.06rem;line-height:1.3;display:block;font-weight:400;margin-bottom:.5rem}:host(.dragenter) .box{border-color:#2491ff}.box{border:1px dashed #adadad;border-radius:0;display:flex;font-size:.93rem;position:relative;text-align:center;width:100%;height:5.2rem;align-items:center;justify-content:center}.container{position:relative}`,
|
|
11
|
-
html `<label><slot class="label"></slot><div class="container"><input type="file" tabindex="0"><j-if bind="filesVisible"><template><j-props><usa-file-input-preview $.files="files" part="preview">Selected file<usa-link>Change file</usa-link></usa-file-input-preview></j-props></template><template else><div class="box" part="input"><slot name="description">Drag file here or<usa-link>choose from folder</usa-link></slot></div></template></j-if></div
|
|
11
|
+
html `<label for="file-input"><slot class="label"></slot></label><div class="container"><j-props><input id="file-input" type="file" tabindex="0" $.name="name" $.multiple="multiple" $.accept="accept" $.required="required"></j-props><j-if bind="filesVisible"><template><j-props><usa-file-input-preview $.files="files" part="preview" exportparts="heading, item">Selected file <usa-link>Change file</usa-link></usa-file-input-preview></j-props></template><template else><div class="box" part="input"><slot name="description">Drag file here or<usa-link>choose from folder</usa-link></slot></div></template></j-if></div>`,
|
|
12
12
|
],
|
|
13
13
|
})];
|
|
14
14
|
let _classDescriptor;
|
|
@@ -43,17 +43,17 @@ let USAFileInputElement = (() => {
|
|
|
43
43
|
static { _classThis = this; }
|
|
44
44
|
static {
|
|
45
45
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
46
|
-
_name_decorators = [attr()];
|
|
47
|
-
_multiple_decorators = [attr()];
|
|
48
|
-
_accept_decorators = [attr()];
|
|
49
|
-
_required_decorators = [attr()];
|
|
46
|
+
_name_decorators = [attr(), bind()];
|
|
47
|
+
_multiple_decorators = [attr(), bind()];
|
|
48
|
+
_accept_decorators = [attr(), bind()];
|
|
49
|
+
_required_decorators = [attr(), bind()];
|
|
50
50
|
_files_decorators = [bind()];
|
|
51
51
|
_filesVisible_decorators = [bind((i) => !!i.files?.length)];
|
|
52
52
|
_syncFormValues_decorators = [effect()];
|
|
53
|
-
_onInputChange_decorators = [listen(
|
|
54
|
-
_onDragEnter_decorators = [listen(
|
|
55
|
-
_onDragLeave_decorators = [listen(
|
|
56
|
-
_onDrop_decorators = [listen(
|
|
53
|
+
_onInputChange_decorators = [listen('change')];
|
|
54
|
+
_onDragEnter_decorators = [listen('dragenter')];
|
|
55
|
+
_onDragLeave_decorators = [listen('dragleave')];
|
|
56
|
+
_onDrop_decorators = [listen('drop')];
|
|
57
57
|
__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);
|
|
58
58
|
__esDecorate(this, null, _multiple_decorators, { kind: "accessor", name: "multiple", static: false, private: false, access: { has: obj => "multiple" in obj, get: obj => obj.multiple, set: (obj, value) => { obj.multiple = value; } }, metadata: _metadata }, _multiple_initializers, _multiple_extraInitializers);
|
|
59
59
|
__esDecorate(this, null, _accept_decorators, { kind: "accessor", name: "accept", static: false, private: false, access: { has: obj => "accept" in obj, get: obj => obj.accept, set: (obj, value) => { obj.accept = value; } }, metadata: _metadata }, _accept_initializers, _accept_extraInitializers);
|
|
@@ -70,13 +70,13 @@ let USAFileInputElement = (() => {
|
|
|
70
70
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
71
71
|
}
|
|
72
72
|
static formAssociated = true;
|
|
73
|
-
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers,
|
|
73
|
+
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers, ''));
|
|
74
74
|
get name() { return this.#name_accessor_storage; }
|
|
75
75
|
set name(value) { this.#name_accessor_storage = value; }
|
|
76
76
|
#multiple_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _multiple_initializers, true));
|
|
77
77
|
get multiple() { return this.#multiple_accessor_storage; }
|
|
78
78
|
set multiple(value) { this.#multiple_accessor_storage = value; }
|
|
79
|
-
#accept_accessor_storage = (__runInitializers(this, _multiple_extraInitializers), __runInitializers(this, _accept_initializers,
|
|
79
|
+
#accept_accessor_storage = (__runInitializers(this, _multiple_extraInitializers), __runInitializers(this, _accept_initializers, ''));
|
|
80
80
|
get accept() { return this.#accept_accessor_storage; }
|
|
81
81
|
set accept(value) { this.#accept_accessor_storage = value; }
|
|
82
82
|
#required_accessor_storage = (__runInitializers(this, _accept_extraInitializers), __runInitializers(this, _required_initializers, false));
|
|
@@ -89,15 +89,7 @@ let USAFileInputElement = (() => {
|
|
|
89
89
|
get filesVisible() { return this.#filesVisible_accessor_storage; }
|
|
90
90
|
set filesVisible(value) { this.#filesVisible_accessor_storage = value; }
|
|
91
91
|
#internals = (__runInitializers(this, _filesVisible_extraInitializers), this.attachInternals());
|
|
92
|
-
#input = query(
|
|
93
|
-
attributeChangedCallback() {
|
|
94
|
-
this.#input({
|
|
95
|
-
name: this.name,
|
|
96
|
-
multiple: this.multiple,
|
|
97
|
-
accept: this.accept,
|
|
98
|
-
required: this.required,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
92
|
+
#input = query('input');
|
|
101
93
|
connectedCallback() {
|
|
102
94
|
const input = this.#input();
|
|
103
95
|
if (input.validationMessage) {
|
|
@@ -105,7 +97,7 @@ let USAFileInputElement = (() => {
|
|
|
105
97
|
}
|
|
106
98
|
}
|
|
107
99
|
syncFormValues() {
|
|
108
|
-
const input = this.#input(
|
|
100
|
+
const input = this.#input();
|
|
109
101
|
const formData = new FormData();
|
|
110
102
|
if (this.files?.length) {
|
|
111
103
|
for (const file of this.files) {
|
|
@@ -123,21 +115,21 @@ let USAFileInputElement = (() => {
|
|
|
123
115
|
onInputChange() {
|
|
124
116
|
const input = this.#input();
|
|
125
117
|
this.files = input.files;
|
|
126
|
-
this.dispatchEvent(new Event(
|
|
118
|
+
this.dispatchEvent(new Event('change'));
|
|
127
119
|
}
|
|
128
120
|
onDragEnter() {
|
|
129
|
-
this.classList.add(
|
|
121
|
+
this.classList.add('dragenter');
|
|
130
122
|
}
|
|
131
123
|
onDragLeave() {
|
|
132
|
-
this.classList.remove(
|
|
124
|
+
this.classList.remove('dragenter');
|
|
133
125
|
}
|
|
134
126
|
onDrop(e) {
|
|
135
|
-
this.classList.remove(
|
|
127
|
+
this.classList.remove('dragenter');
|
|
136
128
|
if (e.dataTransfer?.items) {
|
|
137
129
|
e.preventDefault();
|
|
138
130
|
const data = new DataTransfer();
|
|
139
131
|
for (const item of e.dataTransfer.items) {
|
|
140
|
-
if (item.kind ===
|
|
132
|
+
if (item.kind === 'file') {
|
|
141
133
|
const file = item.getAsFile();
|
|
142
134
|
if (file) {
|
|
143
135
|
data.items.add(file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.element.js","sourceRoot":"","sources":["../../../src/lib/file-input/file-input.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"file-input.element.js","sourceRoot":"","sources":["../../../src/lib/file-input/file-input.element.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,G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E,CAAC;wBAE9B,IAAI,IAAI,EAAE,CAAC;4BACT,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBACvB,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YAC1B,CAAC;QACH,CAAC;;YAjGU,uDAAmB;;;;;SAAnB,mBAAmB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { USAIcon } from
|
|
1
|
+
import type { USAIcon } from './icon-types.js';
|
|
2
2
|
declare global {
|
|
3
3
|
interface HTMLElementTagNameMap {
|
|
4
|
-
|
|
4
|
+
'usa-icon': USAIconElement;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export declare class USAIconElement extends HTMLElement {
|
|
8
8
|
#private;
|
|
9
|
-
accessor icon: USAIcon;
|
|
9
|
+
accessor icon: USAIcon | '';
|
|
10
10
|
ariaHidden: string | null;
|
|
11
|
-
attributeChangedCallback(_: string, newVal: string, oldVal: string): void;
|
|
12
11
|
connectedCallback(): void;
|
|
12
|
+
onIconUpdate(): void;
|
|
13
13
|
}
|
|
@@ -1,62 +1,72 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { inject, injectable } from
|
|
3
|
-
import { attr, css, element } from
|
|
4
|
-
import { IconService } from
|
|
2
|
+
import { inject, injectable } from '@joist/di';
|
|
3
|
+
import { attr, css, element } from '@joist/element';
|
|
4
|
+
import { IconService } from '../services/icon.service.js';
|
|
5
|
+
import { effect, observe } from '@joist/observable';
|
|
5
6
|
let USAIconElement = (() => {
|
|
6
7
|
let _classDecorators = [element({
|
|
7
|
-
tagName:
|
|
8
|
+
tagName: 'usa-icon',
|
|
8
9
|
shadowDom: [
|
|
9
10
|
css `:host{display:inline-block;height:2rem;position:relative;width:2rem}svg{fill:currentColor;height:100%;width:100%}`,
|
|
10
11
|
],
|
|
11
12
|
}), injectable({
|
|
12
|
-
name:
|
|
13
|
+
name: 'usa-icon-ctx',
|
|
13
14
|
})];
|
|
14
15
|
let _classDescriptor;
|
|
15
16
|
let _classExtraInitializers = [];
|
|
16
17
|
let _classThis;
|
|
17
18
|
let _classSuper = HTMLElement;
|
|
19
|
+
let _instanceExtraInitializers = [];
|
|
18
20
|
let _icon_decorators;
|
|
19
21
|
let _icon_initializers = [];
|
|
20
22
|
let _icon_extraInitializers = [];
|
|
23
|
+
let _onIconUpdate_decorators;
|
|
21
24
|
var USAIconElement = class extends _classSuper {
|
|
22
25
|
static { _classThis = this; }
|
|
23
26
|
static {
|
|
24
27
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
25
|
-
_icon_decorators = [attr()];
|
|
28
|
+
_icon_decorators = [attr(), observe()];
|
|
29
|
+
_onIconUpdate_decorators = [effect()];
|
|
26
30
|
__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);
|
|
31
|
+
__esDecorate(this, null, _onIconUpdate_decorators, { kind: "method", name: "onIconUpdate", static: false, private: false, access: { has: obj => "onIconUpdate" in obj, get: obj => obj.onIconUpdate }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
27
32
|
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
28
33
|
USAIconElement = _classThis = _classDescriptor.value;
|
|
29
34
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
30
35
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
31
36
|
}
|
|
32
|
-
#icon_accessor_storage = __runInitializers(this, _icon_initializers,
|
|
37
|
+
#icon_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _icon_initializers, ''));
|
|
33
38
|
get icon() { return this.#icon_accessor_storage; }
|
|
34
39
|
set icon(value) { this.#icon_accessor_storage = value; }
|
|
35
|
-
ariaHidden = (__runInitializers(this, _icon_extraInitializers),
|
|
40
|
+
ariaHidden = (__runInitializers(this, _icon_extraInitializers), 'true');
|
|
36
41
|
#icon = inject(IconService);
|
|
37
|
-
#
|
|
38
|
-
attributeChangedCallback(_, newVal, oldVal) {
|
|
39
|
-
if (this.#injected) {
|
|
40
|
-
if (newVal !== oldVal) {
|
|
41
|
-
this.#updateIcon();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
42
|
+
#abortController = null;
|
|
45
43
|
connectedCallback() {
|
|
46
|
-
this.#
|
|
44
|
+
this.#updateIcon();
|
|
45
|
+
}
|
|
46
|
+
onIconUpdate() {
|
|
47
|
+
console.log('onIconUpdate', this.icon);
|
|
47
48
|
this.#updateIcon();
|
|
48
49
|
}
|
|
49
50
|
async #updateIcon() {
|
|
51
|
+
this.#abortController?.abort();
|
|
52
|
+
this.#abortController = new AbortController();
|
|
53
|
+
if (!this.icon) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
50
56
|
const icon = this.#icon();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
icon
|
|
58
|
+
.getIcon(this.icon, this.#abortController?.signal)
|
|
59
|
+
.then((currentIcon) => {
|
|
60
|
+
if (this.shadowRoot) {
|
|
61
|
+
if (this.shadowRoot.firstElementChild) {
|
|
62
|
+
this.shadowRoot.firstElementChild.replaceWith(currentIcon);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.shadowRoot.append(currentIcon);
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
68
|
+
})
|
|
69
|
+
.catch(() => { });
|
|
60
70
|
}
|
|
61
71
|
};
|
|
62
72
|
return USAIconElement = _classThis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.element.js","sourceRoot":"","sources":["../../../src/lib/icon/icon.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"icon.element.js","sourceRoot":"","sources":["../../../src/lib/icon/icon.element.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAY,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;IA8BvC,cAAc;4BAtB1B,OAAO,CAAC;YACP,OAAO,EAAE,UAAU;YACnB,SAAS,EAAE;gBACT,GAAG,CAAA;;;;;;;;;;;;;KAaF;aACF;SACF,CAAC,EACD,UAAU,CAAC;YACV,IAAI,EAAE,cAAc;SACrB,CAAC;;;;sBACkC,WAAW;;;;;;8BAAnB,SAAQ,WAAW;;;;gCAC5C,IAAI,EAAE,EACN,OAAO,EAAE;wCAYT,MAAM,EAAE;YAXT,iKAAS,IAAI,6BAAJ,IAAI,mFAAoB;YAYjC,uLAAA,YAAY,6DAIX;YAnBH,6KA4CC;;;YA5CY,uDAAc;;QAGzB,0BAHW,mDAAc,8CAGK,EAAE,GAAC;QAAjC,IAAS,IAAI,0CAAoB;QAAjC,IAAS,IAAI,gDAAoB;QAEjC,UAAU,sDAAkB,MAAM,EAAC;QAEnC,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5B,gBAAgB,GAA2B,IAAI,CAAC;QAEhD,iBAAiB;YACf,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;QAGD,YAAY;YACV,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAEvC,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;QAED,KAAK,CAAC,WAAW;YACf,IAAI,CAAC,gBAAgB,EAAE,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,EAAE,CAAC;YAE9C,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACf,OAAO;YACT,CAAC;YAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAE1B,IAAI;iBACD,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC;iBACjD,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;gBACpB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,IAAI,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC;wBACtC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;oBAC7D,CAAC;yBAAM,CAAC;wBACN,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;oBACtC,CAAC;gBACH,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACrB,CAAC;;;;SA3CU,cAAc"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MaskableElement } from
|
|
1
|
+
import type { MaskableElement } from '../input-mask/maskable.element.js';
|
|
2
2
|
declare global {
|
|
3
3
|
interface HTMLElementTagNameMap {
|
|
4
|
-
|
|
4
|
+
'usa-input': USATextInputElement;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export declare class USATextInputElement extends HTMLElement implements MaskableElement {
|
|
@@ -16,14 +16,14 @@ export declare class USATextInputElement extends HTMLElement implements Maskable
|
|
|
16
16
|
accessor maxLength: number;
|
|
17
17
|
accessor required: boolean;
|
|
18
18
|
accessor disabled: boolean;
|
|
19
|
-
accessor type:
|
|
20
|
-
accessor detail:
|
|
19
|
+
accessor type: 'text' | 'password' | 'number';
|
|
20
|
+
accessor detail: 'pfx' | 'sfx' | '';
|
|
21
21
|
accessor value: string;
|
|
22
22
|
accessor selectionStart: number | null;
|
|
23
23
|
accessor selectionEnd: number | null;
|
|
24
24
|
get validationMessage(): string;
|
|
25
25
|
onReady(): void;
|
|
26
|
-
attributeChangedCallback(
|
|
26
|
+
attributeChangedCallback(): void;
|
|
27
27
|
connectedCallback(): void;
|
|
28
28
|
focus(options?: FocusOptions): void;
|
|
29
29
|
onChange(): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
-
import { attr, css, element, html, listen, query, ready } from
|
|
3
|
-
import { effect, observe } from
|
|
2
|
+
import { attr, css, element, html, listen, query, ready } from '@joist/element';
|
|
3
|
+
import { effect, observe } from '@joist/observable';
|
|
4
4
|
let USATextInputElement = (() => {
|
|
5
5
|
let _classDecorators = [element({
|
|
6
|
-
tagName:
|
|
6
|
+
tagName: 'usa-input',
|
|
7
7
|
shadowDom: [
|
|
8
8
|
css `*{box-sizing:border-box}:host{font-size:1.06rem;line-height:1.3;display:block;font-weight:400;max-width:30rem;margin-bottom:1.5rem;position:relative}input{background-color:#fff;border-width:1px;border-color:#5c5c5c;border-style:solid;border-radius:0;color:#1b1b1b;display:block;height:2.5rem;line-height:1.3;font-size:1.06rem;margin-top:.5rem;padding:.5rem;width:100%}input:not(:disabled):focus{outline:.25rem solid #2491ff;outline-offset:0}input:disabled{background-color:#fff;border-color:#757575;color:#757575}slot[name=detail]::slotted(*){color:#757575}slot[name=detail]::slotted(usa-icon){width:1.5rem;height:1.5rem}slot[name=detail]{display:block;position:absolute;bottom:.21rem;left:.5rem}:host([detail=pfx]) input{padding-left:2.5rem}:host([detail=sfx]) input{padding-right:2.5rem}:host([detail=sfx]) slot[name=detail]{right:.5rem;left:auto}`,
|
|
9
9
|
html `<label><slot name="detail"></slot><slot></slot><input tabindex="0" part="input"></label>`,
|
|
@@ -74,9 +74,7 @@ let USATextInputElement = (() => {
|
|
|
74
74
|
_required_decorators = [attr()];
|
|
75
75
|
_disabled_decorators = [attr()];
|
|
76
76
|
_type_decorators = [attr()];
|
|
77
|
-
_detail_decorators = [attr(
|
|
78
|
-
observed: false,
|
|
79
|
-
})];
|
|
77
|
+
_detail_decorators = [attr()];
|
|
80
78
|
_value_decorators = [attr({
|
|
81
79
|
reflect: false,
|
|
82
80
|
}), observe()];
|
|
@@ -84,8 +82,8 @@ let USATextInputElement = (() => {
|
|
|
84
82
|
_selectionEnd_decorators = [observe()];
|
|
85
83
|
_onReady_decorators = [ready()];
|
|
86
84
|
_onChange_decorators = [effect()];
|
|
87
|
-
_onKeyDown_decorators = [listen(
|
|
88
|
-
_onInputChange_decorators = [listen(
|
|
85
|
+
_onKeyDown_decorators = [listen('keydown')];
|
|
86
|
+
_onInputChange_decorators = [listen('input')];
|
|
89
87
|
__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);
|
|
90
88
|
__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);
|
|
91
89
|
__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);
|
|
@@ -109,19 +107,19 @@ let USATextInputElement = (() => {
|
|
|
109
107
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
110
108
|
}
|
|
111
109
|
static formAssociated = true;
|
|
112
|
-
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers,
|
|
110
|
+
#name_accessor_storage = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _name_initializers, ''));
|
|
113
111
|
get name() { return this.#name_accessor_storage; }
|
|
114
112
|
set name(value) { this.#name_accessor_storage = value; }
|
|
115
|
-
#autocomplete_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _autocomplete_initializers,
|
|
113
|
+
#autocomplete_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _autocomplete_initializers, 'on'));
|
|
116
114
|
get autocomplete() { return this.#autocomplete_accessor_storage; }
|
|
117
115
|
set autocomplete(value) { this.#autocomplete_accessor_storage = value; }
|
|
118
|
-
#placeholder_accessor_storage = (__runInitializers(this, _autocomplete_extraInitializers), __runInitializers(this, _placeholder_initializers,
|
|
116
|
+
#placeholder_accessor_storage = (__runInitializers(this, _autocomplete_extraInitializers), __runInitializers(this, _placeholder_initializers, ''));
|
|
119
117
|
get placeholder() { return this.#placeholder_accessor_storage; }
|
|
120
118
|
set placeholder(value) { this.#placeholder_accessor_storage = value; }
|
|
121
|
-
#min_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _min_initializers,
|
|
119
|
+
#min_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _min_initializers, ''));
|
|
122
120
|
get min() { return this.#min_accessor_storage; }
|
|
123
121
|
set min(value) { this.#min_accessor_storage = value; }
|
|
124
|
-
#max_accessor_storage = (__runInitializers(this, _min_extraInitializers), __runInitializers(this, _max_initializers,
|
|
122
|
+
#max_accessor_storage = (__runInitializers(this, _min_extraInitializers), __runInitializers(this, _max_initializers, ''));
|
|
125
123
|
get max() { return this.#max_accessor_storage; }
|
|
126
124
|
set max(value) { this.#max_accessor_storage = value; }
|
|
127
125
|
#minLength_accessor_storage = (__runInitializers(this, _max_extraInitializers), __runInitializers(this, _minLength_initializers, -1));
|
|
@@ -136,13 +134,13 @@ let USATextInputElement = (() => {
|
|
|
136
134
|
#disabled_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _disabled_initializers, false));
|
|
137
135
|
get disabled() { return this.#disabled_accessor_storage; }
|
|
138
136
|
set disabled(value) { this.#disabled_accessor_storage = value; }
|
|
139
|
-
#type_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _type_initializers,
|
|
137
|
+
#type_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _type_initializers, 'text'));
|
|
140
138
|
get type() { return this.#type_accessor_storage; }
|
|
141
139
|
set type(value) { this.#type_accessor_storage = value; }
|
|
142
|
-
#detail_accessor_storage = (__runInitializers(this, _type_extraInitializers), __runInitializers(this, _detail_initializers,
|
|
140
|
+
#detail_accessor_storage = (__runInitializers(this, _type_extraInitializers), __runInitializers(this, _detail_initializers, ''));
|
|
143
141
|
get detail() { return this.#detail_accessor_storage; }
|
|
144
142
|
set detail(value) { this.#detail_accessor_storage = value; }
|
|
145
|
-
#value_accessor_storage = (__runInitializers(this, _detail_extraInitializers), __runInitializers(this, _value_initializers,
|
|
143
|
+
#value_accessor_storage = (__runInitializers(this, _detail_extraInitializers), __runInitializers(this, _value_initializers, ''));
|
|
146
144
|
get value() { return this.#value_accessor_storage; }
|
|
147
145
|
set value(value) { this.#value_accessor_storage = value; }
|
|
148
146
|
#selectionStart_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _selectionStart_initializers, null));
|
|
@@ -155,11 +153,11 @@ let USATextInputElement = (() => {
|
|
|
155
153
|
return this.#input().validationMessage;
|
|
156
154
|
}
|
|
157
155
|
#internals = (__runInitializers(this, _selectionEnd_extraInitializers), this.attachInternals());
|
|
158
|
-
#input = query(
|
|
156
|
+
#input = query('input');
|
|
159
157
|
onReady() {
|
|
160
158
|
this.#input({ autofocus: this.autofocus });
|
|
161
159
|
}
|
|
162
|
-
attributeChangedCallback(
|
|
160
|
+
attributeChangedCallback() {
|
|
163
161
|
this.#input({
|
|
164
162
|
autocomplete: this.autocomplete,
|
|
165
163
|
placeholder: this.placeholder,
|
|
@@ -188,7 +186,7 @@ let USATextInputElement = (() => {
|
|
|
188
186
|
const form = this.#internals.form;
|
|
189
187
|
if (form) {
|
|
190
188
|
const hasModifier = e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
|
|
191
|
-
if (e.key.toUpperCase() ===
|
|
189
|
+
if (e.key.toUpperCase() === 'ENTER' && !hasModifier) {
|
|
192
190
|
// this makes sure that the user has a chance to cancel the event before submitting
|
|
193
191
|
setTimeout(() => {
|
|
194
192
|
if (!e.defaultPrevented && !e.isComposing) {
|
|
@@ -207,14 +205,14 @@ let USATextInputElement = (() => {
|
|
|
207
205
|
#syncFormState() {
|
|
208
206
|
const input = this.#input();
|
|
209
207
|
this.#internals.setValidity({});
|
|
210
|
-
this.#internals.setFormValue(
|
|
208
|
+
this.#internals.setFormValue(this.value);
|
|
211
209
|
if (input.validationMessage) {
|
|
212
210
|
this.#internals.setValidity({ customError: true }, input.validationMessage, input);
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
#submit(form) {
|
|
216
|
-
const btn = document.createElement(
|
|
217
|
-
btn.type =
|
|
214
|
+
const btn = document.createElement('button');
|
|
215
|
+
btn.type = 'submit';
|
|
218
216
|
form.append(btn);
|
|
219
217
|
btn.click();
|
|
220
218
|
btn.remove();
|
|
@@ -1 +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,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;IA+FvC,mB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AAC,MAAM,EAAE,CAAC;YAE5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;YAC3C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QACzC,CAAC;QAED,cAAc;YACZ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAE5B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAChC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAEzC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;gBAC5B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAqB;YAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAC7C,GAAG,CAAC,IAAI,GAAG,QAAQ,CAAC;YACpB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAEjB,GAAG,CAAC,KAAK,EAAE,CAAC;YACZ,GAAG,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;;YAzIU,uDAAmB;;;;;SAAnB,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './input.element.js';
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { assert, fixture, html } from
|
|
3
|
-
import { userEvent } from
|
|
4
|
-
describe(
|
|
5
|
-
it(
|
|
1
|
+
import './input.element.js';
|
|
2
|
+
import { assert, fixture, html } from '@open-wc/testing';
|
|
3
|
+
import { userEvent } from '@testing-library/user-event';
|
|
4
|
+
describe('usa-input', () => {
|
|
5
|
+
it('should be accessible', async () => {
|
|
6
6
|
const form = await fixture(html `<usa-input name="fname" value="Foo">Hello World</usa-input>`);
|
|
7
7
|
return assert.isAccessible(form);
|
|
8
8
|
});
|
|
9
|
-
it(
|
|
9
|
+
it('should submit form with default values', async () => {
|
|
10
10
|
const form = await fixture(html `<form><usa-input name="fname" value="Foo">Hello World</usa-input><button>Submit</button></form>`);
|
|
11
11
|
const value = new FormData(form);
|
|
12
|
-
assert.equal(value.get(
|
|
12
|
+
assert.equal(value.get('fname'), 'Foo');
|
|
13
13
|
});
|
|
14
|
-
it(
|
|
14
|
+
it('should update form value as input value changed', async () => {
|
|
15
15
|
const form = await fixture(html `<form><usa-input name="fname">Hello World</usa-input><button>Submit</button></form>`);
|
|
16
|
-
const input = form.querySelector(
|
|
17
|
-
const nativeInput = input?.shadowRoot?.querySelector(
|
|
16
|
+
const input = form.querySelector('usa-input');
|
|
17
|
+
const nativeInput = input?.shadowRoot?.querySelector('input');
|
|
18
18
|
if (nativeInput) {
|
|
19
|
-
await userEvent.type(nativeInput,
|
|
19
|
+
await userEvent.type(nativeInput, 'Bar');
|
|
20
20
|
}
|
|
21
21
|
const value = new FormData(form);
|
|
22
|
-
assert.equal(value.get(
|
|
22
|
+
assert.equal(value.get('fname'), 'Bar');
|
|
23
23
|
});
|
|
24
|
-
it(
|
|
24
|
+
it('should not submit when not valid', async () => {
|
|
25
25
|
const form = await fixture(html `<form><usa-input name="fname" required>Hello World</usa-input><button>Submit</button></form>`);
|
|
26
26
|
assert.equal(form.checkValidity(), false);
|
|
27
27
|
});
|
|
@@ -1 +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,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,QAAQ,CAAC,W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