@coreui/react-pro 4.11.3 → 4.12.0-beta.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/README.md +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/calendar/CCalendar.d.ts +4 -4
- package/dist/components/date-range-picker/CDateRangePicker copy.d.ts +114 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +49 -1
- package/dist/components/multi-select/CMultiSelect.d.ts +34 -3
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +4 -5
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +4 -2
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -0
- package/dist/components/multi-select/types.d.ts +7 -3
- package/dist/components/multi-select/utils.d.ts +5 -5
- 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/picker/CPicker copy.d.ts +82 -0
- package/dist/components/picker/CPicker.d.ts +14 -56
- package/dist/components/picker copy/CPicker.d.ts +82 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/time-picker/CTimePicker.d.ts +41 -1
- package/dist/components/tooltip/CTooltip.d.ts +3 -3
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/useColorModes.d.ts +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +2385 -2403
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2386 -2401
- package/dist/index.js.map +1 -1
- package/dist/props.d.ts +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/isRTL.d.ts +2 -0
- package/package.json +15 -15
- package/src/components/accordion/index.ts +1 -7
- package/src/components/calendar/CCalendar.tsx +49 -64
- package/src/components/calendar/__tests__/__snapshots__/CCalendar.spec.tsx.snap +601 -555
- package/src/components/calendar/utils.ts +1 -1
- package/src/components/date-picker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +599 -561
- package/src/components/date-range-picker/CDateRangePicker.tsx +208 -107
- package/src/components/date-range-picker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1197 -1121
- package/src/components/date-range-picker/utils.ts +2 -2
- package/src/components/dropdown/CDropdownMenu.tsx +5 -4
- package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
- package/src/components/element-cover/CElementCover.tsx +1 -0
- package/src/components/form/CFormSelect.tsx +3 -1
- package/src/components/modal/CModal.tsx +2 -0
- package/src/components/multi-select/CMultiSelect.tsx +200 -79
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +34 -24
- package/src/components/multi-select/CMultiSelectOptions.tsx +25 -23
- package/src/components/multi-select/CMultiSelectSelection.tsx +36 -7
- package/src/components/multi-select/__tests__/CMultiSelect.spec.tsx +25 -14
- package/src/components/multi-select/__tests__/CMultiSelectNativeSelect.spec.tsx +1 -1
- package/src/components/multi-select/__tests__/CMultiSelectOptions.spec.tsx +4 -4
- package/src/components/multi-select/__tests__/CMultiSelectSelection.spec.tsx +0 -1
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelect.spec.tsx.snap +136 -30
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectNativeSelect.spec.tsx.snap +2 -0
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectOptions.spec.tsx.snap +3 -1
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelection.spec.tsx.snap +2 -2
- package/src/components/multi-select/types.ts +9 -4
- package/src/components/multi-select/utils.ts +56 -39
- package/src/components/picker/CPicker.tsx +113 -138
- package/src/components/popover/CPopover.tsx +61 -26
- package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +2 -1
- package/src/components/progress/CProgress.tsx +1 -0
- package/src/components/sidebar/CSidebar.tsx +2 -2
- package/src/components/smart-table/CSmartTable.tsx +22 -10
- package/src/components/smart-table/CSmartTableBody.tsx +3 -5
- package/src/components/smart-table/CSmartTableHead.tsx +5 -6
- package/src/components/smart-table/__tests__/CSmartTable.spec.tsx +1 -1
- package/src/components/smart-table/__tests__/__snapshots__/CSmartTable.spec.tsx.snap +580 -0
- package/src/components/spinner/CSpinner.tsx +4 -2
- package/src/components/spinner/__tests__/__snapshots__/CSpinner.spec.tsx.snap +2 -2
- package/src/components/table/CTable.tsx +2 -1
- package/src/components/time-picker/CTimePicker.tsx +182 -82
- package/src/components/time-picker/__tests__/__snapshots__/CTimePicker.spec.tsx.snap +1078 -0
- package/src/components/tooltip/CTooltip.tsx +65 -31
- package/src/components/tooltip/__tests__/CTooltip.spec.tsx +1 -1
- package/src/components/virtual-scroller/CVirtualScroller.tsx +0 -1
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useColorModes.ts +55 -0
- package/src/hooks/useForkedRef.ts +1 -1
- package/src/index.ts +1 -0
- package/src/props.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/isRTL.ts +13 -0
- package/src/components/multi-select/__tests__/CMultiSelectCleaner.spec.tsx +0 -15
- package/src/components/multi-select/__tests__/CMultiSelectSearchInput.spec.tsx +0 -17
- package/src/components/multi-select/__tests__/CMultiSelectSelectAllButton.spec.tsx +0 -21
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectCleaner.spec.tsx.snap +0 -19
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSearchInput.spec.tsx.snap +0 -20
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelectAllButton.spec.tsx.snap +0 -24
- package/src/components/smart-table/CSmartTableCleaner.tsx +0 -37
|
@@ -2,7 +2,7 @@ import React, { forwardRef, ReactNode, useEffect, useRef, useState } from 'react
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { CButton } from '../button'
|
|
6
6
|
import { CFormControlWrapper, CFormControlWrapperProps } from '../form/CFormControlWrapper'
|
|
7
7
|
import { CPicker, CPickerProps } from './../picker/CPicker'
|
|
8
8
|
|
|
@@ -18,14 +18,12 @@ import {
|
|
|
18
18
|
isValidTime,
|
|
19
19
|
} from './utils'
|
|
20
20
|
|
|
21
|
+
import { Colors } from '../../types'
|
|
21
22
|
import type { LocalizedTimePartials } from './types'
|
|
22
23
|
|
|
23
24
|
export interface CTimePickerProps
|
|
24
25
|
extends Omit<CFormControlWrapperProps, 'floatingLabel'>,
|
|
25
|
-
Omit<
|
|
26
|
-
CPickerProps,
|
|
27
|
-
'autoClose' | 'component' | 'dark' | 'placeholder' | 'variant' | 'onChange'
|
|
28
|
-
> {
|
|
26
|
+
Omit<CPickerProps, 'placeholder'> {
|
|
29
27
|
/**
|
|
30
28
|
* Set if the component should use the 12/24 hour format. If `true` forces the interface to a 12-hour format. If `false` forces the interface into a 24-hour format. If `auto` the current locale will determine the 12 or 24-hour interface by default locales.
|
|
31
29
|
*
|
|
@@ -36,10 +34,49 @@ export interface CTimePickerProps
|
|
|
36
34
|
* A string of all className you want applied to the component.
|
|
37
35
|
*/
|
|
38
36
|
className?: string
|
|
37
|
+
/**
|
|
38
|
+
* Toggle visibility or set the content of cancel button.
|
|
39
|
+
*/
|
|
40
|
+
cancelButton?: boolean | ReactNode
|
|
41
|
+
/**
|
|
42
|
+
* Sets the color context of the cancel button to one of CoreUI’s themed colors.
|
|
43
|
+
*
|
|
44
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
|
|
45
|
+
*/
|
|
46
|
+
cancelButtonColor?: Colors
|
|
47
|
+
/**
|
|
48
|
+
* Size the cancel button small or large.
|
|
49
|
+
*/
|
|
50
|
+
cancelButtonSize?: 'sm' | 'lg'
|
|
51
|
+
/**
|
|
52
|
+
* Set the cancel button variant to an outlined button or a ghost button.
|
|
53
|
+
*/
|
|
54
|
+
cancelButtonVariant?: 'outline' | 'ghost'
|
|
55
|
+
/**
|
|
56
|
+
* A string of all className you want applied to the component.
|
|
57
|
+
*/
|
|
39
58
|
/**
|
|
40
59
|
* Toggle visibility or set the content of the cleaner button.
|
|
41
60
|
*/
|
|
42
61
|
cleaner?: ReactNode | boolean
|
|
62
|
+
/**
|
|
63
|
+
* Toggle visibility or set the content of confirm button.
|
|
64
|
+
*/
|
|
65
|
+
confirmButton?: boolean | ReactNode
|
|
66
|
+
/**
|
|
67
|
+
* Sets the color context of the confirm button to one of CoreUI’s themed colors.
|
|
68
|
+
*
|
|
69
|
+
* @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
|
|
70
|
+
*/
|
|
71
|
+
confirmButtonColor?: Colors
|
|
72
|
+
/**
|
|
73
|
+
* Size the confirm button small or large.
|
|
74
|
+
*/
|
|
75
|
+
confirmButtonSize?: 'sm' | 'lg'
|
|
76
|
+
/**
|
|
77
|
+
* Set the confirm button variant to an outlined button or a ghost button.
|
|
78
|
+
*/
|
|
79
|
+
confirmButtonVariant?: 'outline' | 'ghost'
|
|
43
80
|
/**
|
|
44
81
|
* Toggle visibility or set the content of the input indicator.
|
|
45
82
|
*/
|
|
@@ -90,8 +127,16 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
90
127
|
(
|
|
91
128
|
{
|
|
92
129
|
ampm = 'auto',
|
|
130
|
+
cancelButton = 'Cancel',
|
|
131
|
+
cancelButtonColor = 'primary',
|
|
132
|
+
cancelButtonSize = 'sm',
|
|
133
|
+
cancelButtonVariant = 'ghost',
|
|
93
134
|
className,
|
|
94
135
|
cleaner = true,
|
|
136
|
+
confirmButton = 'OK',
|
|
137
|
+
confirmButtonColor = 'primary',
|
|
138
|
+
confirmButtonSize = 'sm',
|
|
139
|
+
confirmButtonVariant,
|
|
95
140
|
container = 'dropdown',
|
|
96
141
|
disabled,
|
|
97
142
|
feedback,
|
|
@@ -121,9 +166,12 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
121
166
|
},
|
|
122
167
|
ref,
|
|
123
168
|
) => {
|
|
169
|
+
const formRef = useRef<HTMLFormElement>()
|
|
124
170
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
171
|
+
|
|
125
172
|
const [date, setDate] = useState<Date | null>(convertTimeToDate(time))
|
|
126
173
|
const [initialDate, setInitialDate] = useState<Date | null>(null)
|
|
174
|
+
const [isValid, setIsValid] = useState(valid || (invalid && false))
|
|
127
175
|
const [_ampm, setAmPm] = useState<'am' | 'pm'>(date ? getAmPm(new Date(date), locale) : 'am')
|
|
128
176
|
const [_visible, setVisible] = useState(visible)
|
|
129
177
|
|
|
@@ -138,6 +186,10 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
138
186
|
setDate(convertTimeToDate(time))
|
|
139
187
|
}, [time])
|
|
140
188
|
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
setIsValid(valid || (invalid && false))
|
|
191
|
+
}, [valid, invalid])
|
|
192
|
+
|
|
141
193
|
useEffect(() => {
|
|
142
194
|
setLocalizedTimePartials(getLocalizedTimePartials(locale, ampm))
|
|
143
195
|
|
|
@@ -153,12 +205,40 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
153
205
|
date && setAmPm(getAmPm(new Date(date), locale))
|
|
154
206
|
}, [date])
|
|
155
207
|
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (inputRef.current && inputRef.current.form) {
|
|
210
|
+
formRef.current = inputRef.current.form
|
|
211
|
+
}
|
|
212
|
+
}, [inputRef])
|
|
213
|
+
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
if (formRef.current) {
|
|
216
|
+
formRef.current.addEventListener('submit', (event) => {
|
|
217
|
+
setTimeout(() => handleFormValidation(event.target as HTMLFormElement))
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
handleFormValidation(formRef.current)
|
|
221
|
+
}
|
|
222
|
+
}, [formRef, date])
|
|
223
|
+
|
|
156
224
|
const handleClear = (event: React.MouseEvent<HTMLElement>) => {
|
|
157
225
|
event.stopPropagation()
|
|
158
226
|
setDate(null)
|
|
159
227
|
onTimeChange && onTimeChange(null)
|
|
160
228
|
}
|
|
161
229
|
|
|
230
|
+
const handleFormValidation = (form: HTMLFormElement) => {
|
|
231
|
+
if (!form.classList.contains('was-validated')) {
|
|
232
|
+
return
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (date) {
|
|
236
|
+
return setIsValid(true)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
setIsValid(false)
|
|
240
|
+
}
|
|
241
|
+
|
|
162
242
|
const handleTimeChange = (set: 'hours' | 'minutes' | 'seconds' | 'toggle', value: string) => {
|
|
163
243
|
const _date = date || new Date('1970-01-01')
|
|
164
244
|
|
|
@@ -192,10 +272,11 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
192
272
|
}
|
|
193
273
|
|
|
194
274
|
const InputGroup = () => (
|
|
195
|
-
<
|
|
196
|
-
<
|
|
275
|
+
<div className="time-picker-input-group">
|
|
276
|
+
<input
|
|
197
277
|
autoComplete="off"
|
|
198
|
-
|
|
278
|
+
className="time-picker-input"
|
|
279
|
+
// delay={true}
|
|
199
280
|
disabled={disabled}
|
|
200
281
|
onChange={(event) =>
|
|
201
282
|
isValidTime(event.target.value) && setDate(convertTimeToDate(event.target.value))
|
|
@@ -205,105 +286,88 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
205
286
|
required={required}
|
|
206
287
|
ref={inputRef}
|
|
207
288
|
/>
|
|
208
|
-
{
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
className="picker-input-group-cleaner"
|
|
222
|
-
role="button"
|
|
223
|
-
onClick={(event) => handleClear(event)}
|
|
224
|
-
>
|
|
225
|
-
{typeof cleaner === 'boolean' ? (
|
|
226
|
-
<span className="picker-input-group-icon time-picker-cleaner-icon" />
|
|
227
|
-
) : (
|
|
228
|
-
cleaner
|
|
229
|
-
)}
|
|
230
|
-
</span>
|
|
231
|
-
)}
|
|
232
|
-
</CInputGroupText>
|
|
233
|
-
)}
|
|
234
|
-
</CInputGroup>
|
|
289
|
+
{indicator &&
|
|
290
|
+
(typeof indicator === 'boolean' ? <div className="time-picker-indicator" /> : indicator)}
|
|
291
|
+
{cleaner &&
|
|
292
|
+
date &&
|
|
293
|
+
(typeof cleaner === 'boolean' ? (
|
|
294
|
+
<div className="time-picker-cleaner" onClick={(event) => handleClear(event)} />
|
|
295
|
+
) : (
|
|
296
|
+
React.isValidElement(cleaner) &&
|
|
297
|
+
React.cloneElement(cleaner as React.ReactElement<any>, {
|
|
298
|
+
onClick: (event: React.MouseEvent<HTMLElement>) => handleClear(event),
|
|
299
|
+
})
|
|
300
|
+
))}
|
|
301
|
+
</div>
|
|
235
302
|
)
|
|
236
303
|
|
|
237
304
|
const TimePickerSelect = () => {
|
|
238
305
|
return (
|
|
239
306
|
<>
|
|
240
307
|
<span className="time-picker-inline-icon" />
|
|
241
|
-
<
|
|
308
|
+
<select
|
|
309
|
+
className="time-picker-inline-select"
|
|
242
310
|
disabled={disabled}
|
|
243
|
-
options={
|
|
244
|
-
localizedTimePartials &&
|
|
245
|
-
localizedTimePartials.listOfHours?.map((option) => {
|
|
246
|
-
return {
|
|
247
|
-
value: option.value.toString(),
|
|
248
|
-
label: option.label,
|
|
249
|
-
}
|
|
250
|
-
})
|
|
251
|
-
}
|
|
252
311
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) =>
|
|
253
312
|
handleTimeChange('hours', event.target.value)
|
|
254
313
|
}
|
|
255
314
|
value={getSelectedHour(date, locale)}
|
|
256
|
-
|
|
315
|
+
>
|
|
316
|
+
{localizedTimePartials &&
|
|
317
|
+
localizedTimePartials.listOfHours.map((option, index) => (
|
|
318
|
+
<option value={option.value.toString()} key={index}>
|
|
319
|
+
{option.label}
|
|
320
|
+
</option>
|
|
321
|
+
))}
|
|
322
|
+
</select>
|
|
257
323
|
<>:</>
|
|
258
|
-
<
|
|
324
|
+
<select
|
|
325
|
+
className="time-picker-inline-select"
|
|
259
326
|
disabled={disabled}
|
|
260
|
-
options={
|
|
261
|
-
localizedTimePartials &&
|
|
262
|
-
localizedTimePartials.listOfMinutes.map((option) => {
|
|
263
|
-
return {
|
|
264
|
-
value: option.value.toString(),
|
|
265
|
-
label: option.label,
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
327
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) =>
|
|
270
328
|
handleTimeChange('minutes', event.target.value)
|
|
271
329
|
}
|
|
272
330
|
value={getSelectedMinutes(date)}
|
|
273
|
-
|
|
331
|
+
>
|
|
332
|
+
{localizedTimePartials &&
|
|
333
|
+
localizedTimePartials.listOfMinutes.map((option, index) => (
|
|
334
|
+
<option value={option.value.toString()} key={index}>
|
|
335
|
+
{option.label}
|
|
336
|
+
</option>
|
|
337
|
+
))}
|
|
338
|
+
</select>
|
|
274
339
|
{seconds && (
|
|
275
340
|
<>
|
|
276
341
|
<>:</>
|
|
277
|
-
<
|
|
342
|
+
<select
|
|
343
|
+
className="time-picker-inline-select"
|
|
278
344
|
disabled={disabled}
|
|
279
|
-
options={
|
|
280
|
-
localizedTimePartials &&
|
|
281
|
-
localizedTimePartials.listOfSeconds.map((option) => {
|
|
282
|
-
return {
|
|
283
|
-
value: option.value.toString(),
|
|
284
|
-
label: option.label,
|
|
285
|
-
}
|
|
286
|
-
})
|
|
287
|
-
}
|
|
288
345
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) =>
|
|
289
346
|
handleTimeChange('seconds', event.target.value)
|
|
290
347
|
}
|
|
291
348
|
value={getSelectedSeconds(date)}
|
|
292
|
-
|
|
349
|
+
>
|
|
350
|
+
{localizedTimePartials &&
|
|
351
|
+
localizedTimePartials.listOfSeconds.map((option, index) => (
|
|
352
|
+
<option value={option.value.toString()} key={index}>
|
|
353
|
+
{option.label}
|
|
354
|
+
</option>
|
|
355
|
+
))}
|
|
356
|
+
</select>
|
|
293
357
|
</>
|
|
294
358
|
)}
|
|
295
359
|
{localizedTimePartials && localizedTimePartials.hour12 && (
|
|
296
|
-
<
|
|
360
|
+
<select
|
|
361
|
+
className="time-picker-inline-select"
|
|
297
362
|
disabled={disabled}
|
|
298
|
-
options={[
|
|
299
|
-
{ value: 'am', label: 'AM' },
|
|
300
|
-
{ value: 'pm', label: 'PM' },
|
|
301
|
-
]}
|
|
302
363
|
onChange={(event: React.ChangeEvent<HTMLSelectElement>) =>
|
|
303
364
|
handleTimeChange('toggle', event.target.value)
|
|
304
365
|
}
|
|
305
366
|
value={_ampm}
|
|
306
|
-
|
|
367
|
+
>
|
|
368
|
+
<option value="am">AM</option>
|
|
369
|
+
<option value="pm">PM</option>
|
|
370
|
+
</select>
|
|
307
371
|
)}
|
|
308
372
|
</>
|
|
309
373
|
)
|
|
@@ -348,29 +412,57 @@ export const CTimePicker = forwardRef<HTMLDivElement | HTMLLIElement, CTimePicke
|
|
|
348
412
|
feedbackInvalid={feedbackInvalid}
|
|
349
413
|
feedbackValid={feedbackValid}
|
|
350
414
|
id={id}
|
|
351
|
-
invalid={
|
|
415
|
+
invalid={isValid === false ? true : false}
|
|
352
416
|
label={label}
|
|
353
417
|
text={text}
|
|
354
418
|
tooltipFeedback={tooltipFeedback}
|
|
355
|
-
valid={
|
|
419
|
+
valid={isValid}
|
|
356
420
|
>
|
|
357
421
|
<CPicker
|
|
358
422
|
className={classNames(
|
|
359
423
|
'time-picker',
|
|
360
424
|
{
|
|
361
|
-
|
|
362
|
-
|
|
425
|
+
[`time-picker-${size}`]: size,
|
|
426
|
+
disabled: disabled,
|
|
427
|
+
'is-invalid': isValid === false ? true : false,
|
|
428
|
+
'is-valid': isValid,
|
|
363
429
|
},
|
|
364
430
|
className,
|
|
365
431
|
)}
|
|
366
432
|
container={container}
|
|
367
433
|
disabled={disabled}
|
|
434
|
+
dropdownClassNames="time-picker-dropdown"
|
|
368
435
|
footer={footer}
|
|
436
|
+
footerContent={
|
|
437
|
+
<div className="time-picker-footer">
|
|
438
|
+
{cancelButton && (
|
|
439
|
+
<CButton
|
|
440
|
+
color={cancelButtonColor}
|
|
441
|
+
size={cancelButtonSize}
|
|
442
|
+
variant={cancelButtonVariant}
|
|
443
|
+
onClick={() => {
|
|
444
|
+
initialDate && setDate(new Date(initialDate))
|
|
445
|
+
setVisible(false)
|
|
446
|
+
}}
|
|
447
|
+
>
|
|
448
|
+
{cancelButton}
|
|
449
|
+
</CButton>
|
|
450
|
+
)}
|
|
451
|
+
{confirmButton && (
|
|
452
|
+
<CButton
|
|
453
|
+
color={confirmButtonColor}
|
|
454
|
+
size={confirmButtonSize}
|
|
455
|
+
variant={confirmButtonVariant}
|
|
456
|
+
onClick={() => {
|
|
457
|
+
setVisible(false)
|
|
458
|
+
}}
|
|
459
|
+
>
|
|
460
|
+
{confirmButton}
|
|
461
|
+
</CButton>
|
|
462
|
+
)}
|
|
463
|
+
</div>
|
|
464
|
+
}
|
|
369
465
|
id={id}
|
|
370
|
-
onCancel={() => {
|
|
371
|
-
initialDate && setDate(new Date(initialDate))
|
|
372
|
-
setVisible(false)
|
|
373
|
-
}}
|
|
374
466
|
onHide={() => {
|
|
375
467
|
setVisible(false)
|
|
376
468
|
onHide && onHide()
|
|
@@ -402,7 +494,15 @@ CTimePicker.propTypes = {
|
|
|
402
494
|
...CFormControlWrapper.propTypes,
|
|
403
495
|
...CPicker.propTypes,
|
|
404
496
|
ampm: PropTypes.oneOfType([PropTypes.oneOf<'auto'>(['auto']), PropTypes.bool]),
|
|
497
|
+
cancelButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
498
|
+
cancelButtonColor: CButton.propTypes?.color,
|
|
499
|
+
cancelButtonSize: CButton.propTypes?.size,
|
|
500
|
+
cancelButtonVariant: CButton.propTypes?.variant,
|
|
405
501
|
className: PropTypes.string,
|
|
502
|
+
confirmButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
503
|
+
confirmButtonColor: CButton.propTypes?.color,
|
|
504
|
+
confirmButtonSize: CButton.propTypes?.size,
|
|
505
|
+
confirmButtonVariant: CButton.propTypes?.variant,
|
|
406
506
|
locale: PropTypes.string,
|
|
407
507
|
onTimeChange: PropTypes.func,
|
|
408
508
|
required: PropTypes.bool,
|