@coreui/vue-pro 4.1.4 → 4.3.0-beta.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/button/CButton.d.ts +29 -2
- package/dist/components/calendar/CCalendar.d.ts +185 -0
- package/dist/components/calendar/index.d.ts +6 -0
- package/dist/components/date-picker/CDatePicker.d.ts +406 -0
- package/dist/components/date-picker/index.d.ts +6 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +480 -0
- package/dist/components/date-range-picker/index.d.ts +6 -0
- package/dist/components/dropdown/CDropdown.d.ts +25 -0
- package/dist/components/dropdown/CDropdownToggle.d.ts +35 -1
- package/dist/components/index.d.ts +5 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
- package/dist/components/picker/CPicker.d.ts +11 -0
- package/dist/components/picker/index.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/sidebar/CSidebar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +35 -99
- package/dist/components/smart-table/CSmartTableInterface.d.ts +3 -3
- package/dist/components/time-picker/CTimePicker.d.ts +10 -0
- package/dist/components/time-picker/CTimePickerRollCol.d.ts +27 -0
- package/dist/components/time-picker/index.d.ts +6 -0
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/index.es.js +3726 -1646
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3734 -1644
- package/dist/index.js.map +1 -1
- package/dist/utils/calendar.d.ts +21 -0
- package/dist/utils/time.d.ts +17 -0
- package/package.json +9 -9
- package/src/components/accordion/CAccordionButton.ts +1 -0
- package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.ts.snap +1 -1
- package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.ts.snap +1 -1
- package/src/components/button/CButton.ts +30 -1
- package/src/components/button/__tests__/__snapshots__/CButton.spec.ts.snap +1 -1
- package/src/components/calendar/CCalendar.ts +546 -0
- package/src/components/calendar/index.ts +10 -0
- package/src/components/close-button/CCloseButton.ts +4 -1
- package/src/components/date-picker/CDatePicker.ts +243 -0
- package/src/components/date-picker/index.ts +10 -0
- package/src/components/date-range-picker/CDateRangePicker.ts +635 -0
- package/src/components/date-range-picker/index.ts +10 -0
- package/src/components/dropdown/CDropdown.ts +48 -49
- package/src/components/dropdown/CDropdownMenu.ts +52 -7
- package/src/components/dropdown/CDropdownToggle.ts +93 -29
- package/src/components/dropdown/__tests__/CDropdownMenu.spec.ts +7 -7
- package/src/components/dropdown/__tests__/CDropdownToggle.spec.ts +4 -5
- package/src/components/dropdown/__tests__/__snapshots__/CDropdownToggle.spec.ts.snap +2 -2
- package/src/components/form/CFormCheck.ts +2 -1
- package/src/components/form/CFormSwitch.ts +1 -7
- package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +2 -8
- package/src/components/index.ts +5 -0
- package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +2 -1
- package/src/components/pagination/CSmartPagination.ts +4 -4
- package/src/components/picker/CPicker.ts +220 -0
- package/src/components/picker/index.ts +10 -0
- package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +8 -2
- package/src/components/smart-table/CSmartTable.ts +17 -49
- package/src/components/smart-table/CSmartTableInterface.ts +5 -3
- package/src/components/time-picker/CTimePicker.ts +410 -0
- package/src/components/time-picker/CTimePickerRollCol.ts +58 -0
- package/src/components/time-picker/index.ts +10 -0
- package/src/components/toast/__tests__/__snapshots__/CToastClose.spec.ts.snap +1 -1
- package/src/utils/calendar.ts +193 -0
- package/src/utils/time.ts +58 -0
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineComponent,
|
|
3
|
-
h,
|
|
4
|
-
ref,
|
|
5
|
-
onUnmounted,
|
|
6
|
-
onMounted,
|
|
7
|
-
provide,
|
|
8
|
-
reactive,
|
|
9
|
-
toRefs,
|
|
10
|
-
watch,
|
|
11
|
-
PropType,
|
|
12
|
-
} from 'vue'
|
|
1
|
+
import { defineComponent, h, ref, provide, watch, PropType } from 'vue'
|
|
13
2
|
import { createPopper, Placement } from '@popperjs/core'
|
|
14
3
|
|
|
15
4
|
const CDropdown = defineComponent({
|
|
@@ -51,6 +40,20 @@ const CDropdown = defineComponent({
|
|
|
51
40
|
}
|
|
52
41
|
},
|
|
53
42
|
},
|
|
43
|
+
/**
|
|
44
|
+
* Configure the auto close behavior of the dropdown:
|
|
45
|
+
* - `true` - the dropdown will be closed by clicking outside or inside the dropdown menu.
|
|
46
|
+
* - `false` - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing esc key)
|
|
47
|
+
* - `'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.
|
|
48
|
+
* - `'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu.
|
|
49
|
+
*/
|
|
50
|
+
autoClose: {
|
|
51
|
+
type: [Boolean, String],
|
|
52
|
+
default: true,
|
|
53
|
+
validator: (value: boolean | string) => {
|
|
54
|
+
return typeof value === 'boolean' || ['inside', 'outside'].includes(value)
|
|
55
|
+
},
|
|
56
|
+
},
|
|
54
57
|
/**
|
|
55
58
|
* Sets a darker color scheme to match a dark navbar.
|
|
56
59
|
*/
|
|
@@ -136,25 +139,29 @@ const CDropdown = defineComponent({
|
|
|
136
139
|
'show',
|
|
137
140
|
],
|
|
138
141
|
setup(props, { slots, emit }) {
|
|
139
|
-
const
|
|
142
|
+
const dropdownToggleRef = ref()
|
|
140
143
|
const dropdownMenuRef = ref()
|
|
141
144
|
const placement = ref(props.placement)
|
|
142
145
|
const popper = ref()
|
|
146
|
+
const visible = ref(props.visible)
|
|
147
|
+
|
|
148
|
+
watch(
|
|
149
|
+
() => props.visible,
|
|
150
|
+
() => {
|
|
151
|
+
visible.value = props.visible
|
|
152
|
+
},
|
|
153
|
+
)
|
|
143
154
|
|
|
144
|
-
|
|
155
|
+
provide('config', {
|
|
156
|
+
autoClose: props.autoClose,
|
|
145
157
|
alignment: props.alignment,
|
|
146
158
|
dark: props.dark,
|
|
147
159
|
popper: props.popper,
|
|
148
|
-
visible: props.visible,
|
|
149
160
|
})
|
|
150
161
|
|
|
151
|
-
const { visible } = toRefs(config)
|
|
152
|
-
|
|
153
|
-
provide('config', config)
|
|
154
|
-
|
|
155
162
|
provide('variant', props.variant)
|
|
156
163
|
provide('visible', visible)
|
|
157
|
-
provide('
|
|
164
|
+
provide('dropdownToggleRef', dropdownToggleRef)
|
|
158
165
|
provide('dropdownMenuRef', dropdownMenuRef)
|
|
159
166
|
|
|
160
167
|
if (props.direction === 'dropup') {
|
|
@@ -176,8 +183,8 @@ const CDropdown = defineComponent({
|
|
|
176
183
|
return
|
|
177
184
|
}
|
|
178
185
|
|
|
179
|
-
if (
|
|
180
|
-
popper.value = createPopper(
|
|
186
|
+
if (dropdownToggleRef.value) {
|
|
187
|
+
popper.value = createPopper(dropdownToggleRef.value, dropdownMenuRef.value, {
|
|
181
188
|
placement: placement.value,
|
|
182
189
|
})
|
|
183
190
|
}
|
|
@@ -190,43 +197,35 @@ const CDropdown = defineComponent({
|
|
|
190
197
|
popper.value = undefined
|
|
191
198
|
}
|
|
192
199
|
|
|
193
|
-
const toggleMenu =
|
|
194
|
-
if (props.disabled
|
|
195
|
-
|
|
196
|
-
visible.value = false
|
|
197
|
-
} else {
|
|
198
|
-
visible.value = true
|
|
199
|
-
}
|
|
200
|
+
const toggleMenu = (_visible?: boolean) => {
|
|
201
|
+
if (props.disabled) {
|
|
202
|
+
return
|
|
200
203
|
}
|
|
201
|
-
}
|
|
202
204
|
|
|
203
|
-
|
|
205
|
+
if (typeof _visible == 'boolean') {
|
|
206
|
+
visible.value = _visible
|
|
207
|
+
return
|
|
208
|
+
}
|
|
204
209
|
|
|
205
|
-
|
|
206
|
-
if (props.disabled === false) {
|
|
210
|
+
if (visible.value === true) {
|
|
207
211
|
visible.value = false
|
|
212
|
+
return
|
|
208
213
|
}
|
|
209
|
-
}
|
|
210
214
|
|
|
211
|
-
|
|
212
|
-
if (dropdownRef.value && !dropdownRef.value.contains(event.target as HTMLElement)) {
|
|
213
|
-
hideMenu()
|
|
214
|
-
}
|
|
215
|
+
visible.value = true
|
|
215
216
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
|
|
218
|
+
provide('toggleMenu', toggleMenu)
|
|
219
|
+
|
|
220
|
+
const hideMenu = () => {
|
|
221
|
+
if (props.disabled) {
|
|
222
|
+
return
|
|
219
223
|
}
|
|
224
|
+
|
|
225
|
+
visible.value = false
|
|
220
226
|
}
|
|
221
227
|
|
|
222
|
-
|
|
223
|
-
window.addEventListener('click', handleClickOutside)
|
|
224
|
-
window.addEventListener('keyup', handleKeyup)
|
|
225
|
-
})
|
|
226
|
-
onUnmounted(() => {
|
|
227
|
-
window.removeEventListener('click', handleClickOutside)
|
|
228
|
-
window.removeEventListener('keyup', handleKeyup)
|
|
229
|
-
})
|
|
228
|
+
provide('hideMenu', hideMenu)
|
|
230
229
|
|
|
231
230
|
watch(visible, () => {
|
|
232
231
|
props.popper && (visible.value ? initPopper() : destroyPopper())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, inject,
|
|
1
|
+
import { defineComponent, h, inject, onUnmounted, onUpdated, Ref } from 'vue'
|
|
2
2
|
|
|
3
3
|
const CDropdownMenu = defineComponent({
|
|
4
4
|
name: 'CDropdownMenu',
|
|
@@ -15,11 +15,13 @@ const CDropdownMenu = defineComponent({
|
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
17
|
setup(props, { slots }) {
|
|
18
|
+
const dropdownToggleRef = inject('dropdownToggleRef') as Ref<HTMLElement>
|
|
18
19
|
const dropdownMenuRef = inject('dropdownMenuRef') as Ref<HTMLElement>
|
|
19
|
-
// eslint-disable-
|
|
20
|
-
const
|
|
20
|
+
const config = inject('config') as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const hideMenu = inject('hideMenu') as () => void
|
|
22
|
+
const visible = inject('visible') as Ref<boolean>
|
|
21
23
|
|
|
22
|
-
const { alignment, dark, popper
|
|
24
|
+
const { autoClose, alignment, dark, popper } = config
|
|
23
25
|
|
|
24
26
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
25
27
|
const alignmentClassNames = (alignment: object | string) => {
|
|
@@ -35,16 +37,59 @@ const CDropdownMenu = defineComponent({
|
|
|
35
37
|
return classNames
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
const handleKeyup = (event: KeyboardEvent) => {
|
|
41
|
+
if (autoClose === false) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (event.key === 'Escape') {
|
|
46
|
+
hideMenu()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const handleMouseUp = (event: Event) => {
|
|
51
|
+
if (dropdownToggleRef.value?.contains(event.target as HTMLElement)) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (autoClose === true) {
|
|
56
|
+
hideMenu()
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (autoClose === 'inside' && dropdownMenuRef.value?.contains(event.target as HTMLElement)) {
|
|
61
|
+
hideMenu()
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (
|
|
66
|
+
autoClose === 'outside' &&
|
|
67
|
+
!dropdownMenuRef.value?.contains(event.target as HTMLElement)
|
|
68
|
+
) {
|
|
69
|
+
hideMenu()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
onUpdated(() => {
|
|
74
|
+
visible.value && window.addEventListener('mouseup', handleMouseUp)
|
|
75
|
+
visible.value && window.addEventListener('keyup', handleKeyup)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
onUnmounted(() => {
|
|
79
|
+
window.removeEventListener('mouseup', handleMouseUp)
|
|
80
|
+
window.removeEventListener('keyup', handleKeyup)
|
|
81
|
+
})
|
|
82
|
+
|
|
38
83
|
return () =>
|
|
39
84
|
h(
|
|
40
85
|
props.component,
|
|
41
86
|
{
|
|
42
87
|
class: [
|
|
43
88
|
'dropdown-menu',
|
|
44
|
-
{ 'dropdown-menu-dark': dark
|
|
45
|
-
alignmentClassNames(alignment
|
|
89
|
+
{ 'dropdown-menu-dark': dark, show: visible.value },
|
|
90
|
+
alignmentClassNames(alignment),
|
|
46
91
|
],
|
|
47
|
-
...((typeof alignment
|
|
92
|
+
...((typeof alignment === 'object' || !popper) && {
|
|
48
93
|
'data-coreui-popper': 'static',
|
|
49
94
|
}),
|
|
50
95
|
ref: dropdownMenuRef,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { defineComponent, h, inject, Ref } from 'vue'
|
|
2
|
-
|
|
1
|
+
import { cloneVNode, defineComponent, h, inject, onMounted, PropType, Ref, ref } from 'vue'
|
|
2
|
+
import { CButton } from '../button'
|
|
3
3
|
import { Color, Shape } from '../props'
|
|
4
|
+
import { Triggers } from '../Types'
|
|
4
5
|
|
|
5
6
|
const CDropdownToggle = defineComponent({
|
|
6
7
|
name: 'CDropdownToggle',
|
|
@@ -35,6 +36,10 @@ const CDropdownToggle = defineComponent({
|
|
|
35
36
|
default: 'button',
|
|
36
37
|
require: false,
|
|
37
38
|
},
|
|
39
|
+
/**
|
|
40
|
+
* Create a custom toggler which accepts any content.
|
|
41
|
+
*/
|
|
42
|
+
custom: Boolean,
|
|
38
43
|
/**
|
|
39
44
|
* Toggle the disabled state for the component.
|
|
40
45
|
*/
|
|
@@ -66,6 +71,16 @@ const CDropdownToggle = defineComponent({
|
|
|
66
71
|
type: Boolean,
|
|
67
72
|
required: false,
|
|
68
73
|
},
|
|
74
|
+
/**
|
|
75
|
+
* Sets which event handlers you’d like provided to your toggle prop. You can specify one trigger or an array of them.
|
|
76
|
+
*
|
|
77
|
+
* @type 'hover' | 'focus' | 'click'
|
|
78
|
+
*/
|
|
79
|
+
trigger: {
|
|
80
|
+
type: String as PropType<Triggers>,
|
|
81
|
+
default: 'click',
|
|
82
|
+
required: false,
|
|
83
|
+
},
|
|
69
84
|
/**
|
|
70
85
|
* Set the button variant to an outlined button or a ghost button.
|
|
71
86
|
*
|
|
@@ -81,60 +96,109 @@ const CDropdownToggle = defineComponent({
|
|
|
81
96
|
},
|
|
82
97
|
},
|
|
83
98
|
setup(props, { slots }) {
|
|
84
|
-
const
|
|
99
|
+
const togglerRef = ref()
|
|
100
|
+
const dropdownToggleRef = inject('dropdownToggleRef') as Ref<HTMLElement>
|
|
85
101
|
const dropdownVariant = inject('variant') as string
|
|
86
|
-
const visible = inject('visible') as boolean
|
|
87
|
-
const toggleMenu = inject('toggleMenu') as () => void
|
|
102
|
+
const visible = inject('visible') as Ref<boolean>
|
|
103
|
+
const toggleMenu = inject('toggleMenu') as (_visible?: boolean) => void
|
|
104
|
+
|
|
88
105
|
const className = [
|
|
89
106
|
{
|
|
90
107
|
'dropdown-toggle': props.caret,
|
|
91
108
|
'dropdown-toggle-split': props.split,
|
|
92
|
-
show: visible,
|
|
93
109
|
active: props.active,
|
|
94
110
|
disabled: props.disabled,
|
|
95
111
|
},
|
|
96
112
|
]
|
|
97
113
|
|
|
98
|
-
const
|
|
99
|
-
'
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
114
|
+
const triggers = {
|
|
115
|
+
...((props.trigger === 'click' || props.trigger.includes('click')) && {
|
|
116
|
+
onClick: () => {
|
|
117
|
+
if (props.disabled) {
|
|
118
|
+
return
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
toggleMenu()
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
...((props.trigger === 'focus' || props.trigger.includes('focus')) && {
|
|
125
|
+
onfocus: () => {
|
|
126
|
+
if (props.disabled) {
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
toggleMenu(true)
|
|
131
|
+
},
|
|
132
|
+
onblur: () => {
|
|
133
|
+
if (props.disabled) {
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
toggleMenu(false)
|
|
137
|
+
},
|
|
138
|
+
}),
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
onMounted(() => {
|
|
142
|
+
if (togglerRef.value) {
|
|
143
|
+
dropdownToggleRef.value = togglerRef.value.$el
|
|
144
|
+
}
|
|
145
|
+
})
|
|
106
146
|
|
|
107
147
|
return () =>
|
|
108
|
-
|
|
148
|
+
props.custom
|
|
149
|
+
? slots.default &&
|
|
150
|
+
slots.default().map((slot) =>
|
|
151
|
+
cloneVNode(slot, {
|
|
152
|
+
ref: (el) => {
|
|
153
|
+
togglerRef.value = el
|
|
154
|
+
},
|
|
155
|
+
...triggers,
|
|
156
|
+
}),
|
|
157
|
+
)
|
|
158
|
+
: dropdownVariant === 'nav-item'
|
|
109
159
|
? h(
|
|
110
160
|
'a',
|
|
111
161
|
{
|
|
112
162
|
active: props.active,
|
|
113
|
-
class: [
|
|
163
|
+
class: [
|
|
164
|
+
'nav-link',
|
|
165
|
+
className,
|
|
166
|
+
{
|
|
167
|
+
show: visible.value,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
114
170
|
disabled: props.disabled,
|
|
115
171
|
href: '#',
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return toggleMenu()
|
|
119
|
-
},
|
|
120
|
-
ref: dropdownRef,
|
|
172
|
+
ref: dropdownToggleRef,
|
|
173
|
+
...triggers,
|
|
121
174
|
},
|
|
122
175
|
{ default: () => slots.default && slots.default() },
|
|
123
176
|
)
|
|
124
177
|
: h(
|
|
125
|
-
|
|
126
|
-
props.component,
|
|
178
|
+
CButton,
|
|
127
179
|
{
|
|
128
|
-
class: [
|
|
180
|
+
class: [
|
|
181
|
+
className,
|
|
182
|
+
{
|
|
183
|
+
show: visible.value,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
129
186
|
active: props.active,
|
|
187
|
+
color: props.color,
|
|
130
188
|
disabled: props.disabled,
|
|
131
|
-
|
|
189
|
+
ref: (el) => {
|
|
190
|
+
togglerRef.value = el
|
|
191
|
+
},
|
|
192
|
+
shape: props.shape,
|
|
193
|
+
size: props.size,
|
|
194
|
+
...triggers,
|
|
132
195
|
...(props.component === 'button' && { type: 'button' }),
|
|
133
|
-
|
|
196
|
+
variant: props.variant,
|
|
134
197
|
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
198
|
+
() =>
|
|
199
|
+
props.split
|
|
200
|
+
? h('span', { class: 'visually-hidden' }, 'Toggle Dropdown')
|
|
201
|
+
: slots.default && slots.default(),
|
|
138
202
|
)
|
|
139
203
|
},
|
|
140
204
|
})
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils'
|
|
2
2
|
import { CDropdownMenu as Component } from '../../../index'
|
|
3
|
-
import {
|
|
3
|
+
import { ref } from 'vue'
|
|
4
4
|
|
|
5
5
|
const ComponentName = 'CDropdownMenu'
|
|
6
6
|
|
|
7
|
-
const config =
|
|
7
|
+
const config = {
|
|
8
8
|
alignment: { lg: 'end' },
|
|
9
9
|
dark: false,
|
|
10
10
|
popper: true,
|
|
11
|
-
|
|
12
|
-
})
|
|
11
|
+
}
|
|
13
12
|
|
|
14
|
-
const customConfig =
|
|
13
|
+
const customConfig = {
|
|
15
14
|
alignment: { lg: 'end' },
|
|
16
15
|
dark: true,
|
|
17
16
|
popper: false,
|
|
18
|
-
|
|
19
|
-
})
|
|
17
|
+
}
|
|
20
18
|
|
|
21
19
|
const defaultWrapper = mount(Component, {
|
|
22
20
|
propsData: {},
|
|
@@ -27,6 +25,7 @@ const defaultWrapper = mount(Component, {
|
|
|
27
25
|
provide: {
|
|
28
26
|
config: config,
|
|
29
27
|
dropdownMenuRef: ref(),
|
|
28
|
+
visible: ref(false),
|
|
30
29
|
},
|
|
31
30
|
},
|
|
32
31
|
})
|
|
@@ -42,6 +41,7 @@ const customWrapper = mount(Component, {
|
|
|
42
41
|
provide: {
|
|
43
42
|
config: customConfig,
|
|
44
43
|
dropdownMenuRef: ref(),
|
|
44
|
+
visible: ref(true),
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
})
|
|
@@ -18,9 +18,9 @@ const defaultWrapper = mount(Component, {
|
|
|
18
18
|
},
|
|
19
19
|
global: {
|
|
20
20
|
provide: {
|
|
21
|
-
|
|
21
|
+
dropdownToggleRef: ref(),
|
|
22
22
|
variant: 'input-group',
|
|
23
|
-
visible: true,
|
|
23
|
+
visible: ref(true),
|
|
24
24
|
toggleMenu: function () {
|
|
25
25
|
return true
|
|
26
26
|
},
|
|
@@ -44,9 +44,9 @@ const customWrapper = mount(Component, {
|
|
|
44
44
|
},
|
|
45
45
|
global: {
|
|
46
46
|
provide: {
|
|
47
|
-
|
|
47
|
+
dropdownToggleRef: ref(),
|
|
48
48
|
variant: 'nav-item',
|
|
49
|
-
visible: true,
|
|
49
|
+
visible: ref(true),
|
|
50
50
|
toggleMenu: function () {
|
|
51
51
|
return true
|
|
52
52
|
},
|
|
@@ -71,7 +71,6 @@ describe(`Loads and display ${ComponentName} component`, () => {
|
|
|
71
71
|
expect(defaultWrapper.classes('active')).toBe(true)
|
|
72
72
|
expect(defaultWrapper.classes('disabled')).toBe(true)
|
|
73
73
|
expect(defaultWrapper.attributes('disabled')).toBe('')
|
|
74
|
-
expect(defaultWrapper.attributes('active')).toBe('true')
|
|
75
74
|
expect(defaultWrapper.find('span').classes('visually-hidden')).toBe(true)
|
|
76
75
|
expect(defaultWrapper.find('span').text()).toContain('Toggle Dropdown')
|
|
77
76
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Customize CDropdownToggle component renders correctly 1`] = `"<a active=\\"true\\" class=\\"nav-link dropdown-toggle-split
|
|
3
|
+
exports[`Customize CDropdownToggle component renders correctly 1`] = `"<a active=\\"true\\" class=\\"nav-link dropdown-toggle-split active disabled show\\" disabled=\\"true\\" href=\\"#\\">Default slot</a>"`;
|
|
4
4
|
|
|
5
|
-
exports[`Loads and display CDropdownToggle component renders correctly 1`] = `"<button class=\\"
|
|
5
|
+
exports[`Loads and display CDropdownToggle component renders correctly 1`] = `"<button class=\\"btn btn-outline-warning btn-lg active disabled rounded-pill dropdown-toggle dropdown-toggle-split active disabled show\\" disabled=\\"\\" type=\\"button\\"><span class=\\"visually-hidden\\">Toggle Dropdown</span></button>"`;
|
|
@@ -128,6 +128,7 @@ const CFormCheck = defineComponent({
|
|
|
128
128
|
|
|
129
129
|
const formControl = () => {
|
|
130
130
|
return h('input', {
|
|
131
|
+
...attrs,
|
|
131
132
|
checked: props.modelValue,
|
|
132
133
|
class: [
|
|
133
134
|
props.button ? 'btn-check' : 'form-check-input',
|
|
@@ -140,7 +141,6 @@ const CFormCheck = defineComponent({
|
|
|
140
141
|
indeterminate: props.indeterminate,
|
|
141
142
|
onChange: (event: InputEvent) => handleChange(event),
|
|
142
143
|
type: props.type,
|
|
143
|
-
...attrs,
|
|
144
144
|
})
|
|
145
145
|
}
|
|
146
146
|
const formLabel = () => {
|
|
@@ -181,6 +181,7 @@ const CFormCheck = defineComponent({
|
|
|
181
181
|
'is-invalid': props.invalid,
|
|
182
182
|
'is-valid': props.valid,
|
|
183
183
|
},
|
|
184
|
+
attrs.class,
|
|
184
185
|
],
|
|
185
186
|
},
|
|
186
187
|
[formControl(), props.label && formLabel()],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h,
|
|
1
|
+
import { defineComponent, h, watch, ref } from 'vue'
|
|
2
2
|
|
|
3
3
|
import { CFormLabel } from './CFormLabel'
|
|
4
4
|
|
|
@@ -81,12 +81,6 @@ const CFormSwitch = defineComponent({
|
|
|
81
81
|
setup(props, { attrs, emit }) {
|
|
82
82
|
const checked = ref(attrs.checked)
|
|
83
83
|
|
|
84
|
-
onMounted(() => {
|
|
85
|
-
if (props.modelValue && typeof props.modelValue === 'boolean') {
|
|
86
|
-
console.log(props.modelValue)
|
|
87
|
-
}
|
|
88
|
-
})
|
|
89
|
-
|
|
90
84
|
watch(
|
|
91
85
|
() => props.modelValue,
|
|
92
86
|
() => {
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Customize with label - CFormCheck component renders correctly 1`] = `
|
|
4
|
-
"<input class=\\"btn-check is-invalid is-valid\\" id=\\"uniqueid\\" type=\\"checkbox\\">
|
|
5
|
-
<label class=\\"btn btn-outline-warning btn-lg rounded-circle\\" for=\\"uniqueid\\">some label</label>"
|
|
6
|
-
`;
|
|
3
|
+
exports[`Customize with label - CFormCheck component renders correctly 1`] = `"<input class=\\"btn-check is-invalid is-valid\\" id=\\"uniqueid\\" type=\\"checkbox\\"><label class=\\"btn btn-outline-warning btn-lg rounded-circle\\" for=\\"uniqueid\\">some label</label>"`;
|
|
7
4
|
|
|
8
|
-
exports[`Customize with label in slot - CFormCheck component renders correctly 1`] = `
|
|
9
|
-
"<input class=\\"btn-check is-invalid is-valid\\" id=\\"uniqueid\\" type=\\"checkbox\\">
|
|
10
|
-
<label class=\\"btn btn-outline-warning btn-lg rounded-circle\\" for=\\"uniqueid\\">some label</label>"
|
|
11
|
-
`;
|
|
5
|
+
exports[`Customize with label in slot - CFormCheck component renders correctly 1`] = `"<input class=\\"btn-check is-invalid is-valid\\" id=\\"uniqueid\\" type=\\"checkbox\\"><label class=\\"btn btn-outline-warning btn-lg rounded-circle\\" for=\\"uniqueid\\">some label</label>"`;
|
|
12
6
|
|
|
13
7
|
exports[`Loads and display CFormCheck component renders correctly 1`] = `"<input class=\\"form-check-input\\" type=\\"checkbox\\">"`;
|
package/src/components/index.ts
CHANGED
|
@@ -6,11 +6,14 @@ export * from './badge'
|
|
|
6
6
|
export * from './breadcrumb'
|
|
7
7
|
export * from './button'
|
|
8
8
|
export * from './button-group'
|
|
9
|
+
export * from './calendar'
|
|
9
10
|
export * from './callout'
|
|
10
11
|
export * from './card'
|
|
11
12
|
export * from './carousel'
|
|
12
13
|
export * from './close-button'
|
|
13
14
|
export * from './collapse'
|
|
15
|
+
export * from './date-picker'
|
|
16
|
+
export * from './date-range-picker'
|
|
14
17
|
export * from './dropdown'
|
|
15
18
|
export * from './element-cover'
|
|
16
19
|
export * from './footer'
|
|
@@ -27,6 +30,7 @@ export * from './nav'
|
|
|
27
30
|
export * from './navbar'
|
|
28
31
|
export * from './offcanvas'
|
|
29
32
|
export * from './pagination'
|
|
33
|
+
export * from './picker'
|
|
30
34
|
export * from './placeholder'
|
|
31
35
|
export * from './progress'
|
|
32
36
|
export * from './popover'
|
|
@@ -35,6 +39,7 @@ export * from './smart-table'
|
|
|
35
39
|
export * from './spinner'
|
|
36
40
|
export * from './table'
|
|
37
41
|
export * from './tabs'
|
|
42
|
+
export * from './time-picker'
|
|
38
43
|
export * from './toast'
|
|
39
44
|
export * from './tooltip'
|
|
40
45
|
export * from './widgets'
|
|
@@ -7,7 +7,8 @@ exports[`Customize CModal component renders correctly 1`] = `
|
|
|
7
7
|
<div class=\\"modal-content bazinga\\">Default slot</div>
|
|
8
8
|
</div>
|
|
9
9
|
</div>
|
|
10
|
-
</transition-stub>
|
|
10
|
+
</transition-stub>
|
|
11
|
+
<!---->"
|
|
11
12
|
`;
|
|
12
13
|
|
|
13
14
|
exports[`Loads and display CModal component renders correctly 1`] = `
|
|
@@ -225,7 +225,7 @@ const CSmartPagination = defineComponent({
|
|
|
225
225
|
CPaginationItem,
|
|
226
226
|
{
|
|
227
227
|
onClick: () => {
|
|
228
|
-
setPage(1)
|
|
228
|
+
activePage.value !== 1 && setPage(1)
|
|
229
229
|
},
|
|
230
230
|
'aria-label': 'Go to first page',
|
|
231
231
|
...(activePage.value === 1 && {
|
|
@@ -247,7 +247,7 @@ const CSmartPagination = defineComponent({
|
|
|
247
247
|
CPaginationItem,
|
|
248
248
|
{
|
|
249
249
|
onClick: () => {
|
|
250
|
-
setPage(activePage.value - 1)
|
|
250
|
+
activePage.value !== 1 && setPage(activePage.value - 1)
|
|
251
251
|
},
|
|
252
252
|
'aria-label': 'Go to previous page',
|
|
253
253
|
...(activePage.value === 1 && {
|
|
@@ -304,7 +304,7 @@ const CSmartPagination = defineComponent({
|
|
|
304
304
|
CPaginationItem,
|
|
305
305
|
{
|
|
306
306
|
onClick: () => {
|
|
307
|
-
setPage(activePage.value + 1)
|
|
307
|
+
activePage.value !== pages.value && setPage(activePage.value + 1)
|
|
308
308
|
},
|
|
309
309
|
'aria-label': 'Go to next page',
|
|
310
310
|
...(activePage.value === pages.value && {
|
|
@@ -326,7 +326,7 @@ const CSmartPagination = defineComponent({
|
|
|
326
326
|
CPaginationItem,
|
|
327
327
|
{
|
|
328
328
|
onClick: () => {
|
|
329
|
-
setPage(pages.value)
|
|
329
|
+
activePage.value !== pages.value && setPage(pages.value)
|
|
330
330
|
},
|
|
331
331
|
'aria-label': 'Go to last page',
|
|
332
332
|
...(activePage.value === pages.value && {
|