@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
package/lib/esm/const.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import 'react';
|
|
11
|
+
import 'lodash-es';
|
|
12
|
+
import '@tanstack/react-table';
|
|
13
|
+
import 'ahooks';
|
|
14
|
+
var ROW_HEIGHT = 40;
|
|
15
|
+
var ROW_SELECTION_COL_WIDTH = 50;
|
|
16
|
+
var ROW_INDEX_COL_ID = '_row_index_';
|
|
17
|
+
var ROW_OPERATION_COL_WIDTH = 160;
|
|
18
|
+
function isSystemCol(id) {
|
|
19
|
+
return id === ROW_INDEX_COL_ID;
|
|
20
|
+
}
|
|
21
|
+
// 分组特性中用于标识空值的特殊标记
|
|
22
|
+
var EMPTY_VALUE = '__EMPTY_VALUE__';
|
|
23
|
+
var SELECTED_OPTION_RAW = '_selected_raw_option_';
|
|
24
|
+
export { EMPTY_VALUE, ROW_HEIGHT, ROW_INDEX_COL_ID, ROW_OPERATION_COL_WIDTH, ROW_SELECTION_COL_WIDTH, SELECTED_OPTION_RAW, isSystemCol };
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
import React, { useRef } from 'react';
|
|
11
|
+
import { TableContainerContext } from './ctx.js';
|
|
12
|
+
import { TableColGroup } from './col-group.js';
|
|
13
|
+
function NonVirtualContainer(props) {
|
|
14
|
+
var headerRef = useRef(null);
|
|
15
|
+
var bodyRef = useRef(null);
|
|
16
|
+
var footerRef = useRef(null);
|
|
17
|
+
var colGroup = /*#__PURE__*/React.createElement(TableColGroup, null);
|
|
18
|
+
return /*#__PURE__*/React.createElement(TableContainerContext.Provider, {
|
|
19
|
+
value: {
|
|
20
|
+
headerRef: headerRef,
|
|
21
|
+
bodyRef: bodyRef,
|
|
22
|
+
footerRef: footerRef,
|
|
23
|
+
colGroup: colGroup
|
|
24
|
+
}
|
|
25
|
+
}, props.children);
|
|
26
|
+
}
|
|
27
|
+
export { NonVirtualContainer };
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
import React from 'react';
|
|
11
|
+
import { Actions } from '@hi-ui/schema-action-trigger';
|
|
12
|
+
import { getGetterValue } from '@hi-ui/schema-utils';
|
|
13
|
+
import { useEditableSchemaTableCtx } from '../ctx.js';
|
|
14
|
+
import { Pagination } from '../features/pagination/component.js';
|
|
15
|
+
import '@hi-ui/use-subscription';
|
|
16
|
+
import 'lodash-es';
|
|
17
|
+
import '@tanstack/react-table';
|
|
18
|
+
import 'ahooks';
|
|
19
|
+
import { cls } from '../utils/cls.js';
|
|
20
|
+
import './index.js';
|
|
21
|
+
import '@hi-ui/checkbox';
|
|
22
|
+
import '@hi-ui/radio';
|
|
23
|
+
import { RowSelectionIndicator } from '../features/row-selection/indicator.js';
|
|
24
|
+
function BottomRender(props) {
|
|
25
|
+
var _a;
|
|
26
|
+
var tableCtx = useEditableSchemaTableCtx();
|
|
27
|
+
var propsRef = tableCtx.propsRef,
|
|
28
|
+
globalStaticRef = tableCtx.globalStaticRef;
|
|
29
|
+
var paginationEl = propsRef.current.pagination ? ( /*#__PURE__*/React.createElement(Pagination, Object.assign({
|
|
30
|
+
key: "pagination"
|
|
31
|
+
}, propsRef.current.pagination))) : null;
|
|
32
|
+
var rowSelectionIndicatorEl = ((_a = propsRef.current.rowSelection) === null || _a === void 0 ? void 0 : _a.enableIndicator) ? ( /*#__PURE__*/React.createElement(RowSelectionIndicator, {
|
|
33
|
+
key: "row-selection-indicator"
|
|
34
|
+
})) : null;
|
|
35
|
+
var builtin = {
|
|
36
|
+
rowSelectionIndicator: rowSelectionIndicatorEl,
|
|
37
|
+
pagination: paginationEl
|
|
38
|
+
};
|
|
39
|
+
var dftLeft = [rowSelectionIndicatorEl];
|
|
40
|
+
var dftRight = [paginationEl];
|
|
41
|
+
var getLeft = props.left,
|
|
42
|
+
getRight = props.right;
|
|
43
|
+
var ctx = {
|
|
44
|
+
tableCtx: tableCtx,
|
|
45
|
+
builtin: builtin
|
|
46
|
+
};
|
|
47
|
+
var left = getGetterValue(getLeft, dftLeft, [ctx]);
|
|
48
|
+
var right = getGetterValue(getRight, dftRight, [ctx]);
|
|
49
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: cls('bottom-container'),
|
|
51
|
+
"data-is-bottom-empty": globalStaticRef.current.isBottomEmpty
|
|
52
|
+
}, /*#__PURE__*/React.createElement(Actions
|
|
53
|
+
// left
|
|
54
|
+
, {
|
|
55
|
+
// left
|
|
56
|
+
className: cls('bottom-container-left'),
|
|
57
|
+
actions: left,
|
|
58
|
+
data: [],
|
|
59
|
+
ctx: {
|
|
60
|
+
tableCtx: tableCtx
|
|
61
|
+
}
|
|
62
|
+
}), /*#__PURE__*/React.createElement(Actions
|
|
63
|
+
// right
|
|
64
|
+
, {
|
|
65
|
+
// right
|
|
66
|
+
className: cls('bottom-container-right'),
|
|
67
|
+
actions: right,
|
|
68
|
+
data: [],
|
|
69
|
+
ctx: {
|
|
70
|
+
tableCtx: tableCtx
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
export { BottomRender };
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
import React from 'react';
|
|
11
|
+
import { useEditableSchemaTableCtx } from '../ctx.js';
|
|
12
|
+
import { isSystemCol } from '../const.js';
|
|
13
|
+
import { groupHeaders } from '../header/index.js';
|
|
14
|
+
|
|
15
|
+
// 基础 ColGroup
|
|
16
|
+
function TableColGroup() {
|
|
17
|
+
var _useEditableSchemaTab = useEditableSchemaTableCtx(),
|
|
18
|
+
table = _useEditableSchemaTab.table;
|
|
19
|
+
return /*#__PURE__*/React.createElement("colgroup", null, table.getVisibleLeafColumns().map(function (column) {
|
|
20
|
+
return /*#__PURE__*/React.createElement(Col, {
|
|
21
|
+
key: column.id,
|
|
22
|
+
column: column
|
|
23
|
+
});
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
// 虚拟化 ColGroup
|
|
27
|
+
function VirtualColGroup(_ref) {
|
|
28
|
+
var virtualColumns = _ref.virtualColumns,
|
|
29
|
+
virtualColPadding = _ref.virtualColPadding;
|
|
30
|
+
var _useEditableSchemaTab2 = useEditableSchemaTableCtx(),
|
|
31
|
+
table = _useEditableSchemaTab2.table;
|
|
32
|
+
var headerGroups = table.getHeaderGroups();
|
|
33
|
+
var lastHeaderGroup = headerGroups[headerGroups.length - 1];
|
|
34
|
+
var realHeaders = lastHeaderGroup.headers;
|
|
35
|
+
var _groupHeaders = groupHeaders(realHeaders, table),
|
|
36
|
+
leftHeaders = _groupHeaders.left,
|
|
37
|
+
rightHeaders = _groupHeaders.right;
|
|
38
|
+
return /*#__PURE__*/React.createElement("colgroup", null, leftHeaders.map(function (_ref2) {
|
|
39
|
+
var column = _ref2.column;
|
|
40
|
+
return /*#__PURE__*/React.createElement(Col, {
|
|
41
|
+
key: column.id,
|
|
42
|
+
column: column
|
|
43
|
+
});
|
|
44
|
+
}), virtualColPadding.start > 0 && /*#__PURE__*/React.createElement("col", {
|
|
45
|
+
style: {
|
|
46
|
+
width: virtualColPadding.start
|
|
47
|
+
}
|
|
48
|
+
}), virtualColumns.map(function (vc) {
|
|
49
|
+
var column = realHeaders[vc.index].column;
|
|
50
|
+
// 固定列不参与中间部分渲染
|
|
51
|
+
if (column.getIsPinned()) return null;
|
|
52
|
+
return /*#__PURE__*/React.createElement(Col, {
|
|
53
|
+
key: column.id,
|
|
54
|
+
column: column
|
|
55
|
+
});
|
|
56
|
+
}), virtualColPadding.end > 0 && /*#__PURE__*/React.createElement("col", {
|
|
57
|
+
style: {
|
|
58
|
+
width: virtualColPadding.end
|
|
59
|
+
}
|
|
60
|
+
}), rightHeaders.map(function (_ref3) {
|
|
61
|
+
var column = _ref3.column;
|
|
62
|
+
return /*#__PURE__*/React.createElement(Col, {
|
|
63
|
+
key: column.id,
|
|
64
|
+
column: column
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function Col(props) {
|
|
69
|
+
var column = props.column;
|
|
70
|
+
var colWidth = column.getSize();
|
|
71
|
+
// 系统字段列使用固定宽度,其他列使用最小宽度+自动列宽
|
|
72
|
+
// 自动列宽分配是指:表格宽度超过所有列宽之和时,自动分配剩余宽度
|
|
73
|
+
// NOTE 预期如上述描述所示,但实测这样写系统字段还是会参与自动列宽分配
|
|
74
|
+
var maxWidth = isSystemCol(column.id) ? colWidth : undefined;
|
|
75
|
+
return /*#__PURE__*/React.createElement("col", {
|
|
76
|
+
key: column.id,
|
|
77
|
+
"data-id": column.id,
|
|
78
|
+
style: {
|
|
79
|
+
width: colWidth,
|
|
80
|
+
minWidth: colWidth,
|
|
81
|
+
maxWidth: maxWidth
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export { TableColGroup, VirtualColGroup };
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import React, { useRef } from 'react';
|
|
11
|
+
import { TableContainerContext } from './ctx.js';
|
|
12
|
+
import { useColumnVirtualizer } from './hooks.js';
|
|
13
|
+
import { VirtualColGroup } from './col-group.js';
|
|
14
|
+
function ColumnVirtualContainer(props) {
|
|
15
|
+
var headerRef = useRef(null);
|
|
16
|
+
var bodyRef = useRef(null);
|
|
17
|
+
var footerRef = useRef(null);
|
|
18
|
+
var _useColumnVirtualizer = useColumnVirtualizer(props.options),
|
|
19
|
+
columns = _useColumnVirtualizer.virtualItems,
|
|
20
|
+
colPadding = _useColumnVirtualizer.padding;
|
|
21
|
+
var colGroup = /*#__PURE__*/React.createElement(VirtualColGroup, {
|
|
22
|
+
virtualColumns: columns,
|
|
23
|
+
virtualColPadding: colPadding
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/React.createElement(TableContainerContext.Provider, {
|
|
26
|
+
value: {
|
|
27
|
+
headerRef: headerRef,
|
|
28
|
+
bodyRef: bodyRef,
|
|
29
|
+
footerRef: footerRef,
|
|
30
|
+
colGroup: colGroup,
|
|
31
|
+
virtualize: {
|
|
32
|
+
columns: columns,
|
|
33
|
+
colPadding: {
|
|
34
|
+
left: colPadding.start,
|
|
35
|
+
right: colPadding.end
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}, props.children);
|
|
40
|
+
}
|
|
41
|
+
export { ColumnVirtualContainer };
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import React from 'react';
|
|
11
|
+
var TableContainerContext = /*#__PURE__*/React.createContext(null);
|
|
12
|
+
function useTableContainer() {
|
|
13
|
+
var context = React.useContext(TableContainerContext);
|
|
14
|
+
if (!context) {
|
|
15
|
+
throw new Error('Table.* component must be rendered as child of Table component');
|
|
16
|
+
}
|
|
17
|
+
return context;
|
|
18
|
+
}
|
|
19
|
+
export { TableContainerContext, useTableContainer };
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import React, { useRef } from 'react';
|
|
11
|
+
import { TableContainerContext } from './ctx.js';
|
|
12
|
+
import { useRowVirtualizer, useColumnVirtualizer } from './hooks.js';
|
|
13
|
+
import { VirtualColGroup } from './col-group.js';
|
|
14
|
+
function FullVirtualContainer(props) {
|
|
15
|
+
var headerRef = useRef(null);
|
|
16
|
+
var bodyRef = useRef(null);
|
|
17
|
+
var footerRef = useRef(null);
|
|
18
|
+
var _useRowVirtualizer = useRowVirtualizer(props.rowOptions),
|
|
19
|
+
rows = _useRowVirtualizer.virtualItems,
|
|
20
|
+
rowPadding = _useRowVirtualizer.padding;
|
|
21
|
+
var _useColumnVirtualizer = useColumnVirtualizer(props.columnOptions),
|
|
22
|
+
columns = _useColumnVirtualizer.virtualItems,
|
|
23
|
+
colPadding = _useColumnVirtualizer.padding;
|
|
24
|
+
var colGroup = /*#__PURE__*/React.createElement(VirtualColGroup, {
|
|
25
|
+
virtualColumns: columns,
|
|
26
|
+
virtualColPadding: colPadding
|
|
27
|
+
});
|
|
28
|
+
return /*#__PURE__*/React.createElement(TableContainerContext.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
headerRef: headerRef,
|
|
31
|
+
bodyRef: bodyRef,
|
|
32
|
+
footerRef: footerRef,
|
|
33
|
+
colGroup: colGroup,
|
|
34
|
+
virtualize: {
|
|
35
|
+
rows: rows,
|
|
36
|
+
columns: columns,
|
|
37
|
+
rowPadding: {
|
|
38
|
+
top: rowPadding.start,
|
|
39
|
+
bottom: rowPadding.end
|
|
40
|
+
},
|
|
41
|
+
colPadding: {
|
|
42
|
+
left: colPadding.start,
|
|
43
|
+
right: colPadding.end
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, props.children);
|
|
48
|
+
}
|
|
49
|
+
export { FullVirtualContainer };
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
import { useEffect } from 'react';
|
|
11
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
12
|
+
import { useEditableSchemaTableCtx } from '../ctx.js';
|
|
13
|
+
import { ROW_HEIGHT } from '../const.js';
|
|
14
|
+
function useRowVirtualizer(options) {
|
|
15
|
+
var _useEditableSchemaTab = useEditableSchemaTableCtx(),
|
|
16
|
+
table = _useEditableSchemaTab.table,
|
|
17
|
+
tableContainerRef = _useEditableSchemaTab.tableContainerRef;
|
|
18
|
+
var virtualizer = useVirtualizer(Object.assign({
|
|
19
|
+
count: table.getRowModel().rows.length,
|
|
20
|
+
getScrollElement: function getScrollElement() {
|
|
21
|
+
return tableContainerRef.current;
|
|
22
|
+
},
|
|
23
|
+
estimateSize: function estimateSize() {
|
|
24
|
+
return ROW_HEIGHT;
|
|
25
|
+
},
|
|
26
|
+
overscan: 5
|
|
27
|
+
}, options));
|
|
28
|
+
var virtualItems = virtualizer.getVirtualItems();
|
|
29
|
+
var padding = !virtualItems.length ? {
|
|
30
|
+
start: 0,
|
|
31
|
+
end: 0
|
|
32
|
+
} : {
|
|
33
|
+
start: virtualItems[0].start,
|
|
34
|
+
end: virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
virtualItems: virtualItems,
|
|
38
|
+
padding: padding
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function useColumnVirtualizer(options) {
|
|
42
|
+
var _useEditableSchemaTab2 = useEditableSchemaTableCtx(),
|
|
43
|
+
table = _useEditableSchemaTab2.table,
|
|
44
|
+
tableContainerRef = _useEditableSchemaTab2.tableContainerRef;
|
|
45
|
+
var virtualizer = useVirtualizer(Object.assign({
|
|
46
|
+
count: table.getVisibleLeafColumns().length,
|
|
47
|
+
getScrollElement: function getScrollElement() {
|
|
48
|
+
return tableContainerRef.current;
|
|
49
|
+
},
|
|
50
|
+
estimateSize: function estimateSize(index) {
|
|
51
|
+
return table.getVisibleLeafColumns()[index].getSize();
|
|
52
|
+
},
|
|
53
|
+
horizontal: true,
|
|
54
|
+
overscan: 3
|
|
55
|
+
}, options));
|
|
56
|
+
var virtualItems = virtualizer.getVirtualItems();
|
|
57
|
+
var padding = !virtualItems.length ? {
|
|
58
|
+
start: 0,
|
|
59
|
+
end: 0
|
|
60
|
+
} : {
|
|
61
|
+
start: virtualItems[0].start,
|
|
62
|
+
end: virtualizer.getTotalSize() - virtualItems[virtualItems.length - 1].end
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
virtualItems: virtualItems,
|
|
66
|
+
padding: padding
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function useTableScroll() {
|
|
70
|
+
var _useEditableSchemaTab3 = useEditableSchemaTableCtx(),
|
|
71
|
+
tableContainerRef = _useEditableSchemaTab3.tableContainerRef;
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
var container = tableContainerRef.current;
|
|
74
|
+
if (!container) return;
|
|
75
|
+
var handleScroll = function handleScroll() {
|
|
76
|
+
var scrollLeft = container.scrollLeft,
|
|
77
|
+
scrollWidth = container.scrollWidth,
|
|
78
|
+
clientWidth = container.clientWidth;
|
|
79
|
+
// 左侧是否有可滚动空间
|
|
80
|
+
var hasLeftSpace = scrollLeft > 0;
|
|
81
|
+
// 右侧是否有可滚动空间
|
|
82
|
+
var hasRightSpace = Math.abs(scrollWidth - clientWidth - scrollLeft) > 1;
|
|
83
|
+
// 根据两侧是否有可滚动空间来切换对应的类名
|
|
84
|
+
container.classList.toggle('editable-schema-table--scrolling-right', hasLeftSpace);
|
|
85
|
+
container.classList.toggle('editable-schema-table--scrolling-left', hasRightSpace);
|
|
86
|
+
};
|
|
87
|
+
container.addEventListener('scroll', handleScroll);
|
|
88
|
+
// 初始化时触发一次
|
|
89
|
+
handleScroll();
|
|
90
|
+
return function () {
|
|
91
|
+
container.removeEventListener('scroll', handleScroll);
|
|
92
|
+
};
|
|
93
|
+
}, [tableContainerRef]);
|
|
94
|
+
}
|
|
95
|
+
export { useColumnVirtualizer, useRowVirtualizer, useTableScroll };
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
import React from 'react';
|
|
11
|
+
import { useInitialRender } from '../hooks/use-initial-render.js';
|
|
12
|
+
import { NonVirtualContainer } from './base.js';
|
|
13
|
+
import { RowVirtualContainer } from './row-virtual.js';
|
|
14
|
+
import { ColumnVirtualContainer } from './column-virtual.js';
|
|
15
|
+
import { FullVirtualContainer } from './full-virtual.js';
|
|
16
|
+
import { TableHeader, TableBody, TableFooter } from './wrapper.js';
|
|
17
|
+
import { useTableScroll } from './hooks.js';
|
|
18
|
+
import '@hi-ui/schema-action-trigger';
|
|
19
|
+
import '@hi-ui/schema-utils';
|
|
20
|
+
import '@hi-ui/pagination';
|
|
21
|
+
import '@hi-ui/use-subscription';
|
|
22
|
+
import 'lodash-es';
|
|
23
|
+
import '@tanstack/react-table';
|
|
24
|
+
import 'ahooks';
|
|
25
|
+
import '../utils/cls.js';
|
|
26
|
+
import '@hi-ui/checkbox';
|
|
27
|
+
import '@hi-ui/radio';
|
|
28
|
+
import '@hi-ui/space';
|
|
29
|
+
import '@hi-ui/switch';
|
|
30
|
+
function TableContainer(props) {
|
|
31
|
+
var virtualizeConfig = props.virtualize;
|
|
32
|
+
useInitialRender(); // 初次渲染时容器组件尚未加载,导致白屏,因此在组件挂在后强制更新一次
|
|
33
|
+
useTableScroll(); // 滚动时给容器增加类名,用于控制阴影效果
|
|
34
|
+
// 根据配置选择合适的容器
|
|
35
|
+
if ((virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.row) && (virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.column)) {
|
|
36
|
+
return /*#__PURE__*/React.createElement(FullVirtualContainer, {
|
|
37
|
+
rowOptions: virtualizeConfig.row,
|
|
38
|
+
columnOptions: virtualizeConfig.column
|
|
39
|
+
}, props.children);
|
|
40
|
+
}
|
|
41
|
+
if (virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.row) {
|
|
42
|
+
return /*#__PURE__*/React.createElement(RowVirtualContainer, {
|
|
43
|
+
options: virtualizeConfig.row
|
|
44
|
+
}, props.children);
|
|
45
|
+
}
|
|
46
|
+
if (virtualizeConfig === null || virtualizeConfig === void 0 ? void 0 : virtualizeConfig.column) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(ColumnVirtualContainer, {
|
|
48
|
+
options: virtualizeConfig.column
|
|
49
|
+
}, props.children);
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React.createElement(NonVirtualContainer, null, props.children);
|
|
52
|
+
}
|
|
53
|
+
// 导出组件
|
|
54
|
+
TableContainer.Header = TableHeader;
|
|
55
|
+
TableContainer.Body = TableBody;
|
|
56
|
+
TableContainer.Footer = TableFooter;
|
|
57
|
+
export { TableContainer };
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
import React, { useRef } from 'react';
|
|
11
|
+
import { TableContainerContext } from './ctx.js';
|
|
12
|
+
import { useRowVirtualizer } from './hooks.js';
|
|
13
|
+
import { TableColGroup } from './col-group.js';
|
|
14
|
+
function RowVirtualContainer(props) {
|
|
15
|
+
var headerRef = useRef(null);
|
|
16
|
+
var bodyRef = useRef(null);
|
|
17
|
+
var footerRef = useRef(null);
|
|
18
|
+
var _useRowVirtualizer = useRowVirtualizer(props.options),
|
|
19
|
+
rows = _useRowVirtualizer.virtualItems,
|
|
20
|
+
rowPadding = _useRowVirtualizer.padding;
|
|
21
|
+
var colGroup = /*#__PURE__*/React.createElement(TableColGroup, null);
|
|
22
|
+
return /*#__PURE__*/React.createElement(TableContainerContext.Provider, {
|
|
23
|
+
value: {
|
|
24
|
+
headerRef: headerRef,
|
|
25
|
+
bodyRef: bodyRef,
|
|
26
|
+
footerRef: footerRef,
|
|
27
|
+
colGroup: colGroup,
|
|
28
|
+
virtualize: {
|
|
29
|
+
rows: rows,
|
|
30
|
+
rowPadding: {
|
|
31
|
+
top: rowPadding.start,
|
|
32
|
+
bottom: rowPadding.end
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, props.children);
|
|
37
|
+
}
|
|
38
|
+
export { RowVirtualContainer };
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
import { __rest } from 'tslib';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { Empty } from '@hi-ui/schema-table-extensions';
|
|
13
|
+
import { useEditableSchemaTableCtx } from '../ctx.js';
|
|
14
|
+
import { RowSelection } from '../features/row-selection/wrapper.js';
|
|
15
|
+
import { RowOperation } from '../features/row-operation/index.js';
|
|
16
|
+
import { cls } from '../utils/cls.js';
|
|
17
|
+
import { useTableContainer } from './ctx.js';
|
|
18
|
+
function TableHeader(_ref) {
|
|
19
|
+
var children = _ref.children,
|
|
20
|
+
sticky = _ref.sticky,
|
|
21
|
+
stickyOffset = _ref.stickyOffset;
|
|
22
|
+
var _a = useTableContainer(),
|
|
23
|
+
headerRef = _a.headerRef,
|
|
24
|
+
rest = __rest(_a, ["headerRef"]);
|
|
25
|
+
var _useEditableSchemaTab = useEditableSchemaTableCtx().propsRef.current,
|
|
26
|
+
rowSelection = _useEditableSchemaTab.rowSelection,
|
|
27
|
+
rowOperation = _useEditableSchemaTab.rowOperation;
|
|
28
|
+
var className = cls('header-wrapper', {
|
|
29
|
+
'header-wrapper--sticky': sticky
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
ref: headerRef,
|
|
33
|
+
className: className,
|
|
34
|
+
style: sticky && stickyOffset !== undefined ? {
|
|
35
|
+
top: stickyOffset
|
|
36
|
+
} : undefined
|
|
37
|
+
}, rowSelection ? /*#__PURE__*/React.createElement(RowSelection.Header, null) : null, /*#__PURE__*/React.createElement("table", {
|
|
38
|
+
className: cls('main-content')
|
|
39
|
+
}, rest.colGroup, children), rowOperation ? /*#__PURE__*/React.createElement(RowOperation.Header, null) : null);
|
|
40
|
+
}
|
|
41
|
+
function TableBody(props) {
|
|
42
|
+
var _a = useTableContainer(),
|
|
43
|
+
bodyRef = _a.bodyRef,
|
|
44
|
+
rest = __rest(_a, ["bodyRef"]);
|
|
45
|
+
var _useEditableSchemaTab2 = useEditableSchemaTableCtx(),
|
|
46
|
+
propsRef = _useEditableSchemaTab2.propsRef,
|
|
47
|
+
globalStaticRef = _useEditableSchemaTab2.globalStaticRef;
|
|
48
|
+
var _propsRef$current = propsRef.current,
|
|
49
|
+
rowSelection = _propsRef$current.rowSelection,
|
|
50
|
+
rowOperation = _propsRef$current.rowOperation;
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
ref: bodyRef,
|
|
53
|
+
className: cls('body-wrapper')
|
|
54
|
+
}, globalStaticRef.current.isEmpty ? ( /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "full-box flex-center"
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Empty, null))) : ( /*#__PURE__*/React.createElement(React.Fragment, null, rowSelection ? /*#__PURE__*/React.createElement(RowSelection.Body, null) : null, /*#__PURE__*/React.createElement("table", {
|
|
57
|
+
className: cls('main-content')
|
|
58
|
+
}, rest.colGroup, props.children), rowOperation ? /*#__PURE__*/React.createElement(RowOperation.Body, null) : null)));
|
|
59
|
+
}
|
|
60
|
+
function TableFooter(_ref2) {
|
|
61
|
+
var children = _ref2.children,
|
|
62
|
+
sticky = _ref2.sticky,
|
|
63
|
+
stickyOffset = _ref2.stickyOffset;
|
|
64
|
+
var _a = useTableContainer(),
|
|
65
|
+
footerRef = _a.footerRef,
|
|
66
|
+
rest = __rest(_a, ["footerRef"]);
|
|
67
|
+
var _useEditableSchemaTab3 = useEditableSchemaTableCtx().propsRef.current,
|
|
68
|
+
rowSelection = _useEditableSchemaTab3.rowSelection,
|
|
69
|
+
rowOperation = _useEditableSchemaTab3.rowOperation;
|
|
70
|
+
var className = cls('footer-wrapper', {
|
|
71
|
+
'footer-wrapper--sticky': sticky
|
|
72
|
+
});
|
|
73
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
ref: footerRef,
|
|
75
|
+
className: className,
|
|
76
|
+
style: sticky && stickyOffset !== undefined ? {
|
|
77
|
+
bottom: stickyOffset
|
|
78
|
+
} : undefined
|
|
79
|
+
}, rowSelection ? /*#__PURE__*/React.createElement(RowSelection.Footer, null) : null, /*#__PURE__*/React.createElement("table", {
|
|
80
|
+
className: cls('main-content')
|
|
81
|
+
}, rest.colGroup, children), rowOperation ? /*#__PURE__*/React.createElement(RowOperation.Footer, null) : null);
|
|
82
|
+
}
|
|
83
|
+
export { TableBody, TableFooter, TableHeader };
|
package/lib/esm/ctx.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import React from 'react';
|
|
11
|
+
var EditableSchemaTableCtx = /*#__PURE__*/React.createContext(null);
|
|
12
|
+
function useEditableSchemaTableCtx() {
|
|
13
|
+
var ctx = React.useContext(EditableSchemaTableCtx);
|
|
14
|
+
if (!ctx) throw new Error('useEditableSchemaTableCtx must be used within a EditableSchemaTable');
|
|
15
|
+
return ctx;
|
|
16
|
+
}
|
|
17
|
+
export { EditableSchemaTableCtx as EditTableCtx, EditableSchemaTableCtx, useEditableSchemaTableCtx as useEditTableCtx, useEditableSchemaTableCtx };
|
|
@@ -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
|
+
import { getGroupedLeafRows } from '../../utils/grouping.js';
|
|
11
|
+
var CustomAggregatedFeature = {
|
|
12
|
+
createRow: function createRow(row, table) {
|
|
13
|
+
// 参考代码来源
|
|
14
|
+
// https://github.com/TanStack/table/blob/66fbe3a74b129e700e4667d1d5e1b29dd0a7b723/packages/table-core/src/utils/getGroupedRowModel.ts#L94-L127
|
|
15
|
+
row.$getAggregatedValue = function getRowAggregateValue(columnId) {
|
|
16
|
+
var column = table.getColumn(columnId);
|
|
17
|
+
// 有缓存直接去取
|
|
18
|
+
if (columnId in row._groupingValuesCache) {
|
|
19
|
+
return row._groupingValuesCache[columnId];
|
|
20
|
+
}
|
|
21
|
+
var aggregateFn = column === null || column === void 0 ? void 0 : column.getAggregationFn();
|
|
22
|
+
if (aggregateFn) {
|
|
23
|
+
var groupedRows = row.subRows;
|
|
24
|
+
// 原版使用 flattenBy 方法生成叶节点,会将中间的节点也包含进去,不符合 IPDTable 的分组逻辑
|
|
25
|
+
// 因此此处使用 getGroupedLeafRows 方法,生成结果仅包含叶节点
|
|
26
|
+
// const leafRows = flattenBy(groupedRows, (row) => row.subRows)
|
|
27
|
+
var leafRows = getGroupedLeafRows(groupedRows);
|
|
28
|
+
row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
|
|
29
|
+
return row._groupingValuesCache[columnId];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
createCell: function createCell(cell, column, row) {
|
|
34
|
+
cell.$getAggregatedValue = function getCellAggregatedValue() {
|
|
35
|
+
return row.$getAggregatedValue(column.id);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export { CustomAggregatedFeature };
|