@coreui/react-pro 5.10.0 → 5.11.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/accordion/CAccordionButton.js +2 -2
- package/dist/cjs/components/accordion/CAccordionButton.js.map +1 -1
- package/dist/cjs/components/accordion/CAccordionItem.d.ts +1 -0
- package/dist/cjs/components/accordion/CAccordionItem.js +6 -3
- package/dist/cjs/components/accordion/CAccordionItem.js.map +1 -1
- package/dist/cjs/components/badge/CBadge.js +1 -1
- package/dist/cjs/components/badge/CBadge.js.map +1 -1
- package/dist/cjs/components/calendar/CCalendar.d.ts +57 -44
- package/dist/cjs/components/calendar/CCalendar.js +51 -187
- package/dist/cjs/components/calendar/CCalendar.js.map +1 -1
- package/dist/cjs/components/calendar/CCalendarNavigation.d.ts +21 -0
- package/dist/cjs/components/calendar/CCalendarNavigation.js +23 -0
- package/dist/cjs/components/calendar/CCalendarNavigation.js.map +1 -0
- package/dist/cjs/components/calendar/CCalendarPanel.d.ts +28 -0
- package/dist/cjs/components/calendar/CCalendarPanel.js +149 -0
- package/dist/cjs/components/calendar/CCalendarPanel.js.map +1 -0
- package/dist/cjs/components/calendar/types.d.ts +3 -0
- package/dist/cjs/components/calendar/utils.d.ts +175 -18
- package/dist/cjs/components/calendar/utils.js +312 -43
- package/dist/cjs/components/calendar/utils.js.map +1 -1
- package/dist/cjs/components/date-picker/CDatePicker.d.ts +1 -1
- package/dist/cjs/components/date-range-picker/CDateRangePicker.d.ts +2 -2
- package/dist/cjs/components/date-range-picker/CDateRangePicker.js +0 -2
- package/dist/cjs/components/date-range-picker/CDateRangePicker.js.map +1 -1
- package/dist/cjs/components/date-range-picker/utils.d.ts +16 -0
- package/dist/cjs/components/date-range-picker/utils.js +18 -2
- package/dist/cjs/components/date-range-picker/utils.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownToggle.js +1 -1
- package/dist/cjs/components/dropdown/CDropdownToggle.js.map +1 -1
- package/dist/cjs/components/modal/CModal.js +0 -1
- package/dist/cjs/components/modal/CModal.js.map +1 -1
- package/dist/cjs/components/nav/CNavGroup.js +1 -1
- package/dist/cjs/components/nav/CNavGroup.js.map +1 -1
- package/dist/cjs/components/progress/CProgress.d.ts +1 -1
- package/dist/cjs/components/range-slider/CRangeSlider.js +6 -2
- package/dist/cjs/components/range-slider/CRangeSlider.js.map +1 -1
- package/dist/cjs/components/sidebar/CSidebar.d.ts +7 -2
- package/dist/cjs/components/sidebar/CSidebar.js +7 -6
- package/dist/cjs/components/sidebar/CSidebar.js.map +1 -1
- package/dist/cjs/components/smart-pagination/CSmartPagination.d.ts +4 -12
- package/dist/cjs/components/smart-pagination/CSmartPagination.js.map +1 -1
- package/dist/cjs/components/smart-table/CSmartTableHead.js +10 -25
- package/dist/cjs/components/smart-table/CSmartTableHead.js.map +1 -1
- package/dist/cjs/components/time-picker/CTimePicker.d.ts +1 -1
- package/dist/cjs/components/time-picker/CTimePicker.js.map +1 -1
- package/dist/cjs/components/time-picker/types.d.ts +5 -0
- package/dist/cjs/components/time-picker/utils.d.ts +8 -11
- package/dist/cjs/components/time-picker/utils.js +8 -4
- package/dist/cjs/components/time-picker/utils.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +2 -1
- package/dist/cjs/hooks/useClipboard.d.ts +12 -0
- package/dist/cjs/hooks/useClipboard.js +54 -0
- package/dist/cjs/hooks/useClipboard.js.map +1 -0
- package/dist/cjs/hooks/useColorModes.js +5 -5
- package/dist/cjs/hooks/useColorModes.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/node_modules/react-device-detect/dist/lib.js +1 -1
- package/dist/cjs/node_modules/react-device-detect/dist/lib.js.map +1 -1
- package/dist/cjs/node_modules/tslib/tslib.es6.js +40 -0
- package/dist/cjs/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +2 -1
- package/dist/cjs/utils/mergeClassNames.d.ts +2 -0
- package/dist/esm/components/accordion/CAccordionButton.js +2 -2
- package/dist/esm/components/accordion/CAccordionButton.js.map +1 -1
- package/dist/esm/components/accordion/CAccordionItem.d.ts +1 -0
- package/dist/esm/components/accordion/CAccordionItem.js +7 -4
- package/dist/esm/components/accordion/CAccordionItem.js.map +1 -1
- package/dist/esm/components/badge/CBadge.js +1 -1
- package/dist/esm/components/badge/CBadge.js.map +1 -1
- package/dist/esm/components/calendar/CCalendar.d.ts +57 -44
- package/dist/esm/components/calendar/CCalendar.js +52 -188
- package/dist/esm/components/calendar/CCalendar.js.map +1 -1
- package/dist/esm/components/calendar/CCalendarNavigation.d.ts +21 -0
- package/dist/esm/components/calendar/CCalendarNavigation.js +21 -0
- package/dist/esm/components/calendar/CCalendarNavigation.js.map +1 -0
- package/dist/esm/components/calendar/CCalendarPanel.d.ts +28 -0
- package/dist/esm/components/calendar/CCalendarPanel.js +147 -0
- package/dist/esm/components/calendar/CCalendarPanel.js.map +1 -0
- package/dist/esm/components/calendar/types.d.ts +3 -0
- package/dist/esm/components/calendar/utils.d.ts +175 -18
- package/dist/esm/components/calendar/utils.js +306 -44
- package/dist/esm/components/calendar/utils.js.map +1 -1
- package/dist/esm/components/date-picker/CDatePicker.d.ts +1 -1
- package/dist/esm/components/date-range-picker/CDateRangePicker.d.ts +2 -2
- package/dist/esm/components/date-range-picker/CDateRangePicker.js +0 -2
- package/dist/esm/components/date-range-picker/CDateRangePicker.js.map +1 -1
- package/dist/esm/components/date-range-picker/utils.d.ts +16 -0
- package/dist/esm/components/date-range-picker/utils.js +18 -2
- package/dist/esm/components/date-range-picker/utils.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownToggle.js +1 -1
- package/dist/esm/components/dropdown/CDropdownToggle.js.map +1 -1
- package/dist/esm/components/modal/CModal.js +0 -1
- package/dist/esm/components/modal/CModal.js.map +1 -1
- package/dist/esm/components/nav/CNavGroup.js +1 -1
- package/dist/esm/components/nav/CNavGroup.js.map +1 -1
- package/dist/esm/components/progress/CProgress.d.ts +1 -1
- package/dist/esm/components/range-slider/CRangeSlider.js +6 -2
- package/dist/esm/components/range-slider/CRangeSlider.js.map +1 -1
- package/dist/esm/components/sidebar/CSidebar.d.ts +7 -2
- package/dist/esm/components/sidebar/CSidebar.js +7 -6
- package/dist/esm/components/sidebar/CSidebar.js.map +1 -1
- package/dist/esm/components/smart-pagination/CSmartPagination.d.ts +4 -12
- package/dist/esm/components/smart-pagination/CSmartPagination.js.map +1 -1
- package/dist/esm/components/smart-table/CSmartTableHead.js +11 -26
- package/dist/esm/components/smart-table/CSmartTableHead.js.map +1 -1
- package/dist/esm/components/time-picker/CTimePicker.d.ts +1 -1
- package/dist/esm/components/time-picker/CTimePicker.js.map +1 -1
- package/dist/esm/components/time-picker/types.d.ts +5 -0
- package/dist/esm/components/time-picker/utils.d.ts +8 -11
- package/dist/esm/components/time-picker/utils.js +8 -4
- package/dist/esm/components/time-picker/utils.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +2 -1
- package/dist/esm/hooks/useClipboard.d.ts +12 -0
- package/dist/esm/hooks/useClipboard.js +52 -0
- package/dist/esm/hooks/useClipboard.js.map +1 -0
- package/dist/esm/hooks/useColorModes.js +5 -5
- package/dist/esm/hooks/useColorModes.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node_modules/react-device-detect/dist/lib.js +1 -1
- package/dist/esm/node_modules/react-device-detect/dist/lib.js.map +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js +39 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/esm/utils/index.d.ts +2 -1
- package/dist/esm/utils/mergeClassNames.d.ts +2 -0
- package/package.json +12 -10
- package/src/components/accordion/CAccordionButton.tsx +3 -2
- package/src/components/accordion/CAccordionItem.tsx +8 -3
- package/src/components/accordion/__tests__/__snapshots__/CAccordionButton.spec.tsx.snap +0 -2
- package/src/components/accordion/__tests__/__snapshots__/CAccordionHeader.spec.tsx.snap +0 -2
- package/src/components/badge/CBadge.tsx +1 -1
- package/src/components/calendar/CCalendar.tsx +154 -489
- package/src/components/calendar/CCalendarNavigation.tsx +120 -0
- package/src/components/calendar/CCalendarPanel.tsx +306 -0
- package/src/components/calendar/types.ts +5 -0
- package/src/components/calendar/utils.ts +414 -109
- package/src/components/carousel/__tests__/CCarousel.spec.tsx +1 -2
- package/src/components/date-picker/CDatePicker.tsx +1 -1
- package/src/components/date-range-picker/CDateRangePicker.tsx +2 -4
- package/src/components/date-range-picker/utils.ts +23 -3
- package/src/components/dropdown/CDropdownToggle.tsx +1 -1
- package/src/components/dropdown/__tests__/CDropdown.spec.tsx +43 -19
- package/src/components/modal/CModal.tsx +0 -2
- package/src/components/modal/__tests__/CModal.spec.tsx +33 -25
- package/src/components/nav/CNavGroup.tsx +5 -1
- package/src/components/nav/__tests__/__snapshots__/CNavGroup.spec.tsx.snap +4 -1
- package/src/components/popover/__tests__/CPopover.spec.tsx +1 -1
- package/src/components/popover/__tests__/__snapshots__/CPopover.spec.tsx.snap +2 -3
- package/src/components/progress/CProgress.tsx +1 -1
- package/src/components/range-slider/CRangeSlider.tsx +7 -2
- package/src/components/sidebar/CSidebar.tsx +15 -5
- package/src/components/smart-pagination/CSmartPagination.tsx +4 -12
- package/src/components/smart-table/CSmartTableHead.tsx +7 -34
- package/src/components/time-picker/CTimePicker.tsx +3 -3
- package/src/components/time-picker/types.ts +7 -0
- package/src/components/time-picker/utils.ts +15 -13
- package/src/components/tooltip/__tests__/__snapshots__/CTooltip.spec.tsx.snap +0 -1
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useClipboard.ts +38 -0
- package/src/hooks/useColorModes.ts +5 -5
- package/src/utils/index.ts +2 -0
- package/src/utils/mergeClassNames.ts +25 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* useClipboard Hook
|
|
5
|
+
*
|
|
6
|
+
* Provides functionality to copy text to the clipboard and track the copy status.
|
|
7
|
+
*
|
|
8
|
+
* @returns An object containing the copy function, copy status, and any error encountered.
|
|
9
|
+
*/
|
|
10
|
+
export const useClipboard = () => {
|
|
11
|
+
const [isCopied, setIsCopied] = useState<boolean>(false)
|
|
12
|
+
const [error, setError] = useState<Error | null>(null)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Copies the provided text to the clipboard.
|
|
16
|
+
*
|
|
17
|
+
* @param text - The text to be copied to the clipboard.
|
|
18
|
+
*/
|
|
19
|
+
const copy = useCallback(async (text: string) => {
|
|
20
|
+
if (!navigator?.clipboard) {
|
|
21
|
+
setError(new Error('Clipboard API is not available'))
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await navigator.clipboard.writeText(text)
|
|
27
|
+
setIsCopied(true)
|
|
28
|
+
setError(null)
|
|
29
|
+
// Reset the isCopied state after 2 seconds
|
|
30
|
+
setTimeout(() => setIsCopied(false), 2000)
|
|
31
|
+
} catch (_error) {
|
|
32
|
+
setError(_error as Error)
|
|
33
|
+
setIsCopied(false)
|
|
34
|
+
}
|
|
35
|
+
}, [])
|
|
36
|
+
|
|
37
|
+
return { copy, isCopied, error }
|
|
38
|
+
}
|
|
@@ -7,13 +7,13 @@ interface UseColorModesOutput {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const getStoredTheme = (localStorageItemName: string) =>
|
|
10
|
-
typeof
|
|
10
|
+
typeof globalThis !== 'undefined' && localStorage.getItem(localStorageItemName)
|
|
11
11
|
|
|
12
12
|
const setStoredTheme = (localStorageItemName: string, colorMode: string) =>
|
|
13
13
|
localStorage.setItem(localStorageItemName, colorMode)
|
|
14
14
|
|
|
15
15
|
const getPreferredColorScheme = (localStorageItemName: string) => {
|
|
16
|
-
if (typeof
|
|
16
|
+
if (typeof globalThis === 'undefined') {
|
|
17
17
|
return 'light'
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -23,12 +23,12 @@ const getPreferredColorScheme = (localStorageItemName: string) => {
|
|
|
23
23
|
return storedTheme
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
return
|
|
26
|
+
return globalThis.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const setTheme = (colorMode: string) => {
|
|
30
30
|
document.documentElement.dataset.coreuiTheme =
|
|
31
|
-
colorMode === 'auto' &&
|
|
31
|
+
colorMode === 'auto' && globalThis.matchMedia('(prefers-color-scheme: dark)').matches
|
|
32
32
|
? 'dark'
|
|
33
33
|
: colorMode
|
|
34
34
|
|
|
@@ -51,7 +51,7 @@ export const useColorModes = (
|
|
|
51
51
|
}, [colorMode])
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
|
-
|
|
54
|
+
globalThis.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
|
55
55
|
const storedTheme = getStoredTheme(localStorageItemName)
|
|
56
56
|
if (storedTheme !== 'light' && storedTheme !== 'dark' && colorMode) {
|
|
57
57
|
setTheme(colorMode)
|
package/src/utils/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import isEqual from './isEqual'
|
|
|
6
6
|
import isInViewport from './isInViewport'
|
|
7
7
|
import isObjectInArray from './isObjectInArray'
|
|
8
8
|
import isRTL from './isRTL'
|
|
9
|
+
import mergeClassNames from './mergeClassNames'
|
|
9
10
|
|
|
10
11
|
export {
|
|
11
12
|
executeAfterTransition,
|
|
@@ -16,4 +17,5 @@ export {
|
|
|
16
17
|
isInViewport,
|
|
17
18
|
isObjectInArray,
|
|
18
19
|
isRTL,
|
|
20
|
+
mergeClassNames,
|
|
19
21
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const mergeClassNames = <T extends object>(
|
|
2
|
+
defaultClassNames: T,
|
|
3
|
+
customClassNames?: Partial<T>,
|
|
4
|
+
): T => {
|
|
5
|
+
if (customClassNames === undefined || typeof customClassNames !== 'object') {
|
|
6
|
+
return defaultClassNames
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const classNames: T = { ...defaultClassNames }
|
|
10
|
+
|
|
11
|
+
for (const key in customClassNames) {
|
|
12
|
+
if (customClassNames.hasOwnProperty(key)) {
|
|
13
|
+
const typedKey = key as keyof T
|
|
14
|
+
const customClassName = customClassNames[typedKey]?.toString()
|
|
15
|
+
|
|
16
|
+
classNames[typedKey] = customClassName?.startsWith('!')
|
|
17
|
+
? (customClassName.slice(1).trim() as T[keyof T])
|
|
18
|
+
: (`${classNames[typedKey]} ${customClassName}`.trim() as T[keyof T])
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return classNames
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default mergeClassNames
|