@coreui/react-pro 5.0.0-alpha.0 → 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 (53) hide show
  1. package/README.md +1 -1
  2. package/dist/components/calendar/CCalendar.d.ts +25 -7
  3. package/dist/components/calendar/utils.d.ts +12 -3
  4. package/dist/components/close-button/CCloseButton.d.ts +6 -0
  5. package/dist/components/modal/CModal.d.ts +6 -0
  6. package/dist/components/multi-select/types.d.ts +2 -2
  7. package/dist/components/multi-select/utils.d.ts +2 -2
  8. package/dist/components/nav/CNav.d.ts +1 -1
  9. package/dist/components/navbar/CNavbar.d.ts +1 -1
  10. package/dist/components/offcanvas/COffcanvas.d.ts +4 -0
  11. package/dist/components/smart-table/CSmartTableBody.d.ts +2 -1
  12. package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -3
  13. package/dist/components/smart-table/types.d.ts +2 -2
  14. package/dist/components/smart-table/utils.d.ts +3 -1
  15. package/dist/index.es.js +1388 -1097
  16. package/dist/index.es.js.map +1 -1
  17. package/dist/index.js +1388 -1097
  18. package/dist/index.js.map +1 -1
  19. package/dist/utils/executeAfterTransition.d.ts +2 -0
  20. package/dist/utils/getTransitionDurationFromElement.d.ts +2 -0
  21. package/dist/utils/index.d.ts +3 -1
  22. package/package.json +2 -2
  23. package/src/components/calendar/CCalendar.tsx +396 -193
  24. package/src/components/calendar/utils.ts +91 -4
  25. package/src/components/carousel/CCarousel.tsx +9 -5
  26. package/src/components/close-button/CCloseButton.tsx +9 -1
  27. package/src/components/date-range-picker/CDateRangePicker.tsx +49 -45
  28. package/src/components/dropdown/CDropdownMenu.tsx +1 -1
  29. package/src/components/modal/CModal.tsx +25 -9
  30. package/src/components/multi-select/CMultiSelect.tsx +3 -3
  31. package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
  32. package/src/components/multi-select/CMultiSelectOptions.tsx +1 -1
  33. package/src/components/multi-select/CMultiSelectSelection.tsx +3 -3
  34. package/src/components/multi-select/types.ts +2 -2
  35. package/src/components/multi-select/utils.ts +5 -5
  36. package/src/components/nav/CNav.tsx +2 -2
  37. package/src/components/nav/CNavGroup.tsx +9 -2
  38. package/src/components/navbar/CNavbar.tsx +2 -2
  39. package/src/components/offcanvas/COffcanvas.tsx +8 -1
  40. package/src/components/popover/CPopover.tsx +2 -2
  41. package/src/components/sidebar/CSidebar.tsx +1 -1
  42. package/src/components/smart-table/CSmartTable.tsx +2 -1
  43. package/src/components/smart-table/CSmartTableBody.tsx +11 -5
  44. package/src/components/smart-table/CSmartTableInterface.tsx +1 -3
  45. package/src/components/smart-table/types.ts +2 -2
  46. package/src/components/smart-table/utils.ts +40 -5
  47. package/src/components/time-picker/CTimePicker.tsx +2 -2
  48. package/src/components/time-picker/utils.ts +5 -1
  49. package/src/components/tooltip/CTooltip.tsx +2 -2
  50. package/src/hooks/usePopper.ts +10 -2
  51. package/src/utils/executeAfterTransition.ts +46 -0
  52. package/src/utils/getTransitionDurationFromElement.ts +24 -0
  53. package/src/utils/index.ts +10 -1
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/v5.0.0-alpha.0.zip)
45
+ - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v5.0.0-alpha.1.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`
@@ -3,7 +3,7 @@ export interface CCalendarProps {
3
3
  /**
4
4
  * Default date of the component
5
5
  */
6
- calendarDate?: Date | string;
6
+ calendarDate?: Date | string | null;
7
7
  /**
8
8
  * The number of calendars that render on desktop devices.
9
9
  */
@@ -80,6 +80,10 @@ export interface CCalendarProps {
80
80
  * @since 4.3.0
81
81
  */
82
82
  navYearFirst?: boolean;
83
+ /**
84
+ * Allow range selection.
85
+ */
86
+ range?: boolean;
83
87
  /**
84
88
  * Set whether days in adjacent months shown before or after the current month are selectable. This only applies if the `showAdjacementDays` option is set to true.
85
89
  *
@@ -93,13 +97,21 @@ export interface CCalendarProps {
93
97
  */
94
98
  showAdjacementDays?: boolean;
95
99
  /**
96
- * Allow range selection.
100
+ * Set whether to display week numbers in the calendar.
101
+ *
102
+ * @since 5.0.0-alpha.1
97
103
  */
98
- range?: boolean;
104
+ showWeekNumber?: boolean;
99
105
  /**
100
106
  * Toggle select mode between start and end date.
101
107
  */
102
108
  selectEndDate?: boolean;
109
+ /**
110
+ * Specify the type of date selection as day, week, month, or year.
111
+ *
112
+ * @since 5.0.0-alpha.1
113
+ */
114
+ selectionType?: 'day' | 'week' | 'month' | 'year';
103
115
  /**
104
116
  * Initial selected date.
105
117
  */
@@ -110,22 +122,28 @@ export interface CCalendarProps {
110
122
  * @default 2
111
123
  */
112
124
  weekdayFormat?: number | 'long' | 'narrow' | 'short' | ((date: Date) => string | number);
125
+ /**
126
+ * Label displayed over week numbers in the calendar.
127
+ *
128
+ * @since 5.0.0-alpha.1
129
+ */
130
+ weekNumbersLabel?: string;
113
131
  /**
114
132
  * Callback fired when the calendar date changed.
115
133
  */
116
- onCalendarDateChange?: (date: Date) => void;
134
+ onCalendarDateChange?: (date: Date | string) => void;
117
135
  /**
118
136
  * Callback fired when the user hovers over the calendar cell.
119
137
  */
120
- onDayHover?: (date: Date | null) => void;
138
+ onDateHover?: (date: Date | string | null) => void;
121
139
  /**
122
140
  * Callback fired when the start date changed.
123
141
  */
124
- onStartDateChange?: (date: Date | null, formatedDate?: string | undefined) => void;
142
+ onStartDateChange?: (date: Date | string | null, formatedDate?: string | undefined) => void;
125
143
  /**
126
144
  * Callback fired when the end date changed.
127
145
  */
128
- onEndDateChange?: (date: Date | null, formatedDate?: string | undefined) => void;
146
+ onEndDateChange?: (date: Date | string | null, formatedDate?: string | undefined) => void;
129
147
  /**
130
148
  * Callback fired when the selection type changed.
131
149
  */
@@ -1,15 +1,24 @@
1
+ export declare const convertIsoWeekToDate: (isoWeek: string) => Date;
2
+ export declare const convertToDateObject: (date: Date | string | null, selectionType?: 'day' | 'week' | 'month' | 'year') => Date;
1
3
  export declare const convertToLocalDate: (d: Date, locale: string, options?: {}) => string;
2
4
  export declare const convertToLocalTime: (d: Date, locale: string, options?: {}) => string;
3
5
  export declare const createGroupsInArray: <T>(arr: T[], numberOfGroups: number) => T[][];
6
+ export declare const getCalendarDate: (calendarDate: Date, order: number, view: 'days' | 'months' | 'years') => Date;
4
7
  export declare const getCurrentYear: () => number;
5
8
  export declare const getCurrentMonth: () => number;
9
+ export declare const getDateBySelectionType: (date: Date | null, selectionType: 'day' | 'week' | 'month' | 'year') => string | Date | null;
6
10
  export declare const getMonthName: (month: number, locale: string) => string;
7
11
  export declare const getMonthsNames: (locale: string) => string[];
8
12
  export declare const getYears: (year: number) => number[];
13
+ export declare const getDayNumber: (date: Date) => number;
14
+ export declare const getWeekNumber: (date: Date) => number;
9
15
  export declare const getMonthDetails: (year: number, month: number, firstDayOfWeek: number) => {
10
- date: Date;
11
- month: string;
12
- }[][];
16
+ weekNumber?: number | undefined;
17
+ days: {
18
+ date: Date;
19
+ month: string;
20
+ }[];
21
+ }[];
13
22
  export declare const isDisableDateInRange: (startDate?: Date | null, endDate?: Date | null, dates?: Date[] | Date[][] | (Date | Date[])[]) => boolean;
14
23
  export declare const isDateDisabled: (date: Date, min?: Date | null, max?: Date | null, dates?: Date[] | Date[][] | (Date | Date[])[]) => boolean | undefined;
15
24
  export declare const isDateInRange: (date: Date, start: Date | null, end: Date | null) => boolean | null;
@@ -4,12 +4,18 @@ export interface CCloseButtonProps extends HTMLAttributes<HTMLButtonElement> {
4
4
  * A string of all className you want applied to the base component.
5
5
  */
6
6
  className?: string;
7
+ /**
8
+ * Invert the default color.
9
+ */
10
+ dark?: boolean;
7
11
  /**
8
12
  * Toggle the disabled state for the component.
9
13
  */
10
14
  disabled?: boolean;
11
15
  /**
12
16
  * Change the default color to white.
17
+ *
18
+ * @deprecated 5.0.0
13
19
  */
14
20
  white?: boolean;
15
21
  }
@@ -16,6 +16,12 @@ export interface CModalProps extends HTMLAttributes<HTMLDivElement> {
16
16
  * @ignore
17
17
  */
18
18
  duration?: number;
19
+ /**
20
+ * Puts the focus on the modal when shown.
21
+ *
22
+ * @since v4.10.0
23
+ */
24
+ focus?: boolean;
19
25
  /**
20
26
  * Set modal to covers the entire user viewport.
21
27
  */
@@ -2,7 +2,7 @@ export type Option = {
2
2
  custom?: boolean;
3
3
  disabled?: boolean;
4
4
  selected?: boolean;
5
- text: string;
5
+ label: string;
6
6
  value: number | string;
7
7
  [key: string]: number | string | any;
8
8
  };
@@ -13,7 +13,7 @@ export type OptionsGroup = {
13
13
  };
14
14
  export type SelectedOption = {
15
15
  disabled?: boolean;
16
- text: string;
16
+ label: string;
17
17
  value: number | string;
18
18
  [key: string]: number | string | any;
19
19
  };
@@ -1,7 +1,7 @@
1
1
  import type { Option, OptionsGroup, SelectedOption } from './types';
2
- export declare const createOption: (text: string, options: (Option | OptionsGroup)[]) => {
2
+ export declare const createOption: (label: string, options: (Option | OptionsGroup)[]) => {
3
3
  value: string;
4
- text: string;
4
+ label: string;
5
5
  custom: boolean;
6
6
  }[];
7
7
  export declare const filterOptionsList: (search: string, _options: (Option | OptionsGroup)[]) => any[];
@@ -15,6 +15,6 @@ export interface CNavProps extends HTMLAttributes<HTMLDivElement | HTMLUListElem
15
15
  /**
16
16
  * Set the nav variant to tabs or pills.
17
17
  */
18
- variant?: 'tabs' | 'pills' | 'underline';
18
+ variant?: 'pills' | 'tabs' | 'underline';
19
19
  }
20
20
  export declare const CNav: React.ForwardRefExoticComponent<CNavProps & React.RefAttributes<HTMLDivElement | HTMLOListElement | HTMLUListElement>>;
@@ -12,7 +12,7 @@ export interface CNavbarProps extends HTMLAttributes<HTMLDivElement> {
12
12
  */
13
13
  color?: Colors;
14
14
  /**
15
- * Sets if the color of text should be colored for a light or dark dark background.
15
+ * Sets if the color of text should be colored for a light or dark background.
16
16
  */
17
17
  colorScheme?: 'dark' | 'light';
18
18
  /**
@@ -8,6 +8,10 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
8
8
  * A string of all className you want applied to the base component.
9
9
  */
10
10
  className?: string;
11
+ /**
12
+ * Sets a darker color scheme.
13
+ */
14
+ dark?: boolean;
11
15
  /**
12
16
  * Closes the offcanvas when escape key is pressed.
13
17
  */
@@ -1,9 +1,10 @@
1
1
  import React, { MouseEvent, ReactNode } from 'react';
2
2
  import { CTableBodyProps } from '../table/CTableBody';
3
- import type { Item, ScopedColumns } from './types';
3
+ import type { Column, Item, ScopedColumns } from './types';
4
4
  export interface CSmartTableBodyProps extends CTableBodyProps {
5
5
  clickableRows?: boolean;
6
6
  columnNames: string[];
7
+ columns: (Column | string)[];
7
8
  currentItems: Item[];
8
9
  firstItemOnActivePageIndex: number;
9
10
  noItemsLabel?: string | ReactNode;
@@ -100,9 +100,7 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
100
100
  itemsPerPageOptions?: number[];
101
101
  /**
102
102
  * 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:
103
- * - label (String) - replaces default label text
104
- * - values (Array) - custom array of pagination values
105
- * - external (Boolean) - disables automatic 'itemsPerPage' change (use to change pages externaly by 'pagination-change' event).
103
+ * - external (Boolean) - disables automatic 'itemsPerPage' change.
106
104
  */
107
105
  itemsPerPageSelect?: boolean | ItemsPerPageSelect;
108
106
  /**
@@ -11,6 +11,8 @@ export type Column = {
11
11
  sorter?: boolean;
12
12
  _style?: any;
13
13
  _props?: CTableHeaderCellProps;
14
+ _colStyle?: any;
15
+ _colProps?: CTableDataCellProps;
14
16
  };
15
17
  export type ColumnFilter = {
16
18
  lazy?: boolean;
@@ -41,8 +43,6 @@ export type Item = {
41
43
  };
42
44
  export type ItemsPerPageSelect = {
43
45
  external?: boolean;
44
- label?: string;
45
- values?: Array<number>;
46
46
  };
47
47
  export type Pagination = {
48
48
  external?: boolean;
@@ -4,6 +4,7 @@ export declare const filterTable: (items: Item[], tableFilter: boolean | TableFi
4
4
  export declare const getClickedColumnName: (target: HTMLTextAreaElement, columnNames: string[]) => string;
5
5
  export declare const getColumnKey: (column: Column | string) => string;
6
6
  export declare const getColumnLabel: (column: Column | string) => string;
7
+ export declare const getColumnName: (column: string | Column) => string;
7
8
  export declare const getColumnNames: (columns: (string | Column)[] | undefined, items: Item[]) => string[];
8
9
  export declare const getColumns: (_columns: (Column | Group | string)[]) => (Column | string)[];
9
10
  export declare const countColumns: (columns: Column[], counter?: number) => number;
@@ -19,7 +20,8 @@ export declare const getColumnGroups: (columns: (string | Column)[] | undefined)
19
20
  export declare const getColumnNamesFromItems: (items: Item[]) => string[];
20
21
  export declare const getColumnSorterState: (key: string, sorterState: SorterValue | undefined) => string | number;
21
22
  export declare const getColumnValues: (items: Item[], key: string) => any[];
22
- export declare const getTableDataCellProps: (item: Item, colName: string) => any;
23
+ export declare const getTableDataCellProps: (column: Column | string, item: Item, colName: string) => {};
24
+ export declare const getTableDataCellStyles: (column: Column | string, item: Item, colName: string) => {};
23
25
  export declare const getTableHeaderCellProps: (column: Column | string) => import("../table/CTableHeaderCell").CTableHeaderCellProps;
24
26
  export declare const getTableHeaderCellStyles: (column: Column | string, columnSorter: boolean | Sorter | undefined) => any;
25
27
  export declare const isSortable: (i: number, columns: (string | Column)[] | undefined, columnSorter: Sorter | boolean | undefined, itemsDataColumns: string[], columnNames: string[]) => boolean | undefined;