@coreui/vue-pro 4.10.4 → 5.0.0-alpha.1

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 (79) hide show
  1. package/README.md +1 -1
  2. package/dist/components/calendar/CCalendar.d.ts +58 -32
  3. package/dist/components/calendar/utils.d.ts +11 -4
  4. package/dist/components/close-button/CCloseButton.d.ts +9 -0
  5. package/dist/components/date-picker/CDatePicker.d.ts +89 -0
  6. package/dist/components/date-range-picker/CDateRangePicker.d.ts +89 -0
  7. package/dist/components/dropdown/CDropdown.d.ts +13 -28
  8. package/dist/components/dropdown/CDropdownToggle.d.ts +19 -9
  9. package/dist/components/dropdown/types.d.ts +15 -0
  10. package/dist/components/dropdown/utils.d.ts +6 -0
  11. package/dist/components/form/CFormInput.d.ts +6 -18
  12. package/dist/components/modal/CModal.d.ts +19 -0
  13. package/dist/components/multi-select/CMultiSelect.d.ts +1 -1
  14. package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
  15. package/dist/components/multi-select/types.d.ts +2 -2
  16. package/dist/components/multi-select/utils.d.ts +2 -2
  17. package/dist/components/offcanvas/COffcanvas.d.ts +9 -0
  18. package/dist/components/progress/CProgress.d.ts +102 -3
  19. package/dist/components/progress/CProgressStacked.d.ts +10 -0
  20. package/dist/components/progress/index.d.ts +2 -1
  21. package/dist/components/smart-table/CSmartTable.d.ts +0 -4
  22. package/dist/components/smart-table/CSmartTableBody.d.ts +12 -1
  23. package/dist/components/smart-table/types.d.ts +2 -2
  24. package/dist/components/smart-table/utils.d.ts +4 -2
  25. package/dist/composables/index.d.ts +3 -1
  26. package/dist/composables/useDebouncedCallback.d.ts +1 -0
  27. package/dist/index.es.js +1142 -2823
  28. package/dist/index.es.js.map +1 -1
  29. package/dist/index.js +1143 -2821
  30. package/dist/index.js.map +1 -1
  31. package/package.json +14 -14
  32. package/src/components/breadcrumb/CBreadcrumb.ts +1 -0
  33. package/src/components/button/CButton.ts +5 -5
  34. package/src/components/calendar/CCalendar.ts +444 -179
  35. package/src/components/calendar/utils.ts +93 -55
  36. package/src/components/carousel/CCarousel.ts +2 -5
  37. package/src/components/close-button/CCloseButton.ts +5 -0
  38. package/src/components/date-picker/CDatePicker.ts +43 -0
  39. package/src/components/date-range-picker/CDateRangePicker.ts +140 -126
  40. package/src/components/date-range-picker/utils.ts +2 -2
  41. package/src/components/dropdown/CDropdown.ts +23 -43
  42. package/src/components/dropdown/CDropdownMenu.ts +4 -19
  43. package/src/components/dropdown/CDropdownToggle.ts +44 -38
  44. package/src/components/dropdown/types.ts +11 -0
  45. package/src/components/dropdown/utils.ts +71 -0
  46. package/src/components/form/CFormCheck.ts +1 -1
  47. package/src/components/modal/CModal.ts +15 -1
  48. package/src/components/multi-select/CMultiSelect.ts +68 -62
  49. package/src/components/multi-select/CMultiSelectOptions.ts +1 -1
  50. package/src/components/multi-select/CMultiSelectSelection.ts +14 -13
  51. package/src/components/multi-select/types.ts +2 -2
  52. package/src/components/multi-select/utils.ts +5 -5
  53. package/src/components/navbar/CNavbar.ts +1 -1
  54. package/src/components/offcanvas/COffcanvas.ts +6 -0
  55. package/src/components/picker/CPicker.ts +7 -22
  56. package/src/components/progress/CProgress.ts +67 -9
  57. package/src/components/progress/CProgressBar.ts +4 -6
  58. package/src/components/progress/CProgressStacked.ts +19 -0
  59. package/src/components/progress/index.ts +3 -1
  60. package/src/components/sidebar/CSidebar.ts +1 -1
  61. package/src/components/smart-table/CSmartTable.ts +17 -12
  62. package/src/components/smart-table/CSmartTableBody.ts +30 -31
  63. package/src/components/smart-table/CSmartTableHead.ts +34 -11
  64. package/src/components/smart-table/types.ts +2 -2
  65. package/src/components/smart-table/utils.ts +41 -5
  66. package/src/components/time-picker/CTimePicker.ts +34 -63
  67. package/src/components/tooltip/CTooltip.ts +1 -1
  68. package/src/components/widgets/CWidgetStatsA.ts +1 -3
  69. package/src/components/widgets/CWidgetStatsB.ts +2 -4
  70. package/src/components/widgets/CWidgetStatsC.ts +2 -2
  71. package/src/components/widgets/CWidgetStatsD.ts +1 -1
  72. package/src/components/widgets/CWidgetStatsE.ts +1 -1
  73. package/src/components/widgets/CWidgetStatsF.ts +1 -1
  74. package/src/components/widgets/__tests__/__snapshots__/CWidgetStatsE.spec.ts.snap +1 -1
  75. package/src/composables/index.ts +3 -1
  76. package/src/composables/useColorModes.ts +63 -0
  77. package/src/composables/useDebouncedCallback.ts +16 -0
  78. package/src/utils/getRTLPlacement.ts +1 -1
  79. package/src/utils/isObjectInArray.ts +1 -1
