@exmg/exm-drawer 0.0.2-alpha.0
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/dist/exm-drawer-base.d.ts +39 -0
- package/dist/exm-drawer-base.js +110 -0
- package/dist/exm-drawer.d.ts +9 -0
- package/dist/exm-drawer.js +12 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/styles/exm-drawer-styles-css.d.ts +1 -0
- package/dist/styles/exm-drawer-styles-css.js +81 -0
- package/package.json +41 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PropertyValues } from 'lit';
|
|
2
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
3
|
+
export declare class ExmDrawerBase extends ExmgElement {
|
|
4
|
+
/**
|
|
5
|
+
* The opened state of the drawer
|
|
6
|
+
*/
|
|
7
|
+
opened: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Which side should we show the drawer
|
|
10
|
+
* @type {String}
|
|
11
|
+
*/
|
|
12
|
+
side: 'right' | 'left';
|
|
13
|
+
/**
|
|
14
|
+
* Prevent cancel on outside click or not
|
|
15
|
+
*/
|
|
16
|
+
noCancelOnOutsideClick: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Prevent cancel on use of the escape key
|
|
19
|
+
*/
|
|
20
|
+
disableEsc: boolean;
|
|
21
|
+
dialogElement?: HTMLDialogElement;
|
|
22
|
+
disconnectedCallback(): void;
|
|
23
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
24
|
+
private handleOpenedChange;
|
|
25
|
+
/**
|
|
26
|
+
* Handle the backdrop click. Check if the clicked element is the dialog. If so close it.
|
|
27
|
+
* In the dialog is a div.content element. When clicking this area, the target is not the dialog, so will not close the client
|
|
28
|
+
*/
|
|
29
|
+
private handleBackdropClick;
|
|
30
|
+
private catchEscKey;
|
|
31
|
+
private handleCloseEvent;
|
|
32
|
+
private handleOpenedChanged;
|
|
33
|
+
openDialog(): void;
|
|
34
|
+
closeDialog(): void;
|
|
35
|
+
/**
|
|
36
|
+
* The div.content in the render is needed for making the backdrop click work
|
|
37
|
+
*/
|
|
38
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property, query } from 'lit/decorators.js';
|
|
4
|
+
import { ExmgElement, observer } from '@exmg/lit-base';
|
|
5
|
+
export class ExmDrawerBase extends ExmgElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
/**
|
|
9
|
+
* The opened state of the drawer
|
|
10
|
+
*/
|
|
11
|
+
this.opened = false;
|
|
12
|
+
/**
|
|
13
|
+
* Which side should we show the drawer
|
|
14
|
+
* @type {String}
|
|
15
|
+
*/
|
|
16
|
+
this.side = 'right';
|
|
17
|
+
/**
|
|
18
|
+
* Prevent cancel on outside click or not
|
|
19
|
+
*/
|
|
20
|
+
this.noCancelOnOutsideClick = false;
|
|
21
|
+
/**
|
|
22
|
+
* Prevent cancel on use of the escape key
|
|
23
|
+
*/
|
|
24
|
+
this.disableEsc = false;
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
(_a = this.dialogElement) === null || _a === void 0 ? void 0 : _a.removeEventListener('close', this.handleCloseEvent.bind(this));
|
|
29
|
+
(_b = this.dialogElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('keydown', this.catchEscKey.bind(this));
|
|
30
|
+
super.disconnectedCallback();
|
|
31
|
+
}
|
|
32
|
+
firstUpdated(_changedProperties) {
|
|
33
|
+
var _a;
|
|
34
|
+
(_a = this.dialogElement) === null || _a === void 0 ? void 0 : _a.addEventListener('close', this.handleCloseEvent.bind(this));
|
|
35
|
+
}
|
|
36
|
+
handleOpenedChange(opened) {
|
|
37
|
+
var _a, _b, _c, _d;
|
|
38
|
+
if (opened) {
|
|
39
|
+
if (!this.noCancelOnOutsideClick) {
|
|
40
|
+
(_a = this.dialogElement) === null || _a === void 0 ? void 0 : _a.addEventListener('click', this.handleBackdropClick.bind(this));
|
|
41
|
+
}
|
|
42
|
+
if (this.disableEsc) {
|
|
43
|
+
(_b = this.dialogElement) === null || _b === void 0 ? void 0 : _b.addEventListener('keydown', this.catchEscKey.bind(this));
|
|
44
|
+
}
|
|
45
|
+
(_c = this.dialogElement) === null || _c === void 0 ? void 0 : _c.showModal();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
(_d = this.dialogElement) === null || _d === void 0 ? void 0 : _d.close();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Handle the backdrop click. Check if the clicked element is the dialog. If so close it.
|
|
53
|
+
* In the dialog is a div.content element. When clicking this area, the target is not the dialog, so will not close the client
|
|
54
|
+
*/
|
|
55
|
+
handleBackdropClick(event) {
|
|
56
|
+
var _a;
|
|
57
|
+
if (event.target === this.dialogElement) {
|
|
58
|
+
(_a = this.dialogElement) === null || _a === void 0 ? void 0 : _a.close();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catchEscKey(event) {
|
|
62
|
+
if (event.code === 'Escape') {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
handleCloseEvent() {
|
|
67
|
+
this.handleOpenedChanged({ detail: { value: false } });
|
|
68
|
+
}
|
|
69
|
+
handleOpenedChanged(e) {
|
|
70
|
+
this.opened = e.detail.value;
|
|
71
|
+
this.fire('exm-drawer-opened-changed', this.opened, true);
|
|
72
|
+
}
|
|
73
|
+
openDialog() {
|
|
74
|
+
this.opened = true;
|
|
75
|
+
}
|
|
76
|
+
closeDialog() {
|
|
77
|
+
this.opened = false;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The div.content in the render is needed for making the backdrop click work
|
|
81
|
+
*/
|
|
82
|
+
render() {
|
|
83
|
+
return html `
|
|
84
|
+
<dialog class="${this.side}" @opened-changed="${this.handleOpenedChanged}">
|
|
85
|
+
<div class="content">
|
|
86
|
+
<slot></slot>
|
|
87
|
+
</div>
|
|
88
|
+
</dialog>
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
__decorate([
|
|
93
|
+
property({ type: Boolean }),
|
|
94
|
+
observer(function (opened) {
|
|
95
|
+
this.handleOpenedChange(opened);
|
|
96
|
+
})
|
|
97
|
+
], ExmDrawerBase.prototype, "opened", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
property({ type: String })
|
|
100
|
+
], ExmDrawerBase.prototype, "side", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
property({ type: Boolean, attribute: 'no-cancel-on-outside-click' })
|
|
103
|
+
], ExmDrawerBase.prototype, "noCancelOnOutsideClick", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
property({ type: Boolean, attribute: 'no-cancel-on-escape' })
|
|
106
|
+
], ExmDrawerBase.prototype, "disableEsc", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
query('dialog')
|
|
109
|
+
], ExmDrawerBase.prototype, "dialogElement", void 0);
|
|
110
|
+
//# sourceMappingURL=exm-drawer-base.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import { style } from './styles/exm-drawer-styles-css.js';
|
|
4
|
+
import { ExmDrawerBase } from './exm-drawer-base.js';
|
|
5
|
+
let ExmDrawer = class ExmDrawer extends ExmDrawerBase {
|
|
6
|
+
};
|
|
7
|
+
ExmDrawer.styles = [style];
|
|
8
|
+
ExmDrawer = __decorate([
|
|
9
|
+
customElement('exm-drawer')
|
|
10
|
+
], ExmDrawer);
|
|
11
|
+
export { ExmDrawer };
|
|
12
|
+
//# sourceMappingURL=exm-drawer.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const style: import("lit").CSSResult;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const style = css `
|
|
3
|
+
:host {
|
|
4
|
+
--_exm-drawer-max-width: var(--exm-drawer-max-width, 574px);
|
|
5
|
+
--_exm-drawer-top-offset: var(--exm-drawer-top-offset, 0);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
dialog {
|
|
9
|
+
--drawer-animation-start: var(--_exm-drawer-max-width);
|
|
10
|
+
--drawer-animation-end: 0;
|
|
11
|
+
|
|
12
|
+
position: fixed;
|
|
13
|
+
top: var(--_exm-drawer-top-offset);
|
|
14
|
+
right: 0;
|
|
15
|
+
left: auto;
|
|
16
|
+
width: var(--_exm-drawer-max-width);
|
|
17
|
+
margin: 0;
|
|
18
|
+
height: calc(100vh - var(--_exm-drawer-top-offset));
|
|
19
|
+
max-height: calc(100vh - var(--_exm-drawer-top-offset));
|
|
20
|
+
padding: 0;
|
|
21
|
+
transition:
|
|
22
|
+
display 0.3s allow-discrete,
|
|
23
|
+
overlay 0.3s allow-discrete;
|
|
24
|
+
animation: drawerClose 0.3s forwards;
|
|
25
|
+
border: 0;
|
|
26
|
+
background-color: var(--exm-drawer-container-color, var(--md-sys-color-surface-container, #f3edf7));
|
|
27
|
+
color: var(--exm-drawer-container-on-color, var(--md-sys-color-on-surface-container, #f3edf7));
|
|
28
|
+
|
|
29
|
+
&[open] {
|
|
30
|
+
animation: drawerShow 0.3s forwards;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&::backdrop {
|
|
34
|
+
background: rgba(0, 0, 0, 0.7);
|
|
35
|
+
backdrop-filter: blur(4px);
|
|
36
|
+
top: var(--_exm-drawer-top-offset);
|
|
37
|
+
animation: overlayShow 300ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.left {
|
|
41
|
+
--drawer-animation-start: calc(var(--_exm-drawer-max-width) * -1);
|
|
42
|
+
|
|
43
|
+
left: 0;
|
|
44
|
+
right: auto;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.content {
|
|
48
|
+
position: absolute;
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@keyframes overlayShow {
|
|
55
|
+
from {
|
|
56
|
+
opacity: 0;
|
|
57
|
+
}
|
|
58
|
+
to {
|
|
59
|
+
opacity: 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@keyframes drawerShow {
|
|
64
|
+
from {
|
|
65
|
+
transform: translateX(var(--drawer-animation-start));
|
|
66
|
+
}
|
|
67
|
+
to {
|
|
68
|
+
transform: translateX(var(--drawer-animation-end));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@keyframes drawerClose {
|
|
73
|
+
from {
|
|
74
|
+
transform: translateX(var(--drawer-animation-end));
|
|
75
|
+
}
|
|
76
|
+
to {
|
|
77
|
+
transform: translateX(var(--drawer-animation-start));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
//# sourceMappingURL=exm-drawer-styles-css.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@exmg/exm-drawer",
|
|
3
|
+
"version": "0.0.2-alpha.0+df24e0c",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./exm-drawer.js": "./dist/exm-drawer.js"
|
|
11
|
+
},
|
|
12
|
+
"description": "Drawer element",
|
|
13
|
+
"contributors": [
|
|
14
|
+
"Ex Machina"
|
|
15
|
+
],
|
|
16
|
+
"keywords": [
|
|
17
|
+
"web-components",
|
|
18
|
+
"lit",
|
|
19
|
+
"form"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"**/*.scss",
|
|
23
|
+
"**/*.js",
|
|
24
|
+
"**/*.d.ts"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git@bitbucket.org:exmachina/exm-web-components.git",
|
|
29
|
+
"directory": "packages/exm-drawer"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"lit": "^3.2.1",
|
|
34
|
+
"tslib": "^2.6.2"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "df24e0c74a76a7e1c258f69386036e24e7860256"
|
|
41
|
+
}
|