@coreui/vue-pro 4.1.3 → 4.3.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.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/dist/components/button/CButton.d.ts +29 -2
  3. package/dist/components/calendar/CCalendar.d.ts +185 -0
  4. package/dist/components/calendar/index.d.ts +6 -0
  5. package/dist/components/date-picker/CDatePicker.d.ts +406 -0
  6. package/dist/components/date-picker/index.d.ts +6 -0
  7. package/dist/components/date-range-picker/CDateRangePicker.d.ts +480 -0
  8. package/dist/components/date-range-picker/index.d.ts +6 -0
  9. package/dist/components/dropdown/CDropdown.d.ts +25 -0
  10. package/dist/components/dropdown/CDropdownToggle.d.ts +35 -1
  11. package/dist/components/index.d.ts +5 -0
  12. package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
  13. package/dist/components/picker/CPicker.d.ts +11 -0
  14. package/dist/components/picker/index.d.ts +6 -0
  15. package/dist/components/popover/CPopover.d.ts +1 -1
  16. package/dist/components/sidebar/CSidebar.d.ts +1 -1
  17. package/dist/components/smart-table/CSmartTable.d.ts +1 -1
  18. package/dist/components/smart-table/CSmartTableBody.d.ts +0 -11
  19. package/dist/components/smart-table/CSmartTableHead.d.ts +1 -1
  20. package/dist/components/time-picker/CTimePicker.d.ts +10 -0
  21. package/dist/components/time-picker/CTimePickerRollCol.d.ts +27 -0
  22. package/dist/components/time-picker/index.d.ts +6 -0
  23. package/dist/components/toast/CToast.d.ts +1 -1
  24. package/dist/index.es.js +3021 -915
  25. package/dist/index.es.js.map +1 -1
  26. package/dist/index.js +3029 -913
  27. package/dist/index.js.map +1 -1
  28. package/dist/utils/calendar.d.ts +21 -0
  29. package/dist/utils/time.d.ts +17 -0
  30. package/package.json +9 -9
  31. package/src/components/accordion/CAccordionButton.ts +1 -0
  32. package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.ts.snap +1 -1
  33. package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.ts.snap +1 -1
  34. package/src/components/button/CButton.ts +30 -1
  35. package/src/components/button/__tests__/__snapshots__/CButton.spec.ts.snap +1 -1
  36. package/src/components/calendar/CCalendar.ts +546 -0
  37. package/src/components/calendar/index.ts +10 -0
  38. package/src/components/close-button/CCloseButton.ts +4 -1
  39. package/src/components/date-picker/CDatePicker.ts +243 -0
  40. package/src/components/date-picker/index.ts +10 -0
  41. package/src/components/date-range-picker/CDateRangePicker.ts +635 -0
  42. package/src/components/date-range-picker/index.ts +10 -0
  43. package/src/components/dropdown/CDropdown.ts +48 -49
  44. package/src/components/dropdown/CDropdownMenu.ts +52 -7
  45. package/src/components/dropdown/CDropdownToggle.ts +93 -29
  46. package/src/components/dropdown/__tests__/CDropdownMenu.spec.ts +7 -7
  47. package/src/components/dropdown/__tests__/CDropdownToggle.spec.ts +4 -5
  48. package/src/components/dropdown/__tests__/__snapshots__/CDropdownToggle.spec.ts.snap +2 -2
  49. package/src/components/form/CFormCheck.ts +2 -1
  50. package/src/components/form/CFormSwitch.ts +1 -7
  51. package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +2 -8
  52. package/src/components/index.ts +5 -0
  53. package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +2 -1
  54. package/src/components/picker/CPicker.ts +220 -0
  55. package/src/components/picker/index.ts +10 -0
  56. package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +8 -2
  57. package/src/components/smart-table/CSmartTable.ts +2 -3
  58. package/src/components/smart-table/CSmartTableBody.ts +0 -5
  59. package/src/components/time-picker/CTimePicker.ts +410 -0
  60. package/src/components/time-picker/CTimePickerRollCol.ts +58 -0
  61. package/src/components/time-picker/index.ts +10 -0
  62. package/src/components/toast/__tests__/__snapshots__/CToastClose.spec.ts.snap +1 -1
  63. package/src/utils/calendar.ts +193 -0
  64. package/src/utils/time.ts +58 -0
