@draftbit/core 46.4.4-c5d4b3.2 → 46.4.4-caab07.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/Provider.js.map +1 -1
- package/lib/commonjs/components/ActionSheet/ActionSheet.js.map +1 -1
- package/lib/commonjs/components/ActionSheet/ActionSheetCancel.js.map +1 -1
- package/lib/commonjs/components/ActionSheet/index.js.map +1 -1
- package/lib/commonjs/components/AvatarEdit.js +15 -4
- package/lib/commonjs/components/AvatarEdit.js.map +1 -1
- package/lib/commonjs/components/Banner.js +23 -4
- package/lib/commonjs/components/Banner.js.map +1 -1
- package/lib/commonjs/components/CardBlock.js +13 -4
- package/lib/commonjs/components/CardContainer.js +14 -4
- package/lib/commonjs/components/CardContainer.js.map +1 -1
- package/lib/commonjs/components/Carousel.js +2 -2
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +22 -5
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxRow.js.map +1 -1
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/CircleImage.js +16 -2
- package/lib/commonjs/components/Config.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +43 -21
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/DeprecatedButton.js +19 -3
- package/lib/commonjs/components/DeprecatedButton.js.map +1 -1
- package/lib/commonjs/components/Divider.js +12 -1
- package/lib/commonjs/components/Divider.js.map +1 -1
- package/lib/commonjs/components/FAB.js +19 -4
- package/lib/commonjs/components/FAB.js.map +1 -1
- package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/components/FormRow.js +17 -3
- package/lib/commonjs/components/FormRow.js.map +1 -1
- package/lib/commonjs/components/Header.js.map +1 -1
- package/lib/commonjs/components/HeaderLarge.js.map +1 -1
- package/lib/commonjs/components/Image.js +16 -2
- package/lib/commonjs/components/Picker/Picker.js +7 -7
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +19 -5
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +30 -11
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -1
- package/lib/commonjs/components/Portal/PortalHost.js +45 -15
- package/lib/commonjs/components/Portal/PortalHost.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js +10 -1
- package/lib/commonjs/components/RadioButton/RadioButtonFieldGroup.js.map +1 -1
- package/lib/commonjs/components/ResizeMode.js +2 -1
- package/lib/commonjs/components/RowBodyIcon.js.map +1 -1
- package/lib/commonjs/components/RowHeadlineImageCaption.js.map +1 -1
- package/lib/commonjs/components/ScreenContainer.js +20 -4
- package/lib/commonjs/components/ScreenContainer.js.map +1 -1
- package/lib/commonjs/components/Stepper.js +1 -0
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/components/Surface.js +13 -2
- package/lib/commonjs/components/Swiper/index.js.map +1 -1
- package/lib/commonjs/components/Text.js +50 -4
- package/lib/commonjs/components/TextField.js +76 -28
- package/lib/commonjs/components/ToggleButton.js +14 -2
- package/lib/commonjs/components/ToggleButton.js.map +1 -1
- package/lib/commonjs/components/Typography.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/interfaces/Icon.js.map +1 -1
- package/lib/commonjs/mappings/AccordionItem.js.map +1 -1
- package/lib/commonjs/mappings/ActionSheet.js.map +1 -1
- package/lib/commonjs/mappings/ActionSheetItem.js.map +1 -1
- package/lib/commonjs/mappings/AudioPlayer.js.map +1 -1
- package/lib/commonjs/mappings/AvatarEdit.js.map +1 -1
- package/lib/commonjs/mappings/BlurView.js.map +1 -1
- package/lib/commonjs/mappings/Card.js.map +1 -1
- package/lib/commonjs/mappings/CardInline.js.map +1 -1
- package/lib/commonjs/mappings/Carousel.js.map +1 -1
- package/lib/commonjs/mappings/CheckboxRow.js.map +1 -1
- package/lib/commonjs/mappings/DatePicker.js +13 -0
- package/lib/commonjs/mappings/DatePicker.js.map +1 -1
- package/lib/commonjs/mappings/Fetch.js.map +1 -1
- package/lib/commonjs/mappings/FieldSearchBarFull.js +1 -1
- package/lib/commonjs/mappings/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/mappings/HeaderLarge.js.map +1 -1
- package/lib/commonjs/mappings/HeaderMedium.js.map +1 -1
- package/lib/commonjs/mappings/ProgressCircle.js.map +1 -1
- package/lib/commonjs/mappings/ProgressIndicator.js.map +1 -1
- package/lib/commonjs/mappings/RadioButton.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
- package/lib/commonjs/mappings/Stepper.js.map +1 -1
- package/lib/commonjs/mappings/Surface.js.map +1 -1
- package/lib/commonjs/mappings/Swiper.js.map +1 -1
- package/lib/commonjs/mappings/SwiperItem.js.map +1 -1
- package/lib/commonjs/mappings/Switch.js.map +1 -1
- package/lib/commonjs/mappings/TextArea.js.map +1 -1
- package/lib/commonjs/mappings/TextField.js.map +1 -1
- package/lib/commonjs/mappings/View.js.map +1 -1
- package/lib/commonjs/utilities.js +1 -2
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/Accordion/index.js.map +1 -1
- package/lib/module/components/ActionSheet/ActionSheet.js.map +1 -1
- package/lib/module/components/ActionSheet/ActionSheetItem.js.map +1 -1
- package/lib/module/components/Banner.js.map +1 -1
- package/lib/module/components/Button.js.map +1 -1
- package/lib/module/components/Card.js.map +1 -1
- package/lib/module/components/CardBlock.js +14 -4
- package/lib/module/components/CardBlock.js.map +1 -1
- package/lib/module/components/CardContainerShortImage.js +16 -4
- package/lib/module/components/CardContainerShortImage.js.map +1 -1
- package/lib/module/components/Carousel.js +27 -9
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/Checkbox/CheckboxGroup.js +17 -2
- package/lib/module/components/Checkbox/CheckboxGroup.js.map +1 -1
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Container.js +16 -4
- package/lib/module/components/Container.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +44 -21
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponent.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponentType.js.map +1 -1
- package/lib/module/components/DeprecatedFAB.js +21 -3
- package/lib/module/components/Elevation.js +15 -2
- package/lib/module/components/Elevation.js.map +1 -1
- package/lib/module/components/HeaderLarge.js.map +1 -1
- package/lib/module/components/HeaderMedium.js.map +1 -1
- package/lib/module/components/Justification.js +2 -2
- package/lib/module/components/Layout.js +41 -21
- package/lib/module/components/Layout.js.map +1 -1
- package/lib/module/components/NumberInput.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +2 -2
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +19 -4
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.ios.js +32 -11
- package/lib/module/components/Picker/PickerComponent.web.js +20 -4
- package/lib/module/components/Picker/PickerTypes.js.map +1 -1
- package/lib/module/components/Portal/PortalHost.js +45 -15
- package/lib/module/components/Portal/PortalHost.js.map +1 -1
- package/lib/module/components/Portal/PortalManager.js +34 -7
- package/lib/module/components/ProgressBar.js +38 -7
- package/lib/module/components/RadioButton/RadioButtonFieldGroup.js +10 -1
- package/lib/module/components/RadioButton/RadioButtonFieldGroup.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +23 -6
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/Row.js.map +1 -1
- package/lib/module/components/RowBodyIcon.js.map +1 -1
- package/lib/module/components/SVG.js.map +1 -1
- package/lib/module/components/ScreenContainer.js +20 -4
- package/lib/module/components/ScreenContainer.js.map +1 -1
- package/lib/module/components/Stepper.js +2 -2
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/components/Surface.js +15 -1
- package/lib/module/components/Swiper/Swiper.js.map +1 -1
- package/lib/module/components/Swiper/SwiperItem.js.map +1 -1
- package/lib/module/components/Switch.js +20 -10
- package/lib/module/components/Switch.js.map +1 -1
- package/lib/module/components/Text.js +50 -4
- package/lib/module/components/TextField.js +78 -28
- package/lib/module/components/TextField.js.map +1 -1
- package/lib/module/components/ToggleButton.js +16 -2
- package/lib/module/components/ToggleButton.js.map +1 -1
- package/lib/module/constants.js +1 -1
- package/lib/module/hooks.js +1 -3
- package/lib/module/mappings/Accordion.js.map +1 -1
- package/lib/module/mappings/AccordionItem.js.map +1 -1
- package/lib/module/mappings/ActionSheetCancel.js.map +1 -1
- package/lib/module/mappings/AudioPlayer.js.map +1 -1
- package/lib/module/mappings/Banner.js.map +1 -1
- package/lib/module/mappings/Button.js.map +1 -1
- package/lib/module/mappings/Card.js.map +1 -1
- package/lib/module/mappings/CardContainer.js.map +1 -1
- package/lib/module/mappings/CardInline.js.map +1 -1
- package/lib/module/mappings/Carousel.js.map +1 -1
- package/lib/module/mappings/CustomCode.js.map +1 -1
- package/lib/module/mappings/DatePicker.js +14 -1
- package/lib/module/mappings/DatePicker.js.map +1 -1
- package/lib/module/mappings/Divider.js.map +1 -1
- package/lib/module/mappings/FAB.js.map +1 -1
- package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -1
- package/lib/module/mappings/MapCallout.js.map +1 -1
- package/lib/module/mappings/MapMarker.js.map +1 -1
- package/lib/module/mappings/Modal.js.map +1 -1
- package/lib/module/mappings/RadioButton.js.map +1 -1
- package/lib/module/mappings/RowHeadlineImageIcon.js.map +1 -1
- package/lib/module/mappings/SVG.js.map +1 -1
- package/lib/module/mappings/SafeAreaView.js.map +1 -1
- package/lib/module/mappings/ScrollView.js.map +1 -1
- package/lib/module/mappings/SwiperItem.js.map +1 -1
- package/lib/module/mappings/Text.js.map +1 -1
- package/lib/module/mappings/TextArea.js.map +1 -1
- package/lib/module/mappings/Video.js.map +1 -1
- package/lib/module/styles/DarkTheme.js.map +1 -1
- package/lib/module/styles/DefaultTheme.js.map +1 -1
- package/lib/module/styles/fonts.js.map +1 -1
- package/lib/module/theming.js.map +1 -1
- package/lib/module/utilities.js +1 -2
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/DatePicker/DatePicker.d.ts +4 -0
- package/lib/typescript/src/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/lib/typescript/src/components/Picker/Picker.d.ts.map +1 -1
- package/lib/typescript/src/mappings/DatePicker.d.ts +42 -0
- package/lib/typescript/src/mappings/DatePicker.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/Provider.js +11 -4
- package/src/components/Accordion/AccordionGroup.js +80 -36
- package/src/components/Accordion/AccordionItem.js +51 -24
- package/src/components/ActionSheet/ActionSheet.js +60 -35
- package/src/components/ActionSheet/ActionSheetCancel.js +7 -2
- package/src/components/ActionSheet/ActionSheetItem.js +35 -24
- package/src/components/AnimatedCircularProgress.js +57 -38
- package/src/components/AspectRatio.js +21 -13
- package/src/components/AvatarEdit.js +46 -23
- package/src/components/Banner.js +151 -99
- package/src/components/Button.js +152 -97
- package/src/components/Card.js +126 -45
- package/src/components/CardBlock.js +109 -46
- package/src/components/CardContainer.js +140 -58
- package/src/components/CardContainerRating.js +152 -67
- package/src/components/CardContainerShortImage.js +80 -25
- package/src/components/CardInline.js +64 -25
- package/src/components/Carousel.js +99 -58
- package/src/components/Carousel.tsx +2 -2
- package/src/components/Checkbox/Checkbox.js +93 -55
- package/src/components/Checkbox/CheckboxGroup.js +28 -15
- package/src/components/Checkbox/CheckboxGroupRow.js +104 -59
- package/src/components/Checkbox/CheckboxRow.js +107 -61
- package/src/components/Checkbox/context.js +6 -6
- package/src/components/CircleImage.js +14 -4
- package/src/components/CircularProgress.js +146 -75
- package/src/components/Config.js +59 -52
- package/src/components/Container.js +80 -38
- package/src/components/DatePicker/DatePicker.js +480 -337
- package/src/components/DatePicker/DatePicker.tsx +23 -7
- package/src/components/DatePicker/DatePickerComponent.js +21 -7
- package/src/components/DatePicker/DatePickerComponent.web.js +48 -22
- package/src/components/DeprecatedButton.js +136 -82
- package/src/components/DeprecatedCardWrapper.js +19 -10
- package/src/components/DeprecatedFAB.js +146 -101
- package/src/components/Divider.js +10 -7
- package/src/components/Elevation.js +24 -13
- package/src/components/FAB.js +84 -38
- package/src/components/FieldSearchBarFull.js +83 -46
- package/src/components/FormRow.js +28 -12
- package/src/components/Header.js +79 -35
- package/src/components/HeaderLarge.js +19 -2
- package/src/components/HeaderMedium.js +19 -2
- package/src/components/HeaderOverline.js +20 -2
- package/src/components/IconButton.js +68 -29
- package/src/components/Image.js +52 -38
- package/src/components/Layout.js +99 -38
- package/src/components/NumberInput.js +46 -42
- package/src/components/Picker/Picker.js +411 -238
- package/src/components/Picker/Picker.tsx +2 -2
- package/src/components/Picker/PickerComponent.android.js +110 -57
- package/src/components/Picker/PickerComponent.ios.js +131 -63
- package/src/components/Picker/PickerComponent.web.js +111 -58
- package/src/components/Portal/Portal.js +10 -5
- package/src/components/Portal/PortalConsumer.js +25 -23
- package/src/components/Portal/PortalHost.js +83 -72
- package/src/components/Portal/PortalManager.js +38 -25
- package/src/components/ProgressBar.js +139 -111
- package/src/components/ProgressCircle.js +40 -7
- package/src/components/ProgressIndicator.js +43 -22
- package/src/components/RadioButton/RadioButton.js +37 -10
- package/src/components/RadioButton/RadioButtonFieldGroup.js +26 -10
- package/src/components/RadioButton/RadioButtonGroup.js +53 -35
- package/src/components/RadioButton/RadioButtonRow.js +105 -58
- package/src/components/RadioButton/context.js +6 -6
- package/src/components/Row.js +81 -41
- package/src/components/RowBodyIcon.js +24 -2
- package/src/components/RowHeadlineImageCaption.js +30 -6
- package/src/components/RowHeadlineImageIcon.js +34 -8
- package/src/components/SVG.js +27 -7
- package/src/components/ScreenContainer.js +56 -27
- package/src/components/Slider.js +95 -49
- package/src/components/StarRating.js +85 -44
- package/src/components/StepIndicator.js +416 -328
- package/src/components/Stepper.js +74 -32
- package/src/components/Stepper.tsx +1 -1
- package/src/components/Surface.js +40 -25
- package/src/components/Swiper/Swiper.js +49 -18
- package/src/components/Swiper/SwiperItem.js +5 -4
- package/src/components/Switch.js +102 -46
- package/src/components/Text.js +37 -23
- package/src/components/TextField.js +515 -398
- package/src/components/ToggleButton.js +56 -31
- package/src/components/Touchable.js +25 -9
- package/src/components/Typography.js +45 -27
- package/src/components/useAuthState.js +27 -27
- package/src/constants.js +7 -5
- package/src/hooks.js +9 -9
- package/src/index.js +19 -3
- package/src/interfaces/Icon.js +2 -1
- package/src/mappings/Accordion.js +47 -39
- package/src/mappings/AccordionItem.js +19 -14
- package/src/mappings/ActionSheet.js +10 -10
- package/src/mappings/ActionSheetCancel.js +24 -17
- package/src/mappings/ActionSheetItem.js +28 -21
- package/src/mappings/ActivityIndicator.js +64 -55
- package/src/mappings/AudioPlayer.js +23 -17
- package/src/mappings/AvatarEdit.js +40 -34
- package/src/mappings/Banner.js +37 -30
- package/src/mappings/BlurView.js +46 -38
- package/src/mappings/Button.js +86 -77
- package/src/mappings/Card.js +61 -50
- package/src/mappings/CardBlock.js +125 -114
- package/src/mappings/CardContainer.js +108 -98
- package/src/mappings/CardContainerRating.js +126 -117
- package/src/mappings/CardContainerShortImage.js +125 -116
- package/src/mappings/CardInline.js +57 -49
- package/src/mappings/Carousel.js +21 -16
- package/src/mappings/Checkbox.js +54 -44
- package/src/mappings/CheckboxGroup.js +34 -24
- package/src/mappings/CheckboxRow.js +71 -59
- package/src/mappings/CircleImage.js +29 -22
- package/src/mappings/Container.js +37 -27
- package/src/mappings/CustomCode.js +5 -5
- package/src/mappings/DatePicker.js +181 -149
- package/src/mappings/DatePicker.ts +23 -0
- package/src/mappings/Divider.js +30 -24
- package/src/mappings/FAB.js +45 -35
- package/src/mappings/Fetch.js +10 -9
- package/src/mappings/FieldSearchBarFull.js +55 -47
- package/src/mappings/FlashList.js +38 -31
- package/src/mappings/FlatList.js +27 -22
- package/src/mappings/HeaderLarge.js +34 -26
- package/src/mappings/HeaderMedium.js +59 -52
- package/src/mappings/HeaderOverline.js +59 -52
- package/src/mappings/Icon.js +36 -29
- package/src/mappings/IconButton.js +43 -33
- package/src/mappings/Image.js +40 -32
- package/src/mappings/ImageBackground.js +38 -27
- package/src/mappings/KeyboardAvoidingView.js +46 -38
- package/src/mappings/KeyboardAwareScrollView.js +60 -48
- package/src/mappings/Layout.js +198 -192
- package/src/mappings/LinearGradient.js +79 -74
- package/src/mappings/MapCallout.js +27 -19
- package/src/mappings/MapMarker.js +53 -45
- package/src/mappings/MapView.js +146 -135
- package/src/mappings/Modal.js +47 -39
- package/src/mappings/NumberInput.js +247 -229
- package/src/mappings/Picker.js +153 -140
- package/src/mappings/ProgressBar.js +106 -98
- package/src/mappings/ProgressCircle.js +112 -105
- package/src/mappings/ProgressIndicator.js +186 -178
- package/src/mappings/RadioButton.js +59 -49
- package/src/mappings/RadioButtonGroup.js +21 -15
- package/src/mappings/RadioButtonRow.js +48 -40
- package/src/mappings/RowBodyIcon.js +77 -71
- package/src/mappings/RowHeadlineImageCaption.js +171 -161
- package/src/mappings/RowHeadlineImageIcon.js +98 -84
- package/src/mappings/SVG.js +22 -18
- package/src/mappings/SafeAreaView.js +35 -30
- package/src/mappings/ScrollView.js +36 -29
- package/src/mappings/Slider.js +67 -58
- package/src/mappings/StarRating.js +49 -41
- package/src/mappings/Stepper.js +34 -26
- package/src/mappings/Surface.js +16 -12
- package/src/mappings/Swiper.js +65 -58
- package/src/mappings/SwiperItem.js +5 -5
- package/src/mappings/Switch.js +87 -76
- package/src/mappings/Text.js +265 -242
- package/src/mappings/TextArea.js +273 -259
- package/src/mappings/TextField.js +379 -358
- package/src/mappings/TextInput.js +388 -362
- package/src/mappings/ToggleButton.js +60 -48
- package/src/mappings/Touchable.js +20 -15
- package/src/mappings/Video.js +92 -79
- package/src/mappings/View.js +225 -204
- package/src/mappings/WebView.js +104 -86
- package/src/styles/DarkTheme.js +17 -17
- package/src/styles/DefaultTheme.js +103 -103
- package/src/styles/fonts.js +55 -55
- package/src/styles/overlay.js +50 -49
- package/src/styles/shadow.js +43 -44
- package/src/theming.js +2 -1
- package/src/utilities.js +97 -76
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Animated,
|
|
5
|
+
TextInput as NativeTextInput,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Text,
|
|
8
|
+
I18nManager,
|
|
9
|
+
} from "react-native";
|
|
3
10
|
import { withTheme } from "../theming";
|
|
4
11
|
import { applyStyles, extractStyles } from "../utilities";
|
|
5
12
|
const AnimatedText = Animated.createAnimatedComponent(Text);
|
|
@@ -7,422 +14,532 @@ const FOCUS_ANIMATION_DURATION = 150;
|
|
|
7
14
|
const BLUR_ANIMATION_DURATION = 180;
|
|
8
15
|
const ICON_SIZE = 24;
|
|
9
16
|
class TextField extends React.Component {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.state = {
|
|
20
|
+
nativeProps: {},
|
|
21
|
+
labeled: new Animated.Value(this.props.value || this.props.error ? 0 : 1),
|
|
22
|
+
focused: false,
|
|
23
|
+
placeholder: this.props.error ? this.props.placeholder : "",
|
|
24
|
+
labelLayout: {
|
|
25
|
+
measured: false,
|
|
26
|
+
width: 0,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
this._timer = setTimeout(() => {}, 0);
|
|
30
|
+
this._showPlaceholder = () => {
|
|
31
|
+
clearTimeout(this._timer);
|
|
32
|
+
// Set the placeholder in a delay to offset the label animation
|
|
33
|
+
// If we show it immediately, they'll overlap and look ugly
|
|
34
|
+
this._timer = setTimeout(
|
|
35
|
+
() =>
|
|
36
|
+
this.setState({
|
|
37
|
+
placeholder: this.props.placeholder,
|
|
38
|
+
}),
|
|
39
|
+
50
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
this._hidePlaceholder = () =>
|
|
43
|
+
this.setState({
|
|
44
|
+
placeholder: "",
|
|
45
|
+
});
|
|
46
|
+
this._restoreLabel = () =>
|
|
47
|
+
Animated.timing(this.state.labeled, {
|
|
48
|
+
toValue: 1,
|
|
49
|
+
duration: FOCUS_ANIMATION_DURATION,
|
|
50
|
+
useNativeDriver: true,
|
|
51
|
+
}).start();
|
|
52
|
+
this._minmizeLabel = () =>
|
|
53
|
+
Animated.timing(this.state.labeled, {
|
|
54
|
+
toValue: 0,
|
|
55
|
+
duration: BLUR_ANIMATION_DURATION,
|
|
56
|
+
useNativeDriver: true,
|
|
57
|
+
}).start();
|
|
58
|
+
this._handleFocus = () => {
|
|
59
|
+
if (this.props.disabled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.setState({ focused: true });
|
|
63
|
+
};
|
|
64
|
+
this._handleBlur = () => {
|
|
65
|
+
if (this.props.disabled) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.setState({ focused: false });
|
|
69
|
+
};
|
|
70
|
+
this._handleChangeText = (value) => {
|
|
71
|
+
if (this.props.disabled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (typeof value === "string") {
|
|
75
|
+
this.setState({ value });
|
|
76
|
+
this.props.onChangeText && this.props.onChangeText(value);
|
|
77
|
+
} else {
|
|
78
|
+
this.setState({ value: value.nativeEvent.text });
|
|
79
|
+
this.props.onChangeText &&
|
|
80
|
+
this.props.onChangeText(value.nativeEvent.text);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
this._root = undefined;
|
|
84
|
+
}
|
|
85
|
+
static getDerivedStateFromProps(nextProps, prevState) {
|
|
86
|
+
return {
|
|
87
|
+
value:
|
|
88
|
+
typeof nextProps.value !== "undefined"
|
|
89
|
+
? nextProps.value
|
|
90
|
+
: prevState.value,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
componentDidMount() {
|
|
94
|
+
if (this.props.defaultValue) {
|
|
95
|
+
this._handleChangeText(this.props.defaultValue);
|
|
78
96
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this._handleChangeText(this.props.defaultValue);
|
|
82
|
-
}
|
|
83
|
-
if (this.props.placeholder) {
|
|
84
|
-
this._minmizeLabel();
|
|
85
|
-
}
|
|
97
|
+
if (this.props.placeholder) {
|
|
98
|
+
this._minmizeLabel();
|
|
86
99
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// We don't show placeholder if there's a label because the label acts as placeholder
|
|
106
|
-
// When focused, the label moves up, so we can show a placeholder
|
|
107
|
-
if (this.state.focused || this.props.error || !this.props.label) {
|
|
108
|
-
this._showPlaceholder();
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
this._hidePlaceholder();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
100
|
+
}
|
|
101
|
+
componentDidUpdate(prevProps, prevState) {
|
|
102
|
+
if (
|
|
103
|
+
prevState.focused !== this.state.focused ||
|
|
104
|
+
prevState.value !== this.state.value
|
|
105
|
+
) {
|
|
106
|
+
// The label should be minimized if the text input is focused, or has text
|
|
107
|
+
// In minimized mode, the label moves up and becomes small
|
|
108
|
+
if (
|
|
109
|
+
this.state.value ||
|
|
110
|
+
this.state.focused ||
|
|
111
|
+
this.props.error ||
|
|
112
|
+
this.props.placeholder
|
|
113
|
+
) {
|
|
114
|
+
this._minmizeLabel();
|
|
115
|
+
} else {
|
|
116
|
+
this._restoreLabel();
|
|
117
|
+
}
|
|
114
118
|
}
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
if (
|
|
120
|
+
prevState.focused !== this.state.focused ||
|
|
121
|
+
prevProps.label !== this.props.label
|
|
122
|
+
) {
|
|
123
|
+
// Show placeholder text only if the input is focused, or has error, or there's no label
|
|
124
|
+
// We don't show placeholder if there's a label because the label acts as placeholder
|
|
125
|
+
// When focused, the label moves up, so we can show a placeholder
|
|
126
|
+
if (this.state.focused || this.props.error || !this.props.label) {
|
|
127
|
+
this._showPlaceholder();
|
|
128
|
+
} else {
|
|
129
|
+
this._hidePlaceholder();
|
|
130
|
+
}
|
|
117
131
|
}
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
}
|
|
133
|
+
componentWillUnmount() {
|
|
134
|
+
clearTimeout(this._timer);
|
|
135
|
+
}
|
|
136
|
+
toggleFocus() {
|
|
137
|
+
this.setState((prevState) => ({ focused: !prevState.focused }));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @internal
|
|
141
|
+
*/
|
|
142
|
+
setNativeProps(args) {
|
|
143
|
+
this.setState((state) => ({
|
|
144
|
+
...state,
|
|
145
|
+
nativeState: args || {},
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
isFocused() {
|
|
149
|
+
return this._root && this._root.isFocused();
|
|
150
|
+
}
|
|
151
|
+
clear() {
|
|
152
|
+
return this._root && this._root.clear();
|
|
153
|
+
}
|
|
154
|
+
focus() {
|
|
155
|
+
return this._root && this._root.focus();
|
|
156
|
+
}
|
|
157
|
+
blur() {
|
|
158
|
+
return this._root && this._root.blur();
|
|
159
|
+
}
|
|
160
|
+
render() {
|
|
161
|
+
const {
|
|
162
|
+
Icon,
|
|
163
|
+
type = "underline",
|
|
164
|
+
disabled = false,
|
|
165
|
+
label,
|
|
166
|
+
error = false,
|
|
167
|
+
leftIconName,
|
|
168
|
+
leftIconMode,
|
|
169
|
+
rightIconName,
|
|
170
|
+
assistiveText,
|
|
171
|
+
underlineColor: underlineColorProp,
|
|
172
|
+
activeBorderColor: activeBorderColorProp,
|
|
173
|
+
multiline = false,
|
|
174
|
+
numberOfLines = 4,
|
|
175
|
+
style,
|
|
176
|
+
theme: { colors, typography, roundness, disabledOpacity },
|
|
177
|
+
render = (props) => React.createElement(NativeTextInput, { ...props }),
|
|
178
|
+
...rest
|
|
179
|
+
} = this.props;
|
|
180
|
+
const MINIMIZED_LABEL_Y_OFFSET = -(typography.caption.lineHeight + 4);
|
|
181
|
+
const OUTLINE_MINIMIZED_LABEL_Y_OFFSET = -(16 * 0.5 + 4);
|
|
182
|
+
const MAXIMIZED_LABEL_FONT_SIZE = typography.subtitle1.fontSize;
|
|
183
|
+
const MINIMIZED_LABEL_FONT_SIZE = typography.caption.fontSize;
|
|
184
|
+
const hasActiveOutline = this.state.focused || error;
|
|
185
|
+
let inputTextColor,
|
|
186
|
+
activeColor,
|
|
187
|
+
underlineColor,
|
|
188
|
+
borderColor,
|
|
189
|
+
placeholderColor,
|
|
190
|
+
containerStyle,
|
|
191
|
+
backgroundColor,
|
|
192
|
+
inputStyle;
|
|
193
|
+
inputTextColor = colors.strong;
|
|
194
|
+
if (disabled) {
|
|
195
|
+
activeColor = colors.light;
|
|
196
|
+
placeholderColor = colors.light;
|
|
197
|
+
borderColor = "transparent";
|
|
198
|
+
underlineColor = "transparent";
|
|
199
|
+
backgroundColor = colors.divider;
|
|
200
|
+
} else {
|
|
201
|
+
activeColor = error ? colors.error : activeBorderColorProp;
|
|
202
|
+
placeholderColor = borderColor = colors.light;
|
|
203
|
+
underlineColor = underlineColorProp;
|
|
204
|
+
backgroundColor = colors.background;
|
|
120
205
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*/
|
|
124
|
-
setNativeProps(args) {
|
|
125
|
-
this.setState((state) => ({
|
|
126
|
-
...state,
|
|
127
|
-
nativeState: args || {},
|
|
128
|
-
}));
|
|
206
|
+
if (rest.placeholderTextColor) {
|
|
207
|
+
placeholderColor = rest.placeholderTextColor;
|
|
129
208
|
}
|
|
130
|
-
|
|
131
|
-
|
|
209
|
+
const { lineHeight, ...subtitle1 } = typography.subtitle1;
|
|
210
|
+
inputStyle = {
|
|
211
|
+
paddingVertical: 0,
|
|
212
|
+
color: inputTextColor,
|
|
213
|
+
paddingLeft:
|
|
214
|
+
leftIconName && leftIconMode === "inset"
|
|
215
|
+
? ICON_SIZE + 12 + (type === "solid" ? 16 : 0)
|
|
216
|
+
: 0,
|
|
217
|
+
paddingRight: rightIconName ? ICON_SIZE + 16 + 4 : 12,
|
|
218
|
+
...subtitle1,
|
|
219
|
+
};
|
|
220
|
+
if (!multiline) {
|
|
221
|
+
inputStyle.height = lineHeight;
|
|
132
222
|
}
|
|
133
|
-
|
|
134
|
-
|
|
223
|
+
let assistiveTextLeftMargin;
|
|
224
|
+
if (type === "underline") {
|
|
225
|
+
containerStyle = {
|
|
226
|
+
borderTopLeftRadius: roundness,
|
|
227
|
+
borderTopRightRadius: roundness,
|
|
228
|
+
paddingBottom: 12,
|
|
229
|
+
marginTop: 16,
|
|
230
|
+
};
|
|
231
|
+
if (leftIconName && leftIconMode === "outset") {
|
|
232
|
+
assistiveTextLeftMargin = ICON_SIZE + 8;
|
|
233
|
+
} else {
|
|
234
|
+
assistiveTextLeftMargin = 0;
|
|
235
|
+
}
|
|
236
|
+
} else {
|
|
237
|
+
containerStyle = {
|
|
238
|
+
borderRadius: roundness,
|
|
239
|
+
borderColor: hasActiveOutline ? activeColor : borderColor,
|
|
240
|
+
borderWidth: 1,
|
|
241
|
+
paddingTop: label ? 16 * 1.5 : 16,
|
|
242
|
+
paddingBottom: label ? 16 * 0.5 : 16,
|
|
243
|
+
opacity: disabled ? disabledOpacity : 1,
|
|
244
|
+
backgroundColor,
|
|
245
|
+
};
|
|
246
|
+
if (leftIconName && leftIconMode === "inset") {
|
|
247
|
+
assistiveTextLeftMargin = 16 + 4;
|
|
248
|
+
} else if (leftIconName && leftIconMode === "outset") {
|
|
249
|
+
assistiveTextLeftMargin = ICON_SIZE + 8 + 12;
|
|
250
|
+
} else {
|
|
251
|
+
assistiveTextLeftMargin = 12;
|
|
252
|
+
}
|
|
253
|
+
inputStyle.paddingHorizontal = 12;
|
|
135
254
|
}
|
|
136
|
-
|
|
137
|
-
|
|
255
|
+
if (leftIconName && leftIconMode === "outset") {
|
|
256
|
+
containerStyle.marginLeft = ICON_SIZE + 8;
|
|
138
257
|
}
|
|
139
|
-
|
|
140
|
-
|
|
258
|
+
let leftIconColor;
|
|
259
|
+
if (error) {
|
|
260
|
+
leftIconColor = colors.error;
|
|
261
|
+
} else if (this.state.focused) {
|
|
262
|
+
leftIconColor = colors.primary;
|
|
263
|
+
} else {
|
|
264
|
+
leftIconColor = colors.light;
|
|
141
265
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
266
|
+
const leftIconProps = {
|
|
267
|
+
size: 24,
|
|
268
|
+
color: leftIconColor,
|
|
269
|
+
name: leftIconName || "",
|
|
270
|
+
};
|
|
271
|
+
const leftIconStyle = {
|
|
272
|
+
position: "absolute",
|
|
273
|
+
marginTop:
|
|
274
|
+
type === "solid"
|
|
275
|
+
? MINIMIZED_LABEL_FONT_SIZE + 4
|
|
276
|
+
: leftIconMode === "outset"
|
|
277
|
+
? 16
|
|
278
|
+
: 0,
|
|
279
|
+
marginLeft: leftIconMode === "inset" && type === "solid" ? 16 : 0,
|
|
280
|
+
};
|
|
281
|
+
const labelStyle = {
|
|
282
|
+
...typography.subtitle1,
|
|
283
|
+
top: type === "solid" ? 16 : 0,
|
|
284
|
+
left:
|
|
285
|
+
leftIconName && leftIconMode === "inset"
|
|
286
|
+
? ICON_SIZE + (type === "solid" ? 16 : 12)
|
|
287
|
+
: 0,
|
|
288
|
+
transform: [
|
|
289
|
+
{
|
|
290
|
+
// Move label to top
|
|
291
|
+
translateY: this.state.labeled.interpolate({
|
|
292
|
+
inputRange: [0, 1],
|
|
293
|
+
outputRange: [
|
|
294
|
+
type === "solid"
|
|
295
|
+
? OUTLINE_MINIMIZED_LABEL_Y_OFFSET
|
|
296
|
+
: MINIMIZED_LABEL_Y_OFFSET,
|
|
297
|
+
0,
|
|
298
|
+
],
|
|
299
|
+
}),
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
// Make label smaller
|
|
303
|
+
scale: this.state.labeled.interpolate({
|
|
304
|
+
inputRange: [0, 1],
|
|
305
|
+
outputRange: [
|
|
306
|
+
MINIMIZED_LABEL_FONT_SIZE / MAXIMIZED_LABEL_FONT_SIZE,
|
|
307
|
+
1,
|
|
308
|
+
],
|
|
309
|
+
}),
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
// Offset label scale since RN doesn't support transform origin
|
|
313
|
+
translateX: this.state.labeled.interpolate({
|
|
314
|
+
inputRange: [0, 1],
|
|
315
|
+
outputRange: [
|
|
316
|
+
-(1 - MINIMIZED_LABEL_FONT_SIZE / MAXIMIZED_LABEL_FONT_SIZE) *
|
|
317
|
+
(this.state.labelLayout.width / 2),
|
|
318
|
+
0,
|
|
319
|
+
],
|
|
320
|
+
}),
|
|
321
|
+
},
|
|
322
|
+
],
|
|
323
|
+
};
|
|
324
|
+
const { textStyles } = extractStyles(style);
|
|
325
|
+
const inputStyles = applyStyles(
|
|
326
|
+
[
|
|
327
|
+
styles.input,
|
|
328
|
+
inputStyle,
|
|
329
|
+
type === "solid" ? { marginHorizontal: 12 } : {},
|
|
330
|
+
],
|
|
331
|
+
textStyles
|
|
332
|
+
);
|
|
333
|
+
const {
|
|
334
|
+
backgroundColor: bgColor,
|
|
335
|
+
padding,
|
|
336
|
+
paddingTop,
|
|
337
|
+
paddingBottom,
|
|
338
|
+
paddingLeft,
|
|
339
|
+
paddingRight,
|
|
340
|
+
borderRadius,
|
|
341
|
+
borderWidth,
|
|
342
|
+
borderTopWidth,
|
|
343
|
+
borderRightWidth,
|
|
344
|
+
borderBottomWidth,
|
|
345
|
+
borderLeftWidth,
|
|
346
|
+
borderColor: borderCol,
|
|
347
|
+
...styleProp
|
|
348
|
+
} = StyleSheet.flatten(style || {});
|
|
349
|
+
return React.createElement(
|
|
350
|
+
View,
|
|
351
|
+
{ style: [styles.container, styleProp] },
|
|
352
|
+
leftIconName && leftIconMode === "outset"
|
|
353
|
+
? React.createElement(Icon, { ...leftIconProps, style: leftIconStyle })
|
|
354
|
+
: null,
|
|
355
|
+
React.createElement(
|
|
356
|
+
View,
|
|
357
|
+
{
|
|
358
|
+
style: applyStyles([containerStyle], {
|
|
359
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
360
|
+
backgroundColor: bgColor,
|
|
361
|
+
padding,
|
|
362
|
+
paddingTop,
|
|
363
|
+
paddingBottom,
|
|
364
|
+
paddingLeft,
|
|
365
|
+
paddingRight,
|
|
366
|
+
borderRadius,
|
|
367
|
+
borderWidth,
|
|
368
|
+
borderTopWidth,
|
|
369
|
+
borderRightWidth,
|
|
370
|
+
borderBottomWidth,
|
|
371
|
+
borderLeftWidth,
|
|
372
|
+
borderColor: borderCol,
|
|
373
|
+
}),
|
|
374
|
+
},
|
|
375
|
+
type === "underline"
|
|
376
|
+
? // When type === 'flat', render an underline
|
|
377
|
+
React.createElement(Animated.View, {
|
|
378
|
+
style: [
|
|
379
|
+
styles.underline,
|
|
250
380
|
{
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}),
|
|
381
|
+
backgroundColor:
|
|
382
|
+
bgColor ||
|
|
383
|
+
(error
|
|
384
|
+
? colors.error
|
|
385
|
+
: this.state.focused
|
|
386
|
+
? activeColor
|
|
387
|
+
: underlineColor),
|
|
388
|
+
// Underlines is thinner when input is not focused
|
|
389
|
+
transform: [{ scaleY: this.state.focused ? 1 : 0.5 }],
|
|
261
390
|
},
|
|
391
|
+
],
|
|
392
|
+
})
|
|
393
|
+
: null,
|
|
394
|
+
label
|
|
395
|
+
? // Position colored placeholder and gray placeholder on top of each other and crossfade them
|
|
396
|
+
// This gives the effect of animating the color, but allows us to use native driver
|
|
397
|
+
React.createElement(
|
|
398
|
+
View,
|
|
399
|
+
{
|
|
400
|
+
pointerEvents: "none",
|
|
401
|
+
style: [
|
|
402
|
+
StyleSheet.absoluteFill,
|
|
403
|
+
{
|
|
404
|
+
opacity:
|
|
405
|
+
// Hide the label in minimized state until we measure its width
|
|
406
|
+
this.state.value || this.state.focused
|
|
407
|
+
? this.state.labelLayout.measured
|
|
408
|
+
? 1
|
|
409
|
+
: 0
|
|
410
|
+
: 1,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
React.createElement(
|
|
415
|
+
AnimatedText,
|
|
262
416
|
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
],
|
|
417
|
+
onLayout: (e) =>
|
|
418
|
+
this.setState({
|
|
419
|
+
labelLayout: {
|
|
420
|
+
width: e.nativeEvent.layout.width,
|
|
421
|
+
measured: true,
|
|
422
|
+
},
|
|
270
423
|
}),
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
424
|
+
style: [
|
|
425
|
+
styles.placeholder,
|
|
426
|
+
type === "solid" ? { paddingHorizontal: 12 } : {},
|
|
427
|
+
labelStyle,
|
|
428
|
+
{
|
|
429
|
+
color: placeholderColor,
|
|
430
|
+
opacity: this.state.labeled.interpolate({
|
|
275
431
|
inputRange: [0, 1],
|
|
276
|
-
outputRange: [
|
|
277
|
-
|
|
278
|
-
(this.state.labelLayout.width / 2),
|
|
279
|
-
0,
|
|
280
|
-
],
|
|
281
|
-
}),
|
|
282
|
-
},
|
|
283
|
-
],
|
|
284
|
-
};
|
|
285
|
-
const { textStyles } = extractStyles(style);
|
|
286
|
-
const inputStyles = applyStyles([
|
|
287
|
-
styles.input,
|
|
288
|
-
inputStyle,
|
|
289
|
-
type === "solid" ? { marginHorizontal: 12 } : {},
|
|
290
|
-
], textStyles);
|
|
291
|
-
const { backgroundColor: bgColor, padding, paddingTop, paddingBottom, paddingLeft, paddingRight, borderRadius, borderWidth, borderTopWidth, borderRightWidth, borderBottomWidth, borderLeftWidth, borderColor: borderCol, ...styleProp } = StyleSheet.flatten(style || {});
|
|
292
|
-
return (React.createElement(View, { style: [styles.container, styleProp] },
|
|
293
|
-
leftIconName && leftIconMode === "outset" ? (React.createElement(Icon, { ...leftIconProps, style: leftIconStyle })) : null,
|
|
294
|
-
React.createElement(View, { style: applyStyles([containerStyle], {
|
|
295
|
-
height: style === null || style === void 0 ? void 0 : style.height,
|
|
296
|
-
backgroundColor: bgColor,
|
|
297
|
-
padding,
|
|
298
|
-
paddingTop,
|
|
299
|
-
paddingBottom,
|
|
300
|
-
paddingLeft,
|
|
301
|
-
paddingRight,
|
|
302
|
-
borderRadius,
|
|
303
|
-
borderWidth,
|
|
304
|
-
borderTopWidth,
|
|
305
|
-
borderRightWidth,
|
|
306
|
-
borderBottomWidth,
|
|
307
|
-
borderLeftWidth,
|
|
308
|
-
borderColor: borderCol,
|
|
309
|
-
}) },
|
|
310
|
-
type === "underline" ? (
|
|
311
|
-
// When type === 'flat', render an underline
|
|
312
|
-
React.createElement(Animated.View, { style: [
|
|
313
|
-
styles.underline,
|
|
314
|
-
{
|
|
315
|
-
backgroundColor: bgColor ||
|
|
316
|
-
(error
|
|
317
|
-
? colors.error
|
|
318
|
-
: this.state.focused
|
|
319
|
-
? activeColor
|
|
320
|
-
: underlineColor),
|
|
321
|
-
// Underlines is thinner when input is not focused
|
|
322
|
-
transform: [{ scaleY: this.state.focused ? 1 : 0.5 }],
|
|
323
|
-
},
|
|
324
|
-
] })) : null,
|
|
325
|
-
label ? (
|
|
326
|
-
// Position colored placeholder and gray placeholder on top of each other and crossfade them
|
|
327
|
-
// This gives the effect of animating the color, but allows us to use native driver
|
|
328
|
-
React.createElement(View, { pointerEvents: "none", style: [
|
|
329
|
-
StyleSheet.absoluteFill,
|
|
330
|
-
{
|
|
331
|
-
opacity:
|
|
332
|
-
// Hide the label in minimized state until we measure its width
|
|
333
|
-
this.state.value || this.state.focused
|
|
334
|
-
? this.state.labelLayout.measured
|
|
335
|
-
? 1
|
|
336
|
-
: 0
|
|
337
|
-
: 1,
|
|
338
|
-
},
|
|
339
|
-
] },
|
|
340
|
-
React.createElement(AnimatedText, { onLayout: (e) => this.setState({
|
|
341
|
-
labelLayout: {
|
|
342
|
-
width: e.nativeEvent.layout.width,
|
|
343
|
-
measured: true,
|
|
344
|
-
},
|
|
345
|
-
}), style: [
|
|
346
|
-
styles.placeholder,
|
|
347
|
-
type === "solid" ? { paddingHorizontal: 12 } : {},
|
|
348
|
-
labelStyle,
|
|
349
|
-
{
|
|
350
|
-
color: placeholderColor,
|
|
351
|
-
opacity: this.state.labeled.interpolate({
|
|
352
|
-
inputRange: [0, 1],
|
|
353
|
-
outputRange: [hasActiveOutline ? 1 : 0, 0],
|
|
354
|
-
}),
|
|
355
|
-
},
|
|
356
|
-
], numberOfLines: 1 }, label),
|
|
357
|
-
React.createElement(AnimatedText, { style: [
|
|
358
|
-
styles.placeholder,
|
|
359
|
-
type === "solid" ? { paddingHorizontal: 12 } : {},
|
|
360
|
-
labelStyle,
|
|
361
|
-
{
|
|
362
|
-
color: placeholderColor,
|
|
363
|
-
opacity: hasActiveOutline ? this.state.labeled : 1,
|
|
364
|
-
},
|
|
365
|
-
], numberOfLines: 1 }, label))) : null,
|
|
366
|
-
leftIconName && leftIconMode === "inset" ? (React.createElement(View, { style: {
|
|
367
|
-
justifyContent: type === "solid" ? "center" : undefined,
|
|
368
|
-
} },
|
|
369
|
-
React.createElement(Icon, { ...leftIconProps, style: leftIconStyle }))) : null,
|
|
370
|
-
render({
|
|
371
|
-
ref: (c) => {
|
|
372
|
-
this._root = c;
|
|
432
|
+
outputRange: [hasActiveOutline ? 1 : 0, 0],
|
|
433
|
+
}),
|
|
373
434
|
},
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
style: inputStyles,
|
|
387
|
-
...rest,
|
|
388
|
-
...this.state.nativeProps,
|
|
389
|
-
value: this.state.value,
|
|
390
|
-
})),
|
|
391
|
-
rightIconName ? (React.createElement(Icon, { name: rightIconName, size: ICON_SIZE, color: colors.light, style: {
|
|
392
|
-
position: "absolute",
|
|
393
|
-
right: 16,
|
|
394
|
-
marginTop: type === "solid" ? MINIMIZED_LABEL_FONT_SIZE + 4 : 16,
|
|
395
|
-
} })) : null,
|
|
396
|
-
assistiveText ? (React.createElement(Text, { style: [
|
|
435
|
+
],
|
|
436
|
+
numberOfLines: 1,
|
|
437
|
+
},
|
|
438
|
+
label
|
|
439
|
+
),
|
|
440
|
+
React.createElement(
|
|
441
|
+
AnimatedText,
|
|
442
|
+
{
|
|
443
|
+
style: [
|
|
444
|
+
styles.placeholder,
|
|
445
|
+
type === "solid" ? { paddingHorizontal: 12 } : {},
|
|
446
|
+
labelStyle,
|
|
397
447
|
{
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
marginLeft: assistiveTextLeftMargin,
|
|
448
|
+
color: placeholderColor,
|
|
449
|
+
opacity: hasActiveOutline ? this.state.labeled : 1,
|
|
401
450
|
},
|
|
402
|
-
|
|
403
|
-
|
|
451
|
+
],
|
|
452
|
+
numberOfLines: 1,
|
|
453
|
+
},
|
|
454
|
+
label
|
|
455
|
+
)
|
|
456
|
+
)
|
|
457
|
+
: null,
|
|
458
|
+
leftIconName && leftIconMode === "inset"
|
|
459
|
+
? React.createElement(
|
|
460
|
+
View,
|
|
461
|
+
{
|
|
462
|
+
style: {
|
|
463
|
+
justifyContent: type === "solid" ? "center" : undefined,
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
React.createElement(Icon, {
|
|
467
|
+
...leftIconProps,
|
|
468
|
+
style: leftIconStyle,
|
|
469
|
+
})
|
|
470
|
+
)
|
|
471
|
+
: null,
|
|
472
|
+
render({
|
|
473
|
+
ref: (c) => {
|
|
474
|
+
this._root = c;
|
|
475
|
+
},
|
|
476
|
+
onChange: this._handleChangeText,
|
|
477
|
+
placeholder: label ? this.state.placeholder : this.props.placeholder,
|
|
478
|
+
placeholderTextColor: placeholderColor,
|
|
479
|
+
editable: !disabled,
|
|
480
|
+
selectionColor: activeColor,
|
|
481
|
+
multiline,
|
|
482
|
+
numberOfLines,
|
|
483
|
+
onFocus: this._handleFocus,
|
|
484
|
+
onBlur: this._handleBlur,
|
|
485
|
+
underlineColorAndroid: "transparent",
|
|
486
|
+
style: inputStyles,
|
|
487
|
+
...rest,
|
|
488
|
+
...this.state.nativeProps,
|
|
489
|
+
value: this.state.value,
|
|
490
|
+
})
|
|
491
|
+
),
|
|
492
|
+
rightIconName
|
|
493
|
+
? React.createElement(Icon, {
|
|
494
|
+
name: rightIconName,
|
|
495
|
+
size: ICON_SIZE,
|
|
496
|
+
color: colors.light,
|
|
497
|
+
style: {
|
|
498
|
+
position: "absolute",
|
|
499
|
+
right: 16,
|
|
500
|
+
marginTop: type === "solid" ? MINIMIZED_LABEL_FONT_SIZE + 4 : 16,
|
|
501
|
+
},
|
|
502
|
+
})
|
|
503
|
+
: null,
|
|
504
|
+
assistiveText
|
|
505
|
+
? React.createElement(
|
|
506
|
+
Text,
|
|
507
|
+
{
|
|
508
|
+
style: [
|
|
509
|
+
{
|
|
510
|
+
color: error ? colors.error : colors.light,
|
|
511
|
+
marginTop: 8,
|
|
512
|
+
marginLeft: assistiveTextLeftMargin,
|
|
513
|
+
},
|
|
514
|
+
],
|
|
515
|
+
},
|
|
516
|
+
assistiveText
|
|
517
|
+
)
|
|
518
|
+
: null
|
|
519
|
+
);
|
|
520
|
+
}
|
|
404
521
|
}
|
|
405
522
|
export default withTheme(TextField);
|
|
406
523
|
const styles = StyleSheet.create({
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
524
|
+
container: {
|
|
525
|
+
alignSelf: "stretch",
|
|
526
|
+
},
|
|
527
|
+
placeholder: {
|
|
528
|
+
position: "absolute",
|
|
529
|
+
left: 0,
|
|
530
|
+
},
|
|
531
|
+
underline: {
|
|
532
|
+
position: "absolute",
|
|
533
|
+
left: 0,
|
|
534
|
+
right: 0,
|
|
535
|
+
bottom: 0,
|
|
536
|
+
height: 2,
|
|
537
|
+
},
|
|
538
|
+
input: {
|
|
539
|
+
flexGrow: 1,
|
|
540
|
+
justifyContent: "center",
|
|
541
|
+
textAlignVertical: "center",
|
|
542
|
+
margin: 0,
|
|
543
|
+
textAlign: I18nManager.isRTL ? "right" : "left",
|
|
544
|
+
},
|
|
428
545
|
});
|