@pairdraw/vue 0.17.0 → 0.19.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/dist/canvas/CanvasRoot.vue.js +4 -1
  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/kit-loader.js +22 -14
  13. package/dist/canvas/surface/kit-loader.js.map +1 -1
  14. package/dist/canvas/surface/lifecycle.js +41 -3
  15. package/dist/canvas/surface/lifecycle.js.map +1 -1
  16. package/dist/canvas/surface/resize-observer.js +11 -4
  17. package/dist/canvas/surface/resize-observer.js.map +1 -1
  18. package/dist/canvas/surface/types.d.ts +16 -0
  19. package/dist/canvas/surface/types.d.ts.map +1 -1
  20. package/dist/canvas/surface/use.d.ts +1 -0
  21. package/dist/canvas/surface/use.js +3 -1
  22. package/dist/canvas/surface/use.js.map +1 -1
  23. package/dist/canvas/text-edit/editing.js +11 -8
  24. package/dist/canvas/text-edit/editing.js.map +1 -1
  25. package/dist/canvas/text-edit/keyboard.js +12 -0
  26. package/dist/canvas/text-edit/keyboard.js.map +1 -1
  27. package/dist/canvas/useCanvasInput.d.ts +240 -0
  28. package/dist/controls/appearance/use.d.ts +1 -1
  29. package/dist/controls/layout/helpers.d.ts.map +1 -1
  30. package/dist/controls/layout/helpers.js +36 -7
  31. package/dist/controls/layout/helpers.js.map +1 -1
  32. package/dist/controls/layout/use.d.ts +1 -0
  33. package/dist/controls/layout/use.d.ts.map +1 -1
  34. package/dist/controls/layout/use.js +3 -0
  35. package/dist/controls/layout/use.js.map +1 -1
  36. package/dist/controls/node-preview/use.js +21 -1
  37. package/dist/controls/node-preview/use.js.map +1 -1
  38. package/dist/controls/position/use.d.ts +2 -1
  39. package/dist/controls/position/use.d.ts.map +1 -1
  40. package/dist/controls/position/use.js +13 -5
  41. package/dist/controls/position/use.js.map +1 -1
  42. package/dist/controls/property-list/use.d.ts.map +1 -1
  43. package/dist/controls/property-list/use.js +27 -5
  44. package/dist/controls/property-list/use.js.map +1 -1
  45. package/dist/controls/selection-layout/use.d.ts.map +1 -1
  46. package/dist/controls/selection-layout/use.js +3 -2
  47. package/dist/controls/selection-layout/use.js.map +1 -1
  48. package/dist/controls/slots/authoring.d.ts.map +1 -1
  49. package/dist/controls/slots/authoring.js +2 -1
  50. package/dist/controls/slots/authoring.js.map +1 -1
  51. package/dist/controls/typography/actions.js +18 -10
  52. package/dist/controls/typography/actions.js.map +1 -1
  53. package/dist/controls/typography/axes.d.ts.map +1 -1
  54. package/dist/controls/typography/axes.js +62 -19
  55. package/dist/controls/typography/axes.js.map +1 -1
  56. package/dist/editor/commands/registry.d.ts +1 -0
  57. package/dist/editor/commands/registry.d.ts.map +1 -1
  58. package/dist/editor/commands/registry.js +1 -0
  59. package/dist/editor/commands/registry.js.map +1 -1
  60. package/dist/editor/commands/selection.js +12 -3
  61. package/dist/editor/commands/selection.js.map +1 -1
  62. package/dist/editor/commands/types.d.ts +1 -1
  63. package/dist/editor/commands/types.d.ts.map +1 -1
  64. package/dist/editor/menu-model/canvas.js +5 -1
  65. package/dist/editor/menu-model/canvas.js.map +1 -1
  66. package/dist/editor/selection-capabilities/use.d.ts +1 -0
  67. package/dist/editor/selection-capabilities/use.js +4 -0
  68. package/dist/editor/selection-capabilities/use.js.map +1 -1
  69. package/dist/editor/selection-state/nodes.js +2 -2
  70. package/dist/editor/selection-state/nodes.js.map +1 -1
  71. package/dist/i18n/locale.d.ts.map +1 -1
  72. package/dist/i18n/locale.js +16 -6
  73. package/dist/i18n/locale.js.map +1 -1
  74. package/dist/i18n/locales/de/ai.json.js +9 -0
  75. package/dist/i18n/locales/de/automation.json.js +2 -0
  76. package/dist/i18n/locales/de/cloud/portal.json.js +1 -1
  77. package/dist/i18n/locales/de/commands.json.js +1 -0
  78. package/dist/i18n/locales/de/comments.json.js +1 -0
  79. package/dist/i18n/locales/de/diagnostics.json.js +1 -0
  80. package/dist/i18n/locales/de/editor.json.js +2 -2
  81. package/dist/i18n/locales/de/menu.json.js +1 -1
  82. package/dist/i18n/locales/de/variables/panel.json.js +2 -0
  83. package/dist/i18n/locales/es/ai.json.js +9 -0
  84. package/dist/i18n/locales/es/automation.json.js +2 -0
  85. package/dist/i18n/locales/es/cloud/portal.json.js +1 -1
  86. package/dist/i18n/locales/es/commands.json.js +1 -0
  87. package/dist/i18n/locales/es/comments.json.js +1 -0
  88. package/dist/i18n/locales/es/diagnostics.json.js +1 -0
  89. package/dist/i18n/locales/es/editor.json.js +2 -2
  90. package/dist/i18n/locales/es/menu.json.js +1 -1
  91. package/dist/i18n/locales/es/variables/panel.json.js +2 -0
  92. package/dist/i18n/locales/fr/ai.json.js +9 -0
  93. package/dist/i18n/locales/fr/automation.json.js +2 -0
  94. package/dist/i18n/locales/fr/cloud/portal.json.js +1 -1
  95. package/dist/i18n/locales/fr/commands.json.js +1 -0
  96. package/dist/i18n/locales/fr/comments.json.js +1 -0
  97. package/dist/i18n/locales/fr/diagnostics.json.js +1 -0
  98. package/dist/i18n/locales/fr/editor.json.js +2 -2
  99. package/dist/i18n/locales/fr/menu.json.js +1 -1
  100. package/dist/i18n/locales/fr/variables/panel.json.js +2 -0
  101. package/dist/i18n/locales/it/ai.json.js +9 -0
  102. package/dist/i18n/locales/it/automation.json.js +2 -0
  103. package/dist/i18n/locales/it/cloud/portal.json.js +1 -1
  104. package/dist/i18n/locales/it/commands.json.js +1 -0
  105. package/dist/i18n/locales/it/comments.json.js +1 -0
  106. package/dist/i18n/locales/it/diagnostics.json.js +1 -0
  107. package/dist/i18n/locales/it/editor.json.js +2 -2
  108. package/dist/i18n/locales/it/menu.json.js +1 -1
  109. package/dist/i18n/locales/it/variables/panel.json.js +2 -0
  110. package/dist/i18n/locales/ja/ai.json.js +9 -0
  111. package/dist/i18n/locales/ja/automation.json.js +2 -0
  112. package/dist/i18n/locales/ja/cloud/portal.json.js +1 -1
  113. package/dist/i18n/locales/ja/commands.json.js +1 -0
  114. package/dist/i18n/locales/ja/comments.json.js +1 -0
  115. package/dist/i18n/locales/ja/diagnostics.json.js +1 -0
  116. package/dist/i18n/locales/ja/editor.json.js +2 -2
  117. package/dist/i18n/locales/ja/menu.json.js +1 -1
  118. package/dist/i18n/locales/ja/variables/panel.json.js +2 -0
  119. package/dist/i18n/locales/pl/ai.json.js +9 -0
  120. package/dist/i18n/locales/pl/automation.json.js +2 -0
  121. package/dist/i18n/locales/pl/cloud/portal.json.js +1 -1
  122. package/dist/i18n/locales/pl/commands.json.js +1 -0
  123. package/dist/i18n/locales/pl/comments.json.js +1 -0
  124. package/dist/i18n/locales/pl/diagnostics.json.js +1 -0
  125. package/dist/i18n/locales/pl/editor.json.js +2 -2
  126. package/dist/i18n/locales/pl/menu.json.js +1 -1
  127. package/dist/i18n/locales/pl/variables/panel.json.js +2 -0
  128. package/dist/i18n/locales/ru/ai.json.js +9 -0
  129. package/dist/i18n/locales/ru/automation.json.js +2 -0
  130. package/dist/i18n/locales/ru/cloud/portal.json.js +1 -1
  131. package/dist/i18n/locales/ru/commands.json.js +1 -0
  132. package/dist/i18n/locales/ru/comments.json.js +1 -0
  133. package/dist/i18n/locales/ru/diagnostics.json.js +1 -0
  134. package/dist/i18n/locales/ru/editor.json.js +2 -2
  135. package/dist/i18n/locales/ru/menu.json.js +1 -1
  136. package/dist/i18n/locales/ru/variables/panel.json.js +2 -0
  137. package/dist/i18n/locales/zh-cn/ai.json.js +9 -0
  138. package/dist/i18n/locales/zh-cn/automation.json.js +2 -0
  139. package/dist/i18n/locales/zh-cn/cloud/portal.json.js +1 -1
  140. package/dist/i18n/locales/zh-cn/commands.json.js +1 -0
  141. package/dist/i18n/locales/zh-cn/comments.json.js +1 -0
  142. package/dist/i18n/locales/zh-cn/diagnostics.json.js +1 -0
  143. package/dist/i18n/locales/zh-cn/editor.json.js +2 -2
  144. package/dist/i18n/locales/zh-cn/menu.json.js +1 -1
  145. package/dist/i18n/locales/zh-cn/variables/panel.json.js +2 -0
  146. package/dist/i18n/messages/ai.d.ts +20 -0
  147. package/dist/i18n/messages/ai.d.ts.map +1 -1
  148. package/dist/i18n/messages/ai.js +10 -0
  149. package/dist/i18n/messages/ai.js.map +1 -1
  150. package/dist/i18n/messages/automation.d.ts +2 -0
  151. package/dist/i18n/messages/automation.d.ts.map +1 -1
  152. package/dist/i18n/messages/automation.js +2 -0
  153. package/dist/i18n/messages/automation.js.map +1 -1
  154. package/dist/i18n/messages/cloud/portal.d.ts +1 -1
  155. package/dist/i18n/messages/cloud/portal.js +1 -1
  156. package/dist/i18n/messages/cloud/portal.js.map +1 -1
  157. package/dist/i18n/messages/commands.d.ts +1 -0
  158. package/dist/i18n/messages/commands.d.ts.map +1 -1
  159. package/dist/i18n/messages/commands.js +1 -0
  160. package/dist/i18n/messages/commands.js.map +1 -1
  161. package/dist/i18n/messages/comments.d.ts +1 -0
  162. package/dist/i18n/messages/comments.d.ts.map +1 -1
  163. package/dist/i18n/messages/comments.js +1 -0
  164. package/dist/i18n/messages/comments.js.map +1 -1
  165. package/dist/i18n/messages/diagnostics.d.ts +1 -0
  166. package/dist/i18n/messages/diagnostics.d.ts.map +1 -1
  167. package/dist/i18n/messages/diagnostics.js +1 -0
  168. package/dist/i18n/messages/diagnostics.js.map +1 -1
  169. package/dist/i18n/messages/editor.d.ts +1 -1
  170. package/dist/i18n/messages/editor.js +1 -1
  171. package/dist/i18n/messages/editor.js.map +1 -1
  172. package/dist/i18n/messages/menu.d.ts +1 -1
  173. package/dist/i18n/messages/menu.js +1 -1
  174. package/dist/i18n/messages/menu.js.map +1 -1
  175. package/dist/i18n/messages/panels.d.ts +1 -1
  176. package/dist/i18n/messages/panels.js +1 -1
  177. package/dist/i18n/messages/panels.js.map +1 -1
  178. package/dist/i18n/messages/variables/panel.d.ts +2 -0
  179. package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
  180. package/dist/i18n/messages/variables/panel.js +2 -0
  181. package/dist/i18n/messages/variables/panel.js.map +1 -1
  182. package/dist/i18n/messages.d.ts +30 -4
  183. package/dist/i18n/useI18n.d.ts +116 -14
  184. package/dist/i18n/useI18n.d.ts.map +1 -1
  185. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +12 -2
  186. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
  187. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +39 -10
  188. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
  189. package/dist/primitives/ColorPicker/gesture.d.ts +40 -0
  190. package/dist/primitives/ColorPicker/gesture.d.ts.map +1 -0
  191. package/dist/primitives/ColorPicker/gesture.js +120 -0
  192. package/dist/primitives/ColorPicker/gesture.js.map +1 -0
  193. package/dist/primitives/ColorPicker/index.d.ts +2 -1
  194. package/dist/primitives/ColorPicker/index.js +2 -1
  195. package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
  196. package/dist/primitives/Fill/FillSwatch.vue.js +6 -1
  197. package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
  198. package/dist/primitives/Fill/types.d.ts +5 -0
  199. package/dist/primitives/Fill/types.d.ts.map +1 -1
  200. package/dist/primitives/Fill/useFill.d.ts.map +1 -1
  201. package/dist/primitives/Fill/useFill.js +15 -7
  202. package/dist/primitives/Fill/useFill.js.map +1 -1
  203. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +1 -0
  204. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
  205. package/dist/primitives/FontPicker/FontPickerRoot.vue.js +7 -2
  206. package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
  207. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +2 -0
  208. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
  209. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +14 -3
  210. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
  211. package/dist/primitives/LayerTree/model.js +1 -1
  212. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.d.ts.map +1 -1
  213. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js +1 -0
  214. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js.map +1 -1
  215. package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts +2 -2
  216. package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts.map +1 -1
  217. package/dist/primitives/NumberField/NumberFieldRoot.vue.js +3 -2
  218. package/dist/primitives/NumberField/NumberFieldRoot.vue.js.map +1 -1
  219. package/dist/primitives/NumberField/types.d.ts +5 -0
  220. package/dist/primitives/NumberField/types.d.ts.map +1 -1
  221. package/dist/primitives/PageList/PageListRoot.vue.d.ts +3 -3
  222. package/dist/primitives/PageList/PageListRoot.vue.d.ts.map +1 -1
  223. package/dist/primitives/PageList/PageListRoot.vue.js +3 -2
  224. package/dist/primitives/PageList/PageListRoot.vue.js.map +1 -1
  225. package/dist/primitives/PageList/usePageList.d.ts +1 -1
  226. package/dist/primitives/PageList/usePageList.d.ts.map +1 -1
  227. package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts +1 -0
  228. package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts.map +1 -1
  229. package/dist/primitives/PositionControls/PositionControlsRoot.vue.js +11 -13
  230. package/dist/primitives/PositionControls/PositionControlsRoot.vue.js.map +1 -1
  231. package/dist/primitives/PropertyList/PropertyListRoot.vue.d.ts.map +1 -1
  232. package/dist/primitives/PropertyList/PropertyListRoot.vue.js +10 -1
  233. package/dist/primitives/PropertyList/PropertyListRoot.vue.js.map +1 -1
  234. package/dist/primitives/PropertyList/index.d.ts +2 -2
  235. package/dist/primitives/PropertyList/types.d.ts +14 -2
  236. package/dist/primitives/PropertyList/types.d.ts.map +1 -1
  237. package/dist/shared/input/drop-target.js +2 -1
  238. package/dist/shared/input/drop-target.js.map +1 -1
  239. package/dist/shared/input/duplicate-drag.js.map +1 -1
  240. package/dist/shared/input/move/drag.js +25 -4
  241. package/dist/shared/input/move/drag.js.map +1 -1
  242. package/dist/shared/input/resize/start.js +2 -1
  243. package/dist/shared/input/resize/start.js.map +1 -1
  244. package/dist/shared/input/select/move.js +8 -3
  245. package/dist/shared/input/select/move.js.map +1 -1
  246. package/dist/shared/input/select.js +22 -12
  247. package/dist/shared/input/select.js.map +1 -1
  248. package/dist/shared/input/types.d.ts +2 -0
  249. package/dist/shared/input/types.d.ts.map +1 -1
  250. package/dist/shared/input/types.js.map +1 -1
  251. package/dist/variables/use.d.ts.map +1 -1
  252. package/dist/variables/use.js +2 -1
  253. package/dist/variables/use.js.map +1 -1
  254. package/package.json +4 -4
