@coreui/react-pro 4.12.0-beta.0 → 4.12.0-beta.2
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/multi-select/CMultiSelect.d.ts +2 -2
- package/dist/hooks/useColorModes.d.ts +2 -1
- package/dist/index.es.js +12 -4
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/multi-select/CMultiSelect.tsx +2 -2
- package/src/hooks/useColorModes.ts +17 -6
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.12.0-beta.
|
|
45
|
+
- [Download the latest release](https://github.com/coreui/coreui-react-pro/archive/v4.12.0-beta.2.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`
|
|
@@ -76,13 +76,13 @@ export interface CMultiSelectProps extends Omit<CFormControlWrapperProps, 'float
|
|
|
76
76
|
/**
|
|
77
77
|
* Custom template for options.
|
|
78
78
|
*
|
|
79
|
-
* @since 4.12.0-beta.
|
|
79
|
+
* @since 4.12.0-beta.2
|
|
80
80
|
*/
|
|
81
81
|
optionsTemplate?: (option: Option) => ReactNode;
|
|
82
82
|
/**
|
|
83
83
|
* Custom template for options groups.
|
|
84
84
|
*
|
|
85
|
-
* @since 4.12.0-beta.
|
|
85
|
+
* @since 4.12.0-beta.2
|
|
86
86
|
*/
|
|
87
87
|
optionsGroupsTemplate?: (option: OptionsGroup) => ReactNode;
|
|
88
88
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface UseColorModesOutput {
|
|
2
|
-
getColorMode: () => string;
|
|
2
|
+
getColorMode: () => string | undefined;
|
|
3
|
+
isColorModeSet: () => boolean;
|
|
3
4
|
setColorMode: (mode: string) => void;
|
|
4
5
|
}
|
|
5
6
|
export declare const useColorModes: (localStorageItemName?: string) => UseColorModesOutput;
|
package/dist/index.es.js
CHANGED
|
@@ -2474,11 +2474,16 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends$1({},
|
|
|
2474
2474
|
}) : {};
|
|
2475
2475
|
var CSSTransition$1 = CSSTransition;
|
|
2476
2476
|
|
|
2477
|
-
var getStoredTheme = function (localStorageItemName) {
|
|
2477
|
+
var getStoredTheme = function (localStorageItemName) {
|
|
2478
|
+
return typeof window !== 'undefined' && localStorage.getItem(localStorageItemName);
|
|
2479
|
+
};
|
|
2478
2480
|
var setStoredTheme = function (localStorageItemName, colorMode) {
|
|
2479
2481
|
return localStorage.setItem(localStorageItemName, colorMode);
|
|
2480
2482
|
};
|
|
2481
2483
|
var getPreferredColorScheme = function (localStorageItemName) {
|
|
2484
|
+
if (typeof window === 'undefined') {
|
|
2485
|
+
return;
|
|
2486
|
+
}
|
|
2482
2487
|
var storedTheme = getStoredTheme(localStorageItemName);
|
|
2483
2488
|
if (storedTheme) {
|
|
2484
2489
|
return storedTheme;
|
|
@@ -2497,19 +2502,22 @@ var useColorModes = function (localStorageItemName) {
|
|
|
2497
2502
|
if (localStorageItemName === void 0) { localStorageItemName = 'coreui-react-color-scheme'; }
|
|
2498
2503
|
var _a = useState(getPreferredColorScheme(localStorageItemName)), colorMode = _a[0], setColorMode = _a[1];
|
|
2499
2504
|
useEffect(function () {
|
|
2500
|
-
|
|
2501
|
-
|
|
2505
|
+
if (colorMode) {
|
|
2506
|
+
setStoredTheme(localStorageItemName, colorMode);
|
|
2507
|
+
setTheme(colorMode);
|
|
2508
|
+
}
|
|
2502
2509
|
}, [colorMode]);
|
|
2503
2510
|
useEffect(function () {
|
|
2504
2511
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function () {
|
|
2505
2512
|
var storedTheme = getStoredTheme(localStorageItemName);
|
|
2506
|
-
if (storedTheme !== 'light' && storedTheme !== 'dark') {
|
|
2513
|
+
if (storedTheme !== 'light' && storedTheme !== 'dark' && colorMode) {
|
|
2507
2514
|
setTheme(colorMode);
|
|
2508
2515
|
}
|
|
2509
2516
|
});
|
|
2510
2517
|
}, []);
|
|
2511
2518
|
return {
|
|
2512
2519
|
getColorMode: function () { return colorMode; },
|
|
2520
|
+
isColorModeSet: function () { return Boolean(getStoredTheme(localStorageItemName)); },
|
|
2513
2521
|
setColorMode: function (mode) { return setColorMode(mode); },
|
|
2514
2522
|
};
|
|
2515
2523
|
};
|