@marimo-team/islands 0.24.1-dev79 → 0.24.1-dev80
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/{chat-ui-DM12Y9is.js → chat-ui-Dcb8pQhM.js} +8 -8
- package/dist/click-outside-container-D_URcm3D.js +167 -0
- package/dist/{common-DuuFqqGa.js → common-C8LWIius.js} +571 -571
- package/dist/{data-grid-overlay-editor-D-p0q7YM.js → data-grid-overlay-editor-DZM4BAaI.js} +49 -48
- package/dist/{click-outside-container-CVJZE0x6.js → data-grid-types-BnZwWG8z.js} +150 -312
- package/dist/{dropdown-menu-C8N-kZzD.js → dropdown-menu-B39I9ARA.js} +20 -31
- package/dist/{glide-data-editor-64-L_DON.js → glide-data-editor-DEJqXbly.js} +2598 -2780
- package/dist/glide-utils-C0dRuWI_.js +201 -0
- package/dist/{html-to-image-B7RQgQQy.js → html-to-image-CvCnIqTI.js} +4476 -4465
- package/dist/main.js +5971 -5913
- package/dist/{process-output-BCqcNNll.js → process-output-C2joqP7d.js} +1 -1
- package/dist/{reveal-component-BDQwrD89.js → reveal-component-CdEcs6WV.js} +3 -3
- package/package.json +1 -1
- package/src/plugins/impl/DataEditorPlugin.tsx +38 -70
- package/src/plugins/impl/__tests__/DataEditorPlugin.test.ts +152 -1
- package/src/plugins/impl/data-editor/__tests__/data-utils.test.ts +73 -78
- package/src/plugins/impl/data-editor/__tests__/editor-state.test.ts +113 -0
- package/src/plugins/impl/data-editor/__tests__/glide-data-editor.test.tsx +49 -13
- package/src/plugins/impl/data-editor/__tests__/glide-utils.test.ts +44 -64
- package/src/plugins/impl/data-editor/data-utils.ts +76 -53
- package/src/plugins/impl/data-editor/editor-state.ts +108 -0
- package/src/plugins/impl/data-editor/glide-data-editor.tsx +40 -223
- package/src/plugins/impl/data-editor/glide-utils.ts +71 -31
- package/src/plugins/impl/data-editor/types.ts +30 -16
- package/dist/types-eyYyHvz7.js +0 -72
|
@@ -10,10 +10,11 @@ import { logNever } from "@/utils/assertNever";
|
|
|
10
10
|
import { Logger } from "@/utils/Logger";
|
|
11
11
|
import type {
|
|
12
12
|
ColumnEdit,
|
|
13
|
+
EditorRow,
|
|
13
14
|
Edits,
|
|
14
15
|
ModifiedGridColumn,
|
|
15
16
|
PositionalEdit,
|
|
16
|
-
|
|
17
|
+
RemoveRowEdit,
|
|
17
18
|
} from "./types";
|
|
18
19
|
|
|
19
20
|
export function getColumnKind(fieldType: DataType): GridCellKind {
|
|
@@ -24,7 +25,15 @@ export function getColumnKind(fieldType: DataType): GridCellKind {
|
|
|
24
25
|
return GridCellKind.Number;
|
|
25
26
|
case "boolean":
|
|
26
27
|
return GridCellKind.Boolean;
|
|
28
|
+
case "integer":
|
|
29
|
+
case "date":
|
|
30
|
+
case "datetime":
|
|
31
|
+
case "time":
|
|
32
|
+
case "geometry":
|
|
33
|
+
case "unknown":
|
|
34
|
+
return GridCellKind.Text;
|
|
27
35
|
default:
|
|
36
|
+
logNever(fieldType);
|
|
28
37
|
return GridCellKind.Text;
|
|
29
38
|
}
|
|
30
39
|
}
|
|
@@ -52,13 +61,48 @@ export function getColumnHeaderIcon(fieldType: DataType): GridColumnIcon {
|
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
|
|
64
|
+
export function isValidCellValue(
|
|
65
|
+
dataType: DataType | undefined,
|
|
66
|
+
value: unknown,
|
|
67
|
+
): boolean {
|
|
68
|
+
switch (dataType) {
|
|
69
|
+
case "number":
|
|
70
|
+
return Number.isFinite(Number(value));
|
|
71
|
+
case "integer":
|
|
72
|
+
if (typeof value === "bigint") {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === "number") {
|
|
76
|
+
return Number.isFinite(value) && Number.isInteger(value);
|
|
77
|
+
}
|
|
78
|
+
if (typeof value === "string") {
|
|
79
|
+
const normalized = value.trim();
|
|
80
|
+
return /^[+-]?[0-9]+(?:\.0+)?$/u.test(normalized);
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
case "boolean":
|
|
84
|
+
return typeof value === "boolean";
|
|
85
|
+
case undefined:
|
|
86
|
+
case "string":
|
|
87
|
+
case "date":
|
|
88
|
+
case "datetime":
|
|
89
|
+
case "time":
|
|
90
|
+
case "geometry":
|
|
91
|
+
case "unknown":
|
|
92
|
+
return true;
|
|
93
|
+
default:
|
|
94
|
+
logNever(dataType);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
55
99
|
export function isPositionalEdit(
|
|
56
100
|
edit: Edits["edits"][number],
|
|
57
101
|
): edit is PositionalEdit {
|
|
58
102
|
return "rowIdx" in edit && "columnId" in edit && "value" in edit;
|
|
59
103
|
}
|
|
60
104
|
|
|
61
|
-
export function isRowEdit(edit: Edits["edits"][number]): edit is
|
|
105
|
+
export function isRowEdit(edit: Edits["edits"][number]): edit is RemoveRowEdit {
|
|
62
106
|
return "rowIdx" in edit && "type" in edit;
|
|
63
107
|
}
|
|
64
108
|
|
|
@@ -66,16 +110,14 @@ export function isColumnEdit(edit: Edits["edits"][number]): edit is ColumnEdit {
|
|
|
66
110
|
return "columnIdx" in edit && "type" in edit;
|
|
67
111
|
}
|
|
68
112
|
|
|
69
|
-
export function pasteCells
|
|
113
|
+
export function pasteCells(options: {
|
|
70
114
|
selection: GridSelection;
|
|
71
|
-
data:
|
|
72
|
-
setData: (updater: (prev: T[]) => T[]) => void;
|
|
115
|
+
data: EditorRow[];
|
|
73
116
|
columns: ModifiedGridColumn[];
|
|
74
117
|
editableColumns: string[] | "all";
|
|
75
118
|
onAddEdits: (edits: Edits["edits"]) => void;
|
|
76
119
|
}) {
|
|
77
|
-
const { selection, data,
|
|
78
|
-
options;
|
|
120
|
+
const { selection, data, onAddEdits, columns, editableColumns } = options;
|
|
79
121
|
if (!selection.current) {
|
|
80
122
|
return;
|
|
81
123
|
}
|
|
@@ -126,7 +168,7 @@ export function pasteCells<T>(options: {
|
|
|
126
168
|
const targetColIdx = startCol + colIndex;
|
|
127
169
|
|
|
128
170
|
// Check if we've exceeded the column bounds
|
|
129
|
-
if (
|
|
171
|
+
if (targetColIdx >= columns.length) {
|
|
130
172
|
break;
|
|
131
173
|
}
|
|
132
174
|
|
|
@@ -143,10 +185,19 @@ export function pasteCells<T>(options: {
|
|
|
143
185
|
let convertedValue: unknown = cellValue;
|
|
144
186
|
|
|
145
187
|
switch (columnType) {
|
|
146
|
-
case "integer":
|
|
188
|
+
case "integer": {
|
|
189
|
+
const numValue = Number(cellValue);
|
|
190
|
+
if (!isValidCellValue(columnType, cellValue)) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
convertedValue = Number.isSafeInteger(numValue)
|
|
194
|
+
? numValue
|
|
195
|
+
: cellValue.trim();
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
147
198
|
case "number": {
|
|
148
199
|
const numValue = Number(cellValue);
|
|
149
|
-
if (
|
|
200
|
+
if (!isValidCellValue(columnType, numValue)) {
|
|
150
201
|
continue;
|
|
151
202
|
}
|
|
152
203
|
convertedValue = numValue;
|
|
@@ -157,6 +208,16 @@ export function pasteCells<T>(options: {
|
|
|
157
208
|
convertedValue = boolValue === "true" || boolValue === "1";
|
|
158
209
|
break;
|
|
159
210
|
}
|
|
211
|
+
case "string":
|
|
212
|
+
case "date":
|
|
213
|
+
case "datetime":
|
|
214
|
+
case "time":
|
|
215
|
+
case "geometry":
|
|
216
|
+
case "unknown":
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
logNever(columnType);
|
|
220
|
+
continue;
|
|
160
221
|
}
|
|
161
222
|
|
|
162
223
|
// Get the column ID from the columns array using the title
|
|
@@ -172,27 +233,6 @@ export function pasteCells<T>(options: {
|
|
|
172
233
|
|
|
173
234
|
if (edits.length > 0) {
|
|
174
235
|
onAddEdits(edits);
|
|
175
|
-
|
|
176
|
-
setData((prev: T[]) => {
|
|
177
|
-
const newData = [...prev];
|
|
178
|
-
|
|
179
|
-
// Apply all edits to the data
|
|
180
|
-
for (const edit of edits) {
|
|
181
|
-
if (isPositionalEdit(edit)) {
|
|
182
|
-
const rowIdx = edit.rowIdx;
|
|
183
|
-
const columnId = edit.columnId;
|
|
184
|
-
|
|
185
|
-
if (rowIdx < newData.length) {
|
|
186
|
-
const row = newData[rowIdx] as Record<string, unknown>;
|
|
187
|
-
if (columnId in row) {
|
|
188
|
-
row[columnId] = edit.value;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return newData;
|
|
195
|
-
});
|
|
196
236
|
}
|
|
197
237
|
})
|
|
198
238
|
.catch((error) => {
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import type { GridCellKind, GridColumn } from "@glideapps/glide-data-grid";
|
|
4
|
-
import type {
|
|
4
|
+
import type { FieldTypes } from "@/components/data-table/types";
|
|
5
5
|
import type { DataType } from "@/core/kernel/messages";
|
|
6
6
|
|
|
7
|
+
export type EditorRow = Record<string, unknown>;
|
|
8
|
+
|
|
9
|
+
export interface EditorState {
|
|
10
|
+
data: EditorRow[];
|
|
11
|
+
columnFields: FieldTypes;
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
export interface PositionalEdit {
|
|
8
15
|
rowIdx: number;
|
|
9
16
|
columnId: string;
|
|
@@ -16,31 +23,38 @@ export const BulkEdit = {
|
|
|
16
23
|
Rename: "rename",
|
|
17
24
|
} as const;
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export interface RowEdit {
|
|
26
|
+
export interface RemoveRowEdit {
|
|
22
27
|
rowIdx: number;
|
|
23
|
-
type: BulkEdit;
|
|
28
|
+
type: typeof BulkEdit.Remove;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RemoveColumnEdit {
|
|
32
|
+
columnIdx: number;
|
|
33
|
+
type: typeof BulkEdit.Remove;
|
|
24
34
|
}
|
|
25
35
|
|
|
26
|
-
export interface
|
|
36
|
+
export interface RenameColumnEdit {
|
|
27
37
|
columnIdx: number;
|
|
28
|
-
newName
|
|
29
|
-
type: BulkEdit;
|
|
38
|
+
newName: string;
|
|
39
|
+
type: typeof BulkEdit.Rename;
|
|
30
40
|
}
|
|
31
41
|
|
|
42
|
+
export interface InsertColumnEdit {
|
|
43
|
+
columnIdx: number;
|
|
44
|
+
newName: string;
|
|
45
|
+
type: typeof BulkEdit.Insert;
|
|
46
|
+
dataType?: DataType;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ColumnEdit = RemoveColumnEdit | RenameColumnEdit | InsertColumnEdit;
|
|
50
|
+
|
|
51
|
+
export type Edit = PositionalEdit | RemoveRowEdit | ColumnEdit;
|
|
52
|
+
|
|
32
53
|
export interface Edits {
|
|
33
|
-
edits:
|
|
54
|
+
edits: Edit[];
|
|
34
55
|
}
|
|
35
56
|
|
|
36
57
|
export type ModifiedGridColumn = GridColumn & {
|
|
37
58
|
kind: GridCellKind;
|
|
38
59
|
dataType: DataType;
|
|
39
60
|
};
|
|
40
|
-
|
|
41
|
-
export interface DataEditorProps<T> {
|
|
42
|
-
data: T[];
|
|
43
|
-
fieldTypes: FieldTypesWithExternalType | null | undefined;
|
|
44
|
-
onAddEdits: (edits: Edits["edits"]) => void;
|
|
45
|
-
onAddRows: (newRows: object[]) => void;
|
|
46
|
-
}
|
package/dist/types-eyYyHvz7.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./rolldown-runtime-Cb76FRpK.js";
|
|
2
|
-
import { u as t } from "./dist-wdOJ5T7-.js";
|
|
3
|
-
var n = t("pencil", [["path", {
|
|
4
|
-
d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
|
|
5
|
-
key: "1a8usu"
|
|
6
|
-
}], ["path", {
|
|
7
|
-
d: "m15 5 4 4",
|
|
8
|
-
key: "1mk7zo"
|
|
9
|
-
}]]), r = t("trash", [
|
|
10
|
-
["path", {
|
|
11
|
-
d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",
|
|
12
|
-
key: "miytrc"
|
|
13
|
-
}],
|
|
14
|
-
["path", {
|
|
15
|
-
d: "M3 6h18",
|
|
16
|
-
key: "d0wm0j"
|
|
17
|
-
}],
|
|
18
|
-
["path", {
|
|
19
|
-
d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",
|
|
20
|
-
key: "e791ji"
|
|
21
|
-
}]
|
|
22
|
-
]), i = /* @__PURE__ */ e(((e, t) => {
|
|
23
|
-
t.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
24
|
-
})), a = /* @__PURE__ */ e(((e, t) => {
|
|
25
|
-
var n = i();
|
|
26
|
-
function r() {}
|
|
27
|
-
function a() {}
|
|
28
|
-
a.resetWarningCache = r, t.exports = function() {
|
|
29
|
-
function e(e, t, r, i, a, o) {
|
|
30
|
-
if (o !== n) {
|
|
31
|
-
var s = /* @__PURE__ */ Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
|
|
32
|
-
throw s.name = "Invariant Violation", s;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
e.isRequired = e;
|
|
36
|
-
function t() {
|
|
37
|
-
return e;
|
|
38
|
-
}
|
|
39
|
-
var i = {
|
|
40
|
-
array: e,
|
|
41
|
-
bigint: e,
|
|
42
|
-
bool: e,
|
|
43
|
-
func: e,
|
|
44
|
-
number: e,
|
|
45
|
-
object: e,
|
|
46
|
-
string: e,
|
|
47
|
-
symbol: e,
|
|
48
|
-
any: e,
|
|
49
|
-
arrayOf: t,
|
|
50
|
-
element: e,
|
|
51
|
-
elementType: e,
|
|
52
|
-
instanceOf: t,
|
|
53
|
-
node: e,
|
|
54
|
-
objectOf: t,
|
|
55
|
-
oneOf: t,
|
|
56
|
-
oneOfType: t,
|
|
57
|
-
shape: t,
|
|
58
|
-
exact: t,
|
|
59
|
-
checkPropTypes: a,
|
|
60
|
-
resetWarningCache: r
|
|
61
|
-
};
|
|
62
|
-
return i.PropTypes = i, i;
|
|
63
|
-
};
|
|
64
|
-
})), o = /* @__PURE__ */ e(((e, t) => {
|
|
65
|
-
t.exports = a()();
|
|
66
|
-
})), s = {
|
|
67
|
-
Insert: "insert",
|
|
68
|
-
Remove: "remove",
|
|
69
|
-
Rename: "rename"
|
|
70
|
-
};
|
|
71
|
-
//#endregion
|
|
72
|
-
export { n as i, o as n, r, s as t };
|