@@ -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"],"mapp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A,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=\"inst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AA;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-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;GACjB,yBAAyB,IAAI;EAC/B;EACA,sBACE,UAAU,GAAG,CAGf;;GAIE,OAAA,WAqBE,KAAA,QAAA,WAAA;IApBC,QAAQ,MAAA,GAAA,CAAG,CAAC;IACZ,MAAM,MAAA,GAAA,CAAG,CAAC,KAAK;IACf,iBAAkB,MAAA,GAAA,CAAG,CAAC,gBAAgB;IACtC,SAAU,MAAA,GAAA,CAAG,CAAC,QAAQ;IACtB,gBAAmB,MAAA,GAAA,CAAG,CAAC,eAAe;IACtC,QAAS,MAAA,GAAA,CAAG,CAAC,OAAO;IACpB,QAAS,MAAA,GAAA,CAAG,CAAC,OAAO;IACpB,aAAc,MAAA,GAAA,CAAG,CAAC,YAAY;IAC9B,cAAe,MAAA,GAAA,CAAG,CAAC,aAAa;IAChC,oBAAsB,MAAA,GAAA,CAAG,CAAC,mBAAmB;IAC7C,qBAAuB,MAAA,GAAA,CAAG,CAAC,oBAAoB;IAC/C,mBAAqB,MAAA,GAAA,CAAG,CAAC,kBAAkB;IAC3C,qBAAuB,MAAA,GAAA,CAAG,CAAC,oBAAoB;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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;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"}
@@ -6,16 +6,16 @@ declare const __VLS_base: import("vue").DefineComponent<NumberFieldRootProps, {}
6
6
  invalid: (expression: string, reason: NumberExpressionError) => any;
7
7
  cancel: () => any;
8
8
  "update:modelValue": (value: number, unit?: string | undefined) => any;
9
+ commit: (value: number, previous: number, unit?: string | undefined) => any;
9
10
  "editing-change": (editing: boolean) => any;
10
11
  "detach-request": (source: NumberFieldMutationSource) => any;
11
- commit: (value: number, previous: number, unit?: string | undefined) => any;
12
12
  }, string, import("vue").PublicProps, Readonly<NumberFieldRootProps> & Readonly<{
13
13
  onInvalid?: ((expression: string, reason: NumberExpressionError) => any) | undefined;
14
14
  onCancel?: (() => any) | undefined;
15
15
  "onUpdate:modelValue"?: ((value: number, unit?: string | undefined) => any) | undefined;
16
+ onCommit?: ((value: number, previous: number, unit?: string | undefined) => any) | undefined;
16
17
  "onEditing-change"?: ((editing: boolean) => any) | undefined;
17
18
  "onDetach-request"?: ((source: NumberFieldMutationSource) => any) | undefined;
18
- onCommit?: ((value: number, previous: number, unit?: string | undefined) => any) | undefined;
19
19
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
20
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
21
21
  declare const _default: typeof __VLS_export;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberFieldRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/NumberField/NumberFieldRoot.vue"],"mappings":";;;KAwfK,cAAc;cAkbb,0BAAU,gBAAA,oDAAA,qCAAA;;;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"NumberFieldRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/NumberField/NumberFieldRoot.vue"],"mappings":";;;KA4fK,cAAc;cAobb,0BAAU,gBAAA,oDAAA,qCAAA;;;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -29,7 +29,8 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
29
29
  default: false
30
30
  },
31
31
  editPolicy: { default: "editable" },
32
- units: { default: () => [] }
32
+ units: { default: () => [] },
33
+ round: { type: Function }
33
34
  },
