@coreui/vue-pro 4.0.1 → 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.
Files changed (68) hide show
  1. package/README.md +1 -1
  2. package/dist/components/carousel/CCarousel.d.ts +2 -2
  3. package/dist/components/collapse/CCollapse.d.ts +10 -0
  4. package/dist/components/element-cover/index.d.ts +6 -0
  5. package/dist/components/form/CFormCheck.d.ts +22 -2
  6. package/dist/components/form/CFormInput.d.ts +17 -2
  7. package/dist/components/form/CFormRange.d.ts +15 -2
  8. package/dist/components/form/CFormSelect.d.ts +36 -2
  9. package/dist/components/form/CFormSwitch.d.ts +15 -2
  10. package/dist/components/form/CFormTextarea.d.ts +18 -2
  11. package/dist/components/index.d.ts +2 -0
  12. package/dist/components/modal/CModal.d.ts +2 -2
  13. package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
  14. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +2 -2
  15. package/dist/components/placeholder/CPlaceholder.d.ts +124 -0
  16. package/dist/components/placeholder/index.d.ts +6 -0
  17. package/dist/components/popover/CPopover.d.ts +2 -2
  18. package/dist/components/smart-table/CSmartTable.d.ts +0 -3
  19. package/dist/components/table/CTable.d.ts +2 -2
  20. package/dist/components/widgets/CWidgetStatsB.d.ts +2 -2
  21. package/dist/components/widgets/CWidgetStatsF.d.ts +2 -2
  22. package/dist/directives/index.d.ts +3 -2
  23. package/dist/directives/v-c-placeholder.d.ts +6 -0
  24. package/dist/directives/v-c-visible.d.ts +6 -0
  25. package/dist/index.es.js +902 -445
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/index.js +905 -443
  28. package/dist/index.js.map +1 -1
  29. package/package.json +10 -9
  30. package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.ts.snap +1 -1
  31. package/src/components/button/CButton.ts +2 -2
  32. package/src/components/card/CCardImage.ts +2 -3
  33. package/src/components/collapse/CCollapse.ts +49 -21
  34. package/src/components/collapse/__test__/__snapshots__/CCollapse.spec.ts.snap +1 -1
  35. package/src/components/element-cover/index.ts +10 -0
  36. package/src/components/form/CFormCheck.ts +34 -2
  37. package/src/components/form/CFormInput.ts +40 -5
  38. package/src/components/form/CFormLabel.ts +1 -2
  39. package/src/components/form/CFormRange.ts +32 -3
  40. package/src/components/form/CFormSelect.ts +63 -4
  41. package/src/components/form/CFormSwitch.ts +46 -4
  42. package/src/components/form/CFormTextarea.ts +31 -2
  43. package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +2 -2
  44. package/src/components/form/__tests__/__snapshots__/CFormInput.spec.ts.snap +3 -3
  45. package/src/components/form/__tests__/__snapshots__/CFormRange.spec.ts.snap +1 -1
  46. package/src/components/form/__tests__/__snapshots__/CFormSwitch.spec.ts.snap +2 -2
  47. package/src/components/form/__tests__/__snapshots__/CFormTextarea.spec.ts.snap +1 -1
  48. package/src/components/grid/CCol.ts +8 -8
  49. package/src/components/grid/CContainer.ts +3 -3
  50. package/src/components/grid/CRow.ts +6 -6
  51. package/src/components/index.ts +2 -0
  52. package/src/components/offcanvas/COffcanvas.ts +19 -16
  53. package/src/components/offcanvas/__tests__/COffcanvas.spec.ts +1 -1
  54. package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.ts.snap +2 -2
  55. package/src/components/pagination/CSmartPagination.ts +1 -1
  56. package/src/components/placeholder/CPlaceholder.ts +139 -0
  57. package/src/components/placeholder/__tests__/CPlaceholder.spec.ts +44 -0
  58. package/src/components/placeholder/__tests__/__snapshots__/CPlaceholder.spec.ts.snap +15 -0
  59. package/src/components/placeholder/index.ts +10 -0
  60. package/src/components/smart-table/CSmartTable.ts +56 -41
  61. package/src/components/smart-table/CSmartTableHead.ts +43 -42
  62. package/src/components/toast/CToastClose.ts +2 -2
  63. package/src/components/toast/__tests__/CToastClose.spec.ts +2 -2
  64. package/src/components/toast/__tests__/__snapshots__/CToastClose.spec.ts.snap +1 -1
  65. package/src/directives/index.ts +3 -2
  66. package/src/directives/v-c-placeholder.ts +32 -0
  67. package/src/directives/v-c-visible.ts +33 -0
  68. package/src/index.ts +2 -1
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize with label - CFormCheck component renders correctly 1`] = `"<input class=\\"btn-check is-invalid is-valid\\" id=\\"uniqueid\\" type=\\"checkbox\\"><label for=\\"uniqueid\\" class=\\"btn btn-outline-warning btn-lg rounded-circle\\">some label</label>"`;
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>"`;
4
4
 
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 for=\\"uniqueid\\" class=\\"btn btn-outline-warning btn-lg rounded-circle\\">some label</label>"`;
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>"`;
6
6
 
