@codeleap/mobile 4.2.18 → 4.3.1

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.
Files changed (204) hide show
  1. package/dist/components/ActivityIndicator/types.d.ts +1 -1
  2. package/dist/components/Autocomplete/index.js +2 -1
  3. package/dist/components/Autocomplete/index.js.map +1 -1
  4. package/dist/components/Autocomplete/types.d.ts +2 -1
  5. package/dist/components/Avatar/index.js +3 -1
  6. package/dist/components/Avatar/index.js.map +1 -1
  7. package/dist/components/Badge/index.js +1 -1
  8. package/dist/components/Badge/index.js.map +1 -1
  9. package/dist/components/Badge/types.d.ts +1 -1
  10. package/dist/components/Button/styles.d.ts +1 -1
  11. package/dist/components/Calendar/index.js +1 -1
  12. package/dist/components/Calendar/index.js.map +1 -1
  13. package/dist/components/Calendar/types.d.ts +1 -1
  14. package/dist/components/DatePickerModal/index.js +3 -1
  15. package/dist/components/DatePickerModal/index.js.map +1 -1
  16. package/dist/components/DatePickerModal/types.d.ts +2 -1
  17. package/dist/components/FileInput/index.js +1 -1
  18. package/dist/components/FileInput/index.js.map +1 -1
  19. package/dist/components/FileInput/types.d.ts +2 -1
  20. package/dist/components/Icon/index.js +2 -1
  21. package/dist/components/Icon/index.js.map +1 -1
  22. package/dist/components/Image/index.js +2 -1
  23. package/dist/components/Image/index.js.map +1 -1
  24. package/dist/components/Image/types.d.ts +1 -1
  25. package/dist/components/ImageView/Spotlight.js +3 -1
  26. package/dist/components/ImageView/Spotlight.js.map +1 -1
  27. package/dist/components/ImageView/component.d.ts +1 -1
  28. package/dist/components/ImageView/component.js +1 -1
  29. package/dist/components/ImageView/component.js.map +1 -1
  30. package/dist/components/InputBase/index.js +2 -1
  31. package/dist/components/InputBase/index.js.map +1 -1
  32. package/dist/components/InputBase/styles.js +1 -1
  33. package/dist/components/InputBase/styles.js.map +1 -1
  34. package/dist/components/InputBase/types.d.ts +1 -1
  35. package/dist/components/List/index.js +2 -1
  36. package/dist/components/List/index.js.map +1 -1
  37. package/dist/components/Modal/index.js +1 -1
  38. package/dist/components/Modal/index.js.map +1 -1
  39. package/dist/components/Modal/types.d.ts +1 -1
  40. package/dist/components/Navigation/Navigation.js +1 -1
  41. package/dist/components/Navigation/Navigation.js.map +1 -1
  42. package/dist/components/NumberIncrement/index.js +2 -1
  43. package/dist/components/NumberIncrement/index.js.map +1 -1
  44. package/dist/components/NumberIncrement/types.d.ts +2 -1
  45. package/dist/components/Pager/PagerDots.d.ts +1 -1
  46. package/dist/components/Pager/index.js +2 -1
  47. package/dist/components/Pager/index.js.map +1 -1
  48. package/dist/components/PaginationIndicator/index.js +1 -1
  49. package/dist/components/PaginationIndicator/index.js.map +1 -1
  50. package/dist/components/PlacesAutocomplete/index.js +1 -1
  51. package/dist/components/PlacesAutocomplete/index.js.map +1 -1
  52. package/dist/components/PlacesAutocomplete/types.d.ts +1 -1
  53. package/dist/components/RadioInput/index.js +1 -1
  54. package/dist/components/RadioInput/index.js.map +1 -1
  55. package/dist/components/RadioInput/types.d.ts +2 -1
  56. package/dist/components/Scroll/index.js +2 -1
  57. package/dist/components/Scroll/index.js.map +1 -1
  58. package/dist/components/SearchInput/index.js +1 -1
  59. package/dist/components/SearchInput/index.js.map +1 -1
  60. package/dist/components/SectionFilters/index.js +2 -1
  61. package/dist/components/SectionFilters/index.js.map +1 -1
  62. package/dist/components/SectionFilters/useSectionFilters.js +2 -1
  63. package/dist/components/SectionFilters/useSectionFilters.js.map +1 -1
  64. package/dist/components/Sections/index.js +2 -1
  65. package/dist/components/Sections/index.js.map +1 -1
  66. package/dist/components/SegmentedControl/Option.d.ts +1 -1
  67. package/dist/components/SegmentedControl/styles.d.ts +1 -1
  68. package/dist/components/SegmentedControl/types.d.ts +1 -1
  69. package/dist/components/Select/index.js +2 -1
  70. package/dist/components/Select/index.js.map +1 -1
  71. package/dist/components/Select/types.d.ts +2 -1
  72. package/dist/components/Slider/index.js +2 -1
  73. package/dist/components/Slider/index.js.map +1 -1
  74. package/dist/components/SortablePhotos/useSortablePhotos.d.ts +1 -1
  75. package/dist/components/SortablePhotos/useSortablePhotos.js +3 -3
  76. package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
  77. package/dist/components/Text/index.js +1 -1
  78. package/dist/components/Text/index.js.map +1 -1
  79. package/dist/components/Text/styles.d.ts +1 -1
  80. package/dist/components/TextInput/index.js +3 -1
  81. package/dist/components/TextInput/index.js.map +1 -1
  82. package/dist/components/TextInput/types.d.ts +2 -1
  83. package/dist/components/Touchable/index.js +3 -1
  84. package/dist/components/Touchable/index.js.map +1 -1
  85. package/dist/components/Touchable/types.d.ts +1 -1
  86. package/dist/components/View/types.d.ts +1 -1
  87. package/dist/modules/types/textInputMask.d.ts +1 -1
  88. package/dist/utils/KeyboardAware/keyboardHooks.js +1 -1
  89. package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
  90. package/dist/utils/MobilePermissionManager/Permission.d.ts +19 -0
  91. package/dist/utils/MobilePermissionManager/Permission.js +65 -0
  92. package/dist/utils/MobilePermissionManager/Permission.js.map +1 -0
  93. package/dist/utils/MobilePermissionManager/PermissionManager.d.ts +24 -0
  94. package/dist/utils/MobilePermissionManager/PermissionManager.js +84 -0
  95. package/dist/utils/MobilePermissionManager/PermissionManager.js.map +1 -0
  96. package/dist/utils/MobilePermissionManager/index.d.ts +3 -0
  97. package/dist/utils/MobilePermissionManager/index.js +5 -0
  98. package/dist/utils/MobilePermissionManager/index.js.map +1 -0
  99. package/dist/utils/MobilePermissionManager/types.d.ts +32 -0
  100. package/dist/utils/MobilePermissionManager/types.js +2 -0
  101. package/dist/utils/MobilePermissionManager/types.js.map +1 -0
  102. package/dist/utils/ModalManager/components.d.ts +1 -1
  103. package/dist/utils/ModalManager/components.js +1 -1
  104. package/dist/utils/ModalManager/components.js.map +1 -1
  105. package/dist/utils/ModalManager/context.d.ts +1 -1
  106. package/dist/utils/ModalManager/context.js +2 -1
  107. package/dist/utils/ModalManager/context.js.map +1 -1
  108. package/dist/utils/NotificationManager/index.d.ts +2 -2
  109. package/dist/utils/NotificationManager/index.js +1 -1
  110. package/dist/utils/NotificationManager/index.js.map +1 -1
  111. package/dist/utils/NotificationManager/types.d.ts +1 -1
  112. package/dist/utils/PermissionManager/context.d.ts +1 -1
  113. package/dist/utils/PermissionManager/context.js +2 -1
  114. package/dist/utils/PermissionManager/context.js.map +1 -1
  115. package/dist/utils/PermissionManager/types.d.ts +1 -1
  116. package/dist/utils/StorageManager.d.ts +1 -1
  117. package/dist/utils/hooks.js +3 -1
  118. package/dist/utils/hooks.js.map +1 -1
  119. package/dist/utils/index.d.ts +1 -0
  120. package/dist/utils/index.js +1 -0
  121. package/dist/utils/index.js.map +1 -1
  122. package/dist/utils/misc.d.ts +1 -1
  123. package/dist/utils/misc.js +2 -1
  124. package/dist/utils/misc.js.map +1 -1
  125. package/dist/utils/useQueryListRefresh.d.ts +2 -1
  126. package/dist/utils/useQueryListRefresh.js +1 -1
  127. package/dist/utils/useQueryListRefresh.js.map +1 -1
  128. package/package.json +19 -5
  129. package/package.json.bak +18 -4
  130. package/src/components/ActivityIndicator/types.ts +1 -1
  131. package/src/components/Autocomplete/index.tsx +3 -1
  132. package/src/components/Autocomplete/types.ts +2 -1
  133. package/src/components/Avatar/index.tsx +3 -1
  134. package/src/components/Badge/index.tsx +2 -2
  135. package/src/components/Badge/types.ts +1 -1
  136. package/src/components/Button/index.tsx +1 -1
  137. package/src/components/Button/styles.ts +1 -1
  138. package/src/components/Calendar/index.tsx +1 -1
  139. package/src/components/Calendar/types.ts +1 -2
  140. package/src/components/DatePickerModal/index.tsx +3 -1
  141. package/src/components/DatePickerModal/types.ts +2 -1
  142. package/src/components/FileInput/index.tsx +2 -1
  143. package/src/components/FileInput/types.ts +2 -1
  144. package/src/components/Icon/index.tsx +2 -1
  145. package/src/components/Image/index.tsx +2 -1
  146. package/src/components/Image/types.ts +1 -1
  147. package/src/components/ImageView/Spotlight.tsx +3 -1
  148. package/src/components/ImageView/component.tsx +3 -1
  149. package/src/components/InputBase/index.tsx +2 -1
  150. package/src/components/InputBase/styles.ts +1 -1
  151. package/src/components/InputBase/types.ts +1 -1
  152. package/src/components/List/index.tsx +2 -1
  153. package/src/components/Modal/index.tsx +1 -1
  154. package/src/components/Modal/types.ts +1 -1
  155. package/src/components/Navigation/Navigation.tsx +1 -1
  156. package/src/components/NumberIncrement/index.tsx +2 -1
  157. package/src/components/NumberIncrement/types.ts +2 -1
  158. package/src/components/Pager/PagerDots.tsx +1 -1
  159. package/src/components/Pager/index.tsx +2 -1
  160. package/src/components/PaginationIndicator/index.tsx +1 -1
  161. package/src/components/PlacesAutocomplete/index.tsx +1 -1
  162. package/src/components/PlacesAutocomplete/types.ts +1 -1
  163. package/src/components/RadioInput/index.tsx +1 -1
  164. package/src/components/RadioInput/types.ts +2 -1
  165. package/src/components/Scroll/index.tsx +2 -1
  166. package/src/components/SearchInput/index.tsx +1 -1
  167. package/src/components/SectionFilters/index.tsx +2 -1
  168. package/src/components/SectionFilters/useSectionFilters.tsx +2 -1
  169. package/src/components/Sections/index.tsx +2 -1
  170. package/src/components/SegmentedControl/Option.tsx +1 -1
  171. package/src/components/SegmentedControl/styles.ts +1 -1
  172. package/src/components/SegmentedControl/types.ts +1 -1
  173. package/src/components/Select/index.tsx +3 -3
  174. package/src/components/Select/types.ts +2 -1
  175. package/src/components/Slider/index.tsx +2 -1
  176. package/src/components/SortablePhotos/useSortablePhotos.ts +3 -3
  177. package/src/components/Text/index.tsx +1 -1
  178. package/src/components/Text/styles.ts +1 -1
  179. package/src/components/TextInput/index.tsx +3 -1
  180. package/src/components/TextInput/types.ts +2 -1
  181. package/src/components/Touchable/index.tsx +3 -1
  182. package/src/components/Touchable/types.ts +1 -1
  183. package/src/components/View/types.ts +1 -1
  184. package/src/modules/types/textInputMask.ts +1 -1
  185. package/src/utils/KeyboardAware/keyboardHooks.ts +1 -1
  186. package/src/utils/MobilePermissionManager/Permission.ts +79 -0
  187. package/src/utils/MobilePermissionManager/PermissionManager.ts +124 -0
  188. package/src/utils/MobilePermissionManager/index.ts +3 -0
  189. package/src/utils/MobilePermissionManager/types.ts +44 -0
  190. package/src/utils/ModalManager/components.tsx +2 -1
  191. package/src/utils/ModalManager/context.tsx +2 -1
  192. package/src/utils/NotificationManager/index.ts +2 -1
  193. package/src/utils/NotificationManager/types.ts +1 -1
  194. package/src/utils/PermissionManager/context.tsx +3 -1
  195. package/src/utils/PermissionManager/types.ts +1 -1
  196. package/src/utils/StorageManager.ts +1 -1
  197. package/src/utils/hooks.ts +3 -1
  198. package/src/utils/index.ts +1 -0
  199. package/src/utils/misc.ts +2 -1
  200. package/src/utils/useQueryListRefresh.ts +2 -1
  201. package/dist/utils/deprecated/notifications.d.ts +0 -40
  202. package/dist/utils/deprecated/notifications.js +0 -167
  203. package/dist/utils/deprecated/notifications.js.map +0 -1
  204. package/src/utils/deprecated/notifications.ts +0 -213
