@coreui/react-pro 4.8.0-alpha.3 → 4.9.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 (82) hide show
  1. package/README.md +1 -1
  2. package/dist/components/calendar/index.d.ts +2 -0
  3. package/dist/components/calendar/utils.d.ts +23 -0
  4. package/dist/components/date-picker/CDatePicker.d.ts +1 -1
  5. package/dist/components/date-range-picker/CDateRangePicker.d.ts +2 -2
  6. package/dist/components/element-cover/CElementCover.d.ts +3 -7
  7. package/dist/components/element-cover/index.d.ts +2 -0
  8. package/dist/components/form/CFormInput.d.ts +1 -1
  9. package/dist/components/form/CFormSwitch.d.ts +1 -1
  10. package/dist/components/index.d.ts +2 -0
  11. package/dist/components/nav/CNavGroup.d.ts +4 -4
  12. package/dist/components/offcanvas/COffcanvas.d.ts +8 -2
  13. package/dist/components/sidebar/CSidebar.d.ts +4 -4
  14. package/dist/components/smart-table/CSmartTableBody.d.ts +6 -5
  15. package/dist/components/smart-table/CSmartTableHead.d.ts +6 -3
  16. package/dist/components/smart-table/CSmartTableInterface.d.ts +46 -109
  17. package/dist/components/smart-table/types.d.ts +53 -0
  18. package/dist/components/smart-table/utils.d.ts +16 -0
  19. package/dist/components/table/CTable.d.ts +5 -5
  20. package/dist/components/time-picker/types.d.ts +15 -0
  21. package/dist/components/time-picker/utils.d.ts +23 -0
  22. package/dist/hooks/index.d.ts +3 -0
  23. package/dist/hooks/useForkedRef.d.ts +7 -0
  24. package/dist/hooks/useStateWithCallback.d.ts +2 -0
  25. package/dist/index.es.js +1246 -1865
  26. package/dist/index.es.js.map +1 -1
  27. package/dist/index.js +1246 -1863
  28. package/dist/index.js.map +1 -1
  29. package/dist/utils/index.d.ts +3 -2
  30. package/dist/utils/isInViewport.d.ts +2 -0
  31. package/dist/utils/isObjectInArray.d.ts +2 -0
  32. package/package.json +14 -14
  33. package/src/components/accordion/CAccordionBody.tsx +1 -1
  34. package/src/components/alert/CAlert.tsx +1 -1
  35. package/src/components/backdrop/CBackdrop.tsx +1 -1
  36. package/src/components/calendar/CCalendar.tsx +351 -240
  37. package/src/components/calendar/index.ts +3 -0
  38. package/src/{utils/calendar.ts → components/calendar/utils.ts} +1 -1
  39. package/src/components/carousel/CCarousel.tsx +4 -4
  40. package/src/components/carousel/CCarouselItem.tsx +1 -1
  41. package/src/components/collapse/CCollapse.tsx +1 -1
  42. package/src/components/date-picker/CDatePicker.tsx +1 -1
  43. package/src/components/date-range-picker/CDateRangePicker.tsx +3 -3
  44. package/src/components/dropdown/CDropdown.tsx +1 -1
  45. package/src/components/dropdown/CDropdownToggle.tsx +1 -1
  46. package/src/components/element-cover/CElementCover.tsx +19 -25
  47. package/src/components/element-cover/index.ts +3 -0
  48. package/src/components/form/CFormCheck.tsx +1 -1
  49. package/src/components/form/CFormControlWrapper.tsx +14 -20
  50. package/src/components/form/CFormInput.tsx +1 -1
  51. package/src/components/form/CFormSwitch.tsx +1 -1
  52. package/src/components/grid/CCol.tsx +4 -0
  53. package/src/components/index.ts +2 -0
  54. package/src/components/modal/CModal.tsx +1 -1
  55. package/src/components/nav/CNavGroup.tsx +4 -4
  56. package/src/components/nav/CNavLink.tsx +2 -1
  57. package/src/components/offcanvas/COffcanvas.tsx +36 -18
  58. package/src/components/sidebar/CSidebar.tsx +10 -10
  59. package/src/components/smart-table/CSmartTable.tsx +279 -259
  60. package/src/components/smart-table/CSmartTableBody.tsx +31 -41
  61. package/src/components/smart-table/CSmartTableCleaner.tsx +1 -1
  62. package/src/components/smart-table/CSmartTableFilter.tsx +1 -3
  63. package/src/components/smart-table/CSmartTableHead.tsx +53 -103
  64. package/src/components/smart-table/CSmartTableInterface.tsx +57 -120
  65. package/src/components/smart-table/CSmartTableItemsPerPageSelector.tsx +1 -2
  66. package/src/components/smart-table/types.tsx +65 -0
  67. package/src/components/smart-table/utils.tsx +199 -0
  68. package/src/components/table/CTable.tsx +12 -9
  69. package/src/components/tabs/CTabPane.tsx +1 -1
  70. package/src/components/time-picker/CTimePicker.tsx +50 -23
  71. package/src/components/time-picker/CTimePickerRollCol.tsx +1 -1
  72. package/src/components/time-picker/types.ts +15 -0
  73. package/src/{utils/time.ts → components/time-picker/utils.ts} +43 -2
  74. package/src/components/toast/CToast.tsx +1 -1
  75. package/src/components/virtual-scroller/CVirtualScroller.tsx +1 -1
  76. package/src/{utils/hooks → hooks}/index.ts +0 -0
  77. package/src/{utils/hooks → hooks}/useForkedRef.ts +0 -0
  78. package/src/{utils/hooks → hooks}/useStateWithCallback.ts +0 -0
  79. package/src/utils/index.ts +3 -2
  80. package/src/utils/isInViewport.ts +11 -0
  81. package/src/utils/isObjectInArray.ts +14 -0
  82. package/src/utils/isVisible.ts +0 -11
