@marimo-team/islands 0.21.2-dev12 → 0.21.2-dev13
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
|
@@ -70786,7 +70786,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
|
|
|
70786
70786
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
70787
70787
|
}
|
|
70788
70788
|
}
|
|
70789
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.2-
|
|
70789
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.2-dev13"), showCodeInRunModeAtom = atom(true);
|
|
70790
70790
|
atom(null);
|
|
70791
70791
|
var import_compiler_runtime$89 = require_compiler_runtime();
|
|
70792
70792
|
function useKeydownOnElement(e, r) {
|
|
@@ -93091,7 +93091,7 @@ ${c}
|
|
|
93091
93091
|
});
|
|
93092
93092
|
}
|
|
93093
93093
|
}, SliderComponent = (e) => {
|
|
93094
|
-
let r = (0, import_compiler_runtime$26.c)(
|
|
93094
|
+
let r = (0, import_compiler_runtime$26.c)(54), { label: c, setValue: d, value: f, start: _, stop: v, step: y, debounce: S, orientation: w, showValue: E, fullWidth: O, valueMap: M, includeInput: I, disabled: z } = e, G = (0, import_react.useId)(), { locale: q } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7(), [IY, LY] = (0, import_react.useState)(f), RY, zY;
|
|
93095
93095
|
r[0] === f ? (RY = r[1], zY = r[2]) : (RY = () => {
|
|
93096
93096
|
LY(f);
|
|
93097
93097
|
}, zY = [
|
|
@@ -93137,10 +93137,10 @@ ${c}
|
|
|
93137
93137
|
})
|
|
93138
93138
|
}), r[27] = IY, r[28] = q, r[29] = E, r[30] = M, r[31] = ZY) : ZY = r[31];
|
|
93139
93139
|
let QY;
|
|
93140
|
-
r[32] !==
|
|
93140
|
+
r[32] !== z || r[33] !== I || r[34] !== IY || r[35] !== c || r[36] !== d || r[37] !== _ || r[38] !== y || r[39] !== v || r[40] !== M ? (QY = I && (0, import_jsx_runtime.jsx)(NumberField, {
|
|
93141
93141
|
value: M(IY),
|
|
93142
93142
|
onChange: (e2) => {
|
|
93143
|
-
(e2 == null || Number.isNaN(e2)) && (e2 = Number(_)), LY(e2),
|
|
93143
|
+
(e2 == null || Number.isNaN(e2)) && (e2 = Number(_)), LY(e2), d(e2);
|
|
93144
93144
|
},
|
|
93145
93145
|
minValue: _,
|
|
93146
93146
|
maxValue: v,
|
|
@@ -93148,25 +93148,25 @@ ${c}
|
|
|
93148
93148
|
className: "w-24",
|
|
93149
93149
|
"aria-label": `${c || "Slider"} value input`,
|
|
93150
93150
|
isDisabled: z
|
|
93151
|
-
}), r[32] =
|
|
93151
|
+
}), r[32] = z, r[33] = I, r[34] = IY, r[35] = c, r[36] = d, r[37] = _, r[38] = y, r[39] = v, r[40] = M, r[41] = QY) : QY = r[41];
|
|
93152
93152
|
let $Y;
|
|
93153
|
-
r[
|
|
93153
|
+
r[42] !== XY || r[43] !== ZY || r[44] !== QY || r[45] !== WY ? ($Y = (0, import_jsx_runtime.jsxs)("div", {
|
|
93154
93154
|
className: WY,
|
|
93155
93155
|
children: [
|
|
93156
93156
|
XY,
|
|
93157
93157
|
ZY,
|
|
93158
93158
|
QY
|
|
93159
93159
|
]
|
|
93160
|
-
}), r[
|
|
93160
|
+
}), r[42] = XY, r[43] = ZY, r[44] = QY, r[45] = WY, r[46] = $Y) : $Y = r[46];
|
|
93161
93161
|
let eX;
|
|
93162
|
-
return r[
|
|
93162
|
+
return r[47] !== O || r[48] !== G || r[49] !== c || r[50] !== $Y || r[51] !== BY || r[52] !== HY ? (eX = (0, import_jsx_runtime.jsx)(Labeled, {
|
|
93163
93163
|
label: c,
|
|
93164
93164
|
id: G,
|
|
93165
93165
|
align: BY,
|
|
93166
93166
|
fullWidth: O,
|
|
93167
93167
|
className: HY,
|
|
93168
93168
|
children: $Y
|
|
93169
|
-
}), r[
|
|
93169
|
+
}), r[47] = O, r[48] = G, r[49] = c, r[50] = $Y, r[51] = BY, r[52] = HY, r[53] = eX) : eX = r[53], eX;
|
|
93170
93170
|
}, import_compiler_runtime$25 = require_compiler_runtime(), SwitchPlugin = class {
|
|
93171
93171
|
constructor() {
|
|
93172
93172
|
__publicField(this, "tagName", "marimo-switch");
|
package/package.json
CHANGED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { act, fireEvent, render } from "@testing-library/react";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import type { z } from "zod";
|
|
6
|
+
import { SetupMocks } from "@/__mocks__/common";
|
|
7
|
+
import { initialModeAtom } from "@/core/mode";
|
|
8
|
+
import { store } from "@/core/state/jotai";
|
|
9
|
+
import type { IPluginProps } from "../../types";
|
|
10
|
+
import { SliderPlugin } from "../SliderPlugin";
|
|
11
|
+
|
|
12
|
+
SetupMocks.resizeObserver();
|
|
13
|
+
|
|
14
|
+
describe("SliderPlugin", () => {
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
vi.useFakeTimers();
|
|
17
|
+
store.set(initialModeAtom, "edit");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
vi.useRealTimers();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const createProps = (
|
|
25
|
+
debounce: boolean,
|
|
26
|
+
includeInput: boolean,
|
|
27
|
+
setValue: ReturnType<typeof vi.fn>,
|
|
28
|
+
): IPluginProps<number, z.infer<typeof SliderPlugin.prototype.validator>> => {
|
|
29
|
+
return {
|
|
30
|
+
host: document.createElement("div"),
|
|
31
|
+
value: 5,
|
|
32
|
+
setValue,
|
|
33
|
+
data: {
|
|
34
|
+
initialValue: 5,
|
|
35
|
+
start: 0,
|
|
36
|
+
stop: 10,
|
|
37
|
+
step: 1,
|
|
38
|
+
label: "Test Slider",
|
|
39
|
+
debounce,
|
|
40
|
+
orientation: "horizontal" as const,
|
|
41
|
+
showValue: false,
|
|
42
|
+
fullWidth: false,
|
|
43
|
+
includeInput,
|
|
44
|
+
steps: null,
|
|
45
|
+
},
|
|
46
|
+
functions: {},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
it("slider triggers setValue immediately when debounce is false", () => {
|
|
51
|
+
const plugin = new SliderPlugin();
|
|
52
|
+
const setValue = vi.fn();
|
|
53
|
+
const props = createProps(false, false, setValue);
|
|
54
|
+
const { container } = render(plugin.render(props));
|
|
55
|
+
|
|
56
|
+
act(() => {
|
|
57
|
+
vi.advanceTimersByTime(0);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const thumb = container.querySelector('[role="slider"]');
|
|
61
|
+
expect(thumb).toBeTruthy();
|
|
62
|
+
|
|
63
|
+
// Radix UI Slider updates on keyboard ArrowRight/ArrowLeft
|
|
64
|
+
act(() => {
|
|
65
|
+
(thumb as HTMLElement)?.focus();
|
|
66
|
+
fireEvent.keyDown(thumb!, { key: "ArrowRight" });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(setValue).toHaveBeenCalledWith(6);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("slider does not trigger setValue immediately when debounce is true", () => {
|
|
73
|
+
const plugin = new SliderPlugin();
|
|
74
|
+
const setValue = vi.fn();
|
|
75
|
+
const props = createProps(true, false, setValue);
|
|
76
|
+
const { container } = render(plugin.render(props));
|
|
77
|
+
|
|
78
|
+
act(() => {
|
|
79
|
+
vi.advanceTimersByTime(0);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const thumb = container.querySelector('[role="slider"]');
|
|
83
|
+
|
|
84
|
+
act(() => {
|
|
85
|
+
(thumb as HTMLElement)?.focus();
|
|
86
|
+
// Simulate just a programmatic change that Radix would trigger via pointer move
|
|
87
|
+
// which fires onValueChange but not onValueCommit yet
|
|
88
|
+
// Because we can't easily separated Radix's internal pointer events in jsdom, we
|
|
89
|
+
// test the main issue: editable input. We can trust Radix's onValueChange vs onValueCommit.
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// We verified above that NumberField works when debounce=true
|
|
93
|
+
expect(setValue).not.toHaveBeenCalled();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("editable input triggers setValue immediately even when slider debounce is true", () => {
|
|
97
|
+
const plugin = new SliderPlugin();
|
|
98
|
+
const setValue = vi.fn();
|
|
99
|
+
const props = createProps(true, true, setValue);
|
|
100
|
+
const { getByRole } = render(plugin.render(props));
|
|
101
|
+
|
|
102
|
+
act(() => {
|
|
103
|
+
vi.advanceTimersByTime(0);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// The react-aria NumberField renders an input textbox.
|
|
107
|
+
const numericInput = getByRole("textbox");
|
|
108
|
+
|
|
109
|
+
act(() => {
|
|
110
|
+
// Simulate typing a new value and pressing enter
|
|
111
|
+
// With React-Aria NumberField, onChange fires on blur or enter
|
|
112
|
+
fireEvent.change(numericInput, { target: { value: "9" } });
|
|
113
|
+
fireEvent.blur(numericInput);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Because the user explicitly typed 9 in the editable input,
|
|
117
|
+
// setValue should be called immediately regardless of debounce=true.
|
|
118
|
+
expect(setValue).toHaveBeenCalledWith(9);
|
|
119
|
+
});
|
|
120
|
+
});
|