@fountain-ui/lab 2.0.0-beta.6 → 2.0.0-beta.7

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 (150) hide show
  1. package/build/commonjs/AnimatedY/AnimatedY.js +3 -5
  2. package/build/commonjs/AnimatedY/AnimatedY.js.map +1 -1
  3. package/build/commonjs/AnimatedY/AnimatedYProps.js.map +1 -1
  4. package/build/commonjs/AnimatedY/index.js.map +1 -1
  5. package/build/commonjs/BottomSheet/BottomSheetNative.js +1 -1
  6. package/build/commonjs/BottomSheet/BottomSheetNative.js.map +1 -1
  7. package/build/commonjs/BottomSheet/BottomSheetProps.js.map +1 -1
  8. package/build/commonjs/BottomSheet/BottomSheetWeb.js +2 -6
  9. package/build/commonjs/BottomSheet/BottomSheetWeb.js.map +1 -1
  10. package/build/commonjs/BottomSheet/TransparentBackdrop.js +1 -1
  11. package/build/commonjs/BottomSheet/TransparentBackdrop.js.map +1 -1
  12. package/build/commonjs/BottomSheet/index.js.map +1 -1
  13. package/build/commonjs/BottomSheet/index.native.js.map +1 -1
  14. package/build/commonjs/Carousel/CarouselNative.js.map +1 -1
  15. package/build/commonjs/Carousel/CarouselProps.js.map +1 -1
  16. package/build/commonjs/Carousel/CarouselWeb.js +1 -1
  17. package/build/commonjs/Carousel/CarouselWeb.js.map +1 -1
  18. package/build/commonjs/Carousel/index.js.map +1 -1
  19. package/build/commonjs/Carousel/index.native.js.map +1 -1
  20. package/build/commonjs/Carousel/utils.js +1 -1
  21. package/build/commonjs/Carousel/utils.js.map +1 -1
  22. package/build/commonjs/ComicViewer/ComicViewer.js +16 -11
  23. package/build/commonjs/ComicViewer/ComicViewer.js.map +1 -1
  24. package/build/commonjs/ComicViewer/ComicViewerItemProps.js.map +1 -1
  25. package/build/commonjs/ComicViewer/ComicViewerProps.js.map +1 -1
  26. package/build/commonjs/ComicViewer/ViewerItem.js +4 -3
  27. package/build/commonjs/ComicViewer/ViewerItem.js.map +1 -1
  28. package/build/commonjs/ComicViewer/index.js.map +1 -1
  29. package/build/commonjs/DateTimePicker/DateTimePicker.js.map +1 -1
  30. package/build/commonjs/DateTimePicker/DateTimePickerProps.js.map +1 -1
  31. package/build/commonjs/DateTimePicker/DateTimePickerProvider.js.map +1 -1
  32. package/build/commonjs/DateTimePicker/YearPicker.js +21 -17
  33. package/build/commonjs/DateTimePicker/YearPicker.js.map +1 -1
  34. package/build/commonjs/DateTimePicker/index.js +4 -4
  35. package/build/commonjs/DateTimePicker/index.js.map +1 -1
  36. package/build/commonjs/DateTimePicker/utils.js +2 -1
  37. package/build/commonjs/DateTimePicker/utils.js.map +1 -1
  38. package/build/commonjs/FlipCard/FlipCard.js +5 -11
  39. package/build/commonjs/FlipCard/FlipCard.js.map +1 -1
  40. package/build/commonjs/FlipCard/FlipCardProps.js.map +1 -1
  41. package/build/commonjs/FlipCard/index.js.map +1 -1
  42. package/build/commonjs/StatusBarProvider/Provider.js +1 -1
  43. package/build/commonjs/StatusBarProvider/Provider.js.map +1 -1
  44. package/build/commonjs/StatusBarProvider/StatusBarProvider.js.map +1 -1
  45. package/build/commonjs/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
  46. package/build/commonjs/StatusBarProvider/index.js.map +1 -1
  47. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js +1 -1
  48. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +1 -1
  49. package/build/commonjs/ViewPager/ViewPagerNative.js.map +1 -1
  50. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  51. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +1 -1
  52. package/build/commonjs/ViewPager/index.js.map +1 -1
  53. package/build/commonjs/ViewPager/index.native.js.map +1 -1
  54. package/build/commonjs/ViewPager/utils.js +13 -11
  55. package/build/commonjs/ViewPager/utils.js.map +1 -1
  56. package/build/commonjs/hooks/index.js.map +1 -1
  57. package/build/commonjs/hooks/useAppbarStyles.js.map +1 -1
  58. package/build/commonjs/hooks/useElevationStyle.js.map +1 -1
  59. package/build/commonjs/hooks/useHeight.js +5 -4
  60. package/build/commonjs/hooks/useHeight.js.map +1 -1
  61. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +18 -29
  62. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  63. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js +7 -9
  64. package/build/commonjs/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  65. package/build/commonjs/hooks/useWidth.js.map +1 -1
  66. package/build/commonjs/index.js +10 -10
  67. package/build/commonjs/index.js.map +1 -1
  68. package/build/module/AnimatedY/AnimatedY.js +4 -4
  69. package/build/module/AnimatedY/AnimatedY.js.map +1 -1
  70. package/build/module/AnimatedY/AnimatedYProps.js.map +1 -1
  71. package/build/module/AnimatedY/index.js.map +1 -1
  72. package/build/module/BottomSheet/BottomSheetNative.js +1 -1
  73. package/build/module/BottomSheet/BottomSheetNative.js.map +1 -1
  74. package/build/module/BottomSheet/BottomSheetProps.js.map +1 -1
  75. package/build/module/BottomSheet/BottomSheetWeb.js +2 -6
  76. package/build/module/BottomSheet/BottomSheetWeb.js.map +1 -1
  77. package/build/module/BottomSheet/TransparentBackdrop.js +1 -1
  78. package/build/module/BottomSheet/TransparentBackdrop.js.map +1 -1
  79. package/build/module/BottomSheet/index.js.map +1 -1
  80. package/build/module/BottomSheet/index.native.js.map +1 -1
  81. package/build/module/Carousel/CarouselNative.js.map +1 -1
  82. package/build/module/Carousel/CarouselProps.js.map +1 -1
  83. package/build/module/Carousel/CarouselWeb.js +1 -1
  84. package/build/module/Carousel/CarouselWeb.js.map +1 -1
  85. package/build/module/Carousel/index.js.map +1 -1
  86. package/build/module/Carousel/index.native.js.map +1 -1
  87. package/build/module/Carousel/utils.js.map +1 -1
  88. package/build/module/ComicViewer/ComicViewer.js +16 -11
  89. package/build/module/ComicViewer/ComicViewer.js.map +1 -1
  90. package/build/module/ComicViewer/ComicViewerItemProps.js.map +1 -1
  91. package/build/module/ComicViewer/ComicViewerProps.js.map +1 -1
  92. package/build/module/ComicViewer/ViewerItem.js +4 -3
  93. package/build/module/ComicViewer/ViewerItem.js.map +1 -1
  94. package/build/module/ComicViewer/index.js.map +1 -1
  95. package/build/module/DateTimePicker/DateTimePicker.js.map +1 -1
  96. package/build/module/DateTimePicker/DateTimePickerProps.js.map +1 -1
  97. package/build/module/DateTimePicker/DateTimePickerProvider.js.map +1 -1
  98. package/build/module/DateTimePicker/YearPicker.js +21 -17
  99. package/build/module/DateTimePicker/YearPicker.js.map +1 -1
  100. package/build/module/DateTimePicker/index.js.map +1 -1
  101. package/build/module/DateTimePicker/utils.js +2 -1
  102. package/build/module/DateTimePicker/utils.js.map +1 -1
  103. package/build/module/FlipCard/FlipCard.js +5 -5
  104. package/build/module/FlipCard/FlipCard.js.map +1 -1
  105. package/build/module/FlipCard/FlipCardProps.js.map +1 -1
  106. package/build/module/FlipCard/index.js.map +1 -1
  107. package/build/module/StatusBarProvider/Provider.js.map +1 -1
  108. package/build/module/StatusBarProvider/StatusBarProvider.js.map +1 -1
  109. package/build/module/StatusBarProvider/StatusBarProviderProps.js.map +1 -1
  110. package/build/module/StatusBarProvider/index.js.map +1 -1
  111. package/build/module/ViewPager/ChildrenMemoizedPage.js +1 -1
  112. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +1 -1
  113. package/build/module/ViewPager/ViewPagerNative.js.map +1 -1
  114. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  115. package/build/module/ViewPager/ViewPagerWeb.js.map +1 -1
  116. package/build/module/ViewPager/index.js.map +1 -1
  117. package/build/module/ViewPager/index.native.js.map +1 -1
  118. package/build/module/ViewPager/utils.js +11 -10
  119. package/build/module/ViewPager/utils.js.map +1 -1
  120. package/build/module/hooks/index.js.map +1 -1
  121. package/build/module/hooks/useAppbarStyles.js.map +1 -1
  122. package/build/module/hooks/useElevationStyle.js.map +1 -1
  123. package/build/module/hooks/useHeight.js +4 -3
  124. package/build/module/hooks/useHeight.js.map +1 -1
  125. package/build/module/hooks/useUnstableCollapsibleAppBar.js +18 -19
  126. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  127. package/build/module/hooks/useUnstableToggleDisplayStyle.js +7 -5
  128. package/build/module/hooks/useUnstableToggleDisplayStyle.js.map +1 -1
  129. package/build/module/hooks/useWidth.js.map +1 -1
  130. package/build/module/index.js.map +1 -1
  131. package/build/typescript/AnimatedY/AnimatedY.d.ts +0 -1
  132. package/build/typescript/BottomSheet/BottomSheetNative.d.ts +0 -1
  133. package/build/typescript/BottomSheet/BottomSheetWeb.d.ts +0 -1
  134. package/build/typescript/BottomSheet/TransparentBackdrop.d.ts +0 -1
  135. package/build/typescript/Carousel/CarouselNative.d.ts +0 -1
  136. package/build/typescript/ComicViewer/ComicViewer.d.ts +0 -1
  137. package/build/typescript/DateTimePicker/DateTimePicker.d.ts +0 -1
  138. package/build/typescript/DateTimePicker/YearPicker.d.ts +0 -1
  139. package/build/typescript/FlipCard/FlipCard.d.ts +0 -1
  140. package/build/typescript/StatusBarProvider/StatusBarProvider.d.ts +0 -1
  141. package/build/typescript/ViewPager/ViewPagerNative.d.ts +0 -1
  142. package/build/typescript/ViewPager/ViewPagerWeb.d.ts +0 -1
  143. package/build/typescript/hooks/useUnstableCollapsibleAppBar.d.ts +2 -2
  144. package/build/typescript/hooks/useUnstableToggleDisplayStyle.d.ts +2 -2
  145. package/package.json +5 -4
  146. package/src/AnimatedY/AnimatedY.tsx +4 -4
  147. package/src/FlipCard/FlipCard.tsx +6 -6
  148. package/src/hooks/useHeight.ts +2 -2
  149. package/src/hooks/useUnstableCollapsibleAppBar.ts +23 -16
  150. package/src/hooks/useUnstableToggleDisplayStyle.ts +6 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["useHeight.ts"],"names":["React","Animated","useHeight","initialHeight","height","setHeight","useState","onLayout","useWorkletCallback","e","nativeEvent","layout"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,OAAOC,QAAP,MAAqB,yBAArB;AAIA,eAAe,SAASC,SAAT,CAAmBC,aAAa,GAAG,CAAnC,EAAkE;AAC7E,QAAM,CAACC,MAAD,EAASC,SAAT,IAAsBL,KAAK,CAACM,QAAN,CAAuBH,aAAvB,CAA5B;AAEA,QAAMI,QAAQ,GAAGN,QAAQ,CAACO,kBAAT,CAA6BC,CAAD,IAAO;AAChDJ,IAAAA,SAAS,CAACI,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBP,MAAtB,CAAT;AACH,GAFgB,EAEd,EAFc,CAAjB;AAIA,SAAO,CAACA,MAAD,EAASG,QAAT,CAAP;AACH;AAAA","sourcesContent":["import React from 'react';\nimport { ViewProps } from 'react-native';\nimport Animated from 'react-native-reanimated';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = React.useState<number>(initialHeight);\n\n const onLayout = Animated.useWorkletCallback((e) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"]}
1
+ {"version":3,"names":["React","useWorkletCallback","useHeight","initialHeight","height","setHeight","useState","onLayout","e","nativeEvent","layout"],"sources":["useHeight.ts"],"sourcesContent":["import React from 'react';\nimport { ViewProps } from 'react-native';\nimport { useWorkletCallback } from 'react-native-reanimated';\n\ntype OnLayoutCallback = ViewProps['onLayout'];\n\nexport default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {\n const [height, setHeight] = React.useState<number>(initialHeight);\n\n const onLayout = useWorkletCallback((e) => {\n setHeight(e.nativeEvent.layout.height);\n }, []);\n\n return [height, onLayout];\n};\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,kBAAT,QAAmC,yBAAnC;AAIA,eAAe,SAASC,SAAT,GAAkE;EAAA,IAA/CC,aAA+C,uEAA/B,CAA+B;EAC7E,MAAM,CAACC,MAAD,EAASC,SAAT,IAAsBL,KAAK,CAACM,QAAN,CAAuBH,aAAvB,CAA5B;EAEA,MAAMI,QAAQ,GAAGN,kBAAkB,CAAEO,CAAD,IAAO;IACvCH,SAAS,CAACG,CAAC,CAACC,WAAF,CAAcC,MAAd,CAAqBN,MAAtB,CAAT;EACH,CAFkC,EAEhC,EAFgC,CAAnC;EAIA,OAAO,CAACA,MAAD,EAASG,QAAT,CAAP;AACH;AAAA"}
@@ -1,6 +1,6 @@
1
1
  import React, { useRef } from 'react';
2
2
  import { Platform } from 'react-native';
3
- import Animated from 'react-native-reanimated';
3
+ import { useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
5
  import useAppbarStyles from './useAppbarStyles';
6
6
  import useElevationStyle from './useElevationStyle';
@@ -18,7 +18,8 @@ function useLargerValueOfLastTwoValues(value) {
18
18
  return Math.max(...refLatestTwoValues.current);
19
19
  }
20
20
 
21
- export default function useUnstableCollapsibleAppBar(userOptions = defaultOptions) {
21
+ export default function useUnstableCollapsibleAppBar() {
22
+ let userOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultOptions;
22
23
  const {
23
24
  shouldTranslateYReset
24
25
  } = { ...defaultOptions,
@@ -29,15 +30,15 @@ export default function useUnstableCollapsibleAppBar(userOptions = defaultOption
29
30
  const [appBarHeight, onAppBarLayout] = useHeight();
30
31
  const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);
31
32
  const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();
32
- const maxTranslateY = Animated.useDerivedValue(() => -collapsibleToolbarHeight);
33
- const translateY = Animated.useSharedValue(0);
34
- const lastTranslateY = Animated.useSharedValue(0);
35
- const lastOffsetY = Animated.useSharedValue(0);
36
- const prevOffsetY = Animated.useSharedValue(0);
37
- const overlapped = Animated.useSharedValue(false);
38
- const vectorY = Animated.useSharedValue(0);
33
+ const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);
34
+ const translateY = useSharedValue(0);
35
+ const lastTranslateY = useSharedValue(0);
36
+ const lastOffsetY = useSharedValue(0);
37
+ const prevOffsetY = useSharedValue(0);
38
+ const overlapped = useSharedValue(false);
39
+ const vectorY = useSharedValue(0);
39
40
  const elevationStyle = useElevationStyle(4);
40
- const animatedStyle = Animated.useAnimatedStyle(() => {
41
+ const animatedStyle = useAnimatedStyle(() => {
41
42
  return Platform.OS === 'web' ? {
42
43
  transform: [{
43
44
  translateY: translateY.value
@@ -58,13 +59,11 @@ export default function useUnstableCollapsibleAppBar(userOptions = defaultOption
58
59
  const offsetsRef = React.useRef([]);
59
60
 
60
61
  const onScrollViewChanged = nextIndex => {
61
- var _offsetsRef$current$n;
62
-
63
62
  const prevIndex = indexRef.current;
64
63
 
65
64
  if (prevIndex === nextIndex) {
66
65
  if (shouldTranslateYReset) {
67
- translateY.value = Animated.withTiming(0, {
66
+ translateY.value = withTiming(0, {
68
67
  duration: ANIMATION_DURATION_MILLIS
69
68
  });
70
69
  vectorY.value = 0;
@@ -76,21 +75,21 @@ export default function useUnstableCollapsibleAppBar(userOptions = defaultOption
76
75
  }
77
76
 
78
77
  offsetsRef.current[prevIndex] = lastOffsetY.value;
79
- const savedOffsetY = (_offsetsRef$current$n = offsetsRef.current[nextIndex]) !== null && _offsetsRef$current$n !== void 0 ? _offsetsRef$current$n : 0;
78
+ const savedOffsetY = offsetsRef.current[nextIndex] ?? 0;
80
79
  lastOffsetY.value = savedOffsetY;
81
80
  indexRef.current = nextIndex; // Determine whether to overlap every time index is changed.
82
81
 
83
82
  overlapped.value = savedOffsetY > 0; // If next ScrollView's offset is too short, expand app bar.
84
83
 
85
84
  if (translateY.value < 0 && savedOffsetY < appBarHeight) {
86
- translateY.value = Animated.withTiming(0, {
85
+ translateY.value = withTiming(0, {
87
86
  duration: ANIMATION_DURATION_MILLIS
88
87
  });
89
88
  vectorY.value = 0;
90
89
  }
91
90
  };
92
91
 
93
- const scrollHandler = Animated.useAnimatedScrollHandler({
92
+ const scrollHandler = useAnimatedScrollHandler({
94
93
  onBeginDrag: () => {
95
94
  lastTranslateY.value = translateY.value;
96
95
  },
@@ -112,13 +111,13 @@ export default function useUnstableCollapsibleAppBar(userOptions = defaultOption
112
111
  } else {
113
112
  if (offsetY > -maxTy) {
114
113
  if (ty === 0) {
115
- translateY.value = Animated.withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {
114
+ translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {
116
115
  duration: ANIMATION_DURATION_MILLIS
117
116
  });
118
117
  }
119
118
  } else {
120
119
  if (ty === maxTy) {
121
- translateY.value = Animated.withTiming(0, {
120
+ translateY.value = withTiming(0, {
122
121
  duration: ANIMATION_DURATION_MILLIS
123
122
  });
124
123
  }
@@ -144,7 +143,7 @@ export default function useUnstableCollapsibleAppBar(userOptions = defaultOption
144
143
  const threshold = maxTy * 0.5;
145
144
  const nextTranslateY = ty > threshold || offsetY < appBarHeight ? 0 : maxTy;
146
145
  overlapped.value = offsetY + nextTranslateY > 0;
147
- translateY.value = Animated.withTiming(nextTranslateY, {
146
+ translateY.value = withTiming(nextTranslateY, {
148
147
  duration: ANIMATION_DURATION_MILLIS
149
148
  });
150
149
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useUnstableCollapsibleAppBar.ts"],"names":["React","useRef","Platform","Animated","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","useAnimatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","withTiming","duration","savedOffsetY","scrollHandler","useAnimatedScrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,QAA8B,OAA9B;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AACA,OAAOC,QAAP,MAAqB,yBAArB;AACA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AA+BA,MAAMC,cAAiC,GAAG;AACtCC,EAAAA,qBAAqB,EAAE;AADe,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGT,QAAQ,CAACU,EAAT,KAAgB,KAAhD;;AAGA,SAASC,6BAAT,CAAuCC,KAAvC,EAAsD;AAClD,QAAMC,kBAAkB,GAAGd,MAAM,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,CAAjC;AAEAc,EAAAA,kBAAkB,CAACC,OAAnB,CAA2BC,KAA3B;AACAF,EAAAA,kBAAkB,CAACC,OAAnB,CAA2BE,IAA3B,CAAgCJ,KAAhC;AAEA,SAAOK,IAAI,CAACC,GAAL,CAAS,GAAGL,kBAAkB,CAACC,OAA/B,CAAP;AACH;;AAGD,eAAe,SAASK,4BAAT,CAAsCC,WAAoB,GAAGd,cAA7D,EAAgG;AAC3G,QAAM;AAAEC,IAAAA;AAAF,MAA+C,EACjD,GAAGD,cAD8C;AAEjD,OAAGc;AAF8C,GAArD;AAKA,QAAMC,MAAM,GAAGlB,eAAe,EAA9B;AAEA,QAAMmB,cAAc,GAAGpB,iBAAiB,EA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["import React, { useRef } 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 useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\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 shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: Animated.SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: 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 appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\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 prevOffsetY = Animated.useSharedValue<number>(0);\n const overlapped = Animated.useSharedValue<boolean>(false);\n const vectorY = Animated.useSharedValue<number>(0);\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 if (shouldTranslateYReset) {\n translateY.value = Animated.withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\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 vectorY.value = 0;\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 const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\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 { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"]}
1
+ {"version":3,"names":["React","useRef","Platform","useAnimatedScrollHandler","useAnimatedStyle","useDerivedValue","useSharedValue","withTiming","useSafeAreaInsets","useAppbarStyles","useElevationStyle","useHeight","defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","safeAreaInsets","appBarHeight","onAppBarLayout","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","translateY","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","animatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","nextIndex","prevIndex","duration","savedOffsetY","scrollHandler","onBeginDrag","onMomentumBegin","onScroll","event","offsetY","contentOffset","y","ty","maxTy","deltaY","dy","min","onEndDrag","onMomentumEnd","threshold","nextTranslateY","hasCollapsible","appBarStyle","paddingTop","top","floating","undefined","scrollContentInsets"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import React, { useRef } from 'react';\nimport { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport {\n useAnimatedScrollHandler,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport useAppbarStyles from './useAppbarStyles';\nimport useElevationStyle from './useElevationStyle';\nimport useHeight from './useHeight';\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 shouldTranslateYReset?: boolean;\n}\n\nexport interface CollapsibleAppBar {\n appBarStyle: ViewStyleProp;\n vectorY: SharedValue<number>;\n onAppBarLayout: OnLayoutCallback;\n onCollapsibleToolbarLayout: OnLayoutCallback;\n onScroll: OnScroll;\n onScrollViewChanged: (index: number) => void;\n scrollContentInsets: ContentInsets;\n}\n\nconst defaultOptions: Required<Options> = {\n shouldTranslateYReset: false,\n};\n\nconst ANIMATION_DURATION_MILLIS = 100;\n\nconst SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';\n\n\nfunction useLargerValueOfLastTwoValues(value: number) {\n const refLatestTwoValues = useRef([0, 0]);\n\n refLatestTwoValues.current.shift();\n refLatestTwoValues.current.push(value);\n\n return Math.max(...refLatestTwoValues.current);\n}\n\n\nexport default function useUnstableCollapsibleAppBar(userOptions: Options = defaultOptions): CollapsibleAppBar {\n const { shouldTranslateYReset }: 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 appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);\n const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();\n\n const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);\n\n const translateY = useSharedValue<number>(0);\n const lastTranslateY = useSharedValue<number>(0);\n const lastOffsetY = useSharedValue<number>(0);\n const prevOffsetY = useSharedValue<number>(0);\n const overlapped = useSharedValue<boolean>(false);\n const vectorY = useSharedValue<number>(0);\n\n const elevationStyle = useElevationStyle(4);\n const animatedStyle = 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 if (shouldTranslateYReset) {\n translateY.value = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n offsetsRef.current = [];\n overlapped.value = false;\n }\n\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 = withTiming(0, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n\n vectorY.value = 0;\n }\n };\n\n const scrollHandler = 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 const deltaY = offsetY - prevOffsetY.value;\n vectorY.value = (vectorY.value * deltaY >= 0 && offsetY > 0) ? vectorY.value + deltaY : deltaY;\n prevOffsetY.value = offsetY;\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 = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {\n duration: ANIMATION_DURATION_MILLIS,\n });\n }\n } else {\n if (ty === maxTy) {\n translateY.value = 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 = withTiming(nextTranslateY, {\n duration: ANIMATION_DURATION_MILLIS,\n });\n },\n });\n\n const hasCollapsible = collapsibleToolbarHeight > 0;\n\n const appBarStyle = [\n animatedStyle,\n { paddingTop: safeAreaInsets.top },\n hasCollapsible ? styles.floating : undefined,\n ];\n\n return {\n appBarStyle,\n vectorY,\n onAppBarLayout,\n onCollapsibleToolbarLayout,\n onScroll: scrollHandler,\n onScrollViewChanged,\n scrollContentInsets: { top: hasCollapsible ? appBarMaxHeight : 0 },\n };\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,QAA8B,OAA9B;AACA,SAAgBC,QAAhB,QAAwF,cAAxF;AAEA,SACIC,wBADJ,EAEIC,gBAFJ,EAGIC,eAHJ,EAIIC,cAJJ,EAKIC,UALJ,QAMO,yBANP;AAOA,SAASC,iBAAT,QAAkC,gCAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,SAAP,MAAsB,aAAtB;AA+BA,MAAMC,cAAiC,GAAG;EACtCC,qBAAqB,EAAE;AADe,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1C;EAPlB,CAAP;AASH;AAAA"}
@@ -1,14 +1,16 @@
1
- import Animated from 'react-native-reanimated';
2
- export default function useAnimatedDisplayStyle(vectorY, threshold = 200, defaultDisplay = 'flex') {
3
- const display = Animated.useSharedValue(defaultDisplay);
4
- Animated.useAnimatedReaction(() => vectorY.value, vy => {
1
+ import { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
2
+ export default function useAnimatedDisplayStyle(vectorY) {
3
+ let threshold = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
4
+ let defaultDisplay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'flex';
5
+ const display = useSharedValue(defaultDisplay);
6
+ useAnimatedReaction(() => vectorY.value, vy => {
5
7
  if (vy >= threshold) {
6
8
  display.value = 'none';
7
9
  } else if (vy < threshold) {
8
10
  display.value = 'flex';
9
11
  }
10
12
  });
11
- return Animated.useAnimatedStyle(() => ({
13
+ return useAnimatedStyle(() => ({
12
14
  display: display.value
13
15
  }));
14
16
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useUnstableToggleDisplayStyle.ts"],"names":["Animated","useAnimatedDisplayStyle","vectorY","threshold","defaultDisplay","display","useSharedValue","useAnimatedReaction","value","vy","useAnimatedStyle"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,yBAArB;AAEA,eAAe,SAASC,uBAAT,CACXC,OADW,EAEXC,SAAiB,GAAG,GAFT,EAGXC,cAA+B,GAAG,MAHvB,EAIb;AACE,QAAMC,OAAO,GAAGL,QAAQ,CAACM,cAAT,CAAwBF,cAAxB,CAAhB;AAEAJ,EAAAA,QAAQ,CAACO,mBAAT,CACI,MAAML,OAAO,CAACM,KADlB,EAEKC,EAAD,IAAQ;AACJ,QAAIA,EAAE,IAAIN,SAAV,EAAqB;AACjBE,MAAAA,OAAO,CAACG,KAAR,GAAgB,MAAhB;AACH,KAFD,MAEO,IAAIC,EAAE,GAAGN,SAAT,EAAoB;AACvBE,MAAAA,OAAO,CAACG,KAAR,GAAgB,MAAhB;AACH;AACJ,GARL;AAWA,SAAOR,QAAQ,CAACU,gBAAT,CAA0B,OAAO;AACpCL,IAAAA,OAAO,EAAEA,OAAO,CAACG;AADmB,GAAP,CAA1B,CAAP;AAGH;AAAA","sourcesContent":["import Animated from 'react-native-reanimated';\n\nexport default function useAnimatedDisplayStyle(\n vectorY: Animated.SharedValue<number>,\n threshold: number = 200,\n defaultDisplay: 'flex' | 'none' = 'flex',\n) {\n const display = Animated.useSharedValue(defaultDisplay);\n\n Animated.useAnimatedReaction(\n () => vectorY.value,\n (vy) => {\n if (vy >= threshold) {\n display.value = 'none';\n } else if (vy < threshold) {\n display.value = 'flex';\n }\n },\n );\n\n return Animated.useAnimatedStyle(() => ({\n display: display.value,\n }));\n};\n"]}
1
+ {"version":3,"names":["useAnimatedReaction","useAnimatedStyle","useSharedValue","useAnimatedDisplayStyle","vectorY","threshold","defaultDisplay","display","value","vy"],"sources":["useUnstableToggleDisplayStyle.ts"],"sourcesContent":["import type { SharedValue } from 'react-native-reanimated';\nimport { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';\n\nexport default function useAnimatedDisplayStyle(\n vectorY: SharedValue<number>,\n threshold: number = 200,\n defaultDisplay: 'flex' | 'none' = 'flex',\n) {\n const display = useSharedValue(defaultDisplay);\n\n useAnimatedReaction(\n () => vectorY.value,\n (vy) => {\n if (vy >= threshold) {\n display.value = 'none';\n } else if (vy < threshold) {\n display.value = 'flex';\n }\n },\n );\n\n return useAnimatedStyle(() => ({\n display: display.value,\n }));\n};\n"],"mappings":"AACA,SAASA,mBAAT,EAA8BC,gBAA9B,EAAgDC,cAAhD,QAAsE,yBAAtE;AAEA,eAAe,SAASC,uBAAT,CACXC,OADW,EAIb;EAAA,IAFEC,SAEF,uEAFsB,GAEtB;EAAA,IADEC,cACF,uEADoC,MACpC;EACE,MAAMC,OAAO,GAAGL,cAAc,CAACI,cAAD,CAA9B;EAEAN,mBAAmB,CACf,MAAMI,OAAO,CAACI,KADC,EAEdC,EAAD,IAAQ;IACJ,IAAIA,EAAE,IAAIJ,SAAV,EAAqB;MACjBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH,CAFD,MAEO,IAAIC,EAAE,GAAGJ,SAAT,EAAoB;MACvBE,OAAO,CAACC,KAAR,GAAgB,MAAhB;IACH;EACJ,CARc,CAAnB;EAWA,OAAOP,gBAAgB,CAAC,OAAO;IAC3BM,OAAO,EAAEA,OAAO,CAACC;EADU,CAAP,CAAD,CAAvB;AAGH;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["useWidth.ts"],"names":["React","useWindowDimensions","useWidth","window","width","setWidth","useState","onLayout","useCallback","e","newWidth","nativeEvent","layout","Math","round"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAA4BC,mBAA5B,QAAkE,cAAlE;AAEA,eAAe,SAASC,QAAT,GAAqD;AAChE,QAAMC,MAAM,GAAGF,mBAAmB,EAAlC;AACA,QAAM,CAACG,KAAD,EAAQC,QAAR,IAAoBL,KAAK,CAACM,QAAN,CAAeH,MAAM,CAACC,KAAtB,CAA1B;AAEA,QAAMG,QAAQ,GAAGP,KAAK,CAACQ,WAAN,CAAmBC,CAAD,IAA0B;AACzD,UAAMC,QAAQ,GAAGD,CAAC,CAACE,WAAF,CAAcC,MAAd,CAAqBR,KAAtC;;AAEA,QAAIM,QAAQ,GAAG,CAAX,IAAgBG,IAAI,CAACC,KAAL,CAAWJ,QAAX,MAAyBG,IAAI,CAACC,KAAL,CAAWV,KAAX,CAA7C,EAAgE;AAC5DC,MAAAA,QAAQ,CAACK,QAAD,CAAR;AACH;AACJ,GANgB,EAMd,EANc,CAAjB;AAQA,SAAO,CAACN,KAAD,EAAQG,QAAR,CAAP;AACH","sourcesContent":["import React from 'react';\nimport { LayoutChangeEvent, useWindowDimensions, ViewProps } from 'react-native';\n\nexport default function useWidth(): [number, ViewProps['onLayout']] {\n const window = useWindowDimensions();\n const [width, setWidth] = React.useState(window.width);\n\n const onLayout = React.useCallback((e: LayoutChangeEvent) => {\n const newWidth = e.nativeEvent.layout.width;\n\n if (newWidth > 0 && Math.round(newWidth) !== Math.round(width)) {\n setWidth(newWidth);\n }\n }, []);\n\n return [width, onLayout];\n}"]}
1
+ {"version":3,"names":["React","useWindowDimensions","useWidth","window","width","setWidth","useState","onLayout","useCallback","e","newWidth","nativeEvent","layout","Math","round"],"sources":["useWidth.ts"],"sourcesContent":["import React from 'react';\nimport { LayoutChangeEvent, useWindowDimensions, ViewProps } from 'react-native';\n\nexport default function useWidth(): [number, ViewProps['onLayout']] {\n const window = useWindowDimensions();\n const [width, setWidth] = React.useState(window.width);\n\n const onLayout = React.useCallback((e: LayoutChangeEvent) => {\n const newWidth = e.nativeEvent.layout.width;\n\n if (newWidth > 0 && Math.round(newWidth) !== Math.round(width)) {\n setWidth(newWidth);\n }\n }, []);\n\n return [width, onLayout];\n}"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAA4BC,mBAA5B,QAAkE,cAAlE;AAEA,eAAe,SAASC,QAAT,GAAqD;EAChE,MAAMC,MAAM,GAAGF,mBAAmB,EAAlC;EACA,MAAM,CAACG,KAAD,EAAQC,QAAR,IAAoBL,KAAK,CAACM,QAAN,CAAeH,MAAM,CAACC,KAAtB,CAA1B;EAEA,MAAMG,QAAQ,GAAGP,KAAK,CAACQ,WAAN,CAAmBC,CAAD,IAA0B;IACzD,MAAMC,QAAQ,GAAGD,CAAC,CAACE,WAAF,CAAcC,MAAd,CAAqBR,KAAtC;;IAEA,IAAIM,QAAQ,GAAG,CAAX,IAAgBG,IAAI,CAACC,KAAL,CAAWJ,QAAX,MAAyBG,IAAI,CAACC,KAAL,CAAWV,KAAX,CAA7C,EAAgE;MAC5DC,QAAQ,CAACK,QAAD,CAAR;IACH;EACJ,CANgB,EAMd,EANc,CAAjB;EAQA,OAAO,CAACN,KAAD,EAAQG,QAAR,CAAP;AACH"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,cAAc,SAAd","sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"]}
1
+ {"version":3,"names":["default","BottomSheet","Carousel","DateTimePicker","FlipCard","ViewPager","ComicViewer","StatusBarProvider","useStatusBarContext"],"sources":["index.ts"],"sourcesContent":["export { default as BottomSheet } from './BottomSheet';\nexport * from './BottomSheet';\n\nexport { default as Carousel } from './Carousel';\nexport * from './Carousel';\n\nexport { default as DateTimePicker } from './DateTimePicker';\nexport * from './DateTimePicker';\n\nexport { default as FlipCard } from './FlipCard';\nexport * from './FlipCard';\n\nexport { default as ViewPager } from './ViewPager';\nexport * from './ViewPager';\n\nexport { default as ComicViewer } from './ComicViewer';\nexport * from './ComicViewer';\n\nexport { default as StatusBarProvider, useStatusBarContext } from './StatusBarProvider';\nexport * from './StatusBarProvider';\n\nexport * from './hooks';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASD,OAAO,IAAIE,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASF,OAAO,IAAIG,cAApB,QAA0C,kBAA1C;AACA,cAAc,kBAAd;AAEA,SAASH,OAAO,IAAII,QAApB,QAAoC,YAApC;AACA,cAAc,YAAd;AAEA,SAASJ,OAAO,IAAIK,SAApB,QAAqC,aAArC;AACA,cAAc,aAAd;AAEA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,cAAc,eAAd;AAEA,SAASN,OAAO,IAAIO,iBAApB,EAAuCC,mBAAvC,QAAkE,qBAAlE;AACA,cAAc,qBAAd;AAEA,cAAc,SAAd"}
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type AnimatedYProps from './AnimatedYProps';
3
2
  export default function AnimatedY(props: AnimatedYProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BottomSheetProps from './BottomSheetProps';
3
2
  export default function BottomSheet(props: BottomSheetProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type BottomSheetProps from './BottomSheetProps';
3
2
  export default function BottomSheet(props: BottomSheetProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { BottomSheetBackdropProps } from '@gorhom/bottom-sheet';
3
2
  export default function TransparentBackdrop(props: BottomSheetBackdropProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type CarouselProps from './CarouselProps';
3
2
  export default function Carousel<ItemT>(props: CarouselProps<ItemT>): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { default as ComicViewerProps } from './ComicViewerProps';
3
2
  export default function ComicViewer<T>(props: ComicViewerProps<T>): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type DateTimePickerProps from './DateTimePickerProps';
3
2
  export default function DateTimePicker(props: DateTimePickerProps): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  interface YearPickerProps {
3
2
  date: Date;
4
3
  locale?: string;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type FlipCardProps from './FlipCardProps';
3
2
  export default function FlipCard(props: FlipCardProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type StatusBarProviderProps from './StatusBarProviderProps';
3
2
  export default function StatusBarProvider(props: StatusBarProviderProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ViewPagerProps from './ViewPagerProps';
3
2
  export default function ViewPager(props: ViewPagerProps): JSX.Element;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type ViewPagerProps from './ViewPagerProps';
3
2
  export default function ViewPager(props: ViewPagerProps): JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Falsy, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
2
- import Animated from 'react-native-reanimated';
2
+ import type { SharedValue } from 'react-native-reanimated';
3
3
  declare type WebOnlyStyle = {
4
4
  boxShadow: any;
5
5
  };
@@ -17,7 +17,7 @@ export interface Options {
17
17
  }
18
18
  export interface CollapsibleAppBar {
19
19
  appBarStyle: ViewStyleProp;
20
- vectorY: Animated.SharedValue<number>;
20
+ vectorY: SharedValue<number>;
21
21
  onAppBarLayout: OnLayoutCallback;
22
22
  onCollapsibleToolbarLayout: OnLayoutCallback;
23
23
  onScroll: OnScroll;
@@ -1,4 +1,4 @@
1
- import Animated from 'react-native-reanimated';
2
- export default function useAnimatedDisplayStyle(vectorY: Animated.SharedValue<number>, threshold?: number, defaultDisplay?: 'flex' | 'none'): {
1
+ import type { SharedValue } from 'react-native-reanimated';
2
+ export default function useAnimatedDisplayStyle(vectorY: SharedValue<number>, threshold?: number, defaultDisplay?: 'flex' | 'none'): {
3
3
  display: "flex" | "none";
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/lab",
3
- "version": "2.0.0-beta.6",
3
+ "version": "2.0.0-beta.7",
4
4
  "private": false,
5
5
  "author": "Fountain-UI Team",
6
6
  "description": "Incubator for Fountain-UI React components.",
@@ -15,8 +15,8 @@
15
15
  "prepare": "bob build"
16
16
  },
17
17
  "dependencies": {
18
- "@emotion/react": "^11.4.1",
19
- "@emotion/styled": "^11.0.0",
18
+ "@emotion/react": "^11.10.0",
19
+ "@emotion/styled": "^11.10.0",
20
20
  "@fountain-ui/icons": "^2.0.0-beta.6",
21
21
  "@fountain-ui/utils": "^2.0.0-beta.3",
22
22
  "react-native-calendars": "1.1267.0"
@@ -29,6 +29,7 @@
29
29
  "react": "^16.8.0 || ^17.0.0",
30
30
  "react-dom": "^16.8.0 || ^17.0.0",
31
31
  "react-native": "^0.63.0",
32
+ "react-native-gesture-handler": "^2.0.0",
32
33
  "react-native-snap-carousel": "^3.9.0",
33
34
  "react-slick": "^0.25.0"
34
35
  },
@@ -84,5 +85,5 @@
84
85
  "publishConfig": {
85
86
  "access": "public"
86
87
  },
87
- "gitHead": "10ec965daab032df7f6e7e09f793de59b9b5f787"
88
+ "gitHead": "92adfb973082a3ebaa68ab16d8144230523b36d8"
88
89
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import Animated, { Easing } from 'react-native-reanimated';
2
+ import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
3
3
  import type AnimatedYProps from './AnimatedYProps';
4
4
 
5
5
  export default function AnimatedY(props: AnimatedYProps) {
@@ -9,14 +9,14 @@ export default function AnimatedY(props: AnimatedYProps) {
9
9
  style,
10
10
  } = props;
11
11
 
12
- const animatedY = Animated.useSharedValue(translateY);
13
- const animatedStyle = Animated.useAnimatedStyle(() => ({
12
+ const animatedY = useSharedValue(translateY);
13
+ const animatedStyle = useAnimatedStyle(() => ({
14
14
  transform: [{ translateY: animatedY.value }],
15
15
  }));
16
16
 
17
17
  React.useEffect(() => {
18
18
  if (translateY >= 0) {
19
- animatedY.value = Animated.withTiming(translateY, {
19
+ animatedY.value = withTiming(translateY, {
20
20
  duration: 150,
21
21
  easing: Easing.out(Easing.exp),
22
22
  });
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
- import Animated from 'react-native-reanimated';
3
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
4
4
  import type FlipCardProps from './FlipCardProps';
5
5
 
6
6
  const styles = StyleSheet.create({
@@ -27,9 +27,9 @@ export default function FlipCard(props: FlipCardProps) {
27
27
  style,
28
28
  } = props;
29
29
 
30
- const sharedAngle = Animated.useSharedValue(0);
30
+ const sharedAngle = useSharedValue(0);
31
31
 
32
- const animatedFrontCardStyle = Animated.useAnimatedStyle(() => {
32
+ const animatedFrontCardStyle = useAnimatedStyle(() => {
33
33
  return {
34
34
  zIndex: sharedAngle.value < Z_INDEX_CHANGE_ANGLE ? 2 : 1,
35
35
  transform: [
@@ -39,7 +39,7 @@ export default function FlipCard(props: FlipCardProps) {
39
39
  };
40
40
  });
41
41
 
42
- const animatedBackCardStyle = Animated.useAnimatedStyle(() => {
42
+ const animatedBackCardStyle = useAnimatedStyle(() => {
43
43
  return {
44
44
  zIndex: sharedAngle.value <= Z_INDEX_CHANGE_ANGLE ? 1 : 2,
45
45
  transform: [
@@ -51,7 +51,7 @@ export default function FlipCard(props: FlipCardProps) {
51
51
 
52
52
  useEffect(() => {
53
53
  sharedAngle.value = 0;
54
- sharedAngle.value = Animated.withTiming(180, { duration: 500 });
54
+ sharedAngle.value = withTiming(180, { duration: 500 });
55
55
  }, [reanimationKey]);
56
56
 
57
57
  return (
@@ -65,4 +65,4 @@ export default function FlipCard(props: FlipCardProps) {
65
65
  </Animated.View>
66
66
  </View>
67
67
  );
68
- };
68
+ };
@@ -1,13 +1,13 @@
1
1
  import React from 'react';
2
2
  import { ViewProps } from 'react-native';
3
- import Animated from 'react-native-reanimated';
3
+ import { useWorkletCallback } from 'react-native-reanimated';
4
4
 
5
5
  type OnLayoutCallback = ViewProps['onLayout'];
6
6
 
7
7
  export default function useHeight(initialHeight = 0): [number, OnLayoutCallback] {
8
8
  const [height, setHeight] = React.useState<number>(initialHeight);
9
9
 
10
- const onLayout = Animated.useWorkletCallback((e) => {
10
+ const onLayout = useWorkletCallback((e) => {
11
11
  setHeight(e.nativeEvent.layout.height);
12
12
  }, []);
13
13
 
@@ -1,6 +1,13 @@
1
1
  import React, { useRef } from 'react';
2
2
  import { Falsy, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
3
- import Animated from 'react-native-reanimated';
3
+ import type { SharedValue } from 'react-native-reanimated';
4
+ import {
5
+ useAnimatedScrollHandler,
6
+ useAnimatedStyle,
7
+ useDerivedValue,
8
+ useSharedValue,
9
+ withTiming,
10
+ } from 'react-native-reanimated';
4
11
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
5
12
  import useAppbarStyles from './useAppbarStyles';
6
13
  import useElevationStyle from './useElevationStyle';
@@ -27,7 +34,7 @@ export interface Options {
27
34
 
28
35
  export interface CollapsibleAppBar {
29
36
  appBarStyle: ViewStyleProp;
30
- vectorY: Animated.SharedValue<number>;
37
+ vectorY: SharedValue<number>;
31
38
  onAppBarLayout: OnLayoutCallback;
32
39
  onCollapsibleToolbarLayout: OnLayoutCallback;
33
40
  onScroll: OnScroll;
@@ -68,17 +75,17 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
68
75
  const appBarMaxHeight = useLargerValueOfLastTwoValues(appBarHeight);
69
76
  const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();
70
77
 
71
- const maxTranslateY = Animated.useDerivedValue(() => -collapsibleToolbarHeight);
78
+ const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);
72
79
 
73
- const translateY = Animated.useSharedValue<number>(0);
74
- const lastTranslateY = Animated.useSharedValue<number>(0);
75
- const lastOffsetY = Animated.useSharedValue<number>(0);
76
- const prevOffsetY = Animated.useSharedValue<number>(0);
77
- const overlapped = Animated.useSharedValue<boolean>(false);
78
- const vectorY = Animated.useSharedValue<number>(0);
80
+ const translateY = useSharedValue<number>(0);
81
+ const lastTranslateY = useSharedValue<number>(0);
82
+ const lastOffsetY = useSharedValue<number>(0);
83
+ const prevOffsetY = useSharedValue<number>(0);
84
+ const overlapped = useSharedValue<boolean>(false);
85
+ const vectorY = useSharedValue<number>(0);
79
86
 
80
87
  const elevationStyle = useElevationStyle(4);
81
- const animatedStyle = Animated.useAnimatedStyle(() => {
88
+ const animatedStyle = useAnimatedStyle(() => {
82
89
  return Platform.OS === 'web' ? ({
83
90
  transform: [{ translateY: translateY.value }],
84
91
  boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,
@@ -99,7 +106,7 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
99
106
  const prevIndex = indexRef.current;
100
107
  if (prevIndex === nextIndex) {
101
108
  if (shouldTranslateYReset) {
102
- translateY.value = Animated.withTiming(0, {
109
+ translateY.value = withTiming(0, {
103
110
  duration: ANIMATION_DURATION_MILLIS,
104
111
  });
105
112
 
@@ -123,7 +130,7 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
123
130
 
124
131
  // If next ScrollView's offset is too short, expand app bar.
125
132
  if (translateY.value < 0 && savedOffsetY < appBarHeight) {
126
- translateY.value = Animated.withTiming(0, {
133
+ translateY.value = withTiming(0, {
127
134
  duration: ANIMATION_DURATION_MILLIS,
128
135
  });
129
136
 
@@ -131,7 +138,7 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
131
138
  }
132
139
  };
133
140
 
134
- const scrollHandler = Animated.useAnimatedScrollHandler({
141
+ const scrollHandler = useAnimatedScrollHandler({
135
142
  onBeginDrag: () => {
136
143
  lastTranslateY.value = translateY.value;
137
144
  },
@@ -157,13 +164,13 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
157
164
  } else {
158
165
  if (offsetY > -maxTy) {
159
166
  if (ty === 0) {
160
- translateY.value = Animated.withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {
167
+ translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), {
161
168
  duration: ANIMATION_DURATION_MILLIS,
162
169
  });
163
170
  }
164
171
  } else {
165
172
  if (ty === maxTy) {
166
- translateY.value = Animated.withTiming(0, {
173
+ translateY.value = withTiming(0, {
167
174
  duration: ANIMATION_DURATION_MILLIS,
168
175
  });
169
176
  }
@@ -196,7 +203,7 @@ export default function useUnstableCollapsibleAppBar(userOptions: Options = defa
196
203
 
197
204
  overlapped.value = offsetY + nextTranslateY > 0;
198
205
 
199
- translateY.value = Animated.withTiming(nextTranslateY, {
206
+ translateY.value = withTiming(nextTranslateY, {
200
207
  duration: ANIMATION_DURATION_MILLIS,
201
208
  });
202
209
  },
@@ -1,13 +1,14 @@
1
- import Animated from 'react-native-reanimated';
1
+ import type { SharedValue } from 'react-native-reanimated';
2
+ import { useAnimatedReaction, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
2
3
 
3
4
  export default function useAnimatedDisplayStyle(
4
- vectorY: Animated.SharedValue<number>,
5
+ vectorY: SharedValue<number>,
5
6
  threshold: number = 200,
6
7
  defaultDisplay: 'flex' | 'none' = 'flex',
7
8
  ) {
8
- const display = Animated.useSharedValue(defaultDisplay);
9
+ const display = useSharedValue(defaultDisplay);
9
10
 
10
- Animated.useAnimatedReaction(
11
+ useAnimatedReaction(
11
12
  () => vectorY.value,
12
13
  (vy) => {
13
14
  if (vy >= threshold) {
@@ -18,7 +19,7 @@ export default function useAnimatedDisplayStyle(
18
19
  },
19
20
  );
20
21
 
21
- return Animated.useAnimatedStyle(() => ({
22
+ return useAnimatedStyle(() => ({
22
23
  display: display.value,
23
24
  }));
24
25
  };