@@ -1,4 +1,5 @@
1
- import { FormTypes, PropsOf } from '@codeleap/common'
1
+ import { PropsOf } from '@codeleap/types'
2
+ import { FormTypes } from '@codeleap/form'
2
3
  import { AppIcon, StyledProp } from '@codeleap/styles'
3
4
  import { StylesOf } from '../../types/utility'
4
5
  import { GetKeyboardAwarePropsOptions } from '../../utils'
@@ -1,7 +1,8 @@
1
1
  import React from 'react'
2
2
  import { Slider as RNSlider } from '@miblanchard/react-native-slider'
3
3
  import { StyleSheet } from 'react-native'
4
- import { TypeGuards, onUpdate } from '@codeleap/common'
4
+ import { TypeGuards } from '@codeleap/types'
5
+ import { onUpdate } from '@codeleap/hooks'
5
6
  import { SliderProps, TrackMarkProps } from './types'
6
7
  import { InputBase, selectInputBaseProps } from '../InputBase'
7
8
  import { Text } from '../Text'
@@ -1,4 +1,5 @@
1
- import { CreateOSAlert, useEffect, useGlobalContext, useMemo, useState } from '@codeleap/common'
1
+ import { CreateOSAlert } from '@codeleap/modals'
2
+ import { useEffect, useMemo, useState } from '@codeleap/hooks'
2
3
  import { FileInputImageSource, useFileInput } from '../FileInput'
