interface.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import type { CSSProperties, VNode } from 'vue';
  2. import type { TreeNodeProps } from './props';
  3. export type { ScrollTo } from '../vc-virtual-list/List';
  4. /** For fieldNames, we provides a abstract interface */
  5. export interface BasicDataNode {
  6. checkable?: boolean;
  7. disabled?: boolean;
  8. disableCheckbox?: boolean;
  9. icon?: IconType;
  10. isLeaf?: boolean;
  11. selectable?: boolean;
  12. switcherIcon?: IconType;
  13. /** Set style of TreeNode. This is not recommend if you don't have any force requirement */
  14. class?: string;
  15. style?: CSSProperties;
  16. slots?: Record<string, string>;
  17. [key: string]: any;
  18. }
  19. export interface DataNode extends BasicDataNode {
  20. children?: DataNode[];
  21. key: string | number;
  22. title?: any;
  23. }
  24. export interface EventDataNode extends DataNode {
  25. expanded?: boolean;
  26. selected?: boolean;
  27. checked: boolean;
  28. loaded?: boolean;
  29. loading?: boolean;
  30. halfChecked?: boolean;
  31. dragOver?: boolean;
  32. dragOverGapTop?: boolean;
  33. dragOverGapBottom?: boolean;
  34. pos?: string;
  35. active?: boolean;
  36. dataRef?: DataNode;
  37. parent?: DataNode;
  38. eventKey?: Key;
  39. }
  40. export declare type IconType = any;
  41. export declare type Key = string | number;
  42. export declare type NodeElement = VNode<TreeNodeProps>;
  43. export declare type DragNodeEvent = {
  44. key: Key;
  45. eventData: EventDataNode;
  46. eventKey: Key;
  47. selectHandle: HTMLSpanElement;
  48. pos: string;
  49. };
  50. export interface Entity {
  51. node: NodeElement;
  52. index: number;
  53. key: Key;
  54. pos: string;
  55. parent?: Entity;
  56. children?: Entity[];
  57. }
  58. export interface DataEntity<TreeDataType extends BasicDataNode = DataNode> extends Omit<Entity, 'node' | 'parent' | 'children'> {
  59. node: TreeDataType;
  60. nodes: TreeDataType[];
  61. parent?: DataEntity<TreeDataType>;
  62. children?: DataEntity<TreeDataType>[];
  63. level: number;
  64. }
  65. export interface FlattenNode {
  66. parent: FlattenNode | null;
  67. children: FlattenNode[];
  68. pos: string;
  69. data: DataNode;
  70. title: any;
  71. key: Key;
  72. isStart: boolean[];
  73. isEnd: boolean[];
  74. }
  75. export declare type GetKey<RecordType> = (record: RecordType, index?: number) => Key;
  76. export declare type GetCheckDisabled<RecordType> = (record: RecordType) => boolean;
  77. export declare type Direction = 'ltr' | 'rtl' | undefined;
  78. export interface FieldNames {
  79. title?: string;
  80. /** @private Internal usage for `vc-tree-select`, safe to remove if no need */
  81. _title?: string[];
  82. key?: string;
  83. children?: string;
  84. }