@@ -130,8 +130,6 @@ const CPicker = defineComponent({
130
130
  'div',
131
131
  {
132
132
  class: [
133
- 'dropdown',
134
- 'picker',
135
133
  attrs.class,
136
134
  {
137
135
  show: visible.value,
@@ -156,26 +154,13 @@ const CPicker = defineComponent({
156
154
  },
157
155
  }),
158
156
  ),
159
- h(
160
- 'div',
161
- {
162
- class: [
163
- 'dropdown-menu',
164
- {
165
- show: visible.value,
166
- },
167
- props.dropdownClassNames,
168
- ],
169
- ref: dropdownRef,
170
- },
171
- [
172
- slots.default && slots.default(),
173
- /**
174
- * @slot Location for the footer element.
175
- */
176
- slots.footer && slots.footer(),
177
- ],
178
- ),
157
+ h('div', { class: props.dropdownClassNames, ref: dropdownRef }, [
158
+ slots.default && slots.default(),
159
+ /**
160
+ * @slot Location for the footer element.
161
+ */
162
+ props.footer && slots.footer && slots.footer(),
163
+ ]),
179
164
  ],
180
165
  )
181
166
  }
@@ -1,25 +1,61 @@
1
- import { defineComponent, h } from 'vue'
1
+ import { defineComponent, h, inject } from 'vue'
2
2
 
3
3
  import { CProgressBar } from './CProgressBar'
4
+ import { Color } from '../../props'
4
5
 
