Skip to content

Commit 0a1d123

Browse files
committed
[@types/react-big-calendar] Add dayLayoutAlgorithm property added in jquense/react-big-calendar#1473 , constrain Culture type to string instead of string | string[]
1 parent f2db20e commit 0a1d123

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

types/react-big-calendar/index.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Type definitions for react-big-calendar 0.22
2-
// Project: https://github.com/intljusticemission/react-big-calendar
2+
// Project: https://github.com/jquense/react-big-calendar
33
// Definitions by: Piotr Witek <https://github.com/piotrwitek>
44
// Austin Turner <https://github.com/paustint>
55
// Krzysztof Bezrąk <https://github.com/pikpok>
@@ -15,6 +15,7 @@
1515
// Eric Kenney <https://github.com/KenneyE>
1616
// Paito Anderson <https://github.com/PaitoAnderson>
1717
// Jan Michalak <https://github.com/michalak111>
18+
// Felix Hessenberger <https://github.com/fhessenberger>
1819
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
1920
// TypeScript Version: 2.8
2021
import { Validator } from 'prop-types';
@@ -33,6 +34,7 @@ export type ViewsProps = View[] | {
3334
month?: boolean | React.ComponentType<any> & ViewStatic,
3435
week?: boolean | React.ComponentType<any> & ViewStatic
3536
};
37+
export type DayLayoutAlgorithm = 'overlap' | 'no-overlap';
3638
export type NavigateAction = 'PREV' | 'NEXT' | 'TODAY' | 'DATE';
3739
export interface Event {
3840
allDay?: boolean;
@@ -46,8 +48,8 @@ export interface DateRange {
4648
end: Date;
4749
}
4850

49-
export type DateFormatFunction = (date: Date, culture?: string, localizer?: object) => string;
50-
export type DateRangeFormatFunction = (range: DateRange, culture?: string, localizer?: object) => string;
51+
export type DateFormatFunction = (date: Date, culture?: Culture, localizer?: DateLocalizer) => string;
52+
export type DateRangeFormatFunction = (range: DateRange, culture?: Culture, localizer?: DateLocalizer) => string;
5153
export type DateFormat = string | DateFormatFunction;
5254

5355
export interface Formats {
@@ -228,7 +230,7 @@ export interface Messages {
228230
noEventsInRange?: string;
229231
}
230232

231-
export type Culture = string | string[];
233+
export type Culture = string;
232234
export type FormatInput = number | string | Date;
233235

234236
export interface DateLocalizerSpec {
@@ -293,6 +295,7 @@ export interface CalendarProps<TEvent extends object = Event, TResource extends
293295
formats?: Formats;
294296
components?: Components<TEvent>;
295297
messages?: Messages;
298+
dayLayoutAlgorithm?: DayLayoutAlgorithm;
296299
titleAccessor?: keyof TEvent | ((event: TEvent) => string);
297300
tooltipAccessor?: keyof TEvent | ((event: TEvent) => string);
298301
allDayAccessor?: keyof TEvent | ((event: TEvent) => boolean);

types/react-big-calendar/react-big-calendar-tests.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
ToolbarProps,
1717
EventProps,
1818
EventWrapperProps,
19-
NavigateAction
19+
NavigateAction,
20+
Culture
2021
} from "react-big-calendar";
2122
import withDragAndDrop from "react-big-calendar/lib/addons/dragAndDrop";
2223

@@ -197,6 +198,7 @@ class CalendarResource {
197198
const end = slotInfo.end;
198199
return true;
199200
}}
201+
dayLayoutAlgorithm="overlap"
200202
views={['day']}
201203
toolbar={true}
202204
popup={true}
@@ -218,8 +220,8 @@ class CalendarResource {
218220
scrollToTime={new Date()}
219221
formats={{
220222
dateFormat: 'h a',
221-
agendaDateFormat: (date: Date, culture?: string, localizer?: object) => 'some-format',
222-
dayRangeHeaderFormat: (range: DateRange, culture?: string, localizer?: object) => 'some-format',
223+
agendaDateFormat: (date: Date, culture?: Culture, localizer?: DateLocalizer) => 'some-format',
224+
dayRangeHeaderFormat: (range: DateRange, culture?: Culture, localizer?: DateLocalizer) => 'some-format',
223225
}}
224226
messages={{
225227
date: 'Date',

0 commit comments

Comments
 (0)