@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,581 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/** A table on the plan, in plan units (not pixels) */
|
|
3
|
+
export interface FloorTable {
|
|
4
|
+
id: string | number
|
|
5
|
+
label: string
|
|
6
|
+
x: number
|
|
7
|
+
y: number
|
|
8
|
+
shape?: 'round' | 'square' | 'rect'
|
|
9
|
+
seats?: number
|
|
10
|
+
/** Size in plan units (default: from the shape and the seats) */
|
|
11
|
+
width?: number
|
|
12
|
+
height?: number
|
|
13
|
+
/** Degrees */
|
|
14
|
+
rotation?: number
|
|
15
|
+
/** A key of `statuses` */
|
|
16
|
+
status?: string
|
|
17
|
+
/** A small badge: minutes seated, the total, a count… */
|
|
18
|
+
badge?: string | number
|
|
19
|
+
data?: Record<string, unknown>
|
|
20
|
+
}
|
|
21
|
+
/** Tables joined together (drawn as one group) */
|
|
22
|
+
export interface FloorMerge {
|
|
23
|
+
id: string | number
|
|
24
|
+
tables: (string | number)[]
|
|
25
|
+
label?: string
|
|
26
|
+
}
|
|
27
|
+
/** A zone of the room (terrace, main hall, VIP): a rectangle behind the tables */
|
|
28
|
+
export interface FloorArea {
|
|
29
|
+
id: string | number
|
|
30
|
+
label?: string
|
|
31
|
+
x: number
|
|
32
|
+
y: number
|
|
33
|
+
width: number
|
|
34
|
+
height: number
|
|
35
|
+
/** An M3 color role or any CSS color */
|
|
36
|
+
color?: string
|
|
37
|
+
}
|
|
38
|
+
/** A wall: a line through its points */
|
|
39
|
+
export interface FloorWall {
|
|
40
|
+
id: string | number
|
|
41
|
+
points: [number, number][]
|
|
42
|
+
thickness?: number
|
|
43
|
+
}
|
|
44
|
+
/** Something on the plan that isn't a table: a door, a window, a plant, a column, the register, a text label… */
|
|
45
|
+
export interface FloorDecor {
|
|
46
|
+
id: string | number
|
|
47
|
+
kind: 'door' | 'window' | 'plant' | 'column' | 'restroom' | 'kitchen' | 'register' | 'stairs' | 'label'
|
|
48
|
+
x: number
|
|
49
|
+
y: number
|
|
50
|
+
width?: number
|
|
51
|
+
height?: number
|
|
52
|
+
rotation?: number
|
|
53
|
+
/** The text of a label (or a caption under the others) */
|
|
54
|
+
label?: string
|
|
55
|
+
}
|
|
56
|
+
/** How a status looks: an M3 color role ('primary', 'tertiary', 'error'…) or any CSS color, an icon, a name */
|
|
57
|
+
export interface FloorStatus {
|
|
58
|
+
label: string
|
|
59
|
+
color: string
|
|
60
|
+
icon?: string
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<script setup lang="ts">
|
|
65
|
+
/**
|
|
66
|
+
* A floor plan of tables: to arrange them (`editable`: drag one or several, snapped to a grid, arrows nudge) and to
|
|
67
|
+
* run service (each table colored by its status, with a badge, a click to open it). Merged tables are drawn as one
|
|
68
|
+
* group. Positions are plan units scaled to the component's width, so the same plan fits a phone and a wall screen.
|
|
69
|
+
* Not an M3 spec component.
|
|
70
|
+
*
|
|
71
|
+
* @slot table The inside of a table: `{ table, status, selected }`
|
|
72
|
+
* @event table-click A table was clicked or opened with Enter (not after a drag)
|
|
73
|
+
* @event move Tables moved by a drag or the arrows, with their new positions (`{ id, x, y }[]`), to save them
|
|
74
|
+
*/
|
|
75
|
+
import { computed, onBeforeUnmount, onMounted, ref, shallowRef } from 'vue'
|
|
76
|
+
import { useLocale } from '../composables/useLocale'
|
|
77
|
+
import MIcon from './MIcon.vue'
|
|
78
|
+
|
|
79
|
+
const props = withDefaults(defineProps<{
|
|
80
|
+
/** The plan's size in plan units */
|
|
81
|
+
width?: number
|
|
82
|
+
height?: number
|
|
83
|
+
/** Status keys to their look */
|
|
84
|
+
statuses?: Record<string, FloorStatus>
|
|
85
|
+
/** Drag tables around; otherwise a click opens one */
|
|
86
|
+
editable?: boolean
|
|
87
|
+
/** Grid step in plan units (0: no snapping) */
|
|
88
|
+
grid?: number
|
|
89
|
+
/** Draw the grid while editing */
|
|
90
|
+
showGrid?: boolean
|
|
91
|
+
/** Draw chairs from `seats` */
|
|
92
|
+
chairs?: boolean
|
|
93
|
+
/** Accessible name */
|
|
94
|
+
label?: string
|
|
95
|
+
}>(), {
|
|
96
|
+
width: 1000,
|
|
97
|
+
height: 600,
|
|
98
|
+
statuses: () => ({
|
|
99
|
+
free: { label: 'Free', color: 'surface' },
|
|
100
|
+
occupied: { label: 'Occupied', color: 'primary', icon: 'restaurant' },
|
|
101
|
+
bill: { label: 'Bill requested', color: 'tertiary', icon: 'receipt_long' },
|
|
102
|
+
reserved: { label: 'Reserved', color: 'secondary', icon: 'event' },
|
|
103
|
+
}),
|
|
104
|
+
editable: false,
|
|
105
|
+
grid: 10,
|
|
106
|
+
showGrid: true,
|
|
107
|
+
chairs: true,
|
|
108
|
+
})
|
|
109
|
+
const tables = defineModel<FloorTable[]>('tables', { default: () => [] })
|
|
110
|
+
const merges = defineModel<FloorMerge[]>('merges', { default: () => [] })
|
|
111
|
+
const selection = defineModel<(string | number)[]>('selection', { default: () => [] })
|
|
112
|
+
const areas = defineModel<FloorArea[]>('areas', { default: () => [] })
|
|
113
|
+
const walls = defineModel<FloorWall[]>('walls', { default: () => [] })
|
|
114
|
+
const decor = defineModel<FloorDecor[]>('decor', { default: () => [] })
|
|
115
|
+
/** While editing: `select` moves things, `wall` draws a wall (click each corner, double-click or Enter to end), `area` drags out a zone */
|
|
116
|
+
const tool = defineModel<'select' | 'wall' | 'area'>('tool', { default: 'select' })
|
|
117
|
+
const emit = defineEmits<{ 'table-click': [table: FloorTable, event: MouseEvent | KeyboardEvent]; move: [moved: { id: string | number; x: number; y: number }[]] }>()
|
|
118
|
+
const locale = useLocale()
|
|
119
|
+
|
|
120
|
+
const root = ref<HTMLElement>()
|
|
121
|
+
const scale = ref(1)
|
|
122
|
+
let ro: ResizeObserver | null = null
|
|
123
|
+
onMounted(() => {
|
|
124
|
+
ro = new ResizeObserver(() => (scale.value = (root.value?.clientWidth || props.width) / props.width))
|
|
125
|
+
ro.observe(root.value!)
|
|
126
|
+
scale.value = (root.value!.clientWidth || props.width) / props.width
|
|
127
|
+
})
|
|
128
|
+
onBeforeUnmount(() => ro?.disconnect())
|
|
129
|
+
|
|
130
|
+
// ── Geometry ────────────────────────────────────────────────────────────────────────────────────────────
|
|
131
|
+
const CHAIR = 16
|
|
132
|
+
type FloorBox = { w: number; h: number }
|
|
133
|
+
function sizeOf(t: FloorTable): FloorBox {
|
|
134
|
+
const n = t.seats ?? 4
|
|
135
|
+
const shape = t.shape ?? 'square'
|
|
136
|
+
if (t.width && (t.height || shape !== 'rect')) return { w: t.width, h: t.height ?? t.width }
|
|
137
|
+
if (shape === 'round') {
|
|
138
|
+
const d = Math.max(60, 40 + n * 8)
|
|
139
|
+
return { w: d, h: d }
|
|
140
|
+
}
|
|
141
|
+
if (shape === 'square') return { w: 72, h: 72 }
|
|
142
|
+
return { w: Math.max(100, Math.ceil(n / 2) * 40 + 20), h: 72 }
|
|
143
|
+
}
|
|
144
|
+
/** Chairs around a table, as centers relative to its center */
|
|
145
|
+
function chairsOf(t: FloorTable, s: FloorBox): { x: number; y: number; r: number }[] {
|
|
146
|
+
const n = t.seats ?? 0
|
|
147
|
+
if (!props.chairs || !n) return []
|
|
148
|
+
const gap = CHAIR / 2 + 4
|
|
149
|
+
if ((t.shape ?? 'square') === 'round') {
|
|
150
|
+
return Array.from({ length: n }, (_, i) => {
|
|
151
|
+
const a = (i / n) * Math.PI * 2 - Math.PI / 2
|
|
152
|
+
return { x: Math.cos(a) * (s.w / 2 + gap), y: Math.sin(a) * (s.h / 2 + gap), r: (a * 180) / Math.PI + 90 }
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
// Long sides first (top and bottom), then the ends
|
|
156
|
+
const sides: { len: number; at: (f: number) => { x: number; y: number; r: number } }[] = [
|
|
157
|
+
{ len: s.w, at: (f) => ({ x: -s.w / 2 + f * s.w, y: -s.h / 2 - gap, r: 0 }) },
|
|
158
|
+
{ len: s.w, at: (f) => ({ x: -s.w / 2 + f * s.w, y: s.h / 2 + gap, r: 180 }) },
|
|
159
|
+
{ len: s.h, at: (f) => ({ x: -s.w / 2 - gap, y: -s.h / 2 + f * s.h, r: 270 }) },
|
|
160
|
+
{ len: s.h, at: (f) => ({ x: s.w / 2 + gap, y: -s.h / 2 + f * s.h, r: 90 }) },
|
|
161
|
+
]
|
|
162
|
+
const square = (t.shape ?? 'square') === 'square'
|
|
163
|
+
const per = [0, 0, 0, 0]
|
|
164
|
+
for (let i = 0; i < n; i++) {
|
|
165
|
+
if (square) per[i % 4]!++
|
|
166
|
+
else if (n > 2 && i >= n - 2 && n % 2 === 0 && n >= 6) per[i === n - 2 ? 2 : 3]!++
|
|
167
|
+
else per[i % 2]!++
|
|
168
|
+
}
|
|
169
|
+
return sides.flatMap((side, k) => Array.from({ length: per[k]! }, (_, i) => side.at((i + 1) / (per[k]! + 1))))
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// While a drag moves tables, their positions live here until the drop
|
|
173
|
+
const draft = shallowRef<Map<string | number, { x: number; y: number }> | null>(null)
|
|
174
|
+
const placed = computed(() =>
|
|
175
|
+
tables.value.map((t) => {
|
|
176
|
+
const at = draft.value?.get(t.id) ?? { x: t.x, y: t.y }
|
|
177
|
+
const size = sizeOf(t)
|
|
178
|
+
return { t, x: at.x, y: at.y, size, chairs: chairsOf(t, size), status: t.status ? props.statuses[t.status] : undefined }
|
|
179
|
+
}),
|
|
180
|
+
)
|
|
181
|
+
const ROLES = new Set(['primary', 'secondary', 'tertiary', 'error', 'success', 'surface'])
|
|
182
|
+
function look(st?: FloorStatus) {
|
|
183
|
+
if (!st || st.color === 'surface') return { background: 'var(--color-surface-container-highest)', color: 'var(--color-on-surface)' }
|
|
184
|
+
if (ROLES.has(st.color)) return { background: `var(--color-${st.color}-container)`, color: `var(--color-on-${st.color}-container)` }
|
|
185
|
+
return { background: st.color, color: '#fff' }
|
|
186
|
+
}
|
|
187
|
+
const mergeBoxes = computed(() =>
|
|
188
|
+
merges.value.map((m) => {
|
|
189
|
+
const ms = placed.value.filter((p) => m.tables.includes(p.t.id))
|
|
190
|
+
if (!ms.length) return null
|
|
191
|
+
const pad = CHAIR + 10
|
|
192
|
+
const x1 = Math.min(...ms.map((p) => p.x - p.size.w / 2)) - pad
|
|
193
|
+
const y1 = Math.min(...ms.map((p) => p.y - p.size.h / 2)) - pad
|
|
194
|
+
const x2 = Math.max(...ms.map((p) => p.x + p.size.w / 2)) + pad
|
|
195
|
+
const y2 = Math.max(...ms.map((p) => p.y + p.size.h / 2)) + pad
|
|
196
|
+
return { m, x: x1, y: y1, w: x2 - x1, h: y2 - y1 }
|
|
197
|
+
}).filter((b) => !!b),
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
// ── Dragging ────────────────────────────────────────────────────────────────────────────────────────────
|
|
201
|
+
let drag: { id: number; sx: number; sy: number; start: Map<string | number, { x: number; y: number }>; moved: boolean } | null = null
|
|
202
|
+
let suppressClick = false
|
|
203
|
+
const snap = (v: number) => (props.grid ? Math.round(v / props.grid) * props.grid : v)
|
|
204
|
+
function clamp(t: FloorTable, x: number, y: number) {
|
|
205
|
+
const s = sizeOf(t)
|
|
206
|
+
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)) }
|
|
207
|
+
}
|
|
208
|
+
function onDown(e: PointerEvent, t: FloorTable) {
|
|
209
|
+
if (!props.editable || e.button !== 0 || tool.value !== 'select') return
|
|
210
|
+
e.stopPropagation()
|
|
211
|
+
picked.value = null
|
|
212
|
+
if (!selection.value.includes(t.id)) selection.value = e.shiftKey || e.ctrlKey || e.metaKey ? [...selection.value, t.id] : [t.id]
|
|
213
|
+
const ids = selection.value.includes(t.id) ? selection.value : [t.id]
|
|
214
|
+
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 }
|
|
215
|
+
window.addEventListener('pointermove', onMove)
|
|
216
|
+
window.addEventListener('pointerup', onUp)
|
|
217
|
+
window.addEventListener('pointercancel', onUp)
|
|
218
|
+
}
|
|
219
|
+
function onMove(e: PointerEvent) {
|
|
220
|
+
if (!drag || e.pointerId !== drag.id) return
|
|
221
|
+
const dx = (e.clientX - drag.sx) / scale.value
|
|
222
|
+
const dy = (e.clientY - drag.sy) / scale.value
|
|
223
|
+
if (!drag.moved && Math.hypot(e.clientX - drag.sx, e.clientY - drag.sy) < 4) return
|
|
224
|
+
drag.moved = true
|
|
225
|
+
const next = new Map<string | number, { x: number; y: number }>()
|
|
226
|
+
for (const [id, p] of drag.start) next.set(id, clamp(tables.value.find((x) => x.id === id)!, p.x + dx, p.y + dy))
|
|
227
|
+
draft.value = next
|
|
228
|
+
}
|
|
229
|
+
function onUp(e: PointerEvent) {
|
|
230
|
+
if (!drag || e.pointerId !== drag.id) return
|
|
231
|
+
window.removeEventListener('pointermove', onMove)
|
|
232
|
+
window.removeEventListener('pointerup', onUp)
|
|
233
|
+
window.removeEventListener('pointercancel', onUp)
|
|
234
|
+
const d = draft.value
|
|
235
|
+
const moved = drag.moved && d && e.type !== 'pointercancel'
|
|
236
|
+
drag = null
|
|
237
|
+
draft.value = null
|
|
238
|
+
if (!moved) return
|
|
239
|
+
suppressClick = true
|
|
240
|
+
setTimeout(() => (suppressClick = false))
|
|
241
|
+
commitMoves(new Map([...d!].map(([id, p]) => [id, clamp(tables.value.find((x) => x.id === id)!, snap(p.x), snap(p.y))])))
|
|
242
|
+
}
|
|
243
|
+
function commitMoves(next: Map<string | number, { x: number; y: number }>) {
|
|
244
|
+
tables.value = tables.value.map((t) => (next.has(t.id) ? { ...t, ...next.get(t.id)! } : t))
|
|
245
|
+
emit('move', [...next].map(([id, p]) => ({ id, ...p })))
|
|
246
|
+
}
|
|
247
|
+
function onClick(e: MouseEvent, t: FloorTable) {
|
|
248
|
+
if (suppressClick) return
|
|
249
|
+
if (props.editable && !(e.shiftKey || e.ctrlKey || e.metaKey)) selection.value = [t.id]
|
|
250
|
+
emit('table-click', t, e)
|
|
251
|
+
}
|
|
252
|
+
function onKey(e: KeyboardEvent, t: FloorTable) {
|
|
253
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
254
|
+
e.preventDefault()
|
|
255
|
+
emit('table-click', t, e)
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
const dir = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[e.key]
|
|
259
|
+
if (!dir || !props.editable) return
|
|
260
|
+
e.preventDefault()
|
|
261
|
+
const step = (props.grid || 1) * (e.shiftKey ? 5 : 1)
|
|
262
|
+
const ids = selection.value.includes(t.id) ? selection.value : [t.id]
|
|
263
|
+
commitMoves(new Map(tables.value.filter((x) => ids.includes(x.id)).map((x) => [x.id, clamp(x, x.x + dir[0]! * step, x.y + dir[1]! * step)])))
|
|
264
|
+
}
|
|
265
|
+
onBeforeUnmount(() => {
|
|
266
|
+
window.removeEventListener('pointermove', onMove)
|
|
267
|
+
window.removeEventListener('pointerup', onUp)
|
|
268
|
+
window.removeEventListener('pointercancel', onUp)
|
|
269
|
+
})
|
|
270
|
+
// ── Zones, walls and decor ───────────────────────────────────────────────────────────────────────────────
|
|
271
|
+
const DECOR: Record<FloorDecor['kind'], { icon?: string; w: number; h: number }> = {
|
|
272
|
+
door: { icon: 'door_front', w: 60, h: 14 },
|
|
273
|
+
window: { icon: 'window', w: 80, h: 10 },
|
|
274
|
+
plant: { icon: 'potted_plant', w: 40, h: 40 },
|
|
275
|
+
column: { w: 30, h: 30 },
|
|
276
|
+
restroom: { icon: 'wc', w: 48, h: 48 },
|
|
277
|
+
kitchen: { icon: 'skillet', w: 48, h: 48 },
|
|
278
|
+
register: { icon: 'point_of_sale', w: 48, h: 48 },
|
|
279
|
+
stairs: { icon: 'stairs', w: 60, h: 60 },
|
|
280
|
+
label: { w: 120, h: 30 },
|
|
281
|
+
}
|
|
282
|
+
const decorSize = (d: FloorDecor) => ({ w: d.width ?? DECOR[d.kind].w, h: d.height ?? DECOR[d.kind].h })
|
|
283
|
+
function areaLook(color?: string) {
|
|
284
|
+
const c = color ?? 'secondary'
|
|
285
|
+
return ROLES.has(c) ? { background: `color-mix(in srgb, var(--color-${c}-container) 45%, transparent)`, borderColor: `var(--color-${c})` } : { background: `color-mix(in srgb, ${c} 18%, transparent)`, borderColor: c }
|
|
286
|
+
}
|
|
287
|
+
/** What's picked while editing, besides tables: an area, a wall or a decor item */
|
|
288
|
+
const picked = ref<{ kind: 'area' | 'wall' | 'decor'; id: string | number } | null>(null)
|
|
289
|
+
const isPicked = (kind: 'area' | 'wall' | 'decor', id: string | number) => picked.value?.kind === kind && picked.value.id === id
|
|
290
|
+
const toPlan = (e: { clientX: number; clientY: number }) => {
|
|
291
|
+
const r = root.value!.getBoundingClientRect()
|
|
292
|
+
return { x: (e.clientX - r.left) / scale.value, y: (e.clientY - r.top) / scale.value }
|
|
293
|
+
}
|
|
294
|
+
/** A generic drag in plan units: `move` gets the offset from where it started, `end` runs once if it moved */
|
|
295
|
+
function follow(e: PointerEvent, move: (dx: number, dy: number) => void, end: () => void) {
|
|
296
|
+
// Keys (Delete, Enter) reach the plan while something on it is being edited
|
|
297
|
+
root.value?.focus({ preventScroll: true })
|
|
298
|
+
const sx = e.clientX
|
|
299
|
+
const sy = e.clientY
|
|
300
|
+
let moved = false
|
|
301
|
+
const mv = (ev: PointerEvent) => {
|
|
302
|
+
if (ev.pointerId !== e.pointerId) return
|
|
303
|
+
if (!moved && Math.hypot(ev.clientX - sx, ev.clientY - sy) < 4) return
|
|
304
|
+
moved = true
|
|
305
|
+
move((ev.clientX - sx) / scale.value, (ev.clientY - sy) / scale.value)
|
|
306
|
+
}
|
|
307
|
+
const up = (ev: PointerEvent) => {
|
|
308
|
+
if (ev.pointerId !== e.pointerId) return
|
|
309
|
+
window.removeEventListener('pointermove', mv)
|
|
310
|
+
window.removeEventListener('pointerup', up)
|
|
311
|
+
window.removeEventListener('pointercancel', up)
|
|
312
|
+
if (moved) end()
|
|
313
|
+
}
|
|
314
|
+
window.addEventListener('pointermove', mv)
|
|
315
|
+
window.addEventListener('pointerup', up)
|
|
316
|
+
window.addEventListener('pointercancel', up)
|
|
317
|
+
}
|
|
318
|
+
const areaDraft = shallowRef<FloorArea | null>(null)
|
|
319
|
+
const shownAreas = computed(() => areas.value.map((a) => (areaDraft.value?.id === a.id ? areaDraft.value : a)).concat(areaDraft.value && !areas.value.some((a) => a.id === areaDraft.value!.id) ? [areaDraft.value] : []))
|
|
320
|
+
function onAreaDown(e: PointerEvent, a: FloorArea, resize: boolean) {
|
|
321
|
+
if (!props.editable || tool.value !== 'select' || e.button !== 0) return
|
|
322
|
+
e.stopPropagation()
|
|
323
|
+
picked.value = { kind: 'area', id: a.id }
|
|
324
|
+
selection.value = []
|
|
325
|
+
follow(e, (dx, dy) => {
|
|
326
|
+
areaDraft.value = resize
|
|
327
|
+
? { ...a, width: Math.max(props.grid || 20, a.width + dx), height: Math.max(props.grid || 20, a.height + dy) }
|
|
328
|
+
: { ...a, x: a.x + dx, y: a.y + dy }
|
|
329
|
+
}, () => {
|
|
330
|
+
const d = areaDraft.value!
|
|
331
|
+
areaDraft.value = null
|
|
332
|
+
areas.value = areas.value.map((x) => (x.id === a.id ? { ...d, x: snap(d.x), y: snap(d.y), width: snap(d.width) || d.width, height: snap(d.height) || d.height } : x))
|
|
333
|
+
})
|
|
334
|
+
}
|
|
335
|
+
const decorDraft = shallowRef<FloorDecor | null>(null)
|
|
336
|
+
const shownDecor = computed(() => decor.value.map((d) => (decorDraft.value?.id === d.id ? decorDraft.value : d)))
|
|
337
|
+
function onDecorDown(e: PointerEvent, d: FloorDecor) {
|
|
338
|
+
if (!props.editable || tool.value !== 'select' || e.button !== 0) return
|
|
339
|
+
e.stopPropagation()
|
|
340
|
+
picked.value = { kind: 'decor', id: d.id }
|
|
341
|
+
selection.value = []
|
|
342
|
+
follow(e, (dx, dy) => (decorDraft.value = { ...d, x: d.x + dx, y: d.y + dy }), () => {
|
|
343
|
+
const n = decorDraft.value!
|
|
344
|
+
decorDraft.value = null
|
|
345
|
+
decor.value = decor.value.map((x) => (x.id === d.id ? { ...n, x: snap(n.x), y: snap(n.y) } : x))
|
|
346
|
+
})
|
|
347
|
+
}
|
|
348
|
+
const wallDraft = shallowRef<FloorWall | null>(null)
|
|
349
|
+
const shownWalls = computed(() => walls.value.map((w) => (wallDraft.value?.id === w.id ? wallDraft.value : w)))
|
|
350
|
+
const wallPath = (w: FloorWall) => w.points.map(([x, y], i) => `${i ? 'L' : 'M'}${x * scale.value} ${y * scale.value}`).join('')
|
|
351
|
+
function onWallDown(e: PointerEvent, w: FloorWall, vertex = -1) {
|
|
352
|
+
if (!props.editable || tool.value !== 'select' || e.button !== 0) return
|
|
353
|
+
e.stopPropagation()
|
|
354
|
+
picked.value = { kind: 'wall', id: w.id }
|
|
355
|
+
selection.value = []
|
|
356
|
+
follow(e, (dx, dy) => {
|
|
357
|
+
wallDraft.value = { ...w, points: w.points.map(([x, y], i) => (vertex < 0 || i === vertex ? [x + dx, y + dy] : [x, y])) }
|
|
358
|
+
}, () => {
|
|
359
|
+
const n = wallDraft.value!
|
|
360
|
+
wallDraft.value = null
|
|
361
|
+
walls.value = walls.value.map((x) => (x.id === w.id ? { ...n, points: n.points.map(([x, y]) => [snap(x), snap(y)] as [number, number]) } : x))
|
|
362
|
+
})
|
|
363
|
+
}
|
|
364
|
+
// Drawing new walls and zones
|
|
365
|
+
const drawing = ref<[number, number][] | null>(null)
|
|
366
|
+
const hover = ref<[number, number] | null>(null)
|
|
367
|
+
let made = 0
|
|
368
|
+
const newId = (p: string) => `${p}${Date.now().toString(36)}${made++}`
|
|
369
|
+
function onPlanPointer(e: PointerEvent) {
|
|
370
|
+
if (!props.editable) return
|
|
371
|
+
if (tool.value === 'select') {
|
|
372
|
+
if (e.target === e.currentTarget || (e.target as Element).closest('svg') === svgEl.value) {
|
|
373
|
+
selection.value = []
|
|
374
|
+
picked.value = null
|
|
375
|
+
}
|
|
376
|
+
return
|
|
377
|
+
}
|
|
378
|
+
const p = toPlan(e)
|
|
379
|
+
const at: [number, number] = [snap(p.x), snap(p.y)]
|
|
380
|
+
if (tool.value === 'wall') {
|
|
381
|
+
drawing.value = [...(drawing.value ?? [at]), at]
|
|
382
|
+
return
|
|
383
|
+
}
|
|
384
|
+
const id = newId('area')
|
|
385
|
+
areaDraft.value = { id, x: at[0], y: at[1], width: 0, height: 0 }
|
|
386
|
+
follow(e, (dx, dy) => (areaDraft.value = { id, x: Math.min(at[0], at[0] + dx), y: Math.min(at[1], at[1] + dy), width: Math.abs(dx), height: Math.abs(dy) }), () => {
|
|
387
|
+
const d = areaDraft.value!
|
|
388
|
+
areaDraft.value = null
|
|
389
|
+
if (d.width > 10 && d.height > 10) {
|
|
390
|
+
areas.value = [...areas.value, { ...d, x: snap(d.x), y: snap(d.y), width: snap(d.width) || d.width, height: snap(d.height) || d.height }]
|
|
391
|
+
picked.value = { kind: 'area', id }
|
|
392
|
+
}
|
|
393
|
+
})
|
|
394
|
+
}
|
|
395
|
+
function onPlanMove(e: PointerEvent) {
|
|
396
|
+
if (drawing.value) {
|
|
397
|
+
const p = toPlan(e)
|
|
398
|
+
hover.value = [snap(p.x), snap(p.y)]
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function finishWall() {
|
|
402
|
+
const pts = drawing.value?.filter((p, i, a) => !i || p[0] !== a[i - 1]![0] || p[1] !== a[i - 1]![1])
|
|
403
|
+
drawing.value = null
|
|
404
|
+
hover.value = null
|
|
405
|
+
if (pts && pts.length > 1) walls.value = [...walls.value, { id: newId('wall'), points: pts }]
|
|
406
|
+
}
|
|
407
|
+
function onPlanKey(e: KeyboardEvent) {
|
|
408
|
+
if (drawing.value && (e.key === 'Enter' || e.key === 'Escape')) {
|
|
409
|
+
e.preventDefault()
|
|
410
|
+
if (e.key === 'Enter') finishWall()
|
|
411
|
+
else drawing.value = null
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
if (!props.editable || (e.key !== 'Delete' && e.key !== 'Backspace') || !picked.value) return
|
|
415
|
+
const { kind, id } = picked.value
|
|
416
|
+
e.preventDefault()
|
|
417
|
+
if (kind === 'area') areas.value = areas.value.filter((a) => a.id !== id)
|
|
418
|
+
if (kind === 'wall') walls.value = walls.value.filter((w) => w.id !== id)
|
|
419
|
+
if (kind === 'decor') decor.value = decor.value.filter((d) => d.id !== id)
|
|
420
|
+
picked.value = null
|
|
421
|
+
}
|
|
422
|
+
const svgEl = ref<SVGSVGElement>()
|
|
423
|
+
|
|
424
|
+
const ariaOf = (p: (typeof placed.value)[number]) =>
|
|
425
|
+
[p.t.label, p.status?.label, p.t.seats ? locale.floorSeats.replace('{n}', String(p.t.seats)) : '', p.t.badge !== undefined ? String(p.t.badge) : ''].filter(Boolean).join(', ')
|
|
426
|
+
const gridStyle = computed(() => {
|
|
427
|
+
const g = (props.grid >= 10 ? props.grid : props.grid * Math.ceil(10 / Math.max(1, props.grid))) * scale.value
|
|
428
|
+
return props.editable && props.showGrid && props.grid
|
|
429
|
+
? { backgroundImage: 'radial-gradient(circle, var(--color-outline-variant) 1px, transparent 1.2px)', backgroundSize: `${g}px ${g}px` }
|
|
430
|
+
: {}
|
|
431
|
+
})
|
|
432
|
+
</script>
|
|
433
|
+
|
|
434
|
+
<template>
|
|
435
|
+
<div
|
|
436
|
+
ref="root"
|
|
437
|
+
class="m3-floor-plan relative overflow-hidden rounded-xl bg-surface-container-low select-none"
|
|
438
|
+
:style="{ aspectRatio: `${width} / ${height}`, ...gridStyle }"
|
|
439
|
+
role="group"
|
|
440
|
+
tabindex="-1"
|
|
441
|
+
:aria-label="label ?? locale.floorPlan"
|
|
442
|
+
:class="editable && tool !== 'select' && 'cursor-crosshair'"
|
|
443
|
+
@pointerdown="onPlanPointer"
|
|
444
|
+
@pointermove="onPlanMove"
|
|
445
|
+
@dblclick="drawing && finishWall()"
|
|
446
|
+
@keydown="onPlanKey"
|
|
447
|
+
>
|
|
448
|
+
<!-- Zones -->
|
|
449
|
+
<div
|
|
450
|
+
v-for="a in shownAreas"
|
|
451
|
+
:key="`a${a.id}`"
|
|
452
|
+
class="absolute rounded-lg border"
|
|
453
|
+
:class="[editable && tool === 'select' ? 'cursor-move' : 'pointer-events-none', isPicked('area', a.id) && 'ring-2 ring-primary']"
|
|
454
|
+
:style="{ left: `${a.x * scale}px`, top: `${a.y * scale}px`, width: `${a.width * scale}px`, height: `${a.height * scale}px`, ...areaLook(a.color) }"
|
|
455
|
+
@pointerdown="onAreaDown($event, a, false)"
|
|
456
|
+
>
|
|
457
|
+
<span v-if="a.label" class="absolute top-1 left-2 text-label-medium text-on-surface-variant">{{ a.label }}</span>
|
|
458
|
+
<span
|
|
459
|
+
v-if="editable && isPicked('area', a.id)"
|
|
460
|
+
class="absolute -right-1.5 -bottom-1.5 size-3 cursor-nwse-resize rounded-xs border-2 border-primary bg-surface"
|
|
461
|
+
@pointerdown="onAreaDown($event, a, true)"
|
|
462
|
+
/>
|
|
463
|
+
</div>
|
|
464
|
+
|
|
465
|
+
<!-- Walls -->
|
|
466
|
+
<svg ref="svgEl" class="pointer-events-none absolute inset-0 size-full overflow-visible">
|
|
467
|
+
<g v-for="w in shownWalls" :key="`w${w.id}`">
|
|
468
|
+
<path
|
|
469
|
+
:d="wallPath(w)"
|
|
470
|
+
fill="none"
|
|
471
|
+
stroke-linecap="round"
|
|
472
|
+
stroke-linejoin="round"
|
|
473
|
+
class="stroke-on-surface-variant"
|
|
474
|
+
:class="[editable && tool === 'select' && 'pointer-events-auto cursor-move', isPicked('wall', w.id) && 'stroke-primary']"
|
|
475
|
+
:stroke-width="(w.thickness ?? 8) * scale"
|
|
476
|
+
@pointerdown="onWallDown($event, w)"
|
|
477
|
+
/>
|
|
478
|
+
<template v-if="editable && isPicked('wall', w.id)">
|
|
479
|
+
<circle
|
|
480
|
+
v-for="(pt, i) in w.points"
|
|
481
|
+
:key="i"
|
|
482
|
+
:cx="pt[0] * scale"
|
|
483
|
+
:cy="pt[1] * scale"
|
|
484
|
+
r="6"
|
|
485
|
+
class="pointer-events-auto cursor-move fill-surface stroke-primary"
|
|
486
|
+
stroke-width="2"
|
|
487
|
+
@pointerdown="onWallDown($event, w, i)"
|
|
488
|
+
/>
|
|
489
|
+
</template>
|
|
490
|
+
</g>
|
|
491
|
+
<path
|
|
492
|
+
v-if="drawing"
|
|
493
|
+
:d="wallPath({ id: 'new', points: hover ? [...drawing, hover] : drawing })"
|
|
494
|
+
fill="none"
|
|
495
|
+
class="stroke-primary"
|
|
496
|
+
stroke-dasharray="6 4"
|
|
497
|
+
stroke-linecap="round"
|
|
498
|
+
:stroke-width="8 * scale"
|
|
499
|
+
/>
|
|
500
|
+
</svg>
|
|
501
|
+
|
|
502
|
+
<!-- Decor -->
|
|
503
|
+
<div
|
|
504
|
+
v-for="d in shownDecor"
|
|
505
|
+
:key="`d${d.id}`"
|
|
506
|
+
class="absolute flex -translate-x-1/2 -translate-y-1/2 items-center justify-center text-on-surface-variant"
|
|
507
|
+
:class="[
|
|
508
|
+
d.kind === 'column' ? 'rounded-full bg-outline' : d.kind === 'door' || d.kind === 'window' ? 'rounded-xs bg-surface-container-highest' : d.kind === 'label' ? '' : 'rounded-lg bg-surface-container-high',
|
|
509
|
+
editable && tool === 'select' ? 'cursor-move' : 'pointer-events-none',
|
|
510
|
+
isPicked('decor', d.id) && 'ring-2 ring-primary',
|
|
511
|
+
]"
|
|
512
|
+
:style="{ left: `${d.x * scale}px`, top: `${d.y * scale}px`, width: `${decorSize(d).w * scale}px`, height: `${decorSize(d).h * scale}px`, rotate: `${d.rotation ?? 0}deg` }"
|
|
513
|
+
:aria-label="d.label ?? d.kind"
|
|
514
|
+
role="img"
|
|
515
|
+
@pointerdown="onDecorDown($event, d)"
|
|
516
|
+
>
|
|
517
|
+
<MIcon v-if="DECOR[d.kind].icon && d.kind !== 'door' && d.kind !== 'window'" :name="DECOR[d.kind].icon!" :size="Math.max(12, Math.min(decorSize(d).w, decorSize(d).h) * 0.6 * scale)" />
|
|
518
|
+
<span v-if="d.kind === 'label'" class="truncate text-title-small text-on-surface-variant" :style="{ fontSize: `${Math.max(10, 16 * scale)}px` }">{{ d.label }}</span>
|
|
519
|
+
</div>
|
|
520
|
+
|
|
521
|
+
<!-- Merged tables: one outline around the group -->
|
|
522
|
+
<div
|
|
523
|
+
v-for="b in mergeBoxes"
|
|
524
|
+
:key="`m${b!.m.id}`"
|
|
525
|
+
class="pointer-events-none absolute rounded-2xl border-2 border-dashed border-primary/60 bg-primary/5"
|
|
526
|
+
:style="{ left: `${b!.x * scale}px`, top: `${b!.y * scale}px`, width: `${b!.w * scale}px`, height: `${b!.h * scale}px` }"
|
|
527
|
+
>
|
|
528
|
+
<span v-if="b!.m.label" class="absolute -top-2.5 left-3 rounded-full bg-primary px-2 text-label-small text-on-primary">{{ b!.m.label }}</span>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
<div
|
|
532
|
+
v-for="p in placed"
|
|
533
|
+
:key="p.t.id"
|
|
534
|
+
class="absolute"
|
|
535
|
+
:class="!draft?.has(p.t.id) && 'transition-[left,top] duration-200 ease-out'"
|
|
536
|
+
:style="{ left: `${p.x * scale}px`, top: `${p.y * scale}px`, transform: `rotate(${p.t.rotation ?? 0}deg)` }"
|
|
537
|
+
>
|
|
538
|
+
<span
|
|
539
|
+
v-for="(ch, i) in p.chairs"
|
|
540
|
+
:key="i"
|
|
541
|
+
class="pointer-events-none absolute rounded-md bg-outline-variant"
|
|
542
|
+
:style="{ width: `${CHAIR * scale}px`, height: `${CHAIR * 0.75 * scale}px`, left: `${ch.x * scale}px`, top: `${ch.y * scale}px`, transform: `translate(-50%, -50%) rotate(${ch.r}deg)` }"
|
|
543
|
+
/>
|
|
544
|
+
<div
|
|
545
|
+
role="button"
|
|
546
|
+
tabindex="0"
|
|
547
|
+
class="absolute flex -translate-x-1/2 -translate-y-1/2 flex-col items-center justify-center gap-0.5 text-center shadow-elevation-1 outline-none transition-[box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-secondary"
|
|
548
|
+
:class="[
|
|
549
|
+
(p.t.shape ?? 'square') === 'round' ? 'rounded-full' : 'rounded-lg',
|
|
550
|
+
editable ? 'cursor-grab touch-none active:cursor-grabbing' : 'cursor-pointer hover:shadow-elevation-2',
|
|
551
|
+
selection.includes(p.t.id) && 'ring-2 ring-primary',
|
|
552
|
+
draft?.has(p.t.id) && 'shadow-elevation-3',
|
|
553
|
+
]"
|
|
554
|
+
:style="{ width: `${p.size.w * scale}px`, height: `${p.size.h * scale}px`, ...look(p.status), fontSize: `${Math.max(9, 14 * scale)}px` }"
|
|
555
|
+
:aria-label="ariaOf(p)"
|
|
556
|
+
:aria-pressed="editable ? selection.includes(p.t.id) : undefined"
|
|
557
|
+
@pointerdown="onDown($event, p.t)"
|
|
558
|
+
@click="onClick($event, p.t)"
|
|
559
|
+
@keydown="onKey($event, p.t)"
|
|
560
|
+
>
|
|
561
|
+
<slot name="table" :table="p.t" :status="p.status" :selected="selection.includes(p.t.id)">
|
|
562
|
+
<MIcon v-if="p.status?.icon && scale > 0.5" :name="p.status.icon" :size="Math.max(12, 18 * scale)" class="opacity-80" />
|
|
563
|
+
<span class="max-w-full truncate px-1 leading-tight font-medium">{{ p.t.label }}</span>
|
|
564
|
+
</slot>
|
|
565
|
+
<span
|
|
566
|
+
v-if="p.t.badge !== undefined"
|
|
567
|
+
class="absolute -top-2 -right-2 min-w-5 rounded-full bg-error px-1.5 text-center text-label-small leading-5 text-on-error"
|
|
568
|
+
:style="{ transform: `rotate(${-(p.t.rotation ?? 0)}deg)` }"
|
|
569
|
+
>{{ p.t.badge }}</span>
|
|
570
|
+
</div>
|
|
571
|
+
</div>
|
|
572
|
+
</div>
|
|
573
|
+
</template>
|
|
574
|
+
|
|
575
|
+
<style>
|
|
576
|
+
@layer base {
|
|
577
|
+
.m3-floor-plan {
|
|
578
|
+
width: 100%;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
</style>
|