@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.
- package/README.md +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/calendar/CCalendar.d.ts +4 -4
- package/dist/components/date-range-picker/CDateRangePicker copy.d.ts +114 -0
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +49 -1
- package/dist/components/multi-select/CMultiSelect.d.ts +34 -3
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +4 -5
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +4 -2
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -0
- package/dist/components/multi-select/types.d.ts +7 -3
- package/dist/components/multi-select/utils.d.ts +5 -5
- package/dist/components/multi-select-new/CMultiSelect.d.ts +133 -0
- package/dist/components/multi-select-new/CMultiSelectNativeSelect.d.ts +7 -0
- package/dist/components/multi-select-new/CMultiSelectNew.d.ts +121 -0
- package/dist/components/multi-select-new/CMultiSelectOptions.d.ts +16 -0
- package/dist/components/multi-select-new/CMultiSelectSelection.d.ts +11 -0
- package/dist/components/multi-select-new/index.d.ts +2 -0
- package/dist/components/multi-select-new/types.d.ts +15 -0
- package/dist/components/multi-select-new/utils.d.ts +11 -0
- package/dist/components/picker/CPicker copy.d.ts +82 -0
- package/dist/components/picker/CPicker.d.ts +14 -56
- package/dist/components/picker copy/CPicker.d.ts +82 -0
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/time-picker/CTimePicker.d.ts +41 -1
- package/dist/components/tooltip/CTooltip.d.ts +3 -3
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/useColorModes.d.ts +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +2385 -2403
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2386 -2401
- package/dist/index.js.map +1 -1
- package/dist/props.d.ts +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/isRTL.d.ts +2 -0
- package/package.json +15 -15
- package/src/components/accordion/index.ts +1 -7
- package/src/components/calendar/CCalendar.tsx +49 -64
- package/src/components/calendar/__tests__/__snapshots__/CCalendar.spec.tsx.snap +601 -555
- package/src/components/calendar/utils.ts +1 -1
- package/src/components/date-picker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +599 -561
- package/src/components/date-range-picker/CDateRangePicker.tsx +208 -107
- package/src/components/date-range-picker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1197 -1121
- package/src/components/date-range-picker/utils.ts +2 -2
- package/src/components/dropdown/CDropdownMenu.tsx +5 -4
- package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
- package/src/components/element-cover/CElementCover.tsx +1 -0
- package/src/components/form/CFormSelect.tsx +3 -1
- package/src/components/modal/CModal.tsx +2 -0
- package/src/components/multi-select/CMultiSelect.tsx +200 -79
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +34 -24
- package/src/components/multi-select/CMultiSelectOptions.tsx +25 -23
- package/src/components/multi-select/CMultiSelectSelection.tsx +36 -7
- package/src/components/multi-select/__tests__/CMultiSelect.spec.tsx +25 -14
- package/src/components/multi-select/__tests__/CMultiSelectNativeSelect.spec.tsx +1 -1
- package/src/components/multi-select/__tests__/CMultiSelectOptions.spec.tsx +4 -4
- package/src/components/multi-select/__tests__/CMultiSelectSelection.spec.tsx +0 -1
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelect.spec.tsx.snap +136 -30
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectNativeSelect.spec.tsx.snap +2 -0
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectOptions.spec.tsx.snap +3 -1
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelection.spec.tsx.snap +2 -2
- package/src/components/multi-select/types.ts +9 -4
- package/src/components/multi-select/utils.ts +56 -39
- package/src/components/picker/CPicker.tsx +113 -138
- package/src/components/popover/CPopover.tsx +61 -26
- package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +2 -1
- package/src/components/progress/CProgress.tsx +1 -0
- package/src/components/sidebar/CSidebar.tsx +2 -2
- package/src/components/smart-table/CSmartTable.tsx +22 -10
- package/src/components/smart-table/CSmartTableBody.tsx +3 -5
- package/src/components/smart-table/CSmartTableHead.tsx +5 -6
- package/src/components/smart-table/__tests__/CSmartTable.spec.tsx +1 -1
- package/src/components/smart-table/__tests__/__snapshots__/CSmartTable.spec.tsx.snap +580 -0
- package/src/components/spinner/CSpinner.tsx +4 -2
- package/src/components/spinner/__tests__/__snapshots__/CSpinner.spec.tsx.snap +2 -2
- package/src/components/table/CTable.tsx +2 -1
- package/src/components/time-picker/CTimePicker.tsx +182 -82
- package/src/components/time-picker/__tests__/__snapshots__/CTimePicker.spec.tsx.snap +1078 -0
- package/src/components/tooltip/CTooltip.tsx +65 -31
- package/src/components/tooltip/__tests__/CTooltip.spec.tsx +1 -1
- package/src/components/virtual-scroller/CVirtualScroller.tsx +0 -1
- package/src/hooks/index.ts +2 -1
- package/src/hooks/useColorModes.ts +55 -0
- package/src/hooks/useForkedRef.ts +1 -1
- package/src/index.ts +1 -0
- package/src/props.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/isRTL.ts +13 -0
- package/src/components/multi-select/__tests__/CMultiSelectCleaner.spec.tsx +0 -15
- package/src/components/multi-select/__tests__/CMultiSelectSearchInput.spec.tsx +0 -17
- package/src/components/multi-select/__tests__/CMultiSelectSelectAllButton.spec.tsx +0 -21
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectCleaner.spec.tsx.snap +0 -19
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSearchInput.spec.tsx.snap +0 -20
- package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelectAllButton.spec.tsx.snap +0 -24
- 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
|
-
|
|
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
|
-
<
|
|
355
|
-
|
|
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
|
-
|
|
99
|
-
(typeof item[colName] !== 'undefined' && (
|
|
97
|
+
(item[colName] !== undefined && (
|
|
100
98
|
<CTableDataCell {...getTableDataCellProps(item, colName)} key={index}>
|
|
101
|
-
{
|
|
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
|
-
?
|
|
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 '../
|
|
5
|
+
import { Item } from '../types'
|
|
6
6
|
|
|
7
7
|
test('loads and displays CSpinner component', async () => {
|
|
8
8
|
const columns = [
|