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,170 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
|
|
5
|
+
const navigationRailStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
+
root: {
|
|
7
|
+
width: 80,
|
|
8
|
+
backgroundColor: theme.colors.surface,
|
|
9
|
+
flexGrow: 1,
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const navigationRailHeaderStylesDefault = StyleSheet.create({
|
|
14
|
+
header: {
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const navigationRailContentStylesDefault = StyleSheet.create({
|
|
20
|
+
root: {
|
|
21
|
+
flexGrow: 1,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const navigationRailFooterStylesDefault = StyleSheet.create({
|
|
26
|
+
root: {
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const navigationRailItemStylesDefault = StyleSheet.create(theme => ({
|
|
32
|
+
root: {
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
marginBottom: theme.spacings['3'],
|
|
35
|
+
_web: {
|
|
36
|
+
cursor: 'pointer',
|
|
37
|
+
},
|
|
38
|
+
variants: {
|
|
39
|
+
state: {
|
|
40
|
+
hovered: {},
|
|
41
|
+
default: {},
|
|
42
|
+
active: {},
|
|
43
|
+
activeAndHovered: {},
|
|
44
|
+
},
|
|
45
|
+
size: {
|
|
46
|
+
undefined: {},
|
|
47
|
+
sm: {},
|
|
48
|
+
md: {},
|
|
49
|
+
lg: {},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
iconContainer: {
|
|
55
|
+
borderRadius: theme.shapes.corner.full,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
overflow: 'visible',
|
|
59
|
+
|
|
60
|
+
_web: {
|
|
61
|
+
cursor: 'pointer',
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
variants: {
|
|
65
|
+
state: {
|
|
66
|
+
hovered: {},
|
|
67
|
+
default: {},
|
|
68
|
+
active: {
|
|
69
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
70
|
+
},
|
|
71
|
+
activeAndHovered: {
|
|
72
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
size: {
|
|
77
|
+
undefined: {},
|
|
78
|
+
sm: {
|
|
79
|
+
width: 56,
|
|
80
|
+
height: 32,
|
|
81
|
+
},
|
|
82
|
+
md: {
|
|
83
|
+
width: 56,
|
|
84
|
+
height: 32,
|
|
85
|
+
},
|
|
86
|
+
lg: {
|
|
87
|
+
width: 56,
|
|
88
|
+
height: 32,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
icon: {
|
|
94
|
+
color: theme.colors.onSurfaceVariant,
|
|
95
|
+
position: 'relative',
|
|
96
|
+
|
|
97
|
+
variants: {
|
|
98
|
+
state: {
|
|
99
|
+
hovered: {},
|
|
100
|
+
default: {},
|
|
101
|
+
active: {
|
|
102
|
+
color: theme.colors.onSecondaryContainer,
|
|
103
|
+
},
|
|
104
|
+
activeAndHovered: {
|
|
105
|
+
color: theme.colors.onSecondaryContainer,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
badge: {
|
|
111
|
+
position: 'absolute',
|
|
112
|
+
bottom: '75%',
|
|
113
|
+
left: '75%',
|
|
114
|
+
zIndex: 2,
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
label: {
|
|
118
|
+
...theme.typescale.labelMedium,
|
|
119
|
+
color: theme.colors.onSurfaceVariant,
|
|
120
|
+
marginTop: theme.spacings['1'],
|
|
121
|
+
justifyContent: 'center',
|
|
122
|
+
|
|
123
|
+
variants: {
|
|
124
|
+
state: {
|
|
125
|
+
hovered: {},
|
|
126
|
+
default: {},
|
|
127
|
+
active: {
|
|
128
|
+
color: theme.colors.onSurface,
|
|
129
|
+
},
|
|
130
|
+
activeAndHovered: {
|
|
131
|
+
color: theme.colors.onSurface,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
stateLayer: {
|
|
138
|
+
borderRadius: theme.shapes.corner.full,
|
|
139
|
+
|
|
140
|
+
variants: {
|
|
141
|
+
state: {
|
|
142
|
+
active: {},
|
|
143
|
+
hovered: {
|
|
144
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurfaceVariant,
|
|
145
|
+
},
|
|
146
|
+
activeAndHovered: {
|
|
147
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
148
|
+
},
|
|
149
|
+
default: {},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
}));
|
|
154
|
+
|
|
155
|
+
registerComponentsStyles({
|
|
156
|
+
NavigationRail: navigationRailStylesDefault,
|
|
157
|
+
NavigationRail_Header: navigationRailHeaderStylesDefault,
|
|
158
|
+
NavigationRail_Content: navigationRailContentStylesDefault,
|
|
159
|
+
NavigationRail_Footer: navigationRailFooterStylesDefault,
|
|
160
|
+
NavigationRail_Item: navigationRailItemStylesDefault,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
export const navigationRailStyles = getRegisteredMoleculesComponentStyles('NavigationRail');
|
|
164
|
+
export const navigationRailHeaderStyles =
|
|
165
|
+
getRegisteredMoleculesComponentStyles('NavigationRail_Header');
|
|
166
|
+
export const navigationRailContentStyles =
|
|
167
|
+
getRegisteredMoleculesComponentStyles('NavigationRail_Content');
|
|
168
|
+
export const navigationRailFooterStyles =
|
|
169
|
+
getRegisteredMoleculesComponentStyles('NavigationRail_Footer');
|
|
170
|
+
export const navigationRailItemStyles = navigationRailItemStylesDefault;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
forwardRef,
|
|
4
|
+
memo,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
useCallback,
|
|
7
|
+
useImperativeHandle,
|
|
8
|
+
useMemo,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react';
|
|
11
|
+
|
|
12
|
+
export type Props = {
|
|
13
|
+
initialRouteName?: string;
|
|
14
|
+
children: ReactElement | ReactElement[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type NavigationStackHandle = {
|
|
18
|
+
currentRoute: string;
|
|
19
|
+
push: (route: string) => void;
|
|
20
|
+
pop: () => void;
|
|
21
|
+
navigate: (route: string) => void;
|
|
22
|
+
goBack: () => void;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const NavigationStack = ({ initialRouteName, children }: Props, ref: any) => {
|
|
26
|
+
const [currentStack, setCurrentStack] = useState<string[]>(() => [
|
|
27
|
+
initialRouteName ||
|
|
28
|
+
(
|
|
29
|
+
(Array.isArray(children)
|
|
30
|
+
? children.find(child => (!!child?.props as any)?.name)
|
|
31
|
+
: children
|
|
32
|
+
)?.props as any
|
|
33
|
+
)?.name ||
|
|
34
|
+
'',
|
|
35
|
+
]);
|
|
36
|
+
const currentRoute = currentStack[currentStack.length - 1] || '';
|
|
37
|
+
|
|
38
|
+
const push = useCallback((item: string) => {
|
|
39
|
+
setCurrentStack(prev => [...prev, item]);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
const pop = useCallback(() => {
|
|
43
|
+
setCurrentStack(prev => {
|
|
44
|
+
// we don't want to remove the last item in the stack
|
|
45
|
+
if (prev.length <= 1) return prev;
|
|
46
|
+
|
|
47
|
+
const newStack = [...prev];
|
|
48
|
+
|
|
49
|
+
newStack.pop();
|
|
50
|
+
return newStack;
|
|
51
|
+
});
|
|
52
|
+
}, []);
|
|
53
|
+
|
|
54
|
+
const contextValue = useMemo(
|
|
55
|
+
() => ({
|
|
56
|
+
currentRoute,
|
|
57
|
+
push,
|
|
58
|
+
pop,
|
|
59
|
+
navigate: push,
|
|
60
|
+
goBack: pop,
|
|
61
|
+
}),
|
|
62
|
+
[currentRoute, pop, push],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// the ref will get the same methods as the context
|
|
66
|
+
useImperativeHandle(ref, () => contextValue);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<NavigationStackContext.Provider value={contextValue}>
|
|
70
|
+
{children}
|
|
71
|
+
</NavigationStackContext.Provider>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type NavigationStackContextType = NavigationStackHandle & {};
|
|
76
|
+
|
|
77
|
+
export const NavigationStackContext = createContext<NavigationStackContextType>({
|
|
78
|
+
currentRoute: '',
|
|
79
|
+
push: () => {},
|
|
80
|
+
pop: () => {},
|
|
81
|
+
navigate: () => {},
|
|
82
|
+
goBack: () => {},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
export default memo(forwardRef(NavigationStack));
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { memo, type ReactElement, useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, type ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { navigationStackItemStyles, useNavigation } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = ViewProps & {
|
|
7
|
+
name: string;
|
|
8
|
+
children: ReactElement;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const NavigationStackItemContainer = memo(({ name, children, ...rest }: Props) => {
|
|
12
|
+
const { currentRoute } = useNavigation();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<NavigationStackItem isCurrentRoute={currentRoute === name} children={children} {...rest} />
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const NavigationStackItem = memo(
|
|
20
|
+
({
|
|
21
|
+
isCurrentRoute,
|
|
22
|
+
children,
|
|
23
|
+
style,
|
|
24
|
+
...rest
|
|
25
|
+
}: Omit<Props, 'name'> & { isCurrentRoute: boolean }) => {
|
|
26
|
+
const opacityRef = useRef(new Animated.Value(isCurrentRoute ? 1 : 0));
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (isCurrentRoute) {
|
|
30
|
+
opacityRef.current.setValue(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Animated.timing(opacityRef.current, {
|
|
34
|
+
toValue: isCurrentRoute ? 1 : 0,
|
|
35
|
+
duration: 250,
|
|
36
|
+
useNativeDriver: true,
|
|
37
|
+
}).start();
|
|
38
|
+
}, [isCurrentRoute, opacityRef]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{isCurrentRoute && (
|
|
43
|
+
<Animated.View
|
|
44
|
+
style={[
|
|
45
|
+
{ opacity: opacityRef.current },
|
|
46
|
+
navigationStackItemStyles.root,
|
|
47
|
+
style,
|
|
48
|
+
]}
|
|
49
|
+
{...rest}>
|
|
50
|
+
{children}
|
|
51
|
+
</Animated.View>
|
|
52
|
+
)}
|
|
53
|
+
</>
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
NavigationStackItemContainer.displayName = 'NavigationStack.Item';
|
|
59
|
+
|
|
60
|
+
export default NavigationStackItemContainer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import NavigationStackComponent from './NavigationStack';
|
|
3
|
+
import NavigationStackItem from './NavigationStackItem';
|
|
4
|
+
|
|
5
|
+
export const NavigationStackDefault = Object.assign(NavigationStackComponent, {
|
|
6
|
+
Item: NavigationStackItem,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
registerMoleculesComponents({
|
|
10
|
+
NavigationStack: NavigationStackDefault,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const NavigationStack = getRegisteredComponentWithFallback(
|
|
14
|
+
'NavigationStack',
|
|
15
|
+
NavigationStackDefault,
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export type { NavigationStackHandle, Props as NavigationStackProps } from './NavigationStack';
|
|
19
|
+
export type { Props as NavigationStackItemProps } from './NavigationStackItem';
|
|
20
|
+
export { navigationStackItemStyles, useNavigation, useRoute } from './utils';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
+
|
|
4
|
+
import { NavigationStackContext } from './NavigationStack';
|
|
5
|
+
|
|
6
|
+
export const useNavigation = () => {
|
|
7
|
+
return useContext(NavigationStackContext);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const useRoute = () => {
|
|
11
|
+
return useContext(NavigationStackContext).currentRoute;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const navigationStackItemStyles = StyleSheet.create({
|
|
15
|
+
root: {},
|
|
16
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Fragment, memo, useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
import { AppState, Dimensions, Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { ScopedTheme, UnistylesRuntime } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { Portal } from '../Portal';
|
|
6
|
+
import {
|
|
7
|
+
DEFAULT_ARROW_SIZE,
|
|
8
|
+
popoverDefaultStyles,
|
|
9
|
+
type PopoverProps,
|
|
10
|
+
useArrowStyles,
|
|
11
|
+
usePopover,
|
|
12
|
+
} from './common';
|
|
13
|
+
|
|
14
|
+
const Popover = ({
|
|
15
|
+
triggerRef,
|
|
16
|
+
children,
|
|
17
|
+
isOpen,
|
|
18
|
+
onClose,
|
|
19
|
+
position = 'bottom',
|
|
20
|
+
align = 'center',
|
|
21
|
+
style,
|
|
22
|
+
showArrow = false,
|
|
23
|
+
arrowSize = DEFAULT_ARROW_SIZE,
|
|
24
|
+
inverted = false,
|
|
25
|
+
triggerDimensions,
|
|
26
|
+
offset = 8,
|
|
27
|
+
...rest
|
|
28
|
+
}: PopoverProps) => {
|
|
29
|
+
const {
|
|
30
|
+
popoverLayoutRef,
|
|
31
|
+
targetLayoutRef,
|
|
32
|
+
actualPositionRef,
|
|
33
|
+
calculatedPosition,
|
|
34
|
+
calculateAndSetPosition,
|
|
35
|
+
handlePopoverLayout,
|
|
36
|
+
} = usePopover({
|
|
37
|
+
isOpen,
|
|
38
|
+
position,
|
|
39
|
+
align,
|
|
40
|
+
showArrow,
|
|
41
|
+
arrowSize,
|
|
42
|
+
offset,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const popoverRef = useRef<View>(null);
|
|
46
|
+
|
|
47
|
+
const measureTarget = useCallback(() => {
|
|
48
|
+
if (triggerRef.current) {
|
|
49
|
+
triggerRef.current.measure(
|
|
50
|
+
(
|
|
51
|
+
_fx: number,
|
|
52
|
+
_fy: number,
|
|
53
|
+
width: number,
|
|
54
|
+
height: number,
|
|
55
|
+
px: number,
|
|
56
|
+
py: number,
|
|
57
|
+
) => {
|
|
58
|
+
if (width !== 0 || height !== 0) {
|
|
59
|
+
const newLayout = { x: px, y: py, width, height };
|
|
60
|
+
const changed =
|
|
61
|
+
!targetLayoutRef.current ||
|
|
62
|
+
targetLayoutRef.current.x !== newLayout.x ||
|
|
63
|
+
targetLayoutRef.current.y !== newLayout.y ||
|
|
64
|
+
targetLayoutRef.current.width !== newLayout.width ||
|
|
65
|
+
targetLayoutRef.current.height !== newLayout.height;
|
|
66
|
+
|
|
67
|
+
if (changed) {
|
|
68
|
+
targetLayoutRef.current = newLayout;
|
|
69
|
+
calculateAndSetPosition();
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
targetLayoutRef.current = null;
|
|
73
|
+
calculateAndSetPosition();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
() => {
|
|
77
|
+
console.error('Failed to measure target element for Popover.');
|
|
78
|
+
targetLayoutRef.current = null;
|
|
79
|
+
calculateAndSetPosition();
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
targetLayoutRef.current = null;
|
|
84
|
+
calculateAndSetPosition();
|
|
85
|
+
}
|
|
86
|
+
}, [triggerRef, calculateAndSetPosition, targetLayoutRef]);
|
|
87
|
+
|
|
88
|
+
useLayoutEffect(() => {
|
|
89
|
+
if (isOpen) {
|
|
90
|
+
measureTarget();
|
|
91
|
+
}
|
|
92
|
+
}, [isOpen, measureTarget, triggerDimensions]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!isOpen) return;
|
|
96
|
+
const subscription = Dimensions.addEventListener('change', measureTarget);
|
|
97
|
+
return () => {
|
|
98
|
+
if (typeof subscription?.remove === 'function') {
|
|
99
|
+
subscription.remove();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}, [isOpen, measureTarget]);
|
|
103
|
+
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!isOpen || Platform.OS === 'web') return;
|
|
106
|
+
const handleAppStateChange = (nextAppState: string) => {
|
|
107
|
+
if (nextAppState === 'active') {
|
|
108
|
+
setTimeout(measureTarget, 50);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const subscription = AppState.addEventListener('change', handleAppStateChange);
|
|
112
|
+
return () => {
|
|
113
|
+
if (typeof subscription?.remove === 'function') {
|
|
114
|
+
subscription.remove();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}, [isOpen, measureTarget]);
|
|
118
|
+
|
|
119
|
+
const arrowStyles = useArrowStyles({
|
|
120
|
+
showArrow,
|
|
121
|
+
arrowSize,
|
|
122
|
+
style,
|
|
123
|
+
calculatedPosition,
|
|
124
|
+
targetLayoutRef,
|
|
125
|
+
popoverLayoutRef,
|
|
126
|
+
actualPositionRef,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const popoverStyle = calculatedPosition ?? popoverDefaultStyles;
|
|
130
|
+
const Wrapper = inverted ? ScopedTheme : Fragment;
|
|
131
|
+
|
|
132
|
+
if (!isOpen && popoverStyle.opacity === 0) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const handleOutsidePress = () => {
|
|
137
|
+
if (isOpen && onClose) {
|
|
138
|
+
onClose();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<Portal>
|
|
144
|
+
<Wrapper
|
|
145
|
+
{...(inverted
|
|
146
|
+
? { name: UnistylesRuntime.themeName === 'dark' ? 'light' : 'dark' }
|
|
147
|
+
: ({} as { name: 'light' }))}>
|
|
148
|
+
<Pressable onPress={handleOutsidePress} style={styles.overlay} />
|
|
149
|
+
|
|
150
|
+
<View
|
|
151
|
+
ref={popoverRef}
|
|
152
|
+
onLayout={handlePopoverLayout}
|
|
153
|
+
style={[styles.popoverContainer, style, popoverStyle]}
|
|
154
|
+
{...rest}>
|
|
155
|
+
{children}
|
|
156
|
+
{showArrow && popoverStyle.opacity === 1 && <View style={arrowStyles} />}
|
|
157
|
+
</View>
|
|
158
|
+
</Wrapper>
|
|
159
|
+
</Portal>
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const styles = StyleSheet.create({
|
|
164
|
+
overlay: {
|
|
165
|
+
position: 'absolute',
|
|
166
|
+
top: 0,
|
|
167
|
+
bottom: 0,
|
|
168
|
+
left: 0,
|
|
169
|
+
right: 0,
|
|
170
|
+
backgroundColor: 'transparent',
|
|
171
|
+
},
|
|
172
|
+
popoverContainer: {
|
|
173
|
+
...popoverDefaultStyles,
|
|
174
|
+
backgroundColor: 'white',
|
|
175
|
+
borderRadius: 4,
|
|
176
|
+
shadowColor: 'rgba(0, 0, 0, 1)',
|
|
177
|
+
shadowOffset: { width: 0, height: 2 },
|
|
178
|
+
shadowOpacity: 0.3,
|
|
179
|
+
shadowRadius: 3.84,
|
|
180
|
+
elevation: 5,
|
|
181
|
+
zIndex: 100,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
export default memo(Popover);
|