react-native-molecules 0.5.0-beta.20 → 0.5.0-beta.22
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/Card/Card.tsx +1 -1
- package/components/Checkbox/CheckboxBase.ios.tsx +9 -16
- package/components/Checkbox/CheckboxBase.tsx +11 -18
- package/components/DateField/DateField.tsx +4 -3
- package/components/DatePicker/DateCalendar.tsx +4 -4
- package/components/DatePicker/DatePickerModal.tsx +35 -23
- package/components/DatePicker/DatePickerProvider.tsx +8 -2
- package/components/DatePicker/context.tsx +2 -1
- package/components/DatePicker/index.tsx +1 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +11 -7
- package/components/DatePickerInline/DatePickerInline.tsx +1 -1
- package/components/DatePickerInline/DatePickerInlineBase.tsx +3 -3
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
- package/components/DatePickerInline/DayNames.tsx +13 -10
- package/components/DatePickerInline/HeaderItem.tsx +2 -2
- package/components/DatePickerInline/Month.tsx +4 -3
- package/components/DatePickerInline/MonthPicker.tsx +74 -54
- package/components/DatePickerInline/Swiper.native.tsx +2 -2
- package/components/DatePickerInline/Swiper.tsx +3 -3
- package/components/DatePickerInline/YearPicker.tsx +136 -112
- package/components/DatePickerInline/{DatePickerContext.tsx → store.tsx} +7 -3
- package/components/DatePickerInline/types.ts +4 -3
- package/components/Divider/Divider.tsx +192 -0
- package/components/Divider/index.tsx +11 -0
- package/components/Drawer/DrawerItemGroup.tsx +3 -7
- package/components/IconButton/IconButton.tsx +2 -12
- package/components/List/List.tsx +507 -0
- package/components/List/context.tsx +28 -0
- package/components/List/index.ts +9 -0
- package/components/List/types.ts +149 -0
- package/components/{ListItem → List}/utils.ts +47 -50
- package/components/Menu/Menu.tsx +156 -12
- package/components/Menu/index.tsx +11 -7
- package/components/Menu/utils.ts +21 -70
- package/components/RadioButton/RadioButtonAndroid.tsx +38 -54
- package/components/RadioButton/RadioButtonIOS.tsx +2 -16
- package/components/Select/Select.tsx +139 -497
- package/components/Select/context.tsx +14 -32
- package/components/Select/types.ts +44 -53
- package/components/Select/utils.ts +15 -47
- package/components/Text/textFactory.tsx +17 -5
- package/components/TimeField/TimeField.tsx +1 -1
- package/components/TimePicker/TimeInput.tsx +2 -7
- package/components/TimePicker/TimePickerModal.tsx +15 -15
- package/components/TimePicker/utils.ts +0 -4
- package/components/TouchableRipple/TouchableRipple.native.tsx +36 -5
- package/components/TouchableRipple/TouchableRipple.tsx +53 -19
- package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
- package/package.json +4 -2
- package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
- package/components/HorizontalDivider/index.tsx +0 -9
- package/components/ListItem/ListItem.tsx +0 -138
- package/components/ListItem/ListItemDescription.tsx +0 -25
- package/components/ListItem/ListItemTitle.tsx +0 -25
- package/components/ListItem/index.tsx +0 -14
- package/components/Menu/MenuDivider.tsx +0 -13
- package/components/Menu/MenuItem.tsx +0 -128
- package/components/VerticalDivider/VerticalDivider.tsx +0 -100
- package/components/VerticalDivider/index.tsx +0 -9
|
@@ -2,30 +2,65 @@ import { StyleSheet } from 'react-native-unistyles';
|
|
|
2
2
|
|
|
3
3
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
4
|
|
|
5
|
+
const defaultStyles = StyleSheet.create(theme => ({
|
|
6
|
+
groupLabel: {
|
|
7
|
+
paddingHorizontal: theme.spacings['4'],
|
|
8
|
+
paddingVertical: theme.spacings['2'],
|
|
9
|
+
fontWeight: '600',
|
|
10
|
+
color: theme.colors.onSurface,
|
|
11
|
+
},
|
|
12
|
+
searchInput: {
|
|
13
|
+
marginHorizontal: theme.spacings['2'],
|
|
14
|
+
marginVertical: theme.spacings['3'],
|
|
15
|
+
},
|
|
16
|
+
searchInputInput: {
|
|
17
|
+
height: 42,
|
|
18
|
+
},
|
|
19
|
+
emptyState: {
|
|
20
|
+
paddingHorizontal: theme.spacings['4'],
|
|
21
|
+
paddingVertical: theme.spacings['6'],
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
},
|
|
25
|
+
emptyStateText: {
|
|
26
|
+
color: theme.colors.onSurfaceVariant,
|
|
27
|
+
fontSize: 14,
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
export const listStyles = getRegisteredComponentStylesWithFallback('List', defaultStyles);
|
|
32
|
+
|
|
5
33
|
const listItemStylesDefault = StyleSheet.create(theme => ({
|
|
6
34
|
root: {
|
|
7
35
|
backgroundColor: theme.colors.surface,
|
|
8
36
|
|
|
37
|
+
_web: {
|
|
38
|
+
outlineStyle: 'none',
|
|
39
|
+
},
|
|
40
|
+
|
|
9
41
|
variants: {
|
|
10
42
|
state: {
|
|
11
43
|
disabled: {
|
|
12
44
|
opacity: 0.38,
|
|
13
45
|
},
|
|
14
46
|
hovered: {},
|
|
47
|
+
focused: {},
|
|
15
48
|
|
|
16
49
|
selected: {
|
|
17
50
|
backgroundColor: theme.colors.surfaceVariant,
|
|
18
51
|
},
|
|
52
|
+
selectedAndFocused: {
|
|
53
|
+
backgroundColor: theme.colors.surfaceVariant,
|
|
54
|
+
},
|
|
19
55
|
},
|
|
20
56
|
variant: {
|
|
21
57
|
default: {
|
|
22
|
-
paddingTop: theme.spacings['2'],
|
|
23
|
-
paddingBottom: theme.spacings['2'],
|
|
24
58
|
paddingLeft: theme.spacings['4'],
|
|
25
59
|
paddingRight: theme.spacings['6'],
|
|
60
|
+
minHeight: 56,
|
|
61
|
+
justifyContent: 'center',
|
|
26
62
|
},
|
|
27
63
|
menuItem: {
|
|
28
|
-
paddingVertical: theme.spacings['2'],
|
|
29
64
|
paddingHorizontal: theme.spacings['3'],
|
|
30
65
|
minHeight: 48,
|
|
31
66
|
justifyContent: 'center',
|
|
@@ -37,20 +72,22 @@ const listItemStylesDefault = StyleSheet.create(theme => ({
|
|
|
37
72
|
innerContainer: {
|
|
38
73
|
flexDirection: 'row',
|
|
39
74
|
alignItems: 'center',
|
|
75
|
+
minHeight: 40,
|
|
40
76
|
},
|
|
41
77
|
|
|
42
78
|
content: {
|
|
43
79
|
flex: 1,
|
|
44
80
|
justifyContent: 'center',
|
|
81
|
+
minHeight: 40,
|
|
45
82
|
},
|
|
46
83
|
|
|
47
84
|
leftElement: {
|
|
48
|
-
marginRight: theme.spacings['
|
|
85
|
+
marginRight: theme.spacings['4'],
|
|
49
86
|
marginLeft: theme.spacings._1,
|
|
50
87
|
},
|
|
51
88
|
rightElement: {
|
|
52
89
|
marginRight: theme.spacings._1,
|
|
53
|
-
marginLeft: theme.spacings['
|
|
90
|
+
marginLeft: theme.spacings['4'],
|
|
54
91
|
},
|
|
55
92
|
stateLayer: {
|
|
56
93
|
variants: {
|
|
@@ -58,58 +95,18 @@ const listItemStylesDefault = StyleSheet.create(theme => ({
|
|
|
58
95
|
hovered: {
|
|
59
96
|
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
60
97
|
},
|
|
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,
|
|
98
|
+
focused: {
|
|
99
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
75
100
|
},
|
|
76
|
-
|
|
77
|
-
|
|
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,
|
|
101
|
+
selectedAndFocused: {
|
|
102
|
+
backgroundColor: theme.colors.stateLayer.focussed.onSurface,
|
|
94
103
|
},
|
|
95
104
|
},
|
|
96
|
-
state: {
|
|
97
|
-
disabled: {},
|
|
98
|
-
hovered: {},
|
|
99
|
-
},
|
|
100
105
|
},
|
|
101
106
|
},
|
|
102
107
|
}));
|
|
103
108
|
|
|
104
109
|
export const listItemStyles = getRegisteredComponentStylesWithFallback(
|
|
105
|
-
'
|
|
110
|
+
'List_Item',
|
|
106
111
|
listItemStylesDefault,
|
|
107
112
|
);
|
|
108
|
-
export const listItemTitleStyles = getRegisteredComponentStylesWithFallback(
|
|
109
|
-
'ListItem_Title',
|
|
110
|
-
listItemTitleStylesDefault,
|
|
111
|
-
);
|
|
112
|
-
export const listItemDescriptionStyles = getRegisteredComponentStylesWithFallback(
|
|
113
|
-
'ListItem_Description',
|
|
114
|
-
listItemDescriptionStylesDefault,
|
|
115
|
-
);
|
package/components/Menu/Menu.tsx
CHANGED
|
@@ -1,28 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
memo,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
useCallback,
|
|
8
|
+
useContext,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import type { GestureResponderEvent, ViewStyle } from 'react-native';
|
|
3
14
|
|
|
15
|
+
import {
|
|
16
|
+
type DefaultListItemT,
|
|
17
|
+
List,
|
|
18
|
+
type ListItemProps,
|
|
19
|
+
type ListProps,
|
|
20
|
+
type ListValue,
|
|
21
|
+
} from '../List';
|
|
4
22
|
import { Popover, type PopoverProps } from '../Popover';
|
|
5
|
-
import { menuStyles } from './utils';
|
|
23
|
+
import { MenuContext, MenuRootContext, menuStyles } from './utils';
|
|
6
24
|
|
|
7
|
-
|
|
25
|
+
type MenuBaseProps = Omit<
|
|
26
|
+
PopoverProps,
|
|
27
|
+
'setIsOpen' | 'onClose' | 'isOpen' | 'triggerRef' | 'children'
|
|
28
|
+
> & {
|
|
8
29
|
style?: ViewStyle;
|
|
9
30
|
closeOnSelect?: boolean;
|
|
10
|
-
onClose: () => void;
|
|
11
31
|
children: ReactElement | ReactElement[];
|
|
12
32
|
backdropStyles?: ViewStyle;
|
|
33
|
+
items?: DefaultListItemT[];
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
searchKey?: string;
|
|
36
|
+
onSearchChange?: (query: string) => void;
|
|
37
|
+
hideSelected?: boolean;
|
|
13
38
|
};
|
|
14
39
|
|
|
40
|
+
type SingleMenuProps = {
|
|
41
|
+
multiple?: false | undefined;
|
|
42
|
+
value?: ListValue<DefaultListItemT, false>;
|
|
43
|
+
defaultValue?: ListValue<DefaultListItemT, false>;
|
|
44
|
+
onChange?: (
|
|
45
|
+
value: ListValue<DefaultListItemT, false>,
|
|
46
|
+
item: DefaultListItemT,
|
|
47
|
+
event?: GestureResponderEvent,
|
|
48
|
+
) => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type MultipleMenuProps = {
|
|
52
|
+
multiple: true;
|
|
53
|
+
value?: ListValue<DefaultListItemT, true>;
|
|
54
|
+
defaultValue?: ListValue<DefaultListItemT, true>;
|
|
55
|
+
onChange?: (
|
|
56
|
+
value: ListValue<DefaultListItemT, true>,
|
|
57
|
+
item: DefaultListItemT,
|
|
58
|
+
event?: GestureResponderEvent,
|
|
59
|
+
) => void;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type Props = MenuBaseProps & (SingleMenuProps | MultipleMenuProps);
|
|
63
|
+
|
|
15
64
|
const emptyObj = {} as ViewStyle;
|
|
16
65
|
|
|
66
|
+
const emptyArr = [] as DefaultListItemT[];
|
|
67
|
+
|
|
17
68
|
const Menu = ({
|
|
18
|
-
isOpen,
|
|
19
|
-
onClose,
|
|
20
69
|
children,
|
|
21
70
|
style: styleProp,
|
|
22
71
|
backdropStyles = emptyObj,
|
|
23
72
|
closeOnSelect = true,
|
|
73
|
+
items,
|
|
74
|
+
value,
|
|
75
|
+
defaultValue,
|
|
76
|
+
onChange,
|
|
77
|
+
multiple,
|
|
78
|
+
disabled,
|
|
79
|
+
searchKey,
|
|
80
|
+
onSearchChange,
|
|
81
|
+
hideSelected,
|
|
24
82
|
...rest
|
|
25
83
|
}: Props) => {
|
|
84
|
+
const { isOpen, onClose, triggerRef } = useContext(MenuRootContext);
|
|
85
|
+
|
|
26
86
|
const { backdropStyle, style } = useMemo(() => {
|
|
27
87
|
return {
|
|
28
88
|
backdropStyle: [menuStyles.backdrop, backdropStyles] as unknown as ViewStyle,
|
|
@@ -38,17 +98,101 @@ const Menu = ({
|
|
|
38
98
|
[closeOnSelect, onClose],
|
|
39
99
|
);
|
|
40
100
|
|
|
101
|
+
const listProps = {
|
|
102
|
+
items: items ?? emptyArr,
|
|
103
|
+
multiple,
|
|
104
|
+
value,
|
|
105
|
+
defaultValue,
|
|
106
|
+
onChange,
|
|
107
|
+
disabled,
|
|
108
|
+
searchKey,
|
|
109
|
+
onSearchChange,
|
|
110
|
+
hideSelected,
|
|
111
|
+
} as ListProps<DefaultListItemT>;
|
|
112
|
+
|
|
41
113
|
return (
|
|
42
|
-
<Popover isOpen={isOpen} onClose={onClose} style={style} {...rest}>
|
|
114
|
+
<Popover isOpen={isOpen} onClose={onClose} style={style} triggerRef={triggerRef} {...rest}>
|
|
43
115
|
<Popover.Overlay style={backdropStyle} />
|
|
44
|
-
<
|
|
116
|
+
<List {...listProps}>
|
|
117
|
+
<MenuContext.Provider value={contextValue}>{children}</MenuContext.Provider>
|
|
118
|
+
</List>
|
|
45
119
|
</Popover>
|
|
46
120
|
);
|
|
47
121
|
};
|
|
48
122
|
|
|
49
|
-
export
|
|
50
|
-
|
|
51
|
-
|
|
123
|
+
export type MenuRootProps = {
|
|
124
|
+
children: ReactNode;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const MenuRoot = memo(({ children }: MenuRootProps) => {
|
|
128
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
129
|
+
const triggerRef = useRef(null);
|
|
130
|
+
|
|
131
|
+
const onOpen = useCallback(() => setIsOpen(true), []);
|
|
132
|
+
const onClose = useCallback(() => setIsOpen(false), []);
|
|
133
|
+
|
|
134
|
+
const contextValue = useMemo(
|
|
135
|
+
() => ({ isOpen, onOpen, onClose, triggerRef }),
|
|
136
|
+
[isOpen, onOpen, onClose],
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
return <MenuRootContext.Provider value={contextValue}>{children}</MenuRootContext.Provider>;
|
|
52
140
|
});
|
|
53
141
|
|
|
142
|
+
MenuRoot.displayName = 'Menu_Root';
|
|
143
|
+
|
|
144
|
+
export type MenuTriggerProps = {
|
|
145
|
+
children: ReactElement;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const MenuTrigger = memo(({ children }: MenuTriggerProps) => {
|
|
149
|
+
const { onOpen, triggerRef } = useContext(MenuRootContext);
|
|
150
|
+
|
|
151
|
+
const onPress = useCallback(
|
|
152
|
+
(e: unknown) => {
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
children?.props?.onPress?.(e);
|
|
155
|
+
onOpen();
|
|
156
|
+
},
|
|
157
|
+
[children?.props, onOpen],
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return useMemo(
|
|
161
|
+
() =>
|
|
162
|
+
cloneElement(Children.only(children), {
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
ref: triggerRef,
|
|
165
|
+
onPress,
|
|
166
|
+
}),
|
|
167
|
+
[children, triggerRef, onPress],
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
MenuTrigger.displayName = 'Menu_Trigger';
|
|
172
|
+
|
|
173
|
+
export type MenuItemProps = Omit<ListItemProps, 'children' | 'onPress'> & {
|
|
174
|
+
children: ReactNode;
|
|
175
|
+
onPress?: (event: GestureResponderEvent) => void;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const MenuItem = memo(({ onPress, children, ...rest }: MenuItemProps) => {
|
|
179
|
+
const { closeOnSelect, onClose } = useContext(MenuContext);
|
|
180
|
+
|
|
181
|
+
const handlePress = useCallback(
|
|
182
|
+
(event: GestureResponderEvent) => {
|
|
183
|
+
onPress?.(event);
|
|
184
|
+
if (closeOnSelect) onClose();
|
|
185
|
+
},
|
|
186
|
+
[closeOnSelect, onClose, onPress],
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<List.Row {...rest} variant="menuItem" onPress={handlePress}>
|
|
191
|
+
{children}
|
|
192
|
+
</List.Row>
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
MenuItem.displayName = 'Menu_Item';
|
|
197
|
+
|
|
54
198
|
export default memo(Menu);
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { List } from '../List';
|
|
3
|
+
import MenuComponent, { MenuItem, MenuRoot, MenuTrigger } from './Menu';
|
|
4
|
+
import { MenuRootContext } from './utils';
|
|
5
5
|
|
|
6
6
|
export const MenuDefault = Object.assign(MenuComponent, {
|
|
7
|
+
Root: MenuRoot,
|
|
8
|
+
Trigger: MenuTrigger,
|
|
7
9
|
Item: MenuItem,
|
|
8
|
-
|
|
10
|
+
Content: List.Content,
|
|
11
|
+
Group: List.Group,
|
|
12
|
+
SearchInput: List.SearchInput,
|
|
13
|
+
RootContext: MenuRootContext,
|
|
9
14
|
});
|
|
10
15
|
|
|
11
16
|
export const Menu = getRegisteredComponentWithFallback('Menu', MenuDefault);
|
|
12
17
|
|
|
13
|
-
export type { Props as MenuProps } from './Menu';
|
|
14
|
-
export
|
|
15
|
-
export { menuItemStyles, menuStyles } from './utils';
|
|
18
|
+
export type { MenuItemProps, Props as MenuProps, MenuRootProps, MenuTriggerProps } from './Menu';
|
|
19
|
+
export { MenuRootContext, menuStyles } from './utils';
|
package/components/Menu/utils.ts
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
|
+
import { createContext, type RefObject } from 'react';
|
|
2
|
+
import type { View } from 'react-native';
|
|
1
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
4
|
|
|
3
5
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
6
|
|
|
7
|
+
export const MenuContext = createContext({
|
|
8
|
+
closeOnSelect: true,
|
|
9
|
+
onClose: () => {},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type MenuRootContextValue = {
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
onOpen: () => void;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
triggerRef: RefObject<View | any>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const MenuRootContext = createContext<MenuRootContextValue>({
|
|
20
|
+
isOpen: false,
|
|
21
|
+
onOpen: () => {},
|
|
22
|
+
onClose: () => {},
|
|
23
|
+
triggerRef: { current: null },
|
|
24
|
+
});
|
|
25
|
+
|
|
5
26
|
const menuStylesDefault = StyleSheet.create(theme => ({
|
|
6
27
|
root: {
|
|
7
28
|
paddingVertical: theme.spacings['2'],
|
|
@@ -17,74 +38,4 @@ const menuStylesDefault = StyleSheet.create(theme => ({
|
|
|
17
38
|
},
|
|
18
39
|
}));
|
|
19
40
|
|
|
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
41
|
export const menuStyles = getRegisteredComponentStylesWithFallback('Menu', menuStylesDefault);
|
|
87
|
-
export const menuItemStyles = getRegisteredComponentStylesWithFallback(
|
|
88
|
-
'Menu_Item',
|
|
89
|
-
menuItemStylesDefault,
|
|
90
|
-
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import setColor from 'color';
|
|
2
1
|
import { forwardRef, memo, type PropsWithoutRef, useEffect, useMemo, useRef } from 'react';
|
|
3
2
|
import type { ViewProps } from 'react-native';
|
|
4
3
|
import { Animated, StyleSheet, View } from 'react-native';
|
|
@@ -77,58 +76,44 @@ const RadioButtonAndroid = (
|
|
|
77
76
|
state: state as any,
|
|
78
77
|
});
|
|
79
78
|
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
],
|
|
119
|
-
stateLayerStyle: [radioButtonStyles.stateLayer, stateLayerProps?.style],
|
|
120
|
-
};
|
|
121
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
122
|
-
}, [
|
|
123
|
-
borderAnim,
|
|
124
|
-
checked,
|
|
125
|
-
colorProp,
|
|
126
|
-
radioAnim,
|
|
127
|
-
stateLayerProps?.style,
|
|
128
|
-
uncheckedColorProp,
|
|
129
|
-
style,
|
|
130
|
-
state,
|
|
131
|
-
]);
|
|
79
|
+
const { containerStyles, radioStyles, dotStyles, dotContainerStyles, stateLayerStyle } =
|
|
80
|
+
useMemo(() => {
|
|
81
|
+
return {
|
|
82
|
+
containerStyles: [radioButtonStyles.container, radioButtonStyles.root, style],
|
|
83
|
+
radioStyles: [
|
|
84
|
+
radioButtonStyles.radio,
|
|
85
|
+
{
|
|
86
|
+
borderWidth: borderAnim,
|
|
87
|
+
},
|
|
88
|
+
tokenStylesParser.getColor(
|
|
89
|
+
checked ? colorProp : uncheckedColorProp,
|
|
90
|
+
'borderColor',
|
|
91
|
+
),
|
|
92
|
+
],
|
|
93
|
+
dotContainerStyles: [StyleSheet.absoluteFill, radioButtonStyles.radioContainer],
|
|
94
|
+
dotStyles: [
|
|
95
|
+
radioButtonStyles.dot,
|
|
96
|
+
{
|
|
97
|
+
transform: [{ scale: radioAnim }],
|
|
98
|
+
},
|
|
99
|
+
tokenStylesParser.getColor(
|
|
100
|
+
checked ? colorProp : uncheckedColorProp,
|
|
101
|
+
'backgroundColor',
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
stateLayerStyle: [radioButtonStyles.stateLayer, stateLayerProps?.style],
|
|
105
|
+
};
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
}, [
|
|
108
|
+
borderAnim,
|
|
109
|
+
checked,
|
|
110
|
+
colorProp,
|
|
111
|
+
radioAnim,
|
|
112
|
+
stateLayerProps?.style,
|
|
113
|
+
uncheckedColorProp,
|
|
114
|
+
style,
|
|
115
|
+
state,
|
|
116
|
+
]);
|
|
132
117
|
|
|
133
118
|
useEffect(() => {
|
|
134
119
|
// Do not run animation on very first rendering
|
|
@@ -160,7 +145,6 @@ const RadioButtonAndroid = (
|
|
|
160
145
|
<TouchableRipple
|
|
161
146
|
{...rest}
|
|
162
147
|
ref={actionsRef}
|
|
163
|
-
rippleColor={rippleColor}
|
|
164
148
|
onPress={onPress}
|
|
165
149
|
style={containerStyles}
|
|
166
150
|
testID={testID}>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import setColor from 'color';
|
|
2
1
|
import { forwardRef, memo, useMemo } from 'react';
|
|
3
2
|
import { StyleSheet, View } from 'react-native';
|
|
4
3
|
|
|
@@ -56,32 +55,19 @@ const RadioButtonIOS = (
|
|
|
56
55
|
state: state as any,
|
|
57
56
|
});
|
|
58
57
|
|
|
59
|
-
const { containerStyle, iconContainerStyle, iconStyle
|
|
58
|
+
const { containerStyle, iconContainerStyle, iconStyle } = useMemo(() => {
|
|
60
59
|
const _color = tokenStylesParser.getColor(checked ? colorProp : uncheckedColorProp);
|
|
61
|
-
let _rippleColor: string | undefined;
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
_rippleColor = setColor(_color).alpha(0.32).rgb().string();
|
|
65
|
-
} catch (e) {
|
|
66
|
-
_rippleColor = undefined;
|
|
67
|
-
}
|
|
68
60
|
|
|
69
61
|
return {
|
|
70
62
|
containerStyle: [styles.container, radioButtonStyles.root, style],
|
|
71
63
|
iconContainerStyle: { opacity: checked ? 1 : 0 },
|
|
72
64
|
iconStyle: [radioButtonStyles.icon, _color],
|
|
73
|
-
rippleColor: _rippleColor,
|
|
74
65
|
};
|
|
75
66
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
67
|
}, [checked, colorProp, style, state, uncheckedColorProp]);
|
|
77
68
|
|
|
78
69
|
return (
|
|
79
|
-
<TouchableRipple
|
|
80
|
-
{...rest}
|
|
81
|
-
ref={ref}
|
|
82
|
-
rippleColor={rippleColor}
|
|
83
|
-
onPress={onPress}
|
|
84
|
-
style={containerStyle}>
|
|
70
|
+
<TouchableRipple {...rest} ref={ref} onPress={onPress} style={containerStyle}>
|
|
85
71
|
<View style={iconContainerStyle}>
|
|
86
72
|
<Icon
|
|
87
73
|
allowFontScaling={false}
|