@teamix/pro 1.4.14 → 1.4.17
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/dist/pro.css +1 -1
- package/dist/pro.js +440 -114
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/card/index.js +49 -6
- package/es/card/index.scss +8 -0
- package/es/form/ProForm/index.js +14 -32
- package/es/form/ProForm/index.scss +9 -2
- package/es/form/ProForm/useAutoLayout.d.ts +9 -0
- package/es/form/ProForm/useAutoLayout.js +114 -0
- package/es/form/SchemaForm/initializeArrayTable.js +42 -7
- package/es/form/typing.d.ts +4 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/baseInfo/index.js +9 -3
- package/es/info/components/headerInfo/index.js +11 -3
- package/es/info/components/tableInfo/index.js +6 -3
- package/es/info/typing.d.ts +2 -0
- package/es/info/utils/index.d.ts +8 -0
- package/es/info/utils/index.js +28 -1
- package/es/nocode/index.scss +2 -2
- package/es/nocode/pages/playground.js +1 -1
- package/es/nocode/pages/renderer.js +1 -1
- package/es/nocode/playground.js +1 -1
- package/es/sidebar/components/tree-node/index.js +15 -6
- package/es/sidebar/components/tree-node/index.scss +9 -5
- package/es/sidebar/index.js +2 -2
- package/es/sidebar/index.scss +13 -1
- package/es/sidebar/typing.d.ts +4 -2
- package/es/sidebar/utils/index.d.ts +278 -0
- package/es/sidebar/utils/index.js +55 -14
- package/es/table/components/Layout/index.js +12 -6
- package/es/table/components/QuickAction/index.js +1 -1
- package/es/table/index.js +36 -11
- package/es/table/index.scss +8 -0
- package/lib/card/index.js +58 -6
- package/lib/card/index.scss +8 -0
- package/lib/form/ProForm/index.js +13 -31
- package/lib/form/ProForm/index.scss +9 -2
- package/lib/form/ProForm/useAutoLayout.d.ts +9 -0
- package/lib/form/ProForm/useAutoLayout.js +124 -0
- package/lib/form/SchemaForm/initializeArrayTable.js +42 -7
- package/lib/form/typing.d.ts +4 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/baseInfo/index.js +8 -2
- package/lib/info/components/headerInfo/index.js +10 -2
- package/lib/info/components/tableInfo/index.js +5 -2
- package/lib/info/typing.d.ts +2 -0
- package/lib/info/utils/index.d.ts +8 -0
- package/lib/info/utils/index.js +29 -0
- package/lib/nocode/index.scss +2 -2
- package/lib/nocode/pages/playground.js +1 -1
- package/lib/nocode/pages/renderer.js +1 -1
- package/lib/nocode/playground.js +1 -1
- package/lib/sidebar/components/tree-node/index.js +16 -6
- package/lib/sidebar/components/tree-node/index.scss +9 -5
- package/lib/sidebar/index.js +2 -2
- package/lib/sidebar/index.scss +13 -1
- package/lib/sidebar/typing.d.ts +4 -2
- package/lib/sidebar/utils/index.d.ts +278 -0
- package/lib/sidebar/utils/index.js +56 -14
- package/lib/table/components/Layout/index.js +12 -6
- package/lib/table/components/QuickAction/index.js +1 -1
- package/lib/table/index.js +35 -10
- package/lib/table/index.scss +8 -0
- package/package.json +1 -1
package/es/table/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody"];
|
1
|
+
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree"];
|
2
2
|
|
3
3
|
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); }
|
4
4
|
|
@@ -32,7 +32,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
32
32
|
|
33
33
|
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; }
|
34
34
|
|
35
|
-
import React, { useState, useEffect, useRef } from 'react';
|
35
|
+
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
36
36
|
import { Table, Checkbox } from '@alicloudfe/components';
|
37
37
|
import Pagination from './components/Pagination';
|
38
38
|
import genProColumnToColumn from './utils/genProColumnToColumn';
|
@@ -175,6 +175,7 @@ var ProTable = function ProTable(props) {
|
|
175
175
|
context = props.context,
|
176
176
|
_props$fixedTableBody = props.fixedTableBody,
|
177
177
|
fixedTableBody = _props$fixedTableBody === void 0 ? false : _props$fixedTableBody,
|
178
|
+
isTree = props.isTree,
|
178
179
|
otherProps = _objectWithoutProperties(props, _excluded);
|
179
180
|
|
180
181
|
var targetPageKey = pageKey || globalPageKey;
|
@@ -316,7 +317,11 @@ var ProTable = function ProTable(props) {
|
|
316
317
|
}, []); // 获取header高度,用作全屏吸底吸底高度计算以及固定body高度计算(滚动条在底部)
|
317
318
|
|
318
319
|
var getHeaderHeight = function getHeaderHeight(isFullscreen, offset) {
|
319
|
-
var _tableDom$getElements, _tableDom$getElements2;
|
320
|
+
var _tableDom$getElements, _tableDom$getElements2, _document$querySelect, _document$querySelect2, _document$querySelect3;
|
321
|
+
|
322
|
+
if (!fixedTableBody) {
|
323
|
+
return;
|
324
|
+
}
|
320
325
|
|
321
326
|
var tableDom = tableRef.current;
|
322
327
|
var headerDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements = tableDom.getElementsByClassName('teamix-pro-table-layout')) === null || _tableDom$getElements === void 0 ? void 0 : _tableDom$getElements[0];
|
@@ -326,8 +331,9 @@ var ProTable = function ProTable(props) {
|
|
326
331
|
var tableHeaderDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements2 = tableDom.getElementsByClassName(basePrefix('table-header-inner'))) === null || _tableDom$getElements2 === void 0 ? void 0 : _tableDom$getElements2[0];
|
327
332
|
var pageContainerDom = document.querySelector('.teamix-pro-page-container-header');
|
328
333
|
var teamixNavDom = document.querySelector('.teamix-nav-console');
|
329
|
-
var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer');
|
330
|
-
|
334
|
+
var footerRowSelectionDom = document.querySelector('.teamix-pro-page-container-footer'); // 这边不能直接取 next-table-body
|
335
|
+
|
336
|
+
var tableBodyDom = (_document$querySelect = document.querySelector('.teamix-pro-table')) === null || _document$querySelect === void 0 ? void 0 : (_document$querySelect2 = _document$querySelect.getElementsByTagName('table')) === null || _document$querySelect2 === void 0 ? void 0 : (_document$querySelect3 = _document$querySelect2[1]) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.parentNode;
|
331
337
|
var headerFixedTopSectionDom = document.querySelector('.teamix-pro-page-container-fixed-top');
|
332
338
|
setTimeout(function () {
|
333
339
|
var _headerDom$offsetHeig, _tableHeaderDom$offse;
|
@@ -345,9 +351,8 @@ var ProTable = function ProTable(props) {
|
|
345
351
|
var teamixNavHeight = (_teamixNavDom$offsetH = teamixNavDom === null || teamixNavDom === void 0 ? void 0 : teamixNavDom.offsetHeight) !== null && _teamixNavDom$offsetH !== void 0 ? _teamixNavDom$offsetH : 0; // 1 为预留值,js无法取出精确高度,会被四舍五入
|
346
352
|
|
347
353
|
var offsetHeaderHeight = headerHeight + tableHeaderHeight + pageHeaderHeight + teamixNavHeight + footerRowSelectionHeight + 16 + (offset !== null && offset !== void 0 ? offset : 0) + 1;
|
348
|
-
var clientTableBodyHeight = document.body.clientHeight - offsetHeaderHeight;
|
349
354
|
|
350
|
-
if (tableBodyDom.clientHeight <
|
355
|
+
if (tableBodyDom.clientHeight < tableBodyDom.scrollHeight) {
|
351
356
|
setFooterSuctionState(true);
|
352
357
|
} else {
|
353
358
|
setFooterSuctionState(false);
|
@@ -405,6 +410,10 @@ var ProTable = function ProTable(props) {
|
|
405
410
|
|
406
411
|
|
407
412
|
var getFooterSuctionState = function getFooterSuctionState() {
|
413
|
+
if (!footerSuction) {
|
414
|
+
return;
|
415
|
+
}
|
416
|
+
|
408
417
|
var containerDom = document.querySelector('.teamix-pro-page-container-scroll-container');
|
409
418
|
|
410
419
|
if (containerDom) {
|
@@ -803,7 +812,7 @@ var ProTable = function ProTable(props) {
|
|
803
812
|
if (Number.isInteger(time) && time >= 1000) {
|
804
813
|
autoRefreshTimerRef.current = setTimeout(function () {
|
805
814
|
// 自动刷新不显示 loading
|
806
|
-
_request(
|
815
|
+
_request(requestData, true);
|
807
816
|
}, Number(time));
|
808
817
|
}
|
809
818
|
});
|
@@ -900,8 +909,10 @@ var ProTable = function ProTable(props) {
|
|
900
909
|
columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context),
|
901
910
|
loading: getTableLoading(),
|
902
911
|
className: classNames('teamix-pro-table', tableClassName, {
|
903
|
-
'with-row-select': rowSelection
|
912
|
+
'with-row-select': rowSelection,
|
913
|
+
'teamix-pro-tree-table': isTree
|
904
914
|
}),
|
915
|
+
isTree: isTree,
|
905
916
|
size: size,
|
906
917
|
onSort: onSort,
|
907
918
|
sort: sort,
|
@@ -1039,8 +1050,22 @@ var ProTable = function ProTable(props) {
|
|
1039
1050
|
className: cls('footer-right-wrapper')
|
1040
1051
|
}, showSkeleton ? /*#__PURE__*/React.createElement(Skeleton.Footer.Pagination, null) : footer));
|
1041
1052
|
}
|
1042
|
-
};
|
1053
|
+
}; // 判断是否需要吸底
|
1043
1054
|
|
1055
|
+
|
1056
|
+
var fixFooterState = useMemo(function () {
|
1057
|
+
if (fullscreenState) {
|
1058
|
+
return false;
|
1059
|
+
}
|
1060
|
+
|
1061
|
+
if (fixedTableBody || footerSuction) {
|
1062
|
+
if (footerSuctionState) {
|
1063
|
+
return true;
|
1064
|
+
}
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
return false;
|
1068
|
+
}, [fullscreenState, fixedTableBody, footerSuction, footerSuctionState]);
|
1044
1069
|
return /*#__PURE__*/React.createElement(FullScreen, {
|
1045
1070
|
visible: fullscreenState,
|
1046
1071
|
actionRef: actionRef
|
@@ -1052,7 +1077,7 @@ var ProTable = function ProTable(props) {
|
|
1052
1077
|
|
1053
1078
|
}),
|
1054
1079
|
ref: tableRef
|
1055
|
-
}, renderTable(isFullScreen),
|
1080
|
+
}, renderTable(isFullScreen), fixFooterState && /*#__PURE__*/React.createElement(ProPageContainer.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
|
1056
1081
|
});
|
1057
1082
|
};
|
1058
1083
|
|
package/es/table/index.scss
CHANGED
package/lib/card/index.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
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); }
|
4
|
+
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
4
6
|
value: true
|
5
7
|
});
|
@@ -38,7 +40,9 @@ var _tab = _interopRequireDefault(require("./tab"));
|
|
38
40
|
|
39
41
|
require("./index.scss");
|
40
42
|
|
41
|
-
var _proField =
|
43
|
+
var _proField = _interopRequireWildcard(require("@teamix/pro-field"));
|
44
|
+
|
45
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
42
46
|
|
43
47
|
var _cardContainer = require("./card-container");
|
44
48
|
|
@@ -56,6 +60,10 @@ Object.keys(_cardContainer).forEach(function (key) {
|
|
56
60
|
var _excluded = ["context"],
|
57
61
|
_excluded2 = ["children", "title", "subTitle", "tooltip", "tooltipIcon", "tags", "description", "extra", "actions", "message", "style", "className", "image", "hoveredShadow", "divider", "bordered", "compacted", "centered", "loading", "contentLoading", "empty", "borderColor", "backgroundColor", "contentClassName", "contentStyle", "direction", "wrap", "spacing", "split", "collapsible", "defaultCollapsed", "collapsed", "onCollapse", "context"];
|
58
62
|
|
63
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
64
|
+
|
65
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
66
|
+
|
59
67
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
60
68
|
|
61
69
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
@@ -155,9 +163,20 @@ var ProCard = function ProCard(props) {
|
|
155
163
|
innerCollapseState = _React$useState2[0],
|
156
164
|
setInnerCollapseState = _React$useState2[1];
|
157
165
|
|
166
|
+
var cardRef = _react.default.useRef(); // 表头 tooltip tags description 宽度
|
167
|
+
|
168
|
+
|
169
|
+
var _React$useState3 = _react.default.useState(0),
|
170
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
171
|
+
headerWithoutTitleWidth = _React$useState4[0],
|
172
|
+
setHeaderWithoutTitleWidth = _React$useState4[1];
|
173
|
+
|
158
174
|
var _formatSpacing = (0, _utils2.formatSpacing)(spacing),
|
159
175
|
horizonal = _formatSpacing.horizonal,
|
160
|
-
vertical = _formatSpacing.vertical;
|
176
|
+
vertical = _formatSpacing.vertical; // useEffect(() => {
|
177
|
+
// calculateHeaderWidth();
|
178
|
+
// }, []);
|
179
|
+
|
161
180
|
|
162
181
|
var hasDivider = (divider || !!split) && (title || extra);
|
163
182
|
var hasCollapse = collapsible === true || defaultCollapsed !== undefined || collapsed !== undefined;
|
@@ -234,7 +253,29 @@ var ProCard = function ProCard(props) {
|
|
234
253
|
marginBottom: -vertical
|
235
254
|
} : {};
|
236
255
|
|
237
|
-
var cardContentStyle = _objectSpread(_objectSpread({}, cardContentMargin), contentStyle);
|
256
|
+
var cardContentStyle = _objectSpread(_objectSpread({}, cardContentMargin), contentStyle); // 计算宽度
|
257
|
+
|
258
|
+
|
259
|
+
var calculateHeaderWidth = function calculateHeaderWidth() {
|
260
|
+
if (cardRef === null || cardRef === void 0 ? void 0 : cardRef.current) {
|
261
|
+
var _tooltipDom$clientWid, _tagsDom$clientWidth, _descriptionDom$clien;
|
262
|
+
|
263
|
+
var cardDom = _reactDom.default.findDOMNode(cardRef.current);
|
264
|
+
|
265
|
+
var headerDom = cardDom === null || cardDom === void 0 ? void 0 : cardDom.querySelector('.teamix-pro-card-title');
|
266
|
+
var tooltipDom = headerDom === null || headerDom === void 0 ? void 0 : headerDom.querySelector('.teamix-pro-card-title-tooltip');
|
267
|
+
var tagsDom = headerDom === null || headerDom === void 0 ? void 0 : headerDom.querySelector('.teamix-pro-tags');
|
268
|
+
var descriptionDom = headerDom === null || headerDom === void 0 ? void 0 : headerDom.querySelector('.teamix-pro-card-title-description');
|
269
|
+
var widthList = [(_tooltipDom$clientWid = tooltipDom === null || tooltipDom === void 0 ? void 0 : tooltipDom.clientWidth) !== null && _tooltipDom$clientWid !== void 0 ? _tooltipDom$clientWid : 0, (_tagsDom$clientWidth = tagsDom === null || tagsDom === void 0 ? void 0 : tagsDom.clientWidth) !== null && _tagsDom$clientWidth !== void 0 ? _tagsDom$clientWidth : 0, (_descriptionDom$clien = descriptionDom === null || descriptionDom === void 0 ? void 0 : descriptionDom.clientWidth) !== null && _descriptionDom$clien !== void 0 ? _descriptionDom$clien : 0].filter(function (item) {
|
270
|
+
return item;
|
271
|
+
});
|
272
|
+
var width = widthList.reduce(function (acc, cur) {
|
273
|
+
return acc + cur;
|
274
|
+
}, 0) + widthList.length * 8; // 无法取出精准宽度,减去1作为阈值
|
275
|
+
|
276
|
+
setHeaderWithoutTitleWidth(width - 1);
|
277
|
+
}
|
278
|
+
};
|
238
279
|
|
239
280
|
var renderTitle = function renderTitle() {
|
240
281
|
var icon = tooltipIcon || 'info-circle-line';
|
@@ -254,9 +295,20 @@ var ProCard = function ProCard(props) {
|
|
254
295
|
type: "down-fill"
|
255
296
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
256
297
|
className: cls('title-name')
|
257
|
-
},
|
258
|
-
|
259
|
-
|
298
|
+
}, /*#__PURE__*/_react.default.createElement(_proField.default, {
|
299
|
+
value: title,
|
300
|
+
type: "text",
|
301
|
+
render: {
|
302
|
+
ellipsis: true
|
303
|
+
}
|
304
|
+
}))), !hasCollapse && /*#__PURE__*/_react.default.createElement("div", {
|
305
|
+
className: cls('title-name'),
|
306
|
+
style: {
|
307
|
+
maxWidth: "calc(100% - ".concat(headerWithoutTitleWidth, "px)")
|
308
|
+
}
|
309
|
+
}, /*#__PURE__*/_react.default.createElement(_proField.Ellipsis, {
|
310
|
+
tooltip: title
|
311
|
+
}, title)), tooltip && /*#__PURE__*/_react.default.createElement("div", {
|
260
312
|
className: cls('title-tooltip')
|
261
313
|
}, /*#__PURE__*/_react.default.createElement(_components.Balloon.Tooltip, {
|
262
314
|
align: "t",
|
package/lib/card/index.scss
CHANGED
@@ -40,6 +40,13 @@
|
|
40
40
|
}
|
41
41
|
}
|
42
42
|
|
43
|
+
.next-card-header-titles {
|
44
|
+
padding-right: 8px;
|
45
|
+
}
|
46
|
+
.next-card-header-extra {
|
47
|
+
margin-top: 2px;
|
48
|
+
}
|
49
|
+
|
43
50
|
&-title {
|
44
51
|
display: flex;
|
45
52
|
align-items: center;
|
@@ -80,6 +87,7 @@
|
|
80
87
|
|
81
88
|
&-description {
|
82
89
|
font-size: 12px;
|
90
|
+
min-width: 40px;
|
83
91
|
}
|
84
92
|
}
|
85
93
|
|
@@ -31,17 +31,17 @@ var _index = _interopRequireDefault(require("../Components/Text/index"));
|
|
31
31
|
|
32
32
|
var _SchemaForm = _interopRequireDefault(require("../SchemaForm"));
|
33
33
|
|
34
|
-
var _utils2 = require("../utils");
|
35
|
-
|
36
34
|
var _useAutoSubmit = _interopRequireDefault(require("./useAutoSubmit"));
|
37
35
|
|
36
|
+
var _useAutoLayout = _interopRequireDefault(require("./useAutoLayout"));
|
37
|
+
|
38
38
|
var _useInitialRequest = _interopRequireDefault(require("./useInitialRequest"));
|
39
39
|
|
40
40
|
var _validate = _interopRequireDefault(require("../locales/validate"));
|
41
41
|
|
42
42
|
require("./index.scss");
|
43
43
|
|
44
|
-
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "
|
44
|
+
var _excluded = ["form", "initialValues", "initialRequest", "scope", "context", "components", "onChange", "onChangeType", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst", "schema", "children"];
|
45
45
|
|
46
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
47
47
|
|
@@ -95,12 +95,6 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
95
95
|
scope = _ref.scope,
|
96
96
|
context = _ref.context,
|
97
97
|
components = _ref.components,
|
98
|
-
layout = _ref.layout,
|
99
|
-
labelAlign = _ref.labelAlign,
|
100
|
-
wrapperAlign = _ref.wrapperAlign,
|
101
|
-
labelCol = _ref.labelCol,
|
102
|
-
wrapperCol = _ref.wrapperCol,
|
103
|
-
breakpoints = _ref.breakpoints,
|
104
98
|
onChange = _ref.onChange,
|
105
99
|
onChangeType = _ref.onChangeType,
|
106
100
|
onSubmit = _ref.onSubmit,
|
@@ -112,7 +106,8 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
112
106
|
children = _ref.children,
|
113
107
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
114
108
|
|
115
|
-
// 获取全局配置
|
109
|
+
var formRef = (0, _react.useRef)(); // 获取全局配置
|
110
|
+
|
116
111
|
var _ref2 = (0, _utils.getGlobalConfig)('ProForm') || {},
|
117
112
|
globalComponents = _ref2.components,
|
118
113
|
globalScope = _ref2.scope;
|
@@ -130,25 +125,10 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
130
125
|
|
131
126
|
var mergedComponents = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, globalComponents), components), formilyComponents), _ProField.default);
|
132
127
|
|
133
|
-
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit, context);
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
breakpoints: [480],
|
138
|
-
layout: (0, _utils2.mergeArrayValue)(['vertical'], layout),
|
139
|
-
labelAlign: (0, _utils2.mergeArrayValue)(['left'], labelAlign),
|
140
|
-
wrapperAlign: (0, _utils2.mergeArrayValue)(['left'], wrapperAlign),
|
141
|
-
labelCol: (0, _utils2.mergeArrayValue)([24], labelCol),
|
142
|
-
wrapperCol: (0, _utils2.mergeArrayValue)([24], wrapperCol)
|
143
|
-
} : {
|
144
|
-
breakpoints: (0, _utils.isBool)(breakpoints) ? undefined : breakpoints,
|
145
|
-
layout: layout,
|
146
|
-
labelAlign: labelAlign,
|
147
|
-
wrapperAlign: wrapperAlign,
|
148
|
-
labelCol: labelCol,
|
149
|
-
wrapperCol: wrapperCol
|
150
|
-
};
|
151
|
-
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
128
|
+
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit, context);
|
129
|
+
var autoTeamixLayout = (0, _useAutoLayout.default)(_objectSpread(_objectSpread({}, otherProps), {}, {
|
130
|
+
schema: schema
|
131
|
+
}), formRef);
|
152
132
|
(0, _react.useMemo)(function () {
|
153
133
|
// 配置表单默认值
|
154
134
|
if (initialValues) {
|
@@ -189,7 +169,7 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
189
169
|
}, []);
|
190
170
|
return /*#__PURE__*/_react.default.createElement(_formily.Form, _objectSpread(_objectSpread(_objectSpread({
|
191
171
|
className: (0, _utils.cls)(prefixCls(), className)
|
192
|
-
}, otherProps),
|
172
|
+
}, otherProps), autoTeamixLayout), {}, {
|
193
173
|
form: form,
|
194
174
|
onAutoSubmit: onAutoSubmit,
|
195
175
|
onAutoSubmitFailed: onSubmitFailed
|
@@ -197,7 +177,9 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
197
177
|
schema: schema,
|
198
178
|
scope: mergedScope,
|
199
179
|
components: mergedComponents
|
200
|
-
}) : null,
|
180
|
+
}) : null, /*#__PURE__*/_react.default.createElement("div", {
|
181
|
+
ref: formRef
|
182
|
+
}), children);
|
201
183
|
});
|
202
184
|
ProForm.defaultProps = {
|
203
185
|
colon: false,
|
@@ -338,8 +338,15 @@
|
|
338
338
|
}
|
339
339
|
|
340
340
|
// ArrayTable
|
341
|
-
.#{$form-array}-table
|
342
|
-
|
341
|
+
.#{$form-array}-table {
|
342
|
+
&-status-select {
|
343
|
+
display: none;
|
344
|
+
}
|
345
|
+
.#{$css-prefix}formily-item:not(.#{$form-item-cls}-feedback-layout-popover) {
|
346
|
+
.#{$form-item-cls}-help {
|
347
|
+
z-index: 2 !important;
|
348
|
+
}
|
349
|
+
}
|
343
350
|
}
|
344
351
|
|
345
352
|
// SelectTable
|
@@ -0,0 +1,9 @@
|
|
1
|
+
declare const useAutoLayout: ({ breakpoints: outBreakpoints, layout, labelAlign, wrapperAlign, labelCol: outLabelCol, wrapperCol: outWrapperCol, autoLayout, schema, }: any, formRef: any) => {
|
2
|
+
breakpoints: any;
|
3
|
+
layout: any;
|
4
|
+
labelAlign: any;
|
5
|
+
wrapperAlign: any;
|
6
|
+
labelCol: any;
|
7
|
+
wrapperCol: any;
|
8
|
+
};
|
9
|
+
export default useAutoLayout;
|
@@ -0,0 +1,124 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = require("react");
|
9
|
+
|
10
|
+
var _utils = require("@teamix/utils");
|
11
|
+
|
12
|
+
var _utils2 = require("../utils");
|
13
|
+
|
14
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
15
|
+
|
16
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
17
|
+
|
18
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
19
|
+
|
20
|
+
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; }
|
21
|
+
|
22
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
23
|
+
|
24
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
25
|
+
|
26
|
+
var useAutoLayout = function useAutoLayout(_ref, formRef) {
|
27
|
+
var outBreakpoints = _ref.breakpoints,
|
28
|
+
layout = _ref.layout,
|
29
|
+
labelAlign = _ref.labelAlign,
|
30
|
+
wrapperAlign = _ref.wrapperAlign,
|
31
|
+
outLabelCol = _ref.labelCol,
|
32
|
+
outWrapperCol = _ref.wrapperCol,
|
33
|
+
autoLayout = _ref.autoLayout,
|
34
|
+
schema = _ref.schema;
|
35
|
+
|
36
|
+
var _ref2 = (0, _utils.isPlainObj)(autoLayout) ? autoLayout : {
|
37
|
+
autoLabel: autoLayout
|
38
|
+
},
|
39
|
+
autoLabel = _ref2.autoLabel;
|
40
|
+
|
41
|
+
var breakpoints = (0, _react.useMemo)(function () {
|
42
|
+
return autoLabel ? false : outBreakpoints;
|
43
|
+
}, []); // 当前断点不支持Col更新
|
44
|
+
|
45
|
+
var _useState = (0, _react.useState)({
|
46
|
+
labelCol: outLabelCol,
|
47
|
+
wrapperCol: outWrapperCol
|
48
|
+
}),
|
49
|
+
_useState2 = _slicedToArray(_useState, 2),
|
50
|
+
autoCol = _useState2[0],
|
51
|
+
setAutoCol = _useState2[1];
|
52
|
+
|
53
|
+
var labelCol = autoCol.labelCol,
|
54
|
+
wrapperCol = autoCol.wrapperCol;
|
55
|
+
(0, _react.useEffect)(function () {
|
56
|
+
/**
|
57
|
+
* autolayout
|
58
|
+
*/
|
59
|
+
if (autoLabel) {
|
60
|
+
var formWidth = formRef.current.getBoundingClientRect().width; // 表单宽度
|
61
|
+
|
62
|
+
var labelArray = schema.map(function (item) {
|
63
|
+
var text = item.title;
|
64
|
+
|
65
|
+
if ((0, _utils.isStr)(text)) {
|
66
|
+
var _item$decoratorProps;
|
67
|
+
|
68
|
+
if (item.required) {
|
69
|
+
text += '一'; // 必填 + 12
|
70
|
+
}
|
71
|
+
|
72
|
+
if ((_item$decoratorProps = item.decoratorProps) === null || _item$decoratorProps === void 0 ? void 0 : _item$decoratorProps.tooltip) {
|
73
|
+
text += '一'; // 提示 + 18
|
74
|
+
}
|
75
|
+
|
76
|
+
return text;
|
77
|
+
}
|
78
|
+
|
79
|
+
return '';
|
80
|
+
}); // 标题内容集合
|
81
|
+
|
82
|
+
var labelWidthArray = (0, _utils.getWidthByCharacterMap)(labelArray); // 标题宽度集合
|
83
|
+
|
84
|
+
var _autoWidthBySpace = (0, _utils.autoWidthBySpace)(labelWidthArray),
|
85
|
+
expectedWidth = _autoWidthBySpace.expectedWidth,
|
86
|
+
consoleArray = _autoWidthBySpace.consoleArray; // 智能计算预期宽度
|
87
|
+
|
88
|
+
|
89
|
+
var expectedCol = Math.ceil(expectedWidth / formWidth * 24); // 预期宽度转换为 Col 值
|
90
|
+
|
91
|
+
setAutoCol({
|
92
|
+
labelCol: expectedCol,
|
93
|
+
wrapperCol: wrapperCol
|
94
|
+
});
|
95
|
+
} else {
|
96
|
+
setAutoCol({
|
97
|
+
labelCol: outLabelCol,
|
98
|
+
wrapperCol: outWrapperCol
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}, [outLabelCol, outWrapperCol]); // Layout配置By断点(配置断点后,目前不支持 Col 更新)
|
102
|
+
|
103
|
+
var autoTeamixLayout = (0, _react.useMemo)(function () {
|
104
|
+
return breakpoints === true ? {
|
105
|
+
breakpoints: [480],
|
106
|
+
layout: (0, _utils2.mergeArrayValue)(['vertical'], layout),
|
107
|
+
labelAlign: (0, _utils2.mergeArrayValue)(['left'], labelAlign),
|
108
|
+
wrapperAlign: (0, _utils2.mergeArrayValue)(['left'], wrapperAlign),
|
109
|
+
labelCol: (0, _utils2.mergeArrayValue)([24], labelCol),
|
110
|
+
wrapperCol: (0, _utils2.mergeArrayValue)([24], wrapperCol)
|
111
|
+
} : {
|
112
|
+
breakpoints: (0, _utils.isBool)(breakpoints) ? undefined : breakpoints,
|
113
|
+
layout: layout,
|
114
|
+
labelAlign: labelAlign,
|
115
|
+
wrapperAlign: wrapperAlign,
|
116
|
+
labelCol: labelCol,
|
117
|
+
wrapperCol: wrapperCol
|
118
|
+
};
|
119
|
+
}, [breakpoints, layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
|
120
|
+
return autoTeamixLayout;
|
121
|
+
};
|
122
|
+
|
123
|
+
var _default = useAutoLayout;
|
124
|
+
exports.default = _default;
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
var _excluded = ["title", "decoratorProps"]
|
7
|
+
var _excluded = ["title", "decoratorProps"],
|
8
|
+
_excluded2 = ["title", "dataIndex", "cell", "htmlTitle", "sortable", "width", "align", "alignHeader", "filters", "filterMode", "filterMenuProps", "lock", "resizable", "colSpan"];
|
8
9
|
|
9
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
10
11
|
|
@@ -18,15 +19,49 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
18
19
|
|
19
20
|
var initializeColumn = function initializeColumn(item) {
|
20
21
|
var title = item.title,
|
21
|
-
decoratorProps = item.decoratorProps,
|
22
|
-
|
22
|
+
_item$decoratorProps = item.decoratorProps,
|
23
|
+
decoratorProps = _item$decoratorProps === void 0 ? {} : _item$decoratorProps,
|
24
|
+
children = _objectWithoutProperties(item, _excluded); // 将Table.Column属性和组件FormItem属性通过decoratorProps统一传入,再分别赋值
|
23
25
|
|
26
|
+
|
27
|
+
var columnTitle = decoratorProps.title,
|
28
|
+
dataIndex = decoratorProps.dataIndex,
|
29
|
+
cell = decoratorProps.cell,
|
30
|
+
htmlTitle = decoratorProps.htmlTitle,
|
31
|
+
sortable = decoratorProps.sortable,
|
32
|
+
width = decoratorProps.width,
|
33
|
+
align = decoratorProps.align,
|
34
|
+
alignHeader = decoratorProps.alignHeader,
|
35
|
+
filters = decoratorProps.filters,
|
36
|
+
filterMode = decoratorProps.filterMode,
|
37
|
+
filterMenuProps = decoratorProps.filterMenuProps,
|
38
|
+
lock = decoratorProps.lock,
|
39
|
+
resizable = decoratorProps.resizable,
|
40
|
+
colSpan = decoratorProps.colSpan,
|
41
|
+
formItemDecoratorProps = _objectWithoutProperties(decoratorProps, _excluded2);
|
42
|
+
|
43
|
+
var columnProperties = {
|
44
|
+
title: title !== null && title !== void 0 ? title : columnTitle,
|
45
|
+
dataIndex: dataIndex,
|
46
|
+
cell: cell,
|
47
|
+
htmlTitle: htmlTitle,
|
48
|
+
sortable: sortable,
|
49
|
+
width: width,
|
50
|
+
align: align,
|
51
|
+
alignHeader: alignHeader,
|
52
|
+
filters: filters,
|
53
|
+
filterMode: filterMode,
|
54
|
+
filterMenuProps: filterMenuProps,
|
55
|
+
lock: lock,
|
56
|
+
resizable: resizable,
|
57
|
+
colSpan: colSpan
|
58
|
+
};
|
24
59
|
return {
|
25
60
|
component: 'ArrayTable.Column',
|
26
|
-
props:
|
27
|
-
|
28
|
-
|
29
|
-
|
61
|
+
props: columnProperties,
|
62
|
+
children: [_objectSpread(_objectSpread({}, children), {}, {
|
63
|
+
decoratorProps: formItemDecoratorProps
|
64
|
+
})]
|
30
65
|
};
|
31
66
|
};
|
32
67
|
|
package/lib/form/typing.d.ts
CHANGED
@@ -59,6 +59,9 @@ export interface ProFormSchemaItem {
|
|
59
59
|
data?: AnyObject;
|
60
60
|
}
|
61
61
|
export declare type ProFormSchema = ProFormSchemaItem[];
|
62
|
+
interface AutoLayout {
|
63
|
+
autoLabel?: boolean;
|
64
|
+
}
|
62
65
|
export interface ProFormProps extends Omit<IFormLayoutProps, 'breakpoints'> {
|
63
66
|
form?: FormType | false;
|
64
67
|
schema?: ProFormSchema;
|
@@ -78,6 +81,7 @@ export interface ProFormProps extends Omit<IFormLayoutProps, 'breakpoints'> {
|
|
78
81
|
onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
|
79
82
|
onInitialComplete?: (form: FormType) => void;
|
80
83
|
breakpoints?: number[] | boolean;
|
84
|
+
autoLayout?: AutoLayout | boolean;
|
81
85
|
}
|
82
86
|
export interface FilterProps extends ProFormProps {
|
83
87
|
form: FormType;
|
package/lib/index.d.ts
CHANGED
@@ -28,5 +28,5 @@ export * from './table';
|
|
28
28
|
export * from './sidebar';
|
29
29
|
export * from './utils';
|
30
30
|
export * from './timeline';
|
31
|
-
declare const version = "1.4.
|
31
|
+
declare const version = "1.4.17";
|
32
32
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, hooks, nocode, templates, utils, };
|
package/lib/index.js
CHANGED
@@ -74,7 +74,13 @@ var ProBaseInfo = function ProBaseInfo(props) {
|
|
74
74
|
|
75
75
|
var renderContent = function renderContent() {
|
76
76
|
return columns.map(function (item, index) {
|
77
|
-
var _layout$span, _layout$span2, _item$title, _item$valueType,
|
77
|
+
var _ref, _ref2, _layout$span, _layout$span2, _item$title, _item$valueType, _ref3, _item$colSpan;
|
78
|
+
|
79
|
+
var hidden = (0, _utils2.isHidden)(item === null || item === void 0 ? void 0 : item.hidden, (0, _utils2.getDataIndexValue)(item.dataIndex, (_ref = dataSource !== null && dataSource !== void 0 ? dataSource : result) !== null && _ref !== void 0 ? _ref : {}), (_ref2 = dataSource !== null && dataSource !== void 0 ? dataSource : result) !== null && _ref2 !== void 0 ? _ref2 : {}, context);
|
80
|
+
|
81
|
+
if (hidden) {
|
82
|
+
return;
|
83
|
+
}
|
78
84
|
|
79
85
|
var span = item.colSpan ? defaultLayout.span * item.colSpan : defaultLayout.span;
|
80
86
|
var layoutSpan = item.colSpan ? ((_layout$span = layout === null || layout === void 0 ? void 0 : layout.span) !== null && _layout$span !== void 0 ? _layout$span : span) * item.colSpan : (_layout$span2 = layout === null || layout === void 0 ? void 0 : layout.span) !== null && _layout$span2 !== void 0 ? _layout$span2 : span;
|
@@ -86,7 +92,7 @@ var ProBaseInfo = function ProBaseInfo(props) {
|
|
86
92
|
loading: loading,
|
87
93
|
value: /*#__PURE__*/_react.default.createElement(_InfoValueItem.default, {
|
88
94
|
type: (_item$valueType = item === null || item === void 0 ? void 0 : item.valueType) !== null && _item$valueType !== void 0 ? _item$valueType : 'text',
|
89
|
-
value: (0, _utils2.getDataIndexValue)(item.dataIndex, (
|
95
|
+
value: (0, _utils2.getDataIndexValue)(item.dataIndex, (_ref3 = dataSource !== null && dataSource !== void 0 ? dataSource : result) !== null && _ref3 !== void 0 ? _ref3 : {}),
|
90
96
|
render: item.render,
|
91
97
|
dataSource: item.dataSource,
|
92
98
|
infoItem: item,
|