@fountain-ui/core 1.13.0 → 1.14.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 (73) 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/index.js +8 -0
  19. package/build/commonjs/hooks/index.js.map +1 -1
  20. package/build/commonjs/hooks/useCollapsibleAppBar.js +5 -5
  21. package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
  22. package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js +22 -0
  23. package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js.map +1 -0
  24. package/build/commonjs/hooks/useValidWindowDimensions/index.js +12 -0
  25. package/build/commonjs/hooks/useValidWindowDimensions/index.js.map +1 -0
  26. package/build/module/Accordion/Accordion.js +6 -1
  27. package/build/module/Accordion/Accordion.js.map +1 -1
  28. package/build/module/ButtonBase/ButtonBase.js +4 -2
  29. package/build/module/ButtonBase/ButtonBase.js.map +1 -1
  30. package/build/module/ButtonBase/useDisabledReaction/index.js +12 -0
  31. package/build/module/ButtonBase/useDisabledReaction/index.js.map +1 -0
  32. package/build/module/ButtonBase/useDisabledReaction/index.native.js +2 -0
  33. package/build/module/ButtonBase/useDisabledReaction/index.native.js.map +1 -0
  34. package/build/module/Chip/Chip.js +3 -3
  35. package/build/module/Chip/Chip.js.map +1 -1
  36. package/build/module/Snackbar/Snackbar.js +5 -1
  37. package/build/module/Snackbar/Snackbar.js.map +1 -1
  38. package/build/module/SnackbarContent/SnackbarContent.js +29 -4
  39. package/build/module/SnackbarContent/SnackbarContent.js.map +1 -1
  40. package/build/module/Tooltip/Tooltip.js +1 -0
  41. package/build/module/Tooltip/Tooltip.js.map +1 -1
  42. package/build/module/hooks/index.js +1 -0
  43. package/build/module/hooks/index.js.map +1 -1
  44. package/build/module/hooks/useCollapsibleAppBar.js +1 -1
  45. package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
  46. package/build/module/hooks/useValidWindowDimensions/index.ios.js +13 -0
  47. package/build/module/hooks/useValidWindowDimensions/index.ios.js.map +1 -0
  48. package/build/module/hooks/useValidWindowDimensions/index.js +3 -0
  49. package/build/module/hooks/useValidWindowDimensions/index.js.map +1 -0
  50. package/build/typescript/ButtonBase/ButtonBase.d.ts +2 -0
  51. package/build/typescript/ButtonBase/useDisabledReaction/index.d.ts +2 -0
  52. package/build/typescript/ButtonBase/useDisabledReaction/index.native.d.ts +2 -0
  53. package/build/typescript/Slider/Slider.d.ts +1 -1
  54. package/build/typescript/Snackbar/SnackbarProps.d.ts +8 -0
  55. package/build/typescript/SnackbarContent/SnackbarContentProps.d.ts +8 -0
  56. package/build/typescript/hooks/index.d.ts +1 -0
  57. package/build/typescript/hooks/useValidWindowDimensions/index.d.ts +2 -0
  58. package/build/typescript/hooks/useValidWindowDimensions/index.ios.d.ts +1 -0
  59. package/package.json +4 -4
  60. package/src/Accordion/Accordion.tsx +7 -1
  61. package/src/ButtonBase/ButtonBase.tsx +5 -2
  62. package/src/ButtonBase/useDisabledReaction/index.native.ts +4 -0
  63. package/src/ButtonBase/useDisabledReaction/index.ts +15 -0
  64. package/src/Chip/Chip.tsx +4 -4
  65. package/src/Snackbar/Snackbar.tsx +7 -1
  66. package/src/Snackbar/SnackbarProps.ts +10 -0
  67. package/src/SnackbarContent/SnackbarContent.tsx +40 -3
  68. package/src/SnackbarContent/SnackbarContentProps.ts +10 -0
  69. package/src/Tooltip/Tooltip.tsx +4 -1
  70. package/src/hooks/index.ts +1 -0
  71. package/src/hooks/useCollapsibleAppBar.ts +1 -1
  72. package/src/hooks/useValidWindowDimensions/index.ios.ts +15 -0
  73. package/src/hooks/useValidWindowDimensions/index.ts +3 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["useCollapsibleAppBar.ts"],"names":["React","Platform","Animated","useSafeAreaInsets","useElevationStyle","useHeight","useAppbarStyles","defaultOptions","translucent","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","overlapped","elevationStyle","animatedStyle","useAnimatedStyle","transform","value","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","useRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","current","savedOffsetY","withTiming","duration","scrollHandler","useAnimatedScrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","dy","Math","min","max","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","undefined","floating","scrollContentInsets"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,iBA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IT,EAAE,GAAGQ,SAAL,IAAkBX,OAAO,GAAGtC,YAA7B,GAA6C,CAA7C,GAAiD0C,KAAxE;AAEAhC,MAAAA,UAAU,CAACK,KAAX,GAAmBuB,OAAO,GAAGY,cAAV,GAA2B,CAA9C;AAEA5C,MAAAA,UAAU,CAACS,KAAX,GAAmB7B,QAAQ,CAAC4C,UAAT,CAAoBoB,cAApB,EAAoC;AACnDnB,QAAAA,QAAQ,EAAEtC;AADyC,OAApC,CAAnB;AAGH;AAhEmD,GAAlC,CAAtB;AAmEA,QAAM0D,cAAc,GAAGjD,wBAAwB,GAAG,CAAlD;AAEA,QAAMkD,WAAW,GAAG,CAChBxC,aADgB,EAEhBpB,WAAW,GAAG;AAAE6D,IAAAA,UAAU,EAAEtD,cAAc,CAACuD;AAA7B,GAAH,GAAwCC,SAFnC,EAGhBJ,cAAc,GAAGrD,MAAM,CAAC0D,QAAV,GAAqBD,SAHnB,CAApB;AAMA,SAAO;AACHH,IAAAA,WADG;AAEHnD,IAAAA,cAFG;AAGHE,IAAAA,0BAHG;AAIHiC,IAAAA,QAAQ,EAAEJ,aAJP;AAKHP,IAAAA,mBALG;AAMHgC,IAAAA,mBAAmB,EAAE;AAAEH,MAAAA,GAAG,EAAEH,cAAc,GAAGnD,YAAH,GAAkB;AAAvC;AANlB,GAAP;AAQH;AAAA","sourcesContent":["import React from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { useElevationStyle } from '../hooks';\nimport { useHeight } from '../internal/hooks';\nimport useAppbarStyles from './useAppbarStyles';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n translucent?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n translucent: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nexport default function useCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { translucent }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = Animated.useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = Animated.useSharedValue<number>(0);\n const lastTranslateY = Animated.useSharedValue<number>(0);\n const lastOffsetY = Animated.useSharedValue<number>(0);\n const overlapped = Animated.useSharedValue<boolean>(false);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = Animated.useAnimatedStyle(() => {\n return Platform.OS === 'web' ? ({\n transform: [{ translateY: translateY.value }],\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n }) : ({\n transform: [{ translateY: translateY.value }],\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n });\n });\n\n const indexRef = React.useRef<number>(0);\n const offsetsRef = React.useRef<Array<number>>([]);\n\n const onScrollViewChanged = (nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n };\n\n const scrollHandler = Animated.useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = Animated.withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = Animated.withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n translucent ? { paddingTop: safeAreaInsets.top } : undefined,\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarHeight : 0 },\n };\n};\n"]}
