@codeleap/mobile 3.23.6 → 3.24.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "3.23.6",
3
+ "version": "3.24.2",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "@codeleap/config": "*",
13
- "@types/react-native": "link:../../apps/mobile/node_modules/@types/react-native"
13
+ "@codeleap/common": "*"
14
14
  },
15
15
  "scripts": {
16
16
  "build": "tsc --build",
@@ -26,7 +26,7 @@
26
26
  "@react-navigation/native-stack": "6.9.8",
27
27
  "@react-navigation/stack": "6.3.11",
28
28
  "react": "18.1.0",
29
- "react-native": "0.70.6",
29
+ "react-native": "0.73.8",
30
30
  "react-native-calendars": "1.1293.0",
31
31
  "react-native-date-picker": "^4.2.13",
32
32
  "react-native-device-info": "10.3.0",
@@ -37,7 +37,7 @@
37
37
  "react-native-image-viewing": "0.2.2",
38
38
  "react-native-keyboard-aware-scroll-view": "0.9.5",
39
39
  "typescript": "5.0.4",
40
- "react-native-avoid-softinput": "3.1.5"
40
+ "react-native-avoid-softinput": "^3.1.5"
41
41
  },
42
42
  "dependencies": {
43
43
  "@gorhom/portal": "1.0.14",
@@ -4,7 +4,7 @@ import {
4
4
  useNestedStylesByKey,
5
5
  } from '@codeleap/common'
6
6
  import React from 'react'
7
- import { StyleSheet } from 'react-native'
7
+ import { StyleSheet, StyleProp, ViewStyle } from 'react-native'
8
8
  import { StylesOf } from '../../types'
9
9
  import { AvatarGroupComposition, AvatarGroupPresets } from './styles'
10
10
  import { View, ViewProps } from '../View'
@@ -18,11 +18,11 @@ export type AvatarGroupProps = ComponentVariants<typeof AvatarGroupPresets> & {
18
18
  avatarVariants?: AvatarProps['variants']
19
19
  }
20
20
 
21
- const defaultProps:Partial<AvatarGroupProps> = {
21
+ const defaultProps: Partial<AvatarGroupProps> = {
22
22
  displacement: 20.5,
23
23
  }
24
24
 
25
- export const AvatarGroup = (props:AvatarGroupProps) => {
25
+ export const AvatarGroup = (props: AvatarGroupProps) => {
26
26
  const {
27
27
  variants = [],
28
28
  avatars = [],
@@ -66,7 +66,7 @@ export const AvatarGroup = (props:AvatarGroupProps) => {
66
66
 
67
67
  AvatarGroup.defaultProps = defaultProps
68
68
 
69
- const getAvatarStyle = (index: number, displacementPixels: number) => {
69
+ const getAvatarStyle = (index: number, displacementPixels: number): StyleProp<ViewStyle> => {
70
70
  const displacement = index * 20.5
71
71
  return { right: `${displacement}%` }
72
72
  }
@@ -10,7 +10,6 @@ import {
10
10
  TypeGuards,
11
11
  } from '@codeleap/common'
12
12
  import { View as NativeView, ViewProps as RNViewProps } from 'react-native'
13
- import { GetKeyboardAwarePropsOptions } from '../../utils'
14
13
  import { TransitionConfig } from '../../types'
15
14
  import Animated from 'react-native-reanimated'
16
15
  export * from './styles'
@@ -19,7 +18,7 @@ type NativeViewProps = RNViewProps
19
18
 
20
19
  export type ViewRefType = NativeView
21
20
 
22
- export type ViewProps ={
21
+ export type ViewProps = {
23
22
  ref?: AnyRef<ViewRefType>
24
23
  component?: any
25
24
  animated?: boolean
@@ -1,70 +1,27 @@
1
1
  import React from 'react'
2
- import { useCodeleapContext, useEffect, useState, useContext } from '@codeleap/common'
3
- import {
4
- Keyboard,
5
- Platform,
6
- KeyboardEvent,
7
- KeyboardEventName,
8
- } from 'react-native'
2
+ import { useSoftInputState } from 'react-native-avoid-softinput'
9
3
 
10
- type KeyboardVisibilityEvents = {
11
- show: KeyboardEventName
12
- hide: KeyboardEventName
13
- }
14
4
  type TKeyboardCtx = {
15
- event: KeyboardEvent
16
5
  isVisible: boolean
17
6
  height: number
18
7
  }
19
- export const KeyboardCtx = React.createContext({} as TKeyboardCtx)
20
8
 
9
+ /**
10
+ *
11
+ * @deprecated useKeyboard does not need to be wrapped in a provider
12
+ */
21
13
  export const KeyboardProvider = ({ children }) => {
22
- const [keyboardEvent, setKeyboardEvent] = useState<KeyboardEvent>(null)
23
- const [keyboardVisible, setKeyboardVisible] = useState(false)
24
-
25
- useEffect(() => {
26
- const eventNames = Platform.select<KeyboardVisibilityEvents>({
27
- ios: {
28
- show: 'keyboardWillShow',
29
- hide: 'keyboardWillHide',
30
- },
31
- android: {
32
- show: 'keyboardDidShow',
33
- hide: 'keyboardDidHide',
34
- },
35
- })
36
- const events = [
37
- Keyboard.addListener(eventNames.show, (e) => {
38
-
39
- setKeyboardEvent(e)
40
- setKeyboardVisible(true)
41
- }),
42
- Keyboard.addListener(eventNames.hide, (e) => {
43
-
44
- setKeyboardEvent(e)
45
- setKeyboardVisible(false)
46
- }),
47
- ]
48
- return () => {
49
- events.forEach(e => e.remove())
50
- }
51
- }, [])
52
14
 
53
- const height = keyboardEvent?.endCoordinates?.height ?? 0
54
-
55
- const _return = {
56
- event: keyboardEvent,
57
- isVisible: keyboardVisible,
58
- height: (!!height && keyboardVisible) ? height : 0,
59
- ...Keyboard,
60
- }
61
-
62
- return <KeyboardCtx.Provider value={_return}>
15
+ return <>
63
16
  {children}
64
- </KeyboardCtx.Provider >
17
+ </>
65
18
 
66
19
  }
67
20
 
68
- export const useKeyboard = () => {
69
- return useContext(KeyboardCtx)
21
+ export const useKeyboard = (): TKeyboardCtx => {
22
+ const state = useSoftInputState()
23
+ return {
24
+ isVisible: state.isSoftInputShown,
25
+ height: state.softInputHeight,
26
+ }
70
27
  }
@@ -43,30 +43,31 @@ export const useKeyboardAwareView = (params?: UseKeyboardAwareViewParams) => {
43
43
  },
44
44
  }
45
45
 
46
- if (!_options.enabled || (Platform.OS === 'android' && !_options.enableOnAndroid)) return {
47
- keyboard,
48
- style: params?.styles,
46
+ if (!_options.enabled || (Platform.OS === 'android' && !_options.enableOnAndroid)) {
47
+ return {
48
+ keyboard,
49
+ style: params?.styles,
50
+ }
49
51
  }
50
52
 
51
-
52
53
  const baseStyle = StyleSheet.flatten(params.styles || {})
53
54
 
54
55
  let baseValue = baseStyle[_options.adapt] as number
55
56
 
56
- if(TypeGuards.isNil(baseValue)){
57
+ if (TypeGuards.isNil(baseValue)) {
57
58
  baseValue = 0
58
59
  }
59
-
60
+
60
61
  let valid = true
61
62
  const warnOnNotNumber = () => {
62
63
  if (!TypeGuards.isNil(baseValue) && !TypeGuards.isNumber(baseValue)) {
63
64
  valid = false
64
65
  const debugStr = params?.debugName ? 'at ' + params?.debugName + ' ' : ''
65
- console.log(debugStr)
66
+ console.log(debugStr)
66
67
  }
67
68
  }
68
69
 
69
- let newStyleProp = {
70
+ let newStyleProp = {
70
71
  ...baseStyle,
71
72
  }
72
73
 
@@ -98,14 +99,13 @@ export const useKeyboardAwareView = (params?: UseKeyboardAwareViewParams) => {
98
99
  break
99
100
  }
100
101
 
101
- if (!valid){
102
+ if (!valid) {
102
103
  newStyleProp = params.styles
103
104
  }
104
105
 
105
-
106
106
  return {
107
107
  keyboard,
108
108
  style: newStyleProp,
109
-
109
+
110
110
  }
111
111
  }