@coreui/vue-pro 5.0.0-rc.1 → 5.0.0-rc.3
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/cjs/components/accordion/CAccordion.js +1 -0
- package/dist/cjs/components/accordion/CAccordion.js.map +1 -1
- package/dist/cjs/components/accordion/index.js.map +1 -1
- package/dist/cjs/components/alert/index.js.map +1 -1
- package/dist/cjs/components/avatar/index.js.map +1 -1
- package/dist/cjs/components/backdrop/index.js.map +1 -1
- package/dist/cjs/components/badge/CBadge.d.ts +34 -14
- package/dist/cjs/components/badge/CBadge.js +14 -6
- package/dist/cjs/components/badge/CBadge.js.map +1 -1
- package/dist/cjs/components/badge/index.js.map +1 -1
- package/dist/cjs/components/breadcrumb/index.js.map +1 -1
- package/dist/cjs/components/button/index.js.map +1 -1
- package/dist/cjs/components/button-group/index.js.map +1 -1
- package/dist/cjs/components/calendar/CCalendar.d.ts +6 -6
- package/dist/cjs/components/calendar/CCalendar.js +3 -3
- package/dist/cjs/components/calendar/index.js.map +1 -1
- package/dist/cjs/components/callout/index.js.map +1 -1
- package/dist/cjs/components/card/CCard.d.ts +20 -0
- package/dist/cjs/components/card/CCard.js +8 -0
- package/dist/cjs/components/card/CCard.js.map +1 -1
- package/dist/cjs/components/card/index.js.map +1 -1
- package/dist/cjs/components/carousel/index.js.map +1 -1
- package/dist/cjs/components/close-button/index.js.map +1 -1
- package/dist/cjs/components/collapse/index.js.map +1 -1
- package/dist/cjs/components/conditional-teleport/CConditionalTeleport.d.ts +2 -2
- package/dist/cjs/components/conditional-teleport/CConditionalTeleport.js +1 -1
- package/dist/cjs/components/conditional-teleport/index.js.map +1 -1
- package/dist/cjs/components/date-picker/CDatePicker.d.ts +13 -13
- package/dist/cjs/components/date-picker/CDatePicker.js +6 -6
- package/dist/cjs/components/date-picker/index.js.map +1 -1
- package/dist/cjs/components/date-range-picker/CDateRangePicker.d.ts +13 -13
- package/dist/cjs/components/date-range-picker/CDateRangePicker.js +6 -6
- package/dist/cjs/components/date-range-picker/index.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdown.d.ts +4 -4
- package/dist/cjs/components/dropdown/CDropdown.js +2 -2
- package/dist/cjs/components/dropdown/CDropdownToggle.d.ts +2 -2
- package/dist/cjs/components/dropdown/CDropdownToggle.js +2 -2
- package/dist/cjs/components/dropdown/CDropdownToggle.js.map +1 -1
- package/dist/cjs/components/dropdown/index.js.map +1 -1
- package/dist/cjs/components/element-cover/index.js.map +1 -1
- package/dist/cjs/components/footer/index.js.map +1 -1
- package/dist/cjs/components/form/CFormCheck.js +1 -1
- package/dist/cjs/components/form/CFormCheck.js.map +1 -1
- package/dist/cjs/components/form/CFormSwitch.js +1 -0
- package/dist/cjs/components/form/CFormSwitch.js.map +1 -1
- package/dist/cjs/components/form/CFormTextarea.js +1 -0
- package/dist/cjs/components/form/CFormTextarea.js.map +1 -1
- package/dist/cjs/components/form/index.js.map +1 -1
- package/dist/cjs/components/grid/index.js.map +1 -1
- package/dist/cjs/components/header/index.js.map +1 -1
- package/dist/cjs/components/image/index.js.map +1 -1
- package/dist/cjs/components/link/index.js.map +1 -1
- package/dist/cjs/components/list-group/index.js.map +1 -1
- package/dist/cjs/components/loading-button/index.js.map +1 -1
- package/dist/cjs/components/modal/CModal.d.ts +2 -2
- package/dist/cjs/components/modal/CModal.js +1 -1
- package/dist/cjs/components/modal/index.js.map +1 -1
- package/dist/cjs/components/multi-select/index.js.map +1 -1
- package/dist/cjs/components/nav/CNavLink.js +2 -2
- package/dist/cjs/components/nav/CNavLink.js.map +1 -1
- package/dist/cjs/components/nav/index.js.map +1 -1
- package/dist/cjs/components/navbar/index.js.map +1 -1
- package/dist/cjs/components/offcanvas/COffcanvas.js +4 -1
- package/dist/cjs/components/offcanvas/COffcanvas.js.map +1 -1
- package/dist/cjs/components/offcanvas/index.js.map +1 -1
- package/dist/cjs/components/pagination/CPaginationItem.js +1 -1
- package/dist/cjs/components/pagination/CPaginationItem.js.map +1 -1
- package/dist/cjs/components/pagination/index.js.map +1 -1
- package/dist/cjs/components/picker/index.js.map +1 -1
- package/dist/cjs/components/placeholder/index.js.map +1 -1
- package/dist/cjs/components/popover/CPopover.d.ts +2 -2
- package/dist/cjs/components/popover/CPopover.js +1 -1
- package/dist/cjs/components/popover/index.js.map +1 -1
- package/dist/cjs/components/progress/CProgress.d.ts +2 -2
- package/dist/cjs/components/progress/CProgress.js +1 -1
- package/dist/cjs/components/progress/index.js.map +1 -1
- package/dist/cjs/components/sidebar/index.js.map +1 -1
- package/dist/cjs/components/smart-pagination/index.js.map +1 -1
- package/dist/cjs/components/smart-table/index.js.map +1 -1
- package/dist/cjs/components/spinner/index.js.map +1 -1
- package/dist/cjs/components/table/index.js.map +1 -1
- package/dist/cjs/components/tabs/index.js.map +1 -1
- package/dist/cjs/components/time-picker/CTimePicker.js +53 -21
- package/dist/cjs/components/time-picker/CTimePicker.js.map +1 -1
- package/dist/cjs/components/time-picker/index.js.map +1 -1
- package/dist/cjs/components/time-picker/utils.d.ts +67 -10
- package/dist/cjs/components/time-picker/utils.js +107 -22
- package/dist/cjs/components/time-picker/utils.js.map +1 -1
- package/dist/cjs/components/toast/index.js.map +1 -1
- package/dist/cjs/components/tooltip/CTooltip.d.ts +2 -2
- package/dist/cjs/components/tooltip/CTooltip.js +1 -1
- package/dist/cjs/components/tooltip/index.js.map +1 -1
- package/dist/cjs/components/virtual-scroller/index.js.map +1 -1
- package/dist/cjs/components/widgets/index.js.map +1 -1
- package/dist/esm/components/accordion/CAccordion.js +2 -1
- package/dist/esm/components/accordion/CAccordion.js.map +1 -1
- package/dist/esm/components/accordion/index.js.map +1 -1
- package/dist/esm/components/alert/index.js.map +1 -1
- package/dist/esm/components/avatar/index.js.map +1 -1
- package/dist/esm/components/backdrop/index.js.map +1 -1
- package/dist/esm/components/badge/CBadge.d.ts +34 -14
- package/dist/esm/components/badge/CBadge.js +14 -6
- package/dist/esm/components/badge/CBadge.js.map +1 -1
- package/dist/esm/components/badge/index.js.map +1 -1
- package/dist/esm/components/breadcrumb/index.js.map +1 -1
- package/dist/esm/components/button/index.js.map +1 -1
- package/dist/esm/components/button-group/index.js.map +1 -1
- package/dist/esm/components/calendar/CCalendar.d.ts +6 -6
- package/dist/esm/components/calendar/CCalendar.js +3 -3
- package/dist/esm/components/calendar/index.js.map +1 -1
- package/dist/esm/components/callout/index.js.map +1 -1
- package/dist/esm/components/card/CCard.d.ts +20 -0
- package/dist/esm/components/card/CCard.js +8 -0
- package/dist/esm/components/card/CCard.js.map +1 -1
- package/dist/esm/components/card/index.js.map +1 -1
- package/dist/esm/components/carousel/index.js.map +1 -1
- package/dist/esm/components/close-button/index.js.map +1 -1
- package/dist/esm/components/collapse/index.js.map +1 -1
- package/dist/esm/components/conditional-teleport/CConditionalTeleport.d.ts +2 -2
- package/dist/esm/components/conditional-teleport/CConditionalTeleport.js +1 -1
- package/dist/esm/components/conditional-teleport/index.js.map +1 -1
- package/dist/esm/components/date-picker/CDatePicker.d.ts +13 -13
- package/dist/esm/components/date-picker/CDatePicker.js +6 -6
- package/dist/esm/components/date-picker/index.js.map +1 -1
- package/dist/esm/components/date-range-picker/CDateRangePicker.d.ts +13 -13
- package/dist/esm/components/date-range-picker/CDateRangePicker.js +6 -6
- package/dist/esm/components/date-range-picker/index.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdown.d.ts +4 -4
- package/dist/esm/components/dropdown/CDropdown.js +2 -2
- package/dist/esm/components/dropdown/CDropdownToggle.d.ts +2 -2
- package/dist/esm/components/dropdown/CDropdownToggle.js +2 -2
- package/dist/esm/components/dropdown/CDropdownToggle.js.map +1 -1
- package/dist/esm/components/dropdown/index.js.map +1 -1
- package/dist/esm/components/element-cover/index.js.map +1 -1
- package/dist/esm/components/footer/index.js.map +1 -1
- package/dist/esm/components/form/CFormCheck.js +1 -1
- package/dist/esm/components/form/CFormCheck.js.map +1 -1
- package/dist/esm/components/form/CFormSwitch.js +1 -0
- package/dist/esm/components/form/CFormSwitch.js.map +1 -1
- package/dist/esm/components/form/CFormTextarea.js +1 -0
- package/dist/esm/components/form/CFormTextarea.js.map +1 -1
- package/dist/esm/components/form/index.js.map +1 -1
- package/dist/esm/components/grid/index.js.map +1 -1
- package/dist/esm/components/header/index.js.map +1 -1
- package/dist/esm/components/image/index.js.map +1 -1
- package/dist/esm/components/link/index.js.map +1 -1
- package/dist/esm/components/list-group/index.js.map +1 -1
- package/dist/esm/components/loading-button/index.js.map +1 -1
- package/dist/esm/components/modal/CModal.d.ts +2 -2
- package/dist/esm/components/modal/CModal.js +1 -1
- package/dist/esm/components/modal/index.js.map +1 -1
- package/dist/esm/components/multi-select/index.js.map +1 -1
- package/dist/esm/components/nav/CNavLink.js +2 -2
- package/dist/esm/components/nav/CNavLink.js.map +1 -1
- package/dist/esm/components/nav/index.js.map +1 -1
- package/dist/esm/components/navbar/index.js.map +1 -1
- package/dist/esm/components/offcanvas/COffcanvas.js +4 -1
- package/dist/esm/components/offcanvas/COffcanvas.js.map +1 -1
- package/dist/esm/components/offcanvas/index.js.map +1 -1
- package/dist/esm/components/pagination/CPaginationItem.js +1 -1
- package/dist/esm/components/pagination/CPaginationItem.js.map +1 -1
- package/dist/esm/components/pagination/index.js.map +1 -1
- package/dist/esm/components/picker/index.js.map +1 -1
- package/dist/esm/components/placeholder/index.js.map +1 -1
- package/dist/esm/components/popover/CPopover.d.ts +2 -2
- package/dist/esm/components/popover/CPopover.js +1 -1
- package/dist/esm/components/popover/index.js.map +1 -1
- package/dist/esm/components/progress/CProgress.d.ts +2 -2
- package/dist/esm/components/progress/CProgress.js +1 -1
- package/dist/esm/components/progress/index.js.map +1 -1
- package/dist/esm/components/sidebar/index.js.map +1 -1
- package/dist/esm/components/smart-pagination/index.js.map +1 -1
- package/dist/esm/components/smart-table/index.js.map +1 -1
- package/dist/esm/components/spinner/index.js.map +1 -1
- package/dist/esm/components/table/index.js.map +1 -1
- package/dist/esm/components/tabs/index.js.map +1 -1
- package/dist/esm/components/time-picker/CTimePicker.js +53 -21
- package/dist/esm/components/time-picker/CTimePicker.js.map +1 -1
- package/dist/esm/components/time-picker/index.js.map +1 -1
- package/dist/esm/components/time-picker/utils.d.ts +67 -10
- package/dist/esm/components/time-picker/utils.js +107 -23
- package/dist/esm/components/time-picker/utils.js.map +1 -1
- package/dist/esm/components/toast/index.js.map +1 -1
- package/dist/esm/components/tooltip/CTooltip.d.ts +2 -2
- package/dist/esm/components/tooltip/CTooltip.js +1 -1
- package/dist/esm/components/tooltip/index.js.map +1 -1
- package/dist/esm/components/virtual-scroller/index.js.map +1 -1
- package/dist/esm/components/widgets/index.js.map +1 -1
- package/package.json +9 -9
- package/src/components/accordion/CAccordion.ts +7 -1
- package/src/components/accordion/index.ts +5 -5
- package/src/components/alert/index.ts +3 -3
- package/src/components/avatar/index.ts +1 -1
- package/src/components/backdrop/index.ts +1 -1
- package/src/components/badge/CBadge.ts +14 -6
- package/src/components/badge/index.ts +1 -1
- package/src/components/breadcrumb/index.ts +2 -2
- package/src/components/button/index.ts +1 -1
- package/src/components/button-group/index.ts +2 -2
- package/src/components/calendar/CCalendar.ts +3 -3
- package/src/components/calendar/index.ts +1 -1
- package/src/components/callout/index.ts +1 -1
- package/src/components/card/CCard.ts +8 -0
- package/src/components/card/index.ts +11 -11
- package/src/components/carousel/index.ts +3 -3
- package/src/components/close-button/index.ts +1 -1
- package/src/components/collapse/index.ts +1 -1
- package/src/components/conditional-teleport/CConditionalTeleport.ts +1 -1
- package/src/components/conditional-teleport/index.ts +1 -1
- package/src/components/date-picker/CDatePicker.ts +6 -6
- package/src/components/date-picker/index.ts +1 -1
- package/src/components/date-range-picker/CDateRangePicker.ts +6 -6
- package/src/components/date-range-picker/index.ts +1 -1
- package/src/components/dropdown/CDropdown.ts +2 -2
- package/src/components/dropdown/CDropdownToggle.ts +2 -2
- package/src/components/dropdown/index.ts +6 -6
- package/src/components/element-cover/index.ts +1 -1
- package/src/components/footer/index.ts +1 -1
- package/src/components/form/CFormCheck.ts +19 -19
- package/src/components/form/CFormSwitch.ts +1 -0
- package/src/components/form/CFormTextarea.ts +1 -0
- package/src/components/form/index.ts +13 -13
- package/src/components/grid/index.ts +3 -3
- package/src/components/header/index.ts +6 -6
- package/src/components/image/index.ts +1 -1
- package/src/components/link/index.ts +1 -1
- package/src/components/list-group/index.ts +2 -2
- package/src/components/loading-button/index.ts +1 -1
- package/src/components/modal/CModal.ts +1 -1
- package/src/components/modal/index.ts +5 -5
- package/src/components/multi-select/index.ts +1 -1
- package/src/components/nav/CNavLink.ts +2 -2
- package/src/components/nav/index.ts +6 -6
- package/src/components/navbar/index.ts +5 -5
- package/src/components/offcanvas/COffcanvas.ts +4 -1
- package/src/components/offcanvas/index.ts +4 -4
- package/src/components/pagination/CPaginationItem.ts +1 -1
- package/src/components/pagination/index.ts +2 -2
- package/src/components/picker/index.ts +1 -1
- package/src/components/placeholder/index.ts +1 -1
- package/src/components/popover/CPopover.ts +1 -1
- package/src/components/popover/index.ts +1 -1
- package/src/components/progress/CProgress.ts +1 -1
- package/src/components/progress/index.ts +3 -3
- package/src/components/sidebar/index.ts +6 -6
- package/src/components/smart-pagination/index.ts +1 -1
- package/src/components/smart-table/index.ts +1 -1
- package/src/components/spinner/index.ts +1 -1
- package/src/components/table/index.ts +8 -8
- package/src/components/tabs/index.ts +2 -2
- package/src/components/time-picker/CTimePicker.ts +79 -36
- package/src/components/time-picker/index.ts +1 -1
- package/src/components/time-picker/utils.ts +128 -64
- package/src/components/toast/index.ts +5 -5
- package/src/components/tooltip/CTooltip.ts +1 -1
- package/src/components/tooltip/index.ts +1 -1
- package/src/components/virtual-scroller/index.ts +1 -1
- package/src/components/widgets/index.ts +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, ref, watch } from 'vue'
|
|
1
|
+
import { defineComponent, h, PropType, ref, watch } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { CButton } from '../button'
|
|
4
4
|
import { CFormControlWrapper } from '../form/CFormControlWrapper'
|
|
@@ -17,9 +17,11 @@ import {
|
|
|
17
17
|
isValidTime,
|
|
18
18
|
} from './utils'
|
|
19
19
|
|
|
20
|
-
import { Color } from '../props'
|
|
21
20
|
import type { LocalizedTimePartials } from './types'
|
|
22
21
|
|
|
22
|
+
import { useDebouncedCallback } from '../../composables'
|
|
23
|
+
import { Color } from '../props'
|
|
24
|
+
|
|
23
25
|
const CTimePicker = defineComponent({
|
|
24
26
|
name: 'CTimePicker',
|
|
25
27
|
props: {
|
|
@@ -146,6 +148,14 @@ const CTimePicker = defineComponent({
|
|
|
146
148
|
* @since 4.6.0
|
|
147
149
|
*/
|
|
148
150
|
feedbackValid: String,
|
|
151
|
+
/**
|
|
152
|
+
* Specify a list of available hours using an array, or customize the filtering of hours through a function.
|
|
153
|
+
*
|
|
154
|
+
* @since 5.0.0-rc.3
|
|
155
|
+
*/
|
|
156
|
+
hours: {
|
|
157
|
+
type: [Array, Function] as PropType<number[] | ((hour: number) => number[])>,
|
|
158
|
+
},
|
|
149
159
|
/**
|
|
150
160
|
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
151
161
|
*/
|
|
@@ -157,6 +167,15 @@ const CTimePicker = defineComponent({
|
|
|
157
167
|
type: Boolean,
|
|
158
168
|
default: true,
|
|
159
169
|
},
|
|
170
|
+
/**
|
|
171
|
+
* Defines the delay (in milliseconds) for the input field's onChange event.
|
|
172
|
+
*
|
|
173
|
+
* @since v5.0.0-rc.3
|
|
174
|
+
*/
|
|
175
|
+
inputOnChangeDelay: {
|
|
176
|
+
type: Number,
|
|
177
|
+
default: 750,
|
|
178
|
+
},
|
|
160
179
|
/**
|
|
161
180
|
* Toggle the readonly state for the component.
|
|
162
181
|
*/
|
|
@@ -183,6 +202,17 @@ const CTimePicker = defineComponent({
|
|
|
183
202
|
type: String,
|
|
184
203
|
defalut: 'default',
|
|
185
204
|
},
|
|
205
|
+
/**
|
|
206
|
+
* Toggle the display of minutes, specify a list of available minutes using an array, or customize the filtering of minutes through a function.
|
|
207
|
+
*
|
|
208
|
+
* @since 5.0.0-rc.3
|
|
209
|
+
*/
|
|
210
|
+
minutes: {
|
|
211
|
+
type: [Array, Boolean, Function] as PropType<
|
|
212
|
+
number[] | ((hour: number) => number[]) | boolean
|
|
213
|
+
>,
|
|
214
|
+
default: true,
|
|
215
|
+
},
|
|
186
216
|
/**
|
|
187
217
|
* Specifies a short hint that is visible in the input.
|
|
188
218
|
*/
|
|
@@ -197,12 +227,14 @@ const CTimePicker = defineComponent({
|
|
|
197
227
|
*/
|
|
198
228
|
required: Boolean,
|
|
199
229
|
/**
|
|
200
|
-
*
|
|
230
|
+
* Toggle the display of seconds, specify a list of available seconds using an array, or customize the filtering of seconds through a function.
|
|
201
231
|
*
|
|
202
232
|
* @since 4.7.0
|
|
203
233
|
*/
|
|
204
234
|
seconds: {
|
|
205
|
-
type: Boolean,
|
|
235
|
+
type: [Array, Boolean, Function] as PropType<
|
|
236
|
+
number[] | ((hour: number) => number[]) | boolean
|
|
237
|
+
>,
|
|
206
238
|
default: true,
|
|
207
239
|
},
|
|
208
240
|
/**
|
|
@@ -314,7 +346,13 @@ const CTimePicker = defineComponent({
|
|
|
314
346
|
watch(
|
|
315
347
|
date,
|
|
316
348
|
() => {
|
|
317
|
-
localizedTimePartials.value = getLocalizedTimePartials(
|
|
349
|
+
localizedTimePartials.value = getLocalizedTimePartials(
|
|
350
|
+
props.locale,
|
|
351
|
+
props.ampm,
|
|
352
|
+
props.hours,
|
|
353
|
+
props.minutes,
|
|
354
|
+
props.seconds,
|
|
355
|
+
)
|
|
318
356
|
|
|
319
357
|
if (date.value) {
|
|
320
358
|
ampm.value = getAmPm(new Date(date.value), props.locale)
|
|
@@ -398,11 +436,12 @@ const CTimePicker = defineComponent({
|
|
|
398
436
|
autocomplete: 'off',
|
|
399
437
|
class: 'time-picker-input',
|
|
400
438
|
disabled: props.disabled,
|
|
401
|
-
onInput: (event: Event) =>
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
439
|
+
onInput: (event: Event) =>
|
|
440
|
+
useDebouncedCallback(() => {
|
|
441
|
+
if (isValidTime((event.target as HTMLInputElement).value)) {
|
|
442
|
+
date.value = convertTimeToDate((event.target as HTMLInputElement).value)
|
|
443
|
+
}
|
|
444
|
+
}, props.inputOnChangeDelay),
|
|
406
445
|
placeholder: props.placeholder,
|
|
407
446
|
readonly: props.inputReadOnly,
|
|
408
447
|
ref: inputRef,
|
|
@@ -410,7 +449,9 @@ const CTimePicker = defineComponent({
|
|
|
410
449
|
value: date.value
|
|
411
450
|
? date.value.toLocaleTimeString(props.locale, {
|
|
412
451
|
hour12: localizedTimePartials.value && localizedTimePartials.value.hour12,
|
|
413
|
-
|
|
452
|
+
hour: 'numeric',
|
|
453
|
+
...(props.minutes && { minute: 'numeric' }),
|
|
454
|
+
...(props.seconds && { second: 'numeric' }),
|
|
414
455
|
})
|
|
415
456
|
: '',
|
|
416
457
|
}),
|
|
@@ -445,27 +486,28 @@ const CTimePicker = defineComponent({
|
|
|
445
486
|
),
|
|
446
487
|
),
|
|
447
488
|
),
|
|
448
|
-
':',
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
localizedTimePartials.value
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
489
|
+
props.minutes && ':',
|
|
490
|
+
props.minutes &&
|
|
491
|
+
h(
|
|
492
|
+
'select',
|
|
493
|
+
{
|
|
494
|
+
class: 'time-picker-inline-select',
|
|
495
|
+
disabled: props.disabled,
|
|
496
|
+
onChange: (event: Event) =>
|
|
497
|
+
handleTimeChange('minutes', (event.target as HTMLSelectElement).value),
|
|
498
|
+
...(date.value && { value: getSelectedMinutes(date.value) }),
|
|
499
|
+
},
|
|
500
|
+
localizedTimePartials.value &&
|
|
501
|
+
localizedTimePartials.value.listOfMinutes?.map((option) =>
|
|
502
|
+
h(
|
|
503
|
+
'option',
|
|
504
|
+
{
|
|
505
|
+
value: option.value.toString(),
|
|
506
|
+
},
|
|
507
|
+
option.label,
|
|
508
|
+
),
|
|
466
509
|
),
|
|
467
|
-
|
|
468
|
-
),
|
|
510
|
+
),
|
|
469
511
|
props.seconds && ':',
|
|
470
512
|
props.seconds &&
|
|
471
513
|
h(
|
|
@@ -524,11 +566,12 @@ const CTimePicker = defineComponent({
|
|
|
524
566
|
onClick: (index: number) => handleTimeChange('hours', index.toString()),
|
|
525
567
|
selected: getSelectedHour(date.value, props.locale, props.ampm),
|
|
526
568
|
}),
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
569
|
+
props.minutes &&
|
|
570
|
+
h(CTimePickerRollCol, {
|
|
571
|
+
elements: localizedTimePartials.value && localizedTimePartials.value.listOfMinutes,
|
|
572
|
+
onClick: (index: number) => handleTimeChange('minutes', index.toString()),
|
|
573
|
+
selected: getSelectedMinutes(date.value),
|
|
574
|
+
}),
|
|
532
575
|
props.seconds &&
|
|
533
576
|
h(CTimePickerRollCol, {
|
|
534
577
|
elements: localizedTimePartials.value && localizedTimePartials.value.listOfSeconds,
|
|
@@ -1,130 +1,194 @@
|
|
|
1
1
|
import type { LocalizedTimePartials } from './types'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Converts a 12-hour time format to a 24-hour time format.
|
|
5
|
+
* @param {('am' | 'pm')} abbr The abbreviation indicating AM or PM.
|
|
6
|
+
* @param {number} hour The hour to be converted.
|
|
7
|
+
* @returns {number} The hour in 24-hour format.
|
|
8
|
+
*/
|
|
3
9
|
export const convert12hTo24h = (abbr: 'am' | 'pm', hour: number) => {
|
|
4
10
|
if (abbr === 'am' && hour === 12) {
|
|
5
11
|
return 0
|
|
6
12
|
}
|
|
13
|
+
|
|
7
14
|
if (abbr === 'am') {
|
|
8
15
|
return hour
|
|
9
16
|
}
|
|
17
|
+
|
|
10
18
|
if (abbr === 'pm' && hour === 12) {
|
|
11
19
|
return 12
|
|
12
20
|
}
|
|
21
|
+
|
|
13
22
|
return hour + 12
|
|
14
23
|
}
|
|
15
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Converts a 24-hour time format to a 12-hour format.
|
|
27
|
+
* @param {number} hour The hour to be converted.
|
|
28
|
+
* @returns {number} The hour in 12-hour format.
|
|
29
|
+
*/
|
|
16
30
|
export const convert24hTo12h = (hour: number) => hour % 12 || 12
|
|
17
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Converts a time input into a Date object.
|
|
34
|
+
* @param {Date | string | null | undefined} time The time input to be converted.
|
|
35
|
+
* @returns {Date | null} The converted Date object or null if the input is falsy.
|
|
36
|
+
*/
|
|
18
37
|
export const convertTimeToDate = (time: Date | string | null | undefined) =>
|
|
19
|
-
time ? (time instanceof Date ?
|
|
38
|
+
time ? (time instanceof Date ? time : new Date(`1970-01-01 ${time}`)) : null
|
|
20
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Retrieves the AM/PM part of the specified date according to the given locale.
|
|
42
|
+
* @param {Date} date The date from which to extract the AM/PM part.
|
|
43
|
+
* @param {string} locale The locale to use for formatting.
|
|
44
|
+
* @returns {string} 'am' or 'pm' based on the given date and locale.
|
|
45
|
+
*/
|
|
21
46
|
export const getAmPm = (date: Date, locale: string) => {
|
|
22
47
|
if (date.toLocaleTimeString(locale).includes('AM')) {
|
|
23
48
|
return 'am'
|
|
24
49
|
}
|
|
50
|
+
|
|
25
51
|
if (date.toLocaleTimeString(locale).includes('PM')) {
|
|
26
52
|
return 'pm'
|
|
27
53
|
}
|
|
54
|
+
|
|
28
55
|
return date.getHours() >= 12 ? 'pm' : 'am'
|
|
29
56
|
}
|
|
30
57
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Formats an array of time values (hours, minutes, or seconds) according to the specified locale and partial.
|
|
60
|
+
* @param {number[]} values An array of time values to format.
|
|
61
|
+
* @param {string} locale The locale to use for formatting.
|
|
62
|
+
* @param {('hour' | 'minute' | 'second')} partial The type of time value to format.
|
|
63
|
+
* @returns {Array} An array of objects with the original value and its localized label.
|
|
64
|
+
*/
|
|
65
|
+
export const formatTimePartials = (
|
|
66
|
+
values: number[],
|
|
67
|
+
locale: string,
|
|
68
|
+
partial: 'hour' | 'minute' | 'second',
|
|
69
|
+
) => {
|
|
70
|
+
const date = new Date()
|
|
71
|
+
|
|
72
|
+
const formatter = new Intl.DateTimeFormat(locale, {
|
|
73
|
+
hour: 'numeric',
|
|
74
|
+
minute: '2-digit',
|
|
75
|
+
second: '2-digit',
|
|
40
76
|
})
|
|
41
77
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
.split(/[^A-Za-z0-9\u06F0-\u06F90-9]/)[0],
|
|
78
|
+
return values.map((value) => {
|
|
79
|
+
if (partial === 'hour') {
|
|
80
|
+
date.setHours(value)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (partial === 'minute') {
|
|
84
|
+
date.setMinutes(value)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (partial === 'second') {
|
|
88
|
+
date.setSeconds(value)
|
|
55
89
|
}
|
|
56
|
-
})
|
|
57
90
|
|
|
58
|
-
// TODO: clean-up
|
|
59
|
-
export const getListOfSeconds = (locale: string, valueAsString = false) =>
|
|
60
|
-
Array.from({ length: 60 }, (_, i) => {
|
|
61
|
-
const d = new Date()
|
|
62
|
-
d.setSeconds(i)
|
|
63
91
|
return {
|
|
64
|
-
value
|
|
65
|
-
label:
|
|
66
|
-
.toLocaleTimeString(locale, {
|
|
67
|
-
minute: '2-digit',
|
|
68
|
-
second: '2-digit',
|
|
69
|
-
})
|
|
70
|
-
.split(/[^A-Za-z0-9\u06F0-\u06F90-9]/)[0],
|
|
92
|
+
value,
|
|
93
|
+
label: formatter.formatToParts(date).find((part) => part.type === partial)?.value || '',
|
|
71
94
|
}
|
|
72
95
|
})
|
|
96
|
+
}
|
|
73
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Generates localized time partials (hours, minutes, seconds) based on the given parameters.
|
|
100
|
+
* @param {string} locale The locale to use for generating localized time partials.
|
|
101
|
+
* @param {'auto' | boolean} ampm Determines whether to use 12-hour or 24-hour format. 'auto' decides based on locale.
|
|
102
|
+
* @param {boolean | number[] | Function} hours An array of hours, a boolean, or a function to generate hours.
|
|
103
|
+
* @param {boolean | number[] | Function} minutes An array of minutes, a boolean, or a function to generate minutes.
|
|
104
|
+
* @param {boolean | number[] | Function} seconds An array of seconds, a boolean, or a function to generate seconds.
|
|
105
|
+
* @returns {LocalizedTimePartials} An object containing arrays of localized time partials and a boolean indicating if 12-hour format is used.
|
|
106
|
+
*/
|
|
74
107
|
export const getLocalizedTimePartials = (
|
|
75
108
|
locale: string,
|
|
76
109
|
ampm: 'auto' | boolean = 'auto',
|
|
110
|
+
hours: boolean | number[] | ((hour: number) => number[]) = [],
|
|
111
|
+
minutes: boolean | number[] | ((minute: number) => number[]) = [],
|
|
112
|
+
seconds: boolean | number[] | ((second: number) => number[]) = [],
|
|
77
113
|
): LocalizedTimePartials => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const listOfHours =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
const hour12 = (ampm === 'auto' && isAmPm(locale)) || ampm === true
|
|
115
|
+
|
|
116
|
+
const listOfHours =
|
|
117
|
+
Array.isArray(hours) && hours.length > 0
|
|
118
|
+
? hours
|
|
119
|
+
: (typeof hours === 'function'
|
|
120
|
+
? Array.from({ length: hour12 ? 12 : 24 }, (_, i) => (hour12 ? i + 1 : i)).filter((hour) =>
|
|
121
|
+
hours(hour),
|
|
122
|
+
)
|
|
123
|
+
: Array.from({ length: hour12 ? 12 : 24 }, (_, i) => (hour12 ? i + 1 : i)))
|
|
124
|
+
|
|
125
|
+
const listOfMinutes =
|
|
126
|
+
Array.isArray(minutes) && minutes.length > 0
|
|
127
|
+
? minutes
|
|
128
|
+
: (typeof minutes === 'function'
|
|
129
|
+
? Array.from({ length: 60 }, (_, i) => i).filter((minute) => minutes(minute))
|
|
130
|
+
: Array.from({ length: 60 }, (_, i) => i))
|
|
131
|
+
|
|
132
|
+
const listOfSeconds =
|
|
133
|
+
Array.isArray(seconds) && seconds.length > 0
|
|
134
|
+
? seconds
|
|
135
|
+
: (typeof seconds === 'function'
|
|
136
|
+
? Array.from({ length: 60 }, (_, i) => i).filter((second) => seconds(second))
|
|
137
|
+
: Array.from({ length: 60 }, (_, i) => i))
|
|
101
138
|
|
|
102
139
|
return {
|
|
103
|
-
listOfHours,
|
|
104
|
-
listOfMinutes:
|
|
105
|
-
listOfSeconds:
|
|
140
|
+
listOfHours: formatTimePartials(listOfHours, locale, 'hour'),
|
|
141
|
+
listOfMinutes: formatTimePartials(listOfMinutes, locale, 'minute'),
|
|
142
|
+
listOfSeconds: formatTimePartials(listOfSeconds, locale, 'second'),
|
|
106
143
|
hour12,
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Gets the selected hour from a date object in either 12-hour or 24-hour format based on locale and preference.
|
|
149
|
+
* @param {Date | null} date The date object from which to extract the hour. If null, the function returns an empty string.
|
|
150
|
+
* @param {string} locale The locale to use when determining whether to return in 12-hour or 24-hour format.
|
|
151
|
+
* @param {'auto' | boolean} ampm Determines the format of the hour returned. 'auto' decides based on locale, true forces 12-hour format, and false forces 24-hour format.
|
|
152
|
+
* @returns {string | number} The hour in the specified format or an empty string if the date is null.
|
|
153
|
+
*/
|
|
110
154
|
export const getSelectedHour = (
|
|
111
155
|
date: Date | null,
|
|
112
156
|
locale: string,
|
|
113
157
|
ampm: 'auto' | boolean = 'auto',
|
|
114
158
|
) =>
|
|
115
159
|
date
|
|
116
|
-
? (ampm === 'auto' && isAmPm(locale)) || ampm === true
|
|
160
|
+
? ((ampm === 'auto' && isAmPm(locale)) || ampm === true
|
|
117
161
|
? convert24hTo12h(date.getHours())
|
|
118
|
-
: date.getHours()
|
|
162
|
+
: date.getHours())
|
|
119
163
|
: ''
|
|
120
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Gets the selected minutes from a date object.
|
|
167
|
+
* @param {Date | null} date The date object from which to extract the minutes. If null, the function returns an empty string.
|
|
168
|
+
* @returns {string | number} The minutes from the date or an empty string if the date is null.
|
|
169
|
+
*/
|
|
121
170
|
export const getSelectedMinutes = (date: Date | null) => (date ? date.getMinutes() : '')
|
|
122
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Gets the selected seconds from a date object.
|
|
174
|
+
* @param {Date | null} date The date object from which to extract the seconds. If null, the function returns an empty string.
|
|
175
|
+
* @returns {string | number} The seconds from the date or an empty string if the date is null.
|
|
176
|
+
*/
|
|
123
177
|
export const getSelectedSeconds = (date: Date | null) => (date ? date.getSeconds() : '')
|
|
124
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Determines if the given locale uses AM/PM format.
|
|
181
|
+
* @param {string} locale The locale to check.
|
|
182
|
+
* @returns {boolean} True if the locale uses AM/PM format, otherwise false.
|
|
183
|
+
*/
|
|
125
184
|
export const isAmPm = (locale: string) =>
|
|
126
185
|
['am', 'AM', 'pm', 'PM'].some((el) => new Date().toLocaleString(locale).includes(el))
|
|
127
186
|
|
|
187
|
+
/**
|
|
188
|
+
* Validates if the given string represents a valid time.
|
|
189
|
+
* @param {string} time The time string to validate.
|
|
190
|
+
* @returns {boolean} True if the string is a valid time, otherwise false.
|
|
191
|
+
*/
|
|
128
192
|
export const isValidTime = (time: string) => {
|
|
129
193
|
const d = new Date(`1970-01-01 ${time}`)
|
|
130
194
|
return d instanceof Date && d.getTime()
|
|
@@ -7,11 +7,11 @@ import { CToastHeader } from './CToastHeader'
|
|
|
7
7
|
|
|
8
8
|
const CToastPlugin = {
|
|
9
9
|
install: (app: App): void => {
|
|
10
|
-
app.component(CToast.name, CToast)
|
|
11
|
-
app.component(CToastBody.name, CToastBody)
|
|
12
|
-
app.component(CToastClose.name, CToastClose)
|
|
13
|
-
app.component(CToaster.name, CToaster)
|
|
14
|
-
app.component(CToastHeader.name, CToastHeader)
|
|
10
|
+
app.component(CToast.name as string, CToast)
|
|
11
|
+
app.component(CToastBody.name as string, CToastBody)
|
|
12
|
+
app.component(CToastClose.name as string, CToastClose)
|
|
13
|
+
app.component(CToaster.name as string, CToaster)
|
|
14
|
+
app.component(CToastHeader.name as string, CToastHeader)
|
|
15
15
|
},
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -23,7 +23,7 @@ const CTooltip = defineComponent({
|
|
|
23
23
|
/**
|
|
24
24
|
* Appends the vue tooltip to a specific element. You can pass an HTML element or function that returns a single element. By default `document.body`.
|
|
25
25
|
*
|
|
26
|
-
* @since v5.0.0-rc.
|
|
26
|
+
* @since v5.0.0-rc.3
|
|
27
27
|
*/
|
|
28
28
|
container: {
|
|
29
29
|
type: [Object, String] as PropType<HTMLElement | (() => HTMLElement) | string>,
|
|
@@ -8,12 +8,12 @@ import { CWidgetStatsF } from './CWidgetStatsF'
|
|
|
8
8
|
|
|
9
9
|
const CWidgetsStatsPlugin = {
|
|
10
10
|
install: (app: App): void => {
|
|
11
|
-
app.component(CWidgetStatsA.name, CWidgetStatsA)
|
|
12
|
-
app.component(CWidgetStatsB.name, CWidgetStatsB)
|
|
13
|
-
app.component(CWidgetStatsC.name, CWidgetStatsC)
|
|
14
|
-
app.component(CWidgetStatsD.name, CWidgetStatsD)
|
|
15
|
-
app.component(CWidgetStatsE.name, CWidgetStatsE)
|
|
16
|
-
app.component(CWidgetStatsF.name, CWidgetStatsF)
|
|
11
|
+
app.component(CWidgetStatsA.name as string, CWidgetStatsA)
|
|
12
|
+
app.component(CWidgetStatsB.name as string, CWidgetStatsB)
|
|
13
|
+
app.component(CWidgetStatsC.name as string, CWidgetStatsC)
|
|
14
|
+
app.component(CWidgetStatsD.name as string, CWidgetStatsD)
|
|
15
|
+
app.component(CWidgetStatsE.name as string, CWidgetStatsE)
|
|
16
|
+
app.component(CWidgetStatsF.name as string, CWidgetStatsF)
|
|
17
17
|
},
|
|
18
18
|
}
|
|
19
19
|
|