react-native-molecules 0.5.0-beta.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/components/Accordion/Accordion.tsx +89 -0
- package/components/Accordion/AccordionItem.tsx +94 -0
- package/components/Accordion/AccordionItemContent.tsx +17 -0
- package/components/Accordion/AccordionItemHeader.tsx +122 -0
- package/components/Accordion/index.tsx +36 -0
- package/components/Accordion/utils.ts +62 -0
- package/components/ActivityIndicator/ActivityIndicator.ios.tsx +1 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +200 -0
- package/components/ActivityIndicator/AnimatedSpinner.tsx +121 -0
- package/components/ActivityIndicator/index.tsx +17 -0
- package/components/Appbar/AppbarActions.tsx +13 -0
- package/components/Appbar/AppbarBase.tsx +60 -0
- package/components/Appbar/AppbarCenterAligned.tsx +13 -0
- package/components/Appbar/AppbarLarge.tsx +13 -0
- package/components/Appbar/AppbarLeft.tsx +26 -0
- package/components/Appbar/AppbarMedium.tsx +13 -0
- package/components/Appbar/AppbarRight.tsx +40 -0
- package/components/Appbar/AppbarSmall.tsx +13 -0
- package/components/Appbar/AppbarTitle.tsx +49 -0
- package/components/Appbar/index.tsx +46 -0
- package/components/Appbar/types.ts +19 -0
- package/components/Appbar/utils.ts +127 -0
- package/components/Avatar/Avatar.tsx +189 -0
- package/components/Avatar/index.tsx +11 -0
- package/components/Avatar/utils.ts +35 -0
- package/components/Backdrop/Backdrop.tsx +18 -0
- package/components/Backdrop/index.tsx +11 -0
- package/components/Backdrop/types.ts +3 -0
- package/components/Backdrop/utils.ts +21 -0
- package/components/Badge/Badge.tsx +29 -0
- package/components/Badge/index.tsx +11 -0
- package/components/Badge/utils.ts +38 -0
- package/components/Button/Button.tsx +349 -0
- package/components/Button/index.tsx +11 -0
- package/components/Button/types.ts +5 -0
- package/components/Button/utils.ts +416 -0
- package/components/Card/Card.tsx +160 -0
- package/components/Card/CardActions.tsx +18 -0
- package/components/Card/CardContent.tsx +29 -0
- package/components/Card/CardHeader.tsx +31 -0
- package/components/Card/CardHeadline.tsx +15 -0
- package/components/Card/CardMedia.tsx +36 -0
- package/components/Card/CardSubhead.tsx +15 -0
- package/components/Card/CardText.tsx +13 -0
- package/components/Card/CardTypography.tsx +113 -0
- package/components/Card/index.tsx +38 -0
- package/components/Card/types.ts +1 -0
- package/components/Card/utils.ts +23 -0
- package/components/Checkbox/Checkbox.tsx +123 -0
- package/components/Checkbox/CheckboxBase.ios.tsx +86 -0
- package/components/Checkbox/CheckboxBase.tsx +216 -0
- package/components/Checkbox/index.tsx +11 -0
- package/components/Checkbox/types.ts +72 -0
- package/components/Checkbox/utils.ts +210 -0
- package/components/Chip/Chip.tsx +416 -0
- package/components/Chip/index.tsx +51 -0
- package/components/Chip/utils.ts +100 -0
- package/components/DatePickerDocked/DatePickerDocked.tsx +30 -0
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +129 -0
- package/components/DatePickerDocked/index.tsx +21 -0
- package/components/DatePickerDocked/types.ts +11 -0
- package/components/DatePickerDocked/utils.ts +155 -0
- package/components/DatePickerInline/AutoSizer.tsx +46 -0
- package/components/DatePickerInline/DatePickerContext.tsx +21 -0
- package/components/DatePickerInline/DatePickerInline.tsx +82 -0
- package/components/DatePickerInline/DatePickerInlineBase.tsx +181 -0
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +108 -0
- package/components/DatePickerInline/Day.tsx +88 -0
- package/components/DatePickerInline/DayName.tsx +17 -0
- package/components/DatePickerInline/DayNames.tsx +32 -0
- package/components/DatePickerInline/DayRange.tsx +48 -0
- package/components/DatePickerInline/HeaderItem.tsx +111 -0
- package/components/DatePickerInline/Month.tsx +233 -0
- package/components/DatePickerInline/MonthPicker.tsx +174 -0
- package/components/DatePickerInline/Swiper.native.tsx +172 -0
- package/components/DatePickerInline/Swiper.tsx +172 -0
- package/components/DatePickerInline/SwiperUtils.ts +40 -0
- package/components/DatePickerInline/Week.tsx +67 -0
- package/components/DatePickerInline/YearPicker.tsx +139 -0
- package/components/DatePickerInline/dateUtils.tsx +334 -0
- package/components/DatePickerInline/index.tsx +41 -0
- package/components/DatePickerInline/types.ts +104 -0
- package/components/DatePickerInline/utils.ts +367 -0
- package/components/DatePickerInput/DatePickerInput.tsx +139 -0
- package/components/DatePickerInput/DatePickerInputModal.tsx +48 -0
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +77 -0
- package/components/DatePickerInput/DateRangeInput.tsx +88 -0
- package/components/DatePickerInput/index.tsx +14 -0
- package/components/DatePickerInput/inputUtils.ts +138 -0
- package/components/DatePickerInput/types.ts +28 -0
- package/components/DatePickerInput/utils.ts +16 -0
- package/components/DatePickerModal/AnimatedCrossView.tsx +94 -0
- package/components/DatePickerModal/CalendarEdit.tsx +139 -0
- package/components/DatePickerModal/DatePickerModal.tsx +85 -0
- package/components/DatePickerModal/DatePickerModalContent.tsx +155 -0
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +213 -0
- package/components/DatePickerModal/DatePickerModalHeader.tsx +74 -0
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +13 -0
- package/components/DatePickerModal/index.tsx +20 -0
- package/components/DatePickerModal/types.ts +92 -0
- package/components/DatePickerModal/utils.ts +121 -0
- package/components/DateTimePicker/DateTimePicker.tsx +172 -0
- package/components/DateTimePicker/index.tsx +14 -0
- package/components/DateTimePicker/utils.ts +13 -0
- package/components/Dialog/Dialog.tsx +66 -0
- package/components/Dialog/DialogActions.tsx +89 -0
- package/components/Dialog/DialogContent.tsx +37 -0
- package/components/Dialog/DialogIcon.tsx +69 -0
- package/components/Dialog/DialogTitle.tsx +68 -0
- package/components/Dialog/index.tsx +37 -0
- package/components/Dialog/utils.ts +80 -0
- package/components/Drawer/Collapsible/DrawerCollapsible.tsx +22 -0
- package/components/Drawer/Collapsible/DrawerCollapsibleItem.tsx +38 -0
- package/components/Drawer/Collapsible/DrawerCollapsibleItemContent.tsx +16 -0
- package/components/Drawer/Collapsible/DrawerCollapsibleItemHeader.tsx +48 -0
- package/components/Drawer/Collapsible/index.tsx +23 -0
- package/components/Drawer/Collapsible/utils.ts +49 -0
- package/components/Drawer/Drawer.tsx +43 -0
- package/components/Drawer/DrawerContent.tsx +35 -0
- package/components/Drawer/DrawerFooter.tsx +27 -0
- package/components/Drawer/DrawerHeader.tsx +27 -0
- package/components/Drawer/DrawerItem.tsx +206 -0
- package/components/Drawer/DrawerItemGroup.tsx +82 -0
- package/components/Drawer/index.tsx +47 -0
- package/components/Drawer/types.ts +3 -0
- package/components/Drawer/utils.ts +8 -0
- package/components/ElementGroup/ElementGroup.tsx +139 -0
- package/components/ElementGroup/index.tsx +11 -0
- package/components/ElementGroup/utils.ts +25 -0
- package/components/FAB/FAB.tsx +176 -0
- package/components/FAB/index.tsx +12 -0
- package/components/FAB/types.ts +1 -0
- package/components/FAB/utils.ts +221 -0
- package/components/FilePicker/FilePicker.tsx +133 -0
- package/components/FilePicker/index.tsx +11 -0
- package/components/FilePicker/utils.ts +13 -0
- package/components/HelperText/HelperText.tsx +139 -0
- package/components/HelperText/index.tsx +11 -0
- package/components/HelperText/utils.ts +29 -0
- package/components/HorizontalDivider/HorizontalDivider.tsx +101 -0
- package/components/HorizontalDivider/index.tsx +13 -0
- package/components/Icon/CrossFadeIcon.tsx +116 -0
- package/components/Icon/Icon.tsx +41 -0
- package/components/Icon/iconFactory.tsx +23 -0
- package/components/Icon/index.tsx +11 -0
- package/components/Icon/types.ts +35 -0
- package/components/IconButton/IconButton.tsx +218 -0
- package/components/IconButton/index.tsx +11 -0
- package/components/IconButton/types.ts +1 -0
- package/components/IconButton/utils.ts +325 -0
- package/components/If/index.tsx +13 -0
- package/components/InputAddon/InputAddon.tsx +27 -0
- package/components/InputAddon/index.tsx +11 -0
- package/components/InputAddon/utils.ts +33 -0
- package/components/Link/Link.tsx +48 -0
- package/components/Link/index.tsx +11 -0
- package/components/Link/utils.ts +37 -0
- package/components/ListItem/ListItem.tsx +136 -0
- package/components/ListItem/ListItemDescription.tsx +25 -0
- package/components/ListItem/ListItemTitle.tsx +25 -0
- package/components/ListItem/index.tsx +18 -0
- package/components/ListItem/utils.ts +113 -0
- package/components/Menu/Menu.tsx +69 -0
- package/components/Menu/MenuDivider.tsx +13 -0
- package/components/Menu/MenuItem.tsx +128 -0
- package/components/Menu/index.tsx +19 -0
- package/components/Menu/utils.ts +92 -0
- package/components/Modal/Modal.tsx +261 -0
- package/components/Modal/index.tsx +11 -0
- package/components/Modal/utils.ts +45 -0
- package/components/NavigationRail/NavigationRail.tsx +32 -0
- package/components/NavigationRail/NavigationRailContent.tsx +25 -0
- package/components/NavigationRail/NavigationRailFooter.tsx +18 -0
- package/components/NavigationRail/NavigationRailHeader.tsx +18 -0
- package/components/NavigationRail/NavigationRailItem.tsx +226 -0
- package/components/NavigationRail/index.tsx +35 -0
- package/components/NavigationRail/utils.ts +170 -0
- package/components/NavigationStack/NavigationStack.tsx +85 -0
- package/components/NavigationStack/NavigationStackItem.tsx +60 -0
- package/components/NavigationStack/index.tsx +20 -0
- package/components/NavigationStack/utils.tsx +16 -0
- package/components/Popover/Popover.native.tsx +185 -0
- package/components/Popover/Popover.tsx +198 -0
- package/components/Popover/common.ts +459 -0
- package/components/Popover/index.ts +2 -0
- package/components/Portal/Portal.tsx +13 -0
- package/components/Portal/index.tsx +12 -0
- package/components/RadioButton/RadioButton.tsx +138 -0
- package/components/RadioButton/RadioButtonAndroid.tsx +188 -0
- package/components/RadioButton/RadioButtonGroup.tsx +98 -0
- package/components/RadioButton/RadioButtonIOS.tsx +106 -0
- package/components/RadioButton/RadioButtonItem.tsx +232 -0
- package/components/RadioButton/index.ts +27 -0
- package/components/RadioButton/utils.ts +164 -0
- package/components/Rating/Rating.tsx +149 -0
- package/components/Rating/RatingItem.tsx +125 -0
- package/components/Rating/index.tsx +13 -0
- package/components/Rating/utils.ts +38 -0
- package/components/Select/Select.tsx +1038 -0
- package/components/Select/index.ts +14 -0
- package/components/Select/types.ts +115 -0
- package/components/StateLayer/StateLayer.tsx +12 -0
- package/components/StateLayer/index.tsx +11 -0
- package/components/StateLayer/utils.ts +17 -0
- package/components/Surface/BackgroundContextWrapper.tsx +27 -0
- package/components/Surface/Surface.android.tsx +62 -0
- package/components/Surface/Surface.ios.tsx +123 -0
- package/components/Surface/Surface.tsx +48 -0
- package/components/Surface/index.tsx +12 -0
- package/components/Surface/utils.ts +106 -0
- package/components/Switch/Switch.ios.tsx +67 -0
- package/components/Switch/Switch.tsx +278 -0
- package/components/Switch/index.tsx +11 -0
- package/components/Switch/utils.ts +283 -0
- package/components/Tabs/TabItem.tsx +150 -0
- package/components/Tabs/TabLabel.tsx +84 -0
- package/components/Tabs/Tabs.tsx +398 -0
- package/components/Tabs/index.tsx +21 -0
- package/components/Tabs/utils.ts +126 -0
- package/components/Text/Text.tsx +23 -0
- package/components/Text/index.tsx +2 -0
- package/components/Text/textFactory.tsx +33 -0
- package/components/TextInput/InputLabel.tsx +181 -0
- package/components/TextInput/TextInput.tsx +693 -0
- package/components/TextInput/index.tsx +16 -0
- package/components/TextInput/types.ts +96 -0
- package/components/TextInput/utils.ts +544 -0
- package/components/TextInputWithMask/TextInputMask.tsx +57 -0
- package/components/TextInputWithMask/index.tsx +11 -0
- package/components/TextInputWithMask/utils.ts +56 -0
- package/components/TimePicker/AmPmSwitcher.tsx +99 -0
- package/components/TimePicker/AnalogClock.tsx +165 -0
- package/components/TimePicker/AnalogClockHours.tsx +163 -0
- package/components/TimePicker/AnalogClockMinutes.tsx +68 -0
- package/components/TimePicker/AnimatedClockSwitcher.tsx +72 -0
- package/components/TimePicker/DisplayModeContext.tsx +6 -0
- package/components/TimePicker/TimeInput.tsx +112 -0
- package/components/TimePicker/TimeInputs.tsx +148 -0
- package/components/TimePicker/TimePicker.tsx +130 -0
- package/components/TimePicker/index.tsx +19 -0
- package/components/TimePicker/timeUtils.ts +159 -0
- package/components/TimePicker/utils.ts +285 -0
- package/components/TimePickerField/TimePickerField.tsx +152 -0
- package/components/TimePickerField/index.tsx +14 -0
- package/components/TimePickerField/sanitizeTime.ts +85 -0
- package/components/TimePickerField/utils.ts +95 -0
- package/components/TimePickerModal/TimePickerModal.tsx +115 -0
- package/components/TimePickerModal/index.tsx +14 -0
- package/components/TimePickerModal/utils.ts +48 -0
- package/components/Tooltip/Tooltip.tsx +137 -0
- package/components/Tooltip/TooltipContent.tsx +12 -0
- package/components/Tooltip/TooltipTrigger.tsx +94 -0
- package/components/Tooltip/index.tsx +20 -0
- package/components/Tooltip/utils.ts +21 -0
- package/components/TouchableRipple/TouchableRipple.native.tsx +105 -0
- package/components/TouchableRipple/TouchableRipple.tsx +286 -0
- package/components/TouchableRipple/index.tsx +14 -0
- package/components/TouchableRipple/utils.ts +15 -0
- package/components/VerticalDivider/VerticalDivider.tsx +99 -0
- package/components/VerticalDivider/index.tsx +13 -0
- package/context-bridge/index.tsx +87 -0
- package/core/componentsRegistry.ts +164 -0
- package/core/index.tsx +2 -0
- package/fast-context/index.tsx +190 -0
- package/hocs/index.tsx +5 -0
- package/hocs/typedMemo.tsx +5 -0
- package/hocs/withKeyboardAccessibility.tsx +231 -0
- package/hocs/withPortal.tsx +16 -0
- package/hooks/createPsuedoHook.tsx +50 -0
- package/hooks/index.tsx +29 -0
- package/hooks/useActionState.native.tsx +22 -0
- package/hooks/useActionState.tsx +34 -0
- package/hooks/useActive.tsx +5 -0
- package/hooks/useBreakpoints.tsx +7 -0
- package/hooks/useColorMode.tsx +17 -0
- package/hooks/useContrastColor.ts +15 -0
- package/hooks/useControlledValue.tsx +68 -0
- package/hooks/useFilePicker.tsx +48 -0
- package/hooks/useFocus.tsx +5 -0
- package/hooks/useHandleNumberFormat.tsx +106 -0
- package/hooks/useHover.tsx +5 -0
- package/hooks/useKeyboardDismissable.ts +66 -0
- package/hooks/useLatest.tsx +9 -0
- package/hooks/useMediaQuery.tsx +64 -0
- package/hooks/useMergedRefs.ts +14 -0
- package/hooks/usePrevious.ts +13 -0
- package/hooks/useQueryFilter.tsx +35 -0
- package/hooks/useSearchable.tsx +74 -0
- package/hooks/useSubcomponents.tsx +59 -0
- package/hooks/useTheme.ts +3 -0
- package/hooks/useToggle.tsx +24 -0
- package/package.json +114 -0
- package/shortcuts-manager/EventsManager.tsx +121 -0
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.native.tsx +9 -0
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +58 -0
- package/shortcuts-manager/ShortcutsManager/index.tsx +2 -0
- package/shortcuts-manager/ShortcutsManager/utils.tsx +30 -0
- package/shortcuts-manager/index.tsx +6 -0
- package/shortcuts-manager/types.ts +24 -0
- package/shortcuts-manager/useIsKeyPressed/index.tsx +1 -0
- package/shortcuts-manager/useIsKeyPressed/useIsKeyPress.tsx +9 -0
- package/shortcuts-manager/useSetScopes/index.tsx +1 -0
- package/shortcuts-manager/useSetScopes/useSetScopes.native.tsx +9 -0
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +25 -0
- package/shortcuts-manager/useShortcut/index.tsx +2 -0
- package/shortcuts-manager/useShortcut/types.ts +3 -0
- package/shortcuts-manager/useShortcut/useShortcut.native.tsx +9 -0
- package/shortcuts-manager/useShortcut/useShortcut.tsx +61 -0
- package/shortcuts-manager/utils.ts +105 -0
- package/styles/index.ts +4 -0
- package/styles/overlay.ts +69 -0
- package/styles/shadow.ts +21 -0
- package/styles/themes/DarkTheme.tsx +98 -0
- package/styles/themes/LightTheme.tsx +212 -0
- package/styles/themes/tokens.ts +248 -0
- package/styles/utils.ts +11 -0
- package/types/index.ts +129 -0
- package/types/theme.ts +159 -0
- package/utils/DocumentPicker/documentPicker.native.ts +10 -0
- package/utils/DocumentPicker/documentPicker.ts +76 -0
- package/utils/DocumentPicker/index.ts +2 -0
- package/utils/DocumentPicker/types.ts +28 -0
- package/utils/addEventListener.tsx +51 -0
- package/utils/backgroundContext.ts +9 -0
- package/utils/color.ts +22 -0
- package/utils/compare/index.ts +54 -0
- package/utils/composeEventHandlers.ts +9 -0
- package/utils/createNumberMask/createNumberMask.ts +98 -0
- package/utils/createNumberMask/index.ts +5 -0
- package/utils/createSyntheticEvent.ts +31 -0
- package/utils/date-fns.ts +7 -0
- package/utils/dateTimePicker.ts +5 -0
- package/utils/escapeRegex.ts +9 -0
- package/utils/extractTextStyles.ts +52 -0
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +26 -0
- package/utils/formatNumberWithMask/formatWithMask.ts +119 -0
- package/utils/formatNumberWithMask/index.ts +6 -0
- package/utils/getCursorStyle/getCursorStyle.native.ts +1 -0
- package/utils/getCursorStyle/getCursorStyle.ts +1 -0
- package/utils/getCursorStyle/index.ts +1 -0
- package/utils/getOS/getOS.native.ts +7 -0
- package/utils/getOS/getOS.ts +24 -0
- package/utils/getOS/index.ts +1 -0
- package/utils/getyearRange.ts +5 -0
- package/utils/index.ts +20 -0
- package/utils/lodash.ts +50 -0
- package/utils/mergeRefs.ts +13 -0
- package/utils/normalizeBorderRadiuses.ts +24 -0
- package/utils/normalizeSpacings.ts +110 -0
- package/utils/normalizeToNumberString/index.ts +4 -0
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +48 -0
- package/utils/repository.ts +103 -0
- package/utils/resolveColorMode.ts +9 -0
- package/utils/resolveStateVariant.ts +26 -0
- package/utils/tokenStylesParser.ts +7 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import TextInputDefault from './TextInput';
|
|
3
|
+
|
|
4
|
+
registerMoleculesComponents({
|
|
5
|
+
TextInput: TextInputDefault,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const TextInput = getRegisteredComponentWithFallback('TextInput', TextInputDefault);
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
type ElementProps as TextInputElementProps,
|
|
12
|
+
type TextInputHandles,
|
|
13
|
+
type Props as TextInputProps,
|
|
14
|
+
} from './TextInput';
|
|
15
|
+
export type * from './types';
|
|
16
|
+
export { styles as textInputStyles } from './utils';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { ReactElement, RefObject } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
Animated,
|
|
4
|
+
BlurEvent,
|
|
5
|
+
ColorValue,
|
|
6
|
+
FocusEvent,
|
|
7
|
+
StyleProp,
|
|
8
|
+
TextInput as NativeTextInput,
|
|
9
|
+
TextStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
|
|
12
|
+
import type { Props as TextInputProps } from './TextInput';
|
|
13
|
+
|
|
14
|
+
export type TextInputLabelProp = string | ReactElement;
|
|
15
|
+
|
|
16
|
+
export type TextInputSize = 'lg' | 'md' | 'sm';
|
|
17
|
+
|
|
18
|
+
export type TextInputVariant = 'flat' | 'outlined' | 'plain';
|
|
19
|
+
|
|
20
|
+
export type RenderProps = {
|
|
21
|
+
ref: RefObject<NativeTextInput | null>;
|
|
22
|
+
onChangeText?: (a: string) => void;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
placeholderTextColor?: ColorValue;
|
|
25
|
+
editable?: boolean;
|
|
26
|
+
selectionColor?: string;
|
|
27
|
+
onFocus?: (args: FocusEvent) => void;
|
|
28
|
+
onBlur?: (args: BlurEvent) => void;
|
|
29
|
+
underlineColorAndroid?: string;
|
|
30
|
+
style: any;
|
|
31
|
+
multiline?: boolean;
|
|
32
|
+
size?: TextInputSize;
|
|
33
|
+
numberOfLines?: number;
|
|
34
|
+
value?: string;
|
|
35
|
+
adjustsFontSizeToFit?: boolean;
|
|
36
|
+
testID?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type State = {
|
|
40
|
+
labelAnimation: Animated.Value;
|
|
41
|
+
errorAnimation: Animated.Value;
|
|
42
|
+
focused: boolean;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
value?: string;
|
|
45
|
+
labelLayout: { measured: boolean; width: number; height: number };
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type InputBaseProps = {
|
|
49
|
+
parentState: State;
|
|
50
|
+
innerRef: RefObject<NativeTextInput | null>;
|
|
51
|
+
onFocus?: (args: any) => void;
|
|
52
|
+
onBlur?: (args: any) => void;
|
|
53
|
+
forceFocus: () => void;
|
|
54
|
+
onChangeText?: (value: string) => void;
|
|
55
|
+
onLayoutAnimatedText: (args: any) => void;
|
|
56
|
+
componentStyles: Record<string, any>;
|
|
57
|
+
} & Omit<
|
|
58
|
+
TextInputProps,
|
|
59
|
+
| 'style'
|
|
60
|
+
| 'activeOutlineColor'
|
|
61
|
+
| 'activeUnderlineColor'
|
|
62
|
+
| 'underlineColor'
|
|
63
|
+
| 'outlineColor'
|
|
64
|
+
| 'placeholderTextColor'
|
|
65
|
+
| 'selectionColor'
|
|
66
|
+
| 'containerStyle'
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
export type InputLabelProps = {
|
|
70
|
+
baseLabelTranslateX: number;
|
|
71
|
+
wiggleOffsetX: number;
|
|
72
|
+
labelScale: number;
|
|
73
|
+
floatingLabelVerticalOffset?: number;
|
|
74
|
+
paddingOffset?: { paddingLeft: number; paddingRight: number } | null;
|
|
75
|
+
labelTranslationXOffset?: number;
|
|
76
|
+
label?: TextInputLabelProp | null;
|
|
77
|
+
error?: boolean | null;
|
|
78
|
+
onLayoutAnimatedText: (args: any) => void;
|
|
79
|
+
maxFontSizeMultiplier?: number | undefined | null;
|
|
80
|
+
required?: boolean;
|
|
81
|
+
testID?: string;
|
|
82
|
+
style?: StyleProp<TextStyle>;
|
|
83
|
+
floatingStyle?: StyleProp<TextStyle>;
|
|
84
|
+
hasValue: boolean;
|
|
85
|
+
labelLayout: { measured: boolean; width: number; height: number };
|
|
86
|
+
labelAnimation: Animated.Value;
|
|
87
|
+
errorAnimation: Animated.Value;
|
|
88
|
+
focused: boolean;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type LabelBackgroundProps = {
|
|
92
|
+
labelProps: InputLabelProps;
|
|
93
|
+
labelStyle: any;
|
|
94
|
+
parentState: State;
|
|
95
|
+
maxFontSizeMultiplier?: number | undefined | null;
|
|
96
|
+
};
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getRegisteredComponentUtils,
|
|
5
|
+
getRegisteredMoleculesComponentStyles,
|
|
6
|
+
registerComponentsStyles,
|
|
7
|
+
registerComponentUtils,
|
|
8
|
+
} from '../../core';
|
|
9
|
+
|
|
10
|
+
export type States =
|
|
11
|
+
| 'disabled'
|
|
12
|
+
| 'focused'
|
|
13
|
+
| 'hovered'
|
|
14
|
+
| 'hoveredAndFocused'
|
|
15
|
+
| 'errorFocusedAndHovered'
|
|
16
|
+
| 'error'
|
|
17
|
+
| 'errorFocused'
|
|
18
|
+
| 'errorHovered'
|
|
19
|
+
| 'errorDisabled';
|
|
20
|
+
|
|
21
|
+
const getInputMinHeightDefault = (variant: string, size: string) => {
|
|
22
|
+
switch (true) {
|
|
23
|
+
case variant === 'outlined' && size === 'lg':
|
|
24
|
+
return 64;
|
|
25
|
+
case variant === 'outlined' && size === 'md':
|
|
26
|
+
return 56;
|
|
27
|
+
case variant === 'outlined' && size === 'sm':
|
|
28
|
+
return 48;
|
|
29
|
+
case variant === 'flat' && size === 'lg':
|
|
30
|
+
return 64;
|
|
31
|
+
case variant === 'flat' && size === 'md':
|
|
32
|
+
return 56;
|
|
33
|
+
case variant === 'flat' && size === 'sm':
|
|
34
|
+
return 52;
|
|
35
|
+
default:
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
registerComponentUtils('TextInput', {
|
|
41
|
+
getInputMinHeight: getInputMinHeightDefault,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export const getInputMinHeight =
|
|
45
|
+
getRegisteredComponentUtils('TextInput').getInputMinHeight ?? getInputMinHeightDefault;
|
|
46
|
+
|
|
47
|
+
const textInputStylesDefault = StyleSheet.create(theme => ({
|
|
48
|
+
root: {
|
|
49
|
+
variants: {
|
|
50
|
+
variant: {
|
|
51
|
+
outlined: {},
|
|
52
|
+
},
|
|
53
|
+
state: {
|
|
54
|
+
focused: {
|
|
55
|
+
...({
|
|
56
|
+
activeColor: theme.colors.primary,
|
|
57
|
+
} as Record<string, any>),
|
|
58
|
+
},
|
|
59
|
+
hovered: {},
|
|
60
|
+
hoveredAndFocused: {
|
|
61
|
+
...({
|
|
62
|
+
activeColor: theme.colors.primary,
|
|
63
|
+
} as Record<string, any>),
|
|
64
|
+
},
|
|
65
|
+
disabled: {},
|
|
66
|
+
error: {
|
|
67
|
+
...({
|
|
68
|
+
activeColor: theme.colors.error,
|
|
69
|
+
} as Record<string, any>),
|
|
70
|
+
},
|
|
71
|
+
errorFocused: {
|
|
72
|
+
...({
|
|
73
|
+
activeColor: theme.colors.error,
|
|
74
|
+
} as Record<string, any>),
|
|
75
|
+
},
|
|
76
|
+
errorFocusedAndHovered: {
|
|
77
|
+
...({
|
|
78
|
+
activeColor: theme.colors.error,
|
|
79
|
+
} as Record<string, any>),
|
|
80
|
+
},
|
|
81
|
+
errorDisabled: {
|
|
82
|
+
...({
|
|
83
|
+
activeColor: theme.colors.error,
|
|
84
|
+
} as Record<string, any>),
|
|
85
|
+
},
|
|
86
|
+
errorHovered: {},
|
|
87
|
+
},
|
|
88
|
+
size: {
|
|
89
|
+
lg: {},
|
|
90
|
+
md: {},
|
|
91
|
+
sm: {},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
container: {
|
|
97
|
+
flexDirection: 'row',
|
|
98
|
+
paddingHorizontal: theme.spacings['4'],
|
|
99
|
+
variants: {
|
|
100
|
+
variant: {
|
|
101
|
+
outlined: {
|
|
102
|
+
borderRadius: theme.shapes.corner.extraSmall,
|
|
103
|
+
},
|
|
104
|
+
flat: {
|
|
105
|
+
backgroundColor: theme.colors.surfaceVariant,
|
|
106
|
+
borderTopLeftRadius: theme.shapes.corner.extraSmall,
|
|
107
|
+
borderTopRightRadius: theme.shapes.corner.extraSmall,
|
|
108
|
+
},
|
|
109
|
+
plain: {},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
compoundVariants: [
|
|
113
|
+
{
|
|
114
|
+
variant: 'flat',
|
|
115
|
+
state: 'disabled',
|
|
116
|
+
styles: {
|
|
117
|
+
backgroundColor: theme.colors.surfaceVariant,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
leftElement: {
|
|
123
|
+
color: theme.colors.onSurfaceVariant,
|
|
124
|
+
iconSize: 20,
|
|
125
|
+
marginRight: theme.spacings['3'],
|
|
126
|
+
marginLeft: theme.spacings._1,
|
|
127
|
+
justifyContent: 'center',
|
|
128
|
+
|
|
129
|
+
state: {
|
|
130
|
+
disabled: {
|
|
131
|
+
color: theme.colors.onSurface,
|
|
132
|
+
opacity: 0.38,
|
|
133
|
+
},
|
|
134
|
+
error: {
|
|
135
|
+
color: theme.colors.onSurfaceVariant,
|
|
136
|
+
},
|
|
137
|
+
errorFocused: {
|
|
138
|
+
color: theme.colors.onSurfaceVariant,
|
|
139
|
+
},
|
|
140
|
+
errorFocusedAndHovered: {
|
|
141
|
+
color: theme.colors.onSurfaceVariant,
|
|
142
|
+
},
|
|
143
|
+
errorDisabled: {
|
|
144
|
+
color: theme.colors.onSurfaceVariant,
|
|
145
|
+
opacity: 0.38,
|
|
146
|
+
},
|
|
147
|
+
errorHovered: {
|
|
148
|
+
color: theme.colors.onSurfaceVariant,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
rightElement: {
|
|
153
|
+
color: theme.colors.onSurfaceVariant,
|
|
154
|
+
iconSize: 24,
|
|
155
|
+
marginRight: theme.spacings._1,
|
|
156
|
+
marginLeft: theme.spacings['3'],
|
|
157
|
+
justifyContent: 'center',
|
|
158
|
+
|
|
159
|
+
variants: {
|
|
160
|
+
state: {
|
|
161
|
+
disabled: {
|
|
162
|
+
color: theme.colors.onSurface,
|
|
163
|
+
opacity: 0.38,
|
|
164
|
+
},
|
|
165
|
+
error: {
|
|
166
|
+
color: theme.colors.error,
|
|
167
|
+
},
|
|
168
|
+
errorFocused: {
|
|
169
|
+
color: theme.colors.error,
|
|
170
|
+
},
|
|
171
|
+
errorFocusedAndHovered: {
|
|
172
|
+
color: theme.colors.error,
|
|
173
|
+
},
|
|
174
|
+
errorDisabled: {
|
|
175
|
+
color: theme.colors.error,
|
|
176
|
+
opacity: 0.38,
|
|
177
|
+
},
|
|
178
|
+
errorHovered: {
|
|
179
|
+
color: theme.colors.onErrorContainer,
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
floatingLabel: {
|
|
185
|
+
variants: {
|
|
186
|
+
variant: {
|
|
187
|
+
outlined: {
|
|
188
|
+
backgroundColor: theme.colors.surface,
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
labelText: {
|
|
194
|
+
position: 'absolute',
|
|
195
|
+
left: 0,
|
|
196
|
+
color: theme.colors.onSurfaceVariant,
|
|
197
|
+
typescale: theme.typescale.bodyLarge,
|
|
198
|
+
|
|
199
|
+
variants: {
|
|
200
|
+
size: {
|
|
201
|
+
lg: {
|
|
202
|
+
...theme.typescale.bodyExtraLarge,
|
|
203
|
+
},
|
|
204
|
+
md: {
|
|
205
|
+
...theme.typescale.bodyLarge,
|
|
206
|
+
},
|
|
207
|
+
sm: {
|
|
208
|
+
...theme.typescale.bodyMedium,
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
variant: {
|
|
213
|
+
outlined: {
|
|
214
|
+
paddingHorizontal: theme.spacings['1'],
|
|
215
|
+
marginLeft: theme.spacings._1,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
state: {
|
|
220
|
+
focused: {
|
|
221
|
+
color: theme.colors.primary,
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
hoveredAndFocused: {
|
|
225
|
+
color: theme.colors.primary,
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
disabled: {
|
|
229
|
+
color: theme.colors.onSurface,
|
|
230
|
+
opacity: 0.38,
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
error: {
|
|
234
|
+
color: theme.colors.error,
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
errorFocused: {
|
|
238
|
+
color: theme.colors.error,
|
|
239
|
+
},
|
|
240
|
+
|
|
241
|
+
errorFocusedAndHovered: {
|
|
242
|
+
color: theme.colors.error,
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
errorDisabled: {
|
|
246
|
+
color: theme.colors.error,
|
|
247
|
+
opacity: 0.38,
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
errorHovered: {
|
|
251
|
+
color: theme.colors.onErrorContainer,
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
inputText: {
|
|
257
|
+
color: theme.colors.onSurface,
|
|
258
|
+
...theme.typescale.bodyLarge,
|
|
259
|
+
flexGrow: 1,
|
|
260
|
+
|
|
261
|
+
variants: {
|
|
262
|
+
size: {
|
|
263
|
+
lg: {
|
|
264
|
+
...theme.typescale.bodyExtraLarge,
|
|
265
|
+
},
|
|
266
|
+
md: {
|
|
267
|
+
...theme.typescale.bodyLarge,
|
|
268
|
+
},
|
|
269
|
+
sm: {
|
|
270
|
+
...theme.typescale.bodyMedium,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
variant: {
|
|
274
|
+
flat: {},
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
state: {
|
|
278
|
+
disabled: {
|
|
279
|
+
color: theme.colors.onSurface,
|
|
280
|
+
opacity: 0.38,
|
|
281
|
+
},
|
|
282
|
+
error: {
|
|
283
|
+
color: theme.colors.onSurface,
|
|
284
|
+
},
|
|
285
|
+
errorFocused: {
|
|
286
|
+
color: theme.colors.onSurface,
|
|
287
|
+
},
|
|
288
|
+
errorFocusedAndHovered: {
|
|
289
|
+
color: theme.colors.onSurface,
|
|
290
|
+
},
|
|
291
|
+
errorDisabled: {
|
|
292
|
+
color: theme.colors.onSurface,
|
|
293
|
+
opacity: 0.38,
|
|
294
|
+
},
|
|
295
|
+
errorHovered: {
|
|
296
|
+
color: theme.colors.onSurface,
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
supportingText: {
|
|
302
|
+
variants: {
|
|
303
|
+
state: {
|
|
304
|
+
disabled: {
|
|
305
|
+
opacity: 0.38,
|
|
306
|
+
},
|
|
307
|
+
errorDisabled: {
|
|
308
|
+
opacity: 0.38,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
placeholder: {
|
|
314
|
+
color: theme.colors.onSurfaceVariant,
|
|
315
|
+
},
|
|
316
|
+
outline: {
|
|
317
|
+
position: 'absolute',
|
|
318
|
+
left: 0,
|
|
319
|
+
right: 0,
|
|
320
|
+
top: 0,
|
|
321
|
+
bottom: 0,
|
|
322
|
+
_web: {
|
|
323
|
+
borderRadius: 'inherit',
|
|
324
|
+
},
|
|
325
|
+
variants: {
|
|
326
|
+
variant: {
|
|
327
|
+
outlined: {
|
|
328
|
+
borderRadius: theme.shapes.corner.extraSmall,
|
|
329
|
+
borderColor: theme.colors.outline,
|
|
330
|
+
borderWidth: 1,
|
|
331
|
+
},
|
|
332
|
+
flat: {
|
|
333
|
+
backgroundColor: theme.colors.surfaceVariant,
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
compoundVariants: [
|
|
338
|
+
{
|
|
339
|
+
variant: 'outlined',
|
|
340
|
+
state: 'focused',
|
|
341
|
+
styles: {
|
|
342
|
+
borderWidth: 2,
|
|
343
|
+
borderColor: theme.colors.primary,
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
variant: 'outlined',
|
|
348
|
+
state: 'errorDisabled',
|
|
349
|
+
styles: {
|
|
350
|
+
borderColor: theme.colors.error,
|
|
351
|
+
backgroundColor: theme.colors.surface,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
variant: 'outlined',
|
|
356
|
+
state: 'hovered',
|
|
357
|
+
styles: {
|
|
358
|
+
borderColor: theme.colors.onSurface,
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
variant: 'outlined',
|
|
363
|
+
state: 'errorHovered',
|
|
364
|
+
styles: {
|
|
365
|
+
borderColor: theme.colors.onErrorContainer,
|
|
366
|
+
backgroundColor: theme.colors.surface,
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
variant: 'outlined',
|
|
371
|
+
state: 'hoveredAndFocused',
|
|
372
|
+
styles: {
|
|
373
|
+
borderWidth: 2,
|
|
374
|
+
borderColor: theme.colors.primary,
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
variant: 'outlined',
|
|
379
|
+
state: 'errorFocusedAndHovered',
|
|
380
|
+
styles: {
|
|
381
|
+
borderWidth: 2,
|
|
382
|
+
borderColor: theme.colors.error,
|
|
383
|
+
backgroundColor: theme.colors.surface,
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
variant: 'outlined',
|
|
388
|
+
state: 'errorFocused',
|
|
389
|
+
styles: {
|
|
390
|
+
borderWidth: 2,
|
|
391
|
+
borderColor: theme.colors.error,
|
|
392
|
+
backgroundColor: theme.colors.surface,
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
variant: 'outlined',
|
|
397
|
+
state: 'error',
|
|
398
|
+
styles: {
|
|
399
|
+
borderColor: theme.colors.error,
|
|
400
|
+
backgroundColor: theme.colors.surface,
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
},
|
|
405
|
+
activeIndicator: {
|
|
406
|
+
variants: {
|
|
407
|
+
variant: {
|
|
408
|
+
flat: {
|
|
409
|
+
height: 1,
|
|
410
|
+
backgroundColor: theme.colors.onSurfaceVariant,
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
state: {
|
|
414
|
+
errorHovered: {
|
|
415
|
+
backgroundColor: theme.colors.onErrorContainer,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
compoundVariants: [
|
|
420
|
+
{
|
|
421
|
+
variant: 'flat',
|
|
422
|
+
state: 'focused',
|
|
423
|
+
styles: {
|
|
424
|
+
height: 2,
|
|
425
|
+
backgroundColor: theme.colors.primary,
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
variant: 'flat',
|
|
430
|
+
state: 'hovered',
|
|
431
|
+
styles: {
|
|
432
|
+
height: 1,
|
|
433
|
+
backgroundColor: theme.colors.onSurface,
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
variant: 'flat',
|
|
438
|
+
state: 'errorHovered',
|
|
439
|
+
styles: {
|
|
440
|
+
height: 1,
|
|
441
|
+
backgroundColor: theme.colors.onErrorContainer,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
variant: 'flat',
|
|
446
|
+
state: 'hoveredAndFocused',
|
|
447
|
+
styles: {
|
|
448
|
+
height: 2,
|
|
449
|
+
backgroundColor: theme.colors.primary,
|
|
450
|
+
},
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
variant: 'flat',
|
|
454
|
+
state: 'errorFocusedAndHovered',
|
|
455
|
+
styles: {
|
|
456
|
+
height: 2,
|
|
457
|
+
backgroundColor: theme.colors.error,
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
variant: 'flat',
|
|
462
|
+
state: 'disabled',
|
|
463
|
+
styles: {
|
|
464
|
+
height: 1,
|
|
465
|
+
backgroundColor: theme.colors.onSurface,
|
|
466
|
+
opacity: 0.38,
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
variant: 'flat',
|
|
471
|
+
state: 'error',
|
|
472
|
+
styles: {
|
|
473
|
+
backgroundColor: theme.colors.error,
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
variant: 'flat',
|
|
478
|
+
state: 'errorFocused',
|
|
479
|
+
styles: {
|
|
480
|
+
height: 2,
|
|
481
|
+
backgroundColor: theme.colors.error,
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
variant: 'flat',
|
|
486
|
+
state: 'errorDisabled',
|
|
487
|
+
styles: {
|
|
488
|
+
height: 1,
|
|
489
|
+
backgroundColor: theme.colors.error,
|
|
490
|
+
opacity: 0.38,
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
],
|
|
494
|
+
},
|
|
495
|
+
stateLayer: {
|
|
496
|
+
compoundVariants: [
|
|
497
|
+
{
|
|
498
|
+
variant: 'flat',
|
|
499
|
+
state: 'hovered',
|
|
500
|
+
styles: {
|
|
501
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
variant: 'flat',
|
|
506
|
+
state: 'errorHovered',
|
|
507
|
+
styles: {
|
|
508
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
],
|
|
512
|
+
},
|
|
513
|
+
underline: {
|
|
514
|
+
position: 'absolute',
|
|
515
|
+
left: 0,
|
|
516
|
+
right: 0,
|
|
517
|
+
bottom: 0,
|
|
518
|
+
height: 1,
|
|
519
|
+
zIndex: 1,
|
|
520
|
+
},
|
|
521
|
+
labelContainer: {
|
|
522
|
+
paddingTop: 0,
|
|
523
|
+
paddingBottom: 0,
|
|
524
|
+
flexGrow: 1,
|
|
525
|
+
flexShrink: 1,
|
|
526
|
+
},
|
|
527
|
+
patchContainer: {
|
|
528
|
+
height: 24,
|
|
529
|
+
zIndex: 2,
|
|
530
|
+
},
|
|
531
|
+
}));
|
|
532
|
+
|
|
533
|
+
registerComponentsStyles({
|
|
534
|
+
TextInput: textInputStylesDefault,
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
export const styles = getRegisteredMoleculesComponentStyles('TextInput');
|
|
538
|
+
|
|
539
|
+
export const inputLabelStyles = StyleSheet.create({
|
|
540
|
+
labelContainer: {
|
|
541
|
+
zIndex: 3,
|
|
542
|
+
justifyContent: 'center',
|
|
543
|
+
},
|
|
544
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
|
+
import type { BlurEvent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { TextInput, type TextInputProps } from '../TextInput';
|
|
5
|
+
import { enhanceTextWithMask } from './utils';
|
|
6
|
+
|
|
7
|
+
export type Props = Omit<TextInputProps, 'onChangeText'> & {
|
|
8
|
+
mask: string;
|
|
9
|
+
onChangeText?: (text: string) => void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// TODO - make it more universal
|
|
13
|
+
function TextInputWithMask(
|
|
14
|
+
{ onChangeText: onChangeTextProp, value = '', mask, onBlur: onBlurProp, ...rest }: Props,
|
|
15
|
+
ref: any,
|
|
16
|
+
) {
|
|
17
|
+
const [controlledValue, setControlledValue] = useState<string>(value || '');
|
|
18
|
+
|
|
19
|
+
const inputRef = useRef(null);
|
|
20
|
+
|
|
21
|
+
const onChangeText = useCallback(
|
|
22
|
+
(text: string) => {
|
|
23
|
+
const enhancedText = enhanceTextWithMask(text, mask, controlledValue);
|
|
24
|
+
setControlledValue(enhancedText);
|
|
25
|
+
onChangeTextProp?.(enhancedText);
|
|
26
|
+
},
|
|
27
|
+
[controlledValue, mask, onChangeTextProp],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const onBlur = useCallback(
|
|
31
|
+
(e: BlurEvent) => {
|
|
32
|
+
onBlurProp?.(e);
|
|
33
|
+
onChangeTextProp?.(controlledValue);
|
|
34
|
+
},
|
|
35
|
+
[controlledValue, onBlurProp, onChangeTextProp],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
setControlledValue(value || '');
|
|
40
|
+
}, [value]);
|
|
41
|
+
|
|
42
|
+
useImperativeHandle(ref, () =>
|
|
43
|
+
Object.assign(inputRef?.current || {}, { setDisplayValue: setControlledValue }),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<TextInput
|
|
48
|
+
ref={inputRef}
|
|
49
|
+
{...rest}
|
|
50
|
+
value={controlledValue}
|
|
51
|
+
onChangeText={onChangeText}
|
|
52
|
+
onBlur={onBlur}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default forwardRef(TextInputWithMask);
|