@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
package/dist/utils/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreui/vue-pro",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0-next.1",
|
|
4
4
|
"description": "UI Components Library for Vue.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@popperjs/core": "^2.11.6",
|
|
38
|
-
"@rollup/plugin-commonjs": "^24.0.
|
|
38
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
39
39
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
40
40
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
41
|
-
"@vue/test-utils": "^2.2.
|
|
41
|
+
"@vue/test-utils": "^2.2.10",
|
|
42
42
|
"date-fns": "^2.29.3",
|
|
43
|
-
"rollup": "^3.
|
|
43
|
+
"rollup": "^3.15.0",
|
|
44
44
|
"rollup-plugin-vue": "^6.0.0",
|
|
45
|
-
"typescript": "^4.9.
|
|
46
|
-
"vue": "^3.2.
|
|
45
|
+
"typescript": "^4.9.5",
|
|
46
|
+
"vue": "^3.2.47",
|
|
47
47
|
"vue-types": "^5.0.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -4,7 +4,7 @@ export const convertToLocalDate = (d: Date, locale: string, options = {}) =>
|
|
|
4
4
|
export const convertToLocalTime = (d: Date, locale: string, options = {}) =>
|
|
5
5
|
d.toLocaleTimeString(locale, options)
|
|
6
6
|
|
|
7
|
-
export const createGroupsInArray = (arr:
|
|
7
|
+
export const createGroupsInArray = <T>(arr: T[], numberOfGroups: number): T[][] => {
|
|
8
8
|
const perGroup = Math.ceil(arr.length / numberOfGroups)
|
|
9
9
|
return new Array(numberOfGroups)
|
|
10
10
|
.fill('')
|
|
@@ -9,7 +9,7 @@ import { CFormControlWrapper } from './../form/CFormControlWrapper'
|
|
|
9
9
|
import { CPicker } from '../picker'
|
|
10
10
|
import { CTimePicker } from '../time-picker'
|
|
11
11
|
|
|
12
|
-
import { getLocalDateFromString } from '
|
|
12
|
+
import { getLocalDateFromString } from '../calendar/utils'
|
|
13
13
|
|
|
14
14
|
import { Color } from '../props'
|
|
15
15
|
|
|
@@ -84,23 +84,23 @@ const CElementCover = defineComponent({
|
|
|
84
84
|
style: { ...coverStyles, ...customBoundaries.value },
|
|
85
85
|
ref: elementCoverRef,
|
|
86
86
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
h(
|
|
88
|
+
'div',
|
|
89
|
+
{
|
|
90
|
+
style: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
top: '50%',
|
|
93
|
+
left: '50%',
|
|
94
|
+
transform: 'translateX(-50%) translateY(-50%)',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
slots.default
|
|
98
|
+
? slots.default()
|
|
99
|
+
: h(CSpinner, {
|
|
100
100
|
variant: 'grow',
|
|
101
101
|
color: 'primary',
|
|
102
102
|
}),
|
|
103
|
-
|
|
103
|
+
),
|
|
104
104
|
)
|
|
105
105
|
},
|
|
106
106
|
})
|
package/src/components/index.ts
CHANGED
|
@@ -25,7 +25,6 @@ const CModal = defineComponent({
|
|
|
25
25
|
*/
|
|
26
26
|
alignment: {
|
|
27
27
|
default: 'top',
|
|
28
|
-
required: false,
|
|
29
28
|
validator: (value: string) => {
|
|
30
29
|
return ['top', 'center'].includes(value)
|
|
31
30
|
},
|
|
@@ -33,12 +32,20 @@ const CModal = defineComponent({
|
|
|
33
32
|
/**
|
|
34
33
|
* Apply a backdrop on body while offcanvas is open.
|
|
35
34
|
*
|
|
36
|
-
* @values 'static'
|
|
35
|
+
* @values boolean | 'static'
|
|
37
36
|
*/
|
|
38
37
|
backdrop: {
|
|
39
38
|
type: [Boolean, String],
|
|
40
39
|
default: true,
|
|
41
|
-
|
|
40
|
+
validator: (value: boolean | string) => {
|
|
41
|
+
if (typeof value == 'string') {
|
|
42
|
+
return ['static'].includes(value)
|
|
43
|
+
}
|
|
44
|
+
if (typeof value == 'boolean') {
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
return false
|
|
48
|
+
},
|
|
42
49
|
},
|
|
43
50
|
/**
|
|
44
51
|
* A string of all className you want applied to the modal content component.
|
|
@@ -46,7 +53,6 @@ const CModal = defineComponent({
|
|
|
46
53
|
contentClassName: {
|
|
47
54
|
type: String,
|
|
48
55
|
default: undefined,
|
|
49
|
-
required: false,
|
|
50
56
|
},
|
|
51
57
|
/**
|
|
52
58
|
* Set modal to covers the entire user viewport
|
|
@@ -56,7 +62,6 @@ const CModal = defineComponent({
|
|
|
56
62
|
fullscreen: {
|
|
57
63
|
type: [Boolean, String],
|
|
58
64
|
default: undefined,
|
|
59
|
-
required: false,
|
|
60
65
|
validator: (value: boolean | string) => {
|
|
61
66
|
if (typeof value == 'string') {
|
|
62
67
|
return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value)
|
|
@@ -73,14 +78,12 @@ const CModal = defineComponent({
|
|
|
73
78
|
keyboard: {
|
|
74
79
|
type: Boolean,
|
|
75
80
|
default: true,
|
|
76
|
-
required: false,
|
|
77
81
|
},
|
|
78
82
|
/**
|
|
79
83
|
* Create a scrollable modal that allows scrolling the modal body.
|
|
80
84
|
*/
|
|
81
85
|
scrollable: {
|
|
82
86
|
type: Boolean,
|
|
83
|
-
required: false,
|
|
84
87
|
},
|
|
85
88
|
/**
|
|
86
89
|
* Size the component small, large, or extra large.
|
|
@@ -90,7 +93,6 @@ const CModal = defineComponent({
|
|
|
90
93
|
size: {
|
|
91
94
|
type: String,
|
|
92
95
|
default: undefined,
|
|
93
|
-
required: false,
|
|
94
96
|
validator: (value: string) => {
|
|
95
97
|
return ['sm', 'lg', 'xl'].includes(value)
|
|
96
98
|
},
|
|
@@ -101,7 +103,6 @@ const CModal = defineComponent({
|
|
|
101
103
|
transition: {
|
|
102
104
|
type: Boolean,
|
|
103
105
|
default: true,
|
|
104
|
-
required: false,
|
|
105
106
|
},
|
|
106
107
|
/**
|
|
107
108
|
* By default the component is unmounted after close animation, if you want to keep the component mounted set this property to false.
|
|
@@ -109,7 +110,6 @@ const CModal = defineComponent({
|
|
|
109
110
|
unmountOnClose: {
|
|
110
111
|
type: Boolean,
|
|
111
112
|
default: true,
|
|
112
|
-
required: false,
|
|
113
113
|
},
|
|
114
114
|
/**
|
|
115
115
|
* Toggle the visibility of alert component.
|
|
@@ -6,27 +6,9 @@ import { CPicker } from '../picker'
|
|
|
6
6
|
import { CMultiSelectNativeSelect } from './CMultiSelectNativeSelect'
|
|
7
7
|
import { CMultiSelectOptions } from './CMultiSelectOptions'
|
|
8
8
|
import { CMultiSelectSelection } from './CMultiSelectSelection'
|
|
9
|
-
export interface Option {
|
|
10
|
-
disabled?: boolean
|
|
11
|
-
label?: string
|
|
12
|
-
options?: Option[]
|
|
13
|
-
order?: number
|
|
14
|
-
selected?: boolean
|
|
15
|
-
text: string
|
|
16
|
-
value: number | string
|
|
17
|
-
}
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
text: string
|
|
22
|
-
value: number | string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const flattenArray = (options: Option[]): Option[] => {
|
|
26
|
-
return options.reduce((acc: Option[], val: Option) => {
|
|
27
|
-
return acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val)
|
|
28
|
-
}, [])
|
|
29
|
-
}
|
|
10
|
+
import { filterOptionsList, flattenArray, selectOptions } from './utils'
|
|
11
|
+
import type { Option, SelectedOption } from './types'
|
|
30
12
|
|
|
31
13
|
const CMultiSelect = defineComponent({
|
|
32
14
|
name: 'CMultiSelect',
|
|
@@ -38,7 +20,6 @@ const CMultiSelect = defineComponent({
|
|
|
38
20
|
*/
|
|
39
21
|
cleaner: {
|
|
40
22
|
type: Boolean,
|
|
41
|
-
required: false,
|
|
42
23
|
default: true,
|
|
43
24
|
},
|
|
44
25
|
/**
|
|
@@ -46,7 +27,6 @@ const CMultiSelect = defineComponent({
|
|
|
46
27
|
*/
|
|
47
28
|
disabled: {
|
|
48
29
|
type: Boolean,
|
|
49
|
-
required: false,
|
|
50
30
|
default: false,
|
|
51
31
|
},
|
|
52
32
|
/**
|
|
@@ -101,7 +81,6 @@ const CMultiSelect = defineComponent({
|
|
|
101
81
|
multiple: {
|
|
102
82
|
type: Boolean,
|
|
103
83
|
default: true,
|
|
104
|
-
required: false,
|
|
105
84
|
},
|
|
106
85
|
/**
|
|
107
86
|
* List of option elements.
|
|
@@ -109,7 +88,6 @@ const CMultiSelect = defineComponent({
|
|
|
109
88
|
options: {
|
|
110
89
|
type: Array as PropType<Option[]>,
|
|
111
90
|
default: () => [],
|
|
112
|
-
required: false,
|
|
113
91
|
},
|
|
114
92
|
/**
|
|
115
93
|
* Sets maxHeight of options list.
|
|
@@ -119,7 +97,6 @@ const CMultiSelect = defineComponent({
|
|
|
119
97
|
optionsMaxHeight: {
|
|
120
98
|
type: [Number, String],
|
|
121
99
|
default: 'auto',
|
|
122
|
-
required: false,
|
|
123
100
|
},
|
|
124
101
|
/**
|
|
125
102
|
* Sets option style.
|
|
@@ -130,7 +107,6 @@ const CMultiSelect = defineComponent({
|
|
|
130
107
|
optionsStyle: {
|
|
131
108
|
type: String,
|
|
132
109
|
default: 'checkbox',
|
|
133
|
-
required: false,
|
|
134
110
|
validator: (value: string) => {
|
|
135
111
|
return ['checkbox', 'text'].includes(value)
|
|
136
112
|
},
|
|
@@ -143,7 +119,6 @@ const CMultiSelect = defineComponent({
|
|
|
143
119
|
placeholder: {
|
|
144
120
|
type: String,
|
|
145
121
|
default: 'Select...',
|
|
146
|
-
required: false,
|
|
147
122
|
},
|
|
148
123
|
/**
|
|
149
124
|
* Enables search input element.
|
|
@@ -151,7 +126,6 @@ const CMultiSelect = defineComponent({
|
|
|
151
126
|
search: {
|
|
152
127
|
type: [Boolean, String],
|
|
153
128
|
default: true,
|
|
154
|
-
required: false,
|
|
155
129
|
validator: (value: boolean | string) => {
|
|
156
130
|
if (typeof value == 'string') {
|
|
157
131
|
return ['external'].includes(value)
|
|
@@ -168,7 +142,6 @@ const CMultiSelect = defineComponent({
|
|
|
168
142
|
searchNoResultsLabel: {
|
|
169
143
|
type: String,
|
|
170
144
|
default: 'no items',
|
|
171
|
-
required: false,
|
|
172
145
|
},
|
|
173
146
|
/**
|
|
174
147
|
* Enables select all button.
|
|
@@ -177,7 +150,6 @@ const CMultiSelect = defineComponent({
|
|
|
177
150
|
*/
|
|
178
151
|
selectAll: {
|
|
179
152
|
type: Boolean,
|
|
180
|
-
required: false,
|
|
181
153
|
default: true,
|
|
182
154
|
},
|
|
183
155
|
/**
|
|
@@ -187,7 +159,6 @@ const CMultiSelect = defineComponent({
|
|
|
187
159
|
*/
|
|
188
160
|
selectAllLabel: {
|
|
189
161
|
type: String,
|
|
190
|
-
required: false,
|
|
191
162
|
default: 'Select all options',
|
|
192
163
|
},
|
|
193
164
|
/**
|
|
@@ -199,7 +170,6 @@ const CMultiSelect = defineComponent({
|
|
|
199
170
|
selectionType: {
|
|
200
171
|
type: String,
|
|
201
172
|
default: 'tags',
|
|
202
|
-
required: false,
|
|
203
173
|
validator: (value: string) => {
|
|
204
174
|
return ['counter', 'tags', 'text'].includes(value)
|
|
205
175
|
},
|
|
@@ -212,7 +182,6 @@ const CMultiSelect = defineComponent({
|
|
|
212
182
|
selectionTypeCounterText: {
|
|
213
183
|
type: String,
|
|
214
184
|
default: 'item(s) selected',
|
|
215
|
-
required: false,
|
|
216
185
|
},
|
|
217
186
|
/**
|
|
218
187
|
* Size the component small or large.
|
|
@@ -221,7 +190,6 @@ const CMultiSelect = defineComponent({
|
|
|
221
190
|
*/
|
|
222
191
|
size: {
|
|
223
192
|
type: String,
|
|
224
|
-
required: false,
|
|
225
193
|
validator: (value: string) => {
|
|
226
194
|
return ['sm', 'lg'].includes(value)
|
|
227
195
|
},
|
|
@@ -246,6 +214,12 @@ const CMultiSelect = defineComponent({
|
|
|
246
214
|
* @since 4.6.0
|
|
247
215
|
*/
|
|
248
216
|
valid: Boolean,
|
|
217
|
+
/**
|
|
218
|
+
* Enable virtual scroller for the options list.
|
|
219
|
+
*
|
|
220
|
+
* @since 4.8.0
|
|
221
|
+
*/
|
|
222
|
+
virtualScroller: Boolean,
|
|
249
223
|
/**
|
|
250
224
|
* Toggle the visibility of multi select dropdown.
|
|
251
225
|
*
|
|
@@ -254,7 +228,16 @@ const CMultiSelect = defineComponent({
|
|
|
254
228
|
visible: {
|
|
255
229
|
type: Boolean,
|
|
256
230
|
default: false,
|
|
257
|
-
|
|
231
|
+
},
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* Amount of visible items when virtualScroller is set to `true`.
|
|
235
|
+
*
|
|
236
|
+
* @since 4.8.0
|
|
237
|
+
*/
|
|
238
|
+
visibleItems: {
|
|
239
|
+
type: Number,
|
|
240
|
+
default: 10,
|
|
258
241
|
},
|
|
259
242
|
},
|
|
260
243
|
emits: [
|
|
@@ -271,37 +254,13 @@ const CMultiSelect = defineComponent({
|
|
|
271
254
|
],
|
|
272
255
|
setup(props, { attrs, emit }) {
|
|
273
256
|
const nativeSelectRef = ref<HTMLSelectElement>()
|
|
274
|
-
provide('nativeSelectRef', nativeSelectRef)
|
|
275
|
-
const searchRef = ref<HTMLInputElement>()
|
|
276
|
-
|
|
277
257
|
const options = ref<Option[]>(props.options)
|
|
278
258
|
const search = ref('')
|
|
259
|
+
const searchRef = ref<HTMLInputElement>()
|
|
279
260
|
const selected = ref<SelectedOption[]>([])
|
|
280
261
|
const visible = ref<Boolean>(props.visible)
|
|
281
262
|
|
|
282
|
-
|
|
283
|
-
let _selected = [...selected.value, ...options]
|
|
284
|
-
|
|
285
|
-
if (deselected) {
|
|
286
|
-
_selected = _selected.filter(
|
|
287
|
-
(selectedOption) =>
|
|
288
|
-
!deselected.some((deselectedOption) => deselectedOption.value === selectedOption.value),
|
|
289
|
-
)
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const deduplicated = _selected.reduce((unique: Option[], option) => {
|
|
293
|
-
if (!unique.some((obj) => obj.value === option.value)) {
|
|
294
|
-
unique.push({
|
|
295
|
-
value: option.value,
|
|
296
|
-
text: option.text,
|
|
297
|
-
...(option.disabled && { disabled: option.disabled }),
|
|
298
|
-
})
|
|
299
|
-
}
|
|
300
|
-
return unique
|
|
301
|
-
}, []) as SelectedOption[]
|
|
302
|
-
|
|
303
|
-
selected.value = deduplicated
|
|
304
|
-
}
|
|
263
|
+
provide('nativeSelectRef', nativeSelectRef)
|
|
305
264
|
|
|
306
265
|
watch(
|
|
307
266
|
() => props.options,
|
|
@@ -328,9 +287,12 @@ const CMultiSelect = defineComponent({
|
|
|
328
287
|
return
|
|
329
288
|
})
|
|
330
289
|
|
|
331
|
-
|
|
290
|
+
if (_selected) {
|
|
291
|
+
selected.value = selectOptions(_selected, selected.value, deselected)
|
|
292
|
+
}
|
|
332
293
|
}
|
|
333
294
|
},
|
|
295
|
+
{ immediate: true },
|
|
334
296
|
)
|
|
335
297
|
|
|
336
298
|
watch(selected, () => {
|
|
@@ -338,39 +300,6 @@ const CMultiSelect = defineComponent({
|
|
|
338
300
|
nativeSelectRef.value.dispatchEvent(new Event('change', { bubbles: true }))
|
|
339
301
|
})
|
|
340
302
|
|
|
341
|
-
const filterOptionsList = (search: string, _options: Option[]) => {
|
|
342
|
-
return search.length
|
|
343
|
-
? _options &&
|
|
344
|
-
_options.reduce((acc: Option[], val: Option) => {
|
|
345
|
-
const options =
|
|
346
|
-
val.options &&
|
|
347
|
-
val.options.filter(
|
|
348
|
-
(element) =>
|
|
349
|
-
element.text && element.text.toLowerCase().includes(search.toLowerCase()),
|
|
350
|
-
)
|
|
351
|
-
|
|
352
|
-
if (
|
|
353
|
-
(val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
354
|
-
(options && options.length)
|
|
355
|
-
) {
|
|
356
|
-
acc.push(Object.assign({}, val, options && options.length && { options }))
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
return acc
|
|
360
|
-
}, [])
|
|
361
|
-
: options.value
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// watch(
|
|
365
|
-
// () => props.options,
|
|
366
|
-
// (newValue, oldValue) => {
|
|
367
|
-
// console.log(props.options)
|
|
368
|
-
// if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) options.value = newValue
|
|
369
|
-
// },
|
|
370
|
-
// )
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
303
|
const handleSearchChange = (event: InputEvent) => {
|
|
375
304
|
const target = event.target as HTMLInputElement
|
|
376
305
|
search.value = target.value.toLowerCase()
|
|
@@ -414,7 +343,10 @@ const CMultiSelect = defineComponent({
|
|
|
414
343
|
}
|
|
415
344
|
|
|
416
345
|
const handleSelectAll = () => {
|
|
417
|
-
|
|
346
|
+
selected.value = selectOptions(
|
|
347
|
+
flattenArray(options.value).filter((option: Option) => !option.disabled),
|
|
348
|
+
selected.value,
|
|
349
|
+
)
|
|
418
350
|
}
|
|
419
351
|
|
|
420
352
|
const handleDeselectAll = () => {
|
|
@@ -517,7 +449,7 @@ const CMultiSelect = defineComponent({
|
|
|
517
449
|
}),
|
|
518
450
|
]),
|
|
519
451
|
default: () =>
|
|
520
|
-
|
|
452
|
+
visible.value && [
|
|
521
453
|
props.multiple &&
|
|
522
454
|
props.selectAll &&
|
|
523
455
|
h(
|
|
@@ -538,9 +470,11 @@ const CMultiSelect = defineComponent({
|
|
|
538
470
|
optionsMaxHeight: props.optionsMaxHeight,
|
|
539
471
|
optionsStyle: props.optionsStyle,
|
|
540
472
|
searchNoResultsLabel: props.searchNoResultsLabel,
|
|
541
|
-
selected: selected.value
|
|
473
|
+
selected: selected.value,
|
|
474
|
+
virtualScroller: props.virtualScroller,
|
|
475
|
+
visibleItems: props.visibleItems,
|
|
542
476
|
}),
|
|
543
|
-
]
|
|
477
|
+
],
|
|
544
478
|
},
|
|
545
479
|
),
|
|
546
480
|
},
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defineComponent, h, PropType, VNode } from 'vue'
|
|
2
|
-
import { Option } from './CMultiSelect'
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { CVirtualScroller } from '../virtual-scroller'
|
|
4
|
+
|
|
5
|
+
import { getNextSibling, getPreviousSibling } from './utils'
|
|
6
|
+
import type { Option } from './types'
|
|
5
7
|
|
|
6
8
|
const CMultiSelectOptions = defineComponent({
|
|
7
9
|
name: 'CMultiSelectOptions',
|
|
@@ -12,7 +14,6 @@ const CMultiSelectOptions = defineComponent({
|
|
|
12
14
|
options: {
|
|
13
15
|
type: Array as PropType<Option[]>,
|
|
14
16
|
default: () => [],
|
|
15
|
-
required: false,
|
|
16
17
|
},
|
|
17
18
|
/**
|
|
18
19
|
* Sets maxHeight of options list.
|
|
@@ -22,7 +23,6 @@ const CMultiSelectOptions = defineComponent({
|
|
|
22
23
|
optionsMaxHeight: {
|
|
23
24
|
type: [Number, String],
|
|
24
25
|
default: 'auto',
|
|
25
|
-
required: false,
|
|
26
26
|
},
|
|
27
27
|
/**
|
|
28
28
|
* Sets option style.
|
|
@@ -33,7 +33,6 @@ const CMultiSelectOptions = defineComponent({
|
|
|
33
33
|
optionsStyle: {
|
|
34
34
|
type: String,
|
|
35
35
|
default: 'checkbox',
|
|
36
|
-
required: false,
|
|
37
36
|
validator: (value: string) => {
|
|
38
37
|
return ['checkbox', 'text'].includes(value)
|
|
39
38
|
},
|
|
@@ -44,12 +43,15 @@ const CMultiSelectOptions = defineComponent({
|
|
|
44
43
|
searchNoResultsLabel: {
|
|
45
44
|
type: String,
|
|
46
45
|
default: 'no items',
|
|
47
|
-
required: false,
|
|
48
46
|
},
|
|
49
47
|
selected: {
|
|
50
48
|
type: Array as PropType<Option[]>,
|
|
51
49
|
default: () => [],
|
|
52
|
-
|
|
50
|
+
},
|
|
51
|
+
virtualScroller: Boolean,
|
|
52
|
+
visibleItems: {
|
|
53
|
+
type: Number,
|
|
54
|
+
default: 10,
|
|
53
55
|
},
|
|
54
56
|
},
|
|
55
57
|
emits: ['optionClick'],
|
|
@@ -114,17 +116,29 @@ const CMultiSelectOptions = defineComponent({
|
|
|
114
116
|
),
|
|
115
117
|
)
|
|
116
118
|
: h('div', { class: 'form-multi-select-options-empty' }, props.searchNoResultsLabel)
|
|
119
|
+
|
|
117
120
|
return () =>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
props.virtualScroller
|
|
122
|
+
? h(
|
|
123
|
+
CVirtualScroller,
|
|
124
|
+
{
|
|
125
|
+
class: 'form-multi-select-options',
|
|
126
|
+
visibleItems: props.visibleItems,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
default: () => createOptions(props.options),
|
|
130
|
+
},
|
|
131
|
+
)
|
|
132
|
+
: h(
|
|
133
|
+
'div',
|
|
134
|
+
{
|
|
135
|
+
class: 'form-multi-select-options',
|
|
136
|
+
...(props.optionsMaxHeight !== 'auto' && {
|
|
137
|
+
style: { maxHeight: props.optionsMaxHeight, overflow: 'scroll' },
|
|
138
|
+
}),
|
|
139
|
+
},
|
|
140
|
+
createOptions(props.options),
|
|
141
|
+
)
|
|
128
142
|
},
|
|
129
143
|
})
|
|
130
144
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Option = {
|
|
2
|
+
disabled?: boolean
|
|
3
|
+
label?: string
|
|
4
|
+
options?: Option[]
|
|
5
|
+
order?: number
|
|
6
|
+
selected?: boolean
|
|
7
|
+
text: string
|
|
8
|
+
value: number | string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type SelectedOption = {
|
|
12
|
+
disabled?: boolean
|
|
13
|
+
text: string
|
|
14
|
+
value: number | string
|
|
15
|
+
}
|