@pie-element/hotspot 11.1.2-next.2 → 11.1.2

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 (234) hide show
  1. package/CHANGELOG.json +997 -0
  2. package/CHANGELOG.md +2220 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +682 -0
  6. package/configure/CHANGELOG.md +1957 -0
  7. package/configure/lib/DeleteWidget.js +64 -0
  8. package/configure/lib/DeleteWidget.js.map +1 -0
  9. package/configure/lib/button.js +42 -0
  10. package/configure/lib/button.js.map +1 -0
  11. package/configure/lib/buttons/circle.js +33 -0
  12. package/configure/lib/buttons/circle.js.map +1 -0
  13. package/configure/lib/buttons/polygon.js +39 -0
  14. package/configure/lib/buttons/polygon.js.map +1 -0
  15. package/configure/lib/buttons/rectangle.js +39 -0
  16. package/configure/lib/buttons/rectangle.js.map +1 -0
  17. package/configure/lib/defaults.js +155 -0
  18. package/configure/lib/defaults.js.map +1 -0
  19. package/configure/lib/hotspot-circle.js +192 -0
  20. package/configure/lib/hotspot-circle.js.map +1 -0
  21. package/configure/lib/hotspot-container.js +320 -0
  22. package/configure/lib/hotspot-container.js.map +1 -0
  23. package/configure/lib/hotspot-drawable.js +519 -0
  24. package/configure/lib/hotspot-drawable.js.map +1 -0
  25. package/configure/lib/hotspot-palette.js +107 -0
  26. package/configure/lib/hotspot-palette.js.map +1 -0
  27. package/configure/lib/hotspot-polygon.js +293 -0
  28. package/configure/lib/hotspot-polygon.js.map +1 -0
  29. package/configure/lib/hotspot-rectangle.js +190 -0
  30. package/configure/lib/hotspot-rectangle.js.map +1 -0
  31. package/configure/lib/icons.js +7 -0
  32. package/configure/lib/icons.js.map +1 -0
  33. package/configure/lib/image-konva.js +66 -0
  34. package/configure/lib/image-konva.js.map +1 -0
  35. package/configure/lib/index.js +194 -0
  36. package/configure/lib/index.js.map +1 -0
  37. package/configure/lib/root.js +330 -0
  38. package/configure/lib/root.js.map +1 -0
  39. package/configure/lib/shapes/circle.js +84 -0
  40. package/configure/lib/shapes/circle.js.map +1 -0
  41. package/configure/lib/shapes/index.js +50 -0
  42. package/configure/lib/shapes/index.js.map +1 -0
  43. package/configure/lib/shapes/polygon.js +82 -0
  44. package/configure/lib/shapes/polygon.js.map +1 -0
  45. package/configure/lib/shapes/rectagle.js +84 -0
  46. package/configure/lib/shapes/rectagle.js.map +1 -0
  47. package/configure/lib/shapes/utils.js +21 -0
  48. package/configure/lib/shapes/utils.js.map +1 -0
  49. package/configure/lib/upload-control.js +41 -0
  50. package/configure/lib/upload-control.js.map +1 -0
  51. package/configure/lib/utils.js +185 -0
  52. package/configure/lib/utils.js.map +1 -0
  53. package/configure/package.json +26 -0
  54. package/configure/src/DeleteWidget.jsx +51 -0
  55. package/configure/src/__tests__/DeleteWidget.test.jsx +366 -0
  56. package/configure/src/__tests__/button.test.jsx +198 -0
  57. package/configure/src/__tests__/hotspot-circle.test.jsx +259 -0
  58. package/configure/src/__tests__/hotspot-container.test.js +366 -0
  59. package/configure/src/__tests__/hotspot-drawable.test.js +271 -0
  60. package/configure/src/__tests__/hotspot-palette.test.jsx +71 -0
  61. package/configure/src/__tests__/image-konva.test.jsx +226 -0
  62. package/configure/src/__tests__/index.test.js +329 -0
  63. package/configure/src/__tests__/root.test.js +400 -0
  64. package/configure/src/__tests__/utils.test.js +241 -0
  65. package/configure/src/button.jsx +35 -0
  66. package/configure/src/buttons/circle.jsx +18 -0
  67. package/configure/src/buttons/polygon.jsx +29 -0
  68. package/configure/src/buttons/rectangle.jsx +29 -0
  69. package/configure/src/defaults.js +109 -0
  70. package/configure/src/hotspot-circle.jsx +183 -0
  71. package/configure/src/hotspot-container.jsx +330 -0
  72. package/configure/src/hotspot-drawable.jsx +527 -0
  73. package/configure/src/hotspot-palette.jsx +90 -0
  74. package/configure/src/hotspot-polygon.jsx +294 -0
  75. package/configure/src/hotspot-rectangle.jsx +169 -0
  76. package/configure/src/icons.js +5 -0
  77. package/configure/src/image-konva.jsx +63 -0
  78. package/configure/src/index.js +208 -0
  79. package/configure/src/root.jsx +346 -0
  80. package/configure/src/shapes/circle.js +81 -0
  81. package/configure/src/shapes/index.js +4 -0
  82. package/configure/src/shapes/polygon.js +81 -0
  83. package/configure/src/shapes/rectagle.js +82 -0
  84. package/configure/src/shapes/utils.js +16 -0
  85. package/configure/src/upload-control.jsx +33 -0
  86. package/configure/src/utils.js +210 -0
  87. package/controller/CHANGELOG.json +362 -0
  88. package/controller/CHANGELOG.md +1304 -0
  89. package/controller/lib/defaults.js +33 -0
  90. package/controller/lib/defaults.js.map +1 -0
  91. package/controller/lib/index.js +341 -0
  92. package/controller/lib/index.js.map +1 -0
  93. package/controller/lib/utils.js +32 -0
  94. package/controller/lib/utils.js.map +1 -0
  95. package/controller/package.json +18 -0
  96. package/controller/src/__tests__/index.test.js +419 -0
  97. package/controller/src/__tests__/utils.test.js +5 -0
  98. package/controller/src/defaults.js +19 -0
  99. package/controller/src/index.js +328 -0
  100. package/controller/src/utils.js +29 -0
  101. package/docs/config-schema.json +2023 -0
  102. package/docs/config-schema.json.md +1495 -0
  103. package/docs/demo/config.js +8 -0
  104. package/docs/demo/generate.js +118 -0
  105. package/docs/demo/index.html +1 -0
  106. package/docs/demo/session.js +11 -0
  107. package/docs/pie-schema.json +1204 -0
  108. package/docs/pie-schema.json.md +851 -0
  109. package/lib/hotspot/circle.js +156 -0
  110. package/lib/hotspot/circle.js.map +1 -0
  111. package/lib/hotspot/container.js +206 -0
  112. package/lib/hotspot/container.js.map +1 -0
  113. package/lib/hotspot/icons.js +8 -0
  114. package/lib/hotspot/icons.js.map +1 -0
  115. package/lib/hotspot/image-konva-tooltip.js +86 -0
  116. package/lib/hotspot/image-konva-tooltip.js.map +1 -0
  117. package/lib/hotspot/index.js +163 -0
  118. package/lib/hotspot/index.js.map +1 -0
  119. package/lib/hotspot/polygon.js +203 -0
  120. package/lib/hotspot/polygon.js.map +1 -0
  121. package/lib/hotspot/rectangle.js +175 -0
  122. package/lib/hotspot/rectangle.js.map +1 -0
  123. package/lib/index.js +213 -0
  124. package/lib/index.js.map +1 -0
  125. package/lib/session-updater.js +42 -0
  126. package/lib/session-updater.js.map +1 -0
  127. package/package.json +18 -83
  128. package/src/__tests__/container.test.jsx +58 -0
  129. package/src/__tests__/index.test.js +123 -0
  130. package/src/__tests__/session-updater.test.jsx +69 -0
  131. package/src/hotspot/__tests__/circle.test.jsx +464 -0
  132. package/src/hotspot/__tests__/container.test.jsx +546 -0
  133. package/src/hotspot/__tests__/image-konva-tooltip.test.jsx +510 -0
  134. package/src/hotspot/__tests__/polygon.test.jsx +502 -0
  135. package/src/hotspot/__tests__/rectangle.test.jsx +418 -0
  136. package/src/hotspot/circle.jsx +152 -0
  137. package/src/hotspot/container.jsx +217 -0
  138. package/src/hotspot/icons.js +7 -0
  139. package/src/hotspot/image-konva-tooltip.jsx +76 -0
  140. package/src/hotspot/index.jsx +165 -0
  141. package/src/hotspot/polygon.jsx +195 -0
  142. package/src/hotspot/rectangle.jsx +171 -0
  143. package/src/index.js +226 -0
  144. package/src/session-updater.js +29 -0
  145. package/configure.js +0 -2
  146. package/controller.js +0 -1
  147. package/dist/author/DeleteWidget.d.ts +0 -38
  148. package/dist/author/DeleteWidget.js +0 -46
  149. package/dist/author/button.d.ts +0 -31
  150. package/dist/author/button.js +0 -27
  151. package/dist/author/buttons/circle.d.ts +0 -18
  152. package/dist/author/buttons/circle.js +0 -25
  153. package/dist/author/buttons/polygon.d.ts +0 -18
  154. package/dist/author/buttons/polygon.js +0 -36
  155. package/dist/author/buttons/rectangle.d.ts +0 -18
  156. package/dist/author/buttons/rectangle.js +0 -36
  157. package/dist/author/defaults.d.ts +0 -157
  158. package/dist/author/defaults.js +0 -119
  159. package/dist/author/hotspot-circle.d.ts +0 -21
  160. package/dist/author/hotspot-circle.js +0 -124
  161. package/dist/author/hotspot-container.d.ts +0 -29
  162. package/dist/author/hotspot-container.js +0 -210
  163. package/dist/author/hotspot-drawable.d.ts +0 -31
  164. package/dist/author/hotspot-drawable.js +0 -312
  165. package/dist/author/hotspot-palette.d.ts +0 -14
  166. package/dist/author/hotspot-palette.js +0 -72
  167. package/dist/author/hotspot-polygon.d.ts +0 -38
  168. package/dist/author/hotspot-polygon.js +0 -200
  169. package/dist/author/hotspot-rectangle.d.ts +0 -20
  170. package/dist/author/hotspot-rectangle.js +0 -119
  171. package/dist/author/icons.d.ts +0 -9
  172. package/dist/author/icons.js +0 -4
  173. package/dist/author/image-konva.d.ts +0 -19
  174. package/dist/author/image-konva.js +0 -49
  175. package/dist/author/index.d.ts +0 -52
  176. package/dist/author/index.js +0 -143
  177. package/dist/author/root.d.ts +0 -15
  178. package/dist/author/root.js +0 -215
  179. package/dist/author/shapes/circle.d.ts +0 -18
  180. package/dist/author/shapes/circle.js +0 -47
  181. package/dist/author/shapes/index.d.ts +0 -12
  182. package/dist/author/shapes/polygon.d.ts +0 -19
  183. package/dist/author/shapes/polygon.js +0 -51
  184. package/dist/author/shapes/rectagle.d.ts +0 -18
  185. package/dist/author/shapes/rectagle.js +0 -57
  186. package/dist/author/shapes/utils.d.ts +0 -19
  187. package/dist/author/shapes/utils.js +0 -16
  188. package/dist/author/upload-control.d.ts +0 -29
  189. package/dist/author/upload-control.js +0 -28
  190. package/dist/author/utils.d.ts +0 -24
  191. package/dist/author/utils.js +0 -83
  192. package/dist/browser/ReactKonva-DI5WIo8o.js +0 -19336
  193. package/dist/browser/ReactKonva-DI5WIo8o.js.map +0 -1
  194. package/dist/browser/author/index.js +0 -41646
  195. package/dist/browser/author/index.js.map +0 -1
  196. package/dist/browser/browser-CfnAFove.js +0 -219
  197. package/dist/browser/browser-CfnAFove.js.map +0 -1
  198. package/dist/browser/controller/index.js +0 -198
  199. package/dist/browser/controller/index.js.map +0 -1
  200. package/dist/browser/delivery/index.js +0 -2460
  201. package/dist/browser/delivery/index.js.map +0 -1
  202. package/dist/browser/dist-C78LDz6R.js +0 -96
  203. package/dist/browser/dist-C78LDz6R.js.map +0 -1
  204. package/dist/browser/hotspot.css +0 -2
  205. package/dist/controller/defaults.d.ts +0 -35
  206. package/dist/controller/defaults.js +0 -29
  207. package/dist/controller/index.d.ts +0 -22
  208. package/dist/controller/index.js +0 -154
  209. package/dist/controller/utils.d.ts +0 -10
  210. package/dist/controller/utils.js +0 -12
  211. package/dist/delivery/hotspot/circle.d.ts +0 -19
  212. package/dist/delivery/hotspot/circle.js +0 -100
  213. package/dist/delivery/hotspot/container.d.ts +0 -16
  214. package/dist/delivery/hotspot/container.js +0 -150
  215. package/dist/delivery/hotspot/icons.d.ts +0 -10
  216. package/dist/delivery/hotspot/icons.js +0 -4
  217. package/dist/delivery/hotspot/image-konva-tooltip.d.ts +0 -19
  218. package/dist/delivery/hotspot/image-konva-tooltip.js +0 -66
  219. package/dist/delivery/hotspot/index.d.ts +0 -17
  220. package/dist/delivery/hotspot/index.js +0 -114
  221. package/dist/delivery/hotspot/polygon.d.ts +0 -21
  222. package/dist/delivery/hotspot/polygon.js +0 -108
  223. package/dist/delivery/hotspot/rectangle.d.ts +0 -19
  224. package/dist/delivery/hotspot/rectangle.js +0 -104
  225. package/dist/delivery/index.d.ts +0 -20
  226. package/dist/delivery/index.js +0 -107
  227. package/dist/delivery/session-updater.d.ts +0 -10
  228. package/dist/delivery/session-updater.js +0 -14
  229. package/dist/index.d.ts +0 -1
  230. package/dist/index.iife.d.ts +0 -8
  231. package/dist/index.iife.js +0 -169
  232. package/dist/index.js +0 -2
  233. package/dist/runtime-support.d.ts +0 -12
  234. package/dist/runtime-support.js +0 -12
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.RectangleShape = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ class RectangleShape {
10
+ static create(shapes, e) {
11
+ const newShapes = [...shapes];
12
+ const highestId = Math.max(...newShapes.map(shape => parseInt(shape.id)), 0) || 0;
13
+ const newRectangle = {
14
+ id: `${highestId + 1}`,
15
+ height: 0,
16
+ width: 0,
17
+ x: e.evt.layerX,
18
+ y: e.evt.layerY,
19
+ group: 'rectangles',
20
+ index: newShapes.length
21
+ };
22
+ newShapes.push(newRectangle);
23
+ return {
24
+ shapes: newShapes,
25
+ isDrawing: true,
26
+ isDrawingShapeId: newRectangle.id
27
+ };
28
+ }
29
+ static finalizeCreation(state, props) {
30
+ const currentShapeIndex = state.shapes.findIndex(shape => shape.id === state.isDrawingShapeId);
31
+ if (currentShapeIndex !== -1) {
32
+ const currentShape = state.shapes[currentShapeIndex];
33
+
34
+ // Check if the shape is a valid rectangle (has more than 0 width and height) before finalizing
35
+ if (currentShape.width > 0 && currentShape.height > 0) {
36
+ return {
37
+ ...state,
38
+ isDrawing: false,
39
+ stateShapes: false,
40
+ isDrawingShapeId: undefined
41
+ };
42
+ } else {
43
+ return {
44
+ ...state,
45
+ isDrawing: false,
46
+ stateShapes: false,
47
+ isDrawingShapeId: undefined,
48
+ shapes: state.shapes.filter(shape => shape.id !== state.isDrawingShapeId)
49
+ };
50
+ }
51
+ }
52
+
53
+ // Return current state if not drawing a rectangle
54
+ return {
55
+ ...state,
56
+ isDrawing: false,
57
+ stateShapes: false,
58
+ isDrawingShapeId: undefined
59
+ };
60
+ }
61
+ static handleMouseMove(state, e) {
62
+ const {
63
+ isDrawing,
64
+ isDrawingShapeId,
65
+ shapes
66
+ } = state;
67
+ if (isDrawing) {
68
+ const tempShapes = [...shapes];
69
+ const resizingShapeIndex = tempShapes.findIndex(shape => shape.id === isDrawingShapeId);
70
+ if (resizingShapeIndex !== -1) {
71
+ const resizingShape = tempShapes[resizingShapeIndex];
72
+ resizingShape.width = e.evt.layerX - resizingShape.x;
73
+ resizingShape.height = e.evt.layerY - resizingShape.y;
74
+ return {
75
+ shapes: tempShapes
76
+ };
77
+ }
78
+ }
79
+ return state;
80
+ }
81
+ }
82
+ exports.RectangleShape = RectangleShape;
83
+ (0, _defineProperty2.default)(RectangleShape, "name", 'rectangle');
84
+ //# sourceMappingURL=rectagle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectagle.js","names":["RectangleShape","create","shapes","e","newShapes","highestId","Math","max","map","shape","parseInt","id","newRectangle","height","width","x","evt","layerX","y","layerY","group","index","length","push","isDrawing","isDrawingShapeId","finalizeCreation","state","props","currentShapeIndex","findIndex","currentShape","stateShapes","undefined","filter","handleMouseMove","tempShapes","resizingShapeIndex","resizingShape","exports","_defineProperty2","default"],"sources":["../../src/shapes/rectagle.js"],"sourcesContent":["export class RectangleShape {\n static name = 'rectangle'\n\n static create(shapes, e) {\n const newShapes = [...shapes];\n const highestId = Math.max(...newShapes.map((shape) => parseInt(shape.id)), 0) || 0;\n\n const newRectangle = {\n id: `${highestId + 1}`,\n height: 0,\n width: 0,\n x: e.evt.layerX,\n y: e.evt.layerY,\n group: 'rectangles',\n index: newShapes.length,\n };\n\n newShapes.push(newRectangle);\n\n return {\n shapes: newShapes,\n isDrawing: true,\n isDrawingShapeId: newRectangle.id,\n };\n }\n\n static finalizeCreation(state, props) {\n const currentShapeIndex = state.shapes.findIndex((shape) => shape.id === state.isDrawingShapeId);\n\n if (currentShapeIndex !== -1) {\n const currentShape = state.shapes[currentShapeIndex];\n\n // Check if the shape is a valid rectangle (has more than 0 width and height) before finalizing\n if (currentShape.width > 0 && currentShape.height > 0) {\n return {\n ...state,\n isDrawing: false,\n stateShapes: false,\n isDrawingShapeId: undefined,\n };\n } else {\n return {\n ...state,\n isDrawing: false,\n stateShapes: false,\n isDrawingShapeId: undefined,\n shapes: state.shapes.filter((shape) => shape.id !== state.isDrawingShapeId),\n };\n }\n }\n\n // Return current state if not drawing a rectangle\n return {\n ...state,\n isDrawing: false,\n stateShapes: false,\n isDrawingShapeId: undefined,\n };\n }\n\n static handleMouseMove(state, e) {\n const { isDrawing, isDrawingShapeId, shapes } = state;\n\n if (isDrawing) {\n const tempShapes = [...shapes];\n const resizingShapeIndex = tempShapes.findIndex((shape) => shape.id === isDrawingShapeId);\n\n if (resizingShapeIndex !== -1) {\n const resizingShape = tempShapes[resizingShapeIndex];\n\n resizingShape.width = e.evt.layerX - resizingShape.x;\n resizingShape.height = e.evt.layerY - resizingShape.y;\n\n return {\n shapes: tempShapes,\n };\n }\n }\n\n return state;\n }\n}\n"],"mappings":";;;;;;;;AAAO,MAAMA,cAAc,CAAC;EAG1B,OAAOC,MAAMA,CAACC,MAAM,EAAEC,CAAC,EAAE;IACvB,MAAMC,SAAS,GAAG,CAAC,GAAGF,MAAM,CAAC;IAC7B,MAAMG,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,GAAGH,SAAS,CAACI,GAAG,CAAEC,KAAK,IAAKC,QAAQ,CAACD,KAAK,CAACE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC;IAEnF,MAAMC,YAAY,GAAG;MACnBD,EAAE,EAAE,GAAGN,SAAS,GAAG,CAAC,EAAE;MACtBQ,MAAM,EAAE,CAAC;MACTC,KAAK,EAAE,CAAC;MACRC,CAAC,EAAEZ,CAAC,CAACa,GAAG,CAACC,MAAM;MACfC,CAAC,EAAEf,CAAC,CAACa,GAAG,CAACG,MAAM;MACfC,KAAK,EAAE,YAAY;MACnBC,KAAK,EAAEjB,SAAS,CAACkB;IACnB,CAAC;IAEDlB,SAAS,CAACmB,IAAI,CAACX,YAAY,CAAC;IAE5B,OAAO;MACLV,MAAM,EAAEE,SAAS;MACjBoB,SAAS,EAAE,IAAI;MACfC,gBAAgB,EAAEb,YAAY,CAACD;IACjC,CAAC;EACH;EAEA,OAAOe,gBAAgBA,CAACC,KAAK,EAAEC,KAAK,EAAE;IACpC,MAAMC,iBAAiB,GAAGF,KAAK,CAACzB,MAAM,CAAC4B,SAAS,CAAErB,KAAK,IAAKA,KAAK,CAACE,EAAE,KAAKgB,KAAK,CAACF,gBAAgB,CAAC;IAEhG,IAA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pDuB,aAAa,CAACzB,MAAM,GAAGV,CAAC,CAACa,GAAG,CAACG,MAAM,GAAGmB,aAAa,CAACpB,CAAC;QAErD,OAAO;UACLhB,MAAM,EAAEkC;QACV,CAAC;MACH;IACF;IAEA,OAAOT,KAAK;EACd;AACF;AAACY,OAAA,CAAAvC,cAAA,GAAAA,cAAA;AAAA,IAAAwC,gBAAA,CAAAC,OAAA,EAjFYzC,cAAc,UACX,WAAW","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SUPPORTED_SHAPES = exports.SHAPE_GROUPS = void 0;
7
+ var _circle = require("./circle");
8
+ var _polygon = require("./polygon");
9
+ var _rectagle = require("./rectagle");
10
+ const SUPPORTED_SHAPES = exports.SUPPORTED_SHAPES = {
11
+ CIRCLE: _circle.CircleShape.name,
12
+ POLYGON: _polygon.PolygonShape.name,
13
+ RECTANGLE: _rectagle.RectangleShape.name,
14
+ NONE: 'none'
15
+ };
16
+ const SHAPE_GROUPS = exports.SHAPE_GROUPS = {
17
+ CIRCLES: 'circles',
18
+ POLYGONS: 'polygons',
19
+ RECTANGLES: 'rectangles'
20
+ };
21
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["_circle","require","_polygon","_rectagle","SUPPORTED_SHAPES","exports","CIRCLE","CircleShape","name","POLYGON","PolygonShape","RECTANGLE","RectangleShape","NONE","SHAPE_GROUPS","CIRCLES","POLYGONS","RECTANGLES"],"sources":["../../src/shapes/utils.js"],"sourcesContent":["import { CircleShape } from './circle';\nimport { PolygonShape } from './polygon';\nimport { RectangleShape } from './rectagle';\n\nexport const SUPPORTED_SHAPES = {\n CIRCLE: CircleShape.name,\n POLYGON: PolygonShape.name,\n RECTANGLE: RectangleShape.name,\n NONE: 'none',\n};\n\nexport const SHAPE_GROUPS = {\n CIRCLES: 'circles',\n POLYGONS: 'polygons',\n RECTANGLES: 'rectangles',\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG;EAC9BE,MAAM,EAAEC,mBAAW,CAACC,IAAI;EACxBC,OAAO,EAAEC,qBAAY,CAACF,IAAI;EAC1BG,SAAS,EAAEC,wBAAc,CAACJ,IAAI;EAC9BK,IAAI,EAAE;AACR,CAAC;AAEM,MAAMC,YAAY,GAAAT,OAAA,CAAAS,YAAA,GAAG;EAC1BC,OAAO,EAAE,SAAS;EAClBC,QAAQ,EAAE,UAAU;EACpBC,UAAU,EAAE;AACd,CAAC","ignoreList":[]}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _button = _interopRequireDefault(require("./button"));
11
+ const UploadControl = ({
12
+ label,
13
+ onInputClick,
14
+ onUploadImage,
15
+ setRef
16
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_button.default, {
17
+ label: label,
18
+ onClick: onInputClick
19
+ }), /*#__PURE__*/_react.default.createElement("input", {
20
+ accept: "image/*",
21
+ style: {
22
+ display: 'none'
23
+ },
24
+ onChange: onUploadImage,
25
+ ref: ref => {
26
+ setRef(ref);
27
+ },
28
+ type: "file"
29
+ }));
30
+ UploadControl.propTypes = {
31
+ label: _propTypes.default.string.isRequired,
32
+ onInputClick: _propTypes.default.func.isRequired,
33
+ onUploadImage: _propTypes.default.func.isRequired,
34
+ setRef: _propTypes.default.func.isRequired
35
+ };
36
+ UploadControl.defaultProps = {
37
+ classNameButton: '',
38
+ classNameSection: ''
39
+ };
40
+ var _default = exports.default = UploadControl;
41
+ //# sourceMappingURL=upload-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-control.js","names":["_react","_interopRequireDefault","require","_propTypes","_button","UploadControl","label","onInputClick","onUploadImage","setRef","default","createElement","Fragment","onClick","accept","style","display","onChange","ref","type","propTypes","PropTypes","string","isRequired","func","defaultProps","classNameButton","classNameSection","_default","exports"],"sources":["../src/upload-control.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nimport Button from './button';\n\nconst UploadControl = ({ label, onInputClick, onUploadImage, setRef }) => (\n <>\n <Button label={label} onClick={onInputClick} />\n <input\n accept=\"image/*\"\n style={{ display: 'none' }}\n onChange={onUploadImage}\n ref={(ref) => {\n setRef(ref);\n }}\n type=\"file\"\n />\n </>\n);\n\nUploadControl.propTypes = {\n label: PropTypes.string.isRequired,\n onInputClick: PropTypes.func.isRequired,\n onUploadImage: PropTypes.func.isRequired,\n setRef: PropTypes.func.isRequired,\n};\n\nUploadControl.defaultProps = {\n classNameButton: '',\n classNameSection: '',\n};\n\nexport default UploadControl;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,MAAMG,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC,YAAY;EAAEC,aAAa;EAAEC;AAAO,CAAC,kBACnET,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAAAX,MAAA,CAAAU,OAAA,CAAAE,QAAA,qBACEZ,MAAA,CAAAU,OAAA,CAAAC,aAAA,CAACP,OAAA,CAAAM,OAAM;EAACJ,KAAK,EAAEA,KAAM;EAACO,OAAO,EAAEN;AAAa,CAAE,CAAC,eAC/CP,MAAA,CAAAU,OAAA,CAAAC,aAAA;EACEG,MAAM,EAAC,SAAS;EAChBC,KAAK,EAAE;IAAEC,OAAO,EAAE;EAAO,CAAE;EAC3BC,QAAQ,EAAET,aAAc;EACxBU,GAAG,EAAGA,GAAG,IAAK;IACZT,MAAM,CAACS,GAAG,CAAC;EACb,CAAE;EACFC,IAAI,EAAC;AAAM,CACZ,CACD,CACH;AAEDd,aAAa,CAACe,SAAS,GAAG;EACxBd,KAAK,EAAEe,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClChB,YAAY,EAAEc,kBAAS,CAACG,IAAI,CAACD,UAAU;EACvCf,aAAa,EAAEa,kBAAS,CAACG,IAAI,CAACD,UAAU;EACxCd,MAAM,EAAEY,kBAAS,CAACG,IAAI,CAACD;AACzB,CAAC;AAEDlB,aAAa,CAACoB,YAAY,GAAG;EAC3BC,eAAe,EAAE,EAAE;EACnBC,gBAAgB,EAAE;AACpB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAnB,OAAA,GAEaL,aAAa","ignoreList":[]}
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.updateImageDimensions = exports.isPointInsidePolygon = exports.groupShapes = exports.getUpdatedShapes = exports.getUpdatedRectangle = exports.getUpdatedPolygon = exports.getAllShapes = exports.generateValidationMessage = exports.calculate = void 0;
7
+ var _lodashEs = require("lodash-es");
8
+ var _shapes = require("./shapes");
9
+ const updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => {
10
+ // if we want to keep image aspect ratio
11
+ if (keepAspectRatio) {
12
+ const imageAspectRatio = initialDim.width / initialDim.height;
13
+ if (resizeType === 'height') {
14
+ // if we want to change image height => we update the width accordingly
15
+ return {
16
+ width: nextDim.height * imageAspectRatio,
17
+ height: nextDim.height
18
+ };
19
+ }
20
+
21
+ // if we want to change image width => we update the height accordingly
22
+ return {
23
+ width: nextDim.width,
24
+ height: nextDim.width / imageAspectRatio
25
+ };
26
+ }
27
+
28
+ // if we don't want to keep aspect ratio, we just update both values
29
+ return {
30
+ width: nextDim.width,
31
+ height: nextDim.height
32
+ };
33
+ };
34
+
35
+ // referenceInitialValue = the initial value of the Stage
36
+ // referenceNextValue = the next value of the Stage
37
+ // currentValue = the value that has to be re-sized influenced by the changes that were made on the Stage
38
+ exports.updateImageDimensions = updateImageDimensions;
39
+ const getDelta = (referenceInitialValue, referenceNextValue, currentValue) => referenceNextValue / referenceInitialValue * currentValue;
40
+ const getUpdatedRectangle = (initialDim, nextDim, shape) => ({
41
+ ...shape,
42
+ width: getDelta(initialDim.width, nextDim.width, shape.width),
43
+ height: getDelta(initialDim.height, nextDim.height, shape.height),
44
+ x: getDelta(initialDim.width, nextDim.width, shape.x),
45
+ y: getDelta(initialDim.height, nextDim.height, shape.y)
46
+ });
47
+ exports.getUpdatedRectangle = getUpdatedRectangle;
48
+ const getUpdatedCircles = (initialDim, nextDim, shape) => ({
49
+ ...shape,
50
+ radius: getDelta(initialDim.width, nextDim.width, shape.radius),
51
+ x: getDelta(initialDim.width, nextDim.width, shape.x),
52
+ y: getDelta(initialDim.height, nextDim.height, shape.y)
53
+ });
54
+ const getUpdatedPolygon = (initialDim, nextDim, shape) => ({
55
+ ...shape,
56
+ points: shape.points.map(point => ({
57
+ x: getDelta(initialDim.width, nextDim.width, point.x),
58
+ y: getDelta(initialDim.height, nextDim.height, point.y)
59
+ }))
60
+ });
61
+
62
+ // initialDim = the initial dimensions: { width, height } of the Stage
63
+ // nextDim = the next dimensions: { width, height } of the Stage
64
+ // shapes = array of shapes that have to be re-sized and re-positioned
65
+ exports.getUpdatedPolygon = getUpdatedPolygon;
66
+ const getUpdatedShapes = (initialDim, nextDim, shapes) => {
67
+ return shapes.map(shape => {
68
+ if (shape.group === _shapes.SHAPE_GROUPS.RECTANGLES) {
69
+ return getUpdatedRectangle(initialDim, nextDim, shape);
70
+ }
71
+ if (shape.group === _shapes.SHAPE_GROUPS.POLYGONS) {
72
+ return getUpdatedPolygon(initialDim, nextDim, shape);
73
+ }
74
+ if (shape.group === _shapes.SHAPE_GROUPS.CIRCLES) {
75
+ return getUpdatedCircles(initialDim, nextDim, shape);
76
+ }
77
+ });
78
+ };
79
+
80
+ // converts shapes map to shapes array
81
+ // example:
82
+ // from: { rectangles: [r1], polygons: [p1, p2]}
83
+ // to: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]
84
+ // if a shape has index defined, keep it, otherwise initialize it
85
+ // index is used for the UNDO function
86
+ exports.getUpdatedShapes = getUpdatedShapes;
87
+ const getAllShapes = shapesMap => {
88
+ shapesMap = shapesMap || {};
89
+ const shapesArray = [];
90
+ const shapesKeys = Object.keys(shapesMap);
91
+ return shapesKeys.length ? shapesKeys.reduce((acc, currentShapeKey) => acc.concat(shapesMap[currentShapeKey] ? shapesMap[currentShapeKey].map((shape, index) => ({
92
+ ...shape,
93
+ group: currentShapeKey,
94
+ index: shape.index || acc.length + index
95
+ })) : []), shapesArray) : shapesArray;
96
+ };
97
+
98
+ // converts shapes array to shapes map
99
+ // is the reverse of getAllShapes function
100
+ // example:
101
+ // from: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]
102
+ // to: { rectangles: [r1], polygons: [p1, p2]}
103
+ exports.getAllShapes = getAllShapes;
104
+ const groupShapes = shapesArray => {
105
+ shapesArray = shapesArray || [];
106
+ const shapesMap = {
107
+ rectangles: [],
108
+ polygons: [],
109
+ circles: []
110
+ };
111
+ if (shapesArray.length) {
112
+ return shapesArray.reduce((acc, {
113
+ group,
114
+ ...shapeProps
115
+ }) => {
116
+ acc[group] = [...(acc[group] || []), shapeProps];
117
+ return acc;
118
+ }, shapesMap);
119
+ }
120
+ return (0, _lodashEs.cloneDeep)(shapesMap);
121
+ };
122
+ exports.groupShapes = groupShapes;
123
+ const isPointInsidePolygon = (polygon, x, y) => {
124
+ let inside = false;
125
+ if (!polygon || polygon.length <= 0) {
126
+ return inside;
127
+ }
128
+ for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
129
+ const xi = polygon[i].x;
130
+ const yi = polygon[i].y;
131
+ const xj = polygon[j].x;
132
+ const yj = polygon[j].y;
133
+ const intersect = yi > y !== yj > y && x < (xj - xi) * (y - yi) / (yj - yi) + xi;
134
+ if (intersect) {
135
+ inside = !inside;
136
+ }
137
+ }
138
+ return inside;
139
+ };
140
+ exports.isPointInsidePolygon = isPointInsidePolygon;
141
+ const calculate = polygonPoints => {
142
+ if (!polygonPoints || polygonPoints.length <= 0) {
143
+ return {
144
+ x: 0,
145
+ y: 0
146
+ };
147
+ }
148
+ const xPoints = polygonPoints.map(point => point.x);
149
+ const yPoints = polygonPoints.map(point => point.y);
150
+ const minX = Math.min(...xPoints);
151
+ const minY = Math.min(...yPoints);
152
+ const maxX = Math.max(...xPoints);
153
+ const maxY = Math.max(...yPoints);
154
+
155
+ // Find a suitable position for the text element within the polygon
156
+ let textX, textY;
157
+ for (let x = minX; x <= maxX - 20; x++) {
158
+ for (let y = maxY - 20; y > minY; y--) {
159
+ // Check if the text element's position (x, y) is within the polygon
160
+ if (isPointInsidePolygon(polygonPoints, x, y)) {
161
+ textX = x - 10;
162
+ textY = y;
163
+ break;
164
+ }
165
+ }
166
+ }
167
+ return {
168
+ x: textX,
169
+ y: textY
170
+ };
171
+ };
172
+ exports.calculate = calculate;
173
+ const generateValidationMessage = config => {
174
+ const {
175
+ minShapes,
176
+ maxShapes,
177
+ maxSelections
178
+ } = config;
179
+ const shapesMessage = `\nThere should be at least ${minShapes} ` + (maxShapes ? `and at most ${maxShapes} ` : '') + 'shapes defined.';
180
+ const selectionsMessage = '\nThere should be at least 1 ' + (maxSelections ? `and at most ${maxSelections} ` : '') + 'shape' + (maxSelections ? 's' : '') + ' selected.';
181
+ const message = 'Validation requirements:' + shapesMessage + selectionsMessage;
182
+ return message;
183
+ };
184
+ exports.generateValidationMessage = generateValidationMessage;
185
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["_lodashEs","require","_shapes","updateImageDimensions","initialDim","nextDim","keepAspectRatio","resizeType","imageAspectRatio","width","height","exports","getDelta","referenceInitialValue","referenceNextValue","currentValue","getUpdatedRectangle","shape","x","y","getUpdatedCircles","radius","getUpdatedPolygon","points","map","point","getUpdatedShapes","shapes","group","SHAPE_GROUPS","RECTANGLES","POLYGONS","CIRCLES","getAllShapes","shapesMap","shapesArray","shapesKeys","Object","keys","length","reduce","acc","currentShapeKey","concat","index","groupShapes","rectangles","polygons","circles","shapeProps","cloneDeep","isPointInsidePolygon","polygon","inside","i","j","xi","yi","xj","yj","intersect","calculate","polygonPoints","xPoints","yPoints","minX","Math","min","minY","maxX","max","maxY","textX","textY","generateValidationMessage","config","minShapes","maxShapes","maxSelections","shapesMessage","selectionsMessage","message"],"sources":["../src/utils.js"],"sourcesContent":["import { cloneDeep } from 'lodash-es';\nimport { SHAPE_GROUPS } from './shapes';\n\nconst updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => {\n // if we want to keep image aspect ratio\n if (keepAspectRatio) {\n const imageAspectRatio = initialDim.width / initialDim.height;\n\n if (resizeType === 'height') {\n // if we want to change image height => we update the width accordingly\n return {\n width: nextDim.height * imageAspectRatio,\n height: nextDim.height,\n };\n }\n\n // if we want to change image width => we update the height accordingly\n return {\n width: nextDim.width,\n height: nextDim.width / imageAspectRatio,\n };\n }\n\n // if we don't want to keep aspect ratio, we just update both values\n return {\n width: nextDim.width,\n height: nextDim.height,\n };\n};\n\n// referenceInitialValue = the initial value of the Stage\n// referenceNextValue = the next value of the Stage\n// currentValue = the value that has to be re-sized influenced by the changes that were made on the Stage\nconst getDelta = (referenceInitialValue, referenceNextValue, currentValue) =>\n (referenceNextValue / referenceInitialValue) * currentValue;\n\nconst getUpdatedRectangle = (initialDim, nextDim, shape) => ({\n ...shape,\n width: getDelta(initialDim.width, nextDim.width, shape.width),\n height: getDelta(initialDim.height, nextDim.height, shape.height),\n x: getDelta(initialDim.width, nextDim.width, shape.x),\n y: getDelta(initialDim.height, nextDim.height, shape.y),\n});\n\nconst getUpdatedCircles = (initialDim, nextDim, shape) => ({\n ...shape,\n radius: getDelta(initialDim.width, nextDim.width, shape.radius),\n x: getDelta(initialDim.width, nextDim.width, shape.x),\n y: getDelta(initialDim.height, nextDim.height, shape.y),\n});\n\nconst getUpdatedPolygon = (initialDim, nextDim, shape) => ({\n ...shape,\n points: shape.points.map((point) => ({\n x: getDelta(initialDim.width, nextDim.width, point.x),\n y: getDelta(initialDim.height, nextDim.height, point.y),\n })),\n});\n\n// initialDim = the initial dimensions: { width, height } of the Stage\n// nextDim = the next dimensions: { width, height } of the Stage\n// shapes = array of shapes that have to be re-sized and re-positioned\nconst getUpdatedShapes = (initialDim, nextDim, shapes) => {\n return shapes.map((shape) => {\n if (shape.group === SHAPE_GROUPS.RECTANGLES) {\n return getUpdatedRectangle(initialDim, nextDim, shape);\n }\n\n if (shape.group === SHAPE_GROUPS.POLYGONS) {\n return getUpdatedPolygon(initialDim, nextDim, shape);\n }\n\n if (shape.group === SHAPE_GROUPS.CIRCLES) {\n return getUpdatedCircles(initialDim, nextDim, shape);\n }\n });\n};\n\n// converts shapes map to shapes array\n// example:\n// from: { rectangles: [r1], polygons: [p1, p2]}\n// to: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// if a shape has index defined, keep it, otherwise initialize it\n// index is used for the UNDO function\nconst getAllShapes = (shapesMap) => {\n shapesMap = shapesMap || {};\n const shapesArray = [];\n const shapesKeys = Object.keys(shapesMap);\n\n return shapesKeys.length\n ? shapesKeys.reduce(\n (acc, currentShapeKey) =>\n acc.concat(\n shapesMap[currentShapeKey]\n ? shapesMap[currentShapeKey].map((shape, index) => ({\n ...shape,\n group: currentShapeKey,\n index: shape.index || acc.length + index,\n }))\n : [],\n ),\n shapesArray,\n )\n : shapesArray;\n};\n\n// converts shapes array to shapes map\n// is the reverse of getAllShapes function\n// example:\n// from: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// to: { rectangles: [r1], polygons: [p1, p2]}\nconst groupShapes = (shapesArray) => {\n shapesArray = shapesArray || [];\n const shapesMap = {\n rectangles: [],\n polygons: [],\n circles: [],\n };\n\n if (shapesArray.length) {\n return shapesArray.reduce((acc, { group, ...shapeProps }) => {\n acc[group] = [...(acc[group] || []), shapeProps];\n return acc;\n }, shapesMap);\n }\n\n return cloneDeep(shapesMap);\n};\n\nconst isPointInsidePolygon = (polygon, x, y) => {\n let inside = false;\n\n if (!polygon || polygon.length <= 0) {\n return inside;\n }\n\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x;\n const yi = polygon[i].y;\n const xj = polygon[j].x;\n const yj = polygon[j].y;\n\n const intersect = yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;\n\n if (intersect) {\n inside = !inside;\n }\n }\n\n return inside;\n};\n\nconst calculate = (polygonPoints) => {\n if (!polygonPoints || polygonPoints.length <= 0) {\n return { x: 0, y: 0 };\n }\n\n const xPoints = polygonPoints.map((point) => point.x);\n const yPoints = polygonPoints.map((point) => point.y);\n const minX = Math.min(...xPoints);\n const minY = Math.min(...yPoints);\n const maxX = Math.max(...xPoints);\n const maxY = Math.max(...yPoints);\n\n // Find a suitable position for the text element within the polygon\n let textX, textY;\n\n for (let x = minX; x <= maxX - 20; x++) {\n for (let y = maxY - 20; y > minY; y--) {\n // Check if the text element's position (x, y) is within the polygon\n if (isPointInsidePolygon(polygonPoints, x, y)) {\n textX = x - 10;\n textY = y;\n break;\n }\n }\n }\n\n return { x: textX, y: textY };\n};\n\nconst generateValidationMessage = (config) => {\n const { minShapes, maxShapes, maxSelections } = config;\n\n const shapesMessage =\n `\\nThere should be at least ${minShapes} ` + (maxShapes ? `and at most ${maxShapes} ` : '') + 'shapes defined.';\n\n const selectionsMessage =\n '\\nThere should be at least 1 ' +\n (maxSelections ? `and at most ${maxSelections} ` : '') +\n 'shape' +\n (maxSelections ? 's' : '') +\n ' selected.';\n\n const message = 'Validation requirements:' + shapesMessage + selectionsMessage;\n\n return message;\n};\n\nexport {\n calculate,\n isPointInsidePolygon,\n updateImageDimensions,\n generateValidationMessage,\n getUpdatedShapes,\n getAllShapes,\n groupShapes,\n getUpdatedRectangle,\n getUpdatedPolygon,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,qBAAqB,GAAGA,CAACC,UAAU,EAAEC,OAAO,EAAEC,eAAe,EAAEC,UAAU,KAAK;EAClF;EACA,IAAID,eAAe,EAAE;IACnB,MAAME,gBAAgB,GAAGJ,UAAU,CAACK,KAAK,GAAGL,UAAU,CAACM,MAAM;IAE7D,IAAIH,UAAU,KAAK,QAAQ,EAAE;MAC3B;MACA,OAAO;QACLE,KAAK,EAAEJ,OAAO,CAACK,MAAM,GAAGF,gBAAgB;QACxCE,MAAM,EAAEL,OAAO,CAACK;MAClB,CAAC;IACH;;IAEA;IACA,OAAO;MACLD,KAAK,EAAEJ,OAAO,CAACI,KAAK;MACpBC,MAAM,EAAEL,OAAO,CAACI,KAAK,GAAGD;IAC1B,CAAC;EACH;;EAEA;EACA,OAAO;IACLC,KAAK,EAAEJ,OAAO,CAACI,KAAK;IACpBC,MAAM,EAAEL,OAAO,CAACK;EAClB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AAAAC,OAAA,CAAAR,qBAAA,GAAAA,qBAAA;AACA,MAAMS,QAAQ,GAAGA,CAACC,qBAAqB,EAAEC,kBAAkB,EAAEC,YAAY,KACtED,kBAAkB,GAAGD,qBAAqB,GAAIE,YAAY;AAE7D,MAAMC,mBAAmB,GAAGA,CAACZ,UAAU,EAAEC,OAAO,EAAEY,KAAK,MAAM;EAC3D,GAAGA,KAAK;EACRR,KAAK,EAAEG,QAAQ,CAACR,UAAU,CAACK,KAAK,EAAEJ,OAAO,CAACI,K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I,EAAE/C,CAAC,IAAImD,IAAI,GAAG,EAAE,EAAEnD,CAAC,EAAE,EAAE;IACtC,KAAK,IAAIC,CAAC,GAAGoD,IAAI,GAAG,EAAE,EAAEpD,CAAC,GAAGiD,IAAI,EAAEjD,CAAC,EAAE,EAAE;MACrC;MACA,IAAIgC,oBAAoB,CAACW,aAAa,EAAE5C,CAAC,EAAEC,CAAC,CAAC,EAAE;QAC7CqD,KAAK,GAAGtD,CAAC,GAAG,EAAE;QACduD,KAAK,GAAGtD,CAAC;QACT;MACF;IACF;EACF;EAEA,OAAO;IAAED,CAAC,EAAEsD,KAAK;IAAErD,CAAC,EAAEsD;EAAM,CAAC;AAC/B,CAAC;AAAC9D,OAAA,CAAAkD,SAAA,GAAAA,SAAA;AAEF,MAAMa,yBAAyB,GAAIC,MAAM,IAAK;EAC5C,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAc,CAAC,GAAGH,MAAM;EAEtD,MAAMI,aAAa,GACjB,8BAA8BH,SAAS,GAAG,IAAIC,SAAS,GAAG,eAAeA,SAAS,GAAG,GAAG,EAAE,CAAC,GAAG,iBAAiB;EAEjH,MAAMG,iBAAiB,GACrB,+BAA+B,IAC9BF,aAAa,GAAG,eAAeA,aAAa,GAAG,GAAG,EAAE,CAAC,GACtD,OAAO,IACNA,aAAa,GAAG,GAAG,GAAG,EAAE,CAAC,GAC1B,YAAY;EAEd,MAAMG,OAAO,GAAG,0BAA0B,GAAGF,aAAa,GAAGC,iBAAiB;EAE9E,OAAOC,OAAO;AAChB,CAAC;AAACtE,OAAA,CAAA+D,yBAAA,GAAAA,yBAAA","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@pie-element/hotspot-configure",
3
+ "private": true,
4
+ "version": "10.1.2",
5
+ "description": "",
6
+ "main": "lib/index.js",
7
+ "module": "src/index.js",
8
+ "author": "",
9
+ "dependencies": {
10
+ "@emotion/react": "^11.14.0",
11
+ "@emotion/style": "^0.8.0",
12
+ "@mui/icons-material": "^7.3.4",
13
+ "@mui/material": "^7.3.4",
14
+ "@pie-framework/pie-configure-events": "^1.3.0",
15
+ "@pie-lib/config-ui": "13.0.6",
16
+ "@pie-lib/editable-html-tip-tap": "2.1.4",
17
+ "debug": "^4.1.1",
18
+ "konva": "8.3.0",
19
+ "lodash-es": "^4.17.23",
20
+ "prop-types": "^15.8.1",
21
+ "react": "18.3.1",
22
+ "react-dom": "18.3.1",
23
+ "react-konva": "^18.2.14"
24
+ },
25
+ "license": "ISC"
26
+ }
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Group } from 'react-konva';
4
+ import { faDelete } from './icons';
5
+ import ImageComponent from './image-konva';
6
+ import { calculate } from './utils';
7
+
8
+ const DeleteWidget = ({ height, id, width, x, y, points, isCircle, radius, handleWidgetClick }) => {
9
+ let positionX, positionY;
10
+ const offset = 20;
11
+
12
+ if (isCircle) {
13
+ // For circles, position the delete icon above the circle
14
+ positionX = x + radius - offset;
15
+ positionY = y;
16
+ } else if (points) {
17
+ // For polygons, compute position based on points
18
+ const calculated = calculate(points);
19
+ positionX = calculated.x;
20
+ positionY = calculated.y;
21
+ } else {
22
+ // For rectangles
23
+ positionX = x + width - offset;
24
+ positionY = y + height - offset;
25
+ }
26
+
27
+ return (
28
+ <Group onClick={() => handleWidgetClick(id)}>
29
+ <ImageComponent x={positionX} y={positionY} src={faDelete} />
30
+ </Group>
31
+ );
32
+ };
33
+
34
+ DeleteWidget.propTypes = {
35
+ id: PropTypes.string.isRequired,
36
+ height: PropTypes.number,
37
+ width: PropTypes.number,
38
+ x: PropTypes.number.isRequired,
39
+ y: PropTypes.number.isRequired,
40
+ handleWidgetClick: PropTypes.func.isRequired,
41
+ radius: PropTypes.number,
42
+ isCircle: PropTypes.bool,
43
+ points: PropTypes.arrayOf(
44
+ PropTypes.shape({
45
+ x: PropTypes.number,
46
+ y: PropTypes.number,
47
+ }),
48
+ ),
49
+ };
50
+
51
+ export default DeleteWidget;