@codeleap/mobile 3.25.0 → 3.25.3

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 (131) hide show
  1. package/package.json +4 -6
  2. package/src/components/ActionIcon/index.tsx +37 -55
  3. package/src/components/ActionIcon/styles.ts +4 -2
  4. package/src/components/ActivityIndicator/index.tsx +64 -42
  5. package/src/components/ActivityIndicator/styles.ts +10 -1
  6. package/src/components/Autocomplete/index.tsx +54 -46
  7. package/src/components/Autocomplete/styles.ts +5 -2
  8. package/src/components/Autocomplete/types.ts +23 -13
  9. package/src/components/Avatar/index.tsx +71 -59
  10. package/src/components/Avatar/styles.ts +9 -1
  11. package/src/components/AvatarGroup/index.tsx +44 -30
  12. package/src/components/AvatarGroup/styles.ts +6 -0
  13. package/src/components/Backdrop/index.tsx +34 -51
  14. package/src/components/Backdrop/styles.ts +10 -5
  15. package/src/components/Badge/index.tsx +62 -36
  16. package/src/components/Badge/styles.ts +11 -3
  17. package/src/components/Button/index.tsx +82 -55
  18. package/src/components/Button/styles.ts +14 -13
  19. package/src/components/Calendar/index.tsx +29 -35
  20. package/src/components/Calendar/style.ts +6 -0
  21. package/src/components/Checkbox/index.tsx +64 -43
  22. package/src/components/Checkbox/styles.ts +6 -1
  23. package/src/components/ContentView/index.tsx +63 -0
  24. package/src/components/ContentView/styles.ts +8 -0
  25. package/src/components/DatePickerModal/index.tsx +65 -50
  26. package/src/components/DatePickerModal/styles.ts +10 -9
  27. package/src/components/DatePickerModal/types.ts +54 -36
  28. package/src/components/Drawer/index.tsx +28 -0
  29. package/src/components/Drawer/styles.ts +8 -0
  30. package/src/components/EmptyPlaceholder/index.tsx +63 -40
  31. package/src/components/EmptyPlaceholder/styles.ts +5 -0
  32. package/src/components/FileInput/index.tsx +49 -11
  33. package/src/components/FileInput/styles.ts +8 -0
  34. package/src/components/Grid/index.tsx +116 -84
  35. package/src/components/Grid/styles.ts +5 -0
  36. package/src/components/Icon/index.tsx +79 -44
  37. package/src/components/Icon/styles.ts +6 -0
  38. package/src/components/Image/index.tsx +78 -58
  39. package/src/components/Image/styles.ts +6 -1
  40. package/src/components/ImageView/Spotlight.tsx +4 -1
  41. package/src/components/ImageView/component.tsx +2 -1
  42. package/src/components/InputBase/index.tsx +24 -33
  43. package/src/components/InputBase/styles.ts +75 -66
  44. package/src/components/InputBase/types.ts +4 -3
  45. package/src/components/InputBase/utils.ts +4 -6
  46. package/src/components/InputLabel/index.tsx +38 -0
  47. package/src/components/InputLabel/styles.ts +7 -0
  48. package/src/components/List/PaginationIndicator.tsx +54 -0
  49. package/src/components/List/index.tsx +151 -99
  50. package/src/components/List/styles.ts +6 -0
  51. package/src/components/LoadingOverlay/index.tsx +29 -42
  52. package/src/components/LoadingOverlay/styles.ts +7 -7
  53. package/src/components/Modal/index.tsx +127 -80
  54. package/src/components/Modal/styles.ts +8 -0
  55. package/src/components/Navigation/Navigation.tsx +0 -1
  56. package/src/components/Navigation/types.ts +9 -2
  57. package/src/components/NumberIncrement/index.tsx +60 -50
  58. package/src/components/NumberIncrement/styles.ts +5 -0
  59. package/src/components/NumberIncrement/types.ts +39 -32
  60. package/src/components/Pager/index.tsx +94 -42
  61. package/src/components/Pager/styles.ts +13 -1
  62. package/src/components/RadioInput/index.tsx +57 -32
  63. package/src/components/RadioInput/styles.ts +7 -5
  64. package/src/components/RefreshControl/index.tsx +19 -39
  65. package/src/components/RefreshControl/styles.ts +6 -1
  66. package/src/components/Scroll/index.tsx +105 -89
  67. package/src/components/Scroll/styles.ts +5 -0
  68. package/src/components/Sections/index.tsx +161 -111
  69. package/src/components/Sections/styles.ts +5 -0
  70. package/src/components/SegmentedControl/Option.tsx +31 -46
  71. package/src/components/SegmentedControl/index.tsx +121 -86
  72. package/src/components/SegmentedControl/styles.ts +22 -15
  73. package/src/components/Select/index.tsx +82 -71
  74. package/src/components/Select/styles.ts +5 -3
  75. package/src/components/Select/types.ts +25 -20
  76. package/src/components/Slider/index.tsx +43 -58
  77. package/src/components/Slider/styles.ts +6 -15
  78. package/src/components/Slider/types.ts +14 -9
  79. package/src/components/Switch/index.tsx +56 -43
  80. package/src/components/Switch/styles.ts +7 -1
  81. package/src/components/Text/index.tsx +52 -56
  82. package/src/components/Text/styles.ts +7 -1
  83. package/src/components/TextInput/index.tsx +162 -49
  84. package/src/components/TextInput/styles.ts +8 -2
  85. package/src/components/Touchable/index.tsx +87 -44
  86. package/src/components/Touchable/styles.ts +9 -0
  87. package/src/components/View/index.tsx +92 -23
  88. package/src/components/View/styles.ts +6 -0
  89. package/src/components/components.ts +6 -2
  90. package/src/components/defaultStyles.ts +77 -0
  91. package/src/index.ts +0 -2
  92. package/src/modules/PressableRipple/type.ts +0 -1
  93. package/src/utils/KeyboardAware/context.tsx +2 -0
  94. package/src/utils/KeyboardAware/keyboardHooks.ts +2 -1
  95. package/src/utils/ModalManager/components.tsx +30 -1
  96. package/src/utils/ModalManager/context.tsx +4 -4
  97. package/src/utils/ModalManager/index.ts +4 -1
  98. package/src/utils/hooks.ts +1 -12
  99. package/src/Registry.ts +0 -52
  100. package/src/components/ActionIcon/types.ts +0 -15
  101. package/src/components/ActivityIndicator/types.ts +0 -9
  102. package/src/components/Avatar/types.ts +0 -23
  103. package/src/components/AvatarGroup/types.ts +0 -10
  104. package/src/components/Backdrop/types.ts +0 -14
  105. package/src/components/Badge/types.ts +0 -27
  106. package/src/components/Button/types.ts +0 -20
  107. package/src/components/Checkbox/types.ts +0 -13
  108. package/src/components/EmptyPlaceholder/types.ts +0 -21
  109. package/src/components/FileInput/types.ts +0 -27
  110. package/src/components/Grid/types.ts +0 -20
  111. package/src/components/Icon/types.ts +0 -15
  112. package/src/components/Image/types.ts +0 -18
  113. package/src/components/List/types.ts +0 -41
  114. package/src/components/LoadingOverlay/types.ts +0 -9
  115. package/src/components/Modal/types.ts +0 -41
  116. package/src/components/Pager/types.ts +0 -37
  117. package/src/components/PaginationIndicator/index.tsx +0 -51
  118. package/src/components/PaginationIndicator/styles.ts +0 -3
  119. package/src/components/PaginationIndicator/types.ts +0 -10
  120. package/src/components/RadioInput/types.ts +0 -31
  121. package/src/components/RefreshControl/types.ts +0 -9
  122. package/src/components/Scroll/types.ts +0 -21
  123. package/src/components/SearchInput/index.tsx +0 -90
  124. package/src/components/Sections/types.ts +0 -39
  125. package/src/components/SegmentedControl/types.ts +0 -31
  126. package/src/components/Switch/types.ts +0 -12
  127. package/src/components/Text/types.ts +0 -18
  128. package/src/components/TextInput/types.ts +0 -23
  129. package/src/components/Touchable/types.ts +0 -27
  130. package/src/components/View/types.ts +0 -13
  131. package/src/hooks/index.ts +0 -13
