tntd 1.3.57 → 1.3.62

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 (110) hide show
  1. package/babel.config.js +2 -2
  2. package/components/Layout/Application.js +1 -1
  3. package/components/QueryForm/Field/index.js +2 -1
  4. package/components/QueryListScene/List.js +17 -13
  5. package/lib/0645cf743e4e44ca9da321d689897f07.png +0 -0
  6. package/lib/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  7. package/lib/1d0b52448de217857b270af807e9360d.png +0 -0
  8. package/lib/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  9. package/lib/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  10. package/lib/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  11. package/lib/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  12. package/lib/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  13. package/lib/4abe481e130d7be0574e45573de8beb7.png +0 -0
  14. package/lib/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  15. package/lib/ArrayInput/icon.js +31 -27
  16. package/lib/ArrayInput/index.js +298 -211
  17. package/lib/AuthContext.js +13 -2
  18. package/lib/BlockHeader/README.md +83 -0
  19. package/lib/BlockHeader/fonts/OswaldLight.ttf +0 -0
  20. package/lib/BlockHeader/index.js +42 -0
  21. package/lib/BlockHeader/index.less +141 -0
  22. package/lib/Columns/index.js +100 -71
  23. package/lib/DevelopmentLogin/LoginModal.js +141 -79
  24. package/lib/DevelopmentLogin/index.js +55 -28
  25. package/lib/Ellipsis/Svg/CopySVG.js +71 -23
  26. package/lib/Ellipsis/Svg/TickSVG.js +49 -17
  27. package/lib/Ellipsis/index.js +155 -149
  28. package/lib/Handle/index.js +109 -72
  29. package/lib/Icon/fonts/iconfont.js +43 -1
  30. package/lib/Icon/iconList.js +8 -119
  31. package/lib/Icon/index.js +45 -13
  32. package/lib/Img/Contain.js +81 -49
  33. package/lib/Img/Cover.js +136 -88
  34. package/lib/Img/index.js +89 -36
  35. package/lib/Layout/ActionsContext.js +11 -2
  36. package/lib/Layout/AppList.js +256 -262
  37. package/lib/Layout/Application.js +135 -119
  38. package/lib/Layout/Avatar.js +137 -137
  39. package/lib/Layout/CompatibleLanguage.js +195 -214
  40. package/lib/Layout/EnterpriseLayout/Avatar.js +168 -156
  41. package/lib/Layout/EnterpriseLayout/Language.js +100 -75
  42. package/lib/Layout/EnterpriseLayout/Theme.js +94 -96
  43. package/lib/Layout/EnterpriseLayout/index.js +45 -32
  44. package/lib/Layout/GlobalNavigation/NavigationPopup.js +407 -335
  45. package/lib/Layout/GlobalNavigation/index.js +158 -110
  46. package/lib/Layout/Header.js +116 -165
  47. package/lib/Layout/HeaderActions.js +129 -170
  48. package/lib/Layout/HeaderNavs.js +113 -90
  49. package/lib/Layout/HeaderTabs.js +278 -312
  50. package/lib/Layout/Iconfont.js +15 -2
  51. package/lib/Layout/Language.js +102 -63
  52. package/lib/Layout/Layout.js +261 -272
  53. package/lib/Layout/Logo.js +87 -132
  54. package/lib/Layout/OrgAppList.js +319 -440
  55. package/lib/Layout/SideMenu.js +343 -429
  56. package/lib/Layout/Theme.js +124 -95
  57. package/lib/Layout/checkAuth.js +35 -21
  58. package/lib/Layout/createActions.js +51 -38
  59. package/lib/Layout/images/index.js +41 -33
  60. package/lib/Layout/index.js +161 -110
  61. package/lib/Layout/locale.js +53 -0
  62. package/lib/Layout/paaslayout/CompactSideMenu.js +178 -200
  63. package/lib/Layout/paaslayout/Header.js +90 -84
  64. package/lib/Layout/paaslayout/Logo.js +32 -27
  65. package/lib/Layout/paaslayout/SideMenu.js +174 -161
  66. package/lib/Layout/paaslayout/index.js +261 -240
  67. package/lib/Layout/paaslayout/index.less +75 -0
  68. package/lib/Layout/storage.js +78 -20
  69. package/lib/Layout/utils.js +143 -93
  70. package/lib/LoadingButton/index.js +57 -29
  71. package/lib/Modal/index.js +108 -83
  72. package/lib/Page/Box.js +81 -56
  73. package/lib/Page/index.js +173 -151
  74. package/lib/Page/utils.js +30 -12
  75. package/lib/QueryForm/Field/Checkbox.js +33 -11
  76. package/lib/QueryForm/Field/Select.js +99 -63
  77. package/lib/QueryForm/Field/SelectInput.js +114 -69
  78. package/lib/QueryForm/Field/fieldsMap.js +52 -30
  79. package/lib/QueryForm/Field/index.js +158 -75
  80. package/lib/QueryForm/createActions.js +65 -50
  81. package/lib/QueryForm/index.js +382 -303
  82. package/lib/QueryForm/useForm.js +17 -6
  83. package/lib/QueryListScene/Field/SelectInput.js +115 -0
  84. package/lib/QueryListScene/Field/fieldsMap.js +52 -0
  85. package/lib/QueryListScene/Field/index.js +159 -0
  86. package/lib/QueryListScene/Field/select.js +100 -0
  87. package/lib/QueryListScene/List.js +362 -285
  88. package/lib/QueryListScene/QueryForm/index.js +423 -0
  89. package/lib/QueryListScene/QueryForm/index.less +141 -0
  90. package/lib/QueryListScene/QueryForm.js +159 -91
  91. package/lib/QueryListScene/QueryListScene.js +87 -33
  92. package/lib/QueryListScene/Title.js +20 -10
  93. package/lib/QueryListScene/Toolbar.js +31 -8
  94. package/lib/QueryListScene/createActions.js +79 -64
  95. package/lib/QueryListScene/index.js +40 -23
  96. package/lib/QueryListScene/useActions.js +17 -6
  97. package/lib/Select/DropDownWrap.js +124 -60
  98. package/lib/Select/index.js +563 -426
  99. package/lib/Table/ResizableTable/index.js +121 -77
  100. package/lib/Table/index.js +51 -19
  101. package/lib/Title/index.js +52 -34
  102. package/lib/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  103. package/lib/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  104. package/lib/index.html +6 -0
  105. package/lib/index.js +159 -19
  106. package/lib/locale.js +63 -48
  107. package/lib/main.css +16420 -0
  108. package/lib/tntd.js +2 -0
  109. package/lib/tntd.js.LICENSE.txt +36 -0
  110. package/package.json +1 -1
