@m3ui-vue/m3ui-vue 1.3.3 → 1.3.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m3ui-vue/m3ui-vue",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Material 3 component library for Vue 3 + Tailwind CSS v4",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,6 +42,44 @@ describe('MFloorPlan', () => {
42
42
  expect(w.emitted('move')![0]![0]).toEqual([{ id: 1, x: 140, y: 140 }, { id: 2, x: 340, y: 140 }])
43
43
  expect((w.props('tables') as FloorTable[])[0]).toMatchObject({ x: 140, y: 140 })
44
44
  })
45
+ it('editable + selectable multiple: a click toggles a table in the selection, a drag moves that table alone', async () => {
46
+ const w = setup({ editable: true, selectable: 'multiple', dragMerged: true, merges: [{ id: 'm', tables: [1, 2] }], grid: 20, selection: [], 'onUpdate:selection': (v: unknown) => w.setProps({ selection: v as number[] }) })
47
+ const press = (label: string, dx = 0) => {
48
+ table(w, label).element.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, button: 0, clientX: 0, clientY: 0, pointerId: 1 }))
49
+ if (dx) window.dispatchEvent(new PointerEvent('pointermove', { clientX: dx, clientY: 0, pointerId: 1 }))
50
+ window.dispatchEvent(new PointerEvent('pointerup', { clientX: dx, clientY: 0, pointerId: 1 }))
51
+ }
52
+ // A press alone doesn't change the selection; the click toggles
53
+ press('T1')
54
+ expect(w.props('selection')).toEqual([])
55
+ await table(w, 'T1').trigger('click')
56
+ await table(w, 'T2').trigger('click')
57
+ expect(w.props('selection')).toEqual([1, 2])
58
+ await table(w, 'T1').trigger('click')
59
+ expect(w.props('selection')).toEqual([2])
60
+ // A drag moves only the table pressed: not the rest of the selection, nor its merge (dragMerged); the selection stays
61
+ await table(w, 'T1').trigger('click')
62
+ expect(w.props('selection')).toEqual([2, 1])
63
+ await new Promise((r) => setTimeout(r))
64
+ press('T2', 40)
65
+ await nextTick()
66
+ expect((w.props('tables') as FloorTable[]).map((t) => t.x)).toEqual([100, 340])
67
+ await new Promise((r) => setTimeout(r))
68
+ press('T1', 60)
69
+ await nextTick()
70
+ expect((w.props('tables') as FloorTable[]).map((t) => t.x)).toEqual([160, 340])
71
+ expect(w.props('selection')).toEqual([2, 1])
72
+ })
73
+ it('tableSnap cell: a dropped table sits in the middle of a grid square, and arrows keep it there', async () => {
74
+ const w = setup({ editable: true, grid: 20, tableSnap: 'cell', selection: [1], 'onUpdate:selection': (v: unknown) => w.setProps({ selection: v as number[] }) })
75
+ table(w, 'T1').element.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, button: 0, clientX: 0, clientY: 0, pointerId: 1 }))
76
+ window.dispatchEvent(new PointerEvent('pointermove', { clientX: 33, clientY: 47, pointerId: 1 }))
77
+ window.dispatchEvent(new PointerEvent('pointerup', { clientX: 33, clientY: 47, pointerId: 1 }))
78
+ await nextTick()
79
+ expect((w.props('tables') as FloorTable[])[0]).toMatchObject({ x: 130, y: 150 })
80
+ await table(w, 'T1').trigger('keydown', { key: 'ArrowRight' })
81
+ expect((w.props('tables') as FloorTable[])[0]).toMatchObject({ x: 150, y: 150 })
82
+ })
45
83
  it('editable: arrows nudge by the grid, and tables stay inside the plan', async () => {
46
84
  const w = setup({ editable: true, grid: 10 })
47
85
  await table(w, 'T1').trigger('keydown', { key: 'ArrowLeft' })
@@ -2,7 +2,9 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
2
2
  import { mount, flushPromises } from '@vue/test-utils'
3
3
  import { nextTick } from 'vue'
4
4
  import MFlow from '../components/MFlow.vue'
5
- import type { FlowEdge, FlowNode } from '../composables/useFlow'
5
+ import MFlowHandle from '../components/MFlowHandle.vue'
6
+ import type { FlowEdge, FlowNode, FlowXY } from '../composables/useFlow'
7
+ import { routePoints, pointsToRoute } from '../composables/flowPaths'
6
8
 
7
9
  // happy-dom has no layout: the canvas is 800×600 at the page's corner, every node 180×60
8
10
  beforeEach(() => {
@@ -16,7 +18,7 @@ beforeEach(() => {
16
18
  if (this.classList.contains('m3-flow')) return r(0, 0, 800, 600)
17
19
  if (this.classList.contains('m3-flow-handle')) {
18
20
  const c = this.className
19
- const [x, y] = c.includes('right-0') ? [180, 30] : c.includes('bottom-0') ? [90, 60] : c.includes('top-1/2') ? [0, 30] : [90, 0]
21
+ const [x, y] = c.includes('left-1/2') && c.includes('top-1/2') ? [90, 30] : c.includes('right-0') ? [180, 30] : c.includes('bottom-0') ? [90, 60] : c.includes('top-1/2') ? [0, 30] : [90, 0]
20
22
  return r(x - 5, y - 5, 10, 10)
21
23
  }
22
24
  return r(0, 0, 0, 0)
@@ -379,6 +381,112 @@ describe('MFlow', () => {
379
381
  expect(w.emitted('update:viewport')!.at(-1)![0]).toEqual({ x: start.x + 60, y: start.y, zoom })
380
382
  touch(window, 'pointerup', 3, 460, 400)
381
383
  })
384
+ it('edgesReroutable: dragging a selected step edge\'s segment gives it a route, which moves with both its nodes', async () => {
385
+ const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'smoothstep' }]
386
+ const w = await flow({ edges, edgesReroutable: true, selection: { nodes: [], edges: ['e1'] } })
387
+ await nextTick()
388
+ const grip = w.find('[data-flow-segment="0"]')
389
+ expect(grip.exists()).toBe(true)
390
+ pointer(grip.element, 'pointerdown', 240, 30)
391
+ pointer(window, 'pointermove', 240, 60)
392
+ pointer(window, 'pointermove', 240, 90)
393
+ pointer(window, 'pointerup', 240, 90)
394
+ const out = w.emitted('update:edges')!.at(-1)![0] as FlowEdge[]
395
+ // A jog a grid step from each handle, running where the pointer let go
396
+ expect(out[0]!.route).toEqual([200, 90, 280])
397
+ expect(w.emitted('reroute')![0]![0]).toMatchObject({ id: 'e1', route: [200, 90, 280] })
398
+ await w.setProps({ edges: out })
399
+ expect(w.find('.m3-flow-edge-line').attributes('d')).toMatch(/^M180,30 L/)
400
+ })
401
+ it('a segment grip moves out from under the delete button', async () => {
402
+ const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'smoothstep' }]
403
+ const w = await flow({ edges, edgesReroutable: true, selection: { nodes: [], edges: ['e1'] } })
404
+ await nextTick()
405
+ // The × sits at (240, 30), 40px wide with its hit area: the grip of the one segment (180 → 300) slides clear of it
406
+ const grip = w.find('[data-flow-segment="0"]')
407
+ const cx = Number(grip.attributes('x')) + 9
408
+ expect(Math.abs(cx - 240)).toBeGreaterThanOrEqual(20 + 9)
409
+ expect(cx).toBeGreaterThan(180)
410
+ expect(cx).toBeLessThan(300)
411
+ })
412
+ it('snapToGrid puts a node\'s position plus its gridOffset on the grid', async () => {
413
+ const w = await flow({ nodes: [N('a', 10, 10, { gridOffset: { x: 10, y: 10 } }), N('b', 300, 0)], snapToGrid: true, gridSize: 20 })
414
+ pointer(node(w, 'a'), 'pointerdown', 100, 40)
415
+ pointer(window, 'pointermove', 140, 80)
416
+ pointer(window, 'pointermove', 203, 143)
417
+ pointer(window, 'pointerup', 203, 143)
418
+ const nodes = w.emitted('update:nodes')!.at(-1)![0] as FlowNode[]
419
+ // Its middle (position + 10) sits on the 20px grid
420
+ expect(nodes.find((n) => n.id === 'a')!.position).toEqual({ x: 110, y: 110 })
421
+ })
422
+ it('getEdgeAt finds the edge under a point, where on it, and which way it runs', async () => {
423
+ const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'smoothstep' }]
424
+ const w = await flow({ edges, snapToGrid: true, gridSize: 20 })
425
+ const ctx = w.vm as unknown as { getEdgeAt: (p: FlowXY, o?: object) => unknown }
426
+ expect(ctx.getEdgeAt({ x: 243, y: 34 })).toMatchObject({ edge: { id: 'e1' }, position: { x: 240, y: 30 }, direction: 'right' })
427
+ expect(ctx.getEdgeAt({ x: 243, y: 60 })).toBeNull()
428
+ expect(ctx.getEdgeAt({ x: 243, y: 34 }, { ignore: (e: FlowEdge) => e.id === 'e1' })).toBeNull()
429
+ })
430
+ it('a tap on a handle selects its node; a drag from it still connects', async () => {
431
+ const w = await flow({ nodes: [N('a', 0, 0), N('b', 300, 0), N('c', 300, 200)] })
432
+ const out = w.find('[data-flow-node="a"] [data-flow-handle="source"]').element
433
+ pointer(out, 'pointerdown', 180, 30)
434
+ pointer(window, 'pointerup', 181, 30)
435
+ expect(w.emitted('update:selection')!.at(-1)![0]).toEqual({ nodes: ['a'], edges: [] })
436
+ expect(w.emitted('connect')).toBeUndefined()
437
+ // b's input already has e1: tapped (not pulled), it selects b and leaves e1 alone
438
+ pointer(w.find('[data-flow-node="b"] [data-flow-handle="target"]').element, 'pointerdown', 300, 30)
439
+ pointer(window, 'pointerup', 300, 30)
440
+ expect(w.emitted('update:selection')!.at(-1)![0]).toEqual({ nodes: ['b'], edges: [] })
441
+ expect(w.emitted('update:edges')).toBeUndefined()
442
+ })
443
+ it("a handle at position 'auto' leaves on the side facing the edge's other end", async () => {
444
+ const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'step', markerEnd: 'none' }]
445
+ const w = mount(MFlow, {
446
+ props: { nodes: [N('a', 0, 0, { type: 'dot' }), N('b', 300, 200)], edges, animate: false },
447
+ slots: { 'node-dot': `<template #node-dot><div style="width:180px;height:60px"><MFlowHandle type="source" position="auto" /></div></template>` },
448
+ global: { components: { MFlowHandle } },
449
+ attachTo: document.body,
450
+ })
451
+ await flushPromises()
452
+ await nextTick()
453
+ // From the middle of a (90, 30) toward b's left side (300, 230): it goes right first
454
+ expect(w.find('.m3-flow-edge-line').attributes('d')).toMatch(/^M90,30 L\d+/)
455
+ const first = () => w.find('.m3-flow-edge-line').attributes('d').match(/^M90,30 L(-?[\d.]+),(-?[\d.]+)/)!
456
+ expect(Number(first()[1])).toBeGreaterThan(90)
457
+ // b far below and only a little to the right: it goes down first
458
+ await w.setProps({ nodes: [N('a', 0, 0, { type: 'dot' }), N('b', 120, 600)] })
459
+ await nextTick()
460
+ expect(Number(first()[1])).toBe(90)
461
+ expect(Number(first()[2])).toBeGreaterThan(30)
462
+ // An edge can ask for its side: up first, whatever the other end
463
+ await w.setProps({ edges: [{ ...edges[0]!, sourcePosition: 'top' as const }] })
464
+ await nextTick()
465
+ expect(Number(first()[1])).toBe(90)
466
+ expect(Number(first()[2])).toBeLessThan(30)
467
+ })
468
+ it('routePoints / pointsToRoute round-trip, and the ends stretch when a node moves', () => {
469
+ const ends = { sourceX: 0, sourceY: 0, sourcePosition: 'right' as const, targetX: 200, targetY: 100, targetPosition: 'left' as const }
470
+ const pts = routePoints({ ...ends, route: [60, 40, 140] })
471
+ expect(pts).toEqual([[0, 0], [60, 0], [60, 40], [140, 40], [140, 100], [200, 100]])
472
+ expect(pointsToRoute(pts, 'right', 'left')).toEqual([60, 40, 140])
473
+ expect(pointsToRoute(pts, 'right')).toEqual([60, 40, 140, 100])
474
+ // The target went up: the last leg still arrives level with it
475
+ expect(routePoints({ ...ends, targetY: -20, route: [60, 40, 140] }).at(-2)).toEqual([140, -20])
476
+ })
477
+ it('a pinch that starts on a node zooms without selecting it; a tap on a node still selects it', async () => {
478
+ const w = await flow()
479
+ const touch = (el: EventTarget, type: string, id: number, x: number, y: number) => pointer(el, type, x, y, { pointerType: 'touch', pointerId: id })
480
+ touch(node(w, 'a'), 'pointerdown', 1, 60, 30)
481
+ touch(w.element, 'pointerdown', 2, 260, 30)
482
+ touch(window, 'pointermove', 2, 460, 30)
483
+ touch(window, 'pointerup', 1, 60, 30)
484
+ touch(window, 'pointerup', 2, 460, 30)
485
+ expect(w.emitted('update:selection')).toBeUndefined()
486
+ touch(node(w, 'b'), 'pointerdown', 3, 360, 30)
487
+ touch(window, 'pointerup', 3, 360, 30)
488
+ expect(w.emitted('update:selection')!.at(-1)![0]).toEqual({ nodes: ['b'], edges: [] })
489
+ })
382
490
  it('a node spliced in without room pushes the next one, and what comes after it, along', async () => {
383
491
  // a (0..180) → c (260..440) → d (600..): b (180 wide) can't fit between a and c with 48px each side
384
492
  const nodes = [N('a', 0, 0), N('c', 260, 0), N('d', 600, 0), N('b', 100, 300)]
@@ -523,6 +631,35 @@ describe('MFlow', () => {
523
631
  // The view didn't pan meanwhile
524
632
  expect(w.emitted('update:viewport')).toBeUndefined()
525
633
  })
634
+ it("edgeBranching 'junction': adds nothing, and tells where on the edge the branch was grabbed", async () => {
635
+ const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'smoothstep' }]
636
+ const w = await flow({ nodes: [N('a', 0, 0), N('b', 300, 0), N('c', 300, 200)], edges, edgeBranching: 'junction', snapToGrid: true, gridSize: 20 })
637
+ pointer(w.find('[data-flow-edge="e1"] path').element, 'pointerdown', 243, 34)
638
+ pointer(window, 'pointermove', 340, 220)
639
+ pointer(window, 'pointerup', 340, 220)
640
+ // On the edge (y 30) and on the grid along it (x 240)
641
+ expect(w.emitted('branch')![0]![0]).toMatchObject({ edge: { id: 'e1' }, connection: { source: 'a', target: 'c' }, position: { x: 240, y: 30 }, direction: 'right', end: { x: 340, y: 220 } })
642
+ expect(w.emitted('connect')).toBeUndefined()
643
+ expect(w.emitted('update:edges')).toBeUndefined()
644
+ // Dropped on nothing: still a branch, with no connection
645
+ pointer(w.find('[data-flow-edge="e1"] path').element, 'pointerdown', 260, 30)
646
+ pointer(window, 'pointermove', 500, 500)
647
+ pointer(window, 'pointerup', 500, 500)
648
+ expect(w.emitted('branch')![1]![0]).toMatchObject({ connection: null, position: { x: 260, y: 30 } })
649
+ })
650
+ it("edgeBranching 'junction': on a vertical run, says it runs down, and splits an edge's own route in two", async () => {
651
+ // a's right (180, 30) → over at x 240 → down to b's left (300, 230)
652
+ const edges: FlowEdge[] = [{ id: 'e1', source: 'a', target: 'b', type: 'smoothstep', route: [240] }]
653
+ const w = await flow({ nodes: [N('a', 0, 0), N('b', 300, 200), N('c', 600, 400)], edges, edgeBranching: 'junction', snapToGrid: true, gridSize: 20 })
654
+ pointer(w.find('[data-flow-edge="e1"] path').element, 'pointerdown', 243, 128)
655
+ pointer(window, 'pointermove', 500, 500)
656
+ pointer(window, 'pointerup', 500, 500)
657
+ const ev = w.emitted('branch')![0]![0] as { position: FlowXY; direction: string; routes: { before: number[]; after: number[] } }
658
+ expect(ev.position).toEqual({ x: 240, y: 120 })
659
+ expect(ev.direction).toBe('bottom')
660
+ expect(routePoints({ sourceX: 180, sourceY: 30, sourcePosition: 'right', targetX: 240, targetY: 120, targetPosition: 'top', route: ev.routes.before })).toEqual([[180, 30], [240, 30], [240, 120]])
661
+ expect(routePoints({ sourceX: 240, sourceY: 120, sourcePosition: 'bottom', targetX: 300, targetY: 230, targetPosition: 'left', route: ev.routes.after })).toEqual([[240, 120], [240, 230], [300, 230]])
662
+ })
526
663
  it('edgeBranching: a click still selects; off (the default), a drag from an edge pans; a finger only branches a selected edge', async () => {
527
664
  let w = await flow({ nodes: [N('a', 0, 0), N('b', 300, 0), N('c', 300, 200)], edgeBranching: true })
528
665
  let hit = w.find('[data-flow-edge="e1"] path').element
@@ -111,6 +111,11 @@ const props = withDefaults(defineProps<{
111
111
  grid?: number
112
112
  /** Draw the grid while editing */
113
113
  showGrid?: boolean
114
+ /**
115
+ * Where a table's middle snaps: `point` a grid point (default), `cell` the middle of a grid square, so tables sit in
116
+ * the squares between the points while walls, zones and decor snap to the points (a plan of cells)
117
+ */
118
+ tableSnap?: 'point' | 'cell'
114
119
  /** Draw chairs from `seats` */
115
120
  chairs?: boolean
116
121
  /** Decor kinds of yours, or the built-in ones restyled (merged over them by name) */
@@ -119,7 +124,11 @@ const props = withDefaults(defineProps<{
119
124
  rotatable?: boolean
120
125
  /** Dragging (or nudging) a merged table moves its whole merge with it */
121
126
  dragMerged?: boolean
122
- /** Outside editing, what a click on a table selects: nothing, one, or several (toggling; to merge them) */
127
+ /**
128
+ * What a click on a table selects outside editing: nothing, one, or several (toggling; to merge them). While
129
+ * editing, `multiple` keeps clicks toggling tables in and out of the selection, and a drag moves the table pressed
130
+ * on its own (to bring the ones being merged together)
131
+ */
123
132
  selectable?: 'none' | 'single' | 'multiple'
124
133
  /** Whether these tables may be merged: `true`, or `false` / a reason to refuse (shown by `merge-refused`) */
125
134
  canMerge?: (ids: (string | number)[]) => boolean | string
@@ -137,6 +146,7 @@ const props = withDefaults(defineProps<{
137
146
  editable: false,
138
147
  grid: 10,
139
148
  showGrid: true,
149
+ tableSnap: 'point',
140
150
  chairs: true,
141
151
  selectable: 'none',
142
152
  dragMerged: false,
@@ -305,6 +315,12 @@ const mergeShapes = computed(() =>
305
315
  let drag: { id: number; sx: number; sy: number; start: Map<string | number, { x: number; y: number }>; moved: boolean; pick?: string | number } | null = null
306
316
  let suppressClick = false
307
317
  const snap = (v: number) => (props.grid ? Math.round(v / props.grid) * props.grid : v)
318
+ /** A table's middle: on a grid point, or with `tableSnap="cell"` in the middle of a grid square */
319
+ const snapTable = (v: number) => {
320
+ const g = props.grid
321
+ if (!g || props.tableSnap !== 'cell') return snap(v)
322
+ return Math.round((v - g / 2) / g) * g + g / 2
323
+ }
308
324
  function clamp(t: FloorTable, x: number, y: number) {
309
325
  const s = sizeOf(t)
310
326
  return { x: Math.min(props.width - s.w / 2, Math.max(s.w / 2, x)), y: Math.min(props.height - s.h / 2, Math.max(s.h / 2, y)) }
@@ -327,10 +343,12 @@ function onDown(e: PointerEvent, t: FloorTable) {
327
343
  selection.value = selection.value.includes(t.id) ? selection.value.filter((x) => x !== t.id) : [...selection.value, t.id]
328
344
  navigator.vibrate?.(10)
329
345
  }, LONG_PRESS)
330
- } else if (!selection.value.includes(t.id)) selection.value = e.shiftKey || e.ctrlKey || e.metaKey ? [...selection.value, t.id] : [t.id]
331
- // A touch picks the table once it moves (or on release), so a long press can add to what's picked
332
- const ids = withMerged(selection.value.includes(t.id) ? selection.value : [t.id])
333
- drag = { id: e.pointerId, sx: e.clientX, sy: e.clientY, start: new Map(tables.value.filter((x) => ids.includes(x.id)).map((x) => [x.id, { x: x.x, y: x.y }])), moved: false, pick: touch && !selection.value.includes(t.id) ? t.id : undefined }
346
+ } else if (!selection.value.includes(t.id) && !toggling.value) selection.value = e.shiftKey || e.ctrlKey || e.metaKey ? [...selection.value, t.id] : [t.id]
347
+ // A touch picks the table once it moves (or on release), so a long press can add to what's picked. With
348
+ // `selectable="multiple"` the selection is the click's to change, and a drag moves only the table pressed (not the
349
+ // rest of the selection nor its merge): to bring the tables being merged together one by one
350
+ const ids = toggling.value ? [t.id] : withMerged(selection.value.includes(t.id) ? selection.value : [t.id])
351
+ drag = { id: e.pointerId, sx: e.clientX, sy: e.clientY, start: new Map(tables.value.filter((x) => ids.includes(x.id)).map((x) => [x.id, { x: x.x, y: x.y }])), moved: false, pick: touch && !toggling.value && !selection.value.includes(t.id) ? t.id : undefined }
334
352
  window.addEventListener('pointermove', onMove)
335
353
  window.addEventListener('pointerup', onUp)
336
354
  window.addEventListener('pointercancel', onUp)
@@ -366,16 +384,19 @@ function onUp(e: PointerEvent) {
366
384
  if (!moved) return
367
385
  suppressClick = true
368
386
  setTimeout(() => (suppressClick = false))
369
- commitMoves(new Map([...d!].map(([id, p]) => [id, clamp(tables.value.find((x) => x.id === id)!, snap(p.x), snap(p.y))])))
387
+ commitMoves(new Map([...d!].map(([id, p]) => [id, clamp(tables.value.find((x) => x.id === id)!, snapTable(p.x), snapTable(p.y))])))
370
388
  }
371
389
  function commitMoves(next: Map<string | number, { x: number; y: number }>) {
372
390
  record()
373
391
  tables.value = tables.value.map((t) => (next.has(t.id) ? { ...t, ...next.get(t.id)! } : t))
374
392
  emit('move', [...next].map(([id, p]) => ({ id, ...p })))
375
393
  }
394
+ /** Editing with `selectable="multiple"`: a click toggles a table in the selection (to merge them), a drag moves that table alone */
395
+ const toggling = computed(() => props.editable && props.selectable === 'multiple')
376
396
  function onClick(e: MouseEvent, t: FloorTable) {
377
397
  if (suppressClick) return
378
- if (props.editable && !(e.shiftKey || e.ctrlKey || e.metaKey)) selection.value = [t.id]
398
+ if (toggling.value) selection.value = selection.value.includes(t.id) ? selection.value.filter((x) => x !== t.id) : [...selection.value, t.id]
399
+ else if (props.editable && !(e.shiftKey || e.ctrlKey || e.metaKey)) selection.value = [t.id]
379
400
  else if (!props.editable && props.selectable === 'single') selection.value = selection.value.length === 1 && selection.value[0] === t.id ? [] : [t.id]
380
401
  else if (!props.editable && props.selectable === 'multiple')
381
402
  selection.value = selection.value.includes(t.id) ? selection.value.filter((x) => x !== t.id) : [...selection.value, t.id]
@@ -736,7 +757,7 @@ function update(kind: FloorItemKind, id: string | number, patch: Record<string,
736
757
  }
737
758
  function addTable(t: Partial<FloorTable> = {}): FloorTable {
738
759
  const n = Math.max(0, ...tables.value.map((x) => Number(x.label)).filter((x) => Number.isFinite(x))) + 1
739
- const table: FloorTable = { id: newId('table'), label: String(n), x: snap(props.width / 2), y: snap(props.height / 2), shape: 'square', seats: 4, ...t }
760
+ const table: FloorTable = { id: newId('table'), label: String(n), x: snapTable(props.width / 2), y: snapTable(props.height / 2), shape: 'square', seats: 4, ...t }
740
761
  record()
741
762
  tables.value = [...tables.value, table]
742
763
  selection.value = [table.id]