@fountain-ui/core 2.0.0-beta.16 → 2.0.0-beta.19

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 (129) hide show
  1. package/build/commonjs/Tabs/IndexAwareTab.js +13 -7
  2. package/build/commonjs/Tabs/IndexAwareTab.js.map +1 -1
  3. package/build/commonjs/Tabs/InternalContext.js +17 -0
  4. package/build/commonjs/Tabs/InternalContext.js.map +1 -0
  5. package/build/commonjs/Tabs/ScrollableTabsView.js +34 -0
  6. package/build/commonjs/Tabs/ScrollableTabsView.js.map +1 -0
  7. package/build/commonjs/Tabs/TabIndicator.js +46 -19
  8. package/build/commonjs/Tabs/TabIndicator.js.map +1 -1
  9. package/build/commonjs/Tabs/TabIndicatorProps.js.map +1 -1
  10. package/build/commonjs/Tabs/Tabs.js +35 -30
  11. package/build/commonjs/Tabs/Tabs.js.map +1 -1
  12. package/build/commonjs/Tabs/TabsProps.js.map +1 -1
  13. package/build/commonjs/Tabs/index.js.map +1 -1
  14. package/build/commonjs/Tabs/types.js +2 -0
  15. package/build/commonjs/Tabs/types.js.map +1 -0
  16. package/build/commonjs/Tabs/useIndexStore.js +35 -0
  17. package/build/commonjs/Tabs/useIndexStore.js.map +1 -0
  18. package/build/commonjs/Tabs/useScrollViewReaction.js +23 -27
  19. package/build/commonjs/Tabs/useScrollViewReaction.js.map +1 -1
  20. package/build/commonjs/Tabs/useTabCoordinates.js +9 -23
  21. package/build/commonjs/Tabs/useTabCoordinates.js.map +1 -1
  22. package/build/commonjs/Tabs/utils.js +19 -0
  23. package/build/commonjs/Tabs/utils.js.map +1 -0
  24. package/build/commonjs/hooks/index.js +16 -0
  25. package/build/commonjs/hooks/index.js.map +1 -1
  26. package/build/commonjs/hooks/useCollapsibleAppBar.js +1 -1
  27. package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
  28. package/build/commonjs/hooks/useImperativeState.js +26 -0
  29. package/build/commonjs/hooks/useImperativeState.js.map +1 -0
  30. package/build/commonjs/hooks/useSyncAnimatedValue.js +37 -0
  31. package/build/commonjs/hooks/useSyncAnimatedValue.js.map +1 -0
  32. package/build/commonjs/index.js +14 -0
  33. package/build/commonjs/index.js.map +1 -1
  34. package/build/commonjs/store/MockStore.js +23 -0
  35. package/build/commonjs/store/MockStore.js.map +1 -0
  36. package/build/commonjs/store/SimpleStore.js +54 -0
  37. package/build/commonjs/store/SimpleStore.js.map +1 -0
  38. package/build/commonjs/store/index.js +24 -0
  39. package/build/commonjs/store/index.js.map +1 -0
  40. package/build/commonjs/store/types.js +2 -0
  41. package/build/commonjs/store/types.js.map +1 -0
  42. package/build/commonjs/types/index.js.map +1 -1
  43. package/build/module/Tabs/IndexAwareTab.js +12 -8
  44. package/build/module/Tabs/IndexAwareTab.js.map +1 -1
  45. package/build/module/Tabs/InternalContext.js +7 -0
  46. package/build/module/Tabs/InternalContext.js.map +1 -0
  47. package/build/module/Tabs/ScrollableTabsView.js +21 -0
  48. package/build/module/Tabs/ScrollableTabsView.js.map +1 -0
  49. package/build/module/Tabs/TabIndicator.js +44 -17
  50. package/build/module/Tabs/TabIndicator.js.map +1 -1
  51. package/build/module/Tabs/TabIndicatorProps.js.map +1 -1
  52. package/build/module/Tabs/Tabs.js +33 -31
  53. package/build/module/Tabs/Tabs.js.map +1 -1
  54. package/build/module/Tabs/TabsProps.js.map +1 -1
  55. package/build/module/Tabs/index.js.map +1 -1
  56. package/build/module/Tabs/types.js +2 -0
  57. package/build/module/Tabs/types.js.map +1 -0
  58. package/build/module/Tabs/useIndexStore.js +25 -0
  59. package/build/module/Tabs/useIndexStore.js.map +1 -0
  60. package/build/module/Tabs/useScrollViewReaction.js +23 -28
  61. package/build/module/Tabs/useScrollViewReaction.js.map +1 -1
  62. package/build/module/Tabs/useTabCoordinates.js +9 -18
  63. package/build/module/Tabs/useTabCoordinates.js.map +1 -1
  64. package/build/module/Tabs/utils.js +9 -0
  65. package/build/module/Tabs/utils.js.map +1 -0
  66. package/build/module/hooks/index.js +2 -0
  67. package/build/module/hooks/index.js.map +1 -1
  68. package/build/module/hooks/useCollapsibleAppBar.js +1 -1
  69. package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
  70. package/build/module/hooks/useImperativeState.js +17 -0
  71. package/build/module/hooks/useImperativeState.js.map +1 -0
  72. package/build/module/hooks/useSyncAnimatedValue.js +27 -0
  73. package/build/module/hooks/useSyncAnimatedValue.js.map +1 -0
  74. package/build/module/index.js +1 -0
  75. package/build/module/index.js.map +1 -1
  76. package/build/module/store/MockStore.js +14 -0
  77. package/build/module/store/MockStore.js.map +1 -0
  78. package/build/module/store/SimpleStore.js +45 -0
  79. package/build/module/store/SimpleStore.js.map +1 -0
  80. package/build/module/store/index.js +3 -0
  81. package/build/module/store/index.js.map +1 -0
  82. package/build/module/store/types.js +2 -0
  83. package/build/module/store/types.js.map +1 -0
  84. package/build/module/types/index.js.map +1 -1
  85. package/build/typescript/Tabs/IndexAwareTab.d.ts +0 -2
  86. package/build/typescript/Tabs/InternalContext.d.ts +7 -0
  87. package/build/typescript/Tabs/ScrollableTabsView.d.ts +6 -0
  88. package/build/typescript/Tabs/TabIndicatorProps.d.ts +4 -5
  89. package/build/typescript/Tabs/Tabs.d.ts +1 -1
  90. package/build/typescript/Tabs/TabsProps.d.ts +3 -16
  91. package/build/typescript/Tabs/index.d.ts +2 -1
  92. package/build/typescript/Tabs/types.d.ts +9 -0
  93. package/build/typescript/Tabs/useIndexStore.d.ts +3 -0
  94. package/build/typescript/Tabs/useScrollViewReaction.d.ts +1 -2
  95. package/build/typescript/Tabs/useTabCoordinates.d.ts +3 -4
  96. package/build/typescript/Tabs/utils.d.ts +3 -0
  97. package/build/typescript/hooks/index.d.ts +2 -0
  98. package/build/typescript/hooks/useImperativeState.d.ts +6 -0
  99. package/build/typescript/hooks/useSyncAnimatedValue.d.ts +6 -0
  100. package/build/typescript/index.d.ts +1 -0
  101. package/build/typescript/store/MockStore.d.ts +6 -0
  102. package/build/typescript/store/SimpleStore.d.ts +9 -0
  103. package/build/typescript/store/index.d.ts +3 -0
  104. package/build/typescript/store/types.d.ts +8 -0
  105. package/build/typescript/types/index.d.ts +6 -0
  106. package/package.json +4 -4
  107. package/src/Tabs/IndexAwareTab.tsx +10 -13
  108. package/src/Tabs/InternalContext.ts +13 -0
  109. package/src/Tabs/ScrollableTabsView.tsx +26 -0
  110. package/src/Tabs/TabIndicator.tsx +37 -21
  111. package/src/Tabs/TabIndicatorProps.ts +4 -5
  112. package/src/Tabs/Tabs.tsx +55 -50
  113. package/src/Tabs/TabsProps.ts +4 -28
  114. package/src/Tabs/index.ts +2 -1
  115. package/src/Tabs/types.ts +18 -0
  116. package/src/Tabs/useIndexStore.ts +31 -0
  117. package/src/Tabs/useScrollViewReaction.ts +15 -26
  118. package/src/Tabs/useTabCoordinates.ts +12 -23
  119. package/src/Tabs/utils.ts +14 -0
  120. package/src/hooks/index.ts +2 -0
  121. package/src/hooks/useCollapsibleAppBar.ts +1 -1
  122. package/src/hooks/useImperativeState.ts +24 -0
  123. package/src/hooks/useSyncAnimatedValue.ts +37 -0
  124. package/src/index.ts +2 -0
  125. package/src/store/MockStore.ts +17 -0
  126. package/src/store/SimpleStore.ts +45 -0
  127. package/src/store/index.ts +3 -0
  128. package/src/store/types.ts +9 -0
  129. package/src/types/index.ts +7 -0
