@zk-tech/base-ui-configuration-service 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.cjs +984 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +15 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +471 -0
- package/dist/index.d.ts +471 -0
- package/dist/index.js +937 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import { Disposable } from '@zk-tech/bedrock/dispose';
|
|
2
|
+
import { IContainerService } from '@zk-tech/bedrock/di';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default, { ReactElement, FunctionComponent, Component, ErrorInfo } from 'react';
|
|
5
|
+
import * as _zk_tech_bedrock_event from '@zk-tech/bedrock/event';
|
|
6
|
+
import { Event } from '@zk-tech/bedrock/event';
|
|
7
|
+
import { NavigateOptions, NavigateFunction } from 'react-router-dom';
|
|
8
|
+
export { Navigate, NavigateOptions, matchPath, parsePath, resolvePath, useLocation, useSearchParams } from 'react-router-dom';
|
|
9
|
+
import { LvErrorRef } from '@zk-tech/bedrock/error';
|
|
10
|
+
|
|
11
|
+
type IUiManagerSymbol = string;
|
|
12
|
+
/** 配置相关内容 */
|
|
13
|
+
interface IBaseUiManager<T extends Record<string, any>> {
|
|
14
|
+
registerConfig: (configs: T[]) => void;
|
|
15
|
+
unRegisterConfig: (id: string) => void;
|
|
16
|
+
render: (...params: any) => React__default.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 全局配置项
|
|
21
|
+
*/
|
|
22
|
+
interface IBaseSetting {
|
|
23
|
+
/**
|
|
24
|
+
* workbench 命名空间(log 会进行区分)
|
|
25
|
+
*/
|
|
26
|
+
namespace: string;
|
|
27
|
+
/**
|
|
28
|
+
* 是否开启调试模式,开启后将为每个 ActionPoint 打印调用信息
|
|
29
|
+
*/
|
|
30
|
+
debugMode: boolean;
|
|
31
|
+
/** 控制服务的显隐规则, 默认展示。如果有特殊隐藏诉求可以传递覆盖 */
|
|
32
|
+
visible: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type IActionPointInfo = IUseMiddlewareOptions<any, any>['actionInfo'];
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
declare class ActionPointRunner<T> extends Function {
|
|
40
|
+
private readonly middlewares;
|
|
41
|
+
private readonly point;
|
|
42
|
+
private readonly _uiConfig;
|
|
43
|
+
private _rawArguments;
|
|
44
|
+
constructor(middlewares: ((...args: any[]) => any)[], point: IActionPointInfo, _uiConfig: T);
|
|
45
|
+
get isStop(): boolean;
|
|
46
|
+
private _isStop;
|
|
47
|
+
private index;
|
|
48
|
+
run(...args: unknown[]): any;
|
|
49
|
+
hasNext(): boolean;
|
|
50
|
+
private getNext;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Extract Function Type From Union Type T
|
|
55
|
+
*/
|
|
56
|
+
type ExtractFunction<T extends Function | any> = Extract<T, Function>;
|
|
57
|
+
/**
|
|
58
|
+
* extract function property names from type T as an union type
|
|
59
|
+
*/
|
|
60
|
+
type FunctionPropertyNames<T> = Required<{
|
|
61
|
+
[K in keyof T]: ExtractFunction<T[K]> extends never ? never : K;
|
|
62
|
+
}>[keyof T];
|
|
63
|
+
type IUseMiddlewareOptions<UIManagerSymbol extends IUiManagerSymbol, MixinConfig extends Record<UIManagerSymbol, any[]>> = {
|
|
64
|
+
/**
|
|
65
|
+
* 禁止 handler 往下继续传递
|
|
66
|
+
* 如果想在中间件运行后确定返回值,则可以通过调用该函数跳过后续中间件的运行
|
|
67
|
+
*/
|
|
68
|
+
stop: () => void;
|
|
69
|
+
actionInfo: {
|
|
70
|
+
/**
|
|
71
|
+
* 操作来源,通常为 Menu、Toolbar 等 UI 服务
|
|
72
|
+
*/
|
|
73
|
+
from: UIManagerSymbol;
|
|
74
|
+
/**
|
|
75
|
+
* 操作对应配置名称
|
|
76
|
+
*/
|
|
77
|
+
name: string;
|
|
78
|
+
/** 劫持的 action method */
|
|
79
|
+
trigger: string;
|
|
80
|
+
};
|
|
81
|
+
uiConfig: MixinConfig[UIManagerSymbol];
|
|
82
|
+
/** handler 自定义的参数内容 */
|
|
83
|
+
triggerArgs: any;
|
|
84
|
+
};
|
|
85
|
+
type IUseMiddlewareProps<UIManagerSymbol extends IUiManagerSymbol, MixinConfig extends Record<UIManagerSymbol, any[]>> = {
|
|
86
|
+
[T in UIManagerSymbol]: {
|
|
87
|
+
/** middleware 的规划 */
|
|
88
|
+
id: string;
|
|
89
|
+
/** 需要劫持的 UI Service */
|
|
90
|
+
trigger: T;
|
|
91
|
+
/** 需要劫持的方法 */
|
|
92
|
+
triggerMethod: FunctionPropertyNames<MixinConfig[T][number]>[];
|
|
93
|
+
handler: (options: IUseMiddlewareOptions<T, MixinConfig>) => any;
|
|
94
|
+
/**
|
|
95
|
+
* 中间件注册后需要有时机来 trigger 页面重渲.
|
|
96
|
+
* 中间件注册后会监听这个事件做 UI 的刷新渲染.
|
|
97
|
+
* */
|
|
98
|
+
freshTrigger: Event<[]>;
|
|
99
|
+
};
|
|
100
|
+
}[UIManagerSymbol];
|
|
101
|
+
type IBuildRunnerProps<UIManagerSymbol extends IUiManagerSymbol, MixinConfig extends Record<UIManagerSymbol, any[]>> = {
|
|
102
|
+
trigger: UIManagerSymbol;
|
|
103
|
+
method: string | number | symbol;
|
|
104
|
+
handler?: (...args: any[]) => any;
|
|
105
|
+
uiConfig: MixinConfig[UIManagerSymbol];
|
|
106
|
+
};
|
|
107
|
+
type IMiddlewareChange<UIManagerSymbol extends IUiManagerSymbol> = {
|
|
108
|
+
trigger: UIManagerSymbol;
|
|
109
|
+
method: string[];
|
|
110
|
+
};
|
|
111
|
+
interface IMiddlewareManager<UIManagerSymbol extends IUiManagerSymbol, MixinConfig extends Record<UIManagerSymbol, any[]>> {
|
|
112
|
+
onMiddlewareChange: Event<[IMiddlewareChange<UIManagerSymbol>]>;
|
|
113
|
+
buildRunner: (options: IBuildRunnerProps<UIManagerSymbol, MixinConfig>) => ActionPointRunner<MixinConfig[UIManagerSymbol]>;
|
|
114
|
+
/** 注册中间件能力 */
|
|
115
|
+
use: (props: IUseMiddlewareProps<UIManagerSymbol, MixinConfig>) => void;
|
|
116
|
+
/** 取消中间件的注册 */
|
|
117
|
+
unUse: (id: string) => void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare abstract class BaseUiConfigurationService<ISetting extends IBaseSetting, UIManagerSymbol extends IUiManagerSymbol, MixinConfig extends Record<UIManagerSymbol, any[]>, ISymbolAllManager extends Record<UIManagerSymbol, IBaseUiManager<any>>> extends Disposable {
|
|
121
|
+
private readonly _setting;
|
|
122
|
+
protected readonly _containerService: IContainerService;
|
|
123
|
+
readonly _serviceBrand: undefined;
|
|
124
|
+
get setting(): ISetting;
|
|
125
|
+
middleware: IMiddlewareManager<UIManagerSymbol, MixinConfig>;
|
|
126
|
+
abstract uiManager: ISymbolAllManager;
|
|
127
|
+
constructor(_setting: ISetting, _containerService: IContainerService);
|
|
128
|
+
abstract render(): React.ReactNode;
|
|
129
|
+
protected abstract _initAllManager(): void;
|
|
130
|
+
registerConfig(config: Partial<MixinConfig>): void;
|
|
131
|
+
useMiddleware(props: IUseMiddlewareProps<UIManagerSymbol, MixinConfig>): void;
|
|
132
|
+
protected _bootstrap(): void;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
declare abstract class BaseSetting<T extends IBaseSetting> {
|
|
136
|
+
observableData: T;
|
|
137
|
+
constructor(options: {
|
|
138
|
+
setting: Partial<T>;
|
|
139
|
+
});
|
|
140
|
+
get namespace(): string;
|
|
141
|
+
get debugMode(): boolean;
|
|
142
|
+
get visible(): boolean;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
type IContext<T extends BaseUiConfigurationService<any, any, any, any>> = {
|
|
146
|
+
uiConfigurationService: T;
|
|
147
|
+
};
|
|
148
|
+
declare const GlobalContext: React$1.Context<any>;
|
|
149
|
+
|
|
150
|
+
declare abstract class BaseUiManager<TConfigSymbol extends IUiManagerSymbol, TConfig extends Record<string, any>> implements IBaseUiManager<TConfig> {
|
|
151
|
+
protected readonly _middlewareManager: IMiddlewareManager<TConfigSymbol, any>;
|
|
152
|
+
constructor(_middlewareManager: IMiddlewareManager<TConfigSymbol, any>);
|
|
153
|
+
abstract registerConfig(configs: TConfig[]): void;
|
|
154
|
+
unRegisterConfig(id: string): void;
|
|
155
|
+
abstract render(...params: any[]): React.ReactNode;
|
|
156
|
+
abstract _middlewareChange(props: IMiddlewareChange<TConfigSymbol>): void;
|
|
157
|
+
private _listenerMiddlewareChange;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
declare class MiddlewareManager implements IMiddlewareManager<any, any> {
|
|
161
|
+
private readonly _registerById;
|
|
162
|
+
/** caller <-> middleware handler 的映射表 */
|
|
163
|
+
private readonly _registerByCaller;
|
|
164
|
+
private readonly _onMiddlewareChange;
|
|
165
|
+
private readonly _disposeMap;
|
|
166
|
+
onMiddlewareChange: Event<[IMiddlewareChange<any>]>;
|
|
167
|
+
buildRunner(options: IBuildRunnerProps<any, any>): ActionPointRunner<any>;
|
|
168
|
+
use<T>(props: IUseMiddlewareProps<any, any>): void;
|
|
169
|
+
unUse(id: string): void;
|
|
170
|
+
private _getCaller;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare enum OrderLevel {
|
|
174
|
+
high = "high",
|
|
175
|
+
default = "default",
|
|
176
|
+
low = "low"
|
|
177
|
+
}
|
|
178
|
+
interface IOrderType {
|
|
179
|
+
/**
|
|
180
|
+
* 在 order 之上的排序规则
|
|
181
|
+
* 严格按照:high > default > low 顺序排序
|
|
182
|
+
* */
|
|
183
|
+
orderLevel?: OrderLevel;
|
|
184
|
+
/** 排序设置,默认为 0 */
|
|
185
|
+
order?: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* 通用的排序函数,主要分作两类排序规则
|
|
189
|
+
* 优先使用 orderLevel 分组,后使用 order 排序
|
|
190
|
+
* 主要为了处理一些希望固定展示头部和底部的场景,而出现 order 争抢的 case
|
|
191
|
+
*/
|
|
192
|
+
declare function sortListBySettings<T extends IOrderType>({ list, filter, }: {
|
|
193
|
+
list: Array<T>;
|
|
194
|
+
filter?: (item: T) => T;
|
|
195
|
+
}): Array<T>;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @description 将传入的UI配置数组,通过打平整合到一个对象中
|
|
199
|
+
* @example
|
|
200
|
+
* input: [{ pageRoute: [xxx] }, {pageRoute: [xxx2]}]
|
|
201
|
+
* output: { pageRoute: [xxx, xxx2] }
|
|
202
|
+
*/
|
|
203
|
+
declare const mergeUiConfigs: <T extends Record<string, Array<any>>>(configs: Array<Partial<T>>) => Partial<T>;
|
|
204
|
+
|
|
205
|
+
declare function runnerBuilder({ middleware, trigger, method, handler, uiConfig, }: {
|
|
206
|
+
middleware: IMiddlewareManager<any, any>;
|
|
207
|
+
trigger: IUiManagerSymbol;
|
|
208
|
+
method: string;
|
|
209
|
+
handler?: (...args: any[]) => any;
|
|
210
|
+
uiConfig: any;
|
|
211
|
+
}): ActionPointRunner<any>;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 用于带默认值执行 config 的回调方法
|
|
215
|
+
* @param config - config 的回调
|
|
216
|
+
* @param defaultValue - 默认值
|
|
217
|
+
* @param args - 参数
|
|
218
|
+
* @internal
|
|
219
|
+
* @privateRemarks
|
|
220
|
+
* config类型改成 T | ((...params: any[]) =\> T),ts认为不一定是callable
|
|
221
|
+
* https://github.com/microsoft/TypeScript/issues/37663
|
|
222
|
+
* 我们需要这个函数能成功的类型推断T
|
|
223
|
+
* 但是config设成any可能会产生错误,这里的类型推断只能由config产生
|
|
224
|
+
* 例如 evaluate\<TooltipConfig| string | undefined\>(tooltipConfig, undefined);
|
|
225
|
+
* 为什么写<T>是因为defaultValue是undefined
|
|
226
|
+
* 所以当T没有写,就会错误的由defaultValue推断T
|
|
227
|
+
* 还有一种可能是T写了就变成了强制类型转换,也会出错
|
|
228
|
+
* 即使改成issue里面说的方法,也没有办法限制defaultValue类型
|
|
229
|
+
*/
|
|
230
|
+
declare function evaluate<T>(config: any, defaultValue: T, ...args: any[]): T;
|
|
231
|
+
|
|
232
|
+
interface ILayoutConfiguration {
|
|
233
|
+
hideTitleBar?: boolean;
|
|
234
|
+
hideSideMenu?: boolean;
|
|
235
|
+
hideSettingPanel?: boolean;
|
|
236
|
+
hideTopMenu?: boolean;
|
|
237
|
+
hideBottomMenu?: boolean;
|
|
238
|
+
}
|
|
239
|
+
interface IPageRouteConfig {
|
|
240
|
+
/** 唯一识别符 */
|
|
241
|
+
id: string;
|
|
242
|
+
/** 路径配置 */
|
|
243
|
+
path: string;
|
|
244
|
+
/** 作为 content 懒加载的标识. */
|
|
245
|
+
loading?: Promise<LvErrorRef>;
|
|
246
|
+
content?: () => React.ReactNode;
|
|
247
|
+
/** skeleton 路由没加载完之前的骨架屏 */
|
|
248
|
+
skeleton?: () => React.ReactNode;
|
|
249
|
+
/** 是否拦截跳转 */
|
|
250
|
+
shouldInterceptNavigate?: () => boolean;
|
|
251
|
+
/** 设置是否需要keep-alive缓存起路由组件 */
|
|
252
|
+
isNeedCache?: boolean | (() => boolean);
|
|
253
|
+
/** 设置该路由中的布局配置项 */
|
|
254
|
+
layoutConfiguration?: ILayoutConfiguration;
|
|
255
|
+
/** 页面是否展示的回调函数 */
|
|
256
|
+
onActiveChange?: (options: {
|
|
257
|
+
active: boolean;
|
|
258
|
+
/** 允许由其他业务模块透传传递到指定 contribution 中.实现特定业务逻辑 */
|
|
259
|
+
extraParams?: any | undefined;
|
|
260
|
+
}) => void;
|
|
261
|
+
index?: boolean;
|
|
262
|
+
_updateTime?: number;
|
|
263
|
+
/**
|
|
264
|
+
* Error Boundary 的 fallback 内容
|
|
265
|
+
* 建议纯组件,避免 fallback 组件内部仍有异常
|
|
266
|
+
*/
|
|
267
|
+
errorElement?: ReactElement<unknown, string | FunctionComponent | typeof Component> | null;
|
|
268
|
+
/**
|
|
269
|
+
* Error Boundary 的 onError 回调
|
|
270
|
+
* 常用于上报问题
|
|
271
|
+
*/
|
|
272
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
declare const PageRouteManagerSymbol = "PageRoute";
|
|
276
|
+
interface IPageRouteObservableData {
|
|
277
|
+
currentRoute: string | undefined;
|
|
278
|
+
configs: IPageRouteConfig[];
|
|
279
|
+
keepAliveStatusMap: Record<string, IKeepAliveEventData>;
|
|
280
|
+
historyRoutes: string[];
|
|
281
|
+
containerWidth: number;
|
|
282
|
+
}
|
|
283
|
+
interface IGeneratePathOptions {
|
|
284
|
+
params?: Record<string, string>;
|
|
285
|
+
query?: Record<string, string> | string;
|
|
286
|
+
}
|
|
287
|
+
interface INavigateOptions extends IGeneratePathOptions, NavigateOptions {
|
|
288
|
+
}
|
|
289
|
+
declare enum KeepAliveStatus {
|
|
290
|
+
/** 激活态 */
|
|
291
|
+
Activated = "Activated",
|
|
292
|
+
/** 失活态 */
|
|
293
|
+
InActivated = "InActivated"
|
|
294
|
+
}
|
|
295
|
+
interface IKeepAliveEventData {
|
|
296
|
+
/** 当前激活状态对应的路由路径 */
|
|
297
|
+
pathName: string;
|
|
298
|
+
/** 当前激活状态对应的路由ID */
|
|
299
|
+
routeId: string;
|
|
300
|
+
/** 当前激活状态 */
|
|
301
|
+
status: KeepAliveStatus;
|
|
302
|
+
/** 当前激活状态的路由携带的信息 */
|
|
303
|
+
locationState: any;
|
|
304
|
+
}
|
|
305
|
+
type IPageRouteRenderOptions = {
|
|
306
|
+
layout: React__default.ReactNode;
|
|
307
|
+
};
|
|
308
|
+
type IPageRouteOutletOptions = {
|
|
309
|
+
routesConfig: IPageRouteConfig[];
|
|
310
|
+
};
|
|
311
|
+
interface IPageRouteManager extends IBaseUiManager<IPageRouteConfig> {
|
|
312
|
+
observableData: IPageRouteObservableData;
|
|
313
|
+
render: (options: IPageRouteRenderOptions) => React__default.ReactNode;
|
|
314
|
+
renderOutlet: (options: IPageRouteOutletOptions) => React__default.ReactNode;
|
|
315
|
+
/** 用于单向的路由跳转场景 */
|
|
316
|
+
renderSingleOutlet: (options: IPageRouteOutletOptions) => React__default.ReactNode;
|
|
317
|
+
/** 当前激活的路由信息 */
|
|
318
|
+
currentKeepAliveData: IKeepAliveEventData | undefined;
|
|
319
|
+
/** 等待待跳转的路由 */
|
|
320
|
+
pendingNavigateOptions: {
|
|
321
|
+
path: string;
|
|
322
|
+
options?: INavigateOptions;
|
|
323
|
+
} | undefined;
|
|
324
|
+
currentRoute: IPageRouteConfig | undefined;
|
|
325
|
+
/** 触发路由改变的回调 */
|
|
326
|
+
onWouldRouteChange: Event<[string | number, options?: NavigateOptions]>;
|
|
327
|
+
notifyPageRendered: (config: string | IPageRouteConfig) => void;
|
|
328
|
+
onPageRendered: Event<[IPageRouteConfig]>;
|
|
329
|
+
onPageContainerWidthChange: Event<[]>;
|
|
330
|
+
/** 路由配置发生变化时触发的事件 */
|
|
331
|
+
onRouteConfigChange: Event<[IPageRouteConfig[]]>;
|
|
332
|
+
getRouteConfigByPath: (path: string) => IPageRouteConfig | undefined;
|
|
333
|
+
/** 更新当前路由 */
|
|
334
|
+
updatePageRoute: (path: string) => void;
|
|
335
|
+
/** 生成路径 */
|
|
336
|
+
generatePath: (id: string, options?: IGeneratePathOptions | undefined) => string;
|
|
337
|
+
/** 路由到具体地址 */
|
|
338
|
+
navigate: (id: string, options?: INavigateOptions) => void;
|
|
339
|
+
/** 返回到上级页面
|
|
340
|
+
* @param {number} 默认是-1 即返回上一级页面
|
|
341
|
+
* */
|
|
342
|
+
navigateBack: (to?: number) => void;
|
|
343
|
+
/** 使用keep-alive之后,可监听keep-alive看当前那一个路由组件被激活了 */
|
|
344
|
+
onKeepAliveChange: Event<[IKeepAliveEventData]>;
|
|
345
|
+
/** 由外部去触发当前需要激活那一个路由 */
|
|
346
|
+
activateKeepAliveRoute: (activatePathName: string, locationState: any) => void;
|
|
347
|
+
updateContainerWidth: (width: number) => void;
|
|
348
|
+
/** 初始化完 pageRouteManager 可以进行navigate了 */
|
|
349
|
+
initDone: VoidFunction;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
declare class PageRouteManager extends BaseUiManager<any, IPageRouteConfig> implements IBaseUiManager<IPageRouteConfig>, IPageRouteManager {
|
|
353
|
+
observableData: IPageRouteObservableData;
|
|
354
|
+
private readonly _locker;
|
|
355
|
+
private _pendingNavigateOptions;
|
|
356
|
+
private readonly _onWouldRouteChange;
|
|
357
|
+
onWouldRouteChange: _zk_tech_bedrock_event.Event<[string | number, options?: INavigateOptions | undefined]>;
|
|
358
|
+
private readonly _onKeepAliveChange;
|
|
359
|
+
onKeepAliveChange: _zk_tech_bedrock_event.Event<[IKeepAliveEventData]>;
|
|
360
|
+
private readonly _onPageRendered;
|
|
361
|
+
onPageRendered: _zk_tech_bedrock_event.Event<[IPageRouteConfig]>;
|
|
362
|
+
private readonly _onPageContainerWidthChange;
|
|
363
|
+
onPageContainerWidthChange: _zk_tech_bedrock_event.Event<[]>;
|
|
364
|
+
private readonly _onRouteConfigChange;
|
|
365
|
+
onRouteConfigChange: _zk_tech_bedrock_event.Event<[IPageRouteConfig[]]>;
|
|
366
|
+
get pendingNavigateOptions(): {
|
|
367
|
+
path: string;
|
|
368
|
+
options?: INavigateOptions;
|
|
369
|
+
} | undefined;
|
|
370
|
+
get currentRoute(): IPageRouteConfig | undefined;
|
|
371
|
+
registerConfig(configs: IPageRouteConfig[]): void;
|
|
372
|
+
updatePageRoute(path: string): void;
|
|
373
|
+
navigate(id: string, options?: INavigateOptions): void;
|
|
374
|
+
private _navigateByPath;
|
|
375
|
+
updateContainerWidth(width: number): void;
|
|
376
|
+
initDone(): void;
|
|
377
|
+
navigateBack(to?: number): void;
|
|
378
|
+
generatePath(id: string, options?: IGeneratePathOptions | undefined): string;
|
|
379
|
+
activateKeepAliveRoute(activatePathName: string, locationState: any): void;
|
|
380
|
+
private _updateKeepAliveStatus;
|
|
381
|
+
get currentKeepAliveData(): IKeepAliveEventData | undefined;
|
|
382
|
+
notifyPageRendered(config: string | IPageRouteConfig): void;
|
|
383
|
+
getRouteConfigByPath(path: string | undefined): IPageRouteConfig | undefined;
|
|
384
|
+
render(options: IPageRouteRenderOptions): React.ReactNode;
|
|
385
|
+
renderOutlet(options: IPageRouteOutletOptions): React$1.JSX.Element;
|
|
386
|
+
renderSingleOutlet(options: IPageRouteOutletOptions): React$1.JSX.Element;
|
|
387
|
+
_middlewareChange(props: IMiddlewareChange<'PageRoute'>): void;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
type TEffectCallback = () => VoidFunction | void;
|
|
391
|
+
/**
|
|
392
|
+
* 用于keep-alive路由组件的显隐的触发钩子
|
|
393
|
+
* 由于使用了keep-alive路由的组件,无法使用useEffect来表示组件是否可见,因此增加该hook来
|
|
394
|
+
* 帮助外部来判断当前组件是否可见,用法和useEffect类似,传入一个函数,该函数会在初始化时候的路由组件
|
|
395
|
+
* 被激活的时候触发,且该函数返回的函数会在失活的时候被触发
|
|
396
|
+
* @example
|
|
397
|
+
* ```
|
|
398
|
+
* useKeepAliveEffect(() => {
|
|
399
|
+
* console.log('我被激活啦!')
|
|
400
|
+
* return () => {
|
|
401
|
+
* console.log('我被失活啦!')
|
|
402
|
+
* }
|
|
403
|
+
* })
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
406
|
+
declare const useKeepAliveEffect: (cb: TEffectCallback) => void;
|
|
407
|
+
declare const useKeepAliveLayoutEffect: (cb: TEffectCallback) => void;
|
|
408
|
+
|
|
409
|
+
declare const usePageContainerWidth: () => number;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* 模块的全局设置,会被赋值到 setting store 上.
|
|
413
|
+
*/
|
|
414
|
+
type IPageRouteSettingObservableData = {
|
|
415
|
+
/** 基础路径,默认为 '/' */
|
|
416
|
+
baseRoute: string;
|
|
417
|
+
/** 当页面无任何内容命中时,自动执行重定向处理; 参数是 pageRoute 对应 id */
|
|
418
|
+
redirectRouteIdWhen404?: string;
|
|
419
|
+
};
|
|
420
|
+
type IPageRouteSetting = IPageRouteSettingObservableData & {
|
|
421
|
+
/** 可选的 observable 数据 */
|
|
422
|
+
observableData?: IPageRouteSettingObservableData;
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
type ITempUiConfigurationServiceContext = IContext<{
|
|
426
|
+
uiManager: {
|
|
427
|
+
[PageRouteManagerSymbol]: IPageRouteManager;
|
|
428
|
+
};
|
|
429
|
+
setting: IPageRouteSetting & IBaseSetting;
|
|
430
|
+
}>;
|
|
431
|
+
|
|
432
|
+
declare const useNavigateFactory: (uiConfigurationService: ITempUiConfigurationServiceContext["uiConfigurationService"]) => NavigateFunction;
|
|
433
|
+
|
|
434
|
+
type IBlockContentSetting = void;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* blockContent 配置内容
|
|
438
|
+
* @public
|
|
439
|
+
*/
|
|
440
|
+
type IBlockContentConfig = {
|
|
441
|
+
/** 唯一识别符 */
|
|
442
|
+
id: string;
|
|
443
|
+
/** 允许自定义挂载 title bar 的自定义类名 */
|
|
444
|
+
className?: string | ((...args: any[]) => string);
|
|
445
|
+
/**
|
|
446
|
+
* 展示的内容,可以是 React 组件或字符串
|
|
447
|
+
*/
|
|
448
|
+
content: React__default.ReactNode | (() => React__default.ReactNode | null) | null;
|
|
449
|
+
onHover?: (...args: any[]) => void;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
declare const BlockContentManagerSymbol = "BlockContent";
|
|
453
|
+
interface IBlockContentObservableData {
|
|
454
|
+
forceUpdate: number;
|
|
455
|
+
activeId: string | undefined;
|
|
456
|
+
configs: IBlockContentConfig[];
|
|
457
|
+
}
|
|
458
|
+
interface IBlockContentManager extends IBaseUiManager<IBlockContentConfig> {
|
|
459
|
+
observableData: IBlockContentObservableData;
|
|
460
|
+
changeActiveId: (activeId: string) => void;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
declare class BlockContentManager extends BaseUiManager<any, IBlockContentConfig> implements IBlockContentManager {
|
|
464
|
+
observableData: IBlockContentObservableData;
|
|
465
|
+
registerConfig(configs: IBlockContentConfig[]): void;
|
|
466
|
+
changeActiveId(activeId: string | undefined): void;
|
|
467
|
+
render(): React$1.JSX.Element;
|
|
468
|
+
_middlewareChange(): void;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export { BaseSetting, BaseUiConfigurationService, BaseUiManager, BlockContentManager, BlockContentManagerSymbol, GlobalContext, type IBaseSetting, type IBaseUiManager, type IBlockContentConfig, type IBlockContentManager, type IBlockContentSetting, type IKeepAliveEventData, type IMiddlewareManager, type INavigateOptions, type IPageRouteConfig, type IPageRouteManager, type IPageRouteSetting, type IUseMiddlewareProps, KeepAliveStatus, MiddlewareManager, OrderLevel, PageRouteManager, PageRouteManagerSymbol, evaluate, mergeUiConfigs, runnerBuilder, sortListBySettings, useKeepAliveEffect, useKeepAliveLayoutEffect, useNavigateFactory, usePageContainerWidth };
|