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,261 @@
|
|
|
1
|
+
import { forwardRef, memo, type ReactNode, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Platform,
|
|
5
|
+
Pressable,
|
|
6
|
+
// Easing,
|
|
7
|
+
type StyleProp,
|
|
8
|
+
useWindowDimensions,
|
|
9
|
+
View,
|
|
10
|
+
type ViewProps,
|
|
11
|
+
type ViewStyle,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
14
|
+
|
|
15
|
+
import { useBackHandler } from '../../hooks';
|
|
16
|
+
import type { MD3Elevation } from '../../types/theme';
|
|
17
|
+
import { Surface } from '../Surface';
|
|
18
|
+
import { modalStyles } from './utils';
|
|
19
|
+
|
|
20
|
+
export type Props = ViewProps & {
|
|
21
|
+
/**
|
|
22
|
+
* Determines whether clicking outside the modal dismiss it.
|
|
23
|
+
*/
|
|
24
|
+
dismissible?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Accessibility label for the overlay. This is read by the screen reader when the user taps outside the modal.
|
|
27
|
+
*/
|
|
28
|
+
overlayAccessibilityLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* content elevation
|
|
31
|
+
*/
|
|
32
|
+
elevation?: MD3Elevation;
|
|
33
|
+
/**
|
|
34
|
+
* to determine whether the modal is visible or not
|
|
35
|
+
*/
|
|
36
|
+
isOpen: boolean | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* onClose function will be trigger when the modal is dismissed
|
|
39
|
+
*/
|
|
40
|
+
onClose?: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Content of the `Modal`.
|
|
43
|
+
*/
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Style for the content of the modal
|
|
47
|
+
*/
|
|
48
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
49
|
+
/**
|
|
50
|
+
* Size of the modal
|
|
51
|
+
* md - width and height - auto
|
|
52
|
+
* lg - maxWidth:600, maxHeight:800
|
|
53
|
+
*/
|
|
54
|
+
size?: 'md' | 'lg';
|
|
55
|
+
/**
|
|
56
|
+
* Style for the wrapper of the modal.
|
|
57
|
+
* Use this prop to change the default wrapper style or to override safe area insets with marginTop and marginBottom.
|
|
58
|
+
*/
|
|
59
|
+
style?: StyleProp<ViewStyle>;
|
|
60
|
+
backdropStyle?: StyleProp<ViewStyle>;
|
|
61
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
62
|
+
// /**
|
|
63
|
+
// * Duration of the animations in the modal
|
|
64
|
+
// * @default 220
|
|
65
|
+
// * */
|
|
66
|
+
// animationDuration?: number;
|
|
67
|
+
/**
|
|
68
|
+
* testID to be used on tests.
|
|
69
|
+
*/
|
|
70
|
+
testID?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// const DEFAULT_DURATION = 220;
|
|
74
|
+
|
|
75
|
+
function Modal(
|
|
76
|
+
{
|
|
77
|
+
dismissible = true,
|
|
78
|
+
isOpen = false,
|
|
79
|
+
overlayAccessibilityLabel = 'Close modal',
|
|
80
|
+
onClose,
|
|
81
|
+
children,
|
|
82
|
+
contentContainerStyle: contentContainerStyleProp,
|
|
83
|
+
elevation,
|
|
84
|
+
size = 'md',
|
|
85
|
+
style,
|
|
86
|
+
containerStyle,
|
|
87
|
+
// animationDuration = DEFAULT_DURATION,
|
|
88
|
+
testID = 'modal',
|
|
89
|
+
backdropStyle: backdropStyleProp,
|
|
90
|
+
...rest
|
|
91
|
+
}: Props,
|
|
92
|
+
ref: any,
|
|
93
|
+
) {
|
|
94
|
+
modalStyles.useVariants({
|
|
95
|
+
size: size as any,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const visibleRef = useRef<boolean>(isOpen);
|
|
99
|
+
const originalBodyOverflowRef = useRef<string | null>(null);
|
|
100
|
+
// const prevVisible = useRef<boolean | null>(null);
|
|
101
|
+
// const opacityRef = useRef(new Animated.Value(isOpen ? 1 : 0));
|
|
102
|
+
const hideModalRef = useRef<() => void>(() => {});
|
|
103
|
+
|
|
104
|
+
const dimensions = useWindowDimensions();
|
|
105
|
+
|
|
106
|
+
const { backdropStyle, contentContainerStyle, contentStyle } = useMemo(() => {
|
|
107
|
+
return {
|
|
108
|
+
animationScale: 1,
|
|
109
|
+
backdropStyle: [
|
|
110
|
+
modalStyles.backdrop,
|
|
111
|
+
{
|
|
112
|
+
// @ts-ignore to resolve maximum callstack exceeded issue
|
|
113
|
+
// TODO - find out why this is happening(it isn't happening on contentStyle)
|
|
114
|
+
opacity: 1,
|
|
115
|
+
},
|
|
116
|
+
backdropStyleProp,
|
|
117
|
+
],
|
|
118
|
+
contentContainerStyle: [
|
|
119
|
+
styles.baseFill,
|
|
120
|
+
modalStyles.contentContainer,
|
|
121
|
+
contentContainerStyleProp,
|
|
122
|
+
],
|
|
123
|
+
contentStyle: [
|
|
124
|
+
modalStyles.modalContent,
|
|
125
|
+
{ width: dimensions.width, opacity: 1 },
|
|
126
|
+
style,
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
130
|
+
}, [backdropStyleProp, contentContainerStyleProp, dimensions.width, style, size]);
|
|
131
|
+
|
|
132
|
+
const handleBack = useCallback(() => {
|
|
133
|
+
if (dismissible) {
|
|
134
|
+
hideModalRef.current();
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}, [dismissible]);
|
|
138
|
+
|
|
139
|
+
useBackHandler({
|
|
140
|
+
enabled: isOpen,
|
|
141
|
+
callback: handleBack,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// const showModal = useCallback(() => {
|
|
145
|
+
// Animated.timing(opacityRef.current, {
|
|
146
|
+
// toValue: 1,
|
|
147
|
+
// duration: animationScale * animationDuration,
|
|
148
|
+
// easing: Easing.out(Easing.cubic),
|
|
149
|
+
// useNativeDriver: true,
|
|
150
|
+
// }).start();
|
|
151
|
+
// }, [animationDuration, animationScale, opacityRef]);
|
|
152
|
+
|
|
153
|
+
const hideModal = useCallback(() => {
|
|
154
|
+
// Animated.timing(opacityRef.current, {
|
|
155
|
+
// toValue: 0,
|
|
156
|
+
// duration: animationScale * animationDuration,
|
|
157
|
+
// easing: Easing.out(Easing.cubic),
|
|
158
|
+
// useNativeDriver: true,
|
|
159
|
+
// }).start(({ finished }) => {
|
|
160
|
+
// if (!finished) {
|
|
161
|
+
// return;
|
|
162
|
+
// }
|
|
163
|
+
|
|
164
|
+
// if (isOpen && onClose) {
|
|
165
|
+
// onClose();
|
|
166
|
+
// }
|
|
167
|
+
// });
|
|
168
|
+
|
|
169
|
+
if (isOpen && onClose) {
|
|
170
|
+
onClose();
|
|
171
|
+
}
|
|
172
|
+
}, [isOpen, onClose]);
|
|
173
|
+
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
hideModalRef.current = hideModal;
|
|
176
|
+
}, [hideModal]);
|
|
177
|
+
|
|
178
|
+
useEffect(() => {
|
|
179
|
+
visibleRef.current = isOpen;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (Platform.OS !== 'web' || globalThis.document === undefined) return;
|
|
184
|
+
|
|
185
|
+
const body = document.body;
|
|
186
|
+
|
|
187
|
+
if (isOpen) {
|
|
188
|
+
if (originalBodyOverflowRef.current === null) {
|
|
189
|
+
originalBodyOverflowRef.current = body.style.overflow;
|
|
190
|
+
}
|
|
191
|
+
body.style.overflow = 'hidden';
|
|
192
|
+
} else if (originalBodyOverflowRef.current !== null) {
|
|
193
|
+
body.style.overflow = originalBodyOverflowRef.current;
|
|
194
|
+
originalBodyOverflowRef.current = null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return () => {
|
|
198
|
+
if (originalBodyOverflowRef.current !== null) {
|
|
199
|
+
body.style.overflow = originalBodyOverflowRef.current;
|
|
200
|
+
originalBodyOverflowRef.current = null;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}, [isOpen]);
|
|
204
|
+
|
|
205
|
+
// useEffect(() => {
|
|
206
|
+
// if (prevVisible.current !== isOpen) {
|
|
207
|
+
// if (isOpen) {
|
|
208
|
+
// showModal();
|
|
209
|
+
// } else {
|
|
210
|
+
// hideModal();
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
// prevVisible.current = isOpen;
|
|
214
|
+
// }, [hideModal, showModal, isOpen]);
|
|
215
|
+
|
|
216
|
+
if (!isOpen) return null;
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<View
|
|
220
|
+
pointerEvents={isOpen ? 'auto' : 'none'}
|
|
221
|
+
accessibilityViewIsModal
|
|
222
|
+
accessibilityLiveRegion="polite"
|
|
223
|
+
style={[styles.baseFill, modalStyles.container, containerStyle]}
|
|
224
|
+
onAccessibilityEscape={hideModal}
|
|
225
|
+
testID={testID}
|
|
226
|
+
ref={ref}
|
|
227
|
+
{...rest}>
|
|
228
|
+
<Pressable
|
|
229
|
+
style={styles.baseFill}
|
|
230
|
+
accessibilityLabel={overlayAccessibilityLabel}
|
|
231
|
+
accessibilityRole="button"
|
|
232
|
+
disabled={!dismissible}
|
|
233
|
+
onPress={dismissible ? hideModal : undefined}
|
|
234
|
+
importantForAccessibility="no">
|
|
235
|
+
<Animated.View testID={`${testID}-backdrop`} style={backdropStyle} />
|
|
236
|
+
</Pressable>
|
|
237
|
+
<View
|
|
238
|
+
style={contentContainerStyle}
|
|
239
|
+
pointerEvents="box-none"
|
|
240
|
+
testID={`${testID}-contentContainer`}>
|
|
241
|
+
<Surface style={contentStyle} elevation={elevation} testID={`${testID}-content`}>
|
|
242
|
+
{children}
|
|
243
|
+
</Surface>
|
|
244
|
+
</View>
|
|
245
|
+
</View>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const styles = StyleSheet.create({
|
|
250
|
+
baseFill: {
|
|
251
|
+
_web: {
|
|
252
|
+
position: 'fixed',
|
|
253
|
+
top: 0,
|
|
254
|
+
right: 0,
|
|
255
|
+
bottom: 0,
|
|
256
|
+
left: 0,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
export default memo(forwardRef(Modal));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import ModalDefault from './Modal';
|
|
3
|
+
|
|
4
|
+
registerMoleculesComponents({
|
|
5
|
+
Modal: ModalDefault,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const Modal = getRegisteredComponentWithFallback('Modal', ModalDefault);
|
|
9
|
+
|
|
10
|
+
export type { Props as ModalProps } from './Modal';
|
|
11
|
+
export { modalStyles } from './utils';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
|
|
5
|
+
const modalStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
+
root: {},
|
|
7
|
+
container: {
|
|
8
|
+
zIndex: 100,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
backdrop: {
|
|
12
|
+
flex: 1,
|
|
13
|
+
backgroundColor: theme.colors.backdrop,
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
contentContainer: {
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
flex: 1,
|
|
20
|
+
},
|
|
21
|
+
modalContent: {
|
|
22
|
+
minWidth: 280,
|
|
23
|
+
backgroundColor: theme.colors.surface,
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
md: {
|
|
29
|
+
maxWidth: 448,
|
|
30
|
+
borderRadius: 10,
|
|
31
|
+
},
|
|
32
|
+
lg: {
|
|
33
|
+
maxWidth: 700,
|
|
34
|
+
borderRadius: 10,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
registerComponentsStyles({
|
|
42
|
+
Modal: modalStylesDefault,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const modalStyles = getRegisteredMoleculesComponentStyles('Modal');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { memo, type ReactElement } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useSubcomponents } from '../../hooks';
|
|
5
|
+
import { navigationRailStyles } from './utils';
|
|
6
|
+
|
|
7
|
+
export type Props = Omit<ViewProps, 'children'> & {
|
|
8
|
+
children: ReactElement | ReactElement[];
|
|
9
|
+
};
|
|
10
|
+
const allowedChildren = [
|
|
11
|
+
'NavigationRail_Header',
|
|
12
|
+
'NavigationRail_Content',
|
|
13
|
+
'NavigationRail_Footer',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const NavigationRail = ({ children, style, ...rest }: Props) => {
|
|
17
|
+
const { NavigationRail_Header, NavigationRail_Content, NavigationRail_Footer } =
|
|
18
|
+
useSubcomponents({
|
|
19
|
+
children,
|
|
20
|
+
allowedChildren,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<View style={[navigationRailStyles.root, style]} {...rest}>
|
|
25
|
+
{NavigationRail_Header[0]}
|
|
26
|
+
{NavigationRail_Content[0]}
|
|
27
|
+
{NavigationRail_Footer[0]}
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default memo(NavigationRail);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import { type ScrollViewProps, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { navigationRailContentStyles } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = ScrollViewProps & {
|
|
7
|
+
/**
|
|
8
|
+
* ContainerComponent prop allows to replace the default container used in DrawerContent - ScrollView
|
|
9
|
+
* */
|
|
10
|
+
ContainerComponent?: ComponentType<any>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const NavigationRailContent = ({ style, children, ContainerComponent, ...rest }: Props) => {
|
|
14
|
+
const Container = ContainerComponent || View;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Container style={[navigationRailContentStyles.root, style]} {...rest}>
|
|
18
|
+
{children}
|
|
19
|
+
</Container>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
NavigationRailContent.displayName = 'NavigationRail_Content';
|
|
24
|
+
|
|
25
|
+
export default NavigationRailContent;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { navigationRailFooterStyles } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = ViewProps & {};
|
|
7
|
+
|
|
8
|
+
const NavigationRailFooter = memo(({ style, children, ...rest }: Props) => {
|
|
9
|
+
return (
|
|
10
|
+
<View style={[navigationRailFooterStyles.root, style]} {...rest}>
|
|
11
|
+
{children}
|
|
12
|
+
</View>
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
NavigationRailFooter.displayName = 'NavigationRail_Footer';
|
|
17
|
+
|
|
18
|
+
export default NavigationRailFooter;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { navigationRailHeaderStyles } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = ViewProps & {};
|
|
7
|
+
|
|
8
|
+
const NavigationRailHeader = memo(({ style, children, ...rest }: Props) => {
|
|
9
|
+
return (
|
|
10
|
+
<View style={[navigationRailHeaderStyles.root, style]} {...rest}>
|
|
11
|
+
{children}
|
|
12
|
+
</View>
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
NavigationRailHeader.displayName = 'NavigationRail_Header';
|
|
17
|
+
|
|
18
|
+
export default NavigationRailHeader;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { forwardRef, memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
GestureResponderEvent,
|
|
4
|
+
PressableProps,
|
|
5
|
+
StyleProp,
|
|
6
|
+
TextProps,
|
|
7
|
+
ViewProps,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { Pressable } from 'react-native';
|
|
11
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
12
|
+
|
|
13
|
+
import { useActionState } from '../../hooks';
|
|
14
|
+
import { resolveStateVariant } from '../../utils';
|
|
15
|
+
import { Badge, type BadgeProps } from '../Badge';
|
|
16
|
+
import { Icon, type IconProps, type IconType } from '../Icon';
|
|
17
|
+
import { StateLayer } from '../StateLayer';
|
|
18
|
+
import { Text } from '../Text';
|
|
19
|
+
import { TouchableRipple, type TouchableRippleProps } from '../TouchableRipple';
|
|
20
|
+
import { navigationRailItemStyles } from './utils';
|
|
21
|
+
|
|
22
|
+
export type Props = Omit<PressableProps, 'children' | 'disabled' | 'onPress'> & {
|
|
23
|
+
/**
|
|
24
|
+
* Whether the NavigationRailItem is active or not
|
|
25
|
+
* */
|
|
26
|
+
active?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* label of the NavigationRailItem, if not specified only the icon will be shown and active indicator with be circular
|
|
29
|
+
* */
|
|
30
|
+
label?: string;
|
|
31
|
+
/**
|
|
32
|
+
* name of the icon
|
|
33
|
+
* */
|
|
34
|
+
iconName: string;
|
|
35
|
+
/**
|
|
36
|
+
* type of the icon
|
|
37
|
+
* */
|
|
38
|
+
iconType?: IconType;
|
|
39
|
+
/**
|
|
40
|
+
* name of the active icon. If not specified, iconName will be used
|
|
41
|
+
* */
|
|
42
|
+
activeIconName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* type of the active icon. If not specified, default iconType will be used
|
|
45
|
+
* */
|
|
46
|
+
activeIconType?: IconType;
|
|
47
|
+
/**
|
|
48
|
+
* Icon Props
|
|
49
|
+
* */
|
|
50
|
+
iconProps?: Omit<IconProps, 'name' | 'type'>;
|
|
51
|
+
/**
|
|
52
|
+
* size of the NavigationRailItem
|
|
53
|
+
* */
|
|
54
|
+
size?: 'sm' | 'md' | 'lg';
|
|
55
|
+
/**
|
|
56
|
+
* onPress event for the icon, the same event will be triggered if it's click on the icon, the label or the overall item
|
|
57
|
+
* */
|
|
58
|
+
onPress?: (e: GestureResponderEvent) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Icon Container Props
|
|
61
|
+
* */
|
|
62
|
+
iconContainerProps?: Partial<Omit<TouchableRippleProps, 'ref'>>;
|
|
63
|
+
/**
|
|
64
|
+
* Label Props
|
|
65
|
+
* */
|
|
66
|
+
labelProps?: Partial<TextProps>;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to display the badge or not
|
|
69
|
+
* */
|
|
70
|
+
showBadge?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Badge Label, if it's not specified and showBadge is true, sm badge will display
|
|
73
|
+
* */
|
|
74
|
+
badgeLabel?: BadgeProps['label'];
|
|
75
|
+
/**
|
|
76
|
+
* Badge Props
|
|
77
|
+
* */
|
|
78
|
+
badgeProps?: Omit<BadgeProps, 'label'>;
|
|
79
|
+
/**
|
|
80
|
+
* Props for the state layer
|
|
81
|
+
* */
|
|
82
|
+
stateLayerProps?: ViewProps;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const defaultIconSize = 24;
|
|
86
|
+
const emptyObj = {};
|
|
87
|
+
|
|
88
|
+
const NavigationRailItem = memo(
|
|
89
|
+
forwardRef(
|
|
90
|
+
(
|
|
91
|
+
{
|
|
92
|
+
active = false,
|
|
93
|
+
iconName,
|
|
94
|
+
iconType,
|
|
95
|
+
activeIconName,
|
|
96
|
+
activeIconType,
|
|
97
|
+
iconProps = emptyObj,
|
|
98
|
+
style,
|
|
99
|
+
label,
|
|
100
|
+
size = 'md',
|
|
101
|
+
onPress,
|
|
102
|
+
iconContainerProps = emptyObj,
|
|
103
|
+
labelProps = emptyObj,
|
|
104
|
+
showBadge = false,
|
|
105
|
+
badgeLabel,
|
|
106
|
+
badgeProps = emptyObj,
|
|
107
|
+
stateLayerProps = emptyObj,
|
|
108
|
+
testID,
|
|
109
|
+
...rest
|
|
110
|
+
}: Props,
|
|
111
|
+
ref: any,
|
|
112
|
+
) => {
|
|
113
|
+
const { hovered, actionsRef } = useActionState({ actionsToListen: ['hover'] });
|
|
114
|
+
|
|
115
|
+
const state = resolveStateVariant({
|
|
116
|
+
activeAndHovered: active && hovered,
|
|
117
|
+
active,
|
|
118
|
+
hovered,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
navigationRailItemStyles.useVariants({
|
|
122
|
+
state: state as any,
|
|
123
|
+
size,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const { iconContainerStyle, iconStyle, badgeStyle, stateLayerStyle } = useMemo(() => {
|
|
127
|
+
return {
|
|
128
|
+
iconContainerStyle: [
|
|
129
|
+
navigationRailItemStyles.iconContainer,
|
|
130
|
+
!label && {
|
|
131
|
+
height: navigationRailItemStyles.iconContainer.width,
|
|
132
|
+
},
|
|
133
|
+
iconContainerProps.style,
|
|
134
|
+
],
|
|
135
|
+
iconStyle: [navigationRailItemStyles.icon, iconProps.style],
|
|
136
|
+
badgeStyle: [
|
|
137
|
+
navigationRailItemStyles.badge,
|
|
138
|
+
badgeLabel && badgeProps.size !== 'sm' && styles.badgeWithLabel,
|
|
139
|
+
badgeProps.style,
|
|
140
|
+
] as StyleProp<ViewStyle>,
|
|
141
|
+
stateLayerStyle: [navigationRailItemStyles.stateLayer, stateLayerProps.style],
|
|
142
|
+
};
|
|
143
|
+
// eslint-disable-next-line
|
|
144
|
+
}, [
|
|
145
|
+
active,
|
|
146
|
+
hovered,
|
|
147
|
+
badgeLabel,
|
|
148
|
+
badgeProps.size,
|
|
149
|
+
badgeProps.style,
|
|
150
|
+
iconContainerProps.style,
|
|
151
|
+
iconProps.style,
|
|
152
|
+
label,
|
|
153
|
+
state,
|
|
154
|
+
size,
|
|
155
|
+
stateLayerProps.style,
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
const onPressIconContainer = useCallback(
|
|
159
|
+
(e: GestureResponderEvent) => {
|
|
160
|
+
iconContainerProps.onPress?.(e);
|
|
161
|
+
onPress?.(e);
|
|
162
|
+
},
|
|
163
|
+
[iconContainerProps, onPress],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<Pressable
|
|
168
|
+
style={[navigationRailItemStyles.root, style] as StyleProp<ViewStyle>}
|
|
169
|
+
onPress={onPress}
|
|
170
|
+
accessibilityRole="none"
|
|
171
|
+
testID={testID}
|
|
172
|
+
{...rest}
|
|
173
|
+
ref={ref}>
|
|
174
|
+
<TouchableRipple
|
|
175
|
+
borderless
|
|
176
|
+
testID={testID ? `${testID}-iconContainer` : ''}
|
|
177
|
+
{...iconContainerProps}
|
|
178
|
+
ref={actionsRef}
|
|
179
|
+
style={iconContainerStyle}
|
|
180
|
+
onPress={onPressIconContainer}>
|
|
181
|
+
<>
|
|
182
|
+
<Icon
|
|
183
|
+
size={defaultIconSize}
|
|
184
|
+
testID={testID ? `${testID}-icon` : ''}
|
|
185
|
+
{...iconProps}
|
|
186
|
+
style={iconStyle}
|
|
187
|
+
name={active ? activeIconName || iconName : iconName}
|
|
188
|
+
type={active ? activeIconType || iconType : iconType}>
|
|
189
|
+
{showBadge && (
|
|
190
|
+
<Badge label={badgeLabel} {...badgeProps} style={badgeStyle} />
|
|
191
|
+
)}
|
|
192
|
+
</Icon>
|
|
193
|
+
<StateLayer
|
|
194
|
+
testID={testID ? `${testID}-stateLayer` : ''}
|
|
195
|
+
{...stateLayerProps}
|
|
196
|
+
style={stateLayerStyle}
|
|
197
|
+
/>
|
|
198
|
+
</>
|
|
199
|
+
</TouchableRipple>
|
|
200
|
+
<>
|
|
201
|
+
{label && (
|
|
202
|
+
<Text
|
|
203
|
+
selectable={false}
|
|
204
|
+
testID={testID ? `${testID}-label` : ''}
|
|
205
|
+
{...labelProps}
|
|
206
|
+
style={navigationRailItemStyles.label}>
|
|
207
|
+
{label}
|
|
208
|
+
</Text>
|
|
209
|
+
)}
|
|
210
|
+
</>
|
|
211
|
+
</Pressable>
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
),
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
NavigationRailItem.displayName = 'NavigationRail_Item';
|
|
218
|
+
|
|
219
|
+
const styles = StyleSheet.create({
|
|
220
|
+
badgeWithLabel: {
|
|
221
|
+
bottom: '55%',
|
|
222
|
+
left: '45%',
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
export default NavigationRailItem;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import NavigationRailComponent from './NavigationRail';
|
|
3
|
+
import NavigationRailContent from './NavigationRailContent';
|
|
4
|
+
import NavigationRailFooter from './NavigationRailFooter';
|
|
5
|
+
import NavigationRailHeader from './NavigationRailHeader';
|
|
6
|
+
import NavigationRailItem from './NavigationRailItem';
|
|
7
|
+
|
|
8
|
+
export const NavigationRailDefault = Object.assign(NavigationRailComponent, {
|
|
9
|
+
Item: NavigationRailItem,
|
|
10
|
+
Header: NavigationRailHeader,
|
|
11
|
+
Content: NavigationRailContent,
|
|
12
|
+
Footer: NavigationRailFooter,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
registerMoleculesComponents({
|
|
16
|
+
NavigationRail: NavigationRailDefault,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const NavigationRail = getRegisteredComponentWithFallback(
|
|
20
|
+
'NavigationRail',
|
|
21
|
+
NavigationRailDefault,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export type { Props as NavigationRailProps } from './NavigationRail';
|
|
25
|
+
export type { Props as NavigationRailContentProps } from './NavigationRailContent';
|
|
26
|
+
export type { Props as NavigationRailFooterProps } from './NavigationRailFooter';
|
|
27
|
+
export type { Props as NavigationRailHeaderProps } from './NavigationRailHeader';
|
|
28
|
+
export type { Props as NavigationRailItemProps } from './NavigationRailItem';
|
|
29
|
+
export {
|
|
30
|
+
navigationRailContentStyles,
|
|
31
|
+
navigationRailFooterStyles,
|
|
32
|
+
navigationRailHeaderStyles,
|
|
33
|
+
navigationRailItemStyles,
|
|
34
|
+
navigationRailStyles,
|
|
35
|
+
} from './utils';
|