@marimo-team/islands 0.20.1 → 0.20.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/main.js
CHANGED
|
@@ -73400,7 +73400,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
73400
73400
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
73401
73401
|
}
|
|
73402
73402
|
}
|
|
73403
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.20.
|
|
73403
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.20.2"), showCodeInRunModeAtom = atom(true);
|
|
73404
73404
|
atom(null);
|
|
73405
73405
|
var import_compiler_runtime$88 = require_compiler_runtime();
|
|
73406
73406
|
function useKeydownOnElement(e, r) {
|
|
@@ -94128,6 +94128,10 @@ ${c}
|
|
|
94128
94128
|
let d = Math.min(r.x, c.x), f = Math.max(r.x, c.x), _ = Math.min(r.y, c.y), v = Math.max(r.y, c.y);
|
|
94129
94129
|
return e.x >= d && e.x <= f && e.y >= _ && e.y <= v;
|
|
94130
94130
|
}
|
|
94131
|
+
function isInAxes(e, r) {
|
|
94132
|
+
let [c, d, f, _] = r.axesPixelBounds;
|
|
94133
|
+
return e.x >= c && e.x <= f && e.y >= d && e.y <= _;
|
|
94134
|
+
}
|
|
94131
94135
|
var MatplotlibRenderer = (_k = class {
|
|
94132
94136
|
constructor(e, r) {
|
|
94133
94137
|
__privateAdd(this, _MatplotlibRenderer_instances);
|
|
@@ -94259,6 +94263,7 @@ ${c}
|
|
|
94259
94263
|
__privateGet(this, _e8).setPointerCapture(e.pointerId), __privateGet(this, _t5).focus();
|
|
94260
94264
|
let r = __privateGet(this, _d2).call(this, e), c = __privateGet(this, _r2);
|
|
94261
94265
|
if (e.shiftKey) {
|
|
94266
|
+
if (!isInAxes(r, __privateGet(this, _n4))) return;
|
|
94262
94267
|
__privateSet(this, _r2, {
|
|
94263
94268
|
type: "lasso",
|
|
94264
94269
|
points: [
|
|
@@ -94307,7 +94312,7 @@ ${c}
|
|
|
94307
94312
|
});
|
|
94308
94313
|
return;
|
|
94309
94314
|
}
|
|
94310
|
-
__privateGet(this, _h2).call(this) && __privateGet(this, _m).call(this);
|
|
94315
|
+
if (__privateGet(this, _h2).call(this) && __privateGet(this, _m).call(this), !isInAxes(r, __privateGet(this, _n4))) return;
|
|
94311
94316
|
let d = clampToAxes(r, __privateGet(this, _n4));
|
|
94312
94317
|
__privateSet(this, _r2, {
|
|
94313
94318
|
type: "box",
|
package/package.json
CHANGED
|
@@ -3,8 +3,14 @@ import { describe, expect, it } from "vitest";
|
|
|
3
3
|
import type { Data } from "../matplotlib-renderer";
|
|
4
4
|
import { visibleForTesting } from "../matplotlib-renderer";
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
|
|
6
|
+
const {
|
|
7
|
+
pixelToData,
|
|
8
|
+
dataToPixel,
|
|
9
|
+
pointInPolygon,
|
|
10
|
+
clampToAxes,
|
|
11
|
+
isPointInBox,
|
|
12
|
+
isInAxes,
|
|
13
|
+
} = visibleForTesting;
|
|
8
14
|
|
|
9
15
|
// A simple axes geometry for testing:
|
|
10
16
|
// axes occupy pixels [100, 50] to [500, 350] (400px wide, 300px tall)
|
|
@@ -150,3 +156,32 @@ describe("isPointInBox", () => {
|
|
|
150
156
|
expect(isPointInBox({ x: 5, y: 30 }, boxEnd, boxStart)).toBe(false);
|
|
151
157
|
});
|
|
152
158
|
});
|
|
159
|
+
|
|
160
|
+
describe("isInAxes", () => {
|
|
161
|
+
it("returns true for a point inside the axes", () => {
|
|
162
|
+
expect(isInAxes({ x: 300, y: 200 }, LINEAR_AXES)).toBe(true);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("returns true for a point on the boundary", () => {
|
|
166
|
+
expect(isInAxes({ x: 100, y: 50 }, LINEAR_AXES)).toBe(true); // top-left
|
|
167
|
+
expect(isInAxes({ x: 500, y: 350 }, LINEAR_AXES)).toBe(true); // bottom-right
|
|
168
|
+
expect(isInAxes({ x: 100, y: 350 }, LINEAR_AXES)).toBe(true); // bottom-left
|
|
169
|
+
expect(isInAxes({ x: 500, y: 50 }, LINEAR_AXES)).toBe(true); // top-right
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("returns false for a point left of axes", () => {
|
|
173
|
+
expect(isInAxes({ x: 99, y: 200 }, LINEAR_AXES)).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("returns false for a point right of axes", () => {
|
|
177
|
+
expect(isInAxes({ x: 501, y: 200 }, LINEAR_AXES)).toBe(false);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("returns false for a point above axes", () => {
|
|
181
|
+
expect(isInAxes({ x: 300, y: 49 }, LINEAR_AXES)).toBe(false);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("returns false for a point below axes", () => {
|
|
185
|
+
expect(isInAxes({ x: 300, y: 351 }, LINEAR_AXES)).toBe(false);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
@@ -257,6 +257,11 @@ function isPointInBox(
|
|
|
257
257
|
return pt.x >= minX && pt.x <= maxX && pt.y >= minY && pt.y <= maxY;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
function isInAxes(pt: PixelPoint, g: AxesGeometry): boolean {
|
|
261
|
+
const [axLeft, axTop, axRight, axBottom] = g.axesPixelBounds;
|
|
262
|
+
return pt.x >= axLeft && pt.x <= axRight && pt.y >= axTop && pt.y <= axBottom;
|
|
263
|
+
}
|
|
264
|
+
|
|
260
265
|
export const visibleForTesting = {
|
|
261
266
|
createScale,
|
|
262
267
|
pixelToData,
|
|
@@ -264,6 +269,7 @@ export const visibleForTesting = {
|
|
|
264
269
|
pointInPolygon,
|
|
265
270
|
clampToAxes,
|
|
266
271
|
isPointInBox,
|
|
272
|
+
isInAxes,
|
|
267
273
|
};
|
|
268
274
|
|
|
269
275
|
export class MatplotlibRenderer {
|
|
@@ -568,6 +574,9 @@ export class MatplotlibRenderer {
|
|
|
568
574
|
|
|
569
575
|
// Shift+click -> start lasso
|
|
570
576
|
if (e.shiftKey) {
|
|
577
|
+
if (!isInAxes(pt, this.#state)) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
571
580
|
this.#interaction = {
|
|
572
581
|
type: "lasso",
|
|
573
582
|
points: [clampToAxes(pt, this.#state)],
|
|
@@ -620,7 +629,10 @@ export class MatplotlibRenderer {
|
|
|
620
629
|
this.#clearSelection();
|
|
621
630
|
}
|
|
622
631
|
|
|
623
|
-
// Start new box selection
|
|
632
|
+
// Start new box selection (only inside axes)
|
|
633
|
+
if (!isInAxes(pt, this.#state)) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
624
636
|
const clamped = clampToAxes(pt, this.#state);
|
|
625
637
|
this.#interaction = {
|
|
626
638
|
type: "box",
|