@lichens-innovation/react-native-common 3.0.1 → 3.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/dist/components/layout/resizable/index.d.ts +1 -1
- package/dist/components/layout/resizable/index.js +1 -1
- package/dist/components/layout/resizable/index.js.map +1 -1
- package/dist/components/layout/resizable/{vertical-resizable-overlay-view.d.ts → resizable-overlay-view.d.ts} +1 -1
- package/dist/components/layout/resizable/{vertical-resizable-overlay-view.js → resizable-overlay-view.js} +43 -32
- package/dist/components/layout/resizable/resizable-overlay-view.js.map +1 -0
- package/dist/components/layout/resizable/resizable-overlay-view.utils.d.ts +16 -0
- package/dist/components/layout/resizable/resizable-overlay-view.utils.js +19 -0
- package/dist/components/layout/resizable/resizable-overlay-view.utils.js.map +1 -0
- package/dist/components/layout/resizable/vertical-resizable-overlay-view.types.d.ts +6 -0
- package/package.json +1 -1
- package/dist/components/layout/resizable/vertical-resizable-overlay-view.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/layout/resizable/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/layout/resizable/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type FunctionComponent } from 'react';
|
|
2
2
|
import { VerticalResizableOverlayViewProps } from './vertical-resizable-overlay-view.types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ResizableOverlayView: FunctionComponent<VerticalResizableOverlayViewProps>;
|
|
@@ -1,52 +1,58 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useState } from 'react';
|
|
3
2
|
import { StyleSheet, View } from 'react-native';
|
|
4
3
|
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
5
4
|
import Animated, { useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
6
5
|
import { isDevelopment } from '../../../utils';
|
|
6
|
+
import { computeResizableOverlayLayoutValues } from './resizable-overlay-view.utils';
|
|
7
7
|
import { validateResizableOverlayProps } from './vertical-resizable-overlay-view.utils';
|
|
8
8
|
const DRAG_HANDLE_HEIGHT = 20;
|
|
9
9
|
const DEFAULT_ANIMATION_CONFIG = { damping: 25, stiffness: 300, mass: 0.8 };
|
|
10
|
-
|
|
10
|
+
const OVERLAY_ANCHOR_STYLES = {
|
|
11
|
+
topLeft: { top: 0, left: 0 },
|
|
12
|
+
topRight: { top: 0, right: 0 },
|
|
13
|
+
bottomLeft: { bottom: 0, left: 0 },
|
|
14
|
+
bottomRight: { bottom: 0, right: 0 },
|
|
15
|
+
};
|
|
16
|
+
export const ResizableOverlayView = (props) => {
|
|
11
17
|
if (isDevelopment())
|
|
12
18
|
validateResizableOverlayProps(props);
|
|
13
|
-
const { foregroundContent, backgroundContent, initialForegroundRatio = 0.5, minForegroundRatio = 0.15, maxForegroundRatio = 0.85, foregroundContentAspectRatio, handleContainerStyle, handleStyle, hideHandle = false, } = props;
|
|
14
|
-
//
|
|
15
|
-
const
|
|
19
|
+
const { foregroundContent, backgroundContent, initialForegroundRatio = 0.5, minForegroundRatio = 0.15, maxForegroundRatio = 0.85, foregroundContentAspectRatio, handleContainerStyle, handleStyle, hideHandle = false, anchorType = 'topRight', } = props;
|
|
20
|
+
// Anchor styles
|
|
21
|
+
const overlayAnchorStyle = OVERLAY_ANCHOR_STYLES[anchorType];
|
|
22
|
+
const isBottomAnchored = ['bottomLeft', 'bottomRight'].includes(anchorType);
|
|
23
|
+
const isLeftAnchored = ['topLeft', 'bottomLeft'].includes(anchorType);
|
|
16
24
|
// Shared values for animation
|
|
17
25
|
const overlayHeight = useSharedValue(0);
|
|
26
|
+
const containerHeight = useSharedValue(0);
|
|
18
27
|
const containerWidth = useSharedValue(0);
|
|
19
28
|
const minHeight = useSharedValue(0);
|
|
20
29
|
const maxHeight = useSharedValue(0);
|
|
21
30
|
const startY = useSharedValue(0);
|
|
22
31
|
const isDragging = useSharedValue(false);
|
|
23
32
|
// Handle container layout measurement
|
|
24
|
-
const handleLayout =
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
maxHeight,
|
|
39
|
-
overlayHeight,
|
|
40
|
-
containerWidth,
|
|
41
|
-
isReady,
|
|
42
|
-
]);
|
|
33
|
+
const handleLayout = (event) => {
|
|
34
|
+
const computedValues = computeResizableOverlayLayoutValues({
|
|
35
|
+
event,
|
|
36
|
+
initialForegroundRatio,
|
|
37
|
+
minForegroundRatio,
|
|
38
|
+
maxForegroundRatio,
|
|
39
|
+
foregroundContentAspectRatio,
|
|
40
|
+
});
|
|
41
|
+
containerHeight.value = computedValues.containerHeight;
|
|
42
|
+
containerWidth.value = computedValues.containerWidth;
|
|
43
|
+
minHeight.value = computedValues.minHeight;
|
|
44
|
+
maxHeight.value = computedValues.maxHeight;
|
|
45
|
+
overlayHeight.value = computedValues.overlayHeight;
|
|
46
|
+
};
|
|
43
47
|
const panGesture = Gesture.Pan()
|
|
44
48
|
.onStart(() => {
|
|
45
49
|
startY.value = overlayHeight.value;
|
|
46
50
|
isDragging.value = true;
|
|
47
51
|
})
|
|
48
52
|
.onUpdate((event) => {
|
|
49
|
-
|
|
53
|
+
// If the overlay is anchored to the bottom, dragging up should INCREASE its height.
|
|
54
|
+
const direction = isBottomAnchored ? -1 : 1;
|
|
55
|
+
const newHeight = startY.value + direction * event.translationY;
|
|
50
56
|
overlayHeight.value = Math.max(minHeight.value, Math.min(newHeight, maxHeight.value));
|
|
51
57
|
})
|
|
52
58
|
.onEnd(() => {
|
|
@@ -81,16 +87,23 @@ export const VerticalResizableOverlayView = (props) => {
|
|
|
81
87
|
effectiveWidth = calculatedWidth;
|
|
82
88
|
}
|
|
83
89
|
}
|
|
90
|
+
// Always compute an explicit `left` to avoid stale left/right values when `anchorType` changes.
|
|
91
|
+
const left = isLeftAnchored ? 0 : Math.max(0, containerWidth.value - effectiveWidth);
|
|
92
|
+
// If anchored at bottom, the handle must attach to the TOP edge of the overlay.
|
|
93
|
+
// Otherwise (top anchor), it attaches to the BOTTOM edge.
|
|
94
|
+
const top = isBottomAnchored
|
|
95
|
+
? containerHeight.value - effectiveHeight - DRAG_HANDLE_HEIGHT / 2
|
|
96
|
+
: effectiveHeight - DRAG_HANDLE_HEIGHT / 2;
|
|
84
97
|
return {
|
|
85
|
-
top
|
|
86
|
-
right: 0,
|
|
98
|
+
top,
|
|
87
99
|
width: effectiveWidth,
|
|
100
|
+
left,
|
|
88
101
|
};
|
|
89
|
-
});
|
|
102
|
+
}, [foregroundContentAspectRatio, isBottomAnchored, isLeftAnchored]);
|
|
90
103
|
const dragHandleAnimatedStyle = useAnimatedStyle(() => ({
|
|
91
104
|
transform: [{ scale: withSpring(isDragging.value ? 1.2 : 1, DEFAULT_ANIMATION_CONFIG) }],
|
|
92
105
|
}));
|
|
93
|
-
return (_jsxs(View, { style: [styles.container], onLayout: handleLayout, children: [_jsx(View, { style: styles.backgroundSection, children: backgroundContent }), _jsx(Animated.View, { style: [styles.overlaySection, overlayAnimatedStyle], children: foregroundContent }), !hideHandle && (_jsx(GestureDetector, { gesture: panGesture, children: _jsx(Animated.View, { style: [styles.handleContainer, handleContainerStyle, dragHandleContainerAnimatedStyle], children: _jsx(Animated.View, { style: [styles.handle, handleStyle, dragHandleAnimatedStyle] }) }) }))] }));
|
|
106
|
+
return (_jsxs(View, { style: [styles.container], onLayout: handleLayout, children: [_jsx(View, { style: styles.backgroundSection, children: backgroundContent }), _jsx(Animated.View, { style: [styles.overlaySection, overlayAnchorStyle, overlayAnimatedStyle], children: foregroundContent }), !hideHandle && (_jsx(GestureDetector, { gesture: panGesture, children: _jsx(Animated.View, { style: [styles.handleContainer, handleContainerStyle, dragHandleContainerAnimatedStyle], children: _jsx(Animated.View, { style: [styles.handle, handleStyle, dragHandleAnimatedStyle] }) }) }))] }));
|
|
94
107
|
};
|
|
95
108
|
const styles = StyleSheet.create({
|
|
96
109
|
container: {
|
|
@@ -101,8 +114,6 @@ const styles = StyleSheet.create({
|
|
|
101
114
|
},
|
|
102
115
|
overlaySection: {
|
|
103
116
|
position: 'absolute',
|
|
104
|
-
top: 0,
|
|
105
|
-
right: 0,
|
|
106
117
|
overflow: 'hidden',
|
|
107
118
|
},
|
|
108
119
|
handleContainer: {
|
|
@@ -118,4 +129,4 @@ const styles = StyleSheet.create({
|
|
|
118
129
|
borderRadius: 4,
|
|
119
130
|
},
|
|
120
131
|
});
|
|
121
|
-
//# sourceMappingURL=
|
|
132
|
+
//# sourceMappingURL=resizable-overlay-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizable-overlay-view.js","sourceRoot":"","sources":["../../../../src/components/layout/resizable/resizable-overlay-view.tsx"],"names":[],"mappings":";AACA,OAAO,EAAqB,UAAU,EAAE,IAAI,EAAa,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,mCAAmC,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAExF,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,wBAAwB,GAAG,EAAE,OAAO,EA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AAE,UAAU,YAClC,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,eAAe,EAAE,oBAAoB,EAAE,gCAAgC,CAAC,YACpG,KAAC,QAAQ,CAAC,IAAI,IAAC,KAAK,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,uBAAuB,CAAC,GAAI,GACjE,GACA,CACnB,IACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC;KACR;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,CAAC;KACR;IACD,cAAc,EAAE;QACd,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,QAAQ;KACnB;IACD,eAAe,EAAE;QACf,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,kBAAkB;QAC1B,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KACzB;IACD,MAAM,EAAE;QACN,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,CAAC;QACT,eAAe,EAAE,SAAS;QAC1B,YAAY,EAAE,CAAC;KAChB;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LayoutChangeEvent } from 'react-native';
|
|
2
|
+
interface ComputeResizableOverlayLayoutValuesArgs {
|
|
3
|
+
event: LayoutChangeEvent;
|
|
4
|
+
initialForegroundRatio: number;
|
|
5
|
+
minForegroundRatio: number;
|
|
6
|
+
maxForegroundRatio: number;
|
|
7
|
+
foregroundContentAspectRatio?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const computeResizableOverlayLayoutValues: ({ event, initialForegroundRatio, minForegroundRatio, maxForegroundRatio, foregroundContentAspectRatio, }: ComputeResizableOverlayLayoutValuesArgs) => {
|
|
10
|
+
containerHeight: number;
|
|
11
|
+
containerWidth: number;
|
|
12
|
+
minHeight: number;
|
|
13
|
+
maxHeight: number;
|
|
14
|
+
overlayHeight: number;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const computeResizableOverlayLayoutValues = ({ event, initialForegroundRatio, minForegroundRatio, maxForegroundRatio, foregroundContentAspectRatio, }) => {
|
|
2
|
+
const { height, width } = event.nativeEvent.layout;
|
|
3
|
+
if (height <= 0)
|
|
4
|
+
return { containerHeight: 0, containerWidth: 0, minHeight: 0, maxHeight: 0, overlayHeight: 0 };
|
|
5
|
+
// Always keep container & bounds updated (layout can change over time).
|
|
6
|
+
const computedMinHeight = height * minForegroundRatio;
|
|
7
|
+
const computedMaxHeightFromContainer = height * maxForegroundRatio;
|
|
8
|
+
const computedMaxHeightFromAspectRatio = foregroundContentAspectRatio !== undefined ? width / foregroundContentAspectRatio : Number.POSITIVE_INFINITY;
|
|
9
|
+
const computedMaxHeight = Math.max(computedMinHeight, Math.min(computedMaxHeightFromContainer, computedMaxHeightFromAspectRatio));
|
|
10
|
+
const computedOverlayHeight = Math.max(computedMinHeight, Math.min(height * initialForegroundRatio, computedMaxHeight));
|
|
11
|
+
return {
|
|
12
|
+
containerHeight: height,
|
|
13
|
+
containerWidth: width,
|
|
14
|
+
minHeight: computedMinHeight,
|
|
15
|
+
maxHeight: computedMaxHeight,
|
|
16
|
+
overlayHeight: computedOverlayHeight,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=resizable-overlay-view.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizable-overlay-view.utils.js","sourceRoot":"","sources":["../../../../src/components/layout/resizable/resizable-overlay-view.utils.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,EAClD,KAAK,EACL,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,GACY,EAAE,EAAE;IAC5C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;IACnD,IAAI,MAAM,IAAI,CAAC;QAAE,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;IAEhH,wEAAwE;IACxE,MAAM,iBAAiB,GAAG,MAAM,GAAG,kBAAkB,CAAC;IACtD,MAAM,8BAA8B,GAAG,MAAM,GAAG,kBAAkB,CAAC;IACnE,MAAM,gCAAgC,GACpC,4BAA4B,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,4BAA4B,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC/G,MAAM,iBAAiB,GAAG,IAAI,CAAC,GAAG,CAChC,iBAAiB,EACjB,IAAI,CAAC,GAAG,CAAC,8BAA8B,EAAE,gCAAgC,CAAC,CAC3E,CAAC;IAEF,MAAM,qBAAqB,GAAG,IAAI,CAAC,GAAG,CACpC,iBAAiB,EACjB,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,sBAAsB,EAAE,iBAAiB,CAAC,CAC7D,CAAC;IAEF,OAAO;QACL,eAAe,EAAE,MAAM;QACvB,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,iBAAiB;QAC5B,SAAS,EAAE,iBAAiB;QAC5B,aAAa,EAAE,qBAAqB;KACrC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ViewStyle } from 'react-native';
|
|
3
|
+
export type VerticalResizableOverlayViewAnchorType = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
|
|
3
4
|
export interface VerticalResizableOverlayViewProps {
|
|
4
5
|
/** Content to display in the overlay section (foreground, on top) */
|
|
5
6
|
foregroundContent: ReactNode;
|
|
6
7
|
/** Content to display in the background section (fills the entire container) */
|
|
7
8
|
backgroundContent: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Where the overlay is anchored inside the container.
|
|
11
|
+
* Default: topRight
|
|
12
|
+
*/
|
|
13
|
+
anchorType?: VerticalResizableOverlayViewAnchorType;
|
|
8
14
|
/** Initial height ratio for the foreground overlay (0 to 1). Default: 0.5 */
|
|
9
15
|
initialForegroundRatio?: number;
|
|
10
16
|
/** Minimum height ratio for the foreground overlay (0 to 1). Default: 0.15 */
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Lichens Innovation React Native Expo shared components, utilities, hooks and services",
|
|
4
4
|
"repository": "https://github.com/Lichens-Innovation/react-native-common",
|
|
5
5
|
"author": "Lichens Innovation",
|
|
6
|
-
"version": "3.0
|
|
6
|
+
"version": "3.1.0",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vertical-resizable-overlay-view.js","sourceRoot":"","sources":["../../../../src/components/layout/resizable/vertical-resizable-overlay-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAA0B,MAAM,OAAO,CAAC;AACtE,OAAO,EAAqB,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,QAAQ,EAAE,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AAExF,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,wBAAwB,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CA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