@gx-design-vue/pro-table 0.2.0-alpha.20 → 0.2.0-alpha.22

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.
Files changed (44) hide show
  1. package/dist/ProTable.js +61 -2
  2. package/dist/components/Drag/Handle.d.ts +90 -0
  3. package/dist/components/Drag/Handle.js +64 -0
  4. package/dist/components/Drag/Tbody.d.ts +17 -0
  5. package/dist/components/Drag/Tbody.js +27 -0
  6. package/dist/components/EllipsisText/index.d.ts +50 -0
  7. package/dist/components/EllipsisText/index.js +65 -0
  8. package/dist/components/ScrollBar/Bar.d.ts +1 -1
  9. package/dist/components/SearchForm/FormItemContainer.d.ts +1 -1
  10. package/dist/components/SearchForm/FormItemWrapper.d.ts +1 -1
  11. package/dist/components/SearchForm/SearchForm.d.ts +1 -1
  12. package/dist/components/Toolbar/ListToolBar.d.ts +3 -3
  13. package/dist/components/Toolbar/index.d.ts +3 -3
  14. package/dist/hooks/index.d.ts +4 -1
  15. package/dist/hooks/index.js +4 -1
  16. package/dist/hooks/useAutoScroll.d.ts +32 -0
  17. package/dist/hooks/useAutoScroll.js +127 -0
  18. package/dist/hooks/useBreakpoints.js +1 -0
  19. package/dist/hooks/useCellRender.js +14 -2
  20. package/dist/hooks/useColumnResize.js +2 -0
  21. package/dist/hooks/useDragHandleColumn.d.ts +26 -0
  22. package/dist/hooks/useDragHandleColumn.js +52 -0
  23. package/dist/hooks/useEllipsis.d.ts +20 -0
  24. package/dist/hooks/useEllipsis.js +51 -0
  25. package/dist/hooks/useRowDrag.d.ts +42 -0
  26. package/dist/hooks/useRowDrag.js +268 -0
  27. package/dist/index.d.ts +3 -2
  28. package/dist/index.js +2 -1
  29. package/dist/interface.d.ts +49 -10
  30. package/dist/pro-table.esm.js +6157 -613
  31. package/dist/pro-table.js +4 -1
  32. package/dist/style/ellipsis.d.ts +13 -0
  33. package/dist/style/ellipsis.js +16 -0
  34. package/dist/style/index.js +4 -0
  35. package/dist/style/row-drag.d.ts +8 -0
  36. package/dist/style/row-drag.js +44 -0
  37. package/dist/utils/arrayMove.d.ts +9 -0
  38. package/dist/utils/arrayMove.js +15 -0
  39. package/dist/utils/ellipsis.d.ts +19 -0
  40. package/dist/utils/ellipsis.js +30 -0
  41. package/dist/utils/flipAnimate.d.ts +25 -0
  42. package/dist/utils/flipAnimate.js +40 -0
  43. package/dist/utils/formConstants.js +3 -3
  44. package/package.json +15 -13
package/dist/index.js CHANGED
@@ -3,8 +3,9 @@ import { useRequestOptions } from "./hooks/useRequestOptions.js";
3
3
  import { useInjectTableContext } from "./context/TableContext.js";
4
4
  import { useFetchData } from "./hooks/useFetchData.js";
5
5
  import { usePagination } from "./hooks/usePagination.js";
6
+ import { arrayMove } from "./utils/arrayMove.js";
6
7
  import { useTable } from "./hooks/useTable.js";
7
8
  import { useTableForm } from "./hooks/useTableForm.js";
8
9
  import "./hooks/index.js";
9
10
  import ForwardProTable from "./ProTable.js";
10
- export { ForwardProTable as GProTable, useFetchData, useInjectTableContext, usePagination, useProBreakpoints, useRequestOptions, useTable, useTableForm };
11
+ export { ForwardProTable as GProTable, arrayMove, useFetchData, useInjectTableContext, usePagination, useProBreakpoints, useRequestOptions, useTable, useTableForm };
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ComputedRef, Ref } from "vue";
1
+ import { ComputedRef, Ref } from "vue";
2
2
  import { AlignType, Breakpoint, CustomRender, RecordType, SemanticClassNames, SemanticStyles, WithFalse } from "@gx-design-vue/pro-utils";