package/README.md CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  Several quick start options are available:
44
44
 
45
- - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.8.0-alpha.3.zip)
45
+ - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.9.0-next.0.zip)
46
46
  - Clone the repo: `git clone https://github.com/coreui/coreui-react.git`
47
47
  - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react`
48
48
  - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react`
@@ -0,0 +1,2 @@
1
+ import { CCalendar } from './CCalendar';
2
+ export { CCalendar };
@@ -0,0 +1,23 @@
1
+ export declare const convertToLocalDate: (d: Date, locale: string, options?: {}) => string;
2
+ export declare const convertToLocalTime: (d: Date, locale: string, options?: {}) => string;
3
+ export declare const createGroupsInArray: <T>(arr: T[], numberOfGroups: number) => T[][];
4
+ export declare const getCurrentYear: () => number;
5
+ export declare const getCurrentMonth: () => number;
6
+ export declare const getLocalDateFromString: (string: string, locale: string, time?: boolean) => Date | undefined;
7
+ export declare const getMonthName: (month: number, locale: string) => string;
8
+ export declare const getMonthsNames: (locale: string) => string[];
9
+ export declare const getYears: (year: number) => number[];
10
+ export declare const getMonthDetails: (year: number, month: number, firstDayOfWeek: number) => {
11
+ date: Date;
12
+ month: string;
13
+ }[][];
14
+ export declare const isDisableDateInRange: (startDate?: Date | null, endDate?: Date | null, dates?: Date[] | Date[][] | (Date | Date[])[]) => boolean;
15
+ export declare const isDateDisabled: (date: Date, min?: Date | null, max?: Date | null, dates?: Date[] | Date[][] | (Date | Date[])[]) => boolean | undefined;
16
+ export declare const isDateInRange: (date: Date, start: Date | null, end: Date | null) => boolean | null;
17
+ export declare const isDateSelected: (date: Date, start: Date | null, end: Date | null) => boolean | null;
18
+ export declare const isEndDate: (date: Date, start: Date | null, end: Date | null) => boolean | null;
19
+ export declare const isLastDayOfMonth: (date: Date) => boolean;
20
+ export declare const isSameDateAs: (date: Date | null, date2: Date | null) => boolean;
21
+ export declare const isStartDate: (date: Date, start: Date | null, end: Date | null) => boolean | null;
22
+ export declare const isToday: (date: Date) => boolean;
23
+ export declare const isValidDate: (date: string) => number | false;
@@ -9,7 +9,7 @@ export interface CDatePickerProps extends Omit<CDateRangePickerProps, 'calendars
9
9
  * The id global attribute defines an identifier (ID) that must be unique in the whole document.
10
10
  *
11
11
  * The name attribute for the input element is generated based on the `id` property:
12
- * - {id}-date
12
+ * - \{id\}-date
13
13
  */
14
14
  id?: string;
