@glodon-aiot/dataset-annotation 3.14.0-alpha.32 → 3.15.0-alpha.1

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.
Files changed (114) hide show
  1. package/dist/es/DatasetContext/index.mjs +3 -6
  2. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +91 -94
  3. package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +28 -37
  4. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +101 -145
  5. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +195 -256
  6. package/dist/es/components/DetectionAnnotation/index.mjs +424 -456
  7. package/dist/es/components/Iconfont/index.mjs +2 -2
  8. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +1 -1
  9. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +1 -1
  10. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +45 -43
  11. package/dist/es/components/PicZipImportModal/index.mjs +293 -308
  12. package/dist/es/components/PreLabelOCR/index.mjs +1 -1
  13. package/dist/es/constant.mjs +3 -3
  14. package/dist/es/featuresConfig.mjs +9 -13
  15. package/dist/es/index.mjs +7 -11
  16. package/dist/lib/index.js +3 -4
  17. package/dist/src/DatasetContext/index.d.ts +0 -2
  18. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +0 -1
  19. package/dist/src/constant.d.ts +1 -1
  20. package/dist/src/featuresConfig.d.ts +0 -4
  21. package/dist/src/index.d.ts +0 -3
  22. package/package.json +2 -2
  23. package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +0 -129
  24. package/dist/es/components/DetectionAnnotation/components/ImageModal/style.less.mjs +0 -4
  25. package/dist/es/components/PicZipImportModal/config.mjs +0 -47
  26. package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +0 -4
  27. package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +0 -4
  28. package/dist/es/components/VLMAnnotation/RegionItem.mjs +0 -170
  29. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +0 -94
  30. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +0 -116
  31. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +0 -115
  32. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +0 -42
  33. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +0 -55
  34. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +0 -51
  35. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +0 -62
  36. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +0 -421
  37. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +0 -100
  38. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +0 -106
  39. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +0 -101
  40. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +0 -103
  41. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +0 -38
  42. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +0 -173
  43. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +0 -72
  44. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +0 -116
  45. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +0 -98
  46. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +0 -156
  47. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +0 -4
  48. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +0 -4
  49. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +0 -4
  50. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +0 -4
  51. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +0 -4
  52. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +0 -651
  53. package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +0 -4
  54. package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +0 -33
  55. package/dist/es/components/VLMAnnotation/components/DragButton.mjs +0 -18
  56. package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +0 -16
  57. package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +0 -30
  58. package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +0 -40
  59. package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +0 -44
  60. package/dist/es/components/VLMAnnotation/constants.mjs +0 -57
  61. package/dist/es/components/VLMAnnotation/index.mjs +0 -279
  62. package/dist/es/components/VLMAnnotation/style.less.mjs +0 -4
  63. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +0 -343
  64. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +0 -4
  65. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +0 -240
  66. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +0 -201
  67. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +0 -4
  68. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
  69. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +0 -4
  70. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +0 -149
  71. package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +0 -4
  72. package/dist/es/components/VLMAnnotationDetail/index.mjs +0 -449
  73. package/dist/es/components/VLMAnnotationDetail/style.less.mjs +0 -4
  74. package/dist/es/createVlmtasetAnnotation/index.mjs +0 -131
  75. package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +0 -34
  76. package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
  77. package/dist/src/components/PicZipImportModal/config.d.ts +0 -23
  78. package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +0 -4
  79. package/dist/src/components/VLMAnnotation/RegionItem.d.ts +0 -4
  80. package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +0 -4
  81. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +0 -13
  82. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +0 -38
  83. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +0 -18
  84. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +0 -7
  85. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +0 -13
  86. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +0 -22
  87. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +0 -34
  88. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +0 -16
  89. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +0 -11
  90. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +0 -29
  91. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +0 -31
  92. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +0 -13
  93. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +0 -41
  94. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +0 -12
  95. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +0 -16
  96. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +0 -32
  97. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +0 -25
  98. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +0 -4
  99. package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +0 -32
  100. package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +0 -7
  101. package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +0 -6
  102. package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +0 -7
  103. package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +0 -4
  104. package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +0 -4
  105. package/dist/src/components/VLMAnnotation/constants.d.ts +0 -113
  106. package/dist/src/components/VLMAnnotation/index.d.ts +0 -6
  107. package/dist/src/components/VLMAnnotation/types.d.ts +0 -187
  108. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +0 -14
  109. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +0 -12
  110. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +0 -12
  111. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +0 -12
  112. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +0 -17
  113. package/dist/src/components/VLMAnnotationDetail/index.d.ts +0 -6
  114. package/dist/src/createVlmtasetAnnotation/index.d.ts +0 -16
