@exmg/exm-form-drawer 1.0.10 → 1.0.12

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `<exm-form-drawer>` [![Published on npm](https://img.shields.io/npm/v/@exmg/exm-form-drawer.svg)](https://www.npmjs.com/package/@exmg/exm-form-drawer)
2
2
 
3
- This package provides dialog drawer functionality.
3
+ This package provides dialog drawer functionality
4
4
 
5
5
  Components included:
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exmg/exm-form-drawer",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
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.6",
34
+ "@exmg/exm-form": "^1.0.8",
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": "9d2407c15858e2a7331ff7b2a16e344d9bb6af9e"
50
+ "gitHead": "e88a21046d092a883458fbecd09d2ebe853fe134"
51
51
  }
@@ -7,7 +7,7 @@ paper-dialog {
7
7
  bottom: 0;
8
8
  width: 100%;
9
9
  box-shadow: none;
10
- overflow: scroll;
10
+ overflow: auto;
11
11
 
12
12
  color: var(--exm-drawer-color, var(--md-sys-color-on-surface, black));
13
13
  // background-color: var(--exm-drawer-bg-color, var(--mdc-theme-surface, $exm-drawer-bg-color));
package/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export { ExmDrawer } from './src/exm-drawer.js';
2
- export { ExmFormDrawer } from './src/exm-form-drawer.js';
3
- export { ExmFormDrawerBase } from './src/exm-form-drawer-base.js';
4
- export { style as drawerStyles } from './src/styles/exm-drawer-styles-css.js';
5
- export { style as formDrawerStyles } from './src/styles/exm-form-drawer-styles-css.js';
package/index.js DELETED
@@ -1,6 +0,0 @@
1
- export { ExmDrawer } from './src/exm-drawer.js';
2
- export { ExmFormDrawer } from './src/exm-form-drawer.js';
3
- export { ExmFormDrawerBase } from './src/exm-form-drawer-base.js';
4
- export { style as drawerStyles } from './src/styles/exm-drawer-styles-css.js';
5
- export { style as formDrawerStyles } from './src/styles/exm-form-drawer-styles-css.js';
6
- //# sourceMappingURL=index.js.map
@@ -1,30 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import '@polymer/neon-animation/animations/slide-from-right-animation.js';
3
- import '@polymer/neon-animation/animations/slide-right-animation.js';
4
- import '@polymer/paper-dialog/paper-dialog.js';
5
- export declare class ExmDrawer extends LitElement {
6
- /**
7
- * The opened state of the drawer
8
- * @type {Boolean}
9
- */
10
- opened: boolean;
11
- /**
12
- * Prevent cancel on outside click or not
13
- * @type {Boolean}
14
- */
15
- noCancelOnOutsideClick: boolean;
16
- /**
17
- * Scroll action of the drawer
18
- * @type {'lock' | 'refit' | 'cancel' | undefined}
19
- */
20
- scrollAction?: 'lock' | 'refit' | 'cancel' | undefined;
21
- handleOpenedChanged(e: CustomEvent): void;
22
- openDialog(): void;
23
- static styles: import("lit").CSSResult[];
24
- render(): import("lit-html").TemplateResult<1>;
25
- }
26
- declare global {
27
- interface HTMLElementTagNameMap {
28
- 'exm-drawer': ExmDrawer;
29
- }
30
- }
package/src/exm-drawer.js DELETED
@@ -1,71 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { LitElement, html } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
4
- import { ifDefined } from 'lit/directives/if-defined.js';
5
- import '@polymer/neon-animation/animations/slide-from-right-animation.js';
6
- import '@polymer/neon-animation/animations/slide-right-animation.js';
7
- import '@polymer/paper-dialog/paper-dialog.js';
8
- import { style } from './styles/exm-drawer-styles-css.js';
9
- let ExmDrawer = class ExmDrawer extends LitElement {
10
- constructor() {
11
- super(...arguments);
12
- /**
13
- * The opened state of the drawer
14
- * @type {Boolean}
15
- */
16
- this.opened = false;
17
- /**
18
- * Prevent cancel on outside click or not
19
- * @type {Boolean}
20
- */
21
- this.noCancelOnOutsideClick = false;
22
- }
23
- handleOpenedChanged(e) {
24
- this.opened = e.detail.value;
25
- this.dispatchEvent(new CustomEvent('exm-drawer-opened-changed', {
26
- bubbles: true,
27
- composed: true,
28
- detail: {
29
- value: e.detail.value,
30
- },
31
- }));
32
- }
33
- openDialog() {
34
- this.opened = true;
35
- }
36
- render() {
37
- return html `
38
- <style>
39
- paper-dialog {
40
- max-width: var(--exm-drawer-max-width, ${this.style.maxWidth || '547px'});
41
- }
42
- </style>
43
- <paper-dialog
44
- scroll-action=${ifDefined(this.scrollAction)}
45
- ?opened="${this.opened}"
46
- ?no-cancel-on-outside-click="${this.noCancelOnOutsideClick}"
47
- @opened-changed="${this.handleOpenedChanged}"
48
- entry-animation="slide-from-right-animation"
49
- exit-animation="slide-right-animation"
50
- with-backdrop
51
- >
52
- <slot></slot>
53
- </paper-dialog>
54
- `;
55
- }
56
- };
57
- ExmDrawer.styles = [style];
58
- __decorate([
59
- property({ type: Boolean })
60
- ], ExmDrawer.prototype, "opened", void 0);
61
- __decorate([
62
- property({ type: Boolean, attribute: 'no-cancel-on-outside-click' })
63
- ], ExmDrawer.prototype, "noCancelOnOutsideClick", void 0);
64
- __decorate([
65
- property({ type: String, attribute: 'scroll-action' })
66
- ], ExmDrawer.prototype, "scrollAction", void 0);
67
- ExmDrawer = __decorate([
68
- customElement('exm-drawer')
69
- ], ExmDrawer);
70
- export { ExmDrawer };
71
- //# sourceMappingURL=exm-drawer.js.map
@@ -1,81 +0,0 @@
1
- import './exm-drawer.js';
2
- import '@exmg/exm-button/exm-filled-button.js';
3
- import '@material/web/button/text-button.js';
4
- import { ExmgElement } from '@exmg/lit-base';
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 {
7
- /**
8
- * Opened state of the form-drawer
9
- * @type {Boolean}
10
- */
11
- opened: boolean;
12
- /**
13
- * The title of the 'submit' button
14
- * @type {String}
15
- */
16
- submitBtnTitle: string;
17
- /**
18
- * Whether or not to hide the submit button
19
- * @type {Boolean}
20
- */
21
- submitBtnHidden: boolean;
22
- /**
23
- * Title of the cancel button
24
- * @type {String}
25
- */
26
- cancelBtnTitle: string;
27
- /**
28
- * Whether or not to keep the form drawer opened on submit success
29
- * @type {Boolean}
30
- */
31
- keepOpenedOnSubmitSuccess: boolean;
32
- /**
33
- * No cancel on outside click
34
- * @type {Boolean}
35
- */
36
- noCancelOnOutsideClick: boolean;
37
- /**
38
- * Disable sticky header in drawer
39
- * @type {Boolean}
40
- */
41
- disableStickyHeader: boolean;
42
- /**
43
- * Internall used to show button spinner.
44
- */
45
- submitting: boolean;
46
- /**
47
- * Scroll action of the drawer
48
- * @type {'lock' | 'refit' | 'cancel' | undefined}
49
- */
50
- scrollAction?: 'lock' | 'refit' | 'cancel' | undefined;
51
- errorMessage?: string | null;
52
- /**
53
- * Opens and shows the drawer.
54
- */
55
- show(): void;
56
- /**
57
- * Closes the drawer.
58
- */
59
- close(): void;
60
- /**
61
- * Opens and shows the dialog if it is closed; otherwise closes it.
62
- */
63
- toggleShow(): void;
64
- reset(): void;
65
- /**
66
- * Action method that needs to be implemented
67
- * @param {CustomEvent} e
68
- */
69
- doAction?(formData: unknown): Promise<void> | void;
70
- protected handleSubmit(): Promise<void>;
71
- private handleCancelBtnClick;
72
- showError(message: string): void;
73
- /**
74
- * Method should be overriden to render form content
75
- */
76
- protected renderFormContent(): import("lit-html").TemplateResult<1>;
77
- protected renderError(): import("lit-html").TemplateResult<1>;
78
- protected handleDrawerOpenedChanged(e: CustomEvent): void;
79
- protected render(): import("lit-html").TemplateResult<1>;
80
- }
81
- export {};
@@ -1,198 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { html, nothing } from 'lit';
3
- import { property } from 'lit/decorators.js';
4
- import { ifDefined } from 'lit/directives/if-defined.js';
5
- import './exm-drawer.js';
6
- import '@exmg/exm-button/exm-filled-button.js';
7
- import '@material/web/button/text-button.js';
8
- import { ExmgElement } from '@exmg/lit-base';
9
- import { serializeForm } from '@exmg/exm-form';
10
- import { ExmFormValidateMixin } from '@exmg/exm-form';
11
- export class ExmFormDrawerBase extends ExmFormValidateMixin(ExmgElement) {
12
- constructor() {
13
- super(...arguments);
14
- /**
15
- * Opened state of the form-drawer
16
- * @type {Boolean}
17
- */
18
- this.opened = false;
19
- /**
20
- * The title of the 'submit' button
21
- * @type {String}
22
- */
23
- this.submitBtnTitle = 'Submit';
24
- /**
25
- * Whether or not to hide the submit button
26
- * @type {Boolean}
27
- */
28
- this.submitBtnHidden = false;
29
- /**
30
- * Title of the cancel button
31
- * @type {String}
32
- */
33
- this.cancelBtnTitle = 'Cancel';
34
- /**
35
- * Whether or not to keep the form drawer opened on submit success
36
- * @type {Boolean}
37
- */
38
- this.keepOpenedOnSubmitSuccess = false;
39
- /**
40
- * No cancel on outside click
41
- * @type {Boolean}
42
- */
43
- this.noCancelOnOutsideClick = false;
44
- /**
45
- * Disable sticky header in drawer
46
- * @type {Boolean}
47
- */
48
- this.disableStickyHeader = false;
49
- /**
50
- * Internall used to show button spinner.
51
- */
52
- this.submitting = false;
53
- }
54
- /**
55
- * Opens and shows the drawer.
56
- */
57
- show() {
58
- this.opened = true;
59
- }
60
- /**
61
- * Closes the drawer.
62
- */
63
- close() {
64
- this.opened = false;
65
- }
66
- /**
67
- * Opens and shows the dialog if it is closed; otherwise closes it.
68
- */
69
- toggleShow() {
70
- if (this.opened) {
71
- this.close();
72
- }
73
- else {
74
- this.show();
75
- }
76
- }
77
- reset() {
78
- this.errorMessage = null;
79
- const form = this.getForm();
80
- form.reset();
81
- }
82
- async handleSubmit() {
83
- const form = this.getForm();
84
- this.errorMessage = null;
85
- // Check form validity
86
- this.checkFormValidity();
87
- // Return when there are invalid fields
88
- if (!this.formValid) {
89
- return;
90
- }
91
- // Serialize form data
92
- const data = serializeForm(form);
93
- if (this.doAction) {
94
- try {
95
- this.submitting = true;
96
- await this.doAction(data);
97
- this.fire('action-success');
98
- }
99
- catch (error) {
100
- this.errorMessage = error instanceof Error ? error.message : 'Unkbnown error';
101
- this.fire('action-error', { message: this.errorMessage }, true);
102
- }
103
- finally {
104
- this.submitting = false;
105
- if (this.errorMessage === null && !this.keepOpenedOnSubmitSuccess) {
106
- this.opened = false;
107
- }
108
- }
109
- }
110
- else {
111
- this.fire('action-submit', data, true);
112
- }
113
- }
114
- handleCancelBtnClick() {
115
- this.reset();
116
- this.close();
117
- }
118
- showError(message) {
119
- this.errorMessage = message;
120
- }
121
- /**
122
- * Method should be overriden to render form content
123
- */
124
- renderFormContent() {
125
- return html `<slot></slot>`;
126
- }
127
- renderError() {
128
- return html `<div class="error"><div>${this.errorMessage}</div></div>`;
129
- }
130
- handleDrawerOpenedChanged(e) {
131
- this.opened = e.detail.value;
132
- if (this.opened) {
133
- this.checkFormValidity();
134
- }
135
- }
136
- render() {
137
- return html `
138
- <exm-drawer
139
- ?opened="${this.opened}"
140
- ?no-cancel-on-outside-click="${this.noCancelOnOutsideClick}"
141
- @exm-drawer-opened-changed=${this.handleDrawerOpenedChanged}
142
- scroll-action=${ifDefined(this.scrollAction)}
143
- style="max-width: ${this.style.maxWidth || '547px'}"
144
- >
145
- <div class="header">
146
- <slot name="title" class="title">${this.title}</slot>
147
- <div class="header-buttons">
148
- <md-text-button slot="footer" dialogFocus @click=${() => this.handleCancelBtnClick()}
149
- >${this.cancelBtnTitle}</md-text-button
150
- >
151
- ${this.submitBtnHidden
152
- ? ''
153
- : html ` <exm-filled-button
154
- slot="footer"
155
- @click=${this.handleSubmit}
156
- ?disabled=${this.submitting || !this.formValid}
157
- ?loading=${this.submitting}
158
- >${this.submitBtnTitle}</exm-filled-button
159
- >`}
160
- </div>
161
- </div>
162
- ${this.errorMessage ? this.renderError() : nothing}
163
- <div class="form-elements">${this.renderFormContent()}</div>
164
- </exm-drawer>
165
- `;
166
- }
167
- }
168
- __decorate([
169
- property({ type: Boolean })
170
- ], ExmFormDrawerBase.prototype, "opened", void 0);
171
- __decorate([
172
- property({ type: String, attribute: 'submit-btn-title' })
173
- ], ExmFormDrawerBase.prototype, "submitBtnTitle", void 0);
174
- __decorate([
175
- property({ type: Boolean, attribute: 'submit-btn-hidden' })
176
- ], ExmFormDrawerBase.prototype, "submitBtnHidden", void 0);
177
- __decorate([
178
- property({ type: String, attribute: 'cancel-btn-title' })
179
- ], ExmFormDrawerBase.prototype, "cancelBtnTitle", void 0);
180
- __decorate([
181
- property({ type: Boolean, attribute: 'keep-opened-on-submit-success' })
182
- ], ExmFormDrawerBase.prototype, "keepOpenedOnSubmitSuccess", void 0);
183
- __decorate([
184
- property({ type: Boolean, attribute: 'no-cancel-on-outside-click' })
185
- ], ExmFormDrawerBase.prototype, "noCancelOnOutsideClick", void 0);
186
- __decorate([
187
- property({ type: Boolean, attribute: 'disable-sticky-header' })
188
- ], ExmFormDrawerBase.prototype, "disableStickyHeader", void 0);
189
- __decorate([
190
- property({ type: Boolean })
191
- ], ExmFormDrawerBase.prototype, "submitting", void 0);
192
- __decorate([
193
- property({ type: String, attribute: 'scroll-action' })
194
- ], ExmFormDrawerBase.prototype, "scrollAction", void 0);
195
- __decorate([
196
- property({ type: String })
197
- ], ExmFormDrawerBase.prototype, "errorMessage", void 0);
198
- //# sourceMappingURL=exm-form-drawer-base.js.map
@@ -1,10 +0,0 @@
1
- import { ExmFormDrawerBase } from './exm-form-drawer-base.js';
2
- export declare class ExmFormDrawer extends ExmFormDrawerBase {
3
- static styles: import("lit").CSSResult[];
4
- getForm(): HTMLFormElement | null;
5
- }
6
- declare global {
7
- interface HTMLElementTagNameMap {
8
- 'exm-form-drawer': ExmFormDrawer;
9
- }
10
- }
@@ -1,16 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { customElement } from 'lit/decorators.js';
3
- import { style } from './styles/exm-form-drawer-styles-css.js';
4
- import { ExmFormDrawerBase } from './exm-form-drawer-base.js';
5
- import { formStyles } from '@exmg/exm-form';
6
- let ExmFormDrawer = class ExmFormDrawer extends ExmFormDrawerBase {
7
- getForm() {
8
- return this.querySelector('form');
9
- }
10
- };
11
- ExmFormDrawer.styles = [style, formStyles];
12
- ExmFormDrawer = __decorate([
13
- customElement('exm-form-drawer')
14
- ], ExmFormDrawer);
15
- export { ExmFormDrawer };
16
- //# sourceMappingURL=exm-form-drawer.js.map
@@ -1,2 +0,0 @@
1
- export declare const style: import("lit").CSSResult;
2
- export default style;
@@ -1,4 +0,0 @@
1
- import { css } from 'lit';
2
- export const style = css `paper-dialog{margin:0;padding:0;position:fixed;top:0;right:0;bottom:0;width:100%;box-shadow:none;overflow:scroll;color:var(--exm-drawer-color, var(--md-sys-color-on-surface, black));background-color:var(--exm-drawer-bg-color, var(--md-sys-color-surface-variant, white))}`;
3
- export default style;
4
- //# sourceMappingURL=exm-drawer-styles-css.js.map
@@ -1,2 +0,0 @@
1
- export declare const style: import("lit").CSSResult;
2
- export default style;
@@ -1,4 +0,0 @@
1
- import { css } from 'lit';
2
- export const style = css `:host{display:flex}:host .header{display:flex;flex-direction:row;align-items:center;margin:0;padding:20px;border-bottom:1px solid var(--exm-form-drawer-header-separator-color, var(--mdc-theme-on-surface, rgba(2, 24, 43, 0.1)))}:host .header .title{font-size:1.4rem}:host .form-elements{padding:0 0px}.header-buttons{display:flex;flex-direction:row;flex:1;justify-content:flex-end}.header-buttons>*{margin-left:20px}:host(:not([disable-sticky-header])) .header{position:sticky;top:0;background-color:var(--exm-drawer-bg-color, var(--md-sys-color-surface-variant, white));z-index:2}form{margin:0 !important;padding:.5rem 1rem;box-sizing:border-box}.error{background-color:var(--md-sys-color-error-container);color:var(--md-sys-color-on-error-container);padding:.5rem}.error>*{margin:1rem}`;
3
- export default style;
4
- //# sourceMappingURL=exm-form-drawer-styles-css.js.map