@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
+ 'use strict';
2
+
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ced1b9b6.js');
6
+
7
+ /*
8
+ Stencil Client Patch Esm v2.10.0 | MIT Licensed | https://stenciljs.com
9
+ */
10
+ const patchEsm = () => {
11
+ return index.promiseResolve();
12
+ };
13
+
14
+ const defineCustomElements = (win, options) => {
15
+ if (typeof window === 'undefined') return Promise.resolve();
16
+ return patchEsm().then(() => {
17
+ return index.bootstrapLazy([["mds-modal.cjs",[[1,"mds-modal",{"opened":[1540],"position":[1537]},[[0,"close","onCloseListener"]]]]]], options);
18
+ });
19
+ };
20
+
21
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,124 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-ced1b9b6.js');
6
+
7
+ function toVal(mix) {
8
+ var k, y, str='';
9
+
10
+ if (typeof mix === 'string' || typeof mix === 'number') {
11
+ str += mix;
12
+ } else if (typeof mix === 'object') {
13
+ if (Array.isArray(mix)) {
14
+ for (k=0; k < mix.length; k++) {
15
+ if (mix[k]) {
16
+ if (y = toVal(mix[k])) {
17
+ str && (str += ' ');
18
+ str += y;
19
+ }
20
+ }
21
+ }
22
+ } else {
23
+ for (k in mix) {
24
+ if (mix[k]) {
25
+ str && (str += ' ');
26
+ str += k;
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ return str;
33
+ }
34
+
35
+ function clsx () {
36
+ var i=0, tmp, x, str='';
37
+ while (i < arguments.length) {
38
+ if (tmp = arguments[i++]) {
39
+ if (x = toVal(tmp)) {
40
+ str && (str += ' ');
41
+ str += x;
42
+ }
43
+ }
44
+ }
45
+ return str;
46
+ }
47
+
48
+ const mdsModalCss = ".animate-left,.animate-right{opacity:0;-webkit-transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width, -webkit-box-shadow, -webkit-transform;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-duration:500ms;transition-duration:500ms;-webkit-transition-timing-function:cubic-bezier(1, 0, 0, 1);transition-timing-function:cubic-bezier(1, 0, 0, 1)}.animate-right-intro,.animate-right-outro{-webkit-transform:translateX(calc(100% + 50px));transform:translateX(calc(100% + 50px))}.border{border-width:1px}.shadow{--tw-shadow:0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);-webkit-box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host{pointer-events:none;position:fixed;top:0px;right:0px;bottom:0px;left:0px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;--tw-bg-opacity:1;background-color:rgba(var(--adjust-tone-01), var(--tw-bg-opacity));--tw-bg-opacity:0;-webkit-transition-duration:700ms;transition-duration:700ms;-webkit-transition-timing-function:cubic-bezier(1, 0, 0, 1);transition-timing-function:cubic-bezier(1, 0, 0, 1);-webkit-perspective:600px;perspective:600px}:host(.animate-center-opened),:host(.animate-left-opened),:host(.animate-right-opened){pointer-events:auto;--tw-bg-opacity:0.5;-webkit-transition-duration:500ms;transition-duration:500ms}.close{position:absolute;top:0px;height:2.25rem;width:2.25rem;-webkit-transform-origin:center;transform-origin:center;cursor:pointer;font-size:2.25rem;line-height:2.5rem;--tw-text-opacity:1;color:rgba(var(--adjust-tone-10), var(--tw-text-opacity));opacity:0;-webkit-transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width, -webkit-box-shadow, -webkit-transform;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-duration:500ms;transition-duration:500ms;-webkit-transition-timing-function:cubic-bezier(0.77, 0, 0.175, 1);transition-timing-function:cubic-bezier(0.77, 0, 0.175, 1);text-shadow:0px 0px 1px rgb(0 0 0 / 20%), 0px 0px 1px rgb(1 0 5 / 10%);-webkit-transform:translate(0, 24px) rotate(90deg);transform:translate(0, 24px) rotate(90deg)}.window{display:grid;height:100%;gap:0px;overflow:auto;background-color:var(--window-background, rgb(var(--adjust-tone)));-webkit-box-shadow:var(--window-shadow, 0 25px 50px -12px rgba(0, 0, 0, 0.25));box-shadow:var(--window-shadow, 0 25px 50px -12px rgba(0, 0, 0, 0.25));grid-template-rows:1fr;max-width:calc(100vw - 80px)}.window--top{grid-template-rows:auto 1fr}.window--bottom{grid-template-rows:1fr auto}.window--top-bottom{grid-template-rows:auto 1fr auto}:host(.animate-center){-ms-flex-pack:center;justify-content:center;padding:2rem}@media (max-width: 767px){:host(.animate-center){padding:1rem}}:host(.animate-center) .window,:host(.animate-center)>::slotted([slot=window]){opacity:0;-webkit-transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width, -webkit-box-shadow, -webkit-transform;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-duration:500ms;transition-duration:500ms;-webkit-transition-timing-function:cubic-bezier(1, 0, 0, 1);transition-timing-function:cubic-bezier(1, 0, 0, 1)}:host(.animate-center-intro) .window,:host(.animate-center-intro)>::slotted([slot=window]){-webkit-transform:rotateX(-22deg) scale(0.5) translateY(40%);transform:rotateX(-22deg) scale(0.5) translateY(40%)}:host(.animate-center-opened.animate-center-outro) .window,:host(.animate-center-opened.animate-center-outro)>::slotted([slot=window]),:host(.animate-center-opened) .window,:host(.animate-center-opened)>::slotted([slot=window]){-webkit-transform:rotateX(0) scale(1) translateY(0);transform:rotateX(0) scale(1) translateY(0);opacity:1}:host(.animate-center-outro) .window,:host(.animate-center-outro)>::slotted([slot=window]){-webkit-transform:rotateX(-22deg) scale(0.5) translateY(-40%);transform:rotateX(-22deg) scale(0.5) translateY(-40%)}:host(.animate-right){-ms-flex-pack:end;justify-content:flex-end}:host(.animate-right) .window,:host(.animate-right)>::slotted([slot=window]){opacity:0;-webkit-transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width, -webkit-box-shadow, -webkit-transform;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-duration:500ms;transition-duration:500ms;-webkit-transition-timing-function:cubic-bezier(1, 0, 0, 1);transition-timing-function:cubic-bezier(1, 0, 0, 1)}:host(.animate-right-intro) .window,:host(.animate-right-intro)>::slotted([slot=window]){-webkit-transform:translateX(calc(100% + 50px));transform:translateX(calc(100% + 50px))}:host(.animate-right-opened.animate-right-outro) .window,:host(.animate-right-opened.animate-right-outro)>::slotted([slot=window]),:host(.animate-right-opened) .window,:host(.animate-right-opened)>::slotted([slot=window]){-webkit-transform:translateX(0);transform:translateX(0);opacity:1}:host(.animate-right-opened) .close,:host(.animate-right-opened.animate-right-outro) .close{opacity:1;-webkit-transform:translate(24px, 24px) rotate(0);transform:translate(24px, 24px) rotate(0)}:host(.animate-right-outro) .window,:host(.animate-right-outro)>::slotted([slot=window]){-webkit-transform:translateX(calc(100% + 50px));transform:translateX(calc(100% + 50px))}:host(.animate-right-outro) .close{-webkit-transform:translate(-24px, 24px) rotate(90deg);transform:translate(-24px, 24px) rotate(90deg)}:host(.animate-right) .close{left:0px;-webkit-transform:translate(-36px, 24px) rotate(-90deg);transform:translate(-36px, 24px) rotate(-90deg)}:host(.animate-left){-ms-flex-pack:start;justify-content:flex-start}:host(.animate-left) .window,:host(.animate-left)>::slotted([slot=window]){opacity:0;-webkit-transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, color, height, margin, opacity, padding, width, -webkit-box-shadow, -webkit-transform;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;transition-property:background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width, -webkit-box-shadow, -webkit-transform;-webkit-transition-duration:150ms;transition-duration:150ms;-webkit-transition-duration:500ms;transition-duration:500ms;-webkit-transition-timing-function:cubic-bezier(1, 0, 0, 1);transition-timing-function:cubic-bezier(1, 0, 0, 1)}:host(.animate-left-intro) .window,:host(.animate-left-intro)>::slotted([slot=window]){-webkit-transform:translateX(calc(-100% - 50px));transform:translateX(calc(-100% - 50px))}:host(.animate-left-opened.animate-left-outro) .window,:host(.animate-left-opened.animate-left-outro)>::slotted([slot=window]),:host(.animate-left-opened) .window,:host(.animate-left-opened)>::slotted([slot=window]){-webkit-transform:translateX(0);transform:translateX(0);opacity:1}:host(.animate-left-opened) .close,:host(.animate-left-opened.animate-left-outro) .close{opacity:1;-webkit-transform:translate(-24px, 24px) rotate(0);transform:translate(-24px, 24px) rotate(0)}:host(.animate-left-outro) .window,:host(.animate-left-outro)>::slotted([slot=window]){-webkit-transform:translateX(calc(-100% - 50px));transform:translateX(calc(-100% - 50px))}:host(.animate-left-outro) .close{-webkit-transform:translate(24px, 24px) rotate(-90deg);transform:translate(24px, 24px) rotate(-90deg)}:host(.animate-left) .close{right:0px;-webkit-transform:translate(36px, 24px) rotate(90deg);transform:translate(36px, 24px) rotate(90deg)}";
49
+
50
+ let MdsModal = class {
51
+ constructor(hostRef) {
52
+ index.registerInstance(this, hostRef);
53
+ this.close = index.createEvent(this, "close", 7);
54
+ this.window = null;
55
+ this.top = null;
56
+ this.bottom = null;
57
+ this.animationState = 'intro';
58
+ /**
59
+ * Specifies the animation position of the modal window
60
+ */
61
+ this.position = null;
62
+ this.animationName = (customState = null, customPosition = null) => {
63
+ return `animate-${customPosition !== null ? customPosition : this.position}${customState !== null ? '-' + customState : ''}`;
64
+ };
65
+ this.closeModal = (e = null) => {
66
+ this.opened = e.target !== e.currentTarget;
67
+ if (!this.opened) {
68
+ this.close.emit();
69
+ }
70
+ };
71
+ }
72
+ componentWillLoad() {
73
+ this.bottom = this.hostElement.querySelector('[slot="bottom"]') !== null;
74
+ this.top = this.hostElement.querySelector('[slot="top"]') !== null;
75
+ this.window = this.hostElement.querySelector('[slot="window"]') !== null;
76
+ if (this.window && this.position === null) {
77
+ this.position = 'center';
78
+ }
79
+ if (this.position === null) {
80
+ this.position = 'right';
81
+ }
82
+ }
83
+ componentWillRender() {
84
+ this.animationState = this.opened ? 'intro' : 'outro';
85
+ this.hostElement.classList.add(this.animationName());
86
+ }
87
+ componentDidRender() {
88
+ this.animationDeelay = window.setTimeout(() => {
89
+ this.animationState = this.animationState === 'intro' ? 'outro' : 'intro';
90
+ this.hostElement.classList.remove(this.animationName(this.animationState === 'intro' ? 'outro' : 'intro'));
91
+ this.hostElement.classList.add(this.animationName(this.animationState));
92
+ window.clearTimeout(this.animationDeelay);
93
+ }, 500);
94
+ }
95
+ positionChange(newValue, oldValue) {
96
+ window.clearTimeout(this.animationDeelay);
97
+ this.hostElement.classList.remove(this.animationName(null, oldValue));
98
+ this.hostElement.classList.remove(this.animationName('intro', oldValue));
99
+ this.hostElement.classList.remove(this.animationName('outro', oldValue));
100
+ }
101
+ openedChange() {
102
+ window.clearTimeout(this.animationDeelay);
103
+ }
104
+ onCloseListener() {
105
+ this.opened = false;
106
+ }
107
+ render() {
108
+ return (index.h(index.Host, { class: clsx(this.opened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } }, this.window
109
+ ?
110
+ index.h("slot", { name: "window" })
111
+ :
112
+ index.h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`) }, this.top &&
113
+ index.h("slot", { name: "top" }), index.h("slot", null), this.bottom &&
114
+ index.h("slot", { name: "bottom" })), !this.window && index.h("mds-icon", { name: "close", class: "close" })));
115
+ }
116
+ get hostElement() { return index.getElement(this); }
117
+ static get watchers() { return {
118
+ "position": ["positionChange"],
119
+ "opened": ["openedChange"]
120
+ }; }
121
+ };
122
+ MdsModal.style = mdsModalCss;
123
+
124
+ exports.mds_modal = MdsModal;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-ced1b9b6.js');
4
+
5
+ /*
6
+ Stencil Client Patch Browser v2.10.0 | MIT Licensed | https://stenciljs.com
7
+ */
8
+ const patchBrowser = () => {
9
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('mds-modal.cjs.js', document.baseURI).href));
10
+ const opts = {};
11
+ if (importMeta !== '') {
12
+ opts.resourcesUrl = new URL('.', importMeta).href;
13
+ }
14
+ return index.promiseResolve(opts);
15
+ };
16
+
17
+ patchBrowser().then(options => {
18
+ return index.bootstrapLazy([["mds-modal.cjs",[[1,"mds-modal",{"opened":[1540],"position":[1537]},[[0,"close","onCloseListener"]]]]]], options);
19
+ });
@@ -0,0 +1,12 @@
1
+ {
2
+ "entries": [
3
+ "./components/mds-modal/mds-modal.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "2.10.0",
8
+ "typescriptVersion": "4.3.5"
9
+ },
10
+ "collections": [],
11
+ "bundles": []
12
+ }
@@ -0,0 +1,215 @@
1
+
2
+
3
+ .animate-left, .animate-right {
4
+ opacity: 0;
5
+ transition-property: background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;
6
+ transition-duration: 150ms;
7
+ transition-duration: 500ms;
8
+ transition-timing-function: cubic-bezier(1, 0, 0, 1);
9
+ }
10
+
11
+ .animate-right-intro,
12
+ .animate-right-outro {
13
+ transform: translateX(calc(100% + 50px));
14
+ }
15
+ .border {
16
+ border-width: 1px;
17
+ }
18
+ .shadow {
19
+ --tw-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
20
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
21
+ }
22
+
23
+ :host {
24
+ pointer-events: none;
25
+ position: fixed;
26
+ top: 0px;
27
+ right: 0px;
28
+ bottom: 0px;
29
+ left: 0px;
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: center;
33
+ --tw-bg-opacity: 1;
34
+ background-color: rgba(var(--adjust-tone-01), var(--tw-bg-opacity));
35
+ --tw-bg-opacity: 0;
36
+ transition-duration: 700ms;
37
+ transition-timing-function: cubic-bezier(1, 0, 0, 1);
38
+
39
+ perspective: 600px;
40
+ }
41
+
42
+ :host ( .animate-center-opened ), :host ( .animate-left-opened ), :host ( .animate-right-opened ) {
43
+ pointer-events: auto;
44
+ --tw-bg-opacity: 0.5;
45
+ transition-duration: 500ms;
46
+ }
47
+
48
+ .close {
49
+ position: absolute;
50
+ top: 0px;
51
+ height: 2.25rem;
52
+ width: 2.25rem;
53
+ transform-origin: center;
54
+ cursor: pointer;
55
+ font-size: 2.25rem;
56
+ line-height: 2.5rem;
57
+ --tw-text-opacity: 1;
58
+ color: rgba(var(--adjust-tone-10), var(--tw-text-opacity));
59
+ opacity: 0;
60
+ transition-property: background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;
61
+ transition-duration: 150ms;
62
+ transition-duration: 500ms;
63
+ transition-timing-function: cubic-bezier(0.77, 0, 0.175, 1);
64
+ text-shadow: 0px 0px 1px rgb(0 0 0 / 20%), 0px 0px 1px rgb(1 0 5 / 10%);
65
+
66
+ transform: translate(0, 24px) rotate(90deg);
67
+ }
68
+
69
+ .window {
70
+ display: grid;
71
+ height: 100%;
72
+ gap: 0px;
73
+ overflow: auto;
74
+
75
+ background-color: var(--window-background, rgb(var(--adjust-tone)));
76
+ box-shadow: var(--window-shadow, 0 25px 50px -12px rgba(0, 0, 0, 0.25));
77
+ grid-template-rows: 1fr;
78
+
79
+ /* grid-template-rows: var(--grid-template-rows, auto 1fr auto); */
80
+ max-width: calc(100vw - 80px);
81
+ }
82
+
83
+ .window--top {
84
+ grid-template-rows: auto 1fr;
85
+ }
86
+
87
+ .window--bottom {
88
+ grid-template-rows: 1fr auto;
89
+ }
90
+
91
+ .window--top-bottom {
92
+ grid-template-rows: auto 1fr auto;
93
+ }
94
+
95
+ :host ( .animate-center ) {
96
+ justify-content: center;
97
+ padding: 2rem;
98
+ }
99
+
100
+ @media (max-width: 767px) {
101
+
102
+ :host ( .animate-center ) {
103
+ padding: 1rem;
104
+ }
105
+ }
106
+
107
+ :host ( .animate-center ) .window, :host ( .animate-center ) > ::slotted ( [slot=window] ) {
108
+ opacity: 0;
109
+ transition-property: background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;
110
+ transition-duration: 150ms;
111
+ transition-duration: 500ms;
112
+ transition-timing-function: cubic-bezier(1, 0, 0, 1);
113
+ }
114
+
115
+ :host ( .animate-center-intro ) .window, :host ( .animate-center-intro ) > ::slotted ( [slot=window] ) {
116
+ transform: rotateX(-22deg) scale(0.5) translateY(40%);
117
+ }
118
+
119
+ :host ( .animate-center-opened.animate-center-outro ) .window, :host ( .animate-center-opened.animate-center-outro ) > ::slotted ( [slot=window] ), :host ( .animate-center-opened ) .window, :host ( .animate-center-opened ) > ::slotted ( [slot=window] ) {
120
+
121
+ transform: rotateX(0) scale(1) translateY(0);
122
+
123
+ opacity: 1;
124
+ }
125
+
126
+ :host ( .animate-center-outro ) .window, :host ( .animate-center-outro ) > ::slotted ( [slot=window] ) {
127
+ transform: rotateX(-22deg) scale(0.5) translateY(-40%);
128
+ }
129
+
130
+ :host ( .animate-right ) {
131
+ justify-content: flex-end;
132
+ }
133
+
134
+ :host ( .animate-right ) .window, :host ( .animate-right ) > ::slotted ( [slot=window] ) {
135
+ opacity: 0;
136
+ transition-property: background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;
137
+ transition-duration: 150ms;
138
+ transition-duration: 500ms;
139
+ transition-timing-function: cubic-bezier(1, 0, 0, 1);
140
+ }
141
+
142
+ :host ( .animate-right-intro ) .window, :host ( .animate-right-intro ) > ::slotted ( [slot=window] ) {
143
+ transform: translateX(calc(100% + 50px));
144
+ }
145
+
146
+ :host ( .animate-right-opened.animate-right-outro ) .window, :host ( .animate-right-opened.animate-right-outro ) > ::slotted ( [slot=window] ), :host ( .animate-right-opened ) .window, :host ( .animate-right-opened ) > ::slotted ( [slot=window] ) {
147
+
148
+ transform: translateX(0);
149
+
150
+ opacity: 1;
151
+ }
152
+
153
+ :host ( .animate-right-opened ) .close, :host ( .animate-right-opened.animate-right-outro ) .close {
154
+ opacity: 1;
155
+
156
+ transform: translate(24px, 24px) rotate(0);
157
+ }
158
+
159
+ :host ( .animate-right-outro ) .window, :host ( .animate-right-outro ) > ::slotted ( [slot=window] ) {
160
+ transform: translateX(calc(100% + 50px));
161
+ }
162
+
163
+ :host ( .animate-right-outro ) .close {
164
+ transform: translate(-24px, 24px) rotate(90deg);
165
+ }
166
+
167
+ :host ( .animate-right ) .close {
168
+ left: 0px;
169
+
170
+ transform: translate(-36px, 24px) rotate(-90deg);
171
+ }
172
+
173
+ :host ( .animate-left ) {
174
+ justify-content: flex-start;
175
+ }
176
+
177
+ :host ( .animate-left ) .window, :host ( .animate-left ) > ::slotted ( [slot=window] ) {
178
+ opacity: 0;
179
+ transition-property: background-color, border-color, box-shadow, color, height, margin, opacity, padding, transform, width;
180
+ transition-duration: 150ms;
181
+ transition-duration: 500ms;
182
+ transition-timing-function: cubic-bezier(1, 0, 0, 1);
183
+ }
184
+
185
+ :host ( .animate-left-intro ) .window, :host ( .animate-left-intro ) > ::slotted ( [slot=window] ) {
186
+ transform: translateX(calc(-100% - 50px));
187
+ }
188
+
189
+ :host ( .animate-left-opened.animate-left-outro ) .window, :host ( .animate-left-opened.animate-left-outro ) > ::slotted ( [slot=window] ), :host ( .animate-left-opened ) .window, :host ( .animate-left-opened ) > ::slotted ( [slot=window] ) {
190
+
191
+ transform: translateX(0);
192
+
193
+ opacity: 1;
194
+ }
195
+
196
+ :host ( .animate-left-opened ) .close, :host ( .animate-left-opened.animate-left-outro ) .close {
197
+ opacity: 1;
198
+
199
+ transform: translate(-24px, 24px) rotate(0);
200
+ }
201
+
202
+ :host ( .animate-left-outro ) .window, :host ( .animate-left-outro ) > ::slotted ( [slot=window] ) {
203
+ transform: translateX(calc(-100% - 50px));
204
+ }
205
+
206
+ :host ( .animate-left-outro ) .close {
207
+ transform: translate(24px, 24px) rotate(-90deg);
208
+ }
209
+
210
+ :host ( .animate-left ) .close {
211
+ right: 0px;
212
+
213
+ transform: translate(36px, 24px) rotate(90deg);
214
+ }
215
+
@@ -0,0 +1,153 @@
1
+ import { Component, Element, Event, Host, h, Listen, Prop, Watch } from '@stencil/core';
2
+ import clsx from 'clsx';
3
+ export class MdsModal {
4
+ constructor() {
5
+ this.window = null;
6
+ this.top = null;
7
+ this.bottom = null;
8
+ this.animationState = 'intro';
9
+ /**
10
+ * Specifies the animation position of the modal window
11
+ */
12
+ this.position = null;
13
+ this.animationName = (customState = null, customPosition = null) => {
14
+ return `animate-${customPosition !== null ? customPosition : this.position}${customState !== null ? '-' + customState : ''}`;
15
+ };
16
+ this.closeModal = (e = null) => {
17
+ this.opened = e.target !== e.currentTarget;
18
+ if (!this.opened) {
19
+ this.close.emit();
20
+ }
21
+ };
22
+ }
23
+ componentWillLoad() {
24
+ this.bottom = this.hostElement.querySelector('[slot="bottom"]') !== null;
25
+ this.top = this.hostElement.querySelector('[slot="top"]') !== null;
26
+ this.window = this.hostElement.querySelector('[slot="window"]') !== null;
27
+ if (this.window && this.position === null) {
28
+ this.position = 'center';
29
+ }
30
+ if (this.position === null) {
31
+ this.position = 'right';
32
+ }
33
+ }
34
+ componentWillRender() {
35
+ this.animationState = this.opened ? 'intro' : 'outro';
36
+ this.hostElement.classList.add(this.animationName());
37
+ }
38
+ componentDidRender() {
39
+ this.animationDeelay = window.setTimeout(() => {
40
+ this.animationState = this.animationState === 'intro' ? 'outro' : 'intro';
41
+ this.hostElement.classList.remove(this.animationName(this.animationState === 'intro' ? 'outro' : 'intro'));
42
+ this.hostElement.classList.add(this.animationName(this.animationState));
43
+ window.clearTimeout(this.animationDeelay);
44
+ }, 500);
45
+ }
46
+ positionChange(newValue, oldValue) {
47
+ window.clearTimeout(this.animationDeelay);
48
+ this.hostElement.classList.remove(this.animationName(null, oldValue));
49
+ this.hostElement.classList.remove(this.animationName('intro', oldValue));
50
+ this.hostElement.classList.remove(this.animationName('outro', oldValue));
51
+ }
52
+ openedChange() {
53
+ window.clearTimeout(this.animationDeelay);
54
+ }
55
+ onCloseListener() {
56
+ this.opened = false;
57
+ }
58
+ render() {
59
+ return (h(Host, { class: clsx(this.opened && this.animationName('opened')), onClick: (e) => { this.closeModal(e); } },
60
+ this.window
61
+ ?
62
+ h("slot", { name: "window" })
63
+ :
64
+ h("div", { class: clsx('window', (this.top || this.bottom) && `window-${this.top ? '-top' : ''}${this.bottom ? '-bottom' : ''}`) },
65
+ this.top &&
66
+ h("slot", { name: "top" }),
67
+ h("slot", null),
68
+ this.bottom &&
69
+ h("slot", { name: "bottom" })),
70
+ !this.window && h("mds-icon", { name: "close", class: "close" })));
71
+ }
72
+ static get is() { return "mds-modal"; }
73
+ static get encapsulation() { return "shadow"; }
74
+ static get originalStyleUrls() { return {
75
+ "$": ["mds-modal.css"]
76
+ }; }
77
+ static get styleUrls() { return {
78
+ "$": ["mds-modal.css"]
79
+ }; }
80
+ static get properties() { return {
81
+ "opened": {
82
+ "type": "boolean",
83
+ "mutable": true,
84
+ "complexType": {
85
+ "original": "boolean",
86
+ "resolved": "boolean",
87
+ "references": {}
88
+ },
89
+ "required": false,
90
+ "optional": true,
91
+ "docs": {
92
+ "tags": [],
93
+ "text": "Specifies if the modal is opened or not"
94
+ },
95
+ "attribute": "opened",
96
+ "reflect": true
97
+ },
98
+ "position": {
99
+ "type": "string",
100
+ "mutable": true,
101
+ "complexType": {
102
+ "original": "ModalPositionType",
103
+ "resolved": "\"center\" | \"left\" | \"right\"",
104
+ "references": {
105
+ "ModalPositionType": {
106
+ "location": "import",
107
+ "path": "./meta/types"
108
+ }
109
+ }
110
+ },
111
+ "required": false,
112
+ "optional": true,
113
+ "docs": {
114
+ "tags": [],
115
+ "text": "Specifies the animation position of the modal window"
116
+ },
117
+ "attribute": "position",
118
+ "reflect": true,
119
+ "defaultValue": "null"
120
+ }
121
+ }; }
122
+ static get events() { return [{
123
+ "method": "close",
124
+ "name": "close",
125
+ "bubbles": true,
126
+ "cancelable": true,
127
+ "composed": true,
128
+ "docs": {
129
+ "tags": [],
130
+ "text": "Emits when a modal is closed"
131
+ },
132
+ "complexType": {
133
+ "original": "void",
134
+ "resolved": "void",
135
+ "references": {}
136
+ }
137
+ }]; }
138
+ static get elementRef() { return "hostElement"; }
139
+ static get watchers() { return [{
140
+ "propName": "position",
141
+ "methodName": "positionChange"
142
+ }, {
143
+ "propName": "opened",
144
+ "methodName": "openedChange"
145
+ }]; }
146
+ static get listeners() { return [{
147
+ "name": "close",
148
+ "method": "onCloseListener",
149
+ "target": undefined,
150
+ "capture": false,
151
+ "passive": false
152
+ }]; }
153
+ }
@@ -0,0 +1,6 @@
1
+ const modalPositionDictionary = [
2
+ 'center',
3
+ 'left',
4
+ 'right',
5
+ ];
6
+ export { modalPositionDictionary, };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,68 @@
1
+ import React from 'react'
2
+ import faker from 'faker'
3
+ import MdsModal from '@component/mds-modal/mds-modal'
4
+
5
+ import { modalPositionDictionary } from '../meta/dictionary'
6
+
7
+ export default {
8
+ title: 'UI / Modal',
9
+ component: MdsModal,
10
+ argTypes: {
11
+ opened: {
12
+ description: 'Specifies if the modal is opened or not',
13
+ type: { name: 'boolean', required: false },
14
+ },
15
+ position: {
16
+ control: { type: 'select' },
17
+ description: 'Specifies the animation position of the modal window',
18
+ options: modalPositionDictionary,
19
+ type: { name: 'string', required: false },
20
+ }
21
+ },
22
+ }
23
+
24
+ const buttonA = faker.hacker.verb()
25
+ const buttonB = faker.hacker.verb()
26
+ const text = faker.lorem.paragraphs(3)
27
+ const firstName = faker.name.firstName(1)
28
+ const lastName = faker.name.lastName(1)
29
+ const fullName = `${firstName} ${lastName}`
30
+ const email = faker.internet.email(firstName, lastName)
31
+
32
+ const Template = args =>
33
+ <mds-modal {...args}>
34
+ <header slot="top" className="p-8 max-w-lg flex gap-4 items-center border-b border-adjust-tone-09">
35
+ <mds-img class="w-16" src="/logo-gruppo-maggioli-512w.webp"/>
36
+ <div className="text-adjust-tone-02">
37
+ <mds-text typography="h5" class="truncate min-w-0">Maggioli Editore</mds-text>
38
+ <mds-text typography="detail" class="truncate min-w-0">Menu di servizio</mds-text>
39
+ </div>
40
+ </header>
41
+ <div className="p-8 max-w-lg">
42
+ <mds-text>
43
+ { text }
44
+ </mds-text>
45
+ </div>
46
+ <footer slot="bottom" className="p-8 max-w-lg flex gap-4 text-adjust-tone-02 border-t border-adjust-tone-09">
47
+ <mds-author>
48
+ <mds-avatar slot="avatar" class="w-16 mobile:w-12" src="/avatar-01-200x200.jpeg"/>
49
+ <mds-text typography="h6" class="truncate min-w-0">{ fullName }</mds-text>
50
+ <mds-text typography="caption" class="text-adjust-tone-04 truncate min-w-0">{ email }</mds-text>
51
+ </mds-author>
52
+ <mds-button icon="menu-more" class="ml-auto bg-transparent text-adjust-tone-02 p-4 border border-adjust-tone-09 rounded-full"/>
53
+ </footer>
54
+ </mds-modal>
55
+
56
+ const CustomTemplate = args =>
57
+ <mds-modal {...args}>
58
+ <mds-banner slot="window" class="max-w-xl" deletable headline="Action required">
59
+ <mds-text typography="detail">
60
+ { text }
61
+ </mds-text>
62
+ <mds-button slot="actions" variant="primary" tone="quiet">Cancel</mds-button>
63
+ <mds-button slot="actions" variant="primary">Confirm</mds-button>
64
+ </mds-banner>
65
+ </mds-modal>
66
+
67
+ export const Default = Template.bind({})
68
+ export const CustomWindow = CustomTemplate.bind({})