1
+ {"version":3,"sources":["useCollapsibleAppBar.ts"],"names":["React","Platform","Animated","useSafeAreaInsets","useHeight","useElevationStyle","useAppbarStyles","defaultOptions","translucent","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","overlapped","elevationStyle","animatedStyle","useAnimatedStyle","transform","value","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","useRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","current","savedOffsetY","withTiming","duration","scrollHandler","useAnimatedScrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","dy","Math","min","max","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","undefined","floating","scrollContentInsets"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,SAASC,SAAT,QAA0B,mBAA1B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AA8BA,MAAMC,cAAiC,GAAG;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V,GAA2B,CAA9C;AAEA5C,MAAAA,UAAU,CAACS,KAAX,GAAmB7B,QAAQ,CAAC4C,UAAT,CAAoBoB,cAApB,EAAoC;AACnDnB,QAAAA,QAAQ,EAAEtC;AADyC,OAApC,CAAnB;AAGH;AAhEmD,GAAlC,CAAtB;AAmEA,QAAM0D,cAAc,GAAGjD,wBAAwB,GAAG,CAAlD;AAEA,QAAMkD,WAAW,GAAG,CAChBxC,aADgB,EAEhBpB,WAAW,GAAG;AAAE6D,IAAAA,UAAU,EAAEtD,cAAc,CAACuD;AAA7B,GAAH,GAAwCC,SAFnC,EAGhBJ,cAAc,GAAGrD,MAAM,CAAC0D,QAAV,GAAqBD,SAHnB,CAApB;AAMA,SAAO;AACHH,IAAAA,WADG;AAEHnD,IAAAA,cAFG;AAGHE,IAAAA,0BAHG;AAIHiC,IAAAA,QAAQ,EAAEJ,aAJP;AAKHP,IAAAA,mBALG;AAMHgC,IAAAA,mBAAmB,EAAE;AAAEH,MAAAA,GAAG,EAAEH,cAAc,GAAGnD,YAAH,GAAkB;AAAvC;AANlB,GAAP;AAQH;AAAA","sourcesContent":["import React from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport Animated from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { useHeight } from '../internal/hooks';\nimport useElevationStyle from './useElevationStyle';\nimport useAppbarStyles from './useAppbarStyles';\n\ntype WebOnlyStyle = { boxShadow: any };\n\ntype ViewStyleProp = Array<ViewStyle | RegisteredStyle<ViewStyle> | WebOnlyStyle | Falsy>;\n\ntype OnScroll = ScrollViewProps['onScroll'];\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport interface ContentInsets {\n top?: number;\n bottom?: number;\n left?: number;\n right?: number;\n}\n\nexport interface Options {\n translucent?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n translucent: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\nexport default function useCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { translucent }: Required<Options> = {\n ...defaultOptions,\n ...userOptions,\n };\n\n const styles = useAppbarStyles();\n\n const safeAreaInsets = useSafeAreaInsets();\n\n const [appBarHeight, onAppBarLayout] = useHeight();\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = Animated.useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = Animated.useSharedValue<number>(0);\n const lastTranslateY = Animated.useSharedValue<number>(0);\n const lastOffsetY = Animated.useSharedValue<number>(0);\n const overlapped = Animated.useSharedValue<boolean>(false);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = Animated.useAnimatedStyle(() => {\n return Platform.OS === 'web' ? ({\n transform: [{ translateY: translateY.value }],\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n }) : ({\n transform: [{ translateY: translateY.value }],\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n });\n });\n\n const indexRef = React.useRef<number>(0);\n const offsetsRef = React.useRef<Array<number>>([]);\n\n const onScrollViewChanged = (nextIndex: number) => {\n const prevIndex = indexRef.current;\n if (prevIndex === nextIndex) {\n return;\n }\n\n offsetsRef.current[prevIndex] = lastOffsetY.value;\n\n const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;\n lastOffsetY.value = savedOffsetY;\n\n indexRef.current = nextIndex;\n\n // Determine whether to overlap every time index is changed.\n overlapped.value = savedOffsetY > 0;\n\n // If next ScrollView's offset is too short, expand app bar.\n if (translateY.value < 0 && savedOffsetY < appBarHeight) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n };\n\n const scrollHandler = Animated.useAnimatedScrollHandler({\n onBeginDrag: () => {\n lastTranslateY.value = translateY.value;\n },\n onMomentumBegin: () => {\n lastTranslateY.value = translateY.value;\n },\n onScroll: (event) => {\n const offsetY = event.contentOffset.y;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n if (SUPPORTS_DRAG_DETECTION) {\n const dy = offsetY - lastOffsetY.value;\n\n translateY.value = offsetY <= 0 ? 0 : Math.min(Math.max(lastTranslateY.value - dy, maxTy), 0);\n\n overlapped.value = offsetY + translateY.value > 0;\n } else {\n if (offsetY > -maxTy) {\n if (ty === 0) {\n translateY.value = Animated.withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n }\n\n overlapped.value = offsetY > 0;\n\n lastOffsetY.value = offsetY;\n }\n },\n onEndDrag: (event) => {\n lastOffsetY.value = event.contentOffset.y;\n },\n onMomentumEnd: (event) => {\n const offsetY = event.contentOffset.y;\n\n lastOffsetY.value = offsetY;\n\n const ty = translateY.value;\n const maxTy = maxTranslateY.value;\n\n // If toolbar is already positioned on edge, do nothing.\n if (ty <= maxTy || ty >= 0) {\n return;\n }\n\n const threshold = maxTy * 0.5;\n\n const nextTranslateY = (ty > threshold || offsetY < appBarHeight) ? 0 : maxTy;\n\n overlapped.value = offsetY + nextTranslateY > 0;\n\n translateY.value = Animated.withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n translucent ? { paddingTop: safeAreaInsets.top } : undefined,\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarHeight : 0 },\n };\n};\n"]}
@@ -0,0 +1,13 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+ export default function useValidWindowDimensions() {
4
+ const window = useWindowDimensions();
5
+ const [validWindow, setValidWindow] = useState(window);
6
+ useEffect(() => {
7
+ if (window.width !== 0 && window.height !== 0) {
8
+ setValidWindow(window);
9
+ }
10
+ }, [window]);
11
+ return validWindow;
12
+ }
13
+ //# sourceMappingURL=index.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ios.ts"],"names":["useState","useEffect","useWindowDimensions","useValidWindowDimensions","window","validWindow","setValidWindow","width","height"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,mBAAT,QAAoC,cAApC;AAEA,eAAe,SAASC,wBAAT,GAAoC;AAC/C,QAAMC,MAAM,GAAGF,mBAAmB,EAAlC;AACA,QAAM,CAACG,WAAD,EAAcC,cAAd,IAAgCN,QAAQ,CAACI,MAAD,CAA9C;AAEAH,EAAAA,SAAS,CAAC,MAAM;AACZ,QAAIG,MAAM,CAACG,KAAP,KAAiB,CAAjB,IAAsBH,MAAM,CAACI,MAAP,KAAkB,CAA5C,EAA+C;AAC3CF,MAAAA,cAAc,CAACF,MAAD,CAAd;AACH;AACJ,GAJQ,EAIN,CAACA,MAAD,CAJM,CAAT;AAMA,SAAOC,WAAP;AACH","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useWindowDimensions } from 'react-native';\n\nexport default function useValidWindowDimensions() {\n const window = useWindowDimensions();\n const [validWindow, setValidWindow] = useState(window);\n\n useEffect(() => {\n if (window.width !== 0 && window.height !== 0) {\n setValidWindow(window);\n }\n }, [window]);\n\n return validWindow;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { useWindowDimensions } from 'react-native';
2
+ export default useWindowDimensions;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["useWindowDimensions"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,cAApC;AAEA,eAAeA,mBAAf","sourcesContent":["import { useWindowDimensions } from 'react-native';\n\nexport default useWindowDimensions;\n"]}
@@ -1,3 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type ButtonBaseProps from './ButtonBaseProps';
3
+ export declare const ORIGINAL_OPACITY = 1;
4
+ export declare const DISABLED_OPACITY = 0.3;
3
5
  export default function ButtonBase(props: ButtonBaseProps): JSX.Element;
@@ -0,0 +1,2 @@
1
+ import Animated from 'react-native-reanimated';
2
+ export default function useDisabledReaction(disabled: boolean, opacity: Animated.SharedValue<number>): void;
@@ -0,0 +1,2 @@
1
+ import Animated from 'react-native-reanimated';
2
+ export default function useDisabledReaction(disabled: boolean, opacity: Animated.SharedValue<number>): void;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import RNSlider from '@react-native-community/slider';
3
3
  import type SliderProps from './SliderProps';
4
- declare const _default: React.ForwardRefExoticComponent<Pick<SliderProps, "style" | "pointerEvents" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "disabled" | "hitSlop" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "value" | "vertical" | "inverted" | "maximumTrackTintColor" | "maximumValue" | "minimumTrackTintColor" | "minimumValue" | "onSlidingStart" | "onSlidingComplete" | "onValueChange" | "step" | "accessibilityUnits" | "accessibilityIncrements" | "maximumTrackImage" | "minimumTrackImage" | "tapToSeek" | "thumbImage" | "trackImage" | "thumbTintColor"> & React.RefAttributes<RNSlider>>;
4
+ declare const _default: React.ForwardRefExoticComponent<Pick<SliderProps, "style" | "pointerEvents" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "disabled" | "hitSlop" | "onLayout" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "value" | "inverted" | "vertical" | "maximumTrackTintColor" | "maximumValue" | "minimumTrackTintColor" | "minimumValue" | "onSlidingStart" | "onSlidingComplete" | "onValueChange" | "step" | "accessibilityUnits" | "accessibilityIncrements" | "maximumTrackImage" | "minimumTrackImage" | "tapToSeek" | "thumbImage" | "trackImage" | "thumbTintColor"> & React.RefAttributes<RNSlider>>;
5
5
  export default _default;
@@ -3,6 +3,10 @@ import type { ViewProps } from 'react-native';
3
3
  import Animated from 'react-native-reanimated';
4
4
  import type { OverridableComponentProps } from '../types';
5
5
  export default interface SnackbarProps extends OverridableComponentProps<ViewProps, {
6
+ /**
7
+ * The text to use for the action component.
8
+ */
9
+ actionLabel?: string;
6
10
  /**
7
11
  * y value for animating.
8
12
  */
@@ -23,6 +27,10 @@ export default interface SnackbarProps extends OverridableComponentProps<ViewPro
23
27
  * The message to display.
24
28
  */
25
29
  message?: string;
30
+ /**
31
+ * Callback fired when the action component pressed.
32
+ */
33
+ onActionPress?: () => void;
26
34
  /**
27
35
  * Callback fired when the component requests to be closed.
28
36
  */
@@ -1,9 +1,17 @@
1
1
  import type { OverridableComponentProps } from '../types';
2
2
  import type { PaperProps } from '../Paper';
3
3
  export default interface SnackbarContentProps extends OverridableComponentProps<PaperProps, {
4
+ /**
5
+ * The text to use for the action component.
6
+ */
7
+ actionLabel?: string;
4
8
  /**
5
9
  * The message to display.
6
10
  */
7
11
  message?: string;
12
+ /**
13
+ * Callback fired when the action component pressed.
14
+ */
15
+ onActionPress?: () => void;
8
16
  }> {
9
17
  }
@@ -4,3 +4,4 @@ export { default as useContentContainerStyle } from './useContentContainerStyle'
4
4
  export { default as useElevationStyle } from './useElevationStyle';
5
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
6
6
  export { default as useThrottle } from './useThrottle';
7
+ export { default as useValidWindowDimensions } from './useValidWindowDimensions';
@@ -0,0 +1,2 @@
1
+ import { useWindowDimensions } from 'react-native';
2
+ export default useWindowDimensions;
@@ -0,0 +1 @@
1
+ export default function useValidWindowDimensions(): import("react-native").ScaledSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "1.13.0",
3
+ "version": "1.14.2",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  "prepare": "bob build"
15
15
  },
16
16
  "dependencies": {
17
- "@fountain-ui/styles": "^1.4.0",
17
+ "@fountain-ui/styles": "^1.4.1",
18
18
  "@fountain-ui/utils": "^1.1.0"
19
19
  },
20
20
  "peerDependencies": {
@@ -22,7 +22,7 @@
22
22
  "react": "^16.8.0 || ^17.0.0",
23
23
  "react-dom": "^16.8.0 || ^17.0.0",
24
24
  "react-native": "^0.63.0",
25
- "react-native-fast-image": "^8.3.7",
25
+ "react-native-fast-image": "^8.5.11",
26
26
  "react-native-reanimated": "^2.0.0",
27
27
  "react-native-safe-area-context": "^3.1.9",
28
28
  "react-native-svg": "^12.1.0"
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "af1afff9aba465ced608d387572a05a2ddac0bf1"
70
+ "gitHead": "2453b78c3d7ff484fc25ea0663e33a681942f910"
71
71
  }
@@ -2,7 +2,13 @@ import React, { useState } from 'react';
2
2
  import Animated from 'react-native-reanimated';
3
3
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
4
4
  import { ChevronDown as ChevronDownIcon } from '../internal/icons';
5
- import { ButtonBase, Column, Divider, Spacer, Typography, useTheme } from '../index';
5
+ import ButtonBase from '../ButtonBase';
6
+ import Column from '../Column';
7
+ import Divider from '../Divider';
8
+ import Spacer from '../Spacer';
9
+ import Typography from '../Typography';
10
+ import { useTheme } from '../styles';
11
+
6
12
  import AccordionProps from './AccordionProps';
7
13
 
8
14
  type AccordionStyles = NamedStylesStringUnion<'root'>;
@@ -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}
@@ -4,3 +4,4 @@ export { default as useContentContainerStyle } from './useContentContainerStyle'
4
4
  export { default as useElevationStyle } from './useElevationStyle';
5
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
6
6
  export { default as useThrottle } from './useThrottle';
7
+ export { default as useValidWindowDimensions } from './useValidWindowDimensions';
@@ -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 };
@@ -0,0 +1,15 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+
4
+ export default function useValidWindowDimensions() {
5
+ const window = useWindowDimensions();
6
+ const [validWindow, setValidWindow] = useState(window);
7
+
8
+ useEffect(() => {
9
+ if (window.width !== 0 && window.height !== 0) {
10
+ setValidWindow(window);
11
+ }
12
+ }, [window]);
13
+
14
+ return validWindow;
15
+ }
@@ -0,0 +1,3 @@
1
+ import { useWindowDimensions } from 'react-native';
2
+
3
+ export default useWindowDimensions;