@marimo-team/frontend 0.25.3-dev134 → 0.25.3-dev136
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/assets/{CellStatus-DC6FFQOg.js → CellStatus-B9hoYYSq.js} +1 -1
- package/dist/assets/{ErrorBoundary-Ce-Ujlwj.js → ErrorBoundary-DIoi62xQ.js} +2 -2
- package/dist/assets/{JsonOutput-CfEBzaqW.js → JsonOutput-f0zvWw7g.js} +5 -5
- package/dist/assets/{MarimoErrorOutput-Bh6o9zle.js → MarimoErrorOutput-DFCWAXPj.js} +4 -4
- package/dist/assets/{RenderHTML-COGZsXQV.js → RenderHTML-CJOIsfDF.js} +2 -2
- package/dist/assets/{RunButton-DQ51plUv.js → RunButton-BhbOSnBI.js} +1 -1
- package/dist/assets/{add-cell-with-ai-D7gtGUsg.js → add-cell-with-ai-xzt8ZIZY.js} +26 -26
- package/dist/assets/{add-connection-dialog-CpMCc97S.js → add-connection-dialog-CLcZdzEt.js} +51 -51
- package/dist/assets/{agent-panel-BSFYqJ9B.js → agent-panel-x_kvcauj.js} +3 -3
- package/dist/assets/ai-model-dropdown-DcOMJlL4.js +13 -0
- package/dist/assets/{app-config-button-Cfcg_5Bz.js → app-config-button-gr-9epH3.js} +1 -1
- package/dist/assets/{blob-CszMu60N.js → blob-B25C4ORK.js} +1 -1
- package/dist/assets/{cache-panel-DuBsA6oO.js → cache-panel-BK4-1NJC.js} +1 -1
- package/dist/assets/cell-editor-CO_2xdmY.js +42 -0
- package/dist/assets/{cell-link-Cj0gGaMV.js → cell-link-DBP_BcJY.js} +1 -1
- package/dist/assets/{cells-SvbLY10y.js → cells-B9RIIuYa.js} +42 -42
- package/dist/assets/{chat-display-D43_g3TX.js → chat-display-CvnF2GaH.js} +1 -1
- package/dist/assets/{chat-panel-B_HAJMwx.js → chat-panel-CJFHiZ2R.js} +2 -2
- package/dist/assets/{chat-ui-BEcYCphu.js → chat-ui-DbPlwime.js} +1 -1
- package/dist/assets/{column-preview-CrzaJKk8.js → column-preview-j0kenrsq.js} +1 -1
- package/dist/assets/{command-palette-Bm9yIVcD.js → command-palette-CQ1DPGNl.js} +1 -1
- package/dist/assets/{common-BJyUxCzv.js → common-C9Gvbmz5.js} +1 -1
- package/dist/assets/{components-D1f_Cz4i.js → components-CMj235gS.js} +1 -1
- package/dist/assets/{datasource-C8KSVfSD.js → datasource-BsklC6tp.js} +2 -2
- package/dist/assets/{dependency-graph-panel-BhmyJbUl.js → dependency-graph-panel-BNqY5al9.js} +3 -3
- package/dist/assets/{documentation-panel-DcVG0Q0d.js → documentation-panel-UrRQcsOB.js} +1 -1
- package/dist/assets/{download-Bx52VRE4.js → download-BRqw2JzE.js} +1 -1
- package/dist/assets/{edit-page-DUrwOHR-.js → edit-page-Dqkmdmfj.js} +6 -6
- package/dist/assets/{error-entries-11OuHzUF.js → error-entries-CuIzi5P7.js} +1 -1
- package/dist/assets/{error-panel-XJy5S25F.js → error-panel-CFCs0M8e.js} +1 -1
- package/dist/assets/{feedback-button-B7jh_B4w.js → feedback-button-DZVOiUEf.js} +2 -2
- package/dist/assets/feedback-button-J9hRaX_K.js +1 -0
- package/dist/assets/{file-explorer-panel-CnVxbF4A.js → file-explorer-panel-Cqey5tMY.js} +1 -1
- package/dist/assets/{file-name-input-BJuqjQqH.js → file-name-input-khW7mtt2.js} +1 -1
- package/dist/assets/{floating-outline-8yyZ-MOJ.js → floating-outline-CSwtWNm9.js} +1 -1
- package/dist/assets/{formatting-DW2u7HXI.js → formatting-CMgDQsM2.js} +1 -1
- package/dist/assets/{gallery-page-DJvGHePf.js → gallery-page-CcG0Msi3.js} +1 -1
- package/dist/assets/{glide-data-editor-Cyc8DHZx.js → glide-data-editor-B46-8C6x.js} +1 -1
- package/dist/assets/{home-page-tRZJmSU6.js → home-page-C5qcnnak.js} +1 -1
- package/dist/assets/{hooks-CxGwybGw.js → hooks-CiNPyjez.js} +1 -1
- package/dist/assets/index-D1hW_v1v.js +30 -0
- package/dist/assets/{input-DLA5Dhn3.js → input-BQBy_25D.js} +1 -1
- package/dist/assets/{layout-DvXJxBiL.js → layout-DSsztKhq.js} +5 -5
- package/dist/assets/{logs-panel-KtsY7TrR.js → logs-panel-DZ8zJWNT.js} +1 -1
- package/dist/assets/{markdown-renderer-DUgV7_fm.js → markdown-renderer-DszNRkaL.js} +1 -1
- package/dist/assets/{name-cell-input-C3-Cj-Ek.js → name-cell-input-BIpvW2kg.js} +1 -1
- package/dist/assets/numbers-BB-lSqeY.js +1 -0
- package/dist/assets/{outline-panel-BzyY4JA6.js → outline-panel-CHwFhhFo.js} +1 -1
- package/dist/assets/{packages-panel-DxosbWko.js → packages-panel-qT6TuHGP.js} +1 -1
- package/dist/assets/{panel-accordion-state-BRbTib2B.js → panel-accordion-state-DROYE5RR.js} +1 -1
- package/dist/assets/panels-3HImHlAU.js +1 -0
- package/dist/assets/{process-output-CSwx7rvo.js → process-output-CPh21qjo.js} +1 -1
- package/dist/assets/{readonly-code-display-B9y9423Y.js → readonly-code-display-DKoAsBb-.js} +1 -1
- package/dist/assets/{readonly-python-code-Dgw6trlk.js → readonly-python-code-QqiDzhYb.js} +1 -1
- package/dist/assets/{reveal-component-B9A4wkG-.js → reveal-component-Dd29QoYx.js} +2 -2
- package/dist/assets/{run-page-C1MQ5b_A.js → run-page-J_1gGmPH.js} +1 -1
- package/dist/assets/{runtime-details-state-D_hOQL9T.js → runtime-details-state-BlarRoM1.js} +1 -1
- package/dist/assets/{scratchpad-panel-CBCsPmMW.js → scratchpad-panel-BPw7VxO6.js} +1 -1
- package/dist/assets/{secrets-panel-ConQpchl.js → secrets-panel-j7vcP2r2.js} +1 -1
- package/dist/assets/session-panel-BnszHmkW.js +1 -0
- package/dist/assets/{snippets-panel-C0VDE_4i.js → snippets-panel-a-A15D0n.js} +1 -1
- package/dist/assets/{state-DvU2AiFx.js → state-2U7LSUNv.js} +4 -4
- package/dist/assets/{state-DrraMmqz.js → state-B_SxQGvw.js} +1 -1
- package/dist/assets/{switch-D2gdC_ep.js → switch-DLzvDOLo.js} +1 -1
- package/dist/assets/{tracing-C5d51Nmi.js → tracing-CpbvZwxP.js} +1 -1
- package/dist/assets/{tracing-panel-B89R8dWE.js → tracing-panel-Dxtm4-GJ.js} +2 -2
- package/dist/assets/{tree-actions-Cph8FVzh.js → tree-actions-CIBdpNC-.js} +1 -1
- package/dist/assets/{useAddCell-VPkB72pn.js → useAddCell-B6my967m.js} +1 -1
- package/dist/assets/{useCellActionButton--zI3GFnt.js → useCellActionButton-BwBEO8zi.js} +1 -1
- package/dist/assets/{useDeleteCell-CjewKeSr.js → useDeleteCell-DYRsSrAa.js} +1 -1
- package/dist/assets/{useDependencyPanelTab-Bt_ka-wl.js → useDependencyPanelTab-lNbBYJZs.js} +1 -1
- package/dist/assets/{useInstallPackage-BfNKN33w.js → useInstallPackage-Q9agSKO7.js} +1 -1
- package/dist/assets/useNotebookActions-CmG2irDr.js +1 -0
- package/dist/assets/{useRunCells-BupCZpzk.js → useRunCells-Bl702L84.js} +1 -1
- package/dist/assets/{useSplitCell-CaLIR0TS.js → useSplitCell-DQRIXpFK.js} +1 -1
- package/dist/assets/{write-secret-modal-CBi2vNK_.js → write-secret-modal-BujVAO67.js} +1 -1
- package/dist/index.html +25 -25
- package/package.json +1 -1
- package/src/components/datasources/__tests__/column-preview.test.tsx +35 -3
- package/src/components/datasources/__tests__/datasources-interactions.test.tsx +181 -0
- package/src/components/datasources/__tests__/utils.test.ts +57 -6
- package/src/components/datasources/column-preview.tsx +5 -2
- package/src/components/datasources/datasources.tsx +3 -4
- package/src/components/datasources/utils.ts +32 -23
- package/src/components/ui/__tests__/range-slider.test.tsx +165 -0
- package/src/components/ui/range-slider.tsx +22 -9
- package/src/plugins/impl/RangeSliderPlugin.tsx +17 -2
- package/src/plugins/impl/__tests__/RangeSliderPlugin.test.tsx +109 -0
- package/src/utils/__tests__/numbers.test.ts +57 -0
- package/src/utils/numbers.ts +59 -9
- package/dist/assets/ai-model-dropdown-D575Vid8.js +0 -13
- package/dist/assets/cell-editor-BLpOlLnM.js +0 -42
- package/dist/assets/feedback-button-C-eKtxXE.js +0 -1
- package/dist/assets/index-CoxbqhGH.js +0 -30
- package/dist/assets/numbers-DJK15_4S.js +0 -1
- package/dist/assets/panels-Da3071Q4.js +0 -1
- package/dist/assets/session-panel-CiHCKPlx.js +0 -1
- package/dist/assets/useNotebookActions-DV2S6KaG.js +0 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { describe, expect, it, vi } from "vitest";
|
|
3
3
|
import {
|
|
4
4
|
countFractionDigits,
|
|
5
|
+
fractionDigitsForSlider,
|
|
5
6
|
maxFractionDigitsForSteps,
|
|
6
7
|
prettyEngineeringNumber,
|
|
7
8
|
prettyNumber,
|
|
@@ -104,6 +105,42 @@ describe("prettyScientificNumber", () => {
|
|
|
104
105
|
"1.23456789101112",
|
|
105
106
|
);
|
|
106
107
|
});
|
|
108
|
+
|
|
109
|
+
it("supports caller-provided display precision", () => {
|
|
110
|
+
expect(
|
|
111
|
+
prettyScientificNumber(1.2340000000000002, {
|
|
112
|
+
maximumFractionDigits: 2,
|
|
113
|
+
locale,
|
|
114
|
+
}),
|
|
115
|
+
).toBe("1.23");
|
|
116
|
+
expect(
|
|
117
|
+
prettyScientificNumber(1.2340000000000002, {
|
|
118
|
+
maximumFractionDigits: 3,
|
|
119
|
+
locale,
|
|
120
|
+
}),
|
|
121
|
+
).toBe("1.234");
|
|
122
|
+
expect(
|
|
123
|
+
prettyScientificNumber(1.234, {
|
|
124
|
+
maximumFractionDigits: 3,
|
|
125
|
+
locale,
|
|
126
|
+
}),
|
|
127
|
+
).toBe("1.234");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("preserves caller-provided precision in scientific notation", () => {
|
|
131
|
+
expect(
|
|
132
|
+
prettyScientificNumber(0.0012300000000000002, {
|
|
133
|
+
maximumFractionDigits: 5,
|
|
134
|
+
locale,
|
|
135
|
+
}),
|
|
136
|
+
).toBe("1.23e-3");
|
|
137
|
+
expect(
|
|
138
|
+
prettyScientificNumber(1_000_001.2300000001, {
|
|
139
|
+
maximumFractionDigits: 2,
|
|
140
|
+
locale,
|
|
141
|
+
}),
|
|
142
|
+
).toBe("1.00000123e6");
|
|
143
|
+
});
|
|
107
144
|
});
|
|
108
145
|
|
|
109
146
|
describe("prettyEngineeringNumber", () => {
|
|
@@ -153,3 +190,23 @@ describe("maxFractionDigitsForSteps", () => {
|
|
|
153
190
|
expect(maxFractionDigitsForSteps([1, 2, 3, 4], 1)).toBe(0);
|
|
154
191
|
});
|
|
155
192
|
});
|
|
193
|
+
|
|
194
|
+
describe("fractionDigitsForSlider", () => {
|
|
195
|
+
it("preserves precision for regular slider steps", () => {
|
|
196
|
+
expect(fractionDigitsForSlider(0.001)).toBe(3);
|
|
197
|
+
expect(fractionDigitsForSlider(0.01)).toBe(2);
|
|
198
|
+
expect(fractionDigitsForSlider(undefined)).toBe(2);
|
|
199
|
+
expect(fractionDigitsForSlider(undefined, null, 0, [0.1234, 0.5])).toBe(4);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("infers precision from custom step values", () => {
|
|
203
|
+
expect(fractionDigitsForSlider(undefined, [1, 1.234, 2])).toBe(3);
|
|
204
|
+
expect(
|
|
205
|
+
fractionDigitsForSlider(undefined, [0.1, 0.2, 0.30000000000000004]),
|
|
206
|
+
).toBe(1);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("includes the slider origin in regular step precision", () => {
|
|
210
|
+
expect(fractionDigitsForSlider(1, null, 0.5)).toBe(1);
|
|
211
|
+
});
|
|
212
|
+
});
|
package/src/utils/numbers.ts
CHANGED
|
@@ -24,19 +24,19 @@ export const maxFractionalDigits = memoizeLastValue((locale: string) => {
|
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
const getScientificFormatter = memoizeLastValue(
|
|
27
|
-
(locale: string) =>
|
|
27
|
+
(locale: string, maximumFractionDigits = 1) =>
|
|
28
28
|
new Intl.NumberFormat(locale, {
|
|
29
29
|
minimumFractionDigits: 1,
|
|
30
|
-
maximumFractionDigits
|
|
30
|
+
maximumFractionDigits,
|
|
31
31
|
notation: "scientific",
|
|
32
32
|
}),
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
const getRoundedFormatter = memoizeLastValue(
|
|
36
|
-
(locale: string) =>
|
|
36
|
+
(locale: string, maximumFractionDigits = 2) =>
|
|
37
37
|
new Intl.NumberFormat(locale, {
|
|
38
38
|
minimumFractionDigits: 0,
|
|
39
|
-
maximumFractionDigits
|
|
39
|
+
maximumFractionDigits,
|
|
40
40
|
}),
|
|
41
41
|
);
|
|
42
42
|
|
|
@@ -60,7 +60,7 @@ export function countFractionDigits(n: number): number {
|
|
|
60
60
|
|
|
61
61
|
/** Max fraction digits to display a set of step values cleanly. */
|
|
62
62
|
export function maxFractionDigitsForSteps(
|
|
63
|
-
steps: number[],
|
|
63
|
+
steps: readonly number[],
|
|
64
64
|
minGap: number,
|
|
65
65
|
): number {
|
|
66
66
|
let max = countFractionDigits(minGap);
|
|
@@ -70,6 +70,41 @@ export function maxFractionDigitsForSteps(
|
|
|
70
70
|
return max;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** Infer display precision from a slider's regular or custom steps. */
|
|
74
|
+
export function fractionDigitsForSlider(
|
|
75
|
+
step?: number,
|
|
76
|
+
steps?: readonly number[] | null,
|
|
77
|
+
origin?: number,
|
|
78
|
+
values?: readonly number[],
|
|
79
|
+
): number {
|
|
80
|
+
const originDigits = origin == null ? 0 : countFractionDigits(origin);
|
|
81
|
+
|
|
82
|
+
if (steps && steps.length > 0) {
|
|
83
|
+
let minGap = Number.POSITIVE_INFINITY;
|
|
84
|
+
for (let i = 1; i < steps.length; i++) {
|
|
85
|
+
const gap = Math.abs(steps[i] - steps[i - 1]);
|
|
86
|
+
if (gap > 0 && gap < minGap) {
|
|
87
|
+
minGap = gap;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return Math.max(
|
|
92
|
+
originDigits,
|
|
93
|
+
maxFractionDigitsForSteps(steps, Number.isFinite(minGap) ? minGap : 0),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (step == null || !Number.isFinite(step) || step <= 0) {
|
|
98
|
+
return Math.max(
|
|
99
|
+
2,
|
|
100
|
+
originDigits,
|
|
101
|
+
...(values ?? []).map(countFractionDigits),
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return Math.max(originDigits, countFractionDigits(step));
|
|
106
|
+
}
|
|
107
|
+
|
|
73
108
|
/** Round away float noise so step-based inputs stay on a clean decimal grid. */
|
|
74
109
|
export function roundToFractionDigits(n: number, digits: number): number {
|
|
75
110
|
return Number(n.toFixed(digits));
|
|
@@ -121,6 +156,7 @@ export function prettyScientificNumber(
|
|
|
121
156
|
value: number,
|
|
122
157
|
opts: {
|
|
123
158
|
shouldRound?: boolean; // Default to false
|
|
159
|
+
maximumFractionDigits?: number;
|
|
124
160
|
locale: string;
|
|
125
161
|
},
|
|
126
162
|
): string {
|
|
@@ -133,14 +169,28 @@ export function prettyScientificNumber(
|
|
|
133
169
|
// Determine if the number should be in scientific notation
|
|
134
170
|
const absValue = Math.abs(value);
|
|
135
171
|
if (absValue < 1e-2 || absValue >= 1e6) {
|
|
136
|
-
|
|
172
|
+
// Scientific notation counts digits after the decimal in the mantissa.
|
|
173
|
+
const digits =
|
|
174
|
+
opts.maximumFractionDigits === undefined
|
|
175
|
+
? 1
|
|
176
|
+
: Math.max(
|
|
177
|
+
1,
|
|
178
|
+
Math.min(
|
|
179
|
+
maxFractionalDigits(opts.locale),
|
|
180
|
+
opts.maximumFractionDigits + Math.floor(Math.log10(absValue)),
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
return getScientificFormatter(opts.locale, digits)
|
|
184
|
+
.format(value)
|
|
185
|
+
.toLowerCase();
|
|
137
186
|
}
|
|
138
187
|
|
|
139
188
|
const { shouldRound, locale } = opts;
|
|
140
189
|
|
|
141
|
-
if (shouldRound) {
|
|
142
|
-
|
|
143
|
-
|
|
190
|
+
if (shouldRound || opts.maximumFractionDigits !== undefined) {
|
|
191
|
+
return getRoundedFormatter(locale, opts.maximumFractionDigits ?? 2).format(
|
|
192
|
+
value,
|
|
193
|
+
);
|
|
144
194
|
}
|
|
145
195
|
|
|
146
196
|
// Don't round
|