3
4
  import { SortablePhoto, SortablePhotosProps } from './types'
4
5
 
@@ -20,7 +21,6 @@ export const useSortablePhotos = <T extends SortablePhoto>(props: SortablePhotos
20
21
  } = props
21
22
 
22
23
  const input = useFileInput()
23
- const { logger } = useGlobalContext()
24
24
 
25
25
  const [data, setData] = useState<T[]>([])
26
26
 
@@ -91,7 +91,7 @@ export const useSortablePhotos = <T extends SortablePhoto>(props: SortablePhotos
91
91
  multiple: isEdit ? false : props?.multiple
92
92
  })
93
93
  } catch (error) {
94
- logger.error('Error opening file picker:', error)
94
+ console.error('Error opening file picker:', error)
95
95
  }
96
96
 
97
97
  if (files?.length <= 0) return null
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef, useState } from 'react'
2
- import { TypeGuards } from '@codeleap/common'
2
+ import { TypeGuards } from '@codeleap/types'
3
3
  import { Animated, Platform, Text as NativeText } from 'react-native'
4
4
  import { TouchableFeedbackConfig, usePressableFeedback } from '../../utils'
5
5
  import { TextProps } from './types'
@@ -1,4 +1,4 @@
1
- import { StylesOf } from '@codeleap/common'
1
+ import { StylesOf } from '@codeleap/types'
2
2
  import { FeedbackConfig } from '../../utils'
