@lemon-fe/kits 1.2.13 → 1.2.14
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/es/hooks/use-batch-operator/index.js +3 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/layouts/index.d.ts +1 -0
- package/es/layouts/index.js +2 -1
- package/es/layouts/simple-layout/index.d.ts +5 -0
- package/es/layouts/simple-layout/index.js +148 -0
- package/es/layouts/simple-layout/locale/en_US.d.ts +3 -0
- package/es/layouts/simple-layout/locale/en_US.js +5 -0
- package/es/layouts/simple-layout/locale/locale.d.ts +4 -0
- package/es/layouts/simple-layout/locale/locale.js +1 -0
- package/es/layouts/simple-layout/locale/zh_CN.d.ts +3 -0
- package/es/layouts/simple-layout/locale/zh_CN.js +5 -0
- package/es/layouts/simple-layout/typings.d.ts +28 -0
- package/package.json +3 -3
|
@@ -692,7 +692,9 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
692
692
|
results: results
|
|
693
693
|
},
|
|
694
694
|
columns: cols,
|
|
695
|
-
rowKey: rowKey
|
|
695
|
+
rowKey: rowKey,
|
|
696
|
+
localeText: this.props.locale.DataGrid.localeText,
|
|
697
|
+
locale: this.props.locale.DataGrid
|
|
696
698
|
})
|
|
697
699
|
})
|
|
698
700
|
})
|
package/es/index.d.ts
CHANGED
|
@@ -4,8 +4,10 @@ export * from '@lemon-fe/utils';
|
|
|
4
4
|
export { default as BasicLayout } from './layouts/basic-layout';
|
|
5
5
|
export type { BasicLayoutLocale } from './layouts/basic-layout/locale/locale';
|
|
6
6
|
export type { MicroLayoutLocale } from './layouts/micro-layout/locale/locale';
|
|
7
|
+
export type { SimpleLayoutLocale } from './layouts/simple-layout/locale/locale';
|
|
7
8
|
export { default as BlankLayout } from './layouts/blank-layout';
|
|
8
9
|
export { default as MicroLayout } from './layouts/micro-layout';
|
|
10
|
+
export { default as SimpleLayout } from './layouts/simple-layout';
|
|
9
11
|
export { default as Breadcrumb } from './layouts/breadcrumb';
|
|
10
12
|
export { default as useBatchOperator } from './hooks/use-batch-operator';
|
|
11
13
|
export { default as useHistoryBlock } from './hooks/use-history-block';
|
package/es/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from '@lemon-fe/utils';
|
|
|
4
4
|
export { default as BasicLayout } from "./layouts/basic-layout";
|
|
5
5
|
export { default as BlankLayout } from "./layouts/blank-layout";
|
|
6
6
|
export { default as MicroLayout } from "./layouts/micro-layout";
|
|
7
|
+
export { default as SimpleLayout } from "./layouts/simple-layout";
|
|
7
8
|
export { default as Breadcrumb } from "./layouts/breadcrumb";
|
|
8
9
|
export { default as useBatchOperator } from "./hooks/use-batch-operator";
|
|
9
10
|
export { default as useHistoryBlock } from "./hooks/use-history-block";
|
package/es/layouts/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { default as BasicLayout } from './basic-layout';
|
|
|
2
2
|
export { default as BlankLayout } from './blank-layout';
|
|
3
3
|
export { default as MicroLayout } from './micro-layout';
|
|
4
4
|
export { default as Breadcrumb } from './breadcrumb';
|
|
5
|
+
export { default as SimpleLayout } from './simple-layout';
|
package/es/layouts/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as BasicLayout } from "./basic-layout";
|
|
2
2
|
export { default as BlankLayout } from "./blank-layout";
|
|
3
3
|
export { default as MicroLayout } from "./micro-layout";
|
|
4
|
-
export { default as Breadcrumb } from "./breadcrumb";
|
|
4
|
+
export { default as Breadcrumb } from "./breadcrumb";
|
|
5
|
+
export { default as SimpleLayout } from "./simple-layout";
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
import { Button, Result } from 'antd';
|
|
8
|
+
import React, { memo, useEffect } from 'react';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
11
|
+
import { matchPath, useHistory } from 'react-router-dom';
|
|
12
|
+
import RouteTab from "../components/route-tab";
|
|
13
|
+
import { useLastestRef } from '@lemon-fe/hooks';
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
function isSubPath(path, subPath) {
|
|
17
|
+
var pathArr = path.split('/');
|
|
18
|
+
var subPathArr = subPath.split('/');
|
|
19
|
+
if (path.length > subPath.length) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
for (var i = 0; i < pathArr.length; i++) {
|
|
23
|
+
if (subPathArr[i] !== pathArr[i]) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function SimpleLayout(props) {
|
|
30
|
+
var _tabs$active;
|
|
31
|
+
var _props$routes = props.routes,
|
|
32
|
+
routes = _props$routes === void 0 ? [] : _props$routes,
|
|
33
|
+
authorities = props.authorities,
|
|
34
|
+
tabs = props.tabs,
|
|
35
|
+
active = props.active;
|
|
36
|
+
var history = useHistory();
|
|
37
|
+
var auth = useMemo(function () {
|
|
38
|
+
if (authorities === undefined || authorities === null) {
|
|
39
|
+
return authorities;
|
|
40
|
+
}
|
|
41
|
+
return new Set(authorities);
|
|
42
|
+
}, [authorities]);
|
|
43
|
+
var key = (_tabs$active = tabs[active]) === null || _tabs$active === void 0 ? void 0 : _tabs$active.rootPath;
|
|
44
|
+
var routeTabs = useMemo(function () {
|
|
45
|
+
return tabs.map(function (item) {
|
|
46
|
+
var tab = _objectSpread(_objectSpread({}, item), {}, {
|
|
47
|
+
route: null,
|
|
48
|
+
match: null
|
|
49
|
+
});
|
|
50
|
+
var findRoute = function findRoute(items) {
|
|
51
|
+
for (var i = 0; i < items.length; i++) {
|
|
52
|
+
var route = items[i];
|
|
53
|
+
var result = route.path ? matchPath(tab.location.pathname, {
|
|
54
|
+
path: route.path,
|
|
55
|
+
strict: route.strict,
|
|
56
|
+
sensitive: route.sensitive
|
|
57
|
+
}) : null;
|
|
58
|
+
if (result !== null) {
|
|
59
|
+
if (result.isExact || route.component && !route.exact) {
|
|
60
|
+
return {
|
|
61
|
+
route: route,
|
|
62
|
+
match: result
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (route.routes) {
|
|
66
|
+
var target = findRoute(route.routes);
|
|
67
|
+
if (target) {
|
|
68
|
+
return target;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
75
|
+
var matched = findRoute(routes);
|
|
76
|
+
if (matched !== null) {
|
|
77
|
+
tab.match = matched.match;
|
|
78
|
+
tab.route = matched.route;
|
|
79
|
+
}
|
|
80
|
+
return tab;
|
|
81
|
+
});
|
|
82
|
+
}, [tabs, routes]);
|
|
83
|
+
var routeTabsRef = useLastestRef(routeTabs);
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
history.block(function (loc, action) {
|
|
86
|
+
if (action === 'POP') {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
var pathname = loc.pathname;
|
|
90
|
+
var target = routeTabsRef.current.find(function (tab) {
|
|
91
|
+
return isSubPath(tab.rootPath, pathname);
|
|
92
|
+
});
|
|
93
|
+
if (target === undefined || loc.pathname === target.location.pathname) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (target.instance !== undefined && target.instance.block({
|
|
97
|
+
title: target.title,
|
|
98
|
+
onOk: function onOk() {
|
|
99
|
+
history.push(loc);
|
|
100
|
+
}
|
|
101
|
+
})) {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}, []);
|
|
106
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
107
|
+
children: routeTabs.map(function (tab, index) {
|
|
108
|
+
var _tab$key;
|
|
109
|
+
var route = tab.route;
|
|
110
|
+
return /*#__PURE__*/_jsx("div", {
|
|
111
|
+
style: {
|
|
112
|
+
display: key !== tab.rootPath ? 'none' : undefined,
|
|
113
|
+
width: '100%',
|
|
114
|
+
height: '100%'
|
|
115
|
+
},
|
|
116
|
+
children: /*#__PURE__*/_jsx(ErrorBoundary, {
|
|
117
|
+
fallbackRender: function fallbackRender(_ref) {
|
|
118
|
+
var error = _ref.error,
|
|
119
|
+
resetErrorBoundary = _ref.resetErrorBoundary;
|
|
120
|
+
return /*#__PURE__*/_jsx(Result, {
|
|
121
|
+
status: "500",
|
|
122
|
+
title: "\u9875\u9762\u5F02\u5E38",
|
|
123
|
+
subTitle: error.message,
|
|
124
|
+
extra: /*#__PURE__*/_jsx(Button, {
|
|
125
|
+
type: "primary",
|
|
126
|
+
onClick: function onClick() {
|
|
127
|
+
resetErrorBoundary();
|
|
128
|
+
},
|
|
129
|
+
children: "\u91CD\u65B0\u52A0\u8F7D"
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
children: route !== null && tab.match !== null && /*#__PURE__*/_jsx(RouteTab, {
|
|
134
|
+
authorities: auth,
|
|
135
|
+
routes: routes,
|
|
136
|
+
index: index,
|
|
137
|
+
history: history,
|
|
138
|
+
route: route,
|
|
139
|
+
location: tab.location,
|
|
140
|
+
match: tab.match,
|
|
141
|
+
instance: tab.instance
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
}, (_tab$key = tab.key) !== null && _tab$key !== void 0 ? _tab$key : tab.rootPath);
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
export default /*#__PURE__*/memo(SimpleLayout);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactText } from 'react';
|
|
2
|
+
import type { TabInstance } from '../tab-instance';
|
|
3
|
+
import type { IRoute, Location } from '../typings';
|
|
4
|
+
|
|
5
|
+
export interface SimpleLayoutProps {
|
|
6
|
+
/**
|
|
7
|
+
* @description 路由配置
|
|
8
|
+
*/
|
|
9
|
+
routes?: IRoute[];
|
|
10
|
+
/**
|
|
11
|
+
* @description 用户包含的所有权限
|
|
12
|
+
*/
|
|
13
|
+
authorities?: ReactText[] | Set<ReactText> | null;
|
|
14
|
+
/**
|
|
15
|
+
* @description 主应用tabs
|
|
16
|
+
*/
|
|
17
|
+
tabs: {
|
|
18
|
+
title: string;
|
|
19
|
+
rootPath: string;
|
|
20
|
+
location: Location;
|
|
21
|
+
instance?: TabInstance;
|
|
22
|
+
key?: string;
|
|
23
|
+
}[];
|
|
24
|
+
/**
|
|
25
|
+
* @description 当前active tab
|
|
26
|
+
*/
|
|
27
|
+
active: number;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/kits",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.14",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ant-design/icons": "^4.7.0",
|
|
27
|
-
"@lemon-fe/components": "^1.2.
|
|
27
|
+
"@lemon-fe/components": "^1.2.14",
|
|
28
28
|
"@lemon-fe/hooks": "^1.2.11",
|
|
29
29
|
"@lemon-fe/utils": "^1.1.0",
|
|
30
30
|
"antd": "4.24.8",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"registry": "https://registry.npmjs.org"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "3ed306d1094065aa0788bb39e4db7d617eddea5b"
|
|
49
49
|
}
|