@flatbiz/pro-layout 4.3.26 → 4.4.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/index.d.ts CHANGED
@@ -15,34 +15,6 @@ export interface FallbackProps {
15
15
  error: Error;
16
16
  resetErrorBoundary: (...args: Array<unknown>) => void;
17
17
  }
18
- export type BreadRouteMatchPath = {
19
- params: Readonly<Record<string, string | undefined>>;
20
- search: URLSearchParams;
21
- };
22
- export type BreadRoutePathFn = (data: BreadRouteMatchPath) => string;
23
- export interface BreadRoute {
24
- /**
25
- * 当前面包屑UI显示名
26
- */
27
- name: string | (() => string);
28
- /**
29
- * Path 匹配,字符串,匹配URL路径
30
- */
31
- path: string;
32
- /**
33
- * 覆盖`path`如果存在,则点击跳转链接使用to, 通常情况 `path`匹配成功之后,可以指定对应的另外的 `to`来替换当前的`path`作为跳转链接.
34
- * 支持函数(match)获取计算后的动态`path`
35
- */
36
- to?: string | BreadRoutePathFn;
37
- /**
38
- * 保留的URL query参数. 默认保留 `env`
39
- */
40
- query?: string[];
41
- }
42
- export type BreadsData = AppBreads | ((data: BreadRouteMatchPath) => AppBreads);
43
- export interface AppBreads {
44
- [index: string]: BreadRoute[];
45
- }
46
18
  export type TMenuItem = {
47
19
  id: string | number;
48
20
  name: string;
@@ -93,54 +65,67 @@ export type IframeTabItem = {
93
65
  menuId?: string;
94
66
  pathSearch: string;
95
67
  };
68
+ export type BreadRouteMatchPath = {
69
+ params: Readonly<Record<string, string | undefined>>;
70
+ search: URLSearchParams;
71
+ };
72
+ export type BreadRoutePathFn = (data: BreadRouteMatchPath) => string;
73
+ export type RouteBreadConfigData = {
74
+ /**
75
+ * 当前面包屑UI显示名
76
+ */
77
+ name: string | (() => string);
78
+ /**
79
+ * 覆盖`path`如果存在,则点击跳转链接使用to, 通常情况 `path`匹配成功之后,可以指定对应的另外的 `to`来替换当前的`path`作为跳转链接.
80
+ * 支持函数(match)获取计算后的动态`path`
81
+ */
82
+ to?: string | BreadRoutePathFn;
83
+ /**
84
+ * 保留的URL query参数. 默认保留 `env`
85
+ */
86
+ query?: string[];
87
+ };
88
+ export type RouteBreadConfig = RouteBreadConfigData | ((data: BreadRouteMatchPath) => RouteBreadConfigData);
89
+ export type BreadConfigItem = {
90
+ path: string;
91
+ breadConfig: RouteBreadConfig;
92
+ };
93
+ export type BreadDataItem = RouteBreadConfigData & {
94
+ path: string;
95
+ };
96
96
  export interface TRouteItemProps {
97
97
  path: string;
98
98
  element: ReactElement | ComponentType | null;
99
99
  redirect?: string;
100
100
  caseSensitive?: boolean;
101
+ /** 面包屑配置 */
102
+ breadConfig?: string | RouteBreadConfig;
101
103
  }
102
104
  export type BootstrapOptions = {
103
105
  /**
104
106
  * ```
105
107
  * 1. 正常用法
106
108
  * [{
107
- * path: '/module/page',
108
- * element: <Text />
109
+ * path: '/',
110
+ * element: <Home />
109
111
  * },{
110
- * path: '*',
111
- * redirect: '/module/page'
112
+ * path: '/detail',
113
+ * element: <Detail />
112
114
  * }]
113
115
  *
114
116
  * 2. 懒加载用法
115
117
  * [{
116
- * path: '/module/page',
117
- * element: lazy(() => import(\/* webpackChunkName: "xxx/xxx/module/chunks/page" *\/ './page')),
118
+ * path: '/',
119
+ * element: lazy(() => import(\/* webpackChunkName: "xxx/xxx/module/chunks/home" *\/ './home')),
118
120
  * },{
119
- * path: '*',
120
- * redirect: '/module/page'
121
+ * path: '/detail',
122
+ * element: lazy(() => import(\/* webpackChunkName: "xxx/xxx/module/chunks/detail" *\/ './detail')),
121
123
  * }]
122
124
  *
123
125
  * 3. 如果配置中 没有path = '*',程序会在路由中添加 <Route path="*" element={<NotFound />} />
124
126
  * ```
125
127
  */
126
128
  routeList: TRouteItemProps[];
127
- /**
128
- * 面包屑配置
129
- * ```
130
- * 例如:
131
- * 模块地址:a/b
132
- * export const breadConfig: Record<string, BreadRoute[]> = {
133
- * 'a/b': [
134
- * { name: 'HOME', path: '', to: '' },
135
- * { name: 'DETAIL', path: 'detail', to: '' },
136
- * { name: 'LIST', path: ':id/list', to: '' },
137
- * ],
138
- * };
139
- * 注意:
140
- * 1. 当路由中存在动态变量时,配置在动态面包屑中动态变量必须与动态路由中的变量相同
141
- * ```
142
- */
143
- breads?: BreadsData;
144
129
  /**
145
130
  * layout模式
146
131
  * ```
@@ -204,7 +189,6 @@ export type BootstrapOptions = {
204
189
  * ANTD 默认的组建尺寸
205
190
  */
206
191
  componentSize?: SizeType;
207
- Footer?: (() => JSX.Element) | null;
208
192
  Header?: (() => JSX.Element) | null;
209
193
  HeaderBrand?: (() => JSX.Element) | null;
210
194
  /**
@@ -303,14 +287,29 @@ export type BootstrapOptions = {
303
287
  * iframe tab 点击刷新效果,默认:true
304
288
  */
305
289
  iframeTabClickRefresh?: boolean;
306
- /** 隐藏侧边栏菜单 */
307
- hideSidebarMenu?: boolean;
290
+ /**
291
+ * 能匹配到菜单的情况下,是否隐藏菜单,值请使用函数方式
292
+ * ```
293
+ * 1. disableTopbarMenu = true,改配置无效(无顶部菜单,侧边栏菜单不能隐藏)
294
+ * 2. 不能通过这个属性来控制【未配置到菜单隐藏侧边栏逻辑】
295
+ *
296
+ * 注意:隐藏侧边栏分为两种
297
+ * 1. 能匹配到菜单的情况下,需要隐藏菜单
298
+ * 2. 匹配不到菜单的情况下,隐藏
299
+ * ```
300
+ */
301
+ hideSidebarMenu?: boolean | (() => boolean);
302
+ /**
303
+ * 未配置到菜单情况下,是否隐藏侧边栏开关, 默认值 true/隐藏
304
+ * ```
305
+ * disableTopbarMenu = true,改配置无效(无顶部菜单,侧边栏菜单不能隐藏)
306
+ * ```
307
+ */
308
+ unMatchHiddenSiderBar?: boolean;
308
309
  /** 收缩后侧边栏宽度,默认:80 */
309
310
  collapsedWidth?: number;
310
311
  /** 菜单为空渲染,默认:请联系运营人员确定菜单数据配置 */
311
312
  MenuEmptyRender?: ReactElement;
312
- /** disableTopbarMenu != true模式下,未配置到菜单,隐藏侧边栏,默认值:true */
313
- unMatchHiddenSiderBar?: boolean;
314
313
  /** 侧边栏是否显示搜索框 */
315
314
  sliderBarSearch?: boolean;
316
315
  /** iframeTab 页面可独立访问 */
@@ -345,7 +344,7 @@ export type LayoutCtxProps = {
345
344
  sidebarWidth: number;
346
345
  componentSize: SizeType;
347
346
  routeList: TRouteItemProps[];
348
- breads: BreadsData;
347
+ breads: BreadConfigItem[];
349
348
  collapsed: boolean;
350
349
  onChangeCollapsed: (boo: boolean) => void;
351
350
  selectedKeys: string[];
@@ -362,7 +361,8 @@ export type LayoutCtxProps = {
362
361
  onUpdateIframeTabName: (name: string) => void;
363
362
  normalModePositionMenu: (link: string) => void;
364
363
  iframeTopRouteMenuChange: (item: TMenuItem) => void;
365
- } & Omit<BootstrapOptions, "sidebarWidth" | "componentSize" | "locale">;
364
+ hideSidebarMenu?: boolean;
365
+ } & Omit<BootstrapOptions, "sidebarWidth" | "componentSize" | "locale" | "hideSidebarMenu">;
366
366
  export interface LeaveMenuProps {
367
367
  leaveMenus?: TMenuItem[];
368
368
  selectedKeys?: string[];
@@ -376,11 +376,10 @@ export type BreadProps = {
376
376
  };
377
377
  export declare const Bread: (props: BreadProps) => import("react/jsx-runtime").JSX.Element | null;
378
378
  export type HistoryBackProps = ButtonWrapperProps & {
379
- breads: BreadsData;
380
379
  level?: number;
381
380
  };
382
381
  /**
383
- * 路由返回,依赖面包屑配置
382
+ * 通过面包屑路径返回
384
383
  * @param props
385
384
  * @returns
386
385
  * ```
@@ -395,7 +394,9 @@ export type HistoryBackProps = ButtonWrapperProps & {
395
394
  * ```
396
395
  */
397
396
  export declare const HistoryBackButton: (props: HistoryBackProps) => import("react/jsx-runtime").JSX.Element;
398
- export declare const useHistoryBack: (props: HistoryBackProps) => {
397
+ export declare const useHistoryBack: (props?: {
398
+ level?: number;
399
+ }) => {
399
400
  path: string;
400
401
  };
401
402
  export interface PageProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatbiz/pro-layout",
3
- "version": "4.3.26",
3
+ "version": "4.4.0",
4
4
  "description": "WEB菜单布局",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",