5
6
  const CProgress = defineComponent({
6
7
  name: 'CProgress',
7
8
  props: {
9
+ /**
10
+ * Use to animate the stripes right to left via CSS3 animations.
11
+ */
12
+ animated: Boolean,
13
+ /**
14
+ * Sets the color context of the component to one of CoreUI’s themed colors.
15
+ *
16
+ * @values 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'dark', 'light'
17
+ */
18
+ color: Color,
8
19
  /**
9
20
  * Sets the height of the component. If you set that value the inner `<CProgressBar>` will automatically resize accordingly.
10
21
  */
11
22
  height: Number,
23
+ /**
24
+ * A string of all className you want applied to the <CProgressBar/> component.
25
+ *
26
+ * @since 5.0.0-alpha.1
27
+ */
28
+ progressBarClassName: String,
12
29
  /**
13
30
  * Makes progress bar thinner.
14
31
  */
15
32
  thin: Boolean,
33
+ /**
34
+ * The percent to progress the ProgressBar.
35
+ */
36
+ value: {
37
+ type: Number,
38
+ default: 0,
39
+ },
40
+ /**
41
+ * Set the progress bar variant to optional striped.
42
+ *
43
+ * @values 'striped'
44
+ */
45
+ variant: {
46
+ type: String,
47
+ validator: (value: string) => {
48
+ return value === 'striped'
49
+ },
50
+ },
16
51
  /**
17
52
  * Change the default color to white.
18
53
  */
19
54
  white: Boolean,
20
- ...CProgressBar.props,
21
55
  },
22
56
  setup(props, { slots }) {
57
+ const stacked = inject('stacked', false) as boolean
58
+
23
59
  return () =>
24
60
  h(
25
61
  'div',
@@ -31,20 +67,42 @@ const CProgress = defineComponent({
31
67
  'progress-white': props.white,
32
68
  },
33
69
  ],
34
- ...(props.height, { style: `height: ${props.height}px` }),
70
+ style: {
71
+ ...(props.height ? { height: `${props.height}px` } : {}),
72
+ ...(stacked ? { width: `${props.value}%` } : {}),
73
+ },
74
+ ...(props.value !== undefined && {
75
+ role: 'progressbar',
76
+ 'aria-valuenow': props.value,
77
+ 'aria-valuemin': 0,
78
+ 'aria-valuemax': 100,
79
+ }),
35
80
  },
36
- props.value
37
- ? h(
81
+ // @ts-expect-error name is defined in component
82
+ slots.default && slots.default().some((vnode) => vnode.type.name === 'CProgressBar')
83
+ ? slots.default().map((vnode) => {
84
+ // @ts-expect-error name is defined in component
85
+ if (vnode.type.name === 'CProgressBar') {
86
+ return h(vnode, {
87
+ ...(props.animated && { animated: props.animated }),
88
+ ...(props.color && { color: props.color }),
89
+ ...(props.value && { value: props.value }),
90
+ ...(props.variant && { variant: props.variant }),
91
+ })
92
+ }
93
+ return vnode
94
+ })
95
+ : h(
38
96
  CProgressBar,
39
97
  {
40
- value: props.value,
98
+ ...(props.progressBarClassName && { class: props.progressBarClassName }),
41
99
  animated: props.animated,
42
100
  color: props.color,
101
+ value: props.value,
43
102
  variant: props.variant,
44
103
  },
45
- slots.default && slots.default(),
46
- )
47
- : slots.default && slots.default(),
104
+ () => slots.default && slots.default(),
105
+ ),
48
106
  )
49
107
  },
50
108
  })
@@ -1,4 +1,4 @@
1
- import { defineComponent, h } from 'vue'
1
+ import { defineComponent, h, inject } from 'vue'
2
2
 
3
3
  import { Color } from '../../props'
4
4
 
@@ -35,6 +35,8 @@ const CProgressBar = defineComponent({
35
35
  },
36
36
  },
37
37
  setup(props, { slots }) {
38
+ const stacked = inject('stacked', false) as boolean
39
+
38
40
  return () =>
39
41
  h(
40
42
  'div',
@@ -47,11 +49,7 @@ const CProgressBar = defineComponent({
47
49
  ['progress-bar-animated']: props.animated,
48
50
  },
49
51
  ],
50
- role: 'progressbar',
51
- style: `width: ${props.value}%`,
52
- 'aria-valuenow': props.value,
53
- 'aria-valuemin': '0',
54
- 'aria-valuemax': '100',
52
+ ...(!stacked && { style: { width: `${props.value}%` } }),
55
53
  },
56
54
  slots.default && slots.default(),
57
55
  )
