@codeleap/mobile 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/components/List/styles.js +1 -1
  2. package/dist/components/List/styles.js.map +1 -1
  3. package/dist/utils/theme.d.ts +1 -0
  4. package/dist/utils/theme.js +7 -2
  5. package/dist/utils/theme.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/components/ActionIcon/index.tsx +32 -0
  8. package/src/components/ActionIcon/styles.ts +97 -0
  9. package/src/components/ActivityIndicator/index.tsx +50 -0
  10. package/src/components/ActivityIndicator/styles.ts +68 -0
  11. package/src/components/Animated.tsx +34 -0
  12. package/src/components/AutoComplete/index.tsx +163 -0
  13. package/src/components/AutoComplete/styles.ts +44 -0
  14. package/src/components/Backdrop/index.tsx +48 -0
  15. package/src/components/Backdrop/styles.ts +33 -0
  16. package/src/components/Button/index.tsx +167 -0
  17. package/src/components/Button/styles.ts +129 -0
  18. package/src/components/Calendar/index.tsx +65 -0
  19. package/src/components/Calendar/style.ts +35 -0
  20. package/src/components/Calendar/types.ts +102 -0
  21. package/src/components/Checkbox/index.tsx +91 -0
  22. package/src/components/Checkbox/styles.ts +81 -0
  23. package/src/components/ContentView/index.tsx +63 -0
  24. package/src/components/ContentView/styles.ts +24 -0
  25. package/src/components/Drawer/index.tsx +33 -0
  26. package/src/components/Drawer/styles.ts +43 -0
  27. package/src/components/EmptyPlaceholder/index.tsx +88 -0
  28. package/src/components/EmptyPlaceholder/styles.ts +58 -0
  29. package/src/components/FileInput/index.tsx +181 -0
  30. package/src/components/FileInput/styles.ts +15 -0
  31. package/src/components/Grid/index.tsx +117 -0
  32. package/src/components/Grid/styles.ts +11 -0
  33. package/src/components/Icon/index.tsx +69 -0
  34. package/src/components/Icon/styles.ts +57 -0
  35. package/src/components/Image/index.tsx +91 -0
  36. package/src/components/Image/styles.ts +20 -0
  37. package/src/components/ImageView/Spotlight.tsx +157 -0
  38. package/src/components/ImageView/component.tsx +38 -0
  39. package/src/components/ImageView/index.ts +2 -0
  40. package/src/components/InputLabel/index.tsx +38 -0
  41. package/src/components/InputLabel/styles.ts +19 -0
  42. package/src/components/List/PaginationIndicator.tsx +71 -0
  43. package/src/components/List/index.tsx +114 -0
  44. package/src/components/List/styles.ts +19 -0
  45. package/src/components/Modal/index.tsx +218 -0
  46. package/src/components/Modal/styles.ts +153 -0
  47. package/src/components/MultiSelect/index.tsx +138 -0
  48. package/src/components/MultiSelect/styles.ts +18 -0
  49. package/src/components/MultiSelect/types.ts +42 -0
  50. package/src/components/Navigation/Navigation.tsx +54 -0
  51. package/src/components/Navigation/constants.ts +8 -0
  52. package/src/components/Navigation/index.tsx +3 -0
  53. package/src/components/Navigation/types.ts +35 -0
  54. package/src/components/Navigation/utils.tsx +57 -0
  55. package/src/components/Pager/index.tsx +121 -0
  56. package/src/components/Pager/styles.ts +81 -0
  57. package/src/components/RadioInput/index.tsx +106 -0
  58. package/src/components/RadioInput/styles.ts +67 -0
  59. package/src/components/Scroll/index.tsx +124 -0
  60. package/src/components/Scroll/styles.ts +18 -0
  61. package/src/components/Sections/index.tsx +91 -0
  62. package/src/components/SegmentedControl/index.tsx +204 -0
  63. package/src/components/SegmentedControl/styles.ts +89 -0
  64. package/src/components/Select/index.tsx +167 -0
  65. package/src/components/Select/styles.ts +62 -0
  66. package/src/components/Select/types.ts +43 -0
  67. package/src/components/Slider/Mark.tsx +46 -0
  68. package/src/components/Slider/Thumb.tsx +29 -0
  69. package/src/components/Slider/index.tsx +130 -0
  70. package/src/components/Slider/styles.ts +76 -0
  71. package/src/components/Slider/types.ts +30 -0
  72. package/src/components/Switch/index.tsx +91 -0
  73. package/src/components/Switch/styles.ts +38 -0
  74. package/src/components/Text/index.tsx +97 -0
  75. package/src/components/Text/styles.ts +50 -0
  76. package/src/components/TextInput/index.tsx +319 -0
  77. package/src/components/TextInput/styles.ts +127 -0
  78. package/src/components/Touchable/index.tsx +172 -0
  79. package/src/components/Touchable/styles.ts +28 -0
  80. package/src/components/View/index.tsx +103 -0
  81. package/src/components/View/styles.ts +24 -0
  82. package/src/components/components.ts +42 -0
  83. package/src/components/defaultStyles.ts +62 -0
  84. package/src/components/legacy/Modal/index.tsx +163 -0
  85. package/src/components/legacy/Modal/styles.ts +125 -0
  86. package/src/components/legacy/Pager/index.tsx +242 -0
  87. package/src/components/legacy/Pager/styles.ts +51 -0
  88. package/src/components/legacy/index.ts +2 -0
  89. package/src/modules/documentPicker.ts +7 -0
  90. package/src/modules/fastImage.ts +2 -0
  91. package/src/modules/imageCropPicker.d.ts +497 -0
  92. package/src/modules/index.d.ts +682 -0
  93. package/src/modules/reactNavigation.ts +15 -0
  94. package/src/modules/textInputMask.ts +11 -0
  95. package/src/modules/types/documentPicker.d.ts +215 -0
  96. package/src/modules/types/fileTypes.ts +138 -0
  97. package/src/modules/types/textInputMask.ts +9 -0
  98. package/src/types/index.ts +1 -0
  99. package/src/types/utility.ts +9 -0
  100. package/src/utils/KeyboardAware/context.tsx +75 -0
  101. package/src/utils/KeyboardAware/index.ts +17 -0
  102. package/src/utils/KeyboardAware/keyboardHooks.ts +124 -0
  103. package/src/utils/KeyboardAware/lib/KeyboardAwareFlatList.ts +4 -0
  104. package/src/utils/KeyboardAware/lib/KeyboardAwareHOC.tsx +618 -0
  105. package/src/utils/KeyboardAware/lib/KeyboardAwareInterface.ts +13 -0
  106. package/src/utils/KeyboardAware/lib/KeyboardAwareScrollView.ts +6 -0
  107. package/src/utils/KeyboardAware/lib/KeyboardAwareSectionList.ts +6 -0
  108. package/src/utils/KeyboardAware/types.ts +159 -0
  109. package/src/utils/ModalManager/components.tsx +112 -0
  110. package/src/utils/ModalManager/context.tsx +260 -0
  111. package/src/utils/ModalManager/index.ts +16 -0
  112. package/src/utils/OSAlert.ts +180 -0
  113. package/src/utils/PermissionManager/context.tsx +302 -0
  114. package/src/utils/PermissionManager/index.ts +20 -0
  115. package/src/utils/PermissionManager/types.ts +24 -0
  116. package/src/utils/hooks.ts +163 -0
  117. package/src/utils/index.ts +11 -0
  118. package/src/utils/input.ts +51 -0
  119. package/src/utils/misc.ts +83 -0
  120. package/src/utils/notifications.ts +206 -0
  121. package/src/utils/theme.ts +58 -0
