@coreui/vue-pro 4.7.0 → 4.8.0-next.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/dist/components/calendar/utils.d.ts +23 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/modal/CModal.d.ts +4 -20
- package/dist/components/multi-select/CMultiSelect.d.ts +35 -44
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +13 -11
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
- package/dist/components/multi-select/types.d.ts +14 -0
- package/dist/components/multi-select/utils.d.ts +6 -0
- package/dist/components/offcanvas/COffcanvas.d.ts +35 -18
- package/dist/components/smart-table/CSmartTable.d.ts +65 -87
- package/dist/components/smart-table/CSmartTableBody.d.ts +16 -40
- package/dist/components/smart-table/CSmartTableHead.d.ts +17 -58
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
- package/dist/components/smart-table/types.d.ts +50 -0
- package/dist/components/smart-table/utils.d.ts +17 -0
- package/dist/components/table/CTable.d.ts +1 -1
- package/dist/components/time-picker/types.d.ts +15 -0
- package/dist/components/time-picker/utils.d.ts +23 -0
- package/dist/components/virtual-scroller/CVirtualScroller.d.ts +23 -0
- package/dist/components/virtual-scroller/index.d.ts +6 -0
- package/dist/index.es.js +943 -885
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +943 -883
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/isObjectInArray.d.ts +2 -0
- package/package.json +6 -6
- package/src/components/calendar/CCalendar.ts +1 -1
- package/src/{utils/calendar.ts → components/calendar/utils.ts} +1 -1
- package/src/components/date-range-picker/CDateRangePicker.ts +1 -1
- package/src/components/element-cover/CElementCover.ts +14 -14
- package/src/components/index.ts +1 -0
- package/src/components/modal/CModal.ts +10 -10
- package/src/components/multi-select/CMultiSelect.ts +33 -99
- package/src/components/multi-select/CMultiSelectNativeSelect.ts +2 -1
- package/src/components/multi-select/CMultiSelectOptions.ts +31 -17
- package/src/components/multi-select/CMultiSelectSelection.ts +2 -1
- package/src/components/multi-select/types.ts +15 -0
- package/src/components/multi-select/utils.ts +92 -0
- package/src/components/offcanvas/COffcanvas.ts +50 -28
- package/src/components/smart-table/CSmartTable.ts +365 -268
- package/src/components/smart-table/CSmartTableBody.ts +126 -137
- package/src/components/smart-table/CSmartTableHead.ts +53 -138
- package/src/components/smart-table/CSmartTableInterface.ts +1 -1
- package/src/components/smart-table/types.ts +61 -0
- package/src/components/smart-table/utils.ts +212 -0
- package/src/components/time-picker/CTimePicker.ts +49 -27
- package/src/components/time-picker/types.ts +15 -0
- package/src/{utils/time.ts → components/time-picker/utils.ts} +43 -2
- package/src/components/virtual-scroller/CVirtualScroller.ts +109 -0
- package/src/components/virtual-scroller/index.ts +10 -0
- package/src/utils/index.ts +1 -3
- package/src/utils/getNextSibling.ts +0 -18
- package/src/utils/getPreviousSibling.ts +0 -18
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Option, SelectedOption } from './types'
|
|
2
|
+
|
|
3
|
+
export const filterOptionsList = (search: string, _options: Option[]) => {
|
|
4
|
+
return search.length
|
|
5
|
+
? _options &&
|
|
6
|
+
_options.reduce((acc: Option[], val: Option) => {
|
|
7
|
+
const options =
|
|
8
|
+
val.options &&
|
|
9
|
+
val.options.filter(
|
|
10
|
+
(element) =>
|
|
11
|
+
element.text && element.text.toLowerCase().includes(search.toLowerCase()),
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
if (
|
|
15
|
+
(val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
16
|
+
(options && options.length)
|
|
17
|
+
) {
|
|
18
|
+
acc.push(Object.assign({}, val, options && options.length && { options }))
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return acc
|
|
22
|
+
}, [])
|
|
23
|
+
: _options
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const flattenArray = (options: Option[]): Option[] => {
|
|
27
|
+
return options.reduce((acc: Option[], val: Option) => {
|
|
28
|
+
return acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val)
|
|
29
|
+
}, [])
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const getNextSibling = (elem: HTMLElement, selector?: string) => {
|
|
33
|
+
// Get the next sibling element
|
|
34
|
+
let sibling = elem.nextElementSibling
|
|
35
|
+
|
|
36
|
+
// If there's no selector, return the first sibling
|
|
37
|
+
if (!selector) return sibling
|
|
38
|
+
|
|
39
|
+
// If the sibling matches our selector, use it
|
|
40
|
+
// If not, jump to the next sibling and continue the loop
|
|
41
|
+
while (sibling) {
|
|
42
|
+
if (sibling.matches(selector)) return sibling
|
|
43
|
+
sibling = sibling.nextElementSibling
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const getPreviousSibling = (elem: HTMLElement, selector?: string) => {
|
|
50
|
+
// Get the next sibling element
|
|
51
|
+
let sibling = elem.previousElementSibling
|
|
52
|
+
|
|
53
|
+
// If there's no selector, return the first sibling
|
|
54
|
+
if (!selector) return sibling
|
|
55
|
+
|
|
56
|
+
// If the sibling matches our selector, use it
|
|
57
|
+
// If not, jump to the next sibling and continue the loop
|
|
58
|
+
while (sibling) {
|
|
59
|
+
if (sibling.matches(selector)) return sibling
|
|
60
|
+
sibling = sibling.previousElementSibling
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const selectOptions = (
|
|
67
|
+
options: Option[],
|
|
68
|
+
selected: SelectedOption[],
|
|
69
|
+
deselected?: Option[],
|
|
70
|
+
) => {
|
|
71
|
+
let _selected = [...selected, ...options]
|
|
72
|
+
|
|
73
|
+
if (deselected) {
|
|
74
|
+
_selected = _selected.filter(
|
|
75
|
+
(selectedOption) =>
|
|
76
|
+
!deselected.some((deselectedOption) => deselectedOption.value === selectedOption.value),
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const deduplicated = _selected.reduce((unique: Option[], option) => {
|
|
81
|
+
if (!unique.some((obj) => obj.value === option.value)) {
|
|
82
|
+
unique.push({
|
|
83
|
+
value: option.value,
|
|
84
|
+
text: option.text,
|
|
85
|
+
...(option.disabled && { disabled: option.disabled }),
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
return unique
|
|
89
|
+
}, []) as SelectedOption[]
|
|
90
|
+
|
|
91
|
+
return deduplicated
|
|
92
|
+
}
|
|
@@ -10,11 +10,21 @@ const COffcanvas = defineComponent({
|
|
|
10
10
|
props: {
|
|
11
11
|
/**
|
|
12
12
|
* Apply a backdrop on body while offcanvas is open.
|
|
13
|
+
*
|
|
14
|
+
* @values boolean | 'static'
|
|
13
15
|
*/
|
|
14
16
|
backdrop: {
|
|
15
|
-
type: Boolean,
|
|
17
|
+
type: [Boolean, String],
|
|
16
18
|
default: true,
|
|
17
|
-
|
|
19
|
+
validator: (value: boolean | string) => {
|
|
20
|
+
if (typeof value === 'string') {
|
|
21
|
+
return ['static'].includes(value)
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === 'boolean') {
|
|
24
|
+
return true
|
|
25
|
+
}
|
|
26
|
+
return false
|
|
27
|
+
},
|
|
18
28
|
},
|
|
19
29
|
/**
|
|
20
30
|
* Closes the offcanvas when escape key is pressed.
|
|
@@ -22,7 +32,6 @@ const COffcanvas = defineComponent({
|
|
|
22
32
|
keyboard: {
|
|
23
33
|
type: Boolean,
|
|
24
34
|
default: true,
|
|
25
|
-
require: false,
|
|
26
35
|
},
|
|
27
36
|
/**
|
|
28
37
|
* Components placement, there’s no default placement.
|
|
@@ -37,21 +46,36 @@ const COffcanvas = defineComponent({
|
|
|
37
46
|
return ['start', 'end', 'top', 'bottom'].includes(value)
|
|
38
47
|
},
|
|
39
48
|
},
|
|
49
|
+
/**
|
|
50
|
+
* Responsive offcanvas property hide content outside the viewport from a specified breakpoint and down.
|
|
51
|
+
*
|
|
52
|
+
* @values boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
|
|
53
|
+
* @since 4.7.0
|
|
54
|
+
*/
|
|
55
|
+
responsive: {
|
|
56
|
+
type: [Boolean, String],
|
|
57
|
+
default: true,
|
|
58
|
+
validator: (value: boolean | string) => {
|
|
59
|
+
if (typeof value === 'string') {
|
|
60
|
+
return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value)
|
|
61
|
+
}
|
|
62
|
+
if (typeof value === 'boolean') {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
return false
|
|
66
|
+
},
|
|
67
|
+
},
|
|
40
68
|
/**
|
|
41
69
|
* Allow body scrolling while offcanvas is open
|
|
42
70
|
*/
|
|
43
71
|
scroll: {
|
|
44
72
|
type: Boolean,
|
|
45
73
|
default: false,
|
|
46
|
-
required: false,
|
|
47
74
|
},
|
|
48
75
|
/**
|
|
49
76
|
* Toggle the visibility of offcanvas component.
|
|
50
77
|
*/
|
|
51
|
-
visible:
|
|
52
|
-
type: Boolean,
|
|
53
|
-
require: false,
|
|
54
|
-
},
|
|
78
|
+
visible: Boolean,
|
|
55
79
|
},
|
|
56
80
|
emits: [
|
|
57
81
|
/**
|
|
@@ -93,22 +117,21 @@ const COffcanvas = defineComponent({
|
|
|
93
117
|
emit('show')
|
|
94
118
|
executeAfterTransition(() => done(), el as HTMLElement)
|
|
95
119
|
setTimeout(() => {
|
|
96
|
-
el.style.visibility = 'visible'
|
|
97
120
|
el.classList.add('show')
|
|
98
121
|
}, 1)
|
|
99
122
|
}
|
|
123
|
+
|
|
100
124
|
const handleAfterEnter = () => {
|
|
101
|
-
|
|
102
|
-
window.addEventListener('keyup', handleKeyUp)
|
|
125
|
+
offcanvasRef.value.focus()
|
|
103
126
|
}
|
|
127
|
+
|
|
104
128
|
const handleLeave = (el: RendererElement, done: () => void) => {
|
|
105
129
|
executeAfterTransition(() => done(), el as HTMLElement)
|
|
106
|
-
|
|
107
|
-
window.removeEventListener('keyup', handleKeyUp)
|
|
108
|
-
el.classList.remove('show')
|
|
130
|
+
el.classList.add('hiding')
|
|
109
131
|
}
|
|
132
|
+
|
|
110
133
|
const handleAfterLeave = (el: RendererElement) => {
|
|
111
|
-
el.
|
|
134
|
+
el.classList.remove('show', 'hiding')
|
|
112
135
|
}
|
|
113
136
|
|
|
114
137
|
const handleDismiss = () => {
|
|
@@ -116,21 +139,15 @@ const COffcanvas = defineComponent({
|
|
|
116
139
|
emit('hide')
|
|
117
140
|
}
|
|
118
141
|
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
return handleDismiss()
|
|
123
|
-
}
|
|
142
|
+
const handleBackdropDismiss = () => {
|
|
143
|
+
if (props.backdrop !== 'static') {
|
|
144
|
+
handleDismiss()
|
|
124
145
|
}
|
|
125
146
|
}
|
|
126
147
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const handleMouseUp = (event: Event) => {
|
|
132
|
-
if (offcanvasRef.value && !offcanvasRef.value.contains(event.target as HTMLElement)) {
|
|
133
|
-
props.backdrop && handleDismiss()
|
|
148
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
149
|
+
if (event.key === 'Escape' && props.keyboard) {
|
|
150
|
+
handleDismiss()
|
|
134
151
|
}
|
|
135
152
|
}
|
|
136
153
|
|
|
@@ -150,13 +167,17 @@ const COffcanvas = defineComponent({
|
|
|
150
167
|
'div',
|
|
151
168
|
{
|
|
152
169
|
class: [
|
|
153
|
-
'offcanvas',
|
|
154
170
|
{
|
|
171
|
+
[`offcanvas${
|
|
172
|
+
typeof props.responsive !== 'boolean' ? '-' + props.responsive : ''
|
|
173
|
+
}`]: props.responsive,
|
|
155
174
|
[`offcanvas-${props.placement}`]: props.placement,
|
|
156
175
|
},
|
|
157
176
|
],
|
|
177
|
+
onKeydown: (event: KeyboardEvent) => handleKeyDown(event),
|
|
158
178
|
ref: offcanvasRef,
|
|
159
179
|
role: 'dialog',
|
|
180
|
+
tabindex: -1,
|
|
160
181
|
},
|
|
161
182
|
slots.default && slots.default(),
|
|
162
183
|
),
|
|
@@ -166,6 +187,7 @@ const COffcanvas = defineComponent({
|
|
|
166
187
|
props.backdrop &&
|
|
167
188
|
h(CBackdrop, {
|
|
168
189
|
class: 'offcanvas-backdrop',
|
|
190
|
+
onClick: handleBackdropDismiss,
|
|
169
191
|
visible: visible.value,
|
|
170
192
|
}),
|
|
171
193
|
]
|