@coreui/react-pro 4.11.3 → 4.12.0-beta.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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/components/accordion/index.d.ts +1 -1
  3. package/dist/components/calendar/CCalendar.d.ts +4 -4
  4. package/dist/components/date-range-picker/CDateRangePicker copy.d.ts +114 -0
  5. package/dist/components/date-range-picker/CDateRangePicker.d.ts +49 -1
  6. package/dist/components/multi-select/CMultiSelect.d.ts +34 -3
  7. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +4 -5
  8. package/dist/components/multi-select/CMultiSelectOptions.d.ts +4 -2
  9. package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -0
  10. package/dist/components/multi-select/types.d.ts +7 -3
  11. package/dist/components/multi-select/utils.d.ts +5 -5
  12. package/dist/components/multi-select-new/CMultiSelect.d.ts +133 -0
  13. package/dist/components/multi-select-new/CMultiSelectNativeSelect.d.ts +7 -0
  14. package/dist/components/multi-select-new/CMultiSelectNew.d.ts +121 -0
  15. package/dist/components/multi-select-new/CMultiSelectOptions.d.ts +16 -0
  16. package/dist/components/multi-select-new/CMultiSelectSelection.d.ts +11 -0
  17. package/dist/components/multi-select-new/index.d.ts +2 -0
  18. package/dist/components/multi-select-new/types.d.ts +15 -0
  19. package/dist/components/multi-select-new/utils.d.ts +11 -0
  20. package/dist/components/picker/CPicker copy.d.ts +82 -0
  21. package/dist/components/picker/CPicker.d.ts +14 -56
  22. package/dist/components/picker copy/CPicker.d.ts +82 -0
  23. package/dist/components/popover/CPopover.d.ts +1 -1
  24. package/dist/components/time-picker/CTimePicker.d.ts +41 -1
  25. package/dist/components/tooltip/CTooltip.d.ts +3 -3
  26. package/dist/hooks/index.d.ts +2 -1
  27. package/dist/hooks/useColorModes.d.ts +6 -0
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.es.js +2385 -2403
  30. package/dist/index.es.js.map +1 -1
  31. package/dist/index.js +2386 -2401
  32. package/dist/index.js.map +1 -1
  33. package/dist/props.d.ts +1 -1
  34. package/dist/utils/index.d.ts +2 -1
  35. package/dist/utils/isRTL.d.ts +2 -0
  36. package/package.json +15 -15
  37. package/src/components/accordion/index.ts +1 -7
  38. package/src/components/calendar/CCalendar.tsx +49 -64
  39. package/src/components/calendar/__tests__/__snapshots__/CCalendar.spec.tsx.snap +601 -555
  40. package/src/components/calendar/utils.ts +1 -1
  41. package/src/components/date-picker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +599 -561
  42. package/src/components/date-range-picker/CDateRangePicker.tsx +208 -107
  43. package/src/components/date-range-picker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1197 -1121
  44. package/src/components/date-range-picker/utils.ts +2 -2
  45. package/src/components/dropdown/CDropdownMenu.tsx +5 -4
  46. package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
  47. package/src/components/element-cover/CElementCover.tsx +1 -0
  48. package/src/components/form/CFormSelect.tsx +3 -1
  49. package/src/components/modal/CModal.tsx +2 -0
  50. package/src/components/multi-select/CMultiSelect.tsx +200 -79
  51. package/src/components/multi-select/CMultiSelectNativeSelect.tsx +34 -24
  52. package/src/components/multi-select/CMultiSelectOptions.tsx +25 -23
  53. package/src/components/multi-select/CMultiSelectSelection.tsx +36 -7
  54. package/src/components/multi-select/__tests__/CMultiSelect.spec.tsx +25 -14
  55. package/src/components/multi-select/__tests__/CMultiSelectNativeSelect.spec.tsx +1 -1
  56. package/src/components/multi-select/__tests__/CMultiSelectOptions.spec.tsx +4 -4
  57. package/src/components/multi-select/__tests__/CMultiSelectSelection.spec.tsx +0 -1
  58. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelect.spec.tsx.snap +136 -30
  59. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectNativeSelect.spec.tsx.snap +2 -0
  60. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectOptions.spec.tsx.snap +3 -1
  61. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelection.spec.tsx.snap +2 -2
  62. package/src/components/multi-select/types.ts +9 -4
  63. package/src/components/multi-select/utils.ts +56 -39
  64. package/src/components/picker/CPicker.tsx +113 -138
  65. package/src/components/popover/CPopover.tsx +61 -26
  66. package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +2 -1
  67. package/src/components/progress/CProgress.tsx +1 -0
  68. package/src/components/sidebar/CSidebar.tsx +2 -2
  69. package/src/components/smart-table/CSmartTable.tsx +22 -10
  70. package/src/components/smart-table/CSmartTableBody.tsx +3 -5
  71. package/src/components/smart-table/CSmartTableHead.tsx +5 -6
  72. package/src/components/smart-table/__tests__/CSmartTable.spec.tsx +1 -1
  73. package/src/components/smart-table/__tests__/__snapshots__/CSmartTable.spec.tsx.snap +580 -0
  74. package/src/components/spinner/CSpinner.tsx +4 -2
  75. package/src/components/spinner/__tests__/__snapshots__/CSpinner.spec.tsx.snap +2 -2
  76. package/src/components/table/CTable.tsx +2 -1
  77. package/src/components/time-picker/CTimePicker.tsx +182 -82
  78. package/src/components/time-picker/__tests__/__snapshots__/CTimePicker.spec.tsx.snap +1078 -0
  79. package/src/components/tooltip/CTooltip.tsx +65 -31
  80. package/src/components/tooltip/__tests__/CTooltip.spec.tsx +1 -1
  81. package/src/components/virtual-scroller/CVirtualScroller.tsx +0 -1
  82. package/src/hooks/index.ts +2 -1
  83. package/src/hooks/useColorModes.ts +55 -0
  84. package/src/hooks/useForkedRef.ts +1 -1
  85. package/src/index.ts +1 -0
  86. package/src/props.ts +4 -1
  87. package/src/utils/index.ts +2 -1
  88. package/src/utils/isRTL.ts +13 -0
  89. package/src/components/multi-select/__tests__/CMultiSelectCleaner.spec.tsx +0 -15
  90. package/src/components/multi-select/__tests__/CMultiSelectSearchInput.spec.tsx +0 -17
  91. package/src/components/multi-select/__tests__/CMultiSelectSelectAllButton.spec.tsx +0 -21
  92. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectCleaner.spec.tsx.snap +0 -19
  93. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSearchInput.spec.tsx.snap +0 -20
  94. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelectAllButton.spec.tsx.snap +0 -24
  95. package/src/components/smart-table/CSmartTableCleaner.tsx +0 -37
