@exmg/exm-form-drawer 1.0.8 → 1.0.9
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exmg/exm-form-drawer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@exmg/exm-button": "^1.0.3",
|
|
34
|
-
"@exmg/exm-form": "^1.0.
|
|
34
|
+
"@exmg/exm-form": "^1.0.6",
|
|
35
35
|
"@material/typography": "^14.0.0",
|
|
36
36
|
"@polymer/neon-animation": "^3.0.1",
|
|
37
37
|
"@polymer/paper-dialog": "^3.0.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "3a7e80814357f7b89d46a44cc821834a9131f25b"
|
|
51
51
|
}
|
|
@@ -2,7 +2,8 @@ import './exm-drawer.js';
|
|
|
2
2
|
import '@exmg/exm-button/exm-filled-button.js';
|
|
3
3
|
import '@material/web/button/text-button.js';
|
|
4
4
|
import { ExmgElement } from '@exmg/lit-base';
|
|
5
|
-
|
|
5
|
+
declare const ExmFormDrawerBase_base: import("@exmg/exm-th").Constructor<import("@exmg/exm-th").FormValidateMixinInterface> & typeof ExmgElement;
|
|
6
|
+
export declare class ExmFormDrawerBase extends ExmFormDrawerBase_base {
|
|
6
7
|
/**
|
|
7
8
|
* Opened state of the form-drawer
|
|
8
9
|
* @type {Boolean}
|
|
@@ -42,18 +43,12 @@ export declare class ExmFormDrawerBase extends ExmgElement {
|
|
|
42
43
|
* Internall used to show button spinner.
|
|
43
44
|
*/
|
|
44
45
|
submitting: boolean;
|
|
45
|
-
private formValid;
|
|
46
|
-
boundHandleBlur?: (e: Event) => void;
|
|
47
46
|
/**
|
|
48
47
|
* Scroll action of the drawer
|
|
49
48
|
* @type {'lock' | 'refit' | 'cancel' | undefined}
|
|
50
49
|
*/
|
|
51
50
|
scrollAction?: 'lock' | 'refit' | 'cancel' | undefined;
|
|
52
51
|
errorMessage?: string | null;
|
|
53
|
-
protected getForm(): HTMLFormElement | null;
|
|
54
|
-
protected _handleBlur(e: Event): void;
|
|
55
|
-
protected firstUpdated(): void;
|
|
56
|
-
disconnectedCallback(): void;
|
|
57
52
|
/**
|
|
58
53
|
* Opens and shows the drawer.
|
|
59
54
|
*/
|
|
@@ -66,7 +61,6 @@ export declare class ExmFormDrawerBase extends ExmgElement {
|
|
|
66
61
|
* Opens and shows the dialog if it is closed; otherwise closes it.
|
|
67
62
|
*/
|
|
68
63
|
toggleShow(): void;
|
|
69
|
-
protected _checkFormValidity(): Promise<void>;
|
|
70
64
|
reset(): void;
|
|
71
65
|
/**
|
|
72
66
|
* Action method that needs to be implemented
|
|
@@ -84,3 +78,4 @@ export declare class ExmFormDrawerBase extends ExmgElement {
|
|
|
84
78
|
protected handleDrawerOpenedChanged(e: CustomEvent): void;
|
|
85
79
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
86
80
|
}
|
|
81
|
+
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { html, nothing } from 'lit';
|
|
3
|
-
import { property
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import './exm-drawer.js';
|
|
6
6
|
import '@exmg/exm-button/exm-filled-button.js';
|
|
7
7
|
import '@material/web/button/text-button.js';
|
|
8
8
|
import { ExmgElement } from '@exmg/lit-base';
|
|
9
9
|
import { serializeForm } from '@exmg/exm-form';
|
|
10
|
-
|
|
10
|
+
import { ExmFormValidateMixin } from '@exmg/exm-form';
|
|
11
|
+
export class ExmFormDrawerBase extends ExmFormValidateMixin(ExmgElement) {
|
|
11
12
|
constructor() {
|
|
12
13
|
super(...arguments);
|
|
13
14
|
/**
|
|
@@ -49,25 +50,6 @@ export class ExmFormDrawerBase extends ExmgElement {
|
|
|
49
50
|
* Internall used to show button spinner.
|
|
50
51
|
*/
|
|
51
52
|
this.submitting = false;
|
|
52
|
-
this.formValid = false;
|
|
53
|
-
}
|
|
54
|
-
getForm() {
|
|
55
|
-
return this.shadowRoot.querySelector('form');
|
|
56
|
-
}
|
|
57
|
-
_handleBlur(e) {
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
typeof e.target.reportValidity === 'function' && e.target.reportValidity();
|
|
60
|
-
this._checkFormValidity();
|
|
61
|
-
}
|
|
62
|
-
firstUpdated() {
|
|
63
|
-
const form = this.getForm();
|
|
64
|
-
this.boundHandleBlur = this._handleBlur.bind(this);
|
|
65
|
-
form.addEventListener('blur', this.boundHandleBlur, true);
|
|
66
|
-
}
|
|
67
|
-
disconnectedCallback() {
|
|
68
|
-
const form = this.getForm();
|
|
69
|
-
this.boundHandleBlur && form.addEventListener('blur', this.boundHandleBlur, true);
|
|
70
|
-
super.disconnectedCallback();
|
|
71
53
|
}
|
|
72
54
|
/**
|
|
73
55
|
* Opens and shows the drawer.
|
|
@@ -92,23 +74,6 @@ export class ExmFormDrawerBase extends ExmgElement {
|
|
|
92
74
|
this.show();
|
|
93
75
|
}
|
|
94
76
|
}
|
|
95
|
-
async _checkFormValidity() {
|
|
96
|
-
const form = this.getForm();
|
|
97
|
-
const formElements = form === null || form === void 0 ? void 0 : form.elements;
|
|
98
|
-
let allValid = true;
|
|
99
|
-
for (const el of formElements || []) {
|
|
100
|
-
let isValid = true;
|
|
101
|
-
// @ts-ignore
|
|
102
|
-
if (typeof el.reportValidity === 'function') {
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
isValid = el.checkValidity();
|
|
105
|
-
}
|
|
106
|
-
if (!isValid) {
|
|
107
|
-
allValid = false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
this.formValid = allValid;
|
|
111
|
-
}
|
|
112
77
|
reset() {
|
|
113
78
|
this.errorMessage = null;
|
|
114
79
|
const form = this.getForm();
|
|
@@ -118,7 +83,7 @@ export class ExmFormDrawerBase extends ExmgElement {
|
|
|
118
83
|
const form = this.getForm();
|
|
119
84
|
this.errorMessage = null;
|
|
120
85
|
// Check form validity
|
|
121
|
-
this.
|
|
86
|
+
this.checkFormValidity();
|
|
122
87
|
// Return when there are invalid fields
|
|
123
88
|
if (!this.formValid) {
|
|
124
89
|
return;
|
|
@@ -165,7 +130,7 @@ export class ExmFormDrawerBase extends ExmgElement {
|
|
|
165
130
|
handleDrawerOpenedChanged(e) {
|
|
166
131
|
this.opened = e.detail.value;
|
|
167
132
|
if (this.opened) {
|
|
168
|
-
this.
|
|
133
|
+
this.checkFormValidity();
|
|
169
134
|
}
|
|
170
135
|
}
|
|
171
136
|
render() {
|
|
@@ -224,9 +189,6 @@ __decorate([
|
|
|
224
189
|
__decorate([
|
|
225
190
|
property({ type: Boolean })
|
|
226
191
|
], ExmFormDrawerBase.prototype, "submitting", void 0);
|
|
227
|
-
__decorate([
|
|
228
|
-
state()
|
|
229
|
-
], ExmFormDrawerBase.prototype, "formValid", void 0);
|
|
230
192
|
__decorate([
|
|
231
193
|
property({ type: String, attribute: 'scroll-action' })
|
|
232
194
|
], ExmFormDrawerBase.prototype, "scrollAction", void 0);
|