qm-law-ui 0.0.1

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.
@@ -0,0 +1,32 @@
1
+ import type { LawThemeMode } from '../hooks/use-law-theme'
2
+
3
+ const THEME_ATTR = 'data-theme'
4
+ const DARK_CLASS = 'dark'
5
+
6
+ /** 判断当前是否为暗色模式 */
7
+ export function isLawDarkMode(): boolean {
8
+ if (typeof document === 'undefined') return false
9
+
10
+ const root = document.documentElement
11
+ return root.getAttribute(THEME_ATTR) === 'dark' || root.classList.contains(DARK_CLASS)
12
+ }
13
+
14
+ /** 获取当前主题模式 */
15
+ export function getLawThemeMode(): LawThemeMode {
16
+ return isLawDarkMode() ? 'dark' : 'light'
17
+ }
18
+
19
+ /** 合并 class 名称 */
20
+ export function mergeLawClass(...classes: Array<string | false | null | undefined>): string {
21
+ return classes.filter(Boolean).join(' ')
22
+ }
23
+
24
+ /** 将 Law 按钮尺寸映射为 Element Plus size */
25
+ export function mapLawButtonSize(size: 'lg' | 'md' | 'sm'): 'large' | 'default' | 'small' {
26
+ const map = {
27
+ lg: 'large',
28
+ md: 'default',
29
+ sm: 'small',
30
+ } as const
31
+ return map[size]
32
+ }