@nokecy/qc-ui 1.1.90 → 1.1.91
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/cjs/ag-grid-plus/queryForm/queryForm.js +17 -29
- package/dist/cjs/ag-grid-plus/toolBar/index.js +23 -23
- package/dist/cjs/ag-grid-plus/toolBar/leftContent.d.ts +5 -0
- package/dist/cjs/ag-grid-plus/toolBar/leftContent.js +21 -0
- package/dist/cjs/array-table/index.js +2 -0
- package/dist/cjs/array-table/indexColumn.d.ts +2 -0
- package/dist/cjs/array-table/indexColumn.js +5 -13
- package/dist/cjs/array-table/preview.js +6 -0
- package/dist/cjs/array-table/utils.js +4 -1
- package/dist/cjs/dialogSelect/index.d.ts +4 -0
- package/dist/cjs/dialogSelect/index.js +30 -19
- package/dist/cjs/dialogSelect/selectedLabels.d.ts +34 -0
- package/dist/cjs/dialogSelect/selectedLabels.js +251 -0
- package/dist/cjs/entitySelect/index.d.ts +2 -0
- package/dist/cjs/entitySelect/index.js +2 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/readPretty/arrayTable.js +6 -2
- package/dist/cjs/readPretty/controls.d.ts +3 -0
- package/dist/cjs/readPretty/controls.js +7 -4
- package/dist/cjs/readPretty/formily.d.ts +1 -1
- package/dist/cjs/readPretty/formily.js +5 -4
- package/dist/cjs/standardList/StandardAgGridPlus.js +5 -32
- package/dist/cjs/utils/gridSequence.d.ts +9 -0
- package/dist/cjs/utils/gridSequence.js +110 -0
- package/dist/esm/ag-grid-plus/queryForm/queryForm.js +17 -29
- package/dist/esm/ag-grid-plus/toolBar/index.js +23 -23
- package/dist/esm/ag-grid-plus/toolBar/leftContent.d.ts +5 -0
- package/dist/esm/ag-grid-plus/toolBar/leftContent.js +13 -0
- package/dist/esm/array-table/index.js +2 -0
- package/dist/esm/array-table/indexColumn.d.ts +2 -0
- package/dist/esm/array-table/indexColumn.js +5 -12
- package/dist/esm/array-table/preview.js +6 -0
- package/dist/esm/array-table/utils.js +4 -1
- package/dist/esm/dialogSelect/index.d.ts +4 -0
- package/dist/esm/dialogSelect/index.js +30 -19
- package/dist/esm/dialogSelect/selectedLabels.d.ts +34 -0
- package/dist/esm/dialogSelect/selectedLabels.js +243 -0
- package/dist/esm/entitySelect/index.d.ts +2 -0
- package/dist/esm/entitySelect/index.js +2 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/readPretty/arrayTable.js +6 -2
- package/dist/esm/readPretty/controls.d.ts +3 -0
- package/dist/esm/readPretty/controls.js +7 -4
- package/dist/esm/readPretty/formily.d.ts +1 -1
- package/dist/esm/readPretty/formily.js +5 -4
- package/dist/esm/standardList/StandardAgGridPlus.js +5 -32
- package/dist/esm/utils/gridSequence.d.ts +9 -0
- package/dist/esm/utils/gridSequence.js +104 -0
- package/dist/umd/qc-ui.min.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withDisplaySequencePolicy = exports.installDisplaySequenceOrder = void 0;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
|
+
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."); }
|
|
10
|
+
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); }
|
|
11
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
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; }
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
/** 由表格生成、与业务行号无关的显示序号标记。@author nokecy */
|
|
20
|
+
var DISPLAY_SEQUENCE_CONTEXT_KEY = 'qcDisplaySequence';
|
|
21
|
+
var SELECTION_COLUMN_ID = 'ag-Grid-SelectionColumn';
|
|
22
|
+
var GENERATED_SEQUENCE_IDS = new Set(['__arrayTableIndex', '__smartErpDisplaySequence', '序号']);
|
|
23
|
+
var installedGrids = new WeakSet();
|
|
24
|
+
|
|
25
|
+
/** 显示序号始终可见、左固定;列方案仍可调整其他业务列。@author nokecy */
|
|
26
|
+
var withDisplaySequencePolicy = exports.withDisplaySequencePolicy = function withDisplaySequencePolicy(column) {
|
|
27
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
28
|
+
context: _objectSpread(_objectSpread({}, column.context), {}, _defineProperty({}, DISPLAY_SEQUENCE_CONTEXT_KEY, true)),
|
|
29
|
+
pinned: 'left',
|
|
30
|
+
hide: false,
|
|
31
|
+
initialHide: false,
|
|
32
|
+
lockPosition: false,
|
|
33
|
+
lockPinned: true,
|
|
34
|
+
lockVisible: true,
|
|
35
|
+
suppressMovable: true,
|
|
36
|
+
suppressColumnsToolPanel: true,
|
|
37
|
+
sortable: false,
|
|
38
|
+
filter: false,
|
|
39
|
+
editable: false
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 首次加载及列方案恢复后,保持“选择框、显示序号、业务列”的顺序。
|
|
45
|
+
* 只校正系统列的位置和可见性,保留业务列的宽度、固定、显隐及相对顺序。
|
|
46
|
+
* @author nokecy
|
|
47
|
+
*/
|
|
48
|
+
var installDisplaySequenceOrder = exports.installDisplaySequenceOrder = function installDisplaySequenceOrder(api) {
|
|
49
|
+
if (installedGrids.has(api)) return;
|
|
50
|
+
installedGrids.add(api);
|
|
51
|
+
var pending = false;
|
|
52
|
+
var applying = false;
|
|
53
|
+
var schedule = function schedule() {
|
|
54
|
+
if (pending || applying) return;
|
|
55
|
+
pending = true;
|
|
56
|
+
Promise.resolve().then(function () {
|
|
57
|
+
var _api$getColumns;
|
|
58
|
+
pending = false;
|
|
59
|
+
if (api.isDestroyed()) return;
|
|
60
|
+
var markedIds = new Set(((_api$getColumns = api.getColumns()) !== null && _api$getColumns !== void 0 ? _api$getColumns : []).filter(function (column) {
|
|
61
|
+
var _column$getColDef$con;
|
|
62
|
+
return (_column$getColDef$con = column.getColDef().context) === null || _column$getColDef$con === void 0 ? void 0 : _column$getColDef$con[DISPLAY_SEQUENCE_CONTEXT_KEY];
|
|
63
|
+
}).map(function (column) {
|
|
64
|
+
return column.getColId();
|
|
65
|
+
}));
|
|
66
|
+
var state = api.getColumnState();
|
|
67
|
+
var isSequence = function isSequence(colId) {
|
|
68
|
+
return GENERATED_SEQUENCE_IDS.has(colId) || markedIds.has(colId);
|
|
69
|
+
};
|
|
70
|
+
var selection = state.find(function (column) {
|
|
71
|
+
return column.colId === SELECTION_COLUMN_ID;
|
|
72
|
+
});
|
|
73
|
+
var sequences = state.filter(function (column) {
|
|
74
|
+
return isSequence(column.colId);
|
|
75
|
+
});
|
|
76
|
+
var prefix = [].concat(_toConsumableArray(selection ? [_objectSpread(_objectSpread({}, selection), {}, {
|
|
77
|
+
pinned: 'left'
|
|
78
|
+
})] : []), _toConsumableArray(sequences.map(function (column) {
|
|
79
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
80
|
+
pinned: 'left',
|
|
81
|
+
hide: false
|
|
82
|
+
});
|
|
83
|
+
})));
|
|
84
|
+
if (prefix.every(function (column, index) {
|
|
85
|
+
var _state$index, _state$index2, _state$index3;
|
|
86
|
+
return ((_state$index = state[index]) === null || _state$index === void 0 ? void 0 : _state$index.colId) === column.colId && ((_state$index2 = state[index]) === null || _state$index2 === void 0 ? void 0 : _state$index2.pinned) === 'left' && (!isSequence(column.colId) || ((_state$index3 = state[index]) === null || _state$index3 === void 0 ? void 0 : _state$index3.hide) !== true);
|
|
87
|
+
})) return;
|
|
88
|
+
var prefixIds = new Set(prefix.map(function (column) {
|
|
89
|
+
return column.colId;
|
|
90
|
+
}));
|
|
91
|
+
applying = true;
|
|
92
|
+
try {
|
|
93
|
+
api.applyColumnState({
|
|
94
|
+
state: [].concat(_toConsumableArray(prefix), _toConsumableArray(state.filter(function (column) {
|
|
95
|
+
return !prefixIds.has(column.colId);
|
|
96
|
+
}))),
|
|
97
|
+
applyOrder: true
|
|
98
|
+
});
|
|
99
|
+
} finally {
|
|
100
|
+
applying = false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
api.addEventListener('newColumnsLoaded', schedule);
|
|
105
|
+
api.addEventListener('columnEverythingChanged', schedule);
|
|
106
|
+
api.addEventListener('columnPinned', schedule);
|
|
107
|
+
api.addEventListener('columnMoved', schedule);
|
|
108
|
+
api.addEventListener('columnVisible', schedule);
|
|
109
|
+
schedule();
|
|
110
|
+
};
|
|
@@ -7,6 +7,8 @@ var useCollapseGrid = function useCollapseGrid(maxRows, defaultExpand) {
|
|
|
7
7
|
var grid = useMemo(function () {
|
|
8
8
|
return FormGrid.createFormGrid({
|
|
9
9
|
maxColumns: 5,
|
|
10
|
+
// 查询项含固定标签和输入框,操作区含查询、重置、折叠入口。@author nokecy
|
|
11
|
+
minWidth: 240,
|
|
10
12
|
maxWidth: 240,
|
|
11
13
|
maxRows: defaultExpand ? Infinity : maxRows,
|
|
12
14
|
shouldVisible: function shouldVisible(node, grid) {
|
|
@@ -18,28 +20,19 @@ var useCollapseGrid = function useCollapseGrid(maxRows, defaultExpand) {
|
|
|
18
20
|
return true;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (isCollapsed && maxRows === 1) {
|
|
26
|
-
// 如果当前节点在第一行,检查是否超过了最大列数限制
|
|
27
|
-
if (node.shadowRow <= 1) {
|
|
28
|
-
// 为按钮预留一列空间,所以实际可显示的列数要减1
|
|
29
|
-
return node.shadowColumn < grid.maxColumns;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 其他情况按照行数限制显示
|
|
35
|
-
return node.shadowRow < maxRows + 1;
|
|
23
|
+
// 所有查询项均占一格;按当前响应式列数为末行按钮预留一格。
|
|
24
|
+
// 单列窄屏至少保留一个查询项,按钮自然换到下一行。@author nokecy
|
|
25
|
+
var capacity = Math.max(1, maxRows * Math.max(1, grid.columns) - 1);
|
|
26
|
+
return node.index !== undefined && node.index < capacity;
|
|
36
27
|
}
|
|
37
28
|
});
|
|
38
29
|
}, [maxRows, defaultExpand] // 添加依赖项
|
|
39
30
|
);
|
|
40
31
|
var expanded = grid.maxRows === Infinity;
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
// 操作区展开时会填满余列,不能把它上一次的跨度用来判断是否还有隐藏条件。
|
|
33
|
+
// 根据完整查询项数量判断,折叠、外部重渲染和容器变宽都不会丢失入口。@author nokecy
|
|
34
|
+
var capacity = Math.max(1, maxRows * Math.max(1, grid.columns) - 1);
|
|
35
|
+
var collapsible = Math.max(0, grid.childSize - 1) > capacity;
|
|
43
36
|
var toggle = function toggle() {
|
|
44
37
|
if (grid.maxRows === Infinity) {
|
|
45
38
|
grid.maxRows = maxRows;
|
|
@@ -47,16 +40,11 @@ var useCollapseGrid = function useCollapseGrid(maxRows, defaultExpand) {
|
|
|
47
40
|
grid.maxRows = Infinity;
|
|
48
41
|
}
|
|
49
42
|
};
|
|
50
|
-
var takeType = function takeType() {
|
|
51
|
-
if (realRows < maxRows + 1) return "incomplete-wrap";
|
|
52
|
-
if (computeRows > maxRows) return "collapsible";
|
|
53
|
-
return "complete-wrap";
|
|
54
|
-
};
|
|
55
43
|
return {
|
|
56
44
|
grid: grid,
|
|
57
45
|
expanded: expanded,
|
|
58
46
|
toggle: toggle,
|
|
59
|
-
|
|
47
|
+
collapsible: collapsible
|
|
60
48
|
};
|
|
61
49
|
};
|
|
62
50
|
var QueryForm = observer(function (props) {
|
|
@@ -64,14 +52,12 @@ var QueryForm = observer(function (props) {
|
|
|
64
52
|
_props$defaultExpand = props.defaultExpand,
|
|
65
53
|
defaultExpand = _props$defaultExpand === void 0 ? false : _props$defaultExpand,
|
|
66
54
|
_props$defaultRows = props.defaultRows,
|
|
67
|
-
defaultRows = _props$defaultRows === void 0 ? 1 : _props$defaultRows;
|
|
68
|
-
|
|
55
|
+
defaultRows = _props$defaultRows === void 0 ? 1 : _props$defaultRows;
|
|
69
56
|
var _useCollapseGrid = useCollapseGrid(defaultRows, defaultExpand),
|
|
70
57
|
grid = _useCollapseGrid.grid,
|
|
71
58
|
expanded = _useCollapseGrid.expanded,
|
|
72
59
|
toggle = _useCollapseGrid.toggle,
|
|
73
|
-
|
|
74
|
-
|
|
60
|
+
collapsible = _useCollapseGrid.collapsible;
|
|
75
61
|
var renderActions = function renderActions() {
|
|
76
62
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Submit, {
|
|
77
63
|
type: "primary",
|
|
@@ -83,6 +69,8 @@ var QueryForm = observer(function (props) {
|
|
|
83
69
|
};
|
|
84
70
|
var renderExpanded = function renderExpanded() {
|
|
85
71
|
return /*#__PURE__*/React.createElement("a", {
|
|
72
|
+
href: "#",
|
|
73
|
+
"aria-expanded": expanded,
|
|
86
74
|
onClick: function onClick(e) {
|
|
87
75
|
e.preventDefault();
|
|
88
76
|
toggle();
|
|
@@ -98,14 +86,14 @@ var QueryForm = observer(function (props) {
|
|
|
98
86
|
var renderButtonGroup = function renderButtonGroup() {
|
|
99
87
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(FormButtonGroup, {
|
|
100
88
|
align: "right"
|
|
101
|
-
}, renderActions(),
|
|
89
|
+
}, renderActions(), collapsible ? renderExpanded() : null));
|
|
102
90
|
};
|
|
103
91
|
return /*#__PURE__*/React.createElement(FormGrid, {
|
|
104
92
|
grid: grid,
|
|
105
93
|
colWrap: true,
|
|
106
94
|
strictAutoFit: true
|
|
107
95
|
}, props.children, /*#__PURE__*/React.createElement(FormGrid.GridColumn, {
|
|
108
|
-
gridSpan: -1,
|
|
96
|
+
gridSpan: expanded || !collapsible ? -1 : 1,
|
|
109
97
|
style: {
|
|
110
98
|
display: "flex",
|
|
111
99
|
justifyContent: "right"
|
|
@@ -4,12 +4,19 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
import { LabelIconTip } from '@ant-design/pro-utils';
|
|
8
14
|
import { proTheme } from '@ant-design/pro-provider';
|
|
9
15
|
import { ConfigProvider, Tooltip } from 'antd';
|
|
10
16
|
import classNames from 'classnames';
|
|
11
|
-
import React, { useContext, useMemo } from 'react';
|
|
17
|
+
import React, { useContext, useMemo, useState } from 'react';
|
|
12
18
|
import { useStyle } from "./style";
|
|
19
|
+
import { ListToolbarLeftContext } from "./leftContent";
|
|
13
20
|
/**
|
|
14
21
|
* 获取配置区域 DOM Item
|
|
15
22
|
*
|
|
@@ -60,6 +67,10 @@ var ListToolBar = function ListToolBar(_ref) {
|
|
|
60
67
|
var _useStyle = useStyle(prefixCls),
|
|
61
68
|
wrapSSR = _useStyle.wrapSSR,
|
|
62
69
|
hashId = _useStyle.hashId;
|
|
70
|
+
var _useState = useState(null),
|
|
71
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
72
|
+
leftContainer = _useState2[0],
|
|
73
|
+
setLeftContainer = _useState2[1];
|
|
63
74
|
|
|
64
75
|
/** 有没有 title,需要结合多个场景判断 */
|
|
65
76
|
var hasTitle = useMemo(function () {
|
|
@@ -96,25 +107,7 @@ var ListToolBar = function ListToolBar(_ref) {
|
|
|
96
107
|
return tooltip || title || subTitle;
|
|
97
108
|
}, [hasTitle, subTitle, title, tooltip]);
|
|
98
109
|
var leftTitleDom = useMemo(function () {
|
|
99
|
-
//
|
|
100
|
-
if (!hasLeft && hasRight) {
|
|
101
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
102
|
-
className: "".concat(prefixCls, "-left ").concat(hashId)
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 减少 space 的dom,渲染的时候能节省点性能
|
|
107
|
-
if (hasTitle) {
|
|
108
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
109
|
-
className: "".concat(prefixCls, "-left ").concat(hashId)
|
|
110
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: "".concat(prefixCls, "-title ").concat(hashId)
|
|
112
|
-
}, /*#__PURE__*/React.createElement(LabelIconTip, {
|
|
113
|
-
tooltip: tooltip,
|
|
114
|
-
label: title,
|
|
115
|
-
subTitle: subTitle
|
|
116
|
-
})));
|
|
117
|
-
}
|
|
110
|
+
// 保留左侧占位,并为操作组件提供当前列表独立的辅助内容位。@author nokecy
|
|
118
111
|
return /*#__PURE__*/React.createElement("div", {
|
|
119
112
|
className: "".concat(prefixCls, "-left ").concat(hashId)
|
|
120
113
|
}, hasTitle && /*#__PURE__*/React.createElement("div", {
|
|
@@ -123,7 +116,12 @@ var ListToolBar = function ListToolBar(_ref) {
|
|
|
123
116
|
tooltip: tooltip,
|
|
124
117
|
label: title,
|
|
125
118
|
subTitle: subTitle
|
|
126
|
-
}))
|
|
119
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
ref: setLeftContainer,
|
|
121
|
+
style: {
|
|
122
|
+
display: 'contents'
|
|
123
|
+
}
|
|
124
|
+
}));
|
|
127
125
|
}, [hasLeft, hasRight, hasTitle, hashId, prefixCls, subTitle, title, tooltip]);
|
|
128
126
|
var rightTitleDom = useMemo(function () {
|
|
129
127
|
if (!hasRight) return null;
|
|
@@ -153,9 +151,11 @@ var ListToolBar = function ListToolBar(_ref) {
|
|
|
153
151
|
className: containerClassName
|
|
154
152
|
}, leftTitleDom, rightTitleDom);
|
|
155
153
|
}, [hasLeft, hasRight, hashId, leftTitleDom, prefixCls, rightTitleDom]);
|
|
156
|
-
return /*#__PURE__*/React.createElement(
|
|
154
|
+
return /*#__PURE__*/React.createElement(ListToolbarLeftContext.Provider, {
|
|
155
|
+
value: leftContainer
|
|
156
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
157
157
|
style: style,
|
|
158
158
|
className: classNames(prefixCls, hashId, className)
|
|
159
|
-
}, titleNode);
|
|
159
|
+
}, titleNode));
|
|
160
160
|
};
|
|
161
161
|
export default ListToolBar;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** 当前列表工具栏的左侧内容容器;undefined 表示位于列表工具栏之外。@author nokecy */
|
|
3
|
+
export declare const ListToolbarLeftContext: React.Context<HTMLElement | null | undefined>;
|
|
4
|
+
/** 将选择摘要等辅助内容放到当前列表标题旁;独立使用时保留原位置。@author nokecy */
|
|
5
|
+
export declare const ListToolbarLeft: React.FC<React.PropsWithChildren>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
|
|
4
|
+
/** 当前列表工具栏的左侧内容容器;undefined 表示位于列表工具栏之外。@author nokecy */
|
|
5
|
+
export var ListToolbarLeftContext = /*#__PURE__*/createContext(undefined);
|
|
6
|
+
|
|
7
|
+
/** 将选择摘要等辅助内容放到当前列表标题旁;独立使用时保留原位置。@author nokecy */
|
|
8
|
+
export var ListToolbarLeft = function ListToolbarLeft(_ref) {
|
|
9
|
+
var children = _ref.children;
|
|
10
|
+
var container = useContext(ListToolbarLeftContext);
|
|
11
|
+
if (container === undefined) return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
12
|
+
return container ? /*#__PURE__*/createPortal(children, container) : null;
|
|
13
|
+
};
|
|
@@ -22,6 +22,7 @@ import { useArrayTableBatchRemove } from "./batchRemove";
|
|
|
22
22
|
import { useAddition, buildArrayTableColumns, useArrayTableSources, useArrayTableActions, isColumnComponent, collectLazyDefaults, applyLazyDefaults } from "./utils";
|
|
23
23
|
import { groupColumnDefs } from "./columnGroup";
|
|
24
24
|
import { ARRAY_TABLE_INDEX_FIELD, hasOwnIndexColumn, makeIndexColumn } from "./indexColumn";
|
|
25
|
+
import { installDisplaySequenceOrder } from "../utils/gridSequence";
|
|
25
26
|
import { ensureArrayTableRowIds, getArrayTableRowId } from "./rowIdentity";
|
|
26
27
|
import { useCellFocus, useKeyboardNavigation, useRowDrag, suppressNativeInputKeys } from "./hooks";
|
|
27
28
|
import ArrayBase from "./arrayBase";
|
|
@@ -381,6 +382,7 @@ var ArrayTableInner = observer(function (props) {
|
|
|
381
382
|
context: gridContext,
|
|
382
383
|
onGridReady: function onGridReady(params) {
|
|
383
384
|
var _props$onGridReady;
|
|
385
|
+
installDisplaySequenceOrder(params.api);
|
|
384
386
|
params.api.hidePopupMenu();
|
|
385
387
|
apiRef.current = params.api;
|
|
386
388
|
setGridApiState(params.api);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ColDef } from 'ag-grid-community';
|
|
2
2
|
/** 默认序号列的字段名;不对应任何数据字段,值由 valueGetter 按行位置生成 */
|
|
3
3
|
export declare const ARRAY_TABLE_INDEX_FIELD = "__arrayTableIndex";
|
|
4
|
+
/** schema 里含 ArrayTable.Index / ArrayBase.Index 之类的序号组件 */
|
|
5
|
+
export declare const containsIndexComponent: (schema: any) => boolean;
|
|
4
6
|
/**
|
|
5
7
|
* 表格是否已经自己写了序号列(某个可见列里放了 ArrayTable.Index)。
|
|
6
8
|
* 写了就不再加默认序号列,免得出现两列序号;「行号」等业务数据列不算序号列。@author nokecy
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { withDisplaySequencePolicy } from "../utils/gridSequence";
|
|
2
|
+
|
|
1
3
|
/** 默认序号列的字段名;不对应任何数据字段,值由 valueGetter 按行位置生成 */
|
|
2
4
|
export var ARRAY_TABLE_INDEX_FIELD = '__arrayTableIndex';
|
|
3
5
|
|
|
4
6
|
/** schema 里含 ArrayTable.Index / ArrayBase.Index 之类的序号组件 */
|
|
5
|
-
var containsIndexComponent = function containsIndexComponent(schema) {
|
|
7
|
+
export var containsIndexComponent = function containsIndexComponent(schema) {
|
|
6
8
|
var _schema$properties;
|
|
7
9
|
if (!schema) return false;
|
|
8
10
|
var component = schema['x-component'];
|
|
@@ -29,26 +31,17 @@ export var hasOwnIndexColumn = function hasOwnIndexColumn(sources) {
|
|
|
29
31
|
* 增删行、拖动换行后由 ArrayTable 在 onRowDataUpdated 里刷新本列,见 index.tsx。@author nokecy
|
|
30
32
|
*/
|
|
31
33
|
export var makeIndexColumn = function makeIndexColumn() {
|
|
32
|
-
return {
|
|
34
|
+
return withDisplaySequencePolicy({
|
|
33
35
|
field: ARRAY_TABLE_INDEX_FIELD,
|
|
34
36
|
headerName: '序号',
|
|
35
37
|
width: 60,
|
|
36
38
|
pinned: 'left',
|
|
37
|
-
// 勾选列拥有最左位置;序号保留固定和禁止拖动,避免恢复旧方案时抢到勾选列之前。@author nokecy
|
|
38
|
-
lockPosition: false,
|
|
39
|
-
lockPinned: true,
|
|
40
|
-
lockVisible: true,
|
|
41
|
-
suppressMovable: true,
|
|
42
|
-
suppressColumnsToolPanel: true,
|
|
43
|
-
sortable: false,
|
|
44
|
-
filter: false,
|
|
45
39
|
resizable: false,
|
|
46
|
-
editable: false,
|
|
47
40
|
valueGetter: function valueGetter(params) {
|
|
48
41
|
var _params$node, _params$node2;
|
|
49
42
|
if ((_params$node = params.node) !== null && _params$node !== void 0 && _params$node.rowPinned) return '';
|
|
50
43
|
var rowIndex = (_params$node2 = params.node) === null || _params$node2 === void 0 ? void 0 : _params$node2.rowIndex;
|
|
51
44
|
return rowIndex == null ? '' : rowIndex + 1;
|
|
52
45
|
}
|
|
53
|
-
};
|
|
46
|
+
});
|
|
54
47
|
};
|
|
@@ -4,6 +4,7 @@ import { buildArrayTableColumns, useArrayTableSources } from "./utils";
|
|
|
4
4
|
import { AgGridPlus } from "../ag-grid-plus";
|
|
5
5
|
import { useArrayTableTheme, ARRAY_TABLE_ROW_HEIGHT } from "./theme";
|
|
6
6
|
import { ARRAY_TABLE_INDEX_FIELD, hasOwnIndexColumn, makeIndexColumn } from "./indexColumn";
|
|
7
|
+
import { installDisplaySequenceOrder } from "../utils/gridSequence";
|
|
7
8
|
//@ts-ignore
|
|
8
9
|
var ArrayTable = function ArrayTable(props) {
|
|
9
10
|
var _buildArrayTableColum;
|
|
@@ -35,6 +36,11 @@ var ArrayTable = function ArrayTable(props) {
|
|
|
35
36
|
search: false,
|
|
36
37
|
theme: arrayTablePreviewTheme,
|
|
37
38
|
rowHeight: ARRAY_TABLE_ROW_HEIGHT,
|
|
39
|
+
onGridReady: function onGridReady(event) {
|
|
40
|
+
var _props$onGridReady;
|
|
41
|
+
installDisplaySequenceOrder(event.api);
|
|
42
|
+
(_props$onGridReady = props.onGridReady) === null || _props$onGridReady === void 0 || _props$onGridReady.call(props, event);
|
|
43
|
+
},
|
|
38
44
|
pagination: false,
|
|
39
45
|
onSortChanged: function onSortChanged(event) {
|
|
40
46
|
var _props$onSortChanged;
|
|
@@ -27,6 +27,8 @@ import { fallbackFormatter, getReadOnlyFormatter, getReadOnlyRenderer } from "./
|
|
|
27
27
|
import { markHeaderGroup } from "./columnGroup";
|
|
28
28
|
import { CellFocusScope } from "./cellFocusScope";
|
|
29
29
|
import { createArrayTableComparator } from "./sorting";
|
|
30
|
+
import { containsIndexComponent } from "./indexColumn";
|
|
31
|
+
import { withDisplaySequencePolicy } from "../utils/gridSequence";
|
|
30
32
|
var isColumnComponent = function isColumnComponent(schema) {
|
|
31
33
|
var _schema$xComponent;
|
|
32
34
|
return ((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : _schema$xComponent.indexOf('Column')) > -1;
|
|
@@ -730,8 +732,9 @@ var buildArrayTableColumns = function buildArrayTableColumns(dataSource, field,
|
|
|
730
732
|
|
|
731
733
|
// 记下分组名再输出列定义;真正合并成列组在 index.tsx 交给 AG-Grid 之前(groupColumnDefs)做,
|
|
732
734
|
// 这里产出的仍是扁平列定义。@author nokecy
|
|
735
|
+
var isSequenceColumn = containsIndexComponent(schema);
|
|
733
736
|
var emit = function emit(colDef) {
|
|
734
|
-
return buf.concat(markHeaderGroup(colDef, headerGroup));
|
|
737
|
+
return buf.concat(markHeaderGroup(isSequenceColumn ? withDisplaySequencePolicy(colDef) : colDef, isSequenceColumn ? undefined : headerGroup));
|
|
735
738
|
};
|
|
736
739
|
|
|
737
740
|
// 三分流渲染策略:@author nokecy
|
|
@@ -7,6 +7,10 @@ import './index.less';
|
|
|
7
7
|
/** 选择窗口的行选择模式。 */
|
|
8
8
|
type DialogSelectionMode = 'single' | 'multiple';
|
|
9
9
|
interface IDialogSelectProps extends SelectProps<any> {
|
|
10
|
+
/** 自定义限定候选的名称解析;不会触发选择或联动。@author nokecy */
|
|
11
|
+
resolveSelected?: (values: any[]) => Promise<any>;
|
|
12
|
+
/** 名称查询的业务范围;如库位所属仓库,变更后不复用旧范围标签。@author nokecy */
|
|
13
|
+
selectedScopeKey?: string | number;
|
|
10
14
|
/** 回显编码或名称,保持原始 value/label 和联动回调不变。@author nokecy */
|
|
11
15
|
displayField?: SelectDisplayField;
|
|
12
16
|
/** 隐藏选择窗口入口(输入框内的后缀图标),只保留输入与下拉。 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var _excluded = ["request", "columnDefs", "value", "labelField", "valueField", "displayField", "onChangeItem", "hideBtn", "useAutoComplete", "queryFun", "pagedApiAdapter", "modalWidth", "dialogZIndex", "dialogMode", "dialogPageSize", "dialogPageSizeOptions", "dialogGridKey", "dialogDataSource", "dialogIsRowSelectable", "dialogRenderer", "gridComponent"],
|
|
2
|
-
_excluded2 = ["request", "columnDefs", "labelField", "valueField", "displayField", "onChangeItem", "hideBtn", "useAutoComplete", "queryFun", "pagedApiAdapter", "modalWidth", "dialogZIndex", "dialogMode", "dialogPageSize", "dialogPageSizeOptions", "dialogGridKey", "dialogDataSource", "dialogIsRowSelectable", "dialogRenderer", "gridComponent"];
|
|
1
|
+
var _excluded = ["request", "columnDefs", "value", "labelField", "valueField", "displayField", "onChangeItem", "hideBtn", "useAutoComplete", "queryFun", "pagedApiAdapter", "resolveSelected", "selectedScopeKey", "modalWidth", "dialogZIndex", "dialogMode", "dialogPageSize", "dialogPageSizeOptions", "dialogGridKey", "dialogDataSource", "dialogIsRowSelectable", "dialogRenderer", "gridComponent"],
|
|
2
|
+
_excluded2 = ["request", "columnDefs", "labelField", "valueField", "displayField", "onChangeItem", "hideBtn", "useAutoComplete", "queryFun", "pagedApiAdapter", "resolveSelected", "selectedScopeKey", "modalWidth", "dialogZIndex", "dialogMode", "dialogPageSize", "dialogPageSizeOptions", "dialogGridKey", "dialogDataSource", "dialogIsRowSelectable", "dialogRenderer", "gridComponent"];
|
|
3
3
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
4
4
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
5
5
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -31,12 +31,13 @@ import { Select as ReadingSelect } from "../readPretty/controls";
|
|
|
31
31
|
import { normalizeSelectValue } from "../readPretty/selectValue";
|
|
32
32
|
import { formatSelectDisplay } from "../array-table/readOnlyFormatters";
|
|
33
33
|
import { useCellInteractionLock } from "../array-table/cellInteractionLock";
|
|
34
|
+
import { selectedDisplayValue, useSelectedLabels, withSelectedLabels } from "./selectedLabels";
|
|
34
35
|
import "./index.less";
|
|
35
36
|
|
|
36
37
|
/** 选择窗口的行选择模式。 */
|
|
37
38
|
|
|
38
39
|
var DialogSelectInner = function DialogSelectInner(props) {
|
|
39
|
-
var _selectRows$length;
|
|
40
|
+
var _rest$labelRender, _selectRows$length;
|
|
40
41
|
// 这些是本组件自己的属性,不能透传给 Select(否则会落到 DOM 上触发未知属性告警)。
|
|
41
42
|
var request = props.request,
|
|
42
43
|
columnDefs = props.columnDefs,
|
|
@@ -49,6 +50,8 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
49
50
|
useAutoComplete = props.useAutoComplete,
|
|
50
51
|
queryFun = props.queryFun,
|
|
51
52
|
pagedApiAdapter = props.pagedApiAdapter,
|
|
53
|
+
resolveSelected = props.resolveSelected,
|
|
54
|
+
selectedScopeKey = props.selectedScopeKey,
|
|
52
55
|
_props$modalWidth = props.modalWidth,
|
|
53
56
|
modalWidth = _props$modalWidth === void 0 ? 960 : _props$modalWidth,
|
|
54
57
|
_props$dialogZIndex = props.dialogZIndex,
|
|
@@ -67,6 +70,7 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
67
70
|
_useControllableValue2 = _slicedToArray(_useControllableValue, 2),
|
|
68
71
|
state = _useControllableValue2[0],
|
|
69
72
|
setState = _useControllableValue2[1];
|
|
73
|
+
var selectedLabels = useSelectedLabels(props, state);
|
|
70
74
|
var _useBoolean = useBoolean(false),
|
|
71
75
|
_useBoolean2 = _slicedToArray(_useBoolean, 2),
|
|
72
76
|
visible = _useBoolean2[0],
|
|
@@ -145,13 +149,17 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
145
149
|
'--qc-dialog-select-trigger-color': token.colorTextTertiary,
|
|
146
150
|
'--qc-dialog-select-trigger-hover': token.colorPrimary
|
|
147
151
|
};
|
|
148
|
-
var commonProps = _objectSpread(_objectSpread(
|
|
149
|
-
labelRender: function
|
|
152
|
+
var commonProps = _objectSpread(_objectSpread({}, rest), {}, {
|
|
153
|
+
labelRender: displayField === 'value' ? function (item) {
|
|
150
154
|
return formatSelectDisplay(item, 'value');
|
|
151
|
-
}
|
|
152
|
-
|
|
155
|
+
} : (_rest$labelRender = rest.labelRender) !== null && _rest$labelRender !== void 0 ? _rest$labelRender : function (item) {
|
|
156
|
+
var _ref, _selectedLabels$find$, _selectedLabels$find;
|
|
157
|
+
return (_ref = (_selectedLabels$find$ = (_selectedLabels$find = selectedLabels.find(function (option) {
|
|
158
|
+
return option.value === item.value;
|
|
159
|
+
})) === null || _selectedLabels$find === void 0 ? void 0 : _selectedLabels$find.label) !== null && _selectedLabels$find$ !== void 0 ? _selectedLabels$find$ : item.label) !== null && _ref !== void 0 ? _ref : item.value;
|
|
160
|
+
},
|
|
153
161
|
className: mergedClassName,
|
|
154
|
-
value: state,
|
|
162
|
+
value: selectedDisplayValue(state, selectedLabels, props.labelInValue),
|
|
155
163
|
style: _objectSpread(_objectSpread({}, triggerStyle), rest.style || {})
|
|
156
164
|
}, trigger ? {
|
|
157
165
|
suffixIcon: trigger
|
|
@@ -189,8 +197,8 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
189
197
|
dataSource: dialogDataSource,
|
|
190
198
|
hidePagination: localData
|
|
191
199
|
}, localData ? {
|
|
192
|
-
getRowId: function getRowId(
|
|
193
|
-
var data =
|
|
200
|
+
getRowId: function getRowId(_ref2) {
|
|
201
|
+
var data = _ref2.data;
|
|
194
202
|
return String(data[key]);
|
|
195
203
|
}
|
|
196
204
|
} : {}, {
|
|
@@ -199,8 +207,8 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
199
207
|
},
|
|
200
208
|
pageSize: dialogPageSize,
|
|
201
209
|
pageSizeOptions: dialogPageSizeOptions,
|
|
202
|
-
onFirstDataRendered: function onFirstDataRendered(
|
|
203
|
-
var api =
|
|
210
|
+
onFirstDataRendered: function onFirstDataRendered(_ref3) {
|
|
211
|
+
var api = _ref3.api;
|
|
204
212
|
// 重开弹窗要把已经选中的行勾回来,否则用户会以为之前的选择丢了。
|
|
205
213
|
// 放在首屏数据渲染完成时做:弹窗是 destroyOnClose,打开的那一刻表格还没有数据。@author nokecy
|
|
206
214
|
var current = Array.isArray(state) ? state : state == null ? [] : [state];
|
|
@@ -222,13 +230,13 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
222
230
|
return !!node.data && dialogIsRowSelectable(node.data);
|
|
223
231
|
}
|
|
224
232
|
} : selectionMode === 'multiple' ? 'multiple' : 'single',
|
|
225
|
-
onRowDoubleClicked: function onRowDoubleClicked(
|
|
226
|
-
var data =
|
|
233
|
+
onRowDoubleClicked: function onRowDoubleClicked(_ref4) {
|
|
234
|
+
var data = _ref4.data;
|
|
227
235
|
if (dialogIsRowSelectable && !dialogIsRowSelectable(data)) return;
|
|
228
236
|
confirmRows([data]);
|
|
229
237
|
},
|
|
230
238
|
request: localData ? undefined : ( /*#__PURE__*/function () {
|
|
231
|
-
var
|
|
239
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params, _, record) {
|
|
232
240
|
var adapter, data;
|
|
233
241
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
234
242
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -256,7 +264,7 @@ var DialogSelectInner = function DialogSelectInner(props) {
|
|
|
256
264
|
}, _callee);
|
|
257
265
|
}));
|
|
258
266
|
return function (_x, _x2, _x3) {
|
|
259
|
-
return
|
|
267
|
+
return _ref5.apply(this, arguments);
|
|
260
268
|
};
|
|
261
269
|
}()),
|
|
262
270
|
columnDefs: columnDefs
|
|
@@ -278,10 +286,11 @@ var DialogSelect = observer(function (props) {
|
|
|
278
286
|
var _ConfigProvider$useCo = ConfigProvider.useConfig(),
|
|
279
287
|
componentDisabled = _ConfigProvider$useCo.componentDisabled;
|
|
280
288
|
var reading = (_props$disabled = props.disabled) !== null && _props$disabled !== void 0 ? _props$disabled : componentDisabled;
|
|
289
|
+
var selectedLabels = useSelectedLabels(props, 'value' in props ? props.value : props.defaultValue, !!(reading || field !== null && field !== void 0 && field.disabled || field !== null && field !== void 0 && field.readOnly || field !== null && field !== void 0 && field.readPretty));
|
|
281
290
|
var safeProps = _objectSpread(_objectSpread(_objectSpread({}, props), 'value' in props ? {
|
|
282
|
-
value: normalizeSelectValue(props.value, props.labelInValue)
|
|
291
|
+
value: selectedDisplayValue(normalizeSelectValue(props.value, props.labelInValue), selectedLabels, props.labelInValue)
|
|
283
292
|
} : {}), 'defaultValue' in props ? {
|
|
284
|
-
defaultValue: normalizeSelectValue(props.defaultValue, props.labelInValue)
|
|
293
|
+
defaultValue: selectedDisplayValue(normalizeSelectValue(props.defaultValue, props.labelInValue), selectedLabels, props.labelInValue)
|
|
285
294
|
} : {});
|
|
286
295
|
if (reading || field !== null && field !== void 0 && field.disabled || field !== null && field !== void 0 && field.readOnly || field !== null && field !== void 0 && field.readPretty) {
|
|
287
296
|
// 阅读态只需要选项与值;弹窗、取数等属性不下发。
|
|
@@ -295,6 +304,8 @@ var DialogSelect = observer(function (props) {
|
|
|
295
304
|
useAutoComplete = safeProps.useAutoComplete,
|
|
296
305
|
queryFun = safeProps.queryFun,
|
|
297
306
|
pagedApiAdapter = safeProps.pagedApiAdapter,
|
|
307
|
+
resolveSelected = safeProps.resolveSelected,
|
|
308
|
+
selectedScopeKey = safeProps.selectedScopeKey,
|
|
298
309
|
modalWidth = safeProps.modalWidth,
|
|
299
310
|
dialogZIndex = safeProps.dialogZIndex,
|
|
300
311
|
dialogMode = safeProps.dialogMode,
|
|
@@ -307,7 +318,7 @@ var DialogSelect = observer(function (props) {
|
|
|
307
318
|
gridComponent = safeProps.gridComponent,
|
|
308
319
|
selectProps = _objectWithoutProperties(safeProps, _excluded2);
|
|
309
320
|
if (displayField === 'value') return /*#__PURE__*/React.createElement("span", null, formatSelectDisplay('value' in safeProps ? safeProps.value : safeProps.defaultValue, 'value') || '—');
|
|
310
|
-
return /*#__PURE__*/React.createElement(ReadingSelect, _extends({}, selectProps, {
|
|
321
|
+
return /*#__PURE__*/React.createElement(ReadingSelect, _extends({}, withSelectedLabels(selectProps, selectedLabels), {
|
|
311
322
|
disabled: true
|
|
312
323
|
}));
|
|
313
324
|
}
|