@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.
Files changed (173) hide show
  1. package/README.md +1 -1
  2. package/dist/components/accordion/CAccordion.d.ts +18 -10
  3. package/dist/components/accordion/CAccordionBody.d.ts +1 -1
  4. package/dist/components/accordion/CAccordionButton.d.ts +1 -1
  5. package/dist/components/accordion/CAccordionCollapse.d.ts +9 -5
  6. package/dist/components/accordion/CAccordionHeader.d.ts +1 -1
  7. package/dist/components/accordion/CAccordionItem.d.ts +10 -5
  8. package/dist/components/alert/CAlert.d.ts +38 -12
  9. package/dist/components/alert/CAlertHeading.d.ts +10 -5
  10. package/dist/components/alert/CAlertLink.d.ts +1 -1
  11. package/dist/components/avatar/CAvatar.d.ts +59 -15
  12. package/dist/components/backdrop/CBackdrop.d.ts +10 -5
  13. package/dist/components/badge/CBadge.d.ts +59 -16
  14. package/dist/components/breadcrumb/CBreadcrumb.d.ts +1 -1
  15. package/dist/components/breadcrumb/CBreadcrumbItem.d.ts +17 -8
  16. package/dist/components/button/CButton.d.ts +73 -20
  17. package/dist/components/button-group/CButtonGroup.d.ts +20 -8
  18. package/dist/components/button-group/CButtonToolbar.d.ts +1 -1
  19. package/dist/components/callout/CCallout.d.ts +11 -5
  20. package/dist/components/card/CCard.d.ts +20 -7
  21. package/dist/components/card/CCardBody.d.ts +1 -1
  22. package/dist/components/card/CCardFooter.d.ts +1 -1
  23. package/dist/components/card/CCardGroup.d.ts +1 -1
  24. package/dist/components/card/CCardHeader.d.ts +10 -5
  25. package/dist/components/card/CCardImage.d.ts +21 -8
  26. package/dist/components/card/CCardImageOverlay.d.ts +1 -1
  27. package/dist/components/card/CCardLink.d.ts +10 -5
  28. package/dist/components/card/CCardSubtitle.d.ts +10 -5
  29. package/dist/components/card/CCardText.d.ts +10 -5
  30. package/dist/components/card/CCardTitle.d.ts +10 -5
  31. package/dist/components/carousel/CCarousel.d.ts +58 -19
  32. package/dist/components/carousel/CCarouselCaption.d.ts +1 -1
  33. package/dist/components/carousel/CCarouselItem.d.ts +25 -9
  34. package/dist/components/close-button/CCloseButton.d.ts +16 -7
  35. package/dist/components/collapse/CCollapse.d.ts +24 -5
  36. package/dist/components/dropdown/CDropdown.d.ts +82 -22
  37. package/dist/components/dropdown/CDropdownDivider.d.ts +1 -1
  38. package/dist/components/dropdown/CDropdownHeader.d.ts +10 -5
  39. package/dist/components/dropdown/CDropdownItem.d.ts +32 -12
  40. package/dist/components/dropdown/CDropdownMenu.d.ts +12 -5
  41. package/dist/components/dropdown/CDropdownToggle.d.ts +78 -22
  42. package/dist/components/element-cover/CElementCover.d.ts +22 -7
  43. package/dist/components/element-cover/index.d.ts +6 -0
  44. package/dist/components/footer/CFooter.d.ts +13 -5
  45. package/dist/components/form/CForm.d.ts +9 -5
  46. package/dist/components/form/CFormCheck.d.ts +66 -23
  47. package/dist/components/form/CFormControl.d.ts +61 -20
  48. package/dist/components/form/CFormFeedback.d.ts +22 -11
  49. package/dist/components/form/CFormFloating.d.ts +1 -1
  50. package/dist/components/form/CFormInput.d.ts +66 -20
  51. package/dist/components/form/CFormLabel.d.ts +10 -5
  52. package/dist/components/form/CFormRange.d.ts +59 -18
  53. package/dist/components/form/CFormSelect.d.ts +66 -18
  54. package/dist/components/form/CFormSwitch.d.ts +61 -18
  55. package/dist/components/form/CFormText.d.ts +10 -5
  56. package/dist/components/form/CFormTextarea.d.ts +45 -16
  57. package/dist/components/form/CInputGroup.d.ts +13 -5
  58. package/dist/components/form/CInputGroupText.d.ts +10 -5
  59. package/dist/components/grid/CCol.d.ts +62 -15
  60. package/dist/components/grid/CContainer.d.ts +44 -15
  61. package/dist/components/grid/CRow.d.ts +57 -15
  62. package/dist/components/header/CHeader.d.ts +24 -7
  63. package/dist/components/header/CHeaderBrand.d.ts +10 -5
  64. package/dist/components/header/CHeaderDivider.d.ts +1 -1
  65. package/dist/components/header/CHeaderNav.d.ts +10 -5
  66. package/dist/components/header/CHeaderText.d.ts +1 -1
  67. package/dist/components/header/CHeaderToggler.d.ts +1 -1
  68. package/dist/components/image/CImage.d.ts +34 -12
  69. package/dist/components/index.d.ts +2 -0
  70. package/dist/components/link/CLink.d.ts +32 -12
  71. package/dist/components/list-group/CListGroup.d.ts +28 -10
  72. package/dist/components/list-group/CListGroupItem.d.ts +33 -12
  73. package/dist/components/modal/CModal.d.ts +97 -23
  74. package/dist/components/modal/CModalBody.d.ts +1 -1
  75. package/dist/components/modal/CModalFooter.d.ts +1 -1
  76. package/dist/components/modal/CModalHeader.d.ts +10 -5
  77. package/dist/components/modal/CModalTitle.d.ts +10 -5
  78. package/dist/components/multi-select/CMultiSelect.d.ts +131 -30
  79. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +26 -11
  80. package/dist/components/multi-select/CMultiSelectOptions.d.ts +40 -11
  81. package/dist/components/multi-select/CMultiSelectSelection.d.ts +47 -13
  82. package/dist/components/nav/CNav.d.ts +32 -10
  83. package/dist/components/nav/CNavGroup.d.ts +10 -7
  84. package/dist/components/nav/CNavGroupItems.d.ts +1 -1
  85. package/dist/components/nav/CNavLink.d.ts +32 -12
  86. package/dist/components/nav/CNavTitle.d.ts +1 -1
  87. package/dist/components/navbar/CNavbar.d.ts +63 -16
  88. package/dist/components/navbar/CNavbarBrand.d.ts +19 -8
  89. package/dist/components/navbar/CNavbarNav.d.ts +10 -5
  90. package/dist/components/navbar/CNavbarText.d.ts +1 -1
  91. package/dist/components/navbar/CNavbarToggler.d.ts +1 -1
  92. package/dist/components/offcanvas/COffcanvas.d.ts +44 -14
  93. package/dist/components/offcanvas/COffcanvasBody.d.ts +1 -1
  94. package/dist/components/offcanvas/COffcanvasHeader.d.ts +1 -1
  95. package/dist/components/offcanvas/COffcanvasTitle.d.ts +10 -5
  96. package/dist/components/pagination/CPagination.d.ts +24 -7
  97. package/dist/components/pagination/CPaginationItem.d.ts +32 -12
  98. package/dist/components/pagination/CSmartPagination.d.ts +120 -28
  99. package/dist/components/placeholder/CPlaceholder.d.ts +189 -0
  100. package/dist/components/placeholder/index.d.ts +6 -0
  101. package/dist/components/popover/CPopover.d.ts +51 -17
  102. package/dist/components/progress/CProgressBar.d.ts +37 -12
  103. package/dist/components/sidebar/CSidebar.d.ts +59 -20
  104. package/dist/components/sidebar/CSidebarBrand.d.ts +1 -1
  105. package/dist/components/sidebar/CSidebarFooter.d.ts +1 -1
  106. package/dist/components/sidebar/CSidebarHeader.d.ts +1 -1
  107. package/dist/components/sidebar/CSidebarNav.d.ts +1 -1
  108. package/dist/components/sidebar/CSidebarToggler.d.ts +1 -1
  109. package/dist/components/smart-table/CSmartTable.d.ts +280 -68
  110. package/dist/components/smart-table/CSmartTableBody.d.ts +37 -20
  111. package/dist/components/smart-table/CSmartTableCleaner.d.ts +7 -5
  112. package/dist/components/smart-table/CSmartTableFilter.d.ts +17 -9
  113. package/dist/components/smart-table/CSmartTableHead.d.ts +42 -23
  114. package/dist/components/smart-table/CSmartTableItemsPerPageSelector.d.ts +17 -10
  115. package/dist/components/spinner/CSpinner.d.ts +51 -14
  116. package/dist/components/table/CTable.d.ts +89 -25
  117. package/dist/components/table/CTableBody.d.ts +11 -5
  118. package/dist/components/table/CTableCaption.d.ts +2 -4
  119. package/dist/components/table/CTableDataCell.d.ts +29 -10
  120. package/dist/components/table/CTableFoot.d.ts +11 -5
  121. package/dist/components/table/CTableHead.d.ts +11 -5
  122. package/dist/components/table/CTableHeaderCell.d.ts +11 -5
  123. package/dist/components/table/CTableRow.d.ts +29 -10
  124. package/dist/components/tabs/CTabContent.d.ts +1 -1
  125. package/dist/components/tabs/CTabPane.d.ts +10 -5
  126. package/dist/components/toast/CToast.d.ts +59 -18
  127. package/dist/components/toast/CToastBody.d.ts +1 -1
  128. package/dist/components/toast/CToastHeader.d.ts +9 -5
  129. package/dist/components/toast/CToaster.d.ts +13 -5
  130. package/dist/components/tooltip/CTooltip.d.ts +42 -14
  131. package/dist/components/widgets/CWidgetStatsA.d.ts +23 -10
  132. package/dist/components/widgets/CWidgetStatsB.d.ts +46 -18
  133. package/dist/components/widgets/CWidgetStatsC.d.ts +37 -15
  134. package/dist/components/widgets/CWidgetStatsD.d.ts +19 -8
  135. package/dist/components/widgets/CWidgetStatsE.d.ts +18 -8
  136. package/dist/components/widgets/CWidgetStatsF.d.ts +43 -15
  137. package/dist/directives/index.d.ts +3 -2
  138. package/dist/directives/v-c-placeholder.d.ts +6 -0
  139. package/dist/directives/v-c-visible.d.ts +6 -0
  140. package/dist/index.es.js +724 -425
  141. package/dist/index.es.js.map +1 -1
  142. package/dist/index.js +727 -423
  143. package/dist/index.js.map +1 -1
  144. package/package.json +8 -8
  145. package/src/components/accordion/__tests__/__snapshots__/CAccordionBody.spec.ts.snap +1 -1
  146. package/src/components/button/CButton.ts +1 -0
  147. package/src/components/collapse/CCollapse.ts +49 -21
  148. package/src/components/collapse/__test__/__snapshots__/CCollapse.spec.ts.snap +1 -1
  149. package/src/components/element-cover/index.ts +10 -0
  150. package/src/components/form/CFormInput.ts +6 -6
  151. package/src/components/form/CFormSelect.ts +21 -6
  152. package/src/components/form/__tests__/__snapshots__/CFormCheck.spec.ts.snap +8 -2
  153. package/src/components/form/__tests__/__snapshots__/CFormSelect.spec.ts.snap +1 -1
  154. package/src/components/grid/CCol.ts +8 -8
  155. package/src/components/grid/CContainer.ts +3 -3
  156. package/src/components/grid/CRow.ts +6 -6
  157. package/src/components/index.ts +2 -0
  158. package/src/components/modal/CModal.ts +68 -40
  159. package/src/components/modal/__tests__/__snapshots__/CModal.spec.ts.snap +1 -2
  160. package/src/components/offcanvas/COffcanvas.ts +30 -20
  161. package/src/components/offcanvas/__tests__/COffcanvas.spec.ts +1 -1
  162. package/src/components/offcanvas/__tests__/__snapshots__/COffcanvas.spec.ts.snap +2 -2
  163. package/src/components/placeholder/CPlaceholder.ts +139 -0
  164. package/src/components/placeholder/__tests__/CPlaceholder.spec.ts +44 -0
  165. package/src/components/placeholder/__tests__/__snapshots__/CPlaceholder.spec.ts.snap +15 -0
  166. package/src/components/placeholder/index.ts +10 -0
  167. package/src/components/sidebar/__tests__/__snapshots__/CSidebar.spec.ts.snap +2 -8
  168. package/src/components/smart-table/CSmartTable.ts +26 -20
  169. package/src/components/smart-table/CSmartTableHead.ts +14 -5
  170. package/src/directives/index.ts +3 -2
  171. package/src/directives/v-c-placeholder.ts +32 -0
  172. package/src/directives/v-c-visible.ts +33 -0
  173. 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('click', handleClickOutside)
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
- const handleClickOutside = (event: Event) => {
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
- 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(),
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: 'modal-backdrop',
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('.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
  `;
@@ -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,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 = Object.keys(items.value[0] || {}).filter((el) => el.charAt(0) !== '_')
540
+ const genCols = computed(() =>
541
+ Object.keys(items.value[0] || {}).filter((el) => el.charAt(0) !== '_'),
542
+ )
543
543
 
544
- const rawColumnNames = props.columns
545
- ? props.columns.map((column: Column | string) => {
546
- if (typeof column === 'object') return column.key
547
- else return column
548
- })
549
- : genCols //! || el
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(() => rawColumnNames.filter((name) => genCols.includes(name)))
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: columnFilterState.value,
709
- columns: props.columns,
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: props.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: props.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 { Column, ColumnFilter, Sorter, SorterValue } from './CSmartTableInterface'
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.columnFilter &&
225
- props.columnFilter[key(column)] && {
226
- value: props.columnFilter[key(column)],
233
+ ...(props.columnFilterValue &&
234
+ props.columnFilterValue[key(column)] && {
235
+ value: props.columnFilterValue[key(column)],
227
236
  }),
228
237
  }),
229
238
  },
@@ -1,4 +1,5 @@
1
- import vctooltip from './v-c-tooltip'
1
+ import vcplaceholder from './v-c-placeholder'
2
2
  import vcpopover from './v-c-popover'
3
+ import vctooltip from './v-c-tooltip'
3
4
 
4
- export { vctooltip, vcpopover }
5
+ export { vcplaceholder, vcpopover, vctooltip, }
@@ -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
  },