react-native-paper-dates 0.24.0 → 0.24.1
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/lib/commonjs/Date/AnimatedCrossView.js +2 -2
- package/lib/commonjs/Date/AnimatedCrossView.js.map +1 -1
- package/lib/commonjs/Date/AutoSizer.js +24 -11
- package/lib/commonjs/Date/AutoSizer.js.map +1 -1
- package/lib/commonjs/Date/Calendar.js +5 -3
- package/lib/commonjs/Date/Calendar.js.map +1 -1
- package/lib/commonjs/Date/CalendarEdit.js +70 -61
- package/lib/commonjs/Date/CalendarEdit.js.map +1 -1
- package/lib/commonjs/Date/CalendarHeader.js +30 -15
- package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModal.js +5 -11
- package/lib/commonjs/Date/DatePickerModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContent.js +48 -34
- package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContentHeader.js +12 -5
- package/lib/commonjs/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeader.js +40 -40
- package/lib/commonjs/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js +22 -4
- package/lib/commonjs/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/commonjs/Date/Month.js +44 -30
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Date/Swiper.js +31 -21
- package/lib/commonjs/Date/Swiper.js.map +1 -1
- package/lib/commonjs/Date/Swiper.native.js +37 -21
- package/lib/commonjs/Date/Swiper.native.js.map +1 -1
- package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
- package/lib/commonjs/Date/YearPicker.js +3 -1
- package/lib/commonjs/Date/YearPicker.js.map +1 -1
- package/lib/commonjs/Date/weekdayColumns.js +60 -0
- package/lib/commonjs/Date/weekdayColumns.js.map +1 -0
- package/lib/commonjs/shared/styles.js +3 -0
- package/lib/commonjs/shared/styles.js.map +1 -1
- package/lib/commonjs/shared/utils.js +9 -0
- package/lib/commonjs/shared/utils.js.map +1 -1
- package/lib/module/Date/AnimatedCrossView.js +2 -2
- package/lib/module/Date/AnimatedCrossView.js.map +1 -1
- package/lib/module/Date/AutoSizer.js +25 -12
- package/lib/module/Date/AutoSizer.js.map +1 -1
- package/lib/module/Date/Calendar.js +5 -3
- package/lib/module/Date/Calendar.js.map +1 -1
- package/lib/module/Date/CalendarEdit.js +70 -61
- package/lib/module/Date/CalendarEdit.js.map +1 -1
- package/lib/module/Date/CalendarHeader.js +31 -16
- package/lib/module/Date/CalendarHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModal.js +7 -13
- package/lib/module/Date/DatePickerModal.js.map +1 -1
- package/lib/module/Date/DatePickerModalContent.js +48 -34
- package/lib/module/Date/DatePickerModalContent.js.map +1 -1
- package/lib/module/Date/DatePickerModalContentHeader.js +12 -5
- package/lib/module/Date/DatePickerModalContentHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeader.js +43 -43
- package/lib/module/Date/DatePickerModalHeader.js.map +1 -1
- package/lib/module/Date/DatePickerModalHeaderBackground.js +24 -6
- package/lib/module/Date/DatePickerModalHeaderBackground.js.map +1 -1
- package/lib/module/Date/Month.js +46 -32
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Date/Swiper.js +32 -22
- package/lib/module/Date/Swiper.js.map +1 -1
- package/lib/module/Date/Swiper.native.js +38 -22
- package/lib/module/Date/Swiper.native.js.map +1 -1
- package/lib/module/Date/SwiperUtils.js.map +1 -1
- package/lib/module/Date/YearPicker.js +4 -2
- package/lib/module/Date/YearPicker.js.map +1 -1
- package/lib/module/Date/weekdayColumns.js +51 -0
- package/lib/module/Date/weekdayColumns.js.map +1 -0
- package/lib/module/shared/styles.js +3 -0
- package/lib/module/shared/styles.js.map +1 -1
- package/lib/module/shared/utils.js +8 -0
- package/lib/module/shared/utils.js.map +1 -1
- package/lib/typescript/Date/AnimatedCrossView.d.ts.map +1 -1
- package/lib/typescript/Date/AutoSizer.d.ts.map +1 -1
- package/lib/typescript/Date/Calendar.d.ts.map +1 -1
- package/lib/typescript/Date/CalendarEdit.d.ts +3 -1
- package/lib/typescript/Date/CalendarEdit.d.ts.map +1 -1
- package/lib/typescript/Date/CalendarHeader.d.ts +5 -1
- package/lib/typescript/Date/CalendarHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModal.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContentHeader.d.ts +2 -0
- package/lib/typescript/Date/DatePickerModalContentHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalHeader.d.ts +2 -0
- package/lib/typescript/Date/DatePickerModalHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts +3 -1
- package/lib/typescript/Date/DatePickerModalHeaderBackground.d.ts.map +1 -1
- package/lib/typescript/Date/Month.d.ts.map +1 -1
- package/lib/typescript/Date/Swiper.d.ts.map +1 -1
- package/lib/typescript/Date/Swiper.native.d.ts.map +1 -1
- package/lib/typescript/Date/SwiperUtils.d.ts +1 -0
- package/lib/typescript/Date/SwiperUtils.d.ts.map +1 -1
- package/lib/typescript/Date/YearPicker.d.ts.map +1 -1
- package/lib/typescript/Date/weekdayColumns.d.ts +9 -0
- package/lib/typescript/Date/weekdayColumns.d.ts.map +1 -0
- package/lib/typescript/shared/styles.d.ts +3 -0
- package/lib/typescript/shared/styles.d.ts.map +1 -1
- package/lib/typescript/shared/utils.d.ts +1 -0
- package/lib/typescript/shared/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Date/AnimatedCrossView.tsx +2 -1
- package/src/Date/AutoSizer.tsx +33 -9
- package/src/Date/Calendar.tsx +5 -4
- package/src/Date/CalendarEdit.tsx +60 -51
- package/src/Date/CalendarHeader.tsx +38 -6
- package/src/Date/DatePickerModal.tsx +5 -13
- package/src/Date/DatePickerModalContent.tsx +55 -40
- package/src/Date/DatePickerModalContentHeader.tsx +14 -3
- package/src/Date/DatePickerModalHeader.tsx +47 -50
- package/src/Date/DatePickerModalHeaderBackground.tsx +30 -8
- package/src/Date/Month.tsx +73 -44
- package/src/Date/Swiper.native.tsx +70 -43
- package/src/Date/Swiper.tsx +44 -19
- package/src/Date/SwiperUtils.ts +1 -0
- package/src/Date/YearPicker.tsx +14 -2
- package/src/Date/weekdayColumns.ts +75 -0
- package/src/shared/styles.tsx +3 -0
- package/src/shared/utils.ts +6 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { I18nManager, type DimensionValue, type ViewStyle } from 'react-native'
|
|
2
|
+
import { showWeekDay, type DisableWeekDaysType } from './dateUtils'
|
|
3
|
+
|
|
4
|
+
const compactTextButtonPadding = 8
|
|
5
|
+
const iconButtonPadding = 8
|
|
6
|
+
const iconButtonSize = 24 + 2 * iconButtonPadding
|
|
7
|
+
const letterHalfWidth = 4
|
|
8
|
+
|
|
9
|
+
export function alignIconToFirstWeekday(
|
|
10
|
+
disableWeekDays?: DisableWeekDaysType
|
|
11
|
+
): ViewStyle {
|
|
12
|
+
return alignToFirstColumn(
|
|
13
|
+
disableWeekDays,
|
|
14
|
+
letterHalfWidth + iconButtonPadding
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function alignTextToFirstWeekday(
|
|
19
|
+
disableWeekDays?: DisableWeekDaysType
|
|
20
|
+
): ViewStyle {
|
|
21
|
+
return alignToFirstColumn(disableWeekDays, letterHalfWidth)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function alignTextToLastWeekday(
|
|
25
|
+
disableWeekDays?: DisableWeekDaysType
|
|
26
|
+
): ViewStyle {
|
|
27
|
+
return alignToLastColumn(
|
|
28
|
+
disableWeekDays,
|
|
29
|
+
letterHalfWidth + compactTextButtonPadding
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function alignToFirstColumn(
|
|
34
|
+
disableWeekDays: DisableWeekDaysType | undefined,
|
|
35
|
+
nudge: number
|
|
36
|
+
): ViewStyle {
|
|
37
|
+
return {
|
|
38
|
+
marginStart: columnCentreInset(disableWeekDays),
|
|
39
|
+
transform: [{ translateX: I18nManager.isRTL ? nudge : -nudge }],
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function alignToLastColumn(
|
|
44
|
+
disableWeekDays: DisableWeekDaysType | undefined,
|
|
45
|
+
nudge: number
|
|
46
|
+
): ViewStyle {
|
|
47
|
+
return {
|
|
48
|
+
marginEnd: columnCentreInset(disableWeekDays),
|
|
49
|
+
transform: [{ translateX: I18nManager.isRTL ? -nudge : nudge }],
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function centerIconOnLastWeekday(
|
|
54
|
+
disableWeekDays?: DisableWeekDaysType
|
|
55
|
+
): ViewStyle {
|
|
56
|
+
return alignToLastColumn(disableWeekDays, iconButtonSize / 2)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function columnCentreInset(
|
|
60
|
+
disableWeekDays: DisableWeekDaysType | undefined
|
|
61
|
+
): DimensionValue {
|
|
62
|
+
const visibleColumns = [0, 1, 2, 3, 4, 5, 6].filter((dayIndex) =>
|
|
63
|
+
showWeekDay(dayIndex, disableWeekDays)
|
|
64
|
+
).length
|
|
65
|
+
return `${50 / (visibleColumns || 7)}%`
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function weekdaySpan(disableWeekDays?: DisableWeekDaysType): ViewStyle {
|
|
69
|
+
const inset = columnCentreInset(disableWeekDays)
|
|
70
|
+
return { marginStart: inset, marginEnd: inset }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const weekdaySpanOvershoot: ViewStyle = {
|
|
74
|
+
marginHorizontal: -letterHalfWidth,
|
|
75
|
+
}
|
package/src/shared/styles.tsx
CHANGED
package/src/shared/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useRef } from 'react'
|
|
2
|
+
import { useWindowDimensions } from 'react-native'
|
|
2
3
|
import { DefaultTheme, MD3DarkTheme, useTheme } from 'react-native-paper'
|
|
3
4
|
import Color from 'color'
|
|
4
5
|
|
|
@@ -24,6 +25,11 @@ export function useLatest<T>(value: T) {
|
|
|
24
25
|
return ref
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
export function useIsLargeScreen() {
|
|
29
|
+
const { width, height } = useWindowDimensions()
|
|
30
|
+
return width > 650 && height > 650
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
export function useHeaderBackgroundColor() {
|
|
28
34
|
const theme = useTheme()
|
|
29
35
|
return theme.colors.elevation.level3
|