@dtjoy/dt-design 1.1.1 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -24
- package/dist/dt-design.min.css +1 -0
- package/dist/dt-design.min.js +1 -0
- package/es/_util/context/createContextSelector.d.ts +28 -0
- package/es/_util/context/createContextSelector.js +110 -0
- package/es/_util/context/immutable.d.ts +10 -0
- package/es/_util/context/immutable.js +84 -0
- package/es/_util/context/index.d.ts +3 -0
- package/es/_util/context/index.js +3 -0
- package/{esm → es}/_util/gapSize.d.ts +1 -1
- package/{esm → es}/_util/getScroll.js +1 -1
- package/es/_util/hooks/index.d.ts +11 -0
- package/es/_util/hooks/index.js +11 -0
- package/es/_util/hooks/useBreakpoint.d.ts +5 -0
- package/es/_util/hooks/useBreakpoint.js +75 -0
- package/es/_util/hooks/useCssVar.d.ts +3 -0
- package/es/_util/hooks/useCssVar.js +28 -0
- package/es/_util/hooks/useEvent.d.ts +1 -0
- package/es/_util/hooks/useEvent.js +1 -0
- package/es/_util/hooks/useLayoutEffect.d.ts +1 -0
- package/es/_util/hooks/useLayoutEffect.js +1 -0
- package/es/_util/hooks/useMultipleSelect.d.ts +2 -0
- package/es/_util/hooks/useMultipleSelect.js +37 -0
- package/es/_util/hooks/useProxyImperativeHandle.d.ts +4 -0
- package/{esm → es}/_util/hooks/useProxyImperativeHandle.js +10 -3
- package/es/_util/hooks/useTimeoutLock.d.ts +1 -0
- package/es/_util/hooks/useTimeoutLock.js +26 -0
- package/es/_util/index.d.ts +11 -0
- package/{esm → es}/_util/index.js +9 -1
- package/es/_util/is.d.ts +5 -0
- package/es/_util/is.js +16 -0
- package/es/_util/rcUtil.d.ts +17 -0
- package/es/_util/rcUtil.js +58 -0
- package/{esm → es}/_util/scrollTo.js +1 -1
- package/es/_util/scrollbar.d.ts +1 -0
- package/es/_util/scrollbar.js +32 -0
- package/{esm → es}/_util/type.d.ts +1 -0
- package/es/_util/validate.d.ts +2 -0
- package/es/_util/validate.js +10 -0
- package/{esm → es}/_util/warning.js +5 -6
- package/{lib/blockHeader → es/block-header}/index.d.ts +1 -1
- package/{esm/blockHeader → es/block-header}/index.js +1 -1
- package/{lib/blockHeader → es/block-header}/style/index.less +167 -143
- package/{esm → es}/button/index.d.ts +3 -3
- package/{esm → es}/button/index.js +16 -4
- package/{esm → es}/button/style/index.less +62 -59
- package/{esm → es}/button/style/mixin.less +40 -39
- package/{esm → es}/collapsible/index.js +3 -2
- package/{esm → es}/collapsible/style/index.less +24 -24
- package/{esm/collapsibleActionItems → es/collapsible-action-items}/index.d.ts +1 -1
- package/{esm/collapsibleActionItems → es/collapsible-action-items}/index.js +21 -19
- package/{lib/collapsibleActionItems → es/collapsible-action-items}/style/index.less +7 -7
- package/{lib → es}/flex/index.d.ts +2 -2
- package/{esm → es}/flex/index.js +3 -3
- package/{esm → es}/flex/style/index.less +80 -76
- package/{esm/formList → es/form-list}/index.d.ts +9 -0
- package/{esm/formList → es/form-list}/index.js +18 -8
- package/{lib/formList → es/form-list}/style/index.less +45 -45
- package/es/index.d.ts +26 -0
- package/es/index.js +21 -0
- package/{lib/overflowList → es/overflow-list}/index.d.ts +4 -1
- package/{esm/overflowList → es/overflow-list}/index.js +37 -9
- package/{esm/overflowList → es/overflow-list}/style/index.less +9 -9
- package/{lib/resizeObserver → es/resize-observer}/index.d.ts +1 -1
- package/{esm/resizeObserver → es/resize-observer}/index.js +8 -8
- package/{esm → es}/splitter/Panel.d.ts +1 -1
- package/{esm → es}/splitter/Panel.js +12 -4
- package/{esm → es}/splitter/SplitBar.d.ts +6 -2
- package/{esm → es}/splitter/SplitBar.js +82 -80
- package/{esm → es}/splitter/Splitter.js +52 -23
- package/{esm → es}/splitter/hooks/sizeUtil.js +1 -1
- package/es/splitter/hooks/useDragListeners.d.ts +14 -0
- package/es/splitter/hooks/useDragListeners.js +107 -0
- package/{esm → es}/splitter/hooks/useItems.d.ts +6 -0
- package/es/splitter/hooks/useOrientation.d.ts +2 -0
- package/es/splitter/hooks/useOrientation.js +6 -0
- package/{esm → es}/splitter/hooks/useResizable.d.ts +3 -0
- package/{esm → es}/splitter/hooks/useResizable.js +5 -2
- package/{esm → es}/splitter/hooks/useResize.d.ts +1 -1
- package/{esm → es}/splitter/hooks/useResize.js +10 -3
- package/{esm → es}/splitter/hooks/useSizes.js +5 -6
- package/{lib → es}/splitter/index.d.ts +2 -1
- package/es/splitter/interface.d.ts +45 -0
- package/es/splitter/style/index.less +349 -0
- package/{esm/statusTag → es/status-tag}/index.js +1 -1
- package/{esm/statusTag → es/status-tag}/style/index.less +70 -70
- package/{esm/statusTag → es/status-tag}/style/mixin.less +48 -39
- package/{esm → es}/style/index.less +1 -1
- package/es/style/themes/index.less +2 -0
- package/{esm → es}/style/themes/variable.less +5 -5
- package/es/table/Column.d.ts +2 -0
- package/es/table/Column.js +1 -0
- package/es/table/ColumnGroup.d.ts +2 -0
- package/es/table/ColumnGroup.js +1 -0
- package/es/table/InternalTable.d.ts +43 -0
- package/es/table/InternalTable.js +816 -0
- package/{lib → es}/table/Table.d.ts +7 -5
- package/{esm → es}/table/Table.js +6 -4
- package/es/table/components/Body/BodyRow.d.ts +37 -0
- package/es/table/components/Body/BodyRow.js +182 -0
- package/es/table/components/Body/ExpandedRow.d.ts +15 -0
- package/es/table/components/Body/ExpandedRow.js +51 -0
- package/es/table/components/Body/MeasureCell.d.ts +8 -0
- package/es/table/components/Body/MeasureCell.js +33 -0
- package/es/table/components/Body/MeasureRow.d.ts +10 -0
- package/es/table/components/Body/MeasureRow.js +54 -0
- package/es/table/components/Body/index.d.ts +11 -0
- package/es/table/components/Body/index.js +123 -0
- package/es/table/components/Cell/index.d.ts +39 -0
- package/es/table/components/Cell/index.js +196 -0
- package/es/table/components/Cell/useCellRender.d.ts +3 -0
- package/es/table/components/Cell/useCellRender.js +69 -0
- package/es/table/components/Cell/useHoverState.d.ts +2 -0
- package/es/table/components/Cell/useHoverState.js +13 -0
- package/es/table/components/ColGroup.d.ts +9 -0
- package/es/table/components/ColGroup.js +53 -0
- package/es/table/components/ExpandIcon.d.ts +12 -0
- package/es/table/components/ExpandIcon.js +27 -0
- package/es/table/components/FixedHolder/index.d.ts +27 -0
- package/es/table/components/FixedHolder/index.js +186 -0
- package/es/table/components/Footer/Cell.d.ts +11 -0
- package/es/table/components/Footer/Cell.js +47 -0
- package/es/table/components/Footer/Row.d.ts +8 -0
- package/es/table/components/Footer/Row.js +10 -0
- package/es/table/components/Footer/Summary.d.ts +14 -0
- package/es/table/components/Footer/Summary.js +12 -0
- package/es/table/components/Footer/SummaryContext.d.ts +11 -0
- package/es/table/components/Footer/SummaryContext.js +3 -0
- package/es/table/components/Footer/index.d.ts +16 -0
- package/es/table/components/Footer/index.js +31 -0
- package/es/table/components/Header/Header.d.ts +10 -0
- package/es/table/components/Header/Header.js +110 -0
- package/es/table/components/Header/HeaderRow.d.ts +19 -0
- package/es/table/components/Header/HeaderRow.js +63 -0
- package/es/table/components/Panel.d.ts +7 -0
- package/es/table/components/Panel.js +11 -0
- package/es/table/components/RcTable.d.ts +114 -0
- package/es/table/components/RcTable.js +757 -0
- package/es/table/components/VirtualTable.d.ts +5 -0
- package/{esm/table/RcTable → es/table/components}/VirtualTable.js +4 -1
- package/es/table/components/VirtualTableBody/BodyGrid.d.ts +13 -0
- package/es/table/components/VirtualTableBody/BodyGrid.js +307 -0
- package/es/table/components/VirtualTableBody/BodyLine.d.ts +14 -0
- package/es/table/components/VirtualTableBody/BodyLine.js +116 -0
- package/es/table/components/VirtualTableBody/VirtualCell.d.ts +26 -0
- package/es/table/components/VirtualTableBody/VirtualCell.js +118 -0
- package/es/table/components/VirtualTableBody/context.d.ts +13 -0
- package/es/table/components/VirtualTableBody/context.js +3 -0
- package/es/table/components/VirtualTableBody/index.d.ts +16 -0
- package/es/table/components/VirtualTableBody/index.js +102 -0
- package/es/table/constant.d.ts +2 -0
- package/es/table/constant.js +2 -0
- package/es/table/features/columns/Column.d.ts +7 -0
- package/es/table/features/columns/Column.js +4 -0
- package/es/table/features/columns/ColumnGroup.d.ts +9 -0
- package/es/table/features/columns/ColumnGroup.js +4 -0
- package/es/table/features/columns/index.d.ts +8 -0
- package/es/table/features/columns/index.js +6 -0
- package/es/table/features/columns/useColumns.d.ts +31 -0
- package/es/table/features/columns/useColumns.js +227 -0
- package/es/table/features/columns/useFilledColumns.d.ts +4 -0
- package/es/table/features/columns/useFilledColumns.js +34 -0
- package/es/table/features/columns/useTitleColumns.d.ts +4 -0
- package/es/table/features/columns/useTitleColumns.js +26 -0
- package/es/table/features/columns/useWidthColumns.d.ts +5 -0
- package/es/table/features/columns/useWidthColumns.js +75 -0
- package/es/table/features/editable/BatchEditModal.d.ts +4 -0
- package/es/table/features/editable/BatchEditModal.js +786 -0
- package/es/table/features/editable/EditableCell.d.ts +42 -0
- package/es/table/features/editable/EditableCell.js +294 -0
- package/es/table/features/editable/EditableContext.d.ts +33 -0
- package/es/table/features/editable/EditableContext.js +20 -0
- package/es/table/features/editable/batchEditTypes.d.ts +55 -0
- package/es/table/features/editable/batchEditTypes.js +1 -0
- package/es/table/features/editable/batchEditUtils.d.ts +44 -0
- package/es/table/features/editable/batchEditUtils.js +258 -0
- package/es/table/features/editable/builtinEditors.d.ts +32 -0
- package/es/table/features/editable/builtinEditors.js +165 -0
- package/es/table/features/editable/index.d.ts +11 -0
- package/es/table/features/editable/index.js +10 -0
- package/es/table/features/editable/useBatchRules.d.ts +17 -0
- package/es/table/features/editable/useBatchRules.js +96 -0
- package/es/table/features/editable/useEditable.d.ts +51 -0
- package/es/table/features/editable/useEditable.js +693 -0
- package/es/table/features/expand/expandUtil.d.ts +5 -0
- package/es/table/features/expand/expandUtil.js +47 -0
- package/es/table/features/expand/index.d.ts +2 -0
- package/es/table/features/expand/index.js +2 -0
- package/es/table/features/expand/useExpand.d.ts +10 -0
- package/es/table/features/expand/useExpand.js +90 -0
- package/es/table/features/filter/FilterDropdown.d.ts +31 -0
- package/es/table/features/filter/FilterDropdown.js +494 -0
- package/es/table/features/filter/FilterSearch.d.ts +12 -0
- package/es/table/features/filter/FilterSearch.js +24 -0
- package/es/table/features/filter/FilterWrapper.d.ts +8 -0
- package/es/table/features/filter/FilterWrapper.js +23 -0
- package/es/table/features/filter/index.d.ts +4 -0
- package/es/table/features/filter/index.js +4 -0
- package/es/table/features/filter/useFilter.d.ts +22 -0
- package/es/table/features/filter/useFilter.js +240 -0
- package/es/table/features/fixed/fixUtil.d.ts +21 -0
- package/es/table/features/fixed/fixUtil.js +69 -0
- package/es/table/features/fixed/index.d.ts +4 -0
- package/es/table/features/fixed/index.js +4 -0
- package/es/table/features/fixed/offsetUtil.d.ts +4 -0
- package/es/table/features/fixed/offsetUtil.js +13 -0
- package/es/table/features/fixed/useFixedInfo.d.ts +2 -0
- package/es/table/features/fixed/useFixedInfo.js +16 -0
- package/es/table/features/fixed/useStickyOffsets.d.ts +6 -0
- package/es/table/features/fixed/useStickyOffsets.js +29 -0
- package/es/table/features/hover/index.d.ts +1 -0
- package/es/table/features/hover/index.js +1 -0
- package/es/table/features/hover/useHover.d.ts +2 -0
- package/es/table/features/hover/useHover.js +22 -0
- package/es/table/features/pagination/index.d.ts +1 -0
- package/es/table/features/pagination/index.js +1 -0
- package/es/table/features/pagination/usePagination.d.ts +5 -0
- package/es/table/features/pagination/usePagination.js +89 -0
- package/es/table/features/resize/ResizeHandle.d.ts +22 -0
- package/es/table/features/resize/ResizeHandle.js +99 -0
- package/es/table/features/resize/index.d.ts +5 -0
- package/es/table/features/resize/index.js +3 -0
- package/es/table/features/resize/transformResizableColumns.d.ts +11 -0
- package/es/table/features/resize/transformResizableColumns.js +52 -0
- package/es/table/features/resize/useResize.d.ts +52 -0
- package/es/table/features/resize/useResize.js +586 -0
- package/es/table/features/selection/index.d.ts +1 -0
- package/es/table/features/selection/index.js +1 -0
- package/es/table/features/selection/useSelection.d.ts +20 -0
- package/es/table/features/selection/useSelection.js +579 -0
- package/es/table/features/sort/index.d.ts +1 -0
- package/es/table/features/sort/index.js +1 -0
- package/es/table/features/sort/useSorter.d.ts +21 -0
- package/es/table/features/sort/useSorter.js +372 -0
- package/es/table/features/sticky/index.d.ts +2 -0
- package/es/table/features/sticky/index.js +2 -0
- package/es/table/features/sticky/stickyScrollBar.d.ts +12 -0
- package/es/table/features/sticky/stickyScrollBar.js +203 -0
- package/es/table/features/sticky/useSticky.d.ts +10 -0
- package/es/table/features/sticky/useSticky.js +34 -0
- package/es/table/features/summary/index.d.ts +1 -0
- package/es/table/features/summary/index.js +1 -0
- package/es/table/features/virtual/index.d.ts +2 -0
- package/es/table/features/virtual/index.js +2 -0
- package/es/table/features/virtual/useFlattenRecords.d.ts +19 -0
- package/es/table/features/virtual/useFlattenRecords.js +55 -0
- package/es/table/features/virtual/useFrame.d.ts +7 -0
- package/es/table/features/virtual/useFrame.js +67 -0
- package/es/table/immutableHelper.d.ts +9 -0
- package/es/table/immutableHelper.js +36 -0
- package/es/table/index.d.ts +24 -0
- package/es/table/index.js +23 -0
- package/es/table/interface.d.ts +438 -0
- package/es/table/interface.js +56 -0
- package/es/table/shared/context/PerfContext.d.ts +6 -0
- package/es/table/shared/context/PerfContext.js +6 -0
- package/es/table/shared/context/TableContext.d.ts +51 -0
- package/es/table/shared/context/TableContext.js +8 -0
- package/es/table/shared/hooks/useLazyKVMap.d.ts +4 -0
- package/es/table/shared/hooks/useLazyKVMap.js +30 -0
- package/es/table/shared/hooks/useRenderTimes.d.ts +5 -0
- package/es/table/shared/hooks/useRenderTimes.js +39 -0
- package/es/table/shared/hooks/useRowInfo.d.ts +11 -0
- package/es/table/shared/hooks/useRowInfo.js +73 -0
- package/es/table/shared/utils/legacyUtil.d.ts +5 -0
- package/es/table/shared/utils/legacyUtil.js +30 -0
- package/{esm/table → es/table/shared/utils}/util.d.ts +3 -11
- package/{esm/table → es/table/shared/utils}/util.js +6 -13
- package/es/table/shared/utils/valueUtil.d.ts +8 -0
- package/es/table/shared/utils/valueUtil.js +29 -0
- package/es/table/style/base.less +164 -0
- package/es/table/style/bordered.less +83 -0
- package/es/table/style/editable.less +50 -0
- package/es/table/style/ellipsis.less +33 -0
- package/es/table/style/empty.less +16 -0
- package/es/table/style/expand.less +123 -0
- package/es/table/style/filter.less +34 -0
- package/es/table/style/fixed.less +85 -0
- package/es/table/style/index.d.ts +3 -0
- package/es/table/style/index.js +3 -0
- package/es/table/style/index.less +19 -0
- package/es/table/style/pagination.less +29 -0
- package/es/table/style/radius.less +64 -0
- package/es/table/style/resize.less +78 -0
- package/es/table/style/rtl.less +52 -0
- package/es/table/style/selection.less +63 -0
- package/es/table/style/size.less +54 -0
- package/es/table/style/sorter.less +99 -0
- package/es/table/style/sticky.less +45 -0
- package/es/table/style/summary.less +23 -0
- package/es/table/style/variables.less +80 -0
- package/es/table/style/virtual.less +95 -0
- package/lib/_util/context/createContextSelector.js +120 -0
- package/lib/_util/context/immutable.js +92 -0
- package/lib/_util/context/index.js +41 -0
- package/lib/_util/easings.js +1 -1
- package/lib/_util/getScroll.js +6 -6
- package/lib/_util/hooks/index.js +82 -5
- package/lib/_util/hooks/useBreakpoint.js +85 -0
- package/lib/_util/hooks/useCssVar.js +37 -0
- package/lib/_util/hooks/useEvent.js +13 -0
- package/lib/_util/hooks/useForceUpdate.js +5 -4
- package/lib/_util/hooks/useLayoutEffect.js +13 -0
- package/lib/_util/hooks/useMultipleSelect.js +43 -0
- package/lib/_util/hooks/useOrientation.js +7 -8
- package/lib/_util/hooks/useProxyImperativeHandle.js +18 -14
- package/lib/_util/hooks/useSyncState.js +19 -9
- package/lib/_util/hooks/useTimeoutLock.js +35 -0
- package/lib/_util/index.js +101 -1
- package/lib/_util/is.js +22 -0
- package/lib/_util/rcUtil.js +134 -0
- package/lib/_util/scrollTo.js +22 -18
- package/lib/_util/scrollbar.js +38 -0
- package/lib/_util/validate.js +17 -0
- package/lib/_util/warning.js +25 -27
- package/lib/block-header/index.js +141 -0
- package/{esm/blockHeader → lib/block-header}/style/index.less +167 -143
- package/lib/button/index.js +24 -9
- package/lib/button/style/index.less +62 -59
- package/lib/button/style/mixin.less +40 -39
- package/lib/collapsible/index.js +210 -169
- package/lib/collapsible/style/index.less +24 -24
- package/lib/collapsible-action-items/index.js +83 -0
- package/{esm/collapsibleActionItems → lib/collapsible-action-items}/style/index.less +7 -7
- package/lib/flex/index.js +43 -34
- package/lib/flex/style/index.less +80 -76
- package/lib/flex/utils.js +23 -23
- package/lib/form-list/index.js +163 -0
- package/{esm/formList → lib/form-list}/style/index.less +45 -45
- package/lib/index.js +37 -67
- package/lib/overflow-list/index.js +203 -0
- package/lib/{overflowList → overflow-list}/style/index.less +9 -9
- package/lib/resize/index.js +13 -13
- package/lib/resize-observer/index.js +182 -0
- package/lib/splitter/Panel.js +36 -25
- package/lib/splitter/SplitBar.js +151 -134
- package/lib/splitter/Splitter.js +141 -89
- package/lib/splitter/hooks/sizeUtil.js +50 -33
- package/lib/splitter/hooks/useDragListeners.js +114 -0
- package/lib/splitter/hooks/useItems.js +27 -20
- package/lib/splitter/hooks/useOrientation.js +12 -0
- package/lib/splitter/hooks/useResizable.js +32 -30
- package/lib/splitter/hooks/useResize.js +76 -45
- package/lib/splitter/hooks/useSizes.js +55 -30
- package/lib/splitter/index.js +1 -1
- package/lib/splitter/style/index.less +349 -312
- package/lib/status-tag/index.js +131 -0
- package/lib/{statusTag → status-tag}/style/index.less +70 -70
- package/lib/{statusTag → status-tag}/style/mixin.less +48 -39
- package/lib/style/index.less +1 -1
- package/lib/style/themes/index.less +2 -2
- package/lib/style/themes/variable.less +5 -5
- package/lib/table/Column.js +13 -0
- package/lib/table/ColumnGroup.js +13 -0
- package/lib/table/InternalTable.js +699 -270
- package/lib/table/Table.js +14 -11
- package/lib/table/TableMeasureRowContext.js +1 -1
- package/lib/table/components/Body/BodyRow.js +192 -0
- package/lib/table/components/Body/ExpandedRow.js +61 -0
- package/lib/table/components/Body/MeasureCell.js +43 -0
- package/lib/table/components/Body/MeasureRow.js +64 -0
- package/lib/table/components/Body/index.js +133 -0
- package/lib/table/components/Cell/index.js +205 -0
- package/lib/table/components/Cell/useCellRender.js +78 -0
- package/lib/table/components/Cell/useHoverState.js +20 -0
- package/lib/table/components/ColGroup.js +62 -0
- package/lib/table/components/ExpandIcon.js +35 -0
- package/lib/table/components/FixedHolder/index.js +195 -0
- package/lib/table/components/Footer/Cell.js +57 -0
- package/lib/table/components/Footer/Row.js +19 -0
- package/lib/table/components/Footer/Summary.js +19 -0
- package/lib/table/components/Footer/SummaryContext.js +12 -0
- package/lib/table/components/Footer/index.js +41 -0
- package/lib/table/components/Header/Header.js +120 -0
- package/lib/table/components/Header/HeaderRow.js +72 -0
- package/lib/table/components/Panel.js +20 -0
- package/lib/table/components/RcTable.js +764 -0
- package/lib/table/components/VirtualTable.js +18 -0
- package/lib/table/components/VirtualTableBody/BodyGrid.js +316 -0
- package/lib/table/components/VirtualTableBody/BodyLine.js +125 -0
- package/lib/table/components/VirtualTableBody/VirtualCell.js +128 -0
- package/lib/table/components/VirtualTableBody/context.js +9 -0
- package/lib/table/components/VirtualTableBody/index.js +111 -0
- package/lib/table/constant.js +8 -0
- package/lib/table/features/columns/Column.js +10 -0
- package/lib/table/features/columns/ColumnGroup.js +10 -0
- package/lib/table/features/columns/index.js +57 -0
- package/lib/table/features/columns/useColumns.js +237 -0
- package/lib/table/features/columns/useFilledColumns.js +42 -0
- package/lib/table/features/columns/useTitleColumns.js +34 -0
- package/lib/table/features/columns/useWidthColumns.js +83 -0
- package/lib/table/features/editable/BatchEditModal.js +794 -0
- package/lib/table/features/editable/EditableCell.js +303 -0
- package/lib/table/features/editable/EditableContext.js +28 -0
- package/lib/table/features/editable/batchEditTypes.js +5 -0
- package/lib/table/features/editable/batchEditUtils.js +264 -0
- package/lib/table/features/editable/builtinEditors.js +174 -0
- package/lib/table/features/editable/index.js +75 -0
- package/lib/table/features/editable/useBatchRules.js +103 -0
- package/lib/table/features/editable/useEditable.js +701 -0
- package/lib/table/features/expand/expandUtil.js +57 -0
- package/lib/table/features/expand/index.js +32 -0
- package/lib/table/features/expand/useExpand.js +99 -0
- package/lib/table/features/filter/FilterDropdown.js +504 -0
- package/lib/table/features/filter/FilterSearch.js +34 -0
- package/lib/table/features/filter/FilterWrapper.js +32 -0
- package/lib/table/features/filter/index.js +49 -0
- package/lib/table/features/filter/useFilter.js +254 -0
- package/lib/table/features/fixed/fixUtil.js +75 -0
- package/lib/table/features/fixed/index.js +34 -0
- package/lib/table/features/fixed/offsetUtil.js +19 -0
- package/lib/table/features/fixed/useFixedInfo.js +26 -0
- package/lib/table/features/fixed/useStickyOffsets.js +35 -0
- package/lib/table/features/hover/index.js +13 -0
- package/lib/table/features/hover/useHover.js +31 -0
- package/lib/table/features/pagination/index.js +27 -0
- package/lib/table/features/pagination/usePagination.js +96 -0
- package/lib/table/features/resize/ResizeHandle.js +109 -0
- package/lib/table/features/resize/index.js +27 -0
- package/lib/table/features/resize/transformResizableColumns.js +61 -0
- package/lib/table/features/resize/useResize.js +595 -0
- package/lib/table/features/selection/index.js +39 -0
- package/lib/table/features/selection/useSelection.js +588 -0
- package/lib/table/features/sort/index.js +21 -0
- package/lib/table/features/sort/useSorter.js +381 -0
- package/lib/table/features/sticky/index.js +20 -0
- package/lib/table/features/sticky/stickyScrollBar.js +212 -0
- package/lib/table/features/sticky/useSticky.js +43 -0
- package/lib/table/features/summary/index.js +13 -0
- package/lib/table/features/virtual/index.js +26 -0
- package/lib/table/features/virtual/useFlattenRecords.js +64 -0
- package/lib/table/features/virtual/useFrame.js +74 -0
- package/lib/table/immutableHelper.js +46 -0
- package/lib/table/index.js +118 -3
- package/lib/table/interface.js +54 -2
- package/lib/table/shared/context/PerfContext.js +15 -0
- package/lib/table/shared/context/TableContext.js +13 -0
- package/lib/table/shared/hooks/useContainerWidth.js +20 -0
- package/lib/table/shared/hooks/useLazyKVMap.js +39 -0
- package/lib/table/shared/hooks/useRenderTimes.js +49 -0
- package/lib/table/shared/hooks/useRowInfo.js +80 -0
- package/lib/table/shared/utils/legacyUtil.js +38 -0
- package/lib/table/shared/utils/util.js +34 -0
- package/lib/table/shared/utils/valueUtil.js +37 -0
- package/lib/table/style/base.less +164 -0
- package/lib/table/style/bordered.less +83 -141
- package/lib/table/style/editable.less +50 -0
- package/lib/table/style/ellipsis.less +33 -0
- package/lib/table/style/empty.less +16 -0
- package/lib/table/style/expand.less +123 -0
- package/lib/table/style/filter.less +34 -0
- package/lib/table/style/fixed.less +85 -88
- package/lib/table/style/index.js +2 -1
- package/lib/table/style/index.less +19 -150
- package/lib/table/style/pagination.less +29 -0
- package/lib/table/style/radius.less +64 -0
- package/lib/table/style/resize.less +78 -0
- package/lib/table/style/rtl.less +52 -0
- package/lib/table/style/selection.less +63 -90
- package/lib/table/style/size.less +54 -0
- package/lib/table/style/sorter.less +99 -0
- package/lib/table/style/sticky.less +45 -55
- package/lib/table/style/summary.less +23 -0
- package/lib/table/style/variables.less +80 -0
- package/lib/table/style/virtual.less +95 -65
- package/package.json +148 -155
- package/esm/_util/extendsObject.d.ts +0 -4
- package/esm/_util/extendsObject.js +0 -17
- package/esm/_util/hooks/index.d.ts +0 -4
- package/esm/_util/hooks/index.js +0 -4
- package/esm/_util/hooks/useProxyImperativeHandle.d.ts +0 -4
- package/esm/_util/index.d.ts +0 -3
- package/esm/_util/isNonNullable.d.ts +0 -2
- package/esm/_util/isNonNullable.js +0 -4
- package/esm/blockHeader/index.d.ts +0 -58
- package/esm/flex/index.d.ts +0 -7
- package/esm/index.d.ts +0 -17
- package/esm/index.js +0 -14
- package/esm/overflowList/index.d.ts +0 -40
- package/esm/resizeObserver/index.d.ts +0 -45
- package/esm/splitter/index.d.ts +0 -8
- package/esm/splitter/interface.d.ts +0 -69
- package/esm/splitter/style/index.less +0 -312
- package/esm/style/mixins/index.less +0 -0
- package/esm/style/themes/index.less +0 -2
- package/esm/table/InternalTable.d.ts +0 -32
- package/esm/table/InternalTable.js +0 -429
- package/esm/table/RcTable/VirtualTable.d.ts +0 -2
- package/esm/table/RcTable/index.d.ts +0 -2
- package/esm/table/RcTable/index.js +0 -9
- package/esm/table/Table.d.ts +0 -17
- package/esm/table/index.d.ts +0 -7
- package/esm/table/index.js +0 -2
- package/esm/table/interface.d.ts +0 -196
- package/esm/table/interface.js +0 -4
- package/esm/table/style/bordered.less +0 -141
- package/esm/table/style/fixed.less +0 -88
- package/esm/table/style/index.d.ts +0 -2
- package/esm/table/style/index.js +0 -2
- package/esm/table/style/index.less +0 -150
- package/esm/table/style/selection.less +0 -90
- package/esm/table/style/sticky.less +0 -55
- package/esm/table/style/virtual.less +0 -65
- package/lib/_util/easings.d.ts +0 -1
- package/lib/_util/extendsObject.d.ts +0 -4
- package/lib/_util/extendsObject.js +0 -20
- package/lib/_util/gapSize.d.ts +0 -3
- package/lib/_util/getScroll.d.ts +0 -3
- package/lib/_util/hooks/index.d.ts +0 -4
- package/lib/_util/hooks/useForceUpdate.d.ts +0 -2
- package/lib/_util/hooks/useOrientation.d.ts +0 -2
- package/lib/_util/hooks/useProxyImperativeHandle.d.ts +0 -4
- package/lib/_util/hooks/useSyncState.d.ts +0 -3
- package/lib/_util/index.d.ts +0 -3
- package/lib/_util/isNonNullable.d.ts +0 -2
- package/lib/_util/isNonNullable.js +0 -10
- package/lib/_util/scrollTo.d.ts +0 -10
- package/lib/_util/type.d.ts +0 -52
- package/lib/_util/warning.d.ts +0 -31
- package/lib/blockHeader/index.js +0 -121
- package/lib/blockHeader/style/index.d.ts +0 -2
- package/lib/button/index.d.ts +0 -10
- package/lib/button/style/index.d.ts +0 -2
- package/lib/collapsible/index.d.ts +0 -102
- package/lib/collapsible/style/index.d.ts +0 -1
- package/lib/collapsibleActionItems/index.d.ts +0 -24
- package/lib/collapsibleActionItems/index.js +0 -68
- package/lib/collapsibleActionItems/style/index.d.ts +0 -2
- package/lib/flex/interface.d.ts +0 -16
- package/lib/flex/style/index.d.ts +0 -2
- package/lib/flex/utils.d.ts +0 -7
- package/lib/formList/index.d.ts +0 -78
- package/lib/formList/index.js +0 -130
- package/lib/formList/style/index.d.ts +0 -2
- package/lib/index.d.ts +0 -17
- package/lib/overflowList/index.js +0 -144
- package/lib/overflowList/style/index.d.ts +0 -2
- package/lib/resize/index.d.ts +0 -9
- package/lib/resizeObserver/index.js +0 -137
- package/lib/splitter/Panel.d.ts +0 -7
- package/lib/splitter/SplitBar.d.ts +0 -24
- package/lib/splitter/Splitter.d.ts +0 -5
- package/lib/splitter/hooks/sizeUtil.d.ts +0 -3
- package/lib/splitter/hooks/useItems.d.ts +0 -14
- package/lib/splitter/hooks/useResizable.d.ts +0 -10
- package/lib/splitter/hooks/useResize.d.ts +0 -6
- package/lib/splitter/hooks/useSizes.d.ts +0 -4
- package/lib/splitter/interface.d.ts +0 -69
- package/lib/splitter/style/index.d.ts +0 -2
- package/lib/statusTag/index.d.ts +0 -29
- package/lib/statusTag/index.js +0 -125
- package/lib/statusTag/style/index.d.ts +0 -2
- package/lib/style/index.d.ts +0 -1
- package/lib/style/mixins/index.less +0 -0
- package/lib/table/InternalTable.d.ts +0 -32
- package/lib/table/RcTable/VirtualTable.d.ts +0 -2
- package/lib/table/RcTable/VirtualTable.js +0 -17
- package/lib/table/RcTable/index.d.ts +0 -2
- package/lib/table/RcTable/index.js +0 -17
- package/lib/table/TableMeasureRowContext.d.ts +0 -3
- package/lib/table/hooks/useContainerWidth.d.ts +0 -1
- package/lib/table/hooks/useContainerWidth.js +0 -20
- package/lib/table/index.d.ts +0 -7
- package/lib/table/interface.d.ts +0 -196
- package/lib/table/style/index.d.ts +0 -2
- package/lib/table/util.d.ts +0 -14
- package/lib/table/util.js +0 -44
- /package/{esm → es}/_util/easings.d.ts +0 -0
- /package/{esm → es}/_util/easings.js +0 -0
- /package/{esm → es}/_util/gapSize.js +0 -0
- /package/{esm → es}/_util/getScroll.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useForceUpdate.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useForceUpdate.js +0 -0
- /package/{esm → es}/_util/hooks/useOrientation.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useOrientation.js +0 -0
- /package/{esm → es}/_util/hooks/useSyncState.d.ts +0 -0
- /package/{esm → es}/_util/hooks/useSyncState.js +0 -0
- /package/{esm → es}/_util/scrollTo.d.ts +0 -0
- /package/{esm → es}/_util/type.js +0 -0
- /package/{esm → es}/_util/warning.d.ts +0 -0
- /package/{esm/blockHeader → es/block-header}/style/index.d.ts +0 -0
- /package/{esm/blockHeader → es/block-header}/style/index.js +0 -0
- /package/{esm → es}/button/style/index.d.ts +0 -0
- /package/{esm → es}/button/style/index.js +0 -0
- /package/{esm → es}/collapsible/index.d.ts +0 -0
- /package/{esm → es}/collapsible/style/index.d.ts +0 -0
- /package/{esm → es}/collapsible/style/index.js +0 -0
- /package/{esm/collapsibleActionItems → es/collapsible-action-items}/style/index.d.ts +0 -0
- /package/{esm/collapsibleActionItems → es/collapsible-action-items}/style/index.js +0 -0
- /package/{esm → es}/flex/interface.d.ts +0 -0
- /package/{esm → es}/flex/interface.js +0 -0
- /package/{esm → es}/flex/style/index.d.ts +0 -0
- /package/{esm → es}/flex/style/index.js +0 -0
- /package/{esm → es}/flex/utils.d.ts +0 -0
- /package/{esm → es}/flex/utils.js +0 -0
- /package/{esm/formList → es/form-list}/style/index.d.ts +0 -0
- /package/{esm/formList → es/form-list}/style/index.js +0 -0
- /package/{esm/overflowList → es/overflow-list}/style/index.d.ts +0 -0
- /package/{esm/overflowList → es/overflow-list}/style/index.js +0 -0
- /package/{esm → es}/resize/index.d.ts +0 -0
- /package/{esm → es}/resize/index.js +0 -0
- /package/{esm → es}/splitter/Splitter.d.ts +0 -0
- /package/{esm → es}/splitter/hooks/sizeUtil.d.ts +0 -0
- /package/{esm → es}/splitter/hooks/useItems.js +0 -0
- /package/{esm → es}/splitter/hooks/useSizes.d.ts +0 -0
- /package/{esm → es}/splitter/index.js +0 -0
- /package/{esm → es}/splitter/interface.js +0 -0
- /package/{esm → es}/splitter/style/index.d.ts +0 -0
- /package/{esm → es}/splitter/style/index.js +0 -0
- /package/{esm/statusTag → es/status-tag}/index.d.ts +0 -0
- /package/{esm/statusTag → es/status-tag}/style/index.d.ts +0 -0
- /package/{esm/statusTag → es/status-tag}/style/index.js +0 -0
- /package/{esm → es}/style/index.d.ts +0 -0
- /package/{esm → es}/style/index.js +0 -0
- /package/{esm → es}/table/TableMeasureRowContext.d.ts +0 -0
- /package/{esm → es}/table/TableMeasureRowContext.js +0 -0
- /package/{esm/table → es/table/shared}/hooks/useContainerWidth.d.ts +0 -0
- /package/{esm/table → es/table/shared}/hooks/useContainerWidth.js +0 -0
- /package/lib/{blockHeader → block-header}/style/index.js +0 -0
- /package/lib/{collapsibleActionItems → collapsible-action-items}/style/index.js +0 -0
- /package/lib/{formList → form-list}/style/index.js +0 -0
- /package/lib/{overflowList → overflow-list}/style/index.js +0 -0
- /package/lib/{statusTag → status-tag}/style/index.js +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { EditableConfig } from '../../interface';
|
|
3
|
+
import type { AnyObject } from '../../../_util/type';
|
|
4
|
+
export interface EditableCellProps {
|
|
5
|
+
dataIndex: string | number;
|
|
6
|
+
title?: React.ReactNode;
|
|
7
|
+
/** 本行 record 的 rowKey — 排序/筛选/树形展开后唯一定位该行;缺失时降级为 rowIndex */
|
|
8
|
+
rowKey?: React.Key;
|
|
9
|
+
rowIndex: number;
|
|
10
|
+
record: AnyObject;
|
|
11
|
+
value: unknown;
|
|
12
|
+
editableConfig: EditableConfig;
|
|
13
|
+
prefixCls: string;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 可编辑单元格
|
|
18
|
+
*
|
|
19
|
+
* 核心设计:
|
|
20
|
+
*
|
|
21
|
+
* 1. **本地状态**(连续型编辑器 Input/Textarea/Number)
|
|
22
|
+
* 输入时只更新本地 state,不触发父组件重渲染。
|
|
23
|
+
*
|
|
24
|
+
* 2. **本地同步校验**
|
|
25
|
+
* 校验在单元格内部同步执行,不经过 context setErrors。
|
|
26
|
+
*
|
|
27
|
+
* 3. **dirty 追踪**
|
|
28
|
+
* 只有用户修改过的单元格才显示校验错误。
|
|
29
|
+
*
|
|
30
|
+
* 4. **blur 提交**
|
|
31
|
+
* 连续型编辑器在失焦时将本地值提交到父组件。
|
|
32
|
+
*
|
|
33
|
+
* 5. **Popover 可见性控制**
|
|
34
|
+
* 始终渲染 Popover 保持 DOM 结构稳定(避免 input 被重建)。
|
|
35
|
+
* open = hasError && (focused || hovered) — 初始无错误时不渲染 tooltip 内容。
|
|
36
|
+
* 关闭动画:lastMessagesRef 缓存最后一次有错误的消息。
|
|
37
|
+
*
|
|
38
|
+
* 6. **Popover 挂载到表格容器**
|
|
39
|
+
* getPopupContainer 返回表格滚动容器,确保 Popover 随表格滚动。
|
|
40
|
+
*/
|
|
41
|
+
declare const EditableCellInner: React.NamedExoticComponent<EditableCellProps>;
|
|
42
|
+
export default EditableCellInner;
|
|
@@ -0,0 +1,294 @@
|
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; } } }; }
|
|
7
|
+
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); } }
|
|
8
|
+
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); }); }; }
|
|
9
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; } }
|
|
14
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
+
import * as React from 'react';
|
|
16
|
+
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
|
17
|
+
import { Popover } from 'antd';
|
|
18
|
+
import { clsx } from 'clsx';
|
|
19
|
+
import EditableContext from "./EditableContext";
|
|
20
|
+
import { renderBuiltinEditor } from "./builtinEditors";
|
|
21
|
+
/**
|
|
22
|
+
* 可编辑单元格
|
|
23
|
+
*
|
|
24
|
+
* 核心设计:
|
|
25
|
+
*
|
|
26
|
+
* 1. **本地状态**(连续型编辑器 Input/Textarea/Number)
|
|
27
|
+
* 输入时只更新本地 state,不触发父组件重渲染。
|
|
28
|
+
*
|
|
29
|
+
* 2. **本地同步校验**
|
|
30
|
+
* 校验在单元格内部同步执行,不经过 context setErrors。
|
|
31
|
+
*
|
|
32
|
+
* 3. **dirty 追踪**
|
|
33
|
+
* 只有用户修改过的单元格才显示校验错误。
|
|
34
|
+
*
|
|
35
|
+
* 4. **blur 提交**
|
|
36
|
+
* 连续型编辑器在失焦时将本地值提交到父组件。
|
|
37
|
+
*
|
|
38
|
+
* 5. **Popover 可见性控制**
|
|
39
|
+
* 始终渲染 Popover 保持 DOM 结构稳定(避免 input 被重建)。
|
|
40
|
+
* open = hasError && (focused || hovered) — 初始无错误时不渲染 tooltip 内容。
|
|
41
|
+
* 关闭动画:lastMessagesRef 缓存最后一次有错误的消息。
|
|
42
|
+
*
|
|
43
|
+
* 6. **Popover 挂载到表格容器**
|
|
44
|
+
* getPopupContainer 返回表格滚动容器,确保 Popover 随表格滚动。
|
|
45
|
+
*/
|
|
46
|
+
var EditableCellInner = /*#__PURE__*/React.memo(function (_ref) {
|
|
47
|
+
var _editCtx$errors$get;
|
|
48
|
+
var dataIndex = _ref.dataIndex,
|
|
49
|
+
title = _ref.title,
|
|
50
|
+
rowKey = _ref.rowKey,
|
|
51
|
+
rowIndex = _ref.rowIndex,
|
|
52
|
+
record = _ref.record,
|
|
53
|
+
value = _ref.value,
|
|
54
|
+
editableConfig = _ref.editableConfig,
|
|
55
|
+
prefixCls = _ref.prefixCls;
|
|
56
|
+
var editCtx = React.useContext(EditableContext);
|
|
57
|
+
|
|
58
|
+
// ---- 连续型 vs 离散型 ----
|
|
59
|
+
var isContinuous = !editableConfig.renderEditor && (editableConfig.type === 'input' || editableConfig.type === 'textarea' || editableConfig.type === 'number' || !editableConfig.type);
|
|
60
|
+
|
|
61
|
+
// ---- 本地状态 ----
|
|
62
|
+
var _React$useState = React.useState(value),
|
|
63
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
64
|
+
localValue = _React$useState2[0],
|
|
65
|
+
setLocalValue = _React$useState2[1];
|
|
66
|
+
var _React$useState3 = React.useState([]),
|
|
67
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
68
|
+
localErrors = _React$useState4[0],
|
|
69
|
+
setLocalErrors = _React$useState4[1];
|
|
70
|
+
|
|
71
|
+
// ---- dirty / 编辑状态追踪 ----
|
|
72
|
+
var isDirtyRef = React.useRef(false);
|
|
73
|
+
var committedValueRef = React.useRef(value);
|
|
74
|
+
var blurHandledRef = React.useRef(false);
|
|
75
|
+
var validateSeqRef = React.useRef(0);
|
|
76
|
+
|
|
77
|
+
// ---- focus / hover 状态 ----
|
|
78
|
+
var _React$useState5 = React.useState(false),
|
|
79
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
80
|
+
focused = _React$useState6[0],
|
|
81
|
+
setFocused = _React$useState6[1];
|
|
82
|
+
|
|
83
|
+
// ---- 外部值变更时同步本地状态 ----
|
|
84
|
+
React.useEffect(function () {
|
|
85
|
+
if (value !== committedValueRef.current) {
|
|
86
|
+
setLocalValue(value);
|
|
87
|
+
committedValueRef.current = value;
|
|
88
|
+
isDirtyRef.current = false;
|
|
89
|
+
setLocalErrors([]);
|
|
90
|
+
}
|
|
91
|
+
}, [value]);
|
|
92
|
+
|
|
93
|
+
// ---- 错误查找(rowKey 定位,与 useEditable 写入侧一致;无 key 降级 rowIndex)----
|
|
94
|
+
var errorKey = "".concat(rowKey !== null && rowKey !== void 0 ? rowKey : rowIndex, "-").concat(dataIndex);
|
|
95
|
+
var globalErrors = (_editCtx$errors$get = editCtx === null || editCtx === void 0 ? void 0 : editCtx.errors.get(errorKey)) !== null && _editCtx$errors$get !== void 0 ? _editCtx$errors$get : [];
|
|
96
|
+
var effectiveErrors = isDirtyRef.current ? localErrors : globalErrors;
|
|
97
|
+
var hasError = effectiveErrors.length > 0;
|
|
98
|
+
|
|
99
|
+
// ---- Popover 退出动画:缓存最后一次有错误的消息 ----
|
|
100
|
+
var lastMessagesRef = React.useRef([]);
|
|
101
|
+
if (hasError) {
|
|
102
|
+
lastMessagesRef.current = effectiveErrors;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ---- 本地同步校验 ----
|
|
106
|
+
var validateLocal = React.useCallback( /*#__PURE__*/function () {
|
|
107
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(val) {
|
|
108
|
+
var rules, seq, messages, _iterator, _step, rule, isEmpty, msg;
|
|
109
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
110
|
+
while (1) switch (_context.prev = _context.next) {
|
|
111
|
+
case 0:
|
|
112
|
+
rules = editableConfig.rules;
|
|
113
|
+
if (rules) {
|
|
114
|
+
_context.next = 4;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
setLocalErrors([]);
|
|
118
|
+
return _context.abrupt("return");
|
|
119
|
+
case 4:
|
|
120
|
+
seq = ++validateSeqRef.current;
|
|
121
|
+
messages = [];
|
|
122
|
+
_iterator = _createForOfIteratorHelper(rules);
|
|
123
|
+
_context.prev = 7;
|
|
124
|
+
_iterator.s();
|
|
125
|
+
case 9:
|
|
126
|
+
if ((_step = _iterator.n()).done) {
|
|
127
|
+
_context.next = 27;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
rule = _step.value;
|
|
131
|
+
if (!rule.required) {
|
|
132
|
+
_context.next = 16;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
isEmpty = val === undefined || val === null || val === '' || Array.isArray(val) && val.length === 0;
|
|
136
|
+
if (!isEmpty) {
|
|
137
|
+
_context.next = 16;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
messages.push(rule.message || "".concat(title || dataIndex, " \u5FC5\u586B"));
|
|
141
|
+
return _context.abrupt("continue", 25);
|
|
142
|
+
case 16:
|
|
143
|
+
if (!(rule.pattern && val != null && val !== '')) {
|
|
144
|
+
_context.next = 20;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (rule.pattern.test(String(val))) {
|
|
148
|
+
_context.next = 20;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
messages.push(rule.message || "".concat(title || dataIndex, " \u683C\u5F0F\u4E0D\u6B63\u786E"));
|
|
152
|
+
return _context.abrupt("continue", 25);
|
|
153
|
+
case 20:
|
|
154
|
+
if (!rule.validator) {
|
|
155
|
+
_context.next = 25;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
_context.next = 23;
|
|
159
|
+
return rule.validator(val, record);
|
|
160
|
+
case 23:
|
|
161
|
+
msg = _context.sent;
|
|
162
|
+
if (msg) messages.push(msg);
|
|
163
|
+
case 25:
|
|
164
|
+
_context.next = 9;
|
|
165
|
+
break;
|
|
166
|
+
case 27:
|
|
167
|
+
_context.next = 32;
|
|
168
|
+
break;
|
|
169
|
+
case 29:
|
|
170
|
+
_context.prev = 29;
|
|
171
|
+
_context.t0 = _context["catch"](7);
|
|
172
|
+
_iterator.e(_context.t0);
|
|
173
|
+
case 32:
|
|
174
|
+
_context.prev = 32;
|
|
175
|
+
_iterator.f();
|
|
176
|
+
return _context.finish(32);
|
|
177
|
+
case 35:
|
|
178
|
+
if (seq === validateSeqRef.current) {
|
|
179
|
+
setLocalErrors(messages);
|
|
180
|
+
}
|
|
181
|
+
case 36:
|
|
182
|
+
case "end":
|
|
183
|
+
return _context.stop();
|
|
184
|
+
}
|
|
185
|
+
}, _callee, null, [[7, 29, 32, 35]]);
|
|
186
|
+
}));
|
|
187
|
+
return function (_x) {
|
|
188
|
+
return _ref2.apply(this, arguments);
|
|
189
|
+
};
|
|
190
|
+
}(), [editableConfig, title, dataIndex, record]);
|
|
191
|
+
|
|
192
|
+
// ---- 提交到父组件 ----
|
|
193
|
+
var commitToParent = React.useCallback(function (val) {
|
|
194
|
+
editCtx === null || editCtx === void 0 || editCtx.onCellChange(rowKey, dataIndex, val, record, rowIndex);
|
|
195
|
+
}, [editCtx, rowKey, dataIndex, record, rowIndex]);
|
|
196
|
+
|
|
197
|
+
// ---- change 处理 ----
|
|
198
|
+
var handleChange = React.useCallback(function (nextValue) {
|
|
199
|
+
isDirtyRef.current = true;
|
|
200
|
+
blurHandledRef.current = false;
|
|
201
|
+
if (isContinuous) {
|
|
202
|
+
setLocalValue(nextValue);
|
|
203
|
+
validateLocal(nextValue);
|
|
204
|
+
} else {
|
|
205
|
+
committedValueRef.current = nextValue;
|
|
206
|
+
setLocalValue(nextValue);
|
|
207
|
+
validateLocal(nextValue);
|
|
208
|
+
commitToParent(nextValue);
|
|
209
|
+
}
|
|
210
|
+
}, [isContinuous, validateLocal, commitToParent]);
|
|
211
|
+
var handleFocus = React.useCallback(function () {
|
|
212
|
+
blurHandledRef.current = false;
|
|
213
|
+
setFocused(true);
|
|
214
|
+
}, []);
|
|
215
|
+
var handleBlur = React.useCallback(function () {
|
|
216
|
+
if (blurHandledRef.current) return;
|
|
217
|
+
blurHandledRef.current = true;
|
|
218
|
+
setFocused(false);
|
|
219
|
+
if (isContinuous) {
|
|
220
|
+
committedValueRef.current = localValue;
|
|
221
|
+
commitToParent(localValue);
|
|
222
|
+
}
|
|
223
|
+
var saveValue = isContinuous ? localValue : value;
|
|
224
|
+
if (saveValue !== undefined) {
|
|
225
|
+
var _editableConfig$onSav;
|
|
226
|
+
(_editableConfig$onSav = editableConfig.onSave) === null || _editableConfig$onSav === void 0 || _editableConfig$onSav.call(editableConfig, saveValue, record, rowIndex);
|
|
227
|
+
}
|
|
228
|
+
}, [isContinuous, localValue, value, commitToParent, editableConfig, record, rowIndex]);
|
|
229
|
+
|
|
230
|
+
// ---- placeholder ----
|
|
231
|
+
var titleStr = typeof title === 'string' ? title : '';
|
|
232
|
+
var placeholder = editableConfig.type === 'select' ? "\u8BF7\u9009\u62E9".concat(titleStr) : editableConfig.type === 'switch' ? undefined : "\u8BF7\u8F93\u5165".concat(titleStr);
|
|
233
|
+
|
|
234
|
+
// ---- 渲染编辑器 ----
|
|
235
|
+
var editorValue = isContinuous ? localValue : value;
|
|
236
|
+
var renderEditor = function renderEditor() {
|
|
237
|
+
if (editableConfig.renderEditor) {
|
|
238
|
+
return editableConfig.renderEditor(editorValue, record, rowIndex, handleChange);
|
|
239
|
+
}
|
|
240
|
+
return renderBuiltinEditor({
|
|
241
|
+
value: editorValue,
|
|
242
|
+
onChange: handleChange,
|
|
243
|
+
onFocus: handleFocus,
|
|
244
|
+
onBlur: handleBlur,
|
|
245
|
+
status: hasError ? 'error' : '',
|
|
246
|
+
placeholder: placeholder,
|
|
247
|
+
config: editableConfig
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// ---- Popover 容器:挂载到表格滚动容器 ----
|
|
252
|
+
var getPopupContainer = React.useCallback(function (triggerNode) {
|
|
253
|
+
var el = triggerNode.parentNode || triggerNode.closest(".".concat(prefixCls, "-body")) || triggerNode.closest(".".concat(prefixCls, "-content")) || triggerNode.closest(".".concat(prefixCls, "-container"));
|
|
254
|
+
return el || document.body;
|
|
255
|
+
}, [prefixCls]);
|
|
256
|
+
|
|
257
|
+
// ---- Popover 显示条件 ----
|
|
258
|
+
var popoverOpen = hasError && focused;
|
|
259
|
+
|
|
260
|
+
// ---- 错误内容 ----
|
|
261
|
+
var errorContent = /*#__PURE__*/React.createElement("div", {
|
|
262
|
+
className: "".concat(prefixCls, "-editable-error-content")
|
|
263
|
+
}, lastMessagesRef.current.map(function (msg) {
|
|
264
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
key: msg,
|
|
266
|
+
className: "".concat(prefixCls, "-editable-error-item")
|
|
267
|
+
}, /*#__PURE__*/React.createElement(ExclamationCircleOutlined, {
|
|
268
|
+
style: {
|
|
269
|
+
color: '#ff4d4f',
|
|
270
|
+
fontSize: 14,
|
|
271
|
+
marginRight: 6
|
|
272
|
+
}
|
|
273
|
+
}), /*#__PURE__*/React.createElement("span", null, msg));
|
|
274
|
+
}));
|
|
275
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
276
|
+
open: popoverOpen,
|
|
277
|
+
content: errorContent,
|
|
278
|
+
placement: "topLeft",
|
|
279
|
+
getPopupContainer: getPopupContainer,
|
|
280
|
+
overlayClassName: "".concat(prefixCls, "-editable-error-popover")
|
|
281
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
282
|
+
className: clsx("".concat(prefixCls, "-editable-cell"), _defineProperty({}, "".concat(prefixCls, "-editable-cell-error"), hasError)),
|
|
283
|
+
onFocusCapture: handleFocus,
|
|
284
|
+
onBlurCapture: function onBlurCapture(e) {
|
|
285
|
+
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
286
|
+
handleBlur();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}, renderEditor()));
|
|
290
|
+
}, function (prevProps, nextProps) {
|
|
291
|
+
return prevProps.record === nextProps.record && prevProps.value === nextProps.value && prevProps.dataIndex === nextProps.dataIndex && prevProps.rowKey === nextProps.rowKey && prevProps.rowIndex === nextProps.rowIndex && prevProps.prefixCls === nextProps.prefixCls && prevProps.editableConfig === nextProps.editableConfig;
|
|
292
|
+
});
|
|
293
|
+
EditableCellInner.displayName = 'EditableCell';
|
|
294
|
+
export default EditableCellInner;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AnyObject } from '../../../_util/type';
|
|
3
|
+
/**
|
|
4
|
+
* EditableContext 的类型定义。
|
|
5
|
+
*
|
|
6
|
+
* 独立于 useEditable.ts,避免循环依赖:
|
|
7
|
+
* index.ts → EditableCell.tsx → EditableContext.ts → useEditable.ts
|
|
8
|
+
* index.ts → useEditable.ts (barrel re-export)
|
|
9
|
+
*
|
|
10
|
+
* 当 webpack 处理 barrel export 时,上述循环会导致 useEditable.ts
|
|
11
|
+
* 在尚未完成模块初始化时被 EditableContext.ts 引用,拿到空对象。
|
|
12
|
+
*
|
|
13
|
+
* 类型策略:
|
|
14
|
+
* - cell value 使用 `any`:单元格值可能是 string / number / boolean / array 等任意类型,
|
|
15
|
+
* 使用 `unknown` 会迫使所有编辑器内部都做类型断言,降低可用性。
|
|
16
|
+
* - record 使用 `AnyObject`:行数据始终是对象。
|
|
17
|
+
*/
|
|
18
|
+
export interface EditableContextValue {
|
|
19
|
+
/** 错误 Map: key = `${rowKey}-${dataIndex}`(无 key 时降级为 `${rowIndex}-${dataIndex}`) */
|
|
20
|
+
errors: Map<string, string[]>;
|
|
21
|
+
/** 校验单个单元格 */
|
|
22
|
+
validateCell: (rowKey: React.Key | undefined, dataIndex: string | number, value: any, record: AnyObject, rowIndex?: number) => void;
|
|
23
|
+
/** 校验全部数据 */
|
|
24
|
+
validateAll: (data: AnyObject[]) => void;
|
|
25
|
+
/** 重置所有错误 */
|
|
26
|
+
resetErrors: () => void;
|
|
27
|
+
/** 更新单元格值 */
|
|
28
|
+
onCellChange: (rowKey: React.Key | undefined, dataIndex: string | number, value: any, record: AnyObject, rowIndex: number) => void;
|
|
29
|
+
/** 滚动到错误行 */
|
|
30
|
+
scrollToError: (rowKey: React.Key, rowIndex?: number) => void;
|
|
31
|
+
}
|
|
32
|
+
declare const EditableContext: React.Context<EditableContextValue | null>;
|
|
33
|
+
export default EditableContext;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* EditableContext 的类型定义。
|
|
5
|
+
*
|
|
6
|
+
* 独立于 useEditable.ts,避免循环依赖:
|
|
7
|
+
* index.ts → EditableCell.tsx → EditableContext.ts → useEditable.ts
|
|
8
|
+
* index.ts → useEditable.ts (barrel re-export)
|
|
9
|
+
*
|
|
10
|
+
* 当 webpack 处理 barrel export 时,上述循环会导致 useEditable.ts
|
|
11
|
+
* 在尚未完成模块初始化时被 EditableContext.ts 引用,拿到空对象。
|
|
12
|
+
*
|
|
13
|
+
* 类型策略:
|
|
14
|
+
* - cell value 使用 `any`:单元格值可能是 string / number / boolean / array 等任意类型,
|
|
15
|
+
* 使用 `unknown` 会迫使所有编辑器内部都做类型断言,降低可用性。
|
|
16
|
+
* - record 使用 `AnyObject`:行数据始终是对象。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
var EditableContext = /*#__PURE__*/React.createContext(null);
|
|
20
|
+
export default EditableContext;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ColumnsType } from '../../interface';
|
|
2
|
+
import type { AnyObject } from '../../../_util/type';
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
/** 批量编辑模式 */
|
|
5
|
+
export type BatchEditMode = 'overwrite' | 'fillEmpty';
|
|
6
|
+
/** 批量规则类型 */
|
|
7
|
+
export type BatchRuleType = 'value' | 'replace' | 'sequence';
|
|
8
|
+
/** 查找替换的匹配方式 */
|
|
9
|
+
export type ReplaceMatchMode = 'exact' | 'contains';
|
|
10
|
+
/** 规则基础 */
|
|
11
|
+
export interface BatchRuleBase {
|
|
12
|
+
id: string;
|
|
13
|
+
fieldKey: string;
|
|
14
|
+
type: BatchRuleType;
|
|
15
|
+
}
|
|
16
|
+
/** 固定值填充规则 */
|
|
17
|
+
export interface ValueBatchRule extends BatchRuleBase {
|
|
18
|
+
type: 'value';
|
|
19
|
+
value: unknown;
|
|
20
|
+
mode: BatchEditMode;
|
|
21
|
+
}
|
|
22
|
+
/** 查找替换规则 */
|
|
23
|
+
export interface ReplaceBatchRule extends BatchRuleBase {
|
|
24
|
+
type: 'replace';
|
|
25
|
+
oldValue: unknown;
|
|
26
|
+
newValue: unknown;
|
|
27
|
+
matchMode: ReplaceMatchMode;
|
|
28
|
+
}
|
|
29
|
+
/** 序列生成规则 */
|
|
30
|
+
export interface SequenceBatchRule extends BatchRuleBase {
|
|
31
|
+
type: 'sequence';
|
|
32
|
+
prefix: string;
|
|
33
|
+
start: number;
|
|
34
|
+
step: number;
|
|
35
|
+
digitWidth?: number;
|
|
36
|
+
}
|
|
37
|
+
/** 批量规则联合类型 */
|
|
38
|
+
export type BatchRule = ValueBatchRule | ReplaceBatchRule | SequenceBatchRule;
|
|
39
|
+
/** BatchEditModal 属性 */
|
|
40
|
+
export interface BatchEditModalProps {
|
|
41
|
+
/** 是否打开 */
|
|
42
|
+
open: boolean;
|
|
43
|
+
/** 列配置 */
|
|
44
|
+
columns: ColumnsType;
|
|
45
|
+
/** 选中行的 key 集合 */
|
|
46
|
+
selectedRowKeys: React.Key[];
|
|
47
|
+
/** 完整数据 */
|
|
48
|
+
data: AnyObject[];
|
|
49
|
+
/** 获取行 key 的函数 */
|
|
50
|
+
getRowKey: (record: AnyObject, index: number) => React.Key;
|
|
51
|
+
/** 取消 */
|
|
52
|
+
onCancel: () => void;
|
|
53
|
+
/** 确认应用 — 返回更新后的数据 */
|
|
54
|
+
onApply: (newData: AnyObject[]) => void;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ColumnsType, ColumnType } from '../../interface';
|
|
2
|
+
import type { AnyObject } from '../../../_util/type';
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
import type { BatchRule, BatchRuleType } from './batchEditTypes';
|
|
5
|
+
/** 叶子列类型 */
|
|
6
|
+
type LeafColumn = ColumnType<AnyObject>;
|
|
7
|
+
/** 规则类型标签映射 */
|
|
8
|
+
export declare const typeLabelMap: Record<BatchRuleType, string>;
|
|
9
|
+
/**
|
|
10
|
+
* 扁平化列(处理列组 children)
|
|
11
|
+
*/
|
|
12
|
+
export declare const flattenColumns: (cols: ColumnsType) => LeafColumn[];
|
|
13
|
+
/** 生成唯一规则 ID */
|
|
14
|
+
export declare const createRuleId: () => string;
|
|
15
|
+
/** 创建空规则 */
|
|
16
|
+
export declare const createEmptyRule: (columns: ColumnsType) => BatchRule;
|
|
17
|
+
/**
|
|
18
|
+
* 应用批量编辑规则到数据
|
|
19
|
+
*
|
|
20
|
+
* @param rows 完整数据数组
|
|
21
|
+
* @param selectedRowKeys 选中的行 key 集合
|
|
22
|
+
* @param getRowKey 行 key 获取函数
|
|
23
|
+
* @param columns 列配置
|
|
24
|
+
* @param rules 批量编辑规则数组(按顺序执行)
|
|
25
|
+
* @returns 更新后的数据数组
|
|
26
|
+
*/
|
|
27
|
+
export declare const applyBatchRules: <T extends AnyObject>(rows: T[], selectedRowKeys: React.Key[], getRowKey: (record: T, index: number) => React.Key, columns: ColumnsType, rules: BatchRule[]) => T[];
|
|
28
|
+
/**
|
|
29
|
+
* 字段切换时规范化规则
|
|
30
|
+
*/
|
|
31
|
+
export declare const normalizeRuleOnFieldChange: (rule: BatchRule, nextFieldKey: string, columns: ColumnsType) => BatchRule;
|
|
32
|
+
/**
|
|
33
|
+
* 规则类型切换时重置规则
|
|
34
|
+
*/
|
|
35
|
+
export declare const resetRuleByType: (rule: BatchRule, nextType: BatchRuleType) => BatchRule;
|
|
36
|
+
/**
|
|
37
|
+
* 获取可批量编辑的列(有 dataIndex 且可编辑的列)
|
|
38
|
+
*/
|
|
39
|
+
export declare const getBatchEditableColumns: (columns: ColumnsType) => LeafColumn[];
|
|
40
|
+
/**
|
|
41
|
+
* 判断字段是否支持序列生成
|
|
42
|
+
*/
|
|
43
|
+
export declare const isSequenceSupported: (columns: ColumnsType, fieldKey: string) => boolean;
|
|
44
|
+
export {};
|