@codeleap/mobile 6.0.1 → 6.1.2

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.
@@ -0,0 +1,6 @@
1
+ import { CollapseProps } from './types';
2
+ export * from './types';
3
+ export declare const Collapse: {
4
+ (props: CollapseProps): import("react/jsx-runtime").JSX.Element;
5
+ defaultProps: CollapseProps;
6
+ };
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect } from 'react';
3
+ import { View } from 'react-native';
4
+ import Animated, { Easing, useSharedValue, useAnimatedStyle, withTiming, } from 'react-native-reanimated';
5
+ export * from './types';
6
+ export const Collapse = (props) => {
7
+ const { open, children, style, contentContainerStyle, animationConfig, ...rest } = {
8
+ ...Collapse.defaultProps,
9
+ ...props,
10
+ };
11
+ const height = useSharedValue(0);
12
+ const animatedHeight = useSharedValue(0);
13
+ const onLayout = useCallback((event) => {
14
+ const measuredHeight = event.nativeEvent.layout.height;
15
+ if (height.value != 0)
16
+ return;
17
+ if (measuredHeight) {
18
+ height.value = measuredHeight;
19
+ if (open) {
20
+ animatedHeight.value = withTiming(measuredHeight, animationConfig);
21
+ }
22
+ }
23
+ }, [open]);
24
+ const animatedStyle = useAnimatedStyle(() => {
25
+ return {
26
+ maxHeight: height.value === 0 ? 'auto' : animatedHeight.value,
27
+ overflow: 'hidden',
28
+ };
29
+ });
30
+ useEffect(() => {
31
+ animatedHeight.value = withTiming(open ? height.value : 0, animationConfig);
32
+ }, [open]);
33
+ return (_jsx(Animated.View, { ...rest, style: [animatedStyle, style], children: _jsx(View, { onLayout: onLayout, style: contentContainerStyle, children: children }) }));
34
+ };
35
+ const defaultAnimationConfig = {
36
+ duration: 300,
37
+ easing: Easing.inOut(Easing.quad),
38
+ };
39
+ Collapse.defaultProps = {
40
+ animationConfig: defaultAnimationConfig,
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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K;YAC7D,QAAQ,EAAE,QAAQ;SACnB,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,CAAA;IAC7E,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,CACL,KAAC,QAAQ,CAAC,IAAI,OAAK,IAAI,EAAE,KAAK,EAAE,CAAC,aAAa,EAAE,KAAK,CAAC,YACpD,KAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,YACnD,QAAQ,GACJ,GACO,CACjB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,sBAAsB,GAA4B;IACtD,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;CAClC,CAAA;AAED,QAAQ,CAAC,YAAY,GAAG;IACtB,eAAe,EAAE,sBAAsB;CACvB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { ViewProps, ViewStyle } from 'react-native';
3
+ import type { AnimatedProps, ReduceMotion, EasingFunction, EasingFunctionFactory } from 'react-native-reanimated';
4
+ export type CollapseAnimationConfig = {
5
+ duration?: number;
6
+ reduceMotion?: ReduceMotion;
7
+ easing?: EasingFunction | EasingFunctionFactory;
8
+ };
9
+ export type CollapseProps = AnimatedProps<ViewProps> & {
10
+ open?: boolean;
11
+ contentContainerStyle?: ViewStyle;
12
+ children: ReactNode;
13
+ animationConfig?: CollapseAnimationConfig;
14
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/Collapse/types.ts"],"names":[],"mappings":""}
@@ -43,3 +43,4 @@ export * from './Tabs';
43
43
  export * from './CalendarInput';
44
44
  export * from './TimeInput';
45
45
  export * from './InputOverlay';
46
+ export * from './Collapse';
@@ -43,4 +43,5 @@ export * from './Tabs';
43
43
  export * from './CalendarInput';
44
44
  export * from './TimeInput';
45
45
  export * from './InputOverlay';
46
+ export * from './Collapse';
46
47
  //# sourceMappingURL=components.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,eAAe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,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "6.0.1",
3
+ "version": "6.1.2",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,28 +9,28 @@
9
9
  "directory": "packages/mobile"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/types": "6.0.1",
13
- "@codeleap/utils": "6.0.1",
14
- "@codeleap/hooks": "6.0.1",
15
- "@codeleap/form": "6.0.1",
16
- "@codeleap/query": "6.0.1",
17
- "@codeleap/logger": "6.0.1",
18
- "@codeleap/config": "6.0.1",
19
- "@codeleap/modals": "6.0.1"
12
+ "@codeleap/types": "6.1.2",
13
+ "@codeleap/utils": "6.1.2",
14
+ "@codeleap/hooks": "6.1.2",
15
+ "@codeleap/form": "6.1.2",
16
+ "@codeleap/query": "6.1.2",
17
+ "@codeleap/logger": "6.1.2",
18
+ "@codeleap/config": "6.1.2",
19
+ "@codeleap/modals": "6.1.2"
20
20
  },
21
21
  "scripts": {
22
22
  "build": "tsc --build",
23
23
  "lint": "eslint -c .eslintrc.js --fix \"./src/**/*.{ts,tsx,js,jsx}\""
24
24
  },
25
25
  "peerDependencies": {
26
- "@codeleap/types": "6.0.1",
27
- "@codeleap/utils": "6.0.1",
28
- "@codeleap/hooks": "6.0.1",
29
- "@codeleap/form": "6.0.1",
30
- "@codeleap/query": "6.0.1",
31
- "@codeleap/logger": "6.0.1",
32
- "@codeleap/styles": "6.0.1",
33
- "@codeleap/modals": "6.0.1",
26
+ "@codeleap/types": "6.1.2",
27
+ "@codeleap/utils": "6.1.2",
28
+ "@codeleap/hooks": "6.1.2",
29
+ "@codeleap/form": "6.1.2",
30
+ "@codeleap/query": "6.1.2",
31
+ "@codeleap/logger": "6.1.2",
32
+ "@codeleap/styles": "6.1.2",
33
+ "@codeleap/modals": "6.1.2",
34
34
  "@d11/react-native-fast-image": "8.12.0",
35
35
  "@react-native-firebase/messaging": "23.4.1",
36
36
  "@react-navigation/bottom-tabs": "7.4.9",
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "6.0.1",
3
+ "version": "6.1.2",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -0,0 +1,70 @@
1
+ import React, { useCallback, useEffect } from 'react'
2
+ import { LayoutChangeEvent, View } from 'react-native'
3
+ import { CollapseAnimationConfig, CollapseProps } from './types'
4
+ import Animated, {
5
+ Easing,
6
+ useSharedValue,
7
+ useAnimatedStyle,
8
+ withTiming,
9
+ } from 'react-native-reanimated'
10
+
11
+ export * from './types'
12
+
13
+ export const Collapse = (props: CollapseProps) => {
14
+ const {
15
+ open,
16
+ children,
17
+ style,
18
+ contentContainerStyle,
19
+ animationConfig,
20
+ ...rest
21
+ } = {
22
+ ...Collapse.defaultProps,
23
+ ...props,
24
+ }
25
+
26
+ const height = useSharedValue(0)
27
+ const animatedHeight = useSharedValue(0)
28
+
29
+ const onLayout = useCallback((event: LayoutChangeEvent) => {
30
+ const measuredHeight = event.nativeEvent.layout.height
31
+
32
+ if (height.value != 0) return
33
+
34
+ if (measuredHeight) {
35
+ height.value = measuredHeight
36
+
37
+ if (open) {
38
+ animatedHeight.value = withTiming(measuredHeight, animationConfig)
39
+ }
40
+ }
41
+ }, [open])
42
+
43
+ const animatedStyle = useAnimatedStyle(() => {
44
+ return {
45
+ maxHeight: height.value === 0 ? 'auto' : animatedHeight.value,
46
+ overflow: 'hidden',
47
+ }
48
+ })
49
+
50
+ useEffect(() => {
51
+ animatedHeight.value = withTiming(open ? height.value : 0, animationConfig)
52
+ }, [open])
53
+
54
+ return (
55
+ <Animated.View {...rest} style={[animatedStyle, style]}>
56
+ <View onLayout={onLayout} style={contentContainerStyle}>
57
+ {children}
58
+ </View>
59
+ </Animated.View>
60
+ )
61
+ }
62
+
63
+ const defaultAnimationConfig: CollapseAnimationConfig = {
64
+ duration: 300,
65
+ easing: Easing.inOut(Easing.quad),
66
+ }
67
+
68
+ Collapse.defaultProps = {
69
+ animationConfig: defaultAnimationConfig,
70
+ } as CollapseProps
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react'
2
+ import { ViewProps, ViewStyle } from 'react-native'
3
+ import type { AnimatedProps, ReduceMotion, EasingFunction, EasingFunctionFactory } from 'react-native-reanimated'
4
+
5
+ export type CollapseAnimationConfig = {
6
+ duration?: number
7
+ reduceMotion?: ReduceMotion
8
+ easing?: EasingFunction | EasingFunctionFactory
9
+ }
10
+
11
+ export type CollapseProps = AnimatedProps<ViewProps> & {
12
+ open?: boolean
13
+ contentContainerStyle?: ViewStyle
14
+ children: ReactNode
15
+ animationConfig?: CollapseAnimationConfig
16
+ }
@@ -43,3 +43,4 @@ export * from './Tabs'
43
43
  export * from './CalendarInput'
44
44
  export * from './TimeInput'
45
45
  export * from './InputOverlay'
46
+ export * from './Collapse'