3
3
  import { SpinProps, TableEmits, TableProps, TableSlots, TooltipProps } from "antdv-next";
4
4
  import { ColumnType, FilterValue, SorterResult, TableCurrentDataSource, TablePaginationConfig } from "antdv-next/dist/table/interface";
@@ -22,7 +22,8 @@ interface ToolbarOptionConfig {
22
22
  reload?: boolean | ((onClick: () => void) => CustomRender);
23
23
  fullScreen?: boolean | (() => Promise<void>);
24
24
  }
25
- type ColConfig = Partial<Record<Breakpoint, number>>;
25
+ /** 支持纯数字(如 2 表示所有断点统一列数)或按断点配置(如 { xl: 4, lg: 3 }) */
26
+ type ColConfig = number | Partial<Record<Breakpoint, number>>;
26
27
  interface FormConfig {
27
28
  className?: string;
28
29
  /**
@@ -282,6 +283,30 @@ interface ProTableIndexColumn {
282
283
  align?: AlignType;
283
284
  fixed?: DefaultProColumn['fixed'];
284
285
  }
286
+ /** 行拖拽把手列配置 */
287
+ interface ProTableRowDragOptions {
288
+ /** 把手列宽度,默认 40 */
289
+ width?: number;
290
+ /** 把手列对齐方式,默认 'center' */
291
+ align?: AlignType;
292
+ /** 把手列 fixed 位置,默认 'start' */
293
+ fixed?: 'start' | 'end';
294
+ /** 自定义把手渲染(默认 HolderOutlined 图标) */
295
+ handleRender?: (record: any, index: number) => CustomRender;
296
+ /** 是否禁用某行拖拽,返回 true 则该行不可拖动 */
297
+ disabled?: (record: any) => boolean;
298
+ }
299
+ /** 行拖拽排序结束事件 */
300
+ interface ProTableRowSortEndEvent<DataRecord = RecordType> {
301
+ /** 原索引 */
302
+ from: number;
303
+ /** 新索引 */
304
+ to: number;
305
+ /** 重排后的完整数据 */
306
+ data: DataRecord[];
307
+ /** 被拖拽的记录 */
308
+ record: DataRecord;
309
+ }
285
310
  interface ProTableScrollPolicy {
286
311
  mode?: 'auto' | 'manual' | 'disabled';
287
312
  breakpoint?: Breakpoint | number;
@@ -292,16 +317,25 @@ interface ProTableScrollPolicy {
292
317
  };
293
318
  actionFixed?: boolean | 'auto';
294
319
  }
295
- type ProColumnType<DataValue = RecordType, SearchParams = RecordType> = ProColumn<Omit<ColumnType<DataValue>, keyof DefaultProColumnWithKeyOrDataIndex> & {
320
+ /** 列文本溢出(省略)配置 */
321
+ interface ProColumnEllipsis {
322
+ /** 省略行数,默认 1 */
323
+ lines?: number;
324
+ /** 是否使用原生 title 属性展示完整文本(不走 Tooltip),默认 false */
325
+ showTitle?: boolean;
326
+ /** tooltip 配置;设为 false 则仅省略不显示 tooltip */
327
+ tooltip?: false | TooltipProps;
328
+ }
329
+ type ProColumnType<DataValue = RecordType, SearchParams = RecordType> = ProColumn<Omit<ColumnType<DataValue>, keyof DefaultProColumnWithKeyOrDataIndex | 'ellipsis'> & {
296
330
  children?: ProColumnType<DataValue, SearchParams>[];
297
331
  index?: number;
298
332
  copyText?: string | ((record: ProColumnType) => string);
299
- tooltip?: false | (TooltipProps & {
300
- width?: number;
301
- targetStyle?: Partial<CSSProperties>;
302
- hiddenLine?: number;
303
- class?: string;
304
- }); /** 不在列表中显示 */
333
+ /**
334
+ * 文本溢出配置:
335
+ * - true:单行省略 + tooltip
336
+ * - 对象:可指定 lines(省略行数,默认 1)、tooltip(false 关闭提示,或透传 TooltipProps)、showTitle(原生 title)
337
+ */
338
+ ellipsis?: boolean | ProColumnEllipsis; /** 不在列表中显示 */
305
339
  show?: boolean; /** 列表顺序值 */
306
340
  order?: number; /** 表单搜索配置 */
307
341
  searchConfig?: ProSearchMap<undefined, keyof DataValue | keyof SearchParams>; /** 是否拷贝 */
@@ -419,6 +453,10 @@ interface ProTableProps<DataRecord = RecordType, ParamsType = RecordType> extend
419
453
  onResizeColumn?: (width: number, column: ProColumnType<DataRecord>) => void;
420
454
  /** 启用列宽拖拽调整 */
421
455
  draggable?: boolean;
456
+ /** 启用行拖拽排序(把手列自动注入到首列,比序号列更靠前) */
457
+ rowDraggable?: boolean | ProTableRowDragOptions;
458
+ /** 行拖拽排序结束回调 */
459
+ onRowSortEnd?: (event: ProTableRowSortEndEvent<DataRecord>) => void;
422
460
  /**
423
461
  * keep-alive 页面重新进入时是否触发数据请求
424
462
  */
@@ -494,6 +532,7 @@ interface ProTableEmits<DataRecord = RecordType, ParamsType = RecordType> extend
494
532
  'sizeChange': ProTableProps<DataRecord, ParamsType>['onSizeChange'];
495
533
  'resizeColumn': ProTableProps<DataRecord, ParamsType>['onResizeColumn'];
496
534
  'fullscreenChange': ProTableProps<DataRecord, ParamsType>['onFullscreenChange'];
535
+ 'rowSortEnd': ProTableProps<DataRecord, ParamsType>['onRowSortEnd'];
497
536
  }
498
537
  //#endregion
499
- export { BeforeSearchSubmit, ColConfig, ColumnWithKeyOrDataIndex, CustomDataFn, CustomDataRender, CustomRenderResult, DefaultProColumn, DefaultProColumnWithKeyOrDataIndex, DefaultRender, FormConfig, OperateRowProps, PageItemFn, PageItemRender, PageState, ProColumn, ProColumnType, ProColumnsValueType, ProCoreActionType, ProCoreFormType, ProFieldValueFormat, ProFieldValueType, ProSchemaValueEnumType, ProSearchMap, ProTableBodyCellProps, ProTableClassNamesType, ProTableCustomProps, ProTableEmits, ProTableFetchParams, ProTableIndexColumn, ProTablePagination, ProTablePaginationConfig, ProTableProps, ProTableRef, ProTableScrollPolicy, ProTableSizeType, ProTableSlots, ProTableStylesType, RequestConfig, RequestData, RequestFunction, RowSelectionActions, TableSemanticName, TableSorterRecord, ToolbarOptionConfig, ToolbarPlacement };
538
+ export { BeforeSearchSubmit, ColConfig, ColumnWithKeyOrDataIndex, CustomDataFn, CustomDataRender, CustomRenderResult, DefaultProColumn, DefaultProColumnWithKeyOrDataIndex, DefaultRender, FormConfig, OperateRowProps, PageItemFn, PageItemRender, PageState, ProColumn, ProColumnEllipsis, ProColumnType, ProColumnsValueType, ProCoreActionType, ProCoreFormType, ProFieldValueFormat, ProFieldValueType, ProSchemaValueEnumType, ProSearchMap, ProTableBodyCellProps, ProTableClassNamesType, ProTableCustomProps, ProTableEmits, ProTableFetchParams, ProTableIndexColumn, ProTablePagination, ProTablePaginationConfig, ProTableProps, ProTableRef, ProTableRowDragOptions, ProTableRowSortEndEvent, ProTableScrollPolicy, ProTableSizeType, ProTableSlots, ProTableStylesType, RequestConfig, RequestData, RequestFunction, RowSelectionActions, TableSemanticName, TableSorterRecord, ToolbarOptionConfig, ToolbarPlacement };