@marimo-team/frontend 0.18.5-dev168 → 0.18.5-dev169
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-C5QfWAQj.js → CellStatus-DlwC0A_k.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-B0tKPs5t.js → ConnectedDataExplorerComponent-C3aK452q.js} +1 -1
- package/dist/assets/{JsonOutput-NOfbbuUx.js → JsonOutput-C7Jn2Hoy.js} +9 -9
- package/dist/assets/{MarimoErrorOutput-usFICLUe.js → MarimoErrorOutput-Dtk0CQJu.js} +2 -2
- package/dist/assets/{RenderHTML-LxV1eecf.js → RenderHTML-DfrA7ZTv.js} +1 -1
- package/dist/assets/{add-cell-with-ai-CEKGThxQ.js → add-cell-with-ai-BYCrNUOQ.js} +12 -12
- package/dist/assets/{add-database-form-DQyrphh9.js → add-database-form-D-BVTDCT.js} +1 -1
- package/dist/assets/{agent-panel-CnTn12AW.js → agent-panel-CNIKszsQ.js} +6 -6
- package/dist/assets/{ai-model-dropdown-CxRols0L.js → ai-model-dropdown-CAhqhkRJ.js} +1 -1
- package/dist/assets/{app-config-button-DtMP2_j5.js → app-config-button-BhKhGiaG.js} +1 -1
- package/dist/assets/{cell-actions-DCZqhhwF.js → cell-actions-C8VD1BFf.js} +1 -1
- package/dist/assets/{cell-editor-DJ1tY3mU.js → cell-editor-bDu_ShRz.js} +7 -7
- package/dist/assets/cell-link-NwzNlJhp.js +1 -0
- package/dist/assets/{cells-DAR6V-0d.js → cells-xPjoZY0S.js} +46 -46
- package/dist/assets/{chat-components-CyY2c7cG.js → chat-components-CQFXyizy.js} +1 -1
- package/dist/assets/{chat-display-BgCCmGdz.js → chat-display-DqUXDG-o.js} +1 -1
- package/dist/assets/{chat-panel-ByuXM3gc.js → chat-panel-8iT2Wjh6.js} +2 -2
- package/dist/assets/client-Cbyg6uhC.js +4 -0
- package/dist/assets/{column-preview-DBqi4KCj.js → column-preview-BuNifqxS.js} +1 -1
- package/dist/assets/{command-BXWdrTY9.js → command-DIcQwElH.js} +1 -1
- package/dist/assets/command-palette-D_boTGwg.js +1 -0
- package/dist/assets/{common-D10A9aix.js → common-C6NCeVE8.js} +1 -1
- package/dist/assets/{config-D3ojpe3F.js → config-DWMmQmTt.js} +1 -1
- package/dist/assets/{datasource-CW2RMV2e.js → datasource-CyWtxjKq.js} +2 -2
- package/dist/assets/{dependency-graph-panel-CtlDdK0s.js → dependency-graph-panel-C01bMyQK.js} +3 -3
- package/dist/assets/{documentation-panel-Cup0ghBs.js → documentation-panel-BPUF-dp2.js} +1 -1
- package/dist/assets/{download-D3Uujsn_.js → download-B9UlWvRO.js} +1 -1
- package/dist/assets/edit-page-DFkV0LWx.js +13 -0
- package/dist/assets/{error-panel-DcRvXIwA.js → error-panel-ClGt4y8j.js} +1 -1
- package/dist/assets/{es-DCqUUmrq.js → es-1yDP0Xdp.js} +1 -1
- package/dist/assets/{file-explorer-panel-9Bt20tRi.js → file-explorer-panel-3SHWDl17.js} +1 -1
- package/dist/assets/{floating-outline-BTc4L5BF.js → floating-outline-C5wKHGsD.js} +1 -1
- package/dist/assets/{focus-6-St0ai2.js → focus-DPgrnlZ1.js} +1 -1
- package/dist/assets/{form-1WOcPtE8.js → form-B2Db87Zc.js} +2 -2
- package/dist/assets/{glide-data-editor-EdMWe-iv.js → glide-data-editor-CwVQm3Mn.js} +1 -1
- package/dist/assets/{globals-CJb4gcmW.js → globals-CC2GcyGk.js} +1 -1
- package/dist/assets/{home-page-Lqy9A89-.js → home-page-BdK-6xZH.js} +2 -2
- package/dist/assets/{index-CIoUDThG.js → index-CEHA_rtG.js} +9 -9
- package/dist/assets/index-G6ss-VDT.css +2 -0
- package/dist/assets/{kiosk-mode-C3lS9kUL.js → kiosk-mode-CsuyIDk3.js} +1 -1
- package/dist/assets/{layout-F63rlsGg.js → layout-DlHn_emH.js} +3 -3
- package/dist/assets/links-DR-r1Edb.js +1 -0
- package/dist/assets/{logs-panel-fnMYUf4-.js → logs-panel-BIW4BIAP.js} +1 -1
- package/dist/assets/{markdown-renderer-B9gYLzJX.js → markdown-renderer-B0tsGAgw.js} +1 -1
- package/dist/assets/{mermaid-BUMgiGGr.js → mermaid-BcA-uOhi.js} +1 -1
- package/dist/assets/{mode-D4GlAyEq.js → mode-Ii-fBazZ.js} +1 -1
- package/dist/assets/{name-cell-input-BMtblyo6.js → name-cell-input-03mNaWsC.js} +1 -1
- package/dist/assets/outline-panel-D2OKWKZx.js +1 -0
- package/dist/assets/{packages-panel-DyC7zUxG.js → packages-panel-CzdZ8dRE.js} +1 -1
- package/dist/assets/{panels-wYHy1fpG.js → panels-DTuGqWrW.js} +1 -1
- package/dist/assets/{process-output-D1GR6Ero.js → process-output-Dsqg6AQn.js} +1 -1
- package/dist/assets/{readonly-python-code-CGnOB_RP.js → readonly-python-code-CEN7uCAn.js} +1 -1
- package/dist/assets/{renderShortcut-CV_tqoEI.js → renderShortcut-DolwKyOI.js} +1 -1
- package/dist/assets/{run-page-BLnJcKtg.js → run-page-Bv4-nptx.js} +1 -1
- package/dist/assets/{scratchpad-panel-CTJDEy90.js → scratchpad-panel-CwWN2smX.js} +1 -1
- package/dist/assets/{session-panel-C3rDPyig.js → session-panel-C35Uxsn7.js} +1 -1
- package/dist/assets/{snippets-panel-s0p4CCoa.js → snippets-panel-VLyEWSgW.js} +1 -1
- package/dist/assets/{state-BK5o1KAL.js → state-CLVMeQ5K.js} +1 -1
- package/dist/assets/{state-DwSzcmzL.js → state-DfW1MJsR.js} +1 -1
- package/dist/assets/{switch-C8yab1pC.js → switch-DXLifdeN.js} +1 -1
- package/dist/assets/{terminal-CA6CqpuO.js → terminal-O_0qSqHX.js} +1 -1
- package/dist/assets/{textarea-DBFtOima.js → textarea-BibopRh1.js} +1 -1
- package/dist/assets/tracing-kd2E6r4-.js +1 -0
- package/dist/assets/{tracing-panel-C-o1Db4W.js → tracing-panel-CingJf_V.js} +2 -2
- package/dist/assets/{types-Bt3U-XJV.js → types-B_DyfI3j.js} +1 -1
- package/dist/assets/{useAddCell-CNI3pgez.js → useAddCell-CuNdAB3f.js} +1 -1
- package/dist/assets/{useBoolean-C_vQizET.js → useBoolean-DWRpatKF.js} +1 -1
- package/dist/assets/{useCellActionButton-BbfiHu5s.js → useCellActionButton-CLGSFvWy.js} +1 -1
- package/dist/assets/{useDeleteCell-B_jFiS1Y.js → useDeleteCell-DAgP4oYp.js} +1 -1
- package/dist/assets/{useNotebookActions-BeM5fet2.js → useNotebookActions-CLAi2J0h.js} +1 -1
- package/dist/assets/useRunCells-BHhExio0.js +1 -0
- package/dist/assets/{useSplitCell-COPg5dJw.js → useSplitCell-CF_E2d8x.js} +1 -1
- package/dist/assets/{useTheme-CuOCKnyR.js → useTheme-CrojuouA.js} +1 -1
- package/dist/assets/{utilities.esm-B7XtzwiJ.js → utilities.esm-lV-KjYEM.js} +2 -2
- package/dist/assets/{utils-Cxqw03y3.js → utils-B_xHF0y2.js} +1 -1
- package/dist/assets/{vega-component-arPQXQS8.js → vega-component-DTFVCfi1.js} +1 -1
- package/dist/index.html +37 -37
- package/package.json +1 -1
- package/src/components/editor/actions/useNotebookActions.tsx +1 -1
- package/src/components/editor/chrome/state.ts +30 -15
- package/src/components/editor/chrome/types.ts +67 -77
- package/src/components/editor/chrome/wrapper/app-chrome.tsx +148 -84
- package/src/components/editor/chrome/wrapper/sidebar.tsx +76 -43
- package/src/components/ui/reorderable-list.tsx +190 -31
- package/dist/assets/cell-link-DjST51KF.js +0 -1
- package/dist/assets/client-BQowSjqE.js +0 -4
- package/dist/assets/command-palette-CjFiCjws.js +0 -1
- package/dist/assets/edit-page-fJ4hHm67.js +0 -13
- package/dist/assets/index-D-BWugLn.css +0 -2
- package/dist/assets/links-ZVVAwqm7.js +0 -1
- package/dist/assets/outline-panel-Blq76m9b.js +0 -1
- package/dist/assets/tracing-VZVj-gEo.js +0 -1
- package/dist/assets/useRunCells-oeY0TrS1.js +0 -1
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
type DropItem,
|
|
7
|
+
ListBox,
|
|
8
|
+
ListBoxItem,
|
|
9
|
+
useDragAndDrop,
|
|
10
|
+
} from "react-aria-components";
|
|
6
11
|
import { Logger } from "@/utils/Logger";
|
|
7
12
|
import {
|
|
8
13
|
ContextMenu,
|
|
@@ -12,15 +17,37 @@ import {
|
|
|
12
17
|
} from "./context-menu";
|
|
13
18
|
import "./reorderable-list.css";
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
interface DragData<T> {
|
|
21
|
+
itemId: string;
|
|
22
|
+
sourceListId: string;
|
|
23
|
+
item: T;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getDragMimeType(dragType: string): string {
|
|
27
|
+
return `application/x-reorderable-${dragType}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function parseDragData<T>(text: string): DragData<T> | null {
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(text) as DragData<T>;
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ReorderableListProps<T> {
|
|
16
39
|
/**
|
|
17
|
-
* The current list of items
|
|
40
|
+
* The current list of items.
|
|
18
41
|
*/
|
|
19
42
|
value: T[];
|
|
20
43
|
/**
|
|
21
44
|
* Callback when items are reordered
|
|
22
45
|
*/
|
|
23
46
|
setValue: (items: T[]) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Function to get a unique key for each item. Used for drag-drop and rendering.
|
|
49
|
+
*/
|
|
50
|
+
getKey: (item: T) => string;
|
|
24
51
|
/**
|
|
25
52
|
* Render function for each item.
|
|
26
53
|
* Note: Avoid interactive elements (buttons) inside - they break drag behavior.
|
|
@@ -50,49 +77,148 @@ export interface ReorderableListProps<T extends { id: string | number }> {
|
|
|
50
77
|
* Additional class name for the list container
|
|
51
78
|
*/
|
|
52
79
|
className?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Configuration for cross-list drag-drop. When set, items can be dragged
|
|
82
|
+
* between lists that share the same `dragType`.
|
|
83
|
+
*/
|
|
84
|
+
crossListDrag?: {
|
|
85
|
+
/** Identifier that links lists together - same dragType = can share items */
|
|
86
|
+
dragType: string;
|
|
87
|
+
/** Unique identifier for this list */
|
|
88
|
+
listId: string;
|
|
89
|
+
/**
|
|
90
|
+
* Callback when an item is received from another list.
|
|
91
|
+
* At this point, setValue has been called with the new item included,
|
|
92
|
+
* but the parent component may not have re-rendered yet.
|
|
93
|
+
* Use this to remove the item from the source list and handle any side effects.
|
|
94
|
+
*/
|
|
95
|
+
onReceive: (item: T, fromListId: string, insertIndex: number) => void;
|
|
96
|
+
};
|
|
53
97
|
}
|
|
54
98
|
|
|
55
99
|
/**
|
|
56
|
-
* A generic reorderable list component using react-aria-components
|
|
57
|
-
* Items can be reordered via drag and drop.
|
|
100
|
+
* A generic reorderable list component using react-aria-components.
|
|
101
|
+
* Items can be reordered via drag and drop within the list.
|
|
102
|
+
*
|
|
103
|
+
* For cross-list drag-drop, set the same `dragType` on multiple lists
|
|
104
|
+
* and provide an `onReceive` callback to handle items dropped from other lists.
|
|
58
105
|
*
|
|
59
106
|
* @example
|
|
60
107
|
* ```tsx
|
|
61
|
-
*
|
|
62
|
-
* id: string;
|
|
63
|
-
* name: string;
|
|
64
|
-
* }
|
|
65
|
-
*
|
|
66
|
-
* const [items, setItems] = useState<MyItem[]>([...]);
|
|
67
|
-
*
|
|
108
|
+
* // Single list reordering
|
|
68
109
|
* <ReorderableList
|
|
69
110
|
* value={items}
|
|
70
111
|
* setValue={setItems}
|
|
112
|
+
* getKey={(item) => item.id}
|
|
71
113
|
* renderItem={(item) => <div>{item.name}</div>}
|
|
72
|
-
*
|
|
114
|
+
* />
|
|
115
|
+
*
|
|
116
|
+
* // Cross-list drag-drop
|
|
117
|
+
* <ReorderableList
|
|
118
|
+
* value={sidebarItems}
|
|
119
|
+
* setValue={setSidebarItems}
|
|
120
|
+
* getKey={(item) => item.type}
|
|
121
|
+
* renderItem={(item) => <div>{item.name}</div>}
|
|
122
|
+
* crossListDrag={{
|
|
123
|
+
* dragType: "panels",
|
|
124
|
+
* listId: "sidebar",
|
|
125
|
+
* onReceive: (item, fromListId) => {
|
|
126
|
+
* // Remove from source list
|
|
127
|
+
* setOtherItems(prev => prev.filter(i => i.type !== item.type));
|
|
128
|
+
* },
|
|
129
|
+
* }}
|
|
73
130
|
* />
|
|
74
131
|
* ```
|
|
75
132
|
*/
|
|
76
|
-
export const ReorderableList = <T extends
|
|
133
|
+
export const ReorderableList = <T extends object>({
|
|
77
134
|
value,
|
|
78
135
|
setValue,
|
|
136
|
+
getKey,
|
|
79
137
|
renderItem,
|
|
80
138
|
onAction,
|
|
81
139
|
availableItems,
|
|
82
|
-
getItemLabel
|
|
140
|
+
getItemLabel,
|
|
83
141
|
minItems = 1,
|
|
84
142
|
ariaLabel = "Reorderable list",
|
|
85
143
|
className,
|
|
144
|
+
crossListDrag,
|
|
86
145
|
}: ReorderableListProps<T>) => {
|
|
146
|
+
const mimeType = crossListDrag
|
|
147
|
+
? getDragMimeType(crossListDrag.dragType)
|
|
148
|
+
: null;
|
|
149
|
+
const onReceive = crossListDrag?.onReceive;
|
|
150
|
+
|
|
151
|
+
// Shared handler for cross-list drops
|
|
152
|
+
const handleCrossListDrop = async (
|
|
153
|
+
items: DropItem[],
|
|
154
|
+
insertIndex: number,
|
|
155
|
+
) => {
|
|
156
|
+
if (!mimeType || !crossListDrag?.listId || !onReceive) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
for (const dragItem of items) {
|
|
161
|
+
if (dragItem.kind !== "text" || !dragItem.types.has(mimeType)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const text = await dragItem.getText(mimeType);
|
|
166
|
+
const data = parseDragData<T>(text);
|
|
167
|
+
if (!data) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Only accept drops from different lists
|
|
172
|
+
if (data.sourceListId === crossListDrag.listId) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Skip if item already exists in this list
|
|
177
|
+
if (value.some((item) => getKey(item) === getKey(data.item))) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Add to this list and notify parent
|
|
182
|
+
setValue([
|
|
183
|
+
...value.slice(0, insertIndex),
|
|
184
|
+
data.item,
|
|
185
|
+
...value.slice(insertIndex),
|
|
186
|
+
]);
|
|
187
|
+
onReceive(data.item, data.sourceListId, insertIndex);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
87
191
|
const { dragAndDropHooks } = useDragAndDrop<T>({
|
|
88
|
-
getItems: (keys) =>
|
|
192
|
+
getItems: (keys) =>
|
|
193
|
+
[...keys].map((key) => {
|
|
194
|
+
const item = value.find((i) => getKey(i) === key);
|
|
195
|
+
const baseData: Record<string, string> = {
|
|
196
|
+
"text/plain": String(key),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Add cross-list drag data if dragType is set
|
|
200
|
+
if (mimeType && crossListDrag?.listId && item) {
|
|
201
|
+
const dragData: DragData<T> = {
|
|
202
|
+
itemId: String(key),
|
|
203
|
+
sourceListId: crossListDrag.listId,
|
|
204
|
+
item,
|
|
205
|
+
};
|
|
206
|
+
baseData[mimeType] = JSON.stringify(dragData);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return baseData;
|
|
210
|
+
}),
|
|
211
|
+
|
|
212
|
+
// Accept drops from lists with the same dragType
|
|
213
|
+
acceptedDragTypes: mimeType ? [mimeType, "text/plain"] : ["text/plain"],
|
|
214
|
+
|
|
89
215
|
onReorder(e) {
|
|
90
216
|
const keySet = new Set(e.keys);
|
|
91
|
-
const draggedItems = value.filter((item) => keySet.has(item
|
|
92
|
-
const remaining = value.filter((item) => !keySet.has(item
|
|
217
|
+
const draggedItems = value.filter((item) => keySet.has(getKey(item)));
|
|
218
|
+
const remaining = value.filter((item) => !keySet.has(getKey(item)));
|
|
93
219
|
|
|
94
220
|
const targetIndex = remaining.findIndex(
|
|
95
|
-
(item) => item
|
|
221
|
+
(item) => getKey(item) === e.target.key,
|
|
96
222
|
);
|
|
97
223
|
const insertIndex =
|
|
98
224
|
e.target.dropPosition === "before" ? targetIndex : targetIndex + 1;
|
|
@@ -103,19 +229,34 @@ export const ReorderableList = <T extends { id: string | number }>({
|
|
|
103
229
|
...remaining.slice(insertIndex),
|
|
104
230
|
]);
|
|
105
231
|
},
|
|
232
|
+
|
|
233
|
+
// Handle drops from other lists (on a specific item)
|
|
234
|
+
async onInsert(e) {
|
|
235
|
+
const targetIndex = value.findIndex(
|
|
236
|
+
(item) => getKey(item) === e.target.key,
|
|
237
|
+
);
|
|
238
|
+
const insertIndex =
|
|
239
|
+
e.target.dropPosition === "before" ? targetIndex : targetIndex + 1;
|
|
240
|
+
await handleCrossListDrop(e.items, insertIndex);
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
// Handle drops on empty list or root
|
|
244
|
+
async onRootDrop(e) {
|
|
245
|
+
await handleCrossListDrop(e.items, value.length);
|
|
246
|
+
},
|
|
106
247
|
});
|
|
107
248
|
|
|
108
249
|
// Track which items are currently in the list
|
|
109
|
-
const
|
|
110
|
-
() => new Set(value.map((item) => item
|
|
111
|
-
[value],
|
|
250
|
+
const currentItemKeys = useMemo(
|
|
251
|
+
() => new Set(value.map((item) => getKey(item))),
|
|
252
|
+
[value, getKey],
|
|
112
253
|
);
|
|
113
254
|
|
|
114
255
|
const handleToggleItem = (item: T, isChecked: boolean) => {
|
|
115
256
|
if (isChecked) {
|
|
116
257
|
setValue([...value, item]);
|
|
117
258
|
} else if (value.length > minItems) {
|
|
118
|
-
setValue(value.filter((v) => v
|
|
259
|
+
setValue(value.filter((v) => getKey(v) !== getKey(item)));
|
|
119
260
|
}
|
|
120
261
|
};
|
|
121
262
|
|
|
@@ -124,12 +265,12 @@ export const ReorderableList = <T extends { id: string | number }>({
|
|
|
124
265
|
return;
|
|
125
266
|
}
|
|
126
267
|
|
|
127
|
-
const item = value.find((i) => i
|
|
268
|
+
const item = value.find((i) => getKey(i) === key);
|
|
128
269
|
|
|
129
270
|
if (!item) {
|
|
130
271
|
Logger.warn("handleAction: item not found for key", {
|
|
131
272
|
key,
|
|
132
|
-
|
|
273
|
+
availableKeys: value.map((v) => getKey(v)),
|
|
133
274
|
});
|
|
134
275
|
return;
|
|
135
276
|
}
|
|
@@ -137,19 +278,36 @@ export const ReorderableList = <T extends { id: string | number }>({
|
|
|
137
278
|
onAction(item);
|
|
138
279
|
};
|
|
139
280
|
|
|
281
|
+
// When list is empty, show a drop zone placeholder
|
|
282
|
+
const isEmpty = value.length === 0;
|
|
283
|
+
|
|
140
284
|
const listBox = (
|
|
141
285
|
<ListBox
|
|
142
286
|
aria-label={ariaLabel}
|
|
143
287
|
selectionMode="none"
|
|
144
|
-
items={value}
|
|
145
288
|
dragAndDropHooks={dragAndDropHooks}
|
|
146
289
|
className={className}
|
|
147
290
|
onAction={handleAction}
|
|
148
291
|
>
|
|
149
|
-
{(item) => (
|
|
150
|
-
<ListBoxItem
|
|
292
|
+
{value.map((item) => (
|
|
293
|
+
<ListBoxItem
|
|
294
|
+
key={getKey(item)}
|
|
295
|
+
id={getKey(item)}
|
|
296
|
+
className="active:cursor-grabbing data-[dragging]:opacity-60 outline-none"
|
|
297
|
+
>
|
|
151
298
|
{renderItem(item)}
|
|
152
299
|
</ListBoxItem>
|
|
300
|
+
))}
|
|
301
|
+
{/*
|
|
302
|
+
* When the list is empty, render an invisible placeholder item.
|
|
303
|
+
* This ensures the ListBox maintains minimum dimensions so users can:
|
|
304
|
+
* 1. Right-click to access the context menu and add items back
|
|
305
|
+
* 2. Drag items from another list into this empty list
|
|
306
|
+
*/}
|
|
307
|
+
{isEmpty && (
|
|
308
|
+
<ListBoxItem id="__empty__" className="min-h-[40px] min-w-[40px]">
|
|
309
|
+
<span />
|
|
310
|
+
</ListBoxItem>
|
|
153
311
|
)}
|
|
154
312
|
</ListBox>
|
|
155
313
|
);
|
|
@@ -164,19 +322,20 @@ export const ReorderableList = <T extends { id: string | number }>({
|
|
|
164
322
|
<ContextMenuTrigger asChild={true}>{listBox}</ContextMenuTrigger>
|
|
165
323
|
<ContextMenuContent>
|
|
166
324
|
{availableItems.map((item) => {
|
|
167
|
-
const
|
|
325
|
+
const key = getKey(item);
|
|
326
|
+
const isChecked = currentItemKeys.has(key);
|
|
168
327
|
const isDisabled = isChecked && value.length <= minItems;
|
|
169
328
|
|
|
170
329
|
return (
|
|
171
330
|
<ContextMenuCheckboxItem
|
|
172
|
-
key={
|
|
331
|
+
key={key}
|
|
173
332
|
checked={isChecked}
|
|
174
333
|
disabled={isDisabled}
|
|
175
334
|
onCheckedChange={(checked) => {
|
|
176
335
|
handleToggleItem(item, checked);
|
|
177
336
|
}}
|
|
178
337
|
>
|
|
179
|
-
{getItemLabel(item)}
|
|
338
|
+
{getItemLabel ? getItemLabel(item) : key}
|
|
180
339
|
</ContextMenuCheckboxItem>
|
|
181
340
|
);
|
|
182
341
|
})}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as P}from"./chunk-LvLJmgfZ.js";import{d as j,l as O,n as w,u as y}from"./useEvent-DlWF5OMa.js";import{A,C as L,Gt as E,O as S,Pt as T,Ur as _,ei as $,pt as D}from"./cells-DAR6V-0d.js";import{t as b}from"./compiler-runtime-DeeZ7FnK.js";import{u as F}from"./hotkeys-D3ICc8RW.js";import{u as U}from"./utils-Cxqw03y3.js";import{r as C}from"./constants-Bkp4R3bQ.js";import{j as q,p as B,w as G}from"./config-D3ojpe3F.js";import{t as H}from"./jsx-runtime-DN_bIXfG.js";import{t as M}from"./cn-C1rgT0yh.js";import{r as R}from"./requests-C0HaHO6a.js";import{n as V}from"./ImperativeModal-7Thr73Oo.js";var z=b();function I(){return y(_)}function J(){let r=(0,z.c)(5),[t]=O(G),e=j(_),{openAlert:a}=V(),{sendRename:o}=R(),s;return r[0]!==t.state||r[1]!==a||r[2]!==o||r[3]!==e?(s=async l=>{let n=U();return t.state===q.OPEN?(B(i=>{l===null?i.delete(C.filePath):i.set(C.filePath,l)}),o({filename:l}).then(()=>(e(l),document.title=n.app_title||T.basename(l)||"Untitled Notebook",l)).catch(i=>(a(i.message),null))):(a("Failed to save notebook: not connected to a kernel."),null)},r[0]=t.state,r[1]=a,r[2]=o,r[3]=e,r[4]=s):s=r[4],w(s)}var p=b(),v=P(H(),1);const k=r=>{let t=(0,p.c)(12),{className:e,cellId:a,variant:o,onClick:s,formatCellName:l,skipScroll:n}=r,i=A()[a]??"",x=S().inOrderIds.indexOf(a),{showCellIfHidden:d}=L(),g=l??W,c;t[0]===e?c=t[1]:(c=M("inline-block cursor-pointer text-link hover:underline",e),t[0]=e,t[1]=c);let m;t[2]!==a||t[3]!==s||t[4]!==d||t[5]!==n||t[6]!==o?(m=h=>{if(a==="__scratch__")return!1;d({cellId:a}),h.stopPropagation(),h.preventDefault(),requestAnimationFrame(()=>{N(a,o,n)&&(s==null||s())})},t[2]=a,t[3]=s,t[4]=d,t[5]=n,t[6]=o,t[7]=m):m=t[7];let f=g(D(i,x)),u;return t[8]!==c||t[9]!==m||t[10]!==f?(u=(0,v.jsx)("div",{className:c,role:"link",tabIndex:-1,onClick:m,children:f}),t[8]=c,t[9]=m,t[10]=f,t[11]=u):u=t[11],u},K=r=>{let t=(0,p.c)(2),e;return t[0]===r?e=t[1]:(e=(0,v.jsx)(k,{...r,variant:"destructive"}),t[0]=r,t[1]=e),e},Q=r=>{let t=(0,p.c)(10),{cellId:e,lineNumber:a}=r,o=I(),s;t[0]!==e||t[1]!==a?(s=()=>E(e,a),t[0]=e,t[1]=a,t[2]=s):s=t[2];let l;t[3]!==e||t[4]!==o?(l=i=>e==="__scratch__"?"scratch":`marimo://${o||"untitled"}#cell=${i}`,t[3]=e,t[4]=o,t[5]=l):l=t[5];let n;return t[6]!==e||t[7]!==s||t[8]!==l?(n=(0,v.jsx)(k,{cellId:e,onClick:s,skipScroll:!0,variant:"destructive",className:"traceback-cell-link",formatCellName:l}),t[6]=e,t[7]=s,t[8]=l,t[9]=n):n=t[9],n};function N(r,t,e){let a=$.create(r),o=document.getElementById(a);return o===null?(F.error(`Cell ${a} not found on page.`),!1):(e||o.scrollIntoView({behavior:"smooth",block:"center"}),t==="destructive"&&(o.classList.add("error-outline"),setTimeout(()=>{o.classList.remove("error-outline")},2e3)),t==="focus"&&(o.classList.add("focus-outline"),setTimeout(()=>{o.classList.remove("focus-outline")},2e3)),!0)}function W(r){return r}export{I as a,N as i,K as n,J as o,Q as r,k as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var z=Object.defineProperty;var L=(n,e,t)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var c=(n,e,t)=>L(n,typeof e!="symbol"?e+"":e,t);var g;import{i as p,o as W,p as b}from"./useEvent-DlWF5OMa.js";import{Ar as P,Dr as R,Ht as a,It as B,Kr as K,Lt as j,Or as J,Tt as Q,Ut as w,V as X,Vr as Y,Wt as Z,fn as ee,fr as v,kr as te,pr as D,qt as ne,wr as ie,zt as S}from"./cells-DAR6V-0d.js";import{x as re}from"./_Uint8Array-BGESiCQL.js";import{i as se}from"./useLifecycle-BX7GmOQ5.js";import{t as oe}from"./debounce-BbFlGgjv.js";import{u as o}from"./hotkeys-D3ICc8RW.js";import{t as x}from"./invariant-C6yE60hi.js";import{d as ae,g as I}from"./utils-Cxqw03y3.js";import{k as le,r as ce}from"./config-D3ojpe3F.js";import{St as m,Ut as E,at as ue,ct as M}from"./dist-CAcX026F.js";import{O as T,g as de,k as F,w as me}from"./dist-CI6_zMIl.js";import{n as h}from"./once-CTiSlR1m.js";import{t as pe}from"./requests-C0HaHO6a.js";import{t as ge}from"./use-toast-Bzf3rpev.js";import{a as he}from"./error-banner-D2-5vgE4.js";var fe="Expected a function";function we(n,e,t){var r=!0,s=!0;if(typeof n!="function")throw TypeError(fe);return re(t)&&(r="leading"in t?!!t.leading:r,s="trailing"in t?!!t.trailing:s),oe(n,e,{leading:r,maxWait:e,trailing:s})}var ve=we;function ye(n){"scheduler"in window?window.scheduler.postTask(n,{priority:"background"}):"requestIdleCallback"in window?requestIdleCallback(n):setTimeout(n,0)}var y=null,Ce=class{constructor(n){c(this,"abortController",new AbortController);this.view=n.view,this.view.dom.addEventListener("focus",()=>{y=new WeakRef(this.view)},{signal:this.abortController.signal,capture:!0}),this.update()}update(){let n=this.view.dom.querySelector(".cm-vimCursorLayer");if(n instanceof HTMLElement)if(X())n.style.display="none";else{let e=(y==null?void 0:y.deref())===this.view;n.style.display=e?"":"none"}}destroy(){this.abortController.abort()}};const O={map:{args:["lhs","rhs"]},nmap:{mode:"normal",args:["lhs","rhs"]},vmap:{mode:"visual",args:["lhs","rhs"]},imap:{mode:"insert",args:["lhs","rhs"]},noremap:{args:["lhs","rhs"]},nnoremap:{mode:"normal",args:["lhs","rhs"]},vnoremap:{mode:"visual",args:["lhs","rhs"]},inoremap:{mode:"insert",args:["lhs","rhs"]},unmap:{args:["lhs"]},nunmap:{mode:"normal",args:["lhs"]},vunmap:{mode:"visual",args:["lhs"]},iunmap:{mode:"insert",args:["lhs"]},mapclear:{},nmapclear:{mode:"normal"},vmapclear:{mode:"visual"},imapclear:{mode:"insert"}};function be(n,e){let t=[];for(let r of n.split(`
|
|
2
|
-
`)){if(r.startsWith('"')||r.trim()==="")continue;let s=xe(r,e);s&&t.push(s)}return t}function xe(n,e){let t=n.split(/\s+/),r=t[0],s=0;if(r in O){let i=O[r],u={};for(let f of i.args||[])if(s+=1,s<t.length)u[f]=t[s];else{e&&e(`Not enough arguments for "${r}" command: "${n}"`);return}let d={name:r};return"args"in i&&(d.args=u),"mode"in i&&(d.mode=i.mode),d}e&&e(`Unknown vimrc command: "${n}"`)}function Ie(){return ke(),De(),[m.of([{key:"j",run:n=>{if(B(n,!0)&&S(n)){let e=n.state.facet(v),t=n.state.facet(D);return e.moveToNextCell({cellId:t,before:!1,noCreate:!0}),!0}return!1}}]),m.of([{key:"k",run:n=>{if(j(n)&&S(n)){let e=n.state.facet(v),t=n.state.facet(D);return e.moveToNextCell({cellId:t,before:!0,noCreate:!0}),!0}return!1}}]),m.of([{linux:"Ctrl-[",win:"Ctrl-[",run:n=>{let e=w(n);return e?$(e)?e.state.vim.insertMode?(a.exitInsertMode(e,!0),!0):!1:(o.warn("Expected CodeMirror instance to have Vim state"),!1):(o.warn("Expected CodeMirror instance to have CodeMirror instance state"),!1)}}]),M.define(n=>(requestAnimationFrame(()=>{H.INSTANCES.addInstance(n)}),{destroy(){H.INSTANCES.removeInstance(n)}})),M.define(n=>new Ce({view:n})),ue.domEventHandlers({keydown(n,e){return n.ctrlKey&&n.key==="Escape"?(e.dom.dispatchEvent(new KeyboardEvent(n.type,n)),!0):!1}})]}var ke=h(()=>{a.defineAction("goToDefinition",n=>{let e=n.cm6;return ne(e)}),a.mapCommand("gd","action","goToDefinition",{},{context:"normal"}),a.defineEx("write","w",n=>{let e=n.cm6;e&&e.state.facet(v).saveNotebook()})}),De=h(async()=>{var e;let n=(e=p.get(I).keymap)==null?void 0:e.vimrc;if(n)try{o.log(`Loading vimrc from ${n}`);let t=(await pe().sendFileDetails({path:n})).contents;if(!t){o.error(`Failed to load vimrc from ${n}`);return}Se(be(t,o.warn))}catch(t){o.error("Failed to load vimrc:",t)}});function Se(n){function e(i){if(!i.args){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}if(!i.args.lhs||!i.args.rhs){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}i.mode?a.map(i.args.lhs,i.args.rhs,i.mode):a.map(i.args.lhs,i.args.rhs)}function t(i){if(!i.args){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}if(!i.args.lhs||!i.args.rhs){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}i.mode?a.noremap(i.args.lhs,i.args.rhs,i.mode):a.noremap(i.args.lhs,i.args.rhs)}function r(i){if(!i.args){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}if(!i.args.lhs){o.warn(`Could not execute vimrc command "${i.name}: expected arguments"`);return}i.mode?a.unmap(i.args.lhs,i.mode):a.unmap(i.args.lhs)}function s(i){i.mode?a.mapclear(i.mode):a.mapclear()}for(let i of n)"map|nmap|vmap|imap".split("|").includes(i.name)?e(i):"noremap|nnoremap|vnoremap|inoremap".split("|").includes(i.name)?t(i):"unmap|nunmap|vunmap|iunmap".split("|").includes(i.name)?r(i):"mapclear|nmapclear|vmapclear|imapclear".split("|").includes(i.name)?s(i):o.warn(`Could not execute vimrc command "${i.name}: unknown command"`)}var H=(g=class{constructor(){c(this,"instances",new Set);c(this,"isBroadcasting",!1)}addInstance(e){this.instances.add(e);let t=w(e);if(!t){o.warn("Expected CodeMirror instance to have CodeMirror instance state");return}t.on("vim-mode-change",r=>{this.isBroadcasting||(x("mode"in r,'Expected event to have a "mode" property'),this.isBroadcasting=!0,ye(()=>{this.broadcastModeChange(e,r.mode,r.subMode),this.isBroadcasting=!1}))})}removeInstance(e){this.instances.delete(e)}broadcastModeChange(e,t,r){x("exitInsertMode"in a,"Vim does not have an exitInsertMode method"),x("exitVisualMode"in a,"Vim does not have an exitVisualMode method");for(let s of this.instances)if(s!==e){let i=w(s);if(!i){o.warn("Expected CodeMirror instance to have CodeMirror instance state");continue}let u=i.setSelections.bind(i);if(i.setSelections=()=>[],!$(i)){o.warn("Expected CodeMirror instance to have Vim state");continue}let d=i.state.vim;switch(t){case"normal":d.insertMode&&a.exitInsertMode(i,!0),d.visualMode&&a.exitVisualMode(i,!0);break;case"insert":d.insertMode||a.handleKey(i,"i","");break;case"visual":break}i.setSelections=u}}},c(g,"INSTANCES",new g),g);function $(n){return n.state.vim!==void 0}const Ee=["default","vim"];function Me(n,e){switch(n.preset){case"default":return[m.of(V()),m.of(q(e))];case"vim":return[m.of(Fe()),m.of(q(e)),m.of([{key:"Enter",run:t=>{var r,s;return(s=(r=w(t))==null?void 0:r.state.vim)!=null&&s.insertMode?me(t):!1}}]),E.high(Oe("d",t=>t.state.doc.toString()==="",t=>t.state.doc.toString()===""?(t.state.facet(v).deleteCell(),!0):!1)),Z({status:!1}),E.high(Ie())];default:return se(n.preset),[]}}var Te=new Set([F,T]),V=h(()=>de.filter(n=>!Te.has(n.run))),q=n=>[{key:n.getHotkey("cell.toggleComment").key,run:F},{key:n.getHotkey("cell.toggleBlockComment").key,run:T}],Fe=h(()=>{let n=new Set(["Enter","Ctrl-v"]);return V().filter(e=>!n.has(e.key||e.mac||e.linux||e.win||""))});function Oe(n,e,t){let r="",s=0;return m.of([{any:(i,u)=>{let d=u.key,f=u.timeStamp;return d!==n||!e(i)?(r="",s=0,!1):r===n&&f-s<500&&t(i)?(r="",s=0,!0):(r=d,s=f,!1)}}])}var N="marimo:copilot:signedIn";const He=K(N,null,ee,{getOnInit:!0}),$e=b(null),C=b(null),k=b({busy:!1,kind:null,message:null});function Ve(n){p.set(C,n)}function qe(n){p.get(C)===n&&p.set(C,null)}function Ne(){return Y.getItem(N)==="true"}function _(){let n=Ne(),e=ae();return n&&e.completion.copilot==="github"}function _e(){return W(I,n=>n.completion.copilot==="github")}var Ue=J(),l=o.get("@github/copilot-language-server"),Ae=class extends R{constructor(e){super(e);c(this,"documentVersion",0);c(this,"hasOpenedDocument",!1);c(this,"copilotSettings",{});c(this,"getCompletionInternal",async(e,t)=>await this._request("textDocument/inlineCompletion",{...e,textDocument:{...e.textDocument,version:t}}));c(this,"throttledGetCompletionInternal",ve(this.getCompletionInternal,200));c(this,"handleNotification",e=>{if(!e.params)return;let t=e;if(t.method==="statusNotification"&&p.set(k,t.params),t.method==="didChangeStatus"&&p.set(k,t.params),t.method==="window/logMessage"){let{type:r,message:s}=t.params;switch(r){case 1:l.error("[GitHub Copilot]",s);break;case 2:l.warn("[GitHub Copilot]",s);break;case 3:l.debug("[GitHub Copilot]",s);break;default:l.log("[GitHub Copilot]",s);break}}});this.copilotSettings=e.copilotSettings??{},this.onNotification(this.handleNotification),this.attachInitializeListener()}attachInitializeListener(){this.initializePromise.then(()=>{this.sendConfiguration()})}async sendConfiguration(){let e=this.copilotSettings;!e||Object.keys(e).length===0||(await this.notify("workspace/didChangeConfiguration",{settings:e}),l.debug("#sendConfiguration: Configuration sent",e))}async _request(e,t){return await this.request(e,t)}async notify(e,t){return l.debug("#notify",e,t),super.notify(e,t)}getInitializationOptions(){let e={name:"marimo",version:"0.1.0"};return{...super.getInitializationOptions(),workspaceFolders:[],capabilities:{workspace:{workspaceFolders:!1}},initializationOptions:{editorInfo:e,editorPluginInfo:e}}}isDisabled(){return!_()}async textDocumentDidOpen(e){return this.isDisabled()?e:(this.hasOpenedDocument=!0,super.textDocumentDidOpen(e))}async textDocumentCompletion(e){return[]}async textDocumentDidChange(e){if(this.isDisabled())return e;this.hasOpenedDocument||await this.textDocumentDidOpen({textDocument:{uri:e.textDocument.uri,languageId:"python",version:e.textDocument.version,text:e.contentChanges[0].text}});let t=e.contentChanges;t.length!==1&&l.warn("#textDocumentDidChange: Multiple changes detected. This is not supported.",t);let r=t[0];"range"in r&&l.warn("#textDocumentDidChange: Copilot doesn't support range changes.",r);let s=Q(r.text);return super.textDocumentDidChange({...e,contentChanges:[{text:s}],textDocument:Ue.VersionedTextDocumentIdentifier.create(e.textDocument.uri,++this.documentVersion)})}textDocumentHover(e){return Promise.resolve({contents:[]})}signOut(){return this._request("signOut",{})}async signInInitiate(){l.log("#signInInitiate: Starting sign-in flow");try{let e=await this._request("signIn",{});return l.log("#signInInitiate: Sign-in flow started successfully"),e}catch(e){throw l.warn("#signInInitiate: Failed to start sign-in flow",e),e}}async signInConfirm(e){l.log("#signInConfirm: Confirming sign-in");try{let t=await this._request("signInConfirm",e);return l.log("#signInConfirm: Sign-in confirmed successfully"),t}catch(t){throw l.warn("#signInConfirm: Failed to confirm sign-in",t),t}}async signedIn(){try{let{status:e}=await this._request("checkStatus",{});return l.log("#checkStatus: Status check completed",{status:e}),e==="SignedIn"||e==="AlreadySignedIn"||e==="OK"}catch(e){throw l.warn("#signedIn: Failed to check sign-in status",e),e}}async getCompletion(e){if(this.isDisabled())return null;let t=this.documentVersion;if(e.textDocument.version=t,t===0)return null;Ve(t);let r=await this.throttledGetCompletionInternal(e,t);return qe(t),t===this.documentVersion?r??null:null}},Ge=te(),ze=P(),Le=class extends ze.Transport{constructor(e){super();c(this,"pendingSubscriptions",[]);this.delegate=void 0,this.pendingSubscriptions=[],this.options={retries:e.retries??3,retryDelayMs:e.retryDelayMs??1e3,maxTimeoutMs:e.maxTimeoutMs??5e3,getWsUrl:e.getWsUrl,waitForReady:e.waitForReady,showError:e.showError}}subscribe(...e){super.subscribe(...e);let[t,r]=e;this.pendingSubscriptions.push({event:t,handler:r}),this.delegate&&this.delegate.subscribe(t,r)}unsubscribe(...e){let t=super.unsubscribe(...e),[r,s]=e;if(this.delegate&&this.delegate.unsubscribe(r,s),s)if(r){let i=this.pendingSubscriptions.findIndex(u=>u.event===r&&u.handler===s);i>-1&&this.pendingSubscriptions.splice(i,1)}else this.pendingSubscriptions=this.pendingSubscriptions.filter(i=>i.handler!==s);else r?this.pendingSubscriptions=this.pendingSubscriptions.filter(i=>i.event!==r):this.pendingSubscriptions=[];return t}createDelegate(){let e=new Ge.WebSocketTransport(this.options.getWsUrl());for(let{event:t,handler:r}of this.pendingSubscriptions)e.subscribe(t,r);return e}async tryConnect(){for(let e=1;e<=this.options.retries;e++)try{this.delegate||(this.delegate=this.createDelegate()),await this.delegate.connect(),o.log("Copilot#connect: Connected successfully");return}catch(t){if(o.warn(`Copilot#connect: Connection attempt ${e}/${this.options.retries} failed`,t),e===this.options.retries)throw this.delegate=void 0,this.options.showError("GitHub Copilot Connection Error",`Failed to connect to GitHub Copilot. Please check your settings and try again.
|
|
3
|
-
|
|
4
|
-
`+he(t)),t;await new Promise(r=>setTimeout(r,this.options.retryDelayMs))}}async connect(){return await this.options.waitForReady(),this.tryConnect()}close(){var e;(e=this.delegate)==null||e.close(),this.delegate=void 0}async sendData(e,t){if(!this.delegate){o.log("Copilot#sendData: Delegate not initialized, reconnecting...");try{await this.options.waitForReady(),await this.tryConnect()}catch(r){throw o.error("Copilot#sendData: Failed to reconnect transport",r),Error("Unable to connect to GitHub Copilot. Please check your settings and try again.")}}if(!this.delegate)throw Error("Failed to initialize GitHub Copilot connection. Please try again.");return t=Math.min(t??this.options.maxTimeoutMs,this.options.maxTimeoutMs),this.delegate.sendData(e,t)}};const U="/__marimo_copilot__.py";var A=`file://${U}`;const We=h(()=>{let n=ce();return new Le({getWsUrl:()=>n.getLSPURL("copilot").toString(),waitForReady:async()=>{await _e(),await le()},showError:(e,t)=>{ge({variant:"danger",title:e,description:t})}})}),G=h(()=>{var e,t;let n=((t=(e=p.get(I).ai)==null?void 0:e.github)==null?void 0:t.copilot_settings)??{};return new Ae({rootUri:A,workspaceFolders:null,transport:We(),copilotSettings:n})});function Pe(){return ie({documentUri:A,client:G(),languageId:"copilot",hoverEnabled:!1,completionEnabled:!1,definitionEnabled:!1,renameEnabled:!1,codeActionsEnabled:!1,signatureHelpEnabled:!1,diagnosticsEnabled:!1,sendIncrementalChanges:!1})}export{k as a,He as c,$e as i,Ee as l,Pe as n,C as o,G as r,_ as s,U as t,Me as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as V}from"./chunk-LvLJmgfZ.js";import{l as X,u as B}from"./useEvent-DlWF5OMa.js";import{t as Y}from"./react-BGmjiNul.js";import{zr as Z}from"./cells-DAR6V-0d.js";import"./react-dom-C9fstfnp.js";import{t as T}from"./compiler-runtime-DeeZ7FnK.js";import"./tooltip-BNPhCMFo.js";import{a as ee,c as le,i as te}from"./hotkeys-D3ICc8RW.js";import{f as ie,v as ae,y as oe}from"./utils-Cxqw03y3.js";import"./config-D3ojpe3F.js";import{i as re}from"./switch-C8yab1pC.js";import{t as ne}from"./useEventListener-COkmyg1v.js";import{t as pe}from"./jsx-runtime-DN_bIXfG.js";import"./dist-CAcX026F.js";import"./JsonOutput-NOfbbuUx.js";import"./cjs-Bj40p_Np.js";import"./main-CwSdzVhm.js";import"./useNonce-EAuSVK-5.js";import{r as se}from"./requests-C0HaHO6a.js";import"./layout-F63rlsGg.js";import"./download-D3Uujsn_.js";import{t as de}from"./useCellActionButton-BbfiHu5s.js";import"./markdown-renderer-B9gYLzJX.js";import{i as me,t as he}from"./useNotebookActions-BeM5fet2.js";import{f as ce}from"./state-BK5o1KAL.js";import"./dist-HGZzCB0y.js";import"./dist-CVj-_Iiz.js";import"./dist-BVf1IY4_.js";import"./dist-Cq_4nPfh.js";import"./dist-RKnr9SNh.js";import"./Combination-D1TsGrBC.js";import"./dates-B2_O0-if.js";import"./popover-DtnzNVk-.js";import"./share-0dWXMs9M.js";import"./vega-loader.browser-C8wT63Va.js";import"./defaultLocale-BLUna9fQ.js";import"./defaultLocale-DzliDDTm.js";import"./purify.es-N-2faAGj.js";import{a as ye,c as fe,i as L,l as J,n as ue,o as K,r as be,s as ge}from"./command-BXWdrTY9.js";import"./chunk-OGVTOU66-CjNLT2C3.js";import"./katex-AwOI3EvM.js";import"./marked.esm-CHnOtnr3.js";import"./es-DCqUUmrq.js";import{r as ke}from"./focus-6-St0ai2.js";import{t as Q}from"./renderShortcut-CV_tqoEI.js";import"./esm-B3JckBtM.js";import"./name-cell-input-BMtblyo6.js";import"./multi-icon-BOYRpNB_.js";import"./dist-BRZzJw_5.js";import"./dist-P7JHert4.js";import"./dist-CoiWxjLF.js";import"./dist-cVYW_wBR.js";import"./dist-BAmo7Mv9.js";import"./dist-3oAtECdQ.js";import"./dist-D6Pwf0VF.js";import"./dist-D9HMoxdZ.js";import"./dist-JtCdI6tY.js";import"./esm-CCqLcax5.js";var Ce=T(),je=V(Y(),1);function xe(e,l){let t=(0,Ce.c)(11),n;t[0]===l?n=t[1]:(n=new Z(l),t[0]=l,t[1]=n);let p=n,r;t[2]!==e||t[3]!==p?(r=()=>p.get(e),t[2]=e,t[3]=p,t[4]=r):r=t[4];let[m,g]=(0,je.useState)(r),i;t[5]!==e||t[6]!==p?(i=k=>{g(k),p.set(e,k)},t[5]=e,t[6]=p,t[7]=i):i=t[7];let f=i,h;return t[8]!==f||t[9]!==m?(h=[m,f],t[8]=f,t[9]=m,t[10]=h):h=t[10],h}var ve=T(),we=3;function Se(){let e=(0,ve.c)(7),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=[],e[0]=l):l=e[0];let[t,n]=xe("marimo:commands",l),p;e[1]!==t||e[2]!==n?(p=m=>{n(_e([m,...t]).slice(0,we))},e[1]=t,e[2]=n,e[3]=p):p=e[3];let r;return e[4]!==t||e[5]!==p?(r={recentCommands:t,addRecentCommand:p},e[4]=t,e[5]=p,e[6]=r):r=e[6],r}function _e(e){return[...new Set(e)]}function W(e){return e.dropdown!==void 0}function U(e,l=""){return e.flatMap(t=>t.label?W(t)?U(t.dropdown,`${l+t.label} > `):{...t,label:l+t.label}:[])}var He=T();function Ae(){let e=(0,He.c)(75),[l,t]=oe(),[n,p]=ae(),{saveAppConfig:r,saveUserConfig:m}=se(),g;e[0]!==m||e[1]!==t?(g=async d=>{await m({config:d}).then(()=>{t(c=>({...c,...d}))})},e[0]=m,e[1]=t,e[2]=g):g=e[2];let i=g,f;e[3]!==r||e[4]!==p?(f=async d=>{await r({config:d}).then(()=>{p(d)})},e[3]=r,e[4]=p,e[5]=f):f=e[5];let h=f,k;if(e[6]!==n||e[7]!==l.completion||e[8]!==l.display||e[9]!==l.keymap||e[10]!==h||e[11]!==i){let d;e[13]===n?d=e[14]:(d=P=>P!==n.width,e[13]=n,e[14]=d);let c;e[15]!==n||e[16]!==h?(c=P=>({label:`App config > Set width=${P}`,handle:()=>{h({...n,width:P})}}),e[15]=n,e[16]=h,e[17]=c):c=e[17];let H;e[18]!==l.display||e[19]!==i?(H={label:"Config > Set theme: dark",handle:()=>{i({display:{...l.display,theme:"dark"}})}},e[18]=l.display,e[19]=i,e[20]=H):H=e[20];let C;e[21]!==l.display||e[22]!==i?(C={label:"Config > Set theme: light",handle:()=>{i({display:{...l.display,theme:"light"}})}},e[21]=l.display,e[22]=i,e[23]=C):C=e[23];let A;e[24]!==l.display||e[25]!==i?(A={label:"Config > Set theme: system",handle:()=>{i({display:{...l.display,theme:"system"}})}},e[24]=l.display,e[25]=i,e[26]=A):A=e[26];let R=l.keymap.preset==="vim",M;e[27]!==l.keymap||e[28]!==i?(M=()=>{i({keymap:{...l.keymap,preset:"vim"}})},e[27]=l.keymap,e[28]=i,e[29]=M):M=e[29];let N;e[30]!==R||e[31]!==M?(N={label:"Config > Switch keymap to VIM",hidden:R,handle:M},e[30]=R,e[31]=M,e[32]=N):N=e[32];let D=l.keymap.preset==="default",j;e[33]!==l.keymap||e[34]!==i?(j=()=>{i({keymap:{...l.keymap,preset:"default"}})},e[33]=l.keymap,e[34]=i,e[35]=j):j=e[35];let u;e[36]!==D||e[37]!==j?(u={label:"Config > Switch keymap to default (current: VIM)",hidden:D,handle:j},e[36]=D,e[37]=j,e[38]=u):u=e[38];let x;e[39]!==l.completion||e[40]!==i?(x=()=>{i({completion:{...l.completion,copilot:!1}})},e[39]=l.completion,e[40]=i,e[41]=x):x=e[41];let v=l.completion.copilot!=="github",$;e[42]!==x||e[43]!==v?($={label:"Config > Disable GitHub Copilot",handle:x,hidden:v},e[42]=x,e[43]=v,e[44]=$):$=e[44];let w;e[45]!==l.completion||e[46]!==i?(w=()=>{i({completion:{...l.completion,copilot:"github"}})},e[45]=l.completion,e[46]=i,e[47]=w):w=e[47];let O=l.completion.copilot==="github",q;e[48]!==w||e[49]!==O?(q={label:"Config > Enable GitHub Copilot",handle:w,hidden:O},e[48]=w,e[49]=O,e[50]=q):q=e[50];let z=!l.display.reference_highlighting,S;e[51]!==l.display||e[52]!==i?(S=()=>{i({display:{...l.display,reference_highlighting:!1}})},e[51]=l.display,e[52]=i,e[53]=S):S=e[53];let b;e[54]!==z||e[55]!==S?(b={label:"Config > Disable reference highlighting",hidden:z,handle:S},e[54]=z,e[55]=S,e[56]=b):b=e[56];let y;e[57]!==l.display||e[58]!==i?(y=()=>{i({display:{...l.display,reference_highlighting:!0}})},e[57]=l.display,e[58]=i,e[59]=y):y=e[59];let E;e[60]!==l.display.reference_highlighting||e[61]!==y?(E={label:"Config > Enable reference highlighting",hidden:l.display.reference_highlighting,handle:y},e[60]=l.display.reference_highlighting,e[61]=y,e[62]=E):E=e[62];let o=l.display.cell_output==="above",a;e[63]!==l.display||e[64]!==i?(a=()=>{i({display:{...l.display,cell_output:"above"}})},e[63]=l.display,e[64]=i,e[65]=a):a=e[65];let F;e[66]!==o||e[67]!==a?(F={label:"Config > Set cell output area: above",hidden:o,handle:a},e[66]=o,e[67]=a,e[68]=F):F=e[68];let _=l.display.cell_output==="below",I;e[69]!==l.display||e[70]!==i?(I=()=>{i({display:{...l.display,cell_output:"below"}})},e[69]=l.display,e[70]=i,e[71]=I):I=e[71];let G;e[72]!==_||e[73]!==I?(G={label:"Config > Set cell output area: below",hidden:_,handle:I},e[72]=_,e[73]=I,e[74]=G):G=e[74],k=[...ce().filter(d).map(c),H,C,A,N,u,$,q,b,E,F,G].filter(Me),e[6]=n,e[7]=l.completion,e[8]=l.display,e[9]=l.keymap,e[10]=h,e[11]=i,e[12]=k}else k=e[12];return k}function Me(e){return!e.hidden}var Ne=T(),s=V(pe(),1),De=()=>{let e=(0,Ne.c)(37),[l,t]=X(me),n=re(),p=B(ke),r=B(ie),m;e[0]===p?m=e[1]:(m={cell:p},e[0]=p,e[1]=m);let g=de(m).flat();g=U(g);let i=Ae(),f=he();f=[...U(f),...U(i)];let h=f.filter(Ee),k=ee.keyBy(h,Fe),{recentCommands:d,addRecentCommand:c}=Se(),H;e[2]===d?H=e[3]:(H=new Set(d),e[2]=d,e[3]=H);let C=H,A;e[4]!==r||e[5]!==t?(A=o=>{le(r.getHotkey("global.commandPalette").key)(o)&&(o.preventDefault(),t(Ie))},e[4]=r,e[5]=t,e[6]=A):A=e[6],ne(document,"keydown",A);let R;e[7]!==c||e[8]!==r||e[9]!==n||e[10]!==t?(R=(o,a)=>{let F=n[o];if(!F)return null;let _=r.getHotkey(o);return(0,s.jsxs)(K,{disabled:a.disabled,onSelect:()=>{c(o),t(!1),requestAnimationFrame(()=>{F()})},value:_.name,children:[(0,s.jsxs)("span",{children:[_.name,a.tooltip&&(0,s.jsx)("span",{className:"ml-2",children:a.tooltip})]}),(0,s.jsx)(J,{children:(0,s.jsx)(Q,{shortcut:_.key})})]},o)},e[7]=c,e[8]=r,e[9]=n,e[10]=t,e[11]=R):R=e[11];let M=R,N;e[12]!==c||e[13]!==r||e[14]!==t?(N=o=>{let{label:a,handle:F,props:_,hotkey:I}=o,G=_===void 0?{}:_;return(0,s.jsxs)(K,{disabled:G.disabled,onSelect:()=>{c(a),t(!1),requestAnimationFrame(()=>{F()})},value:a,children:[(0,s.jsxs)("span",{children:[a,G.tooltip&&(0,s.jsxs)("span",{className:"ml-2",children:["(",G.tooltip,")"]})]}),I&&(0,s.jsx)(J,{children:(0,s.jsx)(Q,{shortcut:r.getHotkey(I).key})})]},a)},e[12]=c,e[13]=r,e[14]=t,e[15]=N):N=e[15];let D=N,j=ue,u;e[16]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)(ye,{placeholder:"Type to search..."}),e[16]=u):u=e[16];let x=ge,v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(be,{children:"No results found."}),e[17]=v):v=e[17];let $=d.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(L,{heading:"Recently Used",children:d.map(o=>{let a=k[o];return te(o)?M(o,{disabled:a==null?void 0:a.disabled,tooltip:a==null?void 0:a.tooltip}):a&&!W(a)?D({label:a.label,handle:a.handleHeadless||a.handle,props:{disabled:a.disabled,tooltip:a.tooltip}}):null})}),(0,s.jsx)(fe,{})]}),w=L,O=r.iterate().map(o=>{if(C.has(o))return null;let a=k[o];return M(o,{disabled:a==null?void 0:a.disabled,tooltip:a==null?void 0:a.tooltip})}),q=h.map(o=>C.has(o.label)?null:D({label:o.label,handle:o.handleHeadless||o.handle,props:{disabled:o.disabled,tooltip:o.tooltip}})),z;e[18]!==C||e[19]!==D?(z=o=>C.has(o.label)?null:D({label:`Cell > ${o.label}`,handle:o.handleHeadless||o.handle,props:{disabled:o.disabled,tooltip:o.tooltip}}),e[18]=C,e[19]=D,e[20]=z):z=e[20];let S=g.map(z),b;e[21]!==w||e[22]!==q||e[23]!==S||e[24]!==O?(b=(0,s.jsxs)(w,{heading:"Commands",children:[O,q,S]}),e[21]=w,e[22]=q,e[23]=S,e[24]=O,e[25]=b):b=e[25];let y;e[26]!==x||e[27]!==b||e[28]!==v||e[29]!==$?(y=(0,s.jsxs)(x,{children:[v,$,b]}),e[26]=x,e[27]=b,e[28]=v,e[29]=$,e[30]=y):y=e[30];let E;return e[31]!==j||e[32]!==l||e[33]!==t||e[34]!==y||e[35]!==u?(E=(0,s.jsxs)(j,{open:l,onOpenChange:t,children:[u,y]}),e[31]=j,e[32]=l,e[33]=t,e[34]=y,e[35]=u,e[36]=E):E=e[36],E};function Ee(e){return!e.hotkey}function Fe(e){return e.label}function Ie(e){return!e}export{De as default};
|