@fountain-ui/core 1.12.1 → 1.14.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 (55) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/commonjs/Accordion/Accordion.js +20 -10
  3. package/build/commonjs/Accordion/Accordion.js.map +1 -1
  4. package/build/commonjs/ButtonBase/ButtonBase.js +8 -1
  5. package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
  6. package/build/commonjs/ButtonBase/useDisabledReaction/index.js +23 -0
  7. package/build/commonjs/ButtonBase/useDisabledReaction/index.js.map +1 -0
  8. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js +9 -0
  9. package/build/commonjs/ButtonBase/useDisabledReaction/index.native.js.map +1 -0
  10. package/build/commonjs/Chip/Chip.js +4 -4
  11. package/build/commonjs/Chip/Chip.js.map +1 -1
  12. package/build/commonjs/Snackbar/Snackbar.js +5 -1
  13. package/build/commonjs/Snackbar/Snackbar.js.map +1 -1
  14. package/build/commonjs/SnackbarContent/SnackbarContent.js +31 -4
  15. package/build/commonjs/SnackbarContent/SnackbarContent.js.map +1 -1
  16. package/build/commonjs/Tooltip/Tooltip.js +1 -0
  17. package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
  18. package/build/commonjs/hooks/useCollapsibleAppBar.js +5 -5
  19. package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
  20. package/build/module/Accordion/Accordion.js +6 -1
  21. package/build/module/Accordion/Accordion.js.map +1 -1
  22. package/build/module/ButtonBase/ButtonBase.js +4 -2
  23. package/build/module/ButtonBase/ButtonBase.js.map +1 -1
  24. package/build/module/ButtonBase/useDisabledReaction/index.js +12 -0
  25. package/build/module/ButtonBase/useDisabledReaction/index.js.map +1 -0
  26. package/build/module/ButtonBase/useDisabledReaction/index.native.js +2 -0
  27. package/build/module/ButtonBase/useDisabledReaction/index.native.js.map +1 -0
  28. package/build/module/Chip/Chip.js +3 -3
  29. package/build/module/Chip/Chip.js.map +1 -1
  30. package/build/module/Snackbar/Snackbar.js +5 -1
  31. package/build/module/Snackbar/Snackbar.js.map +1 -1
  32. package/build/module/SnackbarContent/SnackbarContent.js +29 -4
  33. package/build/module/SnackbarContent/SnackbarContent.js.map +1 -1
  34. package/build/module/Tooltip/Tooltip.js +1 -0
  35. package/build/module/Tooltip/Tooltip.js.map +1 -1
  36. package/build/module/hooks/useCollapsibleAppBar.js +1 -1
  37. package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
  38. package/build/typescript/ButtonBase/ButtonBase.d.ts +2 -0
  39. package/build/typescript/ButtonBase/useDisabledReaction/index.d.ts +2 -0
  40. package/build/typescript/ButtonBase/useDisabledReaction/index.native.d.ts +2 -0
  41. package/build/typescript/Slider/Slider.d.ts +1 -1
  42. package/build/typescript/Snackbar/SnackbarProps.d.ts +8 -0
  43. package/build/typescript/SnackbarContent/SnackbarContentProps.d.ts +8 -0
  44. package/package.json +4 -4
  45. package/src/Accordion/Accordion.tsx +7 -1
  46. package/src/ButtonBase/ButtonBase.tsx +5 -2
  47. package/src/ButtonBase/useDisabledReaction/index.native.ts +4 -0
  48. package/src/ButtonBase/useDisabledReaction/index.ts +15 -0
  49. package/src/Chip/Chip.tsx +4 -4
  50. package/src/Snackbar/Snackbar.tsx +7 -1
  51. package/src/Snackbar/SnackbarProps.ts +10 -0
  52. package/src/SnackbarContent/SnackbarContent.tsx +40 -3
  53. package/src/SnackbarContent/SnackbarContentProps.ts +10 -0
  54. package/src/Tooltip/Tooltip.tsx +4 -1
  55. package/src/hooks/useCollapsibleAppBar.ts +1 -1
@@ -4,10 +4,11 @@ import { useThrottle } from '../hooks';
4
4
  import { AnimatedPressable } from '../animated';
5
5
  import { StyleSheet } from '../styles';
6
6
  import type ButtonBaseProps from './ButtonBaseProps';
7
+ import useDisabledReaction from './useDisabledReaction';
7
8
 
8
- const ORIGINAL_OPACITY = 1;
9
+ export const ORIGINAL_OPACITY = 1;
10
+ export const DISABLED_OPACITY = .3;
9
11
  const ACTIVE_OPACITY = .65;
