UNPKG

8.14 kBPlain TextView Raw
1import { CSSProperties } from "react";
2
3import type { CustomComponents, ClassNames, Styles } from "./types/index.js";
4
5/**
6 * The UI elements composing DayPicker. These elements are mapped to
7 * {@link CustomComponents}, the {@link ClassNames} and the {@link Styles} used by
8 * DayPicker.
9 *
10 * Some of these elements are extended by flags and modifiers.
11 */
12export enum UI {
13 /** The previous button in the navigation. */
14 ButtonPrevious = "button_previous",
15 /** The next button the navigation. */
16 ButtonNext = "button_next",
17 /** The root component displaying the months and the navigation bar. */
18 Root = "root",
19 /** The Chevron SVG element used by navigation buttons and dropdowns. */
20 Chevron = "chevron",
21 /**
22 * The grid cell with the day's date. Extended by {@link DayFlag} and
23 * {@link SelectionFlag}.
24 */
25 Day = "day",
26 /** The button containing the formatted day's date, inside the grid cell. */
27 DayButton = "day_button",
28 /** The caption label of the month (when not showing the dropdown navigation). */
29 CaptionLabel = "caption_label",
30 /** The container of the dropdown navigation (when enabled). */
31 Dropdowns = "dropdowns",
32 /** The dropdown element to select for years and months. */
33 Dropdown = "dropdown",
34 /** The container element of the dropdown. */
35 DropdownRoot = "dropdown_root",
36 /** The root element of the footer. */
37 Footer = "footer",
38 /** The month grid. */
39 MonthGrid = "month_grid",
40 /** Contains the dropdown navigation or the caption label. */
41 MonthCaption = "month_caption",
42 /** The dropdown with the months. */
43 MonthsDropdown = "months_dropdown",
44 /** Wrapper of the month grid. */
45 Month = "month",
46 /** The container of the displayed months. */
47 Months = "months",
48 /** The navigation bar with the previous and next buttons. */
49 Nav = "nav",
50 /** The row containing the week. */
51 Week = "week",
52 /** The group of row weeks in a month (`tbody`). */
53 Weeks = "weeks",
54 /** The column header with the weekday. */
55 Weekday = "weekday",
56 /** The row grouping the weekdays in the column headers. */
57 Weekdays = "weekdays",
58 /** The cell containing the week number. */
59 WeekNumber = "week_number",
60 /** The cell header of the week numbers column. */
61 WeekNumberHeader = "week_number_header",
62 /** The dropdown with the years. */
63 YearsDropdown = "years_dropdown"
64}
65
66/** The flags for the {@link UI.Day}. */
67export enum DayFlag {
68 /** The day is disabled. */
69 disabled = "disabled",
70 /** The day is hidden. */
71 hidden = "hidden",
72 /** The day is outside the current month. */
73 outside = "outside",
74 /** The day is focused. */
75 focused = "focused",
76 /** The day is today. */
77 today = "today"
78}
79
80/**
81 * The state that can be applied to the {@link UI.Day} element when in selection
82 * mode.
83 */
84export enum SelectionState {
85 /** The day is at the end of a selected range. */
86 range_end = "range_end",
87 /** The day is at the middle of a selected range. */
88 range_middle = "range_middle",
89 /** The day is at the start of a selected range. */
90 range_start = "range_start",
91 /** The day is selected. */
92 selected = "selected"
93}
94
95/**
96 * Deprecated UI elements and flags.
97 *
98 * These elements were used in previous version of DayPicker and are kept here
99 * to help the transition to the new {@link UI | UI elements}.
100 *
101 * ```diff
102 * <DayPicker classNames={{
103 * - cell: "my-cell",
104 * + day: "my-cell",
105 * - day: "my-day",
106 * + day_button: "my-day",
107 * - day_disabled: "my-day_disabled",
108 * + disabled: "my-day_disabled",
109 * // etc.
110 * }}/>
111 * ```
112 *
113 * @deprecated
114 * @since 9.0.1
115 * @see https://daypicker.dev/upgrading
116 * @see https://daypicker.dev/docs/styling
117 */
118export type DeprecatedUI<T extends CSSProperties | string> = {
119 /**
120 * This element was applied to the style of any button in DayPicker and it is
121 * replaced by {@link UI.ButtonPrevious} and {@link UI.ButtonNext}.
122 *
123 * @deprecated
124 */
125 button: T;
126 /**
127 * This element was resetting the style of any button in DayPicker and it is
128 * replaced by {@link UI.ButtonPrevious} and {@link UI.ButtonNext}.
129 *
130 * @deprecated
131 */
132 button_reset: T;
133 /**
134 * This element has been renamed to {@link UI.MonthCaption}.
135 *
136 * @deprecated
137 */
138 caption: T;
139 /**
140 * This element has been removed. Captions are styled via
141 * {@link UI.MonthCaption}.
142 *
143 * @deprecated
144 */
145 caption_between: T;
146 /**
147 * This element has been renamed to {@link UI.Dropdowns}.
148 *
149 * @deprecated
150 */
151 caption_dropdowns: T;
152 /**
153 * This element has been removed. Captions are styled via
154 * {@link UI.MonthCaption}.
155 *
156 * @deprecated
157 */
158 caption_end: T;
159 /**
160 * This element has been removed.
161 *
162 * @deprecated
163 */
164 caption_start: T;
165 /**
166 * This element has been renamed to {@link UI.Day}.
167 *
168 * @deprecated
169 */
170 cell: T;
171 /**
172 * This element has been renamed to {@link DayFlag.disabled}.
173 *
174 * @deprecated
175 */
176 day_disabled: T;
177 /**
178 * This element has been renamed to {@link DayFlag.hidden}.
179 *
180 * @deprecated
181 */
182 day_hidden: T;
183 /**
184 * This element has been renamed to {@link DayFlag.outside}.
185 *
186 * @deprecated
187 */
188 day_outside: T;
189 /**
190 * This element has been renamed to {@link SelectionState.range_end}.
191 *
192 * @deprecated
193 */
194 day_range_end: T;
195 /**
196 * This element has been renamed to {@link SelectionState.range_middle}.
197 *
198 * @deprecated
199 */
200 day_range_middle: T;
201 /**
202 * This element has been renamed to {@link SelectionState.range_start}.
203 *
204 * @deprecated
205 */
206 day_range_start: T;
207 /**
208 * This element has been renamed to {@link SelectionState.selected}.
209 *
210 * @deprecated
211 */
212 day_selected: T;
213 /**
214 * This element has been renamed to {@link DayFlag.today}.
215 *
216 * @deprecated
217 */
218 day_today: T;
219 /**
220 * This element has been removed. The dropdown icon is now {@link UI.Chevron}
221 * inside a {@link UI.CaptionLabel}.
222 *
223 * @deprecated
224 */
225 dropdown_icon: T;
226 /**
227 * This element has been renamed to {@link UI.MonthsDropdown}.
228 *
229 * @deprecated
230 */
231 dropdown_month: T;
232 /**
233 * This element has been renamed to {@link UI.YearsDropdown}.
234 *
235 * @deprecated
236 */
237 dropdown_year: T;
238 /**
239 * This element has been removed.
240 *
241 * @deprecated
242 */
243 head: T;
244 /**
245 * This element has been renamed to {@link UI.Weekday}.
246 *
247 * @deprecated
248 */
249 head_cell: T;
250 /**
251 * This element has been renamed to {@link UI.Weekdays}.
252 *
253 * @deprecated
254 */
255 head_row: T;
256 /**
257 * This flag has been removed. Use `data-multiple-months` in your CSS
258 * selectors.
259 *
260 * @deprecated
261 */
262 multiple_months: T;
263 /**
264 * This element has been removed. To style the navigation buttons, use
265 * {@link UI.ButtonPrevious} and {@link UI.ButtonNext}.
266 *
267 * @deprecated
268 */
269 nav_button: T;
270 /**
271 * This element has been renamed to {@link UI.ButtonNext}.
272 *
273 * @deprecated
274 */
275 nav_button_next: T;
276 /**
277 * This element has been renamed to {@link UI.ButtonPrevious}.
278 *
279 * @deprecated
280 */
281 nav_button_previous: T;
282 /**
283 * This element has been removed. The dropdown icon is now {@link UI.Chevron}
284 * inside a {@link UI.ButtonNext} or a {@link UI.ButtonPrevious}.
285 *
286 * @deprecated
287 */
288 nav_icon: T;
289 /**
290 * This element has been renamed to {@link UI.Week}.
291 *
292 * @deprecated
293 */
294 row: T;
295 /**
296 * This element has been renamed to {@link UI.MonthGrid}.
297 *
298 * @deprecated
299 */
300 table: T;
301 /**
302 * This element has been renamed to {@link UI.Weeks}.
303 *
304 * @deprecated
305 */
306 tbody: T;
307 /**
308 * This element has been removed. The {@link UI.Footer} is now a single element
309 * below the months.
310 *
311 * @deprecated
312 */
313 tfoot: T;
314 /**
315 * This flag has been removed. There are no "visually hidden" elements in
316 * DayPicker 9.
317 *
318 * @deprecated
319 */
320 vhidden: T;
321 /**
322 * This element has been renamed. Use {@link UI.WeekNumber} instead.
323 *
324 * @deprecated
325 */
326 weeknumber: T;
327 /**
328 * This flag has been removed. Use `data-week-numbers` in your CSS.
329 *
330 * @deprecated
331 */
332 with_weeknumber: T;
333};