@codeleap/mobile 3.24.3 → 4.0.0

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 +6 -4
  2. package/src/Registry.ts +52 -0
  3. package/src/components/ActionIcon/index.tsx +55 -37
  4. package/src/components/ActionIcon/styles.ts +2 -4
  5. package/src/components/ActionIcon/types.ts +15 -0
  6. package/src/components/ActivityIndicator/index.tsx +42 -64
  7. package/src/components/ActivityIndicator/styles.ts +1 -10
  8. package/src/components/ActivityIndicator/types.ts +9 -0
  9. package/src/components/Autocomplete/index.tsx +46 -54
  10. package/src/components/Autocomplete/styles.ts +2 -5
  11. package/src/components/Autocomplete/types.ts +13 -23
  12. package/src/components/Avatar/index.tsx +59 -71
  13. package/src/components/Avatar/styles.ts +1 -9
  14. package/src/components/Avatar/types.ts +23 -0
  15. package/src/components/AvatarGroup/index.tsx +30 -44
  16. package/src/components/AvatarGroup/styles.ts +0 -6
  17. package/src/components/AvatarGroup/types.ts +10 -0
  18. package/src/components/Backdrop/index.tsx +51 -34
  19. package/src/components/Backdrop/styles.ts +5 -10
  20. package/src/components/Backdrop/types.ts +14 -0
  21. package/src/components/Badge/index.tsx +36 -62
  22. package/src/components/Badge/styles.ts +3 -11
  23. package/src/components/Badge/types.ts +27 -0
  24. package/src/components/Button/index.tsx +55 -82
  25. package/src/components/Button/styles.ts +13 -14
  26. package/src/components/Button/types.ts +20 -0
  27. package/src/components/Calendar/index.tsx +35 -29
  28. package/src/components/Checkbox/index.tsx +43 -64
  29. package/src/components/Checkbox/styles.ts +1 -6
  30. package/src/components/Checkbox/types.ts +13 -0
  31. package/src/components/DatePickerModal/index.tsx +50 -65
  32. package/src/components/DatePickerModal/styles.ts +9 -10
  33. package/src/components/DatePickerModal/types.ts +36 -54
  34. package/src/components/EmptyPlaceholder/index.tsx +40 -63
  35. package/src/components/EmptyPlaceholder/styles.ts +0 -5
  36. package/src/components/EmptyPlaceholder/types.ts +21 -0
  37. package/src/components/FileInput/index.tsx +11 -49
  38. package/src/components/FileInput/types.ts +27 -0
  39. package/src/components/Grid/index.tsx +84 -116
  40. package/src/components/Grid/styles.ts +0 -5
  41. package/src/components/Grid/types.ts +20 -0
  42. package/src/components/Icon/index.tsx +44 -79
  43. package/src/components/Icon/styles.ts +0 -6
  44. package/src/components/Icon/types.ts +15 -0
  45. package/src/components/Image/index.tsx +58 -78
  46. package/src/components/Image/styles.ts +1 -6
  47. package/src/components/Image/types.ts +18 -0
  48. package/src/components/ImageView/Spotlight.tsx +1 -4
  49. package/src/components/ImageView/component.tsx +1 -2
  50. package/src/components/InputBase/index.tsx +33 -24
  51. package/src/components/InputBase/styles.ts +66 -75
  52. package/src/components/InputBase/types.ts +3 -4
  53. package/src/components/InputBase/utils.ts +6 -4
  54. package/src/components/List/index.tsx +99 -151
  55. package/src/components/List/styles.ts +0 -6
  56. package/src/components/List/types.ts +41 -0
  57. package/src/components/LoadingOverlay/index.tsx +42 -29
  58. package/src/components/LoadingOverlay/styles.ts +7 -7
  59. package/src/components/LoadingOverlay/types.ts +9 -0
  60. package/src/components/Modal/index.tsx +80 -127
  61. package/src/components/Modal/styles.ts +0 -8
  62. package/src/components/Modal/types.ts +41 -0
  63. package/src/components/Navigation/Navigation.tsx +1 -0
  64. package/src/components/Navigation/types.ts +2 -9
  65. package/src/components/NumberIncrement/index.tsx +50 -60
  66. package/src/components/NumberIncrement/styles.ts +0 -5
  67. package/src/components/NumberIncrement/types.ts +32 -39
  68. package/src/components/Pager/index.tsx +42 -94
  69. package/src/components/Pager/styles.ts +1 -13
  70. package/src/components/Pager/types.ts +37 -0
  71. package/src/components/PaginationIndicator/index.tsx +51 -0
  72. package/src/components/PaginationIndicator/styles.ts +3 -0
  73. package/src/components/PaginationIndicator/types.ts +10 -0
  74. package/src/components/RadioInput/index.tsx +32 -57
  75. package/src/components/RadioInput/styles.ts +5 -7
  76. package/src/components/RadioInput/types.ts +31 -0
  77. package/src/components/RefreshControl/index.tsx +39 -19
  78. package/src/components/RefreshControl/styles.ts +1 -6
  79. package/src/components/RefreshControl/types.ts +9 -0
  80. package/src/components/Scroll/index.tsx +89 -105
  81. package/src/components/Scroll/styles.ts +0 -5
  82. package/src/components/Scroll/types.ts +21 -0
  83. package/src/components/SearchInput/index.tsx +90 -0
  84. package/src/components/Sections/index.tsx +111 -161
  85. package/src/components/Sections/styles.ts +0 -5
  86. package/src/components/Sections/types.ts +39 -0
  87. package/src/components/SegmentedControl/Option.tsx +46 -31
  88. package/src/components/SegmentedControl/index.tsx +86 -121
  89. package/src/components/SegmentedControl/styles.ts +15 -22
  90. package/src/components/SegmentedControl/types.ts +31 -0
  91. package/src/components/Select/index.tsx +71 -82
  92. package/src/components/Select/styles.ts +3 -5
  93. package/src/components/Select/types.ts +20 -25
  94. package/src/components/Slider/index.tsx +58 -43
  95. package/src/components/Slider/styles.ts +15 -6
  96. package/src/components/Slider/types.ts +9 -14
  97. package/src/components/Switch/index.tsx +43 -56
  98. package/src/components/Switch/styles.ts +1 -7
  99. package/src/components/Switch/types.ts +12 -0
  100. package/src/components/Text/index.tsx +56 -52
  101. package/src/components/Text/styles.ts +1 -7
  102. package/src/components/Text/types.ts +18 -0
  103. package/src/components/TextInput/index.tsx +49 -162
  104. package/src/components/TextInput/styles.ts +2 -8
  105. package/src/components/TextInput/types.ts +23 -0
  106. package/src/components/Touchable/index.tsx +44 -87
  107. package/src/components/Touchable/styles.ts +0 -9
  108. package/src/components/Touchable/types.ts +27 -0
  109. package/src/components/View/index.tsx +23 -92
  110. package/src/components/View/styles.ts +0 -6
  111. package/src/components/View/types.ts +13 -0
  112. package/src/components/components.ts +2 -6
  113. package/src/hooks/index.ts +13 -0
  114. package/src/index.ts +2 -0
  115. package/src/modules/PressableRipple/type.ts +1 -0
  116. package/src/utils/KeyboardAware/context.tsx +0 -2
  117. package/src/utils/KeyboardAware/keyboardHooks.ts +1 -2
  118. package/src/utils/ModalManager/components.tsx +1 -30
  119. package/src/utils/ModalManager/context.tsx +4 -4
  120. package/src/utils/ModalManager/index.ts +1 -4
  121. package/src/utils/hooks.ts +12 -1
  122. package/src/components/Calendar/style.ts +0 -6
  123. package/src/components/ContentView/index.tsx +0 -63
  124. package/src/components/ContentView/styles.ts +0 -8
  125. package/src/components/Drawer/index.tsx +0 -28
  126. package/src/components/Drawer/styles.ts +0 -8
  127. package/src/components/FileInput/styles.ts +0 -8
  128. package/src/components/InputLabel/index.tsx +0 -38
  129. package/src/components/InputLabel/styles.ts +0 -7
  130. package/src/components/List/PaginationIndicator.tsx +0 -54
  131. package/src/components/defaultStyles.ts +0 -77
