index.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { Point, Line } from '@antv/x6-geometry';
  2. import { KeyValue } from '@antv/x6-common';
  3. import { Registry } from '../registry';
  4. import { Edge } from '../../model/edge';
  5. import { CellView } from '../../view/cell';
  6. import * as connectionPoints from './main';
  7. export declare namespace ConnectionPoint {
  8. type Definition<T> = (line: Line, view: CellView, magnet: SVGElement, options: T, type: Edge.TerminalType) => Point;
  9. type CommonDefinition = Definition<KeyValue>;
  10. interface BaseOptions {
  11. /**
  12. * Offset the connection point from the anchor by the specified
  13. * distance along the end edge path segment.
  14. *
  15. * Default is `0`.
  16. */
  17. offset?: number | Point.PointLike;
  18. }
  19. interface StrokedOptions extends BaseOptions {
  20. /**
  21. * If the stroke width should be included when calculating the
  22. * connection point.
  23. *
  24. * Default is `false`.
  25. */
  26. stroked?: boolean;
  27. }
  28. }
  29. export declare namespace ConnectionPoint {
  30. type Presets = (typeof ConnectionPoint)['presets'];
  31. type OptionsMap = {
  32. readonly [K in keyof Presets]-?: Parameters<Presets[K]>[3];
  33. };
  34. type NativeNames = keyof Presets;
  35. interface NativeItem<T extends NativeNames = NativeNames> {
  36. name: T;
  37. args?: OptionsMap[T];
  38. }
  39. interface ManaualItem {
  40. name: Exclude<string, NativeNames>;
  41. args?: KeyValue;
  42. }
  43. }
  44. export declare namespace ConnectionPoint {
  45. const presets: typeof connectionPoints;
  46. const registry: Registry<CommonDefinition, typeof connectionPoints, never>;
  47. }