7
7
  exports[`Loads and display CFormCheck component renders correctly 1`] = `"<input class=\\"form-check-input\\" type=\\"checkbox\\">"`;
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize (two) CFormInput component renders correctly 1`] = `"<input type=\\"color\\" class=\\"form-control form-control-color form-control-lg is-invalid is-valid\\">"`;
3
+ exports[`Customize (two) CFormInput component renders correctly 1`] = `"<input class=\\"form-control form-control-color form-control-lg is-invalid is-valid\\" disabled=\\"\\" readonly=\\"\\" type=\\"color\\">"`;
4
4
 
5
- exports[`Customize CFormInput component renders correctly 1`] = `"<input type=\\"color\\" class=\\"form-control-plaintext form-control-color form-control-lg is-invalid is-valid\\">"`;
5
+ exports[`Customize CFormInput component renders correctly 1`] = `"<input class=\\"form-control-plaintext form-control-color form-control-lg is-invalid is-valid\\" disabled=\\"\\" readonly=\\"\\" type=\\"color\\">"`;
6
6
 
7
- exports[`Loads and display CFormInput component renders correctly 1`] = `"<input type=\\"text\\" class=\\"form-control\\">"`;
7
+ exports[`Loads and display CFormInput component renders correctly 1`] = `"<input class=\\"form-control\\" type=\\"text\\">"`;
@@ -1,5 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize CFormRange component renders correctly 1`] = `"<input class=\\"form-range\\" type=\\"range\\" disabled=\\"\\" max=\\"400\\" min=\\"50\\" readonly=\\"\\" steps=\\"10\\">"`;
3
+ exports[`Customize CFormRange component renders correctly 1`] = `"<input class=\\"form-range\\" disabled=\\"\\" max=\\"400\\" min=\\"50\\" steps=\\"10\\" readonly=\\"\\" type=\\"range\\">"`;
4
4
 
5
5
  exports[`Loads and display CFormRange component renders correctly 1`] = `"<input class=\\"form-range\\" type=\\"range\\">"`;
@@ -1,9 +1,9 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize CFormSwitch component renders correctly 1`] = `"<div class=\\"form-check form-switch form-switch-lg is-invalid is-valid\\"><input id=\\"uniqueid\\" type=\\"radio\\" class=\\"form-check-input is-invalid is-valid\\"><label for=\\"uniqueid\\" class=\\"form-label form-check-label\\">some label</label></div>"`;
3
+ exports[`Customize CFormSwitch component renders correctly 1`] = `"<div class=\\"form-check form-switch form-switch-lg is-invalid is-valid\\"><input class=\\"form-check-input is-invalid is-valid\\" id=\\"uniqueid\\" type=\\"radio\\"><label class=\\"form-label form-check-label\\" for=\\"uniqueid\\">some label</label></div>"`;
4
4
 
5
5
  exports[`Loads and display CFormSwitch component renders correctly 1`] = `