10
- const DISABLED_OPACITY = .3;
11
12
 
12
13
  const ORIGINAL_SCALE = 1;
13
14
  const MINIFIED_SCALE = .96;
@@ -46,6 +47,8 @@ export default function ButtonBase(props: ButtonBaseProps) {
46
47
  transform: [{ scale: scale.value }],
47
48
  }));
48
49
 
50
+ useDisabledReaction(disabled, opacity);
51
+
49
52
  const startAnimation = (pressIn: boolean, isHovered: boolean = false) => {
50
53
  if (pressEffect === 'none') {
51
54
  return;
@@ -0,0 +1,4 @@
1
+ import Animated from 'react-native-reanimated';
2
+
3
+ export default function useDisabledReaction(disabled: boolean, opacity: Animated.SharedValue<number>) {
4
+ }
@@ -0,0 +1,15 @@
1
+ import Animated from 'react-native-reanimated';
2
+ import { DISABLED_OPACITY, ORIGINAL_OPACITY } from '../ButtonBase';
3
+
4
+ export default function useDisabledReaction(disabled: boolean, opacity: Animated.SharedValue<number>) {
5
+ Animated.useAnimatedReaction(
6
+ () => disabled,
7
+ (result) => {
8
+ if (result) {
9
+ opacity.value = DISABLED_OPACITY;
10
+ } else {
11
+ opacity.value = ORIGINAL_OPACITY;
12
+ }
13
+ },
14
+ );
15
+ }
package/src/Chip/Chip.tsx CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Text } from 'react-native';
3
3
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
4
  import { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';
5
- import { ButtonBase } from '../index';
5
+ import ButtonBase from '../ButtonBase';
6
6
  import type ChipProps from './ChipProps';
7
7
 
8
8
  type ChipStyles = NamedStylesStringUnion<'root'>;
@@ -47,7 +47,7 @@ export default function Chip(props: ChipProps) {
47
47
  outlined: {
48
48
  backgroundColor: theme.palette.paper.default,
49
49
  borderColor: theme.palette.border,
50
- borderWidth: 1,
50
+ borderWidth: 2,
51
51
  },
52
52
  filled: {
53
53
  backgroundColor: theme.palette.paper.grey,
@@ -55,7 +55,7 @@ export default function Chip(props: ChipProps) {
55
55
  bold: {
56
56
  backgroundColor: theme.palette.paper.grey,
57
57
  borderColor: theme.palette.primary.main,
58
- borderWidth: 1,
58
+ borderWidth: 2,
59
59
  },
60
60
  };
61
61
 
@@ -102,4 +102,4 @@ export default function Chip(props: ChipProps) {
102
102
  {endIcon}
103
103
  </ButtonBase>
104
104
  );
105
- }
105
+ }
@@ -30,10 +30,12 @@ const useStyles: UseStyles<SnackBarStyles> = function (): SnackBarStyles {
30
30
 
31
31
  export default function Snackbar(props: SnackbarProps) {
32
32
  const {
33
+ actionLabel,
33
34
  animatedY,
34
35
  autoHideDuration = null,
35
36
  children,
36
37
  message,
38
+ onActionPress,
37
39
  onClose,
38
40
  style,
39
41
  visible = false,
@@ -90,7 +92,11 @@ export default function Snackbar(props: SnackbarProps) {
90
92
  onExited={() => setExited(true)}
91
93
  >
92
94
  {children ? children : (
93
- <SnackbarContent message={message}/>
95
+ <SnackbarContent
96
+ actionLabel={actionLabel}
97
+ message={message}
98
+ onActionPress={onActionPress}
99
+ />
94
100
  )}
95
101
  </Slide>
96
102
  </View>
@@ -4,6 +4,11 @@ import Animated from 'react-native-reanimated';
4
4
  import type { OverridableComponentProps } from '../types';
5
5
 
6
6
  export default interface SnackbarProps extends OverridableComponentProps<ViewProps, {
7
+ /**
8
+ * The text to use for the action component.
9
+ */
10
+ actionLabel?: string,
11
+
7
12
  /**
8
13
  * y value for animating.
9
14
  */
@@ -28,6 +33,11 @@ export default interface SnackbarProps extends OverridableComponentProps<ViewPro
28
33
  */
29
34
  message?: string,
30
35
 
36
+ /**
37
+ * Callback fired when the action component pressed.
38
+ */
39
+ onActionPress?: () => void
40
+
31
41
  /**
32
42
  * Callback fired when the component requests to be closed.
33
43
  */
@@ -3,10 +3,12 @@ import { Text } from 'react-native';
3
3
  import type { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
4
  import { rgb } from '@fountain-ui/utils';
5
5
  import { createFontStyle, css, useTheme } from '../styles';
6
+ import ButtonBase from '../ButtonBase';
6
7
  import Paper from '../Paper';
8
+ import Spacer from '../Spacer';
7
9
  import type SnackbarContentProps from './SnackbarContentProps';
8
10
 
9
- type SnackBarContentStyles = NamedStylesStringUnion<'root'>;
11
+ type SnackBarContentStyles = NamedStylesStringUnion<'root' | 'action'>;
10
12
 
11
13
  const useStyles: UseStyles<SnackBarContentStyles> = function (): SnackBarContentStyles {
12
14
  const theme = useTheme();
@@ -21,12 +23,20 @@ const useStyles: UseStyles<SnackBarContentStyles> = function (): SnackBarContent
21
23
  paddingHorizontal: theme.spacing(4),
22
24
  paddingVertical: theme.spacing(3),
23
25
  },
26
+ action: {
27
+ alignItems: 'center',
28
+ flexDirection: 'row',
29
+ justifyContent: 'space-between',
30
+ paddingVertical: theme.spacing(2),
31
+ },
24
32
  };
25
33
  };
26
34
 
27
35
  export default function SnackbarContent(props: SnackbarContentProps) {
28
36
  const {
37
+ actionLabel,
29
38
  message,
39
+ onActionPress,
30
40
  style,
31
41
  ...otherProps
32
42
  } = props;
@@ -35,16 +45,27 @@ export default function SnackbarContent(props: SnackbarContentProps) {
35
45
 
36
46
  const theme = useTheme();
37
47
 
38
- const fontStyle = createFontStyle(theme, {
48
+ const messageFontStyle = createFontStyle(theme, {
39
49
  selector: (typo) => typo.body2,
40
50
  color: theme.palette.primary.contrastTextColor,
41
51
  });
42
52
 
53
+ const labelFontStyle = createFontStyle(theme, {
54
+ selector: (typo) => typo.button2,
55
+ color: theme.palette.primary.contrastTextColor,
56
+ });
57
+
58
+ const labelStyle = css([
59
+ labelFontStyle,
60
+ { padding: theme.spacing(2) },
61
+ ]);
62
+
43
63
  return (
44
64
  <Paper
45
65
  elevation={0}
46
66
  style={css([
47
67
  styles.root,
68
+ actionLabel ? styles.action : undefined,
48
69
  style,
49
70
  ])}
50
71
  {...otherProps}
@@ -52,9 +73,25 @@ export default function SnackbarContent(props: SnackbarContentProps) {
52
73
  <Text
53
74
  children={message}
54
75
  style={css([
55
- fontStyle,
76
+ messageFontStyle,
56
77
  ])}
57
78
  />
79
+
80
+ {actionLabel ? (
81
+ <React.Fragment>
82
+ <Spacer size={1}/>
83
+
84
+ <ButtonBase
85
+ onPress={onActionPress}
86
+ pressEffect={'none'}
87
+ >
88
+ <Text
89
+ children={actionLabel}
90
+ style={labelStyle}
91
+ />
92
+ </ButtonBase>
93
+ </React.Fragment>
94
+ ) : null}
58
95
  </Paper>
59
96
  );
60
97
  };
@@ -2,8 +2,18 @@ import type { OverridableComponentProps } from '../types';
2
2
  import type { PaperProps } from '../Paper';
3
3
 
4
4
  export default interface SnackbarContentProps extends OverridableComponentProps<PaperProps, {
5
+ /**
6
+ * The text to use for the action component.
7
+ */
8
+ actionLabel?: string,
9
+
5
10
  /**
6
11
  * The message to display.
7
12
  */
8
13
  message?: string,
14
+
15
+ /**
16
+ * Callback fired when the action component pressed.
17
+ */
18
+ onActionPress?: () => void
9
19
  }> {}
@@ -77,7 +77,10 @@ export default function Tooltip(props: TooltipProps) {
77
77
  ]);
78
78
 
79
79
  const buttonElem = (
80
- <TouchableWithoutFeedback onPress={onClose}>
80
+ <TouchableWithoutFeedback
81
+ disallowInterruption={true}
82
+ onPress={onClose}
83
+ >
81
84
  <View style={css(touchableStyle)}>
82
85
  <Text
83
86
  children={title}
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
3
3
  import Animated from 'react-native-reanimated';
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
- import { useElevationStyle } from '../hooks';
6
5
  import { useHeight } from '../internal/hooks';
6
+ import useElevationStyle from './useElevationStyle';
7
7
  import useAppbarStyles from './useAppbarStyles';
8
8
 
9
9
  type WebOnlyStyle = { boxShadow: any };