@mdesignable/core 1.0.0-beta.64

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 (389) hide show
  1. package/LICENSE.md +20 -0
  2. package/README.md +1 -0
  3. package/dist/designable.core.umd.production.js +10 -0
  4. package/dist/designable.core.umd.production.min.js +23505 -0
  5. package/esm/drivers/DragDropDriver.d.ts +14 -0
  6. package/esm/drivers/DragDropDriver.js +157 -0
  7. package/esm/drivers/KeyboardDriver.d.ts +7 -0
  8. package/esm/drivers/KeyboardDriver.js +90 -0
  9. package/esm/drivers/MouseClickDriver.d.ts +8 -0
  10. package/esm/drivers/MouseClickDriver.js +95 -0
  11. package/esm/drivers/MouseMoveDriver.d.ts +8 -0
  12. package/esm/drivers/MouseMoveDriver.js +75 -0
  13. package/esm/drivers/ViewportResizeDriver.d.ts +10 -0
  14. package/esm/drivers/ViewportResizeDriver.js +95 -0
  15. package/esm/drivers/ViewportScrollDriver.d.ts +8 -0
  16. package/esm/drivers/ViewportScrollDriver.js +74 -0
  17. package/esm/drivers/index.d.ts +6 -0
  18. package/esm/drivers/index.js +6 -0
  19. package/esm/effects/index.d.ts +11 -0
  20. package/esm/effects/index.js +11 -0
  21. package/esm/effects/useAutoScrollEffect.d.ts +2 -0
  22. package/esm/effects/useAutoScrollEffect.js +65 -0
  23. package/esm/effects/useContentEditableEffect.d.ts +2 -0
  24. package/esm/effects/useContentEditableEffect.js +167 -0
  25. package/esm/effects/useCursorEffect.d.ts +2 -0
  26. package/esm/effects/useCursorEffect.js +55 -0
  27. package/esm/effects/useDragDropEffect.d.ts +2 -0
  28. package/esm/effects/useDragDropEffect.js +168 -0
  29. package/esm/effects/useFreeSelectionEffect.d.ts +2 -0
  30. package/esm/effects/useFreeSelectionEffect.js +59 -0
  31. package/esm/effects/useKeyboardEffect.d.ts +2 -0
  32. package/esm/effects/useKeyboardEffect.js +17 -0
  33. package/esm/effects/useResizeEffect.d.ts +2 -0
  34. package/esm/effects/useResizeEffect.js +80 -0
  35. package/esm/effects/useSelectionEffect.d.ts +2 -0
  36. package/esm/effects/useSelectionEffect.js +68 -0
  37. package/esm/effects/useTranslateEffect.d.ts +2 -0
  38. package/esm/effects/useTranslateEffect.js +58 -0
  39. package/esm/effects/useViewportEffect.d.ts +2 -0
  40. package/esm/effects/useViewportEffect.js +31 -0
  41. package/esm/effects/useWorkspaceEffect.d.ts +2 -0
  42. package/esm/effects/useWorkspaceEffect.js +29 -0
  43. package/esm/events/cursor/AbstractCursorEvent.d.ts +21 -0
  44. package/esm/events/cursor/AbstractCursorEvent.js +40 -0
  45. package/esm/events/cursor/DragMoveEvent.d.ts +5 -0
  46. package/esm/events/cursor/DragMoveEvent.js +51 -0
  47. package/esm/events/cursor/DragStartEvent.d.ts +5 -0
  48. package/esm/events/cursor/DragStartEvent.js +51 -0
  49. package/esm/events/cursor/DragStopEvent.d.ts +5 -0
  50. package/esm/events/cursor/DragStopEvent.js +51 -0
  51. package/esm/events/cursor/MouseClickEvent.d.ts +8 -0
  52. package/esm/events/cursor/MouseClickEvent.js +61 -0
  53. package/esm/events/cursor/MouseMoveEvent.d.ts +5 -0
  54. package/esm/events/cursor/MouseMoveEvent.js +51 -0
  55. package/esm/events/cursor/index.d.ts +5 -0
  56. package/esm/events/cursor/index.js +5 -0
  57. package/esm/events/history/AbstractHistoryEvent.d.ts +6 -0
  58. package/esm/events/history/AbstractHistoryEvent.js +7 -0
  59. package/esm/events/history/HistoryGotoEvent.d.ts +5 -0
  60. package/esm/events/history/HistoryGotoEvent.js +51 -0
  61. package/esm/events/history/HistoryPushEvent.d.ts +5 -0
  62. package/esm/events/history/HistoryPushEvent.js +51 -0
  63. package/esm/events/history/HistoryRedoEvent.d.ts +5 -0
  64. package/esm/events/history/HistoryRedoEvent.js +51 -0
  65. package/esm/events/history/HistoryUndoEvent.d.ts +5 -0
  66. package/esm/events/history/HistoryUndoEvent.js +51 -0
  67. package/esm/events/history/index.d.ts +4 -0
  68. package/esm/events/history/index.js +4 -0
  69. package/esm/events/index.d.ts +6 -0
  70. package/esm/events/index.js +6 -0
  71. package/esm/events/keyboard/AbstractKeyboardEvent.d.ts +15 -0
  72. package/esm/events/keyboard/AbstractKeyboardEvent.js +61 -0
  73. package/esm/events/keyboard/KeyDownEvent.d.ts +5 -0
  74. package/esm/events/keyboard/KeyDownEvent.js +51 -0
  75. package/esm/events/keyboard/KeyUpEvent.d.ts +5 -0
  76. package/esm/events/keyboard/KeyUpEvent.js +51 -0
  77. package/esm/events/keyboard/index.d.ts +2 -0
  78. package/esm/events/keyboard/index.js +2 -0
  79. package/esm/events/mutation/AbstractMutationNodeEvent.d.ts +13 -0
  80. package/esm/events/mutation/AbstractMutationNodeEvent.js +7 -0
  81. package/esm/events/mutation/AppendNodeEvent.d.ts +5 -0
  82. package/esm/events/mutation/AppendNodeEvent.js +51 -0
  83. package/esm/events/mutation/CloneNodeEvent.d.ts +5 -0
  84. package/esm/events/mutation/CloneNodeEvent.js +51 -0
  85. package/esm/events/mutation/DragNodeEvent.d.ts +5 -0
  86. package/esm/events/mutation/DragNodeEvent.js +51 -0
  87. package/esm/events/mutation/DropNodeEvent.d.ts +5 -0
  88. package/esm/events/mutation/DropNodeEvent.js +51 -0
  89. package/esm/events/mutation/FromNodeEvent.d.ts +13 -0
  90. package/esm/events/mutation/FromNodeEvent.js +8 -0
  91. package/esm/events/mutation/HoverNodeEvent.d.ts +5 -0
  92. package/esm/events/mutation/HoverNodeEvent.js +51 -0
  93. package/esm/events/mutation/InsertAfterEvent.d.ts +5 -0
  94. package/esm/events/mutation/InsertAfterEvent.js +51 -0
  95. package/esm/events/mutation/InsertBeforeEvent.d.ts +5 -0
  96. package/esm/events/mutation/InsertBeforeEvent.js +51 -0
  97. package/esm/events/mutation/InsertChildrenEvent.d.ts +5 -0
  98. package/esm/events/mutation/InsertChildrenEvent.js +51 -0
  99. package/esm/events/mutation/PrependNodeEvent.d.ts +5 -0
  100. package/esm/events/mutation/PrependNodeEvent.js +51 -0
  101. package/esm/events/mutation/RemoveNodeEvent.d.ts +5 -0
  102. package/esm/events/mutation/RemoveNodeEvent.js +51 -0
  103. package/esm/events/mutation/SelectNodeEvent.d.ts +5 -0
  104. package/esm/events/mutation/SelectNodeEvent.js +51 -0
  105. package/esm/events/mutation/UnSelectNodeEvent.d.ts +5 -0
  106. package/esm/events/mutation/UnSelectNodeEvent.js +51 -0
  107. package/esm/events/mutation/UpdateChildrenEvent.d.ts +5 -0
  108. package/esm/events/mutation/UpdateChildrenEvent.js +51 -0
  109. package/esm/events/mutation/UpdateNodePropsEvent.d.ts +5 -0
  110. package/esm/events/mutation/UpdateNodePropsEvent.js +51 -0
  111. package/esm/events/mutation/UserSelectNodeEvent.d.ts +5 -0
  112. package/esm/events/mutation/UserSelectNodeEvent.js +51 -0
  113. package/esm/events/mutation/WrapNodeEvent.d.ts +5 -0
  114. package/esm/events/mutation/WrapNodeEvent.js +51 -0
  115. package/esm/events/mutation/index.d.ts +16 -0
  116. package/esm/events/mutation/index.js +16 -0
  117. package/esm/events/viewport/AbstractViewportEvent.d.ts +16 -0
  118. package/esm/events/viewport/AbstractViewportEvent.js +17 -0
  119. package/esm/events/viewport/ViewportResizeEvent.d.ts +5 -0
  120. package/esm/events/viewport/ViewportResizeEvent.js +51 -0
  121. package/esm/events/viewport/ViewportScrollEvent.d.ts +5 -0
  122. package/esm/events/viewport/ViewportScrollEvent.js +51 -0
  123. package/esm/events/viewport/index.d.ts +2 -0
  124. package/esm/events/viewport/index.js +2 -0
  125. package/esm/events/workbench/AbstractWorkspaceEvent.d.ts +7 -0
  126. package/esm/events/workbench/AbstractWorkspaceEvent.js +7 -0
  127. package/esm/events/workbench/AddWorkspaceEvent.d.ts +5 -0
  128. package/esm/events/workbench/AddWorkspaceEvent.js +51 -0
  129. package/esm/events/workbench/RemoveWorkspaceEvent.d.ts +5 -0
  130. package/esm/events/workbench/RemoveWorkspaceEvent.js +51 -0
  131. package/esm/events/workbench/SwitchWorkspaceEvent.d.ts +5 -0
  132. package/esm/events/workbench/SwitchWorkspaceEvent.js +51 -0
  133. package/esm/events/workbench/index.d.ts +3 -0
  134. package/esm/events/workbench/index.js +3 -0
  135. package/esm/exports.d.ts +5 -0
  136. package/esm/exports.js +5 -0
  137. package/esm/externals.d.ts +12 -0
  138. package/esm/externals.js +113 -0
  139. package/esm/index.d.ts +1 -0
  140. package/esm/index.js +24 -0
  141. package/esm/internals.d.ts +3 -0
  142. package/esm/internals.js +34 -0
  143. package/esm/models/Cursor.d.ts +60 -0
  144. package/esm/models/Cursor.js +151 -0
  145. package/esm/models/Engine.d.ts +29 -0
  146. package/esm/models/Engine.js +112 -0
  147. package/esm/models/History.d.ts +34 -0
  148. package/esm/models/History.js +110 -0
  149. package/esm/models/Hover.d.ts +14 -0
  150. package/esm/models/Hover.js +38 -0
  151. package/esm/models/Keyboard.d.ts +29 -0
  152. package/esm/models/Keyboard.js +126 -0
  153. package/esm/models/MoveHelper.d.ts +66 -0
  154. package/esm/models/MoveHelper.js +363 -0
  155. package/esm/models/Operation.d.ts +29 -0
  156. package/esm/models/Operation.js +75 -0
  157. package/esm/models/Screen.d.ts +31 -0
  158. package/esm/models/Screen.js +73 -0
  159. package/esm/models/Selection.d.ts +29 -0
  160. package/esm/models/Selection.js +192 -0
  161. package/esm/models/Shortcut.d.ts +20 -0
  162. package/esm/models/Shortcut.js +69 -0
  163. package/esm/models/SnapLine.d.ts +27 -0
  164. package/esm/models/SnapLine.js +141 -0
  165. package/esm/models/SpaceBlock.d.ts +40 -0
  166. package/esm/models/SpaceBlock.js +171 -0
  167. package/esm/models/TransformHelper.d.ts +80 -0
  168. package/esm/models/TransformHelper.js +601 -0
  169. package/esm/models/TreeNode.d.ts +115 -0
  170. package/esm/models/TreeNode.js +932 -0
  171. package/esm/models/Viewport.d.ts +90 -0
  172. package/esm/models/Viewport.js +474 -0
  173. package/esm/models/Workbench.d.ts +23 -0
  174. package/esm/models/Workbench.js +98 -0
  175. package/esm/models/Workspace.d.ts +41 -0
  176. package/esm/models/Workspace.js +95 -0
  177. package/esm/models/index.d.ts +13 -0
  178. package/esm/models/index.js +13 -0
  179. package/esm/presets.d.ts +4 -0
  180. package/esm/presets.js +38 -0
  181. package/esm/registry.d.ts +16 -0
  182. package/esm/registry.js +123 -0
  183. package/esm/shortcuts/CursorSwitch.d.ts +2 -0
  184. package/esm/shortcuts/CursorSwitch.js +10 -0
  185. package/esm/shortcuts/MultiSelection.d.ts +5 -0
  186. package/esm/shortcuts/MultiSelection.js +27 -0
  187. package/esm/shortcuts/NodeMutation.d.ts +7 -0
  188. package/esm/shortcuts/NodeMutation.js +40 -0
  189. package/esm/shortcuts/QuickSelection.d.ts +3 -0
  190. package/esm/shortcuts/QuickSelection.js +85 -0
  191. package/esm/shortcuts/UndoRedo.d.ts +3 -0
  192. package/esm/shortcuts/UndoRedo.js +27 -0
  193. package/esm/shortcuts/index.d.ts +5 -0
  194. package/esm/shortcuts/index.js +5 -0
  195. package/esm/types.d.ts +131 -0
  196. package/esm/types.js +1 -0
  197. package/lib/drivers/DragDropDriver.d.ts +14 -0
  198. package/lib/drivers/DragDropDriver.js +160 -0
  199. package/lib/drivers/KeyboardDriver.d.ts +7 -0
  200. package/lib/drivers/KeyboardDriver.js +93 -0
  201. package/lib/drivers/MouseClickDriver.d.ts +8 -0
  202. package/lib/drivers/MouseClickDriver.js +98 -0
  203. package/lib/drivers/MouseMoveDriver.d.ts +8 -0
  204. package/lib/drivers/MouseMoveDriver.js +78 -0
  205. package/lib/drivers/ViewportResizeDriver.d.ts +10 -0
  206. package/lib/drivers/ViewportResizeDriver.js +98 -0
  207. package/lib/drivers/ViewportScrollDriver.d.ts +8 -0
  208. package/lib/drivers/ViewportScrollDriver.js +77 -0
  209. package/lib/drivers/index.d.ts +6 -0
  210. package/lib/drivers/index.js +22 -0
  211. package/lib/effects/index.d.ts +11 -0
  212. package/lib/effects/index.js +27 -0
  213. package/lib/effects/useAutoScrollEffect.d.ts +2 -0
  214. package/lib/effects/useAutoScrollEffect.js +69 -0
  215. package/lib/effects/useContentEditableEffect.d.ts +2 -0
  216. package/lib/effects/useContentEditableEffect.js +171 -0
  217. package/lib/effects/useCursorEffect.d.ts +2 -0
  218. package/lib/effects/useCursorEffect.js +59 -0
  219. package/lib/effects/useDragDropEffect.d.ts +2 -0
  220. package/lib/effects/useDragDropEffect.js +172 -0
  221. package/lib/effects/useFreeSelectionEffect.d.ts +2 -0
  222. package/lib/effects/useFreeSelectionEffect.js +63 -0
  223. package/lib/effects/useKeyboardEffect.d.ts +2 -0
  224. package/lib/effects/useKeyboardEffect.js +21 -0
  225. package/lib/effects/useResizeEffect.d.ts +2 -0
  226. package/lib/effects/useResizeEffect.js +84 -0
  227. package/lib/effects/useSelectionEffect.d.ts +2 -0
  228. package/lib/effects/useSelectionEffect.js +72 -0
  229. package/lib/effects/useTranslateEffect.d.ts +2 -0
  230. package/lib/effects/useTranslateEffect.js +62 -0
  231. package/lib/effects/useViewportEffect.d.ts +2 -0
  232. package/lib/effects/useViewportEffect.js +35 -0
  233. package/lib/effects/useWorkspaceEffect.d.ts +2 -0
  234. package/lib/effects/useWorkspaceEffect.js +33 -0
  235. package/lib/events/cursor/AbstractCursorEvent.d.ts +21 -0
  236. package/lib/events/cursor/AbstractCursorEvent.js +43 -0
  237. package/lib/events/cursor/DragMoveEvent.d.ts +5 -0
  238. package/lib/events/cursor/DragMoveEvent.js +54 -0
  239. package/lib/events/cursor/DragStartEvent.d.ts +5 -0
  240. package/lib/events/cursor/DragStartEvent.js +54 -0
  241. package/lib/events/cursor/DragStopEvent.d.ts +5 -0
  242. package/lib/events/cursor/DragStopEvent.js +54 -0
  243. package/lib/events/cursor/MouseClickEvent.d.ts +8 -0
  244. package/lib/events/cursor/MouseClickEvent.js +64 -0
  245. package/lib/events/cursor/MouseMoveEvent.d.ts +5 -0
  246. package/lib/events/cursor/MouseMoveEvent.js +54 -0
  247. package/lib/events/cursor/index.d.ts +5 -0
  248. package/lib/events/cursor/index.js +21 -0
  249. package/lib/events/history/AbstractHistoryEvent.d.ts +6 -0
  250. package/lib/events/history/AbstractHistoryEvent.js +10 -0
  251. package/lib/events/history/HistoryGotoEvent.d.ts +5 -0
  252. package/lib/events/history/HistoryGotoEvent.js +54 -0
  253. package/lib/events/history/HistoryPushEvent.d.ts +5 -0
  254. package/lib/events/history/HistoryPushEvent.js +54 -0
  255. package/lib/events/history/HistoryRedoEvent.d.ts +5 -0
  256. package/lib/events/history/HistoryRedoEvent.js +54 -0
  257. package/lib/events/history/HistoryUndoEvent.d.ts +5 -0
  258. package/lib/events/history/HistoryUndoEvent.js +54 -0
  259. package/lib/events/history/index.d.ts +4 -0
  260. package/lib/events/history/index.js +20 -0
  261. package/lib/events/index.d.ts +6 -0
  262. package/lib/events/index.js +22 -0
  263. package/lib/events/keyboard/AbstractKeyboardEvent.d.ts +15 -0
  264. package/lib/events/keyboard/AbstractKeyboardEvent.js +64 -0
  265. package/lib/events/keyboard/KeyDownEvent.d.ts +5 -0
  266. package/lib/events/keyboard/KeyDownEvent.js +54 -0
  267. package/lib/events/keyboard/KeyUpEvent.d.ts +5 -0
  268. package/lib/events/keyboard/KeyUpEvent.js +54 -0
  269. package/lib/events/keyboard/index.d.ts +2 -0
  270. package/lib/events/keyboard/index.js +18 -0
  271. package/lib/events/mutation/AbstractMutationNodeEvent.d.ts +13 -0
  272. package/lib/events/mutation/AbstractMutationNodeEvent.js +10 -0
  273. package/lib/events/mutation/AppendNodeEvent.d.ts +5 -0
  274. package/lib/events/mutation/AppendNodeEvent.js +54 -0
  275. package/lib/events/mutation/CloneNodeEvent.d.ts +5 -0
  276. package/lib/events/mutation/CloneNodeEvent.js +54 -0
  277. package/lib/events/mutation/DragNodeEvent.d.ts +5 -0
  278. package/lib/events/mutation/DragNodeEvent.js +54 -0
  279. package/lib/events/mutation/DropNodeEvent.d.ts +5 -0
  280. package/lib/events/mutation/DropNodeEvent.js +54 -0
  281. package/lib/events/mutation/FromNodeEvent.d.ts +13 -0
  282. package/lib/events/mutation/FromNodeEvent.js +11 -0
  283. package/lib/events/mutation/HoverNodeEvent.d.ts +5 -0
  284. package/lib/events/mutation/HoverNodeEvent.js +54 -0
  285. package/lib/events/mutation/InsertAfterEvent.d.ts +5 -0
  286. package/lib/events/mutation/InsertAfterEvent.js +54 -0
  287. package/lib/events/mutation/InsertBeforeEvent.d.ts +5 -0
  288. package/lib/events/mutation/InsertBeforeEvent.js +54 -0
  289. package/lib/events/mutation/InsertChildrenEvent.d.ts +5 -0
  290. package/lib/events/mutation/InsertChildrenEvent.js +54 -0
  291. package/lib/events/mutation/PrependNodeEvent.d.ts +5 -0
  292. package/lib/events/mutation/PrependNodeEvent.js +54 -0
  293. package/lib/events/mutation/RemoveNodeEvent.d.ts +5 -0
  294. package/lib/events/mutation/RemoveNodeEvent.js +54 -0
  295. package/lib/events/mutation/SelectNodeEvent.d.ts +5 -0
  296. package/lib/events/mutation/SelectNodeEvent.js +54 -0
  297. package/lib/events/mutation/UnSelectNodeEvent.d.ts +5 -0
  298. package/lib/events/mutation/UnSelectNodeEvent.js +54 -0
  299. package/lib/events/mutation/UpdateChildrenEvent.d.ts +5 -0
  300. package/lib/events/mutation/UpdateChildrenEvent.js +54 -0
  301. package/lib/events/mutation/UpdateNodePropsEvent.d.ts +5 -0
  302. package/lib/events/mutation/UpdateNodePropsEvent.js +54 -0
  303. package/lib/events/mutation/UserSelectNodeEvent.d.ts +5 -0
  304. package/lib/events/mutation/UserSelectNodeEvent.js +54 -0
  305. package/lib/events/mutation/WrapNodeEvent.d.ts +5 -0
  306. package/lib/events/mutation/WrapNodeEvent.js +54 -0
  307. package/lib/events/mutation/index.d.ts +16 -0
  308. package/lib/events/mutation/index.js +32 -0
  309. package/lib/events/viewport/AbstractViewportEvent.d.ts +16 -0
  310. package/lib/events/viewport/AbstractViewportEvent.js +20 -0
  311. package/lib/events/viewport/ViewportResizeEvent.d.ts +5 -0
  312. package/lib/events/viewport/ViewportResizeEvent.js +54 -0
  313. package/lib/events/viewport/ViewportScrollEvent.d.ts +5 -0
  314. package/lib/events/viewport/ViewportScrollEvent.js +54 -0
  315. package/lib/events/viewport/index.d.ts +2 -0
  316. package/lib/events/viewport/index.js +18 -0
  317. package/lib/events/workbench/AbstractWorkspaceEvent.d.ts +7 -0
  318. package/lib/events/workbench/AbstractWorkspaceEvent.js +10 -0
  319. package/lib/events/workbench/AddWorkspaceEvent.d.ts +5 -0
  320. package/lib/events/workbench/AddWorkspaceEvent.js +54 -0
  321. package/lib/events/workbench/RemoveWorkspaceEvent.d.ts +5 -0
  322. package/lib/events/workbench/RemoveWorkspaceEvent.js +54 -0
  323. package/lib/events/workbench/SwitchWorkspaceEvent.d.ts +5 -0
  324. package/lib/events/workbench/SwitchWorkspaceEvent.js +54 -0
  325. package/lib/events/workbench/index.d.ts +3 -0
  326. package/lib/events/workbench/index.js +19 -0
  327. package/lib/exports.d.ts +5 -0
  328. package/lib/exports.js +21 -0
  329. package/lib/externals.d.ts +12 -0
  330. package/lib/externals.js +126 -0
  331. package/lib/index.d.ts +1 -0
  332. package/lib/index.js +52 -0
  333. package/lib/internals.d.ts +3 -0
  334. package/lib/internals.js +40 -0
  335. package/lib/models/Cursor.d.ts +60 -0
  336. package/lib/models/Cursor.js +154 -0
  337. package/lib/models/Engine.d.ts +29 -0
  338. package/lib/models/Engine.js +115 -0
  339. package/lib/models/History.d.ts +34 -0
  340. package/lib/models/History.js +113 -0
  341. package/lib/models/Hover.d.ts +14 -0
  342. package/lib/models/Hover.js +41 -0
  343. package/lib/models/Keyboard.d.ts +29 -0
  344. package/lib/models/Keyboard.js +129 -0
  345. package/lib/models/MoveHelper.d.ts +66 -0
  346. package/lib/models/MoveHelper.js +366 -0
  347. package/lib/models/Operation.d.ts +29 -0
  348. package/lib/models/Operation.js +78 -0
  349. package/lib/models/Screen.d.ts +31 -0
  350. package/lib/models/Screen.js +76 -0
  351. package/lib/models/Selection.d.ts +29 -0
  352. package/lib/models/Selection.js +195 -0
  353. package/lib/models/Shortcut.d.ts +20 -0
  354. package/lib/models/Shortcut.js +72 -0
  355. package/lib/models/SnapLine.d.ts +27 -0
  356. package/lib/models/SnapLine.js +144 -0
  357. package/lib/models/SpaceBlock.d.ts +40 -0
  358. package/lib/models/SpaceBlock.js +174 -0
  359. package/lib/models/TransformHelper.d.ts +80 -0
  360. package/lib/models/TransformHelper.js +604 -0
  361. package/lib/models/TreeNode.d.ts +115 -0
  362. package/lib/models/TreeNode.js +935 -0
  363. package/lib/models/Viewport.d.ts +90 -0
  364. package/lib/models/Viewport.js +477 -0
  365. package/lib/models/Workbench.d.ts +23 -0
  366. package/lib/models/Workbench.js +101 -0
  367. package/lib/models/Workspace.d.ts +41 -0
  368. package/lib/models/Workspace.js +98 -0
  369. package/lib/models/index.d.ts +13 -0
  370. package/lib/models/index.js +29 -0
  371. package/lib/presets.d.ts +4 -0
  372. package/lib/presets.js +41 -0
  373. package/lib/registry.d.ts +16 -0
  374. package/lib/registry.js +126 -0
  375. package/lib/shortcuts/CursorSwitch.d.ts +2 -0
  376. package/lib/shortcuts/CursorSwitch.js +13 -0
  377. package/lib/shortcuts/MultiSelection.d.ts +5 -0
  378. package/lib/shortcuts/MultiSelection.js +30 -0
  379. package/lib/shortcuts/NodeMutation.d.ts +7 -0
  380. package/lib/shortcuts/NodeMutation.js +43 -0
  381. package/lib/shortcuts/QuickSelection.d.ts +3 -0
  382. package/lib/shortcuts/QuickSelection.js +88 -0
  383. package/lib/shortcuts/UndoRedo.d.ts +3 -0
  384. package/lib/shortcuts/UndoRedo.js +30 -0
  385. package/lib/shortcuts/index.d.ts +5 -0
  386. package/lib/shortcuts/index.js +21 -0
  387. package/lib/types.d.ts +131 -0
  388. package/lib/types.js +2 -0
  389. package/package.json +49 -0
