@cdx-ui/components 0.0.1-beta.112 → 0.0.1-beta.113
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/lib/commonjs/animation/hooks/index.js +33 -0
- package/lib/commonjs/animation/hooks/index.js.map +1 -1
- package/lib/commonjs/animation/hooks/usePopupDialogContentAnimation.js +173 -0
- package/lib/commonjs/animation/hooks/usePopupDialogContentAnimation.js.map +1 -0
- package/lib/commonjs/animation/hooks/usePopupOverlayAnimation.js +67 -0
- package/lib/commonjs/animation/hooks/usePopupOverlayAnimation.js.map +1 -0
- package/lib/commonjs/animation/hooks/usePopupRootAnimation.js +26 -0
- package/lib/commonjs/animation/hooks/usePopupRootAnimation.js.map +1 -0
- package/lib/commonjs/components/AlertDialog/index.js +15 -1
- package/lib/commonjs/components/AlertDialog/index.js.map +1 -1
- package/lib/commonjs/components/Dialog/animation.js +13 -0
- package/lib/commonjs/components/Dialog/animation.js.map +1 -0
- package/lib/commonjs/components/Dialog/index.js +267 -24
- package/lib/commonjs/components/Dialog/index.js.map +1 -1
- package/lib/commonjs/components/Dialog/styles.js +7 -3
- package/lib/commonjs/components/Dialog/styles.js.map +1 -1
- package/lib/module/animation/hooks/index.js +3 -0
- package/lib/module/animation/hooks/index.js.map +1 -1
- package/lib/module/animation/hooks/usePopupDialogContentAnimation.js +169 -0
- package/lib/module/animation/hooks/usePopupDialogContentAnimation.js.map +1 -0
- package/lib/module/animation/hooks/usePopupOverlayAnimation.js +63 -0
- package/lib/module/animation/hooks/usePopupOverlayAnimation.js.map +1 -0
- package/lib/module/animation/hooks/usePopupRootAnimation.js +22 -0
- package/lib/module/animation/hooks/usePopupRootAnimation.js.map +1 -0
- package/lib/module/components/AlertDialog/index.js +15 -1
- package/lib/module/components/AlertDialog/index.js.map +1 -1
- package/lib/module/components/Dialog/animation.js +7 -0
- package/lib/module/components/Dialog/animation.js.map +1 -0
- package/lib/module/components/Dialog/index.js +271 -30
- package/lib/module/components/Dialog/index.js.map +1 -1
- package/lib/module/components/Dialog/styles.js +6 -2
- package/lib/module/components/Dialog/styles.js.map +1 -1
- package/lib/typescript/animation/hooks/index.d.ts +3 -0
- package/lib/typescript/animation/hooks/index.d.ts.map +1 -1
- package/lib/typescript/animation/hooks/usePopupDialogContentAnimation.d.ts +47 -0
- package/lib/typescript/animation/hooks/usePopupDialogContentAnimation.d.ts.map +1 -0
- package/lib/typescript/animation/hooks/usePopupOverlayAnimation.d.ts +29 -0
- package/lib/typescript/animation/hooks/usePopupOverlayAnimation.d.ts.map +1 -0
- package/lib/typescript/animation/hooks/usePopupRootAnimation.d.ts +16 -0
- package/lib/typescript/animation/hooks/usePopupRootAnimation.d.ts.map +1 -0
- package/lib/typescript/components/AlertDialog/index.d.ts +5 -2
- package/lib/typescript/components/AlertDialog/index.d.ts.map +1 -1
- package/lib/typescript/components/Dialog/animation.d.ts +11 -0
- package/lib/typescript/components/Dialog/animation.d.ts.map +1 -0
- package/lib/typescript/components/Dialog/index.d.ts +6 -2
- package/lib/typescript/components/Dialog/index.d.ts.map +1 -1
- package/lib/typescript/components/Dialog/styles.d.ts +1 -0
- package/lib/typescript/components/Dialog/styles.d.ts.map +1 -1
- package/package.json +13 -5
- package/src/animation/hooks/index.ts +3 -0
- package/src/animation/hooks/usePopupDialogContentAnimation.ts +256 -0
- package/src/animation/hooks/usePopupOverlayAnimation.ts +84 -0
- package/src/animation/hooks/usePopupRootAnimation.ts +27 -0
- package/src/components/AlertDialog/index.tsx +16 -3
- package/src/components/Dialog/animation.ts +13 -0
- package/src/components/Dialog/index.tsx +331 -31
- package/src/components/Dialog/styles.ts +22 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","cva","TRANSITION_COLORS","dialogOverlayVariants","dialogPopupVariants","select","web","default","variants","size","xs","sm","md","lg","xl","full","defaultVariants","dialogHeaderVariants","dialogTitleVariants","appearance","danger","warning","success","dialogTitleIconVariants","dialogDescriptionVariants","dialogContentVariants","fullBleed","true","false","dialogTextVariants","dialogFooterVariants","dialogCloseVariants","join","dialogCloseIconVariants"],"sourceRoot":"../../../../src","sources":["components/Dialog/styles.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,GAAG,QAA2B,0BAA0B;AACjE,SAASC,iBAAiB,QAAQ,wBAAwB;;AAE1D;;AAEA,OAAO,MAAMC,
|
|
1
|
+
{"version":3,"names":["Platform","cva","TRANSITION_COLORS","dialogPortalVariants","dialogOverlayVariants","dialogPopupVariants","select","web","default","variants","size","xs","sm","md","lg","xl","full","defaultVariants","dialogHeaderVariants","dialogTitleVariants","appearance","danger","warning","success","dialogTitleIconVariants","dialogDescriptionVariants","dialogContentVariants","fullBleed","true","false","dialogTextVariants","dialogFooterVariants","dialogCloseVariants","join","dialogCloseIconVariants"],"sourceRoot":"../../../../src","sources":["components/Dialog/styles.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,GAAG,QAA2B,0BAA0B;AACjE,SAASC,iBAAiB,QAAQ,wBAAwB;;AAE1D;;AAEA,OAAO,MAAMC,oBAAoB,GAAGF,GAAG,CAAC,CACtC,QAAQ,EACR,kBAAkB,EAClB,gCAAgC,CACjC,CAAC;;AAEF;;AAEA,OAAO,MAAMG,qBAAqB,GAAGH,GAAG,CAAC,CACvC,kBAAkB,EAClB,qBAAqB,EACrB,sDAAsD,EACtD,qCAAqC,EACrC,mCAAmC,EACnC,wEAAwE,EACxE,gEAAgE,CACjE,CAAC;;AAEF;;AAEA,OAAO,MAAMI,mBAAmB,GAAGJ,GAAG,CACpC,CACE,oBAAoB,EACpB,YAAY,EACZD,QAAQ,CAACM,MAAM,CAAC;EAAEC,GAAG,EAAE,WAAW;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,EAClD,8BAA8B,EAC9B,kEAAkE,EAClE,4EAA4E,EAC5E,mEAAmE,EACnE,6GAA6G,EAC7G,gEAAgE,CACjE,EACD;EACEC,QAAQ,EAAE;IACRC,IAAI,EAAE;MACJC,EAAE,EAAE,kBAAkB;MACtBC,EAAE,EAAE,kBAAkB;MACtBC,EAAE,EAAE,kBAAkB;MACtBC,EAAE,EAAE,kBAAkB;MACtBC,EAAE,EAAE,kBAAkB;MACtBC,IAAI,EAAE;IACR;EACF,CAAC;EACDC,eAAe,EAAE;IACfP,IAAI,EAAE;EACR;AACF,CACF,CAAC;;AAED;;AAEA,OAAO,MAAMQ,oBAAoB,GAAGjB,GAAG,CAAC,CACtC,+CAA+C,EAC/C,iBAAiB,CAClB,CAAC;;AAEF;;AAEA,OAAO,MAAMkB,mBAAmB,GAAGlB,GAAG,CAAC,CAAC,YAAY,EAAE,sBAAsB,CAAC,EAAE;EAC7EQ,QAAQ,EAAE;IACRW,UAAU,EAAE;MACVZ,OAAO,EAAE,EAAE;MACXa,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE,EAAE;MACXC,OAAO,EAAE;IACX;EACF,CAAC;EACDN,eAAe,EAAE;IACfG,UAAU,EAAE;EACd;AACF,CAAC,CAAC;;AAEF;;AAEA,OAAO,MAAMI,uBAAuB,GAAGvB,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE;EACrDQ,QAAQ,EAAE;IACRW,UAAU,EAAE;MACVZ,OAAO,EAAE,EAAE;MACXa,MAAM,EAAE,qBAAqB;MAC7BC,OAAO,EAAE,sBAAsB;MAC/BC,OAAO,EAAE;IACX;EACF,CAAC;EACDN,eAAe,EAAE;IACfG,UAAU,EAAE;EACd;AACF,CAAC,CAAC;;AAEF;;AAEA,OAAO,MAAMK,yBAAyB,GAAGxB,GAAG,CAAC,CAAC,cAAc,EAAE,wBAAwB,CAAC,CAAC;;AAExF;;AAEA,OAAO,MAAMyB,qBAAqB,GAAGzB,GAAG,CAAC,CAAC,gCAAgC,CAAC,EAAE;EAC3EQ,QAAQ,EAAE;IACRkB,SAAS,EAAE;MACTC,IAAI,EAAE,MAAM;MACZC,KAAK,EAAE;IACT;EACF,CAAC;EACDZ,eAAe,EAAE;IACfU,SAAS,EAAE;EACb;AACF,CAAC,CAAC;;AAEF;;AAEA,OAAO,MAAMG,kBAAkB,GAAG7B,GAAG,CAAC,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;;AAE1E;;AAEA,OAAO,MAAM8B,oBAAoB,GAAG9B,GAAG,CAAC,CACtC,4CAA4C,EAC5C,sBAAsB,CACvB,CAAC;;AAEF;;AAEA,OAAO,MAAM+B,mBAAmB,GAAG/B,GAAG,CAAC,CACrC,kCAAkC,EAClC,uDAAuD,EACvD,sBAAsB,EACtBC,iBAAiB,EACjBF,QAAQ,CAACM,MAAM,CAAC;EACdE,OAAO,EAAE,+BAA+B;EACxCD,GAAG,EAAE,CACH,4CAA4C,EAC5C,8CAA8C,EAC9C,sHAAsH,CACvH,CAAC0B,IAAI,CAAC,GAAG;AACZ,CAAC,CAAC,CACH,CAAC;;AAEF;;AAEA,OAAO,MAAMC,uBAAuB,GAAGjC,GAAG,CAAC,CAAC,8BAA8B,CAAC,CAAC;;AAE5E","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/animation/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/animation/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import type { PopupDialogContentAnimation } from '../types';
|
|
3
|
+
export interface UsePopupDialogContentAnimationOptions {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
progress: SharedValue<number>;
|
|
6
|
+
isDragging: SharedValue<boolean>;
|
|
7
|
+
isGestureReleaseAnimationRunning: SharedValue<boolean>;
|
|
8
|
+
onOpenChange: (open: boolean) => void;
|
|
9
|
+
animation?: PopupDialogContentAnimation;
|
|
10
|
+
/** @default true */
|
|
11
|
+
isSwipeable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Animation hook for popup dialog content (panel).
|
|
15
|
+
* Handles enter/exit Keyframes, swipe-to-dismiss gesture, and drag-driven
|
|
16
|
+
* translateY + scale via a shared `progress` value.
|
|
17
|
+
*
|
|
18
|
+
* On web, entering/exiting are undefined (CSS transitions drive the visuals)
|
|
19
|
+
* and the gesture is disabled.
|
|
20
|
+
*/
|
|
21
|
+
export declare function usePopupDialogContentAnimation({ isOpen, progress, isDragging, isGestureReleaseAnimationRunning, onOpenChange, animation, isSwipeable, }: UsePopupDialogContentAnimationOptions): {
|
|
22
|
+
contentY: SharedValue<number>;
|
|
23
|
+
contentHeight: SharedValue<number>;
|
|
24
|
+
panGesture: import("react-native-gesture-handler/lib/typescript/handlers/gestures/panGesture").PanGesture;
|
|
25
|
+
rDragContainerStyle: {
|
|
26
|
+
opacity: number;
|
|
27
|
+
transform: ({
|
|
28
|
+
translateY: number;
|
|
29
|
+
scale?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
scale: number;
|
|
32
|
+
translateY?: undefined;
|
|
33
|
+
})[];
|
|
34
|
+
} | {
|
|
35
|
+
transform: ({
|
|
36
|
+
translateY: number;
|
|
37
|
+
scale?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
scale: number;
|
|
40
|
+
translateY?: undefined;
|
|
41
|
+
})[];
|
|
42
|
+
opacity?: undefined;
|
|
43
|
+
};
|
|
44
|
+
entering: import("react-native-reanimated").BaseAnimationBuilder | ((targetValues: import("react-native-reanimated").EntryAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | ((targetValues: import("react-native-reanimated").ExitAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | import("react-native-reanimated").ReanimatedKeyframe | undefined;
|
|
45
|
+
exiting: import("react-native-reanimated").BaseAnimationBuilder | ((targetValues: import("react-native-reanimated").EntryAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | ((targetValues: import("react-native-reanimated").ExitAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | import("react-native-reanimated").ReanimatedKeyframe | undefined;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=usePopupDialogContentAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePopupDialogContentAnimation.d.ts","sourceRoot":"","sources":["../../../../src/animation/hooks/usePopupDialogContentAnimation.ts"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAK5D,MAAM,WAAW,qCAAqC;IACpD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACjC,gCAAgC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACvD,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,SAAS,CAAC,EAAE,2BAA2B,CAAC;IACxC,oBAAoB;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA0BD;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,MAAM,EACN,QAAQ,EACR,UAAU,EACV,gCAAgC,EAChC,YAAY,EACZ,SAAS,EACT,WAAkB,GACnB,EAAE,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;EAsLvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
import type { PopupOverlayAnimation } from '../types';
|
|
3
|
+
export interface UsePopupOverlayAnimationOptions {
|
|
4
|
+
/** Animation progress shared value (0=idle, 1=open, 2=close) */
|
|
5
|
+
progress?: SharedValue<number>;
|
|
6
|
+
/** Dragging state shared value */
|
|
7
|
+
isDragging?: SharedValue<boolean>;
|
|
8
|
+
/** Gesture release animation running state (for components with swipe gestures) */
|
|
9
|
+
isGestureReleaseAnimationRunning?: SharedValue<boolean>;
|
|
10
|
+
/** Animation configuration for overlay */
|
|
11
|
+
animation?: PopupOverlayAnimation;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Animation hook for popup overlay (backdrop) components.
|
|
15
|
+
* Shared by Dialog, Select, BottomSheet, Popover, etc.
|
|
16
|
+
*
|
|
17
|
+
* Returns progress-based opacity style and entering/exiting layout animations.
|
|
18
|
+
* On web, entering/exiting are undefined (CSS transitions drive the visuals).
|
|
19
|
+
*/
|
|
20
|
+
export declare function usePopupOverlayAnimation(options: UsePopupOverlayAnimationOptions): {
|
|
21
|
+
rContainerStyle: {
|
|
22
|
+
opacity?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
opacity: number;
|
|
25
|
+
};
|
|
26
|
+
entering: import("react-native-reanimated").BaseAnimationBuilder | ((targetValues: import("react-native-reanimated").EntryAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | ((targetValues: import("react-native-reanimated").ExitAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | import("react-native-reanimated").ReanimatedKeyframe | undefined;
|
|
27
|
+
exiting: import("react-native-reanimated").BaseAnimationBuilder | ((targetValues: import("react-native-reanimated").EntryAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | ((targetValues: import("react-native-reanimated").ExitAnimationsValues) => import("react-native-reanimated").LayoutAnimation) | import("react-native-reanimated").ReanimatedKeyframe | undefined;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=usePopupOverlayAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePopupOverlayAnimation.d.ts","sourceRoot":"","sources":["../../../../src/animation/hooks/usePopupOverlayAnimation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAStD,MAAM,WAAW,+BAA+B;IAC9C,gEAAgE;IAChE,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,kCAAkC;IAClC,UAAU,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,mFAAmF;IACnF,gCAAgC,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACxD,0CAA0C;IAC1C,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,+BAA+B;;;;;;;;EAoDhF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnimationRootDisableAll } from '../types';
|
|
2
|
+
export interface UsePopupRootAnimationOptions {
|
|
3
|
+
animation?: AnimationRootDisableAll;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Root animation hook for popup-like components (Dialog, Select, BottomSheet, Popover, etc.)
|
|
7
|
+
* Manages component state transitions and animation coordination via a shared
|
|
8
|
+
* `progress` value: 0 = idle/closed, 1 = fully open, 2 = dismissed.
|
|
9
|
+
*/
|
|
10
|
+
export declare function usePopupRootAnimation(options: UsePopupRootAnimationOptions): {
|
|
11
|
+
isAllAnimationsDisabled: boolean;
|
|
12
|
+
progress: import("react-native-reanimated").SharedValue<number>;
|
|
13
|
+
isDragging: import("react-native-reanimated").SharedValue<boolean>;
|
|
14
|
+
isGestureReleaseAnimationRunning: import("react-native-reanimated").SharedValue<boolean>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=usePopupRootAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePopupRootAnimation.d.ts","sourceRoot":"","sources":["../../../../src/animation/hooks/usePopupRootAnimation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,uBAAuB,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B;;;;;EAa1E"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { type ButtonProps } from '../Button';
|
|
4
|
-
import { Dialog, type DialogRootProps } from '../Dialog';
|
|
4
|
+
import { Dialog, type DialogRootProps, type DialogPopupProps } from '../Dialog';
|
|
5
5
|
export interface AlertDialogRootProps extends DialogRootProps {
|
|
6
6
|
}
|
|
7
7
|
declare const AlertDialogRoot: React.ForwardRefExoticComponent<AlertDialogRootProps & React.RefAttributes<View>>;
|
|
8
|
+
export interface AlertDialogPopupProps extends DialogPopupProps {
|
|
9
|
+
}
|
|
10
|
+
declare const AlertDialogPopup: React.ForwardRefExoticComponent<AlertDialogPopupProps & React.RefAttributes<View>>;
|
|
8
11
|
export interface AlertDialogActionProps extends Omit<ButtonProps, 'variant'> {
|
|
9
12
|
readonly asChild?: boolean;
|
|
10
13
|
}
|
|
@@ -15,7 +18,7 @@ export interface AlertDialogCancelProps extends Omit<ButtonProps, 'variant'> {
|
|
|
15
18
|
declare const AlertDialogCancel: React.ForwardRefExoticComponent<AlertDialogCancelProps & React.RefAttributes<View>>;
|
|
16
19
|
type AlertDialogCompoundComponent = typeof AlertDialogRoot & {
|
|
17
20
|
Trigger: typeof Dialog.Trigger;
|
|
18
|
-
Popup: typeof
|
|
21
|
+
Popup: typeof AlertDialogPopup;
|
|
19
22
|
Header: typeof Dialog.Header;
|
|
20
23
|
Title: typeof Dialog.Title;
|
|
21
24
|
Description: typeof Dialog.Description;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/AlertDialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/AlertDialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAMhF,MAAM,WAAW,oBAAqB,SAAQ,eAAe;CAAG;AAEhE,QAAA,MAAM,eAAe,mFAqBpB,CAAC;AAOF,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;CAAG;AAElE,QAAA,MAAM,gBAAgB,oFAIrB,CAAC;AAOF,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,QAAA,MAAM,iBAAiB,qFAgBtB,CAAC;AAOF,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,QAAA,MAAM,iBAAiB,qFAmBtB,CAAC;AAOF,KAAK,4BAA4B,GAAG,OAAO,eAAe,GAAG;IAC3D,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IAC/B,KAAK,EAAE,OAAO,gBAAgB,CAAC;IAC/B,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC;IAC3B,WAAW,EAAE,OAAO,MAAM,CAAC,WAAW,CAAC;IACvC,OAAO,EAAE,OAAO,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC;IACzB,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IAC7B,KAAK,EAAE,OAAO,MAAM,CAAC,KAAK,CAAC;IAC3B,MAAM,EAAE,OAAO,iBAAiB,CAAC;IACjC,MAAM,EAAE,OAAO,iBAAiB,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,WAAW,EAYlB,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
2
|
+
export interface DialogAnimationContextValue {
|
|
3
|
+
progress: SharedValue<number>;
|
|
4
|
+
isDragging: SharedValue<boolean>;
|
|
5
|
+
isGestureReleaseAnimationRunning: SharedValue<boolean>;
|
|
6
|
+
}
|
|
7
|
+
export declare const DialogAnimationProvider: import("react").FunctionComponent<{
|
|
8
|
+
children: import("react").ReactNode;
|
|
9
|
+
value: DialogAnimationContextValue;
|
|
10
|
+
}>, useDialogAnimation: () => DialogAnimationContextValue;
|
|
11
|
+
//# sourceMappingURL=animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/animation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACjC,gCAAgC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACxD;AAED,eAAO,MAAO,uBAAuB;;;IAAE,kBAAkB,mCAGrD,CAAC"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { Text, View, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
-
import { type IDialogCloseProps, type
|
|
3
|
+
import { type IDialogCloseProps, type IDialogContentProps, type IDialogRootProps, type IDialogTriggerProps } from '@cdx-ui/primitives';
|
|
4
|
+
import { type AnimationRootDisableAll } from '../../animation';
|
|
4
5
|
import { type DialogTitleVariantProps, type DialogVariantProps } from './styles';
|
|
5
6
|
export { useDialog } from '@cdx-ui/primitives';
|
|
6
7
|
export interface DialogRootProps extends Omit<ViewProps, 'children' | 'role'>, IDialogRootProps, DialogVariantProps {
|
|
7
8
|
className?: string;
|
|
9
|
+
animation?: AnimationRootDisableAll;
|
|
8
10
|
}
|
|
9
11
|
declare const DialogRoot: import("react").ForwardRefExoticComponent<DialogRootProps & import("react").RefAttributes<View>>;
|
|
10
12
|
export interface DialogTriggerProps extends IDialogTriggerProps {
|
|
@@ -12,9 +14,11 @@ export interface DialogTriggerProps extends IDialogTriggerProps {
|
|
|
12
14
|
children?: ReactNode;
|
|
13
15
|
}
|
|
14
16
|
declare const DialogTrigger: import("react").ForwardRefExoticComponent<DialogTriggerProps & import("react").RefAttributes<View>>;
|
|
15
|
-
export interface DialogPopupProps extends
|
|
17
|
+
export interface DialogPopupProps extends Omit<IDialogContentProps, 'asChild'>, Pick<DialogVariantProps, 'size'> {
|
|
16
18
|
className?: string;
|
|
17
19
|
children?: ReactNode;
|
|
20
|
+
disableFullWindowOverlay?: boolean;
|
|
21
|
+
isSwipeable?: boolean;
|
|
18
22
|
}
|
|
19
23
|
declare const DialogPopup: import("react").ForwardRefExoticComponent<DialogPopupProps & import("react").RefAttributes<View>>;
|
|
20
24
|
export interface DialogHeaderProps extends ViewProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/index.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
export declare const dialogPortalVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
2
3
|
export declare const dialogOverlayVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
|
|
3
4
|
export declare const dialogPopupVariants: (props?: ({
|
|
4
5
|
size?: "full" | "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKlE,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKlE,eAAO,MAAM,oBAAoB,oFAI/B,CAAC;AAIH,eAAO,MAAM,qBAAqB,oFAQhC,CAAC;AAIH,eAAO,MAAM,mBAAmB;;8EA2B/B,CAAC;AAIF,eAAO,MAAM,oBAAoB,oFAG/B,CAAC;AAIH,eAAO,MAAM,mBAAmB;;8EAY9B,CAAC;AAIH,eAAO,MAAM,uBAAuB;;8EAYlC,CAAC;AAIH,eAAO,MAAM,yBAAyB,oFAAkD,CAAC;AAIzF,eAAO,MAAM,qBAAqB;;8EAUhC,CAAC;AAIH,eAAO,MAAM,kBAAkB,oFAA2C,CAAC;AAI3E,eAAO,MAAM,oBAAoB,oFAG/B,CAAC;AAIH,eAAO,MAAM,mBAAmB,oFAa9B,CAAC;AAIH,eAAO,MAAM,uBAAuB,oFAAwC,CAAC;AAI7E,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,OAAO,mBAAmB,CAAC,GAAG;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,YAAY,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/components",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.113",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -45,9 +45,11 @@
|
|
|
45
45
|
"@shopify/flash-list": ">=2.0.0",
|
|
46
46
|
"react": "^18.2.0 || ^19.0.0",
|
|
47
47
|
"react-native": ">=0.76.0",
|
|
48
|
+
"react-native-gesture-handler": ">=2.0.0",
|
|
48
49
|
"react-native-reanimated": ">=4.0.0",
|
|
49
50
|
"react-native-safe-area-context": ">=4.0.0",
|
|
50
|
-
"react-native-web": ">=0.19.0"
|
|
51
|
+
"react-native-web": ">=0.19.0",
|
|
52
|
+
"react-native-worklets": ">=0.4.0"
|
|
51
53
|
},
|
|
52
54
|
"peerDependenciesMeta": {
|
|
53
55
|
"@shopify/flash-list": {
|
|
@@ -56,11 +58,17 @@
|
|
|
56
58
|
"react-native": {
|
|
57
59
|
"optional": true
|
|
58
60
|
},
|
|
61
|
+
"react-native-gesture-handler": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
59
64
|
"react-native-reanimated": {
|
|
60
65
|
"optional": true
|
|
61
66
|
},
|
|
62
67
|
"react-native-web": {
|
|
63
68
|
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"react-native-worklets": {
|
|
71
|
+
"optional": true
|
|
64
72
|
}
|
|
65
73
|
},
|
|
66
74
|
"dependencies": {
|
|
@@ -68,9 +76,9 @@
|
|
|
68
76
|
"class-variance-authority": "^0.7.1",
|
|
69
77
|
"react-native-reanimated-carousel": "5.0.0-beta.5",
|
|
70
78
|
"uniwind": "1.10.0",
|
|
71
|
-
"@cdx-ui/utils": "0.0.1-beta.
|
|
72
|
-
"@cdx-ui/
|
|
73
|
-
"@cdx-ui/
|
|
79
|
+
"@cdx-ui/utils": "0.0.1-beta.113",
|
|
80
|
+
"@cdx-ui/primitives": "0.0.1-beta.113",
|
|
81
|
+
"@cdx-ui/icons": "0.0.1-beta.113"
|
|
74
82
|
},
|
|
75
83
|
"devDependencies": {
|
|
76
84
|
"@react-navigation/bottom-tabs": "*",
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { Keyboard, Platform, useWindowDimensions } from 'react-native';
|
|
3
|
+
import { Gesture } from 'react-native-gesture-handler';
|
|
4
|
+
import {
|
|
5
|
+
Easing,
|
|
6
|
+
Extrapolation,
|
|
7
|
+
interpolate,
|
|
8
|
+
Keyframe,
|
|
9
|
+
useAnimatedStyle,
|
|
10
|
+
useDerivedValue,
|
|
11
|
+
useSharedValue,
|
|
12
|
+
withSpring,
|
|
13
|
+
type EntryOrExitLayoutType,
|
|
14
|
+
type SharedValue,
|
|
15
|
+
} from 'react-native-reanimated';
|
|
16
|
+
import { scheduleOnRN } from 'react-native-worklets';
|
|
17
|
+
import { useAnimationSettings } from '../../providers/animation-settings';
|
|
18
|
+
import type { PopupDialogContentAnimation } from '../types';
|
|
19
|
+
import { getAnimationState, getIsAnimationDisabledValue } from '../utils';
|
|
20
|
+
|
|
21
|
+
const IS_WEB = Platform.OS === 'web';
|
|
22
|
+
|
|
23
|
+
export interface UsePopupDialogContentAnimationOptions {
|
|
24
|
+
isOpen: boolean;
|
|
25
|
+
progress: SharedValue<number>;
|
|
26
|
+
isDragging: SharedValue<boolean>;
|
|
27
|
+
isGestureReleaseAnimationRunning: SharedValue<boolean>;
|
|
28
|
+
onOpenChange: (open: boolean) => void;
|
|
29
|
+
animation?: PopupDialogContentAnimation;
|
|
30
|
+
/** @default true */
|
|
31
|
+
isSwipeable?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const DEFAULT_ENTERING_ANIMATION: EntryOrExitLayoutType = new Keyframe({
|
|
35
|
+
0: {
|
|
36
|
+
transform: [{ scale: 0.96 }],
|
|
37
|
+
opacity: 0,
|
|
38
|
+
},
|
|
39
|
+
100: {
|
|
40
|
+
transform: [{ scale: 1 }],
|
|
41
|
+
opacity: 1,
|
|
42
|
+
easing: Easing.out(Easing.ease),
|
|
43
|
+
},
|
|
44
|
+
}).duration(200);
|
|
45
|
+
|
|
46
|
+
const DEFAULT_EXITING_ANIMATION: EntryOrExitLayoutType = new Keyframe({
|
|
47
|
+
0: {
|
|
48
|
+
transform: [{ scale: 1 }],
|
|
49
|
+
opacity: 1,
|
|
50
|
+
},
|
|
51
|
+
100: {
|
|
52
|
+
transform: [{ scale: 0.96 }],
|
|
53
|
+
opacity: 0,
|
|
54
|
+
easing: Easing.in(Easing.ease),
|
|
55
|
+
},
|
|
56
|
+
}).duration(150);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Animation hook for popup dialog content (panel).
|
|
60
|
+
* Handles enter/exit Keyframes, swipe-to-dismiss gesture, and drag-driven
|
|
61
|
+
* translateY + scale via a shared `progress` value.
|
|
62
|
+
*
|
|
63
|
+
* On web, entering/exiting are undefined (CSS transitions drive the visuals)
|
|
64
|
+
* and the gesture is disabled.
|
|
65
|
+
*/
|
|
66
|
+
export function usePopupDialogContentAnimation({
|
|
67
|
+
isOpen,
|
|
68
|
+
progress,
|
|
69
|
+
isDragging,
|
|
70
|
+
isGestureReleaseAnimationRunning,
|
|
71
|
+
onOpenChange,
|
|
72
|
+
animation,
|
|
73
|
+
isSwipeable = true,
|
|
74
|
+
}: UsePopupDialogContentAnimationOptions) {
|
|
75
|
+
const { height: screenHeight } = useWindowDimensions();
|
|
76
|
+
|
|
77
|
+
const animationSettingsContext = useAnimationSettings();
|
|
78
|
+
const isAllAnimationsDisabled = animationSettingsContext?.isAllAnimationsDisabled;
|
|
79
|
+
|
|
80
|
+
const { animationConfig, isAnimationDisabled } = getAnimationState(animation);
|
|
81
|
+
|
|
82
|
+
const isAnimationDisabledValue = getIsAnimationDisabledValue({
|
|
83
|
+
isAnimationDisabled,
|
|
84
|
+
isAllAnimationsDisabled,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const enteringValue = animationConfig?.entering ?? DEFAULT_ENTERING_ANIMATION;
|
|
88
|
+
const exitingValue = animationConfig?.exiting ?? DEFAULT_EXITING_ANIMATION;
|
|
89
|
+
|
|
90
|
+
const contentY = useSharedValue(0);
|
|
91
|
+
const contentHeight = useSharedValue(0);
|
|
92
|
+
const progressAnchor = useSharedValue(1);
|
|
93
|
+
const contentTranslateYAnchor = useSharedValue(0);
|
|
94
|
+
const contentScaleAnchor = useSharedValue(1);
|
|
95
|
+
const gestureTranslationY = useSharedValue(0);
|
|
96
|
+
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (isOpen) {
|
|
99
|
+
progress.set(1);
|
|
100
|
+
}
|
|
101
|
+
}, [isOpen, progress]);
|
|
102
|
+
|
|
103
|
+
const dismissKeyboard = () => {
|
|
104
|
+
Keyboard.dismiss();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const contentTranslateY = useDerivedValue(() => {
|
|
108
|
+
const maxDragDistance = screenHeight - contentY.get();
|
|
109
|
+
|
|
110
|
+
if (progress.get() >= 1) {
|
|
111
|
+
return interpolate(progress.get(), [1, 2], [0, maxDragDistance], Extrapolation.CLAMP);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const absoluteGestureTranslationY = Math.abs(gestureTranslationY.get());
|
|
115
|
+
|
|
116
|
+
return interpolate(
|
|
117
|
+
absoluteGestureTranslationY,
|
|
118
|
+
[0, screenHeight],
|
|
119
|
+
[0, -50],
|
|
120
|
+
Extrapolation.CLAMP,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const contentScale = useDerivedValue(() => {
|
|
125
|
+
return interpolate(progress.get(), [1, 2], [1, 0.95], Extrapolation.CLAMP);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const panGesture = useMemo(
|
|
129
|
+
() =>
|
|
130
|
+
Gesture.Pan()
|
|
131
|
+
.enabled(isSwipeable && isOpen && !isAnimationDisabledValue && !IS_WEB)
|
|
132
|
+
.onStart(() => isDragging.set(true))
|
|
133
|
+
.onUpdate((event) => {
|
|
134
|
+
if (!isDragging.get()) return;
|
|
135
|
+
|
|
136
|
+
const maxDragDistance = screenHeight - contentY.get();
|
|
137
|
+
|
|
138
|
+
gestureTranslationY.set(event.translationY);
|
|
139
|
+
|
|
140
|
+
if (event.translationY > 0) {
|
|
141
|
+
const progressValue = 1 + event.translationY / maxDragDistance;
|
|
142
|
+
progress.set(Math.max(1, Math.min(progressValue, 2)));
|
|
143
|
+
} else if (event.translationY < 0) {
|
|
144
|
+
const progressValue = 1 - Math.abs(event.translationY) / contentY.get();
|
|
145
|
+
progress.set(Math.max(0, Math.min(progressValue, 1)));
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
.onFinalize(() => {
|
|
149
|
+
progressAnchor.set(progress.get());
|
|
150
|
+
contentTranslateYAnchor.set(contentTranslateY.get());
|
|
151
|
+
contentScaleAnchor.set(contentScale.get());
|
|
152
|
+
|
|
153
|
+
if (progress.get() > 1.1) {
|
|
154
|
+
isGestureReleaseAnimationRunning.set(true);
|
|
155
|
+
scheduleOnRN(dismissKeyboard);
|
|
156
|
+
progress.set(
|
|
157
|
+
withSpring(
|
|
158
|
+
2,
|
|
159
|
+
{
|
|
160
|
+
mass: 4,
|
|
161
|
+
damping: 120,
|
|
162
|
+
stiffness: 900,
|
|
163
|
+
overshootClamping: false,
|
|
164
|
+
},
|
|
165
|
+
() => {
|
|
166
|
+
isGestureReleaseAnimationRunning.set(false);
|
|
167
|
+
},
|
|
168
|
+
),
|
|
169
|
+
);
|
|
170
|
+
isDragging.set(false);
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
progress.set(2);
|
|
173
|
+
scheduleOnRN(onOpenChange, false);
|
|
174
|
+
}, 300);
|
|
175
|
+
setTimeout(() => {
|
|
176
|
+
progress.set(0);
|
|
177
|
+
}, 350);
|
|
178
|
+
} else {
|
|
179
|
+
isGestureReleaseAnimationRunning.set(true);
|
|
180
|
+
progress.set(
|
|
181
|
+
withSpring(1, {}, () => {
|
|
182
|
+
isGestureReleaseAnimationRunning.set(false);
|
|
183
|
+
}),
|
|
184
|
+
);
|
|
185
|
+
isDragging.set(false);
|
|
186
|
+
}
|
|
187
|
+
}),
|
|
188
|
+
[
|
|
189
|
+
contentScale,
|
|
190
|
+
contentScaleAnchor,
|
|
191
|
+
contentTranslateY,
|
|
192
|
+
contentTranslateYAnchor,
|
|
193
|
+
contentY,
|
|
194
|
+
isOpen,
|
|
195
|
+
isDragging,
|
|
196
|
+
isGestureReleaseAnimationRunning,
|
|
197
|
+
isSwipeable,
|
|
198
|
+
onOpenChange,
|
|
199
|
+
progress,
|
|
200
|
+
progressAnchor,
|
|
201
|
+
screenHeight,
|
|
202
|
+
isAnimationDisabledValue,
|
|
203
|
+
gestureTranslationY,
|
|
204
|
+
],
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
const rDragContainerStyle = useAnimatedStyle(() => {
|
|
208
|
+
if (isGestureReleaseAnimationRunning.get()) {
|
|
209
|
+
return {
|
|
210
|
+
opacity: interpolate(progress.get(), [1, progressAnchor.get(), 1.5, 1.75], [1, 1, 1, 0]),
|
|
211
|
+
transform: [
|
|
212
|
+
{
|
|
213
|
+
translateY: interpolate(
|
|
214
|
+
progress.get(),
|
|
215
|
+
[progressAnchor.get(), 1, progressAnchor.get(), progressAnchor.get() + 0.1, 2],
|
|
216
|
+
[
|
|
217
|
+
contentTranslateYAnchor.get(),
|
|
218
|
+
0,
|
|
219
|
+
contentTranslateYAnchor.get(),
|
|
220
|
+
contentTranslateYAnchor.get() + 50,
|
|
221
|
+
contentTranslateYAnchor.get() - 150,
|
|
222
|
+
],
|
|
223
|
+
),
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
scale: interpolate(
|
|
227
|
+
progress.get(),
|
|
228
|
+
[progressAnchor.get(), 1, progressAnchor.get(), 2],
|
|
229
|
+
[contentScaleAnchor.get(), 1, contentScaleAnchor.get(), 0.75],
|
|
230
|
+
),
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return {
|
|
237
|
+
transform: [
|
|
238
|
+
{
|
|
239
|
+
translateY: contentTranslateY.get(),
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
scale: contentScale.get(),
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
};
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
contentY,
|
|
250
|
+
contentHeight,
|
|
251
|
+
panGesture,
|
|
252
|
+
rDragContainerStyle,
|
|
253
|
+
entering: isAnimationDisabledValue || IS_WEB ? undefined : enteringValue,
|
|
254
|
+
exiting: isAnimationDisabledValue || IS_WEB ? undefined : exitingValue,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import type { SharedValue } from 'react-native-reanimated';
|
|
3
|
+
import { FadeIn, FadeOut, interpolate, useAnimatedStyle } from 'react-native-reanimated';
|
|
4
|
+
import { useAnimationSettings } from '../../providers/animation-settings';
|
|
5
|
+
import type { PopupOverlayAnimation } from '../types';
|
|
6
|
+
import {
|
|
7
|
+
getAnimationState,
|
|
8
|
+
getAnimationValueProperty,
|
|
9
|
+
getIsAnimationDisabledValue,
|
|
10
|
+
} from '../utils';
|
|
11
|
+
|
|
12
|
+
const IS_WEB = Platform.OS === 'web';
|
|
13
|
+
|
|
14
|
+
export interface UsePopupOverlayAnimationOptions {
|
|
15
|
+
/** Animation progress shared value (0=idle, 1=open, 2=close) */
|
|
16
|
+
progress?: SharedValue<number>;
|
|
17
|
+
/** Dragging state shared value */
|
|
18
|
+
isDragging?: SharedValue<boolean>;
|
|
19
|
+
/** Gesture release animation running state (for components with swipe gestures) */
|
|
20
|
+
isGestureReleaseAnimationRunning?: SharedValue<boolean>;
|
|
21
|
+
/** Animation configuration for overlay */
|
|
22
|
+
animation?: PopupOverlayAnimation;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Animation hook for popup overlay (backdrop) components.
|
|
27
|
+
* Shared by Dialog, Select, BottomSheet, Popover, etc.
|
|
28
|
+
*
|
|
29
|
+
* Returns progress-based opacity style and entering/exiting layout animations.
|
|
30
|
+
* On web, entering/exiting are undefined (CSS transitions drive the visuals).
|
|
31
|
+
*/
|
|
32
|
+
export function usePopupOverlayAnimation(options: UsePopupOverlayAnimationOptions) {
|
|
33
|
+
const { progress, isDragging, isGestureReleaseAnimationRunning, animation } = options;
|
|
34
|
+
|
|
35
|
+
const animationSettingsContext = useAnimationSettings();
|
|
36
|
+
const isAllAnimationsDisabled = animationSettingsContext?.isAllAnimationsDisabled;
|
|
37
|
+
|
|
38
|
+
const { animationConfig, isAnimationDisabled } = getAnimationState(animation);
|
|
39
|
+
|
|
40
|
+
const isAnimationDisabledValue = getIsAnimationDisabledValue({
|
|
41
|
+
isAnimationDisabled,
|
|
42
|
+
isAllAnimationsDisabled,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const opacityValue = getAnimationValueProperty({
|
|
46
|
+
animationValue: animationConfig?.opacity,
|
|
47
|
+
property: 'value',
|
|
48
|
+
defaultValue: [0, 1, 0] as [number, number, number],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const rContainerStyle = useAnimatedStyle(() => {
|
|
52
|
+
if (progress?.get() === undefined) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (isAnimationDisabledValue) {
|
|
57
|
+
return {
|
|
58
|
+
opacity: progress.get() > 0 ? 1 : 0,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if ((isDragging?.get() || isGestureReleaseAnimationRunning?.get()) && progress.get() <= 1) {
|
|
63
|
+
return {
|
|
64
|
+
opacity: 1,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
opacity: interpolate(progress.get(), [0, 1, 2], opacityValue),
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const enteringValue =
|
|
74
|
+
animationConfig?.entering ?? (isAnimationDisabledValue ? undefined : FadeIn.duration(200));
|
|
75
|
+
|
|
76
|
+
const exitingValue =
|
|
77
|
+
animationConfig?.exiting ?? (isAnimationDisabledValue ? undefined : FadeOut.duration(150));
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
rContainerStyle,
|
|
81
|
+
entering: isAnimationDisabledValue || IS_WEB ? undefined : enteringValue,
|
|
82
|
+
exiting: isAnimationDisabledValue || IS_WEB ? undefined : exitingValue,
|
|
83
|
+
};
|
|
84
|
+
}
|