react-native-paper-dates 0.22.8 → 0.22.10
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/Calendar.js +7 -3
- package/lib/commonjs/Date/Calendar.js.map +1 -1
- package/lib/commonjs/Date/CalendarHeader.js +4 -2
- package/lib/commonjs/Date/CalendarHeader.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInput.js +4 -2
- package/lib/commonjs/Date/DatePickerInput.js.map +1 -1
- package/lib/commonjs/Date/DatePickerInputWithoutModal.js +3 -1
- package/lib/commonjs/Date/DatePickerInputWithoutModal.js.map +1 -1
- package/lib/commonjs/Date/DatePickerModalContent.js +4 -2
- package/lib/commonjs/Date/DatePickerModalContent.js.map +1 -1
- package/lib/commonjs/Date/DayNames.js +8 -5
- package/lib/commonjs/Date/DayNames.js.map +1 -1
- package/lib/commonjs/Date/DayRange.js +1 -4
- package/lib/commonjs/Date/DayRange.js.map +1 -1
- package/lib/commonjs/Date/Month.js +18 -16
- package/lib/commonjs/Date/Month.js.map +1 -1
- package/lib/commonjs/Date/Swiper.js +11 -8
- package/lib/commonjs/Date/Swiper.js.map +1 -1
- package/lib/commonjs/Date/Swiper.native.js +8 -7
- package/lib/commonjs/Date/Swiper.native.js.map +1 -1
- package/lib/commonjs/Date/SwiperUtils.js.map +1 -1
- package/lib/commonjs/Date/dateUtils.js +13 -6
- package/lib/commonjs/Date/dateUtils.js.map +1 -1
- package/lib/module/Date/Calendar.js +7 -3
- package/lib/module/Date/Calendar.js.map +1 -1
- package/lib/module/Date/CalendarHeader.js +4 -2
- package/lib/module/Date/CalendarHeader.js.map +1 -1
- package/lib/module/Date/DatePickerInput.js +4 -2
- package/lib/module/Date/DatePickerInput.js.map +1 -1
- package/lib/module/Date/DatePickerInputWithoutModal.js +3 -1
- package/lib/module/Date/DatePickerInputWithoutModal.js.map +1 -1
- package/lib/module/Date/DatePickerModalContent.js +4 -2
- package/lib/module/Date/DatePickerModalContent.js.map +1 -1
- package/lib/module/Date/DayNames.js +8 -5
- package/lib/module/Date/DayNames.js.map +1 -1
- package/lib/module/Date/DayRange.js +1 -4
- package/lib/module/Date/DayRange.js.map +1 -1
- package/lib/module/Date/Month.js +18 -16
- package/lib/module/Date/Month.js.map +1 -1
- package/lib/module/Date/Swiper.js +11 -8
- package/lib/module/Date/Swiper.js.map +1 -1
- package/lib/module/Date/Swiper.native.js +8 -7
- package/lib/module/Date/Swiper.native.js.map +1 -1
- package/lib/module/Date/SwiperUtils.js.map +1 -1
- package/lib/module/Date/dateUtils.js +13 -6
- package/lib/module/Date/dateUtils.js.map +1 -1
- package/lib/typescript/Date/Calendar.d.ts +1 -0
- package/lib/typescript/Date/Calendar.d.ts.map +1 -1
- package/lib/typescript/Date/CalendarHeader.d.ts +2 -1
- package/lib/typescript/Date/CalendarHeader.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerInput.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerInput.shared.d.ts +1 -0
- package/lib/typescript/Date/DatePickerInput.shared.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts +2 -0
- package/lib/typescript/Date/DatePickerInputWithoutModal.d.ts.map +1 -1
- package/lib/typescript/Date/DatePickerModalContent.d.ts.map +1 -1
- package/lib/typescript/Date/DayNames.d.ts +2 -1
- package/lib/typescript/Date/DayNames.d.ts.map +1 -1
- package/lib/typescript/Date/DayRange.d.ts.map +1 -1
- package/lib/typescript/Date/Month.d.ts +4 -3
- package/lib/typescript/Date/Month.d.ts.map +1 -1
- package/lib/typescript/Date/Swiper.d.ts +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/dateUtils.d.ts +4 -3
- package/lib/typescript/Date/dateUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Date/Calendar.tsx +5 -0
- package/src/Date/CalendarHeader.tsx +7 -1
- package/src/Date/DatePickerInput.shared.tsx +1 -0
- package/src/Date/DatePickerInput.tsx +2 -0
- package/src/Date/DatePickerInputWithoutModal.tsx +3 -0
- package/src/Date/DatePickerModalContent.tsx +2 -0
- package/src/Date/DayNames.tsx +16 -12
- package/src/Date/DayRange.tsx +1 -4
- package/src/Date/Month.tsx +29 -14
- package/src/Date/Swiper.native.tsx +17 -6
- package/src/Date/Swiper.tsx +15 -5
- package/src/Date/SwiperUtils.ts +1 -0
- package/src/Date/dateUtils.tsx +13 -5
package/src/Date/Swiper.tsx
CHANGED
|
@@ -20,6 +20,7 @@ function Swiper({
|
|
|
20
20
|
renderFooter,
|
|
21
21
|
selectedYear,
|
|
22
22
|
initialIndex,
|
|
23
|
+
startWeekOnMonday,
|
|
23
24
|
}: SwiperProps) {
|
|
24
25
|
const isHorizontal = scrollMode === 'horizontal'
|
|
25
26
|
const [index, setIndex] = React.useState(initialIndex)
|
|
@@ -66,6 +67,7 @@ function Swiper({
|
|
|
66
67
|
initialIndex={initialIndex}
|
|
67
68
|
estimatedHeight={estimatedMonthHeight}
|
|
68
69
|
renderItem={renderItem}
|
|
70
|
+
startWeekOnMonday={startWeekOnMonday}
|
|
69
71
|
/>
|
|
70
72
|
)}
|
|
71
73
|
</AutoSizer>
|
|
@@ -83,12 +85,14 @@ function VerticalScroller({
|
|
|
83
85
|
initialIndex,
|
|
84
86
|
estimatedHeight,
|
|
85
87
|
renderItem,
|
|
88
|
+
startWeekOnMonday,
|
|
86
89
|
}: {
|
|
87
90
|
renderItem: (renderProps: RenderProps) => any
|
|
88
91
|
width: number
|
|
89
92
|
height: number
|
|
90
93
|
initialIndex: number
|
|
91
94
|
estimatedHeight: number
|
|
95
|
+
startWeekOnMonday: boolean
|
|
92
96
|
}) {
|
|
93
97
|
const idx = React.useRef<number>(initialIndex)
|
|
94
98
|
const [visibleIndexes, setVisibleIndexes] = React.useState<number[]>(
|
|
@@ -101,7 +105,8 @@ function VerticalScroller({
|
|
|
101
105
|
if (!element) {
|
|
102
106
|
return
|
|
103
107
|
}
|
|
104
|
-
const top =
|
|
108
|
+
const top =
|
|
109
|
+
getVerticalMonthsOffset(idx.current, startWeekOnMonday) - montHeaderHeight
|
|
105
110
|
|
|
106
111
|
element.scrollTo({
|
|
107
112
|
top,
|
|
@@ -118,14 +123,14 @@ function VerticalScroller({
|
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
const offset = top - beginOffset
|
|
121
|
-
const index = getIndexFromVerticalOffset(offset)
|
|
126
|
+
const index = getIndexFromVerticalOffset(offset, startWeekOnMonday)
|
|
122
127
|
|
|
123
128
|
if (idx.current !== index) {
|
|
124
129
|
idx.current = index
|
|
125
130
|
setVisibleIndexesThrottled(visibleArray(index))
|
|
126
131
|
}
|
|
127
132
|
},
|
|
128
|
-
[setVisibleIndexesThrottled]
|
|
133
|
+
[setVisibleIndexesThrottled, startWeekOnMonday]
|
|
129
134
|
)
|
|
130
135
|
|
|
131
136
|
return (
|
|
@@ -153,12 +158,17 @@ function VerticalScroller({
|
|
|
153
158
|
style={{
|
|
154
159
|
willChange: 'transform',
|
|
155
160
|
transform: `translateY(${getVerticalMonthsOffset(
|
|
156
|
-
visibleIndexes[vi]
|
|
161
|
+
visibleIndexes[vi],
|
|
162
|
+
startWeekOnMonday
|
|
157
163
|
)}px)`,
|
|
158
164
|
left: 0,
|
|
159
165
|
right: 0,
|
|
160
166
|
position: 'absolute',
|
|
161
|
-
height: getMonthHeight(
|
|
167
|
+
height: getMonthHeight(
|
|
168
|
+
'vertical',
|
|
169
|
+
visibleIndexes[vi],
|
|
170
|
+
startWeekOnMonday
|
|
171
|
+
),
|
|
162
172
|
}}
|
|
163
173
|
>
|
|
164
174
|
{renderItem({
|
package/src/Date/SwiperUtils.ts
CHANGED
package/src/Date/dateUtils.tsx
CHANGED
|
@@ -58,11 +58,19 @@ export function getDaysInMonth({
|
|
|
58
58
|
export function getFirstDayOfMonth({
|
|
59
59
|
year,
|
|
60
60
|
month,
|
|
61
|
+
startWeekOnMonday,
|
|
61
62
|
}: {
|
|
62
63
|
year: number
|
|
63
64
|
month: number
|
|
65
|
+
startWeekOnMonday: boolean
|
|
64
66
|
}): number {
|
|
65
|
-
|
|
67
|
+
let dayOfWeek = new Date(year, month, 1).getDay()
|
|
68
|
+
if (startWeekOnMonday) {
|
|
69
|
+
// Map Sunday (0) to 6, Monday (1) to 0, etc.
|
|
70
|
+
dayOfWeek = (dayOfWeek + 6) % 7
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return dayOfWeek
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
export function useRangeChecker(validRange: ValidRangeType | undefined) {
|
|
@@ -167,22 +175,22 @@ export const totalMonths = startAtIndex * 2
|
|
|
167
175
|
export const beginOffset = estimatedMonthHeight * startAtIndex
|
|
168
176
|
export const gridCounts = new Array<number | undefined>(totalMonths)
|
|
169
177
|
|
|
170
|
-
export function getGridCount(index: number) {
|
|
178
|
+
export function getGridCount(index: number, startWeekOnMonday: boolean) {
|
|
171
179
|
const cHeight = gridCounts[index]
|
|
172
180
|
if (cHeight) {
|
|
173
181
|
return cHeight
|
|
174
182
|
}
|
|
175
183
|
const monthDate = addMonths(new Date(), getRealIndex(index))
|
|
176
|
-
const h = getGridCountForDate(monthDate)
|
|
184
|
+
const h = getGridCountForDate(monthDate, startWeekOnMonday)
|
|
177
185
|
gridCounts[index] = h
|
|
178
186
|
return h
|
|
179
187
|
}
|
|
180
188
|
|
|
181
|
-
export function getGridCountForDate(date: Date) {
|
|
189
|
+
export function getGridCountForDate(date: Date, startWeekOnMonday: boolean) {
|
|
182
190
|
const year = date.getFullYear()
|
|
183
191
|
const month = date.getMonth()
|
|
184
192
|
const daysInMonth = getDaysInMonth({ year, month })
|
|
185
|
-
const dayOfWeek = getFirstDayOfMonth({ year, month })
|
|
193
|
+
const dayOfWeek = getFirstDayOfMonth({ year, month, startWeekOnMonday })
|
|
186
194
|
return Math.ceil((daysInMonth + dayOfWeek) / 7)
|
|
187
195
|
}
|
|
188
196
|
|