Skip to content

Commit 0f6338b

Browse files
Make it possible to start the week on monday
Signed-off-by: Grégoire Bélorgey <[email protected]>
1 parent e582bff commit 0f6338b

22 files changed

+141
-45
lines changed

docusaurus/docs/date-picker/input-date-picker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ The start year when the component is rendered. Defaults to `1800`.
119119
`Type: number | undefined`
120120
The end year when the component is rendered. Defaults to `2200`.
121121

122+
**startWeekOnMonday**
123+
`Type: boolean | undefined`
124+
Flag indicating if calendar grid sould show monday as the first column. Defaults to `false`.
125+
122126
**inputEnabled**
123127
`Type: boolean | undefined`
124128
Flag indicating if the component should be enabled or not. Behavior similarly to `disabled`. Defaults to `true`.

docusaurus/docs/date-picker/multiple-dates-picker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ The start year when the component is rendered. Defaults to `1800`.
131131
`Type: number | undefined`
132132
The end year when the component is rendered. Defaults to `2200`.
133133

134+
**startWeekOnMonday**
135+
`Type: boolean | undefined`
136+
Flag indicating if calendar grid sould show monday as the first column. Defaults to `false`.
137+
134138
**closeIcon**
135139
`Type: string | undefined`
136140
The icon used to close the component. Defaults to `close`. You can pass the name of an icon from [MaterialCommunityIcons](https://materialdesignicons.com/).

docusaurus/docs/date-picker/range-date-picker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ The start year when the component is rendered. Defaults to `1800`.
134134
`Type: number | undefined`
135135
The end year when the component is rendered. Defaults to `2200`.
136136

137+
**startWeekOnMonday**
138+
`Type: boolean | undefined`
139+
Flag indicating if calendar grid sould show monday as the first column. Defaults to `false`.
140+
137141
**closeIcon**
138142
`Type: string | undefined`
139143
The icon used to close the component. Defaults to `close`. You can pass the name of an icon from [MaterialCommunityIcons](https://materialdesignicons.com/).

docusaurus/docs/date-picker/single-date-picker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ The start year when the component is rendered. Defaults to `1800`.
121121
`Type: number | undefined`
122122
The end year when the component is rendered. Defaults to `2200`.
123123

124+
**startWeekOnMonday**
125+
`Type: boolean | undefined`
126+
Flag indicating if calendar grid sould show monday as the first column. Defaults to `false`.
127+
124128
**closeIcon**
125129
`Type: string | undefined`
126130
The icon used to close the component. Defaults to `close`. You can pass the name of an icon from [MaterialCommunityIcons](https://materialdesignicons.com/).

example/src/ReadMeExampleMultiple.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default function ReadMeExampleMultiple() {
4444
// animationType="slide" // optional, default is slide on ios/android and none on web
4545
// startYear={2000} // optional, default is 1800
4646
// endYear={2100} // optional, default is 2200
47+
// startWeekOnMonday={true} // optional, default is false
4748
/>
4849
</>
4950
)

example/src/ReadMeExampleRange.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default function ReadMeExampleRange() {
5252
// animationType="slide" // optional, default is slide on ios/android and none on web
5353
// startYear={2000} // optional, default is 1800
5454
// endYear={2100} // optional, default is 2200
55+
// startWeekOnMonday={true} // optional, default is false
5556
/>
5657
</>
5758
)

example/src/ReadMeExampleSingle.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function ReadMeExampleSingle() {
4343
// animationType="slide" // optional, default is 'slide' on ios/android and 'none' on web
4444
// startYear={2000} // optional, default is 1800
4545
// endYear={2100} // optional, default is 2200
46+
// startWeekOnMonday={true} // optional, default is false
4647
//
4748
/>
4849
</>

src/Date/Calendar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type BaseCalendarProps = {
3333
validRange?: ValidRangeType
3434
startYear?: number
3535
endYear?: number
36+
startWeekOnMonday?: boolean
3637

3738
// here they are optional but in final implementation they are required
3839
date?: CalendarDate
@@ -95,6 +96,7 @@ function Calendar(
9596
dates,
9697
validRange,
9798
dateMode,
99+
startWeekOnMonday,
98100
} = props
99101

100102
const theme = useTheme()
@@ -177,6 +179,7 @@ function Calendar(
177179
initialIndex={getInitialIndex(firstDate)}
178180
selectedYear={selectedYear}
179181
scrollMode={scrollMode}
182+
startWeekOnMonday={startWeekOnMonday || false}
180183
renderItem={({ index }) => (
181184
<Month
182185
locale={locale}
@@ -196,6 +199,7 @@ function Calendar(
196199
selectColor={selectColor}
197200
roundness={theme.roundness}
198201
disableWeekDays={disableWeekDays}
202+
startWeekOnMonday={startWeekOnMonday || false}
199203
/>
200204
)}
201205
renderHeader={({ onPrev, onNext }) => (
@@ -205,6 +209,7 @@ function Calendar(
205209
onNext={onNext}
206210
scrollMode={scrollMode}
207211
disableWeekDays={disableWeekDays}
212+
startWeekOnMonday={startWeekOnMonday || false}
208213
/>
209214
)}
210215
/>

src/Date/CalendarHeader.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ function CalendarHeader({
2727
onNext,
2828
disableWeekDays,
2929
locale,
30+
startWeekOnMonday,
3031
}: {
3132
locale: undefined | string
3233
scrollMode: 'horizontal' | 'vertical'
3334
onPrev: () => any
3435
onNext: () => any
3536
disableWeekDays?: DisableWeekDaysType
37+
startWeekOnMonday: boolean
3638
}) {
3739
const theme = useTheme()
3840
const isHorizontal = scrollMode === 'horizontal'
@@ -67,7 +69,11 @@ function CalendarHeader({
6769
</View>
6870
</View>
6971
) : null}
70-
<DayNames disableWeekDays={disableWeekDays} locale={locale} />
72+
<DayNames
73+
disableWeekDays={disableWeekDays}
74+
locale={locale}
75+
startWeekOnMonday={startWeekOnMonday}
76+
/>
7177
</View>
7278
)
7379
}

src/Date/DatePickerInput.shared.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type DatePickerInputProps = {
2727
disableStatusBarPadding?: boolean
2828
animationType?: 'slide' | 'fade' | 'none'
2929
presentationStyle?: 'pageSheet' | 'overFullScreen'
30+
startWeekOnMonday?: boolean
3031
} & Omit<
3132
React.ComponentProps<typeof TextInput>,
3233
'value' | 'onChange' | 'onChangeText' | 'inputMode'

0 commit comments

Comments
 (0)