react-native-molecules 0.5.0-beta.3 → 0.5.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Accordion/Accordion.tsx +2 -6
- package/components/Accordion/AccordionItem.tsx +16 -12
- package/components/Accordion/AccordionItemContent.tsx +6 -1
- package/components/Accordion/AccordionItemHeader.tsx +1 -1
- package/components/Accordion/utils.ts +6 -0
- package/components/ActivityIndicator/ActivityIndicator.tsx +6 -15
- package/components/Appbar/AppbarBase.tsx +18 -13
- package/components/Button/Button.tsx +211 -264
- package/components/Button/index.tsx +9 -3
- package/components/Button/types.ts +16 -2
- package/components/Button/utils.ts +230 -208
- package/components/Card/Card.tsx +1 -1
- package/components/Checkbox/Checkbox.tsx +125 -88
- package/components/Checkbox/CheckboxBase.ios.tsx +14 -23
- package/components/Checkbox/CheckboxBase.tsx +21 -137
- package/components/Checkbox/context.tsx +14 -0
- package/components/Checkbox/index.tsx +11 -4
- package/components/Checkbox/types.ts +63 -29
- package/components/Checkbox/utils.ts +25 -108
- package/components/Chip/Chip.tsx +41 -52
- package/components/Chip/utils.ts +3 -7
- package/components/DateField/DateField.tsx +111 -0
- package/components/DateField/index.tsx +6 -0
- package/components/{DatePickerInput/inputUtils.ts → DateField/useDateFieldState.ts} +19 -51
- package/components/DatePicker/DateCalendar.tsx +83 -0
- package/components/DatePicker/DatePickerActions.tsx +73 -0
- package/components/DatePicker/DatePickerModal.tsx +246 -0
- package/components/DatePicker/DatePickerPopover.tsx +79 -0
- package/components/DatePicker/DatePickerProvider.tsx +158 -0
- package/components/DatePicker/DatePickerTrigger.tsx +23 -0
- package/components/DatePicker/context.tsx +83 -0
- package/components/DatePicker/index.tsx +45 -0
- package/components/DatePicker/utils.ts +295 -0
- package/components/DatePickerInline/DatePickerDockedHeader.tsx +117 -0
- package/components/DatePickerInline/DatePickerInline.tsx +17 -16
- package/components/DatePickerInline/DatePickerInlineBase.tsx +11 -5
- package/components/DatePickerInline/DatePickerInlineHeader.tsx +50 -20
- package/components/DatePickerInline/Day.tsx +25 -1
- package/components/DatePickerInline/DayNames.tsx +13 -10
- package/components/DatePickerInline/DayRange.tsx +2 -4
- package/components/DatePickerInline/HeaderItem.tsx +44 -29
- package/components/DatePickerInline/Month.tsx +48 -67
- package/components/DatePickerInline/MonthPicker.tsx +80 -92
- package/components/DatePickerInline/Swiper.native.tsx +21 -4
- package/components/DatePickerInline/Swiper.tsx +169 -14
- package/components/DatePickerInline/SwiperUtils.ts +1 -1
- package/components/DatePickerInline/Week.tsx +6 -1
- package/components/DatePickerInline/YearPicker.tsx +220 -78
- package/components/DatePickerInline/dateUtils.tsx +18 -13
- package/components/DatePickerInline/store.tsx +27 -0
- package/components/DatePickerInline/types.ts +6 -2
- package/components/DatePickerInline/utils.ts +66 -29
- package/components/Divider/Divider.tsx +192 -0
- package/components/Divider/index.tsx +10 -0
- package/components/Drawer/Drawer.tsx +17 -6
- package/components/Drawer/DrawerItemGroup.tsx +3 -7
- package/components/ElementGroup/ElementGroup.tsx +1 -1
- package/components/FilePicker/FilePicker.tsx +48 -78
- package/components/FilePicker/index.tsx +2 -1
- package/components/FilePicker/utils.ts +9 -0
- package/components/HelperText/HelperText.tsx +0 -35
- package/components/Icon/iconFactory.tsx +5 -4
- package/components/Icon/index.tsx +1 -1
- package/components/Icon/types.ts +17 -6
- package/components/IconButton/IconButton.tsx +84 -84
- package/components/IconButton/index.tsx +1 -0
- package/components/IconButton/types.ts +10 -0
- package/components/IconButton/utils.ts +167 -33
- package/components/List/List.tsx +276 -0
- package/components/List/context.tsx +27 -0
- package/components/List/index.ts +8 -0
- package/components/List/types.ts +117 -0
- package/components/List/utils.ts +79 -0
- package/components/LoadingIndicator/LoadingIndicator.tsx +253 -0
- package/components/LoadingIndicator/LoadingIndicator.web.tsx +136 -0
- package/components/LoadingIndicator/index.tsx +13 -0
- package/components/LoadingIndicator/utils.ts +117 -0
- package/components/Menu/Menu.tsx +162 -39
- package/components/Menu/index.tsx +10 -7
- package/components/Menu/utils.ts +21 -70
- package/components/NavigationRail/NavigationRail.tsx +15 -9
- package/components/Popover/Popover.tsx +119 -145
- package/components/Popover/PopoverRoot.tsx +60 -0
- package/components/Popover/common.ts +54 -34
- package/components/Popover/index.ts +12 -1
- package/components/Popover/usePlatformMeasure.native.ts +90 -0
- package/components/Popover/usePlatformMeasure.ts +120 -0
- package/components/Popover/utils.ts +34 -0
- package/components/Portal/Portal.tsx +1 -2
- package/components/Radio/Radio.tsx +188 -0
- package/components/Radio/RadioBase.ios.tsx +69 -0
- package/components/Radio/RadioBase.tsx +136 -0
- package/components/Radio/context.tsx +23 -0
- package/components/Radio/index.tsx +20 -0
- package/components/Radio/types.ts +101 -0
- package/components/Radio/utils.ts +115 -0
- package/components/Rating/Rating.tsx +1 -1
- package/components/Select/Select.tsx +521 -785
- package/components/Select/context.tsx +81 -0
- package/components/Select/index.ts +26 -14
- package/components/Select/types.ts +65 -58
- package/components/Select/utils.ts +126 -0
- package/components/Slot/Slot.tsx +244 -0
- package/components/Slot/compose-refs.tsx +62 -0
- package/components/Slot/index.tsx +8 -0
- package/components/Surface/Surface.android.tsx +32 -7
- package/components/Surface/Surface.ios.tsx +34 -29
- package/components/Surface/Surface.tsx +31 -4
- package/components/Surface/utils.ts +44 -6
- package/components/Switch/Switch.ios.tsx +1 -1
- package/components/Switch/Switch.tsx +10 -3
- package/components/Tabs/TabItem.tsx +35 -58
- package/components/Tabs/TabLabel.tsx +5 -9
- package/components/Tabs/Tabs.tsx +156 -150
- package/components/Tabs/utils.ts +15 -2
- package/components/Text/textFactory.tsx +17 -5
- package/components/TextInput/TextInput.tsx +663 -579
- package/components/TextInput/index.tsx +19 -3
- package/components/TextInput/types.ts +77 -28
- package/components/TextInput/utils.ts +235 -145
- package/components/TimeField/TimeField.tsx +75 -0
- package/components/TimeField/index.tsx +6 -0
- package/components/TimeField/useTimeFieldState.ts +70 -0
- package/components/{TimePickerField/sanitizeTime.ts → TimeField/utils.ts} +77 -10
- package/components/TimePicker/AnalogClock.tsx +1 -1
- package/components/TimePicker/TimeInput.tsx +87 -42
- package/components/TimePicker/TimeInputs.tsx +138 -50
- package/components/TimePicker/TimePicker.tsx +74 -11
- package/components/TimePicker/TimePickerModal.tsx +186 -0
- package/components/TimePicker/context.tsx +17 -0
- package/components/TimePicker/index.tsx +15 -3
- package/components/TimePicker/utils.ts +93 -4
- package/components/Tooltip/Tooltip.tsx +42 -67
- package/components/Tooltip/TooltipContent.tsx +32 -5
- package/components/Tooltip/TooltipTrigger.tsx +20 -20
- package/components/Tooltip/index.tsx +1 -1
- package/components/TouchableRipple/TouchableRipple.native.tsx +83 -16
- package/components/TouchableRipple/TouchableRipple.tsx +150 -102
- package/components/TouchableRipple/rippleFromForegroundColor.ts +21 -0
- package/hocs/index.tsx +1 -1
- package/hocs/withKeyboardAccessibility.tsx +2 -3
- package/hocs/withPortal.tsx +1 -1
- package/hooks/index.tsx +2 -12
- package/hooks/useActionState.tsx +19 -8
- package/hooks/useContrastColor.ts +1 -2
- package/hooks/useFilePicker.tsx +7 -17
- package/hooks/useHandleNumberFormat.tsx +2 -2
- package/hooks/useMediaQuery.tsx +1 -2
- package/package.json +95 -111
- package/shortcuts-manager/ShortcutsManager/ShortcutsManager.tsx +6 -3
- package/shortcuts-manager/ShortcutsManager/utils.tsx +1 -1
- package/shortcuts-manager/useSetScopes/useSetScopes.tsx +1 -1
- package/shortcuts-manager/useShortcut/useShortcut.tsx +1 -1
- package/styles/shadow.ts +2 -1
- package/styles/themes/LightTheme.tsx +1 -1
- package/utils/DocumentPicker/documentPicker.ts +78 -27
- package/utils/DocumentPicker/types.ts +0 -1
- package/utils/extractSubcomponents.ts +89 -0
- package/utils/extractTextStyles.ts +1 -2
- package/utils/formatNumberWithMask/formatNumberWithMask.ts +2 -1
- package/utils/index.ts +0 -3
- package/utils/normalizeToNumberString/normalizeToNumberString.ts +1 -1
- package/components/DatePickerDocked/DatePickerDocked.tsx +0 -30
- package/components/DatePickerDocked/DatePickerDockedHeader.tsx +0 -129
- package/components/DatePickerDocked/index.tsx +0 -17
- package/components/DatePickerDocked/types.ts +0 -11
- package/components/DatePickerDocked/utils.ts +0 -157
- package/components/DatePickerInline/DatePickerContext.tsx +0 -21
- package/components/DatePickerInput/DatePickerInput.tsx +0 -139
- package/components/DatePickerInput/DatePickerInputModal.tsx +0 -48
- package/components/DatePickerInput/DatePickerInputWithoutModal.tsx +0 -77
- package/components/DatePickerInput/DateRangeInput.tsx +0 -88
- package/components/DatePickerInput/index.tsx +0 -10
- package/components/DatePickerInput/types.ts +0 -28
- package/components/DatePickerInput/utils.ts +0 -15
- package/components/DatePickerModal/AnimatedCrossView.tsx +0 -94
- package/components/DatePickerModal/CalendarEdit.tsx +0 -139
- package/components/DatePickerModal/DatePickerModal.tsx +0 -85
- package/components/DatePickerModal/DatePickerModalContent.tsx +0 -155
- package/components/DatePickerModal/DatePickerModalContentHeader.tsx +0 -213
- package/components/DatePickerModal/DatePickerModalHeader.tsx +0 -74
- package/components/DatePickerModal/DatePickerModalHeaderBackground.tsx +0 -13
- package/components/DatePickerModal/index.tsx +0 -16
- package/components/DatePickerModal/types.ts +0 -92
- package/components/DatePickerModal/utils.ts +0 -122
- package/components/DateTimePicker/DateTimePicker.tsx +0 -172
- package/components/DateTimePicker/index.tsx +0 -10
- package/components/DateTimePicker/utils.ts +0 -12
- package/components/HorizontalDivider/HorizontalDivider.tsx +0 -103
- package/components/HorizontalDivider/index.tsx +0 -9
- package/components/ListItem/ListItem.tsx +0 -136
- package/components/ListItem/ListItemDescription.tsx +0 -25
- package/components/ListItem/ListItemTitle.tsx +0 -25
- package/components/ListItem/index.tsx +0 -14
- package/components/ListItem/utils.ts +0 -115
- package/components/Menu/MenuDivider.tsx +0 -13
- package/components/Menu/MenuItem.tsx +0 -128
- package/components/Popover/Popover.native.tsx +0 -185
- package/components/RadioButton/RadioButton.tsx +0 -138
- package/components/RadioButton/RadioButtonAndroid.tsx +0 -188
- package/components/RadioButton/RadioButtonGroup.tsx +0 -98
- package/components/RadioButton/RadioButtonIOS.tsx +0 -106
- package/components/RadioButton/RadioButtonItem.tsx +0 -232
- package/components/RadioButton/index.ts +0 -22
- package/components/RadioButton/utils.ts +0 -165
- package/components/TimePickerField/TimePickerField.tsx +0 -152
- package/components/TimePickerField/index.tsx +0 -10
- package/components/TimePickerField/utils.ts +0 -94
- package/components/TimePickerModal/TimePickerModal.tsx +0 -115
- package/components/TimePickerModal/index.tsx +0 -10
- package/components/TimePickerModal/utils.ts +0 -47
- package/components/VerticalDivider/VerticalDivider.tsx +0 -100
- package/components/VerticalDivider/index.tsx +0 -9
- package/context-bridge/index.tsx +0 -87
- package/fast-context/index.tsx +0 -190
- package/hocs/typedMemo.tsx +0 -5
- package/hooks/useControlledValue.tsx +0 -68
- package/hooks/useLatest.tsx +0 -9
- package/hooks/useMergedRefs.ts +0 -14
- package/hooks/usePrevious.ts +0 -13
- package/hooks/useSearchable.tsx +0 -74
- package/hooks/useSubcomponents.tsx +0 -59
- package/hooks/useToggle.tsx +0 -24
- package/utils/color.ts +0 -22
- package/utils/compare/index.ts +0 -54
- package/utils/lodash.ts +0 -49
- package/utils/repository.ts +0 -53
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { useLatest } from '@react-native-molecules/utils/hooks';
|
|
1
2
|
import { useCallback } from 'react';
|
|
2
3
|
|
|
3
|
-
import { useLatest } from '../../hooks';
|
|
4
4
|
import type { CalendarDate, CalendarDates, ValidRangeType } from './types';
|
|
5
5
|
|
|
6
6
|
export type DisableWeekDaysType = number[];
|
|
@@ -219,21 +219,25 @@ export const generateCalendarGrid = ({
|
|
|
219
219
|
const isFirstWeek = weekGrid === 0;
|
|
220
220
|
const realDayIndex = emptyDays - dayIndex;
|
|
221
221
|
const beforeWeekDay = isFirstWeek && realDayIndex > 0;
|
|
222
|
-
const
|
|
223
|
-
const afterWeekDay =
|
|
224
|
-
|
|
225
|
-
|
|
222
|
+
const rawDayOfMonth = weekGrid * 7 + dayIndex - emptyDays + 1;
|
|
223
|
+
const afterWeekDay = rawDayOfMonth > daysInMonth;
|
|
224
|
+
const outside = beforeWeekDay || afterWeekDay;
|
|
225
|
+
|
|
226
|
+
const day = new Date(year, month, rawDayOfMonth);
|
|
227
|
+
const dayOfMonth = day.getDate();
|
|
228
|
+
const displayYear = day.getFullYear();
|
|
229
|
+
const displayMonth = day.getMonth();
|
|
226
230
|
const isToday = areDatesOnSameDay(day, today);
|
|
227
231
|
|
|
228
232
|
let inRange = false;
|
|
229
233
|
let disabled = isDisabled(day);
|
|
230
234
|
let selected = false;
|
|
231
235
|
|
|
232
|
-
let leftCrop =
|
|
233
|
-
let rightCrop =
|
|
236
|
+
let leftCrop = rawDayOfMonth === 1;
|
|
237
|
+
let rightCrop = rawDayOfMonth === daysInMonth;
|
|
234
238
|
|
|
235
|
-
const isFirstDayOfMonth =
|
|
236
|
-
const isLastDayOfMonth =
|
|
239
|
+
const isFirstDayOfMonth = rawDayOfMonth === 1;
|
|
240
|
+
const isLastDayOfMonth = rawDayOfMonth === daysInMonth;
|
|
237
241
|
|
|
238
242
|
if (mode === 'range') {
|
|
239
243
|
const selectedStartDay = areDatesOnSameDay(day, startDate);
|
|
@@ -267,8 +271,8 @@ export const generateCalendarGrid = ({
|
|
|
267
271
|
const safeDates = dates || [];
|
|
268
272
|
selected = safeDates.some(d => areDatesOnSameDay(day, d));
|
|
269
273
|
|
|
270
|
-
const yesterday = new Date(year, month,
|
|
271
|
-
const tomorrow = new Date(year, month,
|
|
274
|
+
const yesterday = new Date(year, month, rawDayOfMonth - 1);
|
|
275
|
+
const tomorrow = new Date(year, month, rawDayOfMonth + 1);
|
|
272
276
|
|
|
273
277
|
const yesterdaySelected = safeDates.some(d => areDatesOnSameDay(d, yesterday));
|
|
274
278
|
const tomorrowSelected = safeDates.some(d => areDatesOnSameDay(d, tomorrow));
|
|
@@ -316,8 +320,9 @@ export const generateCalendarGrid = ({
|
|
|
316
320
|
return {
|
|
317
321
|
beforeWeekDay,
|
|
318
322
|
afterWeekDay,
|
|
319
|
-
|
|
320
|
-
|
|
323
|
+
outside,
|
|
324
|
+
year: displayYear,
|
|
325
|
+
month: displayMonth,
|
|
321
326
|
dayOfMonth,
|
|
322
327
|
dayIndex,
|
|
323
328
|
mode,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createFastContext } from '@react-native-molecules/utils/fast-context';
|
|
2
|
+
|
|
3
|
+
import { registerPortalContext } from '../Portal/Portal';
|
|
4
|
+
|
|
5
|
+
export type Store = {
|
|
6
|
+
localDate: Date;
|
|
7
|
+
startDateYear: number;
|
|
8
|
+
endDateYear: number;
|
|
9
|
+
pickerType: 'month' | 'year' | undefined;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const defaultValue = {
|
|
13
|
+
localDate: new Date(),
|
|
14
|
+
startDateYear: 1800,
|
|
15
|
+
endDateYear: 2200,
|
|
16
|
+
pickerType: undefined,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const {
|
|
20
|
+
Provider,
|
|
21
|
+
useContext: useDatePickerInlineStore,
|
|
22
|
+
useContextValue: useDatePickerInlineStoreValue,
|
|
23
|
+
useStoreRef: useDatePickerInlineStoreRef,
|
|
24
|
+
Context: DatePickerInlineStoreContext,
|
|
25
|
+
} = createFastContext<Store>();
|
|
26
|
+
|
|
27
|
+
registerPortalContext(DatePickerInlineStoreContext);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MemoExoticComponent } from 'react';
|
|
2
2
|
import type { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
+
import type { DatePickerLocale } from '../DatePicker/context';
|
|
4
5
|
import type { CalendarHeaderProps } from './DatePickerInlineHeader';
|
|
5
6
|
import type { DisableWeekDaysType } from './dateUtils';
|
|
6
7
|
|
|
7
8
|
export interface BaseMonthProps {
|
|
8
|
-
locale:
|
|
9
|
+
locale: DatePickerLocale | undefined;
|
|
9
10
|
scrollMode: 'horizontal' | 'vertical';
|
|
10
11
|
disableWeekDays?: DisableWeekDaysType;
|
|
11
12
|
mode: ModeType;
|
|
@@ -13,6 +14,7 @@ export interface BaseMonthProps {
|
|
|
13
14
|
onPressDate: (date: Date) => any;
|
|
14
15
|
validRange?: ValidRangeType;
|
|
15
16
|
customMonthStyles?: Record<string, any>;
|
|
17
|
+
showOutsideDays?: boolean;
|
|
16
18
|
|
|
17
19
|
// some of these should be required in final implementation
|
|
18
20
|
date?: CalendarDate;
|
|
@@ -46,13 +48,15 @@ export type ValidRangeType = {
|
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
export type BaseDatePickerProps = {
|
|
49
|
-
locale?:
|
|
51
|
+
locale?: DatePickerLocale;
|
|
50
52
|
disableWeekDays?: DisableWeekDaysType;
|
|
51
53
|
validRange?: ValidRangeType;
|
|
52
54
|
startYear?: number;
|
|
53
55
|
endYear?: number;
|
|
54
56
|
HeaderComponent?: MemoExoticComponent<CalendarHeaderProps | any>;
|
|
57
|
+
headerLayout?: 'default' | 'docked';
|
|
55
58
|
monthStyle?: Record<string, any>;
|
|
59
|
+
showOutsideDays?: boolean;
|
|
56
60
|
|
|
57
61
|
// here they are optional but in final implemenation they are required
|
|
58
62
|
date?: CalendarDate;
|
|
@@ -3,11 +3,13 @@ import { StyleSheet } from 'react-native-unistyles';
|
|
|
3
3
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
4
4
|
import { daySize } from './dateUtils';
|
|
5
5
|
|
|
6
|
-
export const dayNamesHeight =
|
|
6
|
+
export const dayNamesHeight = 48;
|
|
7
7
|
|
|
8
8
|
// TODO make it flexible
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
9
|
+
export const cellSize = 48;
|
|
10
|
+
export const cellVerticalPadding = (cellSize - daySize) / 2;
|
|
11
|
+
export const weekMargin = 0;
|
|
12
|
+
export const weekSize = cellSize + weekMargin;
|
|
11
13
|
export const montHeaderHeight = 56;
|
|
12
14
|
export const monthHeaderSingleMarginTop = 4;
|
|
13
15
|
export const monthHeaderSingleMarginBottom = 8 + 22 + 12;
|
|
@@ -33,8 +35,7 @@ const datePickerMonthStylesDefault = StyleSheet.create(theme => ({
|
|
|
33
35
|
backgroundColor: theme.colors.surface,
|
|
34
36
|
},
|
|
35
37
|
monthLabel: {
|
|
36
|
-
...theme.typescale.
|
|
37
|
-
opacity: 0.7,
|
|
38
|
+
...theme.typescale.labelLarge,
|
|
38
39
|
},
|
|
39
40
|
yearButton: {
|
|
40
41
|
alignSelf: 'flex-start',
|
|
@@ -89,6 +90,30 @@ const datePickerYearPickerStylesDefault = StyleSheet.create(theme => ({
|
|
|
89
90
|
},
|
|
90
91
|
}));
|
|
91
92
|
|
|
93
|
+
export const datePickerDayStateLayerStyles = StyleSheet.create(theme => ({
|
|
94
|
+
stateLayer: {
|
|
95
|
+
variants: {
|
|
96
|
+
state: {
|
|
97
|
+
hovered: {
|
|
98
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
99
|
+
},
|
|
100
|
+
todayAndHovered: {
|
|
101
|
+
backgroundColor: theme.colors.stateLayer.hover.primary,
|
|
102
|
+
},
|
|
103
|
+
outsideAndHovered: {
|
|
104
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
105
|
+
},
|
|
106
|
+
selectedAndHovered: {
|
|
107
|
+
backgroundColor: theme.colors.stateLayer.hover.onPrimary,
|
|
108
|
+
},
|
|
109
|
+
inRangeAndHovered: {
|
|
110
|
+
backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
|
|
92
117
|
const datePickerDayStylesDefault = StyleSheet.create(theme => ({
|
|
93
118
|
containerStyle: {
|
|
94
119
|
flex: 1,
|
|
@@ -102,6 +127,9 @@ const datePickerDayStylesDefault = StyleSheet.create(theme => ({
|
|
|
102
127
|
disabled: {
|
|
103
128
|
opacity: 0.3,
|
|
104
129
|
},
|
|
130
|
+
outside: {
|
|
131
|
+
opacity: 0.38,
|
|
132
|
+
},
|
|
105
133
|
},
|
|
106
134
|
},
|
|
107
135
|
},
|
|
@@ -117,7 +145,7 @@ const datePickerDayStylesDefault = StyleSheet.create(theme => ({
|
|
|
117
145
|
variants: {
|
|
118
146
|
state: {
|
|
119
147
|
inRange: {
|
|
120
|
-
backgroundColor:
|
|
148
|
+
backgroundColor: 'transparent',
|
|
121
149
|
},
|
|
122
150
|
},
|
|
123
151
|
},
|
|
@@ -140,12 +168,13 @@ const datePickerDayStylesDefault = StyleSheet.create(theme => ({
|
|
|
140
168
|
},
|
|
141
169
|
|
|
142
170
|
inRange: {
|
|
143
|
-
|
|
171
|
+
borderWidth: 0,
|
|
172
|
+
borderColor: 'transparent',
|
|
144
173
|
button: {
|
|
145
|
-
backgroundColor:
|
|
174
|
+
backgroundColor: 'transparent',
|
|
146
175
|
},
|
|
147
176
|
today: {
|
|
148
|
-
borderColor:
|
|
177
|
+
borderColor: 'transparent',
|
|
149
178
|
},
|
|
150
179
|
},
|
|
151
180
|
},
|
|
@@ -156,15 +185,17 @@ const datePickerDayStylesDefault = StyleSheet.create(theme => ({
|
|
|
156
185
|
variants: {
|
|
157
186
|
state: {
|
|
158
187
|
inRange: {
|
|
159
|
-
|
|
188
|
+
borderWidth: 0,
|
|
189
|
+
borderColor: 'transparent',
|
|
160
190
|
button: {
|
|
161
|
-
backgroundColor:
|
|
191
|
+
backgroundColor: 'transparent',
|
|
162
192
|
},
|
|
163
193
|
},
|
|
164
194
|
},
|
|
165
195
|
},
|
|
166
196
|
},
|
|
167
197
|
text: {
|
|
198
|
+
...theme.typescale.bodyLarge,
|
|
168
199
|
variants: {
|
|
169
200
|
state: {
|
|
170
201
|
selected: {
|
|
@@ -175,16 +206,16 @@ const datePickerDayStylesDefault = StyleSheet.create(theme => ({
|
|
|
175
206
|
},
|
|
176
207
|
|
|
177
208
|
inRange: {
|
|
178
|
-
color: theme.colors.
|
|
209
|
+
color: theme.colors.onSecondaryContainer,
|
|
179
210
|
|
|
180
211
|
day: {
|
|
181
|
-
borderColor:
|
|
212
|
+
borderColor: 'transparent',
|
|
182
213
|
},
|
|
183
214
|
button: {
|
|
184
|
-
backgroundColor:
|
|
215
|
+
backgroundColor: 'transparent',
|
|
185
216
|
},
|
|
186
217
|
today: {
|
|
187
|
-
borderColor:
|
|
218
|
+
borderColor: 'transparent',
|
|
188
219
|
},
|
|
189
220
|
},
|
|
190
221
|
},
|
|
@@ -205,7 +236,7 @@ const datePickerDayEmptyStylesDefault = StyleSheet.create({
|
|
|
205
236
|
const datePickerWeekStylesDefault = StyleSheet.create({
|
|
206
237
|
root: {
|
|
207
238
|
flexDirection: 'row',
|
|
208
|
-
height:
|
|
239
|
+
height: cellSize,
|
|
209
240
|
},
|
|
210
241
|
});
|
|
211
242
|
|
|
@@ -214,7 +245,7 @@ const datePickerHeaderStylesDefault = StyleSheet.create(theme => ({
|
|
|
214
245
|
flexDirection: 'row',
|
|
215
246
|
alignItems: 'center',
|
|
216
247
|
justifyContent: 'space-between',
|
|
217
|
-
|
|
248
|
+
padding: theme.spacings['2'],
|
|
218
249
|
},
|
|
219
250
|
buttonContainer: {
|
|
220
251
|
height: 56,
|
|
@@ -226,8 +257,7 @@ const datePickerHeaderStylesDefault = StyleSheet.create(theme => ({
|
|
|
226
257
|
buttonWrapper: {},
|
|
227
258
|
spacer: { flex: 1 },
|
|
228
259
|
yearLabelStyle: {
|
|
229
|
-
...theme.typescale.
|
|
230
|
-
opacity: 0.7,
|
|
260
|
+
...theme.typescale.labelLarge,
|
|
231
261
|
},
|
|
232
262
|
yearButtonStyle: {
|
|
233
263
|
alignSelf: 'flex-start',
|
|
@@ -249,24 +279,25 @@ const dateDayNameStylesDefault = StyleSheet.create(theme => ({
|
|
|
249
279
|
alignItems: 'center',
|
|
250
280
|
backgroundColor: theme.colors.surface,
|
|
251
281
|
},
|
|
252
|
-
dayName: { flex: 1, alignItems: 'center' },
|
|
282
|
+
dayName: { flex: 1, alignItems: 'center', ...theme.typescale.bodyLarge },
|
|
253
283
|
dayNameLabel: {
|
|
254
|
-
|
|
255
|
-
...theme.typescale.bodyMedium,
|
|
284
|
+
...theme.typescale.bodyLarge,
|
|
256
285
|
},
|
|
257
286
|
}));
|
|
258
287
|
|
|
259
288
|
const datePickerDayRangeStylesDefault = StyleSheet.create(theme => ({
|
|
260
289
|
container: {
|
|
290
|
+
position: 'absolute',
|
|
291
|
+
top: cellVerticalPadding,
|
|
292
|
+
bottom: cellVerticalPadding,
|
|
293
|
+
left: 0,
|
|
294
|
+
right: 0,
|
|
261
295
|
flexDirection: 'row',
|
|
262
296
|
|
|
263
297
|
variants: {
|
|
264
298
|
state: {
|
|
265
|
-
bothWays: {
|
|
266
|
-
borderRadius: daySize / 2,
|
|
267
|
-
},
|
|
268
299
|
inRange: {
|
|
269
|
-
backgroundColor: theme.colors.
|
|
300
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
270
301
|
},
|
|
271
302
|
isCrop: {
|
|
272
303
|
backgroundColor: undefined,
|
|
@@ -280,7 +311,7 @@ const datePickerDayRangeStylesDefault = StyleSheet.create(theme => ({
|
|
|
280
311
|
variants: {
|
|
281
312
|
state: {
|
|
282
313
|
isRightCrop: {
|
|
283
|
-
backgroundColor: theme.colors.
|
|
314
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
284
315
|
},
|
|
285
316
|
},
|
|
286
317
|
},
|
|
@@ -291,13 +322,13 @@ const datePickerDayRangeStylesDefault = StyleSheet.create(theme => ({
|
|
|
291
322
|
variants: {
|
|
292
323
|
state: {
|
|
293
324
|
isLeftCrop: {
|
|
294
|
-
backgroundColor: theme.colors.
|
|
325
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
295
326
|
},
|
|
296
327
|
},
|
|
297
328
|
},
|
|
298
329
|
},
|
|
299
330
|
centerCrop: {
|
|
300
|
-
backgroundColor: theme.colors.
|
|
331
|
+
backgroundColor: theme.colors.secondaryContainer,
|
|
301
332
|
minWidth: daySize,
|
|
302
333
|
minHeight: daySize,
|
|
303
334
|
|
|
@@ -317,7 +348,13 @@ const datePickerDayRangeStylesDefault = StyleSheet.create(theme => ({
|
|
|
317
348
|
}));
|
|
318
349
|
|
|
319
350
|
const datePickerYearItemStylesDefault = StyleSheet.create(theme => ({
|
|
351
|
+
content: {
|
|
352
|
+
alignItems: 'center',
|
|
353
|
+
},
|
|
320
354
|
yearButton: {
|
|
355
|
+
borderRadius: theme.shapes.corner.full,
|
|
356
|
+
paddingHorizontal: 0,
|
|
357
|
+
overflow: 'hidden',
|
|
321
358
|
variants: {
|
|
322
359
|
state: {
|
|
323
360
|
selected: {
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
import { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
|
|
5
|
+
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
6
|
+
|
|
7
|
+
export type DividerProps = Omit<ViewProps, 'children'> & {
|
|
8
|
+
/**
|
|
9
|
+
* Line orientation. Defaults to horizontal.
|
|
10
|
+
*/
|
|
11
|
+
mode?: 'horizontal' | 'vertical';
|
|
12
|
+
/**
|
|
13
|
+
* Left inset when `mode` is `"horizontal"`.
|
|
14
|
+
*/
|
|
15
|
+
leftInset?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Right inset when `mode` is `"horizontal"`.
|
|
18
|
+
*/
|
|
19
|
+
rightInset?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Top inset when `mode` is `"vertical"`.
|
|
22
|
+
*/
|
|
23
|
+
topInset?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Bottom inset when `mode` is `"vertical"`.
|
|
26
|
+
*/
|
|
27
|
+
bottomInset?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the divider stroke should use the bold thickness.
|
|
30
|
+
*/
|
|
31
|
+
bold?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Margin added perpendicular to the divider line (`marginVertical` for horizontal,
|
|
34
|
+
* `marginHorizontal` for vertical).
|
|
35
|
+
*/
|
|
36
|
+
spacing?: number;
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type Props = DividerProps;
|
|
41
|
+
|
|
42
|
+
const DividerHorizontalImpl = memo(function DividerHorizontalImpl({
|
|
43
|
+
leftInset = 0,
|
|
44
|
+
rightInset = 0,
|
|
45
|
+
style,
|
|
46
|
+
bold = false,
|
|
47
|
+
spacing = 8,
|
|
48
|
+
...rest
|
|
49
|
+
}: Omit<DividerProps, 'mode' | 'topInset' | 'bottomInset'>) {
|
|
50
|
+
horizontalDividerStyles.useVariants({
|
|
51
|
+
isBold: bold,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<View
|
|
56
|
+
{...rest}
|
|
57
|
+
style={
|
|
58
|
+
[
|
|
59
|
+
horizontalDividerStyles.root,
|
|
60
|
+
leftInset ? { marginLeft: leftInset } : undefined,
|
|
61
|
+
rightInset ? { marginRight: rightInset } : undefined,
|
|
62
|
+
spacing ? { marginVertical: spacing } : undefined,
|
|
63
|
+
style,
|
|
64
|
+
] as StyleProp<ViewStyle>
|
|
65
|
+
}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const DividerVerticalImpl = memo(function DividerVerticalImpl({
|
|
71
|
+
topInset = 0,
|
|
72
|
+
bottomInset = 0,
|
|
73
|
+
spacing = 0,
|
|
74
|
+
style,
|
|
75
|
+
bold = false,
|
|
76
|
+
...rest
|
|
77
|
+
}: Omit<DividerProps, 'mode' | 'leftInset' | 'rightInset'>) {
|
|
78
|
+
verticalDividerStyles.useVariants({
|
|
79
|
+
isBold: bold,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View
|
|
84
|
+
{...rest}
|
|
85
|
+
style={
|
|
86
|
+
[
|
|
87
|
+
verticalDividerStyles.root,
|
|
88
|
+
style,
|
|
89
|
+
topInset ? { marginTop: topInset } : undefined,
|
|
90
|
+
bottomInset ? { marginBottom: bottomInset } : undefined,
|
|
91
|
+
spacing ? { marginHorizontal: spacing } : undefined,
|
|
92
|
+
] as StyleProp<ViewStyle>
|
|
93
|
+
}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
function DividerRoot(props: DividerProps) {
|
|
99
|
+
const mode = props.mode ?? 'horizontal';
|
|
100
|
+
|
|
101
|
+
if (mode === 'vertical') {
|
|
102
|
+
const {
|
|
103
|
+
mode: _m,
|
|
104
|
+
leftInset: _l,
|
|
105
|
+
rightInset: _r,
|
|
106
|
+
topInset,
|
|
107
|
+
bottomInset,
|
|
108
|
+
bold,
|
|
109
|
+
spacing,
|
|
110
|
+
style,
|
|
111
|
+
...viewRest
|
|
112
|
+
} = props;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<DividerVerticalImpl
|
|
116
|
+
{...viewRest}
|
|
117
|
+
topInset={topInset}
|
|
118
|
+
bottomInset={bottomInset}
|
|
119
|
+
bold={bold}
|
|
120
|
+
spacing={spacing}
|
|
121
|
+
style={style}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const {
|
|
127
|
+
mode: _m,
|
|
128
|
+
topInset: _t,
|
|
129
|
+
bottomInset: _b,
|
|
130
|
+
leftInset,
|
|
131
|
+
rightInset,
|
|
132
|
+
bold,
|
|
133
|
+
spacing,
|
|
134
|
+
style,
|
|
135
|
+
...viewRest
|
|
136
|
+
} = props;
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<DividerHorizontalImpl
|
|
140
|
+
{...viewRest}
|
|
141
|
+
leftInset={leftInset}
|
|
142
|
+
rightInset={rightInset}
|
|
143
|
+
bold={bold}
|
|
144
|
+
spacing={spacing}
|
|
145
|
+
style={style}
|
|
146
|
+
/>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export const Divider = memo(DividerRoot);
|
|
151
|
+
|
|
152
|
+
export const horizontalDividerStylesDefault = StyleSheet.create(theme => ({
|
|
153
|
+
root: {
|
|
154
|
+
height: StyleSheet.hairlineWidth,
|
|
155
|
+
background: theme.colors.outlineVariant,
|
|
156
|
+
|
|
157
|
+
variants: {
|
|
158
|
+
isBold: {
|
|
159
|
+
true: {
|
|
160
|
+
height: 1,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
export const verticalDividerStylesDefault = StyleSheet.create(theme => ({
|
|
168
|
+
root: {
|
|
169
|
+
width: StyleSheet.hairlineWidth,
|
|
170
|
+
background: theme.colors.outlineVariant,
|
|
171
|
+
|
|
172
|
+
variants: {
|
|
173
|
+
isBold: {
|
|
174
|
+
true: {
|
|
175
|
+
width: 1,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
}));
|
|
181
|
+
|
|
182
|
+
export const horizontalDividerStyles = getRegisteredComponentStylesWithFallback(
|
|
183
|
+
'HorizontalDivider',
|
|
184
|
+
horizontalDividerStylesDefault,
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
export const verticalDividerStyles = getRegisteredComponentStylesWithFallback(
|
|
188
|
+
'VerticalDivider',
|
|
189
|
+
verticalDividerStylesDefault,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
export default Divider;
|
|
@@ -3,25 +3,36 @@ import { View, type ViewProps } from 'react-native';
|
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
|
|
5
5
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
6
|
-
import {
|
|
6
|
+
import { extractSubcomponents } from '../../utils/extractSubcomponents';
|
|
7
7
|
|
|
8
8
|
export type Props = Omit<ViewProps, 'children'> & {
|
|
9
9
|
children: ReactElement | ReactElement[];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
const allowedChildren = [
|
|
12
|
+
const allowedChildren = [
|
|
13
|
+
{ name: 'Drawer_Footer', allowMultiple: false },
|
|
14
|
+
{ name: 'Drawer_Header', allowMultiple: false },
|
|
15
|
+
{ name: 'Drawer_Content', allowMultiple: false },
|
|
16
|
+
];
|
|
13
17
|
|
|
14
18
|
const Drawer = ({ style, children, ...rest }: Props) => {
|
|
15
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
Drawer_Header,
|
|
21
|
+
Drawer_Footer,
|
|
22
|
+
Drawer_Content,
|
|
23
|
+
rest: restChildren,
|
|
24
|
+
} = extractSubcomponents({
|
|
16
25
|
children,
|
|
17
26
|
allowedChildren,
|
|
27
|
+
includeRest: true,
|
|
18
28
|
});
|
|
19
29
|
|
|
20
30
|
return (
|
|
21
31
|
<View style={[drawerStyles.root, style]} {...rest}>
|
|
22
|
-
{Drawer_Header
|
|
23
|
-
{Drawer_Content
|
|
24
|
-
{Drawer_Footer
|
|
32
|
+
{Drawer_Header}
|
|
33
|
+
{Drawer_Content}
|
|
34
|
+
{Drawer_Footer}
|
|
35
|
+
{restChildren}
|
|
25
36
|
</View>
|
|
26
37
|
);
|
|
27
38
|
};
|
|
@@ -3,13 +3,13 @@ import { type TextProps, View, type ViewProps } from 'react-native';
|
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
4
|
|
|
5
5
|
import { getRegisteredComponentStylesWithFallback } from '../../core';
|
|
6
|
-
import {
|
|
6
|
+
import { Divider, type DividerProps } from '../Divider';
|
|
7
7
|
import { Text } from '../Text';
|
|
8
8
|
|
|
9
9
|
export type Props = ViewProps & {
|
|
10
10
|
title?: ReactNode;
|
|
11
11
|
showDivider?: boolean;
|
|
12
|
-
dividerProps?:
|
|
12
|
+
dividerProps?: Omit<DividerProps, 'mode'>;
|
|
13
13
|
titleProps?: TextProps;
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -45,11 +45,7 @@ const DrawerItemGroup = memo(
|
|
|
45
45
|
)}
|
|
46
46
|
</>
|
|
47
47
|
{children}
|
|
48
|
-
<>
|
|
49
|
-
{showDivider && (
|
|
50
|
-
<HorizontalDivider style={dividerStyle} {...dividerRestProps} />
|
|
51
|
-
)}
|
|
52
|
-
</>
|
|
48
|
+
<>{showDivider && <Divider style={dividerStyle} {...dividerRestProps} />}</>
|
|
53
49
|
</View>
|
|
54
50
|
);
|
|
55
51
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { isNil } from '@react-native-molecules/utils/helpers/lodash';
|
|
1
2
|
import { Children, cloneElement, forwardRef, memo, type ReactElement, useMemo } from 'react';
|
|
2
3
|
import { View, type ViewProps, type ViewStyle } from 'react-native';
|
|
3
4
|
|
|
4
5
|
import { extractPropertiesFromStyles } from '../../utils/extractPropertiesFromStyles';
|
|
5
|
-
import { isNil } from '../../utils/lodash';
|
|
6
6
|
import { elementGroupStyles } from './utils';
|
|
7
7
|
|
|
8
8
|
export enum Orientation {
|