@codeleap/mobile 3.5.0 → 3.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -26,7 +26,7 @@ const defaultFilterFunction = (search: string, options: FormTypes.Options<any>)
26
26
  })
27
27
  }
28
28
 
29
- const defaultProps:Partial<AutocompleteProps<any, boolean>> = {
29
+ const defaultProps: Partial<AutocompleteProps<any, boolean>> = {
30
30
  getLabel(option) {
31
31
 
32
32
  if (TypeGuards.isArray(option)) {
@@ -45,7 +45,7 @@ const defaultProps:Partial<AutocompleteProps<any, boolean>> = {
45
45
  searchComponent: SearchInput,
46
46
  }
47
47
 
48
- export const Autocomplete = <T extends string|number = string, Multi extends boolean = false>(autocomplete:AutocompleteProps<T, Multi>) => {
48
+ export const Autocomplete = <T extends string | number = string, Multi extends boolean = false>(autocomplete: AutocompleteProps<T, Multi>) => {
49
49
  const allProps = {
50
50
  ...defaultProps,
51
51
  ...autocomplete,
@@ -74,11 +74,11 @@ export const Autocomplete = <T extends string|number = string, Multi extends boo
74
74
  searchComponent,
75
75
  filterItems = defaultFilterFunction,
76
76
  searchInputProps: searchProps = {},
77
- onItemPressed = () => {},
77
+ onItemPressed = () => { },
78
78
  listPlaceholder,
79
79
  style,
80
80
  loading: loadingProp = false,
81
- ...listProps
81
+ listProps = {},
82
82
  } = allProps
83
83
 
84
84
  const isValueArray = TypeGuards.isArray(value) && multiple
@@ -54,7 +54,7 @@ export type AutocompleteProps<T = any, Multi extends boolean = false> = {
54
54
  styles?: StylesOf<AutocompleteComposition>
55
55
  style?: TextInputProps['style']
56
56
  closeOnSelect?: boolean
57
- listProps?: Partial<FlatListProps>
57
+
58
58
  keyboardAware?: GetKeyboardAwarePropsOptions
59
59
  multiple?: Multi
60
60
  itemProps?: Partial<
@@ -70,6 +70,7 @@ export type AutocompleteProps<T = any, Multi extends boolean = false> = {
70
70
  debugName: string
71
71
  searchComponent?: React.ComponentType<SearchInputProps>
72
72
  listPlaceholder?: Partial<EmptyPlaceholderProps>
73
+ listProps?: Partial<Omit<FlatListProps<T>, 'renderItem'|'styles'|'style'>>
73
74
  loading: boolean | ((isLoading: boolean) => boolean)
74
75
  }
75
76
  & Omit<FlatListProps<T>, 'renderItem'|'styles'|'style'>
@@ -30,6 +30,7 @@ export type IconProps = {
30
30
  wrapperProps?: Partial<PropsOf<typeof View>>
31
31
  size?: number
32
32
  styles?: StylesOf<IconComposition>
33
+ source?: string
33
34
  } & BadgeComponentProps
34
35
 
35
36
  export const IconComponent = (props: IconProps) => {
@@ -41,6 +42,7 @@ export const IconComponent = (props: IconProps) => {
41
42
  badgeProps = {},
42
43
  wrapperProps = {},
43
44
  styles = {},
45
+ source,
44
46
  ...otherProps
45
47
  } = props
46
48
 
@@ -55,17 +57,32 @@ export const IconComponent = (props: IconProps) => {
55
57
  },
56
58
  rootElement: 'icon',
57
59
  })
58
- const Component = Theme?.icons?.[name]
60
+ const Component = Theme?.icons?.[name] || (source && Theme.icons.RenderSource)
61
+
59
62
  onUpdate(() => {
60
63
  if (!Component && !!name) {
61
64
  logger.warn(
62
65
  `Icon: No icon found in theme for name "${name}".`,
63
- { props: { style, name, variants, variantStyles }},
66
+ { props: { style, name, variants, variantStyles } },
64
67
  'Component',
65
68
  )
69
+ } else if (!Component && !!source) {
70
+ logger.warn('Icon: Cannot render source, no RenderSource component in Theme.icons', {
71
+ source,
72
+ props: { style, name, variants, variantStyles },
73
+ Component,
74
+ }, 'Component')
66
75
  }
67
76
  }, [name])
68
77
 
78
+ if (!name && !source) {
79
+ return null
80
+ }
81
+
82
+ if (!Component) {
83
+ return null
84
+ }
85
+
69
86
  if (badge || TypeGuards.isNumber(badge)) {
70
87
  const badgeStyles = getNestedStylesByKey('badge', variantStyles)
71
88
 
@@ -80,20 +97,12 @@ export const IconComponent = (props: IconProps) => {
80
97
  ]
81
98
 
82
99
  return <View {...wrapperProps} style={wrapperStyle}>
83
- <Component {...otherProps} style={variantStyles.icon} />
100
+ <Component {...otherProps} style={variantStyles.icon} source={source} />
84
101
  <Badge styles={badgeStyles} badge={badge} {...badgeProps} />
85
102
  </View>
86
103
  }
87
104
 
88
- if (!name) {
89
- return null
90
- }
91
-
92
- if (!Component) {
93
-
94
- return null
95
- }
96
- return <Component {...otherProps} style={variantStyles.icon} />
105
+ return <Component {...otherProps} style={variantStyles.icon} source={source} />
97
106
  }
98
107
 
99
108
  function areEqual(prevProps, nextProps) {
@@ -199,8 +199,7 @@ export const Modal = (modalProps:ModalProps) => {
199
199
  showsVerticalScrollIndicator={false}
200
200
  keyboardAware
201
201
  animated
202
- // @ts-ignore
203
- ref={scrollRef}
202
+
204
203
  { ...scrollProps}
205
204
  >
206
205
  {dismissOnBackdrop &&