3
3
 
4
4
  export type TextComposition = 'text' | 'pressFeedback' | 'text:disabled'
@@ -1,5 +1,7 @@
1
1
  import React, { useState } from 'react'
2
- import { TypeGuards, useValidate, useBooleanToggle } from '@codeleap/common'
2
+ import { useValidate } from '@codeleap/form'
3
+ import { useBooleanToggle } from '@codeleap/hooks'
4
+ import { TypeGuards } from '@codeleap/types'
3
5
  import { forwardRef, useImperativeHandle } from 'react'
4
6
  import { TextInput as NativeTextInput, NativeSyntheticEvent, TextInputFocusEventData } from 'react-native'
5
7
  import { InputBase, selectInputBaseProps } from '../InputBase'
@@ -1,6 +1,7 @@
1
1
  import { InputBaseProps } from '../InputBase'
2
2
  import { TextInputProps as RNTextInputProps, TextInput as RNTextInput } from 'react-native'
3
- import { AnyFunction, FormTypes, yup } from '@codeleap/common'
3
+ import { AnyFunction } from '@codeleap/types'
4
+ import { FormTypes, yup } from '@codeleap/form'
4
5
  import { AppIcon, StyledProp } from '@codeleap/styles'
5
6
  import { TextInputMaskProps } from '../../modules/textInputMask'
6
7
  import { TextInputComposition } from './styles'
@@ -1,5 +1,7 @@
1
1
  import React, { forwardRef } from 'react'