@@ -20,7 +20,7 @@ exports.ListStyles = {
20
20
  var defaultStyles = styles_1.ScrollStyles.default(theme);
21
21
  return __assign(__assign({}, defaultStyles), { separator: {
22
22
  width: '100%',
23
- height: theme.spacing.value(1.5),
23
+ height: theme.spacing.value(1),
24
24
  } });
25
25
  }),
26
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/List/styles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,2CAAkE;AAIlE,IAAM,eAAe,GAAG,IAAA,oCAA2B,GAAmB,CAAA;AAEzD,QAAA,UAAU,GAAG;IACxB,OAAO,EAAE,eAAe,CAAC,UAAC,KAAK;QAC7B,IAAM,aAAa,GAAG,qBAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjD,6BACK,aAAa,KAChB,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC;aACjC,IACF;IACH,CAAC,CAAC;CACH,CAAA"}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/components/List/styles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAA8D;AAC9D,2CAAkE;AAIlE,IAAM,eAAe,GAAG,IAAA,oCAA2B,GAAmB,CAAA;AAEzD,QAAA,UAAU,GAAG;IACxB,OAAO,EAAE,eAAe,CAAC,UAAC,KAAK;QAC7B,IAAM,aAAa,GAAG,qBAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjD,6BACK,aAAa,KAChB,SAAS,EAAE;gBACT,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;aAC/B,IACF;IACH,CAAC,CAAC;CACH,CAAA"}
@@ -5,6 +5,7 @@ declare type AppValues = {
5
5
  export declare function getMobileThemeValues(initialWindowMetrics: any, values: AppValues): {
6
6
  pixel: number;
7
7
  hasNotch: boolean;
8
+ hasIsland: boolean;
8
9
  prefersConstantNavigationBar: boolean;
9
10
  safeAreaTop: number;
10
11
  safeAreaBottom: number;
@@ -10,18 +10,23 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  exports.getMobileThemeValues = void 0;
15
18
  var react_native_1 = require("react-native");
19
+ var react_native_device_info_1 = __importDefault(require("react-native-device-info"));
16
20
  function getMobileThemeValues(initialWindowMetrics, values) {
17
21
  var _a, _b;
18
22
  var screenDimensions = react_native_1.Dimensions.get('screen');
19
23
  var hasNotch = react_native_1.Platform.OS === 'ios' ? (react_native_1.Dimensions.get('window').height >= 812) : (((_a = initialWindowMetrics === null || initialWindowMetrics === void 0 ? void 0 : initialWindowMetrics.insets) === null || _a === void 0 ? void 0 : _a.top) > 24 || react_native_1.StatusBar.currentHeight > 24);
24
+ var hasIsland = react_native_device_info_1.default.hasDynamicIsland();
20
25
  var bottomNavHeight = react_native_1.Platform.OS === 'android' ? (_b = initialWindowMetrics === null || initialWindowMetrics === void 0 ? void 0 : initialWindowMetrics.insets) === null || _b === void 0 ? void 0 : _b.bottom : 0;
21
26
  var prefersConstantNavigationBar = bottomNavHeight > 0;
22
- var safeAreaTop = react_native_1.Platform.OS === 'ios' ? (hasNotch ? 34 : 20) : react_native_1.StatusBar.currentHeight;
27
+ var safeAreaTop = react_native_1.Platform.OS === 'ios' ? (hasNotch ? 34 + (hasIsland ? 12 : 0) : 20) : react_native_1.StatusBar.currentHeight;
23
28
  var safeAreaBottom = (hasNotch && !prefersConstantNavigationBar ? 20 : 0);
24
- return __assign(__assign({}, screenDimensions), { pixel: react_native_1.StyleSheet.hairlineWidth, hasNotch: hasNotch, prefersConstantNavigationBar: prefersConstantNavigationBar, safeAreaTop: safeAreaTop, safeAreaBottom: safeAreaBottom, keyboardVerticalOffset: react_native_1.Platform.OS === 'ios' ? 57 : 47, get headerHeight() { return values.headerHeight + safeAreaTop; },
29
+ return __assign(__assign({}, screenDimensions), { pixel: react_native_1.StyleSheet.hairlineWidth, hasNotch: hasNotch, hasIsland: hasIsland, prefersConstantNavigationBar: prefersConstantNavigationBar, safeAreaTop: safeAreaTop, safeAreaBottom: safeAreaBottom, keyboardVerticalOffset: react_native_1.Platform.OS === 'ios' ? 57 : 47, get headerHeight() { return values.headerHeight + safeAreaTop; },
25
30
  get tabBarHeight() { return values.tabBarHeight + (prefersConstantNavigationBar ? 0 : this.safeAreaBottom); }, bottomNavHeight: bottomNavHeight, get window() {
26
31
  return {
27
32
  height: screenDimensions.height - (bottomNavHeight + safeAreaTop),
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/utils/theme.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6CAA0E;AAO1E,SAAgB,oBAAoB,CAAC,oBAAoB,EAAE,MAAiB;;IAC1E,IAAM,gBAAgB,GAAG,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEjD,IAAM,QAAQ,GAAG,uBAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,yBAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,MAAA,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAE,MAAM,0CAAE,GAAG,IAAG,EAAE,IAAI,wBAAS,CAAC,aAAa,GAAG,EAAE,CAAC,CAAA;IAC5J,IAAM,eAA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obile",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -0,0 +1,32 @@
1
+ import { ComponentVariants, getNestedStylesByKey, useDefaultComponentStyle } from '@codeleap/common'
2
+ import React from 'react'
3
+ import { StyleSheet } from 'react-native'
4
+ import { StylesOf } from '../../types'
5
+ import { Icon, IconProps } from '../Icon'
6
+ import { Touchable, TouchableProps } from '../Touchable'
7
+ import { ActionIconComposition, ActionIconStyles } from './styles'
8
+
9
+ export type ActionIconProps= {
10
+ iconProps?: Partial<IconProps>
11
+ icon?: IconProps['name']
12
+ styles?: StylesOf<ActionIconComposition>
13
+ } & Omit<TouchableProps, 'styles' | 'variants'> & ComponentVariants<typeof ActionIconStyles>
14
+
15
+ export const ActionIcon:React.FC<ActionIconProps> = (props) => {
16
+ const { icon, iconProps, variants, styles, children, ...touchableProps } = props
17
+ const variantStyles = useDefaultComponentStyle<'u:ActionIcon', typeof ActionIconStyles>('u:ActionIcon', {
18
+ variants, styles, transform: StyleSheet.flatten,
19
+ })
20
+ const touchableStyles = getNestedStylesByKey('touchable', variantStyles)
21
+
22
+ return <Touchable styles={touchableStyles} {...touchableProps}>
23
+ <Icon name={icon} style={
24
+ [
25
+ variantStyles.icon,
26
+ touchableProps?.disabled && variantStyles['icon:disabled'],
27
+ ]} {...iconProps}/>
28
+ {children}
29
+ </Touchable>
30
+ }
31
+
32
+ export * from './styles'
@@ -0,0 +1,97 @@
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
+ import { TouchableComposition } from '../Touchable'
3
+
4
+ export type ActionIconParts = 'icon' | `touchable${Capitalize<TouchableComposition>}`
5
+ export type ActionIconStates = ':disabled' | ''
6
+ export type ActionIconComposition = `${ActionIconParts}${ActionIconStates}`
7
+ const createActionIconStyle = createDefaultVariantFactory<ActionIconComposition>()
8
+
9
+ const presets = includePresets((style) => createActionIconStyle(() => ({ touchableWrapper: style })))
10
+
11
+ export const ActionIconStyles = {
12
+ ...presets,
13
+ default: createActionIconStyle((theme) => {
14
+
15
+ return {
16
+ icon: {
17
+ color: theme.colors.icon,
18
+ ...theme.sized(5 * 0.6),
19
+
20
+ },
21
+ touchableWrapper: {
22
+ ...theme.sized(5),
23
+ borderRadius: theme.borderRadius.round,
24
+ ...theme.presets.center,
25
+ },
26
+ 'icon:disabled': {
27
+ color: theme.colors.disabled,
28
+ },
29
+
30
+ }
31
+ }),
32
+ originalColor: createActionIconStyle(theme => ({
33
+ icon: {
34
+ color: 'auto',
35
+ },
36
+ })),
37
+ small: createActionIconStyle((theme) => ({
38
+ touchableWrapper: {
39
+ ...theme.sized(3.5),
40
+
41
+ },
42
+ icon: {
43
+ ...theme.sized(3.5 * 0.6),
44
+
45
+ },
46
+ })),
47
+ large: createActionIconStyle((theme) => ({
48
+ touchableWrapper: {
49
+ ...theme.sized(6.5),
50
+
51
+ },
52
+ icon: {
53
+ ...theme.sized(6.5 * 0.6),
54
+
55
+ },
56
+ })),
57
+ primary: createActionIconStyle((theme) => ({
58
+ icon: {
59
+ color: theme.colors.primary,
60
+
61
+ },
62
+
63
+ })),
64
+ negative: createActionIconStyle((theme) => ({
65
+ icon: {
66
+ color: theme.colors.negative,
67
+
68
+ },
69
+
70
+ })),
71
+ positive: createActionIconStyle((theme) => ({
72
+ icon: {
73
+ color: theme.colors.positive,
74
+
75
+ },
76
+
77
+ })),
78
+ black: createActionIconStyle((theme) => ({
79
+ icon: {
80
+ color: theme.colors.black,
81
+
82
+ },
83
+
84
+ })),
85
+ white: createActionIconStyle((theme) => ({
86
+ icon: {
87
+ color: theme.colors.white,
88
+
89
+ },
90
+
91
+ })),
92
+ neutral: createActionIconStyle((theme) => ({
93
+ icon: {
94
+ color: theme.colors.neutral,
95
+ },
96
+ })),
97
+ }
@@ -0,0 +1,50 @@
1
+ import * as React from 'react'
2
+ import { ComponentPropsWithoutRef, forwardRef } from 'react'
3
+ import { ActivityIndicator as Indicator, StyleSheet } from 'react-native'
4
+ import {
5
+
6
+ useDefaultComponentStyle,
7
+ ComponentVariants,
8
+ useCodeleapContext,
9
+ } from '@codeleap/common'
10
+ import { StylesOf } from '../../types'
11
+ import {
12
+ ActivityIndicatorComposition,
13
+ ActivityIndicatorStyles,
14
+ } from './styles'
15
+
16
+ export * from './styles'
17
+ export type ActivityIndicatorProps = ComponentPropsWithoutRef<
18
+ typeof Indicator
19
+ > & {
20
+ variants?: ComponentVariants<typeof ActivityIndicatorStyles>['variants']
21
+ styles?: StylesOf<ActivityIndicatorComposition>
22
+ }
23
+
24
+ export const ActivityIndicator = forwardRef<Indicator, ActivityIndicatorProps>(
25
+ (activityIndicatorProps, ref) => {
26
+ const { variants = [], style, styles: propStyles, ...props } = activityIndicatorProps
27
+
28
+ const variantStyles = useDefaultComponentStyle('ActivityIndicator', {
29
+ variants,
30
+ transform: StyleSheet.flatten,
31
+ styles: propStyles,
32
+ })
33
+
34
+ const { Theme } = useCodeleapContext()
35
+
36
+ const styles = StyleSheet.flatten([variantStyles.wrapper, style])
37
+ const color = styles?.color || Theme.colors.gray
38
+ const size = styles?.height || styles?.width || 'large'
39
+
40
+ return (
41
+ <Indicator
42
+ size={size}
43
+ ref={ref}
44
+ color={color}
45
+ style={styles}
46
+ {...props}
47
+ />
48
+ )
49
+ },
50
+ )
@@ -0,0 +1,68 @@
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
+
3
+ export type ActivityIndicatorComposition =
4
+ | 'wrapper'
5
+ | 'backCircle'
6
+ | 'frontCircle'
7
+ | 'circle'
8
+
9
+ const createActivityIndicatorStyle =
10
+ createDefaultVariantFactory<ActivityIndicatorComposition>()
11
+
12
+ const presets = includePresets((styles) => createActivityIndicatorStyle(() => ({ wrapper: styles })),
13
+ )
14
+
15
+ export const getActivityIndicatorBaseStyles = (size:number) => {
16
+ const sizes = {
17
+ height: size,
18
+ width: size,
19
+ borderWidth: size * 0.25,
20
+ }
21
+
22
+ return {
23
+ wrapper: {
24
+ position: 'relative',
25
+ ...sizes,
26
+ } as any,
27
+ circle: {
28
+ borderRadius: 100,
29
+ position: 'absolute',
30
+ borderStyle: 'solid',
31
+ top: 0,
32
+ bottom: 0,
33
+ left: 0,
34
+ right: 0,
35
+ } as any,
36
+ backCircle: {
37
+
38
+ // borderColor: theme.colors.primary,
39
+ minWidth: '100%',
40
+ opacity: 0.5,
41
+ } as any,
42
+ frontCircle: {
43
+ position: 'absolute',
44
+ borderColor: 'transparent',
45
+ // borderTopColor: theme.colors.primary,
46
+ } as any,
47
+ }
48
+ }
49
+
50
+ export const ActivityIndicatorStyles = {
51
+ ...presets,
52
+ default: createActivityIndicatorStyle((theme) => {
53
+ const baseStyles = getActivityIndicatorBaseStyles(35)
54
+
55
+ return {
56
+ ...baseStyles,
57
+ backCircle: {
58
+ ...baseStyles.backCircle,
59
+ borderColor: theme.colors.primary,
60
+ },
61
+ frontCircle: {
62
+ ...baseStyles.frontCircle,
63
+ borderTopColor: theme.colors.primary,
64
+ },
65
+ }
66
+
67
+ }),
68
+ }
@@ -0,0 +1,34 @@
1
+ import { onUpdate } from '@codeleap/common'
2
+ import React, { useRef } from 'react'
3
+
4
+ import posed from 'react-native-pose'
5
+ import { Touchable } from './Touchable'
6
+ import { View } from './View'
7
+ const Components = {
8
+ Touchable,
9
+ View,
10
+ }
11
+
12
+ const PosedComponents = Object.fromEntries(
13
+ Object.entries(Components).map(([key, Render]) => [key, posed(Render)]),
14
+ )
15
+
16
+ type AnimatedComponents = typeof Components
17
+ type CP = keyof AnimatedComponents
18
+
19
+ type AnimatedProps<T extends CP, CFG = Record<string, any>> = {
20
+ component: T
21
+ config: CFG
22
+ pose: keyof CFG
23
+ initialPose?: keyof CFG
24
+ } & Omit<Parameters<AnimatedComponents[T]>[0], 'component'>
25
+
26
+ export const Animated = <T extends CP, CFG = any>({
27
+ config,
28
+ component,
29
+ ...props
30
+ }: AnimatedProps<T, CFG>) => {
31
+ const Component = useRef(PosedComponents[component](config)).current
32
+
33
+ return <Component withParent={false} {...props} />
34
+ }
@@ -0,0 +1,163 @@
1
+ import * as React from 'react'
2
+ import { ComponentVariants,
3
+ FormTypes,
4
+ getNestedStylesByKey,
5
+ IconPlaceholder,
6
+ onUpdate,
7
+ PropsOf,
8
+ ReactStateProps,
9
+ TypeGuards,
10
+ useDebounce,
11
+ useDefaultComponentStyle,
12
+ useMemo,
13
+ useState,
14
+ } from '@codeleap/common'
15
+ import { ModalHeaderProps } from '../Modal'
16
+ import { TextInput, TextInputProps } from '../TextInput'
17
+ import { View, ViewProps } from '../View'
18
+ import { CustomSelectProps, Select } from '../Select'
19
+ import { AutoCompleteStyles, AutoCompleteComposition } from './styles'
20
+ import { StylesOf } from '../../types'
21
+ import { StyleSheet } from 'react-native'
22
+ import { Text } from '../Text'
23
+ import { Button } from '../Button'
24
+
25
+ export type AutoCompleteHeaderProps = ReactStateProps<'search', string> &
26
+ Omit<PropsOf<typeof View>, 'style'|'styles'|'variants'>
27
+ & {
28
+ label: FormTypes.Label
29
+ searchInputProps?: Partial<TextInputProps>
30
+ styles: ModalHeaderProps['styles'] & { searchInput?: TextInputProps['styles']; titleWrapper?:ViewProps['style']}
31
+ debugName: string
32
+ icon?: IconPlaceholder
33
+ toggle: ModalHeaderProps['toggle']
34
+ }
35
+
36
+ export const AutoCompleteHeader:React.FC<AutoCompleteHeaderProps> = (props) => {
37
+ const { search, setSearch, icon = 'search', debugName, label, styles, toggle, searchInputProps, ...viewProps } = props
38
+
39
+ return <View style={[styles.wrapper]} {...viewProps}>
40
+ <View style={styles.titleWrapper}>
41
+ <Text style={styles.title} text={label}/>
42
+ <Button
43
+ icon={'close' as IconPlaceholder}
44
+ debugName={`Close Autocomplete ${debugName} button`}
45
+ onPress={toggle} variants={['icon']}
46
+ styles={styles.closeButton}/>
47
+ </View>
48
+ <TextInput subtitle={() => null} leftIcon={{
49
+ icon: icon as IconPlaceholder,
50
+ }} debugName={`AutoComplete ${debugName} search input`} value={search} onChangeText={setSearch} styles={styles.searchInput} {...searchInputProps}/>
51
+ </View>
52
+ }
53
+
54
+ export type AutoCompleteOption<T> = CustomSelectProps<T>['options'][number] & {searchTerm?: string}
55
+
56
+ export type AutoCompleteProps<
57
+ T,
58
+ Base extends CustomSelectProps<T> = CustomSelectProps<T>
59
+ > = Omit<Base, 'options'| 'variants' | 'styles'> & {
60
+ options: AutoCompleteOption<T>[]
61
+ caseSensitive?: boolean
62
+ debounce?: number
63
+ headerProps?: Partial<AutoCompleteHeaderProps>
64
+ styles?: StylesOf<AutoCompleteComposition>
65
+ filterFn?: (search?: string, option?:AutoCompleteOption<T>) => boolean
66
+ } & ComponentVariants<typeof AutoCompleteStyles>
67
+
68
+ export const AutoComplete = <T extends string|number = string>(props: AutoCompleteProps<T>) => {
69
+ const {
70
+ options,
71
+ caseSensitive = false,
72
+ debounce = 200,
73
+ filterFn,
74
+ headerProps = {},
75
+ variants,
76
+ styles,
77
+ ...selectProps
78
+ } = props
79
+
80
+ const [search, setSearch] = useState('')
81
+ const [debouncedSearch, resetDebounce] = useDebounce(search, debounce)
82
+ const [filteredOptions, setFilteredOptions] = useState(options)
83
+
84
+ const [loading, setLoading] = useState(false)
85
+ const variantStyles = useDefaultComponentStyle<'u:AutoComplete', typeof AutoCompleteStyles>('u:AutoComplete', {
86
+ variants,
87
+ transform: StyleSheet.flatten,
88
+ styles,
89
+ })
90
+ const serialVariants = JSON.stringify(variantStyles)
91
+ const { searchInputStyles, closeButtonStyles } = useMemo(() => ({
92
+ searchInputStyles: getNestedStylesByKey('searchInput', variantStyles),
93
+ closeButtonStyles: getNestedStylesByKey('closeButton', variantStyles),
94
+
95
+ }), [serialVariants])
96
+
97
+ onUpdate(() => {
98
+ setLoading(true)
99
+ let persist = true
100
+ setTimeout(() => {
101
+
102
+ const newOpts = options.filter((option) => {
103
+ if (filterFn) {
104
+ return filterFn(debouncedSearch, option)
105
+ }
106
+ const { label, searchTerm, value } = option
107
+ let term = searchTerm || (TypeGuards.isString(label) ? label : value.toString())
108
+
109
+ if (!caseSensitive) {
110
+ term = term.toLowerCase()
111
+ }
112
+
113
+ return term.includes(debouncedSearch.toLowerCase())
114
+ })
115
+ if (persist) {
116
+ setFilteredOptions(newOpts)
117
+ setTimeout(() => {
118
+ if (persist) {
119
+ setLoading(false)
120
+ }
121
+ }, debounce * 1.5)
122
+ }
123
+
124
+ })
125
+ return () => {
126
+ persist = false
127
+ resetDebounce()
128
+ }
129
+ }, [debouncedSearch, caseSensitive, options.length, filterFn])
130
+ return <Select
131
+ styles={variantStyles}
132
+ options={ loading ? [] : filteredOptions}
133
+ header={
134
+ <AutoCompleteHeader
135
+ debugName={selectProps.debugName}
136
+ label={selectProps.label}
137
+ search={search}
138
+ setSearch={setSearch}
139
+ toggle={selectProps.toggle}
140
+ styles={{
141
+ wrapper: variantStyles.header,
142
+ closeButton: closeButtonStyles,
143
+ title: variantStyles.title,
144
+ searchInput: searchInputStyles,
145
+ titleWrapper: variantStyles.titleWrapper,
146
+ }}
147
+
148
+ {...headerProps}
149
+ />
150
+ }
151
+
152
+ {...selectProps}
153
+ listProps={{
154
+ ...selectProps?.listProps,
155
+ placeholder: {
156
+ loading,
157
+ ...selectProps?.listProps?.placeholder,
158
+ },
159
+ }}
160
+ />
161
+
162
+ }
163
+ export * from './styles'
@@ -0,0 +1,44 @@
1
+ import { assignTextStyle, createDefaultVariantFactory } from '@codeleap/common'
2
+ import { SelectComposition, SelectStyles } from '../Select'
3
+ import { TextInputComposition } from '../TextInput'
4
+
5
+ export type AutoCompleteComposition = SelectComposition | `searchInput${Capitalize<TextInputComposition>}` | 'titleWrapper'
6
+
7
+ const createAutoCompleteStyle = createDefaultVariantFactory<AutoCompleteComposition>()
8
+
9
+ export const AutoCompleteStyles = {
10
+ ...SelectStyles,
11
+ default: createAutoCompleteStyle((theme) => {
12
+ const defaultStyle = SelectStyles.default(theme)
13
+
14
+ return {
15
+ ...defaultStyle,
16
+ header: {
17
+ ...theme.spacing.paddingHorizontal(2),
18
+ ...theme.spacing.paddingTop(1),
19
+ ...theme.presets.column,
20
+ ...theme.presets.alignStart,
21
+ },
22
+
23
+ searchInputWrapper: {
24
+ ...theme.presets.fullWidth,
25
+ ...theme.spacing.marginTop(2),
26
+ },
27
+
28
+ titleWrapper: {
29
+ ...theme.presets.row,
30
+ ...theme.presets.alignCenter,
31
+ ...theme.presets.fullWidth,
32
+ ...theme.presets.justifyCenter,
33
+ },
34
+ title: {
35
+ ...theme.presets.textCenter,
36
+ flex: 1,
37
+ },
38
+ closeButtonWrapper: {
39
+ position: 'absolute',
40
+ right: 0,
41
+ },
42
+ }
43
+ }),
44
+ }
@@ -0,0 +1,48 @@
1
+ import React from 'react'
2
+ import { ComponentVariants, onUpdate, PropsOf, useDefaultComponentStyle } from '@codeleap/common'
3
+ import { useDynamicAnimation } from 'moti'
4
+ import { Touchable } from '../Touchable'
5
+ import { View } from '../View'
6
+
7
+ import { StylesOf } from '../../types/utility'
8
+ import { StyleSheet } from 'react-native'
9
+ import { useStaticAnimationStyles } from '../../utils'
10
+ import { BackdropComposition, BackdropStyles } from './styles'
11
+
12
+ export * from './styles'
13
+ export type BackdropProps = PropsOf<typeof Touchable> & {
14
+ visible: boolean
15
+ wrapperProps?: PropsOf<typeof View>
16
+ variants?: ComponentVariants<typeof BackdropStyles>['variants']
17
+ styles?: StylesOf<BackdropComposition>
18
+ }
19
+
20
+ export const Backdrop = (backdropProps:BackdropProps) => {
21
+ const { variants = [], styles = {}, visible, children, wrapperProps = {}, ...props } = backdropProps
22
+
23
+ const variantStyles = useDefaultComponentStyle<'u:Backdrop', typeof BackdropStyles>('u:Backdrop', {
24
+ variants,
25
+ rootElement: 'wrapper',
26
+ styles,
27
+ transform: StyleSheet.flatten,
28
+ })
29
+
30
+ const animationStates = useStaticAnimationStyles(variantStyles, ['wrapper:hidden', 'wrapper:visible'])
31
+
32
+ const animation = useDynamicAnimation(() => {
33
+ return visible ? animationStates['wrapper:visible'] : animationStates['wrapper:hidden']
34
+ })
35
+
36
+ onUpdate(() => {
37
+ animation.animateTo(visible ? animationStates['wrapper:visible'] : animationStates['wrapper:hidden'])
38
+ }, [visible, animationStates])
39
+
40
+ return <View pointerEvents={visible ? 'auto' : 'none' } animated style={variantStyles.wrapper} state={animation} {...wrapperProps}>
41
+ {
42
+ props?.onPress ?
43
+ <Touchable style={variantStyles.touchable} {...props} noFeedback android_ripple={null}/>
44
+ : null
45
+ }
46
+ {children}
47
+ </View>
48
+ }
@@ -0,0 +1,33 @@
1
+ import { createDefaultVariantFactory, includePresets } from '@codeleap/common'
2
+
3
+ export type BackdropComposition =
4
+ 'wrapper'|
5
+ 'touchable' |
6
+ 'wrapper:visible' |
7
+ 'wrapper:hidden'
8
+
9
+ const createBackdropVariant = createDefaultVariantFactory<BackdropComposition>()
10
+
11
+ const presets = includePresets((style) => createBackdropVariant(() => ({ wrapper: style })))
12
+
13
+ export const BackdropStyles = {
14
+ ...presets,
15
+ default: createBackdropVariant((theme) => ({
16
+ wrapper: {
17
+ backgroundColor: theme.colors.black,
18
+ ...theme.presets.whole,
19
+ ...theme.presets.absolute,
20
+ },
21
+ 'wrapper:visible': {
22
+ opacity: 0.5,
23
+ },
24
+ 'wrapper:hidden': {
25
+
26
+ opacity: 0,
27
+ },
28
+ touchable: {
29
+ ...theme.presets.whole,
30
+ ...theme.presets.absolute,
31
+ },
32
+ })),
33
+ }