@code-coaching/vuetiful 0.23.1 → 0.23.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.
Files changed (144) hide show
  1. package/dist/style.css +1 -1
  2. package/dist/types/components/VBootstrap.vue.d.ts +1 -1
  3. package/dist/types/components/atoms/VAvatar.vue.d.ts +1 -1
  4. package/dist/types/components/atoms/VLightSwitch.vue.d.ts +2 -2
  5. package/dist/types/components/atoms/index.d.ts +13 -13
  6. package/dist/types/components/index.d.ts +2 -2
  7. package/dist/types/components/molecules/VAlert.vue.d.ts +1 -1
  8. package/dist/types/components/molecules/VCodeBlock.vue.d.ts +2 -2
  9. package/dist/types/components/molecules/VDrawer.vue.d.ts +1 -1
  10. package/dist/types/components/molecules/VListbox/VListbox.vue.d.ts +1 -1
  11. package/dist/types/components/molecules/VRail/VRail.vue.d.ts +1 -1
  12. package/dist/types/components/molecules/VRail/VRailTile.vue.d.ts +1 -1
  13. package/dist/types/components/molecules/index.d.ts +21 -21
  14. package/dist/types/directives/clipboard.d.ts +1 -1
  15. package/dist/types/directives/index.d.ts +1 -1
  16. package/dist/types/index.d.ts +6 -6
  17. package/dist/types/props/props.d.ts +1 -1
  18. package/dist/types/services/dark-mode.service.d.ts +1 -1
  19. package/dist/types/services/drawer.service.d.ts +1 -1
  20. package/dist/types/services/index.d.ts +5 -5
  21. package/dist/types/types/index.d.ts +1 -1
  22. package/dist/types/utils/index.d.ts +2 -2
  23. package/dist/types/utils/theme/theme-switcher.vue.d.ts +1 -1
  24. package/dist/types/utils/theme/theme.service.d.ts +1 -1
  25. package/dist/vuetiful.es.mjs +12 -18
  26. package/dist/vuetiful.umd.js +3 -3
  27. package/package.json +1 -1
  28. package/src/assets/main.css +6 -6
  29. package/src/components/VBootstrap.vue +43 -43
  30. package/src/components/atoms/VAvatar.test.ts +71 -71
  31. package/src/components/atoms/VAvatar.vue +22 -23
  32. package/src/components/atoms/VBadge.test.ts +11 -11
  33. package/src/components/atoms/VBadge.vue +2 -2
  34. package/src/components/atoms/VButton.test.ts +82 -82
  35. package/src/components/atoms/VButton.vue +20 -21
  36. package/src/components/atoms/VChip.test.ts +11 -11
  37. package/src/components/atoms/VChip.vue +3 -3
  38. package/src/components/atoms/VLightSwitch.test.ts +6 -6
  39. package/src/components/atoms/VLightSwitch.vue +26 -31
  40. package/src/components/atoms/VRadio/VRadioDescription.test.ts +13 -13
  41. package/src/components/atoms/VRadio/VRadioDescription.vue +2 -2
  42. package/src/components/atoms/VRadio/VRadioGroup.test.ts +40 -40
  43. package/src/components/atoms/VRadio/VRadioGroup.vue +19 -22
  44. package/src/components/atoms/VRadio/VRadioItem.test.ts +67 -67
  45. package/src/components/atoms/VRadio/VRadioItem.vue +10 -13
  46. package/src/components/atoms/VRadio/VRadioLabel.test.ts +13 -13
  47. package/src/components/atoms/VRadio/VRadioLabel.vue +5 -3
  48. package/src/components/atoms/VSwitch/VSwitch.test.ts +33 -33
  49. package/src/components/atoms/VSwitch/VSwitch.vue +24 -27
  50. package/src/components/atoms/VSwitch/VSwitchDescription.test.ts +13 -13
  51. package/src/components/atoms/VSwitch/VSwitchDescription.vue +2 -2
  52. package/src/components/atoms/VSwitch/VSwitchGroup.test.ts +9 -9
  53. package/src/components/atoms/VSwitch/VSwitchGroup.vue +2 -2
  54. package/src/components/atoms/VSwitch/VSwitchLabel.test.ts +19 -19
  55. package/src/components/atoms/VSwitch/VSwitchLabel.vue +2 -2
  56. package/src/components/atoms/index.ts +13 -13
  57. package/src/components/index.test.ts +3 -3
  58. package/src/components/index.ts +2 -2
  59. package/src/components/molecules/VAccordion/VAccordion.test.ts +11 -17
  60. package/src/components/molecules/VAccordion/VAccordion.vue +3 -3
  61. package/src/components/molecules/VAccordion/VAccordionItem.test.ts +55 -55
  62. package/src/components/molecules/VAccordion/VAccordionItem.vue +9 -22
  63. package/src/components/molecules/VAlert.test.ts +38 -38
  64. package/src/components/molecules/VAlert.vue +25 -47
  65. package/src/components/molecules/VCard/VCard.test.ts +25 -25
  66. package/src/components/molecules/VCard/VCard.vue +13 -15
  67. package/src/components/molecules/VCard/VCardBody.test.ts +14 -14
  68. package/src/components/molecules/VCard/VCardBody.vue +4 -8
  69. package/src/components/molecules/VCard/VCardFooter.test.ts +22 -22
  70. package/src/components/molecules/VCard/VCardFooter.vue +10 -8
  71. package/src/components/molecules/VCard/VCardHeader.test.ts +25 -25
  72. package/src/components/molecules/VCard/VCardHeader.vue +7 -8
  73. package/src/components/molecules/VCodeBlock.test.ts +63 -63
  74. package/src/components/molecules/VCodeBlock.vue +27 -34
  75. package/src/components/molecules/VDrawer.test.ts +5 -5
  76. package/src/components/molecules/VDrawer.vue +10 -10
  77. package/src/components/molecules/VListbox/VListbox.test.ts +53 -53
  78. package/src/components/molecules/VListbox/VListbox.vue +31 -32
  79. package/src/components/molecules/VListbox/VListboxButton.test.ts +13 -13
  80. package/src/components/molecules/VListbox/VListboxButton.vue +5 -5
  81. package/src/components/molecules/VListbox/VListboxItem.test.ts +25 -25
  82. package/src/components/molecules/VListbox/VListboxItem.vue +7 -8
  83. package/src/components/molecules/VListbox/VListboxItems.test.ts +14 -14
  84. package/src/components/molecules/VListbox/VListboxItems.vue +9 -11
  85. package/src/components/molecules/VListbox/VListboxLabel.test.ts +10 -10
  86. package/src/components/molecules/VListbox/VListboxLabel.vue +2 -2
  87. package/src/components/molecules/VPreview.test.ts +26 -26
  88. package/src/components/molecules/VPreview.vue +22 -27
  89. package/src/components/molecules/VRail/VRail.test.ts +5 -5
  90. package/src/components/molecules/VRail/VRail.vue +7 -7
  91. package/src/components/molecules/VRail/VRailTile.test.ts +26 -28
  92. package/src/components/molecules/VRail/VRailTile.vue +13 -11
  93. package/src/components/molecules/VShell.test.ts +5 -5
  94. package/src/components/molecules/VShell.vue +11 -20
  95. package/src/components/molecules/VTabs/VTab.test.ts +48 -52
  96. package/src/components/molecules/VTabs/VTab.vue +13 -17
  97. package/src/components/molecules/VTabs/VTabPanel.test.ts +8 -8
  98. package/src/components/molecules/VTabs/VTabPanel.vue +1 -1
  99. package/src/components/molecules/VTabs/VTabs.test.ts +36 -36
  100. package/src/components/molecules/VTabs/VTabs.vue +18 -22
  101. package/src/components/molecules/index.ts +21 -21
  102. package/src/directives/clipboard.test.ts +9 -9
  103. package/src/directives/clipboard.ts +2 -2
  104. package/src/directives/index.ts +1 -1
  105. package/src/env.d.ts +2 -2
  106. package/src/index.test.ts +6 -6
  107. package/src/index.ts +7 -7
  108. package/src/props/index.ts +1 -1
  109. package/src/props/props.ts +44 -44
  110. package/src/services/dark-mode.service.test.ts +115 -93
  111. package/src/services/dark-mode.service.ts +9 -9
  112. package/src/services/drawer.service.test.ts +21 -21
  113. package/src/services/drawer.service.ts +10 -10
  114. package/src/services/highlight.service.test.ts +12 -12
  115. package/src/services/highlight.service.ts +1 -1
  116. package/src/services/index.ts +5 -5
  117. package/src/services/rail.service.test.ts +7 -7
  118. package/src/services/rail.service.ts +2 -2
  119. package/src/services/settings.service.test.ts +5 -5
  120. package/src/services/settings.service.ts +1 -1
  121. package/src/styles/all.css +7 -7
  122. package/src/styles/elements/buttons.css +1 -1
  123. package/src/styles/elements/forms.css +7 -7
  124. package/src/styles/elements.css +13 -13
  125. package/src/styles/transitions.css +2 -2
  126. package/src/styles/typography.css +5 -5
  127. package/src/themes/theme-rocket.css +10 -10
  128. package/src/themes/theme-sahara.css +13 -13
  129. package/src/themes/theme-seafoam.css +13 -13
  130. package/src/themes/theme-seasonal.css +4 -4
  131. package/src/themes/theme-skeleton.css +7 -7
  132. package/src/themes/theme-vintage.css +12 -12
  133. package/src/themes/theme-vuetiful-0.0.1.css +13 -13
  134. package/src/types/index.ts +46 -46
  135. package/src/types/tailwind.ts +2 -21
  136. package/src/utils/index.test.ts +3 -3
  137. package/src/utils/index.ts +2 -2
  138. package/src/utils/platform/platform.service.test.ts +6 -6
  139. package/src/utils/platform/platform.service.ts +1 -1
  140. package/src/utils/theme/callback.test.ts +6 -6
  141. package/src/utils/theme/remove.test.ts +8 -8
  142. package/src/utils/theme/theme-switcher.vue +10 -13
  143. package/src/utils/theme/theme.service.test.ts +69 -61
  144. package/src/utils/theme/theme.service.ts +19 -20