package/lib/Page/Box.js CHANGED
@@ -1,61 +1,86 @@
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
- }
30
- }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ require("antd/es/card/style");
9
+
10
+ var _card = _interopRequireDefault(require("antd/es/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; }
31
23
 
32
- // 如果设置了noPadding,优先级最高
33
- if (noPadding) {
34
- bodyStyle.padding = 0;
35
- headStyle.padding = 0;
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;
36
61
  }
62
+ } // 如果设置了noPadding,优先级最高
63
+
64
+
65
+ if (noPadding) {
66
+ bodyStyle.padding = 0;
67
+ headStyle.padding = 0;
68
+ } // 如果传入只有数字,需要默认加px
69
+
37
70
 
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
- );
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);
59
83
  };
60
84
 
61
- export default Box;
85
+ var _default = Box;
86
+ exports["default"] = _default;
package/lib/Page/index.js CHANGED
@@ -1,161 +1,183 @@
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
- }
1
+ "use strict";
34
2
 
35
- if (inLayout) {
36
- computedHeaderHeight = '40px';
37
- }
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
38
7
 
39
- // 计算中间的zIndex,灰色递减,白色递增
40
- let whiteCols = 0;
41
- let childrenToArray = [];
8
+ var _react = _interopRequireDefault(require("react"));
42
9
 
43
- // 计算children type是box的数量
44
- let boxCount = 0;
10
+ var _classnames = _interopRequireDefault(require("classnames"));
45
11
 
46
- // 如果children是单个节点,统一转为数组处理计算层级
47
- console.log('children', children);
12
+ var _Icon = _interopRequireDefault(require("../Icon"));
48
13
 
49
- if (typeof children === 'object') {
50
- childrenToArray = [children];
51
- } else if (Array.isArray(children)) {
52
- childrenToArray = [...children];
53
- }
14
+ var _utils = require("./utils");
54
15
 
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
72
- };
73
- const contentStyle = {
74
- display: boxCount > 0 ? 'flex' : 'block',
75
- marginTop: computedHeaderHeight,
76
- padding: inLayout ? '16px 20px' : '0px'
77
- };
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; } }
78
37
 
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
- );
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';
45
+
46
+ var isPageBox = function isPageBox(child) {
47
+ var _child$props;
48
+
49
+ return (child == null ? void 0 : child.type) === _Box["default"] || (child == null ? void 0 : (_child$props = child.props) == null ? void 0 : _child$props.pageBox);
157
50
  };
158
51
 
159
- PageLayout.Box = Box;
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
+ }
151
+
152
+ var extraProps = _objectSpread({
153
+ headerHeight: computedHeaderHeight,
154
+ size: size,
155
+ height: computedHeight,
156
+ contentTotalMargin: inLayout ? '32px' : '0px',
157
+ inLayout: inLayout
158
+ }, child.props);
159
+
160
+ if (!isPageBox(child)) {
161
+ return _react["default"].cloneElement(child, extraProps);
162
+ }
163
+
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++
172
+ };
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
+ })));
179
+ };
160
180
 
161
- export default PageLayout;
181
+ PageLayout.Box = _Box["default"];
182
+ var _default = PageLayout;
183
+ exports["default"] = _default;
package/lib/Page/utils.js CHANGED
@@ -1,16 +1,34 @@
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;
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;
10
19
  };
11
20
 
12
- const isValidNumber = (value) => !isNaN(parseFloat(value));
21
+ exports.computeWidth = computeWidth;
13
22
 
14
- const addUnitForValue = (value, unit = 'px') => !isNaN(value) ? `${value}${unit}` : value;
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
+ };
15
33
 
16
- export { computeWidth, isValidNumber, addUnitForValue };
34
+ exports.addUnitForValue = addUnitForValue;
@@ -1,11 +1,33 @@
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
- );
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ require("antd/es/checkbox/style");
9
+
10
+ var _checkbox = _interopRequireDefault(require("antd/es/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;