@@ -0,0 +1,54 @@
1
+ import React from 'react'
2
+ import {
3
+ ComponentVariants,
4
+ createDefaultVariantFactory,
5
+ getNestedStylesByKey,
6
+ includePresets,
7
+ TypeGuards,
8
+ useDefaultComponentStyle,
9
+ } from '@codeleap/common'
10
+ import { StyleSheet, ViewStyle } from 'react-native'
11
+ import { StylesOf } from '../../types'
12
+ import { ActivityIndicator, ActivityIndicatorComposition } from '../ActivityIndicator'
13
+ import { Text } from '../Text'
14
+
15
+ export type PaginationIndicatorComposition = 'text' | `loader${Capitalize<ActivityIndicatorComposition>}`
16
+
17
+ const createPaginationIndicatorStyle = createDefaultVariantFactory<PaginationIndicatorComposition>()
18
+
19
+ export const PaginationIndicatorPresets = includePresets((style) => createPaginationIndicatorStyle(() => ({ loaderWrapper: style, text: style })))
20
+
21
+ export type PaginationIndicatorProps = {
22
+ isFetching?: boolean
23
+ noMoreItemsText: React.ReactChild
24
+ hasMore?: boolean
25
+ activityIndicator?: JSX.Element
26
+ styles?: StylesOf<PaginationIndicatorComposition>
27
+ style?: ViewStyle
28
+ } & ComponentVariants<typeof PaginationIndicatorPresets>
29
+
30
+ export const PaginationIndicator = (props: PaginationIndicatorProps) => {
31
+ const { hasMore, isFetching, noMoreItemsText, style, activityIndicator, styles = {}, variants = [] } = props
32
+
33
+ const variantStyles = useDefaultComponentStyle<
34
+ 'u:PaginationIndicator',
35
+ typeof PaginationIndicatorPresets
36
+ >('u:PaginationIndicator', {
37
+ variants,
38
+ styles,
39
+ transform: StyleSheet.flatten,
40
+ })
41
+
42
+ const loaderStyles = getNestedStylesByKey('loader', variantStyles)
43
+
44
+ if (isFetching) {
45
+ return activityIndicator || <ActivityIndicator style={style} styles={loaderStyles}/>
46
+ }
47
+ if (!hasMore) {
48
+ if (TypeGuards.isString(noMoreItemsText) || TypeGuards.isNumber(noMoreItemsText)) {
49
+ return <Text style={[variantStyles.text, style]} text={noMoreItemsText.toString()}/>
50
+ }
51
+ return noMoreItemsText
52
+ }
53
+ return null
54
+ }
@@ -1,119 +1,171 @@
1
- import React, { forwardRef } from 'react'
2
- import { useCallback, TypeGuards } from '@codeleap/common'
3
- import { ListRenderItemInfo, FlatList } from 'react-native'
1
+ import * as React from 'react'
2
+ import { forwardRef } from 'react'
3
+ import {
4
+ useDefaultComponentStyle,
5
+ ComponentVariants,
6
+ useCallback,
7
+ TypeGuards,
8
+ } from '@codeleap/common'
9
+
10
+ import { FlatListProps as RNFlatListProps, ListRenderItemInfo, StyleSheet, FlatList } from 'react-native'
4
11
  import { View, ViewProps } from '../View'
