@fountain-ui/core 2.0.0-beta.81 → 2.0.0-beta.83
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.
- package/build/commonjs/Accordion/Accordion.js +14 -18
- package/build/commonjs/Accordion/Accordion.js.map +1 -1
- package/build/commonjs/Dialog/Dialog.js +59 -31
- package/build/commonjs/Dialog/Dialog.js.map +1 -1
- package/build/commonjs/Dialog/DialogProps.js.map +1 -1
- package/build/commonjs/Modal/AnimatedContainer/index.js +153 -0
- package/build/commonjs/Modal/AnimatedContainer/index.js.map +1 -0
- package/build/commonjs/Modal/Modal.js +41 -15
- package/build/commonjs/Modal/Modal.js.map +1 -1
- package/build/commonjs/Modal/ModalProps.js +12 -0
- package/build/commonjs/Modal/ModalProps.js.map +1 -1
- package/build/commonjs/Modal/index.js +8 -0
- package/build/commonjs/Modal/index.js.map +1 -1
- package/build/commonjs/Tab/Tab.js +1 -0
- package/build/commonjs/Tab/Tab.js.map +1 -1
- package/build/commonjs/Tabs/Tabs.js +2 -1
- package/build/commonjs/Tabs/Tabs.js.map +1 -1
- package/build/commonjs/Tabs/TabsProps.js.map +1 -1
- package/build/module/Accordion/Accordion.js +14 -18
- package/build/module/Accordion/Accordion.js.map +1 -1
- package/build/module/Dialog/Dialog.js +61 -31
- package/build/module/Dialog/Dialog.js.map +1 -1
- package/build/module/Dialog/DialogProps.js.map +1 -1
- package/build/module/Modal/AnimatedContainer/index.js +131 -0
- package/build/module/Modal/AnimatedContainer/index.js.map +1 -0
- package/build/module/Modal/Modal.js +41 -14
- package/build/module/Modal/Modal.js.map +1 -1
- package/build/module/Modal/ModalProps.js +5 -0
- package/build/module/Modal/ModalProps.js.map +1 -1
- package/build/module/Modal/index.js +1 -0
- package/build/module/Modal/index.js.map +1 -1
- package/build/module/Tab/Tab.js +1 -0
- package/build/module/Tab/Tab.js.map +1 -1
- package/build/module/Tabs/Tabs.js +2 -1
- package/build/module/Tabs/Tabs.js.map +1 -1
- package/build/module/Tabs/TabsProps.js.map +1 -1
- package/build/typescript/Dialog/DialogProps.d.ts +6 -0
- package/build/typescript/Modal/AnimatedContainer/index.d.ts +5 -0
- package/build/typescript/Modal/ModalProps.d.ts +41 -8
- package/build/typescript/Modal/index.d.ts +2 -1
- package/build/typescript/Tabs/Tabs.d.ts +1 -1
- package/build/typescript/Tabs/TabsProps.d.ts +5 -0
- package/package.json +2 -2
- package/src/Accordion/Accordion.tsx +13 -14
- package/src/Dialog/Dialog.tsx +70 -32
- package/src/Dialog/DialogProps.ts +7 -0
- package/src/Modal/AnimatedContainer/index.tsx +156 -0
- package/src/Modal/Modal.tsx +42 -18
- package/src/Modal/ModalProps.ts +51 -10
- package/src/Modal/index.ts +2 -1
- package/src/Tab/Tab.tsx +1 -0
- package/src/Tabs/Tabs.tsx +5 -1
- package/src/Tabs/TabsProps.ts +6 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React, { useCallback, useEffect } from 'react';
|
|
2
|
+
import { Animated, Easing, Platform, useWindowDimensions } from 'react-native';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
import { useAnimatedValue } from '../../hooks';
|
|
5
|
+
import { isNotAndroid12 } from '../../utils';
|
|
6
|
+
import { ANIMATION_TYPE } from '../ModalProps';
|
|
7
|
+
const DEFAULT_ANIMATION_CONFIG = {
|
|
8
|
+
duration: 300,
|
|
9
|
+
useNativeDriver: isNotAndroid12
|
|
10
|
+
};
|
|
11
|
+
export default function AnimatedContainer(props) {
|
|
12
|
+
const {
|
|
13
|
+
children,
|
|
14
|
+
closeAnimation,
|
|
15
|
+
initialOpacity,
|
|
16
|
+
initialTranslateY,
|
|
17
|
+
onEnter,
|
|
18
|
+
onEntered,
|
|
19
|
+
onExit,
|
|
20
|
+
onExited,
|
|
21
|
+
openAnimation,
|
|
22
|
+
style,
|
|
23
|
+
visible
|
|
24
|
+
} = props;
|
|
25
|
+
const {
|
|
26
|
+
height: screenHeight
|
|
27
|
+
} = useWindowDimensions();
|
|
28
|
+
const opacity = useAnimatedValue(initialOpacity ?? 0);
|
|
29
|
+
const translateY = useAnimatedValue(initialTranslateY ?? screenHeight);
|
|
30
|
+
const convertToCompositeAnimation = useCallback(animationUnit => {
|
|
31
|
+
const {
|
|
32
|
+
type,
|
|
33
|
+
...others
|
|
34
|
+
} = animationUnit;
|
|
35
|
+
|
|
36
|
+
switch (type) {
|
|
37
|
+
case ANIMATION_TYPE.FADE:
|
|
38
|
+
return Animated.timing(opacity, { ...others,
|
|
39
|
+
useNativeDriver: isNotAndroid12
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
case ANIMATION_TYPE.SLIDE:
|
|
43
|
+
default:
|
|
44
|
+
const easing = others.toValue === screenHeight ? Easing.in(Easing.ease) : Platform.OS === 'web' ? Easing.bezier(0.16, 1, 0.3, 1) : Easing.out(Easing.exp);
|
|
45
|
+
return Animated.timing(translateY, { ...others,
|
|
46
|
+
easing,
|
|
47
|
+
useNativeDriver: isNotAndroid12
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, [screenHeight]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (visible) {
|
|
53
|
+
onEnter === null || onEnter === void 0 ? void 0 : onEnter();
|
|
54
|
+
|
|
55
|
+
if (R.isNil(openAnimation)) {
|
|
56
|
+
opacity.setValue(1);
|
|
57
|
+
Animated.timing(translateY, { ...DEFAULT_ANIMATION_CONFIG,
|
|
58
|
+
easing: Platform.OS === 'web' ? Easing.bezier(0.16, 1, 0.3, 1) : Easing.out(Easing.exp),
|
|
59
|
+
toValue: 0
|
|
60
|
+
}).start(_ref => {
|
|
61
|
+
let {
|
|
62
|
+
finished
|
|
63
|
+
} = _ref;
|
|
64
|
+
|
|
65
|
+
if (finished) {
|
|
66
|
+
onEntered === null || onEntered === void 0 ? void 0 : onEntered();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
const convertedAnimation = openAnimation.map(animationUnit => {
|
|
71
|
+
return convertToCompositeAnimation({ ...DEFAULT_ANIMATION_CONFIG,
|
|
72
|
+
...animationUnit
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
Animated.parallel(convertedAnimation).start(_ref2 => {
|
|
76
|
+
let {
|
|
77
|
+
finished
|
|
78
|
+
} = _ref2;
|
|
79
|
+
|
|
80
|
+
if (finished) {
|
|
81
|
+
onEntered === null || onEntered === void 0 ? void 0 : onEntered();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
onExit === null || onExit === void 0 ? void 0 : onExit();
|
|
87
|
+
|
|
88
|
+
if (R.isNil(closeAnimation)) {
|
|
89
|
+
opacity.setValue(1);
|
|
90
|
+
Animated.timing(translateY, { ...DEFAULT_ANIMATION_CONFIG,
|
|
91
|
+
easing: Easing.in(Easing.ease),
|
|
92
|
+
toValue: screenHeight
|
|
93
|
+
}).start(_ref3 => {
|
|
94
|
+
let {
|
|
95
|
+
finished
|
|
96
|
+
} = _ref3;
|
|
97
|
+
|
|
98
|
+
if (finished) {
|
|
99
|
+
onExited === null || onExited === void 0 ? void 0 : onExited();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
const convertedAnimation = closeAnimation.map(animationUnit => {
|
|
104
|
+
return convertToCompositeAnimation({ ...DEFAULT_ANIMATION_CONFIG,
|
|
105
|
+
...animationUnit
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
Animated.parallel(convertedAnimation).start(_ref4 => {
|
|
109
|
+
let {
|
|
110
|
+
finished
|
|
111
|
+
} = _ref4;
|
|
112
|
+
|
|
113
|
+
if (finished) {
|
|
114
|
+
onExited === null || onExited === void 0 ? void 0 : onExited();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}, [convertToCompositeAnimation, visible]);
|
|
120
|
+
const animatedStyle = {
|
|
121
|
+
opacity,
|
|
122
|
+
transform: [{
|
|
123
|
+
translateY
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
127
|
+
pointerEvents: 'box-none',
|
|
128
|
+
style: [animatedStyle, style]
|
|
129
|
+
}, children);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","Animated","Easing","Platform","useWindowDimensions","R","useAnimatedValue","isNotAndroid12","ANIMATION_TYPE","DEFAULT_ANIMATION_CONFIG","duration","useNativeDriver","AnimatedContainer","props","children","closeAnimation","initialOpacity","initialTranslateY","onEnter","onEntered","onExit","onExited","openAnimation","style","visible","height","screenHeight","opacity","translateY","convertToCompositeAnimation","animationUnit","type","others","FADE","timing","SLIDE","easing","toValue","in","ease","OS","bezier","out","exp","isNil","setValue","start","finished","convertedAnimation","map","parallel","animatedStyle","transform"],"sources":["index.tsx"],"sourcesContent":["import React, { useCallback, useEffect } from 'react';\nimport { Animated, Easing, Platform, useWindowDimensions } from 'react-native';\nimport * as R from 'ramda';\nimport { useAnimatedValue } from '../../hooks';\nimport { isNotAndroid12 } from '../../utils';\nimport type ModalProps from '../ModalProps';\nimport { ANIMATION_TYPE, AnimationUnit } from '../ModalProps';\n\ntype AnimatedContainerProps = Pick<ModalProps,\n | 'children'\n | 'closeAnimation'\n | 'initialOpacity'\n | 'initialTranslateY'\n | 'onEnter'\n | 'onEntered'\n | 'onExit'\n | 'onExited'\n | 'openAnimation'\n | 'style'\n | 'visible'>\n\nconst DEFAULT_ANIMATION_CONFIG = {\n duration: 300,\n useNativeDriver: isNotAndroid12,\n};\n\nexport default function AnimatedContainer(props: AnimatedContainerProps) {\n const {\n children,\n closeAnimation,\n initialOpacity,\n initialTranslateY,\n onEnter,\n onEntered,\n onExit,\n onExited,\n openAnimation,\n style,\n visible,\n } = props;\n\n const { height: screenHeight } = useWindowDimensions();\n\n const opacity = useAnimatedValue(initialOpacity ?? 0);\n\n const translateY = useAnimatedValue(initialTranslateY ?? screenHeight);\n\n const convertToCompositeAnimation = useCallback((animationUnit: AnimationUnit) => {\n const {\n type,\n ...others\n } = animationUnit;\n\n switch (type) {\n case ANIMATION_TYPE.FADE:\n return Animated.timing(opacity, {\n ...others,\n useNativeDriver: isNotAndroid12,\n });\n case ANIMATION_TYPE.SLIDE:\n default:\n const easing = others.toValue === screenHeight\n ? Easing.in(Easing.ease)\n : Platform.OS === 'web'\n ? Easing.bezier(0.16, 1, 0.3, 1)\n : Easing.out(Easing.exp);\n\n return Animated.timing(translateY, {\n ...others,\n easing,\n useNativeDriver: isNotAndroid12,\n });\n }\n }, [screenHeight]);\n\n useEffect(() => {\n if (visible) {\n onEnter?.();\n\n if (R.isNil(openAnimation)) {\n opacity.setValue(1);\n\n Animated.timing(translateY, {\n ...DEFAULT_ANIMATION_CONFIG,\n easing: Platform.OS === 'web'\n ? Easing.bezier(0.16, 1, 0.3, 1)\n : Easing.out(Easing.exp),\n toValue: 0,\n }).start(({ finished }) => {\n if (finished) {\n onEntered?.();\n }\n });\n } else {\n const convertedAnimation = openAnimation.map((animationUnit) => {\n return convertToCompositeAnimation({\n ...DEFAULT_ANIMATION_CONFIG,\n ...animationUnit,\n });\n });\n\n Animated.parallel(convertedAnimation).start(({ finished }) => {\n if (finished) {\n onEntered?.();\n }\n });\n }\n } else {\n onExit?.();\n\n if (R.isNil(closeAnimation)) {\n opacity.setValue(1);\n\n Animated.timing(translateY, {\n ...DEFAULT_ANIMATION_CONFIG,\n easing: Easing.in(Easing.ease),\n toValue: screenHeight,\n }).start(({ finished }) => {\n if (finished) {\n onExited?.();\n }\n });\n } else {\n const convertedAnimation = closeAnimation.map((animationUnit) => {\n return convertToCompositeAnimation({\n ...DEFAULT_ANIMATION_CONFIG,\n ...animationUnit,\n });\n });\n\n Animated.parallel(convertedAnimation).start(({ finished }) => {\n if (finished) {\n onExited?.();\n }\n });\n }\n }\n }, [convertToCompositeAnimation, visible]);\n\n const animatedStyle = {\n opacity,\n transform: [{ translateY }],\n };\n\n return (\n <Animated.View\n pointerEvents={'box-none'}\n style={[\n animatedStyle,\n style,\n ]}\n >\n {children}\n </Animated.View>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,QAA8C,OAA9C;AACA,SAASC,QAAT,EAAmBC,MAAnB,EAA2BC,QAA3B,EAAqCC,mBAArC,QAAgE,cAAhE;AACA,OAAO,KAAKC,CAAZ,MAAmB,OAAnB;AACA,SAASC,gBAAT,QAAiC,aAAjC;AACA,SAASC,cAAT,QAA+B,aAA/B;AAEA,SAASC,cAAT,QAA8C,eAA9C;AAeA,MAAMC,wBAAwB,GAAG;EAC7BC,QAAQ,EAAE,GADmB;EAE7BC,eAAe,EAAEJ;AAFY,CAAjC;AAKA,eAAe,SAASK,iBAAT,CAA2BC,KAA3B,EAA0D;EACrE,MAAM;IACFC,QADE;IAEFC,cAFE;IAGFC,cAHE;IAIFC,iBAJE;IAKFC,OALE;IAMFC,SANE;IAOFC,MAPE;IAQFC,QARE;IASFC,aATE;IAUFC,KAVE;IAWFC;EAXE,IAYFX,KAZJ;EAcA,MAAM;IAAEY,MAAM,EAAEC;EAAV,IAA2BtB,mBAAmB,EAApD;EAEA,MAAMuB,OAAO,GAAGrB,gBAAgB,CAACU,cAAc,IAAI,CAAnB,CAAhC;EAEA,MAAMY,UAAU,GAAGtB,gBAAgB,CAACW,iBAAiB,IAAIS,YAAtB,CAAnC;EAEA,MAAMG,2BAA2B,GAAG9B,WAAW,CAAE+B,aAAD,IAAkC;IAC9E,MAAM;MACFC,IADE;MAEF,GAAGC;IAFD,IAGFF,aAHJ;;IAKA,QAAQC,IAAR;MACI,KAAKvB,cAAc,CAACyB,IAApB;QACI,OAAOhC,QAAQ,CAACiC,MAAT,CAAgBP,OAAhB,EAAyB,EAC5B,GAAGK,MADyB;UAE5BrB,eAAe,EAAEJ;QAFW,CAAzB,CAAP;;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AAiB;;UAC1D,IAAIA,QAAJ,EAAc;YACV1B,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ;UACX;QACJ,CAJD;MAKH;IACJ;EACJ,CA9DQ,EA8DN,CAACQ,2BAAD,EAA8BL,OAA9B,CA9DM,CAAT;EAgEA,MAAM2B,aAAa,GAAG;IAClBxB,OADkB;IAElByB,SAAS,EAAE,CAAC;MAAExB;IAAF,CAAD;EAFO,CAAtB;EAKA,oBACI,oBAAC,QAAD,CAAU,IAAV;IACI,aAAa,EAAE,UADnB;IAEI,KAAK,EAAE,CACHuB,aADG,EAEH5B,KAFG;EAFX,GAOKT,QAPL,CADJ;AAWH"}
|
|
@@ -4,10 +4,8 @@ import React from 'react';
|
|
|
4
4
|
import { View } from 'react-native';
|
|
5
5
|
import { css, StyleSheet } from '../styles';
|
|
6
6
|
import { useElevationStyle } from '../hooks';
|
|
7
|
-
import
|
|
7
|
+
import AnimatedContainer from './AnimatedContainer';
|
|
8
8
|
import SimpleBackdrop from './SimpleBackdrop';
|
|
9
|
-
const defaultEnterDuration = 300;
|
|
10
|
-
const defaultExitDuration = 150;
|
|
11
9
|
export const createModalCloseEvent = reason => ({
|
|
12
10
|
metadata: {
|
|
13
11
|
reason
|
|
@@ -18,11 +16,17 @@ export default function Modal(props) {
|
|
|
18
16
|
animationStyle,
|
|
19
17
|
backdropOpacity = 0.5,
|
|
20
18
|
children,
|
|
19
|
+
closeAnimation,
|
|
21
20
|
disableAnimation = false,
|
|
22
|
-
enterDuration = defaultEnterDuration,
|
|
23
|
-
exitDuration = defaultExitDuration,
|
|
24
21
|
hideBackdrop = false,
|
|
22
|
+
initialOpacity,
|
|
23
|
+
initialTranslateY,
|
|
25
24
|
onClose,
|
|
25
|
+
onEnter: onEnterProp,
|
|
26
|
+
onEntered: onEnteredProp,
|
|
27
|
+
onExit: onExitProp,
|
|
28
|
+
onExited: onExitedProp,
|
|
29
|
+
openAnimation,
|
|
26
30
|
style,
|
|
27
31
|
visible,
|
|
28
32
|
...otherProps
|
|
@@ -37,6 +41,24 @@ export default function Modal(props) {
|
|
|
37
41
|
const [exited, setExited] = React.useState(true);
|
|
38
42
|
const elevationStyle = useElevationStyle(6);
|
|
39
43
|
|
|
44
|
+
const onEnter = () => {
|
|
45
|
+
setExited(false);
|
|
46
|
+
onEnterProp === null || onEnterProp === void 0 ? void 0 : onEnterProp();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const onEntered = () => {
|
|
50
|
+
onEnteredProp === null || onEnteredProp === void 0 ? void 0 : onEnteredProp();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onExit = () => {
|
|
54
|
+
onExitProp === null || onExitProp === void 0 ? void 0 : onExitProp();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const onExited = () => {
|
|
58
|
+
setExited(true);
|
|
59
|
+
onExitedProp === null || onExitedProp === void 0 ? void 0 : onExitedProp();
|
|
60
|
+
};
|
|
61
|
+
|
|
40
62
|
if (!visible) {
|
|
41
63
|
if (disableAnimation || exited) {
|
|
42
64
|
return null;
|
|
@@ -45,17 +67,22 @@ export default function Modal(props) {
|
|
|
45
67
|
|
|
46
68
|
return /*#__PURE__*/React.createElement(View, _extends({
|
|
47
69
|
style: css([StyleSheet.absoluteFill, elevationStyle, style])
|
|
48
|
-
}, otherProps), hideBackdrop
|
|
70
|
+
}, otherProps), !hideBackdrop && visible ? /*#__PURE__*/React.createElement(SimpleBackdrop, {
|
|
49
71
|
onPress: handleBackdropPress,
|
|
50
72
|
opacity: backdropOpacity
|
|
51
|
-
}), !disableAnimation ? /*#__PURE__*/React.createElement(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
}) : null, !disableAnimation ? /*#__PURE__*/React.createElement(AnimatedContainer, {
|
|
74
|
+
children: children,
|
|
75
|
+
closeAnimation: closeAnimation,
|
|
76
|
+
initialOpacity: initialOpacity,
|
|
77
|
+
initialTranslateY: initialTranslateY,
|
|
78
|
+
onEnter: onEnter,
|
|
79
|
+
onEntered: onEntered,
|
|
80
|
+
onExit: onExit,
|
|
81
|
+
onExited: onExited,
|
|
82
|
+
openAnimation: openAnimation,
|
|
83
|
+
style: animationStyle,
|
|
84
|
+
visible: visible
|
|
85
|
+
}) : children);
|
|
59
86
|
}
|
|
60
87
|
;
|
|
61
88
|
//# sourceMappingURL=Modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","css","StyleSheet","useElevationStyle","
|
|
1
|
+
{"version":3,"names":["React","View","css","StyleSheet","useElevationStyle","AnimatedContainer","SimpleBackdrop","createModalCloseEvent","reason","metadata","Modal","props","animationStyle","backdropOpacity","children","closeAnimation","disableAnimation","hideBackdrop","initialOpacity","initialTranslateY","onClose","onEnter","onEnterProp","onEntered","onEnteredProp","onExit","onExitProp","onExited","onExitedProp","openAnimation","style","visible","otherProps","handleBackdropPress","exited","setExited","useState","elevationStyle","absoluteFill"],"sources":["Modal.tsx"],"sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { css, StyleSheet } from '../styles';\nimport { useElevationStyle } from '../hooks';\nimport type ModalProps from './ModalProps';\nimport AnimatedContainer from './AnimatedContainer';\nimport SimpleBackdrop from './SimpleBackdrop';\n\nexport type ModalCloseReasonType = 'OUTSIDE_PRESS' | 'HARDWARE_BACK_PRESS' | 'CLOSE_BUTTON_PRESS' | 'UNKNOWN';\n\nexport interface ModalCloseEvent {\n metadata: {\n reason: ModalCloseReasonType\n };\n}\n\nexport const createModalCloseEvent = (reason: ModalCloseReasonType) => ({\n metadata: {\n reason,\n },\n});\n\nexport default function Modal(props: ModalProps) {\n const {\n animationStyle,\n backdropOpacity = 0.5,\n children,\n closeAnimation,\n disableAnimation = false,\n hideBackdrop = false,\n initialOpacity,\n initialTranslateY,\n onClose,\n onEnter: onEnterProp,\n onEntered: onEnteredProp,\n onExit: onExitProp,\n onExited: onExitedProp,\n openAnimation,\n style,\n visible,\n ...otherProps\n } = props;\n\n const handleBackdropPress = () => {\n if (onClose) {\n onClose(createModalCloseEvent('OUTSIDE_PRESS'));\n }\n };\n\n const [exited, setExited] = React.useState(true);\n\n const elevationStyle = useElevationStyle(6);\n\n const onEnter = () => {\n setExited(false);\n onEnterProp?.();\n };\n\n const onEntered = () => {\n onEnteredProp?.();\n };\n\n const onExit = () => {\n onExitProp?.();\n };\n\n const onExited = () => {\n setExited(true);\n onExitedProp?.();\n };\n\n if (!visible) {\n if (disableAnimation || exited) {\n return null;\n }\n }\n\n return (\n <View\n style={css([\n StyleSheet.absoluteFill,\n elevationStyle,\n style,\n ])}\n {...otherProps}\n >\n {(!hideBackdrop && visible) ? (\n <SimpleBackdrop\n onPress={handleBackdropPress}\n opacity={backdropOpacity}\n />\n ) : null}\n\n {!disableAnimation ? (\n <AnimatedContainer\n children={children}\n closeAnimation={closeAnimation}\n initialOpacity={initialOpacity}\n initialTranslateY={initialTranslateY}\n onEnter={onEnter}\n onEntered={onEntered}\n onExit={onExit}\n onExited={onExited}\n openAnimation={openAnimation}\n style={animationStyle}\n visible={visible}\n />\n ) : children}\n </View>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAAqB,cAArB;AACA,SAASC,GAAT,EAAcC,UAAd,QAAgC,WAAhC;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,cAAP,MAA2B,kBAA3B;AAUA,OAAO,MAAMC,qBAAqB,GAAIC,MAAD,KAAmC;EACpEC,QAAQ,EAAE;IACND;EADM;AAD0D,CAAnC,CAA9B;AAMP,eAAe,SAASE,KAAT,CAAeC,KAAf,EAAkC;EAC7C,MAAM;IACFC,cADE;IAEFC,eAAe,GAAG,GAFhB;IAGFC,QAHE;IAIFC,cAJE;IAKFC,gBAAgB,GAAG,KALjB;IAMFC,YAAY,GAAG,KANb;IAOFC,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IACI,OAAO,EAAEE,mBADb;IAEI,OAAO,EAAEpB;EAFb,EADH,GAKG,IAbR,EAeK,CAACG,gBAAD,gBACG,oBAAC,iBAAD;IACI,QAAQ,EAAEF,QADd;IAEI,cAAc,EAAEC,cAFpB;IAGI,cAAc,EAAEG,cAHpB;IAII,iBAAiB,EAAEC,iBAJvB;IAKI,OAAO,EAAEE,OALb;IAMI,SAAS,EAAEE,SANf;IAOI,MAAM,EAAEE,MAPZ;IAQI,QAAQ,EAAEE,QARd;IASI,aAAa,EAAEE,aATnB;IAUI,KAAK,EAAEjB,cAVX;IAWI,OAAO,EAAEmB;EAXb,EADH,GAcGjB,QA7BR,CADJ;AAiCH;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport default interface ModalProps extends OverridableComponentProps<ViewProps, {\n /**\n * Style object provided to animation component.\n */\n animationStyle?: ComponentProps['style'];\n\n /**\n * Opacity for backdrop.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * A single child content element.\n */\n children: React.ReactElement;\n\n /**\n * If `true`, the animation is disabled.\n * @default false\n */\n disableAnimation?: boolean;\n\n /**\n *
|
|
1
|
+
{"version":3,"names":["ANIMATION_TYPE"],"sources":["ModalProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Animated } from 'react-native';\nimport type { ComponentProps, OverridableComponentProps } from '../types';\nimport { ModalCloseEvent } from './Modal';\n\nexport const enum ANIMATION_TYPE {\n SLIDE = 'slide',\n FADE = 'fade',\n}\n\nexport type AnimationUnit = Omit<Animated.TimingAnimationConfig, 'useNativeDriver'> & {\n /**\n * Type of animation used when the dialog opens and closes.\n */\n type: ANIMATION_TYPE;\n}\n\nexport default interface ModalProps extends OverridableComponentProps<ViewProps, {\n /**\n * Style object provided to animation component.\n */\n animationStyle?: ComponentProps['style'];\n\n /**\n * Opacity for backdrop.\n * @default 0.5\n */\n backdropOpacity?: number;\n\n /**\n * A single child content element.\n */\n children: React.ReactElement;\n\n /**\n * If `true`, the animation is disabled.\n * @default false\n */\n disableAnimation?: boolean;\n\n /**\n * Animation used when the modal closes.\n */\n closeAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the backdrop is not rendered.\n * @default false\n */\n hideBackdrop?: boolean;\n\n /**\n * Set the initial value of opacity for animating.\n */\n initialOpacity?: number | undefined;\n\n /**\n * Set the initial value of transition y for animating.\n */\n initialTranslateY?: number | undefined;\n\n /**\n * Callback fired when the component requests to be closed.\n */\n onClose?: (event?: ModalCloseEvent) => void;\n\n /**\n * Callback fired when the enter animation will start.\n */\n onEnter?: () => void | undefined;\n\n /**\n * Callback fired when the enter animation is completed.\n */\n onEntered?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation will start.\n */\n onExit?: () => void | undefined;\n\n /**\n * Callback fired when the exit animation is completed.\n */\n onExited?: () => void | undefined;\n\n /**\n * Animation used when the modal opens.\n */\n openAnimation?: AnimationUnit[] | undefined;\n\n /**\n * If `true`, the modal is visible.\n */\n visible: boolean;\n}> {}\n"],"mappings":"AAMA,WAAkBA,cAAlB;;WAAkBA,c;EAAAA,c;EAAAA,c;GAAAA,c,KAAAA,c"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","createModalCloseEvent"],"sources":["index.ts"],"sourcesContent":["export { default, createModalCloseEvent } from './Modal';\nexport type { ModalCloseEvent } from './Modal';\nexport type { default as ModalProps } from './ModalProps';\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,qBAAlB,QAA+C,SAA/C"}
|
|
1
|
+
{"version":3,"names":["default","createModalCloseEvent","ANIMATION_TYPE"],"sources":["index.ts"],"sourcesContent":["export { default, createModalCloseEvent } from './Modal';\nexport type { ModalCloseEvent } from './Modal';\nexport type { default as ModalProps, AnimationUnit } from './ModalProps';\nexport { ANIMATION_TYPE } from './ModalProps';\n"],"mappings":"AAAA,SAASA,OAAT,EAAkBC,qBAAlB,QAA+C,SAA/C;AAGA,SAASC,cAAT,QAA+B,cAA/B"}
|
package/build/module/Tab/Tab.js
CHANGED
|
@@ -42,6 +42,7 @@ export default function Tab(props) {
|
|
|
42
42
|
borderColor: selected ? theme.palette.primary.main : theme.palette.border,
|
|
43
43
|
borderRadius: theme.shape.roundnessExtra,
|
|
44
44
|
borderWidth: selected ? 1.5 : 1,
|
|
45
|
+
minHeight: 'auto',
|
|
45
46
|
paddingHorizontal: theme.spacing(3),
|
|
46
47
|
paddingVertical: theme.spacing(1.5)
|
|
47
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","cloneElement","Platform","Text","View","Badge","TabBase","createFontStyle","css","StyleSheet","useTheme","TabIndicator","styles","create","root","OS","minWidth","minHeight","bottomNavigation","filledInner","justifyContent","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","indicatorColor","indicatorSize","selected","selectedIcon","variant","style","onTabInnerLayout","otherProps","theme","vertical","color","palette","text","primary","secondary","hint","containedStyle","borderColor","main","border","borderRadius","shape","roundnessExtra","borderWidth","paddingHorizontal","spacing","paddingVertical","tabBaseStyle","tabInnerStyle","fontStyle","selector","typo","h2","button2","subtitle2","fontWeight","medium","body2","flag","pressEffect","iconElement","fill","tabElement","tabIndicator"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text, View } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n minHeight: 40,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n filledInner: {\n justifyContent: 'center',\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n indicatorColor = 'primary',\n indicatorSize = 'full',\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n onTabInnerLayout,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected\n ? theme.palette.text.primary\n : variant === 'contained'\n ? theme.palette.text.secondary\n : theme.palette.text.hint;\n\n const containedStyle = {\n borderColor: selected ? theme.palette.primary.main : theme.palette.border,\n borderRadius: theme.shape.roundnessExtra,\n borderWidth: selected ? 1.5 : 1,\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n };\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'bottom-navigation' && styles.bottomNavigation,\n variant === 'contained' && containedStyle,\n style,\n ]);\n\n const tabInnerStyle = css([\n styles.root,\n styles.filledInner,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : variant === 'secondary'\n ? typo.button2\n : variant === 'contained'\n ? (selected ? { ...typo.subtitle2, fontWeight: typo.fontWeight.medium } : typo.body2)\n : typo.flag,\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n const tabElement = typeof children !== 'string' ? (\n React.cloneElement(children, {\n selected,\n })\n ) : (\n <React.Fragment>\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n </React.Fragment>\n );\n const tabIndicator = (enableIndicator && selected)\n ? <TabIndicator indicatorSize={indicatorSize} color={indicatorColor}/>\n : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n {indicatorSize === 'fit-content' ? (\n <View onLayout={onTabInnerLayout} style={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AAmBC,OADH,GAEhBT,OAAO,KAAK,WAAZ,GACII,KAAK,CAACG,OAAN,CAAcC,IAAd,CAAmBE,SADvB,GAEIN,KAAK,CAACG,OAAN,CAAcC,IAAd,CAAmBG,IAJ7B;EAMA,MAAMC,cAAc,GAAG;IACnBC,WAAW,EAAEf,QAAQ,GAAGM,KAAK,CAACG,OAAN,CAAcE,OAAd,CAAsBK,IAAzB,GAAgCV,KAAK,CAACG,OAAN,CAAcQ,MADhD;IAEnBC,YAAY,EAAEZ,KAAK,CAACa,KAAN,CAAYC,cAFP;IAGnBC,WAAW,EAAErB,QAAQ,GAAG,GAAH,GAAS,CAHX;
|
|
1
|
+
{"version":3,"names":["React","cloneElement","Platform","Text","View","Badge","TabBase","createFontStyle","css","StyleSheet","useTheme","TabIndicator","styles","create","root","OS","minWidth","minHeight","bottomNavigation","filledInner","justifyContent","Tab","props","badgeVisible","children","enableIndicator","icon","defaultIcon","indicatorColor","indicatorSize","selected","selectedIcon","variant","style","onTabInnerLayout","otherProps","theme","vertical","color","palette","text","primary","secondary","hint","containedStyle","borderColor","main","border","borderRadius","shape","roundnessExtra","borderWidth","paddingHorizontal","spacing","paddingVertical","tabBaseStyle","tabInnerStyle","fontStyle","selector","typo","h2","button2","subtitle2","fontWeight","medium","body2","flag","pressEffect","iconElement","fill","tabElement","tabIndicator"],"sources":["Tab.tsx"],"sourcesContent":["import React, { cloneElement } from 'react';\nimport { Platform, Text, View } from 'react-native';\nimport Badge from '../Badge';\nimport TabBase from '../TabBase';\nimport type TabProps from './TabProps';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport TabIndicator from './TabIndicator';\n\nconst styles = StyleSheet.create({\n root: {\n // TODO: Remove redundant platform checking\n ...(Platform.OS === 'web' ? { minWidth: 'auto' } : {}),\n minHeight: 40,\n },\n bottomNavigation: {\n minHeight: 56,\n },\n filledInner: {\n justifyContent: 'center',\n },\n});\n\nexport default function Tab(props: TabProps) {\n const {\n badgeVisible = false,\n children,\n enableIndicator = false,\n icon: defaultIcon,\n indicatorColor = 'primary',\n indicatorSize = 'full',\n selected = false,\n selectedIcon,\n variant = 'primary',\n style,\n onTabInnerLayout,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const vertical = variant === 'bottom-navigation';\n\n const color = selected\n ? theme.palette.text.primary\n : variant === 'contained'\n ? theme.palette.text.secondary\n : theme.palette.text.hint;\n\n const containedStyle = {\n borderColor: selected ? theme.palette.primary.main : theme.palette.border,\n borderRadius: theme.shape.roundnessExtra,\n borderWidth: selected ? 1.5 : 1,\n minHeight: 'auto',\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n };\n\n const tabBaseStyle = css([\n styles.root,\n variant === 'bottom-navigation' && styles.bottomNavigation,\n variant === 'contained' && containedStyle,\n style,\n ]);\n\n const tabInnerStyle = css([\n styles.root,\n styles.filledInner,\n ]);\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => variant === 'primary'\n ? typo.h2\n : variant === 'secondary'\n ? typo.button2\n : variant === 'contained'\n ? (selected ? { ...typo.subtitle2, fontWeight: typo.fontWeight.medium } : typo.body2)\n : typo.flag,\n color,\n });\n\n const pressEffect = selected ? 'none' : 'opacity';\n\n const icon = selected ? (selectedIcon || defaultIcon) : defaultIcon;\n const iconElement = icon ? cloneElement(icon, { fill: color }) : null;\n\n const tabElement = typeof children !== 'string' ? (\n React.cloneElement(children, {\n selected,\n })\n ) : (\n <React.Fragment>\n <Badge\n children={iconElement}\n invisible={!badgeVisible}\n />\n\n <Text\n children={children}\n style={css(fontStyle)}\n />\n </React.Fragment>\n );\n const tabIndicator = (enableIndicator && selected)\n ? <TabIndicator indicatorSize={indicatorSize} color={indicatorColor}/>\n : null;\n\n return (\n <TabBase\n pressEffect={pressEffect}\n style={tabBaseStyle}\n vertical={vertical}\n {...otherProps}\n >\n {indicatorSize === 'fit-content' ? (\n <View onLayout={onTabInnerLayout} style={tabInnerStyle}>\n {tabElement}\n\n {tabIndicator}\n </View>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6B,WAAW,GAAGrC,QAAQ,GAAG,MAAH,GAAY,SAAxC;EAEA,MAAMJ,IAAI,GAAGI,QAAQ,GAAIC,YAAY,IAAIJ,WAApB,GAAmCA,WAAxD;EACA,MAAMyC,WAAW,GAAG1C,IAAI,gBAAGzB,YAAY,CAACyB,IAAD,EAAO;IAAE2C,IAAI,EAAE/B;EAAR,CAAP,CAAf,GAAyC,IAAjE;EAEA,MAAMgC,UAAU,GAAG,OAAO9C,QAAP,KAAoB,QAApB,gBACfxB,KAAK,CAACC,YAAN,CAAmBuB,QAAnB,EAA6B;IACzBM;EADyB,CAA7B,CADe,gBAKf,oBAAC,KAAD,CAAO,QAAP,qBACI,oBAAC,KAAD;IACI,QAAQ,EAAEsC,WADd;IAEI,SAAS,EAAE,CAAC7C;EAFhB,EADJ,eAMI,oBAAC,IAAD;IACI,QAAQ,EAAEC,QADd;IAEI,KAAK,EAAEhB,GAAG,CAACiD,SAAD;EAFd,EANJ,CALJ;EAiBA,MAAMc,YAAY,GAAI9C,eAAe,IAAIK,QAApB,gBACf,oBAAC,YAAD;IAAc,aAAa,EAAED,aAA7B;IAA4C,KAAK,EAAED;EAAnD,EADe,GAEf,IAFN;EAIA,oBACI,oBAAC,OAAD;IACI,WAAW,EAAEuC,WADjB;IAEI,KAAK,EAAEZ,YAFX;IAGI,QAAQ,EAAElB;EAHd,GAIQF,UAJR,GAMKN,aAAa,KAAK,aAAlB,gBACG,oBAAC,IAAD;IAAM,QAAQ,EAAEK,gBAAhB;IAAkC,KAAK,EAAEsB;EAAzC,GACKc,UADL,EAGKC,YAHL,CADH,gBAOG,oBAAC,KAAD,CAAO,QAAP,QACKD,UADL,EAGKC,YAHL,CAbR,CADJ;AAsBH;AAAA"}
|
|
@@ -40,6 +40,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
|
|
|
40
40
|
keyboardShouldPersistTaps = 'never',
|
|
41
41
|
onChange,
|
|
42
42
|
scrollable = false,
|
|
43
|
+
scrollViewContentContainerStyle,
|
|
43
44
|
style,
|
|
44
45
|
variant = 'primary',
|
|
45
46
|
UNSTABLE_sharedIndex,
|
|
@@ -163,7 +164,7 @@ const Tabs = /*#__PURE__*/forwardRef(function Tabs(props, ref) {
|
|
|
163
164
|
}, scrollable ? /*#__PURE__*/React.createElement(ScrollableTabsView, {
|
|
164
165
|
automaticallyAdjustContentInsets: false,
|
|
165
166
|
bounces: false,
|
|
166
|
-
contentContainerStyle: styles.scrollableContainer,
|
|
167
|
+
contentContainerStyle: css([styles.scrollableContainer, scrollViewContentContainerStyle]),
|
|
167
168
|
coordinates: coordinates,
|
|
168
169
|
directionalLockEnabled: true,
|
|
169
170
|
horizontal: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","cloneElement","forwardRef","useEffect","useImperativeHandle","useMemo","useRef","View","css","useTheme","useSyncAnimatedValue","TabIndicator","ScrollableTabsView","IndexAwareTab","useTabCoordinates","useTabInnerContentsWidth","useIndexStore","InternalContext","isEveryTabCoordinatesDefined","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","ref","children","indicatorColor","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","initialValue","sharedIndex","realInitialIndex","currentIndexRef","setTab","newIndex","currentIndex","current","animatedValue","setValue","styles","outerCoordinates","updateCoordinate","innerContentsWidthList","updateInnerContentsWidth","canRenderIndicator","indexStore","coordinates","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","subscribe","tabElements","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabElement","enableIndicator","undefined","filter","Boolean","tabIndicator"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } 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 useTabInnerContentsWidth from './useTabInnerContentsWidth';\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 indicatorColor = 'primary',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'full',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n style,\n variant = 'primary',\n UNSTABLE_sharedIndex,\n onTabSelected,\n } = props;\n\n const fallbackSharedIndex = useSyncAnimatedValue({ initialValue: initialIndex });\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n const realInitialIndex = sharedIndex.initialValue;\n\n const currentIndexRef = useRef(initialIndex);\n\n const setTab = (newIndex: number) => {\n const currentIndex = currentIndexRef.current;\n onTabSelected?.(newIndex, currentIndex);\n\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 [outerCoordinates, updateCoordinate] = useTabCoordinates(children);\n const [innerContentsWidthList, updateInnerContentsWidth] = useTabInnerContentsWidth(children);\n\n const canRenderIndicator = indicatorSize === 'fit-content'\n ? isEveryTabCoordinatesDefined(innerContentsWidthList, children)\n : isEveryTabCoordinatesDefined(outerCoordinates, children);\n\n const indexStore = useIndexStore(sharedIndex);\n\n const coordinates = useMemo(() => {\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const { x1: outerX1, x2: outerX2 } = outerCoordinates[idx];\n\n const tabWidth = outerX2 - outerX1;\n const distanceFromParent = (tabWidth - innerContentWidth) / 2;\n const indicatorStartCoordinate = outerX1 + distanceFromParent;\n\n return {\n x1: indicatorStartCoordinate,\n x2: indicatorStartCoordinate + innerContentWidth,\n };\n });\n }, [outerCoordinates, innerContentsWidthList, variant]);\n\n useEffect(() => {\n return indexStore.subscribe(newIndex => {\n onChange?.(newIndex);\n currentIndexRef.current = newIndex;\n });\n }, [indexStore, onChange]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n if (!child) {\n return null;\n }\n\n const onTabInnerLayout = (event: LayoutChangeEvent) => {\n const { width } = event.nativeEvent.layout;\n\n updateInnerContentsWidth(index, width);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n updateCoordinate(index, x, width);\n\n // @ts-ignore\n child.props.onLayout?.(event);\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 indicatorColor,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n indicatorSize,\n style: scrollable ? undefined : styles.fixedTab,\n });\n\n return (\n <IndexAwareTab\n children={tabElement}\n index={index}\n initialIndex={realInitialIndex}\n />\n );\n })?.filter(Boolean);\n\n const tabIndicator = canRenderIndicator ? (\n <TabIndicator\n color={indicatorColor}\n coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\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 initialIndex={realInitialIndex}\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,EAA0EC,OAA1E,EAAmFC,MAAnF,QAAiG,OAAjG;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,wBAAP,MAAqC,4BAArC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,SAASC,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C,KAAD,CAAO,QAAP,QACKpB,WADL,EAEKoB,YAFL,CA1BR,CADJ,CADJ;AAoCH,CAhLsB,CAAvB;AAkLA,eAAelE,IAAf"}
|
|
1
|
+
{"version":3,"names":["React","cloneElement","forwardRef","useEffect","useImperativeHandle","useMemo","useRef","View","css","useTheme","useSyncAnimatedValue","TabIndicator","ScrollableTabsView","IndexAwareTab","useTabCoordinates","useTabInnerContentsWidth","useIndexStore","InternalContext","isEveryTabCoordinatesDefined","useStyles","theme","root","fixedRoot","flexDirection","fixedTab","flex","scrollableContainer","paddingHorizontal","spacing","Tabs","props","ref","children","indicatorColor","initialIndex","disableIndicator","indicatorSize","keyboardDismissMode","keyboardShouldPersistTaps","onChange","scrollable","scrollViewContentContainerStyle","style","variant","UNSTABLE_sharedIndex","onTabSelected","fallbackSharedIndex","initialValue","sharedIndex","realInitialIndex","currentIndexRef","setTab","newIndex","currentIndex","current","animatedValue","setValue","styles","outerCoordinates","updateCoordinate","innerContentsWidthList","updateInnerContentsWidth","canRenderIndicator","indexStore","coordinates","map","innerContentWidth","idx","x1","outerX1","x2","outerX2","tabWidth","distanceFromParent","indicatorStartCoordinate","subscribe","tabElements","Children","child","index","onTabInnerLayout","event","width","nativeEvent","layout","onLayout","x","onMouseDown","e","preventDefault","onPress","tabElement","enableIndicator","undefined","filter","Boolean","tabIndicator"],"sources":["Tabs.tsx"],"sourcesContent":["import React, { cloneElement, forwardRef, useEffect, useImperativeHandle, useMemo, useRef } 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 useTabInnerContentsWidth from './useTabInnerContentsWidth';\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 indicatorColor = 'primary',\n initialIndex = 0,\n disableIndicator = false,\n indicatorSize = 'full',\n keyboardDismissMode = 'none',\n keyboardShouldPersistTaps = 'never',\n onChange,\n scrollable = false,\n scrollViewContentContainerStyle,\n style,\n variant = 'primary',\n UNSTABLE_sharedIndex,\n onTabSelected,\n } = props;\n\n const fallbackSharedIndex = useSyncAnimatedValue({ initialValue: initialIndex });\n const sharedIndex = UNSTABLE_sharedIndex ?? fallbackSharedIndex;\n const realInitialIndex = sharedIndex.initialValue;\n\n const currentIndexRef = useRef(initialIndex);\n\n const setTab = (newIndex: number) => {\n const currentIndex = currentIndexRef.current;\n onTabSelected?.(newIndex, currentIndex);\n\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 [outerCoordinates, updateCoordinate] = useTabCoordinates(children);\n const [innerContentsWidthList, updateInnerContentsWidth] = useTabInnerContentsWidth(children);\n\n const canRenderIndicator = indicatorSize === 'fit-content'\n ? isEveryTabCoordinatesDefined(innerContentsWidthList, children)\n : isEveryTabCoordinatesDefined(outerCoordinates, children);\n\n const indexStore = useIndexStore(sharedIndex);\n\n const coordinates = useMemo(() => {\n if (indicatorSize !== 'fit-content') {\n return outerCoordinates;\n }\n\n return innerContentsWidthList.map((innerContentWidth, idx) => {\n const { x1: outerX1, x2: outerX2 } = outerCoordinates[idx];\n\n const tabWidth = outerX2 - outerX1;\n const distanceFromParent = (tabWidth - innerContentWidth) / 2;\n const indicatorStartCoordinate = outerX1 + distanceFromParent;\n\n return {\n x1: indicatorStartCoordinate,\n x2: indicatorStartCoordinate + innerContentWidth,\n };\n });\n }, [outerCoordinates, innerContentsWidthList, variant]);\n\n useEffect(() => {\n return indexStore.subscribe(newIndex => {\n onChange?.(newIndex);\n currentIndexRef.current = newIndex;\n });\n }, [indexStore, onChange]);\n\n const tabElements = React.Children.map(children, (child, index) => {\n if (!child) {\n return null;\n }\n\n const onTabInnerLayout = (event: LayoutChangeEvent) => {\n const { width } = event.nativeEvent.layout;\n\n updateInnerContentsWidth(index, width);\n };\n\n const onLayout = (event: LayoutChangeEvent) => {\n const { x, width } = event.nativeEvent.layout;\n\n updateCoordinate(index, x, width);\n\n // @ts-ignore\n child.props.onLayout?.(event);\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 indicatorColor,\n onTabInnerLayout,\n onLayout,\n onPress,\n onMouseDown,\n variant,\n indicatorSize,\n style: scrollable ? undefined : styles.fixedTab,\n });\n\n return (\n <IndexAwareTab\n children={tabElement}\n index={index}\n initialIndex={realInitialIndex}\n />\n );\n })?.filter(Boolean);\n\n const tabIndicator = canRenderIndicator ? (\n <TabIndicator\n color={indicatorColor}\n coordinates={coordinates}\n disabled={disableIndicator}\n initialIndex={realInitialIndex}\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={css([\n styles.scrollableContainer,\n scrollViewContentContainerStyle,\n ])}\n coordinates={coordinates}\n directionalLockEnabled={true}\n horizontal={true}\n initialIndex={realInitialIndex}\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,EAA0EC,OAA1E,EAAmFC,MAAnF,QAAiG,OAAjG;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,wBAAP,MAAqC,4BAArC;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,SAASC,4BAAT,QAA6C,SAA7C;;AAUA,MAAMC,SAAgC,GAAG,YAAwB;EAC7D,MAAMC,KAAK,GAAGX,QAAQ,EAAtB;EAEA,OAAO;IACHY,IAAI,EAAE,EADH;IAEHC,SAAS,EAAE;MACPC,aAAa,EAAE;IADR,CAFR;IAKHC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA,CALP;IAQHC,mBAAmB,EAAE;MACjBC,iBAAiB,EAAE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from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { TabIndicatorColor } from './TabIndicatorProps';\nimport type { TabVariant, TabIndicatorSize } 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 * The color of tab indicator\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\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 /**\n * Callback function executed when a Tab is selected.\n * Executed even if the index does not change when a Tab is pressed.\n * Receives the next tab index and the current tab index as parameters.\n */\n onTabSelected?: (newIndex: number, currentIndex: number) => void;\n}> {}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["TabsProps.ts"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { TabIndicatorColor } from './TabIndicatorProps';\nimport type { TabVariant, TabIndicatorSize } from '../Tab';\nimport type { OverridableComponentProps, SyncAnimatedValue } from '../types';\nimport type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';\nimport type { ExtendedStyle } 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 * The color of tab indicator\n * @default 'primary'\n */\n indicatorColor?: TabIndicatorColor;\n\n /**\n * The size of tab indicator.\n * 'full' adjusts the indicator to the size of the Tab,\n * while 'fit-content' adjusts the indicator to the size of the content inside the Tab.\n * @default 'full'\n */\n indicatorSize?: TabIndicatorSize;\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 * These styles will be applied to the scroll view content container which wraps all of the child views.\n */\n scrollViewContentContainerStyle?: ExtendedStyle | ExtendedStyle[];\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 /**\n * Callback function executed when a Tab is selected.\n * Executed even if the index does not change when a Tab is pressed.\n * Receives the next tab index and the current tab index as parameters.\n */\n onTabSelected?: (newIndex: number, currentIndex: number) => void;\n}> {}\n"],"mappings":""}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ModalProps } from '../Modal';
|
|
3
3
|
import type { OverridableComponentProps } from '../types';
|
|
4
|
+
import { ANIMATION_TYPE } from '../Modal';
|
|
4
5
|
export default interface DialogProps extends OverridableComponentProps<ModalProps, {
|
|
6
|
+
/**
|
|
7
|
+
* Type of animation used when the dialog opens and closes.
|
|
8
|
+
* @default 'slide'
|
|
9
|
+
*/
|
|
10
|
+
animationType?: ANIMATION_TYPE;
|
|
5
11
|
/**
|
|
6
12
|
* Dialog children, usually the included sub-components.
|
|
7
13
|
*/
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type ModalProps from '../ModalProps';
|
|
3
|
+
declare type AnimatedContainerProps = Pick<ModalProps, 'children' | 'closeAnimation' | 'initialOpacity' | 'initialTranslateY' | 'onEnter' | 'onEntered' | 'onExit' | 'onExited' | 'openAnimation' | 'style' | 'visible'>;
|
|
4
|
+
export default function AnimatedContainer(props: AnimatedContainerProps): JSX.Element;
|
|
5
|
+
export {};
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ViewProps } from 'react-native';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
3
4
|
import type { ComponentProps, OverridableComponentProps } from '../types';
|
|
4
5
|
import { ModalCloseEvent } from './Modal';
|
|
6
|
+
export declare const enum ANIMATION_TYPE {
|
|
7
|
+
SLIDE = "slide",
|
|
8
|
+
FADE = "fade"
|
|
9
|
+
}
|
|
10
|
+
export declare type AnimationUnit = Omit<Animated.TimingAnimationConfig, 'useNativeDriver'> & {
|
|
11
|
+
/**
|
|
12
|
+
* Type of animation used when the dialog opens and closes.
|
|
13
|
+
*/
|
|
14
|
+
type: ANIMATION_TYPE;
|
|
15
|
+
};
|
|
5
16
|
export default interface ModalProps extends OverridableComponentProps<ViewProps, {
|
|
6
17
|
/**
|
|
7
18
|
* Style object provided to animation component.
|
|
@@ -22,24 +33,46 @@ export default interface ModalProps extends OverridableComponentProps<ViewProps,
|
|
|
22
33
|
*/
|
|
23
34
|
disableAnimation?: boolean;
|
|
24
35
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @default 300
|
|
27
|
-
*/
|
|
28
|
-
enterDuration?: number;
|
|
29
|
-
/**
|
|
30
|
-
* The number of milliseconds to exit animation.
|
|
31
|
-
* @default 150
|
|
36
|
+
* Animation used when the modal closes.
|
|
32
37
|
*/
|
|
33
|
-
|
|
38
|
+
closeAnimation?: AnimationUnit[] | undefined;
|
|
34
39
|
/**
|
|
35
40
|
* If `true`, the backdrop is not rendered.
|
|
36
41
|
* @default false
|
|
37
42
|
*/
|
|
38
43
|
hideBackdrop?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Set the initial value of opacity for animating.
|
|
46
|
+
*/
|
|
47
|
+
initialOpacity?: number | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Set the initial value of transition y for animating.
|
|
50
|
+
*/
|
|
51
|
+
initialTranslateY?: number | undefined;
|
|
39
52
|
/**
|
|
40
53
|
* Callback fired when the component requests to be closed.
|
|
41
54
|
*/
|
|
42
55
|
onClose?: (event?: ModalCloseEvent) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Callback fired when the enter animation will start.
|
|
58
|
+
*/
|
|
59
|
+
onEnter?: () => void | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Callback fired when the enter animation is completed.
|
|
62
|
+
*/
|
|
63
|
+
onEntered?: () => void | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Callback fired when the exit animation will start.
|
|
66
|
+
*/
|
|
67
|
+
onExit?: () => void | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Callback fired when the exit animation is completed.
|
|
70
|
+
*/
|
|
71
|
+
onExited?: () => void | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Animation used when the modal opens.
|
|
74
|
+
*/
|
|
75
|
+
openAnimation?: AnimationUnit[] | undefined;
|
|
43
76
|
/**
|
|
44
77
|
* If `true`, the modal is visible.
|
|
45
78
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default, createModalCloseEvent } from './Modal';
|
|
2
2
|
export type { ModalCloseEvent } from './Modal';
|
|
3
|
-
export type { default as ModalProps } from './ModalProps';
|
|
3
|
+
export type { default as ModalProps, AnimationUnit } from './ModalProps';
|
|
4
|
+
export { ANIMATION_TYPE } from './ModalProps';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type TabsProps from './TabsProps';
|
|
3
3
|
import type { TabsInstance } from './types';
|
|
4
|
-
declare const Tabs: React.ForwardRefExoticComponent<Pick<TabsProps, "testID" | "style" | "onLayout" | "keyboardDismissMode" | "children" | "pointerEvents" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "accessibilityLabel" | "accessible" | "hitSlop" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessibilityActions" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "variant" | "keyboardShouldPersistTaps" | "onChange" | "indicatorColor" | "indicatorSize" | "initialIndex" | "scrollable" | "disableIndicator" | "UNSTABLE_sharedIndex" | "onTabSelected"> & React.RefAttributes<TabsInstance>>;
|
|
4
|
+
declare const Tabs: React.ForwardRefExoticComponent<Pick<TabsProps, "testID" | "style" | "onLayout" | "keyboardDismissMode" | "children" | "pointerEvents" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "accessibilityLabel" | "accessible" | "hitSlop" | "removeClippedSubviews" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessibilityActions" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "variant" | "keyboardShouldPersistTaps" | "onChange" | "indicatorColor" | "indicatorSize" | "initialIndex" | "scrollable" | "disableIndicator" | "scrollViewContentContainerStyle" | "UNSTABLE_sharedIndex" | "onTabSelected"> & React.RefAttributes<TabsInstance>>;
|
|
5
5
|
export default Tabs;
|
|
@@ -4,6 +4,7 @@ import type { TabIndicatorColor } from './TabIndicatorProps';
|
|
|
4
4
|
import type { TabVariant, TabIndicatorSize } from '../Tab';
|
|
5
5
|
import type { OverridableComponentProps, SyncAnimatedValue } from '../types';
|
|
6
6
|
import type { KeyboardDismissMode, KeyboardShouldPersistTaps, TabsInstance } from './types';
|
|
7
|
+
import type { ExtendedStyle } from '../types';
|
|
7
8
|
export default interface TabsProps extends OverridableComponentProps<ViewProps, {
|
|
8
9
|
ref?: Ref<TabsInstance>;
|
|
9
10
|
/**
|
|
@@ -51,6 +52,10 @@ export default interface TabsProps extends OverridableComponentProps<ViewProps,
|
|
|
51
52
|
* @default false
|
|
52
53
|
*/
|
|
53
54
|
scrollable?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* These styles will be applied to the scroll view content container which wraps all of the child views.
|
|
57
|
+
*/
|
|
58
|
+
scrollViewContentContainerStyle?: ExtendedStyle | ExtendedStyle[];
|
|
54
59
|
/**
|
|
55
60
|
* Unstable API.
|
|
56
61
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fountain-ui/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.83",
|
|
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": "
|
|
70
|
+
"gitHead": "ade918bdbf6082ea7d61be5749d28ff0c6c3300b"
|
|
71
71
|
}
|