@fountain-ui/core 1.14.1 → 1.16.0

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 (32) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/build/commonjs/IconButton/IconButton.js +1 -1
  3. package/build/commonjs/IconButton/IconButton.js.map +1 -1
  4. package/build/commonjs/Tabs/Tabs.js +12 -1
  5. package/build/commonjs/Tabs/Tabs.js.map +1 -1
  6. package/build/commonjs/hooks/index.js +8 -0
  7. package/build/commonjs/hooks/index.js.map +1 -1
  8. package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js +22 -0
  9. package/build/commonjs/hooks/useValidWindowDimensions/index.ios.js.map +1 -0
  10. package/build/commonjs/hooks/useValidWindowDimensions/index.js +12 -0
  11. package/build/commonjs/hooks/useValidWindowDimensions/index.js.map +1 -0
  12. package/build/module/IconButton/IconButton.js +1 -1
  13. package/build/module/IconButton/IconButton.js.map +1 -1
  14. package/build/module/Tabs/Tabs.js +12 -1
  15. package/build/module/Tabs/Tabs.js.map +1 -1
  16. package/build/module/hooks/index.js +1 -0
  17. package/build/module/hooks/index.js.map +1 -1
  18. package/build/module/hooks/useValidWindowDimensions/index.ios.js +13 -0
  19. package/build/module/hooks/useValidWindowDimensions/index.ios.js.map +1 -0
  20. package/build/module/hooks/useValidWindowDimensions/index.js +3 -0
  21. package/build/module/hooks/useValidWindowDimensions/index.js.map +1 -0
  22. package/build/typescript/Tabs/TabsProps.d.ts +12 -0
  23. package/build/typescript/hooks/index.d.ts +1 -0
  24. package/build/typescript/hooks/useValidWindowDimensions/index.d.ts +2 -0
  25. package/build/typescript/hooks/useValidWindowDimensions/index.ios.d.ts +1 -0
  26. package/package.json +2 -2
  27. package/src/IconButton/IconButton.tsx +1 -1
  28. package/src/Tabs/Tabs.tsx +12 -1
  29. package/src/Tabs/TabsProps.ts +23 -0
  30. package/src/hooks/index.ts +1 -0
  31. package/src/hooks/useValidWindowDimensions/index.ios.ts +15 -0
  32. package/src/hooks/useValidWindowDimensions/index.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.16.0](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/core@1.11.0...@fountain-ui/core@1.16.0) (2022-03-07)
7
+
8
+ **Note:** Version bump only for package @fountain-ui/core
9
+
10
+
11
+
12
+
13
+
14
+ # [1.15.0](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/core@1.11.0...@fountain-ui/core@1.15.0) (2022-01-25)
15
+
16
+ **Note:** Version bump only for package @fountain-ui/core
17
+
18
+
19
+
20
+
21
+
22
+ ## [1.14.2](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/core@1.11.0...@fountain-ui/core@1.14.2) (2022-01-13)
23
+
24
+ **Note:** Version bump only for package @fountain-ui/core
25
+
26
+
27
+
28
+
29
+
6
30
  ## [1.14.1](https://github.com/tappytoon/tappytoon/compare/@fountain-ui/core@1.11.0...@fountain-ui/core@1.14.1) (2022-01-07)
7
31
 
8
32
  **Note:** Version bump only for package @fountain-ui/core
@@ -48,7 +48,7 @@ function IconButton(props) {
48
48
  });
49
49
  const fontStyle = (0, _styles.createFontStyle)(theme, {
50
50
  selector: typo => typo.caption1,
51
- color: theme.palette['text'].hint
51
+ color: theme.palette[color].main
52
52
  });
53
53
  const labelStyle = (0, _styles.css)([fontStyle]);
54
54
  const rootStyle = (0, _styles.css)([styles.root, style]);
