react-native-molecules 0.5.0-beta.3 → 0.5.0-beta.31
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 +2 -6
- package/components/Accordion/AccordionItem.tsx +16 -12
- package/components/Accordion/AccordionItemContent.tsx +6 -1
- package/components/Accordion/AccordionItemHeader.tsx +1 -1
- package/components/Accordion/utils.ts +6 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +6 -15
- package/components/Appbar/AppbarBase.tsx +18 -13
- package/components/Button/Button.tsx +211 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Card/Card.tsx +1 -1
- package/components/Checkbox/Checkbox.tsx +125 -88
- package/components/Checkbox/CheckboxBase.ios.tsx +14 -23
- package/components/Checkbox/CheckboxBase.tsx +21 -137
- package/components/Checkbox/context.tsx +14 -0
- package/components/Checkbox/index.tsx +11 -4
- package/components/Checkbox/types.ts +63 -29
- package/components/Checkbox/utils.ts +25 -108
- package/components/Chip/Chip.tsx +41 -52
- package/components/Chip/utils.ts +3 -7
- package/components/DateField/DateField.tsx +111 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +19 -51
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +246 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +158 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +83 -0
- package/components/DatePicker/index.tsx +45 -0
- package/components/DatePicker/utils.ts +295 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +117 -0
- package/components/DatePickerInline/DatePickerInline.tsx +17 -16
- package/components/DatePickerInline/DatePickerInlineBase.tsx +11 -5
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayNames.tsx +13 -10
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +44 -29
- package/components/DatePickerInline/Month.tsx +48 -67
- package/components/DatePickerInline/MonthPicker.tsx +80 -92
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +169 -14
- package/components/DatePickerInline/SwiperUtils.ts +1 -1
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +220 -78
- package/components/DatePickerInline/dateUtils.tsx +18 -13
- package/components/DatePickerInline/store.tsx +27 -0
- package/components/DatePickerInline/types.ts +6 -2
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/Divider/Divider.tsx +192 -0
- package/components/Divider/index.tsx +10 -0
- package/components/Drawer/Drawer.tsx +17 -6
- package/components/Drawer/DrawerItemGroup.tsx +3 -7
- package/components/ElementGroup/ElementGroup.tsx +1 -1
- package/components/FilePicker/FilePicker.tsx +48 -78
- package/components/FilePicker/index.tsx +2 -1
- package/components/FilePicker/utils.ts +9 -0
- package/components/HelperText/HelperText.tsx +0 -35
- package/components/Icon/iconFactory.tsx +5 -4
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +84 -84
- package/components/IconButton/index.tsx +1 -0
- package/components/IconButton/types.ts +10 -0
- package/components/IconButton/utils.ts +167 -33
- package/components/List/List.tsx +276 -0
- package/components/List/context.tsx +27 -0
- package/components/List/index.ts +8 -0
- package/components/List/types.ts +117 -0
- package/components/List/utils.ts +79 -0
- package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
- package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
- package/components/LoadingIndicator/index.tsx +13 -0
- package/components/LoadingIndicator/utils.ts +117 -0
- package/components/Menu/Menu.tsx +162 -39
- package/components/Menu/index.tsx +10 -7
- package/components/Menu/utils.ts +21 -70
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +119 -145
- package/components/Popover/PopoverRoot.tsx +60 -0
- package/components/Popover/common.ts +54 -34
- package/components/Popover/index.ts +12 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +120 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Portal/Portal.tsx +1 -2
- package/components/Radio/Radio.tsx +188 -0
- package/components/Radio/RadioBase.ios.tsx +69 -0
- package/components/Radio/RadioBase.tsx +136 -0
- package/components/Radio/context.tsx +23 -0
- package/components/Radio/index.tsx +20 -0
- package/components/Radio/types.ts +101 -0
- package/components/Radio/utils.ts +115 -0
- package/components/Rating/Rating.tsx +1 -1
- package/components/Select/Select.tsx +521 -785
- package/components/Select/context.tsx +81 -0
- package/components/Select/index.ts +26 -14
- package/components/Select/types.ts +65 -58
- package/components/Select/utils.ts +126 -0
- package/components/Slot/Slot.tsx +224 -0
- package/components/Slot/compose-refs.tsx +62 -0
- package/components/Slot/index.tsx +8 -0
- package/components/Surface/Surface.android.tsx +32 -7
- package/components/Surface/Surface.ios.tsx +34 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -6
- package/components/Switch/Switch.ios.tsx +1 -1
- package/components/Switch/Switch.tsx +10 -3
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +156 -150
- package/components/Tabs/utils.ts +15 -2
- package/components/Text/textFactory.tsx +17 -5
- package/components/TextInput/TextInput.tsx +663 -579
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +77 -28
- package/components/TextInput/utils.ts +235 -145
- package/components/TimeField/TimeField.tsx +75 -0
- package/components/TimeField/index.tsx +6 -0
- package/components/TimeField/useTimeFieldState.ts +70 -0
- package/components/{TimePickerField/sanitizeTime.ts → TimeField/utils.ts} +77 -10
- package/components/TimePicker/AnalogClock.tsx +1 -1
- package/components/TimePicker/TimeInput.tsx +87 -42
- package/components/TimePicker/TimeInputs.tsx +138 -50
- package/components/TimePicker/TimePicker.tsx +74 -11
- package/components/TimePicker/TimePickerModal.tsx +186 -0
- package/components/TimePicker/context.tsx +17 -0
- package/components/TimePicker/index.tsx +15 -3
- package/components/TimePicker/utils.ts +93 -4
- package/components/Tooltip/Tooltip.tsx +42 -67
- package/components/Tooltip/TooltipContent.tsx +32 -5
- package/components/Tooltip/TooltipTrigger.tsx +21 -24
- package/components/Tooltip/index.tsx +1 -1
- package/components/TouchableRipple/TouchableRipple.native.tsx +83 -16
- package/components/TouchableRipple/TouchableRipple.tsx +150 -102
- package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
- package/hocs/index.tsx +1 -1
- package/hocs/withKeyboardAccessibility.tsx +2 -3
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +2 -12
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useContrastColor.ts +1 -2
- package/hooks/useFilePicker.tsx +7 -17
- package/hooks/useHandleNumberFormat.tsx +2 -2
- package/hooks/useMediaQuery.tsx +1 -2
- package/package.json +95 -111
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +6 -3
- package/shortcuts-manager/ShortcutsManager/utils.tsx +1 -1
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +1 -1
- package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
- package/styles/shadow.ts +2 -1
- package/styles/themes/LightTheme.tsx +1 -1
- package/utils/DocumentPicker/documentPicker.ts +78 -27
- package/utils/DocumentPicker/types.ts +0 -1
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/extractTextStyles.ts +1 -2
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +2 -1
- package/utils/index.ts +0 -3
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +1 -1
- package/components/DatePickerDocked/DatePickerDocked.tsx +0 -30
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +0 -129
- package/components/DatePickerDocked/index.tsx +0 -17
- package/components/DatePickerDocked/types.ts +0 -11
- package/components/DatePickerDocked/utils.ts +0 -157
- package/components/DatePickerInline/DatePickerContext.tsx +0 -21
- package/components/DatePickerInput/DatePickerInput.tsx +0 -139
- package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -77
- package/components/DatePickerInput/DateRangeInput.tsx +0 -88
- package/components/DatePickerInput/index.tsx +0 -10
- package/components/DatePickerInput/types.ts +0 -28
- package/components/DatePickerInput/utils.ts +0 -15
- package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
- package/components/DatePickerModal/CalendarEdit.tsx +0 -139
- package/components/DatePickerModal/DatePickerModal.tsx +0 -85
- package/components/DatePickerModal/DatePickerModalContent.tsx +0 -155
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +0 -213
- package/components/DatePickerModal/DatePickerModalHeader.tsx +0 -74
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +0 -13
- package/components/DatePickerModal/index.tsx +0 -16
- package/components/DatePickerModal/types.ts +0 -92
- package/components/DatePickerModal/utils.ts +0 -122
- package/components/DateTimePicker/DateTimePicker.tsx +0 -172
- package/components/DateTimePicker/index.tsx +0 -10
- package/components/DateTimePicker/utils.ts +0 -12
- package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
- package/components/HorizontalDivider/index.tsx +0 -9
- package/components/ListItem/ListItem.tsx +0 -136
- package/components/ListItem/ListItemDescription.tsx +0 -25
- package/components/ListItem/ListItemTitle.tsx +0 -25
- package/components/ListItem/index.tsx +0 -14
- package/components/ListItem/utils.ts +0 -115
- package/components/Menu/MenuDivider.tsx +0 -13
- package/components/Menu/MenuItem.tsx +0 -128
- package/components/Popover/Popover.native.tsx +0 -185
- package/components/RadioButton/RadioButton.tsx +0 -138
- package/components/RadioButton/RadioButtonAndroid.tsx +0 -188
- package/components/RadioButton/RadioButtonGroup.tsx +0 -98
- package/components/RadioButton/RadioButtonIOS.tsx +0 -106
- package/components/RadioButton/RadioButtonItem.tsx +0 -232
- package/components/RadioButton/index.ts +0 -22
- package/components/RadioButton/utils.ts +0 -165
- package/components/TimePickerField/TimePickerField.tsx +0 -152
- package/components/TimePickerField/index.tsx +0 -10
- package/components/TimePickerField/utils.ts +0 -94
- package/components/TimePickerModal/TimePickerModal.tsx +0 -115
- package/components/TimePickerModal/index.tsx +0 -10
- package/components/TimePickerModal/utils.ts +0 -47
- package/components/VerticalDivider/VerticalDivider.tsx +0 -100
- package/components/VerticalDivider/index.tsx +0 -9
- package/context-bridge/index.tsx +0 -87
- package/fast-context/index.tsx +0 -190
- package/hocs/typedMemo.tsx +0 -5
- package/hooks/useControlledValue.tsx +0 -68
- package/hooks/useLatest.tsx +0 -9
- package/hooks/useMergedRefs.ts +0 -14
- package/hooks/usePrevious.ts +0 -13
- package/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
- package/hooks/useToggle.tsx +0 -24
- package/utils/color.ts +0 -22
- package/utils/compare/index.ts +0 -54
- package/utils/lodash.ts +0 -49
- package/utils/repository.ts +0 -53
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
import DateTimePickerDefault from './DateTimePicker';
|
|
3
|
-
|
|
4
|
-
export const DateTimePicker = getRegisteredComponentWithFallback(
|
|
5
|
-
'DateTimePicker',
|
|
6
|
-
DateTimePickerDefault,
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export type { Props as DateTimePickerProps } from './DateTimePicker';
|
|
10
|
-
export { dateTimePickerStyles } from './utils';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
|
|
3
|
-
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
|
-
|
|
5
|
-
const dateTimePickerStylesDefault = StyleSheet.create({
|
|
6
|
-
container: {},
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export const dateTimePickerStyles = getRegisteredComponentStylesWithFallback(
|
|
10
|
-
'DateTimePicker',
|
|
11
|
-
dateTimePickerStylesDefault,
|
|
12
|
-
);
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
2
|
-
import { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
|
|
5
|
-
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
6
|
-
|
|
7
|
-
export type Props = Omit<ViewProps, 'children'> & {
|
|
8
|
-
/**
|
|
9
|
-
* left inset of the divider.
|
|
10
|
-
*/
|
|
11
|
-
leftInset?: number;
|
|
12
|
-
/**
|
|
13
|
-
* right inset of the divider.
|
|
14
|
-
*/
|
|
15
|
-
rightInset?: number;
|
|
16
|
-
/**
|
|
17
|
-
* Whether divider should be bolded.
|
|
18
|
-
*/
|
|
19
|
-
bold?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Vertical spacing of the Divider
|
|
22
|
-
*/
|
|
23
|
-
spacing?: number;
|
|
24
|
-
style?: StyleProp<ViewStyle>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A divider is a thin, lightweight separator that groups content in lists and page layouts.
|
|
29
|
-
*
|
|
30
|
-
* <div class="screenshots">
|
|
31
|
-
* <figure>
|
|
32
|
-
* <img class="medium" src="screenshots/divider.png" />
|
|
33
|
-
* </figure>
|
|
34
|
-
* </div>
|
|
35
|
-
*
|
|
36
|
-
* ## Usage
|
|
37
|
-
* ```js
|
|
38
|
-
* import * as React from 'react';
|
|
39
|
-
* import { View } from 'react-native';
|
|
40
|
-
* import { Divider, Text } from 'react-native-paper';
|
|
41
|
-
*
|
|
42
|
-
* const MyComponent = () => (
|
|
43
|
-
* <View>
|
|
44
|
-
* <Text>Lemon</Text>
|
|
45
|
-
* <Divider />
|
|
46
|
-
* <Text>Mango</Text>
|
|
47
|
-
* <Divider />
|
|
48
|
-
* </View>
|
|
49
|
-
* );
|
|
50
|
-
*
|
|
51
|
-
* export default MyComponent;
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
const HorizontalDivider = ({
|
|
56
|
-
leftInset = 0,
|
|
57
|
-
rightInset = 0,
|
|
58
|
-
style,
|
|
59
|
-
bold = false,
|
|
60
|
-
spacing = 0,
|
|
61
|
-
...rest
|
|
62
|
-
}: Props) => {
|
|
63
|
-
horizontalDividerStyles.useVariants({
|
|
64
|
-
isBold: bold,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<View
|
|
69
|
-
{...rest}
|
|
70
|
-
style={
|
|
71
|
-
[
|
|
72
|
-
horizontalDividerStyles.root,
|
|
73
|
-
leftInset && { marginLeft: leftInset },
|
|
74
|
-
rightInset && { marginRight: rightInset },
|
|
75
|
-
spacing && { marginVertical: spacing },
|
|
76
|
-
style,
|
|
77
|
-
] as StyleProp<ViewStyle>
|
|
78
|
-
}
|
|
79
|
-
/>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const horizontalDividerStylesDefault = StyleSheet.create(theme => ({
|
|
84
|
-
root: {
|
|
85
|
-
height: StyleSheet.hairlineWidth,
|
|
86
|
-
background: theme.colors.outlineVariant,
|
|
87
|
-
|
|
88
|
-
variants: {
|
|
89
|
-
isBold: {
|
|
90
|
-
true: {
|
|
91
|
-
height: 1,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
export const horizontalDividerStyles = getRegisteredComponentStylesWithFallback(
|
|
99
|
-
'HorizontalDivider',
|
|
100
|
-
horizontalDividerStylesDefault,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
export default memo(HorizontalDivider);
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
import HorizontalDividerDefault from './HorizontalDivider';
|
|
3
|
-
|
|
4
|
-
export const HorizontalDivider = getRegisteredComponentWithFallback(
|
|
5
|
-
'HorizontalDivider',
|
|
6
|
-
HorizontalDividerDefault,
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export { type Props as HorizontalDividerProps, horizontalDividerStyles } from './HorizontalDivider';
|
|
@@ -1,136 +0,0 @@
|
|
|
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));
|
|
@@ -1,25 +0,0 @@
|
|
|
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);
|
|
@@ -1,25 +0,0 @@
|
|
|
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);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getRegisteredComponentWithFallback } 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
|
-
export const ListItem = getRegisteredComponentWithFallback('ListItem', ListItemDefault);
|
|
12
|
-
|
|
13
|
-
export type { Props as ListItemProps } from './ListItem';
|
|
14
|
-
export { listItemDescriptionStyles, listItemStyles, listItemTitleStyles } from './utils';
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
|
|
3
|
-
import { getRegisteredComponentStylesWithFallback } 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
|
-
export const listItemStyles = getRegisteredComponentStylesWithFallback(
|
|
105
|
-
'ListItem',
|
|
106
|
-
listItemStylesDefault,
|
|
107
|
-
);
|
|
108
|
-
export const listItemTitleStyles = getRegisteredComponentStylesWithFallback(
|
|
109
|
-
'ListItem_Title',
|
|
110
|
-
listItemTitleStylesDefault,
|
|
111
|
-
);
|
|
112
|
-
export const listItemDescriptionStyles = getRegisteredComponentStylesWithFallback(
|
|
113
|
-
'ListItem_Description',
|
|
114
|
-
listItemDescriptionStylesDefault,
|
|
115
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
|
@@ -1,128 +0,0 @@
|
|
|
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;
|