15
15
  /**
@@ -31,8 +31,8 @@ export interface CDateRangePickerProps extends Omit<CFormControlWrapperProps, 'f
31
31
  * The id global attribute defines an identifier (ID) that must be unique in the whole document.
32
32
  *
33
33
  * The name attributes for input elements are generated based on the `id` property:
34
- * - {id}-start-date
35
- * - {id}-end-date
34
+ * - \{id\}-start-date
35
+ * - \{id\}-end-date
36
36
  */
37
37
  id?: string;
38
38
  /**
@@ -1,24 +1,20 @@
1
1
  import React, { HTMLAttributes } from 'react';
2
2
  interface CElementCoverProps extends HTMLAttributes<HTMLDivElement> {
3
3
  /**
4
- * A string of all className you want applied to the base component. [docs]
4
+ * A string of all className you want applied to the base component.
5
5
  */
6
6
  className?: string;
7
7
  /**
8
8
  * Array of custom boundaries. Use to create custom cover area (instead of parent element area). Area is defined by four sides: 'top', 'bottom', 'right', 'left'. If side is not defined by any custom boundary it is equal to parent element boundary. Each custom boundary is object with keys:
9
9
  * - sides (array) - select boundaries of element to define boundaries. Sides names: 'top', 'bottom', 'right', 'left'.
10
- * - query (string) - query used to get element which define boundaries. Search will be done only inside parent element, by parent.querySelector(query) function. [docs]
11
- *
12
- * @type {sides: string[], query: string}[]
10
+ * - query (string) - query used to get element which define boundaries. Search will be done only inside parent element, by parent.querySelector(query) function.
13
11
  */
14
12
  boundaries?: {
15
13
  sides: string[];
16
14
  query: string;
17
15
  }[];
18
16
  /**
19
- * Opacity of the cover. [docs]
20
- *
21
- * @type number
17
+ * Opacity of the cover.
22
18
  */
23
19
  opacity?: number;
24
20
  }
@@ -0,0 +1,2 @@
1
+ import { CElementCover } from './CElementCover';
2
+ export { CElementCover };
@@ -18,7 +18,7 @@ export interface CFormInputProps extends CFormControlWrapperProps, Omit<InputHTM
18
18
  */
19
19
  onChange?: ChangeEventHandler<HTMLInputElement>;
20
20
  /**
21
- * Render the component styled as plain text. Removes the default form field styling and preserve the correct margin and padding. Recommend to use only along side `readonly` [docs]
21
+ * Render the component styled as plain text. Removes the default form field styling and preserve the correct margin and padding. Recommend to use only along side `readonly`.
22
22
  */
23
23
  plainText?: boolean;
24
24
  /**
@@ -17,7 +17,7 @@ export interface CFormSwitchProps extends Omit<InputHTMLAttributes<HTMLInputElem
17
17
  */
18
18
  label?: string | ReactNode;
19
19
  /**
20
- * Size the component large or extra large. Works only with `switch` [docs]
20
+ * Size the component large or extra large. Works only with `switch`.
21
21
  */
22
22
  size?: 'lg' | 'xl';
23
23
  /**
@@ -14,6 +14,7 @@ export * from './collapse';
14
14
  export * from './date-picker';
15
15
  export * from './date-range-picker';
16
16
  export * from './dropdown';
17
+ export * from './element-cover';
17
18
  export * from './footer';
18
19
  export * from './form';
19
20
  export * from './grid';
@@ -40,4 +41,5 @@ export * from './tabs';
40
41
  export * from './time-picker';
41
42
  export * from './toast';
42
43
  export * from './tooltip';
44
+ export * from './virtual-scroller';
43
45
  export * from './widgets';
@@ -2,19 +2,19 @@ import React, { ReactNode } from 'react';
2
2
  export interface CNavGroupProps {
3
3
  children?: ReactNode;
4
4
  /**
5
- * A string of all className you want applied to the component. [docs]
5
+ * A string of all className you want applied to the component.
6
6
  */
7
7
  className?: string;
8
8
  /**
9
- * Make nav group more compact by cutting all `padding` in half. [docs]
9
+ * Make nav group more compact by cutting all `padding` in half.
10
10
  */
11
11
  compact?: boolean;
12
12
  /**
13
- * Set group toggler label. [docs]
13
+ * Set group toggler label.
14
14
  */
15
15
  toggler?: string | ReactNode;
16
16
  /**
17
- * Show nav group items. [docs]
17
+ * Show nav group items.
18
18
  */
19
19
  visible?: boolean;
20
20
  /**
@@ -3,13 +3,13 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
3
3
  /**
4
4
  * Apply a backdrop on body while offcanvas is open.
5
5
  */
