index.d.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Point, Rectangle } from '@antv/x6-geometry';
  2. import { KeyValue } from '@antv/x6-common';
  3. import { Registry } from '../registry';
  4. import { Attr } from '../attr';
  5. import * as layouts from './main';
  6. export declare namespace PortLabelLayout {
  7. interface Result {
  8. position: Point.PointLike;
  9. angle: number;
  10. attrs: Attr.CellAttrs;
  11. }
  12. type Definition<T> = (portPosition: Point, elemBBox: Rectangle, args: T) => Result;
  13. type CommonDefinition = Definition<KeyValue>;
  14. interface CommonOptions {
  15. x?: number;
  16. y?: number;
  17. angle?: number;
  18. attrs?: Attr.CellAttrs;
  19. }
  20. }
  21. export declare namespace PortLabelLayout {
  22. type Presets = (typeof PortLabelLayout)['presets'];
  23. type OptionsMap = {
  24. readonly [K in keyof Presets]-?: Parameters<Presets[K]>[2];
  25. };
  26. type NativeNames = keyof Presets;
  27. interface NativeItem<T extends NativeNames = NativeNames> {
  28. name: T;
  29. args?: OptionsMap[T];
  30. }
  31. interface ManaualItem {
  32. name: Exclude<string, NativeNames>;
  33. args?: KeyValue;
  34. }
  35. }
  36. export declare namespace PortLabelLayout {
  37. const presets: typeof layouts;
  38. const registry: Registry<CommonDefinition, typeof layouts, never>;
  39. }