@chem-po/react-native 0.0.29 → 0.0.30
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/components/button/Toggle.js +19 -16
- package/lib/commonjs/components/button/Toggle.js.map +1 -1
- package/lib/commonjs/components/form/input/Editable.js +52 -73
- package/lib/commonjs/components/form/input/Editable.js.map +1 -1
- package/lib/commonjs/components/form/input/StandaloneInput.js.map +1 -1
- package/lib/commonjs/components/form/input/datetime/index.js +7 -2
- package/lib/commonjs/components/form/input/datetime/index.js.map +1 -1
- package/lib/commonjs/components/form/input/multipleSelect/index.js +7 -2
- package/lib/commonjs/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/commonjs/components/form/input/select/index.js +1 -1
- package/lib/commonjs/components/form/input/select/index.js.map +1 -1
- package/lib/commonjs/components/form/input/text/index.js +3 -2
- package/lib/commonjs/components/form/input/text/index.js.map +1 -1
- package/lib/commonjs/components/form/input/text/textarea.js +1 -12
- package/lib/commonjs/components/form/input/text/textarea.js.map +1 -1
- package/lib/commonjs/components/form/input/text/useWebAutoResize.js +5 -6
- package/lib/commonjs/components/form/input/text/useWebAutoResize.js.map +1 -1
- package/lib/commonjs/components/form/view/file.js +21 -12
- package/lib/commonjs/components/form/view/file.js.map +1 -1
- package/lib/commonjs/components/form/view/index.js +29 -18
- package/lib/commonjs/components/form/view/index.js.map +1 -1
- package/lib/commonjs/components/form/view/multipleSelect.js +17 -13
- package/lib/commonjs/components/form/view/multipleSelect.js.map +1 -1
- package/lib/commonjs/components/form/view/select.js +14 -7
- package/lib/commonjs/components/form/view/select.js.map +1 -1
- package/lib/commonjs/components/form/view/styles.js +0 -3
- package/lib/commonjs/components/form/view/styles.js.map +1 -1
- package/lib/commonjs/components/layout/CollapseHorizontal.js +72 -0
- package/lib/commonjs/components/layout/CollapseHorizontal.js.map +1 -0
- package/lib/commonjs/contexts/root.js +6 -6
- package/lib/commonjs/contexts/root.js.map +1 -1
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/forms.js +6 -0
- package/lib/commonjs/types/forms.js.map +1 -0
- package/lib/commonjs/types/index.js +17 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/module/components/button/Toggle.js +21 -18
- package/lib/module/components/button/Toggle.js.map +1 -1
- package/lib/module/components/form/input/Editable.js +52 -73
- package/lib/module/components/form/input/Editable.js.map +1 -1
- package/lib/module/components/form/input/StandaloneInput.js.map +1 -1
- package/lib/module/components/form/input/datetime/index.js +7 -2
- package/lib/module/components/form/input/datetime/index.js.map +1 -1
- package/lib/module/components/form/input/multipleSelect/index.js +7 -2
- package/lib/module/components/form/input/multipleSelect/index.js.map +1 -1
- package/lib/module/components/form/input/select/index.js +1 -1
- package/lib/module/components/form/input/select/index.js.map +1 -1
- package/lib/module/components/form/input/text/index.js +3 -2
- package/lib/module/components/form/input/text/index.js.map +1 -1
- package/lib/module/components/form/input/text/textarea.js +2 -13
- package/lib/module/components/form/input/text/textarea.js.map +1 -1
- package/lib/module/components/form/input/text/useWebAutoResize.js +5 -6
- package/lib/module/components/form/input/text/useWebAutoResize.js.map +1 -1
- package/lib/module/components/form/view/file.js +15 -6
- package/lib/module/components/form/view/file.js.map +1 -1
- package/lib/module/components/form/view/index.js +19 -8
- package/lib/module/components/form/view/index.js.map +1 -1
- package/lib/module/components/form/view/multipleSelect.js +18 -14
- package/lib/module/components/form/view/multipleSelect.js.map +1 -1
- package/lib/module/components/form/view/select.js +14 -7
- package/lib/module/components/form/view/select.js.map +1 -1
- package/lib/module/components/form/view/styles.js +0 -3
- package/lib/module/components/form/view/styles.js.map +1 -1
- package/lib/module/components/layout/CollapseHorizontal.js +64 -0
- package/lib/module/components/layout/CollapseHorizontal.js.map +1 -0
- package/lib/module/contexts/root.js +6 -6
- package/lib/module/contexts/root.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/forms.js +2 -0
- package/lib/module/types/forms.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/typescript/components/button/Toggle.d.ts +5 -2
- package/lib/typescript/components/button/Toggle.d.ts.map +1 -1
- package/lib/typescript/components/form/input/Editable.d.ts +2 -2
- package/lib/typescript/components/form/input/Editable.d.ts.map +1 -1
- package/lib/typescript/components/form/input/StandaloneInput.d.ts +5 -14
- package/lib/typescript/components/form/input/StandaloneInput.d.ts.map +1 -1
- package/lib/typescript/components/form/input/datetime/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/multipleSelect/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/index.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/textarea.d.ts +2 -2
- package/lib/typescript/components/form/input/text/textarea.d.ts.map +1 -1
- package/lib/typescript/components/form/input/text/useWebAutoResize.d.ts.map +1 -1
- package/lib/typescript/components/form/view/file.d.ts.map +1 -1
- package/lib/typescript/components/form/view/index.d.ts +3 -2
- package/lib/typescript/components/form/view/index.d.ts.map +1 -1
- package/lib/typescript/components/form/view/multipleSelect.d.ts.map +1 -1
- package/lib/typescript/components/form/view/select.d.ts +2 -1
- package/lib/typescript/components/form/view/select.d.ts.map +1 -1
- package/lib/typescript/components/form/view/styles.d.ts +0 -3
- package/lib/typescript/components/form/view/styles.d.ts.map +1 -1
- package/lib/typescript/components/layout/CollapseHorizontal.d.ts +9 -0
- package/lib/typescript/components/layout/CollapseHorizontal.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types/forms.d.ts +5 -0
- package/lib/typescript/types/forms.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +2 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/components/button/Toggle.tsx +21 -17
- package/src/components/form/input/Editable.tsx +47 -86
- package/src/components/form/input/StandaloneInput.tsx +4 -13
- package/src/components/form/input/datetime/index.tsx +7 -2
- package/src/components/form/input/multipleSelect/index.tsx +13 -2
- package/src/components/form/input/select/index.tsx +1 -1
- package/src/components/form/input/text/index.tsx +3 -2
- package/src/components/form/input/text/textarea.tsx +3 -15
- package/src/components/form/input/text/useWebAutoResize.tsx +5 -6
- package/src/components/form/view/file.tsx +9 -5
- package/src/components/form/view/index.tsx +26 -7
- package/src/components/form/view/multipleSelect.tsx +11 -9
- package/src/components/form/view/select.tsx +7 -2
- package/src/components/form/view/styles.ts +0 -3
- package/src/components/layout/CollapseHorizontal.tsx +82 -0
- package/src/contexts/root.tsx +6 -6
- package/src/index.ts +1 -0
- package/src/types/forms.ts +14 -0
- package/src/types/index.ts +1 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useCallback } from 'react'
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, View, ViewStyle } from 'react-native'
|
|
3
|
+
import Animated, {
|
|
4
|
+
useAnimatedStyle,
|
|
5
|
+
useSharedValue,
|
|
6
|
+
withSequence,
|
|
7
|
+
withTiming,
|
|
8
|
+
} from 'react-native-reanimated'
|
|
9
|
+
|
|
10
|
+
export const CollapseHorizontal = ({
|
|
11
|
+
children,
|
|
12
|
+
in: isIn,
|
|
13
|
+
duration = 200,
|
|
14
|
+
style,
|
|
15
|
+
}: {
|
|
16
|
+
children: React.ReactNode
|
|
17
|
+
in: boolean
|
|
18
|
+
duration?: number
|
|
19
|
+
style?: StyleProp<ViewStyle>
|
|
20
|
+
}) => {
|
|
21
|
+
const contentWidth = useSharedValue(0)
|
|
22
|
+
const width = useSharedValue(0)
|
|
23
|
+
const opacity = useSharedValue(0)
|
|
24
|
+
|
|
25
|
+
const handleLayout = useCallback(
|
|
26
|
+
(event: LayoutChangeEvent) => {
|
|
27
|
+
contentWidth.value = event.nativeEvent.layout.width
|
|
28
|
+
// Initialize width if component is initially visible
|
|
29
|
+
if (isIn && width.value === 0) {
|
|
30
|
+
width.value = contentWidth.value
|
|
31
|
+
opacity.value = 1
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
[isIn, contentWidth, width, opacity],
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (isIn) {
|
|
39
|
+
// Fade in: width first, then opacity
|
|
40
|
+
width.value = withTiming(contentWidth.value, {
|
|
41
|
+
duration,
|
|
42
|
+
})
|
|
43
|
+
opacity.value = withSequence(
|
|
44
|
+
withTiming(0, { duration: 0 }), // Reset opacity
|
|
45
|
+
withTiming(1, {
|
|
46
|
+
duration,
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
49
|
+
} else {
|
|
50
|
+
// Fade out: opacity first, then width
|
|
51
|
+
opacity.value = withTiming(0, {
|
|
52
|
+
duration,
|
|
53
|
+
})
|
|
54
|
+
width.value = withSequence(
|
|
55
|
+
withTiming(width.value, { duration: 0 }), // Ensure we start from current width
|
|
56
|
+
withTiming(0, {
|
|
57
|
+
duration,
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
}, [isIn, contentWidth.value, duration, width, opacity])
|
|
62
|
+
|
|
63
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
64
|
+
width: width.value,
|
|
65
|
+
opacity: opacity.value,
|
|
66
|
+
}))
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Animated.View
|
|
70
|
+
style={[
|
|
71
|
+
{
|
|
72
|
+
overflow: 'hidden',
|
|
73
|
+
pointerEvents: isIn ? 'auto' : 'none',
|
|
74
|
+
},
|
|
75
|
+
animatedStyle,
|
|
76
|
+
]}>
|
|
77
|
+
<View style={[{ position: 'absolute' }, style]} onLayout={handleLayout}>
|
|
78
|
+
{children}
|
|
79
|
+
</View>
|
|
80
|
+
</Animated.View>
|
|
81
|
+
)
|
|
82
|
+
}
|
package/src/contexts/root.tsx
CHANGED
|
@@ -28,14 +28,14 @@ const createPaperTheme = (
|
|
|
28
28
|
return {
|
|
29
29
|
dark: colorMode === 'dark',
|
|
30
30
|
colors: {
|
|
31
|
-
primary: colors.accent[
|
|
31
|
+
primary: colors.accent[300],
|
|
32
32
|
onPrimary: colors.text[900],
|
|
33
|
-
primaryContainer: colors.accent[
|
|
34
|
-
onPrimaryContainer: colors.text[
|
|
33
|
+
primaryContainer: colors.accent[800],
|
|
34
|
+
onPrimaryContainer: colors.text[150],
|
|
35
35
|
|
|
36
36
|
secondary: colors.background[150],
|
|
37
37
|
onSecondary: colors.text[100],
|
|
38
|
-
secondaryContainer: colors.
|
|
38
|
+
secondaryContainer: colors.accent[950],
|
|
39
39
|
onSecondaryContainer: colors.text[150],
|
|
40
40
|
|
|
41
41
|
tertiary: colors.accent[600],
|
|
@@ -53,7 +53,7 @@ const createPaperTheme = (
|
|
|
53
53
|
surface: colors.background[100],
|
|
54
54
|
onSurface: colors.text[100],
|
|
55
55
|
surfaceVariant: colors.background[200],
|
|
56
|
-
onSurfaceVariant: colors.text[
|
|
56
|
+
onSurfaceVariant: colors.text[300],
|
|
57
57
|
outline: colors.text[500],
|
|
58
58
|
outlineVariant: colors.accent[300],
|
|
59
59
|
|
|
@@ -92,7 +92,7 @@ const createPaperTheme = (
|
|
|
92
92
|
...fonts?.bodyMedium,
|
|
93
93
|
},
|
|
94
94
|
bodySmall: {
|
|
95
|
-
fontSize:
|
|
95
|
+
fontSize: 16,
|
|
96
96
|
...fonts?.bodySmall,
|
|
97
97
|
},
|
|
98
98
|
},
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCustomInput, BaseCustomInputProps } from '@chem-po/react'
|
|
2
|
+
import { TextStyle, ViewStyle } from 'react-native'
|
|
3
|
+
|
|
4
|
+
export type CustomInput<Value, InputStyle = TextStyle> = BaseCustomInput<
|
|
5
|
+
Value,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
InputStyle
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
export type CustomInputProps<Value, InputStyle = TextStyle> = BaseCustomInputProps<
|
|
11
|
+
Value,
|
|
12
|
+
ViewStyle,
|
|
13
|
+
InputStyle
|
|
14
|
+
>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './forms'
|