@maggioli-design-system/mds-modal 1.0.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.
Files changed (129) hide show
  1. package/dist/cjs/index-ced1b9b6.js +1236 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/mds-modal.cjs.entry.js +124 -0
  5. package/dist/cjs/mds-modal.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/mds-modal/mds-modal.css +215 -0
  8. package/dist/collection/components/mds-modal/mds-modal.js +153 -0
  9. package/dist/collection/components/mds-modal/meta/dictionary.js +6 -0
  10. package/dist/collection/components/mds-modal/meta/types.js +1 -0
  11. package/dist/collection/components/mds-modal/test/mds-modal.stories.js +68 -0
  12. package/dist/collection/dictionary/autocomplete.js +59 -0
  13. package/dist/collection/dictionary/button.js +26 -0
  14. package/dist/collection/dictionary/color.js +19 -0
  15. package/dist/collection/dictionary/icon.js +3 -0
  16. package/dist/collection/dictionary/input-text-type.js +13 -0
  17. package/dist/collection/dictionary/loading.js +5 -0
  18. package/dist/collection/dictionary/typography.js +37 -0
  19. package/dist/collection/dictionary/variant.js +64 -0
  20. package/dist/collection/fixtures/cities.js +110 -0
  21. package/dist/collection/interface/input-value.js +1 -0
  22. package/dist/collection/types/autocomplete.js +1 -0
  23. package/dist/collection/types/button.js +1 -0
  24. package/dist/collection/types/form-rel.js +1 -0
  25. package/dist/collection/types/input-text-type.js +1 -0
  26. package/dist/collection/types/input-value-type.js +1 -0
  27. package/dist/collection/types/loading.js +1 -0
  28. package/dist/collection/types/typography.js +1 -0
  29. package/dist/collection/types/variant.js +1 -0
  30. package/dist/custom-elements/index.d.ts +45 -0
  31. package/dist/custom-elements/index.js +136 -0
  32. package/dist/esm/index-7d5b7d79.js +1208 -0
  33. package/dist/esm/index.js +1 -0
  34. package/dist/esm/loader.js +17 -0
  35. package/dist/esm/mds-modal.entry.js +120 -0
  36. package/dist/esm/mds-modal.js +17 -0
  37. package/dist/esm/polyfills/core-js.js +11 -0
  38. package/dist/esm/polyfills/css-shim.js +1 -0
  39. package/dist/esm/polyfills/dom.js +79 -0
  40. package/dist/esm/polyfills/es5-html-element.js +1 -0
  41. package/dist/esm/polyfills/index.js +34 -0
  42. package/dist/esm/polyfills/system.js +6 -0
  43. package/dist/esm-es5/index-7d5b7d79.js +1 -0
  44. package/dist/esm-es5/index.js +0 -0
  45. package/dist/esm-es5/loader.js +1 -0
  46. package/dist/esm-es5/mds-modal.entry.js +1 -0
  47. package/dist/esm-es5/mds-modal.js +1 -0
  48. package/dist/index.cjs.js +1 -0
  49. package/dist/index.js +1 -0
  50. package/dist/mds-modal/index.esm.js +0 -0
  51. package/dist/mds-modal/mds-modal.esm.js +1 -0
  52. package/dist/mds-modal/mds-modal.js +130 -0
  53. package/dist/mds-modal/p-0fa95990.system.js +1 -0
  54. package/dist/mds-modal/p-50ea2036.system.js +1 -0
  55. package/dist/mds-modal/p-818ca69a.js +1 -0
  56. package/dist/mds-modal/p-c8003e96.system.js +1 -0
  57. package/dist/mds-modal/p-d10799a8.entry.js +1 -0
  58. package/dist/mds-modal/p-fda9967b.system.entry.js +1 -0
  59. package/dist/stats.json +510 -0
  60. package/dist/types/components/mds-modal/meta/dictionary.d.ts +2 -0
  61. package/dist/types/components/mds-modal/meta/types.d.ts +2 -0
  62. package/dist/types/components.d.ts +58 -0
  63. package/dist/types/dictionary/autocomplete.d.ts +2 -0
  64. package/dist/types/dictionary/button.d.ts +5 -0
  65. package/dist/types/dictionary/color.d.ts +3 -0
  66. package/dist/types/dictionary/icon.d.ts +2 -0
  67. package/dist/types/dictionary/input-text-type.d.ts +2 -0
  68. package/dist/types/dictionary/loading.d.ts +2 -0
  69. package/dist/types/dictionary/typography.d.ts +5 -0
  70. package/dist/types/dictionary/variant.d.ts +9 -0
  71. package/dist/types/fixtures/cities.d.ts +2 -0
  72. package/dist/types/interface/input-value.d.ts +4 -0
  73. package/dist/types/stencil-public-runtime.d.ts +1563 -0
  74. package/dist/types/types/autocomplete.d.ts +2 -0
  75. package/dist/types/types/button.d.ts +4 -0
  76. package/dist/types/types/form-rel.d.ts +1 -0
  77. package/dist/types/types/input-text-type.d.ts +1 -0
  78. package/dist/types/types/input-value-type.d.ts +1 -0
  79. package/dist/types/types/loading.d.ts +1 -0
  80. package/dist/types/types/typography.d.ts +4 -0
  81. package/dist/types/types/variant.d.ts +10 -0
  82. package/loader/cdn.js +3 -0
  83. package/loader/index.cjs.js +3 -0
  84. package/loader/index.d.ts +12 -0
  85. package/loader/index.es2017.js +3 -0
  86. package/loader/index.js +4 -0
  87. package/loader/package.json +10 -0
  88. package/package.json +49 -0
  89. package/readme.md +43 -0
  90. package/src/components/mds-modal/css/mds-modal-animate-center.css +28 -0
  91. package/src/components/mds-modal/css/mds-modal-animate-left.css +42 -0
  92. package/src/components/mds-modal/css/mds-modal-animate-right.css +42 -0
  93. package/src/components/mds-modal/mds-modal.css +127 -0
  94. package/src/components/mds-modal/mds-modal.tsx +114 -0
  95. package/src/components/mds-modal/meta/dictionary.ts +9 -0
  96. package/src/components/mds-modal/meta/types.ts +8 -0
  97. package/src/components/mds-modal/readme.md +25 -0
  98. package/src/components/mds-modal/test/mds-modal.e2e.ts +69 -0
  99. package/src/components/mds-modal/test/mds-modal.spec.tsx +19 -0
  100. package/src/components/mds-modal/test/mds-modal.stories.js +68 -0
  101. package/src/components.d.ts +58 -0
  102. package/src/dictionary/autocomplete.ts +62 -0
  103. package/src/dictionary/button.ts +35 -0
  104. package/src/dictionary/color.ts +24 -0
  105. package/src/dictionary/icon.ts +5 -0
  106. package/src/dictionary/input-text-type.ts +17 -0
  107. package/src/dictionary/loading.ts +9 -0
  108. package/src/dictionary/typography.ts +46 -0
  109. package/src/dictionary/variant.ts +81 -0
  110. package/src/fixtures/cities.ts +116 -0
  111. package/src/interface/input-value.ts +5 -0
  112. package/src/types/autocomplete.ts +69 -0
  113. package/src/types/button.ts +24 -0
  114. package/src/types/form-rel.ts +11 -0
  115. package/src/types/input-text-type.ts +11 -0
  116. package/src/types/input-value-type.ts +5 -0
  117. package/src/types/loading.ts +3 -0
  118. package/src/types/typography.ts +35 -0
  119. package/src/types/variant.ts +72 -0
  120. package/www/build/index.esm.js +0 -0
  121. package/www/build/mds-modal.esm.js +1 -0
  122. package/www/build/mds-modal.js +130 -0
  123. package/www/build/p-0fa95990.system.js +1 -0
  124. package/www/build/p-50ea2036.system.js +1 -0
  125. package/www/build/p-818ca69a.js +1 -0
  126. package/www/build/p-c8003e96.system.js +1 -0
  127. package/www/build/p-d10799a8.entry.js +1 -0
  128. package/www/build/p-fda9967b.system.entry.js +1 -0
  129. package/www/host.config.json +15 -0
