@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,102 @@
|
|
|
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
|
+
var React = require('react');
|
|
16
|
+
var reactVirtual = require('@tanstack/react-virtual');
|
|
17
|
+
var ctx = require('../ctx.js');
|
|
18
|
+
var _const = require('../const.js');
|
|
19
|
+
function useRowVirtualizer(options) {
|
|
20
|
+
var _useEditableSchemaTab = ctx.useEditableSchemaTableCtx(),
|
|
21
|
+
table = _useEditableSchemaTab.table,
|
|
22
|
+
tableContainerRef = _useEditableSchemaTab.tableContainerRef;
|
|
23
|
+
var virtualizer = reactVirtual.useVirtualizer(Object.assign({
|
|
24
|
+
count: table.getRowModel().rows.length,
|
|
25
|
+
getScrollElement: function getScrollElement() {
|
|
26
|
+
return tableContainerRef.current;
|
|
27
|
+
},
|
|
28
|
+
estimateSize: function estimateSize() {
|
|
29
|
+
return _const.ROW_HEIGHT;
|
|
30
|
+
},
|
|
31
|
+
overscan: 5
|
|
32
|
+
}, options));
|
|
33
|
+
var virtualItems = virtualizer.getVirtualItems();
|
|
34
|
+
var padding = !virtualItems.length ? {
|
|
35
|
+
start: 0,
|
|
36
|
+
end: 0
|
|
37
|
+
} : {
|
|
38
|
+
start: virtualItems[0].start,
|
|
39
|
+
end: virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
virtualItems: virtualItems,
|
|
43
|
+
padding: padding
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function useColumnVirtualizer(options) {
|
|
47
|
+
var _useEditableSchemaTab2 = ctx.useEditableSchemaTableCtx(),
|
|
48
|
+
table = _useEditableSchemaTab2.table,
|
|
49
|
+
tableContainerRef = _useEditableSchemaTab2.tableContainerRef;
|
|
50
|
+
var virtualizer = reactVirtual.useVirtualizer(Object.assign({
|
|
51
|
+
count: table.getVisibleLeafColumns().length,
|
|
52
|
+
getScrollElement: function getScrollElement() {
|
|
53
|
+
return tableContainerRef.current;
|
|
54
|
+
},
|
|
55
|
+
estimateSize: function estimateSize(index) {
|
|
56
|
+
return table.getVisibleLeafColumns()[index].getSize();
|
|
57
|
+
},
|
|
58
|
+
horizontal: true,
|
|
59
|
+
overscan: 3
|
|
60
|
+
}, options));
|
|
61
|
+
var virtualItems = virtualizer.getVirtualItems();
|
|
62
|
+
var padding = !virtualItems.length ? {
|
|
63
|
+
start: 0,
|
|
64
|
+
end: 0
|
|
65
|
+
} : {
|
|
66
|
+
start: virtualItems[0].start,
|
|
67
|
+
end: virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
virtualItems: virtualItems,
|
|
71
|
+
padding: padding
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function useTableScroll() {
|
|
75
|
+
var _useEditableSchemaTab3 = ctx.useEditableSchemaTableCtx(),
|
|
76
|
+
tableContainerRef = _useEditableSchemaTab3.tableContainerRef;
|
|
77
|
+
React.useEffect(function () {
|
|
78
|
+
var container = tableContainerRef.current;
|
|
79
|
+
if (!container) return;
|
|
80
|
+
var handleScroll = function handleScroll() {
|
|
81
|
+
var scrollLeft = container.scrollLeft,
|
|
82
|
+
scrollWidth = container.scrollWidth,
|
|
83
|
+
clientWidth = container.clientWidth;
|
|
84
|
+
// 左侧是否有可滚动空间
|
|
85
|
+
var hasLeftSpace = scrollLeft > 0;
|
|
86
|
+
// 右侧是否有可滚动空间
|
|
87
|
+
var hasRightSpace = Math.abs(scrollWidth - clientWidth - scrollLeft) > 1;
|
|
88
|
+
// 根据两侧是否有可滚动空间来切换对应的类名
|
|
89
|
+
container.classList.toggle('editable-schema-table--scrolling-right', hasLeftSpace);
|
|
90
|
+
container.classList.toggle('editable-schema-table--scrolling-left', hasRightSpace);
|
|
91
|
+
};
|
|
92
|
+
container.addEventListener('scroll', handleScroll);
|
|
93
|
+
// 初始化时触发一次
|
|
94
|
+
handleScroll();
|
|
95
|
+
return function () {
|
|
96
|
+
container.removeEventListener('scroll', handleScroll);
|
|
97
|
+
};
|
|
98
|
+
}, [tableContainerRef]);
|
|
99
|
+
}
|
|
100
|
+
exports.useColumnVirtualizer = useColumnVirtualizer;
|
|
101
|
+
exports.useRowVirtualizer = useRowVirtualizer;
|
|
102
|
+
exports.useTableScroll = useTableScroll;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 useInitialRender = require('../hooks/use-initial-render.js');
|
|
18
|
+
var base = require('./base.js');
|
|
19
|
+
var rowVirtual = require('./row-virtual.js');
|
|
20
|
+
var columnVirtual = require('./column-virtual.js');
|
|
21
|
+
var fullVirtual = require('./full-virtual.js');
|
|
22
|
+
var wrapper = require('./wrapper.js');
|
|
23
|
+
var hooks = require('./hooks.js');
|
|
24
|
+
require('@hi-ui/schema-action-trigger');
|
|
25
|
+
require('@hi-ui/schema-utils');
|
|
26
|
+
require('@hi-ui/pagination');
|
|
27
|
+
require('@hi-ui/use-subscription');
|
|
28
|
+
require('lodash-es');
|
|
29
|
+
require('@tanstack/react-table');
|
|
30
|
+
require('ahooks');
|
|
31
|
+
require('../utils/cls.js');
|
|
32
|
+
require('@hi-ui/checkbox');
|
|
33
|
+
require('@hi-ui/radio');
|
|
34
|
+
require('@hi-ui/space');
|
|
35
|
+
require('@hi-ui/switch');
|
|
36
|
+
function _interopDefaultCompat(e) {
|
|
37
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
38
|
+
'default': e
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
42
|
+
function TableContainer(props) {
|
|
43
|
+
var virtualizeConfig = props.virtualize;
|
|
44
|
+
useInitialRender.useInitialRender(); // 初次渲染时容器组件尚未加载,导致白屏,因此在组件挂在后强制更新一次
|
|
45
|
+
hooks.useTableScroll(); // 滚动时给容器增加类名,用于控制阴影效果
|
|
46
|
+
// 根据配置选择合适的容器
|
|
47
|
+
if ((virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.row) && (virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.column)) {
|
|
48
|
+
return /*#__PURE__*/React__default["default"].createElement(fullVirtual.FullVirtualContainer, {
|
|
49
|
+
rowOptions: virtualizeConfig.row,
|
|
50
|
+
columnOptions: virtualizeConfig.column
|
|
51
|
+
}, props.children);
|
|
52
|
+
}
|
|
53
|
+
if (virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.row) {
|
|
54
|
+
return /*#__PURE__*/React__default["default"].createElement(rowVirtual.RowVirtualContainer, {
|
|
55
|
+
options: virtualizeConfig.row
|
|
56
|
+
}, props.children);
|
|
57
|
+
}
|
|
58
|
+
if (virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.column) {
|
|
59
|
+
return /*#__PURE__*/React__default["default"].createElement(columnVirtual.ColumnVirtualContainer, {
|
|
60
|
+
options: virtualizeConfig.column
|
|
61
|
+
}, props.children);
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/React__default["default"].createElement(base.NonVirtualContainer, null, props.children);
|
|
64
|
+
}
|
|
65
|
+
// 导出组件
|
|
66
|
+
TableContainer.Header = wrapper.TableHeader;
|
|
67
|
+
TableContainer.Body = wrapper.TableBody;
|
|
68
|
+
TableContainer.Footer = wrapper.TableFooter;
|
|
69
|
+
exports.TableContainer = TableContainer;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 RowVirtualContainer(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.options),
|
|
31
|
+
rows = _useRowVirtualizer.virtualItems,
|
|
32
|
+
rowPadding = _useRowVirtualizer.padding;
|
|
33
|
+
var colGroup$1 = /*#__PURE__*/React__default["default"].createElement(colGroup.TableColGroup, null);
|
|
34
|
+
return /*#__PURE__*/React__default["default"].createElement(ctx.TableContainerContext.Provider, {
|
|
35
|
+
value: {
|
|
36
|
+
headerRef: headerRef,
|
|
37
|
+
bodyRef: bodyRef,
|
|
38
|
+
footerRef: footerRef,
|
|
39
|
+
colGroup: colGroup$1,
|
|
40
|
+
virtualize: {
|
|
41
|
+
rows: rows,
|
|
42
|
+
rowPadding: {
|
|
43
|
+
top: rowPadding.start,
|
|
44
|
+
bottom: rowPadding.end
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}, props.children);
|
|
49
|
+
}
|
|
50
|
+
exports.RowVirtualContainer = RowVirtualContainer;
|
|
@@ -0,0 +1,97 @@
|
|
|
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 schemaTableExtensions = require('@hi-ui/schema-table-extensions');
|
|
19
|
+
var ctx$1 = require('../ctx.js');
|
|
20
|
+
var wrapper = require('../features/row-selection/wrapper.js');
|
|
21
|
+
var index = require('../features/row-operation/index.js');
|
|
22
|
+
var cls = require('../utils/cls.js');
|
|
23
|
+
var ctx = require('./ctx.js');
|
|
24
|
+
function _interopDefaultCompat(e) {
|
|
25
|
+
return e && _typeof(e) === 'object' && 'default' in e ? e : {
|
|
26
|
+
'default': e
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
30
|
+
function TableHeader(_ref) {
|
|
31
|
+
var children = _ref.children,
|
|
32
|
+
sticky = _ref.sticky,
|
|
33
|
+
stickyOffset = _ref.stickyOffset;
|
|
34
|
+
var _a = ctx.useTableContainer(),
|
|
35
|
+
headerRef = _a.headerRef,
|
|
36
|
+
rest = tslib.__rest(_a, ["headerRef"]);
|
|
37
|
+
var _useEditableSchemaTab = ctx$1.useEditableSchemaTableCtx().propsRef.current,
|
|
38
|
+
rowSelection = _useEditableSchemaTab.rowSelection,
|
|
39
|
+
rowOperation = _useEditableSchemaTab.rowOperation;
|
|
40
|
+
var className = cls.cls('header-wrapper', {
|
|
41
|
+
'header-wrapper--sticky': sticky
|
|
42
|
+
});
|
|
43
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
44
|
+
ref: headerRef,
|
|
45
|
+
className: className,
|
|
46
|
+
style: sticky && stickyOffset !== undefined ? {
|
|
47
|
+
top: stickyOffset
|
|
48
|
+
} : undefined
|
|
49
|
+
}, rowSelection ? /*#__PURE__*/React__default["default"].createElement(wrapper.RowSelection.Header, null) : null, /*#__PURE__*/React__default["default"].createElement("table", {
|
|
50
|
+
className: cls.cls('main-content')
|
|
51
|
+
}, rest.colGroup, children), rowOperation ? /*#__PURE__*/React__default["default"].createElement(index.RowOperation.Header, null) : null);
|
|
52
|
+
}
|
|
53
|
+
function TableBody(props) {
|
|
54
|
+
var _a = ctx.useTableContainer(),
|
|
55
|
+
bodyRef = _a.bodyRef,
|
|
56
|
+
rest = tslib.__rest(_a, ["bodyRef"]);
|
|
57
|
+
var _useEditableSchemaTab2 = ctx$1.useEditableSchemaTableCtx(),
|
|
58
|
+
propsRef = _useEditableSchemaTab2.propsRef,
|
|
59
|
+
globalStaticRef = _useEditableSchemaTab2.globalStaticRef;
|
|
60
|
+
var _propsRef$current = propsRef.current,
|
|
61
|
+
rowSelection = _propsRef$current.rowSelection,
|
|
62
|
+
rowOperation = _propsRef$current.rowOperation;
|
|
63
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
64
|
+
ref: bodyRef,
|
|
65
|
+
className: cls.cls('body-wrapper')
|
|
66
|
+
}, globalStaticRef.current.isEmpty ? ( /*#__PURE__*/React__default["default"].createElement("div", {
|
|
67
|
+
className: "full-box flex-center"
|
|
68
|
+
}, /*#__PURE__*/React__default["default"].createElement(schemaTableExtensions.Empty, null))) : ( /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, rowSelection ? /*#__PURE__*/React__default["default"].createElement(wrapper.RowSelection.Body, null) : null, /*#__PURE__*/React__default["default"].createElement("table", {
|
|
69
|
+
className: cls.cls('main-content')
|
|
70
|
+
}, rest.colGroup, props.children), rowOperation ? /*#__PURE__*/React__default["default"].createElement(index.RowOperation.Body, null) : null)));
|
|
71
|
+
}
|
|
72
|
+
function TableFooter(_ref2) {
|
|
73
|
+
var children = _ref2.children,
|
|
74
|
+
sticky = _ref2.sticky,
|
|
75
|
+
stickyOffset = _ref2.stickyOffset;
|
|
76
|
+
var _a = ctx.useTableContainer(),
|
|
77
|
+
footerRef = _a.footerRef,
|
|
78
|
+
rest = tslib.__rest(_a, ["footerRef"]);
|
|
79
|
+
var _useEditableSchemaTab3 = ctx$1.useEditableSchemaTableCtx().propsRef.current,
|
|
80
|
+
rowSelection = _useEditableSchemaTab3.rowSelection,
|
|
81
|
+
rowOperation = _useEditableSchemaTab3.rowOperation;
|
|
82
|
+
var className = cls.cls('footer-wrapper', {
|
|
83
|
+
'footer-wrapper--sticky': sticky
|
|
84
|
+
});
|
|
85
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
86
|
+
ref: footerRef,
|
|
87
|
+
className: className,
|
|
88
|
+
style: sticky && stickyOffset !== undefined ? {
|
|
89
|
+
bottom: stickyOffset
|
|
90
|
+
} : undefined
|
|
91
|
+
}, rowSelection ? /*#__PURE__*/React__default["default"].createElement(wrapper.RowSelection.Footer, null) : null, /*#__PURE__*/React__default["default"].createElement("table", {
|
|
92
|
+
className: cls.cls('main-content')
|
|
93
|
+
}, rest.colGroup, children), rowOperation ? /*#__PURE__*/React__default["default"].createElement(index.RowOperation.Footer, null) : null);
|
|
94
|
+
}
|
|
95
|
+
exports.TableBody = TableBody;
|
|
96
|
+
exports.TableFooter = TableFooter;
|
|
97
|
+
exports.TableHeader = TableHeader;
|
package/lib/cjs/ctx.js
ADDED
|
@@ -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 EditableSchemaTableCtx = /*#__PURE__*/React__default["default"].createContext(null);
|
|
24
|
+
function useEditableSchemaTableCtx() {
|
|
25
|
+
var ctx = React__default["default"].useContext(EditableSchemaTableCtx);
|
|
26
|
+
if (!ctx) throw new Error('useEditableSchemaTableCtx must be used within a EditableSchemaTable');
|
|
27
|
+
return ctx;
|
|
28
|
+
}
|
|
29
|
+
exports.EditTableCtx = EditableSchemaTableCtx;
|
|
30
|
+
exports.EditableSchemaTableCtx = EditableSchemaTableCtx;
|
|
31
|
+
exports.useEditTableCtx = useEditableSchemaTableCtx;
|
|
32
|
+
exports.useEditableSchemaTableCtx = useEditableSchemaTableCtx;
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var grouping = require('../../utils/grouping.js');
|
|
16
|
+
var CustomAggregatedFeature = {
|
|
17
|
+
createRow: function createRow(row, table) {
|
|
18
|
+
// 参考代码来源
|
|
19
|
+
// https://github.com/TanStack/table/blob/66fbe3a74b129e700e4667d1d5e1b29dd0a7b723/packages/table-core/src/utils/getGroupedRowModel.ts#L94-L127
|
|
20
|
+
row.$getAggregatedValue = function getRowAggregateValue(columnId) {
|
|
21
|
+
var column = table.getColumn(columnId);
|
|
22
|
+
// 有缓存直接去取
|
|
23
|
+
if (columnId in row._groupingValuesCache) {
|
|
24
|
+
return row._groupingValuesCache[columnId];
|
|
25
|
+
}
|
|
26
|
+
var aggregateFn = column === null || column === void 0 ? void 0 : column.getAggregationFn();
|
|
27
|
+
if (aggregateFn) {
|
|
28
|
+
var groupedRows = row.subRows;
|
|
29
|
+
// 原版使用 flattenBy 方法生成叶节点,会将中间的节点也包含进去,不符合 IPDTable 的分组逻辑
|
|
30
|
+
// 因此此处使用 getGroupedLeafRows 方法,生成结果仅包含叶节点
|
|
31
|
+
// const leafRows = flattenBy(groupedRows, (row) => row.subRows)
|
|
32
|
+
var leafRows = grouping.getGroupedLeafRows(groupedRows);
|
|
33
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
34
|
+
return row._groupingValuesCache[columnId];
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
createCell: function createCell(cell, column, row) {
|
|
39
|
+
cell.$getAggregatedValue = function getCellAggregatedValue() {
|
|
40
|
+
return row.$getAggregatedValue(column.id);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.CustomAggregatedFeature = CustomAggregatedFeature;
|
|
@@ -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
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
var reactTable = require('@tanstack/react-table');
|
|
16
|
+
var CustomGetterFeature = {
|
|
17
|
+
createTable: function createTable(table) {
|
|
18
|
+
table.$getInnerRef = function $getInnerRef() {
|
|
19
|
+
var _a;
|
|
20
|
+
// @ts-expect-error innerRef
|
|
21
|
+
return (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.innerRef;
|
|
22
|
+
};
|
|
23
|
+
table.$getCell = function $getCell(cellId) {
|
|
24
|
+
var firstUnderscoreIndex = cellId.indexOf('_');
|
|
25
|
+
var rowId = cellId.slice(0, firstUnderscoreIndex);
|
|
26
|
+
var columnId = cellId.slice(firstUnderscoreIndex + 1);
|
|
27
|
+
var row = table.getRow(rowId);
|
|
28
|
+
if (!row) return null;
|
|
29
|
+
var column = table.getColumn(columnId);
|
|
30
|
+
if (!column) return null;
|
|
31
|
+
return reactTable.createCell(table, row, column, columnId);
|
|
32
|
+
};
|
|
33
|
+
table.$getRealtimeRowData = function getTableRealtimeRowData(rowId) {
|
|
34
|
+
var _a;
|
|
35
|
+
try {
|
|
36
|
+
var row = table.getRow(rowId);
|
|
37
|
+
if (!row) return undefined;
|
|
38
|
+
var subscription = (_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.subscription;
|
|
39
|
+
if (!subscription) return undefined;
|
|
40
|
+
var rowIndex = row.index;
|
|
41
|
+
return subscription.getValue()[rowIndex];
|
|
42
|
+
} catch (error) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
createRow: function createRow(row, table) {
|
|
48
|
+
row.$getRealtimeRowData = function getRealtimeRowData() {
|
|
49
|
+
// 这里的 row.original 实际上没用
|
|
50
|
+
// getRealtimeRowData 会返回 undefined 是因为 rowId 可能会被用户误传
|
|
51
|
+
// 但此处的 rowId 是不会错误的,所以只是留一个 fallback
|
|
52
|
+
return table.$getRealtimeRowData(row.id) || row.original;
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
createCell: function createCell(cell, column, row) {
|
|
56
|
+
cell.$getRealtimeRowData = function getRealtimeCellRowData() {
|
|
57
|
+
return row.$getRealtimeRowData();
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.CustomGetterFeature = CustomGetterFeature;
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
var _const = require('../../const.js');
|
|
16
|
+
require('../../utils/cls.js');
|
|
17
|
+
var grouping = require('../../utils/grouping.js');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 自定义分组特性
|
|
21
|
+
* 主要用于处理分组值为null或undefined的情况,将不同类型的空值统一为一个特殊标记
|
|
22
|
+
* 这样所有的空值都会被归为同一组,而不是分散在不同的组中
|
|
23
|
+
*/
|
|
24
|
+
var CustomGroupingFeature = {
|
|
25
|
+
createRow: function createRow(row) {
|
|
26
|
+
// 保存原始的getGroupingValue方法
|
|
27
|
+
var originalGetGroupingValue = row.getGroupingValue;
|
|
28
|
+
// 重写getGroupingValue方法,统一处理空值
|
|
29
|
+
row.getGroupingValue = function (columnId) {
|
|
30
|
+
// 获取原始分组值
|
|
31
|
+
var value = originalGetGroupingValue.call(this, columnId);
|
|
32
|
+
// 如果是空值,统一返回特殊标记
|
|
33
|
+
if (grouping.isEmptyValue(value)) {
|
|
34
|
+
return _const.EMPTY_VALUE;
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.CustomGroupingFeature = CustomGroupingFeature;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
var useOpts = require('../pagination/use-opts.js');
|
|
16
|
+
|
|
17
|
+
// 内置 Feature 的覆写逻辑
|
|
18
|
+
var OverridesFeature = {
|
|
19
|
+
createTable: function createTable(table) {
|
|
20
|
+
// 覆写 resetPagination 方法
|
|
21
|
+
if (!table.originalResetPagination) table.originalResetPagination = table.resetPagination;
|
|
22
|
+
table.resetPagination = function resetPagination(defaultState) {
|
|
23
|
+
var _a;
|
|
24
|
+
// 先从分页状态中取行数,否则从 table 实例数据上取
|
|
25
|
+
// 原因是后端分页时,table 实例上只有一页的数据,不准
|
|
26
|
+
var rowCount = (_a = table.getState().pagination.rowCount) !== null && _a !== void 0 ? _a : table.getRowCount();
|
|
27
|
+
if (defaultState) {
|
|
28
|
+
var pageSize = useOpts.dftPageSize;
|
|
29
|
+
table.setPagination({
|
|
30
|
+
pageIndex: 0,
|
|
31
|
+
pageSize: pageSize,
|
|
32
|
+
rowCount: rowCount
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
var pagination = table.initialState.pagination;
|
|
36
|
+
table.setPagination(Object.assign(Object.assign({}, pagination), {
|
|
37
|
+
rowCount: rowCount
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.OverridesFeature = OverridesFeature;
|