@coreui/vue-pro 4.1.4 → 4.3.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/button/CButton.d.ts +29 -2
- package/dist/components/calendar/CCalendar.d.ts +185 -0
- package/dist/components/calendar/index.d.ts +6 -0
- package/dist/components/date-picker/CDatePicker.d.ts +406 -0
- package/dist/components/date-picker/index.d.ts +6 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +480 -0
- package/dist/components/date-range-picker/index.d.ts +6 -0
- package/dist/components/dropdown/CDropdown.d.ts +25 -0
- package/dist/components/dropdown/CDropdownToggle.d.ts +35 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
- package/dist/components/picker/CPicker.d.ts +11 -0
- package/dist/components/picker/index.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/sidebar/CSidebar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +35 -99
- package/dist/components/smart-table/CSmartTableInterface.d.ts +3 -3
- package/dist/components/time-picker/CTimePicker.d.ts +10 -0
- package/dist/components/time-picker/CTimePickerRollCol.d.ts +27 -0
- package/dist/components/time-picker/index.d.ts +6 -0
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/index.es.js +3726 -1646
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3734 -1644
- 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 +9 -9
- package/src/components/accordion/CAccordionButton.ts +1 -0
- package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.ts.snap +1 -1
- package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.ts.snap +1 -1
- package/src/components/button/CButton.ts +30 -1
- package/src/components/button/__tests__/__snapshots__/CButton.spec.ts.snap +1 -1
- package/src/components/calendar/CCalendar.ts +546 -0
- package/src/components/calendar/index.ts +10 -0
- package/src/components/close-button/CCloseButton.ts +4 -1
- package/src/components/date-picker/CDatePicker.ts +243 -0
- package/src/components/date-picker/index.ts +10 -0
- package/src/components/date-range-picker/CDateRangePicker.ts +635 -0
- package/src/components/date-range-picker/index.ts +10 -0
- package/src/components/dropdown/CDropdown.ts +48 -49
- package/src/components/dropdown/CDropdownMenu.ts +52 -7
- package/src/components/dropdown/CDropdownToggle.ts +93 -29
- package/src/components/dropdown/__tests__/CDropdownMenu.spec.ts +7 -7
- package/src/components/dropdown/__tests__/CDropdownToggle.spec.ts +4 -5
- package/src/components/dropdown/__tests__/__snapshots__/CDropdownToggle.spec.ts.snap +2 -2
- package/src/components/form/CFormCheck.ts +2 -1
- package/src/components/form/CFormSwitch.ts +1 -7
- package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +2 -8
- package/src/components/index.ts +5 -0
- package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +2 -1
- package/src/components/pagination/CSmartPagination.ts +4 -4
- package/src/components/picker/CPicker.ts +220 -0
- package/src/components/picker/index.ts +10 -0
- package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +8 -2
- package/src/components/smart-table/CSmartTable.ts +17 -49
- package/src/components/smart-table/CSmartTableInterface.ts +5 -3
- package/src/components/time-picker/CTimePicker.ts +410 -0
- package/src/components/time-picker/CTimePickerRollCol.ts +58 -0
- package/src/components/time-picker/index.ts +10 -0
- package/src/components/toast/__tests__/__snapshots__/CToastClose.spec.ts.snap +1 -1
- package/src/utils/calendar.ts +193 -0
- package/src/utils/time.ts +58 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const convert12hTo24h = (abbr: 'am' | 'pm', hour: number) => {
|
|
2
|
+
if (abbr === 'am' && hour === 12) {
|
|
3
|
+
return 0
|
|
4
|
+
}
|
|
5
|
+
if (abbr === 'am') {
|
|
6
|
+
return hour
|
|
7
|
+
}
|
|
8
|
+
if (abbr === 'pm' && hour === 12) {
|
|
9
|
+
return 12
|
|
10
|
+
}
|
|
11
|
+
return hour + 12
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const convert24hTo12h = (hour: number) => hour % 12 || 12
|
|
15
|
+
|
|
16
|
+
export const convertTimeToDate = (time: Date | string | null | undefined) =>
|
|
17
|
+
time ? (time instanceof Date ? new Date(time) : new Date(`1970-01-01 ${time}`)) : null
|
|
18
|
+
|
|
19
|
+
export const getAmPm = (date: Date, locale: string) => {
|
|
20
|
+
if (date.toLocaleTimeString(locale).includes('AM')) {
|
|
21
|
+
return 'am'
|
|
22
|
+
}
|
|
23
|
+
if (date.toLocaleTimeString(locale).includes('PM')) {
|
|
24
|
+
return 'pm'
|
|
25
|
+
}
|
|
26
|
+
return date.getHours() >= 12 ? 'pm' : 'am'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const getListOfHours = (locale: string) =>
|
|
30
|
+
Array.from({ length: isAmPm(locale) ? 12 : 24 }, (_, i) => {
|
|
31
|
+
return {
|
|
32
|
+
value: isAmPm(locale) ? i + 1 : i,
|
|
33
|
+
label: (isAmPm(locale) ? i + 1 : i).toLocaleString(locale),
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const getMinutesOrSeconds = (locale: string) =>
|
|
38
|
+
Array.from({ length: 60 }, (_, i) => {
|
|
39
|
+
return {
|
|
40
|
+
value: i,
|
|
41
|
+
label: i.toLocaleString(locale).padStart(2, (0).toLocaleString(locale)),
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
export const getSelectedHour = (date: Date | null, locale: string) =>
|
|
46
|
+
date ? (isAmPm(locale) ? convert24hTo12h(date.getHours()) : date.getHours()) : ''
|
|
47
|
+
|
|
48
|
+
export const getSelectedMinutes = (date: Date | null) => (date ? date.getMinutes() : '')
|
|
49
|
+
|
|
50
|
+
export const getSelectedSeconds = (date: Date | null) => (date ? date.getSeconds() : '')
|
|
51
|
+
|
|
52
|
+
export const isAmPm = (locale: string) =>
|
|
53
|
+
['am', 'AM', 'pm', 'PM'].some((el) => new Date().toLocaleString(locale).includes(el))
|
|
54
|
+
|
|
55
|
+
export const isValidTime = (time: string) => {
|
|
56
|
+
const d = new Date(`1970-01-01 ${time}`)
|
|
57
|
+
return d instanceof Date && d.getTime()
|
|
58
|
+
}
|