@coreui/vue-pro 5.0.0-alpha.0 → 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 +58 -32
- package/dist/components/calendar/utils.d.ts +11 -4
- package/dist/components/close-button/CCloseButton.d.ts +9 -0
- package/dist/components/date-picker/CDatePicker.d.ts +89 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +89 -0
- package/dist/components/dropdown/CDropdown.d.ts +13 -28
- package/dist/components/dropdown/CDropdownToggle.d.ts +19 -9
- package/dist/components/dropdown/types.d.ts +15 -0
- package/dist/components/dropdown/utils.d.ts +6 -0
- package/dist/components/form/CFormCheck.d.ts +4 -4
- package/dist/components/modal/CModal.d.ts +19 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
- package/dist/components/multi-select/types.d.ts +2 -2
- package/dist/components/multi-select/utils.d.ts +2 -2
- package/dist/components/offcanvas/COffcanvas.d.ts +9 -0
- package/dist/components/progress/CProgress.d.ts +102 -3
- package/dist/components/progress/CProgressStacked.d.ts +10 -0
- package/dist/components/progress/index.d.ts +2 -1
- package/dist/components/smart-table/CSmartTable.d.ts +0 -4
- package/dist/components/smart-table/CSmartTableBody.d.ts +12 -1
- package/dist/components/smart-table/types.d.ts +2 -2
- package/dist/components/smart-table/utils.d.ts +4 -2
- package/dist/composables/index.d.ts +2 -1
- package/dist/composables/useDebouncedCallback.d.ts +1 -0
- package/dist/index.es.js +1035 -2716
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1035 -2714
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/components/breadcrumb/CBreadcrumb.ts +1 -0
- package/src/components/button/CButton.ts +5 -5
- package/src/components/calendar/CCalendar.ts +444 -179
- package/src/components/calendar/utils.ts +93 -55
- package/src/components/carousel/CCarousel.ts +2 -5
- package/src/components/close-button/CCloseButton.ts +5 -0
- package/src/components/date-picker/CDatePicker.ts +43 -0
- package/src/components/date-range-picker/CDateRangePicker.ts +130 -83
- package/src/components/date-range-picker/utils.ts +2 -2
- package/src/components/dropdown/CDropdown.ts +23 -43
- package/src/components/dropdown/CDropdownMenu.ts +4 -19
- package/src/components/dropdown/CDropdownToggle.ts +44 -38
- package/src/components/dropdown/types.ts +11 -0
- package/src/components/dropdown/utils.ts +71 -0
- package/src/components/form/CFormCheck.ts +4 -4
- package/src/components/modal/CModal.ts +15 -1
- package/src/components/multi-select/CMultiSelect.ts +5 -8
- package/src/components/multi-select/CMultiSelectOptions.ts +1 -1
- package/src/components/multi-select/CMultiSelectSelection.ts +3 -3
- package/src/components/multi-select/types.ts +2 -2
- package/src/components/multi-select/utils.ts +5 -5
- package/src/components/navbar/CNavbar.ts +1 -1
- package/src/components/offcanvas/COffcanvas.ts +6 -0
- package/src/components/picker/CPicker.ts +1 -1
- package/src/components/progress/CProgress.ts +67 -9
- package/src/components/progress/CProgressBar.ts +4 -6
- package/src/components/progress/CProgressStacked.ts +19 -0
- package/src/components/progress/index.ts +3 -1
- package/src/components/sidebar/CSidebar.ts +1 -1
- package/src/components/smart-pagination/CSmartPagination.ts +20 -5
- package/src/components/smart-table/CSmartTable.ts +21 -12
- package/src/components/smart-table/CSmartTableBody.ts +30 -31
- package/src/components/smart-table/CSmartTableHead.ts +39 -12
- package/src/components/smart-table/types.ts +2 -2
- package/src/components/smart-table/utils.ts +41 -5
- package/src/components/time-picker/CTimePicker.ts +4 -2
- package/src/components/tooltip/CTooltip.ts +1 -1
- package/src/components/widgets/CWidgetStatsA.ts +1 -3
- package/src/components/widgets/CWidgetStatsB.ts +2 -4
- package/src/components/widgets/CWidgetStatsC.ts +2 -2
- package/src/components/widgets/CWidgetStatsD.ts +1 -1
- package/src/components/widgets/CWidgetStatsE.ts +1 -1
- package/src/components/widgets/CWidgetStatsF.ts +1 -1
- package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsE.spec.ts.snap +1 -1
- package/src/composables/index.ts +2 -1
- package/src/composables/useDebouncedCallback.ts +16 -0
- package/src/utils/isObjectInArray.ts +1 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Placement } from '@popperjs/core'
|
|
2
|
+
import type { Placements } from '../../types'
|
|
3
|
+
import type { Alignments } from './types'
|
|
4
|
+
|
|
5
|
+
export const getAlignmentClassNames = (alignment: object | string) => {
|
|
6
|
+
const classNames: string[] = []
|
|
7
|
+
if (typeof alignment === 'object') {
|
|
8
|
+
Object.keys(alignment).map((key) => {
|
|
9
|
+
classNames.push(`dropdown-menu${key === 'xs' ? '' : `-${key}`}-${alignment[key]}`)
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof alignment === 'string') {
|
|
14
|
+
classNames.push(`dropdown-menu-${alignment}`)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return classNames
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getNextActiveElement = (
|
|
21
|
+
list: HTMLElement[],
|
|
22
|
+
activeElement: HTMLElement,
|
|
23
|
+
shouldGetNext: boolean,
|
|
24
|
+
isCycleAllowed: boolean,
|
|
25
|
+
) => {
|
|
26
|
+
const listLength = list.length
|
|
27
|
+
let index = list.indexOf(activeElement)
|
|
28
|
+
|
|
29
|
+
if (index === -1) {
|
|
30
|
+
return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
index += shouldGetNext ? 1 : -1
|
|
34
|
+
|
|
35
|
+
if (isCycleAllowed) {
|
|
36
|
+
index = (index + listLength) % listLength
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return list[Math.max(0, Math.min(index, listLength - 1))]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const getPlacement = (
|
|
43
|
+
placement: Placement,
|
|
44
|
+
direction: string | undefined,
|
|
45
|
+
alignment: Alignments | string | undefined,
|
|
46
|
+
isRTL: boolean,
|
|
47
|
+
): Placements => {
|
|
48
|
+
let _placement = placement
|
|
49
|
+
|
|
50
|
+
if (direction === 'dropup') {
|
|
51
|
+
_placement = isRTL ? 'top-end' : 'top-start'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (direction === 'dropup-center') {
|
|
55
|
+
_placement = 'top'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (direction === 'dropend') {
|
|
59
|
+
_placement = isRTL ? 'left-start' : 'right-start'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (direction === 'dropstart') {
|
|
63
|
+
_placement = isRTL ? 'right-start' : 'left-start'
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (alignment === 'end') {
|
|
67
|
+
_placement = isRTL ? 'bottom-start' : 'bottom-end'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return _placement
|
|
71
|
+
}
|
|
@@ -17,7 +17,7 @@ const CFormCheck = defineComponent({
|
|
|
17
17
|
/**
|
|
18
18
|
* Use in conjunction with the v-model directive to specify the value that should be assigned to the bound variable when the checkbox is in the `false` state.
|
|
19
19
|
*
|
|
20
|
-
* @since 4.
|
|
20
|
+
* @since 4.10.0
|
|
21
21
|
*/
|
|
22
22
|
falseValue: String,
|
|
23
23
|
/**
|
|
@@ -90,7 +90,7 @@ const CFormCheck = defineComponent({
|
|
|
90
90
|
/**
|
|
91
91
|
* Use in conjunction with the v-model directive to specify the value that should be assigned to the bound variable when the checkbox is in the `true` state.
|
|
92
92
|
*
|
|
93
|
-
* @since 4.
|
|
93
|
+
* @since 4.10.0
|
|
94
94
|
*/
|
|
95
95
|
trueValue: String,
|
|
96
96
|
/**
|
|
@@ -189,7 +189,7 @@ const CFormCheck = defineComponent({
|
|
|
189
189
|
const formControl = () => {
|
|
190
190
|
return h('input', {
|
|
191
191
|
...attrs,
|
|
192
|
-
...(props.modelValue
|
|
192
|
+
...((props.modelValue || props.value) && { checked: isChecked.value }),
|
|
193
193
|
class: inputClassName,
|
|
194
194
|
id: props.id,
|
|
195
195
|
indeterminate: props.indeterminate,
|
|
@@ -259,4 +259,4 @@ const CFormCheck = defineComponent({
|
|
|
259
259
|
},
|
|
260
260
|
})
|
|
261
261
|
|
|
262
|
-
export { CFormCheck }
|
|
262
|
+
export { CFormCheck }
|
|
@@ -51,6 +51,15 @@ const CModal = defineComponent({
|
|
|
51
51
|
* A string of all className you want applied to the modal content component.
|
|
52
52
|
*/
|
|
53
53
|
contentClassName: String,
|
|
54
|
+
/**
|
|
55
|
+
* Puts the focus on the modal when shown.
|
|
56
|
+
*
|
|
57
|
+
* @since v5.0.0-alpha.1
|
|
58
|
+
*/
|
|
59
|
+
focus: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: true,
|
|
62
|
+
},
|
|
54
63
|
/**
|
|
55
64
|
* Set modal to covers the entire user viewport
|
|
56
65
|
*
|
|
@@ -124,6 +133,7 @@ const CModal = defineComponent({
|
|
|
124
133
|
'show',
|
|
125
134
|
],
|
|
126
135
|
setup(props, { slots, attrs, emit }) {
|
|
136
|
+
const activeElementRef = ref()
|
|
127
137
|
const modalRef = ref()
|
|
128
138
|
const modalContentRef = ref()
|
|
129
139
|
const visible = ref(props.visible)
|
|
@@ -136,6 +146,7 @@ const CModal = defineComponent({
|
|
|
136
146
|
)
|
|
137
147
|
|
|
138
148
|
const handleEnter = (el: RendererElement, done: () => void) => {
|
|
149
|
+
activeElementRef.value = document.activeElement as HTMLElement | null
|
|
139
150
|
executeAfterTransition(() => done(), el as HTMLElement)
|
|
140
151
|
document.body.classList.add('modal-open')
|
|
141
152
|
document.body.style.overflow = 'hidden'
|
|
@@ -148,6 +159,7 @@ const CModal = defineComponent({
|
|
|
148
159
|
}
|
|
149
160
|
|
|
150
161
|
const handleAfterEnter = () => {
|
|
162
|
+
props.focus && modalRef.value?.focus()
|
|
151
163
|
window.addEventListener('mousedown', handleMouseDown)
|
|
152
164
|
window.addEventListener('keyup', handleKeyUp)
|
|
153
165
|
}
|
|
@@ -166,6 +178,7 @@ const CModal = defineComponent({
|
|
|
166
178
|
}
|
|
167
179
|
|
|
168
180
|
const handleAfterLeave = (el: RendererElement) => {
|
|
181
|
+
activeElementRef.value?.focus()
|
|
169
182
|
window.removeEventListener('mousedown', handleMouseDown)
|
|
170
183
|
window.removeEventListener('keyup', handleKeyUp)
|
|
171
184
|
el.style.display = 'none'
|
|
@@ -217,6 +230,7 @@ const CModal = defineComponent({
|
|
|
217
230
|
h(
|
|
218
231
|
'div',
|
|
219
232
|
{
|
|
233
|
+
...attrs,
|
|
220
234
|
class: [
|
|
221
235
|
'modal',
|
|
222
236
|
{
|
|
@@ -224,6 +238,7 @@ const CModal = defineComponent({
|
|
|
224
238
|
},
|
|
225
239
|
attrs.class,
|
|
226
240
|
],
|
|
241
|
+
...(visible.value ? { 'aria-modal': true, role: 'dialog' } : { 'aria-hidden': 'true' }),
|
|
227
242
|
ref: modalRef,
|
|
228
243
|
},
|
|
229
244
|
h(
|
|
@@ -240,7 +255,6 @@ const CModal = defineComponent({
|
|
|
240
255
|
[`modal-${props.size}`]: props.size,
|
|
241
256
|
},
|
|
242
257
|
],
|
|
243
|
-
role: 'dialog',
|
|
244
258
|
},
|
|
245
259
|
h(
|
|
246
260
|
'div',
|
|
@@ -298,7 +298,7 @@ const CMultiSelect = defineComponent({
|
|
|
298
298
|
if (
|
|
299
299
|
props.allowCreateOptions &&
|
|
300
300
|
filteredOptions.value.some(
|
|
301
|
-
(option) => option.
|
|
301
|
+
(option) => option.label && option.label.toLowerCase() === searchValue.value.toLowerCase(),
|
|
302
302
|
)
|
|
303
303
|
) {
|
|
304
304
|
return false
|
|
@@ -425,7 +425,7 @@ const CMultiSelect = defineComponent({
|
|
|
425
425
|
selected.value = [
|
|
426
426
|
...selected.value,
|
|
427
427
|
filteredOptions.value.find(
|
|
428
|
-
(option) => String(option.
|
|
428
|
+
(option) => String(option.label).toLowerCase() === searchValue.value.toLowerCase(),
|
|
429
429
|
) as Option,
|
|
430
430
|
]
|
|
431
431
|
}
|
|
@@ -458,7 +458,7 @@ const CMultiSelect = defineComponent({
|
|
|
458
458
|
|
|
459
459
|
const handleOptionClick = (option: Option) => {
|
|
460
460
|
if (!props.multiple) {
|
|
461
|
-
selected.value = [
|
|
461
|
+
selected.value = [option] as SelectedOption[]
|
|
462
462
|
visible.value = false
|
|
463
463
|
|
|
464
464
|
if (searchRef.value) {
|
|
@@ -483,10 +483,7 @@ const CMultiSelect = defineComponent({
|
|
|
483
483
|
if (selected.value.some((_option) => _option.value === option.value)) {
|
|
484
484
|
selected.value = selected.value.filter((_option) => _option.value !== option.value)
|
|
485
485
|
} else {
|
|
486
|
-
selected.value = [
|
|
487
|
-
...selected.value,
|
|
488
|
-
{ value: option.value, text: option.text },
|
|
489
|
-
] as SelectedOption[]
|
|
486
|
+
selected.value = [...selected.value, option] as SelectedOption[]
|
|
490
487
|
}
|
|
491
488
|
}
|
|
492
489
|
|
|
@@ -592,7 +589,7 @@ const CMultiSelect = defineComponent({
|
|
|
592
589
|
}),
|
|
593
590
|
...(selected.value.length > 0 &&
|
|
594
591
|
!props.multiple && {
|
|
595
|
-
placeholder: selected.value.map((option) => option.
|
|
592
|
+
placeholder: selected.value.map((option) => option.label)[0],
|
|
596
593
|
}),
|
|
597
594
|
|
|
598
595
|
...(props.multiple &&
|
|
@@ -59,7 +59,7 @@ const CMultiSelectSelection = defineComponent({
|
|
|
59
59
|
props.selected.map((option: Option) => {
|
|
60
60
|
if (props.selectionType === 'tags') {
|
|
61
61
|
return h('span', { class: 'form-multi-select-tag' }, [
|
|
62
|
-
option.
|
|
62
|
+
option.label,
|
|
63
63
|
!option.disabled &&
|
|
64
64
|
h('button', {
|
|
65
65
|
class: 'form-multi-select-tag-delete',
|
|
@@ -73,9 +73,9 @@ const CMultiSelectSelection = defineComponent({
|
|
|
73
73
|
props.multiple &&
|
|
74
74
|
props.selectionType === 'text' &&
|
|
75
75
|
props.selected.map((option, index) =>
|
|
76
|
-
h('span', `${option.
|
|
76
|
+
h('span', `${option.label}${index === props.selected.length - 1 ? '' : ','}\xA0`),
|
|
77
77
|
),
|
|
78
|
-
!props.multiple && !props.search && props.selected.map((option) => option.
|
|
78
|
+
!props.multiple && !props.search && props.selected.map((option) => option.label)[0],
|
|
79
79
|
slots.default && slots.default(),
|
|
80
80
|
],
|
|
81
81
|
)
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Option, OptionsGroup, SelectedOption } from './types'
|
|
2
2
|
|
|
3
|
-
export const createOption = (
|
|
4
|
-
const value =
|
|
3
|
+
export const createOption = (label: string, options: (Option | OptionsGroup)[]) => {
|
|
4
|
+
const value = label.toLowerCase().replace(/\s/g, '-')
|
|
5
5
|
let uniqueValue = value
|
|
6
6
|
let i = 1
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ export const createOption = (text: string, options: (Option | OptionsGroup)[]) =
|
|
|
13
13
|
return [
|
|
14
14
|
{
|
|
15
15
|
value: uniqueValue,
|
|
16
|
-
|
|
16
|
+
label,
|
|
17
17
|
custom: true,
|
|
18
18
|
},
|
|
19
19
|
]
|
|
@@ -28,10 +28,10 @@ export const filterOptionsList = (search: string, _options: (Option | OptionsGro
|
|
|
28
28
|
option.options &&
|
|
29
29
|
option.options.filter(
|
|
30
30
|
(option: Option) =>
|
|
31
|
-
option.
|
|
31
|
+
option.label && option.label.toLowerCase().includes(search.toLowerCase()),
|
|
32
32
|
)
|
|
33
33
|
if (
|
|
34
|
-
(option.
|
|
34
|
+
(option.label && option.label.toLowerCase().includes(search.toLowerCase())) ||
|
|
35
35
|
(options && options.length > 0)
|
|
36
36
|
) {
|
|
37
37
|
optionsList.push(Object.assign({}, option, options && options.length > 0 && { options }))
|
|
@@ -74,13 +74,13 @@ const CNavbar = defineComponent({
|
|
|
74
74
|
'navbar',
|
|
75
75
|
{
|
|
76
76
|
[`bg-${props.color}`]: props.color,
|
|
77
|
-
[`navbar-${props.colorScheme}`]: props.colorScheme,
|
|
78
77
|
[typeof props.expand === 'boolean'
|
|
79
78
|
? 'navbar-expand'
|
|
80
79
|
: `navbar-expand-${props.expand}`]: props.expand,
|
|
81
80
|
},
|
|
82
81
|
props.placement,
|
|
83
82
|
],
|
|
83
|
+
...(props.colorScheme && { 'data-coreui-theme': props.colorScheme }),
|
|
84
84
|
},
|
|
85
85
|
props.container
|
|
86
86
|
? h(
|
|
@@ -26,6 +26,10 @@ const COffcanvas = defineComponent({
|
|
|
26
26
|
return false
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
|
+
/**
|
|
30
|
+
* Sets a darker color scheme.
|
|
31
|
+
*/
|
|
32
|
+
dark: Boolean,
|
|
29
33
|
/**
|
|
30
34
|
* Closes the offcanvas when escape key is pressed.
|
|
31
35
|
*/
|
|
@@ -159,6 +163,7 @@ const COffcanvas = defineComponent({
|
|
|
159
163
|
h(
|
|
160
164
|
Transition,
|
|
161
165
|
{
|
|
166
|
+
appear: visible.value,
|
|
162
167
|
css: false,
|
|
163
168
|
onEnter: (el, done) => handleEnter(el, done),
|
|
164
169
|
onAfterEnter: () => handleAfterEnter(),
|
|
@@ -182,6 +187,7 @@ const COffcanvas = defineComponent({
|
|
|
182
187
|
ref: offcanvasRef,
|
|
183
188
|
role: 'dialog',
|
|
184
189
|
tabindex: -1,
|
|
190
|
+
...(props.dark && { 'data-coreui-theme': 'dark' }),
|
|
185
191
|
},
|
|
186
192
|
slots.default && slots.default(),
|
|
187
193
|
),
|
|
@@ -1,25 +1,61 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue'
|
|
1
|
+
import { defineComponent, h, inject } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { CProgressBar } from './CProgressBar'
|
|
4
|
+
import { Color } from '../../props'
|
|
4
5
|
|
|
5
6
|
const CProgress = defineComponent({
|
|
6
7
|
name: 'CProgress',
|
|
7
8
|
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Use to animate the stripes right to left via CSS3 animations.
|
|
11
|
+
*/
|
|
12
|
+
animated: Boolean,
|
|
13
|
+
/**
|
|
14
|
+
* Sets the color context of the component to one of CoreUI’s themed colors.
|
|
15
|
+
*
|
|
16
|
+
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
17
|
+
*/
|
|
18
|
+
color: Color,
|
|
8
19
|
/**
|
|
9
20
|
* Sets the height of the component. If you set that value the inner `<CProgressBar>` will automatically resize accordingly.
|
|
10
21
|
*/
|
|
11
22
|
height: Number,
|
|
23
|
+
/**
|
|
24
|
+
* A string of all className you want applied to the <CProgressBar/> component.
|
|
25
|
+
*
|
|
26
|
+
* @since 5.0.0-alpha.1
|
|
27
|
+
*/
|
|
28
|
+
progressBarClassName: String,
|
|
12
29
|
/**
|
|
13
30
|
* Makes progress bar thinner.
|
|
14
31
|
*/
|
|
15
32
|
thin: Boolean,
|
|
33
|
+
/**
|
|
34
|
+
* The percent to progress the ProgressBar.
|
|
35
|
+
*/
|
|
36
|
+
value: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: 0,
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Set the progress bar variant to optional striped.
|
|
42
|
+
*
|
|
43
|
+
* @values 'striped'
|
|
44
|
+
*/
|
|
45
|
+
variant: {
|
|
46
|
+
type: String,
|
|
47
|
+
validator: (value: string) => {
|
|
48
|
+
return value === 'striped'
|
|
49
|
+
},
|
|
50
|
+
},
|
|
16
51
|
/**
|
|
17
52
|
* Change the default color to white.
|
|
18
53
|
*/
|
|
19
54
|
white: Boolean,
|
|
20
|
-
...CProgressBar.props,
|
|
21
55
|
},
|
|
22
56
|
setup(props, { slots }) {
|
|
57
|
+
const stacked = inject('stacked', false) as boolean
|
|
58
|
+
|
|
23
59
|
return () =>
|
|
24
60
|
h(
|
|
25
61
|
'div',
|
|
@@ -31,20 +67,42 @@ const CProgress = defineComponent({
|
|
|
31
67
|
'progress-white': props.white,
|
|
32
68
|
},
|
|
33
69
|
],
|
|
34
|
-
|
|
70
|
+
style: {
|
|
71
|
+
...(props.height ? { height: `${props.height}px` } : {}),
|
|
72
|
+
...(stacked ? { width: `${props.value}%` } : {}),
|
|
73
|
+
},
|
|
74
|
+
...(props.value !== undefined && {
|
|
75
|
+
role: 'progressbar',
|
|
76
|
+
'aria-valuenow': props.value,
|
|
77
|
+
'aria-valuemin': 0,
|
|
78
|
+
'aria-valuemax': 100,
|
|
79
|
+
}),
|
|
35
80
|
},
|
|
36
|
-
|
|
37
|
-
|
|
81
|
+
// @ts-expect-error name is defined in component
|
|
82
|
+
slots.default && slots.default().some((vnode) => vnode.type.name === 'CProgressBar')
|
|
83
|
+
? slots.default().map((vnode) => {
|
|
84
|
+
// @ts-expect-error name is defined in component
|
|
85
|
+
if (vnode.type.name === 'CProgressBar') {
|
|
86
|
+
return h(vnode, {
|
|
87
|
+
...(props.animated && { animated: props.animated }),
|
|
88
|
+
...(props.color && { color: props.color }),
|
|
89
|
+
...(props.value && { value: props.value }),
|
|
90
|
+
...(props.variant && { variant: props.variant }),
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
return vnode
|
|
94
|
+
})
|
|
95
|
+
: h(
|
|
38
96
|
CProgressBar,
|
|
39
97
|
{
|
|
40
|
-
|
|
98
|
+
...(props.progressBarClassName && { class: props.progressBarClassName }),
|
|
41
99
|
animated: props.animated,
|
|
42
100
|
color: props.color,
|
|
101
|
+
value: props.value,
|
|
43
102
|
variant: props.variant,
|
|
44
103
|
},
|
|
45
|
-
slots.default && slots.default(),
|
|
46
|
-
)
|
|
47
|
-
: slots.default && slots.default(),
|
|
104
|
+
() => slots.default && slots.default(),
|
|
105
|
+
),
|
|
48
106
|
)
|
|
49
107
|
},
|
|
50
108
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue'
|
|
1
|
+
import { defineComponent, h, inject } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { Color } from '../../props'
|
|
4
4
|
|
|
@@ -35,6 +35,8 @@ const CProgressBar = defineComponent({
|
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
setup(props, { slots }) {
|
|
38
|
+
const stacked = inject('stacked', false) as boolean
|
|
39
|
+
|
|
38
40
|
return () =>
|
|
39
41
|
h(
|
|
40
42
|
'div',
|
|
@@ -47,11 +49,7 @@ const CProgressBar = defineComponent({
|
|
|
47
49
|
['progress-bar-animated']: props.animated,
|
|
48
50
|
},
|
|
49
51
|
],
|
|
50
|
-
|
|
51
|
-
style: `width: ${props.value}%`,
|
|
52
|
-
'aria-valuenow': props.value,
|
|
53
|
-
'aria-valuemin': '0',
|
|
54
|
-
'aria-valuemax': '100',
|
|
52
|
+
...(!stacked && { style: { width: `${props.value}%` } }),
|
|
55
53
|
},
|
|
56
54
|
slots.default && slots.default(),
|
|
57
55
|
)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineComponent, h, provide } from 'vue'
|
|
2
|
+
|
|
3
|
+
const CProgressStacked = defineComponent({
|
|
4
|
+
name: 'CProgressStacked',
|
|
5
|
+
props: {},
|
|
6
|
+
setup(_, { slots }) {
|
|
7
|
+
provide('stacked', true)
|
|
8
|
+
return () =>
|
|
9
|
+
h(
|
|
10
|
+
'div',
|
|
11
|
+
{
|
|
12
|
+
class: 'progress-stacked',
|
|
13
|
+
},
|
|
14
|
+
slots.default && slots.default(),
|
|
15
|
+
)
|
|
16
|
+
},
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
export { CProgressStacked }
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { App } from 'vue'
|
|
2
2
|
import { CProgress } from './CProgress'
|
|
3
3
|
import { CProgressBar } from './CProgressBar'
|
|
4
|
+
import { CProgressStacked } from './CProgressStacked'
|
|
4
5
|
|
|
5
6
|
const CProgressPlugin = {
|
|
6
7
|
install: (app: App): void => {
|
|
7
8
|
app.component(CProgress.name, CProgress)
|
|
8
9
|
app.component(CProgressBar.name, CProgressBar)
|
|
10
|
+
app.component(CProgressStacked.name, CProgressStacked)
|
|
9
11
|
},
|
|
10
12
|
}
|
|
11
13
|
|
|
12
|
-
export { CProgressPlugin, CProgress, CProgressBar }
|
|
14
|
+
export { CProgressPlugin, CProgress, CProgressBar, CProgressStacked }
|
|
@@ -140,11 +140,26 @@ const CSmartPagination = defineComponent({
|
|
|
140
140
|
const limit = ref(props.limit)
|
|
141
141
|
const pages = ref(props.pages)
|
|
142
142
|
|
|
143
|
-
watch(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
watch(
|
|
144
|
+
() => props.activePage,
|
|
145
|
+
() => {
|
|
146
|
+
activePage.value = props.activePage
|
|
147
|
+
},
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
watch(
|
|
151
|
+
() => props.limit,
|
|
152
|
+
() => {
|
|
153
|
+
limit.value = props.limit
|
|
154
|
+
},
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
watch(
|
|
158
|
+
() => props.pages,
|
|
159
|
+
() => {
|
|
160
|
+
pages.value = props.pages
|
|
161
|
+
},
|
|
162
|
+
)
|
|
148
163
|
|
|
149
164
|
const showDots = computed(() => {
|
|
150
165
|
return props.dots && limit.value > 4 && limit.value < pages.value
|