@pairdraw/vue 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/dist/canvas/CanvasRoot.vue.js +1 -0
  2. package/dist/canvas/CanvasRoot.vue.js.map +1 -1
  3. package/dist/canvas/drop/use.d.ts.map +1 -1
  4. package/dist/canvas/drop/use.js +5 -3
  5. package/dist/canvas/drop/use.js.map +1 -1
  6. package/dist/canvas/guides/input.js +2 -1
  7. package/dist/canvas/guides/input.js.map +1 -1
  8. package/dist/canvas/pen/input.js +20 -6
  9. package/dist/canvas/pen/input.js.map +1 -1
  10. package/dist/canvas/surface/gl-surface.js +82 -4
  11. package/dist/canvas/surface/gl-surface.js.map +1 -1
  12. package/dist/canvas/surface/lifecycle.js +5 -0
  13. package/dist/canvas/surface/lifecycle.js.map +1 -1
  14. package/dist/canvas/surface/resize-observer.js +11 -4
  15. package/dist/canvas/surface/resize-observer.js.map +1 -1
  16. package/dist/canvas/surface/types.d.ts +5 -0
  17. package/dist/canvas/surface/types.d.ts.map +1 -1
  18. package/dist/canvas/surface/use.d.ts +1 -0
  19. package/dist/canvas/surface/use.js +1 -0
  20. package/dist/canvas/surface/use.js.map +1 -1
  21. package/dist/canvas/text-edit/editing.js +11 -8
  22. package/dist/canvas/text-edit/editing.js.map +1 -1
  23. package/dist/canvas/text-edit/keyboard.js +12 -0
  24. package/dist/canvas/text-edit/keyboard.js.map +1 -1
  25. package/dist/canvas/useCanvasInput.d.ts +240 -0
  26. package/dist/controls/appearance/use.d.ts +1 -1
  27. package/dist/controls/layout/helpers.d.ts.map +1 -1
  28. package/dist/controls/layout/helpers.js +36 -7
  29. package/dist/controls/layout/helpers.js.map +1 -1
  30. package/dist/controls/layout/use.d.ts +1 -0
  31. package/dist/controls/layout/use.d.ts.map +1 -1
  32. package/dist/controls/layout/use.js +3 -0
  33. package/dist/controls/layout/use.js.map +1 -1
  34. package/dist/controls/node-preview/use.js +21 -1
  35. package/dist/controls/node-preview/use.js.map +1 -1
  36. package/dist/controls/position/use.d.ts +2 -1
  37. package/dist/controls/position/use.d.ts.map +1 -1
  38. package/dist/controls/position/use.js +13 -5
  39. package/dist/controls/position/use.js.map +1 -1
  40. package/dist/controls/property-list/use.d.ts.map +1 -1
  41. package/dist/controls/property-list/use.js +27 -5
  42. package/dist/controls/property-list/use.js.map +1 -1
  43. package/dist/controls/selection-layout/use.d.ts.map +1 -1
  44. package/dist/controls/selection-layout/use.js +2 -1
  45. package/dist/controls/selection-layout/use.js.map +1 -1
  46. package/dist/controls/slots/authoring.d.ts.map +1 -1
  47. package/dist/controls/slots/authoring.js +2 -1
  48. package/dist/controls/slots/authoring.js.map +1 -1
  49. package/dist/controls/typography/actions.js +18 -10
  50. package/dist/controls/typography/actions.js.map +1 -1
  51. package/dist/controls/typography/axes.d.ts.map +1 -1
  52. package/dist/controls/typography/axes.js +62 -19
  53. package/dist/controls/typography/axes.js.map +1 -1
  54. package/dist/editor/commands/registry.d.ts +1 -0
  55. package/dist/editor/commands/registry.d.ts.map +1 -1
  56. package/dist/editor/commands/registry.js +1 -0
  57. package/dist/editor/commands/registry.js.map +1 -1
  58. package/dist/editor/commands/selection.js +12 -3
  59. package/dist/editor/commands/selection.js.map +1 -1
  60. package/dist/editor/commands/types.d.ts +1 -1
  61. package/dist/editor/commands/types.d.ts.map +1 -1
  62. package/dist/editor/menu-model/canvas.js +5 -1
  63. package/dist/editor/menu-model/canvas.js.map +1 -1
  64. package/dist/editor/selection-capabilities/use.d.ts +1 -0
  65. package/dist/editor/selection-capabilities/use.js +4 -0
  66. package/dist/editor/selection-capabilities/use.js.map +1 -1
  67. package/dist/editor/selection-state/nodes.js +2 -2
  68. package/dist/editor/selection-state/nodes.js.map +1 -1
  69. package/dist/i18n/locale.d.ts.map +1 -1
  70. package/dist/i18n/locale.js +16 -6
  71. package/dist/i18n/locale.js.map +1 -1
  72. package/dist/i18n/locales/de/ai.json.js +3 -0
  73. package/dist/i18n/locales/de/cloud/portal.json.js +1 -1
  74. package/dist/i18n/locales/de/commands.json.js +1 -0
  75. package/dist/i18n/locales/de/comments.json.js +1 -0
  76. package/dist/i18n/locales/de/editor.json.js +2 -2
  77. package/dist/i18n/locales/de/menu.json.js +1 -1
  78. package/dist/i18n/locales/de/variables/panel.json.js +2 -0
  79. package/dist/i18n/locales/es/ai.json.js +3 -0
  80. package/dist/i18n/locales/es/cloud/portal.json.js +1 -1
  81. package/dist/i18n/locales/es/commands.json.js +1 -0
  82. package/dist/i18n/locales/es/comments.json.js +1 -0
  83. package/dist/i18n/locales/es/editor.json.js +2 -2
  84. package/dist/i18n/locales/es/menu.json.js +1 -1
  85. package/dist/i18n/locales/es/variables/panel.json.js +2 -0
  86. package/dist/i18n/locales/fr/ai.json.js +3 -0
  87. package/dist/i18n/locales/fr/cloud/portal.json.js +1 -1
  88. package/dist/i18n/locales/fr/commands.json.js +1 -0
  89. package/dist/i18n/locales/fr/comments.json.js +1 -0
  90. package/dist/i18n/locales/fr/editor.json.js +2 -2
  91. package/dist/i18n/locales/fr/menu.json.js +1 -1
  92. package/dist/i18n/locales/fr/variables/panel.json.js +2 -0
  93. package/dist/i18n/locales/it/ai.json.js +3 -0
  94. package/dist/i18n/locales/it/cloud/portal.json.js +1 -1
  95. package/dist/i18n/locales/it/commands.json.js +1 -0
  96. package/dist/i18n/locales/it/comments.json.js +1 -0
  97. package/dist/i18n/locales/it/editor.json.js +2 -2
  98. package/dist/i18n/locales/it/menu.json.js +1 -1
  99. package/dist/i18n/locales/it/variables/panel.json.js +2 -0
  100. package/dist/i18n/locales/ja/ai.json.js +3 -0
  101. package/dist/i18n/locales/ja/cloud/portal.json.js +1 -1
  102. package/dist/i18n/locales/ja/commands.json.js +1 -0
  103. package/dist/i18n/locales/ja/comments.json.js +1 -0
  104. package/dist/i18n/locales/ja/editor.json.js +2 -2
  105. package/dist/i18n/locales/ja/menu.json.js +1 -1
  106. package/dist/i18n/locales/ja/variables/panel.json.js +2 -0
  107. package/dist/i18n/locales/pl/ai.json.js +3 -0
  108. package/dist/i18n/locales/pl/cloud/portal.json.js +1 -1
  109. package/dist/i18n/locales/pl/commands.json.js +1 -0
  110. package/dist/i18n/locales/pl/comments.json.js +1 -0
  111. package/dist/i18n/locales/pl/editor.json.js +2 -2
  112. package/dist/i18n/locales/pl/menu.json.js +1 -1
  113. package/dist/i18n/locales/pl/variables/panel.json.js +2 -0
  114. package/dist/i18n/locales/ru/ai.json.js +3 -0
  115. package/dist/i18n/locales/ru/cloud/portal.json.js +1 -1
  116. package/dist/i18n/locales/ru/commands.json.js +1 -0
  117. package/dist/i18n/locales/ru/comments.json.js +1 -0
  118. package/dist/i18n/locales/ru/editor.json.js +2 -2
  119. package/dist/i18n/locales/ru/menu.json.js +1 -1
  120. package/dist/i18n/locales/ru/variables/panel.json.js +2 -0
  121. package/dist/i18n/locales/zh-cn/ai.json.js +3 -0
  122. package/dist/i18n/locales/zh-cn/cloud/portal.json.js +1 -1
  123. package/dist/i18n/locales/zh-cn/commands.json.js +1 -0
  124. package/dist/i18n/locales/zh-cn/comments.json.js +1 -0
  125. package/dist/i18n/locales/zh-cn/editor.json.js +2 -2
  126. package/dist/i18n/locales/zh-cn/menu.json.js +1 -1
  127. package/dist/i18n/locales/zh-cn/variables/panel.json.js +2 -0
  128. package/dist/i18n/messages/ai.d.ts +6 -0
  129. package/dist/i18n/messages/ai.d.ts.map +1 -1
  130. package/dist/i18n/messages/ai.js +4 -0
  131. package/dist/i18n/messages/ai.js.map +1 -1
  132. package/dist/i18n/messages/cloud/portal.d.ts +1 -1
  133. package/dist/i18n/messages/cloud/portal.js +1 -1
  134. package/dist/i18n/messages/cloud/portal.js.map +1 -1
  135. package/dist/i18n/messages/commands.d.ts +1 -0
  136. package/dist/i18n/messages/commands.d.ts.map +1 -1
  137. package/dist/i18n/messages/commands.js +1 -0
  138. package/dist/i18n/messages/commands.js.map +1 -1
  139. package/dist/i18n/messages/comments.d.ts +1 -0
  140. package/dist/i18n/messages/comments.d.ts.map +1 -1
  141. package/dist/i18n/messages/comments.js +1 -0
  142. package/dist/i18n/messages/comments.js.map +1 -1
  143. package/dist/i18n/messages/editor.d.ts +1 -1
  144. package/dist/i18n/messages/editor.js +1 -1
  145. package/dist/i18n/messages/editor.js.map +1 -1
  146. package/dist/i18n/messages/menu.d.ts +1 -1
  147. package/dist/i18n/messages/menu.js +1 -1
  148. package/dist/i18n/messages/menu.js.map +1 -1
  149. package/dist/i18n/messages/panels.d.ts +1 -1
  150. package/dist/i18n/messages/panels.js +1 -1
  151. package/dist/i18n/messages/panels.js.map +1 -1
  152. package/dist/i18n/messages/variables/panel.d.ts +2 -0
  153. package/dist/i18n/messages/variables/panel.d.ts.map +1 -1
  154. package/dist/i18n/messages/variables/panel.js +2 -0
  155. package/dist/i18n/messages/variables/panel.js.map +1 -1
  156. package/dist/i18n/messages.d.ts +13 -4
  157. package/dist/i18n/useI18n.d.ts +48 -14
  158. package/dist/i18n/useI18n.d.ts.map +1 -1
  159. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts +12 -2
  160. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.d.ts.map +1 -1
  161. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js +39 -10
  162. package/dist/primitives/ColorPicker/ColorPickerRoot.vue.js.map +1 -1
  163. package/dist/primitives/ColorPicker/gesture.d.ts +40 -0
  164. package/dist/primitives/ColorPicker/gesture.d.ts.map +1 -0
  165. package/dist/primitives/ColorPicker/gesture.js +120 -0
  166. package/dist/primitives/ColorPicker/gesture.js.map +1 -0
  167. package/dist/primitives/ColorPicker/index.d.ts +2 -1
  168. package/dist/primitives/ColorPicker/index.js +2 -1
  169. package/dist/primitives/Fill/FillSwatch.vue.d.ts.map +1 -1
  170. package/dist/primitives/Fill/FillSwatch.vue.js +6 -1
  171. package/dist/primitives/Fill/FillSwatch.vue.js.map +1 -1
  172. package/dist/primitives/Fill/types.d.ts +5 -0
  173. package/dist/primitives/Fill/types.d.ts.map +1 -1
  174. package/dist/primitives/Fill/useFill.d.ts.map +1 -1
  175. package/dist/primitives/Fill/useFill.js +15 -7
  176. package/dist/primitives/Fill/useFill.js.map +1 -1
  177. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts +1 -0
  178. package/dist/primitives/FontPicker/FontPickerRoot.vue.d.ts.map +1 -1
  179. package/dist/primitives/FontPicker/FontPickerRoot.vue.js +7 -2
  180. package/dist/primitives/FontPicker/FontPickerRoot.vue.js.map +1 -1
  181. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts +2 -0
  182. package/dist/primitives/LayerTree/LayerTreeRoot.vue.d.ts.map +1 -1
  183. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js +14 -3
  184. package/dist/primitives/LayerTree/LayerTreeRoot.vue.js.map +1 -1
  185. package/dist/primitives/LayerTree/model.js +1 -1
  186. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.d.ts.map +1 -1
  187. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js +1 -0
  188. package/dist/primitives/LayoutControls/LayoutControlsRoot.vue.js.map +1 -1
  189. package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts +2 -2
  190. package/dist/primitives/NumberField/NumberFieldRoot.vue.d.ts.map +1 -1
  191. package/dist/primitives/NumberField/NumberFieldRoot.vue.js +3 -2
  192. package/dist/primitives/NumberField/NumberFieldRoot.vue.js.map +1 -1
  193. package/dist/primitives/NumberField/types.d.ts +5 -0
  194. package/dist/primitives/NumberField/types.d.ts.map +1 -1
  195. package/dist/primitives/PageList/PageListRoot.vue.d.ts +3 -3
  196. package/dist/primitives/PageList/PageListRoot.vue.d.ts.map +1 -1
  197. package/dist/primitives/PageList/PageListRoot.vue.js +3 -2
  198. package/dist/primitives/PageList/PageListRoot.vue.js.map +1 -1
  199. package/dist/primitives/PageList/usePageList.d.ts +1 -1
  200. package/dist/primitives/PageList/usePageList.d.ts.map +1 -1
  201. package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts +1 -0
  202. package/dist/primitives/PositionControls/PositionControlsRoot.vue.d.ts.map +1 -1
  203. package/dist/primitives/PositionControls/PositionControlsRoot.vue.js +11 -13
  204. package/dist/primitives/PositionControls/PositionControlsRoot.vue.js.map +1 -1
  205. package/dist/primitives/PropertyList/PropertyListRoot.vue.d.ts.map +1 -1
  206. package/dist/primitives/PropertyList/PropertyListRoot.vue.js +10 -1
  207. package/dist/primitives/PropertyList/PropertyListRoot.vue.js.map +1 -1
  208. package/dist/primitives/PropertyList/index.d.ts +2 -2
  209. package/dist/primitives/PropertyList/types.d.ts +14 -2
  210. package/dist/primitives/PropertyList/types.d.ts.map +1 -1
  211. package/dist/shared/input/drop-target.js +2 -1
  212. package/dist/shared/input/drop-target.js.map +1 -1
  213. package/dist/shared/input/duplicate-drag.js.map +1 -1
  214. package/dist/shared/input/move/drag.js +25 -4
  215. package/dist/shared/input/move/drag.js.map +1 -1
  216. package/dist/shared/input/resize/start.js +2 -1
  217. package/dist/shared/input/resize/start.js.map +1 -1
  218. package/dist/shared/input/select/move.js +8 -3
  219. package/dist/shared/input/select/move.js.map +1 -1
  220. package/dist/shared/input/select.js +22 -12
  221. package/dist/shared/input/select.js.map +1 -1
  222. package/dist/shared/input/types.d.ts +2 -0
  223. package/dist/shared/input/types.d.ts.map +1 -1
  224. package/dist/shared/input/types.js.map +1 -1
  225. package/dist/variables/use.d.ts.map +1 -1
  226. package/dist/variables/use.js +2 -1
  227. package/dist/variables/use.js.map +1 -1
  228. package/package.json +4 -4