6
- backdrop?: boolean;
6
+ backdrop?: boolean | 'static';
7
7
  /**
8
8
  * A string of all className you want applied to the base component.
9
9
  */
10
10
  className?: string;
11
11
  /**
12
- * Closes the offcanvas when escape key is pressed [docs]
12
+ * Closes the offcanvas when escape key is pressed.
13
13
  */
14
14
  keyboard?: boolean;
15
15
  /**
@@ -28,6 +28,12 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
28
28
  * Generates modal using createPortal.
29
29
  */
30
30
  portal?: boolean;
31
+ /**
32
+ * Responsive offcanvas property hide content outside the viewport from a specified breakpoint and down.
33
+ *
34
+ * @since 4.6.0
35
+ */
36
+ responsive?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
31
37
  /**
32
38
  * Allow body scrolling while offcanvas is open
33
39
  */
@@ -5,13 +5,13 @@ export interface CSidebarProps extends HTMLAttributes<HTMLDivElement> {
5
5
  */
6
6
  className?: string;
7
7
  /**
8
- * Sets if the color of text should be colored for a light or dark dark background. [docs]
8
+ * Sets if the color of text should be colored for a light or dark dark background.
9
9
  *
10
10
  * @type 'dark' | 'light'
11
11
  */
12
12
  colorScheme?: 'dark' | 'light';
13
13
  /**
14
- * Make sidebar narrow. [docs]
14
+ * Make sidebar narrow.
15
15
  */
16
16
  narrow?: boolean;
17
17
  /**
@@ -31,12 +31,12 @@ export interface CSidebarProps extends HTMLAttributes<HTMLDivElement> {
31
31
  */
32
32
  overlaid?: boolean;
33
33
  /**
34
- * Components placement, there’s no default placement. [docs]
34
+ * Components placement, there’s no default placement.
35
35
  * @type 'start' | 'end'
36
36
  */
37
37
  placement?: 'start' | 'end';
38
38
  /**
39
- * Place sidebar in non-static positions. [docs]
39
+ * Place sidebar in non-static positions.
40
40
  */
41
41
  position?: 'fixed' | 'sticky';
42
42
  /**
@@ -1,15 +1,16 @@
1
1
  import React, { MouseEvent, ReactNode } from 'react';
2
2
  import { CTableBodyProps } from '../table/CTableBody';
3
- import { ItemInternal, ScopedColumns } from './CSmartTableInterface';
3
+ import type { Item, ScopedColumns } from './types';
4
4
  export interface CSmartTableBodyProps extends CTableBodyProps {
5
5
  clickableRows?: boolean;
6
- currentItems: ItemInternal[];
6
+ columnNames: string[];
7
+ currentItems: Item[];
7
8
  firstItemOnActivePageIndex: number;
8
9
  noItemsLabel?: string | ReactNode;
9
- onRowChecked?: (id: number, value: boolean) => void;
10
- onRowClick?: (item: ItemInternal, index: number, columnName: string, event: MouseEvent | boolean) => void;
11
- rawColumnNames: string[];
10
+ onRowChecked?: (item: Item, value: boolean) => void;
11
+ onRowClick?: (item: Item, index: number, columnName: string, event: MouseEvent | boolean) => void;
12
12
  scopedColumns?: ScopedColumns;
13
13
  selectable?: boolean;
14
+ selected?: Item[];
14
15
  }
15
16
  export declare const CSmartTableBody: React.ForwardRefExoticComponent<CSmartTableBodyProps & React.RefAttributes<HTMLTableSectionElement>>;
@@ -1,5 +1,5 @@
1
1
  import React, { ElementType, ReactNode } from 'react';
2
- import { ColumnFilter, ColumnFilterValue, Column, ItemInternal, Sorter, SorterValue } from './CSmartTableInterface';
2
+ import type { ColumnFilter, ColumnFilterValue, Column, Item, Sorter, SorterValue } from './types';
3
3
  import { CTableHeadProps } from '../table/CTableHead';
4
4
  export interface CSmartTableHeadProps extends CTableHeadProps {
5
5
  columnFilter?: boolean | ColumnFilter;
@@ -12,9 +12,12 @@ export interface CSmartTableHeadProps extends CTableHeadProps {
12
12
  handleFilterOnInput?: (key: string, value: string) => void;
13
13
  handleSelectAllChecked?: () => void;
14
14
  handleSort?: (key: string, index: number) => void;
15
- items: ItemInternal[];
15
+ items: Item[];
16
16
  selectable?: boolean;
17
- selectAll?: boolean | string;
17
+ selectAll?: boolean | {
18
+ external?: boolean;
19
+ };
20
+ selectedAll?: boolean | string;
18
21
  sorterState?: SorterValue;
19
22
  sortingIcon?: ReactNode;
20
23
  sortingIconAscending?: ReactNode;
@@ -3,66 +3,11 @@ import { CSmartPaginationProps } from '../smart-pagination/CSmartPagination';
3
3
  import { CTableProps } from '../table/CTable';
4
4
  import { CTableBodyProps } from '../table/CTableBody';
5
5
  import { CTableFootProps } from '../table/CTableFoot';
6
- import { CTableHeaderCellProps } from '../table/CTableHeaderCell';
7
- import { CTableRowProps } from '../table/CTableRow';
8
6
  import { CTableHeadProps } from '../table/CTableHead';
9
- export interface Column {
10
- filter?: boolean | ((values: any[], onChange: (value: any) => void) => ReactNode);
11
- label?: string;
12
- key: string;
13
- sorter?: boolean;
14
- _style?: any;
15
- _props?: CTableHeaderCellProps;
16
- }
17
- export interface ColumnFilter {
18
- lazy?: boolean;
19
- external?: boolean;
20
- }
21
- export interface ColumnFilterValue {
22
- [key: string]: any;
23
- }
24
- export interface Item {
25
- [key: string]: number | string | any;
26
- _cellProps?: any;
27
- _props?: CTableRowProps;
28
- _selected?: boolean;
29
- }
30
- export interface ItemInternal extends Item {
31
- _id: number;
32
- }
33
- export interface ItemsPerPageSelect {
34
- external?: boolean;
35
- label?: string;
36
- values?: Array<number>;
37
- }
38
- export interface Pagination {
39
- external?: boolean;
40
- }
41
- export interface Sorter {
42
- resetable?: boolean;
43
- external?: boolean;
44
- }
45
- export interface ScopedColumns {
46
- [key: string]: any;
47
- details?: (a: Item, b: number) => ReactNode;
48
- }
49
- export interface SorterValue {
50
- column?: string;
51
- state?: number | string;
52
- }
53
- export interface TableFilter {
54
- lazy?: boolean;
55
- external?: boolean;
56
- }
57
- export interface NoItemsView {
58
- noResults?: string;
59
- noItems?: string;
60
- }
7
+ import type { Column, ColumnFilter, ColumnFilterValue, FooterItem, Item, ItemsPerPageSelect, Pagination, Sorter, ScopedColumns, SorterValue, TableFilter } from './types';
61
8
  export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
62
9
  /**
63
10
  * Sets active page. If 'pagination' prop is enabled, activePage is set only initially.
64
- *
65
- * @default 1
66
11
  */
67
12
  activePage?: number;
68
13
  /**
@@ -72,8 +17,6 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
72
17
  cleaner?: boolean;
73
18
  /**
74
19
  * Style table items as clickable.
75
- *
76
- * @type boolean
77
20
  */
78
21
  clickableRows?: boolean;
79
22
  /**
@@ -81,13 +24,11 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
81
24
  * Column filter can be customized, by passing prop as object with additional options as keys. Available options:
82
25
  * - external (Boolean) - Disables automatic filtering inside component.
83
26
  * - lazy (Boolean) - Set to true to trigger filter updates only on change event.
84
- *
85
- * @type boolean | ColumnFilter
86
27
  */
87
28
  columnFilter?: boolean | ColumnFilter;
88
29
  /**
89
30
  * Value of table filter. To set pass object where keys are column names and values are filter strings e.g.:
90
- * { user: 'John', age: 12 }
31
+ * `{ user: 'John', age: 12 }`
91
32
  */
92
33
  columnFilterValue?: ColumnFilterValue;
93
34
  /**
@@ -110,46 +51,49 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
110
51
  * Sorter can be customized, by passing prop as object with additional options as keys. Available options:
111
52
  * - external (Boolean) - Disables automatic sorting inside component.
112
53
  * - resetable (Boolean) - If set to true clicking on sorter have three states: ascending, descending and null. That means that third click on sorter will reset sorting, and restore table to original order.
113
- *
114
- * @type boolean | Sorter
115
54
  */
116
55
  columnSorter?: boolean | Sorter;
117
56
  /**
118
- * Displays table footer, which mirrors table header. (without column filter).
57
+ * ReactNode for passing custom CElementCover content.
58
+ *
59
+ * @since 4.9.0
119
60
  */
120
- footer?: boolean;
61
+ elementCover?: ReactNode;
121
62
  /**
122
- * Set to false to remove table header.
63
+ * If `true` Displays table footer, which mirrors table header. (without column filter).
64
+ * Or Array of objects or strings, where each element represents one cell in the table footer.
123
65
  *
124
- * @default true
66
+ * Example items:
67
+ * `['FooterCell', 'FooterCell', 'FooterCell']`
68
+ * or
69
+ * `[{ label: 'FooterCell', _props: { color: 'success' }, ...]`
70
+ */
71
+ footer?: boolean | (FooterItem | string)[];
72
+ /**
73
+ * Set to false to remove table header.
125
74
  */
126
75
  header?: boolean;
127
76
  /**
128
- * Array of objects, where each object represents one item - row in table. Additionally, you can add style classes to each row by passing them by '_classes' key and to single cell by '_cellClasses'.
77
+ * Array of objects, where each object represents one item - row in table. Additionally, you can add style classes to each row by passing them by '_props' key and to single cell by '_cellProps'.
129
78
  *
130
79
  * Example item:
131
- * { name: 'John' , age: 12, _props: { color: 'success' }, _cellProps: { age: { className: 'fw-bold'}}}
132
- * For column generation description watch columns prop.
133
- *
134
- * @type Array<string>
80
+ * `{ name: 'John' , age: 12, _props: { color: 'success' }, _cellProps: { age: { className: 'fw-bold'}}}`
135
81
  */
136
82
  items?: Item[];
83
+ /**
84
+ * The total number of items. Use if you pass a portion of data from an external source to let know component what is the total number of items.
85
+ */
86
+ itemsNumber?: number;
137
87
  /**
138
88
  * Number of items per site, when pagination is enabled.
139
- *
140
- * @default 10
141
89
  */
142
90
  itemsPerPage?: number;
143
91
  /**
144
92
  * Label for items per page selector.
145
- *
146
- * @default 'Items per page:'
147
93
  */
148
94
  itemsPerPageLabel?: string;
149
95
  /**
150
96
  * Items per page selector options.
151
- *
152
- * @default [5, 10, 20, 50]
153
97
  */
154
98
  itemsPerPageOptions?: number[];
155
99
  /**
@@ -165,7 +109,6 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
165
109
  loading?: boolean;
166
110
  /**
167
111
  * ReactNode or string for passing custom noItemsLabel texts.
168
- * @default 'No items found'
169
112
  */
170
113
  noItemsLabel?: string | ReactNode;
171
114
  /**
@@ -188,6 +131,10 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
188
131
  * Row click callback.
189
132
  */
190
133
  onRowClick?: (item: Item, index: number, columnName: string, event: MouseEvent | boolean) => void;
134
+ /**
135
+ * Select all callback.
136
+ */
137
+ onSelectAll?: () => void;
191
138
  /**
192
139
  * Selected items change callback.
193
140
  */
@@ -205,15 +152,11 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
205
152
  */
206
153
  pagination?: boolean | Pagination;
207
154
  /**
208
- * Properties to `CSmartPagination` component.
209
- *
210
- * @link https://coreui.io/react/docs/components/smart-pagination#csmartpagination
155
+ * Properties to `CSmartPagination` component - https://coreui.io/react/docs/components/smart-pagination#csmartpagination
211
156
  */
212
157
  paginationProps?: CSmartPaginationProps;
213
158
  /**
214
159
  * Scoped columns.
215
- *
216
- * @type scopedColumns
217
160
  */
218
161
  scopedColumns?: ScopedColumns;
219
162
  /**
@@ -221,39 +164,42 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
221
164
  */
222
165
  selectable?: boolean;
223
166
  /**
224
- * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'.
167
+ * Enables select all checkbox displayed in the header of the table.
168
+ *
169
+ * Can be customized, by passing prop as object with additional options as keys. Available options:
170
+ * - external (Boolean) - Disables automatic selection inside the component.
171
+ */
172
+ selectAll?: boolean | {
173
+ external?: boolean;
174
+ };
175
+ /**
176
+ * Array of selected objects, where each object represents one item - row in table.
225
177
  *
226
- * @type SorterValue
178
+ * Example item: `{ name: 'John' , age: 12 }`
179
+ */
180
+ selected?: Item[];
181
+ /**
182
+ * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'.
227
183
  */
228
184
  sorterValue?: SorterValue;
229
185
  /**
230
186
  * Sorter icon when items are unsorted.
231
- *
232
- * @default '<CIcon width="18" content={cilArrowTop} />
233
187
  */
234
188
  sortingIcon?: ReactNode;
235
189
  /**
236
190
  * Sorter icon when items are sorted ascending.
237
- *
238
- * @default '<CIcon width="18" content={cilArrowTop} />
239
191
  */
240
192
  sortingIconAscending?: ReactNode;
241
193
  /**
242
194
  * Sorter icon when items are sorted descending.
243
- *
244
- * @default '<CIcon width="18" content={cilArrowBottom} />'
245
195
  */
246
196
  sortingIconDescending?: ReactNode;
247
197
  /**
248
- * Properties to `CTableBody` component.
249
- *
250
- * @link https://coreui.io/react/docs/components/table/#ctablebody
198
+ * Properties to `CTableBody` component - https://coreui.io/react/docs/components/table/#ctablebody
251
199
  */
252
200
  tableBodyProps?: CTableBodyProps;
253
201
  /**
254
- * Properties to `CTableFoot` component.
255
- *
256
- * @link https://coreui.io/react/docs/components/table/#ctablefoot
202
+ * Properties to `CTableFoot` component - https://coreui.io/react/docs/components/table/#ctablefoot
257
203
  */
258
204
  tableFootProps?: CTableFootProps;
259
205
  /**
@@ -266,31 +212,22 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
266
212
  tableFilter?: boolean | TableFilter;
267
213
  /**
268
214
  * The element represents a caption for a component.
269
- *
270
- * @default 'Filter:'
271
215
  */
272
216
  tableFilterLabel?: string;
273
217
  /**
274
218
  * Specifies a short hint that is visible in the search input.
275
- *
276
- * @default 'type string...'
277
219
  */
278
220
  tableFilterPlaceholder?: string;
279
221
  /**
280
222
  * Value of table filter.
281
- *
282
223
  */
283
224
  tableFilterValue?: string;
284
225
  /**
285
- * Properties to `CTableHead` component.
286
- *
287
- * @link https://coreui.io/react/docs/components/table/#ctablehead
226
+ * Properties to `CTableHead` component - https://coreui.io/react/docs/components/table/#ctablehead
288
227
  */
289
228
  tableHeadProps?: CTableHeadProps;
290
229
  /**
291
- * Properties to `CTable` component.
292
- *
293
- * @link https://coreui.io/react/docs/components/table/#ctable
230
+ * Properties to `CTable` component - https://coreui.io/react/docs/components/table/#ctable
294
231
  */
295
232
  tableProps?: CTableProps;
296
233
  }