@@ -1,6 +1,6 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
2
- import { DirectiveBinding } from "vue";
3
- import { vClipboard } from ".";
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { DirectiveBinding } from 'vue';
3
+ import { vClipboard } from '.';
4
4
 
5
5
  const navigatorMock = {
6
6
  clipboard: {
@@ -8,19 +8,19 @@ const navigatorMock = {
8
8
  } as any,
9
9
  } as any;
10
10
 
11
- describe("clipboard", () => {
11
+ describe('clipboard', () => {
12
12
  afterEach(() => {
13
13
  vi.resetAllMocks();
14
14
  });
15
- describe("given the v-clipboard directive is used", () => {
16
- it("should copy text to the clipboard on click", () => {
15
+ describe('given the v-clipboard directive is used', () => {
16
+ it('should copy text to the clipboard on click', () => {
17
17
  window.navigator = navigatorMock;
18
18
 
19
- const el = document.createElement("div");
20
- vClipboard(el, { value: "John Duck" } as DirectiveBinding);
19
+ const el = document.createElement('div');
20
+ vClipboard(el, { value: 'John Duck' } as DirectiveBinding);
21
21
  el.click();
22
22
 
23
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith("John Duck");
23
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith('John Duck');
24
24
  });
25
25
  });
26
26
  });
@@ -1,7 +1,7 @@
1
- import { DirectiveBinding } from "vue";
1
+ import { DirectiveBinding } from 'vue';
2
2
 
3
3
  const clipboard = (el: HTMLElement, binding: DirectiveBinding) => {
4
- el.addEventListener("click", () => {
4
+ el.addEventListener('click', () => {
5
5
  navigator.clipboard.writeText(binding.value);
6
6
  });
7
7
  };
@@ -1,3 +1,3 @@
1
- import vClipboard from "./clipboard";
1
+ import vClipboard from './clipboard';
2
2
 
3
3
  export { vClipboard };
package/src/env.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="vite/client" />
2
2
 
3
- declare module "*.vue" {
4
- import { DefineComponent } from "vue";
3
+ declare module '*.vue' {
4
+ import { DefineComponent } from 'vue';
5
5
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
6
6
  const component: DefineComponent<{}, {}, any>;
7
7
  export default component;
package/src/index.test.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import * as components from "./components";
3
- import plugin, * as index from "./index";
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import * as components from './components';
3
+ import plugin, * as index from './index';
4
4
 
5
- describe("src", () => {
5
+ describe('src', () => {
6
6
  Object.entries(index).forEach(([key, value]) => {
7
7
  it(`${key} is defined`, () => {
8
8
  expect(value).toBeDefined();
9
9
  });
10
10
  });
11
11
 
12
- describe("given install is called", () => {
13
- it("should register all components", () => {
12
+ describe('given install is called', () => {
13
+ it('should register all components', () => {
14
14
  const app = {
15
15
  component: vi.fn(),
16
16
  };
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as components from "./components";
1
+ import * as components from './components';
2
2
 
3
3
  function install(app: any) {
4
4
  for (const key in components) {
@@ -7,15 +7,15 @@ function install(app: any) {
7
7
  }
8
8
  }
9
9
 
10
- import "./assets/main.css";
11
- import "./styles/tailwind.css";
10
+ import './assets/main.css';
11
+ import './styles/tailwind.css';
12
12
 
13
13
  export default { install };
14
14
 
15
- export * from "./components";
16
- export * from "./utils";
17
- export * from "./directives";
18
- export * from "./services";
15
+ export * from './components';
16
+ export * from './utils';
17
+ export * from './directives';
18
+ export * from './services';
19
19
 
20
20
  // This type alias is to identify CSS classes within component props, which enables Tailwind IntelliSense
21
21
  export type CssClasses = string;
@@ -1 +1 @@
1
- export * from './props';
1
+ export * from './props';
@@ -1,8 +1,8 @@
1
- import { Size, Variant } from "@/types";
2
- import { PropType } from "vue";
1
+ import { Size, Variant } from '@/types';
2
+ import { PropType } from 'vue';
3
3
 
4
4
  const sizeProp = {
5
- type: String as PropType<"xs" | "sm" | "md" | "lg" | "xl">,
5
+ type: String as PropType<'xs' | 'sm' | 'md' | 'lg' | 'xl'>,
6
6
  default: Size.MD,
7
7
  };
8
8
 
@@ -14,47 +14,47 @@ const unstyledProp = {
14
14
  const variantProp = {
15
15
  // explicit string union because TypeScript type won't throw error if invalid value is passed
16
16
  type: String as PropType<
17
- | ""
18
- | "filled"
19
- | "filled-primary"
20
- | "filled-secondary"
21
- | "filled-tertiary"
22
- | "filled-success"
23
- | "filled-warning"
24
- | "filled-error"
25
- | "filled-surface"
26
- | "ringed"
27
- | "ringed-primary"
28
- | "ringed-secondary"
29
- | "ringed-tertiary"
30
- | "ringed-success"
31
- | "ringed-warning"
32
- | "ringed-error"
33
- | "ringed-surface"
34
- | "ghost"
35
- | "ghost-primary"
36
- | "ghost-secondary"
37
- | "ghost-tertiary"
38
- | "ghost-success"
39
- | "ghost-warning"
40
- | "ghost-error"
41
- | "ghost-surface"
42
- | "soft"
43
- | "soft-primary"
44
- | "soft-secondary"
45
- | "soft-tertiary"
46
- | "soft-success"
47
- | "soft-warning"
48
- | "soft-error"
49
- | "soft-surface"
50
- | "glass"
51
- | "glass-primary"
52
- | "glass-secondary"
53
- | "glass-tertiary"
54
- | "glass-success"
55
- | "glass-warning"
56
- | "glass-error"
57
- | "glass-surface"
17
+ | ''
18
+ | 'filled'
19
+ | 'filled-primary'
20
+ | 'filled-secondary'
21
+ | 'filled-tertiary'
22
+ | 'filled-success'
23
+ | 'filled-warning'
24
+ | 'filled-error'
25
+ | 'filled-surface'
26
+ | 'ringed'
27
+ | 'ringed-primary'
28
+ | 'ringed-secondary'
29
+ | 'ringed-tertiary'
30
+ | 'ringed-success'
31
+ | 'ringed-warning'
32
+ | 'ringed-error'
33
+ | 'ringed-surface'
34
+ | 'ghost'
35
+ | 'ghost-primary'
36
+ | 'ghost-secondary'
37
+ | 'ghost-tertiary'
38
+ | 'ghost-success'
39
+ | 'ghost-warning'
40
+ | 'ghost-error'
41
+ | 'ghost-surface'
42
+ | 'soft'
43
+ | 'soft-primary'
44
+ | 'soft-secondary'
45
+ | 'soft-tertiary'
46
+ | 'soft-success'
47
+ | 'soft-warning'
48
+ | 'soft-error'
49
+ | 'soft-surface'
50
+ | 'glass'
51
+ | 'glass-primary'
52
+ | 'glass-secondary'
53
+ | 'glass-tertiary'
54
+ | 'glass-success'
55
+ | 'glass-warning'
56
+ | 'glass-error'
57
+ | 'glass-surface'
58
58
  >,
59
59
  default: Variant.Filled,
60
60
  };
@@ -1,4 +1,4 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
2
 
3
3
  const localStorageMock = {
4
4
  getItem: vi.fn(),
@@ -6,47 +6,53 @@ const localStorageMock = {
6
6
  };
7
7
  const matchMediaMock = (matches: boolean) => vi.fn(() => ({ matches, onchange: vi.fn() }));
8
8
 
9
- describe("useDarkMode", () => {
9
+ describe('useDarkMode', () => {
10
10
  afterEach(() => {
11
11
  vi.resetModules();
12
12
  });
13
- describe("getModeUserPrefers", () => {
14
- describe("given not in browser", () => {
15
- it("should return default modeUserPrefers", async () => {
16
- const platform = await import("../utils/platform/platform.service");
17
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
13
+ describe('getModeUserPrefers', () => {
14
+ describe('given not in browser', () => {
15
+ it('should return default modeUserPrefers', async () => {
16
+ const platform = await import('../utils/platform/platform.service');
17
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
18
+ isBrowser: false,
19
+ });
18
20
 
19
- const { useDarkMode } = await import("./dark-mode.service");
21
+ const { useDarkMode } = await import('./dark-mode.service');
20
22
  const { getModeUserPrefers } = useDarkMode();
21
23
  expect(getModeUserPrefers()).toBe(undefined);
22
24
  });
23
25
  });
24
26
 
25
- describe("given in browser", () => {
26
- describe("given no modeUserPrefers in localStorage", () => {
27
- it("should return default modeUserPrefers", async () => {
28
- const platform = await import("../utils/platform/platform.service");
29
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
27
+ describe('given in browser', () => {
28
+ describe('given no modeUserPrefers in localStorage', () => {
29
+ it('should return default modeUserPrefers', async () => {
30
+ const platform = await import('../utils/platform/platform.service');
31
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
32
+ isBrowser: true,
33
+ });
30
34
 
31
- const { useDarkMode } = await import("./dark-mode.service");
35
+ const { useDarkMode } = await import('./dark-mode.service');
32
36
  const { getModeUserPrefers } = useDarkMode();
33
37
 
34
38
  window.localStorage = localStorageMock as any;
35
- vi.spyOn(window.localStorage, "getItem").mockReturnValueOnce(null);
39
+ vi.spyOn(window.localStorage, 'getItem').mockReturnValueOnce(null);
36
40
 
37
41
  expect(getModeUserPrefers()).toBe(undefined);
38
42
  });
39
43
  });
40
- describe("given modeUserPrefers in localStorage", () => {
41
- it("should return the value", async () => {
42
- const platform = await import("../utils/platform/platform.service");
43
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
44
-
45
- const { useDarkMode } = await import("./dark-mode.service");
44
+ describe('given modeUserPrefers in localStorage', () => {
45
+ it('should return the value', async () => {
46
+ const platform = await import('../utils/platform/platform.service');
47
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
48
+ isBrowser: true,
49
+ });
50
+
51
+ const { useDarkMode } = await import('./dark-mode.service');
46
52
  const { getModeUserPrefers } = useDarkMode();
47
53
 
48
54
  window.localStorage = localStorageMock as any;
49
- vi.spyOn(window.localStorage, "getItem").mockReturnValueOnce("true");
55
+ vi.spyOn(window.localStorage, 'getItem').mockReturnValueOnce('true');
50
56
 
51
57
  expect(getModeUserPrefers()).toBe(true);
52
58
  });
@@ -54,87 +60,99 @@ describe("useDarkMode", () => {
54
60
  });
55
61
  });
56
62
 
57
- describe("getModeOsPrefers", () => {
58
- describe("given not in browser", () => {
59
- it("should return default modeOsPrefers", async () => {
60
- const platform = await import("../utils/platform/platform.service");
61
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
63
+ describe('getModeOsPrefers', () => {
64
+ describe('given not in browser', () => {
65
+ it('should return default modeOsPrefers', async () => {
66
+ const platform = await import('../utils/platform/platform.service');
67
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
68
+ isBrowser: false,
69
+ });
62
70
 
63
- const { useDarkMode } = await import("./dark-mode.service");
71
+ const { useDarkMode } = await import('./dark-mode.service');
64
72
  const { getModeOsPrefers } = useDarkMode();
65
73
  expect(getModeOsPrefers()).toBe(false);
66
74
  });
67
75
  });
68
76
 
69
- describe("given in browser", () => {
70
- describe("given prefers-color-scheme: light", () => {
71
- it("should return true", async () => {
72
- const platform = await import("../utils/platform/platform.service");
73
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
74
- const localStorageSpy = vi.spyOn(window.localStorage, "setItem");
77
+ describe('given in browser', () => {
78
+ describe('given prefers-color-scheme: light', () => {
79
+ it('should return true', async () => {
80
+ const platform = await import('../utils/platform/platform.service');
81
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
82
+ isBrowser: true,
83
+ });
84
+ const localStorageSpy = vi.spyOn(window.localStorage, 'setItem');
75
85
 
76
- const { useDarkMode } = await import("./dark-mode.service");
86
+ const { useDarkMode } = await import('./dark-mode.service');
77
87
  const { getModeOsPrefers, MODE } = useDarkMode();
78
88
 
79
89
  window.matchMedia = matchMediaMock(MODE.LIGHT) as any;
80
90
  expect(getModeOsPrefers()).toBe(MODE.LIGHT);
81
- expect(localStorageSpy).toHaveBeenCalledWith("modeOsPrefers", "true");
91
+ expect(localStorageSpy).toHaveBeenCalledWith('modeOsPrefers', 'true');
82
92
  });
83
93
  });
84
- describe("given prefers-color-scheme: dark", () => {
85
- it("should return false", async () => {
86
- const platform = await import("../utils/platform/platform.service");
87
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
88
- const localStorageSpy = vi.spyOn(window.localStorage, "setItem");
89
-
90
- const { useDarkMode } = await import("./dark-mode.service");
94
+ describe('given prefers-color-scheme: dark', () => {
95
+ it('should return false', async () => {
96
+ const platform = await import('../utils/platform/platform.service');
97
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
98
+ isBrowser: true,
99
+ });
100
+ const localStorageSpy = vi.spyOn(window.localStorage, 'setItem');
101
+
102
+ const { useDarkMode } = await import('./dark-mode.service');
91
103
  const { getModeOsPrefers, MODE } = useDarkMode();
92
104
 
93
105
  window.matchMedia = matchMediaMock(MODE.DARK) as any;
94
106
  expect(getModeOsPrefers()).toBe(MODE.DARK);
95
- expect(localStorageSpy).toHaveBeenCalledWith("modeOsPrefers", "false");
107
+ expect(localStorageSpy).toHaveBeenCalledWith('modeOsPrefers', 'false');
96
108
  });
97
109
  });
98
110
  });
99
111
  });
100
112
 
101
- describe("getModeAutoPrefers", () => {
102
- describe("given not in browser", () => {
103
- it("should return default modeAutoPrefers", async () => {
104
- const platform = await import("../utils/platform/platform.service");
105
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
113
+ describe('getModeAutoPrefers', () => {
114
+ describe('given not in browser', () => {
115
+ it('should return default modeAutoPrefers', async () => {
116
+ const platform = await import('../utils/platform/platform.service');
117
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
118
+ isBrowser: false,
119
+ });
106
120
 
107
- const { useDarkMode } = await import("./dark-mode.service");
121
+ const { useDarkMode } = await import('./dark-mode.service');
108
122
  const { getModeAutoPrefers } = useDarkMode();
109
123
  expect(getModeAutoPrefers()).toBe(false);
110
124
  });
111
125
  });
112
126
 
113
- describe("given in browser", () => {
114
- describe("given no modeUserPrefers in localStorage", () => {
115
- it("should return default modeAutoPrefers", async () => {
116
- const platform = await import("../utils/platform/platform.service");
117
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
127
+ describe('given in browser', () => {
128
+ describe('given no modeUserPrefers in localStorage', () => {
129
+ it('should return default modeAutoPrefers', async () => {
130
+ const platform = await import('../utils/platform/platform.service');
131
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
132
+ isBrowser: true,
133
+ });
118
134
 
119
- const { useDarkMode } = await import("./dark-mode.service");
135
+ const { useDarkMode } = await import('./dark-mode.service');
120
136
  const { getModeAutoPrefers } = useDarkMode();
121
137
 
122
138
  window.localStorage = localStorageMock as any;
123
- vi.spyOn(window.localStorage, "getItem").mockReturnValueOnce(null);
139
+ vi.spyOn(window.localStorage, 'getItem').mockReturnValueOnce(null);
124
140
 
125
141
  expect(getModeAutoPrefers()).toBe(false);
126
142
  });
127
143
  });
128
- describe("given modeUserPrefers in localStorage", () => {
129
- it("should return the value", async () => {
130
- const platform = await import("../utils/platform/platform.service");
131
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
132
-
133
- const { useDarkMode } = await import("./dark-mode.service");
144
+ describe('given modeUserPrefers in localStorage', () => {
145
+ it('should return the value', async () => {
146
+ const platform = await import('../utils/platform/platform.service');
147
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
148
+ isBrowser: true,
149
+ });
150
+
151
+ const { useDarkMode } = await import('./dark-mode.service');
134
152
  const { getModeAutoPrefers } = useDarkMode();
135
153
 
136
154
  window.localStorage = localStorageMock as any;
137
- vi.spyOn(window.localStorage, "getItem").mockReturnValueOnce("true");
155
+ vi.spyOn(window.localStorage, 'getItem').mockReturnValueOnce('true');
138
156
 
139
157
  expect(getModeAutoPrefers()).toBe(true);
140
158
  });
@@ -142,14 +160,16 @@ describe("useDarkMode", () => {
142
160
  });
143
161
  });
144
162
 
145
- describe("setModeUserPrefers", () => {
146
- describe("given not in browser", () => {
147
- it("should set modeUserPrefers", async () => {
148
- const platform = await import("../utils/platform/platform.service");
149
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
150
- vi.spyOn(window.localStorage, "setItem");
163
+ describe('setModeUserPrefers', () => {
164
+ describe('given not in browser', () => {
165
+ it('should set modeUserPrefers', async () => {
166
+ const platform = await import('../utils/platform/platform.service');
167
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
168
+ isBrowser: false,
169
+ });
170
+ vi.spyOn(window.localStorage, 'setItem');
151
171
 
152
- const { useDarkMode } = await import("./dark-mode.service");
172
+ const { useDarkMode } = await import('./dark-mode.service');
153
173
  const { setModeUserPrefers, modeUserPrefers } = useDarkMode();
154
174
 
155
175
  setModeUserPrefers(true);
@@ -158,45 +178,47 @@ describe("useDarkMode", () => {
158
178
  });
159
179
  });
160
180
 
161
- describe("given in browser", () => {
162
- it("should set modeUserPrefers and localStorage", async () => {
163
- const platform = await import("../utils/platform/platform.service");
164
- vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
181
+ describe('given in browser', () => {
182
+ it('should set modeUserPrefers and localStorage', async () => {
183
+ const platform = await import('../utils/platform/platform.service');
184
+ vi.spyOn(platform, 'usePlatform').mockReturnValueOnce({
185
+ isBrowser: true,
186
+ });
165
187
 
166
- const { useDarkMode } = await import("./dark-mode.service");
188
+ const { useDarkMode } = await import('./dark-mode.service');
167
189
  const { setModeUserPrefers, modeUserPrefers } = useDarkMode();
168
190
 
169
- const localStorageSpy = vi.spyOn(window.localStorage, "setItem");
191
+ const localStorageSpy = vi.spyOn(window.localStorage, 'setItem');
170
192
 
171
193
  setModeUserPrefers(true);
172
194
  expect(modeUserPrefers.value).toBe(true);
173
- expect(localStorageSpy).toHaveBeenCalledWith("modeUserPrefers", "true");
195
+ expect(localStorageSpy).toHaveBeenCalledWith('modeUserPrefers', 'true');
174
196
  });
175
197
  });
176
198
  });
177
199
 
178
- describe("setModeCurrent", () => {
179
- it("light mode set", async () => {
180
- const { useDarkMode } = await import("./dark-mode.service");
200
+ describe('setModeCurrent', () => {
201
+ it('light mode set', async () => {
202
+ const { useDarkMode } = await import('./dark-mode.service');
181
203
  const { setModeCurrent, currentMode, MODE } = useDarkMode();
182
204
 
183
205
  setModeCurrent(MODE.LIGHT);
184
206
  expect(currentMode.value).toBe(MODE.LIGHT);
185
- expect(document.documentElement.classList.contains("dark")).toBe(false);
207
+ expect(document.documentElement.classList.contains('dark')).toBe(false);
186
208
  });
187
- it("dark mode set", async () => {
188
- const { useDarkMode } = await import("./dark-mode.service");
209
+ it('dark mode set', async () => {
210
+ const { useDarkMode } = await import('./dark-mode.service');
189
211
  const { setModeCurrent, currentMode, MODE } = useDarkMode();
190
212
 
191
213
  setModeCurrent(MODE.DARK);
192
214
  expect(currentMode.value).toBe(MODE.DARK);
193
- expect(document.documentElement.classList.contains("dark")).toBe(true);
215
+ expect(document.documentElement.classList.contains('dark')).toBe(true);
194
216
  });
195
217
  });
196
218
 
197
- describe("initializeMode", () => {
198
- it("should set currentMode", async () => {
199
- const { useDarkMode } = await import("./dark-mode.service");
219
+ describe('initializeMode', () => {
220
+ it('should set currentMode', async () => {
221
+ const { useDarkMode } = await import('./dark-mode.service');
200
222
  const { initializeMode, currentMode, getModeAutoPrefers } = useDarkMode();
201
223
 
202
224
  const mode = getModeAutoPrefers();
@@ -205,10 +227,10 @@ describe("useDarkMode", () => {
205
227
  });
206
228
  });
207
229
 
208
- describe("autoModeWatcher", () => {
209
- describe("given mode changes", () => {
210
- it("should set modeCurrent", async () => {
211
- const { useDarkMode } = await import("./dark-mode.service");
230
+ describe('autoModeWatcher', () => {
231
+ describe('given mode changes', () => {
232
+ it('should set modeCurrent', async () => {
233
+ const { useDarkMode } = await import('./dark-mode.service');
212
234
  const darkMode = useDarkMode();
213
235
 
214
236
  const mql = {
@@ -217,7 +239,7 @@ describe("useDarkMode", () => {
217
239
  darkMode.setModeCurrent(mql.matches);
218
240
  },
219
241
  };
220
- vi.spyOn(window, "matchMedia").mockReturnValueOnce(mql as any);
242
+ vi.spyOn(window, 'matchMedia').mockReturnValueOnce(mql as any);
221
243
 
222
244
  darkMode.autoModeWatcher();
223
245
 
@@ -1,5 +1,5 @@
1
- import { computed, readonly, Ref, ref } from "vue";
2
- import { usePlatform } from "../utils/platform/platform.service";
1
+ import { computed, readonly, Ref, ref } from 'vue';
2
+ import { usePlatform } from '../utils/platform/platform.service';
3
3
 
4
4
  const { isBrowser } = usePlatform();
5
5
 
@@ -16,15 +16,15 @@ const isDark = computed(() => currentMode.value === MODE.DARK);
16
16
  const useDarkMode = () => {
17
17
  const getModeOsPrefers = (): boolean => {
18
18
  let prefersLightMode = false;
19
- if (isBrowser) prefersLightMode = window.matchMedia("(prefers-color-scheme: light)").matches;
19
+ if (isBrowser) prefersLightMode = window.matchMedia('(prefers-color-scheme: light)').matches;
20
20
  setModeOsPrefers(prefersLightMode);
21
21
  return prefersLightMode;
22
22
  };
23
23
 
24
24
  const getModeUserPrefers = (): boolean | undefined => {
25
25
  if (isBrowser) {
26
- const mode = localStorage.getItem("modeUserPrefers");
27
- if (mode !== null) modeUserPrefers.value = mode === "true";
26
+ const mode = localStorage.getItem('modeUserPrefers');
27
+ if (mode !== null) modeUserPrefers.value = mode === 'true';
28
28
  }
29
29
  return modeUserPrefers.value;
30
30
  };
@@ -39,19 +39,19 @@ const useDarkMode = () => {
39
39
  const setModeOsPrefers = (value: boolean) => {
40
40
  modeOsPrefers.value = value;
41
41
  if (isBrowser) {
42
- localStorage.setItem("modeOsPrefers", value.toString());
42
+ localStorage.setItem('modeOsPrefers', value.toString());
43
43
  }
44
44
  };
45
45
  const setModeUserPrefers = (value: boolean): void => {
46
46
  modeUserPrefers.value = value;
47
47
  if (isBrowser) {
48
- localStorage.setItem("modeUserPrefers", value.toString());
48
+ localStorage.setItem('modeUserPrefers', value.toString());
49
49
  }
50
50
  };
51
51
 
52
52
  const setModeCurrent = (value: boolean) => {
53
53
  const elemHtmlClasses = document.documentElement.classList;
54
- const classDark = "dark";
54
+ const classDark = 'dark';
55
55
  value === MODE.LIGHT ? elemHtmlClasses.remove(classDark) : elemHtmlClasses.add(classDark);
56
56
  currentMode.value = value;
57
57
  };
@@ -62,7 +62,7 @@ const useDarkMode = () => {
62
62
  };
63
63
 
64
64
  const autoModeWatcher = (): void => {
65
- const mql = window.matchMedia("(prefers-color-scheme: light)");
65
+ const mql = window.matchMedia('(prefers-color-scheme: light)');
66
66
  const setMode = (value: boolean) => {
67
67
  const elemHtmlClasses = document.documentElement.classList;
68
68
  const classDark = `dark`;