@coreui/vue-pro 4.9.0-beta.0 → 4.9.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/composables/useColorModes.d.ts +2 -1
- package/dist/directives/v-c-tooltip.d.ts +1 -0
- package/dist/index.es.js +19 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +19 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/sidebar/CSidebar.ts +7 -2
- package/src/composables/useColorModes.ts +13 -7
- package/src/directives/v-c-tooltip.ts +1 -0
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -3,8 +3,13 @@ import { CBackdrop } from '../backdrop'
|
|
|
3
3
|
|
|
4
4
|
import { isInViewport } from '../../utils'
|
|
5
5
|
|
|
6
|
-
const isOnMobile = (element: HTMLDivElement) =>
|
|
7
|
-
|
|
6
|
+
const isOnMobile = (element: HTMLDivElement) => {
|
|
7
|
+
if (!element) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return Boolean(getComputedStyle(element).getPropertyValue('--cui-is-mobile'))
|
|
12
|
+
}
|
|
8
13
|
|
|
9
14
|
const CSidebar = defineComponent({
|
|
10
15
|
name: 'CSidebar',
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { onBeforeMount, ref, watch } from 'vue'
|
|
2
2
|
|
|
3
|
-
const getStoredTheme = (localStorageItemName: string) =>
|
|
3
|
+
const getStoredTheme = (localStorageItemName: string) =>
|
|
4
|
+
typeof window !== 'undefined' && localStorage.getItem(localStorageItemName)
|
|
4
5
|
const setStoredTheme = (localStorageItemName: string, colorMode: string) =>
|
|
5
6
|
localStorage.setItem(localStorageItemName, colorMode)
|
|
6
7
|
|
|
7
8
|
const getPreferredColorScheme = (localStorageItemName: string) => {
|
|
9
|
+
if (typeof window === 'undefined') {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
const storedTheme = getStoredTheme(localStorageItemName)
|
|
9
14
|
|
|
10
15
|
if (storedTheme) {
|
|
@@ -28,27 +33,28 @@ export const useColorModes = (localStorageItemName = 'coreui-vue-color-scheme')
|
|
|
28
33
|
const colorMode = ref(getPreferredColorScheme(localStorageItemName))
|
|
29
34
|
|
|
30
35
|
watch(colorMode, () => {
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
if (colorMode.value) {
|
|
37
|
+
setStoredTheme(localStorageItemName, colorMode.value)
|
|
38
|
+
setTheme(colorMode.value)
|
|
39
|
+
}
|
|
33
40
|
})
|
|
34
41
|
|
|
35
42
|
onBeforeMount(() => {
|
|
36
|
-
if (typeof getStoredTheme(localStorageItemName) === 'string') {
|
|
43
|
+
if (typeof getStoredTheme(localStorageItemName) === 'string' && colorMode.value) {
|
|
37
44
|
setTheme(colorMode.value)
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
|
|
41
48
|
const storedTheme = getStoredTheme(localStorageItemName)
|
|
42
|
-
if (storedTheme !== 'light' && storedTheme !== 'dark') {
|
|
49
|
+
if (storedTheme !== 'light' && storedTheme !== 'dark' && colorMode.value) {
|
|
43
50
|
setTheme(colorMode.value)
|
|
44
51
|
}
|
|
45
52
|
})
|
|
46
|
-
|
|
47
|
-
watch(colorMode, () => setTheme(colorMode.value))
|
|
48
53
|
})
|
|
49
54
|
|
|
50
55
|
return {
|
|
51
56
|
getColorMode: () => colorMode.value,
|
|
57
|
+
isColorModeSet: () => Boolean(getStoredTheme(localStorageItemName)),
|
|
52
58
|
setColorMode: (mode: string) => {
|
|
53
59
|
colorMode.value = mode
|
|
54
60
|
},
|
|
@@ -40,6 +40,7 @@ const toggleTooltipElement = (tooltip: HTMLDivElement, el: HTMLElement, popperOp
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export default {
|
|
43
|
+
name: 'c-tooltip',
|
|
43
44
|
mounted(el: HTMLElement, binding: DirectiveBinding): void {
|
|
44
45
|
const value = binding.value
|
|
45
46
|
const content = typeof value === 'string' ? value : value.content ?? ''
|