@@ -1,107 +1,38 @@
1
1
  import React from 'react'
2
- import { forwardRef } from 'react'
3
- import {
4
- ComponentVariants,
5
- useDefaultComponentStyle,
6
- ViewStyles,
7
- useCodeleapContext,
8
- useMemo,
9
- AnyRef,
10
- TypeGuards,
11
- } from '@codeleap/common'
12
- import { View as NativeView, ViewProps as RNViewProps } from 'react-native'
13
- import { TransitionConfig } from '../../types'
2
+ import { View as RNView } from 'react-native'
3
+ import { AnyRecord, IJSX, StyledComponentProps } from '@codeleap/styles'
4
+ import { MobileStyleRegistry } from '../../Registry'
14
5
  import Animated from 'react-native-reanimated'
15
- export * from './styles'
16
-
17
- type NativeViewProps = RNViewProps
18
-
19
- export type ViewRefType = NativeView
6
+ import { ViewProps } from './types'
7
+ import { useStylesFor } from '../../hooks'
20
8
 
21
- export type ViewProps = {
22
- ref?: AnyRef<ViewRefType>
23
- component?: any
24
- animated?: boolean
25
- keyboardAware?: boolean
26
- transition?: Partial<TransitionConfig>
27
- }
28
- & NativeViewProps
29
- & ComponentVariants<typeof ViewStyles>
9
+ export * from './types'
10
+ export * from './styles'
30
11
 