5
- import { EmptyPlaceholder } from '../EmptyPlaceholder'
6
- import { RefreshControl } from '../RefreshControl'
12
+ import { EmptyPlaceholder, EmptyPlaceholderProps } from '../EmptyPlaceholder'
13
+ import { RefreshControl, RefreshControlProps } from '../RefreshControl'
14
+ import { ListComposition, ListPresets } from './styles'
15
+ import { StylesOf } from '../../types'
16
+
17
+ import { KeyboardAwareFlatList } from 'react-native-keyboard-aware-scroll-view'
7
18
  import { useKeyboardPaddingStyle } from '../../utils'
8
- import { AnyRecord, IJSX, StyledComponentProps, StyledComponentWithProps } from '@codeleap/styles'
9
- import { FlatListProps, ListItem } from './types'
10
- import { MobileStyleRegistry } from '../../Registry'
11
- import { useStylesFor } from '../../hooks'
19
+
20
+ export type DataboundFlatListPropsTypes = 'data' | 'renderItem' | 'keyExtractor' | 'getItemLayout'
21
+
22
+ export type AugmentedRenderItemInfo<T> = ListRenderItemInfo<T> & {
23
+ isFirst: boolean
24
+ isLast: boolean
25
+ isOnly: boolean
26
+ }
27
+
28
+ export type ReplaceFlatlistProps<P, T> = Omit<P, DataboundFlatListPropsTypes> & {
29
+ data: T[]
30
+ keyExtractor?: (item: T, index: number) => string
31
+ renderItem: (data: AugmentedRenderItemInfo<T>) => React.ReactElement
32
+ onRefresh?: () => void
33
+ getItemLayout?: ((
34
+ data: T,
35
+ index: number,
36
+ ) => { length: number; offset: number; index: number })
37
+ fakeEmpty?: boolean
38
+ loading?: boolean
39
+ }
12
40
 
