@draftbit/core 47.0.1-e04fa3.2 → 47.1.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.
- package/lib/commonjs/components/Button.js +3 -3
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -3
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +1 -2
- package/lib/commonjs/components/Checkbox/CheckboxRow.js +1 -2
- package/lib/commonjs/components/DeprecatedButton.js +3 -27
- package/lib/commonjs/components/DeprecatedFAB.js +1 -2
- package/lib/commonjs/components/Justification.js +1 -5
- package/lib/commonjs/components/Pressable.js +37 -0
- package/lib/commonjs/components/ResizeMode.js +1 -5
- package/lib/commonjs/components/Swiper/Swiper.js +2 -0
- package/lib/commonjs/components/Touchable.js +8 -3
- package/lib/commonjs/index.js +89 -25
- package/lib/commonjs/mappings/Button.js +39 -10
- package/lib/commonjs/mappings/FlashList.js +45 -2
- package/lib/commonjs/mappings/FlatList.js +12 -0
- package/lib/commonjs/mappings/Swiper.js +2 -0
- package/lib/commonjs/mappings/Touchable.js +47 -7
- package/lib/module/components/Button.js +3 -3
- package/lib/module/components/Checkbox/Checkbox.js +2 -3
- package/lib/module/components/Checkbox/CheckboxGroupRow.js +2 -3
- package/lib/module/components/Checkbox/CheckboxRow.js +2 -3
- package/lib/module/components/DeprecatedButton.js +4 -28
- package/lib/module/components/DeprecatedFAB.js +2 -3
- package/lib/module/components/Justification.js +0 -1
- package/lib/module/components/Pressable.js +30 -0
- package/lib/module/components/ResizeMode.js +0 -1
- package/lib/module/components/Swiper/Swiper.js +2 -0
- package/lib/module/components/Touchable.js +8 -3
- package/lib/module/index.js +32 -121
- package/lib/module/mappings/Button.js +40 -11
- package/lib/module/mappings/FlashList.js +46 -3
- package/lib/module/mappings/FlatList.js +13 -1
- package/lib/module/mappings/Swiper.js +3 -1
- package/lib/module/mappings/Touchable.js +49 -9
- package/lib/typescript/src/components/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/typescript/src/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/CheckboxGroupRow.d.ts.map +1 -1
- package/lib/typescript/src/components/Checkbox/CheckboxRow.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedButton.d.ts +2 -2
- package/lib/typescript/src/components/DeprecatedButton.d.ts.map +1 -1
- package/lib/typescript/src/components/DeprecatedFAB.d.ts +2 -2
- package/lib/typescript/src/components/DeprecatedFAB.d.ts.map +1 -1
- package/lib/typescript/src/components/Pressable.d.ts +10 -0
- package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/Swiper/Swiper.d.ts +2 -1
- package/lib/typescript/src/components/Swiper/Swiper.d.ts.map +1 -1
- package/lib/typescript/src/components/Touchable.d.ts +5 -6
- package/lib/typescript/src/components/Touchable.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +30 -102
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Button.d.ts +113 -4
- package/lib/typescript/src/mappings/Button.d.ts.map +1 -1
- package/lib/typescript/src/mappings/FlashList.d.ts +112 -2
- package/lib/typescript/src/mappings/FlashList.d.ts.map +1 -1
- package/lib/typescript/src/mappings/FlatList.d.ts +42 -0
- package/lib/typescript/src/mappings/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Swiper.d.ts +11 -0
- package/lib/typescript/src/mappings/Swiper.d.ts.map +1 -1
- package/lib/typescript/src/mappings/Touchable.d.ts +59 -5
- package/lib/typescript/src/mappings/Touchable.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Button.tsx +14 -4
- package/src/components/Checkbox/Checkbox.tsx +5 -7
- package/src/components/Checkbox/CheckboxGroupRow.tsx +3 -3
- package/src/components/Checkbox/CheckboxRow.tsx +3 -3
- package/src/components/DeprecatedButton.tsx +7 -31
- package/src/components/DeprecatedFAB.tsx +5 -5
- package/src/components/Pressable.tsx +44 -0
- package/src/components/Swiper/Swiper.tsx +3 -0
- package/src/components/Touchable.tsx +11 -7
- package/src/index.tsx +44 -123
- package/src/mappings/Button.ts +41 -10
- package/src/mappings/FlashList.ts +82 -30
- package/src/mappings/FlatList.ts +16 -0
- package/src/mappings/Swiper.ts +4 -0
- package/src/mappings/Touchable.ts +53 -6
- package/lib/commonjs/mappings/NativeBase/AlertDialog.js +0 -102
- package/lib/commonjs/mappings/NativeBase/Button.js +0 -84
- package/lib/commonjs/mappings/NativeBase/DataDisplay.js +0 -61
- package/lib/commonjs/mappings/NativeBase/Feedback.js +0 -74
- package/lib/commonjs/mappings/NativeBase/Layout.js +0 -114
- package/lib/commonjs/mappings/NativeBase/Media.js +0 -49
- package/lib/commonjs/mappings/NativeBase/Menu.js +0 -111
- package/lib/commonjs/mappings/NativeBase/Modal.js +0 -93
- package/lib/commonjs/mappings/NativeBase/Other.js +0 -94
- package/lib/commonjs/mappings/NativeBase/Popover.js +0 -99
- package/lib/commonjs/mappings/NativeBase/Select.js +0 -65
- package/lib/commonjs/mappings/NativeBase/Slider.js +0 -81
- package/lib/module/mappings/NativeBase/AlertDialog.js +0 -95
- package/lib/module/mappings/NativeBase/Button.js +0 -86
- package/lib/module/mappings/NativeBase/DataDisplay.js +0 -54
- package/lib/module/mappings/NativeBase/Feedback.js +0 -67
- package/lib/module/mappings/NativeBase/Layout.js +0 -107
- package/lib/module/mappings/NativeBase/Media.js +0 -42
- package/lib/module/mappings/NativeBase/Menu.js +0 -104
- package/lib/module/mappings/NativeBase/Modal.js +0 -86
- package/lib/module/mappings/NativeBase/Other.js +0 -87
- package/lib/module/mappings/NativeBase/Popover.js +0 -92
- package/lib/module/mappings/NativeBase/Select.js +0 -58
- package/lib/module/mappings/NativeBase/Slider.js +0 -74
- package/lib/typescript/src/mappings/NativeBase/AlertDialog.d.ts +0 -146
- package/lib/typescript/src/mappings/NativeBase/AlertDialog.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Button.d.ts +0 -1
- package/lib/typescript/src/mappings/NativeBase/Button.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/DataDisplay.d.ts +0 -96
- package/lib/typescript/src/mappings/NativeBase/DataDisplay.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Feedback.d.ts +0 -2
- package/lib/typescript/src/mappings/NativeBase/Feedback.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts +0 -146
- package/lib/typescript/src/mappings/NativeBase/Layout.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Media.d.ts +0 -48
- package/lib/typescript/src/mappings/NativeBase/Media.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Menu.d.ts +0 -227
- package/lib/typescript/src/mappings/NativeBase/Menu.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Modal.d.ts +0 -133
- package/lib/typescript/src/mappings/NativeBase/Modal.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Other.d.ts +0 -179
- package/lib/typescript/src/mappings/NativeBase/Other.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Popover.d.ts +0 -136
- package/lib/typescript/src/mappings/NativeBase/Popover.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Select.d.ts +0 -156
- package/lib/typescript/src/mappings/NativeBase/Select.d.ts.map +0 -1
- package/lib/typescript/src/mappings/NativeBase/Slider.d.ts +0 -200
- package/lib/typescript/src/mappings/NativeBase/Slider.d.ts.map +0 -1
- package/src/Provider.js +0 -9
- package/src/components/Accordion/AccordionGroup.js +0 -44
- package/src/components/Accordion/AccordionItem.js +0 -32
- package/src/components/Accordion/index.js +0 -2
- package/src/components/ActionSheet/ActionSheet.js +0 -45
- package/src/components/ActionSheet/ActionSheetCancel.js +0 -6
- package/src/components/ActionSheet/ActionSheetItem.js +0 -30
- package/src/components/ActionSheet/index.js +0 -3
- package/src/components/AnimatedCircularProgress.js +0 -43
- package/src/components/AspectRatio.js +0 -18
- package/src/components/AvatarEdit.js +0 -30
- package/src/components/Banner.js +0 -109
- package/src/components/Button.js +0 -114
- package/src/components/Card.js +0 -57
- package/src/components/CardBlock.js +0 -54
- package/src/components/CardContainer.js +0 -69
- package/src/components/CardContainerRating.js +0 -79
- package/src/components/CardContainerShortImage.js +0 -33
- package/src/components/CardInline.js +0 -36
- package/src/components/Carousel.js +0 -68
- package/src/components/Checkbox/Checkbox.js +0 -63
- package/src/components/Checkbox/CheckboxGroup.js +0 -21
- package/src/components/Checkbox/CheckboxGroupRow.js +0 -77
- package/src/components/Checkbox/CheckboxRow.js +0 -78
- package/src/components/Checkbox/context.js +0 -14
- package/src/components/Checkbox/index.js +0 -3
- package/src/components/CircleImage.js +0 -8
- package/src/components/CircularProgress.js +0 -81
- package/src/components/Config.js +0 -64
- package/src/components/Container.js +0 -43
- package/src/components/DatePicker/DatePicker.js +0 -377
- package/src/components/DatePicker/DatePickerComponent.js +0 -13
- package/src/components/DatePicker/DatePickerComponent.web.js +0 -30
- package/src/components/DatePicker/DatePickerComponentType.js +0 -1
- package/src/components/DeprecatedButton.js +0 -95
- package/src/components/DeprecatedCardWrapper.js +0 -18
- package/src/components/DeprecatedFAB.js +0 -115
- package/src/components/Divider.js +0 -13
- package/src/components/Elevation.js +0 -20
- package/src/components/FAB.js +0 -46
- package/src/components/FieldSearchBarFull.js +0 -53
- package/src/components/FormRow.js +0 -19
- package/src/components/Header.js +0 -44
- package/src/components/HeaderLarge.js +0 -7
- package/src/components/HeaderMedium.js +0 -7
- package/src/components/HeaderOverline.js +0 -7
- package/src/components/IconButton.js +0 -35
- package/src/components/Image.js +0 -47
- package/src/components/Justification.js +0 -1
- package/src/components/Layout.js +0 -50
- package/src/components/NumberInput.js +0 -49
- package/src/components/Picker/Picker.js +0 -267
- package/src/components/Picker/PickerComponent.android.js +0 -69
- package/src/components/Picker/PickerComponent.ios.js +0 -79
- package/src/components/Picker/PickerComponent.web.js +0 -70
- package/src/components/Picker/PickerTypes.js +0 -1
- package/src/components/Portal/Portal.js +0 -35
- package/src/components/Portal/PortalConsumer.js +0 -27
- package/src/components/Portal/PortalHost.js +0 -107
- package/src/components/Portal/PortalManager.js +0 -32
- package/src/components/ProgressBar.js +0 -118
- package/src/components/ProgressCircle.js +0 -13
- package/src/components/ProgressIndicator.js +0 -27
- package/src/components/RadioButton/RadioButton.js +0 -17
- package/src/components/RadioButton/RadioButtonFieldGroup.js +0 -17
- package/src/components/RadioButton/RadioButtonGroup.js +0 -43
- package/src/components/RadioButton/RadioButtonRow.js +0 -76
- package/src/components/RadioButton/context.js +0 -14
- package/src/components/RadioButton/index.js +0 -4
- package/src/components/ResizeMode.js +0 -1
- package/src/components/Row.js +0 -48
- package/src/components/RowBodyIcon.js +0 -8
- package/src/components/RowHeadlineImageCaption.js +0 -12
- package/src/components/RowHeadlineImageIcon.js +0 -14
- package/src/components/SVG.js +0 -13
- package/src/components/ScreenContainer.js +0 -34
- package/src/components/Slider.js +0 -63
- package/src/components/StarRating.js +0 -50
- package/src/components/StepIndicator.js +0 -346
- package/src/components/Stepper.js +0 -41
- package/src/components/Surface.js +0 -32
- package/src/components/Swiper/Swiper.js +0 -29
- package/src/components/Swiper/SwiperItem.js +0 -9
- package/src/components/Swiper/index.js +0 -2
- package/src/components/Switch.js +0 -56
- package/src/components/Text.js +0 -33
- package/src/components/TextField.js +0 -428
- package/src/components/ToggleButton.js +0 -39
- package/src/components/Touchable.js +0 -12
- package/src/components/Touchable.web.js +0 -2
- package/src/components/Typography.js +0 -36
- package/src/components/useAuthState.js +0 -31
- package/src/constants.js +0 -10
- package/src/hooks.js +0 -12
- package/src/index.js +0 -133
- package/src/interfaces/Icon.js +0 -8
- package/src/mappings/Accordion.js +0 -41
- package/src/mappings/AccordionItem.js +0 -16
- package/src/mappings/ActionSheet.js +0 -13
- package/src/mappings/ActionSheetCancel.js +0 -19
- package/src/mappings/ActionSheetItem.js +0 -23
- package/src/mappings/ActivityIndicator.js +0 -58
- package/src/mappings/AudioPlayer.js +0 -57
- package/src/mappings/AvatarEdit.js +0 -38
- package/src/mappings/Banner.js +0 -32
- package/src/mappings/BlurView.js +0 -42
- package/src/mappings/Button.js +0 -87
- package/src/mappings/Card.js +0 -52
- package/src/mappings/CardBlock.js +0 -123
- package/src/mappings/CardContainer.js +0 -104
- package/src/mappings/CardContainerRating.js +0 -126
- package/src/mappings/CardContainerShortImage.js +0 -120
- package/src/mappings/CardInline.js +0 -52
- package/src/mappings/Carousel.js +0 -19
- package/src/mappings/Checkbox.js +0 -46
- package/src/mappings/CheckboxGroup.js +0 -26
- package/src/mappings/CheckboxRow.js +0 -61
- package/src/mappings/CircleImage.js +0 -25
- package/src/mappings/Container.js +0 -30
- package/src/mappings/CustomCode.js +0 -8
- package/src/mappings/DatePicker.js +0 -176
- package/src/mappings/Divider.js +0 -27
- package/src/mappings/FAB.js +0 -37
- package/src/mappings/Fetch.js +0 -13
- package/src/mappings/FieldSearchBarFull.js +0 -50
- package/src/mappings/FlashList.js +0 -33
- package/src/mappings/FlatList.js +0 -24
- package/src/mappings/HeaderLarge.js +0 -29
- package/src/mappings/HeaderMedium.js +0 -55
- package/src/mappings/HeaderOverline.js +0 -55
- package/src/mappings/Icon.js +0 -32
- package/src/mappings/IconButton.js +0 -35
- package/src/mappings/Image.js +0 -35
- package/src/mappings/ImageBackground.js +0 -29
- package/src/mappings/KeyboardAvoidingView.js +0 -41
- package/src/mappings/KeyboardAwareScrollView.js +0 -50
- package/src/mappings/Layout.js +0 -200
- package/src/mappings/LinearGradient.js +0 -77
- package/src/mappings/MapCallout.js +0 -21
- package/src/mappings/MapMarker.js +0 -47
- package/src/mappings/MapView.js +0 -139
- package/src/mappings/Modal.js +0 -42
- package/src/mappings/NativeBase/AlertDialog.js +0 -112
- package/src/mappings/NativeBase/AlertDialog.ts +0 -128
- package/src/mappings/NativeBase/Button.js +0 -84
- package/src/mappings/NativeBase/Button.ts +0 -83
- package/src/mappings/NativeBase/DataDisplay.js +0 -67
- package/src/mappings/NativeBase/DataDisplay.ts +0 -79
- package/src/mappings/NativeBase/Feedback.js +0 -89
- package/src/mappings/NativeBase/Feedback.ts +0 -100
- package/src/mappings/NativeBase/Layout.js +0 -140
- package/src/mappings/NativeBase/Layout.ts +0 -152
- package/src/mappings/NativeBase/Media.js +0 -56
- package/src/mappings/NativeBase/Media.ts +0 -65
- package/src/mappings/NativeBase/Menu.js +0 -134
- package/src/mappings/NativeBase/Menu.ts +0 -150
- package/src/mappings/NativeBase/Modal.js +0 -103
- package/src/mappings/NativeBase/Modal.ts +0 -118
- package/src/mappings/NativeBase/Other.js +0 -123
- package/src/mappings/NativeBase/Other.ts +0 -139
- package/src/mappings/NativeBase/Popover.js +0 -123
- package/src/mappings/NativeBase/Popover.ts +0 -136
- package/src/mappings/NativeBase/Select.js +0 -71
- package/src/mappings/NativeBase/Select.ts +0 -85
- package/src/mappings/NativeBase/Slider.js +0 -89
- package/src/mappings/NativeBase/Slider.ts +0 -105
- package/src/mappings/NumberInput.js +0 -254
- package/src/mappings/Picker.js +0 -148
- package/src/mappings/ProgressBar.js +0 -101
- package/src/mappings/ProgressCircle.js +0 -109
- package/src/mappings/ProgressIndicator.js +0 -181
- package/src/mappings/RadioButton.js +0 -51
- package/src/mappings/RadioButtonGroup.js +0 -17
- package/src/mappings/RadioButtonRow.js +0 -42
- package/src/mappings/RowBodyIcon.js +0 -75
- package/src/mappings/RowHeadlineImageCaption.js +0 -167
- package/src/mappings/RowHeadlineImageIcon.js +0 -99
- package/src/mappings/SVG.js +0 -20
- package/src/mappings/SafeAreaView.js +0 -33
- package/src/mappings/ScrollView.js +0 -31
- package/src/mappings/Slider.js +0 -60
- package/src/mappings/StarRating.js +0 -43
- package/src/mappings/Stepper.js +0 -32
- package/src/mappings/Surface.js +0 -14
- package/src/mappings/Swiper.js +0 -60
- package/src/mappings/SwiperItem.js +0 -8
- package/src/mappings/Switch.js +0 -81
- package/src/mappings/Text.js +0 -251
- package/src/mappings/TextArea.js +0 -274
- package/src/mappings/TextField.js +0 -391
- package/src/mappings/TextInput.js +0 -402
- package/src/mappings/ToggleButton.js +0 -50
- package/src/mappings/Touchable.js +0 -17
- package/src/mappings/Video.js +0 -81
- package/src/mappings/View.js +0 -207
- package/src/mappings/WebView.js +0 -88
- package/src/styles/DarkTheme.js +0 -26
- package/src/styles/DefaultTheme.js +0 -111
- package/src/styles/fonts.js +0 -62
- package/src/styles/overlay.js +0 -60
- package/src/styles/shadow.js +0 -51
- package/src/theming.js +0 -3
- package/src/utilities.js +0 -102
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, ImageBackground, StyleSheet, } from "react-native";
|
|
3
|
-
import { withTheme } from "../theming";
|
|
4
|
-
import Elevation from "./Elevation";
|
|
5
|
-
const Container = ({ useThemeGutterPadding, borderColor, borderWidth, backgroundColor, backgroundImage, backgroundImageResizeMode, elevation, style, children, theme, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
6
|
-
...rest }) => {
|
|
7
|
-
const { flex, flexGrow, flexWrap, flexBasis, flexShrink, flexDirection, alignContent, justifyContent, alignItems, padding, paddingTop, paddingBottom, paddingLeft, paddingRight, paddingVertical, paddingHorizontal, ...styleProp } = StyleSheet.flatten(style) || {};
|
|
8
|
-
const containerStyle = {
|
|
9
|
-
backgroundColor,
|
|
10
|
-
borderColor,
|
|
11
|
-
borderWidth,
|
|
12
|
-
width: "100%",
|
|
13
|
-
...styleProp,
|
|
14
|
-
};
|
|
15
|
-
const innerStyle = {
|
|
16
|
-
flex,
|
|
17
|
-
flexGrow,
|
|
18
|
-
flexWrap,
|
|
19
|
-
flexBasis,
|
|
20
|
-
flexShrink,
|
|
21
|
-
flexDirection,
|
|
22
|
-
alignContent,
|
|
23
|
-
justifyContent,
|
|
24
|
-
alignItems,
|
|
25
|
-
padding,
|
|
26
|
-
paddingTop,
|
|
27
|
-
paddingBottom,
|
|
28
|
-
paddingLeft,
|
|
29
|
-
paddingRight,
|
|
30
|
-
paddingVertical,
|
|
31
|
-
paddingHorizontal: paddingHorizontal || useThemeGutterPadding ? 16 : 0,
|
|
32
|
-
};
|
|
33
|
-
const Wrap = elevation ? Elevation : View;
|
|
34
|
-
if (elevation)
|
|
35
|
-
containerStyle.elevation = elevation;
|
|
36
|
-
return (React.createElement(Wrap, { style: [containerStyle, style], ...rest }, backgroundImage ? (React.createElement(ImageBackground, { source: typeof backgroundImage === "string"
|
|
37
|
-
? { uri: backgroundImage }
|
|
38
|
-
: backgroundImage, resizeMode: backgroundImageResizeMode, style: {
|
|
39
|
-
flex: 1,
|
|
40
|
-
} },
|
|
41
|
-
React.createElement(View, { style: innerStyle }, children))) : (React.createElement(View, { style: innerStyle }, children))));
|
|
42
|
-
};
|
|
43
|
-
export default withTheme(Container);
|
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { View, Animated, Text, StyleSheet, I18nManager, TextInput as NativeTextInput, } from "react-native";
|
|
3
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
-
import dateFormat from "dateformat";
|
|
5
|
-
import { withTheme } from "../../theming";
|
|
6
|
-
import Portal from "../Portal/Portal";
|
|
7
|
-
import Touchable from "../Touchable";
|
|
8
|
-
import DateTimePicker from "./DatePickerComponent";
|
|
9
|
-
import { extractStyles } from "../../utilities";
|
|
10
|
-
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
11
|
-
const FOCUS_ANIMATION_DURATION = 150;
|
|
12
|
-
const BLUR_ANIMATION_DURATION = 180;
|
|
13
|
-
const ICON_SIZE = 24;
|
|
14
|
-
const MONTHS = [
|
|
15
|
-
"January",
|
|
16
|
-
"February",
|
|
17
|
-
"March",
|
|
18
|
-
"April",
|
|
19
|
-
"May",
|
|
20
|
-
"June",
|
|
21
|
-
"July",
|
|
22
|
-
"August",
|
|
23
|
-
"September",
|
|
24
|
-
"October",
|
|
25
|
-
"November",
|
|
26
|
-
"December",
|
|
27
|
-
];
|
|
28
|
-
const DatePicker = ({ Icon, style, theme: { colors, typography, roundness, disabledOpacity }, date, onDateChange = () => { }, defaultValue, disabled = false, mode = "date", format, type = "underline", leftIconName, rightIconName, leftIconMode = "inset", label, labelSize, labelColor, placeholder, borderColor: inputBorderColor, borderColorActive: inputBorderColorActive, ...props }) => {
|
|
29
|
-
const [value, setValue] = React.useState(date || defaultValue);
|
|
30
|
-
React.useEffect(() => {
|
|
31
|
-
if (defaultValue != null) {
|
|
32
|
-
setValue(defaultValue);
|
|
33
|
-
}
|
|
34
|
-
}, [defaultValue]);
|
|
35
|
-
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
36
|
-
const [labeled] = React.useState(new Animated.Value(date ? 0 : 1));
|
|
37
|
-
const [placeholder1, setPlaceholder1] = React.useState("");
|
|
38
|
-
const [focused, setFocused] = React.useState(false);
|
|
39
|
-
const [labelLayout, setLabelLayout] = React.useState({ measured: false, width: 0 });
|
|
40
|
-
const { viewStyles, textStyles } = extractStyles(style);
|
|
41
|
-
const getValidDate = () => {
|
|
42
|
-
if (!value) {
|
|
43
|
-
return new Date();
|
|
44
|
-
}
|
|
45
|
-
return typeof (value === null || value === void 0 ? void 0 : value.getMonth) === "function" ? value : new Date();
|
|
46
|
-
};
|
|
47
|
-
const formatDate = () => {
|
|
48
|
-
if (!value)
|
|
49
|
-
return "";
|
|
50
|
-
let newDate = getValidDate();
|
|
51
|
-
if (format)
|
|
52
|
-
return dateFormat(newDate, format);
|
|
53
|
-
if (mode === "time") {
|
|
54
|
-
return `${newDate.toLocaleTimeString()}`;
|
|
55
|
-
}
|
|
56
|
-
if (mode === "datetime") {
|
|
57
|
-
return `${newDate.toLocaleString()}`;
|
|
58
|
-
}
|
|
59
|
-
return `${MONTHS[newDate.getMonth()]} ${newDate.getDate()}, ${newDate.getFullYear()}`;
|
|
60
|
-
};
|
|
61
|
-
const toggleVisibility = async () => {
|
|
62
|
-
setPickerVisible(!pickerVisible);
|
|
63
|
-
focused ? _handleBlur() : _handleFocus();
|
|
64
|
-
};
|
|
65
|
-
const insets = useSafeAreaInsets();
|
|
66
|
-
// const _restoreLabel = () =>
|
|
67
|
-
// Animated.timing(labeled, {
|
|
68
|
-
// toValue: 1,
|
|
69
|
-
// duration: FOCUS_ANIMATION_DURATION,
|
|
70
|
-
// useNativeDriver: true,
|
|
71
|
-
// }).start();
|
|
72
|
-
// const _minmizeLabel = () =>
|
|
73
|
-
// Animated.timing(labeled, {
|
|
74
|
-
// toValue: 0,
|
|
75
|
-
// duration: BLUR_ANIMATION_DURATION,
|
|
76
|
-
// useNativeDriver: true,
|
|
77
|
-
// }).start();
|
|
78
|
-
// const _showPlaceholder = () =>
|
|
79
|
-
// setTimeout(() => setPlaceholder1(placeholder || ""), 50);
|
|
80
|
-
const _hidePlaceholder = () => {
|
|
81
|
-
setPlaceholder1("");
|
|
82
|
-
};
|
|
83
|
-
React.useEffect(() => {
|
|
84
|
-
setValue(date);
|
|
85
|
-
}, [date]);
|
|
86
|
-
React.useEffect(() => {
|
|
87
|
-
if (value || focused || placeholder1) {
|
|
88
|
-
// _minmizeLabel();
|
|
89
|
-
Animated.timing(labeled, {
|
|
90
|
-
toValue: 0,
|
|
91
|
-
duration: BLUR_ANIMATION_DURATION,
|
|
92
|
-
useNativeDriver: true,
|
|
93
|
-
}).start();
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
// _restoreLabel();
|
|
97
|
-
Animated.timing(labeled, {
|
|
98
|
-
toValue: 1,
|
|
99
|
-
duration: FOCUS_ANIMATION_DURATION,
|
|
100
|
-
useNativeDriver: true,
|
|
101
|
-
}).start();
|
|
102
|
-
}
|
|
103
|
-
}, [value, focused, placeholder1, labeled]);
|
|
104
|
-
React.useEffect(() => {
|
|
105
|
-
const _showPlaceholder = () => setTimeout(() => setPlaceholder1(placeholder || ""), 50);
|
|
106
|
-
if (focused || !label) {
|
|
107
|
-
_showPlaceholder();
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
_hidePlaceholder();
|
|
111
|
-
}
|
|
112
|
-
return () => {
|
|
113
|
-
clearTimeout(_showPlaceholder());
|
|
114
|
-
};
|
|
115
|
-
}, [focused, label, placeholder]);
|
|
116
|
-
const _handleFocus = () => {
|
|
117
|
-
if (disabled) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
setFocused(true);
|
|
121
|
-
};
|
|
122
|
-
const _handleBlur = () => {
|
|
123
|
-
if (disabled) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
setFocused(false);
|
|
127
|
-
};
|
|
128
|
-
const MINIMIZED_LABEL_Y_OFFSET = -(typography.caption.lineHeight + 4);
|
|
129
|
-
const OUTLINE_MINIMIZED_LABEL_Y_OFFSET = -(16 * 0.5 + 4);
|
|
130
|
-
const MAXIMIZED_LABEL_FONT_SIZE = textStyles.fontSize || typography.subtitle1.fontSize;
|
|
131
|
-
const MINIMIZED_LABEL_FONT_SIZE = labelSize
|
|
132
|
-
? labelSize
|
|
133
|
-
: typography.caption.fontSize;
|
|
134
|
-
const hasActiveOutline = focused;
|
|
135
|
-
let inputTextColor, activeColor, underlineColor, borderColor, placeholderColor, containerStyle, backgroundColor, inputStyle;
|
|
136
|
-
inputTextColor = colors.strong;
|
|
137
|
-
if (disabled) {
|
|
138
|
-
activeColor = colors.light;
|
|
139
|
-
placeholderColor = colors.light;
|
|
140
|
-
borderColor = "transparent";
|
|
141
|
-
underlineColor = "transparent";
|
|
142
|
-
backgroundColor = colors.divider;
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
activeColor = inputBorderColorActive || colors.primary;
|
|
146
|
-
placeholderColor = inputBorderColor || colors.light;
|
|
147
|
-
underlineColor = inputBorderColor || colors.light;
|
|
148
|
-
backgroundColor = colors.background;
|
|
149
|
-
}
|
|
150
|
-
const { lineHeight, ...subtitle1 } = typography.subtitle1;
|
|
151
|
-
inputStyle = {
|
|
152
|
-
paddingVertical: 0,
|
|
153
|
-
color: inputTextColor,
|
|
154
|
-
paddingLeft: leftIconName && leftIconMode === "inset"
|
|
155
|
-
? ICON_SIZE + (type === "solid" ? 16 : 12)
|
|
156
|
-
: 0,
|
|
157
|
-
paddingRight: rightIconName ? ICON_SIZE + 16 + 4 : 12,
|
|
158
|
-
...subtitle1,
|
|
159
|
-
height: lineHeight,
|
|
160
|
-
};
|
|
161
|
-
if (type === "underline") {
|
|
162
|
-
containerStyle = {
|
|
163
|
-
borderTopLeftRadius: roundness,
|
|
164
|
-
borderTopRightRadius: roundness,
|
|
165
|
-
paddingBottom: 12,
|
|
166
|
-
marginTop: 16,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
containerStyle = {
|
|
171
|
-
borderRadius: roundness,
|
|
172
|
-
borderColor: hasActiveOutline ? activeColor : borderColor,
|
|
173
|
-
borderWidth: 1,
|
|
174
|
-
paddingTop: labeled ? 16 * 1.5 : 16,
|
|
175
|
-
paddingBottom: labeled ? 16 * 0.5 : 16,
|
|
176
|
-
opacity: disabled ? disabledOpacity : 1,
|
|
177
|
-
backgroundColor,
|
|
178
|
-
};
|
|
179
|
-
inputStyle.paddingHorizontal = 12;
|
|
180
|
-
}
|
|
181
|
-
if (leftIconName && leftIconMode === "outset") {
|
|
182
|
-
containerStyle.marginLeft = ICON_SIZE + 8;
|
|
183
|
-
}
|
|
184
|
-
let leftIconColor;
|
|
185
|
-
if (focused) {
|
|
186
|
-
leftIconColor = colors.primary;
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
leftIconColor = colors.light;
|
|
190
|
-
}
|
|
191
|
-
const leftIconProps = {
|
|
192
|
-
size: 24,
|
|
193
|
-
color: leftIconColor,
|
|
194
|
-
name: leftIconName || "",
|
|
195
|
-
};
|
|
196
|
-
const leftIconStyle = {
|
|
197
|
-
position: "absolute",
|
|
198
|
-
marginTop: type === "solid"
|
|
199
|
-
? leftIconMode === "inset"
|
|
200
|
-
? MINIMIZED_LABEL_FONT_SIZE + 4
|
|
201
|
-
: 16
|
|
202
|
-
: leftIconMode === "outset"
|
|
203
|
-
? 16
|
|
204
|
-
: 0,
|
|
205
|
-
};
|
|
206
|
-
const labelStyle = {
|
|
207
|
-
...typography.subtitle1,
|
|
208
|
-
top: type === "solid" ? 16 : 0,
|
|
209
|
-
fontFamily: textStyles === null || textStyles === void 0 ? void 0 : textStyles.fontFamily,
|
|
210
|
-
left: leftIconName && leftIconMode === "inset"
|
|
211
|
-
? ICON_SIZE + (type === "solid" ? 16 : 12)
|
|
212
|
-
: 0,
|
|
213
|
-
transform: [
|
|
214
|
-
{
|
|
215
|
-
// Move label to top
|
|
216
|
-
translateY: labeled.interpolate({
|
|
217
|
-
inputRange: [0, 1],
|
|
218
|
-
outputRange: [
|
|
219
|
-
type === "solid"
|
|
220
|
-
? OUTLINE_MINIMIZED_LABEL_Y_OFFSET
|
|
221
|
-
: MINIMIZED_LABEL_Y_OFFSET,
|
|
222
|
-
0,
|
|
223
|
-
],
|
|
224
|
-
}),
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
// Make label smaller
|
|
228
|
-
scale: labeled.interpolate({
|
|
229
|
-
inputRange: [0, 1],
|
|
230
|
-
outputRange: [
|
|
231
|
-
MINIMIZED_LABEL_FONT_SIZE / MAXIMIZED_LABEL_FONT_SIZE,
|
|
232
|
-
1,
|
|
233
|
-
],
|
|
234
|
-
}),
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
// Offset label scale since RN doesn't support transform origin
|
|
238
|
-
translateX: labeled.interpolate({
|
|
239
|
-
inputRange: [0, 1],
|
|
240
|
-
outputRange: [
|
|
241
|
-
-(1 - MINIMIZED_LABEL_FONT_SIZE / MAXIMIZED_LABEL_FONT_SIZE) *
|
|
242
|
-
(labelLayout.width / 2),
|
|
243
|
-
0,
|
|
244
|
-
],
|
|
245
|
-
}),
|
|
246
|
-
},
|
|
247
|
-
],
|
|
248
|
-
};
|
|
249
|
-
const inputStyles = [
|
|
250
|
-
styles.input,
|
|
251
|
-
inputStyle,
|
|
252
|
-
type === "solid" ? { marginHorizontal: 12 } : {},
|
|
253
|
-
];
|
|
254
|
-
// const render = (props) => <NativeTextInput {...props} />;
|
|
255
|
-
return (React.createElement(View, { style: [styles.container, style] },
|
|
256
|
-
React.createElement(Touchable, { disabled: disabled, onPress: toggleVisibility },
|
|
257
|
-
React.createElement(View, { pointerEvents: "none" },
|
|
258
|
-
React.createElement(View, { style: [styles.container, style] },
|
|
259
|
-
leftIconName && leftIconMode === "outset" ? (React.createElement(Icon, { ...leftIconProps, style: leftIconStyle })) : null,
|
|
260
|
-
React.createElement(View, { style: [
|
|
261
|
-
containerStyle,
|
|
262
|
-
style ? { height: style.height } : {},
|
|
263
|
-
viewStyles,
|
|
264
|
-
] },
|
|
265
|
-
type === "underline" ? (
|
|
266
|
-
// When type === 'flat', render an underline
|
|
267
|
-
React.createElement(Animated.View, { style: [
|
|
268
|
-
styles.underline,
|
|
269
|
-
{
|
|
270
|
-
backgroundColor: focused ? activeColor : underlineColor,
|
|
271
|
-
// Underlines is thinner when input is not focused
|
|
272
|
-
transform: [{ scaleY: focused ? 1 : 0.5 }],
|
|
273
|
-
},
|
|
274
|
-
] })) : null,
|
|
275
|
-
label ? (
|
|
276
|
-
// Position colored placeholder and gray placeholder on top of each other and crossfade them
|
|
277
|
-
// This gives the effect of animating the color, but allows us to use native driver
|
|
278
|
-
React.createElement(View, { pointerEvents: "none", style: [
|
|
279
|
-
StyleSheet.absoluteFill,
|
|
280
|
-
{
|
|
281
|
-
opacity:
|
|
282
|
-
// Hide the label in minimized state until we measure its width
|
|
283
|
-
date || focused ? (labelLayout.measured ? 1 : 0) : 1,
|
|
284
|
-
},
|
|
285
|
-
] },
|
|
286
|
-
React.createElement(AnimatedText, { onLayout: (e) => setLabelLayout({
|
|
287
|
-
width: e.nativeEvent.layout.width,
|
|
288
|
-
measured: true,
|
|
289
|
-
}), style: [
|
|
290
|
-
styles.placeholder,
|
|
291
|
-
type === "solid" ? { paddingHorizontal: 12 } : {},
|
|
292
|
-
labelStyle,
|
|
293
|
-
{
|
|
294
|
-
color: labelColor || colors.light,
|
|
295
|
-
opacity: labeled.interpolate({
|
|
296
|
-
inputRange: [0, 1],
|
|
297
|
-
outputRange: [hasActiveOutline ? 1 : 0, 0],
|
|
298
|
-
}),
|
|
299
|
-
},
|
|
300
|
-
], numberOfLines: 1 }, label),
|
|
301
|
-
React.createElement(AnimatedText, { style: [
|
|
302
|
-
styles.placeholder,
|
|
303
|
-
type === "solid" ? { paddingHorizontal: 12 } : {},
|
|
304
|
-
labelStyle,
|
|
305
|
-
{
|
|
306
|
-
color: labelColor || placeholderColor,
|
|
307
|
-
opacity: hasActiveOutline ? labeled : 1,
|
|
308
|
-
},
|
|
309
|
-
], numberOfLines: 1 }, label))) : null,
|
|
310
|
-
leftIconName && leftIconMode === "inset" ? (React.createElement(Icon, { ...leftIconProps, style: {
|
|
311
|
-
...leftIconStyle,
|
|
312
|
-
marginLeft: type === "solid" ? 16 : 0,
|
|
313
|
-
} })) : null,
|
|
314
|
-
React.createElement(NativeTextInput, { value: formatDate(), placeholder: label ? placeholder1 : placeholder, editable: !disabled, placeholderTextColor: placeholderColor, selectionColor: activeColor, onFocus: _handleFocus, onBlur: _handleBlur, underlineColorAndroid: "transparent", style: [inputStyles, textStyles], ...props })),
|
|
315
|
-
rightIconName ? (React.createElement(Icon, { name: rightIconName, size: ICON_SIZE, color: colors.light, style: {
|
|
316
|
-
position: "absolute",
|
|
317
|
-
right: 16,
|
|
318
|
-
marginTop: type === "solid" ? MINIMIZED_LABEL_FONT_SIZE + 4 : 16,
|
|
319
|
-
} })) : null))),
|
|
320
|
-
pickerVisible && (React.createElement(Portal, null,
|
|
321
|
-
React.createElement(View, { style: [
|
|
322
|
-
styles.picker,
|
|
323
|
-
{
|
|
324
|
-
backgroundColor: colors.divider,
|
|
325
|
-
},
|
|
326
|
-
] },
|
|
327
|
-
React.createElement(View, { style: [
|
|
328
|
-
styles.pickerContainer,
|
|
329
|
-
{
|
|
330
|
-
paddingTop: insets.top,
|
|
331
|
-
paddingBottom: insets.bottom,
|
|
332
|
-
paddingLeft: insets.left,
|
|
333
|
-
paddingRight: insets.right,
|
|
334
|
-
},
|
|
335
|
-
] },
|
|
336
|
-
React.createElement(DateTimePicker, { value: getValidDate(), mode: mode, isVisible: pickerVisible, toggleVisibility: toggleVisibility, onChange: (_event, data) => {
|
|
337
|
-
toggleVisibility();
|
|
338
|
-
setValue(data);
|
|
339
|
-
onDateChange(data);
|
|
340
|
-
} })))))));
|
|
341
|
-
};
|
|
342
|
-
const styles = StyleSheet.create({
|
|
343
|
-
container: {
|
|
344
|
-
alignSelf: "stretch",
|
|
345
|
-
},
|
|
346
|
-
picker: {
|
|
347
|
-
position: "absolute",
|
|
348
|
-
bottom: 0,
|
|
349
|
-
left: 0,
|
|
350
|
-
right: 0,
|
|
351
|
-
flexDirection: "row",
|
|
352
|
-
justifyContent: "center",
|
|
353
|
-
},
|
|
354
|
-
underline: {
|
|
355
|
-
position: "absolute",
|
|
356
|
-
left: 0,
|
|
357
|
-
right: 0,
|
|
358
|
-
bottom: 0,
|
|
359
|
-
height: 2,
|
|
360
|
-
},
|
|
361
|
-
input: {
|
|
362
|
-
flexGrow: 1,
|
|
363
|
-
justifyContent: "center",
|
|
364
|
-
textAlignVertical: "center",
|
|
365
|
-
margin: 0,
|
|
366
|
-
textAlign: I18nManager.isRTL ? "right" : "left",
|
|
367
|
-
},
|
|
368
|
-
placeholder: {
|
|
369
|
-
position: "absolute",
|
|
370
|
-
left: 0,
|
|
371
|
-
},
|
|
372
|
-
pickerContainer: { flexDirection: "column", width: "100%", zIndex: 100 },
|
|
373
|
-
closeButton: {
|
|
374
|
-
alignSelf: "flex-end",
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
export default withTheme(DatePicker);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Platform } from "react-native";
|
|
3
|
-
import DateTimePicker from "@react-native-community/datetimepicker";
|
|
4
|
-
import DateTimePickerModal from "react-native-modal-datetime-picker";
|
|
5
|
-
const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, }) => {
|
|
6
|
-
return Platform.OS === "ios" || Platform.OS === "android" ? (React.createElement(DateTimePickerModal, { date: value, mode: mode, isVisible: true, display: Platform.OS === "ios" ? "spinner" : "default", onCancel: () => {
|
|
7
|
-
console.log("Picker cancelled before selecting anything.");
|
|
8
|
-
toggleVisibility();
|
|
9
|
-
}, onConfirm: (data) => {
|
|
10
|
-
onChange(null, data);
|
|
11
|
-
} })) : (React.createElement(DateTimePicker, { value: value, mode: mode, onChange: onChange, display: "default" }));
|
|
12
|
-
};
|
|
13
|
-
export default DatePickerComponent;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import DateFnsUtils from "@date-io/date-fns";
|
|
3
|
-
import { MuiPickersUtilsProvider, DatePicker, TimePicker, DateTimePicker, } from "@material-ui/pickers";
|
|
4
|
-
import { createMuiTheme, ThemeProvider } from "@material-ui/core/styles";
|
|
5
|
-
import { withTheme } from "../../theming";
|
|
6
|
-
import Theme from "../../styles/DefaultTheme";
|
|
7
|
-
const DatePickerComponent = ({ value, onChange, mode, toggleVisibility, isVisible, theme, }) => {
|
|
8
|
-
const internalTheme = createMuiTheme({
|
|
9
|
-
palette: {
|
|
10
|
-
primary: {
|
|
11
|
-
main: theme.colors.primary || Theme.colors.primary,
|
|
12
|
-
},
|
|
13
|
-
secondary: {
|
|
14
|
-
main: theme.colors.secondary || Theme.colors.secondary,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
const Picker = mode === "date"
|
|
19
|
-
? DatePicker
|
|
20
|
-
: mode === "time"
|
|
21
|
-
? TimePicker
|
|
22
|
-
: DateTimePicker;
|
|
23
|
-
return (React.createElement(MuiPickersUtilsProvider, { utils: DateFnsUtils },
|
|
24
|
-
React.createElement(ThemeProvider, { theme: internalTheme },
|
|
25
|
-
React.createElement(Picker, { value: value, open: isVisible, onChange: (d) => {
|
|
26
|
-
toggleVisibility();
|
|
27
|
-
onChange(null, d);
|
|
28
|
-
}, onClose: () => toggleVisibility(), variant: "dialog", TextFieldComponent: () => null }))));
|
|
29
|
-
};
|
|
30
|
-
export default withTheme(DatePickerComponent);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { ActivityIndicator, View, Text, StyleSheet, } from "react-native";
|
|
3
|
-
import color from "color";
|
|
4
|
-
import Config from "./Config";
|
|
5
|
-
import Touchable from "./Touchable";
|
|
6
|
-
import Elevation from "./Elevation";
|
|
7
|
-
import { withTheme } from "../theming";
|
|
8
|
-
const Button = ({ Icon, icon, disabled = false, type = "solid", loading = false, labelColor, color: colorOverride, children, onPress, elevation = 0, style, theme: { colors, disabledOpacity, roundness, typography }, ...rest }) => {
|
|
9
|
-
let backgroundColor, borderColor, textColor, borderWidth;
|
|
10
|
-
const buttonColor = colorOverride || colors.primary;
|
|
11
|
-
if (type === "solid") {
|
|
12
|
-
backgroundColor = buttonColor;
|
|
13
|
-
if (disabled) {
|
|
14
|
-
textColor = color(colors.surface).alpha(disabledOpacity).rgb().string();
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
textColor = labelColor || colors.surface;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
backgroundColor = "transparent";
|
|
22
|
-
if (disabled) {
|
|
23
|
-
textColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
textColor = labelColor || buttonColor;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (type === "outline") {
|
|
30
|
-
if (disabled) {
|
|
31
|
-
borderColor = color(buttonColor).alpha(disabledOpacity).rgb().string();
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
borderColor = buttonColor;
|
|
35
|
-
}
|
|
36
|
-
borderWidth = StyleSheet.hairlineWidth;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
borderColor = "transparent";
|
|
40
|
-
borderWidth = 0;
|
|
41
|
-
}
|
|
42
|
-
const buttonStyle = {
|
|
43
|
-
backgroundColor,
|
|
44
|
-
borderColor,
|
|
45
|
-
borderWidth,
|
|
46
|
-
borderRadius: roundness,
|
|
47
|
-
};
|
|
48
|
-
const textStyle = {
|
|
49
|
-
textAlign: "center",
|
|
50
|
-
color: textColor,
|
|
51
|
-
marginVertical: 16,
|
|
52
|
-
marginHorizontal: 16,
|
|
53
|
-
};
|
|
54
|
-
const iconStyle = [
|
|
55
|
-
styles.icon,
|
|
56
|
-
{
|
|
57
|
-
marginLeft: 16,
|
|
58
|
-
marginRight: -8,
|
|
59
|
-
width: Config.buttonIconSize,
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
const { margin, marginEnd, marginTop, marginLeft, marginRight, marginBottom, marginHorizontal, marginVertical, ...innerStyles } = StyleSheet.flatten(style || {});
|
|
63
|
-
const margins = {
|
|
64
|
-
margin,
|
|
65
|
-
marginEnd,
|
|
66
|
-
marginTop,
|
|
67
|
-
marginLeft,
|
|
68
|
-
marginRight,
|
|
69
|
-
marginBottom,
|
|
70
|
-
marginHorizontal,
|
|
71
|
-
marginVertical,
|
|
72
|
-
};
|
|
73
|
-
return (React.createElement(Elevation, { style: { elevation, alignSelf: "stretch", ...margins } },
|
|
74
|
-
React.createElement(Touchable, { ...rest, onPress: onPress, accessibilityState: { disabled }, accessibilityRole: "button", disabled: disabled || loading, style: [styles.button, buttonStyle, innerStyles] },
|
|
75
|
-
React.createElement(View, { style: styles.content },
|
|
76
|
-
icon && loading !== true ? (React.createElement(View, { style: iconStyle },
|
|
77
|
-
React.createElement(Icon, { name: icon, size: Config.buttonIconSize, color: textColor }))) : null,
|
|
78
|
-
loading ? (React.createElement(ActivityIndicator, { size: "small", color: textColor, style: iconStyle })) : null,
|
|
79
|
-
React.createElement(Text, { numberOfLines: 1, style: [textStyle, typography.button] }, children)))));
|
|
80
|
-
};
|
|
81
|
-
const styles = StyleSheet.create({
|
|
82
|
-
button: {
|
|
83
|
-
minWidth: 64,
|
|
84
|
-
borderStyle: "solid",
|
|
85
|
-
},
|
|
86
|
-
content: {
|
|
87
|
-
flexDirection: "row",
|
|
88
|
-
alignItems: "center",
|
|
89
|
-
justifyContent: "center",
|
|
90
|
-
},
|
|
91
|
-
icon: {
|
|
92
|
-
width: Config.buttonIconSize,
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
export default withTheme(Button);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { withTheme } from "../theming";
|
|
3
|
-
import Touchable from "./Touchable";
|
|
4
|
-
const getWidth = (numColumns) => {
|
|
5
|
-
switch (numColumns) {
|
|
6
|
-
case 1:
|
|
7
|
-
return "33%";
|
|
8
|
-
case 2:
|
|
9
|
-
return "50%";
|
|
10
|
-
default:
|
|
11
|
-
return "100%";
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const Card = ({ numColumns = 3, children, onPress, style, ...rest }) => {
|
|
15
|
-
const width = getWidth(numColumns);
|
|
16
|
-
return (React.createElement(Touchable, { disabled: !onPress, onPress: onPress, style: [style, { width }], ...rest }, children));
|
|
17
|
-
};
|
|
18
|
-
export default withTheme(Card);
|