@@ -5,17 +5,17 @@ type __VLS_Slots = NumberFieldRootSlots;
5
5
  declare const __VLS_base: import("vue").DefineComponent<NumberFieldRootProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
6
  invalid: (expression: string, reason: NumberExpressionError) => any;
7
7
  cancel: () => any;
8
+ commit: (value: number, previous: number, unit?: string | undefined) => any;
8
9
  "update:modelValue": (value: 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
+ onCommit?: ((value: number, previous: number, unit?: string | undefined) => any) | undefined;
15
16
  "onUpdate:modelValue"?: ((value: 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;EAC1D,MAAM,UAAU,QAAA,iBAAiB,mBAAmB,KAAA;EACpD,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,YAAY,IAAI,KAAK;EAC3B,MAAM,aAAa,IAAI,EAAE;EACzB,MAAM,WAAW,IAA6B,IAAI;EAClD,MAAM,gBAAgB,IAAkC,IAAI;EAC5D,MAAM,eAAe,IAAI,CAAC;EAE1B,MAAM,UAAU,eAAe,SAAS,MAAM,UAAU,WAAW,OAAO,QAAA,eAAe,QAAQ;EACjG,MAAM,eAAe,eAAe;GAClC,MAAM,WAAW,SAAS,cAAc;GACxC,IAAI,SAAS,MAAM,UAAU,WAAW,OAAO,aAAa,UAAU,OAAO;GAC7E,OAAO,OAAO,QAAA,eAAe,WAAW,Q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AAC;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(cancelDetachedInteraction)\nonDeactivated(cancelDetachedInteraction)\n</script>\n\n<template>\n <slot v-bind=\"slotProps\" />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,OAAO;EAGb,MAAM,mBAAmB,oBAAoB;EAC7C,MAAM,mBAAmB,yBAAiC;EAC1D,MAAM,UAAU,QAAA,iBAAiB,mBAAmB,KAAA;EACpD,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,YAAY,IAAI,KAAK;EAC3B,MAAM,aAAa,IAAI,EAAE;EACzB,MAAM,WAAW,IAA6B,IAAI;EAClD,MAAM,gBAAgB,IAAkC,IAAI;EAC5D,MAAM,eAAe,IAAI,CAAC;EAE1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S,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"}
@@ -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,SAAS,OAAO,0BAA0B,KAAK;;UAGhC,wBAAwB,UAAU;EACjD,OAAO,MAAM,oBAAoB;EACjC,MAAM,SAAS,qBAAqB;EACpC;EACA;;UAGe,sBAAsB,UAAU;;EAE/C,SAAS;;EAET,cAAc;;EAEd;;EAEA;;UAGe,0BAA0B,UAAU;EACnD,MAAM,oBAAoB;EAC1B;EACA;EACA;EACA;EACA,SAAS,wBAAwB"}
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;;UAGK;EACf,UAAU,SAAS,oBAAoB;IAAc;;EACrD,YAAY;EACZ,qBAAqB;EACrB,aAAa;IAAM;;;UAGJ,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;EAC7B,OAAO;;UAGQ,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,SAAS,OAAO,0BAA0B,KAAK;;UAGhC,wBAAwB,UAAU;EACjD,OAAO,MAAM,oBAAoB;EACjC,MAAM,SAAS,qBAAqB;EACpC;EACA;;UAGe,sBAAsB,UAAU;;EAE/C,SAAS;;EAET,cAAc;;EAEd;;EAEA;;UAGe,0BAA0B,UAAU;EACnD,MAAM,oBAAoB;EAC1B;EACA;EACA;EACA;EACA,SAAS,wBAAwB"}
@@ -1,4 +1,5 @@
1
1
  import { getWorldMatrix } from "@pairdraw/scene-graph/coordinate";
2
+ import { acceptsContent } from "@pairdraw/scene-graph/icons";
2
3
  import { cycleSafeParent } from "@pairdraw/scene-graph/instances";
3
4
  import Matrix from "@pairdraw/scene-graph/matrix";
4
5
  //#region src/shared/input/drop-target.ts
@@ -13,7 +14,7 @@ const NOT_DRAWN_INTO = /* @__PURE__ */ new Set([
13
14
  function acceptingTarget(target, editor) {
14
15
  if (!target) return null;
15
16
  const accepting = editor.graph.getNode(editor.acceptingParent(target.id));
16
- if (!accepting || accepting.type === "CANVAS" || !editor.acceptsChildren(accepting.id)) return null;
17
+ if (!accepting || !acceptsContent(accepting) || !editor.acceptsChildren(accepting.id)) return null;
17
18
  return accepting;
18
19
  }
19
20
  /** The frame a dragged layer lands in under the cursor; null is the page. */
@@ -1 +1 @@
1
- {"version":3,"file":"drop-target.js","names":[],"sources":["../../../src/shared/input/drop-target.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport type { NodeType, SceneNode } from '@pairdraw/scene-graph'\nimport { getWorldMatrix } from '@pairdraw/scene-graph/coordinate'\nimport { cycleSafeParent } from '@pairdraw/scene-graph/instances'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\n/** Parents a layer stays in while dragged until it lands on another frame. */\nconst ENCLOSING_TYPES = new Set<NodeType>(['GROUP', 'BOOLEAN_OPERATION'])\n/** Containers that never take a drawn layer. */\nconst NOT_DRAWN_INTO = new Set<NodeType>(['GROUP', 'BOOLEAN_OPERATION', 'COMPONENT_SET'])\n\nfunction acceptingTarget(target: SceneNode | null, editor: Editor): SceneNode | null {\n if (!target) return null\n // Only an instance's slots take layers; anywhere else in it drops into its parent.\n const accepting = editor.graph.getNode(editor.acceptingParent(target.id))\n if (!accepting || accepting.type === 'CANVAS' || !editor.acceptsChildren(accepting.id))\n return null\n return accepting\n}\n\n/** The frame a dragged layer lands in under the cursor; null is the page. */\nexport function findMoveDropTarget(\n cx: number,\n cy: number,\n editor: Editor,\n excludeIds: ReadonlySet<string> = editor.state.selectedIds\n): SceneNode | null {\n const moving = [...excludeIds].map((id) => editor.graph.getNode(id))\n const components = moving.length > 0 && moving.every((node) => node?.type === 'COMPONENT')\n const componentSetIds = components\n ? new Set(moving.flatMap((node) => (node?.parentId ? [node.parentId] : [])))\n : undefined\n let dropTarget = editor.graph.hitTestDropTarget(cx, cy, excludeIds, editor.state.currentPageId, {\n componentSetIds\n })\n const movingSection = moving.some((node) => node?.type === 'SECTION')\n if (movingSection && dropTarget && dropTarget.type !== 'SECTION') {\n dropTarget = null\n }\n return cycleSafeTarget(acceptingTarget(dropTarget, editor), [...excludeIds], editor)\n}\n\n/**\n * The target, or its nearest ancestor these layers can go into without a component containing\n * itself; null is the page.\n */\nexport function cycleSafeTarget(\n target: SceneNode | null,\n ids: readonly string[],\n editor: Editor\n): SceneNode | null {\n if (!target) return null\n const safe = editor.graph.getNode(cycleSafeParent(editor.graph, target.id, ids))\n return safe && safe.type !== 'CANVAS' ? safe : null\n}\n\nfunction takesDrawnLayer(target: SceneNode, type: NodeType) {\n if (NOT_DRAWN_INTO.has(target.type)) return false\n // Sections only go into pages and other sections.\n return type !== 'SECTION' || target.type === 'SECTION'\n}\n\n/** The parent a new layer drawn from this point goes into. */\nexport function findDrawParent(cx: number, cy: number, type: NodeType, editor: Editor): string {\n let target = editor.graph.hitTestDropTarget(cx, cy, new Set(), editor.state.currentPageId)\n while (target && target.type !== 'CANVAS' && !takesDrawnLayer(target, type)) {\n target = target.parentId ? (editor.graph.getNode(target.parentId) ?? null) : null\n }\n return acceptingTarget(target, editor)?.id ?? editor.state.currentPageId\n}\n\n/** Whether every canvas point lies inside the container's own box, rotated or flipped with it. */\nfunction holdsPoints(target: SceneNode, points: readonly Vector[], editor: Editor): boolean {\n const toLocal = Matrix.invert(getWorldMatrix(target, editor.graph))\n if (!toLocal) return false\n const local = Matrix.mapPoints(\n toLocal,\n points.flatMap((point) => [point.x, point.y])\n )\n for (let i = 0; i < local.length; i += 2) {\n const [x, y] = [local[i], local[i + 1]]\n if (x < 0 || y < 0 || x > target.width || y > target.height) return false\n }\n return true\n}\n\n/**\n * The parent a layer drawn through `points` goes into: the one it would go into from the first\n * point, or the nearest container above that holds all of them, as Figma places a pencil stroke.\n */\nexport function findEnclosingDrawParent(\n points: readonly Vector[],\n type: NodeType,\n editor: Editor\n): string {\n const pageId = editor.state.currentPageId\n const start = points.at(0)\n if (!start) return pageId\n let target = editor.graph.getNode(findDrawParent(start.x, start.y, type, editor))\n while (target && target.type !== 'CANVAS') {\n if (holdsPoints(target, points, editor)) return target.id\n let parent = target.parentId ? editor.graph.getNode(target.parentId) : undefined\n while (parent && parent.type !== 'CANVAS' && !takesDrawnLayer(parent, type)) {\n parent = parent.parentId ? editor.graph.getNode(parent.parentId) : undefined\n }\n target = acceptingTarget(parent ?? null, editor) ?? undefined\n }\n return pageId\n}\n\n/** The frame or page that holds a layer, looking past the groups it sits in. */\nfunction enclosingContainer(id: string, editor: Editor): string {\n let parent = editor.graph.getNode(editor.graph.getNode(id)?.parentId ?? '')\n while (parent?.parentId && ENCLOSING_TYPES.has(parent.type)) {\n parent = editor.graph.getNode(parent.parentId)\n }\n return parent?.id ?? editor.state.currentPageId\n}\n\n/**\n * Moves dropped layers into the frame under the cursor, or onto the page. A layer that lands in\n * the frame already holding it keeps its group.\n */\nexport function reparentDroppedNodes(editor: Editor, ids: string[], targetId: string | null) {\n const target = targetId ?? editor.state.currentPageId\n const moving = ids.filter((id) => enclosingContainer(id, editor) !== target)\n if (moving.length > 0) editor.reparentNodes(moving, target)\n}\n"],"mappings":";;;;;AAQA,MAAM,kCAAkB,IAAI,IAAc,CAAC,SAAS,mBAAmB,CAAC;;AAExE,MAAM,iCAAiB,IAAI,IAAc;CAAC;CAAS;CAAqB;AAAe,CAAC;AAExF,SAAS,gBAAgB,QAA0B,QAAkC;CACnF,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,YAAY,OAAO,MAAM,QAAQ,OAAO,gBAAgB,OAAO,EAAE,CAAC;CACxE,IAAI,CAAC,aAAa,UAAU,SAAS,YAAY,CAAC,OAAO,gBAAgB,UAAU,EAAE,GACnF,OAAO;CACT,OAAO;AACT;;AAGA,SAAgB,mBACd,IACA,IACA,QACA,aAAkC,OAAO,MAAM,aAC7B;CAClB,MAAM,SAAS,CAAC,GAAG,UAAU,CA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OAAO,MAAM;AACpC;;;;;AAMA,SAAgB,qBAAqB,QAAgB,KAAe,UAAyB;CAC3F,MAAM,SAAS,YAAY,OAAO,MAAM;CACxC,MAAM,SAAS,IAAI,QAAQ,OAAO,mBAAmB,IAAI,MAAM,MAAM,MAAM;CAC3E,IAAI,OAAO,SAAS,GAAG,OAAO,cAAc,QAAQ,MAAM;AAC5D"}
1
+ {"version":3,"file":"drop-target.js","names":[],"sources":["../../../src/shared/input/drop-target.ts"],"sourcesContent":["import type { Editor } from '@pairdraw/core'\nimport type { NodeType, SceneNode } from '@pairdraw/scene-graph'\nimport { getWorldMatrix } from '@pairdraw/scene-graph/coordinate'\nimport { acceptsContent } from '@pairdraw/scene-graph/icons'\nimport { cycleSafeParent } from '@pairdraw/scene-graph/instances'\nimport Matrix from '@pairdraw/scene-graph/matrix'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\n\n/** Parents a layer stays in while dragged until it lands on another frame. */\nconst ENCLOSING_TYPES = new Set<NodeType>(['GROUP', 'BOOLEAN_OPERATION'])\n/** Containers that never take a drawn layer. */\nconst NOT_DRAWN_INTO = new Set<NodeType>(['GROUP', 'BOOLEAN_OPERATION', 'COMPONENT_SET'])\n\nfunction acceptingTarget(target: SceneNode | null, editor: Editor): SceneNode | null {\n if (!target) return null\n // Only an instance's slots take layers; anywhere else in it drops into its parent.\n const accepting = editor.graph.getNode(editor.acceptingParent(target.id))\n // An icon frame holds only its glyph, so a layer lands on the page instead.\n if (!accepting || !acceptsContent(accepting) || !editor.acceptsChildren(accepting.id)) return null\n return accepting\n}\n\n/** The frame a dragged layer lands in under the cursor; null is the page. */\nexport function findMoveDropTarget(\n cx: number,\n cy: number,\n editor: Editor,\n excludeIds: ReadonlySet<string> = editor.state.selectedIds\n): SceneNode | null {\n const moving = [...excludeIds].map((id) => editor.graph.getNode(id))\n const components = moving.length > 0 && moving.every((node) => node?.type === 'COMPONENT')\n const componentSetIds = components\n ? new Set(moving.flatMap((node) => (node?.parentId ? [node.parentId] : [])))\n : undefined\n let dropTarget = editor.graph.hitTestDropTarget(cx, cy, excludeIds, editor.state.currentPageId, {\n componentSetIds\n })\n const movingSection = moving.some((node) => node?.type === 'SECTION')\n if (movingSection && dropTarget && dropTarget.type !== 'SECTION') {\n dropTarget = null\n }\n return cycleSafeTarget(acceptingTarget(dropTarget, editor), [...excludeIds], editor)\n}\n\n/**\n * The target, or its nearest ancestor these layers can go into without a component containing\n * itself; null is the page.\n */\nexport function cycleSafeTarget(\n target: SceneNode | null,\n ids: readonly string[],\n editor: Editor\n): SceneNode | null {\n if (!target) return null\n const safe = editor.graph.getNode(cycleSafeParent(editor.graph, target.id, ids))\n return safe && safe.type !== 'CANVAS' ? safe : null\n}\n\nfunction takesDrawnLayer(target: SceneNode, type: NodeType) {\n if (NOT_DRAWN_INTO.has(target.type)) return false\n // Sections only go into pages and other sections.\n return type !== 'SECTION' || target.type === 'SECTION'\n}\n\n/** The parent a new layer drawn from this point goes into. */\nexport function findDrawParent(cx: number, cy: number, type: NodeType, editor: Editor): string {\n let target = editor.graph.hitTestDropTarget(cx, cy, new Set(), editor.state.currentPageId)\n while (target && target.type !== 'CANVAS' && !takesDrawnLayer(target, type)) {\n target = target.parentId ? (editor.graph.getNode(target.parentId) ?? null) : null\n }\n return acceptingTarget(target, editor)?.id ?? editor.state.currentPageId\n}\n\n/** Whether every canvas point lies inside the container's own box, rotated or flipped with it. */\nfunction holdsPoints(target: SceneNode, points: readonly Vector[], editor: Editor): boolean {\n const toLocal = Matrix.invert(getWorldMatrix(target, editor.graph))\n if (!toLocal) return false\n const local = Matrix.mapPoints(\n toLocal,\n points.flatMap((point) => [point.x, point.y])\n )\n for (let i = 0; i < local.length; i += 2) {\n const [x, y] = [local[i], local[i + 1]]\n if (x < 0 || y < 0 || x > target.width || y > target.height) return false\n }\n return true\n}\n\n/**\n * The parent a layer drawn through `points` goes into: the one it would go into from the first\n * point, or the nearest container above that holds all of them, as Figma places a pencil stroke.\n */\nexport function findEnclosingDrawParent(\n points: readonly Vector[],\n type: NodeType,\n editor: Editor\n): string {\n const pageId = editor.state.currentPageId\n const start = points.at(0)\n if (!start) return pageId\n let target = editor.graph.getNode(findDrawParent(start.x, start.y, type, editor))\n while (target && target.type !== 'CANVAS') {\n if (holdsPoints(target, points, editor)) return target.id\n let parent = target.parentId ? editor.graph.getNode(target.parentId) : undefined\n while (parent && parent.type !== 'CANVAS' && !takesDrawnLayer(parent, type)) {\n parent = parent.parentId ? editor.graph.getNode(parent.parentId) : undefined\n }\n target = acceptingTarget(parent ?? null, editor) ?? undefined\n }\n return pageId\n}\n\n/** The frame or page that holds a layer, looking past the groups it sits in. */\nfunction enclosingContainer(id: string, editor: Editor): string {\n let parent = editor.graph.getNode(editor.graph.getNode(id)?.parentId ?? '')\n while (parent?.parentId && ENCLOSING_TYPES.has(parent.type)) {\n parent = editor.graph.getNode(parent.parentId)\n }\n return parent?.id ?? editor.state.currentPageId\n}\n\n/**\n * Moves dropped layers into the frame under the cursor, or onto the page. A layer that lands in\n * the frame already holding it keeps its group.\n */\nexport function reparentDroppedNodes(editor: Editor, ids: string[], targetId: string | null) {\n const target = targetId ?? editor.state.currentPageId\n const moving = ids.filter((id) => enclosingContainer(id, editor) !== target)\n if (moving.length > 0) editor.reparentNodes(moving, target)\n}\n"],"mappings":";;;;;;AASA,MAAM,kCAAkB,IAAI,IAAc,CAAC,SAAS,mBAAmB,CAAC;;AAExE,MAAM,iCAAiB,IAAI,IAAc;CAAC;CAAS;CAAqB;AAAe,CAAC;AAExF,SAAS,gBAAgB,QAA0B,QAAkC;CACnF,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,YAAY,OAAO,MAAM,QAAQ,OAAO,gBAAgB,OAAO,EAAE,CAAC;CAExE,IAAI,CAAC,aAAa,CAAC,eAAe,SAAS,KAAK,CAAC,OAAO,gBAAgB,UAAU,EAAE,GAAG,OAAO;CAC9F,OAAO;AACT;;AAGA,SAAgB,mBACd,IACA,IACA,QACA,aAAkC,OAAO,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AAM,QAAQ,OAAO,QAAQ;CAE/C,OAAO,QAAQ,MAAM,OAAO,MAAM;AACpC;;;;;AAMA,SAAgB,qBAAqB,QAAgB,KAAe,UAAyB;CAC3F,MAAM,SAAS,YAAY,OAAO,MAAM;CACxC,MAAM,SAAS,IAAI,QAAQ,OAAO,mBAAmB,IAAI,MAAM,MAAM,MAAM;CAC3E,IAAI,OAAO,SAAS,GAAG,OAAO,cAAc,QAAQ,MAAM;AAC5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"duplicate-drag.js","names":[],"sources":["../../../src/shared/input/duplicate-drag.ts"],"sourcesContent":["import type { Editor, MovePlace } from '@pairdraw/core'\n\nimport type { DragState } from '#vue/shared/input/types'\n\nexport function duplicateAndDrag(\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor\n): { originals: Map<string, MovePlace>; drag: DragState } {\n const previousSelection = new Set(editor.state.selectedIds)\n const newIds: string[] = []\n const newOriginals = new Map<string, MovePlace>()\n for (const id of previousSelection) {\n const source = editor.graph.getNode(id)\n if (!source) continue\n const parentId = source.parentId ?? editor.state.currentPageId\n const clone = editor.duplicateNode(source, parentId, { x: source.x, y: source.y })\n if (!clone) continue\n newIds.push(clone.id)\n newOriginals.set(clone.id, {\n x: source.x,\n y: source.y,\n parentId\n })\n }\n editor.select(newIds)\n editor.requestRender()\n return {\n originals: newOriginals,\n drag: {\n type: 'move',\n startX: cx,\n startY: cy,\n currentX: cx,\n currentY: cy,\n appliedDx: 0,\n appliedDy: 0,\n startScreenX: sx,\n startScreenY: sy,\n dragStarted: true,\n originals: newOriginals,\n duplicated: true,\n duplicatedPreviousSelection: previousSelection\n }\n }\n}\n"],"mappings":";AAIA,SAAgB,iBACd,IACA,IACA,IACA,IACA,QACwD;CACxD,MAAM,oBAAoB,IAAI,IAAI,OAAO,MAAM,WAAW;CAC1D,MAAM,SAAmB,CAAC;CAC1B,MAAM,+BAAe,IAAI,IAAuB;CAChD,KAAK,MAAM,MAAM,mBAAmB;EAClC,MAAM,SAAS,OAAO,MAAM,QAAQ,EAAE;EACtC,IAAI,CAAC,QAAQ;EACb,MAAM,WAAW,OAAO,YAAY,OAAO,MAAM;EACjD,MAAM,QAAQ,OAAO,cAAc,QAAQ,UAAU;GAAE,GAAG,OAAO;GAAG,GAAG,OAAO;EAAE,CAAC;EACjF,IAAI,CAAC,OAAO;EACZ,OAAO,KAAK,MAAM,EAAE;EACpB,aAAa,IAAI,MAAM,IAAI;GACzB,GAAG,OAAO;GACV,GAAG,OAAO;GACV;EACF,CAAC;CACH;CACA,OAAO,OAAO,MAAM;CACpB,OAAO,cAAc;CACrB,OAAO;EACL,WAAW;EACX,MAAM;GACJ,MAAM;GACN,QAAQ;GACR,QAAQ;GACR,UAAU;GACV,UAAU;GACV,WAAW;GACX,WAAW;GACX,cAAc;GACd,cAAc;GACd,aAAa;GACb,WAAW;GACX,YAAY;GACZ,6BAA6B;EAC/B;CACF;AACF"}
1
+ {"version":3,"file":"duplicate-drag.js","names":[],"sources":["../../../src/shared/input/duplicate-drag.ts"],"sourcesContent":["import type { Editor, MovePlace } from '@pairdraw/core'\n\nimport type { DragMove } from '#vue/shared/input/types'\n\nexport function duplicateAndDrag(\n cx: number,\n cy: number,\n sx: number,\n sy: number,\n editor: Editor\n): { originals: Map<string, MovePlace>; drag: DragMove } {\n const previousSelection = new Set(editor.state.selectedIds)\n const newIds: string[] = []\n const newOriginals = new Map<string, MovePlace>()\n for (const id of previousSelection) {\n const source = editor.graph.getNode(id)\n if (!source) continue\n const parentId = source.parentId ?? editor.state.currentPageId\n const clone = editor.duplicateNode(source, parentId, { x: source.x, y: source.y })\n if (!clone) continue\n newIds.push(clone.id)\n newOriginals.set(clone.id, {\n x: source.x,\n y: source.y,\n parentId\n })\n }\n editor.select(newIds)\n editor.requestRender()\n return {\n originals: newOriginals,\n drag: {\n type: 'move',\n startX: cx,\n startY: cy,\n currentX: cx,\n currentY: cy,\n appliedDx: 0,\n appliedDy: 0,\n startScreenX: sx,\n startScreenY: sy,\n dragStarted: true,\n originals: newOriginals,\n duplicated: true,\n duplicatedPreviousSelection: previousSelection\n }\n }\n}\n"],"mappings":";AAIA,SAAgB,iBACd,IACA,IACA,IACA,IACA,QACuD;CACvD,MAAM,oBAAoB,IAAI,IAAI,OAAO,MAAM,WAAW;CAC1D,MAAM,SAAmB,CAAC;CAC1B,MAAM,+BAAe,IAAI,IAAuB;CAChD,KAAK,MAAM,MAAM,mBAAmB;EAClC,MAAM,SAAS,OAAO,MAAM,QAAQ,EAAE;EACtC,IAAI,CAAC,QAAQ;EACb,MAAM,WAAW,OAAO,YAAY,OAAO,MAAM;EACjD,MAAM,QAAQ,OAAO,cAAc,QAAQ,UAAU;GAAE,GAAG,OAAO;GAAG,GAAG,OAAO;EAAE,CAAC;EACjF,IAAI,CAAC,OAAO;EACZ,OAAO,KAAK,MAAM,EAAE;EACpB,aAAa,IAAI,MAAM,IAAI;GACzB,GAAG,OAAO;GACV,GAAG,OAAO;GACV;EACF,CAAC;CACH;CACA,OAAO,OAAO,MAAM;CACpB,OAAO,cAAc;CACrB,OAAO;EACL,WAAW;EACX,MAAM;GACJ,MAAM;GACN,QAAQ;GACR,QAAQ;GACR,UAAU;GACV,UAAU;GACV,WAAW;GACX,WAAW;GACX,cAAc;GACd,cAAc;GACd,aAAa;GACb,WAAW;GACX,YAAY;GACZ,6BAA6B;EAC/B;CACF;AACF"}
@@ -229,12 +229,26 @@ function cancelMove(d, editor) {
229
229
  editor.setDropTarget(null);
230
230
  editor.requestRender();
231
231
  }
232
+ function isFlowClick(d, flows, slots) {
233
+ return flows.every((flow, i) => slots[i] === flow.start) && getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP;
234
+ }
235
+ function deselectClicked(d, editor) {
236
+ if (d.clickDeselectsId && editor.state.selectedIds.has(d.clickDeselectsId)) editor.select([d.clickDeselectsId], true);
237
+ }
238
+ function discardDuplicates(d, editor) {
239
+ const previousSelection = d.duplicatedPreviousSelection ?? /* @__PURE__ */ new Set();
240
+ for (const id of [...d.originals.keys()].toReversed()) editor.graph.deleteNode(id);
241
+ editor.select([...previousSelection].filter((id) => id !== d.clickDeselectsId));
242
+ editor.requestRender();
243
+ editor.setDropTarget(null);
244
+ }
232
245
  function handleMoveUp(d, editor) {
233
246
  if (!d.dragStarted) {
234
247
  editor.setLayoutInsertIndicator(null);
235
248
  editor.setSnapGuides([]);
236
249
  editor.setDropTarget(null);
237
250
  if (d.selectOnClick) editor.select([d.selectOnClick]);
251
+ deselectClicked(d, editor);
238
252
  return;
239
253
  }
240
254
  const indicator = editor.state.layoutInsertIndicator;
@@ -243,11 +257,17 @@ function handleMoveUp(d, editor) {
243
257
  if (d.flows && d.flowSlots && !d.brokeFromAutoLayout) {
244
258
  dropAlongFlows(d, d.flows, editor);
245
259
  editor.setDropTarget(null);
260
+ if (isFlowClick(d, d.flows, d.flowSlots)) deselectClicked(d, editor);
246
261
  return;
247
262
  }
248
263
  if (indicator) {
249
264
  if (getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP) {
265
+ if (d.duplicated) {
266
+ discardDuplicates(d, editor);
267
+ return;
268
+ }
250
269
  editor.setDropTarget(null);
270
+ deselectClicked(d, editor);
251
271
  return;
252
272
  }
253
273
  editor.undo.runBatch("Reorder", () => {
@@ -258,11 +278,12 @@ function handleMoveUp(d, editor) {
258
278
  }
259
279
  const moved = hasMoved(d, editor);
260
280
  if (d.duplicated && !moved) {
261
- const previousSelection = d.duplicatedPreviousSelection ?? /* @__PURE__ */ new Set();
262
- for (const id of [...d.originals.keys()].toReversed()) editor.graph.deleteNode(id);
263
- editor.select([...previousSelection]);
264
- editor.requestRender();
281
+ discardDuplicates(d, editor);
282
+ return;
283
+ }
284
+ if (!moved && !d.duplicated && getMoveDistance(d) < AUTO_LAYOUT_REORDER_CLICK_SLOP) {
265
285
  editor.setDropTarget(null);
286
+ deselectClicked(d, editor);
266
287
  return;
267
288
  }
268
289
  editor.undo.runBatch(d.duplicated ? "Duplicate" : "Move", () => {