floor-editor-ts 1.1.9 → 1.2.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/floor-editor.es.js +32 -77
- package/dist/floor-editor.es.js.map +1 -1
- package/package.json +1 -1
package/dist/floor-editor.es.js
CHANGED
|
@@ -4970,33 +4970,8 @@ var init_attachments = __esmMin((() => {
|
|
|
4970
4970
|
init_effects();
|
|
4971
4971
|
}));
|
|
4972
4972
|
//#endregion
|
|
4973
|
-
//#region node_modules/clsx/dist/clsx.mjs
|
|
4974
|
-
function r$1(e) {
|
|
4975
|
-
var t, f, n = "";
|
|
4976
|
-
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
4977
|
-
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
4978
|
-
var o = e.length;
|
|
4979
|
-
for (t = 0; t < o; t++) e[t] && (f = r$1(e[t])) && (n && (n += " "), n += f);
|
|
4980
|
-
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
4981
|
-
return n;
|
|
4982
|
-
}
|
|
4983
|
-
function clsx$1() {
|
|
4984
|
-
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r$1(e)) && (n && (n += " "), n += t);
|
|
4985
|
-
return n;
|
|
4986
|
-
}
|
|
4987
|
-
var init_clsx = __esmMin((() => {}));
|
|
4988
|
-
//#endregion
|
|
4989
4973
|
//#region node_modules/svelte/src/internal/shared/attributes.js
|
|
4990
4974
|
/**
|
|
4991
|
-
* Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values.
|
|
4992
|
-
* TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does)
|
|
4993
|
-
* @param {any} value
|
|
4994
|
-
*/
|
|
4995
|
-
function clsx(value) {
|
|
4996
|
-
if (typeof value === "object") return clsx$1(value);
|
|
4997
|
-
else return value !== null && value !== void 0 ? value : "";
|
|
4998
|
-
}
|
|
4999
|
-
/**
|
|
5000
4975
|
* @param {any} value
|
|
5001
4976
|
* @param {string | null} [hash]
|
|
5002
4977
|
* @param {Record<string, boolean>} [directives]
|
|
@@ -5105,7 +5080,6 @@ function to_style(value, styles) {
|
|
|
5105
5080
|
}
|
|
5106
5081
|
var whitespace;
|
|
5107
5082
|
var init_attributes$1 = __esmMin((() => {
|
|
5108
|
-
init_clsx();
|
|
5109
5083
|
init_utils$3();
|
|
5110
5084
|
whitespace = [..." \n\r\f\xA0\v"];
|
|
5111
5085
|
}));
|
|
@@ -64666,7 +64640,7 @@ var root_22 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -tr
|
|
|
64666
64640
|
var root_23 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -translate-x-1/2 bg-emerald-600 text-white px-3 py-1 rounded-full text-xs shadow">Click to place text label · Esc to cancel</div>`);
|
|
64667
64641
|
var root_24 = /* @__PURE__ */ from_html(`<div class="absolute top-2 left-1/2 -translate-x-1/2 bg-indigo-600 text-white px-3 py-1 rounded-full text-xs shadow"> </div>`);
|
|
64668
64642
|
var root_2$3 = /* @__PURE__ */ from_html(`<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <div class="absolute bottom-3 left-3 z-20 flex items-center gap-1 bg-white rounded-lg shadow-lg border border-gray-200 px-1 py-0.5"><button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-600 hover:text-gray-800 font-bold text-lg" title="Zoom Out (−)" aria-label="Zoom out">−</button> <button class="min-w-[3.5rem] h-7 flex items-center justify-center rounded hover:bg-gray-100 text-xs font-medium text-gray-600 hover:text-gray-800 tabular-nums" title="Reset to 100%" aria-label="Zoom to 100%"> </button> <button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-600 hover:text-gray-800 font-bold text-lg" title="Zoom In (+)" aria-label="Zoom in">+</button> <div class="w-px h-5 bg-gray-200"></div> <button class="w-7 h-7 flex items-center justify-center rounded hover:bg-gray-100 text-gray-500 hover:text-gray-700 text-sm" title="Zoom to Fit (F)" aria-label="Zoom to fit">⊞</button></div> <!>`, 1);
|
|
64669
|
-
var root$1 = /* @__PURE__ */ from_html(`<div role="application"><div><canvas aria-label="Floor plan editor canvas"></canvas></div> <!> <!></div>`);
|
|
64643
|
+
var root$1 = /* @__PURE__ */ from_html(`<div class="w-full h-full relative overflow-hidden" role="application"><div class="w-full h-full"><canvas aria-label="Floor plan editor canvas"></canvas></div> <!> <!></div>`);
|
|
64670
64644
|
function FloorPlanCanvas($$anchor, $$props) {
|
|
64671
64645
|
push($$props, true);
|
|
64672
64646
|
const $panMode = () => store_get(panMode, "$panMode", $$stores);
|
|
@@ -64763,6 +64737,7 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
64763
64737
|
user_effect(() => {
|
|
64764
64738
|
if ($$props.viewOnly) set(showRulers, false);
|
|
64765
64739
|
if ($$props.viewOnly) set(showMinimap, false);
|
|
64740
|
+
if ($$props.viewOnly) set(showDimensions, false);
|
|
64766
64741
|
});
|
|
64767
64742
|
user_effect(() => {
|
|
64768
64743
|
if ($$props.viewOnly) {
|
|
@@ -65127,36 +65102,25 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65127
65102
|
markDirty();
|
|
65128
65103
|
needsFitToCanvas = true;
|
|
65129
65104
|
}
|
|
65130
|
-
/** viewOnly: canvas
|
|
65105
|
+
/** viewOnly: canvas fills parent 100%, floor zoomed to fit edge-to-edge */
|
|
65131
65106
|
function layoutViewOnlyViewport() {
|
|
65132
|
-
|
|
65133
|
-
if (!container || !get(currentFloor)) return;
|
|
65107
|
+
if (!canvasFrame || !get(currentFloor)) return;
|
|
65134
65108
|
const bounds = getViewOnlyFitBounds(get(currentFloor));
|
|
65135
65109
|
if (!bounds) return;
|
|
65136
|
-
const maxW =
|
|
65137
|
-
const maxH =
|
|
65110
|
+
const maxW = canvasFrame.clientWidth;
|
|
65111
|
+
const maxH = canvasFrame.clientHeight;
|
|
65138
65112
|
if (maxW <= 0 || maxH <= 0) return;
|
|
65139
|
-
|
|
65140
|
-
|
|
65141
|
-
|
|
65142
|
-
|
|
65143
|
-
canvasH = maxH;
|
|
65144
|
-
canvasW = Math.floor(maxH * contentAspect);
|
|
65145
|
-
} else {
|
|
65146
|
-
canvasW = maxW;
|
|
65147
|
-
canvasH = Math.floor(maxW / contentAspect);
|
|
65148
|
-
}
|
|
65149
|
-
set(viewOnlyCanvasW, canvasW, true);
|
|
65150
|
-
set(viewOnlyCanvasH, canvasH, true);
|
|
65151
|
-
set(width, canvasW, true);
|
|
65152
|
-
set(height, canvasH, true);
|
|
65113
|
+
set(width, maxW, true);
|
|
65114
|
+
set(height, maxH, true);
|
|
65115
|
+
set(viewOnlyCanvasW, maxW, true);
|
|
65116
|
+
set(viewOnlyCanvasH, maxH, true);
|
|
65153
65117
|
if (canvas) {
|
|
65154
|
-
canvas.width =
|
|
65155
|
-
canvas.height =
|
|
65118
|
+
canvas.width = maxW;
|
|
65119
|
+
canvas.height = maxH;
|
|
65156
65120
|
}
|
|
65157
65121
|
set(camX, (bounds.minX + bounds.maxX) / 2);
|
|
65158
65122
|
set(camY, (bounds.minY + bounds.maxY) / 2);
|
|
65159
|
-
set(zoom, Math.min(
|
|
65123
|
+
set(zoom, Math.min(maxW / bounds.width, maxH / bounds.height), true);
|
|
65160
65124
|
set(zoom, Math.max(get(zoom), .1), true);
|
|
65161
65125
|
markDirty();
|
|
65162
65126
|
}
|
|
@@ -65634,18 +65598,19 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65634
65598
|
height
|
|
65635
65599
|
};
|
|
65636
65600
|
}
|
|
65637
|
-
/** Bounds for viewOnly fit: wall rect
|
|
65601
|
+
/** Bounds for viewOnly fit: wall rect incl. wall thickness */
|
|
65638
65602
|
function getViewOnlyFitBounds(floor = get(currentFloor)) {
|
|
65639
|
-
|
|
65640
|
-
|
|
65641
|
-
|
|
65603
|
+
var _floor$walls2;
|
|
65604
|
+
const wb = getFloorWallBounds(floor);
|
|
65605
|
+
if (!wb || !(floor === null || floor === void 0 || (_floor$walls2 = floor.walls) === null || _floor$walls2 === void 0 ? void 0 : _floor$walls2.length)) return wb;
|
|
65606
|
+
const pad = Math.max(...floor.walls.map((w) => w.thickness / 2), 8);
|
|
65642
65607
|
return {
|
|
65643
|
-
minX:
|
|
65644
|
-
minY:
|
|
65645
|
-
maxX:
|
|
65646
|
-
maxY:
|
|
65647
|
-
width:
|
|
65648
|
-
height:
|
|
65608
|
+
minX: wb.minX - pad,
|
|
65609
|
+
minY: wb.minY - pad,
|
|
65610
|
+
maxX: wb.maxX + pad,
|
|
65611
|
+
maxY: wb.maxY + pad,
|
|
65612
|
+
width: wb.width + pad * 2,
|
|
65613
|
+
height: wb.height + pad * 2
|
|
65649
65614
|
};
|
|
65650
65615
|
}
|
|
65651
65616
|
function getCanvasFrameStyle() {
|
|
@@ -65659,11 +65624,9 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65659
65624
|
}
|
|
65660
65625
|
canvasDirty = false;
|
|
65661
65626
|
ctx.clearRect(0, 0, get(width), get(height));
|
|
65662
|
-
|
|
65663
|
-
|
|
65664
|
-
|
|
65665
|
-
drawGrid();
|
|
65666
|
-
}
|
|
65627
|
+
ctx.fillStyle = "#f8f9fa";
|
|
65628
|
+
ctx.fillRect(0, 0, get(width), get(height));
|
|
65629
|
+
if (!$$props.viewOnly) drawGrid();
|
|
65667
65630
|
if (!$$props.viewOnly && get(layerVis).guides) drawGuides$1();
|
|
65668
65631
|
drawBackgroundImage();
|
|
65669
65632
|
const floor = get(currentFloor);
|
|
@@ -66318,8 +66281,7 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
66318
66281
|
resize();
|
|
66319
66282
|
setTextureLoadCallback(() => {});
|
|
66320
66283
|
const resizeObs = new ResizeObserver(resize);
|
|
66321
|
-
|
|
66322
|
-
if (resizeTarget) resizeObs.observe(resizeTarget);
|
|
66284
|
+
if (canvasFrame) resizeObs.observe(canvasFrame);
|
|
66323
66285
|
requestAnimationFrame(draw);
|
|
66324
66286
|
let initialFitDone = false;
|
|
66325
66287
|
const unsub1 = activeFloor.subscribe((f) => {
|
|
@@ -69190,10 +69152,9 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
69190
69152
|
var div = root$1();
|
|
69191
69153
|
event("keydown", $window, onKeyDown);
|
|
69192
69154
|
event("keyup", $window, onKeyUp);
|
|
69193
|
-
let classes;
|
|
69194
69155
|
var div_1 = child(div);
|
|
69195
69156
|
var canvas_1 = child(div_1);
|
|
69196
|
-
let
|
|
69157
|
+
let classes;
|
|
69197
69158
|
bind_this(canvas_1, ($$value) => canvas = $$value, () => canvas);
|
|
69198
69159
|
reset(div_1);
|
|
69199
69160
|
bind_this(div_1, ($$value) => canvasFrame = $$value, () => canvasFrame);
|
|
@@ -69724,17 +69685,11 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
69724
69685
|
});
|
|
69725
69686
|
reset(div);
|
|
69726
69687
|
template_effect(($0) => {
|
|
69727
|
-
classes = set_class(div, 1, "w-full h-full relative overflow-hidden", null, classes, {
|
|
69728
|
-
flex: $$props.viewOnly,
|
|
69729
|
-
"items-center": $$props.viewOnly,
|
|
69730
|
-
"justify-center": $$props.viewOnly
|
|
69731
|
-
});
|
|
69732
69688
|
set_style(div_1, $0);
|
|
69733
|
-
set_class(
|
|
69734
|
-
classes_1 = set_class(canvas_1, 1, clsx($$props.viewOnly ? "block" : "block w-full h-full"), null, classes_1, { "pointer-events-none": $$props.viewOnly });
|
|
69689
|
+
classes = set_class(canvas_1, 1, "block w-full h-full", null, classes, { "pointer-events-none": $$props.viewOnly });
|
|
69735
69690
|
set_attribute(canvas_1, "tabindex", $$props.viewOnly ? -1 : 0);
|
|
69736
|
-
set_style(canvas_1,
|
|
69737
|
-
}, [() =>
|
|
69691
|
+
set_style(canvas_1, `cursor: ${get(cursorStyle)};`);
|
|
69692
|
+
}, [() => getCanvasFrameStyle()]);
|
|
69738
69693
|
delegated("mousedown", canvas_1, onMouseDown);
|
|
69739
69694
|
delegated("mousemove", canvas_1, onMouseMove);
|
|
69740
69695
|
delegated("mouseup", canvas_1, onMouseUp);
|