index.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { Point } from '@antv/x6-geometry';
  2. import { KeyValue } from '@antv/x6-common';
  3. import { Registry } from '../registry';
  4. import { Edge } from '../../model';
  5. import { EdgeView, NodeView } from '../../view';
  6. import * as anchors from './main';
  7. export declare namespace NodeAnchor {
  8. type Definition<T> = (this: EdgeView,
  9. /**
  10. * The NodeView to which we are connecting.
  11. */
  12. nodeView: NodeView,
  13. /**
  14. * The SVGElement in our graph that contains the magnet
  15. * (element/subelement/port) to which we are connecting.
  16. */
  17. magnet: SVGElement,
  18. /**
  19. * A reference to another component of the edge path that may be
  20. * necessary to find this anchor point. If we are calling this method
  21. * for a source anchor, it is the first vertex, or if there are no
  22. * vertices the target anchor. If we are calling this method for a target
  23. * anchor, it is the last vertex, or if there are no vertices the source
  24. * anchor...
  25. */
  26. ref: Point | Point.PointLike | SVGElement, args: T, type: Edge.TerminalType) => Point;
  27. type CommonDefinition = Definition<KeyValue>;
  28. type ResolvedDefinition<T> = (this: EdgeView, view: NodeView, magnet: SVGElement, refPoint: Point, args: T) => Point;
  29. }
  30. export declare namespace NodeAnchor {
  31. type Presets = (typeof NodeAnchor)['presets'];
  32. type OptionsMap = {
  33. readonly [K in keyof Presets]-?: Parameters<Presets[K]>[3];
  34. };
  35. type NativeNames = keyof Presets;
  36. interface NativeItem<T extends NativeNames = NativeNames> {
  37. name: T;
  38. args?: OptionsMap[T];
  39. }
  40. interface ManaualItem {
  41. name: Exclude<string, NativeNames>;
  42. args?: KeyValue;
  43. }
  44. }
  45. export declare namespace NodeAnchor {
  46. const presets: typeof anchors;
  47. const registry: Registry<CommonDefinition, typeof anchors, never>;
  48. }