react-native-molecules 0.5.0-beta.2 → 0.5.0-beta.20
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/README.md +1 -1
- 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 +209 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Checkbox/CheckboxBase.tsx +23 -128
- package/components/Checkbox/utils.ts +0 -25
- package/components/Chip/Chip.tsx +40 -52
- package/components/Chip/utils.ts +3 -7
- package/components/DateField/DateField.tsx +110 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +17 -49
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +234 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +152 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +82 -0
- package/components/DatePicker/index.tsx +44 -0
- package/components/DatePicker/utils.ts +293 -0
- package/components/DatePickerInline/DatePickerContext.tsx +1 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +113 -0
- package/components/DatePickerInline/DatePickerInline.tsx +16 -15
- package/components/DatePickerInline/DatePickerInlineBase.tsx +7 -1
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +42 -27
- package/components/DatePickerInline/Month.tsx +45 -65
- package/components/DatePickerInline/MonthPicker.tsx +25 -41
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +168 -13
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +206 -53
- package/components/DatePickerInline/dateUtils.tsx +17 -12
- package/components/DatePickerInline/types.ts +3 -0
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/Drawer/Drawer.tsx +17 -6
- package/components/ElementGroup/ElementGroup.tsx +16 -14
- 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 +3 -3
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +42 -57
- package/components/IconButton/utils.ts +142 -33
- package/components/ListItem/ListItem.tsx +3 -1
- package/components/ListItem/utils.ts +1 -1
- 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 +3 -18
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +122 -145
- package/components/Popover/PopoverRoot.tsx +74 -0
- package/components/Popover/common.ts +50 -34
- package/components/Popover/index.ts +18 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +118 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Select/Select.tsx +368 -507
- package/components/Select/context.tsx +72 -0
- package/components/Select/index.ts +8 -14
- package/components/Select/types.ts +2 -4
- package/components/Select/utils.ts +144 -0
- package/components/Slot/Slot.tsx +244 -0
- package/components/Slot/compose-refs.tsx +62 -0
- package/components/Slot/index.tsx +8 -0
- package/components/Surface/Surface.android.tsx +34 -8
- package/components/Surface/Surface.ios.tsx +36 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -30
- package/components/Switch/Switch.tsx +8 -2
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +154 -148
- package/components/Tabs/utils.ts +15 -2
- package/components/TextInput/TextInput.tsx +658 -575
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +76 -27
- package/components/TextInput/utils.ts +225 -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/TimeInput.tsx +87 -37
- package/components/TimePicker/TimeInputs.tsx +137 -49
- package/components/TimePicker/TimePicker.tsx +73 -10
- 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 -0
- package/components/Tooltip/Tooltip.tsx +42 -67
- package/components/Tooltip/TooltipContent.tsx +32 -5
- package/components/Tooltip/TooltipTrigger.tsx +20 -20
- package/components/Tooltip/index.tsx +1 -1
- package/components/TouchableRipple/TouchableRipple.native.tsx +50 -14
- package/components/TouchableRipple/TouchableRipple.tsx +137 -47
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +0 -6
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useControlledValue.tsx +20 -4
- package/hooks/useFilePicker.tsx +6 -16
- package/hooks/useWhatHasUpdated.tsx +48 -0
- package/package.json +17 -13
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +5 -2
- 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/extractPropertiesFromStyles.ts +25 -0
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/lodash.ts +77 -5
- 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/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/Popover/Popover.native.tsx +0 -185
- 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/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ React Native Molecules
|
|
|
4
4
|
|
|
5
5
|
<h3 align="center">
|
|
6
6
|
Material 3-powered primitives for React Native + Web.<br/>
|
|
7
|
-
<a href="https://
|
|
7
|
+
<a href="https://molecules.taylordb.ai">Explore the docs</a>
|
|
8
8
|
</h3>
|
|
9
9
|
|
|
10
10
|
---
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from 'react';
|
|
10
10
|
import { View } from 'react-native';
|
|
11
11
|
|
|
12
|
-
import { useControlledValue
|
|
12
|
+
import { useControlledValue } from '../../hooks';
|
|
13
13
|
import { accordionStyles } from './utils';
|
|
14
14
|
|
|
15
15
|
export type Props = Omit<ComponentPropsWithRef<typeof View>, 'children'> & {
|
|
@@ -38,8 +38,6 @@ const Accordion = (
|
|
|
38
38
|
onChange: onChangeProp,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
const { AccordionItem } = useSubcomponents({ children, allowedChildren: ['AccordionItem'] });
|
|
42
|
-
|
|
43
41
|
const onPressItem = useCallback(
|
|
44
42
|
(id: string) => {
|
|
45
43
|
const isSelected = Array.isArray(expandedItemIds)
|
|
@@ -70,9 +68,7 @@ const Accordion = (
|
|
|
70
68
|
|
|
71
69
|
return (
|
|
72
70
|
<View style={[accordionStyles.root, style]} {...rest} ref={ref}>
|
|
73
|
-
<AccordionContext.Provider value={contextValue}>
|
|
74
|
-
{AccordionItem}
|
|
75
|
-
</AccordionContext.Provider>
|
|
71
|
+
<AccordionContext.Provider value={contextValue}>{children}</AccordionContext.Provider>
|
|
76
72
|
</View>
|
|
77
73
|
);
|
|
78
74
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createContext,
|
|
3
2
|
forwardRef,
|
|
4
3
|
memo,
|
|
5
4
|
type ReactElement,
|
|
@@ -10,10 +9,11 @@ import {
|
|
|
10
9
|
} from 'react';
|
|
11
10
|
import { View, type ViewProps } from 'react-native';
|
|
12
11
|
|
|
13
|
-
import { useControlledValue
|
|
12
|
+
import { useControlledValue } from '../../hooks';
|
|
14
13
|
import type { WithElements } from '../../types';
|
|
14
|
+
import { extractSubcomponents } from '../../utils/extractSubcomponents';
|
|
15
15
|
import { AccordionContext } from './Accordion';
|
|
16
|
-
import { accordionItemStyles } from './utils';
|
|
16
|
+
import { AccordionItemContext, accordionItemStyles } from './utils';
|
|
17
17
|
|
|
18
18
|
export type Props = Omit<ViewProps, 'children'> &
|
|
19
19
|
WithElements<ReactNode> & {
|
|
@@ -45,9 +45,17 @@ const AccordionItem = memo(
|
|
|
45
45
|
|
|
46
46
|
const groupContext = useContext(AccordionContext);
|
|
47
47
|
|
|
48
|
-
const {
|
|
48
|
+
const {
|
|
49
|
+
AccordionItem_Header,
|
|
50
|
+
AccordionItem_Content,
|
|
51
|
+
rest: restChildren,
|
|
52
|
+
} = extractSubcomponents({
|
|
49
53
|
children,
|
|
50
|
-
allowedChildren: [
|
|
54
|
+
allowedChildren: [
|
|
55
|
+
{ name: 'AccordionItem_Header', allowMultiple: false },
|
|
56
|
+
{ name: 'AccordionItem_Content', allowMultiple: false },
|
|
57
|
+
],
|
|
58
|
+
includeRest: true,
|
|
51
59
|
});
|
|
52
60
|
|
|
53
61
|
useEffect(() => {
|
|
@@ -76,8 +84,9 @@ const AccordionItem = memo(
|
|
|
76
84
|
return (
|
|
77
85
|
<View style={[accordionItemStyles.root, style]} {...rest} ref={ref}>
|
|
78
86
|
<AccordionItemContext.Provider value={contextValue}>
|
|
79
|
-
{AccordionItem_Header
|
|
80
|
-
{contextValue.expanded ? AccordionItem_Content
|
|
87
|
+
{AccordionItem_Header}
|
|
88
|
+
{contextValue.expanded ? AccordionItem_Content : null}
|
|
89
|
+
{restChildren}
|
|
81
90
|
</AccordionItemContext.Provider>
|
|
82
91
|
</View>
|
|
83
92
|
);
|
|
@@ -85,11 +94,6 @@ const AccordionItem = memo(
|
|
|
85
94
|
),
|
|
86
95
|
);
|
|
87
96
|
|
|
88
|
-
export const AccordionItemContext = createContext({
|
|
89
|
-
expanded: false,
|
|
90
|
-
onExpandedChange: (_expanded: boolean) => {},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
97
|
AccordionItem.displayName = 'AccordionItem';
|
|
94
98
|
|
|
95
99
|
export default AccordionItem;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { memo } from 'react';
|
|
1
|
+
import { memo, useContext } from 'react';
|
|
2
2
|
import { View, type ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import { AccordionItemContext } from './utils';
|
|
4
5
|
import { accordionItemContentStyles } from './utils';
|
|
5
6
|
|
|
6
7
|
export type Props = ViewProps & {};
|
|
7
8
|
|
|
8
9
|
const AccordionItemContent = memo(({ style, children, ...rest }: Props) => {
|
|
10
|
+
const { expanded } = useContext(AccordionItemContext);
|
|
11
|
+
|
|
12
|
+
if (!expanded) return null;
|
|
13
|
+
|
|
9
14
|
return (
|
|
10
15
|
<View style={[accordionItemContentStyles.root, style]} {...rest}>
|
|
11
16
|
{children}
|
|
@@ -6,7 +6,7 @@ import type { WithElements } from '../../types';
|
|
|
6
6
|
import { resolveStateVariant } from '../../utils';
|
|
7
7
|
import { Text } from '../Text';
|
|
8
8
|
import { TouchableRipple, type TouchableRippleProps } from '../TouchableRipple';
|
|
9
|
-
import { AccordionItemContext } from './
|
|
9
|
+
import { AccordionItemContext } from './utils';
|
|
10
10
|
import { accordionItemHeaderStyles } from './utils';
|
|
11
11
|
|
|
12
12
|
export type AccordionHeaderElementProps = {
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
1
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
3
|
|
|
3
4
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
5
|
|
|
6
|
+
export const AccordionItemContext = createContext({
|
|
7
|
+
expanded: false,
|
|
8
|
+
onExpandedChange: (_expanded: boolean) => {},
|
|
9
|
+
});
|
|
10
|
+
|
|
5
11
|
const accordionStylesDefault = StyleSheet.create({
|
|
6
12
|
root: {},
|
|
7
13
|
});
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
type ActivityIndicatorProps,
|
|
4
|
-
Animated,
|
|
5
|
-
Easing,
|
|
6
|
-
Platform,
|
|
7
|
-
View,
|
|
8
|
-
type ViewStyle,
|
|
9
|
-
} from 'react-native';
|
|
2
|
+
import { type ActivityIndicatorProps, Animated, Easing, Platform, View } from 'react-native';
|
|
10
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
11
4
|
|
|
12
5
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
13
6
|
import AnimatedSpinner from './AnimatedSpinner';
|
|
14
7
|
|
|
15
|
-
export type Props = ActivityIndicatorProps & {
|
|
8
|
+
export type Props = Omit<ActivityIndicatorProps, 'color'> & {
|
|
16
9
|
/**
|
|
17
10
|
* Whether to show the indicator or hide it.
|
|
18
11
|
*/
|
|
19
12
|
animating?: boolean;
|
|
20
13
|
/**
|
|
21
14
|
* The color of the spinner.
|
|
22
|
-
*/
|
|
23
15
|
color?: string;
|
|
24
16
|
/**
|
|
25
17
|
* Size of the indicator.
|
|
@@ -29,7 +21,7 @@ export type Props = ActivityIndicatorProps & {
|
|
|
29
21
|
* Whether the indicator should hide when not animating.
|
|
30
22
|
*/
|
|
31
23
|
hidesWhenStopped?: boolean;
|
|
32
|
-
|
|
24
|
+
color?: string;
|
|
33
25
|
};
|
|
34
26
|
|
|
35
27
|
const DURATION = 2400;
|
|
@@ -63,7 +55,7 @@ const mapIndicatorSize = (indicatorSize: 'small' | 'large' | number | undefined)
|
|
|
63
55
|
*/
|
|
64
56
|
const ActivityIndicator = ({
|
|
65
57
|
animating = true,
|
|
66
|
-
color
|
|
58
|
+
color,
|
|
67
59
|
hidesWhenStopped = true,
|
|
68
60
|
size: indicatorSize = 'small',
|
|
69
61
|
style: styleProp,
|
|
@@ -83,13 +75,12 @@ const ActivityIndicator = ({
|
|
|
83
75
|
|
|
84
76
|
const size = mapIndicatorSize(indicatorSize);
|
|
85
77
|
|
|
86
|
-
const {
|
|
78
|
+
const { viewStyle, animatedViewStyle } = useMemo(() => {
|
|
87
79
|
return {
|
|
88
|
-
color: indicatorColorProp,
|
|
89
80
|
viewStyle: [componentStyles.container, styleProp],
|
|
90
81
|
animatedViewStyle: [{ width: size, height: size, opacity: fade }],
|
|
91
82
|
};
|
|
92
|
-
}, [componentStyles.container, fade,
|
|
83
|
+
}, [componentStyles.container, fade, size, styleProp]);
|
|
93
84
|
|
|
94
85
|
const startRotation = useCallback(() => {
|
|
95
86
|
// Show indicator
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext, memo, useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { extractSubcomponents } from '../../utils/extractSubcomponents';
|
|
5
5
|
import { Surface } from '../Surface';
|
|
6
6
|
import type { AppbarBaseProps, AppbarType } from './types';
|
|
7
7
|
import { appbarBaseStyles } from './utils';
|
|
@@ -26,9 +26,19 @@ const AppbarBase = ({
|
|
|
26
26
|
};
|
|
27
27
|
}, [innerContainerStyleProp, scrolling, style]);
|
|
28
28
|
|
|
29
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
Appbar_Left,
|
|
31
|
+
Appbar_Right,
|
|
32
|
+
Appbar_Title,
|
|
33
|
+
rest: restChildren,
|
|
34
|
+
} = extractSubcomponents({
|
|
30
35
|
children,
|
|
31
|
-
allowedChildren: [
|
|
36
|
+
allowedChildren: [
|
|
37
|
+
{ name: 'Appbar_Left', allowMultiple: false },
|
|
38
|
+
{ name: 'Appbar_Right', allowMultiple: false },
|
|
39
|
+
{ name: 'Appbar_Title', allowMultiple: false },
|
|
40
|
+
],
|
|
41
|
+
includeRest: true,
|
|
32
42
|
});
|
|
33
43
|
|
|
34
44
|
const contextValue = useMemo(() => ({ type: _type }), [_type]);
|
|
@@ -37,17 +47,12 @@ const AppbarBase = ({
|
|
|
37
47
|
<Surface elevation={elevation} style={containerStyle} {...rest}>
|
|
38
48
|
<AppbarContext.Provider value={contextValue}>
|
|
39
49
|
<View style={innerContainerStyle}>
|
|
40
|
-
{Appbar_Left
|
|
41
|
-
<>
|
|
42
|
-
|
|
43
|
-
Appbar_Title[0]
|
|
44
|
-
) : (
|
|
45
|
-
<View />
|
|
46
|
-
)}
|
|
47
|
-
</>
|
|
48
|
-
{Appbar_Right[0]}
|
|
50
|
+
{Appbar_Left}
|
|
51
|
+
<>{_type === 'center-aligned' || _type === 'small' ? Appbar_Title : <View />}</>
|
|
52
|
+
{Appbar_Right}
|
|
49
53
|
</View>
|
|
50
|
-
|
|
54
|
+
{(_type === 'medium' || _type === 'large') && Appbar_Title}
|
|
55
|
+
{restChildren}
|
|
51
56
|
</AppbarContext.Provider>
|
|
52
57
|
</Surface>
|
|
53
58
|
);
|