@coreui/react-pro 4.10.0 → 4.11.0-next.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.
- package/README.md +1 -1
- package/dist/components/calendar/CCalendar.d.ts +12 -0
- package/dist/components/multi-select/CMultiSelect.d.ts +18 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -0
- package/dist/components/multi-select/types.d.ts +1 -0
- package/dist/components/multi-select/utils.d.ts +5 -0
- package/dist/components/smart-table/CSmartTableInterface.d.ts +1 -1
- package/dist/index.es.js +143 -58
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +143 -58
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/calendar/CCalendar.tsx +130 -59
- package/src/components/calendar/utils.ts +1 -0
- package/src/components/date-range-picker/CDateRangePicker.tsx +4 -0
- package/src/components/multi-select/CMultiSelect.tsx +101 -14
- package/src/components/multi-select/CMultiSelectOptions.tsx +29 -16
- package/src/components/multi-select/types.ts +1 -0
- package/src/components/multi-select/utils.ts +42 -25
- package/src/components/smart-table/CSmartTableInterface.tsx +1 -1
- package/src/components/virtual-scroller/CVirtualScroller.tsx +8 -7
|
@@ -1,33 +1,50 @@
|
|
|
1
1
|
import type { Option, SelectedOption } from './types'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
3
|
+
export const createOption = (text: string, options: Option[]) => {
|
|
4
|
+
const value = text.toLowerCase().replace(/\s/g, '-')
|
|
5
|
+
let uniqueValue = value
|
|
6
|
+
let i = 1
|
|
7
|
+
|
|
8
|
+
while (options.find((option) => String(option.value) === uniqueValue)) {
|
|
9
|
+
uniqueValue = `${value}-${i}`
|
|
10
|
+
i++
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
value: uniqueValue,
|
|
16
|
+
text,
|
|
17
|
+
custom: true,
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const filterOptionsList = (search: string, _options: Option[]) =>
|
|
23
|
+
search.length > 0
|
|
5
24
|
? _options &&
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return acc
|
|
22
|
-
}, [])
|
|
25
|
+
_options.reduce((acc: Option[], val: Option) => {
|
|
26
|
+
const options =
|
|
27
|
+
val.options &&
|
|
28
|
+
val.options.filter(
|
|
29
|
+
(element) => element.text && element.text.toLowerCase().includes(search.toLowerCase()),
|
|
30
|
+
)
|
|
31
|
+
if (
|
|
32
|
+
(val.text && val.text.toLowerCase().includes(search.toLowerCase())) ||
|
|
33
|
+
(options && options.length > 0)
|
|
34
|
+
) {
|
|
35
|
+
acc.push(Object.assign({}, val, options && options.length > 0 && { options }))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return acc
|
|
39
|
+
}, [])
|
|
23
40
|
: _options
|
|
24
|
-
}
|
|
25
41
|
|
|
26
|
-
export const flattenArray = (options: Option[]): Option[] =>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
export const flattenArray = (options: Option[]): Option[] =>
|
|
43
|
+
options.reduce(
|
|
44
|
+
(acc: Option[], val: Option) =>
|
|
45
|
+
acc.concat(Array.isArray(val.options) ? flattenArray(val.options) : val),
|
|
46
|
+
[],
|
|
47
|
+
)
|
|
31
48
|
|
|
32
49
|
export const getNextSibling = (elem: HTMLElement, selector?: string) => {
|
|
33
50
|
// Get the next sibling element
|
|
@@ -121,7 +121,7 @@ export interface CSmartTableProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
121
121
|
*/
|
|
122
122
|
itemsPerPageSelect?: boolean | ItemsPerPageSelect
|
|
123
123
|
/**
|
|
124
|
-
* When set, table will have loading style: loading spinner and reduced opacity.
|
|
124
|
+
* When set, table will have loading style: loading spinner and reduced opacity.
|
|
125
125
|
*/
|
|
126
126
|
loading?: boolean
|
|
127
127
|
/**
|
|
@@ -43,17 +43,17 @@ export const CVirtualScroller = forwardRef<HTMLDivElement, CVirtualScrollerProps
|
|
|
43
43
|
})
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
|
-
setItemsNumber(
|
|
47
|
-
}, [children
|
|
46
|
+
setItemsNumber(React.Children.count(children))
|
|
47
|
+
}, [children])
|
|
48
48
|
|
|
49
49
|
useEffect(() => {
|
|
50
|
-
setViewportHeight(visibleItems * itemHeight + 2 * viewportPadding)
|
|
51
|
-
}, [viewportPadding, visibleItems
|
|
50
|
+
setViewportHeight(Math.min(visibleItems, itemsNumber) * itemHeight + 2 * viewportPadding)
|
|
51
|
+
}, [itemHeight, itemsNumber, viewportPadding, visibleItems])
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
|
-
setMaxHeight(itemsNumber * itemHeight
|
|
54
|
+
setMaxHeight(itemsNumber * itemHeight)
|
|
55
55
|
virtualScrollRef.current && virtualScrollRef.current.scrollTop
|
|
56
|
-
}, [
|
|
56
|
+
}, [itemHeight, itemsNumber])
|
|
57
57
|
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
setBuffer(Math.floor(visibleItems / 2))
|
|
@@ -73,7 +73,8 @@ export const CVirtualScroller = forwardRef<HTMLDivElement, CVirtualScrollerProps
|
|
|
73
73
|
}
|
|
74
74
|
ref={forkedRef}
|
|
75
75
|
style={{
|
|
76
|
-
height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
76
|
+
// height: maxHeight > viewportHeight ? viewportHeight : maxHeight,
|
|
77
|
+
height: viewportHeight,
|
|
77
78
|
overflowY: 'auto',
|
|
78
79
|
}}
|
|
79
80
|
>
|