@pairdraw/vue 0.18.0 → 0.19.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 (228) hide show
  1. package/dist/canvas/CanvasRoot.vue.js +1 -0
  2. package/dist/canvas/CanvasRoot.vue.js.map +1 -1
  3. package/dist/canvas/drop/use.d.ts.map +1 -1
  4. package/dist/canvas/drop/use.js +5 -3
  5. package/dist/canvas/drop/use.js.map +1 -1
  6. package/dist/canvas/guides/input.js +2 -1
  7. package/dist/canvas/guides/input.js.map +1 -1
  8. package/dist/canvas/pen/input.js +20 -6
  9. package/dist/canvas/pen/input.js.map +1 -1
  10. package/dist/canvas/surface/gl-surface.js +82 -4
  11. package/dist/canvas/surface/gl-surface.js.map +1 -1
  12. package/dist/canvas/surface/lifecycle.js +5 -0
  13. package/dist/canvas/surface/lifecycle.js.map +1 -1
  14. package/dist/canvas/surface/resize-observer.js +11 -4
  15. package/dist/canvas/surface/resize-observer.js.map +1 -1
  16. package/dist/canvas/surface/types.d.ts +5 -0
  17. package/dist/canvas/surface/types.d.ts.map +1 -1
  18. package/dist/canvas/surface/use.d.ts +1 -0
  19. package/dist/canvas/surface/use.js +1 -0
  20. package/dist/canvas/surface/use.js.map +1 -1
  21. package/dist/canvas/text-edit/editing.js +11 -8
  22. package/dist/canvas/text-edit/editing.js.map +1 -1
  23. package/dist/canvas/text-edit/keyboard.js +12 -0
  24. package/dist/canvas/text-edit/keyboard.js.map +1 -1
  25. package/dist/canvas/useCanvasInput.d.ts +240 -0
  26. package/dist/controls/appearance/use.d.ts +1 -1
  27. package/dist/controls/layout/helpers.d.ts.map +1 -1
  28. package/dist/controls/layout/helpers.js +36 -7
  29. package/dist/controls/layout/helpers.js.map +1 -1
  30. package/dist/controls/layout/use.d.ts +1 -0
  31. package/dist/controls/layout/use.d.ts.map +1 -1
  32. package/dist/controls/layout/use.js +3 -0
  33. package/dist/controls/layout/use.js.map +1 -1
  34. package/dist/controls/node-preview/use.js +21 -1
  35. package/dist/controls/node-preview/use.js.map +1 -1
  36. package/dist/controls/position/use.d.ts +2 -1
  37. package/dist/controls/position/use.d.ts.map +1 -1
  38. package/dist/controls/position/use.js +13 -5
  39. package/dist/controls/position/use.js.map +1 -1
  40. package/dist/controls/property-list/use.d.ts.map +1 -1
  41. package/dist/controls/property-list/use.js +27 -5
  42. package/dist/controls/property-list/use.js.map +1 -1
  43. package/dist/controls/selection-layout/use.d.ts.map +1 -1
  44. package/dist/controls/selection-layout/use.js +2 -1
  45. package/dist/controls/selection-layout/use.js.map +1 -1
  46. package/dist/controls/slots/authoring.d.ts.map +1 -1
  47. package/dist/controls/slots/authoring.js +2 -1
  48. package/dist/controls/slots/authoring.js.map +1 -1
  49. package/dist/controls/typography/actions.js +18 -10
  50. package/dist/controls/typography/actions.js.map +1 -1
  51. package/dist/controls/typography/axes.d.ts.map +1 -1
  52. package/dist/controls/typography/axes.js +62 -19
  53. package/dist/controls/typography/axes.js.map +1 -1
  54. package/dist/editor/commands/registry.d.ts +1 -0
  55. package/dist/editor/commands/registry.d.ts.map +1 -1
  56. package/dist/editor/commands/registry.js +1 -0
  57. package/dist/editor/commands/registry.js.map +1 -1
  58. package/dist/editor/commands/selection.js +12 -3
  59. package/dist/editor/commands/selection.js.map +1 -1
  60. package/dist/editor/commands/types.d.ts +1 -1
  61. package/dist/editor/commands/types.d.ts.map +1 -1
  62. package/dist/editor/menu-model/canvas.js +5 -1
  63. package/dist/editor/menu-model/canvas.js.map +1 -1
  64. package/dist/editor/selection-capabilities/use.d.ts +1 -0
  65. package/dist/editor/selection-capabilities/use.js +4 -0
  66. package/dist/editor/selection-capabilities/use.js.map +1 -1
  67. package/dist/editor/selection-state/nodes.js +2 -2
  68. package/dist/editor/selection-state/nodes.js.map +1 -1
  69. package/dist/i18n/locale.d.ts.map +1 -1
  70. package/dist/i18n/locale.js +16 -6
  71. package/dist/i18n/locale.js.map +1 -1
  72. package/dist/i18n/locales/de/ai.json.js +3 -0
  73. package/dist/i18n/locales/de/cloud/portal.json.js +1 -1
  74. package/dist/i18n/locales/de/commands.json.js +1 -0
  75. package/dist/i18n/locales/de/comments.json.js +1 -0
  76. package/dist/i18n/locales/de/editor.json.js +2 -2
  77. package/dist/i18n/locales/de/menu.json.js +1 -1
  78. package/dist/i18n/locales/de/variables/panel.json.js +2 -0
  79. package/dist/i18n/locales/es/ai.json.js +3 -0
  80. package/dist/i18n/locales/es/cloud/portal.json.js +1 -1
  81. package/dist/i18n/locales/es/commands.json.js +1 -0
  82. package/dist/i18n/locales/es/comments.json.js +1 -0
  83. package/dist/i18n/locales/es/editor.json.js +2 -2
  84. package/dist/i18n/locales/es/menu.json.js +1 -1
  85. package/dist/i18n/locales/es/variables/panel.json.js +2 -0
  86. package/dist/i18n/locales/fr/ai.json.js +3 -0
  87. package/dist/i18n/locales/fr/cloud/portal.json.js +1 -1
  88. package/dist/i18n/locales/fr/commands.json.js +1 -0
  89. package/dist/i18n/locales/fr/comments.json.js +1 -0
  90. package/dist/i18n/locales/fr/editor.json.js +2 -2
  91. package/dist/i18n/locales/fr/menu.json.js +1 -1
  92. package/dist/i18n/locales/fr/variables/panel.json.js +2 -0
  93. package/dist/i18n/locales/it/ai.json.js +3 -0
  94. package/dist/i18n/locales/it/cloud/portal.json.js +1 -1
  95. package/dist/i18n/locales/it/commands.json.js +1 -0
  96. package/dist/i18n/locales/it/comments.json.js +1 -0
  97. package/dist/i18n/locales/it/editor.json.js +2 -2
  98. package/dist/i18n/locales/it/menu.json.js +1 -1
  99. package/dist/i18n/locales/it/variables/panel.json.js +2 -0
  100. package/dist/i18n/locales/ja/ai.json.js +3 -0
  101. package/dist/i18n/locales/ja/cloud/portal.json.js +1 -1
  102. package/dist/i18n/locales/ja/commands.json.js +1 -0
  103. package/dist/i18n/locales/ja/comments.json.js +1 -0
  104. package/dist/i18n/locales/ja/editor.json.js +2 -2
  105. package/dist/i18n/locales/ja/menu.json.js +1 -1
  106. package/dist/i18n/locales/ja/variables/panel.json.js +2 -0
  107. package/dist/i18n/locales/pl/ai.json.js +3 -0
  108. package/dist/i18n/locales/pl/cloud/portal.json.js +1 -1
  109. package/dist/i18n/locales/pl/commands.json.js +1 -0
  110. package/dist/i18n/locales/pl/comments.json.js +1 -0
  111. package/dist/i18n/locales/pl/editor.json.js +2 -2
  112. package/dist/i18n/locales/pl/menu.json.js +1 -1
  113. package/dist/i18n/locales/pl/variables/panel.json.js +2 -0
  114. package/dist/i18n/locales/ru/ai.json.js +3 -0
  115. package/dist/i18n/locales/ru/cloud/portal.json.js +1 -1
  116. package/dist/i18n/locales/ru/commands.json.js +1 -0
  117. package/dist/i18n/locales/ru/comments.json.js +1 -0
  118. package/dist/i18n/locales/ru/editor.json.js +2 -2
  119. package/dist/i18n/locales/ru/menu.json.js +1 -1
  120. package/dist/i18n/locales/ru/variables/panel.json.js +2 -0
  121. package/dist/i18n/locales/zh-cn/ai.json.js +3 -0
  122. package/dist/i18n/locales/zh-cn/cloud/portal.json.js +1 -1
  123. package/dist/i18n/locales/zh-cn/commands.json.js +1 -0
  124. package/dist/i18n/locales/zh-cn/comments.json.js +1 -0
  125. package/dist/i18n/locales/zh-cn/editor.json.js +2 -2
  126. package/dist/i18n/locales/zh-cn/menu.json.js +1 -1
  127. package/dist/i18n/locales/zh-cn/variables/panel.json.js +2 -0
  128. package/dist/i18n/messages/ai.d.ts +6 -0
  129. package/dist/i18n/messages/ai.d.ts.map +1 -1
  130. package/dist/i18n/messages/ai.js +4 -0
  131. package/dist/i18n/messages/ai.js.map +1 -1
  132. package/dist/i18n/messages/cloud/portal.d.ts +1 -1
  133. package/dist/i18n/messages/cloud/portal.js +1 -1
  134. package/dist/i18n/messages/cloud/portal.js.map +1 -1
  135. package/dist/i18n/messages/commands.d.ts +1 -0
  136. package/dist/i18n/messages/commands.d.ts.map +1 -1
  137. package/dist/i18n/messages/commands.js +1 -0
  138. package/dist/i18n/messages/commands.js.map +1 -1
  139. package/dist/i18n/messages/comments.d.ts +1 -0
  140. package/dist/i18n/messages/comments.d.ts.map +1 -1
  141. package/dist/i18n/messages/comments.js +1 -0
  142. package/dist/i18n/messages/comments.js.map +1 -1
  143. package/dist/i18n/messages/editor.d.ts +1 -1
  144. package/dist/i18n/messages/editor.js +1 -1
  145. package/dist/i18n/messages/editor.js.map +1 -1
  146. package/dist/i18n/messages/menu.d.ts +1 -1
  147. package/dist/i18n/messages/menu.js +1 -1
  148. package/dist/i18n/messages/menu.js.map +1 -1
  149. package/dist/i18n/messages/panels.d.ts +1 -1
  150. package/dist/i18n/messages/panels.js +1 -1
  151. package/dist/i18n/messages/panels.js.map +1 -1
  152. package/dist/i18n/messages/variables/panel.d.ts +2 -0
  153. package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
  154. package/dist/i18n/messages/variables/panel.js +2 -0
  155. package/dist/i18n/messages/variables/panel.js.map +1 -1
  156. package/dist/i18n/messages.d.ts +13 -4
  157. package/dist/i18n/useI18n.d.ts +48 -14
  158. package/dist/i18n/useI18n.d.ts.map +1 -1
  159. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +12 -2
  160. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
  161. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +39 -10
  162. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
  163. package/dist/primitives/ColorPicker/gesture.d.ts +40 -0
  164. package/dist/primitives/ColorPicker/gesture.d.ts.map +1 -0
  165. package/dist/primitives/ColorPicker/gesture.js +120 -0
  166. package/dist/primitives/ColorPicker/gesture.js.map +1 -0
  167. package/dist/primitives/ColorPicker/index.d.ts +2 -1
  168. package/dist/primitives/ColorPicker/index.js +2 -1
  169. package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
  170. package/dist/primitives/Fill/FillSwatch.vue.js +6 -1
  171. package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
  172. package/dist/primitives/Fill/types.d.ts +5 -0
  173. package/dist/primitives/Fill/types.d.ts.map +1 -1
  174. package/dist/primitives/Fill/useFill.d.ts.map +1 -1
  175. package/dist/primitives/Fill/useFill.js +15 -7
  176. package/dist/primitives/Fill/useFill.js.map +1 -1
  177. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +1 -0
  178. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
  179. package/dist/primitives/FontPicker/FontPickerRoot.vue.js +7 -2
  180. package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
  181. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +2 -0
  182. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
  183. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +14 -3
  184. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
  185. package/dist/primitives/LayerTree/model.js +1 -1
  186. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.d.ts.map +1 -1
  187. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js +1 -0
  188. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js.map +1 -1
  189. package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts +2 -2
  190. package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts.map +1 -1
  191. package/dist/primitives/NumberField/NumberFieldRoot.vue.js +3 -2
  192. package/dist/primitives/NumberField/NumberFieldRoot.vue.js.map +1 -1
  193. package/dist/primitives/NumberField/types.d.ts +5 -0
  194. package/dist/primitives/NumberField/types.d.ts.map +1 -1
  195. package/dist/primitives/PageList/PageListRoot.vue.d.ts +3 -3
  196. package/dist/primitives/PageList/PageListRoot.vue.d.ts.map +1 -1
  197. package/dist/primitives/PageList/PageListRoot.vue.js +3 -2
  198. package/dist/primitives/PageList/PageListRoot.vue.js.map +1 -1
  199. package/dist/primitives/PageList/usePageList.d.ts +1 -1
  200. package/dist/primitives/PageList/usePageList.d.ts.map +1 -1
  201. package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts +1 -0
  202. package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts.map +1 -1
  203. package/dist/primitives/PositionControls/PositionControlsRoot.vue.js +11 -13
  204. package/dist/primitives/PositionControls/PositionControlsRoot.vue.js.map +1 -1
  205. package/dist/primitives/PropertyList/PropertyListRoot.vue.d.ts.map +1 -1
  206. package/dist/primitives/PropertyList/PropertyListRoot.vue.js +10 -1
  207. package/dist/primitives/PropertyList/PropertyListRoot.vue.js.map +1 -1
  208. package/dist/primitives/PropertyList/index.d.ts +2 -2
  209. package/dist/primitives/PropertyList/types.d.ts +14 -2
  210. package/dist/primitives/PropertyList/types.d.ts.map +1 -1
  211. package/dist/shared/input/drop-target.js +2 -1
  212. package/dist/shared/input/drop-target.js.map +1 -1
  213. package/dist/shared/input/duplicate-drag.js.map +1 -1
  214. package/dist/shared/input/move/drag.js +25 -4
  215. package/dist/shared/input/move/drag.js.map +1 -1
  216. package/dist/shared/input/resize/start.js +2 -1
  217. package/dist/shared/input/resize/start.js.map +1 -1
  218. package/dist/shared/input/select/move.js +8 -3
  219. package/dist/shared/input/select/move.js.map +1 -1
  220. package/dist/shared/input/select.js +22 -12
  221. package/dist/shared/input/select.js.map +1 -1
  222. package/dist/shared/input/types.d.ts +2 -0
  223. package/dist/shared/input/types.d.ts.map +1 -1
  224. package/dist/shared/input/types.js.map +1 -1
  225. package/dist/variables/use.d.ts.map +1 -1
  226. package/dist/variables/use.js +2 -1
  227. package/dist/variables/use.js.map +1 -1
  228. package/package.json +4 -4
