@coreui/react-pro 4.2.0-beta.0 → 4.2.0-beta.1
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/README.md +1 -1
- package/dist/components/calendar/CCalendar.d.ts +27 -10
- package/dist/components/calendar/CCalendar.utils.d.ts +2 -1
- package/dist/components/daterangepicker/CDateRangePicker.d.ts +26 -11
- package/dist/components/picker/CPicker.d.ts +50 -9
- package/dist/components/timepicker/CTimePicker.d.ts +9 -13
- package/dist/components/timepicker/CTimePicker.utils.d.ts +13 -0
- package/dist/index.es.js +243 -206
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +243 -206
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +21 -0
- package/dist/utils/time.d.ts +17 -0
- package/package.json +3 -2
- package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.tsx.snap +2 -0
- package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.tsx.snap +2 -0
- package/src/components/calendar/CCalendar.tsx +104 -58
- package/src/components/calendar/__tests__/CCalendar.spec.tsx +9 -0
- package/src/components/calendar/__tests__/__snapshots__/CCalendar.spec.tsx.snap +573 -0
- package/src/components/datepicker/CDatePicker.tsx +1 -0
- package/src/components/datepicker/__tests__/CDatePicker.spec.tsx +9 -0
- package/src/components/datepicker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +617 -0
- package/src/components/daterangepicker/CDateRangePicker.tsx +152 -91
- package/src/components/daterangepicker/__tests__/CDateRangePicker.spec.tsx +9 -0
- package/src/components/daterangepicker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1201 -0
- package/src/components/dropdown/CDropdownMenu.tsx +5 -3
- package/src/components/picker/CPicker.tsx +99 -34
- package/src/components/picker/__tests__/CPicker.spec.tsx +9 -0
- package/src/components/picker/__tests__/__snapshots__/CPicker.spec.tsx.snap +23 -0
- package/src/components/timepicker/CTimePicker.tsx +66 -87
- package/src/components/timepicker/CTimePickerRollCol.tsx +7 -1
- package/src/components/timepicker/__tests__/CTimePicker.spec.tsx +9 -0
- package/src/{components/calendar/CCalendar.utils.ts → utils/calendar.ts} +11 -1
- package/src/utils/time.ts +58 -0
- package/src/components/timepicker/CTimePicker.utils.ts +0 -27
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const convertToLocalDate: (d: Date, locale: string, options?: {}) => string;
|
|
2
|
+
export declare const convertToLocalTime: (d: Date, locale: string, options?: {}) => string;
|
|
3
|
+
export declare const createGroupsInArray: (arr: any[], numberOfGroups: number) => any[][];
|
|
4
|
+
export declare const getCurrentYear: () => number;
|
|
5
|
+
export declare const getCurrentMonth: () => number;
|
|
6
|
+
export declare const getMonthName: (month: number, locale: string) => string;
|
|
7
|
+
export declare const getMonthsNames: (locale: string) => string[];
|
|
8
|
+
export declare const getYears: (year: number) => number[];
|
|
9
|
+
export declare const getMonthDetails: (year: number, month: number, firstDayOfWeek: number) => {
|
|
10
|
+
date: Date;
|
|
11
|
+
month: string;
|
|
12
|
+
}[][];
|
|
13
|
+
export declare const isDateDisabled: (date: Date, min?: Date | null | undefined, max?: Date | null | undefined, dates?: Date[] | Date[][] | undefined) => boolean | undefined;
|
|
14
|
+
export declare const isDateInRange: (date: Date, start: Date | null, end: Date | null) => boolean | null;
|
|
15
|
+
export declare const isDateSelected: (date: Date, start: Date | null, end: Date | null) => boolean | null;
|
|
16
|
+
export declare const isEndDate: (date: Date, start: Date | null, end: Date | null) => boolean | null;
|
|
17
|
+
export declare const isLastDayOfMonth: (date: Date) => boolean;
|
|
18
|
+
export declare const isSameDateAs: (date: Date, date2: Date) => boolean;
|
|
19
|
+
export declare const isStartDate: (date: Date, start: Date | null, end: Date | null) => boolean | null;
|
|
20
|
+
export declare const isToday: (date: Date) => boolean;
|
|
21
|
+
export declare const isValidDate: (date: string) => number | false;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const convert12hTo24h: (abbr: 'am' | 'pm', hour: number) => number;
|
|
2
|
+
export declare const convert24hTo12h: (hour: number) => number;
|
|
3
|
+
export declare const convertTimeToDate: (time: Date | string | null | undefined) => Date | null;
|
|
4
|
+
export declare const getAmPm: (date: Date, locale: string) => "am" | "pm";
|
|
5
|
+
export declare const getListOfHours: (locale: string) => {
|
|
6
|
+
value: number;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const getMinutesOrSeconds: (locale: string) => {
|
|
10
|
+
value: number;
|
|
11
|
+
label: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const getSelectedHour: (date: Date | null, locale: string) => number | "";
|
|
14
|
+
export declare const getSelectedMinutes: (date: Date | null) => number | "";
|
|
15
|
+
export declare const getSelectedSeconds: (date: Date | null) => number | "";
|
|
16
|
+
export declare const isAmPm: (locale: string) => boolean;
|
|
17
|
+
export declare const isValidTime: (time: string) => number | false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreui/react-pro",
|
|
3
|
-
"version": "4.2.0-beta.
|
|
3
|
+
"version": "4.2.0-beta.1",
|
|
4
4
|
"description": "UI Components Library for React.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"build": "rollup -c"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@coreui/icons-pro": "^
|
|
38
|
+
"@coreui/icons-pro": "^3.0.0-0",
|
|
39
39
|
"@coreui/icons-react": "^2.0.0",
|
|
40
40
|
"@popperjs/core": "^2.11.2",
|
|
41
41
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"classnames": "^2.3.1",
|
|
50
50
|
"prop-types": "^15.8.1",
|
|
51
51
|
"react": "^17.0.2",
|
|
52
|
+
"react-device-detect": "^2.1.2",
|
|
52
53
|
"react-dom": "^17.0.2",
|
|
53
54
|
"react-popper": "^2.2.5",
|
|
54
55
|
"react-transition-group": "^4.4.2",
|
|
@@ -5,6 +5,7 @@ exports[`CAccordionButton customize 1`] = `
|
|
|
5
5
|
<button
|
|
6
6
|
aria-expanded="true"
|
|
7
7
|
class="accordion-button collapsed bazinga"
|
|
8
|
+
type="button"
|
|
8
9
|
>
|
|
9
10
|
Test
|
|
10
11
|
</button>
|
|
@@ -16,6 +17,7 @@ exports[`loads and displays CAccordionButton component 1`] = `
|
|
|
16
17
|
<button
|
|
17
18
|
aria-expanded="true"
|
|
18
19
|
class="accordion-button collapsed"
|
|
20
|
+
type="button"
|
|
19
21
|
>
|
|
20
22
|
Test
|
|
21
23
|
</button>
|
|
@@ -8,6 +8,7 @@ exports[`CAccordionHeader customize 1`] = `
|
|
|
8
8
|
<button
|
|
9
9
|
aria-expanded="true"
|
|
10
10
|
class="accordion-button collapsed"
|
|
11
|
+
type="button"
|
|
11
12
|
>
|
|
12
13
|
Test
|
|
13
14
|
</button>
|
|
@@ -23,6 +24,7 @@ exports[`loads and displays CAccordionHeader component 1`] = `
|
|
|
23
24
|
<button
|
|
24
25
|
aria-expanded="true"
|
|
25
26
|
class="accordion-button collapsed"
|
|
27
|
+
type="button"
|
|
26
28
|
>
|
|
27
29
|
Test
|
|
28
30
|
</button>
|
|
@@ -3,12 +3,13 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
5
|
import { CButton } from '../button/CButton'
|
|
6
|
+
|
|
6
7
|
import {
|
|
7
8
|
createGroupsInArray,
|
|
8
9
|
getMonthDetails,
|
|
9
10
|
getMonthsNames,
|
|
10
11
|
getYears,
|
|
11
|
-
|
|
12
|
+
isDateDisabled,
|
|
12
13
|
isDateInRange,
|
|
13
14
|
isDateSelected,
|
|
14
15
|
isLastDayOfMonth,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
isToday,
|
|
17
18
|
isStartDate,
|
|
18
19
|
isEndDate,
|
|
19
|
-
} from '
|
|
20
|
+
} from '../../utils/calendar'
|
|
20
21
|
|
|
21
22
|
export interface CCalendarProps {
|
|
22
23
|
/**
|
|
@@ -37,21 +38,32 @@ export interface CCalendarProps {
|
|
|
37
38
|
endDate?: Date | string | null
|
|
38
39
|
/**
|
|
39
40
|
* Sets the day of start week.
|
|
40
|
-
* 0 - Sunday,
|
|
41
|
+
* - 0 - Sunday,
|
|
42
|
+
* - 1 - Monday,
|
|
43
|
+
* - 2 - Tuesday,
|
|
44
|
+
* - 3 - Wednesday,
|
|
45
|
+
* - 4 - Thursday,
|
|
46
|
+
* - 5 - Friday,
|
|
47
|
+
* - 6 - Saturday,
|
|
48
|
+
* - 7 - Sunday
|
|
49
|
+
*
|
|
50
|
+
* @default 1
|
|
41
51
|
*/
|
|
42
52
|
firstDayOfWeek?: number
|
|
43
53
|
/**
|
|
44
|
-
* Sets the default locale for components. If not set, it is inherited from the
|
|
54
|
+
* Sets the default locale for components. If not set, it is inherited from the browser.
|
|
55
|
+
*
|
|
56
|
+
* @default 'default'
|
|
45
57
|
*/
|
|
46
58
|
locale?: string
|
|
47
59
|
/**
|
|
48
60
|
* Max selectable date.
|
|
49
61
|
*/
|
|
50
|
-
maxDate?: Date
|
|
62
|
+
maxDate?: Date | string
|
|
51
63
|
/**
|
|
52
64
|
* Min selectable date.
|
|
53
65
|
*/
|
|
54
|
-
minDate?: Date
|
|
66
|
+
minDate?: Date | string
|
|
55
67
|
/**
|
|
56
68
|
* Show arrows navigation.
|
|
57
69
|
*/
|
|
@@ -59,19 +71,19 @@ export interface CCalendarProps {
|
|
|
59
71
|
/**
|
|
60
72
|
* The custom next icon.
|
|
61
73
|
*/
|
|
62
|
-
|
|
74
|
+
navNextIcon?: ReactNode
|
|
63
75
|
/**
|
|
64
76
|
* The custom next double icon.
|
|
65
77
|
*/
|
|
66
|
-
|
|
78
|
+
navNextDoubleIcon?: ReactNode
|
|
67
79
|
/**
|
|
68
80
|
* The custom prev icon.
|
|
69
81
|
*/
|
|
70
|
-
|
|
82
|
+
navPrevIcon?: ReactNode
|
|
71
83
|
/**
|
|
72
84
|
* The custom prev double icon.
|
|
73
85
|
*/
|
|
74
|
-
|
|
86
|
+
navPrevDoubleIcon?: ReactNode
|
|
75
87
|
/**
|
|
76
88
|
* Allow range selection.
|
|
77
89
|
*/
|
|
@@ -85,9 +97,11 @@ export interface CCalendarProps {
|
|
|
85
97
|
*/
|
|
86
98
|
startDate?: Date | string | null
|
|
87
99
|
/**
|
|
88
|
-
* Set length of day name.
|
|
100
|
+
* Set length or format of day name.
|
|
101
|
+
*
|
|
102
|
+
* @default 2
|
|
89
103
|
*/
|
|
90
|
-
|
|
104
|
+
weekdayFormat?: number | 'long' | 'narrow' | 'short'
|
|
91
105
|
/**
|
|
92
106
|
* Callback fired when the user hovers over the calendar cell.
|
|
93
107
|
*/
|
|
@@ -104,6 +118,10 @@ export interface CCalendarProps {
|
|
|
104
118
|
* Callback fired when the end date changed.
|
|
105
119
|
*/
|
|
106
120
|
onEndDateChange?: (date: Date | null) => void
|
|
121
|
+
/**
|
|
122
|
+
* Callback fired when the view type of calendar changed.
|
|
123
|
+
*/
|
|
124
|
+
onViewChanged?: (view: string) => void
|
|
107
125
|
}
|
|
108
126
|
|
|
109
127
|
export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
@@ -113,22 +131,23 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
113
131
|
disabledDates,
|
|
114
132
|
endDate,
|
|
115
133
|
firstDayOfWeek = 1,
|
|
116
|
-
locale =
|
|
134
|
+
locale = 'default',
|
|
117
135
|
maxDate,
|
|
118
136
|
minDate,
|
|
119
137
|
navigation = true,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
navNextIcon,
|
|
139
|
+
navNextDoubleIcon,
|
|
140
|
+
navPrevIcon,
|
|
141
|
+
navPrevDoubleIcon,
|
|
124
142
|
range,
|
|
125
143
|
selectEndDate,
|
|
126
144
|
startDate,
|
|
127
|
-
|
|
145
|
+
weekdayFormat = 2,
|
|
128
146
|
onCalendarDateChange,
|
|
129
147
|
onStartDateChange,
|
|
130
148
|
onEndDateChange,
|
|
131
149
|
onCalendarCellHover,
|
|
150
|
+
onViewChanged,
|
|
132
151
|
},
|
|
133
152
|
ref,
|
|
134
153
|
) => {
|
|
@@ -140,6 +159,9 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
140
159
|
const [_selectEndDate, setSelectEndDate] = useState(selectEndDate)
|
|
141
160
|
const [view, setView] = useState('days')
|
|
142
161
|
|
|
162
|
+
const _maxDate = maxDate ? new Date(maxDate) : null
|
|
163
|
+
const _minDate = minDate ? new Date(minDate) : null
|
|
164
|
+
|
|
143
165
|
useEffect(() => {
|
|
144
166
|
if (calendarDate) {
|
|
145
167
|
const d = new Date(calendarDate)
|
|
@@ -152,12 +174,14 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
152
174
|
setStartDate(null)
|
|
153
175
|
return
|
|
154
176
|
}
|
|
177
|
+
|
|
155
178
|
if (startDate) {
|
|
156
179
|
const d = new Date(startDate)
|
|
157
180
|
if (_startDate === null) {
|
|
158
181
|
setStartDate(d)
|
|
159
182
|
return
|
|
160
183
|
}
|
|
184
|
+
|
|
161
185
|
if (_startDate && !isSameDateAs(d, _startDate)) {
|
|
162
186
|
setStartDate(d)
|
|
163
187
|
}
|
|
@@ -169,12 +193,14 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
169
193
|
setEndDate(null)
|
|
170
194
|
return
|
|
171
195
|
}
|
|
196
|
+
|
|
172
197
|
if (endDate) {
|
|
173
198
|
const d = new Date(endDate)
|
|
174
199
|
if (_endDate === null) {
|
|
175
200
|
setEndDate(d)
|
|
176
201
|
return
|
|
177
202
|
}
|
|
203
|
+
|
|
178
204
|
if (_endDate && !isSameDateAs(d, _endDate)) {
|
|
179
205
|
setEndDate(d)
|
|
180
206
|
}
|
|
@@ -193,6 +219,10 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
193
219
|
setSelectEndDate(selectEndDate)
|
|
194
220
|
}, [selectEndDate])
|
|
195
221
|
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
onViewChanged && onViewChanged(view)
|
|
224
|
+
}, [view])
|
|
225
|
+
|
|
196
226
|
const setCalendarPage = (years: number, months = 0, setMonth?: number) => {
|
|
197
227
|
const year = _calendarDate.getFullYear()
|
|
198
228
|
const month = _calendarDate.getMonth()
|
|
@@ -207,7 +237,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
207
237
|
}
|
|
208
238
|
|
|
209
239
|
const handleCellOnClick = (date: Date) => {
|
|
210
|
-
if (
|
|
240
|
+
if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
|
|
211
241
|
return
|
|
212
242
|
}
|
|
213
243
|
|
|
@@ -230,7 +260,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
230
260
|
}
|
|
231
261
|
|
|
232
262
|
const handleCellMouseEnter = (date: Date) => {
|
|
233
|
-
if (
|
|
263
|
+
if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
|
|
234
264
|
return
|
|
235
265
|
}
|
|
236
266
|
onCalendarCellHover && onCalendarCellHover(date)
|
|
@@ -243,25 +273,29 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
243
273
|
const handleNavigationOnClick = (direction: string, double = false) => {
|
|
244
274
|
if (direction === 'prev') {
|
|
245
275
|
if (double) {
|
|
246
|
-
setCalendarPage(view
|
|
276
|
+
setCalendarPage(view === 'years' ? -10 : -1)
|
|
247
277
|
return
|
|
248
278
|
}
|
|
279
|
+
|
|
249
280
|
if (view !== 'days') {
|
|
250
281
|
setCalendarPage(-1)
|
|
251
282
|
return
|
|
252
283
|
}
|
|
284
|
+
|
|
253
285
|
setCalendarPage(0, -1)
|
|
254
286
|
return
|
|
255
287
|
}
|
|
256
288
|
if (direction === 'next') {
|
|
257
289
|
if (double) {
|
|
258
|
-
setCalendarPage(view
|
|
290
|
+
setCalendarPage(view === 'years' ? 10 : 1)
|
|
259
291
|
return
|
|
260
292
|
}
|
|
293
|
+
|
|
261
294
|
if (view !== 'days') {
|
|
262
295
|
setCalendarPage(1)
|
|
263
296
|
return
|
|
264
297
|
}
|
|
298
|
+
|
|
265
299
|
setCalendarPage(0, 1)
|
|
266
300
|
return
|
|
267
301
|
}
|
|
@@ -284,7 +318,11 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
284
318
|
{weekDays.map(({ date }: { date: Date }, idx: number) => (
|
|
285
319
|
<th key={idx} className="calendar-cell">
|
|
286
320
|
<div className="calendar-header-cell-inner">
|
|
287
|
-
{
|
|
321
|
+
{typeof weekdayFormat === 'string'
|
|
322
|
+
? date.toLocaleDateString(locale, { weekday: weekdayFormat })
|
|
323
|
+
: date
|
|
324
|
+
.toLocaleDateString(locale, { weekday: 'long' })
|
|
325
|
+
.slice(0, weekdayFormat)}
|
|
288
326
|
</div>
|
|
289
327
|
</th>
|
|
290
328
|
))}
|
|
@@ -300,7 +338,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
300
338
|
<td
|
|
301
339
|
className={classNames('calendar-cell', {
|
|
302
340
|
today: isToday(date),
|
|
303
|
-
disabled:
|
|
341
|
+
disabled: isDateDisabled(date, _minDate, _maxDate, disabledDates),
|
|
304
342
|
next: month === 'next',
|
|
305
343
|
previous: month === 'previous',
|
|
306
344
|
last: isLastDayOfMonth(date),
|
|
@@ -383,23 +421,25 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
383
421
|
size="sm"
|
|
384
422
|
onClick={() => handleNavigationOnClick('prev', true)}
|
|
385
423
|
>
|
|
386
|
-
{
|
|
387
|
-
|
|
424
|
+
{navPrevDoubleIcon ? (
|
|
425
|
+
navPrevDoubleIcon
|
|
388
426
|
) : (
|
|
389
427
|
<span className="calendar-nav-icon calendar-nav-icon-double-prev" />
|
|
390
428
|
)}
|
|
391
429
|
</CButton>
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
430
|
+
{view === 'days' && (
|
|
431
|
+
<CButton
|
|
432
|
+
color="transparent"
|
|
433
|
+
size="sm"
|
|
434
|
+
onClick={() => handleNavigationOnClick('prev')}
|
|
435
|
+
>
|
|
436
|
+
{navPrevIcon ? (
|
|
437
|
+
navPrevIcon
|
|
438
|
+
) : (
|
|
439
|
+
<span className="calendar-nav-icon calendar-nav-icon-prev" />
|
|
440
|
+
)}
|
|
441
|
+
</CButton>
|
|
442
|
+
)}
|
|
403
443
|
</div>
|
|
404
444
|
)}
|
|
405
445
|
<div className="calendar-nav-date">
|
|
@@ -418,24 +458,26 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
418
458
|
</div>
|
|
419
459
|
{navigation && (
|
|
420
460
|
<div className="calendar-nav-next">
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
461
|
+
{view === 'days' && (
|
|
462
|
+
<CButton
|
|
463
|
+
color="transparent"
|
|
464
|
+
size="sm"
|
|
465
|
+
onClick={() => handleNavigationOnClick('next')}
|
|
466
|
+
>
|
|
467
|
+
{navNextIcon ? (
|
|
468
|
+
navNextIcon
|
|
469
|
+
) : (
|
|
470
|
+
<span className="calendar-nav-icon calendar-nav-icon-next" />
|
|
471
|
+
)}
|
|
472
|
+
</CButton>
|
|
473
|
+
)}
|
|
432
474
|
<CButton
|
|
433
475
|
color="transparent"
|
|
434
476
|
size="sm"
|
|
435
477
|
onClick={() => handleNavigationOnClick('next', true)}
|
|
436
478
|
>
|
|
437
|
-
{
|
|
438
|
-
|
|
479
|
+
{navNextDoubleIcon ? (
|
|
480
|
+
navNextDoubleIcon
|
|
439
481
|
) : (
|
|
440
482
|
<span className="calendar-nav-icon calendar-nav-icon-double-next" />
|
|
441
483
|
)}
|
|
@@ -447,7 +489,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
|
|
|
447
489
|
}
|
|
448
490
|
|
|
449
491
|
return (
|
|
450
|
-
<div className=
|
|
492
|
+
<div className={classNames('calendar', view)} ref={ref}>
|
|
451
493
|
<Navigation />
|
|
452
494
|
<Calendar />
|
|
453
495
|
</div>
|
|
@@ -462,21 +504,25 @@ CCalendar.propTypes = {
|
|
|
462
504
|
endDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
463
505
|
firstDayOfWeek: PropTypes.number,
|
|
464
506
|
locale: PropTypes.string,
|
|
465
|
-
maxDate: PropTypes.instanceOf(Date),
|
|
466
|
-
minDate: PropTypes.instanceOf(Date),
|
|
507
|
+
maxDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
508
|
+
minDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
467
509
|
navigation: PropTypes.bool,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
510
|
+
navNextIcon: PropTypes.node,
|
|
511
|
+
navNextDoubleIcon: PropTypes.node,
|
|
512
|
+
navPrevIcon: PropTypes.node,
|
|
513
|
+
navPrevDoubleIcon: PropTypes.node,
|
|
472
514
|
range: PropTypes.bool,
|
|
473
515
|
selectEndDate: PropTypes.bool,
|
|
474
516
|
startDate: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string]),
|
|
475
|
-
|
|
517
|
+
weekdayFormat: PropTypes.oneOfType([
|
|
518
|
+
PropTypes.number,
|
|
519
|
+
PropTypes.oneOf<'long' | 'narrow' | 'short'>(['long', 'narrow', 'short']),
|
|
520
|
+
]),
|
|
476
521
|
onCalendarCellHover: PropTypes.func,
|
|
477
522
|
onCalendarDateChange: PropTypes.func,
|
|
478
523
|
onStartDateChange: PropTypes.func,
|
|
479
524
|
onEndDateChange: PropTypes.func,
|
|
525
|
+
onViewChanged: PropTypes.func,
|
|
480
526
|
}
|
|
481
527
|
|
|
482
528
|
CCalendar.displayName = 'CCalendar'
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import '@testing-library/jest-dom/extend-expect'
|
|
4
|
+
import { CCalendar } from '../CCalendar'
|
|
5
|
+
|
|
6
|
+
test('loads and displays CCalendar component', async () => {
|
|
7
|
+
const { container } = render(<CCalendar />)
|
|
8
|
+
expect(container).toMatchSnapshot()
|
|
9
|
+
})
|