tntd 1.4.6 → 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.
Files changed (86) hide show
  1. package/components/Layout/HeaderActions.js +90 -128
  2. package/components/LoadingButton/index.js +11 -15
  3. package/dist/stats.json +4958 -4958
  4. package/dist/tntd.js +1 -1
  5. package/es/Layout/HeaderActions.js +10 -10
  6. package/es/LoadingButton/index.js +20 -10
  7. package/lib/ArrayInput/icon.js +27 -31
  8. package/lib/ArrayInput/index.js +211 -298
  9. package/lib/AuthContext.js +2 -13
  10. package/lib/Columns/index.js +71 -100
  11. package/lib/DevelopmentLogin/LoginModal.js +79 -141
  12. package/lib/DevelopmentLogin/index.js +28 -55
  13. package/lib/Ellipsis/Svg/CopySVG.js +23 -71
  14. package/lib/Ellipsis/Svg/TickSVG.js +17 -49
  15. package/lib/Ellipsis/index.js +148 -154
  16. package/lib/Handle/index.js +72 -109
  17. package/lib/Icon/fonts/iconfont.js +1 -43
  18. package/lib/Icon/iconList.js +119 -8
  19. package/lib/Icon/index.js +13 -45
  20. package/lib/Img/Contain.js +49 -81
  21. package/lib/Img/Cover.js +88 -136
  22. package/lib/Img/index.js +36 -89
  23. package/lib/Layout/ActionsContext.js +2 -11
  24. package/lib/Layout/AppList.js +262 -256
  25. package/lib/Layout/Application.js +119 -135
  26. package/lib/Layout/Avatar.js +137 -137
  27. package/lib/Layout/CompatibleLanguage.js +214 -195
  28. package/lib/Layout/EnterpriseLayout/Avatar.js +156 -168
  29. package/lib/Layout/EnterpriseLayout/Language.js +75 -100
  30. package/lib/Layout/EnterpriseLayout/Theme.js +96 -94
  31. package/lib/Layout/EnterpriseLayout/index.js +32 -45
  32. package/lib/Layout/GlobalNavigation/NavigationPopup.js +335 -407
  33. package/lib/Layout/GlobalNavigation/index.js +110 -158
  34. package/lib/Layout/Header.js +165 -116
  35. package/lib/Layout/HeaderActions.js +132 -129
  36. package/lib/Layout/HeaderNavs.js +90 -113
  37. package/lib/Layout/HeaderTabs.js +312 -278
  38. package/lib/Layout/Iconfont.js +2 -15
  39. package/lib/Layout/Language.js +63 -102
  40. package/lib/Layout/Layout.js +272 -261
  41. package/lib/Layout/Logo.js +132 -87
  42. package/lib/Layout/OrgAppList.js +440 -319
  43. package/lib/Layout/SideMenu.js +429 -343
  44. package/lib/Layout/Theme.js +95 -124
  45. package/lib/Layout/checkAuth.js +21 -35
  46. package/lib/Layout/createActions.js +38 -51
  47. package/lib/Layout/images/index.js +33 -41
  48. package/lib/Layout/index.js +110 -161
  49. package/lib/Layout/paaslayout/CompactSideMenu.js +200 -178
  50. package/lib/Layout/paaslayout/Header.js +84 -90
  51. package/lib/Layout/paaslayout/Logo.js +27 -32
  52. package/lib/Layout/paaslayout/SideMenu.js +161 -174
  53. package/lib/Layout/paaslayout/index.js +240 -261
  54. package/lib/Layout/storage.js +20 -78
  55. package/lib/Layout/utils.js +93 -143
  56. package/lib/LoadingButton/index.js +25 -57
  57. package/lib/Modal/index.js +83 -108
  58. package/lib/Page/Box.js +56 -81
  59. package/lib/Page/index.js +151 -173
  60. package/lib/Page/utils.js +12 -30
  61. package/lib/QueryForm/Field/Checkbox.js +11 -33
  62. package/lib/QueryForm/Field/Select.js +63 -99
  63. package/lib/QueryForm/Field/SelectInput.js +69 -114
  64. package/lib/QueryForm/Field/fieldsMap.js +30 -52
  65. package/lib/QueryForm/Field/index.js +76 -158
  66. package/lib/QueryForm/createActions.js +50 -65
  67. package/lib/QueryForm/index.js +304 -383
  68. package/lib/QueryForm/useForm.js +6 -17
  69. package/lib/QueryListScene/List.js +290 -366
  70. package/lib/QueryListScene/QueryForm.js +93 -161
  71. package/lib/QueryListScene/QueryListScene.js +33 -87
  72. package/lib/QueryListScene/Title.js +10 -20
  73. package/lib/QueryListScene/Toolbar.js +8 -31
  74. package/lib/QueryListScene/createActions.js +64 -79
  75. package/lib/QueryListScene/index.js +23 -40
  76. package/lib/QueryListScene/useActions.js +6 -17
  77. package/lib/Select/DropDownWrap.js +60 -124
  78. package/lib/Select/index.js +425 -561
  79. package/lib/Table/ResizableTable/index.js +77 -121
  80. package/lib/Table/index.js +19 -51
  81. package/lib/Title/index.js +34 -52
  82. package/lib/index.js +19 -159
  83. package/lib/locale.js +48 -63
  84. package/package.json +1 -1
  85. package/lib/Layout/EnterpriseLayout/Header.js +0 -113
  86. package/lib/Layout/EnterpriseLayout/HeaderActions.js +0 -104
