@coreui/react-pro 4.12.0-alpha.0 → 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 (41) 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.d.ts +1 -1
  5. package/dist/components/multi-select/CMultiSelect.d.ts +2 -2
  6. package/dist/hooks/index.d.ts +2 -1
  7. package/dist/hooks/useColorModes.d.ts +6 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.es.js +133 -274
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.js +135 -273
  12. package/dist/index.js.map +1 -1
  13. package/dist/props.d.ts +1 -1
  14. package/package.json +12 -12
  15. package/src/components/accordion/index.ts +1 -7
  16. package/src/components/calendar/CCalendar.tsx +49 -64
  17. package/src/components/calendar/utils.ts +1 -1
  18. package/src/components/date-range-picker/CDateRangePicker.tsx +10 -10
  19. package/src/components/date-range-picker/utils.ts +2 -2
  20. package/src/components/form/CFormSelect.tsx +3 -1
  21. package/src/components/modal/CModal.tsx +2 -0
  22. package/src/components/multi-select/CMultiSelect.tsx +2 -2
  23. package/src/components/popover/CPopover.tsx +0 -1
  24. package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +2 -1
  25. package/src/components/progress/CProgress.tsx +1 -0
  26. package/src/components/sidebar/CSidebar.tsx +2 -2
  27. package/src/components/smart-table/CSmartTable.tsx +22 -10
  28. package/src/components/smart-table/CSmartTableBody.tsx +3 -5
  29. package/src/components/smart-table/CSmartTableHead.tsx +5 -6
  30. package/src/components/spinner/CSpinner.tsx +4 -2
  31. package/src/components/spinner/__tests__/__snapshots__/CSpinner.spec.tsx.snap +2 -2
  32. package/src/components/table/CTable.tsx +2 -1
  33. package/src/components/tooltip/CTooltip.tsx +0 -1
  34. package/src/components/tooltip/__tests__/CTooltip.spec.tsx +1 -1
  35. package/src/hooks/index.ts +2 -1
  36. package/src/hooks/useColorModes.ts +55 -0
  37. package/src/hooks/useForkedRef.ts +1 -1
  38. package/src/index.ts +1 -0
  39. package/src/props.ts +4 -1
  40. package/src/utils/isRTL.ts +1 -1
  41. package/src/components/smart-table/CSmartTableCleaner.tsx +0 -37
package/dist/props.d.ts CHANGED
@@ -5,4 +5,4 @@ export declare const gradientsPropType: PropTypes.Requireable<string>;
5
5
  export declare const placementPropType: PropTypes.Requireable<Placements>;
6
6
  export declare const shapePropType: PropTypes.Requireable<string>;
7
7
  export declare const textColorsPropType: PropTypes.Requireable<string>;
8
- export declare const triggerPropType: PropTypes.Requireable<Triggers>;
8
+ export declare const triggerPropType: PropTypes.Requireable<NonNullable<Triggers | NonNullable<Triggers>[] | null | undefined>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreui/react-pro",
3
- "version": "4.12.0-alpha.0",
3
+ "version": "4.12.0-beta.0",
4
4
  "description": "UI Components Library for React.js",
5
5
  "keywords": [
6
6
  "react",
@@ -37,34 +37,34 @@
37
37
  "test:update": "jest --coverage --updateSnapshot"
38
38
  },
