@fountain-ui/core 1.19.0 → 2.0.0-beta.2

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 (153) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/commonjs/Accordion/Accordion.js +1 -7
  3. package/build/commonjs/Accordion/Accordion.js.map +1 -1
  4. package/build/commonjs/Button/Button.js +14 -8
  5. package/build/commonjs/Button/Button.js.map +1 -1
  6. package/build/commonjs/Checkbox/Checkbox.js +7 -2
  7. package/build/commonjs/Checkbox/Checkbox.js.map +1 -1
  8. package/build/commonjs/Chip/Chip.js +10 -9
  9. package/build/commonjs/Chip/Chip.js.map +1 -1
  10. package/build/commonjs/Fab/Fab.js +10 -3
  11. package/build/commonjs/Fab/Fab.js.map +1 -1
  12. package/build/commonjs/IconButton/IconButton.js +13 -3
  13. package/build/commonjs/IconButton/IconButton.js.map +1 -1
  14. package/build/commonjs/Image/Image.js +13 -1
  15. package/build/commonjs/Image/Image.js.map +1 -1
  16. package/build/commonjs/Radio/Radio.js +12 -11
  17. package/build/commonjs/Radio/Radio.js.map +1 -1
  18. package/build/commonjs/SvgIcon/SvgIcon.js +6 -2
  19. package/build/commonjs/SvgIcon/SvgIcon.js.map +1 -1
  20. package/build/commonjs/Switch/Switch.js +1 -1
  21. package/build/commonjs/Switch/Switch.js.map +1 -1
  22. package/build/commonjs/TextField/InputLabel.js +5 -2
  23. package/build/commonjs/TextField/InputLabel.js.map +1 -1
  24. package/build/commonjs/TextField/OutlinedTextField.js +2 -1
  25. package/build/commonjs/TextField/OutlinedTextField.js.map +1 -1
  26. package/build/commonjs/hooks/useFadeInAppBar.js +5 -2
  27. package/build/commonjs/hooks/useFadeInAppBar.js.map +1 -1
  28. package/build/commonjs/internal/icons/Checkbox.js +1 -2
  29. package/build/commonjs/internal/icons/Checkbox.js.map +1 -1
  30. package/build/commonjs/internal/icons/CheckboxChecked.js +3 -2
  31. package/build/commonjs/internal/icons/CheckboxChecked.js.map +1 -1
  32. package/build/commonjs/internal/icons/ChevronDown.js +0 -2
  33. package/build/commonjs/internal/icons/ChevronDown.js.map +1 -1
  34. package/build/commonjs/internal/icons/ChevronLeft.js +0 -2
  35. package/build/commonjs/internal/icons/ChevronLeft.js.map +1 -1
  36. package/build/commonjs/internal/icons/ChevronRight.js +0 -2
  37. package/build/commonjs/internal/icons/ChevronRight.js.map +1 -1
  38. package/build/commonjs/internal/icons/Close.js +0 -2
  39. package/build/commonjs/internal/icons/Close.js.map +1 -1
  40. package/build/commonjs/internal/icons/Radio.js.map +1 -1
  41. package/build/commonjs/internal/icons/RadioChecked.js.map +1 -1
  42. package/build/commonjs/styles/index.js +0 -8
  43. package/build/commonjs/styles/index.js.map +1 -1
  44. package/build/commonjs/utils/cloneElementSafely.js +15 -0
  45. package/build/commonjs/utils/cloneElementSafely.js.map +1 -0
  46. package/build/commonjs/utils/index.js +8 -0
  47. package/build/commonjs/utils/index.js.map +1 -1
  48. package/build/module/Accordion/Accordion.js +1 -7
  49. package/build/module/Accordion/Accordion.js.map +1 -1
  50. package/build/module/Button/Button.js +13 -9
  51. package/build/module/Button/Button.js.map +1 -1
  52. package/build/module/Checkbox/Checkbox.js +7 -2
  53. package/build/module/Checkbox/Checkbox.js.map +1 -1
  54. package/build/module/Chip/Chip.js +10 -10
  55. package/build/module/Chip/Chip.js.map +1 -1
  56. package/build/module/Fab/Fab.js +10 -4
  57. package/build/module/Fab/Fab.js.map +1 -1
  58. package/build/module/IconButton/IconButton.js +12 -4
  59. package/build/module/IconButton/IconButton.js.map +1 -1
  60. package/build/module/Image/Image.js +13 -1
  61. package/build/module/Image/Image.js.map +1 -1
  62. package/build/module/Radio/Radio.js +11 -11
  63. package/build/module/Radio/Radio.js.map +1 -1
  64. package/build/module/SvgIcon/SvgIcon.js +7 -3
  65. package/build/module/SvgIcon/SvgIcon.js.map +1 -1
  66. package/build/module/Switch/Switch.js +1 -1
  67. package/build/module/Switch/Switch.js.map +1 -1
  68. package/build/module/TextField/InputLabel.js +4 -2
  69. package/build/module/TextField/InputLabel.js.map +1 -1
  70. package/build/module/TextField/OutlinedTextField.js +2 -1
  71. package/build/module/TextField/OutlinedTextField.js.map +1 -1
  72. package/build/module/hooks/useFadeInAppBar.js +3 -2
  73. package/build/module/hooks/useFadeInAppBar.js.map +1 -1
  74. package/build/module/internal/icons/Checkbox.js +1 -2
  75. package/build/module/internal/icons/Checkbox.js.map +1 -1
  76. package/build/module/internal/icons/CheckboxChecked.js +3 -2
  77. package/build/module/internal/icons/CheckboxChecked.js.map +1 -1
  78. package/build/module/internal/icons/ChevronDown.js +0 -2
  79. package/build/module/internal/icons/ChevronDown.js.map +1 -1
  80. package/build/module/internal/icons/ChevronLeft.js +0 -2
  81. package/build/module/internal/icons/ChevronLeft.js.map +1 -1
  82. package/build/module/internal/icons/ChevronRight.js +0 -2
  83. package/build/module/internal/icons/ChevronRight.js.map +1 -1
  84. package/build/module/internal/icons/Close.js +0 -2
  85. package/build/module/internal/icons/Close.js.map +1 -1
  86. package/build/module/internal/icons/Radio.js.map +1 -1
  87. package/build/module/internal/icons/RadioChecked.js.map +1 -1
  88. package/build/module/styles/index.js +0 -1
  89. package/build/module/styles/index.js.map +1 -1
  90. package/build/module/utils/cloneElementSafely.js +6 -0
  91. package/build/module/utils/cloneElementSafely.js.map +1 -0
  92. package/build/module/utils/index.js +1 -0
  93. package/build/module/utils/index.js.map +1 -1
  94. package/build/typescript/Button/ButtonProps.d.ts +2 -2
  95. package/build/typescript/Checkbox/CheckboxProps.d.ts +7 -1
  96. package/build/typescript/Fab/FabProps.d.ts +2 -2
  97. package/build/typescript/IconButton/IconButtonProps.d.ts +2 -2
  98. package/build/typescript/Image/ImageProps.d.ts +8 -0
  99. package/build/typescript/Slider/Slider.d.ts +1 -1
  100. package/build/typescript/SvgIcon/SvgIconProps.d.ts +7 -6
  101. package/build/typescript/Switch/SwitchProps.d.ts +2 -2
  102. package/build/typescript/hooks/useFadeInAppBar.d.ts +0 -1
  103. package/build/typescript/internal/icons/Checkbox.d.ts +19 -18
  104. package/build/typescript/internal/icons/CheckboxChecked.d.ts +19 -18
  105. package/build/typescript/internal/icons/ChevronDown.d.ts +19 -18
  106. package/build/typescript/internal/icons/ChevronLeft.d.ts +19 -18
  107. package/build/typescript/internal/icons/ChevronRight.d.ts +19 -18
  108. package/build/typescript/internal/icons/Close.d.ts +19 -18
  109. package/build/typescript/internal/icons/Radio.d.ts +19 -18
  110. package/build/typescript/internal/icons/RadioChecked.d.ts +19 -18
  111. package/build/typescript/styles/index.d.ts +0 -1
  112. package/build/typescript/types/index.d.ts +1 -0
  113. package/build/typescript/utils/cloneElementSafely.d.ts +4 -0
  114. package/build/typescript/utils/index.d.ts +1 -0
  115. package/package.json +4 -4
  116. package/src/Accordion/Accordion.tsx +1 -4
  117. package/src/Button/Button.tsx +18 -3
  118. package/src/Button/ButtonProps.ts +2 -7
  119. package/src/Checkbox/Checkbox.tsx +3 -2
  120. package/src/Checkbox/CheckboxProps.ts +9 -1
  121. package/src/Chip/Chip.tsx +11 -4
  122. package/src/Fab/Fab.tsx +14 -4
  123. package/src/Fab/FabProps.ts +2 -8
  124. package/src/IconButton/IconButton.tsx +16 -4
  125. package/src/IconButton/IconButtonProps.ts +2 -7
  126. package/src/Image/Image.tsx +12 -1
  127. package/src/Image/ImageProps.ts +10 -0
  128. package/src/Radio/Radio.tsx +7 -15
  129. package/src/SvgIcon/SvgIcon.tsx +11 -5
  130. package/src/SvgIcon/SvgIconProps.ts +8 -6
  131. package/src/Switch/Switch.tsx +1 -1
  132. package/src/Switch/SwitchProps.ts +2 -8
  133. package/src/TextField/InputLabel.tsx +6 -3
  134. package/src/TextField/OutlinedTextField.tsx +2 -1
  135. package/src/hooks/useFadeInAppBar.ts +4 -3
  136. package/src/internal/icons/Checkbox.tsx +3 -3
  137. package/src/internal/icons/CheckboxChecked.tsx +5 -3
  138. package/src/internal/icons/ChevronDown.tsx +3 -4
  139. package/src/internal/icons/ChevronLeft.tsx +3 -4
  140. package/src/internal/icons/ChevronRight.tsx +3 -4
  141. package/src/internal/icons/Close.tsx +3 -4
  142. package/src/internal/icons/Radio.tsx +4 -2
  143. package/src/internal/icons/RadioChecked.tsx +4 -2
  144. package/src/styles/index.ts +0 -1
  145. package/src/types/index.ts +7 -0
  146. package/src/utils/cloneElementSafely.ts +9 -0
  147. package/src/utils/index.ts +1 -0
  148. package/build/commonjs/styles/cloneSvgIcon.js +0 -37
  149. package/build/commonjs/styles/cloneSvgIcon.js.map +0 -1
  150. package/build/module/styles/cloneSvgIcon.js +0 -25
  151. package/build/module/styles/cloneSvgIcon.js.map +0 -1
  152. package/build/typescript/styles/cloneSvgIcon.d.ts +0 -12
  153. package/src/styles/cloneSvgIcon.ts +0 -39