34
35
  emits: [
35
36
  "update:modelValue",
@@ -53,7 +54,7 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
53
54
  const isMixed = computed(() => binding?.state.value === "mixed" || typeof __props.modelValue === "symbol");
54
55
  const numericValue = computed(() => {
55
56
  const resolved = binding?.resolvedValue.value;
56
- if (binding?.state.value === "bound" && typeof resolved === "number") return resolved;
57
+ if (binding?.state.value === "bound" && typeof resolved === "number") return __props.round ? __props.round(resolved) : resolved;
57
58
  return typeof __props.modelValue === "number" ? __props.modelValue : 0;
58
59
  });
59
60
  const displayValue = computed(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"NumberFieldRoot.vue.js","names":[],"sources":["../../../src/primitives/NumberField/NumberFieldRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useEventListener, watchImmediate } from '@vueuse/core'\nimport { computed, nextTick, onBeforeUnmount, onDeactivated, ref, watch } from 'vue'\n\nimport {\n clampNumberValue,\n evaluateNumberExpression,\n normalizeNumberValue,\n stepNumberValue\n} from '#vue/controls/number-expression'\nimport type { NumberExpressionError } from '#vue/controls/number-expression'\nimport { useRetainedActivity } from '#vue/lifecycle/retention/context'\nimport { useOptionalBindableValue } from '#vue/primitives/BindableValue/context'\nimport { provideNumberField } from '#vue/primitives/NumberField/context'\nimport type {\n NumberFieldActions,\n NumberFieldEditPolicy,\n NumberFieldMutationSource,\n NumberFieldRootAttrs,\n NumberFieldRootEmits,\n NumberFieldRootProps,\n NumberFieldRootSlots,\n NumberFieldSlotProps,\n NumberFieldState,\n NumberFieldStateAttrs\n} from '#vue/primitives/NumberField/types'\nimport { inputValue } from '#vue/shared/dom-events'\n\nconst {\n modelValue,\n min = -Infinity,\n max = Infinity,\n step = 1,\n sensitivity = 1,\n inheritBinding = true,\n placeholder = 'Mixed',\n ariaLabel,\n disabled: disabledProp = false,\n bound: boundProp = false,\n editPolicy = 'editable',\n units = []\n} = defineProps<NumberFieldRootProps>()\nconst emit = defineEmits<NumberFieldRootEmits>()\ndefineSlots<NumberFieldRootSlots>()\n\nconst retainedActivity = useRetainedActivity()\nconst enclosingBinding = useOptionalBindableValue<number>()\nconst binding = inheritBinding ? enclosingBinding : undefined\nconst editing = ref(false)\nconst scrubbing = ref(false)\nconst draftValue = ref('')\nconst inputRef = ref<HTMLInputElement | null>(null)\nconst invalidReason = ref<NumberExpressionError | null>(null)\nconst workingValue = ref(0)\n\nconst isMixed = computed(() => binding?.state.value === 'mixed' || typeof modelValue === 'symbol')\nconst numericValue = computed(() => {\n const resolved = binding?.resolvedValue.value\n if (binding?.state.value === 'bound' && typeof resolved === 'number') return resolved\n return typeof modelValue === 'number' ? modelValue : 0\n})\nconst displayValue = computed(() => {\n if (binding?.state.value === 'unresolved') return '—'\n return isMixed.value ? '' : String(normalizeNumberValue(numericValue.value))\n})\nconst disabled = computed(() => disabledProp)\nconst bound = computed(() =>\n binding ? binding.state.value === 'bound' || binding.state.value === 'unresolved' : boundProp\n)\nconst effectiveEditPolicy = computed<NumberFieldEditPolicy>(() => {\n if (!binding) return editPolicy\n if (binding.policy.value === 'readonly-when-bound') return 'readonly'\n if (binding.policy.value === 'detach-on-edit') return 'detach-on-edit'\n return 'editable'\n})\nconst minValue = computed(() => min)\nconst maxValue = computed(() => max)\nconst stepValue = computed(() => (Number.isFinite(step) && step > 0 ? step : 1))\nconst ariaLabelValue = computed(() => ariaLabel)\n\nlet interactionStartValue = 0\nlet interactionStartedMixed = false\nlet mutationRequested = false\n/**\n * The draft the field itself last wrote, on focus or with the arrow keys, whose value is already\n * absolute: `-1` there is not \"minus 1\". A draft the user types is an expression.\n */\nlet absoluteDraft: string | null = null\nlet stopMove: (() => void) | undefined\nlet stopUp: (() => void) | undefined\nlet stopCancel: (() => void) | undefined\nlet scrubTarget: Element | undefined\nlet scrubPointerId: number | undefined\n\nfunction canMutate(): boolean {\n if (binding?.state.value === 'unresolved') return false\n return !disabled.value && !(bound.value && effectiveEditPolicy.value === 'readonly')\n}\n\nfunction requestMutation(source: NumberFieldMutationSource): boolean {\n if (mutationRequested) return true\n if (!canMutate()) return false\n if (binding && !binding.actions.beginMutation(source)) return false\n if (!binding && bound.value && effectiveEditPolicy.value === 'detach-on-edit') {\n emit('detach-request', source)\n }\n mutationRequested = true\n return true\n}\n\nfunction beginInteraction() {\n interactionStartValue = numericValue.value\n interactionStartedMixed = isMixed.value\n workingValue.value = numericValue.value\n mutationRequested = false\n absoluteDraft = null\n invalidReason.value = null\n}\n\n/** Shows `value` live, in the unit typed after it when there is one. */\nfunction updateValue(value: number, unit?: string) {\n const normalized = normalizeNumberValue(clampNumberValue(value, min, max))\n workingValue.value = normalized\n if (binding?.actions.applyValue(normalized)) return\n if (modelValue !== normalized || unit) emit('update:modelValue', normalized, unit)\n}\n\nfunction restoreInteractionValue() {\n if (!mutationRequested) return\n if (workingValue.value !== interactionStartValue || interactionStartedMixed !== isMixed.value) {\n workingValue.value = interactionStartValue\n if (!binding?.actions.applyValue(interactionStartValue)) {\n emit('update:modelValue', interactionStartValue)\n }\n }\n}\n\nfunction finishCommit(value: number, unit?: string) {\n updateValue(value, unit)\n editing.value = false\n if (\n mutationRequested ||\n workingValue.value !== interactionStartValue ||\n interactionStartedMixed\n ) {\n emit('commit', workingValue.value, interactionStartValue, unit)\n }\n binding?.actions.commitMutation()\n}\n\nfunction startEdit() {\n if (editing.value || !canMutate()) return\n beginInteraction()\n draftValue.value = interactionStartedMixed ? '' : String(interactionStartValue)\n // A mixed field's empty draft stays an expression, which Enter rejects.\n absoluteDraft = interactionStartedMixed ? null : draftValue.value\n editing.value = true\n void nextTick(() => {\n inputRef.value?.focus()\n inputRef.value?.select()\n })\n}\n\nfunction setDraft(value: string) {\n if (value !== draftValue.value && !requestMutation('edit')) return\n draftValue.value = value\n const absoluteNumber = /^\\s*(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?\\s*$/i.test(value)\n if (absoluteNumber) updateValue(Number(value))\n}\n\nfunction onInput(event: Event) {\n setDraft(inputValue(event))\n}\n\n/** The typed expression without a unit from `units` it ends with, and that unit. */\nfunction splitUnit(expression: string): { value: string; unit?: string } {\n const source = expression.trim()\n const unit = [...units]\n .sort((a, b) => b.length - a.length)\n .find((candidate) => source.toLowerCase().endsWith(candidate.toLowerCase()))\n return unit ? { value: source.slice(0, -unit.length), unit } : { value: source }\n}\n\nfunction commitEdit() {\n if (!editing.value) return\n const expression = draftValue.value\n const { value, unit } = splitUnit(expression)\n if (expression === absoluteDraft) {\n finishCommit(workingValue.value, unit)\n return\n }\n const result = evaluateNumberExpression(value, {\n current: interactionStartValue,\n max,\n mixed: interactionStartedMixed\n })\n if (!result.ok) {\n invalidReason.value = result.error\n restoreInteractionValue()\n editing.value = false\n binding?.actions.cancelMutation()\n emit('cancel')\n emit('invalid', expression, result.error)\n return\n }\n finishCommit(result.value, unit)\n}\n\nfunction cancelEdit() {\n if (!editing.value) return\n restoreInteractionValue()\n invalidReason.value = null\n editing.value = false\n binding?.actions.cancelMutation()\n emit('cancel')\n}\n\nfunction stopScrubListeners() {\n stopMove?.()\n stopUp?.()\n stopCancel?.()\n stopMove = undefined\n stopUp = undefined\n stopCancel = undefined\n if (scrubTarget && scrubPointerId != null && scrubTarget.hasPointerCapture(scrubPointerId)) {\n scrubTarget.releasePointerCapture(scrubPointerId)\n }\n scrubTarget = undefined\n scrubPointerId = undefined\n if (typeof document !== 'undefined') document.body.style.cursor = ''\n}\n\nfunction startScrub(event: PointerEvent) {\n if (!canMutate()) return\n event.preventDefault()\n beginInteraction()\n\n const startX = event.clientX\n let lastX = startX\n const startValue = numericValue.value\n let accumulated = startValue\n let hasMoved = false\n const target = event.currentTarget instanceof Element ? event.currentTarget : undefined\n scrubTarget = target\n scrubPointerId = event.pointerId\n target?.setPointerCapture(event.pointerId)\n const listenerTarget = target ?? document\n\n stopMove = useEventListener(listenerTarget, 'pointermove', (moveEvent: PointerEvent) => {\n if (moveEvent.pointerId !== event.pointerId) return\n const dx = moveEvent.clientX - lastX\n lastX = moveEvent.clientX\n if (!hasMoved && Math.abs(moveEvent.clientX - startX) > 2) {\n if (!requestMutation('scrub')) return\n hasMoved = true\n scrubbing.value = true\n document.body.style.cursor = 'ew-resize'\n }\n if (!hasMoved) return\n accumulated += dx * stepValue.value * sensitivity\n // Pointer movement is fractional on high-density screens; the value moves in whole steps.\n const steps = Math.round((accumulated - startValue) / stepValue.value)\n updateValue(startValue + steps * stepValue.value)\n })\n\n const finish = (cancelled: boolean) => {\n stopScrubListeners()\n scrubbing.value = false\n if (cancelled) {\n restoreInteractionValue()\n binding?.actions.cancelMutation()\n emit('cancel')\n return\n }\n if (!hasMoved) {\n startEdit()\n return\n }\n emit('commit', workingValue.value, interactionStartValue)\n binding?.actions.commitMutation()\n }\n\n stopUp = useEventListener(listenerTarget, 'pointerup', (upEvent: PointerEvent) => {\n if (upEvent.pointerId === event.pointerId) finish(false)\n })\n stopCancel = useEventListener(listenerTarget, 'pointercancel', (cancelEvent: PointerEvent) => {\n if (cancelEvent.pointerId === event.pointerId) finish(true)\n })\n}\n\nfunction stepValueFromKeyboard(event: KeyboardEvent) {\n if (event.code !== 'ArrowUp' && event.code !== 'ArrowDown') return false\n if (!editing.value) beginInteraction()\n if (!requestMutation('step')) return true\n event.preventDefault()\n\n // A unit typed after the value stays on it, for the commit to report.\n const draft = editing.value ? splitUnit(draftValue.value) : undefined\n const draftResult =\n draft && draftValue.value !== absoluteDraft\n ? evaluateNumberExpression(draft.value, {\n current: interactionStartValue,\n max,\n mixed: interactionStartedMixed\n })\n : undefined\n const base = draftResult?.ok ? draftResult.value : workingValue.value\n const next = stepNumberValue(\n base,\n event.code === 'ArrowUp' ? 1 : -1,\n stepValue.value,\n event,\n min,\n max\n )\n updateValue(next, draft?.unit)\n draftValue.value = `${next}${draft?.unit ?? ''}`\n absoluteDraft = draftValue.value\n\n if (!editing.value) {\n emit('commit', next, interactionStartValue)\n binding?.actions.commitMutation()\n }\n return true\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (stepValueFromKeyboard(event)) return\n if (event.code === 'Enter') {\n event.preventDefault()\n commitEdit()\n } else if (event.code === 'Escape') {\n event.preventDefault()\n cancelEdit()\n }\n}\n\nconst state = computed<NumberFieldState>(() => ({\n editing: editing.value,\n scrubbing: scrubbing.value,\n mixed: isMixed.value,\n disabled: disabled.value,\n bound: bound.value\n}))\n\nconst stateAttrs = computed<NumberFieldStateAttrs>(() => ({\n 'data-editing': editing.value ? '' : undefined,\n 'data-scrubbing': scrubbing.value ? '' : undefined,\n 'data-mixed': isMixed.value ? '' : undefined,\n 'data-disabled': disabled.value ? '' : undefined,\n 'data-bound': bound.value ? '' : undefined\n}))\n\nconst rootTabindex = computed<0 | -1 | undefined>(() => {\n if (editing.value) return undefined\n return disabled.value ? -1 : 0\n})\n\nconst rootAttrs = computed<NumberFieldRootAttrs>(() => ({\n ...stateAttrs.value,\n role: editing.value ? undefined : 'spinbutton',\n tabindex: rootTabindex.value,\n 'aria-valuenow':\n editing.value || isMixed.value || binding?.state.value === 'unresolved'\n ? undefined\n : numericValue.value,\n 'aria-readonly': binding?.state.value === 'unresolved' ? true : undefined,\n 'aria-valuemin': !editing.value && Number.isFinite(min) ? min : undefined,\n 'aria-valuemax': !editing.value && Number.isFinite(max) ? max : undefined,\n 'aria-disabled': !editing.value && disabled.value ? 'true' : undefined,\n 'aria-label': editing.value ? undefined : ariaLabel,\n onFocus: startEdit,\n onKeydown\n}))\n\nconst actions: NumberFieldActions = {\n startScrub,\n startEdit,\n cancelEdit,\n commitEdit,\n setDraft,\n input: onInput,\n keydown: onKeydown\n}\n\nconst slotProps = computed<NumberFieldSlotProps>(() => ({\n modelValue,\n displayValue: displayValue.value,\n draftValue: draftValue.value,\n isMixed: isMixed.value,\n placeholder,\n ...state.value,\n state: state.value,\n attrs: rootAttrs.value,\n actions\n}))\n\nprovideNumberField({\n modelValue: computed(() => modelValue),\n numericValue,\n displayValue,\n draftValue,\n isMixed,\n editing,\n scrubbing,\n disabled,\n bound,\n min: minValue,\n max: maxValue,\n step: stepValue,\n ariaLabel: ariaLabelValue,\n inputRef,\n state,\n stateAttrs,\n rootAttrs,\n slotProps,\n actions,\n invalidReason\n})\n\nwatch(editing, (value) => emit('editing-change', value))\nwatch(\n () => modelValue,\n (value) => {\n if (!editing.value && !scrubbing.value && typeof value === 'number') workingValue.value = value\n },\n { immediate: true }\n)\n\nfunction cancelDetachedInteraction() {\n stopScrubListeners()\n if (editing.value || scrubbing.value) {\n restoreInteractionValue()\n editing.value = false\n scrubbing.value = false\n binding?.actions.cancelMutation()\n emit('cancel')\n }\n}\n\n// Cancel before KeepAlive moves a focused input: detachment can synchronously\n// fire blur, which must not commit the draft before onDeactivated runs.\nwatchImmediate(\n () => retainedActivity?.value ?? true,\n (active) => {\n if (!active) cancelDetachedInteraction()\n },\n { flush: 'sync' }\n)\nonBeforeUnmount(cancelDetachedInteraction)\nonDeactivated(cancelDetachedInteraction)\n</script>\n\n<template>\n <slot v-bind=\"slotProps\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,OAAO;EAGb,MAAM,mBAAmB,oBAAoB;EAC7C,MAAM,mBAAmB,yBAAiC;EA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Y,QAAA;GAC1C,SAAS;GACT;EACF,EAAE;EAEF,MAAM,UAA8B;GAClC;GACA;GACA;GACA;GACA;GACA,OAAO;GACP,SAAS;EACX;EAEA,MAAM,YAAY,gBAAsC;GACtD,YAAS,QAAA;GACT,cAAc,aAAa;GAC3B,YAAY,WAAW;GACvB,SAAS,QAAQ;GACjB,aAAU,QAAA;GACV,GAAG,MAAM;GACT,OAAO,MAAM;GACb,OAAO,UAAU;GACjB;EACF,EAAE;EAEF,mBAAmB;GACjB,YAAY,eAAe,QAAA,UAAU;GACrC;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,KAAK;GACL,KAAK;GACL,MAAM;GACN,WAAW;GACX;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EAED,MAAM,UAAU,UAAU,KAAK,kBAAkB,KAAK,CAAC;EACvD,YACQ,QAAA,aACL,UAAU;GACT,IAAI,CAAC,QAAQ,SAAS,CAAC,UAAU,SAAS,OAAO,UAAU,UAAU,aAAa,QAAQ;EAC5F,GACA,EAAE,WAAW,KAAK,CACpB;EAEA,SAAS,4BAA4B;GACnC,mBAAmB;GACnB,IAAI,QAAQ,SAAS,UAAU,OAAO;IACpC,wBAAwB;IACxB,QAAQ,QAAQ;IAChB,UAAU,QAAQ;IAClB,SAAS,QAAQ,eAAe;IAChC,KAAK,QAAQ;GACf;EACF;EAIA,qBACQ,kBAAkB,SAAS,OAChC,WAAW;GACV,IAAI,CAAC,QAAQ,0BAA0B;EACzC,GACA,EAAE,OAAO,OAAO,CAClB;EACA,gBAAgB,yBAAyB;EACzC,cAAc,yBAAyB;;GAIrC,OAAA,WAA2B,KAAA,QAAA,WAAA,eAAA,mBAAb,UAAA,KAAS,CAAA,CAAA"}
1
+ {"version":3,"file":"NumberFieldRoot.vue.js","names":[],"sources":["../../../src/primitives/NumberField/NumberFieldRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useEventListener, watchImmediate } from '@vueuse/core'\nimport { computed, nextTick, onBeforeUnmount, onDeactivated, ref, watch } from 'vue'\n\nimport {\n clampNumberValue,\n evaluateNumberExpression,\n normalizeNumberValue,\n stepNumberValue\n} from '#vue/controls/number-expression'\nimport type { NumberExpressionError } from '#vue/controls/number-expression'\nimport { useRetainedActivity } from '#vue/lifecycle/retention/context'\nimport { useOptionalBindableValue } from '#vue/primitives/BindableValue/context'\nimport { provideNumberField } from '#vue/primitives/NumberField/context'\nimport type {\n NumberFieldActions,\n NumberFieldEditPolicy,\n NumberFieldMutationSource,\n NumberFieldRootAttrs,\n NumberFieldRootEmits,\n NumberFieldRootProps,\n NumberFieldRootSlots,\n NumberFieldSlotProps,\n NumberFieldState,\n NumberFieldStateAttrs\n} from '#vue/primitives/NumberField/types'\nimport { inputValue } from '#vue/shared/dom-events'\n\nconst {\n modelValue,\n min = -Infinity,\n max = Infinity,\n step = 1,\n sensitivity = 1,\n inheritBinding = true,\n placeholder = 'Mixed',\n ariaLabel,\n disabled: disabledProp = false,\n bound: boundProp = false,\n editPolicy = 'editable',\n units = [],\n round\n} = defineProps<NumberFieldRootProps>()\nconst emit = defineEmits<NumberFieldRootEmits>()\ndefineSlots<NumberFieldRootSlots>()\n\nconst retainedActivity = useRetainedActivity()\nconst enclosingBinding = useOptionalBindableValue<number>()\nconst binding = inheritBinding ? enclosingBinding : undefined\nconst editing = ref(false)\nconst scrubbing = ref(false)\nconst draftValue = ref('')\nconst inputRef = ref<HTMLInputElement | null>(null)\nconst invalidReason = ref<NumberExpressionError | null>(null)\nconst workingValue = ref(0)\n\nconst isMixed = computed(() => binding?.state.value === 'mixed' || typeof modelValue === 'symbol')\nconst numericValue = computed(() => {\n const resolved = binding?.resolvedValue.value\n if (binding?.state.value === 'bound' && typeof resolved === 'number') {\n return round ? round(resolved) : resolved\n }\n return typeof modelValue === 'number' ? modelValue : 0\n})\nconst displayValue = computed(() => {\n if (binding?.state.value === 'unresolved') return '—'\n return isMixed.value ? '' : String(normalizeNumberValue(numericValue.value))\n})\nconst disabled = computed(() => disabledProp)\nconst bound = computed(() =>\n binding ? binding.state.value === 'bound' || binding.state.value === 'unresolved' : boundProp\n)\nconst effectiveEditPolicy = computed<NumberFieldEditPolicy>(() => {\n if (!binding) return editPolicy\n if (binding.policy.value === 'readonly-when-bound') return 'readonly'\n if (binding.policy.value === 'detach-on-edit') return 'detach-on-edit'\n return 'editable'\n})\nconst minValue = computed(() => min)\nconst maxValue = computed(() => max)\nconst stepValue = computed(() => (Number.isFinite(step) && step > 0 ? step : 1))\nconst ariaLabelValue = computed(() => ariaLabel)\n\nlet interactionStartValue = 0\nlet interactionStartedMixed = false\nlet mutationRequested = false\n/**\n * The draft the field itself last wrote, on focus or with the arrow keys, whose value is already\n * absolute: `-1` there is not \"minus 1\". A draft the user types is an expression.\n */\nlet absoluteDraft: string | null = null\nlet stopMove: (() => void) | undefined\nlet stopUp: (() => void) | undefined\nlet stopCancel: (() => void) | undefined\nlet scrubTarget: Element | undefined\nlet scrubPointerId: number | undefined\n\nfunction canMutate(): boolean {\n if (binding?.state.value === 'unresolved') return false\n return !disabled.value && !(bound.value && effectiveEditPolicy.value === 'readonly')\n}\n\nfunction requestMutation(source: NumberFieldMutationSource): boolean {\n if (mutationRequested) return true\n if (!canMutate()) return false\n if (binding && !binding.actions.beginMutation(source)) return false\n if (!binding && bound.value && effectiveEditPolicy.value === 'detach-on-edit') {\n emit('detach-request', source)\n }\n mutationRequested = true\n return true\n}\n\nfunction beginInteraction() {\n interactionStartValue = numericValue.value\n interactionStartedMixed = isMixed.value\n workingValue.value = numericValue.value\n mutationRequested = false\n absoluteDraft = null\n invalidReason.value = null\n}\n\n/** Shows `value` live, in the unit typed after it when there is one. */\nfunction updateValue(value: number, unit?: string) {\n const normalized = normalizeNumberValue(clampNumberValue(value, min, max))\n workingValue.value = normalized\n if (binding?.actions.applyValue(normalized)) return\n if (modelValue !== normalized || unit) emit('update:modelValue', normalized, unit)\n}\n\nfunction restoreInteractionValue() {\n if (!mutationRequested) return\n if (workingValue.value !== interactionStartValue || interactionStartedMixed !== isMixed.value) {\n workingValue.value = interactionStartValue\n if (!binding?.actions.applyValue(interactionStartValue)) {\n emit('update:modelValue', interactionStartValue)\n }\n }\n}\n\nfunction finishCommit(value: number, unit?: string) {\n updateValue(value, unit)\n editing.value = false\n if (\n mutationRequested ||\n workingValue.value !== interactionStartValue ||\n interactionStartedMixed\n ) {\n emit('commit', workingValue.value, interactionStartValue, unit)\n }\n binding?.actions.commitMutation()\n}\n\nfunction startEdit() {\n if (editing.value || !canMutate()) return\n beginInteraction()\n draftValue.value = interactionStartedMixed ? '' : String(interactionStartValue)\n // A mixed field's empty draft stays an expression, which Enter rejects.\n absoluteDraft = interactionStartedMixed ? null : draftValue.value\n editing.value = true\n void nextTick(() => {\n inputRef.value?.focus()\n inputRef.value?.select()\n })\n}\n\nfunction setDraft(value: string) {\n if (value !== draftValue.value && !requestMutation('edit')) return\n draftValue.value = value\n const absoluteNumber = /^\\s*(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?\\s*$/i.test(value)\n if (absoluteNumber) updateValue(Number(value))\n}\n\nfunction onInput(event: Event) {\n setDraft(inputValue(event))\n}\n\n/** The typed expression without a unit from `units` it ends with, and that unit. */\nfunction splitUnit(expression: string): { value: string; unit?: string } {\n const source = expression.trim()\n const unit = [...units]\n .sort((a, b) => b.length - a.length)\n .find((candidate) => source.toLowerCase().endsWith(candidate.toLowerCase()))\n return unit ? { value: source.slice(0, -unit.length), unit } : { value: source }\n}\n\nfunction commitEdit() {\n if (!editing.value) return\n const expression = draftValue.value\n const { value, unit } = splitUnit(expression)\n if (expression === absoluteDraft) {\n finishCommit(workingValue.value, unit)\n return\n }\n const result = evaluateNumberExpression(value, {\n current: interactionStartValue,\n max,\n mixed: interactionStartedMixed\n })\n if (!result.ok) {\n invalidReason.value = result.error\n restoreInteractionValue()\n editing.value = false\n binding?.actions.cancelMutation()\n emit('cancel')\n emit('invalid', expression, result.error)\n return\n }\n finishCommit(result.value, unit)\n}\n\nfunction cancelEdit() {\n if (!editing.value) return\n restoreInteractionValue()\n invalidReason.value = null\n editing.value = false\n binding?.actions.cancelMutation()\n emit('cancel')\n}\n\nfunction stopScrubListeners() {\n stopMove?.()\n stopUp?.()\n stopCancel?.()\n stopMove = undefined\n stopUp = undefined\n stopCancel = undefined\n if (scrubTarget && scrubPointerId != null && scrubTarget.hasPointerCapture(scrubPointerId)) {\n scrubTarget.releasePointerCapture(scrubPointerId)\n }\n scrubTarget = undefined\n scrubPointerId = undefined\n if (typeof document !== 'undefined') document.body.style.cursor = ''\n}\n\nfunction startScrub(event: PointerEvent) {\n if (!canMutate()) return\n event.preventDefault()\n beginInteraction()\n\n const startX = event.clientX\n let lastX = startX\n const startValue = numericValue.value\n let accumulated = startValue\n let hasMoved = false\n const target = event.currentTarget instanceof Element ? event.currentTarget : undefined\n scrubTarget = target\n scrubPointerId = event.pointerId\n target?.setPointerCapture(event.pointerId)\n const listenerTarget = target ?? document\n\n stopMove = useEventListener(listenerTarget, 'pointermove', (moveEvent: PointerEvent) => {\n if (moveEvent.pointerId !== event.pointerId) return\n const dx = moveEvent.clientX - lastX\n lastX = moveEvent.clientX\n if (!hasMoved && Math.abs(moveEvent.clientX - startX) > 2) {\n if (!requestMutation('scrub')) return\n hasMoved = true\n scrubbing.value = true\n document.body.style.cursor = 'ew-resize'\n }\n if (!hasMoved) return\n accumulated += dx * stepValue.value * sensitivity\n // Pointer movement is fractional on high-density screens; the value moves in whole steps.\n const steps = Math.round((accumulated - startValue) / stepValue.value)\n updateValue(startValue + steps * stepValue.value)\n })\n\n const finish = (cancelled: boolean) => {\n stopScrubListeners()\n scrubbing.value = false\n if (cancelled) {\n restoreInteractionValue()\n binding?.actions.cancelMutation()\n emit('cancel')\n return\n }\n if (!hasMoved) {\n startEdit()\n return\n }\n emit('commit', workingValue.value, interactionStartValue)\n binding?.actions.commitMutation()\n }\n\n stopUp = useEventListener(listenerTarget, 'pointerup', (upEvent: PointerEvent) => {\n if (upEvent.pointerId === event.pointerId) finish(false)\n })\n stopCancel = useEventListener(listenerTarget, 'pointercancel', (cancelEvent: PointerEvent) => {\n if (cancelEvent.pointerId === event.pointerId) finish(true)\n })\n}\n\nfunction stepValueFromKeyboard(event: KeyboardEvent) {\n if (event.code !== 'ArrowUp' && event.code !== 'ArrowDown') return false\n if (!editing.value) beginInteraction()\n if (!requestMutation('step')) return true\n event.preventDefault()\n\n // A unit typed after the value stays on it, for the commit to report.\n const draft = editing.value ? splitUnit(draftValue.value) : undefined\n const draftResult =\n draft && draftValue.value !== absoluteDraft\n ? evaluateNumberExpression(draft.value, {\n current: interactionStartValue,\n max,\n mixed: interactionStartedMixed\n })\n : undefined\n const base = draftResult?.ok ? draftResult.value : workingValue.value\n const next = stepNumberValue(\n base,\n event.code === 'ArrowUp' ? 1 : -1,\n stepValue.value,\n event,\n min,\n max\n )\n updateValue(next, draft?.unit)\n draftValue.value = `${next}${draft?.unit ?? ''}`\n absoluteDraft = draftValue.value\n\n if (!editing.value) {\n emit('commit', next, interactionStartValue)\n binding?.actions.commitMutation()\n }\n return true\n}\n\nfunction onKeydown(event: KeyboardEvent) {\n if (stepValueFromKeyboard(event)) return\n if (event.code === 'Enter') {\n event.preventDefault()\n commitEdit()\n } else if (event.code === 'Escape') {\n event.preventDefault()\n cancelEdit()\n }\n}\n\nconst state = computed<NumberFieldState>(() => ({\n editing: editing.value,\n scrubbing: scrubbing.value,\n mixed: isMixed.value,\n disabled: disabled.value,\n bound: bound.value\n}))\n\nconst stateAttrs = computed<NumberFieldStateAttrs>(() => ({\n 'data-editing': editing.value ? '' : undefined,\n 'data-scrubbing': scrubbing.value ? '' : undefined,\n 'data-mixed': isMixed.value ? '' : undefined,\n 'data-disabled': disabled.value ? '' : undefined,\n 'data-bound': bound.value ? '' : undefined\n}))\n\nconst rootTabindex = computed<0 | -1 | undefined>(() => {\n if (editing.value) return undefined\n return disabled.value ? -1 : 0\n})\n\nconst rootAttrs = computed<NumberFieldRootAttrs>(() => ({\n ...stateAttrs.value,\n role: editing.value ? undefined : 'spinbutton',\n tabindex: rootTabindex.value,\n 'aria-valuenow':\n editing.value || isMixed.value || binding?.state.value === 'unresolved'\n ? undefined\n : numericValue.value,\n 'aria-readonly': binding?.state.value === 'unresolved' ? true : undefined,\n 'aria-valuemin': !editing.value && Number.isFinite(min) ? min : undefined,\n 'aria-valuemax': !editing.value && Number.isFinite(max) ? max : undefined,\n 'aria-disabled': !editing.value && disabled.value ? 'true' : undefined,\n 'aria-label': editing.value ? undefined : ariaLabel,\n onFocus: startEdit,\n onKeydown\n}))\n\nconst actions: NumberFieldActions = {\n startScrub,\n startEdit,\n cancelEdit,\n commitEdit,\n setDraft,\n input: onInput,\n keydown: onKeydown\n}\n\nconst slotProps = computed<NumberFieldSlotProps>(() => ({\n modelValue,\n displayValue: displayValue.value,\n draftValue: draftValue.value,\n isMixed: isMixed.value,\n placeholder,\n ...state.value,\n state: state.value,\n attrs: rootAttrs.value,\n actions\n}))\n\nprovideNumberField({\n modelValue: computed(() => modelValue),\n numericValue,\n displayValue,\n draftValue,\n isMixed,\n editing,\n scrubbing,\n disabled,\n bound,\n min: minValue,\n max: maxValue,\n step: stepValue,\n ariaLabel: ariaLabelValue,\n inputRef,\n state,\n stateAttrs,\n rootAttrs,\n slotProps,\n actions,\n invalidReason\n})\n\nwatch(editing, (value) => emit('editing-change', value))\nwatch(\n () => modelValue,\n (value) => {\n if (!editing.value && !scrubbing.value && typeof value === 'number') workingValue.value = value\n },\n { immediate: true }\n)\n\nfunction cancelDetachedInteraction() {\n stopScrubListeners()\n if (editing.value || scrubbing.value) {\n restoreInteractionValue()\n editing.value = false\n scrubbing.value = false\n binding?.actions.cancelMutation()\n emit('cancel')\n }\n}\n\n// Cancel before KeepAlive moves a focused input: detachment can synchronously\n// fire blur, which must not commit the draft before onDeactivated runs.\nwatchImmediate(\n () => retainedActivity?.value ?? true,\n (active) => {\n if (!active) cancelDetachedInteraction()\n },\n { flush: 'sync' }\n)\nonBeforeUnmount(cancel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ACzC,cAAc,yBAAyB;;GAIrC,OAAA,WAA2B,KAAA,QAAA,WAAA,eAAA,mBAAb,UAAA,KAAS,CAAA,CAAA"}
@@ -31,6 +31,11 @@ interface NumberFieldRootProps {
31
31
  * unit listed here is read as that unit, not as a percent of `max`.
32
32
  */
33
33
  units?: readonly string[];
34
+ /**
35
+ * How the field shows a bound variable's value and starts editing from it, such as to the two
36
+ * decimals the Design panel shows; the variable keeps its exact value until an edit changes it.
37
+ */
38
+ round?: (value: number) => number;
34
39
  }
35
40
  interface NumberFieldRootEmits {
36
41
  /** Emitted for live numeric updates and committed expression results. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/NumberField/types.ts"],"mappings":";;;KAIY;KACA;UAEK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;EAGA;EACA;;EAEA,aAAa;;;;;EAKb;;UAGe;;GAEd,4BAA4B,eAAe;;GAE3C,iBAAiB,eAAe,kBAAkB;;GAElD;;GAEA,yBAAyB;;GAEzB,kBAAkB,oBAAoB,QAAQ;;GAE9C,yBAAyB,QAAQ;;UAGnB;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe,6BAA6B;EAC5C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY,OAAO;;UAGJ;EACf,WAAW,OAAO;EAClB;EACA;EACA,WAAW,QAAQ;EACnB,SAAS;EACT,MAAM,OAAO;EACb,QAAQ,OAAO;;UAGA,6BAA6B;EAC5C;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,OAAO;EACP,SAAS;;UAGM;;EAEf,QAAQ,OAAO,uBAAuB;;UAGvB;;EAEf,QAAQ,OAAO;IAAyB;MAAkB;;UAG3C;EACf,YAAY;EACZ,cAAc;EACd,cAAc;EACd,YAAY;EACZ,SAAS;EACT,SAAS;EACT,WAAW;EACX,UAAU;EACV,OAAO;EACP,KAAK;EACL,KAAK;EACL,MAAM;EACN,WAAW;EACX,UAAU,IAAI;EACd,OAAO,YAAY;EACnB,YAAY,YAAY;EACxB,WAAW,YAAY;EACvB,WAAW,YAAY;EACvB,SAAS;EACT,eAAe,IAAI"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/NumberField/types.ts"],"mappings":";;;KAIY;KACA;UAEK;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;EAGA;EACA;;EAEA,aAAa;;;;;EAKb;;;;;EAKA,SAAS;;UAGM;;GAEd,4BAA4B,eAAe;;GAE3C,iBAAiB,eAAe,kBAAkB;;GAElD;;GAEA,yBAAyB;;GAEzB,kBAAkB,oBAAoB,QAAQ;;GAE9C,yBAAyB,QAAQ;;UAGnB;EACf;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;;UAGe,6BAA6B;EAC5C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY,OAAO;;UAGJ;EACf,WAAW,OAAO;EAClB;EACA;EACA,WAAW,QAAQ;EACnB,SAAS;EACT,MAAM,OAAO;EACb,QAAQ,OAAO;;UAGA,6BAA6B;EAC5C;EACA;EACA;EACA;EACA;EACA,OAAO;EACP,OAAO;EACP,SAAS;;UAGM;;EAEf,QAAQ,OAAO,uBAAuB;;UAGvB;;EAEf,QAAQ,OAAO;IAAyB;MAAkB;;UAG3C;EACf,YAAY;EACZ,cAAc;EACd,cAAc;EACd,YAAY;EACZ,SAAS;EACT,SAAS;EACT,WAAW;EACX,UAAU;EACV,OAAO;EACP,KAAK;EACL,KAAK;EACL,MAAM;EACN,WAAW;EACX,UAAU,IAAI;EACd,OAAO,YAAY;EACnB,YAAY,YAAY;EACxB,WAAW,YAAY;EACvB,WAAW,YAAY;EACvB,SAAS;EACT,eAAe,IAAI"}
@@ -6,7 +6,7 @@ declare function isDivider(page: {
6
6
  name: string;
7
7
  childIds: string[];
8
8
  }): boolean;
9
- declare function handleAdd(): void;
9
+ declare function handleAdd(): string;
10
10
  declare function handleSwitch(pageId: string): void;
11
11
  declare function handleRename(pageId: string, name: string): void;
12
12
  declare function handleDelete(pageId: string): void;
@@ -29,13 +29,13 @@ type __VLS_Slots = {} & {
29
29
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
30
30
  switch: (pageId: string) => any;
31
31
  delete: (pageId: string) => any;
32
- add: () => any;
32
+ add: (pageId: string) => any;
33
33
  rename: (pageId: string, name: string) => any;
34
34
  move: (pageId: string, index: number) => any;
35
35
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
36
36
  onSwitch?: ((pageId: string) => any) | undefined;
37
37
  onDelete?: ((pageId: string) => any) | undefined;
38
- onAdd?: (() => any) | undefined;
38
+ onAdd?: ((pageId: string) => any) | undefined;
39
39
  onRename?: ((pageId: string, name: string) => any) | undefined;
40
40
  onMove?: ((pageId: string, index: number) => any) | undefined;
41
41
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"PageListRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/PageList/PageListRoot.vue"],"mappings":";KA6EK;EACH,iBAAiB;;iBAmBV,UAAU;EAAQ;EAAc;;iBAIhC;iBAKA,aAAa;iBAKb,aAAa,gBAAgB;iBAK7B,aAAa;iBAKb,WAAW,gBAAgB;YA0ChC;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,gBAAA,2CAAA,qCAAA;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"PageListRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/PageList/PageListRoot.vue"],"mappings":";KA8EK;EACH,iBAAiB;;iBAmBV,UAAU;EAAQ;EAAc;;iBAIhC;iBAMA,aAAa;iBAKb,aAAa,gBAAgB;iBAK7B,aAAa;iBAKb,WAAW,gBAAgB;YA0ChC;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,gBAAA,2CAAA,qCAAA;;;;;;;;;;;;0CAGd;cACI,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -20,8 +20,9 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
20
20
  return isPageDivider(page, dividerPattern.value);
21
21
  }
22
22
  function handleAdd() {
23
- addPage();
24
- emit("add");
23
+ const pageId = addPage();
24
+ emit("add", pageId);
25
+ return pageId;
25
26
  }
26
27
  function handleSwitch(pageId) {
27
28
  switchPage(pageId);
@@ -1 +1 @@
1
- {"version":3,"file":"PageListRoot.vue.js","names":[],"sources":["../../../src/primitives/PageList/PageListRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { isPageDivider, PAGE_DIVIDER_PATTERN } from '#vue/primitives/PageList/divider'\nimport { usePageList } from '#vue/primitives/PageList/usePageList'\n\nconst { dividerPattern: customDividerPattern } = defineProps<{\n dividerPattern?: RegExp\n}>()\n\nconst emit = defineEmits<{\n add: []\n switch: [pageId: string]\n rename: [pageId: string, name: string]\n delete: [pageId: string]\n move: [pageId: string, index: number]\n}>()\n\nconst { pages, currentPageId, switchPage, addPage, renamePage, deletePage, movePage } =\n usePageList()\n\nconst dividerPattern = computed(() => customDividerPattern ?? PAGE_DIVIDER_PATTERN)\n\nfunction isDivider(page: { name: string; childIds: string[] }) {\n return isPageDivider(page, dividerPattern.value)\n}\n\nfunction handleAdd() {\n addPage()\n emit('add')\n}\n\nfunction handleSwitch(pageId: string) {\n switchPage(pageId)\n emit('switch', pageId)\n}\n\nfunction handleRename(pageId: string, name: string) {\n renamePage(pageId, name)\n emit('rename', pageId, name)\n}\n\nfunction handleDelete(pageId: string) {\n deletePage(pageId)\n emit('delete', pageId)\n}\n\nfunction handleMove(pageId: string, index: number) {\n movePage(pageId, index)\n emit('move', pageId, index)\n}\n\nconst actions = {\n add: handleAdd,\n switch: handleSwitch,\n rename: handleRename,\n delete: handleDelete,\n move: handleMove\n}\n</script>\n\n<template>\n <slot\n :pages=\"pages\"\n :current-page-id=\"currentPageId\"\n :is-divider=\"isDivider\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAUA,MAAM,OAAO;EAQb,MAAM,EAAE,OAAO,eAAe,YAAY,SAAS,YAAY,YAAY,aACzE,YAAY;EAEd,MAAM,iBAAiB,eAAe,QAAA,kBAAwB,oBAAoB;EAElF,SAAS,UAAU,MAA4C;GAC7D,OAAO,cAAc,MAAM,eAAe,KAAK;EACjD;EAEA,SAAS,YAAY;GACnB,QAAQ;GACR,KAAK,KAAK;EACZ;EAEA,SAAS,aAAa,QAAgB;GACpC,WAAW,MAAM;GACjB,KAAK,UAAU,MAAM;EACvB;EAEA,SAAS,aAAa,QAAgB,MAAc;GAClD,WAAW,QAAQ,IAAI;GACvB,KAAK,UAAU,QAAQ,IAAI;EAC7B;EAEA,SAAS,aAAa,QAAgB;GACpC,WAAW,MAAM;GACjB,KAAK,UAAU,MAAM;EACvB;EAEA,SAAS,WAAW,QAAgB,OAAe;GACjD,SAAS,QAAQ,KAAK;GACtB,KAAK,QAAQ,QAAQ,KAAK;EAC5B;EAEA,MAAM,UAAU;GACd,KAAK;GACL,QAAQ;GACR,QAAQ;GACR,QAAQ;GACR,MAAM;EACR;;GAIE,OAAA,WAKE,KAAA,QAAA,WAAA;IAJC,OAAO,MAAA,KAAA;IACP,eAAiB,MAAA,aAAA;IACL;IACH"}
1
+ {"version":3,"file":"PageListRoot.vue.js","names":[],"sources":["../../../src/primitives/PageList/PageListRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { isPageDivider, PAGE_DIVIDER_PATTERN } from '#vue/primitives/PageList/divider'\nimport { usePageList } from '#vue/primitives/PageList/usePageList'\n\nconst { dividerPattern: customDividerPattern } = defineProps<{\n dividerPattern?: RegExp\n}>()\n\nconst emit = defineEmits<{\n add: [pageId: string]\n switch: [pageId: string]\n rename: [pageId: string, name: string]\n delete: [pageId: string]\n move: [pageId: string, index: number]\n}>()\n\nconst { pages, currentPageId, switchPage, addPage, renamePage, deletePage, movePage } =\n usePageList()\n\nconst dividerPattern = computed(() => customDividerPattern ?? PAGE_DIVIDER_PATTERN)\n\nfunction isDivider(page: { name: string; childIds: string[] }) {\n return isPageDivider(page, dividerPattern.value)\n}\n\nfunction handleAdd() {\n const pageId = addPage()\n emit('add', pageId)\n return pageId\n}\n\nfunction handleSwitch(pageId: string) {\n switchPage(pageId)\n emit('switch', pageId)\n}\n\nfunction handleRename(pageId: string, name: string) {\n renamePage(pageId, name)\n emit('rename', pageId, name)\n}\n\nfunction handleDelete(pageId: string) {\n void deletePage(pageId)\n emit('delete', pageId)\n}\n\nfunction handleMove(pageId: string, index: number) {\n movePage(pageId, index)\n emit('move', pageId, index)\n}\n\nconst actions = {\n add: handleAdd,\n switch: handleSwitch,\n rename: handleRename,\n delete: handleDelete,\n move: handleMove\n}\n</script>\n\n<template>\n <slot\n :pages=\"pages\"\n :current-page-id=\"currentPageId\"\n :is-divider=\"isDivider\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;EAUA,MAAM,OAAO;EAQb,MAAM,EAAE,OAAO,eAAe,YAAY,SAAS,YAAY,YAAY,aACzE,YAAY;EAEd,MAAM,iBAAiB,eAAe,QAAA,kBAAwB,oBAAoB;EAElF,SAAS,UAAU,MAA4C;GAC7D,OAAO,cAAc,MAAM,eAAe,KAAK;EACjD;EAEA,SAAS,YAAY;GACnB,MAAM,SAAS,QAAQ;GACvB,KAAK,OAAO,MAAM;GAClB,OAAO;EACT;EAEA,SAAS,aAAa,QAAgB;GACpC,WAAW,MAAM;GACjB,KAAK,UAAU,MAAM;EACvB;EAEA,SAAS,aAAa,QAAgB,MAAc;GAClD,WAAW,QAAQ,IAAI;GACvB,KAAK,UAAU,QAAQ,IAAI;EAC7B;EAEA,SAAS,aAAa,QAAgB;GACpC,WAAgB,MAAM;GACtB,KAAK,UAAU,MAAM;EACvB;EAEA,SAAS,WAAW,QAAgB,OAAe;GACjD,SAAS,QAAQ,KAAK;GACtB,KAAK,QAAQ,QAAQ,KAAK;EAC5B;EAEA,MAAM,UAAU;GACd,KAAK;GACL,QAAQ;GACR,QAAQ;GACR,QAAQ;GACR,MAAM;EACR;;GAIE,OAAA,WAKE,KAAA,QAAA,WAAA;IAJC,OAAO,MAAA,KAAA;IACP,eAAiB,MAAA,aAAA;IACL;IACH"}
@@ -11,7 +11,7 @@ declare function usePageList(): {
11
11
  currentPageId: import("vue").ComputedRef<string>;
12
12
  switchPage: (pageId: string, options?: import("@pairdraw/core").SwitchPageOptions) => Promise<void>;
13
13
  addPage: (name?: string) => string;
14
- deletePage: (pageId: string) => void;
14
+ deletePage: (pageId: string) => Promise<void>;
15
15
  movePage: (pageId: string, index: number) => void;
16
16
  renamePage: (pageId: string, name: string) => void;
17
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"usePageList.d.ts","names":[],"sources":["../../../src/primitives/PageList/usePageList.ts"],"mappings":";;;;;;;iBAWgB;;;;wFAAA"}
1
+ {"version":3,"file":"usePageList.d.ts","names":[],"sources":["../../../src/primitives/PageList/usePageList.ts"],"mappings":";;;;;;;iBAWgB;;;;wFAAA;;kCAAA"}
@@ -9,6 +9,7 @@ declare var __VLS_1: {
9
9
  hValue: number | symbol;
10
10
  rotationValue: number | symbol;
11
11
  rotates: boolean;
12
+ resizes: boolean;
12
13
  inAutoLayout: boolean;
13
14
  ignoresAutoLayout: boolean;
14
15
  mixed: symbol;
@@ -1 +1 @@
1
- {"version":3,"file":"PositionControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/PositionControls/PositionControlsRoot.vue"],"mappings":";YAwJI;;;;;;;;;;;;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,kDAAA,qCAAA,iDAAA,aAAA,eAAA,oDAAA;cAEV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
1
+ {"version":3,"file":"PositionControlsRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/PositionControls/PositionControlsRoot.vue"],"mappings":";YA2II;;;;;;;;;;;;;;;;;;;;;;;;KACC;EACD,WAAW,cAAc;;cAGvB,0BAAU,kDAAA,qCAAA,iDAAA,aAAA,eAAA,oDAAA;cAEV,cAAqB,uBAAuB,YAAY;cACzC,iBAAO;KACvB,gBAAgB,GAAG,KAAK;;IAE3B,QAAQ"}
@@ -1,19 +1,16 @@
1
1
  import { MIXED } from "../../controls/node-props/helpers.js";
2
2
  import { usePosition } from "../../controls/position/use.js";
3
- import { computed, defineComponent, renderSlot, unref } from "vue";
3
+ import { defineComponent, renderSlot, unref } from "vue";
4
4
  //#region src/primitives/PositionControls/PositionControlsRoot.vue
5
5
  const _sfc_main = /*@__PURE__*/ defineComponent({
6
6
  __name: "PositionControlsRoot",
7
7
  setup(__props) {
8
- const { updateProp, commitProp, cancelProp, ids, align, flip, rotate, isMulti, active, prop: multiProp, panelProp, x, y, rotation, rotates, inAutoLayout, ignoresAutoLayout, toggleIgnoreAutoLayout } = usePosition();
9
- const multiX = panelProp("x");
10
- const multiY = panelProp("y");
11
- const multiRotation = panelProp("rotation");
12
- const xValue = computed(() => isMulti.value ? multiX.value : x.value);
13
- const yValue = computed(() => isMulti.value ? multiY.value : y.value);
14
- const wValue = multiProp("width");
15
- const hValue = multiProp("height");
16
- const rotationValue = computed(() => isMulti.value ? multiRotation.value : rotation.value);
8
+ const { updateProp, commitProp, cancelProp, ids, align, flip, rotate, isMulti, active, panelProp, rotates, resizes, inAutoLayout, ignoresAutoLayout, toggleIgnoreAutoLayout } = usePosition();
9
+ const xValue = panelProp("x");
10
+ const yValue = panelProp("y");
11
+ const wValue = panelProp("width");
12
+ const hValue = panelProp("height");
13
+ const rotationValue = panelProp("rotation");
17
14
  const actions = {
18
15
  updateProp,
19
16
  commitProp,
@@ -28,12 +25,13 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
28
25
  active: unref(active),
29
26
  isMulti: unref(isMulti),
30
27
  ids: unref(ids),
31
- xValue: xValue.value,
32
- yValue: yValue.value,
28
+ xValue: unref(xValue),
29
+ yValue: unref(yValue),
33
30
  wValue: unref(wValue),
34
31
  hValue: unref(hValue),
35
- rotationValue: rotationValue.value,
32
+ rotationValue: unref(rotationValue),
36
33
  rotates: unref(rotates),
34
+ resizes: unref(resizes),
37
35
  inAutoLayout: unref(inAutoLayout),
38
36
  ignoresAutoLayout: unref(ignoresAutoLayout),
39
37
  mixed: unref(MIXED),
@@ -1 +1 @@
1
- {"version":3,"file":"PositionControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/PositionControls/PositionControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed } from 'vue'\n\nimport { MIXED } from '#vue/controls/node-props/use'\nimport { usePosition } from '#vue/controls/position/use'\n\nconst {\n updateProp,\n commitProp,\n cancelProp,\n ids,\n align,\n flip,\n rotate,\n isMulti,\n active,\n prop: multiProp,\n panelProp,\n x,\n y,\n rotation,\n rotates,\n inAutoLayout,\n ignoresAutoLayout,\n toggleIgnoreAutoLayout\n} = usePosition()\n\nconst multiX = panelProp('x')\nconst multiY = panelProp('y')\nconst multiRotation = panelProp('rotation')\nconst xValue = computed(() => (isMulti.value ? multiX.value : x.value))\nconst yValue = computed(() => (isMulti.value ? multiY.value : y.value))\nconst wValue = multiProp('width')\nconst hValue = multiProp('height')\nconst rotationValue = computed(() => (isMulti.value ? multiRotation.value : rotation.value))\nconst actions = {\n updateProp,\n commitProp,\n cancelProp,\n align,\n flip,\n rotate,\n toggleIgnoreAutoLayout\n}\n</script>\n\n<template>\n <slot\n :active=\"active\"\n :is-multi=\"isMulti\"\n :ids=\"ids\"\n :x-value=\"xValue\"\n :y-value=\"yValue\"\n :w-value=\"wValue\"\n :h-value=\"hValue\"\n :rotation-value=\"rotationValue\"\n :rotates=\"rotates\"\n :in-auto-layout=\"inAutoLayout\"\n :ignores-auto-layout=\"ignoresAutoLayout\"\n :mixed=\"MIXED\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;EAMA,MAAM,EACJ,YACA,YACA,YACA,KACA,OACA,MACA,QACA,SACA,QACA,MAAM,WACN,WACA,GACA,GACA,UACA,SACA,cACA,mBACA,2BACE,YAAY;EAEhB,MAAM,SAAS,UAAU,GAAG;EAC5B,MAAM,SAAS,UAAU,GAAG;EAC5B,MAAM,gBAAgB,UAAU,UAAU;EAC1C,MAAM,SAAS,eAAgB,QAAQ,QAAQ,OAAO,QAAQ,EAAE,KAAM;EACtE,MAAM,SAAS,eAAgB,QAAQ,QAAQ,OAAO,QAAQ,EAAE,KAAM;EACtE,MAAM,SAAS,UAAU,OAAO;EAChC,MAAM,SAAS,UAAU,QAAQ;EACjC,MAAM,gBAAgB,eAAgB,QAAQ,QAAQ,cAAc,QAAQ,SAAS,KAAM;EAC3F,MAAM,UAAU;GACd;GACA;GACA;GACA;GACA;GACA;GACA;EACF;;GAIE,OAAA,WAcE,KAAA,QAAA,WAAA;IAbC,QAAQ,MAAA,MAAA;IACR,SAAU,MAAA,OAAA;IACV,KAAK,MAAA,GAAA;IACL,QAAS,OAAA;IACT,QAAS,OAAA;IACT,QAAS,MAAA,MAAA;IACT,QAAS,MAAA,MAAA;IACT,eAAgB,cAAA;IAChB,SAAS,MAAA,OAAA;IACT,cAAgB,MAAA,YAAA;IAChB,mBAAqB,MAAA,iBAAA;IACrB,OAAO,MAAA,KAAA;IACE"}
1
+ {"version":3,"file":"PositionControlsRoot.vue.js","names":[],"sources":["../../../src/primitives/PositionControls/PositionControlsRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { MIXED } from '#vue/controls/node-props/use'\nimport { usePosition } from '#vue/controls/position/use'\n\nconst {\n updateProp,\n commitProp,\n cancelProp,\n ids,\n align,\n flip,\n rotate,\n isMulti,\n active,\n panelProp,\n rotates,\n resizes,\n inAutoLayout,\n ignoresAutoLayout,\n toggleIgnoreAutoLayout\n} = usePosition()\n\nconst xValue = panelProp('x')\nconst yValue = panelProp('y')\nconst wValue = panelProp('width')\nconst hValue = panelProp('height')\nconst rotationValue = panelProp('rotation')\nconst actions = {\n updateProp,\n commitProp,\n cancelProp,\n align,\n flip,\n rotate,\n toggleIgnoreAutoLayout\n}\n</script>\n\n<template>\n <slot\n :active=\"active\"\n :is-multi=\"isMulti\"\n :ids=\"ids\"\n :x-value=\"xValue\"\n :y-value=\"yValue\"\n :w-value=\"wValue\"\n :h-value=\"hValue\"\n :rotation-value=\"rotationValue\"\n :rotates=\"rotates\"\n :resizes=\"resizes\"\n :in-auto-layout=\"inAutoLayout\"\n :ignores-auto-layout=\"ignoresAutoLayout\"\n :mixed=\"MIXED\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;EAIA,MAAM,EACJ,YACA,YACA,YACA,KACA,OACA,MACA,QACA,SACA,QACA,WACA,SACA,SACA,cACA,mBACA,2BACE,YAAY;EAEhB,MAAM,SAAS,UAAU,GAAG;EAC5B,MAAM,SAAS,UAAU,GAAG;EAC5B,MAAM,SAAS,UAAU,OAAO;EAChC,MAAM,SAAS,UAAU,QAAQ;EACjC,MAAM,gBAAgB,UAAU,UAAU;EAC1C,MAAM,UAAU;GACd;GACA;GACA;GACA;GACA;GACA;GACA;EACF;;GAIE,OAAA,WAeE,KAAA,QAAA,WAAA;IAdC,QAAQ,MAAA,MAAA;IACR,SAAU,MAAA,OAAA;IACV,KAAK,MAAA,GAAA;IACL,QAAS,MAAA,MAAA;IACT,QAAS,MAAA,MAAA;IACT,QAAS,MAAA,MAAA;IACT,QAAS,MAAA,MAAA;IACT,eAAgB,MAAA,aAAA;IAChB,SAAS,MAAA,OAAA;IACT,SAAS,MAAA,OAAA;IACT,cAAgB,MAAA,YAAA;IAChB,mBAAqB,MAAA,iBAAA;IACrB,OAAO,MAAA,KAAA;IACE"}
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyListRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/PropertyList/PropertyListRoot.vue"],"mappings":";;cA0FM,eAAiB,UAAU,iBAChC,aAAa,YAAY,eAAe,wBACxC,YAAY,oBAAoB,KAAK,YAAY,eAAe,6CAChE,gBAAgB,YAAY,eAAe,yBAC3C,cAAA;EAsFO,qBAAc,cAAc,oBAAoB,sBAAA;;;;;;;eAA+C;IAAqB,4BAA4B;MAAM;EACrJ,SAAC;EACF;;;qBAKkB;EAAU,QAAQ,YAAY,eAAe;;cAClD,iBAAO;KACvB,oBAAoB,MAAM,mBAAmB,WAAW,IAAI,EAAE,WAAW,WAAW,KAAK,IAAI,EAAE"}
1
+ {"version":3,"file":"PropertyListRoot.vue.d.ts","names":[],"sources":["../../../src/primitives/PropertyList/PropertyListRoot.vue"],"mappings":";;cAwGM,eAAiB,UAAU,iBAChC,aAAa,YAAY,eAAe,wBACxC,YAAY,oBAAoB,KAAK,YAAY,eAAe,6CAChE,gBAAgB,YAAY,eAAe,yBAC3C,cAAA;EAkGO,qBAAc,cAAc,oBAAoB,sBAAA;;;;;;;eAA+C;IAAqB,4BAA4B;MAAM;EACrJ,SAAC;EACF;;;qBAKkB;EAAU,QAAQ,YAAY,eAAe;;cAClD,iBAAO;KACvB,oBAAoB,MAAM,mBAAmB,WAAW,IAAI,EAAE,WAAW,WAAW,KAAK,IAAI,EAAE"}
@@ -1,4 +1,5 @@
1
1
  import { providePropertyList } from "./context.js";
2
+ import { useFlatReorderDrag } from "../../shared/drag/useFlatReorderDrag.js";
2
3
  import { computed, defineComponent, renderSlot } from "vue";
3
4
  //#region src/primitives/PropertyList/PropertyListRoot.vue
4
5
  const _sfc_main = /*@__PURE__*/ defineComponent({
@@ -53,13 +54,21 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
53
54
  if (!disabled.value) emit("reorder", fromIndex, toIndex);
54
55
  }
55
56
  };
57
+ const drag = useFlatReorderDrag({
58
+ items: () => items.value.map((item, index) => ({ id: String(keyOf(item, index)) })),
59
+ onMove: (sourceId, targetIndex) => {
60
+ const fromIndex = items.value.findIndex((item, index) => String(keyOf(item, index)) === sourceId);
61
+ if (fromIndex !== -1) actions.reorder(fromIndex, targetIndex);
62
+ }
63
+ });
56
64
  providePropertyList({
57
65
  propKey: __props.propKey,
58
66
  items,
59
67
  isMixed,
60
68
  disabled,
61
69
  keyOf,
62
- actions
70
+ actions,
71
+ drag
63
72
  });
64
73
  return (_ctx, _cache) => {
65
74
  return renderSlot(_ctx.$slots, "default", {
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyListRoot.vue.js","names":[],"sources":["../../../src/primitives/PropertyList/PropertyListRoot.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"K extends PropertyListKey\">\nimport { computed } from 'vue'\n\nimport { providePropertyList } from '#vue/primitives/PropertyList/context'\n\nimport type {\n PropertyListActions,\n PropertyListIdentity,\n PropertyListItemFor,\n PropertyListKey,\n PropertyListPatchFor,\n PropertyListRootProps,\n PropertyListRootSlots\n} from './types'\n\nconst {\n propKey,\n items: itemsProp,\n mixed = false,\n disabled: disabledProp = false,\n getKey\n} = defineProps<PropertyListRootProps<K>>()\nconst emit = defineEmits<{\n add: [item: PropertyListItemFor<K>]\n remove: [index: number]\n update: [index: number, item: PropertyListItemFor<K>]\n patch: [index: number, changes: PropertyListPatchFor<K>]\n toggleVisibility: [index: number]\n reorder: [fromIndex: number, toIndex: number]\n}>()\ndefineSlots<PropertyListRootSlots<K>>()\n\nconst items = computed(() => itemsProp)\nconst isMixed = computed(() => mixed)\nconst disabled = computed(() => disabledProp)\n\nfunction keyOf(item: PropertyListItemFor<K>, index: number): PropertyListIdentity {\n return getKey?.(item, index) ?? index\n}\n\nconst actions: PropertyListActions<K> = {\n add: (item) => {\n if (!disabled.value) emit('add', item)\n },\n remove: (index) => {\n if (!disabled.value) emit('remove', index)\n },\n update: (index, item) => {\n if (!disabled.value) emit('update', index, item)\n },\n patch: (index, changes) => {\n if (!disabled.value) emit('patch', index, changes)\n },\n toggleVisibility: (index) => {\n if (!disabled.value) emit('toggleVisibility', index)\n },\n reorder: (fromIndex, toIndex) => {\n if (!disabled.value) emit('reorder', fromIndex, toIndex)\n }\n}\n\nprovidePropertyList({ propKey, items, isMixed, disabled, keyOf, actions })\n</script>\n\n<template>\n <slot\n :items=\"items\"\n :is-mixed=\"isMixed\"\n :disabled=\"disabled\"\n :key-of=\"keyOf\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBA,MAAM,OAAO;EAUb,MAAM,QAAQ,eAAe,QAAA,KAAS;EACtC,MAAM,UAAU,eAAe,QAAA,KAAK;EACpC,MAAM,WAAW,eAAe,QAAA,QAAY;EAE5C,SAAS,MAAM,MAA8B,OAAqC;GAChF,OAAO,QAAA,SAAS,MAAM,KAAK,KAAK;EAClC;EAEA,MAAM,UAAkC;GACtC,MAAM,SAAS;IACb,IAAI,CAAC,SAAS,OAAO,KAAK,OAAO,IAAI;GACvC;GACA,SAAS,UAAU;IACjB,IAAI,CAAC,SAAS,OAAO,KAAK,UAAU,KAAK;GAC3C;GACA,SAAS,OAAO,SAAS;IACvB,IAAI,CAAC,SAAS,OAAO,KAAK,UAAU,OAAO,IAAI;GACjD;GACA,QAAQ,OAAO,YAAY;IACzB,IAAI,CAAC,SAAS,OAAO,KAAK,SAAS,OAAO,OAAO;GACnD;GACA,mBAAmB,UAAU;IAC3B,IAAI,CAAC,SAAS,OAAO,KAAK,oBAAoB,KAAK;GACrD;GACA,UAAU,WAAW,YAAY;IAC/B,IAAI,CAAC,SAAS,OAAO,KAAK,WAAW,WAAW,OAAO;GACzD;EACF;EAEA,oBAAoB;GAAE,SAAM,QAAA;GAAG;GAAO;GAAS;GAAU;GAAO;EAAQ,CAAC;;GAIvE,OAAA,WAME,KAAA,QAAA,WAAA;IALC,OAAO,MAAA;IACP,SAAU,QAAA;IACV,UAAU,SAAA;IACF;IACC"}
1
+ {"version":3,"file":"PropertyListRoot.vue.js","names":[],"sources":["../../../src/primitives/PropertyList/PropertyListRoot.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"K extends PropertyListKey\">\nimport { computed } from 'vue'\n\nimport { providePropertyList } from '#vue/primitives/PropertyList/context'\nimport { useFlatReorderDrag } from '#vue/shared/drag'\n\nimport type {\n PropertyListActions,\n PropertyListIdentity,\n PropertyListItemFor,\n PropertyListKey,\n PropertyListPatchFor,\n PropertyListRootProps,\n PropertyListRootSlots\n} from './types'\n\nconst {\n propKey,\n items: itemsProp,\n mixed = false,\n disabled: disabledProp = false,\n getKey\n} = defineProps<PropertyListRootProps<K>>()\nconst emit = defineEmits<{\n add: [item: PropertyListItemFor<K>]\n remove: [index: number]\n update: [index: number, item: PropertyListItemFor<K>]\n patch: [index: number, changes: PropertyListPatchFor<K>]\n toggleVisibility: [index: number]\n reorder: [fromIndex: number, toIndex: number]\n}>()\ndefineSlots<PropertyListRootSlots<K>>()\n\nconst items = computed(() => itemsProp)\nconst isMixed = computed(() => mixed)\nconst disabled = computed(() => disabledProp)\n\nfunction keyOf(item: PropertyListItemFor<K>, index: number): PropertyListIdentity {\n return getKey?.(item, index) ?? index\n}\n\nconst actions: PropertyListActions<K> = {\n add: (item) => {\n if (!disabled.value) emit('add', item)\n },\n remove: (index) => {\n if (!disabled.value) emit('remove', index)\n },\n update: (index, item) => {\n if (!disabled.value) emit('update', index, item)\n },\n patch: (index, changes) => {\n if (!disabled.value) emit('patch', index, changes)\n },\n toggleVisibility: (index) => {\n if (!disabled.value) emit('toggleVisibility', index)\n },\n reorder: (fromIndex, toIndex) => {\n if (!disabled.value) emit('reorder', fromIndex, toIndex)\n }\n}\n\n// Rows drag to reorder, as Figma's paint lists do; the drag lives here so every row of the list\n// shares one monitor and one drop instruction.\nconst drag = useFlatReorderDrag({\n items: () => items.value.map((item, index) => ({ id: String(keyOf(item, index)) })),\n onMove: (sourceId, targetIndex) => {\n const fromIndex = items.value.findIndex(\n (item, index) => String(keyOf(item, index)) === sourceId\n )\n if (fromIndex !== -1) actions.reorder(fromIndex, targetIndex)\n }\n})\n\nprovidePropertyList({ propKey, items, isMixed, disabled, keyOf, actions, drag })\n</script>\n\n<template>\n <slot\n :items=\"items\"\n :is-mixed=\"isMixed\"\n :disabled=\"disabled\"\n :key-of=\"keyOf\"\n :actions=\"actions\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBA,MAAM,OAAO;EAUb,MAAM,QAAQ,eAAe,QAAA,KAAS;EACtC,MAAM,UAAU,eAAe,QAAA,KAAK;EACpC,MAAM,WAAW,eAAe,QAAA,QAAY;EAE5C,SAAS,MAAM,MAA8B,OAAqC;GAChF,OAAO,QAAA,SAAS,MAAM,KAAK,KAAK;EAClC;EAEA,MAAM,UAAkC;GACtC,MAAM,SAAS;IACb,IAAI,CAAC,SAAS,OAAO,KAAK,OAAO,IAAI;GACvC;GACA,SAAS,UAAU;IACjB,IAAI,CAAC,SAAS,OAAO,KAAK,UAAU,KAAK;GAC3C;GACA,SAAS,OAAO,SAAS;IACvB,IAAI,CAAC,SAAS,OAAO,KAAK,UAAU,OAAO,IAAI;GACjD;GACA,QAAQ,OAAO,YAAY;IACzB,IAAI,CAAC,SAAS,OAAO,KAAK,SAAS,OAAO,OAAO;GACnD;GACA,mBAAmB,UAAU;IAC3B,IAAI,CAAC,SAAS,OAAO,KAAK,oBAAoB,KAAK;GACrD;GACA,UAAU,WAAW,YAAY;IAC/B,IAAI,CAAC,SAAS,OAAO,KAAK,WAAW,WAAW,OAAO;GACzD;EACF;EAIA,MAAM,OAAO,mBAAmB;GAC9B,aAAa,MAAM,MAAM,KAAK,MAAM,WAAW,EAAE,IAAI,OAAO,MAAM,MAAM,KAAK,CAAC,EAAE,EAAE;GAClF,SAAS,UAAU,gBAAgB;IACjC,MAAM,YAAY,MAAM,MAAM,WAC3B,MAAM,UAAU,OAAO,MAAM,MAAM,KAAK,CAAC,MAAM,QAClD;IACA,IAAI,cAAc,IAAI,QAAQ,QAAQ,WAAW,WAAW;GAC9D;EACF,CAAC;EAED,oBAAoB;GAAE,SAAM,QAAA;GAAG;GAAO;GAAS;GAAU;GAAO;GAAS;EAAK,CAAC;;GAI7E,OAAA,WAME,KAAA,QAAA,WAAA;IALC,OAAO,MAAA;IACP,SAAU,QAAA;IACV,UAAU,SAAA;IACF;IACC"}
@@ -1,8 +1,8 @@
1
- import { PropertyListActions, PropertyListContext, PropertyListIdentity, PropertyListItemActions, PropertyListItemFor, PropertyListItemMap, PropertyListItemSlotProps, PropertyListKey, PropertyListPartProps, PropertyListPatchFor, PropertyListRootProps, PropertyListRootSlotProps, PropertyListRootSlots } from "./types.js";
1
+ import { PropertyListActions, PropertyListContext, PropertyListDrag, PropertyListIdentity, PropertyListItemActions, PropertyListItemFor, PropertyListItemMap, PropertyListItemSlotProps, PropertyListKey, PropertyListPartProps, PropertyListPatchFor, PropertyListRootProps, PropertyListRootSlotProps, PropertyListRootSlots } from "./types.js";
2
2
  import _default$3 from "./PropertyListRoot.vue.js";
3
3
  import _default$1 from "./PropertyListItem.vue.js";
4
4
  import _default from "./PropertyListAdd.vue.js";
5
5
  import _default$2 from "./PropertyListRemove.vue.js";
6
6
  import _default$4 from "./PropertyListVisibility.vue.js";
7
7
  import { usePropertyList } from "./context.js";
8
- export { type PropertyListActions, _default as PropertyListAdd, type PropertyListContext, type PropertyListIdentity, _default$1 as PropertyListItem, type PropertyListItemActions, type PropertyListItemFor, type PropertyListItemMap, type PropertyListItemSlotProps, type PropertyListKey, type PropertyListPartProps, type PropertyListPatchFor, _default$2 as PropertyListRemove, _default$3 as PropertyListRoot, type PropertyListRootProps, type PropertyListRootSlotProps, type PropertyListRootSlots, _default$4 as PropertyListVisibility, usePropertyList };
8
+ export { type PropertyListActions, _default as PropertyListAdd, type PropertyListContext, type PropertyListDrag, type PropertyListIdentity, _default$1 as PropertyListItem, type PropertyListItemActions, type PropertyListItemFor, type PropertyListItemMap, type PropertyListItemSlotProps, type PropertyListKey, type PropertyListPartProps, type PropertyListPatchFor, _default$2 as PropertyListRemove, _default$3 as PropertyListRoot, type PropertyListRootProps, type PropertyListRootSlotProps, type PropertyListRootSlots, _default$4 as PropertyListVisibility, usePropertyList };
@@ -1,4 +1,4 @@
1
- import { Component, ComputedRef, VNode } from "vue";
1
+ import { Component, ComputedRef, Ref, VNode } from "vue";
2
2
  import { Effect, Fill, Stroke } from "@pairdraw/scene-graph";
3
3
  //#region src/primitives/PropertyList/types.d.ts
4
4
  interface PropertyListItemMap {
@@ -10,6 +10,17 @@ type PropertyListKey = keyof PropertyListItemMap;
10
10
  type PropertyListItemFor<K extends PropertyListKey> = PropertyListItemMap[K];
11
11
  type PropertyListPatchFor<K extends PropertyListKey> = Partial<PropertyListItemFor<K>>;
12
12
  type PropertyListIdentity = string | number;
13
+ /** The row reorder drag a list root shares with its rows, when the list can be reordered. */
14
+ interface PropertyListDrag {
15
+ setupItem(element: HTMLElement | null, item: () => {
16
+ id: string;
17
+ }): void;
18
+ draggingId: Ref<string | null>;
19
+ instructionTargetId: Ref<string | null>;
20
+ instruction: Ref<{
21
+ operation: string;
22
+ } | null>;
23
+ }
13
24
  interface PropertyListActions<K extends PropertyListKey> {
14
25
  add(item: PropertyListItemFor<K>): void;
15
26
  remove(index: number): void;
@@ -25,6 +36,7 @@ interface PropertyListContext<K extends PropertyListKey = PropertyListKey> {
25
36
  disabled: ComputedRef<boolean>;
26
37
  keyOf(item: PropertyListItemFor<K>, index: number): PropertyListIdentity;
27
38
  actions: PropertyListActions<K>;
39
+ drag?: PropertyListDrag;
28
40
  }
29
41
  interface PropertyListRootProps<K extends PropertyListKey> {
30
42
  /** Discriminator that provides exact Fill, Stroke, or Effect types to slots and actions. */
@@ -75,5 +87,5 @@ interface PropertyListItemSlotProps<K extends PropertyListKey> {
75
87
  actions: PropertyListItemActions<K>;
76
88
  }
77
89
  //#endregion
78
- export { PropertyListActions, PropertyListContext, PropertyListIdentity, PropertyListItemActions, PropertyListItemFor, PropertyListItemMap, PropertyListItemSlotProps, PropertyListKey, PropertyListPartProps, PropertyListPatchFor, PropertyListRootProps, PropertyListRootSlotProps, PropertyListRootSlots };
90
+ export { PropertyListActions, PropertyListContext, PropertyListDrag, PropertyListIdentity, PropertyListItemActions, PropertyListItemFor, PropertyListItemMap, PropertyListItemSlotProps, PropertyListKey, PropertyListPartProps, PropertyListPatchFor, PropertyListRootProps, PropertyListRootSlotProps, PropertyListRootSlots };
79
91
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/primitives/PropertyList/types.ts"],"mappings":";;;UAIiB;EACf,OAAO;EACP,SAAS;EACT,SAAS;;KAGC,wBAAwB;KACxB,oBAAoB,UAAU,mBAAmB,oBAAoB;KACrE,qBAAqB,UAAU,mBAAmB,QAAQ,oBAAoB;KAC9E;UAEK,oBAAoB,UAAU;EAC7C,IAAI,MAAM,oBAAoB;EAC9B,OAAO;EACP,OAAO,eAAe,MAAM,oBAAoB;EAChD,MAAM,eAAe,SAAS,qBAAqB;EACnD,iBAAiB;EACjB,QAAQ,mBAAmB;;UAGZ,oBAAoB,UAAU,kBAAkB;EAC/D,SAAS;EACT,OAAO,YAAY,oBAAoB;EACvC,SAAS;EACT,UAAU;EACV,MAAM,MAAM,oBAAoB,IAAI,gBAAgB;EACpD,SAAS,oBAAoB;;UAGd,sBAAsB,UAAU;;EAE/C,SAAS;;EAET,OAAO,oBAAoB;;EAE3B;;EAEA;;EAEA,UAAU,MAAM,oBAAoB,IAAI,kBAAkB;;EAE1D;;UAGe,0BAA0B,UAAU;EACnD,OAAO,oBAAoB;EAC3B;EACA;EACA,MAAM,MAAM,oBAAoB,IAAI,gBAAgB;EACpD,SAAS,oBAAoB;;UAGd,sBAAsB,UAAU;EAC/C,S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