39
39
  "devDependencies": {
40
- "@coreui/icons": "^3.0.0",
40
+ "@coreui/icons": "^3.0.1",
41
41
  "@coreui/icons-react": "^2.1.0",
42
- "@popperjs/core": "^2.11.6",
43
- "@rollup/plugin-commonjs": "^24.0.1",
44
- "@rollup/plugin-node-resolve": "^15.0.1",
45
- "@rollup/plugin-typescript": "^11.0.0",
42
+ "@popperjs/core": "^2.11.8",
43
+ "@rollup/plugin-commonjs": "^25.0.1",
44
+ "@rollup/plugin-node-resolve": "^15.1.0",
45
+ "@rollup/plugin-typescript": "^11.1.1",
46
46
  "@testing-library/jest-dom": "^5.16.5",
47
47
  "@testing-library/react": "^14.0.0",
48
- "@types/react": "18.2.6",
48
+ "@types/react": "18.2.11",
49
49
  "@types/react-dom": "^18.2.4",
50
50
  "@types/react-transition-group": "^4.4.6",
51
51
  "classnames": "^2.3.2",
52
- "date-fns": "^2.29.3",
52
+ "date-fns": "^2.30.0",
53
53
  "jest": "^29.5.0",
54
54
  "jest-environment-jsdom": "^29.5.0",
55
55
  "prop-types": "^15.8.1",
56
56
  "react": "^18.2.0",
57
- "react-device-detect": "^2.2.2",
57
+ "react-device-detect": "^2.2.3",
58
58
  "react-dom": "^18.2.0",
59
59
  "react-popper": "^2.3.0",
60
60
  "react-transition-group": "^4.4.5",
61
- "rollup": "^3.21.6",
62
- "tslib": "^2.5.0",
61
+ "rollup": "^3.25.0",
62
+ "tslib": "^2.5.3",
63
63
  "ts-jest": "^29.1.0",
64
64
  "typescript": "^4.9.5"
65
65
  },
66
66
  "peerDependencies": {
67
- "@coreui/coreui-pro": ">=4.6.0-alpha.0",
67
+ "@coreui/coreui-pro": ">=4.6.0-beta.0",
68
68
  "react": ">=17",
69
69
  "react-dom": ">=17"
70
70
  }
@@ -4,10 +4,4 @@ import { CAccordionButton } from './CAccordionButton'
4
4
  import { CAccordionHeader } from './CAccordionHeader'
5
5
  import { CAccordionItem } from './CAccordionItem'
6
6
 
