@adminui-dev/layout 1.0.4 → 1.0.6

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.
@@ -1,4 +1,9 @@
1
1
  import { LAYOUT_ASIDE_KEY } from "./LayoutContext";
2
+ /**
3
+ * Aside for layout
4
+ * @param props
5
+ * @returns
6
+ */
2
7
  declare function LayoutAside(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
3
8
  declare namespace LayoutAside {
4
9
  var displayName: string;
@@ -1 +1,12 @@
1
- export default function (): import("react/jsx-runtime").JSX.Element;
1
+ import { LAYOUT_BACKGROUND_KEY } from "./LayoutContext";
2
+ /**
3
+ * Background for layout
4
+ * @param props
5
+ * @returns
6
+ */
7
+ declare function LayoutBackground(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
8
+ declare namespace LayoutBackground {
9
+ var displayName: string;
10
+ var role: typeof LAYOUT_BACKGROUND_KEY;
11
+ }
12
+ export default LayoutBackground;
@@ -1,4 +1,9 @@
1
1
  import { LAYOUT_CONTENT_KEY } from './LayoutContext';
2
+ /**
3
+ * Content for layout
4
+ * @param props
5
+ * @returns
6
+ */
2
7
  declare function LayoutContent(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
3
8
  declare namespace LayoutContent {
4
9
  var displayName: string;
@@ -1,12 +1,12 @@
1
- import type { LayoutConfig, ThemeSkin, ConfigActionDispatcher, ConfigStateDispatcher } from "./typings";
1
+ import type { LayoutConfig, ConfigActionDispatcher, ConfigStateDispatcher } from "./typings";
2
2
  export declare function defineConfig(config: LayoutConfig): LayoutConfig;
3
3
  export declare const LAYOUT_ASIDE_KEY: unique symbol;
4
4
  export declare const LAYOUT_CONTENT_KEY: unique symbol;
5
5
  export declare const LAYOUT_HEADER_KEY: unique symbol;
6
- export declare const defaultSkinData: ThemeSkin;
6
+ export declare const LAYOUT_BACKGROUND_KEY: unique symbol;
7
7
  export declare const defaultConfig: LayoutConfig;
8
8
  export declare const createConfigActionContext: () => import("react").Context<ConfigActionDispatcher>;
9
9
  export declare const createConfigStateContext: () => import("react").Context<ConfigStateDispatcher>;
10
10
  export declare const useConfigState: () => ConfigStateDispatcher;
11
11
  export declare const useConfigAction: () => ConfigActionDispatcher;
12
- export declare const useTheme: () => import("./typings").Theme;
12
+ export declare const useTheme: () => import("./typings").Theme | undefined;
@@ -1,4 +1,9 @@
1
1
  import { LAYOUT_HEADER_KEY } from "./LayoutContext";
2
+ /**
3
+ * Header for layout
4
+ * @param props
5
+ * @returns
6
+ */
2
7
  declare function LayoutHeader(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
3
8
  declare namespace LayoutHeader {
4
9
  var displayName: string;
@@ -1,6 +1,6 @@
1
1
  import { BaseLayout } from "./Layout";
2
2
  import FullScreenButton from "./FullScreenButton";
3
3
  import LayoutBackground from "./LayoutBackground";
4
- import { createConfigActionContext, createConfigStateContext, useConfigState, useConfigAction, useTheme, defaultConfig, defineConfig, defaultSkinData } from "./LayoutContext";
4
+ import { createConfigActionContext, createConfigStateContext, useConfigState, useConfigAction, useTheme, defaultConfig, defineConfig } from "./LayoutContext";
5
5
  import { getAvatarInitials, hexToRgb, hexToRgbaString, getLayoutTheme } from "./common";
6
- export { BaseLayout, LayoutBackground, FullScreenButton, createConfigActionContext, createConfigStateContext, useConfigState, useConfigAction, useTheme, getAvatarInitials, hexToRgb, hexToRgbaString, defaultConfig, defaultSkinData, getLayoutTheme, defineConfig };
6
+ export { BaseLayout, LayoutBackground, FullScreenButton, createConfigActionContext, createConfigStateContext, useConfigState, useConfigAction, useTheme, getAvatarInitials, hexToRgb, hexToRgbaString, defaultConfig, getLayoutTheme, defineConfig };
@@ -1,3 +1,4 @@
1
+ import LayoutBackground from './LayoutBackground';
1
2
  import type { BaseLayoutProps } from './typings';
2
3
  /**
3
4
  * Base layout
@@ -9,5 +10,6 @@ declare namespace BaseLayout {
9
10
  var Aside: typeof import("./LayoutAside").default;
10
11
  var Content: typeof import("./LayoutContent").default;
11
12
  var Header: typeof import("./LayoutHeader").default;
13
+ var Background: typeof LayoutBackground;
12
14
  }
13
15
  export { BaseLayout };
@@ -5,16 +5,16 @@ type ContainerMode = 'inline' | 'box' | 'panel';
5
5
  type ContainerStretch = 'inline' | 'auto' | 'fill';
6
6
  type SkinType = 'tidy' | 'rich';
7
7
  type Position = "top" | "center" | "bottom";
8
+ type AvatarPosition = "rightTop" | "leftBottom" | "none";
8
9
  type ConfigStateDispatcher = {
9
10
  layoutConfig: LayoutConfig;
10
11
  locale: string;
11
- theme: Theme;
12
- themeSkin: ThemeSkin;
12
+ themeSkin?: ThemeSkin;
13
13
  themeSkinMap: Record<SkinType, ThemeSkin[]>;
14
14
  languages: Language[];
15
+ menuDataMap?: Record<string, MenuData[]>;
15
16
  };
16
17
  type ConfigActionDispatcher = {
17
- setTheme: (theme: Theme) => void;
18
18
  setLocale: (locale: string) => void;
19
19
  setLayoutConfig: (config: LayoutConfig) => void;
20
20
  };
@@ -47,19 +47,26 @@ interface LayoutConfig {
47
47
  asideTransparent?: boolean;
48
48
  headerTransparent?: boolean;
49
49
  containerTransparent?: boolean;
50
+ asideBlur?: boolean;
51
+ headerBlur?: boolean;
52
+ containerBlur?: boolean;
50
53
  collapsedPosition?: Position;
54
+ avatarPosition?: AvatarPosition;
51
55
  userInfo?: UserInfo;
52
56
  brandInfo?: BrandInfo;
53
57
  }
54
58
  interface ThemeSkin {
55
59
  name: string;
56
- icon: string;
60
+ icon?: string;
57
61
  label?: string;
58
62
  theme: LayoutTheme[];
59
- themeType: SkinType;
63
+ skinType: SkinType;
64
+ backgroundContent?: React.ReactNode;
60
65
  asideWidth?: number;
61
66
  primaryColor?: string;
62
- asideCollapsedWidth?: number;
67
+ asideBlur?: boolean;
68
+ headerBlur?: boolean;
69
+ containerBlur?: boolean;
63
70
  layoutBorderColor?: string;
64
71
  headerStyle?: React.CSSProperties;
65
72
  asideStyle?: React.CSSProperties;
@@ -106,7 +113,7 @@ interface BaseLayoutProps extends LayoutProps {
106
113
  }
107
114
  interface RootLayoutProps<T> extends LayoutProps {
108
115
  layoutConfig?: LayoutConfig;
109
- menuData?: MenuData[];
116
+ menuData?: MenuData;
110
117
  theme?: Theme;
111
118
  locale?: string;
112
119
  localeMessages?: Record<string, T>;
@@ -122,4 +129,4 @@ interface ContainerProps extends LayoutProps {
122
129
  transparent?: boolean;
123
130
  children?: React.ReactNode;
124
131
  }
125
- export type { LayoutProps, BaseLayoutProps, RootLayoutProps, ContainerProps, ContainerMode, ContainerStretch, Theme, LayoutTheme, LayoutType, LayoutConfig, Language, LocaleMessageData, UserInfo, BrandInfo, ConfigStateDispatcher, ConfigActionDispatcher, SkinType, ThemeSkin, MenuData, Position, OutletContainer };
132
+ export type { LayoutProps, BaseLayoutProps, RootLayoutProps, ContainerProps, ContainerMode, ContainerStretch, Theme, LayoutTheme, LayoutType, LayoutConfig, Language, LocaleMessageData, UserInfo, BrandInfo, ConfigStateDispatcher, ConfigActionDispatcher, SkinType, ThemeSkin, MenuData, Position, AvatarPosition, OutletContainer };
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("react/jsx-runtime"),n=require("react");function t(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===t&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}var r="Layout-module_rootBackground__j3UVG";function o(){return e.jsx("div",{className:r})}t("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%;\r\n height:100%\r\n }\r\n #Layout-module_root__3x-pW { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.Layout-module_rootBox__3JHjy {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-width: 100%;\r\n}\r\n.Layout-module_rootBackground__j3UVG {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n overflow: hidden;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n height:100%;\r\n min-height: 100%;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.Layout-module_rootLayout__jVEEF {\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.Layout-module_mainLayout__6W9W9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n");const i=Symbol("LayoutAside"),a=Symbol("LayoutContent"),s=Symbol("LayoutHeader"),l={icon:"",name:"default",themeType:"tidy",theme:["light","dark"]},d={headerHeight:50,asideWidth:260,layoutType:"leftMenu",collapsedPosition:"bottom",theme:"system",primaryColor:"#417ffb",skinName:l.name},u=n.createContext({setTheme:()=>{},setLayoutConfig:()=>{},setLocale:()=>{}}),c=n.createContext({locale:"en-US",languages:[],theme:"system",layoutConfig:{},themeSkin:l,themeSkinMap:{tidy:[],rich:[]}}),m=()=>n.useContext(c);function h(n){return e.jsx(e.Fragment,{children:n.children})}function x(n){return e.jsx(e.Fragment,{children:n.children})}function g(n){return e.jsx(e.Fragment,{children:n.children})}h.displayName="LayoutContent",h.role=a,x.displayName="LayoutAside",x.role=i,g.displayName="LayoutHeader",g.role=s;var f="layout-module_rootBox__Y8bEx",y="layout-module_rootLayout__TePvr",b="layout-module_mainLayout__a8Tb9";function p(t){let r=null,l=null,d=null;return n.Children.forEach(t.children,e=>{const n=e.type.role;n===s?r=e:n===a?l=e:n===i&&(d=e)}),e.jsx(e.Fragment,{children:e.jsxs("div",{ref:t.ref,className:f,style:{...t.style},children:[e.jsx(o,{}),e.jsxs("div",{className:y,children:[d,e.jsxs("div",{className:b,children:[r,l]})]})]})})}t("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%;\r\n height:100%\r\n }\r\n #layout-module_root__0efzq { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.layout-module_rootBox__Y8bEx {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-width: 100%;\r\n}\r\n.layout-module_rootBackground__vEs6e {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n overflow: hidden;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n height:100%;\r\n min-height: 100%;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.layout-module_rootLayout__TePvr {\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.layout-module_mainLayout__a8Tb9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n"),p.Aside=x,p.Content=h,p.Header=g;const _=e=>({r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:9===e.length?(parseInt(e.slice(7,9),16)/255).toFixed(2):1});exports.BaseLayout=p,exports.FullScreenButton=function(t){const r=!!document.fullscreenElement,[o,i]=n.useState(r),a=()=>{i(!!document.fullscreenElement)},s=e=>{"F11"===e.code&&(e.preventDefault(),l())};n.useEffect(()=>(document.addEventListener("fullscreenchange",a),document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("fullscreenchange",a),document.removeEventListener("keydown",s)}),[]);const l=()=>{o?document.exitFullscreen():document.documentElement.requestFullscreen()};if(!t.buttons||t.buttons.length<2)return e.jsx(e.Fragment,{});const[d,u]=t.buttons,c=o?d:u;return n.cloneElement(c,{onClick:e=>{console.log(e),l()}})},exports.LayoutBackground=o,exports.createConfigActionContext=()=>u,exports.createConfigStateContext=()=>c,exports.defaultConfig=d,exports.defaultSkinData=l,exports.defineConfig=function(e){return e},exports.getAvatarInitials=function(e){if(!e)return"";const n=Array.from(e);if(0===n.length)return"";const t=n[0];return function(e){if(0===e.length)return!1;const n=e.codePointAt(0);return n>=19968&&n<=40959||n>=13312&&n<=19903||n>=12352&&n<=12543||n>=44032&&n<=55215||n>=65280&&n<=65519||n>=126976&&n<=129791||n>=127744&&n<=128511||n>=128640&&n<=128767||n>=129280&&n<=129535||n>=9728&&n<=9983||n>=9984&&n<=10175}(t)?t:n.slice(0,2).join("")},exports.getLayoutTheme=e=>{if("system"==e){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return e},exports.hexToRgb=e=>{const{r:n,g:t,b:r}=_(e);return{r:n,g:t,b:r}},exports.hexToRgbaString=(e,n)=>{const{r:t,g:r,b:o,a:i}=_(e);return`rgba(${t}, ${r}, ${o}, ${n??i})`},exports.useConfigAction=()=>n.useContext(u),exports.useConfigState=m,exports.useTheme=()=>m().theme;
1
+ "use strict";var e=require("react/jsx-runtime"),n=require("react");function r(e,n){void 0===n&&(n={});var r=n.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}var t="Layout-module_rootBackground__j3UVG";r("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%; \r\n height: 100%;\r\n }\r\n #Layout-module_root__3x-pW { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.Layout-module_rootBox__3JHjy {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-height: 100%;\r\n}\r\n.Layout-module_rootBackground__j3UVG {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n width: 100%; \r\n min-width: 100vw;\r\n height:100%;\r\n min-height: 100vh;\r\n overflow: hidden;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.Layout-module_rootBackground__j3UVG>div{\r\n width:100%;\r\n height: 100%;\r\n overflow: hidden;\r\n}\r\n.Layout-module_rootLayout__jVEEF {\r\n position: relative;\r\n z-index: 1;\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.Layout-module_mainLayout__6W9W9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n");const o=Symbol("LayoutAside"),i=Symbol("LayoutContent"),a=Symbol("LayoutHeader"),l=Symbol("LayoutBackground"),s=n.createContext({setLayoutConfig:()=>{},setLocale:()=>{}}),d=n.createContext({locale:"en-US",languages:[],layoutConfig:{},themeSkinMap:{tidy:[],rich:[]}}),u=()=>n.useContext(d);function c(n){return e.jsx("div",{className:t,children:e.jsx(e.Fragment,{children:n.children})})}function h(n){return e.jsx(e.Fragment,{children:n.children})}function m(n){return e.jsx(e.Fragment,{children:n.children})}function g(n){return e.jsx(e.Fragment,{children:n.children})}c.displayName="LayoutBackground",c.role=l,h.displayName="LayoutContent",h.role=i,m.displayName="LayoutAside",m.role=o,g.displayName="LayoutHeader",g.role=a;var x="layout-module_rootBox__Y8bEx",y="layout-module_rootLayout__TePvr",f="layout-module_mainLayout__a8Tb9";function b(r){let t=null,s=null,d=null,u=null;return n.Children.forEach(r.children,e=>{const n=e.type.role;n===a?t=e:n===i?s=e:n===o?d=e:n===l&&(u=e)}),e.jsx(e.Fragment,{children:e.jsxs("div",{ref:r.ref,className:x,style:{...r.style},children:[u,e.jsxs("div",{className:y,children:[d,e.jsxs("div",{className:f,children:[t,s]})]})]})})}r("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%; \r\n height: 100%;\r\n }\r\n #layout-module_root__0efzq { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.layout-module_rootBox__Y8bEx {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-height: 100%;\r\n}\r\n.layout-module_rootBackground__vEs6e {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n width: 100%; \r\n min-width: 100vw;\r\n height:100%;\r\n min-height: 100vh;\r\n overflow: hidden;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.layout-module_rootBackground__vEs6e>div{\r\n width:100%;\r\n height: 100%;\r\n overflow: hidden;\r\n}\r\n.layout-module_rootLayout__TePvr {\r\n position: relative;\r\n z-index: 1;\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.layout-module_mainLayout__a8Tb9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n"),b.Aside=m,b.Content=h,b.Header=g,b.Background=c;const p=e=>({r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:9===e.length?(parseInt(e.slice(7,9),16)/255).toFixed(2):1});exports.BaseLayout=b,exports.FullScreenButton=function(r){const t=!!document.fullscreenElement,[o,i]=n.useState(t),a=()=>{i(!!document.fullscreenElement)},l=e=>{"F11"===e.code&&(e.preventDefault(),s())};n.useEffect(()=>(document.addEventListener("fullscreenchange",a),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("fullscreenchange",a),document.removeEventListener("keydown",l)}),[]);const s=()=>{o?document.exitFullscreen():document.documentElement.requestFullscreen()};if(!r.buttons||r.buttons.length<2)return e.jsx(e.Fragment,{});const[d,u]=r.buttons,c=o?d:u;return n.cloneElement(c,{onClick:e=>{console.log(e),s()}})},exports.LayoutBackground=c,exports.createConfigActionContext=()=>s,exports.createConfigStateContext=()=>d,exports.defaultConfig={headerHeight:50,asideWidth:260,layoutType:"leftMenu",collapsedPosition:"bottom",avatarPosition:"rightTop",theme:"system",primaryColor:"#417ffb"},exports.defineConfig=function(e){return e},exports.getAvatarInitials=function(e){if(!e)return"";const n=Array.from(e);if(0===n.length)return"";const r=n[0];return function(e){if(0===e.length)return!1;const n=e.codePointAt(0);return n>=19968&&n<=40959||n>=13312&&n<=19903||n>=12352&&n<=12543||n>=44032&&n<=55215||n>=65280&&n<=65519||n>=126976&&n<=129791||n>=127744&&n<=128511||n>=128640&&n<=128767||n>=129280&&n<=129535||n>=9728&&n<=9983||n>=9984&&n<=10175}(r)?r:n.slice(0,2).join("")},exports.getLayoutTheme=e=>{if("system"==e){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return e},exports.hexToRgb=e=>{const{r:n,g:r,b:t}=p(e);return{r:n,g:r,b:t}},exports.hexToRgbaString=(e,n)=>{const{r:r,g:t,b:o,a:i}=p(e);return`rgba(${r}, ${t}, ${o}, ${n??i})`},exports.useConfigAction=()=>n.useContext(s),exports.useConfigState=u,exports.useTheme=()=>u().layoutConfig.theme;
package/dist/index.d.ts CHANGED
@@ -9,16 +9,16 @@ type ContainerMode = 'inline' | 'box' | 'panel';
9
9
  type ContainerStretch = 'inline' | 'auto' | 'fill';
10
10
  type SkinType = 'tidy' | 'rich';
11
11
  type Position = "top" | "center" | "bottom";
12
+ type AvatarPosition = "rightTop" | "leftBottom" | "none";
12
13
  type ConfigStateDispatcher = {
13
14
  layoutConfig: LayoutConfig;
14
15
  locale: string;
15
- theme: Theme;
16
- themeSkin: ThemeSkin;
16
+ themeSkin?: ThemeSkin;
17
17
  themeSkinMap: Record<SkinType, ThemeSkin[]>;
18
18
  languages: Language[];
19
+ menuDataMap?: Record<string, MenuData[]>;
19
20
  };
20
21
  type ConfigActionDispatcher = {
21
- setTheme: (theme: Theme) => void;
22
22
  setLocale: (locale: string) => void;
23
23
  setLayoutConfig: (config: LayoutConfig) => void;
24
24
  };
@@ -51,19 +51,26 @@ interface LayoutConfig {
51
51
  asideTransparent?: boolean;
52
52
  headerTransparent?: boolean;
53
53
  containerTransparent?: boolean;
54
+ asideBlur?: boolean;
55
+ headerBlur?: boolean;
56
+ containerBlur?: boolean;
54
57
  collapsedPosition?: Position;
58
+ avatarPosition?: AvatarPosition;
55
59
  userInfo?: UserInfo;
56
60
  brandInfo?: BrandInfo;
57
61
  }
58
62
  interface ThemeSkin {
59
63
  name: string;
60
- icon: string;
64
+ icon?: string;
61
65
  label?: string;
62
66
  theme: LayoutTheme[];
63
- themeType: SkinType;
67
+ skinType: SkinType;
68
+ backgroundContent?: React.ReactNode;
64
69
  asideWidth?: number;
65
70
  primaryColor?: string;
66
- asideCollapsedWidth?: number;
71
+ asideBlur?: boolean;
72
+ headerBlur?: boolean;
73
+ containerBlur?: boolean;
67
74
  layoutBorderColor?: string;
68
75
  headerStyle?: React.CSSProperties;
69
76
  asideStyle?: React.CSSProperties;
@@ -110,7 +117,7 @@ interface BaseLayoutProps extends LayoutProps {
110
117
  }
111
118
  interface RootLayoutProps<T> extends LayoutProps {
112
119
  layoutConfig?: LayoutConfig;
113
- menuData?: MenuData[];
120
+ menuData?: MenuData;
114
121
  theme?: Theme;
115
122
  locale?: string;
116
123
  localeMessages?: Record<string, T>;
@@ -131,32 +138,58 @@ declare function defineConfig(config: LayoutConfig): LayoutConfig;
131
138
  declare const LAYOUT_ASIDE_KEY: unique symbol;
132
139
  declare const LAYOUT_CONTENT_KEY: unique symbol;
133
140
  declare const LAYOUT_HEADER_KEY: unique symbol;
134
- declare const defaultSkinData: ThemeSkin;
141
+ declare const LAYOUT_BACKGROUND_KEY: unique symbol;
135
142
  declare const defaultConfig: LayoutConfig;
136
143
  declare const createConfigActionContext: () => react.Context<ConfigActionDispatcher>;
137
144
  declare const createConfigStateContext: () => react.Context<ConfigStateDispatcher>;
138
145
  declare const useConfigState: () => ConfigStateDispatcher;
139
146
  declare const useConfigAction: () => ConfigActionDispatcher;
140
- declare const useTheme: () => Theme;
147
+ declare const useTheme: () => Theme | undefined;
141
148
 
149
+ /**
150
+ * Header for layout
151
+ * @param props
152
+ * @returns
153
+ */
142
154
  declare function LayoutHeader(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
143
155
  declare namespace LayoutHeader {
144
156
  var displayName: string;
145
157
  var role: typeof LAYOUT_HEADER_KEY;
146
158
  }
147
159
 
160
+ /**
161
+ * Content for layout
162
+ * @param props
163
+ * @returns
164
+ */
148
165
  declare function LayoutContent(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
149
166
  declare namespace LayoutContent {
150
167
  var displayName: string;
151
168
  var role: typeof LAYOUT_CONTENT_KEY;
152
169
  }
153
170
 
171
+ /**
172
+ * Aside for layout
173
+ * @param props
174
+ * @returns
175
+ */
154
176
  declare function LayoutAside(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
155
177
  declare namespace LayoutAside {
156
178
  var displayName: string;
157
179
  var role: typeof LAYOUT_ASIDE_KEY;
158
180
  }
159
181
 
182
+ /**
183
+ * Background for layout
184
+ * @param props
185
+ * @returns
186
+ */
187
+ declare function LayoutBackground(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
188
+ declare namespace LayoutBackground {
189
+ var displayName: string;
190
+ var role: typeof LAYOUT_BACKGROUND_KEY;
191
+ }
192
+
160
193
  /**
161
194
  * Base layout
162
195
  * @param props layout properites
@@ -167,6 +200,7 @@ declare namespace BaseLayout {
167
200
  var Aside: typeof LayoutAside;
168
201
  var Content: typeof LayoutContent;
169
202
  var Header: typeof LayoutHeader;
203
+ var Background: typeof LayoutBackground;
170
204
  }
171
205
 
172
206
  /**
@@ -174,12 +208,10 @@ declare namespace BaseLayout {
174
208
  * @param props max and min button icon
175
209
  * @returns
176
210
  */
177
- declare function export_default$1(props: {
211
+ declare function export_default(props: {
178
212
  buttons: react__default.ReactElement[];
179
213
  }): react_jsx_runtime.JSX.Element;
180
214
 
181
- declare function export_default(): react_jsx_runtime.JSX.Element;
182
-
183
215
  declare function getAvatarInitials(name: string): string;
184
216
  declare const hexToRgb: (color: string) => {
185
217
  r: number;
@@ -189,5 +221,5 @@ declare const hexToRgb: (color: string) => {
189
221
  declare const hexToRgbaString: (color: string, alpha?: number) => string;
190
222
  declare const getLayoutTheme: (theme: Theme) => LayoutTheme;
191
223
 
192
- export { BaseLayout, export_default$1 as FullScreenButton, export_default as LayoutBackground, createConfigActionContext, createConfigStateContext, defaultConfig, defaultSkinData, defineConfig, getAvatarInitials, getLayoutTheme, hexToRgb, hexToRgbaString, useConfigAction, useConfigState, useTheme };
193
- export type { BaseLayoutProps, BrandInfo, ConfigActionDispatcher, ConfigStateDispatcher, ContainerMode, ContainerProps, ContainerStretch, Language, LayoutConfig, LayoutProps, LayoutTheme, LayoutType, LocaleMessageData, MenuData, OutletContainer, Position, RootLayoutProps, SkinType, Theme, ThemeSkin, UserInfo };
224
+ export { BaseLayout, export_default as FullScreenButton, LayoutBackground, createConfigActionContext, createConfigStateContext, defaultConfig, defineConfig, getAvatarInitials, getLayoutTheme, hexToRgb, hexToRgbaString, useConfigAction, useConfigState, useTheme };
225
+ export type { AvatarPosition, BaseLayoutProps, BrandInfo, ConfigActionDispatcher, ConfigStateDispatcher, ContainerMode, ContainerProps, ContainerStretch, Language, LayoutConfig, LayoutProps, LayoutTheme, LayoutType, LocaleMessageData, MenuData, OutletContainer, Position, RootLayoutProps, SkinType, Theme, ThemeSkin, UserInfo };
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{jsx as n,Fragment as e,jsxs as r}from"react/jsx-runtime";import t,{createContext as o,useContext as i,useState as l,useEffect as a}from"react";function d(n,e){void 0===e&&(e={});var r=e.insertAt;if(n&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var s="Layout-module_rootBackground__j3UVG";function u(){return n("div",{className:s})}function c(n){return n}d("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%;\r\n height:100%\r\n }\r\n #Layout-module_root__3x-pW { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.Layout-module_rootBox__3JHjy {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-width: 100%;\r\n}\r\n.Layout-module_rootBackground__j3UVG {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n overflow: hidden;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n height:100%;\r\n min-height: 100%;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.Layout-module_rootLayout__jVEEF {\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.Layout-module_mainLayout__6W9W9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n");const m=Symbol("LayoutAside"),h=Symbol("LayoutContent"),y=Symbol("LayoutHeader"),f={icon:"",name:"default",themeType:"tidy",theme:["light","dark"]},g={headerHeight:50,asideWidth:260,layoutType:"leftMenu",collapsedPosition:"bottom",theme:"system",primaryColor:"#417ffb",skinName:f.name},b=o({setTheme:()=>{},setLayoutConfig:()=>{},setLocale:()=>{}}),x=o({locale:"en-US",languages:[],theme:"system",layoutConfig:{},themeSkin:f,themeSkinMap:{tidy:[],rich:[]}}),p=()=>b,_=()=>x,w=()=>i(x),L=()=>i(b),v=()=>w().theme;function k(r){return n(e,{children:r.children})}function z(r){return n(e,{children:r.children})}function E(r){return n(e,{children:r.children})}k.displayName="LayoutContent",k.role=h,z.displayName="LayoutAside",z.role=m,E.displayName="LayoutHeader",E.role=y;var C="layout-module_rootBox__Y8bEx",N="layout-module_rootLayout__TePvr",T="layout-module_mainLayout__a8Tb9";function B(o){let i=null,l=null,a=null;return t.Children.forEach(o.children,n=>{const e=n.type.role;e===y?i=n:e===h?l=n:e===m&&(a=n)}),n(e,{children:r("div",{ref:o.ref,className:C,style:{...o.style},children:[n(u,{}),r("div",{className:N,children:[a,r("div",{className:T,children:[i,l]})]})]})})}function S(r){const o=!!document.fullscreenElement,[i,d]=l(o),s=()=>{d(!!document.fullscreenElement)},u=n=>{"F11"===n.code&&(n.preventDefault(),c())};a(()=>(document.addEventListener("fullscreenchange",s),document.addEventListener("keydown",u,!0),()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("keydown",u)}),[]);const c=()=>{i?document.exitFullscreen():document.documentElement.requestFullscreen()};if(!r.buttons||r.buttons.length<2)return n(e,{});const[m,h]=r.buttons,y=i?m:h;return t.cloneElement(y,{onClick:n=>{console.log(n),c()}})}function j(n){if(!n)return"";const e=Array.from(n);if(0===e.length)return"";const r=e[0];return function(n){if(0===n.length)return!1;const e=n.codePointAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=12352&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519||e>=126976&&e<=129791||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=129280&&e<=129535||e>=9728&&e<=9983||e>=9984&&e<=10175}(r)?r:e.slice(0,2).join("")}d("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%;\r\n height:100%\r\n }\r\n #layout-module_root__0efzq { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.layout-module_rootBox__Y8bEx {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-width: 100%;\r\n}\r\n.layout-module_rootBackground__vEs6e {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n overflow: hidden;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n height:100%;\r\n min-height: 100%;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.layout-module_rootLayout__TePvr {\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.layout-module_mainLayout__a8Tb9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n"),B.Aside=z,B.Content=k,B.Header=E;const A=n=>({r:parseInt(n.slice(1,3),16),g:parseInt(n.slice(3,5),16),b:parseInt(n.slice(5,7),16),a:9===n.length?(parseInt(n.slice(7,9),16)/255).toFixed(2):1}),F=n=>{const{r:e,g:r,b:t}=A(n);return{r:e,g:r,b:t}},H=(n,e)=>{const{r:r,g:t,b:o,a:i}=A(n);return`rgba(${r}, ${t}, ${o}, ${e??i})`},I=n=>{if("system"==n){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return n};export{B as BaseLayout,S as FullScreenButton,u as LayoutBackground,p as createConfigActionContext,_ as createConfigStateContext,g as defaultConfig,f as defaultSkinData,c as defineConfig,j as getAvatarInitials,I as getLayoutTheme,F as hexToRgb,H as hexToRgbaString,L as useConfigAction,w as useConfigState,v as useTheme};
1
+ import{jsx as n,Fragment as e,jsxs as r}from"react/jsx-runtime";import t,{createContext as o,useContext as i,useState as l,useEffect as d}from"react";function a(n,e){void 0===e&&(e={});var r=e.insertAt;if(n&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=n:o.appendChild(document.createTextNode(n))}}var s="Layout-module_rootBackground__j3UVG";function u(n){return n}a("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%; \r\n height: 100%;\r\n }\r\n #Layout-module_root__3x-pW { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.Layout-module_rootBox__3JHjy {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-height: 100%;\r\n}\r\n.Layout-module_rootBackground__j3UVG {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n width: 100%; \r\n min-width: 100vw;\r\n height:100%;\r\n min-height: 100vh;\r\n overflow: hidden;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.Layout-module_rootBackground__j3UVG>div{\r\n width:100%;\r\n height: 100%;\r\n overflow: hidden;\r\n}\r\n.Layout-module_rootLayout__jVEEF {\r\n position: relative;\r\n z-index: 1;\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.Layout-module_mainLayout__6W9W9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n");const c=Symbol("LayoutAside"),h=Symbol("LayoutContent"),m=Symbol("LayoutHeader"),y=Symbol("LayoutBackground"),g={headerHeight:50,asideWidth:260,layoutType:"leftMenu",collapsedPosition:"bottom",avatarPosition:"rightTop",theme:"system",primaryColor:"#417ffb"},f=o({setLayoutConfig:()=>{},setLocale:()=>{}}),b=o({locale:"en-US",languages:[],layoutConfig:{},themeSkinMap:{tidy:[],rich:[]}}),x=()=>f,_=()=>b,p=()=>i(b),v=()=>i(f),w=()=>p().layoutConfig.theme;function L(r){return n("div",{className:s,children:n(e,{children:r.children})})}function k(r){return n(e,{children:r.children})}function z(r){return n(e,{children:r.children})}function E(r){return n(e,{children:r.children})}L.displayName="LayoutBackground",L.role=y,k.displayName="LayoutContent",k.role=h,z.displayName="LayoutAside",z.role=c,E.displayName="LayoutHeader",E.role=m;var B="layout-module_rootBox__Y8bEx",C="layout-module_rootLayout__TePvr",N="layout-module_mainLayout__a8Tb9";function T(o){let i=null,l=null,d=null,a=null;return t.Children.forEach(o.children,n=>{const e=n.type.role;e===m?i=n:e===h?l=n:e===c?d=n:e===y&&(a=n)}),n(e,{children:r("div",{ref:o.ref,className:B,style:{...o.style},children:[a,r("div",{className:C,children:[d,r("div",{className:N,children:[i,l]})]})]})})}function S(r){const o=!!document.fullscreenElement,[i,a]=l(o),s=()=>{a(!!document.fullscreenElement)},u=n=>{"F11"===n.code&&(n.preventDefault(),c())};d(()=>(document.addEventListener("fullscreenchange",s),document.addEventListener("keydown",u,!0),()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("keydown",u)}),[]);const c=()=>{i?document.exitFullscreen():document.documentElement.requestFullscreen()};if(!r.buttons||r.buttons.length<2)return n(e,{});const[h,m]=r.buttons,y=i?h:m;return t.cloneElement(y,{onClick:n=>{console.log(n),c()}})}function j(n){if(!n)return"";const e=Array.from(n);if(0===e.length)return"";const r=e[0];return function(n){if(0===n.length)return!1;const e=n.codePointAt(0);return e>=19968&&e<=40959||e>=13312&&e<=19903||e>=12352&&e<=12543||e>=44032&&e<=55215||e>=65280&&e<=65519||e>=126976&&e<=129791||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=129280&&e<=129535||e>=9728&&e<=9983||e>=9984&&e<=10175}(r)?r:e.slice(0,2).join("")}a("@layer base {\r\n html, body {\r\n padding: 0;\r\n margin: 0;\r\n border: 0;\r\n width: 100%; \r\n height: 100%;\r\n }\r\n #layout-module_root__0efzq { \r\n text-align: initial;\r\n width: 100%;\r\n height:100%\r\n } \r\n}\r\n*, *:before, *:after {\r\n box-sizing: border-box;\r\n}\r\n.layout-module_rootBox__Y8bEx {\r\n text-rendering: optimizeLegibility;\r\n -webkit-font-smoothing: antialiased;\r\n -moz-osx-font-smoothing: grayscale;\r\n width: 100%;\r\n min-height: 100%;\r\n}\r\n.layout-module_rootBackground__vEs6e {\r\n box-sizing: border-box; \r\n pointer-events: none;\r\n inset-block-start:0;\r\n inset-inline-start:0; \r\n width: 100%; \r\n min-width: 100vw;\r\n height:100%;\r\n min-height: 100vh;\r\n overflow: hidden;\r\n position: fixed;\r\n z-index: 0;\r\n}\r\n.layout-module_rootBackground__vEs6e>div{\r\n width:100%;\r\n height: 100%;\r\n overflow: hidden;\r\n}\r\n.layout-module_rootLayout__TePvr {\r\n position: relative;\r\n z-index: 1;\r\n box-sizing: border-box; \r\n width: 100%;\r\n min-height: 100%;\r\n display: flex; \r\n flex-flow: row;\r\n background-color: transparent;\r\n container-type: inline-size;\r\n}\r\n\r\n.layout-module_mainLayout__a8Tb9 {\r\n box-sizing: border-box; \r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n}\r\n"),T.Aside=z,T.Content=k,T.Header=E,T.Background=L;const A=n=>({r:parseInt(n.slice(1,3),16),g:parseInt(n.slice(3,5),16),b:parseInt(n.slice(5,7),16),a:9===n.length?(parseInt(n.slice(7,9),16)/255).toFixed(2):1}),F=n=>{const{r:e,g:r,b:t}=A(n);return{r:e,g:r,b:t}},H=(n,e)=>{const{r:r,g:t,b:o,a:i}=A(n);return`rgba(${r}, ${t}, ${o}, ${e??i})`},P=n=>{if("system"==n){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return n};export{T as BaseLayout,S as FullScreenButton,L as LayoutBackground,x as createConfigActionContext,_ as createConfigStateContext,g as defaultConfig,u as defineConfig,j as getAvatarInitials,P as getLayoutTheme,F as hexToRgb,H as hexToRgbaString,v as useConfigAction,p as useConfigState,w as useTheme};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminui-dev/layout",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "adminui.dev's layout",
5
5
  "keywords": [
6
6
  "layout",
@@ -8,6 +8,7 @@
8
8
  "admin",
9
9
  "dashboard"
10
10
  ],
11
+
11
12
  "license": "MIT",
12
13
  "author": "zhouwenqi",
13
14
  "type": "commonjs",
@@ -30,6 +31,11 @@
30
31
  "files": [
31
32
  "dist"
32
33
  ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/zhouwenqi/adminui-layout.git"
37
+ },
38
+ "homepage": "https://demo.adminui.dev",
33
39
  "scripts": {
34
40
  "build": "rollup -c",
35
41
  "dev": "rollup -c -w",