@@ -1,170 +0,0 @@
1
- import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { useRef as U, useState as k, useEffect as $ } from "react";
3
- import { Tooltip as V, Input as W } from "antd";
4
- import { UpOutlined as q } from "@ant-design/icons";
5
- import G from "./VLMLabelMaker/icons/del.png.mjs";
6
- import H from "./VLMLabelMaker/icons/ai.svg.mjs";
7
- import J from "./VLMLabelMaker/icons/star.svg.mjs";
8
- import K from "./VLMLabelMaker/icons/loading.svg.mjs";
9
- const F = ({
10
- name: P,
11
- labelDefinitions: v,
12
- region: m,
13
- isSelected: g,
14
- isActive: l,
15
- activeLabelId: a,
16
- onChange: x,
17
- onFocus: h,
18
- onBlur: N,
19
- onDelete: T,
20
- onRegionClick: c,
21
- onOCR: M,
22
- isOCRRecognizing: p,
23
- hasOCRError: w,
24
- readOnly: d
25
- }) => {
26
- const n = U(null), u = U(/* @__PURE__ */ new Map()), [f, I] = k(!1);
27
- return $(() => {
28
- g && n.current && (I(!1), setTimeout(() => {
29
- n.current && n.current.scrollIntoView({
30
- behavior: "smooth",
31
- block: "nearest",
32
- inline: "nearest"
33
- });
34
- }, 200));
35
- }, [g]), $(() => {
36
- l && n.current && (I(!1), setTimeout(() => {
37
- n.current && n.current.scrollIntoView({
38
- behavior: "smooth",
39
- block: "nearest",
40
- inline: "nearest"
41
- });
42
- }, 200));
43
- }, [l]), $(() => {
44
- if (l && a) {
45
- const t = u.current.get(a);
46
- t != null && t.input ? t.input.focus() : setTimeout(() => {
47
- const r = u.current.get(a);
48
- r != null && r.input && r.input.focus();
49
- }, 100);
50
- }
51
- }, [l, a]), /* @__PURE__ */ i("div", {
52
- ref: n,
53
- className: `vlm-text-region ${g || l ? "vlm-text-region-selected" : ""} ${f ? "vlm-text-region-collapsed" : ""}`,
54
- children: [/* @__PURE__ */ i("div", {
55
- className: "vlm-text-region-header",
56
- onClick: (t) => {
57
- const r = t.target;
58
- r.closest(".vlm-text-region-delete-btn") !== null || r.closest(".vlm-text-region-collapse-icon") !== null || c == null || c(m);
59
- },
60
- children: [/* @__PURE__ */ e("span", {
61
- className: `vlm-text-region-collapse-icon ${f ? "vlm-text-region-collapse-icon-collapsed" : ""}`,
62
- onClick: (t) => {
63
- t.stopPropagation(), I(!f);
64
- },
65
- children: /* @__PURE__ */ e(q, {})
66
- }), /* @__PURE__ */ e("span", {
67
- className: "vlm-text-region-name",
68
- children: P
69
- }), /* @__PURE__ */ i("div", {
70
- className: "vlm-text-region-actions",
71
- children: [!d && M && /* @__PURE__ */ e(V, {
72
- title: p ? "识别中..." : w ? "识别失败,点击重试" : "OCR识别",
73
- children: /* @__PURE__ */ e("span", {
74
- className: `vlm-text-region-ocr-btn ${p ? "vlm-text-region-ocr-btn-loading" : ""} ${w ? "vlm-text-region-ocr-btn-error" : ""}`,
75
- onClick: (t) => {
76
- t.stopPropagation(), p || M(m.id);
77
- },
78
- children: /* @__PURE__ */ i("div", {
79
- className: "vlm-text-region-ocr-icon-wrapper",
80
- children: [/* @__PURE__ */ e("img", {
81
- src: H,
82
- alt: "OCR识别",
83
- className: "vlm-text-region-ocr-icon"
84
- }), p ? /* @__PURE__ */ e("img", {
85
- src: K,
86
- alt: "",
87
- className: "vlm-text-region-ocr-status vlm-text-region-ocr-loading"
88
- }) : w ? /* @__PURE__ */ i("svg", {
89
- className: "vlm-text-region-ocr-status vlm-text-region-ocr-error-icon",
90
- width: "12",
91
- height: "12",
92
- viewBox: "0 0 12 12",
93
- fill: "none",
94
- xmlns: "http://www.w3.org/2000/svg",
95
- children: [/* @__PURE__ */ e("circle", {
96
- cx: "6",
97
- cy: "6",
98
- r: "5.5",
99
- fill: "#ff4d4f",
100
- stroke: "none"
101
- }), /* @__PURE__ */ e("path", {
102
- d: "M6 3.5v3M6 8.5h.01",
103
- stroke: "#fff",
104
- strokeWidth: "1.2",
105
- strokeLinecap: "round"
106
- })]
107
- }) : /* @__PURE__ */ e("img", {
108
- src: J,
109
- alt: "",
110
- className: "vlm-text-region-ocr-status vlm-text-region-ocr-star"
111
- })]
112
- })
113
- })
114
- }), !d && T && /* @__PURE__ */ e("span", {
115
- className: "vlm-text-region-delete-btn",
116
- onClick: (t) => {
117
- t.stopPropagation(), T(m.id);
118
- },
119
- title: "删除",
120
- children: /* @__PURE__ */ e("img", {
121
- src: G,
122
- alt: "删除",
123
- className: "vlm-text-region-delete-icon"
124
- })
125
- })]
126
- })]
127
- }), /* @__PURE__ */ e("div", {
128
- className: `vlm-text-region-content ${f ? "vlm-text-region-content-collapsed" : ""}`,
129
- onClick: (t) => {
130
- const r = t.target;
131
- r.tagName === "INPUT" || r.closest("input") !== null || c == null || c(m);
132
- },
133
- children: v == null ? void 0 : v.map((t) => {
134
- const r = l && a === t.id;
135
- return /* @__PURE__ */ i("div", {
136
- className: "vlm-text-label",
137
- children: [t.name, /* @__PURE__ */ e("br", {}), /* @__PURE__ */ e(W, {
138
- ref: (o) => {
139
- o ? u.current.set(t.id, o) : u.current.delete(t.id);
140
- },
141
- value: m.content[t.id],
142
- onFocus: (o) => {
143
- h == null || h(t.id, o.target.value || ""), setTimeout(() => {
144
- const s = u.current.get(t.id);
145
- s != null && s.input && s.input.focus();
146
- }, 0);
147
- },
148
- onBlur: (o) => {
149
- console.log("onBlur", o);
150
- const s = o.relatedTarget, j = (s == null ? void 0 : s.tagName) === "INPUT" || (s == null ? void 0 : s.closest("input")) !== null;
151
- if (r && !j) {
152
- o.target.focus();
153
- return;
154
- }
155
- N == null || N(t.id, o.target.value || "");
156
- },
157
- onChange: (o) => {
158
- x == null || x(t.id, o.target.value || "");
159
- },
160
- allowClear: !d,
161
- readOnly: d
162
- })]
163
- }, t.id);
164
- })
165
- })]
166
- }, P);
167
- };
168
- export {
169
- F as default
170
- };
@@ -1,94 +0,0 @@
1
- var B = Object.defineProperty, H = Object.defineProperties;
2
- var J = Object.getOwnPropertyDescriptors;
3
- var S = Object.getOwnPropertySymbols;
4
- var K = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
5
- var T = (m, d, t) => d in m ? B(m, d, { enumerable: !0, configurable: !0, writable: !0, value: t }) : m[d] = t, c = (m, d) => {
6
- for (var t in d || (d = {}))
7
- K.call(d, t) && T(m, t, d[t]);
8
- if (S)
9
- for (var t of S(d))
10
- Q.call(d, t) && T(m, t, d[t]);
11
- return m;
12
- }, _ = (m, d) => H(m, J(d));
13
- import { jsx as y } from "react/jsx-runtime";
14
- import { Empty as R } from "antd";
15
- import U from "./RegionItem.mjs";
16
- import { REGION_NAME_PREFIX as W } from "./constants.mjs";
17
- const V = ({
18
- labelDefinitions: m,
19
- labels: d,
20
- selectedRegion: t,
21
- activeLabelValue: A,
22
- activeRegionNumber: X,
23
- onChange: u,
24
- onInputActive: $,
25
- onBlur: j,
26
- onDelete: f,
27
- onRegionClick: k,
28
- onOCR: q,
29
- ocrRecognizing: F,
30
- ocrErrors: I,
31
- readOnly: w
32
- }) => !d || d.length === 0 ? /* @__PURE__ */ y("div", {
33
- className: "vlm-text-panel",
34
- children: /* @__PURE__ */ y("div", {
35
- className: "vlm-text-panel-empty",
36
- children: /* @__PURE__ */ y(R, {
37
- description: "暂无标注数据,按R键开始标注吧"
38
- })
39
- })
40
- }) : /* @__PURE__ */ y("div", {
41
- className: "vlm-text-panel",
42
- children: d.map((p, N) => {
43
- var G, M;
44
- const E = A != null && X === N && A.region.id === p.id, x = E ? A.label.id : void 0;
45
- return /* @__PURE__ */ y(U, {
46
- name: `${W}${N + 1}`,
47
- labelDefinitions: m != null ? m : [],
48
- region: p,
49
- isSelected: (t == null ? void 0 : t.id) === p.id,
50
- isActive: E,
51
- activeLabelId: x,
52
- readOnly: w,
53
- onDelete: f,
54
- onRegionClick: k,
55
- onOCR: q,
56
- isOCRRecognizing: (G = F == null ? void 0 : F.has(p.id)) != null ? G : !1,
57
- hasOCRError: (M = I == null ? void 0 : I.has(p.id)) != null ? M : !1,
58
- onFocus: (O) => {
59
- const r = m == null ? void 0 : m.find((P) => P.id === O);
60
- if (!r)
61
- return;
62
- const v = d == null ? void 0 : d[N];
63
- v && ($ ? $({
64
- label: r,
65
- region: c({}, v)
66
- }, N) : u == null || u({
67
- label: r,
68
- region: v
69
- }, N));
70
- },
71
- onBlur: (O) => {
72
- const r = m == null ? void 0 : m.find((v) => v.id === O);
73
- r && (r && j ? j({
74
- label: r,
75
- region: c({}, p)
76
- }, N) : u == null || u(null));
77
- },
78
- onChange: (O, r) => {
79
- const v = m == null ? void 0 : m.find((P) => P.id === O);
80
- v && u && u({
81
- label: v,
82
- region: _(c({}, p), {
83
- content: _(c({}, p.content), {
84
- [O]: r
85
- })
86
- })
87
- }, N);
88
- }
89
- }, p.id);
90
- })
91
- });
92
- export {
93
- V as default
94
- };
@@ -1,116 +0,0 @@
1
- import { useEffect as b } from "react";
2
- import { fabric as c } from "fabric";
3
- const O = ({
4
- canvas: e,
5
- draggable: i,
6
- drawingMode: f,
7
- textLayersMapRef: n
8
- }) => {
9
- const u = () => {
10
- const s = /* @__PURE__ */ new Set();
11
- return n.current.forEach((l) => {
12
- l.forEach((r) => {
13
- s.add(r);
14
- });
15
- }), s;
16
- };
17
- b(() => {
18
- if (!e || f) {
19
- if (e) {
20
- e.selection = !1, e.skipTargetFind = !1;
21
- const o = u();
22
- e.getObjects().forEach((t) => {
23
- t instanceof c.Rect && o.has(t) ? t.set({
24
- evented: !0,
25
- selectable: !1,
26
- lockMovementX: !0,
27
- lockMovementY: !0,
28
- lockScalingX: !0,
29
- lockScalingY: !0,
30
- lockRotation: !0
31
- }) : t.set({
32
- evented: !0,
33
- selectable: !0,
34
- lockMovementX: !1,
35
- lockMovementY: !1,
36
- lockScalingX: !1,
37
- lockScalingY: !1
38
- });
39
- }), e.defaultCursor = "default";
40
- }
41
- return;
42
- }
43
- if (!i) {
44
- e.selection = !1, e.skipTargetFind = !1;
45
- const o = u();
46
- e.getObjects().forEach((t) => {
47
- t instanceof c.Rect && o.has(t) ? t.set({
48
- evented: !0,
49
- selectable: !1,
50
- lockMovementX: !0,
51
- lockMovementY: !0,
52
- lockScalingX: !0,
53
- lockScalingY: !0,
54
- lockRotation: !0
55
- }) : t.set({
56
- evented: !0,
57
- selectable: !0,
58
- lockMovementX: !1,
59
- lockMovementY: !1,
60
- lockScalingX: !1,
61
- lockScalingY: !1
62
- });
63
- }), e.defaultCursor = "default";
64
- return;
65
- }
66
- e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((o) => {
67
- o.set({
68
- evented: !1,
69
- selectable: !1,
70
- lockMovementX: !0,
71
- lockMovementY: !0,
72
- lockScalingX: !0,
73
- lockScalingY: !0,
74
- lockRotation: !0
75
- });
76
- }), e.defaultCursor = "grab";
77
- let l = !1;
78
- const r = (o) => {
79
- e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), l = !0, e.selection = !1, e.skipTargetFind = !0, e.setCursor("grabbing");
80
- }, k = (o) => {
81
- if (l && o && o.e) {
82
- const t = o.e, m = new c.Point(t.movementX, t.movementY);
83
- e.relativePan(m);
84
- }
85
- }, d = () => {
86
- l = !1, e.selection = !1, e.skipTargetFind = !0, e.defaultCursor = "grab", e.setCursor("grab"), e.getActiveObject() && (e.discardActiveObject(), e.renderAll());
87
- }, g = () => {
88
- e.setCursor("grabbing");
89
- };
90
- return e.on("mouse:down", r), e.on("mouse:move", k), e.on("mouse:up", d), e.on("mouse:down:before", g), () => {
91
- e.off("mouse:down", r), e.off("mouse:move", k), e.off("mouse:up", d), e.off("mouse:down:before", g), e.selection = !1, e.skipTargetFind = !1;
92
- const o = u();
93
- e.getObjects().forEach((t) => {
94
- t instanceof c.Rect && o.has(t) ? t.set({
95
- evented: !0,
96
- selectable: !1,
97
- lockMovementX: !0,
98
- lockMovementY: !0,
99
- lockScalingX: !0,
100
- lockScalingY: !0,
101
- lockRotation: !0
102
- }) : t.set({
103
- evented: !0,
104
- selectable: !0,
105
- lockMovementX: !1,
106
- lockMovementY: !1,
107
- lockScalingX: !1,
108
- lockScalingY: !1
109
- });
110
- });
111
- };
112
- }, [e, i, f, n]);
113
- };
114
- export {
115
- O as useCanvasDrag
116
- };
@@ -1,115 +0,0 @@
1
- import { useEffect as V, useCallback as Z } from "react";
2
- import { fabric as o } from "fabric";
3
- import { CANVAS_CONTAINER_CLASS as q, BASE_STROKE_WIDTH as F } from "../../constants.mjs";
4
- const $ = ({
5
- sample: h,
6
- image: f,
7
- onImageLoad: y,
8
- canvasRef: w,
9
- containerRef: d,
10
- canvasInitializedRef: S,
11
- bgImagePositionRef: s,
12
- bgImageSizeRef: b,
13
- rectMapRef: U,
14
- updateTextLayersRef: j,
15
- onRectPositionUpdated: p,
16
- setCanvas: a,
17
- setImage: O,
18
- setScale: X,
19
- setBgImagePosition: Y,
20
- setLoading: C
21
- }) => (V(() => {
22
- if (C(!0), O(void 0), a((t) => (t && t.setBackgroundImage(void 0, t.renderAll.bind(t)), t)), s.current = {
23
- left: 0,
24
- top: 0
25
- }, !(h != null && h.fileUrl)) {
26
- C(!1);
27
- return;
28
- }
29
- o.Image.fromURL(h.fileUrl, (t) => {
30
- t.set({
31
- originX: "center",
32
- originY: "center"
33
- }), O(t), C(!1);
34
- }, {
35
- crossOrigin: "anonymous"
36
- });
37
- }, [h == null ? void 0 : h.fileUrl, O, C, s, a]), {
38
- updateCanvas: Z(() => {
39
- if (!f || !w.current || !d.current)
40
- return;
41
- S.current = !1;
42
- const t = f.getElement();
43
- if (!(t != null && t.width) || !(t != null && t.height))
44
- return;
45
- const N = d.current.offsetWidth, B = d.current.offsetHeight, _ = t.width / t.height, l = N, i = B;
46
- let r, c;
47
- if (t.width <= l && t.height <= i)
48
- r = 1, c = [t.width, t.height];
49
- else {
50
- const u = l / t.width, e = i / t.height;
51
- u > e ? c = [i * _, i] : c = [l, l / _];
52
- const k = c[0] / t.width, W = c[1] / t.height;
53
- r = Math.min(k, W);
54
- }
55
- s.current = {
56
- left: 0,
57
- top: 0
58
- }, a((u) => {
59
- let e = u;
60
- if (e)
61
- e.setDimensions({
62
- width: l,
63
- height: i
64
- });
65
- else {
66
- e = new o.Canvas(w.current, {
67
- containerClass: q,
68
- width: l,
69
- height: i
70
- }), e.selection = !1;
71
- const n = e;
72
- n.uniScaleKey = "", n.uniformScaling = !1, o.Object.prototype.hasRotatingPoint = !1, o.Object.prototype.lockRotation = !0, o.Object.prototype.lockUniScaling = !1, o.Object.prototype.objectCaching = !1, o.Object.prototype.statefullCache = !1, o.Object.prototype.noScaleCache = !1;
73
- }
74
- e.setViewportTransform([1, 0, 0, 1, 0, 0]), e.setZoom(r), X(r);
75
- const k = c[0], W = c[1], D = k / r, K = W / r, A = (l / r - D) / 2, H = (i / r - K) / 2;
76
- return s.current = {
77
- left: A,
78
- top: H
79
- }, b.current = {
80
- width: c[0] / r,
81
- height: c[1] / r
82
- }, Y({
83
- left: A,
84
- top: H
85
- }), e.setBackgroundImage(f, () => {
86
- S.current = !0, u && (U.current.forEach((n, x) => {
87
- const E = {
88
- x: n.shape.x + s.current.left,
89
- y: n.shape.y + s.current.top
90
- };
91
- x.set({
92
- left: E.x,
93
- top: E.y
94
- });
95
- const T = F / r;
96
- x.set({
97
- strokeWidth: T,
98
- strokeUniform: !0,
99
- objectCaching: !1,
100
- statefullCache: !1,
101
- noScaleCache: !1
102
- }), n.textLayouts && n.textLayouts.length > 0 && j.current && j.current(x, n);
103
- }), p && p(r)), e.renderAll(), u || y && y();
104
- }, {
105
- originX: "left",
106
- originY: "top",
107
- left: A,
108
- top: H
109
- }), e;
110
- });
111
- }, [f, w, d, S, s, b, U, j, p, a, X, Y, y])
112
- });
113
- export {
114
- $ as useCanvasSetup
115
- };
@@ -1,42 +0,0 @@
1
- var l = Math.pow;
2
- import { useCallback as h, useEffect as C } from "react";
3
- import { ZOOM_FACTOR as M, MAX_ZOOM as n, MIN_ZOOM as O } from "../../constants.mjs";
4
- const w = ({
5
- canvas: t,
6
- setScale: m,
7
- isZoomingRef: f
8
- }) => {
9
- const u = h((r, o) => {
10
- if (!t)
11
- return;
12
- o || (o = {
13
- x: t.getCenter().left,
14
- y: t.getCenter().top
15
- });
16
- let e = t.getZoom();
17
- e *= l(M, r), e > n && (e = n), e < O && (e = O), f.current = !0, t.zoomToPoint(o, e), m(e), requestAnimationFrame(() => {
18
- requestAnimationFrame(() => {
19
- f.current = !1;
20
- });
21
- });
22
- }, [t, m, f]);
23
- return C(() => {
24
- if (!t)
25
- return;
26
- const r = (o) => {
27
- const e = o.e, i = e.deltaY;
28
- u(i, {
29
- x: e.offsetX,
30
- y: e.offsetY
31
- });
32
- };
33
- return t.on("mouse:wheel", r), () => {
34
- t.off("mouse:wheel", r);
35
- };
36
- }, [t, u]), {
37
- zoom: u
38
- };
39
- };
40
- export {
41
- w as useCanvasZoom
42
- };
@@ -1,55 +0,0 @@
1
- var f = (r, p, n) => new Promise((i, a) => {
2
- var t = (o) => {
3
- try {
4
- c(n.next(o));
5
- } catch (s) {
6
- a(s);
7
- }
8
- }, e = (o) => {
9
- try {
10
- c(n.throw(o));
11
- } catch (s) {
12
- a(s);
13
- }
14
- }, c = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(t, e);
15
- c((n = n.apply(r, p)).next());
16
- });
17
- import { useCallback as l } from "react";
18
- import { IMAGE_EXPORT_FORMAT as A } from "../../constants.mjs";
19
- const _ = (r) => l((n) => f(void 0, null, function* () {
20
- if (r)
21
- return new Promise((i, a) => {
22
- const t = new Image();
23
- t.crossOrigin = "anonymous", t.onload = () => {
24
- try {
25
- const {
26
- x: e,
27
- y: c,
28
- width: o,
29
- height: s
30
- } = n.shape, x = e, M = e + o, w = c, I = c + s, T = 0, y = t.width, E = 0, L = t.height, d = Math.max(T, x), v = Math.min(y, M), u = Math.max(E, w), B = Math.min(L, I), m = Math.max(0, v - d), g = Math.max(0, B - u);
31
- if (m <= 0 || g <= 0) {
32
- i(void 0);
33
- return;
34
- }
35
- const C = d, O = u, h = document.createElement("canvas");
36
- h.width = m, h.height = g;
37
- const R = h.getContext("2d");
38
- if (!R) {
39
- i(void 0);
40
- return;
41
- }
42
- R.drawImage(t, C, O, m, g, 0, 0, m, g);
43
- const b = h.toDataURL(A);
44
- i(b);
45
- } catch (e) {
46
- a(e);
47
- }
48
- }, t.onerror = () => {
49
- a(new Error("Failed to load image"));
50
- }, t.src = r;
51
- });
52
- }), [r]);
53
- export {
54
- _ as useCropRegionImage
55
- };
@@ -1,51 +0,0 @@
1
- import { useRef as E, useEffect as I, useCallback as g } from "react";
2
- import { fabric as f } from "fabric";
3
- import { DELETE_CONTROL_OFFSET_X as O, DELETE_CONTROL_OFFSET_Y as C, DELETE_ICON_SIZE as T } from "../../constants.mjs";
4
- import _ from "../icons/del.png.mjs";
5
- const S = ({
6
- performDelete: a
7
- }) => {
8
- const i = (e) => !(!e.complete || e.naturalWidth === 0), n = E(null);
9
- return I(() => {
10
- if (!n.current) {
11
- const e = document.createElement("img");
12
- e.src = _, n.current = e;
13
- }
14
- }, []), {
15
- createDeleteControl: g(() => {
16
- const e = T, r = n.current, d = (t, o, s, D, l) => {
17
- if (!r)
18
- return;
19
- const c = () => {
20
- t.save(), t.translate(o, s), t.rotate(f.util.degreesToRadians(l.angle || 0)), t.drawImage(r, -e / 2, -e / 2, e, e), t.restore();
21
- };
22
- i(r) ? c() : r.onload = () => {
23
- c();
24
- const u = l.canvas;
25
- u && u.renderAll();
26
- };
27
- }, m = (t, o) => {
28
- const s = o.target;
29
- return a(s), !1;
30
- };
31
- return new f.Control({
32
- x: 0.5,
33
- // 右侧(0 = 左边,0.5 = 中间,1 = 右边)
34
- y: -0.5,
35
- // 顶部(0 = 顶部,0.5 = 中间,1 = 底部)
36
- offsetX: O,
37
- // 向右偏移,让按钮更靠近矩形边缘
38
- offsetY: C,
39
- // 向上偏移,让按钮更靠近矩形边缘
40
- cursorStyle: "pointer",
41
- mouseUpHandler: m,
42
- render: d,
43
- sizeX: e,
44
- sizeY: e
45
- });
46
- }, [a])
47
- };
48
- };
49
- export {
50
- S as useDeleteControl
51
- };