@mekari/pixel3-modal 0.0.1
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/body.d.mts +6 -0
- package/dist/body.d.ts +6 -0
- package/dist/body.js +63 -0
- package/dist/body.mjs +8 -0
- package/dist/chunk-2WYPEVZV.mjs +62 -0
- package/dist/chunk-7LGGLG42.mjs +77 -0
- package/dist/chunk-ASQKAMBD.mjs +37 -0
- package/dist/chunk-D4KITWKW.mjs +34 -0
- package/dist/chunk-DKUTSUEJ.mjs +8 -0
- package/dist/chunk-FU2Y3XYA.mjs +70 -0
- package/dist/chunk-FXPPG3HJ.mjs +24 -0
- package/dist/chunk-MO6AFEOO.mjs +285 -0
- package/dist/chunk-NCQFKFXL.mjs +69 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-THCDEEFK.mjs +24 -0
- package/dist/close-button.d.mts +6 -0
- package/dist/close-button.d.ts +6 -0
- package/dist/close-button.js +60 -0
- package/dist/close-button.mjs +8 -0
- package/dist/content.d.mts +28 -0
- package/dist/content.d.ts +28 -0
- package/dist/content.js +359 -0
- package/dist/content.mjs +10 -0
- package/dist/footer.d.mts +6 -0
- package/dist/footer.d.ts +6 -0
- package/dist/footer.js +48 -0
- package/dist/footer.mjs +7 -0
- package/dist/header.d.mts +6 -0
- package/dist/header.d.ts +6 -0
- package/dist/header.js +48 -0
- package/dist/header.mjs +7 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +668 -0
- package/dist/index.mjs +34 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modal.d.mts +103 -0
- package/dist/modal.d.ts +103 -0
- package/dist/modal.js +191 -0
- package/dist/modal.mjs +10 -0
- package/dist/modules/modal.context.d.mts +11 -0
- package/dist/modules/modal.context.d.ts +11 -0
- package/dist/modules/modal.context.js +33 -0
- package/dist/modules/modal.context.mjs +9 -0
- package/dist/modules/modal.props.d.mts +64 -0
- package/dist/modules/modal.props.d.ts +64 -0
- package/dist/modules/modal.props.js +88 -0
- package/dist/modules/modal.props.mjs +11 -0
- package/dist/modules/useModal.d.mts +28 -0
- package/dist/modules/useModal.d.ts +28 -0
- package/dist/modules/useModal.js +321 -0
- package/dist/modules/useModal.mjs +12 -0
- package/dist/overlay.d.mts +6 -0
- package/dist/overlay.d.ts +6 -0
- package/dist/overlay.js +104 -0
- package/dist/overlay.mjs +8 -0
- package/package.json +47 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
type BaseSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full';
|
|
4
|
+
type ScrollBehavior = 'inside' | 'outside' | 'auto';
|
|
5
|
+
type Placement = 'left' | 'right' | 'top' | 'bottom';
|
|
6
|
+
declare const modalProps: {
|
|
7
|
+
id: {
|
|
8
|
+
type: PropType<string>;
|
|
9
|
+
};
|
|
10
|
+
isOpen: {
|
|
11
|
+
type: PropType<boolean>;
|
|
12
|
+
default: boolean;
|
|
13
|
+
};
|
|
14
|
+
isBlockScrollOnMount: {
|
|
15
|
+
type: PropType<boolean>;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
isCloseOnEsc: {
|
|
19
|
+
type: PropType<boolean>;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
isCloseOnOverlayClick: {
|
|
23
|
+
type: PropType<boolean>;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
isKeepAlive: {
|
|
27
|
+
type: PropType<boolean>;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
isCentered: {
|
|
31
|
+
type: PropType<boolean>;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
scrollBehavior: {
|
|
35
|
+
type: PropType<ScrollBehavior>;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
size: {
|
|
39
|
+
type: PropType<BaseSize>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
isDisablePortal: {
|
|
43
|
+
type: PropType<boolean>;
|
|
44
|
+
default: boolean;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
declare const modalContentProps: {
|
|
48
|
+
type: {
|
|
49
|
+
type: PropType<"modal" | "drawer">;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
placement: {
|
|
53
|
+
type: PropType<Placement>;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
declare const modalEmits: {
|
|
58
|
+
open: (value: boolean) => boolean;
|
|
59
|
+
close: (value: boolean) => boolean;
|
|
60
|
+
};
|
|
61
|
+
type ModalProps = ExtractPropTypes<typeof modalProps>;
|
|
62
|
+
type ModalContentProps = ExtractPropTypes<typeof modalContentProps>;
|
|
63
|
+
|
|
64
|
+
export { BaseSize, ModalContentProps, ModalProps, Placement, ScrollBehavior, modalContentProps, modalEmits, modalProps };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/modules/modal.props.ts
|
|
21
|
+
var modal_props_exports = {};
|
|
22
|
+
__export(modal_props_exports, {
|
|
23
|
+
modalContentProps: () => modalContentProps,
|
|
24
|
+
modalEmits: () => modalEmits,
|
|
25
|
+
modalProps: () => modalProps
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(modal_props_exports);
|
|
28
|
+
var modalProps = {
|
|
29
|
+
id: {
|
|
30
|
+
type: String
|
|
31
|
+
},
|
|
32
|
+
isOpen: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
isBlockScrollOnMount: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
isCloseOnEsc: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
},
|
|
44
|
+
isCloseOnOverlayClick: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true
|
|
47
|
+
},
|
|
48
|
+
isKeepAlive: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
isCentered: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
scrollBehavior: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "outside"
|
|
59
|
+
},
|
|
60
|
+
size: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "md"
|
|
63
|
+
},
|
|
64
|
+
isDisablePortal: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: false
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var modalContentProps = {
|
|
70
|
+
type: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: "modal"
|
|
73
|
+
},
|
|
74
|
+
placement: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: "right"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var modalEmits = {
|
|
80
|
+
"open": (value) => value,
|
|
81
|
+
"close": (value) => value
|
|
82
|
+
};
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
modalContentProps,
|
|
86
|
+
modalEmits,
|
|
87
|
+
modalProps
|
|
88
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { BaseSize, ModalProps, ModalContentProps } from './modal.props.mjs';
|
|
3
|
+
|
|
4
|
+
declare const baseSizes: Record<BaseSize, string>;
|
|
5
|
+
declare function useModal(props: ModalProps, emit: CallableFunction): {
|
|
6
|
+
isModalOpen: vue.Ref<boolean>;
|
|
7
|
+
modalEl: vue.Ref<any>;
|
|
8
|
+
getId: vue.ComputedRef<string>;
|
|
9
|
+
onOpen: () => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare function useModalContent(props: ModalContentProps): {
|
|
13
|
+
wrapperEl: vue.Ref<any>;
|
|
14
|
+
isOpen: vue.Ref<boolean>;
|
|
15
|
+
isKeepAlive: vue.Ref<boolean>;
|
|
16
|
+
size: vue.Ref<BaseSize>;
|
|
17
|
+
inlineStyle: vue.ComputedRef<{
|
|
18
|
+
wrapperStyle: {};
|
|
19
|
+
contentStyle: {};
|
|
20
|
+
}>;
|
|
21
|
+
onOverlayClick: (e: Event) => void;
|
|
22
|
+
beforeEnterAnimation: (el: Element) => void;
|
|
23
|
+
enterAnimation: (el: HTMLElement, complete: () => void) => void;
|
|
24
|
+
leaveAnimation: (el: HTMLElement, complete: () => void) => void;
|
|
25
|
+
};
|
|
26
|
+
type UseModal = ReturnType<typeof useModal>;
|
|
27
|
+
|
|
28
|
+
export { UseModal, baseSizes, useModal, useModalContent };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { BaseSize, ModalProps, ModalContentProps } from './modal.props.js';
|
|
3
|
+
|
|
4
|
+
declare const baseSizes: Record<BaseSize, string>;
|
|
5
|
+
declare function useModal(props: ModalProps, emit: CallableFunction): {
|
|
6
|
+
isModalOpen: vue.Ref<boolean>;
|
|
7
|
+
modalEl: vue.Ref<any>;
|
|
8
|
+
getId: vue.ComputedRef<string>;
|
|
9
|
+
onOpen: () => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
};
|
|
12
|
+
declare function useModalContent(props: ModalContentProps): {
|
|
13
|
+
wrapperEl: vue.Ref<any>;
|
|
14
|
+
isOpen: vue.Ref<boolean>;
|
|
15
|
+
isKeepAlive: vue.Ref<boolean>;
|
|
16
|
+
size: vue.Ref<BaseSize>;
|
|
17
|
+
inlineStyle: vue.ComputedRef<{
|
|
18
|
+
wrapperStyle: {};
|
|
19
|
+
contentStyle: {};
|
|
20
|
+
}>;
|
|
21
|
+
onOverlayClick: (e: Event) => void;
|
|
22
|
+
beforeEnterAnimation: (el: Element) => void;
|
|
23
|
+
enterAnimation: (el: HTMLElement, complete: () => void) => void;
|
|
24
|
+
leaveAnimation: (el: HTMLElement, complete: () => void) => void;
|
|
25
|
+
};
|
|
26
|
+
type UseModal = ReturnType<typeof useModal>;
|
|
27
|
+
|
|
28
|
+
export { UseModal, baseSizes, useModal, useModalContent };
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/modules/useModal.ts
|
|
32
|
+
var useModal_exports = {};
|
|
33
|
+
__export(useModal_exports, {
|
|
34
|
+
baseSizes: () => baseSizes,
|
|
35
|
+
useModal: () => useModal,
|
|
36
|
+
useModalContent: () => useModalContent
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(useModal_exports);
|
|
39
|
+
var import_vue = require("vue");
|
|
40
|
+
var import_pixel3_utils2 = require("@mekari/pixel3-utils");
|
|
41
|
+
var import_body_scroll_lock = require("body-scroll-lock");
|
|
42
|
+
|
|
43
|
+
// src/modules/modal.context.ts
|
|
44
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
45
|
+
var [ModalProvider, useModalContext] = (0, import_pixel3_utils.usePixelCreateContext)("ModalContext");
|
|
46
|
+
|
|
47
|
+
// src/modules/useModal.ts
|
|
48
|
+
var import_animejs = __toESM(require("animejs"));
|
|
49
|
+
var import_pixel3_utils3 = require("@mekari/pixel3-utils");
|
|
50
|
+
var baseSizes = {
|
|
51
|
+
sm: "330px",
|
|
52
|
+
md: "448px",
|
|
53
|
+
lg: "684px",
|
|
54
|
+
xl: "920px",
|
|
55
|
+
"2xl": "1152px",
|
|
56
|
+
full: "100%"
|
|
57
|
+
};
|
|
58
|
+
function useModal(props, emit) {
|
|
59
|
+
const isModalOpen = (0, import_vue.ref)(props.isOpen);
|
|
60
|
+
const modalEl = (0, import_vue.ref)();
|
|
61
|
+
const getId = (0, import_vue.computed)(() => props.id || (0, import_pixel3_utils2.useId)(4));
|
|
62
|
+
function onOpen() {
|
|
63
|
+
isModalOpen.value = true;
|
|
64
|
+
if (props.isBlockScrollOnMount) {
|
|
65
|
+
(0, import_vue.nextTick)(() => {
|
|
66
|
+
(0, import_body_scroll_lock.disableBodyScroll)(modalEl.value);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
emit("open", true);
|
|
70
|
+
}
|
|
71
|
+
__name(onOpen, "onOpen");
|
|
72
|
+
function onClose() {
|
|
73
|
+
if (props.isBlockScrollOnMount) {
|
|
74
|
+
(0, import_body_scroll_lock.enableBodyScroll)(modalEl.value);
|
|
75
|
+
}
|
|
76
|
+
emit("close", true);
|
|
77
|
+
}
|
|
78
|
+
__name(onClose, "onClose");
|
|
79
|
+
return {
|
|
80
|
+
isModalOpen,
|
|
81
|
+
modalEl,
|
|
82
|
+
getId,
|
|
83
|
+
onOpen,
|
|
84
|
+
onClose
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
__name(useModal, "useModal");
|
|
88
|
+
function useModalContent(props) {
|
|
89
|
+
const {
|
|
90
|
+
props: modalProps,
|
|
91
|
+
onClose,
|
|
92
|
+
isModalOpen
|
|
93
|
+
} = useModalContext();
|
|
94
|
+
const {
|
|
95
|
+
isCloseOnOverlayClick,
|
|
96
|
+
isOpen,
|
|
97
|
+
isCloseOnEsc,
|
|
98
|
+
isKeepAlive,
|
|
99
|
+
size,
|
|
100
|
+
isCentered,
|
|
101
|
+
scrollBehavior
|
|
102
|
+
} = modalProps;
|
|
103
|
+
const wrapperEl = (0, import_vue.ref)();
|
|
104
|
+
const inlineStyle = (0, import_vue.computed)(() => {
|
|
105
|
+
let wrapperStyle = {};
|
|
106
|
+
let contentStyle = {};
|
|
107
|
+
if (isCentered == null ? void 0 : isCentered.value) {
|
|
108
|
+
wrapperStyle = {
|
|
109
|
+
display: "flex",
|
|
110
|
+
alignItems: "center",
|
|
111
|
+
justifyContent: "center"
|
|
112
|
+
};
|
|
113
|
+
} else {
|
|
114
|
+
contentStyle = {
|
|
115
|
+
top: "3.75rem",
|
|
116
|
+
mx: "auto"
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (scrollBehavior.value === "inside") {
|
|
120
|
+
wrapperStyle = {
|
|
121
|
+
...wrapperStyle,
|
|
122
|
+
maxHeight: "calc(100vh - 7.5rem)",
|
|
123
|
+
overflow: "hidden",
|
|
124
|
+
top: "3.75rem"
|
|
125
|
+
};
|
|
126
|
+
contentStyle = {
|
|
127
|
+
...contentStyle,
|
|
128
|
+
height: "100%",
|
|
129
|
+
top: 0
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (scrollBehavior.value === "outside") {
|
|
133
|
+
wrapperStyle = {
|
|
134
|
+
...wrapperStyle,
|
|
135
|
+
overflowY: "auto",
|
|
136
|
+
overflowX: "hidden"
|
|
137
|
+
};
|
|
138
|
+
contentStyle = {
|
|
139
|
+
...contentStyle,
|
|
140
|
+
my: "3.75rem",
|
|
141
|
+
top: 0
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (scrollBehavior.value === "auto") {
|
|
145
|
+
wrapperStyle = {
|
|
146
|
+
...wrapperStyle,
|
|
147
|
+
maxHeight: "calc(100vh - 7.5rem)",
|
|
148
|
+
overflow: "hidden",
|
|
149
|
+
top: "3.75rem"
|
|
150
|
+
};
|
|
151
|
+
contentStyle = {
|
|
152
|
+
...contentStyle,
|
|
153
|
+
height: "auto",
|
|
154
|
+
maxHeight: "calc(100vh - 7.5rem)",
|
|
155
|
+
top: 0
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (size.value === "full" || props.type === "drawer") {
|
|
159
|
+
wrapperStyle = {};
|
|
160
|
+
contentStyle = {};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
wrapperStyle,
|
|
164
|
+
contentStyle
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
const {
|
|
168
|
+
activate: activeFocusTrap,
|
|
169
|
+
deactivate: deactivateFocusTrap
|
|
170
|
+
} = (0, import_pixel3_utils3.useFocusTrap)(wrapperEl);
|
|
171
|
+
function onOverlayClick(e) {
|
|
172
|
+
if (isOpen.value && isCloseOnOverlayClick.value && e.target === wrapperEl.value) {
|
|
173
|
+
onClose();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
__name(onOverlayClick, "onOverlayClick");
|
|
177
|
+
const onKeydown = /* @__PURE__ */ __name((event) => {
|
|
178
|
+
if (event.key === "Escape" && isCloseOnEsc.value) {
|
|
179
|
+
onClose();
|
|
180
|
+
}
|
|
181
|
+
}, "onKeydown");
|
|
182
|
+
const getTransition = (0, import_vue.computed)(() => {
|
|
183
|
+
const duration = size.value === "full" ? 400 : 300;
|
|
184
|
+
let enter = {};
|
|
185
|
+
let leave = {};
|
|
186
|
+
if (props.type === "modal") {
|
|
187
|
+
enter = {
|
|
188
|
+
opacity: [0, 1],
|
|
189
|
+
scale: [0.95, 1],
|
|
190
|
+
translateY: ["16px", "0px"],
|
|
191
|
+
easing: "easeOutSine",
|
|
192
|
+
duration
|
|
193
|
+
};
|
|
194
|
+
leave = {
|
|
195
|
+
opacity: [1, 0],
|
|
196
|
+
scale: [1, 0.95],
|
|
197
|
+
translateY: ["0px", "16px"],
|
|
198
|
+
easing: "easeInSine",
|
|
199
|
+
duration: 300
|
|
200
|
+
};
|
|
201
|
+
return {
|
|
202
|
+
enter,
|
|
203
|
+
leave
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (props.type === "drawer") {
|
|
207
|
+
if (props.placement === "right") {
|
|
208
|
+
enter = {
|
|
209
|
+
translateX(el) {
|
|
210
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
211
|
+
return [translateWidth, "0px"];
|
|
212
|
+
},
|
|
213
|
+
easing: "easeInOutSine",
|
|
214
|
+
duration: 500
|
|
215
|
+
};
|
|
216
|
+
leave = {
|
|
217
|
+
translateX: ["0px", "100%"],
|
|
218
|
+
easing: "easeInOutSine",
|
|
219
|
+
duration: 500
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (props.placement === "left") {
|
|
223
|
+
enter = {
|
|
224
|
+
translateX(el) {
|
|
225
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
226
|
+
return [`-${translateWidth}`, "0px"];
|
|
227
|
+
},
|
|
228
|
+
easing: "easeInOutSine",
|
|
229
|
+
duration: 500
|
|
230
|
+
};
|
|
231
|
+
leave = {
|
|
232
|
+
translateX: ["0px", "-100%"],
|
|
233
|
+
easing: "easeInOutSine",
|
|
234
|
+
duration: 500
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
if (props.placement === "top") {
|
|
238
|
+
enter = {
|
|
239
|
+
translateY(el) {
|
|
240
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
241
|
+
return [`-${translateWidth}`, "0px"];
|
|
242
|
+
},
|
|
243
|
+
easing: "easeInOutSine",
|
|
244
|
+
duration: 500
|
|
245
|
+
};
|
|
246
|
+
leave = {
|
|
247
|
+
translateY: ["0px", "-100%"],
|
|
248
|
+
easing: "easeInOutSine",
|
|
249
|
+
duration: 500
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
if (props.placement === "bottom") {
|
|
253
|
+
enter = {
|
|
254
|
+
translateY(el) {
|
|
255
|
+
const translateWidth = size.value === "full" ? el.clientWidth : baseSizes[size.value];
|
|
256
|
+
return [`${translateWidth}`, "0px"];
|
|
257
|
+
},
|
|
258
|
+
easing: "easeInOutSine",
|
|
259
|
+
duration: 500
|
|
260
|
+
};
|
|
261
|
+
leave = {
|
|
262
|
+
translateY: ["0px", "100%"],
|
|
263
|
+
easing: "easeInOutSine",
|
|
264
|
+
duration: 500
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
enter,
|
|
270
|
+
leave
|
|
271
|
+
};
|
|
272
|
+
});
|
|
273
|
+
const beforeEnterAnimation = /* @__PURE__ */ __name((el) => {
|
|
274
|
+
el && el.style.setProperty("will-change", "opacity, transform", "scale");
|
|
275
|
+
}, "beforeEnterAnimation");
|
|
276
|
+
const enterAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
277
|
+
(0, import_animejs.default)({
|
|
278
|
+
targets: el,
|
|
279
|
+
...getTransition.value.enter,
|
|
280
|
+
complete: () => {
|
|
281
|
+
if (isOpen.value) {
|
|
282
|
+
complete();
|
|
283
|
+
document.addEventListener("keydown", onKeydown);
|
|
284
|
+
activeFocusTrap();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}, "enterAnimation");
|
|
289
|
+
const leaveAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
290
|
+
deactivateFocusTrap();
|
|
291
|
+
(0, import_animejs.default)({
|
|
292
|
+
targets: el,
|
|
293
|
+
...getTransition.value.leave,
|
|
294
|
+
complete: () => {
|
|
295
|
+
complete();
|
|
296
|
+
isModalOpen.value = false;
|
|
297
|
+
document.removeEventListener("keydown", onKeydown);
|
|
298
|
+
onClose();
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
}, "leaveAnimation");
|
|
302
|
+
return {
|
|
303
|
+
wrapperEl,
|
|
304
|
+
isOpen,
|
|
305
|
+
isKeepAlive,
|
|
306
|
+
size,
|
|
307
|
+
inlineStyle,
|
|
308
|
+
onOverlayClick,
|
|
309
|
+
// Animation
|
|
310
|
+
beforeEnterAnimation,
|
|
311
|
+
enterAnimation,
|
|
312
|
+
leaveAnimation
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
__name(useModalContent, "useModalContent");
|
|
316
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
317
|
+
0 && (module.exports = {
|
|
318
|
+
baseSizes,
|
|
319
|
+
useModal,
|
|
320
|
+
useModalContent
|
|
321
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
declare const MpModalOverlay: vue.DefineComponent<{}, () => vue_jsx_runtime.JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
|
|
5
|
+
|
|
6
|
+
export { MpModalOverlay };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
declare const MpModalOverlay: vue.DefineComponent<{}, () => vue_jsx_runtime.JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
|
|
5
|
+
|
|
6
|
+
export { MpModalOverlay };
|
package/dist/overlay.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// src/overlay.tsx
|
|
32
|
+
var overlay_exports = {};
|
|
33
|
+
__export(overlay_exports, {
|
|
34
|
+
MpModalOverlay: () => MpModalOverlay
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(overlay_exports);
|
|
37
|
+
var import_vue = require("vue");
|
|
38
|
+
var import_vue2 = require("vue");
|
|
39
|
+
var import_animejs = __toESM(require("animejs"));
|
|
40
|
+
|
|
41
|
+
// src/modules/modal.context.ts
|
|
42
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
43
|
+
var [ModalProvider, useModalContext] = (0, import_pixel3_utils.usePixelCreateContext)("ModalContext");
|
|
44
|
+
|
|
45
|
+
// src/overlay.tsx
|
|
46
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
47
|
+
var MpModalOverlay = (0, import_vue2.defineComponent)({
|
|
48
|
+
name: "MpModalOverlay",
|
|
49
|
+
setup(_props, {
|
|
50
|
+
slots
|
|
51
|
+
}) {
|
|
52
|
+
const {
|
|
53
|
+
overlay
|
|
54
|
+
} = (0, import_recipes.modalSlotRecipe)();
|
|
55
|
+
const {
|
|
56
|
+
props: modalProps
|
|
57
|
+
} = useModalContext();
|
|
58
|
+
const {
|
|
59
|
+
isOpen,
|
|
60
|
+
isKeepAlive
|
|
61
|
+
} = modalProps;
|
|
62
|
+
const handleBeforeEnter = /* @__PURE__ */ __name((el) => {
|
|
63
|
+
el && el.style.setProperty("will-change", "opacity, transform", "scale");
|
|
64
|
+
}, "handleBeforeEnter");
|
|
65
|
+
const enterAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
66
|
+
(0, import_animejs.default)({
|
|
67
|
+
targets: el,
|
|
68
|
+
opacity: [0, 1],
|
|
69
|
+
easing: "easeOutSine",
|
|
70
|
+
duration: 300,
|
|
71
|
+
complete
|
|
72
|
+
});
|
|
73
|
+
}, "enterAnimation");
|
|
74
|
+
const leaveAnimation = /* @__PURE__ */ __name((el, complete) => {
|
|
75
|
+
(0, import_animejs.default)({
|
|
76
|
+
targets: el,
|
|
77
|
+
opacity: [1, 0],
|
|
78
|
+
easing: "easeInSine",
|
|
79
|
+
duration: 300,
|
|
80
|
+
complete
|
|
81
|
+
});
|
|
82
|
+
}, "leaveAnimation");
|
|
83
|
+
return () => {
|
|
84
|
+
const overlayNode = (0, import_vue.withDirectives)((0, import_vue.createVNode)("div", {
|
|
85
|
+
"data-pixel-component": "MpModalOverlay",
|
|
86
|
+
"class": overlay
|
|
87
|
+
}, [slots.default && slots.default()]), [[import_vue.vShow, isOpen.value]]);
|
|
88
|
+
const withConditionalRender = isOpen.value ? overlayNode : null;
|
|
89
|
+
return (0, import_vue.createVNode)(import_vue2.Transition, {
|
|
90
|
+
"css": false,
|
|
91
|
+
"appear": true,
|
|
92
|
+
"onBeforeEnter": (el) => handleBeforeEnter(el),
|
|
93
|
+
"onEnter": (el, complete) => enterAnimation(el, complete),
|
|
94
|
+
"onLeave": (el, complete) => leaveAnimation(el, complete)
|
|
95
|
+
}, {
|
|
96
|
+
default: () => [isKeepAlive.value ? overlayNode : withConditionalRender]
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
MpModalOverlay
|
|
104
|
+
});
|