UNPKG

8.55 kBTypeScriptView Raw
1import { AnimationDirection } from '../Calendar/Calendar.types';
2import { DayOfWeek, FirstWeekOfYear, DateRangeType } from '@fluentui/date-time-utilities';
3import type { IBaseProps, IRefObject, IStyleFunctionOrObject } from '@fluentui/utilities';
4import type { ICalendarStrings, IDateFormatting, IDayGridOptions } from '@fluentui/date-time-utilities';
5import type { IStyle, ITheme, IProcessedStyleSet } from '@fluentui/style-utilities';
6/**
7 * {@docCategory Calendar}
8 */
9export interface ICalendarDayGrid {
10 focus(): void;
11}
12/**
13 * {@docCategory Calendar}
14 */
15export interface ICalendarDayGridProps extends IDayGridOptions, IBaseProps<ICalendarDayGrid> {
16 /**
17 * Optional callback to access the ICalendarDayGrid interface. Use this instead of ref for accessing
18 * the public methods and properties of the component.
19 */
20 componentRef?: IRefObject<ICalendarDayGrid>;
21 /**
22 * Customized styles for the component.
23 */
24 styles?: IStyleFunctionOrObject<ICalendarDayGridStyleProps, ICalendarDayGridStyles>;
25 /**
26 * Theme (provided through customization).
27 */
28 theme?: ITheme;
29 /**
30 * Additional CSS class(es) to apply to the CalendarDayGrid.
31 */
32 className?: string;
33 /**
34 * Localized strings to use in the CalendarDayGrid
35 */
36 strings: ICalendarStrings;
37 /**
38 * The currently selected date
39 */
40 selectedDate: Date;
41 /**
42 * The currently navigated date
43 */
44 navigatedDate: Date;
45 /**
46 * Callback issued when a date is selected
47 * @param date - The date the user selected
48 * @param selectedDateRangeArray - The resultant list of dates that are selected based on the date range type set
49 * for the component.
50 */
51 onSelectDate?: (date: Date, selectedDateRangeArray?: Date[]) => void;
52 /**
53 * Callback issued when a date in the calendar is navigated
54 * @param date - The date that is navigated to
55 * @param focusOnNavigatedDay - Whether to set the focus to the navigated date.
56 */
57 onNavigateDate: (date: Date, focusOnNavigatedDay: boolean) => void;
58 /**
59 * Callback issued when calendar day is closed
60 */
61 onDismiss?: () => void;
62 /**
63 * The first day of the week for your locale.
64 * @defaultvalue DayOfWeek.Sunday
65 */
66 firstDayOfWeek: DayOfWeek;
67 /**
68 * Defines when the first week of the year should start, FirstWeekOfYear.FirstDay,
69 * FirstWeekOfYear.FirstFullWeek or FirstWeekOfYear.FirstFourDayWeek are the possible values
70 * @defaultvalue FirstWeekOfYear.FirstDay
71 */
72 firstWeekOfYear: FirstWeekOfYear;
73 /**
74 * The date range type indicating how many days should be selected as the user
75 * selects days
76 * @defaultValue DateRangeType.Day
77 */
78 dateRangeType: DateRangeType;
79 /**
80 * The number of days to select while dateRangeType === DateRangeType.Day. Used in order to have multi-day
81 * views.
82 * @defaultValue 1
83 */
84 daysToSelectInDayView?: number;
85 /**
86 * Value of today. If unspecified, current time in client machine will be used.
87 */
88 today?: Date;
89 /**
90 * Whether the calendar should show the week number (weeks 1 to 53) before each week row
91 * @defaultvalue false
92 */
93 showWeekNumbers?: boolean;
94 /**
95 * Apply additional formatting to dates, for example localized date formatting.
96 */
97 dateTimeFormatter: IDateFormatting;
98 /**
99 * Ref callback for individual days. Allows for customization of the styling, properties, or listeners of the
100 * specific day.
101 */
102 customDayCellRef?: (element: HTMLElement, date: Date, classNames: IProcessedStyleSet<ICalendarDayGridStyles>) => void;
103 /**
104 * How many weeks to show by default. If not provided, will show enough weeks to display the current
105 * month, between 4 and 6 depending
106 * @defaultvalue undefined
107 */
108 weeksToShow?: number;
109 /**
110 * If set the Calendar will not allow navigation to or selection of a date earlier than this value.
111 */
112 minDate?: Date;
113 /**
114 * If set the Calendar will not allow navigation to or selection of a date later than this value.
115 */
116 maxDate?: Date;
117 /**
118 * If set the Calendar will not allow selection of dates in this array.
119 */
120 restrictedDates?: Date[];
121 /**
122 * The days that are selectable when `dateRangeType` is WorkWeek.
123 * If `dateRangeType` is not WorkWeek this property does nothing.
124 * @defaultvalue [Monday,Tuesday,Wednesday,Thursday,Friday]
125 */
126 workWeekDays?: DayOfWeek[];
127 /**
128 * Whether the close button should be shown or not
129 * @defaultvalue false
130 */
131 showCloseButton?: boolean;
132 /**
133 * Allows all dates and buttons to be focused, including disabled ones
134 * @defaultvalue false
135 */
136 allFocusable?: boolean;
137 /**
138 * The ID of the control that labels this one
139 */
140 labelledBy?: string;
141 /**
142 * Whether to show days outside the selected month with lighter styles
143 * @defaultvalue true
144 */
145 lightenDaysOutsideNavigatedMonth?: boolean;
146 /**
147 * The cardinal directions for animation to occur during transitions, either horizontal or veritcal
148 */
149 animationDirection?: AnimationDirection;
150 /**
151 * Optional callback function to mark specific days with a small symbol. Fires when the date range changes,
152 * gives the starting and ending displayed dates and expects the list of which days in between should be
153 * marked.
154 */
155 getMarkedDays?: (startingDate: Date, endingDate: Date) => Date[];
156}
157/**
158 * {@docCategory Calendar}
159 */
160export interface ICalendarDayGridStyleProps {
161 /**
162 * Theme provided by High-Order Component.
163 */
164 theme: ITheme;
165 /**
166 * Accept custom classNames
167 */
168 className?: string;
169 /**
170 * The date range type
171 */
172 dateRangeType?: DateRangeType;
173 /**
174 * Whether week numbers are being shown
175 */
176 showWeekNumbers?: boolean;
177 /**
178 * Whether to show days outside the selected month with lighter styles
179 */
180 lightenDaysOutsideNavigatedMonth?: boolean;
181 /**
182 * Whether grid entering animation should be forwards or backwards
183 */
184 animateBackwards?: boolean;
185 /**
186 * The cardinal directions for animation to occur during transitions, either horizontal or vertical
187 */
188 animationDirection?: AnimationDirection;
189}
190/**
191 * {@docCategory Calendar}
192 */
193export interface ICalendarDayGridStyles {
194 /**
195 * The style for the root div
196 */
197 wrapper?: IStyle;
198 /**
199 * The style for the table containing the grid
200 */
201 table?: IStyle;
202 /**
203 * The style to apply to the grid cells for days
204 */
205 dayCell?: IStyle;
206 /**
207 * The style to apply to grid cells for days in the selected range
208 */
209 daySelected?: IStyle;
210 /**
211 * The style to apply to row around weeks
212 */
213 weekRow?: IStyle;
214 /**
215 * The style to apply to the column headers above the weeks
216 */
217 weekDayLabelCell?: IStyle;
218 /**
219 * The style to apply to grid cells for week numbers
220 */
221 weekNumberCell?: IStyle;
222 /**
223 * The style to apply to individual days that are outside the min/max date range
224 */
225 dayOutsideBounds?: IStyle;
226 /**
227 * The style to apply to individual days that are outside the current month
228 */
229 dayOutsideNavigatedMonth?: IStyle;
230 /**
231 * The style to apply to the button element within the day cells
232 */
233 dayButton?: IStyle;
234 /**
235 * The style to apply to the individual button element that matches the "today" parameter
236 */
237 dayIsToday?: IStyle;
238 /**
239 * The style applied to the first placeholder week used during transitions
240 */
241 firstTransitionWeek?: IStyle;
242 /**
243 * The style applied to the last placeholder week used during transitions
244 */
245 lastTransitionWeek?: IStyle;
246 /**
247 * The style applied to the marker on days to mark as important
248 */
249 dayMarker?: IStyle;
250 /**
251 * The styles to apply to days for rounded corners. Can apply multiple to round multiple corners
252 */
253 topRightCornerDate?: IStyle;
254 topLeftCornerDate?: IStyle;
255 bottomRightCornerDate?: IStyle;
256 bottomLeftCornerDate?: IStyle;
257 /**
258 * The styles to apply to days for focus borders. Can apply multiple if there are multiple focused days
259 * around the current focused date
260 */
261 datesAbove?: IStyle;
262 datesBelow?: IStyle;
263 datesLeft?: IStyle;
264 datesRight?: IStyle;
265}