@maggioli-design-system/mds-modal 4.1.0 → 4.3.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/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mds-modal.cjs.entry.js +22 -24
- package/dist/cjs/mds-modal.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/common/aria.js +4 -2
- package/dist/collection/common/keyboard-manager.js +1 -1
- package/dist/collection/common/unit.js +10 -0
- package/dist/collection/components/mds-modal/mds-modal.css +95 -97
- package/dist/collection/components/mds-modal/mds-modal.js +25 -26
- package/dist/collection/dictionary/button.js +5 -1
- package/dist/collection/dictionary/variant.js +9 -1
- package/dist/components/mds-modal.js +22 -24
- package/dist/documentation.d.ts +148 -0
- package/dist/documentation.json +142 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mds-modal.entry.js +22 -24
- package/dist/esm/mds-modal.js +1 -1
- package/dist/esm-es5/mds-modal.entry.js +1 -1
- package/dist/mds-modal/mds-modal.esm.js +1 -1
- package/dist/mds-modal/mds-modal.js +1 -1
- package/dist/mds-modal/p-24b3f7bd.entry.js +1 -0
- package/dist/mds-modal/p-b2f313ba.system.entry.js +1 -0
- package/{www/build/p-f856db3e.system.js → dist/mds-modal/p-e2fdb863.system.js} +1 -1
- package/dist/stats.json +33 -26
- package/dist/types/common/unit.d.ts +2 -0
- package/dist/types/components.d.ts +1 -1
- package/dist/types/dictionary/button.d.ts +2 -1
- package/dist/types/dictionary/variant.d.ts +2 -1
- package/dist/types/interface/input-value.d.ts +1 -1
- package/dist/types/type/button.d.ts +1 -0
- package/dist/types/type/variant.d.ts +1 -0
- package/documentation.json +149 -0
- package/package.json +10 -4
- package/readme.md +4 -4
- package/src/common/aria.ts +2 -2
- package/src/common/keyboard-manager.ts +1 -1
- package/src/common/unit.ts +14 -0
- package/src/components/mds-modal/css/components.css +49 -0
- package/src/components/mds-modal/css/mds-modal-animate-bottom.css +12 -12
- package/src/components/mds-modal/css/mds-modal-animate-center.css +12 -12
- package/src/components/mds-modal/css/mds-modal-animate-left.css +16 -16
- package/src/components/mds-modal/css/mds-modal-animate-right.css +16 -16
- package/src/components/mds-modal/css/mds-modal-animate-top.css +12 -12
- package/src/components/mds-modal/mds-modal.css +14 -67
- package/src/components/mds-modal/mds-modal.tsx +16 -21
- package/src/components/mds-modal/readme.md +11 -4
- package/src/components/mds-modal/test/mds-modal.e2e.ts +3 -3
- package/src/components.d.ts +1 -1
- package/src/dictionary/button.ts +7 -1
- package/src/dictionary/variant.ts +10 -0
- package/src/fixtures/icons.json +38 -0
- package/src/fixtures/iconsauce.json +37 -0
- package/src/interface/input-value.ts +1 -1
- package/src/type/button.ts +4 -0
- package/src/type/variant.ts +9 -0
- package/www/build/mds-modal.esm.js +1 -1
- package/www/build/mds-modal.js +1 -1
- package/www/build/p-24b3f7bd.entry.js +1 -0
- package/www/build/p-b2f313ba.system.entry.js +1 -0
- package/{dist/mds-modal/p-f856db3e.system.js → www/build/p-e2fdb863.system.js} +1 -1
- package/dist/mds-modal/p-1e2f03d3.system.entry.js +0 -1
- package/dist/mds-modal/p-536e9f30.entry.js +0 -1
- package/src/components/mds-modal/test/mds-modal.spec.tsx +0 -19
- package/www/build/p-1e2f03d3.system.entry.js +0 -1
- package/www/build/p-536e9f30.entry.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maggioli-design-system/mds-modal",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "mds-modal is a web-component from Maggioli Design System Magma, built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScirpt framework you are using.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"unpkg": "dist/mds-modal/mds-modal.esm.js",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist/",
|
|
15
|
+
"documentation.json",
|
|
15
16
|
"loader/",
|
|
16
17
|
"readme.md",
|
|
17
18
|
"src/",
|
|
@@ -23,8 +24,8 @@
|
|
|
23
24
|
"test": "stencil test --spec --e2e"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@maggioli-design-system/styles": "^11.
|
|
27
|
-
"@stencil/core": "^2.22.
|
|
27
|
+
"@maggioli-design-system/styles": "^11.7.0",
|
|
28
|
+
"@stencil/core": "^2.22.3",
|
|
28
29
|
"clsx": "^1.2.1"
|
|
29
30
|
},
|
|
30
31
|
"license": "MIT",
|
|
@@ -39,10 +40,15 @@
|
|
|
39
40
|
"email": "andrea.pruccoli@maggioli.it",
|
|
40
41
|
"role": "Software Engineer"
|
|
41
42
|
},
|
|
43
|
+
{
|
|
44
|
+
"name": "Nicola Tamburini",
|
|
45
|
+
"email": "nicola.tamburini@maggioli.it",
|
|
46
|
+
"role": "Software Engineer"
|
|
47
|
+
},
|
|
42
48
|
{
|
|
43
49
|
"name": "Vittorio Vittori",
|
|
44
50
|
"email": "vittorio.vittori@maggioli.it",
|
|
45
|
-
"role": "
|
|
51
|
+
"role": "Product Designer"
|
|
46
52
|
}
|
|
47
53
|
]
|
|
48
54
|
}
|
package/readme.md
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
## Properties
|
|
9
9
|
|
|
10
|
-
| Property | Attribute | Description | Type
|
|
11
|
-
| ---------- | ---------- | ---------------------------------------------------- |
|
|
12
|
-
| `opened` | `opened` | Specifies if the modal is opened or not | `boolean`
|
|
13
|
-
| `position` | `position` | Specifies the animation position of the modal window | `"bottom" \| "center" \| "left" \| "right" \| "top"` | `
|
|
10
|
+
| Property | Attribute | Description | Type | Default |
|
|
11
|
+
| ---------- | ---------- | ---------------------------------------------------- | ----------------------------------------------------------------- | ---------- |
|
|
12
|
+
| `opened` | `opened` | Specifies if the modal is opened or not | `boolean` | `false` |
|
|
13
|
+
| `position` | `position` | Specifies the animation position of the modal window | `"bottom" \| "center" \| "left" \| "right" \| "top" \| undefined` | `'center'` |
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
## Events
|
package/src/common/aria.ts
CHANGED
|
@@ -7,12 +7,12 @@ const hash = (s: string): string => {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const unslugName = (name: string): string => {
|
|
10
|
-
return name.split('/')
|
|
10
|
+
return name.split('/')?.slice(-1).pop()?.replace(/-/g, ' ') ?? name
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const setAttributeIfEmpty = (element: HTMLElement, attribute: string, value: string): string => {
|
|
14
14
|
if (element.hasAttribute(attribute)) {
|
|
15
|
-
return element.getAttribute(attribute)
|
|
15
|
+
return element.getAttribute(attribute) ?? ''
|
|
16
16
|
}
|
|
17
17
|
element.setAttribute(attribute, value)
|
|
18
18
|
return value
|
|
@@ -38,7 +38,7 @@ export class KeyboardManager {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
detachEscapeBehavior = (): void => {
|
|
41
|
-
this.escapeCallback =
|
|
41
|
+
this.escapeCallback = () => {return}
|
|
42
42
|
if (typeof window !== undefined) {
|
|
43
43
|
window.removeEventListener('keydown', this.handleEscapeBehaviorDispatchEvent.bind(this))
|
|
44
44
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const cssDurationToMilliseconds = (duration: string, defaultValue = 1000): number => {
|
|
2
|
+
if (duration.includes('s')) {
|
|
3
|
+
return Number(duration.replace('s', '')) * 1000
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (duration.includes('ms')) {
|
|
7
|
+
return Number(duration.replace('s', ''))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return defaultValue
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
cssDurationToMilliseconds,
|
|
14
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@tailwind components;
|
|
2
|
+
@tailwind utilities;
|
|
3
|
+
|
|
4
|
+
@layer components {
|
|
5
|
+
.animate {
|
|
6
|
+
@apply
|
|
7
|
+
duration-500
|
|
8
|
+
ease-in-out-expo
|
|
9
|
+
opacity-0
|
|
10
|
+
transition-cosmetic;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.animate-bottom-intro,
|
|
14
|
+
.animate-center-intro,
|
|
15
|
+
.animate-top-intro {
|
|
16
|
+
transform: rotateX(-22deg) scale(0.5) translateY(40%);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.animate-bottom-opened,
|
|
20
|
+
.animate-center-opened,
|
|
21
|
+
.animate-top-opened {
|
|
22
|
+
@apply opacity-100;
|
|
23
|
+
|
|
24
|
+
transform: rotateX(0) scale(1) translateY(0);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.animate-bottom-outro,
|
|
28
|
+
.animate-center-outro,
|
|
29
|
+
.animate-top-outro {
|
|
30
|
+
transform: rotateX(-22deg) scale(0.5) translateY(-40%);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.animate-right-intro,
|
|
34
|
+
.animate-right-outro {
|
|
35
|
+
transform: translateX(calc(100% + 50px));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.animate-right-opened,
|
|
39
|
+
.animate-left-opened {
|
|
40
|
+
@apply opacity-100;
|
|
41
|
+
|
|
42
|
+
transform: translateX(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.animate-left-intro,
|
|
46
|
+
.animate-left-outro {
|
|
47
|
+
transform: translateX(calc(-100% - 50px));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host( .to-bottom ) {
|
|
2
2
|
@apply
|
|
3
3
|
justify-center
|
|
4
4
|
mobile:p-4
|
|
5
5
|
p-8;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
:host
|
|
9
|
-
:host
|
|
10
|
-
@apply animate
|
|
8
|
+
:host( .to-bottom ) .window,
|
|
9
|
+
:host( .to-bottom ) > ::slotted( [slot="window"] ) {
|
|
10
|
+
@apply animate;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
:host
|
|
14
|
-
:host
|
|
13
|
+
:host( .to-bottom-intro ) .window,
|
|
14
|
+
:host( .to-bottom-intro ) > ::slotted( [slot="window"] ) {
|
|
15
15
|
@apply animate-bottom-intro;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
:host
|
|
19
|
-
:host
|
|
20
|
-
:host
|
|
21
|
-
:host
|
|
18
|
+
:host( .to-bottom-opened.to-bottom-outro ) .window,
|
|
19
|
+
:host( .to-bottom-opened.to-bottom-outro ) > ::slotted( [slot="window"] ),
|
|
20
|
+
:host( .to-bottom-opened ) .window,
|
|
21
|
+
:host( .to-bottom-opened ) > ::slotted( [slot="window"] ) {
|
|
22
22
|
@apply animate-bottom-opened;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
:host
|
|
26
|
-
:host
|
|
25
|
+
:host( .to-bottom-outro ) .window,
|
|
26
|
+
:host( .to-bottom-outro ) > ::slotted( [slot="window"] ) {
|
|
27
27
|
@apply animate-bottom-outro;
|
|
28
28
|
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host( .to-center ) {
|
|
2
2
|
@apply
|
|
3
3
|
justify-center
|
|
4
4
|
mobile:p-4
|
|
5
5
|
p-8;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
:host
|
|
9
|
-
:host
|
|
10
|
-
@apply animate
|
|
8
|
+
:host( .to-center ) .window,
|
|
9
|
+
:host( .to-center ) > ::slotted( [slot="window"] ) {
|
|
10
|
+
@apply animate;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
:host
|
|
14
|
-
:host
|
|
13
|
+
:host( .to-center-intro ) .window,
|
|
14
|
+
:host( .to-center-intro ) > ::slotted( [slot="window"] ) {
|
|
15
15
|
@apply animate-center-intro;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
:host
|
|
19
|
-
:host
|
|
20
|
-
:host
|
|
21
|
-
:host
|
|
18
|
+
:host( .to-center-opened.to-center-outro ) .window,
|
|
19
|
+
:host( .to-center-opened.to-center-outro ) > ::slotted( [slot="window"] ),
|
|
20
|
+
:host( .to-center-opened ) .window,
|
|
21
|
+
:host( .to-center-opened ) > ::slotted( [slot="window"] ) {
|
|
22
22
|
@apply animate-center-opened;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
:host
|
|
26
|
-
:host
|
|
25
|
+
:host( .to-center-outro ) .window,
|
|
26
|
+
:host( .to-center-outro ) > ::slotted( [slot="window"] ) {
|
|
27
27
|
@apply animate-center-outro;
|
|
28
28
|
}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host( .to-left ) {
|
|
2
2
|
@apply justify-start;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
:host
|
|
6
|
-
:host
|
|
7
|
-
@apply animate
|
|
5
|
+
:host( .to-left ) .window,
|
|
6
|
+
:host( .to-left ) > ::slotted( [slot="window"] ) {
|
|
7
|
+
@apply animate;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
:host
|
|
11
|
-
:host
|
|
10
|
+
:host( .to-left-intro ) .window,
|
|
11
|
+
:host( .to-left-intro ) > ::slotted( [slot="window"] ) {
|
|
12
12
|
@apply animate-left-intro;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
:host
|
|
16
|
-
:host
|
|
17
|
-
:host
|
|
18
|
-
:host
|
|
15
|
+
:host( .to-left-opened.to-left-outro ) .window,
|
|
16
|
+
:host( .to-left-opened.to-left-outro ) > ::slotted( [slot="window"] ),
|
|
17
|
+
:host( .to-left-opened ) .window,
|
|
18
|
+
:host( .to-left-opened ) > ::slotted( [slot="window"] ) {
|
|
19
19
|
@apply animate-left-opened;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
:host
|
|
23
|
-
:host
|
|
22
|
+
:host( .to-left-opened ) .close,
|
|
23
|
+
:host( .to-left-opened.to-left-outro ) .close {
|
|
24
24
|
@apply opacity-100;
|
|
25
25
|
|
|
26
26
|
transform: translate(-24px, 24px) rotate(0);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
:host
|
|
30
|
-
:host
|
|
29
|
+
:host( .to-left-outro ) .window,
|
|
30
|
+
:host( .to-left-outro ) > ::slotted( [slot="window"] ) {
|
|
31
31
|
@apply animate-left-outro;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
:host
|
|
34
|
+
:host( .to-left-outro ) .close {
|
|
35
35
|
transform: translate(24px, 24px) rotate(-90deg);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
:host
|
|
38
|
+
:host( .to-left ) .close {
|
|
39
39
|
@apply right-0;
|
|
40
40
|
|
|
41
41
|
transform: translate(36px, 24px) rotate(90deg);
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host( .to-right ) {
|
|
2
2
|
@apply justify-end;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
:host
|
|
6
|
-
:host
|
|
7
|
-
@apply animate
|
|
5
|
+
:host( .to-right ) .window,
|
|
6
|
+
:host( .to-right ) > ::slotted([slot="window"]) {
|
|
7
|
+
@apply animate;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
:host
|
|
11
|
-
:host
|
|
10
|
+
:host( .to-right-intro ) .window,
|
|
11
|
+
:host( .to-right-intro ) > ::slotted( [slot="window"] ) {
|
|
12
12
|
@apply animate-right-intro;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
:host
|
|
16
|
-
:host
|
|
17
|
-
:host
|
|
18
|
-
:host
|
|
15
|
+
:host( .to-right-opened.to-right-outro ) .window,
|
|
16
|
+
:host( .to-right-opened.to-right-outro ) > ::slotted( [slot="window"] ),
|
|
17
|
+
:host( .to-right-opened ) .window,
|
|
18
|
+
:host( .to-right-opened ) > ::slotted( [slot="window"] ) {
|
|
19
19
|
@apply animate-right-opened;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
:host
|
|
23
|
-
:host
|
|
22
|
+
:host( .to-right-opened ) .close,
|
|
23
|
+
:host( .to-right-opened.to-right-outro ) .close {
|
|
24
24
|
@apply opacity-100;
|
|
25
25
|
|
|
26
26
|
transform: translate(24px, 24px) rotate(0);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
:host
|
|
30
|
-
:host
|
|
29
|
+
:host( .to-right-outro ) .window,
|
|
30
|
+
:host( .to-right-outro ) > ::slotted( [slot="window"] ) {
|
|
31
31
|
@apply animate-right-outro;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
:host
|
|
34
|
+
:host( .to-right-outro ) .close {
|
|
35
35
|
transform: translate(-24px, 24px) rotate(90deg);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
:host
|
|
38
|
+
:host( .to-right ) .close {
|
|
39
39
|
@apply left-0;
|
|
40
40
|
|
|
41
41
|
transform: translate(-36px, 24px) rotate(-90deg);
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
:host
|
|
1
|
+
:host( .to-top ) {
|
|
2
2
|
@apply
|
|
3
3
|
justify-center
|
|
4
4
|
mobile:p-4
|
|
5
5
|
p-8;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
:host
|
|
9
|
-
:host
|
|
10
|
-
@apply animate
|
|
8
|
+
:host( .to-top ) .window,
|
|
9
|
+
:host( .to-top ) > ::slotted( [slot="window"] ) {
|
|
10
|
+
@apply animate;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
:host
|
|
14
|
-
:host
|
|
13
|
+
:host( .to-top-intro ) .window,
|
|
14
|
+
:host( .to-top-intro ) > ::slotted( [slot="window"] ) {
|
|
15
15
|
@apply animate-top-intro;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
:host
|
|
19
|
-
:host
|
|
20
|
-
:host
|
|
21
|
-
:host
|
|
18
|
+
:host( .to-top-opened.to-top-outro ) .window,
|
|
19
|
+
:host( .to-top-opened.to-top-outro ) > ::slotted( [slot="window"] ),
|
|
20
|
+
:host( .to-top-opened ) .window,
|
|
21
|
+
:host( .to-top-opened ) > ::slotted( [slot="window"] ) {
|
|
22
22
|
@apply animate-top-opened;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
:host
|
|
26
|
-
:host
|
|
25
|
+
:host( .to-top-outro ) .window,
|
|
26
|
+
:host( .to-top-outro ) > ::slotted( [slot="window"] ) {
|
|
27
27
|
@apply animate-top-outro;
|
|
28
28
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/* stylelint-disable */
|
|
1
2
|
@import '../../tailwind/components.css';
|
|
3
|
+
@import './css/components.css';
|
|
4
|
+
|
|
2
5
|
@tailwind components;
|
|
3
6
|
@tailwind utilities;
|
|
4
7
|
|
|
@@ -11,64 +14,6 @@
|
|
|
11
14
|
* @prop --mds-modal-z-index: Set the z-index of the window when the component is opened
|
|
12
15
|
*/
|
|
13
16
|
|
|
14
|
-
@layer components {
|
|
15
|
-
.animate-bottom,
|
|
16
|
-
.animate-center,
|
|
17
|
-
.animate-top {
|
|
18
|
-
@apply
|
|
19
|
-
duration-500
|
|
20
|
-
ease-in-out-expo
|
|
21
|
-
opacity-0
|
|
22
|
-
transition-cosmetic;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.animate-bottom-intro,
|
|
26
|
-
.animate-center-intro,
|
|
27
|
-
.animate-top-intro {
|
|
28
|
-
transform: rotateX(-22deg) scale(0.5) translateY(40%);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.animate-bottom-opened,
|
|
32
|
-
.animate-center-opened,
|
|
33
|
-
.animate-top-opened {
|
|
34
|
-
@apply opacity-100;
|
|
35
|
-
|
|
36
|
-
transform: rotateX(0) scale(1) translateY(0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.animate-bottom-outro,
|
|
40
|
-
.animate-center-outro,
|
|
41
|
-
.animate-top-outro {
|
|
42
|
-
transform: rotateX(-22deg) scale(0.5) translateY(-40%);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.animate-left,
|
|
46
|
-
.animate-right {
|
|
47
|
-
@apply
|
|
48
|
-
duration-500
|
|
49
|
-
opacity-0
|
|
50
|
-
ease-in-out-expo
|
|
51
|
-
transition-cosmetic;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.animate-right-intro,
|
|
55
|
-
.animate-right-outro {
|
|
56
|
-
transform: translateX(calc(100% + 50px));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.animate-right-opened,
|
|
60
|
-
.animate-left-opened {
|
|
61
|
-
@apply opacity-100;
|
|
62
|
-
|
|
63
|
-
transform: translateX(0);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.animate-left-intro,
|
|
67
|
-
.animate-left-outro {
|
|
68
|
-
transform: translateX(calc(-100% - 50px));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
17
|
:host {
|
|
73
18
|
|
|
74
19
|
--mds-modal-overlay-color: var(--magma-overlay-color, 0 0 0);
|
|
@@ -89,27 +34,28 @@
|
|
|
89
34
|
pointer-events-none;
|
|
90
35
|
|
|
91
36
|
background-color: rgba(var(--mds-modal-overlay-color) / 0);
|
|
37
|
+
fill: theme('colors.tone-neutral');
|
|
92
38
|
perspective: 600px;
|
|
93
|
-
z-index: var(--z-index, 1000);
|
|
39
|
+
z-index: var(--mds-modal-z-index, 1000);
|
|
94
40
|
}
|
|
95
41
|
|
|
96
|
-
:host
|
|
42
|
+
:host( [position=top] ) {
|
|
97
43
|
@apply
|
|
98
44
|
items-start
|
|
99
45
|
justify-center;
|
|
100
46
|
}
|
|
101
47
|
|
|
102
|
-
:host
|
|
48
|
+
:host( [position=bottom] ) {
|
|
103
49
|
@apply
|
|
104
50
|
items-end
|
|
105
51
|
justify-center;
|
|
106
52
|
}
|
|
107
53
|
|
|
108
|
-
:host
|
|
109
|
-
:host
|
|
110
|
-
:host
|
|
111
|
-
:host
|
|
112
|
-
:host
|
|
54
|
+
:host( .to-bottom-opened ),
|
|
55
|
+
:host( .to-center-opened ),
|
|
56
|
+
:host( .to-left-opened ),
|
|
57
|
+
:host( .to-right-opened ),
|
|
58
|
+
:host( .to-top-opened ) {
|
|
113
59
|
@apply
|
|
114
60
|
duration-500
|
|
115
61
|
pointer-events-auto;
|
|
@@ -123,7 +69,6 @@
|
|
|
123
69
|
cursor-pointer
|
|
124
70
|
duration-500
|
|
125
71
|
ease-in-out-quart
|
|
126
|
-
fill-tone-neutral-10
|
|
127
72
|
h-9
|
|
128
73
|
opacity-0
|
|
129
74
|
origin-center
|
|
@@ -132,6 +77,7 @@
|
|
|
132
77
|
top-0
|
|
133
78
|
w-9;
|
|
134
79
|
|
|
80
|
+
fill: inherit;
|
|
135
81
|
transform: translate(0, 24px) rotate(90deg);
|
|
136
82
|
transition-property: opacity, outline, outline-offset, transform;
|
|
137
83
|
}
|
|
@@ -166,3 +112,4 @@
|
|
|
166
112
|
@import './css/mds-modal-animate-left.css';
|
|
167
113
|
@import './css/mds-modal-animate-right.css';
|
|
168
114
|
@import './css/mds-modal-animate-top.css';
|
|
115
|
+
|
|
@@ -12,23 +12,24 @@ import { ModalPositionType, ModalAnimationStateType } from './meta/types'
|
|
|
12
12
|
export class MdsModal {
|
|
13
13
|
|
|
14
14
|
private animationDeelay
|
|
15
|
-
private window
|
|
16
|
-
private top
|
|
17
|
-
private bottom
|
|
15
|
+
private window = false
|
|
16
|
+
private top = false
|
|
17
|
+
private bottom = false
|
|
18
18
|
private animationState: ModalAnimationStateType = 'intro'
|
|
19
19
|
private km = new KeyboardManager()
|
|
20
|
+
|
|
20
21
|
@State() stateOpened: boolean
|
|
21
22
|
@Element() host: HTMLMdsModalElement
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Specifies if the modal is opened or not
|
|
25
26
|
*/
|
|
26
|
-
@Prop({ reflect: true, mutable: true }) opened
|
|
27
|
+
@Prop({ reflect: true, mutable: true }) opened = false
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Specifies the animation position of the modal window
|
|
30
31
|
*/
|
|
31
|
-
@Prop({ reflect: true, mutable: true }) position?: ModalPositionType =
|
|
32
|
+
@Prop({ reflect: true, mutable: true }) position?: ModalPositionType = 'center'
|
|
32
33
|
|
|
33
34
|
componentWillLoad (): void {
|
|
34
35
|
this.bottom = this.host.querySelector('[slot="bottom"]') !== null
|
|
@@ -36,17 +37,12 @@ export class MdsModal {
|
|
|
36
37
|
this.window = this.host.querySelector('[slot="window"]') !== null
|
|
37
38
|
this.stateOpened = this.opened
|
|
38
39
|
|
|
39
|
-
if (this.window
|
|
40
|
-
this.position = 'center'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (this.position === null) {
|
|
40
|
+
if (!this.window) {
|
|
44
41
|
this.position = 'right'
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
if (this.window) {
|
|
48
|
-
|
|
49
|
-
modal.setAttribute('role', 'modal')
|
|
45
|
+
this.host.querySelector('[slot="window"]')?.setAttribute('role', 'modal')
|
|
50
46
|
}
|
|
51
47
|
}
|
|
52
48
|
|
|
@@ -66,7 +62,8 @@ export class MdsModal {
|
|
|
66
62
|
|
|
67
63
|
componentDidLoad = (): void => {
|
|
68
64
|
this.km.addElement(this.host, 'host')
|
|
69
|
-
this.
|
|
65
|
+
const close = this.host.shadowRoot?.querySelector('.close')
|
|
66
|
+
if (close) this.km.addElement(close as HTMLElement, 'close')
|
|
70
67
|
this.km.attachEscapeBehavior(() => this.closeEvent.emit())
|
|
71
68
|
this.km.attachClickBehavior('close')
|
|
72
69
|
}
|
|
@@ -76,14 +73,14 @@ export class MdsModal {
|
|
|
76
73
|
this.km.detachClickBehavior('close')
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
private animationName = (customState
|
|
80
|
-
return `
|
|
76
|
+
private animationName = (customState = '', customPosition = ''): string => {
|
|
77
|
+
return `to-${customPosition !== '' ? customPosition : this.position}${customState !== '' ? '-' + customState : ''}`
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
@Watch('position')
|
|
84
81
|
positionChange (_newValue: string, oldValue: string): void {
|
|
85
82
|
window.clearTimeout(this.animationDeelay)
|
|
86
|
-
this.host.classList.remove(this.animationName(
|
|
83
|
+
this.host.classList.remove(this.animationName('', oldValue))
|
|
87
84
|
this.host.classList.remove(this.animationName('intro', oldValue))
|
|
88
85
|
this.host.classList.remove(this.animationName('outro', oldValue))
|
|
89
86
|
}
|
|
@@ -99,7 +96,7 @@ export class MdsModal {
|
|
|
99
96
|
*/
|
|
100
97
|
@Event({ bubbles: true, composed: true, eventName: 'mdsModalClose' }) closeEvent: EventEmitter<void>
|
|
101
98
|
|
|
102
|
-
private closeModal = (e:Event
|
|
99
|
+
private closeModal = (e:Event): void => {
|
|
103
100
|
if ((e.target as HTMLElement)?.localName !== 'mds-modal') {
|
|
104
101
|
return
|
|
105
102
|
}
|
|
@@ -123,10 +120,8 @@ export class MdsModal {
|
|
|
123
120
|
return (
|
|
124
121
|
<Host aria-modal={clsx(this.opened ? 'true' : 'false' )} class={clsx(this.stateOpened && this.animationName('opened'))} onClick={(e: Event) => { this.closeModal(e) }}>
|
|
125
122
|
{ this.window
|
|
126
|
-
?
|
|
127
|
-
<
|
|
128
|
-
:
|
|
129
|
-
<div class={clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`)} role="dialog">
|
|
123
|
+
? <slot name="window"/>
|
|
124
|
+
: <div class={clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`)} role="dialog" part="window">
|
|
130
125
|
{ this.top &&
|
|
131
126
|
<slot name="top"/>
|
|
132
127
|
}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
## Properties
|
|
9
9
|
|
|
10
|
-
| Property | Attribute | Description | Type
|
|
11
|
-
| ---------- | ---------- | ---------------------------------------------------- |
|
|
12
|
-
| `opened` | `opened` | Specifies if the modal is opened or not | `boolean`
|
|
13
|
-
| `position` | `position` | Specifies the animation position of the modal window | `"bottom" \| "center" \| "left" \| "right" \| "top"` | `
|
|
10
|
+
| Property | Attribute | Description | Type | Default |
|
|
11
|
+
| ---------- | ---------- | ---------------------------------------------------- | ----------------------------------------------------------------- | ---------- |
|
|
12
|
+
| `opened` | `opened` | Specifies if the modal is opened or not | `boolean` | `false` |
|
|
13
|
+
| `position` | `position` | Specifies the animation position of the modal window | `"bottom" \| "center" \| "left" \| "right" \| "top" \| undefined` | `'center'` |
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
## Events
|
|
@@ -20,6 +20,13 @@
|
|
|
20
20
|
| `mdsModalClose` | Emits when a modal is closed | `CustomEvent<void>` |
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
## Shadow Parts
|
|
24
|
+
|
|
25
|
+
| Part | Description |
|
|
26
|
+
| ---------- | ----------- |
|
|
27
|
+
| `"window"` | |
|
|
28
|
+
|
|
29
|
+
|
|
23
30
|
## CSS Custom Properties
|
|
24
31
|
|
|
25
32
|
| Name | Description |
|