@teamix/pro 1.5.16 → 1.5.18-beta
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/fonts/txddinmedium.woff +0 -0
- package/dist/pro.all.min.css +1 -0
- package/dist/pro.css +1 -0
- package/dist/pro.js +114772 -0
- package/dist/pro.min.css +1 -0
- package/dist/pro.min.js +2 -0
- package/dist/pro.min.js.LICENSE.txt +47 -0
- package/dist/pro.xconsole.min.css +1 -0
- package/es/actions/dialog-component.js +1 -4
- package/es/actions/dialog-form.js +4 -3
- package/es/actions/dialog.js +2 -1
- package/es/actions/index.js +35 -22
- package/es/actions/quick.js +1 -4
- package/es/card/card-container.js +12 -5
- package/es/card/divider.js +2 -4
- package/es/card/index.js +18 -7
- package/es/card/selectable.js +2 -4
- package/es/card/tab.js +2 -4
- package/es/form/Components/Editable/index.js +1 -1
- package/es/form/Components/FormGroup/index.js +4 -3
- package/es/form/Components/LightFilter/index.js +11 -2
- package/es/form/Components/ProField/index.js +2 -4
- package/es/form/Components/Text/index.js +2 -4
- package/es/form/Filter/AdvancedFilter.js +16 -14
- package/es/form/Filter/LightFilter.js +13 -9
- package/es/form/Filter/SimpleFilter.js +8 -5
- package/es/form/Filter/index.js +24 -7
- package/es/form/Filter/index.scss +1 -0
- package/es/form/Filter/index2.js +22 -17
- package/es/form/Filter/index2.scss +1 -0
- package/es/form/Filter/useBindUrl.js +3 -0
- package/es/form/Filter/useSpecialProps.js +1 -0
- package/es/form/ProForm/index.js +5 -2
- package/es/form/ProForm/useAutoLayout.js +4 -0
- package/es/form/ProForm/useFormDisplayValues.js +1 -0
- package/es/form/SchemaForm/adapterComponent.js +1 -0
- package/es/form/SchemaForm/adapterDecorator.js +1 -0
- package/es/form/SchemaForm/adapterType.js +1 -0
- package/es/form/SchemaForm/index.js +13 -0
- package/es/form/SchemaForm/initializeFormButton.js +2 -0
- package/es/form/SchemaForm/initializeReactions.js +1 -0
- package/es/form/SchemaForm/initializeSelectTable.js +1 -0
- package/es/form/SchemaForm/reactions.js +5 -0
- package/es/form/index.js +4 -0
- package/es/form/utils.js +12 -0
- package/es/form/warning.js +2 -0
- package/es/index.js +3 -1
- package/es/info/components/InfoGroup/index.js +2 -4
- package/es/info/components/InfoValueItem/index.js +32 -20
- package/es/info/components/ProInfoItem/index.js +1 -0
- package/es/info/components/baseInfo/index.js +3 -0
- package/es/info/components/tableInfo/index.js +6 -4
- package/es/info/index.js +11 -5
- package/es/info/utils/index.js +3 -0
- package/es/layout/index.js +2 -0
- package/es/nocode/index.js +2 -0
- package/es/nocode/pages/index.js +3 -0
- package/es/nocode/pages/playground.js +3 -5
- package/es/nocode/pages/renderer.js +4 -6
- package/es/nocode/playground.js +2 -4
- package/es/page-header/index.js +12 -7
- package/es/sidebar/components/sidebar-container/index.js +10 -7
- package/es/sidebar/components/tree/index.js +22 -4
- package/es/sidebar/components/tree-node/components/HoverTooltip/index.js +3 -4
- package/es/sidebar/components/tree-node/components/IconAction/index.js +4 -2
- package/es/sidebar/components/tree-node/components/IconSwitch/index.js +1 -0
- package/es/sidebar/components/tree-node/index.js +29 -16
- package/es/sidebar/index.js +15 -4
- package/es/sidebar/utils/index.js +19 -11
- package/es/table/components/CardView/index.js +29 -13
- package/es/table/components/Filter/index.js +11 -0
- package/es/table/components/Layout/index.js +13 -8
- package/es/table/components/LoadMore/index.js +3 -0
- package/es/table/components/Pagination/index.js +12 -10
- package/es/table/components/QuickAction/index.js +3 -2
- package/es/table/components/ToolBar/CardSwitch.js +2 -0
- package/es/table/components/ToolBar/DensityIcon.js +7 -2
- package/es/table/components/ToolBar/FilterColumnIcon.js +9 -0
- package/es/table/components/ToolBar/FullScreenIcon.js +1 -0
- package/es/table/components/ToolBar/Fullscreen.js +3 -0
- package/es/table/components/ToolBar/RefreshIcon.js +11 -0
- package/es/table/components/ToolBar/index.js +13 -10
- package/es/table/index.js +138 -51
- package/es/table/index.scss +26 -0
- package/es/table/utils/columnRender.js +78 -27
- package/es/table/utils/genAutoWidthColumns.js +340 -0
- package/es/table/utils/index.js +6 -0
- package/es/table/utils/pureColumnRender.js +9 -1
- package/es/templates/List/index.js +4 -6
- package/es/templates/index.js +2 -1
- package/es/timeline/ProTimeLineItem/index.js +8 -4
- package/es/timeline/index.js +5 -5
- package/es/utils/message.js +3 -5
- package/es/xconsole.scss +23 -0
- package/lib/form/Filter/index.scss +1 -0
- package/lib/form/Filter/index2.scss +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/table/components/CardView/index.js +5 -10
- package/lib/table/components/ToolBar/index.js +10 -7
- package/lib/table/index.js +72 -25
- package/lib/table/index.scss +26 -0
- package/lib/table/typing.d.ts +11 -1
- package/lib/table/utils/columnRender.d.ts +1 -0
- package/lib/table/utils/columnRender.js +51 -4
- package/lib/table/utils/genAutoWidthColumns.d.ts +35 -0
- package/lib/table/utils/genAutoWidthColumns.js +345 -0
- package/lib/xconsole.scss +23 -0
- package/package.json +1 -1
- package/es/actions/base.d.ts +0 -24
- package/es/actions/confirm.d.ts +0 -7
- package/es/actions/danger-confirm.d.ts +0 -7
- package/es/actions/danger-pop-confirm.d.ts +0 -5
- package/es/actions/dialog-component.d.ts +0 -10
- package/es/actions/dialog-form.d.ts +0 -29
- package/es/actions/dialog-info.d.ts +0 -9
- package/es/actions/dialog-table.d.ts +0 -9
- package/es/actions/dialog.d.ts +0 -40
- package/es/actions/drawer-form.d.ts +0 -6
- package/es/actions/drawer-info.d.ts +0 -6
- package/es/actions/drawer-table.d.ts +0 -6
- package/es/actions/drawer.d.ts +0 -6
- package/es/actions/error.d.ts +0 -7
- package/es/actions/index.d.ts +0 -114
- package/es/actions/link.d.ts +0 -8
- package/es/actions/notice.d.ts +0 -7
- package/es/actions/pop-confirm.d.ts +0 -9
- package/es/actions/quick.d.ts +0 -2
- package/es/actions/request.d.ts +0 -9
- package/es/actions/utils.d.ts +0 -1
- package/es/card/card-container.d.ts +0 -18
- package/es/card/divider.d.ts +0 -6
- package/es/card/index.d.ts +0 -109
- package/es/card/selectable.d.ts +0 -13
- package/es/card/tab.d.ts +0 -6
- package/es/card/utils.d.ts +0 -9
- package/es/field/index.d.ts +0 -3
- package/es/form/Components/Editable/index.d.ts +0 -20
- package/es/form/Components/FormGroup/index.d.ts +0 -14
- package/es/form/Components/LightFilter/componentMap.d.ts +0 -3
- package/es/form/Components/LightFilter/index.d.ts +0 -17
- package/es/form/Components/ProField/index.d.ts +0 -2
- package/es/form/Components/ProField/mapDateFormat.d.ts +0 -3
- package/es/form/Components/Text/index.d.ts +0 -8
- package/es/form/Filter/AdvancedFilter.d.ts +0 -7
- package/es/form/Filter/Layout.d.ts +0 -5
- package/es/form/Filter/LightFilter.d.ts +0 -7
- package/es/form/Filter/SimpleFilter.d.ts +0 -7
- package/es/form/Filter/index.d.ts +0 -9
- package/es/form/Filter/index2.d.ts +0 -13
- package/es/form/Filter/useBindUrl.d.ts +0 -2
- package/es/form/Filter/useSpecialProps.d.ts +0 -6
- package/es/form/ProForm/addCascadeEffect.d.ts +0 -2
- package/es/form/ProForm/customComponent.d.ts +0 -3
- package/es/form/ProForm/index.d.ts +0 -5
- package/es/form/ProForm/useAutoLayout.d.ts +0 -9
- package/es/form/ProForm/useAutoSubmit.d.ts +0 -6
- package/es/form/ProForm/useFieldRequest.d.ts +0 -5
- package/es/form/ProForm/useFormDisplayValues.d.ts +0 -4
- package/es/form/ProForm/useInitialRequest.d.ts +0 -6
- package/es/form/SchemaForm/adapterComponent.d.ts +0 -5
- package/es/form/SchemaForm/adapterDecorator.d.ts +0 -6
- package/es/form/SchemaForm/adapterType.d.ts +0 -5
- package/es/form/SchemaForm/index.d.ts +0 -4
- package/es/form/SchemaForm/initializeArrayCards.d.ts +0 -3
- package/es/form/SchemaForm/initializeArrayCollapse.d.ts +0 -3
- package/es/form/SchemaForm/initializeArrayItems.d.ts +0 -3
- package/es/form/SchemaForm/initializeArrayTable.d.ts +0 -3
- package/es/form/SchemaForm/initializeDataSource.d.ts +0 -15
- package/es/form/SchemaForm/initializeFormButton.d.ts +0 -3
- package/es/form/SchemaForm/initializeFormCollapse.d.ts +0 -3
- package/es/form/SchemaForm/initializeFormGroup.d.ts +0 -3
- package/es/form/SchemaForm/initializeFormStep.d.ts +0 -5
- package/es/form/SchemaForm/initializeFormTab.d.ts +0 -3
- package/es/form/SchemaForm/initializeReactions.d.ts +0 -2
- package/es/form/SchemaForm/initializeRequest.d.ts +0 -11
- package/es/form/SchemaForm/initializeRules.d.ts +0 -11
- package/es/form/SchemaForm/initializeSelectTable.d.ts +0 -3
- package/es/form/SchemaForm/reactions.d.ts +0 -6
- package/es/form/docs/ActionResponse.d.ts +0 -8
- package/es/form/fieldTypeMap.d.ts +0 -7
- package/es/form/index.d.ts +0 -125
- package/es/form/locales/validate.d.ts +0 -159
- package/es/form/schemaNameMap.d.ts +0 -5
- package/es/form/typing.d.ts +0 -194
- package/es/form/utils.d.ts +0 -55
- package/es/form/warning.d.ts +0 -3
- package/es/hooks/index.d.ts +0 -2
- package/es/index-without-icon.d.ts +0 -32
- package/es/index.d.ts +0 -32
- package/es/info/components/InfoGroup/index.d.ts +0 -5
- package/es/info/components/InfoValueItem/index.d.ts +0 -5
- package/es/info/components/ProInfoItem/index.d.ts +0 -5
- package/es/info/components/baseInfo/index.d.ts +0 -8
- package/es/info/components/headerInfo/index.d.ts +0 -8
- package/es/info/components/tableInfo/index.d.ts +0 -7
- package/es/info/index.d.ts +0 -10
- package/es/info/typing.d.ts +0 -220
- package/es/info/utils/index.d.ts +0 -20
- package/es/info/utils/layout.d.ts +0 -2
- package/es/info/utils/utils.d.ts +0 -1
- package/es/layout/index.d.ts +0 -2
- package/es/nocode/configurators/Card.d.ts +0 -3
- package/es/nocode/configurators/PageHeader.d.ts +0 -3
- package/es/nocode/configurators/ProTable.d.ts +0 -3
- package/es/nocode/configurators/common.d.ts +0 -280
- package/es/nocode/configurators/index.d.ts +0 -15
- package/es/nocode/configurators/map.d.ts +0 -2
- package/es/nocode/index.d.ts +0 -8
- package/es/nocode/pages/editor.d.ts +0 -12
- package/es/nocode/pages/index.d.ts +0 -14
- package/es/nocode/pages/playground.d.ts +0 -11
- package/es/nocode/pages/renderer.d.ts +0 -10
- package/es/nocode/playground.d.ts +0 -14
- package/es/page-container/index.d.ts +0 -3
- package/es/page-header/index.d.ts +0 -74
- package/es/sidebar/components/sidebar-container/index.d.ts +0 -5
- package/es/sidebar/components/tree/index.d.ts +0 -6
- package/es/sidebar/components/tree-node/components/HoverTooltip/index.d.ts +0 -15
- package/es/sidebar/components/tree-node/components/IconAction/index.d.ts +0 -12
- package/es/sidebar/components/tree-node/components/IconSwitch/index.d.ts +0 -23
- package/es/sidebar/components/tree-node/index.d.ts +0 -7
- package/es/sidebar/index.d.ts +0 -9
- package/es/sidebar/typing.d.ts +0 -141
- package/es/sidebar/utils/action-ref.d.ts +0 -3
- package/es/sidebar/utils/index.d.ts +0 -364
- package/es/skeleton/index.d.ts +0 -3
- package/es/table/components/CardView/index.d.ts +0 -5
- package/es/table/components/EmptyContent/index.d.ts +0 -2
- package/es/table/components/Filter/index.d.ts +0 -12
- package/es/table/components/Layout/index.d.ts +0 -5
- package/es/table/components/LoadMore/index.d.ts +0 -20
- package/es/table/components/Pagination/index.d.ts +0 -7
- package/es/table/components/QuickAction/index.d.ts +0 -11
- package/es/table/components/ToolBar/CardSwitch.d.ts +0 -8
- package/es/table/components/ToolBar/DensityIcon.d.ts +0 -4
- package/es/table/components/ToolBar/FilterColumnIcon.d.ts +0 -4
- package/es/table/components/ToolBar/FullScreenIcon.d.ts +0 -4
- package/es/table/components/ToolBar/Fullscreen.d.ts +0 -10
- package/es/table/components/ToolBar/RefreshIcon.d.ts +0 -4
- package/es/table/components/ToolBar/index.d.ts +0 -5
- package/es/table/index.d.ts +0 -5
- package/es/table/typing.d.ts +0 -418
- package/es/table/utils/columnRender.d.ts +0 -13
- package/es/table/utils/genProColumnToColumn.d.ts +0 -13
- package/es/table/utils/getTableProps.d.ts +0 -2
- package/es/table/utils/getTableSortIcons.d.ts +0 -3
- package/es/table/utils/index.d.ts +0 -19
- package/es/table/utils/pureColumnRender.d.ts +0 -9
- package/es/table/utils/pureGenProColumnToColumn.d.ts +0 -7
- package/es/table/utils/useTableSelection.d.ts +0 -3
- package/es/table/utils/util.d.ts +0 -5
- package/es/templates/Detail/index.d.ts +0 -2
- package/es/templates/Form/index.d.ts +0 -2
- package/es/templates/List/index.d.ts +0 -9
- package/es/templates/index.d.ts +0 -3
- package/es/timeline/ProTimeLineItem/index.d.ts +0 -5
- package/es/timeline/index.d.ts +0 -10
- package/es/timeline/typing.d.ts +0 -107
- package/es/utils/index.d.ts +0 -3
- package/es/utils/message.d.ts +0 -3
@@ -8,6 +8,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
8
8
|
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; }
|
9
9
|
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; }
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
11
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
11
12
|
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; }
|
12
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
14
|
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; }
|
@@ -34,17 +35,18 @@ export var renderColumnsTitle = function renderColumnsTitle(item, actionRef, bin
|
|
34
35
|
var _actionRef$current$ge, _actionRef$current, _actionRef$current$ge2;
|
35
36
|
var selectedItem = (_actionRef$current$ge = (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$ge2 = _actionRef$current.getState) === null || _actionRef$current$ge2 === void 0 ? void 0 : _actionRef$current$ge2.call(_actionRef$current).filterRules) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {};
|
36
37
|
if (Object.keys(selectedItem).length > 0) {
|
37
|
-
var _selectedItem
|
38
|
-
if ((_selectedItem
|
39
|
-
var _targetFilters$find;
|
38
|
+
var _selectedItem;
|
39
|
+
if ((_selectedItem = selectedItem[dataIndex]) === null || _selectedItem === void 0 ? void 0 : _selectedItem.params) {
|
40
|
+
var _ref, _targetFilters$find;
|
40
41
|
// 找到对应的 label
|
41
|
-
var targetFilters = filters !== null &&
|
42
|
+
var targetFilters = (_ref = filters) !== null && _ref !== void 0 ? _ref : [];
|
42
43
|
if (filters === true) {
|
43
|
-
|
44
|
+
var _ref2;
|
45
|
+
targetFilters = (_ref2 = dataSource) !== null && _ref2 !== void 0 ? _ref2 : [];
|
44
46
|
}
|
45
47
|
var label = (_targetFilters$find = targetFilters.find(function (item) {
|
46
|
-
var
|
47
|
-
return item.value === ((
|
48
|
+
var _selectedItem2;
|
49
|
+
return item.value === ((_selectedItem2 = selectedItem[dataIndex]) === null || _selectedItem2 === void 0 ? void 0 : _selectedItem2.params);
|
48
50
|
})) === null || _targetFilters$find === void 0 ? void 0 : _targetFilters$find.label;
|
49
51
|
var value = "".concat(item.title, " (").concat(label, ")");
|
50
52
|
return /*#__PURE__*/React.createElement(ProField, {
|
@@ -84,13 +86,11 @@ export var renderColumnsTitle = function renderColumnsTitle(item, actionRef, bin
|
|
84
86
|
bindUrlProps: bindUrlProps
|
85
87
|
}));
|
86
88
|
};
|
89
|
+
|
87
90
|
/**
|
88
91
|
* 负责单元格的具体渲染
|
89
92
|
*/
|
90
|
-
export var renderCell = function renderCell(value, item, index, record, actionRef,
|
91
|
-
context,
|
92
|
-
// 用于埋点
|
93
|
-
dataTeamixSpm) {
|
93
|
+
export var renderCell = function renderCell(value, item, index, record, actionRef, context, dataTeamixSpm) {
|
94
94
|
var _actionSchema$actions;
|
95
95
|
var _item$valueType = item.valueType,
|
96
96
|
valueType = _item$valueType === void 0 ? 'text' : _item$valueType,
|
@@ -98,10 +98,12 @@ dataTeamixSpm) {
|
|
98
98
|
actionSchema = item.actionSchema,
|
99
99
|
dataIndex = item.dataIndex,
|
100
100
|
format = item.format;
|
101
|
+
|
101
102
|
// 如果没传 dataIndex,返回 null
|
102
103
|
if (!dataIndex) {
|
103
104
|
value = null;
|
104
105
|
}
|
106
|
+
|
105
107
|
// 处理 dataIndex 为数组的情况
|
106
108
|
if (Array.isArray(dataIndex)) {
|
107
109
|
value = dataIndex.map(function (item) {
|
@@ -142,6 +144,7 @@ dataTeamixSpm) {
|
|
142
144
|
});
|
143
145
|
}
|
144
146
|
}
|
147
|
+
|
145
148
|
// 渲染操作组
|
146
149
|
if (actionSchema && ((_actionSchema$actions = actionSchema.actions) === null || _actionSchema$actions === void 0 ? void 0 : _actionSchema$actions.length)) {
|
147
150
|
// 默认 context
|
@@ -151,13 +154,14 @@ dataTeamixSpm) {
|
|
151
154
|
record: record,
|
152
155
|
action: actionRef.current
|
153
156
|
}, context);
|
154
|
-
return /*#__PURE__*/React.createElement(ProActionGroup,
|
157
|
+
return /*#__PURE__*/React.createElement(ProActionGroup, _extends({
|
155
158
|
type: "text"
|
156
|
-
}, actionSchema
|
159
|
+
}, actionSchema, {
|
157
160
|
context: _objectSpread(_objectSpread({}, defaultContext), actionSchema.context),
|
158
161
|
"data-teamix-spm": dataTeamixSpm ? "".concat(dataTeamixSpm, "-columnAction") : undefined
|
159
162
|
}));
|
160
163
|
}
|
164
|
+
|
161
165
|
// dataSource可传函数
|
162
166
|
if (typeof item.dataSource === 'function') {
|
163
167
|
var _item$dataSource;
|
@@ -165,10 +169,10 @@ dataTeamixSpm) {
|
|
165
169
|
} else {
|
166
170
|
var _item$dataSource2;
|
167
171
|
newDataSource = ((_item$dataSource2 = item.dataSource) !== null && _item$dataSource2 !== void 0 ? _item$dataSource2 : []).map(function (item) {
|
168
|
-
return Object.fromEntries(Object.entries(item).map(function (
|
169
|
-
var
|
170
|
-
k =
|
171
|
-
v =
|
172
|
+
return Object.fromEntries(Object.entries(item).map(function (_ref3) {
|
173
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
174
|
+
k = _ref4[0],
|
175
|
+
v = _ref4[1];
|
172
176
|
return [k, getTargetValue(v, _objectSpread(_objectSpread({}, record), {}, {
|
173
177
|
record: record,
|
174
178
|
value: value,
|
@@ -177,15 +181,61 @@ dataTeamixSpm) {
|
|
177
181
|
}));
|
178
182
|
});
|
179
183
|
}
|
184
|
+
|
180
185
|
// 渲染 ProField
|
181
|
-
return /*#__PURE__*/React.createElement(ProField
|
186
|
+
return /*#__PURE__*/React.createElement(ProField
|
187
|
+
// style={{width: `${width}px`}}
|
188
|
+
, _extends({
|
182
189
|
type: valueType || 'text',
|
183
190
|
value: value,
|
184
191
|
render: newRender,
|
185
192
|
dataSource: newDataSource,
|
186
|
-
format: format
|
193
|
+
format: format,
|
194
|
+
proFieldWidthType: valueType
|
187
195
|
}, props));
|
188
196
|
};
|
197
|
+
export var renderCellSmartWidth = function renderCellSmartWidth(value, item, index, record, actionRef, context) {
|
198
|
+
var _item$valueType2 = item.valueType,
|
199
|
+
valueType = _item$valueType2 === void 0 ? 'text' : _item$valueType2,
|
200
|
+
render = item.render,
|
201
|
+
actionSchema = item.actionSchema,
|
202
|
+
dataIndex = item.dataIndex,
|
203
|
+
format = item.format;
|
204
|
+
var newRender = null;
|
205
|
+
var newDataSource = null;
|
206
|
+
var props = item.props;
|
207
|
+
// 如果 render 直接传函数
|
208
|
+
if (typeof render === 'function') {
|
209
|
+
newRender = function newRender() {
|
210
|
+
return render === null || render === void 0 ? void 0 : render(value, index, record);
|
211
|
+
};
|
212
|
+
} else {
|
213
|
+
newRender = processBuriedPoint(processRenderFunction(render, value, index, record), record, value, index);
|
214
|
+
if (valueType === 'selectGroup') {
|
215
|
+
newRender = _objectSpread(_objectSpread({
|
216
|
+
maxShowNumber: 'auto',
|
217
|
+
foldText: 'more',
|
218
|
+
editOnClick: function editOnClick() {},
|
219
|
+
edit: true
|
220
|
+
}, newRender), {}, {
|
221
|
+
ellipsis: false
|
222
|
+
});
|
223
|
+
props = _objectSpread({
|
224
|
+
valueAlias: {
|
225
|
+
value: 'TagValue',
|
226
|
+
key: 'TagKey'
|
227
|
+
}
|
228
|
+
}, props);
|
229
|
+
}
|
230
|
+
if ((render === null || render === void 0 ? void 0 : render.type) === 'step') {
|
231
|
+
newRender = _objectSpread(_objectSpread({}, newRender), {}, {
|
232
|
+
ellipsis: false
|
233
|
+
});
|
234
|
+
}
|
235
|
+
}
|
236
|
+
// return getProFieldWidthBox(valueType, newRender)?.minWidth || undefined
|
237
|
+
};
|
238
|
+
|
189
239
|
/**
|
190
240
|
* 处理 render 配置项是函数的情况
|
191
241
|
* @param render ProFieldRender
|
@@ -201,10 +251,10 @@ var processRenderFunction = function processRenderFunction() {
|
|
201
251
|
var record = arguments.length > 3 ? arguments[3] : undefined;
|
202
252
|
// 当 ProField render 类型为 function 时。需要表格预先处理以塞入 record
|
203
253
|
var external = ['linkOnClick', 'link', 'value', 'renderEdit', 'descriptionRenderEdit', 'editPopConfirmProps', 'descriptionEditPopConfirmProps', 'editOnClick', 'descriptionEditOnClick', 'extra', 'prefixExtra'];
|
204
|
-
return Object.fromEntries(Object.entries(render).map(function (
|
205
|
-
var
|
206
|
-
k =
|
207
|
-
v =
|
254
|
+
return Object.fromEntries(Object.entries(render).map(function (_ref5) {
|
255
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
256
|
+
k = _ref6[0],
|
257
|
+
v = _ref6[1];
|
208
258
|
if (typeof v === 'function') {
|
209
259
|
var _v;
|
210
260
|
if (external.includes(k)) {
|
@@ -220,6 +270,7 @@ var processRenderFunction = function processRenderFunction() {
|
|
220
270
|
return [k, v];
|
221
271
|
}));
|
222
272
|
};
|
273
|
+
|
223
274
|
/**
|
224
275
|
* 处理 render 数据,取出 {{xxx}} 匹配值
|
225
276
|
* @param render ProFieldRender
|
@@ -234,10 +285,10 @@ var processBuriedPoint = function processBuriedPoint() {
|
|
234
285
|
return Object.fromEntries([
|
235
286
|
// 默认 ellipsis、descriptionEllipsis 为 true
|
236
287
|
// emptyText 默认为 '-'
|
237
|
-
['ellipsis', true], ['descriptionEllipsis', true], ['emptyText', '-']].concat(_toConsumableArray(Object.entries(render).map(function (
|
238
|
-
var
|
239
|
-
k =
|
240
|
-
v =
|
288
|
+
['ellipsis', true], ['descriptionEllipsis', true], ['emptyText', '-']].concat(_toConsumableArray(Object.entries(render).map(function (_ref7) {
|
289
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
290
|
+
k = _ref8[0],
|
291
|
+
v = _ref8[1];
|
241
292
|
return [k, getTargetValue(v, _objectSpread(_objectSpread({}, record), {}, {
|
242
293
|
record: record,
|
243
294
|
value: value,
|
@@ -0,0 +1,340 @@
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
|
+
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); }
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
6
|
+
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; }
|
7
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
8
|
+
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; }
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
10
|
+
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; }
|
11
|
+
import React, { useRef } from 'react';
|
12
|
+
import { getTargetValue } from '@teamix/utils';
|
13
|
+
import { renderCell } from './pureColumnRender';
|
14
|
+
import { renderColumnsTitle } from './columnRender';
|
15
|
+
import { ProActionGroup } from '../../actions';
|
16
|
+
|
17
|
+
// 最大宽度
|
18
|
+
var maxColumnWidth = 600;
|
19
|
+
// 最小宽度
|
20
|
+
var minColumnWidth = 48;
|
21
|
+
// 每个列可以缩减的最大宽度
|
22
|
+
var columnShrinkMaxWidth = 100;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @param fileteredColumns
|
26
|
+
* @param ref
|
27
|
+
* @param data
|
28
|
+
* @returns
|
29
|
+
*/
|
30
|
+
export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSelection, actionColumnRef) {
|
31
|
+
if (!ref.current) {
|
32
|
+
return fileteredColumns;
|
33
|
+
}
|
34
|
+
var hasLockFlag = false;
|
35
|
+
var dom = ref.current;
|
36
|
+
var actionColumnDom = actionColumnRef === null || actionColumnRef === void 0 ? void 0 : actionColumnRef.current;
|
37
|
+
var childNodes = dom.children;
|
38
|
+
var finalColumns = [];
|
39
|
+
fileteredColumns.forEach(function (column, index) {
|
40
|
+
var render = column.render,
|
41
|
+
_column$valueType = column.valueType,
|
42
|
+
valueType = _column$valueType === void 0 ? 'text' : _column$valueType,
|
43
|
+
_column$autoWidth = column.autoWidth,
|
44
|
+
autoWidth = _column$autoWidth === void 0 ? true : _column$autoWidth,
|
45
|
+
actionSchema = column.actionSchema,
|
46
|
+
sortable = column.sortable,
|
47
|
+
lock = column.lock;
|
48
|
+
if (lock) {
|
49
|
+
hasLockFlag = true;
|
50
|
+
}
|
51
|
+
//@ts-ignore
|
52
|
+
var type = render === null || render === void 0 ? void 0 : render.type;
|
53
|
+
var finalType = type || valueType || '';
|
54
|
+
var shrink = fieldTypeShrink[finalType];
|
55
|
+
column.shrink = column.shrink || (shrink !== undefined ? shrink : 1);
|
56
|
+
//@ts-ignore
|
57
|
+
// if (!autoWidth) {
|
58
|
+
// finalColumns.push(column);
|
59
|
+
// return;
|
60
|
+
// }
|
61
|
+
if (actionSchema) {
|
62
|
+
// TODO 操作列暂时未处理,但是应该根据actionSchema的数量直接推测出操作列的宽度
|
63
|
+
// console.log('column', column);
|
64
|
+
column.shrink = 0;
|
65
|
+
// column.width = 280;
|
66
|
+
// console.log(
|
67
|
+
// 'actionColumnDom',
|
68
|
+
// actionColumnDom?.childNodes[0].scrollWidth,
|
69
|
+
// );
|
70
|
+
if (actionColumnDom === null || actionColumnDom === void 0 ? void 0 : actionColumnDom.childNodes[0]) {
|
71
|
+
//@ts-ignore
|
72
|
+
var width = actionColumnDom === null || actionColumnDom === void 0 ? void 0 : actionColumnDom.childNodes[0].scrollWidth;
|
73
|
+
if (width >= 280) {
|
74
|
+
width = 280;
|
75
|
+
}
|
76
|
+
console.log('actionWidth', width);
|
77
|
+
column.width = defaultPaddingFixer(width, size, false);
|
78
|
+
}
|
79
|
+
finalColumns.push(column);
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
// @ts-ignore
|
83
|
+
var titleWidth = childNodes[index].children[0].scrollWidth;
|
84
|
+
// @ts-ignore
|
85
|
+
if (fixedWidthTypeList[finalType]) {
|
86
|
+
// console.log(
|
87
|
+
// 'fixedWidthTypeList[finalType]',
|
88
|
+
// fixedWidthTypeList[finalType],
|
89
|
+
// );
|
90
|
+
// 固定宽度
|
91
|
+
column.width = defaultPaddingFixer(
|
92
|
+
// @ts-ignore
|
93
|
+
Math.max(titleWidth, fixedWidthTypeList[finalType]), size, index === 0 && useRowSelection);
|
94
|
+
// @ts-ignore
|
95
|
+
} else if (computeableWidthTypeList[finalType]) {
|
96
|
+
// 可计算宽度
|
97
|
+
column.width = defaultPaddingFixer(
|
98
|
+
// @ts-ignore
|
99
|
+
Math.max(titleWidth, computeableWidthTypeList[finalType](data, render)), size, index === 0 && useRowSelection);
|
100
|
+
} else {
|
101
|
+
// 直接根据 dom 计算
|
102
|
+
column.width = defaultPaddingFixer(Math.max(titleWidth,
|
103
|
+
// @ts-ignore
|
104
|
+
calcWidthWithParentDOM(childNodes[index], column.shrink)), size, index === 0 && useRowSelection);
|
105
|
+
}
|
106
|
+
if (index === 0) {
|
107
|
+
// 首列不会被挤占
|
108
|
+
column.shrink = 0;
|
109
|
+
}
|
110
|
+
finalColumns.push(column);
|
111
|
+
});
|
112
|
+
if (!hasLockFlag) {
|
113
|
+
// 如果没有锁列的情况,需要将所有列放到一屏内,此时需要将所有列放到一起计算一次
|
114
|
+
var containerWidth = dom.offsetWidth;
|
115
|
+
var comboColumns = calcMultiColumnLength(finalColumns, useRowSelection ? containerWidth - 50 : containerWidth);
|
116
|
+
return comboColumns;
|
117
|
+
}
|
118
|
+
console.log('[ finalColumns ] >', finalColumns);
|
119
|
+
return finalColumns;
|
120
|
+
}
|
121
|
+
export var shadowContainer = function shadowContainer(props) {
|
122
|
+
var ref = useRef();
|
123
|
+
var columns = props.columns,
|
124
|
+
data = props.data,
|
125
|
+
shadowContainerRef = props.shadowContainerRef;
|
126
|
+
return /*#__PURE__*/React.createElement("div", {
|
127
|
+
ref: shadowContainerRef,
|
128
|
+
className: "teamix-pro-table-shadow-container"
|
129
|
+
}, columns.map(function (column, index) {
|
130
|
+
var dataIndex = column.dataIndex,
|
131
|
+
valueType = column.valueType;
|
132
|
+
if (!(column === null || column === void 0 ? void 0 : column.actionSchema)) {
|
133
|
+
return /*#__PURE__*/React.createElement("div", {
|
134
|
+
className: "teamix-pro-table-shadow-container-columns",
|
135
|
+
key: index
|
136
|
+
}, /*#__PURE__*/React.createElement("div", null, renderColumnsTitle(column, ref)),
|
137
|
+
//@ts-ignore
|
138
|
+
!computeableWidthTypeList[valueType] &&
|
139
|
+
//@ts-ignore
|
140
|
+
!fixedWidthTypeList[valueType] && data.map(function (item, index) {
|
141
|
+
return renderCell(getValueFromRecord(dataIndex, item), column, index, item);
|
142
|
+
}));
|
143
|
+
}
|
144
|
+
}));
|
145
|
+
};
|
146
|
+
export var shadowActionColumnContainer = function shadowActionColumnContainer(columns, shadowActionColumnContainerRef) {
|
147
|
+
var actionColumn = columns.find(function (column) {
|
148
|
+
return column === null || column === void 0 ? void 0 : column.actionSchema;
|
149
|
+
});
|
150
|
+
if (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionSchema) {
|
151
|
+
return /*#__PURE__*/React.createElement("div", {
|
152
|
+
ref: shadowActionColumnContainerRef,
|
153
|
+
className: "teamix-pro-table-action-column-shadow-container"
|
154
|
+
}, /*#__PURE__*/React.createElement(ProActionGroup, _extends({
|
155
|
+
type: "text"
|
156
|
+
}, actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionSchema, {
|
157
|
+
context: _objectSpread({}, actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionSchema.context)
|
158
|
+
})));
|
159
|
+
}
|
160
|
+
};
|
161
|
+
|
162
|
+
// 计算操作列的宽度
|
163
|
+
|
164
|
+
function getValueFromRecord(dataIndex, record) {
|
165
|
+
if (!dataIndex) {
|
166
|
+
return null;
|
167
|
+
}
|
168
|
+
if (Array.isArray(dataIndex)) {
|
169
|
+
var value = dataIndex.map(function (item) {
|
170
|
+
return getTargetValue("{{".concat(item, "}}"), _objectSpread(_objectSpread({}, record), {}, {
|
171
|
+
record: record
|
172
|
+
}));
|
173
|
+
});
|
174
|
+
return value;
|
175
|
+
} else {
|
176
|
+
var result = record;
|
177
|
+
var array = dataIndex.split('.');
|
178
|
+
array.forEach(function (item) {
|
179
|
+
return result = result ? result[item] : undefined;
|
180
|
+
});
|
181
|
+
return result;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
// TODO 某些可以直接算出结果的 profield 类型白名单,待补充,每个类型下支持一个函数,用当前值和渲染类型算出一个结果
|
186
|
+
export var computeableWidthTypeList = {
|
187
|
+
// text: (data: any[], render: ITableCellRender) => {
|
188
|
+
// }
|
189
|
+
};
|
190
|
+
|
191
|
+
// TODO 某些固定宽度的 profield 类型白名单,这里的数据可能需要综合考虑 dataFold 和 render.rows
|
192
|
+
export var fixedWidthTypeList = {
|
193
|
+
// 时间日期
|
194
|
+
dateTime: 160,
|
195
|
+
dateMonth: 74,
|
196
|
+
dateWeek: 74,
|
197
|
+
date: 100,
|
198
|
+
dateYear: 46,
|
199
|
+
dateQuarter: 64,
|
200
|
+
dateRange: 212,
|
201
|
+
dateWeekRange: 156,
|
202
|
+
dateMonthRange: 156,
|
203
|
+
dateYearRange: 102,
|
204
|
+
dateQuarterRange: 136,
|
205
|
+
dateTimeRange: 326,
|
206
|
+
time: 38,
|
207
|
+
timeRange: 124
|
208
|
+
};
|
209
|
+
|
210
|
+
// TODO 不同类型的 profield 的 shrink,0表示不可以省略号,数字越大越容易被挤占空间
|
211
|
+
export var fieldTypeShrink = {
|
212
|
+
tag: 0,
|
213
|
+
statusTag: 0,
|
214
|
+
statusIconTag: 0,
|
215
|
+
circle: 0,
|
216
|
+
rank: 0,
|
217
|
+
progress: 0,
|
218
|
+
money: 0,
|
219
|
+
number: 0,
|
220
|
+
percent: 0,
|
221
|
+
dateTime: 0,
|
222
|
+
ip: 0
|
223
|
+
};
|
224
|
+
function calcWidthWithParentDOM(dom, shrink) {
|
225
|
+
var childNodes = _toConsumableArray(dom.children);
|
226
|
+
childNodes.shift();
|
227
|
+
return calcSingleColumnLength(childNodes.map(function (node) {
|
228
|
+
return node.scrollWidth;
|
229
|
+
}), shrink);
|
230
|
+
}
|
231
|
+
function calcSingleColumnLength() {
|
232
|
+
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
233
|
+
var shrink = arguments.length > 1 ? arguments[1] : undefined;
|
234
|
+
if (shrink === 0) {
|
235
|
+
return Math.ceil(Math.max.apply(null, list));
|
236
|
+
}
|
237
|
+
return getConfidence90UpperBound(list);
|
238
|
+
}
|
239
|
+
|
240
|
+
/**
|
241
|
+
* 根据所有列的宽度和权重,结合总宽度,计算出各个列合适的宽度
|
242
|
+
* 目前算法:
|
243
|
+
* 当前需要的总宽度-总宽度=需要降低的宽度
|
244
|
+
* 从后往前,将shrink不为0的列,降低一些宽度到最小宽度
|
245
|
+
* 最小宽度可以用百分比去算
|
246
|
+
* TODO 当前shrink只用了0,其他的权重也要考虑一下
|
247
|
+
* @param list
|
248
|
+
* @param max
|
249
|
+
* @returns
|
250
|
+
*/
|
251
|
+
function calcMultiColumnLength() {
|
252
|
+
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
253
|
+
var max = arguments.length > 1 ? arguments[1] : undefined;
|
254
|
+
var result = _toConsumableArray(list);
|
255
|
+
var targetList = [];
|
256
|
+
var needWidth = 0;
|
257
|
+
var canShrink = 0;
|
258
|
+
list.forEach(function (item) {
|
259
|
+
//@ts-ignore
|
260
|
+
needWidth += item.width;
|
261
|
+
console.log('item.width', item.width);
|
262
|
+
if (item.shrink !== 0) {
|
263
|
+
targetList.push(item);
|
264
|
+
//@ts-ignore
|
265
|
+
canShrink += Math.min(item.width - minColumnWidth, columnShrinkMaxWidth);
|
266
|
+
}
|
267
|
+
});
|
268
|
+
console.log('needWidth', needWidth);
|
269
|
+
console.log('max', max);
|
270
|
+
var widthToBeRemoved = needWidth - max;
|
271
|
+
if (widthToBeRemoved <= 0) {
|
272
|
+
return list;
|
273
|
+
}
|
274
|
+
console.log('canShrink', canShrink);
|
275
|
+
console.log('widthToBeRemoved', widthToBeRemoved);
|
276
|
+
// TODO 超过的特别多直接加锁列,这个逻辑怎么设计
|
277
|
+
// 目前用可以缩小的宽度加起来比较一下
|
278
|
+
if (canShrink < widthToBeRemoved) {
|
279
|
+
console.log('canShrink', canShrink);
|
280
|
+
console.log('widthToBeRemoved', widthToBeRemoved);
|
281
|
+
list[0].lock = 'left';
|
282
|
+
if (list[list.length - 1].actionSchema) {
|
283
|
+
list[list.length - 1].lock = 'right';
|
284
|
+
}
|
285
|
+
return list;
|
286
|
+
}
|
287
|
+
//@ts-ignore
|
288
|
+
var sortedList = targetList.sort(function (a, b) {
|
289
|
+
return a.width - b.width;
|
290
|
+
});
|
291
|
+
var shrinkedWidth = 0;
|
292
|
+
for (var i = sortedList.length - 1; i >= 0; i--) {
|
293
|
+
if (shrinkedWidth >= widthToBeRemoved) {
|
294
|
+
break;
|
295
|
+
}
|
296
|
+
var singleShrinkedWidth = Math.min(sortedList[i].width - minColumnWidth, columnShrinkMaxWidth, widthToBeRemoved - shrinkedWidth);
|
297
|
+
sortedList[i].width = sortedList[i].width - singleShrinkedWidth;
|
298
|
+
shrinkedWidth += singleShrinkedWidth;
|
299
|
+
}
|
300
|
+
return result;
|
301
|
+
}
|
302
|
+
|
303
|
+
/**
|
304
|
+
* 修正内容放在table中默认的padding
|
305
|
+
* @param width
|
306
|
+
* @returns
|
307
|
+
*/
|
308
|
+
function defaultPaddingFixer(width) {
|
309
|
+
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'medium';
|
310
|
+
var half = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
311
|
+
return size === 'medium' ? width + (half ? 16 : 32) + 0.5 : width + (half ? 8 : 16) + 0.5;
|
312
|
+
}
|
313
|
+
function sum() {
|
314
|
+
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
315
|
+
return list.reduce(function (a, b) {
|
316
|
+
return a + b;
|
317
|
+
});
|
318
|
+
}
|
319
|
+
|
320
|
+
/**
|
321
|
+
* 假设样本正态分布,取 90% 置信区间的上界
|
322
|
+
* 当上界与最大值差距不大(目前是20)的时候,直接用最大值
|
323
|
+
* TODO 这里没考虑是否可以直接用标准差做评判依据,如标准差过大时,直接排序并展示前90%,或标准差很小时直接用最大值
|
324
|
+
* TODO 这里极限情况是不是会挂? 如:长度为9个100和2个10000,估计会挂,是否置信区间这个不靠谱。。。最差情况就直接展示90%的数据算了
|
325
|
+
*/
|
326
|
+
function getConfidence90UpperBound() {
|
327
|
+
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
328
|
+
var max = Math.max.apply(null, list);
|
329
|
+
var length = list.length;
|
330
|
+
var mean = sum(list) / length;
|
331
|
+
var std = Math.sqrt(sum(list.map(function (n) {
|
332
|
+
return (n - mean) * (n - mean);
|
333
|
+
})) / length);
|
334
|
+
var interval = length > 30 ? 1.65 * std / Math.sqrt(length) : 2.2622 * std / Math.sqrt(length);
|
335
|
+
var bound = Math.ceil(mean + interval);
|
336
|
+
if (max - bound < 20) {
|
337
|
+
return Math.min(max, maxColumnWidth);
|
338
|
+
}
|
339
|
+
return Math.min(bound, maxColumnWidth);
|
340
|
+
}
|
package/es/table/utils/index.js
CHANGED
@@ -10,6 +10,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
10
|
import cloneDeepLodash from 'lodash.clonedeep';
|
11
11
|
// 所有 ProTable 组件公用一套组件内事件转发机制
|
12
12
|
var tableCallback = {};
|
13
|
+
|
13
14
|
// 组件内对全局状态的更改
|
14
15
|
var getMutations = function getMutations(actionRef) {
|
15
16
|
var _actionRef$current2, _actionRef$current2$g, _actionRef$current2$g2;
|
@@ -50,6 +51,7 @@ var getMutations = function getMutations(actionRef) {
|
|
50
51
|
}
|
51
52
|
};
|
52
53
|
};
|
54
|
+
|
53
55
|
// 调用绑定的监听函数
|
54
56
|
export function actionRefUseStateOn(callback, state) {
|
55
57
|
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
@@ -66,16 +68,19 @@ export function actionRefUseStateOn(callback, state) {
|
|
66
68
|
});
|
67
69
|
}
|
68
70
|
}
|
71
|
+
|
69
72
|
/** table 组件内监听 不对外暴露 */
|
70
73
|
export function on(fun, key) {
|
71
74
|
tableCallback[key] = fun;
|
72
75
|
}
|
76
|
+
|
73
77
|
/** table 组件内销毁监听 不对外暴露 */
|
74
78
|
export function off(key) {
|
75
79
|
if (tableCallback[key]) {
|
76
80
|
delete tableCallback[key];
|
77
81
|
}
|
78
82
|
}
|
83
|
+
|
79
84
|
/** table 组件内触发事件 不对外暴露 */
|
80
85
|
export function emit(key) {
|
81
86
|
var fun = tableCallback[key];
|
@@ -96,6 +101,7 @@ export function useActionType(ref, action) {
|
|
96
101
|
export function cloneDeep(obj) {
|
97
102
|
return cloneDeepLodash(obj);
|
98
103
|
}
|
104
|
+
|
99
105
|
/**
|
100
106
|
* 处理默认过滤参数
|
101
107
|
* @param columns
|
@@ -2,6 +2,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
2
2
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
3
3
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
4
4
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
5
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
5
6
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
6
7
|
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."); }
|
7
8
|
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); }
|
@@ -27,6 +28,7 @@ export var renderColumnsTitle = function renderColumnsTitle(item) {
|
|
27
28
|
icon: item.tooltipIcon
|
28
29
|
}));
|
29
30
|
};
|
31
|
+
|
30
32
|
/**
|
31
33
|
* 负责单元格的具体渲染
|
32
34
|
*/
|
@@ -36,10 +38,12 @@ export var renderCell = function renderCell(value, item, index, record) {
|
|
36
38
|
render = item.render,
|
37
39
|
dataIndex = item.dataIndex,
|
38
40
|
format = item.format;
|
41
|
+
|
39
42
|
// 如果没传 dataIndex,返回 null
|
40
43
|
if (!dataIndex) {
|
41
44
|
value = null;
|
42
45
|
}
|
46
|
+
|
43
47
|
// 处理 dataIndex 为数组的情况
|
44
48
|
if (Array.isArray(dataIndex)) {
|
45
49
|
value = dataIndex.map(function (item) {
|
@@ -80,6 +84,7 @@ export var renderCell = function renderCell(value, item, index, record) {
|
|
80
84
|
});
|
81
85
|
}
|
82
86
|
}
|
87
|
+
|
83
88
|
// dataSource可传函数
|
84
89
|
if (typeof item.dataSource === 'function') {
|
85
90
|
var _item$dataSource;
|
@@ -99,8 +104,9 @@ export var renderCell = function renderCell(value, item, index, record) {
|
|
99
104
|
}));
|
100
105
|
});
|
101
106
|
}
|
107
|
+
|
102
108
|
// 渲染 ProField
|
103
|
-
return /*#__PURE__*/React.createElement(ProField,
|
109
|
+
return /*#__PURE__*/React.createElement(ProField, _extends({
|
104
110
|
type: valueType || 'text',
|
105
111
|
value: value,
|
106
112
|
render: newRender,
|
@@ -108,6 +114,7 @@ export var renderCell = function renderCell(value, item, index, record) {
|
|
108
114
|
format: format
|
109
115
|
}, props));
|
110
116
|
};
|
117
|
+
|
111
118
|
/**
|
112
119
|
* 处理 render 配置项是函数的情况
|
113
120
|
* @param render ProFieldRender
|
@@ -142,6 +149,7 @@ var processRenderFunction = function processRenderFunction() {
|
|
142
149
|
return [k, v];
|
143
150
|
}));
|
144
151
|
};
|
152
|
+
|
145
153
|
/**
|
146
154
|
* 处理 render 数据,取出 {{xxx}} 匹配值
|
147
155
|
* @param render ProFieldRender
|