@iamgx/koala 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,7 +55,7 @@ import type { FieldOption, MenuItem } from '@iamgx/koala'
55
55
  ```html
56
56
  <script src="https://unpkg.com/@iamgx/koala/dist/index.umd.js"></script>
57
57
  <script>
58
- const { LoginForm, Layout } = IamgxUI
58
+ const { LoginForm, Layout } = KoalaUI
59
59
  </script>
60
60
  ```
61
61
 
@@ -1,4 +1,4 @@
1
1
  import type { LayoutProps } from './types';
2
2
  export type { LayoutProps, MenuItem, BreadcrumbItem } from './types';
3
- export declare function Layout({ className, loading, logo, breadcrumbs, menus, active, open, onChange, version, breadRender, itemRender, title, onLogout, theme, onTheme, children }: LayoutProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Layout({ className, contentClassName, loading, logo, breadcrumbs, menus, active, open, onChange, version, breadRender, itemRender, onMenuItemClick, 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,EAA4B,MAAM,SAAS,CAAA;AAEpE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAoJpE,wBAAgB,MAAM,CAAC,EACrB,SAAc,EACd,OAAe,EACf,IAAI,EACJ,WAAgB,EAChB,KAAK,EACL,MAAM,EACN,IAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,KAAK,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,QAAQ,EACT,EAAE,WAAW,2CAkHb"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAA4B,MAAM,SAAS,CAAA;AAEpE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAwSpE,wBAAgB,MAAM,CAAC,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,KAAK,EACL,QAAQ,EACR,KAAK,EACL,OAAO,EACP,QAAQ,EACT,EAAE,WAAW,2CA0Jb"}
@@ -22,6 +22,7 @@ export interface BreadcrumbItem {
22
22
  */
23
23
  export interface LayoutProps {
24
24
  className?: string;
25
+ contentClassName?: string;
25
26
  loading?: boolean;
26
27
  logo?: ReactNode;
27
28
  breadcrumbs?: BreadcrumbItem[];
@@ -32,6 +33,7 @@ export interface LayoutProps {
32
33
  version?: string;
33
34
  breadRender?: (items: BreadcrumbItem[]) => ReactNode;
34
35
  itemRender?: (item: MenuItem, open: boolean, active: boolean) => ReactNode;
36
+ onMenuItemClick?: (item: MenuItem, e: React.MouseEvent) => void;
35
37
  title?: string | ReactNode;
36
38
  onLogout?: () => void;
37
39
  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;AAEjC;;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,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,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,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"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Layout/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;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,WAAW;IAC1B,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,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"}
@@ -1,7 +1,7 @@
1
1
  import type { LoginFormProps } from './types';
2
2
  export type { LoginFormProps, FieldOption, FormData, FieldRenderContext, FieldRenderer } from './types';
3
3
  /**
4
- * Swiss minimalism login form - Refined, elegant, full-screen design
4
+ * Main LoginForm component
5
5
  */
6
- export declare function LoginForm({ options, render, onFinish, loading, text, icon, title }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function LoginForm({ className, options, render, onFinish, loading, text, icon, title }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LoginForm/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,SAAS,CAAA;AAGxF,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAyKvG;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,MAA0B,EAC1B,QAAQ,EACR,OAAe,EACf,IAAgB,EAChB,IAAI,EACJ,KAAc,EACf,EAAE,cAAc,2CAkHhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/LoginForm/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,SAAS,CAAA;AAGxF,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AA6KvG;;GAEG;AACH,wBAAgB,SAAS,CAAC,EACxB,SAAc,EACd,OAAO,EACP,MAAqB,EACrB,QAAQ,EACR,OAAe,EACf,IAAgB,EAChB,IAAI,EACJ,KAAc,EACf,EAAE,cAAc,2CA+GhB"}
@@ -34,6 +34,7 @@ export type FieldRenderer<T = string> = (context: FieldRenderContext<T>) => Reac
34
34
  * LoginForm component props
35
35
  */
36
36
  export interface LoginFormProps {
37
+ className?: string;
37
38
  options: FieldOption[];
38
39
  onFinish: (data: FormData) => void | Promise<void>;
39
40
  render?: FieldRenderer;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/LoginForm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,MAAM;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,YAAY,CAAC,EAAE,CAAC,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAAA;CAC5C;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,MAAM;IAC5C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;IACtB,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,MAAM,IAAI,CACtC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAC3B,SAAS,CAAA;AAEd;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/LoginForm/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,MAAM;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,YAAY,CAAC,EAAE,CAAC,CAAA;IAChB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,MAAM,CAAA;CAC5C;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,MAAM;IAC5C,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;IACtB,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,MAAM,IAAI,CACtC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAC3B,SAAS,CAAA;AAEd;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,WAAW,EAAE,CAAA;IACtB,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClD,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as e,jsx as r,Fragment as a}from"react/jsx-runtime";import{useState as t,useEffect as n}from"react";function o({option:a,value:n,error:o,onChange:i}){const[s,l]=t(!1),{key:d,label:c,placeholder:g,prefix:h}=a;return e("div",{className:"group relative",children:[c&&r("label",{htmlFor:d,className:"block text-[11px] font-medium text-gray-500 dark:text-gray-500 mb-2 tracking-wide transition-colors group-focus-within:text-gray-900 dark:group-focus-within:text-gray-100",children:c}),e("div",{className:"relative",children:[h&&r("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 pointer-events-none transition-all duration-300 group-focus-within:text-gray-900 dark:group-focus-within:text-gray-300 group-focus-within:scale-110",children:h}),r("input",{id:d,type:s?"text":"password",placeholder:g,value:n,onChange:e=>i(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-white sm:bg-white/50 dark:bg-gray-950 sm:dark:bg-gray-950/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${h?"pl-10":""}\n pr-10\n ${o?"border-gray-900 dark:border-gray-100 shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-gray-200 dark:border-gray-800 hover:border-gray-300 dark:hover:border-gray-700 focus:border-gray-900 dark:focus:border-gray-100 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-gray-900 dark:text-gray-100\n placeholder:text-gray-400 dark:placeholder:text-gray-600\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),r("button",{type:"button",onClick:()=>l(!s),style:{opacity:n?1:0},className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 transition-all duration-200 hover:text-gray-900 dark:hover:text-gray-300 "+(n?"pointer-events-auto":"pointer-events-none"),children:s?r("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:r("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:[r("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"}),r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),o&&r("p",{className:"text-[11px] text-gray-900 dark:text-gray-100 mt-1.5 animate-[slideIn_0.2s_ease-out]",children:o})]},d)}function i(a){const{option:t,value:n,error:i,onChange:s}=a,{key:l,label:d,type:c="text",placeholder:g,prefix:h,suffix:m}=t;return"password"===c?r(o,{option:t,value:n,error:i,onChange:s}):e("div",{className:"group relative",children:[d&&r("label",{htmlFor:l,className:"block text-[11px] font-medium text-gray-500 dark:text-gray-500 mb-2 tracking-wide transition-colors group-focus-within:text-gray-900 dark:group-focus-within:text-gray-100",children:d}),e("div",{className:"relative",children:[h&&r("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 pointer-events-none transition-all duration-300 group-focus-within:text-gray-900 dark:group-focus-within:text-gray-300 group-focus-within:scale-110",children:h}),r("input",{id:l,type:c,placeholder:g,value:n,onChange:e=>s(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-white sm:bg-white/50 dark:bg-gray-950 sm:dark:bg-gray-950/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${h?"pl-10":""}\n ${m?"pr-10":""}\n ${i?"border-gray-900 dark:border-gray-100 shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-gray-200 dark:border-gray-800 hover:border-gray-300 dark:hover:border-gray-700 focus:border-gray-900 dark:focus:border-gray-100 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-gray-900 dark:text-gray-100\n placeholder:text-gray-400 dark:placeholder:text-gray-600\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),m&&r("div",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 transition-all duration-300",children:m})]}),i&&r("p",{className:"text-[11px] text-gray-900 dark:text-gray-100 mt-1.5 animate-[slideIn_0.2s_ease-out]",children:i})]},l)}function s({options:n,render:o=i,onFinish:s,loading:l=!1,text:d="sign in",icon:c,title:g="欢迎登录"}){const[h,m]=t(()=>n.reduce((e,r)=>{var a;return e[r.key]=null!==(a=r.defaultValue)&&void 0!==a?a:"",e},{})),{errors:u,validate:y,clearError:p}=function(e,r){const[a,n]=t({});return{errors:a,validate:()=>{const a={};for(const t of e){const e=r[t.key];if(!t.required||e){if(t.validation&&e){const r=t.validation(e);!0!==r&&(a[t.key]="string"==typeof r?r:"Invalid value")}}else a[t.key]="This field is required"}return n(a),0===Object.keys(a).length},clearError:e=>{a[e]&&n(r=>({...r,[e]:""}))}}}(n,h),x=async()=>{y()&&await s(h)},f=l||n.some(e=>e.required&&!h[e.key]);return e("div",{className:"relative w-full h-full bg-gradient-to-br from-gray-50 via-white to-gray-100 dark:from-black dark:via-gray-950 dark:to-black flex items-center justify-center p-6",children:[r("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\")"}}),r("div",{className:"w-full max-w-[400px] animate-[fadeInUp_0.5s_ease-out]",children:e("div",{className:"relative bg-transparent sm:bg-white/80 sm:dark:bg-gray-950/80 backdrop-blur-none sm:backdrop-blur-xl rounded-2xl border-0 md:border md:border-gray-200/50 md:dark:border-gray-800/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:[c&&r("div",{className:"mb-6 animate-[float_3s_ease-in-out_infinite]",children:r("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-900 border border-gray-300/50 dark:border-gray-700/50 shadow-sm transition-transform duration-300 hover:scale-105",children:c})}),r("h1",{className:"text-[26px] font-semibold text-gray-900 dark:text-gray-100 tracking-tight leading-tight mb-1.5",children:g}),r("div",{className:"w-12 h-0.5 bg-gradient-to-r from-gray-900 to-gray-400 dark:from-gray-100 dark:to-gray-600 rounded-full animate-[slideRight_0.4s_ease-out]"})]}),r("div",{className:"space-y-5",onKeyPress:e=>{"Enter"===e.key&&x()},children:n.map((e,a)=>r("div",{className:"animate-[fadeIn_0.5s_ease-out]",style:{animationDelay:.1*a+"s",animationFillMode:"backwards"},children:o({option:e,value:h[e.key],error:u[e.key],onChange:r=>((e,r)=>{m(a=>({...a,[e]:r})),p(e)})(e.key,r)})},e.key))}),r("button",{onClick:x,disabled:f,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 ${f?"bg-gray-200 dark:bg-gray-800 text-gray-400 dark:text-gray-600 cursor-not-allowed":"bg-gray-900 dark:bg-gray-100 text-white dark:text-black 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-gray-900 dark:focus:ring-gray-100 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-black\n `,children:l?e(a,{children:[e("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[r("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),r("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"})]}),r("span",{children:"Loading..."})]}):d})]})}),r("style",{children:"@keyframes fadeInUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes float{0%,100%{transform:translateY(0px)}50%{transform:translateY(-6px)}}@keyframes slideRight{from{width:0;opacity:0}to{width:3rem;opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}"})]})}function l({className:e="h-4 w-4"}){return r("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function d({className:a="h-6 w-6"}){return e("svg",{className:`${a} animate-spin`,fill:"none",viewBox:"0 0 24 24",children:[r("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r("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 r("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r("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 g({className:e="h-4 w-4"}){return r("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r("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 h({className:e="h-4 w-4"}){return r("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r("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 m({items:a}){return 0===a.length?null:r("nav",{className:"flex items-center gap-2 text-sm",children:a.map((a,t)=>e("div",{className:"flex items-center gap-2",children:[t>0&&r(l,{className:"h-4 w-4 text-gray-400 dark:text-gray-600"}),a.href||a.onClick?e("a",{href:a.href,onClick:a.onClick,className:"flex items-center gap-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 transition-colors cursor-pointer",children:[a.icon,r("span",{children:a.label})]}):e("span",{className:"font-medium text-gray-900 dark:text-gray-100 flex items-center gap-1.5",children:[a.icon,a.label]})]},t))})}function u({item:a,open:t,active:n}){return e("a",{href:a.path,className:`group flex items-center rounded-lg text-sm font-medium transition-colors mb-1 ${t?"gap-3 px-3 py-2":"gap-0 justify-center p-2"} ${n?"bg-gray-900 dark:bg-gray-100 text-white dark:text-black":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[a.icon&&r("div",{className:"shrink-0 flex items-center justify-center "+(t?"h-4 w-4":"h-5 w-5"),children:a.icon}),t&&r("span",{className:"flex-1 whitespace-nowrap",children:a.name})]})}function y({theme:e,onTheme:a}){const[o,i]=t("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 r("button",{onClick:()=>{const e="light"===l?"dark":"light";s||(i(e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")),null==a||a(e)},className:"p-2 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":"切换主题",children:r("light"===l?g:c,{})})}function p({className:n="",loading:o=!1,logo:i,breadcrumbs:s=[],menus:l,active:c,open:g=!1,onChange:p,version:x,breadRender:f,itemRender:k,title:b,onLogout:v,theme:w,onTheme:N,children:_}){const[C,L]=t(!1),M=g||C,j=e=>!!c&&(e.path===c||e.name===c);return e("div",{className:`flex h-screen bg-gray-50 dark:bg-black ${n}`,children:[e("aside",{onMouseEnter:()=>{L(!0),null==p||p(!0)},onMouseLeave:()=>{L(!1),null==p||p(!1)},className:"fixed left-0 top-0 h-screen z-50 border-r border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-950 transition-[width] duration-150 ease-in-out shadow-lg overflow-hidden",style:{width:M?"240px":"56px"},children:[r("div",{className:"flex items-center justify-center px-4 border-b border-gray-200 dark:border-gray-800 shrink-0",style:{height:"56px"},children:i}),r("div",{className:"flex-1 overflow-auto px-3 py-4",children:o?r("div",{className:"flex items-center justify-center py-8",children:r(d,{className:"h-6 w-6 text-gray-400 dark:text-gray-600"})}):l.length>0?r("nav",{className:"space-y-1",children:l.map((e,a)=>{const t=j(e);return k?r("div",{children:k(e,M,t)},a):r(u,{item:e,open:M,active:t},a)})}):r("div",{className:"text-center text-sm text-gray-500 dark:text-gray-400 py-8",children:M?"暂无菜单":"无"})}),x&&M&&e("div",{className:"px-4 py-3 border-t border-gray-200 dark:border-gray-800 text-center text-xs text-gray-400 dark:text-gray-600",children:["v",x]})]}),e("main",{className:"flex flex-col overflow-hidden w-full transition-[margin-left] duration-150 ease-in-out",style:{marginLeft:"56px"},children:[r("header",{className:"bg-white dark:bg-gray-950 shrink-0",children:e("div",{className:"px-3 flex items-center justify-between border-b border-gray-200 dark:border-gray-800",style:{height:"56px"},children:[r("div",{className:"flex items-center",children:f?f(s):r(m,{items:s})}),e("div",{className:"flex items-center gap-2",children:[r(y,{theme:w,onTheme:N}),b&&r("button",{onClick:v,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"string"==typeof b?e(a,{children:[r("span",{children:b}),v&&r(h,{})]}):b})]})]})}),r("div",{className:"flex-grow overflow-auto",children:_})]})]})}export{p as Layout,s as LoginForm};
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};
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react/jsx-runtime"),require("react")):"function"==typeof define&&define.amd?define(["exports","react/jsx-runtime","react"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).IamgxUI={},e.jsxRuntime,e.React)}(this,function(e,r,a){"use strict";function t({option:e,value:t,error:s,onChange:n}){const[o,i]=a.useState(!1),{key:l,label:d,placeholder:c,prefix:g}=e;return r.jsxs("div",{className:"group relative",children:[d&&r.jsx("label",{htmlFor:l,className:"block text-[11px] font-medium text-gray-500 dark:text-gray-500 mb-2 tracking-wide transition-colors group-focus-within:text-gray-900 dark:group-focus-within:text-gray-100",children:d}),r.jsxs("div",{className:"relative",children:[g&&r.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 pointer-events-none transition-all duration-300 group-focus-within:text-gray-900 dark:group-focus-within:text-gray-300 group-focus-within:scale-110",children:g}),r.jsx("input",{id:l,type:o?"text":"password",placeholder:c,value:t,onChange:e=>n(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-white sm:bg-white/50 dark:bg-gray-950 sm:dark:bg-gray-950/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${g?"pl-10":""}\n pr-10\n ${s?"border-gray-900 dark:border-gray-100 shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-gray-200 dark:border-gray-800 hover:border-gray-300 dark:hover:border-gray-700 focus:border-gray-900 dark:focus:border-gray-100 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-gray-900 dark:text-gray-100\n placeholder:text-gray-400 dark:placeholder:text-gray-600\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),r.jsx("button",{type:"button",onClick:()=>i(!o),style:{opacity:t?1:0},className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 transition-all duration-200 hover:text-gray-900 dark:hover:text-gray-300 "+(t?"pointer-events-auto":"pointer-events-none"),children:o?r.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:r.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"})}):r.jsxs("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",children:[r.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"}),r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),s&&r.jsx("p",{className:"text-[11px] text-gray-900 dark:text-gray-100 mt-1.5 animate-[slideIn_0.2s_ease-out]",children:s})]},l)}function s(e){const{option:a,value:s,error:n,onChange:o}=e,{key:i,label:l,type:d="text",placeholder:c,prefix:g,suffix:x}=a;return"password"===d?r.jsx(t,{option:a,value:s,error:n,onChange:o}):r.jsxs("div",{className:"group relative",children:[l&&r.jsx("label",{htmlFor:i,className:"block text-[11px] font-medium text-gray-500 dark:text-gray-500 mb-2 tracking-wide transition-colors group-focus-within:text-gray-900 dark:group-focus-within:text-gray-100",children:l}),r.jsxs("div",{className:"relative",children:[g&&r.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 pointer-events-none transition-all duration-300 group-focus-within:text-gray-900 dark:group-focus-within:text-gray-300 group-focus-within:scale-110",children:g}),r.jsx("input",{id:i,type:d,placeholder:c,value:s,onChange:e=>o(e.target.value),className:`\n w-full px-3.5 py-2.5 text-[14px]\n bg-white sm:bg-white/50 dark:bg-gray-950 sm:dark:bg-gray-950/50\n backdrop-blur-none sm:backdrop-blur-sm\n border rounded-lg\n transition-all duration-300\n ${g?"pl-10":""}\n ${x?"pr-10":""}\n ${n?"border-gray-900 dark:border-gray-100 shadow-[0_0_0_3px_rgba(0,0,0,0.1)] dark:shadow-[0_0_0_3px_rgba(255,255,255,0.1)]":"border-gray-200 dark:border-gray-800 hover:border-gray-300 dark:hover:border-gray-700 focus:border-gray-900 dark:focus:border-gray-100 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-gray-900 dark:text-gray-100\n placeholder:text-gray-400 dark:placeholder:text-gray-600\n focus:outline-none\n disabled:opacity-40 disabled:cursor-not-allowed\n `}),x&&r.jsx("div",{className:"absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-500 dark:text-gray-500 transition-all duration-300",children:x})]}),n&&r.jsx("p",{className:"text-[11px] text-gray-900 dark:text-gray-100 mt-1.5 animate-[slideIn_0.2s_ease-out]",children:n})]},i)}function n({className:e="h-4 w-4"}){return r.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})}function o({className:e="h-6 w-6"}){return r.jsxs("svg",{className:`${e} animate-spin`,fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.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 r.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r.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 r.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r.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 r.jsx("svg",{className:e,fill:"none",stroke:"currentColor",strokeWidth:2,viewBox:"0 0 24 24",children:r.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({items:e}){return 0===e.length?null:r.jsx("nav",{className:"flex items-center gap-2 text-sm",children:e.map((e,a)=>r.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&r.jsx(n,{className:"h-4 w-4 text-gray-400 dark:text-gray-600"}),e.href||e.onClick?r.jsxs("a",{href:e.href,onClick:e.onClick,className:"flex items-center gap-1.5 text-gray-500 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 transition-colors cursor-pointer",children:[e.icon,r.jsx("span",{children:e.label})]}):r.jsxs("span",{className:"font-medium text-gray-900 dark:text-gray-100 flex items-center gap-1.5",children:[e.icon,e.label]})]},a))})}function g({item:e,open:a,active:t}){return r.jsxs("a",{href:e.path,className:`group flex items-center rounded-lg text-sm font-medium transition-colors mb-1 ${a?"gap-3 px-3 py-2":"gap-0 justify-center p-2"} ${t?"bg-gray-900 dark:bg-gray-100 text-white dark:text-black":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[e.icon&&r.jsx("div",{className:"shrink-0 flex items-center justify-center "+(a?"h-4 w-4":"h-5 w-5"),children:e.icon}),a&&r.jsx("span",{className:"flex-1 whitespace-nowrap",children:e.name})]})}function x({theme:e,onTheme:t}){const[s,n]=a.useState("light"),o=void 0!==e,d=o?e:s;a.useEffect(()=>{if(!o){const e=document.documentElement.classList.contains("dark");n(e?"dark":"light")}},[o]);return r.jsx("button",{onClick:()=>{const e="light"===d?"dark":"light";o||(n(e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")),null==t||t(e)},className:"p-2 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":"切换主题",children:"light"===d?r.jsx(l,{}):r.jsx(i,{})})}e.Layout=function({className:e="",loading:t=!1,logo:s,breadcrumbs:n=[],menus:i,active:l,open:h=!1,onChange:u,version:m,breadRender:y,itemRender:p,title:f,onLogout:k,theme:b,onTheme:v,children:j}){const[w,N]=a.useState(!1),_=h||w,C=e=>!!l&&(e.path===l||e.name===l);return r.jsxs("div",{className:`flex h-screen bg-gray-50 dark:bg-black ${e}`,children:[r.jsxs("aside",{onMouseEnter:()=>{N(!0),null==u||u(!0)},onMouseLeave:()=>{N(!1),null==u||u(!1)},className:"fixed left-0 top-0 h-screen z-50 border-r border-gray-200 dark:border-gray-800 flex flex-col bg-white dark:bg-gray-950 transition-[width] duration-150 ease-in-out shadow-lg overflow-hidden",style:{width:_?"240px":"56px"},children:[r.jsx("div",{className:"flex items-center justify-center px-4 border-b border-gray-200 dark:border-gray-800 shrink-0",style:{height:"56px"},children:s}),r.jsx("div",{className:"flex-1 overflow-auto px-3 py-4",children:t?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(o,{className:"h-6 w-6 text-gray-400 dark:text-gray-600"})}):i.length>0?r.jsx("nav",{className:"space-y-1",children:i.map((e,a)=>{const t=C(e);return p?r.jsx("div",{children:p(e,_,t)},a):r.jsx(g,{item:e,open:_,active:t},a)})}):r.jsx("div",{className:"text-center text-sm text-gray-500 dark:text-gray-400 py-8",children:_?"暂无菜单":"无"})}),m&&_&&r.jsxs("div",{className:"px-4 py-3 border-t border-gray-200 dark:border-gray-800 text-center text-xs text-gray-400 dark:text-gray-600",children:["v",m]})]}),r.jsxs("main",{className:"flex flex-col overflow-hidden w-full transition-[margin-left] duration-150 ease-in-out",style:{marginLeft:"56px"},children:[r.jsx("header",{className:"bg-white dark:bg-gray-950 shrink-0",children:r.jsxs("div",{className:"px-3 flex items-center justify-between border-b border-gray-200 dark:border-gray-800",style:{height:"56px"},children:[r.jsx("div",{className:"flex items-center",children:y?y(n):r.jsx(c,{items:n})}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(x,{theme:b,onTheme:v}),f&&r.jsx("button",{onClick:k,className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors",children:"string"==typeof f?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:f}),k&&r.jsx(d,{})]}):f})]})]})}),r.jsx("div",{className:"flex-grow overflow-auto",children:j})]})]})},e.LoginForm=function({options:e,render:t=s,onFinish:n,loading:o=!1,text:i="sign in",icon:l,title:d="欢迎登录"}){const[c,g]=a.useState(()=>e.reduce((e,r)=>{var a;return e[r.key]=null!==(a=r.defaultValue)&&void 0!==a?a:"",e},{})),{errors:x,validate:h,clearError:u}=function(e,r){const[t,s]=a.useState({});return{errors:t,validate:()=>{const a={};for(const t of e){const e=r[t.key];if(!t.required||e){if(t.validation&&e){const r=t.validation(e);!0!==r&&(a[t.key]="string"==typeof r?r:"Invalid value")}}else a[t.key]="This field is required"}return s(a),0===Object.keys(a).length},clearError:e=>{t[e]&&s(r=>({...r,[e]:""}))}}}(e,c),m=async()=>{h()&&await n(c)},y=o||e.some(e=>e.required&&!c[e.key]);return r.jsxs("div",{className:"relative w-full h-full bg-gradient-to-br from-gray-50 via-white to-gray-100 dark:from-black dark:via-gray-950 dark:to-black flex items-center justify-center p-6",children:[r.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\")"}}),r.jsx("div",{className:"w-full max-w-[400px] animate-[fadeInUp_0.5s_ease-out]",children:r.jsxs("div",{className:"relative bg-transparent sm:bg-white/80 sm:dark:bg-gray-950/80 backdrop-blur-none sm:backdrop-blur-xl rounded-2xl border-0 md:border md:border-gray-200/50 md:dark:border-gray-800/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:[r.jsxs("div",{className:"mb-8",children:[l&&r.jsx("div",{className:"mb-6 animate-[float_3s_ease-in-out_infinite]",children:r.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-900 border border-gray-300/50 dark:border-gray-700/50 shadow-sm transition-transform duration-300 hover:scale-105",children:l})}),r.jsx("h1",{className:"text-[26px] font-semibold text-gray-900 dark:text-gray-100 tracking-tight leading-tight mb-1.5",children:d}),r.jsx("div",{className:"w-12 h-0.5 bg-gradient-to-r from-gray-900 to-gray-400 dark:from-gray-100 dark:to-gray-600 rounded-full animate-[slideRight_0.4s_ease-out]"})]}),r.jsx("div",{className:"space-y-5",onKeyPress:e=>{"Enter"===e.key&&m()},children:e.map((e,a)=>r.jsx("div",{className:"animate-[fadeIn_0.5s_ease-out]",style:{animationDelay:.1*a+"s",animationFillMode:"backwards"},children:t({option:e,value:c[e.key],error:x[e.key],onChange:r=>((e,r)=>{g(a=>({...a,[e]:r})),u(e)})(e.key,r)})},e.key))}),r.jsx("button",{onClick:m,disabled:y,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 ${y?"bg-gray-200 dark:bg-gray-800 text-gray-400 dark:text-gray-600 cursor-not-allowed":"bg-gray-900 dark:bg-gray-100 text-white dark:text-black 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-gray-900 dark:focus:ring-gray-100 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-black\n `,children:o?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3"}),r.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"})]}),r.jsx("span",{children:"Loading..."})]}):i})]})}),r.jsx("style",{children:"@keyframes fadeInUp{from{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes float{0%,100%{transform:translateY(0px)}50%{transform:translateY(-6px)}}@keyframes slideRight{from{width:0;opacity:0}to{width:3rem;opacity:1}}@keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}"})]})}});
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 "})]})}});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iamgx/koala",
3
- "rollUpBuildName": "IamgxUI",
4
- "version": "1.0.1",
3
+ "rollUpBuildName": "KoalaUI",
4
+ "version": "1.1.0",
5
5
  "description": "Universal React + Tailwind UI component library",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",