@fountain-ui/lab 2.0.0-beta.19 → 2.0.0-beta.22

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 (125) hide show
  1. package/build/commonjs/ViewPager/FluxContext.js +13 -0
  2. package/build/commonjs/ViewPager/FluxContext.js.map +1 -0
  3. package/build/commonjs/ViewPager/PageStateContext.js +1 -7
  4. package/build/commonjs/ViewPager/PageStateContext.js.map +1 -1
  5. package/build/commonjs/ViewPager/{ViewPagerWeb.js → ViewPager.js} +10 -9
  6. package/build/commonjs/ViewPager/ViewPager.js.map +1 -0
  7. package/build/commonjs/ViewPager/{ViewPagerNative.js → ViewPager.native.js} +11 -10
  8. package/build/commonjs/ViewPager/ViewPager.native.js.map +1 -0
  9. package/build/commonjs/ViewPager/ViewPagerProps.js.map +1 -1
  10. package/build/commonjs/ViewPager/{ChildrenMemoizedPage.js → components/ChildrenMemoizedPage.js} +5 -3
  11. package/build/commonjs/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  12. package/build/commonjs/ViewPager/components/FluxStoreProvider.js +37 -0
  13. package/build/commonjs/ViewPager/components/FluxStoreProvider.js.map +1 -0
  14. package/build/commonjs/ViewPager/components/index.js +24 -0
  15. package/build/commonjs/ViewPager/components/index.js.map +1 -0
  16. package/build/commonjs/ViewPager/hooks/index.js +56 -0
  17. package/build/commonjs/ViewPager/hooks/index.js.map +1 -0
  18. package/build/commonjs/ViewPager/hooks/useDispatch.js +22 -0
  19. package/build/commonjs/ViewPager/hooks/useDispatch.js.map +1 -0
  20. package/build/commonjs/ViewPager/hooks/useForceRender.js +16 -0
  21. package/build/commonjs/ViewPager/hooks/useForceRender.js.map +1 -0
  22. package/build/commonjs/ViewPager/hooks/useLazyState.js +45 -0
  23. package/build/commonjs/ViewPager/hooks/useLazyState.js.map +1 -0
  24. package/build/commonjs/ViewPager/{usePageStore.js → hooks/usePageStore.js} +0 -0
  25. package/build/commonjs/ViewPager/{usePageStore.js.map → hooks/usePageStore.js.map} +0 -0
  26. package/build/commonjs/ViewPager/hooks/useStore.js +26 -0
  27. package/build/commonjs/ViewPager/hooks/useStore.js.map +1 -0
  28. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js +19 -0
  29. package/build/commonjs/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  30. package/build/commonjs/ViewPager/index.js +30 -4
  31. package/build/commonjs/ViewPager/index.js.map +1 -1
  32. package/build/commonjs/ViewPager/types.js +0 -4
  33. package/build/commonjs/ViewPager/types.js.map +1 -1
  34. package/build/commonjs/ViewPager/utils.js +5 -8
  35. package/build/commonjs/ViewPager/utils.js.map +1 -1
  36. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js +2 -4
  37. package/build/commonjs/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  38. package/build/module/ViewPager/FluxContext.js +4 -0
  39. package/build/module/ViewPager/FluxContext.js.map +1 -0
  40. package/build/module/ViewPager/PageStateContext.js +1 -4
  41. package/build/module/ViewPager/PageStateContext.js.map +1 -1
  42. package/build/module/ViewPager/{ViewPagerWeb.js → ViewPager.js} +10 -10
  43. package/build/module/ViewPager/ViewPager.js.map +1 -0
  44. package/build/module/ViewPager/{ViewPagerNative.js → ViewPager.native.js} +10 -10
  45. package/build/module/ViewPager/ViewPager.native.js.map +1 -0
  46. package/build/module/ViewPager/ViewPagerProps.js.map +1 -1
  47. package/build/module/ViewPager/{ChildrenMemoizedPage.js → components/ChildrenMemoizedPage.js} +5 -4
  48. package/build/module/ViewPager/components/ChildrenMemoizedPage.js.map +1 -0
  49. package/build/module/ViewPager/components/FluxStoreProvider.js +20 -0
  50. package/build/module/ViewPager/components/FluxStoreProvider.js.map +1 -0
  51. package/build/module/ViewPager/components/index.js +3 -0
  52. package/build/module/ViewPager/components/index.js.map +1 -0
  53. package/build/module/ViewPager/hooks/index.js +7 -0
  54. package/build/module/ViewPager/hooks/index.js.map +1 -0
  55. package/build/module/ViewPager/hooks/useDispatch.js +10 -0
  56. package/build/module/ViewPager/hooks/useDispatch.js.map +1 -0
  57. package/build/module/ViewPager/hooks/useForceRender.js +7 -0
  58. package/build/module/ViewPager/hooks/useForceRender.js.map +1 -0
  59. package/build/module/ViewPager/hooks/useLazyState.js +30 -0
  60. package/build/module/ViewPager/hooks/useLazyState.js.map +1 -0
  61. package/build/module/ViewPager/{usePageStore.js → hooks/usePageStore.js} +0 -0
  62. package/build/module/ViewPager/{usePageStore.js.map → hooks/usePageStore.js.map} +0 -0
  63. package/build/module/ViewPager/hooks/useStore.js +14 -0
  64. package/build/module/ViewPager/hooks/useStore.js.map +1 -0
  65. package/build/module/ViewPager/hooks/useViewPagerPageState.js +7 -0
  66. package/build/module/ViewPager/hooks/useViewPagerPageState.js.map +1 -0
  67. package/build/module/ViewPager/index.js +3 -2
  68. package/build/module/ViewPager/index.js.map +1 -1
  69. package/build/module/ViewPager/types.js +1 -1
  70. package/build/module/ViewPager/types.js.map +1 -1
  71. package/build/module/ViewPager/utils.js +1 -2
  72. package/build/module/ViewPager/utils.js.map +1 -1
  73. package/build/module/hooks/useUnstableCollapsibleAppBar.js +3 -5
  74. package/build/module/hooks/useUnstableCollapsibleAppBar.js.map +1 -1
  75. package/build/typescript/ViewPager/FluxContext.d.ts +5 -0
  76. package/build/typescript/ViewPager/PageStateContext.d.ts +1 -2
  77. package/build/typescript/ViewPager/{ViewPagerNative.d.ts → ViewPager.d.ts} +1 -1
  78. package/build/typescript/ViewPager/{ViewPagerWeb.d.ts → ViewPager.native.d.ts} +1 -1
  79. package/build/typescript/ViewPager/ViewPagerProps.d.ts +1 -6
  80. package/build/typescript/ViewPager/components/ChildrenMemoizedPage.d.ts +14 -0
  81. package/build/typescript/ViewPager/components/FluxStoreProvider.d.ts +6 -0
  82. package/build/typescript/ViewPager/components/index.d.ts +2 -0
  83. package/build/typescript/ViewPager/hooks/index.d.ts +6 -0
  84. package/build/typescript/ViewPager/hooks/useDispatch.d.ts +2 -0
  85. package/build/typescript/ViewPager/hooks/useForceRender.d.ts +2 -0
  86. package/build/typescript/ViewPager/hooks/useLazyState.d.ts +2 -0
  87. package/build/typescript/ViewPager/{usePageStore.d.ts → hooks/usePageStore.d.ts} +0 -0
  88. package/build/typescript/ViewPager/hooks/useStore.d.ts +2 -0
  89. package/build/typescript/ViewPager/hooks/useViewPagerPageState.d.ts +1 -0
  90. package/build/typescript/ViewPager/index.d.ts +3 -2
  91. package/build/typescript/ViewPager/types.d.ts +3 -10
  92. package/build/typescript/ViewPager/utils.d.ts +2 -2
  93. package/package.json +2 -2
  94. package/src/ViewPager/FluxContext.ts +8 -0
  95. package/src/ViewPager/PageStateContext.ts +2 -6
  96. package/src/ViewPager/{ViewPagerNative.tsx → ViewPager.native.tsx} +7 -7
  97. package/src/ViewPager/{ViewPagerWeb.tsx → ViewPager.tsx} +7 -7
  98. package/src/ViewPager/ViewPagerProps.ts +1 -7
  99. package/src/ViewPager/{ChildrenMemoizedPage.tsx → components/ChildrenMemoizedPage.tsx} +16 -5
  100. package/src/ViewPager/components/FluxStoreProvider.tsx +27 -0
  101. package/src/ViewPager/components/index.ts +2 -0
  102. package/src/ViewPager/hooks/index.ts +6 -0
  103. package/src/ViewPager/hooks/useDispatch.ts +11 -0
  104. package/src/ViewPager/hooks/useForceRender.ts +7 -0
  105. package/src/ViewPager/hooks/useLazyState.ts +32 -0
  106. package/src/ViewPager/{usePageStore.ts → hooks/usePageStore.ts} +0 -0
  107. package/src/ViewPager/hooks/useStore.ts +15 -0
  108. package/src/ViewPager/hooks/useViewPagerPageState.ts +6 -0
  109. package/src/ViewPager/index.ts +3 -2
  110. package/src/ViewPager/types.ts +4 -13
  111. package/src/ViewPager/utils.tsx +2 -3
  112. package/src/hooks/useUnstableCollapsibleAppBar.ts +3 -3
  113. package/build/commonjs/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  114. package/build/commonjs/ViewPager/ViewPagerNative.js.map +0 -1
  115. package/build/commonjs/ViewPager/ViewPagerWeb.js.map +0 -1
  116. package/build/commonjs/ViewPager/index.native.js +0 -24
  117. package/build/commonjs/ViewPager/index.native.js.map +0 -1
  118. package/build/module/ViewPager/ChildrenMemoizedPage.js.map +0 -1
  119. package/build/module/ViewPager/ViewPagerNative.js.map +0 -1
  120. package/build/module/ViewPager/ViewPagerWeb.js.map +0 -1
  121. package/build/module/ViewPager/index.native.js +0 -3
  122. package/build/module/ViewPager/index.native.js.map +0 -1
  123. package/build/typescript/ViewPager/ChildrenMemoizedPage.d.ts +0 -5
  124. package/build/typescript/ViewPager/index.native.d.ts +0 -2
  125. package/src/ViewPager/index.native.ts +0 -2
