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,38 @@
|
|
|
1
|
+
import { createContext, forwardRef, memo, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { AccordionItem, type AccordionItemProps } from '../../Accordion';
|
|
4
|
+
import { drawerCollapsibleItemStyles } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = AccordionItemProps & {
|
|
7
|
+
active?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const DrawerCollapsibleItem = memo(
|
|
11
|
+
forwardRef(({ style, active = false, children, ...rest }: Props, ref: any) => {
|
|
12
|
+
const contextValue = useMemo(
|
|
13
|
+
() => ({
|
|
14
|
+
active,
|
|
15
|
+
}),
|
|
16
|
+
[active],
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<DrawerCollapsibleItemContext.Provider value={contextValue}>
|
|
21
|
+
<AccordionItem
|
|
22
|
+
{...rest}
|
|
23
|
+
style={useMemo(() => [drawerCollapsibleItemStyles.root, style], [style])}
|
|
24
|
+
ref={ref}>
|
|
25
|
+
{children}
|
|
26
|
+
</AccordionItem>
|
|
27
|
+
</DrawerCollapsibleItemContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const DrawerCollapsibleItemContext = createContext({
|
|
33
|
+
active: false,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
DrawerCollapsibleItem.displayName = 'AccordionItem';
|
|
37
|
+
|
|
38
|
+
export default DrawerCollapsibleItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { AccordionItem, type AccordionItemContentProps } from '../../Accordion';
|
|
4
|
+
import { drawerCollapsibleItemContentStyles } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = AccordionItemContentProps & {};
|
|
7
|
+
|
|
8
|
+
const DrawerCollapsibleItemContent = memo(({ style, ...rest }: Props) => {
|
|
9
|
+
return (
|
|
10
|
+
<AccordionItem.Content {...rest} style={[drawerCollapsibleItemContentStyles.root, style]} />
|
|
11
|
+
);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
DrawerCollapsibleItemContent.displayName = 'AccordionItem_Content';
|
|
15
|
+
|
|
16
|
+
export default DrawerCollapsibleItemContent;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { forwardRef, memo, useContext, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { resolveStateVariant } from '../../../utils';
|
|
4
|
+
import { AccordionItem, type AccordionItemHeaderProps } from '../../Accordion';
|
|
5
|
+
import { DrawerCollapsibleItemContext } from './DrawerCollapsibleItem';
|
|
6
|
+
import { drawerCollapsibleItemHeaderStyles } from './utils';
|
|
7
|
+
|
|
8
|
+
export type Props = AccordionItemHeaderProps & {};
|
|
9
|
+
|
|
10
|
+
const DrawerCollapsibleItemHeader = memo(
|
|
11
|
+
forwardRef(({ style, ...rest }: Props, ref: any) => {
|
|
12
|
+
const { active } = useContext(DrawerCollapsibleItemContext);
|
|
13
|
+
|
|
14
|
+
const state = resolveStateVariant({
|
|
15
|
+
active,
|
|
16
|
+
});
|
|
17
|
+
drawerCollapsibleItemHeaderStyles.useVariants({
|
|
18
|
+
state: state as any,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const { leftElementStyle, rightElementStyle, contentStyle, headerStyle } = useMemo(() => {
|
|
22
|
+
const { content, leftElement, rightElement } = drawerCollapsibleItemHeaderStyles;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
headerStyle: [style],
|
|
26
|
+
leftElementStyle: leftElement,
|
|
27
|
+
rightElementStyle: rightElement,
|
|
28
|
+
contentStyle: content,
|
|
29
|
+
};
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
}, [style, state]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<AccordionItem.Header
|
|
35
|
+
{...rest}
|
|
36
|
+
style={headerStyle}
|
|
37
|
+
contentStyle={contentStyle}
|
|
38
|
+
leftElementStyle={leftElementStyle}
|
|
39
|
+
rightElementStyle={rightElementStyle}
|
|
40
|
+
ref={ref}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
DrawerCollapsibleItemHeader.displayName = 'AccordionItem_Header';
|
|
47
|
+
|
|
48
|
+
export default DrawerCollapsibleItemHeader;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import DrawerCollapsibleItemComponent from './DrawerCollapsibleItem';
|
|
2
|
+
import DrawerCollapsibleItemContent from './DrawerCollapsibleItemContent';
|
|
3
|
+
import DrawerCollapsibleItemHeader from './DrawerCollapsibleItemHeader';
|
|
4
|
+
|
|
5
|
+
export const DrawerCollapsibleItem = Object.assign(DrawerCollapsibleItemComponent, {
|
|
6
|
+
Header: DrawerCollapsibleItemHeader,
|
|
7
|
+
Content: DrawerCollapsibleItemContent,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type { AccordionHeaderElementProps as DrawerCollapsibleItemHeaderElementProps } from '../../Accordion';
|
|
11
|
+
export {
|
|
12
|
+
default as DrawerCollapsible,
|
|
13
|
+
type Props as DrawerCollapsibleProps,
|
|
14
|
+
} from './DrawerCollapsible';
|
|
15
|
+
export type { Props as DrawerCollapsibleItemProps } from './DrawerCollapsibleItem';
|
|
16
|
+
export type { Props as DrawerCollapsibleItemContentProps } from './DrawerCollapsibleItemContent';
|
|
17
|
+
export type { Props as DrawerCollapsibleItemHeaderProps } from './DrawerCollapsibleItemHeader';
|
|
18
|
+
export {
|
|
19
|
+
drawerCollapsibleItemContentStyles,
|
|
20
|
+
drawerCollapsibleItemHeaderStyles,
|
|
21
|
+
drawerCollapsibleItemStyles,
|
|
22
|
+
drawerCollapsibleStyles,
|
|
23
|
+
} from './utils';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../../core';
|
|
4
|
+
|
|
5
|
+
export const drawerCollapsibleStylesDefault = StyleSheet.create({
|
|
6
|
+
root: {},
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const drawerCollapsibleItemStylesDefault = StyleSheet.create({
|
|
10
|
+
root: {},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const drawerCollapsibleItemHeaderStylesDefault = StyleSheet.create(theme => ({
|
|
14
|
+
content: {
|
|
15
|
+
color: theme.colors.onSurfaceVariant,
|
|
16
|
+
...theme.typescale.labelLarge,
|
|
17
|
+
|
|
18
|
+
variants: {
|
|
19
|
+
state: {
|
|
20
|
+
active: {
|
|
21
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
leftElement: {},
|
|
27
|
+
rightElement: {},
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export const drawerCollapsibleItemContentStylesDefault = StyleSheet.create({
|
|
31
|
+
root: {},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
registerComponentsStyles({
|
|
35
|
+
Drawer_Collapsible: drawerCollapsibleStylesDefault,
|
|
36
|
+
Drawer_CollapsibleItem: drawerCollapsibleItemStylesDefault,
|
|
37
|
+
Drawer_CollapsibleItem_Header: drawerCollapsibleItemHeaderStylesDefault,
|
|
38
|
+
Drawer_CollapsibleItem_Content: drawerCollapsibleItemContentStylesDefault,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const drawerCollapsibleStyles = getRegisteredMoleculesComponentStyles('Drawer_Collapsible');
|
|
42
|
+
export const drawerCollapsibleItemStyles =
|
|
43
|
+
getRegisteredMoleculesComponentStyles('Drawer_CollapsibleItem');
|
|
44
|
+
export const drawerCollapsibleItemHeaderStyles = getRegisteredMoleculesComponentStyles(
|
|
45
|
+
'Drawer_CollapsibleItem_Header',
|
|
46
|
+
);
|
|
47
|
+
export const drawerCollapsibleItemContentStyles = getRegisteredMoleculesComponentStyles(
|
|
48
|
+
'Drawer_CollapsibleItem_Content',
|
|
49
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { memo, type ReactElement } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
|
|
6
|
+
import { useSubcomponents } from '../../hooks';
|
|
7
|
+
|
|
8
|
+
export type Props = Omit<ViewProps, 'children'> & {
|
|
9
|
+
children: ReactElement | ReactElement[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const allowedChildren = ['Drawer_Footer', 'Drawer_Header', 'Drawer_Content'];
|
|
13
|
+
|
|
14
|
+
const Drawer = ({ style, children, ...rest }: Props) => {
|
|
15
|
+
const { Drawer_Header, Drawer_Footer, Drawer_Content } = useSubcomponents({
|
|
16
|
+
children,
|
|
17
|
+
allowedChildren,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<View style={[drawerStyles.root, style]} {...rest}>
|
|
22
|
+
{Drawer_Header[0]}
|
|
23
|
+
{Drawer_Content[0]}
|
|
24
|
+
{Drawer_Footer[0]}
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const drawerStylesDefault = StyleSheet.create(theme => ({
|
|
30
|
+
root: {
|
|
31
|
+
borderTopRightRadius: theme.shapes.corner.large,
|
|
32
|
+
borderBottomRightRadius: theme.shapes.corner.large,
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
backgroundColor: theme.colors.surface,
|
|
35
|
+
minWidth: 360,
|
|
36
|
+
flexGrow: 1,
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
registerComponentStyles('Drawer', drawerStylesDefault);
|
|
41
|
+
export const drawerStyles = getRegisteredMoleculesComponentStyles('Drawer');
|
|
42
|
+
|
|
43
|
+
export default memo(Drawer);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ComponentType, memo } from 'react';
|
|
2
|
+
import { ScrollView, type ScrollViewProps } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
|
|
6
|
+
|
|
7
|
+
export type Props = ScrollViewProps & {
|
|
8
|
+
/**
|
|
9
|
+
* ContainerComponent prop allows to replace the default container used in DrawerContent - ScrollView
|
|
10
|
+
* */
|
|
11
|
+
ContainerComponent?: ComponentType<any>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const DrawerContent = memo(
|
|
15
|
+
({ style, children, ContainerComponent = ScrollView, ...rest }: Props) => {
|
|
16
|
+
return (
|
|
17
|
+
<ContainerComponent style={[drawerContentStyles.root, style]} {...rest}>
|
|
18
|
+
{children}
|
|
19
|
+
</ContainerComponent>
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const drawerContentStylesDefault = StyleSheet.create(theme => ({
|
|
25
|
+
root: {
|
|
26
|
+
paddingHorizontal: theme.spacings['3'],
|
|
27
|
+
flex: 1,
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
registerComponentStyles('Drawer_Content', drawerContentStylesDefault);
|
|
31
|
+
export const drawerContentStyles = getRegisteredMoleculesComponentStyles('Drawer_Content');
|
|
32
|
+
|
|
33
|
+
DrawerContent.displayName = 'Drawer_Content';
|
|
34
|
+
|
|
35
|
+
export default DrawerContent;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
|
|
6
|
+
|
|
7
|
+
export type Props = ViewProps & {};
|
|
8
|
+
|
|
9
|
+
const DrawerFooter = memo(({ style, children, ...rest }: Props) => {
|
|
10
|
+
return (
|
|
11
|
+
<View style={[drawerFooterStyles.root, style]} {...rest}>
|
|
12
|
+
{children}
|
|
13
|
+
</View>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
DrawerFooter.displayName = 'Drawer_Footer';
|
|
18
|
+
|
|
19
|
+
const drawerFooterStylesDefault = StyleSheet.create({
|
|
20
|
+
root: {},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
registerComponentStyles('Drawer_Footer', drawerFooterStylesDefault);
|
|
24
|
+
|
|
25
|
+
export const drawerFooterStyles = getRegisteredMoleculesComponentStyles('Drawer_Footer');
|
|
26
|
+
|
|
27
|
+
export default DrawerFooter;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { View, type ViewProps } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
|
|
6
|
+
|
|
7
|
+
export type Props = ViewProps & {};
|
|
8
|
+
|
|
9
|
+
const DrawerHeader = memo(({ style, children, ...rest }: Props) => {
|
|
10
|
+
return (
|
|
11
|
+
<View style={[drawerHeaderStyles.root, style]} {...rest}>
|
|
12
|
+
{children}
|
|
13
|
+
</View>
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
DrawerHeader.displayName = 'Drawer_Header';
|
|
18
|
+
|
|
19
|
+
const drawerHeaderStylesDefault = StyleSheet.create({
|
|
20
|
+
root: {},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
registerComponentStyles('Drawer_Header', drawerHeaderStylesDefault);
|
|
24
|
+
|
|
25
|
+
export const drawerHeaderStyles = getRegisteredMoleculesComponentStyles('Drawer_Header');
|
|
26
|
+
|
|
27
|
+
export default DrawerHeader;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { forwardRef, memo, type ReactNode, useMemo } from 'react';
|
|
2
|
+
import { type TextProps, type TextStyle, View, type ViewStyle } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
|
|
6
|
+
import { useActionState } from '../../hooks';
|
|
7
|
+
import type { WithElements } from '../../types';
|
|
8
|
+
import { resolveStateVariant } from '../../utils';
|
|
9
|
+
import { Text } from '../Text';
|
|
10
|
+
import { TouchableRipple, type TouchableRippleProps } from '../TouchableRipple';
|
|
11
|
+
|
|
12
|
+
export type DrawerItemElementProps = { color: string; hovered: boolean };
|
|
13
|
+
|
|
14
|
+
export type DrawerItemElement = ReactNode | ((props: DrawerItemElementProps) => ReactNode);
|
|
15
|
+
|
|
16
|
+
export type Props = Omit<TouchableRippleProps, 'children' | 'disabled'> &
|
|
17
|
+
WithElements<DrawerItemElement> & {
|
|
18
|
+
label?: string;
|
|
19
|
+
active?: boolean;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
|
|
22
|
+
leftElementContainerStyle?: ViewStyle;
|
|
23
|
+
rightElementContainerStyle?: ViewStyle;
|
|
24
|
+
contentStyle?: ViewStyle;
|
|
25
|
+
labelStyle?: TextStyle;
|
|
26
|
+
labelProps?: Omit<TextProps, 'children' | 'style'>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const emptyObj = {};
|
|
30
|
+
|
|
31
|
+
const DrawerItem = (
|
|
32
|
+
{
|
|
33
|
+
left,
|
|
34
|
+
right,
|
|
35
|
+
label,
|
|
36
|
+
children,
|
|
37
|
+
style,
|
|
38
|
+
active = false,
|
|
39
|
+
leftElementContainerStyle = emptyObj,
|
|
40
|
+
rightElementContainerStyle = emptyObj,
|
|
41
|
+
labelStyle: labelStyleProp = emptyObj,
|
|
42
|
+
contentStyle: contentStyleProp = emptyObj,
|
|
43
|
+
labelProps,
|
|
44
|
+
...rest
|
|
45
|
+
}: Props,
|
|
46
|
+
ref: any,
|
|
47
|
+
) => {
|
|
48
|
+
const { hovered, actionsRef } = useActionState({ ref, actionsToListen: ['hover'] });
|
|
49
|
+
const state = resolveStateVariant({
|
|
50
|
+
activeAndHovered: active && hovered,
|
|
51
|
+
active,
|
|
52
|
+
hovered,
|
|
53
|
+
});
|
|
54
|
+
drawerItemStyles.useVariants({
|
|
55
|
+
state: state as any,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const {
|
|
59
|
+
leftElementColor,
|
|
60
|
+
rightElementColor,
|
|
61
|
+
containerStyle,
|
|
62
|
+
leftElementStyle,
|
|
63
|
+
rightElementStyle,
|
|
64
|
+
contentStyle,
|
|
65
|
+
labelStyle,
|
|
66
|
+
} = useMemo(() => {
|
|
67
|
+
const { leftElement, rightElement, label: _labelStyle, content } = drawerItemStyles;
|
|
68
|
+
const {
|
|
69
|
+
leftElementColor: _leftElementColor,
|
|
70
|
+
rightElementColor: _rightElementColor,
|
|
71
|
+
...restStyle
|
|
72
|
+
} = drawerItemStyles.root;
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
leftElementColor: _leftElementColor,
|
|
76
|
+
rightElementColor: _rightElementColor,
|
|
77
|
+
containerStyle: [restStyle, style],
|
|
78
|
+
leftElementStyle: [leftElement, leftElementContainerStyle],
|
|
79
|
+
rightElementStyle: [rightElement, rightElementContainerStyle],
|
|
80
|
+
labelStyle: [_labelStyle, labelStyleProp],
|
|
81
|
+
contentStyle: [content, contentStyleProp],
|
|
82
|
+
};
|
|
83
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
|
+
}, [
|
|
85
|
+
contentStyleProp,
|
|
86
|
+
labelStyleProp,
|
|
87
|
+
leftElementContainerStyle,
|
|
88
|
+
rightElementContainerStyle,
|
|
89
|
+
style,
|
|
90
|
+
state,
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const _hoveredForLeftElement = typeof left === 'function' ? hovered : false;
|
|
94
|
+
const _hoveredForRightElement = typeof right === 'function' ? hovered : false;
|
|
95
|
+
|
|
96
|
+
const leftElement = useMemo(
|
|
97
|
+
() =>
|
|
98
|
+
left ? (
|
|
99
|
+
<View style={leftElementStyle}>
|
|
100
|
+
{typeof left === 'function'
|
|
101
|
+
? left?.({
|
|
102
|
+
color: leftElementColor,
|
|
103
|
+
hovered: _hoveredForLeftElement,
|
|
104
|
+
})
|
|
105
|
+
: left}
|
|
106
|
+
</View>
|
|
107
|
+
) : null,
|
|
108
|
+
[left, leftElementColor, leftElementStyle, _hoveredForLeftElement],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const rightElement = useMemo(
|
|
112
|
+
() =>
|
|
113
|
+
right ? (
|
|
114
|
+
<View style={rightElementStyle}>
|
|
115
|
+
{typeof right === 'function'
|
|
116
|
+
? right?.({
|
|
117
|
+
color: rightElementColor,
|
|
118
|
+
hovered: _hoveredForRightElement,
|
|
119
|
+
})
|
|
120
|
+
: right}
|
|
121
|
+
</View>
|
|
122
|
+
) : null,
|
|
123
|
+
[right, rightElementColor, rightElementStyle, _hoveredForRightElement],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<TouchableRipple style={containerStyle} {...rest} ref={actionsRef}>
|
|
128
|
+
<>
|
|
129
|
+
{leftElement}
|
|
130
|
+
<View style={contentStyle}>
|
|
131
|
+
<Text style={labelStyle} selectable={false} {...labelProps}>
|
|
132
|
+
{label}
|
|
133
|
+
</Text>
|
|
134
|
+
{children}
|
|
135
|
+
</View>
|
|
136
|
+
{rightElement}
|
|
137
|
+
</>
|
|
138
|
+
</TouchableRipple>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const drawerItemStylesDefault = StyleSheet.create(theme => ({
|
|
143
|
+
root: {
|
|
144
|
+
minHeight: 56,
|
|
145
|
+
flexDirection: 'row',
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
borderRadius: theme.shapes.corner.full,
|
|
148
|
+
paddingLeft: theme.spacings['4'],
|
|
149
|
+
paddingRight: theme.spacings['6'],
|
|
150
|
+
|
|
151
|
+
leftElementColor: theme.colors.onSurfaceVariant,
|
|
152
|
+
rightElementColor: theme.colors.onSurfaceVariant,
|
|
153
|
+
|
|
154
|
+
variants: {
|
|
155
|
+
state: {
|
|
156
|
+
activeAndHovered: {
|
|
157
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
158
|
+
leftElementColor: theme.colors.onSecondaryContainer,
|
|
159
|
+
},
|
|
160
|
+
active: {
|
|
161
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
162
|
+
leftElementColor: theme.colors.onSecondaryContainer,
|
|
163
|
+
},
|
|
164
|
+
hovered: {
|
|
165
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
leftElement: {
|
|
172
|
+
marginRight: theme.spacings['3'],
|
|
173
|
+
},
|
|
174
|
+
rightElement: {
|
|
175
|
+
marginLeft: theme.spacings['3'],
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
content: {
|
|
179
|
+
flexDirection: 'row',
|
|
180
|
+
flex: 1,
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
label: {
|
|
184
|
+
color: theme.colors.onSurfaceVariant,
|
|
185
|
+
lineHeight: theme.typescale.labelLarge.lineHeight,
|
|
186
|
+
fontSize: theme.typescale.labelLarge.fontSize,
|
|
187
|
+
fontWeight: theme.typescale.labelLarge.fontWeight,
|
|
188
|
+
flexGrow: 1,
|
|
189
|
+
|
|
190
|
+
variants: {
|
|
191
|
+
state: {
|
|
192
|
+
activeAndHovered: {
|
|
193
|
+
color: theme.colors.onSecondaryContainer,
|
|
194
|
+
},
|
|
195
|
+
active: {
|
|
196
|
+
color: theme.colors.onSecondaryContainer,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
}));
|
|
202
|
+
|
|
203
|
+
registerComponentStyles('Drawer_Item', drawerItemStylesDefault);
|
|
204
|
+
export const drawerItemStyles = getRegisteredMoleculesComponentStyles('Drawer_Item');
|
|
205
|
+
|
|
206
|
+
export default memo(forwardRef(DrawerItem));
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { memo, type ReactNode, useMemo } from 'react';
|
|
2
|
+
import { type TextProps, View, type ViewProps } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentStyles } from '../../core';
|
|
6
|
+
import { HorizontalDivider, type HorizontalDividerProps } from '../HorizontalDivider';
|
|
7
|
+
import { Text } from '../Text';
|
|
8
|
+
|
|
9
|
+
export type Props = ViewProps & {
|
|
10
|
+
title?: ReactNode;
|
|
11
|
+
showDivider?: boolean;
|
|
12
|
+
dividerProps?: HorizontalDividerProps;
|
|
13
|
+
titleProps?: TextProps;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const DrawerItemGroup = memo(
|
|
17
|
+
({
|
|
18
|
+
title,
|
|
19
|
+
style,
|
|
20
|
+
children,
|
|
21
|
+
showDivider,
|
|
22
|
+
dividerProps = {},
|
|
23
|
+
titleProps = {},
|
|
24
|
+
...rest
|
|
25
|
+
}: Props) => {
|
|
26
|
+
const { containerStyle, titleStyle, dividerStyle, dividerRestProps } = useMemo(() => {
|
|
27
|
+
const { title: _titleStyle, divider: _dividerStyle } = drawerItemGroupStyles;
|
|
28
|
+
const { style: dividerStyleProp, ..._dividerRestProps } = dividerProps;
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
containerStyle: [drawerItemGroupStyles.root, style],
|
|
32
|
+
titleStyle: _titleStyle,
|
|
33
|
+
dividerStyle: [_dividerStyle, dividerStyleProp],
|
|
34
|
+
dividerRestProps: _dividerRestProps,
|
|
35
|
+
};
|
|
36
|
+
}, [dividerProps, style]);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<View style={containerStyle} {...rest}>
|
|
40
|
+
<>
|
|
41
|
+
{title && (
|
|
42
|
+
<Text {...titleProps} style={[titleStyle, titleProps?.style]}>
|
|
43
|
+
{title}
|
|
44
|
+
</Text>
|
|
45
|
+
)}
|
|
46
|
+
</>
|
|
47
|
+
{children}
|
|
48
|
+
<>
|
|
49
|
+
{showDivider && (
|
|
50
|
+
<HorizontalDivider style={dividerStyle} {...dividerRestProps} />
|
|
51
|
+
)}
|
|
52
|
+
</>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const drawerItemGroupStylesDefault = StyleSheet.create(theme => ({
|
|
59
|
+
root: {
|
|
60
|
+
marginBottom: theme.spacings['1'],
|
|
61
|
+
},
|
|
62
|
+
title: {
|
|
63
|
+
color: theme.colors.onSurfaceVariant,
|
|
64
|
+
lineHeight: theme.typescale.titleSmall.lineHeight,
|
|
65
|
+
fontSize: theme.typescale.titleSmall.fontSize,
|
|
66
|
+
fontWeight: theme.typescale.titleSmall.fontWeight,
|
|
67
|
+
marginVertical: theme.spacings['4'],
|
|
68
|
+
marginHorizontal: theme.spacings['3'],
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
divider: {
|
|
72
|
+
marginTop: theme.spacings['1'],
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
registerComponentStyles('Drawer_ItemGroup', drawerItemGroupStylesDefault);
|
|
77
|
+
|
|
78
|
+
export const drawerItemGroupStyles = getRegisteredMoleculesComponentStyles('Drawer_ItemGroup');
|
|
79
|
+
|
|
80
|
+
DrawerItemGroup.displayName = 'Drawer_ItemGroup';
|
|
81
|
+
|
|
82
|
+
export default DrawerItemGroup;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import { DrawerCollapsible, DrawerCollapsibleItem } from './Collapsible';
|
|
3
|
+
import DrawerComponent from './Drawer';
|
|
4
|
+
import DrawerContent from './DrawerContent';
|
|
5
|
+
import DrawerFooter from './DrawerFooter';
|
|
6
|
+
import DrawerHeader from './DrawerHeader';
|
|
7
|
+
import DrawerItem from './DrawerItem';
|
|
8
|
+
import DrawerItemGroup from './DrawerItemGroup';
|
|
9
|
+
|
|
10
|
+
const DrawerDefault = Object.assign(DrawerComponent, {
|
|
11
|
+
Item: DrawerItem,
|
|
12
|
+
ItemGroup: DrawerItemGroup,
|
|
13
|
+
Header: DrawerHeader,
|
|
14
|
+
Content: DrawerContent,
|
|
15
|
+
Footer: DrawerFooter,
|
|
16
|
+
Collapsible: DrawerCollapsible,
|
|
17
|
+
CollapsibleItem: DrawerCollapsibleItem,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
registerMoleculesComponents({
|
|
21
|
+
Drawer: DrawerDefault,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Drawer = getRegisteredComponentWithFallback('Drawer', DrawerDefault);
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
type DrawerCollapsibleItemContentProps,
|
|
28
|
+
drawerCollapsibleItemContentStyles,
|
|
29
|
+
type DrawerCollapsibleItemHeaderElementProps,
|
|
30
|
+
type DrawerCollapsibleItemHeaderProps,
|
|
31
|
+
drawerCollapsibleItemHeaderStyles,
|
|
32
|
+
type DrawerCollapsibleItemProps,
|
|
33
|
+
drawerCollapsibleItemStyles,
|
|
34
|
+
type DrawerCollapsibleProps,
|
|
35
|
+
drawerCollapsibleStyles,
|
|
36
|
+
} from './Collapsible';
|
|
37
|
+
export { type Props as DrawerProps, drawerStyles } from './Drawer';
|
|
38
|
+
export { type Props as DrawerContentProps, drawerContentStyles } from './DrawerContent';
|
|
39
|
+
export { type Props as DrawerFooterProps, drawerFooterStyles } from './DrawerFooter';
|
|
40
|
+
export { type Props as DrawerHeaderProps, drawerHeaderStyles } from './DrawerHeader';
|
|
41
|
+
export {
|
|
42
|
+
type DrawerItemElement,
|
|
43
|
+
type DrawerItemElementProps,
|
|
44
|
+
type Props as DrawerItemProps,
|
|
45
|
+
drawerItemStyles,
|
|
46
|
+
} from './DrawerItem';
|
|
47
|
+
export { type Props as DrawerItemGroupProps, drawerItemGroupStyles } from './DrawerItemGroup';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { registerComponentsStyles } from '../../core';
|
|
2
|
+
|
|
3
|
+
registerComponentsStyles({
|
|
4
|
+
// Drawer_Collapsible: drawerCollapsibleStyles,
|
|
5
|
+
// Drawer_CollapsibleItem: drawerCollapsibleItemStyles,
|
|
6
|
+
// Drawer_CollapsibleItem_Header: drawerCollapsibleItemHeaderStyles,
|
|
7
|
+
// Drawer_CollapsibleItem_Content: drawerCollapsibleItemContentStyles,
|
|
8
|
+
});
|