@pairdraw/vue 0.19.2 → 0.21.0

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 (477) hide show
  1. package/dist/canvas/CanvasRoot.vue.js +5 -0
  2. package/dist/canvas/CanvasRoot.vue.js.map +1 -1
  3. package/dist/canvas/auto-layout/value-edit.js +1 -1
  4. package/dist/canvas/auto-layout/value-edit.js.map +1 -1
  5. package/dist/canvas/eyedropper/index.d.ts +26 -0
  6. package/dist/canvas/eyedropper/index.d.ts.map +1 -0
  7. package/dist/canvas/eyedropper/index.js +62 -0
  8. package/dist/canvas/eyedropper/index.js.map +1 -0
  9. package/dist/canvas/eyedropper/sample.js +13 -0
  10. package/dist/canvas/eyedropper/sample.js.map +1 -0
  11. package/dist/canvas/eyedropper/use.d.ts +33 -0
  12. package/dist/canvas/eyedropper/use.d.ts.map +1 -0
  13. package/dist/canvas/eyedropper/use.js +52 -0
  14. package/dist/canvas/eyedropper/use.js.map +1 -0
  15. package/dist/canvas/pointer/drag-move.js +4 -0
  16. package/dist/canvas/pointer/drag-move.js.map +1 -1
  17. package/dist/canvas/surface/color-space.d.ts +1 -0
  18. package/dist/canvas/surface/color-space.d.ts.map +1 -1
  19. package/dist/canvas/surface/gl-surface.js +5 -1
  20. package/dist/canvas/surface/gl-surface.js.map +1 -1
  21. package/dist/canvas/surface/kit-loader.js +2 -3
  22. package/dist/canvas/surface/kit-loader.js.map +1 -1
  23. package/dist/canvas/surface/lifecycle.js +34 -3
  24. package/dist/canvas/surface/lifecycle.js.map +1 -1
  25. package/dist/canvas/surface/origin.js +14 -0
  26. package/dist/canvas/surface/origin.js.map +1 -0
  27. package/dist/canvas/surface/shader/plan.js +40 -0
  28. package/dist/canvas/surface/shader/plan.js.map +1 -0
  29. package/dist/canvas/surface/shader/playback.js +132 -36
  30. package/dist/canvas/surface/shader/playback.js.map +1 -1
  31. package/dist/canvas/surface/shader/stage.d.ts.map +1 -1
  32. package/dist/canvas/surface/shader/stage.js +42 -5
  33. package/dist/canvas/surface/shader/stage.js.map +1 -1
  34. package/dist/canvas/surface/types.d.ts +25 -0
  35. package/dist/canvas/surface/types.d.ts.map +1 -1
  36. package/dist/canvas/surface/use.js +3 -1
  37. package/dist/canvas/surface/use.js.map +1 -1
  38. package/dist/canvas/text-edit/textarea.d.ts +1 -0
  39. package/dist/canvas/text-edit/textarea.d.ts.map +1 -1
  40. package/dist/canvas/tools/registry.js +5 -1
  41. package/dist/canvas/tools/registry.js.map +1 -1
  42. package/dist/canvas/useCanvasInput.d.ts +144 -2
  43. package/dist/canvas/useCanvasInput.d.ts.map +1 -1
  44. package/dist/canvas/useCanvasInput.js +3 -2
  45. package/dist/canvas/useCanvasInput.js.map +1 -1
  46. package/dist/controls/appearance/use.d.ts +1 -1
  47. package/dist/controls/binding-provider/pairdraw.js +1 -1
  48. package/dist/controls/binding-provider/pairdraw.js.map +1 -1
  49. package/dist/controls/color-model/types.d.ts +6 -0
  50. package/dist/controls/color-model/types.d.ts.map +1 -1
  51. package/dist/controls/color-model/use.d.ts.map +1 -1
  52. package/dist/controls/color-model/use.js +5 -3
  53. package/dist/controls/color-model/use.js.map +1 -1
  54. package/dist/controls/document-colors/index.d.ts +2 -0
  55. package/dist/controls/document-colors/index.js +2 -0
  56. package/dist/controls/document-colors/use.d.ts +20 -0
  57. package/dist/controls/document-colors/use.d.ts.map +1 -0
  58. package/dist/controls/document-colors/use.js +35 -0
  59. package/dist/controls/document-colors/use.js.map +1 -0
  60. package/dist/controls/effects/helpers.d.ts +13 -2
  61. package/dist/controls/effects/helpers.d.ts.map +1 -1
  62. package/dist/controls/effects/helpers.js +89 -34
  63. package/dist/controls/effects/helpers.js.map +1 -1
  64. package/dist/controls/effects/index.d.ts +2 -1
  65. package/dist/controls/effects/index.js +2 -1
  66. package/dist/controls/effects/use.d.ts +9 -7
  67. package/dist/controls/effects/use.d.ts.map +1 -1
  68. package/dist/controls/effects/use.js +6 -3
  69. package/dist/controls/effects/use.js.map +1 -1
  70. package/dist/controls/okhcl/use.d.ts +2 -2
  71. package/dist/controls/shader/catalog.d.ts +11 -0
  72. package/dist/controls/shader/catalog.d.ts.map +1 -1
  73. package/dist/controls/shader/catalog.js +35 -6
  74. package/dist/controls/shader/catalog.js.map +1 -1
  75. package/dist/controls/shader/gallery.d.ts +1 -1
  76. package/dist/controls/shader/gallery.d.ts.map +1 -1
  77. package/dist/controls/shader/gallery.js +292 -0
  78. package/dist/controls/shader/gallery.js.map +1 -1
  79. package/dist/controls/shader/index.d.ts +3 -1
  80. package/dist/controls/shader/index.js +3 -1
  81. package/dist/controls/shader/shapes.d.ts +18 -0
  82. package/dist/controls/shader/shapes.d.ts.map +1 -0
  83. package/dist/controls/shader/shapes.js +227 -0
  84. package/dist/controls/shader/shapes.js.map +1 -0
  85. package/dist/controls/shader/stops.d.ts +22 -0
  86. package/dist/controls/shader/stops.d.ts.map +1 -0
  87. package/dist/controls/shader/stops.js +73 -0
  88. package/dist/controls/shader/stops.js.map +1 -0
  89. package/dist/controls/typography/features.d.ts +24 -0
  90. package/dist/controls/typography/features.d.ts.map +1 -0
  91. package/dist/controls/typography/features.js +130 -0
  92. package/dist/controls/typography/features.js.map +1 -0
  93. package/dist/controls/typography/index.d.ts +2 -1
  94. package/dist/controls/typography/index.js +2 -1
  95. package/dist/controls/typography/use.d.ts +6 -0
  96. package/dist/controls/typography/use.d.ts.map +1 -1
  97. package/dist/controls/typography/use.js +4 -1
  98. package/dist/controls/typography/use.js.map +1 -1
  99. package/dist/controls/variable-modes/helpers.d.ts.map +1 -1
  100. package/dist/controls/variable-modes/helpers.js +4 -2
  101. package/dist/controls/variable-modes/helpers.js.map +1 -1
  102. package/dist/editor/commands/registry.d.ts +4 -0
  103. package/dist/editor/commands/registry.d.ts.map +1 -1
  104. package/dist/editor/commands/registry.js +2 -0
  105. package/dist/editor/commands/registry.js.map +1 -1
  106. package/dist/editor/commands/selection.js +22 -0
  107. package/dist/editor/commands/selection.js.map +1 -1
  108. package/dist/editor/commands/types.d.ts +1 -1
  109. package/dist/editor/commands/types.d.ts.map +1 -1
  110. package/dist/editor/menu-model/canvas.d.ts.map +1 -1
  111. package/dist/editor/menu-model/canvas.js +7 -1
  112. package/dist/editor/menu-model/canvas.js.map +1 -1
  113. package/dist/editor/selection-capabilities/use.d.ts +2 -0
  114. package/dist/editor/selection-capabilities/use.js +5 -0
  115. package/dist/editor/selection-capabilities/use.js.map +1 -1
  116. package/dist/editor/selection-state/use.d.ts +1 -0
  117. package/dist/editor/selection-state/use.js +5 -0
  118. package/dist/editor/selection-state/use.js.map +1 -1
  119. package/dist/editor/tool-cursor/index.d.ts.map +1 -1
  120. package/dist/editor/tool-cursor/index.js +5 -1
  121. package/dist/editor/tool-cursor/index.js.map +1 -1
  122. package/dist/i18n/create.d.ts +1 -1
  123. package/dist/i18n/create.d.ts.map +1 -1
  124. package/dist/i18n/create.js +1 -0
  125. package/dist/i18n/create.js.map +1 -1
  126. package/dist/i18n/index.d.ts +5 -2
  127. package/dist/i18n/index.js +5 -2
  128. package/dist/i18n/locale.d.ts +5 -4
  129. package/dist/i18n/locale.d.ts.map +1 -1
  130. package/dist/i18n/locale.js +4 -0
  131. package/dist/i18n/locale.js.map +1 -1
  132. package/dist/i18n/locales/de/ai.json.js +68 -2
  133. package/dist/i18n/locales/de/commands.json.js +2 -0
  134. package/dist/i18n/locales/de/comments.json.js +1 -1
  135. package/dist/i18n/locales/de/design-check.json.js +13 -1
  136. package/dist/i18n/locales/de/design-memory.json.js +82 -0
  137. package/dist/i18n/locales/de/design-memory.json.js.map +1 -0
  138. package/dist/i18n/locales/de/fonts.json.js +10 -0
  139. package/dist/i18n/locales/de/index.js +5 -1
  140. package/dist/i18n/locales/de/index.js.map +1 -1
  141. package/dist/i18n/locales/de/menu.json.js +2 -0
  142. package/dist/i18n/locales/de/panels.json.js +109 -1
  143. package/dist/i18n/locales/de/settings.json.js +1 -0
  144. package/dist/i18n/locales/de/tools.json.js +3 -1
  145. package/dist/i18n/locales/de/variables/panel.json.js +20 -0
  146. package/dist/i18n/locales/de/variations.json.js +23 -0
  147. package/dist/i18n/locales/de/variations.json.js.map +1 -0
  148. package/dist/i18n/locales/es/ai.json.js +67 -1
  149. package/dist/i18n/locales/es/commands.json.js +2 -0
  150. package/dist/i18n/locales/es/comments.json.js +1 -1
  151. package/dist/i18n/locales/es/design-check.json.js +13 -1
  152. package/dist/i18n/locales/es/design-memory.json.js +82 -0
  153. package/dist/i18n/locales/es/design-memory.json.js.map +1 -0
  154. package/dist/i18n/locales/es/fonts.json.js +10 -0
  155. package/dist/i18n/locales/es/index.js +5 -1
  156. package/dist/i18n/locales/es/index.js.map +1 -1
  157. package/dist/i18n/locales/es/menu.json.js +2 -0
  158. package/dist/i18n/locales/es/panels.json.js +109 -1
  159. package/dist/i18n/locales/es/settings.json.js +1 -0
  160. package/dist/i18n/locales/es/tools.json.js +3 -1
  161. package/dist/i18n/locales/es/variables/panel.json.js +20 -0
  162. package/dist/i18n/locales/es/variations.json.js +23 -0
  163. package/dist/i18n/locales/es/variations.json.js.map +1 -0
  164. package/dist/i18n/locales/fr/ai.json.js +68 -2
  165. package/dist/i18n/locales/fr/commands.json.js +2 -0
  166. package/dist/i18n/locales/fr/comments.json.js +1 -1
  167. package/dist/i18n/locales/fr/design-check.json.js +13 -1
  168. package/dist/i18n/locales/fr/design-memory.json.js +82 -0
  169. package/dist/i18n/locales/fr/design-memory.json.js.map +1 -0
  170. package/dist/i18n/locales/fr/fonts.json.js +10 -0
  171. package/dist/i18n/locales/fr/index.js +5 -1
  172. package/dist/i18n/locales/fr/index.js.map +1 -1
  173. package/dist/i18n/locales/fr/menu.json.js +2 -0
  174. package/dist/i18n/locales/fr/panels.json.js +109 -1
  175. package/dist/i18n/locales/fr/settings.json.js +1 -0
  176. package/dist/i18n/locales/fr/tools.json.js +3 -1
  177. package/dist/i18n/locales/fr/variables/panel.json.js +20 -0
  178. package/dist/i18n/locales/fr/variations.json.js +23 -0
  179. package/dist/i18n/locales/fr/variations.json.js.map +1 -0
  180. package/dist/i18n/locales/id/agents.json.js +31 -0
  181. package/dist/i18n/locales/id/agents.json.js.map +1 -0
  182. package/dist/i18n/locales/id/ai.json.js +608 -0
  183. package/dist/i18n/locales/id/ai.json.js.map +1 -0
  184. package/dist/i18n/locales/id/automation.json.js +150 -0
  185. package/dist/i18n/locales/id/automation.json.js.map +1 -0
  186. package/dist/i18n/locales/id/browser.json.js +50 -0
  187. package/dist/i18n/locales/id/browser.json.js.map +1 -0
  188. package/dist/i18n/locales/id/chat-context.json.js +62 -0
  189. package/dist/i18n/locales/id/chat-context.json.js.map +1 -0
  190. package/dist/i18n/locales/id/cloud/editor.json.js +337 -0
  191. package/dist/i18n/locales/id/cloud/editor.json.js.map +1 -0
  192. package/dist/i18n/locales/id/cloud/portal.json.js +435 -0
  193. package/dist/i18n/locales/id/cloud/portal.json.js.map +1 -0
  194. package/dist/i18n/locales/id/code.json.js +43 -0
  195. package/dist/i18n/locales/id/code.json.js.map +1 -0
  196. package/dist/i18n/locales/id/collaboration.json.js +84 -0
  197. package/dist/i18n/locales/id/collaboration.json.js.map +1 -0
  198. package/dist/i18n/locales/id/commands.json.js +111 -0
  199. package/dist/i18n/locales/id/commands.json.js.map +1 -0
  200. package/dist/i18n/locales/id/comments.json.js +37 -0
  201. package/dist/i18n/locales/id/comments.json.js.map +1 -0
  202. package/dist/i18n/locales/id/common.json.js +51 -0
  203. package/dist/i18n/locales/id/common.json.js.map +1 -0
  204. package/dist/i18n/locales/id/credentials.json.js +21 -0
  205. package/dist/i18n/locales/id/credentials.json.js.map +1 -0
  206. package/dist/i18n/locales/id/design-check.json.js +101 -0
  207. package/dist/i18n/locales/id/design-check.json.js.map +1 -0
  208. package/dist/i18n/locales/id/design-memory.json.js +61 -0
  209. package/dist/i18n/locales/id/design-memory.json.js.map +1 -0
  210. package/dist/i18n/locales/id/diagnostics.json.js +78 -0
  211. package/dist/i18n/locales/id/diagnostics.json.js.map +1 -0
  212. package/dist/i18n/locales/id/editor.json.js +62 -0
  213. package/dist/i18n/locales/id/editor.json.js.map +1 -0
  214. package/dist/i18n/locales/id/explore.json.js +30 -0
  215. package/dist/i18n/locales/id/explore.json.js.map +1 -0
  216. package/dist/i18n/locales/id/figjam.json.js +39 -0
  217. package/dist/i18n/locales/id/figjam.json.js.map +1 -0
  218. package/dist/i18n/locales/id/files.json.js +86 -0
  219. package/dist/i18n/locales/id/files.json.js.map +1 -0
  220. package/dist/i18n/locales/id/fonts.json.js +54 -0
  221. package/dist/i18n/locales/id/fonts.json.js.map +1 -0
  222. package/dist/i18n/locales/id/index.js +85 -0
  223. package/dist/i18n/locales/id/index.js.map +1 -0
  224. package/dist/i18n/locales/id/media.json.js +52 -0
  225. package/dist/i18n/locales/id/media.json.js.map +1 -0
  226. package/dist/i18n/locales/id/menu.json.js +118 -0
  227. package/dist/i18n/locales/id/menu.json.js.map +1 -0
  228. package/dist/i18n/locales/id/pages.json.js +16 -0
  229. package/dist/i18n/locales/id/pages.json.js.map +1 -0
  230. package/dist/i18n/locales/id/panels.json.js +838 -0
  231. package/dist/i18n/locales/id/panels.json.js.map +1 -0
  232. package/dist/i18n/locales/id/recovery.json.js +36 -0
  233. package/dist/i18n/locales/id/recovery.json.js.map +1 -0
  234. package/dist/i18n/locales/id/rename.json.js +19 -0
  235. package/dist/i18n/locales/id/rename.json.js.map +1 -0
  236. package/dist/i18n/locales/id/rendering.json.js +18 -0
  237. package/dist/i18n/locales/id/rendering.json.js.map +1 -0
  238. package/dist/i18n/locales/id/settings.json.js +169 -0
  239. package/dist/i18n/locales/id/settings.json.js.map +1 -0
  240. package/dist/i18n/locales/id/shaders.json.js +24 -0
  241. package/dist/i18n/locales/id/shaders.json.js.map +1 -0
  242. package/dist/i18n/locales/id/shapes.json.js +48 -0
  243. package/dist/i18n/locales/id/shapes.json.js.map +1 -0
  244. package/dist/i18n/locales/id/slides.json.js +27 -0
  245. package/dist/i18n/locales/id/slides.json.js.map +1 -0
  246. package/dist/i18n/locales/id/statuses.json.js +38 -0
  247. package/dist/i18n/locales/id/statuses.json.js.map +1 -0
  248. package/dist/i18n/locales/id/storage.json.js +21 -0
  249. package/dist/i18n/locales/id/storage.json.js.map +1 -0
  250. package/dist/i18n/locales/id/tools.json.js +27 -0
  251. package/dist/i18n/locales/id/tools.json.js.map +1 -0
  252. package/dist/i18n/locales/id/updates.json.js +31 -0
  253. package/dist/i18n/locales/id/updates.json.js.map +1 -0
  254. package/dist/i18n/locales/id/variables/panel.json.js +175 -0
  255. package/dist/i18n/locales/id/variables/panel.json.js.map +1 -0
  256. package/dist/i18n/locales/id/variables/types.json.js +15 -0
  257. package/dist/i18n/locales/id/variables/types.json.js.map +1 -0
  258. package/dist/i18n/locales/id/variations.json.js +23 -0
  259. package/dist/i18n/locales/id/variations.json.js.map +1 -0
  260. package/dist/i18n/locales/it/ai.json.js +68 -2
  261. package/dist/i18n/locales/it/commands.json.js +2 -0
  262. package/dist/i18n/locales/it/comments.json.js +1 -1
  263. package/dist/i18n/locales/it/design-check.json.js +13 -1
  264. package/dist/i18n/locales/it/design-memory.json.js +82 -0
  265. package/dist/i18n/locales/it/design-memory.json.js.map +1 -0
  266. package/dist/i18n/locales/it/fonts.json.js +10 -0
  267. package/dist/i18n/locales/it/index.js +5 -1
  268. package/dist/i18n/locales/it/index.js.map +1 -1
  269. package/dist/i18n/locales/it/menu.json.js +2 -0
  270. package/dist/i18n/locales/it/panels.json.js +109 -1
  271. package/dist/i18n/locales/it/settings.json.js +1 -0
  272. package/dist/i18n/locales/it/tools.json.js +3 -1
  273. package/dist/i18n/locales/it/variables/panel.json.js +20 -0
  274. package/dist/i18n/locales/it/variations.json.js +23 -0
  275. package/dist/i18n/locales/it/variations.json.js.map +1 -0
  276. package/dist/i18n/locales/ja/ai.json.js +68 -2
  277. package/dist/i18n/locales/ja/commands.json.js +2 -0
  278. package/dist/i18n/locales/ja/comments.json.js +1 -1
  279. package/dist/i18n/locales/ja/design-check.json.js +13 -1
  280. package/dist/i18n/locales/ja/design-memory.json.js +61 -0
  281. package/dist/i18n/locales/ja/design-memory.json.js.map +1 -0
  282. package/dist/i18n/locales/ja/fonts.json.js +10 -0
  283. package/dist/i18n/locales/ja/index.js +5 -1
  284. package/dist/i18n/locales/ja/index.js.map +1 -1
  285. package/dist/i18n/locales/ja/menu.json.js +2 -0
  286. package/dist/i18n/locales/ja/panels.json.js +106 -1
  287. package/dist/i18n/locales/ja/settings.json.js +1 -0
  288. package/dist/i18n/locales/ja/tools.json.js +3 -1
  289. package/dist/i18n/locales/ja/variables/panel.json.js +20 -0
  290. package/dist/i18n/locales/ja/variations.json.js +23 -0
  291. package/dist/i18n/locales/ja/variations.json.js.map +1 -0
  292. package/dist/i18n/locales/pl/ai.json.js +68 -2
  293. package/dist/i18n/locales/pl/commands.json.js +2 -0
  294. package/dist/i18n/locales/pl/comments.json.js +1 -1
  295. package/dist/i18n/locales/pl/design-check.json.js +13 -1
  296. package/dist/i18n/locales/pl/design-memory.json.js +89 -0
  297. package/dist/i18n/locales/pl/design-memory.json.js.map +1 -0
  298. package/dist/i18n/locales/pl/fonts.json.js +10 -0
  299. package/dist/i18n/locales/pl/index.js +5 -1
  300. package/dist/i18n/locales/pl/index.js.map +1 -1
  301. package/dist/i18n/locales/pl/menu.json.js +2 -0
  302. package/dist/i18n/locales/pl/panels.json.js +110 -1
  303. package/dist/i18n/locales/pl/settings.json.js +1 -0
  304. package/dist/i18n/locales/pl/tools.json.js +3 -1
  305. package/dist/i18n/locales/pl/variables/panel.json.js +20 -0
  306. package/dist/i18n/locales/pl/variations.json.js +23 -0
  307. package/dist/i18n/locales/pl/variations.json.js.map +1 -0
  308. package/dist/i18n/locales/ru/ai.json.js +68 -2
  309. package/dist/i18n/locales/ru/commands.json.js +3 -1
  310. package/dist/i18n/locales/ru/comments.json.js +1 -1
  311. package/dist/i18n/locales/ru/design-check.json.js +13 -1
  312. package/dist/i18n/locales/ru/design-memory.json.js +89 -0
  313. package/dist/i18n/locales/ru/design-memory.json.js.map +1 -0
  314. package/dist/i18n/locales/ru/fonts.json.js +10 -0
  315. package/dist/i18n/locales/ru/index.js +5 -1
  316. package/dist/i18n/locales/ru/index.js.map +1 -1
  317. package/dist/i18n/locales/ru/menu.json.js +2 -0
  318. package/dist/i18n/locales/ru/panels.json.js +110 -1
  319. package/dist/i18n/locales/ru/settings.json.js +1 -0
  320. package/dist/i18n/locales/ru/tools.json.js +3 -1
  321. package/dist/i18n/locales/ru/variables/panel.json.js +20 -0
  322. package/dist/i18n/locales/ru/variations.json.js +23 -0
  323. package/dist/i18n/locales/ru/variations.json.js.map +1 -0
  324. package/dist/i18n/locales/zh-cn/ai.json.js +68 -2
  325. package/dist/i18n/locales/zh-cn/commands.json.js +2 -0
  326. package/dist/i18n/locales/zh-cn/comments.json.js +1 -1
  327. package/dist/i18n/locales/zh-cn/design-check.json.js +13 -1
  328. package/dist/i18n/locales/zh-cn/design-memory.json.js +61 -0
  329. package/dist/i18n/locales/zh-cn/design-memory.json.js.map +1 -0
  330. package/dist/i18n/locales/zh-cn/fonts.json.js +10 -0
  331. package/dist/i18n/locales/zh-cn/index.js +5 -1
  332. package/dist/i18n/locales/zh-cn/index.js.map +1 -1
  333. package/dist/i18n/locales/zh-cn/menu.json.js +2 -0
  334. package/dist/i18n/locales/zh-cn/panels.json.js +106 -1
  335. package/dist/i18n/locales/zh-cn/settings.json.js +1 -0
  336. package/dist/i18n/locales/zh-cn/tools.json.js +3 -1
  337. package/dist/i18n/locales/zh-cn/variables/panel.json.js +20 -0
  338. package/dist/i18n/locales/zh-cn/variations.json.js +23 -0
  339. package/dist/i18n/locales/zh-cn/variations.json.js.map +1 -0
  340. package/dist/i18n/messages/ai.d.ts +98 -2
  341. package/dist/i18n/messages/ai.d.ts.map +1 -1
  342. package/dist/i18n/messages/ai.js +70 -2
  343. package/dist/i18n/messages/ai.js.map +1 -1
  344. package/dist/i18n/messages/chat-usage.d.ts +34 -0
  345. package/dist/i18n/messages/chat-usage.d.ts.map +1 -0
  346. package/dist/i18n/messages/chat-usage.js +25 -0
  347. package/dist/i18n/messages/chat-usage.js.map +1 -0
  348. package/dist/i18n/messages/commands.d.ts +2 -0
  349. package/dist/i18n/messages/commands.d.ts.map +1 -1
  350. package/dist/i18n/messages/commands.js +2 -0
  351. package/dist/i18n/messages/commands.js.map +1 -1
  352. package/dist/i18n/messages/comments.d.ts +2 -2
  353. package/dist/i18n/messages/comments.js +2 -2
  354. package/dist/i18n/messages/comments.js.map +1 -1
  355. package/dist/i18n/messages/design-check.d.ts +12 -0
  356. package/dist/i18n/messages/design-check.d.ts.map +1 -1
  357. package/dist/i18n/messages/design-check.js +13 -1
  358. package/dist/i18n/messages/design-check.js.map +1 -1
  359. package/dist/i18n/messages/design-memory.d.ts +68 -0
  360. package/dist/i18n/messages/design-memory.d.ts.map +1 -0
  361. package/dist/i18n/messages/design-memory.js +85 -0
  362. package/dist/i18n/messages/design-memory.js.map +1 -0
  363. package/dist/i18n/messages/fonts.d.ts +12 -0
  364. package/dist/i18n/messages/fonts.d.ts.map +1 -1
  365. package/dist/i18n/messages/fonts.js +10 -0
  366. package/dist/i18n/messages/fonts.js.map +1 -1
  367. package/dist/i18n/messages/menu.d.ts +2 -0
  368. package/dist/i18n/messages/menu.d.ts.map +1 -1
  369. package/dist/i18n/messages/menu.js +2 -0
  370. package/dist/i18n/messages/menu.js.map +1 -1
  371. package/dist/i18n/messages/panels.d.ts +131 -0
  372. package/dist/i18n/messages/panels.d.ts.map +1 -1
  373. package/dist/i18n/messages/panels.js +109 -1
  374. package/dist/i18n/messages/panels.js.map +1 -1
  375. package/dist/i18n/messages/settings.d.ts +1 -0
  376. package/dist/i18n/messages/settings.d.ts.map +1 -1
  377. package/dist/i18n/messages/settings.js +1 -0
  378. package/dist/i18n/messages/settings.js.map +1 -1
  379. package/dist/i18n/messages/tools.d.ts +2 -0
  380. package/dist/i18n/messages/tools.d.ts.map +1 -1
  381. package/dist/i18n/messages/tools.js +3 -1
  382. package/dist/i18n/messages/tools.js.map +1 -1
  383. package/dist/i18n/messages/variables/panel.d.ts +24 -0
  384. package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
  385. package/dist/i18n/messages/variables/panel.js +20 -0
  386. package/dist/i18n/messages/variables/panel.js.map +1 -1
  387. package/dist/i18n/messages/variations.d.ts +28 -0
  388. package/dist/i18n/messages/variations.d.ts.map +1 -0
  389. package/dist/i18n/messages/variations.js +26 -0
  390. package/dist/i18n/messages/variations.js.map +1 -0
  391. package/dist/i18n/messages.d.ts +405 -4
  392. package/dist/i18n/messages.d.ts.map +1 -1
  393. package/dist/i18n/messages.js +8 -2
  394. package/dist/i18n/messages.js.map +1 -1
  395. package/dist/i18n/useI18n.d.ts +1389 -13
  396. package/dist/i18n/useI18n.d.ts.map +1 -1
  397. package/dist/i18n/useI18n.js +8 -1
  398. package/dist/i18n/useI18n.js.map +1 -1
  399. package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts +6 -0
  400. package/dist/primitives/ColorPicker/ColorInputRoot.vue.d.ts.map +1 -1
  401. package/dist/primitives/ColorPicker/ColorInputRoot.vue.js +3 -1
  402. package/dist/primitives/ColorPicker/ColorInputRoot.vue.js.map +1 -1
  403. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +11 -2
  404. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
  405. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +15 -5
  406. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
  407. package/dist/primitives/ColorPicker/index.d.ts +2 -1
  408. package/dist/primitives/ColorPicker/index.js +2 -1
  409. package/dist/primitives/ColorPicker/outside.d.ts +16 -0
  410. package/dist/primitives/ColorPicker/outside.d.ts.map +1 -0
  411. package/dist/primitives/ColorPicker/outside.js +20 -0
  412. package/dist/primitives/ColorPicker/outside.js.map +1 -0
  413. package/dist/primitives/Fill/FillRoot.vue.d.ts +2 -1
  414. package/dist/primitives/Fill/FillRoot.vue.d.ts.map +1 -1
  415. package/dist/primitives/Fill/FillRoot.vue.js +5 -2
  416. package/dist/primitives/Fill/FillRoot.vue.js.map +1 -1
  417. package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
  418. package/dist/primitives/Fill/FillSwatch.vue.js +2 -1
  419. package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
  420. package/dist/primitives/Fill/types.d.ts +6 -1
  421. package/dist/primitives/Fill/types.d.ts.map +1 -1
  422. package/dist/primitives/Fill/useFill.d.ts +10 -4
  423. package/dist/primitives/Fill/useFill.d.ts.map +1 -1
  424. package/dist/primitives/Fill/useFill.js +14 -10
  425. package/dist/primitives/Fill/useFill.js.map +1 -1
  426. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +5 -0
  427. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
  428. package/dist/primitives/FontPicker/FontPickerRoot.vue.js +63 -56
  429. package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
  430. package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts +2 -1
  431. package/dist/primitives/GradientEditor/GradientEditorRoot.vue.d.ts.map +1 -1
  432. package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js +5 -2
  433. package/dist/primitives/GradientEditor/GradientEditorRoot.vue.js.map +1 -1
  434. package/dist/primitives/GradientEditor/GradientEditorStop.vue.d.ts.map +1 -1
  435. package/dist/primitives/GradientEditor/GradientEditorStop.vue.js +4 -3
  436. package/dist/primitives/GradientEditor/GradientEditorStop.vue.js.map +1 -1
  437. package/dist/primitives/GradientEditor/types.d.ts +3 -1
  438. package/dist/primitives/GradientEditor/types.d.ts.map +1 -1
  439. package/dist/primitives/GradientEditor/useGradientStops.d.ts +5 -3
  440. package/dist/primitives/GradientEditor/useGradientStops.d.ts.map +1 -1
  441. package/dist/primitives/GradientEditor/useGradientStops.js +9 -4
  442. package/dist/primitives/GradientEditor/useGradientStops.js.map +1 -1
  443. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +6 -1
  444. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
  445. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +16 -1
  446. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
  447. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts +3 -0
  448. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.d.ts.map +1 -1
  449. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js +3 -1
  450. package/dist/primitives/TypographyControls/TypographyControlsRoot.vue.js.map +1 -1
  451. package/dist/shared/assets/cursors/eyedropper.svg.js +6 -0
  452. package/dist/shared/assets/cursors/eyedropper.svg.js.map +1 -0
  453. package/dist/shared/frame.d.ts +28 -0
  454. package/dist/shared/frame.d.ts.map +1 -0
  455. package/dist/shared/frame.js +92 -0
  456. package/dist/shared/frame.js.map +1 -0
  457. package/dist/shared/input/auto-layout/drag.js +71 -0
  458. package/dist/shared/input/auto-layout/drag.js.map +1 -0
  459. package/dist/shared/input/{auto-layout-hover.d.ts → auto-layout/hover.d.ts} +3 -3
  460. package/dist/shared/input/auto-layout/hover.d.ts.map +1 -0
  461. package/dist/shared/input/{auto-layout-hover.js → auto-layout/hover.js} +42 -86
  462. package/dist/shared/input/auto-layout/hover.js.map +1 -0
  463. package/dist/shared/input/{auto-layout.js → auto-layout/index.js} +2 -2
  464. package/dist/shared/input/auto-layout/index.js.map +1 -0
  465. package/dist/shared/input/index.d.ts +1 -1
  466. package/dist/shared/input/index.js +1 -1
  467. package/dist/shared/input/move/drag.js +1 -1
  468. package/dist/shared/input/resize.js +1 -1
  469. package/dist/shared/input/select.js +5 -3
  470. package/dist/shared/input/select.js.map +1 -1
  471. package/dist/shared/input/types.d.ts +10 -2
  472. package/dist/shared/input/types.d.ts.map +1 -1
  473. package/dist/shared/input/types.js.map +1 -1
  474. package/package.json +19 -4
  475. package/dist/shared/input/auto-layout-hover.d.ts.map +0 -1
  476. package/dist/shared/input/auto-layout-hover.js.map +0 -1
  477. package/dist/shared/input/auto-layout.js.map +0 -1
