@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,38 @@
|
|
|
1
|
+
import { ArtColumn } from '../../interfaces';
|
|
2
|
+
import { TablePipeline } from '../pipeline';
|
|
3
|
+
export interface TreeSelectFeatureOptions {
|
|
4
|
+
/** 完整的树 */
|
|
5
|
+
tree: any[];
|
|
6
|
+
/** 虚拟的根节点值;该参数非空时,treeSelect 将会在 tree 参数之上再添加一个父节点 */
|
|
7
|
+
rootKey?: string;
|
|
8
|
+
/** 父子节点选中状态是否不再关联。设置为 true 之后,父节点和子节点的 value 独立管理,不再联动 */
|
|
9
|
+
checkStrictly?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 定义选中时回填的方式,可选值:
|
|
12
|
+
* - 'all'(返回所有选中的节点)
|
|
13
|
+
* - 'parent'(父子节点都选中时只返回父节点)
|
|
14
|
+
* - 'child'(父子节点都选中时只返回子节点)
|
|
15
|
+
*/
|
|
16
|
+
checkedStrategy?: 'all' | 'parent' | 'child';
|
|
17
|
+
/** 复选框所在列的位置 */
|
|
18
|
+
checkboxPlacement?: 'start' | 'end';
|
|
19
|
+
/** 复选框所在列的 column 配置,可指定 width,lock, title, align, features 等属性 */
|
|
20
|
+
checkboxColumn?: Partial<ArtColumn>;
|
|
21
|
+
/** 受控用法:当前选中的值 */
|
|
22
|
+
value?: string[];
|
|
23
|
+
/** 非受控用法:默认选中的值 */
|
|
24
|
+
defaultValue?: string[];
|
|
25
|
+
/** 受控用法:状态改变回调 */
|
|
26
|
+
onChange?(nextValue: string[]): void;
|
|
27
|
+
/** 点击事件的响应区域 */
|
|
28
|
+
clickArea?: 'checkbox' | 'cell' | 'row';
|
|
29
|
+
/** 是否对触发 onChange 的 click 事件调用 event.stopPropagation() */
|
|
30
|
+
stopClickEventPropagation?: boolean;
|
|
31
|
+
/** 被选中时是否高亮整行 */
|
|
32
|
+
highlightRowWhenSelected?: boolean;
|
|
33
|
+
/** 是否禁用该节点的交互 */
|
|
34
|
+
isDisabled?(row: any): boolean;
|
|
35
|
+
/** 是否让该节点对应的子树 与其父节点脱离联动 */
|
|
36
|
+
idDetached?(row: any): boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare function treeSelect(opts: TreeSelectFeatureOptions): (pipeline: TablePipeline) => TablePipeline;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
3
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { always } from '../../utils/others';
|
|
6
|
+
import StrictTreeDataHelper from '../../utils/tree-data-helpers/StrictTreeDataHelper';
|
|
7
|
+
import TreeDataHelper from '../../utils/tree-data-helpers/TreeDataHelper';
|
|
8
|
+
var STATE_KEY = 'treeSelect';
|
|
9
|
+
export function treeSelect(opts) {
|
|
10
|
+
return function treeSelectStep(pipeline) {
|
|
11
|
+
var _ref, _context;
|
|
12
|
+
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14
|
+
|
|
15
|
+
var Checkbox = pipeline.ctx.components.Checkbox;
|
|
16
|
+
|
|
17
|
+
if (Checkbox == null) {
|
|
18
|
+
throw new Error('使用 treeSelect 之前需要通过 pipeline context 设置 components.Checkbox');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
var primaryKey = pipeline.ensurePrimaryKey('treeSelect');
|
|
22
|
+
|
|
23
|
+
if (typeof primaryKey !== 'string') {
|
|
24
|
+
throw new Error('treeSelect 仅支持字符串作为 primaryKey');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var clickArea = (_a = opts.clickArea) !== null && _a !== void 0 ? _a : 'checkbox';
|
|
28
|
+
var isDisabled = (_b = opts.isDisabled) !== null && _b !== void 0 ? _b : always(false);
|
|
29
|
+
var isDetached = (_c = opts.idDetached) !== null && _c !== void 0 ? _c : always(false);
|
|
30
|
+
var value = (_f = (_e = (_d = opts.value) !== null && _d !== void 0 ? _d : pipeline.getStateAtKey(STATE_KEY)) !== null && _e !== void 0 ? _e : opts.defaultValue) !== null && _f !== void 0 ? _f : [];
|
|
31
|
+
var tree = opts.rootKey != null ? [(_ref = {}, _defineProperty(_ref, primaryKey, opts.rootKey), _defineProperty(_ref, "children", opts.tree), _ref)] : opts.tree;
|
|
32
|
+
|
|
33
|
+
var getNodeValue = function getNodeValue(node) {
|
|
34
|
+
return node[primaryKey];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var treeDataHelper = opts.checkStrictly ? new StrictTreeDataHelper({
|
|
38
|
+
value: value,
|
|
39
|
+
getNodeValue: getNodeValue,
|
|
40
|
+
tree: tree
|
|
41
|
+
}) : new TreeDataHelper({
|
|
42
|
+
value: value,
|
|
43
|
+
getNodeValue: getNodeValue,
|
|
44
|
+
isDetached: isDetached,
|
|
45
|
+
tree: tree,
|
|
46
|
+
checkedStrategy: (_g = opts.checkedStrategy) !== null && _g !== void 0 ? _g : 'parent'
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var onToggleKey = function onToggleKey(key) {
|
|
50
|
+
var _a;
|
|
51
|
+
|
|
52
|
+
var nextValue = treeDataHelper.getValueAfterToggle(key);
|
|
53
|
+
pipeline.setStateAtKey(STATE_KEY, nextValue);
|
|
54
|
+
(_a = opts.onChange) === null || _a === void 0 ? void 0 : _a.call(opts, nextValue);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var makeCheckbox = function makeCheckbox(key, root, row) {
|
|
58
|
+
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
59
|
+
checked: treeDataHelper.isChecked(key),
|
|
60
|
+
indeterminate: treeDataHelper.isIndeterminate(key),
|
|
61
|
+
disabled: !root && isDisabled(row),
|
|
62
|
+
onChange: clickArea === 'checkbox' || root ? function () {
|
|
63
|
+
return onToggleKey(key);
|
|
64
|
+
} : undefined
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var checkboxColumn = _extends(_extends({
|
|
69
|
+
name: '',
|
|
70
|
+
width: 50,
|
|
71
|
+
align: 'center',
|
|
72
|
+
title: opts.rootKey != null ? makeCheckbox(opts.rootKey, true) : undefined
|
|
73
|
+
}, opts.checkboxColumn), {
|
|
74
|
+
render: function render(value, record) {
|
|
75
|
+
return makeCheckbox(record[primaryKey], false, record);
|
|
76
|
+
},
|
|
77
|
+
getCellProps: function getCellProps(value, row) {
|
|
78
|
+
var rowKey = row[primaryKey];
|
|
79
|
+
|
|
80
|
+
if (clickArea !== 'cell') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var disabled = isDisabled(row);
|
|
85
|
+
|
|
86
|
+
if (disabled) {
|
|
87
|
+
return {
|
|
88
|
+
style: {
|
|
89
|
+
cursor: 'not-allowed'
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
style: {
|
|
96
|
+
cursor: 'pointer'
|
|
97
|
+
},
|
|
98
|
+
onClick: function onClick(e) {
|
|
99
|
+
if (opts.stopClickEventPropagation) {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
onToggleKey(rowKey);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
var nextColumns = _sliceInstanceProperty(_context = pipeline.getColumns()).call(_context);
|
|
110
|
+
|
|
111
|
+
var checkboxPlacement = (_h = opts.checkboxPlacement) !== null && _h !== void 0 ? _h : 'start';
|
|
112
|
+
|
|
113
|
+
if (checkboxPlacement === 'start') {
|
|
114
|
+
nextColumns.unshift(checkboxColumn);
|
|
115
|
+
} else {
|
|
116
|
+
nextColumns.push(checkboxColumn);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
pipeline.columns(nextColumns);
|
|
120
|
+
|
|
121
|
+
if (clickArea === 'row') {
|
|
122
|
+
pipeline.appendRowPropsGetter(function (row) {
|
|
123
|
+
var disabled = isDisabled(row);
|
|
124
|
+
|
|
125
|
+
if (!disabled) {
|
|
126
|
+
return {
|
|
127
|
+
style: {
|
|
128
|
+
cursor: 'pointer'
|
|
129
|
+
},
|
|
130
|
+
onClick: function onClick(e) {
|
|
131
|
+
if (opts.stopClickEventPropagation) {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
onToggleKey(row[primaryKey]);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (opts.highlightRowWhenSelected) {
|
|
143
|
+
pipeline.appendRowPropsGetter(function (row) {
|
|
144
|
+
if (treeDataHelper.isChecked(row[primaryKey])) {
|
|
145
|
+
return {
|
|
146
|
+
className: 'highlight'
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return pipeline;
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableProps, PrimaryKey } from '../base';
|
|
3
|
+
import { ArtColumn, TableTransform, Transform } from '../interfaces';
|
|
4
|
+
declare type RowPropsGetter = TableProps['getRowProps'];
|
|
5
|
+
export interface TablePipelineIndentsConfig {
|
|
6
|
+
iconIndent: number;
|
|
7
|
+
iconWidth: 16;
|
|
8
|
+
iconGap: number;
|
|
9
|
+
indentSize: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TablePipelineCtx {
|
|
12
|
+
primaryKey?: PrimaryKey;
|
|
13
|
+
components: {
|
|
14
|
+
[name: string]: any;
|
|
15
|
+
};
|
|
16
|
+
indents: TablePipelineIndentsConfig;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
|
|
21
|
+
*
|
|
22
|
+
* 1. ctx:上下文环境对象,step(流水线上的一步)可以对 ctx 中的字段进行读写。
|
|
23
|
+
* ctx 中部分字段名称有特定的含义(例如 primaryKey 表示行的主键),使用自定义的上下文信息时注意避开这些名称。
|
|
24
|
+
*
|
|
25
|
+
* 2. rowPropsGetters:getRowProps 回调队列,step 可以通过 pipeline.appendRowPropsGetter 向队列中追加回调函数,
|
|
26
|
+
* 在调用 pipeline.props() 队列中的所有函数会组合形成最终的 getRowProps
|
|
27
|
+
*
|
|
28
|
+
* 3. 当前流水线的状态,包括 dataSource, columns, rowPropsGetters 三个部分
|
|
29
|
+
*
|
|
30
|
+
* 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
|
|
31
|
+
* */
|
|
32
|
+
export declare class TablePipeline {
|
|
33
|
+
ref?: React.MutableRefObject<any>;
|
|
34
|
+
private readonly _snapshots;
|
|
35
|
+
private readonly _rowPropsGetters;
|
|
36
|
+
private _tableProps;
|
|
37
|
+
private _dataSource;
|
|
38
|
+
private _columns;
|
|
39
|
+
static defaultIndents: TablePipelineIndentsConfig;
|
|
40
|
+
readonly ctx: TablePipelineCtx;
|
|
41
|
+
private readonly state;
|
|
42
|
+
private readonly setState;
|
|
43
|
+
constructor({ state, setState, ctx, ref }: {
|
|
44
|
+
state: any;
|
|
45
|
+
setState: TablePipeline['setState'];
|
|
46
|
+
ctx: Partial<TablePipelineCtx>;
|
|
47
|
+
ref?: React.MutableRefObject<any>;
|
|
48
|
+
});
|
|
49
|
+
guid(): string;
|
|
50
|
+
appendRowPropsGetter(getter: RowPropsGetter): this;
|
|
51
|
+
addTableProps(props: React.HTMLAttributes<HTMLTableElement>): void;
|
|
52
|
+
getDataSource(name?: string): any[];
|
|
53
|
+
getColumns(name?: string): any[];
|
|
54
|
+
getStateAtKey<T = any>(stateKey: string, defaultValue?: T): T;
|
|
55
|
+
/** 将 stateKey 对应的状态设置为 partialState */
|
|
56
|
+
setStateAtKey(stateKey: string, partialState: any, extraInfo?: any): void;
|
|
57
|
+
/** 确保 primaryKey 已被设置,并返回 primaryKey */
|
|
58
|
+
ensurePrimaryKey(hint?: string): PrimaryKey;
|
|
59
|
+
/** 设置流水线的输入数据 */
|
|
60
|
+
input(input: {
|
|
61
|
+
dataSource: any[];
|
|
62
|
+
columns: ArtColumn[];
|
|
63
|
+
}): this;
|
|
64
|
+
/** 设置 dataSource */
|
|
65
|
+
dataSource(rows: any[]): this;
|
|
66
|
+
/** 设置 columns */
|
|
67
|
+
columns(cols: ArtColumn[]): this;
|
|
68
|
+
/** 设置主键 */
|
|
69
|
+
primaryKey(key: PrimaryKey): this;
|
|
70
|
+
/** 保存快照 */
|
|
71
|
+
snapshot(name: string): this;
|
|
72
|
+
/** @deprecated
|
|
73
|
+
* 应用一个 kd-table Table transform */
|
|
74
|
+
useTransform(transform: TableTransform): this;
|
|
75
|
+
/** 使用 pipeline 功能拓展 */
|
|
76
|
+
use(step: (pipeline: this) => this): this;
|
|
77
|
+
/** 转换 dataSource */
|
|
78
|
+
mapDataSource(mapper: Transform<any[]>): this;
|
|
79
|
+
/** 转换 columns */
|
|
80
|
+
mapColumns(mapper: Transform<ArtColumn[]>): this;
|
|
81
|
+
/** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
|
|
82
|
+
getProps(this: TablePipeline): TableProps;
|
|
83
|
+
}
|
|
84
|
+
export declare function useTablePipeline(ctx?: Partial<TablePipelineCtx>): TablePipeline;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
3
|
+
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
4
|
+
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
6
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
7
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
8
|
+
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
9
|
+
import { useState, useRef } from 'react';
|
|
10
|
+
import { mergeCellProps } from '../utils';
|
|
11
|
+
import { autoFillTableWidth, tableWidthKey } from './features/autoFill';
|
|
12
|
+
/**
|
|
13
|
+
* 表格数据处理流水线。TablePipeline 提供了表格数据处理过程中的一些上下方与工具方法,包括……
|
|
14
|
+
*
|
|
15
|
+
* 1. ctx:上下文环境对象,step(流水线上的一步)可以对 ctx 中的字段进行读写。
|
|
16
|
+
* ctx 中部分字段名称有特定的含义(例如 primaryKey 表示行的主键),使用自定义的上下文信息时注意避开这些名称。
|
|
17
|
+
*
|
|
18
|
+
* 2. rowPropsGetters:getRowProps 回调队列,step 可以通过 pipeline.appendRowPropsGetter 向队列中追加回调函数,
|
|
19
|
+
* 在调用 pipeline.props() 队列中的所有函数会组合形成最终的 getRowProps
|
|
20
|
+
*
|
|
21
|
+
* 3. 当前流水线的状态,包括 dataSource, columns, rowPropsGetters 三个部分
|
|
22
|
+
*
|
|
23
|
+
* 4. snapshots,调用 pipeline.snapshot(name) 可以记录当前的状态,后续可以通过 name 来读取保存的状态
|
|
24
|
+
* */
|
|
25
|
+
|
|
26
|
+
export var TablePipeline = /*#__PURE__*/function () {
|
|
27
|
+
function TablePipeline(_ref) {
|
|
28
|
+
var state = _ref.state,
|
|
29
|
+
setState = _ref.setState,
|
|
30
|
+
ctx = _ref.ctx,
|
|
31
|
+
ref = _ref.ref;
|
|
32
|
+
|
|
33
|
+
_classCallCheck(this, TablePipeline);
|
|
34
|
+
|
|
35
|
+
this._snapshots = {};
|
|
36
|
+
this._rowPropsGetters = [];
|
|
37
|
+
this._tableProps = {};
|
|
38
|
+
this.ctx = {
|
|
39
|
+
components: {},
|
|
40
|
+
indents: TablePipeline.defaultIndents
|
|
41
|
+
};
|
|
42
|
+
this.state = state;
|
|
43
|
+
this.setState = setState;
|
|
44
|
+
this.ref = ref;
|
|
45
|
+
|
|
46
|
+
_extends(this.ctx, ctx);
|
|
47
|
+
} // Generate a pseudo-GUID by concatenating random hexadecimal.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
_createClass(TablePipeline, [{
|
|
51
|
+
key: "guid",
|
|
52
|
+
value: function guid() {
|
|
53
|
+
function S4() {
|
|
54
|
+
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "appendRowPropsGetter",
|
|
61
|
+
value: function appendRowPropsGetter(getter) {
|
|
62
|
+
this._rowPropsGetters.push(getter);
|
|
63
|
+
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
67
|
+
key: "addTableProps",
|
|
68
|
+
value: function addTableProps(props) {
|
|
69
|
+
this._tableProps = _extends(_extends({}, this._tableProps), props);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "getDataSource",
|
|
73
|
+
value: function getDataSource(name) {
|
|
74
|
+
if (name == null) {
|
|
75
|
+
return this._dataSource;
|
|
76
|
+
} else {
|
|
77
|
+
return this._snapshots[name].dataSource;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "getColumns",
|
|
82
|
+
value: function getColumns(name) {
|
|
83
|
+
if (name == null) {
|
|
84
|
+
return this._columns;
|
|
85
|
+
} else {
|
|
86
|
+
return this._snapshots[name].columns;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "getStateAtKey",
|
|
91
|
+
value: function getStateAtKey(stateKey, defaultValue) {
|
|
92
|
+
var _a;
|
|
93
|
+
|
|
94
|
+
return (_a = this.state[stateKey]) !== null && _a !== void 0 ? _a : defaultValue;
|
|
95
|
+
}
|
|
96
|
+
/** 将 stateKey 对应的状态设置为 partialState */
|
|
97
|
+
|
|
98
|
+
}, {
|
|
99
|
+
key: "setStateAtKey",
|
|
100
|
+
value: function setStateAtKey(stateKey, partialState, extraInfo) {
|
|
101
|
+
this.setState(function (prev) {
|
|
102
|
+
return _extends(_extends({}, prev), _defineProperty({}, stateKey, partialState));
|
|
103
|
+
}, stateKey, partialState, extraInfo);
|
|
104
|
+
}
|
|
105
|
+
/** 确保 primaryKey 已被设置,并返回 primaryKey */
|
|
106
|
+
|
|
107
|
+
}, {
|
|
108
|
+
key: "ensurePrimaryKey",
|
|
109
|
+
value: function ensurePrimaryKey(hint) {
|
|
110
|
+
if (this.ctx.primaryKey == null) {
|
|
111
|
+
throw new Error(hint ? "\u4F7F\u7528 ".concat(hint, " \u4E4B\u524D\u5FC5\u987B\u5148\u8BBE\u7F6E primaryKey") : '必须先设置 primaryKey');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return this.ctx.primaryKey;
|
|
115
|
+
}
|
|
116
|
+
/** 设置流水线的输入数据 */
|
|
117
|
+
|
|
118
|
+
}, {
|
|
119
|
+
key: "input",
|
|
120
|
+
value: function input(_input) {
|
|
121
|
+
var _context,
|
|
122
|
+
_this = this;
|
|
123
|
+
|
|
124
|
+
if (this._dataSource != null || this._columns != null) {
|
|
125
|
+
throw new Error('input 不能调用两次');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this._dataSource = _input.dataSource;
|
|
129
|
+
this._columns = _mapInstanceProperty(_context = _input.columns).call(_context, function (col) {
|
|
130
|
+
return _extends(_extends({}, col), {
|
|
131
|
+
key: _this.guid()
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
this.snapshot('input');
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
/** 设置 dataSource */
|
|
138
|
+
|
|
139
|
+
}, {
|
|
140
|
+
key: "dataSource",
|
|
141
|
+
value: function dataSource(rows) {
|
|
142
|
+
this._dataSource = rows;
|
|
143
|
+
return this;
|
|
144
|
+
}
|
|
145
|
+
/** 设置 columns */
|
|
146
|
+
|
|
147
|
+
}, {
|
|
148
|
+
key: "columns",
|
|
149
|
+
value: function columns(cols) {
|
|
150
|
+
this._columns = cols;
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
/** 设置主键 */
|
|
154
|
+
|
|
155
|
+
}, {
|
|
156
|
+
key: "primaryKey",
|
|
157
|
+
value: function primaryKey(key) {
|
|
158
|
+
this.ctx.primaryKey = key;
|
|
159
|
+
return this;
|
|
160
|
+
}
|
|
161
|
+
/** 保存快照 */
|
|
162
|
+
|
|
163
|
+
}, {
|
|
164
|
+
key: "snapshot",
|
|
165
|
+
value: function snapshot(name) {
|
|
166
|
+
var _context2;
|
|
167
|
+
|
|
168
|
+
this._snapshots[name] = {
|
|
169
|
+
dataSource: this._dataSource,
|
|
170
|
+
columns: this._columns,
|
|
171
|
+
rowPropsGetters: _sliceInstanceProperty(_context2 = this._rowPropsGetters).call(_context2)
|
|
172
|
+
};
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
/** @deprecated
|
|
176
|
+
* 应用一个 kd-table Table transform */
|
|
177
|
+
|
|
178
|
+
}, {
|
|
179
|
+
key: "useTransform",
|
|
180
|
+
value: function useTransform(transform) {
|
|
181
|
+
var next = transform({
|
|
182
|
+
dataSource: this.getDataSource(),
|
|
183
|
+
columns: this.getColumns()
|
|
184
|
+
});
|
|
185
|
+
return this.dataSource(next.dataSource).columns(next.columns);
|
|
186
|
+
}
|
|
187
|
+
/** 使用 pipeline 功能拓展 */
|
|
188
|
+
|
|
189
|
+
}, {
|
|
190
|
+
key: "use",
|
|
191
|
+
value: function use(step) {
|
|
192
|
+
return step(this);
|
|
193
|
+
}
|
|
194
|
+
/** 转换 dataSource */
|
|
195
|
+
|
|
196
|
+
}, {
|
|
197
|
+
key: "mapDataSource",
|
|
198
|
+
value: function mapDataSource(mapper) {
|
|
199
|
+
return this.dataSource(mapper(this.getDataSource()));
|
|
200
|
+
}
|
|
201
|
+
/** 转换 columns */
|
|
202
|
+
|
|
203
|
+
}, {
|
|
204
|
+
key: "mapColumns",
|
|
205
|
+
value: function mapColumns(mapper) {
|
|
206
|
+
return this.columns(mapper(this.getColumns()));
|
|
207
|
+
}
|
|
208
|
+
/** 获取 BaseTable 的 props,结果中包含 dataSource/columns/primaryKey/getRowProps 四个字段 */
|
|
209
|
+
|
|
210
|
+
}, {
|
|
211
|
+
key: "getProps",
|
|
212
|
+
value: function getProps() {
|
|
213
|
+
var _this2 = this;
|
|
214
|
+
|
|
215
|
+
this.use(autoFillTableWidth());
|
|
216
|
+
var result = {
|
|
217
|
+
dataSource: this._dataSource,
|
|
218
|
+
columns: this._columns
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
if (this.ctx.primaryKey) {
|
|
222
|
+
result.primaryKey = this.ctx.primaryKey;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this._rowPropsGetters.length > 0) {
|
|
226
|
+
result.getRowProps = function (row, rowIndex) {
|
|
227
|
+
var _context3;
|
|
228
|
+
|
|
229
|
+
return _reduceInstanceProperty(_context3 = _this2._rowPropsGetters).call(_context3, function (res, get) {
|
|
230
|
+
return mergeCellProps(res, get(row, rowIndex));
|
|
231
|
+
}, {});
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
result.getTableProps = function () {
|
|
236
|
+
return _this2._tableProps;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
result.setTableWidth = function (tableWidth) {
|
|
240
|
+
var preTableWidth = _this2.getStateAtKey(tableWidthKey);
|
|
241
|
+
|
|
242
|
+
if (preTableWidth !== tableWidth) {
|
|
243
|
+
_this2.setStateAtKey(tableWidthKey, tableWidth);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
}]);
|
|
250
|
+
|
|
251
|
+
return TablePipeline;
|
|
252
|
+
}();
|
|
253
|
+
TablePipeline.defaultIndents = {
|
|
254
|
+
iconIndent: -8,
|
|
255
|
+
iconWidth: 16,
|
|
256
|
+
iconGap: 0,
|
|
257
|
+
indentSize: 16
|
|
258
|
+
};
|
|
259
|
+
export function useTablePipeline(ctx) {
|
|
260
|
+
var _useState = useState({}),
|
|
261
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
262
|
+
state = _useState2[0],
|
|
263
|
+
setState = _useState2[1];
|
|
264
|
+
|
|
265
|
+
var ref = useRef({});
|
|
266
|
+
return new TablePipeline({
|
|
267
|
+
state: state,
|
|
268
|
+
setState: setState,
|
|
269
|
+
ctx: ctx,
|
|
270
|
+
ref: ref
|
|
271
|
+
});
|
|
272
|
+
}
|
|
@@ -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'>;
|