6
- "<div class=\\"form-check form-switch\\"><input type=\\"checkbox\\" class=\\"form-check-input\\">
6
+ "<div class=\\"form-check form-switch\\"><input class=\\"form-check-input\\" type=\\"checkbox\\">
7
7
  <!---->
8
8
  </div>"
9
9
  `;
@@ -1,5 +1,5 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Customize CFormTextarea component renders correctly 1`] = `"<textarea class=\\"form-control-plaintext is-invalid is-valid\\">Default slot</textarea>"`;
3
+ exports[`Customize CFormTextarea component renders correctly 1`] = `"<textarea disabled=\\"\\" readonly=\\"\\" class=\\"form-control-plaintext is-invalid is-valid\\">Default slot</textarea>"`;
4
4
 
5
5
  exports[`Loads and display CFormTextarea component renders correctly 1`] = `"<textarea class=\\"form-control\\">Default slot</textarea>"`;
@@ -84,7 +84,7 @@ const CCol = defineComponent({
84
84
  },
85
85
  },
86
86
  setup(props, { slots }) {
87
- const repsonsiveCLassNames: string[] = []
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
- repsonsiveCLassNames.push(`col${infix}-${breakpoint}`)
96
+ repsonsiveClassNames.push(`col${infix}-${breakpoint}`)
97
97
  }
98
98
 
99
99
  if (typeof breakpoint === 'boolean') {
100
- repsonsiveCLassNames.push(`col${infix}`)
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
- repsonsiveCLassNames.push(`col${infix}-${breakpoint.span}`)
106
+ repsonsiveClassNames.push(`col${infix}-${breakpoint.span}`)
107
107
  }
108
108
 
109
109
  if (typeof breakpoint.span === 'boolean') {
110
- repsonsiveCLassNames.push(`col${infix}`)
110
+ repsonsiveClassNames.push(`col${infix}`)
111
111
  }
112
112
 
113
113
  if (typeof breakpoint.order === 'number' || typeof breakpoint.order === 'string') {
114
- repsonsiveCLassNames.push(`order${infix}-${breakpoint.order}`)
114
+ repsonsiveClassNames.push(`order${infix}-${breakpoint.order}`)
115
115
  }
116
116
 