@@ -1,7 +1,7 @@
1
1
  import React, { ChangeEvent, forwardRef, useEffect, useMemo, useRef, useState } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
- import { cilArrowBottom, cilArrowTop, cilSwapVertical } from '@coreui/icons'
4
+ import { cilArrowBottom, cilArrowTop, cilFilterX, cilSwapVertical } from '@coreui/icons'
5
5
  import CIcon from '@coreui/icons-react'
6
6
 
7
7
  import { CElementCover } from '../element-cover'
@@ -9,15 +9,13 @@ import { CFormInput, CFormLabel, CFormSelect } from '../form'
9
9
  import { CSmartPagination } from '../smart-pagination'
10
10
  import { CTable, CTableDataCell, CTableFoot, CTableRow } from '../table'
11
11
 
12
- import { CSmartTableProps } from './CSmartTableInterface'
13
- import type { ColumnFilterValue, FooterItem, Item, SorterValue } from './types'
14
-
15
12
  import { CSmartTableBody } from './CSmartTableBody'
16
- import { CSmartTableCleaner } from './CSmartTableCleaner'
17
13
  import { CSmartTableHead } from './CSmartTableHead'
14
+ import { CSmartTableProps } from './CSmartTableInterface'
18
15
 
19
16
  import { isObjectInArray } from '../../utils'
20
17
 
18
+ import type { ColumnFilterValue, FooterItem, Item, SorterValue } from './types'
21
19
  import {
22
20
  filterColumns,
23
21
  filterTable,
@@ -99,6 +97,8 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
99
97
  setActivePage(1)
100
98
  }
101
99
 
100
+ const selected: Item[] = []
101
+
102
102
  items &&
103
103
  items.forEach((item: Item) => {
104
104
  if (item._selected) {
@@ -106,12 +106,17 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
106
106
  delete _item['_cellProps']
107
107
  delete _item['_props']
108
108
  delete _item['_selected']
109
- setSelected([..._selected, _item])
109
+ selected.push(_item)
110
110
  }
111
111
  })
112
112
 
113
+ if (selected.length > 0) {
114
+ setSelected([..._selected, ...selected])
115
+ }
116
+
113
117
  if (Array.isArray(items)) {
114
118
  setItems(items)
119
+ // eslint-disable-next-line unicorn/explicit-length-check
115
120
  setItemsNumber(itemsNumber || items.length)
116
121
  }
117
122
  }, [JSON.stringify(items)])
