@common-stack/client-react 8.0.1-alpha.0 → 8.0.2-alpha.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/lib/connector/base-connector.d.ts +3 -3
- package/lib/connector/base-connector.js +4 -4
- package/lib/connector/base-connector.js.map +1 -1
- package/lib/connector/connector.d.ts +4 -5
- package/lib/connector/connector.js +3 -3
- package/lib/connector/connector.js.map +1 -1
- package/lib/connector/connector.native.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/index.native.js +1 -1
- package/lib/interfaces/extended-feature.d.ts +24 -24
- package/lib/interfaces/feature.d.ts +2 -3
- package/lib/interfaces/index.d.ts +1 -2
- package/lib/interfaces/menu.d.ts +3 -111
- package/lib/interfaces/route.d.ts +18 -0
- package/lib/route/get-routes.d.ts +3 -3
- package/lib/route/get-routes.js +1 -1
- package/lib/route/get-routes.js.map +1 -1
- package/lib/route/index.d.ts +0 -1
- package/lib/route/react-navigation/get-navigation-utils.d.ts +3 -11
- package/lib/route/react-navigation/get-navigation-utils.js +13 -13
- package/lib/route/react-navigation/get-navigation-utils.js.map +1 -1
- package/lib/route/react-navigation/index.d.ts +2 -1
- package/lib/route/react-navigation/interfaces/route.d.ts +16 -0
- package/lib/router-factory/index.js +1 -1
- package/lib/utils/filteredRoutes.d.ts +4 -3
- package/lib/utils/filteredRoutes.js.map +1 -1
- package/lib/utils/matchRoute.d.ts +2 -1
- package/lib/utils/sort-keys.d.ts +3 -2
- package/lib/utils/sort-keys.js +38 -37
- package/lib/utils/sort-keys.js.map +1 -1
- package/package.json +5 -4
- package/lib/__tests__/integrated-routes.test.d.ts +0 -1
- package/lib/__tests__/router-render.test.d.ts +0 -3
- package/lib/interfaces/menu.js +0 -13
- package/lib/interfaces/menu.js.map +0 -1
- package/lib/interfaces/new-router.d.ts +0 -55
- package/lib/interfaces/router.d.ts +0 -41
- package/lib/route/__tests__/admin-new-routes.test.d.ts +0 -1
- package/lib/route/old/__tests__/config-sidebar-menu.test.d.ts +0 -1
- package/lib/route/old/get-menus.d.ts +0 -2
- package/lib/route/old/get-menus.js +0 -54
- package/lib/route/old/get-menus.js.map +0 -1
- package/lib/route/old/get-routes-notused.d.ts +0 -11
- package/lib/route/old/render.d.ts +0 -2
- package/lib/route/old/render.js +0 -6
- package/lib/route/old/render.js.map +0 -1
- package/lib/route/render-routes.d.ts +0 -3
- package/lib/route/render-routes.js +0 -96
- package/lib/route/render-routes.js.map +0 -1
- package/lib/route/render-routes.test.d.ts +0 -1
- /package/lib/{route/__tests__/route-type.test.d.ts → utils/__tests__/filteredRoutes.test.d.ts} +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AbstractFeature } from '@common-stack/client-core';
|
|
3
|
-
import { FeatureParam, IReactFeature } from '../interfaces';
|
|
3
|
+
import { FeatureParam, IReactFeature, IComputedRoutesArray } from '../interfaces';
|
|
4
4
|
export declare abstract class BaseFeature extends AbstractFeature implements IReactFeature {
|
|
5
5
|
componentFillPlugins: any;
|
|
6
6
|
hydrate: FeatureParam['hydrate'];
|
|
7
7
|
beforeSSR: FeatureParam['beforeSSR'];
|
|
8
|
-
routeConfig:
|
|
8
|
+
routeConfig: IComputedRoutesArray;
|
|
9
9
|
reduxConfig: any;
|
|
10
10
|
menuConfig: any;
|
|
11
11
|
authWrapper: (ele: React.ReactElement, props: Record<string, any>) => void;
|
|
@@ -40,7 +40,7 @@ export declare abstract class BaseFeature extends AbstractFeature implements IRe
|
|
|
40
40
|
* Note: It overwrites the any duplicate key with latest loaded key.
|
|
41
41
|
* TODO: Find a way to warn when there are duplicate keys.
|
|
42
42
|
*/
|
|
43
|
-
getConfiguredMenus(searchPath?: string):
|
|
43
|
+
getConfiguredMenus(searchPath?: string): void;
|
|
44
44
|
get navItems(): any;
|
|
45
45
|
get navItemsRight(): any;
|
|
46
46
|
getWrappedRoot(root: React.ReactNode, req?: any): React.ReactNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import {AbstractFeature}from'@common-stack/client-core';import {merge,sortBy,find}from'lodash-es';import
|
|
1
|
+
import*as React from'react';import {AbstractFeature}from'@common-stack/client-core';import {merge,sortBy,find}from'lodash-es';import'@wordpress/hooks';import'../plugin-area/plugin-context.js';import {getPlugin,registerPlugin,getPlugins}from'../plugin-area/plugin-api.js';import'sort-keys';import {combine}from'../utils/combine.js';import {hydrate}from'../utils/hydrate.js';import {beforeSSR}from'../utils/before-ssr.js';const getFirst = (features, extractor) => extractor(find(features, (res) => extractor(res)) || {});
|
|
2
2
|
class BaseFeature extends AbstractFeature {
|
|
3
3
|
// private logger;
|
|
4
4
|
componentFillPlugins;
|
|
@@ -71,8 +71,8 @@ class BaseFeature extends AbstractFeature {
|
|
|
71
71
|
* TODO: Find a way to warn when there are duplicate keys.
|
|
72
72
|
*/
|
|
73
73
|
getConfiguredMenus(searchPath = '/') {
|
|
74
|
-
const routes = Object.assign({}, ...this.menuConfig);
|
|
75
|
-
return getMenus(searchPath, { ...routes });
|
|
74
|
+
// const routes = Object.assign({}, ...this.menuConfig);
|
|
75
|
+
// return getMenus(searchPath, { ...routes });
|
|
76
76
|
}
|
|
77
77
|
get navItems() {
|
|
78
78
|
return this.navItem.map((component, idx) => React.cloneElement(component, {
|
|
@@ -122,7 +122,7 @@ class BaseFeature extends AbstractFeature {
|
|
|
122
122
|
sortMenus = (sortByPriority, menus) => {
|
|
123
123
|
if (sortByPriority) {
|
|
124
124
|
const menuData = this.sortMenusByPriority(menus);
|
|
125
|
-
return menuData.map(menu => {
|
|
125
|
+
return menuData.map((menu) => {
|
|
126
126
|
return {
|
|
127
127
|
...menu,
|
|
128
128
|
children: menu.children && this.sortMenus(sortByPriority, menu.children),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-connector.js","sources":["../../src/connector/base-connector.tsx"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base-connector.js","sources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CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9D,KAAC,CAAC;AAEM,IAAA,SAAS,GAAG,CAAC,cAAc,EAAE,KAAK,KAAI;QAC1C,IAAI,cAAc,EAAE;YAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACjD,YAAA,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;gBACzB,OAAO;AACH,oBAAA,GAAG,IAAI;AACP,oBAAA,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC;iBAC3E,CAAC;AACN,aAAC,CAAC,CAAC;SACN;aAAM;AACH,YAAA,OAAO,KAAK,CAAC;SAChB;AACL,KAAC,CAAC;AACL"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { IReactFeature } from '../interfaces';
|
|
2
2
|
import { BaseFeature } from './base-connector';
|
|
3
|
-
import { renderRoutes2 } from '../route/render-routes';
|
|
4
3
|
export declare class Feature extends BaseFeature implements IReactFeature {
|
|
5
|
-
protected renderRoutes:
|
|
6
|
-
protected renderRoutes2:
|
|
7
|
-
protected getSortedRoutes: (path: string, routeData: import("
|
|
8
|
-
protected getSortedRoutes2: (path: string, routeData: import("
|
|
4
|
+
protected renderRoutes: any;
|
|
5
|
+
protected renderRoutes2: any;
|
|
6
|
+
protected getSortedRoutes: (path: string, routeData: import("packages/common-core/lib/component/interfaces/routeJson").IComputedRoutesArray, authWrapper?: (ele: React.ReactElement, props: Record<string, any>) => void) => any;
|
|
7
|
+
protected getSortedRoutes2: (path: string, routeData: import("packages/common-core/lib/component/interfaces/routeJson").IComputedRoutesArray, authWrapper?: (ele: React.ReactElement, props: Record<string, any>) => void) => any;
|
|
9
8
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {BaseFeature}from'./base-connector.js';import {
|
|
2
|
-
renderRoutes =
|
|
3
|
-
renderRoutes2 =
|
|
1
|
+
import {BaseFeature}from'./base-connector.js';import {getSortedRoutes}from'../route/get-routes.js';class Feature extends BaseFeature {
|
|
2
|
+
renderRoutes = null;
|
|
3
|
+
renderRoutes2 = null;
|
|
4
4
|
getSortedRoutes = getSortedRoutes;
|
|
5
5
|
getSortedRoutes2 = getSortedRoutes;
|
|
6
6
|
}export{Feature};//# sourceMappingURL=connector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector.js","sources":["../../src/connector/connector.tsx"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"connector.js","sources":["../../src/connector/connector.tsx"],"sourcesContent":[null],"names":[],"mappings":"mGAIM,MAAO,OAAQ,SAAQ,WAAW,CAAA;IAC1B,YAAY,GAAG,IAAI,CAAC;IACpB,aAAa,GAAG,IAAI,CAAC;IACrB,eAAe,GAAG,eAAe,CAAC;IAClC,gBAAgB,GAAG,eAAe,CAAC;AAChD"}
|
|
@@ -9,9 +9,9 @@ export declare class Feature extends BaseFeature implements IReactFeature {
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
protected renderRoutes2: (arg1: any, arg2: any) => import("react").JSX.Element;
|
|
12
|
-
protected getSortedRoutes: (path: string, routeData: import("
|
|
12
|
+
protected getSortedRoutes: (path: string, routeData: import("..").IComputedMobileRoutesArray, authWrapper?: (component: React.FC) => import("react").ReactElement) => any;
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated use getSortedRoutes
|
|
15
15
|
*/
|
|
16
|
-
protected getSortedRoutes2: (path: string, routeData: import("
|
|
16
|
+
protected getSortedRoutes2: (path: string, routeData: import("..").IComputedMobileRoutesArray, authWrapper?: (component: React.FC) => import("react").ReactElement) => any;
|
|
17
17
|
}
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.js';export{FeatureWithRouterFactory}from'./router-factory/index.js';export{
|
|
1
|
+
export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.js';export{FeatureWithRouterFactory}from'./router-factory/index.js';export{default as resolveRootRoute}from'./route/react-navigation/react-navigation-render.js';export{getNavigation,getSortedNavigations}from'./route/react-navigation/get-navigation-utils.js';export{navigate,navigationRef}from'./route/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{getFilteredMenus,getFilteredRoutes,getFilteredTabs}from'./utils/filteredRoutes.js';export{IMenuPosition}from'@common-stack/core/lib/component/interfaces/menu.js';export{PluginArea}from'./plugin-area/index.js';export{RouteBasedPluginArea}from'./route-based-plugin-area/route-based-plugin-area.js';export{getRouteBasePlugin,getRouteBasePlugins,registerRouteBasePlugin,unregisterRouteBasePlugin}from'./route-based-plugin-area/plugin-api.js';export{InversifyContext,InversifyProvider,useInjection}from'./inversify/InversifyContext.js';export{getPlugin,getPlugins,registerPlugin,unregisterPlugin}from'./plugin-area/plugin-api.js';//# sourceMappingURL=index.js.map
|
package/lib/index.native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.native.js';export{FeatureWithRouterFactory}from'./router-factory/index.native.js';export{navigate,navigationRef}from'./route/react-navigation/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{getFilteredMenus,getFilteredRoutes,getFilteredTabs}from'./utils/filteredRoutes.js';export{IMenuPosition}from'
|
|
1
|
+
export{ClientTypes}from'@common-stack/client-core';export{Feature}from'./connector/connector.native.js';export{FeatureWithRouterFactory}from'./router-factory/index.native.js';export{navigate,navigationRef}from'./route/react-navigation/root-navigation.js';export{sortByPaths,sortKeys}from'./utils/sort-keys.js';export{formatSlash}from'./utils/utils.js';export{combine}from'./utils/combine.js';export{hydrate}from'./utils/hydrate.js';export{beforeSSR}from'./utils/before-ssr.js';export{getFilteredMenus,getFilteredRoutes,getFilteredTabs}from'./utils/filteredRoutes.js';export{IMenuPosition}from'@common-stack/core/lib/component/interfaces/menu.js';export{PluginArea}from'./plugin-area/index.native.js';export{RouteBasedPluginArea}from'./route-based-plugin-area/route-based-plugin-area.js';export{getRouteBasePlugin,getRouteBasePlugins,registerRouteBasePlugin,unregisterRouteBasePlugin}from'./route-based-plugin-area/plugin-api.js';export{InversifyContext,InversifyProvider,useInjection}from'./inversify/InversifyContext.js';export{getPlugin,getPlugins,registerPlugin,unregisterPlugin}from'./plugin-area/plugin-api.js';//# sourceMappingURL=index.native.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { IFeature } from '@common-stack/client-core';
|
|
3
|
-
import { IMappedData, IRouteData } from './router';
|
|
4
|
-
import { IMenuData } from './menu';
|
|
5
3
|
import { ComponentElement } from 'react';
|
|
4
|
+
import { IMenuData } from './menu';
|
|
5
|
+
import { IComputedRoutesArray } from './route';
|
|
6
6
|
export interface IPlugin {
|
|
7
7
|
name: string;
|
|
8
8
|
icon?: string | ComponentElement<any, any> | Function;
|
|
@@ -11,27 +11,6 @@ export interface IPlugin {
|
|
|
11
11
|
export interface IReduxConfig {
|
|
12
12
|
ignoredActions?: string[];
|
|
13
13
|
}
|
|
14
|
-
export type IReactFeature = IFeature & IReactModuleShape & {
|
|
15
|
-
readonly getRouter: any;
|
|
16
|
-
/**
|
|
17
|
-
* @returns client-side React route components list
|
|
18
|
-
*/
|
|
19
|
-
readonly getRoutes: any;
|
|
20
|
-
readonly getConfiguredRoutes: any;
|
|
21
|
-
readonly getMenus: any;
|
|
22
|
-
readonly getConfiguredMenus: any;
|
|
23
|
-
readonly routeConfig: IRouteData;
|
|
24
|
-
readonly menuConfig: IMappedData;
|
|
25
|
-
componentFillPlugins: IPlugin[];
|
|
26
|
-
/**
|
|
27
|
-
* React component of all fill of each plugin.
|
|
28
|
-
*/
|
|
29
|
-
getComponentFillPlugins(): IPlugin[];
|
|
30
|
-
/**
|
|
31
|
-
* Authentication Wrapper for secured routes
|
|
32
|
-
*/
|
|
33
|
-
readonly authWrapper?: (ele: React.ReactElement, props: Record<string, any>) => void;
|
|
34
|
-
};
|
|
35
14
|
export type IReactModuleShape = {
|
|
36
15
|
/**
|
|
37
16
|
* @param route Route list
|
|
@@ -40,7 +19,7 @@ export type IReactModuleShape = {
|
|
|
40
19
|
/**
|
|
41
20
|
* @param routeConfig Custom route data to create React Routers
|
|
42
21
|
*/
|
|
43
|
-
readonly routeConfig?:
|
|
22
|
+
readonly routeConfig?: IComputedRoutesArray;
|
|
44
23
|
/**
|
|
45
24
|
* @param reduxConfig Custom route data to create React Routers
|
|
46
25
|
*/
|
|
@@ -50,6 +29,27 @@ export type IReactModuleShape = {
|
|
|
50
29
|
*/
|
|
51
30
|
readonly menuConfig?: IMenuData | IMenuData[];
|
|
52
31
|
readonly componentFillPlugins?: IPlugin[];
|
|
32
|
+
/**
|
|
33
|
+
* Authentication Wrapper for secured routes
|
|
34
|
+
*/
|
|
35
|
+
readonly authWrapper?: (ele: React.ReactElement, props: Record<string, never>) => void;
|
|
36
|
+
};
|
|
37
|
+
export type IReactFeature = IFeature & IReactModuleShape & {
|
|
38
|
+
readonly getRouter: any;
|
|
39
|
+
/**
|
|
40
|
+
* @returns client-side React route components list
|
|
41
|
+
*/
|
|
42
|
+
readonly getRoutes: any;
|
|
43
|
+
readonly getConfiguredRoutes: any;
|
|
44
|
+
readonly getMenus: any;
|
|
45
|
+
readonly getConfiguredMenus: any;
|
|
46
|
+
readonly routeConfig: IComputedRoutesArray;
|
|
47
|
+
readonly menuConfig: IMenuData;
|
|
48
|
+
componentFillPlugins: IPlugin[];
|
|
49
|
+
/**
|
|
50
|
+
* React component of all fill of each plugin.
|
|
51
|
+
*/
|
|
52
|
+
getComponentFillPlugins(): IPlugin[];
|
|
53
53
|
/**
|
|
54
54
|
* Authentication Wrapper for secured routes
|
|
55
55
|
*/
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { IModuleShape } from '@common-stack/client-core';
|
|
2
2
|
import { Container } from 'inversify';
|
|
3
|
-
import { IReactModuleShape } from './extended-feature';
|
|
4
|
-
import { Feature } from '../connector';
|
|
3
|
+
import { IReactModuleShape, IReactFeature } from './extended-feature';
|
|
5
4
|
type SSRFeatureOptions = {
|
|
6
5
|
readonly hydrate?: (container: Container, state: never) => void;
|
|
7
6
|
readonly beforeSSR?: (options: {
|
|
8
7
|
request: any;
|
|
9
|
-
module:
|
|
8
|
+
module: IReactFeature;
|
|
10
9
|
}) => Promise<void>;
|
|
11
10
|
};
|
|
12
11
|
export type FeatureParam = IModuleShape & IReactModuleShape & SSRFeatureOptions;
|
package/lib/interfaces/menu.d.ts
CHANGED
|
@@ -1,113 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
* @deprecated Will be removed, don't use it. It is replaced by
|
|
4
|
-
*/
|
|
1
|
+
import type { IMenuDataItem } from '@common-stack/core/lib/component/interfaces/menu.js';
|
|
2
|
+
export { IMenuPosition } from '@common-stack/core/lib/component/interfaces/menu.js';
|
|
5
3
|
export interface IMenuData {
|
|
6
|
-
[key: string]:
|
|
7
|
-
name: any;
|
|
8
|
-
position?: IMenuPosition;
|
|
9
|
-
icon?: any;
|
|
10
|
-
authority?: any;
|
|
11
|
-
exact?: boolean;
|
|
12
|
-
strict?: boolean;
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated Will be removed, don't use it. Replaced by IMenuDataItem
|
|
18
|
-
*/
|
|
19
|
-
export interface IMenuItem {
|
|
20
|
-
path?: string;
|
|
21
|
-
name: any;
|
|
22
|
-
icon?: any;
|
|
23
|
-
position: IMenuPosition;
|
|
24
|
-
authority?: any;
|
|
25
|
-
loading?: any;
|
|
26
|
-
exact?: boolean;
|
|
27
|
-
strict?: boolean;
|
|
28
|
-
children?: IMenuItem[];
|
|
29
|
-
priority?: number;
|
|
30
|
-
}
|
|
31
|
-
export interface IMenuDataItem {
|
|
32
|
-
/**
|
|
33
|
-
* @name submenu
|
|
34
|
-
*/
|
|
35
|
-
children?: IMenuDataItem[];
|
|
36
|
-
/**
|
|
37
|
-
* @name Hide child nodes in the menu
|
|
38
|
-
*/
|
|
39
|
-
hideChildrenInMenu?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* @name hideSelf and children in menu
|
|
42
|
-
*/
|
|
43
|
-
hideInMenu?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* @name Icon of the menu
|
|
46
|
-
*/
|
|
47
|
-
icon?: React.ReactNode;
|
|
48
|
-
/**
|
|
49
|
-
* @name Internationalization key for custom menus
|
|
50
|
-
*/
|
|
51
|
-
locale?: string | false;
|
|
52
|
-
/**
|
|
53
|
-
* @name The name of the menu
|
|
54
|
-
*/
|
|
55
|
-
name?: string;
|
|
56
|
-
/**
|
|
57
|
-
* @name is used to calibrate the selected value, default is path
|
|
58
|
-
*/
|
|
59
|
-
key?: string;
|
|
60
|
-
/**
|
|
61
|
-
* @name disable menu option
|
|
62
|
-
*/
|
|
63
|
-
disabled?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Disable menu tooltip menu option
|
|
66
|
-
*/
|
|
67
|
-
disabledTooltip?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* @name path
|
|
70
|
-
*/
|
|
71
|
-
path?: string;
|
|
72
|
-
/**
|
|
73
|
-
* @name custom parent node
|
|
74
|
-
* @description When this node is selected, the node of parentKeys is also selected
|
|
75
|
-
*/
|
|
76
|
-
parentKeys?: string[];
|
|
77
|
-
/**
|
|
78
|
-
* @name hides itself and elevates child nodes to its level
|
|
79
|
-
*/
|
|
80
|
-
flatMenu?: boolean;
|
|
81
|
-
/** @name Specify the external link opening mode, same as a tag */
|
|
82
|
-
target?: string;
|
|
83
|
-
/**
|
|
84
|
-
* @name position of the Menu
|
|
85
|
-
* @enum IMenuPosition
|
|
86
|
-
*/
|
|
87
|
-
position?: IMenuPosition;
|
|
88
|
-
/**
|
|
89
|
-
* @name permissions to determine whether to render menu or not
|
|
90
|
-
*/
|
|
91
|
-
authority?: string[];
|
|
92
|
-
/**
|
|
93
|
-
* @name priority of the menu to display in the order. Lower values shows first.
|
|
94
|
-
*/
|
|
95
|
-
priority?: number;
|
|
96
|
-
/**
|
|
97
|
-
* The path displayed by the menuItem's tooltip
|
|
98
|
-
*/
|
|
99
|
-
tooltip?: string;
|
|
100
|
-
[key: string]: any;
|
|
101
|
-
}
|
|
102
|
-
export declare enum IMenuPosition {
|
|
103
|
-
LOGO = "LOGO",
|
|
104
|
-
UPPER = "UPPER",
|
|
105
|
-
MIDDLE = "MIDDLE",
|
|
106
|
-
LOWER = "LOWER",
|
|
107
|
-
BOTTOM = "BOTTOM",
|
|
108
|
-
Logo = "LOGO",
|
|
109
|
-
Upper = "UPPER",
|
|
110
|
-
Middle = "MIDDLE",
|
|
111
|
-
Lower = "LOWER",
|
|
112
|
-
Bottom = "BOTTOM"
|
|
4
|
+
[key: string]: IMenuDataItem;
|
|
113
5
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IRouteMap, IComputedRoutesArray } from '@common-stack/core/lib/component/interfaces/routeJson.js';
|
|
2
|
+
import type { IRouteModule } from '@common-stack/core/lib/component/interfaces/routeCompute.js';
|
|
3
|
+
import type { IRollupBuildGenerated } from '@common-stack/core/lib/component/interfaces/rollupRouteGenerated.js';
|
|
4
|
+
type IInternalRouteProcessing<T = unknown> = {
|
|
5
|
+
route: string;
|
|
6
|
+
parentPath?: string;
|
|
7
|
+
relativePath?: string;
|
|
8
|
+
_pathPrefix?: string;
|
|
9
|
+
routes?: IProcessedRoute<T>[];
|
|
10
|
+
};
|
|
11
|
+
export type IProcessedRoute<T = unknown> = IRouteModule & IInternalRouteProcessing<T> & T & {
|
|
12
|
+
path: string;
|
|
13
|
+
routes?: any;
|
|
14
|
+
};
|
|
15
|
+
export type IComputedInternalRoutesArray = Array<{
|
|
16
|
+
[key: string]: IRouteModule & IRollupBuildGenerated;
|
|
17
|
+
}>;
|
|
18
|
+
export { IRouteMap, IComputedRoutesArray, IRouteModule };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const getSortedRoutes: (path: string, routeData:
|
|
3
|
-
export declare function getRoutes(path: string, routeData:
|
|
1
|
+
import { IComputedRoutesArray } from '../interfaces';
|
|
2
|
+
export declare const getSortedRoutes: (path: string, routeData: IComputedRoutesArray, authWrapper?: (ele: React.ReactElement, props: Record<string, any>) => void) => any;
|
|
3
|
+
export declare function getRoutes(path: string, routeData: IComputedRoutesArray, authWrapper?: (ele: any, props: any) => void): any;
|
package/lib/route/get-routes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IMenuPosition}from'
|
|
1
|
+
import {IMenuPosition}from'@common-stack/core/lib/component/interfaces/menu.js';import {sortKeys}from'../utils/sort-keys.js';import {formatSlash}from'../utils/utils.js';// Function to get sorted routes based on a given path, route data, and an optional authentication wrapper.
|
|
2
2
|
const getSortedRoutes = (path, routeData, authWrapper = null) => {
|
|
3
3
|
// Sort the keys of the route data for consistency.
|
|
4
4
|
const sortedRoutes = sortKeys(routeData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-routes.js","sources":["../../src/route/get-routes.tsx"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-routes.js","sources":["../../src/route/get-routes.tsx"],"sourcesContent":[null],"names":[],"mappings":"yKAIA;AACO,MAAM,eAAe,GAAG,CAC3B,IAAY,EACZ,SAA+B,EAC/B,WAAA,GAA6E,IAAI,KACjF;;AAEA,IAAA,MAAM,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null;
|
|
7
|
-
index?: boolean;
|
|
8
|
-
path?: string;
|
|
9
|
-
exact?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare const getSortedNavigations: (path: string, routeData: IRouteData, authWrapper?: ((component: React.FC) => ReactElement)) => any;
|
|
12
|
-
export declare function getNavigation(path: string, routeData: any, authWrapper?: ((component: React.FC, unauthenticatedComponent: React.FC) => ReactElement)): any;
|
|
2
|
+
import { IComputedMobileRoutesArray } from './interfaces/route';
|
|
3
|
+
export declare const getSortedNavigations: (path: string, routeData: IComputedMobileRoutesArray, authWrapper?: (component: React.FC) => ReactElement) => any;
|
|
4
|
+
export declare function getNavigation(path: string, routeData: IComputedMobileRoutesArray, authWrapper?: (component: React.FC, unauthenticatedComponent: React.FC) => ReactElement): import("packages/common-core/lib").IMenuDataItem[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {uniq,isEmpty}from'lodash-es';import {IMenuPosition}from'
|
|
1
|
+
import {uniq,isEmpty}from'lodash-es';import {IMenuPosition}from'@common-stack/core/lib/component/interfaces/menu.js';import {sortKeys}from'../../utils/sort-keys.js';import {formatSlash}from'../../utils/utils.js';import'@common-stack/client-core';const getSortedNavigations = (path, routeData, authWrapper) => {
|
|
2
2
|
const sortedRoutes = sortKeys(routeData);
|
|
3
3
|
const result = addRouteParams(getNavigation(path, sortedRoutes, authWrapper));
|
|
4
4
|
return result;
|
|
@@ -10,9 +10,9 @@ const addRouteParams = (result, routeParams = []) => {
|
|
|
10
10
|
item.routeParams = params;
|
|
11
11
|
}
|
|
12
12
|
if (item?.children?.length) {
|
|
13
|
-
if (item.path !== '/' && item.path.includes(
|
|
13
|
+
if (item.path !== '/' && item.path.includes(':')) {
|
|
14
14
|
const matched = item.path.match(/:([^\/]+)/g);
|
|
15
|
-
params = uniq(params.concat(...matched.map((item) => item.replace(':',
|
|
15
|
+
params = uniq(params.concat(...matched.map((item) => item.replace(':', ''))));
|
|
16
16
|
}
|
|
17
17
|
item.children = addRouteParams(item.children, uniq(params));
|
|
18
18
|
}
|
|
@@ -27,10 +27,10 @@ function getNavigation(path, routeData, authWrapper) {
|
|
|
27
27
|
if (path[path.length - 1] !== '/') {
|
|
28
28
|
searchPath = path + '/';
|
|
29
29
|
}
|
|
30
|
-
const childrens = Object.keys(routeData).filter(menuPath => {
|
|
30
|
+
const childrens = Object.keys(routeData).filter((menuPath) => {
|
|
31
31
|
return menuPath.indexOf(searchPath) === 0 || menuPath === path;
|
|
32
32
|
});
|
|
33
|
-
const mappedMenuPaths = childrens.map(mPath => {
|
|
33
|
+
const mappedMenuPaths = childrens.map((mPath) => {
|
|
34
34
|
return {
|
|
35
35
|
route: mPath,
|
|
36
36
|
position: IMenuPosition.Middle,
|
|
@@ -43,7 +43,7 @@ function getNavigation(path, routeData, authWrapper) {
|
|
|
43
43
|
name: 'root',
|
|
44
44
|
position: IMenuPosition.Logo,
|
|
45
45
|
};
|
|
46
|
-
mappedMenuPaths.forEach(routeItem => {
|
|
46
|
+
mappedMenuPaths.forEach((routeItem) => {
|
|
47
47
|
const children = routeItem.route.split('/');
|
|
48
48
|
children.shift();
|
|
49
49
|
// if the route is `/` then add this correction.
|
|
@@ -54,7 +54,7 @@ function getNavigation(path, routeData, authWrapper) {
|
|
|
54
54
|
const depth = children.length;
|
|
55
55
|
let lastNode = root;
|
|
56
56
|
for (let i = 0; i < depth; i++) {
|
|
57
|
-
const lastIndex = (lastNode.children || []).findIndex(item => {
|
|
57
|
+
const lastIndex = (lastNode.children || []).findIndex((item) => {
|
|
58
58
|
const routePath = `${item._pathPrefix}${item.path}`;
|
|
59
59
|
if (routeItem.route.startsWith(routePath)) {
|
|
60
60
|
// only if the parent path has `exact: false` allows to nested
|
|
@@ -78,12 +78,12 @@ function getNavigation(path, routeData, authWrapper) {
|
|
|
78
78
|
...(!isEmpty(rest.props) && {
|
|
79
79
|
props: {
|
|
80
80
|
...rest.props,
|
|
81
|
-
...(rest.props.component
|
|
82
|
-
&&
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
81
|
+
...(rest.props.component && {
|
|
82
|
+
component: auth && authWrapper
|
|
83
|
+
? authWrapper(rest.props?.component, rest.props?.unauthenticatedComponent)
|
|
84
|
+
: rest.props?.component,
|
|
85
|
+
}),
|
|
86
|
+
},
|
|
87
87
|
}),
|
|
88
88
|
// path: formatSlash(routeItem.route),
|
|
89
89
|
// path: routeItem.route,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-navigation-utils.js","sources":["../../../src/route/react-navigation/get-navigation-utils.tsx"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-navigation-utils.js","sources":["../../../src/route/react-navigation/get-navigation-utils.tsx"],"sourcesContent":[null],"names":[],"mappings":"sPAQa,MAAA,oBAAoB,GAAG,CAChC,IAAY,EACZ,SAAqC,EACrC,WAAmD,KACnD;AACA,IAAA,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AACzC,IAAA,MAAM,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AAC9E,IAAA,OAAO,MAAM,CAAC;AAClB,EAAE;AAEF,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,EAAE,KAAI;AAChD,IAAA,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;QACvB,IAAI,MAAM,GAAG,WAAW,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;AAClC,YAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;SAC7B;AACD,QAAA,IAAI,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE;AACxB,YAAA,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAC9C,MAAM,OAAO,GAAG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0 +1,16 @@
|
|
|
1
|
+
import type { createStackNavigator } from '@react-navigation/stack';
|
|
2
|
+
import type { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
3
|
+
import type { createDrawerNavigator } from '@react-navigation/drawer';
|
|
4
|
+
import type { IRouteMobileAdditions, IReactNavigationProps } from '@common-stack/core/lib/component/interfaces/routeMobileAdditions.js';
|
|
5
|
+
import type { IRollupBuildGenerated } from '@common-stack/core/lib/component/interfaces/rollupRouteGenerated.js';
|
|
6
|
+
import type { IRouteMap, IRouteModule } from '../../../interfaces';
|
|
7
|
+
export { IReactNavigationProps };
|
|
8
|
+
type OptionalPath<T extends {
|
|
9
|
+
path: string;
|
|
10
|
+
}> = Omit<T, 'path'> & Partial<Pick<T, 'path'>>;
|
|
11
|
+
export interface IReactNavigationRoute extends IRouteMobileAdditions {
|
|
12
|
+
container?: ReturnType<typeof createStackNavigator> | ReturnType<typeof createBottomTabNavigator> | ReturnType<typeof createDrawerNavigator>;
|
|
13
|
+
}
|
|
14
|
+
export type IRouteMobileModule = IRouteModule & IReactNavigationRoute;
|
|
15
|
+
export type IRouteMapWithMobile = IRouteMap<IRollupBuildGenerated & OptionalPath<IReactNavigationRoute>>;
|
|
16
|
+
export type IComputedMobileRoutesArray = Array<IRouteMapWithMobile>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import*as React from'react';import {Routes}from'react
|
|
1
|
+
import*as React from'react';import {Routes}from'@remix-run/react';import {Feature}from'../connector/connector.js';const routerFactory = (routes) => React.createElement(Routes, null, routes);
|
|
2
2
|
const FeatureWithRouterFactory = new Feature({
|
|
3
3
|
routerFactory,
|
|
4
4
|
});export{FeatureWithRouterFactory};//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IRouteMap, IRouteModule } from '../interfaces';
|
|
1
2
|
type SelectedType = '*' | string[];
|
|
2
|
-
export declare const getFilteredMenus: (accountPageStore:
|
|
3
|
-
export declare const getFilteredRoutes: (accountPageStore:
|
|
4
|
-
export declare const getFilteredTabs: (accountPageStore:
|
|
3
|
+
export declare const getFilteredMenus: (accountPageStore: IRouteModule[], selectedMenu?: SelectedType) => IRouteMap[];
|
|
4
|
+
export declare const getFilteredRoutes: (accountPageStore: IRouteModule[], selectedRoutes?: SelectedType) => IRouteMap[];
|
|
5
|
+
export declare const getFilteredTabs: (accountPageStore: IRouteModule[], selectedTabs?: SelectedType) => Omit<IRouteModule, "component">[];
|
|
5
6
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filteredRoutes.js","sources":["../../src/utils/filteredRoutes.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filteredRoutes.js","sources":["../../src/utils/filteredRoutes.ts"],"sourcesContent":[null],"names":[],"mappings":"AAKO,MAAM,gBAAgB,GAAG,CAAC,gBAAgC,EAAE,YAAA,GAAe,GAAmB,KACjG,gBAAgB;AACX,KAAA,GAAG,CAAC,CAAC,IAAI,KAAI;AACV,IAAA,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACzD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;QAC1C,OAAO;AACH,YAAA,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE;SACtC,CAAC;KACL;AACD,IAAA,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;KACD,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE;AAE3B,MAAM,iBAAiB,GAAG,CAC7B,gBAAgC,EAChC,cAAA,GAAiB,GAAmB,KAEpC,gBAAgB;AACX,KAAA,GAAG,CAAC,CAAC,IAAI,KAAI;AACV,IAAA,IAAI,cAAc,KAAK,GAAG,IAAI,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAC7D,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,OAAO;YACH,CAAC,IAAI,GAAG,IAAI;SACf,CAAC;KACL;AACD,IAAA,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;KACD,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE;AAE3B,MAAM,eAAe,GAAG,CAC3B,gBAAgC,EAChC,YAAA,GAAe,GAAmB,KAElC,gBAAgB;AACX,KAAA,GAAG,CAAC,CAAC,IAAI,KAAI;AACV,IAAA,IAAI,YAAY,KAAK,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACzD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AACpC,QAAA,OAAO,IAAI,CAAC;KACf;AACD,IAAA,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;KACD,MAAM,CAAC,CAAC,KAAK,KAAK,KAAK"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { IRouteModule } from '../interfaces';
|
|
2
|
+
export declare function findRouteByPath(routes: IRouteModule[], targetPath: string): any;
|
package/lib/utils/sort-keys.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
1
|
+
import { IRouteModule, IComputedRoutesArray } from '../interfaces';
|
|
2
|
+
export declare function sortKeys(routeData: IComputedRoutesArray): IComputedRoutesArray;
|
|
3
|
+
export declare function sortByPaths(routes: IRouteModule[]): (Omit<IRouteModule, "path"> & Partial<Pick<IRouteModule, "path">>)[];
|
package/lib/utils/sort-keys.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import defaultSortKeys from'sort-keys'
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import defaultSortKeys from'sort-keys';/* eslint-disable no-param-reassign */
|
|
2
|
+
function notStartWithColon(str) {
|
|
3
|
+
const match = (str.match(/^[\/, *, :]{1,}/) || [-1])[0];
|
|
4
|
+
if (match === -1) {
|
|
5
|
+
return -1;
|
|
6
|
+
}
|
|
7
|
+
let i = match.length;
|
|
8
|
+
let count = 0;
|
|
9
|
+
while (i--) {
|
|
10
|
+
const char = match[i];
|
|
11
|
+
if (char === '/') {
|
|
12
|
+
if (str === '/') {
|
|
13
|
+
// if it is root only we put at the last
|
|
14
|
+
count += 6;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
count += 3;
|
|
18
|
+
}
|
|
9
19
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
else if (char === ':') {
|
|
21
|
+
count += 1;
|
|
22
|
+
}
|
|
23
|
+
else if (char === '*') {
|
|
24
|
+
count += 2;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return count;
|
|
14
28
|
}
|
|
15
29
|
const compare = (a, b) => {
|
|
16
30
|
const aStr = String(a).toLowerCase();
|
|
@@ -50,30 +64,17 @@ const compare = (a, b) => {
|
|
|
50
64
|
// In all other cases, default to usual sort order.
|
|
51
65
|
return aStr.localeCompare(bStr);
|
|
52
66
|
};
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const char = match[i];
|
|
62
|
-
if (char === '/') {
|
|
63
|
-
if (str === '/') {
|
|
64
|
-
// if it is root only we put at the last
|
|
65
|
-
count += 6;
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
count += 3;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else if (char === ':') {
|
|
72
|
-
count += 1;
|
|
73
|
-
}
|
|
74
|
-
else if (char === '*') {
|
|
75
|
-
count += 2;
|
|
67
|
+
function sortKeys(routeData) {
|
|
68
|
+
return defaultSortKeys(routeData, { compare });
|
|
69
|
+
}
|
|
70
|
+
function sortByPaths(routes) {
|
|
71
|
+
const routeData = {};
|
|
72
|
+
routes.forEach((route) => {
|
|
73
|
+
if (typeof route.path === 'undefined') {
|
|
74
|
+
route.path = '*';
|
|
76
75
|
}
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
routeData[route.path] = route;
|
|
77
|
+
});
|
|
78
|
+
const sortedRoutes = defaultSortKeys(routeData, { compare });
|
|
79
|
+
return Object.keys(sortedRoutes).map((key) => sortedRoutes[key]);
|
|
79
80
|
}export{sortByPaths,sortKeys};//# sourceMappingURL=sort-keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-keys.js","sources":["../../src/utils/sort-keys.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-keys.js","sources":["../../src/utils/sort-keys.ts"],"sourcesContent":[null],"names":[],"mappings":"uCAAA;AAIA,SAAS,iBAAiB,CAAC,GAAG,EAAA;AAC1B,IAAA,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxD,IAAA,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;QACd,OAAO,CAAC,CAAC,CAAC;KACb;AACD,IAAA,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IACrB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,EAAE;AACR,QAAA,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AACtB,QAAA,IAAI,IAAI,KAAK,GAAG,EAAE;AACd,YAAA,IAAI,GAAG,KAAK,GAAG,EAAE;;gBAEb,KAAK,IAAI,CAAC,CAAC;aACd;iBAAM;gBACH,KAAK,IAAI,CAAC,CAAC;aACd;SACJ;AAAM,aAAA,IAAI,IAAI,KAAK,GAAG,EAAE;YACrB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AGD,IAAA,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC,CAAC;AAEI,SAAU,QAAQ,CAAC,SAA+B,EAAA;IACpD,OAAO,eAAe,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC;AAEK,SAAU,WAAW,CAAC,MAAsB,EAAA;IAC9C,MAAM,SAAS,GAAc,EAAE,CAAC;AAChC,IAAA,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;AACrB,QAAA,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;AACnC,YAAA,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;SACpB;AACD,QAAA,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAClC,KAAC,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7D,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;AACrE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/client-react",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2-alpha.0",
|
|
4
4
|
"description": "Client Module for react app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"test": "jest",
|
|
28
28
|
"test:debug": "npm test -- --runInBand",
|
|
29
29
|
"test:watch": "npm test -- --watch",
|
|
30
|
+
"vitest": "vitest",
|
|
30
31
|
"watch": "npm run build:lib:watch"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@common-stack/client-core": "8.0.
|
|
34
|
-
"@common-stack/core": "8.0.
|
|
34
|
+
"@common-stack/client-core": "8.0.2-alpha.0",
|
|
35
|
+
"@common-stack/core": "8.0.2-alpha.0",
|
|
35
36
|
"@wordpress/hooks": "^3.53.0",
|
|
36
37
|
"browser-bunyan": "^1.6.3",
|
|
37
38
|
"history-with-query": "^4.10.4",
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"typescript": {
|
|
60
61
|
"definition": "lib/index.d.ts"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d45864ba7429065d7b67e573e909ecf762ffc150"
|
|
63
64
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'jest';
|
package/lib/interfaces/menu.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
var IMenuPosition;
|
|
2
|
-
(function (IMenuPosition) {
|
|
3
|
-
IMenuPosition["LOGO"] = "LOGO";
|
|
4
|
-
IMenuPosition["UPPER"] = "UPPER";
|
|
5
|
-
IMenuPosition["MIDDLE"] = "MIDDLE";
|
|
6
|
-
IMenuPosition["LOWER"] = "LOWER";
|
|
7
|
-
IMenuPosition["BOTTOM"] = "BOTTOM";
|
|
8
|
-
IMenuPosition["Logo"] = "LOGO";
|
|
9
|
-
IMenuPosition["Upper"] = "UPPER";
|
|
10
|
-
IMenuPosition["Middle"] = "MIDDLE";
|
|
11
|
-
IMenuPosition["Lower"] = "LOWER";
|
|
12
|
-
IMenuPosition["Bottom"] = "BOTTOM";
|
|
13
|
-
})(IMenuPosition || (IMenuPosition = {}));export{IMenuPosition};//# sourceMappingURL=menu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"menu.js","sources":["../../src/interfaces/menu.ts"],"sourcesContent":[null],"names":[],"mappings":"IA8GY,cAWX;AAXD,CAAA,UAAY,aAAa,EAAA;AACrB,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACrB,CAAC,EAXW,aAAa,KAAb,aAAa,GAWxB,EAAA,CAAA,CAAA"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { FunctionComponent } from 'react';
|
|
2
|
-
import { matchPath, ActionFunction } from 'react-router-dom';
|
|
3
|
-
export interface IComponent extends FunctionComponent {
|
|
4
|
-
getInitialProps?: Function;
|
|
5
|
-
preload?: () => Promise<any>;
|
|
6
|
-
}
|
|
7
|
-
export interface IRouterRederOptions {
|
|
8
|
-
routes: IRoute[];
|
|
9
|
-
plugin?: Plugin;
|
|
10
|
-
extraProps?: object;
|
|
11
|
-
pageInitialProps?: object;
|
|
12
|
-
getInitialPropsCtx?: object;
|
|
13
|
-
isServer?: boolean;
|
|
14
|
-
ssrProps?: object;
|
|
15
|
-
rootRoutes?: IRoute[];
|
|
16
|
-
auth?: boolean;
|
|
17
|
-
key?: any;
|
|
18
|
-
authWrapper?: () => void;
|
|
19
|
-
withRoutesElement?: boolean;
|
|
20
|
-
loaderArgs?: any;
|
|
21
|
-
}
|
|
22
|
-
export interface IGetRouteElementOpts {
|
|
23
|
-
route: IRoute;
|
|
24
|
-
index: number;
|
|
25
|
-
opts: IRouterRederOptions;
|
|
26
|
-
}
|
|
27
|
-
export interface IRouteMap<T = unknown> {
|
|
28
|
-
[key: string]: IRoute & T;
|
|
29
|
-
}
|
|
30
|
-
export interface IRoute {
|
|
31
|
-
path?: string;
|
|
32
|
-
index?: boolean;
|
|
33
|
-
exact?: boolean;
|
|
34
|
-
redirect?: string;
|
|
35
|
-
component?: IComponent | null;
|
|
36
|
-
routes?: IRoute[];
|
|
37
|
-
key?: any;
|
|
38
|
-
strict?: boolean;
|
|
39
|
-
sensitive?: boolean;
|
|
40
|
-
wrappers?: any[];
|
|
41
|
-
loader?: (any: any) => any;
|
|
42
|
-
action?: ActionFunction;
|
|
43
|
-
[k: string]: any;
|
|
44
|
-
}
|
|
45
|
-
export interface IRouteComponentProps<Params extends {
|
|
46
|
-
[K in keyof Params]?: string;
|
|
47
|
-
} = {}, Query extends {
|
|
48
|
-
[K in keyof Query]?: string;
|
|
49
|
-
} = {}> {
|
|
50
|
-
children: JSX.Element;
|
|
51
|
-
location: any /** Location & { query: Query }; * */;
|
|
52
|
-
route: IRoute;
|
|
53
|
-
history: any /** History;* */;
|
|
54
|
-
match: typeof matchPath;
|
|
55
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export interface ICoreRouteData<T> {
|
|
2
|
-
[key: string]: {
|
|
3
|
-
loading?: T;
|
|
4
|
-
component?: any;
|
|
5
|
-
container?: any;
|
|
6
|
-
name?: string;
|
|
7
|
-
props?: Object;
|
|
8
|
-
exact?: boolean;
|
|
9
|
-
strict?: boolean;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
interface CommonMenuData {
|
|
13
|
-
/** @name hideSelf and children in menu */
|
|
14
|
-
hideInMenu?: boolean;
|
|
15
|
-
/** @name Hide child nodes in the menu */
|
|
16
|
-
hideChildrenInMenu?: boolean;
|
|
17
|
-
/** @name Internationalization key for custom menus */
|
|
18
|
-
locale?: string | false;
|
|
19
|
-
/** @name The name of the menu */
|
|
20
|
-
name?: string;
|
|
21
|
-
/** @name is used to calibrate the selected value, default is path */
|
|
22
|
-
key?: string;
|
|
23
|
-
/** @name Icon of the menu */
|
|
24
|
-
icon?: any;
|
|
25
|
-
/** @name disable menu option */
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
/** @name hides itself and elevates child nodes to its level */
|
|
28
|
-
flatMenu?: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface IMappedData extends CommonMenuData {
|
|
31
|
-
/** @name path */
|
|
32
|
-
path?: string;
|
|
33
|
-
component?: any;
|
|
34
|
-
route?: string;
|
|
35
|
-
exact?: boolean;
|
|
36
|
-
strict?: boolean;
|
|
37
|
-
[key: string]: any;
|
|
38
|
-
}
|
|
39
|
-
export interface IRouteData extends ICoreRouteData<React.ComponentType<any> | (() => null)> {
|
|
40
|
-
}
|
|
41
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import 'jest';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {IMenuPosition}from'../../interfaces/menu.js';function getMenus(path, menuData) {
|
|
2
|
-
if (!path.startsWith('/')) {
|
|
3
|
-
throw new Error('Invalid path!');
|
|
4
|
-
}
|
|
5
|
-
let searchPath = path;
|
|
6
|
-
if (path[path.length - 1] !== '/') {
|
|
7
|
-
searchPath = path + '/';
|
|
8
|
-
}
|
|
9
|
-
const routes = Object.keys(menuData).filter(menuPath => {
|
|
10
|
-
return menuPath.indexOf(searchPath) === 0 || menuPath === path;
|
|
11
|
-
});
|
|
12
|
-
const mappedMenuPaths = routes.map(mPath => {
|
|
13
|
-
return {
|
|
14
|
-
route: mPath,
|
|
15
|
-
position: IMenuPosition.Middle,
|
|
16
|
-
...menuData[mPath],
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
const root = {
|
|
20
|
-
// just to satisfy types added following
|
|
21
|
-
// TOOD need to correct types so we don't have to enter them.
|
|
22
|
-
name: 'root',
|
|
23
|
-
position: IMenuPosition.Logo,
|
|
24
|
-
};
|
|
25
|
-
mappedMenuPaths.forEach(menutItem => {
|
|
26
|
-
const children = menutItem.route.split('/');
|
|
27
|
-
children.shift();
|
|
28
|
-
const depth = children.length;
|
|
29
|
-
let lastNode = root;
|
|
30
|
-
for (let i = 0; i < depth; i++) {
|
|
31
|
-
const lastIndex = (lastNode.children || []).findIndex(item => {
|
|
32
|
-
if (menutItem.route.startsWith(item.path)) {
|
|
33
|
-
return menutItem.route[item.path.length] === '/';
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
if (lastIndex === -1) {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
lastNode = lastNode.children[lastIndex];
|
|
40
|
-
// do not overwrite the route's exact value
|
|
41
|
-
lastNode.exact = menuData[lastNode.path].hasOwnProperty('exact') ? menuData[lastNode.path].exact : false;
|
|
42
|
-
}
|
|
43
|
-
if (!lastNode.children) {
|
|
44
|
-
lastNode.children = [];
|
|
45
|
-
}
|
|
46
|
-
const { route: ignore, ...rest } = menutItem;
|
|
47
|
-
lastNode.children.push({
|
|
48
|
-
path: menutItem.route,
|
|
49
|
-
...rest,
|
|
50
|
-
exact: menuData[menutItem.route].hasOwnProperty('exact') ? menuData[menutItem.route].exact : true,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
return root.children;
|
|
54
|
-
}export{getMenus};//# sourceMappingURL=get-menus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-menus.js","sources":["../../../src/route/old/get-menus.ts"],"sourcesContent":[null],"names":[],"mappings":"qDAEgB,SAAA,QAAQ,CAAC,IAAY,EAAE,QAAmB,EAAA;IACtD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AACvB,QAAA,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;KACpC;IACD,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;AAC/B,QAAA,UAAU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AAC,CAAC;AACH,YAAA,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;gBAClB,MAAM;aACT;AACD,YAAA,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;;AAExC,YAAA,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC;SAC5G;AACD,QAAA,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;AACpB,YAAA,QAAQ,CAAC,QAAQ,GAAG,EAAE,CAAC;SAC1B;QACD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC;AAC7C,QAAA,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,SAAS,CAAC,KAAK;AACrB,YAAA,GAAG,IAAI;YACP,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI;AACpG,SAAA,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,QAAQ,CAAC;AACzB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IRouteData } from '../../interfaces';
|
|
2
|
-
export declare function isUrl(path: any): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* Generates Routes based on the key value, where key has the path of the route and value
|
|
5
|
-
* has rest of the values for building a `<Router ../>` component.
|
|
6
|
-
*
|
|
7
|
-
* @param path: RegExp
|
|
8
|
-
* @param routerData
|
|
9
|
-
* @deprecated
|
|
10
|
-
*/
|
|
11
|
-
export declare function getRoutes2(path: RegExp, routerData: IRouteData): any;
|
package/lib/route/old/render.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import*as React from'react';import {Routes,Route}from'react-router-dom';const renderRoutes = (routes, solidRoutes, extraProps = {}) => routes ? (React.createElement(Routes, null, [
|
|
2
|
-
...solidRoutes,
|
|
3
|
-
...routes.map((route, i) => (React.createElement(Route, { key: route.key || i, path: route.path, element: route.render
|
|
4
|
-
? React.createElement(route.render, { ...extraProps, route: route })
|
|
5
|
-
: React.createElement(route.component, { ...extraProps, route: route }) }))),
|
|
6
|
-
])) : null;export{renderRoutes};//# sourceMappingURL=render.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sources":["../../../src/route/old/render.tsx"],"sourcesContent":[null],"names":[],"mappings":"8EAGa,YAAY,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,GAAG,EAAE,KAC7D,MAAM,IACF,KAAC,CAAA,aAAA,CAAA,MAAM,EACF,IAAA,EAAA;AACG,IAAA,GAAG,WAAW;AACd,IAAA,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,MACnB,KAAA,CAAA,aAAA,CAAC,KAAK,EACF,EAAA,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,EACnB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EACH,KAAK,CAAC,MAAM;AACR,cAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;cAClE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAA,CAEjF,CACL,CAAC;AACL,CAAA,CACI,IACT"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import*as React from'react';import {useState,useEffect,cloneElement,createElement}from'react';import {Routes,Route,Navigate,useLocation}from'react-router-dom';import {sortByPaths}from'../utils/sort-keys.js';import'lodash-es';import'@common-stack/client-core';function createRouteElement(route, { isServer, withRoutesElement, ...options }, children) {
|
|
2
|
-
if (typeof route.redirect === "string") {
|
|
3
|
-
return React.createElement(Navigate, { to: route.redirect, replace: true });
|
|
4
|
-
}
|
|
5
|
-
if (!route.component) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
const Component = route.component;
|
|
9
|
-
const routeProps = { route, routes: options.routes };
|
|
10
|
-
function ComponentWithRoute(innerProps) {
|
|
11
|
-
const [initialProps, setInitialProps] = useState({});
|
|
12
|
-
const location = useLocation();
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
handleInitialProps(routeProps);
|
|
15
|
-
}, []);
|
|
16
|
-
const handleInitialProps = async (param) => {
|
|
17
|
-
if (typeof Component.getInitialProps === "function") {
|
|
18
|
-
const initialProps = await Component.getInitialProps(param);
|
|
19
|
-
setInitialProps(initialProps);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const cloneChild = (ui, props) => {
|
|
23
|
-
if (ui) {
|
|
24
|
-
return cloneElement(ui, props);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return createElement(React.Fragment, props);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
if (isServer) {
|
|
31
|
-
// Since React.useEffect will not run in server side,
|
|
32
|
-
// this function will be called manually.
|
|
33
|
-
handleInitialProps(routeProps);
|
|
34
|
-
}
|
|
35
|
-
let childrenElement = null;
|
|
36
|
-
if (children) {
|
|
37
|
-
childrenElement = !!withRoutesElement ?
|
|
38
|
-
React.Children.map(children, (child, key) => cloneChild(child.props.element, { key })) :
|
|
39
|
-
children.map((child, key) => cloneChild(child.element, { key }));
|
|
40
|
-
}
|
|
41
|
-
return (React.createElement(Component, { ...routeProps, ...initialProps, ...innerProps, location: location }, childrenElement));
|
|
42
|
-
}
|
|
43
|
-
let routeElement = React.createElement(ComponentWithRoute, null);
|
|
44
|
-
const wrappers = route.wrappers || [];
|
|
45
|
-
let len = wrappers.length - 1;
|
|
46
|
-
while (len >= 0) {
|
|
47
|
-
const Wrapper = wrappers[len];
|
|
48
|
-
routeElement = React.createElement(Wrapper, { ...routeProps }, routeElement);
|
|
49
|
-
len -= 1;
|
|
50
|
-
}
|
|
51
|
-
return routeElement;
|
|
52
|
-
}
|
|
53
|
-
function getRoute({ key, options, route, }) {
|
|
54
|
-
const { index, path, sensitive, routes, ...routeOptions } = route;
|
|
55
|
-
const routeObject = {
|
|
56
|
-
path: !!index ? null : path,
|
|
57
|
-
index: !!index,
|
|
58
|
-
caseSensitive: !!sensitive,
|
|
59
|
-
children: getRoutes({ options, routes: routes }),
|
|
60
|
-
...routeOptions,
|
|
61
|
-
};
|
|
62
|
-
if (routeOptions?.loader) {
|
|
63
|
-
routeObject.loader = (loaderContext) => { return routeOptions?.loader({ ...loaderContext, ...options.loaderArgs }); };
|
|
64
|
-
}
|
|
65
|
-
routeObject.element = createRouteElement(route, { ...options, key }, routeObject.children);
|
|
66
|
-
return routeObject;
|
|
67
|
-
}
|
|
68
|
-
function renderRoute(params) {
|
|
69
|
-
const routeObject = getRoute(params);
|
|
70
|
-
return !!params.options.withRoutesElement ?
|
|
71
|
-
React.createElement(Route, { key: params.key, ...routeObject }) : routeObject;
|
|
72
|
-
}
|
|
73
|
-
function getRoutes({ routes, options }) {
|
|
74
|
-
if (routes) {
|
|
75
|
-
const sortedRoutes = sortByPaths(routes);
|
|
76
|
-
return (sortedRoutes.map((route, key) => {
|
|
77
|
-
return renderRoute({
|
|
78
|
-
key,
|
|
79
|
-
options,
|
|
80
|
-
route,
|
|
81
|
-
});
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
function renderRoutes(options) {
|
|
87
|
-
if (options.routes) {
|
|
88
|
-
const routes = getRoutes({
|
|
89
|
-
options,
|
|
90
|
-
routes: options.routes,
|
|
91
|
-
});
|
|
92
|
-
return !!options.withRoutesElement ?
|
|
93
|
-
React.createElement(Routes, null, routes) : routes;
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}export{renderRoutes as renderRoutes2};//# sourceMappingURL=render-routes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-routes.js","sources":["../../src/route/render-routes.tsx"],"sourcesContent":[null],"names":[],"mappings":"mQAyJA,SAAS,kBAAkB,CAAC,KAAa,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE,GAAG,OAAO,EAAuB,EAAE,QAAa,EAAA;AACxH,IAAA,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,EAAE;AACtC,QAAA,OAAO,KAAC,CAAA,aAAA,CAAA,QAAQ,EAAC,EAAA,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAI,CAAC;KACxD;AAED,IAAA,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;AACpB,QAAA,OAAO,IAAI,CAAC;KACb;AAED,IAAA,MAAM,SAAS,GAAQ,KAAK,CAAC,SAAS,CAAC;IACvC,MAAM,UAAU,GAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IAE1D,SAAS,kBAAkB,CAAC,UAAe,EAAA;QACzC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;AACrD,QAAA,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;QAE/B,SAAS,CAAC,MAAK;YACb,kBAAkB,CAAC,UAAU,CAAC,CAAC;SAChC,EAAE,EAAE,CAAC,CAAC;AAEP,QAAA,MAAM,kBAAkB,GAAG,OAAO,KAAK,KAAI;AACzC,YAAA,IAAI,OAAO,SAAS,CAAC,eAAe,KAAK,UAAU,EAAE;gBACnD,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;gBAC5D,eAAe,CAAC,YAAY,CAAC,CAAC;aAC/B;A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