@@ -1,13 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { ButtonBaseProps } from '../ButtonBase';
3
- import type { OverridableComponentProps } from '../types';
3
+ import type { OverridableComponentProps, CommonComponentColor } from '../types';
4
4
 
5
- export type ButtonColor =
6
- | 'primary'
7
- | 'secondary'
8
- | 'tertiary'
9
- | 'warning'
10
- | 'accent';
5
+ export type ButtonColor = CommonComponentColor;
11
6
 
12
7
  export type ButtonSize = 'small' | 'medium';
13
8
 
@@ -22,6 +22,7 @@ export default function Checkbox(props: CheckboxProps) {
22
22
  const {
23
23
  checked = false,
24
24
  checkedIcon: checkedIconProp,
25
+ color = 'primary',
25
26
  disabled = false,
26
27
  icon: iconProp,
27
28
  onChange,
@@ -31,8 +32,8 @@ export default function Checkbox(props: CheckboxProps) {
31
32
 
32
33
  const styles = useStyles();
33
34
 
34
- const uncheckedIcon = iconProp ? iconProp : <CheckboxIcon/>;
35
- const checkedIcon = checkedIconProp ? checkedIconProp : <CheckboxCheckedIcon/>;
35
+ const uncheckedIcon = iconProp ? iconProp : <CheckboxIcon color={color}/>;
36
+ const checkedIcon = checkedIconProp ? checkedIconProp : <CheckboxCheckedIcon color={color}/>;
36
37
 
37
38
  const handlePress = () => {
38
39
  if (onChange) {
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
- import type { OverridableComponentProps } from '../types';
2
+ import type { CommonComponentColor, OverridableComponentProps } from '../types';
3
3
  import type { ButtonBaseProps } from '../ButtonBase';
4
4
 
5
5
  type BaseProps = Omit<ButtonBaseProps, 'onPress'>;
6
6
 
7
+ export type CheckboxColor = CommonComponentColor;
8
+
7
9
  export default interface CheckboxProps extends OverridableComponentProps<BaseProps, {
8
10
  /**
9
11
  * If `true`, the component is checked.
@@ -16,6 +18,12 @@ export default interface CheckboxProps extends OverridableComponentProps<BasePro
16
18
  */
17
19
  checkedIcon?: React.ReactElement;
18
20
 
21
+ /**
22
+ * The color of the component. It supports those theme colors that make sense for this component.
23
+ * @default 'primary'
24
+ */
25
+ color?: CheckboxColor;
26
+
19
27
  /**
20
28
  * If `true`, the checkbox is disabled.
21
29
  * @default false
package/src/Chip/Chip.tsx CHANGED
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Text } from 'react-native';
3
3
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
- import { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';
4
+ import { createFontStyle, css, useTheme } from '../styles';
5
+ import { cloneElementSafely } from '../utils';
5
6
  import ButtonBase from '../ButtonBase';
6
7
  import type ChipProps from './ChipProps';
7
8
 
8
9
  type ChipStyles = NamedStylesStringUnion<'root'>;
9
10
 
10
- const ICON_SIZE = 'tiny';
11
+ const ICON_SIZE = 16;
11
12
 
12
13
  const useStyles: UseStyles<ChipStyles> = function (): ChipStyles {
13
14
  const theme = useTheme();
@@ -83,8 +84,14 @@ export default function Chip(props: ChipProps) {
83
84
  { textAlign: 'center' },
84
85
  ]);
85
86
 
86
- const startIcon = cloneSvgIcon(startIconProp, { size: ICON_SIZE, color: fontColor });
87
- const endIcon = cloneSvgIcon(endIconProp, { size: ICON_SIZE, color: fontColor });
87
+ const iconProps = {
88
+ width: ICON_SIZE,
89
+ height: ICON_SIZE,
90
+ colorValue: fontColor,
91
+ };
92
+
93
+ const startIcon = cloneElementSafely(startIconProp, iconProps);
94
+ const endIcon = cloneElementSafely(endIconProp, iconProps);
88
95
 
89
96
  return (
90
97
  <ButtonBase
package/src/Fab/Fab.tsx CHANGED
@@ -2,12 +2,21 @@ import React from 'react';
2
2
  import { Text } from 'react-native';
3
3
  import ButtonBase from '../ButtonBase';
4
4
  import { useElevationStyle } from '../hooks';
5
- import { cloneSvgIcon, createFontStyle, css, StyleSheet, useTheme } from '../styles';
5
+ import { createFontStyle, css, StyleSheet, useTheme } from '../styles';
6
+ import { cloneElementSafely } from '../utils';
6
7
  import type FabProps from './FabProps';
8
+ import type { FabSize } from './FabProps';
7
9
 
8
10
  const SMALL = 32;
9
11
  const MEDIUM = 48;
10
12
 
13
+ type IconSizes = { [n in FabSize]: number };
14
+
15
+ const iconSizes: IconSizes = {
16
+ small: 20,
17
+ medium: 24,
18
+ };
19
+
11
20
  const styles = StyleSheet.create({
12
21
  medium: {
13
22
  borderRadius: MEDIUM * 0.5,
@@ -50,9 +59,10 @@ export default function Fab(props: FabProps) {
50
59
  const backgroundColor = theme.palette[color].main;
51
60
  const fontColor = theme.palette[color].contrastTextColor;
52
61
 
53
- const icon = cloneSvgIcon(children, {
54
- size,
55
- color: fontColor,
62
+ const icon = cloneElementSafely(children, {
63
+ width: iconSizes[size],
64
+ height: iconSizes[size],
65
+ colorValue: fontColor,
56
66
  });
57
67
 
58
68
  const elevationStyle = useElevationStyle(elevation);
@@ -1,15 +1,9 @@
1
1
  import React from 'react';
2
2
  import type { ButtonBaseProps } from '../ButtonBase';
3
- import type { OverridableComponentProps } from '../types';
3
+ import type { OverridableComponentProps, CommonComponentColor } from '../types';
4
4
  import type { Elevation } from '@fountain-ui/styles';
5
5
 
6
- export type FabColor =
7
- | 'primary'
8
- | 'secondary'
9
- | 'tertiary'
10
- | 'warning'
11
- | 'accent'
12
- | 'surface';
6
+ export type FabColor = CommonComponentColor | 'surface';
13
7
 
14
8
  export type FabSize = 'small' | 'medium';
15
9
 
@@ -2,11 +2,22 @@ import React from 'react';
2
2
  import { Text } from 'react-native';
3
3
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
4
  import ButtonBase from '../ButtonBase';
5
- import { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';
5
+ import { createFontStyle, css, useTheme } from '../styles';
6
+ import { cloneElementSafely } from '../utils';
6
7
  import type IconButtonProps from './IconButtonProps';
8
+ import type { IconButtonSize } from './IconButtonProps';
7
9
 
8
10
  type IconButtonStyles = NamedStylesStringUnion<'root'>;
9
11
 
12
+ type IconSizes = { [n in IconButtonSize]: number };
13
+
14
+ const iconSizes: IconSizes = {
15
+ tiny: 16,
16
+ small: 20,
17
+ medium: 24,
18
+ large: 28,
19
+ };
20
+
10
21
  const useStyles: UseStyles<IconButtonStyles> = function (): IconButtonStyles {
11
22
  const theme = useTheme();
12
23
 
@@ -35,9 +46,10 @@ export default function IconButton(props: IconButtonProps) {
35
46
  const theme = useTheme();
36
47
  const styles = useStyles();
37
48
 
38
- const icon = cloneSvgIcon(children, {
39
- color: theme.palette[color].main,
40
- size,
49
+ const icon = cloneElementSafely(children, {
50
+ width: iconSizes[size],
51
+ height: iconSizes[size],
52
+ color: color,
41
53
  });
42
54
 
43
55
  const fontStyle = createFontStyle(theme, {
@@ -1,13 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { ButtonBaseProps } from '../ButtonBase';
3
- import type { OverridableComponentProps } from '../types';
3
+ import type { CommonComponentColor, OverridableComponentProps } from '../types';
4
4
 
5
- export type IconButtonColor =
6
- | 'primary'
7
- | 'secondary'
8
- | 'tertiary'
9
- | 'warning'
10
- | 'accent';
5
+ export type IconButtonColor = CommonComponentColor;
11
6
 
12
7
  export type IconButtonSize = 'medium' | 'large' | 'small' | 'tiny';
13
8
 
@@ -44,6 +44,8 @@ export default function Image(props: ImageProps) {
44
44
  source,
45
45
  style,
46
46
  square = false,
47
+ onLoad,
48
+ onError,
47
49
  ...otherProps
48
50
  } = props;
49
51
 
@@ -51,6 +53,14 @@ export default function Image(props: ImageProps) {
51
53
 
52
54
  const styles = useStyles();
53
55
 
56
+ const handleError = () => {
57
+ if(onError){
58
+ onError();
59
+ }
60
+
61
+ setFailed(true);
62
+ }
63
+
54
64
  return (
55
65
  <View
56
66
  style={css([
@@ -69,7 +79,8 @@ export default function Image(props: ImageProps) {
69
79
  alt={alt}
70
80
  height={'100%'}
71
81
  loading={loading}
72
- onError={() => setFailed(true)}
82
+ onError={handleError}
83
+ onLoad={onLoad}
73
84
  resizeMode={resizeMode}
74
85
  source={source}
75
86
  width={'100%'}
@@ -30,6 +30,16 @@ export default interface ImageProps extends OverridableComponentProps<ViewProps,
30
30
  */
31
31
  loading?: Loading;
32
32
 
33
+ /**
34
+ * error event handler
35
+ */
36
+ onError?: () => void;
37
+
38
+ /**
39
+ * image loaded event handler
40
+ */
41
+ onLoad?: () => void;
42
+
33
43
  /**
34
44
  * The children on top this image.
35
45
  */
@@ -8,6 +8,8 @@ import type RadioProps from './RadioProps';
8
8
 
9
9
  type RadioStyles = NamedStylesStringUnion<'root'>;
10
10
 
11
+ const ICON_SIZE = 20;
12
+
11
13
  const useStyles: UseStyles<RadioStyles> = function (): RadioStyles {
12
14
  return {
13
15
  root: {
@@ -43,8 +45,9 @@ export default function Radio(props: RadioProps) {
43
45
 
44
46
  const isChecked = context?.value === value ?? checked;
45
47
 
46
- const color = theme.palette.tertiary.main;
47
- const checkedColor = theme.palette.primary.main;
48
+ const icon = isChecked
49
+ ? <RadioCheckedIcon width={ICON_SIZE} height={ICON_SIZE} color={'primary'}/>
50
+ : <RadioIcon width={ICON_SIZE} height={ICON_SIZE} color={'tertiary'}/>;
48
51
 
49
52
  const rootStyle = css([
50
53
  styles.root,
@@ -58,19 +61,8 @@ export default function Radio(props: RadioProps) {
58
61
  style={rootStyle}
59
62
  {...otherProps}
60
63
  >
61
- {isChecked ? (
62
- <RadioCheckedIcon
63
- fill={checkedColor}
64
- height={20}
65
- width={20}
66
- />
67
- ) : (
68
- <RadioIcon
69
- fill={color}
70
- height={20}
71
- width={20}
72
- />
73
- )}
64
+ {icon}
65
+
74
66
  {children ? children : null}
75
67
  </ButtonBase>
76
68
  );
@@ -1,11 +1,12 @@
1
1
  import React from 'react';
2
2
  import Svg from 'react-native-svg';
3
- import { css } from '../styles';
3
+ import { css, useTheme } from '../styles';
4
4
  import type SvgIconProps from './SvgIconProps';
5
5
 
6
6
  export default function SvgIcon(props: SvgIconProps) {
7
7
  const {
8
- fill = '#000',
8
+ color: colorProp = 'primary',
9
+ colorValue,
9
10
  height = 24,
10
11
  style: styleProp,
11
12
  viewBox = '0 0 20 20',
@@ -13,14 +14,19 @@ export default function SvgIcon(props: SvgIconProps) {
13
14
  ...otherProps
14
15
  }: SvgIconProps = props;
15
16
 
17
+ const theme = useTheme();
18
+
19
+ const color = colorValue ?? theme.palette[colorProp].main;
20
+
16
21
  const style = css([
17
- { flexShrink : 0 },
22
+ { flexShrink: 0 },
18
23
  styleProp,
19
24
  ]);
20
25
 
21
26
  return (
22
27
  <Svg
23
- fill={fill}
28
+ color={color}
29
+ fill={'currentColor'}
24
30
  height={height}
25
31
  style={style}
26
32
  viewBox={viewBox}
@@ -28,4 +34,4 @@ export default function SvgIcon(props: SvgIconProps) {
28
34
  {...otherProps}
29
35
  />
30
36
  );
31
- };
37
+ };
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { SvgProps } from 'react-native-svg';
3
- import type { OverridableComponentProps } from '../types';
3
+ import type { CommonComponentColor, OverridableComponentProps } from '../types';
4
+
5
+ export type SvgIconColor = CommonComponentColor;
4
6
 
5
7
  export default interface SvgIconProps extends OverridableComponentProps<SvgProps, {
6
8
  /**
@@ -9,15 +11,15 @@ export default interface SvgIconProps extends OverridableComponentProps<SvgProps
9
11
  children: React.ReactNode;
10
12
 
11
13
  /**
12
- * The color of the component.
14
+ * The color of the component. It supports those theme colors that make sense for this component.
15
+ * @default 'primary'
13
16
  */
14
- color?: SvgProps['color'];
17
+ color?: SvgIconColor;
15
18
 
16
19
  /**
17
- * The fill color of the component.
18
- * @default '#000'
20
+ * The color of the component. It is treated as higher priority than `color` prop if provided.
19
21
  */
20
- fill?: SvgProps['fill'];
22
+ colorValue?: string;
21
23
 
22
24
  /**
23
25
  * The height applied to the icon.
@@ -23,7 +23,7 @@ export default function Switch(props: SwitchProps) {
23
23
  ? undefined
24
24
  : disabled
25
25
  ? disabledColor
26
- : theme.palette.background.default;
26
+ : '#fff';
27
27
 
28
28
  const trackColor = Platform.OS === 'ios'
29
29
  ? accentColor
@@ -1,13 +1,7 @@
1
1
  import { SwitchProps as RNSwitchProps } from 'react-native';
2
- import type { OverridableComponentProps } from '../types';
2
+ import type { CommonComponentColor, OverridableComponentProps } from '../types';
3
3
 
4
- export type SwitchColor =
5
- | 'primary'
6
- | 'secondary'
7
- | 'tertiary'
8
- | 'warning'
9
- | 'error'
10
- | 'accent';
4
+ export type SwitchColor = CommonComponentColor;
11
5
 
12
6
  export default interface SwitchProps extends OverridableComponentProps<RNSwitchProps, {
13
7
  /**
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Animated, LayoutChangeEvent, StyleSheet } from 'react-native';
3
3
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
+ import { useTheme } from '../styles';
4
5
  import { inputPaddingHorizontal } from './utils';
5
6
 
6
7
  interface LabelProps {
@@ -29,6 +30,8 @@ interface LabelProps {
29
30
  type InputLabelStyles = NamedStylesStringUnion<'background' | 'backgroundText' | 'placeholder'>;
30
31
 
31
32
  const useStyles: UseStyles<InputLabelStyles> = function (): InputLabelStyles {
33
+ const theme = useTheme();
34
+
32
35
  return {
33
36
  background: {
34
37
  position: 'absolute',
@@ -38,14 +41,14 @@ const useStyles: UseStyles<InputLabelStyles> = function (): InputLabelStyles {
38
41
  right: 0,
39
42
  width: 8,
40
43
  height: 2,
41
- backgroundColor: '#fff',
44
+ backgroundColor: theme.palette.background.default,
42
45
  },
43
46
  backgroundText: {
44
47
  position: 'absolute',
45
48
  left: 18,
46
49
  paddingHorizontal: 0,
47
50
  color: 'transparent',
48
- backgroundColor: '#fff',
51
+ backgroundColor: theme.palette.background.default,
49
52
  },
50
53
  placeholder: {
51
54
  position: 'absolute',
@@ -216,4 +219,4 @@ const InputLabel = (props: LabelProps) => {
216
219
  ) : null);
217
220
  };
218
221
 
219
- export default InputLabel;
222
+ export default InputLabel;
@@ -34,7 +34,7 @@ const useStyles: UseStyles<OutlinedTextFieldStyles> = function (): OutlinedTextF
34
34
  left: 0,
35
35
  right: 0,
36
36
  bottom: 0,
37
- backgroundColor: '#fff',
37
+ backgroundColor: theme.palette.background.default,
38
38
  borderRadius: theme.shape.roundness,
39
39
  },
40
40
  input: {
@@ -196,6 +196,7 @@ const OutlinedTextField = React.forwardRef<TextInput, OutlinedTextFieldProps>(fu
196
196
  <TextInput
197
197
  autoCapitalize={'none'}
198
198
  autoCorrect={false}
199
+ disableFullscreenUI={true}
199
200
  ref={ref}
200
201
  onChangeText={onChangeText}
201
202
  placeholder={placeholder}
@@ -4,6 +4,7 @@ import Animated from 'react-native-reanimated';
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
5
  import { rgb } from '@fountain-ui/utils';
6
6
  import { useHeight } from '../internal/hooks';
7
+ import { useTheme } from '../styles';
7
8
  import useAppbarStyles from './useAppbarStyles';
8
9
 
9
10
  type ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | Falsy>;
@@ -13,7 +14,6 @@ type OnScroll = ScrollViewProps['onScroll'];
13
14
  type OnLayoutCallback = ViewProps['onLayout'];
14
15
 
15
16
  export interface Options {
16
- backgroundColor?: string;
17
17
  fadeInBeginY?: number | ((endY: number, appBarHeight: number) => number);
18
18
  fadeInEndY?: number | ((appBarHeight: number) => number);
19
19
  floating?: boolean;
@@ -31,7 +31,6 @@ export interface FadeInAppBar {
31
31
  }
32
32
 
33
33
  const defaultOptions: Required<Options> = {
34
- backgroundColor: '#ffffff',
35
34
  fadeInBeginY: (endY, appBarHeight) => endY - appBarHeight,
36
35
  fadeInEndY: (appBarHeight) => appBarHeight,
37
36
  floating: true,
@@ -43,7 +42,6 @@ const shadowOffset = Platform.OS === 'ios' ? { width: 0, height: 3 } : undefined
43
42
 
44
43
  export default function useFadeInAppBar(userOptions: Options = defaultOptions): FadeInAppBar {
45
44
  const {
46
- backgroundColor,
47
45
  fadeInBeginY,
48
46
  fadeInEndY,
49
47
  floating,
@@ -54,6 +52,8 @@ export default function useFadeInAppBar(userOptions: Options = defaultOptions):
54
52
  ...userOptions,
55
53
  };
56
54
 
55
+ const theme = useTheme();
56
+
57
57
  const styles = useAppbarStyles();
58
58
 
59
59
  const safeAreaInsets = useSafeAreaInsets();
@@ -76,6 +76,7 @@ export default function useFadeInAppBar(userOptions: Options = defaultOptions):
76
76
  const lastOffsetY = Animated.useSharedValue<number>(0);
77
77
  const normalized = Animated.useSharedValue<number>(0);
78
78
 
79
+ const backgroundColor = theme.palette.background.default;
79
80
  const [r, g, b] = React.useMemo(() => rgb(backgroundColor), [backgroundColor]);
80
81
 
81
82
  const animatedAppBarStyle = Animated.useAnimatedStyle(() => ({
@@ -5,6 +5,6 @@ import { createSvgIcon } from '../../utils';
5
5
  export default createSvgIcon(
6
6
  <Path
7
7
  d="M13 4.5C14.3807 4.5 15.5 5.61929 15.5 7V13C15.5 14.3807 14.3807 15.5 13 15.5H7C5.61929 15.5 4.5 14.3807 4.5 13V7C4.5 5.61929 5.61929 4.5 7 4.5H13ZM7 3C4.79086 3 3 4.79086 3 7V13C3 15.2091 4.79086 17 7 17H13C15.2091 17 17 15.2091 17 13V7C17 4.79086 15.2091 3 13 3H7Z"
8
- fill="#767676"
9
- />
10
- , 'Checkbox');
8
+ />,
9
+ 'Checkbox',
10
+ );
@@ -5,12 +5,14 @@ import { createSvgIcon } from '../../utils';
5
5
  export default createSvgIcon(
6
6
  <React.Fragment>
7
7
  <Path
8
+ fillRule="evenodd"
9
+ clipRule="evenodd"
8
10
  d="M3 7C3 4.79086 4.79086 3 7 3H13C15.2091 3 17 4.79086 17 7V13C17 15.2091 15.2091 17 13 17H7C4.79086 17 3 15.2091 3 13V7Z"
9
- fill="#242424"
10
11
  />
11
12
  <Path
12
13
  d="M14.8303 7.53033L8.32856 14.0321L4.96967 10.6732L6.03033 9.61252L8.32856 11.9108L13.7697 6.46967L14.8303 7.53033Z"
13
14
  fill="#FFFFFF"
14
15
  />
15
- </React.Fragment>
16
- , 'CheckboxChecked');
16
+ </React.Fragment>,
17
+ 'CheckboxChecked',
18
+ );
@@ -4,8 +4,7 @@ import { createSvgIcon } from '../../utils';
4
4
 
5
5
  export default createSvgIcon(
6
6
  <Path
7
- fillRule="evenodd"
8
- clipRule="evenodd"
9
7
  d="M9.51967 13.2803L4.01967 7.78033L5.08033 6.71967L10.05 11.6893L15.0197 6.71967L16.0803 7.78033L10.5803 13.2803L9.51967 13.2803Z"
10
- />
11
- , 'ChevronDown');
8
+ />,
9
+ 'ChevronDown',
10
+ );
@@ -4,8 +4,7 @@ import { createSvgIcon } from '../../utils';
4
4
 
5
5
  export default createSvgIcon(
6
6
  <Path
7
- fillRule="evenodd"
8
- clipRule="evenodd"
9
7
  d="M6.76965 9.46973L12.2697 3.96973L13.3303 5.03039L8.36064 10.0001L13.3303 14.9697L12.2697 16.0304L6.76965 10.5304L6.76965 9.46973Z"
10
- />
11
- , 'ChevronLeft');
8
+ />,
9
+ 'ChevronLeft',
10
+ );
@@ -4,8 +4,7 @@ import { createSvgIcon } from '../../utils';
4
4
 
5
5
  export default createSvgIcon(
6
6
  <Path
7
- fillRule="evenodd"
8
- clipRule="evenodd"
9
7
  d="M13.3303 10.5303L7.83032 16.0303L6.76966 14.9697L11.7393 10L6.76966 5.03033L7.83032 3.96968L13.3303 9.46967V10.5303Z"
10
- />
11
- , 'ChevronRight');
8
+ />,
9
+ 'ChevronRight',
10
+ );
@@ -4,8 +4,7 @@ import { createSvgIcon } from '../../utils';
4
4
 
5
5
  export default createSvgIcon(
6
6
  <Path
7
- fillRule="evenodd"
8
- clipRule="evenodd"
9
7
  d="M3.96968 14.9697L5.03034 16.0303L10 11.0607L14.9697 16.0303L16.0303 14.9697L11.0607 10L16.0303 5.03033L14.9697 3.96967L10 8.93934L5.03034 3.96968L3.96968 5.03033L8.93935 10L3.96968 14.9697Z"
10
- />
11
- , 'Close');
8
+ />,
9
+ 'Close',
10
+ );
@@ -4,5 +4,7 @@ import { createSvgIcon } from '../../utils';
4
4
 
5
5
  export default createSvgIcon(
6
6
  <Path
7
- d="M10 16.5C6.41015 16.5 3.5 13.5899 3.5 10C3.5 6.41015 6.41015 3.5 10 3.5C13.5899 3.5 16.5 6.41015 16.5 10C16.5 13.5899 13.5899 16.5 10 16.5ZM10 18C14.4183 18 18 14.4183 18 10C18 5.58172 14.4183 2 10 2C5.58172 2 2 5.58172 2 10C2 14.4183 5.58172 18 10 18Z"/>
8
- , 'Radio');
7
+ d="M10 16.5C6.41015 16.5 3.5 13.5899 3.5 10C3.5 6.41015 6.41015 3.5 10 3.5C13.5899 3.5 16.5 6.41015 16.5 10C16.5 13.5899 13.5899 16.5 10 16.5ZM10 18C14.4183 18 18 14.4183 18 10C18 5.58172 14.4183 2 10 2C5.58172 2 2 5.58172 2 10C2 14.4183 5.58172 18 10 18Z"
8
+ />,
9
+ 'Radio',
10
+ );
@@ -4,5 +4,7 @@ import { createSvgIcon } from '../../utils';
4
4
 
5
5
  export default createSvgIcon(
6
6
  <Path
7
- d="M16.5 10C16.5 6.41015 13.5899 3.5 10 3.5C6.41015 3.5 3.5 6.41015 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10ZM18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2C14.4183 2 18 5.58172 18 10ZM10 15C7.23858 15 5 12.7614 5 10C5 7.23858 7.23858 5 10 5C12.7614 5 15 7.23858 15 10C15 12.7614 12.7614 15 10 15Z"/>
8
- , 'RadioChecked');
7
+ d="M16.5 10C16.5 6.41015 13.5899 3.5 10 3.5C6.41015 3.5 3.5 6.41015 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10ZM18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2C14.4183 2 18 5.58172 18 10ZM10 15C7.23858 15 5 12.7614 5 10C5 7.23858 7.23858 5 10 5C12.7614 5 15 7.23858 15 10C15 12.7614 12.7614 15 10 15Z"
8
+ />,
9
+ 'RadioChecked',
10
+ );
@@ -1,4 +1,3 @@
1
- export { default as cloneSvgIcon } from './cloneSvgIcon';
2
1
  export { default as createFontStyle } from './createFontStyle';
3
2
  export { default as EdgeInsets } from './EdgeInsets';
4
3
  export type { EdgeInsetsType } from './EdgeInsets';
@@ -13,3 +13,10 @@ export interface BaseProps extends Readonly<{
13
13
  }> {}
14
14
 
15
15
  export type { Theme } from '@fountain-ui/styles';
16
+
17
+ export type CommonComponentColor =
18
+ | 'primary'
19
+ | 'secondary'
20
+ | 'tertiary'
21
+ | 'warning'
22
+ | 'accent';
@@ -0,0 +1,9 @@
1
+ import { cloneElement, ReactElement } from 'react';
2
+
3
+ type FalsyReactElement = ReactElement | null | undefined;
4
+
5
+ export default function cloneElementSafely(element: FalsyReactElement, props?: any): FalsyReactElement {
6
+ return element
7
+ ? cloneElement(element, props)
8
+ : null;
9
+ };
@@ -1 +1,2 @@
1
+ export { default as cloneElementSafely } from './cloneElementSafely';
1
2
  export { default as createSvgIcon } from './createSvgIcon';