31
- export const View = forwardRef<NativeView, ViewProps>((viewProps, ref) => {
12
+ export const View = <T extends React.ComponentType = typeof RNView>(props: ViewProps<T>) => {
32
13
  const {
33
- responsiveVariants = {},
34
- variants = [],
35
- children,
36
14
  style,
37
- keyboardAware,
38
- component,
15
+ component: _Component = RNView,
39
16
  animated = false,
40
- ...props
41
- } = viewProps
17
+ animatedStyle,
18
+ ...viewProps
19
+ } = props
42
20
 
43
- const variantStyles = useDefaultComponentStyle('View', {
44
- responsiveVariants,
45
- variants,
46
- })
47
- const Component = animated ? Animated.View : component || NativeView
21
+ const styles = useStylesFor(View.styleRegistryName, style)
22
+
23
+ const Component: React.ComponentType<AnyRecord> = animated ? Animated.View : _Component
48
24
 
49
25
  return (
50
- <Component {...props} style={[variantStyles.wrapper, style]}>
51
- {children}
52
- </Component>
26
+ <Component {...viewProps} style={[styles.wrapper, animatedStyle]} />
53
27
  )
54
- }) as unknown as ((props: ViewProps) => JSX.Element)
55
-
56
- type GapProps = ViewProps & {
57
- value: number
58
- crossValue?: number
59
- defaultProps?: any
60
28
  }
61
29
 