2
- import { TypeGuards, onMount, useGlobalContext } from '@codeleap/common'
2
+ import { TypeGuards } from '@codeleap/types'
3
+ import { onMount } from '@codeleap/hooks'
4
+ import { useGlobalContext } from '@codeleap/hooks'
3
5
  import { Pressable, StyleSheet, View as RNView, Insets, Platform } from 'react-native'
4
6
  import { View } from '../View'
5
7
  import { TouchableFeedbackConfig, usePressableFeedback } from '../../utils'
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from '@codeleap/common'
1
+ import { AnyFunction } from '@codeleap/types'
2
2
  import { StyledProp } from '@codeleap/styles'
3
3
  import { View as RNView, PressableProps } from 'react-native'
4
4
  import { TouchableComposition } from './styles'
@@ -1,4 +1,4 @@
1
- import { PropsOf } from '@codeleap/common'
1
+ import { PropsOf } from '@codeleap/types'
2
2
  import { StyledProp } from '@codeleap/styles'
3
3
  import { ImageStyle, TextStyle, View as RNView, ViewStyle } from 'react-native'
4
4
  import { AnimatedStyleProp } from 'react-native-reanimated'
@@ -1,4 +1,4 @@
1
- import { FormTypes } from '@codeleap/common'
1
+ import { FormTypes } from '@codeleap/form'
2
2
  import { TextInputProps } from 'react-native'
3
3
 
4
4
  import { TextInputMaskProps as RNTextInputMaskProps } from 'react-native-masked-text'
@@ -1,4 +1,4 @@
1
- import { PropsOf, TypeGuards } from '@codeleap/common'
1
+ import { PropsOf, TypeGuards } from '@codeleap/types'
2
2
  import { ScrollView, Platform, StyleSheet, Dimensions, EasingFunction, Easing } from 'react-native'
3
3
  import { TransitionConfig } from '../../types'
4
4
  import { useKeyboard } from './context'
