@aaas-pro/library 0.0.0-stage → 0.1.0
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 +107 -2
- package/dist/components/address-picker.d.ts +18 -0
- package/dist/components/address-picker.js +46 -0
- package/dist/components/card-date-filter.d.ts +12 -0
- package/dist/components/card-date-filter.js +95 -0
- package/dist/components/date-time-picker.d.ts +12 -0
- package/dist/components/date-time-picker.js +96 -0
- package/dist/components/detail-dialog.d.ts +48 -0
- package/dist/components/detail-dialog.js +97 -0
- package/dist/components/document-links.d.ts +13 -0
- package/dist/components/document-links.js +19 -0
- package/dist/components/draft-row-actions.d.ts +14 -0
- package/dist/components/draft-row-actions.js +70 -0
- package/dist/components/error-boundary.d.ts +14 -0
- package/dist/components/error-boundary.js +35 -0
- package/dist/components/glow-card.d.ts +13 -0
- package/dist/components/glow-card.js +48 -0
- package/dist/components/org-picker.d.ts +17 -0
- package/dist/components/org-picker.js +56 -0
- package/dist/components/overflow-row-actions.d.ts +29 -0
- package/dist/components/overflow-row-actions.js +135 -0
- package/dist/components/page-header.d.ts +21 -0
- package/dist/components/page-header.js +21 -0
- package/dist/components/permission-button.d.ts +4 -0
- package/dist/components/permission-button.js +17 -0
- package/dist/components/permission-context.d.ts +12 -0
- package/dist/components/permission-context.js +17 -0
- package/dist/components/person-picker.d.ts +20 -0
- package/dist/components/person-picker.js +38 -0
- package/dist/components/process-flow-bar.d.ts +15 -0
- package/dist/components/process-flow-bar.js +19 -0
- package/dist/components/product-picker.d.ts +19 -0
- package/dist/components/product-picker.js +155 -0
- package/dist/components/ref-doc-picker.d.ts +24 -0
- package/dist/components/ref-doc-picker.js +139 -0
- package/dist/components/scroll-to-top.d.ts +1 -0
- package/dist/components/scroll-to-top.js +20 -0
- package/dist/components/state-view.d.ts +26 -0
- package/dist/components/state-view.js +75 -0
- package/dist/components/theme-switcher.d.ts +27 -0
- package/dist/components/theme-switcher.js +77 -0
- package/dist/components/time-filter.d.ts +7 -0
- package/dist/components/time-filter.js +65 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +64 -0
- package/dist/components/ui/alert-dialog.d.ts +15 -0
- package/dist/components/ui/alert-dialog.js +160 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +66 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.js +10 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/avatar.js +53 -0
- package/dist/components/ui/badge.d.ts +12 -0
- package/dist/components/ui/badge.js +44 -0
- package/dist/components/ui/breadcrumb.d.ts +11 -0
- package/dist/components/ui/breadcrumb.js +103 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.js +76 -0
- package/dist/components/ui/button.d.ts +20 -0
- package/dist/components/ui/button.js +93 -0
- package/dist/components/ui/calendar.d.ts +73 -0
- package/dist/components/ui/calendar.js +103 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/card.js +90 -0
- package/dist/components/ui/carousel.d.ts +14 -0
- package/dist/components/ui/carousel.js +200 -0
- package/dist/components/ui/chart.d.ts +43 -0
- package/dist/components/ui/chart.js +252 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/checkbox.js +31 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +34 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/command.js +170 -0
- package/dist/components/ui/context-menu.d.ts +26 -0
- package/dist/components/ui/context-menu.js +237 -0
- package/dist/components/ui/dialog.d.ts +17 -0
- package/dist/components/ui/dialog.js +139 -0
- package/dist/components/ui/drawer.d.ts +13 -0
- package/dist/components/ui/drawer.js +129 -0
- package/dist/components/ui/dropdown-menu.d.ts +26 -0
- package/dist/components/ui/dropdown-menu.js +245 -0
- package/dist/components/ui/empty.d.ts +14 -0
- package/dist/components/ui/empty.js +102 -0
- package/dist/components/ui/field.d.ts +27 -0
- package/dist/components/ui/field.js +229 -0
- package/dist/components/ui/form.d.ts +26 -0
- package/dist/components/ui/form.js +118 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.js +39 -0
- package/dist/components/ui/input-group.d.ts +22 -0
- package/dist/components/ui/input-group.js +156 -0
- package/dist/components/ui/input-otp.d.ts +11 -0
- package/dist/components/ui/input-otp.js +66 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.js +21 -0
- package/dist/components/ui/item.d.ts +29 -0
- package/dist/components/ui/item.js +187 -0
- package/dist/components/ui/kbd.d.ts +3 -0
- package/dist/components/ui/kbd.js +31 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/label.js +22 -0
- package/dist/components/ui/menubar.d.ts +26 -0
- package/dist/components/ui/menubar.js +252 -0
- package/dist/components/ui/navigation-menu.d.ts +17 -0
- package/dist/components/ui/navigation-menu.js +170 -0
- package/dist/components/ui/pagination.d.ts +13 -0
- package/dist/components/ui/pagination.js +118 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.js +47 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/progress.js +34 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +45 -0
- package/dist/components/ui/resizable.d.ts +7 -0
- package/dist/components/ui/resizable.js +49 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +60 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +215 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +26 -0
- package/dist/components/ui/sheet.d.ts +13 -0
- package/dist/components/ui/sheet.js +127 -0
- package/dist/components/ui/sidebar.d.ts +72 -0
- package/dist/components/ui/sidebar.js +656 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +15 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +63 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.js +34 -0
- package/dist/components/ui/spinner.d.ts +2 -0
- package/dist/components/ui/spinner.js +17 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +31 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +114 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +67 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.js +18 -0
- package/dist/components/ui/toggle-group.d.ts +9 -0
- package/dist/components/ui/toggle-group.js +68 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/toggle.js +43 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +56 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +115 -0
- package/dist/icons/paths.d.ts +556 -0
- package/dist/icons/paths.js +231 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +399 -0
- package/dist/internal/selection-base.d.ts +37 -0
- package/dist/internal/selection-base.js +40 -0
- package/dist/lib/class-names.d.ts +6 -0
- package/dist/lib/class-names.js +159 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +7 -0
- package/dist/lib/variants.d.ts +21 -0
- package/dist/lib/variants.js +21 -0
- package/dist/primitives/accordion.d.ts +29 -0
- package/dist/primitives/accordion.js +49 -0
- package/dist/primitives/alert-dialog.d.ts +10 -0
- package/dist/primitives/alert-dialog.js +22 -0
- package/dist/primitives/aspect-ratio.d.ts +4 -0
- package/dist/primitives/aspect-ratio.js +7 -0
- package/dist/primitives/avatar.d.ts +8 -0
- package/dist/primitives/avatar.js +45 -0
- package/dist/primitives/carousel.d.ts +22 -0
- package/dist/primitives/carousel.js +78 -0
- package/dist/primitives/chart.d.ts +71 -0
- package/dist/primitives/chart.js +125 -0
- package/dist/primitives/checkbox.d.ts +13 -0
- package/dist/primitives/checkbox.js +24 -0
- package/dist/primitives/collapsible.d.ts +14 -0
- package/dist/primitives/collapsible.js +29 -0
- package/dist/primitives/command.d.ts +43 -0
- package/dist/primitives/command.js +98 -0
- package/dist/primitives/context-menu.d.ts +24 -0
- package/dist/primitives/context-menu.js +19 -0
- package/dist/primitives/core.d.ts +25 -0
- package/dist/primitives/core.js +89 -0
- package/dist/primitives/dialog.d.ts +7 -0
- package/dist/primitives/dialog.js +15 -0
- package/dist/primitives/drawer.d.ts +30 -0
- package/dist/primitives/drawer.js +39 -0
- package/dist/primitives/dropdown-menu.d.ts +24 -0
- package/dist/primitives/dropdown-menu.js +19 -0
- package/dist/primitives/form.d.ts +154 -0
- package/dist/primitives/form.js +139 -0
- package/dist/primitives/hover-card.d.ts +4 -0
- package/dist/primitives/hover-card.js +8 -0
- package/dist/primitives/input-otp.d.ts +21 -0
- package/dist/primitives/input-otp.js +78 -0
- package/dist/primitives/label.d.ts +2 -0
- package/dist/primitives/label.js +7 -0
- package/dist/primitives/layer.d.ts +84 -0
- package/dist/primitives/layer.js +300 -0
- package/dist/primitives/menu.d.ts +56 -0
- package/dist/primitives/menu.js +126 -0
- package/dist/primitives/menubar.d.ts +91 -0
- package/dist/primitives/menubar.js +44 -0
- package/dist/primitives/navigation-menu.d.ts +32 -0
- package/dist/primitives/navigation-menu.js +121 -0
- package/dist/primitives/popover.d.ts +4 -0
- package/dist/primitives/popover.js +12 -0
- package/dist/primitives/progress.d.ts +7 -0
- package/dist/primitives/progress.js +13 -0
- package/dist/primitives/radio-group.d.ts +18 -0
- package/dist/primitives/radio-group.js +36 -0
- package/dist/primitives/resizable.d.ts +19 -0
- package/dist/primitives/resizable.js +91 -0
- package/dist/primitives/scroll-area.d.ts +12 -0
- package/dist/primitives/scroll-area.js +26 -0
- package/dist/primitives/select.d.ts +42 -0
- package/dist/primitives/select.js +167 -0
- package/dist/primitives/separator.d.ts +5 -0
- package/dist/primitives/separator.js +7 -0
- package/dist/primitives/slider.d.ts +25 -0
- package/dist/primitives/slider.js +98 -0
- package/dist/primitives/slot.d.ts +1 -0
- package/dist/primitives/slot.js +4 -0
- package/dist/primitives/switch.d.ts +11 -0
- package/dist/primitives/switch.js +22 -0
- package/dist/primitives/tabs.d.ts +23 -0
- package/dist/primitives/tabs.js +38 -0
- package/dist/primitives/toast.d.ts +55 -0
- package/dist/primitives/toast.js +86 -0
- package/dist/primitives/toggle-group.d.ts +24 -0
- package/dist/primitives/toggle-group.js +33 -0
- package/dist/primitives/toggle.d.ts +7 -0
- package/dist/primitives/toggle.js +13 -0
- package/dist/primitives/tooltip.d.ts +7 -0
- package/dist/primitives/tooltip.js +10 -0
- package/dist/style-entry.d.ts +1 -0
- package/dist/style-entry.js +1 -0
- package/dist/styles.css +7016 -0
- package/dist/styles.js +1 -0
- package/dist/theme/index.d.ts +110 -0
- package/dist/theme/index.js +199 -0
- package/licenses/Lucide.txt +15 -0
- package/package.json +67 -4
package/dist/styles.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* empty css */
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type ThemeName = 'green' | 'teal' | 'cyan' | 'lime' | 'gold' | 'blue' | 'indigo' | 'violet' | 'rose' | 'orange' | 'slate' | 'dark';
|
|
3
|
+
export declare const themeNames: readonly ThemeName[];
|
|
4
|
+
/** 导航栏外观:浅色随页面表面,深色为品牌色调的深底;与色彩预设相互独立。 */
|
|
5
|
+
export type NavStyle = 'light' | 'dark';
|
|
6
|
+
export declare const navStyleLabels: Record<NavStyle, string>;
|
|
7
|
+
export interface ThemeToken {
|
|
8
|
+
/** 品牌主色;任意有效 CSS 颜色。 */
|
|
9
|
+
colorPrimary: string;
|
|
10
|
+
colorSuccess: string;
|
|
11
|
+
colorWarning: string;
|
|
12
|
+
colorDanger: string;
|
|
13
|
+
colorInfo: string;
|
|
14
|
+
colorBackground: string;
|
|
15
|
+
colorSurface: string;
|
|
16
|
+
colorText: string;
|
|
17
|
+
colorTextSecondary: string;
|
|
18
|
+
colorBorder: string;
|
|
19
|
+
colorPrimaryText: string;
|
|
20
|
+
/** 基础圆角;控件 = 基础 − 2px,卡片 = 基础 + 4px,弹窗 = 基础 + 8px。 */
|
|
21
|
+
borderRadius: string;
|
|
22
|
+
/** 导航栏(侧边栏)背景。浅色预设默认同 colorSurface。 */
|
|
23
|
+
colorNavBackground: string;
|
|
24
|
+
/** 导航栏文字与图标。 */
|
|
25
|
+
colorNavText: string;
|
|
26
|
+
/** 导航栏选中项的强调色。 */
|
|
27
|
+
colorNavActive: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ThemeConfig {
|
|
30
|
+
preset?: ThemeName;
|
|
31
|
+
token?: Partial<ThemeToken>;
|
|
32
|
+
}
|
|
33
|
+
export interface ConfigProviderProps {
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
/** 默认 green;token 可覆盖预设中的单个颜色。 */
|
|
36
|
+
theme?: ThemeName | ThemeConfig;
|
|
37
|
+
/** local 仅影响本 Provider;document 同时影响页面背景和第三方 body 浮层。 */
|
|
38
|
+
scope?: 'local' | 'document';
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare const themePresets: Record<ThemeName, ThemeToken>;
|
|
42
|
+
export declare const themeLabels: Record<ThemeName, string>;
|
|
43
|
+
export declare const themeDescriptions: Record<ThemeName, string>;
|
|
44
|
+
/** 深色导航栏:由主色调出的深底(12% 主色混入近黑),文字浅灰,选中色为提亮 35% 的主色,保证在深底上可读。 */
|
|
45
|
+
export declare function darkNavTokens(token: ThemeToken): Pick<ThemeToken, 'colorNavBackground' | 'colorNavText' | 'colorNavActive'>;
|
|
46
|
+
export declare function resolveTheme(theme?: ThemeName | ThemeConfig): {
|
|
47
|
+
preset: ThemeName;
|
|
48
|
+
token: {
|
|
49
|
+
colorPrimary: string;
|
|
50
|
+
colorSuccess: string;
|
|
51
|
+
colorWarning: string;
|
|
52
|
+
colorDanger: string;
|
|
53
|
+
colorInfo: string;
|
|
54
|
+
colorBackground: string;
|
|
55
|
+
colorSurface: string;
|
|
56
|
+
colorText: string;
|
|
57
|
+
colorTextSecondary: string;
|
|
58
|
+
colorBorder: string;
|
|
59
|
+
colorPrimaryText: string;
|
|
60
|
+
borderRadius: string;
|
|
61
|
+
colorNavBackground: string;
|
|
62
|
+
colorNavText: string;
|
|
63
|
+
colorNavActive: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export declare function themeVariables(token: ThemeToken): Record<string, string>;
|
|
67
|
+
export declare function useLibraryTheme(): {
|
|
68
|
+
preset: ThemeName;
|
|
69
|
+
token: ThemeToken;
|
|
70
|
+
portalContainer: HTMLElement | undefined;
|
|
71
|
+
};
|
|
72
|
+
export declare function useThemePortalContainer(): HTMLElement | undefined;
|
|
73
|
+
export declare function ConfigProvider({ children, theme, scope, className }: ConfigProviderProps): import("react").JSX.Element;
|
|
74
|
+
export interface ThemeOverrideContext {
|
|
75
|
+
theme: ThemeName;
|
|
76
|
+
navStyle: NavStyle;
|
|
77
|
+
}
|
|
78
|
+
export type ThemeOverrides = Partial<Record<ThemeName, Partial<ThemeToken>>> | ((ctx: ThemeOverrideContext) => Partial<ThemeToken> | undefined);
|
|
79
|
+
export interface ThemeProviderProps {
|
|
80
|
+
children: ReactNode;
|
|
81
|
+
/** 首次访问使用的预设;本地已有记忆时以记忆为准。默认 green。 */
|
|
82
|
+
defaultTheme?: ThemeName;
|
|
83
|
+
/** 可供切换的预设,默认全部;记忆值不在其中时回落到 defaultTheme。 */
|
|
84
|
+
themes?: readonly ThemeName[];
|
|
85
|
+
/** 首次访问的导航栏外观,默认 light(白色导航)。深色预设始终使用深色导航。 */
|
|
86
|
+
defaultNavStyle?: NavStyle;
|
|
87
|
+
/** 应用级覆盖:按预设声明,或按(预设, 导航外观)计算;在内置深色导航派生之后应用。 */
|
|
88
|
+
overrides?: ThemeOverrides;
|
|
89
|
+
/** localStorage 键,默认 `aaas-theme`(导航外观存于 `<key>:nav`);传 null 不持久化。 */
|
|
90
|
+
storageKey?: string | null;
|
|
91
|
+
/** 同 ConfigProvider.scope;整页应用建议 document。默认 document。 */
|
|
92
|
+
scope?: 'local' | 'document';
|
|
93
|
+
className?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface ThemeSwitchContext {
|
|
96
|
+
theme: ThemeName;
|
|
97
|
+
setTheme: (theme: ThemeName) => void;
|
|
98
|
+
themes: readonly ThemeName[];
|
|
99
|
+
labels: Record<ThemeName, string>;
|
|
100
|
+
/** 当前导航栏外观;深色预设下恒为 dark。 */
|
|
101
|
+
navStyle: NavStyle;
|
|
102
|
+
setNavStyle: (style: NavStyle) => void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 带记忆的主题容器:在 ConfigProvider 之上提供 `useTheme()` 以读取/切换色彩预设与导航栏外观,
|
|
106
|
+
* 两者分别写入 localStorage 并跨标签页同步;`overrides` 让应用再补充自己的 token。
|
|
107
|
+
*/
|
|
108
|
+
export declare function ThemeProvider({ children, defaultTheme, themes, defaultNavStyle, overrides, storageKey, scope, className }: ThemeProviderProps): import("react").JSX.Element;
|
|
109
|
+
/** 读取与切换当前主题;须位于 ThemeProvider 内。 */
|
|
110
|
+
export declare function useTheme(): ThemeSwitchContext;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState, useMemo, useLayoutEffect, useCallback, useEffect } from "react";
|
|
3
|
+
const themeNames = ["green", "teal", "cyan", "lime", "gold", "blue", "indigo", "violet", "rose", "orange", "slate", "dark"];
|
|
4
|
+
const navStyleLabels = { light: "浅色导航", dark: "深色导航" };
|
|
5
|
+
const light = { colorPrimary: "#00875a", colorSuccess: "#15803d", colorWarning: "#b45309", colorDanger: "#dc2626", colorInfo: "#2563eb", colorBackground: "#f3f6f5", colorSurface: "#ffffff", colorText: "#17241f", colorTextSecondary: "#5b6b65", colorBorder: "#e1e7e4", colorPrimaryText: "#ffffff", borderRadius: "0.5rem", colorNavBackground: "#ffffff", colorNavText: "#17241f", colorNavActive: "#00875a" };
|
|
6
|
+
const themePresets = {
|
|
7
|
+
green: light,
|
|
8
|
+
teal: { ...light, colorPrimary: "#0f766e", colorBackground: "#f1f7f6", colorText: "#132a28", colorTextSecondary: "#53706d", colorBorder: "#dbe8e6", colorNavText: "#132a28", colorNavActive: "#0f766e" },
|
|
9
|
+
cyan: { ...light, colorPrimary: "#0e7490", colorBackground: "#f0f9fb", colorText: "#15313b", colorTextSecondary: "#536e79", colorBorder: "#d9eaf0", colorNavText: "#15313b", colorNavActive: "#0e7490" },
|
|
10
|
+
lime: { ...light, colorPrimary: "#4d7c0f", colorBackground: "#f6faee", colorText: "#253313", colorTextSecondary: "#626f4e", colorBorder: "#e1e9d1", colorNavText: "#253313", colorNavActive: "#4d7c0f" },
|
|
11
|
+
gold: { ...light, colorPrimary: "#a16207", colorBackground: "#fdf8ed", colorText: "#3b2d14", colorTextSecondary: "#78684b", colorBorder: "#eee4cb", colorNavText: "#3b2d14", colorNavActive: "#a16207" },
|
|
12
|
+
blue: { ...light, colorPrimary: "#175cd3", colorBackground: "#f2f6fd", colorText: "#182b4d", colorTextSecondary: "#536b8e", colorBorder: "#dbe4f3", colorNavText: "#182b4d", colorNavActive: "#175cd3" },
|
|
13
|
+
indigo: { ...light, colorPrimary: "#4338ca", colorBackground: "#f4f4fc", colorText: "#1e1b4b", colorTextSecondary: "#5b5b8a", colorBorder: "#e0e1f2", colorNavText: "#1e1b4b", colorNavActive: "#4338ca" },
|
|
14
|
+
violet: { ...light, colorPrimary: "#6d28d9", colorBackground: "#f7f4fc", colorText: "#2a1d4a", colorTextSecondary: "#6b5e8a", colorBorder: "#e6dff3", colorNavText: "#2a1d4a", colorNavActive: "#6d28d9" },
|
|
15
|
+
rose: { ...light, colorPrimary: "#be123c", colorBackground: "#fbf4f6", colorText: "#3f1a26", colorTextSecondary: "#80606a", colorBorder: "#f0dde3", colorNavText: "#3f1a26", colorNavActive: "#be123c" },
|
|
16
|
+
orange: { ...light, colorPrimary: "#c4510b", colorBackground: "#fbf5f0", colorText: "#402818", colorTextSecondary: "#826348", colorBorder: "#efe1d4", colorNavText: "#402818", colorNavActive: "#c4510b" },
|
|
17
|
+
// 石墨:主色为深石板灰,适合强调数据本身而非品牌色的报表场景;语义色不变。
|
|
18
|
+
slate: { ...light, colorPrimary: "#334155", colorBackground: "#f4f5f7", colorText: "#0f172a", colorTextSecondary: "#5b667a", colorBorder: "#e0e4ea", colorNavText: "#0f172a", colorNavActive: "#334155" },
|
|
19
|
+
// 深色:以深海军蓝为底(与 aaaspro 导航同族),表面比底色亮一级、边框再亮一级,主色提亮以保证深底文字对比度。
|
|
20
|
+
dark: { ...light, colorPrimary: "#3ddc97", colorSuccess: "#4ade80", colorWarning: "#fbbf24", colorDanger: "#fb7185", colorInfo: "#60a5fa", colorBackground: "#0d151d", colorSurface: "#16222d", colorText: "#e6edf3", colorTextSecondary: "#9fb0bf", colorBorder: "#2a3845", colorPrimaryText: "#07261a", colorNavBackground: "#0a1118", colorNavText: "#d5dee7", colorNavActive: "#3ddc97" }
|
|
21
|
+
};
|
|
22
|
+
const themeLabels = { green: "生态绿", teal: "青碧", cyan: "青空", lime: "青柠", gold: "鎏金", blue: "科技蓝", indigo: "靛蓝", violet: "紫罗兰", rose: "玫红", orange: "暖橙", slate: "石墨", dark: "深色" };
|
|
23
|
+
const themeDescriptions = { green: "农牧品牌默认", teal: "环控与水产场景", cyan: "清透青蓝与浅色表面", lime: "自然青柠与柔和底色", gold: "沉稳金色与暖色表面", blue: "数据与监控场景", indigo: "财务与审批场景", violet: "AI 与分析场景", rose: "营销与活动场景", orange: "交易与采购场景", slate: "报表与打印场景", dark: "弱光环境 / 大屏" };
|
|
24
|
+
function darkNavTokens(token) {
|
|
25
|
+
return { colorNavBackground: mix(token.colorPrimary, "#0f1720", 12), colorNavText: "#d5dee7", colorNavActive: mix(token.colorPrimary, "#ffffff", 65) };
|
|
26
|
+
}
|
|
27
|
+
const mix = (a, b, percent) => `color-mix(in srgb, ${a} ${percent}%, ${b})`;
|
|
28
|
+
function resolveTheme(theme = "green") {
|
|
29
|
+
const preset = typeof theme === "string" ? theme : theme.preset ?? "green";
|
|
30
|
+
return { preset, token: { ...themePresets[preset], ...typeof theme === "object" ? theme.token : {} } };
|
|
31
|
+
}
|
|
32
|
+
function themeVariables(token) {
|
|
33
|
+
const primarySoft = mix(token.colorPrimary, token.colorSurface, 16);
|
|
34
|
+
const vars = {
|
|
35
|
+
"--primary": token.colorPrimary,
|
|
36
|
+
"--primary-foreground": token.colorPrimaryText,
|
|
37
|
+
"--primary-hover": mix(token.colorPrimary, token.colorText, 85),
|
|
38
|
+
"--primary-soft": primarySoft,
|
|
39
|
+
"--primary-light": mix(token.colorPrimary, token.colorSurface, 70),
|
|
40
|
+
"--background": token.colorBackground,
|
|
41
|
+
"--foreground": token.colorText,
|
|
42
|
+
"--card": token.colorSurface,
|
|
43
|
+
"--card-foreground": token.colorText,
|
|
44
|
+
"--popover": token.colorSurface,
|
|
45
|
+
"--popover-foreground": token.colorText,
|
|
46
|
+
"--muted": mix(token.colorText, token.colorSurface, 4),
|
|
47
|
+
"--muted-foreground": token.colorTextSecondary,
|
|
48
|
+
"--secondary": primarySoft,
|
|
49
|
+
"--secondary-foreground": token.colorPrimary,
|
|
50
|
+
"--accent": primarySoft,
|
|
51
|
+
"--accent-foreground": token.colorText,
|
|
52
|
+
// 输入框边框比分隔线更深,便于识别可编辑区域。
|
|
53
|
+
"--border": token.colorBorder,
|
|
54
|
+
"--input": mix(token.colorText, token.colorBorder, 16),
|
|
55
|
+
"--ring": token.colorPrimary,
|
|
56
|
+
"--destructive": token.colorDanger,
|
|
57
|
+
"--success": token.colorSuccess,
|
|
58
|
+
"--warning": token.colorWarning,
|
|
59
|
+
"--info": token.colorInfo,
|
|
60
|
+
"--radius": token.borderRadius,
|
|
61
|
+
"--page-bg": token.colorBackground,
|
|
62
|
+
"--eco-green": token.colorPrimary,
|
|
63
|
+
"--eco-green-light": primarySoft,
|
|
64
|
+
"--eco-green-dark": mix(token.colorPrimary, "#000", 80),
|
|
65
|
+
"--sidebar": token.colorNavBackground,
|
|
66
|
+
"--sidebar-foreground": token.colorNavText,
|
|
67
|
+
"--sidebar-accent": mix(token.colorNavText, token.colorNavBackground, 7),
|
|
68
|
+
"--sidebar-accent-foreground": token.colorNavText,
|
|
69
|
+
"--sidebar-border": mix(token.colorNavText, token.colorNavBackground, 10),
|
|
70
|
+
"--sidebar-ring": token.colorNavActive,
|
|
71
|
+
"--sidebar-primary": token.colorNavActive,
|
|
72
|
+
"--sidebar-primary-foreground": token.colorNavBackground,
|
|
73
|
+
"--chart-1": token.colorPrimary,
|
|
74
|
+
"--chart-2": token.colorSuccess,
|
|
75
|
+
"--chart-3": token.colorInfo,
|
|
76
|
+
"--chart-4": token.colorWarning,
|
|
77
|
+
"--chart-5": token.colorDanger,
|
|
78
|
+
"--docs-blue": token.colorPrimary,
|
|
79
|
+
"--docs-border": token.colorBorder,
|
|
80
|
+
"--doc-accent": token.colorPrimary,
|
|
81
|
+
"--doc-active": primarySoft
|
|
82
|
+
};
|
|
83
|
+
return vars;
|
|
84
|
+
}
|
|
85
|
+
const ThemeContext = createContext({ preset: "green", token: light, portalContainer: void 0 });
|
|
86
|
+
function useLibraryTheme() {
|
|
87
|
+
return useContext(ThemeContext);
|
|
88
|
+
}
|
|
89
|
+
function useThemePortalContainer() {
|
|
90
|
+
return useLibraryTheme().portalContainer;
|
|
91
|
+
}
|
|
92
|
+
function ConfigProvider({ children, theme = "green", scope = "local", className = "" }) {
|
|
93
|
+
const { preset, token } = resolveTheme(theme);
|
|
94
|
+
const [container, setContainer] = useState(null);
|
|
95
|
+
const vars = useMemo(() => themeVariables(token), [JSON.stringify(token)]);
|
|
96
|
+
useLayoutEffect(() => {
|
|
97
|
+
if (scope !== "document") return;
|
|
98
|
+
const root = document.documentElement;
|
|
99
|
+
const old = Object.fromEntries(Object.keys(vars).map((k) => [k, root.style.getPropertyValue(k)]));
|
|
100
|
+
const wasDark = root.classList.contains("dark");
|
|
101
|
+
for (const [k, v] of Object.entries(vars)) root.style.setProperty(k, v);
|
|
102
|
+
root.classList.toggle("dark", preset === "dark");
|
|
103
|
+
return () => {
|
|
104
|
+
for (const [k, v] of Object.entries(old)) v ? root.style.setProperty(k, v) : root.style.removeProperty(k);
|
|
105
|
+
root.classList.toggle("dark", wasDark);
|
|
106
|
+
};
|
|
107
|
+
}, [vars, scope, preset]);
|
|
108
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { preset, token, portalContainer: container ?? void 0 }, children: /* @__PURE__ */ jsx("div", { ref: setContainer, "data-aaas-theme": preset, className: `${preset === "dark" ? "dark " : ""}aaas-theme ${className}`, style: { ...vars, colorScheme: preset === "dark" ? "dark" : "light" }, children }) });
|
|
109
|
+
}
|
|
110
|
+
const ThemeSwitchCtx = createContext(null);
|
|
111
|
+
const isThemeName = (v) => typeof v === "string" && themeNames.includes(v);
|
|
112
|
+
const isNavStyle = (v) => v === "light" || v === "dark";
|
|
113
|
+
function readStored(key, guard) {
|
|
114
|
+
if (!key || typeof window === "undefined") return void 0;
|
|
115
|
+
try {
|
|
116
|
+
const v = window.localStorage.getItem(key);
|
|
117
|
+
return guard(v) ? v : void 0;
|
|
118
|
+
} catch {
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function writeStored(key, value) {
|
|
123
|
+
if (!key || typeof window === "undefined") return;
|
|
124
|
+
try {
|
|
125
|
+
window.localStorage.setItem(key, value);
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function markSwitching() {
|
|
130
|
+
if (typeof document === "undefined") return;
|
|
131
|
+
const root = document.documentElement;
|
|
132
|
+
root.setAttribute("data-theme-switching", "");
|
|
133
|
+
window.setTimeout(() => root.removeAttribute("data-theme-switching"), 260);
|
|
134
|
+
}
|
|
135
|
+
function ThemeProvider({ children, defaultTheme = "green", themes = themeNames, defaultNavStyle = "light", overrides, storageKey = "aaas-theme", scope = "document", className }) {
|
|
136
|
+
const navKey = storageKey ? `${storageKey}:nav` : null;
|
|
137
|
+
const allowed = useCallback((v) => v && themes.includes(v) ? v : themes.includes(defaultTheme) ? defaultTheme : themes[0] ?? "green", [themes, defaultTheme]);
|
|
138
|
+
const [theme, setThemeState] = useState(() => allowed(readStored(storageKey, isThemeName)));
|
|
139
|
+
const [navPref, setNavPref] = useState(() => readStored(navKey, isNavStyle) ?? defaultNavStyle);
|
|
140
|
+
const setTheme = useCallback((next) => {
|
|
141
|
+
const value = allowed(next);
|
|
142
|
+
setThemeState((prev) => {
|
|
143
|
+
if (prev !== value) markSwitching();
|
|
144
|
+
return value;
|
|
145
|
+
});
|
|
146
|
+
writeStored(storageKey, value);
|
|
147
|
+
}, [allowed, storageKey]);
|
|
148
|
+
const setNavStyle = useCallback((next) => {
|
|
149
|
+
setNavPref((prev) => {
|
|
150
|
+
if (prev !== next) markSwitching();
|
|
151
|
+
return next;
|
|
152
|
+
});
|
|
153
|
+
writeStored(navKey, next);
|
|
154
|
+
}, [navKey]);
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
if (!storageKey || typeof window === "undefined") return;
|
|
157
|
+
const onStorage = (e) => {
|
|
158
|
+
if (e.key === storageKey && isThemeName(e.newValue)) {
|
|
159
|
+
markSwitching();
|
|
160
|
+
setThemeState(allowed(e.newValue));
|
|
161
|
+
}
|
|
162
|
+
if (e.key === navKey && isNavStyle(e.newValue)) {
|
|
163
|
+
markSwitching();
|
|
164
|
+
setNavPref(e.newValue);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
window.addEventListener("storage", onStorage);
|
|
168
|
+
return () => window.removeEventListener("storage", onStorage);
|
|
169
|
+
}, [storageKey, navKey, allowed]);
|
|
170
|
+
const navStyle = theme === "dark" ? "dark" : navPref;
|
|
171
|
+
const config = useMemo(() => {
|
|
172
|
+
const preset = themePresets[theme];
|
|
173
|
+
const nav = navStyle === "dark" && theme !== "dark" ? darkNavTokens(preset) : {};
|
|
174
|
+
const extra = typeof overrides === "function" ? overrides({ theme, navStyle }) : overrides?.[theme];
|
|
175
|
+
return { preset: theme, token: { ...nav, ...extra } };
|
|
176
|
+
}, [theme, navStyle, overrides]);
|
|
177
|
+
const ctx = useMemo(() => ({ theme, setTheme, themes, labels: themeLabels, navStyle, setNavStyle }), [theme, setTheme, themes, navStyle, setNavStyle]);
|
|
178
|
+
return /* @__PURE__ */ jsx(ThemeSwitchCtx.Provider, { value: ctx, children: /* @__PURE__ */ jsx(ConfigProvider, { theme: config, scope, className, children }) });
|
|
179
|
+
}
|
|
180
|
+
function useTheme() {
|
|
181
|
+
const ctx = useContext(ThemeSwitchCtx);
|
|
182
|
+
if (!ctx) throw new Error("useTheme 须在 <ThemeProvider> 内使用");
|
|
183
|
+
return ctx;
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
ConfigProvider,
|
|
187
|
+
ThemeProvider,
|
|
188
|
+
darkNavTokens,
|
|
189
|
+
navStyleLabels,
|
|
190
|
+
resolveTheme,
|
|
191
|
+
themeDescriptions,
|
|
192
|
+
themeLabels,
|
|
193
|
+
themeNames,
|
|
194
|
+
themePresets,
|
|
195
|
+
themeVariables,
|
|
196
|
+
useLibraryTheme,
|
|
197
|
+
useTheme,
|
|
198
|
+
useThemePortalContainer
|
|
199
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aaas-pro/library",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": [
|
|
6
|
+
"**/*.css"
|
|
7
|
+
],
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"licenses"
|
|
12
|
+
],
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"source": "./src/index.ts",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./styles.css": {
|
|
23
|
+
"source": "./src/styles.css",
|
|
24
|
+
"default": "./dist/styles.css"
|
|
25
|
+
},
|
|
26
|
+
"./theme": {
|
|
27
|
+
"source": "./src/theme/index.tsx",
|
|
28
|
+
"types": "./dist/theme/index.d.ts",
|
|
29
|
+
"import": "./dist/theme/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./lib/utils": {
|
|
32
|
+
"source": "./src/lib/utils.ts",
|
|
33
|
+
"types": "./dist/lib/utils.d.ts",
|
|
34
|
+
"import": "./dist/lib/utils.js"
|
|
35
|
+
},
|
|
36
|
+
"./hooks/*": {
|
|
37
|
+
"source": "./src/hooks/*.ts",
|
|
38
|
+
"types": "./dist/hooks/*.d.ts",
|
|
39
|
+
"import": "./dist/hooks/*.js"
|
|
40
|
+
},
|
|
41
|
+
"./components/*": {
|
|
42
|
+
"source": "./src/components/*.tsx",
|
|
43
|
+
"types": "./dist/components/*.d.ts",
|
|
44
|
+
"import": "./dist/components/*.js"
|
|
45
|
+
},
|
|
46
|
+
"./icons": {
|
|
47
|
+
"source": "./src/icons/index.tsx",
|
|
48
|
+
"types": "./dist/icons/index.d.ts",
|
|
49
|
+
"import": "./dist/icons/index.js"
|
|
50
|
+
},
|
|
51
|
+
"./package.json": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"react": "^19.0.0",
|
|
55
|
+
"react-dom": "^19.0.0",
|
|
56
|
+
"react-router-dom": "^7.0.0"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"dev": "vite --config docs/vite.config.ts",
|
|
61
|
+
"check": "tsc --noEmit",
|
|
62
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
63
|
+
"build:docs": "pnpm run docs && vite build --config docs/vite.config.ts",
|
|
64
|
+
"test": "vitest run --config vitest.config.ts",
|
|
65
|
+
"test:permissions": "vitest run --config vitest.permissions.config.ts",
|
|
66
|
+
"docs": "node --max-old-space-size=8192 scripts/生成组件文档.mjs",
|
|
67
|
+
"check:examples": "node --max-old-space-size=8192 scripts/check-examples.mjs"
|
|
68
|
+
}
|
|
69
|
+
}
|