@burdenoff/microfe-eventfullymanaged 2026.1030.2 → 2026.1101.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eventfullymanaged/api/eventApi.d.ts.map +1 -1
- package/dist/eventfullymanaged/api/eventApi.js +2 -0
- package/dist/eventfullymanaged/api/eventApi.js.map +1 -1
- package/dist/eventfullymanaged/components/FloorPlanZoneEditor.d.ts +24 -0
- package/dist/eventfullymanaged/components/FloorPlanZoneEditor.d.ts.map +1 -0
- package/dist/eventfullymanaged/components/FloorPlanZoneEditor.js +65 -0
- package/dist/eventfullymanaged/components/FloorPlanZoneEditor.js.map +1 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.d.ts +24 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.d.ts.map +1 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.js +169 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.js.map +1 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.d.ts +33 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.d.ts.map +1 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.js +248 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.js.map +1 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.d.ts +33 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.d.ts.map +1 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.js +78 -0
- package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.js.map +1 -0
- package/dist/eventfullymanaged/lib/floorPlanZones.d.ts +148 -0
- package/dist/eventfullymanaged/lib/floorPlanZones.d.ts.map +1 -0
- package/dist/eventfullymanaged/lib/floorPlanZones.js +239 -0
- package/dist/eventfullymanaged/lib/floorPlanZones.js.map +1 -0
- package/dist/eventfullymanaged/pages/venues/FloorPlansPage.d.ts.map +1 -1
- package/dist/eventfullymanaged/pages/venues/FloorPlansPage.js +367 -291
- package/dist/eventfullymanaged/pages/venues/FloorPlansPage.js.map +1 -1
- package/dist/eventfullymanaged/types/index.d.ts.map +1 -1
- package/dist/utils/pageContext.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloorPlanZoneEditor.js","names":[],"sources":["../../../src/eventfullymanaged/components/FloorPlanZoneEditor.tsx"],"sourcesContent":["import type { Zone } from '../lib/floorPlanZones';\nimport { ZoneCanvas } from './floorPlanEditor/ZoneCanvas';\nimport { ZoneDetailsPanel, ZoneEditorToolbar, ZoneListPanel } from './floorPlanEditor/ZonePanels';\nimport type { ZoneEditorState } from './floorPlanEditor/useZoneEditorState';\n\nexport type FloorPlanZoneEditorProps = {\n /** Editing session state, owned by the page (see useZoneEditorState). */\n editor: ZoneEditorState;\n planName: string;\n imageUrl: string;\n saving: boolean;\n /** Persist the edited zones. Resolve `true` on success; the parent closes the editor. */\n onSave: (zones: Zone[]) => Promise<boolean>;\n onCancel: () => void;\n};\n\n/**\n * Interactive zone/booth editor drawn over an uploaded floor-plan image.\n *\n * Zones are rectangles stored in percent of the image (see lib/floorPlanZones).\n * Pointer users draw, move and resize zones on the canvas; keyboard users add\n * zones with \"Add zone\" and move/resize the focused zone with the arrow keys.\n * While a save is in flight every input is disabled, so the request always\n * carries exactly what is on screen.\n */\nexport function FloorPlanZoneEditor({\n editor,\n planName,\n imageUrl,\n saving,\n onSave,\n onCancel,\n}: FloorPlanZoneEditorProps) {\n const { dirty } = editor;\n\n const handleSave = async () => {\n if (saving || editor.validateForSave().length > 0) {\n return;\n }\n await onSave(editor.zones);\n };\n\n return (\n <div className=\"flex flex-col\" data-testid=\"floor-plan-zone-editor\" aria-busy={saving}>\n <ZoneEditorToolbar\n mode={editor.mode}\n dirty={dirty}\n saving={saving}\n onModeChange={editor.setMode}\n onAddZone={() => editor.addZone()}\n onCancel={onCancel}\n onSave={handleSave}\n />\n <ZoneCanvas\n planName={planName}\n imageUrl={imageUrl}\n zones={editor.zones}\n selectedId={editor.selectedId}\n mode={editor.mode}\n disabled={saving}\n onSelect={editor.select}\n onRectChange={(zoneId, rect) => editor.updateZone(zoneId, { rect })}\n onDrawn={(rect) => editor.addZone(rect)}\n onRemove={editor.removeZone}\n />\n <div className=\"grid grid-cols-1 gap-4 border-t border-border-seam px-5 py-4 md:grid-cols-2\">\n <ZoneDetailsPanel\n selected={editor.selected}\n hasZones={editor.zones.length > 0}\n capacityText={editor.selected ? editor.capacityValue(editor.selected) : ''}\n capacityInvalid={editor.selected ? editor.invalidCapacityIds.has(editor.selected.id) : false}\n errors={editor.errors}\n disabled={saving}\n onChange={editor.updateZone}\n onCapacityChange={editor.setCapacityText}\n onRemove={editor.removeZone}\n />\n <ZoneListPanel\n zones={editor.zones}\n selectedId={editor.selectedId}\n summary={editor.summary}\n unplacedCount={editor.unplacedCount}\n disabled={saving}\n onSelect={(zoneId) => {\n editor.select(zoneId);\n editor.setMode('select');\n }}\n onAddZone={() => editor.addZone()}\n />\n </div>\n </div>\n );\n}\n"],"mappings":";;;;AAyBA,SAAgB,EAAoB,EAClC,WACA,aACA,aACA,WACA,WACA,eAC2B;CAC3B,IAAM,EAAE,aAAU;AASlB,QACE,kBAAC,OAAD;EAAK,WAAU;EAAgB,eAAY;EAAyB,aAAW;YAA/E;GACE,kBAAC,GAAD;IACE,MAAM,EAAO;IACN;IACC;IACR,cAAc,EAAO;IACrB,iBAAiB,EAAO,SAAS;IACvB;IACV,QAhBa,YAAY;AACzB,UAAU,EAAO,iBAAiB,CAAC,SAAS,KAGhD,MAAM,EAAO,EAAO,MAAM;;IAatB,CAAA;GACF,kBAAC,GAAD;IACY;IACA;IACV,OAAO,EAAO;IACd,YAAY,EAAO;IACnB,MAAM,EAAO;IACb,UAAU;IACV,UAAU,EAAO;IACjB,eAAe,GAAQ,MAAS,EAAO,WAAW,GAAQ,EAAE,SAAM,CAAC;IACnE,UAAU,MAAS,EAAO,QAAQ,EAAK;IACvC,UAAU,EAAO;IACjB,CAAA;GACF,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KACE,UAAU,EAAO;KACjB,UAAU,EAAO,MAAM,SAAS;KAChC,cAAc,EAAO,WAAW,EAAO,cAAc,EAAO,SAAS,GAAG;KACxE,iBAAiB,EAAO,WAAW,EAAO,mBAAmB,IAAI,EAAO,SAAS,GAAG,GAAG;KACvF,QAAQ,EAAO;KACf,UAAU;KACV,UAAU,EAAO;KACjB,kBAAkB,EAAO;KACzB,UAAU,EAAO;KACjB,CAAA,EACF,kBAAC,GAAD;KACE,OAAO,EAAO;KACd,YAAY,EAAO;KACnB,SAAS,EAAO;KAChB,eAAe,EAAO;KACtB,UAAU;KACV,WAAW,MAAW;AAEpB,MADA,EAAO,OAAO,EAAO,EACrB,EAAO,QAAQ,SAAS;;KAE1B,iBAAiB,EAAO,SAAS;KACjC,CAAA,CACE;;GACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Zone, ZoneRect } from '../../lib/floorPlanZones';
|
|
2
|
+
import { EditorMode } from './useZoneEditorState';
|
|
3
|
+
|
|
4
|
+
export type ZoneCanvasProps = {
|
|
5
|
+
planName: string;
|
|
6
|
+
imageUrl: string;
|
|
7
|
+
zones: Zone[];
|
|
8
|
+
selectedId: string | null;
|
|
9
|
+
mode: EditorMode;
|
|
10
|
+
/** While true (e.g. a save is in flight) the canvas ignores all input. */
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
onSelect: (zoneId: string | null) => void;
|
|
13
|
+
onRectChange: (zoneId: string, rect: ZoneRect) => void;
|
|
14
|
+
onDrawn: (rect: ZoneRect) => void;
|
|
15
|
+
onRemove: (zoneId: string) => void;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The floor-plan image with its zone overlay. The overlay box hugs the rendered
|
|
19
|
+
* image, so percent-based zones line up at any size. Pointer input draws (in
|
|
20
|
+
* draw mode), moves and resizes zones; a focused zone also responds to the
|
|
21
|
+
* keyboard (arrows move, Alt+arrows resize, Shift for 5% steps, Delete removes).
|
|
22
|
+
*/
|
|
23
|
+
export declare function ZoneCanvas({ planName, imageUrl, zones, selectedId, mode, disabled, onSelect, onRectChange, onDrawn, onRemove, }: ZoneCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=ZoneCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneCanvas.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAkBvD,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvD,OAAO,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAMF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,QAAQ,GACT,EAAE,eAAe,2CAoJjB"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { isUsableRect as e, moveRect as t, rectFromPoints as n, resizeRect as r } from "../../lib/floorPlanZones.js";
|
|
2
|
+
import { useRef as i, useState as a } from "react";
|
|
3
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
|
+
//#region src/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.tsx
|
|
5
|
+
var c = 1, l = 5, u = {
|
|
6
|
+
ArrowLeft: {
|
|
7
|
+
x: -1,
|
|
8
|
+
y: 0
|
|
9
|
+
},
|
|
10
|
+
ArrowRight: {
|
|
11
|
+
x: 1,
|
|
12
|
+
y: 0
|
|
13
|
+
},
|
|
14
|
+
ArrowUp: {
|
|
15
|
+
x: 0,
|
|
16
|
+
y: -1
|
|
17
|
+
},
|
|
18
|
+
ArrowDown: {
|
|
19
|
+
x: 0,
|
|
20
|
+
y: 1
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function d(e) {
|
|
24
|
+
return `Zone ${e.label}${e.capacity === void 0 ? "" : `, capacity ${e.capacity}`}`;
|
|
25
|
+
}
|
|
26
|
+
function f({ planName: d, imageUrl: f, zones: m, selectedId: h, mode: g, disabled: _, onSelect: v, onRectChange: y, onDrawn: b, onRemove: x }) {
|
|
27
|
+
let S = i(null), C = i(null), [w, T] = a(null), E = (e) => {
|
|
28
|
+
let t = S.current?.getBoundingClientRect();
|
|
29
|
+
return !t || t.width === 0 || t.height === 0 ? null : {
|
|
30
|
+
x: (e.clientX - t.left) / t.width * 100,
|
|
31
|
+
y: (e.clientY - t.top) / t.height * 100
|
|
32
|
+
};
|
|
33
|
+
}, D = (e, t) => {
|
|
34
|
+
e.preventDefault(), C.current = t, S.current?.setPointerCapture?.(e.pointerId);
|
|
35
|
+
}, O = (e) => {
|
|
36
|
+
let t = e.button === 0 && !_ ? E(e) : null;
|
|
37
|
+
if (t) {
|
|
38
|
+
if (g !== "draw") {
|
|
39
|
+
v(null);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
D(e, {
|
|
43
|
+
kind: "draw",
|
|
44
|
+
start: t
|
|
45
|
+
}), T(n(t, t));
|
|
46
|
+
}
|
|
47
|
+
}, k = (e, t, n) => {
|
|
48
|
+
let r = e.button === 0 && !_ && t.rect ? E(e) : null;
|
|
49
|
+
!r || !t.rect || (e.stopPropagation(), v(t.id), D(e, {
|
|
50
|
+
kind: n,
|
|
51
|
+
zoneId: t.id,
|
|
52
|
+
origin: r,
|
|
53
|
+
startRect: t.rect
|
|
54
|
+
}));
|
|
55
|
+
}, A = (e) => {
|
|
56
|
+
let i = C.current, a = i ? E(e) : null;
|
|
57
|
+
if (!i || !a) return;
|
|
58
|
+
if (i.kind === "draw") {
|
|
59
|
+
T(n(i.start, a));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let o = a.x - i.origin.x, s = a.y - i.origin.y, c = i.kind === "move" ? t : r;
|
|
63
|
+
y(i.zoneId, c(i.startRect, o, s));
|
|
64
|
+
}, j = () => {
|
|
65
|
+
let t = C.current;
|
|
66
|
+
if (C.current = null, t?.kind !== "draw") return;
|
|
67
|
+
let n = w;
|
|
68
|
+
T(null), n && e(n) && b(n);
|
|
69
|
+
}, M = () => {
|
|
70
|
+
C.current = null, T(null);
|
|
71
|
+
}, N = (e, n) => {
|
|
72
|
+
if (_) return;
|
|
73
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
74
|
+
e.preventDefault(), x(n.id);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (e.key === "Escape") {
|
|
78
|
+
v(null);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let i = u[e.key];
|
|
82
|
+
if (!i || !n.rect) return;
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
let a = e.shiftKey ? l : c, o = e.altKey ? r : t;
|
|
85
|
+
v(n.id), y(n.id, o(n.rect, i.x * a, i.y * a));
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ o("div", {
|
|
88
|
+
className: "flex justify-center bg-bg-sunken p-3",
|
|
89
|
+
children: /* @__PURE__ */ s("div", {
|
|
90
|
+
className: "relative inline-block max-w-full select-none",
|
|
91
|
+
children: [/* @__PURE__ */ o("img", {
|
|
92
|
+
src: f,
|
|
93
|
+
alt: `${d} floor plan`,
|
|
94
|
+
className: "block h-auto max-h-[32rem] w-auto max-w-full",
|
|
95
|
+
draggable: !1
|
|
96
|
+
}), /* @__PURE__ */ s("div", {
|
|
97
|
+
ref: S,
|
|
98
|
+
"data-testid": "floor-plan-canvas",
|
|
99
|
+
role: "group",
|
|
100
|
+
"aria-label": `${d} zone canvas`,
|
|
101
|
+
"aria-disabled": _,
|
|
102
|
+
className: `absolute inset-0 touch-none ${g === "draw" && !_ ? "cursor-crosshair" : "cursor-default"}`,
|
|
103
|
+
onPointerDown: O,
|
|
104
|
+
onPointerMove: A,
|
|
105
|
+
onPointerUp: j,
|
|
106
|
+
onPointerCancel: M,
|
|
107
|
+
children: [m.map((e) => e.rect ? /* @__PURE__ */ o(p, {
|
|
108
|
+
zone: e,
|
|
109
|
+
rect: e.rect,
|
|
110
|
+
active: e.id === h,
|
|
111
|
+
mode: g,
|
|
112
|
+
disabled: _,
|
|
113
|
+
onPointerDown: (t, n) => k(t, e, n),
|
|
114
|
+
onKeyDown: (t) => N(t, e),
|
|
115
|
+
onFocus: () => v(e.id)
|
|
116
|
+
}, e.id) : null), w ? /* @__PURE__ */ o("div", {
|
|
117
|
+
"data-testid": "zone-draft",
|
|
118
|
+
className: "pointer-events-none absolute rounded-md border-2 border-dashed border-accent-primary bg-action-primary-bg/20",
|
|
119
|
+
style: {
|
|
120
|
+
left: `${w.x}%`,
|
|
121
|
+
top: `${w.y}%`,
|
|
122
|
+
width: `${w.w}%`,
|
|
123
|
+
height: `${w.h}%`
|
|
124
|
+
}
|
|
125
|
+
}) : null]
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function p({ zone: e, rect: t, active: n, mode: r, disabled: i, onPointerDown: a, onKeyDown: c, onFocus: l }) {
|
|
131
|
+
let u = r === "draw" || i;
|
|
132
|
+
return /* @__PURE__ */ s("button", {
|
|
133
|
+
type: "button",
|
|
134
|
+
"aria-pressed": n,
|
|
135
|
+
"aria-label": d(e),
|
|
136
|
+
"data-zone-id": e.id,
|
|
137
|
+
className: `absolute flex flex-col items-center justify-center overflow-hidden rounded-md border p-0 text-[10px] font-medium leading-tight focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary ${u ? "pointer-events-none" : "cursor-move"} ${n ? "z-10 border-2 border-accent-primary bg-action-primary-bg/30 text-text-primary" : "border-accent-primary/70 bg-action-primary-bg/15 text-accent-primary"}`,
|
|
138
|
+
style: {
|
|
139
|
+
left: `${t.x}%`,
|
|
140
|
+
top: `${t.y}%`,
|
|
141
|
+
width: `${t.w}%`,
|
|
142
|
+
height: `${t.h}%`
|
|
143
|
+
},
|
|
144
|
+
title: e.label,
|
|
145
|
+
onPointerDown: (e) => a(e, "move"),
|
|
146
|
+
onKeyDown: c,
|
|
147
|
+
onFocus: l,
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ o("span", {
|
|
150
|
+
className: "max-w-full truncate px-1",
|
|
151
|
+
children: e.label
|
|
152
|
+
}),
|
|
153
|
+
e.capacity === void 0 ? null : /* @__PURE__ */ o("span", {
|
|
154
|
+
className: "max-w-full truncate px-1 text-text-muted",
|
|
155
|
+
children: e.capacity
|
|
156
|
+
}),
|
|
157
|
+
n && !u ? /* @__PURE__ */ o("span", {
|
|
158
|
+
"aria-hidden": "true",
|
|
159
|
+
"data-testid": "zone-resize-handle",
|
|
160
|
+
className: "absolute bottom-0 right-0 h-3 w-3 cursor-se-resize rounded-tl-sm bg-accent-primary",
|
|
161
|
+
onPointerDown: (e) => a(e, "resize")
|
|
162
|
+
}) : null
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
//#endregion
|
|
167
|
+
export { f as ZoneCanvas };
|
|
168
|
+
|
|
169
|
+
//# sourceMappingURL=ZoneCanvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneCanvas.js","names":[],"sources":["../../../../src/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport type { KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from 'react';\n\nimport { isUsableRect, moveRect, rectFromPoints, resizeRect } from '../../lib/floorPlanZones';\nimport type { Zone, ZoneRect } from '../../lib/floorPlanZones';\nimport type { EditorMode } from './useZoneEditorState';\n\ntype Point = { x: number; y: number };\n\ntype Interaction =\n | { kind: 'draw'; start: Point }\n | { kind: 'move' | 'resize'; zoneId: string; origin: Point; startRect: ZoneRect };\n\nconst KEY_STEP = 1;\nconst KEY_STEP_LARGE = 5;\n\nconst ARROW_DELTAS: Record<string, Point> = {\n ArrowLeft: { x: -1, y: 0 },\n ArrowRight: { x: 1, y: 0 },\n ArrowUp: { x: 0, y: -1 },\n ArrowDown: { x: 0, y: 1 },\n};\n\nexport type ZoneCanvasProps = {\n planName: string;\n imageUrl: string;\n zones: Zone[];\n selectedId: string | null;\n mode: EditorMode;\n /** While true (e.g. a save is in flight) the canvas ignores all input. */\n disabled: boolean;\n onSelect: (zoneId: string | null) => void;\n onRectChange: (zoneId: string, rect: ZoneRect) => void;\n onDrawn: (rect: ZoneRect) => void;\n onRemove: (zoneId: string) => void;\n};\n\nfunction zoneAriaLabel(zone: Zone): string {\n return `Zone ${zone.label}${zone.capacity !== undefined ? `, capacity ${zone.capacity}` : ''}`;\n}\n\n/**\n * The floor-plan image with its zone overlay. The overlay box hugs the rendered\n * image, so percent-based zones line up at any size. Pointer input draws (in\n * draw mode), moves and resizes zones; a focused zone also responds to the\n * keyboard (arrows move, Alt+arrows resize, Shift for 5% steps, Delete removes).\n */\nexport function ZoneCanvas({\n planName,\n imageUrl,\n zones,\n selectedId,\n mode,\n disabled,\n onSelect,\n onRectChange,\n onDrawn,\n onRemove,\n}: ZoneCanvasProps) {\n const overlayRef = useRef<HTMLDivElement | null>(null);\n const interactionRef = useRef<Interaction | null>(null);\n const [draft, setDraft] = useState<ZoneRect | null>(null);\n\n const toPercent = (event: ReactPointerEvent): Point | null => {\n const box = overlayRef.current?.getBoundingClientRect();\n if (!box || box.width === 0 || box.height === 0) {\n return null;\n }\n return { x: ((event.clientX - box.left) / box.width) * 100, y: ((event.clientY - box.top) / box.height) * 100 };\n };\n\n const startInteraction = (event: ReactPointerEvent, interaction: Interaction) => {\n event.preventDefault();\n interactionRef.current = interaction;\n // jsdom (unit tests) has no pointer capture; real browsers always do.\n overlayRef.current?.setPointerCapture?.(event.pointerId);\n };\n\n const handleOverlayPointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {\n const point = event.button === 0 && !disabled ? toPercent(event) : null;\n if (!point) {\n return;\n }\n if (mode !== 'draw') {\n onSelect(null);\n return;\n }\n startInteraction(event, { kind: 'draw', start: point });\n setDraft(rectFromPoints(point, point));\n };\n\n const beginZoneInteraction = (event: ReactPointerEvent, zone: Zone, kind: 'move' | 'resize') => {\n const point = event.button === 0 && !disabled && zone.rect ? toPercent(event) : null;\n if (!point || !zone.rect) {\n return;\n }\n event.stopPropagation();\n onSelect(zone.id);\n startInteraction(event, { kind, zoneId: zone.id, origin: point, startRect: zone.rect });\n };\n\n const handlePointerMove = (event: ReactPointerEvent<HTMLDivElement>) => {\n const interaction = interactionRef.current;\n const point = interaction ? toPercent(event) : null;\n if (!interaction || !point) {\n return;\n }\n if (interaction.kind === 'draw') {\n setDraft(rectFromPoints(interaction.start, point));\n return;\n }\n const dx = point.x - interaction.origin.x;\n const dy = point.y - interaction.origin.y;\n const transform = interaction.kind === 'move' ? moveRect : resizeRect;\n onRectChange(interaction.zoneId, transform(interaction.startRect, dx, dy));\n };\n\n const handlePointerUp = () => {\n const interaction = interactionRef.current;\n interactionRef.current = null;\n if (interaction?.kind !== 'draw') {\n return;\n }\n const rect = draft;\n setDraft(null);\n if (rect && isUsableRect(rect)) {\n onDrawn(rect);\n }\n };\n\n const handlePointerCancel = () => {\n interactionRef.current = null;\n setDraft(null);\n };\n\n const handleZoneKeyDown = (event: ReactKeyboardEvent, zone: Zone) => {\n if (disabled) {\n return;\n }\n if (event.key === 'Delete' || event.key === 'Backspace') {\n event.preventDefault();\n onRemove(zone.id);\n return;\n }\n if (event.key === 'Escape') {\n onSelect(null);\n return;\n }\n const direction = ARROW_DELTAS[event.key];\n if (!direction || !zone.rect) {\n return;\n }\n event.preventDefault();\n const step = event.shiftKey ? KEY_STEP_LARGE : KEY_STEP;\n const transform = event.altKey ? resizeRect : moveRect;\n onSelect(zone.id);\n onRectChange(zone.id, transform(zone.rect, direction.x * step, direction.y * step));\n };\n\n return (\n <div className=\"flex justify-center bg-bg-sunken p-3\">\n <div className=\"relative inline-block max-w-full select-none\">\n <img\n src={imageUrl}\n alt={`${planName} floor plan`}\n className=\"block h-auto max-h-[32rem] w-auto max-w-full\"\n draggable={false}\n />\n <div\n ref={overlayRef}\n data-testid=\"floor-plan-canvas\"\n role=\"group\"\n aria-label={`${planName} zone canvas`}\n aria-disabled={disabled}\n className={`absolute inset-0 touch-none ${mode === 'draw' && !disabled ? 'cursor-crosshair' : 'cursor-default'}`}\n onPointerDown={handleOverlayPointerDown}\n onPointerMove={handlePointerMove}\n onPointerUp={handlePointerUp}\n onPointerCancel={handlePointerCancel}\n >\n {zones.map((zone) =>\n zone.rect ? (\n <ZoneBox\n key={zone.id}\n zone={zone}\n rect={zone.rect}\n active={zone.id === selectedId}\n mode={mode}\n disabled={disabled}\n onPointerDown={(event, kind) => beginZoneInteraction(event, zone, kind)}\n onKeyDown={(event) => handleZoneKeyDown(event, zone)}\n onFocus={() => onSelect(zone.id)}\n />\n ) : null\n )}\n {draft ? (\n <div\n data-testid=\"zone-draft\"\n className=\"pointer-events-none absolute rounded-md border-2 border-dashed border-accent-primary bg-action-primary-bg/20\"\n style={{ left: `${draft.x}%`, top: `${draft.y}%`, width: `${draft.w}%`, height: `${draft.h}%` }}\n />\n ) : null}\n </div>\n </div>\n </div>\n );\n}\n\nfunction ZoneBox({\n zone,\n rect,\n active,\n mode,\n disabled,\n onPointerDown,\n onKeyDown,\n onFocus,\n}: {\n zone: Zone;\n rect: ZoneRect;\n active: boolean;\n mode: EditorMode;\n disabled: boolean;\n onPointerDown: (event: ReactPointerEvent, kind: 'move' | 'resize') => void;\n onKeyDown: (event: ReactKeyboardEvent) => void;\n onFocus: () => void;\n}) {\n const passive = mode === 'draw' || disabled;\n return (\n <button\n type=\"button\"\n aria-pressed={active}\n aria-label={zoneAriaLabel(zone)}\n data-zone-id={zone.id}\n className={`absolute flex flex-col items-center justify-center overflow-hidden rounded-md border p-0 text-[10px] font-medium leading-tight focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary ${\n passive ? 'pointer-events-none' : 'cursor-move'\n } ${\n active\n ? 'z-10 border-2 border-accent-primary bg-action-primary-bg/30 text-text-primary'\n : 'border-accent-primary/70 bg-action-primary-bg/15 text-accent-primary'\n }`}\n style={{ left: `${rect.x}%`, top: `${rect.y}%`, width: `${rect.w}%`, height: `${rect.h}%` }}\n title={zone.label}\n onPointerDown={(event) => onPointerDown(event, 'move')}\n onKeyDown={onKeyDown}\n onFocus={onFocus}\n >\n <span className=\"max-w-full truncate px-1\">{zone.label}</span>\n {zone.capacity !== undefined ? (\n <span className=\"max-w-full truncate px-1 text-text-muted\">{zone.capacity}</span>\n ) : null}\n {active && !passive ? (\n <span\n aria-hidden=\"true\"\n data-testid=\"zone-resize-handle\"\n className=\"absolute bottom-0 right-0 h-3 w-3 cursor-se-resize rounded-tl-sm bg-accent-primary\"\n onPointerDown={(event) => onPointerDown(event, 'resize')}\n />\n ) : null}\n </button>\n );\n}\n"],"mappings":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K;EACZ,gBAAgB,MAAU,EAAc,GAAO,OAAO;EAC3C;EACF;YAhBX;GAkBE,kBAAC,QAAD;IAAM,WAAU;cAA4B,EAAK;IAAa,CAAA;GAC7D,EAAK,aAAa,KAAA,IAEf,OADF,kBAAC,QAAD;IAAM,WAAU;cAA4C,EAAK;IAAgB,CAAA;GAElF,KAAU,CAAC,IACV,kBAAC,QAAD;IACE,eAAY;IACZ,eAAY;IACZ,WAAU;IACV,gBAAgB,MAAU,EAAc,GAAO,SAAS;IACxD,CAAA,GACA;GACG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Zone, ZoneSummary } from '../../lib/floorPlanZones';
|
|
2
|
+
import { EditorMode } from './useZoneEditorState';
|
|
3
|
+
|
|
4
|
+
export declare function ZoneEditorToolbar({ mode, dirty, saving, onModeChange, onAddZone, onCancel, onSave, }: {
|
|
5
|
+
mode: EditorMode;
|
|
6
|
+
dirty: boolean;
|
|
7
|
+
saving: boolean;
|
|
8
|
+
onModeChange: (mode: EditorMode) => void;
|
|
9
|
+
onAddZone: () => void;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
onSave: () => void;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function ZoneDetailsPanel({ selected, hasZones, capacityText, capacityInvalid, errors, disabled, onChange, onCapacityChange, onRemove, }: {
|
|
14
|
+
selected: Zone | null;
|
|
15
|
+
hasZones: boolean;
|
|
16
|
+
capacityText: string;
|
|
17
|
+
capacityInvalid: boolean;
|
|
18
|
+
errors: string[];
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
onChange: (zoneId: string, patch: Partial<Zone>) => void;
|
|
21
|
+
onCapacityChange: (zoneId: string, text: string) => void;
|
|
22
|
+
onRemove: (zoneId: string) => void;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare function ZoneListPanel({ zones, selectedId, summary, unplacedCount, disabled, onSelect, onAddZone, }: {
|
|
25
|
+
zones: Zone[];
|
|
26
|
+
selectedId: string | null;
|
|
27
|
+
summary: ZoneSummary;
|
|
28
|
+
unplacedCount: number;
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
onSelect: (zoneId: string) => void;
|
|
31
|
+
onAddZone: () => void;
|
|
32
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
//# sourceMappingURL=ZonePanels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZonePanels.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/components/floorPlanEditor/ZonePanels.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,KAAK,EACL,MAAM,EACN,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,MAAM,GACP,EAAE;IACD,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACzC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,2CAgDA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IACzD,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,2CAuFA;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,UAAU,EACV,OAAO,EACP,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,SAAS,GACV,EAAE;IACD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,2CAgCA"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { ZONE_TYPES as e, defaultPlacedRect as t, zoneTypeLabel as n } from "../../lib/floorPlanZones.js";
|
|
2
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
3
|
+
import { Crosshair as a, MousePointer2 as o, Plus as s, Save as c, SquareDashed as l, SquarePlus as u, Trash2 as d, X as f } from "lucide-react";
|
|
4
|
+
import { Badge as p, Button as m, Input as h, Select as g, SelectContent as _, SelectItem as v, SelectTrigger as y, SelectValue as b } from "@burdenoff/fe-libs/ui";
|
|
5
|
+
//#region src/eventfullymanaged/components/floorPlanEditor/ZonePanels.tsx
|
|
6
|
+
function x({ mode: e, dirty: t, saving: n, onModeChange: a, onAddZone: s, onCancel: d, onSave: p }) {
|
|
7
|
+
return /* @__PURE__ */ i("div", {
|
|
8
|
+
className: "flex flex-wrap items-center gap-2 border-b border-border-seam px-5 py-3",
|
|
9
|
+
children: [
|
|
10
|
+
/* @__PURE__ */ i("div", {
|
|
11
|
+
role: "group",
|
|
12
|
+
"aria-label": "Editor tool",
|
|
13
|
+
className: "flex items-center gap-1",
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ i(m, {
|
|
16
|
+
type: "button",
|
|
17
|
+
size: "sm",
|
|
18
|
+
variant: e === "select" ? "secondary" : "ghost",
|
|
19
|
+
"aria-pressed": e === "select",
|
|
20
|
+
disabled: n,
|
|
21
|
+
onClick: () => a("select"),
|
|
22
|
+
children: [/* @__PURE__ */ r(o, { className: "h-4 w-4" }), "Select"]
|
|
23
|
+
}),
|
|
24
|
+
/* @__PURE__ */ i(m, {
|
|
25
|
+
type: "button",
|
|
26
|
+
size: "sm",
|
|
27
|
+
variant: e === "draw" ? "secondary" : "ghost",
|
|
28
|
+
"aria-pressed": e === "draw",
|
|
29
|
+
disabled: n,
|
|
30
|
+
onClick: () => a("draw"),
|
|
31
|
+
children: [/* @__PURE__ */ r(l, { className: "h-4 w-4" }), "Draw zone"]
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ i(m, {
|
|
34
|
+
type: "button",
|
|
35
|
+
size: "sm",
|
|
36
|
+
variant: "ghost",
|
|
37
|
+
disabled: n,
|
|
38
|
+
onClick: s,
|
|
39
|
+
children: [/* @__PURE__ */ r(u, { className: "h-4 w-4" }), "Add zone"]
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ r("span", {
|
|
44
|
+
className: "text-xs text-text-muted",
|
|
45
|
+
children: e === "draw" ? "Drag on the map to draw a zone." : "Drag a zone to move it, or its corner to resize. Arrow keys nudge the focused zone; Alt+arrows resize it."
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ i("div", {
|
|
48
|
+
className: "ml-auto flex items-center gap-2",
|
|
49
|
+
children: [/* @__PURE__ */ i(m, {
|
|
50
|
+
type: "button",
|
|
51
|
+
size: "sm",
|
|
52
|
+
variant: "ghost",
|
|
53
|
+
onClick: d,
|
|
54
|
+
disabled: n,
|
|
55
|
+
children: [/* @__PURE__ */ r(f, { className: "h-4 w-4" }), t ? "Discard changes" : "Close editor"]
|
|
56
|
+
}), /* @__PURE__ */ i(m, {
|
|
57
|
+
type: "button",
|
|
58
|
+
size: "sm",
|
|
59
|
+
onClick: p,
|
|
60
|
+
disabled: n || !t,
|
|
61
|
+
children: [/* @__PURE__ */ r(c, { className: "h-4 w-4" }), n ? "Saving…" : "Save zones"]
|
|
62
|
+
})]
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function S({ selected: n, hasZones: o, capacityText: s, capacityInvalid: c, errors: l, disabled: u, onChange: f, onCapacityChange: p, onRemove: x }) {
|
|
68
|
+
let S = n?.type && !e.some((e) => e.value === n.type) ? n.type : null;
|
|
69
|
+
return /* @__PURE__ */ i("section", {
|
|
70
|
+
"aria-label": "Selected zone",
|
|
71
|
+
className: "space-y-3",
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ r("h3", {
|
|
74
|
+
className: "text-sm font-semibold text-text-primary",
|
|
75
|
+
children: "Zone details"
|
|
76
|
+
}),
|
|
77
|
+
n ? /* @__PURE__ */ i("fieldset", {
|
|
78
|
+
disabled: u,
|
|
79
|
+
className: "space-y-3",
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ i("label", {
|
|
82
|
+
className: "block space-y-1 text-sm",
|
|
83
|
+
children: [/* @__PURE__ */ r("span", {
|
|
84
|
+
className: "font-medium text-text-primary",
|
|
85
|
+
children: "Label"
|
|
86
|
+
}), /* @__PURE__ */ r(h, {
|
|
87
|
+
value: n.label,
|
|
88
|
+
maxLength: 60,
|
|
89
|
+
onChange: (e) => f(n.id, { label: e.target.value }),
|
|
90
|
+
"aria-label": "Zone label"
|
|
91
|
+
})]
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ i("div", {
|
|
94
|
+
className: "grid grid-cols-2 gap-3",
|
|
95
|
+
children: [/* @__PURE__ */ i("label", {
|
|
96
|
+
className: "block space-y-1 text-sm",
|
|
97
|
+
children: [/* @__PURE__ */ r("span", {
|
|
98
|
+
className: "font-medium text-text-primary",
|
|
99
|
+
children: "Type"
|
|
100
|
+
}), /* @__PURE__ */ i(g, {
|
|
101
|
+
value: n.type ?? "other",
|
|
102
|
+
disabled: u,
|
|
103
|
+
onValueChange: (e) => f(n.id, { type: e }),
|
|
104
|
+
children: [/* @__PURE__ */ r(y, {
|
|
105
|
+
"aria-label": "Zone type",
|
|
106
|
+
children: /* @__PURE__ */ r(b, {})
|
|
107
|
+
}), /* @__PURE__ */ i(_, { children: [e.map((e) => /* @__PURE__ */ r(v, {
|
|
108
|
+
value: e.value,
|
|
109
|
+
children: e.label
|
|
110
|
+
}, e.value)), S ? /* @__PURE__ */ r(v, {
|
|
111
|
+
value: S,
|
|
112
|
+
children: S
|
|
113
|
+
}) : null] })]
|
|
114
|
+
})]
|
|
115
|
+
}), /* @__PURE__ */ i("label", {
|
|
116
|
+
className: "block space-y-1 text-sm",
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ r("span", {
|
|
119
|
+
className: "font-medium text-text-primary",
|
|
120
|
+
children: "Capacity"
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ r(h, {
|
|
123
|
+
inputMode: "numeric",
|
|
124
|
+
value: s,
|
|
125
|
+
onChange: (e) => p(n.id, e.target.value),
|
|
126
|
+
placeholder: "e.g. 40",
|
|
127
|
+
"aria-label": "Zone capacity",
|
|
128
|
+
"aria-invalid": c
|
|
129
|
+
}),
|
|
130
|
+
c ? /* @__PURE__ */ r("span", {
|
|
131
|
+
className: "text-xs text-status-error-text",
|
|
132
|
+
children: "Use a whole number, or leave it empty."
|
|
133
|
+
}) : null
|
|
134
|
+
]
|
|
135
|
+
})]
|
|
136
|
+
}),
|
|
137
|
+
/* @__PURE__ */ i("div", {
|
|
138
|
+
className: "flex flex-wrap gap-2",
|
|
139
|
+
children: [n.rect ? null : /* @__PURE__ */ i(m, {
|
|
140
|
+
type: "button",
|
|
141
|
+
size: "sm",
|
|
142
|
+
variant: "outline",
|
|
143
|
+
onClick: () => f(n.id, { rect: t() }),
|
|
144
|
+
children: [/* @__PURE__ */ r(a, { className: "h-4 w-4" }), "Place on map"]
|
|
145
|
+
}), /* @__PURE__ */ i(m, {
|
|
146
|
+
type: "button",
|
|
147
|
+
size: "sm",
|
|
148
|
+
variant: "destructive",
|
|
149
|
+
onClick: () => x(n.id),
|
|
150
|
+
children: [/* @__PURE__ */ r(d, { className: "h-4 w-4" }), "Delete zone"]
|
|
151
|
+
})]
|
|
152
|
+
})
|
|
153
|
+
]
|
|
154
|
+
}) : /* @__PURE__ */ r("p", {
|
|
155
|
+
className: "text-sm text-text-secondary",
|
|
156
|
+
children: o ? "Select a zone on the map or in the list to edit its label, type and capacity." : "Choose \"Draw zone\" and drag across the map, or use \"Add zone\", to add your first booth, stage or entrance."
|
|
157
|
+
}),
|
|
158
|
+
l.length > 0 ? /* @__PURE__ */ r("ul", {
|
|
159
|
+
role: "alert",
|
|
160
|
+
className: "space-y-1 text-xs text-status-error-text",
|
|
161
|
+
children: l.map((e) => /* @__PURE__ */ r("li", { children: e }, e))
|
|
162
|
+
}) : null
|
|
163
|
+
]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function C({ zones: e, selectedId: t, summary: n, unplacedCount: a, disabled: o, onSelect: c, onAddZone: l }) {
|
|
167
|
+
return /* @__PURE__ */ i("section", {
|
|
168
|
+
"aria-label": "All zones",
|
|
169
|
+
className: "space-y-3",
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ i("div", {
|
|
172
|
+
className: "flex items-center justify-between gap-2",
|
|
173
|
+
children: [/* @__PURE__ */ r("h3", {
|
|
174
|
+
className: "text-sm font-semibold text-text-primary",
|
|
175
|
+
children: "Zones"
|
|
176
|
+
}), /* @__PURE__ */ i("span", {
|
|
177
|
+
className: "text-xs text-text-muted",
|
|
178
|
+
children: [
|
|
179
|
+
n.zones,
|
|
180
|
+
" ",
|
|
181
|
+
n.zones === 1 ? "zone" : "zones",
|
|
182
|
+
n.capacity > 0 ? ` · ${n.capacity.toLocaleString()} capacity` : ""
|
|
183
|
+
]
|
|
184
|
+
})]
|
|
185
|
+
}),
|
|
186
|
+
e.length === 0 ? /* @__PURE__ */ i(m, {
|
|
187
|
+
type: "button",
|
|
188
|
+
size: "sm",
|
|
189
|
+
variant: "outline",
|
|
190
|
+
disabled: o,
|
|
191
|
+
onClick: l,
|
|
192
|
+
children: [/* @__PURE__ */ r(s, { className: "h-4 w-4" }), "Add your first zone"]
|
|
193
|
+
}) : /* @__PURE__ */ r("ul", {
|
|
194
|
+
className: "max-h-60 space-y-1 overflow-y-auto",
|
|
195
|
+
role: "list",
|
|
196
|
+
children: e.map((e) => /* @__PURE__ */ r("li", { children: /* @__PURE__ */ r(w, {
|
|
197
|
+
zone: e,
|
|
198
|
+
active: e.id === t,
|
|
199
|
+
disabled: o,
|
|
200
|
+
onSelect: c
|
|
201
|
+
}) }, e.id))
|
|
202
|
+
}),
|
|
203
|
+
a > 0 ? /* @__PURE__ */ i("p", {
|
|
204
|
+
className: "text-xs text-text-muted",
|
|
205
|
+
children: [
|
|
206
|
+
a,
|
|
207
|
+
" ",
|
|
208
|
+
a === 1 ? "zone has" : "zones have",
|
|
209
|
+
" no position yet — select one and use “Place on map”."
|
|
210
|
+
]
|
|
211
|
+
}) : null
|
|
212
|
+
]
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function w({ zone: e, active: t, disabled: a, onSelect: o }) {
|
|
216
|
+
let s = n(e.type);
|
|
217
|
+
return /* @__PURE__ */ i("button", {
|
|
218
|
+
type: "button",
|
|
219
|
+
onClick: () => o(e.id),
|
|
220
|
+
"aria-pressed": t,
|
|
221
|
+
disabled: a,
|
|
222
|
+
className: `flex w-full items-center justify-between gap-2 rounded-md border px-3 py-1.5 text-left text-sm transition-colors ${t ? "border-accent-primary bg-action-primary-bg/10" : "border-border-seam hover:border-border-strong"}`,
|
|
223
|
+
children: [/* @__PURE__ */ r("span", {
|
|
224
|
+
className: "min-w-0 truncate text-text-primary",
|
|
225
|
+
children: e.label || "Untitled zone"
|
|
226
|
+
}), /* @__PURE__ */ i("span", {
|
|
227
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
228
|
+
children: [
|
|
229
|
+
s ? /* @__PURE__ */ r(p, {
|
|
230
|
+
variant: "outline",
|
|
231
|
+
children: s
|
|
232
|
+
}) : null,
|
|
233
|
+
e.capacity === void 0 ? null : /* @__PURE__ */ r("span", {
|
|
234
|
+
className: "text-xs tabular-nums text-text-muted",
|
|
235
|
+
children: e.capacity
|
|
236
|
+
}),
|
|
237
|
+
e.rect ? null : /* @__PURE__ */ r(p, {
|
|
238
|
+
variant: "secondary",
|
|
239
|
+
children: "Unplaced"
|
|
240
|
+
})
|
|
241
|
+
]
|
|
242
|
+
})]
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
//#endregion
|
|
246
|
+
export { S as ZoneDetailsPanel, x as ZoneEditorToolbar, C as ZoneListPanel };
|
|
247
|
+
|
|
248
|
+
//# sourceMappingURL=ZonePanels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZonePanels.js","names":[],"sources":["../../../../src/eventfullymanaged/components/floorPlanEditor/ZonePanels.tsx"],"sourcesContent":["import { Crosshair, MousePointer2, Plus, Save, SquareDashed, SquarePlus, Trash2, X } from 'lucide-react';\nimport {\n Badge,\n Button,\n Input,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nimport { MAX_LABEL_LENGTH, ZONE_TYPES, defaultPlacedRect, zoneTypeLabel } from '../../lib/floorPlanZones';\nimport type { Zone, ZoneSummary } from '../../lib/floorPlanZones';\nimport type { EditorMode } from './useZoneEditorState';\n\nexport function ZoneEditorToolbar({\n mode,\n dirty,\n saving,\n onModeChange,\n onAddZone,\n onCancel,\n onSave,\n}: {\n mode: EditorMode;\n dirty: boolean;\n saving: boolean;\n onModeChange: (mode: EditorMode) => void;\n onAddZone: () => void;\n onCancel: () => void;\n onSave: () => void;\n}) {\n return (\n <div className=\"flex flex-wrap items-center gap-2 border-b border-border-seam px-5 py-3\">\n <div role=\"group\" aria-label=\"Editor tool\" className=\"flex items-center gap-1\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant={mode === 'select' ? 'secondary' : 'ghost'}\n aria-pressed={mode === 'select'}\n disabled={saving}\n onClick={() => onModeChange('select')}\n >\n <MousePointer2 className=\"h-4 w-4\" />\n Select\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant={mode === 'draw' ? 'secondary' : 'ghost'}\n aria-pressed={mode === 'draw'}\n disabled={saving}\n onClick={() => onModeChange('draw')}\n >\n <SquareDashed className=\"h-4 w-4\" />\n Draw zone\n </Button>\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" disabled={saving} onClick={onAddZone}>\n <SquarePlus className=\"h-4 w-4\" />\n Add zone\n </Button>\n </div>\n <span className=\"text-xs text-text-muted\">\n {mode === 'draw'\n ? 'Drag on the map to draw a zone.'\n : 'Drag a zone to move it, or its corner to resize. Arrow keys nudge the focused zone; Alt+arrows resize it.'}\n </span>\n <div className=\"ml-auto flex items-center gap-2\">\n <Button type=\"button\" size=\"sm\" variant=\"ghost\" onClick={onCancel} disabled={saving}>\n <X className=\"h-4 w-4\" />\n {dirty ? 'Discard changes' : 'Close editor'}\n </Button>\n <Button type=\"button\" size=\"sm\" onClick={onSave} disabled={saving || !dirty}>\n <Save className=\"h-4 w-4\" />\n {saving ? 'Saving…' : 'Save zones'}\n </Button>\n </div>\n </div>\n );\n}\n\nexport function ZoneDetailsPanel({\n selected,\n hasZones,\n capacityText,\n capacityInvalid,\n errors,\n disabled,\n onChange,\n onCapacityChange,\n onRemove,\n}: {\n selected: Zone | null;\n hasZones: boolean;\n capacityText: string;\n capacityInvalid: boolean;\n errors: string[];\n disabled: boolean;\n onChange: (zoneId: string, patch: Partial<Zone>) => void;\n onCapacityChange: (zoneId: string, text: string) => void;\n onRemove: (zoneId: string) => void;\n}) {\n const customType =\n selected?.type && !ZONE_TYPES.some((entry) => entry.value === selected.type) ? selected.type : null;\n return (\n <section aria-label=\"Selected zone\" className=\"space-y-3\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Zone details</h3>\n {selected ? (\n <fieldset disabled={disabled} className=\"space-y-3\">\n <label className=\"block space-y-1 text-sm\">\n <span className=\"font-medium text-text-primary\">Label</span>\n <Input\n value={selected.label}\n maxLength={MAX_LABEL_LENGTH}\n onChange={(event) => onChange(selected.id, { label: event.target.value })}\n aria-label=\"Zone label\"\n />\n </label>\n <div className=\"grid grid-cols-2 gap-3\">\n <label className=\"block space-y-1 text-sm\">\n <span className=\"font-medium text-text-primary\">Type</span>\n <Select\n value={selected.type ?? 'other'}\n disabled={disabled}\n onValueChange={(value) => onChange(selected.id, { type: value })}\n >\n <SelectTrigger aria-label=\"Zone type\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {ZONE_TYPES.map((entry) => (\n <SelectItem key={entry.value} value={entry.value}>\n {entry.label}\n </SelectItem>\n ))}\n {customType ? <SelectItem value={customType}>{customType}</SelectItem> : null}\n </SelectContent>\n </Select>\n </label>\n <label className=\"block space-y-1 text-sm\">\n <span className=\"font-medium text-text-primary\">Capacity</span>\n <Input\n inputMode=\"numeric\"\n value={capacityText}\n onChange={(event) => onCapacityChange(selected.id, event.target.value)}\n placeholder=\"e.g. 40\"\n aria-label=\"Zone capacity\"\n aria-invalid={capacityInvalid}\n />\n {capacityInvalid ? (\n <span className=\"text-xs text-status-error-text\">Use a whole number, or leave it empty.</span>\n ) : null}\n </label>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n {!selected.rect ? (\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"outline\"\n onClick={() => onChange(selected.id, { rect: defaultPlacedRect() })}\n >\n <Crosshair className=\"h-4 w-4\" />\n Place on map\n </Button>\n ) : null}\n <Button type=\"button\" size=\"sm\" variant=\"destructive\" onClick={() => onRemove(selected.id)}>\n <Trash2 className=\"h-4 w-4\" />\n Delete zone\n </Button>\n </div>\n </fieldset>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n {hasZones\n ? 'Select a zone on the map or in the list to edit its label, type and capacity.'\n : 'Choose \"Draw zone\" and drag across the map, or use \"Add zone\", to add your first booth, stage or entrance.'}\n </p>\n )}\n {errors.length > 0 ? (\n <ul role=\"alert\" className=\"space-y-1 text-xs text-status-error-text\">\n {errors.map((message) => (\n <li key={message}>{message}</li>\n ))}\n </ul>\n ) : null}\n </section>\n );\n}\n\nexport function ZoneListPanel({\n zones,\n selectedId,\n summary,\n unplacedCount,\n disabled,\n onSelect,\n onAddZone,\n}: {\n zones: Zone[];\n selectedId: string | null;\n summary: ZoneSummary;\n unplacedCount: number;\n disabled: boolean;\n onSelect: (zoneId: string) => void;\n onAddZone: () => void;\n}) {\n return (\n <section aria-label=\"All zones\" className=\"space-y-3\">\n <div className=\"flex items-center justify-between gap-2\">\n <h3 className=\"text-sm font-semibold text-text-primary\">Zones</h3>\n <span className=\"text-xs text-text-muted\">\n {summary.zones} {summary.zones === 1 ? 'zone' : 'zones'}\n {summary.capacity > 0 ? ` · ${summary.capacity.toLocaleString()} capacity` : ''}\n </span>\n </div>\n {zones.length === 0 ? (\n <Button type=\"button\" size=\"sm\" variant=\"outline\" disabled={disabled} onClick={onAddZone}>\n <Plus className=\"h-4 w-4\" />\n Add your first zone\n </Button>\n ) : (\n <ul className=\"max-h-60 space-y-1 overflow-y-auto\" role=\"list\">\n {zones.map((zone) => (\n <li key={zone.id}>\n <ZoneListItem zone={zone} active={zone.id === selectedId} disabled={disabled} onSelect={onSelect} />\n </li>\n ))}\n </ul>\n )}\n {unplacedCount > 0 ? (\n <p className=\"text-xs text-text-muted\">\n {unplacedCount} {unplacedCount === 1 ? 'zone has' : 'zones have'} no position yet — select one and use “Place\n on map”.\n </p>\n ) : null}\n </section>\n );\n}\n\nfunction ZoneListItem({\n zone,\n active,\n disabled,\n onSelect,\n}: {\n zone: Zone;\n active: boolean;\n disabled: boolean;\n onSelect: (zoneId: string) => void;\n}) {\n const typeLabel = zoneTypeLabel(zone.type);\n return (\n <button\n type=\"button\"\n onClick={() => onSelect(zone.id)}\n aria-pressed={active}\n disabled={disabled}\n className={`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-1.5 text-left text-sm transition-colors ${\n active ? 'border-accent-primary bg-action-primary-bg/10' : 'border-border-seam hover:border-border-strong'\n }`}\n >\n <span className=\"min-w-0 truncate text-text-primary\">{zone.label || 'Untitled zone'}</span>\n <span className=\"flex shrink-0 items-center gap-1.5\">\n {typeLabel ? <Badge variant=\"outline\">{typeLabel}</Badge> : null}\n {zone.capacity !== undefined ? (\n <span className=\"text-xs tabular-nums text-text-muted\">{zone.capacity}</span>\n ) : null}\n {!zone.rect ? <Badge variant=\"secondary\">Unplaced</Badge> : null}\n </span>\n </button>\n );\n}\n"],"mappings":";;;;;AAgBA,SAAgB,EAAkB,EAChC,SACA,UACA,WACA,iBACA,cACA,aACA,aASC;AACD,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,OAAD;IAAK,MAAK;IAAQ,cAAW;IAAc,WAAU;cAArD;KACE,kBAAC,GAAD;MACE,MAAK;MACL,MAAK;MACL,SAAS,MAAS,WAAW,cAAc;MAC3C,gBAAc,MAAS;MACvB,UAAU;MACV,eAAe,EAAa,SAAS;gBANvC,CAQE,kBAAC,GAAD,EAAe,WAAU,WAAY,CAAA,EAAA,SAE9B;;KACT,kBAAC,GAAD;MACE,MAAK;MACL,MAAK;MACL,SAAS,MAAS,SAAS,cAAc;MACzC,gBAAc,MAAS;MACvB,UAAU;MACV,eAAe,EAAa,OAAO;gBANrC,CAQE,kBAAC,GAAD,EAAc,WAAU,WAAY,CAA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AK,SAAS;GAAuB,CAAA,EAC3F,kBAAC,QAAD;GAAM,WAAU;aAAhB;IACG,IAAY,kBAAC,GAAD;KAAO,SAAQ;eAAW;KAAkB,CAAA,GAAG;IAC3D,EAAK,aAAa,KAAA,IAEf,OADF,kBAAC,QAAD;KAAM,WAAU;eAAwC,EAAK;KAAgB,CAAA;IAE7E,EAAK,OAAqD,OAA9C,kBAAC,GAAD;KAAO,SAAQ;eAAY;KAAgB,CAAA;IACpD;KACA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Zone, ZoneRect, ZoneSummary } from '../../lib/floorPlanZones';
|
|
2
|
+
|
|
3
|
+
export type EditorMode = 'select' | 'draw';
|
|
4
|
+
export type ZoneEditorState = {
|
|
5
|
+
zones: Zone[];
|
|
6
|
+
selected: Zone | null;
|
|
7
|
+
selectedId: string | null;
|
|
8
|
+
mode: EditorMode;
|
|
9
|
+
summary: ZoneSummary;
|
|
10
|
+
unplacedCount: number;
|
|
11
|
+
errors: string[];
|
|
12
|
+
dirty: boolean;
|
|
13
|
+
invalidCapacityIds: ReadonlySet<string>;
|
|
14
|
+
setMode: (mode: EditorMode) => void;
|
|
15
|
+
select: (zoneId: string | null) => void;
|
|
16
|
+
updateZone: (zoneId: string, patch: Partial<Zone>) => void;
|
|
17
|
+
removeZone: (zoneId: string) => void;
|
|
18
|
+
/** Add a zone at `rect` (or a default centred rectangle) and select it. */
|
|
19
|
+
addZone: (rect?: ZoneRect) => void;
|
|
20
|
+
capacityValue: (zone: Zone) => string;
|
|
21
|
+
setCapacityText: (zoneId: string, text: string) => void;
|
|
22
|
+
/** Validate for saving: returns the messages to show, or an empty list when the zones can be saved. */
|
|
23
|
+
validateForSave: () => string[];
|
|
24
|
+
/** Start a fresh editing session from `zones` (the saved state that `dirty` compares against). */
|
|
25
|
+
reset: (zones: Zone[]) => void;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* All editor state and its mutations, kept apart from the pointer/canvas wiring.
|
|
29
|
+
* The page owns this hook (so it can read `dirty` to guard navigation without
|
|
30
|
+
* an effect) and starts each editing session with `reset(zonesOfThePlan)`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useZoneEditorState(seedZones?: Zone[]): ZoneEditorState;
|
|
33
|
+
//# sourceMappingURL=useZoneEditorState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useZoneEditorState.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5E,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AAK3C,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACpC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACxC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC3D,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,2EAA2E;IAC3E,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAC;IACnC,aAAa,EAA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