react-native-paper-dates 0.22.9 → 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/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/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/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/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
|
@@ -14,6 +14,7 @@ interface BaseMonthProps {
|
|
|
14
14
|
selectColor: string;
|
|
15
15
|
roundness: number;
|
|
16
16
|
validRange?: ValidRangeType;
|
|
17
|
+
startWeekOnMonday: boolean;
|
|
17
18
|
startDate?: CalendarDate;
|
|
18
19
|
endDate?: CalendarDate;
|
|
19
20
|
date?: CalendarDate;
|
|
@@ -40,10 +41,10 @@ export declare const monthHeaderSingleMarginTop = 4;
|
|
|
40
41
|
export declare const monthHeaderSingleMarginBottom: number;
|
|
41
42
|
export declare const monthHeaderSingleHeight: number;
|
|
42
43
|
export declare function getIndexFromHorizontalOffset(offset: number, width: number): number;
|
|
43
|
-
export declare function getIndexFromVerticalOffset(offset: number): number;
|
|
44
|
+
export declare function getIndexFromVerticalOffset(offset: number, startWeekOnMonday: boolean): number;
|
|
44
45
|
export declare function getHorizontalMonthOffset(index: number, width: number): number;
|
|
45
|
-
export declare function getVerticalMonthsOffset(index: number): number;
|
|
46
|
-
export declare function getMonthHeight(scrollMode: 'horizontal' | 'vertical', index: number): number;
|
|
46
|
+
export declare function getVerticalMonthsOffset(index: number, startWeekOnMonday: boolean): number;
|
|
47
|
+
export declare function getMonthHeight(scrollMode: 'horizontal' | 'vertical', index: number, startWeekOnMonday: boolean): number;
|
|
47
48
|
declare const _default: React.MemoExoticComponent<typeof Month>;
|
|
48
49
|
export default _default;
|
|
49
50
|
//# sourceMappingURL=Month.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Month.d.ts","sourceRoot":"","sources":["../../../src/Date/Month.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,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,CACrC,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,OAAO,UAQ3B;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,YAAY,GAAG,UAAU,EACrC,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,OAAO,GACzB,MAAM,CASR;;AAED,wBAAgC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SwiperProps } from './SwiperUtils';
|
|
3
|
-
declare function Swiper({ scrollMode, renderItem, renderHeader, renderFooter, selectedYear, initialIndex, }: SwiperProps): React.JSX.Element;
|
|
3
|
+
declare function Swiper({ scrollMode, renderItem, renderHeader, renderFooter, selectedYear, initialIndex, startWeekOnMonday, }: SwiperProps): React.JSX.Element;
|
|
4
4
|
export declare function useDebouncedCallback(callback: any): any;
|
|
5
5
|
declare const _default: React.MemoExoticComponent<typeof Swiper>;
|
|
6
6
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swiper.d.ts","sourceRoot":"","sources":["../../../src/Date/Swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,EAAe,WAAW,EAAiB,MAAM,eAAe,CAAA;AAGvE,iBAAS,MAAM,CAAC,EACd,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,
|
|
1
|
+
{"version":3,"file":"Swiper.d.ts","sourceRoot":"","sources":["../../../src/Date/Swiper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,OAAO,EAAe,WAAW,EAAiB,MAAM,eAAe,CAAA;AAGvE,iBAAS,MAAM,CAAC,EACd,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAClB,EAAE,WAAW,qBAsDb;AAoHD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CA2BvD;;AAKD,wBAAiC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Swiper.native.d.ts","sourceRoot":"","sources":["../../../src/Date/Swiper.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAgB9B,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAA;AAuB1D,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,qBAQjC;;
|
|
1
|
+
{"version":3,"file":"Swiper.native.d.ts","sourceRoot":"","sources":["../../../src/Date/Swiper.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAgB9B,OAAO,EAAE,WAAW,EAAiB,MAAM,eAAe,CAAA;AAuB1D,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,qBAQjC;;AA8KD,wBAAiC"}
|
|
@@ -11,6 +11,7 @@ export type SwiperProps = {
|
|
|
11
11
|
renderHeader?: (renderProps: RenderProps) => any;
|
|
12
12
|
renderFooter?: (renderProps: RenderProps) => any;
|
|
13
13
|
selectedYear: number | undefined;
|
|
14
|
+
startWeekOnMonday: boolean;
|
|
14
15
|
};
|
|
15
16
|
export declare function useYearChange(onChange: (index: number | undefined) => void, { selectedYear, currentIndexRef, }: {
|
|
16
17
|
currentIndexRef: MutableRefObject<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwiperUtils.d.ts","sourceRoot":"","sources":["../../../src/Date/SwiperUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAU7C,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,CAAA;IACjB,MAAM,EAAE,MAAM,GAAG,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,YAAY,GAAG,UAAU,CAAA;IACrC,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,GAAG,CAAA;IAC7C,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,GAAG,CAAA;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,GAAG,CAAA;IAChD,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"SwiperUtils.d.ts","sourceRoot":"","sources":["../../../src/Date/SwiperUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAU7C,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,CAAA;IACjB,MAAM,EAAE,MAAM,GAAG,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,YAAY,GAAG,UAAU,CAAA;IACrC,UAAU,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,GAAG,CAAA;IAC7C,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,GAAG,CAAA;IAChD,YAAY,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,GAAG,CAAA;IAChD,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,EAC7C,EACE,YAAY,EACZ,eAAe,GAChB,EAAE;IACD,eAAe,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACzC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC,QAkBF"}
|
|
@@ -7,9 +7,10 @@ export declare function getDaysInMonth({ year, month, }: {
|
|
|
7
7
|
year: number;
|
|
8
8
|
month: number;
|
|
9
9
|
}): number;
|
|
10
|
-
export declare function getFirstDayOfMonth({ year, month, }: {
|
|
10
|
+
export declare function getFirstDayOfMonth({ year, month, startWeekOnMonday, }: {
|
|
11
11
|
year: number;
|
|
12
12
|
month: number;
|
|
13
|
+
startWeekOnMonday: boolean;
|
|
13
14
|
}): number;
|
|
14
15
|
export declare function useRangeChecker(validRange: ValidRangeType | undefined): {
|
|
15
16
|
isDisabled: (day: Date) => boolean;
|
|
@@ -40,8 +41,8 @@ export declare const startAtIndex = 1200;
|
|
|
40
41
|
export declare const totalMonths: number;
|
|
41
42
|
export declare const beginOffset: number;
|
|
42
43
|
export declare const gridCounts: (number | undefined)[];
|
|
43
|
-
export declare function getGridCount(index: number): number;
|
|
44
|
-
export declare function getGridCountForDate(date: Date): number;
|
|
44
|
+
export declare function getGridCount(index: number, startWeekOnMonday: boolean): number;
|
|
45
|
+
export declare function getGridCountForDate(date: Date, startWeekOnMonday: boolean): number;
|
|
45
46
|
export declare function getRealIndex(index: number): number;
|
|
46
47
|
export declare function getInitialIndex(date: Date | undefined): number;
|
|
47
48
|
export declare function useInputFormatter({ locale }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../../src/Date/dateUtils.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,MAAM,MAAM,mBAAmB,GAAG,MAAM,EAAE,CAAA;AAE1C,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,eAAe,CAAC,EAAE,mBAAmB,GACpC,OAAO,CAET;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAE1C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,QAalD;AAID,wBAAgB,cAAc,CAAC,EAC7B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CAAA;IAC9B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,UASA;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,UAKnE"}
|
package/package.json
CHANGED
package/src/Date/Calendar.tsx
CHANGED
|
@@ -33,6 +33,7 @@ export type BaseCalendarProps = {
|
|
|
33
33
|
validRange?: ValidRangeType
|
|
34
34
|
startYear?: number
|
|
35
35
|
endYear?: number
|
|
36
|
+
startWeekOnMonday?: boolean
|
|
36
37
|
|
|
37
38
|
// here they are optional but in final implementation they are required
|
|
38
39
|
date?: CalendarDate
|
|
@@ -95,6 +96,7 @@ function Calendar(
|
|
|
95
96
|
dates,
|
|
96
97
|
validRange,
|
|
97
98
|
dateMode,
|
|
99
|
+
startWeekOnMonday,
|
|
98
100
|
} = props
|
|
99
101
|
|
|
100
102
|
const theme = useTheme()
|
|
@@ -177,6 +179,7 @@ function Calendar(
|
|
|
177
179
|
initialIndex={getInitialIndex(firstDate)}
|
|
178
180
|
selectedYear={selectedYear}
|
|
179
181
|
scrollMode={scrollMode}
|
|
182
|
+
startWeekOnMonday={startWeekOnMonday || false}
|
|
180
183
|
renderItem={({ index }) => (
|
|
181
184
|
<Month
|
|
182
185
|
locale={locale}
|
|
@@ -196,6 +199,7 @@ function Calendar(
|
|
|
196
199
|
selectColor={selectColor}
|
|
197
200
|
roundness={theme.roundness}
|
|
198
201
|
disableWeekDays={disableWeekDays}
|
|
202
|
+
startWeekOnMonday={startWeekOnMonday || false}
|
|
199
203
|
/>
|
|
200
204
|
)}
|
|
201
205
|
renderHeader={({ onPrev, onNext }) => (
|
|
@@ -205,6 +209,7 @@ function Calendar(
|
|
|
205
209
|
onNext={onNext}
|
|
206
210
|
scrollMode={scrollMode}
|
|
207
211
|
disableWeekDays={disableWeekDays}
|
|
212
|
+
startWeekOnMonday={startWeekOnMonday || false}
|
|
208
213
|
/>
|
|
209
214
|
)}
|
|
210
215
|
/>
|
|
@@ -27,12 +27,14 @@ function CalendarHeader({
|
|
|
27
27
|
onNext,
|
|
28
28
|
disableWeekDays,
|
|
29
29
|
locale,
|
|
30
|
+
startWeekOnMonday,
|
|
30
31
|
}: {
|
|
31
32
|
locale: undefined | string
|
|
32
33
|
scrollMode: 'horizontal' | 'vertical'
|
|
33
34
|
onPrev: () => any
|
|
34
35
|
onNext: () => any
|
|
35
36
|
disableWeekDays?: DisableWeekDaysType
|
|
37
|
+
startWeekOnMonday: boolean
|
|
36
38
|
}) {
|
|
37
39
|
const theme = useTheme()
|
|
38
40
|
const isHorizontal = scrollMode === 'horizontal'
|
|
@@ -67,7 +69,11 @@ function CalendarHeader({
|
|
|
67
69
|
</View>
|
|
68
70
|
</View>
|
|
69
71
|
) : null}
|
|
70
|
-
<DayNames
|
|
72
|
+
<DayNames
|
|
73
|
+
disableWeekDays={disableWeekDays}
|
|
74
|
+
locale={locale}
|
|
75
|
+
startWeekOnMonday={startWeekOnMonday}
|
|
76
|
+
/>
|
|
71
77
|
</View>
|
|
72
78
|
)
|
|
73
79
|
}
|
|
@@ -27,6 +27,7 @@ export type DatePickerInputProps = {
|
|
|
27
27
|
disableStatusBarPadding?: boolean
|
|
28
28
|
animationType?: 'slide' | 'fade' | 'none'
|
|
29
29
|
presentationStyle?: 'pageSheet' | 'overFullScreen'
|
|
30
|
+
startWeekOnMonday?: boolean
|
|
30
31
|
} & Omit<
|
|
31
32
|
React.ComponentProps<typeof TextInput>,
|
|
32
33
|
'value' | 'onChange' | 'onChangeText' | 'inputMode'
|
|
@@ -60,6 +60,7 @@ function DatePickerInput(
|
|
|
60
60
|
endYear,
|
|
61
61
|
inputEnabled,
|
|
62
62
|
disableStatusBarPadding,
|
|
63
|
+
startWeekOnMonday,
|
|
63
64
|
}) =>
|
|
64
65
|
withModal ? (
|
|
65
66
|
<DatePickerModal
|
|
@@ -81,6 +82,7 @@ function DatePickerInput(
|
|
|
81
82
|
animationType={animationType}
|
|
82
83
|
presentationStyle={presentationStyle}
|
|
83
84
|
label={rest.label as any}
|
|
85
|
+
startWeekOnMonday={startWeekOnMonday}
|
|
84
86
|
/>
|
|
85
87
|
) : null
|
|
86
88
|
}
|
|
@@ -29,6 +29,7 @@ function DatePickerInputWithoutModal(
|
|
|
29
29
|
onChangeText,
|
|
30
30
|
inputEnabled,
|
|
31
31
|
disableStatusBarPadding,
|
|
32
|
+
startWeekOnMonday,
|
|
32
33
|
...rest
|
|
33
34
|
}: DatePickerInputProps & {
|
|
34
35
|
modal?: (params: {
|
|
@@ -43,6 +44,7 @@ function DatePickerInputWithoutModal(
|
|
|
43
44
|
endYear: DatePickerInputProps['endYear']
|
|
44
45
|
inputEnabled: DatePickerInputProps['inputEnabled']
|
|
45
46
|
disableStatusBarPadding: DatePickerInputProps['disableStatusBarPadding']
|
|
47
|
+
startWeekOnMonday?: DatePickerInputProps['startWeekOnMonday']
|
|
46
48
|
}) => any
|
|
47
49
|
inputButton?: React.ReactNode
|
|
48
50
|
},
|
|
@@ -118,6 +120,7 @@ function DatePickerInputWithoutModal(
|
|
|
118
120
|
endYear,
|
|
119
121
|
inputEnabled,
|
|
120
122
|
disableStatusBarPadding,
|
|
123
|
+
startWeekOnMonday,
|
|
121
124
|
})}
|
|
122
125
|
</>
|
|
123
126
|
)
|
|
@@ -93,6 +93,7 @@ export function DatePickerModalContent(
|
|
|
93
93
|
startYear,
|
|
94
94
|
endYear,
|
|
95
95
|
statusBarOnTopOfBackdrop,
|
|
96
|
+
startWeekOnMonday,
|
|
96
97
|
} = props
|
|
97
98
|
const anyProps = props as any
|
|
98
99
|
|
|
@@ -199,6 +200,7 @@ export function DatePickerModalContent(
|
|
|
199
200
|
dateMode={dateMode}
|
|
200
201
|
startYear={startYear}
|
|
201
202
|
endYear={endYear}
|
|
203
|
+
startWeekOnMonday={startWeekOnMonday}
|
|
202
204
|
/>
|
|
203
205
|
}
|
|
204
206
|
calendarEdit={
|
package/src/Date/DayNames.tsx
CHANGED
|
@@ -6,31 +6,35 @@ import { DisableWeekDaysType, showWeekDay } from './dateUtils'
|
|
|
6
6
|
|
|
7
7
|
export const dayNamesHeight = 44
|
|
8
8
|
|
|
9
|
-
// TODO: wait for a better Intl api ;-)
|
|
10
|
-
const weekdays = [
|
|
11
|
-
new Date(2020, 7, 2),
|
|
12
|
-
new Date(2020, 7, 3),
|
|
13
|
-
new Date(2020, 7, 4),
|
|
14
|
-
new Date(2020, 7, 5),
|
|
15
|
-
new Date(2020, 7, 6),
|
|
16
|
-
new Date(2020, 7, 7),
|
|
17
|
-
new Date(2020, 7, 8),
|
|
18
|
-
]
|
|
19
|
-
|
|
20
9
|
function DayNames({
|
|
21
10
|
disableWeekDays,
|
|
22
11
|
locale,
|
|
12
|
+
startWeekOnMonday,
|
|
23
13
|
}: {
|
|
24
14
|
locale: undefined | string
|
|
25
15
|
disableWeekDays?: DisableWeekDaysType
|
|
16
|
+
startWeekOnMonday: boolean
|
|
26
17
|
}) {
|
|
27
18
|
const theme = useTheme()
|
|
28
19
|
const shortDayNames = React.useMemo<string[]>(() => {
|
|
20
|
+
// TODO: wait for a better Intl api ;-)
|
|
21
|
+
const weekdays = [
|
|
22
|
+
new Date(2020, 7, 2),
|
|
23
|
+
new Date(2020, 7, 3),
|
|
24
|
+
new Date(2020, 7, 4),
|
|
25
|
+
new Date(2020, 7, 5),
|
|
26
|
+
new Date(2020, 7, 6),
|
|
27
|
+
new Date(2020, 7, 7),
|
|
28
|
+
new Date(2020, 7, 8),
|
|
29
|
+
]
|
|
30
|
+
if (startWeekOnMonday) {
|
|
31
|
+
weekdays.push(weekdays.shift() as Date)
|
|
32
|
+
}
|
|
29
33
|
const formatter = new Intl.DateTimeFormat(locale, {
|
|
30
34
|
weekday: 'narrow',
|
|
31
35
|
})
|
|
32
36
|
return weekdays.map((date) => formatter.format(date))
|
|
33
|
-
}, [locale])
|
|
37
|
+
}, [locale, startWeekOnMonday])
|
|
34
38
|
|
|
35
39
|
return (
|
|
36
40
|
<View
|
package/src/Date/Month.tsx
CHANGED
|
@@ -49,6 +49,7 @@ interface BaseMonthProps {
|
|
|
49
49
|
selectColor: string
|
|
50
50
|
roundness: number
|
|
51
51
|
validRange?: ValidRangeType
|
|
52
|
+
startWeekOnMonday: boolean
|
|
52
53
|
|
|
53
54
|
// some of these should be required in final implementation
|
|
54
55
|
startDate?: CalendarDate
|
|
@@ -91,6 +92,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
91
92
|
disableWeekDays,
|
|
92
93
|
locale,
|
|
93
94
|
validRange,
|
|
95
|
+
startWeekOnMonday,
|
|
94
96
|
} = props
|
|
95
97
|
const theme = useTheme()
|
|
96
98
|
const textColorOnPrimary = useTextColorOnPrimary()
|
|
@@ -111,10 +113,10 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
111
113
|
const today = new Date()
|
|
112
114
|
|
|
113
115
|
const daysInMonth = getDaysInMonth({ year, month })
|
|
114
|
-
const dayOfWeek = getFirstDayOfMonth({ year, month })
|
|
116
|
+
const dayOfWeek = getFirstDayOfMonth({ year, month, startWeekOnMonday })
|
|
115
117
|
const emptyDays = dayOfWeek
|
|
116
118
|
|
|
117
|
-
return monthGrid(index).map(({ days, weekGrid }) => {
|
|
119
|
+
return monthGrid(index, startWeekOnMonday).map(({ days, weekGrid }) => {
|
|
118
120
|
return {
|
|
119
121
|
weekIndex: weekGrid,
|
|
120
122
|
generatedDays: days.map((_, dayIndex) => {
|
|
@@ -248,6 +250,7 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
248
250
|
endDate,
|
|
249
251
|
dates,
|
|
250
252
|
date,
|
|
253
|
+
startWeekOnMonday,
|
|
251
254
|
])
|
|
252
255
|
|
|
253
256
|
let textFont = theme?.isV3
|
|
@@ -263,7 +266,12 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
|
|
|
263
266
|
const iconSource = theme.isV3 ? iconSourceV3 : iconSourceV2
|
|
264
267
|
|
|
265
268
|
return (
|
|
266
|
-
<View
|
|
269
|
+
<View
|
|
270
|
+
style={[
|
|
271
|
+
styles.month,
|
|
272
|
+
{ height: getMonthHeight(scrollMode, index, startWeekOnMonday) },
|
|
273
|
+
]}
|
|
274
|
+
>
|
|
267
275
|
<View
|
|
268
276
|
style={[
|
|
269
277
|
styles.monthHeader,
|
|
@@ -388,8 +396,8 @@ const styles = StyleSheet.create({
|
|
|
388
396
|
opacity1: { opacity: 1 },
|
|
389
397
|
})
|
|
390
398
|
|
|
391
|
-
const monthGrid = (index: number) => {
|
|
392
|
-
return Array(getGridCount(index))
|
|
399
|
+
const monthGrid = (index: number, startWeekOnMonday: boolean) => {
|
|
400
|
+
return Array(getGridCount(index, startWeekOnMonday))
|
|
393
401
|
.fill(null)
|
|
394
402
|
.map((_, weekGrid) => {
|
|
395
403
|
const days = Array(7).fill(null)
|
|
@@ -405,7 +413,7 @@ function getIndexCount(index: number): number {
|
|
|
405
413
|
return -(startAtIndex - index)
|
|
406
414
|
}
|
|
407
415
|
|
|
408
|
-
function weeksOffset(index: number): number {
|
|
416
|
+
function weeksOffset(index: number, startWeekOnMonday: boolean): number {
|
|
409
417
|
if (index === startAtIndex) {
|
|
410
418
|
return 0
|
|
411
419
|
}
|
|
@@ -413,12 +421,12 @@ function weeksOffset(index: number): number {
|
|
|
413
421
|
if (index > startAtIndex) {
|
|
414
422
|
for (let i = 0; i < index - startAtIndex; i++) {
|
|
415
423
|
const cIndex = startAtIndex + i
|
|
416
|
-
off += gridCounts[cIndex] || getGridCount(cIndex)
|
|
424
|
+
off += gridCounts[cIndex] || getGridCount(cIndex, startWeekOnMonday)
|
|
417
425
|
}
|
|
418
426
|
} else {
|
|
419
427
|
for (let i = 0; i < startAtIndex - index; i++) {
|
|
420
428
|
const cIndex = startAtIndex - i - 1
|
|
421
|
-
off -= gridCounts[cIndex] || getGridCount(cIndex)
|
|
429
|
+
off -= gridCounts[cIndex] || getGridCount(cIndex, startWeekOnMonday)
|
|
422
430
|
}
|
|
423
431
|
}
|
|
424
432
|
return off
|
|
@@ -431,10 +439,13 @@ export function getIndexFromHorizontalOffset(
|
|
|
431
439
|
return startAtIndex + Math.floor(offset / width)
|
|
432
440
|
}
|
|
433
441
|
|
|
434
|
-
export function getIndexFromVerticalOffset(
|
|
442
|
+
export function getIndexFromVerticalOffset(
|
|
443
|
+
offset: number,
|
|
444
|
+
startWeekOnMonday: boolean
|
|
445
|
+
): number {
|
|
435
446
|
let estimatedIndex = startAtIndex + Math.ceil(offset / estimatedMonthHeight)
|
|
436
447
|
|
|
437
|
-
const realOffset = getVerticalMonthsOffset(estimatedIndex)
|
|
448
|
+
const realOffset = getVerticalMonthsOffset(estimatedIndex, startWeekOnMonday)
|
|
438
449
|
const difference = (realOffset - beginOffset - offset) / estimatedMonthHeight
|
|
439
450
|
if (difference >= 1 || difference <= -1) {
|
|
440
451
|
estimatedIndex -= Math.floor(difference)
|
|
@@ -449,9 +460,12 @@ export function getHorizontalMonthOffset(index: number, width: number) {
|
|
|
449
460
|
return width * index
|
|
450
461
|
}
|
|
451
462
|
|
|
452
|
-
export function getVerticalMonthsOffset(
|
|
463
|
+
export function getVerticalMonthsOffset(
|
|
464
|
+
index: number,
|
|
465
|
+
startWeekOnMonday: boolean
|
|
466
|
+
) {
|
|
453
467
|
const count = getIndexCount(index)
|
|
454
|
-
const ob = weeksOffset(index)
|
|
468
|
+
const ob = weeksOffset(index, startWeekOnMonday)
|
|
455
469
|
const monthsHeight = weekSize * ob
|
|
456
470
|
const c = monthsHeight + count * (dayNamesHeight + montHeaderHeight)
|
|
457
471
|
|
|
@@ -460,10 +474,11 @@ export function getVerticalMonthsOffset(index: number) {
|
|
|
460
474
|
|
|
461
475
|
export function getMonthHeight(
|
|
462
476
|
scrollMode: 'horizontal' | 'vertical',
|
|
463
|
-
index: number
|
|
477
|
+
index: number,
|
|
478
|
+
startWeekOnMonday: boolean
|
|
464
479
|
): number {
|
|
465
480
|
const calendarHeight = getCalendarHeaderHeight(scrollMode)
|
|
466
|
-
const gc = getGridCount(index)
|
|
481
|
+
const gc = getGridCount(index, startWeekOnMonday)
|
|
467
482
|
|
|
468
483
|
const currentMonthHeight = weekSize * gc
|
|
469
484
|
const extraHeight =
|
|
@@ -56,6 +56,7 @@ function SwiperInner({
|
|
|
56
56
|
initialIndex,
|
|
57
57
|
width,
|
|
58
58
|
height,
|
|
59
|
+
startWeekOnMonday,
|
|
59
60
|
}: SwiperProps & { width: number; height: number }) {
|
|
60
61
|
const idx = React.useRef<number>(initialIndex)
|
|
61
62
|
const isHorizontal = scrollMode === 'horizontal'
|
|
@@ -75,7 +76,7 @@ function SwiperInner({
|
|
|
75
76
|
}
|
|
76
77
|
const offset = isHorizontal
|
|
77
78
|
? getHorizontalMonthOffset(index, width)
|
|
78
|
-
: getVerticalMonthsOffset(index) - montHeaderHeight
|
|
79
|
+
: getVerticalMonthsOffset(index, startWeekOnMonday) - montHeaderHeight
|
|
79
80
|
|
|
80
81
|
if (isHorizontal) {
|
|
81
82
|
parentRef.current.scrollTo({
|
|
@@ -91,7 +92,7 @@ function SwiperInner({
|
|
|
91
92
|
})
|
|
92
93
|
}
|
|
93
94
|
},
|
|
94
|
-
[parentRef, isHorizontal, width, height]
|
|
95
|
+
[parentRef, isHorizontal, width, height, startWeekOnMonday]
|
|
95
96
|
)
|
|
96
97
|
|
|
97
98
|
const onPrev = React.useCallback(() => {
|
|
@@ -112,7 +113,10 @@ function SwiperInner({
|
|
|
112
113
|
const viewSize = e.nativeEvent.layoutMeasurement
|
|
113
114
|
const newIndex = isHorizontal
|
|
114
115
|
? Math.floor(contentOffset.x / viewSize.width)
|
|
115
|
-
: getIndexFromVerticalOffset(
|
|
116
|
+
: getIndexFromVerticalOffset(
|
|
117
|
+
contentOffset.y - beginOffset,
|
|
118
|
+
startWeekOnMonday
|
|
119
|
+
)
|
|
116
120
|
|
|
117
121
|
if (newIndex === 0) {
|
|
118
122
|
return
|
|
@@ -123,7 +127,7 @@ function SwiperInner({
|
|
|
123
127
|
setVisibleIndexes(getVisibleArray(newIndex, { isHorizontal, height }))
|
|
124
128
|
}
|
|
125
129
|
},
|
|
126
|
-
[idx, height, isHorizontal]
|
|
130
|
+
[idx, height, isHorizontal, startWeekOnMonday]
|
|
127
131
|
)
|
|
128
132
|
|
|
129
133
|
const renderProps = {
|
|
@@ -179,7 +183,10 @@ function SwiperInner({
|
|
|
179
183
|
style={{
|
|
180
184
|
top: isHorizontal
|
|
181
185
|
? 0
|
|
182
|
-
: getVerticalMonthsOffset(
|
|
186
|
+
: getVerticalMonthsOffset(
|
|
187
|
+
visibleIndexes[vi],
|
|
188
|
+
startWeekOnMonday
|
|
189
|
+
),
|
|
183
190
|
left: isHorizontal
|
|
184
191
|
? getHorizontalMonthOffset(visibleIndexes[vi], width)
|
|
185
192
|
: 0,
|
|
@@ -189,7 +196,11 @@ function SwiperInner({
|
|
|
189
196
|
width: isHorizontal ? width : undefined,
|
|
190
197
|
height: isHorizontal
|
|
191
198
|
? undefined
|
|
192
|
-
: getMonthHeight(
|
|
199
|
+
: getMonthHeight(
|
|
200
|
+
scrollMode,
|
|
201
|
+
visibleIndexes[vi],
|
|
202
|
+
startWeekOnMonday
|
|
203
|
+
),
|
|
193
204
|
}}
|
|
194
205
|
>
|
|
195
206
|
{renderItem({
|
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
|
|