13
41
  export * from './styles'
14
- export * from './types'
42
+ export * from './PaginationIndicator'
43
+
44
+ export type FlatListProps<
45
+ T = any[],
46
+ Data = T extends Array<infer D> ? D : never
47
+ > = ReplaceFlatlistProps<RNFlatListProps<Data>, Data> &
48
+ Omit<ViewProps, 'variants'> & {
49
+ separators?: boolean
50
+ placeholder?: EmptyPlaceholderProps
51
+ styles?: StylesOf<ListComposition>
52
+ refreshControlProps?: Partial<RefreshControlProps>
53
+ fakeEmpty?: boolean
54
+ loading?: boolean
55
+ keyboardAware?: boolean
56
+ } & ComponentVariants<typeof ListPresets>
15
57
 
16
58
  const RenderSeparator = (props: { separatorStyles: ViewProps['style'] }) => {
17
- return <View style={props.separatorStyles} />
59
+ return (
60
+ <View style={props.separatorStyles}></View>
61
+ )
18
62
  }
19
63
 
20
- export const List = forwardRef<FlatList, FlatListProps>((flatListProps, ref) => {
21
- const {
22
- style,
23
- onRefresh,
24
- component,
25
- refreshing,
26
- placeholder,
27
- refreshControlProps,
28
- loading,
29
- keyboardAware,
30
- fakeEmpty = loading,
31
- contentContainerStyle,
32
- renderItem: RenderItem,
33
- data,
34
- ...props
35
- } = {
36
- ...List.defaultProps,
37
- ...flatListProps,
38
- }
39
-
40
- const styles = useStylesFor(List.styleRegistryName, style)
41
-
42
- const separator = props?.separators && <RenderSeparator separatorStyles={styles.separator} />
43
-
44
- const dataLength = data?.length || 0
45
-
46
- const renderItem = useCallback((data: ListRenderItemInfo<any>) => {
47
- if (!RenderItem) return null
48
-
49
- const isFirst = data.index === 0
50
- const isLast = data.index === dataLength - 1
51
-
52
- const isOnly = isFirst && isLast
53
-
54
- const itemProps = {
55
- ...data,
56
- isFirst,
57
- isLast,
58
- isOnly,
64
+ const defaultProps: Partial<FlatListProps> = {
65
+ keyboardShouldPersistTaps: 'handled',
66
+ styles: {},
67
+ variants: [],
68
+ refreshControlProps: {},
69
+ fakeEmpty: false,
70
+ loading: false,
71
+ keyboardAware: true,
72
+ }
73
+
74
+ const ListCP = forwardRef<FlatList, FlatListProps>(
75
+ (flatListProps, ref) => {
76
+ const {
77
+ variants,
78
+ style,
79
+ styles,
80
+ onRefresh,
81
+ component,
82
+ refreshing,
83
+ placeholder,
84
+ refreshControlProps,
85
+ loading,
86
+ keyboardAware,
87
+ fakeEmpty = loading,
88
+ contentContainerStyle,
89
+ ...props
90
+ } = {
91
+ ...defaultProps,
92
+ ...flatListProps,
59
93
  }
60
94
 
61
- return <RenderItem {...itemProps} />
62
- }, [dataLength, RenderItem])
95
+ const variantStyles = useDefaultComponentStyle<'u:List', typeof ListPresets>('u:List', {
96
+ variants,
97
+ styles,
98
+ transform: StyleSheet.flatten,
63
99
 
64
- const isEmpty = !data || !data?.length
100
+ })
65
101
 
66
- const _placeholder = {
67
- ...placeholder,
68
- loading: TypeGuards.isBoolean(placeholder?.loading) ? placeholder.loading : loading,
69
- }
102
+ // const isEmpty = !props.data || !props.data.length
103
+ const separator = props?.separators && <RenderSeparator separatorStyles={variantStyles.separator} />
70
104
 
71
- const keyboardStyle = useKeyboardPaddingStyle([
72
- styles.content,
73
- contentContainerStyle,
74
- isEmpty && styles['content:empty'],
75
- loading && styles['content:loading'],
76
- ], keyboardAware && !props.horizontal)
105
+ const renderItem = useCallback((data: ListRenderItemInfo<any>) => {
106
+ if (!props?.renderItem) return null
107
+ const listLength = props?.data?.length || 0
77
108
 
78
- const wrapperStyle = [styles.wrapper, isEmpty && styles['wrapper:empty'], loading && styles['wrapper:loading']]
109
+ const isFirst = data.index === 0
110
+ const isLast = data.index === listLength - 1
79
111
 
80
- return (
81
- <FlatList
82
- ItemSeparatorComponent={separator as unknown as React.ComponentType}
83
- refreshControl={!!onRefresh && (
84
- <RefreshControl
85
- refreshing={refreshing}
86
- onRefresh={onRefresh}
87
- {...refreshControlProps}
88
- />
89
- )}
90
- ListEmptyComponent={<EmptyPlaceholder {..._placeholder} />}
91
- showsVerticalScrollIndicator={false}
92
- showsHorizontalScrollIndicator={false}
93
- {...props}
94
- ListHeaderComponentStyle={styles.header}
95
- style={wrapperStyle}
96
- contentContainerStyle={keyboardStyle}
97
- data={fakeEmpty ? [] : data}
98
- ref={ref}
99
- renderItem={renderItem}
100
- />
101
- )
102
- }) as StyledComponentWithProps<FlatListProps>
112
+ const isOnly = isFirst && isLast
113
+
114
+ return props?.renderItem({
115
+ ...data,
116
+ isFirst,
117
+ isLast,
118
+ isOnly,
119
+ })
120
+ }, [props?.renderItem, props?.data?.length])
103
121
 
104
- List.styleRegistryName = 'List'
105
- List.elements = ['wrapper', 'content', 'separator', 'header', 'refreshControl']
106
- List.rootElement = 'wrapper'
122
+ const isEmpty = !props.data || !props.data.length
107
123
 
108
- List.withVariantTypes = <S extends AnyRecord>(styles: S) => {
109
- return List as <T extends ListItem>(props: StyledComponentProps<FlatListProps<T>, typeof styles>) => IJSX
124
+ const _placeholder = {
125
+ ...placeholder,
126
+ loading: TypeGuards.isBoolean(placeholder?.loading) ? placeholder.loading : loading,
127
+ }
128
+
129
+ const keyboardStyle = useKeyboardPaddingStyle([
130
+ variantStyles.content,
131
+ contentContainerStyle,
132
+ isEmpty && variantStyles['content:empty'],
133
+ ], keyboardAware && !props.horizontal)
134
+
135
+ return (
136
+ <FlatList
137
+ style={[
138
+ variantStyles.wrapper,
139
+ style,
140
+ isEmpty && variantStyles['wrapper:empty'],
141
+ ]}
142
+ contentContainerStyle={keyboardStyle}
143
+ // @ts-expect-error This works
144
+ ItemSeparatorComponent={separator}
145
+ ListHeaderComponentStyle={variantStyles.header}
146
+ refreshControl={!!onRefresh && (
147
+ <RefreshControl
148
+ refreshing={refreshing}
149
+ onRefresh={onRefresh}
150
+ {...refreshControlProps}
151
+ />
152
+ )}
153
+
154
+ ListEmptyComponent={<EmptyPlaceholder {..._placeholder} />}
155
+ {...props}
156
+ data={fakeEmpty ? [] : props.data}
157
+ ref={ref}
158
+ renderItem={renderItem}
159
+
160
+ />
161
+ )
162
+ },
163
+ )
164
+
165
+ export type ListComponentType = (<T extends any[] = any[]>(props: FlatListProps<T>) => JSX.Element) & {
166
+ defaultProps: Partial<FlatListProps>
110
167
  }
168
+ export const List = ListCP as unknown as ListComponentType
111
169
 
112
- List.defaultProps = {
113
- keyboardShouldPersistTaps: 'handled',
114
- fakeEmpty: false,
115
- loading: false,
116
- keyboardAware: true,
117
- } as Partial<FlatListProps>
170
+ List.defaultProps = defaultProps
118
171
 
119
- MobileStyleRegistry.registerComponent(List)
@@ -1,7 +1,13 @@
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
1
2
  import { ScrollComposition } from '../Scroll/styles'
2
3
 
4
+
3
5
  type ListStates = 'empty' | 'loading'
4
6
 
5
7
  type ListParts = ScrollComposition | 'separator' | 'header' | 'refreshControl'
6
8
 
7
9
  export type ListComposition = `${ListParts}:${ListStates}` | ListParts
10
+
11
+ const createListStyle = createDefaultVariantFactory<ListComposition>()
12
+
13
+ export const ListPresets = includePresets(style => createListStyle(() => ({ content: style })))
@@ -1,68 +1,55 @@
1
1
  import React, { useRef } from 'react'
2
+ import { ComponentVariants, getNestedStylesByKey, onUpdate, useDefaultComponentStyle, useMemo } from '@codeleap/common'
3
+ import { StyleSheet } from 'react-native'
4
+ import { StylesOf } from '../../types'
2
5
  import { ActivityIndicator } from '../ActivityIndicator'
3
6
  import { View } from '../View'
7
+ import { LoadingOverlayComposition, LoadingOverlayPresets } from './styles'
4
8
  import { useAnimatedVariantStyles } from '../../utils'
5
- import { LoadingOverlayProps } from './types'
6
- import { MobileStyleRegistry } from '../../Registry'
7
- import { AnyRecord, useNestedStylesByKey, IJSX, StyledComponentProps } from '@codeleap/styles'
8
- import { useStylesFor } from '../../hooks'
9
9
 
10
10
  export * from './styles'
11
- export * from './types'
11
+
12
+ export type LoadingOverlayProps = React.PropsWithChildren<{
13
+ variants?: ComponentVariants<typeof LoadingOverlayPresets>['variants']
14
+ styles?: StylesOf<LoadingOverlayComposition>
15
+ visible?: boolean
16
+ } >
12
17
 
13
18
  export const LoadingOverlay = (props: LoadingOverlayProps) => {
14
19
  const {
15
20
  children,
21
+ styles,
22
+ variants,
16
23
  visible,
17
- style,
18
- } = {
19
- ...LoadingOverlay.defaultProps,
20
- ...props
21
- }
22
-
23
- const transition = useRef(null)
24
+ } = props
24
25
 
25
- const styles = useStylesFor(LoadingOverlay.styleRegistryName, style)
26
+ const variantStyles = useDefaultComponentStyle<'u:LoadingOverlay', typeof LoadingOverlayPresets>('u:LoadingOverlay', {
27
+ variants,
28
+ rootElement: 'wrapper',
29
+ styles,
30
+ transform: StyleSheet.flatten,
31
+ })
26
32
 
27
- const loaderStyles = useNestedStylesByKey('loader', styles)
33
+ const loaderStyles = useMemo(() => getNestedStylesByKey('loader', variantStyles), [variantStyles])
28
34
 
29
35
  const wrapperAnimation = useAnimatedVariantStyles({
30
- variantStyles: styles,
36
+ variantStyles,
31
37
  animatedProperties: ['wrapper:visible', 'wrapper:hidden'],
32
38
  updater: (s) => {
33
39
  'worklet'
34
40
  return visible ? s['wrapper:visible'] : s['wrapper:hidden']
35
41
  },
36
- transition: styles.transition,
42
+ transition: variantStyles.transition,
37
43
  dependencies: [visible],
38
44
  })
45
+
39
46
 
47
+ const transition = useRef(null)
40
48
  if (!transition.current) {
41
- transition.current = JSON.parse(JSON.stringify(styles['wrapper:transition']))
49
+ transition.current = JSON.parse(JSON.stringify(variantStyles['wrapper:transition']))
42
50
  }
43
-
44
- return (
45
- <View
46
- animated
47
- animatedStyle={wrapperAnimation}
48
- style={styles.wrapper}
49
- // @ts-expect-error
50
- transition={transition.current}
51
- >
52
- <ActivityIndicator style={loaderStyles} />
53
- {children}
54
- </View>
55
- )
56
- }
57
-
58
- LoadingOverlay.styleRegistryName = 'LoadingOverlay'
59
- LoadingOverlay.elements = ['wrapper', 'loader', 'transition']
60
- LoadingOverlay.rootElement = 'wrapper'
61
-
62
- LoadingOverlay.defaultProps = {} as Partial<LoadingOverlayProps>
63
-
64
- LoadingOverlay.withVariantTypes = <S extends AnyRecord>(styles: S) => {
65
- return LoadingOverlay as (props: StyledComponentProps<LoadingOverlayProps, typeof styles>) => IJSX
51
+ return <View style={[variantStyles.wrapper, wrapperAnimation]} animated transition={transition.current}>
52
+ <ActivityIndicator styles={loaderStyles}/>
53
+ {children}
54
+ </View>
66
55
  }
67
-
68
- MobileStyleRegistry.registerComponent(LoadingOverlay)
@@ -1,10 +1,10 @@
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
1
2
  import { ActivityIndicatorComposition } from '../ActivityIndicator'
2
3
 
3
- type WrapperStates = 'hidden' | 'visible'
4
+ type WrapperStates = 'hidden'| 'visible'
4
5
 
5
- export type LoadingOverlayComposition =
6
- 'wrapper' |
7
- `wrapper:${WrapperStates}` |
8
- 'wrapper:transition' |
9
- `loader${Capitalize<ActivityIndicatorComposition>}` |
10
- 'transition'
6
+ export type LoadingOverlayComposition = 'wrapper' | `wrapper:${WrapperStates}` | 'wrapper:transition' | `loader${Capitalize<ActivityIndicatorComposition>}` | 'transition'
7
+
8
+ const createLoadingOverlayStyle = createDefaultVariantFactory<LoadingOverlayComposition>()
9
+
10
+ export const LoadingOverlayPresets = includePresets((styles) => createLoadingOverlayStyle(() => ({ wrapper: styles })))