floor-editor-ts 1.1.9 → 1.2.2
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 +24 -79
- 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,19 +65598,10 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65634
65598
|
height
|
|
65635
65599
|
};
|
|
65636
65600
|
}
|
|
65637
|
-
/** Bounds for viewOnly fit: wall
|
|
65601
|
+
/** Bounds for viewOnly fit: outer wall edges */
|
|
65638
65602
|
function getViewOnlyFitBounds(floor = get(currentFloor)) {
|
|
65639
|
-
|
|
65640
|
-
|
|
65641
|
-
const margin = 40;
|
|
65642
|
-
return {
|
|
65643
|
-
minX: wallBounds.minX - margin,
|
|
65644
|
-
minY: wallBounds.minY - margin,
|
|
65645
|
-
maxX: wallBounds.maxX + margin,
|
|
65646
|
-
maxY: wallBounds.maxY + margin,
|
|
65647
|
-
width: wallBounds.width + margin * 2,
|
|
65648
|
-
height: wallBounds.height + margin * 2
|
|
65649
|
-
};
|
|
65603
|
+
if (!floor) return null;
|
|
65604
|
+
return getFloorBounds(floor, { includeWallThickness: true });
|
|
65650
65605
|
}
|
|
65651
65606
|
function getCanvasFrameStyle() {
|
|
65652
65607
|
return "width: 100%; height: 100%";
|
|
@@ -65659,11 +65614,9 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
65659
65614
|
}
|
|
65660
65615
|
canvasDirty = false;
|
|
65661
65616
|
ctx.clearRect(0, 0, get(width), get(height));
|
|
65662
|
-
|
|
65663
|
-
|
|
65664
|
-
|
|
65665
|
-
drawGrid();
|
|
65666
|
-
}
|
|
65617
|
+
ctx.fillStyle = "#f8f9fa";
|
|
65618
|
+
ctx.fillRect(0, 0, get(width), get(height));
|
|
65619
|
+
if (!$$props.viewOnly) drawGrid();
|
|
65667
65620
|
if (!$$props.viewOnly && get(layerVis).guides) drawGuides$1();
|
|
65668
65621
|
drawBackgroundImage();
|
|
65669
65622
|
const floor = get(currentFloor);
|
|
@@ -66318,8 +66271,7 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
66318
66271
|
resize();
|
|
66319
66272
|
setTextureLoadCallback(() => {});
|
|
66320
66273
|
const resizeObs = new ResizeObserver(resize);
|
|
66321
|
-
|
|
66322
|
-
if (resizeTarget) resizeObs.observe(resizeTarget);
|
|
66274
|
+
if (canvasFrame) resizeObs.observe(canvasFrame);
|
|
66323
66275
|
requestAnimationFrame(draw);
|
|
66324
66276
|
let initialFitDone = false;
|
|
66325
66277
|
const unsub1 = activeFloor.subscribe((f) => {
|
|
@@ -69190,10 +69142,9 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
69190
69142
|
var div = root$1();
|
|
69191
69143
|
event("keydown", $window, onKeyDown);
|
|
69192
69144
|
event("keyup", $window, onKeyUp);
|
|
69193
|
-
let classes;
|
|
69194
69145
|
var div_1 = child(div);
|
|
69195
69146
|
var canvas_1 = child(div_1);
|
|
69196
|
-
let
|
|
69147
|
+
let classes;
|
|
69197
69148
|
bind_this(canvas_1, ($$value) => canvas = $$value, () => canvas);
|
|
69198
69149
|
reset(div_1);
|
|
69199
69150
|
bind_this(div_1, ($$value) => canvasFrame = $$value, () => canvasFrame);
|
|
@@ -69724,17 +69675,11 @@ function FloorPlanCanvas($$anchor, $$props) {
|
|
|
69724
69675
|
});
|
|
69725
69676
|
reset(div);
|
|
69726
69677
|
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
69678
|
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 });
|
|
69679
|
+
classes = set_class(canvas_1, 1, "block w-full h-full", null, classes, { "pointer-events-none": $$props.viewOnly });
|
|
69735
69680
|
set_attribute(canvas_1, "tabindex", $$props.viewOnly ? -1 : 0);
|
|
69736
|
-
set_style(canvas_1,
|
|
69737
|
-
}, [() =>
|
|
69681
|
+
set_style(canvas_1, `cursor: ${get(cursorStyle)};`);
|
|
69682
|
+
}, [() => getCanvasFrameStyle()]);
|
|
69738
69683
|
delegated("mousedown", canvas_1, onMouseDown);
|
|
69739
69684
|
delegated("mousemove", canvas_1, onMouseMove);
|
|
69740
69685
|
delegated("mouseup", canvas_1, onMouseUp);
|