@@ -0,0 +1,19 @@
1
+ import { defineComponent, h, provide } from 'vue'
2
+
3
+ const CProgressStacked = defineComponent({
4
+ name: 'CProgressStacked',
5
+ props: {},
6
+ setup(_, { slots }) {
7
+ provide('stacked', true)
8
+ return () =>
9
+ h(
10
+ 'div',
11
+ {
12
+ class: 'progress-stacked',
13
+ },
14
+ slots.default && slots.default(),
15
+ )
16
+ },
17
+ })
18
+
19
+ export { CProgressStacked }
@@ -1,12 +1,14 @@
1
1
  import { App } from 'vue'
2
2
  import { CProgress } from './CProgress'
3
3
  import { CProgressBar } from './CProgressBar'
4
+ import { CProgressStacked } from './CProgressStacked'
4
5
 
5
6
  const CProgressPlugin = {
6
7
  install: (app: App): void => {
7
8
  app.component(CProgress.name, CProgress)
8
9
  app.component(CProgressBar.name, CProgressBar)
10
+ app.component(CProgressStacked.name, CProgressStacked)
9
11
  },
10
12
  }
11
13
 
12
- export { CProgressPlugin, CProgress, CProgressBar }
14
+ export { CProgressPlugin, CProgress, CProgressBar, CProgressStacked }
@@ -187,7 +187,7 @@ const CSidebar = defineComponent({
187
187
  ),
188
188
  mobile.value &&
189
189
  h(CBackdrop, {
190
- class: 'sidebar-backdrop d-none',
190
+ class: 'sidebar-backdrop',
191
191
  visible: props.visible,
192
192
  onClick: () => handleHide(),
193
193
  }),
@@ -156,8 +156,6 @@ const CSmartTable = defineComponent({
156
156
  },
157
157
  /**
158
158
  * Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values:
159
- * - label (String) - replaces default label text
160
- * - values (Array) - custom array of pagination values
161
159
  * - external (Boolean) - disables automatic 'itemsPerPage' change (use to change pages externaly by 'pagination-change' event).
162
160
  */
163
161
  itemsPerPageSelect: {
@@ -330,7 +328,6 @@ const CSmartTable = defineComponent({
330
328
  }),
331
329
  )
332
330
  const itemsNumber = ref(props.itemsNumber)
333
- // eslint-disable-next-line unicorn/explicit-length-check
334
331
  const itemsPerPage = ref<number>(props.itemsPerPage || items.value.length)
335
332
  const selected = ref<Item[]>([])
336
333
  const selectedAll = ref<boolean | string>()
@@ -375,8 +372,9 @@ const CSmartTable = defineComponent({
375
372
  })
376
373
 
377
374
  if (Array.isArray(props.items)) {
378
- items.value = props.items
379
- // eslint-disable-next-line unicorn/explicit-length-check
375
+ items.value = props.items.map((item: Item, index: number) => {
376
+ return { ...item, _id: index }
377
+ })
380
378
  itemsNumber.value = props.itemsNumber || props.items.length
381
379
  }
382
380
  },
@@ -458,7 +456,7 @@ const CSmartTable = defineComponent({
458
456
  }
459
457
  })
460
458
 
