@adminui-dev/layout 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BaseLayout.d.ts +11 -0
- package/dist/components/FullScreenButton.d.ts +5 -0
- package/dist/components/LayoutAside.d.ts +2 -0
- package/dist/components/LayoutContent.d.ts +2 -0
- package/dist/components/LayoutContext.d.ts +12 -11
- package/dist/components/LayoutHeader.d.ts +2 -0
- package/dist/components/ThemeProvider.d.ts +1 -1
- package/dist/components/common.d.ts +16 -0
- package/dist/components/hook.d.ts +6 -0
- package/dist/components/index.d.ts +4 -3
- package/dist/components/layout.d.ts +9 -4
- package/dist/components/typings.d.ts +70 -12
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +126 -45
- package/dist/index.esm.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LayoutPros, LayoutConfig } from './typings';
|
|
2
|
+
/**
|
|
3
|
+
* Base layout
|
|
4
|
+
* @param props layout properites
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare function BaseLayout(props: LayoutPros): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function defineConfig(config: LayoutConfig): LayoutConfig;
|
|
9
|
+
declare const defaultConfig: LayoutConfig;
|
|
10
|
+
export { defineConfig, defaultConfig };
|
|
11
|
+
export default BaseLayout;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { LAYOUT_ASIDE_KEY } from "./LayoutContext";
|
|
1
2
|
declare function LayoutAside(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
2
3
|
declare namespace LayoutAside {
|
|
3
4
|
var displayName: string;
|
|
5
|
+
var role: typeof LAYOUT_ASIDE_KEY;
|
|
4
6
|
}
|
|
5
7
|
export default LayoutAside;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { LAYOUT_CONTENT_KEY } from './LayoutContext';
|
|
1
2
|
declare function LayoutContent(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
2
3
|
declare namespace LayoutContent {
|
|
3
4
|
var displayName: string;
|
|
5
|
+
var role: typeof LAYOUT_CONTENT_KEY;
|
|
4
6
|
}
|
|
5
7
|
export default LayoutContent;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
11
|
-
export
|
|
1
|
+
import type { LayoutConfig, ThemeSkin, ConfigActionDispatcher, ConfigStateDispatcher } from "./typings";
|
|
2
|
+
export declare function defineConfig(config: LayoutConfig): LayoutConfig;
|
|
3
|
+
export declare const LAYOUT_ASIDE_KEY: unique symbol;
|
|
4
|
+
export declare const LAYOUT_CONTENT_KEY: unique symbol;
|
|
5
|
+
export declare const LAYOUT_HEADER_KEY: unique symbol;
|
|
6
|
+
export declare const defaultSkinData: ThemeSkin;
|
|
7
|
+
export declare const defaultConfig: LayoutConfig;
|
|
8
|
+
export declare const createConfigActionContext: () => import("react").Context<ConfigActionDispatcher>;
|
|
9
|
+
export declare const createConfigStateContext: () => import("react").Context<ConfigStateDispatcher>;
|
|
10
|
+
export declare const useConfigState: () => ConfigStateDispatcher;
|
|
11
|
+
export declare const useConfigAction: () => ConfigActionDispatcher;
|
|
12
|
+
export declare const useTheme: () => import("./typings").Theme;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { LAYOUT_HEADER_KEY } from "./LayoutContext";
|
|
1
2
|
declare function LayoutHeader(props: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
|
|
2
3
|
declare namespace LayoutHeader {
|
|
3
4
|
var displayName: string;
|
|
5
|
+
var role: typeof LAYOUT_HEADER_KEY;
|
|
4
6
|
}
|
|
5
7
|
export default LayoutHeader;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LayoutTheme, Theme } from "./typings";
|
|
2
|
+
declare function getAvatarInitials(name: string): string;
|
|
3
|
+
declare const hexToRgba: (hex: string) => {
|
|
4
|
+
r: number;
|
|
5
|
+
g: number;
|
|
6
|
+
b: number;
|
|
7
|
+
a: string | number;
|
|
8
|
+
};
|
|
9
|
+
declare const hexToRgb: (color: string) => {
|
|
10
|
+
r: number;
|
|
11
|
+
g: number;
|
|
12
|
+
b: number;
|
|
13
|
+
};
|
|
14
|
+
declare const hexToRgbaString: (color: string, alpha?: number) => string;
|
|
15
|
+
declare const getLayoutTheme: (theme: Theme) => LayoutTheme;
|
|
16
|
+
export { getAvatarInitials, hexToRgb, hexToRgba, hexToRgbaString, getLayoutTheme };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BaseLayout } from "./Layout";
|
|
2
2
|
import FullScreenButton from "./FullScreenButton";
|
|
3
3
|
import LayoutBackground from "./LayoutBackground";
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { createConfigActionContext, createConfigStateContext, useConfigState, useConfigAction, useTheme, defaultConfig, defineConfig, defaultSkinData } from "./LayoutContext";
|
|
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 };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { BaseLayoutProps } from './typings';
|
|
2
|
+
/**
|
|
3
|
+
* Base layout
|
|
4
|
+
* @param props layout properites
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare function BaseLayout(props: BaseLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare namespace BaseLayout {
|
|
4
9
|
var Aside: typeof import("./LayoutAside").default;
|
|
5
10
|
var Content: typeof import("./LayoutContent").default;
|
|
6
11
|
var Header: typeof import("./LayoutHeader").default;
|
|
7
12
|
}
|
|
8
|
-
export
|
|
13
|
+
export { BaseLayout };
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
type Theme = 'light' | 'dark' | 'system';
|
|
2
2
|
type LayoutType = 'headMenu' | 'leftMenu';
|
|
3
|
-
type LayoutTheme = 'light' | 'dark'
|
|
3
|
+
type LayoutTheme = 'light' | 'dark';
|
|
4
4
|
type ContainerMode = 'inline' | 'box' | 'panel';
|
|
5
|
-
type ContainerStretch = 'inline' | 'auto' | '
|
|
5
|
+
type ContainerStretch = 'inline' | 'auto' | 'fill';
|
|
6
|
+
type SkinType = 'tidy' | 'rich';
|
|
7
|
+
type ConfigStateDispatcher = {
|
|
8
|
+
layoutConfig: LayoutConfig;
|
|
9
|
+
locale: string;
|
|
10
|
+
theme: Theme;
|
|
11
|
+
themeSkin: ThemeSkin;
|
|
12
|
+
themeSkinMap: Record<SkinType, ThemeSkin[]>;
|
|
13
|
+
languages: Language[];
|
|
14
|
+
};
|
|
15
|
+
type ConfigActionDispatcher = {
|
|
16
|
+
setTheme: (theme: Theme) => void;
|
|
17
|
+
setLocale: (locale: string) => void;
|
|
18
|
+
setLayoutConfig: (config: LayoutConfig) => void;
|
|
19
|
+
};
|
|
20
|
+
type OutletContainer = {
|
|
21
|
+
title: string;
|
|
22
|
+
breadcrumbData: any[];
|
|
23
|
+
footer?: React.ReactNode;
|
|
24
|
+
};
|
|
6
25
|
interface LayoutConfig {
|
|
7
26
|
layoutType?: LayoutType;
|
|
8
27
|
headerHeight?: number;
|
|
@@ -10,9 +29,35 @@ interface LayoutConfig {
|
|
|
10
29
|
asideCollapsedWidth?: number;
|
|
11
30
|
theme?: Theme;
|
|
12
31
|
locale?: string;
|
|
32
|
+
disabledLocale?: boolean;
|
|
33
|
+
skinName?: string;
|
|
34
|
+
primaryColor?: string;
|
|
35
|
+
highlight?: boolean;
|
|
36
|
+
flated?: boolean;
|
|
37
|
+
menuIconSize?: number;
|
|
38
|
+
compact?: boolean;
|
|
39
|
+
splitMenu?: boolean;
|
|
40
|
+
hideBorder?: boolean;
|
|
41
|
+
hideTitle?: boolean;
|
|
42
|
+
hideFooter?: boolean;
|
|
43
|
+
hideBreadcrumb?: boolean;
|
|
44
|
+
containerTransparent?: boolean;
|
|
13
45
|
userInfo?: UserInfo;
|
|
14
46
|
brandInfo?: BrandInfo;
|
|
15
47
|
}
|
|
48
|
+
interface ThemeSkin {
|
|
49
|
+
name: string;
|
|
50
|
+
icon: string;
|
|
51
|
+
label?: string;
|
|
52
|
+
theme: LayoutTheme[];
|
|
53
|
+
themeType: SkinType;
|
|
54
|
+
asideWidth?: number;
|
|
55
|
+
primaryColor?: string;
|
|
56
|
+
asideCollapsedWidth?: number;
|
|
57
|
+
layoutBorderColor?: string;
|
|
58
|
+
headerStyle?: React.CSSProperties;
|
|
59
|
+
asideStyle?: React.CSSProperties;
|
|
60
|
+
}
|
|
16
61
|
interface Language {
|
|
17
62
|
name: string;
|
|
18
63
|
locale: string;
|
|
@@ -36,18 +81,32 @@ interface BrandInfo {
|
|
|
36
81
|
title: string;
|
|
37
82
|
logo?: React.ReactNode;
|
|
38
83
|
}
|
|
39
|
-
|
|
40
|
-
|
|
84
|
+
interface MenuData {
|
|
85
|
+
id?: string;
|
|
86
|
+
name: string;
|
|
87
|
+
label?: string;
|
|
88
|
+
icon?: React.ReactNode;
|
|
89
|
+
path?: string;
|
|
90
|
+
extra?: React.ReactNode;
|
|
91
|
+
originalPath?: string;
|
|
92
|
+
params?: Record<string, string>;
|
|
93
|
+
children?: MenuData[];
|
|
94
|
+
}
|
|
95
|
+
interface LayoutProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
96
|
+
}
|
|
97
|
+
interface BaseLayoutProps extends LayoutProps {
|
|
98
|
+
headerHeight: number;
|
|
99
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
100
|
+
}
|
|
101
|
+
interface RootLayoutProps<T> extends LayoutProps {
|
|
41
102
|
layoutConfig?: LayoutConfig;
|
|
103
|
+
menuData?: MenuData[];
|
|
42
104
|
theme?: Theme;
|
|
43
105
|
locale?: string;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export interface MainLayoutProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
47
|
-
header?: React.ReactNode;
|
|
48
|
-
aside?: React.ReactNode;
|
|
106
|
+
localeMessages?: Record<string, T>;
|
|
107
|
+
themeSkins?: ThemeSkin[];
|
|
49
108
|
}
|
|
50
|
-
|
|
109
|
+
interface ContainerProps extends LayoutProps {
|
|
51
110
|
mode?: ContainerMode;
|
|
52
111
|
stretch?: ContainerStretch;
|
|
53
112
|
bordered?: boolean;
|
|
@@ -57,5 +116,4 @@ export interface ContainerProps {
|
|
|
57
116
|
transparent?: boolean;
|
|
58
117
|
children?: React.ReactNode;
|
|
59
118
|
}
|
|
60
|
-
export {
|
|
61
|
-
export type { Theme, LayoutTheme, LayoutType, LayoutConfig, Language, LocaleMessageData, UserInfo, BrandInfo };
|
|
119
|
+
export type { LayoutProps, BaseLayoutProps, RootLayoutProps, ContainerProps, ContainerMode, ContainerStretch, Theme, LayoutTheme, LayoutType, LayoutConfig, Language, LocaleMessageData, UserInfo, BrandInfo, ConfigStateDispatcher, ConfigActionDispatcher, SkinType, ThemeSkin, MenuData, OutletContainer };
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react");function n(e,r){void 0===r&&(r={});var n=r.insertAt;if(e&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&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",o="Layout-module_mainLayout__6W9W9";function i(){return e.jsx("div",{className:t,children:"55555"})}n('@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 overflow: hidden;\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.Layout-module_rootBox__3JHjy {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height:100%; \r\n text-align: initial; \r\n display: grid;\r\n grid-template-areas: "root";\r\n background-color: transparent;\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 width: 100%;\r\n z-index: 0;\r\n grid-area: root;\r\n}\r\n.Layout-module_rootLayout__jVEEF {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-area: root;\r\n grid-template-columns: auto 1fr;\r\n grid-template-rows: 50px 1fr; \r\n z-index: 1; \r\n overflow: auto;\r\n background-color: transparent; \r\n}\r\n.Layout-module_mainLayout__6W9W9 {\r\n box-sizing: border-box;\r\n grid-row: 2;\r\n grid-column: 2;\r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n height: 100%;\r\n min-height: 0;\r\n}\r\n');const a=Symbol("LayoutAside"),l=Symbol("LayoutContent"),d=Symbol("LayoutHeader"),s={icon:"",name:"default",themeType:"tidy",theme:["light","dark"]},u={headerHeight:50,asideCollapsedWidth:52,asideWidth:260,layoutType:"leftMenu",theme:"system",primaryColor:"#417ffb",skinName:s.name},c=r.createContext({setTheme:()=>{},setLayoutConfig:()=>{},setLocale:()=>{}}),h=r.createContext({locale:"en-US",languages:[],theme:"system",layoutConfig:{},themeSkin:s,themeSkinMap:{tidy:[],rich:[]}}),m=()=>r.useContext(h);function g(r){return e.jsx("div",{className:o,...r,children:r.children})}function x(r){return e.jsx(e.Fragment,{children:r.children})}function y(r){return e.jsx(e.Fragment,{children:r.children})}g.displayName="LayoutContent",g.role=l,x.displayName="LayoutAside",x.role=a,y.displayName="LayoutHeader",y.role=d;var f="layout-module_rootBox__Y8bEx",p="layout-module_rootLayout__TePvr";function b(n){let t=null,o=null,s=null;r.Children.forEach(n.children,e=>{const r=e.type.role;r===d?t=e:r===l?o=e:r===a&&(s=e)});const u={gridTemplateRows:`${n.headerHeight}px 1fr`};return e.jsx(e.Fragment,{children:e.jsxs("div",{ref:n.ref,className:f,style:{...n.style},children:[e.jsx(i,{}),e.jsxs("div",{className:p,style:u,children:[s,t,o]})]})})}n('@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 overflow: hidden;\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.layout-module_rootBox__Y8bEx {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height:100%; \r\n text-align: initial; \r\n display: grid;\r\n grid-template-areas: "root";\r\n background-color: transparent;\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 width: 100%;\r\n z-index: 0;\r\n grid-area: root;\r\n}\r\n.layout-module_rootLayout__TePvr {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-area: root;\r\n grid-template-columns: auto 1fr;\r\n grid-template-rows: 50px 1fr; \r\n z-index: 1; \r\n overflow: auto;\r\n background-color: transparent; \r\n}\r\n.layout-module_mainLayout__a8Tb9 {\r\n box-sizing: border-box;\r\n grid-row: 2;\r\n grid-column: 2;\r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n height: 100%;\r\n min-height: 0;\r\n}\r\n'),b.Aside=x,b.Content=g,b.Header=y;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=b,exports.FullScreenButton=function(n){const t=!!document.fullscreenElement,[o,i]=r.useState(t),a=()=>{i(!!document.fullscreenElement)},l=e=>{"F11"===e.code&&(e.preventDefault(),d())};r.useEffect(()=>(document.addEventListener("fullscreenchange",a),document.addEventListener("keydown",l,!0),()=>{document.removeEventListener("fullscreenchange",a),document.removeEventListener("keydown",l)}),[]);const d=()=>{o?document.exitFullscreen():document.documentElement.requestFullscreen()};if(!n.buttons||n.buttons.length<2)return e.jsx(e.Fragment,{});const[s,u]=n.buttons,c=o?s:u;return r.cloneElement(c,{onClick:e=>{console.log(e),d()}})},exports.LayoutBackground=i,exports.createConfigActionContext=()=>c,exports.createConfigStateContext=()=>h,exports.defaultConfig=u,exports.defaultSkinData=s,exports.defineConfig=function(e){return e},exports.getAvatarInitials=function(e){if(!e)return"";const r=Array.from(e);if(0===r.length)return"";const n=r[0];return function(e){if(0===e.length)return!1;const r=e.codePointAt(0);return r>=19968&&r<=40959||r>=13312&&r<=19903||r>=12352&&r<=12543||r>=44032&&r<=55215||r>=65280&&r<=65519||r>=126976&&r<=129791||r>=127744&&r<=128511||r>=128640&&r<=128767||r>=129280&&r<=129535||r>=9728&&r<=9983||r>=9984&&r<=10175}(n)?n:r.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:r,g:n,b:t}=_(e);return{r:r,g:n,b:t}},exports.hexToRgbaString=(e,r)=>{const{r:n,g:t,b:o,a:i}=_(e);return`rgba(${n}, ${t}, ${o}, ${r??i})`},exports.useConfigAction=()=>r.useContext(c),exports.useConfigState=m,exports.useTheme=()=>m().theme;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare function LayoutHeader(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
5
|
-
declare namespace LayoutHeader {
|
|
6
|
-
var displayName: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare function LayoutContent(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
10
|
-
declare namespace LayoutContent {
|
|
11
|
-
var displayName: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare function LayoutAside(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
15
|
-
declare namespace LayoutAside {
|
|
16
|
-
var displayName: string;
|
|
17
|
-
}
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import react__default from 'react';
|
|
18
4
|
|
|
19
5
|
type Theme = 'light' | 'dark' | 'system';
|
|
20
6
|
type LayoutType = 'headMenu' | 'leftMenu';
|
|
21
|
-
type LayoutTheme = 'light' | 'dark'
|
|
7
|
+
type LayoutTheme = 'light' | 'dark';
|
|
22
8
|
type ContainerMode = 'inline' | 'box' | 'panel';
|
|
23
|
-
type ContainerStretch = 'inline' | 'auto' | '
|
|
9
|
+
type ContainerStretch = 'inline' | 'auto' | 'fill';
|
|
10
|
+
type SkinType = 'tidy' | 'rich';
|
|
11
|
+
type ConfigStateDispatcher = {
|
|
12
|
+
layoutConfig: LayoutConfig;
|
|
13
|
+
locale: string;
|
|
14
|
+
theme: Theme;
|
|
15
|
+
themeSkin: ThemeSkin;
|
|
16
|
+
themeSkinMap: Record<SkinType, ThemeSkin[]>;
|
|
17
|
+
languages: Language[];
|
|
18
|
+
};
|
|
19
|
+
type ConfigActionDispatcher = {
|
|
20
|
+
setTheme: (theme: Theme) => void;
|
|
21
|
+
setLocale: (locale: string) => void;
|
|
22
|
+
setLayoutConfig: (config: LayoutConfig) => void;
|
|
23
|
+
};
|
|
24
|
+
type OutletContainer = {
|
|
25
|
+
title: string;
|
|
26
|
+
breadcrumbData: any[];
|
|
27
|
+
footer?: React.ReactNode;
|
|
28
|
+
};
|
|
24
29
|
interface LayoutConfig {
|
|
25
30
|
layoutType?: LayoutType;
|
|
26
31
|
headerHeight?: number;
|
|
@@ -28,9 +33,35 @@ interface LayoutConfig {
|
|
|
28
33
|
asideCollapsedWidth?: number;
|
|
29
34
|
theme?: Theme;
|
|
30
35
|
locale?: string;
|
|
36
|
+
disabledLocale?: boolean;
|
|
37
|
+
skinName?: string;
|
|
38
|
+
primaryColor?: string;
|
|
39
|
+
highlight?: boolean;
|
|
40
|
+
flated?: boolean;
|
|
41
|
+
menuIconSize?: number;
|
|
42
|
+
compact?: boolean;
|
|
43
|
+
splitMenu?: boolean;
|
|
44
|
+
hideBorder?: boolean;
|
|
45
|
+
hideTitle?: boolean;
|
|
46
|
+
hideFooter?: boolean;
|
|
47
|
+
hideBreadcrumb?: boolean;
|
|
48
|
+
containerTransparent?: boolean;
|
|
31
49
|
userInfo?: UserInfo;
|
|
32
50
|
brandInfo?: BrandInfo;
|
|
33
51
|
}
|
|
52
|
+
interface ThemeSkin {
|
|
53
|
+
name: string;
|
|
54
|
+
icon: string;
|
|
55
|
+
label?: string;
|
|
56
|
+
theme: LayoutTheme[];
|
|
57
|
+
themeType: SkinType;
|
|
58
|
+
asideWidth?: number;
|
|
59
|
+
primaryColor?: string;
|
|
60
|
+
asideCollapsedWidth?: number;
|
|
61
|
+
layoutBorderColor?: string;
|
|
62
|
+
headerStyle?: React.CSSProperties;
|
|
63
|
+
asideStyle?: React.CSSProperties;
|
|
64
|
+
}
|
|
34
65
|
interface Language {
|
|
35
66
|
name: string;
|
|
36
67
|
locale: string;
|
|
@@ -54,18 +85,32 @@ interface BrandInfo {
|
|
|
54
85
|
title: string;
|
|
55
86
|
logo?: React.ReactNode;
|
|
56
87
|
}
|
|
57
|
-
|
|
58
|
-
|
|
88
|
+
interface MenuData {
|
|
89
|
+
id?: string;
|
|
90
|
+
name: string;
|
|
91
|
+
label?: string;
|
|
92
|
+
icon?: React.ReactNode;
|
|
93
|
+
path?: string;
|
|
94
|
+
extra?: React.ReactNode;
|
|
95
|
+
originalPath?: string;
|
|
96
|
+
params?: Record<string, string>;
|
|
97
|
+
children?: MenuData[];
|
|
98
|
+
}
|
|
99
|
+
interface LayoutProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
100
|
+
}
|
|
101
|
+
interface BaseLayoutProps extends LayoutProps {
|
|
102
|
+
headerHeight: number;
|
|
103
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
104
|
+
}
|
|
105
|
+
interface RootLayoutProps<T> extends LayoutProps {
|
|
59
106
|
layoutConfig?: LayoutConfig;
|
|
107
|
+
menuData?: MenuData[];
|
|
60
108
|
theme?: Theme;
|
|
61
109
|
locale?: string;
|
|
62
|
-
|
|
110
|
+
localeMessages?: Record<string, T>;
|
|
111
|
+
themeSkins?: ThemeSkin[];
|
|
63
112
|
}
|
|
64
|
-
interface
|
|
65
|
-
header?: React.ReactNode;
|
|
66
|
-
aside?: React.ReactNode;
|
|
67
|
-
}
|
|
68
|
-
interface ContainerProps {
|
|
113
|
+
interface ContainerProps extends LayoutProps {
|
|
69
114
|
mode?: ContainerMode;
|
|
70
115
|
stretch?: ContainerStretch;
|
|
71
116
|
bordered?: boolean;
|
|
@@ -76,31 +121,67 @@ interface ContainerProps {
|
|
|
76
121
|
children?: React.ReactNode;
|
|
77
122
|
}
|
|
78
123
|
|
|
79
|
-
declare function
|
|
80
|
-
declare
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
124
|
+
declare function defineConfig(config: LayoutConfig): LayoutConfig;
|
|
125
|
+
declare const LAYOUT_ASIDE_KEY: unique symbol;
|
|
126
|
+
declare const LAYOUT_CONTENT_KEY: unique symbol;
|
|
127
|
+
declare const LAYOUT_HEADER_KEY: unique symbol;
|
|
128
|
+
declare const defaultSkinData: ThemeSkin;
|
|
129
|
+
declare const defaultConfig: LayoutConfig;
|
|
130
|
+
declare const createConfigActionContext: () => react.Context<ConfigActionDispatcher>;
|
|
131
|
+
declare const createConfigStateContext: () => react.Context<ConfigStateDispatcher>;
|
|
132
|
+
declare const useConfigState: () => ConfigStateDispatcher;
|
|
133
|
+
declare const useConfigAction: () => ConfigActionDispatcher;
|
|
134
|
+
declare const useTheme: () => Theme;
|
|
135
|
+
|
|
136
|
+
declare function LayoutHeader(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
137
|
+
declare namespace LayoutHeader {
|
|
138
|
+
var displayName: string;
|
|
139
|
+
var role: typeof LAYOUT_HEADER_KEY;
|
|
84
140
|
}
|
|
85
141
|
|
|
86
|
-
declare function
|
|
87
|
-
|
|
88
|
-
|
|
142
|
+
declare function LayoutContent(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
143
|
+
declare namespace LayoutContent {
|
|
144
|
+
var displayName: string;
|
|
145
|
+
var role: typeof LAYOUT_CONTENT_KEY;
|
|
146
|
+
}
|
|
89
147
|
|
|
90
|
-
declare function
|
|
148
|
+
declare function LayoutAside(props: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
|
|
149
|
+
declare namespace LayoutAside {
|
|
150
|
+
var displayName: string;
|
|
151
|
+
var role: typeof LAYOUT_ASIDE_KEY;
|
|
152
|
+
}
|
|
91
153
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Base layout
|
|
156
|
+
* @param props layout properites
|
|
157
|
+
* @returns
|
|
158
|
+
*/
|
|
159
|
+
declare function BaseLayout(props: BaseLayoutProps): react_jsx_runtime.JSX.Element;
|
|
160
|
+
declare namespace BaseLayout {
|
|
161
|
+
var Aside: typeof LayoutAside;
|
|
162
|
+
var Content: typeof LayoutContent;
|
|
163
|
+
var Header: typeof LayoutHeader;
|
|
97
164
|
}
|
|
165
|
+
|
|
98
166
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @param props
|
|
167
|
+
* full screen buttons
|
|
168
|
+
* @param props max and min button icon
|
|
101
169
|
* @returns
|
|
102
170
|
*/
|
|
103
|
-
declare function export_default(props:
|
|
171
|
+
declare function export_default$1(props: {
|
|
172
|
+
buttons: react__default.ReactElement[];
|
|
173
|
+
}): react_jsx_runtime.JSX.Element;
|
|
174
|
+
|
|
175
|
+
declare function export_default(): react_jsx_runtime.JSX.Element;
|
|
176
|
+
|
|
177
|
+
declare function getAvatarInitials(name: string): string;
|
|
178
|
+
declare const hexToRgb: (color: string) => {
|
|
179
|
+
r: number;
|
|
180
|
+
g: number;
|
|
181
|
+
b: number;
|
|
182
|
+
};
|
|
183
|
+
declare const hexToRgbaString: (color: string, alpha?: number) => string;
|
|
184
|
+
declare const getLayoutTheme: (theme: Theme) => LayoutTheme;
|
|
104
185
|
|
|
105
|
-
export { export_default$
|
|
106
|
-
export type { BrandInfo, ContainerProps, Language, LayoutConfig,
|
|
186
|
+
export { BaseLayout, export_default$1 as FullScreenButton, export_default as LayoutBackground, createConfigActionContext, createConfigStateContext, defaultConfig, defaultSkinData, defineConfig, getAvatarInitials, getLayoutTheme, hexToRgb, hexToRgbaString, useConfigAction, useConfigState, useTheme };
|
|
187
|
+
export type { BaseLayoutProps, BrandInfo, ConfigActionDispatcher, ConfigStateDispatcher, ContainerMode, ContainerProps, ContainerStretch, Language, LayoutConfig, LayoutProps, LayoutTheme, LayoutType, LocaleMessageData, MenuData, OutletContainer, RootLayoutProps, SkinType, Theme, ThemeSkin, UserInfo };
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r,Fragment as e,jsxs as n}from"react/jsx-runtime";import t,{createContext as o,useContext as i,useState as a,useEffect as d}from"react";function l(r,e){void 0===e&&(e={});var n=e.insertAt;if(r&&"undefined"!=typeof document){var t=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&t.firstChild?t.insertBefore(o,t.firstChild):t.appendChild(o),o.styleSheet?o.styleSheet.cssText=r:o.appendChild(document.createTextNode(r))}}var s="Layout-module_rootBackground__j3UVG",u="Layout-module_mainLayout__6W9W9";function c(){return r("div",{className:s,children:"55555"})}function h(r){return r}l('@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 overflow: hidden;\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.Layout-module_rootBox__3JHjy {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height:100%; \r\n text-align: initial; \r\n display: grid;\r\n grid-template-areas: "root";\r\n background-color: transparent;\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 width: 100%;\r\n z-index: 0;\r\n grid-area: root;\r\n}\r\n.Layout-module_rootLayout__jVEEF {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-area: root;\r\n grid-template-columns: auto 1fr;\r\n grid-template-rows: 50px 1fr; \r\n z-index: 1; \r\n overflow: auto;\r\n background-color: transparent; \r\n}\r\n.Layout-module_mainLayout__6W9W9 {\r\n box-sizing: border-box;\r\n grid-row: 2;\r\n grid-column: 2;\r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n height: 100%;\r\n min-height: 0;\r\n}\r\n');const m=Symbol("LayoutAside"),g=Symbol("LayoutContent"),y=Symbol("LayoutHeader"),f={icon:"",name:"default",themeType:"tidy",theme:["light","dark"]},b={headerHeight:50,asideCollapsedWidth:52,asideWidth:260,layoutType:"leftMenu",theme:"system",primaryColor:"#417ffb",skinName:f.name},p=o({setTheme:()=>{},setLayoutConfig:()=>{},setLocale:()=>{}}),x=o({locale:"en-US",languages:[],theme:"system",layoutConfig:{},themeSkin:f,themeSkinMap:{tidy:[],rich:[]}}),_=()=>p,w=()=>x,v=()=>i(x),L=()=>i(p),k=()=>v().theme;function E(e){return r("div",{className:u,...e,children:e.children})}function z(n){return r(e,{children:n.children})}function C(n){return r(e,{children:n.children})}E.displayName="LayoutContent",E.role=g,z.displayName="LayoutAside",z.role=m,C.displayName="LayoutHeader",C.role=y;var N="layout-module_rootBox__Y8bEx",T="layout-module_rootLayout__TePvr";function B(o){let i=null,a=null,d=null;t.Children.forEach(o.children,r=>{const e=r.type.role;e===y?i=r:e===g?a=r:e===m&&(d=r)});const l={gridTemplateRows:`${o.headerHeight}px 1fr`};return r(e,{children:n("div",{ref:o.ref,className:N,style:{...o.style},children:[r(c,{}),n("div",{className:T,style:l,children:[d,i,a]})]})})}function S(n){const o=!!document.fullscreenElement,[i,l]=a(o),s=()=>{l(!!document.fullscreenElement)},u=r=>{"F11"===r.code&&(r.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(!n.buttons||n.buttons.length<2)return r(e,{});const[h,m]=n.buttons,g=i?h:m;return t.cloneElement(g,{onClick:r=>{console.log(r),c()}})}function W(r){if(!r)return"";const e=Array.from(r);if(0===e.length)return"";const n=e[0];return function(r){if(0===r.length)return!1;const e=r.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}(n)?n:e.slice(0,2).join("")}l('@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 overflow: hidden;\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.layout-module_rootBox__Y8bEx {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height:100%; \r\n text-align: initial; \r\n display: grid;\r\n grid-template-areas: "root";\r\n background-color: transparent;\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 width: 100%;\r\n z-index: 0;\r\n grid-area: root;\r\n}\r\n.layout-module_rootLayout__TePvr {\r\n box-sizing: border-box; \r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-area: root;\r\n grid-template-columns: auto 1fr;\r\n grid-template-rows: 50px 1fr; \r\n z-index: 1; \r\n overflow: auto;\r\n background-color: transparent; \r\n}\r\n.layout-module_mainLayout__a8Tb9 {\r\n box-sizing: border-box;\r\n grid-row: 2;\r\n grid-column: 2;\r\n display: flex;\r\n flex-flow: column; \r\n width: 100%;\r\n height: 100%;\r\n min-height: 0;\r\n}\r\n'),B.Aside=z,B.Content=E,B.Header=C;const j=r=>({r:parseInt(r.slice(1,3),16),g:parseInt(r.slice(3,5),16),b:parseInt(r.slice(5,7),16),a:9===r.length?(parseInt(r.slice(7,9),16)/255).toFixed(2):1}),A=r=>{const{r:e,g:n,b:t}=j(r);return{r:e,g:n,b:t}},H=(r,e)=>{const{r:n,g:t,b:o,a:i}=j(r);return`rgba(${n}, ${t}, ${o}, ${e??i})`},F=r=>{if("system"==r){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}return r};export{B as BaseLayout,S as FullScreenButton,c as LayoutBackground,_ as createConfigActionContext,w as createConfigStateContext,b as defaultConfig,f as defaultSkinData,h as defineConfig,W as getAvatarInitials,F as getLayoutTheme,A as hexToRgb,H as hexToRgbaString,L as useConfigAction,v as useConfigState,k as useTheme};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminui-dev/layout",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "adminui.dev's layout",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layout",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
46
46
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
47
47
|
"@types/commander": "^2.12.5",
|
|
48
|
-
"@types/react": "^
|
|
49
|
-
"@types/react-dom": "^
|
|
48
|
+
"@types/react": "^19.2.0",
|
|
49
|
+
"@types/react-dom": "^19.2.0",
|
|
50
50
|
"postcss": "^8.5.6",
|
|
51
51
|
"postcss-modules": "^6.0.1",
|
|
52
52
|
"rollup": "^4.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"typescript": "^5.0.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"react": "
|
|
60
|
-
"react-dom": "
|
|
59
|
+
"react": ">=19.2.0",
|
|
60
|
+
"react-dom": ">=19.2.0"
|
|
61
61
|
}
|
|
62
62
|
}
|