@dtjoy/dt-design 1.1.1 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -24
- package/dist/dt-design.min.css +1 -0
- package/dist/dt-design.min.js +1 -0
- package/es/_util/context/createContextSelector.d.ts +28 -0
- package/es/_util/context/createContextSelector.js +110 -0
- package/es/_util/context/immutable.d.ts +10 -0
- package/es/_util/context/immutable.js +84 -0
- package/es/_util/context/index.d.ts +3 -0
- package/es/_util/context/index.js +3 -0
- package/{esm → es}/_util/gapSize.d.ts +1 -1
- package/{esm → es}/_util/getScroll.js +1 -1
- package/es/_util/hooks/index.d.ts +11 -0
- package/es/_util/hooks/index.js +11 -0
- package/es/_util/hooks/useBreakpoint.d.ts +5 -0
- package/es/_util/hooks/useBreakpoint.js +75 -0
- package/es/_util/hooks/useCssVar.d.ts +3 -0
- package/es/_util/hooks/useCssVar.js +28 -0
- package/es/_util/hooks/useEvent.d.ts +1 -0
- package/es/_util/hooks/useEvent.js +1 -0
- package/es/_util/hooks/useLayoutEffect.d.ts +1 -0
- package/es/_util/hooks/useLayoutEffect.js +1 -0
- package/es/_util/hooks/useMultipleSelect.d.ts +2 -0
- package/es/_util/hooks/useMultipleSelect.js +37 -0
- package/es/_util/hooks/useProxyImperativeHandle.d.ts +4 -0
- package/{esm → es}/_util/hooks/useProxyImperativeHandle.js +10 -3
- package/es/_util/hooks/useTimeoutLock.d.ts +1 -0
- package/es/_util/hooks/useTimeoutLock.js +26 -0
- package/es/_util/index.d.ts +11 -0
- package/{esm → es}/_util/index.js +9 -1
- package/es/_util/is.d.ts +5 -0
- package/es/_util/is.js +16 -0
- package/es/_util/rcUtil.d.ts +17 -0
- package/es/_util/rcUtil.js +58 -0
- package/{esm → es}/_util/scrollTo.js +1 -1
- package/es/_util/scrollbar.d.ts +1 -0
- package/es/_util/scrollbar.js +32 -0
- package/{esm → es}/_util/type.d.ts +1 -0
- package/es/_util/validate.d.ts +2 -0
- package/es/_util/validate.js +10 -0
- package/{esm → es}/_util/warning.js +5 -6
- package/{lib/blockHeader → es/block-header}/index.d.ts +1 -1
- package/{esm/blockHeader → es/block-header}/index.js +1 -1
- package/{lib/blockHeader → es/block-header}/style/index.less +167 -143
- package/{esm → es}/button/index.d.ts +3 -3
- package/{esm → es}/button/index.js +16 -4
- package/{esm → es}/button/style/index.less +62 -59
- package/{esm → es}/button/style/mixin.less +40 -39
- package/{esm → es}/collapsible/index.js +3 -2
- package/{esm → es}/collapsible/style/index.less +24 -24
- package/{esm/collapsibleActionItems → es/collapsible-action-items}/index.d.ts +1 -1
- package/{esm/collapsibleActionItems → es/collapsible-action-items}/index.js +21 -19
- package/{lib/collapsibleActionItems → es/collapsible-action-items}/style/index.less +7 -7
- package/{lib → es}/flex/index.d.ts +2 -2
- package/{esm → es}/flex/index.js +3 -3
- package/{esm → es}/flex/style/index.less +80 -76
- package/{esm/formList → es/form-list}/index.d.ts +9 -0
- package/{esm/formList → es/form-list}/index.js +18 -8
- package/{lib/formList → es/form-list}/style/index.less +45 -45
- package/es/index.d.ts +26 -0
- package/es/index.js +21 -0
- package/{lib/overflowList → es/overflow-list}/index.d.ts +4 -1
- package/{esm/overflowList → es/overflow-list}/index.js +37 -9
- package/{esm/overflowList → es/overflow-list}/style/index.less +9 -9
- package/{lib/resizeObserver → es/resize-observer}/index.d.ts +1 -1
- package/{esm/resizeObserver → es/resize-observer}/index.js +8 -8
- package/{esm → es}/splitter/Panel.d.ts +1 -1
- package/{esm → es}/splitter/Panel.js +12 -4
- package/{esm → es}/splitter/SplitBar.d.ts +6 -2
- package/{esm → es}/splitter/SplitBar.js +82 -80
- package/{esm → es}/splitter/Splitter.js +52 -23
- package/{esm → es}/splitter/hooks/sizeUtil.js +1 -1
- package/es/splitter/hooks/useDragListeners.d.ts +14 -0
- package/es/splitter/hooks/useDragListeners.js +107 -0
- package/{esm → es}/splitter/hooks/useItems.d.ts +6 -0
- package/es/splitter/hooks/useOrientation.d.ts +2 -0
- package/es/splitter/hooks/useOrientation.js +6 -0
- package/{esm → es}/splitter/hooks/useResizable.d.ts +3 -0
- package/{esm → es}/splitter/hooks/useResizable.js +5 -2
- package/{esm → es}/splitter/hooks/useResize.d.ts +1 -1
- package/{esm → es}/splitter/hooks/useResize.js +10 -3
- package/{esm → es}/splitter/hooks/useSizes.js +5 -6
- package/{lib → es}/splitter/index.d.ts +2 -1
- package/es/splitter/interface.d.ts +45 -0
- package/es/splitter/style/index.less +349 -0
- package/{esm/statusTag → es/status-tag}/index.js +1 -1
- package/{esm/statusTag → es/status-tag}/style/index.less +70 -70
- package/{esm/statusTag → es/status-tag}/style/mixin.less +48 -39
- package/{esm → es}/style/index.less +1 -1
- package/es/style/themes/index.less +2 -0
- package/{esm → es}/style/themes/variable.less +5 -5
- package/es/table/Column.d.ts +2 -0
- package/es/table/Column.js +1 -0
- package/es/table/ColumnGroup.d.ts +2 -0
- package/es/table/ColumnGroup.js +1 -0
- package/es/table/InternalTable.d.ts +43 -0
- package/es/table/InternalTable.js +816 -0
- package/{lib → es}/table/Table.d.ts +7 -5
- package/{esm → es}/table/Table.js +6 -4
- package/es/table/components/Body/BodyRow.d.ts +37 -0
- package/es/table/components/Body/BodyRow.js +182 -0
- package/es/table/components/Body/ExpandedRow.d.ts +15 -0
- package/es/table/components/Body/ExpandedRow.js +51 -0
- package/es/table/components/Body/MeasureCell.d.ts +8 -0
- package/es/table/components/Body/MeasureCell.js +33 -0
- package/es/table/components/Body/MeasureRow.d.ts +10 -0
- package/es/table/components/Body/MeasureRow.js +54 -0
- package/es/table/components/Body/index.d.ts +11 -0
- package/es/table/components/Body/index.js +123 -0
- package/es/table/components/Cell/index.d.ts +39 -0
- package/es/table/components/Cell/index.js +196 -0
- package/es/table/components/Cell/useCellRender.d.ts +3 -0
- package/es/table/components/Cell/useCellRender.js +69 -0
- package/es/table/components/Cell/useHoverState.d.ts +2 -0
- package/es/table/components/Cell/useHoverState.js +13 -0
- package/es/table/components/ColGroup.d.ts +9 -0
- package/es/table/components/ColGroup.js +53 -0
- package/es/table/components/ExpandIcon.d.ts +12 -0
- package/es/table/components/ExpandIcon.js +27 -0
- package/es/table/components/FixedHolder/index.d.ts +27 -0
- package/es/table/components/FixedHolder/index.js +186 -0
- package/es/table/components/Footer/Cell.d.ts +11 -0
- package/es/table/components/Footer/Cell.js +47 -0
- package/es/table/components/Footer/Row.d.ts +8 -0
- package/es/table/components/Footer/Row.js +10 -0
- package/es/table/components/Footer/Summary.d.ts +14 -0
- package/es/table/components/Footer/Summary.js +12 -0
- package/es/table/components/Footer/SummaryContext.d.ts +11 -0
- package/es/table/components/Footer/SummaryContext.js +3 -0
- package/es/table/components/Footer/index.d.ts +16 -0
- package/es/table/components/Footer/index.js +31 -0
- package/es/table/components/Header/Header.d.ts +10 -0
- package/es/table/components/Header/Header.js +110 -0
- package/es/table/components/Header/HeaderRow.d.ts +19 -0
- package/es/table/components/Header/HeaderRow.js +63 -0
- package/es/table/components/Panel.d.ts +7 -0
- package/es/table/components/Panel.js +11 -0
- package/es/table/components/RcTable.d.ts +114 -0
- package/es/table/components/RcTable.js +757 -0
- package/es/table/components/VirtualTable.d.ts +5 -0
- package/{esm/table/RcTable → es/table/components}/VirtualTable.js +4 -1
- package/es/table/components/VirtualTableBody/BodyGrid.d.ts +13 -0
- package/es/table/components/VirtualTableBody/BodyGrid.js +307 -0
- package/es/table/components/VirtualTableBody/BodyLine.d.ts +14 -0
- package/es/table/components/VirtualTableBody/BodyLine.js +116 -0
- package/es/table/components/VirtualTableBody/VirtualCell.d.ts +26 -0
- package/es/table/components/VirtualTableBody/VirtualCell.js +118 -0
- package/es/table/components/VirtualTableBody/context.d.ts +13 -0
- package/es/table/components/VirtualTableBody/context.js +3 -0
- package/es/table/components/VirtualTableBody/index.d.ts +16 -0
- package/es/table/components/VirtualTableBody/index.js +102 -0
- package/es/table/constant.d.ts +2 -0
- package/es/table/constant.js +2 -0
- package/es/table/features/columns/Column.d.ts +7 -0
- package/es/table/features/columns/Column.js +4 -0
- package/es/table/features/columns/ColumnGroup.d.ts +9 -0
- package/es/table/features/columns/ColumnGroup.js +4 -0
- package/es/table/features/columns/index.d.ts +8 -0
- package/es/table/features/columns/index.js +6 -0
- package/es/table/features/columns/useColumns.d.ts +31 -0
- package/es/table/features/columns/useColumns.js +227 -0
- package/es/table/features/columns/useFilledColumns.d.ts +4 -0
- package/es/table/features/columns/useFilledColumns.js +34 -0
- package/es/table/features/columns/useTitleColumns.d.ts +4 -0
- package/es/table/features/columns/useTitleColumns.js +26 -0
- package/es/table/features/columns/useWidthColumns.d.ts +5 -0
- package/es/table/features/columns/useWidthColumns.js +75 -0
- package/es/table/features/editable/BatchEditModal.d.ts +4 -0
- package/es/table/features/editable/BatchEditModal.js +786 -0
- package/es/table/features/editable/EditableCell.d.ts +42 -0
- package/es/table/features/editable/EditableCell.js +294 -0
- package/es/table/features/editable/EditableContext.d.ts +33 -0
- package/es/table/features/editable/EditableContext.js +20 -0
- package/es/table/features/editable/batchEditTypes.d.ts +55 -0
- package/es/table/features/editable/batchEditTypes.js +1 -0
- package/es/table/features/editable/batchEditUtils.d.ts +44 -0
- package/es/table/features/editable/batchEditUtils.js +258 -0
- package/es/table/features/editable/builtinEditors.d.ts +32 -0
- package/es/table/features/editable/builtinEditors.js +165 -0
- package/es/table/features/editable/index.d.ts +11 -0
- package/es/table/features/editable/index.js +10 -0
- package/es/table/features/editable/useBatchRules.d.ts +17 -0
- package/es/table/features/editable/useBatchRules.js +96 -0
- package/es/table/features/editable/useEditable.d.ts +51 -0
- package/es/table/features/editable/useEditable.js +693 -0
- package/es/table/features/expand/expandUtil.d.ts +5 -0
- package/es/table/features/expand/expandUtil.js +47 -0
- package/es/table/features/expand/index.d.ts +2 -0
- package/es/table/features/expand/index.js +2 -0
- package/es/table/features/expand/useExpand.d.ts +10 -0
- package/es/table/features/expand/useExpand.js +90 -0
- package/es/table/features/filter/FilterDropdown.d.ts +31 -0
- package/es/table/features/filter/FilterDropdown.js +494 -0
- package/es/table/features/filter/FilterSearch.d.ts +12 -0
- package/es/table/features/filter/FilterSearch.js +24 -0
- package/es/table/features/filter/FilterWrapper.d.ts +8 -0
- package/es/table/features/filter/FilterWrapper.js +23 -0
- package/es/table/features/filter/index.d.ts +4 -0
- package/es/table/features/filter/index.js +4 -0
- package/es/table/features/filter/useFilter.d.ts +22 -0
- package/es/table/features/filter/useFilter.js +240 -0
- package/es/table/features/fixed/fixUtil.d.ts +21 -0
- package/es/table/features/fixed/fixUtil.js +69 -0
- package/es/table/features/fixed/index.d.ts +4 -0
- package/es/table/features/fixed/index.js +4 -0
- package/es/table/features/fixed/offsetUtil.d.ts +4 -0
- package/es/table/features/fixed/offsetUtil.js +13 -0
- package/es/table/features/fixed/useFixedInfo.d.ts +2 -0
- package/es/table/features/fixed/useFixedInfo.js +16 -0
- package/es/table/features/fixed/useStickyOffsets.d.ts +6 -0
- package/es/table/features/fixed/useStickyOffsets.js +29 -0
- package/es/table/features/hover/index.d.ts +1 -0
- package/es/table/features/hover/index.js +1 -0
- package/es/table/features/hover/useHover.d.ts +2 -0
- package/es/table/features/hover/useHover.js +22 -0
- package/es/table/features/pagination/index.d.ts +1 -0
- package/es/table/features/pagination/index.js +1 -0
- package/es/table/features/pagination/usePagination.d.ts +5 -0
- package/es/table/features/pagination/usePagination.js +89 -0
- package/es/table/features/resize/ResizeHandle.d.ts +22 -0
- package/es/table/features/resize/ResizeHandle.js +99 -0
- package/es/table/features/resize/index.d.ts +5 -0
- package/es/table/features/resize/index.js +3 -0
- package/es/table/features/resize/transformResizableColumns.d.ts +11 -0
- package/es/table/features/resize/transformResizableColumns.js +52 -0
- package/es/table/features/resize/useResize.d.ts +52 -0
- package/es/table/features/resize/useResize.js +586 -0
- package/es/table/features/selection/index.d.ts +1 -0
- package/es/table/features/selection/index.js +1 -0
- package/es/table/features/selection/useSelection.d.ts +20 -0
- package/es/table/features/selection/useSelection.js +579 -0
- package/es/table/features/sort/index.d.ts +1 -0
- package/es/table/features/sort/index.js +1 -0
- package/es/table/features/sort/useSorter.d.ts +21 -0
- package/es/table/features/sort/useSorter.js +372 -0
- package/es/table/features/sticky/index.d.ts +2 -0
- package/es/table/features/sticky/index.js +2 -0
- package/es/table/features/sticky/stickyScrollBar.d.ts +12 -0
- package/es/table/features/sticky/stickyScrollBar.js +203 -0
- package/es/table/features/sticky/useSticky.d.ts +10 -0
- package/es/table/features/sticky/useSticky.js +34 -0
- package/es/table/features/summary/index.d.ts +1 -0
- package/es/table/features/summary/index.js +1 -0
- package/es/table/features/virtual/index.d.ts +2 -0
- package/es/table/features/virtual/index.js +2 -0
- package/es/table/features/virtual/useFlattenRecords.d.ts +19 -0
- package/es/table/features/virtual/useFlattenRecords.js +55 -0
- package/es/table/features/virtual/useFrame.d.ts +7 -0
- package/es/table/features/virtual/useFrame.js +67 -0
- package/es/table/immutableHelper.d.ts +9 -0
- package/es/table/immutableHelper.js +36 -0
- package/es/table/index.d.ts +24 -0
- package/es/table/index.js +23 -0
- package/es/table/interface.d.ts +438 -0
- package/es/table/interface.js +56 -0
- package/es/table/shared/context/PerfContext.d.ts +6 -0
- package/es/table/shared/context/PerfContext.js +6 -0
- package/es/table/shared/context/TableContext.d.ts +51 -0
- package/es/table/shared/context/TableContext.js +8 -0
- package/es/table/shared/hooks/useLazyKVMap.d.ts +4 -0
- package/es/table/shared/hooks/useLazyKVMap.js +30 -0
- package/es/table/shared/hooks/useRenderTimes.d.ts +5 -0
- package/es/table/shared/hooks/useRenderTimes.js +39 -0
- package/es/table/shared/hooks/useRowInfo.d.ts +11 -0
- package/es/table/shared/hooks/useRowInfo.js +73 -0
- package/es/table/shared/utils/legacyUtil.d.ts +5 -0
- package/es/table/shared/utils/legacyUtil.js +30 -0
- package/{esm/table → es/table/shared/utils}/util.d.ts +3 -11
- package/{esm/table → es/table/shared/utils}/util.js +6 -13
- package/es/table/shared/utils/valueUtil.d.ts +8 -0
- package/es/table/shared/utils/valueUtil.js +29 -0
- package/es/table/style/base.less +164 -0
- package/es/table/style/bordered.less +83 -0
- package/es/table/style/editable.less +50 -0
- package/es/table/style/ellipsis.less +33 -0
- package/es/table/style/empty.less +16 -0
- package/es/table/style/expand.less +123 -0
- package/es/table/style/filter.less +34 -0
- package/es/table/style/fixed.less +85 -0
- package/es/table/style/index.d.ts +3 -0
- package/es/table/style/index.js +3 -0
- package/es/table/style/index.less +19 -0
- package/es/table/style/pagination.less +29 -0
- package/es/table/style/radius.less +64 -0
- package/es/table/style/resize.less +78 -0
- package/es/table/style/rtl.less +52 -0
- package/es/table/style/selection.less +63 -0
- package/es/table/style/size.less +54 -0
- package/es/table/style/sorter.less +99 -0
- package/es/table/style/sticky.less +45 -0
- package/es/table/style/summary.less +23 -0
- package/es/table/style/variables.less +80 -0
- package/es/table/style/virtual.less +95 -0
- package/lib/_util/context/createContextSelector.js +120 -0
- package/lib/_util/context/immutable.js +92 -0
- package/lib/_util/context/index.js +41 -0
- package/lib/_util/easings.js +1 -1
- package/lib/_util/getScroll.js +6 -6
- package/lib/_util/hooks/index.js +82 -5
- package/lib/_util/hooks/useBreakpoint.js +85 -0
- package/lib/_util/hooks/useCssVar.js +37 -0
- package/lib/_util/hooks/useEvent.js +13 -0
- package/lib/_util/hooks/useForceUpdate.js +5 -4
- package/lib/_util/hooks/useLayoutEffect.js +13 -0
- package/lib/_util/hooks/useMultipleSelect.js +43 -0
- package/lib/_util/hooks/useOrientation.js +7 -8
- package/lib/_util/hooks/useProxyImperativeHandle.js +18 -14
- package/lib/_util/hooks/useSyncState.js +19 -9
- package/lib/_util/hooks/useTimeoutLock.js +35 -0
- package/lib/_util/index.js +101 -1
- package/lib/_util/is.js +22 -0
- package/lib/_util/rcUtil.js +134 -0
- package/lib/_util/scrollTo.js +22 -18
- package/lib/_util/scrollbar.js +38 -0
- package/lib/_util/validate.js +17 -0
- package/lib/_util/warning.js +25 -27
- package/lib/block-header/index.js +141 -0
- package/{esm/blockHeader → lib/block-header}/style/index.less +167 -143
- package/lib/button/index.js +24 -9
- package/lib/button/style/index.less +62 -59
- package/lib/button/style/mixin.less +40 -39
- package/lib/collapsible/index.js +210 -169
- package/lib/collapsible/style/index.less +24 -24
- package/lib/collapsible-action-items/index.js +83 -0
- package/{esm/collapsibleActionItems → lib/collapsible-action-items}/style/index.less +7 -7
- package/lib/flex/index.js +43 -34
- package/lib/flex/style/index.less +80 -76
- package/lib/flex/utils.js +23 -23
- package/lib/form-list/index.js +163 -0
- package/{esm/formList → lib/form-list}/style/index.less +45 -45
- package/lib/index.js +37 -67
- package/lib/overflow-list/index.js +203 -0
- package/lib/{overflowList → overflow-list}/style/index.less +9 -9
- package/lib/resize/index.js +13 -13
- package/lib/resize-observer/index.js +182 -0
- package/lib/splitter/Panel.js +36 -25
- package/lib/splitter/SplitBar.js +151 -134
- package/lib/splitter/Splitter.js +141 -89
- package/lib/splitter/hooks/sizeUtil.js +50 -33
- package/lib/splitter/hooks/useDragListeners.js +114 -0
- package/lib/splitter/hooks/useItems.js +27 -20
- package/lib/splitter/hooks/useOrientation.js +12 -0
- package/lib/splitter/hooks/useResizable.js +32 -30
- package/lib/splitter/hooks/useResize.js +76 -45
- package/lib/splitter/hooks/useSizes.js +55 -30
- package/lib/splitter/index.js +1 -1
- package/lib/splitter/style/index.less +349 -312
- package/lib/status-tag/index.js +131 -0
- package/lib/{statusTag → status-tag}/style/index.less +70 -70
- package/lib/{statusTag → status-tag}/style/mixin.less +48 -39
- package/lib/style/index.less +1 -1
- package/lib/style/themes/index.less +2 -2
- package/lib/style/themes/variable.less +5 -5
- package/lib/table/Column.js +13 -0
- package/lib/table/ColumnGroup.js +13 -0
- package/lib/table/InternalTable.js +699 -270
- package/lib/table/Table.js +14 -11
- package/lib/table/TableMeasureRowContext.js +1 -1
- package/lib/table/components/Body/BodyRow.js +192 -0
- package/lib/table/components/Body/ExpandedRow.js +61 -0
- package/lib/table/components/Body/MeasureCell.js +43 -0
- package/lib/table/components/Body/MeasureRow.js +64 -0
- package/lib/table/components/Body/index.js +133 -0
- package/lib/table/components/Cell/index.js +205 -0
- package/lib/table/components/Cell/useCellRender.js +78 -0
- package/lib/table/components/Cell/useHoverState.js +20 -0
- package/lib/table/components/ColGroup.js +62 -0
- package/lib/table/components/ExpandIcon.js +35 -0
- package/lib/table/components/FixedHolder/index.js +195 -0
- package/lib/table/components/Footer/Cell.js +57 -0
- package/lib/table/components/Footer/Row.js +19 -0
- package/lib/table/components/Footer/Summary.js +19 -0
- package/lib/table/components/Footer/SummaryContext.js +12 -0
- package/lib/table/components/Footer/index.js +41 -0
- package/lib/table/components/Header/Header.js +120 -0
- package/lib/table/components/Header/HeaderRow.js +72 -0
- package/lib/table/components/Panel.js +20 -0
- package/lib/table/components/RcTable.js +764 -0
- package/lib/table/components/VirtualTable.js +18 -0
- package/lib/table/components/VirtualTableBody/BodyGrid.js +316 -0
- package/lib/table/components/VirtualTableBody/BodyLine.js +125 -0
- package/lib/table/components/VirtualTableBody/VirtualCell.js +128 -0
- package/lib/table/components/VirtualTableBody/context.js +9 -0
- package/lib/table/components/VirtualTableBody/index.js +111 -0
- package/lib/table/constant.js +8 -0
- package/lib/table/features/columns/Column.js +10 -0
- package/lib/table/features/columns/ColumnGroup.js +10 -0
- package/lib/table/features/columns/index.js +57 -0
- package/lib/table/features/columns/useColumns.js +237 -0
- package/lib/table/features/columns/useFilledColumns.js +42 -0
- package/lib/table/features/columns/useTitleColumns.js +34 -0
- package/lib/table/features/columns/useWidthColumns.js +83 -0
- package/lib/table/features/editable/BatchEditModal.js +794 -0
- package/lib/table/features/editable/EditableCell.js +303 -0
- package/lib/table/features/editable/EditableContext.js +28 -0
- package/lib/table/features/editable/batchEditTypes.js +5 -0
- package/lib/table/features/editable/batchEditUtils.js +264 -0
- package/lib/table/features/editable/builtinEditors.js +174 -0
- package/lib/table/features/editable/index.js +75 -0
- package/lib/table/features/editable/useBatchRules.js +103 -0
- package/lib/table/features/editable/useEditable.js +701 -0
- package/lib/table/features/expand/expandUtil.js +57 -0
- package/lib/table/features/expand/index.js +32 -0
- package/lib/table/features/expand/useExpand.js +99 -0
- package/lib/table/features/filter/FilterDropdown.js +504 -0
- package/lib/table/features/filter/FilterSearch.js +34 -0
- package/lib/table/features/filter/FilterWrapper.js +32 -0
- package/lib/table/features/filter/index.js +49 -0
- package/lib/table/features/filter/useFilter.js +254 -0
- package/lib/table/features/fixed/fixUtil.js +75 -0
- package/lib/table/features/fixed/index.js +34 -0
- package/lib/table/features/fixed/offsetUtil.js +19 -0
- package/lib/table/features/fixed/useFixedInfo.js +26 -0
- package/lib/table/features/fixed/useStickyOffsets.js +35 -0
- package/lib/table/features/hover/index.js +13 -0
- package/lib/table/features/hover/useHover.js +31 -0
- package/lib/table/features/pagination/index.js +27 -0
- package/lib/table/features/pagination/usePagination.js +96 -0
- package/lib/table/features/resize/ResizeHandle.js +109 -0
- package/lib/table/features/resize/index.js +27 -0
- package/lib/table/features/resize/transformResizableColumns.js +61 -0
- package/lib/table/features/resize/useResize.js +595 -0
- package/lib/table/features/selection/index.js +39 -0
- package/lib/table/features/selection/useSelection.js +588 -0
- package/lib/table/features/sort/index.js +21 -0
- package/lib/table/features/sort/useSorter.js +381 -0
- package/lib/table/features/sticky/index.js +20 -0
- package/lib/table/features/sticky/stickyScrollBar.js +212 -0
- package/lib/table/features/sticky/useSticky.js +43 -0
- package/lib/table/features/summary/index.js +13 -0
- package/lib/table/features/virtual/index.js +26 -0
- package/lib/table/features/virtual/useFlattenRecords.js +64 -0
- package/lib/table/features/virtual/useFrame.js +74 -0
- package/lib/table/immutableHelper.js +46 -0
- package/lib/table/index.js +118 -3
- package/lib/table/interface.js +54 -2
- package/lib/table/shared/context/PerfContext.js +15 -0
- package/lib/table/shared/context/TableContext.js +13 -0
- package/lib/table/shared/hooks/useContainerWidth.js +20 -0
- package/lib/table/shared/hooks/useLazyKVMap.js +39 -0
- package/lib/table/shared/hooks/useRenderTimes.js +49 -0
- package/lib/table/shared/hooks/useRowInfo.js +80 -0
- package/lib/table/shared/utils/legacyUtil.js +38 -0
- package/lib/table/shared/utils/util.js +34 -0
- package/lib/table/shared/utils/valueUtil.js +37 -0
- package/lib/table/style/base.less +164 -0
- package/lib/table/style/bordered.less +83 -141
- package/lib/table/style/editable.less +50 -0
- package/lib/table/style/ellipsis.less +33 -0
- package/lib/table/style/empty.less +16 -0
- package/lib/table/style/expand.less +123 -0
- package/lib/table/style/filter.less +34 -0
- package/lib/table/style/fixed.less +85 -88
- package/lib/table/style/index.js +2 -1
- package/lib/table/style/index.less +19 -150
- package/lib/table/style/pagination.less +29 -0
- package/lib/table/style/radius.less +64 -0
- package/lib/table/style/resize.less +78 -0
- package/lib/table/style/rtl.less +52 -0
- package/lib/table/style/selection.less +63 -90
- package/lib/table/style/size.less +54 -0
- package/lib/table/style/sorter.less +99 -0
- package/lib/table/style/sticky.less +45 -55
- package/lib/table/style/summary.less +23 -0
- package/lib/table/style/variables.less +80 -0
- package/lib/table/style/virtual.less +95 -65
- package/package.json +148 -155
- package/esm/_util/extendsObject.d.ts +0 -4
- package/esm/_util/extendsObject.js +0 -17
- package/esm/_util/hooks/index.d.ts +0 -4
- package/esm/_util/hooks/index.js +0 -4
- package/esm/_util/hooks/useProxyImperativeHandle.d.ts +0 -4
- package/esm/_util/index.d.ts +0 -3
- package/esm/_util/isNonNullable.d.ts +0 -2
- package/esm/_util/isNonNullable.js +0 -4
- package/esm/blockHeader/index.d.ts +0 -58
- package/esm/flex/index.d.ts +0 -7
- package/esm/index.d.ts +0 -17
- package/esm/index.js +0 -14
- package/esm/overflowList/index.d.ts +0 -40
- package/esm/resizeObserver/index.d.ts +0 -45
- package/esm/splitter/index.d.ts +0 -8
- package/esm/splitter/interface.d.ts +0 -69
- package/esm/splitter/style/index.less +0 -312
- package/esm/style/mixins/index.less +0 -0
- package/esm/style/themes/index.less +0 -2
- package/esm/table/InternalTable.d.ts +0 -32
- package/esm/table/InternalTable.js +0 -429
- package/esm/table/RcTable/VirtualTable.d.ts +0 -2
- package/esm/table/RcTable/index.d.ts +0 -2
- package/esm/table/RcTable/index.js +0 -9
- package/esm/table/Table.d.ts +0 -17
- package/esm/table/index.d.ts +0 -7
- package/esm/table/index.js +0 -2
- package/esm/table/interface.d.ts +0 -196
- package/esm/table/interface.js +0 -4
- package/esm/table/style/bordered.less +0 -141
- package/esm/table/style/fixed.less +0 -88
- package/esm/table/style/index.d.ts +0 -2
- package/esm/table/style/index.js +0 -2
- package/esm/table/style/index.less +0 -150
- package/esm/table/style/selection.less +0 -90
- package/esm/table/style/sticky.less +0 -55
- package/esm/table/style/virtual.less +0 -65
- package/lib/_util/easings.d.ts +0 -1
- package/lib/_util/extendsObject.d.ts +0 -4
- package/lib/_util/extendsObject.js +0 -20
- package/lib/_util/gapSize.d.ts +0 -3
- package/lib/_util/getScroll.d.ts +0 -3
- package/lib/_util/hooks/index.d.ts +0 -4
- package/lib/_util/hooks/useForceUpdate.d.ts +0 -2
- package/lib/_util/hooks/useOrientation.d.ts +0 -2
- package/lib/_util/hooks/useProxyImperativeHandle.d.ts +0 -4
- package/lib/_util/hooks/useSyncState.d.ts +0 -3
- package/lib/_util/index.d.ts +0 -3
- package/lib/_util/isNonNullable.d.ts +0 -2
- package/lib/_util/isNonNullable.js +0 -10
- package/lib/_util/scrollTo.d.ts +0 -10
- package/lib/_util/type.d.ts +0 -52
- package/lib/_util/warning.d.ts +0 -31
- package/lib/blockHeader/index.js +0 -121
- package/lib/blockHeader/style/index.d.ts +0 -2
- package/lib/button/index.d.ts +0 -10
- package/lib/button/style/index.d.ts +0 -2
- package/lib/collapsible/index.d.ts +0 -102
- package/lib/collapsible/style/index.d.ts +0 -1
- package/lib/collapsibleActionItems/index.d.ts +0 -24
- package/lib/collapsibleActionItems/index.js +0 -68
- package/lib/collapsibleActionItems/style/index.d.ts +0 -2
- package/lib/flex/interface.d.ts +0 -16
- package/lib/flex/style/index.d.ts +0 -2
- package/lib/flex/utils.d.ts +0 -7
- package/lib/formList/index.d.ts +0 -78
- package/lib/formList/index.js +0 -130
- package/lib/formList/style/index.d.ts +0 -2
- package/lib/index.d.ts +0 -17
- package/lib/overflowList/index.js +0 -144
- package/lib/overflowList/style/index.d.ts +0 -2
- package/lib/resize/index.d.ts +0 -9
- package/lib/resizeObserver/index.js +0 -137
- package/lib/splitter/Panel.d.ts +0 -7
- package/lib/splitter/SplitBar.d.ts +0 -24
- package/lib/splitter/Splitter.d.ts +0 -5
- package/lib/splitter/hooks/sizeUtil.d.ts +0 -3
- package/lib/splitter/hooks/useItems.d.ts +0 -14
- package/lib/splitter/hooks/useResizable.d.ts +0 -10
- package/lib/splitter/hooks/useResize.d.ts +0 -6
- package/lib/splitter/hooks/useSizes.d.ts +0 -4
- package/lib/splitter/interface.d.ts +0 -69
- package/lib/splitter/style/index.d.ts +0 -2
- package/lib/statusTag/index.d.ts +0 -29
- package/lib/statusTag/index.js +0 -125
- package/lib/statusTag/style/index.d.ts +0 -2
- package/lib/style/index.d.ts +0 -1
- package/lib/style/mixins/index.less +0 -0
- package/lib/table/InternalTable.d.ts +0 -32
- package/lib/table/RcTable/VirtualTable.d.ts +0 -2
- package/lib/table/RcTable/VirtualTable.js +0 -17
- package/lib/table/RcTable/index.d.ts +0 -2
- package/lib/table/RcTable/index.js +0 -17
- package/lib/table/TableMeasureRowContext.d.ts +0 -3
- package/lib/table/hooks/useContainerWidth.d.ts +0 -1
- package/lib/table/hooks/useContainerWidth.js +0 -20
- package/lib/table/index.d.ts +0 -7
- package/lib/table/interface.d.ts +0 -196
- package/lib/table/style/index.d.ts +0 -2
- package/lib/table/util.d.ts +0 -14
- package/lib/table/util.js +0 -44
- /package/{esm → es}/_util/easings.d.ts +0 -0
- /package/{esm → es}/_util/easings.js +0 -0
- /package/{esm → es}/_util/gapSize.js +0 -0
- /package/{esm → es}/_util/getScroll.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useForceUpdate.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useForceUpdate.js +0 -0
- /package/{esm → es}/_util/hooks/useOrientation.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useOrientation.js +0 -0
- /package/{esm → es}/_util/hooks/useSyncState.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useSyncState.js +0 -0
- /package/{esm → es}/_util/scrollTo.d.ts +0 -0
- /package/{esm → es}/_util/type.js +0 -0
- /package/{esm → es}/_util/warning.d.ts +0 -0
- /package/{esm/blockHeader → es/block-header}/style/index.d.ts +0 -0
- /package/{esm/blockHeader → es/block-header}/style/index.js +0 -0
- /package/{esm → es}/button/style/index.d.ts +0 -0
- /package/{esm → es}/button/style/index.js +0 -0
- /package/{esm → es}/collapsible/index.d.ts +0 -0
- /package/{esm → es}/collapsible/style/index.d.ts +0 -0
- /package/{esm → es}/collapsible/style/index.js +0 -0
- /package/{esm/collapsibleActionItems → es/collapsible-action-items}/style/index.d.ts +0 -0
- /package/{esm/collapsibleActionItems → es/collapsible-action-items}/style/index.js +0 -0
- /package/{esm → es}/flex/interface.d.ts +0 -0
- /package/{esm → es}/flex/interface.js +0 -0
- /package/{esm → es}/flex/style/index.d.ts +0 -0
- /package/{esm → es}/flex/style/index.js +0 -0
- /package/{esm → es}/flex/utils.d.ts +0 -0
- /package/{esm → es}/flex/utils.js +0 -0
- /package/{esm/formList → es/form-list}/style/index.d.ts +0 -0
- /package/{esm/formList → es/form-list}/style/index.js +0 -0
- /package/{esm/overflowList → es/overflow-list}/style/index.d.ts +0 -0
- /package/{esm/overflowList → es/overflow-list}/style/index.js +0 -0
- /package/{esm → es}/resize/index.d.ts +0 -0
- /package/{esm → es}/resize/index.js +0 -0
- /package/{esm → es}/splitter/Splitter.d.ts +0 -0
- /package/{esm → es}/splitter/hooks/sizeUtil.d.ts +0 -0
- /package/{esm → es}/splitter/hooks/useItems.js +0 -0
- /package/{esm → es}/splitter/hooks/useSizes.d.ts +0 -0
- /package/{esm → es}/splitter/index.js +0 -0
- /package/{esm → es}/splitter/interface.js +0 -0
- /package/{esm → es}/splitter/style/index.d.ts +0 -0
- /package/{esm → es}/splitter/style/index.js +0 -0
- /package/{esm/statusTag → es/status-tag}/index.d.ts +0 -0
- /package/{esm/statusTag → es/status-tag}/style/index.d.ts +0 -0
- /package/{esm/statusTag → es/status-tag}/style/index.js +0 -0
- /package/{esm → es}/style/index.d.ts +0 -0
- /package/{esm → es}/style/index.js +0 -0
- /package/{esm → es}/table/TableMeasureRowContext.d.ts +0 -0
- /package/{esm → es}/table/TableMeasureRowContext.js +0 -0
- /package/{esm/table → es/table/shared}/hooks/useContainerWidth.d.ts +0 -0
- /package/{esm/table → es/table/shared}/hooks/useContainerWidth.js +0 -0
- /package/lib/{blockHeader → block-header}/style/index.js +0 -0
- /package/lib/{collapsibleActionItems → collapsible-action-items}/style/index.js +0 -0
- /package/lib/{formList → form-list}/style/index.js +0 -0
- /package/lib/{overflowList → overflow-list}/style/index.js +0 -0
- /package/lib/{statusTag → status-tag}/style/index.js +0 -0
|
@@ -0,0 +1,816 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(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); }
|
|
5
|
+
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; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { INTERNAL_HOOKS } from "./constant";
|
|
16
|
+
import { convertChildrenToColumns } from "./features/columns/useColumns";
|
|
17
|
+
import { omit, pickAttrs } from "../_util/rcUtil";
|
|
18
|
+
import { clsx } from 'clsx';
|
|
19
|
+
import { useProxyImperativeHandle } from "../_util/hooks/useProxyImperativeHandle";
|
|
20
|
+
import { isFunction, isNumber, isPlainObject } from "../_util/is";
|
|
21
|
+
import scrollTo from "../_util/scrollTo";
|
|
22
|
+
import { devUseWarning } from "../_util/warning";
|
|
23
|
+
import { useBreakpoint } from "../_util/hooks/useBreakpoint";
|
|
24
|
+
import useCssVar from "../_util/hooks/useCssVar";
|
|
25
|
+
import Pagination from 'antd/lib/pagination';
|
|
26
|
+
import Spin from 'antd/lib/spin';
|
|
27
|
+
import { ConfigContext, globalConfig } from 'antd/lib/config-provider';
|
|
28
|
+
import renderExpandIcon from "./components/ExpandIcon";
|
|
29
|
+
import useContainerWidth from "./shared/hooks/useContainerWidth";
|
|
30
|
+
import useFilledColumns from "./features/columns/useFilledColumns";
|
|
31
|
+
import useFilter, { getFilterData } from "./features/filter/useFilter";
|
|
32
|
+
import useLazyKVMap from "./shared/hooks/useLazyKVMap";
|
|
33
|
+
import usePagination, { DEFAULT_PAGE_SIZE, getPaginationParam } from "./features/pagination/usePagination";
|
|
34
|
+
import useSelection from "./features/selection/useSelection";
|
|
35
|
+
import useSorter, { getSortData } from "./features/sort/useSorter";
|
|
36
|
+
import useTitleColumns from "./features/columns/useTitleColumns";
|
|
37
|
+
import RcTable from "./components/RcTable";
|
|
38
|
+
import RcVirtualTable from "./components/VirtualTable";
|
|
39
|
+
import DefaultRenderEmpty from 'antd/lib/config-provider/defaultRenderEmpty';
|
|
40
|
+
import { transformResizableColumns, useResize } from "./features/resize";
|
|
41
|
+
import { EditableCell, EditableContext, parseEditableConfig, useEditable } from "./features/editable";
|
|
42
|
+
|
|
43
|
+
/** 稳定的空配置引用 */
|
|
44
|
+
var EMPTY_EDITABLE_CONFIG = {};
|
|
45
|
+
var EMPTY_LIST = [];
|
|
46
|
+
var HeaderTableContext = /*#__PURE__*/React.createContext({});
|
|
47
|
+
var HeaderTable = function HeaderTable(props) {
|
|
48
|
+
var _React$useContext = React.useContext(HeaderTableContext),
|
|
49
|
+
ariaProps = _React$useContext.ariaProps,
|
|
50
|
+
_React$useContext$com = _React$useContext.component,
|
|
51
|
+
component = _React$useContext$com === void 0 ? 'table' : _React$useContext$com;
|
|
52
|
+
return /*#__PURE__*/React.createElement(component, _objectSpread(_objectSpread({}, ariaProps), props));
|
|
53
|
+
};
|
|
54
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
55
|
+
HeaderTable.displayName = 'HeaderTable';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Same as `TableProps` but we need record parent render times */
|
|
59
|
+
|
|
60
|
+
var InternalTable = function InternalTable(props, ref) {
|
|
61
|
+
var _components$header2, _mergedPagination$cur, _mergedPagination$pag, _mergedPagination$cur2, _mergedPagination$pag2;
|
|
62
|
+
var customizePrefixCls = props.prefixCls,
|
|
63
|
+
className = props.className,
|
|
64
|
+
rootClassName = props.rootClassName,
|
|
65
|
+
style = props.style,
|
|
66
|
+
customizeSize = props.size,
|
|
67
|
+
bordered = props.bordered,
|
|
68
|
+
customizeDropdownPrefixCls = props.dropdownPrefixCls,
|
|
69
|
+
dataSource = props.dataSource,
|
|
70
|
+
pagination = props.pagination,
|
|
71
|
+
customizeRowSelection = props.rowSelection,
|
|
72
|
+
customizeRowKey = props.rowKey,
|
|
73
|
+
rowClassName = props.rowClassName,
|
|
74
|
+
column = props.column,
|
|
75
|
+
columns = props.columns,
|
|
76
|
+
children = props.children,
|
|
77
|
+
legacyChildrenColumnName = props.childrenColumnName,
|
|
78
|
+
onChange = props.onChange,
|
|
79
|
+
getPopupContainer = props.getPopupContainer,
|
|
80
|
+
loading = props.loading,
|
|
81
|
+
expandIcon = props.expandIcon,
|
|
82
|
+
expandable = props.expandable,
|
|
83
|
+
expandedRowRender = props.expandedRowRender,
|
|
84
|
+
expandIconColumnIndex = props.expandIconColumnIndex,
|
|
85
|
+
indentSize = props.indentSize,
|
|
86
|
+
scroll = props.scroll,
|
|
87
|
+
sortDirections = props.sortDirections,
|
|
88
|
+
locale = props.locale,
|
|
89
|
+
_props$showSorterTool = props.showSorterTooltip,
|
|
90
|
+
showSorterTooltip = _props$showSorterTool === void 0 ? {
|
|
91
|
+
target: 'full-header'
|
|
92
|
+
} : _props$showSorterTool,
|
|
93
|
+
virtual = props.virtual,
|
|
94
|
+
_props$resizable = props.resizable,
|
|
95
|
+
resizable = _props$resizable === void 0 ? false : _props$resizable,
|
|
96
|
+
onColumnResizeProp = props.onColumnResize,
|
|
97
|
+
_props$editable = props.editable,
|
|
98
|
+
editableEnabled = _props$editable === void 0 ? false : _props$editable,
|
|
99
|
+
onEditableChange = props.onEditableChange,
|
|
100
|
+
onValidateProp = props.onValidate;
|
|
101
|
+
var warning = devUseWarning('Table');
|
|
102
|
+
var rawColumns = React.useMemo(function () {
|
|
103
|
+
return columns || convertChildrenToColumns(children);
|
|
104
|
+
}, [columns, children]);
|
|
105
|
+
var baseColumns = useFilledColumns(rawColumns, column);
|
|
106
|
+
var needResponsive = React.useMemo(function () {
|
|
107
|
+
return baseColumns.some(function (col) {
|
|
108
|
+
return col.responsive;
|
|
109
|
+
});
|
|
110
|
+
}, [baseColumns]);
|
|
111
|
+
var screens = useBreakpoint(needResponsive);
|
|
112
|
+
var mergedColumns = React.useMemo(function () {
|
|
113
|
+
var matched = new Set(Object.keys(screens).filter(function (m) {
|
|
114
|
+
return screens[m];
|
|
115
|
+
}));
|
|
116
|
+
return baseColumns.filter(function (c) {
|
|
117
|
+
return !c.responsive || c.responsive.some(function (r) {
|
|
118
|
+
return matched.has(r);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}, [baseColumns, screens]);
|
|
122
|
+
|
|
123
|
+
// ========================= Column Resize (hasResizableColumns check only) =========================
|
|
124
|
+
var hasResizableColumns = React.useMemo(function () {
|
|
125
|
+
return resizable || mergedColumns.some(function (col) {
|
|
126
|
+
return 'resizable' in col ? col.resizable === true : false;
|
|
127
|
+
});
|
|
128
|
+
}, [resizable, mergedColumns]);
|
|
129
|
+
|
|
130
|
+
// ========================= Editable =========================
|
|
131
|
+
var hasEditableColumns = React.useMemo(function () {
|
|
132
|
+
return editableEnabled || mergedColumns.some(function (col) {
|
|
133
|
+
var ed = 'editable' in col ? col.editable : undefined;
|
|
134
|
+
// 与 parseEditableConfig 语义对齐:列显式开启 = true 或任意配置对象;
|
|
135
|
+
// editable === false(显式关闭)或未配置 → 非显式开启,
|
|
136
|
+
// 全局开启时由 parseEditableConfig 继承、false 时优先关闭
|
|
137
|
+
return ed === true || ed !== null && _typeof(ed) === 'object';
|
|
138
|
+
});
|
|
139
|
+
}, [editableEnabled, mergedColumns]);
|
|
140
|
+
var tableProps = omit(props, ['className', 'style', 'column', 'columns', 'resizable', 'onColumnResize', 'editable', 'onEditableChange', 'onValidate']);
|
|
141
|
+
var components = tableProps.components;
|
|
142
|
+
var ariaProps = pickAttrs(tableProps, {
|
|
143
|
+
aria: true
|
|
144
|
+
});
|
|
145
|
+
var hasAriaProps = Object.keys(ariaProps).length > 0;
|
|
146
|
+
var headerTableContext = React.useMemo(function () {
|
|
147
|
+
var _components$header;
|
|
148
|
+
return {
|
|
149
|
+
ariaProps: ariaProps,
|
|
150
|
+
component: components === null || components === void 0 || (_components$header = components.header) === null || _components$header === void 0 ? void 0 : _components$header.table
|
|
151
|
+
};
|
|
152
|
+
}, [ariaProps, components === null || components === void 0 || (_components$header2 = components.header) === null || _components$header2 === void 0 ? void 0 : _components$header2.table]);
|
|
153
|
+
var prefixCls = globalConfig().getPrefixCls('table', customizePrefixCls);
|
|
154
|
+
|
|
155
|
+
// ============================= Refs =============================
|
|
156
|
+
var rootRef = React.useRef(null);
|
|
157
|
+
var tblRef = React.useRef(null);
|
|
158
|
+
|
|
159
|
+
// ========================= Column Resize (hook needs rootRef) =========================
|
|
160
|
+
var resizeResult = useResize({
|
|
161
|
+
columns: mergedColumns,
|
|
162
|
+
enabled: resizable,
|
|
163
|
+
containerRef: rootRef,
|
|
164
|
+
onColumnResize: onColumnResizeProp,
|
|
165
|
+
prefixCls: prefixCls
|
|
166
|
+
});
|
|
167
|
+
var mergedComponents = React.useMemo(function () {
|
|
168
|
+
if (!hasAriaProps) return components;
|
|
169
|
+
return _objectSpread(_objectSpread({}, components), {}, {
|
|
170
|
+
header: _objectSpread(_objectSpread({}, components === null || components === void 0 ? void 0 : components.header), {}, {
|
|
171
|
+
table: HeaderTable
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}, [components, hasAriaProps]);
|
|
175
|
+
|
|
176
|
+
// Use antd@4 ConfigContext for locale and renderEmpty
|
|
177
|
+
var _ref = React.useContext(ConfigContext),
|
|
178
|
+
contextLocale = _ref.locale,
|
|
179
|
+
renderEmpty = _ref.renderEmpty,
|
|
180
|
+
getContextPopupContainer = _ref.getPopupContainer;
|
|
181
|
+
var tableLocale = _objectSpread(_objectSpread({
|
|
182
|
+
filterTitle: 'Filter',
|
|
183
|
+
filterConfirm: 'OK',
|
|
184
|
+
filterReset: 'Reset',
|
|
185
|
+
filterEmptyText: 'No filters',
|
|
186
|
+
filterCheckAll: 'Select all items',
|
|
187
|
+
filterSearchPlaceholder: 'Search in filters',
|
|
188
|
+
emptyText: (renderEmpty === null || renderEmpty === void 0 ? void 0 : renderEmpty('Table')) || 'No data',
|
|
189
|
+
selectAll: 'Select current page',
|
|
190
|
+
selectInvert: 'Invert current page',
|
|
191
|
+
selectNone: 'Clear all data',
|
|
192
|
+
selectionAll: 'Select all data',
|
|
193
|
+
sortTitle: 'Sort',
|
|
194
|
+
expand: 'Expand row',
|
|
195
|
+
collapse: 'Collapse row',
|
|
196
|
+
triggerDesc: 'Click to sort descending',
|
|
197
|
+
triggerAsc: 'Click to sort ascending',
|
|
198
|
+
cancelSort: 'Click to cancel sorting'
|
|
199
|
+
}, contextLocale === null || contextLocale === void 0 ? void 0 : contextLocale.Table), locale);
|
|
200
|
+
var rawData = dataSource || EMPTY_LIST;
|
|
201
|
+
var dropdownPrefixCls = globalConfig().getPrefixCls('dropdown', customizeDropdownPrefixCls);
|
|
202
|
+
var mergedRowSelection = React.useMemo(function () {
|
|
203
|
+
return isPlainObject(customizeRowSelection) ? _objectSpread({}, customizeRowSelection) : customizeRowSelection;
|
|
204
|
+
}, [customizeRowSelection]);
|
|
205
|
+
var mergedExpandable = _objectSpread({
|
|
206
|
+
childrenColumnName: legacyChildrenColumnName,
|
|
207
|
+
expandIconColumnIndex: expandIconColumnIndex
|
|
208
|
+
}, expandable);
|
|
209
|
+
var _mergedExpandable$chi = mergedExpandable.childrenColumnName,
|
|
210
|
+
childrenColumnName = _mergedExpandable$chi === void 0 ? 'children' : _mergedExpandable$chi;
|
|
211
|
+
var expandType = React.useMemo(function () {
|
|
212
|
+
if (rawData.some(function (item) {
|
|
213
|
+
return item === null || item === void 0 ? void 0 : item[childrenColumnName];
|
|
214
|
+
})) {
|
|
215
|
+
return 'nest';
|
|
216
|
+
}
|
|
217
|
+
if (expandedRowRender || expandable !== null && expandable !== void 0 && expandable.expandedRowRender) {
|
|
218
|
+
return 'row';
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}, [childrenColumnName, rawData]);
|
|
222
|
+
var internalRef = {
|
|
223
|
+
body: React.useRef(null)
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// ============================ Width =============================
|
|
227
|
+
var getContainerWidth = useContainerWidth(prefixCls);
|
|
228
|
+
|
|
229
|
+
// 用 resize 后的渲染宽度覆盖列的 width
|
|
230
|
+
// renderWidth = column.width + 容器剩余空间分配到最后一列(撑满容器,不留空)
|
|
231
|
+
var finalColumns = React.useMemo(function () {
|
|
232
|
+
if (!hasResizableColumns) return mergedColumns;
|
|
233
|
+
return mergedColumns.map(function (col) {
|
|
234
|
+
var width = resizeResult.getColumnRenderWidth(col);
|
|
235
|
+
return width != null ? _objectSpread(_objectSpread({}, col), {}, {
|
|
236
|
+
width: width
|
|
237
|
+
}) : col;
|
|
238
|
+
});
|
|
239
|
+
}, [mergedColumns, hasResizableColumns, resizeResult.renderWidths]);
|
|
240
|
+
|
|
241
|
+
// 用于暴露 validate / resetErrors 的 ref
|
|
242
|
+
var editableMethodsRef = React.useRef(null);
|
|
243
|
+
|
|
244
|
+
// 跨页滚动 timer ref(防止组件卸载后 timer 泄漏)
|
|
245
|
+
var scrollTimerRef = React.useRef(null);
|
|
246
|
+
React.useEffect(function () {
|
|
247
|
+
return function () {
|
|
248
|
+
if (scrollTimerRef.current) clearTimeout(scrollTimerRef.current);
|
|
249
|
+
};
|
|
250
|
+
}, []);
|
|
251
|
+
|
|
252
|
+
// ============================ RowKey ============================
|
|
253
|
+
var rowKey = customizeRowKey || 'key';
|
|
254
|
+
|
|
255
|
+
// ============================ Scroll ============================
|
|
256
|
+
// 当 resize 启用且容器宽度已测量时,用 scrollX(= renderWidths 总和)覆盖 scroll.x
|
|
257
|
+
// 确保 table 宽度 = 列宽总和,避免不匹配导致的滚动条问题
|
|
258
|
+
var mergedScroll = React.useMemo(function () {
|
|
259
|
+
if (hasResizableColumns && resizeResult.scrollX != null) {
|
|
260
|
+
return _objectSpread(_objectSpread({}, scroll), {}, {
|
|
261
|
+
x: resizeResult.scrollX
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return scroll;
|
|
265
|
+
}, [scroll, hasResizableColumns, resizeResult.scrollX]);
|
|
266
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
267
|
+
warning(!(isFunction(rowKey) && rowKey.length > 1), 'usage', '`index` parameter of `rowKey` function is deprecated. There is no guarantee that it will work as expected.');
|
|
268
|
+
}
|
|
269
|
+
var getRowKey = React.useMemo(function () {
|
|
270
|
+
if (isFunction(rowKey)) {
|
|
271
|
+
return rowKey;
|
|
272
|
+
}
|
|
273
|
+
return function (record) {
|
|
274
|
+
return record === null || record === void 0 ? void 0 : record[rowKey];
|
|
275
|
+
};
|
|
276
|
+
}, [rowKey]);
|
|
277
|
+
var _useLazyKVMap = useLazyKVMap(rawData, childrenColumnName, getRowKey),
|
|
278
|
+
_useLazyKVMap2 = _slicedToArray(_useLazyKVMap, 1),
|
|
279
|
+
getRecordByKey = _useLazyKVMap2[0];
|
|
280
|
+
|
|
281
|
+
// 分页偏移量 ref — 用于将 page-local rowIndex 转换为 rawData 全局 index
|
|
282
|
+
// 修复 BUG: 分页时 EditableCell 收到的是 page-local index,但 useEditable 的
|
|
283
|
+
// onCellChange / validateCell 用此 index 匹配 rawData,导致跨页编辑写入错误行。
|
|
284
|
+
var pageOffsetRef = React.useRef(0);
|
|
285
|
+
|
|
286
|
+
// mergedData(排序/筛选后、分页前)ref — scrollToRow 按 rowKey 定位行所在页时使用。
|
|
287
|
+
// useEditable 在 mergedData 计算之前调用,所以用 ref 传递(同 paginationInfoRef 模式)。
|
|
288
|
+
var mergedDataRef = React.useRef(EMPTY_LIST);
|
|
289
|
+
|
|
290
|
+
// 分页控制 ref — validate 时用于自动跳转到错误行所在页
|
|
291
|
+
// useEditable 在 usePagination 之前调用,所以用 ref 传递
|
|
292
|
+
var resetPaginationRef = React.useRef(function () {});
|
|
293
|
+
var paginationInfoRef = React.useRef({
|
|
294
|
+
current: 1,
|
|
295
|
+
pageSize: 10,
|
|
296
|
+
enabled: false
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// ============================ Editable =============================
|
|
300
|
+
var editableResult = useEditable({
|
|
301
|
+
columns: mergedColumns,
|
|
302
|
+
data: rawData,
|
|
303
|
+
onChange: onEditableChange,
|
|
304
|
+
onValidate: onValidateProp,
|
|
305
|
+
getRowKey: getRowKey,
|
|
306
|
+
childrenColumnName: childrenColumnName,
|
|
307
|
+
scrollToRow: function scrollToRow(key, idx) {
|
|
308
|
+
var _paginationInfoRef$cu = paginationInfoRef.current,
|
|
309
|
+
current = _paginationInfoRef$cu.current,
|
|
310
|
+
pageSize = _paginationInfoRef$cu.pageSize,
|
|
311
|
+
enabled = _paginationInfoRef$cu.enabled;
|
|
312
|
+
// 在 mergedData(排序/筛选后、分页前)中按 key 定位顶层行下标;
|
|
313
|
+
// 树形子行归属于其顶层祖先。定位失败(无 key / 行被过滤掉)降级为传入下标。
|
|
314
|
+
var matchRow = function matchRow(row, index) {
|
|
315
|
+
if (getRowKey(row, index) === key) return true;
|
|
316
|
+
var children = row === null || row === void 0 ? void 0 : row[childrenColumnName];
|
|
317
|
+
return Array.isArray(children) && children.some(function (child, ci) {
|
|
318
|
+
return matchRow(child, ci);
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
var list = mergedDataRef.current;
|
|
322
|
+
var topIndex = -1;
|
|
323
|
+
for (var i = 0; i < list.length; i += 1) {
|
|
324
|
+
if (matchRow(list[i], i)) {
|
|
325
|
+
topIndex = i;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
var foundByKey = topIndex !== -1;
|
|
330
|
+
if (!foundByKey) topIndex = idx;
|
|
331
|
+
var scrollToRowOnPage = function scrollToRowOnPage(pageLocalIdx) {
|
|
332
|
+
// key 定位成功时直接按 key 滚动(树形子行也能命中);否则用页内下标
|
|
333
|
+
if (foundByKey) {
|
|
334
|
+
var _tblRef$current;
|
|
335
|
+
(_tblRef$current = tblRef.current) === null || _tblRef$current === void 0 || _tblRef$current.scrollTo({
|
|
336
|
+
key: key,
|
|
337
|
+
align: 'center'
|
|
338
|
+
});
|
|
339
|
+
} else {
|
|
340
|
+
var _tblRef$current2;
|
|
341
|
+
(_tblRef$current2 = tblRef.current) === null || _tblRef$current2 === void 0 || _tblRef$current2.scrollTo({
|
|
342
|
+
index: pageLocalIdx,
|
|
343
|
+
align: 'center'
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
if (enabled && pageSize > 0) {
|
|
348
|
+
var targetPage = Math.floor(topIndex / pageSize) + 1;
|
|
349
|
+
if (targetPage !== current) {
|
|
350
|
+
if (isPlainObject(pagination) && pagination.current !== undefined) {
|
|
351
|
+
var _pagination$onChange;
|
|
352
|
+
// 受控分页:current 由外部持有,内部 setState 无法换页(merge 时受控值优先),
|
|
353
|
+
// 自动跳页只能通过 onChange 发起请求,由外部响应后更新 current
|
|
354
|
+
(_pagination$onChange = pagination.onChange) === null || _pagination$onChange === void 0 || _pagination$onChange.call(pagination, targetPage, pageSize);
|
|
355
|
+
} else {
|
|
356
|
+
// 切换到错误行所在页
|
|
357
|
+
resetPaginationRef.current(targetPage, pageSize);
|
|
358
|
+
}
|
|
359
|
+
// 等待页面渲染后滚动到错误行(page-local index)
|
|
360
|
+
var localIdx = topIndex - (targetPage - 1) * pageSize;
|
|
361
|
+
if (scrollTimerRef.current) clearTimeout(scrollTimerRef.current);
|
|
362
|
+
scrollTimerRef.current = setTimeout(function () {
|
|
363
|
+
scrollToRowOnPage(localIdx);
|
|
364
|
+
scrollTimerRef.current = null;
|
|
365
|
+
}, 50);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
// 同页:直接滚动(使用 page-local index)
|
|
369
|
+
scrollToRowOnPage(topIndex - (current - 1) * pageSize);
|
|
370
|
+
} else {
|
|
371
|
+
// 无分页:直接用全局 index 滚动
|
|
372
|
+
scrollToRowOnPage(topIndex);
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
enabled: hasEditableColumns
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
// 暴露 validate / resetErrors 到 ref
|
|
379
|
+
// validate 不传参数,内部用 dataRef.current 获取最新数据
|
|
380
|
+
editableMethodsRef.current = hasEditableColumns ? {
|
|
381
|
+
validate: function validate() {
|
|
382
|
+
return editableResult.validateAll();
|
|
383
|
+
},
|
|
384
|
+
resetErrors: editableResult.resetErrors
|
|
385
|
+
} : null;
|
|
386
|
+
|
|
387
|
+
// 用于稳定 validate / resetErrors 引用,配合 useProxyImperativeHandle deps=[]
|
|
388
|
+
// 避免 each render 重建 Proxy
|
|
389
|
+
var validateAllRef = React.useRef(editableResult.validateAll);
|
|
390
|
+
validateAllRef.current = editableResult.validateAll;
|
|
391
|
+
var resetErrorsRef = React.useRef(editableResult.resetErrors);
|
|
392
|
+
resetErrorsRef.current = editableResult.resetErrors;
|
|
393
|
+
var resetColumnWidthsRef = React.useRef(resizeResult.resetColumnWidths);
|
|
394
|
+
resetColumnWidthsRef.current = resizeResult.resetColumnWidths;
|
|
395
|
+
|
|
396
|
+
// useImperativeHandle 在 commit 阶段执行(DOM ref 已挂载),
|
|
397
|
+
// 所以直接读 rootRef.current / tblRef.current 即可。
|
|
398
|
+
// deps=[] 保证只创建一次 Proxy;方法通过 ref 间接访问最新值。
|
|
399
|
+
useProxyImperativeHandle(ref, function () {
|
|
400
|
+
return {
|
|
401
|
+
nativeElement: rootRef.current,
|
|
402
|
+
// 惰性间接调用,不展开 tblRef.current:
|
|
403
|
+
// 1. 展开会形成首次渲染快照 — RcTable 的 scrollTo 闭包捕获当次 render 的
|
|
404
|
+
// mergedData/getRowKey,dataSource/分页变化后用旧数据解析 rowKey 导致找不到/找错行;
|
|
405
|
+
// 2. 展开会对 getter 提前求值(如虚拟表格 BodyGrid 的 scrollLeft/scrollTop 变成静态数字)。
|
|
406
|
+
scrollTo: function scrollTo(config) {
|
|
407
|
+
var _tblRef$current3, _tblRef$current3$scro;
|
|
408
|
+
return (_tblRef$current3 = tblRef.current) === null || _tblRef$current3 === void 0 || (_tblRef$current3$scro = _tblRef$current3.scrollTo) === null || _tblRef$current3$scro === void 0 ? void 0 : _tblRef$current3$scro.call(_tblRef$current3, config);
|
|
409
|
+
},
|
|
410
|
+
validate: function validate() {
|
|
411
|
+
var _validateAllRef$curre, _validateAllRef$curre2;
|
|
412
|
+
return (_validateAllRef$curre = (_validateAllRef$curre2 = validateAllRef.current) === null || _validateAllRef$curre2 === void 0 ? void 0 : _validateAllRef$curre2.call(validateAllRef)) !== null && _validateAllRef$curre !== void 0 ? _validateAllRef$curre : Promise.resolve({
|
|
413
|
+
valid: true,
|
|
414
|
+
errors: new Map()
|
|
415
|
+
});
|
|
416
|
+
},
|
|
417
|
+
resetErrors: function resetErrors() {
|
|
418
|
+
var _resetErrorsRef$curre;
|
|
419
|
+
return (_resetErrorsRef$curre = resetErrorsRef.current) === null || _resetErrorsRef$curre === void 0 ? void 0 : _resetErrorsRef$curre.call(resetErrorsRef);
|
|
420
|
+
},
|
|
421
|
+
resetColumnWidths: function resetColumnWidths() {
|
|
422
|
+
var _resetColumnWidthsRef;
|
|
423
|
+
return (_resetColumnWidthsRef = resetColumnWidthsRef.current) === null || _resetColumnWidthsRef === void 0 ? void 0 : _resetColumnWidthsRef.call(resetColumnWidthsRef);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}, []);
|
|
427
|
+
|
|
428
|
+
// 可编辑列 transform
|
|
429
|
+
// 错误状态通过 EditableContext 传递,不需要重建列 transform。
|
|
430
|
+
// 如果依赖 errors 会导致每次校验都重建整个列结构,引发全表重渲染,严重影响输入性能。
|
|
431
|
+
var transformEditableColumns = React.useCallback(function (cols) {
|
|
432
|
+
if (!hasEditableColumns) return cols;
|
|
433
|
+
return cols.map(function (col) {
|
|
434
|
+
// 列组(表头合并):递归处理子列
|
|
435
|
+
if ('children' in col && col.children) {
|
|
436
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
437
|
+
children: transformEditableColumns(col.children)
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
var leafCol = col;
|
|
441
|
+
var parsed = parseEditableConfig(leafCol.editable, editableEnabled);
|
|
442
|
+
if (!parsed.enabled) return col;
|
|
443
|
+
|
|
444
|
+
// 全局 editable 开启时,跳过没有 dataIndex 的列(如操作列),
|
|
445
|
+
// 避免将原始 render 的返回值(React 元素)当作 value 传给 EditableCell,
|
|
446
|
+
// 导致显示 [object Object]。
|
|
447
|
+
// 列级显式设置 editable 时仍然生效(用户明确要求编辑此列)。
|
|
448
|
+
if (!leafCol.editable && !leafCol.dataIndex && leafCol.dataIndex !== 0) {
|
|
449
|
+
return col;
|
|
450
|
+
}
|
|
451
|
+
return _objectSpread(_objectSpread({}, leafCol), {}, {
|
|
452
|
+
render: function render(value, record, index) {
|
|
453
|
+
var _parsed$config;
|
|
454
|
+
// index 是 pageData 的局部索引,加上 pageOffset 后才是 rawData 全局索引。
|
|
455
|
+
// rowKey 是排序/筛选/树形展开后唯一稳定的行标识:editable 链路(提交、错误查找)
|
|
456
|
+
// 都以 rowKey 定位,globalRowIndex 仅作无 key 时的降级与列回调参数。
|
|
457
|
+
var globalRowIndex = index + pageOffsetRef.current;
|
|
458
|
+
return /*#__PURE__*/React.createElement(EditableCell
|
|
459
|
+
// `EditableCell` contracts `dataIndex`/`title` as plain render values;
|
|
460
|
+
// pass the column config through as-is.
|
|
461
|
+
, {
|
|
462
|
+
dataIndex: leafCol.dataIndex,
|
|
463
|
+
title: leafCol.title,
|
|
464
|
+
rowKey: getRowKey(record, index),
|
|
465
|
+
rowIndex: globalRowIndex,
|
|
466
|
+
record: record,
|
|
467
|
+
value: value,
|
|
468
|
+
editableConfig: (_parsed$config = parsed.config) !== null && _parsed$config !== void 0 ? _parsed$config : EMPTY_EDITABLE_CONFIG,
|
|
469
|
+
prefixCls: prefixCls
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
}, [hasEditableColumns, editableEnabled, prefixCls, getRowKey]);
|
|
475
|
+
|
|
476
|
+
// ============================ Events =============================
|
|
477
|
+
var changeEventInfo = {};
|
|
478
|
+
var triggerOnChange = function triggerOnChange(info, action) {
|
|
479
|
+
var reset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
480
|
+
var changeInfo = _objectSpread(_objectSpread({}, changeEventInfo), info);
|
|
481
|
+
if (reset) {
|
|
482
|
+
var _changeEventInfo$rese, _changeInfo$paginatio;
|
|
483
|
+
(_changeEventInfo$rese = changeEventInfo.resetPagination) === null || _changeEventInfo$rese === void 0 || _changeEventInfo$rese.call(changeEventInfo);
|
|
484
|
+
if ((_changeInfo$paginatio = changeInfo.pagination) !== null && _changeInfo$paginatio !== void 0 && _changeInfo$paginatio.current) {
|
|
485
|
+
changeInfo.pagination.current = 1;
|
|
486
|
+
}
|
|
487
|
+
if (pagination) {
|
|
488
|
+
var _pagination$onChange2, _changeInfo$paginatio2;
|
|
489
|
+
(_pagination$onChange2 = pagination.onChange) === null || _pagination$onChange2 === void 0 || _pagination$onChange2.call(pagination, 1, (_changeInfo$paginatio2 = changeInfo.pagination) === null || _changeInfo$paginatio2 === void 0 ? void 0 : _changeInfo$paginatio2.pageSize);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (scroll && scroll.scrollToFirstRowOnChange !== false && internalRef.body.current) {
|
|
493
|
+
scrollTo(0, {
|
|
494
|
+
getContainer: function getContainer() {
|
|
495
|
+
return internalRef.body.current;
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
onChange === null || onChange === void 0 || onChange(changeInfo.pagination, changeInfo.filters, changeInfo.sorter, {
|
|
500
|
+
currentDataSource: getFilterData(getSortData(rawData, changeInfo.sorterStates, childrenColumnName), changeInfo.filterStates, childrenColumnName),
|
|
501
|
+
action: action
|
|
502
|
+
});
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
// ============================ Sorter =============================
|
|
506
|
+
var onSorterChange = function onSorterChange(sorter, sorterStates) {
|
|
507
|
+
triggerOnChange({
|
|
508
|
+
sorter: sorter,
|
|
509
|
+
sorterStates: sorterStates
|
|
510
|
+
}, 'sort', false);
|
|
511
|
+
};
|
|
512
|
+
var _useSorter = useSorter({
|
|
513
|
+
prefixCls: prefixCls,
|
|
514
|
+
mergedColumns: mergedColumns,
|
|
515
|
+
baseColumns: baseColumns,
|
|
516
|
+
onSorterChange: onSorterChange,
|
|
517
|
+
sortDirections: sortDirections || ['ascend', 'descend'],
|
|
518
|
+
tableLocale: tableLocale,
|
|
519
|
+
showSorterTooltip: showSorterTooltip
|
|
520
|
+
}),
|
|
521
|
+
_useSorter2 = _slicedToArray(_useSorter, 4),
|
|
522
|
+
transformSorterColumns = _useSorter2[0],
|
|
523
|
+
sortStates = _useSorter2[1],
|
|
524
|
+
sorterTitleProps = _useSorter2[2],
|
|
525
|
+
getSorters = _useSorter2[3];
|
|
526
|
+
var sortedData = React.useMemo(function () {
|
|
527
|
+
return getSortData(rawData, sortStates, childrenColumnName);
|
|
528
|
+
}, [childrenColumnName, rawData, sortStates]);
|
|
529
|
+
changeEventInfo.sorter = getSorters();
|
|
530
|
+
changeEventInfo.sorterStates = sortStates;
|
|
531
|
+
|
|
532
|
+
// ============================ Filter ============================
|
|
533
|
+
var onFilterChange = function onFilterChange(filters, filterStates) {
|
|
534
|
+
triggerOnChange({
|
|
535
|
+
filters: filters,
|
|
536
|
+
filterStates: filterStates
|
|
537
|
+
}, 'filter', true);
|
|
538
|
+
};
|
|
539
|
+
var _useFilter = useFilter({
|
|
540
|
+
prefixCls: prefixCls,
|
|
541
|
+
locale: tableLocale,
|
|
542
|
+
dropdownPrefixCls: dropdownPrefixCls,
|
|
543
|
+
mergedColumns: mergedColumns,
|
|
544
|
+
onFilterChange: onFilterChange,
|
|
545
|
+
getPopupContainer: getPopupContainer || getContextPopupContainer,
|
|
546
|
+
rootClassName: rootClassName
|
|
547
|
+
}),
|
|
548
|
+
_useFilter2 = _slicedToArray(_useFilter, 3),
|
|
549
|
+
transformFilterColumns = _useFilter2[0],
|
|
550
|
+
filterStates = _useFilter2[1],
|
|
551
|
+
filters = _useFilter2[2];
|
|
552
|
+
var mergedData = getFilterData(sortedData, filterStates, childrenColumnName);
|
|
553
|
+
mergedDataRef.current = mergedData;
|
|
554
|
+
changeEventInfo.filters = filters;
|
|
555
|
+
changeEventInfo.filterStates = filterStates;
|
|
556
|
+
|
|
557
|
+
// ============================ Column ============================
|
|
558
|
+
var columnTitleProps = React.useMemo(function () {
|
|
559
|
+
var mergedFilters = {};
|
|
560
|
+
Object.keys(filters).forEach(function (filterKey) {
|
|
561
|
+
if (filters[filterKey] !== null) {
|
|
562
|
+
mergedFilters[filterKey] = filters[filterKey];
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
return _objectSpread(_objectSpread({}, sorterTitleProps), {}, {
|
|
566
|
+
filters: mergedFilters
|
|
567
|
+
});
|
|
568
|
+
}, [sorterTitleProps, filters]);
|
|
569
|
+
var _useTitleColumns = useTitleColumns(columnTitleProps),
|
|
570
|
+
_useTitleColumns2 = _slicedToArray(_useTitleColumns, 1),
|
|
571
|
+
transformTitleColumns = _useTitleColumns2[0];
|
|
572
|
+
|
|
573
|
+
// ========================== Pagination ==========================
|
|
574
|
+
var onPaginationChange = function onPaginationChange(current, pageSize) {
|
|
575
|
+
triggerOnChange({
|
|
576
|
+
pagination: _objectSpread(_objectSpread({}, changeEventInfo.pagination), {}, {
|
|
577
|
+
current: current,
|
|
578
|
+
pageSize: pageSize
|
|
579
|
+
})
|
|
580
|
+
}, 'paginate');
|
|
581
|
+
};
|
|
582
|
+
var _usePagination = usePagination(mergedData.length, onPaginationChange, pagination),
|
|
583
|
+
_usePagination2 = _slicedToArray(_usePagination, 2),
|
|
584
|
+
mergedPagination = _usePagination2[0],
|
|
585
|
+
resetPagination = _usePagination2[1];
|
|
586
|
+
changeEventInfo.pagination = pagination === false ? {} : getPaginationParam(mergedPagination, pagination);
|
|
587
|
+
changeEventInfo.resetPagination = resetPagination;
|
|
588
|
+
|
|
589
|
+
// 更新分页偏移量 ref — 在 transformEditableColumns 中使用
|
|
590
|
+
// 必须在 pageData 计算之前更新,因为 transformEditableColumns 在渲染期间被调用
|
|
591
|
+
pageOffsetRef.current = pagination === false || !mergedPagination.pageSize ? 0 : (((_mergedPagination$cur = mergedPagination.current) !== null && _mergedPagination$cur !== void 0 ? _mergedPagination$cur : 1) - 1) * ((_mergedPagination$pag = mergedPagination.pageSize) !== null && _mergedPagination$pag !== void 0 ? _mergedPagination$pag : 10);
|
|
592
|
+
|
|
593
|
+
// 更新分页控制 ref — validate 时使用
|
|
594
|
+
paginationInfoRef.current = {
|
|
595
|
+
current: (_mergedPagination$cur2 = mergedPagination.current) !== null && _mergedPagination$cur2 !== void 0 ? _mergedPagination$cur2 : 1,
|
|
596
|
+
pageSize: (_mergedPagination$pag2 = mergedPagination.pageSize) !== null && _mergedPagination$pag2 !== void 0 ? _mergedPagination$pag2 : 10,
|
|
597
|
+
enabled: pagination !== false
|
|
598
|
+
};
|
|
599
|
+
resetPaginationRef.current = resetPagination;
|
|
600
|
+
|
|
601
|
+
// ============================= Data =============================
|
|
602
|
+
var pageData = React.useMemo(function () {
|
|
603
|
+
if (pagination === false || !mergedPagination.pageSize) {
|
|
604
|
+
return mergedData;
|
|
605
|
+
}
|
|
606
|
+
var _mergedPagination$cur3 = mergedPagination.current,
|
|
607
|
+
current = _mergedPagination$cur3 === void 0 ? 1 : _mergedPagination$cur3,
|
|
608
|
+
total = mergedPagination.total,
|
|
609
|
+
_mergedPagination$pag3 = mergedPagination.pageSize,
|
|
610
|
+
pageSize = _mergedPagination$pag3 === void 0 ? DEFAULT_PAGE_SIZE : _mergedPagination$pag3;
|
|
611
|
+
warning(current > 0, 'usage', '`current` should be positive number.');
|
|
612
|
+
if (mergedData.length < total) {
|
|
613
|
+
if (mergedData.length > pageSize) {
|
|
614
|
+
warning(false, 'usage', '`dataSource` length is less than `pagination.total` but large than `pagination.pageSize`. Please make sure your config correct data with async mode.');
|
|
615
|
+
return mergedData.slice((current - 1) * pageSize, current * pageSize);
|
|
616
|
+
}
|
|
617
|
+
return mergedData;
|
|
618
|
+
}
|
|
619
|
+
return mergedData.slice((current - 1) * pageSize, current * pageSize);
|
|
620
|
+
}, [!!pagination, mergedData, mergedPagination === null || mergedPagination === void 0 ? void 0 : mergedPagination.current, mergedPagination === null || mergedPagination === void 0 ? void 0 : mergedPagination.pageSize, mergedPagination === null || mergedPagination === void 0 ? void 0 : mergedPagination.total]);
|
|
621
|
+
|
|
622
|
+
// ========================== Selections ==========================
|
|
623
|
+
var _useSelection = useSelection({
|
|
624
|
+
prefixCls: prefixCls,
|
|
625
|
+
data: mergedData,
|
|
626
|
+
pageData: pageData,
|
|
627
|
+
getRowKey: getRowKey,
|
|
628
|
+
getRecordByKey: getRecordByKey,
|
|
629
|
+
expandType: expandType,
|
|
630
|
+
childrenColumnName: childrenColumnName,
|
|
631
|
+
locale: tableLocale,
|
|
632
|
+
getPopupContainer: getPopupContainer || getContextPopupContainer
|
|
633
|
+
}, mergedRowSelection),
|
|
634
|
+
_useSelection2 = _slicedToArray(_useSelection, 2),
|
|
635
|
+
transformSelectionColumns = _useSelection2[0],
|
|
636
|
+
selectedKeySet = _useSelection2[1];
|
|
637
|
+
var internalRowClassName = function internalRowClassName(record, index, indent) {
|
|
638
|
+
return clsx(_defineProperty({}, "".concat(prefixCls, "-row-selected"), selectedKeySet.has(getRowKey(record, index))), isFunction(rowClassName) ? rowClassName(record, index, indent) : rowClassName);
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// ========================== Expandable ==========================
|
|
642
|
+
|
|
643
|
+
mergedExpandable.__PARENT_RENDER_ICON__ = mergedExpandable.expandIcon;
|
|
644
|
+
mergedExpandable.expandIcon = mergedExpandable.expandIcon || expandIcon || renderExpandIcon(tableLocale);
|
|
645
|
+
if (expandType === 'nest' && mergedExpandable.expandIconColumnIndex === undefined) {
|
|
646
|
+
mergedExpandable.expandIconColumnIndex = mergedRowSelection ? 1 : 0;
|
|
647
|
+
} else if (mergedExpandable.expandIconColumnIndex > 0 && mergedRowSelection) {
|
|
648
|
+
mergedExpandable.expandIconColumnIndex -= 1;
|
|
649
|
+
}
|
|
650
|
+
if (!isNumber(mergedExpandable.indentSize)) {
|
|
651
|
+
mergedExpandable.indentSize = isNumber(indentSize) ? indentSize : 15;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// ============================ Render ============================
|
|
655
|
+
var transformColumns = React.useCallback(function (innerColumns) {
|
|
656
|
+
var result = transformTitleColumns(transformSelectionColumns(transformFilterColumns(transformSorterColumns(transformEditableColumns(innerColumns)))));
|
|
657
|
+
// 在 transformColumns 链末端注入 resize(resize 依赖最终列结构)
|
|
658
|
+
if (hasResizableColumns) {
|
|
659
|
+
result = transformResizableColumns(result, {
|
|
660
|
+
prefixCls: prefixCls,
|
|
661
|
+
enabled: hasResizableColumns,
|
|
662
|
+
isColumnResizable: resizeResult.isColumnResizable,
|
|
663
|
+
onStartResize: resizeResult.onStartResize,
|
|
664
|
+
onKeyboardResize: resizeResult.setColumnWidth
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
return result;
|
|
668
|
+
}, [transformSorterColumns, transformFilterColumns, transformSelectionColumns, transformEditableColumns, hasResizableColumns, prefixCls, resizeResult.isColumnResizable, resizeResult.onStartResize]);
|
|
669
|
+
var topPaginationNode;
|
|
670
|
+
var bottomPaginationNode;
|
|
671
|
+
if (pagination !== false && mergedPagination !== null && mergedPagination !== void 0 && mergedPagination.total) {
|
|
672
|
+
var paginationSize;
|
|
673
|
+
if (mergedPagination.size) {
|
|
674
|
+
paginationSize = mergedPagination.size;
|
|
675
|
+
} else {
|
|
676
|
+
paginationSize = customizeSize === 'small' || customizeSize === 'middle' ? 'small' : undefined;
|
|
677
|
+
}
|
|
678
|
+
var renderPagination = function renderPagination() {
|
|
679
|
+
var placement = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'end';
|
|
680
|
+
return /*#__PURE__*/React.createElement(Pagination, _extends({}, mergedPagination, {
|
|
681
|
+
className: clsx("".concat(prefixCls, "-pagination ").concat(prefixCls, "-pagination-").concat(placement), mergedPagination.className),
|
|
682
|
+
size: paginationSize
|
|
683
|
+
}));
|
|
684
|
+
};
|
|
685
|
+
var placement = mergedPagination.placement,
|
|
686
|
+
position = mergedPagination.position;
|
|
687
|
+
var mergedPlacement = placement !== null && placement !== void 0 ? placement : position;
|
|
688
|
+
var normalizePlacement = function normalizePlacement(pos) {
|
|
689
|
+
var lowerPos = pos.toLowerCase();
|
|
690
|
+
if (lowerPos.includes('center')) {
|
|
691
|
+
return 'center';
|
|
692
|
+
}
|
|
693
|
+
return lowerPos.includes('left') || lowerPos.includes('start') ? 'start' : 'end';
|
|
694
|
+
};
|
|
695
|
+
if (Array.isArray(mergedPlacement)) {
|
|
696
|
+
var _map = ['top', 'bottom'].map(function (dir) {
|
|
697
|
+
return mergedPlacement.find(function (p) {
|
|
698
|
+
return p.includes(dir);
|
|
699
|
+
});
|
|
700
|
+
}),
|
|
701
|
+
_map2 = _slicedToArray(_map, 2),
|
|
702
|
+
topPos = _map2[0],
|
|
703
|
+
bottomPos = _map2[1];
|
|
704
|
+
var isDisable = mergedPlacement.every(function (p) {
|
|
705
|
+
return "".concat(p) === 'none';
|
|
706
|
+
});
|
|
707
|
+
if (!topPos && !bottomPos && !isDisable) {
|
|
708
|
+
bottomPaginationNode = renderPagination();
|
|
709
|
+
}
|
|
710
|
+
if (topPos) {
|
|
711
|
+
topPaginationNode = renderPagination(normalizePlacement(topPos));
|
|
712
|
+
}
|
|
713
|
+
if (bottomPos) {
|
|
714
|
+
bottomPaginationNode = renderPagination(normalizePlacement(bottomPos));
|
|
715
|
+
}
|
|
716
|
+
} else {
|
|
717
|
+
bottomPaginationNode = renderPagination();
|
|
718
|
+
}
|
|
719
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
720
|
+
warning.deprecated(!position, 'pagination.position', 'pagination.placement');
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// >>>>>>>>> Spinning
|
|
725
|
+
var spinProps = React.useMemo(function () {
|
|
726
|
+
if (typeof loading === 'boolean') {
|
|
727
|
+
return {
|
|
728
|
+
spinning: loading
|
|
729
|
+
};
|
|
730
|
+
} else if (isPlainObject(loading)) {
|
|
731
|
+
return _objectSpread({
|
|
732
|
+
spinning: true
|
|
733
|
+
}, loading);
|
|
734
|
+
} else {
|
|
735
|
+
return undefined;
|
|
736
|
+
}
|
|
737
|
+
}, [loading]);
|
|
738
|
+
var wrappercls = clsx("".concat(prefixCls, "-wrapper"), _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-wrapper-rtl"), false), "".concat(prefixCls, "-middle"), customizeSize === 'middle'), "".concat(prefixCls, "-small"), customizeSize === 'small'), "".concat(prefixCls, "-wrapper-resizing"), resizeResult.resizingKey != null), className, rootClassName);
|
|
739
|
+
|
|
740
|
+
// ========== empty ==========
|
|
741
|
+
var mergedEmptyNode = React.useMemo(function () {
|
|
742
|
+
// When dataSource is null/undefined (detected by reference equality with EMPTY_LIST),
|
|
743
|
+
// and the table is in a loading state, we only show the loading spinner without the empty placeholder.
|
|
744
|
+
// For empty arrays (datasource={[]}), both loading and empty states would normally be shown.
|
|
745
|
+
// discussion https://github.com/ant-design/ant-design/issues/54601#issuecomment-3158091383
|
|
746
|
+
if (spinProps !== null && spinProps !== void 0 && spinProps.spinning && rawData === EMPTY_LIST) {
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
if (typeof (locale === null || locale === void 0 ? void 0 : locale.emptyText) !== 'undefined') {
|
|
750
|
+
return locale.emptyText;
|
|
751
|
+
}
|
|
752
|
+
var emptyNode = (renderEmpty === null || renderEmpty === void 0 ? void 0 : renderEmpty('Table')) || DefaultRenderEmpty('Table');
|
|
753
|
+
return emptyNode;
|
|
754
|
+
}, [spinProps === null || spinProps === void 0 ? void 0 : spinProps.spinning, rawData, locale === null || locale === void 0 ? void 0 : locale.emptyText, renderEmpty]);
|
|
755
|
+
|
|
756
|
+
// ========================== Render ==========================
|
|
757
|
+
var TableComponent = virtual ? RcVirtualTable : RcTable;
|
|
758
|
+
|
|
759
|
+
// >>> Virtual Table props.
|
|
760
|
+
var virtualProps = {};
|
|
761
|
+
|
|
762
|
+
// Derive virtual row height from the CSS custom property defined in LESS.
|
|
763
|
+
// Fallback values match the default token calculations when CSS is not ready.
|
|
764
|
+
var fallbackItemHeight = React.useMemo(function () {
|
|
765
|
+
switch (customizeSize) {
|
|
766
|
+
case 'middle':
|
|
767
|
+
return 47;
|
|
768
|
+
case 'small':
|
|
769
|
+
return 39;
|
|
770
|
+
default:
|
|
771
|
+
return 55;
|
|
772
|
+
}
|
|
773
|
+
}, [customizeSize]);
|
|
774
|
+
var listItemHeight = useCssVar(rootRef, "--".concat(prefixCls, "-row-height"), fallbackItemHeight);
|
|
775
|
+
if (virtual) {
|
|
776
|
+
virtualProps.listItemHeight = listItemHeight;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// ========================== Resize Line ==========================
|
|
780
|
+
// 竖线 DOM 通过 ref 直接操作,不需要 React state 驱动
|
|
781
|
+
|
|
782
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
783
|
+
ref: rootRef,
|
|
784
|
+
className: wrappercls,
|
|
785
|
+
style: style
|
|
786
|
+
}, hasResizableColumns && /*#__PURE__*/React.createElement("div", {
|
|
787
|
+
ref: resizeResult.lineRef,
|
|
788
|
+
className: "".concat(prefixCls, "-resize-line")
|
|
789
|
+
}), /*#__PURE__*/React.createElement(Spin, _extends({
|
|
790
|
+
spinning: false
|
|
791
|
+
}, spinProps), topPaginationNode, /*#__PURE__*/React.createElement(EditableContext.Provider, {
|
|
792
|
+
value: hasEditableColumns ? editableResult.contextValue : null
|
|
793
|
+
}, /*#__PURE__*/React.createElement(HeaderTableContext.Provider, {
|
|
794
|
+
value: headerTableContext
|
|
795
|
+
}, /*#__PURE__*/React.createElement(TableComponent, _extends({}, virtualProps, tableProps, {
|
|
796
|
+
components: mergedComponents,
|
|
797
|
+
scroll: mergedScroll,
|
|
798
|
+
ref: tblRef,
|
|
799
|
+
columns: finalColumns,
|
|
800
|
+
direction: 'ltr',
|
|
801
|
+
expandable: mergedExpandable,
|
|
802
|
+
prefixCls: prefixCls,
|
|
803
|
+
className: clsx(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(prefixCls, "-middle"), customizeSize === 'middle'), "".concat(prefixCls, "-small"), customizeSize === 'small'), "".concat(prefixCls, "-bordered"), bordered), "".concat(prefixCls, "-empty"), rawData.length === 0)),
|
|
804
|
+
data: pageData,
|
|
805
|
+
rowKey: getRowKey,
|
|
806
|
+
rowClassName: internalRowClassName,
|
|
807
|
+
emptyText: mergedEmptyNode
|
|
808
|
+
// Internal
|
|
809
|
+
,
|
|
810
|
+
internalHooks: INTERNAL_HOOKS,
|
|
811
|
+
internalRefs: internalRef,
|
|
812
|
+
transformColumns: transformColumns,
|
|
813
|
+
getContainerWidth: getContainerWidth
|
|
814
|
+
})))), bottomPaginationNode));
|
|
815
|
+
};
|
|
816
|
+
export default /*#__PURE__*/React.forwardRef(InternalTable);
|