@coreui/vue-pro 4.0.3 → 4.1.2
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/accordion/CAccordion.d.ts +18 -10
- package/dist/components/accordion/CAccordionBody.d.ts +1 -1
- package/dist/components/accordion/CAccordionButton.d.ts +1 -1
- package/dist/components/accordion/CAccordionCollapse.d.ts +9 -5
- package/dist/components/accordion/CAccordionHeader.d.ts +1 -1
- package/dist/components/accordion/CAccordionItem.d.ts +10 -5
- package/dist/components/alert/CAlert.d.ts +38 -12
- package/dist/components/alert/CAlertHeading.d.ts +10 -5
- package/dist/components/alert/CAlertLink.d.ts +1 -1
- package/dist/components/avatar/CAvatar.d.ts +59 -15
- package/dist/components/backdrop/CBackdrop.d.ts +10 -5
- package/dist/components/badge/CBadge.d.ts +59 -16
- package/dist/components/breadcrumb/CBreadcrumb.d.ts +1 -1
- package/dist/components/breadcrumb/CBreadcrumbItem.d.ts +17 -8
- package/dist/components/button/CButton.d.ts +73 -20
- package/dist/components/button-group/CButtonGroup.d.ts +20 -8
- package/dist/components/button-group/CButtonToolbar.d.ts +1 -1
- package/dist/components/callout/CCallout.d.ts +11 -5
- package/dist/components/card/CCard.d.ts +20 -7
- package/dist/components/card/CCardBody.d.ts +1 -1
- package/dist/components/card/CCardFooter.d.ts +1 -1
- package/dist/components/card/CCardGroup.d.ts +1 -1
- package/dist/components/card/CCardHeader.d.ts +10 -5
- package/dist/components/card/CCardImage.d.ts +21 -8
- package/dist/components/card/CCardImageOverlay.d.ts +1 -1
- package/dist/components/card/CCardLink.d.ts +10 -5
- package/dist/components/card/CCardSubtitle.d.ts +10 -5
- package/dist/components/card/CCardText.d.ts +10 -5
- package/dist/components/card/CCardTitle.d.ts +10 -5
- package/dist/components/carousel/CCarousel.d.ts +58 -19
- package/dist/components/carousel/CCarouselCaption.d.ts +1 -1
- package/dist/components/carousel/CCarouselItem.d.ts +25 -9
- package/dist/components/close-button/CCloseButton.d.ts +16 -7
- package/dist/components/collapse/CCollapse.d.ts +24 -5
- package/dist/components/dropdown/CDropdown.d.ts +82 -22
- package/dist/components/dropdown/CDropdownDivider.d.ts +1 -1
- package/dist/components/dropdown/CDropdownHeader.d.ts +10 -5
- package/dist/components/dropdown/CDropdownItem.d.ts +32 -12
- package/dist/components/dropdown/CDropdownMenu.d.ts +12 -5
- package/dist/components/dropdown/CDropdownToggle.d.ts +78 -22
- package/dist/components/element-cover/CElementCover.d.ts +22 -7
- package/dist/components/element-cover/index.d.ts +6 -0
- package/dist/components/footer/CFooter.d.ts +13 -5
- package/dist/components/form/CForm.d.ts +9 -5
- package/dist/components/form/CFormCheck.d.ts +66 -23
- package/dist/components/form/CFormControl.d.ts +61 -20
- package/dist/components/form/CFormFeedback.d.ts +22 -11
- package/dist/components/form/CFormFloating.d.ts +1 -1
- package/dist/components/form/CFormInput.d.ts +66 -20
- package/dist/components/form/CFormLabel.d.ts +10 -5
- package/dist/components/form/CFormRange.d.ts +59 -18
- package/dist/components/form/CFormSelect.d.ts +66 -18
- package/dist/components/form/CFormSwitch.d.ts +61 -18
- package/dist/components/form/CFormText.d.ts +10 -5
- package/dist/components/form/CFormTextarea.d.ts +45 -16
- package/dist/components/form/CInputGroup.d.ts +13 -5
- package/dist/components/form/CInputGroupText.d.ts +10 -5
- package/dist/components/grid/CCol.d.ts +62 -15
- package/dist/components/grid/CContainer.d.ts +44 -15
- package/dist/components/grid/CRow.d.ts +57 -15
- package/dist/components/header/CHeader.d.ts +24 -7
- package/dist/components/header/CHeaderBrand.d.ts +10 -5
- package/dist/components/header/CHeaderDivider.d.ts +1 -1
- package/dist/components/header/CHeaderNav.d.ts +10 -5
- package/dist/components/header/CHeaderText.d.ts +1 -1
- package/dist/components/header/CHeaderToggler.d.ts +1 -1
- package/dist/components/image/CImage.d.ts +34 -12
- package/dist/components/index.d.ts +2 -0
- package/dist/components/link/CLink.d.ts +32 -12
- package/dist/components/list-group/CListGroup.d.ts +28 -10
- package/dist/components/list-group/CListGroupItem.d.ts +33 -12
- package/dist/components/modal/CModal.d.ts +97 -23
- package/dist/components/modal/CModalBody.d.ts +1 -1
- package/dist/components/modal/CModalFooter.d.ts +1 -1
- package/dist/components/modal/CModalHeader.d.ts +10 -5
- package/dist/components/modal/CModalTitle.d.ts +10 -5
- package/dist/components/multi-select/CMultiSelect.d.ts +131 -30
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +26 -11
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +40 -11
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +47 -13
- package/dist/components/nav/CNav.d.ts +32 -10
- package/dist/components/nav/CNavGroup.d.ts +10 -7
- package/dist/components/nav/CNavGroupItems.d.ts +1 -1
- package/dist/components/nav/CNavLink.d.ts +32 -12
- package/dist/components/nav/CNavTitle.d.ts +1 -1
- package/dist/components/navbar/CNavbar.d.ts +63 -16
- package/dist/components/navbar/CNavbarBrand.d.ts +19 -8
- package/dist/components/navbar/CNavbarNav.d.ts +10 -5
- package/dist/components/navbar/CNavbarText.d.ts +1 -1
- package/dist/components/navbar/CNavbarToggler.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +44 -14
- package/dist/components/offcanvas/COffcanvasBody.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvasHeader.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvasTitle.d.ts +10 -5
- package/dist/components/pagination/CPagination.d.ts +24 -7
- package/dist/components/pagination/CPaginationItem.d.ts +32 -12
- package/dist/components/pagination/CSmartPagination.d.ts +120 -28
- package/dist/components/placeholder/CPlaceholder.d.ts +189 -0
- package/dist/components/placeholder/index.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +51 -17
- package/dist/components/progress/CProgressBar.d.ts +37 -12
- package/dist/components/sidebar/CSidebar.d.ts +59 -20
- package/dist/components/sidebar/CSidebarBrand.d.ts +1 -1
- package/dist/components/sidebar/CSidebarFooter.d.ts +1 -1
- package/dist/components/sidebar/CSidebarHeader.d.ts +1 -1
- package/dist/components/sidebar/CSidebarNav.d.ts +1 -1
- package/dist/components/sidebar/CSidebarToggler.d.ts +1 -1
- package/dist/components/smart-table/CSmartTable.d.ts +281 -69
- package/dist/components/smart-table/CSmartTableBody.d.ts +37 -20
- package/dist/components/smart-table/CSmartTableCleaner.d.ts +7 -5
- package/dist/components/smart-table/CSmartTableFilter.d.ts +17 -9
- package/dist/components/smart-table/CSmartTableHead.d.ts +42 -23
- package/dist/components/smart-table/CSmartTableItemsPerPageSelector.d.ts +17 -10
- package/dist/components/spinner/CSpinner.d.ts +51 -14
- package/dist/components/table/CTable.d.ts +89 -25
- package/dist/components/table/CTableBody.d.ts +11 -5
- package/dist/components/table/CTableCaption.d.ts +2 -4
- package/dist/components/table/CTableDataCell.d.ts +29 -10
- package/dist/components/table/CTableFoot.d.ts +11 -5
- package/dist/components/table/CTableHead.d.ts +11 -5
- package/dist/components/table/CTableHeaderCell.d.ts +11 -5
- package/dist/components/table/CTableRow.d.ts +29 -10
- package/dist/components/tabs/CTabContent.d.ts +1 -1
- package/dist/components/tabs/CTabPane.d.ts +10 -5
- package/dist/components/toast/CToast.d.ts +59 -18
- package/dist/components/toast/CToastBody.d.ts +1 -1
- package/dist/components/toast/CToastHeader.d.ts +9 -5
- package/dist/components/toast/CToaster.d.ts +13 -5
- package/dist/components/tooltip/CTooltip.d.ts +42 -14
- package/dist/components/widgets/CWidgetStatsA.d.ts +23 -10
- package/dist/components/widgets/CWidgetStatsB.d.ts +46 -18
- package/dist/components/widgets/CWidgetStatsC.d.ts +37 -15
- package/dist/components/widgets/CWidgetStatsD.d.ts +19 -8
- package/dist/components/widgets/CWidgetStatsE.d.ts +18 -8
- package/dist/components/widgets/CWidgetStatsF.d.ts +43 -15
- package/dist/directives/index.d.ts +3 -2
- package/dist/directives/v-c-placeholder.d.ts +6 -0
- package/dist/directives/v-c-visible.d.ts +6 -0
- package/dist/index.es.js +760 -455
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +763 -453
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.ts.snap +1 -1
- package/src/components/button/CButton.ts +1 -0
- package/src/components/collapse/CCollapse.ts +49 -21
- package/src/components/collapse/__test__/__snapshots__/CCollapse.spec.ts.snap +1 -1
- package/src/components/element-cover/index.ts +10 -0
- package/src/components/form/CFormInput.ts +6 -6
- package/src/components/form/CFormSelect.ts +21 -6
- package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +8 -2
- package/src/components/form/__tests__/__snapshots__/CFormSelect.spec.ts.snap +1 -1
- package/src/components/grid/CCol.ts +8 -8
- package/src/components/grid/CContainer.ts +3 -3
- package/src/components/grid/CRow.ts +6 -6
- package/src/components/index.ts +2 -0
- package/src/components/modal/CModal.ts +68 -40
- package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +1 -2
- package/src/components/offcanvas/COffcanvas.ts +30 -20
- package/src/components/offcanvas/__tests__/COffcanvas.spec.ts +1 -1
- package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.ts.snap +2 -2
- package/src/components/placeholder/CPlaceholder.ts +139 -0
- package/src/components/placeholder/__tests__/CPlaceholder.spec.ts +44 -0
- package/src/components/placeholder/__tests__/__snapshots__/CPlaceholder.spec.ts.snap +15 -0
- package/src/components/placeholder/index.ts +10 -0
- package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +2 -8
- package/src/components/smart-table/CSmartTable.ts +38 -36
- package/src/components/smart-table/CSmartTableHead.ts +54 -44
- package/src/directives/index.ts +3 -2
- package/src/directives/v-c-placeholder.ts +32 -0
- package/src/directives/v-c-visible.ts +33 -0
- package/src/index.ts +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { defineComponent, h, ref, RendererElement, Transition, watch } from 'vue'
|
|
1
|
+
import { defineComponent, h, ref, RendererElement, Transition, watch, withDirectives } from 'vue'
|
|
2
2
|
import { CBackdrop } from '../backdrop'
|
|
3
|
+
import { vVisible } from '../../directives/v-c-visible'
|
|
3
4
|
|
|
4
5
|
const COffcanvas = defineComponent({
|
|
5
6
|
name: 'COffcanvas',
|
|
@@ -96,19 +97,20 @@ const COffcanvas = defineComponent({
|
|
|
96
97
|
}, 1)
|
|
97
98
|
}
|
|
98
99
|
const handleAfterEnter = () => {
|
|
99
|
-
window.addEventListener('
|
|
100
|
+
window.addEventListener('mousedown', handleMouseDown)
|
|
101
|
+
// window.addEventListener('click', handleClickOutside)
|
|
100
102
|
window.addEventListener('keyup', handleKeyUp)
|
|
101
103
|
}
|
|
102
104
|
const handleLeave = (el: RendererElement, done: () => void) => {
|
|
103
105
|
el.addEventListener('transitionend', () => {
|
|
104
106
|
done()
|
|
105
107
|
})
|
|
108
|
+
window.removeEventListener('mousedown', handleMouseDown)
|
|
109
|
+
window.removeEventListener('keyup', handleKeyUp)
|
|
106
110
|
el.classList.remove('show')
|
|
107
111
|
}
|
|
108
112
|
const handleAfterLeave = (el: RendererElement) => {
|
|
109
113
|
el.style.visibility = 'hidden'
|
|
110
|
-
window.removeEventListener('click', handleClickOutside)
|
|
111
|
-
window.removeEventListener('keyup', handleKeyUp)
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
const handleDismiss = () => {
|
|
@@ -123,7 +125,12 @@ const COffcanvas = defineComponent({
|
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
|
|
128
|
+
|
|
129
|
+
const handleMouseDown = (event: Event) => {
|
|
130
|
+
window.addEventListener('mouseup', () => handleMouseUp(event), { once: true })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const handleMouseUp = (event: Event) => {
|
|
127
134
|
if (offcanvasRef.value && !offcanvasRef.value.contains(event.target as HTMLElement)) {
|
|
128
135
|
props.backdrop && handleDismiss()
|
|
129
136
|
}
|
|
@@ -133,31 +140,34 @@ const COffcanvas = defineComponent({
|
|
|
133
140
|
h(
|
|
134
141
|
Transition,
|
|
135
142
|
{
|
|
143
|
+
css: false,
|
|
136
144
|
onEnter: (el, done) => handleEnter(el, done),
|
|
137
145
|
onAfterEnter: () => handleAfterEnter(),
|
|
138
146
|
onLeave: (el, done) => handleLeave(el, done),
|
|
139
147
|
onAfterLeave: (el) => handleAfterLeave(el),
|
|
140
148
|
},
|
|
141
149
|
() =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
withDirectives(
|
|
151
|
+
h(
|
|
152
|
+
'div',
|
|
153
|
+
{
|
|
154
|
+
class: [
|
|
155
|
+
'offcanvas',
|
|
156
|
+
{
|
|
157
|
+
[`offcanvas-${props.placement}`]: props.placement,
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
ref: offcanvasRef,
|
|
161
|
+
role: 'dialog',
|
|
162
|
+
},
|
|
163
|
+
slots.default && slots.default(),
|
|
164
|
+
),
|
|
165
|
+
[[vVisible, props.visible]],
|
|
156
166
|
),
|
|
157
167
|
),
|
|
158
168
|
props.backdrop &&
|
|
159
169
|
h(CBackdrop, {
|
|
160
|
-
class: '
|
|
170
|
+
class: 'offcanvas-backdrop',
|
|
161
171
|
visible: visible.value,
|
|
162
172
|
}),
|
|
163
173
|
]
|
|
@@ -47,6 +47,6 @@ describe(`Customize ${ComponentName} component`, () => {
|
|
|
47
47
|
expect(customWrapper.text()).toContain('Default slot')
|
|
48
48
|
expect(customWrapper.find('div').classes('offcanvas')).toBe(true)
|
|
49
49
|
expect(customWrapper.find('div').classes('offcanvas-bottom')).toBe(true)
|
|
50
|
-
expect(customWrapper.find('.
|
|
50
|
+
expect(customWrapper.find('.offcanvas-backdrop').classes('offcanvas-backdrop')).toBe(true)
|
|
51
51
|
})
|
|
52
52
|
})
|
|
@@ -4,7 +4,7 @@ exports[`Customize COffcanvas component renders correctly 1`] = `
|
|
|
4
4
|
"<transition-stub>
|
|
5
5
|
<div class=\\"offcanvas offcanvas-bottom\\" role=\\"dialog\\">Default slot</div>
|
|
6
6
|
</transition-stub>
|
|
7
|
-
<transition-stub class=\\"
|
|
7
|
+
<transition-stub class=\\"offcanvas-backdrop\\">
|
|
8
8
|
<div class=\\"fade\\"></div>
|
|
9
9
|
</transition-stub>"
|
|
10
10
|
`;
|
|
@@ -13,7 +13,7 @@ exports[`Loads and display COffcanvas component renders correctly 1`] = `
|
|
|
13
13
|
"<transition-stub>
|
|
14
14
|
<div class=\\"offcanvas offcanvas-end\\" role=\\"dialog\\">Default slot</div>
|
|
15
15
|
</transition-stub>
|
|
16
|
-
<transition-stub class=\\"
|
|
16
|
+
<transition-stub class=\\"offcanvas-backdrop\\">
|
|
17
17
|
<div class=\\"fade\\"></div>
|
|
18
18
|
</transition-stub>"
|
|
19
19
|
`;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue'
|
|
2
|
+
|
|
3
|
+
import { Color } from '../props'
|
|
4
|
+
|
|
5
|
+
const BREAKPOINTS = [
|
|
6
|
+
'xxl' as const,
|
|
7
|
+
'xl' as const,
|
|
8
|
+
'lg' as const,
|
|
9
|
+
'md' as const,
|
|
10
|
+
'sm' as const,
|
|
11
|
+
'xs' as const,
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
export const CPlaceholder = defineComponent({
|
|
15
|
+
name: 'CPlaceholder',
|
|
16
|
+
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Set animation type to better convey the perception of something being actively loaded.
|
|
19
|
+
*
|
|
20
|
+
* @values 'glow', 'wave'
|
|
21
|
+
*/
|
|
22
|
+
animation: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: undefined,
|
|
25
|
+
require: false,
|
|
26
|
+
validator: (value: string) => {
|
|
27
|
+
return ['glow', 'wave'].includes(value)
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Sets the color context of the component to one of CoreUI’s themed colors.
|
|
32
|
+
*
|
|
33
|
+
* @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
|
|
34
|
+
*/
|
|
35
|
+
color: Color,
|
|
36
|
+
/**
|
|
37
|
+
* Component used for the root node. Either a string to use a HTML element or a component.
|
|
38
|
+
*/
|
|
39
|
+
component: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: 'span',
|
|
42
|
+
required: false,
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Size the component extra small, small, or large.
|
|
46
|
+
*
|
|
47
|
+
* @values 'xs', 'sm', 'lg'
|
|
48
|
+
*/
|
|
49
|
+
size: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: undefined,
|
|
52
|
+
required: false,
|
|
53
|
+
validator: (value: string) => {
|
|
54
|
+
return ['xs', 'sm', 'lg'].includes(value)
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* The number of columns on extra small devices (<576px).
|
|
59
|
+
*/
|
|
60
|
+
xs: {
|
|
61
|
+
type: Number,
|
|
62
|
+
default: undefined,
|
|
63
|
+
require: false,
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* The number of columns on small devices (<768px).
|
|
67
|
+
*/
|
|
68
|
+
sm: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: undefined,
|
|
71
|
+
require: false,
|
|
72
|
+
},
|
|
73
|
+
/**
|
|
74
|
+
* The number of columns on medium devices (<992px).
|
|
75
|
+
*/
|
|
76
|
+
md: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: undefined,
|
|
79
|
+
require: false,
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* The number of columns on large devices (<1200px).
|
|
83
|
+
*/
|
|
84
|
+
lg: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: undefined,
|
|
87
|
+
require: false,
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* The number of columns on X-Large devices (<1400px).
|
|
91
|
+
*/
|
|
92
|
+
xl: {
|
|
93
|
+
type: Number,
|
|
94
|
+
default: undefined,
|
|
95
|
+
require: false,
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* The number of columns on XX-Large devices (≥1400px).
|
|
99
|
+
*/
|
|
100
|
+
xxl: {
|
|
101
|
+
type: Number,
|
|
102
|
+
default: undefined,
|
|
103
|
+
require: false,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
setup(props, { slots }) {
|
|
107
|
+
const repsonsiveClassNames: string[] = []
|
|
108
|
+
|
|
109
|
+
BREAKPOINTS.forEach((bp) => {
|
|
110
|
+
const breakpoint = props[bp]
|
|
111
|
+
|
|
112
|
+
const infix = bp === 'xs' ? '' : `-${bp}`
|
|
113
|
+
|
|
114
|
+
if (typeof breakpoint === 'number') {
|
|
115
|
+
repsonsiveClassNames.push(`col${infix}-${breakpoint}`)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (typeof breakpoint === 'boolean') {
|
|
119
|
+
repsonsiveClassNames.push(`col${infix}`)
|
|
120
|
+
}
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
return () =>
|
|
124
|
+
h(
|
|
125
|
+
props.component,
|
|
126
|
+
{
|
|
127
|
+
class: [
|
|
128
|
+
props.animation ? `placeholder-${props.animation}` : 'placeholder',
|
|
129
|
+
{
|
|
130
|
+
[`bg-${props.color}`]: props.color,
|
|
131
|
+
[`placeholder-${props.size}`]: props.size,
|
|
132
|
+
},
|
|
133
|
+
repsonsiveClassNames,
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
slots.default && slots.default(),
|
|
137
|
+
)
|
|
138
|
+
},
|
|
139
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils'
|
|
2
|
+
import { CPlaceholder as Component } from './../../'
|
|
3
|
+
|
|
4
|
+
const ComponentName = 'CPlaceholder'
|
|
5
|
+
const wrapper = shallowMount(Component)
|
|
6
|
+
const customWrapper = shallowMount(Component, {
|
|
7
|
+
props: {
|
|
8
|
+
animation: 'glow',
|
|
9
|
+
color: 'secondary',
|
|
10
|
+
size: 'lg',
|
|
11
|
+
sm: 7,
|
|
12
|
+
},
|
|
13
|
+
attrs: {
|
|
14
|
+
class: 'bazinga',
|
|
15
|
+
},
|
|
16
|
+
slots: {
|
|
17
|
+
default: 'Hello World!',
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe(`Loads and display ${ComponentName} component`, () => {
|
|
22
|
+
it('has a name', () => {
|
|
23
|
+
expect(Component.name).toMatch(ComponentName)
|
|
24
|
+
})
|
|
25
|
+
it('renders correctly', () => {
|
|
26
|
+
expect(wrapper.element).toMatchSnapshot()
|
|
27
|
+
})
|
|
28
|
+
it('renders correctly with slot', () => {
|
|
29
|
+
expect(customWrapper.element).toMatchSnapshot()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
describe(`Customize ${ComponentName} component`, () => {
|
|
34
|
+
it('has a prope class names', () => {
|
|
35
|
+
expect(customWrapper.find('span').classes('bazinga')).toBe(true)
|
|
36
|
+
expect(customWrapper.find('span').classes('bg-secondary')).toBe(true)
|
|
37
|
+
expect(customWrapper.find('span').classes('col-sm-7')).toBe(true)
|
|
38
|
+
expect(customWrapper.find('span').classes('placeholder-glow')).toBe(true)
|
|
39
|
+
expect(customWrapper.find('span').classes('placeholder-lg')).toBe(true)
|
|
40
|
+
})
|
|
41
|
+
it('default slot contains text', () => {
|
|
42
|
+
expect(customWrapper.text()).toBe('Hello World!')
|
|
43
|
+
})
|
|
44
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Loads and display CPlaceholder component renders correctly 1`] = `
|
|
4
|
+
<span
|
|
5
|
+
class="placeholder"
|
|
6
|
+
/>
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
exports[`Loads and display CPlaceholder component renders correctly with slot 1`] = `
|
|
10
|
+
<span
|
|
11
|
+
class="placeholder-glow bg-secondary placeholder-lg col-sm-7 bazinga"
|
|
12
|
+
>
|
|
13
|
+
Hello World!
|
|
14
|
+
</span>
|
|
15
|
+
`;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Customize CSidebar component renders correctly 1`] = `
|
|
4
|
-
"<div class=\\"sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-xl sidebar-narrow-unfoldable\\">Default slot</div>
|
|
5
|
-
<!---->"
|
|
6
|
-
`;
|
|
3
|
+
exports[`Customize CSidebar component renders correctly 1`] = `"<div class=\\"sidebar sidebar-narrow sidebar-overlaid sidebar-fixed sidebar-xl sidebar-narrow-unfoldable\\">Default slot</div>"`;
|
|
7
4
|
|
|
8
|
-
exports[`Loads and display CSidebar component renders correctly 1`] = `
|
|
9
|
-
"<div class=\\"sidebar hide\\">Default slot</div>
|
|
10
|
-
<!---->"
|
|
11
|
-
`;
|
|
5
|
+
exports[`Loads and display CSidebar component renders correctly 1`] = `"<div class=\\"sidebar hide\\">Default slot</div>"`;
|
|
@@ -46,7 +46,6 @@ const CSmartTable = defineComponent({
|
|
|
46
46
|
*/
|
|
47
47
|
cleaner: {
|
|
48
48
|
type: Boolean,
|
|
49
|
-
default: true,
|
|
50
49
|
required: false,
|
|
51
50
|
},
|
|
52
51
|
/**
|
|
@@ -68,7 +67,6 @@ const CSmartTable = defineComponent({
|
|
|
68
67
|
*/
|
|
69
68
|
columnFilter: {
|
|
70
69
|
type: [Boolean, Object] as PropType<boolean | ColumnFilter>,
|
|
71
|
-
default: undefined,
|
|
72
70
|
required: false,
|
|
73
71
|
},
|
|
74
72
|
/**
|
|
@@ -145,7 +143,6 @@ const CSmartTable = defineComponent({
|
|
|
145
143
|
*/
|
|
146
144
|
itemsPerPage: {
|
|
147
145
|
type: Number,
|
|
148
|
-
default: 10,
|
|
149
146
|
required: false,
|
|
150
147
|
},
|
|
151
148
|
/**
|
|
@@ -217,7 +214,8 @@ const CSmartTable = defineComponent({
|
|
|
217
214
|
*/
|
|
218
215
|
selectable: Boolean,
|
|
219
216
|
/**
|
|
220
|
-
* State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. Set .sync modifier to track changes.
|
|
217
|
+
* State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. Set .sync modifier to track changes. eg.:
|
|
218
|
+
* { column: 'status', state: 'asc' }
|
|
221
219
|
*
|
|
222
220
|
* @type SorterValue
|
|
223
221
|
*/
|
|
@@ -257,7 +255,6 @@ const CSmartTable = defineComponent({
|
|
|
257
255
|
*/
|
|
258
256
|
tableFilter: {
|
|
259
257
|
type: [Boolean, Object] as PropType<boolean | TableFilter>,
|
|
260
|
-
default: undefined,
|
|
261
258
|
required: false,
|
|
262
259
|
},
|
|
263
260
|
/**
|
|
@@ -389,6 +386,7 @@ const CSmartTable = defineComponent({
|
|
|
389
386
|
|
|
390
387
|
watch(items, () => {
|
|
391
388
|
const selected = items.value.filter((item) => item._selected === true)
|
|
389
|
+
emit('selectedItemsChange', selected)
|
|
392
390
|
|
|
393
391
|
if (selected.length === items.value.length) {
|
|
394
392
|
selectedAll.value = true
|
|
@@ -403,11 +401,9 @@ const CSmartTable = defineComponent({
|
|
|
403
401
|
if (selected.length !== 0 && selected.length !== items.value.length) {
|
|
404
402
|
selectedAll.value = 'indeterminate'
|
|
405
403
|
}
|
|
406
|
-
|
|
407
|
-
emit('selectedItemsChange', selected)
|
|
408
404
|
})
|
|
409
405
|
|
|
410
|
-
const itemsPerPage = ref<number>(props.itemsPerPage)
|
|
406
|
+
const itemsPerPage = ref<number>(props.itemsPerPage || items.value.length)
|
|
411
407
|
const activePage = ref(props.activePage)
|
|
412
408
|
|
|
413
409
|
const sorterState: SorterValue = reactive(props.sorterValue || {})
|
|
@@ -452,7 +448,11 @@ const CSmartTable = defineComponent({
|
|
|
452
448
|
} else if (state.state === 'asc') {
|
|
453
449
|
state.state = 'desc'
|
|
454
450
|
} else {
|
|
455
|
-
|
|
451
|
+
if (typeof props.columnSorter === 'object' && !props.columnSorter.resetable) {
|
|
452
|
+
state.state = 'asc'
|
|
453
|
+
} else {
|
|
454
|
+
state.state = 0
|
|
455
|
+
}
|
|
456
456
|
}
|
|
457
457
|
} else {
|
|
458
458
|
state.column = column
|
|
@@ -641,14 +641,14 @@ const CSmartTable = defineComponent({
|
|
|
641
641
|
|
|
642
642
|
return () =>
|
|
643
643
|
h('div', {}, [
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
644
|
+
(props.tableFilter || props.cleaner) &&
|
|
645
|
+
h(
|
|
646
|
+
'div',
|
|
647
|
+
{
|
|
648
|
+
class: 'row my-2 mx-0',
|
|
649
|
+
},
|
|
650
|
+
[
|
|
651
|
+
props.tableFilter &&
|
|
652
652
|
h(
|
|
653
653
|
'div',
|
|
654
654
|
{
|
|
@@ -656,35 +656,36 @@ const CSmartTable = defineComponent({
|
|
|
656
656
|
},
|
|
657
657
|
props.tableFilter &&
|
|
658
658
|
h(CSmartTableFilter, {
|
|
659
|
+
filterLabel: props.tableFilterLabel,
|
|
660
|
+
filterPlaceholder: props.tableFilterPlaceholder,
|
|
659
661
|
onFilterInput: (value: string) => tableFilterChange(value, 'input'),
|
|
660
662
|
onFilterChange: (value: string) => tableFilterChange(value, 'change'),
|
|
661
663
|
value: tableFilterState.value,
|
|
662
664
|
}),
|
|
663
665
|
),
|
|
666
|
+
props.cleaner &&
|
|
664
667
|
h(
|
|
665
668
|
'div',
|
|
666
669
|
{
|
|
667
670
|
class: 'col-auto p-0',
|
|
668
671
|
},
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
cleanerIcon
|
|
679
|
-
slots.cleanerIcon
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
),
|
|
672
|
+
h(
|
|
673
|
+
CSmartTableCleaner,
|
|
674
|
+
{
|
|
675
|
+
onClick: () => clean(),
|
|
676
|
+
isFiltered: isFiltered.value,
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
// @slot Cleaner icon.
|
|
680
|
+
cleanerIcon: () =>
|
|
681
|
+
slots.cleanerIcon
|
|
682
|
+
? slots.cleanerIcon()
|
|
683
|
+
: h(CIcon, { width: '18', content: cilFilterX }),
|
|
684
|
+
},
|
|
685
|
+
),
|
|
684
686
|
),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
), //h
|
|
687
|
+
],
|
|
688
|
+
), //h
|
|
688
689
|
h(
|
|
689
690
|
'div',
|
|
690
691
|
{
|
|
@@ -705,7 +706,8 @@ const CSmartTable = defineComponent({
|
|
|
705
706
|
{
|
|
706
707
|
component: 'head',
|
|
707
708
|
...props.tableHeadProps,
|
|
708
|
-
columnFilter:
|
|
709
|
+
columnFilter: props.columnFilter,
|
|
710
|
+
columnFilterValue: columnFilterState.value,
|
|
709
711
|
columns: props.columns,
|
|
710
712
|
columnSorter: props.columnSorter,
|
|
711
713
|
selectable: props.selectable,
|
|
@@ -5,7 +5,13 @@ import { CTableRow } from '../table/CTableRow'
|
|
|
5
5
|
|
|
6
6
|
import { CFormCheck, CFormInput } from '../form/'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
Column,
|
|
10
|
+
ColumnFilter,
|
|
11
|
+
ColumnFilterValue,
|
|
12
|
+
Sorter,
|
|
13
|
+
SorterValue,
|
|
14
|
+
} from './CSmartTableInterface'
|
|
9
15
|
|
|
10
16
|
const CSmartTableHead = defineComponent({
|
|
11
17
|
name: 'CSmartTableHead',
|
|
@@ -17,9 +23,12 @@ const CSmartTableHead = defineComponent({
|
|
|
17
23
|
},
|
|
18
24
|
columnFilter: {
|
|
19
25
|
type: [Boolean, Object] as PropType<boolean | ColumnFilter>,
|
|
20
|
-
default: undefined,
|
|
21
26
|
require: false,
|
|
22
27
|
},
|
|
28
|
+
columnFilterValue: {
|
|
29
|
+
type: Object as PropType<ColumnFilterValue>,
|
|
30
|
+
required: false,
|
|
31
|
+
},
|
|
23
32
|
columnSorter: {
|
|
24
33
|
type: [Boolean, Object] as PropType<boolean | Sorter>,
|
|
25
34
|
default: undefined,
|
|
@@ -188,49 +197,50 @@ const CSmartTableHead = defineComponent({
|
|
|
188
197
|
],
|
|
189
198
|
},
|
|
190
199
|
),
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
props.
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
200
|
+
props.columnFilter &&
|
|
201
|
+
h(
|
|
202
|
+
CTableRow,
|
|
203
|
+
{},
|
|
204
|
+
{
|
|
205
|
+
default: () => [
|
|
206
|
+
props.selectable && h(CTableHeaderCell),
|
|
207
|
+
props.columns.map((column: Column | string) =>
|
|
208
|
+
h(
|
|
209
|
+
CTableHeaderCell,
|
|
210
|
+
{
|
|
211
|
+
...tableHeaderCellProps(column),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
default: () =>
|
|
215
|
+
(typeof column !== 'object'
|
|
216
|
+
? true
|
|
217
|
+
: typeof column.filter === 'undefined'
|
|
218
|
+
? true
|
|
219
|
+
: column.filter) &&
|
|
220
|
+
h(CFormInput, {
|
|
221
|
+
size: 'sm',
|
|
222
|
+
onInput: (event: Event) =>
|
|
223
|
+
handleFilterInput(
|
|
224
|
+
key(column),
|
|
225
|
+
(event.target as HTMLInputElement).value,
|
|
226
|
+
),
|
|
227
|
+
onChange: (event: Event) =>
|
|
228
|
+
handleFilterChange(
|
|
229
|
+
key(column),
|
|
230
|
+
(event.target as HTMLInputElement).value,
|
|
231
|
+
),
|
|
232
|
+
'aria-label': `column name: '${label(column)}' filter input`,
|
|
233
|
+
...(props.columnFilterValue &&
|
|
234
|
+
props.columnFilterValue[key(column)] && {
|
|
235
|
+
value: props.columnFilterValue[key(column)],
|
|
236
|
+
}),
|
|
237
|
+
}),
|
|
238
|
+
},
|
|
239
|
+
),
|
|
229
240
|
),
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
),
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
),
|
|
234
244
|
],
|
|
235
245
|
},
|
|
236
246
|
)
|
package/src/directives/index.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DirectiveBinding } from 'vue'
|
|
2
|
+
|
|
3
|
+
const BREAKPOINTS = [
|
|
4
|
+
'xxl' as const,
|
|
5
|
+
'xl' as const,
|
|
6
|
+
'lg' as const,
|
|
7
|
+
'md' as const,
|
|
8
|
+
'sm' as const,
|
|
9
|
+
'xs' as const,
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
name: 'c-placeholder',
|
|
14
|
+
mounted(el: HTMLElement, binding: DirectiveBinding): void {
|
|
15
|
+
const value = binding.value
|
|
16
|
+
el.classList.add(value.animation ? `placeholder-${value.animation}` : 'placeholder')
|
|
17
|
+
|
|
18
|
+
BREAKPOINTS.forEach((bp) => {
|
|
19
|
+
const breakpoint = value[bp]
|
|
20
|
+
|
|
21
|
+
const infix = bp === 'xs' ? '' : `-${bp}`
|
|
22
|
+
|
|
23
|
+
if (typeof breakpoint === 'number') {
|
|
24
|
+
el.classList.add(`col${infix}-${breakpoint}`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (typeof breakpoint === 'boolean') {
|
|
28
|
+
el.classList.add(`col${infix}`)
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
},
|
|
32
|
+
}
|