@kurocado-studio/systemhaus-motion-react 1.0.0-develop.1 → 1.0.0-develop.3
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 +54 -16
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +3 -14
package/dist/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{get as
|
|
1
|
+
import{get as A}from"lodash-es";function I(o,t,r,n){var i=o.getBoundingClientRect(),e=i.left+i.width/2,s=i.top+i.height/2,a=t-e,p=r-s,m=n.magneticModeActivationRadius,c=A(n,["maxDistance"],3e3),f=A(n,["intensity"],.1);if(globalThis.matchMedia("(prefers-reduced-motion: reduce)").matches)return{x:0,y:0};if(typeof m=="number"){var u=Math.hypot(Math.pow(a,2)+Math.pow(p,2));if(u>c)return{x:0,y:0};var v=0;return u<m&&(v=1-u/m),{x:a*v*f,y:p*v*f}}if(Math.abs(a)<c&&Math.abs(p)<c){var C=1-Math.max(Math.abs(a),Math.abs(p))/c;return{x:a*C*f,y:p*C*f}}return{x:0,y:0}}var H=.4;var N="easeInOut",d=12;var U=12,M={isStatic:!1,fadeInSpeed:U,fadeDistance:d,transition:{duration:H,ease:N},reducedMotion:"user"};import{get as D}from"lodash-es";import O,{createContext as w,useContext as V,useMemo as B}from"react";var l=(e=>(e.TOP="TOP",e.BOTTOM="BOTTOM",e.LEFT="LEFT",e.RIGHT="RIGHT",e.DEFAULT="DEFAULT",e))(l||{});import{useMotionValue as x,useSpring as T,MotionConfig as h,AnimatePresence as F,motion as P}from"framer-motion";var y={...M,fadeInDirection:"TOP",fadeInDistance:d,viewport:{once:!1,amount:.2}},S=w(y),oe=({children:o,motionOverrides:t})=>{let r=B(()=>({...M,...t,viewport:D(t,["viewport"],y.viewport),fadeInDistance:D(t,["fadeInDistance"],y.fadeInDistance),fadeInDirection:D(t,["fadeInDirection"],y.fadeInDirection)}),[t]);return O.createElement(S.Provider,{value:r},O.createElement(h,{...r},o))},_=()=>V(S);import{get as g}from"lodash-es";import{useEffect as G,useState as X}from"react";function pe(o){let t=g(o,["damping"],100),r=g(o,["stiffness"],600),n=x(0),i=x(0),[e,s]=X(),a=T(n,{damping:t,stiffness:r}),p=T(i,{damping:t,stiffness:r});return G(()=>{let m=c=>{if(!e)return;let{x:f,y:u}=I(e,c.clientX,c.clientY,o);n.set(f),i.set(u)};return document.addEventListener("mousemove",m),()=>document.removeEventListener("mousemove",m)},[e,o,n,i]),{ref:s,x:a,y:p}}import{get as E}from"lodash-es";var R=({onEnterDirection:o,onExitDirection:t}={})=>{let{viewport:r,transition:n,...i}=_(),e=Math.abs(E(i,["fadeInDistance"],d)),s={DEFAULT:{hidden:{opacity:0,y:0},visible:{opacity:1,y:0},exit:{opacity:0,y:0}},TOP:{hidden:{opacity:0,y:-e},visible:{opacity:1,y:0},exit:{opacity:0,y:-e}},BOTTOM:{hidden:{opacity:0,y:e},visible:{opacity:1,y:0},exit:{opacity:0,y:e}},LEFT:{hidden:{opacity:0,x:-e},visible:{opacity:1,x:0},exit:{opacity:0,x:-e}},RIGHT:{hidden:{opacity:0,x:e},visible:{opacity:1,x:0},exit:{opacity:0,x:e}}},a=E(s,[t??"BOTTOM","exit"],s.BOTTOM.exit);return{initial:"hidden",animate:"visible",exit:"exit",variants:{...E(s,[o??"TOP"],s.TOP),exit:a},transition:n,viewport:r}};import{get as q}from"lodash-es";import b from"react";import{cloneDeep as Y,merge as k}from"lodash-es";function L(...o){let t=o.map(r=>Y(r));return k({},...t)}function Ee(o){let{as:t,isVisible:r,onExitDirection:n,onEnterDirection:i,...e}=o,s=R({onEnterDirection:i,onExitDirection:n}),a=typeof r=="boolean"?r:!0,p=e;(n||i)&&(p=L(e,s));let m=q(P,[t??"div"],P.div);return b.createElement(F,null,a&&b.createElement(m,{...p}))}export{l as DirectionEnum,oe as MotionProvider,Ee as PolymorphicMotionElement,L as mergeMotionProperties,y as systemHausMotionConfiguration,pe as useCursorFollow,R as useFadeIn,_ as useSystemHausMotionProvider};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as Motion from 'framer-motion';
|
|
2
|
+
import { MotionProps } from 'framer-motion';
|
|
3
|
+
import { MotionProps as MotionProps_2 } from 'motion/react';
|
|
4
|
+
import * as React_2 from 'react';
|
|
5
|
+
import React__default from 'react';
|
|
6
|
+
import { ViewportOptions } from 'framer-motion';
|
|
3
7
|
|
|
4
8
|
declare type CalculateCursorOffsetController = CursorFollowSettings;
|
|
5
9
|
|
|
@@ -11,26 +15,60 @@ declare interface CursorFollowSettings {
|
|
|
11
15
|
magneticModeActivationRadius?: number;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
export declare
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
export declare enum DirectionEnum {
|
|
19
|
+
TOP = "TOP",
|
|
20
|
+
BOTTOM = "BOTTOM",
|
|
21
|
+
LEFT = "LEFT",
|
|
22
|
+
RIGHT = "RIGHT",
|
|
23
|
+
DEFAULT = "DEFAULT"
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
export declare
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
export declare function mergeMotionProperties(...motionProperties: MotionProps_2[]): MotionProps_2;
|
|
27
|
+
|
|
28
|
+
export declare const MotionProvider: React__default.FC<SystemHausMotionProviderProperties>;
|
|
29
|
+
|
|
30
|
+
export declare function PolymorphicMotionElement<T extends keyof React__default.JSX.IntrinsicElements = 'div'>(properties: React__default.PropsWithChildren<PolymorphicMotionProperties<T>>): React__default.ReactNode;
|
|
31
|
+
|
|
32
|
+
export declare type PolymorphicMotionProperties<T extends keyof React__default.JSX.IntrinsicElements = 'div'> = Omit<React__default.JSX.IntrinsicElements[T], keyof MotionProps | 'ref'> & MotionProps & UseFadeInProperties & {
|
|
33
|
+
as?: T;
|
|
34
|
+
isVisible?: boolean;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
declare type ProvidedConfig = {
|
|
38
|
+
fadeInSpeed: number;
|
|
39
|
+
fadeDistance: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export declare const systemHausMotionConfiguration: SystemHausMotionProvider;
|
|
43
|
+
|
|
44
|
+
export declare interface SystemHausMotionProvider extends SystemHausMotionProviderConfig {
|
|
45
|
+
fadeInDistance: number;
|
|
46
|
+
fadeInDirection: DirectionEnum;
|
|
47
|
+
viewport: ViewportOptions;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare type SystemHausMotionProviderConfig = ProvidedConfig & {
|
|
51
|
+
[K in keyof Motion.MotionConfigProps as Motion.MotionConfigProps[K] extends (...unknowns: unknown[]) => unknown ? never : K]: Motion.MotionConfigProps[K];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
declare interface SystemHausMotionProviderProperties {
|
|
55
|
+
children?: React__default.ReactNode;
|
|
56
|
+
motionOverrides?: Partial<SystemHausMotionProvider>;
|
|
26
57
|
}
|
|
27
58
|
|
|
28
59
|
export declare function useCursorFollow(settings: CalculateCursorOffsetController): {
|
|
29
|
-
ref:
|
|
30
|
-
x:
|
|
31
|
-
y:
|
|
60
|
+
ref: React_2.Dispatch<React_2.SetStateAction<HTMLDivElement | undefined>>;
|
|
61
|
+
x: Motion.MotionValue<number>;
|
|
62
|
+
y: Motion.MotionValue<number>;
|
|
32
63
|
};
|
|
33
64
|
|
|
34
|
-
export declare
|
|
65
|
+
export declare const useFadeIn: ({ onEnterDirection, onExitDirection, }?: UseFadeInProperties) => PolymorphicMotionProperties;
|
|
66
|
+
|
|
67
|
+
export declare interface UseFadeInProperties {
|
|
68
|
+
onEnterDirection?: DirectionEnum;
|
|
69
|
+
onExitDirection?: DirectionEnum;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export declare const useSystemHausMotionProvider: () => SystemHausMotionProvider;
|
|
35
73
|
|
|
36
74
|
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.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,13 +28,10 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build:typings": "api-extractor run --local",
|
|
31
|
-
"build": "
|
|
31
|
+
"build": "tsup && pnpm build:typings && rm -rf dist/exports.d.ts",
|
|
32
32
|
"prepublishOnly": "node ../../scripts/strip-workspaces.js .",
|
|
33
33
|
"clean": "rm -rf .turbo node_modules dist",
|
|
34
34
|
"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
35
|
"lint": "eslint --max-warnings=0 --no-warn-ignored",
|
|
39
36
|
"lint:fix": "eslint --max-warnings=0 --fix --no-warn-ignored",
|
|
40
37
|
"prettier:fix": "prettier --write . --ignore-path ../../.prettierignore",
|
|
@@ -42,10 +39,8 @@
|
|
|
42
39
|
"typecheck": "tsc --noEmit --pretty"
|
|
43
40
|
},
|
|
44
41
|
"dependencies": {
|
|
45
|
-
"
|
|
46
|
-
"framer-motion": "^12.23.6",
|
|
42
|
+
"framer-motion": "^12.23.24",
|
|
47
43
|
"lodash-es": "^4.17.21",
|
|
48
|
-
"motion": "^12.11.0",
|
|
49
44
|
"react": "19"
|
|
50
45
|
},
|
|
51
46
|
"devDependencies": {
|
|
@@ -57,17 +52,11 @@
|
|
|
57
52
|
"@types/node": "^22.15.19",
|
|
58
53
|
"@types/react": "^19.1.10",
|
|
59
54
|
"@types/react-dom": "^19.1.4",
|
|
60
|
-
"@vitejs/plugin-react": "^4.4.1",
|
|
61
55
|
"@vitest/coverage-v8": "^3.1.3",
|
|
62
|
-
"copyfiles": "^2.4.1",
|
|
63
56
|
"eslint": "^9.28.0",
|
|
64
57
|
"prettier": "3.5.3",
|
|
65
58
|
"tsup": "^8.5.0",
|
|
66
59
|
"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
60
|
"vitest": "^3.1.3"
|
|
72
61
|
}
|
|
73
62
|
}
|