@coreui/vue-pro 4.9.0-beta.2 → 5.0.0-alpha.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.
- package/README.md +1 -1
- package/dist/components/dropdown/CDropdown.d.ts +62 -4
- package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/components/form/CFormCheck.d.ts +26 -2
- package/dist/components/form/CFormInput.d.ts +6 -18
- package/dist/components/multi-select/CMultiSelect.d.ts +6 -6
- package/dist/components/popover/CPopover.d.ts +75 -6
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +77 -8
- package/dist/composables/index.d.ts +2 -1
- package/dist/composables/useColorModes.d.ts +1 -1
- package/dist/composables/usePopper.d.ts +6 -0
- package/dist/index.es.js +384 -238
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +383 -236
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/getRTLPlacement.d.ts +3 -0
- package/dist/utils/index.d.ts +2 -1
- package/package.json +11 -11
- package/src/components/date-range-picker/CDateRangePicker.ts +6 -4
- package/src/components/dropdown/CDropdown.ts +116 -61
- package/src/components/dropdown/CDropdownMenu.ts +2 -47
- package/src/components/dropdown/CDropdownToggle.ts +5 -5
- package/src/components/form/CFormCheck.ts +53 -4
- package/src/components/multi-select/CMultiSelect.ts +3 -3
- package/src/components/popover/CPopover.ts +96 -50
- package/src/components/tooltip/CTooltip.ts +97 -51
- package/src/composables/index.ts +2 -1
- package/src/composables/useColorModes.ts +2 -1
- package/src/composables/usePopper.ts +25 -0
- package/src/types.ts +1 -1
- package/src/utils/getRTLPlacement.ts +18 -0
- package/src/utils/index.ts +2 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Breakpoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
2
2
|
export type Colors = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | 'primary-gradient' | 'secondary-gradient' | 'success-gradient' | 'danger-gradient' | 'warning-gradient' | 'info-gradient' | 'dark-gradient' | 'light-gradient' | string;
|
|
3
|
-
export type Placements = 'auto' | 'auto-start' | 'auto-end' | 'top-end' | 'top' | 'top-start' | 'bottom-end' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end' |
|
|
3
|
+
export type Placements = 'auto' | 'auto-start' | 'auto-end' | 'top-end' | 'top' | 'top-start' | 'bottom-end' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end' | string;
|
|
4
4
|
export type Shapes = 'rounded' | 'rounded-top' | 'rounded-end' | 'rounded-bottom' | 'rounded-start' | 'rounded-circle' | 'rounded-pill' | 'rounded-0' | 'rounded-1' | 'rounded-2' | 'rounded-3' | string;
|
|
5
5
|
export type Triggers = 'hover' | 'focus' | 'click';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import getRTLPlacement from './getRTLPlacement';
|
|
1
2
|
import getUID from './getUID';
|
|
2
3
|
import isInViewport from './isInViewport';
|
|
3
4
|
import isObjectInArray from './isObjectInArray';
|
|
4
5
|
import isRTL from './isRTL';
|
|
5
|
-
export { getUID, isInViewport, isObjectInArray, isRTL };
|
|
6
|
+
export { getRTLPlacement, getUID, isInViewport, isObjectInArray, isRTL };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreui/vue-pro",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.0",
|
|
4
4
|
"description": "UI Components Library for Vue.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -38,24 +38,24 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@popperjs/core": "^2.11.8",
|
|
41
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
41
|
+
"@rollup/plugin-commonjs": "^25.0.2",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^15.1.0",
|
|
43
|
-
"@rollup/plugin-typescript": "^11.1.
|
|
43
|
+
"@rollup/plugin-typescript": "^11.1.2",
|
|
44
44
|
"@types/jest": "^29.5.2",
|
|
45
|
-
"@vue/test-utils": "^2.
|
|
45
|
+
"@vue/test-utils": "^2.4.0",
|
|
46
46
|
"@vue/vue3-jest": "29.2.4",
|
|
47
47
|
"date-fns": "^2.29.3",
|
|
48
|
-
"jest": "^29.
|
|
49
|
-
"jest-environment-jsdom": "^29.
|
|
50
|
-
"rollup": "^3.
|
|
48
|
+
"jest": "^29.6.0",
|
|
49
|
+
"jest-environment-jsdom": "^29.6.0",
|
|
50
|
+
"rollup": "^3.26.2",
|
|
51
51
|
"rollup-plugin-vue": "^6.0.0",
|
|
52
|
-
"ts-jest": "^29.1.
|
|
53
|
-
"typescript": "^
|
|
52
|
+
"ts-jest": "^29.1.1",
|
|
53
|
+
"typescript": "^5.1.6",
|
|
54
54
|
"vue": "^3.3.4",
|
|
55
|
-
"vue-types": "^5.0
|
|
55
|
+
"vue-types": "^5.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@coreui/coreui-pro": "^
|
|
58
|
+
"@coreui/coreui-pro": "^5.0.0-alpha.0",
|
|
59
59
|
"vue": "^3.2.21"
|
|
60
60
|
},
|
|
61
61
|
"standard": {
|
|
@@ -495,8 +495,9 @@ const CDateRangePicker = defineComponent({
|
|
|
495
495
|
() => props.startDate,
|
|
496
496
|
() => {
|
|
497
497
|
if (props.startDate) {
|
|
498
|
-
|
|
499
|
-
|
|
498
|
+
const date = new Date(props.startDate)
|
|
499
|
+
calendarDate.value = date
|
|
500
|
+
startDate.value = date
|
|
500
501
|
}
|
|
501
502
|
},
|
|
502
503
|
)
|
|
@@ -505,8 +506,9 @@ const CDateRangePicker = defineComponent({
|
|
|
505
506
|
() => props.endDate,
|
|
506
507
|
() => {
|
|
507
508
|
if (props.endDate) {
|
|
508
|
-
|
|
509
|
-
|
|
509
|
+
const date = new Date(props.endDate)
|
|
510
|
+
calendarDate.value = date
|
|
511
|
+
endDate.value = date
|
|
510
512
|
}
|
|
511
513
|
},
|
|
512
514
|
)
|
|
@@ -1,9 +1,53 @@
|
|
|
1
|
-
import { defineComponent, h, ref, provide, watch, PropType
|
|
2
|
-
import {
|
|
1
|
+
import { defineComponent, h, ref, provide, watch, PropType } from 'vue'
|
|
2
|
+
import type { Placement } from '@popperjs/core'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { usePopper } from '../../composables'
|
|
5
|
+
import type { Placements, Triggers } from '../../types'
|
|
5
6
|
import { isRTL } from '../../utils'
|
|
6
7
|
|
|
8
|
+
export type Directions = 'start' | 'end'
|
|
9
|
+
|
|
10
|
+
export type Breakpoints =
|
|
11
|
+
| { xs: Directions }
|
|
12
|
+
| { sm: Directions }
|
|
13
|
+
| { md: Directions }
|
|
14
|
+
| { lg: Directions }
|
|
15
|
+
| { xl: Directions }
|
|
16
|
+
| { xxl: Directions }
|
|
17
|
+
|
|
18
|
+
export type Alignments = Directions | Breakpoints
|
|
19
|
+
|
|
20
|
+
const getPlacement = (
|
|
21
|
+
placement: Placement,
|
|
22
|
+
direction: string | undefined,
|
|
23
|
+
alignment: Alignments | string | undefined,
|
|
24
|
+
isRTL: boolean,
|
|
25
|
+
): Placements => {
|
|
26
|
+
let _placement = placement
|
|
27
|
+
|
|
28
|
+
if (direction === 'dropup') {
|
|
29
|
+
_placement = isRTL ? 'top-end' : 'top-start'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (direction === 'dropup-center') {
|
|
33
|
+
_placement = 'top'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (direction === 'dropend') {
|
|
37
|
+
_placement = isRTL ? 'left-start' : 'right-start'
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (direction === 'dropstart') {
|
|
41
|
+
_placement = isRTL ? 'right-start' : 'left-start'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (alignment === 'end') {
|
|
45
|
+
_placement = isRTL ? 'bottom-start' : 'bottom-end'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return _placement
|
|
49
|
+
}
|
|
50
|
+
|
|
7
51
|
const CDropdown = defineComponent({
|
|
8
52
|
name: 'CDropdown',
|
|
9
53
|
props: {
|
|
@@ -13,7 +57,7 @@ const CDropdown = defineComponent({
|
|
|
13
57
|
* @values { 'start' | 'end' | { xs: 'start' | 'end' } | { sm: 'start' | 'end' } | { md: 'start' | 'end' } | { lg: 'start' | 'end' } | { xl: 'start' | 'end'} | { xxl: 'start' | 'end'} }
|
|
14
58
|
*/
|
|
15
59
|
alignment: {
|
|
16
|
-
type: [String, Object]
|
|
60
|
+
type: [String, Object] as PropType<string | Alignments>,
|
|
17
61
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
62
|
validator: (value: string | any) => {
|
|
19
63
|
if (value === 'start' || value === 'end') {
|
|
@@ -74,6 +118,15 @@ const CDropdown = defineComponent({
|
|
|
74
118
|
* Toggle the disabled state for the component.
|
|
75
119
|
*/
|
|
76
120
|
disabled: Boolean,
|
|
121
|
+
/**
|
|
122
|
+
* Offset of the dropdown menu relative to its target.
|
|
123
|
+
*
|
|
124
|
+
* @since 4.9.0
|
|
125
|
+
*/
|
|
126
|
+
offset: {
|
|
127
|
+
type: Array,
|
|
128
|
+
default: () => [0, 2],
|
|
129
|
+
},
|
|
77
130
|
/**
|
|
78
131
|
* Describes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.
|
|
79
132
|
*
|
|
@@ -127,10 +180,28 @@ const CDropdown = defineComponent({
|
|
|
127
180
|
setup(props, { slots, emit }) {
|
|
128
181
|
const dropdownToggleRef = ref()
|
|
129
182
|
const dropdownMenuRef = ref()
|
|
130
|
-
const
|
|
131
|
-
const popper = ref()
|
|
183
|
+
const popper = ref(typeof props.alignment === 'object' ? false : props.popper)
|
|
132
184
|
const visible = ref(props.visible)
|
|
133
185
|
|
|
186
|
+
const { initPopper, destroyPopper } = usePopper()
|
|
187
|
+
|
|
188
|
+
const popperConfig = {
|
|
189
|
+
modifiers: [
|
|
190
|
+
{
|
|
191
|
+
name: 'offset',
|
|
192
|
+
options: {
|
|
193
|
+
offset: props.offset,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
placement: getPlacement(
|
|
198
|
+
props.placement,
|
|
199
|
+
props.direction,
|
|
200
|
+
props.alignment,
|
|
201
|
+
isRTL(dropdownMenuRef.value),
|
|
202
|
+
) as Placement,
|
|
203
|
+
}
|
|
204
|
+
|
|
134
205
|
watch(
|
|
135
206
|
() => props.visible,
|
|
136
207
|
() => {
|
|
@@ -138,8 +209,22 @@ const CDropdown = defineComponent({
|
|
|
138
209
|
},
|
|
139
210
|
)
|
|
140
211
|
|
|
212
|
+
watch(visible, () => {
|
|
213
|
+
if (visible.value && dropdownToggleRef.value && dropdownMenuRef.value) {
|
|
214
|
+
popper.value && initPopper(dropdownToggleRef.value, dropdownMenuRef.value, popperConfig)
|
|
215
|
+
window.addEventListener('mouseup', handleMouseUp)
|
|
216
|
+
window.addEventListener('keyup', handleKeyup)
|
|
217
|
+
emit('show')
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
popper.value && destroyPopper()
|
|
222
|
+
window.removeEventListener('mouseup', handleMouseUp)
|
|
223
|
+
window.removeEventListener('keyup', handleKeyup)
|
|
224
|
+
emit('hide')
|
|
225
|
+
})
|
|
226
|
+
|
|
141
227
|
provide('config', {
|
|
142
|
-
autoClose: props.autoClose,
|
|
143
228
|
alignment: props.alignment,
|
|
144
229
|
dark: props.dark,
|
|
145
230
|
popper: props.popper,
|
|
@@ -150,27 +235,38 @@ const CDropdown = defineComponent({
|
|
|
150
235
|
provide('dropdownToggleRef', dropdownToggleRef)
|
|
151
236
|
provide('dropdownMenuRef', dropdownMenuRef)
|
|
152
237
|
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
if (typeof props.alignment === 'object') {
|
|
238
|
+
const handleKeyup = (event: KeyboardEvent) => {
|
|
239
|
+
if (props.autoClose === false) {
|
|
156
240
|
return
|
|
157
241
|
}
|
|
158
242
|
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
placement: placement.value,
|
|
162
|
-
})
|
|
243
|
+
if (event.key === 'Escape') {
|
|
244
|
+
setVisible(false)
|
|
163
245
|
}
|
|
164
246
|
}
|
|
165
247
|
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
|
|
248
|
+
const handleMouseUp = (event: Event) => {
|
|
249
|
+
if (!dropdownToggleRef.value || !dropdownMenuRef.value) {
|
|
250
|
+
return
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (dropdownToggleRef.value.contains(event.target as HTMLElement)) {
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (
|
|
258
|
+
props.autoClose === true ||
|
|
259
|
+
(props.autoClose === 'inside' &&
|
|
260
|
+
dropdownMenuRef.value.contains(event.target as HTMLElement)) ||
|
|
261
|
+
(props.autoClose === 'outside' &&
|
|
262
|
+
!dropdownMenuRef.value.contains(event.target as HTMLElement))
|
|
263
|
+
) {
|
|
264
|
+
setVisible(false)
|
|
265
|
+
return
|
|
169
266
|
}
|
|
170
|
-
popper.value = undefined
|
|
171
267
|
}
|
|
172
268
|
|
|
173
|
-
const
|
|
269
|
+
const setVisible = (_visible?: boolean) => {
|
|
174
270
|
if (props.disabled) {
|
|
175
271
|
return
|
|
176
272
|
}
|
|
@@ -188,48 +284,7 @@ const CDropdown = defineComponent({
|
|
|
188
284
|
visible.value = true
|
|
189
285
|
}
|
|
190
286
|
|
|
191
|
-
provide('
|
|
192
|
-
|
|
193
|
-
const hideMenu = () => {
|
|
194
|
-
if (props.disabled) {
|
|
195
|
-
return
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
visible.value = false
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
provide('hideMenu', hideMenu)
|
|
202
|
-
|
|
203
|
-
watch(visible, () => {
|
|
204
|
-
props.popper && (visible.value ? initPopper() : destroyPopper())
|
|
205
|
-
visible.value ? emit('show') : emit('hide')
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
onMounted(() => {
|
|
209
|
-
if (props.direction === 'center') {
|
|
210
|
-
placement.value = 'bottom'
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (props.direction === 'dropup') {
|
|
214
|
-
placement.value = isRTL(dropdownMenuRef.value) ? 'top-end' : 'top-start'
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (props.direction === 'dropup-center') {
|
|
218
|
-
placement.value = 'top'
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (props.direction === 'dropend') {
|
|
222
|
-
placement.value = isRTL(dropdownMenuRef.value) ? 'left-start' : 'right-start'
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (props.direction === 'dropstart') {
|
|
226
|
-
placement.value = isRTL(dropdownMenuRef.value) ? 'right-start' : 'left-start'
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (props.alignment === 'end') {
|
|
230
|
-
placement.value = isRTL(dropdownMenuRef.value) ? 'bottom-start' : 'bottom-end'
|
|
231
|
-
}
|
|
232
|
-
})
|
|
287
|
+
provide('setVisible', setVisible)
|
|
233
288
|
|
|
234
289
|
return () =>
|
|
235
290
|
props.variant === 'input-group'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, inject,
|
|
1
|
+
import { defineComponent, h, inject, Ref } from 'vue'
|
|
2
2
|
|
|
3
3
|
const CDropdownMenu = defineComponent({
|
|
4
4
|
name: 'CDropdownMenu',
|
|
@@ -14,13 +14,11 @@ const CDropdownMenu = defineComponent({
|
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
setup(props, { slots }) {
|
|
17
|
-
const dropdownToggleRef = inject('dropdownToggleRef') as Ref<HTMLElement>
|
|
18
17
|
const dropdownMenuRef = inject('dropdownMenuRef') as Ref<HTMLElement>
|
|
19
18
|
const config = inject('config') as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
20
|
-
const hideMenu = inject('hideMenu') as () => void
|
|
21
19
|
const visible = inject('visible') as Ref<boolean>
|
|
22
20
|
|
|
23
|
-
const {
|
|
21
|
+
const { alignment, dark, popper } = config
|
|
24
22
|
|
|
25
23
|
// eslint-disable-next-line @typescript-eslint/ban-types, unicorn/consistent-function-scoping
|
|
26
24
|
const alignmentClassNames = (alignment: object | string) => {
|
|
@@ -36,49 +34,6 @@ const CDropdownMenu = defineComponent({
|
|
|
36
34
|
return classNames
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
const handleKeyup = (event: KeyboardEvent) => {
|
|
40
|
-
if (autoClose === false) {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (event.key === 'Escape') {
|
|
45
|
-
hideMenu()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const handleMouseUp = (event: Event) => {
|
|
50
|
-
if (dropdownToggleRef.value?.contains(event.target as HTMLElement)) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (autoClose === true) {
|
|
55
|
-
hideMenu()
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (autoClose === 'inside' && dropdownMenuRef.value?.contains(event.target as HTMLElement)) {
|
|
60
|
-
hideMenu()
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
autoClose === 'outside' &&
|
|
66
|
-
!dropdownMenuRef.value?.contains(event.target as HTMLElement)
|
|
67
|
-
) {
|
|
68
|
-
hideMenu()
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
onUpdated(() => {
|
|
73
|
-
visible.value && window.addEventListener('mouseup', handleMouseUp)
|
|
74
|
-
visible.value && window.addEventListener('keyup', handleKeyup)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
onUnmounted(() => {
|
|
78
|
-
window.removeEventListener('mouseup', handleMouseUp)
|
|
79
|
-
window.removeEventListener('keyup', handleKeyup)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
37
|
return () =>
|
|
83
38
|
h(
|
|
84
39
|
props.component,
|
|
@@ -3,7 +3,7 @@ import { cloneVNode, defineComponent, h, inject, onMounted, PropType, Ref, ref }
|
|
|
3
3
|
import { CButton } from '../button'
|
|
4
4
|
|
|
5
5
|
import { Color, Shape } from '../../props'
|
|
6
|
-
import { Triggers } from '../../types'
|
|
6
|
+
import type { Triggers } from '../../types'
|
|
7
7
|
|
|
8
8
|
const CDropdownToggle = defineComponent({
|
|
9
9
|
name: 'CDropdownToggle',
|
|
@@ -85,7 +85,7 @@ const CDropdownToggle = defineComponent({
|
|
|
85
85
|
const dropdownToggleRef = inject('dropdownToggleRef') as Ref<HTMLElement>
|
|
86
86
|
const dropdownVariant = inject('variant') as string
|
|
87
87
|
const visible = inject('visible') as Ref<boolean>
|
|
88
|
-
const
|
|
88
|
+
const setVisible = inject('setVisible') as (_visible?: boolean) => void
|
|
89
89
|
|
|
90
90
|
const className = [
|
|
91
91
|
{
|
|
@@ -103,7 +103,7 @@ const CDropdownToggle = defineComponent({
|
|
|
103
103
|
return
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
setVisible()
|
|
107
107
|
},
|
|
108
108
|
}),
|
|
109
109
|
...((props.trigger === 'focus' || props.trigger.includes('focus')) && {
|
|
@@ -112,13 +112,13 @@ const CDropdownToggle = defineComponent({
|
|
|
112
112
|
return
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
setVisible(true)
|
|
116
116
|
},
|
|
117
117
|
onblur: () => {
|
|
118
118
|
if (props.disabled) {
|
|
119
119
|
return
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
setVisible(false)
|
|
122
122
|
},
|
|
123
123
|
}),
|
|
124
124
|
}
|
|
@@ -14,6 +14,12 @@ const CFormCheck = defineComponent({
|
|
|
14
14
|
* @see http://coreui.io/vue/docs/components/button.html
|
|
15
15
|
*/
|
|
16
16
|
button: Object,
|
|
17
|
+
/**
|
|
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
|
+
*
|
|
20
|
+
* @since 4.9.0
|
|
21
|
+
*/
|
|
22
|
+
falseValue: String,
|
|
17
23
|
/**
|
|
18
24
|
* Provide valuable, actionable feedback.
|
|
19
25
|
*
|
|
@@ -66,7 +72,7 @@ const CFormCheck = defineComponent({
|
|
|
66
72
|
* The default name for a value passed using v-model.
|
|
67
73
|
*/
|
|
68
74
|
modelValue: {
|
|
69
|
-
type: [Boolean, String],
|
|
75
|
+
type: [Array, Boolean, String],
|
|
70
76
|
value: undefined,
|
|
71
77
|
},
|
|
72
78
|
/**
|
|
@@ -81,6 +87,12 @@ const CFormCheck = defineComponent({
|
|
|
81
87
|
* @since 4.3.0
|
|
82
88
|
*/
|
|
83
89
|
tooltipFeedback: Boolean,
|
|
90
|
+
/**
|
|
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
|
+
*
|
|
93
|
+
* @since 4.9.0
|
|
94
|
+
*/
|
|
95
|
+
trueValue: String,
|
|
84
96
|
/**
|
|
85
97
|
* Specifies the type of component.
|
|
86
98
|
*
|
|
@@ -111,8 +123,35 @@ const CFormCheck = defineComponent({
|
|
|
111
123
|
],
|
|
112
124
|
setup(props, { attrs, emit, slots }) {
|
|
113
125
|
const handleChange = (event: InputEvent) => {
|
|
126
|
+
const target = event.target as HTMLInputElement
|
|
114
127
|
emit('change', event)
|
|
115
|
-
|
|
128
|
+
|
|
129
|
+
if (props.falseValue && props.trueValue) {
|
|
130
|
+
emit('update:modelValue', target.checked ? props.trueValue : props.falseValue)
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (props.value && Array.isArray(props.modelValue)) {
|
|
135
|
+
if (props.modelValue.includes(props.value)) {
|
|
136
|
+
emit(
|
|
137
|
+
'update:modelValue',
|
|
138
|
+
props.modelValue.filter((value) => value !== props.value),
|
|
139
|
+
)
|
|
140
|
+
} else {
|
|
141
|
+
emit('update:modelValue', [...props.modelValue, props.value])
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (props.value === undefined) {
|
|
148
|
+
emit('update:modelValue', target.checked)
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (props.value && (props.modelValue === undefined || typeof props.modelValue === 'string')) {
|
|
153
|
+
emit('update:modelValue', target.checked ? props.value : undefined)
|
|
154
|
+
}
|
|
116
155
|
}
|
|
117
156
|
|
|
118
157
|
const className = [
|
|
@@ -135,12 +174,22 @@ const CFormCheck = defineComponent({
|
|
|
135
174
|
},
|
|
136
175
|
]
|
|
137
176
|
|
|
138
|
-
const isChecked = computed(() =>
|
|
177
|
+
const isChecked = computed(() => {
|
|
178
|
+
if (Array.isArray(props.modelValue)) {
|
|
179
|
+
return props.modelValue.includes(props.value)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (typeof props.modelValue === 'string') {
|
|
183
|
+
return props.modelValue === props.value
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return props.modelValue
|
|
187
|
+
})
|
|
139
188
|
|
|
140
189
|
const formControl = () => {
|
|
141
190
|
return h('input', {
|
|
142
191
|
...attrs,
|
|
143
|
-
...(props.modelValue && { checked: isChecked.value }),
|
|
192
|
+
...(props.modelValue && props.value && { checked: isChecked.value }),
|
|
144
193
|
class: inputClassName,
|
|
145
194
|
id: props.id,
|
|
146
195
|
indeterminate: props.indeterminate,
|
|
@@ -19,7 +19,7 @@ const CMultiSelect = defineComponent({
|
|
|
19
19
|
/**
|
|
20
20
|
* Allow users to create options if they are not in the list of options.
|
|
21
21
|
*
|
|
22
|
-
* @since 4.9.0
|
|
22
|
+
* @since 4.9.0
|
|
23
23
|
*/
|
|
24
24
|
allowCreateOptions: Boolean,
|
|
25
25
|
/**
|
|
@@ -34,7 +34,7 @@ const CMultiSelect = defineComponent({
|
|
|
34
34
|
/**
|
|
35
35
|
* Clear current search on selecting an item.
|
|
36
36
|
*
|
|
37
|
-
* @since 4.9.0
|
|
37
|
+
* @since 4.9.0
|
|
38
38
|
*/
|
|
39
39
|
clearSearchOnSelect: Boolean,
|
|
40
40
|
/**
|
|
@@ -78,7 +78,7 @@ const CMultiSelect = defineComponent({
|
|
|
78
78
|
/**
|
|
79
79
|
* When set, the options list will have a loading style: loading spinner and reduced opacity.
|
|
80
80
|
*
|
|
81
|
-
* @since 4.9.0
|
|
81
|
+
* @since 4.9.0
|
|
82
82
|
*/
|
|
83
83
|
loading: Boolean,
|
|
84
84
|
/**
|