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