@kdcloudjs/table 1.0.0
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/LICENSE +568 -0
- package/README.md +111 -0
- package/dist/@kdcloudjs/table.css +422 -0
- package/dist/@kdcloudjs/table.css.map +1 -0
- package/dist/@kdcloudjs/table.js +38578 -0
- package/dist/@kdcloudjs/table.js.map +1 -0
- package/dist/@kdcloudjs/table.min.css +9 -0
- package/dist/@kdcloudjs/table.min.js +208 -0
- package/dist/@kdcloudjs/table.min.js.map +1 -0
- package/dist/default-theme.js +344 -0
- package/dist/kd-table.css +422 -0
- package/dist/kd-table.css.map +1 -0
- package/dist/kd-table.js +38578 -0
- package/dist/kd-table.js.map +1 -0
- package/dist/kd-table.min.css +9 -0
- package/dist/kd-table.min.js +208 -0
- package/dist/kd-table.min.js.map +1 -0
- package/dist/kd-ui-complete.less +779 -0
- package/dist/kd-ui.less +2 -0
- package/dist/theme.js +13 -0
- package/es/_utils/arrayUtil.d.ts +5 -0
- package/es/_utils/arrayUtil.js +17 -0
- package/es/_utils/devwarning.d.ts +1 -0
- package/es/_utils/devwarning.js +10 -0
- package/es/_utils/formatUtil.d.ts +46 -0
- package/es/_utils/formatUtil.js +346 -0
- package/es/_utils/hooks.d.ts +51 -0
- package/es/_utils/hooks.js +165 -0
- package/es/_utils/index.d.ts +8 -0
- package/es/_utils/index.js +15 -0
- package/es/_utils/numberUtil.d.ts +34 -0
- package/es/_utils/numberUtil.js +181 -0
- package/es/_utils/omit.d.ts +1 -0
- package/es/_utils/omit.js +11 -0
- package/es/_utils/react-children.d.ts +2 -0
- package/es/_utils/react-children.js +8 -0
- package/es/_utils/type.d.ts +12 -0
- package/es/_utils/type.js +15 -0
- package/es/_utils/usePopper.d.ts +29 -0
- package/es/_utils/usePopper.js +546 -0
- package/es/config-provider/ConfigContext.d.ts +22 -0
- package/es/config-provider/ConfigContext.js +7 -0
- package/es/config-provider/compDefaultProps.d.ts +8 -0
- package/es/config-provider/compDefaultProps.js +10 -0
- package/es/config-provider/configProvider.d.ts +11 -0
- package/es/config-provider/configProvider.js +40 -0
- package/es/config-provider/defaultConfig.d.ts +10 -0
- package/es/config-provider/defaultConfig.js +18 -0
- package/es/config-provider/index.d.ts +6 -0
- package/es/config-provider/index.js +6 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +4 -0
- package/es/locale/index.d.ts +3 -0
- package/es/locale/index.js +3 -0
- package/es/locale/locale.d.ts +50 -0
- package/es/locale/locale.js +251 -0
- package/es/locale/zh-CN.d.ts +8 -0
- package/es/locale/zh-CN.js +8 -0
- package/es/style/color/colors.less +2 -0
- package/es/style/core/index.less +2 -0
- package/es/style/core/motion/other.less +28 -0
- package/es/style/core/motion/slide.less +53 -0
- package/es/style/core/motion.less +2 -0
- package/es/style/core/reset.less +186 -0
- package/es/style/css.js +1 -0
- package/es/style/index.css +410 -0
- package/es/style/index.d.ts +1 -0
- package/es/style/index.js +1 -0
- package/es/style/index.less +2 -0
- package/es/style/mixins/index.less +19 -0
- package/es/style/mixins/overlay.less +22 -0
- package/es/style/mixins/reset.less +13 -0
- package/es/style/themes/default.less +445 -0
- package/es/style/themes/index.less +1 -0
- package/es/table/base/calculations.d.ts +5 -0
- package/es/table/base/calculations.js +364 -0
- package/es/table/base/colgroup.d.ts +5 -0
- package/es/table/base/colgroup.js +22 -0
- package/es/table/base/empty.d.ts +9 -0
- package/es/table/base/empty.js +38 -0
- package/es/table/base/header.d.ts +5 -0
- package/es/table/base/header.js +324 -0
- package/es/table/base/helpers/SpanManager.d.ts +9 -0
- package/es/table/base/helpers/SpanManager.js +50 -0
- package/es/table/base/helpers/TableDOMUtils.d.ts +18 -0
- package/es/table/base/helpers/TableDOMUtils.js +104 -0
- package/es/table/base/helpers/__test__/SpanManager.test.d.ts +1 -0
- package/es/table/base/helpers/__test__/SpanManager.test.js +18 -0
- package/es/table/base/helpers/__test__/TableDOMUtils.test.d.ts +1 -0
- package/es/table/base/helpers/__test__/TableDOMUtils.test.js +34 -0
- package/es/table/base/helpers/__test__/rowHeightManager.test.d.ts +1 -0
- package/es/table/base/helpers/__test__/rowHeightManager.test.js +30 -0
- package/es/table/base/helpers/__test__/visible-part.test.d.ts +1 -0
- package/es/table/base/helpers/__test__/visible-part.test.js +28 -0
- package/es/table/base/helpers/rowHeightManager.d.ts +7 -0
- package/es/table/base/helpers/rowHeightManager.js +157 -0
- package/es/table/base/helpers/visible-part.d.ts +23 -0
- package/es/table/base/helpers/visible-part.js +58 -0
- package/es/table/base/html-table.d.ts +15 -0
- package/es/table/base/html-table.js +132 -0
- package/es/table/base/index.d.ts +3 -0
- package/es/table/base/index.js +2 -0
- package/es/table/base/interfaces.d.ts +54 -0
- package/es/table/base/interfaces.js +0 -0
- package/es/table/base/loading.d.ts +13 -0
- package/es/table/base/loading.js +60 -0
- package/es/table/base/styles.d.ts +132 -0
- package/es/table/base/styles.js +112 -0
- package/es/table/base/table.d.ts +150 -0
- package/es/table/base/table.js +733 -0
- package/es/table/base/utils.d.ts +36 -0
- package/es/table/base/utils.js +193 -0
- package/es/table/common-views.d.ts +24 -0
- package/es/table/common-views.js +70 -0
- package/es/table/index.d.ts +6 -0
- package/es/table/index.js +6 -0
- package/es/table/interfaces.d.ts +98 -0
- package/es/table/interfaces.js +0 -0
- package/es/table/internals.d.ts +14 -0
- package/es/table/internals.js +56 -0
- package/es/table/pipeline/features/__test__/multiSelect.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/multiSelect.test.js +152 -0
- package/es/table/pipeline/features/__test__/rowDetail.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/rowDetail.test.js +223 -0
- package/es/table/pipeline/features/__test__/rowGrouping.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/rowGrouping.test.js +120 -0
- package/es/table/pipeline/features/__test__/singleSelect.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/singleSelect.test.js +191 -0
- package/es/table/pipeline/features/__test__/sort.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/sort.test.js +213 -0
- package/es/table/pipeline/features/__test__/tips.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/tips.test.js +123 -0
- package/es/table/pipeline/features/__test__/treeMode.test.d.ts +1 -0
- package/es/table/pipeline/features/__test__/treeMode.test.js +202 -0
- package/es/table/pipeline/features/autoFill.d.ts +4 -0
- package/es/table/pipeline/features/autoFill.js +63 -0
- package/es/table/pipeline/features/autoRowSpan.d.ts +2 -0
- package/es/table/pipeline/features/autoRowSpan.js +72 -0
- package/es/table/pipeline/features/buildTree.d.ts +2 -0
- package/es/table/pipeline/features/buildTree.js +8 -0
- package/es/table/pipeline/features/columnDrag.d.ts +6 -0
- package/es/table/pipeline/features/columnDrag.js +265 -0
- package/es/table/pipeline/features/columnFilter.d.ts +20 -0
- package/es/table/pipeline/features/columnFilter.js +173 -0
- package/es/table/pipeline/features/columnHover.d.ts +12 -0
- package/es/table/pipeline/features/columnHover.js +51 -0
- package/es/table/pipeline/features/columnRangeHover.d.ts +15 -0
- package/es/table/pipeline/features/columnRangeHover.js +83 -0
- package/es/table/pipeline/features/columnResizeWidth.d.ts +21 -0
- package/es/table/pipeline/features/columnResizeWidth.js +173 -0
- package/es/table/pipeline/features/contextMenu.d.ts +14 -0
- package/es/table/pipeline/features/contextMenu.js +370 -0
- package/es/table/pipeline/features/filter/DefaultFilterContent.d.ts +4 -0
- package/es/table/pipeline/features/filter/DefaultFilterContent.js +91 -0
- package/es/table/pipeline/features/filter/Filter.d.ts +17 -0
- package/es/table/pipeline/features/filter/Filter.js +111 -0
- package/es/table/pipeline/features/filter/FilterPanel.d.ts +20 -0
- package/es/table/pipeline/features/filter/FilterPanel.js +81 -0
- package/es/table/pipeline/features/filter/__test__/Filter.test.d.ts +1 -0
- package/es/table/pipeline/features/filter/__test__/Filter.test.js +29 -0
- package/es/table/pipeline/features/filter/index.d.ts +4 -0
- package/es/table/pipeline/features/filter/index.js +4 -0
- package/es/table/pipeline/features/filter/util.d.ts +10 -0
- package/es/table/pipeline/features/filter/util.js +67 -0
- package/es/table/pipeline/features/index.d.ts +16 -0
- package/es/table/pipeline/features/index.js +16 -0
- package/es/table/pipeline/features/multiSelect.d.ts +27 -0
- package/es/table/pipeline/features/multiSelect.js +208 -0
- package/es/table/pipeline/features/rowDetail.d.ts +35 -0
- package/es/table/pipeline/features/rowDetail.js +254 -0
- package/es/table/pipeline/features/rowGrouping.d.ts +14 -0
- package/es/table/pipeline/features/rowGrouping.js +200 -0
- package/es/table/pipeline/features/singleSelect.d.ts +23 -0
- package/es/table/pipeline/features/singleSelect.js +122 -0
- package/es/table/pipeline/features/sort.d.ts +40 -0
- package/es/table/pipeline/features/sort.js +332 -0
- package/es/table/pipeline/features/tips.d.ts +2 -0
- package/es/table/pipeline/features/tips.js +57 -0
- package/es/table/pipeline/features/treeMode.d.ts +37 -0
- package/es/table/pipeline/features/treeMode.js +234 -0
- package/es/table/pipeline/features/treeSelect.d.ts +38 -0
- package/es/table/pipeline/features/treeSelect.js +154 -0
- package/es/table/pipeline/index.d.ts +3 -0
- package/es/table/pipeline/index.js +3 -0
- package/es/table/pipeline/pipeline.d.ts +85 -0
- package/es/table/pipeline/pipeline.js +272 -0
- package/es/table/pivot/cross-table/buildCrossTable.d.ts +14 -0
- package/es/table/pivot/cross-table/buildCrossTable.js +294 -0
- package/es/table/pivot/cross-table/constants.d.ts +1 -0
- package/es/table/pivot/cross-table/constants.js +1 -0
- package/es/table/pivot/cross-table/cross-table.d.ts +18 -0
- package/es/table/pivot/cross-table/cross-table.js +55 -0
- package/es/table/pivot/cross-table/index.d.ts +4 -0
- package/es/table/pivot/cross-table/index.js +3 -0
- package/es/table/pivot/cross-table/interfaces.d.ts +29 -0
- package/es/table/pivot/cross-table/interfaces.js +0 -0
- package/es/table/pivot/cross-table/internals.d.ts +13 -0
- package/es/table/pivot/cross-table/internals.js +0 -0
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.d.ts +14 -0
- package/es/table/pivot/cross-tree-table/buildCrossTreeTable.js +219 -0
- package/es/table/pivot/cross-tree-table/cross-tree-table.d.ts +38 -0
- package/es/table/pivot/cross-tree-table/cross-tree-table.js +127 -0
- package/es/table/pivot/cross-tree-table/index.d.ts +2 -0
- package/es/table/pivot/cross-tree-table/index.js +2 -0
- package/es/table/pivot/pivot-utils/buildDrillTree.d.ts +16 -0
- package/es/table/pivot/pivot-utils/buildDrillTree.js +93 -0
- package/es/table/pivot/pivot-utils/builders.d.ts +26 -0
- package/es/table/pivot/pivot-utils/builders.js +252 -0
- package/es/table/pivot/pivot-utils/convert-utils.d.ts +31 -0
- package/es/table/pivot/pivot-utils/convert-utils.js +180 -0
- package/es/table/pivot/pivot-utils/index.d.ts +5 -0
- package/es/table/pivot/pivot-utils/index.js +4 -0
- package/es/table/pivot/pivot-utils/interfaces.d.ts +12 -0
- package/es/table/pivot/pivot-utils/interfaces.js +0 -0
- package/es/table/pivot/pivot-utils/simpleEncode.d.ts +1 -0
- package/es/table/pivot/pivot-utils/simpleEncode.js +7 -0
- package/es/table/style/css.js +2 -0
- package/es/table/style/index.css +0 -0
- package/es/table/style/index.d.ts +2 -0
- package/es/table/style/index.js +2 -0
- package/es/table/style/index.less +1 -0
- package/es/table/transforms/autoRowSpan.d.ts +3 -0
- package/es/table/transforms/autoRowSpan.js +73 -0
- package/es/table/transforms/autoWidth.d.ts +25 -0
- package/es/table/transforms/autoWidth.js +160 -0
- package/es/table/transforms/buildTree.d.ts +3 -0
- package/es/table/transforms/buildTree.js +15 -0
- package/es/table/transforms/columnHover.d.ts +17 -0
- package/es/table/transforms/columnHover.js +59 -0
- package/es/table/transforms/columnRangeHover.d.ts +17 -0
- package/es/table/transforms/columnRangeHover.js +94 -0
- package/es/table/transforms/columnResize.d.ts +27 -0
- package/es/table/transforms/columnResize.js +152 -0
- package/es/table/transforms/flatten.d.ts +3 -0
- package/es/table/transforms/flatten.js +16 -0
- package/es/table/transforms/index.d.ts +12 -0
- package/es/table/transforms/index.js +12 -0
- package/es/table/transforms/orderField.d.ts +3 -0
- package/es/table/transforms/orderField.js +22 -0
- package/es/table/transforms/sort.d.ts +43 -0
- package/es/table/transforms/sort.js +338 -0
- package/es/table/transforms/tips.d.ts +8 -0
- package/es/table/transforms/tips.js +54 -0
- package/es/table/transforms/treeMode.d.ts +30 -0
- package/es/table/transforms/treeMode.js +252 -0
- package/es/table/transforms/visible.d.ts +5 -0
- package/es/table/transforms/visible.js +19 -0
- package/es/table/transforms/warnTransformsDeprecated.d.ts +1 -0
- package/es/table/transforms/warnTransformsDeprecated.js +8 -0
- package/es/table/use/useResizeObserver.d.ts +2 -0
- package/es/table/use/useResizeObserver.js +20 -0
- package/es/table/utils/applyTransforms.d.ts +6 -0
- package/es/table/utils/applyTransforms.js +15 -0
- package/es/table/utils/buildTree.d.ts +36 -0
- package/es/table/utils/buildTree.js +119 -0
- package/es/table/utils/collectNodes.d.ts +8 -0
- package/es/table/utils/collectNodes.js +59 -0
- package/es/table/utils/console.d.ts +11 -0
- package/es/table/utils/console.js +58 -0
- package/es/table/utils/copyToClipboard.d.ts +3 -0
- package/es/table/utils/copyToClipboard.js +30 -0
- package/es/table/utils/element.d.ts +42 -0
- package/es/table/utils/element.js +228 -0
- package/es/table/utils/exportTableAsExcel.d.ts +4 -0
- package/es/table/utils/exportTableAsExcel.js +188 -0
- package/es/table/utils/getTreeDepth.d.ts +3 -0
- package/es/table/utils/getTreeDepth.js +41 -0
- package/es/table/utils/groupBy.d.ts +1 -0
- package/es/table/utils/groupBy.js +37 -0
- package/es/table/utils/index.d.ts +18 -0
- package/es/table/utils/index.js +18 -0
- package/es/table/utils/isGroupColumn.d.ts +2 -0
- package/es/table/utils/isGroupColumn.js +7 -0
- package/es/table/utils/isLeafNode.d.ts +2 -0
- package/es/table/utils/isLeafNode.js +4 -0
- package/es/table/utils/layeredFilter.d.ts +2 -0
- package/es/table/utils/layeredFilter.js +25 -0
- package/es/table/utils/layeredSort.d.ts +5 -0
- package/es/table/utils/layeredSort.js +26 -0
- package/es/table/utils/makeRecursiveMapper.d.ts +9 -0
- package/es/table/utils/makeRecursiveMapper.js +76 -0
- package/es/table/utils/mergeCellProps.d.ts +8 -0
- package/es/table/utils/mergeCellProps.js +67 -0
- package/es/table/utils/others.d.ts +16 -0
- package/es/table/utils/others.js +80 -0
- package/es/table/utils/proto.d.ts +21 -0
- package/es/table/utils/proto.js +106 -0
- package/es/table/utils/smartCompare.d.ts +9 -0
- package/es/table/utils/smartCompare.js +51 -0
- package/es/table/utils/traverseColumn.d.ts +11 -0
- package/es/table/utils/traverseColumn.js +88 -0
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.d.ts +22 -0
- package/es/table/utils/tree-data-helpers/StrictTreeDataHelper.js +138 -0
- package/es/table/utils/tree-data-helpers/TreeDataHelper.d.ts +26 -0
- package/es/table/utils/tree-data-helpers/TreeDataHelper.js +337 -0
- package/lib/_utils/arrayUtil.d.ts +5 -0
- package/lib/_utils/arrayUtil.js +26 -0
- package/lib/_utils/devwarning.d.ts +1 -0
- package/lib/_utils/devwarning.js +21 -0
- package/lib/_utils/formatUtil.d.ts +46 -0
- package/lib/_utils/formatUtil.js +358 -0
- package/lib/_utils/hooks.d.ts +51 -0
- package/lib/_utils/hooks.js +187 -0
- package/lib/_utils/index.d.ts +8 -0
- package/lib/_utils/index.js +28 -0
- package/lib/_utils/numberUtil.d.ts +34 -0
- package/lib/_utils/numberUtil.js +202 -0
- package/lib/_utils/omit.d.ts +1 -0
- package/lib/_utils/omit.js +21 -0
- package/lib/_utils/react-children.d.ts +2 -0
- package/lib/_utils/react-children.js +20 -0
- package/lib/_utils/type.d.ts +12 -0
- package/lib/_utils/type.js +27 -0
- package/lib/_utils/usePopper.d.ts +29 -0
- package/lib/_utils/usePopper.js +574 -0
- package/lib/config-provider/ConfigContext.d.ts +22 -0
- package/lib/config-provider/ConfigContext.js +19 -0
- package/lib/config-provider/compDefaultProps.d.ts +8 -0
- package/lib/config-provider/compDefaultProps.js +17 -0
- package/lib/config-provider/configProvider.d.ts +11 -0
- package/lib/config-provider/configProvider.js +56 -0
- package/lib/config-provider/defaultConfig.d.ts +10 -0
- package/lib/config-provider/defaultConfig.js +30 -0
- package/lib/config-provider/index.d.ts +6 -0
- package/lib/config-provider/index.js +37 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +45 -0
- package/lib/locale/index.d.ts +3 -0
- package/lib/locale/index.js +25 -0
- package/lib/locale/locale.d.ts +50 -0
- package/lib/locale/locale.js +277 -0
- package/lib/locale/zh-CN.d.ts +8 -0
- package/lib/locale/zh-CN.js +15 -0
- package/lib/style/color/colors.less +2 -0
- package/lib/style/components.less +1 -0
- package/lib/style/core/index.less +2 -0
- package/lib/style/core/motion/other.less +28 -0
- package/lib/style/core/motion/slide.less +53 -0
- package/lib/style/core/motion.less +2 -0
- package/lib/style/core/reset.less +186 -0
- package/lib/style/css.js +3 -0
- package/lib/style/index.css +410 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +3 -0
- package/lib/style/index.less +2 -0
- package/lib/style/mixins/index.less +19 -0
- package/lib/style/mixins/overlay.less +22 -0
- package/lib/style/mixins/reset.less +13 -0
- package/lib/style/themes/default.less +445 -0
- package/lib/style/themes/index.less +1 -0
- package/lib/table/base/calculations.d.ts +5 -0
- package/lib/table/base/calculations.js +385 -0
- package/lib/table/base/colgroup.d.ts +5 -0
- package/lib/table/base/colgroup.js +33 -0
- package/lib/table/base/empty.d.ts +9 -0
- package/lib/table/base/empty.js +54 -0
- package/lib/table/base/header.d.ts +5 -0
- package/lib/table/base/header.js +340 -0
- package/lib/table/base/helpers/SpanManager.d.ts +9 -0
- package/lib/table/base/helpers/SpanManager.js +59 -0
- package/lib/table/base/helpers/TableDOMUtils.d.ts +18 -0
- package/lib/table/base/helpers/TableDOMUtils.js +113 -0
- package/lib/table/base/helpers/__test__/SpanManager.test.d.ts +1 -0
- package/lib/table/base/helpers/__test__/SpanManager.test.js +23 -0
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.d.ts +1 -0
- package/lib/table/base/helpers/__test__/TableDOMUtils.test.js +41 -0
- package/lib/table/base/helpers/__test__/rowHeightManager.test.d.ts +1 -0
- package/lib/table/base/helpers/__test__/rowHeightManager.test.js +33 -0
- package/lib/table/base/helpers/__test__/visible-part.test.d.ts +1 -0
- package/lib/table/base/helpers/__test__/visible-part.test.js +31 -0
- package/lib/table/base/helpers/rowHeightManager.d.ts +7 -0
- package/lib/table/base/helpers/rowHeightManager.js +170 -0
- package/lib/table/base/helpers/visible-part.d.ts +23 -0
- package/lib/table/base/helpers/visible-part.js +72 -0
- package/lib/table/base/html-table.d.ts +15 -0
- package/lib/table/base/html-table.js +149 -0
- package/lib/table/base/index.d.ts +3 -0
- package/lib/table/base/index.js +21 -0
- package/lib/table/base/interfaces.d.ts +54 -0
- package/lib/table/base/interfaces.js +0 -0
- package/lib/table/base/loading.d.ts +13 -0
- package/lib/table/base/loading.js +71 -0
- package/lib/table/base/styles.d.ts +132 -0
- package/lib/table/base/styles.js +136 -0
- package/lib/table/base/table.d.ts +150 -0
- package/lib/table/base/table.js +773 -0
- package/lib/table/base/utils.d.ts +36 -0
- package/lib/table/base/utils.js +234 -0
- package/lib/table/common-views.d.ts +24 -0
- package/lib/table/common-views.js +90 -0
- package/lib/table/index.d.ts +6 -0
- package/lib/table/index.js +85 -0
- package/lib/table/interfaces.d.ts +98 -0
- package/lib/table/interfaces.js +0 -0
- package/lib/table/internals.d.ts +14 -0
- package/lib/table/internals.js +64 -0
- package/lib/table/pipeline/features/__test__/multiSelect.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/multiSelect.test.js +163 -0
- package/lib/table/pipeline/features/__test__/rowDetail.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/rowDetail.test.js +230 -0
- package/lib/table/pipeline/features/__test__/rowGrouping.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/rowGrouping.test.js +129 -0
- package/lib/table/pipeline/features/__test__/singleSelect.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/singleSelect.test.js +201 -0
- package/lib/table/pipeline/features/__test__/sort.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/sort.test.js +218 -0
- package/lib/table/pipeline/features/__test__/tips.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/tips.test.js +133 -0
- package/lib/table/pipeline/features/__test__/treeMode.test.d.ts +1 -0
- package/lib/table/pipeline/features/__test__/treeMode.test.js +206 -0
- package/lib/table/pipeline/features/autoFill.d.ts +4 -0
- package/lib/table/pipeline/features/autoFill.js +80 -0
- package/lib/table/pipeline/features/autoRowSpan.d.ts +2 -0
- package/lib/table/pipeline/features/autoRowSpan.js +84 -0
- package/lib/table/pipeline/features/buildTree.d.ts +2 -0
- package/lib/table/pipeline/features/buildTree.js +16 -0
- package/lib/table/pipeline/features/columnDrag.d.ts +6 -0
- package/lib/table/pipeline/features/columnDrag.js +278 -0
- package/lib/table/pipeline/features/columnFilter.d.ts +20 -0
- package/lib/table/pipeline/features/columnFilter.js +197 -0
- package/lib/table/pipeline/features/columnHover.d.ts +12 -0
- package/lib/table/pipeline/features/columnHover.js +62 -0
- package/lib/table/pipeline/features/columnRangeHover.d.ts +15 -0
- package/lib/table/pipeline/features/columnRangeHover.js +95 -0
- package/lib/table/pipeline/features/columnResizeWidth.d.ts +21 -0
- package/lib/table/pipeline/features/columnResizeWidth.js +192 -0
- package/lib/table/pipeline/features/contextMenu.d.ts +14 -0
- package/lib/table/pipeline/features/contextMenu.js +397 -0
- package/lib/table/pipeline/features/filter/DefaultFilterContent.d.ts +4 -0
- package/lib/table/pipeline/features/filter/DefaultFilterContent.js +112 -0
- package/lib/table/pipeline/features/filter/Filter.d.ts +17 -0
- package/lib/table/pipeline/features/filter/Filter.js +129 -0
- package/lib/table/pipeline/features/filter/FilterPanel.d.ts +20 -0
- package/lib/table/pipeline/features/filter/FilterPanel.js +98 -0
- package/lib/table/pipeline/features/filter/__test__/Filter.test.d.ts +1 -0
- package/lib/table/pipeline/features/filter/__test__/Filter.test.js +36 -0
- package/lib/table/pipeline/features/filter/index.d.ts +4 -0
- package/lib/table/pipeline/features/filter/index.js +39 -0
- package/lib/table/pipeline/features/filter/util.d.ts +10 -0
- package/lib/table/pipeline/features/filter/util.js +77 -0
- package/lib/table/pipeline/features/index.d.ts +16 -0
- package/lib/table/pipeline/features/index.js +141 -0
- package/lib/table/pipeline/features/multiSelect.d.ts +27 -0
- package/lib/table/pipeline/features/multiSelect.js +227 -0
- package/lib/table/pipeline/features/rowDetail.d.ts +35 -0
- package/lib/table/pipeline/features/rowDetail.js +283 -0
- package/lib/table/pipeline/features/rowGrouping.d.ts +14 -0
- package/lib/table/pipeline/features/rowGrouping.js +227 -0
- package/lib/table/pipeline/features/singleSelect.d.ts +23 -0
- package/lib/table/pipeline/features/singleSelect.js +138 -0
- package/lib/table/pipeline/features/sort.d.ts +40 -0
- package/lib/table/pipeline/features/sort.js +361 -0
- package/lib/table/pipeline/features/tips.d.ts +2 -0
- package/lib/table/pipeline/features/tips.js +73 -0
- package/lib/table/pipeline/features/treeMode.d.ts +37 -0
- package/lib/table/pipeline/features/treeMode.js +266 -0
- package/lib/table/pipeline/features/treeSelect.d.ts +38 -0
- package/lib/table/pipeline/features/treeSelect.js +169 -0
- package/lib/table/pipeline/index.d.ts +3 -0
- package/lib/table/pipeline/index.js +26 -0
- package/lib/table/pipeline/pipeline.d.ts +85 -0
- package/lib/table/pipeline/pipeline.js +291 -0
- package/lib/table/pivot/cross-table/buildCrossTable.d.ts +14 -0
- package/lib/table/pivot/cross-table/buildCrossTable.js +313 -0
- package/lib/table/pivot/cross-table/constants.d.ts +1 -0
- package/lib/table/pivot/cross-table/constants.js +8 -0
- package/lib/table/pivot/cross-table/cross-table.d.ts +18 -0
- package/lib/table/pivot/cross-table/cross-table.js +71 -0
- package/lib/table/pivot/cross-table/index.d.ts +4 -0
- package/lib/table/pivot/cross-table/index.js +31 -0
- package/lib/table/pivot/cross-table/interfaces.d.ts +29 -0
- package/lib/table/pivot/cross-table/interfaces.js +0 -0
- package/lib/table/pivot/cross-table/internals.d.ts +13 -0
- package/lib/table/pivot/cross-table/internals.js +0 -0
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.d.ts +14 -0
- package/lib/table/pivot/cross-tree-table/buildCrossTreeTable.js +240 -0
- package/lib/table/pivot/cross-tree-table/cross-tree-table.d.ts +38 -0
- package/lib/table/pivot/cross-tree-table/cross-tree-table.js +144 -0
- package/lib/table/pivot/cross-tree-table/index.d.ts +2 -0
- package/lib/table/pivot/cross-tree-table/index.js +23 -0
- package/lib/table/pivot/pivot-utils/buildDrillTree.d.ts +16 -0
- package/lib/table/pivot/pivot-utils/buildDrillTree.js +106 -0
- package/lib/table/pivot/pivot-utils/builders.d.ts +26 -0
- package/lib/table/pivot/pivot-utils/builders.js +272 -0
- package/lib/table/pivot/pivot-utils/convert-utils.d.ts +31 -0
- package/lib/table/pivot/pivot-utils/convert-utils.js +204 -0
- package/lib/table/pivot/pivot-utils/index.d.ts +5 -0
- package/lib/table/pivot/pivot-utils/index.js +59 -0
- package/lib/table/pivot/pivot-utils/interfaces.d.ts +12 -0
- package/lib/table/pivot/pivot-utils/interfaces.js +0 -0
- package/lib/table/pivot/pivot-utils/simpleEncode.d.ts +1 -0
- package/lib/table/pivot/pivot-utils/simpleEncode.js +14 -0
- package/lib/table/style/css.js +5 -0
- package/lib/table/style/index.css +0 -0
- package/lib/table/style/index.d.ts +2 -0
- package/lib/table/style/index.js +5 -0
- package/lib/table/style/index.less +1 -0
- package/lib/table/transforms/autoRowSpan.d.ts +3 -0
- package/lib/table/transforms/autoRowSpan.js +86 -0
- package/lib/table/transforms/autoWidth.d.ts +25 -0
- package/lib/table/transforms/autoWidth.js +187 -0
- package/lib/table/transforms/buildTree.d.ts +3 -0
- package/lib/table/transforms/buildTree.js +23 -0
- package/lib/table/transforms/columnHover.d.ts +17 -0
- package/lib/table/transforms/columnHover.js +74 -0
- package/lib/table/transforms/columnRangeHover.d.ts +17 -0
- package/lib/table/transforms/columnRangeHover.js +110 -0
- package/lib/table/transforms/columnResize.d.ts +27 -0
- package/lib/table/transforms/columnResize.js +176 -0
- package/lib/table/transforms/flatten.d.ts +3 -0
- package/lib/table/transforms/flatten.js +24 -0
- package/lib/table/transforms/index.d.ts +12 -0
- package/lib/table/transforms/index.js +131 -0
- package/lib/table/transforms/orderField.d.ts +3 -0
- package/lib/table/transforms/orderField.js +33 -0
- package/lib/table/transforms/sort.d.ts +43 -0
- package/lib/table/transforms/sort.js +369 -0
- package/lib/table/transforms/tips.d.ts +8 -0
- package/lib/table/transforms/tips.js +71 -0
- package/lib/table/transforms/treeMode.d.ts +30 -0
- package/lib/table/transforms/treeMode.js +286 -0
- package/lib/table/transforms/visible.d.ts +5 -0
- package/lib/table/transforms/visible.js +31 -0
- package/lib/table/transforms/warnTransformsDeprecated.d.ts +1 -0
- package/lib/table/transforms/warnTransformsDeprecated.js +19 -0
- package/lib/table/use/useResizeObserver.d.ts +2 -0
- package/lib/table/use/useResizeObserver.js +32 -0
- package/lib/table/utils/applyTransforms.d.ts +6 -0
- package/lib/table/utils/applyTransforms.js +24 -0
- package/lib/table/utils/buildTree.d.ts +36 -0
- package/lib/table/utils/buildTree.js +140 -0
- package/lib/table/utils/collectNodes.d.ts +8 -0
- package/lib/table/utils/collectNodes.js +72 -0
- package/lib/table/utils/console.d.ts +11 -0
- package/lib/table/utils/console.js +68 -0
- package/lib/table/utils/copyToClipboard.d.ts +3 -0
- package/lib/table/utils/copyToClipboard.js +40 -0
- package/lib/table/utils/element.d.ts +42 -0
- package/lib/table/utils/element.js +243 -0
- package/lib/table/utils/exportTableAsExcel.d.ts +4 -0
- package/lib/table/utils/exportTableAsExcel.js +205 -0
- package/lib/table/utils/getTreeDepth.d.ts +3 -0
- package/lib/table/utils/getTreeDepth.js +54 -0
- package/lib/table/utils/groupBy.d.ts +1 -0
- package/lib/table/utils/groupBy.js +48 -0
- package/lib/table/utils/index.d.ts +18 -0
- package/lib/table/utils/index.js +187 -0
- package/lib/table/utils/isGroupColumn.d.ts +2 -0
- package/lib/table/utils/isGroupColumn.js +17 -0
- package/lib/table/utils/isLeafNode.d.ts +2 -0
- package/lib/table/utils/isLeafNode.js +11 -0
- package/lib/table/utils/layeredFilter.d.ts +2 -0
- package/lib/table/utils/layeredFilter.js +38 -0
- package/lib/table/utils/layeredSort.d.ts +5 -0
- package/lib/table/utils/layeredSort.js +37 -0
- package/lib/table/utils/makeRecursiveMapper.d.ts +9 -0
- package/lib/table/utils/makeRecursiveMapper.js +94 -0
- package/lib/table/utils/mergeCellProps.d.ts +8 -0
- package/lib/table/utils/mergeCellProps.js +78 -0
- package/lib/table/utils/others.d.ts +16 -0
- package/lib/table/utils/others.js +108 -0
- package/lib/table/utils/proto.d.ts +21 -0
- package/lib/table/utils/proto.js +117 -0
- package/lib/table/utils/smartCompare.d.ts +9 -0
- package/lib/table/utils/smartCompare.js +58 -0
- package/lib/table/utils/traverseColumn.d.ts +11 -0
- package/lib/table/utils/traverseColumn.js +103 -0
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.d.ts +22 -0
- package/lib/table/utils/tree-data-helpers/StrictTreeDataHelper.js +154 -0
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.d.ts +26 -0
- package/lib/table/utils/tree-data-helpers/TreeDataHelper.js +358 -0
- package/package.json +213 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useTablePipeline = useTablePipeline;
|
|
9
|
+
exports.TablePipeline = void 0;
|
|
10
|
+
|
|
11
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
12
|
+
|
|
13
|
+
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
14
|
+
|
|
15
|
+
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
16
|
+
|
|
17
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
18
|
+
|
|
19
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
20
|
+
|
|
21
|
+
var _extends3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
22
|
+
|
|
23
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
24
|
+
|
|
25
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
26
|
+
|
|
27
|
+
var _react = require("react");
|
|
28
|
+
|
|
29
|
+
var _utils = require("../utils");
|
|
30
|
+
|
|
31
|
+
var _autoFill = require("./features/autoFill");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
|
|
35
|
+
*
|
|
36
|
+
* 1. ctx:上下文环境对象,step(流水线上的一步)可以对 ctx 中的字段进行读写。
|
|
37
|
+
* ctx 中部分字段名称有特定的含义(例如 primaryKey 表示行的主键),使用自定义的上下文信息时注意避开这些名称。
|
|
38
|
+
*
|
|
39
|
+
* 2. rowPropsGetters:getRowProps 回调队列,step 可以通过 pipeline.appendRowPropsGetter 向队列中追加回调函数,
|
|
40
|
+
* 在调用 pipeline.props() 队列中的所有函数会组合形成最终的 getRowProps
|
|
41
|
+
*
|
|
42
|
+
* 3. 当前流水线的状态,包括 dataSource, columns, rowPropsGetters 三个部分
|
|
43
|
+
*
|
|
44
|
+
* 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
|
|
45
|
+
* */
|
|
46
|
+
var TablePipeline = /*#__PURE__*/function () {
|
|
47
|
+
function TablePipeline(_ref) {
|
|
48
|
+
var state = _ref.state,
|
|
49
|
+
setState = _ref.setState,
|
|
50
|
+
ctx = _ref.ctx,
|
|
51
|
+
ref = _ref.ref;
|
|
52
|
+
(0, _classCallCheck2.default)(this, TablePipeline);
|
|
53
|
+
this._snapshots = {};
|
|
54
|
+
this._rowPropsGetters = [];
|
|
55
|
+
this._tableProps = {};
|
|
56
|
+
this.ctx = {
|
|
57
|
+
components: {},
|
|
58
|
+
indents: TablePipeline.defaultIndents
|
|
59
|
+
};
|
|
60
|
+
this.state = state;
|
|
61
|
+
this.setState = setState;
|
|
62
|
+
this.ref = ref;
|
|
63
|
+
(0, _extends3.default)(this.ctx, ctx);
|
|
64
|
+
} // Generate a pseudo-GUID by concatenating random hexadecimal.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
(0, _createClass2.default)(TablePipeline, [{
|
|
68
|
+
key: "guid",
|
|
69
|
+
value: function guid() {
|
|
70
|
+
function S4() {
|
|
71
|
+
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "appendRowPropsGetter",
|
|
78
|
+
value: function appendRowPropsGetter(getter) {
|
|
79
|
+
this._rowPropsGetters.push(getter);
|
|
80
|
+
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "addTableProps",
|
|
85
|
+
value: function addTableProps(props) {
|
|
86
|
+
this._tableProps = (0, _extends3.default)((0, _extends3.default)({}, this._tableProps), props);
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "getDataSource",
|
|
90
|
+
value: function getDataSource(name) {
|
|
91
|
+
if (name == null) {
|
|
92
|
+
return this._dataSource;
|
|
93
|
+
} else {
|
|
94
|
+
return this._snapshots[name].dataSource;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "getColumns",
|
|
99
|
+
value: function getColumns(name) {
|
|
100
|
+
if (name == null) {
|
|
101
|
+
return this._columns;
|
|
102
|
+
} else {
|
|
103
|
+
return this._snapshots[name].columns;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "getStateAtKey",
|
|
108
|
+
value: function getStateAtKey(stateKey, defaultValue) {
|
|
109
|
+
var _a;
|
|
110
|
+
|
|
111
|
+
return (_a = this.state[stateKey]) !== null && _a !== void 0 ? _a : defaultValue;
|
|
112
|
+
}
|
|
113
|
+
/** 将 stateKey 对应的状态设置为 partialState */
|
|
114
|
+
|
|
115
|
+
}, {
|
|
116
|
+
key: "setStateAtKey",
|
|
117
|
+
value: function setStateAtKey(stateKey, partialState, extraInfo) {
|
|
118
|
+
this.setState(function (prev) {
|
|
119
|
+
return (0, _extends3.default)((0, _extends3.default)({}, prev), (0, _defineProperty2.default)({}, stateKey, partialState));
|
|
120
|
+
}, stateKey, partialState, extraInfo);
|
|
121
|
+
}
|
|
122
|
+
/** 确保 primaryKey 已被设置,并返回 primaryKey */
|
|
123
|
+
|
|
124
|
+
}, {
|
|
125
|
+
key: "ensurePrimaryKey",
|
|
126
|
+
value: function ensurePrimaryKey(hint) {
|
|
127
|
+
if (this.ctx.primaryKey == null) {
|
|
128
|
+
throw new Error(hint ? "\u4F7F\u7528 ".concat(hint, " \u4E4B\u524D\u5FC5\u987B\u5148\u8BBE\u7F6E primaryKey") : '必须先设置 primaryKey');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return this.ctx.primaryKey;
|
|
132
|
+
}
|
|
133
|
+
/** 设置流水线的输入数据 */
|
|
134
|
+
|
|
135
|
+
}, {
|
|
136
|
+
key: "input",
|
|
137
|
+
value: function input(_input) {
|
|
138
|
+
var _context,
|
|
139
|
+
_this = this;
|
|
140
|
+
|
|
141
|
+
if (this._dataSource != null || this._columns != null) {
|
|
142
|
+
throw new Error('input 不能调用两次');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
this._dataSource = _input.dataSource;
|
|
146
|
+
this._columns = (0, _map.default)(_context = _input.columns).call(_context, function (col) {
|
|
147
|
+
return (0, _extends3.default)((0, _extends3.default)({}, col), {
|
|
148
|
+
key: _this.guid()
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
this.snapshot('input');
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
/** 设置 dataSource */
|
|
155
|
+
|
|
156
|
+
}, {
|
|
157
|
+
key: "dataSource",
|
|
158
|
+
value: function dataSource(rows) {
|
|
159
|
+
this._dataSource = rows;
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
/** 设置 columns */
|
|
163
|
+
|
|
164
|
+
}, {
|
|
165
|
+
key: "columns",
|
|
166
|
+
value: function columns(cols) {
|
|
167
|
+
this._columns = cols;
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
/** 设置主键 */
|
|
171
|
+
|
|
172
|
+
}, {
|
|
173
|
+
key: "primaryKey",
|
|
174
|
+
value: function primaryKey(key) {
|
|
175
|
+
this.ctx.primaryKey = key;
|
|
176
|
+
return this;
|
|
177
|
+
}
|
|
178
|
+
/** 保存快照 */
|
|
179
|
+
|
|
180
|
+
}, {
|
|
181
|
+
key: "snapshot",
|
|
182
|
+
value: function snapshot(name) {
|
|
183
|
+
var _context2;
|
|
184
|
+
|
|
185
|
+
this._snapshots[name] = {
|
|
186
|
+
dataSource: this._dataSource,
|
|
187
|
+
columns: this._columns,
|
|
188
|
+
rowPropsGetters: (0, _slice.default)(_context2 = this._rowPropsGetters).call(_context2)
|
|
189
|
+
};
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
/** @deprecated
|
|
193
|
+
* 应用一个 kd-table Table transform */
|
|
194
|
+
|
|
195
|
+
}, {
|
|
196
|
+
key: "useTransform",
|
|
197
|
+
value: function useTransform(transform) {
|
|
198
|
+
var next = transform({
|
|
199
|
+
dataSource: this.getDataSource(),
|
|
200
|
+
columns: this.getColumns()
|
|
201
|
+
});
|
|
202
|
+
return this.dataSource(next.dataSource).columns(next.columns);
|
|
203
|
+
}
|
|
204
|
+
/** 使用 pipeline 功能拓展 */
|
|
205
|
+
|
|
206
|
+
}, {
|
|
207
|
+
key: "use",
|
|
208
|
+
value: function use(step) {
|
|
209
|
+
return step(this);
|
|
210
|
+
}
|
|
211
|
+
/** 转换 dataSource */
|
|
212
|
+
|
|
213
|
+
}, {
|
|
214
|
+
key: "mapDataSource",
|
|
215
|
+
value: function mapDataSource(mapper) {
|
|
216
|
+
return this.dataSource(mapper(this.getDataSource()));
|
|
217
|
+
}
|
|
218
|
+
/** 转换 columns */
|
|
219
|
+
|
|
220
|
+
}, {
|
|
221
|
+
key: "mapColumns",
|
|
222
|
+
value: function mapColumns(mapper) {
|
|
223
|
+
return this.columns(mapper(this.getColumns()));
|
|
224
|
+
}
|
|
225
|
+
/** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
|
|
226
|
+
|
|
227
|
+
}, {
|
|
228
|
+
key: "getProps",
|
|
229
|
+
value: function getProps() {
|
|
230
|
+
var _this2 = this;
|
|
231
|
+
|
|
232
|
+
this.use((0, _autoFill.autoFillTableWidth)());
|
|
233
|
+
var result = {
|
|
234
|
+
dataSource: this._dataSource,
|
|
235
|
+
columns: this._columns
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
if (this.ctx.primaryKey) {
|
|
239
|
+
result.primaryKey = this.ctx.primaryKey;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (this._rowPropsGetters.length > 0) {
|
|
243
|
+
result.getRowProps = function (row, rowIndex) {
|
|
244
|
+
var _context3;
|
|
245
|
+
|
|
246
|
+
return (0, _reduce.default)(_context3 = _this2._rowPropsGetters).call(_context3, function (res, get) {
|
|
247
|
+
return (0, _utils.mergeCellProps)(res, get(row, rowIndex));
|
|
248
|
+
}, {});
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
result.getTableProps = function () {
|
|
253
|
+
return _this2._tableProps;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
result.setTableWidth = function (tableWidth) {
|
|
257
|
+
var preTableWidth = _this2.getStateAtKey(_autoFill.tableWidthKey);
|
|
258
|
+
|
|
259
|
+
if (preTableWidth !== tableWidth) {
|
|
260
|
+
_this2.setStateAtKey(_autoFill.tableWidthKey, tableWidth);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
}]);
|
|
267
|
+
return TablePipeline;
|
|
268
|
+
}();
|
|
269
|
+
|
|
270
|
+
exports.TablePipeline = TablePipeline;
|
|
271
|
+
TablePipeline.defaultIndents = {
|
|
272
|
+
iconIndent: -8,
|
|
273
|
+
iconWidth: 16,
|
|
274
|
+
iconGap: 0,
|
|
275
|
+
indentSize: 16
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
function useTablePipeline(ctx) {
|
|
279
|
+
var _useState = (0, _react.useState)({}),
|
|
280
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
281
|
+
state = _useState2[0],
|
|
282
|
+
setState = _useState2[1];
|
|
283
|
+
|
|
284
|
+
var ref = (0, _react.useRef)({});
|
|
285
|
+
return new TablePipeline({
|
|
286
|
+
state: state,
|
|
287
|
+
setState: setState,
|
|
288
|
+
ctx: ctx,
|
|
289
|
+
ref: ref
|
|
290
|
+
});
|
|
291
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableProps } from '../../base';
|
|
2
|
+
import { CrossTableProps } from './cross-table';
|
|
3
|
+
import { CrossTableLeftMetaColumn, LeftCrossTreeNode, TopCrossTreeNode } from './interfaces';
|
|
4
|
+
export interface BuildCrossTableOptions {
|
|
5
|
+
leftTree: LeftCrossTreeNode[];
|
|
6
|
+
topTree: TopCrossTreeNode[];
|
|
7
|
+
leftTotalNode?: LeftCrossTreeNode;
|
|
8
|
+
topTotalNode?: TopCrossTreeNode;
|
|
9
|
+
leftMetaColumns: CrossTableLeftMetaColumn[];
|
|
10
|
+
getValue: CrossTableProps['getValue'];
|
|
11
|
+
render?: CrossTableProps['render'];
|
|
12
|
+
getCellProps?: CrossTableProps['getCellProps'];
|
|
13
|
+
}
|
|
14
|
+
export default function buildCrossTable(options: BuildCrossTableOptions): Pick<TableProps, 'columns' | 'dataSource'>;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _sliceInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
4
|
+
|
|
5
|
+
var _Array$from = require("@babel/runtime-corejs3/core-js-stable/array/from");
|
|
6
|
+
|
|
7
|
+
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
8
|
+
|
|
9
|
+
var _getIteratorMethod = require("@babel/runtime-corejs3/core-js/get-iterator-method");
|
|
10
|
+
|
|
11
|
+
var _getIterator = require("@babel/runtime-corejs3/core-js/get-iterator");
|
|
12
|
+
|
|
13
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
14
|
+
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
exports.default = buildCrossTable;
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
23
|
+
|
|
24
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
|
|
25
|
+
|
|
26
|
+
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
|
|
27
|
+
|
|
28
|
+
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
29
|
+
|
|
30
|
+
var _utils = require("../../utils");
|
|
31
|
+
|
|
32
|
+
var _constants = require("./constants");
|
|
33
|
+
|
|
34
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof _Symbol === "undefined" || _getIteratorMethod(o) == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = _getIterator(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
35
|
+
|
|
36
|
+
function _unsupportedIterableToArray(o, minLen) { var _context4; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context4 = Object.prototype.toString.call(o)).call(_context4, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
+
|
|
38
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
39
|
+
|
|
40
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
41
|
+
var t = {};
|
|
42
|
+
|
|
43
|
+
for (var p in s) {
|
|
44
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (s != null && typeof _getOwnPropertySymbols.default === "function") for (var i = 0, p = (0, _getOwnPropertySymbols.default)(s); i < p.length; i++) {
|
|
48
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
49
|
+
}
|
|
50
|
+
return t;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function buildCrossTable(options) {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
|
|
56
|
+
var leftTotalNode = options.leftTotalNode,
|
|
57
|
+
topTotalNode = options.topTotalNode; // 有的时候 leftTree/topTree 是通过 node.children 传入的
|
|
58
|
+
// 此时 leftTree/topTree 等于 null 和等于空数组是等价的
|
|
59
|
+
// 故在这里兼容 leftTree/topTree 为空的情况
|
|
60
|
+
|
|
61
|
+
var leftTree = (_a = options.leftTree) !== null && _a !== void 0 ? _a : [];
|
|
62
|
+
var topTree = (_b = options.topTree) !== null && _b !== void 0 ? _b : [];
|
|
63
|
+
var leftMetaColumns = (_c = options.leftMetaColumns) !== null && _c !== void 0 ? _c : [];
|
|
64
|
+
var leftHeaderWidth = Math.max(leftMetaColumns.length, (0, _utils.getTreeDepth)(leftTree) + 1);
|
|
65
|
+
return {
|
|
66
|
+
columns: getColumns(),
|
|
67
|
+
dataSource: getDataSource()
|
|
68
|
+
};
|
|
69
|
+
/** 获取表格的列配置 */
|
|
70
|
+
|
|
71
|
+
function getColumns() {
|
|
72
|
+
var _context;
|
|
73
|
+
|
|
74
|
+
return (0, _concat.default)(_context = []).call(_context, (0, _toConsumableArray2.default)(getLeftPartColumns()), (0, _toConsumableArray2.default)(getDataPartColumns()));
|
|
75
|
+
|
|
76
|
+
function getLeftPartColumns() {
|
|
77
|
+
var _a;
|
|
78
|
+
|
|
79
|
+
var leftPartColumns = [];
|
|
80
|
+
|
|
81
|
+
for (var index = 0; index < leftHeaderWidth; index++) {
|
|
82
|
+
var metaCol = (_a = leftMetaColumns[index]) !== null && _a !== void 0 ? _a : {};
|
|
83
|
+
|
|
84
|
+
var getCellProps = metaCol.getCellProps,
|
|
85
|
+
render = metaCol.render,
|
|
86
|
+
staticMetaColConfig = __rest(metaCol, ["getCellProps", "render"]);
|
|
87
|
+
|
|
88
|
+
leftPartColumns.push((0, _extends2.default)((0, _extends2.default)({
|
|
89
|
+
columnType: 'left',
|
|
90
|
+
lock: true
|
|
91
|
+
}, staticMetaColConfig), {
|
|
92
|
+
getCellProps: leftHeaderGetCellPropsFactory(metaCol, index),
|
|
93
|
+
getSpanRect: leftHeaderGetSpanRectFactory(metaCol, index),
|
|
94
|
+
getValue: leftHeaderGetValueFactory(metaCol, index),
|
|
95
|
+
render: leftHeaderRenderFactory(metaCol, index)
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return leftPartColumns;
|
|
100
|
+
|
|
101
|
+
function leftHeaderGetCellPropsFactory(metaCol, colIndex) {
|
|
102
|
+
return function (_value, row, rowIndex) {
|
|
103
|
+
var _a;
|
|
104
|
+
|
|
105
|
+
var node = row.nodes[colIndex];
|
|
106
|
+
return (_a = metaCol.getCellProps) === null || _a === void 0 ? void 0 : _a.call(metaCol, node, colIndex);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function leftHeaderGetSpanRectFactory(metaCol, colIndex) {
|
|
111
|
+
return function (_value, row) {
|
|
112
|
+
return row.rects[colIndex];
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function leftHeaderGetValueFactory(metaCol, colIndex) {
|
|
117
|
+
return function (row, rowIndex) {
|
|
118
|
+
var node = row.nodes[colIndex];
|
|
119
|
+
return node.value;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function leftHeaderRenderFactory(metaCol, colIndex) {
|
|
124
|
+
return function (v, row, rowIndex) {
|
|
125
|
+
var _a;
|
|
126
|
+
|
|
127
|
+
var node = row.nodes[colIndex];
|
|
128
|
+
|
|
129
|
+
if (metaCol.render) {
|
|
130
|
+
return metaCol.render(node, colIndex);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (_a = node.title) !== null && _a !== void 0 ? _a : node.value;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** 获取表格数据部分的列配置 */
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
function getDataPartColumns() {
|
|
141
|
+
if (topTree.length > 0) {
|
|
142
|
+
return dfs(topTree, {
|
|
143
|
+
valuePath: [],
|
|
144
|
+
depth: 0
|
|
145
|
+
});
|
|
146
|
+
} else if (topTotalNode) {
|
|
147
|
+
return dfs([topTotalNode], {
|
|
148
|
+
valuePath: [],
|
|
149
|
+
depth: 0
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function dfs(nodes, ctx) {
|
|
156
|
+
var result = [];
|
|
157
|
+
|
|
158
|
+
var _iterator = _createForOfIteratorHelper(nodes),
|
|
159
|
+
_step;
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
163
|
+
var node = _step.value;
|
|
164
|
+
ctx.valuePath.push(node.value);
|
|
165
|
+
|
|
166
|
+
if ((0, _utils.isLeafNode)(node)) {
|
|
167
|
+
// 叶子节点
|
|
168
|
+
result.push(getDataColumn(node, ctx.depth));
|
|
169
|
+
} else {
|
|
170
|
+
var key = node.key,
|
|
171
|
+
value = node.value,
|
|
172
|
+
children = node.children,
|
|
173
|
+
others = __rest(node // 强制展开的节点
|
|
174
|
+
, ["key", "value", "children"]); // 强制展开的节点
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
result.push((0, _extends2.default)((0, _extends2.default)({
|
|
178
|
+
columnType: 'data-parent'
|
|
179
|
+
}, others), {
|
|
180
|
+
name: value,
|
|
181
|
+
children: dfs(children, {
|
|
182
|
+
valuePath: ctx.valuePath,
|
|
183
|
+
depth: ctx.depth + 1
|
|
184
|
+
})
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
ctx.valuePath.pop();
|
|
189
|
+
}
|
|
190
|
+
} catch (err) {
|
|
191
|
+
_iterator.e(err);
|
|
192
|
+
} finally {
|
|
193
|
+
_iterator.f();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function getDataColumn(topNode, topDepth) {
|
|
201
|
+
var columnGetValue = function columnGetValue(row) {
|
|
202
|
+
var leftDepth = row.nodes.length - 1;
|
|
203
|
+
var leftNode = row.nodes[leftDepth];
|
|
204
|
+
return options.getValue(leftNode, topNode, leftDepth, topDepth);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var key = topNode.key,
|
|
208
|
+
value = topNode.value,
|
|
209
|
+
children = topNode.children,
|
|
210
|
+
others = __rest(topNode, ["key", "value", "children"]);
|
|
211
|
+
|
|
212
|
+
return (0, _extends2.default)((0, _extends2.default)({
|
|
213
|
+
columnType: 'data'
|
|
214
|
+
}, others), {
|
|
215
|
+
getValue: columnGetValue,
|
|
216
|
+
name: value,
|
|
217
|
+
children: null,
|
|
218
|
+
render: function render(value, row) {
|
|
219
|
+
if (options.render) {
|
|
220
|
+
var leftDepth = row.nodes.length - 1;
|
|
221
|
+
var leftNode = row.nodes[leftDepth];
|
|
222
|
+
return options.render(value, leftNode, topNode, leftDepth, topDepth);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return value;
|
|
226
|
+
},
|
|
227
|
+
getCellProps: function getCellProps(value, row) {
|
|
228
|
+
if (options.getCellProps) {
|
|
229
|
+
var leftDepth = row.nodes.length - 1;
|
|
230
|
+
var leftNode = row.nodes[leftDepth];
|
|
231
|
+
return options.getCellProps(value, leftNode, topNode, leftDepth, topDepth);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function getDataSource() {
|
|
239
|
+
var flatRows = [];
|
|
240
|
+
var ctx = {
|
|
241
|
+
depth: 0,
|
|
242
|
+
nodes: [],
|
|
243
|
+
rects: [],
|
|
244
|
+
rowIndex: 0
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
if (leftTree.length > 0) {
|
|
248
|
+
dfs(leftTree, ctx);
|
|
249
|
+
} else if (leftTotalNode) {
|
|
250
|
+
dfs([leftTotalNode], ctx);
|
|
251
|
+
} // else 表格没有行,展示空表格
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
return flatRows;
|
|
255
|
+
|
|
256
|
+
function dfs(nodes, ctx) {
|
|
257
|
+
var count = 0;
|
|
258
|
+
|
|
259
|
+
var _iterator2 = _createForOfIteratorHelper(nodes),
|
|
260
|
+
_step2;
|
|
261
|
+
|
|
262
|
+
try {
|
|
263
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
264
|
+
var _context2, _context3, _row;
|
|
265
|
+
|
|
266
|
+
var node = _step2.value;
|
|
267
|
+
|
|
268
|
+
if (node.hidden) {
|
|
269
|
+
// 跳过被隐藏的节点
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var rect = {
|
|
274
|
+
top: ctx.rowIndex + count,
|
|
275
|
+
bottom: -1,
|
|
276
|
+
left: ctx.depth,
|
|
277
|
+
right: -1
|
|
278
|
+
};
|
|
279
|
+
var row = (_row = {}, (0, _defineProperty2.default)(_row, _constants.ROW_KEY, node.key), (0, _defineProperty2.default)(_row, "rects", (0, _concat.default)(_context2 = []).call(_context2, (0, _toConsumableArray2.default)(ctx.rects), [rect])), (0, _defineProperty2.default)(_row, "nodes", (0, _concat.default)(_context3 = []).call(_context3, (0, _toConsumableArray2.default)(ctx.nodes), [node])), _row);
|
|
280
|
+
|
|
281
|
+
if ((0, _utils.isLeafNode)(node)) {
|
|
282
|
+
rect.right = leftHeaderWidth;
|
|
283
|
+
rect.bottom = rect.top + 1;
|
|
284
|
+
flatRows.push(row);
|
|
285
|
+
count += 1;
|
|
286
|
+
} else {
|
|
287
|
+
ctx.rects.push(rect);
|
|
288
|
+
ctx.nodes.push(node);
|
|
289
|
+
var ret = dfs(node.children, {
|
|
290
|
+
nodes: ctx.nodes,
|
|
291
|
+
rects: ctx.rects,
|
|
292
|
+
depth: ctx.depth + 1,
|
|
293
|
+
rowIndex: ctx.rowIndex + count
|
|
294
|
+
});
|
|
295
|
+
ctx.rects.pop();
|
|
296
|
+
ctx.nodes.pop();
|
|
297
|
+
count += ret.count;
|
|
298
|
+
rect.right = rect.left + 1;
|
|
299
|
+
rect.bottom = rect.top + ret.count;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
} catch (err) {
|
|
303
|
+
_iterator2.e(err);
|
|
304
|
+
} finally {
|
|
305
|
+
_iterator2.f();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
count: count
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROW_KEY = "rowKey";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table, TableProps } from '../../base';
|
|
3
|
+
import { CellProps } from '../../interfaces';
|
|
4
|
+
import { CrossTableLeftMetaColumn, LeftCrossTreeNode, TopCrossTreeNode } from './interfaces';
|
|
5
|
+
export interface CrossTableProps extends Omit<TableProps, 'dataSource' | 'columns' | 'primaryKey'> {
|
|
6
|
+
BaseTableComponent?: any;
|
|
7
|
+
baseTableRef?: React.Ref<Table>;
|
|
8
|
+
leftTree: LeftCrossTreeNode[];
|
|
9
|
+
topTree: TopCrossTreeNode[];
|
|
10
|
+
leftTotalNode?: LeftCrossTreeNode;
|
|
11
|
+
topTotalNode?: TopCrossTreeNode;
|
|
12
|
+
leftMetaColumns?: CrossTableLeftMetaColumn[];
|
|
13
|
+
getValue(leftNode: LeftCrossTreeNode, topNode: TopCrossTreeNode, leftDepth: number, topDepth: number): any;
|
|
14
|
+
render?(value: any, leftNode: LeftCrossTreeNode, topNode: TopCrossTreeNode, leftDepth: number, topDepth: number): React.ReactNode;
|
|
15
|
+
getCellProps?(value: any, leftNode: LeftCrossTreeNode, topNode: TopCrossTreeNode, leftDepth: number, topDepth: number): CellProps;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: ({ BaseTableComponent, leftTree, leftTotalNode, topTree, topTotalNode, getValue, getCellProps, leftMetaColumns, render, baseTableRef, ...others }: CrossTableProps) => JSX.Element;
|
|
18
|
+
export default _default;
|