@coreui/react-pro 4.13.1 → 5.0.0-alpha.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 +25 -7
- package/dist/components/calendar/utils.d.ts +12 -3
- package/dist/components/close-button/CCloseButton.d.ts +6 -0
- package/dist/components/date-range-picker/CDateRangePicker copy.d.ts +114 -0
- package/dist/components/multi-select/types.d.ts +2 -2
- package/dist/components/multi-select/utils.d.ts +2 -2
- package/dist/components/multi-select-new/CMultiSelect.d.ts +133 -0
- package/dist/components/multi-select-new/CMultiSelectNativeSelect.d.ts +7 -0
- package/dist/components/multi-select-new/CMultiSelectNew.d.ts +121 -0
- package/dist/components/multi-select-new/CMultiSelectOptions.d.ts +16 -0
- package/dist/components/multi-select-new/CMultiSelectSelection.d.ts +11 -0
- package/dist/components/multi-select-new/index.d.ts +2 -0
- package/dist/components/multi-select-new/types.d.ts +15 -0
- package/dist/components/multi-select-new/utils.d.ts +11 -0
- package/dist/components/nav/CNav.d.ts +1 -1
- package/dist/components/navbar/CNavbar.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +4 -0
- package/dist/components/picker/CPicker copy.d.ts +82 -0
- package/dist/components/picker copy/CPicker.d.ts +82 -0
- package/dist/components/smart-table/CSmartTableBody.d.ts +2 -1
- package/dist/components/smart-table/CSmartTableCleaner.d.ts +7 -0
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -3
- package/dist/components/smart-table/types.d.ts +2 -2
- package/dist/components/smart-table/utils.d.ts +3 -1
- package/dist/hooks/index.d.ts +2 -1
- package/dist/index.es.js +523 -265
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +523 -264
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/components/calendar/CCalendar.tsx +396 -193
- package/src/components/calendar/utils.ts +91 -4
- package/src/components/carousel/CCarousel.tsx +9 -5
- package/src/components/close-button/CCloseButton.tsx +9 -1
- package/src/components/date-range-picker/CDateRangePicker.tsx +65 -81
- package/src/components/dropdown/CDropdownMenu.tsx +1 -1
- package/src/components/multi-select/CMultiSelect.tsx +18 -10
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
- package/src/components/multi-select/CMultiSelectOptions.tsx +1 -1
- package/src/components/multi-select/CMultiSelectSelection.tsx +4 -6
- package/src/components/multi-select/types.ts +2 -2
- package/src/components/multi-select/utils.ts +5 -5
- package/src/components/nav/CNav.tsx +2 -2
- package/src/components/navbar/CNavbar.tsx +2 -2
- package/src/components/offcanvas/COffcanvas.tsx +7 -0
- package/src/components/picker/CPicker.tsx +2 -11
- package/src/components/smart-table/CSmartTable.tsx +2 -1
- package/src/components/smart-table/CSmartTableBody.tsx +11 -5
- package/src/components/smart-table/CSmartTableInterface.tsx +1 -3
- package/src/components/smart-table/types.ts +2 -2
- package/src/components/smart-table/utils.ts +40 -5
- package/src/components/time-picker/CTimePicker.tsx +20 -37
- package/src/components/time-picker/utils.ts +5 -1
- package/src/hooks/index.ts +2 -1
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
export const convertIsoWeekToDate = (isoWeek: string) => {
|
|
2
|
+
const [year, week] = isoWeek.split(/w/i)
|
|
3
|
+
// Get date for 4th of January for year
|
|
4
|
+
const date = new Date(Number(year), 0, 4)
|
|
5
|
+
// Get previous Monday, add 7 days for each week after first
|
|
6
|
+
date.setDate(date.getDate() - (date.getDay() || 7) + 1 + (Number(week) - 1) * 7)
|
|
7
|
+
return date
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const convertToDateObject = (
|
|
11
|
+
date: Date | string | null,
|
|
12
|
+
selectionType?: 'day' | 'week' | 'month' | 'year',
|
|
13
|
+
) => {
|
|
14
|
+
// if (date === null) {
|
|
15
|
+
// return null
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
if (date instanceof Date) {
|
|
19
|
+
return date
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (selectionType === 'week') {
|
|
23
|
+
return convertIsoWeekToDate(date as string)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return new Date(Date.parse(date))
|
|
27
|
+
}
|
|
28
|
+
|
|
1
29
|
export const convertToLocalDate = (d: Date, locale: string, options = {}) =>
|
|
2
30
|
d.toLocaleDateString(locale, options)
|
|
3
31
|
|
|
@@ -11,10 +39,50 @@ export const createGroupsInArray = <T>(arr: T[], numberOfGroups: number): T[][]
|
|
|
11
39
|
.map((_, i) => arr.slice(i * perGroup, (i + 1) * perGroup))
|
|
12
40
|
}
|
|
13
41
|
|
|
42
|
+
export const getCalendarDate = (calendarDate: Date, order: number, view: 'days' | 'months' | 'years') => {
|
|
43
|
+
if (order !== 0 && view === 'days') {
|
|
44
|
+
return new Date(Date.UTC(calendarDate.getFullYear(), calendarDate.getMonth() + order, 1))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (order !== 0 && view === 'months') {
|
|
48
|
+
return new Date(Date.UTC(calendarDate.getFullYear() + order, calendarDate.getMonth(), 1))
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (order !== 0 && view === 'years') {
|
|
52
|
+
return new Date(Date.UTC(calendarDate.getFullYear() + (12 * order), calendarDate.getMonth(), 1))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return calendarDate
|
|
56
|
+
}
|
|
57
|
+
|
|
14
58
|
export const getCurrentYear = () => new Date().getFullYear()
|
|
15
59
|
|
|
16
60
|
export const getCurrentMonth = () => new Date().getMonth()
|
|
17
61
|
|
|
62
|
+
export const getDateBySelectionType = (
|
|
63
|
+
date: Date | null,
|
|
64
|
+
selectionType: 'day' | 'week' | 'month' | 'year',
|
|
65
|
+
) => {
|
|
66
|
+
if (date === null) {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (selectionType === 'week') {
|
|
71
|
+
return `${date.getFullYear()}W${getWeekNumber(date)}`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (selectionType === 'month') {
|
|
75
|
+
const monthNumber = `0${date.getMonth() + 1}`.slice(-2)
|
|
76
|
+
return `${date.getFullYear()}-${monthNumber}`
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (selectionType === 'year') {
|
|
80
|
+
return `${date.getFullYear()}`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return date
|
|
84
|
+
}
|
|
85
|
+
|
|
18
86
|
export const getMonthName = (month: number, locale: string) => {
|
|
19
87
|
const d = new Date()
|
|
20
88
|
d.setDate(1)
|
|
@@ -77,6 +145,7 @@ const getMonthDays = (year: number, month: number) => {
|
|
|
77
145
|
month: 'current',
|
|
78
146
|
})
|
|
79
147
|
}
|
|
148
|
+
|
|
80
149
|
return dates
|
|
81
150
|
}
|
|
82
151
|
|
|
@@ -94,22 +163,40 @@ const getTrailingDays = (
|
|
|
94
163
|
month: 'next',
|
|
95
164
|
})
|
|
96
165
|
}
|
|
166
|
+
|
|
97
167
|
return dates
|
|
98
168
|
}
|
|
99
169
|
|
|
170
|
+
export const getDayNumber = (date: Date) =>
|
|
171
|
+
Math.ceil((Number(date) - Number(new Date(date.getFullYear(), 0, 0))) / 1000 / 60 / 60 / 24)
|
|
172
|
+
|
|
173
|
+
export const getWeekNumber = (date: Date) => {
|
|
174
|
+
const week1 = new Date(date.getFullYear(), 0, 4)
|
|
175
|
+
return (
|
|
176
|
+
1 +
|
|
177
|
+
Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + ((week1.getDay() + 6) % 7)) / 7)
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
100
181
|
export const getMonthDetails = (year: number, month: number, firstDayOfWeek: number) => {
|
|
101
182
|
const daysPrevMonth = getLeadingDays(year, month, firstDayOfWeek)
|
|
102
183
|
const daysThisMonth = getMonthDays(year, month)
|
|
103
184
|
const daysNextMonth = getTrailingDays(year, month, daysPrevMonth, daysThisMonth)
|
|
104
185
|
const days = [...daysPrevMonth, ...daysThisMonth, ...daysNextMonth]
|
|
105
|
-
|
|
106
|
-
const weeks: { date: Date; month: string }[][] = []
|
|
186
|
+
const weeks: { weekNumber?: number; days: { date: Date; month: string }[] }[] = []
|
|
107
187
|
|
|
108
188
|
days.forEach((day, index) => {
|
|
109
189
|
if (index % 7 === 0 || weeks.length === 0) {
|
|
110
|
-
weeks.push(
|
|
190
|
+
weeks.push({
|
|
191
|
+
days: [],
|
|
192
|
+
})
|
|
111
193
|
}
|
|
112
|
-
|
|
194
|
+
|
|
195
|
+
if ((index + 1) % 7 === 0) {
|
|
196
|
+
weeks[weeks.length - 1].weekNumber = getWeekNumber(day.date)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
weeks[weeks.length - 1].days.push(day)
|
|
113
200
|
})
|
|
114
201
|
|
|
115
202
|
return weeks
|
|
@@ -226,11 +226,11 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
|
|
|
226
226
|
className={classNames(
|
|
227
227
|
'carousel slide',
|
|
228
228
|
{
|
|
229
|
-
'carousel-dark': dark,
|
|
230
229
|
'carousel-fade': transition === 'crossfade',
|
|
231
230
|
},
|
|
232
231
|
className,
|
|
233
232
|
)}
|
|
233
|
+
{...(dark && { 'data-coreui-theme': 'dark' })}
|
|
234
234
|
onMouseEnter={_pause}
|
|
235
235
|
onMouseLeave={cycle}
|
|
236
236
|
{...(touch && { onTouchStart: handleTouchStart, onTouchMove: handleTouchMove })}
|
|
@@ -244,20 +244,24 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
|
|
|
244
244
|
}}
|
|
245
245
|
>
|
|
246
246
|
{indicators && (
|
|
247
|
-
<
|
|
247
|
+
<div className="carousel-indicators">
|
|
248
248
|
{Array.from({ length: itemsNumber }, (_, i) => i).map((index) => {
|
|
249
249
|
return (
|
|
250
|
-
<
|
|
250
|
+
<button
|
|
251
251
|
key={`indicator${index}`}
|
|
252
252
|
onClick={() => {
|
|
253
253
|
!animating && handleIndicatorClick(index)
|
|
254
254
|
}}
|
|
255
|
-
className={
|
|
255
|
+
className={classNames({
|
|
256
|
+
active: active === index
|
|
257
|
+
})}
|
|
256
258
|
data-coreui-target=""
|
|
259
|
+
{...(active === index && { 'aria-current': true })}
|
|
260
|
+
aria-label={`Slide ${index + 1}`}
|
|
257
261
|
/>
|
|
258
262
|
)
|
|
259
263
|
})}
|
|
260
|
-
</
|
|
264
|
+
</div>
|
|
261
265
|
)}
|
|
262
266
|
<div className="carousel-inner">
|
|
263
267
|
{Children.map(children, (child, index) => {
|
|
@@ -7,18 +7,24 @@ export interface CCloseButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
|
7
7
|
* A string of all className you want applied to the base component.
|
|
8
8
|
*/
|
|
9
9
|
className?: string
|
|
10
|
+
/**
|
|
11
|
+
* Invert the default color.
|
|
12
|
+
*/
|
|
13
|
+
dark?: boolean
|
|
10
14
|
/**
|
|
11
15
|
* Toggle the disabled state for the component.
|
|
12
16
|
*/
|
|
13
17
|
disabled?: boolean
|
|
14
18
|
/**
|
|
15
19
|
* Change the default color to white.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated 5.0.0
|
|
16
22
|
*/
|
|
17
23
|
white?: boolean
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
export const CCloseButton = forwardRef<HTMLButtonElement, CCloseButtonProps>(
|
|
21
|
-
({ className, disabled, white, ...rest }, ref) => {
|
|
27
|
+
({ className, dark, disabled, white, ...rest }, ref) => {
|
|
22
28
|
return (
|
|
23
29
|
<button
|
|
24
30
|
type="button"
|
|
@@ -33,6 +39,7 @@ export const CCloseButton = forwardRef<HTMLButtonElement, CCloseButtonProps>(
|
|
|
33
39
|
)}
|
|
34
40
|
aria-label="Close"
|
|
35
41
|
disabled={disabled}
|
|
42
|
+
{...(dark && { 'data-coreui-theme': 'dark' })}
|
|
36
43
|
{...rest}
|
|
37
44
|
ref={ref}
|
|
38
45
|
/>
|
|
@@ -42,6 +49,7 @@ export const CCloseButton = forwardRef<HTMLButtonElement, CCloseButtonProps>(
|
|
|
42
49
|
|
|
43
50
|
CCloseButton.propTypes = {
|
|
44
51
|
className: PropTypes.string,
|
|
52
|
+
dark: PropTypes.bool,
|
|
45
53
|
disabled: PropTypes.bool,
|
|
46
54
|
white: PropTypes.bool,
|
|
47
55
|
}
|
|
@@ -223,7 +223,9 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
223
223
|
required,
|
|
224
224
|
separator = true,
|
|
225
225
|
selectAdjacementDays,
|
|
226
|
+
selectionType = 'day',
|
|
226
227
|
showAdjacementDays,
|
|
228
|
+
showWeekNumber,
|
|
227
229
|
size,
|
|
228
230
|
startDate,
|
|
229
231
|
text,
|
|
@@ -245,23 +247,19 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
245
247
|
const inputStartRef = useRef<HTMLInputElement>(null)
|
|
246
248
|
const formRef = useRef<HTMLFormElement>()
|
|
247
249
|
|
|
248
|
-
const [_calendarDate, setCalendarDate] = useState<Date>(
|
|
249
|
-
|
|
250
|
-
)
|
|
251
|
-
const [
|
|
252
|
-
const [
|
|
253
|
-
const [_minDate, setMinDate] = useState<Date | null>(minDate ? new Date(minDate) : null)
|
|
254
|
-
const [_startDate, setStartDate] = useState<Date | null>(startDate ? new Date(startDate) : null)
|
|
250
|
+
const [_calendarDate, setCalendarDate] = useState<Date | string | null>(calendarDate ?? null)
|
|
251
|
+
const [_endDate, setEndDate] = useState<Date | string | null>(endDate ?? null)
|
|
252
|
+
const [_maxDate, setMaxDate] = useState<Date | string | null>(maxDate ?? null)
|
|
253
|
+
const [_minDate, setMinDate] = useState<Date | string | null>(minDate ?? null)
|
|
254
|
+
const [_startDate, setStartDate] = useState<Date | string | null>(startDate ?? null)
|
|
255
255
|
const [_visible, setVisible] = useState(visible)
|
|
256
256
|
|
|
257
|
-
const [initialStartDate, setInitialStartDate] = useState<Date | null>(
|
|
258
|
-
startDate
|
|
259
|
-
)
|
|
260
|
-
const [initialEndDate, setInitialEndDate] = useState<Date | null>(
|
|
261
|
-
endDate ? new Date(endDate) : null,
|
|
257
|
+
const [initialStartDate, setInitialStartDate] = useState<Date | string | null>(
|
|
258
|
+
startDate ?? null,
|
|
262
259
|
)
|
|
263
|
-
const [
|
|
264
|
-
const [
|
|
260
|
+
const [initialEndDate, setInitialEndDate] = useState<Date | string | null>(endDate ?? null)
|
|
261
|
+
const [inputStartHoverValue, setInputStartHoverValue] = useState<Date | string | null>(null)
|
|
262
|
+
const [inputEndHoverValue, setInputEndHoverValue] = useState<Date | string | null>(null)
|
|
265
263
|
const [isValid, setIsValid] = useState(valid ?? (invalid === true ? false : undefined))
|
|
266
264
|
const [selectEndDate, setSelectEndDate] = useState(false)
|
|
267
265
|
|
|
@@ -271,24 +269,24 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
271
269
|
|
|
272
270
|
useEffect(() => {
|
|
273
271
|
if (startDate) {
|
|
274
|
-
setStartDate(
|
|
275
|
-
setCalendarDate(
|
|
272
|
+
setStartDate(startDate)
|
|
273
|
+
setCalendarDate(startDate)
|
|
276
274
|
}
|
|
277
275
|
}, [startDate])
|
|
278
276
|
|
|
279
277
|
useEffect(() => {
|
|
280
278
|
if (endDate) {
|
|
281
|
-
setEndDate(
|
|
282
|
-
setCalendarDate(
|
|
279
|
+
setEndDate(endDate)
|
|
280
|
+
setCalendarDate(endDate)
|
|
283
281
|
}
|
|
284
282
|
}, [endDate])
|
|
285
283
|
|
|
286
284
|
useEffect(() => {
|
|
287
|
-
maxDate && setMaxDate(
|
|
285
|
+
maxDate && setMaxDate(maxDate)
|
|
288
286
|
}, [maxDate])
|
|
289
287
|
|
|
290
288
|
useEffect(() => {
|
|
291
|
-
minDate && setMinDate(
|
|
289
|
+
minDate && setMinDate(minDate)
|
|
292
290
|
}, [minDate])
|
|
293
291
|
|
|
294
292
|
useEffect(() => {
|
|
@@ -325,15 +323,21 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
325
323
|
}
|
|
326
324
|
}, [formRef, _startDate, _endDate])
|
|
327
325
|
|
|
328
|
-
const formatDate = (date: Date) => {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
326
|
+
const formatDate = (date: Date | string) => {
|
|
327
|
+
if (selectionType !== 'day') {
|
|
328
|
+
return date
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const _date = new Date(date)
|
|
332
|
+
|
|
333
|
+
return format ?
|
|
334
|
+
dateFormat(_date, format) :
|
|
335
|
+
timepicker ?
|
|
336
|
+
_date.toLocaleString(locale) :
|
|
337
|
+
_date.toLocaleDateString(locale)
|
|
334
338
|
}
|
|
335
339
|
|
|
336
|
-
const setInputValue = (el: HTMLInputElement | null, date: Date | null) => {
|
|
340
|
+
const setInputValue = (el: HTMLInputElement | null, date: Date | string | null) => {
|
|
337
341
|
if (!el) {
|
|
338
342
|
return
|
|
339
343
|
}
|
|
@@ -346,23 +350,17 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
346
350
|
el.value = ''
|
|
347
351
|
}
|
|
348
352
|
|
|
349
|
-
const
|
|
353
|
+
const handleDateHover = (date: Date | string | null) => {
|
|
350
354
|
selectEndDate ? setInputEndHoverValue(date) : setInputStartHoverValue(date)
|
|
351
355
|
}
|
|
352
356
|
|
|
353
|
-
const handleCalendarDateChange = (date: Date, difference?: number) => {
|
|
354
|
-
difference
|
|
355
|
-
? setCalendarDate(new Date(date.getFullYear(), date.getMonth() - difference, 1))
|
|
356
|
-
: setCalendarDate(date)
|
|
357
|
-
}
|
|
358
|
-
|
|
359
357
|
const handleClear = (event: React.MouseEvent<HTMLElement>) => {
|
|
360
358
|
event.stopPropagation()
|
|
361
359
|
setStartDate(null)
|
|
362
360
|
setEndDate(null)
|
|
363
361
|
}
|
|
364
362
|
|
|
365
|
-
const handleEndDateChange = (date: Date | null) => {
|
|
363
|
+
const handleEndDateChange = (date: Date | string | null) => {
|
|
366
364
|
setEndDate(date)
|
|
367
365
|
setInputEndHoverValue(null)
|
|
368
366
|
onEndDateChange && onEndDateChange(date, date ? formatDate(date) : undefined)
|
|
@@ -388,7 +386,7 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
388
386
|
setIsValid(false)
|
|
389
387
|
}
|
|
390
388
|
|
|
391
|
-
const handleStartDateChange = (date: Date | null) => {
|
|
389
|
+
const handleStartDateChange = (date: Date | string | null) => {
|
|
392
390
|
setStartDate(date)
|
|
393
391
|
setInputStartHoverValue(null)
|
|
394
392
|
onStartDateChange && onStartDateChange(date, date ? formatDate(date) : undefined)
|
|
@@ -403,16 +401,13 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
403
401
|
}
|
|
404
402
|
|
|
405
403
|
const InputGroup = () => (
|
|
406
|
-
<div
|
|
407
|
-
className={classNames('input-group', 'picker-input-group', {
|
|
408
|
-
[`input-group-${size}`]: size,
|
|
409
|
-
})}
|
|
410
|
-
>
|
|
404
|
+
<div className="date-picker-input-group">
|
|
411
405
|
<input
|
|
412
406
|
autoComplete="off"
|
|
413
|
-
className={classNames('
|
|
407
|
+
className={classNames('date-picker-input', {
|
|
414
408
|
hover: inputStartHoverValue,
|
|
415
409
|
})}
|
|
410
|
+
// delay={true} TODO
|
|
416
411
|
disabled={disabled}
|
|
417
412
|
{...(id && { name: range ? `${id}-start-date` : `${id}-date` })}
|
|
418
413
|
placeholder={Array.isArray(placeholder) ? placeholder[0] : placeholder}
|
|
@@ -428,18 +423,14 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
428
423
|
onClick={() => setSelectEndDate(false)}
|
|
429
424
|
ref={inputStartRef}
|
|
430
425
|
/>
|
|
431
|
-
{range && separator !== false &&
|
|
432
|
-
<span className="input-group-text">
|
|
433
|
-
<span className="picker-input-group-icon date-picker-arrow-icon"></span>
|
|
434
|
-
</span>
|
|
435
|
-
)}
|
|
426
|
+
{range && separator !== false && <div className="date-picker-separator" />}
|
|
436
427
|
{range && (
|
|
437
428
|
<input
|
|
438
429
|
autoComplete="off"
|
|
439
|
-
className={classNames('
|
|
430
|
+
className={classNames('date-picker-input', {
|
|
440
431
|
hover: inputEndHoverValue,
|
|
441
432
|
})}
|
|
442
|
-
|
|
433
|
+
// delay={true} TODO
|
|
443
434
|
disabled={disabled}
|
|
444
435
|
{...(id && { name: `${id}-end-date` })}
|
|
445
436
|
placeholder={placeholder[1]}
|
|
@@ -456,32 +447,18 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
456
447
|
ref={inputEndRef}
|
|
457
448
|
/>
|
|
458
449
|
)}
|
|
459
|
-
{
|
|
460
|
-
<
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
)
|
|
470
|
-
|
|
471
|
-
<span
|
|
472
|
-
className="picker-input-group-cleaner"
|
|
473
|
-
role="button"
|
|
474
|
-
onClick={(event) => handleClear(event)}
|
|
475
|
-
>
|
|
476
|
-
{typeof cleaner === 'boolean' ? (
|
|
477
|
-
<span className="picker-input-group-icon date-picker-cleaner-icon" />
|
|
478
|
-
) : (
|
|
479
|
-
cleaner
|
|
480
|
-
)}
|
|
481
|
-
</span>
|
|
482
|
-
)}
|
|
483
|
-
</span>
|
|
484
|
-
)}
|
|
450
|
+
{indicator &&
|
|
451
|
+
(typeof indicator === 'boolean' ? <div className="date-picker-indicator" /> : indicator)}
|
|
452
|
+
{cleaner &&
|
|
453
|
+
(_startDate || _endDate) &&
|
|
454
|
+
(typeof cleaner === 'boolean' ? (
|
|
455
|
+
<div className="date-picker-cleaner" onClick={(event) => handleClear(event)} />
|
|
456
|
+
) : (
|
|
457
|
+
React.isValidElement(cleaner) &&
|
|
458
|
+
React.cloneElement(cleaner as React.ReactElement<any>, {
|
|
459
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => handleClear(event),
|
|
460
|
+
})
|
|
461
|
+
))}
|
|
485
462
|
</div>
|
|
486
463
|
)
|
|
487
464
|
|
|
@@ -510,9 +487,10 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
510
487
|
className,
|
|
511
488
|
)}
|
|
512
489
|
disabled={disabled}
|
|
490
|
+
dropdownClassNames="date-picker-dropdown"
|
|
513
491
|
footer={footer || timepicker}
|
|
514
492
|
footerContent={
|
|
515
|
-
<div className="picker-footer">
|
|
493
|
+
<div className="date-picker-footer">
|
|
516
494
|
{todayButton && (
|
|
517
495
|
<CButton
|
|
518
496
|
className="me-auto"
|
|
@@ -608,10 +586,12 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
608
586
|
range={range}
|
|
609
587
|
selectAdjacementDays={selectAdjacementDays}
|
|
610
588
|
selectEndDate={selectEndDate}
|
|
589
|
+
selectionType={selectionType}
|
|
611
590
|
showAdjacementDays={showAdjacementDays}
|
|
591
|
+
showWeekNumber={showWeekNumber}
|
|
612
592
|
startDate={_startDate}
|
|
613
|
-
|
|
614
|
-
onCalendarDateChange={(date) =>
|
|
593
|
+
onDateHover={(date) => handleDateHover(date)}
|
|
594
|
+
onCalendarDateChange={(date) => setCalendarDate(date)}
|
|
615
595
|
onStartDateChange={(date) => handleStartDateChange(date)}
|
|
616
596
|
onEndDateChange={(date) => handleEndDateChange(date)}
|
|
617
597
|
onSelectEndChange={(value) => setSelectEndDate(value)}
|
|
@@ -626,7 +606,7 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
626
606
|
disabled={_startDate === null ? true : false}
|
|
627
607
|
locale={locale}
|
|
628
608
|
onTimeChange={(_, __, date) => date && handleStartDateChange(date)}
|
|
629
|
-
time={_startDate}
|
|
609
|
+
time={_startDate && new Date(_startDate)}
|
|
630
610
|
variant="select"
|
|
631
611
|
/>
|
|
632
612
|
<CTimePicker
|
|
@@ -634,7 +614,7 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
634
614
|
disabled={_endDate === null ? true : false}
|
|
635
615
|
locale={locale}
|
|
636
616
|
onTimeChange={(_, __, date) => date && handleEndDateChange(date)}
|
|
637
|
-
time={_endDate}
|
|
617
|
+
time={_endDate && new Date(_endDate)}
|
|
638
618
|
variant="select"
|
|
639
619
|
/>
|
|
640
620
|
</>
|
|
@@ -658,7 +638,11 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
|
|
|
658
638
|
? date && handleStartDateChange(date)
|
|
659
639
|
: date && handleEndDateChange(date)
|
|
660
640
|
}
|
|
661
|
-
time={
|
|
641
|
+
time={
|
|
642
|
+
index === 0
|
|
643
|
+
? _startDate && new Date(_startDate)
|
|
644
|
+
: _endDate && new Date(_endDate)
|
|
645
|
+
}
|
|
662
646
|
variant="select"
|
|
663
647
|
/>
|
|
664
648
|
))
|
|
@@ -46,7 +46,6 @@ export const CDropdownMenu = forwardRef<HTMLDivElement | HTMLUListElement, CDrop
|
|
|
46
46
|
className={classNames(
|
|
47
47
|
'dropdown-menu',
|
|
48
48
|
{
|
|
49
|
-
'dropdown-menu-dark': dark,
|
|
50
49
|
show: visible,
|
|
51
50
|
},
|
|
52
51
|
alignment && alignmentClassNames(alignment),
|
|
@@ -56,6 +55,7 @@ export const CDropdownMenu = forwardRef<HTMLDivElement | HTMLUListElement, CDrop
|
|
|
56
55
|
role="menu"
|
|
57
56
|
aria-hidden={!visible}
|
|
58
57
|
{...(!popper && { 'data-coreui-popper': 'static' })}
|
|
58
|
+
{...(dark && { 'data-coreui-theme': 'dark' })}
|
|
59
59
|
{...rest}
|
|
60
60
|
>
|
|
61
61
|
{Component === 'ul'
|
|
@@ -243,7 +243,7 @@ export const CMultiSelect = forwardRef<HTMLDivElement, CMultiSelectProps>(
|
|
|
243
243
|
if (
|
|
244
244
|
allowCreateOptions &&
|
|
245
245
|
filteredOptions.some(
|
|
246
|
-
(option) => option.
|
|
246
|
+
(option) => option.label && option.label.toLowerCase() === searchValue.toLowerCase(),
|
|
247
247
|
)
|
|
248
248
|
) {
|
|
249
249
|
return false
|
|
@@ -354,7 +354,7 @@ export const CMultiSelect = forwardRef<HTMLDivElement, CMultiSelectProps>(
|
|
|
354
354
|
setSelected([
|
|
355
355
|
...selected,
|
|
356
356
|
filteredOptions.find(
|
|
357
|
-
(option) => String(option.
|
|
357
|
+
(option) => String(option.label).toLowerCase() === searchValue.toLowerCase(),
|
|
358
358
|
) as Option,
|
|
359
359
|
])
|
|
360
360
|
}
|
|
@@ -435,7 +435,6 @@ export const CMultiSelect = forwardRef<HTMLDivElement, CMultiSelectProps>(
|
|
|
435
435
|
valid={valid}
|
|
436
436
|
>
|
|
437
437
|
<CMultiSelectNativeSelect
|
|
438
|
-
className='form-multi-select'
|
|
439
438
|
id={id}
|
|
440
439
|
multiple={multiple}
|
|
441
440
|
options={selected}
|
|
@@ -452,9 +451,7 @@ export const CMultiSelect = forwardRef<HTMLDivElement, CMultiSelectProps>(
|
|
|
452
451
|
className={classNames(
|
|
453
452
|
'form-multi-select',
|
|
454
453
|
{
|
|
455
|
-
'form-multi-select-with-cleaner': cleaner,
|
|
456
454
|
[`form-multi-select-${size}`]: size,
|
|
457
|
-
'form-multi-select-selection-tags': multiple && selectionType === 'tags',
|
|
458
455
|
disabled,
|
|
459
456
|
'is-invalid': invalid,
|
|
460
457
|
'is-valid': valid,
|
|
@@ -494,7 +491,7 @@ export const CMultiSelect = forwardRef<HTMLDivElement, CMultiSelectProps>(
|
|
|
494
491
|
placeholder: `${selected.length} ${selectionTypeCounterText}`,
|
|
495
492
|
})}
|
|
496
493
|
{...(selected.length > 0 &&
|
|
497
|
-
!multiple && { placeholder: selected.map((option) => option.
|
|
494
|
+
!multiple && { placeholder: selected.map((option) => option.label)[0] })}
|
|
498
495
|
{...(multiple &&
|
|
499
496
|
selected.length > 0 &&
|
|
500
497
|
selectionType !== 'counter' && { size: searchValue.length + 2 })}
|
|
@@ -502,13 +499,24 @@ export const CMultiSelect = forwardRef<HTMLDivElement, CMultiSelectProps>(
|
|
|
502
499
|
></input>
|
|
503
500
|
)}
|
|
504
501
|
</CMultiSelectSelection>
|
|
505
|
-
|
|
502
|
+
<div className="form-multi-select-buttons">
|
|
503
|
+
{!disabled && cleaner && selected.length > 0 && (
|
|
504
|
+
<button
|
|
505
|
+
type="button"
|
|
506
|
+
className="form-multi-select-cleaner"
|
|
507
|
+
onClick={() => handleDeselectAll()}
|
|
508
|
+
></button>
|
|
509
|
+
)}
|
|
506
510
|
<button
|
|
507
511
|
type="button"
|
|
508
|
-
className="form-multi-select-
|
|
509
|
-
onClick={() =>
|
|
512
|
+
className="form-multi-select-indicator"
|
|
513
|
+
onClick={(event) => {
|
|
514
|
+
event.preventDefault()
|
|
515
|
+
event.stopPropagation()
|
|
516
|
+
setVisible(!_visible)
|
|
517
|
+
}}
|
|
510
518
|
></button>
|
|
511
|
-
|
|
519
|
+
</div>
|
|
512
520
|
</div>
|
|
513
521
|
<div className="form-multi-select-dropdown" role="menu" ref={dropdownRef}>
|
|
514
522
|
{multiple && selectAll && (
|
|
@@ -77,7 +77,7 @@ export const CMultiSelectOptions = forwardRef<HTMLDivElement, CMultiSelectOption
|
|
|
77
77
|
onKeyDown={(event) => handleKeyDown(event, option as Option)}
|
|
78
78
|
tabIndex={0}
|
|
79
79
|
>
|
|
80
|
-
{optionsTemplate ? optionsTemplate(option as Option) : option.
|
|
80
|
+
{optionsTemplate ? optionsTemplate(option as Option) : option.label}
|
|
81
81
|
</div>
|
|
82
82
|
) : (
|
|
83
83
|
<div className="form-multi-select-optgroup-label" key={index}>
|
|
@@ -48,15 +48,13 @@ export const CMultiSelectSelection = forwardRef<HTMLSpanElement, CMultiSelectSel
|
|
|
48
48
|
if (selectionType === 'tags') {
|
|
49
49
|
return (
|
|
50
50
|
<span className="form-multi-select-tag" key={index}>
|
|
51
|
-
{option.
|
|
51
|
+
{option.label}
|
|
52
52
|
{!option.disabled && (
|
|
53
53
|
<button
|
|
54
54
|
className="form-multi-select-tag-delete"
|
|
55
55
|
aria-label="Close"
|
|
56
56
|
onClick={() => onRemove && onRemove(option)}
|
|
57
|
-
|
|
58
|
-
<span aria-hidden="true">×</span>
|
|
59
|
-
</button>
|
|
57
|
+
/>
|
|
60
58
|
)}
|
|
61
59
|
</span>
|
|
62
60
|
)
|
|
@@ -67,11 +65,11 @@ export const CMultiSelectSelection = forwardRef<HTMLSpanElement, CMultiSelectSel
|
|
|
67
65
|
selectionType === 'text' &&
|
|
68
66
|
selected.map((option, index) => (
|
|
69
67
|
<span key={index}>
|
|
70
|
-
{option.
|
|
68
|
+
{option.label}
|
|
71
69
|
{index === selected.length - 1 ? '' : ','}
|
|
72
70
|
</span>
|
|
73
71
|
))}
|
|
74
|
-
{!multiple && !search && selected.map((option) => option.
|
|
72
|
+
{!multiple && !search && selected.map((option) => option.label)[0]}
|
|
75
73
|
{children}
|
|
76
74
|
</span>
|
|
77
75
|
)
|
|
@@ -2,7 +2,7 @@ export type Option = {
|
|
|
2
2
|
custom?: boolean
|
|
3
3
|
disabled?: boolean
|
|
4
4
|
selected?: boolean
|
|
5
|
-
|
|
5
|
+
label: string
|
|
6
6
|
value: number | string
|
|
7
7
|
[key: string]: number | string | any
|
|
8
8
|
}
|
|
@@ -15,7 +15,7 @@ export type OptionsGroup = {
|
|
|
15
15
|
|
|
16
16
|
export type SelectedOption = {
|
|
17
17
|
disabled?: boolean
|
|
18
|
-
|
|
18
|
+
label: string
|
|
19
19
|
value: number | string
|
|
20
20
|
[key: string]: number | string | any
|
|
21
21
|
}
|