@maggioli-design-system/mds-modal 5.3.0 → 5.4.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 +34 -3
- package/dist/cjs/mds-modal.cjs.js +1 -1
- package/dist/collection/common/floating-controller.js +3 -3
- package/dist/collection/common/slot.js +10 -1
- package/dist/collection/common/string.js +30 -0
- package/dist/collection/components/mds-modal/mds-modal.css +124 -0
- package/dist/collection/components/mds-modal/mds-modal.js +59 -2
- package/dist/collection/components/mds-modal/meta/dictionary.js +5 -1
- package/dist/collection/components/mds-modal/test/mds-modal.stories.js +20 -2
- package/dist/collection/dictionary/keyboard.js +84 -0
- package/dist/collection/type/keyboard.js +1 -0
- package/dist/components/mds-modal.js +36 -4
- package/dist/documentation.json +46 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mds-modal.entry.js +34 -3
- package/dist/esm/mds-modal.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mds-modal.entry.js +1 -1
- package/dist/esm-es5/mds-modal.js +1 -1
- package/dist/mds-modal/mds-modal.esm.js +1 -1
- package/dist/mds-modal/p-2c91cf1f.entry.js +1 -0
- package/dist/mds-modal/p-69576bb4.system.entry.js +1 -0
- package/dist/mds-modal/p-c6899cb0.system.js +1 -1
- package/dist/stats.json +84 -16
- package/dist/types/common/slot.d.ts +2 -1
- package/dist/types/common/string.d.ts +4 -0
- package/dist/types/components/mds-modal/mds-modal.d.ts +8 -1
- package/dist/types/components/mds-modal/meta/dictionary.d.ts +2 -1
- package/dist/types/components/mds-modal/meta/types.d.ts +1 -0
- package/dist/types/components/mds-modal/test/mds-modal.stories.d.ts +11 -0
- package/dist/types/components.d.ts +10 -2
- package/dist/types/dictionary/keyboard.d.ts +2 -0
- package/dist/types/type/keyboard.d.ts +12 -0
- package/documentation.json +61 -1
- package/package.json +3 -3
- package/readme.md +18 -16
- package/src/common/floating-controller.ts +6 -6
- package/src/common/slot.ts +11 -0
- package/src/common/string.ts +42 -0
- package/src/components/mds-modal/mds-modal.css +7 -1
- package/src/components/mds-modal/mds-modal.tsx +36 -1
- package/src/components/mds-modal/meta/dictionary.ts +6 -0
- package/src/components/mds-modal/meta/types.ts +4 -0
- package/src/components/mds-modal/readme.md +18 -16
- package/src/components/mds-modal/test/mds-modal.stories.tsx +57 -3
- package/src/components.d.ts +10 -2
- package/src/dictionary/keyboard.ts +87 -0
- package/src/fixtures/icons.json +18 -1
- package/src/meta/keyboard/keys.json +83 -0
- package/src/tailwind/components.css +11 -0
- package/src/tailwind/fouc.css +118 -0
- package/src/type/keyboard.ts +93 -0
- package/www/build/mds-modal.esm.js +1 -1
- package/www/build/p-2c91cf1f.entry.js +1 -0
- package/www/build/p-69576bb4.system.entry.js +1 -0
- package/www/build/p-c6899cb0.system.js +1 -1
- package/dist/mds-modal/p-413a00c5.entry.js +0 -1
- package/dist/mds-modal/p-96958acc.system.entry.js +0 -1
- package/www/build/p-413a00c5.entry.js +0 -1
- package/www/build/p-96958acc.system.entry.js +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type KeyboardKeyData = {
|
|
2
|
+
alias: string;
|
|
3
|
+
description: string;
|
|
4
|
+
group: string;
|
|
5
|
+
keyCodes: string[];
|
|
6
|
+
keyboardPosition?: {
|
|
7
|
+
left?: boolean;
|
|
8
|
+
right?: boolean;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type KeyboardKeyName = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'alt' | 'altleft' | 'altright' | 'arrowdown' | 'arrowleft' | 'arrowright' | 'arrowup' | 'b' | 'backspace' | 'c' | 'capslock' | 'command' | 'commandleft' | 'commandright' | 'control' | 'controlleft' | 'controlright' | 'd' | 'delete' | 'e' | 'end' | 'enter' | 'escape' | 'f' | 'f1' | 'f10' | 'f11' | 'f12' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'g' | 'h' | 'home' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'option' | 'optionleft' | 'optionright' | 'p' | 'pagedown' | 'pageup' | 'q' | 'r' | 's' | 'shift' | 'shiftleft' | 'shiftright' | 'space' | 't' | 'tab' | 'u' | 'v' | 'w' | 'windows' | 'windowsleft' | 'windowsright' | 'x' | 'y' | 'z';
|
|
12
|
+
export type KeyboardKeyMap = Record<KeyboardKeyName, KeyboardKeyData>;
|
package/documentation.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2025-02-
|
|
2
|
+
"timestamp": "2025-02-25T13:09:05",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.25.1",
|
|
@@ -98,6 +98,41 @@
|
|
|
98
98
|
"getter": false,
|
|
99
99
|
"setter": false
|
|
100
100
|
},
|
|
101
|
+
{
|
|
102
|
+
"name": "overflow",
|
|
103
|
+
"type": "\"auto\" | \"manual\"",
|
|
104
|
+
"complexType": {
|
|
105
|
+
"original": "ModalOverflowType",
|
|
106
|
+
"resolved": "\"auto\" | \"manual\"",
|
|
107
|
+
"references": {
|
|
108
|
+
"ModalOverflowType": {
|
|
109
|
+
"location": "import",
|
|
110
|
+
"path": "./meta/types",
|
|
111
|
+
"id": "src/components/mds-modal/meta/types.ts::ModalOverflowType"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"mutable": false,
|
|
116
|
+
"attr": "overflow",
|
|
117
|
+
"reflectToAttr": true,
|
|
118
|
+
"docs": "Specifies if the component prevents the body from scrolling when modal window is opened",
|
|
119
|
+
"docsTags": [],
|
|
120
|
+
"default": "'auto'",
|
|
121
|
+
"values": [
|
|
122
|
+
{
|
|
123
|
+
"value": "auto",
|
|
124
|
+
"type": "string"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"value": "manual",
|
|
128
|
+
"type": "string"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"optional": false,
|
|
132
|
+
"required": false,
|
|
133
|
+
"getter": false,
|
|
134
|
+
"setter": false
|
|
135
|
+
},
|
|
101
136
|
{
|
|
102
137
|
"name": "position",
|
|
103
138
|
"type": "\"bottom\" | \"bottom-left\" | \"bottom-right\" | \"center\" | \"left\" | \"right\" | \"top\" | \"top-left\" | \"top-right\" | undefined",
|
|
@@ -216,6 +251,11 @@
|
|
|
216
251
|
"annotation": "prop",
|
|
217
252
|
"docs": "Set the color of the close icon button to the top left."
|
|
218
253
|
},
|
|
254
|
+
{
|
|
255
|
+
"name": "--mds-modal-custom-window-distance",
|
|
256
|
+
"annotation": "prop",
|
|
257
|
+
"docs": "Set the distance between the slotted modal window and the screen bounds"
|
|
258
|
+
},
|
|
219
259
|
{
|
|
220
260
|
"name": "--mds-modal-overlay-color",
|
|
221
261
|
"annotation": "prop",
|
|
@@ -498,6 +538,11 @@
|
|
|
498
538
|
"docstring": "",
|
|
499
539
|
"path": "src/components/mds-header/meta/event-detail.ts"
|
|
500
540
|
},
|
|
541
|
+
"src/components/mds-header/meta/event-detail.ts::MdsHeaderVisibilityEventDetail": {
|
|
542
|
+
"declaration": "export interface MdsHeaderVisibilityEventDetail {\n visibility: boolean\n}",
|
|
543
|
+
"docstring": "",
|
|
544
|
+
"path": "src/components/mds-header/meta/event-detail.ts"
|
|
545
|
+
},
|
|
501
546
|
"src/components/mds-horizontal-scroll/meta/types.ts::ViewportType": {
|
|
502
547
|
"declaration": "export type ViewportType =\n | 'all'\n | 'tv'\n | 'xlarge'\n | 'large'\n | 'wide'\n | 'desktop'\n | 'tablet'\n | 'none'",
|
|
503
548
|
"docstring": "",
|
|
@@ -613,6 +658,16 @@
|
|
|
613
658
|
"docstring": "",
|
|
614
659
|
"path": "src/components/mds-input-upload/meta/types.ts"
|
|
615
660
|
},
|
|
661
|
+
"src/components/mds-keyboard/meta/type.ts::KeyboardTest": {
|
|
662
|
+
"declaration": "export type KeyboardTest =\n | 'pass'\n | 'fail'",
|
|
663
|
+
"docstring": "",
|
|
664
|
+
"path": "src/components/mds-keyboard/meta/type.ts"
|
|
665
|
+
},
|
|
666
|
+
"src/type/keyboard.ts::KeyboardKeyName": {
|
|
667
|
+
"declaration": "export type KeyboardKeyName =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'a'\n | 'alt'\n | 'altleft'\n | 'altright'\n | 'arrowdown'\n | 'arrowleft'\n | 'arrowright'\n | 'arrowup'\n | 'b'\n | 'backspace'\n | 'c'\n | 'capslock'\n | 'command'\n | 'commandleft'\n | 'commandright'\n | 'control'\n | 'controlleft'\n | 'controlright'\n | 'd'\n | 'delete'\n | 'e'\n | 'end'\n | 'enter'\n | 'escape'\n | 'f'\n | 'f1'\n | 'f10'\n | 'f11'\n | 'f12'\n | 'f2'\n | 'f3'\n | 'f4'\n | 'f5'\n | 'f6'\n | 'f7'\n | 'f8'\n | 'f9'\n | 'g'\n | 'h'\n | 'home'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'option'\n | 'optionleft'\n | 'optionright'\n | 'p'\n | 'pagedown'\n | 'pageup'\n | 'q'\n | 'r'\n | 's'\n | 'shift'\n | 'shiftleft'\n | 'shiftright'\n | 'space'\n | 't'\n | 'tab'\n | 'u'\n | 'v'\n | 'w'\n | 'windows'\n | 'windowsleft'\n | 'windowsright'\n | 'x'\n | 'y'\n | 'z'",
|
|
668
|
+
"docstring": "",
|
|
669
|
+
"path": "src/type/keyboard.ts"
|
|
670
|
+
},
|
|
616
671
|
"src/type/typography.ts::TypographyType": {
|
|
617
672
|
"declaration": "export type TypographyType =\n | 'action'\n | 'caption'\n | 'snippet'\n | 'detail'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'hack'\n | 'label'\n | 'option'\n | 'paragraph'\n | 'tip'",
|
|
618
673
|
"docstring": "",
|
|
@@ -633,6 +688,11 @@
|
|
|
633
688
|
"docstring": "",
|
|
634
689
|
"path": "src/components/mds-modal/meta/types.ts"
|
|
635
690
|
},
|
|
691
|
+
"src/components/mds-modal/meta/types.ts::ModalOverflowType": {
|
|
692
|
+
"declaration": "export type ModalOverflowType =\n | 'auto'\n | 'manual'",
|
|
693
|
+
"docstring": "",
|
|
694
|
+
"path": "src/components/mds-modal/meta/types.ts"
|
|
695
|
+
},
|
|
636
696
|
"src/type/variant.ts::LabelVariantType": {
|
|
637
697
|
"declaration": "export type LabelVariantType =\n | 'amaranth'\n | 'aqua'\n | 'blue'\n | 'green'\n | 'lime'\n | 'orange'\n | 'orchid'\n | 'sky'\n | 'violet'\n | 'yellow'",
|
|
638
698
|
"docstring": "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maggioli-design-system/mds-modal",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "mds-modal is a web-component from Magma Design System, built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScript framework you are using.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"test": "stencil test --spec --e2e"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@maggioli-design-system/mds-button": "6.
|
|
28
|
-
"@maggioli-design-system/styles": "15.
|
|
27
|
+
"@maggioli-design-system/mds-button": "6.3.0",
|
|
28
|
+
"@maggioli-design-system/styles": "15.8.0",
|
|
29
29
|
"@stencil/core": "4.25.1",
|
|
30
30
|
"clsx": "2.1.0"
|
|
31
31
|
},
|
package/readme.md
CHANGED
|
@@ -9,11 +9,12 @@ This is a web-component from Maggioli Design System [Magma](https://magma.maggio
|
|
|
9
9
|
|
|
10
10
|
## Properties
|
|
11
11
|
|
|
12
|
-
| Property | Attribute | Description
|
|
13
|
-
| ----------- | ----------- |
|
|
14
|
-
| `animating` | `animating` | Specifies if the component is animating itself or not
|
|
15
|
-
| `opened` | `opened` | Specifies if the modal is opened or not
|
|
16
|
-
| `
|
|
12
|
+
| Property | Attribute | Description | Type | Default |
|
|
13
|
+
| ----------- | ----------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------- |
|
|
14
|
+
| `animating` | `animating` | Specifies if the component is animating itself or not | `"intro" \| "none" \| "outro" \| undefined` | `'none'` |
|
|
15
|
+
| `opened` | `opened` | Specifies if the modal is opened or not | `boolean` | `false` |
|
|
16
|
+
| `overflow` | `overflow` | Specifies if the component prevents the body from scrolling when modal window is opened | `"auto" \| "manual"` | `'auto'` |
|
|
17
|
+
| `position` | `position` | Specifies the animation position of the modal window | `"bottom" \| "bottom-left" \| "bottom-right" \| "center" \| "left" \| "right" \| "top" \| "top-left" \| "top-right" \| undefined` | `'center'` |
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
## Events
|
|
@@ -43,17 +44,18 @@ This is a web-component from Maggioli Design System [Magma](https://magma.maggio
|
|
|
43
44
|
|
|
44
45
|
## CSS Custom Properties
|
|
45
46
|
|
|
46
|
-
| Name
|
|
47
|
-
|
|
|
48
|
-
| `--mds-modal-close-icon-color`
|
|
49
|
-
| `--mds-modal-
|
|
50
|
-
| `--mds-modal-overlay-
|
|
51
|
-
| `--mds-modal-
|
|
52
|
-
| `--mds-modal-window-
|
|
53
|
-
| `--mds-modal-window-
|
|
54
|
-
| `--mds-modal-window-
|
|
55
|
-
| `--mds-modal-window-
|
|
56
|
-
| `--mds-modal-
|
|
47
|
+
| Name | Description |
|
|
48
|
+
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| `--mds-modal-close-icon-color` | Set the color of the close icon button to the top left. |
|
|
50
|
+
| `--mds-modal-custom-window-distance` | Set the distance between the slotted modal window and the screen bounds |
|
|
51
|
+
| `--mds-modal-overlay-color` | Set the overlay color of the background when the component is opened, this property can be inherited from `globals.css` in `styles^8.0.0`. |
|
|
52
|
+
| `--mds-modal-overlay-opacity` | Set the overlay color opacity of the background when the component is opened, this property can be inherited from `globals.css` in `styles^8.0.0`. |
|
|
53
|
+
| `--mds-modal-window-background` | Set the background color of the window |
|
|
54
|
+
| `--mds-modal-window-distance` | Set the distance between the modal window and the screen bounds |
|
|
55
|
+
| `--mds-modal-window-overflow` | Set the overflow of the window |
|
|
56
|
+
| `--mds-modal-window-radius` | Set the border radius of the window |
|
|
57
|
+
| `--mds-modal-window-shadow` | Set the box shadow of the window |
|
|
58
|
+
| `--mds-modal-z-index` | Set the z-index of the window when the component is opened |
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
## Dependencies
|
|
@@ -214,21 +214,21 @@ export class FloatingController {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
export class Backdrop {
|
|
217
|
-
private readonly defaultBackdropId = '
|
|
217
|
+
private readonly defaultBackdropId = 'magma-backdrop'
|
|
218
218
|
private readonly backdropBackgroundVisible = 'rgba(var(--magma-backdrop-color, 0 0 0) / var(--magma-backdrop-opacity, 0.1))'
|
|
219
219
|
private readonly backdropBackgroundHidden = 'rgba(var(--magma-backdrop-color, 0 0 0) / 0)'
|
|
220
220
|
|
|
221
|
-
private readonly backdropId
|
|
222
|
-
private readonly cssBackdropZIndex
|
|
223
|
-
private readonly cssBackdropDuration
|
|
221
|
+
private readonly backdropId: string
|
|
222
|
+
private readonly cssBackdropZIndex: string
|
|
223
|
+
private readonly cssBackdropDuration: string
|
|
224
224
|
|
|
225
225
|
private backdropEl: HTMLElement
|
|
226
226
|
private backdropTimer: NodeJS.Timeout
|
|
227
227
|
|
|
228
228
|
constructor (backdropId?: string) {
|
|
229
229
|
this.backdropId = backdropId ?? this.defaultBackdropId
|
|
230
|
-
this.cssBackdropZIndex = `var(--${this.backdropId}-z-index)`
|
|
231
|
-
this.cssBackdropDuration = `var(--${this.backdropId}-duration)`
|
|
230
|
+
this.cssBackdropZIndex = `var(--${this.backdropId}-z-index, 4000)`
|
|
231
|
+
this.cssBackdropDuration = `var(--${this.backdropId}-animation-duration, 300ms)`
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
attachBackdrop (): void {
|
package/src/common/slot.ts
CHANGED
|
@@ -18,7 +18,18 @@ const hasSlottedNodes = (el: HTMLElement, name?: string): boolean => {
|
|
|
18
18
|
return false
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const hasSlotted = (el: HTMLElement, name?: string): boolean => {
|
|
22
|
+
const query = name ? `slot[name="${name}"]` : 'slot:not([name])'
|
|
23
|
+
|
|
24
|
+
const slot: HTMLSlotElement = el.shadowRoot?.querySelector(query) as HTMLSlotElement
|
|
25
|
+
if (slot) {
|
|
26
|
+
return slot.assignedNodes().length > 0 || slot.assignedElements().length > 0
|
|
27
|
+
}
|
|
28
|
+
return false
|
|
29
|
+
}
|
|
30
|
+
|
|
21
31
|
export {
|
|
22
32
|
hasSlottedElements,
|
|
23
33
|
hasSlottedNodes,
|
|
34
|
+
hasSlotted,
|
|
24
35
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const levenshteinDistance = (a: string, b: string): number => {
|
|
2
|
+
const dp: number[][] = Array.from({ length: a.length + 1 }, (_, i) =>
|
|
3
|
+
// eslint-disable-next-line no-nested-ternary
|
|
4
|
+
Array.from({ length: b.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)),
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
for (let i = 1; i <= a.length; i++) {
|
|
8
|
+
for (let j = 1; j <= b.length; j++) {
|
|
9
|
+
if (a[i - 1] === b[j - 1]) {
|
|
10
|
+
dp[i][j] = dp[i - 1][j - 1]
|
|
11
|
+
} else {
|
|
12
|
+
dp[i][j] = 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1])
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return dp[a.length][b.length]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const closest = (input: string, validCodes: string[]): string => {
|
|
22
|
+
let [closest] = validCodes
|
|
23
|
+
let minDistance = levenshteinDistance(input, closest)
|
|
24
|
+
|
|
25
|
+
for (const code of validCodes) {
|
|
26
|
+
const distance = levenshteinDistance(input, code)
|
|
27
|
+
if (distance < minDistance) {
|
|
28
|
+
minDistance = distance
|
|
29
|
+
closest = code
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return closest
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const firstLetterUppercase = (str: string): string => str.charAt(0).toUpperCase() + str.slice(1)
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
closest,
|
|
40
|
+
firstLetterUppercase,
|
|
41
|
+
levenshteinDistance,
|
|
42
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* @prop --mds-modal-window-overflow: Set the overflow of the window
|
|
13
13
|
* @prop --mds-modal-window-radius: Set the border radius of the window
|
|
14
14
|
* @prop --mds-modal-window-distance: Set the distance between the modal window and the screen bounds
|
|
15
|
+
* @prop --mds-modal-custom-window-distance: Set the distance between the slotted modal window and the screen bounds
|
|
15
16
|
* @prop --mds-modal-window-shadow: Set the box shadow of the window
|
|
16
17
|
* @prop --mds-modal-z-index: Set the z-index of the window when the component is opened
|
|
17
18
|
*/
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
--mds-modal-window-radius: 0;
|
|
29
30
|
--mds-modal-window-shadow: theme('boxShadow.2xl');
|
|
30
31
|
--mds-modal-window-distance: 0;
|
|
32
|
+
--mds-modal-custom-window-distance: theme('spacing.600');
|
|
31
33
|
--mds-modal-z-index: var(--magma-modal-z-index);
|
|
32
34
|
|
|
33
35
|
@apply ease-in-out-expo;
|
|
@@ -46,6 +48,10 @@
|
|
|
46
48
|
z-index: var(--mds-modal-z-index, 1000);
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
:host ::slotted([slot="window"]) {
|
|
52
|
+
margin: var(--mds-modal-custom-window-distance);
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
:host( [position="top"] ) {
|
|
50
56
|
align-items: flex-start;
|
|
51
57
|
justify-content: center;
|
|
@@ -113,4 +119,4 @@
|
|
|
113
119
|
@import './css/mds-modal-pref-animation.css';
|
|
114
120
|
@import './css/mds-modal-pref-contrast.css';
|
|
115
121
|
@import './css/mds-modal-pref-theme.css';
|
|
116
|
-
|
|
122
|
+
@import '../../tailwind/fouc.css';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import clsx from 'clsx'
|
|
2
2
|
import { Component, Element, Event, EventEmitter, Host, h, Listen, Prop, Watch } from '@stencil/core'
|
|
3
|
-
import { ModalPositionType, ModalAnimationStateType } from './meta/types'
|
|
3
|
+
import { ModalPositionType, ModalAnimationStateType, ModalOverflowType } from './meta/types'
|
|
4
4
|
import { cssDurationToMilliseconds } from '@common/unit'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -20,6 +20,7 @@ export class MdsModal {
|
|
|
20
20
|
private animationDelayTimeout: NodeJS.Timeout
|
|
21
21
|
private window = false
|
|
22
22
|
private top = false
|
|
23
|
+
private bodyOverflow: string
|
|
23
24
|
private bottom = false
|
|
24
25
|
private cssTransitionDuration: string
|
|
25
26
|
|
|
@@ -40,6 +41,11 @@ export class MdsModal {
|
|
|
40
41
|
*/
|
|
41
42
|
@Prop({ reflect: true, mutable: true }) animating?: ModalAnimationStateType = 'none'
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Specifies if the component prevents the body from scrolling when modal window is opened
|
|
46
|
+
*/
|
|
47
|
+
@Prop({ reflect: true }) readonly overflow: ModalOverflowType = 'auto'
|
|
48
|
+
|
|
43
49
|
/**
|
|
44
50
|
* Emits when a modal is closed
|
|
45
51
|
*/
|
|
@@ -69,6 +75,25 @@ export class MdsModal {
|
|
|
69
75
|
clearTimeout(this.animationDelayTimeout)
|
|
70
76
|
}
|
|
71
77
|
|
|
78
|
+
private disableOverflow = (): void => {
|
|
79
|
+
if (document) {
|
|
80
|
+
if (document.body.style.overflow) {
|
|
81
|
+
this.bodyOverflow = document.body.style.overflow
|
|
82
|
+
}
|
|
83
|
+
document.body.style.overflow = 'hidden'
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private enableOverflow = (): void => {
|
|
88
|
+
if (document) {
|
|
89
|
+
if (this.bodyOverflow) {
|
|
90
|
+
document.body.style.overflow = this.bodyOverflow
|
|
91
|
+
} else {
|
|
92
|
+
document.body.style.removeProperty('overflow')
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
72
97
|
private animateOpenWindow = (): void => {
|
|
73
98
|
this.animating = 'intro'
|
|
74
99
|
clearTimeout(this.animationDelayTimeout)
|
|
@@ -86,6 +111,10 @@ export class MdsModal {
|
|
|
86
111
|
this.top = this.host.querySelector('[slot="top"]') !== null
|
|
87
112
|
this.window = this.host.querySelector('[slot="window"]') !== null
|
|
88
113
|
|
|
114
|
+
if (this.overflow === 'auto' && this.opened) {
|
|
115
|
+
this.disableOverflow()
|
|
116
|
+
}
|
|
117
|
+
|
|
89
118
|
if (this.window) {
|
|
90
119
|
this.host.querySelector('[slot="window"]')?.setAttribute('role', 'dialog')
|
|
91
120
|
}
|
|
@@ -112,9 +141,15 @@ export class MdsModal {
|
|
|
112
141
|
@Watch('opened')
|
|
113
142
|
handleOpenProp (newValue: boolean): void {
|
|
114
143
|
if (newValue) {
|
|
144
|
+
if (this.overflow === 'auto') {
|
|
145
|
+
this.disableOverflow()
|
|
146
|
+
}
|
|
115
147
|
this.animateOpenWindow()
|
|
116
148
|
return
|
|
117
149
|
}
|
|
150
|
+
if (this.overflow === 'auto') {
|
|
151
|
+
this.enableOverflow()
|
|
152
|
+
}
|
|
118
153
|
this.animateCloseWindow()
|
|
119
154
|
}
|
|
120
155
|
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
## Properties
|
|
9
9
|
|
|
10
|
-
| Property | Attribute | Description
|
|
11
|
-
| ----------- | ----------- |
|
|
12
|
-
| `animating` | `animating` | Specifies if the component is animating itself or not
|
|
13
|
-
| `opened` | `opened` | Specifies if the modal is opened or not
|
|
14
|
-
| `
|
|
10
|
+
| Property | Attribute | Description | Type | Default |
|
|
11
|
+
| ----------- | ----------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------- |
|
|
12
|
+
| `animating` | `animating` | Specifies if the component is animating itself or not | `"intro" \| "none" \| "outro" \| undefined` | `'none'` |
|
|
13
|
+
| `opened` | `opened` | Specifies if the modal is opened or not | `boolean` | `false` |
|
|
14
|
+
| `overflow` | `overflow` | Specifies if the component prevents the body from scrolling when modal window is opened | `"auto" \| "manual"` | `'auto'` |
|
|
15
|
+
| `position` | `position` | Specifies the animation position of the modal window | `"bottom" \| "bottom-left" \| "bottom-right" \| "center" \| "left" \| "right" \| "top" \| "top-left" \| "top-right" \| undefined` | `'center'` |
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
## Events
|
|
@@ -41,17 +42,18 @@
|
|
|
41
42
|
|
|
42
43
|
## CSS Custom Properties
|
|
43
44
|
|
|
44
|
-
| Name
|
|
45
|
-
|
|
|
46
|
-
| `--mds-modal-close-icon-color`
|
|
47
|
-
| `--mds-modal-
|
|
48
|
-
| `--mds-modal-overlay-
|
|
49
|
-
| `--mds-modal-
|
|
50
|
-
| `--mds-modal-window-
|
|
51
|
-
| `--mds-modal-window-
|
|
52
|
-
| `--mds-modal-window-
|
|
53
|
-
| `--mds-modal-window-
|
|
54
|
-
| `--mds-modal-
|
|
45
|
+
| Name | Description |
|
|
46
|
+
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
47
|
+
| `--mds-modal-close-icon-color` | Set the color of the close icon button to the top left. |
|
|
48
|
+
| `--mds-modal-custom-window-distance` | Set the distance between the slotted modal window and the screen bounds |
|
|
49
|
+
| `--mds-modal-overlay-color` | Set the overlay color of the background when the component is opened, this property can be inherited from `globals.css` in `styles^8.0.0`. |
|
|
50
|
+
| `--mds-modal-overlay-opacity` | Set the overlay color opacity of the background when the component is opened, this property can be inherited from `globals.css` in `styles^8.0.0`. |
|
|
51
|
+
| `--mds-modal-window-background` | Set the background color of the window |
|
|
52
|
+
| `--mds-modal-window-distance` | Set the distance between the modal window and the screen bounds |
|
|
53
|
+
| `--mds-modal-window-overflow` | Set the overflow of the window |
|
|
54
|
+
| `--mds-modal-window-radius` | Set the border radius of the window |
|
|
55
|
+
| `--mds-modal-window-shadow` | Set the box shadow of the window |
|
|
56
|
+
| `--mds-modal-z-index` | Set the z-index of the window when the component is opened |
|
|
55
57
|
|
|
56
58
|
|
|
57
59
|
----------------------------------------------
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { h } from '@stencil/core'
|
|
3
3
|
import { useState } from 'react'
|
|
4
|
-
import { modalPositionDictionary } from '../meta/dictionary'
|
|
4
|
+
import { modalPositionDictionary, modalOverflowDictionary } from '../meta/dictionary'
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'UI / Modal',
|
|
@@ -10,6 +10,12 @@ export default {
|
|
|
10
10
|
description: 'Specifies if the modal is opened or not',
|
|
11
11
|
type: { name: 'boolean' },
|
|
12
12
|
},
|
|
13
|
+
overflow: {
|
|
14
|
+
description: 'Specifies if the component prevents the body from scrolling when modal window is opened',
|
|
15
|
+
control: { type: 'select' },
|
|
16
|
+
options: modalOverflowDictionary,
|
|
17
|
+
type: { name: 'string' },
|
|
18
|
+
},
|
|
13
19
|
position: {
|
|
14
20
|
control: { type: 'select' },
|
|
15
21
|
description: 'Specifies the animation position of the modal window',
|
|
@@ -27,7 +33,7 @@ const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@nintendo.com
|
|
|
27
33
|
const Template = args =>
|
|
28
34
|
<mds-modal {...args}>
|
|
29
35
|
<header slot="top" class="p-800 flex gap-400 items-center border-b border-solid border-0 border-tone-neutral-09 max-w-[400px]">
|
|
30
|
-
<mds-img class="w-1600" src="
|
|
36
|
+
<mds-img class="w-1600" src="./logo-gruppo-maggioli-512w.webp"/>
|
|
31
37
|
<div class="text-tone-neutral-02">
|
|
32
38
|
<mds-text typography="h5" class="truncate min-w-0">Maggioli Editore</mds-text>
|
|
33
39
|
<mds-text typography="detail" class="truncate min-w-0">Menu di servizio</mds-text>
|
|
@@ -40,7 +46,7 @@ const Template = args =>
|
|
|
40
46
|
</div>
|
|
41
47
|
<footer slot="bottom" class="p-800 flex gap-400 text-tone-neutral-02 border-t border-solid border-0 border-tone-neutral-09 max-w-[400px]">
|
|
42
48
|
<mds-author class="flex-grow">
|
|
43
|
-
<mds-avatar slot="avatar" class="w-1600 mobile:w-1200" src="
|
|
49
|
+
<mds-avatar slot="avatar" class="w-1600 mobile:w-1200" src="./avatar-01-200x200.jpeg"/>
|
|
44
50
|
<mds-text typography="h6">{ fullName }</mds-text>
|
|
45
51
|
<mds-text typography="caption" class="text-tone-neutral-04">{ email }</mds-text>
|
|
46
52
|
</mds-author>
|
|
@@ -48,6 +54,41 @@ const Template = args =>
|
|
|
48
54
|
</footer>
|
|
49
55
|
</mds-modal>
|
|
50
56
|
|
|
57
|
+
const TemplateOverflow = args =>
|
|
58
|
+
<div>
|
|
59
|
+
<div class="grid">
|
|
60
|
+
{Array(40).fill(null).map((_value, index) => (
|
|
61
|
+
<div key={index} class="h-[100px] flex items-start justify-center text-center border-0 border-t border-solid border-t-tone-neutral-07">
|
|
62
|
+
<mds-text class="px-200 py-100 rounded-b-lg bg-tone-neutral-10 border-t-0 border border-solid border-tone-neutral-07" typography="snippet" tag="div">
|
|
63
|
+
{ index === 0 ? '0px' : index + '00px' }
|
|
64
|
+
</mds-text>
|
|
65
|
+
</div>
|
|
66
|
+
))}
|
|
67
|
+
</div>
|
|
68
|
+
<mds-modal {...args}>
|
|
69
|
+
<header slot="top" class="p-800 flex gap-400 items-center border-b border-solid border-0 border-tone-neutral-09 max-w-[400px]">
|
|
70
|
+
<mds-img class="w-1600" src="./logo-gruppo-maggioli-512w.webp"/>
|
|
71
|
+
<div class="text-tone-neutral-02">
|
|
72
|
+
<mds-text typography="h5" class="truncate min-w-0">Maggioli Editore</mds-text>
|
|
73
|
+
<mds-text typography="detail" class="truncate min-w-0">Menu di servizio</mds-text>
|
|
74
|
+
</div>
|
|
75
|
+
</header>
|
|
76
|
+
<div class="p-800 max-w-[400px]">
|
|
77
|
+
<mds-text>
|
|
78
|
+
As a multi-brand design system, our components need to be flexible enough for any one of our brands to use them for multiple use cases. To achieve this, we ensure that all of the brands are involved in the specification stage, giving us more confidence that we’re future-proofing our components as more brands adopt NewsKit.
|
|
79
|
+
</mds-text>
|
|
80
|
+
</div>
|
|
81
|
+
<footer slot="bottom" class="p-800 flex gap-400 text-tone-neutral-02 border-t border-solid border-0 border-tone-neutral-09 max-w-[400px]">
|
|
82
|
+
<mds-author class="flex-grow">
|
|
83
|
+
<mds-avatar slot="avatar" class="w-1600 mobile:w-1200" src="./avatar-01-200x200.jpeg"/>
|
|
84
|
+
<mds-text typography="h6">{ fullName }</mds-text>
|
|
85
|
+
<mds-text typography="caption" class="text-tone-neutral-04">{ email }</mds-text>
|
|
86
|
+
</mds-author>
|
|
87
|
+
<mds-button icon="mdi/dots-vertical" variant="light"></mds-button>
|
|
88
|
+
</footer>
|
|
89
|
+
</mds-modal>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
51
92
|
const CustomTemplate = args =>
|
|
52
93
|
<mds-modal {...args}>
|
|
53
94
|
<mds-banner slot="window" class="max-w-xl mx-6" deletable headline="Action required">
|
|
@@ -80,15 +121,28 @@ const InteractiveTemplate = () => {
|
|
|
80
121
|
export const Default = Template.bind({})
|
|
81
122
|
Default.args = {
|
|
82
123
|
position: 'right',
|
|
124
|
+
opened: true,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const BodyOverflowDisabled = TemplateOverflow.bind({})
|
|
128
|
+
BodyOverflowDisabled.args = {
|
|
129
|
+
overflow: 'auto',
|
|
130
|
+
opened: true,
|
|
131
|
+
position: 'right',
|
|
83
132
|
}
|
|
84
133
|
|
|
85
134
|
export const DefaultWindowCustomized = Template.bind({})
|
|
86
135
|
DefaultWindowCustomized.args = {
|
|
87
136
|
position: 'right',
|
|
137
|
+
opened: true,
|
|
88
138
|
style: { '--mds-modal-window-distance': '1rem', '--mds-modal-window-radius': '1rem' },
|
|
89
139
|
}
|
|
90
140
|
export const CustomWindowElement = CustomTemplate.bind({})
|
|
141
|
+
CustomWindowElement.args = {
|
|
142
|
+
opened: true,
|
|
143
|
+
}
|
|
91
144
|
export const Interactive = InteractiveTemplate.bind({})
|
|
145
|
+
|
|
92
146
|
export const ARIATest = CustomTemplate.bind({})
|
|
93
147
|
ARIATest.args = {
|
|
94
148
|
opened: true,
|
package/src/components.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* It contains typing information for all components that exist in this project.
|
|
6
6
|
*/
|
|
7
7
|
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
|
|
8
|
-
import { ModalAnimationStateType, ModalPositionType } from "./components/mds-modal/meta/types";
|
|
9
|
-
export { ModalAnimationStateType, ModalPositionType } from "./components/mds-modal/meta/types";
|
|
8
|
+
import { ModalAnimationStateType, ModalOverflowType, ModalPositionType } from "./components/mds-modal/meta/types";
|
|
9
|
+
export { ModalAnimationStateType, ModalOverflowType, ModalPositionType } from "./components/mds-modal/meta/types";
|
|
10
10
|
export namespace Components {
|
|
11
11
|
interface MdsModal {
|
|
12
12
|
/**
|
|
@@ -17,6 +17,10 @@ export namespace Components {
|
|
|
17
17
|
* Specifies if the modal is opened or not
|
|
18
18
|
*/
|
|
19
19
|
"opened": boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Specifies if the component prevents the body from scrolling when modal window is opened
|
|
22
|
+
*/
|
|
23
|
+
"overflow": ModalOverflowType;
|
|
20
24
|
/**
|
|
21
25
|
* Specifies the animation position of the modal window
|
|
22
26
|
*/
|
|
@@ -68,6 +72,10 @@ declare namespace LocalJSX {
|
|
|
68
72
|
* Specifies if the modal is opened or not
|
|
69
73
|
*/
|
|
70
74
|
"opened"?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Specifies if the component prevents the body from scrolling when modal window is opened
|
|
77
|
+
*/
|
|
78
|
+
"overflow"?: ModalOverflowType;
|
|
71
79
|
/**
|
|
72
80
|
* Specifies the animation position of the modal window
|
|
73
81
|
*/
|