package/lib/Page/Box.js CHANGED
@@ -1,86 +1,61 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- require("antd/lib/card/style");
9
-
10
- var _card = _interopRequireDefault(require("antd/lib/card"));
11
-
12
- var _react = _interopRequireDefault(require("react"));
13
-
14
- var _utils = require("./utils");
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
-
18
- 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); }
19
-
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
-
24
- 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; }
25
-
26
- 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; }
27
-
28
- 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; }
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
- cardTitleHeight = (0, _utils.addUnitForValue)(cardTitleHeight);
72
- var cardBodyHeight = "calc(".concat(height, " - ").concat(headerHeight, " - ").concat(contentTotalMargin, " - ").concat(cardTitleHeight, ")");
73
- return _react["default"].createElement(_card["default"], _extends({
74
- className: "".concat(clsPrefix, "-box-card"),
75
- bordered: bordered,
76
- bodyStyle: _objectSpread({}, bodyStyle, {
77
- // overflow: 'auto',
78
- height: inLayout ? "calc(100% - ".concat(headerHeight, ")") : cardBodyHeight
79
- }),
80
- size: size,
81
- headStyle: headStyle
82
- }, restProps), children);
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
- var _default = Box;
86
- exports["default"] = _default;
61
+ export default Box;
package/lib/Page/index.js CHANGED
@@ -1,183 +1,161 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
-
12
- var _Icon = _interopRequireDefault(require("../Icon"));
13
-
14
- var _utils = require("./utils");
15
-
16
- var _Box = _interopRequireDefault(require("./Box"));
17
-
18
- require("./index.less");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
-
22
- 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); }
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
-
28
- 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; }
29
-
30
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
31
-
32
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
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
- var isPageBox = function isPageBox(child) {
47
- var _child$props;
35
+ if (inLayout) {
36
+ computedHeaderHeight = '40px';
37
+ }
48
38
 
49
- return (child == null ? void 0 : child.type) === _Box["default"] || (child == null ? void 0 : (_child$props = child.props) == null ? void 0 : _child$props.pageBox);
50
- };
39
+ // 计算中间的zIndex,灰色递减,白色递增
40
+ let whiteCols = 0;
41
+ let childrenToArray = [];
51
42
 
52
- var PageLayout = function PageLayout(_ref) {
53
- var _childrenToArray, _childrenToArray$filt, _childrenToArray2, _cn;
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
- var extraProps = _objectSpread({
153
- headerHeight: computedHeaderHeight,
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 (!isPageBox(child)) {
161
- return _react["default"].cloneElement(child, extraProps);
49
+ if (typeof children === 'object') {
50
+ childrenToArray = [children];
51
+ } else if (Array.isArray(children)) {
52
+ childrenToArray = [...children];
162
53
  }
163
54
 
164
- var _child$props2 = child.props,
165
- _child$props2$mode = _child$props2.mode,
166
- mode = _child$props2$mode === void 0 ? 'gray' : _child$props2$mode,
167
- width = _child$props2.width;
168
- var style = {
169
- flex: (0, _utils.computeWidth)(width),
170
- // 设置cols层级关系
171
- zIndex: mode === 'gray' ? endIndex-- : startIndex++
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
- var className = (0, _classnames["default"])("".concat(clsPrefix, "-box ").concat(clsPrefix, "-box-").concat(mode));
174
- return _react["default"].createElement('div', {
175
- className: className,
176
- style: style
177
- }, _react["default"].cloneElement(child, extraProps));
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 = _Box["default"];
182
- var _default = PageLayout;
183
- exports["default"] = _default;
159
+ PageLayout.Box = Box;
160
+
161
+ export default PageLayout;
package/lib/Page/utils.js CHANGED
@@ -1,34 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.addUnitForValue = exports.isValidNumber = exports.computeWidth = void 0;
7
-
8
- var computeWidth = function computeWidth(width) {
9
- var flex = '1';
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
- exports.computeWidth = computeWidth;
12
+ const isValidNumber = (value) => !isNaN(parseFloat(value));
22
13
 
23
- var isValidNumber = function isValidNumber(value) {
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
- exports.addUnitForValue = addUnitForValue;
16
+ export { computeWidth, isValidNumber, addUnitForValue };
@@ -1,33 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- require("antd/lib/checkbox/style");
9
-
10
- var _checkbox = _interopRequireDefault(require("antd/lib/checkbox"));
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
+ );