461
- const handleSorterChange = (column: string, index: number) => {
459
+ const handleSorterChange = (column: string, index: number, order?: 'asc' | 'desc') => {
462
460
  if (
463
461
  !isSortable(
464
462
  index,
@@ -474,8 +472,14 @@ const CSmartTable = defineComponent({
474
472
  //if column changed or sort was descending change asc to true
475
473
  const state = sorterState.value
476
474
 
475
+ if (order) {
476
+ state.state = order
477
+ }
478
+
477
479
  if (state.column === column) {
478
- if (state.state === 0) {
480
+ if (order) {
481
+ state.state = order
482
+ } else if (state.state === 0) {
479
483
  state.state = 'asc'
480
484
  } else if (state.state === 'asc') {
481
485
  state.state = 'desc'
@@ -488,7 +492,7 @@ const CSmartTable = defineComponent({
488
492
  }
489
493
  } else {
490
494
  state.column = column
491
- state.state = 'asc'
495
+ state.state = order || 'asc'
492
496
  }
493
497
 
494
498
  sorterState.value.column = state.column
@@ -748,8 +752,8 @@ const CSmartTable = defineComponent({
748
752
  onFilterChange: (key: string, value: string) =>
749
753
  handleColumnFilterChange(key, value, 'change'),
750
754
  onSelectAllChecked: () => handleSelectAllChecked(),
751
- onSortClick: (key: string, index: number) =>
752
- handleSorterChange(key, index),
755
+ onSortClick: (key: string, index: number, order: 'asc' | 'desc') =>
756
+ handleSorterChange(key, index, order),
753
757
  },
754
758
  {
755
759
  // @slot Sorter icon when items are unsorted.
@@ -772,7 +776,7 @@ const CSmartTable = defineComponent({
772
776
  class: 'icon',
773
777
  viewBox: '0 0 512 512',
774
778
  role: 'img',
775
- innerHTML: cilArrowBottom[1],
779
+ innerHTML: cilArrowTop[1],
776
780
  }),
777
781
  // @slot Sorter icon when items are sorted descending.
778
782
  sortingIconDescending: () =>
@@ -783,13 +787,14 @@ const CSmartTable = defineComponent({
783
787
  class: 'icon',
784
788
  viewBox: '0 0 512 512',
785
789
  role: 'img',
786
- innerHTML: cilArrowTop[1],
790
+ innerHTML: cilArrowBottom[1],
787
791
  }),
788
792
  },
789
793
  ),
790
794
  h(CSmartTableBody, {
791
795
  clickableRows: props.clickableRows,
792
796
  columnNames: columnNames.value,
797
+ columns: props.columns ?? columnNames.value,
793
798
  currentItems: currentItems.value,
794
799
  firstItemOnActivePageIndex: firstItemOnActivePageIndex.value,
795
800
  noItemsLabel: props.noItemsLabel,
@@ -5,8 +5,13 @@ import { CTableBody, CTableDataCell, CTableRow } from '../table/'
5
5
 
6
6
  import { isObjectInArray } from '../../utils'
7
7
 
8
- import { getClickedColumnName, getTableDataCellProps } from './utils'
9
- import type { Item } from './types'
8
+ import {
9
+ getClickedColumnName,
10
+ getColumnName,
11
+ getTableDataCellProps,
12
+ getTableDataCellStyles,
13
+ } from './utils'
14
+ import type { Column, Item } from './types'
10
15
 
11
16
  const CSmartTableBody = defineComponent({
12
17
  name: 'CSmartTableBody',
@@ -17,6 +22,11 @@ const CSmartTableBody = defineComponent({
17
22
  default: () => [],
18
23
  require: true,
19
24
  },
25
+ columns: {
26
+ type: Array as PropType<(Column | string)[]>,
27
+ default: () => [],
28
+ require: true,
29
+ },
20
30
  currentItems: {
21
31
  type: Array as PropType<Item[]>,
22
32
  default: () => [],
@@ -33,9 +43,7 @@ const CSmartTableBody = defineComponent({
33
43
  },
34
44
  emits: ['rowChecked', 'rowClick'],
35
45
  setup(props, { emit }) {
36
- const colspan: number = props.selectable
37
- ? props.columnNames.length + 1
38
- : props.columnNames.length
46
+ const colspan: number = props.selectable ? props.columns.length + 1 : props.columns.length
39
47
  return () =>
40
48
  h(
41
49
  CTableBody,
@@ -59,6 +67,7 @@ const CSmartTableBody = defineComponent({
59
67
  getClickedColumnName(
60
68
  event.target as HTMLTextAreaElement,
61
69
  props.columnNames,
70
+ props.selectable,
62
71
  ),
63
72
  event,
64
73
  )
@@ -81,22 +90,24 @@ const CSmartTableBody = defineComponent({
81
90
  },
82
91
  }),
83
92
  ),
84
- props.columnNames.map((colName) =>
85
- props.scopedSlots &&
86
- props.scopedSlots[colName] &&
87
- typeof props.scopedSlots[colName] === 'function'
93
+ props.columns.map((column) => {
94
+ const colName = getColumnName(column)
95
+ return props.scopedSlots &&
96
+ props.scopedSlots[colName] &&
97
+ typeof props.scopedSlots[colName] === 'function'
88
98
  ? h(props.scopedSlots[colName], { item: item })
89
99
  : typeof item[colName] !== 'undefined' &&
90
- h(
91
- CTableDataCell,
92
- {
93
- ...getTableDataCellProps(item, colName),
94
- },
95
- {
96
- default: () => String(item[colName]),
97
- },
98
- ),
99
- ),
100
+ h(
101
+ CTableDataCell,
102
+ {
103
+ ...getTableDataCellProps(column, item, colName),
104
+ style: getTableDataCellStyles(column, item, colName),
105
+ },
106
+ {
107
+ default: () => String(item[colName]),
108
+ },
109
+ )
110
+ }),
100
111
  ],
101
112
  },
102
113
  ),
@@ -115,18 +126,6 @@ const CSmartTableBody = defineComponent({
115
126
  {
116
127
  class: 'p-0',
117
128
  key: `details${trIndex}`,
118
- onClick: (event: MouseEvent) => {
119
- emit(
120
- 'rowClick',
121
- item,
122
- trIndex + props.firstItemOnActivePageIndex,
123
- getClickedColumnName(
124
- event.target as HTMLTextAreaElement,
125
- props.columnNames,
126
- ),
127
- true,
128
- )
129
- },
130
129
  },
131
130
  {
132
131
  default: () =>
@@ -115,15 +115,38 @@ const CSmartTableHead = defineComponent({
115
115
  },
116
116
  }),
117
117
  ),
118
- columns.value.map((column, index: number) =>
119
- h(
118
+ columns.value.map((column, index: number) => {
119
+ const isSortable =
120
+ props.columnSorter &&
121
+ (typeof column === 'object'
122
+ ? column.sorter === undefined
123
+ ? true
124
+ : column.sorter
125
+ : true)
126
+ return h(
120
127
  CTableHeaderCell,
121
128
  {
122
129
  ...getTableHeaderCellProps(column),
123
- onClick: () => {
124
- emit('sortClick', getColumnKey(column), index)
125
- },
126
130
  style: getTableHeaderCellStyles(column, props.columnSorter),
131
+ ...isSortable && {
132
+ tabindex: 0,
133
+ onClick: () => emit('sortClick', getColumnKey(column), index),
134
+ onKeydown: (event: KeyboardEvent) => {
135
+ if (event.key === 'Enter') {
136
+ emit('sortClick', getColumnKey(column), index)
137
+ }
138
+
139
+ if (event.key === 'ArrowUp') {
140
+ event.preventDefault()
141
+ emit('sortClick', getColumnKey(column), index, 'asc')
142
+ }
143
+
144
+ if (event.key === 'ArrowDown') {
145
+ event.preventDefault()
146
+ emit('sortClick', getColumnKey(column), index, 'desc')
147
+ }
148
+ },
149
+ }
127
150
  },
128
151
  {
129
152
  default: () => [
@@ -143,8 +166,8 @@ const CSmartTableHead = defineComponent({
143
166
  columnSorterIcon(column),
144
167
  ],
145
168
  },
146
- ),
147
- ),
169
+ )
170
+ }),
148
171
  ],
149
172
  },
150
173
  ),
@@ -155,8 +178,8 @@ const CSmartTableHead = defineComponent({
155
178
  {
156
179
  default: () => [
157
180
  props.selectable && h(CTableHeaderCell),
158
- columns.value.map((column: Column | string) =>
159
- h(
181
+ columns.value.map((column: Column | string) => {
182
+ return h(
160
183
  CTableHeaderCell,
161
184
  {
162
185
  ...getTableHeaderCellProps(column),
@@ -203,8 +226,8 @@ const CSmartTableHead = defineComponent({
203
226
  })
204
227
  : '',
205
228
  },
206
- ),
207
- ),
229
+ )
230
+ }),
208
231
  ],
209
232
  },
210
233
  ),
@@ -9,6 +9,8 @@ export type Column = {
9
9
  sorter?: boolean
10
10
  _style?: any
11
11
  _props?: any
12
+ _colStyle?: any
13
+ _colProps?: any
12
14
  }
13
15
 
14
16
  export type ColumnFilter = {
@@ -45,8 +47,6 @@ export type Item = {
45
47
 
46
48
  export type ItemsPerPageSelect = {
47
49
  external?: boolean
48
- label?: string
49
- values?: Array<number>
50
50
  }
51
51
 
52
52
  export type Pagination = {
@@ -61,11 +61,12 @@ export const filterTable = (
61
61
  export const getClickedColumnName = (
62
62
  target: HTMLTextAreaElement,
63
63
  columnNames: string[],
64
+ selectable: boolean | undefined
64
65
  ): string => {
65
66
  const closest = target.closest('tr')
66
67
  const children = closest ? Array.from(closest.children) : []
67
68
  const clickedCell = children.filter((child) => child.contains(target))[0]
68
- return columnNames[children.indexOf(clickedCell)]
69
+ return selectable ? columnNames[children.indexOf(clickedCell) - 1] : columnNames[children.indexOf(clickedCell)]
69
70
  }
70
71
 
71
72
  export const getColumnKey = (column: Column | string) =>
@@ -78,6 +79,14 @@ export const getColumnLabel = (column: Column | string) =>
78
79
  : pretifyName(column.key)
79
80
  : pretifyName(column)
80
81
 
82
+ export const getColumnName = (column: string | Column) => {
83
+ if (typeof column === 'object') {
84
+ return column.key
85
+ }
86
+
87
+ return column
88
+ }
89
+
81
90
  export const getColumnNames = (
82
91
  columns: (string | Column)[] | undefined,
83
92
  items: Item[],
@@ -217,15 +226,42 @@ export const getColumnValues = (items: Item[], key: string) => {
217
226
  return items.map((item) => item[key])
218
227
  }
219
228
 
220
- export const getTableDataCellProps = (item: Item, colName: string) => {
221
- const props = item._cellProps && {
222
- ...(item._cellProps['all'] && { ...item._cellProps['all'] }),
223
- ...(item._cellProps[colName] && { ...item._cellProps[colName] }),
229
+ export const getTableDataCellProps = (column: Column | string, item: Item, colName: string) => {
230
+ const props = {}
231
+
232
+ if (typeof column === 'object' && column._colProps) {
233
+ Object.assign(props, column._colProps)
234
+ }
235
+
236
+ if (item._cellProps && item._cellProps['all']) {
237
+ Object.assign(props, item._cellProps['all'])
238
+ }
239
+
240
+ if (item._cellProps && item._cellProps[colName]) {
241
+ Object.assign(props, item._cellProps[colName])
224
242
  }
225
243
 
226
244
  return props
227
245
  }
228
246
 
247
+ export const getTableDataCellStyles = (column: Column | string, item: Item, colName: string) => {
248
+ const styles = {}
249
+
250
+ if (typeof column === 'object' && column._colStyle) {
251
+ Object.assign(styles, column._colStyle)
252
+ }
253
+
254
+ if (item._cellStyle && item._cellStyle['all']) {
255
+ Object.assign(styles, item._cellStyle['all'])
256
+ }
257
+
258
+ if (item._cellStyle && item._cellStyle[colName]) {
259
+ Object.assign(styles, item._cellStyle[colName])
260
+ }
261
+
262
+ return styles
263
+ }
264
+
229
265
  export const getTableHeaderCellProps = (column: Column | string) => {
230
266
  if (typeof column === 'object' && column._props) {
231
267
  return column._props