@@ -3,18 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.defaultPageComponent = exports.defaultOffscreenPageRerenderLimit = exports.defaultLoading = exports.defaultInitialPage = void 0;
7
-
8
- var _ChildrenMemoizedPage = _interopRequireDefault(require("./ChildrenMemoizedPage"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
6
+ exports.refEqual = exports.defaultOffscreenPageRerenderLimit = exports.defaultLoading = exports.defaultInitialPage = void 0;
12
7
  const defaultInitialPage = 0;
13
8
  exports.defaultInitialPage = defaultInitialPage;
14
9
  const defaultLoading = 'lazy';
15
10
  exports.defaultLoading = defaultLoading;
16
11
  const defaultOffscreenPageRerenderLimit = 0;
17
12
  exports.defaultOffscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit;
18
- const defaultPageComponent = _ChildrenMemoizedPage.default;
19
- exports.defaultPageComponent = defaultPageComponent;
13
+
14
+ const refEqual = (a, b) => a === b;
15
+
16
+ exports.refEqual = refEqual;
20
17
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","defaultPageComponent","ChildrenMemoizedPage"],"sources":["utils.tsx"],"sourcesContent":["import ChildrenMemoizedPage from './ChildrenMemoizedPage';\nimport type { Loading, PageComponent } from './types';\n\nexport const defaultInitialPage: number = 0;\n\nexport const defaultLoading: Loading = 'lazy';\n\nexport const defaultOffscreenPageRerenderLimit: number = 0;\n\nexport const defaultPageComponent: PageComponent = ChildrenMemoizedPage;\n"],"mappings":";;;;;;;AAAA;;;;AAGO,MAAMA,kBAA0B,GAAG,CAAnC;;AAEA,MAAMC,cAAuB,GAAG,MAAhC;;AAEA,MAAMC,iCAAyC,GAAG,CAAlD;;AAEA,MAAMC,oBAAmC,GAAGC,6BAA5C"}
1
+ {"version":3,"names":["defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","refEqual","a","b"],"sources":["utils.tsx"],"sourcesContent":["import type { EqualityFunction, Loading } from './types';\n\nexport const defaultInitialPage: number = 0;\n\nexport const defaultLoading: Loading = 'lazy';\n\nexport const defaultOffscreenPageRerenderLimit: number = 0;\n\nexport const refEqual: EqualityFunction<any> = (a: any, b: any) => a === b;\n"],"mappings":";;;;;;AAEO,MAAMA,kBAA0B,GAAG,CAAnC;;AAEA,MAAMC,cAAuB,GAAG,MAAhC;;AAEA,MAAMC,iCAAyC,GAAG,CAAlD;;;AAEA,MAAMC,QAA+B,GAAG,CAACC,CAAD,EAASC,CAAT,KAAoBD,CAAC,KAAKC,CAAlE"}
@@ -91,8 +91,7 @@ function useUnstableCollapsibleAppBar() {
91
91
  ]);
92
92
  const indexRef = (0, _react.useRef)(0);
93
93
  const offsetsRef = (0, _react.useRef)([]);
94
-
95
- const onScrollViewChanged = nextIndex => {
94
+ const onScrollViewChanged = (0, _react.useCallback)(nextIndex => {
96
95
  const prevIndex = indexRef.current;
97
96
 
98
97
  if (prevIndex === nextIndex) {
@@ -121,8 +120,7 @@ function useUnstableCollapsibleAppBar() {
121
120
  });
122
121
  vectorY.value = 0;
123
122
  }
124
- };
125
-
123
+ }, [appBarHeight]);
126
124
  const scrollHandler = (0, _reactNativeReanimated.useAnimatedScrollHandler)({
127
125
  onBeginDrag: () => {
128
126
  lastTranslateY.value = translateY.value;
@@ -1 +1 @@
1
- {"version":3,"names":["defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","Platform","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","useRef","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","useAppbarStyles","safeAreaInsets","useSafeAreaInsets","appBarHeight","onAppBarLayout","useHeight","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","useElevationStyle","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"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import { 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\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\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, [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 const transform = [{ translateY: translateY.value }];\n\n if (Platform.OS === 'web') {\n return {\n transform,\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n }, [\n /**\n * FIXME: Consider add `elevationStyle` to dependencies.\n */\n ]);\n\n const indexRef = useRef<number>(0);\n const offsetsRef = 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 }, [appBarHeight]);\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;;AACA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;;;AA+BA,MAAMA,cAAiC,GAAG;EACtCC,qBAAqB,EAAE;AADe,CAA1C;AAIA,MAAMC,yBAAyB,GAAG,GAAlC;AAEA,MAAMC,uBAAuB,GAAGC,qBAAA,CAASC,EAAT,KAAgB,KAAhD;;AAEA,SAASC,6BAAT,CAAuCC,KAAvC,EAAsD;EAClD,MAAMC,kBAAkB,GAAG,IAAA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O;IACHJ,WADG;IAEHvC,OAFG;IAGHb,cAHG;IAIHI,0BAJG;IAKHiC,QAAQ,EAAEJ,aALP;IAMHN,mBANG;IAOH8B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAGjD,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;;AAAA"}
1
+ {"version":3,"names":["defaultOptions","shouldTranslateYReset","ANIMATION_DURATION_MILLIS","SUPPORTS_DRAG_DETECTION","Platform","OS","useLargerValueOfLastTwoValues","value","refLatestTwoValues","useRef","current","shift","push","Math","max","useUnstableCollapsibleAppBar","userOptions","styles","useAppbarStyles","safeAreaInsets","useSafeAreaInsets","appBarHeight","onAppBarLayout","useHeight","appBarMaxHeight","collapsibleToolbarHeight","onCollapsibleToolbarLayout","maxTranslateY","useDerivedValue","translateY","useSharedValue","lastTranslateY","lastOffsetY","prevOffsetY","overlapped","vectorY","elevationStyle","useElevationStyle","animatedStyle","useAnimatedStyle","transform","boxShadow","elevation","shadowColor","shadowOffset","shadowRadius","shadowOpacity","indexRef","offsetsRef","onScrollViewChanged","useCallback","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"],"sources":["useUnstableCollapsibleAppBar.ts"],"sourcesContent":["import { useCallback, 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\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\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, [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 const transform = [{ translateY: translateY.value }];\n\n if (Platform.OS === 'web') {\n return {\n transform,\n boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,\n };\n }\n if (Platform.OS === 'android') {\n return {\n transform,\n elevation: overlapped.value ? elevationStyle?.elevation : 0,\n };\n }\n if (Platform.OS === 'ios') {\n return {\n transform,\n shadowColor: elevationStyle?.shadowColor,\n shadowOffset: elevationStyle?.shadowOffset,\n shadowRadius: elevationStyle?.shadowRadius,\n shadowOpacity: overlapped.value ? elevationStyle?.shadowOpacity : 0,\n };\n }\n return {};\n }, [\n /**\n * FIXME: Consider add `elevationStyle` to dependencies.\n */\n ]);\n\n const indexRef = useRef<number>(0);\n const offsetsRef = useRef<Array<number>>([]);\n\n const onScrollViewChanged = useCallback((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 }, [appBarHeight]);\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 }, [appBarHeight]);\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;;AACA;;AAEA;;AAOA;;AACA;;AACA;;AACA;;;;AA+BA,M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GH;EApE0C,CAAzB,EAqEnB,CAACmB,YAAD,CArEmB,CAAtB;EAuEA,MAAMqD,cAAc,GAAGjD,wBAAwB,GAAG,CAAlD;EAEA,MAAMkD,WAAW,GAAG,CAChBrC,aADgB,EAEhB;IAAEsC,UAAU,EAAEzD,cAAc,CAAC0D;EAA7B,CAFgB,EAGhBH,cAAc,GAAGzD,MAAM,CAAC6D,QAAV,GAAqBC,SAHnB,CAApB;EAMA,OAAO;IACHJ,WADG;IAEHxC,OAFG;IAGHb,cAHG;IAIHI,0BAJG;IAKHkC,QAAQ,EAAEJ,aALP;IAMHP,mBANG;IAOH+B,mBAAmB,EAAE;MAAEH,GAAG,EAAEH,cAAc,GAAGlD,eAAH,GAAqB;IAA1C;EAPlB,CAAP;AASH;;AAAA"}
@@ -0,0 +1,4 @@
1
+ import { createContext } from 'react';
2
+ const FluxContext = /*#__PURE__*/createContext(null);
3
+ export default FluxContext;
4
+ //# sourceMappingURL=FluxContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","FluxContext"],"sources":["FluxContext.ts"],"sourcesContent":["import { createContext } from 'react';\nimport type { MonoStore } from '@fountain-ui/core';\n\nexport type FluxStore<S> = MonoStore<S>;\n\nconst FluxContext = createContext<FluxStore<any> | null>(null);\n\nexport default FluxContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AAKA,MAAMC,WAAW,gBAAGD,aAAa,CAAwB,IAAxB,CAAjC;AAEA,eAAeC,WAAf"}
@@ -1,10 +1,7 @@
1
- import { createContext, useContext } from 'react';
1
+ import { createContext } from 'react';
2
2
  const initialPageState = {
3
3
  isActive: false
4
4
  };
5
5
  const PageStateContext = /*#__PURE__*/createContext(initialPageState);
6
- export const useViewPagerPageState = () => {
7
- return useContext(PageStateContext);
8
- };
9
6
  export default PageStateContext;
10
7
  //# sourceMappingURL=PageStateContext.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","useContext","initialPageState","isActive","PageStateContext","useViewPagerPageState"],"sources":["PageStateContext.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\n\ninterface PageState {\n isActive: boolean;\n}\n\nconst initialPageState: Readonly<PageState> = { isActive: false };\n\nconst PageStateContext = createContext<PageState>(initialPageState);\n\nexport const useViewPagerPageState = () => {\n return useContext(PageStateContext);\n};\n\nexport default PageStateContext;\n"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,UAAxB,QAA0C,OAA1C;AAMA,MAAMC,gBAAqC,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAA9C;AAEA,MAAMC,gBAAgB,gBAAGJ,aAAa,CAAYE,gBAAZ,CAAtC;AAEA,OAAO,MAAMG,qBAAqB,GAAG,MAAM;EACvC,OAAOJ,UAAU,CAACG,gBAAD,CAAjB;AACH,CAFM;AAIP,eAAeA,gBAAf"}
1
+ {"version":3,"names":["createContext","initialPageState","isActive","PageStateContext"],"sources":["PageStateContext.ts"],"sourcesContent":["import { createContext } from 'react';\n\nexport interface PageState {\n isActive: boolean;\n}\n\nconst initialPageState: Readonly<PageState> = { isActive: false };\n\nconst PageStateContext = createContext<PageState>(initialPageState);\n\nexport default PageStateContext;\n"],"mappings":"AAAA,SAASA,aAAT,QAA8B,OAA9B;AAMA,MAAMC,gBAAqC,GAAG;EAAEC,QAAQ,EAAE;AAAZ,CAA9C;AAEA,MAAMC,gBAAgB,gBAAGH,aAAa,CAAYC,gBAAZ,CAAtC;AAEA,eAAeE,gBAAf"}
@@ -1,8 +1,9 @@
1
- import React, { Children, forwardRef, useCallback, useImperativeHandle } from 'react';
1
+ import React, { Children, forwardRef, useCallback, useImperativeHandle, useMemo } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { StyleSheet, useSyncAnimatedValue } from '@fountain-ui/core';
4
- import { defaultInitialPage, defaultLoading, defaultPageComponent } from './utils';
5
- import usePageStore from './usePageStore';
4
+ import { ChildrenMemoizedPage } from './components';
5
+ import { defaultInitialPage, defaultLoading } from './utils';
6
+ import { usePageStore } from './hooks';
6
7
  import InternalContext from './InternalContext';
7
8
  const styles = StyleSheet.create({
8
9
  root: {
@@ -16,7 +17,6 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
16
17
  children,
17
18
  initialPage = defaultInitialPage,
18
19
  loading = defaultLoading,
19
- pageComponent = defaultPageComponent,
20
20
  pageForceRerenderKey,
21
21
  style,
22
22
  UNSTABLE_sharedPage
@@ -32,14 +32,14 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
32
32
  setPage
33
33
  }), [setPage]);
34
34
  const pageStore = usePageStore(sharedPage);
35
- const PageComponent = pageComponent;
35
+ const contextValue = useMemo(() => ({
36
+ pageStore
37
+ }), [pageStore]);
36
38
  return /*#__PURE__*/React.createElement(InternalContext.Provider, {
37
- value: {
38
- pageStore
39
- }
39
+ value: contextValue
40
40
  }, /*#__PURE__*/React.createElement(View, {
41
41
  style: [styles.root, style]
42
- }, Children.map(children, (child, index) => /*#__PURE__*/React.createElement(PageComponent, {
42
+ }, Children.map(children, (child, index) => /*#__PURE__*/React.createElement(ChildrenMemoizedPage, {
43
43
  key: index,
44
44
  children: child,
45
45
  index: index,
@@ -51,4 +51,4 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
51
51
  }))));
52
52
  });
53
53
  export default ViewPager;
54
- //# sourceMappingURL=ViewPagerWeb.js.map
54
+ //# sourceMappingURL=ViewPager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Children","forwardRef","useCallback","useImperativeHandle","useMemo","View","StyleSheet","useSyncAnimatedValue","ChildrenMemoizedPage","defaultInitialPage","defaultLoading","usePageStore","InternalContext","styles","create","root","overflow","position","ViewPager","props","ref","children","initialPage","loading","pageForceRerenderKey","style","UNSTABLE_sharedPage","fallbackSharedPage","initialValue","sharedPage","setPage","newPage","animatedValue","setValue","pageStore","contextValue","map","child","index"],"sources":["ViewPager.tsx"],"sourcesContent":["import React, { Children, forwardRef, useCallback, useImperativeHandle, useMemo } from 'react';\nimport { View } from 'react-native';\nimport { StyleSheet, useSyncAnimatedValue } from '@fountain-ui/core';\nimport { ChildrenMemoizedPage } from './components';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './types';\nimport { defaultInitialPage, defaultLoading } from './utils';\nimport { usePageStore } from './hooks';\nimport InternalContext from './InternalContext';\n\nconst styles = StyleSheet.create({\n root: {\n // @ts-ignore\n overflow: 'auto',\n position: 'relative',\n },\n});\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n loading = defaultLoading,\n pageForceRerenderKey,\n style,\n UNSTABLE_sharedPage,\n } = props;\n\n const fallbackSharedPage = useSyncAnimatedValue({ initialValue: initialPage });\n\n const sharedPage = UNSTABLE_sharedPage ?? fallbackSharedPage;\n\n const setPage = useCallback((newPage: number) => {\n sharedPage.animatedValue.setValue(newPage);\n }, [sharedPage]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const pageStore = usePageStore(sharedPage);\n\n const contextValue = useMemo(() => ({ pageStore }), [pageStore]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n <View style={[styles.root, style]}>\n {Children.map(children, (child, index) => (\n <ChildrenMemoizedPage\n key={index}\n children={child}\n index={index}\n initialPage={sharedPage.initialValue}\n loading={loading}\n offscreenPageRerenderLimit={0} // All offscreen pages will not be re-rendered\n rerenderKey={pageForceRerenderKey}\n />\n ))}\n </View>\n </InternalContext.Provider>\n );\n});\n\nexport default ViewPager;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,UAA1B,EAAsCC,WAAtC,EAAmDC,mBAAnD,EAAwEC,OAAxE,QAAuF,OAAvF;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,SAASC,UAAT,EAAqBC,oBAArB,QAAiD,mBAAjD;AACA,SAASC,oBAAT,QAAqC,cAArC;AAGA,SAASC,kBAAT,E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EAAQC,KAAR,kBACpB,oBAAC,oBAAD;IACI,GAAG,EAAEA,KADT;IAEI,QAAQ,EAAED,KAFd;IAGI,KAAK,EAAEC,KAHX;IAII,WAAW,EAAET,UAAU,CAACD,YAJ5B;IAKI,OAAO,EAAEL,OALb;IAMI,0BAA0B,EAAE,CANhC,CAMmC;IANnC;IAOI,WAAW,EAAEC;EAPjB,EADH,CADL,CADJ,CADJ;AAiBH,CA7C2B,CAA5B;AA+CA,eAAeN,SAAf"}
@@ -1,8 +1,9 @@
1
- import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';
1
+ import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
2
2
  import RNViewPager from 'react-native-pager-view';
3
3
  import { useSyncAnimatedValue } from '@fountain-ui/core';
4
- import { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit, defaultPageComponent } from './utils';
5
- import usePageStore from './usePageStore';
4
+ import { ChildrenMemoizedPage } from './components';
5
+ import { usePageStore } from './hooks';
6
+ import { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit } from './utils';
6
7
  import InternalContext from './InternalContext';
7
8
  const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
8
9
  const {
@@ -12,7 +13,6 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
12
13
  loading = defaultLoading,
13
14
  offscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit,
14
15
  onChange,
15
- pageComponent = defaultPageComponent,
16
16
  pageForceRerenderKey,
17
17
  scrollEnabled = true,
18
18
  style,
@@ -99,11 +99,11 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
99
99
  setPage
100
100
  }), [setPage]);
101
101
  const pageStore = usePageStore(sharedPage);
102
- const PageComponent = pageComponent;
102
+ const contextValue = useMemo(() => ({
103
+ pageStore
104
+ }), [pageStore]);
103
105
  return /*#__PURE__*/React.createElement(InternalContext.Provider, {
104
- value: {
105
- pageStore
106
- }
106
+ value: contextValue
107
107
  }, /*#__PURE__*/React.createElement(RNViewPager, {
108
108
  ref: pagerRef,
109
109
  initialPage: sharedPage.initialValue,
@@ -112,7 +112,7 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
112
112
  pageMargin: 8,
113
113
  scrollEnabled: scrollEnabled,
114
114
  style: style
115
- }, Children.map(children, (child, index) => /*#__PURE__*/React.createElement(PageComponent, {
115
+ }, Children.map(children, (child, index) => /*#__PURE__*/React.createElement(ChildrenMemoizedPage, {
116
116
  key: index,
117
117
  children: child,
118
118
  index: index,
@@ -123,4 +123,4 @@ const ViewPager = /*#__PURE__*/forwardRef(function ViewPager(props, ref) {
123
123
  }))));
124
124
  });
125
125
  export default ViewPager;
126
- //# sourceMappingURL=ViewPagerNative.js.map
126
+ //# sourceMappingURL=ViewPager.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Children","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","RNViewPager","useSyncAnimatedValue","ChildrenMemoizedPage","usePageStore","defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","InternalContext","ViewPager","props","ref","children","initialPage","keyboardDismissMode","loading","offscreenPageRerenderLimit","onChange","pageForceRerenderKey","scrollEnabled","style","UNSTABLE_sharedPage","fallbackSharedPage","initialValue","sharedPage","pageRef","desiredPageRef","NaN","pagerRef","animationFrameRef","setPage","newPage","Number","isInteger","current","requestAnimationFrame","isFinite","cancelAnimationFrame","animatedValue","id","addListener","newValue","value","removeListener","handlePageSelected","e","desiredPage","setValue","trustfulNextPage","nativeEvent","position","pageStore","contextValue","map","child","index"],"sources":["ViewPager.native.tsx"],"sourcesContent":["import React, { Children, forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\nimport type { ViewPagerOnPageSelectedEvent } from 'react-native-pager-view';\nimport RNViewPager from 'react-native-pager-view';\nimport { useSyncAnimatedValue } from '@fountain-ui/core';\nimport { ChildrenMemoizedPage } from './components';\nimport type ViewPagerProps from './ViewPagerProps';\nimport type { ViewPagerInstance } from './types';\nimport { usePageStore } from './hooks';\nimport { defaultInitialPage, defaultLoading, defaultOffscreenPageRerenderLimit } from './utils';\nimport InternalContext from './InternalContext';\n\nconst ViewPager = forwardRef<ViewPagerInstance, ViewPagerProps>(function ViewPager(props, ref) {\n const {\n children,\n initialPage = defaultInitialPage,\n keyboardDismissMode = 'on-drag',\n loading = defaultLoading,\n offscreenPageRerenderLimit = defaultOffscreenPageRerenderLimit,\n onChange,\n pageForceRerenderKey,\n scrollEnabled = true,\n style,\n UNSTABLE_sharedPage,\n } = props;\n\n const fallbackSharedPage = useSyncAnimatedValue({ initialValue: initialPage });\n\n const sharedPage = UNSTABLE_sharedPage ?? fallbackSharedPage;\n\n const pageRef = useRef<number>(sharedPage.initialValue);\n\n const desiredPageRef = useRef<number>(NaN);\n\n const pagerRef = useRef<RNViewPager | null>(null);\n\n const animationFrameRef = useRef<number>(NaN);\n\n const setPage = useCallback((newPage: number) => {\n if (!Number.isInteger(newPage)) {\n return;\n }\n\n animationFrameRef.current = requestAnimationFrame(() => {\n if (Number.isFinite(desiredPageRef.current)) {\n if (pageRef.current === desiredPageRef.current) {\n // end of state machine. clear desired page.\n desiredPageRef.current = NaN;\n return;\n }\n\n if (newPage === desiredPageRef.current) {\n return;\n }\n }\n\n desiredPageRef.current = newPage;\n pagerRef.current?.setPage(newPage);\n });\n }, []);\n\n useEffect(() => {\n return () => {\n if (animationFrameRef.current) {\n cancelAnimationFrame(animationFrameRef.current);\n }\n };\n }, []);\n\n useEffect(() => {\n const animatedValue = sharedPage.animatedValue;\n const id = animatedValue.addListener(newValue => {\n const newPage = newValue.value;\n pageRef.current = newPage;\n setPage(newPage);\n });\n\n return () => {\n animatedValue.removeListener(id);\n };\n }, [sharedPage, setPage]);\n\n const handlePageSelected = useCallback((e: ViewPagerOnPageSelectedEvent) => {\n if (Number.isFinite(desiredPageRef.current)) {\n // onPageSelected is called from outer controlling mechanism\n // e.g. sharedPage.value is changed, setPage() is called\n // Due to the onPageSelected bug,\n // we don't trust the value from event, (e.nativeEvent.position)\n // other than that trust the value from desiredPageRef.\n\n const desiredPage = desiredPageRef.current;\n\n if (pageRef.current === desiredPage) {\n // end of state machine. clear desired page.\n desiredPageRef.current = NaN;\n } else {\n sharedPage.animatedValue.setValue(desiredPage);\n }\n\n onChange?.(desiredPage);\n } else {\n const trustfulNextPage = e.nativeEvent.position;\n\n if (trustfulNextPage !== pageRef.current) {\n desiredPageRef.current = trustfulNextPage;\n sharedPage.animatedValue.setValue(trustfulNextPage);\n\n onChange?.(trustfulNextPage);\n }\n }\n }, [onChange, sharedPage]);\n\n useImperativeHandle(\n ref,\n () => ({ setPage }),\n [setPage],\n );\n\n const pageStore = usePageStore(sharedPage);\n\n const contextValue = useMemo(() => ({ pageStore }), [pageStore]);\n\n return (\n <InternalContext.Provider value={contextValue}>\n <RNViewPager\n ref={pagerRef}\n initialPage={sharedPage.initialValue}\n keyboardDismissMode={keyboardDismissMode}\n onPageSelected={handlePageSelected}\n pageMargin={8}\n scrollEnabled={scrollEnabled}\n style={style}\n >\n {Children.map(children, (child, index) => (\n <ChildrenMemoizedPage\n key={index}\n children={child}\n index={index}\n initialPage={sharedPage.initialValue}\n loading={loading}\n offscreenPageRerenderLimit={offscreenPageRerenderLimit}\n rerenderKey={pageForceRerenderKey}\n />\n ))}\n </RNViewPager>\n </InternalContext.Provider>\n );\n});\n\nexport default ViewPager;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,UAA1B,EAAsCC,WAAtC,EAAmDC,SAAnD,EAA8DC,mBAA9D,EAAmFC,OAAnF,EAA4FC,MAA5F,QAA0G,OAA1G;AAEA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,SAASC,oBAAT,QAAqC,mBAArC;AACA,SAASC,oBAAT,QAAqC,cAArC;AAGA,SAASC,YAAT,QAA6B,SAA7B;AACA,SAASC,kBAAT,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ADJ;AAyBH,CAvI2B,CAA5B;AAyIA,eAAeT,SAAf"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["ViewPagerProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ComponentProps, SyncAnimatedValue } from '@fountain-ui/core';\nimport type { KeyboardDismissMode, Loading, PageComponent, ViewPagerInstance } from './types';\n\nexport default interface ViewPagerProps extends ComponentProps<{\n ref?: Ref<ViewPagerInstance>;\n\n /**\n * Collection of ViewPager components.\n */\n children?: ReactNode;\n\n /**\n * Index of initial page that should be selected.\n * @default 0\n */\n initialPage?: number;\n\n /**\n * Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * Mobile only. The number of pages that should be re-rendered to either side of the current page.\n * Changing this value after the component mount has no effect.\n * @default 0\n */\n offscreenPageRerenderLimit?: number;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void,\n\n /**\n * The component used to render the wrapper of the page.\n * @default 'ChildrenMemoizedPage'\n */\n pageComponent?: PageComponent,\n\n /**\n * When this value is changed, page will be rerender.\n */\n pageForceRerenderKey?: any;\n\n /**\n * Mobile only. Should pager view scroll, when scroll enabled.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * Mobile only. Determines whether the keyboard gets dismissed in response to a drag.\n * @default 'on-drag'\n */\n keyboardDismissMode?: KeyboardDismissMode;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedPage?: SyncAnimatedValue;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["ViewPagerProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ComponentProps, SyncAnimatedValue } from '@fountain-ui/core';\nimport type { KeyboardDismissMode, Loading, ViewPagerInstance } from './types';\n\nexport default interface ViewPagerProps extends ComponentProps<{\n ref?: Ref<ViewPagerInstance>;\n\n /**\n * Collection of ViewPager components.\n */\n children?: ReactNode;\n\n /**\n * Index of initial page that should be selected.\n * @default 0\n */\n initialPage?: number;\n\n /**\n * Whether to load the page immediately (`eager`) or on an as-needed basis (`lazy`).\n * @default 'lazy'\n */\n loading?: Loading;\n\n /**\n * Mobile only. The number of pages that should be re-rendered to either side of the current page.\n * Changing this value after the component mount has no effect.\n * @default 0\n */\n offscreenPageRerenderLimit?: number;\n\n /**\n * Callback fired when an index is changed.\n */\n onChange?: (newIndex: number) => void,\n\n /**\n * When this value is changed, page will be rerender.\n */\n pageForceRerenderKey?: any;\n\n /**\n * Mobile only. Should pager view scroll, when scroll enabled.\n * @default true\n */\n scrollEnabled?: boolean;\n\n /**\n * Mobile only. Determines whether the keyboard gets dismissed in response to a drag.\n * @default 'on-drag'\n */\n keyboardDismissMode?: KeyboardDismissMode;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedPage?: SyncAnimatedValue;\n}> {}\n"],"mappings":""}
@@ -1,8 +1,9 @@
1
- import React, { memo, useCallback, useContext, useEffect, useMemo, useReducer, useRef, useState } from 'react';
1
+ import React, { memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Platform, View } from 'react-native';
3
3
  import { StyleSheet } from '@fountain-ui/core';
4
- import PageStateContext from './PageStateContext';
5
- import InternalContext from './InternalContext';
4
+ import { useForceRender } from '../hooks';
5
+ import PageStateContext from '../PageStateContext';
6
+ import InternalContext from '../InternalContext';
6
7
  const styles = StyleSheet.create({
7
8
  fill: {
8
9
  width: '100%',
@@ -54,7 +55,7 @@ function Page(props) {
54
55
  }); // `Bailing out of a state update` is not working as expected.
55
56
 
56
57
  const pageStateRef = useRef(initialState);
57
- const [, forceRender] = useReducer(s => s + 1, 0);
58
+ const forceRender = useForceRender();
58
59
  const {
59
60
  active,
60
61
  loaded
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","memo","useCallback","useContext","useEffect","useMemo","useRef","useState","Platform","View","StyleSheet","useForceRender","PageStateContext","InternalContext","styles","create","fill","width","height","none","display","Page","props","index","initialPage","children","loading","offscreenPageRerenderLimit","pageStore","computePageDescription","page","activeIndex","isActive","shouldRerender","becomeNeighbor","initialState","active","loaded","pageStateRef","forceRender","current","content","subscribe","newPage","currentState","newState","contextValue","style","OS","absoluteFill","prevProps","nextProps","rerenderKey"],"sources":["ChildrenMemoizedPage.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport React, { memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Platform, View } from 'react-native';\nimport { StyleSheet } from '@fountain-ui/core';\nimport type { Loading } from '../types';\nimport { useForceRender } from '../hooks';\nimport PageStateContext from '../PageStateContext';\nimport InternalContext from '../InternalContext';\n\nconst styles = StyleSheet.create({\n fill: { width: '100%', height: '100%' },\n none: { display: 'none' },\n});\n\nexport type PageProps = PropsWithChildren<ViewProps> & {\n index: number;\n initialPage: number;\n loading: Loading;\n offscreenPageRerenderLimit: number;\n rerenderKey?: any;\n};\n\ninterface InternalPageDescription {\n isActive: boolean;\n becomeNeighbor: boolean;\n}\n\ninterface InternalPageState {\n active: boolean;\n loaded: boolean;\n}\n\nfunction Page(props: PageProps) {\n const {\n index,\n initialPage,\n children,\n loading,\n offscreenPageRerenderLimit,\n } = props;\n\n const { pageStore } = useContext(InternalContext);\n\n const computePageDescription: (page: number) => InternalPageDescription = useCallback((page: number) => {\n const activeIndex = page;\n\n const isActive = index === activeIndex;\n\n const shouldRerender = index >= activeIndex - offscreenPageRerenderLimit\n && index <= activeIndex + offscreenPageRerenderLimit;\n\n const becomeNeighbor = shouldRerender && !isActive;\n\n return { isActive, becomeNeighbor };\n }, [index]);\n\n const [initialState] = useState<InternalPageState>(() => {\n const { isActive, becomeNeighbor } = computePageDescription(initialPage);\n\n if (loading === 'eager') {\n return { active: isActive, loaded: true };\n }\n\n return { active: isActive, loaded: isActive || becomeNeighbor };\n });\n\n // `Bailing out of a state update` is not working as expected.\n const pageStateRef = useRef<InternalPageState>(initialState);\n const forceRender = useForceRender();\n\n const { active, loaded } = pageStateRef.current;\n\n const content = loaded ? children : null;\n\n useEffect(() => {\n return pageStore.subscribe(newPage => {\n const { isActive, becomeNeighbor } = computePageDescription(newPage);\n\n const currentState = pageStateRef.current;\n\n const newState: InternalPageState = {\n active: isActive,\n loaded: isActive || becomeNeighbor ? true : currentState.loaded,\n };\n\n if (\n currentState.active !== newState.active\n || currentState.loaded !== newState.loaded\n ) {\n pageStateRef.current = newState;\n\n forceRender();\n }\n });\n }, [pageStore, computePageDescription]);\n\n const contextValue = useMemo(() => ({\n isActive: active,\n }), [active]);\n\n const style = Platform.OS === 'web'\n ? (active ? StyleSheet.absoluteFill : styles.none)\n : styles.fill;\n\n return (\n <View\n collapsable={false}\n style={style}\n >\n <PageStateContext.Provider value={contextValue}>\n {content}\n </PageStateContext.Provider>\n </View>\n );\n}\n\nexport default memo(Page, (prevProps, nextProps) => {\n if (prevProps.rerenderKey !== nextProps.rerenderKey) {\n return false;\n }\n\n return prevProps.index === nextProps.index;\n});\n"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,IAAhB,EAAsBC,WAAtB,EAAmCC,UAAnC,EAA+CC,SAA/C,EAA0DC,OAA1D,EAAmEC,MAAnE,EAA2EC,QAA3E,QAA2F,OAA3F;AAEA,SAASC,QAAT,EAAmBC,IAAnB,QAA+B,cAA/B;AACA,SAASC,UAAT,QAA2B,mBAA3B;AAEA,SAASC,cAAT,QAA+B,UAA/B;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AAEA,MAAMC,MAAM,GAAGJ,UAAU,CAACK,MAAX,CAAkB;EAC7BC,IAAI,EAAE;IAAEC,KAAK,EAAE,MAAT;IAAiBC,MAAM,EAAE;EAAzB,CADuB;EAE7BC,IAAI,EAAE;IAAEC,OAAO,EAAE;EAAX;AAFuB,CAAlB,CAAf;;AAuBA,SAASC,IAAT,CAAcC,KAAd,EAAgC;EAC5B,MAAM;IACFC,KADE;IAEFC,WAFE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ountain-ui/core';
3
+ import FluxContext from '../FluxContext';
4
+ export default function FluxStoreProvider(props) {
5
+ const {
6
+ children,
7
+ initialState
8
+ } = props;
9
+ const store = useRef(new SimpleStore(initialState)).current;
10
+ useEffect(() => {
11
+ return () => {
12
+ store.removeAllListeners();
13
+ };
14
+ }, [store]);
15
+ return /*#__PURE__*/React.createElement(FluxContext.Provider, {
16
+ value: store
17
+ }, children);
18
+ }
19
+ ;
20
+ //# sourceMappingURL=FluxStoreProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useRef","SimpleStore","FluxContext","FluxStoreProvider","props","children","initialState","store","current","removeAllListeners"],"sources":["FluxStoreProvider.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { SimpleStore } from '@fountain-ui/core';\nimport type { FluxStore } from '../FluxContext';\nimport FluxContext from '../FluxContext';\n\nexport interface FluxStoreProviderProps<State> {\n children: React.ReactElement;\n initialState: State;\n}\n\nexport default function FluxStoreProvider<State>(props: FluxStoreProviderProps<State>) {\n const { children, initialState } = props;\n\n const store = useRef<FluxStore<State>>(new SimpleStore(initialState)).current;\n\n useEffect(() => {\n return () => {\n store.removeAllListeners();\n };\n }, [store]);\n\n return (\n <FluxContext.Provider value={store}>\n {children}\n </FluxContext.Provider>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,QAAyC,OAAzC;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA,OAAOC,WAAP,MAAwB,gBAAxB;AAOA,eAAe,SAASC,iBAAT,CAAkCC,KAAlC,EAAwE;EACnF,MAAM;IAAEC,QAAF;IAAYC;EAAZ,IAA6BF,KAAnC;EAEA,MAAMG,KAAK,GAAGP,MAAM,CAAmB,IAAIC,WAAJ,CAAgBK,YAAhB,CAAnB,CAAN,CAAwDE,OAAtE;EAEAT,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTQ,KAAK,CAACE,kBAAN;IACH,CAFD;EAGH,CAJQ,EAIN,CAACF,KAAD,CAJM,CAAT;EAMA,oBACI,oBAAC,WAAD,CAAa,QAAb;IAAsB,KAAK,EAAEA;EAA7B,GACKF,QADL,CADJ;AAKH;AAAA"}
@@ -0,0 +1,3 @@
1
+ export { default as ChildrenMemoizedPage } from './ChildrenMemoizedPage';
2
+ export { default as FluxStoreProvider } from './FluxStoreProvider';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","ChildrenMemoizedPage","FluxStoreProvider"],"sources":["index.ts"],"sourcesContent":["export { default as ChildrenMemoizedPage } from './ChildrenMemoizedPage';\nexport { default as FluxStoreProvider } from './FluxStoreProvider';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,oBAApB,QAAgD,wBAAhD;AACA,SAASD,OAAO,IAAIE,iBAApB,QAA6C,qBAA7C"}
@@ -0,0 +1,7 @@
1
+ export { default as useDispatch } from './useDispatch';
2
+ export { default as useForceRender } from './useForceRender';
3
+ export { default as useLazyState } from './useLazyState';
4
+ export { default as usePageStore } from './usePageStore';
5
+ export { default as useStore } from './useStore';
6
+ export { default as useViewPagerPageState } from './useViewPagerPageState';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","useDispatch","useForceRender","useLazyState","usePageStore","useStore","useViewPagerPageState"],"sources":["index.ts"],"sourcesContent":["export { default as useDispatch } from './useDispatch';\nexport { default as useForceRender } from './useForceRender';\nexport { default as useLazyState } from './useLazyState';\nexport { default as usePageStore } from './usePageStore';\nexport { default as useStore } from './useStore';\nexport { default as useViewPagerPageState } from './useViewPagerPageState';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC;AACA,SAASD,OAAO,IAAIE,cAApB,QAA0C,kBAA1C;AACA,SAASF,OAAO,IAAIG,YAApB,QAAwC,gBAAxC;AACA,SAASH,OAAO,IAAII,YAApB,QAAwC,gBAAxC;AACA,SAASJ,OAAO,IAAIK,QAApB,QAAoC,YAApC;AACA,SAASL,OAAO,IAAIM,qBAApB,QAAiD,yBAAjD"}
@@ -0,0 +1,10 @@
1
+ import { useCallback } from 'react';
2
+ import useStore from './useStore';
3
+ export default function useDispatch() {
4
+ const store = useStore();
5
+ return useCallback(action => {
6
+ store.dispatch(action);
7
+ }, [store]);
8
+ }
9
+ ;
10
+ //# sourceMappingURL=useDispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCallback","useStore","useDispatch","store","action","dispatch"],"sources":["useDispatch.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport type { DispatchAction } from '@fountain-ui/core';\nimport useStore from './useStore';\n\nexport default function useDispatch<State>() {\n const store = useStore<State>();\n\n return useCallback((action: DispatchAction<State>) => {\n store.dispatch(action);\n }, [store]);\n};\n"],"mappings":"AAAA,SAASA,WAAT,QAA4B,OAA5B;AAEA,OAAOC,QAAP,MAAqB,YAArB;AAEA,eAAe,SAASC,WAAT,GAA8B;EACzC,MAAMC,KAAK,GAAGF,QAAQ,EAAtB;EAEA,OAAOD,WAAW,CAAEI,MAAD,IAAmC;IAClDD,KAAK,CAACE,QAAN,CAAeD,MAAf;EACH,CAFiB,EAEf,CAACD,KAAD,CAFe,CAAlB;AAGH;AAAA"}
@@ -0,0 +1,7 @@
1
+ import { useReducer } from 'react';
2
+ export default function useForceRender() {
3
+ const [, forceRender] = useReducer(s => s + 1, 0);
4
+ return forceRender;
5
+ }
6
+ ;
7
+ //# sourceMappingURL=useForceRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useReducer","useForceRender","forceRender","s"],"sources":["useForceRender.ts"],"sourcesContent":["import { useReducer } from 'react';\n\nexport default function useForceRender() {\n const [, forceRender] = useReducer((s) => s + 1, 0);\n\n return forceRender;\n};\n"],"mappings":"AAAA,SAASA,UAAT,QAA2B,OAA3B;AAEA,eAAe,SAASC,cAAT,GAA0B;EACrC,MAAM,GAAGC,WAAH,IAAkBF,UAAU,CAAEG,CAAD,IAAOA,CAAC,GAAG,CAAZ,EAAe,CAAf,CAAlC;EAEA,OAAOD,WAAP;AACH;AAAA"}
@@ -0,0 +1,30 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { refEqual } from '../utils';
3
+ import useForceRender from './useForceRender';
4
+ import useViewPagerPageState from './useViewPagerPageState';
5
+ import useStore from './useStore';
6
+ export default function useLazyState() {
7
+ let equalityFn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : refEqual;
8
+ const store = useStore();
9
+ const stateRef = useRef(store.getState());
10
+ const forceRender = useForceRender();
11
+ const {
12
+ isActive
13
+ } = useViewPagerPageState();
14
+ useEffect(() => {
15
+ return store.subscribe(newState => {
16
+ if (equalityFn(stateRef.current, newState)) {
17
+ return;
18
+ }
19
+
20
+ stateRef.current = newState;
21
+
22
+ if (isActive) {
23
+ forceRender();
24
+ }
25
+ });
26
+ }, [store, isActive]);
27
+ return stateRef.current;
28
+ }
29
+ ;
30
+ //# sourceMappingURL=useLazyState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","refEqual","useForceRender","useViewPagerPageState","useStore","useLazyState","equalityFn","store","stateRef","getState","forceRender","isActive","subscribe","newState","current"],"sources":["useLazyState.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { EqualityFunction } from '../types';\nimport { refEqual } from '../utils';\nimport useForceRender from './useForceRender';\nimport useViewPagerPageState from './useViewPagerPageState';\nimport useStore from './useStore';\n\nexport default function useLazyState<State>(equalityFn: EqualityFunction<State> = refEqual): State {\n const store = useStore<State>();\n\n const stateRef = useRef<State>(store.getState());\n\n const forceRender = useForceRender();\n\n const { isActive } = useViewPagerPageState();\n\n useEffect(() => {\n return store.subscribe(newState => {\n if (equalityFn(stateRef.current, newState)) {\n return;\n }\n\n stateRef.current = newState;\n\n if (isActive) {\n forceRender();\n }\n });\n }, [store, isActive]);\n\n return stateRef.current;\n};\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AAEA,SAASC,QAAT,QAAyB,UAAzB;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,OAAOC,QAAP,MAAqB,YAArB;AAEA,eAAe,SAASC,YAAT,GAAoF;EAAA,IAAvDC,UAAuD,uEAAjBL,QAAiB;EAC/F,MAAMM,KAAK,GAAGH,QAAQ,EAAtB;EAEA,MAAMI,QAAQ,GAAGR,MAAM,CAAQO,KAAK,CAACE,QAAN,EAAR,CAAvB;EAEA,MAAMC,WAAW,GAAGR,cAAc,EAAlC;EAEA,MAAM;IAAES;EAAF,IAAeR,qBAAqB,EAA1C;EAEAJ,SAAS,CAAC,MAAM;IACZ,OAAOQ,KAAK,CAACK,SAAN,CAAgBC,QAAQ,IAAI;MAC/B,IAAIP,UAAU,CAACE,QAAQ,CAACM,OAAV,EAAmBD,QAAnB,CAAd,EAA4C;QACxC;MACH;;MAEDL,QAAQ,CAACM,OAAT,GAAmBD,QAAnB;;MAEA,IAAIF,QAAJ,EAAc;QACVD,WAAW;MACd;IACJ,CAVM,CAAP;EAWH,CAZQ,EAYN,CAACH,KAAD,EAAQI,QAAR,CAZM,CAAT;EAcA,OAAOH,QAAQ,CAACM,OAAhB;AACH;AAAA"}
@@ -0,0 +1,14 @@
1
+ import { useContext } from 'react';
2
+ import FluxContext from '../FluxContext';
3
+ export default function useStore() {
4
+ // @ts-ignore
5
+ const store = useContext(FluxContext);
6
+
7
+ if (store == null) {
8
+ throw new Error('You should wrap your parent component with `FluxStoreProvider`');
9
+ }
10
+
11
+ return store;
12
+ }
13
+ ;
14
+ //# sourceMappingURL=useStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useContext","FluxContext","useStore","store","Error"],"sources":["useStore.ts"],"sourcesContent":["import { useContext } from 'react';\nimport type { FluxStore } from '../FluxContext';\nimport FluxContext from '../FluxContext';\n\nexport default function useStore<State>(): FluxStore<State> {\n // @ts-ignore\n const store = useContext<FluxStore<State>>(FluxContext);\n if (store == null) {\n throw new Error(\n 'You should wrap your parent component with `FluxStoreProvider`',\n );\n }\n\n return store;\n};\n"],"mappings":"AAAA,SAASA,UAAT,QAA2B,OAA3B;AAEA,OAAOC,WAAP,MAAwB,gBAAxB;AAEA,eAAe,SAASC,QAAT,GAA6C;EACxD;EACA,MAAMC,KAAK,GAAGH,UAAU,CAAmBC,WAAnB,CAAxB;;EACA,IAAIE,KAAK,IAAI,IAAb,EAAmB;IACf,MAAM,IAAIC,KAAJ,CACF,gEADE,CAAN;EAGH;;EAED,OAAOD,KAAP;AACH;AAAA"}
@@ -0,0 +1,7 @@
1
+ import { useContext } from 'react';
2
+ import PageStateContext from '../PageStateContext';
3
+ export default function useViewPagerPageState() {
4
+ return useContext(PageStateContext);
5
+ }
6
+ ;
7
+ //# sourceMappingURL=useViewPagerPageState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useContext","PageStateContext","useViewPagerPageState"],"sources":["useViewPagerPageState.ts"],"sourcesContent":["import { useContext } from 'react';\nimport PageStateContext from '../PageStateContext';\n\nexport default function useViewPagerPageState() {\n return useContext(PageStateContext);\n};\n"],"mappings":"AAAA,SAASA,UAAT,QAA2B,OAA3B;AACA,OAAOC,gBAAP,MAA6B,qBAA7B;AAEA,eAAe,SAASC,qBAAT,GAAiC;EAC5C,OAAOF,UAAU,CAACC,gBAAD,CAAjB;AACH;AAAA"}
@@ -1,3 +1,4 @@
1
- export { default } from './ViewPagerWeb';
2
- export { useViewPagerPageState } from './PageStateContext';
1
+ export { default } from './ViewPager';
2
+ export { useViewPagerPageState, useDispatch as useFluxDispatch, useLazyState, useStore as useFluxStore } from './hooks';
3
+ export { FluxStoreProvider } from './components';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","useViewPagerPageState"],"sources":["index.ts"],"sourcesContent":["export { default } from './ViewPagerWeb';\nexport type { default as ViewPagerProps } from './ViewPagerProps';\nexport type { ViewPagerInstance } from './types';\nexport { useViewPagerPageState } from './PageStateContext';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,gBAAxB;AAGA,SAASC,qBAAT,QAAsC,oBAAtC"}
1
+ {"version":3,"names":["default","useViewPagerPageState","useDispatch","useFluxDispatch","useLazyState","useStore","useFluxStore","FluxStoreProvider"],"sources":["index.ts"],"sourcesContent":["export { default } from './ViewPager';\nexport type { default as ViewPagerProps } from './ViewPagerProps';\nexport type { ViewPagerInstance } from './types';\nexport { useViewPagerPageState, useDispatch as useFluxDispatch, useLazyState, useStore as useFluxStore } from './hooks';\nexport { FluxStoreProvider } from './components';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,aAAxB;AAGA,SAASC,qBAAT,EAAgCC,WAAW,IAAIC,eAA/C,EAAgEC,YAAhE,EAA8EC,QAAQ,IAAIC,YAA1F,QAA8G,SAA9G;AACA,SAASC,iBAAT,QAAkC,cAAlC"}
@@ -1,2 +1,2 @@
1
- export {};
1
+
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ComponentType, PropsWithChildren } from 'react';\nimport type { ViewProps } from 'react-native';\n\nexport type PageProps = PropsWithChildren<ViewProps> & {\n index: number;\n initialPage: number;\n loading: Loading;\n offscreenPageRerenderLimit: number;\n rerenderKey?: any;\n};\n\nexport type KeyboardDismissMode = 'none' | 'on-drag';\n\nexport type PageComponent = ComponentType<PageProps>;\n\nexport type Loading = 'lazy' | 'eager';\n\nexport interface ViewPagerInstance {\n /**\n * Function to scroll to a specific page in the ViewPager. Invalid index is ignored.\n * @param index\n */\n setPage: (index: number) => void;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type KeyboardDismissMode = 'none' | 'on-drag';\n\nexport type Loading = 'lazy' | 'eager';\n\nexport interface EqualityFunction<State> {\n (a: State, b: State): boolean;\n}\n\nexport interface ViewPagerInstance {\n /**\n * Function to scroll to a specific page in the ViewPager. Invalid index is ignored.\n * @param index\n */\n setPage: (index: number) => void;\n}\n"],"mappings":""}
@@ -1,6 +1,5 @@
1
- import ChildrenMemoizedPage from './ChildrenMemoizedPage';
2
1
  export const defaultInitialPage = 0;
3
2
  export const defaultLoading = 'lazy';
4
3
  export const defaultOffscreenPageRerenderLimit = 0;
5
- export const defaultPageComponent = ChildrenMemoizedPage;
4
+ export const refEqual = (a, b) => a === b;
6
5
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ChildrenMemoizedPage","defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","defaultPageComponent"],"sources":["utils.tsx"],"sourcesContent":["import ChildrenMemoizedPage from './ChildrenMemoizedPage';\nimport type { Loading, PageComponent } from './types';\n\nexport const defaultInitialPage: number = 0;\n\nexport const defaultLoading: Loading = 'lazy';\n\nexport const defaultOffscreenPageRerenderLimit: number = 0;\n\nexport const defaultPageComponent: PageComponent = ChildrenMemoizedPage;\n"],"mappings":"AAAA,OAAOA,oBAAP,MAAiC,wBAAjC;AAGA,OAAO,MAAMC,kBAA0B,GAAG,CAAnC;AAEP,OAAO,MAAMC,cAAuB,GAAG,MAAhC;AAEP,OAAO,MAAMC,iCAAyC,GAAG,CAAlD;AAEP,OAAO,MAAMC,oBAAmC,GAAGJ,oBAA5C"}
1
+ {"version":3,"names":["defaultInitialPage","defaultLoading","defaultOffscreenPageRerenderLimit","refEqual","a","b"],"sources":["utils.tsx"],"sourcesContent":["import type { EqualityFunction, Loading } from './types';\n\nexport const defaultInitialPage: number = 0;\n\nexport const defaultLoading: Loading = 'lazy';\n\nexport const defaultOffscreenPageRerenderLimit: number = 0;\n\nexport const refEqual: EqualityFunction<any> = (a: any, b: any) => a === b;\n"],"mappings":"AAEA,OAAO,MAAMA,kBAA0B,GAAG,CAAnC;AAEP,OAAO,MAAMC,cAAuB,GAAG,MAAhC;AAEP,OAAO,MAAMC,iCAAyC,GAAG,CAAlD;AAEP,OAAO,MAAMC,QAA+B,GAAG,CAACC,CAAD,EAASC,CAAT,KAAoBD,CAAC,KAAKC,CAAlE"}
@@ -1,4 +1,4 @@
1
- import { useRef } from 'react';
1
+ import { useCallback, useRef } from 'react';
2
2
  import { Platform } from 'react-native';
3
3
  import { useAnimatedScrollHandler, useAnimatedStyle, useDerivedValue, useSharedValue, withTiming } from 'react-native-reanimated';
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -75,8 +75,7 @@ export default function useUnstableCollapsibleAppBar() {
75
75
  ]);
76
76
  const indexRef = useRef(0);
77
77
  const offsetsRef = useRef([]);
78
-
79
- const onScrollViewChanged = nextIndex => {
78
+ const onScrollViewChanged = useCallback(nextIndex => {
80
79
  const prevIndex = indexRef.current;
81
80
 
82
81
  if (prevIndex === nextIndex) {
@@ -105,8 +104,7 @@ export default function useUnstableCollapsibleAppBar() {
105
104
  });
106
105
  vectorY.value = 0;
107
106
  }
108
- };
109
-
107
+ }, [appBarHeight]);
110
108
  const scrollHandler = useAnimatedScrollHandler({
111
109
  onBeginDrag: () => {
112
110
  lastTranslateY.value = translateY.value;