@@ -0,0 +1,2 @@
1
+ export declare type AutocompleteType = 'additional-name' | 'address' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'cc-additional-name' | 'cc-csc' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-family-name' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-type' | 'country' | 'country-name' | 'current-password' | 'email' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'impp' | 'language' | 'name' | 'new-password' | 'nickname' | 'off' | 'on' | 'one-time-code' | 'organization' | 'organization-title' | 'photo' | 'postal-code' | 'sex' | 'street-address' | 'tel' | 'tel-area-code' | 'tel-country-code' | 'tel-extension' | 'tel-local' | 'tel-national' | 'transaction-amount' | 'transaction-currency' | 'url' | 'username';
2
+ export declare type InputTextType = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'textarea' | 'time' | 'url';
@@ -0,0 +1,4 @@
1
+ export declare type ButtonType = 'a' | 'button' | 'reset' | 'submit';
2
+ export declare type ButtonSizeType = 'sm' | 'md' | 'lg' | 'xl';
3
+ export declare type ButtonIconPositionType = 'left' | 'right';
4
+ export declare type ButtonVariantType = 'primary' | 'dark' | 'light' | 'error' | 'info' | 'success' | 'warning';
@@ -0,0 +1 @@
1
+ export declare type FormRelType = 'external' | 'help' | 'license' | 'next' | 'nofollow' | 'noopener' | 'noreferrer' | 'opener' | 'prev' | 'search';
@@ -0,0 +1 @@
1
+ export declare type InputTextType = 'date' | 'email' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'textarea' | 'time' | 'url';
@@ -0,0 +1 @@
1
+ export declare type InputValueType = null | number | string | undefined;
@@ -0,0 +1 @@
1
+ export declare type LoadingType = 'eager' | 'lazy';
@@ -0,0 +1,4 @@
1
+ export declare type TypographyType = 'action' | 'caption' | 'code' | 'detail' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'hack' | 'label' | 'option' | 'paragraph';
2
+ export declare type TypographyPrimaryType = 'action' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
3
+ export declare type TypographySecondaryType = 'caption' | 'detail' | 'label' | 'option' | 'paragraph';
4
+ export declare type TypographyMonoType = 'code' | 'hack';
@@ -0,0 +1,10 @@
1
+ export declare type ThemeStatusVariantType = 'error' | 'info' | 'success' | 'warning';
2
+ export declare type ThemeVariantType = 'dark' | 'light' | 'error' | 'info' | 'success' | 'warning';
3
+ export declare type ThemeFullVariantType = 'amaranth' | 'aqua' | 'blue' | 'dark' | 'error' | 'green' | 'info' | 'light' | 'lime' | 'orange' | 'orchid' | 'sky' | 'success' | 'violet' | 'warning' | 'yellow';
4
+ export declare type ThemeLuminanceVariantType = 'dark' | 'light';
5
+ export declare type LabelVariantType = 'amaranth' | 'aqua' | 'blue' | 'green' | 'lime' | 'orange' | 'orchid' | 'sky' | 'violet' | 'yellow';
6
+ export declare type ActionVariantType = 'primary' | 'dark' | 'light';
7
+ export declare type StateVariantType = 'disabled' | 'focused' | 'readonly';
8
+ export declare type ToneVariantType = 'strong' | 'weak' | 'ghost' | 'quiet';
9
+ export declare type ToneSimpleVariantType = 'strong' | 'weak' | 'quiet';
10
+ export declare type ToneMinimalVariantType = 'strong' | 'weak';
package/loader/cdn.js ADDED
@@ -0,0 +1,3 @@
1
+
2
+ module.exports = require('../dist/cjs/loader.cjs.js');
3
+ module.exports.applyPolyfills = function() { return Promise.resolve() };
@@ -0,0 +1,3 @@
1
+
2
+ module.exports = require('../dist/cjs/loader.cjs.js');
3
+ module.exports.applyPolyfills = function() { return Promise.resolve() };
@@ -0,0 +1,12 @@
1
+ export * from '../dist/types/components';
2
+ export interface CustomElementsDefineOptions {
3
+ exclude?: string[];
4
+ resourcesUrl?: string;
5
+ syncQueue?: boolean;
6
+ jmp?: (c: Function) => any;
7
+ raf?: (c: FrameRequestCallback) => number;
8
+ ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
9
+ rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
10
+ }
11
+ export declare function defineCustomElements(win?: Window, opts?: CustomElementsDefineOptions): Promise<void>;
12
+ export declare function applyPolyfills(): Promise<void>;
@@ -0,0 +1,3 @@
1
+
2
+ export * from '../dist/esm/polyfills/index.js';
3
+ export * from '../dist/esm/loader.js';
@@ -0,0 +1,4 @@
1
+
2
+ (function(){if("undefined"!==typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var a=HTMLElement;window.HTMLElement=function(){return Reflect.construct(a,[],this.constructor)};HTMLElement.prototype=a.prototype;HTMLElement.prototype.constructor=HTMLElement;Object.setPrototypeOf(HTMLElement,a)}})();
3
+ export * from '../dist/esm/polyfills/index.js';
4
+ export * from '../dist/esm-es5/loader.js';
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "mds-modal-loader",
3
+ "typings": "./index.d.ts",
4
+ "module": "./index.js",
5
+ "main": "./index.cjs.js",
6
+ "jsnext:main": "./index.es2017.js",
7
+ "es2015": "./index.es2017.js",
8
+ "es2017": "./index.es2017.js",
9
+ "unpkg": "./cdn.js"
10
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@maggioli-design-system/mds-modal",
3
+ "version": "1.0.0",
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
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/custom-elements/index.js",
7
+ "es2015": "dist/esm/index.mjs",
8
+ "es2017": "dist/esm/index.mjs",
9
+ "types": "dist/custom-elements/index.d.ts",
10
+ "collection": "dist/collection/collection-manifest.json",
11
+ "collection:main": "dist/collection/index.js",
12
+ "unpkg": "dist/mds-modal/mds-modal.esm.js",
13
+ "files": [
14
+ "dist/",
15
+ "loader/",
16
+ "readme.md",
17
+ "src/",
18
+ "www/"
19
+ ],
20
+ "scripts": {
21
+ "build": "stencil build --docs-readme"
22
+ },
23
+ "dependencies": {
24
+ "@maggioli-design-system/design-tokens": "^5.0.5",
25
+ "@maggioli-design-system/icons": "^1.29.0",
26
+ "@maggioli-design-system/identity": "^1.8.3",
27
+ "@maggioli-design-system/styles": "^4.0.2",
28
+ "@stencil/core": "^2.10.0",
29
+ "tailwindcss": "^2.2.19"
30
+ },
31
+ "license": "MIT",
32
+ "author": {
33
+ "name": "Vittorio Vittori",
34
+ "email": "vittorio.vittori@maggioli.it",
35
+ "url": "http://vit.to"
36
+ },
37
+ "contributors": [
38
+ {
39
+ "name": "Andrea Pruccoli",
40
+ "email": "andrea.pruccoli@maggioli.it",
41
+ "role": "Software Engineer"
42
+ },
43
+ {
44
+ "name": "Vittorio Vittori",
45
+ "email": "vittorio.vittori@maggioli.it",
46
+ "role": "UX UI Designer"
47
+ }
48
+ ]
49
+ }
package/readme.md ADDED
@@ -0,0 +1,43 @@
1
+ # mds-modal
2
+
3
+
4
+
5
+ <!-- Auto Generated Below -->
6
+
7
+
8
+ ## Properties
9
+
10
+ | Property | Attribute | Description | Type | Default |
11
+ | ---------- | ---------- | ---------------------------------------------------- | ------------------------------- | ----------- |
12
+ | `opened` | `opened` | Specifies if the modal is opened or not | `boolean` | `undefined` |
13
+ | `position` | `position` | Specifies the animation position of the modal window | `"center" \| "left" \| "right"` | `null` |
14
+
15
+
16
+ ## Events
17
+
18
+ | Event | Description | Type |
19
+ | ------- | ---------------------------- | ------------------- |
20
+ | `close` | Emits when a modal is closed | `CustomEvent<void>` |
21
+
22
+
23
+ ## Dependencies
24
+
25
+ ### Used by
26
+
27
+ - [mds-header](../mds-header)
28
+
29
+ ### Depends on
30
+
31
+ - [mds-icon](../mds-icon)
32
+
33
+ ### Graph
34
+ ```mermaid
35
+ graph TD;
36
+ mds-modal --> mds-icon
37
+ mds-header --> mds-modal
38
+ style mds-modal fill:#f9f,stroke:#333,stroke-width:4px
39
+ ```
40
+
41
+ ----------------------------------------------
42
+
43
+ Built with love @ **Maggioli Informatica / R&D Department**
@@ -0,0 +1,28 @@
1
+ :host ( .animate-center ) {
2
+ @apply
3
+ justify-center
4
+ mobile:p-4
5
+ p-8;
6
+ }
7
+
8
+ :host ( .animate-center ) .window,
9
+ :host ( .animate-center ) > ::slotted ( [slot=window] ) {
10
+ @apply animate-center;
11
+ }
12
+
13
+ :host ( .animate-center-intro ) .window,
14
+ :host ( .animate-center-intro ) > ::slotted ( [slot=window] ) {
15
+ @apply animate-center-intro;
16
+ }
17
+
18
+ :host ( .animate-center-opened.animate-center-outro ) .window,
19
+ :host ( .animate-center-opened.animate-center-outro ) > ::slotted ( [slot=window] ),
20
+ :host ( .animate-center-opened ) .window,
21
+ :host ( .animate-center-opened ) > ::slotted ( [slot=window] ) {
22
+ @apply animate-center-opened;
23
+ }
24
+
25
+ :host ( .animate-center-outro ) .window,
26
+ :host ( .animate-center-outro ) > ::slotted ( [slot=window] ) {
27
+ @apply animate-center-outro;
28
+ }
@@ -0,0 +1,42 @@
1
+ :host ( .animate-left ) {
2
+ @apply justify-start;
3
+ }
4
+
5
+ :host ( .animate-left ) .window,
6
+ :host ( .animate-left ) > ::slotted ( [slot=window] ) {
7
+ @apply animate-left;
8
+ }
9
+
10
+ :host ( .animate-left-intro ) .window,
11
+ :host ( .animate-left-intro ) > ::slotted ( [slot=window] ) {
12
+ @apply animate-left-intro;
13
+ }
14
+
15
+ :host ( .animate-left-opened.animate-left-outro ) .window,
16
+ :host ( .animate-left-opened.animate-left-outro ) > ::slotted ( [slot=window] ),
17
+ :host ( .animate-left-opened ) .window,
18
+ :host ( .animate-left-opened ) > ::slotted ( [slot=window] ) {
19
+ @apply animate-left-opened;
20
+ }
21
+
22
+ :host ( .animate-left-opened ) .close,
23
+ :host ( .animate-left-opened.animate-left-outro ) .close {
24
+ @apply opacity-100;
25
+
26
+ transform: translate(-24px, 24px) rotate(0);
27
+ }
28
+
29
+ :host ( .animate-left-outro ) .window,
30
+ :host ( .animate-left-outro ) > ::slotted ( [slot=window] ) {
31
+ @apply animate-left-outro;
32
+ }
33
+
34
+ :host ( .animate-left-outro ) .close {
35
+ transform: translate(24px, 24px) rotate(-90deg);
36
+ }
37
+
38
+ :host ( .animate-left ) .close {
39
+ @apply right-0;
40
+
41
+ transform: translate(36px, 24px) rotate(90deg);
42
+ }
@@ -0,0 +1,42 @@
1
+ :host ( .animate-right ) {
2
+ @apply justify-end;
3
+ }
4
+
5
+ :host ( .animate-right ) .window,
6
+ :host ( .animate-right ) > ::slotted ( [slot=window] ) {
7
+ @apply animate-right;
8
+ }
9
+
10
+ :host ( .animate-right-intro ) .window,
11
+ :host ( .animate-right-intro ) > ::slotted ( [slot=window] ) {
12
+ @apply animate-right-intro;
13
+ }
14
+
15
+ :host ( .animate-right-opened.animate-right-outro ) .window,
16
+ :host ( .animate-right-opened.animate-right-outro ) > ::slotted ( [slot=window] ),
17
+ :host ( .animate-right-opened ) .window,
18
+ :host ( .animate-right-opened ) > ::slotted ( [slot=window] ) {
19
+ @apply animate-right-opened;
20
+ }
21
+
22
+ :host ( .animate-right-opened ) .close,
23
+ :host ( .animate-right-opened.animate-right-outro ) .close {
24
+ @apply opacity-100;
25
+
26
+ transform: translate(24px, 24px) rotate(0);
27
+ }
28
+
29
+ :host ( .animate-right-outro ) .window,
30
+ :host ( .animate-right-outro ) > ::slotted ( [slot=window] ) {
31
+ @apply animate-right-outro;
32
+ }
33
+
34
+ :host ( .animate-right-outro ) .close {
35
+ transform: translate(-24px, 24px) rotate(90deg);
36
+ }
37
+
38
+ :host ( .animate-right ) .close {
39
+ @apply left-0;
40
+
41
+ transform: translate(-36px, 24px) rotate(-90deg);
42
+ }
@@ -0,0 +1,127 @@
1
+ @tailwind components;
2
+ @tailwind utilities;
3
+
4
+ @layer components {
5
+ .animate-center {
6
+ @apply
7
+ duration-500
8
+ ease-in-out-expo
9
+ opacity-0
10
+ transition-cosmetic;
11
+ }
12
+
13
+ .animate-center-intro {
14
+ transform: rotateX(-22deg) scale(0.5) translateY(40%);
15
+ }
16
+
17
+ .animate-center-opened {
18
+ @apply opacity-100;
19
+
20
+ transform: rotateX(0) scale(1) translateY(0);
21
+ }
22
+
23
+ .animate-center-outro {
24
+ transform: rotateX(-22deg) scale(0.5) translateY(-40%);
25
+ }
26
+
27
+ .animate-left,
28
+ .animate-right {
29
+ @apply
30
+ duration-500
31
+ opacity-0
32
+ ease-in-out-expo
33
+ transition-cosmetic;
34
+ }
35
+
36
+ .animate-right-intro,
37
+ .animate-right-outro {
38
+ transform: translateX(calc(100% + 50px));
39
+ }
40
+
41
+ .animate-right-opened,
42
+ .animate-left-opened {
43
+ @apply opacity-100;
44
+
45
+ transform: translateX(0);
46
+ }
47
+
48
+ .animate-left-intro,
49
+ .animate-left-outro {
50
+ transform: translateX(calc(-100% - 50px));
51
+ }
52
+ }
53
+
54
+ :host {
55
+ @apply
56
+ bg-adjust-tone-01
57
+ bg-opacity-0
58
+ duration-700
59
+ ease-in-out-expo
60
+ fixed
61
+ flex
62
+ inset-0
63
+ items-center
64
+ justify-center
65
+ pointer-events-none;
66
+
67
+ perspective: 600px;
68
+ }
69
+
70
+ :host ( .animate-center-opened ),
71
+ :host ( .animate-left-opened ),
72
+ :host ( .animate-right-opened ) {
73
+ @apply
74
+ bg-opacity-50
75
+ duration-500
76
+ pointer-events-auto;
77
+ }
78
+
79
+ .close {
80
+ @apply
81
+ absolute
82
+ cursor-pointer
83
+ duration-500
84
+ ease-in-out-quart
85
+ h-9
86
+ opacity-0
87
+ origin-center
88
+ text-4xl
89
+ text-adjust-tone-10
90
+ text-shadow
91
+ top-0
92
+ transition-cosmetic
93
+ w-9;
94
+
95
+ transform: translate(0, 24px) rotate(90deg);
96
+ }
97
+
98
+ .window {
99
+ @apply
100
+ gap-0
101
+ grid
102
+ h-full
103
+ overflow-auto;
104
+
105
+ background-color: var(--window-background, theme('colors.adjust-tone'));
106
+ box-shadow: var(--window-shadow, theme('boxShadow.2xl'));
107
+ grid-template-rows: 1fr;
108
+
109
+ /* grid-template-rows: var(--grid-template-rows, auto 1fr auto); */
110
+ max-width: calc(100vw - 80px);
111
+ }
112
+
113
+ .window--top {
114
+ grid-template-rows: auto 1fr;
115
+ }
116
+
117
+ .window--bottom {
118
+ grid-template-rows: 1fr auto;
119
+ }
120
+
121
+ .window--top-bottom {
122
+ grid-template-rows: auto 1fr auto;
123
+ }
124
+
125
+ @import './css/mds-modal-animate-center.css';
126
+ @import './css/mds-modal-animate-right.css';
127
+ @import './css/mds-modal-animate-left.css';
@@ -0,0 +1,114 @@
1
+ import { Component, Element, Event, EventEmitter, Host, h, Listen, Prop, Watch } from '@stencil/core'
2
+ import clsx from 'clsx'
3
+ import { ModalPositionType, ModalAnimationStateType } from './meta/types'
4
+ @Component({
5
+ tag: 'mds-modal',
6
+ styleUrl: 'mds-modal.css',
7
+ shadow: true,
8
+ })
9
+ export class MdsModal {
10
+
11
+ private animationDeelay
12
+ private window: boolean = null
13
+ private top: boolean = null
14
+ private bottom: boolean = null
15
+ private animationState: ModalAnimationStateType = 'intro'
16
+ @Element() hostElement: HTMLMdsModalElement
17
+
18
+ /**
19
+ * Specifies if the modal is opened or not
20
+ */
21
+ @Prop({ reflect: true, mutable: true }) opened?: boolean
22
+
23
+ /**
24
+ * Specifies the animation position of the modal window
25
+ */
26
+ @Prop({ reflect: true, mutable: true }) position?: ModalPositionType = null
27
+
28
+ componentWillLoad (): void {
29
+ this.bottom = this.hostElement.querySelector('[slot="bottom"]') !== null
30
+ this.top = this.hostElement.querySelector('[slot="top"]') !== null
31
+ this.window = this.hostElement.querySelector('[slot="window"]') !== null
32
+
33
+ if (this.window && this.position === null) {
34
+ this.position = 'center'
35
+ }
36
+
37
+ if (this.position === null) {
38
+ this.position = 'right'
39
+ }
40
+ }
41
+
42
+ componentWillRender (): void {
43
+ this.animationState = this.opened ? 'intro' : 'outro'
44
+ this.hostElement.classList.add(this.animationName())
45
+ }
46
+
47
+ componentDidRender (): void {
48
+ this.animationDeelay = window.setTimeout(() => {
49
+ this.animationState = this.animationState === 'intro' ? 'outro' : 'intro'
50
+ this.hostElement.classList.remove(this.animationName(this.animationState === 'intro' ? 'outro' : 'intro'))
51
+ this.hostElement.classList.add(this.animationName(this.animationState))
52
+ window.clearTimeout(this.animationDeelay)
53
+ }, 500)
54
+ }
55
+
56
+ private animationName = (customState: string = null, customPosition: string = null): string => {
57
+ return `animate-${customPosition !== null ? customPosition : this.position}${customState !== null ? '-' + customState : ''}`
58
+ }
59
+
60
+ @Watch('position')
61
+ positionChange (newValue: string, oldValue: string): void {
62
+ window.clearTimeout(this.animationDeelay)
63
+ this.hostElement.classList.remove(this.animationName(null, oldValue))
64
+ this.hostElement.classList.remove(this.animationName('intro', oldValue))
65
+ this.hostElement.classList.remove(this.animationName('outro', oldValue))
66
+ }
67
+
68
+ @Watch('opened')
69
+ openedChange (): void {
70
+ window.clearTimeout(this.animationDeelay)
71
+ }
72
+
73
+ /**
74
+ * Emits when a modal is closed
75
+ */
76
+ @Event() close: EventEmitter<void>
77
+
78
+ private closeModal = (e:Event = null): void => {
79
+ this.opened = e.target !== e.currentTarget
80
+ if (!this.opened) {
81
+ this.close.emit()
82
+ }
83
+ }
84
+
85
+ @Listen('close')
86
+ onCloseListener (): void {
87
+ this.opened = false
88
+ }
89
+
90
+ render () {
91
+ return (
92
+ <Host class={clsx(
93
+ this.opened && this.animationName('opened'),
94
+ )} onClick={(e: Event) => { this.closeModal(e) }}>
95
+ { this.window
96
+ ?
97
+ <slot name="window"/>
98
+ :
99
+ <div class={clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`)}>
100
+ { this.top &&
101
+ <slot name="top"/>
102
+ }
103
+ <slot/>
104
+ { this.bottom &&
105
+ <slot name="bottom"/>
106
+ }
107
+ </div>
108
+ }
109
+ { !this.window && <mds-icon name="close" class="close"/> }
110
+ </Host>
111
+ )
112
+ }
113
+
114
+ }
@@ -0,0 +1,9 @@
1
+ const modalPositionDictionary = [
2
+ 'center',
3
+ 'left',
4
+ 'right',
5
+ ]
6
+
7
+ export {
8
+ modalPositionDictionary,
9
+ }
@@ -0,0 +1,8 @@
1
+ export type ModalPositionType =
2
+ | 'center'
3
+ | 'left'
4
+ | 'right'
5
+
6
+ export type ModalAnimationStateType =
7
+ | 'intro'
8
+ | 'outro'
@@ -0,0 +1,25 @@
1
+ # mds-modal
2
+
3
+
4
+
5
+ <!-- Auto Generated Below -->
6
+
7
+
8
+ ## Properties
9
+
10
+ | Property | Attribute | Description | Type | Default |
11
+ | ---------- | ---------- | ---------------------------------------------------- | ------------------------------- | ----------- |
12
+ | `opened` | `opened` | Specifies if the modal is opened or not | `boolean` | `undefined` |
13
+ | `position` | `position` | Specifies the animation position of the modal window | `"center" \| "left" \| "right"` | `null` |
14
+
15
+
16
+ ## Events
17
+
18
+ | Event | Description | Type |
19
+ | ------- | ---------------------------- | ------------------- |
20
+ | `close` | Emits when a modal is closed | `CustomEvent<void>` |
21
+
22
+
23
+ ----------------------------------------------
24
+
25
+ Built with love @ **Maggioli Informatica / R&D Department**
@@ -0,0 +1,69 @@
1
+ import { newE2EPage } from '@stencil/core/testing'
2
+
3
+ describe('mds-modal', () => {
4
+ it('renders', async () => {
5
+ const page = await newE2EPage()
6
+ await page.setContent('<mds-modal></mds-modal>')
7
+
8
+ const element = await page.find('mds-modal')
9
+
10
+ // La riga seguente non è valida perché `animate-right-intro` viene impostato in `componentDidRender`
11
+ // e quindi appena instanziato non è presente come classe
12
+ // expect(element).toHaveClasses(['animate-right', 'hydrated', 'animate-right-intro'])
13
+ expect(element).toHaveClasses(['animate-right', 'hydrated'])
14
+
15
+ expect(element).toHaveAttribute('position')
16
+
17
+ expect(element.getAttribute('position')).toBe('right')
18
+
19
+ expect(element).not.toHaveAttribute('opened')
20
+
21
+ expect(element.shadowRoot).toEqualHtml(`
22
+ <div class="window">
23
+ <slot></slot>
24
+ </div>
25
+ <mds-icon class="close hydrated"></mds-icon>
26
+ `)
27
+ })
28
+
29
+ it('renders opened', async () => {
30
+ const page = await newE2EPage()
31
+ await page.setContent('<mds-modal opened="true"></mds-modal>')
32
+
33
+ const element = await page.find('mds-modal')
34
+
35
+ expect(element.getAttribute('opened')).not.toBe('false')
36
+
37
+ expect(element.shadowRoot).toEqualHtml(`
38
+ <div class="window">
39
+ <slot></slot>
40
+ </div>
41
+ <mds-icon class="close hydrated"></mds-icon>
42
+ `)
43
+ })
44
+
45
+ it('can be closed', async () => {
46
+ const page = await newE2EPage()
47
+ await page.setContent('<mds-modal opened="true"></mds-modal>')
48
+
49
+ const element = await page.find('mds-modal')
50
+
51
+ expect(element.getAttribute('opened')).not.toBe('false')
52
+
53
+ await page.mouse.click(window.innerWidth / 2, window.innerHeight / 2)
54
+
55
+ // const mdsIcon = element.shadowRoot.querySelector('mds-icon') as HTMLElement
56
+
57
+ // console.info('mdsIcon', mdsIcon)
58
+
59
+ // const closeButton = mdsIcon.shadowRoot.querySelector('i') as HTMLElement
60
+
61
+ // console.info('closeButton', closeButton)
62
+
63
+ // closeButton.click()
64
+
65
+ await page.waitForChanges()
66
+
67
+ expect(element).not.toHaveAttribute('opened')
68
+ })
69
+ })
@@ -0,0 +1,19 @@
1
+ import { newSpecPage } from '@stencil/core/testing'
2
+ import { MdsModal } from '../mds-modal'
3
+
4
+ describe('mds-modal', () => {
5
+ it('renders', async () => {
6
+ const page = await newSpecPage({
7
+ components: [MdsModal],
8
+ html: '<mds-modal></mds-modal>',
9
+ })
10
+ // expect(page.root).toEqualHtml(`
11
+ // <mds-modal>
12
+ // <mock:shadow-root>
13
+ // <slot></slot>
14
+ // </mock:shadow-root>
15
+ // </mds-modal>
16
+ // `)
17
+ expect(true).toBe(true)
18
+ })
19
+ })