@coreui/vue-pro 4.7.0 → 4.8.0-next.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 (34) hide show
  1. package/dist/components/calendar/utils.d.ts +23 -0
  2. package/dist/components/modal/CModal.d.ts +4 -20
  3. package/dist/components/offcanvas/COffcanvas.d.ts +35 -18
  4. package/dist/components/smart-table/CSmartTable.d.ts +65 -87
  5. package/dist/components/smart-table/CSmartTableBody.d.ts +16 -40
  6. package/dist/components/smart-table/CSmartTableHead.d.ts +17 -58
  7. package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
  8. package/dist/components/smart-table/types.d.ts +50 -0
  9. package/dist/components/smart-table/utils.d.ts +17 -0
  10. package/dist/components/table/CTable.d.ts +1 -1
  11. package/dist/components/time-picker/types.d.ts +15 -0
  12. package/dist/components/time-picker/utils.d.ts +23 -0
  13. package/dist/index.es.js +752 -793
  14. package/dist/index.es.js.map +1 -1
  15. package/dist/index.js +752 -793
  16. package/dist/index.js.map +1 -1
  17. package/dist/utils/isObjectInArray.d.ts +2 -0
  18. package/package.json +6 -6
  19. package/src/components/calendar/CCalendar.ts +1 -1
  20. package/src/{utils/calendar.ts → components/calendar/utils.ts} +1 -1
  21. package/src/components/date-range-picker/CDateRangePicker.ts +1 -1
  22. package/src/components/element-cover/CElementCover.ts +14 -14
  23. package/src/components/modal/CModal.ts +10 -10
  24. package/src/components/multi-select/CMultiSelect.ts +0 -10
  25. package/src/components/offcanvas/COffcanvas.ts +50 -28
  26. package/src/components/smart-table/CSmartTable.ts +365 -268
  27. package/src/components/smart-table/CSmartTableBody.ts +126 -137
  28. package/src/components/smart-table/CSmartTableHead.ts +53 -138
  29. package/src/components/smart-table/CSmartTableInterface.ts +1 -1
  30. package/src/components/smart-table/types.ts +61 -0
  31. package/src/components/smart-table/utils.ts +212 -0
  32. package/src/components/time-picker/CTimePicker.ts +49 -27
  33. package/src/components/time-picker/types.ts +15 -0
  34. package/src/{utils/time.ts → components/time-picker/utils.ts} +43 -2
@@ -0,0 +1,2 @@
1
+ declare const isObjectInArray: <T>(array: T[], item: T, ignore?: string[]) => boolean;
2
+ export default isObjectInArray;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreui/vue-pro",
3
- "version": "4.7.0",
3
+ "version": "4.8.0-next.0",
4
4
  "description": "UI Components Library for Vue.js",
5
5
  "keywords": [
6
6
  "vue",
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@popperjs/core": "^2.11.6",
38
- "@rollup/plugin-commonjs": "^24.0.0",
38
+ "@rollup/plugin-commonjs": "^24.0.1",
39
39
  "@rollup/plugin-node-resolve": "^15.0.1",
40
40
  "@rollup/plugin-typescript": "^11.0.0",
41
- "@vue/test-utils": "^2.2.7",
41
+ "@vue/test-utils": "^2.2.10",
42
42
  "date-fns": "^2.29.3",
43
- "rollup": "^3.10.0",
43
+ "rollup": "^3.15.0",
44
44
  "rollup-plugin-vue": "^6.0.0",
45
- "typescript": "^4.9.4",
46
- "vue": "^3.2.45",
45
+ "typescript": "^4.9.5",
46
+ "vue": "^3.2.47",
47
47
  "vue-types": "^5.0.2"
48
48
  },
49
49
  "peerDependencies": {
@@ -16,7 +16,7 @@ import {
16
16
  isToday,
17
17
  isStartDate,
18
18
  isEndDate,
19
- } from '../../utils/calendar'
19
+ } from './utils'
20
20
 
