@iamgx/koala 1.1.0 → 1.1.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/dist/components/Icons/index.d.ts +12 -0
- package/dist/components/Icons/index.d.ts.map +1 -0
- package/dist/components/Icons/types.d.ts +8 -0
- package/dist/components/Icons/types.d.ts.map +1 -0
- package/dist/components/Layout/AsideSkeleton.d.ts +8 -0
- package/dist/components/Layout/Breadcrumb.d.ts +10 -0
- package/dist/components/Layout/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Layout/MenuItem.d.ts +32 -0
- package/dist/components/Layout/MenuItem.d.ts.map +1 -0
- package/dist/components/Layout/ThemeToggle.d.ts +8 -0
- package/dist/components/Layout/ThemeToggle.d.ts.map +1 -0
- package/dist/components/Layout/index.d.ts +2 -2
- package/dist/components/Layout/index.d.ts.map +1 -1
- package/dist/components/Layout/types.d.ts +15 -1
- package/dist/components/Layout/types.d.ts.map +1 -1
- package/dist/components/LayoutSkeleton/index.d.ts +11 -0
- package/dist/components/LayoutSkeleton/types.d.ts +9 -0
- package/dist/components/PageTransition/index.d.ts +9 -0
- package/dist/components/PageTransition/index.d.ts.map +1 -0
- package/dist/components/PageTransition/types.d.ts +11 -0
- package/dist/components/PageTransition/types.d.ts.map +1 -0
- package/dist/components/Skeleton/Aside.d.ts +6 -0
- package/dist/components/Skeleton/Aside.d.ts.map +1 -0
- package/dist/components/Skeleton/Layout.d.ts +11 -0
- package/dist/components/Skeleton/Layout.d.ts.map +1 -0
- package/dist/components/Skeleton/index.d.ts +7 -0
- package/dist/components/Skeleton/index.d.ts.map +1 -0
- package/dist/components/Skeleton/types.d.ts +13 -0
- package/dist/components/Skeleton/types.d.ts.map +1 -0
- package/dist/config/layout.d.ts +8 -0
- package/dist/config/layout.d.ts.map +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 图标组件集合
|
|
3
|
+
*/
|
|
4
|
+
import type { IconProps } from './types';
|
|
5
|
+
export type { IconProps } from './types';
|
|
6
|
+
export declare function ChevronRightIcon({ className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function LoadingIcon({ className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function SunIcon({ className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function MoonIcon({ className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function LogoutIcon({ className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function ChevronDownIcon({ className, style }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Icons/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,wBAAgB,gBAAgB,CAAC,EAAE,SAAqB,EAAE,EAAE,SAAS,2CAMpE;AAED,wBAAgB,WAAW,CAAC,EAAE,SAAqB,EAAE,EAAE,SAAS,2CAO/D;AAED,wBAAgB,OAAO,CAAC,EAAE,SAAqB,EAAE,EAAE,SAAS,2CAM3D;AAED,wBAAgB,QAAQ,CAAC,EAAE,SAAqB,EAAE,EAAE,SAAS,2CAM5D;AAED,wBAAgB,UAAU,CAAC,EAAE,SAAqB,EAAE,EAAE,SAAS,2CAM9D;AAED,wBAAgB,eAAe,CAAC,EAAE,SAAqB,EAAE,KAAK,EAAE,EAAE,SAAS,2CAM1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Icons/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout 面包屑组件
|
|
3
|
+
*/
|
|
4
|
+
import type { BreadcrumbItem, LinkComponentProps } from './types';
|
|
5
|
+
import type { ComponentType } from 'react';
|
|
6
|
+
export declare function DefaultBreadcrumb({ items, linkComponent: LinkComponent }: {
|
|
7
|
+
items: BreadcrumbItem[];
|
|
8
|
+
linkComponent?: ComponentType<LinkComponentProps>;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
//# sourceMappingURL=Breadcrumb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Breadcrumb.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/Breadcrumb.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAG1C,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,aAAa,EAAE,aAAa,EAC7B,EAAE;IACD,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,aAAa,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAA;CAClD,kDA2CA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout 菜单项组件
|
|
3
|
+
*/
|
|
4
|
+
import type { MenuItem } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* 检查菜单项或其子项是否激活
|
|
7
|
+
*/
|
|
8
|
+
export declare function hasActiveChild(item: MenuItem, activePath?: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 默认菜单项内容渲染(仅渲染图标和文字,不包括箭头)
|
|
11
|
+
*/
|
|
12
|
+
export declare function DefaultMenuItemContent({ item, open, active }: {
|
|
13
|
+
item: MenuItem;
|
|
14
|
+
open: boolean;
|
|
15
|
+
active?: boolean;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* 通用菜单项渲染器(处理嵌套逻辑)
|
|
19
|
+
*/
|
|
20
|
+
export declare function MenuItemWrapper({ item, open, active, activePath, level, itemRender, onMenuItemClick, onNavigate, expandedMenu, onToggleExpand }: {
|
|
21
|
+
item: MenuItem;
|
|
22
|
+
open: boolean;
|
|
23
|
+
active: boolean;
|
|
24
|
+
activePath?: string;
|
|
25
|
+
level?: number;
|
|
26
|
+
itemRender?: (item: MenuItem, open: boolean, active: boolean) => React.ReactNode;
|
|
27
|
+
onMenuItemClick?: (item: MenuItem, e: React.MouseEvent) => void;
|
|
28
|
+
onNavigate?: (path: string) => void;
|
|
29
|
+
expandedMenu?: string;
|
|
30
|
+
onToggleExpand?: (menuName: string) => void;
|
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
//# sourceMappingURL=MenuItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/MenuItem.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGvC;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAO3E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,IAAI,EACJ,MAAM,EACP,EAAE;IACD,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,2CAeA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,UAAU,EACV,KAAS,EACT,UAAU,EACV,eAAe,EACf,UAAU,EACV,YAAY,EACZ,cAAc,EACf,EAAE;IACD,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAA;IAChF,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;IAC/D,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5C,2CA2GA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout 主题切换组件
|
|
3
|
+
*/
|
|
4
|
+
export declare function ThemeToggle({ theme: controlledTheme, onTheme }: {
|
|
5
|
+
theme?: 'light' | 'dark';
|
|
6
|
+
onTheme?: (theme: 'light' | 'dark') => void;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ThemeToggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeToggle.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/ThemeToggle.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAKH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EAAE,eAAe,EACtB,OAAO,EACR,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAA;CAC5C,2CAoCA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LayoutProps } from './types';
|
|
2
|
-
export type { LayoutProps, MenuItem, BreadcrumbItem } from './types';
|
|
3
|
-
export
|
|
2
|
+
export type { LayoutProps, MenuItem, BreadcrumbItem, LinkComponentProps } from './types';
|
|
3
|
+
export default function Layout({ collapsed, expanded, height, className, contentClassName, loading, logo, breadcrumbs, menus, active, open, onChange, version, breadRender, itemRender, onMenuItemClick, onNavigate, linkComponent, title, onLogout, theme, onTheme, children }: LayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAY,MAAM,SAAS,CAAA;AAQpD,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAExF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC7B,SAAwB,EACxB,QAA2B,EAC3B,MAAqB,EACrB,SAAc,EACd,gBAAqB,EACrB,OAAe,EACf,IAAI,EACJ,WAAgB,EAChB,KAAK,EACL,MAAM,EACN,IAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,eAAe,EACf,UAAU,EACV,aAAa,EACb,KAAK,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,QAAQ,EACT,EAAE,WAAW,2CAwJb"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, ComponentType } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Layout menu item
|
|
4
4
|
*/
|
|
@@ -17,10 +17,22 @@ export interface BreadcrumbItem {
|
|
|
17
17
|
icon?: ReactNode;
|
|
18
18
|
onClick?: () => void;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Link component props
|
|
22
|
+
*/
|
|
23
|
+
export interface LinkComponentProps {
|
|
24
|
+
href: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
className?: string;
|
|
27
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
28
|
+
}
|
|
20
29
|
/**
|
|
21
30
|
* Layout component props
|
|
22
31
|
*/
|
|
23
32
|
export interface LayoutProps {
|
|
33
|
+
collapsed?: number;
|
|
34
|
+
expanded?: number;
|
|
35
|
+
height?: number;
|
|
24
36
|
className?: string;
|
|
25
37
|
contentClassName?: string;
|
|
26
38
|
loading?: boolean;
|
|
@@ -34,6 +46,8 @@ export interface LayoutProps {
|
|
|
34
46
|
breadRender?: (items: BreadcrumbItem[]) => ReactNode;
|
|
35
47
|
itemRender?: (item: MenuItem, open: boolean, active: boolean) => ReactNode;
|
|
36
48
|
onMenuItemClick?: (item: MenuItem, e: React.MouseEvent) => void;
|
|
49
|
+
onNavigate?: (path: string) => void;
|
|
50
|
+
linkComponent?: ComponentType<LinkComponentProps>;
|
|
37
51
|
title?: string | ReactNode;
|
|
38
52
|
onLogout?: () => void;
|
|
39
53
|
theme?: 'light' | 'dark';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,SAAS,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,WAAW,CAAC,EAAE,cAAc,EAAE,CAAA;IAC9B,KAAK,EAAE,QAAQ,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,SAAS,CAAA;IACpD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,KAAK,SAAS,CAAA;IAC1E,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;IAC/D,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,aAAa,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAA;IACjD,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,KAAK,IAAI,CAAA;IAC3C,QAAQ,EAAE,SAAS,CAAA;CACpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LayoutSkeletonProps } from './types';
|
|
2
|
+
export type { LayoutSkeletonProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 布局加载骨架屏
|
|
5
|
+
*
|
|
6
|
+
* 模拟真实布局结构,包含:
|
|
7
|
+
* - 收起状态的侧边栏(logo + 菜单项图标)
|
|
8
|
+
* - 顶部导航栏(面包屑 + 右侧操作区)
|
|
9
|
+
* - 主内容区域(表格/卡片骨架)
|
|
10
|
+
*/
|
|
11
|
+
export default function LayoutSkeleton({ size, height }: LayoutSkeletonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PageTransitionProps } from './types';
|
|
2
|
+
export type { PageTransitionProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 页面过渡动画组件
|
|
5
|
+
*
|
|
6
|
+
* 在路径变化时提供淡入淡出 + 轻微上移的过渡效果
|
|
7
|
+
*/
|
|
8
|
+
export default function PageTransition({ pathname, children }: PageTransitionProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PageTransition/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,2CA4BjF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/PageTransition/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,eAAe;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU;IACV,QAAQ,EAAE,SAAS,CAAA;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Aside.d.ts","sourceRoot":"","sources":["../../../src/components/Skeleton/Aside.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,wBAAgB,aAAa,CAAC,EAAE,KAAS,EAAE,EAAE,kBAAkB,2CAY9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LayoutSkeletonProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 布局加载骨架屏
|
|
4
|
+
*
|
|
5
|
+
* 模拟真实布局结构,包含:
|
|
6
|
+
* - 收起状态的侧边栏(logo + 菜单项图标)
|
|
7
|
+
* - 顶部导航栏(面包屑 + 右侧操作区)
|
|
8
|
+
* - 主内容区域(表格/卡片骨架)
|
|
9
|
+
*/
|
|
10
|
+
export declare function LayoutSkeleton({ size, height }: LayoutSkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=Layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../../../src/components/Skeleton/Layout.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAGlD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAuB,EACvB,MAAqB,EACtB,EAAE,mBAAmB,2CAqIrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Skeleton/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skeleton component props
|
|
3
|
+
*/
|
|
4
|
+
/** 侧边栏菜单骨架屏 Props */
|
|
5
|
+
export interface AsideSkeletonProps {
|
|
6
|
+
count?: number;
|
|
7
|
+
}
|
|
8
|
+
/** 完整布局骨架屏 Props */
|
|
9
|
+
export interface LayoutSkeletonProps {
|
|
10
|
+
size?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Skeleton/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAqB;AACrB,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,oBAAoB;AACpB,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/config/layout.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,2BAA2B;AAC3B,eAAO,MAAM,YAAY,KAAK,CAAA;AAE9B,cAAc;AACd,eAAO,MAAM,gBAAgB,MAAM,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { LoginForm } from './components/LoginForm';
|
|
2
|
-
export { Layout } from './components/Layout';
|
|
2
|
+
export { default as Layout } from './components/Layout';
|
|
3
|
+
export { default as PageTransition } from './components/PageTransition';
|
|
4
|
+
export * from './components/Icons';
|
|
5
|
+
export * from './components/Skeleton';
|
|
3
6
|
export type { LoginFormProps, FieldOption, FormData, FieldRenderContext, FieldRenderer } from './components/LoginForm';
|
|
4
|
-
export type { LayoutProps, MenuItem, BreadcrumbItem } from './components/Layout';
|
|
7
|
+
export type { LayoutProps, MenuItem, BreadcrumbItem, LinkComponentProps } from './components/Layout';
|
|
8
|
+
export type { PageTransitionProps } from './components/PageTransition';
|
|
9
|
+
export type { IconProps } from './components/Icons';
|
|
10
|
+
export type { AsideSkeletonProps, LayoutSkeletonProps } from './components/Skeleton';
|
|
5
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACvE,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AAGrC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtH,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACpG,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACtE,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as r}from"react/jsx-runtime";import{useState as a,useEffect as n}from"react";function o({option:r,value:n,error:o,onChange:i}){const[s,l]=a(!1),{key:d,label:c,placeholder:f,prefix:m}=r;return e("div",{className:"group relative",children:[c&&t("label",{htmlFor:d,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:c}),e("div",{className:"relative",children:[m&&t("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:m}),t("input",{id:d,type:s?"text":"password",placeholder:f,value:n,onChange:e=>i(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${m?"pl-10":""}\n pr-10\n ${o?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),t("button",{type:"button",onClick:()=>l(!s),style:{opacity:n?1:0},className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-200 hover:text-[#171717] dark:hover:text-[#d4d4d4] "+(n?"pointer-events-auto":"pointer-events-none"),children:s?t("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})}):e("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:[t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),o&&t("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:o})]},d)}function i({option:r,value:a,error:n,onChange:i}){const{key:s,label:l,type:d="text",placeholder:c,prefix:f,suffix:m}=r;return"password"===d?t(o,{option:r,value:a,error:n,onChange:i}):e("div",{className:"group relative",children:[l&&t("label",{htmlFor:s,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:l}),e("div",{className:"relative",children:[f&&t("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:f}),t("input",{id:s,type:d,placeholder:c,value:a,onChange:e=>i(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${f?"pl-10":""}\n ${m?"pr-10":""}\n ${n?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),m&&t("div",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-300",children:m})]}),n&&t("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:n})]},s)}function s({className:n="",options:o,render:s=i,onFinish:l,loading:d=!1,text:c="sign in",icon:f,title:m="欢迎登录"}){const[h,u]=a(()=>o.reduce((e,t)=>{var r;return e[t.key]=null!==(r=t.defaultValue)&&void 0!==r?r:"",e},{})),{errors:p,validate:x,clearError:k}=function(e,t){const[r,n]=a({});return{errors:r,validate:()=>{const r={};for(const a of e){const e=t[a.key];if(!a.required||e){if(a.validation&&e){const t=a.validation(e);!0!==t&&(r[a.key]="string"==typeof t?t:"Invalid value")}}else r[a.key]="This field is required"}return n(r),0===Object.keys(r).length},clearError:e=>{r[e]&&n(t=>({...t,[e]:""}))}}}(o,h),g=async()=>{x()&&await l(h)},b=d||o.some(e=>e.required&&!h[e.key]);return e("div",{className:`relative w-full h-screen bg-gradient-to-br from-[#fafafa] via-[#ffffff] to-[#fafafa] dark:from-[#000000] dark:via-[#0a0a0a] dark:to-[#000000] flex items-center justify-center p-6 ${n}`,children:[t("div",{className:"absolute inset-0 opacity-[0.015] dark:opacity-[0.02] pointer-events-none",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E\")"}}),t("div",{className:"w-full max-w-[400px] animate-[fadeInUp_0.5s_ease-out]",children:e("div",{className:"relative bg-transparent sm:bg-[#ffffff]/80 sm:dark:bg-[#0a0a0a]/80 backdrop-blur-none sm:backdrop-blur-xl rounded-2xl border-0 md:border md:border-[#e5e5e5]/50 md:dark:border-[#262626]/50 shadow-none sm:shadow-[0_8px_30px_rgb(0,0,0,0.04)] sm:dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] p-8 transition-all duration-500 sm:hover:shadow-[0_8px_30px_rgb(0,0,0,0.06)] sm:dark:hover:shadow-[0_8px_30px_rgb(0,0,0,0.4)]",children:[e("div",{className:"mb-8",children:[f&&t("div",{className:"mb-6 animate-[float_3s_ease-in-out_infinite]",children:t("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-[#fafafa] to-[#e5e5e5] dark:from-[#262626] dark:to-[#171717] border border-[#d4d4d4]/50 dark:border-[#404040]/50 shadow-sm transition-transform duration-300 hover:scale-105",children:f})}),t("h1",{className:"text-[26px] font-semibold text-[#171717] dark:text-[#f5f5f5] tracking-tight leading-tight mb-1.5",children:m}),t("div",{className:"w-12 h-0.5 bg-gradient-to-r from-[#171717] to-[#a3a3a3] dark:from-[#f5f5f5] dark:to-[#525252] rounded-full animate-[slideRight_0.4s_ease-out]"})]}),t("div",{className:"space-y-5",onKeyPress:e=>{"Enter"===e.key&&g()},children:o.map((e,r)=>t("div",{className:"animate-[fadeIn_0.5s_ease-out]",style:{animationDelay:.1*r+"s",animationFillMode:"backwards"},children:s({option:e,value:h[e.key],error:p[e.key],onChange:t=>((e,t)=>{u(r=>({...r,[e]:t})),k(e)})(e.key,t)})},e.key))}),t("button",{onClick:g,disabled:b,className:`\n mt-7 w-full py-3 px-4 rounded-xl\n text-[13px] font-medium tracking-wide\n transition-all duration-300\n ${b?"bg-[#e5e5e5] dark:bg-[#262626] text-[#a3a3a3] dark:text-[#525252] cursor-not-allowed":"bg-[#171717] dark:bg-[#f5f5f5] text-[#ffffff] dark:text-[#000000] shadow-[0_4px_14px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_14px_rgba(255,255,255,0.15)] hover:shadow-[0_6px_20px_rgba(0,0,0,0.2)] dark:hover:shadow-[0_6px_20px_rgba(255,255,255,0.2)] hover:scale-[1.02] active:scale-[0.98]"}\n flex items-center justify-center gap-2\n focus:outline-none focus:ring-2 focus:ring-[#171717] dark:focus:ring-[#f5f5f5] focus:ring-offset-2 focus:ring-offset-[#ffffff] dark:focus:ring-offset-[#000000]\n `,children:d?e(r,{children:[e("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[t("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),t("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t("span",{children:"Loading..."})]}):c})]})}),t("style",{children:"\n @keyframes fadeInUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}\n @keyframes fadeIn{from{opacity:0}to{opacity:1}}\n @keyframes float{0%,100%{transform:translateY(0px)}50%{transform:translateY(-6px)}}\n @keyframes slideRight{from{width:0;opacity:0}to{width:3rem;opacity:1}}\n @keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}\n "})]})}function l({className:e="h-4 w-4"}){return t("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function d({className:r="h-6 w-6"}){return e("svg",{className:`${r} animate-spin`,fill:"none",viewBox:"0 0 24 24",children:[t("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function c({className:e="h-4 w-4"}){return t("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})}function f({className:e="h-4 w-4"}){return t("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}function m({className:e="h-4 w-4"}){return t("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function h({className:e="h-4 w-4",style:r}){return t("svg",{className:e,style:r,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function u({items:r}){return 0===r.length?null:t("nav",{className:"flex items-center gap-2 text-sm",children:r.map((r,a)=>e("div",{className:"flex items-center gap-2",children:[a>0&&t(l,{className:"h-4 w-4 text-[#a3a3a3] dark:text-[#525252]"}),r.href||r.onClick?e("button",{type:"button",onClick:e=>{r.onClick?r.onClick():r.href&&(window.location.href=r.href)},className:"flex items-center gap-1.5 text-[#737373] dark:text-[#d4d4d4] hover:text-[#171717] dark:hover:text-[#f5f5f5] transition-colors cursor-pointer bg-transparent border-none p-0",children:[r.icon,t("span",{children:r.label})]}):e("span",{className:"font-medium text-[#171717] dark:text-[#f5f5f5] flex items-center gap-1.5",children:[r.icon,r.label]})]},a))})}function p(e,t){return!!t&&(e.path===t||e.name===t||!!e.children&&e.children.some(e=>p(e,t)))}function x({item:a,open:n,active:o}){return e(r,{children:[a.icon&&t("div",{className:`shrink-0 flex items-center justify-center transition-colors ${n?"h-4 w-4":"h-5 w-5"} ${o?"text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] group-hover:text-[#171717] dark:group-hover:text-[#fafafa]"}`,children:a.icon}),n&&t("span",{className:"flex-1 text-left whitespace-nowrap",children:a.name})]})}function k({item:r,open:a,active:o,activePath:i,level:s=0,itemRender:l,onMenuItemClick:d,expandedMenu:c,onToggleExpand:f}){const m=r.children&&r.children.length>0,u=m&&p(r,i),k=c===r.name;n(()=>{u&&a&&f&&f(r.name)},[u,a,r.name,f]);const g=o||u;return e("div",{children:[e("button",{type:"button",onClick:e=>{m?(e.preventDefault(),f&&f(r.name)):r.path&&d&&(e.preventDefault(),d(r,e))},className:`w-full group flex items-center rounded-lg text-sm font-medium transition-colors mb-1 ${a?"gap-2 px-3 py-2":"gap-0 justify-center px-2 py-2"} ${g?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"}`,children:[l?l(r,a,o):t(x,{item:r,open:a,active:g}),m&&a&&t(h,{className:"h-4 w-4 shrink-0 transition-transform duration-150 ease-in-out "+(g?"text-[#737373] dark:text-[#a3a3a3]":"text-[#a3a3a3] dark:text-[#737373]"),style:{transform:k?"rotate(180deg)":"rotate(0deg)"}})]}),m&&a&&t("div",{style:{display:"grid",gridTemplateRows:k?"1fr":"0fr",transition:"grid-template-rows 0.2s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden"},children:t("div",{style:{minHeight:0},children:t("div",{className:"ml-3 pl-3 border-l border-[#e5e5e5] dark:border-[#262626] mt-1 space-y-1",children:r.children.map((e,r)=>t("button",{type:"button",onClick:t=>{e.path&&d&&(t.preventDefault(),d(e,t))},className:"w-full flex items-center gap-2 rounded-lg px-3 py-1.5 mb-1 text-sm transition-colors "+(e.path===i||e.name===i?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa] font-medium":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"),children:l?l(e,a,e.path===i||e.name===i):t("span",{className:"flex-1 whitespace-nowrap",children:e.name})},r))})})})]})}function g({theme:e,onTheme:r}){const[o,i]=a("light"),s=void 0!==e,l=s?e:o;n(()=>{if(!s){const e=document.documentElement.classList.contains("dark");i(e?"dark":"light")}},[s]);return t("button",{onClick:()=>{const e="light"===l?"dark":"light";s||(i(e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")),null==r||r(e)},className:"p-2 rounded-lg text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors","aria-label":"切换主题",children:t("light"===l?f:c,{})})}function b({className:o="",contentClassName:i="",loading:s=!1,logo:l,breadcrumbs:c=[],menus:f,active:h,open:p=!1,onChange:x,version:b,breadRender:v,itemRender:w,onMenuItemClick:y,title:N,onLogout:_,theme:C,onTheme:L,children:M}){const[j,E]=a(!1),[$,I]=a(""),z=p||j,B=e=>{I(t=>t===e?"":e)};return n(()=>{if(!h)return;const e=(e=>{for(const t of e)if(t.children){if(t.children.some(e=>e.path===h||e.name===h))return t.name}return null})(f);e&&I(e)},[h,f]),e("div",{className:`flex h-screen bg-[#fafafa] dark:bg-[#000000] ${o}`,children:[e("aside",{onMouseEnter:()=>{E(!0),null==x||x(!0)},onMouseLeave:()=>{E(!1),null==x||x(!1)},className:"fixed left-0 top-0 h-screen z-50 border-r border-[#e5e5e5] dark:border-[#262626] flex flex-col bg-[#ffffff] dark:bg-[#0a0a0a] shadow-lg overflow-hidden",style:{width:z?"240px":"56px",transition:"width 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[t("div",{className:"flex items-center justify-center px-4 border-b border-[#e5e5e5] dark:border-[#262626] shrink-0",style:{height:"56px"},children:l}),t("div",{className:"flex-1 overflow-auto px-3 py-4",children:s?t("div",{className:"flex items-center justify-center py-8",children:t(d,{className:"h-6 w-6 text-[#a3a3a3] dark:text-[#525252]"})}):f.length>0?t("nav",{className:"space-y-1",children:f.map((e,r)=>{const a=(e=>!!h&&(e.path===h||e.name===h))(e);return t(k,{item:e,open:z,active:a,activePath:h,itemRender:w,onMenuItemClick:y,expandedMenu:$,onToggleExpand:B},r)})}):t("div",{className:"text-center text-sm text-[#a3a3a3] dark:text-[#525252] py-8",children:z?"暂无菜单":"无"})}),b&&z&&e("div",{className:"px-4 py-3 border-t border-[#e5e5e5] dark:border-[#262626] text-center text-xs text-[#a3a3a3] dark:text-[#525252]",children:["v",b]})]}),e("main",{className:"flex flex-col overflow-hidden w-full",style:{marginLeft:"56px"},children:[t("header",{className:"bg-[#ffffff] dark:bg-[#0a0a0a] shrink-0",children:e("div",{className:"px-3 flex items-center justify-between border-b border-[#e5e5e5] dark:border-[#262626]",style:{height:"56px"},children:[t("div",{className:"flex items-center",children:v?v(c):t(u,{items:c})}),e("div",{className:"flex items-center gap-2",children:[t(g,{theme:C,onTheme:L}),N&&t("button",{onClick:_,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors",children:"string"==typeof N?e(r,{children:[t("span",{children:N}),_&&t(m,{})]}):N})]})]})}),t("div",{className:`flex-grow overflow-auto ${i}`,children:M})]})]})}export{b as Layout,s as LoginForm};
|
|
1
|
+
import{jsxs as e,jsx as a,Fragment as t}from"react/jsx-runtime";import{useState as r,useEffect as n}from"react";function s({option:t,value:n,error:s,onChange:d}){const[i,o]=r(!1),{key:l,label:c,placeholder:m,prefix:f}=t;return e("div",{className:"group relative",children:[c&&a("label",{htmlFor:l,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:c}),e("div",{className:"relative",children:[f&&a("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:f}),a("input",{id:l,type:i?"text":"password",placeholder:m,value:n,onChange:e=>d(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${f?"pl-10":""}\n pr-10\n ${s?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),a("button",{type:"button",onClick:()=>o(!i),style:{opacity:n?1:0},className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-200 hover:text-[#171717] dark:hover:text-[#d4d4d4] "+(n?"pointer-events-auto":"pointer-events-none"),children:i?a("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})}):e("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:[a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),s&&a("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:s})]},l)}function d({option:t,value:r,error:n,onChange:d}){const{key:i,label:o,type:l="text",placeholder:c,prefix:m,suffix:f}=t;return"password"===l?a(s,{option:t,value:r,error:n,onChange:d}):e("div",{className:"group relative",children:[o&&a("label",{htmlFor:i,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:o}),e("div",{className:"relative",children:[m&&a("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:m}),a("input",{id:i,type:l,placeholder:c,value:r,onChange:e=>d(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${m?"pl-10":""}\n ${f?"pr-10":""}\n ${n?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),f&&a("div",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-300",children:f})]}),n&&a("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:n})]},i)}function i({className:n="",options:s,render:i=d,onFinish:o,loading:l=!1,text:c="sign in",icon:m,title:f="欢迎登录"}){const[u,h]=r(()=>s.reduce((e,a)=>{var t;return e[a.key]=null!==(t=a.defaultValue)&&void 0!==t?t:"",e},{})),{errors:p,validate:x,clearError:g}=function(e,a){const[t,n]=r({});return{errors:t,validate:()=>{const t={};for(const r of e){const e=a[r.key];if(!r.required||e){if(r.validation&&e){const a=r.validation(e);!0!==a&&(t[r.key]="string"==typeof a?a:"Invalid value")}}else t[r.key]="This field is required"}return n(t),0===Object.keys(t).length},clearError:e=>{t[e]&&n(a=>({...a,[e]:""}))}}}(s,u),b=async()=>{x()&&await o(u)},v=l||s.some(e=>e.required&&!u[e.key]);return e("div",{className:`relative w-full h-screen bg-gradient-to-br from-[#fafafa] via-[#ffffff] to-[#fafafa] dark:from-[#000000] dark:via-[#0a0a0a] dark:to-[#000000] flex items-center justify-center p-6 ${n}`,children:[a("div",{className:"absolute inset-0 opacity-[0.015] dark:opacity-[0.02] pointer-events-none",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E\")"}}),a("div",{className:"w-full max-w-[400px] animate-[fadeInUp_0.5s_ease-out]",children:e("div",{className:"relative bg-transparent sm:bg-[#ffffff]/80 sm:dark:bg-[#0a0a0a]/80 backdrop-blur-none sm:backdrop-blur-xl rounded-2xl border-0 md:border md:border-[#e5e5e5]/50 md:dark:border-[#262626]/50 shadow-none sm:shadow-[0_8px_30px_rgb(0,0,0,0.04)] sm:dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] p-8 transition-all duration-500 sm:hover:shadow-[0_8px_30px_rgb(0,0,0,0.06)] sm:dark:hover:shadow-[0_8px_30px_rgb(0,0,0,0.4)]",children:[e("div",{className:"mb-8",children:[m&&a("div",{className:"mb-6 animate-[float_3s_ease-in-out_infinite]",children:a("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-[#fafafa] to-[#e5e5e5] dark:from-[#262626] dark:to-[#171717] border border-[#d4d4d4]/50 dark:border-[#404040]/50 shadow-sm transition-transform duration-300 hover:scale-105",children:m})}),a("h1",{className:"text-[26px] font-semibold text-[#171717] dark:text-[#f5f5f5] tracking-tight leading-tight mb-1.5",children:f}),a("div",{className:"w-12 h-0.5 bg-gradient-to-r from-[#171717] to-[#a3a3a3] dark:from-[#f5f5f5] dark:to-[#525252] rounded-full animate-[slideRight_0.4s_ease-out]"})]}),a("div",{className:"space-y-5",onKeyPress:e=>{"Enter"===e.key&&b()},children:s.map((e,t)=>a("div",{className:"animate-[fadeIn_0.5s_ease-out]",style:{animationDelay:.1*t+"s",animationFillMode:"backwards"},children:i({option:e,value:u[e.key],error:p[e.key],onChange:a=>((e,a)=>{h(t=>({...t,[e]:a})),g(e)})(e.key,a)})},e.key))}),a("button",{onClick:b,disabled:v,className:`\n mt-7 w-full py-3 px-4 rounded-xl\n text-[13px] font-medium tracking-wide\n transition-all duration-300\n ${v?"bg-[#e5e5e5] dark:bg-[#262626] text-[#a3a3a3] dark:text-[#525252] cursor-not-allowed":"bg-[#171717] dark:bg-[#f5f5f5] text-[#ffffff] dark:text-[#000000] shadow-[0_4px_14px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_14px_rgba(255,255,255,0.15)] hover:shadow-[0_6px_20px_rgba(0,0,0,0.2)] dark:hover:shadow-[0_6px_20px_rgba(255,255,255,0.2)] hover:scale-[1.02] active:scale-[0.98]"}\n flex items-center justify-center gap-2\n focus:outline-none focus:ring-2 focus:ring-[#171717] dark:focus:ring-[#f5f5f5] focus:ring-offset-2 focus:ring-offset-[#ffffff] dark:focus:ring-offset-[#000000]\n `,children:l?e(t,{children:[e("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[a("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),a("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),a("span",{children:"Loading..."})]}):c})]})}),a("style",{children:"\n @keyframes fadeInUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}\n @keyframes fadeIn{from{opacity:0}to{opacity:1}}\n @keyframes float{0%,100%{transform:translateY(0px)}50%{transform:translateY(-6px)}}\n @keyframes slideRight{from{width:0;opacity:0}to{width:3rem;opacity:1}}\n @keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}\n "})]})}function o({className:e="h-4 w-4"}){return a("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function l({className:t="h-6 w-6"}){return e("svg",{className:`${t} animate-spin`,fill:"none",viewBox:"0 0 24 24",children:[a("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function c({className:e="h-4 w-4"}){return a("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})}function m({className:e="h-4 w-4"}){return a("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}function f({className:e="h-4 w-4"}){return a("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function u({className:e="h-4 w-4",style:t}){return a("svg",{className:e,style:t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function h({items:t,linkComponent:r}){return 0===t.length?null:a("nav",{className:"flex items-center gap-2 text-sm",children:t.map((t,n)=>e("div",{className:"flex items-center gap-2",children:[n>0&&a(o,{className:"h-4 w-4 text-[#a3a3a3] dark:text-[#525252]"}),t.href||t.onClick?r&&t.href?e(r,{href:t.href,className:"flex items-center gap-1.5 text-[#737373] dark:text-[#d4d4d4] hover:text-[#171717] dark:hover:text-[#f5f5f5] transition-colors",children:[t.icon,a("span",{children:t.label})]}):e("button",{type:"button",onClick:e=>{t.onClick?t.onClick():t.href&&(window.location.href=t.href)},className:"flex items-center gap-1.5 text-[#737373] dark:text-[#d4d4d4] hover:text-[#171717] dark:hover:text-[#f5f5f5] transition-colors cursor-pointer bg-transparent border-none p-0",children:[t.icon,a("span",{children:t.label})]}):e("span",{className:"font-medium text-[#171717] dark:text-[#f5f5f5] flex items-center gap-1.5",children:[t.icon,t.label]})]},n))})}function p(e,a){return!!a&&(e.path===a||e.name===a||!!e.children&&e.children.some(e=>p(e,a)))}function x({item:r,open:n,active:s}){return e(t,{children:[r.icon&&a("div",{className:`shrink-0 flex items-center justify-center transition-colors ${n?"h-4 w-4":"h-5 w-5"} ${s?"text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] group-hover:text-[#171717] dark:group-hover:text-[#fafafa]"}`,children:r.icon}),n&&a("span",{className:"flex-1 text-left whitespace-nowrap",children:r.name})]})}function g({item:t,open:r,active:s,activePath:d,level:i=0,itemRender:o,onMenuItemClick:l,onNavigate:c,expandedMenu:m,onToggleExpand:f}){const h=t.children&&t.children.length>0,g=h&&p(t,d),b=m===t.name;n(()=>{g&&r&&f&&!b&&f(t.name)},[g,r,t.name]);const v=s||g;return e("div",{children:[e("button",{type:"button",onClick:e=>{h?(e.preventDefault(),f&&f(t.name)):t.path&&(e.preventDefault(),l?l(t,e):c&&c(t.path))},className:`w-full group flex items-center rounded-lg text-sm font-medium transition-colors mb-1 ${r?"gap-2 px-3 py-2":"gap-0 justify-center px-2 py-2"} ${v?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"}`,children:[o?o(t,r,s):a(x,{item:t,open:r,active:v}),h&&r&&a(u,{className:"h-4 w-4 shrink-0 transition-transform duration-150 ease-in-out "+(v?"text-[#737373] dark:text-[#a3a3a3]":"text-[#a3a3a3] dark:text-[#737373]"),style:{transform:b?"rotate(180deg)":"rotate(0deg)"}})]}),h&&r&&a("div",{style:{display:"grid",gridTemplateRows:b?"1fr":"0fr",transition:"grid-template-rows 0.2s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden"},children:a("div",{style:{minHeight:0},children:a("div",{className:"ml-3 pl-3 border-l border-[#e5e5e5] dark:border-[#262626] mt-1 space-y-1",children:t.children.map((e,t)=>a("button",{type:"button",onClick:a=>{e.path&&(a.preventDefault(),l?l(e,a):c&&c(e.path))},className:"w-full flex items-center gap-2 rounded-lg px-3 py-1.5 mb-1 text-sm transition-colors "+(e.path===d||e.name===d?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa] font-medium":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"),children:o?o(e,r,e.path===d||e.name===d):a("span",{className:"flex-1 whitespace-nowrap",children:e.name})},t))})})})]})}function b({theme:e,onTheme:t}){const[s,d]=r("light"),i=void 0!==e,o=i?e:s;n(()=>{if(!i){const e=document.documentElement.classList.contains("dark");d(e?"dark":"light")}},[i]);return a("button",{onClick:()=>{const e="light"===o?"dark":"light";i||(d(e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")),null==t||t(e)},className:"p-2 rounded-lg text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors","aria-label":"切换主题",children:a("light"===o?m:c,{})})}function v({count:e=6}){return a("div",{className:"space-y-2",children:[...Array(e)].map((e,t)=>a("div",{className:"h-9 rounded-md bg-muted animate-pulse",style:{animationDelay:100*t+"ms"}},t))})}function k({size:t=240,height:r=56}){return e("div",{className:"flex h-screen bg-background",children:[e("aside",{className:"fixed left-0 top-0 h-screen border-r bg-card",style:{width:`${t}px`},children:[a("div",{className:"flex items-center justify-center border-b",style:{height:`${r}px`},children:a("div",{className:"h-5 w-5 rounded bg-muted animate-pulse"})}),a("div",{className:"px-3 py-4 space-y-2",children:[...Array(6)].map((e,t)=>a("div",{className:"h-9 rounded-md bg-muted animate-pulse",style:{animationDelay:100*t+"ms"}},t))})]}),e("main",{className:"flex flex-col overflow-hidden w-full",style:{marginLeft:`${t}px`},children:[a("header",{className:"bg-card shrink-0",children:e("div",{className:"px-3 flex items-center justify-between border-b",style:{height:`${r}px`},children:[e("div",{className:"flex items-center gap-2",children:[a("div",{className:"h-4 w-16 rounded bg-muted animate-pulse"}),a("div",{className:"h-4 w-1 bg-muted/50"}),a("div",{className:"h-4 w-20 rounded bg-muted animate-pulse"})]}),e("div",{className:"flex items-center gap-2",children:[a("div",{className:"h-8 w-8 rounded-md bg-muted animate-pulse"}),a("div",{className:"h-8 w-8 rounded-full bg-muted animate-pulse"})]})]})}),a("div",{className:"flex-grow overflow-hidden p-3",children:e("div",{className:"space-y-4",children:[e("div",{className:"flex items-center justify-between",children:[a("div",{className:"h-8 w-32 rounded bg-muted animate-pulse"}),a("div",{className:"h-9 w-24 rounded-md bg-muted animate-pulse"})]}),e("div",{className:"flex items-center gap-3",children:[a("div",{className:"h-10 flex-1 rounded-md bg-muted animate-pulse"}),a("div",{className:"h-10 w-32 rounded-md bg-muted animate-pulse"})]}),e("div",{className:"rounded-lg border bg-card overflow-hidden",children:[a("div",{className:"border-b bg-muted/50 px-4 py-3",children:e("div",{className:"flex items-center gap-4",children:[a("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),a("div",{className:"h-4 w-24 rounded bg-muted animate-pulse"}),a("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),a("div",{className:"h-4 w-28 rounded bg-muted animate-pulse"}),a("div",{className:"h-4 w-40 rounded bg-muted animate-pulse"}),a("div",{className:"flex-1"}),a("div",{className:"h-4 w-16 rounded bg-muted animate-pulse"})]})}),[...Array(8)].map((t,r)=>a("div",{className:"border-b px-4 py-3 last:border-b-0",children:e("div",{className:"flex items-center gap-4",children:[a("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),a("div",{className:"h-4 w-24 rounded bg-muted animate-pulse",style:{animationDelay:50*r+"ms"}}),a("div",{className:"h-4 w-32 rounded bg-muted animate-pulse",style:{animationDelay:50*r+100+"ms"}}),a("div",{className:"h-4 w-28 rounded bg-muted animate-pulse",style:{animationDelay:50*r+200+"ms"}}),a("div",{className:"h-4 w-40 rounded bg-muted animate-pulse",style:{animationDelay:50*r+300+"ms"}}),a("div",{className:"flex-1"}),e("div",{className:"flex items-center gap-2",children:[a("div",{className:"h-6 w-6 rounded bg-muted animate-pulse"}),a("div",{className:"h-6 w-6 rounded bg-muted animate-pulse"})]})]})},r))]}),e("div",{className:"flex items-center justify-between",children:[a("div",{className:"h-4 w-40 rounded bg-muted animate-pulse"}),e("div",{className:"flex items-center gap-2",children:[a("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"}),a("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"}),a("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"}),a("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"})]})]})]})})]})]})}function N({collapsed:s=56,expanded:d=240,height:i=56,className:o="",contentClassName:l="",loading:c=!1,logo:m,breadcrumbs:u=[],menus:p,active:x,open:k=!1,onChange:N,version:w,breadRender:y,itemRender:_,onMenuItemClick:C,onNavigate:L,linkComponent:M,title:$,onLogout:j,theme:E,onTheme:z,children:I}){const[T,B]=r(!1),[D,W]=r(""),A=k||T,F=e=>{W(a=>a===e?"":e)};return n(()=>{if(!x)return;const e=(e=>{for(const a of e)if(a.children){if(a.children.some(e=>e.path===x||e.name===x))return a.name}return null})(p);e&&e!==D&&W(e)},[x]),e("div",{className:`flex h-screen bg-[#fafafa] dark:bg-[#000000] ${o}`,children:[e("aside",{onMouseEnter:()=>{B(!0),null==N||N(!0)},onMouseLeave:()=>{B(!1),null==N||N(!1)},className:"fixed left-0 top-0 h-screen z-50 border-r border-[#e5e5e5] dark:border-[#262626] flex flex-col bg-[#ffffff] dark:bg-[#0a0a0a] shadow-lg overflow-hidden",style:{width:A?`${d}px`:`${s}px`,transition:"width 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[a("div",{className:"flex items-center justify-center px-4 border-b border-[#e5e5e5] dark:border-[#262626] shrink-0",style:{height:`${i}px`},children:m}),a("div",{className:"flex-1 overflow-auto px-3 py-4",children:c||0===p.length?a(v,{}):a("nav",{className:"space-y-1",children:p.map((e,t)=>{const r=(e=>!!x&&(e.path===x||e.name===x))(e);return a(g,{item:e,open:A,active:r,activePath:x,itemRender:_,onMenuItemClick:C,onNavigate:L,expandedMenu:D,onToggleExpand:F},t)})})}),w&&A&&e("div",{className:"px-4 py-3 border-t border-[#e5e5e5] dark:border-[#262626] text-center text-xs text-[#a3a3a3] dark:text-[#525252]",children:["v",w]})]}),e("main",{className:"flex flex-col overflow-hidden w-full",style:{marginLeft:`${s}px`},children:[a("header",{className:"bg-[#ffffff] dark:bg-[#0a0a0a] shrink-0",children:e("div",{className:"px-3 flex items-center justify-between border-b border-[#e5e5e5] dark:border-[#262626]",style:{height:`${i}px`},children:[a("div",{className:"flex items-center",children:y?y(u):a(h,{items:u,linkComponent:M})}),e("div",{className:"flex items-center gap-2",children:[a(b,{theme:E,onTheme:z}),$&&a("button",{onClick:j,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors",children:"string"==typeof $?e(t,{children:[a("span",{children:$}),j&&a(f,{})]}):$})]})]})}),a("div",{className:`flex-grow overflow-auto ${l}`,children:I})]})]})}function w({pathname:e,children:t}){const[s,d]=r(!1);return n(()=>{if(!e)return;d(!0);const a=setTimeout(()=>{d(!1)},50);return()=>clearTimeout(a)},[e]),a("div",{className:"h-full transition-all duration-300 ease-out "+(s?"opacity-0 translate-y-2":"opacity-100 translate-y-0"),children:t})}export{v as AsideSkeleton,u as ChevronDownIcon,o as ChevronRightIcon,N as Layout,k as LayoutSkeleton,l as LoadingIcon,i as LoginForm,f as LogoutIcon,m as MoonIcon,w as PageTransition,c as SunIcon};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KoalaUI={},e.jsxRuntime,e.React)}(this,function(e,t,r){"use strict";function a({option:e,value:a,error:n,onChange:s}){const[o,i]=r.useState(!1),{key:l,label:d,placeholder:c,prefix:f}=e;return t.jsxs("div",{className:"group relative",children:[d&&t.jsx("label",{htmlFor:l,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:d}),t.jsxs("div",{className:"relative",children:[f&&t.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:f}),t.jsx("input",{id:l,type:o?"text":"password",placeholder:c,value:a,onChange:e=>s(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${f?"pl-10":""}\n pr-10\n ${n?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),t.jsx("button",{type:"button",onClick:()=>i(!o),style:{opacity:a?1:0},className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-200 hover:text-[#171717] dark:hover:text-[#d4d4d4] "+(a?"pointer-events-auto":"pointer-events-none"),children:o?t.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})}):t.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),n&&t.jsx("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:n})]},l)}function n({option:e,value:r,error:n,onChange:s}){const{key:o,label:i,type:l="text",placeholder:d,prefix:c,suffix:f}=e;return"password"===l?t.jsx(a,{option:e,value:r,error:n,onChange:s}):t.jsxs("div",{className:"group relative",children:[i&&t.jsx("label",{htmlFor:o,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:i}),t.jsxs("div",{className:"relative",children:[c&&t.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:c}),t.jsx("input",{id:o,type:l,placeholder:d,value:r,onChange:e=>s(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${c?"pl-10":""}\n ${f?"pr-10":""}\n ${n?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),f&&t.jsx("div",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-300",children:f})]}),n&&t.jsx("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:n})]},o)}function s({className:e="h-4 w-4"}){return t.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function o({className:e="h-6 w-6"}){return t.jsxs("svg",{className:`${e} animate-spin`,fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function i({className:e="h-4 w-4"}){return t.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})}function l({className:e="h-4 w-4"}){return t.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}function d({className:e="h-4 w-4"}){return t.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function c({className:e="h-4 w-4",style:r}){return t.jsx("svg",{className:e,style:r,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function f({items:e}){return 0===e.length?null:t.jsx("nav",{className:"flex items-center gap-2 text-sm",children:e.map((e,r)=>t.jsxs("div",{className:"flex items-center gap-2",children:[r>0&&t.jsx(s,{className:"h-4 w-4 text-[#a3a3a3] dark:text-[#525252]"}),e.href||e.onClick?t.jsxs("button",{type:"button",onClick:t=>{e.onClick?e.onClick():e.href&&(window.location.href=e.href)},className:"flex items-center gap-1.5 text-[#737373] dark:text-[#d4d4d4] hover:text-[#171717] dark:hover:text-[#f5f5f5] transition-colors cursor-pointer bg-transparent border-none p-0",children:[e.icon,t.jsx("span",{children:e.label})]}):t.jsxs("span",{className:"font-medium text-[#171717] dark:text-[#f5f5f5] flex items-center gap-1.5",children:[e.icon,e.label]})]},r))})}function x(e,t){return!!t&&(e.path===t||e.name===t||!!e.children&&e.children.some(e=>x(e,t)))}function u({item:e,open:r,active:a}){return t.jsxs(t.Fragment,{children:[e.icon&&t.jsx("div",{className:`shrink-0 flex items-center justify-center transition-colors ${r?"h-4 w-4":"h-5 w-5"} ${a?"text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] group-hover:text-[#171717] dark:group-hover:text-[#fafafa]"}`,children:e.icon}),r&&t.jsx("span",{className:"flex-1 text-left whitespace-nowrap",children:e.name})]})}function m({item:e,open:a,active:n,activePath:s,level:o=0,itemRender:i,onMenuItemClick:l,expandedMenu:d,onToggleExpand:f}){const m=e.children&&e.children.length>0,h=m&&x(e,s),p=d===e.name;r.useEffect(()=>{h&&a&&f&&f(e.name)},[h,a,e.name,f]);const k=n||h;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:t=>{m?(t.preventDefault(),f&&f(e.name)):e.path&&l&&(t.preventDefault(),l(e,t))},className:`w-full group flex items-center rounded-lg text-sm font-medium transition-colors mb-1 ${a?"gap-2 px-3 py-2":"gap-0 justify-center px-2 py-2"} ${k?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"}`,children:[i?i(e,a,n):t.jsx(u,{item:e,open:a,active:k}),m&&a&&t.jsx(c,{className:"h-4 w-4 shrink-0 transition-transform duration-150 ease-in-out "+(k?"text-[#737373] dark:text-[#a3a3a3]":"text-[#a3a3a3] dark:text-[#737373]"),style:{transform:p?"rotate(180deg)":"rotate(0deg)"}})]}),m&&a&&t.jsx("div",{style:{display:"grid",gridTemplateRows:p?"1fr":"0fr",transition:"grid-template-rows 0.2s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden"},children:t.jsx("div",{style:{minHeight:0},children:t.jsx("div",{className:"ml-3 pl-3 border-l border-[#e5e5e5] dark:border-[#262626] mt-1 space-y-1",children:e.children.map((e,r)=>t.jsx("button",{type:"button",onClick:t=>{e.path&&l&&(t.preventDefault(),l(e,t))},className:"w-full flex items-center gap-2 rounded-lg px-3 py-1.5 mb-1 text-sm transition-colors "+(e.path===s||e.name===s?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa] font-medium":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"),children:i?i(e,a,e.path===s||e.name===s):t.jsx("span",{className:"flex-1 whitespace-nowrap",children:e.name})},r))})})})]})}function h({theme:e,onTheme:a}){const[n,s]=r.useState("light"),o=void 0!==e,d=o?e:n;r.useEffect(()=>{if(!o){const e=document.documentElement.classList.contains("dark");s(e?"dark":"light")}},[o]);return t.jsx("button",{onClick:()=>{const e="light"===d?"dark":"light";o||(s(e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")),null==a||a(e)},className:"p-2 rounded-lg text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors","aria-label":"切换主题",children:"light"===d?t.jsx(l,{}):t.jsx(i,{})})}e.Layout=function({className:e="",contentClassName:a="",loading:n=!1,logo:s,breadcrumbs:i=[],menus:l,active:c,open:x=!1,onChange:u,version:p,breadRender:k,itemRender:g,onMenuItemClick:b,title:v,onLogout:j,theme:w,onTheme:y,children:N}){const[_,C]=r.useState(!1),[L,M]=r.useState(""),E=x||_,$=e=>{M(t=>t===e?"":e)};return r.useEffect(()=>{if(!c)return;const e=(e=>{for(const t of e)if(t.children){if(t.children.some(e=>e.path===c||e.name===c))return t.name}return null})(l);e&&M(e)},[c,l]),t.jsxs("div",{className:`flex h-screen bg-[#fafafa] dark:bg-[#000000] ${e}`,children:[t.jsxs("aside",{onMouseEnter:()=>{C(!0),null==u||u(!0)},onMouseLeave:()=>{C(!1),null==u||u(!1)},className:"fixed left-0 top-0 h-screen z-50 border-r border-[#e5e5e5] dark:border-[#262626] flex flex-col bg-[#ffffff] dark:bg-[#0a0a0a] shadow-lg overflow-hidden",style:{width:E?"240px":"56px",transition:"width 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[t.jsx("div",{className:"flex items-center justify-center px-4 border-b border-[#e5e5e5] dark:border-[#262626] shrink-0",style:{height:"56px"},children:s}),t.jsx("div",{className:"flex-1 overflow-auto px-3 py-4",children:n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(o,{className:"h-6 w-6 text-[#a3a3a3] dark:text-[#525252]"})}):l.length>0?t.jsx("nav",{className:"space-y-1",children:l.map((e,r)=>{const a=(e=>!!c&&(e.path===c||e.name===c))(e);return t.jsx(m,{item:e,open:E,active:a,activePath:c,itemRender:g,onMenuItemClick:b,expandedMenu:L,onToggleExpand:$},r)})}):t.jsx("div",{className:"text-center text-sm text-[#a3a3a3] dark:text-[#525252] py-8",children:E?"暂无菜单":"无"})}),p&&E&&t.jsxs("div",{className:"px-4 py-3 border-t border-[#e5e5e5] dark:border-[#262626] text-center text-xs text-[#a3a3a3] dark:text-[#525252]",children:["v",p]})]}),t.jsxs("main",{className:"flex flex-col overflow-hidden w-full",style:{marginLeft:"56px"},children:[t.jsx("header",{className:"bg-[#ffffff] dark:bg-[#0a0a0a] shrink-0",children:t.jsxs("div",{className:"px-3 flex items-center justify-between border-b border-[#e5e5e5] dark:border-[#262626]",style:{height:"56px"},children:[t.jsx("div",{className:"flex items-center",children:k?k(i):t.jsx(f,{items:i})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(h,{theme:w,onTheme:y}),v&&t.jsx("button",{onClick:j,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors",children:"string"==typeof v?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:v}),j&&t.jsx(d,{})]}):v})]})]})}),t.jsx("div",{className:`flex-grow overflow-auto ${a}`,children:N})]})]})},e.LoginForm=function({className:e="",options:a,render:s=n,onFinish:o,loading:i=!1,text:l="sign in",icon:d,title:c="欢迎登录"}){const[f,x]=r.useState(()=>a.reduce((e,t)=>{var r;return e[t.key]=null!==(r=t.defaultValue)&&void 0!==r?r:"",e},{})),{errors:u,validate:m,clearError:h}=function(e,t){const[a,n]=r.useState({});return{errors:a,validate:()=>{const r={};for(const a of e){const e=t[a.key];if(!a.required||e){if(a.validation&&e){const t=a.validation(e);!0!==t&&(r[a.key]="string"==typeof t?t:"Invalid value")}}else r[a.key]="This field is required"}return n(r),0===Object.keys(r).length},clearError:e=>{a[e]&&n(t=>({...t,[e]:""}))}}}(a,f),p=async()=>{m()&&await o(f)},k=i||a.some(e=>e.required&&!f[e.key]);return t.jsxs("div",{className:`relative w-full h-screen bg-gradient-to-br from-[#fafafa] via-[#ffffff] to-[#fafafa] dark:from-[#000000] dark:via-[#0a0a0a] dark:to-[#000000] flex items-center justify-center p-6 ${e}`,children:[t.jsx("div",{className:"absolute inset-0 opacity-[0.015] dark:opacity-[0.02] pointer-events-none",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E\")"}}),t.jsx("div",{className:"w-full max-w-[400px] animate-[fadeInUp_0.5s_ease-out]",children:t.jsxs("div",{className:"relative bg-transparent sm:bg-[#ffffff]/80 sm:dark:bg-[#0a0a0a]/80 backdrop-blur-none sm:backdrop-blur-xl rounded-2xl border-0 md:border md:border-[#e5e5e5]/50 md:dark:border-[#262626]/50 shadow-none sm:shadow-[0_8px_30px_rgb(0,0,0,0.04)] sm:dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] p-8 transition-all duration-500 sm:hover:shadow-[0_8px_30px_rgb(0,0,0,0.06)] sm:dark:hover:shadow-[0_8px_30px_rgb(0,0,0,0.4)]",children:[t.jsxs("div",{className:"mb-8",children:[d&&t.jsx("div",{className:"mb-6 animate-[float_3s_ease-in-out_infinite]",children:t.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-[#fafafa] to-[#e5e5e5] dark:from-[#262626] dark:to-[#171717] border border-[#d4d4d4]/50 dark:border-[#404040]/50 shadow-sm transition-transform duration-300 hover:scale-105",children:d})}),t.jsx("h1",{className:"text-[26px] font-semibold text-[#171717] dark:text-[#f5f5f5] tracking-tight leading-tight mb-1.5",children:c}),t.jsx("div",{className:"w-12 h-0.5 bg-gradient-to-r from-[#171717] to-[#a3a3a3] dark:from-[#f5f5f5] dark:to-[#525252] rounded-full animate-[slideRight_0.4s_ease-out]"})]}),t.jsx("div",{className:"space-y-5",onKeyPress:e=>{"Enter"===e.key&&p()},children:a.map((e,r)=>t.jsx("div",{className:"animate-[fadeIn_0.5s_ease-out]",style:{animationDelay:.1*r+"s",animationFillMode:"backwards"},children:s({option:e,value:f[e.key],error:u[e.key],onChange:t=>((e,t)=>{x(r=>({...r,[e]:t})),h(e)})(e.key,t)})},e.key))}),t.jsx("button",{onClick:p,disabled:k,className:`\n mt-7 w-full py-3 px-4 rounded-xl\n text-[13px] font-medium tracking-wide\n transition-all duration-300\n ${k?"bg-[#e5e5e5] dark:bg-[#262626] text-[#a3a3a3] dark:text-[#525252] cursor-not-allowed":"bg-[#171717] dark:bg-[#f5f5f5] text-[#ffffff] dark:text-[#000000] shadow-[0_4px_14px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_14px_rgba(255,255,255,0.15)] hover:shadow-[0_6px_20px_rgba(0,0,0,0.2)] dark:hover:shadow-[0_6px_20px_rgba(255,255,255,0.2)] hover:scale-[1.02] active:scale-[0.98]"}\n flex items-center justify-center gap-2\n focus:outline-none focus:ring-2 focus:ring-[#171717] dark:focus:ring-[#f5f5f5] focus:ring-offset-2 focus:ring-offset-[#ffffff] dark:focus:ring-offset-[#000000]\n `,children:i?t.jsxs(t.Fragment,{children:[t.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t.jsx("span",{children:"Loading..."})]}):l})]})}),t.jsx("style",{children:"\n @keyframes fadeInUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}\n @keyframes fadeIn{from{opacity:0}to{opacity:1}}\n @keyframes float{0%,100%{transform:translateY(0px)}50%{transform:translateY(-6px)}}\n @keyframes slideRight{from{width:0;opacity:0}to{width:3rem;opacity:1}}\n @keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}\n "})]})}});
|
|
1
|
+
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],a):a((e="undefined"!=typeof globalThis?globalThis:e||self).KoalaUI={},e.jsxRuntime,e.React)}(this,function(e,a,t){"use strict";function s({option:e,value:s,error:r,onChange:n}){const[o,i]=t.useState(!1),{key:d,label:l,placeholder:c,prefix:m}=e;return a.jsxs("div",{className:"group relative",children:[l&&a.jsx("label",{htmlFor:d,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:l}),a.jsxs("div",{className:"relative",children:[m&&a.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:m}),a.jsx("input",{id:d,type:o?"text":"password",placeholder:c,value:s,onChange:e=>n(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${m?"pl-10":""}\n pr-10\n ${r?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),a.jsx("button",{type:"button",onClick:()=>i(!o),style:{opacity:s?1:0},className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-200 hover:text-[#171717] dark:hover:text-[#d4d4d4] "+(s?"pointer-events-auto":"pointer-events-none"),children:o?a.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"})}):a.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:[a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.036 12.322a1.012 1.012 0 010-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178z"}),a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),r&&a.jsx("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:r})]},d)}function r({option:e,value:t,error:r,onChange:n}){const{key:o,label:i,type:d="text",placeholder:l,prefix:c,suffix:m}=e;return"password"===d?a.jsx(s,{option:e,value:t,error:r,onChange:n}):a.jsxs("div",{className:"group relative",children:[i&&a.jsx("label",{htmlFor:o,className:"block text-[11px] font-medium text-[#737373] dark:text-[#737373] mb-2 tracking-wide transition-colors group-focus-within:text-[#171717] dark:group-focus-within:text-[#f5f5f5]",children:i}),a.jsxs("div",{className:"relative",children:[c&&a.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] pointer-events-none transition-all duration-300 group-focus-within:text-[#171717] dark:group-focus-within:text-[#d4d4d4] group-focus-within:scale-110",children:c}),a.jsx("input",{id:o,type:d,placeholder:l,value:t,onChange:e=>n(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-[#ffffff] sm:bg-[#ffffff]/50 dark:bg-[#0a0a0a] sm:dark:bg-[#0a0a0a]/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${c?"pl-10":""}\n ${m?"pr-10":""}\n ${r?"border-[#171717] dark:border-[#f5f5f5] shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-[#e5e5e5] dark:border-[#262626] hover:border-[#d4d4d4] dark:hover:border-[#404040] focus:border-[#171717] dark:focus:border-[#f5f5f5] focus:shadow-[0_0_0_3px_rgba(0,0,0,0.05)] dark:focus:shadow-[0_0_0_3px_rgba(255,255,255,0.05)]"}\n text-[#171717] dark:text-[#f5f5f5]\n placeholder:text-[#a3a3a3] dark:placeholder:text-[#525252]\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),m&&a.jsx("div",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-[#737373] dark:text-[#737373] transition-all duration-300",children:m})]}),r&&a.jsx("p",{className:"text-[11px] text-[#171717] dark:text-[#f5f5f5] mt-1.5 animate-[slideIn_0.2s_ease-out]",children:r})]},o)}function n({className:e="h-4 w-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function o({className:e="h-4 w-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})}function i({className:e="h-4 w-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}function d({className:e="h-4 w-4"}){return a.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function l({className:e="h-4 w-4",style:t}){return a.jsx("svg",{className:e,style:t,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function c({items:e,linkComponent:t}){return 0===e.length?null:a.jsx("nav",{className:"flex items-center gap-2 text-sm",children:e.map((e,s)=>a.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&a.jsx(n,{className:"h-4 w-4 text-[#a3a3a3] dark:text-[#525252]"}),e.href||e.onClick?t&&e.href?a.jsxs(t,{href:e.href,className:"flex items-center gap-1.5 text-[#737373] dark:text-[#d4d4d4] hover:text-[#171717] dark:hover:text-[#f5f5f5] transition-colors",children:[e.icon,a.jsx("span",{children:e.label})]}):a.jsxs("button",{type:"button",onClick:a=>{e.onClick?e.onClick():e.href&&(window.location.href=e.href)},className:"flex items-center gap-1.5 text-[#737373] dark:text-[#d4d4d4] hover:text-[#171717] dark:hover:text-[#f5f5f5] transition-colors cursor-pointer bg-transparent border-none p-0",children:[e.icon,a.jsx("span",{children:e.label})]}):a.jsxs("span",{className:"font-medium text-[#171717] dark:text-[#f5f5f5] flex items-center gap-1.5",children:[e.icon,e.label]})]},s))})}function m(e,a){return!!a&&(e.path===a||e.name===a||!!e.children&&e.children.some(e=>m(e,a)))}function f({item:e,open:t,active:s}){return a.jsxs(a.Fragment,{children:[e.icon&&a.jsx("div",{className:`shrink-0 flex items-center justify-center transition-colors ${t?"h-4 w-4":"h-5 w-5"} ${s?"text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] group-hover:text-[#171717] dark:group-hover:text-[#fafafa]"}`,children:e.icon}),t&&a.jsx("span",{className:"flex-1 text-left whitespace-nowrap",children:e.name})]})}function x({item:e,open:s,active:r,activePath:n,level:o=0,itemRender:i,onMenuItemClick:d,onNavigate:c,expandedMenu:x,onToggleExpand:u}){const h=e.children&&e.children.length>0,p=h&&m(e,n),g=x===e.name;t.useEffect(()=>{p&&s&&u&&!g&&u(e.name)},[p,s,e.name]);const b=r||p;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:a=>{h?(a.preventDefault(),u&&u(e.name)):e.path&&(a.preventDefault(),d?d(e,a):c&&c(e.path))},className:`w-full group flex items-center rounded-lg text-sm font-medium transition-colors mb-1 ${s?"gap-2 px-3 py-2":"gap-0 justify-center px-2 py-2"} ${b?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa]":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"}`,children:[i?i(e,s,r):a.jsx(f,{item:e,open:s,active:b}),h&&s&&a.jsx(l,{className:"h-4 w-4 shrink-0 transition-transform duration-150 ease-in-out "+(b?"text-[#737373] dark:text-[#a3a3a3]":"text-[#a3a3a3] dark:text-[#737373]"),style:{transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),h&&s&&a.jsx("div",{style:{display:"grid",gridTemplateRows:g?"1fr":"0fr",transition:"grid-template-rows 0.2s cubic-bezier(0.4, 0, 0.2, 1)",overflow:"hidden"},children:a.jsx("div",{style:{minHeight:0},children:a.jsx("div",{className:"ml-3 pl-3 border-l border-[#e5e5e5] dark:border-[#262626] mt-1 space-y-1",children:e.children.map((e,t)=>a.jsx("button",{type:"button",onClick:a=>{e.path&&(a.preventDefault(),d?d(e,a):c&&c(e.path))},className:"w-full flex items-center gap-2 rounded-lg px-3 py-1.5 mb-1 text-sm transition-colors "+(e.path===n||e.name===n?"bg-[#f5f5f5] dark:bg-[#262626] text-[#171717] dark:text-[#fafafa] font-medium":"text-[#737373] dark:text-[#a3a3a3] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] hover:text-[#171717] dark:hover:text-[#fafafa]"),children:i?i(e,s,e.path===n||e.name===n):a.jsx("span",{className:"flex-1 whitespace-nowrap",children:e.name})},t))})})})]})}function u({theme:e,onTheme:s}){const[r,n]=t.useState("light"),d=void 0!==e,l=d?e:r;t.useEffect(()=>{if(!d){const e=document.documentElement.classList.contains("dark");n(e?"dark":"light")}},[d]);return a.jsx("button",{onClick:()=>{const e="light"===l?"dark":"light";d||(n(e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")),null==s||s(e)},className:"p-2 rounded-lg text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors","aria-label":"切换主题",children:"light"===l?a.jsx(i,{}):a.jsx(o,{})})}function h({count:e=6}){return a.jsx("div",{className:"space-y-2",children:[...Array(e)].map((e,t)=>a.jsx("div",{className:"h-9 rounded-md bg-muted animate-pulse",style:{animationDelay:100*t+"ms"}},t))})}e.AsideSkeleton=h,e.ChevronDownIcon=l,e.ChevronRightIcon=n,e.Layout=function({collapsed:e=56,expanded:s=240,height:r=56,className:n="",contentClassName:o="",loading:i=!1,logo:l,breadcrumbs:m=[],menus:f,active:p,open:g=!1,onChange:b,version:v,breadRender:k,itemRender:j,onMenuItemClick:w,onNavigate:N,linkComponent:y,title:_,onLogout:C,theme:L,onTheme:M,children:$}){const[E,I]=t.useState(!1),[T,z]=t.useState(""),D=g||E,F=e=>{z(a=>a===e?"":e)};return t.useEffect(()=>{if(!p)return;const e=(e=>{for(const a of e)if(a.children){if(a.children.some(e=>e.path===p||e.name===p))return a.name}return null})(f);e&&e!==T&&z(e)},[p]),a.jsxs("div",{className:`flex h-screen bg-[#fafafa] dark:bg-[#000000] ${n}`,children:[a.jsxs("aside",{onMouseEnter:()=>{I(!0),null==b||b(!0)},onMouseLeave:()=>{I(!1),null==b||b(!1)},className:"fixed left-0 top-0 h-screen z-50 border-r border-[#e5e5e5] dark:border-[#262626] flex flex-col bg-[#ffffff] dark:bg-[#0a0a0a] shadow-lg overflow-hidden",style:{width:D?`${s}px`:`${e}px`,transition:"width 0.18s cubic-bezier(0.4, 0, 0.2, 1)"},children:[a.jsx("div",{className:"flex items-center justify-center px-4 border-b border-[#e5e5e5] dark:border-[#262626] shrink-0",style:{height:`${r}px`},children:l}),a.jsx("div",{className:"flex-1 overflow-auto px-3 py-4",children:i||0===f.length?a.jsx(h,{}):a.jsx("nav",{className:"space-y-1",children:f.map((e,t)=>{const s=(e=>!!p&&(e.path===p||e.name===p))(e);return a.jsx(x,{item:e,open:D,active:s,activePath:p,itemRender:j,onMenuItemClick:w,onNavigate:N,expandedMenu:T,onToggleExpand:F},t)})})}),v&&D&&a.jsxs("div",{className:"px-4 py-3 border-t border-[#e5e5e5] dark:border-[#262626] text-center text-xs text-[#a3a3a3] dark:text-[#525252]",children:["v",v]})]}),a.jsxs("main",{className:"flex flex-col overflow-hidden w-full",style:{marginLeft:`${e}px`},children:[a.jsx("header",{className:"bg-[#ffffff] dark:bg-[#0a0a0a] shrink-0",children:a.jsxs("div",{className:"px-3 flex items-center justify-between border-b border-[#e5e5e5] dark:border-[#262626]",style:{height:`${r}px`},children:[a.jsx("div",{className:"flex items-center",children:k?k(m):a.jsx(c,{items:m,linkComponent:y})}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(u,{theme:L,onTheme:M}),_&&a.jsx("button",{onClick:C,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-[#737373] dark:text-[#d4d4d4] hover:bg-[#f5f5f5] dark:hover:bg-[#262626] transition-colors",children:"string"==typeof _?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:_}),C&&a.jsx(d,{})]}):_})]})]})}),a.jsx("div",{className:`flex-grow overflow-auto ${o}`,children:$})]})]})},e.LayoutSkeleton=function({size:e=240,height:t=56}){return a.jsxs("div",{className:"flex h-screen bg-background",children:[a.jsxs("aside",{className:"fixed left-0 top-0 h-screen border-r bg-card",style:{width:`${e}px`},children:[a.jsx("div",{className:"flex items-center justify-center border-b",style:{height:`${t}px`},children:a.jsx("div",{className:"h-5 w-5 rounded bg-muted animate-pulse"})}),a.jsx("div",{className:"px-3 py-4 space-y-2",children:[...Array(6)].map((e,t)=>a.jsx("div",{className:"h-9 rounded-md bg-muted animate-pulse",style:{animationDelay:100*t+"ms"}},t))})]}),a.jsxs("main",{className:"flex flex-col overflow-hidden w-full",style:{marginLeft:`${e}px`},children:[a.jsx("header",{className:"bg-card shrink-0",children:a.jsxs("div",{className:"px-3 flex items-center justify-between border-b",style:{height:`${t}px`},children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-4 w-16 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-4 w-1 bg-muted/50"}),a.jsx("div",{className:"h-4 w-20 rounded bg-muted animate-pulse"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-8 w-8 rounded-md bg-muted animate-pulse"}),a.jsx("div",{className:"h-8 w-8 rounded-full bg-muted animate-pulse"})]})]})}),a.jsx("div",{className:"flex-grow overflow-hidden p-3",children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"h-8 w-32 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-9 w-24 rounded-md bg-muted animate-pulse"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"h-10 flex-1 rounded-md bg-muted animate-pulse"}),a.jsx("div",{className:"h-10 w-32 rounded-md bg-muted animate-pulse"})]}),a.jsxs("div",{className:"rounded-lg border bg-card overflow-hidden",children:[a.jsx("div",{className:"border-b bg-muted/50 px-4 py-3",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-4 w-24 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-4 w-28 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-4 w-40 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"flex-1"}),a.jsx("div",{className:"h-4 w-16 rounded bg-muted animate-pulse"})]})}),[...Array(8)].map((e,t)=>a.jsx("div",{className:"border-b px-4 py-3 last:border-b-0",children:a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-4 w-24 rounded bg-muted animate-pulse",style:{animationDelay:50*t+"ms"}}),a.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse",style:{animationDelay:50*t+100+"ms"}}),a.jsx("div",{className:"h-4 w-28 rounded bg-muted animate-pulse",style:{animationDelay:50*t+200+"ms"}}),a.jsx("div",{className:"h-4 w-40 rounded bg-muted animate-pulse",style:{animationDelay:50*t+300+"ms"}}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-6 w-6 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-6 w-6 rounded bg-muted animate-pulse"})]})]})},t))]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("div",{className:"h-4 w-40 rounded bg-muted animate-pulse"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"}),a.jsx("div",{className:"h-8 w-8 rounded bg-muted animate-pulse"})]})]})]})})]})]})},e.LoadingIcon=function({className:e="h-6 w-6"}){return a.jsxs("svg",{className:`${e} animate-spin`,fill:"none",viewBox:"0 0 24 24",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})},e.LoginForm=function({className:e="",options:s,render:n=r,onFinish:o,loading:i=!1,text:d="sign in",icon:l,title:c="欢迎登录"}){const[m,f]=t.useState(()=>s.reduce((e,a)=>{var t;return e[a.key]=null!==(t=a.defaultValue)&&void 0!==t?t:"",e},{})),{errors:x,validate:u,clearError:h}=function(e,a){const[s,r]=t.useState({});return{errors:s,validate:()=>{const t={};for(const s of e){const e=a[s.key];if(!s.required||e){if(s.validation&&e){const a=s.validation(e);!0!==a&&(t[s.key]="string"==typeof a?a:"Invalid value")}}else t[s.key]="This field is required"}return r(t),0===Object.keys(t).length},clearError:e=>{s[e]&&r(a=>({...a,[e]:""}))}}}(s,m),p=async()=>{u()&&await o(m)},g=i||s.some(e=>e.required&&!m[e.key]);return a.jsxs("div",{className:`relative w-full h-screen bg-gradient-to-br from-[#fafafa] via-[#ffffff] to-[#fafafa] dark:from-[#000000] dark:via-[#0a0a0a] dark:to-[#000000] flex items-center justify-center p-6 ${e}`,children:[a.jsx("div",{className:"absolute inset-0 opacity-[0.015] dark:opacity-[0.02] pointer-events-none",style:{backgroundImage:"url(\"data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E\")"}}),a.jsx("div",{className:"w-full max-w-[400px] animate-[fadeInUp_0.5s_ease-out]",children:a.jsxs("div",{className:"relative bg-transparent sm:bg-[#ffffff]/80 sm:dark:bg-[#0a0a0a]/80 backdrop-blur-none sm:backdrop-blur-xl rounded-2xl border-0 md:border md:border-[#e5e5e5]/50 md:dark:border-[#262626]/50 shadow-none sm:shadow-[0_8px_30px_rgb(0,0,0,0.04)] sm:dark:shadow-[0_8px_30px_rgb(0,0,0,0.3)] p-8 transition-all duration-500 sm:hover:shadow-[0_8px_30px_rgb(0,0,0,0.06)] sm:dark:hover:shadow-[0_8px_30px_rgb(0,0,0,0.4)]",children:[a.jsxs("div",{className:"mb-8",children:[l&&a.jsx("div",{className:"mb-6 animate-[float_3s_ease-in-out_infinite]",children:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-[#fafafa] to-[#e5e5e5] dark:from-[#262626] dark:to-[#171717] border border-[#d4d4d4]/50 dark:border-[#404040]/50 shadow-sm transition-transform duration-300 hover:scale-105",children:l})}),a.jsx("h1",{className:"text-[26px] font-semibold text-[#171717] dark:text-[#f5f5f5] tracking-tight leading-tight mb-1.5",children:c}),a.jsx("div",{className:"w-12 h-0.5 bg-gradient-to-r from-[#171717] to-[#a3a3a3] dark:from-[#f5f5f5] dark:to-[#525252] rounded-full animate-[slideRight_0.4s_ease-out]"})]}),a.jsx("div",{className:"space-y-5",onKeyPress:e=>{"Enter"===e.key&&p()},children:s.map((e,t)=>a.jsx("div",{className:"animate-[fadeIn_0.5s_ease-out]",style:{animationDelay:.1*t+"s",animationFillMode:"backwards"},children:n({option:e,value:m[e.key],error:x[e.key],onChange:a=>((e,a)=>{f(t=>({...t,[e]:a})),h(e)})(e.key,a)})},e.key))}),a.jsx("button",{onClick:p,disabled:g,className:`\n mt-7 w-full py-3 px-4 rounded-xl\n text-[13px] font-medium tracking-wide\n transition-all duration-300\n ${g?"bg-[#e5e5e5] dark:bg-[#262626] text-[#a3a3a3] dark:text-[#525252] cursor-not-allowed":"bg-[#171717] dark:bg-[#f5f5f5] text-[#ffffff] dark:text-[#000000] shadow-[0_4px_14px_rgba(0,0,0,0.15)] dark:shadow-[0_4px_14px_rgba(255,255,255,0.15)] hover:shadow-[0_6px_20px_rgba(0,0,0,0.2)] dark:hover:shadow-[0_6px_20px_rgba(255,255,255,0.2)] hover:scale-[1.02] active:scale-[0.98]"}\n flex items-center justify-center gap-2\n focus:outline-none focus:ring-2 focus:ring-[#171717] dark:focus:ring-[#f5f5f5] focus:ring-offset-2 focus:ring-offset-[#ffffff] dark:focus:ring-offset-[#000000]\n `,children:i?a.jsxs(a.Fragment,{children:[a.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[a.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),a.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),a.jsx("span",{children:"Loading..."})]}):d})]})}),a.jsx("style",{children:"\n @keyframes fadeInUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}\n @keyframes fadeIn{from{opacity:0}to{opacity:1}}\n @keyframes float{0%,100%{transform:translateY(0px)}50%{transform:translateY(-6px)}}\n @keyframes slideRight{from{width:0;opacity:0}to{width:3rem;opacity:1}}\n @keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}\n "})]})},e.LogoutIcon=d,e.MoonIcon=i,e.PageTransition=function({pathname:e,children:s}){const[r,n]=t.useState(!1);return t.useEffect(()=>{if(!e)return;n(!0);const a=setTimeout(()=>{n(!1)},50);return()=>clearTimeout(a)},[e]),a.jsx("div",{className:"h-full transition-all duration-300 ease-out "+(r?"opacity-0 translate-y-2":"opacity-100 translate-y-0"),children:s})},e.SunIcon=o});
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export type { LayoutProps, MenuItem, BreadcrumbItem } from '../components/Layout/types';
|
|
1
|
+
export type { LayoutProps, MenuItem, BreadcrumbItem, LinkComponentProps } from '../components/Layout/types';
|
|
2
2
|
export type { LoginFormProps, FieldOption, FormData, FieldRenderContext, FieldRenderer } from '../components/LoginForm/types';
|
|
3
|
+
export type { IconProps } from '../components/Icons/types';
|
|
4
|
+
export type { AsideSkeletonProps, LayoutSkeletonProps } from '../components/Skeleton/types';
|
|
5
|
+
export type { PageTransitionProps } from '../components/PageTransition/types';
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAG3G,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAG7H,YAAY,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAG1D,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AAG3F,YAAY,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA"}
|