@@ -351,17 +356,24 @@ export const CSmartTable = forwardRef<HTMLDivElement, CSmartTableProps>(
351
356
  </div>
352
357
  <div className="col-auto p-0">
353
358
  {cleaner && (
354
- <CSmartTableCleaner
355
- isFiltered={
359
+ <button
360
+ type="button"
361
+ className="btn btn-transparent"
362
+ {...(!(
356
363
  tableFilterState ||
357
364
  sorterState?.column ||
358
365
  Object.values(columnFilterState).join('')
359
- }
366
+ ) && {
367
+ disabled: true,
368
+ tabIndex: -1,
369
+ })}
360
370
  onClick={() => handleClean()}
361
371
  onKeyDown={(event) => {
362
372
  if (event.key === 'Enter') handleClean()
363
373
  }}
364
- />
374
+ >
375
+ <CIcon width={18} icon={cilFilterX} />
376
+ </button>
365
377
  )}
366
378
  </div>
367
379
  </>
@@ -5,10 +5,9 @@ import { CTableBody, CTableBodyProps } from '../table/CTableBody'
5
5
  import { CFormCheck } from '../form'
6
6
  import { CTableDataCell, CTableRow } from '../table'
7
7
 
8
- import type { Item, ScopedColumns } from './types'
9
-
10
8
  import { isObjectInArray } from '../../utils'
11
9
 
10
+ import type { Item, ScopedColumns } from './types'
12
11
  import { getClickedColumnName, getTableDataCellProps } from './utils'
13
12
 
14
13
  export interface CSmartTableBodyProps extends CTableBodyProps {
@@ -95,10 +94,9 @@ export const CSmartTableBody = forwardRef<HTMLTableSectionElement, CSmartTableBo
95
94
  key: index,
96
95
  },
97
96
  )) ||
98
- // eslint-disable-next-line unicorn/no-typeof-undefined
99
- (typeof item[colName] !== 'undefined' && (
97
+ (item[colName] !== undefined && (
100
98
  <CTableDataCell {...getTableDataCellProps(item, colName)} key={index}>
101
- {String(item[colName])}
99
+ {item[colName]}
102
100
  </CTableDataCell>
103
101
  ))
104
102
  )
@@ -13,6 +13,7 @@ import { CFormCheck, CFormInput } from '../form'
13
13
  import { CTableHeaderCell, CTableRow } from '../table'
14
14
  import { CTableHead, CTableHeadProps } from '../table/CTableHead'
15
15
 
16
+ import type { ColumnFilter, ColumnFilterValue, Column, Item, Sorter, SorterValue } from './types'
16
17
  import {
17
18
  getColumnKey,
18
19
  getColumnLabel,
@@ -24,8 +25,6 @@ import {
24
25
  getTableHeaderCellStyles,
25
26
  } from './utils'
26
27
 
27
- import type { ColumnFilter, ColumnFilterValue, Column, Item, Sorter, SorterValue } from './types'
28
-
29
28
  export interface CSmartTableHeadProps extends CTableHeadProps {
30
29
  columnFilter?: boolean | ColumnFilter
31
30
  columnFilterState?: ColumnFilterValue
@@ -155,9 +154,9 @@ export const CSmartTableHead = forwardRef<HTMLTableSectionElement, CSmartTableHe
155
154
  <div className="d-inline">{getColumnLabel(column)}</div>
156
155
  {columnSorter &&
157
156
  (typeof column === 'object'
158
- ? typeof column.sorter === 'undefined'
157
+ ? (column.sorter === undefined
159
158
  ? true
160
- : column.sorter
159
+ : column.sorter)
161
160
  : true) &&
162
161
  columnSorterIcon(column)}
163
162
  </CTableHeaderCell>
@@ -172,9 +171,9 @@ export const CSmartTableHead = forwardRef<HTMLTableSectionElement, CSmartTableHe
172
171
  <CTableHeaderCell {...getTableHeaderCellProps(column)} key={index}>
173
172
  {(
174
173
  typeof column === 'object'
175
- ? column.filter === undefined
174
+ ? (column.filter === undefined
176
175
  ? true
177
- : column.filter
176
+ : column.filter)
178
177
  : true
179
178
  ) ? (
180
179
  typeof column !== 'string' && typeof column.filter === 'function' ? (
@@ -2,7 +2,7 @@ import * as React from 'react'
2
2
  import { render } from '@testing-library/react'
3
3
  import '@testing-library/jest-dom/extend-expect'
4
4
  import { CBadge, CSmartTable } from '../../../index'
5
- import { Item } from '../CSmartTableInterface'
5
+ import { Item } from '../types'
6
6
 
7
7
  test('loads and displays CSpinner component', async () => {
8
8
  const columns = [