@@ -0,0 +1,120 @@
1
+ import { useEventListener, useTimeoutFn } from "@vueuse/core";
2
+ //#region src/primitives/ColorPicker/gesture.ts
3
+ /** Every picker surface carries this, including one opened from inside another picker. */
4
+ const PICKER_CONTENT = "[data-picker-content]";
5
+ /**
6
+ * Groups a picker's changes into undo steps as Figma desktop 126 does. A press inside the picker
7
+ * and everything it changes until the release is one step, such as a drag over the colour area;
8
+ * a change made with no press held is a step of its own, such as a tab's click, a typed value, or
9
+ * a chosen image. A press counts in the picker or in one opened from it, such as a shader colour's.
10
+ * Escape while a press that changed something is held puts that back, leaves the picker open, and
11
+ * ends the drag: the control holding the pointer loses it, so it stops following until the
12
+ * release, and anything it still reports is dropped.
13
+ */
14
+ function usePickerGesture({ open, commit, cancel, beforeChange }) {
15
+ let press = null;
16
+ let changed = false;
17
+ let cancelled = false;
18
+ /** The Escape that put a press back, whose key repeats must not close the picker. */
19
+ let escapeHeld = false;
20
+ /** Steps of their own that arrived while a press was held, applied once it ends. */
21
+ let waiting = [];
22
+ function applyWaiting() {
23
+ const steps = waiting;
24
+ waiting = [];
25
+ for (const apply of steps) {
26
+ apply();
27
+ commit();
28
+ }
29
+ }
30
+ function end() {
31
+ const step = changed && !cancelled;
32
+ press = null;
33
+ changed = false;
34
+ cancelled = false;
35
+ return step;
36
+ }
37
+ function release() {
38
+ releaseLater.stop();
39
+ if (!press) return;
40
+ if (end()) commit();
41
+ applyWaiting();
42
+ }
43
+ const releaseLater = useTimeoutFn(release, 0, { immediate: false });
44
+ /** Sliders, the colour area, and the gradient bar move only while they hold the pointer. */
45
+ function endDrag(held) {
46
+ for (let element = held.target; element; element = element.parentElement) {
47
+ if (!element.hasPointerCapture(held.pointerId)) continue;
48
+ element.releasePointerCapture(held.pointerId);
49
+ return;
50
+ }
51
+ }
52
+ useEventListener("pointerdown", (event) => {
53
+ if (press || event.button !== 0 || !open()) return;
54
+ if (!(event.target instanceof Element) || !event.target.closest(PICKER_CONTENT)) return;
55
+ press = {
56
+ target: event.target,
57
+ pointerId: event.pointerId
58
+ };
59
+ changed = false;
60
+ cancelled = false;
61
+ }, { capture: true });
62
+ useEventListener(["pointerup", "pointercancel"], (event) => {
63
+ if (press?.pointerId === event.pointerId) releaseLater.start();
64
+ }, { capture: true });
65
+ useEventListener(["pointerup", "pointercancel"], (event) => {
66
+ if (press?.pointerId === event.pointerId) release();
67
+ });
68
+ useEventListener("blur", release);
69
+ useEventListener("keydown", (event) => {
70
+ if (event.code !== "Escape" || event.isComposing) return;
71
+ const held = press;
72
+ const putBack = held !== null && changed && !cancelled;
73
+ if (!putBack && !(escapeHeld && event.repeat)) return;
74
+ event.preventDefault();
75
+ event.stopPropagation();
76
+ if (!held || !putBack) return;
77
+ cancelled = true;
78
+ escapeHeld = true;
79
+ endDrag(held);
80
+ cancel();
81
+ }, { capture: true });
82
+ useEventListener("keyup", (event) => {
83
+ if (event.code === "Escape") escapeHeld = false;
84
+ });
85
+ return {
86
+ /** Applies a change, unless Escape put its press back; with no press held it is a step. */
87
+ change(apply) {
88
+ if (cancelled) return;
89
+ if (press && !changed) beforeChange?.();
90
+ apply();
91
+ if (press) changed = true;
92
+ else commit();
93
+ },
94
+ /**
95
+ * Applies a change that is a step of its own, such as an image that arrives once its file is
96
+ * read. While a press is held, even one Escape put back, it waits for the press to end, so it
97
+ * neither splits that step nor survives being put back with it, and steps keep their order.
98
+ */
99
+ step(apply) {
100
+ if (press) {
101
+ waiting.push(apply);
102
+ return;
103
+ }
104
+ apply();
105
+ commit();
106
+ },
107
+ /** For the picker closing while a press is held, such as when it loses focus: drops it. */
108
+ abort() {
109
+ releaseLater.stop();
110
+ const putBack = press !== null && changed && !cancelled;
111
+ end();
112
+ if (putBack) cancel();
113
+ applyWaiting();
114
+ }
115
+ };
116
+ }
117
+ //#endregion
118
+ export { usePickerGesture };
119
+
120
+ //# sourceMappingURL=gesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gesture.js","names":[],"sources":["../../../src/primitives/ColorPicker/gesture.ts"],"sourcesContent":["import { useEventListener, useTimeoutFn } from '@vueuse/core'\n\nexport interface PickerGestureOptions {\n /** Whether the picker is open; only then does a press inside it start a step. */\n open: () => boolean\n /** Ends the edit made so far as one undo step. */\n commit: () => void\n /** Puts back what the press being held has changed. */\n cancel: () => void\n /** A held press is about to make its first change, such as the moment to note what it changes. */\n beforeChange?: () => void\n}\n\n/**\n * Why a picker reports `cancel`: `press` when Escape, or the picker closing, put back a press's\n * change; `escape` when Escape closed a picker that puts back the colour it opened with.\n */\nexport type PickerCancelCause = 'press' | 'escape'\n\n/** Every picker surface carries this, including one opened from inside another picker. */\nconst PICKER_CONTENT = '[data-picker-content]'\n\n/**\n * Groups a picker's changes into undo steps as Figma desktop 126 does. A press inside the picker\n * and everything it changes until the release is one step, such as a drag over the colour area;\n * a change made with no press held is a step of its own, such as a tab's click, a typed value, or\n * a chosen image. A press counts in the picker or in one opened from it, such as a shader colour's.\n * Escape while a press that changed something is held puts that back, leaves the picker open, and\n * ends the drag: the control holding the pointer loses it, so it stops following until the\n * release, and anything it still reports is dropped.\n */\nexport function usePickerGesture({ open, commit, cancel, beforeChange }: PickerGestureOptions) {\n let press: { target: Element; pointerId: number } | null = null\n let changed = false\n let cancelled = false\n /** The Escape that put a press back, whose key repeats must not close the picker. */\n let escapeHeld = false\n /** Steps of their own that arrived while a press was held, applied once it ends. */\n let waiting: Array<() => void> = []\n\n function applyWaiting() {\n const steps = waiting\n waiting = []\n for (const apply of steps) {\n apply()\n commit()\n }\n }\n\n function end(): boolean {\n const step = changed && !cancelled\n press = null\n changed = false\n cancelled = false\n return step\n }\n\n function release() {\n releaseLater.stop()\n if (!press) return\n if (end()) commit()\n applyWaiting()\n }\n\n // A control that stops its release from bubbling still ends the press, once its own handler\n // has made its last change.\n const releaseLater = useTimeoutFn(release, 0, { immediate: false })\n\n /** Sliders, the colour area, and the gradient bar move only while they hold the pointer. */\n function endDrag(held: { target: Element; pointerId: number }) {\n for (let element: Element | null = held.target; element; element = element.parentElement) {\n if (!element.hasPointerCapture(held.pointerId)) continue\n element.releasePointerCapture(held.pointerId)\n return\n }\n }\n\n // Captured on the window, ahead of controls such as a slider that change on the press itself.\n useEventListener(\n 'pointerdown',\n (event: PointerEvent) => {\n if (press || event.button !== 0 || !open()) return\n if (!(event.target instanceof Element) || !event.target.closest(PICKER_CONTENT)) return\n press = { target: event.target, pointerId: event.pointerId }\n changed = false\n cancelled = false\n },\n { capture: true }\n )\n useEventListener(\n ['pointerup', 'pointercancel'],\n (event: PointerEvent) => {\n if (press?.pointerId === event.pointerId) releaseLater.start()\n },\n { capture: true }\n )\n useEventListener(['pointerup', 'pointercancel'], (event: PointerEvent) => {\n if (press?.pointerId === event.pointerId) release()\n })\n useEventListener('blur', release)\n // Ahead of the popover's own Escape, which would close the picker, as the canvas does for its\n // drags. Propagation stops, but a picker opened from this one still sees the key and puts back\n // the same press.\n useEventListener(\n 'keydown',\n (event: KeyboardEvent) => {\n if (event.code !== 'Escape' || event.isComposing) return\n const held = press\n const putBack = held !== null && changed && !cancelled\n if (!putBack && !(escapeHeld && event.repeat)) return\n event.preventDefault()\n event.stopPropagation()\n if (!held || !putBack) return\n cancelled = true\n escapeHeld = true\n endDrag(held)\n cancel()\n },\n { capture: true }\n )\n useEventListener('keyup', (event: KeyboardEvent) => {\n if (event.code === 'Escape') escapeHeld = false\n })\n\n return {\n /** Applies a change, unless Escape put its press back; with no press held it is a step. */\n change(apply: () => void) {\n if (cancelled) return\n if (press && !changed) beforeChange?.()\n apply()\n if (press) changed = true\n else commit()\n },\n /**\n * Applies a change that is a step of its own, such as an image that arrives once its file is\n * read. While a press is held, even one Escape put back, it waits for the press to end, so it\n * neither splits that step nor survives being put back with it, and steps keep their order.\n */\n step(apply: () => void) {\n if (press) {\n waiting.push(apply)\n return\n }\n apply()\n commit()\n },\n /** For the picker closing while a press is held, such as when it loses focus: drops it. */\n abort() {\n releaseLater.stop()\n const putBack = press !== null && changed && !cancelled\n end()\n if (putBack) cancel()\n applyWaiting()\n }\n }\n}\n"],"mappings":";;;AAoBA,MAAM,iBAAiB;;;;;;;;;;AAWvB,SAAgB,iBAAiB,EAAE,MAAM,QAAQ,QAAQ,gBAAsC;CAC7F,IAAI,QAAuD;CAC3D,IAAI,UAAU;CACd,IAAI,YAAY;;CAEhB,IAAI,aAAa;;CAEjB,IAAI,UAA6B,CAAC;CAElC,SAAS,eAAe;EACtB,MAAM,QAAQ;EACd,UAAU,CAAC;EACX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AAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,IAAI,CAAC,QAAQ,CAAC,SAAS;EACvB,YAAY;EACZ,aAAa;EACb,QAAQ,IAAI;EACZ,OAAO;CACT,GACA,EAAE,SAAS,KAAK,CAClB;CACA,iBAAiB,UAAU,UAAyB;EAClD,IAAI,MAAM,SAAS,UAAU,aAAa;CAC5C,CAAC;CAED,OAAO;;EAEL,OAAO,OAAmB;GACxB,IAAI,WAAW;GACf,IAAI,SAAS,CAAC,SAAS,eAAe;GACtC,MAAM;GACN,IAAI,OAAO,UAAU;QAChB,OAAO;EACd;;;;;;EAMA,KAAK,OAAmB;GACtB,IAAI,OAAO;IACT,QAAQ,KAAK,KAAK;IAClB;GACF;GACA,MAAM;GACN,OAAO;EACT;;EAEA,QAAQ;GACN,aAAa,KAAK;GAClB,MAAM,UAAU,UAAU,QAAQ,WAAW,CAAC;GAC9C,IAAI;GACJ,IAAI,SAAS,OAAO;GACpB,aAAa;EACf;CACF;AACF"}
@@ -1,3 +1,4 @@
1
1
  import _default from "./ColorInputRoot.vue.js";
