@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,693 @@
|
|
|
1
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
2
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
3
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
|
+
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); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
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); }
|
|
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 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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
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); }
|
|
17
|
+
import * as React from 'react';
|
|
18
|
+
|
|
19
|
+
/** 错误集合类型 — 从 interface.ts 重新导出保持兼容 */
|
|
20
|
+
|
|
21
|
+
/** 重新导出,保持 index.ts 的 API 不变 */
|
|
22
|
+
|
|
23
|
+
/** 空配置常量 — 保证引用稳定,使 React.memo 比较生效 */
|
|
24
|
+
var EMPTY_EDITABLE_CONFIG = Object.freeze({});
|
|
25
|
+
|
|
26
|
+
/** 扁平化后的行:rowIndex 为 DFS 扁平序号(无 children 时 = data 下标) */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 深度优先扁平化数据(含树形 children)。
|
|
30
|
+
* 排序/筛选/展开子行都会改变"展示下标",只有 rowKey 能稳定标识一条记录。
|
|
31
|
+
*/
|
|
32
|
+
function flattenEditableRows(rows, childrenColumnName, getRowKey) {
|
|
33
|
+
var flat = [];
|
|
34
|
+
var dig = function dig(list) {
|
|
35
|
+
list.forEach(function (record, index) {
|
|
36
|
+
flat.push({
|
|
37
|
+
record: record,
|
|
38
|
+
rowIndex: flat.length,
|
|
39
|
+
rowKey: getRowKey === null || getRowKey === void 0 ? void 0 : getRowKey(record, index)
|
|
40
|
+
});
|
|
41
|
+
var children = record === null || record === void 0 ? void 0 : record[childrenColumnName];
|
|
42
|
+
if (Array.isArray(children)) dig(children);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
dig(rows);
|
|
46
|
+
return flat;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 按 rowKey 在(含树形 children 的)数据中不可变更新一条记录。
|
|
51
|
+
*
|
|
52
|
+
* 返回 `undefined` 表示无法按 key 唯一定位(未命中或 key 重复),
|
|
53
|
+
* 调用方需降级为索引更新,以保持与历史行为兼容。
|
|
54
|
+
*/
|
|
55
|
+
function updateRecordByKey(data, childrenColumnName, getRowKey, targetKey, dataIndex, value) {
|
|
56
|
+
var matches = 0;
|
|
57
|
+
var walk = function walk(rows) {
|
|
58
|
+
var changed = false;
|
|
59
|
+
var next = rows.map(function (row, index) {
|
|
60
|
+
if (getRowKey(row, index) === targetKey) {
|
|
61
|
+
matches += 1;
|
|
62
|
+
changed = true;
|
|
63
|
+
return _objectSpread(_objectSpread({}, row), {}, _defineProperty({}, dataIndex, value));
|
|
64
|
+
}
|
|
65
|
+
var children = row === null || row === void 0 ? void 0 : row[childrenColumnName];
|
|
66
|
+
if (Array.isArray(children)) {
|
|
67
|
+
var nextChildren = walk(children);
|
|
68
|
+
if (nextChildren !== children) {
|
|
69
|
+
changed = true;
|
|
70
|
+
return _objectSpread(_objectSpread({}, row), {}, _defineProperty({}, childrenColumnName, nextChildren));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return row;
|
|
74
|
+
});
|
|
75
|
+
return changed ? next : rows;
|
|
76
|
+
};
|
|
77
|
+
var result = walk(data);
|
|
78
|
+
// 仅当 key 唯一命中时才按 key 更新
|
|
79
|
+
return matches === 1 ? result : undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* validateCell 的写入记录 — validateAll 竞态合并用。
|
|
84
|
+
* 记录完整错误消息与定位信息,使合并成为纯函数(不依赖 setState 时机读取 prev)。
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* validateAll 完成时的错误合并(纯函数 — setErrors 与返回值共用同一份合并结果)。
|
|
89
|
+
* 校验期间被用户重新编辑(validateCell 写入,seq > startSeq)的单元格保留其最新错误状态;
|
|
90
|
+
* 未被触碰的单元格应用 validateAll 的校验结果。
|
|
91
|
+
*/
|
|
92
|
+
function mergeValidatedErrors(validated, touchedCells, startSeq) {
|
|
93
|
+
var _next;
|
|
94
|
+
var next = null;
|
|
95
|
+
var _iterator = _createForOfIteratorHelper(touchedCells),
|
|
96
|
+
_step;
|
|
97
|
+
try {
|
|
98
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
99
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
100
|
+
key = _step$value[0],
|
|
101
|
+
touched = _step$value[1];
|
|
102
|
+
if (touched.seq > startSeq) {
|
|
103
|
+
if (!next) next = new Map(validated);
|
|
104
|
+
if (touched.messages.length > 0) {
|
|
105
|
+
next.set(key, touched.messages);
|
|
106
|
+
} else {
|
|
107
|
+
next.delete(key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// 无校验期编辑 → 直接复用校验结果,避免额外 Map 分配
|
|
112
|
+
} catch (err) {
|
|
113
|
+
_iterator.e(err);
|
|
114
|
+
} finally {
|
|
115
|
+
_iterator.f();
|
|
116
|
+
}
|
|
117
|
+
return (_next = next) !== null && _next !== void 0 ? _next : validated;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 解析列的 editable 配置
|
|
122
|
+
*/
|
|
123
|
+
export function parseEditableConfig(editable, globalEnabled) {
|
|
124
|
+
if (editable === true) return {
|
|
125
|
+
enabled: true,
|
|
126
|
+
config: EMPTY_EDITABLE_CONFIG
|
|
127
|
+
};
|
|
128
|
+
if (editable && _typeof(editable) === 'object') return {
|
|
129
|
+
enabled: true,
|
|
130
|
+
config: editable
|
|
131
|
+
};
|
|
132
|
+
// 列级显式关闭优先于全局开关:editable === false → 该列禁用编辑
|
|
133
|
+
if (editable === false) return {
|
|
134
|
+
enabled: false,
|
|
135
|
+
config: null
|
|
136
|
+
};
|
|
137
|
+
// 列未配置 → 继承全局开关
|
|
138
|
+
if (globalEnabled) return {
|
|
139
|
+
enabled: true,
|
|
140
|
+
config: EMPTY_EDITABLE_CONFIG
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
enabled: false,
|
|
144
|
+
config: null
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** 叶子列类型(排除 ColumnGroupType) */
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* useEditable hook
|
|
152
|
+
*
|
|
153
|
+
* 管理表格的可编辑状态、校验、错误展示
|
|
154
|
+
*
|
|
155
|
+
* 性能优化:
|
|
156
|
+
* - flatColumns 通过 useMemo 缓存,避免每次 onCellChange / validateCell 都重新扁平化
|
|
157
|
+
* - colMap 缓存 dataIndex → column 映射,O(1) 查找
|
|
158
|
+
*/
|
|
159
|
+
function useEditable(_ref) {
|
|
160
|
+
var columns = _ref.columns,
|
|
161
|
+
data = _ref.data,
|
|
162
|
+
onChange = _ref.onChange,
|
|
163
|
+
onValidate = _ref.onValidate,
|
|
164
|
+
getRowKey = _ref.getRowKey,
|
|
165
|
+
_ref$childrenColumnNa = _ref.childrenColumnName,
|
|
166
|
+
childrenColumnName = _ref$childrenColumnNa === void 0 ? 'children' : _ref$childrenColumnNa,
|
|
167
|
+
scrollToRow = _ref.scrollToRow;
|
|
168
|
+
var _React$useState = React.useState(function () {
|
|
169
|
+
return new Map();
|
|
170
|
+
}),
|
|
171
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
172
|
+
errors = _React$useState2[0],
|
|
173
|
+
setErrors = _React$useState2[1];
|
|
174
|
+
|
|
175
|
+
// validateAll 竞态防护(序号机制):
|
|
176
|
+
// touchSeqRef 全局单调递增;cellTouchSeqRef 记录每个单元格最后一次 validateCell 写入的序号。
|
|
177
|
+
// validateAll 开始时快照序号,结束时对校验期间被用户重新编辑(validateCell 写入)过的
|
|
178
|
+
// 单元格保留其最新错误状态,未被触碰的单元格应用 validateAll 的校验结果。
|
|
179
|
+
var touchSeqRef = React.useRef(0);
|
|
180
|
+
var cellTouchSeqRef = React.useRef(new Map());
|
|
181
|
+
var dataRef = React.useRef(data);
|
|
182
|
+
dataRef.current = data;
|
|
183
|
+
var onChangeRef = React.useRef(onChange);
|
|
184
|
+
onChangeRef.current = onChange;
|
|
185
|
+
var onValidateRef = React.useRef(onValidate);
|
|
186
|
+
onValidateRef.current = onValidate;
|
|
187
|
+
var getRowKeyRef = React.useRef(getRowKey);
|
|
188
|
+
getRowKeyRef.current = getRowKey;
|
|
189
|
+
var childrenColumnNameRef = React.useRef(childrenColumnName);
|
|
190
|
+
childrenColumnNameRef.current = childrenColumnName;
|
|
191
|
+
var scrollToRowRef = React.useRef(scrollToRow);
|
|
192
|
+
scrollToRowRef.current = scrollToRow;
|
|
193
|
+
|
|
194
|
+
// 错误 key 的第一分量是 rowKey;无 key 的降级场景传入 rowIndex
|
|
195
|
+
var errorKey = React.useCallback(function (rowId, dataIndex) {
|
|
196
|
+
return "".concat(rowId, "-").concat(dataIndex);
|
|
197
|
+
}, []);
|
|
198
|
+
|
|
199
|
+
// ---- 扁平化列 + 缓存映射 ----
|
|
200
|
+
// useMemo 确保 columns 引用不变时不会重复计算
|
|
201
|
+
var flatColumns = React.useMemo(function () {
|
|
202
|
+
var result = [];
|
|
203
|
+
var walk = function walk(cols) {
|
|
204
|
+
var _iterator2 = _createForOfIteratorHelper(cols),
|
|
205
|
+
_step2;
|
|
206
|
+
try {
|
|
207
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
208
|
+
var col = _step2.value;
|
|
209
|
+
if ('children' in col && col.children) {
|
|
210
|
+
walk(col.children);
|
|
211
|
+
} else {
|
|
212
|
+
result.push(col);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
_iterator2.e(err);
|
|
217
|
+
} finally {
|
|
218
|
+
_iterator2.f();
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
walk(columns);
|
|
222
|
+
return result;
|
|
223
|
+
}, [columns]);
|
|
224
|
+
var colMap = React.useMemo(function () {
|
|
225
|
+
var map = new Map();
|
|
226
|
+
var _iterator3 = _createForOfIteratorHelper(flatColumns),
|
|
227
|
+
_step3;
|
|
228
|
+
try {
|
|
229
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
230
|
+
var _col$dataIndex;
|
|
231
|
+
var col = _step3.value;
|
|
232
|
+
var key = String((_col$dataIndex = col.dataIndex) !== null && _col$dataIndex !== void 0 ? _col$dataIndex : col.key);
|
|
233
|
+
if (key) map.set(key, col);
|
|
234
|
+
}
|
|
235
|
+
} catch (err) {
|
|
236
|
+
_iterator3.e(err);
|
|
237
|
+
} finally {
|
|
238
|
+
_iterator3.f();
|
|
239
|
+
}
|
|
240
|
+
return map;
|
|
241
|
+
}, [flatColumns]);
|
|
242
|
+
var getEditableConfig = React.useCallback(function (col) {
|
|
243
|
+
if (!col) return null;
|
|
244
|
+
var ed = col.editable;
|
|
245
|
+
if (ed === true) return EMPTY_EDITABLE_CONFIG;
|
|
246
|
+
if (ed && _typeof(ed) === 'object') return ed;
|
|
247
|
+
return null;
|
|
248
|
+
}, []);
|
|
249
|
+
|
|
250
|
+
// 校验单个值
|
|
251
|
+
var validateValue = React.useCallback( /*#__PURE__*/function () {
|
|
252
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(value, record, config, colTitle, dataIndex) {
|
|
253
|
+
var messages, _iterator4, _step4, rule, isEmpty, msg;
|
|
254
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
255
|
+
while (1) switch (_context.prev = _context.next) {
|
|
256
|
+
case 0:
|
|
257
|
+
messages = [];
|
|
258
|
+
if (!config.rules) {
|
|
259
|
+
_context.next = 37;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
_iterator4 = _createForOfIteratorHelper(config.rules);
|
|
263
|
+
_context.prev = 3;
|
|
264
|
+
_iterator4.s();
|
|
265
|
+
case 5:
|
|
266
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
267
|
+
_context.next = 29;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
rule = _step4.value;
|
|
271
|
+
if (!rule.required) {
|
|
272
|
+
_context.next = 12;
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
isEmpty = value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
|
|
276
|
+
if (!isEmpty) {
|
|
277
|
+
_context.next = 12;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
messages.push(rule.message || "".concat(colTitle || dataIndex, " \u5FC5\u586B"));
|
|
281
|
+
return _context.abrupt("continue", 27);
|
|
282
|
+
case 12:
|
|
283
|
+
if (!(rule.pattern && value != null && value !== '')) {
|
|
284
|
+
_context.next = 16;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
if (rule.pattern.test(String(value))) {
|
|
288
|
+
_context.next = 16;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
messages.push(rule.message || "".concat(colTitle || dataIndex, " \u683C\u5F0F\u4E0D\u6B63\u786E"));
|
|
292
|
+
return _context.abrupt("continue", 27);
|
|
293
|
+
case 16:
|
|
294
|
+
if (!rule.validator) {
|
|
295
|
+
_context.next = 27;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
_context.prev = 17;
|
|
299
|
+
_context.next = 20;
|
|
300
|
+
return rule.validator(value, record);
|
|
301
|
+
case 20:
|
|
302
|
+
msg = _context.sent;
|
|
303
|
+
if (msg) messages.push(msg);
|
|
304
|
+
_context.next = 27;
|
|
305
|
+
break;
|
|
306
|
+
case 24:
|
|
307
|
+
_context.prev = 24;
|
|
308
|
+
_context.t0 = _context["catch"](17);
|
|
309
|
+
messages.push(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0));
|
|
310
|
+
case 27:
|
|
311
|
+
_context.next = 5;
|
|
312
|
+
break;
|
|
313
|
+
case 29:
|
|
314
|
+
_context.next = 34;
|
|
315
|
+
break;
|
|
316
|
+
case 31:
|
|
317
|
+
_context.prev = 31;
|
|
318
|
+
_context.t1 = _context["catch"](3);
|
|
319
|
+
_iterator4.e(_context.t1);
|
|
320
|
+
case 34:
|
|
321
|
+
_context.prev = 34;
|
|
322
|
+
_iterator4.f();
|
|
323
|
+
return _context.finish(34);
|
|
324
|
+
case 37:
|
|
325
|
+
return _context.abrupt("return", messages);
|
|
326
|
+
case 38:
|
|
327
|
+
case "end":
|
|
328
|
+
return _context.stop();
|
|
329
|
+
}
|
|
330
|
+
}, _callee, null, [[3, 31, 34, 37], [17, 24]]);
|
|
331
|
+
}));
|
|
332
|
+
return function (_x, _x2, _x3, _x4, _x5) {
|
|
333
|
+
return _ref2.apply(this, arguments);
|
|
334
|
+
};
|
|
335
|
+
}(), []);
|
|
336
|
+
|
|
337
|
+
// 校验单个单元格(rowKey 定位错误位;无 key 时降级为 rowIndex)
|
|
338
|
+
var validateCell = React.useCallback( /*#__PURE__*/function () {
|
|
339
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(rowKey, dataIndex, value, record, rowIndex) {
|
|
340
|
+
var _ref4, _ref5;
|
|
341
|
+
var col, config, messages, key;
|
|
342
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
343
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
344
|
+
case 0:
|
|
345
|
+
col = colMap.get(String(dataIndex));
|
|
346
|
+
if (col) {
|
|
347
|
+
_context2.next = 3;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
return _context2.abrupt("return");
|
|
351
|
+
case 3:
|
|
352
|
+
config = getEditableConfig(col);
|
|
353
|
+
if (config) {
|
|
354
|
+
_context2.next = 6;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
return _context2.abrupt("return");
|
|
358
|
+
case 6:
|
|
359
|
+
_context2.next = 8;
|
|
360
|
+
return validateValue(value, record, config, col.title, dataIndex);
|
|
361
|
+
case 8:
|
|
362
|
+
messages = _context2.sent;
|
|
363
|
+
key = errorKey((_ref4 = rowKey !== null && rowKey !== void 0 ? rowKey : rowIndex) !== null && _ref4 !== void 0 ? _ref4 : '', dataIndex); // 记录本次写入序号 — validateAll 据此识别校验期间被用户重新编辑过的单元格
|
|
364
|
+
cellTouchSeqRef.current.set(key, {
|
|
365
|
+
seq: ++touchSeqRef.current,
|
|
366
|
+
messages: messages,
|
|
367
|
+
rowId: (_ref5 = rowKey !== null && rowKey !== void 0 ? rowKey : rowIndex) !== null && _ref5 !== void 0 ? _ref5 : '',
|
|
368
|
+
dataIndex: dataIndex,
|
|
369
|
+
rowIndex: rowIndex
|
|
370
|
+
});
|
|
371
|
+
setErrors(function (prev) {
|
|
372
|
+
var existing = prev.get(key);
|
|
373
|
+
// 错误内容没变化 → 返回旧 Map,不触发 context 重渲染
|
|
374
|
+
if (existing && existing.length === messages.length && existing.every(function (m, i) {
|
|
375
|
+
return m === messages[i];
|
|
376
|
+
})) {
|
|
377
|
+
return prev;
|
|
378
|
+
}
|
|
379
|
+
if (!existing && messages.length === 0) {
|
|
380
|
+
return prev;
|
|
381
|
+
}
|
|
382
|
+
// 有变化才创建新 Map
|
|
383
|
+
var next = new Map(prev);
|
|
384
|
+
if (messages.length > 0) {
|
|
385
|
+
next.set(key, messages);
|
|
386
|
+
} else {
|
|
387
|
+
next.delete(key);
|
|
388
|
+
}
|
|
389
|
+
return next;
|
|
390
|
+
});
|
|
391
|
+
case 12:
|
|
392
|
+
case "end":
|
|
393
|
+
return _context2.stop();
|
|
394
|
+
}
|
|
395
|
+
}, _callee2);
|
|
396
|
+
}));
|
|
397
|
+
return function (_x6, _x7, _x8, _x9, _x10) {
|
|
398
|
+
return _ref3.apply(this, arguments);
|
|
399
|
+
};
|
|
400
|
+
}(), [errorKey, getEditableConfig, validateValue, colMap]);
|
|
401
|
+
|
|
402
|
+
// 校验全部数据(异步 — 支持异步 validator)
|
|
403
|
+
var validateAll = React.useCallback( /*#__PURE__*/function () {
|
|
404
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(validateData) {
|
|
405
|
+
var _onValidateRef$curren;
|
|
406
|
+
var rows, nextErrors, startTouchSeq, flatRows, rowResults, errorEntries, _iterator7, _step7, _step7$value, _rowIndex, _rowKey, cells, _iterator9, _step9, cell, mergedErrors, mergedFirstError, _i, _errorEntries, _errorEntries$_i, key, errRowIndex, errRowKey, errDataIndex, errMessages, _iterator8, _step8, _step8$value, _key, touched, _touched$rowIndex, touchedRowIndex, result;
|
|
407
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
408
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
409
|
+
case 0:
|
|
410
|
+
rows = validateData !== null && validateData !== void 0 ? validateData : dataRef.current;
|
|
411
|
+
nextErrors = new Map(); // 校验开始时的写入序号快照 — 完成合并时以此识别校验期间被触碰过的单元格
|
|
412
|
+
startTouchSeq = touchSeqRef.current; // 扁平化(DFS,含树形 children)— 错误以 rowKey 定位,排序/筛选后仍挂对行
|
|
413
|
+
flatRows = flattenEditableRows(rows, childrenColumnNameRef.current, getRowKeyRef.current); // 行间并行、行内串行(保留 continue 语义)
|
|
414
|
+
_context4.next = 6;
|
|
415
|
+
return Promise.all(flatRows.map( /*#__PURE__*/function () {
|
|
416
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref7) {
|
|
417
|
+
var row, rowIndex, rowKey, cells, _iterator5, _step5, col, config, dataIndex, value, messages, _iterator6, _step6, rule, isEmpty, msg;
|
|
418
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
419
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
420
|
+
case 0:
|
|
421
|
+
row = _ref7.record, rowIndex = _ref7.rowIndex, rowKey = _ref7.rowKey;
|
|
422
|
+
cells = [];
|
|
423
|
+
_iterator5 = _createForOfIteratorHelper(flatColumns);
|
|
424
|
+
_context3.prev = 3;
|
|
425
|
+
_iterator5.s();
|
|
426
|
+
case 5:
|
|
427
|
+
if ((_step5 = _iterator5.n()).done) {
|
|
428
|
+
_context3.next = 52;
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
col = _step5.value;
|
|
432
|
+
config = getEditableConfig(col);
|
|
433
|
+
if (config) {
|
|
434
|
+
_context3.next = 10;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
return _context3.abrupt("continue", 50);
|
|
438
|
+
case 10:
|
|
439
|
+
dataIndex = col.dataIndex;
|
|
440
|
+
value = row[dataIndex];
|
|
441
|
+
messages = [];
|
|
442
|
+
if (!config.rules) {
|
|
443
|
+
_context3.next = 49;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
_iterator6 = _createForOfIteratorHelper(config.rules);
|
|
447
|
+
_context3.prev = 15;
|
|
448
|
+
_iterator6.s();
|
|
449
|
+
case 17:
|
|
450
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
451
|
+
_context3.next = 41;
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
rule = _step6.value;
|
|
455
|
+
if (!rule.required) {
|
|
456
|
+
_context3.next = 24;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
isEmpty = value === undefined || value === null || value === '' || Array.isArray(value) && value.length === 0;
|
|
460
|
+
if (!isEmpty) {
|
|
461
|
+
_context3.next = 24;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
messages.push(rule.message || "".concat(String(col.title || dataIndex), " \u5FC5\u586B"));
|
|
465
|
+
return _context3.abrupt("continue", 39);
|
|
466
|
+
case 24:
|
|
467
|
+
if (!(rule.pattern && value != null && value !== '')) {
|
|
468
|
+
_context3.next = 28;
|
|
469
|
+
break;
|
|
470
|
+
}
|
|
471
|
+
if (rule.pattern.test(String(value))) {
|
|
472
|
+
_context3.next = 28;
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
messages.push(rule.message || "".concat(String(col.title || dataIndex), " \u683C\u5F0F\u4E0D\u6B63\u786E"));
|
|
476
|
+
return _context3.abrupt("continue", 39);
|
|
477
|
+
case 28:
|
|
478
|
+
if (!rule.validator) {
|
|
479
|
+
_context3.next = 39;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
_context3.prev = 29;
|
|
483
|
+
_context3.next = 32;
|
|
484
|
+
return rule.validator(value, row);
|
|
485
|
+
case 32:
|
|
486
|
+
msg = _context3.sent;
|
|
487
|
+
if (msg) messages.push(msg);
|
|
488
|
+
_context3.next = 39;
|
|
489
|
+
break;
|
|
490
|
+
case 36:
|
|
491
|
+
_context3.prev = 36;
|
|
492
|
+
_context3.t0 = _context3["catch"](29);
|
|
493
|
+
messages.push(_context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0));
|
|
494
|
+
case 39:
|
|
495
|
+
_context3.next = 17;
|
|
496
|
+
break;
|
|
497
|
+
case 41:
|
|
498
|
+
_context3.next = 46;
|
|
499
|
+
break;
|
|
500
|
+
case 43:
|
|
501
|
+
_context3.prev = 43;
|
|
502
|
+
_context3.t1 = _context3["catch"](15);
|
|
503
|
+
_iterator6.e(_context3.t1);
|
|
504
|
+
case 46:
|
|
505
|
+
_context3.prev = 46;
|
|
506
|
+
_iterator6.f();
|
|
507
|
+
return _context3.finish(46);
|
|
508
|
+
case 49:
|
|
509
|
+
if (messages.length > 0) {
|
|
510
|
+
cells.push({
|
|
511
|
+
key: errorKey(rowKey !== null && rowKey !== void 0 ? rowKey : rowIndex, String(dataIndex)),
|
|
512
|
+
dataIndex: dataIndex,
|
|
513
|
+
messages: messages
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
case 50:
|
|
517
|
+
_context3.next = 5;
|
|
518
|
+
break;
|
|
519
|
+
case 52:
|
|
520
|
+
_context3.next = 57;
|
|
521
|
+
break;
|
|
522
|
+
case 54:
|
|
523
|
+
_context3.prev = 54;
|
|
524
|
+
_context3.t2 = _context3["catch"](3);
|
|
525
|
+
_iterator5.e(_context3.t2);
|
|
526
|
+
case 57:
|
|
527
|
+
_context3.prev = 57;
|
|
528
|
+
_iterator5.f();
|
|
529
|
+
return _context3.finish(57);
|
|
530
|
+
case 60:
|
|
531
|
+
return _context3.abrupt("return", {
|
|
532
|
+
rowIndex: rowIndex,
|
|
533
|
+
rowKey: rowKey,
|
|
534
|
+
cells: cells
|
|
535
|
+
});
|
|
536
|
+
case 61:
|
|
537
|
+
case "end":
|
|
538
|
+
return _context3.stop();
|
|
539
|
+
}
|
|
540
|
+
}, _callee3, null, [[3, 54, 57, 60], [15, 43, 46, 49], [29, 36]]);
|
|
541
|
+
}));
|
|
542
|
+
return function (_x12) {
|
|
543
|
+
return _ref8.apply(this, arguments);
|
|
544
|
+
};
|
|
545
|
+
}()));
|
|
546
|
+
case 6:
|
|
547
|
+
rowResults = _context4.sent;
|
|
548
|
+
// 收集本次校验的错误条目,用于合并后重建 firstError
|
|
549
|
+
errorEntries = []; // 合并结果
|
|
550
|
+
_iterator7 = _createForOfIteratorHelper(rowResults);
|
|
551
|
+
try {
|
|
552
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
553
|
+
_step7$value = _step7.value, _rowIndex = _step7$value.rowIndex, _rowKey = _step7$value.rowKey, cells = _step7$value.cells;
|
|
554
|
+
_iterator9 = _createForOfIteratorHelper(cells);
|
|
555
|
+
try {
|
|
556
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
557
|
+
cell = _step9.value;
|
|
558
|
+
nextErrors.set(cell.key, cell.messages);
|
|
559
|
+
errorEntries.push({
|
|
560
|
+
key: cell.key,
|
|
561
|
+
rowIndex: _rowIndex,
|
|
562
|
+
rowKey: _rowKey,
|
|
563
|
+
dataIndex: cell.dataIndex,
|
|
564
|
+
messages: cell.messages
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
} catch (err) {
|
|
568
|
+
_iterator9.e(err);
|
|
569
|
+
} finally {
|
|
570
|
+
_iterator9.f();
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// 函数式合并:异步校验期间被用户重新编辑过的单元格
|
|
575
|
+
// (validateCell 已写入,序号 > startTouchSeq)保留其最新错误状态;
|
|
576
|
+
// 未被触碰的单元格应用本次校验结果。
|
|
577
|
+
// setErrors 与返回值共用同一份合并结果,保证外部拿到的 errors 与内部 state 一致。
|
|
578
|
+
} catch (err) {
|
|
579
|
+
_iterator7.e(err);
|
|
580
|
+
} finally {
|
|
581
|
+
_iterator7.f();
|
|
582
|
+
}
|
|
583
|
+
mergedErrors = mergeValidatedErrors(nextErrors, cellTouchSeqRef.current, startTouchSeq); // 合并后重建 firstError:保留在 mergedErrors 中的错误里 rowIndex 最小者
|
|
584
|
+
for (_i = 0, _errorEntries = errorEntries; _i < _errorEntries.length; _i++) {
|
|
585
|
+
_errorEntries$_i = _errorEntries[_i], key = _errorEntries$_i.key, errRowIndex = _errorEntries$_i.rowIndex, errRowKey = _errorEntries$_i.rowKey, errDataIndex = _errorEntries$_i.dataIndex, errMessages = _errorEntries$_i.messages;
|
|
586
|
+
if (mergedErrors.has(key)) {
|
|
587
|
+
if (!mergedFirstError || errRowIndex < mergedFirstError.rowIndex) {
|
|
588
|
+
mergedFirstError = {
|
|
589
|
+
rowIndex: errRowIndex,
|
|
590
|
+
rowKey: errRowKey !== null && errRowKey !== void 0 ? errRowKey : errRowIndex,
|
|
591
|
+
dataIndex: errDataIndex,
|
|
592
|
+
message: errMessages[0]
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
_iterator8 = _createForOfIteratorHelper(cellTouchSeqRef.current);
|
|
598
|
+
try {
|
|
599
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
600
|
+
_step8$value = _slicedToArray(_step8.value, 2), _key = _step8$value[0], touched = _step8$value[1];
|
|
601
|
+
if (touched.seq > startTouchSeq && touched.messages.length > 0 && mergedErrors.has(_key)) {
|
|
602
|
+
touchedRowIndex = (_touched$rowIndex = touched.rowIndex) !== null && _touched$rowIndex !== void 0 ? _touched$rowIndex : 0;
|
|
603
|
+
if (!mergedFirstError || touchedRowIndex < mergedFirstError.rowIndex) {
|
|
604
|
+
mergedFirstError = {
|
|
605
|
+
rowIndex: touchedRowIndex,
|
|
606
|
+
rowKey: touched.rowId,
|
|
607
|
+
dataIndex: touched.dataIndex,
|
|
608
|
+
message: touched.messages[0]
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
} catch (err) {
|
|
614
|
+
_iterator8.e(err);
|
|
615
|
+
} finally {
|
|
616
|
+
_iterator8.f();
|
|
617
|
+
}
|
|
618
|
+
setErrors(mergedErrors);
|
|
619
|
+
result = {
|
|
620
|
+
valid: mergedErrors.size === 0,
|
|
621
|
+
firstError: mergedFirstError,
|
|
622
|
+
errors: mergedErrors
|
|
623
|
+
};
|
|
624
|
+
(_onValidateRef$curren = onValidateRef.current) === null || _onValidateRef$curren === void 0 || _onValidateRef$curren.call(onValidateRef, result);
|
|
625
|
+
if (!result.valid && mergedFirstError && scrollToRowRef.current) {
|
|
626
|
+
scrollToRowRef.current(mergedFirstError.rowKey, mergedFirstError.rowIndex);
|
|
627
|
+
}
|
|
628
|
+
return _context4.abrupt("return", result);
|
|
629
|
+
case 19:
|
|
630
|
+
case "end":
|
|
631
|
+
return _context4.stop();
|
|
632
|
+
}
|
|
633
|
+
}, _callee4);
|
|
634
|
+
}));
|
|
635
|
+
return function (_x11) {
|
|
636
|
+
return _ref6.apply(this, arguments);
|
|
637
|
+
};
|
|
638
|
+
}(), [errorKey, getEditableConfig, flatColumns]);
|
|
639
|
+
var resetErrors = React.useCallback(function () {
|
|
640
|
+
setErrors(new Map());
|
|
641
|
+
}, []);
|
|
642
|
+
var onCellChange = React.useCallback(function (rowKey, dataIndex, value, record, rowIndex) {
|
|
643
|
+
var _onChangeRef$current;
|
|
644
|
+
var currentData = dataRef.current;
|
|
645
|
+
var newData;
|
|
646
|
+
|
|
647
|
+
// 优先按 rowKey 定位(含树形 children)— 排序/筛选后展示下标与 rawData 下标已不一致
|
|
648
|
+
if (rowKey !== undefined && rowKey !== null && getRowKeyRef.current) {
|
|
649
|
+
newData = updateRecordByKey(currentData, childrenColumnNameRef.current, getRowKeyRef.current, rowKey, dataIndex, value);
|
|
650
|
+
}
|
|
651
|
+
if (!newData) {
|
|
652
|
+
// 降级:无 key / key 未命中 / key 重复 → 维持原有索引行为
|
|
653
|
+
newData = currentData.map(function (row, i) {
|
|
654
|
+
if (i === rowIndex) {
|
|
655
|
+
return _objectSpread(_objectSpread({}, row), {}, _defineProperty({}, dataIndex, value));
|
|
656
|
+
}
|
|
657
|
+
return row;
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
(_onChangeRef$current = onChangeRef.current) === null || _onChangeRef$current === void 0 || _onChangeRef$current.call(onChangeRef, newData);
|
|
661
|
+
|
|
662
|
+
// 触发列的 onChange 回调 — O(1) 查找
|
|
663
|
+
var col = colMap.get(String(dataIndex));
|
|
664
|
+
if (col) {
|
|
665
|
+
var _config$onChange;
|
|
666
|
+
var config = getEditableConfig(col);
|
|
667
|
+
config === null || config === void 0 || (_config$onChange = config.onChange) === null || _config$onChange === void 0 || _config$onChange.call(config, value, record, rowIndex);
|
|
668
|
+
}
|
|
669
|
+
}, [getEditableConfig, colMap]);
|
|
670
|
+
var scrollToError = React.useCallback(function (rowKey, rowIndex) {
|
|
671
|
+
var _scrollToRowRef$curre;
|
|
672
|
+
(_scrollToRowRef$curre = scrollToRowRef.current) === null || _scrollToRowRef$curre === void 0 || _scrollToRowRef$curre.call(scrollToRowRef, rowKey, rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0);
|
|
673
|
+
}, []);
|
|
674
|
+
var contextValue = React.useMemo(function () {
|
|
675
|
+
return {
|
|
676
|
+
errors: errors,
|
|
677
|
+
validateCell: validateCell,
|
|
678
|
+
validateAll: validateAll,
|
|
679
|
+
resetErrors: resetErrors,
|
|
680
|
+
onCellChange: onCellChange,
|
|
681
|
+
scrollToError: scrollToError
|
|
682
|
+
};
|
|
683
|
+
}, [errors, validateCell, validateAll, resetErrors, onCellChange, scrollToError]);
|
|
684
|
+
return {
|
|
685
|
+
contextValue: contextValue,
|
|
686
|
+
errors: errors,
|
|
687
|
+
validateCell: validateCell,
|
|
688
|
+
validateAll: validateAll,
|
|
689
|
+
resetErrors: resetErrors,
|
|
690
|
+
onCellChange: onCellChange
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
export default useEditable;
|