@coreui/vue-pro 4.0.4 → 4.1.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/carousel/CCarousel.d.ts +2 -2
- package/dist/components/collapse/CCollapse.d.ts +10 -0
- package/dist/components/element-cover/index.d.ts +6 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/modal/CModal.d.ts +2 -2
- package/dist/components/placeholder/CPlaceholder.d.ts +124 -0
- package/dist/components/placeholder/index.d.ts +6 -0
- package/dist/components/popover/CPopover.d.ts +2 -2
- package/dist/components/table/CTable.d.ts +2 -2
- package/dist/components/widgets/CWidgetStatsB.d.ts +2 -2
- package/dist/components/widgets/CWidgetStatsF.d.ts +2 -2
- 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 +609 -363
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +612 -361
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- 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 +2 -0
- 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/offcanvas/COffcanvas.ts +19 -16
- 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/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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreui/vue-pro",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "UI Components Library for Vue.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -35,22 +35,22 @@
|
|
|
35
35
|
"watch": "rollup -c -w"
|
|
36
36
|
},
|
|
37
37
|
"config": {
|
|
38
|
-
"version_short": "4.
|
|
38
|
+
"version_short": "4.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@popperjs/core": "^2.
|
|
41
|
+
"@popperjs/core": "^2.11.0",
|
|
42
42
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
43
43
|
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
44
44
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
45
45
|
"@vue/test-utils": "^2.0.0-0",
|
|
46
|
-
"rollup": "^2.
|
|
46
|
+
"rollup": "^2.60.1",
|
|
47
47
|
"rollup-plugin-vue": "^6.0.0",
|
|
48
|
-
"typescript": "^4.
|
|
49
|
-
"vue": "^3.2.
|
|
48
|
+
"typescript": "^4.5.2",
|
|
49
|
+
"vue": "^3.2.23",
|
|
50
50
|
"vue-types": "^4.1.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@coreui/coreui": "^4.0
|
|
53
|
+
"@coreui/coreui": "^4.1.0",
|
|
54
54
|
"vue": "^3.2.21"
|
|
55
55
|
},
|
|
56
56
|
"standard": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Loads and display CAccordionBody component renders correctly 1`] = `
|
|
4
4
|
"<transition-stub class=\\"accordion-collapse\\">
|
|
5
|
-
<div class=\\"collapse\\"
|
|
5
|
+
<div class=\\"collapse\\">
|
|
6
6
|
<div class=\\"accordion-body\\">Default slot</div>
|
|
7
7
|
</div>
|
|
8
8
|
</transition-stub>"
|
|
@@ -91,6 +91,7 @@ export const CButton = defineComponent({
|
|
|
91
91
|
],
|
|
92
92
|
disabled: props.disabled && props.component !== 'a',
|
|
93
93
|
...(props.component === 'a' && props.disabled && { 'aria-disabled': true, tabIndex: -1 }),
|
|
94
|
+
...(props.component === 'a' && props.href && { href: props.href }),
|
|
94
95
|
},
|
|
95
96
|
slots.default && slots.default(),
|
|
96
97
|
)
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { defineComponent, h, Transition,
|
|
1
|
+
import { defineComponent, h, Transition, ref, RendererElement, withDirectives } from 'vue'
|
|
2
|
+
import { vVisible } from '../../directives/v-c-visible'
|
|
2
3
|
|
|
3
4
|
const CCollapse = defineComponent({
|
|
4
5
|
name: 'CCollapse',
|
|
5
6
|
props: {
|
|
7
|
+
/**
|
|
8
|
+
* Set horizontal collapsing to transition the width instead of height.
|
|
9
|
+
*/
|
|
10
|
+
horizontal: {
|
|
11
|
+
type: Boolean,
|
|
12
|
+
required: false,
|
|
13
|
+
},
|
|
6
14
|
/**
|
|
7
15
|
* Toggle the visibility of component.
|
|
8
16
|
*/
|
|
@@ -22,46 +30,68 @@ const CCollapse = defineComponent({
|
|
|
22
30
|
'show',
|
|
23
31
|
],
|
|
24
32
|
setup(props, { slots, emit }) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
const collapsing = ref(false)
|
|
34
|
+
const show = ref(props.visible)
|
|
35
|
+
|
|
36
|
+
const handleBeforeEnter = () => {
|
|
37
|
+
collapsing.value = true
|
|
28
38
|
}
|
|
39
|
+
|
|
29
40
|
const handleEnter = (el: RendererElement, done: () => void) => {
|
|
30
41
|
emit('show')
|
|
31
42
|
el.addEventListener('transitionend', () => {
|
|
32
|
-
el.classList.add('collapse', 'show')
|
|
33
43
|
done()
|
|
34
44
|
})
|
|
35
|
-
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
if (props.horizontal) {
|
|
47
|
+
el.style.width = `${el.scrollWidth}px`
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
el.style.height = `${el.scrollHeight}px`
|
|
51
|
+
}, 1)
|
|
36
52
|
}
|
|
53
|
+
|
|
37
54
|
const handleAfterEnter = (el: RendererElement) => {
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
show.value = true
|
|
56
|
+
collapsing.value = false
|
|
57
|
+
props.horizontal ? el.style.removeProperty('width') : el.style.removeProperty('height')
|
|
40
58
|
}
|
|
59
|
+
|
|
41
60
|
const handleBeforeLeave = (el: RendererElement) => {
|
|
42
|
-
|
|
61
|
+
collapsing.value = true
|
|
62
|
+
show.value = false
|
|
63
|
+
if (props.horizontal) {
|
|
64
|
+
el.style.width = `${el.scrollWidth}px`
|
|
65
|
+
return
|
|
66
|
+
}
|
|
43
67
|
el.style.height = `${el.scrollHeight}px`
|
|
44
68
|
}
|
|
69
|
+
|
|
45
70
|
const handleLeave = (el: RendererElement, done: () => void) => {
|
|
46
71
|
emit('hide')
|
|
47
|
-
el.classList.remove('collapse', 'show')
|
|
48
|
-
el.classList.add('collapsing')
|
|
49
72
|
el.addEventListener('transitionend', () => {
|
|
50
73
|
done()
|
|
51
74
|
})
|
|
52
|
-
|
|
75
|
+
setTimeout(() => {
|
|
76
|
+
if (props.horizontal) {
|
|
77
|
+
el.style.width = '0px'
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
el.style.height = '0px'
|
|
81
|
+
}, 1)
|
|
53
82
|
}
|
|
83
|
+
|
|
54
84
|
const handleAfterLeave = (el: RendererElement) => {
|
|
55
|
-
|
|
56
|
-
el.
|
|
85
|
+
collapsing.value = false
|
|
86
|
+
props.horizontal ? el.style.removeProperty('width') : el.style.removeProperty('height')
|
|
57
87
|
}
|
|
58
88
|
|
|
59
89
|
return () =>
|
|
60
90
|
h(
|
|
61
91
|
Transition,
|
|
62
92
|
{
|
|
63
|
-
|
|
64
|
-
onBeforeEnter: (
|
|
93
|
+
css: false,
|
|
94
|
+
onBeforeEnter: () => handleBeforeEnter(),
|
|
65
95
|
onEnter: (el, done) => handleEnter(el, done),
|
|
66
96
|
onAfterEnter: (el) => handleAfterEnter(el),
|
|
67
97
|
onBeforeLeave: (el) => handleBeforeLeave(el),
|
|
@@ -74,15 +104,13 @@ const CCollapse = defineComponent({
|
|
|
74
104
|
'div',
|
|
75
105
|
{
|
|
76
106
|
class: [
|
|
77
|
-
'collapse',
|
|
78
|
-
{
|
|
79
|
-
show: props.visible,
|
|
80
|
-
},
|
|
107
|
+
collapsing.value ? 'collapsing' : 'collapse',
|
|
108
|
+
{ 'collapse-horizontal': props.horizontal, show: show.value },
|
|
81
109
|
],
|
|
82
110
|
},
|
|
83
111
|
slots.default && slots.default(),
|
|
84
112
|
),
|
|
85
|
-
[[
|
|
113
|
+
[[vVisible, props.visible]],
|
|
86
114
|
),
|
|
87
115
|
)
|
|
88
116
|
},
|
|
@@ -85,11 +85,11 @@ const CFormInput = defineComponent({
|
|
|
85
85
|
'update:modelValue',
|
|
86
86
|
],
|
|
87
87
|
setup(props, { emit, slots }) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const handleChange = (event: InputEvent) => {
|
|
89
|
+
const target = event.target as HTMLInputElement
|
|
90
|
+
emit('change', event)
|
|
91
|
+
emit('update:modelValue', target.value)
|
|
92
|
+
}
|
|
93
93
|
const handleInput = (event: InputEvent) => {
|
|
94
94
|
const target = event.target as HTMLInputElement
|
|
95
95
|
emit('input', event)
|
|
@@ -110,7 +110,7 @@ const CFormInput = defineComponent({
|
|
|
110
110
|
},
|
|
111
111
|
],
|
|
112
112
|
disabled: props.disabled,
|
|
113
|
-
|
|
113
|
+
onChange: (event: InputEvent) => handleChange(event),
|
|
114
114
|
onInput: (event: InputEvent) => handleInput(event),
|
|
115
115
|
readonly: props.readonly,
|
|
116
116
|
type: props.type,
|
|
@@ -84,7 +84,7 @@ const CCol = defineComponent({
|
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
setup(props, { slots }) {
|
|
87
|
-
const
|
|
87
|
+
const repsonsiveClassNames: string[] = []
|
|
88
88
|
|
|
89
89
|
BREAKPOINTS.forEach((bp) => {
|
|
90
90
|
const breakpoint = props[bp]
|
|
@@ -93,29 +93,29 @@ const CCol = defineComponent({
|
|
|
93
93
|
|
|
94
94
|
if (breakpoint) {
|
|
95
95
|
if (typeof breakpoint === 'number' || typeof breakpoint === 'string') {
|
|
96
|
-
|
|
96
|
+
repsonsiveClassNames.push(`col${infix}-${breakpoint}`)
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if (typeof breakpoint === 'boolean') {
|
|
100
|
-
|
|
100
|
+
repsonsiveClassNames.push(`col${infix}`)
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (breakpoint && typeof breakpoint === 'object') {
|
|
105
105
|
if (typeof breakpoint.span === 'number' || typeof breakpoint.span === 'string') {
|
|
106
|
-
|
|
106
|
+
repsonsiveClassNames.push(`col${infix}-${breakpoint.span}`)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
if (typeof breakpoint.span === 'boolean') {
|
|
110
|
-
|
|
110
|
+
repsonsiveClassNames.push(`col${infix}`)
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
if (typeof breakpoint.order === 'number' || typeof breakpoint.order === 'string') {
|
|
114
|
-
|
|
114
|
+
repsonsiveClassNames.push(`order${infix}-${breakpoint.order}`)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
if (typeof breakpoint.offset === 'number') {
|
|
118
|
-
|
|
118
|
+
repsonsiveClassNames.push(`offset${infix}-${breakpoint.offset}`)
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
})
|
|
@@ -124,7 +124,7 @@ const CCol = defineComponent({
|
|
|
124
124
|
h(
|
|
125
125
|
'div',
|
|
126
126
|
{
|
|
127
|
-
class: [
|
|
127
|
+
class: [repsonsiveClassNames.length ? repsonsiveClassNames : 'col'],
|
|
128
128
|
},
|
|
129
129
|
slots.default && slots.default(),
|
|
130
130
|
)
|
|
@@ -56,18 +56,18 @@ const CContainer = defineComponent({
|
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
setup(props, { slots }) {
|
|
59
|
-
const
|
|
59
|
+
const repsonsiveClassNames: string[] = []
|
|
60
60
|
|
|
61
61
|
BREAKPOINTS.forEach((bp) => {
|
|
62
62
|
const breakpoint = props[bp]
|
|
63
63
|
|
|
64
|
-
breakpoint &&
|
|
64
|
+
breakpoint && repsonsiveClassNames.push(`container-${bp}`)
|
|
65
65
|
})
|
|
66
66
|
return () =>
|
|
67
67
|
h(
|
|
68
68
|
'div',
|
|
69
69
|
{
|
|
70
|
-
class: [
|
|
70
|
+
class: [repsonsiveClassNames.length ? repsonsiveClassNames : 'container'],
|
|
71
71
|
},
|
|
72
72
|
slots.default && slots.default(),
|
|
73
73
|
)
|
|
@@ -81,7 +81,7 @@ const CRow = defineComponent({
|
|
|
81
81
|
},
|
|
82
82
|
},
|
|
83
83
|
setup(props, { slots }) {
|
|
84
|
-
const
|
|
84
|
+
const repsonsiveClassNames: string[] = []
|
|
85
85
|
|
|
86
86
|
BREAKPOINTS.forEach((bp) => {
|
|
87
87
|
const breakpoint = props[bp]
|
|
@@ -89,16 +89,16 @@ const CRow = defineComponent({
|
|
|
89
89
|
|
|
90
90
|
if (typeof breakpoint === 'object') {
|
|
91
91
|
if (breakpoint.cols) {
|
|
92
|
-
|
|
92
|
+
repsonsiveClassNames.push(`row-cols${infix}-${breakpoint.cols}`)
|
|
93
93
|
}
|
|
94
94
|
if (typeof breakpoint.gutter === 'number') {
|
|
95
|
-
|
|
95
|
+
repsonsiveClassNames.push(`g${infix}-${breakpoint.gutter}`)
|
|
96
96
|
}
|
|
97
97
|
if (typeof breakpoint.gutterX === 'number') {
|
|
98
|
-
|
|
98
|
+
repsonsiveClassNames.push(`gx${infix}-${breakpoint.gutterX}`)
|
|
99
99
|
}
|
|
100
100
|
if (typeof breakpoint.gutterY === 'number') {
|
|
101
|
-
|
|
101
|
+
repsonsiveClassNames.push(`gy${infix}-${breakpoint.gutterY}`)
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
})
|
|
@@ -107,7 +107,7 @@ const CRow = defineComponent({
|
|
|
107
107
|
h(
|
|
108
108
|
'div',
|
|
109
109
|
{
|
|
110
|
-
class: ['row',
|
|
110
|
+
class: ['row', repsonsiveClassNames],
|
|
111
111
|
},
|
|
112
112
|
slots.default && slots.default(),
|
|
113
113
|
)
|
package/src/components/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './carousel'
|
|
|
12
12
|
export * from './close-button'
|
|
13
13
|
export * from './collapse'
|
|
14
14
|
export * from './dropdown'
|
|
15
|
+
export * from './element-cover'
|
|
15
16
|
export * from './footer'
|
|
16
17
|
export * from './form'
|
|
17
18
|
export * from './grid'
|
|
@@ -26,6 +27,7 @@ export * from './nav'
|
|
|
26
27
|
export * from './navbar'
|
|
27
28
|
export * from './offcanvas'
|
|
28
29
|
export * from './pagination'
|
|
30
|
+
export * from './placeholder'
|
|
29
31
|
export * from './progress'
|
|
30
32
|
export * from './popover'
|
|
31
33
|
export * from './sidebar'
|
|
@@ -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',
|
|
@@ -139,25 +140,27 @@ const COffcanvas = defineComponent({
|
|
|
139
140
|
onAfterLeave: (el) => handleAfterLeave(el),
|
|
140
141
|
},
|
|
141
142
|
() =>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
143
|
+
withDirectives(
|
|
144
|
+
h(
|
|
145
|
+
'div',
|
|
146
|
+
{
|
|
147
|
+
class: [
|
|
148
|
+
'offcanvas',
|
|
149
|
+
{
|
|
150
|
+
[`offcanvas-${props.placement}`]: props.placement,
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
ref: offcanvasRef,
|
|
154
|
+
role: 'dialog',
|
|
155
|
+
},
|
|
156
|
+
slots.default && slots.default(),
|
|
157
|
+
),
|
|
158
|
+
[[vVisible, props.visible]],
|
|
156
159
|
),
|
|
157
160
|
),
|
|
158
161
|
props.backdrop &&
|
|
159
162
|
h(CBackdrop, {
|
|
160
|
-
class: '
|
|
163
|
+
class: 'offcanvas-backdrop',
|
|
161
164
|
visible: visible.value,
|
|
162
165
|
}),
|
|
163
166
|
]
|
|
@@ -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
|
+
`;
|
package/src/directives/index.ts
CHANGED