tntd 1.4.4 → 1.4.7
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/components/Layout/HeaderActions.js +90 -128
- package/components/LoadingButton/index.js +11 -15
- package/components/QueryListScene/QueryForm.js +7 -4
- package/dist/stats.json +4990 -4990
- package/dist/tntd.js +1 -1
- package/es/Layout/HeaderActions.js +10 -10
- package/es/LoadingButton/index.js +20 -10
- package/es/QueryListScene/QueryForm.js +6 -3
- package/lib/ArrayInput/icon.js +27 -31
- package/lib/ArrayInput/index.js +211 -298
- package/lib/AuthContext.js +2 -13
- package/lib/Columns/index.js +71 -100
- package/lib/DevelopmentLogin/LoginModal.js +79 -141
- package/lib/DevelopmentLogin/index.js +28 -55
- package/lib/Ellipsis/Svg/CopySVG.js +23 -71
- package/lib/Ellipsis/Svg/TickSVG.js +17 -49
- package/lib/Ellipsis/index.js +148 -154
- package/lib/Handle/index.js +72 -109
- package/lib/Icon/fonts/iconfont.js +1 -43
- package/lib/Icon/iconList.js +119 -8
- package/lib/Icon/index.js +13 -45
- package/lib/Img/Contain.js +49 -81
- package/lib/Img/Cover.js +88 -136
- package/lib/Img/index.js +36 -89
- package/lib/Layout/ActionsContext.js +2 -11
- package/lib/Layout/AppList.js +262 -256
- package/lib/Layout/Application.js +119 -135
- package/lib/Layout/Avatar.js +137 -137
- package/lib/Layout/CompatibleLanguage.js +214 -195
- package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
- package/lib/Layout/EnterpriseLayout/Language.js +75 -100
- package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
- package/lib/Layout/EnterpriseLayout/index.js +32 -45
- package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
- package/lib/Layout/GlobalNavigation/index.js +110 -158
- package/lib/Layout/Header.js +165 -116
- package/lib/Layout/HeaderActions.js +132 -129
- package/lib/Layout/HeaderNavs.js +90 -113
- package/lib/Layout/HeaderTabs.js +312 -278
- package/lib/Layout/Iconfont.js +2 -15
- package/lib/Layout/Language.js +63 -102
- package/lib/Layout/Layout.js +272 -261
- package/lib/Layout/Logo.js +132 -87
- package/lib/Layout/OrgAppList.js +440 -319
- package/lib/Layout/SideMenu.js +429 -343
- package/lib/Layout/Theme.js +95 -124
- package/lib/Layout/checkAuth.js +21 -35
- package/lib/Layout/createActions.js +38 -51
- package/lib/Layout/images/index.js +33 -41
- package/lib/Layout/index.js +110 -161
- package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
- package/lib/Layout/paaslayout/Header.js +84 -90
- package/lib/Layout/paaslayout/Logo.js +27 -32
- package/lib/Layout/paaslayout/SideMenu.js +161 -174
- package/lib/Layout/paaslayout/index.js +240 -261
- package/lib/Layout/storage.js +20 -78
- package/lib/Layout/utils.js +93 -143
- package/lib/LoadingButton/index.js +25 -57
- package/lib/Modal/index.js +83 -108
- package/lib/Page/Box.js +56 -81
- package/lib/Page/index.js +151 -173
- package/lib/Page/utils.js +12 -30
- package/lib/QueryForm/Field/Checkbox.js +11 -33
- package/lib/QueryForm/Field/Select.js +63 -99
- package/lib/QueryForm/Field/SelectInput.js +69 -114
- package/lib/QueryForm/Field/fieldsMap.js +30 -52
- package/lib/QueryForm/Field/index.js +76 -158
- package/lib/QueryForm/createActions.js +50 -65
- package/lib/QueryForm/index.js +304 -383
- package/lib/QueryForm/useForm.js +6 -17
- package/lib/QueryListScene/List.js +290 -366
- package/lib/QueryListScene/QueryForm.js +93 -158
- package/lib/QueryListScene/QueryListScene.js +33 -87
- package/lib/QueryListScene/Title.js +10 -20
- package/lib/QueryListScene/Toolbar.js +8 -31
- package/lib/QueryListScene/createActions.js +64 -79
- package/lib/QueryListScene/index.js +23 -40
- package/lib/QueryListScene/useActions.js +6 -17
- package/lib/Select/DropDownWrap.js +60 -124
- package/lib/Select/index.js +425 -561
- package/lib/Table/ResizableTable/index.js +77 -121
- package/lib/Table/index.js +19 -51
- package/lib/Title/index.js +34 -52
- package/lib/index.js +19 -159
- package/lib/locale.js +48 -63
- package/package.json +1 -1
- package/lib/Layout/EnterpriseLayout/Header.js +0 -113
- package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
package/lib/Page/Box.js
CHANGED
|
@@ -1,86 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var Box = function Box(_ref) {
|
|
31
|
-
var inLayout = _ref.inLayout,
|
|
32
|
-
_ref$clsPrefix = _ref.clsPrefix,
|
|
33
|
-
clsPrefix = _ref$clsPrefix === void 0 ? 'tnt-page' : _ref$clsPrefix,
|
|
34
|
-
children = _ref.children,
|
|
35
|
-
_ref$noPadding = _ref.noPadding,
|
|
36
|
-
noPadding = _ref$noPadding === void 0 ? false : _ref$noPadding,
|
|
37
|
-
headerHeight = _ref.headerHeight,
|
|
38
|
-
_ref$bordered = _ref.bordered,
|
|
39
|
-
bordered = _ref$bordered === void 0 ? false : _ref$bordered,
|
|
40
|
-
_ref$bodyStyle = _ref.bodyStyle,
|
|
41
|
-
bodyStyle = _ref$bodyStyle === void 0 ? {} : _ref$bodyStyle,
|
|
42
|
-
_ref$headStyle = _ref.headStyle,
|
|
43
|
-
headStyle = _ref$headStyle === void 0 ? {} : _ref$headStyle,
|
|
44
|
-
height = _ref.height,
|
|
45
|
-
_ref$size = _ref.size,
|
|
46
|
-
size = _ref$size === void 0 ? 'small' : _ref$size,
|
|
47
|
-
_ref$contentTotalMarg = _ref.contentTotalMargin,
|
|
48
|
-
contentTotalMargin = _ref$contentTotalMarg === void 0 ? '0px' : _ref$contentTotalMarg,
|
|
49
|
-
restProps = _objectWithoutProperties(_ref, ["inLayout", "clsPrefix", "children", "noPadding", "headerHeight", "bordered", "bodyStyle", "headStyle", "height", "size", "contentTotalMargin"]);
|
|
50
|
-
|
|
51
|
-
var cardTitleHeight = 0;
|
|
52
|
-
console.log('inLayout', inLayout);
|
|
53
|
-
console.log('restProps', restProps);
|
|
54
|
-
|
|
55
|
-
if (restProps.title) {
|
|
56
|
-
// 根据Card的size,计算Card的title的高度值
|
|
57
|
-
cardTitleHeight = size === 'small' ? 40 : 60; // 如果Card的自定义高度,Card的title就使用此高度
|
|
58
|
-
|
|
59
|
-
if (headStyle.hasOwnProperty(height)) {
|
|
60
|
-
cardTitleHeight = headStyle.height;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Card } from 'antd';
|
|
3
|
+
import { addUnitForValue } from './utils';
|
|
4
|
+
|
|
5
|
+
const Box = ({
|
|
6
|
+
inLayout,
|
|
7
|
+
clsPrefix = 'tnt-page',
|
|
8
|
+
children,
|
|
9
|
+
noPadding = false,
|
|
10
|
+
headerHeight,
|
|
11
|
+
bordered = false,
|
|
12
|
+
bodyStyle = {},
|
|
13
|
+
headStyle = {},
|
|
14
|
+
height,
|
|
15
|
+
size = 'small',
|
|
16
|
+
contentTotalMargin = '0px',
|
|
17
|
+
...restProps
|
|
18
|
+
}) => {
|
|
19
|
+
|
|
20
|
+
let cardTitleHeight = 0;
|
|
21
|
+
console.log('inLayout', inLayout);
|
|
22
|
+
console.log('restProps', restProps);
|
|
23
|
+
if (restProps.title) {
|
|
24
|
+
// 根据Card的size,计算Card的title的高度值
|
|
25
|
+
cardTitleHeight = size === 'small' ? 40 : 60;
|
|
26
|
+
// 如果Card的自定义高度,Card的title就使用此高度
|
|
27
|
+
if (headStyle.hasOwnProperty(height)) {
|
|
28
|
+
cardTitleHeight = headStyle.height;
|
|
29
|
+
}
|
|
61
30
|
}
|
|
62
|
-
} // 如果设置了noPadding,优先级最高
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (noPadding) {
|
|
66
|
-
bodyStyle.padding = 0;
|
|
67
|
-
headStyle.padding = 0;
|
|
68
|
-
} // 如果传入只有数字,需要默认加px
|
|
69
31
|
|
|
32
|
+
// 如果设置了noPadding,优先级最高
|
|
33
|
+
if (noPadding) {
|
|
34
|
+
bodyStyle.padding = 0;
|
|
35
|
+
headStyle.padding = 0;
|
|
36
|
+
}
|
|
70
37
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
38
|
+
// 如果传入只有数字,需要默认加px
|
|
39
|
+
cardTitleHeight = addUnitForValue(cardTitleHeight);
|
|
40
|
+
|
|
41
|
+
const cardBodyHeight = `calc(${height} - ${headerHeight} - ${contentTotalMargin} - ${cardTitleHeight})`;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Card
|
|
45
|
+
className={`${clsPrefix}-box-card`}
|
|
46
|
+
bordered={bordered}
|
|
47
|
+
bodyStyle={{
|
|
48
|
+
...bodyStyle,
|
|
49
|
+
// overflow: 'auto',
|
|
50
|
+
height: inLayout ? `calc(100% - ${headerHeight})` : cardBodyHeight
|
|
51
|
+
}}
|
|
52
|
+
size={size}
|
|
53
|
+
headStyle={headStyle}
|
|
54
|
+
{...restProps}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</Card>
|
|
58
|
+
);
|
|
83
59
|
};
|
|
84
60
|
|
|
85
|
-
|
|
86
|
-
exports["default"] = _default;
|
|
61
|
+
export default Box;
|
package/lib/Page/index.js
CHANGED
|
@@ -1,183 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
35
|
-
|
|
36
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
37
|
-
|
|
38
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
39
|
-
|
|
40
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
41
|
-
|
|
42
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
43
|
-
|
|
44
|
-
var clsPrefix = 'tnt-page';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import { computeWidth, addUnitForValue } from './utils';
|
|
5
|
+
import Box from './Box';
|
|
6
|
+
import './index.less';
|
|
7
|
+
|
|
8
|
+
const clsPrefix = 'tnt-page';
|
|
9
|
+
|
|
10
|
+
const isPageBox = child => child?.type === Box || child?.props?.pageBox;
|
|
11
|
+
|
|
12
|
+
const PageLayout = ({
|
|
13
|
+
height = '100vh',
|
|
14
|
+
headerHeight = 50,
|
|
15
|
+
children,
|
|
16
|
+
title,
|
|
17
|
+
goBack,
|
|
18
|
+
goBackText,
|
|
19
|
+
center,
|
|
20
|
+
extra,
|
|
21
|
+
size = 'small',
|
|
22
|
+
inLayout = false,
|
|
23
|
+
className,
|
|
24
|
+
...restProps
|
|
25
|
+
}) => {
|
|
26
|
+
// 如果传入只有数字,需要默认加px
|
|
27
|
+
let computedHeaderHeight = addUnitForValue(headerHeight);
|
|
28
|
+
let computedHeight = addUnitForValue(height);
|
|
29
|
+
|
|
30
|
+
// 判断是否有标题栏
|
|
31
|
+
if (!(title || extra || center)) {
|
|
32
|
+
computedHeaderHeight = '0px';
|
|
33
|
+
}
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
if (inLayout) {
|
|
36
|
+
computedHeaderHeight = '40px';
|
|
37
|
+
}
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
|
|
39
|
+
// 计算中间的zIndex,灰色递减,白色递增
|
|
40
|
+
let whiteCols = 0;
|
|
41
|
+
let childrenToArray = [];
|
|
51
42
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _ref$height = _ref.height,
|
|
56
|
-
height = _ref$height === void 0 ? '100vh' : _ref$height,
|
|
57
|
-
_ref$headerHeight = _ref.headerHeight,
|
|
58
|
-
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
59
|
-
children = _ref.children,
|
|
60
|
-
title = _ref.title,
|
|
61
|
-
goBack = _ref.goBack,
|
|
62
|
-
goBackText = _ref.goBackText,
|
|
63
|
-
center = _ref.center,
|
|
64
|
-
extra = _ref.extra,
|
|
65
|
-
_ref$size = _ref.size,
|
|
66
|
-
size = _ref$size === void 0 ? 'small' : _ref$size,
|
|
67
|
-
_ref$inLayout = _ref.inLayout,
|
|
68
|
-
inLayout = _ref$inLayout === void 0 ? false : _ref$inLayout,
|
|
69
|
-
className = _ref.className,
|
|
70
|
-
restProps = _objectWithoutProperties(_ref, ["height", "headerHeight", "children", "title", "goBack", "goBackText", "center", "extra", "size", "inLayout", "className"]);
|
|
71
|
-
|
|
72
|
-
// 如果传入只有数字,需要默认加px
|
|
73
|
-
var computedHeaderHeight = (0, _utils.addUnitForValue)(headerHeight);
|
|
74
|
-
var computedHeight = (0, _utils.addUnitForValue)(height); // 判断是否有标题栏
|
|
75
|
-
|
|
76
|
-
if (!(title || extra || center)) {
|
|
77
|
-
computedHeaderHeight = '0px';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (inLayout) {
|
|
81
|
-
computedHeaderHeight = '40px';
|
|
82
|
-
} // 计算中间的zIndex,灰色递减,白色递增
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var whiteCols = 0;
|
|
86
|
-
var childrenToArray = []; // 计算children type是box的数量
|
|
87
|
-
|
|
88
|
-
var boxCount = 0; // 如果children是单个节点,统一转为数组处理计算层级
|
|
89
|
-
|
|
90
|
-
console.log('children', children);
|
|
91
|
-
|
|
92
|
-
if (_typeof(children) === 'object') {
|
|
93
|
-
childrenToArray = [children];
|
|
94
|
-
} else if (Array.isArray(children)) {
|
|
95
|
-
childrenToArray = _toConsumableArray(children);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
console.log('React.Children', _react["default"].Children);
|
|
99
|
-
|
|
100
|
-
_react["default"].Children.map(children, function (child) {
|
|
101
|
-
if (isPageBox(child)) {
|
|
102
|
-
boxCount += 1;
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
console.log(boxCount);
|
|
107
|
-
whiteCols = (_childrenToArray = childrenToArray) == null ? void 0 : (_childrenToArray$filt = _childrenToArray.filter(function (_ref2) {
|
|
108
|
-
var props = _ref2.props;
|
|
109
|
-
return (props == null ? void 0 : props.mode) === 'white';
|
|
110
|
-
})) == null ? void 0 : _childrenToArray$filt.length;
|
|
111
|
-
var total = ((_childrenToArray2 = childrenToArray) == null ? void 0 : _childrenToArray2.length) + 5;
|
|
112
|
-
var startIndex = total - whiteCols - 1;
|
|
113
|
-
var endIndex = total - 2;
|
|
114
|
-
var headerStyle = {
|
|
115
|
-
height: computedHeaderHeight,
|
|
116
|
-
padding: "".concat(size === 'small' ? 20 : 24, "px"),
|
|
117
|
-
zIndex: inLayout ? 1 : total || 1
|
|
118
|
-
};
|
|
119
|
-
var contentStyle = {
|
|
120
|
-
display: boxCount > 0 ? 'flex' : 'block',
|
|
121
|
-
marginTop: computedHeaderHeight,
|
|
122
|
-
padding: inLayout ? '16px 20px' : '0px'
|
|
123
|
-
};
|
|
124
|
-
return _react["default"].createElement("section", _extends({
|
|
125
|
-
className: (0, _classnames["default"])(clsPrefix, (_cn = {}, _defineProperty(_cn, className, className), _defineProperty(_cn, 'in-layout', inLayout), _defineProperty(_cn, 'not-in-layout', !inLayout), _cn))
|
|
126
|
-
}, restProps), (title || goBack || center || extra) && _react["default"].createElement("div", {
|
|
127
|
-
className: "".concat(clsPrefix, "-header"),
|
|
128
|
-
style: headerStyle
|
|
129
|
-
}, _react["default"].createElement("div", {
|
|
130
|
-
className: "".concat(clsPrefix, "-header-section")
|
|
131
|
-
}, goBack && _react["default"].createElement("div", {
|
|
132
|
-
className: "page-header-section-back",
|
|
133
|
-
onClick: function onClick() {
|
|
134
|
-
goBack();
|
|
135
|
-
}
|
|
136
|
-
}, _react["default"].createElement(_Icon["default"], {
|
|
137
|
-
type: "left"
|
|
138
|
-
}), _react["default"].createElement("span", null, goBackText ? goBackText : '返回')), title), [center, extra].map(function (item) {
|
|
139
|
-
return _react["default"].createElement("div", {
|
|
140
|
-
className: "".concat(clsPrefix, "-header-section")
|
|
141
|
-
}, item);
|
|
142
|
-
})), _react["default"].createElement("div", {
|
|
143
|
-
className: "".concat(clsPrefix, "-content"),
|
|
144
|
-
style: contentStyle
|
|
145
|
-
}, _react["default"].Children.map(children, function (child) {
|
|
146
|
-
// 如果children不是Box,就不需要多列布局
|
|
147
|
-
if (!child.type) {
|
|
148
|
-
// console.log("没有type");
|
|
149
|
-
return _react["default"].cloneElement(_react["default"].createElement("div", null, child));
|
|
150
|
-
}
|
|
43
|
+
// 计算children type是box的数量
|
|
44
|
+
let boxCount = 0;
|
|
151
45
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
size: size,
|
|
155
|
-
height: computedHeight,
|
|
156
|
-
contentTotalMargin: inLayout ? '32px' : '0px',
|
|
157
|
-
inLayout: inLayout
|
|
158
|
-
}, child.props);
|
|
46
|
+
// 如果children是单个节点,统一转为数组处理计算层级
|
|
47
|
+
console.log('children', children);
|
|
159
48
|
|
|
160
|
-
if (
|
|
161
|
-
|
|
49
|
+
if (typeof children === 'object') {
|
|
50
|
+
childrenToArray = [children];
|
|
51
|
+
} else if (Array.isArray(children)) {
|
|
52
|
+
childrenToArray = [...children];
|
|
162
53
|
}
|
|
163
54
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
55
|
+
console.log('React.Children', React.Children);
|
|
56
|
+
React.Children.map(children, (child) => {
|
|
57
|
+
if (isPageBox(child)) {
|
|
58
|
+
boxCount += 1;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log(boxCount);
|
|
63
|
+
|
|
64
|
+
whiteCols = childrenToArray?.filter(({ props }) => props?.mode === 'white')?.length;
|
|
65
|
+
const total = childrenToArray?.length + 5;
|
|
66
|
+
let startIndex = total - whiteCols - 1;
|
|
67
|
+
let endIndex = total - 2;
|
|
68
|
+
const headerStyle = {
|
|
69
|
+
height: computedHeaderHeight,
|
|
70
|
+
padding: `${size === 'small' ? 20 : 24}px`,
|
|
71
|
+
zIndex: inLayout ? 1 : total || 1
|
|
172
72
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
73
|
+
const contentStyle = {
|
|
74
|
+
display: boxCount > 0 ? 'flex' : 'block',
|
|
75
|
+
marginTop: computedHeaderHeight,
|
|
76
|
+
padding: inLayout ? '16px 20px' : '0px'
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<section
|
|
81
|
+
className={
|
|
82
|
+
cn(clsPrefix, {
|
|
83
|
+
[className]: className,
|
|
84
|
+
'in-layout': inLayout,
|
|
85
|
+
'not-in-layout': !inLayout
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
{...restProps}
|
|
89
|
+
>
|
|
90
|
+
{
|
|
91
|
+
(title || goBack || center || extra) &&
|
|
92
|
+
<div className={`${clsPrefix}-header`} style={headerStyle}>
|
|
93
|
+
<div className={`${clsPrefix}-header-section`}>
|
|
94
|
+
{
|
|
95
|
+
goBack &&
|
|
96
|
+
<div
|
|
97
|
+
className='page-header-section-back'
|
|
98
|
+
onClick={() => {
|
|
99
|
+
goBack();
|
|
100
|
+
}}
|
|
101
|
+
>
|
|
102
|
+
<Icon type="left" />
|
|
103
|
+
<span>{goBackText ? goBackText : '返回'}</span>
|
|
104
|
+
</div>
|
|
105
|
+
}
|
|
106
|
+
{title}
|
|
107
|
+
</div>
|
|
108
|
+
{
|
|
109
|
+
[center, extra].map(item => (
|
|
110
|
+
<div className={`${clsPrefix}-header-section`}>
|
|
111
|
+
{item}
|
|
112
|
+
</div>
|
|
113
|
+
))
|
|
114
|
+
}
|
|
115
|
+
</div>
|
|
116
|
+
}
|
|
117
|
+
<div className={`${clsPrefix}-content`} style={contentStyle}>
|
|
118
|
+
{React.Children.map(children, (child) => {
|
|
119
|
+
// 如果children不是Box,就不需要多列布局
|
|
120
|
+
if (!child.type) {
|
|
121
|
+
// console.log("没有type");
|
|
122
|
+
return React.cloneElement(<div>{child}</div>);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const extraProps = {
|
|
126
|
+
headerHeight: computedHeaderHeight,
|
|
127
|
+
size,
|
|
128
|
+
height: computedHeight,
|
|
129
|
+
contentTotalMargin: inLayout ? '32px' : '0px',
|
|
130
|
+
inLayout,
|
|
131
|
+
...child.props
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
if (!isPageBox(child)) {
|
|
135
|
+
return React.cloneElement(child, extraProps);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const { mode = 'gray', width } = child.props;
|
|
139
|
+
|
|
140
|
+
const style = {
|
|
141
|
+
flex: computeWidth(width),
|
|
142
|
+
// 设置cols层级关系
|
|
143
|
+
zIndex: mode === 'gray' ? endIndex-- : startIndex++
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const className = cn(`${clsPrefix}-box ${clsPrefix}-box-${mode}`);
|
|
147
|
+
|
|
148
|
+
return React.createElement(
|
|
149
|
+
'div',
|
|
150
|
+
{ className, style },
|
|
151
|
+
React.cloneElement(child, extraProps)
|
|
152
|
+
);
|
|
153
|
+
})}
|
|
154
|
+
</div>
|
|
155
|
+
</section>
|
|
156
|
+
);
|
|
179
157
|
};
|
|
180
158
|
|
|
181
|
-
PageLayout.Box =
|
|
182
|
-
|
|
183
|
-
|
|
159
|
+
PageLayout.Box = Box;
|
|
160
|
+
|
|
161
|
+
export default PageLayout;
|
package/lib/Page/utils.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var validNumber = isValidNumber(width);
|
|
11
|
-
|
|
12
|
-
if (/(%|px)$/.test(width) && validNumber) {
|
|
13
|
-
flex = "0 0 ".concat(width);
|
|
14
|
-
} else if (!isNaN(width)) {
|
|
15
|
-
flex = "0 0 ".concat(width, "px");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return flex;
|
|
1
|
+
const computeWidth = (width) => {
|
|
2
|
+
let flex = '1';
|
|
3
|
+
const validNumber = isValidNumber(width);
|
|
4
|
+
if (/(%|px)$/.test(width) && validNumber) {
|
|
5
|
+
flex = `0 0 ${width}`;
|
|
6
|
+
} else if (!isNaN(width)) {
|
|
7
|
+
flex = `0 0 ${width}px`;
|
|
8
|
+
}
|
|
9
|
+
return flex;
|
|
19
10
|
};
|
|
20
11
|
|
|
21
|
-
|
|
12
|
+
const isValidNumber = (value) => !isNaN(parseFloat(value));
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
return !isNaN(parseFloat(value));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
exports.isValidNumber = isValidNumber;
|
|
28
|
-
|
|
29
|
-
var addUnitForValue = function addUnitForValue(value) {
|
|
30
|
-
var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
|
|
31
|
-
return !isNaN(value) ? "".concat(value).concat(unit) : value;
|
|
32
|
-
};
|
|
14
|
+
const addUnitForValue = (value, unit = 'px') => !isNaN(value) ? `${value}${unit}` : value;
|
|
33
15
|
|
|
34
|
-
|
|
16
|
+
export { computeWidth, isValidNumber, addUnitForValue };
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
|
|
16
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
|
-
|
|
18
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
-
|
|
20
|
-
var _default = function _default(_ref) {
|
|
21
|
-
var value = _ref.value,
|
|
22
|
-
_onChange = _ref.onChange,
|
|
23
|
-
props = _objectWithoutProperties(_ref, ["value", "onChange"]);
|
|
24
|
-
|
|
25
|
-
return React.createElement(_checkbox["default"], _extends({}, props, {
|
|
26
|
-
checked: value,
|
|
27
|
-
onChange: function onChange(evt) {
|
|
28
|
-
_onChange == null ? void 0 : _onChange(evt.target.checked);
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
exports["default"] = _default;
|
|
1
|
+
import { Checkbox } from 'antd';
|
|
2
|
+
|
|
3
|
+
export default ({ value, onChange, ...props }) => (
|
|
4
|
+
<Checkbox
|
|
5
|
+
{...props}
|
|
6
|
+
checked={value}
|
|
7
|
+
onChange={evt => {
|
|
8
|
+
onChange?.(evt.target.checked);
|
|
9
|
+
}}
|
|
10
|
+
/>
|
|
11
|
+
);
|