@@ -21,7 +21,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
21
21
  "toggleLock",
22
22
  "rename"
23
23
  ],
24
- setup(__props, { emit: __emit }) {
24
+ setup(__props, { expose: __expose, emit: __emit }) {
25
25
  const emit = __emit;
26
26
  const editor = useEditor();
27
27
  const items = ref([]);
@@ -109,6 +109,18 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
109
109
  rowRefs.get(id)?.scrollIntoView({ block: "nearest" });
110
110
  });
111
111
  }
112
+ /** Moves the list to a row without selecting it, for keyboard focus and Tab. */
113
+ function reveal(id) {
114
+ const index = visibleRows.value.findIndex((row) => row.node.id === id);
115
+ if (index !== -1 && virtualizer) {
116
+ virtualizer.scrollToIndex(index, { align: "auto" });
117
+ return;
118
+ }
119
+ rowRefs.get(id)?.scrollIntoView({
120
+ block: "nearest",
121
+ inline: "nearest"
122
+ });
123
+ }
112
124
  function onSelectionChanged(ids) {
113
125
  expandSelectionAncestors(ids);
114
126
  if (applyingSelection) return;
@@ -173,11 +185,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
173
185
  const actions = {
174
186
  select,
175
187
  toggleExpand,
188
+ reveal,
176
189
  setFocused: (value) => {
177
190
  focused.value = value;
178
191
  },
179
192
  setVirtualizer
180
193
  };
194
+ /** The rows as listed, top to bottom, for a consumer that sizes or measures them. */
195
+ __expose({ visibleRows });
181
196
  provideLayerTree({
182
197
  editor,
183
198
  items,
@@ -1 +1 @@
1
- {"version":3,"file":"LayerTreeRoot.vue.js","names":[],"sources":["../../../src/primitives/LayerTree/LayerTreeRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TreeRoot } from 'reka-ui'\nimport { computed, nextTick, onScopeDispose, reactive, ref } from 'vue'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { useEditor } from '#vue/editor/context'\nimport { LAYER_OUTLINE_FIELDS, provideLayerTree } from '#vue/primitives/LayerTree/context'\nimport type {\n LayerNode,\n LayerSelectionMode,\n LayerTreeVirtualizer\n} from '#vue/primitives/LayerTree/context'\nimport {\n buildLayerTreeModel,\n layerSelectionForTarget,\n patchLayerNode,\n visibleLayerRows\n} from '#vue/primitives/LayerTree/model'\nimport { useLayerDrag } from '#vue/primitives/LayerTree/useLayerDrag'\n\nconst { indentPerLevel = 16, multiple = false } = defineProps<{\n indentPerLevel?: number\n /** Whether the tree selects more than one layer at a time; Reka announces it to assistive tech. */\n multiple?: boolean\n}>()\n\nconst emit = defineEmits<{\n select: [id: string, additive: boolean]\n toggleExpand: [id: string]\n toggleVisibility: [id: string]\n toggleLock: [id: string]\n rename: [id: string, name: string]\n}>()\n\nconst editor = useEditor()\nconst items = ref<LayerNode[]>([])\nconst expanded = ref<string[]>([])\nconst treeVersion = ref(0)\nconst selectedIds = computed(() => editor.state.selectedIds)\nconst focused = ref(false)\nconst visibleRows = computed(() => visibleLayerRows(items.value, new Set(expanded.value)))\nlet nodesById = new Map<string, LayerNode>()\nlet virtualizer: LayerTreeVirtualizer | null = null\nlet selectionAnchorId: string | null = null\nlet applyingSelection = false\n\nfunction expandNode(id: string) {\n if (!expanded.value.includes(id)) expanded.value = [...expanded.value, id]\n}\n\nconst { draggingId, instruction, instructionTargetId, setupItem } = useLayerDrag(\n editor,\n indentPerLevel,\n expandNode\n)\n\nlet rebuildPending = false\nlet rebuildToken = 0\n\nfunction rebuildTree() {\n rebuildPending = false\n rebuildToken++\n const model = buildLayerTreeModel(editor.graph, editor.state.currentPageId)\n items.value = model.items\n nodesById = model.byId\n expanded.value = expanded.value.filter((id) => nodesById.has(id))\n treeVersion.value++\n}\n\nfunction scheduleTreeRebuild() {\n if (rebuildPending) return\n rebuildPending = true\n const token = ++rebuildToken\n queueMicrotask(() => {\n if (!rebuildPending || token !== rebuildToken) return\n rebuildTree()\n })\n}\n\nrebuildTree()\n\nconst PATCHABLE_NODE_KEYS = new Set<keyof SceneNode>([\n 'name',\n 'type',\n 'layoutMode',\n 'visible',\n 'locked',\n 'variableModes',\n 'isMask',\n 'fills',\n 'strokes',\n ...LAYER_OUTLINE_FIELDS\n])\n\nfunction patchTreeNode(id: string, changes: Partial<SceneNode>) {\n // A layout mode turns a layer's rows between front-most first and flow order.\n const reordersRows = 'layoutMode' in changes && !!nodesById.get(id)?.children?.length\n // Coalesced with creates and deletes, so an edit that moves many layers rebuilds once.\n if ('childIds' in changes || 'parentId' in changes || reordersRows) {\n scheduleTreeRebuild()\n return\n }\n // The rebuild reads every row again.\n if (rebuildPending) return\n if (!(Object.keys(changes) as (keyof SceneNode)[]).some((key) => PATCHABLE_NODE_KEYS.has(key))) {\n return\n }\n const target = nodesById.get(id)\n const source = editor.graph.getNode(id)\n // The index holds the plain rows; writing through their reactive proxy updates every view of\n // them, including values a row derives and caches, such as its variable mode tags.\n if (target && source) patchLayerNode(reactive(target), source)\n}\n\nconst rowRefs = new Map<string, HTMLElement>()\n\nfunction setRowRef(id: string, el: HTMLElement | null) {\n if (el) rowRefs.set(id, el)\n else rowRefs.delete(id)\n}\n\nfunction expandSelectionAncestors(ids: readonly string[]) {\n const next = new Set(expanded.value)\n for (const id of ids) {\n let node = editor.graph.getNode(id)\n while (node?.parentId && node.parentId !== editor.state.currentPageId) {\n next.add(node.parentId)\n node = editor.graph.getNode(node.parentId)\n }\n }\n if (next.size !== expanded.value.length) expanded.value = [...next]\n}\n\nfunction scrollToNode(id: string) {\n void nextTick(() => {\n const index = visibleRows.value.findIndex((row) => row.node.id === id)\n if (index !== -1 && virtualizer) {\n virtualizer.scrollToIndex(index, { align: 'auto' })\n return\n }\n rowRefs.get(id)?.scrollIntoView({ block: 'nearest' })\n })\n}\n\nfunction onSelectionChanged(ids: string[]) {\n expandSelectionAncestors(ids)\n if (applyingSelection) return\n const visibleIds = new Set(visibleRows.value.map((row) => row.node.id))\n selectionAnchorId = ids.find((id) => visibleIds.has(id)) ?? null\n if (selectionAnchorId) scrollToNode(selectionAnchorId)\n}\n\nconst unsubscribe = [\n editor.onEditorEvent('graph:replaced', rebuildTree),\n editor.onEditorEvent('page:changed', rebuildTree),\n editor.onEditorEvent('node:created', scheduleTreeRebuild),\n editor.onEditorEvent('node:deleted', scheduleTreeRebuild),\n editor.onEditorEvent('node:reparented', scheduleTreeRebuild),\n editor.onEditorEvent('node:reordered', scheduleTreeRebuild),\n editor.onEditorEvent('node:updated', patchTreeNode),\n editor.onEditorEvent('selection:changed', onSelectionChanged)\n]\n\nonScopeDispose(() => {\n for (const stop of unsubscribe) stop()\n})\n\n/**\n * Leaves canvas clicks as a click on the picked layer would, as in Figma: the panel enters what a\n * double-click on it enters, and never a container that is open by itself.\n */\nfunction syncCanvasScope(nodeId: string) {\n if (!editor.graph.getNode(nodeId)) return\n editor.enterContainerOf(nodeId)\n}\n\nfunction select(id: string, selection: boolean | LayerSelectionMode) {\n const mode = typeof selection === 'boolean' ? { additive: selection, range: false } : selection\n emit('select', id, mode.additive)\n const visibleIds = visibleRows.value.map((row) => row.node.id)\n const next = layerSelectionForTarget(\n visibleIds,\n editor.state.selectedIds,\n selectionAnchorId,\n id,\n mode\n )\n if (!mode.range) selectionAnchorId = id\n applyingSelection = true\n try {\n // Adding a layer goes through the editor, which drops its selected ancestors and descendants.\n if (mode.additive && !mode.range) editor.select([id], true)\n else editor.select([...next])\n } finally {\n applyingSelection = false\n }\n // A layer picked here leaves canvas clicks as a click on it there would, as in Figma.\n if (!mode.additive && !mode.range) syncCanvasScope(id)\n scrollToNode(id)\n}\n\nfunction toggleExpand(id: string) {\n emit('toggleExpand', id)\n const index = expanded.value.indexOf(id)\n if (index !== -1) expanded.value = expanded.value.filter((expandedId) => expandedId !== id)\n else expandNode(id)\n}\n\nfunction getKey(node: LayerNode) {\n return node.id\n}\n\nfunction getChildren(node: LayerNode) {\n return node.children\n}\n\nfunction setVirtualizer(next: LayerTreeVirtualizer) {\n virtualizer = next\n}\n\nconst actions = {\n select,\n toggleExpand,\n setFocused: (value: boolean) => {\n focused.value = value\n },\n setVirtualizer\n}\n\nprovideLayerTree({\n editor,\n items,\n expanded,\n visibleRows,\n treeVersion,\n selectedIds,\n focused,\n indentPerLevel,\n draggingId,\n instruction,\n instructionTargetId,\n setupDrag: setupItem,\n select,\n toggleExpand,\n setFocused: actions.setFocused,\n setVirtualizer,\n toggleVisibility: (id: string) => {\n emit('toggleVisibility', id)\n editor.toggleNodeVisibility(id)\n },\n toggleLock: (id: string) => {\n emit('toggleLock', id)\n editor.toggleNodeLock(id)\n },\n rename: (id: string, name: string) => {\n emit('rename', id, name)\n editor.renameNode(id, name)\n },\n setRowRef\n})\n</script>\n\n<template>\n <TreeRoot\n v-slot=\"{ flattenItems }\"\n v-model:expanded=\"expanded\"\n as=\"div\"\n class=\"flex min-h-0 flex-1 flex-col overflow-hidden\"\n :items=\"items\"\n :get-key=\"getKey\"\n :get-children=\"getChildren\"\n :multiple=\"multiple\"\n >\n <slot\n :items=\"items\"\n :flatten-items=\"flattenItems\"\n :visible-rows=\"visibleRows\"\n :expanded=\"expanded\"\n :tree-version=\"treeVersion\"\n :selected-ids=\"selectedIds\"\n :focused=\"focused\"\n :dragging-id=\"draggingId\"\n :instruction=\"instruction\"\n :instruction-target-id=\"instructionTargetId\"\n :actions=\"actions\"\n />\n </TreeRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAM,OAAO;EAQb,MAAM,SAAS,UAAU;EACzB,MAAM,QAAQ,IAAiB,CAAC,CAAC;EACjC,MAAM,WAAW,IAAc,CAAC,CAAC;EACjC,MAAM,cAAc,IAAI,CAAC;EACzB,MAAM,cAAc,eAAe,OAAO,MAAM,WAAW;EAC3D,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,cAAc,eAAe,iBAAiB,MAAM,OAAO,IAAI,IAAI,SAAS,KAAK,CAAC,CAAC;EACzF,IAAI,4BAAY,IAAI,IAAuB;EAC3C,IAAI,cAA2C;EAC/C,IAAI,oBA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B;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA,gBAAa,QAAA;GACb;GACA;GACA;GACA,WAAW;GACX;GACA;GACA,YAAY,QAAQ;GACpB;GACA,mBAAmB,OAAe;IAChC,KAAK,oBAAoB,EAAE;IAC3B,OAAO,qBAAqB,EAAE;GAChC;GACA,aAAa,OAAe;IAC1B,KAAK,cAAc,EAAE;IACrB,OAAO,eAAe,EAAE;GAC1B;GACA,SAAS,IAAY,SAAiB;IACpC,KAAK,UAAU,IAAI,IAAI;IACvB,OAAO,WAAW,IAAI,IAAI;GAC5B;GACA;EACF,CAAC;;GAIC,OAAA,UAAA,GAAA,YAuBW,MAAA,QAAA,GAAA;IArBD,UAAU,SAAA;IAAA,qBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,SAAQ,QAAA;IAC1B,IAAG;IACH,OAAM;IACL,OAAO,MAAA;IACP,WAAS;IACT,gBAAc;IACd,UAAU,QAAA;;IAcT,SAAA,SAAA,EArBQ,mBAAY,CAStB,WAYE,KAAA,QAAA,WAAA;KAXC,OAAO,MAAA;KACQ;KACf,aAAc,YAAA;KACd,UAAU,SAAA;KACV,aAAc,YAAA;KACd,aAAc,YAAA;KACd,SAAS,QAAA;KACT,YAAa,MAAA,UAAA;KACb,aAAa,MAAA,WAAA;KACb,qBAAuB,MAAA,mBAAA;KACd"}
1
+ {"version":3,"file":"LayerTreeRoot.vue.js","names":[],"sources":["../../../src/primitives/LayerTree/LayerTreeRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TreeRoot } from 'reka-ui'\nimport { computed, nextTick, onScopeDispose, reactive, ref } from 'vue'\n\nimport type { SceneNode } from '@pairdraw/scene-graph'\n\nimport { useEditor } from '#vue/editor/context'\nimport { LAYER_OUTLINE_FIELDS, provideLayerTree } from '#vue/primitives/LayerTree/context'\nimport type {\n LayerNode,\n LayerSelectionMode,\n LayerTreeVirtualizer\n} from '#vue/primitives/LayerTree/context'\nimport {\n buildLayerTreeModel,\n layerSelectionForTarget,\n patchLayerNode,\n visibleLayerRows\n} from '#vue/primitives/LayerTree/model'\nimport { useLayerDrag } from '#vue/primitives/LayerTree/useLayerDrag'\n\nconst { indentPerLevel = 16, multiple = false } = defineProps<{\n indentPerLevel?: number\n /** Whether the tree selects more than one layer at a time; Reka announces it to assistive tech. */\n multiple?: boolean\n}>()\n\nconst emit = defineEmits<{\n select: [id: string, additive: boolean]\n toggleExpand: [id: string]\n toggleVisibility: [id: string]\n toggleLock: [id: string]\n rename: [id: string, name: string]\n}>()\n\nconst editor = useEditor()\nconst items = ref<LayerNode[]>([])\nconst expanded = ref<string[]>([])\nconst treeVersion = ref(0)\nconst selectedIds = computed(() => editor.state.selectedIds)\nconst focused = ref(false)\nconst visibleRows = computed(() => visibleLayerRows(items.value, new Set(expanded.value)))\nlet nodesById = new Map<string, LayerNode>()\nlet virtualizer: LayerTreeVirtualizer | null = null\nlet selectionAnchorId: string | null = null\nlet applyingSelection = false\n\nfunction expandNode(id: string) {\n if (!expanded.value.includes(id)) expanded.value = [...expanded.value, id]\n}\n\nconst { draggingId, instruction, instructionTargetId, setupItem } = useLayerDrag(\n editor,\n indentPerLevel,\n expandNode\n)\n\nlet rebuildPending = false\nlet rebuildToken = 0\n\nfunction rebuildTree() {\n rebuildPending = false\n rebuildToken++\n const model = buildLayerTreeModel(editor.graph, editor.state.currentPageId)\n items.value = model.items\n nodesById = model.byId\n expanded.value = expanded.value.filter((id) => nodesById.has(id))\n treeVersion.value++\n}\n\nfunction scheduleTreeRebuild() {\n if (rebuildPending) return\n rebuildPending = true\n const token = ++rebuildToken\n queueMicrotask(() => {\n if (!rebuildPending || token !== rebuildToken) return\n rebuildTree()\n })\n}\n\nrebuildTree()\n\nconst PATCHABLE_NODE_KEYS = new Set<keyof SceneNode>([\n 'name',\n 'type',\n 'layoutMode',\n 'visible',\n 'locked',\n 'variableModes',\n 'isMask',\n 'fills',\n 'strokes',\n ...LAYER_OUTLINE_FIELDS\n])\n\nfunction patchTreeNode(id: string, changes: Partial<SceneNode>) {\n // A layout mode turns a layer's rows between front-most first and flow order.\n const reordersRows = 'layoutMode' in changes && !!nodesById.get(id)?.children?.length\n // Coalesced with creates and deletes, so an edit that moves many layers rebuilds once.\n if ('childIds' in changes || 'parentId' in changes || reordersRows) {\n scheduleTreeRebuild()\n return\n }\n // The rebuild reads every row again.\n if (rebuildPending) return\n if (!(Object.keys(changes) as (keyof SceneNode)[]).some((key) => PATCHABLE_NODE_KEYS.has(key))) {\n return\n }\n const target = nodesById.get(id)\n const source = editor.graph.getNode(id)\n // The index holds the plain rows; writing through their reactive proxy updates every view of\n // them, including values a row derives and caches, such as its variable mode tags.\n if (target && source) patchLayerNode(reactive(target), source)\n}\n\nconst rowRefs = new Map<string, HTMLElement>()\n\nfunction setRowRef(id: string, el: HTMLElement | null) {\n if (el) rowRefs.set(id, el)\n else rowRefs.delete(id)\n}\n\nfunction expandSelectionAncestors(ids: readonly string[]) {\n const next = new Set(expanded.value)\n for (const id of ids) {\n let node = editor.graph.getNode(id)\n while (node?.parentId && node.parentId !== editor.state.currentPageId) {\n next.add(node.parentId)\n node = editor.graph.getNode(node.parentId)\n }\n }\n if (next.size !== expanded.value.length) expanded.value = [...next]\n}\n\nfunction scrollToNode(id: string) {\n void nextTick(() => {\n const index = visibleRows.value.findIndex((row) => row.node.id === id)\n if (index !== -1 && virtualizer) {\n virtualizer.scrollToIndex(index, { align: 'auto' })\n return\n }\n rowRefs.get(id)?.scrollIntoView({ block: 'nearest' })\n })\n}\n\n/** Moves the list to a row without selecting it, for keyboard focus and Tab. */\nfunction reveal(id: string) {\n const index = visibleRows.value.findIndex((row) => row.node.id === id)\n if (index !== -1 && virtualizer) {\n virtualizer.scrollToIndex(index, { align: 'auto' })\n return\n }\n rowRefs.get(id)?.scrollIntoView({ block: 'nearest', inline: 'nearest' })\n}\n\nfunction onSelectionChanged(ids: string[]) {\n expandSelectionAncestors(ids)\n if (applyingSelection) return\n const visibleIds = new Set(visibleRows.value.map((row) => row.node.id))\n selectionAnchorId = ids.find((id) => visibleIds.has(id)) ?? null\n if (selectionAnchorId) scrollToNode(selectionAnchorId)\n}\n\nconst unsubscribe = [\n editor.onEditorEvent('graph:replaced', rebuildTree),\n editor.onEditorEvent('page:changed', rebuildTree),\n editor.onEditorEvent('node:created', scheduleTreeRebuild),\n editor.onEditorEvent('node:deleted', scheduleTreeRebuild),\n editor.onEditorEvent('node:reparented', scheduleTreeRebuild),\n editor.onEditorEvent('node:reordered', scheduleTreeRebuild),\n editor.onEditorEvent('node:updated', patchTreeNode),\n editor.onEditorEvent('selection:changed', onSelectionChanged)\n]\n\nonScopeDispose(() => {\n for (const stop of unsubscribe) stop()\n})\n\n/**\n * Leaves canvas clicks as a click on the picked layer would, as in Figma: the panel enters what a\n * double-click on it enters, and never a container that is open by itself.\n */\nfunction syncCanvasScope(nodeId: string) {\n if (!editor.graph.getNode(nodeId)) return\n editor.enterContainerOf(nodeId)\n}\n\nfunction select(id: string, selection: boolean | LayerSelectionMode) {\n const mode = typeof selection === 'boolean' ? { additive: selection, range: false } : selection\n emit('select', id, mode.additive)\n const visibleIds = visibleRows.value.map((row) => row.node.id)\n const next = layerSelectionForTarget(\n visibleIds,\n editor.state.selectedIds,\n selectionAnchorId,\n id,\n mode\n )\n if (!mode.range) selectionAnchorId = id\n applyingSelection = true\n try {\n // Adding a layer goes through the editor, which drops its selected ancestors and descendants.\n if (mode.additive && !mode.range) editor.select([id], true)\n else editor.select([...next])\n } finally {\n applyingSelection = false\n }\n // A layer picked here leaves canvas clicks as a click on it there would, as in Figma.\n if (!mode.additive && !mode.range) syncCanvasScope(id)\n scrollToNode(id)\n}\n\nfunction toggleExpand(id: string) {\n emit('toggleExpand', id)\n const index = expanded.value.indexOf(id)\n if (index !== -1) expanded.value = expanded.value.filter((expandedId) => expandedId !== id)\n else expandNode(id)\n}\n\nfunction getKey(node: LayerNode) {\n return node.id\n}\n\nfunction getChildren(node: LayerNode) {\n return node.children\n}\n\nfunction setVirtualizer(next: LayerTreeVirtualizer) {\n virtualizer = next\n}\n\nconst actions = {\n select,\n toggleExpand,\n reveal,\n setFocused: (value: boolean) => {\n focused.value = value\n },\n setVirtualizer\n}\n\n/** The rows as listed, top to bottom, for a consumer that sizes or measures them. */\ndefineExpose({ visibleRows })\n\nprovideLayerTree({\n editor,\n items,\n expanded,\n visibleRows,\n treeVersion,\n selectedIds,\n focused,\n indentPerLevel,\n draggingId,\n instruction,\n instructionTargetId,\n setupDrag: setupItem,\n select,\n toggleExpand,\n setFocused: actions.setFocused,\n setVirtualizer,\n toggleVisibility: (id: string) => {\n emit('toggleVisibility', id)\n editor.toggleNodeVisibility(id)\n },\n toggleLock: (id: string) => {\n emit('toggleLock', id)\n editor.toggleNodeLock(id)\n },\n rename: (id: string, name: string) => {\n emit('rename', id, name)\n editor.renameNode(id, name)\n },\n setRowRef\n})\n</script>\n\n<template>\n <TreeRoot\n v-slot=\"{ flattenItems }\"\n v-model:expanded=\"expanded\"\n as=\"div\"\n class=\"flex min-h-0 flex-1 flex-col overflow-hidden\"\n :items=\"items\"\n :get-key=\"getKey\"\n :get-children=\"getChildren\"\n :multiple=\"multiple\"\n >\n <slot\n :items=\"items\"\n :flatten-items=\"flattenItems\"\n :visible-rows=\"visibleRows\"\n :expanded=\"expanded\"\n :tree-version=\"treeVersion\"\n :selected-ids=\"selectedIds\"\n :focused=\"focused\"\n :dragging-id=\"draggingId\"\n :instruction=\"instruction\"\n :instruction-target-id=\"instructionTargetId\"\n :actions=\"actions\"\n />\n </TreeRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA2BA,MAAM,OAAO;EAQb,MAAM,SAAS,UAAU;EACzB,MAAM,QAAQ,IAAiB,CAAC,CAAC;EACjC,MAAM,WAAW,IAAc,CAAC,CAAC;EACjC,MAAM,cAAc,IAAI,CAAC;EACzB,MAAM,cAAc,eAAe,OAAO,MAAM,WAAW;EAC3D,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,cAAc,eAAe,iB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,qBAAuB,MAAA,mBAAA;KACd"}
@@ -1,4 +1,5 @@
1
1
  import { MixedValue } from "../../controls/node-props/helpers.js";
2
+ import { TypographyFeature } from "../../controls/typography/features.js";
2
3
  import { TypographyAxis } from "../../controls/typography/axes.js";
3
4
  import { TypographyFontLoader } from "../../controls/typography/use.js";
4
5
  import { AcceptableValue } from "reka-ui";
@@ -25,6 +26,8 @@ declare var __VLS_1: {
25
26
  listType: import("vue").ComputedRef<import("@pairdraw/scene-graph").TextListType | null>;
26
27
  axes: import("vue").ComputedRef<TypographyAxis[]>;
27
28
  opticalSizeAuto: import("vue").ComputedRef<MixedValue<boolean>>;
29
+ availableFeatures: import("vue").ComputedRef<TypographyFeature[]>;
30
+ featureState: (tag: string) => MixedValue<boolean>;
28
31
  actions: {
29
32
  setFamily: (family: string) => Promise<void>;
30
33
  setWeight: (weight: number, targets?: import("@pairdraw/scene-graph").SceneNode[]) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"TypographyControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"mappings":";;;;;KA0EK;EACH,aAAa;;iBAON,cAAc,KAAK;iBAInB,mBAAmB,KAAK,kBAAkB;YAkE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,gBAAA,2CAAA,qCAAA,iDAAA,aAAA,SAAA,eAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"TypographyControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"mappings":";;;;;;KA4EK;EACH,aAAa;;iBAON,cAAc,KAAK;iBAInB,mBAAmB,KAAK,kBAAkB;YAoE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,gBAAA,2CAAA,qCAAA,iDAAA,aAAA,SAAA,eAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -20,7 +20,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
20
20
  setVerticalAlign: ctx.setVerticalAlign,
21
21
  setTextCase: ctx.setTextCase,
22
22
  setTruncation: ctx.setTruncation,
23
- setFontFeature: ctx.setFontFeature,
23
+ setFontFeature: ctx.features.set,
24
24
  setListType: ctx.setListType,
25
25
  setHangingList: ctx.setHangingList,
26
26
  previewParagraphSpacing: ctx.previewParagraphSpacing,
@@ -53,6 +53,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
53
53
  listType: unref(ctx).listType,
54
54
  axes: unref(ctx).axes,
55
55
  opticalSizeAuto: unref(ctx).opticalSizeAuto,
56
+ availableFeatures: unref(ctx).features.available,
57
+ featureState: unref(ctx).features.state,
56
58
  actions
57
59
  });
58
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TypographyControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { AcceptableValue } from 'reka-ui'\n\nimport { useTypography } from '#vue/controls/typography/use'\nimport type { TypographyFontLoader } from '#vue/controls/typography/use'\n\nconst { fontLoader } = defineProps<{\n fontLoader?: TypographyFontLoader\n}>()\n\nconst ctx = useTypography({ fontLoader })\n\nfunction onAlignChange(val: AcceptableValue) {\n if (val) ctx.setAlign(val as 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED')\n}\n\nfunction onFormattingChange(val: AcceptableValue | AcceptableValue[]) {\n if (Array.isArray(val)) ctx.onFormattingChange(val as string[])\n}\n\nconst actions = {\n setFamily: ctx.setFamily,\n setWeight: ctx.setWeight,\n setFace: ctx.setFace,\n setDirection: ctx.setDirection,\n setVerticalAlign: ctx.setVerticalAlign,\n setTextCase: ctx.setTextCase,\n setTruncation: ctx.setTruncation,\n setFontFeature: ctx.setFontFeature,\n setListType: ctx.setListType,\n setHangingList: ctx.setHangingList,\n previewParagraphSpacing: ctx.previewParagraphSpacing,\n setParagraphSpacing: ctx.setParagraphSpacing,\n updateProp: ctx.updateProp,\n commitProp: ctx.commitProp,\n cancelProp: ctx.cancelProp,\n align: onAlignChange,\n formatting: onFormattingChange,\n toggleBold: ctx.toggleBold,\n toggleItalic: ctx.toggleItalic,\n toggleDecoration: ctx.toggleDecoration,\n previewAxis: ctx.previewAxis,\n cancelAxis: ctx.cancelAxis,\n setAxis: ctx.setAxis,\n setOpticalSizeAuto: ctx.setOpticalSizeAuto\n}\n</script>\n\n<template>\n <slot\n :node=\"ctx.node\"\n :nodes=\"ctx.nodes\"\n :merged=\"ctx.merged\"\n :paragraph-spacing=\"ctx.paragraphSpacing\"\n :font-feature=\"ctx.fontFeature\"\n :faces=\"ctx.faces\"\n :face-name=\"ctx.faceName\"\n :missing-fonts=\"ctx.missingFonts\"\n :has-missing-fonts=\"ctx.hasMissingFonts\"\n :active-formatting=\"ctx.activeFormatting\"\n :list-type=\"ctx.listType\"\n :axes=\"ctx.axes\"\n :optical-size-auto=\"ctx.opticalSizeAuto\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;EAUA,MAAM,MAAM,cAAc,EAAE,YAAS,QAAA,WAAE,CAAC;EAExC,SAAS,cAAc,KAAsB;GAC3C,IAAI,KAAK,IAAI,SAAS,GAAgD;EACxE;EAEA,SAAS,mBAAmB,KAA0C;GACpE,IAAI,MAAM,QAAQ,GAAG,GAAG,IAAI,mBAAmB,GAAe;EAChE;EAEA,MAAM,UAAU;GACd,WAAW,IAAI;GACf,WAAW,IAAI;GACf,SAAS,IAAI;GACb,cAAc,IAAI;GAClB,kBAAkB,IAAI;GACtB,aAAa,IAAI;GACjB,eAAe,IAAI;GACnB,gBAAgB,IAAI;GACpB,aAAa,IAAI;GACjB,gBAAgB,IAAI;GACpB,yBAAyB,IAAI;GAC7B,qBAAqB,IAAI;GACzB,YAAY,IAAI;GAChB,YAAY,IAAI;GAChB,YAAY,IAAI;GAChB,OAAO;GACP,YAAY;GACZ,YAAY,IAAI;GAChB,cAAc,IAAI;GAClB,kBAAkB,IAAI;GACtB,aAAa,IAAI;GACjB,YAAY,IAAI;GAChB,SAAS,IAAI;GACb,oBAAoB,IAAI;EAC1B;;GAIE,OAAA,WAeE,KAAA,QAAA,WAAA;IAdC,MAAM,MAAA,GAAA,CAAG,CAAC;IACV,OAAO,MAAA,GAAA,CAAG,CAAC;IACX,QAAQ,MAAA,GAAA,CAAG,CAAC;IACZ,kBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,aAAc,MAAA,GAAA,CAAG,CAAC;IAClB,OAAO,MAAA,GAAA,CAAG,CAAC;IACX,UAAW,MAAA,GAAA,CAAG,CAAC;IACf,cAAe,MAAA,GAAA,CAAG,CAAC;IACnB,iBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,kBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,UAAW,MAAA,GAAA,CAAG,CAAC;IACf,MAAM,MAAA,GAAA,CAAG,CAAC;IACV,iBAAmB,MAAA,GAAA,CAAG,CAAC;IACd"}
1
+ {"version":3,"file":"TypographyControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/TypographyControls/TypographyControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { AcceptableValue } from 'reka-ui'\n\nimport { useTypography } from '#vue/controls/typography/use'\nimport type { TypographyFontLoader } from '#vue/controls/typography/use'\n\nconst { fontLoader } = defineProps<{\n fontLoader?: TypographyFontLoader\n}>()\n\nconst ctx = useTypography({ fontLoader })\n\nfunction onAlignChange(val: AcceptableValue) {\n if (val) ctx.setAlign(val as 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFIED')\n}\n\nfunction onFormattingChange(val: AcceptableValue | AcceptableValue[]) {\n if (Array.isArray(val)) ctx.onFormattingChange(val as string[])\n}\n\nconst actions = {\n setFamily: ctx.setFamily,\n setWeight: ctx.setWeight,\n setFace: ctx.setFace,\n setDirection: ctx.setDirection,\n setVerticalAlign: ctx.setVerticalAlign,\n setTextCase: ctx.setTextCase,\n setTruncation: ctx.setTruncation,\n setFontFeature: ctx.features.set,\n setListType: ctx.setListType,\n setHangingList: ctx.setHangingList,\n previewParagraphSpacing: ctx.previewParagraphSpacing,\n setParagraphSpacing: ctx.setParagraphSpacing,\n updateProp: ctx.updateProp,\n commitProp: ctx.commitProp,\n cancelProp: ctx.cancelProp,\n align: onAlignChange,\n formatting: onFormattingChange,\n toggleBold: ctx.toggleBold,\n toggleItalic: ctx.toggleItalic,\n toggleDecoration: ctx.toggleDecoration,\n previewAxis: ctx.previewAxis,\n cancelAxis: ctx.cancelAxis,\n setAxis: ctx.setAxis,\n setOpticalSizeAuto: ctx.setOpticalSizeAuto\n}\n</script>\n\n<template>\n <slot\n :node=\"ctx.node\"\n :nodes=\"ctx.nodes\"\n :merged=\"ctx.merged\"\n :paragraph-spacing=\"ctx.paragraphSpacing\"\n :font-feature=\"ctx.fontFeature\"\n :faces=\"ctx.faces\"\n :face-name=\"ctx.faceName\"\n :missing-fonts=\"ctx.missingFonts\"\n :has-missing-fonts=\"ctx.hasMissingFonts\"\n :active-formatting=\"ctx.activeFormatting\"\n :list-type=\"ctx.listType\"\n :axes=\"ctx.axes\"\n :optical-size-auto=\"ctx.opticalSizeAuto\"\n :available-features=\"ctx.features.available\"\n :feature-state=\"ctx.features.state\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;EAUA,MAAM,MAAM,cAAc,EAAE,YAAS,QAAA,WAAE,CAAC;EAExC,SAAS,cAAc,KAAsB;GAC3C,IAAI,KAAK,IAAI,SAAS,GAAgD;EACxE;EAEA,SAAS,mBAAmB,KAA0C;GACpE,IAAI,MAAM,QAAQ,GAAG,GAAG,IAAI,mBAAmB,GAAe;EAChE;EAEA,MAAM,UAAU;GACd,WAAW,IAAI;GACf,WAAW,IAAI;GACf,SAAS,IAAI;GACb,cAAc,IAAI;GAClB,kBAAkB,IAAI;GACtB,aAAa,IAAI;GACjB,eAAe,IAAI;GACnB,gBAAgB,IAAI,SAAS;GAC7B,aAAa,IAAI;GACjB,gBAAgB,IAAI;GACpB,yBAAyB,IAAI;GAC7B,qBAAqB,IAAI;GACzB,YAAY,IAAI;GAChB,YAAY,IAAI;GAChB,YAAY,IAAI;GAChB,OAAO;GACP,YAAY;GACZ,YAAY,IAAI;GAChB,cAAc,IAAI;GAClB,kBAAkB,IAAI;GACtB,aAAa,IAAI;GACjB,YAAY,IAAI;GAChB,SAAS,IAAI;GACb,oBAAoB,IAAI;EAC1B;;GAIE,OAAA,WAiBE,KAAA,QAAA,WAAA;IAhBC,MAAM,MAAA,GAAA,CAAG,CAAC;IACV,OAAO,MAAA,GAAA,CAAG,CAAC;IACX,QAAQ,MAAA,GAAA,CAAG,CAAC;IACZ,kBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,aAAc,MAAA,GAAA,CAAG,CAAC;IAClB,OAAO,MAAA,GAAA,CAAG,CAAC;IACX,UAAW,MAAA,GAAA,CAAG,CAAC;IACf,cAAe,MAAA,GAAA,CAAG,CAAC;IACnB,iBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,kBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,UAAW,MAAA,GAAA,CAAG,CAAC;IACf,MAAM,MAAA,GAAA,CAAG,CAAC;IACV,iBAAmB,MAAA,GAAA,CAAG,CAAC;IACvB,mBAAoB,MAAA,GAAA,CAAG,CAAC,SAAS;IACjC,cAAe,MAAA,GAAA,CAAG,CAAC,SAAS;IACnB"}
@@ -0,0 +1,6 @@
1
+ //#region src/shared/assets/cursors/eyedropper.svg?raw
2
+ var eyedropper_default = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" viewBox=\"0 0 32 32\">\n <filter id=\"shadow\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feDropShadow dx=\"0\" dy=\"1.25\" stdDeviation=\"1\" flood-opacity=\"0.5\"/>\n </filter>\n <g filter=\"url(#shadow)\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <g transform=\"translate(2.16 2.16) scale(0.8)\">\n <g fill=\"#fff\" stroke=\"#fff\" stroke-width=\"3.75\">\n <path d=\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\"/>\n <path d=\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z\"/>\n </g>\n <g fill=\"none\" stroke=\"#000\" stroke-width=\"1.25\">\n <path d=\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\"/>\n <path d=\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3zM2 22l.414-.414\"/>\n </g>\n </g>\n </g>\n</svg>\n";
3
+ //#endregion
4
+ export { eyedropper_default as default };
5
+
6
+ //# sourceMappingURL=eyedropper.svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eyedropper.svg.js","names":[],"sources":["../../../../src/shared/assets/cursors/eyedropper.svg?raw"],"sourcesContent":["export default \"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"32\\\" height=\\\"32\\\" viewBox=\\\"0 0 32 32\\\">\\n <filter id=\\\"shadow\\\" x=\\\"-50%\\\" y=\\\"-50%\\\" width=\\\"200%\\\" height=\\\"200%\\\">\\n <feDropShadow dx=\\\"0\\\" dy=\\\"1.25\\\" stdDeviation=\\\"1\\\" flood-opacity=\\\"0.5\\\"/>\\n </filter>\\n <g filter=\\\"url(#shadow)\\\" stroke-linecap=\\\"round\\\" stroke-linejoin=\\\"round\\\">\\n <g transform=\\\"translate(2.16 2.16) scale(0.8)\\\">\\n <g fill=\\\"#fff\\\" stroke=\\\"#fff\\\" stroke-width=\\\"3.75\\\">\\n <path d=\\\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\\\"/>\\n <path d=\\\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z\\\"/>\\n </g>\\n <g fill=\\\"none\\\" stroke=\\\"#000\\\" stroke-width=\\\"1.25\\\">\\n <path d=\\\"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12\\\"/>\\n <path d=\\\"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3zM2 22l.414-.414\\\"/>\\n </g>\\n </g>\\n </g>\\n</svg>\\n\""],"mappings":";AAAA,IAAA,qBAAe"}
@@ -0,0 +1,28 @@
1
+ import { Ref } from "vue";
2
+ //#region src/shared/frame.d.ts
3
+ type Visibility = Readonly<Ref<DocumentVisibilityState>>;
4
+ interface NextFrameOptions {
5
+ /** Whether the browser shows the page; the document's own by default. */
6
+ visibility?: Visibility;
7
+ }
8
+ interface NextShownFrameOptions extends NextFrameOptions {
9
+ /** Stops waiting, rejecting with the signal's reason, when the work it is for is cancelled. */
10
+ signal?: AbortSignal;
11
+ }
12
+ /**
13
+ * Lets the page lay out and draw before going on: resolves on the next animation frame. A
14
+ * hidden tab draws no frames and shows nothing, so work started in a background tab, such as
15
+ * opening a file or starting the canvas, goes on at once rather than waiting until the tab is
16
+ * shown again, and a tab hidden while waiting stops waiting.
17
+ */
18
+ declare function nextFrame(options?: NextFrameOptions): Promise<void>;
19
+ /**
20
+ * Waits for a frame drawn while the page is shown, by which the canvas has reported its size:
21
+ * a hidden tab reports none. Placing the view, such as fitting a page, waits for this so it
22
+ * uses the canvas's own size, while work before it goes on in a background tab. A tab hidden
23
+ * before its frame waits to be shown again.
24
+ */
25
+ declare function nextShownFrame(options?: NextShownFrameOptions): Promise<void>;
26
+ //#endregion
27
+ export { NextFrameOptions, NextShownFrameOptions, nextFrame, nextShownFrame };
28
+ //# sourceMappingURL=frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.d.ts","names":[],"sources":["../../src/shared/frame.ts"],"mappings":";;KAMK,aAAa,SAAS,IAAI;UAEd;;EAEf,aAAa;;UAGE,8BAA8B;;EAE7C,SAAS;;;;;;;;iBAsEW,UAAU,UAAS,mBAAwB;;;;;;;iBAY3C,eAAe,UAAS,wBAA6B"}
@@ -0,0 +1,92 @@
1
+ import { watch } from "vue";
2
+ import { useDocumentVisibility } from "@vueuse/core";
3
+ //#region src/shared/frame.ts
4
+ /** Whether the browser shows the page; shared by every wait. */
5
+ const documentVisibility = useDocumentVisibility();
6
+ function abortReason(signal) {
7
+ return signal.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError");
8
+ }
9
+ /** True once a frame runs while the page is shown; false if the page is hidden first. */
10
+ function frameWhileShown(visibility, signal) {
11
+ return new Promise((resolve, reject) => {
12
+ if (signal?.aborted) {
13
+ reject(abortReason(signal));
14
+ return;
15
+ }
16
+ let frame = 0;
17
+ const stop = watch(visibility, (state) => {
18
+ if (state === "hidden") finish(false);
19
+ });
20
+ const abort = () => {
21
+ cleanup();
22
+ if (signal) reject(abortReason(signal));
23
+ };
24
+ function cleanup() {
25
+ if (frame !== 0 && typeof cancelAnimationFrame === "function") cancelAnimationFrame(frame);
26
+ stop();
27
+ signal?.removeEventListener("abort", abort);
28
+ }
29
+ function finish(drawn) {
30
+ cleanup();
31
+ resolve(drawn);
32
+ }
33
+ signal?.addEventListener("abort", abort, { once: true });
34
+ frame = requestAnimationFrame(() => finish(true));
35
+ });
36
+ }
37
+ /** Resolves once the page is shown. */
38
+ function shown(visibility, signal) {
39
+ return new Promise((resolve, reject) => {
40
+ if (signal?.aborted) {
41
+ reject(abortReason(signal));
42
+ return;
43
+ }
44
+ if (visibility.value !== "hidden") {
45
+ resolve(void 0);
46
+ return;
47
+ }
48
+ const stop = watch(visibility, (state) => {
49
+ if (state === "hidden") return;
50
+ cleanup();
51
+ resolve(void 0);
52
+ });
53
+ const abort = () => {
54
+ cleanup();
55
+ if (signal) reject(abortReason(signal));
56
+ };
57
+ function cleanup() {
58
+ stop();
59
+ signal?.removeEventListener("abort", abort);
60
+ }
61
+ signal?.addEventListener("abort", abort, { once: true });
62
+ });
63
+ }
64
+ /**
65
+ * Lets the page lay out and draw before going on: resolves on the next animation frame. A
66
+ * hidden tab draws no frames and shows nothing, so work started in a background tab, such as
67
+ * opening a file or starting the canvas, goes on at once rather than waiting until the tab is
68
+ * shown again, and a tab hidden while waiting stops waiting.
69
+ */
70
+ async function nextFrame(options = {}) {
71
+ const visibility = options.visibility ?? documentVisibility;
72
+ if (visibility.value === "hidden") return;
73
+ await frameWhileShown(visibility);
74
+ }
75
+ /**
76
+ * Waits for a frame drawn while the page is shown, by which the canvas has reported its size:
77
+ * a hidden tab reports none. Placing the view, such as fitting a page, waits for this so it
78
+ * uses the canvas's own size, while work before it goes on in a background tab. A tab hidden
79
+ * before its frame waits to be shown again.
80
+ */
81
+ async function nextShownFrame(options = {}) {
82
+ const visibility = options.visibility ?? documentVisibility;
83
+ const { signal } = options;
84
+ for (;;) {
85
+ await shown(visibility, signal);
86
+ if (await frameWhileShown(visibility, signal)) return;
87
+ }
88
+ }
89
+ //#endregion
90
+ export { nextFrame, nextShownFrame };
91
+
92
+ //# sourceMappingURL=frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.js","names":[],"sources":["../../src/shared/frame.ts"],"sourcesContent":["import { useDocumentVisibility } from '@vueuse/core'\nimport { watch, type Ref } from 'vue'\n\n/** Whether the browser shows the page; shared by every wait. */\nconst documentVisibility = useDocumentVisibility()\n\ntype Visibility = Readonly<Ref<DocumentVisibilityState>>\n\nexport interface NextFrameOptions {\n /** Whether the browser shows the page; the document's own by default. */\n visibility?: Visibility\n}\n\nexport interface NextShownFrameOptions extends NextFrameOptions {\n /** Stops waiting, rejecting with the signal's reason, when the work it is for is cancelled. */\n signal?: AbortSignal\n}\n\nfunction abortReason(signal: AbortSignal): Error {\n return signal.reason instanceof Error ? signal.reason : new DOMException('Aborted', 'AbortError')\n}\n\n/** True once a frame runs while the page is shown; false if the page is hidden first. */\nfunction frameWhileShown(visibility: Visibility, signal?: AbortSignal): Promise<boolean> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(abortReason(signal))\n return\n }\n let frame = 0\n const stop = watch(visibility, (state) => {\n if (state === 'hidden') finish(false)\n })\n const abort = () => {\n cleanup()\n if (signal) reject(abortReason(signal))\n }\n function cleanup() {\n if (frame !== 0 && typeof cancelAnimationFrame === 'function') cancelAnimationFrame(frame)\n stop()\n signal?.removeEventListener('abort', abort)\n }\n function finish(drawn: boolean) {\n cleanup()\n resolve(drawn)\n }\n signal?.addEventListener('abort', abort, { once: true })\n frame = requestAnimationFrame(() => finish(true))\n })\n}\n\n/** Resolves once the page is shown. */\nfunction shown(visibility: Visibility, signal?: AbortSignal): Promise<undefined> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(abortReason(signal))\n return\n }\n if (visibility.value !== 'hidden') {\n resolve(undefined)\n return\n }\n const stop = watch(visibility, (state) => {\n if (state === 'hidden') return\n cleanup()\n resolve(undefined)\n })\n const abort = () => {\n cleanup()\n if (signal) reject(abortReason(signal))\n }\n function cleanup() {\n stop()\n signal?.removeEventListener('abort', abort)\n }\n signal?.addEventListener('abort', abort, { once: true })\n })\n}\n\n/**\n * Lets the page lay out and draw before going on: resolves on the next animation frame. A\n * hidden tab draws no frames and shows nothing, so work started in a background tab, such as\n * opening a file or starting the canvas, goes on at once rather than waiting until the tab is\n * shown again, and a tab hidden while waiting stops waiting.\n */\nexport async function nextFrame(options: NextFrameOptions = {}): Promise<void> {\n const visibility = options.visibility ?? documentVisibility\n if (visibility.value === 'hidden') return\n await frameWhileShown(visibility)\n}\n\n/**\n * Waits for a frame drawn while the page is shown, by which the canvas has reported its size:\n * a hidden tab reports none. Placing the view, such as fitting a page, waits for this so it\n * uses the canvas's own size, while work before it goes on in a background tab. A tab hidden\n * before its frame waits to be shown again.\n */\nexport async function nextShownFrame(options: NextShownFrameOptions = {}): Promise<void> {\n const visibility = options.visibility ?? documentVisibility\n const { signal } = options\n for (;;) {\n await shown(visibility, signal)\n if (await frameWhileShown(visibility, signal)) return\n }\n}\n"],"mappings":";;;;AAIA,MAAM,qBAAqB,sBAAsB;AAcjD,SAAS,YAAY,QAA4B;CAC/C,OAAO,OAAO,kBAAkB,QAAQ,OAAO,SAAS,IAAI,aAAa,WAAW,YAAY;AAClG;;AAGA,SAAS,gBAAgB,YAAwB,QAAwC;CACvF,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,QAAQ,SAAS;GACnB,OAAO,YAAY,MAAM,CAAC;GAC1B;EACF;EACA,IAAI,QAAQ;EACZ,MAAM,OAAO,MAAM,aAAa,UAAU;GACxC,IAAI,UAAU,UAAU,OAAO,KAAK;EACtC,CAAC;EACD,MAAM,cAAc;GAClB,QAAQ;GACR,IAAI,QAAQ,OAAO,YAAY,MAAM,CAAC;EACxC;EACA,SAAS,UAAU;GACjB,IAAI,UAAU,KAAK,OAAO,yBAAyB,YAAY,qBAAqB,KAAK;GACzF,KAAK;GACL,QAAQ,oBAAoB,SAAS,KAAK;EAC5C;EACA,SAAS,OAAO,OAAgB;GAC9B,QAAQ;GACR,QAAQ,KAAK;EACf;EACA,QAAQ,iBAAiB,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;EACvD,QAAQ,4BAA4B,OAAO,IAAI,CAAC;CAClD,CAAC;AACH;;AAGA,SAAS,MAAM,YAAwB,QAA0C;CAC/E,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,IAAI,QAAQ,SAAS;GACnB,OAAO,YAAY,MAAM,CAAC;GAC1B;EACF;EACA,IAAI,WAAW,UAAU,UAAU;GACjC,QAAQ,KAAA,CAAS;GACjB;EACF;EACA,MAAM,OAAO,MAAM,aAAa,UAAU;GACxC,IAAI,UAAU,UAAU;GACxB,QAAQ;GACR,QAAQ,KAAA,CAAS;EACnB,CAAC;EACD,MAAM,cAAc;GAClB,QAAQ;GACR,IAAI,QAAQ,OAAO,YAAY,MAAM,CAAC;EACxC;EACA,SAAS,UAAU;GACjB,KAAK;GACL,QAAQ,oBAAoB,SAAS,KAAK;EAC5C;EACA,QAAQ,iBAAiB,SAAS,OAAO,EAAE,MAAM,KAAK,CAAC;CACzD,CAAC;AACH;;;;;;;AAQA,eAAsB,UAAU,UAA4B,CAAC,GAAkB;CAC7E,MAAM,aAAa,QAAQ,cAAc;CACzC,IAAI,WAAW,UAAU,UAAU;CACnC,MAAM,gBAAgB,UAAU;AAClC;;;;;;;AAQA,eAAsB,eAAe,UAAiC,CAAC,GAAkB;CACvF,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,EAAE,WAAW;CACnB,SAAS;EACP,MAAM,MAAM,YAAY,MAAM;EAC9B,IAAI,MAAM,gBAAgB,YAAY,MAAM,GAAG;CACjD;AACF"}
@@ -0,0 +1,71 @@
1
+ import { isPastPointerDragThreshold } from "../drag-threshold.js";
2
+ import { autoLayoutDragChanges, hitAutoLayoutHandle, measureAutoLayoutHandles } from "@pairdraw/core/layout";
3
+ import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
4
+ //#region src/shared/input/auto-layout/drag.ts
5
+ const HANDLE_DRAG_THRESHOLD_PX = 5;
6
+ function visibleChildren(editor, node) {
7
+ return node.childIds.map((id) => editor.graph.getNode(id)).filter((child) => !!child);
8
+ }
9
+ /** The hover state that keeps the pink zone and its value pill on while a handle is dragged. */
10
+ function dragHover(node, hit) {
11
+ if (hit.kind === "padding") return {
12
+ nodeId: node.id,
13
+ kind: "padding-value",
14
+ side: hit.side
15
+ };
16
+ return {
17
+ nodeId: node.id,
18
+ kind: "spacing-value",
19
+ axis: hit.axis,
20
+ index: hit.index
21
+ };
22
+ }
23
+ /**
24
+ * Starts dragging a padding edge or an item gap of the selected auto layout frame. Alt edits the
25
+ * opposite side on the dragged axis (with Shift, every side); Shift moves padding or spacing by
26
+ * the large nudge; the drag previews on the frame and commits as one undo step.
27
+ */
28
+ function tryStartAutoLayoutHandleDrag(editor, cx, cy, sx, sy, setDrag, bigNudge = 10) {
29
+ if (editor.state.selectedIds.size !== 1) return false;
30
+ const nodeId = [...editor.state.selectedIds][0];
31
+ const node = editor.graph.getNode(nodeId);
32
+ if (!node || isGeneratedFrame(node) || node.layoutMode !== "HORIZONTAL" && node.layoutMode !== "VERTICAL") return false;
33
+ const layout = measureAutoLayoutHandles(node, visibleChildren(editor, node));
34
+ if (!layout?.editable) return false;
35
+ const abs = editor.graph.getAbsolutePosition(node.id);
36
+ const hit = hitAutoLayoutHandle(layout, cx - abs.x, cy - abs.y);
37
+ if (!hit) return false;
38
+ const handleLayout = layout;
39
+ const handleHit = hit;
40
+ const target = node;
41
+ const preview = editor.beginNodePreview("Adjust auto layout");
42
+ let moved = false;
43
+ function update(screenX, screenY, altKey, shiftKey) {
44
+ moved ||= isPastPointerDragThreshold(sx, sy, screenX, screenY, HANDLE_DRAG_THRESHOLD_PX);
45
+ if (!moved || preview.closed) return;
46
+ if (!editor.graph.getNode(target.id)) return;
47
+ const next = autoLayoutDragChanges(handleLayout, handleHit, {
48
+ dx: screenX - sx,
49
+ dy: screenY - sy,
50
+ zoom: editor.state.zoom,
51
+ alt: altKey,
52
+ shift: shiftKey,
53
+ bigNudge
54
+ });
55
+ preview.update(target.id, next.changes);
56
+ editor.setAutoLayoutHover(dragHover(target, handleHit));
57
+ }
58
+ const drag = {
59
+ type: "auto-layout",
60
+ update,
61
+ commit: () => preview.commit(),
62
+ cancel: () => preview.cancel()
63
+ };
64
+ editor.setAutoLayoutHover(dragHover(target, handleHit));
65
+ setDrag(drag);
66
+ return true;
67
+ }
68
+ //#endregion
69
+ export { tryStartAutoLayoutHandleDrag };
70
+
71
+ //# sourceMappingURL=drag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.js","names":[],"sources":["../../../../src/shared/input/auto-layout/drag.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport {\n autoLayoutDragChanges,\n hitAutoLayoutHandle,\n measureAutoLayoutHandles,\n type AutoLayoutHandleHit,\n type AutoLayoutHandleLayout\n} from '@pairdraw/core/layout'\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { isGeneratedFrame } from '@pairdraw/scene-graph/generated'\n\nimport { isPastPointerDragThreshold } from '#vue/shared/input/drag-threshold'\nimport type { DragAutoLayout, DragState } from '#vue/shared/input/types'\n\nconst HANDLE_DRAG_THRESHOLD_PX = 5\n\nfunction visibleChildren(editor: Editor, node: SceneNode): SceneNode[] {\n return node.childIds\n .map((id) => editor.graph.getNode(id))\n .filter((child): child is SceneNode => !!child)\n}\n\n/** The hover state that keeps the pink zone and its value pill on while a handle is dragged. */\nfunction dragHover(node: SceneNode, hit: AutoLayoutHandleHit) {\n if (hit.kind === 'padding') {\n return { nodeId: node.id, kind: 'padding-value' as const, side: hit.side }\n }\n return {\n nodeId: node.id,\n kind: 'spacing-value' as const,\n axis: hit.axis,\n index: hit.index\n }\n}\n\n/**\n * Starts dragging a padding edge or an item gap of the selected auto layout frame. Alt edits the\n * opposite side on the dragged axis (with Shift, every side); Shift moves padding or spacing by\n * the large nudge; the drag previews on the frame and commits as one undo step.\n */\nexport function tryStartAutoLayoutHandleDrag(\n editor: Editor,\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n setDrag: (drag: DragState) => void,\n bigNudge = 10\n): boolean {\n if (editor.state.selectedIds.size !== 1) return false\n const nodeId = [...editor.state.selectedIds][0]\n const node = editor.graph.getNode(nodeId)\n if (\n !node ||\n isGeneratedFrame(node) ||\n (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')\n )\n return false\n const layout = measureAutoLayoutHandles(node, visibleChildren(editor, node))\n if (!layout?.editable) return false\n const abs = editor.graph.getAbsolutePosition(node.id)\n const hit = hitAutoLayoutHandle(layout, cx - abs.x, cy - abs.y)\n if (!hit) return false\n\n const handleLayout: AutoLayoutHandleLayout = layout\n const handleHit: AutoLayoutHandleHit = hit\n const target = node\n const preview = editor.beginNodePreview('Adjust auto layout')\n let moved = false\n\n function update(screenX: number, screenY: number, altKey: boolean, shiftKey: boolean) {\n moved ||= isPastPointerDragThreshold(sx, sy, screenX, screenY, HANDLE_DRAG_THRESHOLD_PX)\n if (!moved || preview.closed) return\n const current = editor.graph.getNode(target.id)\n if (!current) return\n const next = autoLayoutDragChanges(handleLayout, handleHit, {\n dx: screenX - sx,\n dy: screenY - sy,\n zoom: editor.state.zoom,\n alt: altKey,\n shift: shiftKey,\n bigNudge\n })\n preview.update(target.id, next.changes)\n editor.setAutoLayoutHover(dragHover(target, handleHit))\n }\n\n const drag: DragAutoLayout = {\n type: 'auto-layout',\n update,\n commit: () => preview.commit(),\n cancel: () => preview.cancel()\n }\n editor.setAutoLayoutHover(dragHover(target, handleHit))\n setDrag(drag)\n return true\n}\n"],"mappings":";;;;AAcA,MAAM,2BAA2B;AAEjC,SAAS,gBAAgB,QAAgB,MAA8B;CACrE,OAAO,KAAK,SACT,KAAK,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,CACrC,QAAQ,UAA8B,CAAC,CAAC,KAAK;AAClD;;AAGA,SAAS,UAAU,MAAiB,KAA0B;CAC5D,IAAI,IAAI,SAAS,WACf,OAAO;EAAE,QAAQ,KAAK;EAAI,MAAM;EAA0B,MAAM,IAAI;CAAK;CAE3E,OAAO;EACL,QAAQ,KAAK;EAC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AAO;CAC/B;CACA,OAAO,mBAAmB,UAAU,QAAQ,SAAS,CAAC;CACtD,QAAQ,IAAI;CACZ,OAAO;AACT"}
@@ -1,8 +1,8 @@
1
1
  import { Editor } from "@pairdraw/core";
2
2
  import { Vector } from "@pairdraw/scene-graph/primitives";
3
- //#region src/shared/input/auto-layout-hover.d.ts
3
+ //#region src/shared/input/auto-layout/hover.d.ts
4
4
  /** An auto layout frame's value the canvas edits in place: a padding or the gap. */
5
- type AutoLayoutValueField = 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'itemSpacing';
5
+ type AutoLayoutValueField = 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'paddingLeft' | 'itemSpacing' | 'counterAxisSpacing';
6
6
  /**
7
7
  * Where the editor for a value sits, in canvas coordinates: the middle of the padding, or of
8
8
  * the gap a double-click opened, as the hover draws its tick.
@@ -10,4 +10,4 @@ type AutoLayoutValueField = 'paddingTop' | 'paddingRight' | 'paddingBottom' | 'p
10
10
  declare function autoLayoutValueAnchor(editor: Editor, nodeId: string, field: AutoLayoutValueField, gap?: number): Vector | null;
11
11
  //#endregion
12
12
  export { AutoLayoutValueField, autoLayoutValueAnchor };
13
- //# sourceMappingURL=auto-layout-hover.d.ts.map
13
+ //# sourceMappingURL=hover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hover.d.ts","names":[],"sources":["../../../../src/shared/input/auto-layout/hover.ts"],"mappings":";;;;KA6GY;;;;;iBA4BI,sBACd,QAAQ,QACR,gBACA,OAAO,sBACP,eACC"}
@@ -1,95 +1,43 @@
1
- import { AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE, AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE } from "@pairdraw/core/constants";
1
+ import { AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE } from "@pairdraw/core/constants";
2
+ import { hitAutoLayoutHandle, measureAutoLayoutHandles } from "@pairdraw/core/layout";
2
3
  import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
3
- //#region src/shared/input/auto-layout-hover.ts
4
+ //#region src/shared/input/auto-layout/hover.ts
4
5
  function visibleLayoutChildren(node, editor) {
5
6
  return node.childIds.map((id) => editor.graph.getNode(id)).filter((child) => !!child && child.visible && child.layoutPositioning !== "ABSOLUTE");
6
7
  }
7
8
  function isNear(value, target, tolerance = AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE) {
8
9
  return Math.abs(value - target) <= tolerance;
9
10
  }
10
- function resolvePaddingHover(node, localX, localY) {
11
- const centerX = node.width / 2;
12
- const centerY = node.height / 2;
13
- if (node.paddingTop > 0) {
14
- const tickY = node.paddingTop / 2;
15
- if (isNear(localX, centerX) && isNear(localY, tickY)) return {
16
- nodeId: node.id,
17
- kind: "padding-value",
18
- side: "top"
19
- };
20
- if (localY <= Math.min(node.paddingTop, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
21
- nodeId: node.id,
22
- kind: "padding",
23
- side: "top"
24
- };
25
- }
26
- if (node.paddingBottom > 0) {
27
- const tickY = node.height - node.paddingBottom / 2;
28
- if (isNear(localX, centerX) && isNear(localY, tickY)) return {
29
- nodeId: node.id,
30
- kind: "padding-value",
31
- side: "bottom"
32
- };
33
- if (localY >= node.height - Math.min(node.paddingBottom, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
34
- nodeId: node.id,
35
- kind: "padding",
36
- side: "bottom"
37
- };
38
- }
39
- if (node.paddingLeft > 0) {
40
- if (isNear(localX, node.paddingLeft / 2) && isNear(localY, centerY)) return {
41
- nodeId: node.id,
42
- kind: "padding-value",
43
- side: "left"
44
- };
45
- if (localX <= Math.min(node.paddingLeft, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
46
- nodeId: node.id,
47
- kind: "padding",
48
- side: "left"
49
- };
50
- }
51
- if (node.paddingRight > 0) {
52
- if (isNear(localX, node.width - node.paddingRight / 2) && isNear(localY, centerY)) return {
53
- nodeId: node.id,
54
- kind: "padding-value",
55
- side: "right"
56
- };
57
- if (localX >= node.width - Math.min(node.paddingRight, AUTO_LAYOUT_HOVER_PADDING_REGION_TOLERANCE)) return {
58
- nodeId: node.id,
59
- kind: "padding",
60
- side: "right"
61
- };
62
- }
63
- return null;
11
+ function resolvePaddingHover(node, children, localX, localY) {
12
+ const layout = measureAutoLayoutHandles(node, children);
13
+ const hit = hitAutoLayoutHandle(layout, localX, localY);
14
+ if (hit?.kind !== "padding" || !layout) return null;
15
+ const handle = layout.padding.find((padding) => padding.side === hit.side);
16
+ if (!handle) return null;
17
+ const isVertical = hit.side === "left" || hit.side === "right";
18
+ const tickX = handle.rect.x + handle.rect.width / 2;
19
+ const tickY = handle.rect.y + handle.rect.height / 2;
20
+ const atTick = isVertical ? isNear(localY, node.height / 2) && isNear(localX, tickX) : isNear(localX, node.width / 2) && isNear(localY, tickY);
21
+ return {
22
+ nodeId: node.id,
23
+ kind: atTick ? "padding-value" : "padding",
24
+ side: hit.side
25
+ };
64
26
  }
65
27
  function resolveSpacingHover(node, children, localX, localY) {
66
- if (children.length < 2 || node.itemSpacing <= 0) return null;
67
- const isRow = node.layoutMode === "HORIZONTAL";
68
- const contentCrossStart = isRow ? node.paddingTop : node.paddingLeft;
69
- const contentCrossEnd = isRow ? node.height - node.paddingBottom : node.width - node.paddingRight;
70
- const cross = isRow ? localY : localX;
71
- if (cross < contentCrossStart || cross > contentCrossEnd) return null;
72
- for (let i = 0; i < children.length - 1; i++) {
73
- const prev = children[i];
74
- const next = children[i + 1];
75
- const gapStart = isRow ? prev.x + prev.width : prev.y + prev.height;
76
- const gapEnd = isRow ? next.x : next.y;
77
- if (gapEnd < gapStart) continue;
78
- const cursor = isRow ? localX : localY;
79
- const tickMain = (gapStart + gapEnd) / 2;
80
- const tickCross = (contentCrossStart + contentCrossEnd) / 2;
81
- if (isNear(cursor, tickMain) && isNear(cross, tickCross)) return {
82
- nodeId: node.id,
83
- kind: "spacing-value",
84
- index: i
85
- };
86
- if (cursor >= gapStart - AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE && cursor <= gapEnd + AUTO_LAYOUT_HOVER_GAP_REGION_TOLERANCE) return {
87
- nodeId: node.id,
88
- kind: "spacing",
89
- index: i
90
- };
91
- }
92
- return null;
28
+ const layout = measureAutoLayoutHandles(node, children);
29
+ const hit = hitAutoLayoutHandle(layout, localX, localY);
30
+ if (hit?.kind !== "gap" || !layout) return null;
31
+ const handle = layout.gaps.find((gap) => gap.axis === hit.axis && gap.index === hit.index);
32
+ if (!handle) return null;
33
+ const { x, y, width, height } = handle.rect;
34
+ const atTick = isNear(localX, x + width / 2) && isNear(localY, y + height / 2);
35
+ return {
36
+ nodeId: node.id,
37
+ kind: atTick ? "spacing-value" : "spacing",
38
+ axis: hit.axis,
39
+ index: hit.index
40
+ };
93
41
  }
94
42
  function resolveChildrenHover(node, children, localX, localY) {
95
43
  for (let i = 0; i < children.length; i++) {
@@ -113,7 +61,7 @@ function resolveAutoLayoutHover(cx, cy, editor) {
113
61
  const localY = cy - abs.y;
114
62
  if (localX < 0 || localY < 0 || localX > node.width || localY > node.height) return null;
115
63
  const children = visibleLayoutChildren(node, editor);
116
- return resolveSpacingHover(node, children, localX, localY) ?? resolvePaddingHover(node, localX, localY) ?? resolveChildrenHover(node, children, localX, localY) ?? {
64
+ return resolvePaddingHover(node, children, localX, localY) ?? resolveSpacingHover(node, children, localX, localY) ?? resolveChildrenHover(node, children, localX, localY) ?? {
117
65
  nodeId: node.id,
118
66
  kind: "frame"
119
67
  };
@@ -127,7 +75,7 @@ const PADDING_FIELDS = {
127
75
  /** The value a hover over a padding or a gap edits, as Figma opens it on a double-click. */
128
76
  function autoLayoutValueField(hover) {
129
77
  if ((hover.kind === "padding" || hover.kind === "padding-value") && hover.side) return PADDING_FIELDS[hover.side];
130
- if (hover.kind === "spacing" || hover.kind === "spacing-value") return "itemSpacing";
78
+ if (hover.kind === "spacing" || hover.kind === "spacing-value") return hover.axis === "counter" ? "counterAxisSpacing" : "itemSpacing";
131
79
  return null;
132
80
  }
133
81
  /**
@@ -159,6 +107,14 @@ function autoLayoutValueAnchor(editor, nodeId, field, gap = 0) {
159
107
  y: middle.y
160
108
  };
161
109
  const children = visibleLayoutChildren(node, editor);
110
+ if (field === "counterAxisSpacing") {
111
+ const handle = measureAutoLayoutHandles(node, children)?.gaps.find((candidate) => candidate.axis === "counter" && candidate.index === gap);
112
+ if (handle) return {
113
+ x: abs.x + handle.rect.x + handle.rect.width / 2,
114
+ y: abs.y + handle.rect.y + handle.rect.height / 2
115
+ };
116
+ return middle;
117
+ }
162
118
  const prev = children.at(gap);
163
119
  const next = children.at(gap + 1);
164
120
  if (!prev || !next) return middle;
@@ -177,4 +133,4 @@ function autoLayoutValueAnchor(editor, nodeId, field, gap = 0) {
177
133
  //#endregion
178
134
  export { autoLayoutValueAnchor, autoLayoutValueField, resolveAutoLayoutHover };
179
135
 
180
- //# sourceMappingURL=auto-layout-hover.js.map
136
+ //# sourceMappingURL=hover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hover.js","names":[],"sources":["../../../../src/shared/input/auto-layout/hover.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport { AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE } from '@pairdraw/core/constants'\nimport { hitAutoLayoutHandle, measureAutoLayoutHandles } from '@pairdraw/core/layout'\nimport type { SceneNode } from '@pairdraw/scene-graph'\nimport { isGeneratedFrame } from '@pairdraw/scene-graph/generated'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\ntype AutoLayoutHover = NonNullable<Editor['state']['autoLayoutHover']>\n\nfunction visibleLayoutChildren(node: SceneNode, editor: Editor) {\n return node.childIds\n .map((id) => editor.graph.getNode(id))\n .filter(\n (child): child is SceneNode =>\n !!child && child.visible && child.layoutPositioning !== 'ABSOLUTE'\n )\n}\n\nfunction isNear(value: number, target: number, tolerance = AUTO_LAYOUT_HOVER_TICK_HIT_TOLERANCE) {\n return Math.abs(value - target) <= tolerance\n}\n\nfunction resolvePaddingHover(\n node: SceneNode,\n children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n const layout = measureAutoLayoutHandles(node, children)\n const hit = hitAutoLayoutHandle(layout, localX, localY)\n if (hit?.kind !== 'padding' || !layout) return null\n const handle = layout.padding.find((padding) => padding.side === hit.side)\n if (!handle) return null\n const isVertical = hit.side === 'left' || hit.side === 'right'\n const tickX = handle.rect.x + handle.rect.width / 2\n const tickY = handle.rect.y + handle.rect.height / 2\n const atTick = isVertical\n ? isNear(localY, node.height / 2) && isNear(localX, tickX)\n : isNear(localX, node.width / 2) && isNear(localY, tickY)\n return { nodeId: node.id, kind: atTick ? 'padding-value' : 'padding', side: hit.side }\n}\n\nfunction resolveSpacingHover(\n node: SceneNode,\n children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n const layout = measureAutoLayoutHandles(node, children)\n const hit = hitAutoLayoutHandle(layout, localX, localY)\n if (hit?.kind !== 'gap' || !layout) return null\n const handle = layout.gaps.find((gap) => gap.axis === hit.axis && gap.index === hit.index)\n if (!handle) return null\n const { x, y, width, height } = handle.rect\n const atTick = isNear(localX, x + width / 2) && isNear(localY, y + height / 2)\n return {\n nodeId: node.id,\n kind: atTick ? 'spacing-value' : 'spacing',\n axis: hit.axis,\n index: hit.index\n }\n}\n\nfunction resolveChildrenHover(\n node: SceneNode,\n children: SceneNode[],\n localX: number,\n localY: number\n): AutoLayoutHover | null {\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n if (\n localX >= child.x &&\n localX <= child.x + child.width &&\n localY >= child.y &&\n localY <= child.y + child.height\n ) {\n return { nodeId: node.id, kind: 'children', index: i }\n }\n }\n return null\n}\n\nexport function resolveAutoLayoutHover(\n cx: number,\n cy: number,\n editor: Editor\n): AutoLayoutHover | null {\n if (editor.state.selectedIds.size !== 1) return null\n const nodeId = [...editor.state.selectedIds][0]\n const node = editor.graph.getNode(nodeId)\n if (!node || (node.layoutMode !== 'HORIZONTAL' && node.layoutMode !== 'VERTICAL')) return null\n // A generated frame, such as a sticky note, lays itself out; its spacing is not the user's.\n if (isGeneratedFrame(node)) return null\n\n const abs = editor.graph.getAbsolutePosition(node.id)\n const localX = cx - abs.x\n const localY = cy - abs.y\n if (localX < 0 || localY < 0 || localX > node.width || localY > node.height) return null\n\n const children = visibleLayoutChildren(node, editor)\n return (\n resolvePaddingHover(node, children, localX, localY) ??\n resolveSpacingHover(node, children, localX, localY) ??\n resolveChildrenHover(node, children, localX, localY) ?? { nodeId: node.id, kind: 'frame' }\n )\n}\n\n/** An auto layout frame's value the canvas edits in place: a padding or the gap. */\nexport type AutoLayoutValueField =\n | 'paddingTop'\n | 'paddingRight'\n | 'paddingBottom'\n | 'paddingLeft'\n | 'itemSpacing'\n | 'counterAxisSpacing'\n\nconst PADDING_FIELDS = {\n top: 'paddingTop',\n right: 'paddingRight',\n bottom: 'paddingBottom',\n left: 'paddingLeft'\n} as const satisfies Record<NonNullable<AutoLayoutHover['side']>, AutoLayoutValueField>\n\n/** The value a hover over a padding or a gap edits, as Figma opens it on a double-click. */\nexport function autoLayoutValueField(hover: AutoLayoutHover): AutoLayoutValueField | null {\n if ((hover.kind === 'padding' || hover.kind === 'padding-value') && hover.side)\n return PADDING_FIELDS[hover.side]\n if (hover.kind === 'spacing' || hover.kind === 'spacing-value')\n return hover.axis === 'counter' ? 'counterAxisSpacing' : 'itemSpacing'\n return null\n}\n\n/**\n * Where the editor for a value sits, in canvas coordinates: the middle of the padding, or of\n * the gap a double-click opened, as the hover draws its tick.\n */\nexport function autoLayoutValueAnchor(\n editor: Editor,\n nodeId: string,\n field: AutoLayoutValueField,\n gap = 0\n): Vector | null {\n const node = editor.graph.getNode(nodeId)\n if (!node) return null\n const abs = editor.graph.getAbsolutePosition(node.id)\n const middle = { x: abs.x + node.width / 2, y: abs.y + node.height / 2 }\n if (field === 'paddingTop') return { x: middle.x, y: abs.y + node.paddingTop / 2 }\n if (field === 'paddingBottom')\n return { x: middle.x, y: abs.y + node.height - node.paddingBottom / 2 }\n if (field === 'paddingLeft') return { x: abs.x + node.paddingLeft / 2, y: middle.y }\n if (field === 'paddingRight')\n return { x: abs.x + node.width - node.paddingRight / 2, y: middle.y }\n const children = visibleLayoutChildren(node, editor)\n if (field === 'counterAxisSpacing') {\n const handle = measureAutoLayoutHandles(node, children)?.gaps.find(\n (candidate) => candidate.axis === 'counter' && candidate.index === gap\n )\n if (handle) {\n return {\n x: abs.x + handle.rect.x + handle.rect.width / 2,\n y: abs.y + handle.rect.y + handle.rect.height / 2\n }\n }\n return middle\n }\n const prev = children.at(gap)\n const next = children.at(gap + 1)\n if (!prev || !next) return middle\n // Across the flow, the middle of the content box, where the hover draws the gap's tick.\n if (node.layoutMode === 'HORIZONTAL') {\n const y = abs.y + (node.paddingTop + node.height - node.paddingBottom) / 2\n return { x: abs.x + (prev.x + prev.width + next.x) / 2, y }\n }\n const x = abs.x + (node.paddingLeft + node.width - node.paddingRight) / 2\n return { x, y: abs.y + (prev.y + prev.height + next.y) / 2 }\n}\n"],"mappings":";;;;AASA,SAAS,sBAAsB,MAAiB,QAAgB;CAC9D,OAAO,KAAK,SACT,KAAK,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,CACrC,QACE,UACC,CAAC,CAAC,SAAS,MAAM,WAAW,MAAM,sBAAsB,UAC5D;AACJ;AAEA,SAAS,OAAO,OAAe,QAAgB,YAAY,sCAAsC;CAC/F,OAAO,KAAK,IAAI,QAAQ,MAAM,KAAK;AACrC;AAEA,SAAS,oBACP,MACA,UACA,QACA,QACwB;CACxB,MAAM,SAAS,yBAAyB,MAAM,QAAQ;CACtD,MAAM,MAAM,oBAAoB,QAAQ,QAAQ,MAAM;CACtD,IAAI,KAAK,SAAS,aAAa,CAAC,QAAQ,OAAO;CAC/C,MAAM,SAAS,OAAO,QAAQ,MAAM,YAAY,QAAQ,SAAS,IAAI,IAAI;CACzE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