7
- export {
8
- CAccordion,
9
- CAccordionBody,
10
- CAccordionButton,
11
- CAccordionHeader,
12
- CAccordionItem,
13
- }
7
+ export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem }
@@ -133,14 +133,14 @@ export interface CCalendarProps {
133
133
  * @default 2
134
134
  */
135
135
  weekdayFormat?: number | 'long' | 'narrow' | 'short' | ((date: Date) => string | number)
136
- /**
137
- * Callback fired when the user hovers over the calendar cell.
138
- */
139
- onCalendarCellHover?: (date: Date | null) => void
140
136
  /**
141
137
  * Callback fired when the calendar date changed.
142
138
  */
143
139
  onCalendarDateChange?: (date: Date) => void
140
+ /**
141
+ * Callback fired when the user hovers over the calendar cell.
142
+ */
143
+ onDayHover?: (date: Date | null) => void
144
144
  /**
145
145
  * Callback fired when the start date changed.
146
146
  */
@@ -170,10 +170,10 @@ const Calendar = (props: {
170
170
  locale: string
171
171
  maxDate: Date | null
172
172
  minDate: Date | null
173
- onCellClick: (date: Date) => void
174
- onCellKeyDown: (event: KeyboardEvent<HTMLDivElement>, date: Date) => void
175
- onCellMouseEnter: (date: Date) => void
176
- onCellMouseLeave: () => void
173
+ onDayClick: (date: Date) => void
174
+ onDayKeyDown: (event: KeyboardEvent<HTMLDivElement>, date: Date) => void
175
+ onDayMouseEnter: (date: Date) => void
176
+ onDayMouseLeave: () => void
177
177
  onMonthClick: (month: number) => void
178
178
  onMonthKeyDown: (event: KeyboardEvent<HTMLDivElement>, month: number) => void
179
179
  onYearClick: (date: Date) => void
@@ -196,10 +196,10 @@ const Calendar = (props: {
196
196
  locale,
197
197
  maxDate,
198
198
  minDate,
199
- onCellClick,
200
- onCellKeyDown,
201
- onCellMouseEnter,
202
- onCellMouseLeave,
199
+ onDayClick,
200
+ onDayKeyDown,
201
+ onDayMouseEnter,
202
+ onDayMouseLeave,
203
203
  onMonthClick,
204
204
  onMonthKeyDown,
205
205
  onYearClick,
@@ -241,9 +241,9 @@ const Calendar = (props: {
241
241
  <div className="calendar-header-cell-inner">
242
242
  {typeof weekdayFormat === 'function'
243
243
  ? weekdayFormat(date)
244
- : typeof weekdayFormat === 'string'
244
+ : (typeof weekdayFormat === 'string'
245
245
  ? date.toLocaleDateString(locale, { weekday: weekdayFormat })
246
- : date.toLocaleDateString(locale, { weekday: 'long' }).slice(0, weekdayFormat)}
246
+ : date.toLocaleDateString(locale, { weekday: 'long' }).slice(0, weekdayFormat))}
247
247
  </div>
248
248
  </th>
249
249
  ))}
@@ -283,16 +283,16 @@ const Calendar = (props: {
283
283
  }
284
284
  title={date.toLocaleDateString(locale)}
285
285
  {...((month === 'current' || selectAdjacementDays) && {
286
- onBlur: () => onCellMouseLeave(),
287
- onClick: () => onCellClick(date),
288
- onFocus: () => onCellMouseEnter(date),
289
- onKeyDown: (event) => onCellKeyDown(event, date),
290
- onMouseEnter: () => onCellMouseEnter(date),
291
- onMouseLeave: () => onCellMouseLeave(),
286
+ onBlur: () => onDayMouseLeave(),
287
+ onClick: () => onDayClick(date),
288
+ onFocus: () => onDayMouseEnter(date),
289
+ onKeyDown: (event) => onDayKeyDown(event, date),
290
+ onMouseEnter: () => onDayMouseEnter(date),
291
+ onMouseLeave: () => onDayMouseLeave(),
292
292
  })}
293
293
  {...(month !== 'current' &&
294
294
  !selectAdjacementDays && {
295
- onMouseEnter: () => onCellMouseLeave(),
295
+ onMouseEnter: () => onDayMouseLeave(),
296
296
  })}
297
297
  >
298
298
  <div className="calendar-cell-inner">
@@ -408,19 +408,13 @@ const Navigation = (props: {
408
408
  {navigation && (
409
409
  <div className="calendar-nav-prev">
410
410
  <CButton color="transparent" size="sm" onClick={() => onNavigationClick('prev', true)}>
411
- {navPrevDoubleIcon ? (
412
- navPrevDoubleIcon
413
- ) : (
411
+ {navPrevDoubleIcon ?? (
414
412
  <span className="calendar-nav-icon calendar-nav-icon-double-prev" />
415
413
  )}
416
414
  </CButton>
417
415
  {view === 'days' && (
418
416
  <CButton color="transparent" size="sm" onClick={() => onNavigationClick('prev')}>
419
- {navPrevIcon ? (
420
- navPrevIcon
421
- ) : (
422
- <span className="calendar-nav-icon calendar-nav-icon-prev" />
423
- )}
417
+ {navPrevIcon ?? <span className="calendar-nav-icon calendar-nav-icon-prev" />}
424
418
  </CButton>
425
419
  )}
426
420
  </div>
@@ -447,17 +441,11 @@ const Navigation = (props: {
447
441
  <div className="calendar-nav-next">
448
442
  {view === 'days' && (
449
443
  <CButton color="transparent" size="sm" onClick={() => onNavigationClick('next')}>
450
- {navNextIcon ? (
451
- navNextIcon
452
- ) : (
453
- <span className="calendar-nav-icon calendar-nav-icon-next" />
454
- )}
444
+ {navNextIcon ?? <span className="calendar-nav-icon calendar-nav-icon-next" />}
455
445
  </CButton>
456
446
  )}
457
447
  <CButton color="transparent" size="sm" onClick={() => onNavigationClick('next', true)}>
458
- {navNextDoubleIcon ? (
459
- navNextDoubleIcon
460
- ) : (
448
+ {navNextDoubleIcon ?? (
461
449
  <span className="calendar-nav-icon calendar-nav-icon-double-next" />
462
450
  )}
463
451
  </CButton>
@@ -492,7 +480,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
492
480
  selectEndDate,
493
481
  showAdjacementDays = true,
494
482
  weekdayFormat = 2,
495
- onCalendarCellHover,
483
+ onDayHover,
496
484
  onCalendarDateChange,
497
485
  onEndDateChange,
498
486
  onStartDateChange,
@@ -590,7 +578,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
590
578
  onCalendarDateChange && onCalendarDateChange(d)
591
579
  }
592
580
 
593
- const handleCellOnClick = (date: Date, index?: number) => {
581
+ const handleDayClick = (date: Date, index?: number) => {
594
582
  if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
595
583
  return
596
584
  }
@@ -638,30 +626,29 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
638
626
  setStartDate(date)
639
627
  }
640
628
 
641
- const handleCellMouseEnter = (date: Date) => {
642
- if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
643
- return
644
- }
645
-
646
- setHoverDate(date)
647
- onCalendarCellHover && onCalendarCellHover(date)
648
- }
649
-
650
- const handleCellMouseLeave = () => {
651
- setHoverDate(null)
652
- onCalendarCellHover && onCalendarCellHover(null)
653
- }
654
-
655
- const handleCellKeyDown = (
629
+ const handleDayKeyDown = (
656
630
  event: React.KeyboardEvent<HTMLDivElement>,
657
631
  date: Date,
658
632
  index?: number,
659
633
  ) => {
660
634
  if (event.code === 'Space' || event.key === 'Enter') {
661
635
  event.preventDefault()
662
- handleCellOnClick && handleCellOnClick(date, index)
636
+ handleDayClick(date, index)
637
+ }
638
+ }
639
+
640
+ const handleDayMouseEnter = (date: Date) => {
641
+ if (isDateDisabled(date, _minDate, _maxDate, disabledDates)) {
663
642
  return
664
643
  }
644
+
645
+ setHoverDate(date)
646
+ onDayHover && onDayHover(date)
647
+ }
648
+
649
+ const handleDayMouseLeave = () => {
650
+ setHoverDate(null)
651
+ onDayHover && onDayHover(null)
665
652
  }
666
653
 
667
654
  const handleMonthClick = (month: number) => {
@@ -671,8 +658,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
671
658
 
672
659
  const handleMonthKeyDown = (event: React.KeyboardEvent<HTMLDivElement>, month: number) => {
673
660
  if (event.code === 'Space' || event.key === 'Enter') {
674
- setCalendarPage(0, 0, month)
675
- setView('days')
661
+ handleMonthClick(month)
676
662
  }
677
663
  }
678
664
 
@@ -714,8 +700,7 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
714
700
 
715
701
  const handleYearKeyDown = (event: React.KeyboardEvent<HTMLDivElement>, date: Date) => {
716
702
  if (event.code === 'Space' || event.key === 'Enter') {
717
- setCalendarDate(date)
718
- setView('months')
703
+ handleYearClick(date)
719
704
  }
720
705
  }
721
706
 
@@ -750,10 +735,10 @@ export const CCalendar = forwardRef<HTMLDivElement, CCalendarProps>(
750
735
  locale={locale}
751
736
  maxDate={_maxDate}
752
737
  minDate={_minDate}
753
- onCellClick={(date) => handleCellOnClick(date, index)}
754
- onCellKeyDown={(event, date) => handleCellKeyDown(event, date, index)}
755
- onCellMouseEnter={handleCellMouseEnter}
756
- onCellMouseLeave={handleCellMouseLeave}
738
+ onDayClick={(date) => handleDayClick(date, index)}
739
+ onDayKeyDown={(event, date) => handleDayKeyDown(event, date, index)}
740
+ onDayMouseEnter={handleDayMouseEnter}
741
+ onDayMouseLeave={handleDayMouseLeave}
757
742
  onMonthClick={handleMonthClick}
758
743
  onMonthKeyDown={handleMonthKeyDown}
759
744
  onYearClick={handleYearClick}
@@ -802,7 +787,7 @@ CCalendar.propTypes = {
802
787
  PropTypes.number,
803
788
  PropTypes.oneOf<'long' | 'narrow' | 'short'>(['long', 'narrow', 'short']),
804
789
  ]),
805
- onCalendarCellHover: PropTypes.func,
790
+ onDayHover: PropTypes.func,
806
791
  onCalendarDateChange: PropTypes.func,
807
792
  onEndDateChange: PropTypes.func,
808
793
  onSelectEndChange: PropTypes.func,
@@ -164,7 +164,7 @@ export const isDateDisabled = (
164
164
  if (max && date > max) {
165
165
  disabled = true
166
166
  }
167
-
167
+
168
168
  return disabled
169
169
  }
170
170
 
@@ -17,7 +17,7 @@ import { getLocalDateFromString } from './utils'
17
17
  export interface CDateRangePickerProps
18
18
  extends Omit<CFormControlWrapperProps, 'floatingLabel'>,
19
19
  Omit<CPickerProps, 'placeholder'>,
20
- Omit<CCalendarProps, 'onCalendarCellHover' | 'onCalendarDateChange'> {
20
+ Omit<CCalendarProps, 'onDayHover' | 'onCalendarDateChange'> {
21
21
  /**
22
22
  * The number of calendars that render on desktop devices.
23
23
  */
@@ -328,9 +328,9 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
328
328
  const formatDate = (date: Date) => {
329
329
  return format
330
330
  ? dateFormat(date, format)
331
- : timepicker
331
+ : (timepicker
332
332
  ? date.toLocaleString(locale)
333
- : date.toLocaleDateString(locale)
333
+ : date.toLocaleDateString(locale))
334
334
  }
335
335
 
336
336
  const setInputValue = (el: HTMLInputElement | null, date: Date | null) => {
@@ -346,7 +346,7 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
346
346
  el.value = ''
347
347
  }
348
348
 
349
- const handleCalendarCellHover = (date: Date | null) => {
349
+ const handleDayHover = (date: Date | null) => {
350
350
  selectEndDate ? setInputEndHoverValue(date) : setInputStartHoverValue(date)
351
351
  }
352
352
 
@@ -590,7 +590,7 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
590
590
  selectEndDate={selectEndDate}
591
591
  showAdjacementDays={showAdjacementDays}
592
592
  startDate={_startDate}
593
- onCalendarCellHover={(date) => handleCalendarCellHover(date)}
593
+ onDayHover={(date) => handleDayHover(date)}
594
594
  onCalendarDateChange={(date) => handleCalendarDateChange(date)}
595
595
  onStartDateChange={(date) => handleStartDateChange(date)}
596
596
  onEndDateChange={(date) => handleEndDateChange(date)}
@@ -619,17 +619,17 @@ export const CDateRangePicker = forwardRef<HTMLDivElement | HTMLLIElement, CDate
619
619
  />
620
620
  </>
621
621
  ) : (
622
- [...Array(calendars)].map((_, index) => (
622
+ Array.from({ length: calendars }).map((_, index) => (
623
623
  <CTimePicker
624
624
  container="inline"
625
625
  disabled={
626
626
  index === 0
627
- ? _startDate === null
627
+ ? (_startDate === null
628
628
  ? true
629
- : false
630
- : _endDate === null
629
+ : false)
630
+ : (_endDate === null
631
631
  ? true
632
- : false
632
+ : false)
633
633
  }
634
634
  key={index}
635
635
  locale={locale}
@@ -32,9 +32,9 @@ export const getLocalDateFromString = (string: string, locale: string, time?: bo
32
32
  Number(partials.groups['month']) - 1,
33
33
  Number(partials.groups['day']),
34
34
  partials.groups['ampm']
35
- ? partials.groups['ampm'] === 'PM'
35
+ ? (partials.groups['ampm'] === 'PM'
36
36
  ? Number(partials.groups['hour']) + 12
37
- : Number(partials.groups['hour'])
37
+ : Number(partials.groups['hour']))
38
38
  : Number(partials.groups['hour']),
39
39
  Number(partials.groups['minute']),
40
40
  Number(partials.groups['second']),
@@ -9,6 +9,7 @@ type Option = {
9
9
  label?: string
10
10
  value?: string
11
11
  }
12
+
12
13
  export interface CFormSelectProps
13
14
  extends CFormControlWrapperProps,
14
15
  Omit<InputHTMLAttributes<HTMLSelectElement>, 'size'> {
@@ -102,7 +103,8 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
102
103
  <option
103
104
  {...(typeof option === 'object' &&
104
105
  option.disabled && { disabled: option.disabled })}
105
- {...(typeof option === 'object' && option.value && { value: option.value })}
106
+ {...(typeof option === 'object' &&
107
+ option.value !== undefined && { value: option.value })}
106
108
  key={index}
107
109
  >
108
110
  {typeof option === 'string' ? option : option.label}
@@ -142,6 +142,7 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
142
142
  return setStaticBackdrop(true)
143
143
  }
144
144
 
145
+ setVisible(false)
145
146
  return onClose && onClose()
146
147
  }
147
148
 
@@ -174,6 +175,7 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
174
175
  document.body.style.removeProperty('padding-right')
175
176
  }
176
177
  }
178
+
177
179
  return () => {
178
180
  document.body.classList.remove('modal-open')
179
181
  if (backdrop) {
@@ -101,13 +101,13 @@ export interface CMultiSelectProps
101
101
  /**
102
102
  * Custom template for options.
103
103
  *
104
- * @since 4.12.0-alpha.0
104
+ * @since 4.12.0-beta.0
105
105
  */
106
106
  optionsTemplate?: (option: Option) => ReactNode
107
107
  /**
108
108
  * Custom template for options groups.
109
109
  *
110
- * @since 4.12.0-alpha.0
110
+ * @since 4.12.0-beta.0
111
111
  */
112
112
  optionsGroupsTemplate?: (option: OptionsGroup) => ReactNode
113
113
  /**
@@ -51,7 +51,6 @@ export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'tit
51
51
  }
52
52
 
53
53
  const getPlacement = (placement: string, element: HTMLDivElement | null): Placement => {
54
- console.log(element)
55
54
  switch (placement) {
56
55
  case 'right': {
57
56
  return isRTL(element) ? 'left' : 'right'
@@ -11,10 +11,11 @@ exports[`CPopover customize 1`] = `
11
11
  <div
12
12
  class="popover bs-popover-end fade"
13
13
  role="tooltip"
14
- style="position: absolute; left: 0px; top: 0px;"
14
+ style="position: absolute; left: 0px; top: 0px; margin: 0px;"
15
15
  >
16
16
  <div
17
17
  class="popover-arrow"
18
+ data-popper-arrow="true"
18
19
  style="position: absolute;"
19
20
  />
20
21
  <div
@@ -29,6 +29,7 @@ export interface CProgressProps
29
29
  white?: boolean
30
30
  }
31
31
 
32
+ // TODO: update markup and add '.progress-stacked' in v5
32
33
  export const CProgress = forwardRef<HTMLDivElement, CProgressProps>(
33
34
  ({ children, className, height, thin, value = 0, white, ...rest }, ref) => {
34
35
  return (
@@ -111,7 +111,7 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
111
111
  sidebarRef.current && setMobile(isOnMobile(sidebarRef.current))
112
112
  sidebarRef.current && setInViewport(isInViewport(sidebarRef.current))
113
113
 
114
- window.addEventListener('resize', () => handleResize())
114
+ window.addEventListener('resize', handleResize)
115
115
  window.addEventListener('mouseup', handleClickOutside)
116
116
  window.addEventListener('keyup', handleKeyup)
117
117
 
@@ -121,7 +121,7 @@ export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
121
121
  })
122
122
 
123
123
  return () => {
124
- window.removeEventListener('resize', () => handleResize())
124
+ window.removeEventListener('resize', handleResize)
125
125
  window.removeEventListener('mouseup', handleClickOutside)
126
126
  window.removeEventListener('keyup', handleKeyup)
127
127
 
@@ -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' ? (
@@ -51,8 +51,10 @@ export const CSpinner = forwardRef<HTMLDivElement | HTMLSpanElement, CSpinnerPro
51
51
  <Component
52
52
  className={classNames(
53
53
  `spinner-${variant}`,
54
- `text-${color}`,
55
- size && `spinner-${variant}-${size}`,
54
+ {
55
+ [`spinner-${variant}-${size}`]: size,
56
+ [`text-${color}`]: color,
57
+ },
56
58
  className,
57
59
  )}
58
60
  role="status"