@flatbiz/pro-layout 2.5.17
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/cjs/index.css +707 -0
- package/cjs/index.js +6 -0
- package/cjs/index.js.map +1 -0
- package/index.d.ts +323 -0
- package/index.js +4 -0
- package/package.json +56 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/// <reference types="prop-types" />
|
|
2
|
+
/// <reference types="scheduler" />
|
|
3
|
+
|
|
4
|
+
import { ButtonProps } from 'antd';
|
|
5
|
+
import { SizeType } from 'antd/lib/config-provider/SizeContext';
|
|
6
|
+
import { Locale } from 'antd/lib/locale-provider';
|
|
7
|
+
import { CSSProperties, ComponentType, FC, ReactElement } from 'react';
|
|
8
|
+
|
|
9
|
+
export interface AclProps {
|
|
10
|
+
/** 标识当前组件的唯一性 */
|
|
11
|
+
aclName: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const isElemVisible: (elemAclLimits: string[], aclName: string) => boolean;
|
|
14
|
+
export declare const Acl: FC<AclProps>;
|
|
15
|
+
export declare type BreadRoutePathFn = (data: BreadRouteMatchPath) => string;
|
|
16
|
+
export interface BreadRoute {
|
|
17
|
+
/**
|
|
18
|
+
* 当前面包屑UI显示名
|
|
19
|
+
*/
|
|
20
|
+
name: string | (() => string);
|
|
21
|
+
/**
|
|
22
|
+
* Path 匹配,字符串,匹配URL路径
|
|
23
|
+
*/
|
|
24
|
+
path: string;
|
|
25
|
+
/**
|
|
26
|
+
* 覆盖`path`如果存在,则点击跳转链接使用to, 通常情况 `path`匹配成功之后,可以指定对应的另外的 `to`来替换当前的`path`作为跳转链接.
|
|
27
|
+
* 支持函数(match)获取计算后的动态`path`
|
|
28
|
+
*/
|
|
29
|
+
to?: string | BreadRoutePathFn;
|
|
30
|
+
/**
|
|
31
|
+
* 保留的URL query参数. 默认保留 `env`
|
|
32
|
+
*/
|
|
33
|
+
query?: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare type BreadsData = AppBreads | ((data: BreadRouteMatchPath) => AppBreads);
|
|
36
|
+
export interface AppBreads {
|
|
37
|
+
[index: string]: BreadRoute[];
|
|
38
|
+
}
|
|
39
|
+
export declare type BreadRouteMatchPath = {
|
|
40
|
+
params: Readonly<Record<string, string | undefined>>;
|
|
41
|
+
search: URLSearchParams;
|
|
42
|
+
};
|
|
43
|
+
export interface ModuleMenu {
|
|
44
|
+
id: string | number;
|
|
45
|
+
name: string;
|
|
46
|
+
path?: string;
|
|
47
|
+
link: string | null;
|
|
48
|
+
sort?: number;
|
|
49
|
+
target?: "_blank" | "_self" | null;
|
|
50
|
+
metaTitle?: string;
|
|
51
|
+
/**
|
|
52
|
+
* iconImg&iconImgActive为自定义png图标
|
|
53
|
+
*/
|
|
54
|
+
iconImg?: string;
|
|
55
|
+
iconImgActive?: string;
|
|
56
|
+
routeBaseName?: string;
|
|
57
|
+
defaultPage?: string;
|
|
58
|
+
parentId: null | number | string;
|
|
59
|
+
children: ModuleMenu[];
|
|
60
|
+
}
|
|
61
|
+
export declare type GlobalData = {
|
|
62
|
+
appName?: string;
|
|
63
|
+
user: AdminUser;
|
|
64
|
+
menus: ModuleMenu[];
|
|
65
|
+
apiBase: string;
|
|
66
|
+
hostUrl: string;
|
|
67
|
+
defaultPage?: string;
|
|
68
|
+
routeBaseName: string;
|
|
69
|
+
elemAclLimits: string[];
|
|
70
|
+
};
|
|
71
|
+
export declare type AdminUser = null | {
|
|
72
|
+
id: string;
|
|
73
|
+
userName: string;
|
|
74
|
+
emailAddress: string;
|
|
75
|
+
};
|
|
76
|
+
export interface FallbackProps {
|
|
77
|
+
error: Error;
|
|
78
|
+
resetErrorBoundary: (...args: Array<unknown>) => void;
|
|
79
|
+
}
|
|
80
|
+
export declare type BootstrapOptions = {
|
|
81
|
+
/**
|
|
82
|
+
* 品牌logo尺寸:40px * ?(?不超过64)
|
|
83
|
+
*/
|
|
84
|
+
logoPath?: string;
|
|
85
|
+
/**
|
|
86
|
+
* 品牌名称
|
|
87
|
+
*/
|
|
88
|
+
brandName?: string | JSX.Element;
|
|
89
|
+
/**
|
|
90
|
+
* 是否隐藏头部,默认值false
|
|
91
|
+
*/
|
|
92
|
+
hideHeader?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* @default 220
|
|
95
|
+
*/
|
|
96
|
+
sidebarWidth?: number;
|
|
97
|
+
/**
|
|
98
|
+
* @default zhCN
|
|
99
|
+
*/
|
|
100
|
+
locale?: Locale;
|
|
101
|
+
/**
|
|
102
|
+
* 是否禁用顶部菜单
|
|
103
|
+
*/
|
|
104
|
+
disableTopbarMenu?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* ANTD 默认的组建尺寸
|
|
107
|
+
*/
|
|
108
|
+
componentSize?: SizeType;
|
|
109
|
+
/**
|
|
110
|
+
* 仅仅针对`LayoutFrame`有效
|
|
111
|
+
*/
|
|
112
|
+
multiFrameTabs?: boolean;
|
|
113
|
+
Footer?: (() => JSX.Element) | null;
|
|
114
|
+
Header?: (() => JSX.Element) | null;
|
|
115
|
+
HeaderBrand?: ((props: {
|
|
116
|
+
logoPath?: string;
|
|
117
|
+
}) => JSX.Element) | null;
|
|
118
|
+
LayoutComponent?: ComponentType<{
|
|
119
|
+
style?: CSSProperties;
|
|
120
|
+
}>;
|
|
121
|
+
ErrorFallback?: ComponentType<FallbackProps>;
|
|
122
|
+
/**
|
|
123
|
+
* 是否禁用全局异常处理
|
|
124
|
+
* 如果未设置ErrorHandling,则走默认ErrorHandling逻辑
|
|
125
|
+
*/
|
|
126
|
+
disableErrorHandling?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* 自定义ErrorHandling
|
|
129
|
+
*/
|
|
130
|
+
ErrorHandling?: (() => JSX.Element) | null;
|
|
131
|
+
onError?: (error: Error, info: {
|
|
132
|
+
componentStack: string;
|
|
133
|
+
}) => void;
|
|
134
|
+
onErrorReset?: (...args: any[]) => void;
|
|
135
|
+
onSignOut?: (user: AdminUser, hostUrl: string) => void;
|
|
136
|
+
AccountOperateMenus?: (() => JSX.Element) | null;
|
|
137
|
+
onSessionExpired: (user: AdminUser, hostUrl: string) => void;
|
|
138
|
+
verifySessionExpired: (err: any) => boolean;
|
|
139
|
+
/**
|
|
140
|
+
* 当sidebar菜单有level限制时,限制数目
|
|
141
|
+
*/
|
|
142
|
+
leaveMenuLevel?: number;
|
|
143
|
+
LeaveMenu?: ((props: LeaveMenuProps) => JSX.Element) | null;
|
|
144
|
+
/**
|
|
145
|
+
* 面包屑起始标题
|
|
146
|
+
*/
|
|
147
|
+
breadTitle?: string | JSX.Element;
|
|
148
|
+
/**
|
|
149
|
+
* 面包屑位置功能扩展
|
|
150
|
+
*/
|
|
151
|
+
breadExtendRender?: JSX.Element;
|
|
152
|
+
/**
|
|
153
|
+
* 隐藏默认设置的面包屑,默认值false
|
|
154
|
+
*/
|
|
155
|
+
hideDefaultBread?: boolean;
|
|
156
|
+
headerThemeConfig?: {
|
|
157
|
+
bgColor?: string;
|
|
158
|
+
activeBgColor?: string;
|
|
159
|
+
color?: string;
|
|
160
|
+
activeColor?: string;
|
|
161
|
+
};
|
|
162
|
+
sidebarThemeConfig?: {
|
|
163
|
+
bgColor?: string;
|
|
164
|
+
menuActiveBgColor?: string;
|
|
165
|
+
menuSelectedBgColor?: string;
|
|
166
|
+
color?: string;
|
|
167
|
+
activeColor?: string;
|
|
168
|
+
/**
|
|
169
|
+
* 默认值 16
|
|
170
|
+
*/
|
|
171
|
+
inlineIndent?: number;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* 设置iframe模式TabBarExtra
|
|
175
|
+
* ```
|
|
176
|
+
* 1. 赋值后,默认的刷新、删除Dropdown将被取消
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
iframeTabBarExtra?: JSX.Element;
|
|
180
|
+
/**
|
|
181
|
+
*是否显示顶部菜单中收缩按键
|
|
182
|
+
*/
|
|
183
|
+
showTopMenuShrink?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* 是否隐藏侧边栏中收缩按键
|
|
186
|
+
*/
|
|
187
|
+
hideSidebarShrink?: boolean;
|
|
188
|
+
};
|
|
189
|
+
export declare type LayoutCtxProps = {
|
|
190
|
+
breads: BreadsData;
|
|
191
|
+
sidebarWidth: number;
|
|
192
|
+
componentSize: SizeType;
|
|
193
|
+
locale: Locale;
|
|
194
|
+
routeConfig: RouteConfig;
|
|
195
|
+
} & Omit<BootstrapOptions, "sidebarWidth" | "componentSize" | "locale">;
|
|
196
|
+
export interface LeaveMenuProps {
|
|
197
|
+
leaveMenus?: ModuleMenu[];
|
|
198
|
+
selectedKeys?: string[];
|
|
199
|
+
}
|
|
200
|
+
export interface RouteItemProps {
|
|
201
|
+
path: string;
|
|
202
|
+
element: (props: any) => ReactElement | null;
|
|
203
|
+
redirect?: string | false;
|
|
204
|
+
caseSensitive?: boolean;
|
|
205
|
+
}
|
|
206
|
+
export interface ModuleItemProps {
|
|
207
|
+
path: string;
|
|
208
|
+
redirect: string | false;
|
|
209
|
+
/**
|
|
210
|
+
* allow use use lazy import(``) with webpack `webpackChunkName`
|
|
211
|
+
*/
|
|
212
|
+
module: ComponentType | null;
|
|
213
|
+
caseSensitive?: boolean;
|
|
214
|
+
}
|
|
215
|
+
export declare class RouteConfig {
|
|
216
|
+
private flattenTree;
|
|
217
|
+
private flattenTreePaths;
|
|
218
|
+
private modules;
|
|
219
|
+
private routeBaseName;
|
|
220
|
+
constructor(modules: ModuleItemProps[]);
|
|
221
|
+
findOneByBestMatchedRequestUrlPath(reqPath: string, ignorePath: string): string | undefined;
|
|
222
|
+
get routes(): RouteItemProps[];
|
|
223
|
+
}
|
|
224
|
+
export declare const bootstrap: (routeConfig: RouteConfig, breads: BreadsData, options: BootstrapOptions, callback?: () => void) => void;
|
|
225
|
+
export declare const Bread: FC;
|
|
226
|
+
export declare type HistoryBackProps = {
|
|
227
|
+
breads: BreadsData;
|
|
228
|
+
level?: number;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* 路由返回,依赖面包屑配置
|
|
232
|
+
* @param props
|
|
233
|
+
* @returns
|
|
234
|
+
* ```
|
|
235
|
+
* 1. breads 模块面包屑配置
|
|
236
|
+
* 2. level回退级别,如果传递数据未获取到路由配置,则取上一级
|
|
237
|
+
* 例如:-1,-2,-3
|
|
238
|
+
* 3. 为什么不能使用useNavigate(-1)
|
|
239
|
+
* 因为内部iframe和外部浏览器共用history历史记录,导致里外浏览器栈混乱
|
|
240
|
+
* 4. 什么场景使用
|
|
241
|
+
* 使用iframe tab的项目,在执行路由回退时使用
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export declare const HistoryBackButton: FC<HistoryBackProps & ButtonProps>;
|
|
245
|
+
export declare const useHistoryBack: (props: HistoryBackProps) => {
|
|
246
|
+
path: string;
|
|
247
|
+
};
|
|
248
|
+
export declare const LeaveMenuDefault: (props: LeaveMenuProps) => JSX.Element;
|
|
249
|
+
export declare type LoaderProps = {
|
|
250
|
+
spinning?: boolean;
|
|
251
|
+
fullScreen?: boolean;
|
|
252
|
+
style?: CSSProperties;
|
|
253
|
+
inner?: boolean;
|
|
254
|
+
};
|
|
255
|
+
export declare const Loader: FC<LoaderProps>;
|
|
256
|
+
export interface PageProps {
|
|
257
|
+
loading?: boolean;
|
|
258
|
+
className?: string;
|
|
259
|
+
style?: CSSProperties;
|
|
260
|
+
fullIndex?: number;
|
|
261
|
+
bread?: JSX.Element;
|
|
262
|
+
}
|
|
263
|
+
export declare const Page: FC<PageProps>;
|
|
264
|
+
export declare const layoutContext: {
|
|
265
|
+
useLayoutCtx: () => LayoutCtxProps;
|
|
266
|
+
};
|
|
267
|
+
export declare type UseBreadRoute = {
|
|
268
|
+
path: string;
|
|
269
|
+
name: string;
|
|
270
|
+
query: Record<string, string>;
|
|
271
|
+
};
|
|
272
|
+
export declare const useBread: (breads: BreadsData, routeBaseName: string) => UseBreadRoute[];
|
|
273
|
+
export declare type IframeHandler<T = unknown> = (data: T) => void;
|
|
274
|
+
/**
|
|
275
|
+
* 使用Iframe通讯的API
|
|
276
|
+
* @param onReceivedMessageCallback 接收iframe通讯消息的回调函数引用
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* const iframeApi = useIframe<MessageData>((data) => {
|
|
280
|
+
* console.log('onMainMessageReceived', data.name);
|
|
281
|
+
* updateMessage(data);
|
|
282
|
+
* });
|
|
283
|
+
*
|
|
284
|
+
* const handleClick = hooks.useCallbackRef(() => {
|
|
285
|
+
* iframeApi.broadcastMessages({
|
|
286
|
+
* fromHeader: '1',
|
|
287
|
+
* });
|
|
288
|
+
* });
|
|
289
|
+
*
|
|
290
|
+
* ```
|
|
291
|
+
* @returns
|
|
292
|
+
*/
|
|
293
|
+
export declare const useIframe: <T>(onReceivedMessageCallback?: IframeHandler<T>) => {
|
|
294
|
+
broadcastMessages<T_1>(data: T_1): any;
|
|
295
|
+
postMessage<T_2>(data: T_2): any;
|
|
296
|
+
openNewTabItem(data: {
|
|
297
|
+
link: string;
|
|
298
|
+
name: string;
|
|
299
|
+
metaTitle?: string | undefined;
|
|
300
|
+
}): any;
|
|
301
|
+
openBrowserWindow(url: string): any;
|
|
302
|
+
locationHref(url: string): any;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* 用来处理, 当前URL state动态改变的时候, 我们需要reload菜单, 因为URL状态 Browserhash状态更改可能通过代码动态触发
|
|
306
|
+
*/
|
|
307
|
+
export declare const useLayoutHistory: () => void;
|
|
308
|
+
export declare const useMobileDetect: () => boolean;
|
|
309
|
+
export declare const LayoutIFrame: FC;
|
|
310
|
+
export declare const LayoutNormal: FC;
|
|
311
|
+
export declare const LayoutPage: FC<{
|
|
312
|
+
style?: CSSProperties;
|
|
313
|
+
}>;
|
|
314
|
+
export declare const utils: {
|
|
315
|
+
ensureSlash: (str: string, slashEndfix?: boolean) => string;
|
|
316
|
+
isHttpUri: (uri?: string | undefined) => boolean;
|
|
317
|
+
toLinkPath: (path?: string | null | undefined, query?: Record<string, any>) => string;
|
|
318
|
+
toLinkPathWithQuery: (path?: string | null | undefined, query?: Record<string, any>) => string;
|
|
319
|
+
urlJoin: (first: string, second: string) => string;
|
|
320
|
+
menuRouteFilter: (routes: RouteItemProps[]) => RouteItemProps[];
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export {};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flatbiz/pro-layout",
|
|
3
|
+
"version": "2.5.17",
|
|
4
|
+
"description": "WEB菜单布局",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"typings": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"cjs/",
|
|
9
|
+
"index.js",
|
|
10
|
+
"index.d.ts",
|
|
11
|
+
"README.md",
|
|
12
|
+
"package.json"
|
|
13
|
+
],
|
|
14
|
+
"keywords": [
|
|
15
|
+
"flatjs",
|
|
16
|
+
"flatui",
|
|
17
|
+
"fabric",
|
|
18
|
+
"biz"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"author": "tcsk",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=13.8.0"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@better-scroll/mouse-wheel": "^2.4.2",
|
|
30
|
+
"@better-scroll/observe-dom": "^2.4.2",
|
|
31
|
+
"@better-scroll/scroll-bar": "^2.4.2",
|
|
32
|
+
"enquire.js": "^2.1.6"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@ant-design/icons": "^4.7.0",
|
|
36
|
+
"@dimjs/lang": "^1.2.19",
|
|
37
|
+
"@dimjs/model": "^1.1.7",
|
|
38
|
+
"@dimjs/model-react": "^1.1.7",
|
|
39
|
+
"@dimjs/utils": "^1.2.19",
|
|
40
|
+
"@wove/react": "^1.2.19"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@ant-design/icons": "^4.7.0",
|
|
44
|
+
"@dimjs/lang": "^1.2.19",
|
|
45
|
+
"@dimjs/model": "^1.1.7",
|
|
46
|
+
"@dimjs/model-react": "^1.1.7",
|
|
47
|
+
"@dimjs/utils": "^1.2.19",
|
|
48
|
+
"@wove/react": "^1.2.19",
|
|
49
|
+
"antd": "^4.22.2",
|
|
50
|
+
"react": "^17.0.2",
|
|
51
|
+
"react-dom": "^17.0.2",
|
|
52
|
+
"react-router": "^6.3.0",
|
|
53
|
+
"react-router-dom": "^6.3.0"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "77dd1b4aae77cf36421b42f069cb9bb833c694f8"
|
|
56
|
+
}
|