@@ -0,0 +1,220 @@
1
+ import { defineComponent, h, PropType, ref, watch } from 'vue'
2
+
3
+ import { CButton } from '../button/'
4
+ import { CDropdown, CDropdownMenu, CDropdownToggle } from '../dropdown/'
5
+
6
+ import { Color } from '../props'
7
+
8
+ const CPicker = defineComponent({
9
+ name: 'CPicker',
10
+ props: {
11
+ ...CDropdown.props,
12
+ /**
13
+ * Toggle visibility or set the content of cancel button.
14
+ */
15
+ cancelButton: {
16
+ type: [Boolean, String],
17
+ default: 'Cancel',
18
+ },
19
+ /**
20
+ * Sets the color context of the cancel button to one of CoreUI’s themed colors.
21
+ *
22
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
23
+ */
24
+ cancelButtonColor: {
25
+ ...Color,
26
+ default: 'primary',
27
+ },
28
+ /**
29
+ * Size the cancel button small or large.
30
+ *
31
+ * @values 'sm', 'lg'
32
+ */
33
+ cancelButtonSize: {
34
+ type: String,
35
+ default: 'sm',
36
+ validator: (value: string) => {
37
+ return ['sm', 'lg'].includes(value)
38
+ },
39
+ },
40
+ /**
41
+ * Set the cancel button variant to an outlined button or a ghost button.
42
+ *
43
+ * @values 'ghost', 'outline'
44
+ */
45
+ cancelButtonVariant: {
46
+ type: String,
47
+ default: 'ghost',
48
+ validator: (value: string) => {
49
+ return ['ghost', 'outline'].includes(value)
50
+ },
51
+ },
52
+ /**
53
+ * Toggle visibility or set the content of confirm button.
54
+ */
55
+ confirmButton: {
56
+ type: [Boolean, String],
57
+ default: 'OK',
58
+ },
59
+ /**
60
+ * Sets the color context of the confirm button to one of CoreUI’s themed colors.
61
+ *
62
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
63
+ */
64
+ confirmButtonColor: {
65
+ ...Color,
66
+ default: 'primary',
67
+ },
68
+ /**
69
+ * Size the confirm button small or large.
70
+ *
71
+ * @values 'sm', 'lg'
72
+ */
73
+ confirmButtonSize: {
74
+ type: String,
75
+ default: 'sm',
76
+ validator: (value: string) => {
77
+ return ['sm', 'lg'].includes(value)
78
+ },
79
+ },
80
+ /**
81
+ * Set the confirm button variant to an outlined button or a ghost button.
82
+ *
83
+ * @values 'ghost', 'outline'
84
+ */
85
+ confirmButtonVariant: {
86
+ type: String,
87
+ validator: (value: string) => {
88
+ return ['ghost', 'outline'].includes(value)
89
+ },
90
+ },
91
+ /**
92
+ * Set container type for the component.
93
+ */
94
+ container: {
95
+ type: String as PropType<'dropdown' | 'inline'>,
96
+ default: 'dropdown',
97
+ },
98
+ /**
99
+ * Toggle the disabled state for the component.
100
+ */
101
+ disabled: Boolean,
102
+ /**
103
+ * Toggle visibility of footer element or set the content of footer.
104
+ */
105
+ footer: Boolean,
106
+ /**
107
+ * Toggle the visibility of the component.
108
+ */
109
+ visible: Boolean,
110
+ },
111
+ emits: [
112
+ /**
113
+ * Callback fired when the cancel button has been clicked.
114
+ */
115
+ 'cancel',
116
+ /**
117
+ * Callback fired when the confirm button has been clicked.
118
+ */
119
+ 'confirm',
120
+ /**
121
+ * Callback fired when the component requests to be hidden.
122
+ */
123
+ 'hide',
124
+ /**
125
+ * Callback fired when the component requests to be shown.
126
+ */
127
+ 'show',
128
+ ],
129
+ setup(props, { emit, slots }) {
130
+ const visible = ref(props.visible)
131
+
132
+ watch(
133
+ () => props.visible,
134
+ () => {
135
+ visible.value = props.visible
136
+ },
137
+ )
138
+
139
+ const handleConfirm = () => {
140
+ emit('confirm')
141
+ visible.value = false
142
+ }
143
+
144
+ const Footer = () =>
145
+ h('div', { class: 'picker-footer' }, [
146
+ props.cancelButton &&
147
+ h(
148
+ CButton,
149
+ {
150
+ color: props.cancelButtonColor,
151
+ onClick: () => emit('cancel'),
152
+ size: props.cancelButtonSize,
153
+ variant: props.cancelButtonVariant,
154
+ },
155
+ /**
156
+ * @slot Location for the cancel button content.
157
+ */
158
+ () => (slots.cancelButton ? slots.cancelButton() : props.cancelButton),
159
+ ),
160
+ props.confirmButton &&
161
+ h(
162
+ CButton,
163
+ {
164
+ color: props.confirmButtonColor,
165
+ onClick: handleConfirm,
166
+ size: props.confirmButtonSize,
167
+ variant: props.confirmButtonVariant,
168
+ },
169
+ /**
170
+ * @slot Location for the confirm button content.
171
+ */
172
+ () => (slots.confirmButton ? slots.confirmButton() : props.confirmButton),
173
+ ),
174
+ ])
175
+
176
+ switch (props.container) {
177
+ case 'inline':
178
+ return () => h('div', { class: 'picker' }, slots.default && slots.default())
179
+ default:
180
+ return () =>
181
+ h(
182
+ CDropdown,
183
+ {
184
+ autoClose: 'outside',
185
+ class: 'picker',
186
+ onHide: () => {
187
+ visible.value = false
188
+ emit('hide')
189
+ },
190
+ onShow: () => {
191
+ visible.value = true
192
+ emit('show')
193
+ },
194
+ variant: 'dropdown',
195
+ visible: visible.value,
196
+ },
197
+ () => [
198
+ h(
199
+ CDropdownToggle,
200
+ {
201
+ custom: true,
202
+ disabled: visible.value || props.disabled,
203
+ },
204
+ {
205
+ /**
206
+ * @slot Location for the toggler element.
207
+ */
208
+ default: () => slots.toggler && slots.toggler(),
209
+ },
210
+ ),
211
+ h(CDropdownMenu, {}, () => [
212
+ slots.default && slots.default(),
213
+ props.footer && Footer(),
214
+ ]),
215
+ ],
216
+ )
217
+ }
218
+ },
219
+ })
220
+ export { CPicker }
@@ -0,0 +1,10 @@
1
+ import { App } from 'vue'
2
+ import { CPicker } from './CPicker'
3
+
4
+ const CPickerPlugin = {
5
+ install: (app: App): void => {
6
+ app.component(CPicker.name, CPicker)
7
+ },
8
+ }
9
+
10
+ export { CPicker, CPickerPlugin }
@@ -1,5 +1,11 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize CSidebar component renders correctly 1`] = `"<div class=\\"sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-xl sidebar-narrow-unfoldable\\">Default slot</div>"`;
3
+ exports[`Customize CSidebar component renders correctly 1`] = `
4
+ "<div class=\\"sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-xl sidebar-narrow-unfoldable\\">Default slot</div>
5
+ <!---->"
6
+ `;
4
7
 
5
- exports[`Loads and display CSidebar component renders correctly 1`] = `"<div class=\\"sidebar hide\\">Default slot</div>"`;
8
+ exports[`Loads and display CSidebar component renders correctly 1`] = `
9
+ "<div class=\\"sidebar hide\\">Default slot</div>
10
+ <!---->"
11
+ `;
@@ -713,7 +713,7 @@ const CSmartTable = defineComponent({
713
713
  ...props.tableHeadProps,
714
714
  columnFilter: props.columnFilter,
715
715
  columnFilterValue: columnFilterState.value,
716
- columns: rawColumnNames.value,
716
+ columns: props.columns ? props.columns : rawColumnNames.value,
717
717
  columnSorter: props.columnSorter,
718
718
  selectable: props.selectable,
719
719
  selectAll: selectedAll.value,
@@ -767,7 +767,6 @@ const CSmartTable = defineComponent({
767
767
  currentItems: currentItems.value,
768
768
  firstItemOnActivePageIndex: firstItemOnActivePageIndex.value,
769
769
  noItemsLabel: props.noItemsLabel,
770
- columns: rawColumnNames.value,
771
770
  scopedSlots: slots,
772
771
  selectable: props.selectable,
773
772
  onRowChecked: (id: number, value: boolean) => handleRowChecked(id, value),
@@ -787,7 +786,7 @@ const CSmartTable = defineComponent({
787
786
  ...props.tableFootProps,
788
787
  columnFilter: false,
789
788
  columnSorter: false,
790
- columns: rawColumnNames.value,
789
+ columns: props.columns ? props.columns : rawColumnNames.value,
791
790
  selectable: props.selectable,
792
791
  selectAll: selectedAll.value,
793
792
  onFilterInput: (key: string, value: string) =>
@@ -27,11 +27,6 @@ const CSmartTableBody = defineComponent({
27
27
  default: undefined,
28
28
  require: false,
29
29
  },
30
- columns: {
31
- type: Array,
32
- default: () => [],
33
- require: true,
34
- },
35
30
  rawColumnNames: {
36
31
  type: Array as PropType<string[]>,
37
32
  default: () => [],
@@ -0,0 +1,410 @@
1
+ import { defineComponent, h, ref, watch } from 'vue'
2
+
3
+ import { CFormInput, CFormSelect, CInputGroup, CInputGroupText } from '../form/'
4
+ import { CPicker } from '../picker'
5
+ import { CTimePickerRollCol } from './CTimePickerRollCol'
6
+
7
+ import {
8
+ convert12hTo24h,
9
+ convertTimeToDate,
10
+ getAmPm,
11
+ getListOfHours,
12
+ getMinutesOrSeconds,
13
+ getSelectedHour,
14
+ getSelectedMinutes,
15
+ getSelectedSeconds,
16
+ isAmPm,
17
+ isValidTime,
18
+ } from '../../utils/time'
19
+
20
+ import { Color } from '../props'
21
+
22
+ const CTimePicker = defineComponent({
23
+ name: 'CTimePicker',
24
+ props: {
25
+ ...CPicker.props,
26
+ /**
27
+ * Toggle visibility or set the content of cancel button.
28
+ */
29
+ cancelButton: {
30
+ type: [Boolean, String],
31
+ default: 'Cancel',
32
+ },
33
+ /**
34
+ * Sets the color context of the cancel button to one of CoreUI’s themed colors.
35
+ *
36
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
37
+ */
38
+ cancelButtonColor: {
39
+ ...Color,
40
+ default: 'primary',
41
+ },
42
+ /**
43
+ * Size the cancel button small or large.
44
+ *
45
+ * @values 'sm', 'lg'
46
+ */
47
+ cancelButtonSize: {
48
+ type: String,
49
+ default: 'sm',
50
+ validator: (value: string) => {
51
+ return ['sm', 'lg'].includes(value)
52
+ },
53
+ },
54
+ /**
55
+ * Set the cancel button variant to an outlined button or a ghost button.
56
+ *
57
+ * @values 'ghost', 'outline'
58
+ */
59
+ cancelButtonVariant: {
60
+ type: String,
61
+ default: 'ghost',
62
+ validator: (value: string) => {
63
+ return ['ghost', 'outline'].includes(value)
64
+ },
65
+ },
66
+ /**
67
+ * Toggle visibility of the cleaner button.
68
+ */
69
+ cleaner: {
70
+ type: Boolean,
71
+ default: true,
72
+ },
73
+ /**
74
+ * Toggle visibility or set the content of confirm button.
75
+ */
76
+ confirmButton: {
77
+ type: [Boolean, String],
78
+ default: 'OK',
79
+ },
80
+ /**
81
+ * Sets the color context of the confirm button to one of CoreUI’s themed colors.
82
+ *
83
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
84
+ */
85
+ confirmButtonColor: {
86
+ ...Color,
87
+ default: 'primary',
88
+ },
89
+ /**
90
+ * Size the confirm button small or large.
91
+ *
92
+ * @values 'sm', 'lg'
93
+ */
94
+ confirmButtonSize: {
95
+ type: String,
96
+ default: 'sm',
97
+ validator: (value: string) => {
98
+ return ['sm', 'lg'].includes(value)
99
+ },
100
+ },
101
+ /**
102
+ * Set the confirm button variant to an outlined button or a ghost button.
103
+ *
104
+ * @values 'ghost', 'outline'
105
+ */
106
+ confirmButtonVariant: {
107
+ type: String,
108
+ validator: (value: string) => {
109
+ return ['ghost', 'outline'].includes(value)
110
+ },
111
+ },
112
+ /**
113
+ * Toggle visibility or set the content of the input indicator.
114
+ */
115
+ indicator: {
116
+ type: Boolean,
117
+ default: true,
118
+ },
119
+ /**
120
+ * Toggle the readonly state for the component.
121
+ */
122
+ inputReadOnly: Boolean,
123
+ /**
124
+ * Sets the default locale for components. If not set, it is inherited from the navigator.language.
125
+ */
126
+ locale: {
127
+ type: String,
128
+ defalut: 'default',
129
+ },
130
+ /**
131
+ * Specifies a short hint that is visible in the input.
132
+ */
133
+ placeholder: {
134
+ type: String,
135
+ default: 'Select time',
136
+ },
137
+ /**
138
+ * Size the component small or large.
139
+ *
140
+ * @values 'sm', 'lg'
141
+ */
142
+ size: {
143
+ type: String,
144
+ default: undefined,
145
+ validator: (value: string) => {
146
+ return ['sm', 'lg'].includes(value)
147
+ },
148
+ },
149
+ /**
150
+ * Initial selected time.
151
+ */
152
+ time: {
153
+ type: [Date, String],
154
+ },
155
+ /**
156
+ * Set the time picker variant to a roll or select.
157
+ *
158
+ * @values 'roll', 'select'
159
+ */
160
+ variant: {
161
+ type: String,
162
+ default: 'roll',
163
+ validator: (value: string) => {
164
+ return ['roll', 'select'].includes(value)
165
+ },
166
+ },
167
+ },
168
+ emits: [
169
+ /**
170
+ * Callback fired when the time changed.
171
+ */
172
+ 'change',
173
+ /**
174
+ * Callback fired when the component requests to be hidden.
175
+ */
176
+ 'hide',
177
+ /**
178
+ * Callback fired when the component requests to be shown.
179
+ */
180
+ 'show',
181
+ ],
182
+ setup(props, { emit, slots }) {
183
+ const date = ref<Date | null>(convertTimeToDate(props.time))
184
+ const initialDate = ref<Date | null>(null)
185
+ const ampm = ref<'am' | 'pm'>(date.value ? getAmPm(new Date(date.value), props.locale) : 'am')
186
+
187
+ watch(
188
+ () => props.time,
189
+ () => {
190
+ date.value = convertTimeToDate(props.time)
191
+ },
192
+ )
193
+
194
+ watch(date, () => {
195
+ if (date.value) {
196
+ ampm.value = getAmPm(new Date(date.value), props.locale)
197
+ }
198
+ })
199
+
200
+ const handleClear = (event: Event) => {
201
+ event.stopPropagation()
202
+ date.value = null
203
+ }
204
+
205
+ const handleTimeChange = (set: 'hours' | 'minutes' | 'seconds' | 'toggle', value: string) => {
206
+ const _date = date.value || new Date('1970-01-01')
207
+
208
+ if (set === 'toggle') {
209
+ if (value === 'am') {
210
+ _date.setHours(_date.getHours() - 12)
211
+ }
212
+ if (value === 'pm') {
213
+ _date.setHours(_date.getHours() + 12)
214
+ }
215
+ }
216
+
217
+ if (set === 'hours') {
218
+ if (isAmPm(props.locale)) {
219
+ _date.setHours(convert12hTo24h(ampm.value, parseInt(value)))
220
+ } else {
221
+ _date.setHours(parseInt(value))
222
+ }
223
+ }
224
+
225
+ if (set === 'minutes') {
226
+ _date.setMinutes(parseInt(value))
227
+ }
228
+
229
+ if (set === 'seconds') {
230
+ _date.setSeconds(parseInt(value))
231
+ }
232
+
233
+ date.value = new Date(_date)
234
+ emit('change', _date.toTimeString(), _date.toLocaleTimeString(), _date)
235
+ }
236
+
237
+ const InputGroup = () =>
238
+ h(CInputGroup, { class: 'picker-input-group', size: props.size }, () => [
239
+ h(CFormInput, {
240
+ disabled: props.disabled,
241
+ onInput: (event) => {
242
+ if (isValidTime(event.target.value)) {
243
+ date.value = convertTimeToDate(event.target.value)
244
+ }
245
+ },
246
+ placeholder: props.placeholder,
247
+ readonly: props.inputReadOnly,
248
+ value: date.value ? date.value.toLocaleTimeString(props.locale) : '',
249
+ }),
250
+ (props.indicator || props.cleaner) &&
251
+ h(CInputGroupText, {}, () => [
252
+ props.indicator &&
253
+ h(
254
+ 'span',
255
+ {
256
+ class: 'picker-input-group-indicator',
257
+ },
258
+ slots.indicator
259
+ ? slots.indicator()
260
+ : h('span', { class: 'picker-input-group-icon time-picker-input-icon' }),
261
+ ),
262
+ props.cleaner &&
263
+ h(
264
+ 'span',
265
+ {
266
+ class: 'picker-input-group-cleaner',
267
+ onClick: (event: Event) => handleClear(event),
268
+ role: 'button',
269
+ },
270
+ slots.cleaner
271
+ ? slots.cleaner()
272
+ : h('span', { class: 'picker-input-group-icon time-picker-cleaner-icon' }),
273
+ ),
274
+ ]),
275
+ ])
276
+
277
+ const TimePickerSelect = () => [
278
+ h('span', { class: 'time-picker-inline-icon' }),
279
+ h(CFormSelect, {
280
+ disabled: props.disabled,
281
+ options: getListOfHours(props.locale).map((option) => {
282
+ return {
283
+ value: option.value.toString(),
284
+ label: option.label,
285
+ }
286
+ }),
287
+ onChange: (event) => handleTimeChange('hours', event.target.value),
288
+ ...(date.value && { value: getSelectedHour(date.value, props.locale) }),
289
+ }),
290
+ ':',
291
+ h(CFormSelect, {
292
+ disabled: props.disabled,
293
+ options: Array.from({ length: 60 }, (_, i) => {
294
+ return {
295
+ value: i.toString(),
296
+ label: i.toLocaleString(props.locale).padStart(2, (0).toLocaleString(props.locale)),
297
+ }
298
+ }),
299
+ onChange: (event) => handleTimeChange('minutes', event.target.value),
300
+ ...(date.value && { value: getSelectedMinutes(date.value) }),
301
+ }),
302
+ ':',
303
+ h(CFormSelect, {
304
+ disabled: props.disabled,
305
+ options: Array.from({ length: 60 }, (_, i) => {
306
+ return {
307
+ value: i.toString(),
308
+ label: i.toLocaleString(props.locale).padStart(2, (0).toLocaleString(props.locale)),
309
+ }
310
+ }),
311
+ onChange: (event) => handleTimeChange('seconds', event.target.value),
312
+ ...(date.value && { value: getSelectedSeconds(date.value) }),
313
+ }),
314
+ isAmPm(props.locale) &&
315
+ h(CFormSelect, {
316
+ disabled: props.disabled,
317
+ options: [
318
+ { value: 'am', label: 'AM' },
319
+ { value: 'pm', label: 'PM' },
320
+ ],
321
+ onChange: (event) => handleTimeChange('toggle', event.target.value),
322
+ value: ampm.value,
323
+ }),
324
+ ]
325
+
326
+ const TimePickerRoll = () => [
327
+ h(CTimePickerRollCol, {
328
+ elements: getListOfHours(props.locale),
329
+ onClick: (index: number) => handleTimeChange('hours', index.toString()),
330
+ selected: getSelectedHour(date.value, props.locale),
331
+ }),
332
+ h(CTimePickerRollCol, {
333
+ elements: getMinutesOrSeconds(props.locale),
334
+ onClick: (index: number) => handleTimeChange('minutes', index.toString()),
335
+ selected: getSelectedMinutes(date.value),
336
+ }),
337
+ h(CTimePickerRollCol, {
338
+ elements: getMinutesOrSeconds(props.locale),
339
+ onClick: (index: number) => handleTimeChange('seconds', index.toString()),
340
+ selected: getSelectedSeconds(date.value),
341
+ }),
342
+ isAmPm(props.locale) &&
343
+ h(CTimePickerRollCol, {
344
+ elements: [
345
+ { value: 'am', label: 'AM' },
346
+ { value: 'pm', label: 'PM' },
347
+ ],
348
+ onClick: (value: string) => handleTimeChange('toggle', value),
349
+ selected: ampm.value,
350
+ }),
351
+ ]
352
+
353
+ return () =>
354
+ h(
355
+ CPicker,
356
+ {
357
+ cancelButton: props.cancelButton,
358
+ cancelButtonColor: props.cancelButtonColor,
359
+ cancelButtonSize: props.cancelButtonSize,
360
+ cancelButtonVariant: props.cancelButtonVariant,
361
+ class: 'time-picker',
362
+ confirmButton: props.confirmButton,
363
+ confirmButtonColor: props.confirmButtonColor,
364
+ confirmButtonSize: props.confirmButtonSize,
365
+ confirmButtonVariant: props.confirmButtonVariant,
366
+ container: props.container,
367
+ disabled: props.disabled,
368
+ footer: true,
369
+ onCancel: () => {
370
+ if (initialDate.value) {
371
+ date.value = new Date(initialDate.value)
372
+ }
373
+ },
374
+ onHide: () => {
375
+ emit('hide')
376
+ },
377
+ onShow: () => {
378
+ if (date.value) {
379
+ initialDate.value = new Date(date.value)
380
+ }
381
+
382
+ emit('show')
383
+ },
384
+ },
385
+ {
386
+ ...(slots.cancelButton && {
387
+ cancelButton: () => slots.cancelButton && slots.cancelButton(),
388
+ }),
389
+ ...(slots.confirmButton && {
390
+ confirmButton: () => slots.confirmButton && slots.confirmButton(),
391
+ }),
392
+ toggler: () => InputGroup(),
393
+ default: () =>
394
+ h(
395
+ 'div',
396
+ {
397
+ class: [
398
+ 'time-picker-body',
399
+ {
400
+ ['time-picker-roll']: props.variant === 'roll',
401
+ },
402
+ ],
403
+ },
404
+ props.variant === 'select' ? TimePickerSelect() : TimePickerRoll(),
405
+ ),
406
+ },
407
+ )
408
+ },
409
+ })
410
+ export { CTimePicker }