@eastgate/react-multi-date-picker 1.0.0

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/index.d.ts ADDED
@@ -0,0 +1,712 @@
1
+ declare module "react-multi-date-picker" {
2
+ import React, { HTMLAttributes } from "react";
3
+ import DateObject, { Calendar, Locale } from "react-date-object";
4
+
5
+ export type Value =
6
+ | Date
7
+ | string
8
+ | number
9
+ | DateObject
10
+ | Date[]
11
+ | string[]
12
+ | number[]
13
+ | DateObject[]
14
+ | null;
15
+
16
+ export type FunctionalPlugin = { type: string; fn: Function };
17
+ export type Plugin = React.ReactElement | FunctionalPlugin;
18
+
19
+ export interface CalendarProps {
20
+ ref?: React.MutableRefObject<any>;
21
+ /**
22
+ * @types Date | string | number | DateObject
23
+ * @types Date[] | string[] | number[] | DateObject[]
24
+ * @example
25
+ * <Calendar value={new Date()} />
26
+ * <DatePicker value={[new Date(), new Date(2020, 2, 12)]} />
27
+ */
28
+ value?: Value;
29
+ /**
30
+ * default calendar is gregorian.
31
+ *
32
+ * if you want to use other calendars instead of gregorian,
33
+ * you must import it from "react-date-object"
34
+ *
35
+ * Availble calendars:
36
+ *
37
+ * - gregorian
38
+ * - persian
39
+ * - arabic
40
+ * - indian
41
+ *
42
+ * @example
43
+ * import persian from "react-date-object/calendars/persian"
44
+ * <Calendar calendar={persian} />
45
+ *
46
+ * import indian from "react-date-object/calendars/indian"
47
+ * <DatePicker calendar={indian} />
48
+ */
49
+ calendar?: Calendar;
50
+ /**
51
+ * default locale is gregorian_en.
52
+ *
53
+ * if you want to use other locales instead of gregorian_en,
54
+ * you must import it from "react-date-object"
55
+ *
56
+ * Availble locales:
57
+ *
58
+ * - gregorian_en
59
+ * - gregorian_fa
60
+ * - gregorian_ar
61
+ * - gregorian_hi
62
+ * - persian_en
63
+ * - persian_fa
64
+ * - persian_ar
65
+ * - persian_hi
66
+ * - arabic_en
67
+ * - arabic_fa
68
+ * - arabic_ar
69
+ * - arabic_hi
70
+ * - indian_en
71
+ * - indian_fa
72
+ * - indian_ar
73
+ * - indian_hi
74
+ *
75
+ * @example
76
+ * import gregorian_fa from "react-date-object/locales/gregorian_fa"
77
+ * <Calendar locale={gregorian_fa} />
78
+ *
79
+ * import gregorian_ar from "react-date-object/locales/gregorian_ar"
80
+ * <DatePicker locale={gregorian_ar} />
81
+ */
82
+ locale?: Locale;
83
+ /**
84
+ * @type string
85
+ * @default "YYYY/MM/DD"
86
+ * @see https://shahabyazdi.github.io/react-multi-date-picker/format-tokens/
87
+ * @example
88
+ * <Calendar format="MM/DD/YYYY hh:mm:ss a" />
89
+ *
90
+ * <DatePicker format="MM-DD-YYYY HH:mm:ss" />
91
+ */
92
+ format?: string;
93
+ onlyMonthPicker?: boolean;
94
+ onlyYearPicker?: boolean;
95
+ /**
96
+ * @example
97
+ * <Calendar
98
+ * value={[new Date(2020,10,10), new Date(2020,10,14)]}
99
+ * range
100
+ * />
101
+ *
102
+ * <DatePicker range />
103
+ */
104
+ range?: boolean;
105
+ /**
106
+ * @example
107
+ * <Calendar
108
+ * value={[new Date(2020,10,10), new Date(2020,10,14)]}
109
+ * multiple
110
+ * />
111
+ *
112
+ * <DatePicker multiple />
113
+ */
114
+ multiple?: boolean;
115
+ /**
116
+ * Calendar wrapper className
117
+ */
118
+ className?: string;
119
+ /**
120
+ * @see https://shahabyazdi.github.io/react-multi-date-picker/locales/
121
+ * @example
122
+ * <Calendar
123
+ * weekDays={[
124
+ * "SU",
125
+ * "MO",
126
+ * "TU",
127
+ * "WE",
128
+ * "TH",
129
+ * "FR",
130
+ * "SA"
131
+ * ]}
132
+ * />
133
+ */
134
+ weekDays?: string[] | Array<string[]>;
135
+ /**
136
+ * @see https://shahabyazdi.github.io/react-multi-date-picker/locales/
137
+ * @example
138
+ * <Calendar
139
+ * months={[
140
+ * "jan",
141
+ * "feb",
142
+ * "mar",
143
+ * "apr",
144
+ * "may",
145
+ * "jun",
146
+ * "jul",
147
+ * "aug",
148
+ * "sep",
149
+ * "oct",
150
+ * "nov",
151
+ * "dec"
152
+ * ]}
153
+ * />
154
+ */
155
+ months?: string[] | Array<string[]>;
156
+ /**
157
+ * @example
158
+ * <Calendar
159
+ * onChange={dateObject=>{
160
+ * console.log(dateObject.format())
161
+ * }}
162
+ * />
163
+ *
164
+ * <DatePicker
165
+ * onChange={dateObject=>{
166
+ * console.log(JSON.stringify(dateObject))
167
+ * }}
168
+ * />
169
+ */
170
+ onChange?(selectedDates: DateObject | DateObject[] | null): void;
171
+ showOtherDays?: boolean;
172
+ /**
173
+ * the date you set in datepicker as value must be equal or bigger than min date.
174
+ *
175
+ * otherwise datepicker recognise it as `invalid date` and doesn't format it.
176
+ *
177
+ * @example
178
+ * <DatePicker
179
+ * value="2020/12/05"
180
+ * minDate="2020/12/05"
181
+ * />
182
+ */
183
+ minDate?: Date | string | number | DateObject;
184
+ /**
185
+ * the date you set in datepicker as value must be equal or smaller than max date.
186
+ *
187
+ * otherwise datepicker recognise it as `invalid date` and doesn't format it.
188
+ *
189
+ * @example
190
+ * <DatePicker
191
+ * value="2020/12/01"
192
+ * maxDate="2020/12/06"
193
+ * />
194
+ */
195
+ maxDate?: Date | string | number | DateObject;
196
+ /**
197
+ * You can customize your calendar days
198
+ * with the mapDays Prop and create different properties
199
+ * for each of them by returning the Props you want.
200
+ * @see https://shahabyazdi.github.io/react-multi-date-picker/map-days/
201
+ * @example
202
+ * <DatePicker
203
+ * mapDays={() => {
204
+ * return {
205
+ * style: {
206
+ * backgroundColor: "brown",
207
+ * color: "white"
208
+ * }
209
+ * }
210
+ * }}
211
+ * />
212
+ */
213
+ mapDays?(object: {
214
+ date: DateObject;
215
+ selectedDate: DateObject | DateObject[];
216
+ currentMonth: object;
217
+ isSameDate(arg1: DateObject, arg2: DateObject): boolean;
218
+ }):
219
+ | (HTMLAttributes<HTMLSpanElement> & {
220
+ disabled?: boolean;
221
+ hidden?: boolean;
222
+ })
223
+ | void;
224
+ disableMonthPicker?: boolean;
225
+ disableYearPicker?: boolean;
226
+ /**
227
+ * @example
228
+ * <DatePicker
229
+ * format="Date:YYYY/MM/DD, Time:HH:mm:ss"
230
+ * formattingIgnoreList={["Date", "Time"]}
231
+ * />
232
+ */
233
+ formattingIgnoreList?: string[];
234
+ /**
235
+ * Calendar z-index
236
+ * @default 100
237
+ */
238
+ zIndex?: number;
239
+ /**
240
+ * Availble Positions:
241
+ * - top
242
+ * - bottom
243
+ * - left
244
+ * - right
245
+ *
246
+ * @example
247
+ *
248
+ * <DatePicker
249
+ * plugins={[
250
+ * <ImportedPlugin position="right" />
251
+ * ]}
252
+ * />
253
+ */
254
+ plugins?: (Plugin | Plugin[])[];
255
+
256
+ /**
257
+ * In Multiple mode, use this Prop to sort the selected dates.
258
+ *
259
+ * @example
260
+ *
261
+ * <DatePicker multiple sort />
262
+ */
263
+ sort?: boolean;
264
+ numberOfMonths?: number;
265
+ currentDate?: DateObject;
266
+ children?: React.ReactNode;
267
+ digits?: string[];
268
+ /**
269
+ * You can set the buttons prop to false to disable the previous & next buttons.
270
+ *
271
+ * @example
272
+ * <Calendar buttons={false} />
273
+ */
274
+ buttons?: boolean;
275
+ /**
276
+ * You can render your favorite element instead of the previous & next buttons.
277
+ *
278
+ * @example
279
+ * <Calendar renderButton={<CustomButton />} />
280
+ */
281
+ renderButton?: React.ReactElement | Function;
282
+ /**
283
+ * Use this property to change the start day of the week.
284
+ *
285
+ * Only numbers between 0 and 6 are valid
286
+ *
287
+ * @example
288
+ *
289
+ * <Calendar weekStartDayIndex={2} />
290
+ */
291
+ weekStartDayIndex?: number;
292
+ disableDayPicker?: boolean;
293
+ onPropsChange?(props: object): void;
294
+ onMonthChange?(date: DateObject): void;
295
+ onYearChange?(date: DateObject): void;
296
+ onFocusedDateChange?(
297
+ focusedDate: DateObject | undefined,
298
+ clickedDate: DateObject | undefined
299
+ ): void;
300
+ readOnly?: boolean;
301
+ disabled?: boolean;
302
+ hideMonth?: boolean;
303
+ hideYear?: boolean;
304
+ hideWeekDays?: boolean;
305
+ shadow?: boolean;
306
+ fullYear?: boolean;
307
+ displayWeekNumbers?: boolean;
308
+ weekNumber?: string;
309
+ weekPicker?: boolean;
310
+ }
311
+
312
+ export interface DatePickerProps {
313
+ arrow?: boolean | React.ReactElement;
314
+ arrowClassName?: string;
315
+ arrowStyle?: React.CSSProperties;
316
+ /**
317
+ * Input name.
318
+ * This feature does not work if you render custom input.
319
+ */
320
+ name?: string;
321
+ id?: string;
322
+ title?: string;
323
+ required?: boolean;
324
+ /**
325
+ * Input placeholder.
326
+ * This feature does not work if you render custom input.
327
+ */
328
+ placeholder?: string;
329
+ /**
330
+ * Input style.
331
+ * This feature does not work if you render custom input.
332
+ */
333
+ style?: React.CSSProperties;
334
+ /**
335
+ * This feature does not work if you render custom input.
336
+ *
337
+ * You can also use this prop for button and icon type.
338
+ *
339
+ * Default class names:
340
+ *
341
+ * - input : `rmdp-input`
342
+ *
343
+ * - button : `rmdp-button`
344
+ *
345
+ * Note that when you enter a new className, the default className is automatically `removed`.
346
+ */
347
+ inputClass?: string;
348
+ /**
349
+ * This feature does not work if you render custom input.
350
+ */
351
+ disabled?: boolean;
352
+ /**
353
+ * @example
354
+ * <DatePicker
355
+ * type="custom"
356
+ * render={<CustomComponent/>}
357
+ * />
358
+ */
359
+ render?: React.ReactElement | Function;
360
+ /**
361
+ * This feature only affects on `input` in `single` mode
362
+ *
363
+ * Input modes:
364
+ *
365
+ * - text
366
+ * - numeric
367
+ * - decimal
368
+ * - none `useful for disabling virtual keyboard`
369
+ *
370
+ * @default "text"
371
+ */
372
+ inputMode?: string;
373
+ scrollSensitive?: boolean;
374
+ hideOnScroll?: boolean;
375
+ /**
376
+ * DatePicker container style.
377
+ */
378
+ containerStyle?: React.CSSProperties;
379
+ /**
380
+ * DatePicker container className.
381
+ */
382
+ containerClassName?: string;
383
+ /**
384
+ * Availble positions:
385
+ *
386
+ * - top or top-center
387
+ * - bottom or bottom-center
388
+ * - left or left-center
389
+ * - right or right-center
390
+ * - top-start or top-left
391
+ * - bottom-start or bottom-left
392
+ * - left-start or left-top
393
+ * - right-start or right-top
394
+ * - top-end or top-right
395
+ * - bottom-end or bottom-right
396
+ * - left-end or left-bottom
397
+ * - right-end or right-bottom
398
+ *
399
+ * @see https://shahabyazdi.github.io/react-multi-date-picker/positions/
400
+ * @example
401
+ *
402
+ * <DatePicker
403
+ * calendarPosition="bottom-start"
404
+ * />
405
+ */
406
+ calendarPosition?: string;
407
+ animations?: Function[];
408
+ /**
409
+ * This feature only affects on `input` in `single` mode
410
+ */
411
+ editable?: boolean;
412
+ /**
413
+ * Set it to false if you want to see selected date(s)
414
+ * that are not in range of min and max dates in calendar.
415
+ * @default true
416
+ */
417
+ onlyShowInRangeDates?: boolean;
418
+ /**
419
+ * Return `false` in case you don't want to open Calendar
420
+ */
421
+ onOpen?(): void | boolean;
422
+ /**
423
+ * Return `false` in case you don't want to close Calendar
424
+ */
425
+ onClose?(): void | boolean;
426
+ fixMainPosition?: boolean;
427
+ fixRelativePosition?: boolean;
428
+ offsetY?: number;
429
+ offsetX?: number;
430
+ onPositionChange?(data: {
431
+ popper: {
432
+ top: number;
433
+ bottom: number;
434
+ left: number;
435
+ right: number;
436
+ height: number;
437
+ width: number;
438
+ };
439
+ element: {
440
+ top: number;
441
+ bottom: number;
442
+ left: number;
443
+ right: number;
444
+ height: number;
445
+ width: number;
446
+ };
447
+ arrow: {
448
+ top: number;
449
+ bottom: number;
450
+ left: number;
451
+ right: number;
452
+ height: number;
453
+ width: number;
454
+ direction: string;
455
+ };
456
+ position: string;
457
+ scroll: {
458
+ scrollLeft: number;
459
+ scrollTop: number;
460
+ };
461
+ }): void;
462
+ mobileLabels?: { OK: string; CANCEL: string };
463
+ portal?: boolean;
464
+ portalTarget?: HTMLElement;
465
+ onOpenPickNewDate?: boolean;
466
+ }
467
+
468
+ export { DateObject };
469
+ export function Calendar(props: CalendarProps): React.ReactElement;
470
+ export function getAllDatesInRange(
471
+ range: DateObject[],
472
+ toDate?: boolean
473
+ ): DateObject[] | Date[];
474
+ export function toDateObject(date: Date, calendar?: Calendar): DateObject;
475
+ export default function DatePicker(
476
+ props: CalendarProps & DatePickerProps
477
+ ): React.ReactElement;
478
+ }
479
+
480
+ declare module "react-multi-date-picker/plugins/date_panel" {
481
+ import React, { HTMLAttributes } from "react";
482
+ import DateObject from "react-date-object";
483
+
484
+ interface DatePanelProps
485
+ extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
486
+ position?: string;
487
+ disabled?: boolean;
488
+ eachDaysInRange?: boolean;
489
+ sort?: string;
490
+ style?: React.CSSProperties;
491
+ className?: string;
492
+ onClickDate?(date: DateObject | undefined): void;
493
+ removeButton?: boolean;
494
+ header?: string;
495
+ markFocused?: boolean;
496
+ focusedClassName?: string;
497
+ formatFunction?(object: {
498
+ date: DateObject | undefined;
499
+ format: string;
500
+ index: number;
501
+ }): React.ReactNode;
502
+ }
503
+
504
+ export default function DatePanel(props: DatePanelProps): React.ReactElement;
505
+ }
506
+
507
+ declare module "react-multi-date-picker/plugins/date_picker_header" {
508
+ import React, { HTMLAttributes } from "react";
509
+ import type { Calendar, Locale } from "react-date-object";
510
+
511
+ interface DatePickerHeaderProps
512
+ extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
513
+ position?: string;
514
+ disabled?: boolean;
515
+ size?: string;
516
+ calendar?: Calendar;
517
+ locale?: Locale;
518
+ className?: string;
519
+ }
520
+
521
+ export default function DatePickerHeader(
522
+ props: DatePickerHeaderProps
523
+ ): React.ReactElement;
524
+ }
525
+
526
+ declare module "react-multi-date-picker/plugins/colors" {
527
+ import { HTMLAttributes } from "react";
528
+ import type { Plugin } from "react-multi-date-picker";
529
+
530
+ interface ColorsProps
531
+ extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
532
+ position?: string;
533
+ disabled?: boolean;
534
+ colors?: string[];
535
+ defaultColor?: string;
536
+ className?: string;
537
+ }
538
+
539
+ export default function colors(object?: ColorsProps): Plugin[];
540
+ }
541
+
542
+ declare module "react-multi-date-picker/plugins/settings" {
543
+ import React, { HTMLAttributes } from "react";
544
+
545
+ interface SettingsProps
546
+ extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
547
+ position?: string;
548
+ disabled?: boolean;
549
+ calendars?: string[];
550
+ locales?: string[];
551
+ modes?: string[];
552
+ others?: string[];
553
+ defaultActive?: string;
554
+ disabledList?: string[];
555
+ defaultFormat?: {
556
+ single?: string;
557
+ onlyYearPicker?: string;
558
+ onlyMonthPicker?: string;
559
+ };
560
+ className?: string;
561
+ names?: {
562
+ gregorian: string;
563
+ persian: string;
564
+ arabic: string;
565
+ indian: string;
566
+ en: string;
567
+ fa: string;
568
+ ar: string;
569
+ hi: string;
570
+ single: string;
571
+ multiple: string;
572
+ range: string;
573
+ disable: string;
574
+ onlyMonthPicker: string;
575
+ onlyYearPicker: string;
576
+ };
577
+ titles?: {
578
+ calendar: string;
579
+ locale: string;
580
+ mode: string;
581
+ otherPickers: string;
582
+ gregorian: string;
583
+ persian: string;
584
+ arabic: string;
585
+ indian: string;
586
+ en: string;
587
+ fa: string;
588
+ ar: string;
589
+ hi: string;
590
+ single: string;
591
+ multiple: string;
592
+ range: string;
593
+ disable: string;
594
+ onlyMonthPicker: string;
595
+ onlyYearPicker: string;
596
+ };
597
+ }
598
+
599
+ export default function Settings(props: SettingsProps): React.ReactElement;
600
+ }
601
+
602
+ declare module "react-multi-date-picker/plugins/toolbar" {
603
+ import React, { HTMLAttributes } from "react";
604
+
605
+ interface ToolbarProps
606
+ extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
607
+ position?: string;
608
+ disabled?: boolean;
609
+ className?: string;
610
+ sort?: string[];
611
+ names?: { today: string; deselect: string; close: string };
612
+ }
613
+
614
+ export default function Toolbar(props: ToolbarProps): React.ReactElement;
615
+ }
616
+
617
+ declare module "react-multi-date-picker/plugins/highlight_weekends" {
618
+ export default function highlightWeekends(weekends?: number[]): {
619
+ type: string;
620
+ fn: Function;
621
+ };
622
+ }
623
+
624
+ declare module "react-multi-date-picker/plugins/time_picker" {
625
+ import React, { HTMLAttributes } from "react";
626
+
627
+ interface TimePickerProps
628
+ extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
629
+ position?: string;
630
+ disabled?: boolean;
631
+ hideSeconds?: boolean;
632
+ /**
633
+ * If the calendar is in multiple or range mode,
634
+ * and the time picker position is right or left,
635
+ * a select with the default format (YYYY/MM/DD)
636
+ * will be added to the time picker.
637
+ * So, you can change the format of the select with this prop.
638
+ */
639
+ format?: string;
640
+ header?: boolean;
641
+ }
642
+
643
+ export default function TimePicker(
644
+ props: TimePickerProps
645
+ ): React.ReactElement;
646
+ }
647
+
648
+ declare module "react-multi-date-picker/plugins/analog_time_picker" {
649
+ import React from "react";
650
+
651
+ interface TimePickerProps {
652
+ position?: string;
653
+ disabled?: boolean;
654
+ hideSeconds?: boolean;
655
+ /**
656
+ * If the calendar is in multiple or range mode,
657
+ * and the time picker position is right or left,
658
+ * a select with the default format (YYYY/MM/DD)
659
+ * will be added to the time picker.
660
+ * So, you can change the format of the select with this prop.
661
+ */
662
+ format?: string;
663
+ }
664
+
665
+ export default function AnalogTimePicker(
666
+ props: TimePickerProps
667
+ ): React.ReactElement;
668
+ }
669
+
670
+ declare module "react-multi-date-picker/plugins/range_picker_footer" {
671
+ import React from "react";
672
+
673
+ interface FooterProps {
674
+ position?: string;
675
+ disabled?: boolean;
676
+ format?: string;
677
+ names?: {
678
+ selectedDates: string;
679
+ from: string;
680
+ to: string;
681
+ selectDate: string;
682
+ close: string;
683
+ separator: string;
684
+ };
685
+ }
686
+
687
+ export default function Footer(props: FooterProps): React.ReactElement;
688
+ }
689
+
690
+ declare module "react-multi-date-picker/components/button" {
691
+ import React, { HTMLAttributes } from "react";
692
+
693
+ export default function Buttons(
694
+ props: HTMLAttributes<HTMLButtonElement>
695
+ ): React.ReactElement;
696
+ }
697
+
698
+ declare module "react-multi-date-picker/components/input_icon" {
699
+ import React, { HTMLAttributes } from "react";
700
+
701
+ export default function InputIcon(
702
+ props: HTMLAttributes<HTMLInputElement>
703
+ ): React.ReactElement;
704
+ }
705
+
706
+ declare module "react-multi-date-picker/components/icon" {
707
+ import React, { SVGAttributes } from "react";
708
+
709
+ export default function Icon(
710
+ props: SVGAttributes<SVGElement>
711
+ ): React.ReactElement;
712
+ }