sprof 0.8.1 → 0.8.3
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/dist/core/composables/index.d.ts +2 -0
- package/dist/core/composables/useTheme.d.ts +46 -0
- package/dist/core/composables/useTheme.test.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/sprof.js +774 -744
- package/dist/sprof.umd.cjs +8 -8
- package/dist/style.css +1 -1
- package/package.json +4 -2
|
@@ -14,3 +14,5 @@ export type { UseFiltersReturn } from './useFilters';
|
|
|
14
14
|
export { useFilters } from './useFilters';
|
|
15
15
|
export type { UsePaginationReturn } from './usePagination';
|
|
16
16
|
export { usePagination } from './usePagination';
|
|
17
|
+
export type { ThemeName, UseThemeOptions, UseThemeReturn } from './useTheme';
|
|
18
|
+
export { getStoredTheme, useTheme } from './useTheme';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/** Доступные темы дизайн-системы (атрибут `data-theme`). */
|
|
3
|
+
export type ThemeName = 'light' | 'dark';
|
|
4
|
+
/**
|
|
5
|
+
* Дополнительные атрибуты дизайн-системы на `<html>` (UI.md §0).
|
|
6
|
+
* Клиент обязан их выставить, иначе токенов нет вовсе.
|
|
7
|
+
*/
|
|
8
|
+
export interface UseThemeOptions {
|
|
9
|
+
/** Набор палитры, `data-brandbook` */
|
|
10
|
+
brandbook?: string;
|
|
11
|
+
/** Платформа, `data-platform` */
|
|
12
|
+
platform?: string;
|
|
13
|
+
/** Ключ в localStorage; меняйте, если на одном домене несколько приложений */
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
/** Тема, если выбор ещё не сделан и системная не определилась */
|
|
16
|
+
defaultTheme?: ThemeName;
|
|
17
|
+
}
|
|
18
|
+
export interface UseThemeReturn {
|
|
19
|
+
/** Текущая тема */
|
|
20
|
+
theme: Ref<ThemeName>;
|
|
21
|
+
/** Тема тёмная */
|
|
22
|
+
isDark: Ref<boolean>;
|
|
23
|
+
/** Установить тему (и запомнить выбор) */
|
|
24
|
+
set(theme: ThemeName): void;
|
|
25
|
+
/** Переключить */
|
|
26
|
+
toggle(): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Переключатель темы дизайн-системы (UI-6.1).
|
|
30
|
+
*
|
|
31
|
+
* ⚠️ Токены объявлены под `:root[data-theme='light'|'dark']`, поэтому смена
|
|
32
|
+
* темы — это смена атрибута на `<html>`, а не подмена CSS. Здесь же ставим
|
|
33
|
+
* `data-brandbook`/`data-platform`: без них переменных не существует вовсе
|
|
34
|
+
* (история проекта — цвета руками именно из-за этого).
|
|
35
|
+
*
|
|
36
|
+
* ⚠️ Экземпляр СОЗДАЁТСЯ в setup клиента (один на приложение): несколько
|
|
37
|
+
* вызовов дадут несколько независимых `ref` и рассинхрон при переключении.
|
|
38
|
+
* Держите его в сторе/провайдере корневого компонента.
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const { theme, toggle } = useTheme({ brandbook: 'rdkb', platform: 'web-desktop' });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function useTheme(options?: UseThemeOptions): UseThemeReturn;
|
|
45
|
+
/** Тема из localStorage (для ранней установки атрибута до создания приложения). */
|
|
46
|
+
export declare function getStoredTheme(storageKey?: string): ThemeName | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -47,5 +47,7 @@ export { useCrud, useFilters, usePagination } from './core/composables/index';
|
|
|
47
47
|
export type { UseCrudOptions, UseCrudReturn } from './core/composables/useCrud';
|
|
48
48
|
export type { UseFiltersReturn } from './core/composables/useFilters';
|
|
49
49
|
export type { UsePaginationReturn } from './core/composables/usePagination';
|
|
50
|
+
export type { ThemeName, UseThemeOptions, UseThemeReturn } from './core/composables/useTheme';
|
|
51
|
+
export { getStoredTheme, useTheme } from './core/composables/useTheme';
|
|
50
52
|
export type { AuthLogOperation, AuthLogProvider, AuthLogReason, AuthLogUser } from './core/auth/AuthLog';
|
|
51
53
|
export { initAuthLog } from './core/auth/AuthLog';
|