@@ -1,9 +1,10 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- import React from 'react';
4
- import Animated, { Easing, useAnimatedStyle, withTiming } from 'react-native-reanimated';
3
+ import React, { useCallback, useContext, useEffect, useRef } from 'react';
4
+ import { Animated, Easing } from 'react-native';
5
5
  import { useTheme } from '../styles';
6
6
  import { defaultCoordinate } from './TabCoordinate';
7
+ import InternalContext from './InternalContext';
7
8
  const INDICATOR_WIDTH = 10;
8
9
  const INDICATOR_HEIGHT = 4;
9
10
  const SCROLLABLE_TABS_INSET = 12 * 2;
@@ -25,40 +26,66 @@ const useStyles = function () {
25
26
  };
26
27
  };
27
28
 
28
- const ANIMATION_CONFIG = {
29
- duration: 300,
30
- easing: Easing.out(Easing.exp)
29
+ const startAnimation = (value, toValue) => {
30
+ Animated.timing(value, {
31
+ toValue: toValue,
32
+ duration: 300,
33
+ easing: Easing.bezier(0.25, 1, 0.5, 1),
34
+ useNativeDriver: true
35
+ }).start();
31
36
  };
37
+
32
38
  export default function TabIndicator(props) {
33
39
  const {
34
40
  coordinates,
35
41
  disabled,
42
+ initialIndex,
36
43
  scrollable,
37
- sharedIndex,
38
44
  style,
39
45
  ...otherProps
40
46
  } = props;
41
47
  const styles = useStyles();
42
- const animatedStyle = useAnimatedStyle(() => {
43
- const index = sharedIndex.value;
48
+ const computeAnimationValues = useCallback(currentIndex => {
44
49
  const {
45
50
  x1,
46
51
  x2
47
- } = coordinates[index] ?? defaultCoordinate;
52
+ } = coordinates[currentIndex] ?? defaultCoordinate;
48
53
  const tabWidth = x2 - x1;
49
- const translateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;
54
+ const nextTranslateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;
50
55
  const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;
51
- const scaleX = (tabWidth - inset) / INDICATOR_WIDTH;
56
+ const nextScaleX = (tabWidth - inset) / INDICATOR_WIDTH;
52
57
  return {
53
- transform: [{
54
- translateX: withTiming(translateX, ANIMATION_CONFIG)
55
- }, {
56
- scaleX: withTiming(scaleX, ANIMATION_CONFIG)
57
- }]
58
+ tx: nextTranslateX,
59
+ sx: nextScaleX
58
60
  };
59
61
  }, [coordinates, scrollable]);
62
+ const {
63
+ tx: initialTx,
64
+ sx: initialSx
65
+ } = computeAnimationValues(initialIndex);
66
+ const translateX = useRef(new Animated.Value(initialTx)).current;
67
+ const scaleX = useRef(new Animated.Value(initialSx)).current;
68
+ const {
69
+ indexStore
70
+ } = useContext(InternalContext);
71
+ useEffect(() => {
72
+ return indexStore.subscribe(currentIndex => {
73
+ const {
74
+ tx,
75
+ sx
76
+ } = computeAnimationValues(currentIndex);
77
+ startAnimation(translateX, tx);
78
+ startAnimation(scaleX, sx);
79
+ });
80
+ }, [indexStore, computeAnimationValues]);
60
81
  return /*#__PURE__*/React.createElement(Animated.View, _extends({
61
- style: [styles.root, disabled ? styles.disabled : undefined, animatedStyle, style]
82
+ style: [styles.root, disabled ? styles.disabled : undefined, {
83
+ transform: [{
84
+ translateX
85
+ }, {
86
+ scaleX
87
+ }]
88
+ }, style]
62
89
  }, otherProps));
63
90
  }
64
91
  ;
@@ -1 +1 @@
1
- {"version":3,"names":["React","Animated","Easing","useAnimatedStyle","withTiming","useTheme","defaultCoordinate","INDICATOR_WIDTH","INDICATOR_HEIGHT","SCROLLABLE_TABS_INSET","useStyles","theme","root","backgroundColor","palette","secondary","main","left","bottom","width","height","position","disabled","ANIMATION_CONFIG","duration","easing","out","exp","TabIndicator","props","coordinates","scrollable","sharedIndex","style","otherProps","styles","animatedStyle","index","value","x1","x2","tabWidth","translateX","inset","scaleX","transform","undefined"],"sources":["TabIndicator.tsx"],"sourcesContent":["import React from 'react';\nimport type { WithTimingConfig } from 'react-native-reanimated';\nimport Animated, { Easing, useAnimatedStyle, withTiming } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport type TabIndicatorProps from './TabIndicatorProps';\nimport { defaultCoordinate } from './TabCoordinate';\n\ntype TabIndicatorStyles = NamedStylesStringUnion<'root' | 'disabled'>;\n\nconst INDICATOR_WIDTH = 10;\nconst INDICATOR_HEIGHT = 4;\n\nconst SCROLLABLE_TABS_INSET = 12 * 2;\n\nconst useStyles: UseStyles<TabIndicatorStyles> = function (): TabIndicatorStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: theme.palette.secondary.main,\n left: 0,\n bottom: 0,\n width: INDICATOR_WIDTH,\n height: INDICATOR_HEIGHT,\n position: 'absolute',\n },\n disabled: {\n height: 0,\n },\n };\n};\n\nconst ANIMATION_CONFIG: Readonly<WithTimingConfig> = {\n duration: 300,\n easing: Easing.out(Easing.exp),\n};\n\nexport default function TabIndicator(props: TabIndicatorProps) {\n const {\n coordinates,\n disabled,\n scrollable,\n sharedIndex,\n style,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const animatedStyle = useAnimatedStyle(() => {\n const index = sharedIndex.value;\n\n const { x1, x2 } = coordinates[index] ?? defaultCoordinate;\n\n const tabWidth = x2 - x1;\n\n const translateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;\n\n const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;\n const scaleX = (tabWidth - inset) / INDICATOR_WIDTH;\n\n return {\n transform: [\n { translateX: withTiming(translateX, ANIMATION_CONFIG) },\n { scaleX: withTiming(scaleX, ANIMATION_CONFIG) },\n ],\n };\n }, [coordinates, scrollable]);\n\n return (\n <Animated.View\n style={[\n styles.root,\n disabled ? styles.disabled : undefined,\n animatedStyle,\n style,\n ]}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,OAAOC,QAAP,IAAmBC,MAAnB,EAA2BC,gBAA3B,EAA6CC,UAA7C,QAA+D,yBAA/D;AAEA,SAASC,QAAT,QAAyB,WAAzB;AAEA,SAASC,iBAAT,QAAkC,iBAAlC;AAIA,MAAMC,eAAe,GAAG,EAAxB;AACA,MAAMC,gBAAgB,GAAG,CAAzB;AAEA,MAAMC,qBAAqB,GAAG,KAAK,CAAnC;;AAEA,MAAMC,SAAwC,GAAG,YAAgC;EAC7E,MAAMC,KAAK,GAAGN,QAAQ,EAAtB;EAEA,OAAO;IACHO,IAAI,EAAE;MACFC,eAAe,EAAEF,KAAK,CAACG,OAAN,CAAcC,SAAd,CAAwBC,IADvC;MAEFC,IAAI,EAAE,CA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BAAC,QAAD,CAAU,IAAV;IACI,KAAK,EAAE,CACHI,MAAM,CAACvB,IADJ,EAEHU,QAAQ,GAAGa,MAAM,CAACb,QAAV,GAAqBwB,SAF1B,EAGHV,aAHG,EAIHH,KAJG;EADX,GAOQC,UAPR,EADJ;AAWH;AAAA"}
1
+ {"version":3,"names":["React","useCallback","useContext","useEffect","useRef","Animated","Easing","useTheme","defaultCoordinate","InternalContext","INDICATOR_WIDTH","INDICATOR_HEIGHT","SCROLLABLE_TABS_INSET","useStyles","theme","root","backgroundColor","palette","secondary","main","left","bottom","width","height","position","disabled","startAnimation","value","toValue","timing","duration","easing","bezier","useNativeDriver","start","TabIndicator","props","coordinates","initialIndex","scrollable","style","otherProps","styles","computeAnimationValues","currentIndex","x1","x2","tabWidth","nextTranslateX","inset","nextScaleX","tx","sx","initialTx","initialSx","translateX","Value","current","scaleX","indexStore","subscribe","undefined","transform"],"sources":["TabIndicator.tsx"],"sourcesContent":["import React, { useCallback, useContext, useEffect, useRef } from 'react';\nimport { Animated, Easing } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { useTheme } from '../styles';\nimport type TabIndicatorProps from './TabIndicatorProps';\nimport { defaultCoordinate } from './TabCoordinate';\nimport InternalContext from './InternalContext';\n\ntype TabIndicatorStyles = NamedStylesStringUnion<'root' | 'disabled'>;\n\nconst INDICATOR_WIDTH = 10;\nconst INDICATOR_HEIGHT = 4;\n\nconst SCROLLABLE_TABS_INSET = 12 * 2;\n\nconst useStyles: UseStyles<TabIndicatorStyles> = function (): TabIndicatorStyles {\n const theme = useTheme();\n\n return {\n root: {\n backgroundColor: theme.palette.secondary.main,\n left: 0,\n bottom: 0,\n width: INDICATOR_WIDTH,\n height: INDICATOR_HEIGHT,\n position: 'absolute',\n },\n disabled: {\n height: 0,\n },\n };\n};\n\nconst startAnimation = (value: Animated.Value, toValue: number) => {\n Animated.timing(value, {\n toValue: toValue,\n duration: 300,\n easing: Easing.bezier(0.25, 1, 0.5, 1),\n useNativeDriver: true,\n }).start();\n};\n\nexport default function TabIndicator(props: TabIndicatorProps) {\n const {\n coordinates,\n disabled,\n initialIndex,\n scrollable,\n style,\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const computeAnimationValues = useCallback((currentIndex: number) => {\n const { x1, x2 } = coordinates[currentIndex] ?? defaultCoordinate;\n\n const tabWidth = x2 - x1;\n\n const nextTranslateX = x1 + (tabWidth - INDICATOR_WIDTH) / 2;\n\n const inset = scrollable ? SCROLLABLE_TABS_INSET : 0;\n const nextScaleX = (tabWidth - inset) / INDICATOR_WIDTH;\n\n return { tx: nextTranslateX, sx: nextScaleX };\n }, [coordinates, scrollable]);\n\n const {\n tx: initialTx,\n sx: initialSx,\n } = computeAnimationValues(initialIndex);\n\n const translateX = useRef(new Animated.Value(initialTx)).current;\n const scaleX = useRef(new Animated.Value(initialSx)).current;\n\n const { indexStore } = useContext(InternalContext);\n\n useEffect(() => {\n return indexStore.subscribe(currentIndex => {\n const { tx, sx } = computeAnimationValues(currentIndex);\n\n startAnimation(translateX, tx);\n startAnimation(scaleX, sx);\n });\n }, [indexStore, computeAnimationValues]);\n\n return (\n <Animated.View\n style={[\n styles.root,\n disabled ? styles.disabled : undefined,\n { transform: [{ translateX }, { scaleX }] },\n style,\n ]}\n {...otherProps}\n />\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,UAA7B,EAAyCC,SAAzC,EAAoDC,MAApD,QAAkE,OAAlE;AACA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,cAAjC;AAEA,SAASC,QAAT,QAAyB,WAAzB;AAEA,SAASC,iBAAT,QAAkC,iBAAlC;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AAIA,MAAMC,eAAe,GAAG,EAAxB;AACA,MAAMC,gBAAgB,GAAG,CAAzB;AAEA,MAAMC,qBAAqB,GAAG,KAAK,CAAnC;;AAEA,MAAMC,SAAwC,GAAG,YAAgC;EAC7E,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native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { OverridableComponentProps } from '../types';\nimport type TabCoordinate from './TabCoordinate';\n\nexport default interface TabIndicatorProps extends OverridableComponentProps<ViewProps, {\n /**\n * Tab item coordinates.\n */\n coordinates: TabCoordinate[];\n\n /**\n * If `true`, the indicator is disabled.\n */\n disabled: boolean;\n\n /**\n * If `true`, the tab will be able to scroll.\n */\n scrollable: boolean;\n\n /**\n * Shared index value for using animated interpolation.\n */\n sharedIndex: SharedValue<number>;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TabIndicatorProps.ts"],"sourcesContent":["import type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\nimport type TabCoordinate from './TabCoordinate';\n\nexport default interface TabIndicatorProps extends OverridableComponentProps<ViewProps, {\n /**\n * Tab item coordinates.\n */\n coordinates: TabCoordinate[];\n\n /**\n * If `true`, the indicator is disabled.\n */\n disabled: boolean;\n\n /**\n * Initial index.\n */\n initialIndex: number;\n\n /**\n * If `true`, the tab will be able to scroll.\n */\n scrollable: boolean;\n}> {}\n"],"mappings":""}
@@ -1,11 +1,14 @@
1
- import React, { cloneElement, forwardRef, useImperativeHandle } from 'react';
2
- import { ScrollView, View } from 'react-native';
3
- import { useSharedValue } from 'react-native-reanimated';
1
+ import React, { cloneElement, forwardRef, useEffect, useImperativeHandle } from 'react';
2
+ import { View } from 'react-native';
4
3
  import { css, useTheme } from '../styles';
4
+ import { useSyncAnimatedValue } from '../hooks';
5
5
  import TabIndicator from './TabIndicator';
6
+ import ScrollableTabsView from './ScrollableTabsView';
6
7
  import IndexAwareTab from './IndexAwareTab';
7
8
  import useTabCoordinates from './useTabCoordinates';
8
- import useScrollViewReaction from './useScrollViewReaction';
9
+ import useIndexStore from './useIndexStore';
10
+ import InternalContext from './InternalContext';
11
+ import { isEveryTabCoordinatesDefined } from './utils';
9
12
 
10
13
  const useStyles = function () {
11
14
  const theme = useTheme();
@@ -36,29 +39,27 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
36
39
  variant = 'primary',
37
40
  UNSTABLE_sharedIndex
38
41
  } = props;
39
- const fallbackSharedIndex = useSharedValue(initialIndex);
42
+ const fallbackSharedIndex = useSyncAnimatedValue({
43
+ initialValue: initialIndex
44
+ });
40
45
  const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;
41
46
 
42
- const getCurrentIndex = () => sharedIndex.value;
43
-
44
47
  const setTab = newIndex => {
45
- sharedIndex.value = newIndex;
48
+ sharedIndex.animatedValue.setValue(newIndex);
46
49
  };
47
50
 
48
51
  useImperativeHandle(ref, () => ({
49
- getCurrentIndex,
50
52
  setTab
51
53
  }), [sharedIndex]);
52
54
  const styles = useStyles();
53
- const {
54
- coordinates,
55
- updateCoordinate
56
- } = useTabCoordinates(children);
57
- const {
58
- scrollViewRef,
59
- onLayout
60
- } = useScrollViewReaction(sharedIndex, coordinates);
61
- const isReadyToRenderIndicator = coordinates.length > 0;
55
+ const [coordinates, updateCoordinate] = useTabCoordinates(children);
56
+ const canRenderIndicator = isEveryTabCoordinatesDefined(coordinates, children);
57
+ const indexStore = useIndexStore(sharedIndex);
58
+ useEffect(() => {
59
+ return indexStore.subscribe(newIndex => {
60
+ onChange === null || onChange === void 0 ? void 0 : onChange(newIndex);
61
+ });
62
+ }, [indexStore, onChange]);
62
63
  const tabElements = React.Children.map(children, (child, index) => {
63
64
  const onLayout = event => {
64
65
  const {
@@ -77,15 +78,14 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
77
78
  const onPress = () => {
78
79
  var _child$props$onPress, _child$props;
79
80
 
80
- setTab(index);
81
- onChange === null || onChange === void 0 ? void 0 : onChange(index); // @ts-ignore
81
+ setTab(index); // @ts-ignore
82
82
 
83
83
  (_child$props$onPress = (_child$props = child.props).onPress) === null || _child$props$onPress === void 0 ? void 0 : _child$props$onPress.call(_child$props);
84
84
  }; // @ts-ignore
85
85
 
86
86
 
87
87
  const tabElement = /*#__PURE__*/cloneElement(child, {
88
- enableIndicator: !disableIndicator && !isReadyToRenderIndicator,
88
+ enableIndicator: !disableIndicator && !canRenderIndicator,
89
89
  onLayout,
90
90
  onPress,
91
91
  onMouseDown,
@@ -94,32 +94,34 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
94
94
  });
95
95
  return /*#__PURE__*/React.createElement(IndexAwareTab, {
96
96
  children: tabElement,
97
- index: index,
98
- sharedIndex: sharedIndex
97
+ index: index
99
98
  });
100
99
  });
101
- const tabIndicator = isReadyToRenderIndicator ? /*#__PURE__*/React.createElement(TabIndicator, {
100
+ const tabIndicator = canRenderIndicator ? /*#__PURE__*/React.createElement(TabIndicator, {
102
101
  coordinates: coordinates,
103
102
  disabled: disableIndicator,
104
- scrollable: scrollable,
105
- sharedIndex: sharedIndex
103
+ initialIndex: sharedIndex.initialValue,
104
+ scrollable: scrollable
106
105
  }) : null;
107
- return /*#__PURE__*/React.createElement(View, {
108
- onLayout: onLayout,
106
+ return /*#__PURE__*/React.createElement(InternalContext.Provider, {
107
+ value: {
108
+ indexStore
109
+ }
110
+ }, /*#__PURE__*/React.createElement(View, {
109
111
  style: css([styles.root, scrollable ? undefined : styles.fixedRoot, style])
110
- }, scrollable ? /*#__PURE__*/React.createElement(ScrollView, {
112
+ }, scrollable ? /*#__PURE__*/React.createElement(ScrollableTabsView, {
111
113
  automaticallyAdjustContentInsets: false,
112
114
  bounces: false,
113
115
  contentContainerStyle: styles.scrollableContainer,
116
+ coordinates: coordinates,
114
117
  directionalLockEnabled: true,
115
118
  horizontal: true,
116
- ref: scrollViewRef,
117
119
  scrollsToTop: false,
118
120
  showsHorizontalScrollIndicator: false,
119
121
  showsVerticalScrollIndicator: false,
120
122
  keyboardDismissMode: keyboardDismissMode,
121
123
  keyboardShouldPersistTaps: keyboardShouldPersistTaps
122
- }, tabElements, tabIndicator) : /*#__PURE__*/React.createElement(React.Fragment, null, tabElements, tabIndicator));
124
+ }, tabElements, tabIndicator) : /*#__PURE__*/React.createElement(React.Fragment, null, tabElements, tabIndicator)));
123
125
  });
124
126
  export default Tabs;
125
127
  //# sourceMappingURL=Tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","cloneElement","forwardRef","useImperativeHandle","ScrollView","View","useSharedValue","css","useTheme","TabIndicator","IndexAwareTab","useTabCoordinates","useScrollViewReaction","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","ref","children","initialIndex","disableIndicator","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","style","variant","UNSTABLE_sharedIndex","fallbackSharedIndex","sharedIndex","getCurrentIndex","value","setTab","newIndex","styles","coordinates","updateCoordinate","scrollViewRef","onLayout","isReadyToRenderIndicator","length","tabElements","Children","map","child","index","event","x","width","nativeEvent","layout","onMouseDown","e","preventDefault","onPress","tabElement","enableIndicator","undefined","tabIndicator"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useImperativeHandle } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\nimport { ScrollView, View } from 'react-native';\nimport { useSharedValue } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { css, useTheme } from '../styles';\nimport type TabsProps from './TabsProps';\nimport type { TabsInstance } from './TabsProps';\nimport TabIndicator from './TabIndicator';\nimport IndexAwareTab from './IndexAwareTab';\nimport useTabCoordinates from './useTabCoordinates';\nimport useScrollViewReaction from './useScrollViewReaction';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'scrollableContainer';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {},\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n scrollableContainer: {\n paddingHorizontal: theme.spacing(1),\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n initialIndex = 0,\n disableIndicator = false,\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n style,\n variant = 'primary',\n UNSTABLE_sharedIndex,\n } = props;\n\n const fallbackSharedIndex = useSharedValue<number>(initialIndex);\n\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n\n const getCurrentIndex = (): number => sharedIndex.value;\n\n const setTab = (newIndex: number) => {\n sharedIndex.value = newIndex;\n };\n\n useImperativeHandle(\n ref,\n () => ({\n getCurrentIndex,\n setTab,\n }),\n [sharedIndex],\n );\n\n const styles = useStyles();\n\n const { coordinates, updateCoordinate } = useTabCoordinates(children);\n\n const { scrollViewRef, onLayout } = useScrollViewReaction(sharedIndex, coordinates);\n\n const isReadyToRenderIndicator = coordinates.length > 0;\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n updateCoordinate(index, x, width);\n };\n\n const onMouseDown = (e: GestureResponderEvent) => {\n if (keyboardShouldPersistTaps === 'always') {\n e.preventDefault();\n }\n };\n\n const onPress = () => {\n setTab(index);\n\n onChange?.(index);\n // @ts-ignore\n child.props.onPress?.();\n };\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !isReadyToRenderIndicator,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n style: scrollable ? undefined : styles.fixedTab,\n });\n\n return (\n <IndexAwareTab\n children={tabElement}\n index={index}\n sharedIndex={sharedIndex}\n />\n );\n });\n\n const tabIndicator = isReadyToRenderIndicator ? (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n scrollable={scrollable}\n sharedIndex={sharedIndex}\n />\n ) : null;\n\n return (\n <View\n onLayout={onLayout}\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={styles.scrollableContainer}\n directionalLockEnabled={true}\n horizontal={true}\n ref={scrollViewRef}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={false}\n keyboardDismissMode={keyboardDismissMode}\n keyboardShouldPersistTaps={keyboardShouldPersistTaps}\n >\n {tabElements}\n {tabIndicator}\n </ScrollView>\n ) : (\n <React.Fragment>\n {tabElements}\n {tabIndicator}\n </React.Fragment>\n )}\n </View>\n );\n});\n\nexport default Tabs;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,YAAhB,EAA8BC,UAA9B,EAA0CC,mBAA1C,QAAqE,OAArE;AAEA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AACA,SAASC,cAAT,QAA+B,yBAA/B;AAEA,SAASC,GAAT,EAAcC,QAAd,QAA8B,WAA9B;AAGA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,qBAAP,MAAkC,yBAAlC;;AAUA,MAAMC,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAGN,QAAQ,EAAtB;EAEA,OAAO;IACHO,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;IAQHC,mBAAmB,EAAE;MACjBC,iBAAiB,EAAEP,KAAK,CAACQ,OAAN,CAAc,CAAd;IADF;EARlB,CAAP;AAYH,CAfD;;AAiBA,MAAMC,IAAI,gBAAGrB,UAAU,CAA0B,SAASqB,IAAT,CAAcC,KAAd,EAAqBC,GAArB,EAA0B;EACvE,MAAM;IACFC,QADE;IAEFC,YAAY,GAAG,CAFb;IAGFC,gBAAgB,GAAG,KAHjB;IAIFC,mBAAmB,GAAG,MAJp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I,4BAA4B,EAAE,KATlC;IAUI,mBAAmB,EAAEhB,mBAVzB;IAWI,yBAAyB,EAAEC;EAX/B,GAaKmB,WAbL,EAcKiB,YAdL,CADO,gBAkBP,oBAAC,KAAD,CAAO,QAAP,QACKjB,WADL,EAEKiB,YAFL,CA1BR,CADJ;AAkCH,CA5HsB,CAAvB;AA8HA,eAAe3C,IAAf"}
1
+ {"version":3,"names":["React","cloneElement","forwardRef","useEffect","useImperativeHandle","View","css","useTheme","useSyncAnimatedValue","TabIndicator","ScrollableTabsView","IndexAwareTab","useTabCoordinates","useIndexStore","InternalContext","isEveryTabCoordinatesDefined","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","ref","children","initialIndex","disableIndicator","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","style","variant","UNSTABLE_sharedIndex","fallbackSharedIndex","initialValue","sharedIndex","setTab","newIndex","animatedValue","setValue","styles","coordinates","updateCoordinate","canRenderIndicator","indexStore","subscribe","tabElements","Children","map","child","index","onLayout","event","x","width","nativeEvent","layout","onMouseDown","e","preventDefault","onPress","tabElement","enableIndicator","undefined","tabIndicator"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle } from 'react';\nimport type { GestureResponderEvent, LayoutChangeEvent } from 'react-native';\nimport { View } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { css, useTheme } from '../styles';\nimport { useSyncAnimatedValue } from '../hooks';\nimport type TabsProps from './TabsProps';\nimport type { TabsInstance } from './types';\nimport TabIndicator from './TabIndicator';\nimport ScrollableTabsView from './ScrollableTabsView';\nimport IndexAwareTab from './IndexAwareTab';\nimport useTabCoordinates from './useTabCoordinates';\nimport useIndexStore from './useIndexStore';\nimport InternalContext from './InternalContext';\nimport { isEveryTabCoordinatesDefined } from './utils';\n\ntype TabsStyleKeys =\n | 'root'\n | 'fixedRoot'\n | 'fixedTab'\n | 'scrollableContainer';\n\ntype TabsStyles = NamedStylesStringUnion<TabsStyleKeys>;\n\nconst useStyles: UseStyles<TabsStyles> = function (): TabsStyles {\n const theme = useTheme();\n\n return {\n root: {},\n fixedRoot: {\n flexDirection: 'row',\n },\n fixedTab: {\n flex: 1,\n },\n scrollableContainer: {\n paddingHorizontal: theme.spacing(1),\n },\n };\n};\n\nconst Tabs = forwardRef<TabsInstance, TabsProps>(function Tabs(props, ref) {\n const {\n children,\n initialIndex = 0,\n disableIndicator = false,\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n style,\n variant = 'primary',\n UNSTABLE_sharedIndex,\n } = props;\n\n const fallbackSharedIndex = useSyncAnimatedValue({ initialValue: initialIndex });\n\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n\n const setTab = (newIndex: number) => {\n sharedIndex.animatedValue.setValue(newIndex);\n };\n\n useImperativeHandle(\n ref,\n () => ({\n setTab,\n }),\n [sharedIndex],\n );\n\n const styles = useStyles();\n\n const [coordinates, updateCoordinate] = useTabCoordinates(children);\n\n const canRenderIndicator = isEveryTabCoordinatesDefined(coordinates, children);\n\n const indexStore = useIndexStore(sharedIndex);\n\n useEffect(() => {\n return indexStore.subscribe(newIndex => {\n onChange?.(newIndex);\n });\n }, [indexStore, onChange]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n updateCoordinate(index, x, width);\n };\n\n const onMouseDown = (e: GestureResponderEvent) => {\n if (keyboardShouldPersistTaps === 'always') {\n e.preventDefault();\n }\n };\n\n const onPress = () => {\n setTab(index);\n\n // @ts-ignore\n child.props.onPress?.();\n };\n\n // @ts-ignore\n const tabElement = cloneElement(child, {\n enableIndicator: !disableIndicator && !canRenderIndicator,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n style: scrollable ? undefined : styles.fixedTab,\n });\n\n return (\n <IndexAwareTab\n children={tabElement}\n index={index}\n />\n );\n });\n\n const tabIndicator = canRenderIndicator ? (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={sharedIndex.initialValue}\n scrollable={scrollable}\n />\n ) : null;\n\n return (\n <InternalContext.Provider value={{ indexStore }}>\n <View\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n >\n {scrollable ? (\n <ScrollableTabsView\n automaticallyAdjustContentInsets={false}\n bounces={false}\n contentContainerStyle={styles.scrollableContainer}\n coordinates={coordinates}\n directionalLockEnabled={true}\n horizontal={true}\n scrollsToTop={false}\n showsHorizontalScrollIndicator={false}\n showsVerticalScrollIndicator={false}\n keyboardDismissMode={keyboardDismissMode}\n keyboardShouldPersistTaps={keyboardShouldPersistTaps}\n >\n {tabElements}\n {tabIndicator}\n </ScrollableTabsView>\n ) : (\n <React.Fragment>\n {tabElements}\n {tabIndicator}\n </React.Fragment>\n )}\n </View>\n </InternalContext.Provider>\n );\n});\n\nexport default Tabs;\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,YAAhB,EAA8BC,UAA9B,EAA0CC,SAA1C,EAAqDC,mBAArD,QAAgF,OAAhF;AAEA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,GAAT,EAAcC,QAAd,QAA8B,WAA9B;AACA,SAASC,oBAAT,QAAqC,UAArC;AAGA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,SAASC,4BAAT,QAA6C,SAA7C;;AAUA,MAAMC,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAGV,QAAQ,EAAtB;EAEA,OAAO;IACHW,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,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,GAOnC,IAPJ;EASA,oBACI,oBAAC,eAAD,CAAiB,QAAjB;IAA0B,KAAK,EAAE;MAAEe;IAAF;EAAjC,gBACI,oBAAC,IAAD;IACI,KAAK,EAAE5C,GAAG,CAAC,CACPwC,MAAM,CAAC5B,IADA,EAEPiB,UAAU,GAAGkC,SAAH,GAAevB,MAAM,CAAC3B,SAFzB,EAGPiB,KAHO,CAAD;EADd,GAOKD,UAAU,gBACP,oBAAC,kBAAD;IACI,gCAAgC,EAAE,KADtC;IAEI,OAAO,EAAE,KAFb;IAGI,qBAAqB,EAAEW,MAAM,CAACvB,mBAHlC;IAII,WAAW,EAAEwB,WAJjB;IAKI,sBAAsB,EAAE,IAL5B;IAMI,UAAU,EAAE,IANhB;IAOI,YAAY,EAAE,KAPlB;IAQI,8BAA8B,EAAE,KARpC;IASI,4BAA4B,EAAE,KATlC;IAUI,mBAAmB,EAAEf,mBAVzB;IAWI,yBAAyB,EAAEC;EAX/B,GAaKmB,WAbL,EAcKkB,YAdL,CADO,gBAkBP,oBAAC,KAAD,CAAO,QAAP,QACKlB,WADL,EAEKkB,YAFL,CAzBR,CADJ,CADJ;AAmCH,CA9HsB,CAAvB;AAgIA,eAAe5C,IAAf"}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["TabsProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport type { TabVariant } from '../Tab';\nimport type { OverridableComponentProps } from '../types';\n\nexport type KeyboardDismissMode =\n 'none'\n | 'on-drag'\n | 'interactive'; // ios only\n\nexport type KeyboardShouldPersistTaps =\n 'never'\n | boolean\n | 'always'\n | 'handled'; // app only\n\nexport interface TabsInstance {\n /**\n * Get current tab index.\n */\n getCurrentIndex: () => number;\n\n /**\n * Function to scroll to a specific tab. Invalid index is ignored.\n * @param index\n */\n setTab: (index: number) => void;\n}\n\nexport default interface TabsProps extends OverridableComponentProps<ViewProps, {\n ref?: Ref<TabsInstance>;\n\n /**\n * Collection of Tab components.\n */\n children: ReactNode;\n\n /**\n * If `true`, the indicator is disabled.\n * @default false\n */\n disableIndicator?: boolean;\n\n /**\n * Index of initial tab that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * keyboard dismissing condition of dragging.\n * @default 'none'\n */\n keyboardDismissMode?: KeyboardDismissMode,\n\n /**\n * keyboard persisting condition of tapping.\n * @default 'never'\n */\n keyboardShouldPersistTaps?: KeyboardShouldPersistTaps,\n\n /**\n * Callback fired when a tab is selected.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * If `true`, the component will be able to scroll.\n * @default false\n */\n scrollable?: boolean;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedIndex?: SharedValue<number>;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["TabsProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { Animated, ViewProps } from 'react-native';\nimport type { TabVariant } from '../Tab';\nimport type { OverridableComponentProps, SyncAnimatedValue } from '../types';\nimport type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';\n\nexport default interface TabsProps extends OverridableComponentProps<ViewProps, {\n ref?: Ref<TabsInstance>;\n\n /**\n * Collection of Tab components.\n */\n children: ReactNode;\n\n /**\n * If `true`, the indicator is disabled.\n * @default false\n */\n disableIndicator?: boolean;\n\n /**\n * Index of initial tab that should be selected.\n * @default 0\n */\n initialIndex?: number;\n\n /**\n * keyboard dismissing condition of dragging.\n * @default 'none'\n */\n keyboardDismissMode?: KeyboardDismissMode,\n\n /**\n * keyboard persisting condition of tapping.\n * @default 'never'\n */\n keyboardShouldPersistTaps?: KeyboardShouldPersistTaps,\n\n /**\n * Callback fired when a tab is selected.\n */\n onChange?: (newIndex: number) => void;\n\n /**\n * If `true`, the component will be able to scroll.\n * @default false\n */\n scrollable?: boolean;\n\n /**\n * Unstable API.\n */\n UNSTABLE_sharedIndex?: SyncAnimatedValue;\n\n /**\n * The variant to use.\n * @default 'primary'\n */\n variant?: TabVariant;\n}> {}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './Tabs';\nexport type { default as TabsProps, TabsInstance } from './TabsProps';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,QAAxB"}
1
+ {"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './Tabs';\nexport type { default as TabsProps } from './TabsProps';\nexport type { TabsInstance } from './types';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,QAAxB"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type KeyboardDismissMode =\n 'none'\n | 'on-drag'\n | 'interactive'; // ios only\n\nexport type KeyboardShouldPersistTaps =\n 'never'\n | boolean\n | 'always'\n | 'handled'; // app only\n\nexport interface TabsInstance {\n /**\n * Function to scroll to a specific tab. Invalid index is ignored.\n * @param index\n */\n setTab: (index: number) => void;\n}\n"],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { SimpleStore } from '../store';
3
+ export default function useIndexStore(value) {
4
+ const {
5
+ animatedValue,
6
+ initialValue
7
+ } = value;
8
+ const store = useRef(new SimpleStore(initialValue)).current;
9
+ useEffect(() => {
10
+ const id = animatedValue.addListener(newIndex => {
11
+ store.dispatch(newIndex.value);
12
+ });
13
+ return () => {
14
+ animatedValue.removeListener(id);
15
+ };
16
+ }, [animatedValue]);
17
+ useEffect(() => {
18
+ return () => {
19
+ store.removeAllListeners();
20
+ };
21
+ }, [store]);
22
+ return store;
23
+ }
24
+ ;
25
+ //# sourceMappingURL=useIndexStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","SimpleStore","useIndexStore","value","animatedValue","initialValue","store","current","id","addListener","newIndex","dispatch","removeListener","removeAllListeners"],"sources":["useIndexStore.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { MonoStore } from '../store';\nimport { SimpleStore } from '../store';\nimport type { SyncAnimatedValue } from '../types';\n\nexport default function useIndexStore(value: SyncAnimatedValue): MonoStore<number> {\n const {\n animatedValue,\n initialValue,\n } = value;\n\n const store = useRef(new SimpleStore(initialValue)).current;\n\n useEffect(() => {\n const id = animatedValue.addListener((newIndex) => {\n store.dispatch(newIndex.value);\n });\n\n return () => {\n animatedValue.removeListener(id);\n };\n }, [animatedValue]);\n\n useEffect(() => {\n return () => {\n store.removeAllListeners();\n };\n }, [store]);\n\n return store;\n};\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AAEA,SAASC,WAAT,QAA4B,UAA5B;AAGA,eAAe,SAASC,aAAT,CAAuBC,KAAvB,EAAoE;EAC/E,MAAM;IACFC,aADE;IAEFC;EAFE,IAGFF,KAHJ;EAKA,MAAMG,KAAK,GAAGN,MAAM,CAAC,IAAIC,WAAJ,CAAgBI,YAAhB,CAAD,CAAN,CAAsCE,OAApD;EAEAR,SAAS,CAAC,MAAM;IACZ,MAAMS,EAAE,GAAGJ,aAAa,CAACK,WAAd,CAA2BC,QAAD,IAAc;MAC/CJ,KAAK,CAACK,QAAN,CAAeD,QAAQ,CAACP,KAAxB;IACH,CAFU,CAAX;IAIA,OAAO,MAAM;MACTC,aAAa,CAACQ,cAAd,CAA6BJ,EAA7B;IACH,CAFD;EAGH,CARQ,EAQN,CAACJ,aAAD,CARM,CAAT;EAUAL,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTO,KAAK,CAACO,kBAAN;IACH,CAFD;EAGH,CAJQ,EAIN,CAACP,KAAD,CAJM,CAAT;EAMA,OAAOA,KAAP;AACH;AAAA"}
@@ -1,9 +1,11 @@
1
- import { useCallback, useRef } from 'react';
2
- import { Platform } from 'react-native';
3
- import { runOnJS, scrollTo, useAnimatedReaction, useAnimatedRef } from 'react-native-reanimated';
4
- export default function useScrollViewReaction(sharedIndex, coordinates) {
5
- const scrollViewRef = useAnimatedRef();
1
+ import { useCallback, useContext, useEffect, useRef } from 'react';
2
+ import InternalContext from './InternalContext';
3
+ export default function useScrollViewReaction(coordinates) {
4
+ const scrollViewRef = useRef(null);
6
5
  const lastScrolledXRef = useRef(NaN);
6
+ const {
7
+ indexStore
8
+ } = useContext(InternalContext);
7
9
 
8
10
  const scrollToX = x => {
9
11
  if (Number.isFinite(x)) {
@@ -14,37 +16,30 @@ export default function useScrollViewReaction(sharedIndex, coordinates) {
14
16
  y: 0,
15
17
  animated: true
16
18
  });
17
- didScrollToX(x);
19
+ lastScrolledXRef.current = x;
18
20
  }
19
21
  };
20
22
 
21
- const didScrollToX = x => {
22
- lastScrolledXRef.current = x;
23
- };
24
-
25
23
  const onLayout = useCallback(() => {
26
24
  scrollToX(lastScrolledXRef.current);
27
25
  }, []);
28
- useAnimatedReaction(() => {
29
- const prevIndex = sharedIndex.value - 1;
30
- const prevCoordinate = coordinates[prevIndex];
31
-
32
- if (prevCoordinate) {
33
- const prevTabWidth = prevCoordinate.x2 - prevCoordinate.x1;
34
- return Math.floor(prevCoordinate.x1 + prevTabWidth / 2);
35
- }
26
+ useEffect(() => {
27
+ const computeNextScrollX = index => {
28
+ const prevIndex = index - 1;
29
+ const prevCoordinate = coordinates[prevIndex];
36
30
 
37
- return 0;
38
- }, (x, prevX) => {
39
- if (x !== prevX) {
40
- if (Platform.OS === 'web') {
41
- runOnJS(scrollToX)(x);
42
- } else {
43
- scrollTo(scrollViewRef, x, 0, true);
44
- runOnJS(didScrollToX)(x);
31
+ if (prevCoordinate) {
32
+ const prevTabWidth = prevCoordinate.x2 - prevCoordinate.x1;
33
+ return Math.floor(prevCoordinate.x1 + prevTabWidth / 2);
45
34
  }
46
- }
47
- }, [coordinates]);
35
+
36
+ return 0;
37
+ };
38
+
39
+ return indexStore.subscribe(currentIndex => {
40
+ scrollToX(computeNextScrollX(currentIndex));
41
+ });
42
+ }, [indexStore, coordinates]);
48
43
  return {
49
44
  scrollViewRef,
50
45
  onLayout
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useRef","Platform","runOnJS","scrollTo","useAnimatedReaction","useAnimatedRef","useScrollViewReaction","sharedIndex","coordinates","scrollViewRef","lastScrolledXRef","NaN","scrollToX","x","Number","isFinite","current","y","animated","didScrollToX","onLayout","prevIndex","value","prevCoordinate","prevTabWidth","x2","x1","Math","floor","prevX","OS"],"sources":["useScrollViewReaction.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useCallback, useRef } from 'react';\nimport type { ScrollView, ViewProps } from 'react-native';\nimport { Platform } from 'react-native';\nimport { runOnJS, scrollTo, SharedValue, useAnimatedReaction, useAnimatedRef } from 'react-native-reanimated';\nimport type TabCoordinate from './TabCoordinate';\n\nexport interface UseScrollViewReaction {\n scrollViewRef: MutableRefObject<ScrollView | null>;\n onLayout: ViewProps['onLayout'];\n}\n\nexport default function useScrollViewReaction(\n sharedIndex: SharedValue<number>,\n coordinates: TabCoordinate[],\n): UseScrollViewReaction {\n const scrollViewRef = useAnimatedRef<ScrollView>();\n\n const lastScrolledXRef = useRef<number>(NaN);\n\n const scrollToX = (x: number) => {\n if (Number.isFinite(x)) {\n scrollViewRef.current?.scrollTo({ x, y: 0, animated: true });\n\n didScrollToX(x);\n }\n };\n\n const didScrollToX = (x: number) => {\n lastScrolledXRef.current = x;\n };\n\n const onLayout = useCallback(() => {\n scrollToX(lastScrolledXRef.current);\n }, []);\n\n useAnimatedReaction(\n () => {\n const prevIndex = sharedIndex.value - 1;\n const prevCoordinate = coordinates[prevIndex];\n\n if (prevCoordinate) {\n const prevTabWidth = prevCoordinate.x2 - prevCoordinate.x1;\n return Math.floor(prevCoordinate.x1 + prevTabWidth / 2);\n }\n\n return 0;\n },\n (x, prevX) => {\n if (x !== prevX) {\n if (Platform.OS === 'web') {\n runOnJS(scrollToX)(x);\n }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AoBF,YAAY,GAAG,CAA9C,CAAP;IACH;;IAED,OAAO,CAAP;EACH,CAXc,EAYf,CAACX,CAAD,EAAIgB,KAAJ,KAAc;IACV,IAAIhB,CAAC,KAAKgB,KAAV,EAAiB;MACb,IAAI5B,QAAQ,CAAC6B,EAAT,KAAgB,KAApB,EAA2B;QACvB5B,OAAO,CAACU,SAAD,CAAP,CAAmBC,CAAnB;MACH,CAFD,MAEO;QACHV,QAAQ,CAACM,aAAD,EAAgBI,CAAhB,EAAmB,CAAnB,EAAsB,IAAtB,CAAR;QACAX,OAAO,CAACiB,YAAD,CAAP,CAAsBN,CAAtB;MACH;IACJ;EACJ,CArBc,EAsBf,CAACL,WAAD,CAtBe,CAAnB;EAyBA,OAAO;IAAEC,aAAF;IAAiBW;EAAjB,CAAP;AACH;AAAA"}
1
+ {"version":3,"names":["useCallback","useContext","useEffect","useRef","InternalContext","useScrollViewReaction","coordinates","scrollViewRef","lastScrolledXRef","NaN","indexStore","scrollToX","x","Number","isFinite","current","scrollTo","y","animated","onLayout","computeNextScrollX","index","prevIndex","prevCoordinate","prevTabWidth","x2","x1","Math","floor","subscribe","currentIndex"],"sources":["useScrollViewReaction.ts"],"sourcesContent":["import type { MutableRefObject } from 'react';\nimport { useCallback, useContext, useEffect, useRef } from 'react';\nimport type { ScrollView, ViewProps } from 'react-native';\nimport type TabCoordinate from './TabCoordinate';\nimport InternalContext from './InternalContext';\n\nexport interface UseScrollViewReaction {\n scrollViewRef: MutableRefObject<ScrollView | null>;\n onLayout: ViewProps['onLayout'];\n}\n\nexport default function useScrollViewReaction(\n coordinates: TabCoordinate[],\n): UseScrollViewReaction {\n const scrollViewRef = useRef<ScrollView | null>(null);\n\n const lastScrolledXRef = useRef<number>(NaN);\n\n const { indexStore } = useContext(InternalContext);\n\n const scrollToX = (x: number) => {\n if (Number.isFinite(x)) {\n scrollViewRef.current?.scrollTo({ x, y: 0, animated: true });\n\n lastScrolledXRef.current = x;\n }\n };\n\n const onLayout = useCallback(() => {\n scrollToX(lastScrolledXRef.current);\n }, []);\n\n useEffect(() => {\n const computeNextScrollX = (index: number) => {\n const prevIndex = index - 1;\n const prevCoordinate = coordinates[prevIndex];\n\n if (prevCoordinate) {\n const prevTabWidth = prevCoordinate.x2 - prevCoordinate.x1;\n return Math.floor(prevCoordinate.x1 + prevTabWidth / 2);\n }\n\n return 0;\n };\n\n return indexStore.subscribe(currentIndex => {\n scrollToX(computeNextScrollX(currentIndex));\n });\n }, [indexStore, coordinates]);\n\n return { scrollViewRef, onLayout };\n};\n"],"mappings":"AACA,SAASA,WAAT,EAAsBC,UAAtB,EAAkCC,SAAlC,EAA6CC,MAA7C,QAA2D,OAA3D;AAGA,OAAOC,eAAP,MAA4B,mBAA5B;AAOA,eAAe,SAASC,qBAAT,CACXC,WADW,EAEU;EACrB,MAAMC,aAAa,GAAGJ,MAAM,CAAoB,IAApB,CAA5B;EAEA,MAAMK,gBAAgB,GAAGL,MAAM,CAASM,GAAT,CAA/B;EAEA,MAAM;IAAEC;EAAF,IAAiBT,UAAU,CAACG,eAAD,CAAjC;;EAEA,MAAMO,SAAS,GAAIC,CAAD,IAAe;IAC7B,IAAIC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAAJ,EAAwB;MAAA;;MACpB,yBAAAL,aAAa,CAACQ,OAAd,gFAAuBC,QAAvB,CAAgC;QAAEJ,CAAF;QAAKK,CAAC,EAAE,CAAR;QAAWC,QAAQ,EAAE;MAArB,CAAhC;MAEAV,gBAAgB,CAACO,OAAjB,GAA2BH,CAA3B;IACH;EACJ,CAND;;EAQA,MAAMO,QAAQ,GAAGnB,WAAW,CAAC,MAAM;IAC/BW,SAAS,CAACH,gBAAgB,CAACO,OAAlB,CAAT;EACH,CAF2B,EAEzB,EAFyB,CAA5B;EAIAb,SAAS,CAAC,MAAM;IACZ,MAAMkB,kBAAkB,GAAIC,KAAD,IAAmB;MAC1C,MAAMC,SAAS,GAAGD,KAAK,GAAG,CAA1B;MACA,MAAME,cAAc,GAAGjB,WAAW,CAACgB,SAAD,CAAlC;;MAEA,IAAIC,cAAJ,EAAoB;QAChB,MAAMC,YAAY,GAAGD,cAAc,CAACE,EAAf,GAAoBF,cAAc,CAACG,EAAxD;QACA,OAAOC,IAAI,CAACC,KAAL,CAAWL,cAAc,CAACG,EAAf,GAAoBF,YAAY,GAAG,CAA9C,CAAP;MACH;;MAED,OAAO,CAAP;IACH,CAVD;;IAYA,OAAOd,UAAU,CAACmB,SAAX,CAAqBC,YAAY,IAAI;MACxCnB,SAAS,CAACS,kBAAkB,CAACU,YAAD,CAAnB,CAAT;IACH,CAFM,CAAP;EAGH,CAhBQ,EAgBN,CAACpB,UAAD,EAAaJ,WAAb,CAhBM,CAAT;EAkBA,OAAO;IAAEC,aAAF;IAAiBY;EAAjB,CAAP;AACH;AAAA"}
@@ -1,30 +1,21 @@
1
- import React, { useRef, useState } from 'react';
2
- import { isEveryDefined } from '@fountain-ui/utils';
1
+ import { useRef, useState } from 'react';
2
+ import { isEveryTabCoordinatesDefined } from './utils';
3
3
  export default function useTabCoordinates(tabElements) {
4
- const incompleteCoordinatesRef = useRef([]);
5
- const [completeCoordinates, setCompleteCoordinates] = useState([]);
6
-
7
- const isAllCoordinatesDefined = coordinates => {
8
- const numberOfTab = React.Children.count(tabElements);
9
- const numberOfCoordinates = coordinates.length;
10
- const everyCoordinatesDefined = isEveryDefined(coordinates);
11
- return numberOfTab === numberOfCoordinates && everyCoordinatesDefined;
12
- };
4
+ const [coordinates, setCoordinates] = useState([]);
5
+ const cacheRef = useRef([]);
13
6
 
14
7
  const updateCoordinate = (index, x, width) => {
15
- incompleteCoordinatesRef.current[index] = {
8
+ cacheRef.current[index] = {
16
9
  x1: x,
17
10
  x2: x + width
18
11
  };
19
12
 
20
- if (isAllCoordinatesDefined(incompleteCoordinatesRef.current)) {
21
- setCompleteCoordinates(incompleteCoordinatesRef.current);
13
+ if (isEveryTabCoordinatesDefined(cacheRef.current, tabElements)) {
14
+ setCoordinates([...cacheRef.current]);
15
+ cacheRef.current = [];
22
16
  }
23
17
  };
24
18
 
25
- return {
26
- coordinates: completeCoordinates,
27
- updateCoordinate
28
- };
19
+ return [coordinates, updateCoordinate];
29
20
  }
30
21
  //# sourceMappingURL=useTabCoordinates.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","useState","isEveryDefined","useTabCoordinates","tabElements","incompleteCoordinatesRef","completeCoordinates","setCompleteCoordinates","isAllCoordinatesDefined","coordinates","numberOfTab","Children","count","numberOfCoordinates","length","everyCoordinatesDefined","updateCoordinate","index","x","width","current","x1","x2"],"sources":["useTabCoordinates.ts"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport TabCoordinate from './TabCoordinate';\n\nexport interface UseTabCoordinates {\n coordinates: TabCoordinate[];\n updateCoordinate: (index: number, x: number, width: number) => void;\n}\n\nexport default function useTabCoordinates(tabElements: React.ReactNode): UseTabCoordinates {\n const incompleteCoordinatesRef = useRef<TabCoordinate[]>([]);\n\n const [completeCoordinates, setCompleteCoordinates] = useState<TabCoordinate[]>([]);\n\n const isAllCoordinatesDefined = (coordinates: TabCoordinate[]): boolean => {\n const numberOfTab = React.Children.count(tabElements);\n const numberOfCoordinates = coordinates.length;\n\n const everyCoordinatesDefined = isEveryDefined(coordinates);\n\n return numberOfTab === numberOfCoordinates && everyCoordinatesDefined;\n };\n\n const updateCoordinate = (index: number, x: number, width: number) => {\n incompleteCoordinatesRef.current[index] = { x1: x, x2: x + width };\n\n if (isAllCoordinatesDefined(incompleteCoordinatesRef.current)) {\n setCompleteCoordinates(incompleteCoordinatesRef.current);\n }\n };\n\n return {\n coordinates: completeCoordinates,\n updateCoordinate,\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,MAAhB,EAAwBC,QAAxB,QAAwC,OAAxC;AACA,SAASC,cAAT,QAA+B,oBAA/B;AAQA,eAAe,SAASC,iBAAT,CAA2BC,WAA3B,EAA4E;EACvF,MAAMC,wBAAwB,GAAGL,MAAM,CAAkB,EAAlB,CAAvC;EAEA,MAAM,CAACM,mBAAD,EAAsBC,sBAAtB,IAAgDN,QAAQ,CAAkB,EAAlB,CAA9D;;EAEA,MAAMO,uBAAuB,GAAIC,WAAD,IAA2C;IACvE,MAAMC,WAAW,GAAGX,KAAK,CAACY,QAAN,CAAeC,KAAf,CAAqBR,WAArB,CAApB;IACA,MAAMS,mBAAmB,GAAGJ,WAAW,CAACK,MAAxC;IAEA,MAAMC,uBAAuB,GAAGb,cAAc,CAACO,WAAD,CAA9C;IAEA,OAAOC,WAAW,KAAKG,mBAAhB,IAAuCE,uBAA9C;EACH,CAPD;;EASA,MAAMC,gBAAgB,GAAG,CAACC,KAAD,EAAgBC,CAAhB,EAA2BC,KAA3B,KAA6C;IAClEd,wBAAwB,CAACe,OAAzB,CAAiCH,KAAjC,IAA0C;MAAEI,EAAE,EAAEH,CAAN;MAASI,EAAE,EAAEJ,CAAC,GAAGC;IAAjB,CAA1C;;IAEA,IAAIX,uBAAuB,CAACH,wBAAwB,CAACe,OAA1B,CAA3B,EAA+D;MAC3Db,sBAAsB,CAACF,wBAAwB,CAACe,OAA1B,CAAtB;IACH;EACJ,CAND;;EAQA,OAAO;IACHX,WAAW,EAAEH,mBADV;IAEHU;EAFG,CAAP;AAIH"}
1
+ {"version":3,"names":["useRef","useState","isEveryTabCoordinatesDefined","useTabCoordinates","tabElements","coordinates","setCoordinates","cacheRef","updateCoordinate","index","x","width","current","x1","x2"],"sources":["useTabCoordinates.ts"],"sourcesContent":["import React, { useRef, useState } from 'react';\nimport TabCoordinate from './TabCoordinate';\nimport { isEveryTabCoordinatesDefined } from './utils';\n\nexport interface UpdateCoordinate {\n (index: number, x: number, width: number): void;\n}\n\nexport default function useTabCoordinates(tabElements: React.ReactNode): [TabCoordinate[], UpdateCoordinate] {\n const [coordinates, setCoordinates] = useState<TabCoordinate[]>([]);\n\n const cacheRef = useRef<TabCoordinate[]>([]);\n\n const updateCoordinate: UpdateCoordinate = (index, x, width) => {\n cacheRef.current[index] = { x1: x, x2: x + width };\n\n if (isEveryTabCoordinatesDefined(cacheRef.current, tabElements)) {\n setCoordinates([...cacheRef.current]);\n\n cacheRef.current = [];\n }\n };\n\n return [coordinates, updateCoordinate];\n}\n"],"mappings":"AAAA,SAAgBA,MAAhB,EAAwBC,QAAxB,QAAwC,OAAxC;AAEA,SAASC,4BAAT,QAA6C,SAA7C;AAMA,eAAe,SAASC,iBAAT,CAA2BC,WAA3B,EAA8F;EACzG,MAAM,CAACC,WAAD,EAAcC,cAAd,IAAgCL,QAAQ,CAAkB,EAAlB,CAA9C;EAEA,MAAMM,QAAQ,GAAGP,MAAM,CAAkB,EAAlB,CAAvB;;EAEA,MAAMQ,gBAAkC,GAAG,CAACC,KAAD,EAAQC,CAAR,EAAWC,KAAX,KAAqB;IAC5DJ,QAAQ,CAACK,OAAT,CAAiBH,KAAjB,IAA0B;MAAEI,EAAE,EAAEH,CAAN;MAASI,EAAE,EAAEJ,CAAC,GAAGC;IAAjB,CAA1B;;IAEA,IAAIT,4BAA4B,CAACK,QAAQ,CAACK,OAAV,EAAmBR,WAAnB,CAAhC,EAAiE;MAC7DE,cAAc,CAAC,CAAC,GAAGC,QAAQ,CAACK,OAAb,CAAD,CAAd;MAEAL,QAAQ,CAACK,OAAT,GAAmB,EAAnB;IACH;EACJ,CARD;;EAUA,OAAO,CAACP,WAAD,EAAcG,gBAAd,CAAP;AACH"}
@@ -0,0 +1,9 @@
1
+ import { Children } from 'react';
2
+ import { isEveryDefined } from '@fountain-ui/utils';
3
+ export function isEveryTabCoordinatesDefined(coordinates, tabElements) {
4
+ const numberOfTabs = Children.count(tabElements);
5
+ const numberOfCoordinates = coordinates.length;
6
+ const everyCoordinatesDefined = isEveryDefined(coordinates);
7
+ return numberOfTabs === numberOfCoordinates && everyCoordinatesDefined;
8
+ }
9
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Children","isEveryDefined","isEveryTabCoordinatesDefined","coordinates","tabElements","numberOfTabs","count","numberOfCoordinates","length","everyCoordinatesDefined"],"sources":["utils.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { Children } from 'react';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport type TabCoordinate from './TabCoordinate';\n\n\nexport function isEveryTabCoordinatesDefined(coordinates: TabCoordinate[], tabElements: ReactNode): boolean {\n const numberOfTabs = Children.count(tabElements);\n const numberOfCoordinates = coordinates.length;\n\n const everyCoordinatesDefined = isEveryDefined(coordinates);\n\n return numberOfTabs === numberOfCoordinates && everyCoordinatesDefined;\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,OAAzB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AAIA,OAAO,SAASC,4BAAT,CAAsCC,WAAtC,EAAoEC,WAApE,EAAqG;EACxG,MAAMC,YAAY,GAAGL,QAAQ,CAACM,KAAT,CAAeF,WAAf,CAArB;EACA,MAAMG,mBAAmB,GAAGJ,WAAW,CAACK,MAAxC;EAEA,MAAMC,uBAAuB,GAAGR,cAAc,CAACE,WAAD,CAA9C;EAEA,OAAOE,YAAY,KAAKE,mBAAjB,IAAwCE,uBAA/C;AACH"}
@@ -3,6 +3,8 @@ export { default as useCollapsibleAppBar } from './useCollapsibleAppBar';
3
3
  export { default as useContentContainerStyle } from './useContentContainerStyle';
4
4
  export { default as useElevationStyle } from './useElevationStyle';
5
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
6
+ export { default as useImperativeState } from './useImperativeState';
7
+ export { default as useSyncAnimatedValue } from './useSyncAnimatedValue';
6
8
  export { default as useThrottle } from './useThrottle';
7
9
  export { default as useValidWindowDimensions } from './useValidWindowDimensions';
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","useBreakpointUp","useCollapsibleAppBar","useContentContainerStyle","useElevationStyle","useFadeInAppBar","useThrottle","useValidWindowDimensions"],"sources":["index.ts"],"sourcesContent":["export { default as useBreakpointUp } from './useBreakpointUp';\nexport { default as useCollapsibleAppBar } from './useCollapsibleAppBar';\nexport { default as useContentContainerStyle } from './useContentContainerStyle';\nexport { default as useElevationStyle } from './useElevationStyle';\nexport { default as useFadeInAppBar } from './useFadeInAppBar';\nexport { default as useThrottle } from './useThrottle';\nexport { default as useValidWindowDimensions } from './useValidWindowDimensions';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,eAApB,QAA2C,mBAA3C;AACA,SAASD,OAAO,IAAIE,oBAApB,QAAgD,wBAAhD;AACA,SAASF,OAAO,IAAIG,wBAApB,QAAoD,4BAApD;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C;AACA,SAASJ,OAAO,IAAIK,eAApB,QAA2C,mBAA3C;AACA,SAASL,OAAO,IAAIM,WAApB,QAAuC,eAAvC;AACA,SAASN,OAAO,IAAIO,wBAApB,QAAoD,4BAApD"}
1
+ {"version":3,"names":["default","useBreakpointUp","useCollapsibleAppBar","useContentContainerStyle","useElevationStyle","useFadeInAppBar","useImperativeState","useSyncAnimatedValue","useThrottle","useValidWindowDimensions"],"sources":["index.ts"],"sourcesContent":["export { default as useBreakpointUp } from './useBreakpointUp';\nexport { default as useCollapsibleAppBar } from './useCollapsibleAppBar';\nexport { default as useContentContainerStyle } from './useContentContainerStyle';\nexport { default as useElevationStyle } from './useElevationStyle';\nexport { default as useFadeInAppBar } from './useFadeInAppBar';\nexport { default as useImperativeState } from './useImperativeState';\nexport { default as useSyncAnimatedValue } from './useSyncAnimatedValue';\nexport { default as useThrottle } from './useThrottle';\nexport { default as useValidWindowDimensions } from './useValidWindowDimensions';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,eAApB,QAA2C,mBAA3C;AACA,SAASD,OAAO,IAAIE,oBAApB,QAAgD,wBAAhD;AACA,SAASF,OAAO,IAAIG,wBAApB,QAAoD,4BAApD;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,qBAA7C;AACA,SAASJ,OAAO,IAAIK,eAApB,QAA2C,mBAA3C;AACA,SAASL,OAAO,IAAIM,kBAApB,QAA8C,sBAA9C;AACA,SAASN,OAAO,IAAIO,oBAApB,QAAgD,wBAAhD;AACA,SAASP,OAAO,IAAIQ,WAApB,QAAuC,eAAvC;AACA,SAASR,OAAO,IAAIS,wBAApB,QAAoD,4BAApD"}
@@ -139,7 +139,7 @@ export default function useCollapsibleAppBar() {
139
139
  overlapped.value = offsetY + nextTranslateY > 0;
140
140
  translateY.value = withTiming(nextTranslateY, ANIMATION_CONFIG);
141
141
  }
142
- }, [keyboardDismissMode]);
142
+ }, [keyboardDismissMode, appBarHeight]);
143
143
  const hasCollapsible = collapsibleToolbarHeight > 0;
144
144
  const appBarStyle = [animatedStyle, {
145
145
  paddingTop: safeAreaInsets.top