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,172 @@
|
|
|
1
|
+
import { format, parse, set } from 'date-fns';
|
|
2
|
+
import {
|
|
3
|
+
type ComponentType,
|
|
4
|
+
forwardRef,
|
|
5
|
+
memo,
|
|
6
|
+
type RefObject,
|
|
7
|
+
useCallback,
|
|
8
|
+
useEffect,
|
|
9
|
+
useImperativeHandle,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import type { ViewProps, ViewStyle } from 'react-native';
|
|
14
|
+
|
|
15
|
+
import { useControlledValue } from '../../hooks';
|
|
16
|
+
import { isValid } from '../../utils/date-fns';
|
|
17
|
+
import { DatePickerInput, type DatePickerInputProps } from '../DatePickerInput';
|
|
18
|
+
import { ElementGroup } from '../ElementGroup';
|
|
19
|
+
import type { TextInputHandles } from '../TextInput/TextInput';
|
|
20
|
+
import { sanitizeTimeString, TimePickerField, type TimePickerFieldProps } from '../TimePickerField';
|
|
21
|
+
|
|
22
|
+
export type Props = Omit<ViewProps, 'style'> & {
|
|
23
|
+
is24Hour?: boolean;
|
|
24
|
+
date?: Date | null;
|
|
25
|
+
onChange?: (date: Date | null) => void;
|
|
26
|
+
defaultValue?: Date | null;
|
|
27
|
+
timePickerFieldProps?: Omit<
|
|
28
|
+
Partial<TimePickerFieldProps>,
|
|
29
|
+
'value' | 'onChangeText' | 'date' | 'onTimeChange'
|
|
30
|
+
>;
|
|
31
|
+
datePickerInputProps?: Omit<Partial<DatePickerInputProps>, 'value' | 'onChange'>;
|
|
32
|
+
datePickerInputRef?: RefObject<TextInputHandles | null>;
|
|
33
|
+
timePickerInputRef?: RefObject<TextInputHandles | null>;
|
|
34
|
+
Wrapper?: ComponentType<any>;
|
|
35
|
+
style?: ViewStyle;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const emptyObj = {};
|
|
39
|
+
|
|
40
|
+
const normalizeDateWithCurrentTime = (specificDate: Date) => {
|
|
41
|
+
const date = new Date();
|
|
42
|
+
|
|
43
|
+
return set(specificDate, {
|
|
44
|
+
hours: date.getHours(),
|
|
45
|
+
minutes: date.getHours(),
|
|
46
|
+
seconds: date.getSeconds(),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const DateTimePicker = (
|
|
51
|
+
{
|
|
52
|
+
is24Hour = false,
|
|
53
|
+
date: dateProp,
|
|
54
|
+
onChange: onChangeProp,
|
|
55
|
+
defaultValue,
|
|
56
|
+
datePickerInputProps = emptyObj,
|
|
57
|
+
timePickerFieldProps = emptyObj,
|
|
58
|
+
style,
|
|
59
|
+
testID,
|
|
60
|
+
datePickerInputRef: _datePickerInputRef,
|
|
61
|
+
timePickerInputRef: _timePickerInputRef,
|
|
62
|
+
Wrapper: _WrapperProp,
|
|
63
|
+
...rest
|
|
64
|
+
}: Props,
|
|
65
|
+
ref: any,
|
|
66
|
+
) => {
|
|
67
|
+
const Wrapper = _WrapperProp ?? ElementGroup;
|
|
68
|
+
|
|
69
|
+
const containerRef = useRef(null);
|
|
70
|
+
const datePickerInputRef = useRef<TextInputHandles>(null);
|
|
71
|
+
const timePickerInputRef = useRef<TextInputHandles>(null);
|
|
72
|
+
|
|
73
|
+
const [date, onChange] = useControlledValue<Date | null>({
|
|
74
|
+
value: dateProp,
|
|
75
|
+
defaultValue,
|
|
76
|
+
onChange: onChangeProp,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const timeString = useMemo(() => (date && isValid(date) ? format(date, 'HH:mm') : ''), [date]);
|
|
80
|
+
|
|
81
|
+
const timeStringRef = useRef(timeString);
|
|
82
|
+
|
|
83
|
+
const onDateChange = useCallback(
|
|
84
|
+
(newDate: Date | null) => {
|
|
85
|
+
if (newDate === date || (!isValid(newDate) && !isValid(date))) return;
|
|
86
|
+
|
|
87
|
+
if (!newDate) {
|
|
88
|
+
onChange(null);
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const addTimeString = (_date: Date) =>
|
|
94
|
+
timeStringRef.current
|
|
95
|
+
? parse(timeStringRef.current ?? '00:00', 'HH:mm', _date)
|
|
96
|
+
: _date;
|
|
97
|
+
|
|
98
|
+
if (!date) {
|
|
99
|
+
onChange(addTimeString(normalizeDateWithCurrentTime(newDate)));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (!isValid(newDate)) {
|
|
104
|
+
onChange(date);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const [day, month, year] = format(newDate, 'dd/MM/yyyy').split('/');
|
|
109
|
+
|
|
110
|
+
onChange(addTimeString(set(date, { date: +day, month: +month - 1, year: +year })));
|
|
111
|
+
},
|
|
112
|
+
[date, onChange],
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const onTimeChange = useCallback(
|
|
116
|
+
(time: string) => {
|
|
117
|
+
if (!time) return;
|
|
118
|
+
|
|
119
|
+
const newTime = sanitizeTimeString(time);
|
|
120
|
+
|
|
121
|
+
timeStringRef.current = newTime;
|
|
122
|
+
|
|
123
|
+
onChange(date ? parse(newTime, 'HH:mm', date) : null);
|
|
124
|
+
},
|
|
125
|
+
[date, onChange],
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (isValid(date)) return;
|
|
130
|
+
|
|
131
|
+
onChange(null);
|
|
132
|
+
}, [date, onChange]);
|
|
133
|
+
|
|
134
|
+
useImperativeHandle(_datePickerInputRef, () => datePickerInputRef.current as TextInputHandles);
|
|
135
|
+
useImperativeHandle(_timePickerInputRef, () => timePickerInputRef.current as TextInputHandles);
|
|
136
|
+
|
|
137
|
+
useImperativeHandle(ref, () =>
|
|
138
|
+
Object.assign(containerRef.current || {}, {
|
|
139
|
+
blur: () => {
|
|
140
|
+
datePickerInputRef.current?.blur?.();
|
|
141
|
+
timePickerInputRef.current?.blur?.();
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<>
|
|
148
|
+
<Wrapper style={style} testID={testID} {...rest} ref={containerRef}>
|
|
149
|
+
<DatePickerInput
|
|
150
|
+
ref={datePickerInputRef}
|
|
151
|
+
inputMode="start"
|
|
152
|
+
variant="outlined"
|
|
153
|
+
testID={testID ? `${testID}--datepickerinput` : undefined}
|
|
154
|
+
{...datePickerInputProps}
|
|
155
|
+
value={date}
|
|
156
|
+
onChange={onDateChange}
|
|
157
|
+
/>
|
|
158
|
+
<TimePickerField
|
|
159
|
+
ref={timePickerInputRef}
|
|
160
|
+
variant="outlined"
|
|
161
|
+
testID={testID ? `${testID}--timepickerinput` : undefined}
|
|
162
|
+
is24Hour={is24Hour}
|
|
163
|
+
{...timePickerFieldProps}
|
|
164
|
+
time={timeString}
|
|
165
|
+
onTimeChange={onTimeChange}
|
|
166
|
+
/>
|
|
167
|
+
</Wrapper>
|
|
168
|
+
</>
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export default memo(forwardRef(DateTimePicker));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import DateTimePickerDefault from './DateTimePicker';
|
|
3
|
+
|
|
4
|
+
registerMoleculesComponents({
|
|
5
|
+
DateTimePicker: DateTimePickerDefault,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export const DateTimePicker = getRegisteredComponentWithFallback(
|
|
9
|
+
'DateTimePicker',
|
|
10
|
+
DateTimePickerDefault,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export type { Props as DateTimePickerProps } from './DateTimePicker';
|
|
14
|
+
export { dateTimePickerStyles } from './utils';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
|
|
5
|
+
const dateTimePickerStylesDefault = StyleSheet.create({
|
|
6
|
+
container: {},
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
registerComponentsStyles({
|
|
10
|
+
DateTimePicker: dateTimePickerStylesDefault,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const dateTimePickerStyles = getRegisteredMoleculesComponentStyles('DateTimePicker');
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Children, cloneElement, isValidElement, memo, type ReactNode, useMemo } from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import type { IconProps } from '../Icon';
|
|
5
|
+
import { Modal, type ModalProps } from '../Modal';
|
|
6
|
+
import DialogIcon from './DialogIcon';
|
|
7
|
+
import { dialogStyles } from './utils';
|
|
8
|
+
|
|
9
|
+
export type Props = ModalProps & {
|
|
10
|
+
/**
|
|
11
|
+
* Callback that is called when the user dismisses the dialog.
|
|
12
|
+
*/
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Determines Whether the dialog is visible.
|
|
16
|
+
*/
|
|
17
|
+
isOpen: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Content of the `Dialog`.
|
|
20
|
+
*/
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
iconProps?: IconProps;
|
|
23
|
+
style?: StyleProp<ViewStyle>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const emptyObj = {};
|
|
27
|
+
|
|
28
|
+
const Dialog = ({ children, onClose, iconProps, style = emptyObj, ...rest }: Props) => {
|
|
29
|
+
const { containerStyle, childStyle } = useMemo(() => {
|
|
30
|
+
const { spacing, ...restStyle } = dialogStyles.root;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
childStyle: {
|
|
34
|
+
marginTop: spacing,
|
|
35
|
+
},
|
|
36
|
+
containerStyle: [restStyle, style],
|
|
37
|
+
};
|
|
38
|
+
}, [style]);
|
|
39
|
+
|
|
40
|
+
const dialogChildren = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
Children.toArray(children)
|
|
43
|
+
.filter(child => child != null && typeof child !== 'boolean')
|
|
44
|
+
.map((child, i) => {
|
|
45
|
+
if (i === 0 && isValidElement(child) && !iconProps) {
|
|
46
|
+
return cloneElement(child, {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
style: [childStyle, child.props.style],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return child;
|
|
52
|
+
}),
|
|
53
|
+
[childStyle, children, iconProps],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Modal elevation={2} {...rest} onClose={onClose} style={containerStyle}>
|
|
58
|
+
<>
|
|
59
|
+
{iconProps ? <DialogIcon {...iconProps} /> : null}
|
|
60
|
+
{dialogChildren}
|
|
61
|
+
</>
|
|
62
|
+
</Modal>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default memo(Dialog);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
cloneElement,
|
|
4
|
+
type ComponentPropsWithRef,
|
|
5
|
+
type ComponentType,
|
|
6
|
+
forwardRef,
|
|
7
|
+
isValidElement,
|
|
8
|
+
memo,
|
|
9
|
+
type ReactElement,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
useMemo,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import type { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
14
|
+
import { View } from 'react-native';
|
|
15
|
+
|
|
16
|
+
import { dialogActionsStyles } from './utils';
|
|
17
|
+
|
|
18
|
+
export type Props = ViewProps &
|
|
19
|
+
ComponentPropsWithRef<ComponentType<ViewProps>> & {
|
|
20
|
+
/**
|
|
21
|
+
* Content of the `DialogActions`.
|
|
22
|
+
*/
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A component to show a list of actions in a Dialog.
|
|
30
|
+
*
|
|
31
|
+
* <div class="screenshots">
|
|
32
|
+
* <figure>
|
|
33
|
+
* <img class="small" src="screenshots/dialog-actions.png" />
|
|
34
|
+
* </figure>
|
|
35
|
+
* </div>
|
|
36
|
+
*
|
|
37
|
+
* ## Usage
|
|
38
|
+
* ```js
|
|
39
|
+
* import * as React from 'react';
|
|
40
|
+
* import { Button, Dialog, Portal } from 'react-native-paper';
|
|
41
|
+
*
|
|
42
|
+
* const MyComponent = () => {
|
|
43
|
+
* const [visible, setVisible] = React.useState(false);
|
|
44
|
+
*
|
|
45
|
+
* const hideDialog = () => setVisible(false);
|
|
46
|
+
*
|
|
47
|
+
* return (
|
|
48
|
+
* <Portal>
|
|
49
|
+
* <Dialog visible={visible} onDismiss={hideDialog}>
|
|
50
|
+
* <Dialog.Actions>
|
|
51
|
+
* <Button onPress={() => console.log('Cancel')}>Cancel</Button>
|
|
52
|
+
* <Button onPress={() => console.log('Ok')}>Ok</Button>
|
|
53
|
+
* </Dialog.Actions>
|
|
54
|
+
* </Dialog>
|
|
55
|
+
* </Portal>
|
|
56
|
+
* );
|
|
57
|
+
* };
|
|
58
|
+
*
|
|
59
|
+
* export default MyComponent;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
const DialogActions = ({ children, style, ...rest }: Props, ref: any) => {
|
|
63
|
+
const { spacing, containerStyle, childrenProps } = useMemo(() => {
|
|
64
|
+
return {
|
|
65
|
+
spacing: dialogActionsStyles.root.spacing,
|
|
66
|
+
containerStyle: [dialogActionsStyles.container, style],
|
|
67
|
+
childrenProps: (i: number, child: ReactElement) => ({
|
|
68
|
+
style: [
|
|
69
|
+
{
|
|
70
|
+
marginLeft: i === 0 ? 0 : spacing,
|
|
71
|
+
},
|
|
72
|
+
(child.props as ViewProps)?.style,
|
|
73
|
+
],
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
}, [style]);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View {...rest} style={containerStyle} ref={ref}>
|
|
80
|
+
{Children.map(children, (child, i) =>
|
|
81
|
+
isValidElement(child) ? cloneElement(child, childrenProps(i, child)) : child,
|
|
82
|
+
)}
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
DialogActions.displayName = 'Dialog_Actions';
|
|
88
|
+
|
|
89
|
+
export default memo(forwardRef(DialogActions));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentPropsWithRef,
|
|
3
|
+
type ComponentType,
|
|
4
|
+
forwardRef,
|
|
5
|
+
memo,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
|
|
9
|
+
|
|
10
|
+
import { dialogContentStyles } from './utils';
|
|
11
|
+
|
|
12
|
+
export type Props = ViewProps &
|
|
13
|
+
ComponentPropsWithRef<ComponentType<ViewProps>> & {
|
|
14
|
+
/**
|
|
15
|
+
* ContainerComponent prop allows to replace the default container used in DrawerContent - ScrollView
|
|
16
|
+
* */
|
|
17
|
+
ContainerComponent?: ComponentType<any>;
|
|
18
|
+
/**
|
|
19
|
+
* Content of the `DialogContent`.
|
|
20
|
+
*/
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const DialogContent = ({ ContainerComponent, children, style, ...rest }: Props, ref: any) => {
|
|
26
|
+
const Container = ContainerComponent || View;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Container {...rest} style={[dialogContentStyles.root, style]} {...{ ref }}>
|
|
30
|
+
{children}
|
|
31
|
+
</Container>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
DialogContent.displayName = 'Dialog_Content';
|
|
36
|
+
|
|
37
|
+
export default memo(forwardRef(DialogContent));
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
|
+
import { View, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { Icon, type IconProps } from '../Icon';
|
|
5
|
+
import { dialogIconStyles } from './utils';
|
|
6
|
+
|
|
7
|
+
export type Props = IconProps & {
|
|
8
|
+
containerStyle?: ViewStyle;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A component to show an icon in a Dialog.
|
|
13
|
+
*
|
|
14
|
+
* <div class="screenshots">
|
|
15
|
+
* <img class="small" src="screenshots/dialog-icon.png" />
|
|
16
|
+
* </div>
|
|
17
|
+
*
|
|
18
|
+
* ## Usage
|
|
19
|
+
* ```js
|
|
20
|
+
* import * as React from 'react';
|
|
21
|
+
* import { StyleSheet } from 'react-native';
|
|
22
|
+
* import { Paragraph, Dialog, Portal } from 'react-native-paper';
|
|
23
|
+
*
|
|
24
|
+
* const MyComponent = () => {
|
|
25
|
+
* const [visible, setVisible] = React.useState(false);
|
|
26
|
+
*
|
|
27
|
+
* const hideDialog = () => setVisible(false);
|
|
28
|
+
*
|
|
29
|
+
* return (
|
|
30
|
+
* <Portal>
|
|
31
|
+
* <Dialog visible={visible} onDismiss={hideDialog}>
|
|
32
|
+
* <Dialog.Icon icon="alert" />
|
|
33
|
+
* <Dialog.Title style={styles.title}>This is a title</Dialog.Title>
|
|
34
|
+
* <Dialog.Content>
|
|
35
|
+
* <Paragraph>This is simple dialog</Paragraph>
|
|
36
|
+
* </Dialog.Content>
|
|
37
|
+
* </Dialog>
|
|
38
|
+
* </Portal>
|
|
39
|
+
* );
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* const styles = StyleSheet.create({
|
|
43
|
+
* title: {
|
|
44
|
+
* textAlign: 'center',
|
|
45
|
+
* },
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* export default MyComponent;
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
const DialogIcon = ({ containerStyle, color: colorProp, style, size = 24, ...rest }: Props) => {
|
|
52
|
+
const { container, iconColor, iconStyle } = useMemo(() => {
|
|
53
|
+
return {
|
|
54
|
+
container: [dialogIconStyles.container, containerStyle],
|
|
55
|
+
iconColor: colorProp || dialogIconStyles.root.color,
|
|
56
|
+
iconStyle: [dialogIconStyles.root, style],
|
|
57
|
+
};
|
|
58
|
+
}, [colorProp, containerStyle, style]);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View style={container}>
|
|
62
|
+
<Icon {...rest} color={iconColor} style={iconStyle} size={size} />
|
|
63
|
+
</View>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
DialogIcon.displayName = 'Dialog_Icon';
|
|
68
|
+
|
|
69
|
+
export default memo(DialogIcon);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentPropsWithRef,
|
|
3
|
+
type ComponentType,
|
|
4
|
+
forwardRef,
|
|
5
|
+
memo,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { type StyleProp, Text, type TextProps, type TextStyle } from 'react-native';
|
|
9
|
+
|
|
10
|
+
import { dialogTitleStyles } from './utils';
|
|
11
|
+
|
|
12
|
+
export type Props = ComponentPropsWithRef<ComponentType<TextProps>> & {
|
|
13
|
+
/**
|
|
14
|
+
* Title text for the `DialogTitle`.
|
|
15
|
+
*/
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
style?: StyleProp<TextStyle>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A component to show a title in a Dialog.
|
|
22
|
+
*
|
|
23
|
+
* <div class="screenshots">
|
|
24
|
+
* <figure>
|
|
25
|
+
* <img class="small" src="screenshots/dialog-title.png" />
|
|
26
|
+
* </figure>
|
|
27
|
+
* </div>
|
|
28
|
+
*
|
|
29
|
+
* ## Usage
|
|
30
|
+
* ```js
|
|
31
|
+
* import * as React from 'react';
|
|
32
|
+
* import { Paragraph, Dialog, Portal } from 'react-native-paper';
|
|
33
|
+
*
|
|
34
|
+
* const MyComponent = () => {
|
|
35
|
+
* const [visible, setVisible] = React.useState(false);
|
|
36
|
+
*
|
|
37
|
+
* const hideDialog = () => setVisible(false);
|
|
38
|
+
*
|
|
39
|
+
* return (
|
|
40
|
+
* <Portal>
|
|
41
|
+
* <Dialog visible={visible} onDismiss={hideDialog}>
|
|
42
|
+
* <Dialog.Title>This is a title</Dialog.Title>
|
|
43
|
+
* <Dialog.Content>
|
|
44
|
+
* <Paragraph>This is simple dialog</Paragraph>
|
|
45
|
+
* </Dialog.Content>
|
|
46
|
+
* </Dialog>
|
|
47
|
+
* </Portal>
|
|
48
|
+
* );
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* export default MyComponent;
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
const DialogTitle = ({ children, style, ...rest }: Props, ref: any) => {
|
|
55
|
+
return (
|
|
56
|
+
<Text
|
|
57
|
+
{...rest}
|
|
58
|
+
accessibilityRole="header"
|
|
59
|
+
style={[dialogTitleStyles.root, style]}
|
|
60
|
+
ref={ref}>
|
|
61
|
+
{children}
|
|
62
|
+
</Text>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
DialogTitle.displayName = 'Dialog_Title';
|
|
67
|
+
|
|
68
|
+
export default memo(forwardRef(DialogTitle));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getRegisteredComponentWithFallback, registerMoleculesComponents } from '../../core';
|
|
2
|
+
import DialogComponent from './Dialog';
|
|
3
|
+
import DialogActions from './DialogActions';
|
|
4
|
+
import DialogContent from './DialogContent';
|
|
5
|
+
import DialogTitle from './DialogTitle';
|
|
6
|
+
|
|
7
|
+
export const DialogDefault = Object.assign(
|
|
8
|
+
// @component ./Checkbox.tsx
|
|
9
|
+
DialogComponent,
|
|
10
|
+
{
|
|
11
|
+
// @component ./DialogContent.tsx
|
|
12
|
+
Content: DialogContent,
|
|
13
|
+
// @component ./DialogActions.tsx
|
|
14
|
+
Actions: DialogActions,
|
|
15
|
+
// @component ./DialogTitle.tsx
|
|
16
|
+
Title: DialogTitle,
|
|
17
|
+
},
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
registerMoleculesComponents({
|
|
21
|
+
Dialog: DialogDefault,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const Dialog = getRegisteredComponentWithFallback('Dialog', DialogDefault);
|
|
25
|
+
|
|
26
|
+
export type { Props as DialogProps } from './Dialog';
|
|
27
|
+
export type { Props as DialogActionsProps } from './DialogActions';
|
|
28
|
+
export type { Props as DialogContentProps } from './DialogContent';
|
|
29
|
+
export type { Props as DialogTitleProps } from './DialogTitle';
|
|
30
|
+
export {
|
|
31
|
+
dialogActionsStyles,
|
|
32
|
+
dialogContentStyles,
|
|
33
|
+
dialogIconStyles,
|
|
34
|
+
dialogScrollAreaStyles,
|
|
35
|
+
dialogStyles,
|
|
36
|
+
dialogTitleStyles,
|
|
37
|
+
} from './utils';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
|
|
3
|
+
import { getRegisteredMoleculesComponentStyles, registerComponentsStyles } from '../../core';
|
|
4
|
+
|
|
5
|
+
const dialogStylesDefault = StyleSheet.create(theme => ({
|
|
6
|
+
root: {
|
|
7
|
+
spacing: theme.spacings['6'],
|
|
8
|
+
justifyContent: 'flex-start',
|
|
9
|
+
borderRadius: theme.shapes.corner.extraLarge,
|
|
10
|
+
backgroundColor: theme.colors.surface,
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
const dialogTitleStylesDefault = StyleSheet.create(theme => ({
|
|
15
|
+
root: {
|
|
16
|
+
marginHorizontal: theme.spacings['6'],
|
|
17
|
+
marginVertical: theme.spacings['3'],
|
|
18
|
+
color: theme.colors.onSurface,
|
|
19
|
+
...theme.typescale.headlineSmall,
|
|
20
|
+
},
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const dialogScrollAreaStylesDefault = StyleSheet.create(theme => ({
|
|
24
|
+
root: {
|
|
25
|
+
flexGrow: 1,
|
|
26
|
+
flexShrink: 1,
|
|
27
|
+
marginBottom: theme.spacings['6'],
|
|
28
|
+
borderTopWidth: 1,
|
|
29
|
+
borderBottomWidth: 1,
|
|
30
|
+
borderColor: theme.colors.surfaceVariant,
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
const dialogIconStylesDefault = StyleSheet.create(theme => ({
|
|
35
|
+
root: {
|
|
36
|
+
color: theme.colors.secondary,
|
|
37
|
+
paddingTop: theme.spacings['6'],
|
|
38
|
+
},
|
|
39
|
+
container: {
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const dialogContentStylesDefault = StyleSheet.create(theme => ({
|
|
46
|
+
root: {
|
|
47
|
+
paddingBottom: theme.spacings['6'],
|
|
48
|
+
paddingHorizontal: theme.spacings['6'],
|
|
49
|
+
flex: 1,
|
|
50
|
+
},
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
const dialogActionsStylesDefault = StyleSheet.create(theme => ({
|
|
54
|
+
root: {
|
|
55
|
+
...({ spacing: theme.spacings['2'] } as any),
|
|
56
|
+
},
|
|
57
|
+
container: {
|
|
58
|
+
flexDirection: 'row',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'flex-end',
|
|
61
|
+
paddingBottom: theme.spacings['6'],
|
|
62
|
+
paddingHorizontal: theme.spacings['6'],
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
registerComponentsStyles({
|
|
67
|
+
Dialog: dialogStylesDefault,
|
|
68
|
+
Dialog_Title: dialogTitleStylesDefault,
|
|
69
|
+
Dialog_ScrollArea: dialogScrollAreaStylesDefault,
|
|
70
|
+
Dialog_Icon: dialogIconStylesDefault,
|
|
71
|
+
Dialog_Content: dialogContentStylesDefault,
|
|
72
|
+
Dialog_Actions: dialogActionsStylesDefault,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const dialogStyles = getRegisteredMoleculesComponentStyles('Dialog');
|
|
76
|
+
export const dialogTitleStyles = getRegisteredMoleculesComponentStyles('Dialog_Title');
|
|
77
|
+
export const dialogScrollAreaStyles = getRegisteredMoleculesComponentStyles('Dialog_ScrollArea');
|
|
78
|
+
export const dialogIconStyles = getRegisteredMoleculesComponentStyles('Dialog_Icon');
|
|
79
|
+
export const dialogContentStyles = getRegisteredMoleculesComponentStyles('Dialog_Content');
|
|
80
|
+
export const dialogActionsStyles = getRegisteredMoleculesComponentStyles('Dialog_Actions');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { forwardRef, memo, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Accordion, type AccordionProps } from '../../Accordion';
|
|
4
|
+
import { drawerCollapsibleStyles } from './utils';
|
|
5
|
+
|
|
6
|
+
export type Props = AccordionProps & {};
|
|
7
|
+
|
|
8
|
+
const DrawerCollapsible = memo(
|
|
9
|
+
forwardRef(({ style, ...rest }: Props, ref: any) => {
|
|
10
|
+
return (
|
|
11
|
+
<Accordion
|
|
12
|
+
{...rest}
|
|
13
|
+
style={useMemo(() => [drawerCollapsibleStyles.root, style], [style])}
|
|
14
|
+
ref={ref}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
DrawerCollapsible.displayName = 'Drawer_Collapsible';
|
|
21
|
+
|
|
22
|
+
export default DrawerCollapsible;
|