@exmg/exm-form-drawer 1.0.7 → 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.7",
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.4",
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": "8504f0aac4737b66d3eb579953c45b56a110cb91"
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
- export declare class ExmFormDrawerBase extends ExmgElement {
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, state } from 'lit/decorators.js';
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
- export class ExmFormDrawerBase extends ExmgElement {
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,19 +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
- // @ts-ignore
101
- const isValid = typeof el.reportValidity === 'function' && el.checkValidity();
102
- if (!isValid) {
103
- allValid = false;
104
- }
105
- }
106
- this.formValid = allValid;
107
- }
108
77
  reset() {
109
78
  this.errorMessage = null;
110
79
  const form = this.getForm();
@@ -114,7 +83,7 @@ export class ExmFormDrawerBase extends ExmgElement {
114
83
  const form = this.getForm();
115
84
  this.errorMessage = null;
116
85
  // Check form validity
117
- this._checkFormValidity();
86
+ this.checkFormValidity();
118
87
  // Return when there are invalid fields
119
88
  if (!this.formValid) {
120
89
  return;
@@ -161,7 +130,7 @@ export class ExmFormDrawerBase extends ExmgElement {
161
130
  handleDrawerOpenedChanged(e) {
162
131
  this.opened = e.detail.value;
163
132
  if (this.opened) {
164
- this._checkFormValidity();
133
+ this.checkFormValidity();
165
134
  }
166
135
  }
167
136
  render() {
@@ -220,9 +189,6 @@ __decorate([
220
189
  __decorate([
221
190
  property({ type: Boolean })
222
191
  ], ExmFormDrawerBase.prototype, "submitting", void 0);
223
- __decorate([
224
- state()
225
- ], ExmFormDrawerBase.prototype, "formValid", void 0);
226
192
  __decorate([
227
193
  property({ type: String, attribute: 'scroll-action' })
228
194
  ], ExmFormDrawerBase.prototype, "scrollAction", void 0);