@coreui/vue-pro 4.0.4 → 4.1.3
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 +280 -68
- 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 +724 -425
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +727 -423
- 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 +26 -20
- package/src/components/smart-table/CSmartTableHead.ts +14 -5
- 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>"`;
|
|
@@ -67,7 +67,6 @@ const CSmartTable = defineComponent({
|
|
|
67
67
|
*/
|
|
68
68
|
columnFilter: {
|
|
69
69
|
type: [Boolean, Object] as PropType<boolean | ColumnFilter>,
|
|
70
|
-
default: undefined,
|
|
71
70
|
required: false,
|
|
72
71
|
},
|
|
73
72
|
/**
|
|
@@ -95,7 +94,6 @@ const CSmartTable = defineComponent({
|
|
|
95
94
|
*/
|
|
96
95
|
columns: {
|
|
97
96
|
type: Array as PropType<Column[] | string[]>,
|
|
98
|
-
default: () => [],
|
|
99
97
|
required: false,
|
|
100
98
|
},
|
|
101
99
|
/**
|
|
@@ -144,7 +142,6 @@ const CSmartTable = defineComponent({
|
|
|
144
142
|
*/
|
|
145
143
|
itemsPerPage: {
|
|
146
144
|
type: Number,
|
|
147
|
-
default: 10,
|
|
148
145
|
required: false,
|
|
149
146
|
},
|
|
150
147
|
/**
|
|
@@ -216,7 +213,8 @@ const CSmartTable = defineComponent({
|
|
|
216
213
|
*/
|
|
217
214
|
selectable: Boolean,
|
|
218
215
|
/**
|
|
219
|
-
* State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. Set .sync modifier to track changes.
|
|
216
|
+
* State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. Set .sync modifier to track changes. eg.:
|
|
217
|
+
* { column: 'status', state: 'asc' }
|
|
220
218
|
*
|
|
221
219
|
* @type SorterValue
|
|
222
220
|
*/
|
|
@@ -404,7 +402,7 @@ const CSmartTable = defineComponent({
|
|
|
404
402
|
}
|
|
405
403
|
})
|
|
406
404
|
|
|
407
|
-
const itemsPerPage = ref<number>(props.itemsPerPage)
|
|
405
|
+
const itemsPerPage = ref<number>(props.itemsPerPage || items.value.length)
|
|
408
406
|
const activePage = ref(props.activePage)
|
|
409
407
|
|
|
410
408
|
const sorterState: SorterValue = reactive(props.sorterValue || {})
|
|
@@ -423,7 +421,7 @@ const CSmartTable = defineComponent({
|
|
|
423
421
|
// functions
|
|
424
422
|
|
|
425
423
|
const isSortable = (i: number): boolean | undefined => {
|
|
426
|
-
const isDataColumn = itemsDataColumns.value.includes(rawColumnNames[i])
|
|
424
|
+
const isDataColumn = itemsDataColumns.value.includes(rawColumnNames.value[i])
|
|
427
425
|
let column
|
|
428
426
|
if (props.columns) column = props.columns[i]
|
|
429
427
|
return (
|
|
@@ -539,16 +537,22 @@ const CSmartTable = defineComponent({
|
|
|
539
537
|
|
|
540
538
|
// computed
|
|
541
539
|
|
|
542
|
-
const genCols =
|
|
540
|
+
const genCols = computed(() =>
|
|
541
|
+
Object.keys(items.value[0] || {}).filter((el) => el.charAt(0) !== '_'),
|
|
542
|
+
)
|
|
543
543
|
|
|
544
|
-
const rawColumnNames =
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
544
|
+
const rawColumnNames = computed(() =>
|
|
545
|
+
props.columns
|
|
546
|
+
? props.columns.map((column: Column | string) => {
|
|
547
|
+
if (typeof column === 'object') return column.key
|
|
548
|
+
else return column
|
|
549
|
+
})
|
|
550
|
+
: genCols.value,
|
|
551
|
+
) //! || el
|
|
550
552
|
|
|
551
|
-
const itemsDataColumns = computed(() =>
|
|
553
|
+
const itemsDataColumns = computed(() =>
|
|
554
|
+
rawColumnNames.value.filter((name) => genCols.value.includes(name)),
|
|
555
|
+
)
|
|
552
556
|
|
|
553
557
|
// variables
|
|
554
558
|
|
|
@@ -657,6 +661,8 @@ const CSmartTable = defineComponent({
|
|
|
657
661
|
},
|
|
658
662
|
props.tableFilter &&
|
|
659
663
|
h(CSmartTableFilter, {
|
|
664
|
+
filterLabel: props.tableFilterLabel,
|
|
665
|
+
filterPlaceholder: props.tableFilterPlaceholder,
|
|
660
666
|
onFilterInput: (value: string) => tableFilterChange(value, 'input'),
|
|
661
667
|
onFilterChange: (value: string) => tableFilterChange(value, 'change'),
|
|
662
668
|
value: tableFilterState.value,
|
|
@@ -705,8 +711,9 @@ const CSmartTable = defineComponent({
|
|
|
705
711
|
{
|
|
706
712
|
component: 'head',
|
|
707
713
|
...props.tableHeadProps,
|
|
708
|
-
columnFilter:
|
|
709
|
-
|
|
714
|
+
columnFilter: props.columnFilter,
|
|
715
|
+
columnFilterValue: columnFilterState.value,
|
|
716
|
+
columns: rawColumnNames.value,
|
|
710
717
|
columnSorter: props.columnSorter,
|
|
711
718
|
selectable: props.selectable,
|
|
712
719
|
selectAll: selectedAll.value,
|
|
@@ -760,7 +767,7 @@ const CSmartTable = defineComponent({
|
|
|
760
767
|
currentItems: currentItems.value,
|
|
761
768
|
firstItemOnActivePageIndex: firstItemOnActivePageIndex.value,
|
|
762
769
|
noItemsLabel: props.noItemsLabel,
|
|
763
|
-
columns:
|
|
770
|
+
columns: rawColumnNames.value,
|
|
764
771
|
scopedSlots: slots,
|
|
765
772
|
selectable: props.selectable,
|
|
766
773
|
onRowChecked: (id: number, value: boolean) => handleRowChecked(id, value),
|
|
@@ -770,7 +777,7 @@ const CSmartTable = defineComponent({
|
|
|
770
777
|
columnName: string,
|
|
771
778
|
event: MouseEvent | boolean,
|
|
772
779
|
) => handleRowClick(item, index, columnName, event),
|
|
773
|
-
rawColumnNames: rawColumnNames,
|
|
780
|
+
rawColumnNames: rawColumnNames.value,
|
|
774
781
|
clickableRows: props.clickableRows,
|
|
775
782
|
...props.tableBodyProps,
|
|
776
783
|
}),
|
|
@@ -780,7 +787,7 @@ const CSmartTable = defineComponent({
|
|
|
780
787
|
...props.tableFootProps,
|
|
781
788
|
columnFilter: false,
|
|
782
789
|
columnSorter: false,
|
|
783
|
-
columns:
|
|
790
|
+
columns: rawColumnNames.value,
|
|
784
791
|
selectable: props.selectable,
|
|
785
792
|
selectAll: selectedAll.value,
|
|
786
793
|
onFilterInput: (key: string, value: string) =>
|
|
@@ -820,7 +827,6 @@ const CSmartTable = defineComponent({
|
|
|
820
827
|
pages: numberOfPages.value,
|
|
821
828
|
activePage: activePage.value,
|
|
822
829
|
onActivePageChange: handleActivePageChange,
|
|
823
|
-
limit: itemsPerPage.value,
|
|
824
830
|
})
|
|
825
831
|
: '',
|
|
826
832
|
),
|
|
@@ -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,
|
|
@@ -221,9 +230,9 @@ const CSmartTableHead = defineComponent({
|
|
|
221
230
|
(event.target as HTMLInputElement).value,
|
|
222
231
|
),
|
|
223
232
|
'aria-label': `column name: '${label(column)}' filter input`,
|
|
224
|
-
...(props.
|
|
225
|
-
props.
|
|
226
|
-
value: props.
|
|
233
|
+
...(props.columnFilterValue &&
|
|
234
|
+
props.columnFilterValue[key(column)] && {
|
|
235
|
+
value: props.columnFilterValue[key(column)],
|
|
227
236
|
}),
|
|
228
237
|
}),
|
|
229
238
|
},
|
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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ObjectDirective } from '@vue/runtime-core'
|
|
2
|
+
|
|
3
|
+
interface VShowElement extends HTMLElement {
|
|
4
|
+
// _vod = vue original display
|
|
5
|
+
_vod: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const vVisible: ObjectDirective<VShowElement> = {
|
|
9
|
+
beforeMount(el, { value }, { transition }) {
|
|
10
|
+
el._vod = el.style.display === 'none' ? '' : el.style.display
|
|
11
|
+
if (transition && value) {
|
|
12
|
+
transition.beforeEnter(el)
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
mounted(el, { value }, { transition }) {
|
|
16
|
+
if (transition && value) {
|
|
17
|
+
transition.enter(el)
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
updated(el, { value, oldValue }, { transition }) {
|
|
21
|
+
if (!value === !oldValue) return
|
|
22
|
+
if (transition) {
|
|
23
|
+
if (value) {
|
|
24
|
+
transition.beforeEnter(el)
|
|
25
|
+
transition.enter(el)
|
|
26
|
+
} else {
|
|
27
|
+
transition.leave(el, () => {
|
|
28
|
+
// setDisplay(el, false)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//@ts-nocheck
|
|
2
2
|
import { App } from 'vue'
|
|
3
3
|
import * as Components from './components'
|
|
4
|
-
import { vcpopover, vctooltip } from './directives'
|
|
4
|
+
import { vcplaceholder, vcpopover, vctooltip } from './directives'
|
|
5
5
|
|
|
6
6
|
const removeKeysFromObject = (object, keys) => {
|
|
7
7
|
return Object.entries(object).reduce((obj, [key, value]) => {
|
|
@@ -30,6 +30,7 @@ const CoreuiVue = {
|
|
|
30
30
|
// app.directive(directive, Directives[directive])
|
|
31
31
|
// }
|
|
32
32
|
|
|
33
|
+
app.directive('c-placeholder', vcplaceholder)
|
|
33
34
|
app.directive('c-popover', vcpopover)
|
|
34
35
|
app.directive('c-tooltip', vctooltip)
|
|
35
36
|
},
|