@kurocado-studio/systemhaus-motion-react 1.0.0-develop.1 → 1.0.0-develop.10
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/exports.js +1 -1
- package/dist/index.d.ts +108 -16
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +3 -18
package/dist/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{get as
|
|
1
|
+
import{get as A}from"lodash-es";function R(t,i,e,a){var n=t.getBoundingClientRect(),o=n.left+n.width/2,p=n.top+n.height/2,r=i-o,m=e-p,s=a.magneticModeActivationRadius,c=A(a,["maxDistance"],3e3),f=A(a,["intensity"],.1);if(globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches)return{x:0,y:0};if(typeof s=="number"){var l=Math.hypot(Math.pow(r,2)+Math.pow(m,2));if(l>c)return{x:0,y:0};var P=0;return l<s&&(P=1-l/s),{x:r*P*f,y:m*P*f}}if(Math.abs(r)<c&&Math.abs(m)<c){var I=1-Math.max(Math.abs(r),Math.abs(m))/c;return{x:r*I*f,y:m*I*f}}return{x:0,y:0}}var U=.4;var w="easeInOut",y=12;var G=12,T={isStatic:!1,fadeInSpeed:G,fadeDistance:y,transition:{duration:U,ease:w},reducedMotion:"user"};import{get as C}from"lodash-es";import g,{createContext as k,useContext as B,useMemo as X}from"react";var x=(o=>(o.TOP="TOP",o.BOTTOM="BOTTOM",o.LEFT="LEFT",o.RIGHT="RIGHT",o.DEFAULT="DEFAULT",o))(x||{});import{useMotionValue as D,useSpring as E,MotionConfig as b,AnimatePresence as S,motion as h}from"framer-motion";var d={...T,fadeInDirection:"TOP",fadeInDistance:y,viewport:{once:!1,amount:.2}},F=k(d),pt=({children:t,motionOverrides:i})=>{let e=X(()=>({...T,...i,viewport:C(i,["viewport"],d.viewport),fadeInDistance:C(i,["fadeInDistance"],d.fadeInDistance),fadeInDirection:C(i,["fadeInDirection"],d.fadeInDirection)}),[i]);return g.createElement(F.Provider,{value:e},g.createElement(b,{...e},t))},u=()=>B(F);import{get as O}from"lodash-es";import{useEffect as Y,useState as $}from"react";function xt(t){let i=O(t,["damping"],100),e=O(t,["stiffness"],600),a=D(0),n=D(0),[o,p]=$(),r=E(a,{damping:i,stiffness:e}),m=E(n,{damping:i,stiffness:e});return Y(()=>{let s=c=>{if(!o)return;let{x:f,y:l}=R(o,c.clientX,c.clientY,t);a.set(f),n.set(l)};return document.addEventListener("mousemove",s),()=>document.removeEventListener("mousemove",s)},[o,t,a,n]),{ref:p,x:r,y:m}}import{get as V}from"lodash-es";import H from"react";var Et=({onEnterDirection:t,onExitDirection:i}={})=>{let{viewport:e,transition:a,fadeInDistance:n=y}=u(),o=Math.abs(n),r=H.useCallback(s=>({DEFAULT:{hidden:{opacity:0,y:0},visible:{opacity:1,y:0},exit:{opacity:0,y:0}},TOP:{hidden:{opacity:0,y:-s},visible:{opacity:1,y:0},exit:{opacity:0,y:-s}},BOTTOM:{hidden:{opacity:0,y:s},visible:{opacity:1,y:0},exit:{opacity:0,y:s}},LEFT:{hidden:{opacity:0,x:-s},visible:{opacity:1,x:0},exit:{opacity:0,x:-s}},RIGHT:{hidden:{opacity:0,x:s},visible:{opacity:1,x:0},exit:{opacity:0,x:s}}}),[])(o),m=V(r,[i??"BOTTOM","exit"],r.BOTTOM.exit);return H.useMemo(()=>({initial:"hidden",animate:"visible",exit:"exit",variants:{...V(r,[t??"TOP"],r.TOP),exit:m},transition:a,viewport:e}),[r,m,t,a,e])};import{cloneDeep as q,merge as W}from"lodash-es";import J from"react";function At(...t){return J.useMemo(()=>{let i=t.map(e=>q(e));return W({},...i)},t)}import{get as M}from"lodash-es";import _ from"react";function Ft(t={}){let{transition:e}=u(),n=_.useCallback(()=>({default:{hidden:{opacity:0,scale:M(t,["initialScale"],1.1)},visible:{opacity:1,scale:1},exit:{opacity:0,scale:M(t,["exitScale"],1.1)}}}),[])(),o=M(n,["default","exit"],n.default.exit);return _.useMemo(()=>({initial:"hidden",animate:"visible",exit:"exit",variants:{...n.default,exit:o},transition:{duration:M(e,["duration"],1.2),...e}}),[n,o,e])}import{get as L}from"lodash-es";import N from"react";function Nt({onEnterDirection:t="RIGHT",onExitDirection:i="RIGHT",distance:e="100%"}={}){let{transition:a}=u(),o=N.useCallback(r=>({DEFAULT:{hidden:{opacity:0},visible:{opacity:1},exit:{opacity:0}},TOP:{hidden:{opacity:0,y:`-${r}`},visible:{opacity:1,y:0},exit:{opacity:0,y:`-${r}`}},BOTTOM:{hidden:{opacity:0,y:r},visible:{opacity:1,y:0},exit:{opacity:0,y:r}},LEFT:{hidden:{opacity:0,x:`-${r}`},visible:{opacity:1,x:0},exit:{opacity:0,x:`-${r}`}},RIGHT:{hidden:{opacity:0,x:r},visible:{opacity:1,x:0},exit:{opacity:0,x:r}}}),[])(e),p=L(o,[i,"exit"],o.RIGHT.exit);return N.useMemo(()=>({initial:"hidden",animate:"visible",exit:"exit",variants:{...L(o,[t],o.RIGHT),exit:p},transition:{...a}}),[o,p,t,a])}import{get as j}from"lodash-es";import z from"react";function Bt(t){let{as:i,...e}=t,a=j(h,[i??"div"],h.div);return z.createElement(a,{...e})}import v from"react";function qt({children:t,isVisible:i,mode:e,initial:a}){return v.createElement(S,{mode:e,initial:a},i&&v.Children.toArray(t).map((n,o)=>v.isValidElement(n)?v.cloneElement(n,{key:n.key??`motion-child-${o}`}):n))}import{cloneDeep as K,merge as Q}from"lodash-es";function jt(...t){let i=t.map(e=>K(e));return Q({},...i)}export{qt as AnimateMotionPresence,x as DirectionEnum,pt as MotionProvider,Bt as PolymorphicMotionElement,jt as mergeMotionProperties,d as systemHausMotionConfiguration,xt as useCursorFollow,At as useDeepMergeMotionProperties,Et as useFadeIn,Ft as useScale,Nt as useSlideOut,u as useSystemHausMotionProvider};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
1
|
+
import { AnimatePresence } from 'framer-motion';
|
|
2
|
+
import * as Motion from 'framer-motion';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
import { MotionConfig } from 'framer-motion';
|
|
5
|
+
import { MotionProps } from 'framer-motion';
|
|
6
|
+
import * as React_2 from 'react';
|
|
7
|
+
import React__default from 'react';
|
|
8
|
+
import { useMotionValue } from 'framer-motion';
|
|
9
|
+
import { useSpring } from 'framer-motion';
|
|
10
|
+
import { Variant } from 'framer-motion';
|
|
11
|
+
import { Variants } from 'framer-motion';
|
|
12
|
+
import { ViewportOptions } from 'framer-motion';
|
|
13
|
+
|
|
14
|
+
export declare function AnimateMotionPresence({ children, isVisible, mode, initial, }: React__default.PropsWithChildren<AnimateMotionPresenceProperties>): React__default.ReactNode;
|
|
15
|
+
|
|
16
|
+
export declare interface AnimateMotionPresenceProperties {
|
|
17
|
+
isVisible?: boolean;
|
|
18
|
+
initial?: boolean;
|
|
19
|
+
children?: React__default.ReactNode;
|
|
20
|
+
mode?: 'wait' | 'sync' | 'popLayout';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { AnimatePresence }
|
|
3
24
|
|
|
4
25
|
declare type CalculateCursorOffsetController = CursorFollowSettings;
|
|
5
26
|
|
|
@@ -11,26 +32,97 @@ declare interface CursorFollowSettings {
|
|
|
11
32
|
magneticModeActivationRadius?: number;
|
|
12
33
|
}
|
|
13
34
|
|
|
14
|
-
export declare
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
35
|
+
export declare enum DirectionEnum {
|
|
36
|
+
TOP = "TOP",
|
|
37
|
+
BOTTOM = "BOTTOM",
|
|
38
|
+
LEFT = "LEFT",
|
|
39
|
+
RIGHT = "RIGHT",
|
|
40
|
+
DEFAULT = "DEFAULT"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export declare function mergeMotionProperties(...motionProperties: MotionProps[]): MotionProps;
|
|
44
|
+
|
|
45
|
+
export { motion }
|
|
46
|
+
|
|
47
|
+
export { MotionConfig }
|
|
48
|
+
|
|
49
|
+
export { MotionProps }
|
|
50
|
+
|
|
51
|
+
export declare const MotionProvider: React__default.FC<SystemHausMotionProviderProperties>;
|
|
52
|
+
|
|
53
|
+
export declare function PolymorphicMotionElement<T extends keyof React__default.JSX.IntrinsicElements = 'div'>(properties: React__default.PropsWithChildren<PolymorphicMotionProperties<T>>): React__default.ReactNode;
|
|
54
|
+
|
|
55
|
+
export declare type PolymorphicMotionProperties<T extends keyof React__default.JSX.IntrinsicElements = 'div'> = Omit<React__default.JSX.IntrinsicElements[T], keyof MotionProps | 'ref'> & MotionProps & {
|
|
56
|
+
as?: T;
|
|
57
|
+
isVisible?: boolean;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
declare type ProvidedConfig = {
|
|
61
|
+
fadeInSpeed: number;
|
|
62
|
+
fadeDistance: number;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare const systemHausMotionConfiguration: SystemHausMotionProvider;
|
|
66
|
+
|
|
67
|
+
export declare interface SystemHausMotionProvider extends SystemHausMotionProviderConfig {
|
|
68
|
+
fadeInDistance: number;
|
|
69
|
+
fadeInDirection: DirectionEnum;
|
|
70
|
+
viewport: ViewportOptions;
|
|
20
71
|
}
|
|
21
72
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
73
|
+
declare type SystemHausMotionProviderConfig = ProvidedConfig & {
|
|
74
|
+
[K in keyof Motion.MotionConfigProps as Motion.MotionConfigProps[K] extends (...unknowns: unknown[]) => unknown ? never : K]: Motion.MotionConfigProps[K];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
declare interface SystemHausMotionProviderProperties {
|
|
78
|
+
children?: React__default.ReactNode;
|
|
79
|
+
motionOverrides?: Partial<SystemHausMotionProvider>;
|
|
26
80
|
}
|
|
27
81
|
|
|
28
82
|
export declare function useCursorFollow(settings: CalculateCursorOffsetController): {
|
|
29
|
-
ref:
|
|
30
|
-
x:
|
|
31
|
-
y:
|
|
83
|
+
ref: React_2.Dispatch<React_2.SetStateAction<HTMLDivElement | undefined>>;
|
|
84
|
+
x: Motion.MotionValue<number>;
|
|
85
|
+
y: Motion.MotionValue<number>;
|
|
32
86
|
};
|
|
33
87
|
|
|
34
|
-
export declare function
|
|
88
|
+
export declare function useDeepMergeMotionProperties(...motionProperties: MotionProps[]): MotionProps;
|
|
89
|
+
|
|
90
|
+
export declare const useFadeIn: ({ onEnterDirection, onExitDirection, }?: UseFadeInProperties) => PolymorphicMotionProperties;
|
|
91
|
+
|
|
92
|
+
export declare interface UseFadeInProperties {
|
|
93
|
+
onEnterDirection?: DirectionEnum;
|
|
94
|
+
onExitDirection?: DirectionEnum;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { useMotionValue }
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Scale motion hook — animates an element scaling in/out.
|
|
101
|
+
* Default scale range: visible = 1, hidden = 1.2 (slightly zoomed in).
|
|
102
|
+
*/
|
|
103
|
+
export declare function useScale(payload?: {
|
|
104
|
+
initialScale?: number;
|
|
105
|
+
exitScale?: number;
|
|
106
|
+
}): PolymorphicMotionProperties;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Slide-out motion hook — animates an element in/out based on direction.
|
|
110
|
+
* Default distance: "100%" (full travel).
|
|
111
|
+
*/
|
|
112
|
+
export declare function useSlideOut({ onEnterDirection, onExitDirection, distance, }?: {
|
|
113
|
+
onEnterDirection?: DirectionEnum;
|
|
114
|
+
onExitDirection?: DirectionEnum;
|
|
115
|
+
distance?: string | number;
|
|
116
|
+
}): PolymorphicMotionProperties;
|
|
117
|
+
|
|
118
|
+
export { useSpring }
|
|
119
|
+
|
|
120
|
+
export declare const useSystemHausMotionProvider: () => SystemHausMotionProvider;
|
|
121
|
+
|
|
122
|
+
export { Variant }
|
|
123
|
+
|
|
124
|
+
export { Variants }
|
|
125
|
+
|
|
126
|
+
export { ViewportOptions }
|
|
35
127
|
|
|
36
128
|
export { }
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kurocado-studio/systemhaus-motion-react",
|
|
3
|
-
"version": "1.0.0-develop.
|
|
3
|
+
"version": "1.0.0-develop.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"import": "./dist/exports.js",
|
|
18
18
|
"types": "./dist/index.d.ts",
|
|
19
19
|
"default": "./dist/exports.js"
|
|
20
|
-
},
|
|
21
|
-
"./tailwind.css": {
|
|
22
|
-
"import": "./dist/exports.css",
|
|
23
|
-
"default": "./dist/exports.css"
|
|
24
20
|
}
|
|
25
21
|
},
|
|
26
22
|
"files": [
|
|
@@ -28,13 +24,10 @@
|
|
|
28
24
|
],
|
|
29
25
|
"scripts": {
|
|
30
26
|
"build:typings": "api-extractor run --local",
|
|
31
|
-
"build": "
|
|
27
|
+
"build": "tsup && pnpm build:typings && rm -rf dist/exports.d.ts",
|
|
32
28
|
"prepublishOnly": "node ../../scripts/strip-workspaces.js .",
|
|
33
29
|
"clean": "rm -rf .turbo node_modules dist",
|
|
34
30
|
"dev": "tsup --watch",
|
|
35
|
-
"dev:vite": "vite build --watch --mode development",
|
|
36
|
-
"vite:watch": "vite build --watch --mode development",
|
|
37
|
-
"build:vite": "rm -rf dist && vite build --mode production",
|
|
38
31
|
"lint": "eslint --max-warnings=0 --no-warn-ignored",
|
|
39
32
|
"lint:fix": "eslint --max-warnings=0 --fix --no-warn-ignored",
|
|
40
33
|
"prettier:fix": "prettier --write . --ignore-path ../../.prettierignore",
|
|
@@ -42,10 +35,8 @@
|
|
|
42
35
|
"typecheck": "tsc --noEmit --pretty"
|
|
43
36
|
},
|
|
44
37
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"framer-motion": "^12.23.6",
|
|
38
|
+
"framer-motion": "^12.23.24",
|
|
47
39
|
"lodash-es": "^4.17.21",
|
|
48
|
-
"motion": "^12.11.0",
|
|
49
40
|
"react": "19"
|
|
50
41
|
},
|
|
51
42
|
"devDependencies": {
|
|
@@ -57,17 +48,11 @@
|
|
|
57
48
|
"@types/node": "^22.15.19",
|
|
58
49
|
"@types/react": "^19.1.10",
|
|
59
50
|
"@types/react-dom": "^19.1.4",
|
|
60
|
-
"@vitejs/plugin-react": "^4.4.1",
|
|
61
51
|
"@vitest/coverage-v8": "^3.1.3",
|
|
62
|
-
"copyfiles": "^2.4.1",
|
|
63
52
|
"eslint": "^9.28.0",
|
|
64
53
|
"prettier": "3.5.3",
|
|
65
54
|
"tsup": "^8.5.0",
|
|
66
55
|
"typescript": "5.8.3",
|
|
67
|
-
"vite": "^5.2.8",
|
|
68
|
-
"vite-node": "3.2.4",
|
|
69
|
-
"vite-plugin-dts": "^4.5.3",
|
|
70
|
-
"vite-tsconfig-paths": "^5.1.4",
|
|
71
56
|
"vitest": "^3.1.3"
|
|
72
57
|
}
|
|
73
58
|
}
|