@@ -0,0 +1,53 @@
1
+ import { ReactNode } from 'react';
2
+ import { CTableDataCellProps } from '../table/CTableDataCell';
3
+ import { CTableHeaderCellProps } from '../table/CTableHeaderCell';
4
+ import { CTableRowProps } from '../table/CTableRow';
5
+ export type Column = {
6
+ filter?: boolean | ((values: any[], onChange: (value: any) => void) => ReactNode);
7
+ label?: string;
8
+ key: string;
9
+ sorter?: boolean;
10
+ _style?: any;
11
+ _props?: CTableHeaderCellProps;
12
+ };
13
+ export type ColumnFilter = {
14
+ lazy?: boolean;
15
+ external?: boolean;
16
+ };
17
+ export type ColumnFilterValue = {
18
+ [key: string]: any;
19
+ };
20
+ export type FooterItem = {
21
+ label?: string;
22
+ _props?: CTableDataCellProps;
23
+ };
24
+ export type Item = {
25
+ [key: string]: number | string | any;
26
+ _cellProps?: any;
27
+ _props?: CTableRowProps;
28
+ _selected?: boolean;
29
+ };
30
+ export type ItemsPerPageSelect = {
31
+ external?: boolean;
32
+ label?: string;
33
+ values?: Array<number>;
34
+ };
35
+ export type Pagination = {
36
+ external?: boolean;
37
+ };
38
+ export type Sorter = {
39
+ resetable?: boolean;
40
+ external?: boolean;
41
+ };
42
+ export type ScopedColumns = {
43
+ [key: string]: any;
44
+ details?: (a: Item, b: number) => ReactNode;
45
+ };
46
+ export type SorterValue = {
47
+ column?: string;
48
+ state?: number | string;
49
+ };
50
+ export type TableFilter = {
51
+ lazy?: boolean;
52
+ external?: boolean;
53
+ };
@@ -0,0 +1,16 @@
1
+ import type { Column, ColumnFilter, ColumnFilterValue, Item, Sorter, SorterValue, TableFilter } from './types';
2
+ export declare const filterColumns: (items: Item[], columnFilter: boolean | ColumnFilter | undefined, columnFilterState: ColumnFilterValue, itemsDataColumns: string[]) => Item[];
3
+ export declare const filterTable: (items: Item[], tableFilter: boolean | TableFilter | undefined, tableFilterState: string, itemsDataColumns: string[]) => Item[];
4
+ export declare const getClickedColumnName: (target: HTMLTextAreaElement, columnNames: string[]) => string;
5
+ export declare const getColumnKey: (column: Column | string) => string;
6
+ export declare const getColumnLabel: (column: Column | string) => string;
7
+ export declare const getColumnNames: (columns: (string | Column)[] | undefined, items: Item[]) => string[];
8
+ export declare const getColumnNamesFromItems: (items: Item[]) => string[];
9
+ export declare const getColumnSorterState: (key: string, sorterState: SorterValue | undefined) => string | number;
10
+ export declare const getColumnValues: (items: Item[], key: string) => any[];
11
+ export declare const getTableDataCellProps: (item: Item, colName: string) => any;
12
+ export declare const getTableHeaderCellProps: (column: Column | string) => import("../table/CTableHeaderCell").CTableHeaderCellProps;
13
+ export declare const getTableHeaderCellStyles: (column: Column | string, columnSorter: boolean | Sorter | undefined) => any;
14
+ export declare const isSortable: (i: number, columns: (string | Column)[] | undefined, columnSorter: Sorter | boolean | undefined, itemsDataColumns: string[], columnNames: string[]) => boolean | undefined;
15
+ export declare const pretifyName: (name: string) => string;
16
+ export declare const sortItems: (columnSorter: boolean | Sorter | undefined, items: Item[], itemsDataColumns: string[], sorterState: SorterValue) => Item[];
@@ -46,7 +46,7 @@ export interface CTableProps extends Omit<TableHTMLAttributes<HTMLTableElement>,
46
46
  * Object: item is object with following keys available as column configuration:
