@codeleap/mobile 5.8.20 → 6.0.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.
- package/dist/Registry.js.map +1 -1
- package/dist/components/ActionIcon/index.d.ts +2 -3
- package/dist/components/ActionIcon/index.js +5 -11
- package/dist/components/ActionIcon/index.js.map +1 -1
- package/dist/components/ActivityIndicator/index.d.ts +2 -2
- package/dist/components/ActivityIndicator/index.js +2 -2
- package/dist/components/ActivityIndicator/index.js.map +1 -1
- package/dist/components/ActivityIndicator/types.d.ts +0 -1
- package/dist/components/Autocomplete/index.d.ts +2 -3
- package/dist/components/Autocomplete/index.js +15 -18
- package/dist/components/Autocomplete/index.js.map +1 -1
- package/dist/components/Autocomplete/types.d.ts +1 -2
- package/dist/components/Avatar/components/Badge.d.ts +1 -2
- package/dist/components/Avatar/components/Badge.js +2 -2
- package/dist/components/Avatar/components/Badge.js.map +1 -1
- package/dist/components/Avatar/components/Content.d.ts +1 -1
- package/dist/components/Avatar/components/Content.js +3 -7
- package/dist/components/Avatar/components/Content.js.map +1 -1
- package/dist/components/Avatar/components/Illustration.d.ts +1 -2
- package/dist/components/Avatar/components/Illustration.js +2 -5
- package/dist/components/Avatar/components/Illustration.js.map +1 -1
- package/dist/components/Avatar/components/OverlayIcon.d.ts +1 -2
- package/dist/components/Avatar/components/OverlayIcon.js +2 -3
- package/dist/components/Avatar/components/OverlayIcon.js.map +1 -1
- package/dist/components/Avatar/components/Text.d.ts +1 -2
- package/dist/components/Avatar/components/Text.js +2 -1
- package/dist/components/Avatar/components/Text.js.map +1 -1
- package/dist/components/Avatar/components/Wrapper.d.ts +1 -2
- package/dist/components/Avatar/components/Wrapper.js +3 -6
- package/dist/components/Avatar/components/Wrapper.js.map +1 -1
- package/dist/components/Avatar/context.d.ts +108 -111
- package/dist/components/Avatar/context.js.map +1 -1
- package/dist/components/Avatar/index.d.ts +6 -7
- package/dist/components/Avatar/index.js +2 -6
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/AvatarGroup/index.d.ts +2 -3
- package/dist/components/AvatarGroup/index.js +2 -4
- package/dist/components/AvatarGroup/index.js.map +1 -1
- package/dist/components/Backdrop/index.d.ts +2 -3
- package/dist/components/Backdrop/index.js +4 -8
- package/dist/components/Backdrop/index.js.map +1 -1
- package/dist/components/Badge/index.d.ts +2 -3
- package/dist/components/Badge/index.js +5 -9
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/types.d.ts +1 -2
- package/dist/components/Button/index.js +3 -9
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Calendar/index.d.ts +2 -3
- package/dist/components/Calendar/index.js +5 -4
- package/dist/components/Calendar/index.js.map +1 -1
- package/dist/components/CalendarInput/index.d.ts +2 -3
- package/dist/components/CalendarInput/index.js +11 -12
- package/dist/components/CalendarInput/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts +2 -3
- package/dist/components/Checkbox/index.js +9 -15
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/DatePickerModal/index.d.ts +2 -3
- package/dist/components/DatePickerModal/index.js +13 -21
- package/dist/components/DatePickerModal/index.js.map +1 -1
- package/dist/components/EmptyPlaceholder/components/Button.d.ts +1 -2
- package/dist/components/EmptyPlaceholder/components/Button.js +2 -2
- package/dist/components/EmptyPlaceholder/components/Button.js.map +1 -1
- package/dist/components/EmptyPlaceholder/components/Content.d.ts +1 -1
- package/dist/components/EmptyPlaceholder/components/Content.js +6 -8
- package/dist/components/EmptyPlaceholder/components/Content.js.map +1 -1
- package/dist/components/EmptyPlaceholder/components/Illustration.d.ts +1 -2
- package/dist/components/EmptyPlaceholder/components/Illustration.js +2 -5
- package/dist/components/EmptyPlaceholder/components/Illustration.js.map +1 -1
- package/dist/components/EmptyPlaceholder/components/Info.d.ts +1 -2
- package/dist/components/EmptyPlaceholder/components/Info.js +2 -5
- package/dist/components/EmptyPlaceholder/components/Info.js.map +1 -1
- package/dist/components/EmptyPlaceholder/components/Loading.d.ts +1 -2
- package/dist/components/EmptyPlaceholder/components/Loading.js +3 -4
- package/dist/components/EmptyPlaceholder/components/Loading.js.map +1 -1
- package/dist/components/EmptyPlaceholder/context.d.ts +4 -5
- package/dist/components/EmptyPlaceholder/context.js.map +1 -1
- package/dist/components/EmptyPlaceholder/index.d.ts +5 -6
- package/dist/components/EmptyPlaceholder/index.js +2 -6
- package/dist/components/EmptyPlaceholder/index.js.map +1 -1
- package/dist/components/FileInput/index.d.ts +1 -1
- package/dist/components/FileInput/index.js +1 -1
- package/dist/components/FileInput/index.js.map +1 -1
- package/dist/components/Grid/index.js +11 -10
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/Grid/types.d.ts +0 -1
- package/dist/components/Icon/index.d.ts +1 -2
- package/dist/components/Icon/index.js +3 -5
- package/dist/components/Icon/index.js.map +1 -1
- package/dist/components/Image/index.js +9 -15
- package/dist/components/Image/index.js.map +1 -1
- package/dist/components/Image/types.d.ts +1 -2
- package/dist/components/ImageView/Spotlight.d.ts +4 -4
- package/dist/components/ImageView/Spotlight.js +4 -5
- package/dist/components/ImageView/Spotlight.js.map +1 -1
- package/dist/components/ImageView/component.d.ts +1 -2
- package/dist/components/ImageView/component.js +4 -2
- package/dist/components/ImageView/component.js.map +1 -1
- package/dist/components/InputBase/index.js +3 -16
- package/dist/components/InputBase/index.js.map +1 -1
- package/dist/components/InputBase/types.d.ts +3 -4
- package/dist/components/InputBase/useInputBase.d.ts +2 -3
- package/dist/components/InputBase/useInputBase.js +1 -1
- package/dist/components/InputBase/useInputBase.js.map +1 -1
- package/dist/components/InputBase/useInputBasePartialStyles.js.map +1 -1
- package/dist/components/InputOverlay/index.d.ts +3 -4
- package/dist/components/InputOverlay/index.js +6 -21
- package/dist/components/InputOverlay/index.js.map +1 -1
- package/dist/components/InputOverlay/store.js.map +1 -1
- package/dist/components/List/index.js +5 -4
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/List/types.d.ts +0 -1
- package/dist/components/LoadingOverlay/index.d.ts +2 -3
- package/dist/components/LoadingOverlay/index.js +5 -7
- package/dist/components/LoadingOverlay/index.js.map +1 -1
- package/dist/components/Modal/index.d.ts +2 -3
- package/dist/components/Modal/index.js +13 -39
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/types.d.ts +0 -1
- package/dist/components/NumberIncrement/index.js +5 -7
- package/dist/components/NumberIncrement/index.js.map +1 -1
- package/dist/components/NumberIncrement/useNumberIncrement.d.ts +3 -4
- package/dist/components/NumberIncrement/useNumberIncrement.js.map +1 -1
- package/dist/components/Pager/PagerDots.d.ts +1 -2
- package/dist/components/Pager/PagerDots.js +3 -6
- package/dist/components/Pager/PagerDots.js.map +1 -1
- package/dist/components/Pager/PagerItem.d.ts +1 -2
- package/dist/components/Pager/PagerItem.js +3 -2
- package/dist/components/Pager/PagerItem.js.map +1 -1
- package/dist/components/Pager/index.d.ts +2 -3
- package/dist/components/Pager/index.js +9 -16
- package/dist/components/Pager/index.js.map +1 -1
- package/dist/components/Pager/types.d.ts +2 -2
- package/dist/components/PaginationIndicator/index.d.ts +2 -3
- package/dist/components/PaginationIndicator/index.js +3 -3
- package/dist/components/PaginationIndicator/index.js.map +1 -1
- package/dist/components/PaginationIndicator/types.d.ts +2 -3
- package/dist/components/PlacesAutocomplete/index.d.ts +6 -7
- package/dist/components/PlacesAutocomplete/index.js +11 -17
- package/dist/components/PlacesAutocomplete/index.js.map +1 -1
- package/dist/components/PlacesAutocomplete/types.d.ts +3 -4
- package/dist/components/RadioInput/index.d.ts +2 -3
- package/dist/components/RadioInput/index.js +4 -22
- package/dist/components/RadioInput/index.js.map +1 -1
- package/dist/components/RefreshControl/index.d.ts +2 -3
- package/dist/components/RefreshControl/index.js +2 -2
- package/dist/components/RefreshControl/index.js.map +1 -1
- package/dist/components/Scroll/index.d.ts +2 -3
- package/dist/components/Scroll/index.js +9 -12
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/SearchInput/index.d.ts +7 -4
- package/dist/components/SearchInput/index.js +4 -3
- package/dist/components/SearchInput/index.js.map +1 -1
- package/dist/components/SectionFilters/context.d.ts +3 -24
- package/dist/components/SectionFilters/index.d.ts +1 -2
- package/dist/components/SectionFilters/index.js +5 -7
- package/dist/components/SectionFilters/index.js.map +1 -1
- package/dist/components/SectionFilters/useSectionFilters.js.map +1 -1
- package/dist/components/Sections/index.d.ts +2 -3
- package/dist/components/Sections/index.js +5 -4
- package/dist/components/Sections/index.js.map +1 -1
- package/dist/components/Sections/types.d.ts +0 -1
- package/dist/components/SegmentedControl/Option.d.ts +1 -1
- package/dist/components/SegmentedControl/Option.js +7 -13
- package/dist/components/SegmentedControl/Option.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +16 -26
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/SegmentedControl/types.d.ts +2 -3
- package/dist/components/Select/index.d.ts +2 -3
- package/dist/components/Select/index.js +20 -25
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/types.d.ts +2 -3
- package/dist/components/Slider/index.d.ts +2 -3
- package/dist/components/Slider/index.js +23 -38
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/types.d.ts +0 -1
- package/dist/components/SortablePhotos/index.d.ts +2 -3
- package/dist/components/SortablePhotos/index.js +7 -18
- package/dist/components/SortablePhotos/index.js.map +1 -1
- package/dist/components/SortablePhotos/useSortablePhotos.d.ts +0 -2
- package/dist/components/SortablePhotos/useSortablePhotos.js.map +1 -1
- package/dist/components/Switch/index.d.ts +2 -3
- package/dist/components/Switch/index.js +9 -13
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Tabs/Context.d.ts +2 -3
- package/dist/components/Tabs/Context.js +2 -1
- package/dist/components/Tabs/Context.js.map +1 -1
- package/dist/components/Tabs/Panel.d.ts +1 -1
- package/dist/components/Tabs/Panel.js +3 -5
- package/dist/components/Tabs/Panel.js.map +1 -1
- package/dist/components/Tabs/Tab.d.ts +1 -2
- package/dist/components/Tabs/Tab.js +12 -16
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Tabs/TabList.d.ts +1 -2
- package/dist/components/Tabs/TabList.js +2 -1
- package/dist/components/Tabs/TabList.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +197 -192
- package/dist/components/Tabs/index.js +2 -6
- package/dist/components/Tabs/index.js.map +1 -1
- package/dist/components/Text/index.js +5 -7
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Text/types.d.ts +2 -2
- package/dist/components/TextInput/index.d.ts +2 -10
- package/dist/components/TextInput/index.js +22 -16
- package/dist/components/TextInput/index.js.map +1 -1
- package/dist/components/TextInput/types.d.ts +0 -1
- package/dist/components/TextInput/useTextInput.d.ts +2 -3
- package/dist/components/TimeInput/index.d.ts +2 -3
- package/dist/components/TimeInput/index.js +8 -12
- package/dist/components/TimeInput/index.js.map +1 -1
- package/dist/components/Touchable/index.js +5 -10
- package/dist/components/Touchable/index.js.map +1 -1
- package/dist/components/Touchable/types.d.ts +0 -1
- package/dist/components/View/index.d.ts +4 -6
- package/dist/components/View/index.js +4 -3
- package/dist/components/View/index.js.map +1 -1
- package/dist/components/View/types.d.ts +2 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/modules/PressableRipple/ripple.d.ts +2 -2
- package/dist/modules/PressableRipple/ripple.js +4 -11
- package/dist/modules/PressableRipple/ripple.js.map +1 -1
- package/dist/modules/PressableRipple/styles.d.ts +5 -5
- package/dist/modules/backgroundTimer.js.map +1 -1
- package/dist/modules/reactNavigation.js.map +1 -1
- package/dist/modules/scroll.d.ts +3 -3
- package/dist/modules/scroll.js +3 -4
- package/dist/modules/scroll.js.map +1 -1
- package/dist/modules/textInputMask.d.ts +1 -2
- package/dist/types/index.d.ts +2 -3
- package/dist/types/utility.d.ts +2 -2
- package/dist/utils/NotificationManager/index.js.map +1 -1
- package/dist/utils/OSAlert.js.map +1 -1
- package/dist/utils/StorageManager.js.map +1 -1
- package/dist/utils/Subscription.js.map +1 -1
- package/dist/utils/hooks.d.ts +3 -3
- package/dist/utils/hooks.js.map +1 -1
- package/dist/utils/input.d.ts +1 -1
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/misc.d.ts +0 -1
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/useQueryListRefresh.js.map +1 -1
- package/package.json +30 -32
- package/package.json.bak +14 -16
- package/src/components/Autocomplete/types.ts +1 -1
- package/src/components/Badge/types.ts +1 -1
- package/src/components/FileInput/index.tsx +2 -2
- package/src/components/Image/types.ts +1 -1
- package/src/components/ImageView/Spotlight.tsx +2 -2
- package/src/components/ImageView/component.tsx +1 -0
- package/src/components/InputBase/types.ts +3 -3
- package/src/components/InputBase/useInputBase.ts +1 -1
- package/src/components/Pager/PagerItem.tsx +1 -1
- package/src/components/Pager/index.tsx +1 -0
- package/src/components/Pager/types.ts +1 -1
- package/src/components/PaginationIndicator/types.ts +2 -2
- package/src/components/PlacesAutocomplete/types.ts +3 -3
- package/src/components/Scroll/index.tsx +1 -1
- package/src/components/SearchInput/index.tsx +7 -3
- package/src/components/SectionFilters/index.tsx +1 -1
- package/src/components/SegmentedControl/types.ts +2 -2
- package/src/components/Select/types.ts +2 -2
- package/src/components/Slider/index.tsx +1 -0
- package/src/components/Text/types.ts +2 -2
- package/src/components/TextInput/index.tsx +11 -3
- package/src/components/View/index.tsx +1 -1
- package/src/components/View/types.ts +2 -2
- package/src/components/components.ts +1 -1
- package/src/index.ts +0 -1
- package/src/modules/scroll.tsx +1 -1
- package/src/types/index.ts +2 -2
- package/src/types/utility.ts +2 -2
- package/src/utils/hooks.ts +3 -3
- package/dist/deprecated/index.d.ts +0 -2
- package/dist/deprecated/index.js +0 -5
- package/dist/deprecated/index.js.map +0 -1
- package/dist/deprecated/modals/Context.d.ts +0 -48
- package/dist/deprecated/modals/Context.js +0 -187
- package/dist/deprecated/modals/Context.js.map +0 -1
- package/dist/deprecated/modals/components.d.ts +0 -15
- package/dist/deprecated/modals/components.js +0 -53
- package/dist/deprecated/modals/components.js.map +0 -1
- package/dist/deprecated/modals/index.d.ts +0 -10
- package/dist/deprecated/modals/index.js +0 -9
- package/dist/deprecated/modals/index.js.map +0 -1
- package/dist/deprecated/permissions/Context.d.ts +0 -53
- package/dist/deprecated/permissions/Context.js +0 -208
- package/dist/deprecated/permissions/Context.js.map +0 -1
- package/dist/deprecated/permissions/index.d.ts +0 -5
- package/dist/deprecated/permissions/index.js +0 -4
- package/dist/deprecated/permissions/index.js.map +0 -1
- package/dist/deprecated/permissions/package/Manager.d.ts +0 -23
- package/dist/deprecated/permissions/package/Manager.js +0 -84
- package/dist/deprecated/permissions/package/Manager.js.map +0 -1
- package/dist/deprecated/permissions/package/Permission.d.ts +0 -19
- package/dist/deprecated/permissions/package/Permission.js +0 -65
- package/dist/deprecated/permissions/package/Permission.js.map +0 -1
- package/dist/deprecated/permissions/package/index.d.ts +0 -3
- package/dist/deprecated/permissions/package/index.js +0 -5
- package/dist/deprecated/permissions/package/index.js.map +0 -1
- package/dist/deprecated/permissions/package/types.d.ts +0 -31
- package/dist/deprecated/permissions/package/types.js +0 -2
- package/dist/deprecated/permissions/package/types.js.map +0 -1
- package/dist/deprecated/permissions/types.d.ts +0 -16
- package/dist/deprecated/permissions/types.js +0 -2
- package/dist/deprecated/permissions/types.js.map +0 -1
- package/mobile-packages.code-workspace +0 -27
- package/src/deprecated/index.ts +0 -2
- package/src/deprecated/modals/Context.tsx +0 -259
- package/src/deprecated/modals/components.tsx +0 -84
- package/src/deprecated/modals/index.ts +0 -13
- package/src/deprecated/permissions/Context.tsx +0 -316
- package/src/deprecated/permissions/index.ts +0 -16
- package/src/deprecated/permissions/package/Manager.ts +0 -123
- package/src/deprecated/permissions/package/Permission.ts +0 -79
- package/src/deprecated/permissions/package/index.ts +0 -3
- package/src/deprecated/permissions/package/types.ts +0 -43
- package/src/deprecated/permissions/types.ts +0 -27
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { forwardRef, useImperativeHandle } from 'react'
|
|
2
2
|
import { TypeGuards } from '@codeleap/types'
|
|
3
3
|
import { TextInput as NativeTextInput } from 'react-native'
|
|
4
4
|
import { InputBase, selectInputBaseProps } from '../InputBase'
|
|
@@ -14,7 +14,7 @@ import { useInputBasePartialStyles } from '../InputBase/useInputBasePartialStyle
|
|
|
14
14
|
export * from './styles'
|
|
15
15
|
export * from './types'
|
|
16
16
|
|
|
17
|
-
export const TextInput = (props
|
|
17
|
+
export const TextInput = forwardRef<NativeTextInput, TextInputProps>((props, ref) => {
|
|
18
18
|
const allProps = {
|
|
19
19
|
...TextInput.defaultProps,
|
|
20
20
|
...props,
|
|
@@ -63,6 +63,14 @@ export const TextInput = (props: TextInputProps) => {
|
|
|
63
63
|
handleBlur,
|
|
64
64
|
handleFocus,
|
|
65
65
|
} = useTextInput(allProps)
|
|
66
|
+
|
|
67
|
+
useImperativeHandle(ref, () => {
|
|
68
|
+
if (!innerInputRef.current) return null
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
...innerInputRef.current,
|
|
72
|
+
} as NativeTextInput
|
|
73
|
+
})
|
|
66
74
|
|
|
67
75
|
const InputElement = masking ? MaskedTextInput : NativeTextInput
|
|
68
76
|
|
|
@@ -154,7 +162,7 @@ export const TextInput = (props: TextInputProps) => {
|
|
|
154
162
|
{...maskingExtraProps}
|
|
155
163
|
/>
|
|
156
164
|
</InputBase>
|
|
157
|
-
}
|
|
165
|
+
}) as StyledComponentWithProps<TextInputProps>
|
|
158
166
|
|
|
159
167
|
TextInput.styleRegistryName = 'TextInput'
|
|
160
168
|
TextInput.elements = [...InputBase.elements, 'input', 'placeholder', 'selection']
|
|
@@ -32,7 +32,7 @@ export const View = forwardRef<RNView, ViewProps>((props, ref) => {
|
|
|
32
32
|
ref={ref}
|
|
33
33
|
/>
|
|
34
34
|
)
|
|
35
|
-
}) as StyledComponentWithProps<ViewProps> & { Animated?: (props: ViewAnimatedProps) =>
|
|
35
|
+
}) as StyledComponentWithProps<ViewProps> & { Animated?: (props: ViewAnimatedProps) => React.ReactElement }
|
|
36
36
|
|
|
37
37
|
View.Animated = (props: ViewAnimatedProps) => {
|
|
38
38
|
return <View {...props} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyledProp } from '@codeleap/styles'
|
|
2
2
|
import { ImageStyle, TextStyle, ViewProps as RNViewProps, ViewStyle } from 'react-native'
|
|
3
|
-
import Animated, {
|
|
3
|
+
import Animated, { AnimatedStyle } from 'react-native-reanimated'
|
|
4
4
|
import { ViewComposition } from './styles'
|
|
5
5
|
import { PropsOf } from '@codeleap/types'
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ export type ViewProps = Omit<RNViewProps, 'style'> & {
|
|
|
8
8
|
style?: StyledProp<ViewComposition>
|
|
9
9
|
animated?: boolean
|
|
10
10
|
children?: React.ReactNode
|
|
11
|
-
animatedStyle?:
|
|
11
|
+
animatedStyle?: AnimatedStyle<ViewStyle | ImageStyle | TextStyle>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export type ViewAnimatedProps = ViewProps & Omit<PropsOf<typeof Animated.View>, 'style'>
|
package/src/index.ts
CHANGED
package/src/modules/scroll.tsx
CHANGED
|
@@ -38,7 +38,7 @@ const ScrollContext = React.createContext({} as ScrollContextValue)
|
|
|
38
38
|
export const useScrollPubSub = (ref: MutableRefObject<Omit<Scrollable,'subscribe'>>) => {
|
|
39
39
|
const listeners = useRef(new Map())
|
|
40
40
|
|
|
41
|
-
const augmentedRef = useRef<Scrollable>()
|
|
41
|
+
const augmentedRef = useRef<Scrollable>(null)
|
|
42
42
|
|
|
43
43
|
const emit = useCallback((event: keyof ScrollEvents, e: NativeSyntheticEvent<NativeScrollEvent>) => {
|
|
44
44
|
listeners.current.forEach((cb, key) => {
|
package/src/types/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './utility'
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export type ComponentWithDefaultProps<P = any> = ((props: P) =>
|
|
4
|
+
export type ComponentWithDefaultProps<P = any> = ((props: P) => React.ReactElement) & {
|
|
5
5
|
defaultProps: Partial<P>
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export type ForwardRefComponentWithDefaultProps<P = any, R = any> = ((props: P, ref: R) =>
|
|
8
|
+
export type ForwardRefComponentWithDefaultProps<P = any, R = any> = ((props: P, ref: R) => React.ReactElement) & {
|
|
9
9
|
defaultProps?: Partial<P>
|
|
10
10
|
}
|
package/src/types/utility.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react'
|
|
2
2
|
import { StyleProp } from 'react-native'
|
|
3
|
-
import {
|
|
3
|
+
import { EasingFunction, EntryAnimationsValues, ExitAnimationsValues, LayoutAnimation, StyleProps } from 'react-native-reanimated'
|
|
4
4
|
|
|
5
5
|
export type StylesOf<C extends string> = Partial<Record<C, StyleProp<any>>>
|
|
6
6
|
type TransitionBase = {
|
|
7
|
-
easing?:
|
|
7
|
+
easing?: EasingFunction
|
|
8
8
|
type?: string
|
|
9
9
|
duration?: number
|
|
10
10
|
}
|
package/src/utils/hooks.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { onUpdate, usePrevious, useRef, useState } from '@codeleap/hooks'
|
|
|
2
2
|
import { shadeColor } from '@codeleap/utils'
|
|
3
3
|
import { TypeGuards } from '@codeleap/types'
|
|
4
4
|
import { Animated, Platform, BackHandler, ViewStyle, ImageStyle, TextStyle, StyleSheet, StyleProp } from 'react-native'
|
|
5
|
-
import {
|
|
5
|
+
import { AnimatedStyle, Easing, EasingFunction, useAnimatedStyle, withTiming } from 'react-native-reanimated'
|
|
6
6
|
import { PressableRippleProps } from '../modules/PressableRipple/type'
|
|
7
7
|
import { useMemo } from 'react'
|
|
8
8
|
import { mergeStyles } from '@codeleap/styles'
|
|
@@ -62,7 +62,7 @@ type AnimatableProperties = 'scale' | 'scaleX' | 'scaleY' | 'translateX' | 'tran
|
|
|
62
62
|
type VariantTransitionConfig = {
|
|
63
63
|
type: 'timing'
|
|
64
64
|
duration?: number
|
|
65
|
-
easing?:
|
|
65
|
+
easing?: EasingFunction
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export type TransitionConfig = Partial<Record<AnimatableProperties, VariantTransitionConfig>> | VariantTransitionConfig
|
|
@@ -70,7 +70,7 @@ export type TransitionConfig = Partial<Record<AnimatableProperties, VariantTrans
|
|
|
70
70
|
type UseAnimatedVariantStylesConfig<T extends Record<string|number|symbol, any>, K extends keyof T > = {
|
|
71
71
|
variantStyles: T
|
|
72
72
|
animatedProperties: K[]
|
|
73
|
-
updater: (states: SelectProperties<T, K>) =>
|
|
73
|
+
updater: (states: SelectProperties<T, K>) => AnimatedStyle<ViewStyle | ImageStyle | TextStyle>
|
|
74
74
|
transition?: TransitionConfig
|
|
75
75
|
dependencies?: any[]
|
|
76
76
|
}
|
package/dist/deprecated/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/deprecated/index.ts"],"names":[],"mappings":"+BAA6B,eAAe;0BAAhC,WAAW;0BACC,eAAe;qBAA3B,MAAM"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { AnyFunction } from '@codeleap/types';
|
|
3
|
-
export type AppModalProps = {
|
|
4
|
-
visible: boolean;
|
|
5
|
-
attachments: string[];
|
|
6
|
-
attachedTo: string[];
|
|
7
|
-
props?: any;
|
|
8
|
-
};
|
|
9
|
-
type TModalState = AppModalProps;
|
|
10
|
-
type ModalTransitionOptions = {
|
|
11
|
-
duration?: number;
|
|
12
|
-
props?: any;
|
|
13
|
-
};
|
|
14
|
-
type TModalContext = {
|
|
15
|
-
state: Record<string, TModalState>;
|
|
16
|
-
toggleModal: (name: string, setTo?: boolean, props?: any) => void;
|
|
17
|
-
setModal: (name: string, to: Partial<TModalState>) => void;
|
|
18
|
-
currentModal: string;
|
|
19
|
-
isVisible: (name: string) => boolean;
|
|
20
|
-
transition: (from: string, to: string, options?: ModalTransitionOptions) => Promise<void>;
|
|
21
|
-
attach: (modal: string, to: string) => void;
|
|
22
|
-
remove(name: string): void;
|
|
23
|
-
transitionDuration: number;
|
|
24
|
-
};
|
|
25
|
-
export declare function Provider({ children }: {
|
|
26
|
-
children: any;
|
|
27
|
-
}): JSX.Element;
|
|
28
|
-
export declare function useModalContext(): TModalContext;
|
|
29
|
-
export type UseModalSequenceOptions = {
|
|
30
|
-
onFinish?: AnyFunction;
|
|
31
|
-
resetOnFinish?: boolean;
|
|
32
|
-
closeLastOnFinish?: boolean;
|
|
33
|
-
waitForLastToCloseBeforeCallingFinish?: boolean;
|
|
34
|
-
transitionOpts?: Partial<Parameters<TModalContext['transition']>[2]>;
|
|
35
|
-
autoOpen?: boolean;
|
|
36
|
-
};
|
|
37
|
-
export declare function useModalSequence(ids: string[], options?: UseModalSequenceOptions): {
|
|
38
|
-
currentId: string;
|
|
39
|
-
nextId: string;
|
|
40
|
-
previousId: string;
|
|
41
|
-
reset: () => void;
|
|
42
|
-
next: (props?: any) => void;
|
|
43
|
-
previous: (props?: any) => void;
|
|
44
|
-
setModal: React.Dispatch<React.SetStateAction<number>>;
|
|
45
|
-
goto: (idxOrId: string | number, props?: any) => void;
|
|
46
|
-
currentIdx: number;
|
|
47
|
-
};
|
|
48
|
-
export {};
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TypeGuards } from '@codeleap/types';
|
|
3
|
-
import { onUpdate, useState } from '@codeleap/hooks';
|
|
4
|
-
import { PortalProvider } from '@gorhom/portal';
|
|
5
|
-
const ModalContext = React.createContext({});
|
|
6
|
-
export function Provider({ children }) {
|
|
7
|
-
const [modals, setModals] = useState({});
|
|
8
|
-
const currentModal = Object.keys(modals).find(name => modals[name].visible);
|
|
9
|
-
function isVisible(name) {
|
|
10
|
-
return !!modals[name]?.visible;
|
|
11
|
-
}
|
|
12
|
-
const toggleModal = (name, set, props) => {
|
|
13
|
-
const visible = isVisible(name);
|
|
14
|
-
const newVisible = typeof set === 'boolean' ? set : !visible;
|
|
15
|
-
setModals((current) => {
|
|
16
|
-
const attached = newVisible ? [] : current[name]?.attachments?.map?.(m => [m, { ...current[m], visible: false }]);
|
|
17
|
-
return {
|
|
18
|
-
...current,
|
|
19
|
-
[name]: {
|
|
20
|
-
...current[name],
|
|
21
|
-
visible: newVisible,
|
|
22
|
-
props,
|
|
23
|
-
},
|
|
24
|
-
...Object.fromEntries(attached ?? []),
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
const setModal = (name, to) => {
|
|
29
|
-
setModals((current) => ({
|
|
30
|
-
...current,
|
|
31
|
-
[name]: {
|
|
32
|
-
...current[name],
|
|
33
|
-
...to,
|
|
34
|
-
},
|
|
35
|
-
}));
|
|
36
|
-
};
|
|
37
|
-
// const codeleapCtx = useCodeleapContext()
|
|
38
|
-
const defaultDuration = 300;
|
|
39
|
-
const transition = (from, to, options) => {
|
|
40
|
-
return new Promise((resolve) => {
|
|
41
|
-
setTimeout(() => {
|
|
42
|
-
if (!from) {
|
|
43
|
-
toggleModal(to, true, options?.props);
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const _options = {
|
|
47
|
-
duration: defaultDuration,
|
|
48
|
-
...options,
|
|
49
|
-
};
|
|
50
|
-
const toVisible = isVisible(to);
|
|
51
|
-
const fromVisible = isVisible(from);
|
|
52
|
-
// if (!fromVisible && !toVisible) {
|
|
53
|
-
// toggleModal(to, true, options?.props)
|
|
54
|
-
// return
|
|
55
|
-
// }
|
|
56
|
-
toggleModal(from, false);
|
|
57
|
-
setTimeout(() => {
|
|
58
|
-
toggleModal(to, true, options?.props);
|
|
59
|
-
resolve();
|
|
60
|
-
}, _options.duration);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
function attach(modal, to) {
|
|
65
|
-
setModals((modals) => {
|
|
66
|
-
const toModal = modals[to];
|
|
67
|
-
const _modal = modals[modal];
|
|
68
|
-
if (!toModal || !_modal)
|
|
69
|
-
return modals;
|
|
70
|
-
const isAttached = toModal.attachments.includes(modal) || _modal.attachedTo.includes(to);
|
|
71
|
-
const newVal = { ...modals };
|
|
72
|
-
if (isAttached) {
|
|
73
|
-
newVal[to].attachments = newVal[to].attachments.filter(x => x !== modal);
|
|
74
|
-
newVal[modal].attachedTo = newVal[modal].attachedTo.filter(x => x !== to);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
newVal[to].attachments.push(modal);
|
|
78
|
-
newVal[modal].attachedTo.push(to);
|
|
79
|
-
}
|
|
80
|
-
return newVal;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function remove(id) {
|
|
84
|
-
const newModals = { ...modals };
|
|
85
|
-
delete newModals[id];
|
|
86
|
-
setModals(newModals);
|
|
87
|
-
}
|
|
88
|
-
return (<ModalContext.Provider value={{
|
|
89
|
-
state: modals,
|
|
90
|
-
toggleModal,
|
|
91
|
-
setModal,
|
|
92
|
-
currentModal,
|
|
93
|
-
attach,
|
|
94
|
-
isVisible,
|
|
95
|
-
remove,
|
|
96
|
-
transition,
|
|
97
|
-
transitionDuration: defaultDuration,
|
|
98
|
-
}}>
|
|
99
|
-
<PortalProvider>
|
|
100
|
-
|
|
101
|
-
{children}
|
|
102
|
-
</PortalProvider>
|
|
103
|
-
</ModalContext.Provider>);
|
|
104
|
-
}
|
|
105
|
-
export function useModalContext() {
|
|
106
|
-
const context = React.useContext(ModalContext);
|
|
107
|
-
return context;
|
|
108
|
-
}
|
|
109
|
-
export function useModalSequence(ids, options) {
|
|
110
|
-
const _options = {
|
|
111
|
-
closeLastOnFinish: true,
|
|
112
|
-
onFinish: () => { },
|
|
113
|
-
resetOnFinish: false,
|
|
114
|
-
waitForLastToCloseBeforeCallingFinish: true,
|
|
115
|
-
...options,
|
|
116
|
-
};
|
|
117
|
-
const modals = useModalContext();
|
|
118
|
-
const [idx, setIdx] = useState(0);
|
|
119
|
-
const state = {
|
|
120
|
-
currentId: ids[idx],
|
|
121
|
-
nextId: ids[idx + 1],
|
|
122
|
-
previousId: ids[idx - 1],
|
|
123
|
-
};
|
|
124
|
-
onUpdate(() => {
|
|
125
|
-
if (_options.autoOpen && typeof ids?.[0] === 'number') {
|
|
126
|
-
if (!modals.isVisible(ids[0])) {
|
|
127
|
-
modals.toggleModal(ids[0]);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [_options.autoOpen, ids?.[0]]);
|
|
131
|
-
function next(props) {
|
|
132
|
-
if (idx === ids.length - 1) {
|
|
133
|
-
if (_options.closeLastOnFinish) {
|
|
134
|
-
modals.transition(ids[idx], null).then(() => {
|
|
135
|
-
if (_options.waitForLastToCloseBeforeCallingFinish) {
|
|
136
|
-
_options.onFinish();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (_options.resetOnFinish) {
|
|
141
|
-
reset();
|
|
142
|
-
}
|
|
143
|
-
if (!(_options.waitForLastToCloseBeforeCallingFinish && _options.closeLastOnFinish)) {
|
|
144
|
-
_options.onFinish();
|
|
145
|
-
}
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
if (!state.nextId)
|
|
150
|
-
return;
|
|
151
|
-
modals.transition(ids[idx], state.nextId, props);
|
|
152
|
-
setIdx(i => i + 1);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
function previous(props) {
|
|
156
|
-
if (!state.previousId)
|
|
157
|
-
return;
|
|
158
|
-
modals.transition(ids[idx], state.previousId, props);
|
|
159
|
-
setIdx(i => i - 1);
|
|
160
|
-
}
|
|
161
|
-
function goto(idxOrId, props) {
|
|
162
|
-
let newId = null;
|
|
163
|
-
if (TypeGuards.isString(idxOrId)) {
|
|
164
|
-
newId = idxOrId;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
newId = ids[idxOrId];
|
|
168
|
-
}
|
|
169
|
-
modals.transition(ids[idx], newId, {
|
|
170
|
-
props,
|
|
171
|
-
});
|
|
172
|
-
setIdx(ids.indexOf(newId));
|
|
173
|
-
}
|
|
174
|
-
function reset() {
|
|
175
|
-
setIdx(0);
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
reset,
|
|
179
|
-
next,
|
|
180
|
-
previous,
|
|
181
|
-
setModal: setIdx,
|
|
182
|
-
goto,
|
|
183
|
-
currentIdx: idx,
|
|
184
|
-
...state,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=Context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../src/deprecated/modals/Context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AA0B/C,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,EAAmB,CAAC,CAAA;AAE7D,MAAM,UAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE;IACnC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAyB,EAAE,CAAC,CAAA;IAChE,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAA;IAE3E,SAAS,SAAS,CAAC,IAAY;QAC7B,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IAChC,CAAC;IAED,MAAM,WAAW,GAAiC,CAAC,IAAI,EAAE,GAAa,EAAE,KAAW,EAAE,EAAE;QACrF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C"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PropsOf } from '@codeleap/types';
|
|
3
|
-
import { Modal as _Modal } from '../../components/Modal';
|
|
4
|
-
type UseManagedModalArgs = {
|
|
5
|
-
id?: string;
|
|
6
|
-
initialVisible?: boolean;
|
|
7
|
-
parent?: string;
|
|
8
|
-
visible?: boolean;
|
|
9
|
-
toggle?: PropsOf<typeof _Modal>['toggle'];
|
|
10
|
-
};
|
|
11
|
-
export type ManagedModalProps<T = PropsOf<typeof _Modal>> = Omit<T, 'visible' | 'toggle'> & UseManagedModalArgs & {
|
|
12
|
-
absolute?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare const Modal: React.FC<ManagedModalProps>;
|
|
15
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { usePrevious, onMount, onUpdate } from '@codeleap/hooks';
|
|
3
|
-
import { useModalContext } from './Context';
|
|
4
|
-
import { Portal } from '@gorhom/portal';
|
|
5
|
-
import { Modal as _Modal } from '../../components/Modal';
|
|
6
|
-
function useManagedModal(props) {
|
|
7
|
-
const { initialVisible = false, parent, id, } = props;
|
|
8
|
-
const modalId = id;
|
|
9
|
-
const modals = useModalContext();
|
|
10
|
-
onMount(() => {
|
|
11
|
-
if (!modalId)
|
|
12
|
-
return;
|
|
13
|
-
modals.setModal(modalId, {
|
|
14
|
-
attachedTo: [],
|
|
15
|
-
attachments: [],
|
|
16
|
-
visible: initialVisible,
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
const prevParent = usePrevious(parent);
|
|
20
|
-
onUpdate(() => {
|
|
21
|
-
if (!modalId)
|
|
22
|
-
return;
|
|
23
|
-
if (!!parent || !!prevParent) {
|
|
24
|
-
modals.attach(modalId, parent);
|
|
25
|
-
}
|
|
26
|
-
}, [parent]);
|
|
27
|
-
const visible = modalId ? modals.isVisible(modalId) : props.visible;
|
|
28
|
-
const ctxProps = modals?.state?.[modalId]?.props;
|
|
29
|
-
const componentProps = {
|
|
30
|
-
...props, ...ctxProps, visible: visible, toggle: () => {
|
|
31
|
-
if (modalId) {
|
|
32
|
-
modals.toggleModal(modalId);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
props?.toggle?.();
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
return componentProps;
|
|
40
|
-
}
|
|
41
|
-
export const Modal = ({ children, absolute = true, ...props }) => {
|
|
42
|
-
const componentProps = useManagedModal(props);
|
|
43
|
-
const content = (<_Modal {...componentProps}>
|
|
44
|
-
{children}
|
|
45
|
-
</_Modal>);
|
|
46
|
-
if (absolute) {
|
|
47
|
-
return <Portal>
|
|
48
|
-
{content}
|
|
49
|
-
</Portal>;
|
|
50
|
-
}
|
|
51
|
-
return content;
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=components.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/deprecated/modals/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAUxD,SAAS,eAAe,CAAC,KAA0B;IACjD,MAAM,EACJ,cAAc,GAAG,KAAK,EACtB,MAAM,EACN,EAAE,GACH,GAAG,KAAK,CAAA;IACT,MAAM,OAAO,GAAG,EAAE,CAAA;IAClB,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;IAEhC,OAAO,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,OAAO;YAAE,OAAM;QACpB,MAAM,CAAC,QAAQ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,CAAC,CACV,CAAA;IAED,IAAI,QAAQ,EAAE;QACZ,OAAO,CAAC,MAAM,CACZ;MAAA,CAAC,OAAO,CACV;IAAA,EAAE,MAAM,CAAC,CAAA;KACV;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { useModalContext, useModalSequence, Provider } from './Context';
|
|
3
|
-
import { ManagedModalProps } from './components';
|
|
4
|
-
export declare const ModalManager: {
|
|
5
|
-
useModalContext: typeof useModalContext;
|
|
6
|
-
Modal: import("react").FC<ManagedModalProps<Omit<import("../..").ModalProps, "">>>;
|
|
7
|
-
Provider: typeof Provider;
|
|
8
|
-
useModalSequence: typeof useModalSequence;
|
|
9
|
-
};
|
|
10
|
-
export type { ManagedModalProps, };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/deprecated/modals/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACvE,OAAO,EAAE,KAAK,EAAqB,MAAM,cAAc,CAAA;AAEvD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,eAAe;IACf,KAAK;IACL,QAAQ;IACR,gBAAgB;CACjB,CAAA"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PermissionConfig, PermissionModalsConfig } from './types';
|
|
3
|
-
import { PermissionManager, PermissionTypes } from './package';
|
|
4
|
-
type TPermissionContext = {
|
|
5
|
-
state: Record<string, PermissionTypes.PermissionStatus>;
|
|
6
|
-
modalConfig: PermissionModalsConfig<any>;
|
|
7
|
-
manager: PermissionManager<any, any>;
|
|
8
|
-
setState: (forPermission: string, status: PermissionTypes.PermissionState) => void;
|
|
9
|
-
};
|
|
10
|
-
type PermissionProviderProps = {
|
|
11
|
-
children: React.ReactElement;
|
|
12
|
-
AppPermissions: PermissionManager<any, any>;
|
|
13
|
-
modalConfig: PermissionModalsConfig<any>;
|
|
14
|
-
};
|
|
15
|
-
export declare function Provider({ children, AppPermissions, modalConfig }: PermissionProviderProps): JSX.Element;
|
|
16
|
-
type TAskManyResults<T extends string> = Record<T, PermissionTypes.PermissionStatus> & {
|
|
17
|
-
overall: PermissionTypes.PermissionStatus;
|
|
18
|
-
};
|
|
19
|
-
type AskManyOpts<T extends string | number | symbol> = {
|
|
20
|
-
breakOnDenied?: T[];
|
|
21
|
-
};
|
|
22
|
-
export type UsePermissions<_PermissionNames extends string, PermissionNames extends string = `${_PermissionNames}?` | _PermissionNames> = () => TPermissionContext & {
|
|
23
|
-
askPermission: (name: PermissionNames, onResolve?: (status: PermissionTypes.PermissionStatus) => any) => Promise<PermissionTypes.PermissionStatus>;
|
|
24
|
-
askMany<T extends PermissionNames, R = TAskManyResults<T>>(perms: T[], onResolve?: (res: R) => any, options?: AskManyOpts<T>): Promise<R>;
|
|
25
|
-
};
|
|
26
|
-
export declare const usePermissions: UsePermissions<any>;
|
|
27
|
-
export declare function usePermissionModal(permissionName: string): {
|
|
28
|
-
onAllow: () => Promise<void>;
|
|
29
|
-
onDeny: () => void;
|
|
30
|
-
modalId: string;
|
|
31
|
-
permissionName: string;
|
|
32
|
-
modalState: {
|
|
33
|
-
visible: boolean;
|
|
34
|
-
attachments: string[];
|
|
35
|
-
attachedTo: string[];
|
|
36
|
-
props?: any;
|
|
37
|
-
};
|
|
38
|
-
currentState: "pending" | "unavailable" | "denied" | "limited" | "granted" | "blocked";
|
|
39
|
-
config: PermissionConfig;
|
|
40
|
-
};
|
|
41
|
-
type PermissionManagerArgTypes<M extends PermissionManager<any, any>> = {
|
|
42
|
-
perms: M extends PermissionManager<infer P, any> ? P extends Record<string, any> ? P : never : never;
|
|
43
|
-
opts: M extends PermissionManager<any, infer O> ? O : never;
|
|
44
|
-
};
|
|
45
|
-
type CreateTypedPermissionHooksArgs<M extends PermissionManager<any, any>, Args extends PermissionManagerArgTypes<M> = PermissionManagerArgTypes<M>, ModalConfig extends PermissionModalsConfig<keyof Args['perms']> = PermissionModalsConfig<keyof Args['perms']>> = {
|
|
46
|
-
modalConfig: ModalConfig;
|
|
47
|
-
permissionsManager: M;
|
|
48
|
-
};
|
|
49
|
-
export declare function createTypedPermissionHooks<M extends PermissionManager<any, any>, Args extends PermissionManagerArgTypes<M> = PermissionManagerArgTypes<M>>(configuration: CreateTypedPermissionHooksArgs<M>): {
|
|
50
|
-
usePermissions: UsePermissions<Exclude<keyof Args["perms"], number | symbol>, Exclude<keyof Args["perms"], number | symbol> | `${Exclude<keyof Args["perms"], number | symbol>}?`>;
|
|
51
|
-
usePermissionModal: (name: keyof Args['perms']) => ReturnType<typeof usePermissionModal>;
|
|
52
|
-
};
|
|
53
|
-
export {};
|