@das-fed/utils 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-services/src/create-service.js +669 -667
- package/common-info/index.js +63 -62
- package/common-tools/get-url-params.js +0 -1
- package/dimple-canvas/index.d.ts +2 -0
- package/dimple-canvas/index.js +5 -0
- package/dimple-canvas/use-dimple-canvas/core/antv-x6/index.d.ts +28 -0
- package/dimple-canvas/use-dimple-canvas/core/antv-x6/index.js +19946 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/index.d.ts +53 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/index.js +119 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/add-event-listener.d.ts +101 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/add-event-listener.js +17 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/add-object/index.d.ts +7 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/add-object/index.js +55 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/create-canvas.d.ts +5 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/create-canvas.js +14 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/find.d.ts +4 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/find.js +5 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/guideline.d.ts +4 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/guideline.js +181 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/lib.d.ts +3 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/lib.js +7374 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/load-json.d.ts +6 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/load-json.js +13 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/remove-object.d.ts +3 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/remove-object.js +7 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/rule.d.ts +8 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/rule.js +193 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/transform-axis.d.ts +10 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/transform-axis.js +20 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/transformer.d.ts +4 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/transformer.js +52 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/wheel-zoom.d.ts +2 -0
- package/dimple-canvas/use-dimple-canvas/core/konva/utils/wheel-zoom.js +14 -0
- package/dimple-canvas/use-dimple-canvas/index.d.ts +8 -0
- package/dimple-canvas/use-dimple-canvas/index.js +10 -0
- package/micro-app/globalData.d.ts +3 -0
- package/micro-app/globalData.js +11 -0
- package/micro-app/index.d.ts +5 -0
- package/micro-app/index.js +3699 -0
- package/nextTiken/index.d.ts +13 -0
- package/nextTiken/index.js +62 -0
- package/package.json +5 -6
- package/panel/index.d.ts +31 -0
- package/panel/index.js +37 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Konva } from '@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/lib';
|
|
2
|
+
import type { ObjectType, ObjectConfig } from '../type';
|
|
3
|
+
declare const useKonva: () => {
|
|
4
|
+
canvasContainerEl: any;
|
|
5
|
+
canvas: any;
|
|
6
|
+
layer: any;
|
|
7
|
+
onCanvasMounted: (cb: Function) => number;
|
|
8
|
+
createCanvas: (container?: HTMLDivElement | null) => void;
|
|
9
|
+
addObject: (type: ObjectType, config?: ObjectConfig) => any;
|
|
10
|
+
findOne: (key: string) => any;
|
|
11
|
+
findObject: (type: ObjectType) => any;
|
|
12
|
+
removeObject: (key: string) => void;
|
|
13
|
+
addEventListener: (eventName: EventName, cb: (e: {
|
|
14
|
+
currentTarget: any;
|
|
15
|
+
evt: Event;
|
|
16
|
+
pointerId: any;
|
|
17
|
+
target: any;
|
|
18
|
+
type: string;
|
|
19
|
+
data: {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
setHoverImage?: (src?: string) => void;
|
|
22
|
+
setActiveImage?: (src?: string) => void;
|
|
23
|
+
setDisabledImage?: (src?: string) => void;
|
|
24
|
+
};
|
|
25
|
+
}) => void) => void;
|
|
26
|
+
changeImageSrc: (imageKey: string, payload: string | {
|
|
27
|
+
src?: string;
|
|
28
|
+
hoverSrc?: string;
|
|
29
|
+
activeSrc?: string;
|
|
30
|
+
disabledSrc?: string;
|
|
31
|
+
}) => void;
|
|
32
|
+
zoom: (type?: 'in' | 'out', radio?: number) => void;
|
|
33
|
+
toJSON: (config?: any) => any;
|
|
34
|
+
loadJSON: (json?: any, config?: any) => void;
|
|
35
|
+
remove: () => void;
|
|
36
|
+
transformAxis: (coordinate: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}) => any;
|
|
41
|
+
setDisabled: () => void;
|
|
42
|
+
showRule: (options?: {
|
|
43
|
+
/** 刻度间隔 */
|
|
44
|
+
precision?: number;
|
|
45
|
+
/** 刻度文字颜色 */
|
|
46
|
+
textColor?: string;
|
|
47
|
+
/** 刻度线颜色 */
|
|
48
|
+
lineColor?: string;
|
|
49
|
+
}) => any;
|
|
50
|
+
removeRule: () => void;
|
|
51
|
+
tr: any;
|
|
52
|
+
};
|
|
53
|
+
export { useKonva, Konva };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { ref as p, shallowRef as m, watch as j } from "vue";
|
|
2
|
+
import { createCanvas as G } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/create-canvas";
|
|
3
|
+
import { addObject as M } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/add-object";
|
|
4
|
+
import { findOne as S, findObject as U } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/find";
|
|
5
|
+
import { removeObject as W } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/remove-object";
|
|
6
|
+
import { initTransformer as X, removeTransformer as w } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/transformer";
|
|
7
|
+
import { initGuideline as $ } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/guideline";
|
|
8
|
+
import { loadJSON as q } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/load-json";
|
|
9
|
+
import { transformAxis as P } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/transform-axis";
|
|
10
|
+
import { initRule as Q } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/rule";
|
|
11
|
+
import { addEventListener as Y } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/add-event-listener";
|
|
12
|
+
import { Konva as H } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/lib";
|
|
13
|
+
import { Konva as me } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/lib";
|
|
14
|
+
const ie = () => {
|
|
15
|
+
const n = p(null), r = m(), c = m(), i = m(), g = m();
|
|
16
|
+
let b = [];
|
|
17
|
+
const k = (e) => b.push(e), f = p(!1), d = (e) => {
|
|
18
|
+
n.value || (n.value = e);
|
|
19
|
+
const o = G(e);
|
|
20
|
+
r.value = o.canvas, c.value = o.layer, h(), f.value = !0;
|
|
21
|
+
}, h = () => {
|
|
22
|
+
var e;
|
|
23
|
+
g.value = X(r.value, c.value), $(r.value, c.value), b.map((o) => o()), (e = r.value) == null || e.on("mouseleave", () => {
|
|
24
|
+
w();
|
|
25
|
+
});
|
|
26
|
+
}, y = (e, o) => M(e, {
|
|
27
|
+
canvas: r.value,
|
|
28
|
+
layer: c.value,
|
|
29
|
+
config: o
|
|
30
|
+
}), F = (e) => {
|
|
31
|
+
W(r.value, e), w();
|
|
32
|
+
}, x = (e) => S(r.value, `${e}`), C = (e) => U(r.value, e), L = (e, o) => {
|
|
33
|
+
Y(r, e, o);
|
|
34
|
+
}, R = (e, o) => {
|
|
35
|
+
const t = S(r.value, e);
|
|
36
|
+
if (!t || !t.image)
|
|
37
|
+
return;
|
|
38
|
+
let a = {};
|
|
39
|
+
typeof o == "string" ? a = { src: o } : a = o;
|
|
40
|
+
const { src: s, hoverSrc: l, activeSrc: u, disabledSrc: O } = a;
|
|
41
|
+
if (s) {
|
|
42
|
+
t.attrs.src = s;
|
|
43
|
+
const v = new Image();
|
|
44
|
+
v.src = s;
|
|
45
|
+
const B = t.width(), z = t.height();
|
|
46
|
+
v.onload = () => {
|
|
47
|
+
t.image(v), t.width(B), t.height(z);
|
|
48
|
+
}, t.attrs.setDefaultImage = () => t.image(v);
|
|
49
|
+
}
|
|
50
|
+
l && (t.attrs.hoverSrc = l), u && (t.attrs.activeSrc = u), O && (t.attrs.disabledSrc = O);
|
|
51
|
+
}, J = (e, o) => {
|
|
52
|
+
var s, l;
|
|
53
|
+
const t = ((s = r.value) == null ? void 0 : s.scaleX()) || 1;
|
|
54
|
+
o === void 0 && (o = 0.1);
|
|
55
|
+
let a = 1;
|
|
56
|
+
e === "in" && (a = t - o), e === "out" && (a = t + o), (l = r.value) == null || l.scale({ x: a, y: a });
|
|
57
|
+
}, N = () => {
|
|
58
|
+
var o;
|
|
59
|
+
const e = (o = n.value) == null ? void 0 : o.children[0];
|
|
60
|
+
e == null || e.remove(), d(n.value);
|
|
61
|
+
}, T = (e) => {
|
|
62
|
+
var t;
|
|
63
|
+
return r.value ? (t = r.value) == null ? void 0 : t.toJSON() : {};
|
|
64
|
+
}, I = (e, o) => {
|
|
65
|
+
const t = () => {
|
|
66
|
+
if (!n.value)
|
|
67
|
+
return;
|
|
68
|
+
const a = q(n.value, e);
|
|
69
|
+
r.value = a.canvas, c.value = a.layer, i.value = a.ruleLayer, h();
|
|
70
|
+
};
|
|
71
|
+
if (f.value)
|
|
72
|
+
return t();
|
|
73
|
+
j(
|
|
74
|
+
() => f.value,
|
|
75
|
+
() => t()
|
|
76
|
+
);
|
|
77
|
+
}, A = (e) => n.value ? P(n.value, r.value, e) : { x: 0, y: 0 }, D = () => {
|
|
78
|
+
var s, l, u;
|
|
79
|
+
const { width: e = 0, height: o = 0 } = ((s = n.value) == null ? void 0 : s.getBoundingClientRect()) || {}, t = new H.Layer({ width: e, height: o }), a = new H.Rect({ width: e, height: o, fill: "rgba(0,0,0,0)", draggable: !1, name: "disabled" });
|
|
80
|
+
t.name("disabled"), (l = r.value) == null || l.add(t), console.log(t), t.add(a), t.moveToTop(), (u = r.value) == null || u.setDraggable(!1);
|
|
81
|
+
}, E = (e) => {
|
|
82
|
+
var o;
|
|
83
|
+
return i.value = Q(r.value, e), i.value.moveToBottom(), (o = r.value) == null || o.add(i.value), i;
|
|
84
|
+
}, K = () => {
|
|
85
|
+
var e;
|
|
86
|
+
(e = i.value) == null || e.remove();
|
|
87
|
+
};
|
|
88
|
+
return j(
|
|
89
|
+
() => n.value,
|
|
90
|
+
(e, o) => {
|
|
91
|
+
e && o === null && d(e);
|
|
92
|
+
}
|
|
93
|
+
), {
|
|
94
|
+
canvasContainerEl: n,
|
|
95
|
+
canvas: r,
|
|
96
|
+
layer: c,
|
|
97
|
+
onCanvasMounted: k,
|
|
98
|
+
createCanvas: d,
|
|
99
|
+
addObject: y,
|
|
100
|
+
findOne: x,
|
|
101
|
+
findObject: C,
|
|
102
|
+
removeObject: F,
|
|
103
|
+
addEventListener: L,
|
|
104
|
+
changeImageSrc: R,
|
|
105
|
+
zoom: J,
|
|
106
|
+
toJSON: T,
|
|
107
|
+
loadJSON: I,
|
|
108
|
+
remove: N,
|
|
109
|
+
transformAxis: A,
|
|
110
|
+
setDisabled: D,
|
|
111
|
+
showRule: E,
|
|
112
|
+
removeRule: K,
|
|
113
|
+
tr: g
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export {
|
|
117
|
+
me as Konva,
|
|
118
|
+
ie as useKonva
|
|
119
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
interface GlobalEventHandlersEventMap {
|
|
2
|
+
abort: UIEvent;
|
|
3
|
+
animationcancel: AnimationEvent;
|
|
4
|
+
animationend: AnimationEvent;
|
|
5
|
+
animationiteration: AnimationEvent;
|
|
6
|
+
animationstart: AnimationEvent;
|
|
7
|
+
auxclick: MouseEvent;
|
|
8
|
+
beforeinput: InputEvent;
|
|
9
|
+
blur: FocusEvent;
|
|
10
|
+
cancel: Event;
|
|
11
|
+
canplay: Event;
|
|
12
|
+
canplaythrough: Event;
|
|
13
|
+
change: Event;
|
|
14
|
+
click: MouseEvent;
|
|
15
|
+
close: Event;
|
|
16
|
+
compositionend: CompositionEvent;
|
|
17
|
+
compositionstart: CompositionEvent;
|
|
18
|
+
compositionupdate: CompositionEvent;
|
|
19
|
+
contextmenu: MouseEvent;
|
|
20
|
+
cuechange: Event;
|
|
21
|
+
dblclick: MouseEvent;
|
|
22
|
+
drag: DragEvent;
|
|
23
|
+
dragend: DragEvent;
|
|
24
|
+
dragenter: DragEvent;
|
|
25
|
+
dragleave: DragEvent;
|
|
26
|
+
dragover: DragEvent;
|
|
27
|
+
dragstart: DragEvent;
|
|
28
|
+
drop: DragEvent;
|
|
29
|
+
durationchange: Event;
|
|
30
|
+
emptied: Event;
|
|
31
|
+
ended: Event;
|
|
32
|
+
error: ErrorEvent;
|
|
33
|
+
focus: FocusEvent;
|
|
34
|
+
focusin: FocusEvent;
|
|
35
|
+
focusout: FocusEvent;
|
|
36
|
+
formdata: FormDataEvent;
|
|
37
|
+
gotpointercapture: PointerEvent;
|
|
38
|
+
input: Event;
|
|
39
|
+
invalid: Event;
|
|
40
|
+
keydown: KeyboardEvent;
|
|
41
|
+
keypress: KeyboardEvent;
|
|
42
|
+
keyup: KeyboardEvent;
|
|
43
|
+
load: Event;
|
|
44
|
+
loadeddata: Event;
|
|
45
|
+
loadedmetadata: Event;
|
|
46
|
+
loadstart: Event;
|
|
47
|
+
lostpointercapture: PointerEvent;
|
|
48
|
+
mousedown: MouseEvent;
|
|
49
|
+
mouseenter: MouseEvent;
|
|
50
|
+
mouseleave: MouseEvent;
|
|
51
|
+
mousemove: MouseEvent;
|
|
52
|
+
mouseout: MouseEvent;
|
|
53
|
+
mouseover: MouseEvent;
|
|
54
|
+
mouseup: MouseEvent;
|
|
55
|
+
pause: Event;
|
|
56
|
+
play: Event;
|
|
57
|
+
playing: Event;
|
|
58
|
+
pointercancel: PointerEvent;
|
|
59
|
+
pointerdown: PointerEvent;
|
|
60
|
+
pointerenter: PointerEvent;
|
|
61
|
+
pointerleave: PointerEvent;
|
|
62
|
+
pointermove: PointerEvent;
|
|
63
|
+
pointerout: PointerEvent;
|
|
64
|
+
pointerover: PointerEvent;
|
|
65
|
+
pointerup: PointerEvent;
|
|
66
|
+
progress: ProgressEvent;
|
|
67
|
+
ratechange: Event;
|
|
68
|
+
reset: Event;
|
|
69
|
+
resize: UIEvent;
|
|
70
|
+
scroll: Event;
|
|
71
|
+
securitypolicyviolation: SecurityPolicyViolationEvent;
|
|
72
|
+
seeked: Event;
|
|
73
|
+
seeking: Event;
|
|
74
|
+
select: Event;
|
|
75
|
+
selectionchange: Event;
|
|
76
|
+
selectstart: Event;
|
|
77
|
+
slotchange: Event;
|
|
78
|
+
stalled: Event;
|
|
79
|
+
submit: SubmitEvent;
|
|
80
|
+
suspend: Event;
|
|
81
|
+
timeupdate: Event;
|
|
82
|
+
toggle: Event;
|
|
83
|
+
touchcancel: TouchEvent;
|
|
84
|
+
touchend: TouchEvent;
|
|
85
|
+
touchmove: TouchEvent;
|
|
86
|
+
touchstart: TouchEvent;
|
|
87
|
+
transitioncancel: TransitionEvent;
|
|
88
|
+
transitionend: TransitionEvent;
|
|
89
|
+
transitionrun: TransitionEvent;
|
|
90
|
+
transitionstart: TransitionEvent;
|
|
91
|
+
volumechange: Event;
|
|
92
|
+
waiting: Event;
|
|
93
|
+
webkitanimationend: Event;
|
|
94
|
+
webkitanimationiteration: Event;
|
|
95
|
+
webkitanimationstart: Event;
|
|
96
|
+
webkittransitionend: Event;
|
|
97
|
+
wheel: WheelEvent;
|
|
98
|
+
}
|
|
99
|
+
export type EventName = keyof GlobalEventHandlersEventMap;
|
|
100
|
+
declare const addEventListener: (canvas: Ref<any>, eventName: EventName, cb: any) => void;
|
|
101
|
+
export { addEventListener };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { watch as d } from "vue";
|
|
2
|
+
const p = (t, r, e) => {
|
|
3
|
+
var o;
|
|
4
|
+
t.value && ((o = t.value) == null || o.on(r, e)), t.value || d(
|
|
5
|
+
() => t.value,
|
|
6
|
+
(a, l) => {
|
|
7
|
+
var u;
|
|
8
|
+
l || (u = t.value) == null || u.on(r, (i) => {
|
|
9
|
+
const f = i.target.attrs;
|
|
10
|
+
e({ ...i, data: f });
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
p as addEventListener
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Canvas, Layer, ObjectConfig } from '@das-fed/utils/dimple-canvas/use-dimple-canvas/core/type';
|
|
2
|
+
declare const addObject: (type: ObjectType, options: {
|
|
3
|
+
canvas?: Canvas | null;
|
|
4
|
+
layer?: Layer | null;
|
|
5
|
+
config?: ObjectConfig;
|
|
6
|
+
}) => Promise<any>;
|
|
7
|
+
export { addObject };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Konva as d } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/lib";
|
|
2
|
+
const f = async (r, n) => {
|
|
3
|
+
const { config: t = {}, canvas: s, layer: a } = n;
|
|
4
|
+
if (!s || !a)
|
|
5
|
+
return;
|
|
6
|
+
let e = null;
|
|
7
|
+
t.type = r, t.draggable = t.draggable ?? !0;
|
|
8
|
+
const c = +/* @__PURE__ */ new Date();
|
|
9
|
+
return t.id = t.id ?? c.toString(), r === "Rect" && (e = new d.Rect(t)), r === "Circle" && (e = new d.Circle(t)), r === "Image" && (e = await l(t)), r === "BackgroundImage" && I(s, t), e && a.add(e), e;
|
|
10
|
+
}, l = (r) => {
|
|
11
|
+
const { src: n = "" } = r || {};
|
|
12
|
+
return new Promise((t, s) => {
|
|
13
|
+
if (!n)
|
|
14
|
+
return t(null);
|
|
15
|
+
const a = new Image();
|
|
16
|
+
a.src = r.src || "", a.onload = () => {
|
|
17
|
+
const e = new d.Image({ image: a });
|
|
18
|
+
r.setDefaultImage = () => e.image(a), e.setAttrs(r);
|
|
19
|
+
const c = [
|
|
20
|
+
{ getter: "hoverSrc", setter: "setHoverImage" },
|
|
21
|
+
{ getter: "activeSrc", setter: "setActiveImage" },
|
|
22
|
+
{ getter: "disabledSrc", setter: "setDisabledImage" }
|
|
23
|
+
];
|
|
24
|
+
for (const g of c)
|
|
25
|
+
r[g.setter] = (u) => {
|
|
26
|
+
const i = u || e.attrs[g.getter];
|
|
27
|
+
if (!i)
|
|
28
|
+
return;
|
|
29
|
+
const o = new Image();
|
|
30
|
+
o.src = i, o.onload = () => {
|
|
31
|
+
var m;
|
|
32
|
+
return (m = e.image) == null ? void 0 : m.call(e, o);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
e.setAttrs(r), t(e);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}, I = (r, n) => {
|
|
39
|
+
const { src: t = "", scaleWidth: s = 30 } = n || {};
|
|
40
|
+
if (!t)
|
|
41
|
+
return;
|
|
42
|
+
const a = new d.Layer();
|
|
43
|
+
return r.add(a), a.moveToBottom(), l({
|
|
44
|
+
// listening: false,
|
|
45
|
+
src: t,
|
|
46
|
+
width: a.width() - s,
|
|
47
|
+
height: a.height() - s,
|
|
48
|
+
type: "BackgroundImage",
|
|
49
|
+
...n,
|
|
50
|
+
draggable: !1
|
|
51
|
+
}).then((e) => (e && a.add(e), e));
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
f as addObject
|
|
55
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Konva as n } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/lib";
|
|
2
|
+
const r = (e, c) => {
|
|
3
|
+
e || (e = document.createElement("div"), document.body.append(e));
|
|
4
|
+
const { width: d, height: o } = e.getBoundingClientRect(), a = new n.Stage({
|
|
5
|
+
container: e,
|
|
6
|
+
width: d,
|
|
7
|
+
height: o,
|
|
8
|
+
draggable: !0
|
|
9
|
+
}), t = new n.Layer();
|
|
10
|
+
return t.name("base"), a.add(t), { canvas: a, layer: t };
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
r as createCanvas
|
|
14
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Canvas } from '@das-fed/utils/dimple-canvas/use-dimple-canvas/core/type';
|
|
2
|
+
declare const findOne: (canvas: Canvas | null | undefined, key: string) => any;
|
|
3
|
+
declare const findObject: (canvas: Canvas | null | undefined, type: ObjectType) => any;
|
|
4
|
+
export { findOne, findObject };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Canvas, Layer } from '@das-fed/utils/dimple-canvas/use-dimple-canvas/core/type';
|
|
2
|
+
declare const initGuideline: (canvas?: Canvas | null, layer?: Layer | null) => void;
|
|
3
|
+
declare const removeGuideline: (layer?: Layer | null) => void;
|
|
4
|
+
export { initGuideline, removeGuideline };
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Konva as p } from "@das-fed/utils/dimple-canvas/use-dimple-canvas/core/konva/utils/lib";
|
|
2
|
+
const w = (r, s) => {
|
|
3
|
+
if (!r || !s)
|
|
4
|
+
return;
|
|
5
|
+
var c = 5;
|
|
6
|
+
function b(o) {
|
|
7
|
+
var t = [0, r.width() / 2, r.width()], n = [0, r.height() / 2, r.height()];
|
|
8
|
+
return r.find(".object").forEach((f) => {
|
|
9
|
+
if (f !== o) {
|
|
10
|
+
var i = f.getClientRect();
|
|
11
|
+
t.push([i.x, i.x + i.width, i.x + i.width / 2]), n.push([i.y, i.y + i.height, i.y + i.height / 2]);
|
|
12
|
+
}
|
|
13
|
+
}), {
|
|
14
|
+
vertical: t.flat(),
|
|
15
|
+
horizontal: n.flat()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function v(o) {
|
|
19
|
+
var t = o.getClientRect(), n = o.absolutePosition();
|
|
20
|
+
return {
|
|
21
|
+
vertical: [
|
|
22
|
+
{
|
|
23
|
+
guide: Math.round(t.x),
|
|
24
|
+
offset: Math.round(n.x - t.x),
|
|
25
|
+
snap: "start"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
guide: Math.round(t.x + t.width / 2),
|
|
29
|
+
offset: Math.round(n.x - t.x - t.width / 2),
|
|
30
|
+
snap: "center"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
guide: Math.round(t.x + t.width),
|
|
34
|
+
offset: Math.round(n.x - t.x - t.width),
|
|
35
|
+
snap: "end"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
horizontal: [
|
|
39
|
+
{
|
|
40
|
+
guide: Math.round(t.y),
|
|
41
|
+
offset: Math.round(n.y - t.y),
|
|
42
|
+
snap: "start"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
guide: Math.round(t.y + t.height / 2),
|
|
46
|
+
offset: Math.round(n.y - t.y - t.height / 2),
|
|
47
|
+
snap: "center"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
guide: Math.round(t.y + t.height),
|
|
51
|
+
offset: Math.round(n.y - t.y - t.height),
|
|
52
|
+
snap: "end"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function g(o, t) {
|
|
58
|
+
var n = [], f = [];
|
|
59
|
+
o.vertical.forEach((d) => {
|
|
60
|
+
t.vertical.forEach((a) => {
|
|
61
|
+
var h = Math.abs(d - a.guide);
|
|
62
|
+
h < c && n.push({
|
|
63
|
+
lineGuide: d,
|
|
64
|
+
diff: h,
|
|
65
|
+
snap: a.snap,
|
|
66
|
+
offset: a.offset
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}), o.horizontal.forEach((d) => {
|
|
70
|
+
t.horizontal.forEach((a) => {
|
|
71
|
+
var h = Math.abs(d - a.guide);
|
|
72
|
+
h < c && f.push({
|
|
73
|
+
lineGuide: d,
|
|
74
|
+
diff: h,
|
|
75
|
+
snap: a.snap,
|
|
76
|
+
offset: a.offset
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
var i = [], e = n.sort((d, a) => d.diff - a.diff)[0], u = f.sort((d, a) => d.diff - a.diff)[0];
|
|
81
|
+
return e && i.push({
|
|
82
|
+
lineGuide: e.lineGuide,
|
|
83
|
+
offset: e.offset,
|
|
84
|
+
orientation: "V",
|
|
85
|
+
snap: e.snap
|
|
86
|
+
}), u && i.push({
|
|
87
|
+
lineGuide: u.lineGuide,
|
|
88
|
+
offset: u.offset,
|
|
89
|
+
orientation: "H",
|
|
90
|
+
snap: u.snap
|
|
91
|
+
}), i;
|
|
92
|
+
}
|
|
93
|
+
function x(o) {
|
|
94
|
+
o.forEach((t) => {
|
|
95
|
+
if (t.orientation === "H") {
|
|
96
|
+
var n = new p.Line({
|
|
97
|
+
points: [-6e3, 0, 6e3, 0],
|
|
98
|
+
stroke: "rgb(0, 161, 255)",
|
|
99
|
+
strokeWidth: 1,
|
|
100
|
+
name: "guid-line",
|
|
101
|
+
dash: [4, 6]
|
|
102
|
+
});
|
|
103
|
+
s.add(n), n.absolutePosition({
|
|
104
|
+
x: 0,
|
|
105
|
+
y: t.lineGuide
|
|
106
|
+
});
|
|
107
|
+
} else if (t.orientation === "V") {
|
|
108
|
+
var n = new p.Line({
|
|
109
|
+
points: [0, -6e3, 0, 6e3],
|
|
110
|
+
stroke: "rgb(0, 161, 255)",
|
|
111
|
+
strokeWidth: 1,
|
|
112
|
+
name: "guid-line",
|
|
113
|
+
dash: [4, 6]
|
|
114
|
+
});
|
|
115
|
+
s.add(n), n.absolutePosition({
|
|
116
|
+
x: t.lineGuide,
|
|
117
|
+
y: 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
s.on("dragmove", function(o) {
|
|
123
|
+
s.find(".guid-line").forEach((e) => e.destroy());
|
|
124
|
+
var t = b(o.target), n = v(o.target), f = g(t, n);
|
|
125
|
+
if (f.length) {
|
|
126
|
+
x(f);
|
|
127
|
+
var i = o.target.absolutePosition();
|
|
128
|
+
f.forEach((e) => {
|
|
129
|
+
switch (e.snap) {
|
|
130
|
+
case "start": {
|
|
131
|
+
switch (e.orientation) {
|
|
132
|
+
case "V": {
|
|
133
|
+
i.x = e.lineGuide + e.offset;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "H": {
|
|
137
|
+
i.y = e.lineGuide + e.offset;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "center": {
|
|
144
|
+
switch (e.orientation) {
|
|
145
|
+
case "V": {
|
|
146
|
+
i.x = e.lineGuide + e.offset;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case "H": {
|
|
150
|
+
i.y = e.lineGuide + e.offset;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case "end": {
|
|
157
|
+
switch (e.orientation) {
|
|
158
|
+
case "V": {
|
|
159
|
+
i.x = e.lineGuide + e.offset;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case "H": {
|
|
163
|
+
i.y = e.lineGuide + e.offset;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}), o.target.absolutePosition(i);
|
|
171
|
+
}
|
|
172
|
+
}), s.on("dragend", function(o) {
|
|
173
|
+
s.find(".guid-line").forEach((t) => t.destroy());
|
|
174
|
+
});
|
|
175
|
+
}, E = (r) => {
|
|
176
|
+
r == null || r.find(".guid-line").forEach((s) => s.destroy());
|
|
177
|
+
};
|
|
178
|
+
export {
|
|
179
|
+
w as initGuideline,
|
|
180
|
+
E as removeGuideline
|
|
181
|
+
};
|