@coreui/react-pro 4.11.2 → 4.12.0-alpha.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 (68) hide show
  1. package/README.md +1 -1
  2. package/dist/components/date-range-picker/CDateRangePicker copy.d.ts +114 -0
  3. package/dist/components/date-range-picker/CDateRangePicker.d.ts +49 -1
  4. package/dist/components/multi-select/CMultiSelect.d.ts +34 -3
  5. package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +4 -5
  6. package/dist/components/multi-select/CMultiSelectOptions.d.ts +4 -2
  7. package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -0
  8. package/dist/components/multi-select/types.d.ts +7 -3
  9. package/dist/components/multi-select/utils.d.ts +5 -5
  10. package/dist/components/multi-select-new/CMultiSelect.d.ts +133 -0
  11. package/dist/components/multi-select-new/CMultiSelectNativeSelect.d.ts +7 -0
  12. package/dist/components/multi-select-new/CMultiSelectNew.d.ts +121 -0
  13. package/dist/components/multi-select-new/CMultiSelectOptions.d.ts +16 -0
  14. package/dist/components/multi-select-new/CMultiSelectSelection.d.ts +11 -0
  15. package/dist/components/multi-select-new/index.d.ts +2 -0
  16. package/dist/components/multi-select-new/types.d.ts +15 -0
  17. package/dist/components/multi-select-new/utils.d.ts +11 -0
  18. package/dist/components/picker/CPicker copy.d.ts +82 -0
  19. package/dist/components/picker/CPicker.d.ts +14 -56
  20. package/dist/components/picker copy/CPicker.d.ts +82 -0
  21. package/dist/components/popover/CPopover.d.ts +1 -1
  22. package/dist/components/time-picker/CTimePicker.d.ts +41 -1
  23. package/dist/components/tooltip/CTooltip.d.ts +3 -3
  24. package/dist/index.es.js +2200 -2074
  25. package/dist/index.es.js.map +1 -1
  26. package/dist/index.js +2199 -2073
  27. package/dist/index.js.map +1 -1
  28. package/dist/utils/index.d.ts +2 -1
  29. package/dist/utils/isRTL.d.ts +2 -0
  30. package/package.json +7 -7
  31. package/src/components/calendar/__tests__/__snapshots__/CCalendar.spec.tsx.snap +601 -555
  32. package/src/components/date-picker/__tests__/__snapshots__/CDatePicker.spec.tsx.snap +599 -561
  33. package/src/components/date-range-picker/CDateRangePicker.tsx +198 -97
  34. package/src/components/date-range-picker/__tests__/__snapshots__/CDateRangePicker.spec.tsx.snap +1197 -1121
  35. package/src/components/dropdown/CDropdownMenu.tsx +5 -4
  36. package/src/components/dropdown/__tests__/__snapshots__/CDropdown.spec.tsx.snap +1 -1
  37. package/src/components/element-cover/CElementCover.tsx +1 -0
  38. package/src/components/multi-select/CMultiSelect.tsx +200 -79
  39. package/src/components/multi-select/CMultiSelectNativeSelect.tsx +34 -24
  40. package/src/components/multi-select/CMultiSelectOptions.tsx +25 -23
  41. package/src/components/multi-select/CMultiSelectSelection.tsx +36 -7
  42. package/src/components/multi-select/__tests__/CMultiSelect.spec.tsx +25 -14
  43. package/src/components/multi-select/__tests__/CMultiSelectNativeSelect.spec.tsx +1 -1
  44. package/src/components/multi-select/__tests__/CMultiSelectOptions.spec.tsx +4 -4
  45. package/src/components/multi-select/__tests__/CMultiSelectSelection.spec.tsx +0 -1
  46. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelect.spec.tsx.snap +136 -30
  47. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectNativeSelect.spec.tsx.snap +2 -0
  48. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectOptions.spec.tsx.snap +3 -1
  49. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelection.spec.tsx.snap +2 -2
  50. package/src/components/multi-select/types.ts +9 -4
  51. package/src/components/multi-select/utils.ts +56 -39
  52. package/src/components/picker/CPicker.tsx +113 -138
  53. package/src/components/popover/CPopover.tsx +62 -26
  54. package/src/components/smart-table/CSmartTable.tsx +5 -1
  55. package/src/components/smart-table/__tests__/CSmartTable.spec.tsx +1 -1
  56. package/src/components/smart-table/__tests__/__snapshots__/CSmartTable.spec.tsx.snap +580 -0
  57. package/src/components/time-picker/CTimePicker.tsx +182 -82
  58. package/src/components/time-picker/__tests__/__snapshots__/CTimePicker.spec.tsx.snap +1078 -0
  59. package/src/components/tooltip/CTooltip.tsx +66 -31
  60. package/src/components/virtual-scroller/CVirtualScroller.tsx +0 -1
  61. package/src/utils/index.ts +2 -1
  62. package/src/utils/isRTL.ts +13 -0
  63. package/src/components/multi-select/__tests__/CMultiSelectCleaner.spec.tsx +0 -15
  64. package/src/components/multi-select/__tests__/CMultiSelectSearchInput.spec.tsx +0 -17
  65. package/src/components/multi-select/__tests__/CMultiSelectSelectAllButton.spec.tsx +0 -21
  66. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectCleaner.spec.tsx.snap +0 -19
  67. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSearchInput.spec.tsx.snap +0 -20
  68. package/src/components/multi-select/__tests__/__snapshots__/CMultiSelectSelectAllButton.spec.tsx.snap +0 -24
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.11.2.zip)
45
+ - [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.12.0-alpha.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,114 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { CCalendarProps } from '../calendar/CCalendar';
3
+ import { CFormControlWrapperProps } from '../form/CFormControlWrapper';
4
+ import { CPickerProps } from '../picker/CPicker';
5
+ import { Colors } from '../../types';
6
+ export interface CDateRangePickerProps extends Omit<CFormControlWrapperProps, 'floatingLabel'>, Omit<CPickerProps, 'autoClose' | 'component' | 'dark' | 'placeholder' | 'variant'>, Omit<CCalendarProps, 'onCalendarCellHover' | 'onCalendarDateChange'> {
7
+ /**
8
+ * The number of calendars that render on desktop devices.
9
+ */
10
+ calendars?: number;
11
+ /**
12
+ * A string of all className you want applied to the component.
13
+ */
14
+ className?: string;
15
+ /**
16
+ * If true the dropdown will be immediately closed after submitting the full date.
17
+ *
18
+ * @since 4.8.0
19
+ */
20
+ closeOnSelect?: boolean;
21
+ /**
22
+ * Toggle visibility or set the content of the cleaner button.
23
+ */
24
+ cleaner?: boolean;
25
+ /**
26
+ * Set date format.
27
+ * We use date-fns to format dates. Visit https://date-fns.org/v2.28.0/docs/format to check accepted patterns.
28
+ */
29
+ format?: string;
30
+ /**
31
+ * The id global attribute defines an identifier (ID) that must be unique in the whole document.
32
+ *
33
+ * The name attributes for input elements are generated based on the `id` property:
34
+ * - \{id\}-start-date
35
+ * - \{id\}-end-date
36
+ */
37
+ id?: string;
38
+ /**
39
+ * Toggle visibility or set the content of the input indicator.
40
+ */
41
+ indicator?: ReactNode | boolean;
42
+ /**
43
+ * Toggle the readonly state for the component.
44
+ */
45
+ inputReadOnly?: boolean;
46
+ /**
47
+ * Specifies short hints that are visible in start date and end date inputs.
48
+ */
49
+ placeholder?: string | string[];
50
+ /**
51
+ * @ignore
52
+ */
53
+ range?: boolean;
54
+ /**
55
+ * Predefined date ranges the user can select from.
56
+ */
57
+ ranges?: object;
58
+ /**
59
+ * Sets the color context of the cancel button to one of CoreUI’s themed colors.
60
+ *
61
+ * @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
62
+ */
63
+ rangesButtonsColor?: Colors;
64
+ /**
65
+ * Size the ranges button small or large.
66
+ */
67
+ rangesButtonsSize?: 'sm' | 'lg';
68
+ /**
69
+ * Set the ranges button variant to an outlined button or a ghost button.
70
+ */
71
+ rangesButtonsVariant?: 'outline' | 'ghost';
72
+ /**
73
+ * When present, it specifies that date must be filled out before submitting the form.
74
+ *
75
+ * @since 4.10.0
76
+ */
77
+ required?: boolean;
78
+ /**
79
+ * Default icon or character character that separates two dates.
80
+ */
81
+ separator?: ReactNode | boolean;
82
+ /**
83
+ * Size the component small or large.
84
+ */
85
+ size?: 'sm' | 'lg';
86
+ /**
87
+ * Provide an additional time selection by adding select boxes to choose times.
88
+ */
89
+ timepicker?: boolean;
90
+ /**
91
+ * Toggle visibility or set the content of today button.
92
+ *
93
+ * @default 'Today'
94
+ */
95
+ todayButton?: boolean | ReactNode;
96
+ /**
97
+ * Sets the color context of the today button to one of CoreUI’s themed colors.
98
+ *
99
+ * @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
100
+ * @default 'primary'
101
+ */
102
+ todayButtonColor?: Colors;
103
+ /**
104
+ * Size the today button small or large.
105
+ *
106
+ * @default 'sm'
107
+ */
108
+ todayButtonSize?: 'sm' | 'lg';
109
+ /**
110
+ * Set the today button variant to an outlined button or a ghost button.
111
+ */
112
+ todayButtonVariant?: 'outline' | 'ghost';
113
+ }
114
+ export declare const CDateRangePicker: React.ForwardRefExoticComponent<CDateRangePickerProps & React.RefAttributes<HTMLDivElement | HTMLLIElement>>;
@@ -3,11 +3,36 @@ import { CCalendarProps } from '../calendar/CCalendar';
3
3
  import { CFormControlWrapperProps } from '../form/CFormControlWrapper';
4
4
  import { CPickerProps } from '../picker/CPicker';
5
5
  import { Colors } from '../../types';
6
- export interface CDateRangePickerProps extends Omit<CFormControlWrapperProps, 'floatingLabel'>, Omit<CPickerProps, 'autoClose' | 'component' | 'dark' | 'placeholder' | 'variant'>, Omit<CCalendarProps, 'onCalendarCellHover' | 'onCalendarDateChange'> {
6
+ export interface CDateRangePickerProps extends Omit<CFormControlWrapperProps, 'floatingLabel'>, Omit<CPickerProps, 'placeholder'>, Omit<CCalendarProps, 'onCalendarCellHover' | 'onCalendarDateChange'> {
7
7
  /**
8
8
  * The number of calendars that render on desktop devices.
9
9
  */
10
10
  calendars?: number;
11
+ /**
12
+ * Toggle visibility or set the content of cancel button.
13
+ *
14
+ * @default 'Cancel'
15
+ */
16
+ cancelButton?: boolean | ReactNode;
17
+ /**
18
+ * Sets the color context of the cancel button to one of CoreUI’s themed colors.
19
+ *
20
+ * @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
21
+ * @default 'primary'
22
+ */
23
+ cancelButtonColor?: Colors;
24
+ /**
25
+ * Size the cancel button small or large.
26
+ *
27
+ * @default 'sm'
28
+ */
29
+ cancelButtonSize?: 'sm' | 'lg';
30
+ /**
31
+ * Set the cancel button variant to an outlined button or a ghost button.
32
+ *
33
+ * @default 'ghost'
34
+ */
35
+ cancelButtonVariant?: 'outline' | 'ghost';
11
36
  /**
12
37
  * A string of all className you want applied to the component.
13
38
  */
@@ -22,6 +47,29 @@ export interface CDateRangePickerProps extends Omit<CFormControlWrapperProps, 'f
22
47
  * Toggle visibility or set the content of the cleaner button.
23
48
  */
24
49
  cleaner?: boolean;
50
+ /**
51
+ * Toggle visibility or set the content of confirm button.
52
+ *
53
+ * @default 'OK'
54
+ */
55
+ confirmButton?: boolean | ReactNode;
56
+ /**
57
+ * Sets the color context of the confirm button to one of CoreUI’s themed colors.
58
+ *
59
+ * @type 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'dark' | 'light' | string
60
+ * @default 'primary'
61
+ */
62
+ confirmButtonColor?: Colors;
63
+ /**
64
+ * Size the confirm button small or large.
65
+ *
66
+ * @default 'sm'
67
+ */
68
+ confirmButtonSize?: 'sm' | 'lg';
69
+ /**
70
+ * Set the confirm button variant to an outlined button or a ghost button.
71
+ */
72
+ confirmButtonVariant?: 'outline' | 'ghost';
25
73
  /**
26
74
  * Set date format.
27
75
  * We use date-fns to format dates. Visit https://date-fns.org/v2.28.0/docs/format to check accepted patterns.
@@ -1,6 +1,6 @@
1
1
  import React, { HTMLAttributes, ReactNode } from 'react';
2
- import { CFormControlWrapperProps } from './../form/CFormControlWrapper';
3
- import type { Option } from './types';
2
+ import { CFormControlWrapperProps } from '../form/CFormControlWrapper';
3
+ import type { Option, OptionsGroup } from './types';
4
4
  export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'floatingClassName' | 'floatingLabel'>, Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
5
5
  /**
6
6
  * Allow users to create options if they are not in the list of options.
@@ -26,6 +26,13 @@ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'float
26
26
  * Toggle the disabled state for the component.
27
27
  */
28
28
  disabled?: boolean;
29
+ /**
30
+ * The id global attribute defines an identifier (ID) that must be unique in the whole document.
31
+ *
32
+ * The name and id attributes for the native select element are generated based on the `id` property:
33
+ * - <select id="\{id\}-multi-select" name="\{id\}-multi-select" />
34
+ */
35
+ id?: string;
29
36
  /**
30
37
  * When set, the options list will have a loading style: loading spinner and reduced opacity.
31
38
  *
@@ -46,10 +53,18 @@ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'float
46
53
  * @since 4.8.0
47
54
  */
48
55
  onFilterChange?: (value: string) => void;
56
+ /**
57
+ * The callback is fired when the Multi Select component requests to be hidden.
58
+ */
59
+ onHide?: () => void;
60
+ /**
61
+ * The callback is fired when the Multi Select component requests to be shown.
62
+ */
63
+ onShow?: () => void;
49
64
  /**
50
65
  * List of option elements.
51
66
  */
52
- options: Option[];
67
+ options: (Option | OptionsGroup)[];
53
68
  /**
54
69
  * Sets maxHeight of options list.
55
70
  */
@@ -58,10 +73,26 @@ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'float
58
73
  * Sets option style.
59
74
  */
60
75
  optionsStyle?: 'checkbox' | 'text';
76
+ /**
77
+ * Custom template for options.
78
+ *
79
+ * @since 4.12.0-alpha.0
80
+ */
81
+ optionsTemplate?: (option: Option) => ReactNode;
82
+ /**
83
+ * Custom template for options groups.
84
+ *
85
+ * @since 4.12.0-alpha.0
86
+ */
87
+ optionsGroupsTemplate?: (option: OptionsGroup) => ReactNode;
61
88
  /**
62
89
  * Specifies a short hint that is visible in the search input.
63
90
  */
64
91
  placeholder?: string;
92
+ /**
93
+ * When it is present, it indicates that the user must choose a value before submitting the form.
94
+ */
95
+ required?: boolean;
65
96
  /**
66
97
  * Enables search input element.
67
98
  */
@@ -1,8 +1,7 @@
1
- import React, { HTMLAttributes } from 'react';
1
+ import React, { InputHTMLAttributes } from 'react';
2
2
  import type { Option } from './types';
3
- export interface CMultiSelectNativeSelectProps extends Omit<HTMLAttributes<HTMLSelectElement>, 'options'> {
4
- multiple?: boolean;
5
- options: Option[] | undefined;
6
- value?: string | number | readonly string[];
3
+ export interface CMultiSelectNativeSelectProps extends Omit<InputHTMLAttributes<HTMLSelectElement>, 'options'> {
4
+ options?: Option[];
5
+ value?: string | number | string[];
7
6
  }
8
7
  export declare const CMultiSelectNativeSelect: React.ForwardRefExoticComponent<CMultiSelectNativeSelectProps & React.RefAttributes<HTMLSelectElement>>;
@@ -1,11 +1,13 @@
1
1
  import React, { HTMLAttributes, ReactNode } from 'react';
2
- import type { Option } from './types';
2
+ import type { Option, OptionsGroup } from './types';
3
3
  export interface CMultiSelectOptionsProps extends HTMLAttributes<HTMLDivElement> {
4
4
  handleOptionOnClick?: (option: Option) => void;
5
5
  loading?: boolean;
6
- options: Option[];
6
+ options: (Option | OptionsGroup)[];
7
7
  optionsMaxHeight?: number | string;
8
8
  optionsStyle?: 'checkbox' | 'text';
9
+ optionsTemplate?: (option: Option) => ReactNode;
10
+ optionsGroupsTemplate?: (option: OptionsGroup) => ReactNode;
9
11
  searchNoResultsLabel?: string | ReactNode;
10
12
  selected: Option[];
11
13
  virtualScroller?: boolean;
@@ -3,6 +3,7 @@ import type { SelectedOption } from './types';
3
3
  export interface CMultiSelectSelectionProps extends HTMLAttributes<HTMLSpanElement> {
4
4
  multiple?: boolean;
5
5
  onRemove?: (option: SelectedOption) => void;
6
+ placeholder?: string;
6
7
  search?: boolean | 'external';
7
8
  selected?: SelectedOption[];
8
9
  selectionType?: 'counter' | 'tags' | 'text';
@@ -1,15 +1,19 @@
1
1
  export type Option = {
2
2
  custom?: boolean;
3
3
  disabled?: boolean;
4
- label?: string;
5
- options?: Option[];
6
- order?: number;
7
4
  selected?: boolean;
8
5
  text: string;
9
6
  value: number | string;
7
+ [key: string]: number | string | any;
8
+ };
9
+ export type OptionsGroup = {
10
+ label: string;
11
+ options?: Option[];
12
+ [key: string]: number | string | any;
10
13
  };
11
14
  export type SelectedOption = {
12
15
  disabled?: boolean;
13
16
  text: string;
14
17
  value: number | string;
18
+ [key: string]: number | string | any;
15
19
  };
@@ -1,11 +1,11 @@
1
- import type { Option, SelectedOption } from './types';
2
- export declare const createOption: (text: string, options: Option[]) => {
1
+ import type { Option, OptionsGroup, SelectedOption } from './types';
2
+ export declare const createOption: (text: string, options: (Option | OptionsGroup)[]) => {
3
3
  value: string;
4
4
  text: string;
5
5
  custom: boolean;
6
6
  }[];
7
- export declare const filterOptionsList: (search: string, _options: Option[]) => Option[];
8
- export declare const flattenArray: (options: Option[]) => Option[];
7
+ export declare const filterOptionsList: (search: string, _options: (Option | OptionsGroup)[]) => any[];
8
+ export declare const flattenOptionsArray: (options: (Option | OptionsGroup)[], keepGroupLabel?: boolean) => (Option | OptionsGroup)[];
9
9
  export declare const getNextSibling: (elem: HTMLElement, selector?: string) => Element | null | undefined;
10
10
  export declare const getPreviousSibling: (elem: HTMLElement, selector?: string) => Element | null | undefined;
11
- export declare const selectOptions: (options: Option[], selected: SelectedOption[], deselected?: Option[]) => SelectedOption[];
11
+ export declare const selectOptions: (options: (Option | OptionsGroup)[], selected: SelectedOption[], deselected?: Option[]) => SelectedOption[];
@@ -0,0 +1,133 @@
1
+ import React, { HTMLAttributes, ReactNode } from 'react';
2
+ import { CFormControlWrapperProps } from '../form/CFormControlWrapper';
3
+ import type { Option } from './types';
4
+ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'floatingClassName' | 'floatingLabel'>, Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
5
+ /**
6
+ * Allow users to create options if they are not in the list of options.
7
+ *
8
+ * @since 4.11.0-next.0
9
+ */
10
+ allowCreateOptions?: boolean;
11
+ /**
12
+ * A string of all className you want applied to the base component.
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Enables selection cleaner element.
17
+ */
18
+ cleaner?: boolean;
19
+ /**
20
+ * Clear current search on selecting an item.
21
+ *
22
+ * @since 4.11.0-next.0
23
+ */
24
+ clearSearchOnSelect?: boolean;
25
+ /**
26
+ * Toggle the disabled state for the component.
27
+ */
28
+ disabled?: boolean;
29
+ /**
30
+ * The id global attribute defines an identifier (ID) that must be unique in the whole document.
31
+ *
32
+ * The name and id attributes for the native select element are generated based on the `id` property:
33
+ * - <select id="\{id\}-multi-select" name="\{id\}-multi-select" />
34
+ */
35
+ id?: string;
36
+ /**
37
+ * When set, the options list will have a loading style: loading spinner and reduced opacity.
38
+ *
39
+ * @since 4.11.0-next.0
40
+ */
41
+ loading?: boolean;
42
+ /**
43
+ * It specifies that multiple options can be selected at once.
44
+ */
45
+ multiple?: boolean;
46
+ /**
47
+ * Execute a function when a user changes the selected option.
48
+ */
49
+ onChange?: (selected: Option[]) => void;
50
+ /**
51
+ * Execute a function when the filter value changed.
52
+ *
53
+ * @since 4.8.0
54
+ */
55
+ onFilterChange?: (value: string) => void;
56
+ /**
57
+ * List of option elements.
58
+ */
59
+ options: Option[];
60
+ /**
61
+ * Sets maxHeight of options list.
62
+ */
63
+ optionsMaxHeight?: number | string;
64
+ /**
65
+ * Sets option style.
66
+ */
67
+ optionsStyle?: 'checkbox' | 'text';
68
+ /**
69
+ * TODO:
70
+ *
71
+ * @since TODO: 4._.0
72
+ */
73
+ optionsTemplate?: (option: Option) => ReactNode;
74
+ /**
75
+ * TODO:
76
+ *
77
+ * @since TODO: 4._.0
78
+ */
79
+ optionsGroupsTemplate?: (option: Option) => ReactNode;
80
+ /**
81
+ * Specifies a short hint that is visible in the search input.
82
+ */
83
+ placeholder?: string;
84
+ /**
85
+ * @since XXXX
86
+ */
87
+ required?: boolean;
88
+ /**
89
+ * Enables search input element.
90
+ */
91
+ search?: boolean | 'external';
92
+ /**
93
+ * Sets the label for no results when filtering.
94
+ */
95
+ searchNoResultsLabel?: string | ReactNode;
96
+ /**
97
+ * Enables select all button.
98
+ */
99
+ selectAll?: boolean;
100
+ /**
101
+ * Sets the select all button label.
102
+ */
103
+ selectAllLabel?: string | ReactNode;
104
+ /**
105
+ * Sets the selection style.
106
+ */
107
+ selectionType?: 'counter' | 'tags' | 'text';
108
+ /**
109
+ * Sets the counter selection label.
110
+ */
111
+ selectionTypeCounterText?: string;
112
+ /**
113
+ * Size the component small or large.
114
+ */
115
+ size?: 'sm' | 'lg';
116
+ /**
117
+ * Enable virtual scroller for the options list.
118
+ *
119
+ * @since 4.8.0
120
+ */
121
+ virtualScroller?: boolean;
122
+ /**
123
+ * Toggle the visibility of multi select dropdown.
124
+ */
125
+ visible?: boolean;
126
+ /**
127
+ * Amount of visible items when virtualScroller is set to `true`.
128
+ *
129
+ * @since 4.8.0
130
+ */
131
+ visibleItems?: number;
132
+ }
133
+ export declare const CMultiSelectNew: React.ForwardRefExoticComponent<CMultiSelectProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,7 @@
1
+ import React, { InputHTMLAttributes } from 'react';
2
+ import type { Option } from './types';
3
+ export interface CMultiSelectNativeSelectProps extends Omit<InputHTMLAttributes<HTMLSelectElement>, 'options'> {
4
+ options?: Option[];
5
+ value?: string | number | string[];
6
+ }
7
+ export declare const CMultiSelectNativeSelect: React.ForwardRefExoticComponent<CMultiSelectNativeSelectProps & React.RefAttributes<HTMLSelectElement>>;
@@ -0,0 +1,121 @@
1
+ import React, { HTMLAttributes, ReactNode } from 'react';
2
+ import { CFormControlWrapperProps } from './../form/CFormControlWrapper';
3
+ import type { Option } from './types';
4
+ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'floatingClassName' | 'floatingLabel'>, Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
5
+ /**
6
+ * Allow users to create options if they are not in the list of options.
7
+ *
8
+ * @since 4.11.0-next.0
9
+ */
10
+ allowCreateOptions?: boolean;
11
+ /**
12
+ * A string of all className you want applied to the base component.
13
+ */
14
+ className?: string;
15
+ /**
16
+ * Enables selection cleaner element.
17
+ */
18
+ cleaner?: boolean;
19
+ /**
20
+ * Clear current search on selecting an item.
21
+ *
22
+ * @since 4.11.0-next.0
23
+ */
24
+ clearSearchOnSelect?: boolean;
25
+ /**
26
+ * Toggle the disabled state for the component.
27
+ */
28
+ disabled?: boolean;
29
+ /**
30
+ * The id global attribute defines an identifier (ID) that must be unique in the whole document.
31
+ *
32
+ * The name and id attributes for the native select element are generated based on the `id` property:
33
+ * - <select id="\{id\}-multi-select" name="\{id\}-multi-select" />
34
+ */
35
+ id?: string;
36
+ /**
37
+ * When set, the options list will have a loading style: loading spinner and reduced opacity.
38
+ *
39
+ * @since 4.11.0-next.0
40
+ */
41
+ loading?: boolean;
42
+ /**
43
+ * It specifies that multiple options can be selected at once.
44
+ */
45
+ multiple?: boolean;
46
+ /**
47
+ * Execute a function when a user changes the selected option.
48
+ */
49
+ onChange?: (selected: Option[]) => void;
50
+ /**
51
+ * Execute a function when the filter value changed.
52
+ *
53
+ * @since 4.8.0
54
+ */
55
+ onFilterChange?: (value: string) => void;
56
+ /**
57
+ * List of option elements.
58
+ */
59
+ options: Option[];
60
+ /**
61
+ * Sets maxHeight of options list.
62
+ */
63
+ optionsMaxHeight?: number | string;
64
+ /**
65
+ * Sets option style.
66
+ */
67
+ optionsStyle?: 'checkbox' | 'text';
68
+ /**
69
+ * Specifies a short hint that is visible in the search input.
70
+ */
71
+ placeholder?: string;
72
+ /**
73
+ * @since XXXX
74
+ */
75
+ required?: boolean;
76
+ /**
77
+ * Enables search input element.
78
+ */
79
+ search?: boolean | 'external';
80
+ /**
81
+ * Sets the label for no results when filtering.
82
+ */
83
+ searchNoResultsLabel?: string | ReactNode;
84
+ /**
85
+ * Enables select all button.
86
+ */
87
+ selectAll?: boolean;
88
+ /**
89
+ * Sets the select all button label.
90
+ */
91
+ selectAllLabel?: string | ReactNode;
92
+ /**
93
+ * Sets the selection style.
94
+ */
95
+ selectionType?: 'counter' | 'tags' | 'text';
96
+ /**
97
+ * Sets the counter selection label.
98
+ */
99
+ selectionTypeCounterText?: string;
100
+ /**
101
+ * Size the component small or large.
102
+ */
103
+ size?: 'sm' | 'lg';
104
+ /**
105
+ * Enable virtual scroller for the options list.
106
+ *
107
+ * @since 4.8.0
108
+ */
109
+ virtualScroller?: boolean;
110
+ /**
111
+ * Toggle the visibility of multi select dropdown.
112
+ */
113
+ visible?: boolean;
114
+ /**
115
+ * Amount of visible items when virtualScroller is set to `true`.
116
+ *
117
+ * @since 4.8.0
118
+ */
119
+ visibleItems?: number;
120
+ }
121
+ export declare const CMultiSelectNew: React.ForwardRefExoticComponent<CMultiSelectProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,16 @@
1
+ import React, { HTMLAttributes, ReactNode } from 'react';
2
+ import type { Option } from './types';
3
+ export interface CMultiSelectOptionsProps extends HTMLAttributes<HTMLDivElement> {
4
+ handleOptionOnClick?: (option: Option) => void;
5
+ loading?: boolean;
6
+ options: Option[];
7
+ optionsMaxHeight?: number | string;
8
+ optionsStyle?: 'checkbox' | 'text';
9
+ optionsTemplate?: (option: Option) => ReactNode;
10
+ optionsGroupsTemplate?: (option: Option) => ReactNode;
11
+ searchNoResultsLabel?: string | ReactNode;
12
+ selected: Option[];
13
+ virtualScroller?: boolean;
14
+ visibleItems?: number;
15
+ }
16
+ export declare const CMultiSelectOptions: React.ForwardRefExoticComponent<CMultiSelectOptionsProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,11 @@
1
+ import React, { HTMLAttributes } from 'react';
2
+ import type { SelectedOption } from './types';
3
+ export interface CMultiSelectSelectionProps extends HTMLAttributes<HTMLSpanElement> {
4
+ multiple?: boolean;
5
+ onRemove?: (option: SelectedOption) => void;
6
+ search?: boolean | 'external';
7
+ selected?: SelectedOption[];
8
+ selectionType?: 'counter' | 'tags' | 'text';
9
+ selectionTypeCounterText?: string;
10
+ }
11
+ export declare const CMultiSelectSelection: React.ForwardRefExoticComponent<CMultiSelectSelectionProps & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,2 @@
1
+ import { CMultiSelectNew } from './CMultiSelect';
2
+ export { CMultiSelectNew };
@@ -0,0 +1,15 @@
1
+ export type Option = {
2
+ custom?: boolean;
3
+ disabled?: boolean;
4
+ label?: string;
5
+ options?: Option[];
6
+ selected?: boolean;
7
+ text: string;
8
+ value: number | string;
9
+ [key: string]: number | string | any;
10
+ };
11
+ export type SelectedOption = {
12
+ disabled?: boolean;
13
+ text: string;
14
+ value: number | string;
15
+ };
@@ -0,0 +1,11 @@
1
+ import type { Option, SelectedOption } from './types';
2
+ export declare const createOption: (text: string, options: Option[]) => {
3
+ value: string;
4
+ text: string;
5
+ custom: boolean;
6
+ }[];
7
+ export declare const filterOptionsList: (search: string, _options: Option[]) => Option[];
8
+ export declare const flattenArray: (options: Option[]) => Option[];
9
+ export declare const getNextSibling: (elem: HTMLElement, selector?: string) => Element | null | undefined;
10
+ export declare const getPreviousSibling: (elem: HTMLElement, selector?: string) => Element | null | undefined;
11
+ export declare const selectOptions: (options: Option[], selected: SelectedOption[], deselected?: Option[]) => SelectedOption[];