117
117
  if (typeof breakpoint.offset === 'number') {
118
- repsonsiveCLassNames.push(`offset${infix}-${breakpoint.offset}`)
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: [repsonsiveCLassNames.length ? repsonsiveCLassNames : 'col'],
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 repsonsiveCLassNames: string[] = []
59
+ const repsonsiveClassNames: string[] = []
60
60
 
61
61
  BREAKPOINTS.forEach((bp) => {
62
62
  const breakpoint = props[bp]
63
63
 
64
- breakpoint && repsonsiveCLassNames.push(`container-${bp}`)
64
+ breakpoint && repsonsiveClassNames.push(`container-${bp}`)
65
65
  })
66
66
  return () =>
67
67
  h(
68
68
  'div',
69
69
  {
70
- class: [repsonsiveCLassNames.length ? repsonsiveCLassNames : 'container'],
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 repsonsiveCLassNames: string[] = []
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
- repsonsiveCLassNames.push(`row-cols${infix}-${breakpoint.cols}`)
92
+ repsonsiveClassNames.push(`row-cols${infix}-${breakpoint.cols}`)
93
93
  }
94
94
  if (typeof breakpoint.gutter === 'number') {
95
- repsonsiveCLassNames.push(`g${infix}-${breakpoint.gutter}`)
95
+ repsonsiveClassNames.push(`g${infix}-${breakpoint.gutter}`)
96
96
  }
97
97
  if (typeof breakpoint.gutterX === 'number') {
98
- repsonsiveCLassNames.push(`gx${infix}-${breakpoint.gutterX}`)
98
+ repsonsiveClassNames.push(`gx${infix}-${breakpoint.gutterX}`)
99
99
  }
100
100
  if (typeof breakpoint.gutterY === 'number') {
101
- repsonsiveCLassNames.push(`gy${infix}-${breakpoint.gutterY}`)
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', repsonsiveCLassNames],
110
+ class: ['row', repsonsiveClassNames],
111
111
  },
112
112
  slots.default && slots.default(),
113
113
  )
@@ -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
- visible.value &&
143
- h(
144
- 'div',
145
- {
146
- class: [
147
- 'offcanvas',
148
- {
149
- [`offcanvas-${props.placement}`]: props.placement,
150
- },
151
- ],
152
- ref: offcanvasRef,
153
- role: 'dialog',
154
- },
155
- slots.default && slots.default(),
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: 'modal-backdrop',
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('.modal-backdrop').classes('modal-backdrop')).toBe(true)
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=\\"modal-backdrop\\">
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=\\"modal-backdrop\\">
16
+ <transition-stub class=\\"offcanvas-backdrop\\">
17
17
  <div class=\\"fade\\"></div>
18
18
  </transition-stub>"
19
19
  `;
@@ -214,7 +214,7 @@ const CSmartPagination = defineComponent({
214
214
  h(
215
215
  CPagination,
216
216
  {
217
- class: [`justify-content-${props.align}`],
217
+ align: props.align,
218
218
  'aria-label': 'pagination',
219
219
  size: props.size,
220
220
  },
@@ -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
+ `;
@@ -0,0 +1,10 @@
1
+ import { App } from 'vue'
2
+ import { CPlaceholder } from './CPlaceholder'
3
+
4
+ const CPlaceholderPlugin = {
5
+ install: (app: App): void => {
6
+ app.component(CPlaceholder.name, CPlaceholder)
7
+ },
8
+ }
9
+
10
+ export { CPlaceholderPlugin, CPlaceholder }
@@ -1,4 +1,4 @@
1
- import { computed, defineComponent, h, reactive, ref, PropType, watch } from 'vue'
1
+ import { computed, defineComponent, h, reactive, ref, PropType, watch, onMounted } from 'vue'
2
2
 
3
3
  import { CSmartPagination } from '../pagination/CSmartPagination'
4
4
  import { CElementCover } from '../element-cover/CElementCover'
@@ -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
  /**
@@ -257,7 +256,6 @@ const CSmartTable = defineComponent({
257
256
  */
258
257
  tableFilter: {
259
258
  type: [Boolean, Object] as PropType<boolean | TableFilter>,
260
- default: undefined,
261
259
  required: false,
262
260
  },
263
261
  /**
@@ -370,18 +368,26 @@ const CSmartTable = defineComponent({
370
368
  }),
371
369
  )
372
370
 
373
- watch(props.items, () => {
374
- items.value = props.items.map((item: Item, index: number) => {
375
- return { ...item, _id: index }
376
- })
377
- console.log(props.items)
378
- })
371
+ watch(
372
+ () => props.items,
373
+ () => {
374
+ items.value = props.items.map((item: Item, index: number) => {
375
+ return { ...item, _id: index }
376
+ })
377
+ if (
378
+ items.value &&
379
+ items.value.length < itemsPerPage.value * activePage.value - itemsPerPage.value
380
+ ) {
381
+ activePage.value = 1
382
+ }
383
+ },
384
+ )
379
385
 
380
386
  const selectedAll = ref()
381
387
 
382
388
  watch(items, () => {
383
- console.log(items.value)
384
389
  const selected = items.value.filter((item) => item._selected === true)
390
+ emit('selectedItemsChange', selected)
385
391
 
386
392
  if (selected.length === items.value.length) {
387
393
  selectedAll.value = true
@@ -396,8 +402,6 @@ const CSmartTable = defineComponent({
396
402
  if (selected.length !== 0 && selected.length !== items.value.length) {
397
403
  selectedAll.value = 'indeterminate'
398
404
  }
399
-
400
- emit('selectedItemsChange', selected)
401
405
  })
402
406
 
403
407
  const itemsPerPage = ref<number>(props.itemsPerPage)
@@ -407,6 +411,15 @@ const CSmartTable = defineComponent({
407
411
  const columnFilterState = ref(props.columnFilterValue ? props.columnFilterValue : {})
408
412
  const tableFilterState = ref(props.tableFilterValue ? props.tableFilterValue : '')
409
413
 
414
+ onMounted(() => {
415
+ if (
416
+ items.value &&
417
+ items.value.length < itemsPerPage.value * activePage.value - itemsPerPage.value
418
+ ) {
419
+ activePage.value = 1
420
+ }
421
+ })
422
+
410
423
  // functions
411
424
 
412
425
  const isSortable = (i: number): boolean | undefined => {
@@ -436,7 +449,11 @@ const CSmartTable = defineComponent({
436
449
  } else if (state.state === 'asc') {
437
450
  state.state = 'desc'
438
451
  } else {
439
- state.state = 0
452
+ if (typeof props.columnSorter === 'object' && !props.columnSorter.resetable) {
453
+ state.state = 'asc'
454
+ } else {
455
+ state.state = 0
456
+ }
440
457
  }
441
458
  } else {
442
459
  state.column = column
@@ -450,7 +467,6 @@ const CSmartTable = defineComponent({
450
467
 
451
468
  const handleActivePageChange = (page: number) => {
452
469
  activePage.value = page
453
- // currentItems.value = updatePage(sortedItems)
454
470
  emit('activePageChange', page)
455
471
  }
456
472
 
@@ -626,14 +642,14 @@ const CSmartTable = defineComponent({
626
642
 
627
643
  return () =>
628
644
  h('div', {}, [
629
- h(
630
- 'div',
631
- {
632
- class: 'row my-2 mx-0',
633
- },
634
- {
635
- default: () =>
636
- (props.tableFilter || props.cleaner) && [
645
+ (props.tableFilter || props.cleaner) &&
646
+ h(
647
+ 'div',
648
+ {
649
+ class: 'row my-2 mx-0',
650
+ },
651
+ [
652
+ props.tableFilter &&
637
653
  h(
638
654
  'div',
639
655
  {
@@ -646,30 +662,29 @@ const CSmartTable = defineComponent({
646
662
  value: tableFilterState.value,
647
663
  }),
648
664
  ),
665
+ props.cleaner &&
649
666
  h(
650
667
  'div',
651
668
  {
652
669
  class: 'col-auto p-0',
653
670
  },
654
- props.cleaner &&
655
- h(
656
- CSmartTableCleaner,
657
- {
658
- onClick: () => clean(),
659
- isFiltered: isFiltered.value,
660
- },
661
- {
662
- // @slot Cleaner icon.
663
- cleanerIcon: () =>
664
- slots.cleanerIcon
665
- ? slots.cleanerIcon()
666
- : h(CIcon, { width: '18', content: cilFilterX }),
667
- },
668
- ),
671
+ h(
672
+ CSmartTableCleaner,
673
+ {
674
+ onClick: () => clean(),
675
+ isFiltered: isFiltered.value,
676
+ },
677
+ {
678
+ // @slot Cleaner icon.
679
+ cleanerIcon: () =>
680
+ slots.cleanerIcon
681
+ ? slots.cleanerIcon()
682
+ : h(CIcon, { width: '18', content: cilFilterX }),
683
+ },
684
+ ),
669
685
  ),
670
- ],
671
- },
672
- ), //h
686
+ ],
687
+ ), //h
673
688
  h(
674
689
  'div',
675
690
  {
@@ -797,7 +812,7 @@ const CSmartTable = defineComponent({
797
812
  h(
798
813
  'div',
799
814
  {
800
- class: 'col-auto',
815
+ class: 'col',
801
816
  },
802
817
  props.pagination && numberOfPages.value > 1
803
818
  ? h(CSmartPagination, {