| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import * as arrow from "./arrow";
- import * as rectangle from "./rectangle";
- import * as circle from "./circle";
- import * as triangle from "./triangle";
- import * as polygon from "./polygon";
- import * as line from "./line";
- import * as lineChunk from "./line-chunk";
- import * as lineIcon from "./line-icon/index";
- import * as text from "./text";
- import * as icon from "./icon";
- import * as image from "./image";
- import * as table from "./table";
- import * as serial from "./serial";
- import * as group from "./group";
- import * as sequentLine from "./sequent-line";
- import { SLineData } from "./sequent-line";
- import { ArrowData } from "./arrow";
- import { TableData } from "./table";
- import { RectangleData } from "./rectangle";
- import { CircleData } from "./circle";
- import { TriangleData } from "./triangle";
- import { PolygonData } from "./polygon";
- import { LineData } from "./line";
- import { LineChunkData } from "./line-chunk";
- import { LineIconData } from "./line-icon/index";
- import { TextData } from "./text";
- import { IconData } from "./icon";
- import { ImageData } from "./image";
- import { SerialData } from "./serial";
- import { GroupData } from "./group";
- import { Pos } from "@/utils/math";
- import { AddMessage } from "../hook/use-draw";
- import { Transform } from "konva/lib/Util";
- import { DrawStore } from "../store";
- import { DrawHistory } from "../hook/use-history";
- import { TransformerVectorType } from "../hook/use-transformer";
- import { UseGetSelectionManage } from "../hook/use-selection";
- const _components = {
- arrow,
- rectangle,
- circle,
- triangle,
- polygon,
- line,
- lineChunk,
- lineIcon,
- text,
- icon,
- image,
- table,
- serial,
- group,
- sequentLine,
- };
- export const components = _components as any as Components;
- type CompAttach<key extends ShapeType> = {
- delItem?: (
- store: DrawStore,
- data: DrawItem<key>,
- childrenId?: string
- ) => void;
- checkItemData?: (item: DrawItem<key>) => boolean
- useDraw?: () => void;
- getSnapInfos?: (items: DrawItem<key>) => ComponentSnapInfo[];
- GroupComponent: (props: { data: DrawItem[] }) => any;
- getPredefine?: (attrKey: keyof DrawItem<key>) => any;
- useGetSelectionManage?: UseGetSelectionManage
- startMatResponse?: () => void
- endMatResponse?: () => void
- childrenDataGetter?: (data: DrawItem<key>, id: string) => any
- };
- type _Components = {
- [key in keyof typeof _components]: (typeof _components)[key];
- };
- export type Components = {
- [key in keyof _Components]: {
- [a in
- | keyof _Components[key]
- | keyof CompAttach<key>]: a extends keyof CompAttach<key>
- ? CompAttach<key>[a]
- : a extends keyof _Components[key] ? _Components[key][a] : never;
- };
- };
- export type ComponentValue<
- T extends ShapeType,
- K extends keyof Components[T]
- > = Components[T][K];
- export type DrawDataItem = {
- arrow: ArrowData;
- rectangle: RectangleData;
- circle: CircleData;
- triangle: TriangleData;
- polygon: PolygonData;
- line: LineData;
- lineChunk: LineChunkData;
- lineIcon: LineIconData,
- text: TextData;
- icon: IconData;
- image: ImageData;
- table: TableData;
- serial: SerialData;
- group: GroupData;
- sequentLine: SLineData;
- };
- export type ShapeType = keyof DrawDataItem;
- export type DrawData = {
- [k in ShapeType]?: DrawDataItem[k][];
- };
- export type DrawItem<T extends ShapeType = ShapeType> = DrawDataItem[T];
- export type SnapPoint = Pos & { view?: boolean };
- export type ComponentSnapInfo = {
- point: SnapPoint;
- links: Pos[];
- linkDirections: Pos[];
- linkAngle: number[];
- };
- export type InteractiveTo<T extends ShapeType> = (args: {
- info: AddMessage<T>;
- preset?: Partial<DrawItem<T>>;
- viewTransform: Transform;
- store: DrawStore;
- history: DrawHistory;
- drawing?: boolean;
- }) => DrawItem<T> | undefined;
- export type InteractiveFix<T extends ShapeType> = (args: {
- data: DrawItem<T>;
- info: AddMessage<T>;
- notdraw?: boolean;
- viewTransform: Transform;
- store: DrawStore;
- history: DrawHistory;
- }) => DrawItem<T> | undefined;
- export type MatResponseProps<T extends ShapeType> = {
- data: DrawItem<T>;
- mat: Transform;
- increment?: boolean;
- operType?: TransformerVectorType;
- store?: DrawStore;
- operId?: string
- };
- export const shapeTypes = Object.keys(components) as ShapeType[]
|