@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,102 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
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); }
|
|
8
|
+
import { clsx } from 'clsx';
|
|
9
|
+
import getValue from 'rc-util/lib/utils/get';
|
|
10
|
+
import useEvent from "../../../_util/hooks/useEvent";
|
|
11
|
+
import warning from 'rc-util/lib/warning';
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
import { INTERNAL_HOOKS } from "../../constant";
|
|
14
|
+
import { makeImmutable } from "../../shared/context/TableContext";
|
|
15
|
+
import Table, { DEFAULT_PREFIX } from "../RcTable";
|
|
16
|
+
import Grid from "./BodyGrid";
|
|
17
|
+
import { StaticContext } from "./context";
|
|
18
|
+
var renderBody = function renderBody(rawData, props) {
|
|
19
|
+
var ref = props.ref,
|
|
20
|
+
onScroll = props.onScroll;
|
|
21
|
+
return /*#__PURE__*/React.createElement(Grid, {
|
|
22
|
+
ref: ref,
|
|
23
|
+
data: rawData,
|
|
24
|
+
onScroll: onScroll
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
var VirtualTable = function VirtualTable(props, ref) {
|
|
28
|
+
var data = props.data,
|
|
29
|
+
columns = props.columns,
|
|
30
|
+
scroll = props.scroll,
|
|
31
|
+
_props$sticky = props.sticky,
|
|
32
|
+
sticky = _props$sticky === void 0 ? false : _props$sticky,
|
|
33
|
+
_props$prefixCls = props.prefixCls,
|
|
34
|
+
prefixCls = _props$prefixCls === void 0 ? DEFAULT_PREFIX : _props$prefixCls,
|
|
35
|
+
className = props.className,
|
|
36
|
+
_props$listItemHeight = props.listItemHeight,
|
|
37
|
+
listItemHeight = _props$listItemHeight === void 0 ? 24 : _props$listItemHeight,
|
|
38
|
+
components = props.components,
|
|
39
|
+
onScroll = props.onScroll;
|
|
40
|
+
var _ref = scroll || {},
|
|
41
|
+
scrollX = _ref.x,
|
|
42
|
+
scrollY = _ref.y;
|
|
43
|
+
|
|
44
|
+
// Fill scrollX
|
|
45
|
+
if (typeof scrollX !== 'number') {
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
+
warning(false, '`scroll.x` in virtual table must be number.');
|
|
48
|
+
}
|
|
49
|
+
scrollX = 1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Fill scrollY
|
|
53
|
+
if (typeof scrollY !== 'number') {
|
|
54
|
+
scrollY = 500;
|
|
55
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
56
|
+
warning(false, '`scroll.y` in virtual table must be number.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
var getComponent = useEvent(function (path, defaultComponent) {
|
|
60
|
+
return getValue(components, path) || defaultComponent;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Memo this
|
|
64
|
+
var onInternalScroll = useEvent(onScroll !== null && onScroll !== void 0 ? onScroll : function () {});
|
|
65
|
+
|
|
66
|
+
// ========================= Context ==========================
|
|
67
|
+
var context = React.useMemo(function () {
|
|
68
|
+
return {
|
|
69
|
+
sticky: sticky,
|
|
70
|
+
scrollY: scrollY,
|
|
71
|
+
listItemHeight: listItemHeight,
|
|
72
|
+
getComponent: getComponent,
|
|
73
|
+
onScroll: onInternalScroll
|
|
74
|
+
};
|
|
75
|
+
}, [sticky, scrollY, listItemHeight, getComponent, onInternalScroll]);
|
|
76
|
+
|
|
77
|
+
// ========================== Render ==========================
|
|
78
|
+
return /*#__PURE__*/React.createElement(StaticContext.Provider, {
|
|
79
|
+
value: context
|
|
80
|
+
}, /*#__PURE__*/React.createElement(Table, _extends({}, props, {
|
|
81
|
+
className: clsx(className, "".concat(prefixCls, "-virtual")),
|
|
82
|
+
scroll: _objectSpread(_objectSpread({}, scroll), {}, {
|
|
83
|
+
x: scrollX
|
|
84
|
+
}),
|
|
85
|
+
components: _objectSpread(_objectSpread({}, components), {}, {
|
|
86
|
+
// fix https://github.com/ant-design/ant-design/issues/48991
|
|
87
|
+
body: data !== null && data !== void 0 && data.length ? renderBody : undefined
|
|
88
|
+
}),
|
|
89
|
+
columns: columns,
|
|
90
|
+
internalHooks: INTERNAL_HOOKS,
|
|
91
|
+
tailor: true,
|
|
92
|
+
ref: ref
|
|
93
|
+
})));
|
|
94
|
+
};
|
|
95
|
+
var RefVirtualTable = /*#__PURE__*/React.forwardRef(VirtualTable);
|
|
96
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
97
|
+
RefVirtualTable.displayName = 'VirtualTable';
|
|
98
|
+
}
|
|
99
|
+
export var genVirtualTable = function genVirtualTable(shouldTriggerRender) {
|
|
100
|
+
return makeImmutable(RefVirtualTable, shouldTriggerRender);
|
|
101
|
+
};
|
|
102
|
+
export default genVirtualTable();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnyObject } from '../../../_util/type';
|
|
2
|
+
import type { ColumnType } from '../../interface';
|
|
3
|
+
export interface ColumnProps<RecordType = AnyObject> extends ColumnType<RecordType> {
|
|
4
|
+
children?: null;
|
|
5
|
+
}
|
|
6
|
+
declare const Column: <RecordType extends AnyObject>(_: ColumnProps<RecordType>) => null;
|
|
7
|
+
export default Column;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as React from 'react';
|
|
2
|
+
import type { AnyObject } from '../../../_util/type';
|
|
3
|
+
import type { ColumnProps } from './Column';
|
|
4
|
+
import type { ColumnType } from '../../interface';
|
|
5
|
+
export interface ColumnGroupProps<RecordType = AnyObject> extends Omit<ColumnType<RecordType>, 'children'> {
|
|
6
|
+
children: React.ReactElement<ColumnProps<RecordType>> | React.ReactElement<ColumnProps<RecordType>>[];
|
|
7
|
+
}
|
|
8
|
+
declare const ColumnGroup: <RecordType extends AnyObject>(_: ColumnGroupProps<RecordType>) => null;
|
|
9
|
+
export default ColumnGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Column } from './Column';
|
|
2
|
+
export type { ColumnProps } from './Column';
|
|
3
|
+
export { default as ColumnGroup } from './ColumnGroup';
|
|
4
|
+
export type { ColumnGroupProps } from './ColumnGroup';
|
|
5
|
+
export { convertChildrenToColumns, default as useColumns } from './useColumns';
|
|
6
|
+
export { default as useFilledColumns } from './useFilledColumns';
|
|
7
|
+
export { default as useTitleColumns } from './useTitleColumns';
|
|
8
|
+
export { default as useWidthColumns } from './useWidthColumns';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Column } from "./Column";
|
|
2
|
+
export { default as ColumnGroup } from "./ColumnGroup";
|
|
3
|
+
export { convertChildrenToColumns, default as useColumns } from "./useColumns";
|
|
4
|
+
export { default as useFilledColumns } from "./useFilledColumns";
|
|
5
|
+
export { default as useTitleColumns } from "./useTitleColumns";
|
|
6
|
+
export { default as useWidthColumns } from "./useWidthColumns";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ColumnsType, ColumnType, Direction, FixedType, GetRowKey, Key, RenderExpandIcon, TriggerEventHandler } from '../../interface';
|
|
3
|
+
export declare function convertChildrenToColumns<RecordType>(children: React.ReactNode): ColumnsType<RecordType>;
|
|
4
|
+
/**
|
|
5
|
+
* Parse `columns` & `children` into `columns`.
|
|
6
|
+
*/
|
|
7
|
+
declare function useColumns<RecordType>({ prefixCls, columns, children, expandable, expandedKeys, columnTitle, getRowKey, onTriggerExpand, expandIcon, rowExpandable, expandIconColumnIndex, expandedRowOffset, direction, expandRowByClick, columnWidth, fixed, scrollWidth, clientWidth, }: {
|
|
8
|
+
prefixCls?: string;
|
|
9
|
+
columns?: ColumnsType<RecordType>;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
expandable: boolean;
|
|
12
|
+
expandedKeys: Set<Key>;
|
|
13
|
+
columnTitle?: React.ReactNode;
|
|
14
|
+
getRowKey: GetRowKey<RecordType>;
|
|
15
|
+
onTriggerExpand: TriggerEventHandler<RecordType>;
|
|
16
|
+
expandIcon: RenderExpandIcon<RecordType>;
|
|
17
|
+
rowExpandable?: (record: RecordType) => boolean;
|
|
18
|
+
expandIconColumnIndex?: number;
|
|
19
|
+
direction?: Direction;
|
|
20
|
+
expandRowByClick?: boolean;
|
|
21
|
+
columnWidth?: number | string;
|
|
22
|
+
clientWidth: number;
|
|
23
|
+
fixed?: FixedType;
|
|
24
|
+
scrollWidth?: number | null;
|
|
25
|
+
expandedRowOffset?: number;
|
|
26
|
+
}, transformColumns: (columns: ColumnsType<RecordType>) => ColumnsType<RecordType>): [
|
|
27
|
+
columns: ColumnsType<RecordType>,
|
|
28
|
+
flattenColumns: readonly ColumnType<RecordType>[],
|
|
29
|
+
realScrollWidth: undefined | number
|
|
30
|
+
];
|
|
31
|
+
export default useColumns;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
var _excluded = ["children"];
|
|
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 _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; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
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); }
|
|
9
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
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; }
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
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); }
|
|
18
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
+
import toArray from 'rc-util/lib/Children/toArray';
|
|
21
|
+
import warning from 'rc-util/lib/warning';
|
|
22
|
+
import * as React from 'react';
|
|
23
|
+
import { EXPAND_COLUMN } from "../../constant";
|
|
24
|
+
import { INTERNAL_COL_DEFINE } from "../../shared/utils/legacyUtil";
|
|
25
|
+
import useWidthColumns from "./useWidthColumns";
|
|
26
|
+
export function convertChildrenToColumns(children) {
|
|
27
|
+
return toArray(children).filter(function (node) {
|
|
28
|
+
return /*#__PURE__*/React.isValidElement(node);
|
|
29
|
+
}).map(function (node) {
|
|
30
|
+
var _ref = node,
|
|
31
|
+
key = _ref.key,
|
|
32
|
+
props = _ref.props;
|
|
33
|
+
var nodeChildren = props.children,
|
|
34
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
35
|
+
var column = _objectSpread({
|
|
36
|
+
key: key
|
|
37
|
+
}, restProps);
|
|
38
|
+
if (nodeChildren) {
|
|
39
|
+
column.children = convertChildrenToColumns(nodeChildren);
|
|
40
|
+
}
|
|
41
|
+
return column;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function filterHiddenColumns(columns) {
|
|
45
|
+
return columns.filter(function (column) {
|
|
46
|
+
return column && _typeof(column) === 'object' && !column.hidden;
|
|
47
|
+
}).map(function (column) {
|
|
48
|
+
var subColumns = column.children;
|
|
49
|
+
if (subColumns && subColumns.length > 0) {
|
|
50
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
51
|
+
children: filterHiddenColumns(subColumns)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return column;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function flatColumns(columns) {
|
|
58
|
+
var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'key';
|
|
59
|
+
return columns.filter(function (column) {
|
|
60
|
+
return column && _typeof(column) === 'object';
|
|
61
|
+
}).reduce(function (list, column, index) {
|
|
62
|
+
var fixed = column.fixed;
|
|
63
|
+
var parsedFixed = fixed === true || fixed === 'left' ? 'start' : fixed === 'right' ? 'end' : fixed;
|
|
64
|
+
var mergedKey = "".concat(parentKey, "-").concat(index);
|
|
65
|
+
var subColumns = column.children;
|
|
66
|
+
if (subColumns && subColumns.length > 0) {
|
|
67
|
+
return [].concat(_toConsumableArray(list), _toConsumableArray(flatColumns(subColumns, mergedKey).map(function (subColum) {
|
|
68
|
+
var _subColum$fixed;
|
|
69
|
+
return _objectSpread(_objectSpread({}, subColum), {}, {
|
|
70
|
+
fixed: (_subColum$fixed = subColum.fixed) !== null && _subColum$fixed !== void 0 ? _subColum$fixed : parsedFixed
|
|
71
|
+
});
|
|
72
|
+
})));
|
|
73
|
+
}
|
|
74
|
+
return [].concat(_toConsumableArray(list), [_objectSpread(_objectSpread({
|
|
75
|
+
key: mergedKey
|
|
76
|
+
}, column), {}, {
|
|
77
|
+
fixed: parsedFixed
|
|
78
|
+
})]);
|
|
79
|
+
}, []);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Parse `columns` & `children` into `columns`.
|
|
84
|
+
*/
|
|
85
|
+
function useColumns(_ref2, transformColumns) {
|
|
86
|
+
var prefixCls = _ref2.prefixCls,
|
|
87
|
+
columns = _ref2.columns,
|
|
88
|
+
children = _ref2.children,
|
|
89
|
+
expandable = _ref2.expandable,
|
|
90
|
+
expandedKeys = _ref2.expandedKeys,
|
|
91
|
+
columnTitle = _ref2.columnTitle,
|
|
92
|
+
getRowKey = _ref2.getRowKey,
|
|
93
|
+
onTriggerExpand = _ref2.onTriggerExpand,
|
|
94
|
+
expandIcon = _ref2.expandIcon,
|
|
95
|
+
rowExpandable = _ref2.rowExpandable,
|
|
96
|
+
expandIconColumnIndex = _ref2.expandIconColumnIndex,
|
|
97
|
+
_ref2$expandedRowOffs = _ref2.expandedRowOffset,
|
|
98
|
+
expandedRowOffset = _ref2$expandedRowOffs === void 0 ? 0 : _ref2$expandedRowOffs,
|
|
99
|
+
direction = _ref2.direction,
|
|
100
|
+
expandRowByClick = _ref2.expandRowByClick,
|
|
101
|
+
columnWidth = _ref2.columnWidth,
|
|
102
|
+
fixed = _ref2.fixed,
|
|
103
|
+
scrollWidth = _ref2.scrollWidth,
|
|
104
|
+
clientWidth = _ref2.clientWidth;
|
|
105
|
+
var baseColumns = React.useMemo(function () {
|
|
106
|
+
var newColumns = columns || convertChildrenToColumns(children) || [];
|
|
107
|
+
return filterHiddenColumns(newColumns.slice());
|
|
108
|
+
}, [columns, children]);
|
|
109
|
+
|
|
110
|
+
// ========================== Expand ==========================
|
|
111
|
+
var withExpandColumns = React.useMemo(function () {
|
|
112
|
+
if (expandable) {
|
|
113
|
+
var cloneColumns = baseColumns.slice();
|
|
114
|
+
|
|
115
|
+
// >>> Warning if use `expandIconColumnIndex`
|
|
116
|
+
if (process.env.NODE_ENV !== 'production' && (expandIconColumnIndex !== null && expandIconColumnIndex !== void 0 ? expandIconColumnIndex : -1) >= 0) {
|
|
117
|
+
warning(false, '`expandIconColumnIndex` is deprecated. Please use `Table.EXPAND_COLUMN` in `columns` instead.');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// >>> Insert expand column if not exist
|
|
121
|
+
if (!cloneColumns.includes(EXPAND_COLUMN)) {
|
|
122
|
+
var expandColIndex = expandIconColumnIndex || 0;
|
|
123
|
+
var insertIndex = expandColIndex === 0 && (fixed === 'right' || fixed === 'end') ? baseColumns.length : expandColIndex;
|
|
124
|
+
if (insertIndex >= 0) {
|
|
125
|
+
cloneColumns.splice(insertIndex, 0, EXPAND_COLUMN);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// >>> Deduplicate additional expand column
|
|
130
|
+
if (process.env.NODE_ENV !== 'production' && cloneColumns.filter(function (c) {
|
|
131
|
+
return c === EXPAND_COLUMN;
|
|
132
|
+
}).length > 1) {
|
|
133
|
+
warning(false, 'There exist more than one `EXPAND_COLUMN` in `columns`.');
|
|
134
|
+
}
|
|
135
|
+
var expandColumnIndex = cloneColumns.indexOf(EXPAND_COLUMN);
|
|
136
|
+
cloneColumns = cloneColumns.filter(function (column, index) {
|
|
137
|
+
return column !== EXPAND_COLUMN || index === expandColumnIndex;
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// >>> Check if expand column need to fixed
|
|
141
|
+
var prevColumn = baseColumns[expandColumnIndex];
|
|
142
|
+
var fixedColumn;
|
|
143
|
+
if (fixed) {
|
|
144
|
+
fixedColumn = fixed;
|
|
145
|
+
} else {
|
|
146
|
+
// Keep the runtime value of `prevColumn.fixed` untouched (it may be `undefined`)
|
|
147
|
+
fixedColumn = prevColumn ? prevColumn.fixed : null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// >>> Create expandable column
|
|
151
|
+
var expandColumn = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, INTERNAL_COL_DEFINE, {
|
|
152
|
+
className: "".concat(prefixCls, "-expand-icon-col"),
|
|
153
|
+
columnType: 'EXPAND_COLUMN'
|
|
154
|
+
}), "title", columnTitle), "fixed", fixedColumn), "className", "".concat(prefixCls, "-row-expand-icon-cell")), "width", columnWidth), "render", function render(_, record, index) {
|
|
155
|
+
var rowKey = getRowKey(record, index);
|
|
156
|
+
var expanded = expandedKeys.has(rowKey);
|
|
157
|
+
var recordExpandable = rowExpandable ? rowExpandable(record) : true;
|
|
158
|
+
var icon = expandIcon({
|
|
159
|
+
// `prefixCls` is optional in the options but always provided by the caller;
|
|
160
|
+
// pass the value through as-is.
|
|
161
|
+
prefixCls: prefixCls,
|
|
162
|
+
expanded: expanded,
|
|
163
|
+
expandable: recordExpandable,
|
|
164
|
+
record: record,
|
|
165
|
+
onExpand: onTriggerExpand
|
|
166
|
+
});
|
|
167
|
+
if (expandRowByClick) {
|
|
168
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
169
|
+
onClick: function onClick(e) {
|
|
170
|
+
return e.stopPropagation();
|
|
171
|
+
}
|
|
172
|
+
}, icon);
|
|
173
|
+
}
|
|
174
|
+
return icon;
|
|
175
|
+
});
|
|
176
|
+
return cloneColumns.map(function (col, index) {
|
|
177
|
+
var column = col === EXPAND_COLUMN ? expandColumn : col;
|
|
178
|
+
if (index < expandedRowOffset) {
|
|
179
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
|
180
|
+
fixed: column.fixed || 'start'
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return column;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (process.env.NODE_ENV !== 'production' && baseColumns.includes(EXPAND_COLUMN)) {
|
|
187
|
+
warning(false, '`expandable` is not config but there exist `EXPAND_COLUMN` in `columns`.');
|
|
188
|
+
}
|
|
189
|
+
return baseColumns.filter(function (col) {
|
|
190
|
+
return col !== EXPAND_COLUMN;
|
|
191
|
+
});
|
|
192
|
+
}, [expandable, baseColumns, getRowKey, expandedKeys, expandIcon, direction, expandedRowOffset]);
|
|
193
|
+
|
|
194
|
+
// ========================= Transform ========================
|
|
195
|
+
var mergedColumns = React.useMemo(function () {
|
|
196
|
+
var finalColumns = withExpandColumns;
|
|
197
|
+
if (transformColumns) {
|
|
198
|
+
finalColumns = transformColumns(finalColumns);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Always provides at least one column for table display
|
|
202
|
+
if (!finalColumns.length) {
|
|
203
|
+
finalColumns = [{
|
|
204
|
+
render: function render() {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}];
|
|
208
|
+
}
|
|
209
|
+
return finalColumns;
|
|
210
|
+
}, [transformColumns, withExpandColumns, direction]);
|
|
211
|
+
|
|
212
|
+
// ========================== Flatten =========================
|
|
213
|
+
var flattenColumns = React.useMemo(function () {
|
|
214
|
+
return flatColumns(mergedColumns);
|
|
215
|
+
}, [mergedColumns, direction, scrollWidth]);
|
|
216
|
+
|
|
217
|
+
// ========================= FillWidth ========================
|
|
218
|
+
var _useWidthColumns = useWidthColumns(flattenColumns,
|
|
219
|
+
// `useWidthColumns` treats falsy values uniformly and returns `scrollWidth`
|
|
220
|
+
// verbatim, so pass the value through as-is.
|
|
221
|
+
scrollWidth, clientWidth),
|
|
222
|
+
_useWidthColumns2 = _slicedToArray(_useWidthColumns, 2),
|
|
223
|
+
filledColumns = _useWidthColumns2[0],
|
|
224
|
+
realScrollWidth = _useWidthColumns2[1];
|
|
225
|
+
return [mergedColumns, filledColumns, realScrollWidth];
|
|
226
|
+
}
|
|
227
|
+
export default useColumns;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyObject } from '../../../_util/type';
|
|
2
|
+
import type { ColumnsType, ColumnType } from '../../interface';
|
|
3
|
+
declare const useFilledColumns: <RecordType extends AnyObject = AnyObject>(columns: ColumnsType<RecordType>, column?: Partial<ColumnType<RecordType>>) => ColumnsType<RecordType>;
|
|
4
|
+
export default useFilledColumns;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { EXPAND_COLUMN } from "../../constant";
|
|
9
|
+
import { mergeProps, omit } from "../../../_util/rcUtil";
|
|
10
|
+
import { SELECTION_COLUMN } from "../selection/useSelection";
|
|
11
|
+
var useFilledColumns = function useFilledColumns(columns, column) {
|
|
12
|
+
return React.useMemo(function () {
|
|
13
|
+
if (!column) {
|
|
14
|
+
return columns;
|
|
15
|
+
}
|
|
16
|
+
var fillColumns = function fillColumns(currentColumns) {
|
|
17
|
+
return currentColumns.map(function (col) {
|
|
18
|
+
if (col === SELECTION_COLUMN || col === EXPAND_COLUMN) {
|
|
19
|
+
return col;
|
|
20
|
+
}
|
|
21
|
+
if ('children' in col && Array.isArray(col.children)) {
|
|
22
|
+
var mergedColumn = mergeProps(column, col);
|
|
23
|
+
return _objectSpread(_objectSpread({}, mergedColumn), {}, {
|
|
24
|
+
children: fillColumns(col.children)
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var columnWithoutChildren = omit(column, ['children']);
|
|
28
|
+
return mergeProps(columnWithoutChildren, col);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
return fillColumns(columns);
|
|
32
|
+
}, [columns, column]);
|
|
33
|
+
};
|
|
34
|
+
export default useFilledColumns;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AnyObject } from '../../../_util/type';
|
|
2
|
+
import type { ColumnTitleProps, TransformColumns } from '../../interface';
|
|
3
|
+
declare const useTitleColumns: <RecordType extends AnyObject = AnyObject>(columnTitleProps: ColumnTitleProps<RecordType>) => readonly [TransformColumns<RecordType>];
|
|
4
|
+
export default useTitleColumns;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { renderColumnTitle } from "../../shared/utils/util";
|
|
9
|
+
var fillTitle = function fillTitle(columns, columnTitleProps) {
|
|
10
|
+
var finalColumns = columns.map(function (column) {
|
|
11
|
+
var cloneColumn = _objectSpread({}, column);
|
|
12
|
+
cloneColumn.title = renderColumnTitle(column.title, columnTitleProps);
|
|
13
|
+
if ('children' in cloneColumn) {
|
|
14
|
+
cloneColumn.children = fillTitle(cloneColumn.children, columnTitleProps);
|
|
15
|
+
}
|
|
16
|
+
return cloneColumn;
|
|
17
|
+
});
|
|
18
|
+
return finalColumns;
|
|
19
|
+
};
|
|
20
|
+
var useTitleColumns = function useTitleColumns(columnTitleProps) {
|
|
21
|
+
var filledColumns = React.useCallback(function (columns) {
|
|
22
|
+
return fillTitle(columns, columnTitleProps);
|
|
23
|
+
}, [columnTitleProps]);
|
|
24
|
+
return [filledColumns];
|
|
25
|
+
};
|
|
26
|
+
export default useTitleColumns;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
function parseColWidth(totalWidth) {
|
|
9
|
+
var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
10
|
+
if (typeof width === 'number') {
|
|
11
|
+
return width;
|
|
12
|
+
}
|
|
13
|
+
if (width.endsWith('%')) {
|
|
14
|
+
return totalWidth * Number.parseFloat(width) / 100;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fill all column with width
|
|
21
|
+
*/
|
|
22
|
+
export default function useWidthColumns(flattenColumns, scrollWidth, clientWidth) {
|
|
23
|
+
return React.useMemo(function () {
|
|
24
|
+
// Fill width if needed
|
|
25
|
+
if (scrollWidth && scrollWidth > 0) {
|
|
26
|
+
var totalWidth = 0;
|
|
27
|
+
var missWidthCount = 0;
|
|
28
|
+
|
|
29
|
+
// collect not given width column
|
|
30
|
+
flattenColumns.forEach(function (col) {
|
|
31
|
+
var colWidth = parseColWidth(scrollWidth, col.width);
|
|
32
|
+
if (colWidth) {
|
|
33
|
+
totalWidth += colWidth;
|
|
34
|
+
} else {
|
|
35
|
+
missWidthCount += 1;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Fill width
|
|
40
|
+
var maxFitWidth = Math.max(scrollWidth, clientWidth);
|
|
41
|
+
var restWidth = Math.max(maxFitWidth - totalWidth, missWidthCount);
|
|
42
|
+
var restCount = missWidthCount;
|
|
43
|
+
var avgWidth = restWidth / missWidthCount;
|
|
44
|
+
var realTotal = 0;
|
|
45
|
+
var filledColumns = flattenColumns.map(function (col) {
|
|
46
|
+
var clone = _objectSpread({}, col);
|
|
47
|
+
var colWidth = parseColWidth(scrollWidth, clone.width);
|
|
48
|
+
if (colWidth) {
|
|
49
|
+
clone.width = colWidth;
|
|
50
|
+
} else {
|
|
51
|
+
var colAvgWidth = Math.floor(avgWidth);
|
|
52
|
+
clone.width = restCount === 1 ? restWidth : colAvgWidth;
|
|
53
|
+
restWidth -= colAvgWidth;
|
|
54
|
+
restCount -= 1;
|
|
55
|
+
}
|
|
56
|
+
realTotal += clone.width;
|
|
57
|
+
return clone;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// If realTotal is less than clientWidth,
|
|
61
|
+
// We need extend column width
|
|
62
|
+
if (realTotal < maxFitWidth) {
|
|
63
|
+
var scale = maxFitWidth / realTotal;
|
|
64
|
+
restWidth = maxFitWidth;
|
|
65
|
+
filledColumns.forEach(function (col, index) {
|
|
66
|
+
var colWidth = Math.floor(col.width * scale);
|
|
67
|
+
col.width = index === filledColumns.length - 1 ? restWidth : colWidth;
|
|
68
|
+
restWidth -= colWidth;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return [filledColumns, Math.max(realTotal, maxFitWidth)];
|
|
72
|
+
}
|
|
73
|
+
return [flattenColumns, scrollWidth];
|
|
74
|
+
}, [flattenColumns, scrollWidth, clientWidth]);
|
|
75
|
+
}
|