@@ -1 +1 @@
1
- {"version":3,"sources":["IconButton.tsx"],"names":["useStyles","theme","root","flexDirection","justifyContent","alignItems","padding","spacing","IconButton","props","children","color","disabled","label","onPress","size","style","otherProps","styles","icon","palette","main","fontStyle","selector","typo","caption1","hint","labelStyle","rootStyle","handlePress"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAKA,MAAMA,SAAsC,GAAG,YAA8B;AAC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I,6BAAC,mBAAD;AACI,IAAA,QAAQ,EAAEF,QADd;AAEI,IAAA,OAAO,EAAEiB,WAFb;AAGI,IAAA,KAAK,EAAED;AAHX,KAIQX,UAJR,GAMKE,IANL,EAQKN,KAAK,gBACF,6BAAC,iBAAD;AACI,IAAA,QAAQ,EAAEA,KADd;AAEI,IAAA,KAAK,EAAEc;AAFX,IADE,GAKF,IAbR,CADJ;AAiBH;;AAAA","sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ButtonBase from '../ButtonBase';\nimport { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';\nimport type IconButtonProps from './IconButtonProps';\n\ntype IconButtonStyles = NamedStylesStringUnion<'root'>;\n\nconst useStyles: UseStyles<IconButtonStyles> = function (): IconButtonStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'center',\n padding: theme.spacing(1),\n },\n };\n};\n\nexport default function IconButton(props: IconButtonProps) {\n const {\n children,\n color = 'primary',\n disabled = false,\n label,\n onPress,\n size = 'medium',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n const styles = useStyles();\n\n const icon = cloneSvgIcon(children, {\n color: theme.palette[color].main,\n size,\n });\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption1,\n color: theme.palette['text'].hint,\n });\n\n const labelStyle = css([\n fontStyle,\n ]);\n\n const rootStyle = css([\n styles.root,\n style,\n ]);\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={rootStyle}\n {...otherProps}\n >\n {icon}\n\n {label ? (\n <Text\n children={label}\n style={labelStyle}\n />\n ) : null}\n </ButtonBase>\n );\n};\n"]}
1
+ {"version":3,"sources":["IconButton.tsx"],"names":["useStyles","theme","root","flexDirection","justifyContent","alignItems","padding","spacing","IconButton","props","children","color","disabled","label","onPress","size","style","otherProps","styles","icon","palette","main","fontStyle","selector","typo","caption1","labelStyle","rootStyle","handlePress"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAKA,MAAMA,SAAsC,GAAG,YAA8B;AACzE,QAAMC,KAAK,GAAG,uBAAd;AAEA,SAAO;AACHC,IAAAA,IAAI,EAAE;AACFC,MAAAA,aAAa,EAAE,QADb;AAEFC,MAAAA,cAAc,EAAE,QAFd;AAGFC,MAAAA,UAAU,EAAE,QAHV;AAIFC,MAAAA,OAAO,EAAEL,KAAK,CAACM,OAAN,CAAc,CAAd;AAJP;AADH,GAAP;AAQH,CAXD;;AAae,SAASC,UAAT,CAAoBC,KAApB,EAA4C;AACvD,QAAM;AACFC,IAAAA,QADE;AAEFC,IAAAA,KAAK,GAAG,SAFN;AAGFC,IAAAA,QAAQ,GAAG,KAHT;AAIFC,IAAAA,KAJE;AAKFC,IAAAA,OALE;AAMFC,IAAAA,IAAI,GAAG,QANL;AAOFC,IAAAA,KAPE;AAQF,OAAGC;AARD,MASFR,KATJ;AAWA,QAAMR,KAAK,GAAG,uBAAd;AACA,QAAMiB,MAAM,GAAGlB,SAAS,EAAxB;AAEA,QAAMmB,IAAI,GAAG,0BAAaT,QAAb,EAAuB;AAChCC,IAAAA,KAAK,EAAEV,KAAK,CAACmB,OAAN,CAAcT,KAAd,EAAqBU,IADI;AAEhCN,IAAAA;AAFgC,GAAvB,CAAb;AAKA,QAAMO,SAAS,GAAG,6BAAgBrB,KAAhB,EAAuB;AACrCsB,IAAAA,QAAQ,EAAGC,IAAD,IAAUA,IAAI,CAACC,QADY;AAErCd,IAAAA,KAAK,EAAEV,KAAK,CAACmB,OAAN,CAAcT,KAAd,EAAqBU;AAFS,GAAvB,CAAlB;AAKA,QAAMK,UAAU,GAAG,iBAAI,CACnBJ,SADmB,CAAJ,CAAnB;AAIA,QAAMK,SAAS,GAAG,iBAAI,CAClBT,MAAM,CAAChB,IADW,EAElBc,KAFkB,CAAJ,CAAlB;;AAKA,QAAMY,WAAW,GAAG,YAAY;AAC5B,QAAIhB,QAAJ,EAAc;AACV;AACH;;AACD,QAAIE,OAAJ,EAAa;AACTA,MAAAA,OAAO;AACP;AACH;AACJ,GARD;;AAUA,sBACI,6BAAC,mBAAD;AACI,IAAA,QAAQ,EAAEF,QADd;AAEI,IAAA,OAAO,EAAEgB,WAFb;AAGI,IAAA,KAAK,EAAED;AAHX,KAIQV,UAJR,GAMKE,IANL,EAQKN,KAAK,gBACF,6BAAC,iBAAD;AACI,IAAA,QAAQ,EAAEA,KADd;AAEI,IAAA,KAAK,EAAEa;AAFX,IADE,GAKF,IAbR,CADJ;AAiBH;;AAAA","sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ButtonBase from '../ButtonBase';\nimport { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';\nimport type IconButtonProps from './IconButtonProps';\n\ntype IconButtonStyles = NamedStylesStringUnion<'root'>;\n\nconst useStyles: UseStyles<IconButtonStyles> = function (): IconButtonStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'center',\n padding: theme.spacing(1),\n },\n };\n};\n\nexport default function IconButton(props: IconButtonProps) {\n const {\n children,\n color = 'primary',\n disabled = false,\n label,\n onPress,\n size = 'medium',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n const styles = useStyles();\n\n const icon = cloneSvgIcon(children, {\n color: theme.palette[color].main,\n size,\n });\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption1,\n color: theme.palette[color].main,\n });\n\n const labelStyle = css([\n fontStyle,\n ]);\n\n const rootStyle = css([\n styles.root,\n style,\n ]);\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={rootStyle}\n {...otherProps}\n >\n {icon}\n\n {label ? (\n <Text\n children={label}\n style={labelStyle}\n />\n ) : null}\n </ButtonBase>\n );\n};\n"]}
@@ -50,6 +50,8 @@ function Tabs(props) {
50
50
  children,
51
51
  index: indexProp,
52
52
  disableIndicator = false,
53
+ keyboardDismissMode = 'none',
54
+ keyboardShouldPersistTaps = 'never',
53
55
  onChange,
54
56
  scrollable = false,
55
57
  scrollValue: scrollValueProp,
@@ -115,6 +117,12 @@ function Tabs(props) {
115
117
  }, ...prev.slice(index + 1)]);
116
118
  };
117
119
 
120
+ const onMouseDown = e => {
121
+ if (keyboardShouldPersistTaps === 'always') {
122
+ e.preventDefault();
123
+ }
124
+ };
125
+
118
126
  const onPress = () => {
119
127
  var _child$props$onPress, _child$props;
120
128
 
@@ -130,6 +138,7 @@ function Tabs(props) {
130
138
  enableIndicator: enableIndicatorPlaceholder,
131
139
  onLayout,
132
140
  onPress,
141
+ onMouseDown,
133
142
  variant,
134
143
  selected,
135
144
  style: scrollable ? undefined : styles.fixedTab
@@ -155,7 +164,9 @@ function Tabs(props) {
155
164
  ref: scrollViewRef,
156
165
  scrollsToTop: false,
157
166
  showsHorizontalScrollIndicator: false,
158
- showsVerticalScrollIndicator: false
167
+ showsVerticalScrollIndicator: false,
168
+ keyboardDismissMode: keyboardDismissMode,
169
+ keyboardShouldPersistTaps: keyboardShouldPersistTaps
159
170
  }, tabElements, indicator) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, tabElements, indicator));
160
171
  }
161
172
 
@@ -1 +1 @@
1
- {"version":3,"sources":["Tabs.tsx"],"names":["useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","children","index","indexProp","disableIndicator","onChange","scrollable","scrollValue","scrollValueProp","style","variant","otherProps","styles","containerWidth","handleLayout","scrollViewRef","React","useRef","tabCount","Children","count","coordinates","setCoordinates","useState","Array","internalScrollValue","Animated","useSharedValue","isReadyToRenderIndicator","useEffect","animateTab","value","withTiming","duration","easing","Easing","out","exp","undefined","snapTab","scrollView","current","coordinate","defaultCoordinate","tabWidth","x2","x1","x","scrollTo","y","animated","tabElements","map","child","onLayout","event","width","nativeEvent","layout","prev","slice","onPress","selected","enableIndicatorPlaceholder","cloneElement","enableIndicator","indicator"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAUA,MAAMA,SAAgC,GAAG,YAAwB;AAC7D,QAAMC,KAAK,GAAG,uBAAd;AAEA,SAAO;AACHC,IAAAA,IAAI,EAAE,EADH;AAEHC,IAAAA,SAAS,EAAE;AACPC,MAAAA,aAAa,EAAE;AADR,KAFR;AAKHC,IAAAA,QAAQ,EAAE;AACNC,MAAAA,IAAI,EAAE;AADA,KALP;AAQHC,IAAAA,mBAAmB,EAAE;AACjBC,MAAAA,iBAAiB,EAAEP,KAAK,CAACQ,OAAN,CAAc,CAAd;AADF;AARlB,GAAP;AAYH,CAfD;;AAiBe,SAASC,IAAT,CAAcC,KAAd,EAAgC;AAC3C,QAAM;AACFC,IAAAA,QADE;AAEFC,IAAAA,KAAK,EAAEC,SAFL;AAGFC,IAAAA,gBAAgB,GAAG,KAHjB;AAIFC,IAAAA,QAJE;AAKFC,IAAAA,UAAU,GAAG,KALX;AAMFC,IAAAA,WAAW,EAAEC,eANX;AAOFC,IAAAA,KAPE;AAQFC,IAAAA,OAAO,GAAG,SARR;AASF,OAAGC;AATD,MAUFX,KAVJ;AAYA,QAAMY,MAAM,GAAGvB,SAAS,EAAxB;AAEA,QAAM,CAACwB,cAAD,EAAiBC,YAAjB,IAAiC,sBAAvC;;AAEA,QAAMC,aAAa,GAAGC,eAAMC,MAAN,CAAgC,IAAhC,CAAtB;;AAEA,QAAMC,QAAQ,GAAGF,eAAMG,QAAN,CAAeC,KAAf,CAAqBnB,QAArB,CAAjB;;AACA,QAAM,CAACoB,WAAD,EAAcC,cAAd,IAAgCN,eAAMO,QAAN,CAAgC,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AAClB;AANV,KAA1B,CAAP;AAQH,GA/BmB,CAApB;;AAiCA,QAAMwE,SAAS,gBACX,6BAAC,qBAAD;AACI,IAAA,WAAW,EAAE7C,WADjB;AAEI,IAAA,QAAQ,EAAEjB,gBAFd;AAGI,IAAA,UAAU,EAAEE,UAHhB;AAII,IAAA,WAAW,EAAEC;AAJjB,IADJ;;AASA,sBACI,6BAAC,iBAAD;AACI,IAAA,QAAQ,EAAEO,YADd;AAEI,IAAA,KAAK,EAAE,iBAAI,CACPF,MAAM,CAACrB,IADA,EAEPe,UAAU,GAAGgC,SAAH,GAAe1B,MAAM,CAACpB,SAFzB,EAGPiB,KAHO,CAAJ;AAFX,KAOQE,UAPR,GASKL,UAAU,gBACP,6BAAC,uBAAD;AACI,IAAA,gCAAgC,EAAE,KADtC;AAEI,IAAA,OAAO,EAAE,KAFb;AAGI,IAAA,qBAAqB,EAAEM,MAAM,CAAChB,mBAHlC;AAII,IAAA,sBAAsB,EAAE,IAJ5B;AAKI,IAAA,UAAU,EAAE,IALhB;AAMI,IAAA,GAAG,EAAEmB,aANT;AAOI,IAAA,YAAY,EAAE,KAPlB;AAQI,IAAA,8BAA8B,EAAE,KARpC;AASI,IAAA,4BAA4B,EAAE;AATlC,KAWKoC,WAXL,EAYKe,SAZL,CADO,gBAgBP,4DACKf,WADL,EAEKe,SAFL,CAzBR,CADJ;AAiCH;;AAAA","sourcesContent":["import React from 'react';\nimport { LayoutChangeEvent, ScrollView, View } from 'react-native';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport { css, useTheme } from '../styles';\nimport { useWidth } from '../internal/hooks';\nimport type TabsProps from './TabsProps';\nimport TabCoordinate, { defaultCoordinate } from './TabCoordinate';\nimport TabIndicator from './TabIndicator';\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\nexport default function Tabs(props: TabsProps) {\n const {\n children,\n index: indexProp,\n disableIndicator = false,\n onChange,\n scrollable = false,\n scrollValue: scrollValueProp,\n style,\n variant = 'primary',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const [containerWidth, handleLayout] = useWidth();\n\n const scrollViewRef = React.useRef<ScrollView | null>(null);\n\n const tabCount = React.Children.count(children);\n const [coordinates, setCoordinates] = React.useState<TabCoordinate[]>(() => new Array(tabCount));\n\n const internalScrollValue = Animated.useSharedValue(0);\n const scrollValue = scrollValueProp || internalScrollValue;\n\n const isReadyToRenderIndicator = isEveryDefined(coordinates);\n\n React.useEffect(() => {\n const animateTab = (index: number) => {\n internalScrollValue.value = Animated.withTiming(index, {\n duration: 200,\n easing: Easing.out(Easing.exp),\n });\n };\n\n if (scrollValueProp === undefined) {\n animateTab(indexProp);\n }\n }, [indexProp, scrollValueProp, internalScrollValue]);\n\n React.useEffect(() => {\n const snapTab = (index: number) => {\n const scrollView = scrollViewRef.current;\n const coordinate: TabCoordinate = coordinates[index - 1] || defaultCoordinate;\n\n if (scrollView) {\n const tabWidth = coordinate.x2 - coordinate.x1;\n const x = coordinate.x1 + tabWidth / 2;\n\n scrollView.scrollTo({ x, y: 0, animated: true });\n }\n };\n\n snapTab(indexProp);\n }, [indexProp, containerWidth, coordinates]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n setCoordinates(prev => ([\n ...prev.slice(0, index),\n { x1: x, x2: x + width },\n ...prev.slice(index + 1),\n ]));\n };\n\n const onPress = () => {\n onChange?.(index);\n // @ts-ignore\n child.props.onPress?.();\n };\n\n const selected = index === indexProp;\n const enableIndicatorPlaceholder = disableIndicator\n ? false\n : (isReadyToRenderIndicator ? false : selected);\n\n //@ts-ignore\n return React.cloneElement(child, {\n enableIndicator: enableIndicatorPlaceholder,\n onLayout,\n onPress,\n variant,\n selected,\n style: scrollable ? undefined : styles.fixedTab,\n });\n });\n\n const indicator = (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n scrollable={scrollable}\n scrollValue={scrollValue}\n />\n );\n\n return (\n <View\n onLayout={handleLayout}\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n {...otherProps}\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 >\n {tabElements}\n {indicator}\n </ScrollView>\n ) : (\n <>\n {tabElements}\n {indicator}\n </>\n )}\n </View>\n );\n};\n"]}
1
+ {"version":3,"sources":["Tabs.tsx"],"names":["useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","children","index","indexProp","disableIndicator","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollValue","scrollValueProp","style","variant","otherProps","styles","containerWidth","handleLayout","scrollViewRef","React","useRef","tabCount","Children","count","coordinates","setCoordinates","useState","Array","internalScrollValue","Animated","useSharedValue","isReadyToRenderIndicator","useEffect","animateTab","value","withTiming","duration","easing","Easing","out","exp","undefined","snapTab","scrollView","current","coordinate","defaultCoordinate","tabWidth","x2","x1","x","scrollTo","y","animated","tabElements","map","child","onLayout","event","width","nativeEvent","layout","prev","slice","onMouseDown","e","preventDefault","onPress","selected","enableIndicatorPlaceholder","cloneElement","enableIndicator","indicator"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;A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AM,CAACpB;AAPV,KAA1B,CAAP;AASH,GAtCmB,CAApB;;AAwCA,QAAM6E,SAAS,gBACX,6BAAC,qBAAD;AACI,IAAA,WAAW,EAAEhD,WADjB;AAEI,IAAA,QAAQ,EAAEnB,gBAFd;AAGI,IAAA,UAAU,EAAEI,UAHhB;AAII,IAAA,WAAW,EAAEC;AAJjB,IADJ;;AASA,sBACI,6BAAC,iBAAD;AACI,IAAA,QAAQ,EAAEO,YADd;AAEI,IAAA,KAAK,EAAE,iBAAI,CACPF,MAAM,CAACvB,IADA,EAEPiB,UAAU,GAAGgC,SAAH,GAAe1B,MAAM,CAACtB,SAFzB,EAGPmB,KAHO,CAAJ;AAFX,KAOQE,UAPR,GASKL,UAAU,gBACP,6BAAC,uBAAD;AACI,IAAA,gCAAgC,EAAE,KADtC;AAEI,IAAA,OAAO,EAAE,KAFb;AAGI,IAAA,qBAAqB,EAAEM,MAAM,CAAClB,mBAHlC;AAII,IAAA,sBAAsB,EAAE,IAJ5B;AAKI,IAAA,UAAU,EAAE,IALhB;AAMI,IAAA,GAAG,EAAEqB,aANT;AAOI,IAAA,YAAY,EAAE,KAPlB;AAQI,IAAA,8BAA8B,EAAE,KARpC;AASI,IAAA,4BAA4B,EAAE,KATlC;AAUI,IAAA,mBAAmB,EAAEZ,mBAVzB;AAWI,IAAA,yBAAyB,EAAEC;AAX/B,KAaK+C,WAbL,EAcKkB,SAdL,CADO,gBAkBP,4DACKlB,WADL,EAEKkB,SAFL,CA3BR,CADJ;AAmCH;;AAAA","sourcesContent":["import React from 'react';\nimport { GestureResponderEvent, LayoutChangeEvent, ScrollView, View } from 'react-native';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport { css, useTheme } from '../styles';\nimport { useWidth } from '../internal/hooks';\nimport type TabsProps from './TabsProps';\nimport TabCoordinate, { defaultCoordinate } from './TabCoordinate';\nimport TabIndicator from './TabIndicator';\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\nexport default function Tabs(props: TabsProps) {\n const {\n children,\n index: indexProp,\n disableIndicator = false,\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollValue: scrollValueProp,\n style,\n variant = 'primary',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const [containerWidth, handleLayout] = useWidth();\n\n const scrollViewRef = React.useRef<ScrollView | null>(null);\n\n const tabCount = React.Children.count(children);\n const [coordinates, setCoordinates] = React.useState<TabCoordinate[]>(() => new Array(tabCount));\n\n const internalScrollValue = Animated.useSharedValue(0);\n const scrollValue = scrollValueProp || internalScrollValue;\n\n const isReadyToRenderIndicator = isEveryDefined(coordinates);\n\n React.useEffect(() => {\n const animateTab = (index: number) => {\n internalScrollValue.value = Animated.withTiming(index, {\n duration: 200,\n easing: Easing.out(Easing.exp),\n });\n };\n\n if (scrollValueProp === undefined) {\n animateTab(indexProp);\n }\n }, [indexProp, scrollValueProp, internalScrollValue]);\n\n React.useEffect(() => {\n const snapTab = (index: number) => {\n const scrollView = scrollViewRef.current;\n const coordinate: TabCoordinate = coordinates[index - 1] || defaultCoordinate;\n\n if (scrollView) {\n const tabWidth = coordinate.x2 - coordinate.x1;\n const x = coordinate.x1 + tabWidth / 2;\n\n scrollView.scrollTo({ x, y: 0, animated: true });\n }\n };\n\n snapTab(indexProp);\n }, [indexProp, containerWidth, coordinates]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n setCoordinates(prev => ([\n ...prev.slice(0, index),\n { x1: x, x2: x + width },\n ...prev.slice(index + 1),\n ]));\n };\n\n const onMouseDown = (e: GestureResponderEvent) => {\n if (keyboardShouldPersistTaps === 'always') {\n e.preventDefault();\n }\n };\n\n const onPress = () => {\n onChange?.(index);\n // @ts-ignore\n child.props.onPress?.();\n };\n\n const selected = index === indexProp;\n const enableIndicatorPlaceholder = disableIndicator\n ? false\n : (isReadyToRenderIndicator ? false : selected);\n\n //@ts-ignore\n return React.cloneElement(child, {\n enableIndicator: enableIndicatorPlaceholder,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n selected,\n style: scrollable ? undefined : styles.fixedTab,\n });\n });\n\n const indicator = (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n scrollable={scrollable}\n scrollValue={scrollValue}\n />\n );\n\n return (\n <View\n onLayout={handleLayout}\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n {...otherProps}\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 {indicator}\n </ScrollView>\n ) : (\n <>\n {tabElements}\n {indicator}\n </>\n )}\n </View>\n );\n};\n"]}
@@ -39,6 +39,12 @@ Object.defineProperty(exports, "useThrottle", {
39
39
  return _useThrottle.default;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "useValidWindowDimensions", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _useValidWindowDimensions.default;
46
+ }
47
+ });
42
48
 
43
49
  var _useBreakpointUp = _interopRequireDefault(require("./useBreakpointUp"));
44
50
 
@@ -52,5 +58,7 @@ var _useFadeInAppBar = _interopRequireDefault(require("./useFadeInAppBar"));
52
58
 
53
59
  var _useThrottle = _interopRequireDefault(require("./useThrottle"));
54
60
 
61
+ var _useValidWindowDimensions = _interopRequireDefault(require("./useValidWindowDimensions"));
62
+
55
63
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
56
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA","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';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","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"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useValidWindowDimensions;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ function useValidWindowDimensions() {
13
+ const window = (0, _reactNative.useWindowDimensions)();
14
+ const [validWindow, setValidWindow] = (0, _react.useState)(window);
15
+ (0, _react.useEffect)(() => {
16
+ if (window.width !== 0 && window.height !== 0) {
17
+ setValidWindow(window);
18
+ }
19
+ }, [window]);
20
+ return validWindow;
21
+ }
22
+ //# sourceMappingURL=index.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ios.ts"],"names":["useValidWindowDimensions","window","validWindow","setValidWindow","width","height"],"mappings":";;;;;;;AAAA;;AACA;;AAEe,SAASA,wBAAT,GAAoC;AAC/C,QAAMC,MAAM,GAAG,uCAAf;AACA,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgC,qBAASF,MAAT,CAAtC;AAEA,wBAAU,MAAM;AACZ,QAAIA,MAAM,CAACG,KAAP,KAAiB,CAAjB,IAAsBH,MAAM,CAACI,MAAP,KAAkB,CAA5C,EAA+C;AAC3CF,MAAAA,cAAc,CAACF,MAAD,CAAd;AACH;AACJ,GAJD,EAIG,CAACA,MAAD,CAJH;AAMA,SAAOC,WAAP;AACH","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useWindowDimensions } from 'react-native';\n\nexport default function useValidWindowDimensions() {\n const window = useWindowDimensions();\n const [validWindow, setValidWindow] = useState(window);\n\n useEffect(() => {\n if (window.width !== 0 && window.height !== 0) {\n setValidWindow(window);\n }\n }, [window]);\n\n return validWindow;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ var _default = _reactNative.useWindowDimensions;
11
+ exports.default = _default;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["useWindowDimensions"],"mappings":";;;;;;;AAAA;;eAEeA,gC","sourcesContent":["import { useWindowDimensions } from 'react-native';\n\nexport default useWindowDimensions;\n"]}
@@ -36,7 +36,7 @@ export default function IconButton(props) {
36
36
  });
37
37
  const fontStyle = createFontStyle(theme, {
38
38
  selector: typo => typo.caption1,
39
- color: theme.palette['text'].hint
39
+ color: theme.palette[color].main
40
40
  });
41
41
  const labelStyle = css([fontStyle]);
42
42
  const rootStyle = css([styles.root, style]);
@@ -1 +1 @@
1
- {"version":3,"sources":["IconButton.tsx"],"names":["React","Text","ButtonBase","cloneSvgIcon","createFontStyle","css","useTheme","useStyles","theme","root","flexDirection","justifyContent","alignItems","padding","spacing","IconButton","props","children","color","disabled","label","onPress","size","style","otherProps","styles","icon","palette","main","fontStyle","selector","typo","caption1","hint","labelStyle","rootStyle","handlePress"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,YAAT,EAAuBC,eAAvB,EAAwCC,GAAxC,EAA6CC,QAA7C,QAA6D,WAA7D;;AAKA,MAAMC,SAAsC,GAAG,YAA8B;AACzE,QAAMC,KAAK,GAAGF,QAAQ,EAAtB;AAEA,SAAO;AACHG,IAAAA,IAAI,EAAE;AACFC,MAAAA,aAAa,EAAE,QADb;AAEFC,MAAAA,cAAc,EAAE,QAFd;AAGFC,MAAAA,UAAU,EAAE,QAHV;AAIFC,MAAAA,OAAO,EAAEL,KAAK,CAACM,OAAN,CAAc,CAAd;AAJP;AADH,GAAP;AAQH,CAXD;;AAaA,eAAe,SAASC,UAAT,CAAoBC,KAApB,EAA4C;AACvD,QAAM;AACFC,IAAAA,QADE;AAEFC,IAAAA,KAAK,GAAG,SAFN;AAGFC,IAAAA,QAAQ,GAAG,KAHT;AAIFC,IAAAA,KAJE;AAKFC,IAAAA,OALE;AAMFC,IAAAA,IAAI,GAAG,QANL;AAOFC,IAAAA,KAPE;AAQF,OAAGC;AARD,MASFR,KATJ;AAWA,QAAMR,KAAK,GAAGF,QAAQ,EAAtB;AACA,QAAMmB,MAAM,GAAGlB,SAAS,EAAxB;AAEA,QAAMmB,IAAI,GAAGvB,YAAY,CAACc,QAAD,EAAW;AAChCC,IAAAA,KAAK,EAAEV,KAAK,CAACmB,OAAN,CAAcT,KAAd,EAAqBU,IADI;AAEhCN,IAAAA;AAFgC,GAAX,CAAzB;AAKA,QAAMO,SAAS,GAAGzB,eAAe,CAACI,KAAD,EAAQ;AACrCsB,IAAAA,QAAQ,EAAGC,IAAD,IAAUA,IAAI,CAACC,QADY;AAErCd,IAAAA,KAAK,EAAEV,KAAK,CAACmB,OAAN,CAAc,MAAd,EAAsBM;AAFQ,GAAR,CAAjC;AAKA,QAAMC,UAAU,GAAG7B,GAAG,CAAC,CACnBwB,SADmB,CAAD,CAAtB;AAIA,QAAMM,SAAS,GAAG9B,GAAG,CAAC,CAClBoB,MAAM,CAAChB,IADW,EAElBc,KAFkB,CAAD,CAArB;;AAKA,QAAMa,WAAW,GAAG,YAAY;AAC5B,QAAIjB,QAAJ,EAAc;AACV;AACH;;AACD,QAAIE,OAAJ,EAAa;AACTA,MAAAA,OAAO;AACP;AACH;AACJ,GARD;;AAUA,sBACI,oBAAC,UAAD;AACI,IAAA,QAAQ,EAAEF,QADd;AAEI,IAAA,OAAO,EAAEiB,WAFb;AAGI,IAAA,KAAK,EAAED;AAHX,KAIQX,UAJR,GAMKE,IANL,EAQKN,KAAK,gBACF,oBAAC,IAAD;AACI,IAAA,QAAQ,EAAEA,KADd;AAEI,IAAA,KAAK,EAAEc;AAFX,IADE,GAKF,IAbR,CADJ;AAiBH;AAAA","sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ButtonBase from '../ButtonBase';\nimport { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';\nimport type IconButtonProps from './IconButtonProps';\n\ntype IconButtonStyles = NamedStylesStringUnion<'root'>;\n\nconst useStyles: UseStyles<IconButtonStyles> = function (): IconButtonStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'center',\n padding: theme.spacing(1),\n },\n };\n};\n\nexport default function IconButton(props: IconButtonProps) {\n const {\n children,\n color = 'primary',\n disabled = false,\n label,\n onPress,\n size = 'medium',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n const styles = useStyles();\n\n const icon = cloneSvgIcon(children, {\n color: theme.palette[color].main,\n size,\n });\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption1,\n color: theme.palette['text'].hint,\n });\n\n const labelStyle = css([\n fontStyle,\n ]);\n\n const rootStyle = css([\n styles.root,\n style,\n ]);\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={rootStyle}\n {...otherProps}\n >\n {icon}\n\n {label ? (\n <Text\n children={label}\n style={labelStyle}\n />\n ) : null}\n </ButtonBase>\n );\n};\n"]}
1
+ {"version":3,"sources":["IconButton.tsx"],"names":["React","Text","ButtonBase","cloneSvgIcon","createFontStyle","css","useTheme","useStyles","theme","root","flexDirection","justifyContent","alignItems","padding","spacing","IconButton","props","children","color","disabled","label","onPress","size","style","otherProps","styles","icon","palette","main","fontStyle","selector","typo","caption1","labelStyle","rootStyle","handlePress"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,YAAT,EAAuBC,eAAvB,EAAwCC,GAAxC,EAA6CC,QAA7C,QAA6D,WAA7D;;AAKA,MAAMC,SAAsC,GAAG,YAA8B;AACzE,QAAMC,KAAK,GAAGF,QAAQ,EAAtB;AAEA,SAAO;AACHG,IAAAA,IAAI,EAAE;AACFC,MAAAA,aAAa,EAAE,QADb;AAEFC,MAAAA,cAAc,EAAE,QAFd;AAGFC,MAAAA,UAAU,EAAE,QAHV;AAIFC,MAAAA,OAAO,EAAEL,KAAK,CAACM,OAAN,CAAc,CAAd;AAJP;AADH,GAAP;AAQH,CAXD;;AAaA,eAAe,SAASC,UAA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,IAbR,CADJ;AAiBH;AAAA","sourcesContent":["import React from 'react';\nimport { Text } from 'react-native';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport ButtonBase from '../ButtonBase';\nimport { cloneSvgIcon, createFontStyle, css, useTheme } from '../styles';\nimport type IconButtonProps from './IconButtonProps';\n\ntype IconButtonStyles = NamedStylesStringUnion<'root'>;\n\nconst useStyles: UseStyles<IconButtonStyles> = function (): IconButtonStyles {\n const theme = useTheme();\n\n return {\n root: {\n flexDirection: 'column',\n justifyContent: 'center',\n alignItems: 'center',\n padding: theme.spacing(1),\n },\n };\n};\n\nexport default function IconButton(props: IconButtonProps) {\n const {\n children,\n color = 'primary',\n disabled = false,\n label,\n onPress,\n size = 'medium',\n style,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n const styles = useStyles();\n\n const icon = cloneSvgIcon(children, {\n color: theme.palette[color].main,\n size,\n });\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption1,\n color: theme.palette[color].main,\n });\n\n const labelStyle = css([\n fontStyle,\n ]);\n\n const rootStyle = css([\n styles.root,\n style,\n ]);\n\n const handlePress = async () => {\n if (disabled) {\n return;\n }\n if (onPress) {\n onPress();\n return;\n }\n };\n\n return (\n <ButtonBase\n disabled={disabled}\n onPress={handlePress}\n style={rootStyle}\n {...otherProps}\n >\n {icon}\n\n {label ? (\n <Text\n children={label}\n style={labelStyle}\n />\n ) : null}\n </ButtonBase>\n );\n};\n"]}
@@ -30,6 +30,8 @@ export default function Tabs(props) {
30
30
  children,
31
31
  index: indexProp,
32
32
  disableIndicator = false,
33
+ keyboardDismissMode = 'none',
34
+ keyboardShouldPersistTaps = 'never',
33
35
  onChange,
34
36
  scrollable = false,
35
37
  scrollValue: scrollValueProp,
@@ -87,6 +89,12 @@ export default function Tabs(props) {
87
89
  }, ...prev.slice(index + 1)]);
88
90
  };
89
91
 
92
+ const onMouseDown = e => {
93
+ if (keyboardShouldPersistTaps === 'always') {
94
+ e.preventDefault();
95
+ }
96
+ };
97
+
90
98
  const onPress = () => {
91
99
  var _child$props$onPress, _child$props;
92
100
 
@@ -102,6 +110,7 @@ export default function Tabs(props) {
102
110
  enableIndicator: enableIndicatorPlaceholder,
103
111
  onLayout,
104
112
  onPress,
113
+ onMouseDown,
105
114
  variant,
106
115
  selected,
107
116
  style: scrollable ? undefined : styles.fixedTab
@@ -125,7 +134,9 @@ export default function Tabs(props) {
125
134
  ref: scrollViewRef,
126
135
  scrollsToTop: false,
127
136
  showsHorizontalScrollIndicator: false,
128
- showsVerticalScrollIndicator: false
137
+ showsVerticalScrollIndicator: false,
138
+ keyboardDismissMode: keyboardDismissMode,
139
+ keyboardShouldPersistTaps: keyboardShouldPersistTaps
129
140
  }, tabElements, indicator) : /*#__PURE__*/React.createElement(React.Fragment, null, tabElements, indicator));
130
141
  }
131
142
  ;
@@ -1 +1 @@
1
- {"version":3,"sources":["Tabs.tsx"],"names":["React","ScrollView","View","Animated","Easing","isEveryDefined","css","useTheme","useWidth","defaultCoordinate","TabIndicator","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","children","index","indexProp","disableIndicator","onChange","scrollable","scrollValue","scrollValueProp","style","variant","otherProps","styles","containerWidth","handleLayout","scrollViewRef","useRef","tabCount","Children","count","coordinates","setCoordinates","useState","Array","internalScrollValue","useSharedValue","isReadyToRenderIndicator","useEffect","animateTab","value","withTiming","duration","easing","out","exp","undefined","snapTab","scrollView","current","coordinate","tabWidth","x2","x1","x","scrollTo","y","animated","tabElements","map","child","onLayout","event","width","nativeEvent","layout","prev","slice","onPress","selected","enableIndicatorPlaceholder","cloneElement","enableIndicator","indicator"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAA4BC,UAA5B,EAAwCC,IAAxC,QAAoD,cAApD;AACA,OAAOC,QAAP,IAAmBC,MAAnB,QAAiC,yBAAjC;AAEA,SAASC,cAAT,QAA+B,oBAA/B;AACA,S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1B,CAAP;AAQH,GA/BmB,CAApB;AAiCA,QAAMoE,SAAS,gBACX,oBAAC,YAAD;AACI,IAAA,WAAW,EAAE1C,WADjB;AAEI,IAAA,QAAQ,EAAEhB,gBAFd;AAGI,IAAA,UAAU,EAAEE,UAHhB;AAII,IAAA,WAAW,EAAEC;AAJjB,IADJ;AASA,sBACI,oBAAC,IAAD;AACI,IAAA,QAAQ,EAAEO,YADd;AAEI,IAAA,KAAK,EAAE9B,GAAG,CAAC,CACP4B,MAAM,CAACrB,IADA,EAEPe,UAAU,GAAG6B,SAAH,GAAevB,MAAM,CAACpB,SAFzB,EAGPiB,KAHO,CAAD;AAFd,KAOQE,UAPR,GASKL,UAAU,gBACP,oBAAC,UAAD;AACI,IAAA,gCAAgC,EAAE,KADtC;AAEI,IAAA,OAAO,EAAE,KAFb;AAGI,IAAA,qBAAqB,EAAEM,MAAM,CAAChB,mBAHlC;AAII,IAAA,sBAAsB,EAAE,IAJ5B;AAKI,IAAA,UAAU,EAAE,IALhB;AAMI,IAAA,GAAG,EAAEmB,aANT;AAOI,IAAA,YAAY,EAAE,KAPlB;AAQI,IAAA,8BAA8B,EAAE,KARpC;AASI,IAAA,4BAA4B,EAAE;AATlC,KAWKgC,WAXL,EAYKe,SAZL,CADO,gBAgBP,0CACKf,WADL,EAEKe,SAFL,CAzBR,CADJ;AAiCH;AAAA","sourcesContent":["import React from 'react';\nimport { LayoutChangeEvent, ScrollView, View } from 'react-native';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport { css, useTheme } from '../styles';\nimport { useWidth } from '../internal/hooks';\nimport type TabsProps from './TabsProps';\nimport TabCoordinate, { defaultCoordinate } from './TabCoordinate';\nimport TabIndicator from './TabIndicator';\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\nexport default function Tabs(props: TabsProps) {\n const {\n children,\n index: indexProp,\n disableIndicator = false,\n onChange,\n scrollable = false,\n scrollValue: scrollValueProp,\n style,\n variant = 'primary',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const [containerWidth, handleLayout] = useWidth();\n\n const scrollViewRef = React.useRef<ScrollView | null>(null);\n\n const tabCount = React.Children.count(children);\n const [coordinates, setCoordinates] = React.useState<TabCoordinate[]>(() => new Array(tabCount));\n\n const internalScrollValue = Animated.useSharedValue(0);\n const scrollValue = scrollValueProp || internalScrollValue;\n\n const isReadyToRenderIndicator = isEveryDefined(coordinates);\n\n React.useEffect(() => {\n const animateTab = (index: number) => {\n internalScrollValue.value = Animated.withTiming(index, {\n duration: 200,\n easing: Easing.out(Easing.exp),\n });\n };\n\n if (scrollValueProp === undefined) {\n animateTab(indexProp);\n }\n }, [indexProp, scrollValueProp, internalScrollValue]);\n\n React.useEffect(() => {\n const snapTab = (index: number) => {\n const scrollView = scrollViewRef.current;\n const coordinate: TabCoordinate = coordinates[index - 1] || defaultCoordinate;\n\n if (scrollView) {\n const tabWidth = coordinate.x2 - coordinate.x1;\n const x = coordinate.x1 + tabWidth / 2;\n\n scrollView.scrollTo({ x, y: 0, animated: true });\n }\n };\n\n snapTab(indexProp);\n }, [indexProp, containerWidth, coordinates]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n setCoordinates(prev => ([\n ...prev.slice(0, index),\n { x1: x, x2: x + width },\n ...prev.slice(index + 1),\n ]));\n };\n\n const onPress = () => {\n onChange?.(index);\n // @ts-ignore\n child.props.onPress?.();\n };\n\n const selected = index === indexProp;\n const enableIndicatorPlaceholder = disableIndicator\n ? false\n : (isReadyToRenderIndicator ? false : selected);\n\n //@ts-ignore\n return React.cloneElement(child, {\n enableIndicator: enableIndicatorPlaceholder,\n onLayout,\n onPress,\n variant,\n selected,\n style: scrollable ? undefined : styles.fixedTab,\n });\n });\n\n const indicator = (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n scrollable={scrollable}\n scrollValue={scrollValue}\n />\n );\n\n return (\n <View\n onLayout={handleLayout}\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n {...otherProps}\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 >\n {tabElements}\n {indicator}\n </ScrollView>\n ) : (\n <>\n {tabElements}\n {indicator}\n </>\n )}\n </View>\n );\n};\n"]}
1
+ {"version":3,"sources":["Tabs.tsx"],"names":["React","ScrollView","View","Animated","Easing","isEveryDefined","css","useTheme","useWidth","defaultCoordinate","TabIndicator","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","children","index","indexProp","disableIndicator","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollValue","scrollValueProp","style","variant","otherProps","styles","containerWidth","handleLayout","scrollViewRef","useRef","tabCount","Children","count","coordinates","setCoordinates","useState","Array","internalScrollValue","useSharedValue","isReadyToRenderIndicator","useEffect","animateTab","value","withTiming","duration","easing","out","exp","undefined","snapTab","scrollView","current","coordinate","tabWidth","x2","x1","x","scrollTo","y","animated","tabElements","map","child","onLayout","event","width","nativeEvent","layout","prev","slice","onMouseDown","e","preventDefault","onPress","selected","enableIndicatorPlaceholder","cloneElement","enableIndicator","indicator"],"mappings":";;AAAA,O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aK2C,WAbL,EAcKkB,SAdL,CADO,gBAkBP,0CACKlB,WADL,EAEKkB,SAFL,CA3BR,CADJ;AAmCH;AAAA","sourcesContent":["import React from 'react';\nimport { GestureResponderEvent, LayoutChangeEvent, ScrollView, View } from 'react-native';\nimport Animated, { Easing } from 'react-native-reanimated';\nimport { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';\nimport { isEveryDefined } from '@fountain-ui/utils';\nimport { css, useTheme } from '../styles';\nimport { useWidth } from '../internal/hooks';\nimport type TabsProps from './TabsProps';\nimport TabCoordinate, { defaultCoordinate } from './TabCoordinate';\nimport TabIndicator from './TabIndicator';\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\nexport default function Tabs(props: TabsProps) {\n const {\n children,\n index: indexProp,\n disableIndicator = false,\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollValue: scrollValueProp,\n style,\n variant = 'primary',\n ...otherProps\n } = props;\n\n const styles = useStyles();\n\n const [containerWidth, handleLayout] = useWidth();\n\n const scrollViewRef = React.useRef<ScrollView | null>(null);\n\n const tabCount = React.Children.count(children);\n const [coordinates, setCoordinates] = React.useState<TabCoordinate[]>(() => new Array(tabCount));\n\n const internalScrollValue = Animated.useSharedValue(0);\n const scrollValue = scrollValueProp || internalScrollValue;\n\n const isReadyToRenderIndicator = isEveryDefined(coordinates);\n\n React.useEffect(() => {\n const animateTab = (index: number) => {\n internalScrollValue.value = Animated.withTiming(index, {\n duration: 200,\n easing: Easing.out(Easing.exp),\n });\n };\n\n if (scrollValueProp === undefined) {\n animateTab(indexProp);\n }\n }, [indexProp, scrollValueProp, internalScrollValue]);\n\n React.useEffect(() => {\n const snapTab = (index: number) => {\n const scrollView = scrollViewRef.current;\n const coordinate: TabCoordinate = coordinates[index - 1] || defaultCoordinate;\n\n if (scrollView) {\n const tabWidth = coordinate.x2 - coordinate.x1;\n const x = coordinate.x1 + tabWidth / 2;\n\n scrollView.scrollTo({ x, y: 0, animated: true });\n }\n };\n\n snapTab(indexProp);\n }, [indexProp, containerWidth, coordinates]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n setCoordinates(prev => ([\n ...prev.slice(0, index),\n { x1: x, x2: x + width },\n ...prev.slice(index + 1),\n ]));\n };\n\n const onMouseDown = (e: GestureResponderEvent) => {\n if (keyboardShouldPersistTaps === 'always') {\n e.preventDefault();\n }\n };\n\n const onPress = () => {\n onChange?.(index);\n // @ts-ignore\n child.props.onPress?.();\n };\n\n const selected = index === indexProp;\n const enableIndicatorPlaceholder = disableIndicator\n ? false\n : (isReadyToRenderIndicator ? false : selected);\n\n //@ts-ignore\n return React.cloneElement(child, {\n enableIndicator: enableIndicatorPlaceholder,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n selected,\n style: scrollable ? undefined : styles.fixedTab,\n });\n });\n\n const indicator = (\n <TabIndicator\n coordinates={coordinates}\n disabled={disableIndicator}\n scrollable={scrollable}\n scrollValue={scrollValue}\n />\n );\n\n return (\n <View\n onLayout={handleLayout}\n style={css([\n styles.root,\n scrollable ? undefined : styles.fixedRoot,\n style,\n ])}\n {...otherProps}\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 {indicator}\n </ScrollView>\n ) : (\n <>\n {tabElements}\n {indicator}\n </>\n )}\n </View>\n );\n};\n"]}
@@ -4,4 +4,5 @@ export { default as useContentContainerStyle } from './useContentContainerStyle'
4
4
  export { default as useElevationStyle } from './useElevationStyle';
5
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
6
6
  export { default as useThrottle } from './useThrottle';
7
+ export { default as useValidWindowDimensions } from './useValidWindowDimensions';
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["default","useBreakpointUp","useCollapsibleAppBar","useContentContainerStyle","useElevationStyle","useFadeInAppBar","useThrottle"],"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","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';\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["default","useBreakpointUp","useCollapsibleAppBar","useContentContainerStyle","useElevationStyle","useFadeInAppBar","useThrottle","useValidWindowDimensions"],"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","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"]}
@@ -0,0 +1,13 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+ export default function useValidWindowDimensions() {
4
+ const window = useWindowDimensions();
5
+ const [validWindow, setValidWindow] = useState(window);
6
+ useEffect(() => {
7
+ if (window.width !== 0 && window.height !== 0) {
8
+ setValidWindow(window);
9
+ }
10
+ }, [window]);
11
+ return validWindow;
12
+ }
13
+ //# sourceMappingURL=index.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ios.ts"],"names":["useState","useEffect","useWindowDimensions","useValidWindowDimensions","window","validWindow","setValidWindow","width","height"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,mBAAT,QAAoC,cAApC;AAEA,eAAe,SAASC,wBAAT,GAAoC;AAC/C,QAAMC,MAAM,GAAGF,mBAAmB,EAAlC;AACA,QAAM,CAACG,WAAD,EAAcC,cAAd,IAAgCN,QAAQ,CAACI,MAAD,CAA9C;AAEAH,EAAAA,SAAS,CAAC,MAAM;AACZ,QAAIG,MAAM,CAACG,KAAP,KAAiB,CAAjB,IAAsBH,MAAM,CAACI,MAAP,KAAkB,CAA5C,EAA+C;AAC3CF,MAAAA,cAAc,CAACF,MAAD,CAAd;AACH;AACJ,GAJQ,EAIN,CAACA,MAAD,CAJM,CAAT;AAMA,SAAOC,WAAP;AACH","sourcesContent":["import { useState, useEffect } from 'react';\nimport { useWindowDimensions } from 'react-native';\n\nexport default function useValidWindowDimensions() {\n const window = useWindowDimensions();\n const [validWindow, setValidWindow] = useState(window);\n\n useEffect(() => {\n if (window.width !== 0 && window.height !== 0) {\n setValidWindow(window);\n }\n }, [window]);\n\n return validWindow;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { useWindowDimensions } from 'react-native';
2
+ export default useWindowDimensions;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["useWindowDimensions"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,cAApC;AAEA,eAAeA,mBAAf","sourcesContent":["import { useWindowDimensions } from 'react-native';\n\nexport default useWindowDimensions;\n"]}
@@ -3,6 +3,8 @@ import type { ViewProps } from 'react-native';
3
3
  import Animated from 'react-native-reanimated';
4
4
  import type { TabVariant } from '../Tab';
5
5
  import type { OverridableComponentProps } from '../types';
6
+ export declare type KeyboardDismissMode = 'none' | 'on-drag' | 'interactive';
7
+ export declare type KeyboardShouldPersistTaps = 'never' | boolean | 'always' | 'handled';
6
8
  export default interface TabsProps extends OverridableComponentProps<ViewProps, {
7
9
  /**
8
10
  * Collection of Tab components.
@@ -17,6 +19,16 @@ export default interface TabsProps extends OverridableComponentProps<ViewProps,
17
19
  * @default false
18
20
  */
19
21
  disableIndicator?: boolean;
22
+ /**
23
+ * keyboard dismissing condition of dragging.
24
+ * @default 'none'
25
+ */
26
+ keyboardDismissMode?: KeyboardDismissMode;
27
+ /**
28
+ * keyboard persisting condition of tapping.
29
+ * @default 'never'
30
+ */
31
+ keyboardShouldPersistTaps?: KeyboardShouldPersistTaps;
20
32
  /**
21
33
  * Callback fired when a tab is selected.
22
34
  */
@@ -4,3 +4,4 @@ export { default as useContentContainerStyle } from './useContentContainerStyle'
4
4
  export { default as useElevationStyle } from './useElevationStyle';
5
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
6
6
  export { default as useThrottle } from './useThrottle';
7
+ export { default as useValidWindowDimensions } from './useValidWindowDimensions';
@@ -0,0 +1,2 @@
1
+ import { useWindowDimensions } from 'react-native';
2
+ export default useWindowDimensions;
@@ -0,0 +1 @@
1
+ export default function useValidWindowDimensions(): import("react-native").ScaledSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "1.14.1",
3
+ "version": "1.16.0",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "db43f98577b3009518570d7b9b3df42f4fe16a51"
70
+ "gitHead": "0738cec018c008c9993b8d432ca8aaa44d7c3f77"
71
71
  }
@@ -42,7 +42,7 @@ export default function IconButton(props: IconButtonProps) {
42
42
 
43
43
  const fontStyle = createFontStyle(theme, {
44
44
  selector: (typo) => typo.caption1,
45
- color: theme.palette['text'].hint,
45
+ color: theme.palette[color].main,
46
46
  });
47
47
 
48
48
  const labelStyle = css([
package/src/Tabs/Tabs.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { LayoutChangeEvent, ScrollView, View } from 'react-native';
2
+ import { GestureResponderEvent, LayoutChangeEvent, ScrollView, View } from 'react-native';
3
3
  import Animated, { Easing } from 'react-native-reanimated';
4
4
  import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
5
5
  import { isEveryDefined } from '@fountain-ui/utils';
@@ -39,6 +39,8 @@ export default function Tabs(props: TabsProps) {
39
39
  children,
40
40
  index: indexProp,
41
41
  disableIndicator = false,
42
+ keyboardDismissMode = 'none',
43
+ keyboardShouldPersistTaps = 'never',
42
44
  onChange,
43
45
  scrollable = false,
44
46
  scrollValue: scrollValueProp,
@@ -101,6 +103,12 @@ export default function Tabs(props: TabsProps) {
101
103
  ]));
102
104
  };
103
105
 
106
+ const onMouseDown = (e: GestureResponderEvent) => {
107
+ if (keyboardShouldPersistTaps === 'always') {
108
+ e.preventDefault();
109
+ }
110
+ };
111
+
104
112
  const onPress = () => {
105
113
  onChange?.(index);
106
114
  // @ts-ignore
@@ -117,6 +125,7 @@ export default function Tabs(props: TabsProps) {
117
125
  enableIndicator: enableIndicatorPlaceholder,
118
126
  onLayout,
119
127
  onPress,
128
+ onMouseDown,
120
129
  variant,
121
130
  selected,
122
131
  style: scrollable ? undefined : styles.fixedTab,
@@ -153,6 +162,8 @@ export default function Tabs(props: TabsProps) {
153
162
  scrollsToTop={false}
154
163
  showsHorizontalScrollIndicator={false}
155
164
  showsVerticalScrollIndicator={false}
165
+ keyboardDismissMode={keyboardDismissMode}
166
+ keyboardShouldPersistTaps={keyboardShouldPersistTaps}
156
167
  >
157
168
  {tabElements}
158
169
  {indicator}
@@ -4,6 +4,17 @@ import Animated from 'react-native-reanimated';
4
4
  import type { TabVariant } from '../Tab';
5
5
  import type { OverridableComponentProps } from '../types';
6
6
 
7
+ export type KeyboardDismissMode =
8
+ 'none'
9
+ | 'on-drag'
10
+ | 'interactive'; // ios only
11
+
12
+ export type KeyboardShouldPersistTaps =
13
+ 'never'
14
+ | boolean
15
+ | 'always'
16
+ | 'handled'; // app only
17
+
7
18
  export default interface TabsProps extends OverridableComponentProps<ViewProps, {
8
19
  /**
9
20
  * Collection of Tab components.
@@ -21,6 +32,18 @@ export default interface TabsProps extends OverridableComponentProps<ViewProps,
21
32
  */
22
33
  disableIndicator?: boolean;
23
34
 
35
+ /**
36
+ * keyboard dismissing condition of dragging.
37
+ * @default 'none'
38
+ */
39
+ keyboardDismissMode?: KeyboardDismissMode,
40
+
41
+ /**
42
+ * keyboard persisting condition of tapping.
43
+ * @default 'never'
44
+ */
45
+ keyboardShouldPersistTaps?: KeyboardShouldPersistTaps,
46
+
24
47
  /**
25
48
  * Callback fired when a tab is selected.
26
49
  */
@@ -4,3 +4,4 @@ export { default as useContentContainerStyle } from './useContentContainerStyle'
4
4
  export { default as useElevationStyle } from './useElevationStyle';
5
5
  export { default as useFadeInAppBar } from './useFadeInAppBar';
6
6
  export { default as useThrottle } from './useThrottle';
7
+ export { default as useValidWindowDimensions } from './useValidWindowDimensions';
@@ -0,0 +1,15 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useWindowDimensions } from 'react-native';
3
+
4
+ export default function useValidWindowDimensions() {
5
+ const window = useWindowDimensions();
6
+ const [validWindow, setValidWindow] = useState(window);
7
+
8
+ useEffect(() => {
9
+ if (window.width !== 0 && window.height !== 0) {
10
+ setValidWindow(window);
11
+ }
12
+ }, [window]);
13
+
14
+ return validWindow;
15
+ }
@@ -0,0 +1,3 @@
1
+ import { useWindowDimensions } from 'react-native';
2
+
3
+ export default useWindowDimensions;