@hi-ui/schema-editable-table 4.0.0-experimental.1
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/README.md +11 -0
- package/lib/cjs/body/index.js +110 -0
- package/lib/cjs/body/wrapper.js +132 -0
- package/lib/cjs/cell/aggregated.js +76 -0
- package/lib/cjs/cell/dependency.js +97 -0
- package/lib/cjs/cell/editing.js +89 -0
- package/lib/cjs/cell/footer.js +64 -0
- package/lib/cjs/cell/header.js +76 -0
- package/lib/cjs/cell/index.js +204 -0
- package/lib/cjs/const.js +35 -0
- package/lib/cjs/container/base.js +39 -0
- package/lib/cjs/container/bottom.js +86 -0
- package/lib/cjs/container/col-group.js +98 -0
- package/lib/cjs/container/column-virtual.js +53 -0
- package/lib/cjs/container/ctx.js +32 -0
- package/lib/cjs/container/full-virtual.js +61 -0
- package/lib/cjs/container/hooks.js +102 -0
- package/lib/cjs/container/index.js +69 -0
- package/lib/cjs/container/row-virtual.js +50 -0
- package/lib/cjs/container/wrapper.js +97 -0
- package/lib/cjs/ctx.js +32 -0
- package/lib/cjs/features/_overrides/aggregated.js +44 -0
- package/lib/cjs/features/_overrides/getter.js +61 -0
- package/lib/cjs/features/_overrides/grouping.js +40 -0
- package/lib/cjs/features/_overrides/overrides.js +43 -0
- package/lib/cjs/features/_overrides/row-selection.js +140 -0
- package/lib/cjs/features/async-data/getter.js +150 -0
- package/lib/cjs/features/async-data/normal.js +145 -0
- package/lib/cjs/features/async-data/use-data-fetcher.js +40 -0
- package/lib/cjs/features/async-data/use-reset-data.js +91 -0
- package/lib/cjs/features/column-grouping/get-grouping-config.js +27 -0
- package/lib/cjs/features/column-grouping/use-opts.js +42 -0
- package/lib/cjs/features/column-state.js +57 -0
- package/lib/cjs/features/filter/bridge.js +114 -0
- package/lib/cjs/features/filter/filter-fns/date.js +34 -0
- package/lib/cjs/features/filter/filter-fns/index.js +23 -0
- package/lib/cjs/features/filter/get-filter-config.js +61 -0
- package/lib/cjs/features/filter/index.js +29 -0
- package/lib/cjs/features/filter/use-opts.js +88 -0
- package/lib/cjs/features/header-actions/components/column-collapsing.js +74 -0
- package/lib/cjs/features/header-actions/get-actions.js +77 -0
- package/lib/cjs/features/pagination/component.js +89 -0
- package/lib/cjs/features/pagination/use-opts.js +98 -0
- package/lib/cjs/features/pagination/use-state.js +44 -0
- package/lib/cjs/features/row-controller.js +265 -0
- package/lib/cjs/features/row-edit/actions.js +65 -0
- package/lib/cjs/features/row-edit/hooks.js +29 -0
- package/lib/cjs/features/row-expanding/use-opts.js +39 -0
- package/lib/cjs/features/row-expanding/wrapper.js +74 -0
- package/lib/cjs/features/row-operation/buttons.js +91 -0
- package/lib/cjs/features/row-operation/cell.js +43 -0
- package/lib/cjs/features/row-operation/index.js +21 -0
- package/lib/cjs/features/row-operation/wrapper.js +114 -0
- package/lib/cjs/features/row-selection/cell.js +114 -0
- package/lib/cjs/features/row-selection/const.js +16 -0
- package/lib/cjs/features/row-selection/hooks/index.js +29 -0
- package/lib/cjs/features/row-selection/hooks/use-click-select.js +70 -0
- package/lib/cjs/features/row-selection/hooks/use-opts.js +120 -0
- package/lib/cjs/features/row-selection/hooks/use-set-selected-row-keys.js +48 -0
- package/lib/cjs/features/row-selection/hooks/use-sync-hover-style.js +86 -0
- package/lib/cjs/features/row-selection/indicator.js +173 -0
- package/lib/cjs/features/row-selection/wrapper.js +119 -0
- package/lib/cjs/features/setting-bridge.js +56 -0
- package/lib/cjs/features/sorter/bridge.js +65 -0
- package/lib/cjs/features/sorter/get-sorter-config.js +46 -0
- package/lib/cjs/features/sorter/index.js +29 -0
- package/lib/cjs/features/sorter/use-opts.js +81 -0
- package/lib/cjs/field-bridge/bridge.js +104 -0
- package/lib/cjs/field-bridge/index.js +58 -0
- package/lib/cjs/field-bridge/toolbar.js +53 -0
- package/lib/cjs/footer/index.js +99 -0
- package/lib/cjs/footer/use-first-cell-patch.js +42 -0
- package/lib/cjs/header/index.js +134 -0
- package/lib/cjs/header/validate.js +69 -0
- package/lib/cjs/hooks/use-get-fields-value.js +62 -0
- package/lib/cjs/hooks/use-global-actions.js +65 -0
- package/lib/cjs/hooks/use-global-static.js +158 -0
- package/lib/cjs/hooks/use-initial-render.js +30 -0
- package/lib/cjs/hooks/use-inner-ctx.js +105 -0
- package/lib/cjs/hooks/use-props.js +108 -0
- package/lib/cjs/hooks/use-table-columns.js +76 -0
- package/lib/cjs/hooks/use-table-meta.js +57 -0
- package/lib/cjs/hooks/use-update.js +57 -0
- package/lib/cjs/index.js +66 -0
- package/lib/cjs/index.scss.js +18 -0
- package/lib/cjs/table.js +263 -0
- package/lib/cjs/utils/cls.js +19 -0
- package/lib/cjs/utils/fixed.js +53 -0
- package/lib/cjs/utils/grouping.js +42 -0
- package/lib/cjs/utils/state-merge.js +43 -0
- package/lib/esm/body/index.js +98 -0
- package/lib/esm/body/wrapper.js +120 -0
- package/lib/esm/cell/aggregated.js +64 -0
- package/lib/esm/cell/dependency.js +90 -0
- package/lib/esm/cell/editing.js +76 -0
- package/lib/esm/cell/footer.js +52 -0
- package/lib/esm/cell/header.js +63 -0
- package/lib/esm/cell/index.js +192 -0
- package/lib/esm/const.js +24 -0
- package/lib/esm/container/base.js +27 -0
- package/lib/esm/container/bottom.js +74 -0
- package/lib/esm/container/col-group.js +85 -0
- package/lib/esm/container/column-virtual.js +41 -0
- package/lib/esm/container/ctx.js +19 -0
- package/lib/esm/container/full-virtual.js +49 -0
- package/lib/esm/container/hooks.js +95 -0
- package/lib/esm/container/index.js +57 -0
- package/lib/esm/container/row-virtual.js +38 -0
- package/lib/esm/container/wrapper.js +83 -0
- package/lib/esm/ctx.js +17 -0
- package/lib/esm/features/_overrides/aggregated.js +39 -0
- package/lib/esm/features/_overrides/getter.js +56 -0
- package/lib/esm/features/_overrides/grouping.js +35 -0
- package/lib/esm/features/_overrides/overrides.js +38 -0
- package/lib/esm/features/_overrides/row-selection.js +135 -0
- package/lib/esm/features/async-data/getter.js +143 -0
- package/lib/esm/features/async-data/normal.js +133 -0
- package/lib/esm/features/async-data/use-data-fetcher.js +34 -0
- package/lib/esm/features/async-data/use-reset-data.js +79 -0
- package/lib/esm/features/column-grouping/get-grouping-config.js +22 -0
- package/lib/esm/features/column-grouping/use-opts.js +36 -0
- package/lib/esm/features/column-state.js +51 -0
- package/lib/esm/features/filter/bridge.js +102 -0
- package/lib/esm/features/filter/filter-fns/date.js +28 -0
- package/lib/esm/features/filter/filter-fns/index.js +18 -0
- package/lib/esm/features/filter/get-filter-config.js +56 -0
- package/lib/esm/features/filter/index.js +24 -0
- package/lib/esm/features/filter/use-opts.js +82 -0
- package/lib/esm/features/header-actions/components/column-collapsing.js +62 -0
- package/lib/esm/features/header-actions/get-actions.js +65 -0
- package/lib/esm/features/pagination/component.js +77 -0
- package/lib/esm/features/pagination/use-opts.js +91 -0
- package/lib/esm/features/pagination/use-state.js +39 -0
- package/lib/esm/features/row-controller.js +253 -0
- package/lib/esm/features/row-edit/actions.js +53 -0
- package/lib/esm/features/row-edit/hooks.js +24 -0
- package/lib/esm/features/row-expanding/use-opts.js +33 -0
- package/lib/esm/features/row-expanding/wrapper.js +62 -0
- package/lib/esm/features/row-operation/buttons.js +79 -0
- package/lib/esm/features/row-operation/cell.js +31 -0
- package/lib/esm/features/row-operation/index.js +16 -0
- package/lib/esm/features/row-operation/wrapper.js +100 -0
- package/lib/esm/features/row-selection/cell.js +101 -0
- package/lib/esm/features/row-selection/const.js +11 -0
- package/lib/esm/features/row-selection/hooks/index.js +24 -0
- package/lib/esm/features/row-selection/hooks/use-click-select.js +65 -0
- package/lib/esm/features/row-selection/hooks/use-opts.js +114 -0
- package/lib/esm/features/row-selection/hooks/use-set-selected-row-keys.js +43 -0
- package/lib/esm/features/row-selection/hooks/use-sync-hover-style.js +81 -0
- package/lib/esm/features/row-selection/indicator.js +159 -0
- package/lib/esm/features/row-selection/wrapper.js +107 -0
- package/lib/esm/features/setting-bridge.js +50 -0
- package/lib/esm/features/sorter/bridge.js +53 -0
- package/lib/esm/features/sorter/get-sorter-config.js +41 -0
- package/lib/esm/features/sorter/index.js +24 -0
- package/lib/esm/features/sorter/use-opts.js +75 -0
- package/lib/esm/field-bridge/bridge.js +92 -0
- package/lib/esm/field-bridge/index.js +44 -0
- package/lib/esm/field-bridge/toolbar.js +41 -0
- package/lib/esm/footer/index.js +87 -0
- package/lib/esm/footer/use-first-cell-patch.js +37 -0
- package/lib/esm/header/index.js +121 -0
- package/lib/esm/header/validate.js +64 -0
- package/lib/esm/hooks/use-get-fields-value.js +56 -0
- package/lib/esm/hooks/use-global-actions.js +60 -0
- package/lib/esm/hooks/use-global-static.js +152 -0
- package/lib/esm/hooks/use-initial-render.js +18 -0
- package/lib/esm/hooks/use-inner-ctx.js +100 -0
- package/lib/esm/hooks/use-props.js +102 -0
- package/lib/esm/hooks/use-table-columns.js +70 -0
- package/lib/esm/hooks/use-table-meta.js +51 -0
- package/lib/esm/hooks/use-update.js +52 -0
- package/lib/esm/index.js +38 -0
- package/lib/esm/index.scss.js +13 -0
- package/lib/esm/table.js +251 -0
- package/lib/esm/utils/cls.js +13 -0
- package/lib/esm/utils/fixed.js +48 -0
- package/lib/esm/utils/grouping.js +36 -0
- package/lib/esm/utils/state-merge.js +37 -0
- package/lib/types/body/index.d.ts +14 -0
- package/lib/types/body/wrapper.d.ts +18 -0
- package/lib/types/cell/aggregated.d.ts +35 -0
- package/lib/types/cell/custom.d.ts +19 -0
- package/lib/types/cell/dependency.d.ts +47 -0
- package/lib/types/cell/editing.d.ts +8 -0
- package/lib/types/cell/footer.d.ts +5 -0
- package/lib/types/cell/header.d.ts +5 -0
- package/lib/types/cell/index.d.ts +6 -0
- package/lib/types/const.d.ts +11 -0
- package/lib/types/container/base.d.ts +2 -0
- package/lib/types/container/bottom.d.ts +20 -0
- package/lib/types/container/col-group.d.ts +11 -0
- package/lib/types/container/column-virtual.d.ts +7 -0
- package/lib/types/container/ctx.d.ts +23 -0
- package/lib/types/container/full-virtual.d.ts +8 -0
- package/lib/types/container/hooks.d.ts +13 -0
- package/lib/types/container/index.d.ts +17 -0
- package/lib/types/container/row-virtual.d.ts +7 -0
- package/lib/types/container/type.d.ts +17 -0
- package/lib/types/container/wrapper.d.ts +12 -0
- package/lib/types/ctx.d.ts +41 -0
- package/lib/types/features/_overrides/aggregated.d.ts +2 -0
- package/lib/types/features/_overrides/getter.d.ts +2 -0
- package/lib/types/features/_overrides/grouping.d.ts +7 -0
- package/lib/types/features/_overrides/index.d.ts +5 -0
- package/lib/types/features/_overrides/overrides.d.ts +2 -0
- package/lib/types/features/_overrides/row-selection.d.ts +2 -0
- package/lib/types/features/async-data/getter.d.ts +9 -0
- package/lib/types/features/async-data/group.d.ts +1 -0
- package/lib/types/features/async-data/index.d.ts +6 -0
- package/lib/types/features/async-data/normal.d.ts +48 -0
- package/lib/types/features/async-data/type.d.ts +22 -0
- package/lib/types/features/async-data/use-data-fetcher.d.ts +22 -0
- package/lib/types/features/async-data/use-reset-data.d.ts +14 -0
- package/lib/types/features/column-grouping/get-grouping-config.d.ts +2 -0
- package/lib/types/features/column-grouping/index.d.ts +3 -0
- package/lib/types/features/column-grouping/use-opts.d.ts +12 -0
- package/lib/types/features/column-state.d.ts +15 -0
- package/lib/types/features/filter/bridge.d.ts +9 -0
- package/lib/types/features/filter/filter-fns/date.d.ts +6 -0
- package/lib/types/features/filter/filter-fns/index.d.ts +6 -0
- package/lib/types/features/filter/get-filter-config.d.ts +4 -0
- package/lib/types/features/filter/index.d.ts +8 -0
- package/lib/types/features/filter/use-opts.d.ts +62 -0
- package/lib/types/features/header-actions/components/column-collapsing.d.ts +4 -0
- package/lib/types/features/header-actions/get-actions.d.ts +13 -0
- package/lib/types/features/header-actions/index.d.ts +3 -0
- package/lib/types/features/header-actions/type.d.ts +20 -0
- package/lib/types/features/pagination/component.d.ts +15 -0
- package/lib/types/features/pagination/index.d.ts +4 -0
- package/lib/types/features/pagination/use-opts.d.ts +14 -0
- package/lib/types/features/pagination/use-state.d.ts +11 -0
- package/lib/types/features/row-controller.d.ts +101 -0
- package/lib/types/features/row-edit/actions.d.ts +12 -0
- package/lib/types/features/row-edit/hooks.d.ts +1 -0
- package/lib/types/features/row-edit/index.d.ts +2 -0
- package/lib/types/features/row-expanding/index.d.ts +3 -0
- package/lib/types/features/row-expanding/use-opts.d.ts +12 -0
- package/lib/types/features/row-expanding/wrapper.d.ts +11 -0
- package/lib/types/features/row-operation/buttons.d.ts +41 -0
- package/lib/types/features/row-operation/cell.d.ts +6 -0
- package/lib/types/features/row-operation/index.d.ts +18 -0
- package/lib/types/features/row-operation/wrapper.d.ts +3 -0
- package/lib/types/features/row-selection/cell.d.ts +62 -0
- package/lib/types/features/row-selection/const.d.ts +1 -0
- package/lib/types/features/row-selection/hooks/index.d.ts +6 -0
- package/lib/types/features/row-selection/hooks/use-click-select.d.ts +1 -0
- package/lib/types/features/row-selection/hooks/use-opts.d.ts +15 -0
- package/lib/types/features/row-selection/hooks/use-set-selected-row-keys.d.ts +9 -0
- package/lib/types/features/row-selection/hooks/use-sync-hover-style.d.ts +5 -0
- package/lib/types/features/row-selection/index.d.ts +7 -0
- package/lib/types/features/row-selection/indicator.d.ts +8 -0
- package/lib/types/features/row-selection/wrapper.d.ts +9 -0
- package/lib/types/features/setting-bridge.d.ts +14 -0
- package/lib/types/features/sorter/bridge.d.ts +8 -0
- package/lib/types/features/sorter/get-sorter-config.d.ts +7 -0
- package/lib/types/features/sorter/index.d.ts +8 -0
- package/lib/types/features/sorter/use-opts.d.ts +71 -0
- package/lib/types/field-bridge/bridge.d.ts +18 -0
- package/lib/types/field-bridge/index.d.ts +11 -0
- package/lib/types/field-bridge/toolbar.d.ts +9 -0
- package/lib/types/footer/index.d.ts +6 -0
- package/lib/types/footer/use-first-cell-patch.d.ts +1 -0
- package/lib/types/header/index.d.ts +17 -0
- package/lib/types/header/validate.d.ts +10 -0
- package/lib/types/hooks/use-get-fields-value.d.ts +14 -0
- package/lib/types/hooks/use-global-actions.d.ts +24 -0
- package/lib/types/hooks/use-global-static.d.ts +83 -0
- package/lib/types/hooks/use-initial-render.d.ts +1 -0
- package/lib/types/hooks/use-inner-ctx.d.ts +12 -0
- package/lib/types/hooks/use-props.d.ts +109 -0
- package/lib/types/hooks/use-table-columns.d.ts +11 -0
- package/lib/types/hooks/use-table-meta.d.ts +15 -0
- package/lib/types/hooks/use-update.d.ts +11 -0
- package/lib/types/index.d.ts +32 -0
- package/lib/types/table.d.ts +152 -0
- package/lib/types/utils/cls.d.ts +4 -0
- package/lib/types/utils/fixed.d.ts +11 -0
- package/lib/types/utils/grouping.d.ts +6 -0
- package/lib/types/utils/index.d.ts +5 -0
- package/lib/types/utils/meta.d.ts +8 -0
- package/lib/types/utils/state-merge.d.ts +14 -0
- package/package.json +90 -0
- package/type.d.ts +143 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var tslib = require('tslib');
|
|
17
|
+
var React = require('react');
|
|
18
|
+
var lodashEs = require('lodash-es');
|
|
19
|
+
var schemaFields = require('@hi-ui/schema-fields');
|
|
20
|
+
var useSubscription = require('@hi-ui/use-subscription');
|
|
21
|
+
var _const = require('../const.js');
|
|
22
|
+
var ctx = require('../ctx.js');
|
|
23
|
+
var hooks = require('../features/row-edit/hooks.js');
|
|
24
|
+
require('@hi-ui/button');
|
|
25
|
+
var editing = require('./editing.js');
|
|
26
|
+
var dependency = require('./dependency.js');
|
|
27
|
+
require('@hi-ui/ellipsis-tooltip');
|
|
28
|
+
require('../utils/cls.js');
|
|
29
|
+
require('@tanstack/react-table');
|
|
30
|
+
require('@hi-ui/schema-utils');
|
|
31
|
+
require('@hi-ui/schema-table-extensions');
|
|
32
|
+
require('@hi-ui/tag');
|
|
33
|
+
function _interopDefaultCompat(e) {
|
|
34
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
35
|
+
'default': e
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
39
|
+
var EditableCell = /*#__PURE__*/React__default["default"].memo(function EditableCellCore(props) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
var field = (_a = props.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.field;
|
|
42
|
+
var formBinding = editing.useEditingCellFormBinding(props);
|
|
43
|
+
var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
|
|
44
|
+
tableValue = _useEditableSchemaTab.subscription,
|
|
45
|
+
globalStaticRef = _useEditableSchemaTab.globalStaticRef;
|
|
46
|
+
var enableRowEdit = globalStaticRef.current.enableRowEdit;
|
|
47
|
+
var rowIndex = props.row.index;
|
|
48
|
+
var dataKey = props.column.id;
|
|
49
|
+
var rowData = tableValue.getValue()[rowIndex];
|
|
50
|
+
var fieldDeps = (((_b = field === null || field === void 0 ? void 0 : field.dependency) === null || _b === void 0 ? void 0 : _b.deps) || []).map(function (dep) {
|
|
51
|
+
return [rowIndex, dep];
|
|
52
|
+
});
|
|
53
|
+
var _c = useSubscription.useSubscribeList(tableValue, [[rowIndex, dataKey]].concat(fieldDeps), {
|
|
54
|
+
// 此处单元格全部可编辑,全部创建监听
|
|
55
|
+
skipSubscribe: false,
|
|
56
|
+
// 行编辑模式下,从 draft 中获取值
|
|
57
|
+
getFieldValueFromDraft: enableRowEdit
|
|
58
|
+
}),
|
|
59
|
+
fieldValue = _c.fieldValue,
|
|
60
|
+
changedDepValues = _c.changedDepValues,
|
|
61
|
+
rest = tslib.__rest(_c, ["fieldValue", "changedDepValues"]);
|
|
62
|
+
if (!field) return null;
|
|
63
|
+
formBinding.value = fieldValue;
|
|
64
|
+
var nextField = Object.assign(Object.assign({}, field), {
|
|
65
|
+
payload: Object.assign(Object.assign({}, field.payload), {
|
|
66
|
+
setSelectedRawOption: function setSelectedRawOption(values) {
|
|
67
|
+
var _a;
|
|
68
|
+
if (enableRowEdit) {
|
|
69
|
+
var _Object$assign, _rowIndex, _tableValue$mergeDraf;
|
|
70
|
+
// 行编辑模式:需要获取最新的 draft 数据
|
|
71
|
+
var draftRowData = ((_a = tableValue.getDraft()) === null || _a === void 0 ? void 0 : _a[rowIndex]) || {};
|
|
72
|
+
var currentData = draftRowData[_const.SELECTED_OPTION_RAW] || {};
|
|
73
|
+
var updatedData = Object.assign(Object.assign({}, currentData), (_Object$assign = {}, _Object$assign[dataKey] = values, _Object$assign));
|
|
74
|
+
tableValue.mergeDraft((_tableValue$mergeDraf = {}, _tableValue$mergeDraf[rowIndex] = (_rowIndex = {}, _rowIndex[_const.SELECTED_OPTION_RAW] = updatedData, _rowIndex), _tableValue$mergeDraf));
|
|
75
|
+
} else {
|
|
76
|
+
var _Object$assign2, _rowIndex2, _tableValue$mergeSile;
|
|
77
|
+
// 普通模式:从当前 rowData 获取数据
|
|
78
|
+
var _currentData = rowData[_const.SELECTED_OPTION_RAW] || {};
|
|
79
|
+
var _updatedData = Object.assign(Object.assign({}, _currentData), (_Object$assign2 = {}, _Object$assign2[dataKey] = values, _Object$assign2));
|
|
80
|
+
tableValue.mergeSilently((_tableValue$mergeSile = {}, _tableValue$mergeSile[rowIndex] = (_rowIndex2 = {}, _rowIndex2[_const.SELECTED_OPTION_RAW] = _updatedData, _rowIndex2), _tableValue$mergeSile));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
var fieldProps = {
|
|
86
|
+
value: fieldValue,
|
|
87
|
+
field: nextField,
|
|
88
|
+
FieldClass: props.FieldClass,
|
|
89
|
+
ctx: {
|
|
90
|
+
field: nextField,
|
|
91
|
+
rowData: rowData,
|
|
92
|
+
rawData: rowData,
|
|
93
|
+
formBinding: formBinding,
|
|
94
|
+
rowIndex: rowIndex,
|
|
95
|
+
dataKey: dataKey,
|
|
96
|
+
formRef: {
|
|
97
|
+
current: null
|
|
98
|
+
} // TODO 待补充实现
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
// 行编辑模式下,失焦时保持激活状态
|
|
102
|
+
keepActiveOnBlur: enableRowEdit,
|
|
103
|
+
defaultActive: props.defaultActive
|
|
104
|
+
};
|
|
105
|
+
dependency.execCellDepsProcess({
|
|
106
|
+
fieldProps: fieldProps,
|
|
107
|
+
rowData: rowData,
|
|
108
|
+
rowIndex: rowIndex,
|
|
109
|
+
dataKey: dataKey,
|
|
110
|
+
changedDepValues: changedDepValues,
|
|
111
|
+
changedFieldNames: rest.changedFieldNames,
|
|
112
|
+
tableValue: tableValue
|
|
113
|
+
});
|
|
114
|
+
return /*#__PURE__*/React__default["default"].createElement(schemaFields.EditableCase, Object.assign({}, fieldProps));
|
|
115
|
+
}, function (prev, next) {
|
|
116
|
+
var _a;
|
|
117
|
+
// 如果 column 配置要求总是更新,则返回 false 触发重渲染
|
|
118
|
+
if ((_a = prev.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.shouldUpdate) return false;
|
|
119
|
+
// 如果 defaultActive 为 true,则直接重渲染
|
|
120
|
+
// TODO 此处仍有BUG,会在行交换时触发
|
|
121
|
+
// 暂时记录,待后续优化
|
|
122
|
+
if (prev.defaultActive) return false;
|
|
123
|
+
// NOTE Cell 暂时始终打开值比较 待补充其他case
|
|
124
|
+
// 其余时候比较关键数据是否相等
|
|
125
|
+
return lodashEs.isEqual(prev.getValue(), next.getValue());
|
|
126
|
+
});
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
128
|
+
// @ts-ignore 关闭 displayName 检查
|
|
129
|
+
EditableCell.displayName = 'EditableCell';
|
|
130
|
+
var CustomCell = /*#__PURE__*/React__default["default"].memo(
|
|
131
|
+
// CustomCell 中的 Custom 是指包含自定义渲染
|
|
132
|
+
function CustomCellCore(props) {
|
|
133
|
+
var _a, _b, _c, _d;
|
|
134
|
+
var field = (_a = props.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.field;
|
|
135
|
+
var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
|
|
136
|
+
tableValue = _useEditableSchemaTab2.subscription,
|
|
137
|
+
propsRef = _useEditableSchemaTab2.propsRef;
|
|
138
|
+
var FieldClass = schemaFields.useMatchFieldClass({
|
|
139
|
+
name: 'TableCellWrapper',
|
|
140
|
+
field: field,
|
|
141
|
+
fieldMap: (_b = props.table.options.meta) === null || _b === void 0 ? void 0 : _b.fieldMap
|
|
142
|
+
});
|
|
143
|
+
// 行编辑状态变更时会触发组件重渲染
|
|
144
|
+
var runtimeEditable = hooks.useRuntimeRowEditable(props.row.index);
|
|
145
|
+
var selfReadonly = schemaFields.useReadonly(field, runtimeEditable);
|
|
146
|
+
var readonly = !schemaFields.runDynamicEditable(field, selfReadonly, function () {
|
|
147
|
+
return {
|
|
148
|
+
type: 'edit-table',
|
|
149
|
+
rowIndex: props.row.index,
|
|
150
|
+
rowId: props.row.id,
|
|
151
|
+
columnIndex: props.column.getIndex(),
|
|
152
|
+
columnId: props.column.id,
|
|
153
|
+
rawData: props.row.$getRealtimeRowData()
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
// 2. 只读状态使用 ReadonlyCase
|
|
157
|
+
if (readonly) {
|
|
158
|
+
var dataKey = props.column.id;
|
|
159
|
+
var rowIndex = props.row.index;
|
|
160
|
+
var rowData = tableValue.getValue()[rowIndex];
|
|
161
|
+
var value = (_d = (_c = props.table.options.meta) === null || _c === void 0 ? void 0 : _c.getCellValue(rowIndex, dataKey)) !== null && _d !== void 0 ? _d : props.getValue();
|
|
162
|
+
return /*#__PURE__*/React__default["default"].createElement(schemaFields.ReadonlyCase, {
|
|
163
|
+
usedBy: "table",
|
|
164
|
+
value: value,
|
|
165
|
+
field: field,
|
|
166
|
+
FieldClass: FieldClass,
|
|
167
|
+
ctx: {
|
|
168
|
+
field: field,
|
|
169
|
+
rowData: rowData,
|
|
170
|
+
rawData: rowData,
|
|
171
|
+
rowIndex: rowIndex,
|
|
172
|
+
dataKey: dataKey
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// 3. 可编辑状态使用 MemoCell
|
|
177
|
+
return /*#__PURE__*/React__default["default"].createElement(EditableCell, Object.assign({}, props, {
|
|
178
|
+
FieldClass: FieldClass,
|
|
179
|
+
defaultActive: propsRef.current.defaultActive
|
|
180
|
+
}));
|
|
181
|
+
});
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
183
|
+
// @ts-ignore 关闭 displayName 检查
|
|
184
|
+
CustomCell.displayName = 'CustomCell';
|
|
185
|
+
// NOTE 此处之所以要分为 DftCell -> CustomCell -> EditableCell 三层,是因为需要区分出【简单】【只读】【可编辑】的字段
|
|
186
|
+
// 【简单】字段:无自定义渲染,无依赖,无表单绑定,无监听,只有最单纯的 DOM 渲染
|
|
187
|
+
// 【只读】字段:有自定义渲染,无依赖,无表单绑定,无监听 // TODO 后续只读部分可能会需要支持deps
|
|
188
|
+
// 【可编辑】字段:有自定义渲染,有依赖,有控制,有表单绑定,有监听
|
|
189
|
+
function DftCell(props) {
|
|
190
|
+
var _a;
|
|
191
|
+
var field = (_a = props.column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.field;
|
|
192
|
+
if (!field) {
|
|
193
|
+
// 此处拦截,必须有 field 配置,否则报错
|
|
194
|
+
throw new Error('DftCell: field is required');
|
|
195
|
+
}
|
|
196
|
+
// 1. 简单字段且无自定义渲染,使用 SimpleCase
|
|
197
|
+
if (schemaFields.isSimpleCase(field)) {
|
|
198
|
+
return /*#__PURE__*/React__default["default"].createElement(schemaFields.SimpleCase, {
|
|
199
|
+
value: props.getValue()
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return /*#__PURE__*/React__default["default"].createElement(CustomCell, Object.assign({}, props));
|
|
203
|
+
}
|
|
204
|
+
exports["default"] = DftCell;
|
package/lib/cjs/const.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
require('react');
|
|
16
|
+
require('lodash-es');
|
|
17
|
+
require('@tanstack/react-table');
|
|
18
|
+
require('ahooks');
|
|
19
|
+
var ROW_HEIGHT = 40;
|
|
20
|
+
var ROW_SELECTION_COL_WIDTH = 50;
|
|
21
|
+
var ROW_INDEX_COL_ID = '_row_index_';
|
|
22
|
+
var ROW_OPERATION_COL_WIDTH = 160;
|
|
23
|
+
function isSystemCol(id) {
|
|
24
|
+
return id === ROW_INDEX_COL_ID;
|
|
25
|
+
}
|
|
26
|
+
// 分组特性中用于标识空值的特殊标记
|
|
27
|
+
var EMPTY_VALUE = '__EMPTY_VALUE__';
|
|
28
|
+
var SELECTED_OPTION_RAW = '_selected_raw_option_';
|
|
29
|
+
exports.EMPTY_VALUE = EMPTY_VALUE;
|
|
30
|
+
exports.ROW_HEIGHT = ROW_HEIGHT;
|
|
31
|
+
exports.ROW_INDEX_COL_ID = ROW_INDEX_COL_ID;
|
|
32
|
+
exports.ROW_OPERATION_COL_WIDTH = ROW_OPERATION_COL_WIDTH;
|
|
33
|
+
exports.ROW_SELECTION_COL_WIDTH = ROW_SELECTION_COL_WIDTH;
|
|
34
|
+
exports.SELECTED_OPTION_RAW = SELECTED_OPTION_RAW;
|
|
35
|
+
exports.isSystemCol = isSystemCol;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var ctx = require('./ctx.js');
|
|
18
|
+
var colGroup = require('./col-group.js');
|
|
19
|
+
function _interopDefaultCompat(e) {
|
|
20
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
21
|
+
'default': e
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
25
|
+
function NonVirtualContainer(props) {
|
|
26
|
+
var headerRef = React.useRef(null);
|
|
27
|
+
var bodyRef = React.useRef(null);
|
|
28
|
+
var footerRef = React.useRef(null);
|
|
29
|
+
var colGroup$1 = /*#__PURE__*/React__default["default"].createElement(colGroup.TableColGroup, null);
|
|
30
|
+
return /*#__PURE__*/React__default["default"].createElement(ctx.TableContainerContext.Provider, {
|
|
31
|
+
value: {
|
|
32
|
+
headerRef: headerRef,
|
|
33
|
+
bodyRef: bodyRef,
|
|
34
|
+
footerRef: footerRef,
|
|
35
|
+
colGroup: colGroup$1
|
|
36
|
+
}
|
|
37
|
+
}, props.children);
|
|
38
|
+
}
|
|
39
|
+
exports.NonVirtualContainer = NonVirtualContainer;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var schemaActionTrigger = require('@hi-ui/schema-action-trigger');
|
|
18
|
+
var schemaUtils = require('@hi-ui/schema-utils');
|
|
19
|
+
var ctx = require('../ctx.js');
|
|
20
|
+
var component = require('../features/pagination/component.js');
|
|
21
|
+
require('@hi-ui/use-subscription');
|
|
22
|
+
require('lodash-es');
|
|
23
|
+
require('@tanstack/react-table');
|
|
24
|
+
require('ahooks');
|
|
25
|
+
var cls = require('../utils/cls.js');
|
|
26
|
+
require('./index.js');
|
|
27
|
+
require('@hi-ui/checkbox');
|
|
28
|
+
require('@hi-ui/radio');
|
|
29
|
+
var indicator = require('../features/row-selection/indicator.js');
|
|
30
|
+
function _interopDefaultCompat(e) {
|
|
31
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
32
|
+
'default': e
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
36
|
+
function BottomRender(props) {
|
|
37
|
+
var _a;
|
|
38
|
+
var tableCtx = ctx.useEditableSchemaTableCtx();
|
|
39
|
+
var propsRef = tableCtx.propsRef,
|
|
40
|
+
globalStaticRef = tableCtx.globalStaticRef;
|
|
41
|
+
var paginationEl = propsRef.current.pagination ? ( /*#__PURE__*/React__default["default"].createElement(component.Pagination, Object.assign({
|
|
42
|
+
key: "pagination"
|
|
43
|
+
}, propsRef.current.pagination))) : null;
|
|
44
|
+
var rowSelectionIndicatorEl = ((_a = propsRef.current.rowSelection) === null || _a === void 0 ? void 0 : _a.enableIndicator) ? ( /*#__PURE__*/React__default["default"].createElement(indicator.RowSelectionIndicator, {
|
|
45
|
+
key: "row-selection-indicator"
|
|
46
|
+
})) : null;
|
|
47
|
+
var builtin = {
|
|
48
|
+
rowSelectionIndicator: rowSelectionIndicatorEl,
|
|
49
|
+
pagination: paginationEl
|
|
50
|
+
};
|
|
51
|
+
var dftLeft = [rowSelectionIndicatorEl];
|
|
52
|
+
var dftRight = [paginationEl];
|
|
53
|
+
var getLeft = props.left,
|
|
54
|
+
getRight = props.right;
|
|
55
|
+
var ctx$1 = {
|
|
56
|
+
tableCtx: tableCtx,
|
|
57
|
+
builtin: builtin
|
|
58
|
+
};
|
|
59
|
+
var left = schemaUtils.getGetterValue(getLeft, dftLeft, [ctx$1]);
|
|
60
|
+
var right = schemaUtils.getGetterValue(getRight, dftRight, [ctx$1]);
|
|
61
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
62
|
+
className: cls.cls('bottom-container'),
|
|
63
|
+
"data-is-bottom-empty": globalStaticRef.current.isBottomEmpty
|
|
64
|
+
}, /*#__PURE__*/React__default["default"].createElement(schemaActionTrigger.Actions
|
|
65
|
+
// left
|
|
66
|
+
, {
|
|
67
|
+
// left
|
|
68
|
+
className: cls.cls('bottom-container-left'),
|
|
69
|
+
actions: left,
|
|
70
|
+
data: [],
|
|
71
|
+
ctx: {
|
|
72
|
+
tableCtx: tableCtx
|
|
73
|
+
}
|
|
74
|
+
}), /*#__PURE__*/React__default["default"].createElement(schemaActionTrigger.Actions
|
|
75
|
+
// right
|
|
76
|
+
, {
|
|
77
|
+
// right
|
|
78
|
+
className: cls.cls('bottom-container-right'),
|
|
79
|
+
actions: right,
|
|
80
|
+
data: [],
|
|
81
|
+
ctx: {
|
|
82
|
+
tableCtx: tableCtx
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
exports.BottomRender = BottomRender;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var ctx = require('../ctx.js');
|
|
18
|
+
var _const = require('../const.js');
|
|
19
|
+
var index = require('../header/index.js');
|
|
20
|
+
function _interopDefaultCompat(e) {
|
|
21
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
22
|
+
'default': e
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
26
|
+
|
|
27
|
+
// 基础 ColGroup
|
|
28
|
+
function TableColGroup() {
|
|
29
|
+
var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
|
|
30
|
+
table = _useEditableSchemaTab.table;
|
|
31
|
+
return /*#__PURE__*/React__default["default"].createElement("colgroup", null, table.getVisibleLeafColumns().map(function (column) {
|
|
32
|
+
return /*#__PURE__*/React__default["default"].createElement(Col, {
|
|
33
|
+
key: column.id,
|
|
34
|
+
column: column
|
|
35
|
+
});
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
// 虚拟化 ColGroup
|
|
39
|
+
function VirtualColGroup(_ref) {
|
|
40
|
+
var virtualColumns = _ref.virtualColumns,
|
|
41
|
+
virtualColPadding = _ref.virtualColPadding;
|
|
42
|
+
var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
|
|
43
|
+
table = _useEditableSchemaTab2.table;
|
|
44
|
+
var headerGroups = table.getHeaderGroups();
|
|
45
|
+
var lastHeaderGroup = headerGroups[headerGroups.length - 1];
|
|
46
|
+
var realHeaders = lastHeaderGroup.headers;
|
|
47
|
+
var _groupHeaders = index.groupHeaders(realHeaders, table),
|
|
48
|
+
leftHeaders = _groupHeaders.left,
|
|
49
|
+
rightHeaders = _groupHeaders.right;
|
|
50
|
+
return /*#__PURE__*/React__default["default"].createElement("colgroup", null, leftHeaders.map(function (_ref2) {
|
|
51
|
+
var column = _ref2.column;
|
|
52
|
+
return /*#__PURE__*/React__default["default"].createElement(Col, {
|
|
53
|
+
key: column.id,
|
|
54
|
+
column: column
|
|
55
|
+
});
|
|
56
|
+
}), virtualColPadding.start > 0 && /*#__PURE__*/React__default["default"].createElement("col", {
|
|
57
|
+
style: {
|
|
58
|
+
width: virtualColPadding.start
|
|
59
|
+
}
|
|
60
|
+
}), virtualColumns.map(function (vc) {
|
|
61
|
+
var column = realHeaders[vc.index].column;
|
|
62
|
+
// 固定列不参与中间部分渲染
|
|
63
|
+
if (column.getIsPinned()) return null;
|
|
64
|
+
return /*#__PURE__*/React__default["default"].createElement(Col, {
|
|
65
|
+
key: column.id,
|
|
66
|
+
column: column
|
|
67
|
+
});
|
|
68
|
+
}), virtualColPadding.end > 0 && /*#__PURE__*/React__default["default"].createElement("col", {
|
|
69
|
+
style: {
|
|
70
|
+
width: virtualColPadding.end
|
|
71
|
+
}
|
|
72
|
+
}), rightHeaders.map(function (_ref3) {
|
|
73
|
+
var column = _ref3.column;
|
|
74
|
+
return /*#__PURE__*/React__default["default"].createElement(Col, {
|
|
75
|
+
key: column.id,
|
|
76
|
+
column: column
|
|
77
|
+
});
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
function Col(props) {
|
|
81
|
+
var column = props.column;
|
|
82
|
+
var colWidth = column.getSize();
|
|
83
|
+
// 系统字段列使用固定宽度,其他列使用最小宽度+自动列宽
|
|
84
|
+
// 自动列宽分配是指:表格宽度超过所有列宽之和时,自动分配剩余宽度
|
|
85
|
+
// NOTE 预期如上述描述所示,但实测这样写系统字段还是会参与自动列宽分配
|
|
86
|
+
var maxWidth = _const.isSystemCol(column.id) ? colWidth : undefined;
|
|
87
|
+
return /*#__PURE__*/React__default["default"].createElement("col", {
|
|
88
|
+
key: column.id,
|
|
89
|
+
"data-id": column.id,
|
|
90
|
+
style: {
|
|
91
|
+
width: colWidth,
|
|
92
|
+
minWidth: colWidth,
|
|
93
|
+
maxWidth: maxWidth
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
exports.TableColGroup = TableColGroup;
|
|
98
|
+
exports.VirtualColGroup = VirtualColGroup;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var ctx = require('./ctx.js');
|
|
18
|
+
var hooks = require('./hooks.js');
|
|
19
|
+
var colGroup = require('./col-group.js');
|
|
20
|
+
function _interopDefaultCompat(e) {
|
|
21
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
22
|
+
'default': e
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
26
|
+
function ColumnVirtualContainer(props) {
|
|
27
|
+
var headerRef = React.useRef(null);
|
|
28
|
+
var bodyRef = React.useRef(null);
|
|
29
|
+
var footerRef = React.useRef(null);
|
|
30
|
+
var _useColumnVirtualizer = hooks.useColumnVirtualizer(props.options),
|
|
31
|
+
columns = _useColumnVirtualizer.virtualItems,
|
|
32
|
+
colPadding = _useColumnVirtualizer.padding;
|
|
33
|
+
var colGroup$1 = /*#__PURE__*/React__default["default"].createElement(colGroup.VirtualColGroup, {
|
|
34
|
+
virtualColumns: columns,
|
|
35
|
+
virtualColPadding: colPadding
|
|
36
|
+
});
|
|
37
|
+
return /*#__PURE__*/React__default["default"].createElement(ctx.TableContainerContext.Provider, {
|
|
38
|
+
value: {
|
|
39
|
+
headerRef: headerRef,
|
|
40
|
+
bodyRef: bodyRef,
|
|
41
|
+
footerRef: footerRef,
|
|
42
|
+
colGroup: colGroup$1,
|
|
43
|
+
virtualize: {
|
|
44
|
+
columns: columns,
|
|
45
|
+
colPadding: {
|
|
46
|
+
left: colPadding.start,
|
|
47
|
+
right: colPadding.end
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, props.children);
|
|
52
|
+
}
|
|
53
|
+
exports.ColumnVirtualContainer = ColumnVirtualContainer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
function _interopDefaultCompat(e) {
|
|
18
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
19
|
+
'default': e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
23
|
+
var TableContainerContext = /*#__PURE__*/React__default["default"].createContext(null);
|
|
24
|
+
function useTableContainer() {
|
|
25
|
+
var context = React__default["default"].useContext(TableContainerContext);
|
|
26
|
+
if (!context) {
|
|
27
|
+
throw new Error('Table.* component must be rendered as child of Table component');
|
|
28
|
+
}
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
exports.TableContainerContext = TableContainerContext;
|
|
32
|
+
exports.useTableContainer = useTableContainer;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/schema-editable-table
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/schema/schema-editable-table#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HiUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
13
|
+
Object.defineProperty(exports, '__esModule', {
|
|
14
|
+
value: true
|
|
15
|
+
});
|
|
16
|
+
var React = require('react');
|
|
17
|
+
var ctx = require('./ctx.js');
|
|
18
|
+
var hooks = require('./hooks.js');
|
|
19
|
+
var colGroup = require('./col-group.js');
|
|
20
|
+
function _interopDefaultCompat(e) {
|
|
21
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
22
|
+
'default': e
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
26
|
+
function FullVirtualContainer(props) {
|
|
27
|
+
var headerRef = React.useRef(null);
|
|
28
|
+
var bodyRef = React.useRef(null);
|
|
29
|
+
var footerRef = React.useRef(null);
|
|
30
|
+
var _useRowVirtualizer = hooks.useRowVirtualizer(props.rowOptions),
|
|
31
|
+
rows = _useRowVirtualizer.virtualItems,
|
|
32
|
+
rowPadding = _useRowVirtualizer.padding;
|
|
33
|
+
var _useColumnVirtualizer = hooks.useColumnVirtualizer(props.columnOptions),
|
|
34
|
+
columns = _useColumnVirtualizer.virtualItems,
|
|
35
|
+
colPadding = _useColumnVirtualizer.padding;
|
|
36
|
+
var colGroup$1 = /*#__PURE__*/React__default["default"].createElement(colGroup.VirtualColGroup, {
|
|
37
|
+
virtualColumns: columns,
|
|
38
|
+
virtualColPadding: colPadding
|
|
39
|
+
});
|
|
40
|
+
return /*#__PURE__*/React__default["default"].createElement(ctx.TableContainerContext.Provider, {
|
|
41
|
+
value: {
|
|
42
|
+
headerRef: headerRef,
|
|
43
|
+
bodyRef: bodyRef,
|
|
44
|
+
footerRef: footerRef,
|
|
45
|
+
colGroup: colGroup$1,
|
|
46
|
+
virtualize: {
|
|
47
|
+
rows: rows,
|
|
48
|
+
columns: columns,
|
|
49
|
+
rowPadding: {
|
|
50
|
+
top: rowPadding.start,
|
|
51
|
+
bottom: rowPadding.end
|
|
52
|
+
},
|
|
53
|
+
colPadding: {
|
|
54
|
+
left: colPadding.start,
|
|
55
|
+
right: colPadding.end
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, props.children);
|
|
60
|
+
}
|
|
61
|
+
exports.FullVirtualContainer = FullVirtualContainer;
|