47
47
  * - key (required)(String) - define column name equal to item key.
48
48
  * - label (String) - define visible label of column. If not defined, label will be generated automatically based on column name, by converting kebab-case and snake_case to individual words and capitalization of each word.
49
- * - _props (Object) - adds classes to all cels in column, ex. _props: { scope: 'col', className: 'custom-class' },
49
+ * - _props (Object) - adds classes to all cels in column, ex. `_props: { scope: 'col', className: 'custom-class' }`,
50
50
  * - _style (Object) - adds styles to the column header (useful for defining widths)
51
51
  *
52
52
  * @since 4.3.0
@@ -62,13 +62,13 @@ export interface CTableProps extends Omit<TableHTMLAttributes<HTMLTableElement>,
62
62
  * Array of objects or strings, where each element represents one cell in the table footer.
63
63
  *
64
64
  * Example items:
65
- * ['FooterCell', 'FooterCell', 'FooterCell']
65
+ * `['FooterCell', 'FooterCell', 'FooterCell']`
66
66
  * or
67
- * [{ label: 'FooterCell', _props: { color: 'success' }, ...]
67
+ * `[{ label: 'FooterCell', _props: { color: 'success' }, ...]`
68
68
  *
69
69
  * @since 4.3.0
70
70
  */
71
- footer?: FooterItem[];
71
+ footer?: (FooterItem | string)[];
72
72
  /**
73
73
  * Enable a hover state on table rows within a `<CTableBody>`.
74
74
  */
@@ -77,7 +77,7 @@ export interface CTableProps extends Omit<TableHTMLAttributes<HTMLTableElement>,
77
77
  * Array of objects, where each object represents one item - row in table. Additionally, you can add style classes to each row by passing them by '_props' key and to single cell by '_cellProps'.
78
78
  *
79
79
  * Example item:
80
- * { name: 'John' , age: 12, _props: { color: 'success' }, _cellProps: { age: { className: 'fw-bold'}}}
80
+ * `{ name: 'John' , age: 12, _props: { color: 'success' }, _cellProps: { age: { className: 'fw-bold'}}}`
81
81
  *
82
82
  * @since 4.3.0
83
83
  */