@m3ui-vue/m3ui-vue 1.2.2 → 1.3.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.
- package/dist/API.md +2776 -351
- package/dist/MButton-CuNzpoxm.js +172 -0
- package/dist/MButton-CuNzpoxm.js.map +1 -0
- package/dist/MDialog-HxEL-m58.js +173 -0
- package/dist/MDialog-HxEL-m58.js.map +1 -0
- package/dist/MIconButton-DoNotQ9v.js +282 -0
- package/dist/MIconButton-DoNotQ9v.js.map +1 -0
- package/dist/MListItem-DnPtv-hY.js +824 -0
- package/dist/MListItem-DnPtv-hY.js.map +1 -0
- package/dist/MLoadingIndicator-BQMNX6Dx.js +115 -0
- package/dist/MLoadingIndicator-BQMNX6Dx.js.map +1 -0
- package/dist/MMenuItem-Bih0h4-n.js +604 -0
- package/dist/MMenuItem-Bih0h4-n.js.map +1 -0
- package/dist/MProgressBar-BCoruxA-.js +184 -0
- package/dist/MProgressBar-BCoruxA-.js.map +1 -0
- package/dist/MSeekBar-LURE1Ah7.js +435 -0
- package/dist/MSeekBar-LURE1Ah7.js.map +1 -0
- package/dist/MSegmentedButton-DL9JtJFX.js +65 -0
- package/dist/MSegmentedButton-DL9JtJFX.js.map +1 -0
- package/dist/MSlider-_J4IS2_z.js +691 -0
- package/dist/MSlider-_J4IS2_z.js.map +1 -0
- package/dist/MSpinner-BhkMYKOM.js +65 -0
- package/dist/MSpinner-BhkMYKOM.js.map +1 -0
- package/dist/MTextField-CkzwNBWS.js +296 -0
- package/dist/MTextField-CkzwNBWS.js.map +1 -0
- package/dist/MTooltip-B67ZDSGp.js +756 -0
- package/dist/MTooltip-B67ZDSGp.js.map +1 -0
- package/dist/_storageKeys-CYXsUBwK.js +18 -0
- package/dist/_storageKeys-CYXsUBwK.js.map +1 -0
- package/dist/_useEscapeStack-CjndQhqg.js +19 -0
- package/dist/_useEscapeStack-CjndQhqg.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/chart.js +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MAudioPlayer.vue.d.ts +115 -0
- package/dist/components/MBadge.vue.d.ts +1 -1
- package/dist/components/MBottomSheetScaffold.vue.d.ts +1 -1
- package/dist/components/MBox.vue.d.ts +1 -1
- package/dist/components/MButton.vue.d.ts +1 -1
- package/dist/components/MConfirmDialog.vue.d.ts +1 -1
- package/dist/components/MCopyButton.vue.d.ts +2 -2
- package/dist/components/MDataTable.vue.d.ts +2 -2
- package/dist/components/MDialog.vue.d.ts +2 -2
- package/dist/components/MDivider.vue.d.ts +1 -1
- package/dist/components/MDragHandle.vue.d.ts +1 -1
- package/dist/components/MDrawCanvas.vue.d.ts +148 -0
- package/dist/components/MDrawLayers.vue.d.ts +3 -0
- package/dist/components/MDrawToolbar.vue.d.ts +34 -0
- package/dist/components/MExportButton.vue.d.ts +1 -1
- package/dist/components/MFab.vue.d.ts +2 -2
- package/dist/components/MFabMenu.vue.d.ts +2 -2
- package/dist/components/MFixed.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +2 -2
- package/dist/components/MFloorPlan.vue.d.ts +160 -0
- package/dist/components/MFlow.vue.d.ts +305 -0
- package/dist/components/MFlowControls.vue.d.ts +33 -0
- package/dist/components/MFlowHandle.vue.d.ts +16 -0
- package/dist/components/MFlowMinimap.vue.d.ts +22 -0
- package/dist/components/MFlowNode.vue.d.ts +35 -0
- package/dist/components/MGantt.vue.d.ts +141 -0
- package/dist/components/MGanttControls.vue.d.ts +32 -0
- package/dist/components/MIconButton.vue.d.ts +3 -1
- package/dist/components/MImageCropper.vue.d.ts +110 -0
- package/dist/components/MInfiniteScroll.vue.d.ts +1 -1
- package/dist/components/MLightbox.vue.d.ts +2 -2
- package/dist/components/MList.vue.d.ts +1 -1
- package/dist/components/MLoadingOverlay.vue.d.ts +1 -1
- package/dist/components/MMapControl.vue.d.ts +1 -1
- package/dist/components/MMapSearch.vue.d.ts +1 -1
- package/dist/components/MMaskField.vue.d.ts +12 -1
- package/dist/components/MMenu.vue.d.ts +1 -1
- package/dist/components/MNavigationDrawer.vue.d.ts +1 -1
- package/dist/components/MNumberField.vue.d.ts +11 -2
- package/dist/components/MPdfViewer.vue.d.ts +174 -0
- package/dist/components/MPullToRefresh.vue.d.ts +1 -1
- package/dist/components/MResourceTimeline.vue.d.ts +149 -0
- package/dist/components/MScheduler.vue.d.ts +3 -3
- package/dist/components/MScheme.vue.d.ts +1 -1
- package/dist/components/MSearchField.vue.d.ts +1 -1
- package/dist/components/MSeekBar.vue.d.ts +1 -1
- package/dist/components/MSimpleCarousel.vue.d.ts +1 -1
- package/dist/components/MSkeleton.vue.d.ts +1 -1
- package/dist/components/MSlider.vue.d.ts +2 -2
- package/dist/components/MSparkline.vue.d.ts +1 -1
- package/dist/components/MSplitter.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +2 -2
- package/dist/components/MSwipeToDismiss.vue.d.ts +1 -1
- package/dist/components/MSwitch.vue.d.ts +1 -1
- package/dist/components/MTable.vue.d.ts +1 -1
- package/dist/components/MTagInput.vue.d.ts +12 -1
- package/dist/components/MTextField.vue.d.ts +13 -2
- package/dist/components/MToolbar.vue.d.ts +1 -1
- package/dist/components/MTree.vue.d.ts +2 -2
- package/dist/components/MVideoPlayer.vue.d.ts +253 -0
- package/dist/components/MVirtualTable.vue.d.ts +1 -1
- package/dist/components/MWindow.vue.d.ts +3 -3
- package/dist/components/_MFlowEdge.vue.d.ts +9 -0
- package/dist/components/_MFlowEdgeLabel.vue.d.ts +9 -0
- package/dist/components/_MFlowNodeShell.vue.d.ts +9 -0
- package/dist/components/_MPdfPage.vue.d.ts +76 -0
- package/dist/components/_MTimeBackground.vue.d.ts +14 -0
- package/dist/components/_MTimeHeader.vue.d.ts +20 -0
- package/dist/composables/_flowPanel.d.ts +2 -0
- package/dist/composables/_flowSlot.d.ts +5 -0
- package/dist/composables/_ganttTime.d.ts +41 -0
- package/dist/composables/_useTimeAxis.d.ts +90 -0
- package/dist/composables/drawGeometry.d.ts +119 -0
- package/dist/composables/flowFormats.d.ts +79 -0
- package/dist/composables/flowLayout.d.ts +45 -0
- package/dist/composables/flowPaths.d.ts +53 -0
- package/dist/composables/ganttFormats.d.ts +52 -0
- package/dist/composables/ganttSchedule.d.ts +99 -0
- package/dist/composables/useDrawing.d.ts +44 -0
- package/dist/composables/useFlow.d.ts +266 -0
- package/dist/composables/useGantt.d.ts +87 -0
- package/dist/composables/useLocale.d.ts +163 -0
- package/dist/composables/useMediaPlayer.d.ts +101 -0
- package/dist/composables/usePdf.d.ts +119 -0
- package/dist/composables/useResourceTimeline.d.ts +70 -0
- package/dist/draw.d.ts +7 -0
- package/dist/draw.js +1700 -0
- package/dist/draw.js.map +1 -0
- package/dist/flow.d.ts +14 -0
- package/dist/flow.js +3542 -0
- package/dist/flow.js.map +1 -0
- package/dist/flowPaths-CUc6X373.js +161 -0
- package/dist/flowPaths-CUc6X373.js.map +1 -0
- package/dist/gantt.d.ts +12 -0
- package/dist/gantt.js +3575 -0
- package/dist/gantt.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/locales/index.js +1148 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +7286 -7654
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +113 -108
- package/dist/map.js.map +1 -1
- package/dist/media.d.ts +5 -0
- package/dist/media.js +1311 -0
- package/dist/media.js.map +1 -0
- package/dist/pdf.d.ts +4 -0
- package/dist/pdf.js +1871 -0
- package/dist/pdf.js.map +1 -0
- package/dist/rich-text-editor.js +28 -26
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/{useLocale-JYxDDeXC.js → useLocale-BpGxplLV.js} +165 -2
- package/dist/useLocale-BpGxplLV.js.map +1 -0
- package/dist/{useThemeTokens-y0HZpyhL.js → useThemeTokens-DQQcaWbE.js} +40 -54
- package/dist/useThemeTokens-DQQcaWbE.js.map +1 -0
- package/package.json +29 -5
- package/src/__tests__/MAudioPlayer.test.ts +75 -0
- package/src/__tests__/MDrawCanvas.test.ts +110 -0
- package/src/__tests__/MFloorPlan.test.ts +97 -0
- package/src/__tests__/MFlow.test.ts +575 -0
- package/src/__tests__/MGantt.test.ts +130 -0
- package/src/__tests__/MImageCropper.test.ts +89 -0
- package/src/__tests__/MPdfViewer.test.ts +235 -0
- package/src/__tests__/MResourceTimeline.test.ts +102 -0
- package/src/__tests__/MVideoPlayer.test.ts +201 -0
- package/src/__tests__/drawGeometry.test.ts +58 -0
- package/src/__tests__/fieldExpose.test.ts +30 -0
- package/src/__tests__/flowFormats.test.ts +185 -0
- package/src/__tests__/flowLayout.test.ts +113 -0
- package/src/__tests__/ganttFormats.test.ts +76 -0
- package/src/__tests__/ganttSchedule.test.ts +136 -0
- package/src/__tests__/pdfMock.ts +83 -0
- package/src/__tests__/useMediaPlayer.test.ts +182 -0
- package/src/__tests__/usePdf.test.ts +102 -0
- package/src/components/MAudioPlayer.vue +319 -0
- package/src/components/MDrawCanvas.vue +813 -0
- package/src/components/MDrawLayers.vue +114 -0
- package/src/components/MDrawToolbar.vue +171 -0
- package/src/components/MFloorPlan.vue +581 -0
- package/src/components/MFlow.vue +2049 -0
- package/src/components/MFlowControls.vue +110 -0
- package/src/components/MFlowHandle.vue +60 -0
- package/src/components/MFlowMinimap.vue +134 -0
- package/src/components/MFlowNode.vue +98 -0
- package/src/components/MGantt.vue +1609 -0
- package/src/components/MGanttControls.vue +77 -0
- package/src/components/MIconButton.vue +3 -1
- package/src/components/MImageCropper.vue +507 -0
- package/src/components/MMaskField.vue +13 -0
- package/src/components/MNumberField.vue +13 -0
- package/src/components/MPdfViewer.vue +1269 -0
- package/src/components/MResourceTimeline.vue +1020 -0
- package/src/components/MTagInput.vue +13 -0
- package/src/components/MTextField.vue +16 -0
- package/src/components/MVideoPlayer.vue +839 -0
- package/src/components/_MFlowEdge.vue +100 -0
- package/src/components/_MFlowEdgeLabel.vue +56 -0
- package/src/components/_MFlowNodeShell.vue +111 -0
- package/src/components/_MPdfPage.vue +456 -0
- package/src/components/_MTimeBackground.vue +16 -0
- package/src/components/_MTimeHeader.vue +31 -0
- package/src/composables/_flowPanel.ts +13 -0
- package/src/composables/_flowSlot.ts +6 -0
- package/src/composables/_ganttTime.ts +200 -0
- package/src/composables/_useTimeAxis.ts +224 -0
- package/src/composables/drawGeometry.ts +405 -0
- package/src/composables/flowFormats.ts +916 -0
- package/src/composables/flowLayout.ts +297 -0
- package/src/composables/flowPaths.ts +239 -0
- package/src/composables/ganttFormats.ts +366 -0
- package/src/composables/ganttSchedule.ts +403 -0
- package/src/composables/useDrawing.ts +53 -0
- package/src/composables/useFlow.ts +250 -0
- package/src/composables/useGantt.ts +92 -0
- package/src/composables/useLocale.ts +328 -0
- package/src/composables/useMediaPlayer.ts +406 -0
- package/src/composables/usePdf.ts +456 -0
- package/src/composables/useResourceTimeline.ts +76 -0
- package/src/draw.ts +25 -0
- package/src/flow.ts +26 -0
- package/src/gantt.ts +12 -0
- package/src/index.ts +4 -0
- package/src/locales/de.ts +163 -0
- package/src/locales/es.ts +163 -0
- package/src/locales/fr.ts +163 -0
- package/src/locales/ja.ts +163 -0
- package/src/locales/ko.ts +163 -0
- package/src/locales/pt.ts +163 -0
- package/src/locales/zh.ts +163 -0
- package/src/media.ts +5 -0
- package/src/pdf.ts +15 -0
- package/dist/MMenuItem-D4Gx_l3F.js +0 -929
- package/dist/MMenuItem-D4Gx_l3F.js.map +0 -1
- package/dist/MSlider-Dx_S3vJ9.js +0 -1506
- package/dist/MSlider-Dx_S3vJ9.js.map +0 -1
- package/dist/MTextField-Bz8JIsnl.js +0 -633
- package/dist/MTextField-Bz8JIsnl.js.map +0 -1
- package/dist/useLocale-JYxDDeXC.js.map +0 -1
- package/dist/useThemeTokens-y0HZpyhL.js.map +0 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import { nextTick } from 'vue'
|
|
4
|
+
import MDrawCanvas from '../components/MDrawCanvas.vue'
|
|
5
|
+
import MDrawToolbar from '../components/MDrawToolbar.vue'
|
|
6
|
+
import type { DrawItem, DrawStroke } from '../composables/drawGeometry'
|
|
7
|
+
|
|
8
|
+
function setup(props: Record<string, unknown> = {}) {
|
|
9
|
+
const w = mount(MDrawCanvas, {
|
|
10
|
+
props: { modelValue: [] as DrawItem[], 'onUpdate:modelValue': (v: DrawItem[]) => w.setProps({ modelValue: v }), ...props },
|
|
11
|
+
attachTo: document.body,
|
|
12
|
+
})
|
|
13
|
+
const el = w.element as HTMLElement
|
|
14
|
+
const svg = el.querySelector('svg')!
|
|
15
|
+
const ev = (type: string, x: number, y: number, o: Record<string, unknown> = {}) =>
|
|
16
|
+
(type === 'pointerdown' ? svg : el).dispatchEvent(new PointerEvent(type, { bubbles: true, clientX: x, clientY: y, pointerId: 1, pointerType: 'mouse', button: 0, buttons: 1, ...o }))
|
|
17
|
+
const drag = async (pts: [number, number][], o: Record<string, unknown> = {}) => {
|
|
18
|
+
ev('pointerdown', ...pts[0]!, o)
|
|
19
|
+
for (const p of pts.slice(1)) ev('pointermove', ...p, o)
|
|
20
|
+
ev('pointerup', ...pts[pts.length - 1]!, o)
|
|
21
|
+
await nextTick()
|
|
22
|
+
}
|
|
23
|
+
const items = () => w.props('modelValue') as DrawItem[]
|
|
24
|
+
return { w, el, ev, drag, items }
|
|
25
|
+
}
|
|
26
|
+
const across = (y = 50): [number, number][] => Array.from({ length: 11 }, (_, i) => [i * 10, y])
|
|
27
|
+
|
|
28
|
+
describe('MDrawCanvas', () => {
|
|
29
|
+
it('draws a stroke with the pen, and undo / redo take it back and forth', async () => {
|
|
30
|
+
const { w, drag, items } = setup()
|
|
31
|
+
await drag(across())
|
|
32
|
+
expect(items()).toHaveLength(1)
|
|
33
|
+
expect(items()[0]!.type).toBe('stroke')
|
|
34
|
+
expect((items()[0] as DrawStroke).points.length).toBeGreaterThan(2)
|
|
35
|
+
;(w.vm as any).undo()
|
|
36
|
+
await nextTick()
|
|
37
|
+
expect(items()).toHaveLength(0)
|
|
38
|
+
;(w.vm as any).redo()
|
|
39
|
+
await nextTick()
|
|
40
|
+
expect(items()).toHaveLength(1)
|
|
41
|
+
})
|
|
42
|
+
it('the eraser cuts a stroke in two, in one undo step', async () => {
|
|
43
|
+
const { w, drag, items } = setup()
|
|
44
|
+
await drag(across())
|
|
45
|
+
await w.setProps({ tool: 'eraser' })
|
|
46
|
+
await drag([[50, 30], [50, 70]])
|
|
47
|
+
expect(items()).toHaveLength(2)
|
|
48
|
+
;(w.vm as any).undo()
|
|
49
|
+
await nextTick()
|
|
50
|
+
expect(items()).toHaveLength(1)
|
|
51
|
+
})
|
|
52
|
+
it('the pen\'s eraser end erases whatever tool is picked', async () => {
|
|
53
|
+
const { drag, items } = setup()
|
|
54
|
+
await drag(across())
|
|
55
|
+
await drag([[50, 30], [50, 70]], { pointerType: 'pen', button: 5, buttons: 32, pressure: 0.5 })
|
|
56
|
+
expect(items()).toHaveLength(2)
|
|
57
|
+
})
|
|
58
|
+
it('draws shapes, and selects, moves and deletes them', async () => {
|
|
59
|
+
const { w, drag, items, el } = setup({ tool: 'rect' })
|
|
60
|
+
await drag([[10, 10], [60, 40]])
|
|
61
|
+
expect(items()[0]).toMatchObject({ type: 'shape', shape: 'rect', from: [10, 10], to: [60, 40] })
|
|
62
|
+
await w.setProps({ tool: 'select' })
|
|
63
|
+
await drag([[0, 0], [100, 0], [100, 100], [0, 100]])
|
|
64
|
+
expect(w.emitted('update:selection')!.at(-1)![0]).toEqual([items()[0]!.id])
|
|
65
|
+
await w.setProps({ selection: [items()[0]!.id] })
|
|
66
|
+
await drag([[10, 25], [30, 45]])
|
|
67
|
+
expect(items()[0]).toMatchObject({ from: [30, 30], to: [80, 60] })
|
|
68
|
+
el.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true }))
|
|
69
|
+
await nextTick()
|
|
70
|
+
expect(items()).toHaveLength(0)
|
|
71
|
+
})
|
|
72
|
+
it('with penOnly, a finger pans instead of drawing', async () => {
|
|
73
|
+
const { w, drag, items } = setup({ penOnly: true })
|
|
74
|
+
await drag(across(), { pointerType: 'touch' })
|
|
75
|
+
expect(items()).toHaveLength(0)
|
|
76
|
+
expect((w.emitted('update:viewport')!.at(-1)![0] as { x: number }).x).toBe(100)
|
|
77
|
+
})
|
|
78
|
+
it('in pages mode, items belong to the page under them, in its coordinates', async () => {
|
|
79
|
+
const { drag, items } = setup({ mode: 'pages', pages: 2, pageSize: { width: 200, height: 100 } })
|
|
80
|
+
await drag([[10, 150], [50, 150]])
|
|
81
|
+
expect(items()[0]!.page).toBe(1)
|
|
82
|
+
expect((items()[0] as DrawStroke).points[0]![1]).toBeCloseTo(26)
|
|
83
|
+
})
|
|
84
|
+
it('hidden and locked layers are left alone', async () => {
|
|
85
|
+
const stroke = (id: string, layer: string): DrawItem => ({ id, type: 'stroke', pen: 'marker', color: '#000', size: 4, layer, points: across().map(([x, y]) => [x, y, 1]) })
|
|
86
|
+
const { w, drag, items } = setup({
|
|
87
|
+
modelValue: [stroke('a', 'l1'), stroke('b', 'l2')],
|
|
88
|
+
layers: [{ id: 'l1', name: '1', locked: true }, { id: 'l2', name: '2' }],
|
|
89
|
+
tool: 'stroke-eraser',
|
|
90
|
+
})
|
|
91
|
+
await drag([[50, 30], [50, 70]])
|
|
92
|
+
expect(items().map((i) => i.id)).toEqual(['a'])
|
|
93
|
+
expect(w.findAll('path').length).toBeGreaterThan(0)
|
|
94
|
+
})
|
|
95
|
+
it('the toolbar picks tools and colors', async () => {
|
|
96
|
+
const w = mount({
|
|
97
|
+
components: { MDrawCanvas, MDrawToolbar },
|
|
98
|
+
data: () => ({ tool: 'pen', color: '#1d1b20' }),
|
|
99
|
+
template: '<MDrawCanvas v-model:tool="tool" v-model:color="color"><MDrawToolbar /></MDrawCanvas>',
|
|
100
|
+
})
|
|
101
|
+
await w.find('[aria-label="Text"]').trigger('click')
|
|
102
|
+
expect((w.vm as any).tool).toBe('text')
|
|
103
|
+
await w.find('[aria-label="Color #e53935"]').trigger('click')
|
|
104
|
+
expect((w.vm as any).color).toBe('#e53935')
|
|
105
|
+
// A color that isn't a swatch lights up the custom-color button
|
|
106
|
+
;(w.vm as any).color = '#123456'
|
|
107
|
+
await nextTick()
|
|
108
|
+
expect(w.find('[aria-label="Custom color"]').attributes('aria-pressed')).toBe('true')
|
|
109
|
+
})
|
|
110
|
+
})
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { mount } from '@vue/test-utils'
|
|
3
|
+
import { nextTick } from 'vue'
|
|
4
|
+
import MFloorPlan, { type FloorTable } from '../components/MFloorPlan.vue'
|
|
5
|
+
|
|
6
|
+
const base = (): FloorTable[] => [
|
|
7
|
+
{ id: 1, label: 'T1', x: 100, y: 100, seats: 4, status: 'occupied', badge: 12 },
|
|
8
|
+
{ id: 2, label: 'T2', x: 300, y: 100, shape: 'round', seats: 6 },
|
|
9
|
+
]
|
|
10
|
+
function setup(props: Record<string, unknown> = {}) {
|
|
11
|
+
const w = mount(MFloorPlan, {
|
|
12
|
+
props: { tables: base(), 'onUpdate:tables': (v: FloorTable[]) => w.setProps({ tables: v }), ...props },
|
|
13
|
+
attachTo: document.body,
|
|
14
|
+
})
|
|
15
|
+
return w
|
|
16
|
+
}
|
|
17
|
+
const table = (w: ReturnType<typeof setup>, label: string) => w.findAll('[role="button"]').find((b) => b.attributes('aria-label')!.startsWith(label))!
|
|
18
|
+
|
|
19
|
+
describe('MFloorPlan', () => {
|
|
20
|
+
it('draws tables with their status, seats and badge', () => {
|
|
21
|
+
const w = setup()
|
|
22
|
+
expect(table(w, 'T1').attributes('aria-label')).toBe('T1, Occupied, 4 seats, 12')
|
|
23
|
+
expect(table(w, 'T1').attributes('style')).toContain('--color-primary-container')
|
|
24
|
+
// chairs: 4 + 6
|
|
25
|
+
expect(w.findAll('.bg-outline-variant').length).toBe(10)
|
|
26
|
+
})
|
|
27
|
+
it('a click opens a table in service mode, without moving it', async () => {
|
|
28
|
+
const w = setup()
|
|
29
|
+
await table(w, 'T2').trigger('click')
|
|
30
|
+
expect(w.emitted('table-click')![0]![0]).toMatchObject({ id: 2 })
|
|
31
|
+
table(w, 'T2').element.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, button: 0, clientX: 0, clientY: 0, pointerId: 1 }))
|
|
32
|
+
window.dispatchEvent(new PointerEvent('pointermove', { clientX: 50, clientY: 0, pointerId: 1 }))
|
|
33
|
+
window.dispatchEvent(new PointerEvent('pointerup', { clientX: 50, clientY: 0, pointerId: 1 }))
|
|
34
|
+
expect(w.emitted('move')).toBeUndefined()
|
|
35
|
+
})
|
|
36
|
+
it('editable: a drag moves the selected tables, snapped to the grid, and emits move', async () => {
|
|
37
|
+
const w = setup({ editable: true, grid: 20, selection: [1, 2], 'onUpdate:selection': (v: unknown) => w.setProps({ selection: v as number[] }) })
|
|
38
|
+
table(w, 'T1').element.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, button: 0, clientX: 0, clientY: 0, pointerId: 1 }))
|
|
39
|
+
window.dispatchEvent(new PointerEvent('pointermove', { clientX: 33, clientY: 47, pointerId: 1 }))
|
|
40
|
+
window.dispatchEvent(new PointerEvent('pointerup', { clientX: 33, clientY: 47, pointerId: 1 }))
|
|
41
|
+
await nextTick()
|
|
42
|
+
expect(w.emitted('move')![0]![0]).toEqual([{ id: 1, x: 140, y: 140 }, { id: 2, x: 340, y: 140 }])
|
|
43
|
+
expect((w.props('tables') as FloorTable[])[0]).toMatchObject({ x: 140, y: 140 })
|
|
44
|
+
})
|
|
45
|
+
it('editable: arrows nudge by the grid, and tables stay inside the plan', async () => {
|
|
46
|
+
const w = setup({ editable: true, grid: 10 })
|
|
47
|
+
await table(w, 'T1').trigger('keydown', { key: 'ArrowLeft' })
|
|
48
|
+
expect((w.props('tables') as FloorTable[])[0]).toMatchObject({ x: 90 })
|
|
49
|
+
for (let i = 0; i < 20; i++) await table(w, 'T1').trigger('keydown', { key: 'ArrowUp', shiftKey: true })
|
|
50
|
+
expect((w.props('tables') as FloorTable[])[0]!.y).toBe(36)
|
|
51
|
+
})
|
|
52
|
+
it('draws merged tables as one group', () => {
|
|
53
|
+
const w = setup({ merges: [{ id: 'm', tables: [1, 2], label: 'T1 + T2' }] })
|
|
54
|
+
expect(w.text()).toContain('T1 + T2')
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
describe('MFloorPlan zones, walls and decor', () => {
|
|
59
|
+
const down = (el: Element, x: number, y: number) => el.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, button: 0, clientX: x, clientY: y, pointerId: 3 }))
|
|
60
|
+
const moveUp = (x: number, y: number) => {
|
|
61
|
+
window.dispatchEvent(new PointerEvent('pointermove', { clientX: x, clientY: y, pointerId: 3 }))
|
|
62
|
+
window.dispatchEvent(new PointerEvent('pointerup', { clientX: x, clientY: y, pointerId: 3 }))
|
|
63
|
+
}
|
|
64
|
+
function plan(props: Record<string, unknown>) {
|
|
65
|
+
const w = mount(MFloorPlan, { props: { editable: true, grid: 10, ...props }, attachTo: document.body })
|
|
66
|
+
for (const k of ['areas', 'walls', 'decor']) (w.vm as any)[`onUpdate:${k}`] = null
|
|
67
|
+
return w
|
|
68
|
+
}
|
|
69
|
+
it('draws a wall corner by corner, Enter ends it', async () => {
|
|
70
|
+
const w = plan({ tool: 'wall' })
|
|
71
|
+
const root = w.element as HTMLElement
|
|
72
|
+
down(root, 10, 10)
|
|
73
|
+
down(root, 200, 12)
|
|
74
|
+
down(root, 200, 300)
|
|
75
|
+
root.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))
|
|
76
|
+
await nextTick()
|
|
77
|
+
expect((w.emitted('update:walls')!.at(-1)![0] as any[])[0].points).toEqual([[10, 10], [200, 10], [200, 300]])
|
|
78
|
+
})
|
|
79
|
+
it('drags out a zone, snapped', async () => {
|
|
80
|
+
const w = plan({ tool: 'area' })
|
|
81
|
+
down(w.element, 20, 20)
|
|
82
|
+
moveUp(203, 118)
|
|
83
|
+
await nextTick()
|
|
84
|
+
expect((w.emitted('update:areas')!.at(-1)![0] as any[])[0]).toMatchObject({ x: 20, y: 20, width: 180, height: 100 })
|
|
85
|
+
})
|
|
86
|
+
it('moves decor and deletes what is picked', async () => {
|
|
87
|
+
const w = plan({ decor: [{ id: 'p', kind: 'plant', x: 100, y: 100 }], 'onUpdate:decor': (v: unknown) => w.setProps({ decor: v as any }) })
|
|
88
|
+
const plant = w.find('[aria-label="plant"]').element
|
|
89
|
+
down(plant, 0, 0)
|
|
90
|
+
moveUp(41, 19)
|
|
91
|
+
await nextTick()
|
|
92
|
+
expect((w.props('decor') as any[])[0]).toMatchObject({ x: 140, y: 120 })
|
|
93
|
+
w.element.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true }))
|
|
94
|
+
await nextTick()
|
|
95
|
+
expect(w.props('decor')).toEqual([])
|
|
96
|
+
})
|
|
97
|
+
})
|