@@ -0,0 +1,79 @@
1
+ import { AnyFunction } from '@codeleap/types'
2
+ import * as PermissionTypes from './types'
3
+
4
+ const SCOPE = 'Permissions'
5
+
6
+ export class Permission implements PermissionTypes.IPermission {
7
+ status: PermissionTypes.PermissionStatus
8
+
9
+ shouldAsk: boolean
10
+
11
+ constructor(private actions:PermissionTypes.PermissionActions & {log?: AnyFunction}, public name = '') {
12
+ this.actions = actions
13
+ this.shouldAsk = true
14
+ this.status = 'pending'
15
+
16
+ }
17
+
18
+ async ask(): Promise<void> {
19
+ const newState = await this.actions.onAsk()
20
+ this.actions.log(`Request for permission ${this.name} returned`, newState, SCOPE)
21
+ this.status = newState
22
+
23
+ if (newState === 'blocked') {
24
+ this.shouldAsk = false
25
+ }
26
+ }
27
+
28
+ async check(options?:PermissionTypes.CheckOptions): Promise<void> {
29
+ const _options:PermissionTypes.CheckOptions = {
30
+ askOnPending: true,
31
+ askOnDenied: false,
32
+ ask: true,
33
+ ...options,
34
+ }
35
+
36
+ this.status = await this.actions.onCheck()
37
+ this.actions.log(`Check for permission ${this.name} returned`, this.status, SCOPE)
38
+ if (!_options.ask) return
39
+
40
+ switch (this.status) {
41
+ case 'denied':
42
+ if (_options.askOnDenied) {
43
+ await this.ask()
44
+ }
45
+ break
46
+ case 'pending':
47
+ if (_options.askOnPending) {
48
+ await this.ask()
49
+ }
50
+ break
51
+ }
52
+ }
53
+
54
+ get isGranted() {
55
+ return this.status === 'granted'
56
+ }
57
+
58
+ get isDenied() {
59
+ return this.status === 'denied'
60
+ }
61
+
62
+ get isPending() {
63
+ return this.status === 'pending'
64
+ }
65
+
66
+ get isBlocked() {
67
+ return this.status === 'blocked'
68
+ }
69
+
70
+ get isUnavailable() {
71
+ return this.status === 'unavailable'
72
+
73
+ }
74
+
75
+ get isLimited() {
76
+ return this.status === 'limited'
77
+
78
+ }
79
+ }
@@ -0,0 +1,124 @@
1
+ import { Logger } from '@codeleap/logger'
2
+ import { Permission } from './Permission'
3
+ import * as PermissionTypes from './types'
4
+
5
+ export class PermissionManager<
6
+ T extends PermissionTypes.PermissionActionRecord,
7
+ I extends PermissionTypes.IPermissionManager<T> = PermissionTypes.IPermissionManager<T>
8
+ > implements PermissionTypes.IPermissionManager<T> {
9
+ private _permissions:Record<keyof T, Permission>
10
+
11
+ subscriberArgs:Parameters<PermissionTypes.ChangeListener<T>>
12
+
13
+ private subscribers: PermissionTypes.ChangeListener<T>[]
14
+
15
+ private permSubscribers: Record<keyof T, PermissionTypes.PermissionSubscriber[]>
16
+
17
+ public _perms: T
18
+
19
+ public opts: I
20
+
21
+ private params: T
22
+
23
+ public permissions: {
24
+ [Property in keyof T as Uppercase<string & Property>] : Property
25
+ }
26
+
27
+ logger: Logger
28
+
29
+ constructor(perms: T, options?: PermissionTypes.PermissionManagerOptions) {
30
+ this.params = perms
31
+ // @ts-ignore
32
+ this._permissions = {}
33
+ // @ts-ignore
34
+ this.permissions = {}
35
+
36
+ this.logger = options?.logger
37
+ this.permSubscribers = {} as typeof this.permSubscribers
38
+
39
+ for (const [permName, actions] of Object.entries(this.params)) {
40
+ const name = permName as keyof T
41
+ this._permissions[name] = new Permission({ ...actions, log: this.logger?.log || (() => null) }, permName)
42
+
43
+ this.permSubscribers[name] = []
44
+
45
+ // @ts-ignore
46
+ this.permissions[(name as string).toUpperCase()] = name
47
+ }
48
+
49
+ this.subscribers = []
50
+ }
51
+
52
+ get values() {
53
+ return this._permissions as unknown as Record<keyof T, PermissionTypes.PermissionState>
54
+ }
55
+
56
+ private async check(name: keyof T, options?: PermissionTypes.CheckOptions): Promise<PermissionTypes.PermissionState> {
57
+ const previousStatus = this._permissions[name].status
58
+
59
+ await this._permissions[name].check(options)
60
+
61
+ if (this._permissions[name].status !== previousStatus) {
62
+ this.permSubscribers[name].forEach(sub => sub(this._permissions[name]))
63
+ this.subscribers.forEach(sub => sub(name, this._permissions[name]))
64
+ }
65
+ return this._permissions[name]
66
+ }
67
+
68
+ getMany:I['getMany'] = async (perms, options) => {
69
+
70
+ const results = []
71
+
72
+ for (const p of perms) {
73
+ const isArray = Array.isArray(p)
74
+ const name = isArray ? p[0] : p
75
+ const opts = isArray ? p[1] : options
76
+
77
+ results.push(await this.check(name, opts))
78
+ }
79
+
80
+ return results
81
+ }
82
+
83
+ // @ts-ignore
84
+ get:I['get'] = async (name, options) => {
85
+ return await this.check(name, options)
86
+ }
87
+
88
+ onPermissionChange(name: keyof T, callback:PermissionTypes.PermissionSubscriber) {
89
+ const subIdx = this.permSubscribers[name].push(callback) - 1
90
+
91
+ return () => {
92
+ this.permSubscribers[name].splice(subIdx, 1)
93
+ }
94
+ }
95
+
96
+ onChange(callback:PermissionTypes.ChangeListener<T>) {
97
+ const subIdx = this.subscribers.push(callback) - 1
98
+
99
+ return () => {
100
+ this.subscribers.splice(subIdx, 1)
101
+ }
102
+ }
103
+
104
+ getState() {
105
+ const state = {}
106
+
107
+ for (const [p, { ask: _ig2, check: _ig1, ...values }] of Object.entries(this._permissions)) {
108
+ state[p] = { ...values }
109
+ }
110
+
111
+ return state as Record<keyof T, PermissionTypes.PermissionState>
112
+ }
113
+
114
+ async update() {
115
+ const res = {} as Record<keyof T, PermissionTypes.PermissionState>
116
+ for (const p of Object.keys(this._permissions)) {
117
+ res[p as keyof T] = await this.check(p, {
118
+ ask: false,
119
+ })
120
+ }
121
+ return res
122
+ }
123
+
124
+ }
@@ -0,0 +1,3 @@
1
+ export * as PermissionTypes from './types'
2
+ export * from './Permission'
3
+ export * from './PermissionManager'
@@ -0,0 +1,44 @@
1
+ import { Logger } from '@codeleap/logger'
2
+ import { FunctionType } from '@codeleap/types'
3
+
4
+ export const permissionStatuses = ['unavailable', 'pending', 'denied', 'limited', 'granted', 'blocked'] as const
5
+ export type PermissionStatus = typeof permissionStatuses[number]
6
+
7
+ export type PermissionState = {
8
+ status: PermissionStatus
9
+ shouldAsk: boolean
10
+
11
+ } & Record<`is${Capitalize<PermissionStatus>}`, boolean>
12
+
13
+ export type CheckOptions = {
14
+ askOnPending?:boolean
15
+ askOnDenied?:boolean
16
+ ask?: boolean
17
+
18
+ }
19
+
20
+ export type IPermission = {
21
+ ask():Promise<void>
22
+ check(options?:CheckOptions):Promise<void>
23
+
24
+ } & PermissionState
25
+
26
+ export type PermFunction = FunctionType<[], Promise<PermissionStatus>>
27
+
28
+ export type PermissionActions = Record<'onAsk'|'onCheck', PermFunction> & { init?: 'check' | PermissionState }
29
+
30
+ export type PermissionActionRecord = Record<string, PermissionActions>
31
+
32
+ export interface IPermissionManager<T extends PermissionActionRecord> {
33
+ getMany(perms: PermissionArray<T>, options?: CheckOptions): Promise<PermissionState[]>
34
+ get(name: keyof T, options?: CheckOptions): Promise<PermissionState>
35
+ }
36
+
37
+ export type ChangeListener<T> = FunctionType<[keyof T, PermissionState], any>
38
+ export type PermissionSubscriber = FunctionType<[PermissionState], any>
39
+
40
+ export type PermissionArray<T> = ([name: keyof T, options: CheckOptions])[] | (keyof T)[]
41
+
42
+ export type PermissionManagerOptions = {
43
+ logger?: Logger
44
+ }
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
- import { usePrevious, onMount, onUpdate, PropsOf } from '@codeleap/common'
2
+ import { usePrevious, onMount, onUpdate } from '@codeleap/hooks'
3
+ import { PropsOf } from '@codeleap/types'
3
4
  import { useModalContext } from './context'