@@ -0,0 +1,932 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
+ if (ar || !(i in from)) {
20
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
+ ar[i] = from[i];
22
+ }
23
+ }
24
+ return to.concat(ar || Array.prototype.slice.call(from));
25
+ };
26
+ import { action, define, observable, toJS } from '@formily/reactive';
27
+ import { uid, isFn, each } from '@mdesignable/shared';
28
+ import { InsertBeforeEvent, InsertAfterEvent, InsertChildrenEvent, PrependNodeEvent, AppendNodeEvent, WrapNodeEvent, UpdateChildrenEvent, RemoveNodeEvent, UpdateNodePropsEvent, CloneNodeEvent, FromNodeEvent, } from '../events';
29
+ import { GlobalRegistry } from '../registry';
30
+ import { mergeLocales } from '../internals';
31
+ var TreeNodes = new Map();
32
+ var CommonDesignerPropsMap = new Map();
33
+ var removeNode = function (node) {
34
+ if (node.parent) {
35
+ node.parent.children = node.parent.children.filter(function (child) { return child !== node; });
36
+ }
37
+ };
38
+ var resetNodesParent = function (nodes, parent) {
39
+ var resetDepth = function (node) {
40
+ node.depth = node.parent ? node.parent.depth + 1 : 0;
41
+ node.children.forEach(resetDepth);
42
+ };
43
+ var shallowReset = function (node) {
44
+ node.parent = parent;
45
+ node.root = parent.root;
46
+ resetDepth(node);
47
+ };
48
+ var deepReset = function (node) {
49
+ shallowReset(node);
50
+ resetNodesParent(node.children, node);
51
+ };
52
+ return nodes.map(function (node) {
53
+ var _a;
54
+ if (node === parent)
55
+ return node;
56
+ if (!parent.isSourceNode) {
57
+ if (node.isSourceNode) {
58
+ node = node.clone(parent);
59
+ resetDepth(node);
60
+ }
61
+ else if (!node.isRoot && node.isInOperation) {
62
+ (_a = node.operation) === null || _a === void 0 ? void 0 : _a.selection.remove(node);
63
+ removeNode(node);
64
+ shallowReset(node);
65
+ }
66
+ else {
67
+ deepReset(node);
68
+ }
69
+ }
70
+ else {
71
+ deepReset(node);
72
+ }
73
+ if (!TreeNodes.has(node.id)) {
74
+ TreeNodes.set(node.id, node);
75
+ CommonDesignerPropsMap.set(node.componentName, node.designerProps);
76
+ }
77
+ return node;
78
+ });
79
+ };
80
+ var resetParent = function (node, parent) {
81
+ return resetNodesParent([node], parent)[0];
82
+ };
83
+ var resolveDesignerProps = function (node, props) {
84
+ if (isFn(props))
85
+ return props(node);
86
+ return props;
87
+ };
88
+ var TreeNode = /** @class */ (function () {
89
+ function TreeNode(node, parent) {
90
+ this.depth = 0;
91
+ this.hidden = false;
92
+ this.componentName = 'NO_NAME_COMPONENT';
93
+ this.sourceName = '';
94
+ this.props = {};
95
+ this.children = [];
96
+ if (node instanceof TreeNode) {
97
+ return node;
98
+ }
99
+ this.id = node.id || uid();
100
+ if (parent) {
101
+ this.parent = parent;
102
+ this.depth = parent.depth + 1;
103
+ this.root = parent.root;
104
+ TreeNodes.set(this.id, this);
105
+ }
106
+ else {
107
+ this.root = this;
108
+ this.rootOperation = node.operation;
109
+ this.isSelfSourceNode = node.isSourceNode || false;
110
+ TreeNodes.set(this.id, this);
111
+ }
112
+ if (node) {
113
+ this.from(node);
114
+ }
115
+ this.makeObservable();
116
+ }
117
+ TreeNode.prototype.makeObservable = function () {
118
+ define(this, {
119
+ componentName: observable.ref,
120
+ props: observable,
121
+ hidden: observable.ref,
122
+ children: observable.shallow,
123
+ designerProps: observable.computed,
124
+ designerLocales: observable.computed,
125
+ wrap: action,
126
+ prepend: action,
127
+ append: action,
128
+ insertAfter: action,
129
+ insertBefore: action,
130
+ remove: action,
131
+ setProps: action,
132
+ setChildren: action,
133
+ setComponentName: action,
134
+ });
135
+ };
136
+ Object.defineProperty(TreeNode.prototype, "designerProps", {
137
+ get: function () {
138
+ var _this = this;
139
+ var behaviors = GlobalRegistry.getDesignerBehaviors(this);
140
+ var designerProps = behaviors.reduce(function (buf, pattern) {
141
+ if (!pattern.designerProps)
142
+ return buf;
143
+ Object.assign(buf, resolveDesignerProps(_this, pattern.designerProps));
144
+ return buf;
145
+ }, {});
146
+ return designerProps;
147
+ },
148
+ enumerable: false,
149
+ configurable: true
150
+ });
151
+ Object.defineProperty(TreeNode.prototype, "designerLocales", {
152
+ get: function () {
153
+ var behaviors = GlobalRegistry.getDesignerBehaviors(this);
154
+ var designerLocales = behaviors.reduce(function (buf, pattern) {
155
+ if (!pattern.designerLocales)
156
+ return buf;
157
+ mergeLocales(buf, pattern.designerLocales);
158
+ return buf;
159
+ }, {});
160
+ return designerLocales;
161
+ },
162
+ enumerable: false,
163
+ configurable: true
164
+ });
165
+ Object.defineProperty(TreeNode.prototype, "previous", {
166
+ get: function () {
167
+ if (this.parent === this || !this.parent)
168
+ return;
169
+ return this.parent.children[this.index - 1];
170
+ },
171
+ enumerable: false,
172
+ configurable: true
173
+ });
174
+ Object.defineProperty(TreeNode.prototype, "next", {
175
+ get: function () {
176
+ if (this.parent === this || !this.parent)
177
+ return;
178
+ return this.parent.children[this.index + 1];
179
+ },
180
+ enumerable: false,
181
+ configurable: true
182
+ });
183
+ Object.defineProperty(TreeNode.prototype, "siblings", {
184
+ get: function () {
185
+ var _this = this;
186
+ if (this.parent) {
187
+ return this.parent.children.filter(function (node) { return node !== _this; });
188
+ }
189
+ return [];
190
+ },
191
+ enumerable: false,
192
+ configurable: true
193
+ });
194
+ Object.defineProperty(TreeNode.prototype, "index", {
195
+ get: function () {
196
+ if (this.parent === this || !this.parent)
197
+ return 0;
198
+ return this.parent.children.indexOf(this);
199
+ },
200
+ enumerable: false,
201
+ configurable: true
202
+ });
203
+ Object.defineProperty(TreeNode.prototype, "descendants", {
204
+ get: function () {
205
+ return this.children.reduce(function (buf, node) {
206
+ return buf.concat(node).concat(node.descendants);
207
+ }, []);
208
+ },
209
+ enumerable: false,
210
+ configurable: true
211
+ });
212
+ Object.defineProperty(TreeNode.prototype, "isRoot", {
213
+ get: function () {
214
+ return this === this.root;
215
+ },
216
+ enumerable: false,
217
+ configurable: true
218
+ });
219
+ Object.defineProperty(TreeNode.prototype, "isInOperation", {
220
+ get: function () {
221
+ return !!this.operation;
222
+ },
223
+ enumerable: false,
224
+ configurable: true
225
+ });
226
+ Object.defineProperty(TreeNode.prototype, "lastChild", {
227
+ get: function () {
228
+ return this.children[this.children.length - 1];
229
+ },
230
+ enumerable: false,
231
+ configurable: true
232
+ });
233
+ Object.defineProperty(TreeNode.prototype, "firstChild", {
234
+ get: function () {
235
+ return this.children[0];
236
+ },
237
+ enumerable: false,
238
+ configurable: true
239
+ });
240
+ Object.defineProperty(TreeNode.prototype, "isSourceNode", {
241
+ get: function () {
242
+ return this.root.isSelfSourceNode;
243
+ },
244
+ enumerable: false,
245
+ configurable: true
246
+ });
247
+ Object.defineProperty(TreeNode.prototype, "operation", {
248
+ get: function () {
249
+ var _a;
250
+ return (_a = this.root) === null || _a === void 0 ? void 0 : _a.rootOperation;
251
+ },
252
+ enumerable: false,
253
+ configurable: true
254
+ });
255
+ Object.defineProperty(TreeNode.prototype, "viewport", {
256
+ get: function () {
257
+ var _a, _b;
258
+ return (_b = (_a = this.operation) === null || _a === void 0 ? void 0 : _a.workspace) === null || _b === void 0 ? void 0 : _b.viewport;
259
+ },
260
+ enumerable: false,
261
+ configurable: true
262
+ });
263
+ Object.defineProperty(TreeNode.prototype, "outline", {
264
+ get: function () {
265
+ var _a, _b;
266
+ return (_b = (_a = this.operation) === null || _a === void 0 ? void 0 : _a.workspace) === null || _b === void 0 ? void 0 : _b.outline;
267
+ },
268
+ enumerable: false,
269
+ configurable: true
270
+ });
271
+ Object.defineProperty(TreeNode.prototype, "moveLayout", {
272
+ get: function () {
273
+ var _a;
274
+ return (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.getValidNodeLayout(this);
275
+ },
276
+ enumerable: false,
277
+ configurable: true
278
+ });
279
+ TreeNode.prototype.getElement = function (area) {
280
+ var _a;
281
+ if (area === void 0) { area = 'viewport'; }
282
+ return (_a = this[area]) === null || _a === void 0 ? void 0 : _a.findElementById(this.id);
283
+ };
284
+ TreeNode.prototype.getValidElement = function (area) {
285
+ var _a;
286
+ if (area === void 0) { area = 'viewport'; }
287
+ return (_a = this[area]) === null || _a === void 0 ? void 0 : _a.getValidNodeElement(this);
288
+ };
289
+ TreeNode.prototype.getElementRect = function (area) {
290
+ var _a;
291
+ if (area === void 0) { area = 'viewport'; }
292
+ return (_a = this[area]) === null || _a === void 0 ? void 0 : _a.getElementRect(this.getElement(area));
293
+ };
294
+ TreeNode.prototype.getValidElementRect = function (area) {
295
+ var _a;
296
+ if (area === void 0) { area = 'viewport'; }
297
+ return (_a = this[area]) === null || _a === void 0 ? void 0 : _a.getValidNodeRect(this);
298
+ };
299
+ TreeNode.prototype.getElementOffsetRect = function (area) {
300
+ var _a;
301
+ if (area === void 0) { area = 'viewport'; }
302
+ return (_a = this[area]) === null || _a === void 0 ? void 0 : _a.getElementOffsetRect(this.getElement(area));
303
+ };
304
+ TreeNode.prototype.getValidElementOffsetRect = function (area) {
305
+ var _a;
306
+ if (area === void 0) { area = 'viewport'; }
307
+ return (_a = this[area]) === null || _a === void 0 ? void 0 : _a.getValidNodeOffsetRect(this);
308
+ };
309
+ TreeNode.prototype.getPrevious = function (step) {
310
+ if (step === void 0) { step = 1; }
311
+ return this.parent.children[this.index - step];
312
+ };
313
+ TreeNode.prototype.getAfter = function (step) {
314
+ if (step === void 0) { step = 1; }
315
+ return this.parent.children[this.index + step];
316
+ };
317
+ TreeNode.prototype.getSibling = function (index) {
318
+ if (index === void 0) { index = 0; }
319
+ return this.parent.children[index];
320
+ };
321
+ TreeNode.prototype.getParents = function (node) {
322
+ var _node = node || this;
323
+ return (_node === null || _node === void 0 ? void 0 : _node.parent)
324
+ ? [_node.parent].concat(this.getParents(_node.parent))
325
+ : [];
326
+ };
327
+ TreeNode.prototype.getParentByDepth = function (depth) {
328
+ if (depth === void 0) { depth = 0; }
329
+ var parent = this.parent;
330
+ if ((parent === null || parent === void 0 ? void 0 : parent.depth) === depth) {
331
+ return parent;
332
+ }
333
+ else {
334
+ return parent === null || parent === void 0 ? void 0 : parent.getParentByDepth(depth);
335
+ }
336
+ };
337
+ TreeNode.prototype.getMessage = function (token) {
338
+ return GlobalRegistry.getDesignerMessage(token, this.designerLocales);
339
+ };
340
+ TreeNode.prototype.isMyAncestor = function (node) {
341
+ if (node === this || this.parent === node)
342
+ return false;
343
+ return node.contains(this);
344
+ };
345
+ TreeNode.prototype.isMyParent = function (node) {
346
+ return this.parent === node;
347
+ };
348
+ TreeNode.prototype.isMyParents = function (node) {
349
+ if (node === this)
350
+ return false;
351
+ return this.isMyParent(node) || this.isMyAncestor(node);
352
+ };
353
+ TreeNode.prototype.isMyChild = function (node) {
354
+ return node.isMyParent(this);
355
+ };
356
+ TreeNode.prototype.isMyChildren = function (node) {
357
+ return node.isMyParents(this);
358
+ };
359
+ TreeNode.prototype.takeSnapshot = function (type) {
360
+ var _a;
361
+ (_a = this.operation) === null || _a === void 0 ? void 0 : _a.snapshot(type);
362
+ };
363
+ TreeNode.prototype.triggerMutation = function (event, callback, defaults) {
364
+ if (this.operation) {
365
+ var result = this.operation.dispatch(event, callback) || defaults;
366
+ this.takeSnapshot(event === null || event === void 0 ? void 0 : event.type);
367
+ return result;
368
+ }
369
+ else if (isFn(callback)) {
370
+ return callback();
371
+ }
372
+ };
373
+ TreeNode.prototype.find = function (finder) {
374
+ if (finder(this)) {
375
+ return this;
376
+ }
377
+ else {
378
+ var result_1 = undefined;
379
+ this.eachChildren(function (node) {
380
+ if (finder(node)) {
381
+ result_1 = node;
382
+ return false;
383
+ }
384
+ });
385
+ return result_1;
386
+ }
387
+ };
388
+ TreeNode.prototype.findAll = function (finder) {
389
+ var results = [];
390
+ if (finder(this)) {
391
+ results.push(this);
392
+ }
393
+ this.eachChildren(function (node) {
394
+ if (finder(node)) {
395
+ results.push(node);
396
+ }
397
+ });
398
+ return results;
399
+ };
400
+ TreeNode.prototype.distanceTo = function (node) {
401
+ if (this.root !== node.root) {
402
+ return Infinity;
403
+ }
404
+ if (this.parent !== node.parent) {
405
+ return Infinity;
406
+ }
407
+ return Math.abs(this.index - node.index);
408
+ };
409
+ TreeNode.prototype.crossSiblings = function (node) {
410
+ if (this.parent !== node.parent)
411
+ return [];
412
+ var minIndex = Math.min(this.index, node.index);
413
+ var maxIndex = Math.max(this.index, node.index);
414
+ var results = [];
415
+ for (var i = minIndex + 1; i < maxIndex; i++) {
416
+ results.push(this.parent.children[i]);
417
+ }
418
+ return results;
419
+ };
420
+ TreeNode.prototype.allowSibling = function (nodes) {
421
+ var _a, _b, _c;
422
+ if (((_b = (_a = this.designerProps) === null || _a === void 0 ? void 0 : _a.allowSiblings) === null || _b === void 0 ? void 0 : _b.call(_a, this, nodes)) === false)
423
+ return false;
424
+ return (_c = this.parent) === null || _c === void 0 ? void 0 : _c.allowAppend(nodes);
425
+ };
426
+ TreeNode.prototype.allowDrop = function (parent) {
427
+ if (!isFn(this.designerProps.allowDrop))
428
+ return true;
429
+ return this.designerProps.allowDrop(parent);
430
+ };
431
+ TreeNode.prototype.allowAppend = function (nodes) {
432
+ var _this = this;
433
+ var _a, _b, _c;
434
+ if (!((_a = this.designerProps) === null || _a === void 0 ? void 0 : _a.droppable))
435
+ return false;
436
+ if (((_c = (_b = this.designerProps) === null || _b === void 0 ? void 0 : _b.allowAppend) === null || _c === void 0 ? void 0 : _c.call(_b, this, nodes)) === false)
437
+ return false;
438
+ if (nodes.some(function (node) { return !node.allowDrop(_this); }))
439
+ return false;
440
+ if (this.root === this)
441
+ return true;
442
+ return true;
443
+ };
444
+ TreeNode.prototype.allowClone = function () {
445
+ var _a;
446
+ if (this === this.root)
447
+ return false;
448
+ return (_a = this.designerProps.cloneable) !== null && _a !== void 0 ? _a : true;
449
+ };
450
+ TreeNode.prototype.allowDrag = function () {
451
+ var _a;
452
+ if (this === this.root && !this.isSourceNode)
453
+ return false;
454
+ return (_a = this.designerProps.draggable) !== null && _a !== void 0 ? _a : true;
455
+ };
456
+ TreeNode.prototype.allowResize = function () {
457
+ if (this === this.root && !this.isSourceNode)
458
+ return false;
459
+ var resizable = this.designerProps.resizable;
460
+ if (!resizable)
461
+ return false;
462
+ if (resizable.width && resizable.height)
463
+ return ['x', 'y'];
464
+ if (resizable.width)
465
+ return ['x'];
466
+ return ['y'];
467
+ };
468
+ TreeNode.prototype.allowRotate = function () { };
469
+ TreeNode.prototype.allowRound = function () { };
470
+ TreeNode.prototype.allowScale = function () { };
471
+ TreeNode.prototype.allowTranslate = function () {
472
+ if (this === this.root && !this.isSourceNode)
473
+ return false;
474
+ var translatable = this.designerProps.translatable;
475
+ if ((translatable === null || translatable === void 0 ? void 0 : translatable.x) && (translatable === null || translatable === void 0 ? void 0 : translatable.y))
476
+ return true;
477
+ return false;
478
+ };
479
+ TreeNode.prototype.allowDelete = function () {
480
+ var _a;
481
+ if (this === this.root)
482
+ return false;
483
+ return (_a = this.designerProps.deletable) !== null && _a !== void 0 ? _a : true;
484
+ };
485
+ TreeNode.prototype.findById = function (id) {
486
+ var _a;
487
+ if (!id)
488
+ return;
489
+ if (this.id === id)
490
+ return this;
491
+ if (((_a = this.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
492
+ return TreeNodes.get(id);
493
+ }
494
+ };
495
+ TreeNode.prototype.contains = function () {
496
+ var _this = this;
497
+ var nodes = [];
498
+ for (var _i = 0; _i < arguments.length; _i++) {
499
+ nodes[_i] = arguments[_i];
500
+ }
501
+ return nodes.every(function (node) {
502
+ if (node === _this ||
503
+ (node === null || node === void 0 ? void 0 : node.parent) === _this ||
504
+ (node === null || node === void 0 ? void 0 : node.getParentByDepth(_this.depth)) === _this) {
505
+ return true;
506
+ }
507
+ return false;
508
+ });
509
+ };
510
+ TreeNode.prototype.eachTree = function (callback) {
511
+ var _a;
512
+ if (isFn(callback)) {
513
+ callback(this.root);
514
+ (_a = this.root) === null || _a === void 0 ? void 0 : _a.eachChildren(callback);
515
+ }
516
+ };
517
+ TreeNode.prototype.eachChildren = function (callback) {
518
+ if (isFn(callback)) {
519
+ for (var i = 0; i < this.children.length; i++) {
520
+ var node = this.children[i];
521
+ if (callback(node) === false)
522
+ return;
523
+ node.eachChildren(callback);
524
+ }
525
+ }
526
+ };
527
+ TreeNode.prototype.resetNodesParent = function (nodes, parent) {
528
+ var _this = this;
529
+ return resetNodesParent(nodes.filter(function (node) { return node !== _this; }), parent);
530
+ };
531
+ TreeNode.prototype.setProps = function (props) {
532
+ var _this = this;
533
+ return this.triggerMutation(new UpdateNodePropsEvent({
534
+ target: this,
535
+ source: null,
536
+ }), function () {
537
+ Object.assign(_this.props, props);
538
+ });
539
+ };
540
+ TreeNode.prototype.setComponentName = function (componentName) {
541
+ this.componentName = componentName;
542
+ };
543
+ TreeNode.prototype.prepend = function () {
544
+ var _this = this;
545
+ var nodes = [];
546
+ for (var _i = 0; _i < arguments.length; _i++) {
547
+ nodes[_i] = arguments[_i];
548
+ }
549
+ if (nodes.some(function (node) { return node.contains(_this); }))
550
+ return [];
551
+ var originSourceParents = nodes.map(function (node) { return node.parent; });
552
+ var newNodes = this.resetNodesParent(nodes, this);
553
+ if (!newNodes.length)
554
+ return [];
555
+ return this.triggerMutation(new PrependNodeEvent({
556
+ originSourceParents: originSourceParents,
557
+ target: this,
558
+ source: newNodes,
559
+ }), function () {
560
+ _this.children = newNodes.concat(_this.children);
561
+ return newNodes;
562
+ }, []);
563
+ };
564
+ TreeNode.prototype.append = function () {
565
+ var _this = this;
566
+ var nodes = [];
567
+ for (var _i = 0; _i < arguments.length; _i++) {
568
+ nodes[_i] = arguments[_i];
569
+ }
570
+ if (nodes.some(function (node) { return node.contains(_this); }))
571
+ return [];
572
+ var originSourceParents = nodes.map(function (node) { return node.parent; });
573
+ var newNodes = this.resetNodesParent(nodes, this);
574
+ if (!newNodes.length)
575
+ return [];
576
+ return this.triggerMutation(new AppendNodeEvent({
577
+ originSourceParents: originSourceParents,
578
+ target: this,
579
+ source: newNodes,
580
+ }), function () {
581
+ _this.children = _this.children.concat(newNodes);
582
+ return newNodes;
583
+ }, []);
584
+ };
585
+ TreeNode.prototype.wrap = function (wrapper) {
586
+ var _this = this;
587
+ if (wrapper === this)
588
+ return;
589
+ var parent = this.parent;
590
+ return this.triggerMutation(new WrapNodeEvent({
591
+ target: this,
592
+ source: wrapper,
593
+ }), function () {
594
+ resetParent(_this, wrapper);
595
+ resetParent(wrapper, parent);
596
+ return wrapper;
597
+ });
598
+ };
599
+ TreeNode.prototype.insertAfter = function () {
600
+ var _this = this;
601
+ var _a;
602
+ var nodes = [];
603
+ for (var _i = 0; _i < arguments.length; _i++) {
604
+ nodes[_i] = arguments[_i];
605
+ }
606
+ var parent = this.parent;
607
+ if (nodes.some(function (node) { return node.contains(_this); }))
608
+ return [];
609
+ if ((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.length) {
610
+ var originSourceParents = nodes.map(function (node) { return node.parent; });
611
+ var newNodes_1 = this.resetNodesParent(nodes, parent);
612
+ if (!newNodes_1.length)
613
+ return [];
614
+ return this.triggerMutation(new InsertAfterEvent({
615
+ originSourceParents: originSourceParents,
616
+ target: this,
617
+ source: newNodes_1,
618
+ }), function () {
619
+ parent.children = parent.children.reduce(function (buf, node) {
620
+ if (node === _this) {
621
+ return buf.concat([node]).concat(newNodes_1);
622
+ }
623
+ else {
624
+ return buf.concat([node]);
625
+ }
626
+ }, []);
627
+ return newNodes_1;
628
+ }, []);
629
+ }
630
+ return [];
631
+ };
632
+ TreeNode.prototype.insertBefore = function () {
633
+ var _this = this;
634
+ var _a;
635
+ var nodes = [];
636
+ for (var _i = 0; _i < arguments.length; _i++) {
637
+ nodes[_i] = arguments[_i];
638
+ }
639
+ var parent = this.parent;
640
+ if (nodes.some(function (node) { return node.contains(_this); }))
641
+ return [];
642
+ if ((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.length) {
643
+ var originSourceParents = nodes.map(function (node) { return node.parent; });
644
+ var newNodes_2 = this.resetNodesParent(nodes, parent);
645
+ if (!newNodes_2.length)
646
+ return [];
647
+ return this.triggerMutation(new InsertBeforeEvent({
648
+ originSourceParents: originSourceParents,
649
+ target: this,
650
+ source: newNodes_2,
651
+ }), function () {
652
+ parent.children = parent.children.reduce(function (buf, node) {
653
+ if (node === _this) {
654
+ return buf.concat(newNodes_2).concat([node]);
655
+ }
656
+ else {
657
+ return buf.concat([node]);
658
+ }
659
+ }, []);
660
+ return newNodes_2;
661
+ }, []);
662
+ }
663
+ return [];
664
+ };
665
+ TreeNode.prototype.insertChildren = function (start) {
666
+ var _this = this;
667
+ var _a;
668
+ var nodes = [];
669
+ for (var _i = 1; _i < arguments.length; _i++) {
670
+ nodes[_i - 1] = arguments[_i];
671
+ }
672
+ if (nodes.some(function (node) { return node.contains(_this); }))
673
+ return [];
674
+ if ((_a = this.children) === null || _a === void 0 ? void 0 : _a.length) {
675
+ var originSourceParents = nodes.map(function (node) { return node.parent; });
676
+ var newNodes_3 = this.resetNodesParent(nodes, this);
677
+ if (!newNodes_3.length)
678
+ return [];
679
+ return this.triggerMutation(new InsertChildrenEvent({
680
+ originSourceParents: originSourceParents,
681
+ target: this,
682
+ source: newNodes_3,
683
+ }), function () {
684
+ _this.children = _this.children.reduce(function (buf, node, index) {
685
+ if (index === start) {
686
+ return buf.concat(newNodes_3).concat([node]);
687
+ }
688
+ return buf.concat([node]);
689
+ }, []);
690
+ return newNodes_3;
691
+ }, []);
692
+ }
693
+ return [];
694
+ };
695
+ TreeNode.prototype.setChildren = function () {
696
+ var _this = this;
697
+ var nodes = [];
698
+ for (var _i = 0; _i < arguments.length; _i++) {
699
+ nodes[_i] = arguments[_i];
700
+ }
701
+ var originSourceParents = nodes.map(function (node) { return node.parent; });
702
+ var newNodes = this.resetNodesParent(nodes, this);
703
+ return this.triggerMutation(new UpdateChildrenEvent({
704
+ originSourceParents: originSourceParents,
705
+ target: this,
706
+ source: newNodes,
707
+ }), function () {
708
+ _this.children = newNodes;
709
+ return newNodes;
710
+ }, []);
711
+ };
712
+ /**
713
+ * @deprecated
714
+ * please use `setChildren`
715
+ */
716
+ TreeNode.prototype.setNodeChildren = function () {
717
+ var nodes = [];
718
+ for (var _i = 0; _i < arguments.length; _i++) {
719
+ nodes[_i] = arguments[_i];
720
+ }
721
+ return this.setChildren.apply(this, __spreadArray([], __read(nodes), false));
722
+ };
723
+ TreeNode.prototype.remove = function () {
724
+ var _this = this;
725
+ return this.triggerMutation(new RemoveNodeEvent({
726
+ target: this,
727
+ source: null,
728
+ }), function () {
729
+ removeNode(_this);
730
+ TreeNodes.delete(_this.id);
731
+ });
732
+ };
733
+ TreeNode.prototype.clone = function (parent) {
734
+ var newNode = new TreeNode({
735
+ id: uid(),
736
+ componentName: this.componentName,
737
+ sourceName: this.sourceName,
738
+ props: toJS(this.props),
739
+ children: [],
740
+ }, parent ? parent : this.parent);
741
+ newNode.children = resetNodesParent(this.children.map(function (child) {
742
+ return child.clone(newNode);
743
+ }), newNode);
744
+ return this.triggerMutation(new CloneNodeEvent({
745
+ target: this,
746
+ source: newNode,
747
+ }), function () { return newNode; });
748
+ };
749
+ TreeNode.prototype.from = function (node) {
750
+ var _this = this;
751
+ if (!node)
752
+ return;
753
+ return this.triggerMutation(new FromNodeEvent({
754
+ target: this,
755
+ source: node,
756
+ }), function () {
757
+ var _a, _b, _c;
758
+ if (node.id && node.id !== _this.id) {
759
+ TreeNodes.delete(_this.id);
760
+ TreeNodes.set(node.id, _this);
761
+ _this.id = node.id;
762
+ }
763
+ if (node.componentName) {
764
+ _this.componentName = node.componentName;
765
+ }
766
+ _this.props = (_a = node.props) !== null && _a !== void 0 ? _a : {};
767
+ if (node.hidden) {
768
+ _this.hidden = node.hidden;
769
+ }
770
+ if (node.children) {
771
+ _this.children =
772
+ ((_c = (_b = node.children) === null || _b === void 0 ? void 0 : _b.map) === null || _c === void 0 ? void 0 : _c.call(_b, function (node) {
773
+ return new TreeNode(node, _this);
774
+ })) || [];
775
+ }
776
+ });
777
+ };
778
+ TreeNode.prototype.serialize = function () {
779
+ return {
780
+ id: this.id,
781
+ componentName: this.componentName,
782
+ sourceName: this.sourceName,
783
+ props: toJS(this.props),
784
+ hidden: this.hidden,
785
+ children: this.children.map(function (treeNode) {
786
+ return treeNode.serialize();
787
+ }),
788
+ };
789
+ };
790
+ TreeNode.create = function (node, parent) {
791
+ return new TreeNode(node, parent);
792
+ };
793
+ TreeNode.findById = function (id) {
794
+ return TreeNodes.get(id);
795
+ };
796
+ TreeNode.remove = function (nodes) {
797
+ var _a, _b;
798
+ if (nodes === void 0) { nodes = []; }
799
+ for (var i = nodes.length - 1; i >= 0; i--) {
800
+ var node = nodes[i];
801
+ if (node.allowDelete()) {
802
+ var previous = node.previous;
803
+ var next = node.next;
804
+ node.remove();
805
+ (_a = node.operation) === null || _a === void 0 ? void 0 : _a.selection.select(previous ? previous : next ? next : node.parent);
806
+ (_b = node.operation) === null || _b === void 0 ? void 0 : _b.hover.clear();
807
+ }
808
+ }
809
+ };
810
+ TreeNode.sort = function (nodes) {
811
+ if (nodes === void 0) { nodes = []; }
812
+ return nodes.sort(function (before, after) {
813
+ if (before.depth !== after.depth)
814
+ return 0;
815
+ return before.index - after.index >= 0 ? 1 : -1;
816
+ });
817
+ };
818
+ TreeNode.clone = function (nodes) {
819
+ if (nodes === void 0) { nodes = []; }
820
+ var groups = {};
821
+ var lastGroupNode = {};
822
+ var filterNestedNode = TreeNode.sort(nodes).filter(function (node) {
823
+ return !nodes.some(function (parent) {
824
+ return node.isMyParents(parent);
825
+ });
826
+ });
827
+ each(filterNestedNode, function (node) {
828
+ var _a, _b, _c, _d, _e, _f, _g;
829
+ if (node === node.root)
830
+ return;
831
+ if (!node.allowClone())
832
+ return;
833
+ if (!(node === null || node === void 0 ? void 0 : node.operation))
834
+ return;
835
+ groups[(_a = node === null || node === void 0 ? void 0 : node.parent) === null || _a === void 0 ? void 0 : _a.id] = groups[(_b = node === null || node === void 0 ? void 0 : node.parent) === null || _b === void 0 ? void 0 : _b.id] || [];
836
+ groups[(_c = node === null || node === void 0 ? void 0 : node.parent) === null || _c === void 0 ? void 0 : _c.id].push(node);
837
+ if (lastGroupNode[(_d = node === null || node === void 0 ? void 0 : node.parent) === null || _d === void 0 ? void 0 : _d.id]) {
838
+ if (node.index > lastGroupNode[(_e = node === null || node === void 0 ? void 0 : node.parent) === null || _e === void 0 ? void 0 : _e.id].index) {
839
+ lastGroupNode[(_f = node === null || node === void 0 ? void 0 : node.parent) === null || _f === void 0 ? void 0 : _f.id] = node;
840
+ }
841
+ }
842
+ else {
843
+ lastGroupNode[(_g = node === null || node === void 0 ? void 0 : node.parent) === null || _g === void 0 ? void 0 : _g.id] = node;
844
+ }
845
+ });
846
+ var parents = new Map();
847
+ each(groups, function (nodes, parentId) {
848
+ var lastNode = lastGroupNode[parentId];
849
+ var insertPoint = lastNode;
850
+ each(nodes, function (node) {
851
+ var _a, _b;
852
+ var cloned = node.clone();
853
+ if (!cloned)
854
+ return;
855
+ if (((_a = node.operation) === null || _a === void 0 ? void 0 : _a.selection.has(node)) &&
856
+ insertPoint.parent.allowAppend([cloned])) {
857
+ insertPoint.insertAfter(cloned);
858
+ insertPoint = insertPoint.next;
859
+ }
860
+ else if (node.operation.selection.length === 1) {
861
+ var targetNode = (_b = node.operation) === null || _b === void 0 ? void 0 : _b.tree.findById(node.operation.selection.first);
862
+ var cloneNodes = parents.get(targetNode);
863
+ if (!cloneNodes) {
864
+ cloneNodes = [];
865
+ parents.set(targetNode, cloneNodes);
866
+ }
867
+ if (targetNode && targetNode.allowAppend([cloned])) {
868
+ cloneNodes.push(cloned);
869
+ }
870
+ }
871
+ });
872
+ });
873
+ parents.forEach(function (nodes, target) {
874
+ if (!nodes.length)
875
+ return;
876
+ target.append.apply(target, __spreadArray([], __read(nodes), false));
877
+ });
878
+ };
879
+ TreeNode.filterResizable = function (nodes) {
880
+ if (nodes === void 0) { nodes = []; }
881
+ return nodes.filter(function (node) { return node.allowResize(); });
882
+ };
883
+ TreeNode.filterRotatable = function (nodes) {
884
+ if (nodes === void 0) { nodes = []; }
885
+ return nodes.filter(function (node) { return node.allowRotate(); });
886
+ };
887
+ TreeNode.filterScalable = function (nodes) {
888
+ if (nodes === void 0) { nodes = []; }
889
+ return nodes.filter(function (node) { return node.allowScale(); });
890
+ };
891
+ TreeNode.filterRoundable = function (nodes) {
892
+ if (nodes === void 0) { nodes = []; }
893
+ return nodes.filter(function (node) { return node.allowRound(); });
894
+ };
895
+ TreeNode.filterTranslatable = function (nodes) {
896
+ if (nodes === void 0) { nodes = []; }
897
+ return nodes.filter(function (node) { return node.allowTranslate(); });
898
+ };
899
+ TreeNode.filterDraggable = function (nodes) {
900
+ if (nodes === void 0) { nodes = []; }
901
+ return nodes.reduce(function (buf, node) {
902
+ var _a;
903
+ if (!node.allowDrag())
904
+ return buf;
905
+ if (isFn((_a = node === null || node === void 0 ? void 0 : node.designerProps) === null || _a === void 0 ? void 0 : _a.getDragNodes)) {
906
+ var transformed = node.designerProps.getDragNodes(node);
907
+ return transformed ? buf.concat(transformed) : buf;
908
+ }
909
+ if (node.componentName === '$$ResourceNode$$')
910
+ return buf.concat(node.children);
911
+ return buf.concat([node]);
912
+ }, []);
913
+ };
914
+ TreeNode.filterDroppable = function (nodes, parent) {
915
+ if (nodes === void 0) { nodes = []; }
916
+ return nodes.reduce(function (buf, node) {
917
+ var _a;
918
+ if (!node.allowDrop(parent))
919
+ return buf;
920
+ if (isFn((_a = node.designerProps) === null || _a === void 0 ? void 0 : _a.getDropNodes)) {
921
+ var cloned = node.isSourceNode ? node.clone(node.parent) : node;
922
+ var transformed = node.designerProps.getDropNodes(cloned, parent);
923
+ return transformed ? buf.concat(transformed) : buf;
924
+ }
925
+ if (node.componentName === '$$ResourceNode$$')
926
+ return buf.concat(node.children);
927
+ return buf.concat([node]);
928
+ }, []);
929
+ };
930
+ return TreeNode;
931
+ }());
932
+ export { TreeNode };