@codeleap/mobile 3.4.0 → 3.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/mobile",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -148,7 +148,7 @@ export const DatePickerModal = (props: DatePickerModalProps) => {
148
148
  const cancelStyle = useNestedStylesByKey('cancelButton', variantStyles)
149
149
  const confirmStyle = useNestedStylesByKey('confirmButton', variantStyles)
150
150
 
151
- const formattedDate = value ? formatDate(value) : placeholder
151
+ const formattedDate = value ? formatDate(value) : ''
152
152
  const { locale } = useI18N()
153
153
 
154
154
  const tempDate = useRef<Date|null>(null)
@@ -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) {
@@ -9,13 +9,14 @@ import {
9
9
  PropsOf,
10
10
  TypeGuards,
11
11
  useDefaultComponentStyle,
12
+ useRef,
12
13
  } from '@codeleap/common'
13
14
  import {
14
15
  ModalComposition,
15
16
  ModalPresets,
16
17
  ModalParts,
17
18
  } from './styles'
18
- import { StyleSheet } from 'react-native'
19
+ import { ScrollView, StyleSheet } from 'react-native'
19
20
  import { StylesOf } from '../../types/utility'
20
21
 
21
22
  import { Backdrop } from '../Backdrop'
@@ -129,7 +130,7 @@ export const Modal = (modalProps:ModalProps) => {
129
130
  transform: StyleSheet.flatten,
130
131
  styles,
131
132
  }) as ModalProps['styles']
132
-
133
+ const scrollRef = useRef<ScrollView>(null)
133
134
  function getStyles(key: ModalParts) {
134
135
  const s = [
135
136
  variantStyles[key],