4
5
  import { Portal } from '@gorhom/portal'
5
6
  import { Modal as _Modal } from '../../components/Modal'
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
- import { AnyFunction, onUpdate, TypeGuards, useState } from '@codeleap/common'
2
+ import { AnyFunction, TypeGuards } from '@codeleap/types'
3
+ import { onUpdate, useState } from '@codeleap/hooks'
3
4
  import { PortalProvider } from '@gorhom/portal'
4
5
  import { KeyboardProvider } from '../KeyboardAware'
5
6
 
@@ -1,4 +1,5 @@
1
- import { AnyFunction, silentLogger } from '@codeleap/common' // @ts-ignore
1
+ import { AnyFunction } from '@codeleap/types'
2
+ import { silentLogger } from '@codeleap/logger' // @ts-ignore
2
3
  import messaging from '@react-native-firebase/messaging'
3
4
  import { Subscriber, Subscription } from '../Subscription'
4
5
  import { Message, NotificationInitializeCallback, NotificationManagerOptions, NotificationType, TNotification } from './types'
@@ -1,6 +1,6 @@
1
1
  // @ts-ignore
2
2
  import { FirebaseMessagingTypes } from '@react-native-firebase/messaging'
3
- import { FunctionType } from '@codeleap/common'
3
+ import { FunctionType } from '@codeleap/types'
4
4
 
5
5
  export type Message = FirebaseMessagingTypes.RemoteMessage
6
6
 
@@ -1,8 +1,10 @@
1
1
  import React, { useContext, useState } from 'react'
2
2
  import { useModalContext } from '../ModalManager/context'
3
- import { deepEqual, onMount, onUpdate, PermissionManager, PermissionTypes, useDebounce, usePrevious } from '@codeleap/common'
3
+ import { onMount, onUpdate, useDebounce, usePrevious } from '@codeleap/hooks'
4
+ import { deepEqual } from '@codeleap/utils'
4
5
  import { AppState, Linking } from 'react-native'
5
6
  import { PermissionConfig, PermissionModalsConfig } from './types'
7
+ import { PermissionManager, PermissionTypes } from '../MobilePermissionManager'
6
8
 
