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,11 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import LinkDefault from './Link';
|
|
3
|
+
|
|
4
|
+
registerMoleculesComponents({
|
|
5
|
+
Link: LinkDefault,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const Link = getRegisteredComponentWithFallback('Link', LinkDefault);
|
|
9
|
+
|
|
10
|
+
export type { Props as LinkProps } from './Link';
|
|
11
|
+
export { linkStyles } from './utils';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
import { getCursorStyle } from '../../utils';
|
|
5
|
+
|
|
6
|
+
// type States = 'disabled' | 'hovered';
|
|
7
|
+
|
|
8
|
+
const linkStylesDefault = StyleSheet.create(theme => ({
|
|
9
|
+
root: {
|
|
10
|
+
...getCursorStyle('pointer'),
|
|
11
|
+
color: theme.colors.primary,
|
|
12
|
+
...theme.typescale.labelLarge,
|
|
13
|
+
|
|
14
|
+
_web: {
|
|
15
|
+
_hover: {
|
|
16
|
+
textDecorationLine: 'underline',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
variants: {
|
|
21
|
+
state: {
|
|
22
|
+
disabled: {
|
|
23
|
+
color: theme.colors.onSurfaceDisabled,
|
|
24
|
+
opacity: 0.38,
|
|
25
|
+
...getCursorStyle('pointer'),
|
|
26
|
+
},
|
|
27
|
+
default: {},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
registerComponentsStyles({
|
|
34
|
+
Link: linkStylesDefault,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const linkStyles = getRegisteredMoleculesComponentStyles('Link');
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { createContext, forwardRef, memo, type ReactNode, useMemo } from 'react';
|
|
2
|
+
import { type StyleProp, View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useActionState } from '../../hooks';
|
|
5
|
+
import type { WithElements } from '../../types';
|
|
6
|
+
import { resolveStateVariant } from '../../utils';
|
|
7
|
+
import { HorizontalDivider } from '../HorizontalDivider';
|
|
8
|
+
import { StateLayer } from '../StateLayer';
|
|
9
|
+
import { TouchableRipple, type TouchableRippleProps } from '../TouchableRipple';
|
|
10
|
+
import { listItemStyles } from './utils';
|
|
11
|
+
|
|
12
|
+
export type Props = Omit<TouchableRippleProps, 'children'> &
|
|
13
|
+
WithElements<ReactNode | ((renderArgs: { hovered: boolean }) => ReactNode)> & {
|
|
14
|
+
hovered?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Description text for the list item or callback which returns a React element to display the description.
|
|
17
|
+
*/
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Style that is passed to the wrapping TouchableRipple element.
|
|
21
|
+
*/
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the divider shows or not.
|
|
25
|
+
*/
|
|
26
|
+
divider?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* variant of the ListItem
|
|
29
|
+
*/
|
|
30
|
+
variant?: 'default' | 'menuItem';
|
|
31
|
+
/**
|
|
32
|
+
* Whether the ListItem is selected or not
|
|
33
|
+
*/
|
|
34
|
+
selected?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Whether the ListItem is hoverable or not
|
|
37
|
+
* @default true if onPress is passed
|
|
38
|
+
*/
|
|
39
|
+
hoverable?: boolean;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const ListItem = (
|
|
43
|
+
{
|
|
44
|
+
left,
|
|
45
|
+
right,
|
|
46
|
+
children,
|
|
47
|
+
style: styleProp,
|
|
48
|
+
disabled = false,
|
|
49
|
+
divider = false,
|
|
50
|
+
variant = 'default',
|
|
51
|
+
selected = false,
|
|
52
|
+
onPress,
|
|
53
|
+
hoverable: hoverableProp = false,
|
|
54
|
+
hovered: hoveredProp = false,
|
|
55
|
+
...props
|
|
56
|
+
}: Props,
|
|
57
|
+
ref: any,
|
|
58
|
+
) => {
|
|
59
|
+
const { hovered: _hovered, actionsRef } = useActionState({ ref, actionsToListen: ['hover'] });
|
|
60
|
+
const hoverable = hoverableProp || !!onPress;
|
|
61
|
+
const hovered = hoveredProp || _hovered;
|
|
62
|
+
|
|
63
|
+
const state = resolveStateVariant({
|
|
64
|
+
selected,
|
|
65
|
+
disabled,
|
|
66
|
+
hovered: hoverable && hovered,
|
|
67
|
+
}) as any;
|
|
68
|
+
|
|
69
|
+
listItemStyles.useVariants({
|
|
70
|
+
state,
|
|
71
|
+
variant: variant as any,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const {
|
|
75
|
+
containerStyles,
|
|
76
|
+
innerContainerStyle,
|
|
77
|
+
contentStyle,
|
|
78
|
+
leftElementStyle,
|
|
79
|
+
rightElementStyle,
|
|
80
|
+
} = useMemo(() => {
|
|
81
|
+
const { innerContainer, content, leftElement, rightElement } = listItemStyles;
|
|
82
|
+
return {
|
|
83
|
+
containerStyles: [listItemStyles.root, styleProp],
|
|
84
|
+
innerContainerStyle: innerContainer,
|
|
85
|
+
contentStyle: content,
|
|
86
|
+
leftElementStyle: leftElement,
|
|
87
|
+
rightElementStyle: rightElement,
|
|
88
|
+
};
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
}, [styleProp, state, variant]);
|
|
91
|
+
|
|
92
|
+
const contextValue = useMemo(
|
|
93
|
+
() => ({ disabled, hovered: hoverable && hovered, selected, variant }),
|
|
94
|
+
[disabled, hoverable, hovered, selected, variant],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<TouchableRipple
|
|
99
|
+
{...props}
|
|
100
|
+
style={containerStyles}
|
|
101
|
+
disabled={disabled}
|
|
102
|
+
onPress={onPress}
|
|
103
|
+
ref={actionsRef}>
|
|
104
|
+
<>
|
|
105
|
+
<View style={innerContainerStyle}>
|
|
106
|
+
{left ? (
|
|
107
|
+
<View style={leftElementStyle}>
|
|
108
|
+
{typeof left === 'function' ? left({ hovered }) : left}
|
|
109
|
+
</View>
|
|
110
|
+
) : null}
|
|
111
|
+
<View style={contentStyle}>
|
|
112
|
+
<ListItemContext.Provider value={contextValue}>
|
|
113
|
+
<>{children}</>
|
|
114
|
+
</ListItemContext.Provider>
|
|
115
|
+
</View>
|
|
116
|
+
{right ? (
|
|
117
|
+
<View style={rightElementStyle}>
|
|
118
|
+
{typeof right === 'function' ? right({ hovered }) : right}
|
|
119
|
+
</View>
|
|
120
|
+
) : null}
|
|
121
|
+
</View>
|
|
122
|
+
{divider && <HorizontalDivider />}
|
|
123
|
+
<StateLayer style={listItemStyles.stateLayer} />
|
|
124
|
+
</>
|
|
125
|
+
</TouchableRipple>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const ListItemContext = createContext({
|
|
130
|
+
disabled: false,
|
|
131
|
+
hovered: false,
|
|
132
|
+
selected: false,
|
|
133
|
+
variant: 'default',
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export default memo(forwardRef(ListItem));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { memo, useContext } from 'react';
|
|
2
|
+
import { type TextProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveStateVariant } from '../../utils';
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
import { ListItemContext } from './ListItem';
|
|
7
|
+
import { listItemDescriptionStyles } from './utils';
|
|
8
|
+
|
|
9
|
+
type Props = TextProps & {};
|
|
10
|
+
|
|
11
|
+
const ListItemDescription = ({ style, ...rest }: Props) => {
|
|
12
|
+
const { disabled, hovered, variant } = useContext(ListItemContext);
|
|
13
|
+
|
|
14
|
+
listItemDescriptionStyles.useVariants({
|
|
15
|
+
state: resolveStateVariant({
|
|
16
|
+
disabled,
|
|
17
|
+
hovered,
|
|
18
|
+
}) as any,
|
|
19
|
+
variant: variant as any,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return <Text selectable={false} {...rest} style={[listItemDescriptionStyles.root, style]} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default memo(ListItemDescription);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { memo, useContext } from 'react';
|
|
2
|
+
import { type TextProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { resolveStateVariant } from '../../utils';
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
import { ListItemContext } from './ListItem';
|
|
7
|
+
import { listItemTitleStyles } from './utils';
|
|
8
|
+
|
|
9
|
+
type Props = TextProps & {};
|
|
10
|
+
|
|
11
|
+
const ListItemTitle = ({ style, ...rest }: Props) => {
|
|
12
|
+
const { disabled, hovered, variant } = useContext(ListItemContext);
|
|
13
|
+
|
|
14
|
+
listItemTitleStyles.useVariants({
|
|
15
|
+
state: resolveStateVariant({
|
|
16
|
+
disabled,
|
|
17
|
+
hovered,
|
|
18
|
+
}) as any,
|
|
19
|
+
variant: variant as any,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return <Text selectable={false} {...rest} style={[listItemTitleStyles.root, style]} />;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default memo(ListItemTitle);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import ListItemComponent from './ListItem';
|
|
3
|
+
import ListItemDescription from './ListItemDescription';
|
|
4
|
+
import ListItemTitle from './ListItemTitle';
|
|
5
|
+
|
|
6
|
+
const ListItemDefault = Object.assign(ListItemComponent, {
|
|
7
|
+
Title: ListItemTitle,
|
|
8
|
+
Description: ListItemDescription,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
registerMoleculesComponents({
|
|
12
|
+
ListItem: ListItemDefault,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const ListItem = getRegisteredComponentWithFallback('ListItem', ListItemDefault);
|
|
16
|
+
|
|
17
|
+
export type { Props as ListItemProps } from './ListItem';
|
|
18
|
+
export { listItemDescriptionStyles, listItemStyles, listItemTitleStyles } from './utils';
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
|
|
5
|
+
const listItemStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
+
root: {
|
|
7
|
+
backgroundColor: theme.colors.surface,
|
|
8
|
+
|
|
9
|
+
variants: {
|
|
10
|
+
state: {
|
|
11
|
+
disabled: {
|
|
12
|
+
opacity: 0.38,
|
|
13
|
+
},
|
|
14
|
+
hovered: {},
|
|
15
|
+
|
|
16
|
+
selected: {
|
|
17
|
+
backgroundColor: theme.colors.surfaceVariant,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
variant: {
|
|
21
|
+
default: {
|
|
22
|
+
paddingTop: theme.spacings['2'],
|
|
23
|
+
paddingBottom: theme.spacings['2'],
|
|
24
|
+
paddingLeft: theme.spacings['4'],
|
|
25
|
+
paddingRight: theme.spacings['6'],
|
|
26
|
+
},
|
|
27
|
+
menuItem: {
|
|
28
|
+
paddingVertical: theme.spacings['2'],
|
|
29
|
+
paddingHorizontal: theme.spacings['3'],
|
|
30
|
+
minHeight: 48,
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
innerContainer: {
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
content: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
leftElement: {
|
|
48
|
+
marginRight: theme.spacings['3'],
|
|
49
|
+
marginLeft: theme.spacings._1,
|
|
50
|
+
},
|
|
51
|
+
rightElement: {
|
|
52
|
+
marginRight: theme.spacings._1,
|
|
53
|
+
marginLeft: theme.spacings['3'],
|
|
54
|
+
},
|
|
55
|
+
stateLayer: {
|
|
56
|
+
variants: {
|
|
57
|
+
state: {
|
|
58
|
+
hovered: {
|
|
59
|
+
backgroundColor: theme.colors.stateLayer.hover.primary,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
const listItemTitleStylesDefault = StyleSheet.create(theme => ({
|
|
67
|
+
root: {
|
|
68
|
+
color: theme.colors.onSurface,
|
|
69
|
+
...theme.typescale.bodyLarge,
|
|
70
|
+
|
|
71
|
+
variants: {
|
|
72
|
+
variant: {
|
|
73
|
+
menuItem: {
|
|
74
|
+
...theme.typescale.labelLarge,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
state: {
|
|
78
|
+
hovered: {},
|
|
79
|
+
disabled: {},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
const listItemDescriptionStylesDefault = StyleSheet.create(theme => ({
|
|
86
|
+
root: {
|
|
87
|
+
color: theme.colors.onSurfaceVariant,
|
|
88
|
+
...theme.typescale.bodyMedium,
|
|
89
|
+
|
|
90
|
+
variants: {
|
|
91
|
+
variant: {
|
|
92
|
+
menuItem: {
|
|
93
|
+
...theme.typescale.bodySmall,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
state: {
|
|
97
|
+
disabled: {},
|
|
98
|
+
hovered: {},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
}));
|
|
103
|
+
|
|
104
|
+
registerComponentsStyles({
|
|
105
|
+
ListItem: listItemStylesDefault,
|
|
106
|
+
ListItem_Title: listItemTitleStylesDefault,
|
|
107
|
+
ListItem_Description: listItemDescriptionStylesDefault,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export const listItemStyles = getRegisteredMoleculesComponentStyles('ListItem');
|
|
111
|
+
export const listItemTitleStyles = getRegisteredMoleculesComponentStyles('ListItem_Title');
|
|
112
|
+
export const listItemDescriptionStyles =
|
|
113
|
+
getRegisteredMoleculesComponentStyles('ListItem_Description');
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createContext, memo, type ReactElement, useMemo } from 'react';
|
|
2
|
+
import type { ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Popover, type PopoverProps } from '../Popover';
|
|
5
|
+
import { menuStyles } from './utils';
|
|
6
|
+
|
|
7
|
+
export type Props = Omit<PopoverProps, 'setIsOpen' | 'onClose' | 'children'> & {
|
|
8
|
+
style?: ViewStyle;
|
|
9
|
+
closeOnSelect?: boolean;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
children: ReactElement | ReactElement[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const emptyObj = {} as ViewStyle;
|
|
15
|
+
|
|
16
|
+
const Menu = ({
|
|
17
|
+
isOpen,
|
|
18
|
+
onClose,
|
|
19
|
+
children,
|
|
20
|
+
style: styleProp,
|
|
21
|
+
backdropStyles = emptyObj,
|
|
22
|
+
closeOnSelect = true,
|
|
23
|
+
...rest
|
|
24
|
+
}: Props) => {
|
|
25
|
+
const { backdropStyle, style } = useMemo(() => {
|
|
26
|
+
return {
|
|
27
|
+
backdropStyle: [menuStyles.backdrop, backdropStyles] as unknown as ViewStyle,
|
|
28
|
+
style: [menuStyles.root, styleProp] as unknown as ViewStyle,
|
|
29
|
+
};
|
|
30
|
+
}, [backdropStyles, styleProp]);
|
|
31
|
+
|
|
32
|
+
const contextValue = useMemo(
|
|
33
|
+
() => ({
|
|
34
|
+
closeOnSelect,
|
|
35
|
+
onClose,
|
|
36
|
+
}),
|
|
37
|
+
[closeOnSelect, onClose],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// const { menuItemsLength } = useMemo(
|
|
41
|
+
// () => ({
|
|
42
|
+
// menuItemsLength:
|
|
43
|
+
// Children.map(children, child => child)?.filter(
|
|
44
|
+
// child => (child.type as FC)?.displayName === 'MenuItem',
|
|
45
|
+
// )?.length || 0,
|
|
46
|
+
// }),
|
|
47
|
+
// [children],
|
|
48
|
+
// );
|
|
49
|
+
//
|
|
50
|
+
// console.log({ menuItemsLength });
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Popover
|
|
54
|
+
isOpen={isOpen}
|
|
55
|
+
onClose={onClose}
|
|
56
|
+
backdropStyles={backdropStyle}
|
|
57
|
+
style={style}
|
|
58
|
+
{...rest}>
|
|
59
|
+
<MenuContext.Provider value={contextValue}>{children}</MenuContext.Provider>
|
|
60
|
+
</Popover>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const MenuContext = createContext({
|
|
65
|
+
closeOnSelect: true,
|
|
66
|
+
onClose: () => {},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export default memo(Menu);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { HorizontalDivider, type HorizontalDividerProps } from '../HorizontalDivider';
|
|
4
|
+
|
|
5
|
+
export type Props = HorizontalDividerProps & {};
|
|
6
|
+
|
|
7
|
+
const MenuDivider = memo(({ spacing = 8, ...rest }: Props) => {
|
|
8
|
+
return <HorizontalDivider spacing={spacing} {...rest} />;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
MenuDivider.displayName = 'Menu_Divider';
|
|
12
|
+
|
|
13
|
+
export default MenuDivider;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { forwardRef, memo, type ReactNode, useCallback, useContext, useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
type GestureResponderEvent,
|
|
4
|
+
type StyleProp,
|
|
5
|
+
Text,
|
|
6
|
+
type TextProps,
|
|
7
|
+
View,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
import { useActionState } from '../../hooks';
|
|
12
|
+
import type { WithElements } from '../../types';
|
|
13
|
+
import { resolveStateVariant } from '../../utils';
|
|
14
|
+
import { StateLayer, type StateLayerProps } from '../StateLayer';
|
|
15
|
+
import { TouchableRipple, type TouchableRippleProps } from '../TouchableRipple';
|
|
16
|
+
import { MenuContext } from './Menu';
|
|
17
|
+
import { menuItemStyles } from './utils';
|
|
18
|
+
|
|
19
|
+
export type Props = TouchableRippleProps &
|
|
20
|
+
WithElements<ReactNode> & {
|
|
21
|
+
size?: 'default' | 'dense';
|
|
22
|
+
stateLayerProps?: StateLayerProps;
|
|
23
|
+
textProps?: Omit<TextProps, 'children'>;
|
|
24
|
+
leftElementStyle?: StyleProp<ViewStyle>;
|
|
25
|
+
rightElementStyle?: StyleProp<ViewStyle>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const emptyObj = {};
|
|
29
|
+
|
|
30
|
+
const _MenuItem = (
|
|
31
|
+
{
|
|
32
|
+
onPress,
|
|
33
|
+
left,
|
|
34
|
+
right,
|
|
35
|
+
children,
|
|
36
|
+
disabled = false,
|
|
37
|
+
size = 'default',
|
|
38
|
+
style,
|
|
39
|
+
testID,
|
|
40
|
+
stateLayerProps,
|
|
41
|
+
textProps = emptyObj,
|
|
42
|
+
leftElementStyle: _leftElementStyle,
|
|
43
|
+
rightElementStyle: _rightElementStyle,
|
|
44
|
+
...rest
|
|
45
|
+
}: Props,
|
|
46
|
+
ref: any,
|
|
47
|
+
) => {
|
|
48
|
+
const { hovered, actionsRef } = useActionState({ ref, actionsToListen: ['hover'] });
|
|
49
|
+
|
|
50
|
+
const { closeOnSelect, onClose } = useContext(MenuContext);
|
|
51
|
+
|
|
52
|
+
const state = resolveStateVariant({
|
|
53
|
+
disabled,
|
|
54
|
+
hovered,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
menuItemStyles.useVariants({
|
|
58
|
+
size: size as any,
|
|
59
|
+
state: state as any,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const onPressItem = useCallback(
|
|
63
|
+
(e: GestureResponderEvent) => {
|
|
64
|
+
if (closeOnSelect) onClose();
|
|
65
|
+
|
|
66
|
+
onPress?.(e);
|
|
67
|
+
},
|
|
68
|
+
[closeOnSelect, onClose, onPress],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const { containerStyle, leftElementStyle, rightElementStyle, textStyle, stateLayerStyle } =
|
|
72
|
+
useMemo(() => {
|
|
73
|
+
const { text, leftElement, rightElement, stateLayer } = menuItemStyles;
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
containerStyle: [menuItemStyles.root, style],
|
|
77
|
+
textStyle: [text, textProps?.style],
|
|
78
|
+
leftElementStyle: [leftElement, _leftElementStyle],
|
|
79
|
+
rightElementStyle: [rightElement, _rightElementStyle],
|
|
80
|
+
stateLayerStyle: stateLayer,
|
|
81
|
+
};
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
}, [_leftElementStyle, _rightElementStyle, style, textProps?.style, state, size]);
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<TouchableRipple
|
|
87
|
+
{...rest}
|
|
88
|
+
testID={testID}
|
|
89
|
+
style={containerStyle}
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
onPress={onPressItem}
|
|
92
|
+
ref={actionsRef}>
|
|
93
|
+
<>
|
|
94
|
+
{left ? (
|
|
95
|
+
<View style={leftElementStyle} testID={testID ? `${testID}-left` : ''}>
|
|
96
|
+
{left}
|
|
97
|
+
</View>
|
|
98
|
+
) : null}
|
|
99
|
+
|
|
100
|
+
<Text
|
|
101
|
+
style={textStyle}
|
|
102
|
+
numberOfLines={1}
|
|
103
|
+
{...textProps}
|
|
104
|
+
testID={testID ? `${testID}-text` : ''}>
|
|
105
|
+
{children}
|
|
106
|
+
</Text>
|
|
107
|
+
|
|
108
|
+
{right ? (
|
|
109
|
+
<View style={rightElementStyle} testID={testID ? `${testID}-right` : ''}>
|
|
110
|
+
{right}
|
|
111
|
+
</View>
|
|
112
|
+
) : null}
|
|
113
|
+
|
|
114
|
+
<StateLayer
|
|
115
|
+
testID={testID ? `${testID}-stateLayer` : ''}
|
|
116
|
+
{...stateLayerProps}
|
|
117
|
+
style={stateLayerStyle}
|
|
118
|
+
/>
|
|
119
|
+
</>
|
|
120
|
+
</TouchableRipple>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const MenuItem = memo(forwardRef(_MenuItem));
|
|
125
|
+
|
|
126
|
+
MenuItem.displayName = 'Menu_Item';
|
|
127
|
+
|
|
128
|
+
export default MenuItem;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import MenuComponent from './Menu';
|
|
3
|
+
import MenuDivider from './MenuDivider';
|
|
4
|
+
import MenuItem from './MenuItem';
|
|
5
|
+
|
|
6
|
+
export const MenuDefault = Object.assign(MenuComponent, {
|
|
7
|
+
Item: MenuItem,
|
|
8
|
+
Divider: MenuDivider,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
registerMoleculesComponents({
|
|
12
|
+
Menu: MenuDefault,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const Menu = getRegisteredComponentWithFallback('Menu', MenuDefault);
|
|
16
|
+
|
|
17
|
+
export type { Props as MenuProps } from './Menu';
|
|
18
|
+
export type { Props as MenuItemProps } from './MenuItem';
|
|
19
|
+
export { menuItemStyles, menuStyles } from './utils';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
|
|
5
|
+
const menuStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
+
root: {
|
|
7
|
+
paddingVertical: theme.spacings['2'],
|
|
8
|
+
backgroundColor: theme.colors.surface,
|
|
9
|
+
minWidth: 112,
|
|
10
|
+
maxWidth: 280,
|
|
11
|
+
borderRadius: theme.shapes.corner.small as unknown as number,
|
|
12
|
+
display: 'flex',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
},
|
|
15
|
+
backdrop: {
|
|
16
|
+
opacity: 0,
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
const menuItemStylesDefault = StyleSheet.create(theme => ({
|
|
21
|
+
root: {
|
|
22
|
+
paddingVertical: theme.spacings['2'],
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
|
|
26
|
+
variants: {
|
|
27
|
+
state: {
|
|
28
|
+
disabled: {
|
|
29
|
+
opacity: 0.38,
|
|
30
|
+
},
|
|
31
|
+
hovered: {},
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
default: {
|
|
35
|
+
paddingHorizontal: theme.spacings['4'],
|
|
36
|
+
height: 48,
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
dense: {
|
|
40
|
+
paddingLeft: theme.spacings['4'],
|
|
41
|
+
paddingRight: theme.spacings['2'],
|
|
42
|
+
height: 32,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
text: {
|
|
49
|
+
flex: 1,
|
|
50
|
+
color: theme.colors.onSurface,
|
|
51
|
+
|
|
52
|
+
size: {
|
|
53
|
+
default: {
|
|
54
|
+
...theme.typescale.bodyLarge,
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
dense: {
|
|
58
|
+
...theme.typescale.bodyMedium,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
leftElement: {
|
|
64
|
+
marginRight: theme.spacings['5'],
|
|
65
|
+
marginLeft: theme.spacings['2'],
|
|
66
|
+
},
|
|
67
|
+
rightElement: {
|
|
68
|
+
marginRight: theme.spacings['2'],
|
|
69
|
+
marginLeft: theme.spacings['5'],
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
stateLayer: {
|
|
73
|
+
variants: {
|
|
74
|
+
state: {
|
|
75
|
+
disabled: {
|
|
76
|
+
backgroundColor: 'transparent',
|
|
77
|
+
},
|
|
78
|
+
hovered: {
|
|
79
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
registerComponentsStyles({
|
|
87
|
+
Menu: menuStylesDefault,
|
|
88
|
+
Menu_Item: menuItemStylesDefault,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const menuStyles = getRegisteredMoleculesComponentStyles('Menu');
|
|
92
|
+
export const menuItemStyles = getRegisteredMoleculesComponentStyles('Menu_Item');
|