21
21
  const CCalendar = defineComponent({
22
22
  name: 'CCalendar',
@@ -4,7 +4,7 @@ export const convertToLocalDate = (d: Date, locale: string, options = {}) =>
4
4
  export const convertToLocalTime = (d: Date, locale: string, options = {}) =>
5
5
  d.toLocaleTimeString(locale, options)
6
6
 
7
- export const createGroupsInArray = (arr: any[], numberOfGroups: number) => {
7
+ export const createGroupsInArray = <T>(arr: T[], numberOfGroups: number): T[][] => {
8
8
  const perGroup = Math.ceil(arr.length / numberOfGroups)
9
9
  return new Array(numberOfGroups)
10
10
  .fill('')
@@ -9,7 +9,7 @@ import { CFormControlWrapper } from './../form/CFormControlWrapper'
9
9
  import { CPicker } from '../picker'
10
10
  import { CTimePicker } from '../time-picker'
11
11
 
12
- import { getLocalDateFromString } from '../../utils/calendar'
12
+ import { getLocalDateFromString } from '../calendar/utils'
13
13
 
14
14
  import { Color } from '../props'
15
15
 
@@ -84,23 +84,23 @@ const CElementCover = defineComponent({
84
84
  style: { ...coverStyles, ...customBoundaries.value },
85
85
  ref: elementCoverRef,
86
86
  },
87
- slots.default
88
- ? slots.default()
89
- : h(
90
- 'div',
91
- {
92
- style: {
93
- position: 'absolute',
94
- top: '50%',
95
- left: '50%',
96
- transform: 'translateX(-50%) translateY(-50%)',
97
- },
98
- },
99
- h(CSpinner, {
87
+ h(
88
+ 'div',
89
+ {
90
+ style: {
91
+ position: 'absolute',
92
+ top: '50%',
93
+ left: '50%',
94
+ transform: 'translateX(-50%) translateY(-50%)',
95
+ },
96
+ },
97
+ slots.default
98
+ ? slots.default()
99
+ : h(CSpinner, {
100
100
  variant: 'grow',
101
101
  color: 'primary',
102
102
  }),
103
- ),
103
+ ),
104
104
  )
105
105
  },
106
106
  })
@@ -25,7 +25,6 @@ const CModal = defineComponent({
25
25
  */
26
26
  alignment: {
27
27
  default: 'top',
28
- required: false,
29
28
  validator: (value: string) => {
30
29
  return ['top', 'center'].includes(value)
31
30
  },
@@ -33,12 +32,20 @@ const CModal = defineComponent({
33
32
  /**
34
33
  * Apply a backdrop on body while offcanvas is open.
35
34
  *
36
- * @values 'static'
35
+ * @values boolean | 'static'
37
36
  */
38
37
  backdrop: {
39
38
  type: [Boolean, String],
40
39
  default: true,
41
- require: false,
40
+ validator: (value: boolean | string) => {
41
+ if (typeof value == 'string') {
42
+ return ['static'].includes(value)
43
+ }
44
+ if (typeof value == 'boolean') {
45
+ return true
46
+ }
47
+ return false
48
+ },
42
49
  },
43
50
  /**
44
51
  * A string of all className you want applied to the modal content component.
@@ -46,7 +53,6 @@ const CModal = defineComponent({
46
53
  contentClassName: {
47
54
  type: String,
48
55
  default: undefined,
49
- required: false,
50
56
  },
51
57
  /**
52
58
  * Set modal to covers the entire user viewport
@@ -56,7 +62,6 @@ const CModal = defineComponent({
56
62
  fullscreen: {
57
63
  type: [Boolean, String],
58
64
  default: undefined,
59
- required: false,
60
65
  validator: (value: boolean | string) => {
61
66
  if (typeof value == 'string') {
62
67
  return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value)
@@ -73,14 +78,12 @@ const CModal = defineComponent({
73
78
  keyboard: {
74
79
  type: Boolean,
75
80
  default: true,
76
- required: false,
77
81
  },
78
82
  /**
79
83
  * Create a scrollable modal that allows scrolling the modal body.
80
84
  */
81
85
  scrollable: {
82
86
  type: Boolean,
83
- required: false,
84
87
  },
85
88
  /**
86
89
  * Size the component small, large, or extra large.
@@ -90,7 +93,6 @@ const CModal = defineComponent({
90
93
  size: {
91
94
  type: String,
92
95
  default: undefined,
93
- required: false,
94
96
  validator: (value: string) => {
95
97
  return ['sm', 'lg', 'xl'].includes(value)
96
98
  },
@@ -101,7 +103,6 @@ const CModal = defineComponent({
101
103
  transition: {
102
104
  type: Boolean,
103
105
  default: true,
104
- required: false,
105
106
  },
106
107
  /**
107
108
  * By default the component is unmounted after close animation, if you want to keep the component mounted set this property to false.
@@ -109,7 +110,6 @@ const CModal = defineComponent({
109
110
  unmountOnClose: {
110
111
  type: Boolean,
111
112
  default: true,
112
- required: false,
113
113
  },
114
114
  /**
115
115
  * Toggle the visibility of alert component.
@@ -361,16 +361,6 @@ const CMultiSelect = defineComponent({
361
361
  : options.value
362
362
  }
363
363
 
364
- // watch(
365
- // () => props.options,
366
- // (newValue, oldValue) => {
367
- // console.log(props.options)
368
- // if (JSON.stringify(newValue) !== JSON.stringify(oldValue)) options.value = newValue
369
- // },
370
- // )
371
-
372
-
373
-
374
364
  const handleSearchChange = (event: InputEvent) => {
375
365
  const target = event.target as HTMLInputElement
376
366
  search.value = target.value.toLowerCase()
@@ -10,11 +10,21 @@ const COffcanvas = defineComponent({
10
10
  props: {
11
11
  /**
12
12
  * Apply a backdrop on body while offcanvas is open.
13
+ *
14
+ * @values boolean | 'static'
13
15
  */
14
16
  backdrop: {
15
- type: Boolean,
17
+ type: [Boolean, String],
16
18
  default: true,
17
- require: false,
19
+ validator: (value: boolean | string) => {
20
+ if (typeof value === 'string') {
21
+ return ['static'].includes(value)
22
+ }
23
+ if (typeof value === 'boolean') {
24
+ return true
25
+ }
26
+ return false
27
+ },
18
28
  },
19
29
  /**
20
30
  * Closes the offcanvas when escape key is pressed.
@@ -22,7 +32,6 @@ const COffcanvas = defineComponent({
22
32
  keyboard: {
23
33
  type: Boolean,
24
34
  default: true,
25
- require: false,
26
35
  },
27
36
  /**
28
37
  * Components placement, there’s no default placement.
@@ -37,21 +46,36 @@ const COffcanvas = defineComponent({
37
46
  return ['start', 'end', 'top', 'bottom'].includes(value)
38
47
  },
39
48
  },
49
+ /**
50
+ * Responsive offcanvas property hide content outside the viewport from a specified breakpoint and down.
51
+ *
52
+ * @values boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
53
+ * @since 4.7.0
54
+ */
55
+ responsive: {
56
+ type: [Boolean, String],
57
+ default: true,
58
+ validator: (value: boolean | string) => {
59
+ if (typeof value === 'string') {
60
+ return ['sm', 'md', 'lg', 'xl', 'xxl'].includes(value)
61
+ }
62
+ if (typeof value === 'boolean') {
63
+ return true
64
+ }
65
+ return false
66
+ },
67
+ },
40
68
  /**
41
69
  * Allow body scrolling while offcanvas is open
42
70
  */
43
71
  scroll: {
44
72
  type: Boolean,
45
73
  default: false,
46
- required: false,
47
74
  },
48
75
  /**
49
76
  * Toggle the visibility of offcanvas component.
50
77
  */
51
- visible: {
52
- type: Boolean,
53
- require: false,
54
- },
78
+ visible: Boolean,
55
79
  },
56
80
  emits: [
57
81
  /**
@@ -93,22 +117,21 @@ const COffcanvas = defineComponent({
93
117
  emit('show')
94
118
  executeAfterTransition(() => done(), el as HTMLElement)
95
119
  setTimeout(() => {
96
- el.style.visibility = 'visible'
97
120
  el.classList.add('show')
98
121
  }, 1)
99
122
  }
123
+
100
124
  const handleAfterEnter = () => {
101
- window.addEventListener('mousedown', handleMouseDown)
102
- window.addEventListener('keyup', handleKeyUp)
125
+ offcanvasRef.value.focus()
103
126
  }
127
+
104
128
  const handleLeave = (el: RendererElement, done: () => void) => {
105
129
  executeAfterTransition(() => done(), el as HTMLElement)
106
- window.removeEventListener('mousedown', handleMouseDown)
107
- window.removeEventListener('keyup', handleKeyUp)
108
- el.classList.remove('show')
130
+ el.classList.add('hiding')
109
131
  }
132
+
110
133
  const handleAfterLeave = (el: RendererElement) => {
111
- el.style.visibility = 'hidden'
134
+ el.classList.remove('show', 'hiding')
112
135
  }
113
136
 
114
137
  const handleDismiss = () => {
@@ -116,21 +139,15 @@ const COffcanvas = defineComponent({
116
139
  emit('hide')
117
140
  }
118
141
 
119
- const handleKeyUp = (event: KeyboardEvent) => {
120
- if (offcanvasRef.value && !offcanvasRef.value.contains(event.target as HTMLElement)) {
121
- if (event.key === 'Escape' && props.keyboard && props.backdrop) {
122
- return handleDismiss()
123
- }
142
+ const handleBackdropDismiss = () => {
143
+ if (props.backdrop !== 'static') {
144
+ handleDismiss()
124
145
  }
125
146
  }
126
147
 
127
- const handleMouseDown = (event: Event) => {
128
- window.addEventListener('mouseup', () => handleMouseUp(event), { once: true })
129
- }
130
-
131
- const handleMouseUp = (event: Event) => {
132
- if (offcanvasRef.value && !offcanvasRef.value.contains(event.target as HTMLElement)) {
133
- props.backdrop && handleDismiss()
148
+ const handleKeyDown = (event: KeyboardEvent) => {
149
+ if (event.key === 'Escape' && props.keyboard) {
150
+ handleDismiss()
134
151
  }
135
152
  }
136
153
 
@@ -150,13 +167,17 @@ const COffcanvas = defineComponent({
150
167
  'div',
151
168
  {
152
169
  class: [
153
- 'offcanvas',
154
170
  {
171
+ [`offcanvas${
172
+ typeof props.responsive !== 'boolean' ? '-' + props.responsive : ''
173
+ }`]: props.responsive,
155
174
  [`offcanvas-${props.placement}`]: props.placement,
156
175
  },
157
176
  ],
177
+ onKeydown: (event: KeyboardEvent) => handleKeyDown(event),
158
178
  ref: offcanvasRef,
159
179
  role: 'dialog',
180
+ tabindex: -1,
160
181
  },
161
182
  slots.default && slots.default(),
162
183
  ),
@@ -166,6 +187,7 @@ const COffcanvas = defineComponent({
166
187
  props.backdrop &&
167
188
  h(CBackdrop, {
168
189
  class: 'offcanvas-backdrop',
190
+ onClick: handleBackdropDismiss,
169
191
  visible: visible.value,
170
192
  }),
171
193
  ]