2
+ import { PickerCancelCause, usePickerGesture } from "./gesture.js";
2
3
  import _default$1 from "./ColorPickerRoot.vue.js";
3
- export { _default as ColorInputRoot, _default$1 as ColorPickerRoot };
4
+ export { _default as ColorInputRoot, _default$1 as ColorPickerRoot, type PickerCancelCause, usePickerGesture };
@@ -1,3 +1,4 @@
1
1
  import _sfc_main from "./ColorInputRoot.vue.js";
2
+ import { usePickerGesture } from "./gesture.js";
2
3
  import _sfc_main$1 from "./ColorPickerRoot.vue.js";
3
- export { _sfc_main as ColorInputRoot, _sfc_main$1 as ColorPickerRoot };
4
+ export { _sfc_main as ColorInputRoot, _sfc_main$1 as ColorPickerRoot, usePickerGesture };
@@ -1 +1 @@
1
- {"version":3,"file":"FillSwatch.vue.d.ts","names":[],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"mappings":";;KAwEK,cAAc;cA6Fb,0BAAU,gBAAA,+CAAA,qCAAA,iDAAA,aAAA,SAAA,mBAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"FillSwatch.vue.d.ts","names":[],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"mappings":";;KAmFK,cAAc;cA4Fb,0BAAU,gBAAA,+CAAA,qCAAA,iDAAA,aAAA,SAAA,mBAAA,oDAAA;cAGV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -9,6 +9,10 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
9
9
  props: {
10
10
  fill: {},
11
11
  label: {},
12
+ ignoreBinding: {
13
+ type: Boolean,
14
+ default: false
15
+ },
12
16
  asChild: {
13
17
  type: Boolean,
14
18
  default: false
@@ -17,8 +21,9 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
17
21
  },
18
22
  setup(__props) {
19
23
  const binding = useOptionalBindableValue();
24
+ const followsBinding = computed(() => !__props.ignoreBinding && bindingState.value === "bound");
20
25
  const bindingState = computed(() => binding?.state.value);
21
- const boundColor = computed(() => bindingState.value === "bound" ? binding?.resolvedValue.value : void 0);
26
+ const boundColor = computed(() => followsBinding.value ? binding?.resolvedValue.value : void 0);
22
27
  const effectiveFill = computed(() => __props.fill.type === "SOLID" && boundColor.value ? {
23
28
  ...__props.fill,
24
29
  color: boundColor.value
@@ -1 +1 @@
1
- {"version":3,"file":"FillSwatch.vue.js","names":["$attrs"],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Primitive } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useOptionalBindableValue } from '#vue/primitives/BindableValue/context'\n\nimport type { FillSwatchProps, FillSwatchSlots } from './types'\nimport { fillCategory, fillIsTransparent, fillSwatchBackground } from './useFill'\n\nconst { fill, label, as = 'span', asChild = false } = defineProps<FillSwatchProps>()\ndefineSlots<FillSwatchSlots>()\ndefineOptions({ inheritAttrs: false })\n\nconst binding = useOptionalBindableValue<Color>()\nconst bindingState = computed(() => binding?.state.value)\nconst boundColor = computed(() =>\n bindingState.value === 'bound' ? binding?.resolvedValue.value : undefined\n)\nconst effectiveFill = computed(() =>\n fill.type === 'SOLID' && boundColor.value ? { ...fill, color: boundColor.value } : fill\n)\nconst category = computed(() => fillCategory(effectiveFill.value))\nconst background = computed(() => fillSwatchBackground(effectiveFill.value))\nconst transparent = computed(() => fillIsTransparent(effectiveFill.value))\nconst accessibleLabel = computed(() => label ?? `${category.value.toLowerCase()} fill`)\nconst stateAttrs = computed(() => binding?.stateAttrs.value)\nconst slotProps = computed(() => ({\n fill: effectiveFill.value,\n color: effectiveFill.value.color,\n category: category.value,\n background: background.value,\n transparent: transparent.value,\n bindingState: bindingState.value,\n stateAttrs: stateAttrs.value\n}))\n</script>\n\n<template>\n <Primitive\n v-bind=\"{ ...$attrs, ...stateAttrs }\"\n :as=\"as\"\n :as-child=\"asChild\"\n :aria-label=\"accessibleLabel\"\n :data-fill-type=\"effectiveFill.type\"\n :data-fill-category=\"category\"\n :data-transparent=\"transparent ? '' : undefined\"\n :style=\"{ '--pairdraw-fill-swatch-background': background }\"\n role=\"img\"\n aria-roledescription=\"fill swatch\"\n data-slot=\"swatch\"\n >\n <slot v-bind=\"slotProps\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;EAeA,MAAM,UAAU,yBAAgC;EAChD,MAAM,eAAe,eAAe,SAAS,MAAM,KAAK;EACxD,MAAM,aAAa,eACjB,aAAa,UAAU,UAAU,SAAS,cAAc,QAAQ,KAAA,CAClE;EACA,MAAM,gBAAgB,eACpB,QAAA,KAAK,SAAS,WAAW,WAAW,QAAQ;GAAE,GAAG,QAAA;GAAM,OAAO,WAAW;EAAM,IAAI,QAAA,IACrF;EACA,MAAM,WAAW,eAAe,aAAa,cAAc,KAAK,CAAC;EACjE,MAAM,aAAa,eAAe,qBAAqB,cAAc,KAAK,CAAC;EAC3E,MAAM,cAAc,eAAe,kBAAkB,cAAc,KAAK,CAAC;EACzE,MAAM,kBAAkB,eAAe,QAAA,SAAS,GAAG,SAAS,MAAM,YAAY,EAAE,MAAM;EACtF,MAAM,aAAa,eAAe,SAAS,WAAW,KAAK;EAC3D,MAAM,YAAY,gBAAgB;GAChC,MAAM,cAAc;GACpB,OAAO,cAAc,MAAM;GAC3B,UAAU,SAAS;GACnB,YAAY,WAAW;GACvB,aAAa,YAAY;GACzB,cAAc,aAAa;GAC3B,YAAY,WAAW;EACzB,EAAE;;GAIA,OAAA,UAAA,GAAA,YAcY,MAAA,SAAA,GAdZ,WAcY;IAAA,GAbGA,KAAAA;IAAM,GAAK,WAAA;GAAU,GAAA;IACjC,IAAI,QAAA;IACJ,YAAU,QAAA;IACV,cAAY,gBAAA;IACZ,kBAAgB,cAAA,MAAc;IAC9B,sBAAoB,SAAA;IACpB,oBAAkB,YAAA,QAAW,KAAQ,KAAA;IACrC,OAAK,EAAA,qCAAyC,WAAA,MAAU;IACzD,MAAK;IACL,wBAAqB;IACrB,aAAU;;IAEiB,SAAA,cAAA,CAA3B,WAA2B,KAAA,QAAA,WAAA,eAAA,mBAAb,UAAA,KAAS,CAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"FillSwatch.vue.js","names":["$attrs"],"sources":["../../../src/primitives/Fill/FillSwatch.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Primitive } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { useOptionalBindableValue } from '#vue/primitives/BindableValue/context'\n\nimport type { FillSwatchProps, FillSwatchSlots } from './types'\nimport { fillCategory, fillIsTransparent, fillSwatchBackground } from './useFill'\n\nconst {\n fill,\n label,\n as = 'span',\n asChild = false,\n ignoreBinding = false\n} = defineProps<FillSwatchProps>()\ndefineSlots<FillSwatchSlots>()\ndefineOptions({ inheritAttrs: false })\n\nconst binding = useOptionalBindableValue<Color>()\nconst followsBinding = computed(() => !ignoreBinding && bindingState.value === 'bound')\nconst bindingState = computed(() => binding?.state.value)\nconst boundColor = computed(() => (followsBinding.value ? binding?.resolvedValue.value : undefined))\nconst effectiveFill = computed(() =>\n fill.type === 'SOLID' && boundColor.value ? { ...fill, color: boundColor.value } : fill\n)\nconst category = computed(() => fillCategory(effectiveFill.value))\nconst background = computed(() => fillSwatchBackground(effectiveFill.value))\nconst transparent = computed(() => fillIsTransparent(effectiveFill.value))\nconst accessibleLabel = computed(() => label ?? `${category.value.toLowerCase()} fill`)\nconst stateAttrs = computed(() => binding?.stateAttrs.value)\nconst slotProps = computed(() => ({\n fill: effectiveFill.value,\n color: effectiveFill.value.color,\n category: category.value,\n background: background.value,\n transparent: transparent.value,\n bindingState: bindingState.value,\n stateAttrs: stateAttrs.value\n}))\n</script>\n\n<template>\n <Primitive\n v-bind=\"{ ...$attrs, ...stateAttrs }\"\n :as=\"as\"\n :as-child=\"asChild\"\n :aria-label=\"accessibleLabel\"\n :data-fill-type=\"effectiveFill.type\"\n :data-fill-category=\"category\"\n :data-transparent=\"transparent ? '' : undefined\"\n :style=\"{ '--pairdraw-fill-swatch-background': background }\"\n role=\"img\"\n aria-roledescription=\"fill swatch\"\n data-slot=\"swatch\"\n >\n <slot v-bind=\"slotProps\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAqBA,MAAM,UAAU,yBAAgC;EAChD,MAAM,iBAAiB,eAAe,CAAC,QAAA,iBAAiB,aAAa,UAAU,OAAO;EACtF,MAAM,eAAe,eAAe,SAAS,MAAM,KAAK;EACxD,MAAM,aAAa,eAAgB,eAAe,QAAQ,SAAS,cAAc,QAAQ,KAAA,CAAU;EACnG,MAAM,gBAAgB,eACpB,QAAA,KAAK,SAAS,WAAW,WAAW,QAAQ;GAAE,GAAG,QAAA;GAAM,OAAO,WAAW;EAAM,IAAI,QAAA,IACrF;EACA,MAAM,WAAW,eAAe,aAAa,cAAc,KAAK,CAAC;EACjE,MAAM,aAAa,eAAe,qBAAqB,cAAc,KAAK,CAAC;EAC3E,MAAM,cAAc,eAAe,kBAAkB,cAAc,KAAK,CAAC;EACzE,MAAM,kBAAkB,eAAe,QAAA,SAAS,GAAG,SAAS,MAAM,YAAY,EAAE,MAAM;EACtF,MAAM,aAAa,eAAe,SAAS,WAAW,KAAK;EAC3D,MAAM,YAAY,gBAAgB;GAChC,MAAM,cAAc;GACpB,OAAO,cAAc,MAAM;GAC3B,UAAU,SAAS;GACnB,YAAY,WAAW;GACvB,aAAa,YAAY;GACzB,cAAc,aAAa;GAC3B,YAAY,WAAW;EACzB,EAAE;;GAIA,OAAA,UAAA,GAAA,YAcY,MAAA,SAAA,GAdZ,WAcY;IAAA,GAbGA,KAAAA;IAAM,GAAK,WAAA;GAAU,GAAA;IACjC,IAAI,QAAA;IACJ,YAAU,QAAA;IACV,cAAY,gBAAA;IACZ,kBAAgB,cAAA,MAAc;IAC9B,sBAAoB,SAAA;IACpB,oBAAkB,YAAA,QAAW,KAAQ,KAAA;IACrC,OAAK,EAAA,qCAAyC,WAAA,MAAU;IACzD,MAAK;IACL,wBAAqB;IACrB,aAAU;;IAEiB,SAAA,cAAA,CAA3B,WAA2B,KAAA,QAAA,WAAA,eAAA,mBAAb,UAAA,KAAS,CAAA,CAAA,CAAA,CAAA"}
@@ -26,6 +26,11 @@ interface FillSwatchProps extends PrimitiveProps {
26
26
  fill: Fill;
27
27
  /** Accessible name for the preview. */
28
28
  label?: string;
29
+ /**
30
+ * Shows the fill as given, even inside a bound field: a variable picker's rows each preview their
31
+ * own variable rather than the one the field is bound to.
32
+ */
33
+ ignoreBinding?: boolean;
29
34
  }
30
35
  interface FillSwatchSlotProps {
31
36
  fill: Fill;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/Fill/types.ts"],"mappings":";;;;;;KAQY;UAEK;EACf;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,UAAU;EACV;EACA;EACA,SAAS;;UAGM;EACf,WAAW,OAAO;;UAGH,wBAAwB;;EAEvC,MAAM;;EAEN;;UAGe;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,WAAW,OAAO"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/Fill/types.ts"],"mappings":";;;;;;KAQY;UAEK;EACf;EACA;EACA;EACA;;UAGe;EACf,MAAM;EACN,UAAU;EACV;EACA;EACA,SAAS;;UAGM;EACf,WAAW,OAAO;;UAGH,wBAAwB;;EAEvC,MAAM;;EAEN;;;;;EAKA;;UAGe;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA,cAAc;EACd,YAAY;;UAGG;EACf,WAAW,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"useFill.d.ts","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"mappings":";;;;iBAkCgB,aAAa,MAAM,OAAO;iBAI1B,kBAAkB,MAAM;iBASxB,qBAAqB,MAAM;;iBAiB3B,QAAQ,MAAM,IAAI,OAAO,WAAW,MAAM"}
1
+ {"version":3,"file":"useFill.d.ts","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"mappings":";;;;iBA2CgB,aAAa,MAAM,OAAO;iBAI1B,kBAAkB,MAAM;iBAWxB,qBAAqB,MAAM;;iBAiB3B,QAAQ,MAAM,IAAI,OAAO,WAAW,MAAM"}
@@ -1,5 +1,6 @@
1
1
  import { computed } from "vue";
2
2
  import { colorToCSS } from "@pairdraw/scene-graph/color";
3
+ import { BLACK, TRANSPARENT } from "@pairdraw/scene-graph/constants";
3
4
  import { DEFAULT_GRADIENT_TRANSFORM, defaultGradientStops, defaultMeshPoints } from "@pairdraw/scene-graph/gradient";
4
5
  //#region src/primitives/Fill/useFill.ts
5
6
  const FILL_CATEGORY = {
@@ -11,6 +12,13 @@ const FILL_CATEGORY = {
11
12
  MESH: "MESH",
12
13
  IMAGE: "IMAGE"
13
14
  };
15
+ /**
16
+ * A non-solid fill carries no `color` at runtime even though the model types it as required,
17
+ * because image and shader paints have no colour; the swatch treats that as no colour paint.
18
+ */
19
+ function fillColor(fill, fallback) {
20
+ return fill.color ?? fallback;
21
+ }
14
22
  function effectiveColor(color, opacity) {
15
23
  return {
16
24
  ...color,
@@ -25,14 +33,14 @@ function fillCategory(fill) {
25
33
  }
26
34
  function fillIsTransparent(fill) {
27
35
  if (fill.opacity < 1) return true;
28
- if (fillCategory(fill) === "GRADIENT") return fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fill.color.a < 1;
29
- if (fillCategory(fill) === "MESH") return fill.meshPoints?.some((point) => point.color.a < 1) ?? fill.color.a < 1;
30
- return fill.color.a < 1;
36
+ if (fillCategory(fill) === "GRADIENT") return fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1;
37
+ if (fillCategory(fill) === "MESH") return fill.meshPoints?.some((point) => point.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1;
38
+ return fillColor(fill, TRANSPARENT).a < 1;
31
39
  }
32
40
  function fillSwatchBackground(fill) {
33
41
  if (fillCategory(fill) === "GRADIENT" && fill.gradientStops?.length) return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity)})`;
34
42
  if (fillCategory(fill) === "MESH" && fill.meshPoints?.length) return `linear-gradient(to right, ${fill.meshPoints.map((point, index) => `${colorToCSS(effectiveColor(point.color, fill.opacity))} ${index / (fill.meshPoints?.length ?? 1) * 100}%`).join(", ")})`;
35
- return colorToCSS(effectiveColor(fill.color, fill.opacity));
43
+ return colorToCSS(effectiveColor(fillColor(fill, TRANSPARENT), fill.opacity));
36
44
  }
37
45
  /** Fill category state and immutable conversion actions without picker or popover behavior. */
38
46
  function useFill(fill, onUpdate) {
@@ -41,7 +49,7 @@ function useFill(fill, onUpdate) {
41
49
  const transparent = computed(() => fillIsTransparent(fill.value));
42
50
  function toSolid() {
43
51
  if (category.value === "SOLID") return;
44
- const color = fill.value.gradientStops?.[0]?.color ?? fill.value.meshPoints?.[0]?.color ?? fill.value.color;
52
+ const color = fill.value.gradientStops?.[0]?.color ?? fill.value.meshPoints?.[0]?.color ?? fillColor(fill.value, BLACK);
45
53
  onUpdate({
46
54
  ...fill.value,
47
55
  type: "SOLID",
@@ -50,7 +58,7 @@ function useFill(fill, onUpdate) {
50
58
  }
51
59
  function toGradient() {
52
60
  if (category.value === "GRADIENT") return;
53
- const gradientStops = fill.value.gradientStops?.length ? structuredClone(fill.value.gradientStops) : defaultGradientStops(fill.value.color);
61
+ const gradientStops = fill.value.gradientStops?.length ? structuredClone(fill.value.gradientStops) : defaultGradientStops(fillColor(fill.value, BLACK));
54
62
  onUpdate({
55
63
  ...fill.value,
56
64
  type: "GRADIENT_LINEAR",
@@ -60,7 +68,7 @@ function useFill(fill, onUpdate) {
60
68
  }
61
69
  function toMesh() {
62
70
  if (category.value === "MESH") return;
63
- const color = fill.value.meshPoints?.[0]?.color ?? fill.value.color;
71
+ const color = fill.value.meshPoints?.[0]?.color ?? fillColor(fill.value, BLACK);
64
72
  onUpdate({
65
73
  ...fill.value,
66
74
  type: "MESH",
@@ -1 +1 @@
1
- {"version":3,"file":"useFill.js","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"sourcesContent":["import { computed } from 'vue'\nimport type { Ref } from 'vue'\n\nimport type { Fill, GradientStop } from '@pairdraw/scene-graph'\nimport { colorToCSS } from '@pairdraw/scene-graph/color'\nimport {\n DEFAULT_GRADIENT_TRANSFORM,\n defaultGradientStops,\n defaultMeshPoints\n} from '@pairdraw/scene-graph/gradient'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FillCategory } from './types'\n\nconst FILL_CATEGORY: Partial<Record<Fill['type'], FillCategory>> = {\n SOLID: 'SOLID',\n GRADIENT_LINEAR: 'GRADIENT',\n GRADIENT_RADIAL: 'GRADIENT',\n GRADIENT_ANGULAR: 'GRADIENT',\n GRADIENT_DIAMOND: 'GRADIENT',\n MESH: 'MESH',\n IMAGE: 'IMAGE'\n}\n\nfunction effectiveColor(color: Color, opacity: number): Color {\n return { ...color, a: color.a * opacity }\n}\n\nfunction gradientCSS(stops: GradientStop[], opacity: number): string {\n return stops\n .map((stop) => `${colorToCSS(effectiveColor(stop.color, opacity))} ${stop.position * 100}%`)\n .join(', ')\n}\n\nexport function fillCategory(fill: Fill): FillCategory {\n return FILL_CATEGORY[fill.type] ?? 'SOLID'\n}\n\nexport function fillIsTransparent(fill: Fill): boolean {\n if (fill.opacity < 1) return true\n if (fillCategory(fill) === 'GRADIENT')\n return fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fill.color.a < 1\n if (fillCategory(fill) === 'MESH')\n return fill.meshPoints?.some((point) => point.color.a < 1) ?? fill.color.a < 1\n return fill.color.a < 1\n}\n\nexport function fillSwatchBackground(fill: Fill): string {\n if (fillCategory(fill) === 'GRADIENT' && fill.gradientStops?.length) {\n return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity)})`\n }\n if (fillCategory(fill) === 'MESH' && fill.meshPoints?.length) {\n const stops = fill.meshPoints\n .map(\n (point, index) =>\n `${colorToCSS(effectiveColor(point.color, fill.opacity))} ${(index / (fill.meshPoints?.length ?? 1)) * 100}%`\n )\n .join(', ')\n return `linear-gradient(to right, ${stops})`\n }\n return colorToCSS(effectiveColor(fill.color, fill.opacity))\n}\n\n/** Fill category state and immutable conversion actions without picker or popover behavior. */\nexport function useFill(fill: Ref<Fill>, onUpdate: (fill: Fill) => void) {\n const category = computed(() => fillCategory(fill.value))\n const swatchBackground = computed(() => fillSwatchBackground(fill.value))\n const transparent = computed(() => fillIsTransparent(fill.value))\n\n function toSolid() {\n if (category.value === 'SOLID') return\n const color =\n fill.value.gradientStops?.[0]?.color ?? fill.value.meshPoints?.[0]?.color ?? fill.value.color\n onUpdate({ ...fill.value, type: 'SOLID', color: { ...color } })\n }\n\n function toGradient() {\n if (category.value === 'GRADIENT') return\n const gradientStops = fill.value.gradientStops?.length\n ? structuredClone(fill.value.gradientStops)\n : defaultGradientStops(fill.value.color)\n onUpdate({\n ...fill.value,\n type: 'GRADIENT_LINEAR',\n gradientStops,\n gradientTransform: fill.value.gradientTransform ?? { ...DEFAULT_GRADIENT_TRANSFORM }\n })\n }\n\n function toMesh() {\n if (category.value === 'MESH') return\n const color = fill.value.meshPoints?.[0]?.color ?? fill.value.color\n onUpdate({\n ...fill.value,\n type: 'MESH',\n meshColumns: 1,\n meshRows: 1,\n meshPoints: defaultMeshPoints(color)\n })\n }\n\n function toImage() {\n if (category.value === 'IMAGE') return\n onUpdate({ ...fill.value, type: 'IMAGE' })\n }\n\n const actions = { toSolid, toGradient, toMesh, toImage }\n\n return {\n category,\n swatchBackground,\n transparent,\n actions,\n toSolid,\n toGradient,\n toMesh,\n toImage\n }\n}\n"],"mappings":";;;;AAcA,MAAM,gBAA6D;CACjE,OAAO;CACP,iBAAiB;CACjB,iBAAiB;CACjB,kBAAkB;CAClB,kBAAkB;CAClB,MAAM;CACN,OAAO;AACT;AAEA,SAAS,eAAe,OAAc,SAAwB;CAC5D,OAAO;EAAE,GAAG;EAAO,GAAG,MAAM,IAAI;CAAQ;AAC1C;AAEA,SAAS,YAAY,OAAuB,SAAyB;CACnE,OAAO,MACJ,KAAK,SAAS,GAAG,WAAW,eAAe,KAAK,OAAO,OAAO,CAAC,EAAE,GAAG,KAAK,WAAW,IAAI,EAAE,CAAC,CAC3F,KAAK,IAAI;AACd;AAEA,SAAgB,aAAa,MAA0B;CACrD,OAAO,cAAc,KAAK,SAAS;AACrC;AAEA,SAAgB,kBAAkB,MAAqB;CACrD,IAAI,KAAK,UAAU,GAAG,OAAO;CAC7B,IAAI,aAAa,IAAI,MAAM,YACzB,OAAO,KAAK,eAAe,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,MAAM,IAAI;CAChF,IAAI,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AE,GAAG,2BAA2B;EACrF,CAAC;CACH;CAEA,SAAS,SAAS;EAChB,IAAI,SAAS,UAAU,QAAQ;EAC/B,MAAM,QAAQ,KAAK,MAAM,aAAa,EAAE,EAAE,SAAS,KAAK,MAAM;EAC9D,SAAS;GACP,GAAG,KAAK;GACR,MAAM;GACN,aAAa;GACb,UAAU;GACV,YAAY,kBAAkB,KAAK;EACrC,CAAC;CACH;CAEA,SAAS,UAAU;EACjB,IAAI,SAAS,UAAU,SAAS;EAChC,SAAS;GAAE,GAAG,KAAK;GAAO,MAAM;EAAQ,CAAC;CAC3C;CAIA,OAAO;EACL;EACA;EACA;EACA,SAAA;GANgB;GAAS;GAAY;GAAQ;EAMvC;EACN;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useFill.js","names":[],"sources":["../../../src/primitives/Fill/useFill.ts"],"sourcesContent":["import { computed } from 'vue'\nimport type { Ref } from 'vue'\n\nimport type { Fill, GradientStop } from '@pairdraw/scene-graph'\nimport { colorToCSS } from '@pairdraw/scene-graph/color'\nimport { BLACK, TRANSPARENT } from '@pairdraw/scene-graph/constants'\nimport {\n DEFAULT_GRADIENT_TRANSFORM,\n defaultGradientStops,\n defaultMeshPoints\n} from '@pairdraw/scene-graph/gradient'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport type { FillCategory } from './types'\n\nconst FILL_CATEGORY: Partial<Record<Fill['type'], FillCategory>> = {\n SOLID: 'SOLID',\n GRADIENT_LINEAR: 'GRADIENT',\n GRADIENT_RADIAL: 'GRADIENT',\n GRADIENT_ANGULAR: 'GRADIENT',\n GRADIENT_DIAMOND: 'GRADIENT',\n MESH: 'MESH',\n IMAGE: 'IMAGE'\n}\n\n/**\n * A non-solid fill carries no `color` at runtime even though the model types it as required,\n * because image and shader paints have no colour; the swatch treats that as no colour paint.\n */\nfunction fillColor(fill: Fill, fallback: Color): Color {\n return (fill as { color?: Color }).color ?? fallback\n}\n\nfunction effectiveColor(color: Color, opacity: number): Color {\n return { ...color, a: color.a * opacity }\n}\n\nfunction gradientCSS(stops: GradientStop[], opacity: number): string {\n return stops\n .map((stop) => `${colorToCSS(effectiveColor(stop.color, opacity))} ${stop.position * 100}%`)\n .join(', ')\n}\n\nexport function fillCategory(fill: Fill): FillCategory {\n return FILL_CATEGORY[fill.type] ?? 'SOLID'\n}\n\nexport function fillIsTransparent(fill: Fill): boolean {\n if (fill.opacity < 1) return true\n if (fillCategory(fill) === 'GRADIENT')\n return (\n fill.gradientStops?.some((stop) => stop.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1\n )\n if (fillCategory(fill) === 'MESH')\n return fill.meshPoints?.some((point) => point.color.a < 1) ?? fillColor(fill, TRANSPARENT).a < 1\n return fillColor(fill, TRANSPARENT).a < 1\n}\n\nexport function fillSwatchBackground(fill: Fill): string {\n if (fillCategory(fill) === 'GRADIENT' && fill.gradientStops?.length) {\n return `linear-gradient(to right, ${gradientCSS(fill.gradientStops, fill.opacity)})`\n }\n if (fillCategory(fill) === 'MESH' && fill.meshPoints?.length) {\n const stops = fill.meshPoints\n .map(\n (point, index) =>\n `${colorToCSS(effectiveColor(point.color, fill.opacity))} ${(index / (fill.meshPoints?.length ?? 1)) * 100}%`\n )\n .join(', ')\n return `linear-gradient(to right, ${stops})`\n }\n return colorToCSS(effectiveColor(fillColor(fill, TRANSPARENT), fill.opacity))\n}\n\n/** Fill category state and immutable conversion actions without picker or popover behavior. */\nexport function useFill(fill: Ref<Fill>, onUpdate: (fill: Fill) => void) {\n const category = computed(() => fillCategory(fill.value))\n const swatchBackground = computed(() => fillSwatchBackground(fill.value))\n const transparent = computed(() => fillIsTransparent(fill.value))\n\n function toSolid() {\n if (category.value === 'SOLID') return\n const color =\n fill.value.gradientStops?.[0]?.color ??\n fill.value.meshPoints?.[0]?.color ??\n fillColor(fill.value, BLACK)\n onUpdate({ ...fill.value, type: 'SOLID', color: { ...color } })\n }\n\n function toGradient() {\n if (category.value === 'GRADIENT') return\n const gradientStops = fill.value.gradientStops?.length\n ? structuredClone(fill.value.gradientStops)\n : defaultGradientStops(fillColor(fill.value, BLACK))\n onUpdate({\n ...fill.value,\n type: 'GRADIENT_LINEAR',\n gradientStops,\n gradientTransform: fill.value.gradientTransform ?? { ...DEFAULT_GRADIENT_TRANSFORM }\n })\n }\n\n function toMesh() {\n if (category.value === 'MESH') return\n const color = fill.value.meshPoints?.[0]?.color ?? fillColor(fill.value, BLACK)\n onUpdate({\n ...fill.value,\n type: 'MESH',\n meshColumns: 1,\n meshRows: 1,\n meshPoints: defaultMeshPoints(color)\n })\n }\n\n function toImage() {\n if (category.value === 'IMAGE') return\n onUpdate({ ...fill.value, type: 'IMAGE' })\n }\n\n const actions = { toSolid, toGradient, toMesh, toImage }\n\n return {\n category,\n swatchBackground,\n transparent,\n actions,\n toSolid,\n toGradient,\n toMesh,\n toImage\n }\n}\n"],"mappings":";;;;;AAeA,MAAM,gBAA6D;CACjE,OAAO;CACP,iBAAiB;CACjB,iBAAiB;CACjB,kBAAkB;CAClB,kBAAkB;CAClB,MAAM;CACN,OAAO;AACT;;;;;AAMA,SAAS,UAAU,MAAY,UAAwB;CACrD,OAAQ,KAA2B,SAAS;AAC9C;AAEA,SAAS,eAAe,OAAc,SAAwB;CAC5D,OAAO;EAAE,GAAG;EAAO,GAAG,MAAM,IAAI;CAAQ;AAC1C;AAEA,SAAS,YAAY,OAAuB,SAAyB;CACnE,OAAO,MACJ,KAAK,SAAS,GAAG,WAAW,eAAe,KAAK,OAAO,OAAO,CAAC,EAAE,GAAG,KAAK,WAAW,IAAI,EAAE,CAAC,CAC3F,KAAK,IAAI;AACd;AAEA,SAAgB,aAAa,MAA0B;CACrD,OAAO,cAAc,KAAK,SAAS;AACrC;AAEA,SAAgB,kBAAkB,MAAqB;CACrD,IAAI,KAAK,UAAU,GAAG,OAAO;CAC7B,IAAI,aAAa,IAAI,MAAM,YACzB,OACE,KAAK,eAAe,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC,KAAK,UAAU,M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AAqB,UAAU,KAAK,OAAO,KAAK,CAAC;EACrD,SAAS;GACP,GAAG,KAAK;GACR,MAAM;GACN;GACA,mBAAmB,KAAK,MAAM,qBAAqB,EAAE,GAAG,2BAA2B;EACrF,CAAC;CACH;CAEA,SAAS,SAAS;EAChB,IAAI,SAAS,UAAU,QAAQ;EAC/B,MAAM,QAAQ,KAAK,MAAM,aAAa,EAAE,EAAE,SAAS,UAAU,KAAK,OAAO,KAAK;EAC9E,SAAS;GACP,GAAG,KAAK;GACR,MAAM;GACN,aAAa;GACb,UAAU;GACV,YAAY,kBAAkB,KAAK;EACrC,CAAC;CACH;CAEA,SAAS,UAAU;EACjB,IAAI,SAAS,UAAU,SAAS;EAChC,SAAS;GAAE,GAAG,KAAK;GAAO,MAAM;EAAQ,CAAC;CAC3C;CAIA,OAAO;EACL;EACA;EACA;EACA,SAAA;GANgB;GAAS;GAAY;GAAQ;EAMvC;EACN;EACA;EACA;EACA;CACF;AACF"}
@@ -6,6 +6,7 @@ type __VLS_Props = {
6
6
  listFamilies: () => Promise<string[] | FontFamilyOption[]>;
7
7
  localFontAccess?: FontAccessController;
8
8
  ui?: FontPickerUI;
9
+ searchPlaceholder?: string;
9
10
  emptySearchText?: string;
10
11
  emptyFontsText?: string;
11
12
  emptyFontsHint?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"FontPickerRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"mappings":";;;;KA+MK;EACD,oBAAoB,mBAAmB;EACvC,kBAAkB;EAClB,KAAK;EACL;EACA;EACA;;KAoDC;EACL;;KAMK,oBAAoB,cAAc;YA6ThB;;;GAA0C;;GAAqB;;;;GAAqB;;;KACtG;EACD,WAAW,cAAc;;EACzB,UAAU,cAAc;;EACxB,QAAQ,cAAc;;EACtB,aAAa,cAAc;;cAQzB,0BAAU,gBAAA,iDAAA,qCAAA;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"FontPickerRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"mappings":";;;;KAuNK;EACH,oBAAoB,mBAAmB;EACvC,kBAAkB;EAClB,KAAK;EACL;EACA;EACA;EACA;;KA2DG;EACL;;KAMK,oBAAoB,cAAc;YA6ThB;;;GAA0C;;GAAqB;;;;GAAqB;;;KACtG;EACD,WAAW,cAAc;;EACzB,UAAU,cAAc;;EACxB,QAAQ,cAAc;;EACtB,aAAa,cAAc;;cAQzB,0BAAU,gBAAA,iDAAA,qCAAA;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -21,6 +21,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
21
21
  listFamilies: { type: Function },
22
22
  localFontAccess: {},
23
23
  ui: {},
24
+ searchPlaceholder: { default: "Search fonts…" },
24
25
  emptySearchText: {},
25
26
  emptyFontsText: {},
26
27
  emptyFontsHint: {}
@@ -101,12 +102,16 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
101
102
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(searchTerm) ? searchTerm.value = $event : null),
102
103
  "display-value": () => "",
103
104
  class: normalizeClass(__props.ui?.search),
104
- placeholder: "Search fonts…",
105
+ placeholder: __props.searchPlaceholder,
105
106
  autocomplete: "off",
106
107
  autocorrect: "off",
107
108
  autocapitalize: "off",
108
109
  spellcheck: "false"
109
- }, null, 8, ["modelValue", "class"])]), createVNode(unref(ComboboxViewport), { class: normalizeClass(__props.ui?.viewport ?? "max-h-72 overflow-y-auto") }, {
110
+ }, null, 8, [
111
+ "modelValue",
112
+ "class",
113
+ "placeholder"
114
+ ])]), createVNode(unref(ComboboxViewport), { class: normalizeClass(__props.ui?.viewport ?? "max-h-72 overflow-y-auto") }, {
110
115
  default: withCtx(() => [createVNode(unref(ComboboxVirtualizer), {
111
116
  options: unref(filtered),
112
117
  "text-content": (option) => option.family,
@@ -1 +1 @@
1
- {"version":3,"file":"FontPickerRoot.vue.js","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { templateRef, unrefElement } from '@vueuse/core'\nimport {\n ComboboxAnchor,\n ComboboxContent,\n ComboboxInput,\n ComboboxItem,\n ComboboxItemIndicator,\n ComboboxPortal,\n ComboboxRoot,\n ComboboxTrigger,\n ComboboxVirtualizer,\n ComboboxViewport,\n type AcceptableValue\n} from 'reka-ui'\nimport { nextTick, useTemplateRef, watch } from 'vue'\n\nimport type { FontFamilyOption } from '@pairdraw/core/text'\n\nimport { useRetainedPopup } from '#vue/lifecycle/retention/popup'\nimport type { FontPickerUI } from '#vue/primitives/FontPicker/types'\nimport { useFontPicker, type FontAccessController } from '#vue/primitives/FontPicker/useFontPicker'\n\nconst { listFamilies, localFontAccess, ui, emptySearchText, emptyFontsText, emptyFontsHint } =\n defineProps<{\n listFamilies: () => Promise<string[] | FontFamilyOption[]>\n localFontAccess?: FontAccessController\n ui?: FontPickerUI\n emptySearchText?: string\n emptyFontsText?: string\n emptyFontsHint?: string\n }>()\n\nconst modelValue = defineModel<string>({ required: true })\nconst emit = defineEmits<{ select: [family: string] }>()\n\nconst contentRef = templateRef<HTMLElement>('contentRef')\n\nfunction focusSearchInput() {\n nextTick(() => {\n const content = unrefElement(contentRef)\n if (!(content instanceof HTMLElement)) return\n content.querySelector<HTMLInputElement>('input')?.focus()\n })\n}\n\nconst { searchTerm, open, filtered, loading, accessState, requestAccess, select } = useFontPicker({\n modelValue,\n listFamilies,\n localFontAccess,\n onSelect: (family) => emit('select', family)\n})\nconst { portalActive } = useRetainedPopup(open)\nconst root = useTemplateRef<{ highlightItem: (value: AcceptableValue) => void }>('root')\n\n// The families arrive after the list opens, too late for Reka's own scroll to the chosen font.\nwatch(\n () => open.value && !loading.value && filtered.value.length > 0,\n async (ready) => {\n if (!ready || searchTerm.value) return\n await nextTick()\n root.value?.highlightItem(modelValue.value)\n }\n)\n\n/**\n * The list holds font options and the value is a family name; Reka compares them to find the\n * chosen font, so opening scrolls to it.\n */\nfunction sameFamily(left: unknown, right: unknown): boolean {\n return familyOf(left) === familyOf(right)\n}\n\nfunction familyOf(value: unknown): unknown {\n return typeof value === 'object' && value !== null && 'family' in value ? value.family : value\n}\n</script>\n\n<template>\n <ComboboxRoot\n ref=\"root\"\n v-model:open=\"open\"\n :model-value=\"modelValue\"\n :ignore-filter=\"true\"\n :by=\"sameFamily\"\n @update:model-value=\"\n (v: AcceptableValue) => {\n if (typeof v === 'string') select(v)\n }\n \"\n >\n <ComboboxAnchor as-child>\n <ComboboxTrigger as-child>\n <slot name=\"trigger\" :value=\"modelValue\" :open=\"open\">\n <button :class=\"ui?.trigger\">\n <span class=\"truncate\">{{ modelValue }}</span>\n </button>\n </slot>\n </ComboboxTrigger>\n </ComboboxAnchor>\n\n <ComboboxPortal v-if=\"portalActive\">\n <ComboboxContent\n :side-offset=\"2\"\n align=\"start\"\n position=\"popper\"\n :class=\"ui?.content\"\n @open-auto-focus.prevent\n ref=\"contentRef\"\n @vue:mounted=\"focusSearchInput\"\n >\n <slot name=\"search\" :search-term=\"searchTerm\">\n <ComboboxInput\n v-model=\"searchTerm\"\n :display-value=\"() => ''\"\n :class=\"ui?.search\"\n placeholder=\"Search fonts…\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n />\n </slot>\n\n <ComboboxViewport :class=\"ui?.viewport ?? 'max-h-72 overflow-y-auto'\">\n <ComboboxVirtualizer\n v-slot=\"{ option }\"\n :options=\"filtered\"\n :text-content=\"(option: FontFamilyOption) => option.family\"\n :estimate-size=\"36\"\n >\n <ComboboxItem\n :value=\"option.family\"\n :class=\"ui?.item\"\n :style=\"{ fontFamily: `'${option.family}', sans-serif` }\"\n >\n <slot\n name=\"item\"\n :family=\"option.family\"\n :source=\"option.source\"\n :selected=\"option.family === modelValue\"\n >\n <ComboboxItemIndicator>\n <slot name=\"indicator\" :selected=\"option.family === modelValue\" />\n </ComboboxItemIndicator>\n <span class=\"truncate\">{{ option.family }}</span>\n </slot>\n </ComboboxItem>\n </ComboboxVirtualizer>\n\n <div v-if=\"filtered.length === 0 && searchTerm\" :class=\"ui?.empty\">\n {{ emptySearchText ?? 'No fonts found' }}\n </div>\n <div v-else-if=\"filtered.length === 0\" :class=\"ui?.empty\">\n <div>\n <p v-if=\"accessState === 'prompt'\">\n Allow local font access to browse installed fonts.\n </p>\n <p v-else-if=\"accessState === 'denied'\">\n Local font access is blocked for this site.\n </p>\n <p v-else-if=\"accessState === 'unsupported'\">\n Local fonts are not available in this browser.\n </p>\n <p v-else>{{ emptyFontsText ?? 'No local fonts available.' }}</p>\n <p v-if=\"emptyFontsHint\" class=\"mt-1\">{{ emptyFontsHint }}</p>\n <button\n v-if=\"accessState === 'prompt'\"\n type=\"button\"\n :class=\"ui?.emptyAction\"\n :disabled=\"loading\"\n @click=\"requestAccess\"\n >\n {{ loading ? 'Loading…' : 'Allow local fonts' }}\n </button>\n </div>\n </div>\n </ComboboxViewport>\n </ComboboxContent>\n </ComboboxPortal>\n </ComboboxRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,MAAM,aAAa,SAAmB,SAAA,YAAmB;EACzD,MAAM,OAAO;EAEb,MAAM,aAAa,YAAyB,YAAY;EAExD,SAAS,mBAAmB;GAC1B,eAAe;IACb,MAAM,UAAU,aAAa,UAAU;IACvC,IAAI,EAAE,mBAAmB,cAAc;IACvC,QAAQ,cAAgC,OAAO,CAAC,EAAE,MAAM;GAC1D,CAAC;EACH;EAEA,MAAM,EAAE,YAAY,MAAM,UAAU,SAAS,aAAa,eAAe,WAAW,cAAc;GAChG;GACA,cAAW,QAAA;GACX,iBAAc,QAAA;GACd,WAAW,WAAW,KAAK,UAAU,MAAM;EAC7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AAA,IAAA;QAEL,GAAA,gBAAA,MAAA,OAAA,IAAO,aAAA,mBAAA,GAAA,IAAA,UAAA,KAAA,mBAAA,QAAA,IAAA"}
1
+ {"version":3,"file":"FontPickerRoot.vue.js","names":[],"sources":["../../../src/primitives/FontPicker/FontPickerRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { templateRef, unrefElement } from '@vueuse/core'\nimport {\n ComboboxAnchor,\n ComboboxContent,\n ComboboxInput,\n ComboboxItem,\n ComboboxItemIndicator,\n ComboboxPortal,\n ComboboxRoot,\n ComboboxTrigger,\n ComboboxVirtualizer,\n ComboboxViewport,\n type AcceptableValue\n} from 'reka-ui'\nimport { nextTick, useTemplateRef, watch } from 'vue'\n\nimport type { FontFamilyOption } from '@pairdraw/core/text'\n\nimport { useRetainedPopup } from '#vue/lifecycle/retention/popup'\nimport type { FontPickerUI } from '#vue/primitives/FontPicker/types'\nimport { useFontPicker, type FontAccessController } from '#vue/primitives/FontPicker/useFontPicker'\n\nconst {\n listFamilies,\n localFontAccess,\n ui,\n searchPlaceholder = 'Search fonts…',\n emptySearchText,\n emptyFontsText,\n emptyFontsHint\n} = defineProps<{\n listFamilies: () => Promise<string[] | FontFamilyOption[]>\n localFontAccess?: FontAccessController\n ui?: FontPickerUI\n searchPlaceholder?: string\n emptySearchText?: string\n emptyFontsText?: string\n emptyFontsHint?: string\n}>()\n\nconst modelValue = defineModel<string>({ required: true })\nconst emit = defineEmits<{ select: [family: string] }>()\n\nconst contentRef = templateRef<HTMLElement>('contentRef')\n\nfunction focusSearchInput() {\n nextTick(() => {\n const content = unrefElement(contentRef)\n if (!(content instanceof HTMLElement)) return\n content.querySelector<HTMLInputElement>('input')?.focus()\n })\n}\n\nconst { searchTerm, open, filtered, loading, accessState, requestAccess, select } = useFontPicker({\n modelValue,\n listFamilies,\n localFontAccess,\n onSelect: (family) => emit('select', family)\n})\nconst { portalActive } = useRetainedPopup(open)\nconst root = useTemplateRef<{ highlightItem: (value: AcceptableValue) => void }>('root')\n\n// The families arrive after the list opens, too late for Reka's own scroll to the chosen font.\nwatch(\n () => open.value && !loading.value && filtered.value.length > 0,\n async (ready) => {\n if (!ready || searchTerm.value) return\n await nextTick()\n root.value?.highlightItem(modelValue.value)\n }\n)\n\n/**\n * The list holds font options and the value is a family name; Reka compares them to find the\n * chosen font, so opening scrolls to it.\n */\nfunction sameFamily(left: unknown, right: unknown): boolean {\n return familyOf(left) === familyOf(right)\n}\n\nfunction familyOf(value: unknown): unknown {\n return typeof value === 'object' && value !== null && 'family' in value ? value.family : value\n}\n</script>\n\n<template>\n <ComboboxRoot\n ref=\"root\"\n v-model:open=\"open\"\n :model-value=\"modelValue\"\n :ignore-filter=\"true\"\n :by=\"sameFamily\"\n @update:model-value=\"\n (v: AcceptableValue) => {\n if (typeof v === 'string') select(v)\n }\n \"\n >\n <ComboboxAnchor as-child>\n <ComboboxTrigger as-child>\n <slot name=\"trigger\" :value=\"modelValue\" :open=\"open\">\n <button :class=\"ui?.trigger\">\n <span class=\"truncate\">{{ modelValue }}</span>\n </button>\n </slot>\n </ComboboxTrigger>\n </ComboboxAnchor>\n\n <ComboboxPortal v-if=\"portalActive\">\n <ComboboxContent\n :side-offset=\"2\"\n align=\"start\"\n position=\"popper\"\n :class=\"ui?.content\"\n @open-auto-focus.prevent\n ref=\"contentRef\"\n @vue:mounted=\"focusSearchInput\"\n >\n <slot name=\"search\" :search-term=\"searchTerm\">\n <ComboboxInput\n v-model=\"searchTerm\"\n :display-value=\"() => ''\"\n :class=\"ui?.search\"\n :placeholder=\"searchPlaceholder\"\n autocomplete=\"off\"\n autocorrect=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n />\n </slot>\n\n <ComboboxViewport :class=\"ui?.viewport ?? 'max-h-72 overflow-y-auto'\">\n <ComboboxVirtualizer\n v-slot=\"{ option }\"\n :options=\"filtered\"\n :text-content=\"(option: FontFamilyOption) => option.family\"\n :estimate-size=\"36\"\n >\n <ComboboxItem\n :value=\"option.family\"\n :class=\"ui?.item\"\n :style=\"{ fontFamily: `'${option.family}', sans-serif` }\"\n >\n <slot\n name=\"item\"\n :family=\"option.family\"\n :source=\"option.source\"\n :selected=\"option.family === modelValue\"\n >\n <ComboboxItemIndicator>\n <slot name=\"indicator\" :selected=\"option.family === modelValue\" />\n </ComboboxItemIndicator>\n <span class=\"truncate\">{{ option.family }}</span>\n </slot>\n </ComboboxItem>\n </ComboboxVirtualizer>\n\n <div v-if=\"filtered.length === 0 && searchTerm\" :class=\"ui?.empty\">\n {{ emptySearchText ?? 'No fonts found' }}\n </div>\n <div v-else-if=\"filtered.length === 0\" :class=\"ui?.empty\">\n <div>\n <p v-if=\"accessState === 'prompt'\">\n Allow local font access to browse installed fonts.\n </p>\n <p v-else-if=\"accessState === 'denied'\">\n Local font access is blocked for this site.\n </p>\n <p v-else-if=\"accessState === 'unsupported'\">\n Local fonts are not available in this browser.\n </p>\n <p v-else>{{ emptyFontsText ?? 'No local fonts available.' }}</p>\n <p v-if=\"emptyFontsHint\" class=\"mt-1\">{{ emptyFontsHint }}</p>\n <button\n v-if=\"accessState === 'prompt'\"\n type=\"button\"\n :class=\"ui?.emptyAction\"\n :disabled=\"loading\"\n @click=\"requestAccess\"\n >\n {{ loading ? 'Loading…' : 'Allow local fonts' }}\n </button>\n </div>\n </div>\n </ComboboxViewport>\n </ComboboxContent>\n </ComboboxPortal>\n </ComboboxRoot>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,aAAa,SAAmB,SAAA,YAAmB;EACzD,MAAM,OAAO;EAEb,MAAM,aAAa,YAAyB,YAAY;EAExD,SAAS,mBAAmB;GAC1B,eAAe;IACb,MAAM,UAAU,aAAa,UAAU;IACvC,IAAI,EAAE,mBAAmB,cAAc;IACvC,QAAQ,cAAgC,OAAO,CAAC,EAAE,MAAM;GAC1D,CAAC;EACH;EAEA,MAAM,EAAE,YAAY,MAAM,UAAU,SAAS,aAAa,eAAe,WAAW,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AAA,GAAA,SAAE,MAAA,aAAA,KAAA,MAAA,aAAA,CAAA,CAAA,GAAA,IAAA;QAEL,GAAA,gBAAA,MAAA,OAAA,IAAO,aAAA,mBAAA,GAAA,IAAA,UAAA,KAAA,mBAAA,QAAA,IAAA"}
@@ -2,6 +2,8 @@ import { LayerNode, LayerRow, LayerSelectionMode, LayerTreeVirtualizer } from ".
2
2
  //#region src/primitives/LayerTree/LayerTreeRoot.vue.d.ts
3
3
  type __VLS_Props = {
4
4
  indentPerLevel?: number;
5
+ /** Whether the tree selects more than one layer at a time; Reka announces it to assistive tech. */
6
+ multiple?: boolean;
5
7
  };
6
8
  declare function select(id: string, selection: boolean | LayerSelectionMode): void;
7
9
  declare function toggleExpand(id: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"LayerTreeRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/LayerTree/LayerTreeRoot.vue"],"mappings":";;KA0TK;EACH;;iBAkKO,OAAO,YAAY,qBAAqB;iBAwBxC,aAAa;iBAeb,eAAe,MAAM;YA4H1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IArHkB,aAAA;;;;KAsHjB;EACD,WAAW,cAAc;;cAKvB,0BAAU,gBAAA,2CAAA,qCAAA;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"LayerTreeRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/LayerTree/LayerTreeRoot.vue"],"mappings":";;KA6TK;EACH;;EAEA;;iBAkKO,OAAO,YAAY,qBAAqB;iBAwBxC,aAAa;iBAeb,eAAe,MAAM;YA8H1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAvHkB,aAAA;;;;KAwHjB;EACD,WAAW,cAAc;;cAKvB,0BAAU,gBAAA,2CAAA,qCAAA;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -7,7 +7,13 @@ import { TreeRoot } from "reka-ui";
7
7
  //#region src/primitives/LayerTree/LayerTreeRoot.vue
8
8
  const _sfc_main = /*@__PURE__*/ defineComponent({
9
9
  __name: "LayerTreeRoot",
10
- props: { indentPerLevel: { default: 16 } },
10
+ props: {
11
+ indentPerLevel: { default: 16 },
12
+ multiple: {
13
+ type: Boolean,
14
+ default: false
15
+ }
16
+ },
11
17
  emits: [
12
18
  "select",
13
19
  "toggleExpand",
@@ -216,7 +222,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
216
222
  class: "flex min-h-0 flex-1 flex-col overflow-hidden",
217
223
  items: items.value,
218
224
  "get-key": getKey,
219
- "get-children": getChildren
225
+ "get-children": getChildren,
226
+ multiple: __props.multiple
220
227
  }, {
221
228
  default: withCtx(({ flattenItems }) => [renderSlot(_ctx.$slots, "default", {
222
229
  items: items.value,
@@ -232,7 +239,11 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
232
239
  actions
233
240
  })]),
234
241
  _: 3
235
- }, 8, ["expanded", "items"]);
242
+ }, 8, [
243
+ "expanded",
244
+ "items",
245
+ "multiple"
246
+ ]);
236
247
  };
237
248
  }
238
249
  });
@@ -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 } = defineProps<{\n indentPerLevel?: number\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\nfunction syncCanvasScope(nodeId: string) {\n const node = editor.graph.getNode(nodeId)\n if (!node) return\n let parentId = node.parentId\n while (parentId && parentId !== editor.state.currentPageId) {\n if (editor.graph.isContainer(parentId)) {\n editor.enterContainer(parentId)\n return\n }\n const parent = editor.graph.getNode(parentId)\n parentId = parent?.parentId ?? null\n }\n editor.state.enteredContainerId = null\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 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 >\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":";;;;;;;;;;;;;;;;;;EAyBA,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,oBAAmC;EACvC,IAAI,oBAAoB;EAExB,SAAS,WAAW,IAAY;GAC9B,IAAI,CAAC,SAAS,MAAM,SAAS,EAAE,GAAG,SAAS,QAAQ,CAAC,GAAG,SA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A,MAAM,UAAU;GACd;GACA;GACA,aAAa,UAAmB;IAC9B,QAAQ,QAAQ;GAClB;GACA;EACF;EAEA,iBAAiB;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,YAsBW,MAAA,QAAA,GAAA;IApBD,UAAU,SAAA;IAAA,qBAAA,OAAA,OAAA,OAAA,MAAA,WAAA,SAAQ,QAAA;IAC1B,IAAG;IACH,OAAM;IACL,OAAO,MAAA;IACP,WAAS;IACT,gBAAc;;IAcb,SAAA,SAAA,EApBQ,mBAAY,CAQtB,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\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\nfunction syncCanvasScope(nodeId: string) {\n const node = editor.graph.getNode(nodeId)\n if (!node) return\n let parentId = node.parentId\n while (parentId && parentId !== editor.state.currentPageId) {\n if (editor.graph.isContainer(parentId)) {\n editor.enterContainer(parentId)\n return\n }\n const parent = editor.graph.getNode(parentId)\n parentId = parent?.parentId ?? null\n }\n editor.state.enteredContainerId = null\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 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,oBAAmC;EACvC,IAAI,oBAAoB;EAExB,SAAS,WAAW,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YAAY,MAAiB;GACpC,OAAO,KAAK;EACd;EAEA,SAAS,eAAe,MAA4B;GAClD,cAAc;EAChB;EAEA,MAAM,UAAU;GACd;GACA;GACA,aAAa,UAAmB;IAC9B,QAAQ,QAAQ;GAClB;GACA;EACF;EAEA,iBAAiB;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,8 +1,8 @@
1
1
  import { LAYER_OUTLINE_FIELDS } from "./context.js";
2
2
  import { toRaw } from "vue";
3
3
  import { isGeneratedFrame } from "@pairdraw/scene-graph/generated";
4
- import { isEqual, pick } from "es-toolkit";
5
4
  import { readIcon } from "@pairdraw/scene-graph/icons";
5
+ import { isEqual, pick } from "es-toolkit";
6
6
  import { slotPropertyId } from "@pairdraw/scene-graph/slots";
7
7
  //#region src/primitives/LayerTree/model.ts
8
8
  function explicitModeIds(node) {
@@ -1 +1 @@
1
- {"version":3,"file":"LayoutControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/LayoutControls/LayoutControlsRoot.vue"],"mappings":";;KA2EK,cAAc;cAwEb,0BAAU,kDAAA,qCAAA,iDAAA,aAAA,eAAA,oDAAA;cAEV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"LayoutControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/LayoutControls/LayoutControlsRoot.vue"],"mappings":";;KA4EK,cAAc;cAyEb,0BAAU,kDAAA,qCAAA,iDAAA,aAAA,eAAA,oDAAA;cAEV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -36,6 +36,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
36
36
  return renderSlot(_ctx.$slots, "default", {
37
37
  editor: unref(ctx).editor,
38
38
  node: unref(ctx).node.value,
39
+ resizes: unref(ctx).resizes.value,
39
40
  layoutDirection: unref(ctx).layoutDirection.value,
40
41
  gapAuto: unref(ctx).gapAuto.value,
41
42
  isInAutoLayout: unref(ctx).isInAutoLayout.value,
@@ -1 +1 @@
1
- {"version":3,"file":"LayoutControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/LayoutControls/LayoutControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { proxyRefs } from 'vue'\n\nimport { useLayout } from '#vue/controls/layout/use'\nimport { provideLayoutControls } from '#vue/primitives/LayoutControls/context'\nimport type { LayoutControlsRootSlots } from '#vue/primitives/LayoutControls/types'\n\nconst ctx = useLayout()\ndefineSlots<LayoutControlsRootSlots>()\nconst actions = {\n cancelPreview: ctx.cancelPreview,\n updateProp: ctx.updateProp,\n updateSizeLimit: ctx.updateSizeLimit,\n setSizeLimitToCurrent: ctx.setSizeLimitToCurrent,\n commitSizeLimit: ctx.commitSizeLimit,\n addSizeLimit: ctx.addSizeLimit,\n removeSizeLimit: ctx.removeSizeLimit,\n commitProp: ctx.commitProp,\n setAxisSizing: ctx.setAxisSizing,\n updateAxisSize: ctx.updateAxisSize,\n commitAxisSize: ctx.commitAxisSize,\n toggleAspectRatioLock: ctx.toggleAspectRatioLock,\n setHorizontalPadding: ctx.setHorizontalPadding,\n commitHorizontalPadding: ctx.commitHorizontalPadding,\n setVerticalPadding: ctx.setVerticalPadding,\n commitVerticalPadding: ctx.commitVerticalPadding,\n setAlignment: ctx.setAlignment,\n setGapAuto: ctx.setGapAuto,\n setLayoutDirection: ctx.setLayoutDirection,\n updateGridTrack: ctx.updateGridTrack,\n addTrack: ctx.addTrack,\n removeTrack: ctx.removeTrack,\n toggleIndividualPadding: ctx.toggleIndividualPadding\n}\nprovideLayoutControls(\n proxyRefs(ctx) as ReturnType<typeof proxyRefs<typeof ctx>> & {\n node: NonNullable<typeof ctx.node.value>\n }\n)\n</script>\n\n<template>\n <slot\n :editor=\"ctx.editor\"\n :node=\"ctx.node.value\"\n :layout-direction=\"ctx.layoutDirection.value\"\n :gap-auto=\"ctx.gapAuto.value\"\n :is-in-auto-layout=\"ctx.isInAutoLayout.value\"\n :is-grid=\"ctx.isGrid.value\"\n :is-flex=\"ctx.isFlex.value\"\n :width-sizing=\"ctx.widthSizing.value\"\n :height-sizing=\"ctx.heightSizing.value\"\n :width-sizing-options=\"ctx.widthSizingOptions.value\"\n :height-sizing-options=\"ctx.heightSizingOptions.value\"\n :aspect-ratio-locked=\"ctx.aspectRatioLocked.value\"\n :aspect-ratio-lockable=\"ctx.aspectRatioLockable.value\"\n :align-grid=\"ctx.alignGrid.value\"\n :show-individual-padding=\"ctx.showIndividualPadding.value\"\n :has-uniform-padding=\"ctx.hasUniformPadding.value\"\n :has-symmetric-padding=\"ctx.hasSymmetricPadding.value\"\n :track-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AAoB;IAC/C,WAAY,MAAA,GAAA,CAAG,CAAC,UAAU;IAC1B,uBAAyB,MAAA,GAAA,CAAG,CAAC,sBAAsB;IACnD,mBAAqB,MAAA,GAAA,CAAG,CAAC,kBAAkB;IAC3C,qBAAuB,MAAA,GAAA,CAAG,CAAC,oBAAoB;IAC/C,oBAAsB,MAAA,GAAA,CAAG,CAAC;IAC1B,YAAa,MAAA,GAAA,CAAG,CAAC;IACR"}
1
+ {"version":3,"file":"LayoutControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/LayoutControls/LayoutControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { proxyRefs } from 'vue'\n\nimport { useLayout } from '#vue/controls/layout/use'\nimport { provideLayoutControls } from '#vue/primitives/LayoutControls/context'\nimport type { LayoutControlsRootSlots } from '#vue/primitives/LayoutControls/types'\n\nconst ctx = useLayout()\ndefineSlots<LayoutControlsRootSlots>()\nconst actions = {\n cancelPreview: ctx.cancelPreview,\n updateProp: ctx.updateProp,\n updateSizeLimit: ctx.updateSizeLimit,\n setSizeLimitToCurrent: ctx.setSizeLimitToCurrent,\n commitSizeLimit: ctx.commitSizeLimit,\n addSizeLimit: ctx.addSizeLimit,\n removeSizeLimit: ctx.removeSizeLimit,\n commitProp: ctx.commitProp,\n setAxisSizing: ctx.setAxisSizing,\n updateAxisSize: ctx.updateAxisSize,\n commitAxisSize: ctx.commitAxisSize,\n toggleAspectRatioLock: ctx.toggleAspectRatioLock,\n setHorizontalPadding: ctx.setHorizontalPadding,\n commitHorizontalPadding: ctx.commitHorizontalPadding,\n setVerticalPadding: ctx.setVerticalPadding,\n commitVerticalPadding: ctx.commitVerticalPadding,\n setAlignment: ctx.setAlignment,\n setGapAuto: ctx.setGapAuto,\n setLayoutDirection: ctx.setLayoutDirection,\n updateGridTrack: ctx.updateGridTrack,\n addTrack: ctx.addTrack,\n removeTrack: ctx.removeTrack,\n toggleIndividualPadding: ctx.toggleIndividualPadding\n}\nprovideLayoutControls(\n proxyRefs(ctx) as ReturnType<typeof proxyRefs<typeof ctx>> & {\n node: NonNullable<typeof ctx.node.value>\n }\n)\n</script>\n\n<template>\n <slot\n :editor=\"ctx.editor\"\n :node=\"ctx.node.value\"\n :resizes=\"ctx.resizes.value\"\n :layout-direction=\"ctx.layoutDirection.value\"\n :gap-auto=\"ctx.gapAuto.value\"\n :is-in-auto-layout=\"ctx.isInAutoLayout.value\"\n :is-grid=\"ctx.isGrid.value\"\n :is-flex=\"ctx.isFlex.value\"\n :width-sizing=\"ctx.widthSizing.value\"\n :height-sizing=\"ctx.heightSizing.value\"\n :width-sizing-options=\"ctx.widthSizingOptions.value\"\n :height-sizing-options=\"ctx.heightSizingOptions.value\"\n :aspect-ratio-locked=\"ctx.aspectRatioLocked.value\"\n :aspect-ratio-lockable=\"ctx.aspectRatioLockable.value\"\n :align-grid=\"ctx.alignGrid.value\"\n :show-individual-padding=\"ctx.showIndividualPadding.value\"\n :has-uniform-padding=\"ctx.hasUniformPadding.value\"\n :has-symmetric-padding=\"ctx.hasSymmetricPadding.value\"\n :track-sizing-options=\"ctx.trackSizingOptions\"\n :track-label=\"ctx.trackLabel\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;EAOA,MAAM,MAAM,UAAU;EAEtB,MAAM,UAAU;GACd,eAAe,IAAI;GACnB,YAAY,IAAI;GAChB,iBAAiB,IAAI;GACrB,uBAAuB,IAAI;GAC3B,iBAAiB,IAAI;GACrB,cAAc,IAAI;GAClB,iBAAiB,IAAI;GACrB,YAAY,IAAI;GAChB,eAAe,IAAI;GACnB,gBAAgB,IAAI;GACpB,gBAAgB,IAAI;GACpB,uBAAuB,IAAI;GAC3B,sBAAsB,IAAI;GAC1B,yBAAyB,IAAI;GAC7B,oBAAoB,IAAI;GACxB,uBAAuB,IAAI;GAC3B,cAAc,IAAI;GAClB,YAAY,IAAI;GAChB,oBAAoB,IAAI;GACxB,iBAAiB,IAAI;GACrB,UAAU,IAAI;GACd,aAAa,IAAI;G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