@coreui/react-pro 5.18.0 → 5.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/components/autocomplete/CAutocomplete.d.ts +16 -2
- package/dist/cjs/components/autocomplete/CAutocomplete.js +99 -86
- package/dist/cjs/components/autocomplete/CAutocomplete.js.map +1 -1
- package/dist/cjs/components/calendar/utils.d.ts +0 -11
- package/dist/cjs/components/calendar/utils.js.map +1 -1
- package/dist/cjs/components/date-range-picker/CDateRangePicker.d.ts +6 -0
- package/dist/cjs/components/date-range-picker/CDateRangePicker.js +17 -14
- package/dist/cjs/components/date-range-picker/CDateRangePicker.js.map +1 -1
- package/dist/cjs/components/multi-select/CMultiSelect.d.ts +6 -0
- package/dist/cjs/components/multi-select/CMultiSelect.js +13 -12
- package/dist/cjs/components/multi-select/CMultiSelect.js.map +1 -1
- package/dist/cjs/components/multi-select/CMultiSelectOptions.js +6 -5
- package/dist/cjs/components/multi-select/CMultiSelectOptions.js.map +1 -1
- package/dist/cjs/components/multi-select/CMultiSelectSelection.js +1 -1
- package/dist/cjs/components/multi-select/CMultiSelectSelection.js.map +1 -1
- package/dist/cjs/components/multi-select/utils.d.ts +0 -2
- package/dist/cjs/components/multi-select/utils.js +0 -26
- package/dist/cjs/components/multi-select/utils.js.map +1 -1
- package/dist/cjs/utils/getNextSibling.js +3 -0
- package/dist/cjs/utils/getNextSibling.js.map +1 -1
- package/dist/cjs/utils/getPreviousSibling.js +3 -0
- package/dist/cjs/utils/getPreviousSibling.js.map +1 -1
- package/dist/esm/components/autocomplete/CAutocomplete.d.ts +16 -2
- package/dist/esm/components/autocomplete/CAutocomplete.js +99 -86
- package/dist/esm/components/autocomplete/CAutocomplete.js.map +1 -1
- package/dist/esm/components/calendar/utils.d.ts +0 -11
- package/dist/esm/components/calendar/utils.js.map +1 -1
- package/dist/esm/components/date-range-picker/CDateRangePicker.d.ts +6 -0
- package/dist/esm/components/date-range-picker/CDateRangePicker.js +17 -14
- package/dist/esm/components/date-range-picker/CDateRangePicker.js.map +1 -1
- package/dist/esm/components/multi-select/CMultiSelect.d.ts +6 -0
- package/dist/esm/components/multi-select/CMultiSelect.js +14 -13
- package/dist/esm/components/multi-select/CMultiSelect.js.map +1 -1
- package/dist/esm/components/multi-select/CMultiSelectOptions.js +4 -3
- package/dist/esm/components/multi-select/CMultiSelectOptions.js.map +1 -1
- package/dist/esm/components/multi-select/CMultiSelectSelection.js +1 -1
- package/dist/esm/components/multi-select/CMultiSelectSelection.js.map +1 -1
- package/dist/esm/components/multi-select/utils.d.ts +0 -2
- package/dist/esm/components/multi-select/utils.js +1 -25
- package/dist/esm/components/multi-select/utils.js.map +1 -1
- package/dist/esm/utils/getNextSibling.js +3 -0
- package/dist/esm/utils/getNextSibling.js.map +1 -1
- package/dist/esm/utils/getPreviousSibling.js +3 -0
- package/dist/esm/utils/getPreviousSibling.js.map +1 -1
- package/package.json +7 -7
- package/src/components/autocomplete/CAutocomplete.tsx +190 -146
- package/src/components/calendar/utils.ts +0 -26
- package/src/components/date-range-picker/CDateRangePicker.tsx +12 -0
- package/src/components/multi-select/CMultiSelect.tsx +23 -4
- package/src/components/multi-select/CMultiSelectOptions.tsx +8 -5
- package/src/components/multi-select/CMultiSelectSelection.tsx +3 -3
- package/src/components/multi-select/utils.ts +0 -34
|
@@ -5,7 +5,7 @@ import classNames from 'classnames'
|
|
|
5
5
|
import { CElementCover } from '../element-cover'
|
|
6
6
|
import { CVirtualScroller } from '../virtual-scroller'
|
|
7
7
|
|
|
8
|
-
import { getNextSibling, getPreviousSibling } from '
|
|
8
|
+
import { getNextSibling, getPreviousSibling } from '../../utils'
|
|
9
9
|
import type { Option, OptionsGroup } from './types'
|
|
10
10
|
|
|
11
11
|
export interface CMultiSelectOptionsProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -38,12 +38,12 @@ export const CMultiSelectOptions = forwardRef<HTMLDivElement, CMultiSelectOption
|
|
|
38
38
|
virtualScroller,
|
|
39
39
|
visibleItems = 10,
|
|
40
40
|
},
|
|
41
|
-
ref
|
|
41
|
+
ref
|
|
42
42
|
) => {
|
|
43
43
|
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>, option: Option) => {
|
|
44
44
|
if (event.code === 'Space' || event.key === 'Enter') {
|
|
45
45
|
event.preventDefault()
|
|
46
|
-
onOptionOnClick
|
|
46
|
+
onOptionOnClick?.(option)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (event.key === 'Down' || event.key === 'ArrowDown') {
|
|
@@ -77,6 +77,9 @@ export const CMultiSelectOptions = forwardRef<HTMLDivElement, CMultiSelectOption
|
|
|
77
77
|
onClick={() => onOptionOnClick && onOptionOnClick(option as Option)}
|
|
78
78
|
onKeyDown={(event) => handleKeyDown(event, option as Option)}
|
|
79
79
|
tabIndex={0}
|
|
80
|
+
role="option"
|
|
81
|
+
aria-selected={selected.some((_option) => _option.value === option.value)}
|
|
82
|
+
aria-disabled={Boolean(option.disabled)}
|
|
80
83
|
>
|
|
81
84
|
{optionsTemplate ? optionsTemplate(option as Option) : option.label}
|
|
82
85
|
</div>
|
|
@@ -84,7 +87,7 @@ export const CMultiSelectOptions = forwardRef<HTMLDivElement, CMultiSelectOption
|
|
|
84
87
|
<div className="form-multi-select-optgroup-label" key={index}>
|
|
85
88
|
{optionsGroupsTemplate ? optionsGroupsTemplate(option as OptionsGroup) : option.label}
|
|
86
89
|
</div>
|
|
87
|
-
)
|
|
90
|
+
)
|
|
88
91
|
)
|
|
89
92
|
) : (
|
|
90
93
|
<div className="form-multi-select-options-empty">{searchNoResultsLabel}</div>
|
|
@@ -116,7 +119,7 @@ export const CMultiSelectOptions = forwardRef<HTMLDivElement, CMultiSelectOption
|
|
|
116
119
|
{loading && <CElementCover />}
|
|
117
120
|
</>
|
|
118
121
|
)
|
|
119
|
-
}
|
|
122
|
+
}
|
|
120
123
|
)
|
|
121
124
|
|
|
122
125
|
CMultiSelectOptions.propTypes = {
|
|
@@ -29,7 +29,7 @@ export const CMultiSelectSelection = forwardRef<HTMLSpanElement, CMultiSelectSel
|
|
|
29
29
|
selectionType,
|
|
30
30
|
selectionTypeCounterText,
|
|
31
31
|
},
|
|
32
|
-
ref
|
|
32
|
+
ref
|
|
33
33
|
) => {
|
|
34
34
|
return (
|
|
35
35
|
<span
|
|
@@ -56,7 +56,7 @@ export const CMultiSelectSelection = forwardRef<HTMLSpanElement, CMultiSelectSel
|
|
|
56
56
|
className="form-multi-select-tag-delete"
|
|
57
57
|
type="button"
|
|
58
58
|
aria-label="Close"
|
|
59
|
-
onClick={() => onRemove
|
|
59
|
+
onClick={() => onRemove?.(option)}
|
|
60
60
|
/>
|
|
61
61
|
)}
|
|
62
62
|
</span>
|
|
@@ -76,7 +76,7 @@ export const CMultiSelectSelection = forwardRef<HTMLSpanElement, CMultiSelectSel
|
|
|
76
76
|
{children}
|
|
77
77
|
</span>
|
|
78
78
|
)
|
|
79
|
-
}
|
|
79
|
+
}
|
|
80
80
|
)
|
|
81
81
|
|
|
82
82
|
CMultiSelectSelection.propTypes = {
|
|
@@ -66,46 +66,12 @@ export const flattenOptionsArray = (
|
|
|
66
66
|
return optionsList
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
export const getNextSibling = (elem: HTMLElement, selector?: string) => {
|
|
70
|
-
// Get the next sibling element
|
|
71
|
-
let sibling = elem.nextElementSibling
|
|
72
|
-
|
|
73
|
-
// If there's no selector, return the first sibling
|
|
74
|
-
if (!selector) return sibling
|
|
75
|
-
|
|
76
|
-
// If the sibling matches our selector, use it
|
|
77
|
-
// If not, jump to the next sibling and continue the loop
|
|
78
|
-
while (sibling) {
|
|
79
|
-
if (sibling.matches(selector)) return sibling
|
|
80
|
-
sibling = sibling.nextElementSibling
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
}
|
|
85
|
-
|
|
86
69
|
export const getOptionsList = (container: HTMLElement): HTMLElement[] => {
|
|
87
70
|
return Array.from(
|
|
88
71
|
container.querySelectorAll('.form-multi-select-option:not(.disabled):not(:disabled)'),
|
|
89
72
|
)
|
|
90
73
|
}
|
|
91
74
|
|
|
92
|
-
export const getPreviousSibling = (elem: HTMLElement, selector?: string) => {
|
|
93
|
-
// Get the next sibling element
|
|
94
|
-
let sibling = elem.previousElementSibling
|
|
95
|
-
|
|
96
|
-
// If there's no selector, return the first sibling
|
|
97
|
-
if (!selector) return sibling
|
|
98
|
-
|
|
99
|
-
// If the sibling matches our selector, use it
|
|
100
|
-
// If not, jump to the next sibling and continue the loop
|
|
101
|
-
while (sibling) {
|
|
102
|
-
if (sibling.matches(selector)) return sibling
|
|
103
|
-
sibling = sibling.previousElementSibling
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
|
|
109
75
|
export const isExternalSearch = (search: Search): boolean => {
|
|
110
76
|
return (
|
|
111
77
|
(typeof search === 'string' && search === 'external') ||
|