@mekari/pixel3-transition 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/animate-height.d.mts +84 -0
- package/dist/animate-height.d.ts +84 -0
- package/dist/animate-height.js +184 -0
- package/dist/animate-height.mjs +9 -0
- package/dist/chunk-7BE634W2.mjs +35 -0
- package/dist/chunk-F65UX7S5.mjs +90 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-SQMYD3AJ.mjs +39 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +186 -0
- package/dist/index.mjs +9 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modules/transition.props.d.mts +40 -0
- package/dist/modules/transition.props.d.ts +40 -0
- package/dist/modules/transition.props.js +63 -0
- package/dist/modules/transition.props.mjs +7 -0
- package/dist/modules/useAnimateHeight.d.mts +9 -0
- package/dist/modules/useAnimateHeight.d.ts +9 -0
- package/dist/modules/useAnimateHeight.js +121 -0
- package/dist/modules/useAnimateHeight.mjs +7 -0
- package/package.json +44 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
2
|
+
import * as vue from 'vue';
|
|
3
|
+
|
|
4
|
+
declare const MpAnimateHeight: vue.DefineComponent<{
|
|
5
|
+
as: {
|
|
6
|
+
type: vue.PropType<keyof HTMLElementTagNameMap>;
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
isOpen: {
|
|
10
|
+
type: vue.PropType<boolean>;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
initialHeight: {
|
|
14
|
+
type: vue.PropType<number>;
|
|
15
|
+
default: number;
|
|
16
|
+
};
|
|
17
|
+
duration: {
|
|
18
|
+
type: vue.PropType<number>;
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
enterEasing: {
|
|
22
|
+
type: vue.PropType<string>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
leaveEasing: {
|
|
26
|
+
type: vue.PropType<string>;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
finalHeight: {
|
|
30
|
+
type: vue.PropType<number>;
|
|
31
|
+
default: number;
|
|
32
|
+
};
|
|
33
|
+
animateOpacity: {
|
|
34
|
+
type: vue.PropType<boolean>;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("enter" | "leave")[], "enter" | "leave", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
38
|
+
as: {
|
|
39
|
+
type: vue.PropType<keyof HTMLElementTagNameMap>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
isOpen: {
|
|
43
|
+
type: vue.PropType<boolean>;
|
|
44
|
+
default: boolean;
|
|
45
|
+
};
|
|
46
|
+
initialHeight: {
|
|
47
|
+
type: vue.PropType<number>;
|
|
48
|
+
default: number;
|
|
49
|
+
};
|
|
50
|
+
duration: {
|
|
51
|
+
type: vue.PropType<number>;
|
|
52
|
+
default: number;
|
|
53
|
+
};
|
|
54
|
+
enterEasing: {
|
|
55
|
+
type: vue.PropType<string>;
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
leaveEasing: {
|
|
59
|
+
type: vue.PropType<string>;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
finalHeight: {
|
|
63
|
+
type: vue.PropType<number>;
|
|
64
|
+
default: number;
|
|
65
|
+
};
|
|
66
|
+
animateOpacity: {
|
|
67
|
+
type: vue.PropType<boolean>;
|
|
68
|
+
default: boolean;
|
|
69
|
+
};
|
|
70
|
+
}>> & {
|
|
71
|
+
onEnter?: ((...args: any[]) => any) | undefined;
|
|
72
|
+
onLeave?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
as: keyof HTMLElementTagNameMap;
|
|
75
|
+
isOpen: boolean;
|
|
76
|
+
initialHeight: number;
|
|
77
|
+
duration: number;
|
|
78
|
+
enterEasing: string;
|
|
79
|
+
leaveEasing: string;
|
|
80
|
+
finalHeight: number;
|
|
81
|
+
animateOpacity: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
export { MpAnimateHeight };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as vue_jsx_runtime from 'vue/jsx-runtime';
|
|
2
|
+
import * as vue from 'vue';
|
|
3
|
+
|
|
4
|
+
declare const MpAnimateHeight: vue.DefineComponent<{
|
|
5
|
+
as: {
|
|
6
|
+
type: vue.PropType<keyof HTMLElementTagNameMap>;
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
isOpen: {
|
|
10
|
+
type: vue.PropType<boolean>;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
initialHeight: {
|
|
14
|
+
type: vue.PropType<number>;
|
|
15
|
+
default: number;
|
|
16
|
+
};
|
|
17
|
+
duration: {
|
|
18
|
+
type: vue.PropType<number>;
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
enterEasing: {
|
|
22
|
+
type: vue.PropType<string>;
|
|
23
|
+
default: string;
|
|
24
|
+
};
|
|
25
|
+
leaveEasing: {
|
|
26
|
+
type: vue.PropType<string>;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
finalHeight: {
|
|
30
|
+
type: vue.PropType<number>;
|
|
31
|
+
default: number;
|
|
32
|
+
};
|
|
33
|
+
animateOpacity: {
|
|
34
|
+
type: vue.PropType<boolean>;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("enter" | "leave")[], "enter" | "leave", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
38
|
+
as: {
|
|
39
|
+
type: vue.PropType<keyof HTMLElementTagNameMap>;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
isOpen: {
|
|
43
|
+
type: vue.PropType<boolean>;
|
|
44
|
+
default: boolean;
|
|
45
|
+
};
|
|
46
|
+
initialHeight: {
|
|
47
|
+
type: vue.PropType<number>;
|
|
48
|
+
default: number;
|
|
49
|
+
};
|
|
50
|
+
duration: {
|
|
51
|
+
type: vue.PropType<number>;
|
|
52
|
+
default: number;
|
|
53
|
+
};
|
|
54
|
+
enterEasing: {
|
|
55
|
+
type: vue.PropType<string>;
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
leaveEasing: {
|
|
59
|
+
type: vue.PropType<string>;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
finalHeight: {
|
|
63
|
+
type: vue.PropType<number>;
|
|
64
|
+
default: number;
|
|
65
|
+
};
|
|
66
|
+
animateOpacity: {
|
|
67
|
+
type: vue.PropType<boolean>;
|
|
68
|
+
default: boolean;
|
|
69
|
+
};
|
|
70
|
+
}>> & {
|
|
71
|
+
onEnter?: ((...args: any[]) => any) | undefined;
|
|
72
|
+
onLeave?: ((...args: any[]) => any) | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
as: keyof HTMLElementTagNameMap;
|
|
75
|
+
isOpen: boolean;
|
|
76
|
+
initialHeight: number;
|
|
77
|
+
duration: number;
|
|
78
|
+
enterEasing: string;
|
|
79
|
+
leaveEasing: string;
|
|
80
|
+
finalHeight: number;
|
|
81
|
+
animateOpacity: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
|
|
84
|
+
export { MpAnimateHeight };
|
|
@@ -0,0 +1,184 @@
|
|
|
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/animate-height.tsx
|
|
32
|
+
var animate_height_exports = {};
|
|
33
|
+
__export(animate_height_exports, {
|
|
34
|
+
MpAnimateHeight: () => MpAnimateHeight
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(animate_height_exports);
|
|
37
|
+
var import_vue2 = require("vue");
|
|
38
|
+
var import_vue3 = require("vue");
|
|
39
|
+
|
|
40
|
+
// src/modules/transition.props.ts
|
|
41
|
+
var animateHeightProps = {
|
|
42
|
+
as: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: "div"
|
|
45
|
+
},
|
|
46
|
+
isOpen: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
initialHeight: {
|
|
51
|
+
type: Number,
|
|
52
|
+
default: 0
|
|
53
|
+
},
|
|
54
|
+
duration: {
|
|
55
|
+
type: Number,
|
|
56
|
+
default: 250
|
|
57
|
+
},
|
|
58
|
+
enterEasing: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "easeInOutSine"
|
|
61
|
+
},
|
|
62
|
+
leaveEasing: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: "easeInOutSine"
|
|
65
|
+
},
|
|
66
|
+
finalHeight: {
|
|
67
|
+
type: Number,
|
|
68
|
+
default: 0
|
|
69
|
+
},
|
|
70
|
+
animateOpacity: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: true
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/modules/useAnimateHeight.ts
|
|
77
|
+
var import_animejs = __toESM(require("animejs"));
|
|
78
|
+
var import_vue = require("vue");
|
|
79
|
+
function useAnimateHeight(props, emit) {
|
|
80
|
+
const currentEl = (0, import_vue.ref)();
|
|
81
|
+
const isFirstRender = (0, import_vue.ref)(true);
|
|
82
|
+
function enter() {
|
|
83
|
+
const el = currentEl.value;
|
|
84
|
+
emit("enter", currentEl);
|
|
85
|
+
el.style.visibility = "hidden";
|
|
86
|
+
el.style.height = props.finalHeight || "auto";
|
|
87
|
+
const {
|
|
88
|
+
height
|
|
89
|
+
} = getComputedStyle(el);
|
|
90
|
+
el.style.height = props.initialHeight || 0;
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
el.style.visibility = "visible";
|
|
93
|
+
(0, import_animejs.default)({
|
|
94
|
+
targets: el,
|
|
95
|
+
...props.animateOpacity && {
|
|
96
|
+
opacity: [0, 1]
|
|
97
|
+
},
|
|
98
|
+
height: [props.initialHeight || 0, props.finalHeight || height],
|
|
99
|
+
easing: props.enterEasing,
|
|
100
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
101
|
+
complete: () => {
|
|
102
|
+
isFirstRender.value = false;
|
|
103
|
+
el.style.height = props.finalHeight || "auto";
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
__name(enter, "enter");
|
|
109
|
+
function leave() {
|
|
110
|
+
const el = currentEl.value;
|
|
111
|
+
emit("leave", currentEl);
|
|
112
|
+
const {
|
|
113
|
+
height
|
|
114
|
+
} = getComputedStyle(el);
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
(0, import_animejs.default)({
|
|
117
|
+
targets: el,
|
|
118
|
+
...props.animateOpacity && {
|
|
119
|
+
opacity: [1, 0]
|
|
120
|
+
},
|
|
121
|
+
height: [props.finalHeight || height, props.initialHeight || 0],
|
|
122
|
+
easing: props.leaveEasing,
|
|
123
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
124
|
+
complete: () => {
|
|
125
|
+
isFirstRender.value = false;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
__name(leave, "leave");
|
|
131
|
+
(0, import_vue.watch)(() => props.isOpen, (isOpen) => {
|
|
132
|
+
if (isOpen) {
|
|
133
|
+
(0, import_vue.nextTick)(() => {
|
|
134
|
+
enter();
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
(0, import_vue.nextTick)(() => {
|
|
138
|
+
leave();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
immediate: true
|
|
143
|
+
});
|
|
144
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
145
|
+
return {
|
|
146
|
+
ref: currentEl,
|
|
147
|
+
"data-pixel-component": "MpAnimateHeight",
|
|
148
|
+
style: {
|
|
149
|
+
overflow: props.isOpen ? "visible" : "hidden"
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
rootAttrs
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
__name(useAnimateHeight, "useAnimateHeight");
|
|
158
|
+
|
|
159
|
+
// src/animate-height.tsx
|
|
160
|
+
var MpAnimateHeight = (0, import_vue3.defineComponent)({
|
|
161
|
+
name: "MpAnimateHeight",
|
|
162
|
+
props: animateHeightProps,
|
|
163
|
+
emits: ["enter", "leave"],
|
|
164
|
+
setup(props, {
|
|
165
|
+
slots,
|
|
166
|
+
emit
|
|
167
|
+
}) {
|
|
168
|
+
const {
|
|
169
|
+
rootAttrs
|
|
170
|
+
} = useAnimateHeight(props, emit);
|
|
171
|
+
return () => {
|
|
172
|
+
const {
|
|
173
|
+
as: Component
|
|
174
|
+
} = props;
|
|
175
|
+
return (0, import_vue2.createVNode)(Component, rootAttrs.value, {
|
|
176
|
+
default: () => [slots.default && slots.default()]
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
182
|
+
0 && (module.exports = {
|
|
183
|
+
MpAnimateHeight
|
|
184
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
animateHeightProps
|
|
3
|
+
} from "./chunk-SQMYD3AJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useAnimateHeight
|
|
6
|
+
} from "./chunk-F65UX7S5.mjs";
|
|
7
|
+
|
|
8
|
+
// src/animate-height.tsx
|
|
9
|
+
import { createVNode as _createVNode } from "vue";
|
|
10
|
+
import { defineComponent } from "vue";
|
|
11
|
+
var MpAnimateHeight = defineComponent({
|
|
12
|
+
name: "MpAnimateHeight",
|
|
13
|
+
props: animateHeightProps,
|
|
14
|
+
emits: ["enter", "leave"],
|
|
15
|
+
setup(props, {
|
|
16
|
+
slots,
|
|
17
|
+
emit
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
rootAttrs
|
|
21
|
+
} = useAnimateHeight(props, emit);
|
|
22
|
+
return () => {
|
|
23
|
+
const {
|
|
24
|
+
as: Component
|
|
25
|
+
} = props;
|
|
26
|
+
return _createVNode(Component, rootAttrs.value, {
|
|
27
|
+
default: () => [slots.default && slots.default()]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
MpAnimateHeight
|
|
35
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/modules/useAnimateHeight.ts
|
|
6
|
+
import anime from "animejs";
|
|
7
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
8
|
+
function useAnimateHeight(props, emit) {
|
|
9
|
+
const currentEl = ref();
|
|
10
|
+
const isFirstRender = ref(true);
|
|
11
|
+
function enter() {
|
|
12
|
+
const el = currentEl.value;
|
|
13
|
+
emit("enter", currentEl);
|
|
14
|
+
el.style.visibility = "hidden";
|
|
15
|
+
el.style.height = props.finalHeight || "auto";
|
|
16
|
+
const {
|
|
17
|
+
height
|
|
18
|
+
} = getComputedStyle(el);
|
|
19
|
+
el.style.height = props.initialHeight || 0;
|
|
20
|
+
requestAnimationFrame(() => {
|
|
21
|
+
el.style.visibility = "visible";
|
|
22
|
+
anime({
|
|
23
|
+
targets: el,
|
|
24
|
+
...props.animateOpacity && {
|
|
25
|
+
opacity: [0, 1]
|
|
26
|
+
},
|
|
27
|
+
height: [props.initialHeight || 0, props.finalHeight || height],
|
|
28
|
+
easing: props.enterEasing,
|
|
29
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
30
|
+
complete: () => {
|
|
31
|
+
isFirstRender.value = false;
|
|
32
|
+
el.style.height = props.finalHeight || "auto";
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
__name(enter, "enter");
|
|
38
|
+
function leave() {
|
|
39
|
+
const el = currentEl.value;
|
|
40
|
+
emit("leave", currentEl);
|
|
41
|
+
const {
|
|
42
|
+
height
|
|
43
|
+
} = getComputedStyle(el);
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
anime({
|
|
46
|
+
targets: el,
|
|
47
|
+
...props.animateOpacity && {
|
|
48
|
+
opacity: [1, 0]
|
|
49
|
+
},
|
|
50
|
+
height: [props.finalHeight || height, props.initialHeight || 0],
|
|
51
|
+
easing: props.leaveEasing,
|
|
52
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
53
|
+
complete: () => {
|
|
54
|
+
isFirstRender.value = false;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
__name(leave, "leave");
|
|
60
|
+
watch(() => props.isOpen, (isOpen) => {
|
|
61
|
+
if (isOpen) {
|
|
62
|
+
nextTick(() => {
|
|
63
|
+
enter();
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
nextTick(() => {
|
|
67
|
+
leave();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
immediate: true
|
|
72
|
+
});
|
|
73
|
+
const rootAttrs = computed(() => {
|
|
74
|
+
return {
|
|
75
|
+
ref: currentEl,
|
|
76
|
+
"data-pixel-component": "MpAnimateHeight",
|
|
77
|
+
style: {
|
|
78
|
+
overflow: props.isOpen ? "visible" : "hidden"
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
rootAttrs
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
__name(useAnimateHeight, "useAnimateHeight");
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
useAnimateHeight
|
|
90
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/modules/transition.props.ts
|
|
2
|
+
var animateHeightProps = {
|
|
3
|
+
as: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: "div"
|
|
6
|
+
},
|
|
7
|
+
isOpen: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false
|
|
10
|
+
},
|
|
11
|
+
initialHeight: {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 0
|
|
14
|
+
},
|
|
15
|
+
duration: {
|
|
16
|
+
type: Number,
|
|
17
|
+
default: 250
|
|
18
|
+
},
|
|
19
|
+
enterEasing: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "easeInOutSine"
|
|
22
|
+
},
|
|
23
|
+
leaveEasing: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "easeInOutSine"
|
|
26
|
+
},
|
|
27
|
+
finalHeight: {
|
|
28
|
+
type: Number,
|
|
29
|
+
default: 0
|
|
30
|
+
},
|
|
31
|
+
animateOpacity: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: true
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
animateHeightProps
|
|
39
|
+
};
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
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/index.tsx
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
|
+
MpAnimateHeight: () => MpAnimateHeight
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
|
|
38
|
+
// src/animate-height.tsx
|
|
39
|
+
var import_vue2 = require("vue");
|
|
40
|
+
var import_vue3 = require("vue");
|
|
41
|
+
|
|
42
|
+
// src/modules/transition.props.ts
|
|
43
|
+
var animateHeightProps = {
|
|
44
|
+
as: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "div"
|
|
47
|
+
},
|
|
48
|
+
isOpen: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
initialHeight: {
|
|
53
|
+
type: Number,
|
|
54
|
+
default: 0
|
|
55
|
+
},
|
|
56
|
+
duration: {
|
|
57
|
+
type: Number,
|
|
58
|
+
default: 250
|
|
59
|
+
},
|
|
60
|
+
enterEasing: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "easeInOutSine"
|
|
63
|
+
},
|
|
64
|
+
leaveEasing: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: "easeInOutSine"
|
|
67
|
+
},
|
|
68
|
+
finalHeight: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: 0
|
|
71
|
+
},
|
|
72
|
+
animateOpacity: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: true
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/modules/useAnimateHeight.ts
|
|
79
|
+
var import_animejs = __toESM(require("animejs"));
|
|
80
|
+
var import_vue = require("vue");
|
|
81
|
+
function useAnimateHeight(props, emit) {
|
|
82
|
+
const currentEl = (0, import_vue.ref)();
|
|
83
|
+
const isFirstRender = (0, import_vue.ref)(true);
|
|
84
|
+
function enter() {
|
|
85
|
+
const el = currentEl.value;
|
|
86
|
+
emit("enter", currentEl);
|
|
87
|
+
el.style.visibility = "hidden";
|
|
88
|
+
el.style.height = props.finalHeight || "auto";
|
|
89
|
+
const {
|
|
90
|
+
height
|
|
91
|
+
} = getComputedStyle(el);
|
|
92
|
+
el.style.height = props.initialHeight || 0;
|
|
93
|
+
requestAnimationFrame(() => {
|
|
94
|
+
el.style.visibility = "visible";
|
|
95
|
+
(0, import_animejs.default)({
|
|
96
|
+
targets: el,
|
|
97
|
+
...props.animateOpacity && {
|
|
98
|
+
opacity: [0, 1]
|
|
99
|
+
},
|
|
100
|
+
height: [props.initialHeight || 0, props.finalHeight || height],
|
|
101
|
+
easing: props.enterEasing,
|
|
102
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
103
|
+
complete: () => {
|
|
104
|
+
isFirstRender.value = false;
|
|
105
|
+
el.style.height = props.finalHeight || "auto";
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
__name(enter, "enter");
|
|
111
|
+
function leave() {
|
|
112
|
+
const el = currentEl.value;
|
|
113
|
+
emit("leave", currentEl);
|
|
114
|
+
const {
|
|
115
|
+
height
|
|
116
|
+
} = getComputedStyle(el);
|
|
117
|
+
requestAnimationFrame(() => {
|
|
118
|
+
(0, import_animejs.default)({
|
|
119
|
+
targets: el,
|
|
120
|
+
...props.animateOpacity && {
|
|
121
|
+
opacity: [1, 0]
|
|
122
|
+
},
|
|
123
|
+
height: [props.finalHeight || height, props.initialHeight || 0],
|
|
124
|
+
easing: props.leaveEasing,
|
|
125
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
126
|
+
complete: () => {
|
|
127
|
+
isFirstRender.value = false;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
__name(leave, "leave");
|
|
133
|
+
(0, import_vue.watch)(() => props.isOpen, (isOpen) => {
|
|
134
|
+
if (isOpen) {
|
|
135
|
+
(0, import_vue.nextTick)(() => {
|
|
136
|
+
enter();
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
(0, import_vue.nextTick)(() => {
|
|
140
|
+
leave();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
immediate: true
|
|
145
|
+
});
|
|
146
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
147
|
+
return {
|
|
148
|
+
ref: currentEl,
|
|
149
|
+
"data-pixel-component": "MpAnimateHeight",
|
|
150
|
+
style: {
|
|
151
|
+
overflow: props.isOpen ? "visible" : "hidden"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
rootAttrs
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
__name(useAnimateHeight, "useAnimateHeight");
|
|
160
|
+
|
|
161
|
+
// src/animate-height.tsx
|
|
162
|
+
var MpAnimateHeight = (0, import_vue3.defineComponent)({
|
|
163
|
+
name: "MpAnimateHeight",
|
|
164
|
+
props: animateHeightProps,
|
|
165
|
+
emits: ["enter", "leave"],
|
|
166
|
+
setup(props, {
|
|
167
|
+
slots,
|
|
168
|
+
emit
|
|
169
|
+
}) {
|
|
170
|
+
const {
|
|
171
|
+
rootAttrs
|
|
172
|
+
} = useAnimateHeight(props, emit);
|
|
173
|
+
return () => {
|
|
174
|
+
const {
|
|
175
|
+
as: Component
|
|
176
|
+
} = props;
|
|
177
|
+
return (0, import_vue2.createVNode)(Component, rootAttrs.value, {
|
|
178
|
+
default: () => [slots.default && slots.default()]
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
+
0 && (module.exports = {
|
|
185
|
+
MpAnimateHeight
|
|
186
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/modules/transition.props.ts":{"bytes":1007,"imports":[],"format":"esm"},"src/modules/useAnimateHeight.ts":{"bytes":2238,"imports":[{"path":"animejs","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/animate-height.tsx":{"bytes":758,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"src/modules/transition.props.ts","kind":"import-statement","original":"./modules/transition.props"},{"path":"src/modules/useAnimateHeight.ts","kind":"import-statement","original":"./modules/useAnimateHeight"}],"format":"esm"},"src/index.tsx":{"bytes":118,"imports":[{"path":"src/animate-height.tsx","kind":"import-statement","original":"./animate-height"}],"format":"esm"}},"outputs":{"dist/animate-height.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"animejs","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/animate-height.tsx","inputs":{"src/animate-height.tsx":{"bytesInOutput":716},"src/modules/transition.props.ts":{"bytesInOutput":500},"src/modules/useAnimateHeight.ts":{"bytesInOutput":2202}},"bytes":5139},"dist/index.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"animejs","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.tsx","inputs":{"src/index.tsx":{"bytesInOutput":135},"src/animate-height.tsx":{"bytesInOutput":548},"src/modules/transition.props.ts":{"bytesInOutput":500},"src/modules/useAnimateHeight.ts":{"bytesInOutput":2202}},"bytes":5124},"dist/modules/transition.props.js":{"imports":[],"exports":[],"entryPoint":"src/modules/transition.props.ts","inputs":{"src/modules/transition.props.ts":{"bytesInOutput":680}},"bytes":1627},"dist/modules/useAnimateHeight.js":{"imports":[{"path":"animejs","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/modules/useAnimateHeight.ts","inputs":{"src/modules/useAnimateHeight.ts":{"bytesInOutput":2378}},"bytes":4010}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/modules/transition.props.ts":{"bytes":1007,"imports":[],"format":"esm"},"src/modules/useAnimateHeight.ts":{"bytes":2238,"imports":[{"path":"animejs","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/animate-height.tsx":{"bytes":758,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"src/modules/transition.props.ts","kind":"import-statement","original":"./modules/transition.props"},{"path":"src/modules/useAnimateHeight.ts","kind":"import-statement","original":"./modules/useAnimateHeight"}],"format":"esm"},"src/index.tsx":{"bytes":118,"imports":[{"path":"src/animate-height.tsx","kind":"import-statement","original":"./animate-height"}],"format":"esm"}},"outputs":{"dist/animate-height.mjs":{"imports":[{"path":"dist/chunk-7BE634W2.mjs","kind":"import-statement"},{"path":"dist/chunk-SQMYD3AJ.mjs","kind":"import-statement"},{"path":"dist/chunk-F65UX7S5.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpAnimateHeight"],"entryPoint":"src/animate-height.tsx","inputs":{},"bytes":181},"dist/index.mjs":{"imports":[{"path":"dist/chunk-7BE634W2.mjs","kind":"import-statement"},{"path":"dist/chunk-SQMYD3AJ.mjs","kind":"import-statement"},{"path":"dist/chunk-F65UX7S5.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["MpAnimateHeight"],"entryPoint":"src/index.tsx","inputs":{"src/index.tsx":{"bytesInOutput":0}},"bytes":181},"dist/chunk-7BE634W2.mjs":{"imports":[{"path":"dist/chunk-SQMYD3AJ.mjs","kind":"import-statement"},{"path":"dist/chunk-F65UX7S5.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true}],"exports":["MpAnimateHeight"],"inputs":{"src/animate-height.tsx":{"bytesInOutput":537}},"bytes":715},"dist/modules/transition.props.mjs":{"imports":[{"path":"dist/chunk-SQMYD3AJ.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["animateHeightProps"],"entryPoint":"src/modules/transition.props.ts","inputs":{},"bytes":127},"dist/chunk-SQMYD3AJ.mjs":{"imports":[],"exports":["animateHeightProps"],"inputs":{"src/modules/transition.props.ts":{"bytesInOutput":500}},"bytes":569},"dist/modules/useAnimateHeight.mjs":{"imports":[{"path":"dist/chunk-F65UX7S5.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["useAnimateHeight"],"entryPoint":"src/modules/useAnimateHeight.ts","inputs":{},"bytes":123},"dist/chunk-F65UX7S5.mjs":{"imports":[{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"animejs","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true}],"exports":["useAnimateHeight"],"inputs":{"src/modules/useAnimateHeight.ts":{"bytesInOutput":2062}},"bytes":2179},"dist/chunk-QZ7VFGWC.mjs":{"imports":[],"exports":["__name"],"inputs":{},"bytes":151}}}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const animateHeightProps: {
|
|
4
|
+
as: {
|
|
5
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
isOpen: {
|
|
9
|
+
type: PropType<boolean>;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
initialHeight: {
|
|
13
|
+
type: PropType<number>;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
duration: {
|
|
17
|
+
type: PropType<number>;
|
|
18
|
+
default: number;
|
|
19
|
+
};
|
|
20
|
+
enterEasing: {
|
|
21
|
+
type: PropType<string>;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
leaveEasing: {
|
|
25
|
+
type: PropType<string>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
finalHeight: {
|
|
29
|
+
type: PropType<number>;
|
|
30
|
+
default: number;
|
|
31
|
+
};
|
|
32
|
+
animateOpacity: {
|
|
33
|
+
type: PropType<boolean>;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type AnimateHeightProps = ExtractPropTypes<typeof animateHeightProps>;
|
|
38
|
+
type AnimateHeightEmits = (e: 'enter' | 'leave', value?: unknown) => void;
|
|
39
|
+
|
|
40
|
+
export { AnimateHeightEmits, AnimateHeightProps, animateHeightProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
declare const animateHeightProps: {
|
|
4
|
+
as: {
|
|
5
|
+
type: PropType<keyof HTMLElementTagNameMap>;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
isOpen: {
|
|
9
|
+
type: PropType<boolean>;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
initialHeight: {
|
|
13
|
+
type: PropType<number>;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
duration: {
|
|
17
|
+
type: PropType<number>;
|
|
18
|
+
default: number;
|
|
19
|
+
};
|
|
20
|
+
enterEasing: {
|
|
21
|
+
type: PropType<string>;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
24
|
+
leaveEasing: {
|
|
25
|
+
type: PropType<string>;
|
|
26
|
+
default: string;
|
|
27
|
+
};
|
|
28
|
+
finalHeight: {
|
|
29
|
+
type: PropType<number>;
|
|
30
|
+
default: number;
|
|
31
|
+
};
|
|
32
|
+
animateOpacity: {
|
|
33
|
+
type: PropType<boolean>;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type AnimateHeightProps = ExtractPropTypes<typeof animateHeightProps>;
|
|
38
|
+
type AnimateHeightEmits = (e: 'enter' | 'leave', value?: unknown) => void;
|
|
39
|
+
|
|
40
|
+
export { AnimateHeightEmits, AnimateHeightProps, animateHeightProps };
|
|
@@ -0,0 +1,63 @@
|
|
|
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/transition.props.ts
|
|
21
|
+
var transition_props_exports = {};
|
|
22
|
+
__export(transition_props_exports, {
|
|
23
|
+
animateHeightProps: () => animateHeightProps
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(transition_props_exports);
|
|
26
|
+
var animateHeightProps = {
|
|
27
|
+
as: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "div"
|
|
30
|
+
},
|
|
31
|
+
isOpen: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
initialHeight: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 0
|
|
38
|
+
},
|
|
39
|
+
duration: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 250
|
|
42
|
+
},
|
|
43
|
+
enterEasing: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: "easeInOutSine"
|
|
46
|
+
},
|
|
47
|
+
leaveEasing: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "easeInOutSine"
|
|
50
|
+
},
|
|
51
|
+
finalHeight: {
|
|
52
|
+
type: Number,
|
|
53
|
+
default: 0
|
|
54
|
+
},
|
|
55
|
+
animateOpacity: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: true
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
animateHeightProps
|
|
63
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { HTMLAttributes } from 'vue';
|
|
3
|
+
import { AnimateHeightProps, AnimateHeightEmits } from './transition.props.mjs';
|
|
4
|
+
|
|
5
|
+
declare function useAnimateHeight(props: AnimateHeightProps, emit: AnimateHeightEmits): {
|
|
6
|
+
rootAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { useAnimateHeight };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { HTMLAttributes } from 'vue';
|
|
3
|
+
import { AnimateHeightProps, AnimateHeightEmits } from './transition.props.js';
|
|
4
|
+
|
|
5
|
+
declare function useAnimateHeight(props: AnimateHeightProps, emit: AnimateHeightEmits): {
|
|
6
|
+
rootAttrs: vue.ComputedRef<HTMLAttributes>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { useAnimateHeight };
|
|
@@ -0,0 +1,121 @@
|
|
|
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/useAnimateHeight.ts
|
|
32
|
+
var useAnimateHeight_exports = {};
|
|
33
|
+
__export(useAnimateHeight_exports, {
|
|
34
|
+
useAnimateHeight: () => useAnimateHeight
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(useAnimateHeight_exports);
|
|
37
|
+
var import_animejs = __toESM(require("animejs"));
|
|
38
|
+
var import_vue = require("vue");
|
|
39
|
+
function useAnimateHeight(props, emit) {
|
|
40
|
+
const currentEl = (0, import_vue.ref)();
|
|
41
|
+
const isFirstRender = (0, import_vue.ref)(true);
|
|
42
|
+
function enter() {
|
|
43
|
+
const el = currentEl.value;
|
|
44
|
+
emit("enter", currentEl);
|
|
45
|
+
el.style.visibility = "hidden";
|
|
46
|
+
el.style.height = props.finalHeight || "auto";
|
|
47
|
+
const {
|
|
48
|
+
height
|
|
49
|
+
} = getComputedStyle(el);
|
|
50
|
+
el.style.height = props.initialHeight || 0;
|
|
51
|
+
requestAnimationFrame(() => {
|
|
52
|
+
el.style.visibility = "visible";
|
|
53
|
+
(0, import_animejs.default)({
|
|
54
|
+
targets: el,
|
|
55
|
+
...props.animateOpacity && {
|
|
56
|
+
opacity: [0, 1]
|
|
57
|
+
},
|
|
58
|
+
height: [props.initialHeight || 0, props.finalHeight || height],
|
|
59
|
+
easing: props.enterEasing,
|
|
60
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
61
|
+
complete: () => {
|
|
62
|
+
isFirstRender.value = false;
|
|
63
|
+
el.style.height = props.finalHeight || "auto";
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
__name(enter, "enter");
|
|
69
|
+
function leave() {
|
|
70
|
+
const el = currentEl.value;
|
|
71
|
+
emit("leave", currentEl);
|
|
72
|
+
const {
|
|
73
|
+
height
|
|
74
|
+
} = getComputedStyle(el);
|
|
75
|
+
requestAnimationFrame(() => {
|
|
76
|
+
(0, import_animejs.default)({
|
|
77
|
+
targets: el,
|
|
78
|
+
...props.animateOpacity && {
|
|
79
|
+
opacity: [1, 0]
|
|
80
|
+
},
|
|
81
|
+
height: [props.finalHeight || height, props.initialHeight || 0],
|
|
82
|
+
easing: props.leaveEasing,
|
|
83
|
+
duration: isFirstRender.value ? 0 : props.duration,
|
|
84
|
+
complete: () => {
|
|
85
|
+
isFirstRender.value = false;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
__name(leave, "leave");
|
|
91
|
+
(0, import_vue.watch)(() => props.isOpen, (isOpen) => {
|
|
92
|
+
if (isOpen) {
|
|
93
|
+
(0, import_vue.nextTick)(() => {
|
|
94
|
+
enter();
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
(0, import_vue.nextTick)(() => {
|
|
98
|
+
leave();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
immediate: true
|
|
103
|
+
});
|
|
104
|
+
const rootAttrs = (0, import_vue.computed)(() => {
|
|
105
|
+
return {
|
|
106
|
+
ref: currentEl,
|
|
107
|
+
"data-pixel-component": "MpAnimateHeight",
|
|
108
|
+
style: {
|
|
109
|
+
overflow: props.isOpen ? "visible" : "hidden"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
rootAttrs
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
__name(useAnimateHeight, "useAnimateHeight");
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
useAnimateHeight
|
|
121
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mekari/pixel3-transition",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"animejs": "^3.2.2",
|
|
11
|
+
"@mekari/pixel3-icon": "0.0.2",
|
|
12
|
+
"@mekari/pixel3-styled-system": "0.0.1",
|
|
13
|
+
"@mekari/pixel3-utils": "0.0.2"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"vue": "3.2.47"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/animejs": "^3.1.12",
|
|
20
|
+
"vue": "3.2.47"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"module": "dist/index.mjs",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"require": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.mjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"clean": "rimraf dist .turbo",
|
|
36
|
+
"build": "tsup && pnpm build:types",
|
|
37
|
+
"build:fast": "tsup",
|
|
38
|
+
"build:types": "tsup src --dts-only",
|
|
39
|
+
"build:external": "tsup src/index.tsx --external @acme-org/styled-system",
|
|
40
|
+
"types:check": "tsc --noEmit",
|
|
41
|
+
"replace-config": "clean-package",
|
|
42
|
+
"restore-config": "clean-package restore"
|
|
43
|
+
}
|
|
44
|
+
}
|