@yamada-ui/motion 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Hirotomo Yamada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @yamada-ui/motion
2
+
3
+ ## Installation
4
+
5
+ ```sh
6
+ $ pnpm add @yamada-ui/motion
7
+ ```
8
+
9
+ or
10
+
11
+ ```sh
12
+ $ yarn add @yamada-ui/motion
13
+ ```
14
+
15
+ or
16
+
17
+ ```sh
18
+ $ npm install @yamada-ui/motion
19
+ ```
20
+
21
+ ## Contribution
22
+
23
+ Wouldn't you like to contribute? That's amazing! We have prepared a [contribution guide](https://github.com/hirotomoyamada/yamada-ui/blob/main/CONTRIBUTING.md) to assist you.
24
+
25
+ ## Licence
26
+
27
+ This package is licensed under the terms of the
28
+ [MIT license](https://github.com/hirotomoyamada/yamada-ui/blob/main/LICENSE).
@@ -0,0 +1,91 @@
1
+ // src/motion.tsx
2
+ import { ui, motionForwardRef } from "@yamada-ui/core";
3
+ import { cx, isNumber } from "@yamada-ui/utils";
4
+ import { motion } from "framer-motion";
5
+ import { jsx } from "react/jsx-runtime";
6
+ var MOTION_TRANSITION_EASINGS = {
7
+ ease: [0.25, 0.1, 0.25, 1],
8
+ easeIn: [0.4, 0, 1, 1],
9
+ easeOut: [0, 0, 0.2, 1],
10
+ easeInOut: [0.4, 0, 0.2, 1]
11
+ };
12
+ var MOTION_TRANSITION_VARIANTS = {
13
+ scale: {
14
+ enter: { scale: 1 },
15
+ exit: { scale: 0.95 }
16
+ },
17
+ fade: {
18
+ enter: { opacity: 1 },
19
+ exit: { opacity: 0 }
20
+ },
21
+ pushLeft: {
22
+ enter: { x: "100%" },
23
+ exit: { x: "-30%" }
24
+ },
25
+ pushRight: {
26
+ enter: { x: "-100%" },
27
+ exit: { x: "30%" }
28
+ },
29
+ pushUp: {
30
+ enter: { y: "100%" },
31
+ exit: { y: "-30%" }
32
+ },
33
+ pushDown: {
34
+ enter: { y: "-100%" },
35
+ exit: { y: "30%" }
36
+ },
37
+ slideLeft: {
38
+ position: { left: 0, top: 0, bottom: 0, width: "100%" },
39
+ enter: { x: 0, y: 0 },
40
+ exit: { x: "-100%", y: 0 }
41
+ },
42
+ slideRight: {
43
+ position: { right: 0, top: 0, bottom: 0, width: "100%" },
44
+ enter: { x: 0, y: 0 },
45
+ exit: { x: "100%", y: 0 }
46
+ },
47
+ slideUp: {
48
+ position: { top: 0, left: 0, right: 0, maxWidth: "100vw" },
49
+ enter: { x: 0, y: 0 },
50
+ exit: { x: 0, y: "-100%" }
51
+ },
52
+ slideDown: {
53
+ position: { bottom: 0, left: 0, right: 0, maxWidth: "100vw" },
54
+ enter: { x: 0, y: 0 },
55
+ exit: { x: 0, y: "100%" }
56
+ }
57
+ };
58
+ var MOTION_TRANSITION_DEFAULTS = {
59
+ enter: {
60
+ duration: 0.25,
61
+ ease: MOTION_TRANSITION_EASINGS.easeOut
62
+ },
63
+ exit: {
64
+ duration: 0.2,
65
+ ease: MOTION_TRANSITION_EASINGS.easeIn
66
+ }
67
+ };
68
+ var transitionEnter = (transition) => (delay, duration) => ({
69
+ ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.enter,
70
+ ...duration ? { duration: isNumber(duration) ? duration : duration == null ? void 0 : duration.enter } : {},
71
+ delay: isNumber(delay) ? delay : delay == null ? void 0 : delay.enter
72
+ });
73
+ var transitionExit = (transition) => (delay, duration) => ({
74
+ ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.exit,
75
+ ...duration ? { duration: isNumber(duration) ? duration : duration == null ? void 0 : duration.exit } : {},
76
+ delay: isNumber(delay) ? delay : delay == null ? void 0 : delay.exit
77
+ });
78
+ var Motion = motionForwardRef(
79
+ ({ as = "div", className, ...rest }, ref) => {
80
+ return /* @__PURE__ */ jsx(ui.div, { as: motion[as], ref, className: cx("ui-motion", className), ...rest });
81
+ }
82
+ );
83
+
84
+ export {
85
+ MOTION_TRANSITION_EASINGS,
86
+ MOTION_TRANSITION_VARIANTS,
87
+ MOTION_TRANSITION_DEFAULTS,
88
+ transitionEnter,
89
+ transitionExit,
90
+ Motion
91
+ };
@@ -0,0 +1,4 @@
1
+ export { AnimatePresence, DragControls, HTMLMotionProps, LayoutGroup, LazyMotion, AnimatePresenceProps as MotionAnimatePresenceProps, AnimationControls as MotionAnimationControls, AnimationLifecycles as MotionAnimationLifecycles, AnimationPlaybackControls as MotionAnimationPlaybackControls, AnimationProps as MotionAnimationProps, AnimationType as MotionAnimationType, MotionConfig, MotionConfigProps, LayoutProps as MotionLayoutProps, LazyProps as MotionLazyProps, Reorder as MotionReorder, MotionStyle, Transition as MotionTransition, MotionValue, ValueAnimationOptions as MotionValueAnimationOptions, Variants as MotionVariants, SVGMotionProps, motion, useDragControls, useInView, useIsPresent, useAnimation as useMotionAnimation, useAnimationControls as useMotionAnimationControls, useAnimationFrame as useMotionAnimationFrame, useMotionTemplate, useMotionValue, useReducedMotion, useScroll, useSpring, useTime, useTransform, useVelocity, useViewportScroll } from 'framer-motion';
2
+ export { MOTION_TRANSITION_DEFAULTS, MOTION_TRANSITION_EASINGS, MOTION_TRANSITION_VARIANTS, Motion, MotionDelayProps, MotionDurationProps, MotionProps, MotionTransitionEndProps, MotionTransitionProperties, MotionTransitionProps, MotionTransitionVariants, WithTransitionProps, transitionEnter, transitionExit } from './motion.js';
3
+ import '@yamada-ui/core';
4
+ import '@yamada-ui/utils';
package/dist/index.js ADDED
@@ -0,0 +1,165 @@
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/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ AnimatePresence: () => import_framer_motion2.AnimatePresence,
24
+ LayoutGroup: () => import_framer_motion2.LayoutGroup,
25
+ LazyMotion: () => import_framer_motion2.LazyMotion,
26
+ MOTION_TRANSITION_DEFAULTS: () => MOTION_TRANSITION_DEFAULTS,
27
+ MOTION_TRANSITION_EASINGS: () => MOTION_TRANSITION_EASINGS,
28
+ MOTION_TRANSITION_VARIANTS: () => MOTION_TRANSITION_VARIANTS,
29
+ Motion: () => Motion,
30
+ MotionConfig: () => import_framer_motion2.MotionConfig,
31
+ MotionReorder: () => import_framer_motion2.Reorder,
32
+ motion: () => import_framer_motion2.motion,
33
+ transitionEnter: () => transitionEnter,
34
+ transitionExit: () => transitionExit,
35
+ useDragControls: () => import_framer_motion2.useDragControls,
36
+ useInView: () => import_framer_motion2.useInView,
37
+ useIsPresent: () => import_framer_motion2.useIsPresent,
38
+ useMotionAnimation: () => import_framer_motion2.useAnimation,
39
+ useMotionAnimationControls: () => import_framer_motion2.useAnimationControls,
40
+ useMotionAnimationFrame: () => import_framer_motion2.useAnimationFrame,
41
+ useMotionTemplate: () => import_framer_motion2.useMotionTemplate,
42
+ useMotionValue: () => import_framer_motion2.useMotionValue,
43
+ useReducedMotion: () => import_framer_motion2.useReducedMotion,
44
+ useScroll: () => import_framer_motion2.useScroll,
45
+ useSpring: () => import_framer_motion2.useSpring,
46
+ useTime: () => import_framer_motion2.useTime,
47
+ useTransform: () => import_framer_motion2.useTransform,
48
+ useVelocity: () => import_framer_motion2.useVelocity,
49
+ useViewportScroll: () => import_framer_motion2.useViewportScroll
50
+ });
51
+ module.exports = __toCommonJS(src_exports);
52
+ var import_framer_motion2 = require("framer-motion");
53
+
54
+ // src/motion.tsx
55
+ var import_core = require("@yamada-ui/core");
56
+ var import_utils = require("@yamada-ui/utils");
57
+ var import_framer_motion = require("framer-motion");
58
+ var import_jsx_runtime = require("react/jsx-runtime");
59
+ var MOTION_TRANSITION_EASINGS = {
60
+ ease: [0.25, 0.1, 0.25, 1],
61
+ easeIn: [0.4, 0, 1, 1],
62
+ easeOut: [0, 0, 0.2, 1],
63
+ easeInOut: [0.4, 0, 0.2, 1]
64
+ };
65
+ var MOTION_TRANSITION_VARIANTS = {
66
+ scale: {
67
+ enter: { scale: 1 },
68
+ exit: { scale: 0.95 }
69
+ },
70
+ fade: {
71
+ enter: { opacity: 1 },
72
+ exit: { opacity: 0 }
73
+ },
74
+ pushLeft: {
75
+ enter: { x: "100%" },
76
+ exit: { x: "-30%" }
77
+ },
78
+ pushRight: {
79
+ enter: { x: "-100%" },
80
+ exit: { x: "30%" }
81
+ },
82
+ pushUp: {
83
+ enter: { y: "100%" },
84
+ exit: { y: "-30%" }
85
+ },
86
+ pushDown: {
87
+ enter: { y: "-100%" },
88
+ exit: { y: "30%" }
89
+ },
90
+ slideLeft: {
91
+ position: { left: 0, top: 0, bottom: 0, width: "100%" },
92
+ enter: { x: 0, y: 0 },
93
+ exit: { x: "-100%", y: 0 }
94
+ },
95
+ slideRight: {
96
+ position: { right: 0, top: 0, bottom: 0, width: "100%" },
97
+ enter: { x: 0, y: 0 },
98
+ exit: { x: "100%", y: 0 }
99
+ },
100
+ slideUp: {
101
+ position: { top: 0, left: 0, right: 0, maxWidth: "100vw" },
102
+ enter: { x: 0, y: 0 },
103
+ exit: { x: 0, y: "-100%" }
104
+ },
105
+ slideDown: {
106
+ position: { bottom: 0, left: 0, right: 0, maxWidth: "100vw" },
107
+ enter: { x: 0, y: 0 },
108
+ exit: { x: 0, y: "100%" }
109
+ }
110
+ };
111
+ var MOTION_TRANSITION_DEFAULTS = {
112
+ enter: {
113
+ duration: 0.25,
114
+ ease: MOTION_TRANSITION_EASINGS.easeOut
115
+ },
116
+ exit: {
117
+ duration: 0.2,
118
+ ease: MOTION_TRANSITION_EASINGS.easeIn
119
+ }
120
+ };
121
+ var transitionEnter = (transition) => (delay, duration) => ({
122
+ ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.enter,
123
+ ...duration ? { duration: (0, import_utils.isNumber)(duration) ? duration : duration == null ? void 0 : duration.enter } : {},
124
+ delay: (0, import_utils.isNumber)(delay) ? delay : delay == null ? void 0 : delay.enter
125
+ });
126
+ var transitionExit = (transition) => (delay, duration) => ({
127
+ ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.exit,
128
+ ...duration ? { duration: (0, import_utils.isNumber)(duration) ? duration : duration == null ? void 0 : duration.exit } : {},
129
+ delay: (0, import_utils.isNumber)(delay) ? delay : delay == null ? void 0 : delay.exit
130
+ });
131
+ var Motion = (0, import_core.motionForwardRef)(
132
+ ({ as = "div", className, ...rest }, ref) => {
133
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { as: import_framer_motion.motion[as], ref, className: (0, import_utils.cx)("ui-motion", className), ...rest });
134
+ }
135
+ );
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ AnimatePresence,
139
+ LayoutGroup,
140
+ LazyMotion,
141
+ MOTION_TRANSITION_DEFAULTS,
142
+ MOTION_TRANSITION_EASINGS,
143
+ MOTION_TRANSITION_VARIANTS,
144
+ Motion,
145
+ MotionConfig,
146
+ MotionReorder,
147
+ motion,
148
+ transitionEnter,
149
+ transitionExit,
150
+ useDragControls,
151
+ useInView,
152
+ useIsPresent,
153
+ useMotionAnimation,
154
+ useMotionAnimationControls,
155
+ useMotionAnimationFrame,
156
+ useMotionTemplate,
157
+ useMotionValue,
158
+ useReducedMotion,
159
+ useScroll,
160
+ useSpring,
161
+ useTime,
162
+ useTransform,
163
+ useVelocity,
164
+ useViewportScroll
165
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,62 @@
1
+ import {
2
+ MOTION_TRANSITION_DEFAULTS,
3
+ MOTION_TRANSITION_EASINGS,
4
+ MOTION_TRANSITION_VARIANTS,
5
+ Motion,
6
+ transitionEnter,
7
+ transitionExit
8
+ } from "./chunk-IENBUDYI.mjs";
9
+
10
+ // src/index.ts
11
+ import {
12
+ motion,
13
+ AnimatePresence,
14
+ LayoutGroup,
15
+ LazyMotion,
16
+ MotionConfig,
17
+ Reorder,
18
+ useMotionTemplate,
19
+ useScroll,
20
+ useSpring,
21
+ useTime,
22
+ useTransform,
23
+ useVelocity,
24
+ useViewportScroll,
25
+ useAnimation,
26
+ useAnimationControls,
27
+ useAnimationFrame,
28
+ useDragControls,
29
+ useInView,
30
+ useIsPresent,
31
+ useReducedMotion,
32
+ useMotionValue
33
+ } from "framer-motion";
34
+ export {
35
+ AnimatePresence,
36
+ LayoutGroup,
37
+ LazyMotion,
38
+ MOTION_TRANSITION_DEFAULTS,
39
+ MOTION_TRANSITION_EASINGS,
40
+ MOTION_TRANSITION_VARIANTS,
41
+ Motion,
42
+ MotionConfig,
43
+ Reorder as MotionReorder,
44
+ motion,
45
+ transitionEnter,
46
+ transitionExit,
47
+ useDragControls,
48
+ useInView,
49
+ useIsPresent,
50
+ useAnimation as useMotionAnimation,
51
+ useAnimationControls as useMotionAnimationControls,
52
+ useAnimationFrame as useMotionAnimationFrame,
53
+ useMotionTemplate,
54
+ useMotionValue,
55
+ useReducedMotion,
56
+ useScroll,
57
+ useSpring,
58
+ useTime,
59
+ useTransform,
60
+ useVelocity,
61
+ useViewportScroll
62
+ };
@@ -0,0 +1,169 @@
1
+ import { Transition, Target, HTMLMotionProps, TargetAndTransition, motion } from 'framer-motion';
2
+ import * as _yamada_ui_core from '@yamada-ui/core';
3
+ import { HTMLUIProps } from '@yamada-ui/core';
4
+ import { Dict } from '@yamada-ui/utils';
5
+
6
+ type TargetResolver<Y = Dict> = (props: Y & MotionTransitionProperties) => TargetAndTransition;
7
+ type Variant<Y = Dict> = TargetAndTransition | TargetResolver<Y>;
8
+ type MotionTransitionVariants<Y = Dict> = {
9
+ enter: Variant<Y>;
10
+ exit: Variant<Y>;
11
+ initial?: Variant<Y>;
12
+ };
13
+ type MotionTransitionProperties = {
14
+ transition?: MotionTransitionProps;
15
+ transitionEnd?: MotionTransitionEndProps;
16
+ delay?: number | MotionDelayProps;
17
+ duration?: number | MotionDurationProps;
18
+ enter?: any;
19
+ exit?: any;
20
+ initial?: any;
21
+ };
22
+ type WithMotionProps<Y> = Partial<Record<'enter' | 'exit', Y>>;
23
+ type MotionTransitionProps = WithMotionProps<Transition>;
24
+ type MotionTransitionEndProps = WithMotionProps<Target>;
25
+ type MotionDelayProps = WithMotionProps<number>;
26
+ type MotionDurationProps = WithMotionProps<number>;
27
+ type WithTransitionProps<Y extends object> = Omit<Y, 'transition'> & MotionTransitionProperties & {
28
+ unmountOnExit?: boolean;
29
+ isOpen?: boolean;
30
+ };
31
+ declare const MOTION_TRANSITION_EASINGS: {
32
+ readonly ease: readonly [0.25, 0.1, 0.25, 1];
33
+ readonly easeIn: readonly [0.4, 0, 1, 1];
34
+ readonly easeOut: readonly [0, 0, 0.2, 1];
35
+ readonly easeInOut: readonly [0.4, 0, 0.2, 1];
36
+ };
37
+ declare const MOTION_TRANSITION_VARIANTS: {
38
+ readonly scale: {
39
+ readonly enter: {
40
+ readonly scale: 1;
41
+ };
42
+ readonly exit: {
43
+ readonly scale: 0.95;
44
+ };
45
+ };
46
+ readonly fade: {
47
+ readonly enter: {
48
+ readonly opacity: 1;
49
+ };
50
+ readonly exit: {
51
+ readonly opacity: 0;
52
+ };
53
+ };
54
+ readonly pushLeft: {
55
+ readonly enter: {
56
+ readonly x: "100%";
57
+ };
58
+ readonly exit: {
59
+ readonly x: "-30%";
60
+ };
61
+ };
62
+ readonly pushRight: {
63
+ readonly enter: {
64
+ readonly x: "-100%";
65
+ };
66
+ readonly exit: {
67
+ readonly x: "30%";
68
+ };
69
+ };
70
+ readonly pushUp: {
71
+ readonly enter: {
72
+ readonly y: "100%";
73
+ };
74
+ readonly exit: {
75
+ readonly y: "-30%";
76
+ };
77
+ };
78
+ readonly pushDown: {
79
+ readonly enter: {
80
+ readonly y: "-100%";
81
+ };
82
+ readonly exit: {
83
+ readonly y: "30%";
84
+ };
85
+ };
86
+ readonly slideLeft: {
87
+ readonly position: {
88
+ readonly left: 0;
89
+ readonly top: 0;
90
+ readonly bottom: 0;
91
+ readonly width: "100%";
92
+ };
93
+ readonly enter: {
94
+ readonly x: 0;
95
+ readonly y: 0;
96
+ };
97
+ readonly exit: {
98
+ readonly x: "-100%";
99
+ readonly y: 0;
100
+ };
101
+ };
102
+ readonly slideRight: {
103
+ readonly position: {
104
+ readonly right: 0;
105
+ readonly top: 0;
106
+ readonly bottom: 0;
107
+ readonly width: "100%";
108
+ };
109
+ readonly enter: {
110
+ readonly x: 0;
111
+ readonly y: 0;
112
+ };
113
+ readonly exit: {
114
+ readonly x: "100%";
115
+ readonly y: 0;
116
+ };
117
+ };
118
+ readonly slideUp: {
119
+ readonly position: {
120
+ readonly top: 0;
121
+ readonly left: 0;
122
+ readonly right: 0;
123
+ readonly maxWidth: "100vw";
124
+ };
125
+ readonly enter: {
126
+ readonly x: 0;
127
+ readonly y: 0;
128
+ };
129
+ readonly exit: {
130
+ readonly x: 0;
131
+ readonly y: "-100%";
132
+ };
133
+ };
134
+ readonly slideDown: {
135
+ readonly position: {
136
+ readonly bottom: 0;
137
+ readonly left: 0;
138
+ readonly right: 0;
139
+ readonly maxWidth: "100vw";
140
+ };
141
+ readonly enter: {
142
+ readonly x: 0;
143
+ readonly y: 0;
144
+ };
145
+ readonly exit: {
146
+ readonly x: 0;
147
+ readonly y: "100%";
148
+ };
149
+ };
150
+ };
151
+ declare const MOTION_TRANSITION_DEFAULTS: {
152
+ readonly enter: {
153
+ readonly duration: 0.25;
154
+ readonly ease: readonly [0, 0, 0.2, 1];
155
+ };
156
+ readonly exit: {
157
+ readonly duration: 0.2;
158
+ readonly ease: readonly [0.4, 0, 1, 1];
159
+ };
160
+ };
161
+ declare const transitionEnter: (transition?: Transition) => (delay?: MotionTransitionProperties['delay'], duration?: MotionTransitionProperties['duration']) => Transition;
162
+ declare const transitionExit: (transition?: Transition) => (delay?: MotionTransitionProperties['delay'], duration?: MotionTransitionProperties['duration']) => Transition;
163
+ type MotionOptions = {
164
+ as?: keyof typeof motion;
165
+ };
166
+ type MotionProps = Omit<HTMLUIProps<'div'>, 'as'> & HTMLMotionProps<'div'> & MotionOptions;
167
+ declare const Motion: _yamada_ui_core.Component<"div", MotionProps>;
168
+
169
+ export { MOTION_TRANSITION_DEFAULTS, MOTION_TRANSITION_EASINGS, MOTION_TRANSITION_VARIANTS, Motion, MotionDelayProps, MotionDurationProps, MotionProps, MotionTransitionEndProps, MotionTransitionProperties, MotionTransitionProps, MotionTransitionVariants, WithTransitionProps, transitionEnter, transitionExit };
package/dist/motion.js ADDED
@@ -0,0 +1,120 @@
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/motion.tsx
21
+ var motion_exports = {};
22
+ __export(motion_exports, {
23
+ MOTION_TRANSITION_DEFAULTS: () => MOTION_TRANSITION_DEFAULTS,
24
+ MOTION_TRANSITION_EASINGS: () => MOTION_TRANSITION_EASINGS,
25
+ MOTION_TRANSITION_VARIANTS: () => MOTION_TRANSITION_VARIANTS,
26
+ Motion: () => Motion,
27
+ transitionEnter: () => transitionEnter,
28
+ transitionExit: () => transitionExit
29
+ });
30
+ module.exports = __toCommonJS(motion_exports);
31
+ var import_core = require("@yamada-ui/core");
32
+ var import_utils = require("@yamada-ui/utils");
33
+ var import_framer_motion = require("framer-motion");
34
+ var import_jsx_runtime = require("react/jsx-runtime");
35
+ var MOTION_TRANSITION_EASINGS = {
36
+ ease: [0.25, 0.1, 0.25, 1],
37
+ easeIn: [0.4, 0, 1, 1],
38
+ easeOut: [0, 0, 0.2, 1],
39
+ easeInOut: [0.4, 0, 0.2, 1]
40
+ };
41
+ var MOTION_TRANSITION_VARIANTS = {
42
+ scale: {
43
+ enter: { scale: 1 },
44
+ exit: { scale: 0.95 }
45
+ },
46
+ fade: {
47
+ enter: { opacity: 1 },
48
+ exit: { opacity: 0 }
49
+ },
50
+ pushLeft: {
51
+ enter: { x: "100%" },
52
+ exit: { x: "-30%" }
53
+ },
54
+ pushRight: {
55
+ enter: { x: "-100%" },
56
+ exit: { x: "30%" }
57
+ },
58
+ pushUp: {
59
+ enter: { y: "100%" },
60
+ exit: { y: "-30%" }
61
+ },
62
+ pushDown: {
63
+ enter: { y: "-100%" },
64
+ exit: { y: "30%" }
65
+ },
66
+ slideLeft: {
67
+ position: { left: 0, top: 0, bottom: 0, width: "100%" },
68
+ enter: { x: 0, y: 0 },
69
+ exit: { x: "-100%", y: 0 }
70
+ },
71
+ slideRight: {
72
+ position: { right: 0, top: 0, bottom: 0, width: "100%" },
73
+ enter: { x: 0, y: 0 },
74
+ exit: { x: "100%", y: 0 }
75
+ },
76
+ slideUp: {
77
+ position: { top: 0, left: 0, right: 0, maxWidth: "100vw" },
78
+ enter: { x: 0, y: 0 },
79
+ exit: { x: 0, y: "-100%" }
80
+ },
81
+ slideDown: {
82
+ position: { bottom: 0, left: 0, right: 0, maxWidth: "100vw" },
83
+ enter: { x: 0, y: 0 },
84
+ exit: { x: 0, y: "100%" }
85
+ }
86
+ };
87
+ var MOTION_TRANSITION_DEFAULTS = {
88
+ enter: {
89
+ duration: 0.25,
90
+ ease: MOTION_TRANSITION_EASINGS.easeOut
91
+ },
92
+ exit: {
93
+ duration: 0.2,
94
+ ease: MOTION_TRANSITION_EASINGS.easeIn
95
+ }
96
+ };
97
+ var transitionEnter = (transition) => (delay, duration) => ({
98
+ ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.enter,
99
+ ...duration ? { duration: (0, import_utils.isNumber)(duration) ? duration : duration == null ? void 0 : duration.enter } : {},
100
+ delay: (0, import_utils.isNumber)(delay) ? delay : delay == null ? void 0 : delay.enter
101
+ });
102
+ var transitionExit = (transition) => (delay, duration) => ({
103
+ ...transition != null ? transition : MOTION_TRANSITION_DEFAULTS.exit,
104
+ ...duration ? { duration: (0, import_utils.isNumber)(duration) ? duration : duration == null ? void 0 : duration.exit } : {},
105
+ delay: (0, import_utils.isNumber)(delay) ? delay : delay == null ? void 0 : delay.exit
106
+ });
107
+ var Motion = (0, import_core.motionForwardRef)(
108
+ ({ as = "div", className, ...rest }, ref) => {
109
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.ui.div, { as: import_framer_motion.motion[as], ref, className: (0, import_utils.cx)("ui-motion", className), ...rest });
110
+ }
111
+ );
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ MOTION_TRANSITION_DEFAULTS,
115
+ MOTION_TRANSITION_EASINGS,
116
+ MOTION_TRANSITION_VARIANTS,
117
+ Motion,
118
+ transitionEnter,
119
+ transitionExit
120
+ });
@@ -0,0 +1,16 @@
1
+ import {
2
+ MOTION_TRANSITION_DEFAULTS,
3
+ MOTION_TRANSITION_EASINGS,
4
+ MOTION_TRANSITION_VARIANTS,
5
+ Motion,
6
+ transitionEnter,
7
+ transitionExit
8
+ } from "./chunk-IENBUDYI.mjs";
9
+ export {
10
+ MOTION_TRANSITION_DEFAULTS,
11
+ MOTION_TRANSITION_EASINGS,
12
+ MOTION_TRANSITION_VARIANTS,
13
+ Motion,
14
+ transitionEnter,
15
+ transitionExit
16
+ };
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@yamada-ui/motion",
3
+ "version": "0.1.0",
4
+ "description": "Yamada UI motion components",
5
+ "keywords": [
6
+ "yamada",
7
+ "yamada ui",
8
+ "react",
9
+ "emotion",
10
+ "component",
11
+ "motion",
12
+ "ui",
13
+ "uikit",
14
+ "styled",
15
+ "style-props",
16
+ "styled-component",
17
+ "css-in-js"
18
+ ],
19
+ "author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
20
+ "license": "MIT",
21
+ "main": "dist/index.js",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "sideEffects": false,
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/hirotomoyamada/yamada-ui",
32
+ "directory": "packages/components/motion"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/hirotomoyamada/yamada-ui/issues"
36
+ },
37
+ "dependencies": {
38
+ "framer-motion": "^9.1.7",
39
+ "@yamada-ui/utils": "0.1.0",
40
+ "@yamada-ui/core": "0.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "react": "^18.0.0",
44
+ "clean-package": "2.2.0"
45
+ },
46
+ "peerDependencies": {
47
+ "react": ">=18"
48
+ },
49
+ "clean-package": "../../../clean-package.config.json",
50
+ "tsup": {
51
+ "clean": true,
52
+ "target": "es2019",
53
+ "format": [
54
+ "cjs",
55
+ "esm"
56
+ ]
57
+ },
58
+ "module": "dist/index.mjs",
59
+ "types": "dist/index.d.ts",
60
+ "exports": {
61
+ ".": {
62
+ "types": "./dist/index.d.ts",
63
+ "import": "./dist/index.mjs",
64
+ "require": "./dist/index.js"
65
+ },
66
+ "./package.json": "./package.json"
67
+ },
68
+ "scripts": {
69
+ "dev": "pnpm build:fast -- --watch",
70
+ "build": "tsup src --dts",
71
+ "build:fast": "tsup src",
72
+ "clean": "rimraf dist .turbo",
73
+ "typecheck": "tsc --noEmit",
74
+ "gen:docs": "tsx ../../../scripts/generate-docs"
75
+ }
76
+ }