@lemon-fe/kits 1.0.2-0 → 1.0.2
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/components/DataGrid/cell-editors/Date.d.ts +10 -3
- package/es/components/DataGrid/cell-editors/Date.js +15 -3
- package/es/components/DataGrid/cell-editors/Select.d.ts +2 -2
- package/es/components/DataGrid/components/CustomColumnPanel/DragContext.d.ts +4 -0
- package/es/components/DataGrid/components/CustomColumnPanel/DragContext.js +3 -0
- package/es/components/DataGrid/components/CustomColumnPanel/FieldModal.d.ts +10 -0
- package/es/components/DataGrid/components/CustomColumnPanel/FieldModal.js +256 -0
- package/es/components/DataGrid/components/CustomColumnPanel/Item.d.ts +14 -0
- package/es/components/DataGrid/components/CustomColumnPanel/Item.js +200 -0
- package/es/components/DataGrid/components/CustomColumnPanel/index.d.ts +5 -0
- package/es/components/DataGrid/components/CustomColumnPanel/index.js +366 -0
- package/es/components/DataGrid/components/CustomColumnPanel/typings.d.ts +25 -0
- package/es/components/DataGrid/components/Search.js +2 -2
- package/es/components/DataGrid/components/Selected.js +3 -3
- package/es/components/DataGrid/index.d.ts +16 -7
- package/es/components/DataGrid/index.js +838 -364
- package/es/components/DataGrid/index.less +261 -8
- package/es/components/DataGrid/renderer/CellDeleteRenderer.d.ts +1 -1
- package/es/components/DataGrid/renderer/CellDeleteRenderer.js +49 -12
- package/es/components/DataGrid/renderer/CellIndexRenderer.js +6 -1
- package/es/components/DataGrid/renderer/DetailCellRenderer.d.ts +1 -0
- package/es/components/DataGrid/renderer/DetailCellRenderer.js +6 -3
- package/es/components/DataGrid/typings.d.ts +24 -5
- package/es/components/DataGrid/utils.d.ts +3 -1
- package/es/components/DataGrid/utils.js +13 -3
- package/es/components/Dropdown/index.d.ts +7 -8
- package/es/components/Dropdown/index.js +40 -47
- package/es/components/Dropdown/index.less +2 -10
- package/es/components/DurationPicker/index.d.ts +3 -1
- package/es/components/DurationPicker/index.js +13 -4
- package/es/components/Filter/index.d.ts +1 -1
- package/es/components/Filter/index.js +22 -8
- package/es/components/Filter/typings.d.ts +6 -1
- package/es/components/FormLayout/index.less +6 -2
- package/es/components/GreyPanel/index.less +5 -0
- package/es/components/Icons/Clear.d.ts +1 -1
- package/es/components/Icons/Clear.js +1 -2
- package/es/components/Icons/Drag/drag.svg +7 -0
- package/es/components/Icons/Drag/index.d.ts +3 -0
- package/es/components/Icons/Drag/index.js +34 -0
- package/es/components/Icons/NewTag.d.ts +3 -0
- package/es/components/Icons/NewTag.js +22 -0
- package/es/components/Icons/Plus/index.d.ts +3 -0
- package/es/components/Icons/Plus/index.js +30 -0
- package/es/components/Icons/Plus/plus.svg +6 -0
- package/es/components/Icons/Reload.d.ts +3 -0
- package/es/components/Icons/Reload.js +21 -0
- package/es/components/Icons/Tip.d.ts +1 -1
- package/es/components/Icons/Tip.js +1 -0
- package/es/components/Icons/index.d.ts +8 -0
- package/es/components/Icons/index.js +9 -1
- package/es/components/InputCompact/index.d.ts +1 -0
- package/es/components/InputCompact/index.js +19 -8
- package/es/components/InputCompact/index.less +15 -0
- package/es/components/InputNumber/index.d.ts +1 -1
- package/es/components/InputNumber/index.js +3 -1
- package/es/components/Layout/index.less +2 -1
- package/es/components/Popup/index.d.ts +1 -1
- package/es/components/Popup/index.js +68 -41
- package/es/components/Popup/index.less +3 -0
- package/es/components/SelectPanel/index.d.ts +17 -0
- package/es/components/SelectPanel/index.js +70 -0
- package/es/components/SelectPanel/index.less +112 -0
- package/es/components/SelectView/index.d.ts +6 -2
- package/es/components/SelectView/index.js +75 -40
- package/es/components/SelectView/index.less +19 -6
- package/es/components/SiderTree/index.js +2 -9
- package/es/components/SiderTree/index.less +6 -26
- package/es/components/State/index.d.ts +1 -1
- package/es/components/State/index.js +13 -3
- package/es/components/State/index.less +6 -1
- package/es/hooks/useBatchOperator/index.d.ts +40 -4
- package/es/hooks/useBatchOperator/index.js +591 -356
- package/es/hooks/useHistoryBlock/index.d.ts +8 -0
- package/es/hooks/useHistoryBlock/index.js +30 -0
- package/es/index.d.ts +4 -1
- package/es/index.js +4 -1
- package/es/index.less +1 -0
- package/es/init.js +26 -1
- package/es/layouts/MicroLayout/index.js +69 -5
- package/es/layouts/MicroLayout/typings.d.ts +4 -2
- package/es/layouts/TabInstance.d.ts +31 -0
- package/es/layouts/TabInstance.js +115 -0
- package/es/layouts/components/RouteTab.d.ts +7 -3
- package/es/layouts/components/RouteTab.js +6 -2
- package/es/layouts/utils.d.ts +1 -1
- package/es/layouts/utils.js +2 -2
- package/es/styles/overrides.less +34 -4
- package/es/styles/theme.less +20 -0
- package/es/styles/utils.less +17 -17
- package/package.json +5 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useLastestRef } from '@lemon-fe/hooks';
|
|
2
|
+
import { useContext, useEffect, useRef } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router';
|
|
4
|
+
import { RouteTabContext } from "../../layouts/components/RouteTab";
|
|
5
|
+
/**
|
|
6
|
+
* 校验函数
|
|
7
|
+
* @param block 返回true或者string 会阻止页面被关闭;
|
|
8
|
+
* @returns string 为提示信息,一般情况不需要
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export default function useHistoryBlock(block) {
|
|
12
|
+
var tabCtx = useContext(RouteTabContext);
|
|
13
|
+
var blockRef = useLastestRef(block);
|
|
14
|
+
var pathname = useLocation().pathname;
|
|
15
|
+
var clearRef = useRef(function () {});
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
clearRef.current = tabCtx.instance.registerCloseBlocker({
|
|
18
|
+
pathname: "".concat(tabCtx.routerBase).concat(pathname),
|
|
19
|
+
block: function block() {
|
|
20
|
+
return blockRef.current();
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return clearRef.current;
|
|
24
|
+
}, []);
|
|
25
|
+
return {
|
|
26
|
+
clear: function clear() {
|
|
27
|
+
clearRef.current();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
package/es/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { default as SelectView } from './components/SelectView';
|
|
|
34
34
|
export { default as DataGrid } from './components/DataGrid';
|
|
35
35
|
export * from './components/DataGrid/typings';
|
|
36
36
|
export * from './components/DataGrid/hooks';
|
|
37
|
-
export type { ColDef, ColGroupDef, ColumnState, GridOptions, GridReadyEvent, ICellEditorParams, ICellRendererParams, IHeaderParams, RowDataUpdatedEvent, CellValueChangedEvent, NavigateToNextCellParams, TabToNextCellParams, AgGridEvent, GroupCellRendererParams as IGroupCellRendererParams, Column, CellPosition, } from '@ag-grid-community/core';
|
|
37
|
+
export type { ColDef, ColGroupDef, ColumnState, GridOptions, GridReadyEvent, ICellEditorParams, ICellRendererParams, IHeaderParams, RowDataUpdatedEvent, CellValueChangedEvent, NavigateToNextCellParams, TabToNextCellParams, AgGridEvent, GroupCellRendererParams as IGroupCellRendererParams, Column, CellPosition, IRowNode, } from '@ag-grid-community/core';
|
|
38
38
|
export { GridApi, ColumnApi } from '@ag-grid-community/core';
|
|
39
39
|
export * from '@ag-grid-community/react';
|
|
40
40
|
export { default as TipMark } from './components/TipMark';
|
|
@@ -44,8 +44,11 @@ export { default as GreyPanel } from './components/GreyPanel';
|
|
|
44
44
|
export { default as Alert } from './components/Alert';
|
|
45
45
|
export { default as InputNumber } from './components/InputNumber';
|
|
46
46
|
export { default as InputCompact } from './components/InputCompact';
|
|
47
|
+
export { default as SelectPanel } from './components/SelectPanel';
|
|
47
48
|
export { default as BasicLayout } from './layouts/BasicLayout';
|
|
48
49
|
export { default as BlankLayout } from './layouts/BlankLayout';
|
|
49
50
|
export { default as MicroLayout } from './layouts/MicroLayout';
|
|
50
51
|
export { default as Breadcrumb } from './layouts/Breadcrumb';
|
|
51
52
|
export { default as useBatchOperator } from './hooks/useBatchOperator';
|
|
53
|
+
export { default as useHistoryBlock } from './hooks/useHistoryBlock';
|
|
54
|
+
export { TabInstance } from './layouts/TabInstance';
|
package/es/index.js
CHANGED
|
@@ -36,8 +36,11 @@ export { default as GreyPanel } from "./components/GreyPanel";
|
|
|
36
36
|
export { default as Alert } from "./components/Alert";
|
|
37
37
|
export { default as InputNumber } from "./components/InputNumber";
|
|
38
38
|
export { default as InputCompact } from "./components/InputCompact";
|
|
39
|
+
export { default as SelectPanel } from "./components/SelectPanel";
|
|
39
40
|
export { default as BasicLayout } from "./layouts/BasicLayout";
|
|
40
41
|
export { default as BlankLayout } from "./layouts/BlankLayout";
|
|
41
42
|
export { default as MicroLayout } from "./layouts/MicroLayout";
|
|
42
43
|
export { default as Breadcrumb } from "./layouts/Breadcrumb";
|
|
43
|
-
export { default as useBatchOperator } from "./hooks/useBatchOperator";
|
|
44
|
+
export { default as useBatchOperator } from "./hooks/useBatchOperator";
|
|
45
|
+
export { default as useHistoryBlock } from "./hooks/useHistoryBlock";
|
|
46
|
+
export { TabInstance } from "./layouts/TabInstance";
|
package/es/index.less
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
@import './components/GreyPanel/index.less';
|
|
26
26
|
@import './components/InputNumber/index.less';
|
|
27
27
|
@import './components//InputCompact/index.less';
|
|
28
|
+
@import './components/SelectPanel/index.less';
|
|
28
29
|
|
|
29
30
|
@import './layouts/BasicLayout/components/MainFramework/index.less';
|
|
30
31
|
@import './layouts/Breadcrumb/index.less';
|
package/es/init.js
CHANGED
|
@@ -7,10 +7,11 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
8
|
|
|
9
9
|
import { config } from '@lemon-fe/hooks';
|
|
10
|
-
import { message, Modal, Select, ConfigProvider, Result, Button, DatePicker, Cascader, TreeSelect, Empty, Menu, TimePicker } from 'antd';
|
|
10
|
+
import { message, Modal, Select, ConfigProvider, Result, Button, DatePicker, Cascader, TreeSelect, Empty, Menu, TimePicker, Tree } from 'antd';
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import Icons from "./components/Icons";
|
|
13
13
|
import PageLoading from "./components/PageLoading";
|
|
14
|
+
import { PREFIX_CLS } from "./constants";
|
|
14
15
|
import empty from "./styles/empty.png";
|
|
15
16
|
var Tip = Icons.Tip,
|
|
16
17
|
Down = Icons.Down,
|
|
@@ -122,6 +123,16 @@ export default function init() {
|
|
|
122
123
|
clearIcon: /*#__PURE__*/React.createElement(Clear, null)
|
|
123
124
|
}; //@ts-ignore
|
|
124
125
|
|
|
126
|
+
Tree.defaultProps = {
|
|
127
|
+
switcherIcon: /*#__PURE__*/React.createElement(Down, {
|
|
128
|
+
style: {
|
|
129
|
+
fontSize: 14,
|
|
130
|
+
color: 'rgba(51, 51, 51, 0.7)',
|
|
131
|
+
verticalAlign: '-0.125em'
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}; //@ts-ignore
|
|
135
|
+
|
|
125
136
|
Cascader.defaultProps = {
|
|
126
137
|
suffixIcon: node,
|
|
127
138
|
clearIcon: /*#__PURE__*/React.createElement(Clear, null)
|
|
@@ -148,6 +159,14 @@ export default function init() {
|
|
|
148
159
|
pointerEvents: 'none'
|
|
149
160
|
}
|
|
150
161
|
})
|
|
162
|
+
});
|
|
163
|
+
TimePicker.RangePicker.defaultProps = _objectSpread(_objectSpread({}, TimePicker.RangePicker.defaultProps), {}, {
|
|
164
|
+
suffixIcon: /*#__PURE__*/React.createElement(Icons.Clock, {
|
|
165
|
+
style: {
|
|
166
|
+
pointerEvents: 'none'
|
|
167
|
+
}
|
|
168
|
+
}),
|
|
169
|
+
clearIcon: /*#__PURE__*/React.createElement(Clear, null)
|
|
151
170
|
}); //@ts-ignore
|
|
152
171
|
|
|
153
172
|
Menu.defaultProps = {
|
|
@@ -170,6 +189,7 @@ export default function init() {
|
|
|
170
189
|
return /*#__PURE__*/React.createElement(PageLoading, null);
|
|
171
190
|
},
|
|
172
191
|
showError: function showError(err) {
|
|
192
|
+
console.error(err);
|
|
173
193
|
message.error(err.message);
|
|
174
194
|
},
|
|
175
195
|
setPrimaryColor: function setPrimaryColor(color) {
|
|
@@ -191,4 +211,9 @@ export default function init() {
|
|
|
191
211
|
});
|
|
192
212
|
}
|
|
193
213
|
});
|
|
214
|
+
/** 设置滚动条 */
|
|
215
|
+
|
|
216
|
+
if (/windows/.test(window.navigator.userAgent.toLowerCase())) {
|
|
217
|
+
document.body.classList.add("".concat(PREFIX_CLS, "-thin-scroll-bar"));
|
|
218
|
+
}
|
|
194
219
|
}
|
|
@@ -4,11 +4,31 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import { useLastestRef } from '@lemon-fe/hooks';
|
|
8
|
+
import { Button, Result } from 'antd';
|
|
9
|
+
import React, { memo, useEffect } from 'react';
|
|
8
10
|
import { useMemo } from 'react';
|
|
11
|
+
import { ErrorBoundary } from 'react-error-boundary';
|
|
9
12
|
import { matchPath, useHistory } from 'react-router-dom';
|
|
10
13
|
import RouteTab from "../components/RouteTab";
|
|
11
14
|
|
|
15
|
+
function isSubPath(path, subPath) {
|
|
16
|
+
var pathArr = path.split('/');
|
|
17
|
+
var subPathArr = subPath.split('/');
|
|
18
|
+
|
|
19
|
+
if (path.length > subPath.length) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (var i = 0; i < pathArr.length; i++) {
|
|
24
|
+
if (subPathArr[i] !== pathArr[i]) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
12
32
|
function MicroLayout(props) {
|
|
13
33
|
var _tabs$active;
|
|
14
34
|
|
|
@@ -19,7 +39,7 @@ function MicroLayout(props) {
|
|
|
19
39
|
active = props.active;
|
|
20
40
|
var history = useHistory();
|
|
21
41
|
var auth = useMemo(function () {
|
|
22
|
-
if (authorities === undefined) {
|
|
42
|
+
if (authorities === undefined || authorities === null) {
|
|
23
43
|
return authorities;
|
|
24
44
|
}
|
|
25
45
|
|
|
@@ -31,7 +51,7 @@ function MicroLayout(props) {
|
|
|
31
51
|
var key = (_tabs$active = tabs[active]) === null || _tabs$active === void 0 ? void 0 : _tabs$active.rootPath;
|
|
32
52
|
var routeTabs = useMemo(function () {
|
|
33
53
|
return tabs.filter(function (tab) {
|
|
34
|
-
return
|
|
54
|
+
return isSubPath(basename, tab.rootPath);
|
|
35
55
|
}).map(function (item) {
|
|
36
56
|
var tab = _objectSpread(_objectSpread({}, item), {}, {
|
|
37
57
|
location: _objectSpread(_objectSpread({}, item.location), {}, {
|
|
@@ -81,6 +101,32 @@ function MicroLayout(props) {
|
|
|
81
101
|
return tab;
|
|
82
102
|
});
|
|
83
103
|
}, [tabs, routes]);
|
|
104
|
+
var routeTabsRef = useLastestRef(routeTabs);
|
|
105
|
+
useEffect(function () {
|
|
106
|
+
history.block(function (loc, action) {
|
|
107
|
+
if (action === 'POP') {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var pathname = "".concat(basename).concat(loc.pathname);
|
|
112
|
+
var target = routeTabsRef.current.find(function (tab) {
|
|
113
|
+
return isSubPath(tab.rootPath, pathname);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (target === undefined || pathname === target.location.pathname) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (target.instance.block({
|
|
121
|
+
title: target.title,
|
|
122
|
+
onOk: function onOk() {
|
|
123
|
+
history.push(loc);
|
|
124
|
+
}
|
|
125
|
+
})) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}, []);
|
|
84
130
|
return /*#__PURE__*/React.createElement(React.Fragment, null, routeTabs.map(function (tab, index) {
|
|
85
131
|
var route = tab.route;
|
|
86
132
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -90,15 +136,33 @@ function MicroLayout(props) {
|
|
|
90
136
|
width: '100%',
|
|
91
137
|
height: '100%'
|
|
92
138
|
}
|
|
139
|
+
}, /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
140
|
+
fallbackRender: function fallbackRender(_ref) {
|
|
141
|
+
var error = _ref.error,
|
|
142
|
+
resetErrorBoundary = _ref.resetErrorBoundary;
|
|
143
|
+
return /*#__PURE__*/React.createElement(Result, {
|
|
144
|
+
status: "500",
|
|
145
|
+
title: "\u9875\u9762\u5F02\u5E38",
|
|
146
|
+
subTitle: error.message,
|
|
147
|
+
extra: /*#__PURE__*/React.createElement(Button, {
|
|
148
|
+
type: "primary",
|
|
149
|
+
onClick: function onClick() {
|
|
150
|
+
resetErrorBoundary();
|
|
151
|
+
}
|
|
152
|
+
}, "\u91CD\u65B0\u52A0\u8F7D")
|
|
153
|
+
});
|
|
154
|
+
}
|
|
93
155
|
}, route !== null && tab.match !== null && /*#__PURE__*/React.createElement(RouteTab, {
|
|
156
|
+
routerBase: basename,
|
|
94
157
|
authorities: auth,
|
|
95
158
|
routes: routes,
|
|
96
159
|
index: index,
|
|
97
160
|
history: history,
|
|
98
161
|
route: route,
|
|
99
162
|
location: tab.location,
|
|
100
|
-
match: tab.match
|
|
101
|
-
|
|
163
|
+
match: tab.match,
|
|
164
|
+
instance: tab.instance
|
|
165
|
+
})));
|
|
102
166
|
}));
|
|
103
167
|
}
|
|
104
168
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactText } from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TabInstance } from '../TabInstance';
|
|
3
|
+
import type { IRoute, Location } from '../typings';
|
|
3
4
|
|
|
4
5
|
export interface MicroLayoutProps {
|
|
5
6
|
/**
|
|
@@ -9,7 +10,7 @@ export interface MicroLayoutProps {
|
|
|
9
10
|
/**
|
|
10
11
|
* @description 用户包含的所有权限
|
|
11
12
|
*/
|
|
12
|
-
authorities?: ReactText[] | Set<ReactText
|
|
13
|
+
authorities?: ReactText[] | Set<ReactText> | null;
|
|
13
14
|
/**
|
|
14
15
|
* @description 主应用tabs
|
|
15
16
|
*/
|
|
@@ -17,6 +18,7 @@ export interface MicroLayoutProps {
|
|
|
17
18
|
title: string;
|
|
18
19
|
rootPath: string;
|
|
19
20
|
location: Location;
|
|
21
|
+
instance: TabInstance;
|
|
20
22
|
}[];
|
|
21
23
|
/**
|
|
22
24
|
* @description 当前active tab
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Location } from './typings';
|
|
2
|
+
declare type CloseBlocker = {
|
|
3
|
+
pathname: string;
|
|
4
|
+
block: () => string | boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 为了简化,只会阻止最后一个且当前路由下的history blocker;
|
|
8
|
+
*/
|
|
9
|
+
export declare class TabInstance {
|
|
10
|
+
private closeBlockers;
|
|
11
|
+
private rootPath;
|
|
12
|
+
private location;
|
|
13
|
+
constructor(rootPath: string, location: Location);
|
|
14
|
+
update(rootPath: string | undefined, location: Location | undefined): void;
|
|
15
|
+
registerCloseBlocker(blocker: CloseBlocker): () => void;
|
|
16
|
+
private shouldNotBlock;
|
|
17
|
+
/**
|
|
18
|
+
* 用于路由跳转
|
|
19
|
+
* @param modalParams
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
block(modalParams: {
|
|
23
|
+
title: string;
|
|
24
|
+
onOk: () => void;
|
|
25
|
+
}): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @returns 用于关闭tab
|
|
28
|
+
*/
|
|
29
|
+
shouldBlock(): string | false;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
+
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
4
|
+
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
import { Modal } from 'antd';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 为了简化,只会阻止最后一个且当前路由下的history blocker;
|
|
13
|
+
*/
|
|
14
|
+
export var TabInstance = /*#__PURE__*/function () {
|
|
15
|
+
function TabInstance(rootPath, location) {
|
|
16
|
+
_classCallCheck(this, TabInstance);
|
|
17
|
+
|
|
18
|
+
_defineProperty(this, "closeBlockers", []);
|
|
19
|
+
|
|
20
|
+
_defineProperty(this, "rootPath", void 0);
|
|
21
|
+
|
|
22
|
+
_defineProperty(this, "location", void 0);
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "shouldNotBlock", '');
|
|
25
|
+
|
|
26
|
+
this.rootPath = rootPath;
|
|
27
|
+
this.location = location;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_createClass(TabInstance, [{
|
|
31
|
+
key: "update",
|
|
32
|
+
value: function update(rootPath, location) {
|
|
33
|
+
if (rootPath) {
|
|
34
|
+
this.rootPath = rootPath;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (location) {
|
|
38
|
+
this.location = location;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "registerCloseBlocker",
|
|
43
|
+
value: function registerCloseBlocker(blocker) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
|
|
46
|
+
this.closeBlockers.push(blocker);
|
|
47
|
+
return function () {
|
|
48
|
+
var index = _this.closeBlockers.findIndex(function (item) {
|
|
49
|
+
return item === blocker;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
_this.closeBlockers.splice(index, 1);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "block",
|
|
57
|
+
value:
|
|
58
|
+
/**
|
|
59
|
+
* 用于路由跳转
|
|
60
|
+
* @param modalParams
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
function block(modalParams) {
|
|
64
|
+
var _this2 = this;
|
|
65
|
+
|
|
66
|
+
var shouldNotBlock = this.shouldNotBlock;
|
|
67
|
+
this.shouldNotBlock = '';
|
|
68
|
+
|
|
69
|
+
if (this.closeBlockers.length > 0) {
|
|
70
|
+
var last = this.closeBlockers[this.closeBlockers.length - 1];
|
|
71
|
+
|
|
72
|
+
if (last.pathname === this.location.pathname && last.pathname !== shouldNotBlock) {
|
|
73
|
+
var shouldBlock = last.block();
|
|
74
|
+
|
|
75
|
+
if (shouldBlock) {
|
|
76
|
+
Modal.confirm({
|
|
77
|
+
title: modalParams.title,
|
|
78
|
+
content: typeof shouldBlock === 'string' ? shouldBlock : "\u9875\u9762\u672A\u4FDD\u5B58\uFF0C\u786E\u8BA4\u79BB\u5F00\uFF1F",
|
|
79
|
+
onOk: function onOk() {
|
|
80
|
+
_this2.shouldNotBlock = last.pathname;
|
|
81
|
+
modalParams.onOk();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @returns 用于关闭tab
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
}, {
|
|
96
|
+
key: "shouldBlock",
|
|
97
|
+
value: function shouldBlock() {
|
|
98
|
+
if (this.closeBlockers.length > 0) {
|
|
99
|
+
var last = this.closeBlockers[this.closeBlockers.length - 1];
|
|
100
|
+
|
|
101
|
+
if (last.pathname === this.location.pathname) {
|
|
102
|
+
var result = last.block();
|
|
103
|
+
|
|
104
|
+
if (result) {
|
|
105
|
+
return typeof result === 'string' ? result : '页面未保存,确认离开?';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}]);
|
|
113
|
+
|
|
114
|
+
return TabInstance;
|
|
115
|
+
}();
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ReactText } from 'react';
|
|
3
2
|
import { type match } from 'react-router';
|
|
3
|
+
import type { TabInstance } from '../TabInstance';
|
|
4
4
|
import type { IRoute, Location } from '../typings';
|
|
5
5
|
interface Props {
|
|
6
|
+
routerBase: string;
|
|
6
7
|
route: IRoute;
|
|
7
8
|
routes: IRoute[];
|
|
8
9
|
index: number;
|
|
9
10
|
location: Location;
|
|
10
11
|
match: match;
|
|
11
12
|
history: any;
|
|
12
|
-
authorities?: Set<
|
|
13
|
-
pathAuthorities?: Map<string,
|
|
13
|
+
authorities?: Set<string | number> | null;
|
|
14
|
+
pathAuthorities?: Map<string, string | number | (string | number)[]>;
|
|
15
|
+
instance: TabInstance;
|
|
14
16
|
}
|
|
15
17
|
export declare const RouteTabContext: React.Context<{
|
|
16
18
|
route: IRoute;
|
|
17
19
|
match: match;
|
|
20
|
+
routerBase: string;
|
|
21
|
+
instance: TabInstance;
|
|
18
22
|
}>;
|
|
19
23
|
declare const _default: React.NamedExoticComponent<Props>;
|
|
20
24
|
export default _default;
|
|
@@ -10,11 +10,15 @@ export default /*#__PURE__*/memo(function RouteTab(props) {
|
|
|
10
10
|
history = props.history,
|
|
11
11
|
routes = props.routes,
|
|
12
12
|
authorities = props.authorities,
|
|
13
|
-
pathAuthorities = props.pathAuthorities
|
|
13
|
+
pathAuthorities = props.pathAuthorities,
|
|
14
|
+
instance = props.instance,
|
|
15
|
+
routerBase = props.routerBase;
|
|
14
16
|
var ctx = useMemo(function () {
|
|
15
17
|
return {
|
|
16
18
|
match: match,
|
|
17
|
-
route: route
|
|
19
|
+
route: route,
|
|
20
|
+
instance: instance,
|
|
21
|
+
routerBase: routerBase
|
|
18
22
|
};
|
|
19
23
|
}, [route]);
|
|
20
24
|
return /*#__PURE__*/React.createElement(RouterContext.Provider, {
|
package/es/layouts/utils.d.ts
CHANGED
package/es/layouts/utils.js
CHANGED
|
@@ -18,8 +18,8 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
18
18
|
|
|
19
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
20
20
|
|
|
21
|
-
import React, { createElement } from 'react';
|
|
22
21
|
import { Result } from 'antd';
|
|
22
|
+
import React, { createElement } from 'react';
|
|
23
23
|
import { Redirect, Route } from 'react-router';
|
|
24
24
|
import { matchPath } from 'react-router';
|
|
25
25
|
import CachableRoute from "./components/CachableRoute";
|
|
@@ -68,7 +68,7 @@ function _render(_ref) {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
if (authority !== undefined) {
|
|
71
|
+
if (authority !== undefined && opts.authorities !== null) {
|
|
72
72
|
var authorities = opts.authorities;
|
|
73
73
|
var flag = false;
|
|
74
74
|
|
package/es/styles/overrides.less
CHANGED
|
@@ -40,7 +40,7 @@ a[title='站长统计'] {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.@{ant-prefix}-table-body {
|
|
43
|
-
.scrollBar(
|
|
43
|
+
.scrollBar();
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.@{ant-prefix}-table-tbody > tr.@{ant-prefix}-table-row-selected > td {
|
|
@@ -168,12 +168,12 @@ a[title='站长统计'] {
|
|
|
168
168
|
@input-padding-vertical-base: (
|
|
169
169
|
round(((@input-height-base - @font-size-base * @line-height-base) / 2) * 10) / 10
|
|
170
170
|
) - @border-width-base;
|
|
171
|
-
@input-disabled-color: fade(#333,
|
|
171
|
+
@input-disabled-color: fade(#333, 50);
|
|
172
172
|
@input-disabled-bg: #fff;
|
|
173
173
|
|
|
174
174
|
.@{ant-prefix}-input-prefix,
|
|
175
175
|
.@{ant-prefix}-input-suffix {
|
|
176
|
-
color:
|
|
176
|
+
color: rgba(51, 51, 51, 0.7);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/** picker */
|
|
@@ -189,7 +189,7 @@ a[title='站长统计'] {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
&&-disabled &-suffix {
|
|
192
|
-
color: fade(#333,
|
|
192
|
+
color: fade(#333, 40);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
@@ -253,6 +253,10 @@ a[title='站长统计'] {
|
|
|
253
253
|
& &-treenode-leaf-last &-switcher-leaf-line::before {
|
|
254
254
|
height: (@tree-title-height / 2) !important;
|
|
255
255
|
}
|
|
256
|
+
|
|
257
|
+
& &-treenode-draggable &-draggable-icon {
|
|
258
|
+
width: @tree-node-indent-width;
|
|
259
|
+
}
|
|
256
260
|
}
|
|
257
261
|
|
|
258
262
|
/** button **/
|
|
@@ -272,12 +276,27 @@ a[title='站长统计'] {
|
|
|
272
276
|
@tabs-card-horizontal-padding: 5px;
|
|
273
277
|
|
|
274
278
|
/** checkbox **/
|
|
279
|
+
@checkbox-group-item-margin-right: 12px;
|
|
280
|
+
|
|
275
281
|
.@{ant-prefix}-checkbox + span {
|
|
276
282
|
padding-right: 0;
|
|
277
283
|
padding-left: 4px;
|
|
278
284
|
}
|
|
279
285
|
|
|
286
|
+
.@{ant-prefix}-checkbox-wrapper {
|
|
287
|
+
& + & {
|
|
288
|
+
margin-left: 12px;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.@{ant-prefix}-checkbox-group {
|
|
293
|
+
&-item + &-item {
|
|
294
|
+
margin-left: 0px;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
280
298
|
/** radio **/
|
|
299
|
+
@radio-wrapper-margin-right: 12px;
|
|
281
300
|
span.@{ant-prefix}-radio + * {
|
|
282
301
|
padding-right: 0;
|
|
283
302
|
padding-left: 4px;
|
|
@@ -303,3 +322,14 @@ span.@{ant-prefix}-radio + * {
|
|
|
303
322
|
|
|
304
323
|
/** tooltip **/
|
|
305
324
|
@tooltip-arrow-width: 5px * sqrt(2);
|
|
325
|
+
|
|
326
|
+
/** form **/
|
|
327
|
+
.@{ant-prefix}-form-item {
|
|
328
|
+
&-explain-error {
|
|
329
|
+
margin-top: 4px;
|
|
330
|
+
color: #ff4128;
|
|
331
|
+
font-weight: 400;
|
|
332
|
+
font-size: 12px;
|
|
333
|
+
line-height: 20px;
|
|
334
|
+
}
|
|
335
|
+
}
|
package/es/styles/theme.less
CHANGED
|
@@ -7,3 +7,23 @@
|
|
|
7
7
|
html {
|
|
8
8
|
--lemon-primary-color: 35, 87, 223;
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
.@{prefixCls}-thin-scroll-bar {
|
|
12
|
+
::-webkit-scrollbar {
|
|
13
|
+
width: 8px;
|
|
14
|
+
height: 8px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
::-webkit-scrollbar-track {
|
|
18
|
+
background-color: transparent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
::-webkit-scrollbar-thumb {
|
|
22
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
|
|
25
|
+
&:hover {
|
|
26
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
package/es/styles/utils.less
CHANGED
|
@@ -90,21 +90,21 @@
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
.scrollBar (@width:
|
|
94
|
-
scrollbar-width: thin;
|
|
95
|
-
|
|
96
|
-
&::-webkit-scrollbar {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
&::-webkit-scrollbar-track {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
&::-webkit-scrollbar-thumb {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
93
|
+
.scrollBar (@width: 8px) {
|
|
94
|
+
// scrollbar-width: thin;
|
|
95
|
+
|
|
96
|
+
// &::-webkit-scrollbar {
|
|
97
|
+
// width: @width;
|
|
98
|
+
// height: 8px;
|
|
99
|
+
// }
|
|
100
|
+
|
|
101
|
+
// &::-webkit-scrollbar-track {
|
|
102
|
+
// background-color: #fff;
|
|
103
|
+
// border-radius: 4px;
|
|
104
|
+
// }
|
|
105
|
+
|
|
106
|
+
// &::-webkit-scrollbar-thumb {
|
|
107
|
+
// background-color: #ddd;
|
|
108
|
+
// border-radius: 4px;
|
|
109
|
+
// }
|
|
110
110
|
}
|