7
9
  type TPermissionContext = {
8
10
  state: Record<string, PermissionTypes.PermissionStatus>
@@ -1,5 +1,5 @@
1
- import { PermissionTypes } from '@codeleap/common'
2
1
  import { ImageProps } from '../../components/Image'
2
+ import { PermissionTypes } from '../MobilePermissionManager'
3
3
  type NonGrantedPermissionTypes = Exclude<PermissionTypes.PermissionStatus, 'granted'>
4
4
 
5
5
  export type BasePermissionConfig = {
@@ -1,5 +1,5 @@
1
1
  import { MMKV } from 'react-native-mmkv'
2
- import { AnyFunction, AnyRecord } from '@codeleap/common'
2
+ import { AnyFunction, AnyRecord } from '@codeleap/types'
3
3
 
4
4
  type StorageKey<T extends Record<string, any>> = keyof T | (string & {}) | ((allKeys: T) => string) | [keyof T, any]
5
5
 
@@ -1,4 +1,6 @@
1
- import { onMount, onUpdate, shadeColor, TypeGuards, usePrevious, useRef, useState } from '@codeleap/common'
1
+ import { onMount, onUpdate, usePrevious, useRef, useState } from '@codeleap/hooks'
2
+ import { shadeColor } from '@codeleap/utils'
3
+ import { TypeGuards } from '@codeleap/types'
2
4
  import { Animated, AppState, AppStateStatus, Platform, BackHandler, ViewStyle, ImageStyle, TextStyle, StyleSheet, StyleProp } from 'react-native'
3
5
  import { AnimatedStyleProp, Easing, EasingFn, useAnimatedStyle, withTiming } from 'react-native-reanimated'
4
6
  import { PressableRippleProps } from '../modules/PressableRipple/type'
@@ -14,3 +14,4 @@ export * from './Subscription'
14
14
  export * from './useQueryListRefresh'
15
15
 
16
16
  export * from './StorageManager'
17
+ export * from './MobilePermissionManager'
package/src/utils/misc.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { MobileFile, MobileInputFile, parseFilePathData, FileWithPreview, TypeGuards } from '@codeleap/common'
1
+ import { MobileFile, MobileInputFile, FileWithPreview, TypeGuards } from '@codeleap/types'
2
+ import { parseFilePathData } from '@codeleap/utils'
2
3
 
3
4
  export const stringToFile = (str: string): MobileInputFile => {
4
5
  if (!str) {
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { useFocusEffect } from '@react-navigation/native'
3
- import { AnyFunction, TypeGuards, UseListEffect } from '@codeleap/common'
3
+ import { AnyFunction, TypeGuards } from '@codeleap/types'
4
+ import { UseListEffect } from '@codeleap/query'
4
5
 
5
6
  type useQueryListRefresh = (
6
7
  listQuery: Parameters<UseListEffect>[0],
@@ -1,40 +0,0 @@
1
- import { FunctionType } from '@codeleap/common';
2
- import { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
3
- export type Message = FirebaseMessagingTypes.RemoteMessage;
4
- export type MessageType = 'foreground' | 'background' | 'press' | 'initial';
5
- export type NotificationHandler = FunctionType<[message: Message, type: MessageType], any>;
6
- export type HandleNotificationParam = {
7
- data: Message;
8
- type: MessageType;
9
- };
10
- export type NotificationStateChangeListener = FunctionType<[isInitialized: boolean, token?: string], any>;
11
- /**
12
- * Class responsible for the notification system
13
- *
14
- * @deprecated Use the most updated version
15
- * @note check the documentation to make the migration
16
- */
17
- export declare class NotificationManager {
18
- private logger;
19
- autoHandleInitialNotification: boolean;
20
- stateChangeListeners: NotificationStateChangeListener[];
21
- messageListeners: NotificationHandler[];
22
- _initialized: boolean;
23
- unsubscribeFromMessage: any;
24
- unsubscribeFromBackgroundMessage: any;
25
- unsubscribeFromPress: any;
26
- _currentToken: any;
27
- _initialNoficationHandled: boolean;
28
- constructor(logger?: import("@codeleap/common").Logger, autoHandleInitialNotification?: boolean);
29
- init(): Promise<void>;
30
- deinit(): Promise<void>;
31
- private handleNotification;
32
- get currentToken(): string;
33
- set currentToken(token: string);
34
- get initialized(): boolean;
35
- set initialized(to: boolean);
36
- onNotification(handler: NotificationHandler): () => void;
37
- private triggerStateChange;
38
- onStateChange(handler: NotificationStateChangeListener): () => void;
39
- getInitialNotification(): Promise<HandleNotificationParam>;
40
- }