62
- export const Gap = ({ children, value, defaultProps = {}, crossValue = null, ...props }: GapProps) => {
63
- const { Theme } = useCodeleapContext()
64
- const childArr = React.Children.toArray(children)
65
-
66
- const horizontal = props.variants?.includes('row')
67
-
68
- const spacings = useMemo(() => {
69
- return childArr.map((_, idx) => {
70
-
71
- const space = Theme.spacing.value(value)
72
- const crossSpace = Theme.spacing.value(crossValue)
30
+ View.styleRegistryName = 'View'
31
+ View.elements = ['wrapper']
32
+ View.rootElement = 'wrapper'
73
33
 
74
- const isLast = idx === childArr.length - 1
75
-
76
- const spacingProperty = horizontal ? 'marginRight' : 'marginBottom'
77
- const crossSpacingProperty = horizontal ? 'marginBottom' : 'marginRight'
78
-
79
- const style = isLast ? {} : {
80
- [spacingProperty]: space,
81
- }
82
-
83
- if (!TypeGuards.isNil(crossValue)) {
84
- style[crossSpacingProperty] = crossSpace
85
- }
86
-
87
- return style
88
- })
89
-
90
- }, [childArr.length, horizontal])
91
-
92
- return (
93
- <View {...props}>
94
- {
95
- childArr.map((Element, idx, childArr) => {
96
- if (React.isValidElement(Element)) {
97
- const props = { ...Element.props, ...defaultProps }
98
-
99
- props.style = [props.style, spacings[idx]]
100
- return React.cloneElement(Element, props)
101
- }
102
- return Element
103
- })
104
- }
105
- </View>
106
- )
34
+ View.withVariantTypes = <S extends AnyRecord>(styles: S) => {
35
+ return View as (<T extends React.ComponentType = typeof RNView>(props: StyledComponentProps<ViewProps<T>, typeof styles>) => IJSX)
107
36
  }
37
+
38
+ MobileStyleRegistry.registerComponent(View)
@@ -1,8 +1,2 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
1
 
3
2
  export type ViewComposition = 'wrapper'
4
-
5
- const createViewStyle = createDefaultVariantFactory<ViewComposition>()
6
-
7
- export const ViewPresets = includePresets((styles) => createViewStyle(() => ({ wrapper: styles })))
8
-
@@ -0,0 +1,13 @@
1
+ import { PropsOf } from '@codeleap/common'
2
+ import { StyledProp } from '@codeleap/styles'
3
+ import { ImageStyle, TextStyle, View as RNView, ViewStyle } from 'react-native'
4
+ import { AnimatedStyleProp } from 'react-native-reanimated'
5
+ import { ViewComposition } from './styles'
6
+
7
+ export type ViewProps<T extends React.ComponentType = typeof RNView> = {
8
+ component?: T
9
+ style?: StyledProp<ViewComposition>
10
+ animated?: boolean
11
+ children?: React.ReactNode
12
+ animatedStyle?: AnimatedStyleProp<ViewStyle | ImageStyle | TextStyle>
13
+ } & PropsOf<T>
@@ -7,7 +7,6 @@ export * from './Checkbox'
7
7
  export * from './TextInput'
8
8
  export * from './RadioInput'
9
9
  export * from './Switch'
10
- export * from './ContentView'
11
10
  export * from './Sections'
12
11
  export * from './Select'
13
12
  export * from './FileInput'
@@ -18,7 +17,6 @@ export * from './Scroll'
18
17
  export * from './List'
19
18
  export * from './ActivityIndicator'
20
19
  export * from './Button'
21
- export * from './ContentView'
22
20
  export * from './Modal'
23
21
  export * from './Calendar'
24
22
  export * from './ImageView'
@@ -26,11 +24,9 @@ export * from './Navigation'
26
24
  export * from './Pager'
27
25
  export * from './EmptyPlaceholder'
28
26
  export * from './Backdrop'
29
- export * from './Drawer'
30
27
  export * from './SegmentedControl'
31
28
  export * from './Autocomplete'
32
29
  export * from './Grid'
33
- export * from './InputLabel'
34
30
  export * from './LoadingOverlay'
35
31
  export * from './ActionIcon'
36
32
  export * from './InputBase'
@@ -40,5 +36,5 @@ export * from './Avatar'
40
36
  export * from './AvatarGroup'
41
37
  export * from './NumberIncrement'
42
38
  export * from './Badge'
43
-
44
- export * from './defaultStyles'
39
+ export * from './SearchInput'
40
+ export * from './PaginationIndicator'
@@ -0,0 +1,13 @@
1
+ import { StyleProp, useStyleObserver } from '@codeleap/styles'
2
+ import { useMemo } from 'react'
3
+ import { MobileStyleRegistry } from '../Registry'
4
+
5
+ export const useStylesFor = <T = unknown>(componentName: string, style: StyleProp<T, string>): T => {
6
+ const styleObserver = useStyleObserver(style)
7
+
8
+ const styles = useMemo(() => {
9
+ return MobileStyleRegistry.current.styleFor(componentName, style)
10
+ }, [styleObserver])
11
+
12
+ return styles
13
+ }
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './components/components'
2
2
  export { Linking } from 'react-native'
3
3
  export * from './utils'
4
+ export * from './hooks'
4
5
  import uuid from 'react-native-uuid'
5
6
  import * as RNKeyboardAwareScrollView from './utils/KeyboardAware'
6
7
  export { uuid, RNKeyboardAwareScrollView }
8
+ export { MobileStyleRegistry } from './Registry'
@@ -10,6 +10,7 @@ export type PressableRippleProps = {
10
10
  rippleCentered?: boolean;
11
11
  rippleSequential?: boolean;
12
12
  rippleFades?: boolean;
13
+ color?: string
13
14
  onRippleAnimation?: (
14
15
  animation: Animated.CompositeAnimation,
15
16
  callback: () => void,
@@ -11,11 +11,9 @@ type TKeyboardCtx = {
11
11
  * @deprecated useKeyboard does not need to be wrapped in a provider
12
12
  */
13
13
  export const KeyboardProvider = ({ children }) => {
14
-
15
14
  return <>
16
15
  {children}
17
16
  </>
18
-
19
17
  }
20
18
 
21
19
  export const useKeyboard = (): TKeyboardCtx => {
@@ -1,4 +1,4 @@
1
- import { PropsOf, useCodeleapContext, TypeGuards } from '@codeleap/common'
1
+ import { PropsOf, TypeGuards } from '@codeleap/common'
2
2
  import { ScrollView, Platform, StyleSheet, Dimensions, EasingFunction, Easing } from 'react-native'
3
3
  import { TransitionConfig } from '../../types'
4
4
  import { useKeyboard } from './context'
@@ -26,7 +26,6 @@ type UseKeyboardAwareViewParams = {
26
26
 
27
27
  export const useKeyboardAwareView = (params?: UseKeyboardAwareViewParams) => {
28
28
  const keyboard = useKeyboard()
29
- const { logger } = useCodeleapContext()
30
29
  const options = params || {}
31
30
 
32
31
  const _options:GetKeyboardAwarePropsOptions = {
@@ -1,9 +1,8 @@
1
- import * as React from 'react'
1
+ import React from 'react'
2
2
  import { usePrevious, onMount, onUpdate, PropsOf } from '@codeleap/common'
3
3
  import { useModalContext } from './context'
4
4
  import { Portal } from '@gorhom/portal'
5
5
  import { Modal as _Modal } from '../../components/Modal'
6
- import { Drawer as _Drawer } from '../../components/Drawer'
7
6
 
8
7
  type UseManagedModalArgs = {
9
8
  id?: string
@@ -82,31 +81,3 @@ export const Modal:React.FC<ManagedModalProps> = ({
82
81
 
83
82
  return content
84
83
  }
85
-
86
- export type ManagedDrawerProps<T = PropsOf<typeof _Drawer>> = Omit<T, 'visible' | 'toggle'> & UseManagedModalArgs & {
87
-
88
- absolute?: boolean
89
-
90
- }
91
-
92
- export const Drawer:React.FC<ManagedDrawerProps> = ({
93
- children,
94
- absolute = true,
95
- ...props
96
- }) => {
97
- const componentProps = useManagedModal(props)
98
-
99
- const content = (
100
- <_Drawer {...componentProps}>
101
- {children}
102
- </_Drawer>
103
- )
104
-
105
- if (absolute) {
106
- return <Portal>
107
- {content}
108
- </Portal>
109
- }
110
-
111
- return content
112
- }
@@ -1,5 +1,5 @@
1
- import * as React from 'react'
2
- import { AnyFunction, onUpdate, TypeGuards, useCodeleapContext, useState } from '@codeleap/common'
1
+ import React from 'react'
2
+ import { AnyFunction, onUpdate, TypeGuards, useState } from '@codeleap/common'
3
3
  import { PortalProvider } from '@gorhom/portal'
4
4
  import { KeyboardProvider } from '../KeyboardAware'
5
5
 
@@ -69,8 +69,8 @@ export function Provider({ children }) {
69
69
 
70
70
  }
71
71
 
72
- const codeleapCtx = useCodeleapContext()
73
- const defaultDuration = codeleapCtx?.Theme?.values?.transitions?.modal?.duration || 300
72
+ // const codeleapCtx = useCodeleapContext()
73
+ const defaultDuration = 300
74
74
  const transition:TModalContext['transition'] = (from, to, options) => {
75
75
  return new Promise((resolve) => {
76
76
  setTimeout(() => {
@@ -1,16 +1,13 @@
1
1
  import { useModalContext, useModalSequence, Provider } from './context'
2
- import { Modal, ManagedModalProps, Drawer, ManagedDrawerProps } from './components'
2
+ import { Modal, ManagedModalProps } from './components'
3
3
 
4
4
  export const ModalManager = {
5
5
  useModalContext,
6
6
  Modal,
7
- Drawer,
8
7
  Provider,
9
8
  useModalSequence,
10
9
  }
11
10
 
12
11
  export type {
13
12
  ManagedModalProps,
14
- ManagedDrawerProps,
15
-
16
13
  }
@@ -6,6 +6,7 @@ import { AnimatedStyleProp, Easing, EasingFn, interpolateColor, runOnJS, useAnim
6
6
  import { PressableRippleProps } from '../modules/PressableRipple/type'
7
7
  import { useSoftInputState } from 'react-native-avoid-softinput'
8
8
  import { useMemo } from 'react'
9
+ import { mergeStyles } from '@codeleap/styles'
9
10
 
10
11
  export function useAnimateColor(value: string, opts?: Partial<Animated.TimingAnimationConfig>) {
11
12
  const iters = useRef(0)
@@ -199,6 +200,16 @@ type RippleConfig = {
199
200
  }
200
201
  export type TouchableFeedbackConfig = RippleConfig | FeedbackConfig
201
202
 
203
+ export type TouchFeedbackConfig = {
204
+ type?: 'ripple' | 'opacity' | 'highlight' | 'styles' | 'none'
205
+ config?: PressableRippleProps
206
+ iosFallback?: FeedbackConfig
207
+ value?: number
208
+ brightness?: number
209
+ shiftOpacity?: number
210
+ styles?: StyleProp<ViewStyle>
211
+ }
212
+
202
213
  export type UsePressableFeedbackConfig = {
203
214
  disabled?: boolean
204
215
  feedbackConfig?: TouchableFeedbackConfig
@@ -353,5 +364,5 @@ export function useKeyboardPaddingStyle(styles: ViewStyle[], enabled = true) {
353
364
 
354
365
  const totalPadding = softInputHeight + bottomPadding
355
366
 
356
- return isSoftInputShown && enabled ? [propStyle, { paddingBottom: totalPadding }] : [propStyle]
367
+ return isSoftInputShown && enabled ? mergeStyles([propStyle, { paddingBottom: totalPadding }]) : propStyle
357
368
  }
@@ -1,6 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
- import { TCalendarStyles, CalendarComposition } from './types'
3
-
4
- const createCalendarStyle = createDefaultVariantFactory<CalendarComposition, TCalendarStyles>()
5
-
6
- export const CalendarPresets = includePresets((style) => createCalendarStyle(() => ({ theme: style })))
@@ -1,63 +0,0 @@
1
- import React from 'react'
2
- import {
3
-
4
- ComponentVariants,
5
- useDefaultComponentStyle,
6
-
7
- } from '@codeleap/common'
8
- import {
9
- ContentViewPresets,
10
- } from './styles'
11
- import { ViewProps, View, ViewComposition } from '../View'
12
- import { Text } from '../Text'
13
- import { StylesOf } from '../../types'
14
- import { ActivityIndicator } from '../ActivityIndicator'
15
- import { StyleSheet } from 'react-native'
16
-
17
- export * from './styles'
18
-
19
- export type ContentViewProps = Omit<
20
- ViewProps,
21
- 'variants' | 'responsiveVariants'
22
- > & {
23
- message?: string
24
- loading?: boolean
25
- styles?: StylesOf<ViewComposition>
26
- } & ComponentVariants<typeof ContentViewPresets>
27
-
28
- const WrapContent = ({ children, ...props }) => (
29
- <View {...props}>{children}</View>
30
- )
31
-
32
- export const ContentView: React.FC<ContentViewProps> = (rawProps) => {
33
- const { children, message, loading, variants, styles, ...props } =
34
- rawProps
35
-
36
- const variantStyle = useDefaultComponentStyle('ContentView', {
37
- variants,
38
- transform: StyleSheet.flatten,
39
- styles,
40
- })
41
-
42
- if (loading) {
43
- return (
44
- <WrapContent {...props} style={variantStyle.wrapper}>
45
- <ActivityIndicator styles={{ wrapper: variantStyle.loader }} />
46
- </WrapContent>
47
- )
48
- }
49
- const hasChildren = Object.keys(children || {}).length > 0
50
- if (hasChildren) {
51
- return (
52
- <WrapContent {...props} style={variantStyle.wrapper}>
53
- {children}
54
- </WrapContent>
55
- )
56
- }
57
-
58
- return (
59
- <WrapContent {...props} style={styles}>
60
- <Text text={message} />
61
- </WrapContent>
62
- )
63
- }
@@ -1,8 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
-
3
- export type ContentViewComposition = 'placeholder' | 'wrapper' | 'loader'
4
-
5
- const createContentViewStyle =
6
- createDefaultVariantFactory<ContentViewComposition>()
7
-
8
- export const ContentViewPresets = includePresets((styles) => createContentViewStyle(() => ({ wrapper: styles })))
@@ -1,28 +0,0 @@
1
- import * as React from 'react'
2
-
3
- import { ComponentVariants, useDefaultComponentStyle } from '@codeleap/common'
4
- import { StyleSheet } from 'react-native'
5
- import Modal, { ModalProps } from '../Modal'
6
- import { DrawerPresets } from './styles'
7
- export * from './styles'
8
- export type DrawerProps = Omit<ModalProps, 'variants'> & ComponentVariants<typeof DrawerPresets>
9
-
10
- export const Drawer:React.FC<DrawerProps> = (props) => {
11
- const { variants, styles, scrollProps, ...modalProps } = props
12
-
13
- const variantStyles = useDefaultComponentStyle('u:Drawer', {
14
- variants,
15
- styles,
16
- transform: StyleSheet.flatten,
17
- })
18
-
19
- return <Modal
20
- styles={variantStyles}
21
- scroll={false}
22
-
23
- {...modalProps}
24
- scrollProps={{
25
- ...scrollProps,
26
- }}
27
- />
28
- }
@@ -1,8 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
- import { ModalComposition } from '../Modal'
3
-
4
- export type DrawerComposition = ModalComposition
5
-
6
- const createModalStyle = createDefaultVariantFactory<DrawerComposition>()
7
-
8
- export const DrawerPresets = includePresets((style) => createModalStyle(() => ({ body: style })))
@@ -1,8 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
-
3
- export type FileInputComposition = 'label' | 'wrapper' | 'input'
4
-
5
- const createFileInputStyle =
6
- createDefaultVariantFactory<FileInputComposition>()
7
-
8
- export const FileInputPresets = includePresets((styles) => createFileInputStyle(() => ({ wrapper: styles })))
@@ -1,38 +0,0 @@
1
- import React from 'react'
2
- import { ComponentVariants, FormTypes, useDefaultComponentStyle } from '@codeleap/common'
3
- import { StylesOf } from '../../types'
4
- import { View, ViewProps } from '../View'
5
- import { InputLabelComposition, InputLabelPresets } from './styles'
6
- import { Text } from '../Text'
7
- import { StyleSheet } from 'react-native'
8
-
9
- export type InputLabelProps = ViewProps & {
10
- styles?: StylesOf<InputLabelComposition>
11
- label?: FormTypes.Label
12
- required?: boolean
13
- } & ComponentVariants<typeof InputLabelPresets>
14
-
15
- export * from './styles'
16
-
17
- export const InputLabel:React.FC<InputLabelProps> = (props) => {
18
- const { label, required = false, variants = [], styles = {}, style, ...viewProps } = props
19
- const variantStyles = useDefaultComponentStyle<'u:InputLabel', typeof InputLabelPresets>('u:InputLabel', {
20
- variants, styles, transform: StyleSheet.flatten,
21
- })
22
-
23
- if (!label) return null
24
-
25
- switch (typeof label) {
26
- case 'string':
27
- return <View {...viewProps} style={[variantStyles.wrapper, style]}>
28
- <Text style={variantStyles.text} text={label} />
29
- {required && <Text style={variantStyles.asterisk} text={' *'} />}
30
- </View>
31
- case 'object':
32
- return <>
33
- {label as React.ReactNode}
34
- </>
35
- default:
36
- return null
37
- }
38
- }
@@ -1,7 +0,0 @@
1
- import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
-
3
- export type InputLabelComposition = 'text' | 'wrapper' | 'asterisk'
4
-
5
- const createInputLabelStyle = createDefaultVariantFactory<InputLabelComposition>()
6
-
7
- export const InputLabelPresets = includePresets(style => createInputLabelStyle(() => ({ wrapper: style, text: style })))
@@ -1,54 +0,0 @@
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
- }