@marimo-team/frontend 0.18.5-dev168 → 0.18.5-dev171
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-ClrYbUob.js} +1 -1
- package/dist/assets/{ConnectedDataExplorerComponent-B0tKPs5t.js → ConnectedDataExplorerComponent-KlUs_Sz3.js} +1 -1
- package/dist/assets/{ErrorBoundary-BYCO3_zw.js → ErrorBoundary-Drf1manw.js} +1 -1
- package/dist/assets/{ImperativeModal-7Thr73Oo.js → ImperativeModal-q6QlC2aZ.js} +1 -1
- package/dist/assets/{JsonOutput-NOfbbuUx.js → JsonOutput-CkeISXrs.js} +9 -9
- package/dist/assets/{LazyAnyLanguageCodeMirror-DIbHWNF6.js → LazyAnyLanguageCodeMirror-jpEDlD0M.js} +2 -2
- package/dist/assets/{MarimoErrorOutput-usFICLUe.js → MarimoErrorOutput-CO8cm8-0.js} +2 -2
- package/dist/assets/{RenderHTML-LxV1eecf.js → RenderHTML-D6fh5YLC.js} +1 -1
- package/dist/assets/{VisuallyHidden-BLp5kXtE.js → VisuallyHidden-BodIky8L.js} +1 -1
- package/dist/assets/{add-cell-with-ai-CEKGThxQ.js → add-cell-with-ai-B3V6Mgb9.js} +12 -12
- package/dist/assets/{add-database-form-DQyrphh9.js → add-database-form-C-K88iSC.js} +1 -1
- package/dist/assets/{agent-panel-CnTn12AW.js → agent-panel-BvLqBe3U.js} +6 -6
- package/dist/assets/{ai-model-dropdown-CxRols0L.js → ai-model-dropdown-D1nEKS8b.js} +1 -1
- package/dist/assets/{alert-dialog-B3T1GCoD.js → alert-dialog-k5KxevGr.js} +1 -1
- package/dist/assets/any-language-editor-DQu1Tt2N.js +3 -0
- package/dist/assets/{app-config-button-DtMP2_j5.js → app-config-button-BD5l-v4I.js} +1 -1
- package/dist/assets/{button-C9TEIJJh.js → button-DuYGqRtX.js} +1 -1
- package/dist/assets/{cache-panel-C-YLXsti.js → cache-panel-C1So4Zu3.js} +1 -1
- package/dist/assets/{capabilities-h9_pyvFv.js → capabilities-BmAOeMOK.js} +1 -1
- package/dist/assets/{capitalize-D4JsDDXI.js → capitalize-DQeWKRGx.js} +1 -1
- package/dist/assets/{cell-actions-DCZqhhwF.js → cell-actions-CJiaF9Tu.js} +1 -1
- package/dist/assets/cell-link-Hwo1QbqQ.js +1 -0
- package/dist/assets/{cells-DAR6V-0d.js → cells-rr1jjvJk.js} +33 -33
- package/dist/assets/{chat-components-CyY2c7cG.js → chat-components-DXJsXOD8.js} +1 -1
- package/dist/assets/{chat-display-BgCCmGdz.js → chat-display-C08N0rx5.js} +1 -1
- package/dist/assets/{chat-panel-ByuXM3gc.js → chat-panel-CNL6ANh8.js} +2 -2
- package/dist/assets/client-SMzMTiO_.js +4 -0
- package/dist/assets/{column-preview-DBqi4KCj.js → column-preview-BzvHnhPG.js} +1 -1
- package/dist/assets/command-palette-B_md1fzh.js +1 -0
- package/dist/assets/{command-BXWdrTY9.js → command-xU8ykulh.js} +1 -1
- package/dist/assets/{common-D10A9aix.js → common-_RAkDTpe.js} +1 -1
- package/dist/assets/{config-D3ojpe3F.js → config-cCkBQ_ER.js} +1 -1
- package/dist/assets/{copy-Bmkr29w4.js → copy-DRhpWiOq.js} +1 -1
- package/dist/assets/{copy-icon-qVgCqhII.js → copy-icon-B69c-352.js} +1 -1
- package/dist/assets/{createReducer-CaezzNVH.js → createReducer-DDa-hVe3.js} +1 -1
- package/dist/assets/{datasource-CW2RMV2e.js → datasource-DHbNHnua.js} +2 -2
- package/dist/assets/{dates-B2_O0-if.js → dates-CdsE1R40.js} +1 -1
- package/dist/assets/{dependency-graph-panel-CtlDdK0s.js → dependency-graph-panel-BGp5UzmZ.js} +3 -3
- package/dist/assets/{dialog-DIUTtzeB.js → dialog-DUEuLcT2.js} +1 -1
- package/dist/assets/{dist-vrNOUnFF.js → dist-DOFFh6Ii.js} +1 -1
- package/dist/assets/{documentation-panel-Cup0ghBs.js → documentation-panel-CuPlvIjJ.js} +1 -1
- package/dist/assets/{download-D3Uujsn_.js → download-DKRxBkYD.js} +1 -1
- package/dist/assets/edit-page-DAFshpgY.js +13 -0
- package/dist/assets/{error-banner-D2-5vgE4.js → error-banner-DU5Qb8a8.js} +1 -1
- package/dist/assets/{error-panel-DcRvXIwA.js → error-panel-CoYFpNUd.js} +1 -1
- package/dist/assets/{es-DCqUUmrq.js → es-YVwBDiDw.js} +1 -1
- package/dist/assets/{field-D2_0r7wT.js → field-DDKGFzpC.js} +1 -1
- package/dist/assets/{file-explorer-panel-9Bt20tRi.js → file-explorer-panel-BcpntT7Q.js} +1 -1
- package/dist/assets/{floating-outline-BTc4L5BF.js → floating-outline-CHprSkP6.js} +1 -1
- package/dist/assets/{focus-6-St0ai2.js → focus-D3ygI6Sy.js} +1 -1
- package/dist/assets/{form-1WOcPtE8.js → form-B_zRT4QS.js} +2 -2
- package/dist/assets/{formats-nh-sPUUZ.js → formats-B9CrBoaO.js} +1 -1
- package/dist/assets/{glide-data-editor-EdMWe-iv.js → glide-data-editor-Brckuic5.js} +1 -1
- package/dist/assets/{globals-CJb4gcmW.js → globals-D46Vbo5D.js} +1 -1
- package/dist/assets/{home-page-Lqy9A89-.js → home-page-DuPzZzUf.js} +2 -2
- package/dist/assets/hotkeys-uKX61F1_.js +1 -0
- package/dist/assets/{index-CIoUDThG.js → index-CQBtzy-J.js} +9 -9
- package/dist/assets/index-G6ss-VDT.css +2 -0
- package/dist/assets/{input-DP44ewsS.js → input-CaEtLL8p.js} +1 -1
- package/dist/assets/{kiosk-mode-C3lS9kUL.js → kiosk-mode-CTjr_Jn4.js} +1 -1
- package/dist/assets/{label-DJo0Eeb3.js → label-qwandMoh.js} +1 -1
- package/dist/assets/{layout-F63rlsGg.js → layout-CprHgyfx.js} +4 -4
- package/dist/assets/links-Cw9RjHIY.js +1 -0
- package/dist/assets/{logs-panel-fnMYUf4-.js → logs-panel-CFM-1lMP.js} +1 -1
- package/dist/assets/{maps-DELIOfTw.js → maps-s2pQkyf5.js} +1 -1
- package/dist/assets/{markdown-renderer-B9gYLzJX.js → markdown-renderer-DecoaRsV.js} +1 -1
- package/dist/assets/{mermaid-BUMgiGGr.js → mermaid-BPkO79lo.js} +1 -1
- package/dist/assets/{mode-D4GlAyEq.js → mode-BYulXE3t.js} +1 -1
- package/dist/assets/{multi-map-TecGBFLS.js → multi-map-fjX9ImVF.js} +1 -1
- package/dist/assets/{name-cell-input-BMtblyo6.js → name-cell-input-BGJDnv5Z.js} +1 -1
- package/dist/assets/{numbers-Ckcn6C-H.js → numbers-C9_R_vlY.js} +1 -1
- package/dist/assets/outline-panel-C-__7mIh.js +1 -0
- package/dist/assets/{packages-panel-DyC7zUxG.js → packages-panel-B4bQCG8Y.js} +1 -1
- package/dist/assets/{cell-editor-DJ1tY3mU.js → panel-context-Bee798AZ.js} +13 -13
- package/dist/assets/{panels-wYHy1fpG.js → panels-CuLZ4Xjj.js} +1 -1
- package/dist/assets/{process-output-D1GR6Ero.js → process-output-2gz8Uri2.js} +1 -1
- package/dist/assets/{readonly-python-code-CGnOB_RP.js → readonly-python-code-ihKi3Mrq.js} +1 -1
- package/dist/assets/{renderShortcut-CV_tqoEI.js → renderShortcut-D0Pei-OA.js} +1 -1
- package/dist/assets/{run-page-BLnJcKtg.js → run-page-Q1ifcEUY.js} +1 -1
- package/dist/assets/{runs-BbV5uZz6.js → runs-yuOchwkU.js} +1 -1
- package/dist/assets/scratchpad-panel-B75Qsjwz.js +1 -0
- package/dist/assets/{secrets-panel-K7EccfRa.js → secrets-panel-CDWmmmBS.js} +1 -1
- package/dist/assets/{select-BJ18Dxpd.js → select-D0g5GnIs.js} +1 -1
- package/dist/assets/{session-panel-C3rDPyig.js → session-panel-Bn5_JmbT.js} +1 -1
- package/dist/assets/{share-0dWXMs9M.js → share-CXQVxivL.js} +1 -1
- package/dist/assets/{slides-component-CZ76zal6.js → slides-component-DUIqQih1.js} +1 -1
- package/dist/assets/{snippets-panel-s0p4CCoa.js → snippets-panel-CVBBnX9H.js} +1 -1
- package/dist/assets/{spec-D9TFI5I_.js → spec-qp_XZeSS.js} +1 -1
- package/dist/assets/{state-DwSzcmzL.js → state-BHFBtWym.js} +1 -1
- package/dist/assets/{state-CGq6kn1k.js → state-CIznbe1J.js} +1 -1
- package/dist/assets/{state-BK5o1KAL.js → state-DNwec0Uj.js} +1 -1
- package/dist/assets/{switch-C8yab1pC.js → switch-iJj-D3dz.js} +1 -1
- package/dist/assets/{terminal-CA6CqpuO.js → terminal-CRIGvHBN.js} +1 -1
- package/dist/assets/{textarea-DBFtOima.js → textarea-DmNrZcLR.js} +1 -1
- package/dist/assets/{tooltip-BNPhCMFo.js → tooltip-CrRUCOBw.js} +1 -1
- package/dist/assets/tracing-D9h130fg.js +1 -0
- package/dist/assets/{tracing-panel-C-o1Db4W.js → tracing-panel-DaDvGMEN.js} +2 -2
- package/dist/assets/{type-drzC-SxF.js → type-BdyvjzTI.js} +1 -1
- package/dist/assets/{types-Bt3U-XJV.js → types-4-l_7Ws2.js} +1 -1
- package/dist/assets/{useAddCell-CNI3pgez.js → useAddCell-BpMe5DB-.js} +1 -1
- package/dist/assets/{useBoolean-C_vQizET.js → useBoolean-BDG41CyP.js} +1 -1
- package/dist/assets/{useCellActionButton-BbfiHu5s.js → useCellActionButton-Dh4wbVPA.js} +1 -1
- package/dist/assets/{useDeleteCell-B_jFiS1Y.js → useDeleteCell-DBzN8QcP.js} +1 -1
- package/dist/assets/{useIframeCapabilities-ZISlVepl.js → useIframeCapabilities-CU-WWxnz.js} +1 -1
- package/dist/assets/{useInstallPackage-CBvG269f.js → useInstallPackage-RldLPyJs.js} +1 -1
- package/dist/assets/{useLifecycle-BX7GmOQ5.js → useLifecycle-CmDXEyIC.js} +1 -1
- package/dist/assets/{useNotebookActions-BeM5fet2.js → useNotebookActions-DKyQBNlS.js} +1 -1
- package/dist/assets/useRunCells-BGzo-QMk.js +1 -0
- package/dist/assets/{useSplitCell-COPg5dJw.js → useSplitCell-CvKAuKQ_.js} +1 -1
- package/dist/assets/{useTheme-CuOCKnyR.js → useTheme-DfP1CWaW.js} +1 -1
- package/dist/assets/{utilities.esm-B7XtzwiJ.js → utilities.esm-CT3NbLA9.js} +2 -2
- package/dist/assets/{utils-Cxqw03y3.js → utils-CJJIceVn.js} +1 -1
- package/dist/assets/{vega-component-arPQXQS8.js → vega-component-CLrcy81y.js} +1 -1
- package/dist/assets/{write-secret-modal-CIbhcoWF.js → write-secret-modal-CLm48gMe.js} +1 -1
- package/dist/index.html +68 -68
- package/package.json +1 -1
- package/src/components/editor/actions/useNotebookActions.tsx +1 -1
- package/src/components/editor/chrome/panels/panel-context.tsx +34 -0
- 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 +216 -139
- package/src/components/editor/chrome/wrapper/sidebar.tsx +76 -43
- package/src/components/scratchpad/scratchpad.tsx +17 -4
- package/src/components/ui/reorderable-list.tsx +190 -31
- package/src/core/codemirror/cells/extensions.ts +7 -4
- package/src/core/hotkeys/__tests__/shortcuts.test.ts +61 -4
- package/src/core/hotkeys/shortcuts.ts +34 -2
- package/dist/assets/any-language-editor-CTAS1EXW.js +0 -3
- 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/hotkeys-D3ICc8RW.js +0 -1
- 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/scratchpad-panel-CTJDEy90.js +0 -1
- package/dist/assets/tracing-VZVj-gEo.js +0 -1
- package/dist/assets/useRunCells-oeY0TrS1.js +0 -1
- /package/dist/assets/{cell-editor-Iey559K_.css → panel-context-Iey559K_.css} +0 -0
|
@@ -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
|
})}
|
|
@@ -7,6 +7,7 @@ import { createTracebackInfoAtom } from "@/core/cells/cells";
|
|
|
7
7
|
import { type CellId, HTMLCellId, SCRATCH_CELL_ID } from "@/core/cells/ids";
|
|
8
8
|
import type { KeymapConfig } from "@/core/config/config-schema";
|
|
9
9
|
import type { HotkeyProvider } from "@/core/hotkeys/hotkeys";
|
|
10
|
+
import { duplicateWithCtrlModifier } from "@/core/hotkeys/shortcuts";
|
|
10
11
|
import { store } from "@/core/state/jotai";
|
|
11
12
|
import { createObservable } from "@/core/state/observable";
|
|
12
13
|
import { formatKeymapExtension } from "../extensions";
|
|
@@ -33,8 +34,9 @@ function cellKeymaps({
|
|
|
33
34
|
}): Extension[] {
|
|
34
35
|
const keybindings: KeyBinding[] = [];
|
|
35
36
|
|
|
37
|
+
// Run-related keybindings get Ctrl equivalents on macOS for Jupyter/Colab users
|
|
36
38
|
keybindings.push(
|
|
37
|
-
{
|
|
39
|
+
...duplicateWithCtrlModifier({
|
|
38
40
|
key: hotkeys.getHotkey("cell.run").key,
|
|
39
41
|
preventDefault: true,
|
|
40
42
|
stopPropagation: true,
|
|
@@ -43,8 +45,9 @@ function cellKeymaps({
|
|
|
43
45
|
actions.onRun();
|
|
44
46
|
return true;
|
|
45
47
|
},
|
|
46
|
-
},
|
|
48
|
+
}),
|
|
47
49
|
{
|
|
50
|
+
// Shift-Enter has no Cmd, so no Ctrl equivalent needed
|
|
48
51
|
key: hotkeys.getHotkey("cell.runAndNewBelow").key,
|
|
49
52
|
preventDefault: true,
|
|
50
53
|
stopPropagation: true,
|
|
@@ -59,7 +62,7 @@ function cellKeymaps({
|
|
|
59
62
|
return true;
|
|
60
63
|
},
|
|
61
64
|
},
|
|
62
|
-
{
|
|
65
|
+
...duplicateWithCtrlModifier({
|
|
63
66
|
key: hotkeys.getHotkey("cell.runAndNewAbove").key,
|
|
64
67
|
preventDefault: true,
|
|
65
68
|
stopPropagation: true,
|
|
@@ -73,7 +76,7 @@ function cellKeymaps({
|
|
|
73
76
|
actions.moveToNextCell({ cellId, before: true });
|
|
74
77
|
return true;
|
|
75
78
|
},
|
|
76
|
-
},
|
|
79
|
+
}),
|
|
77
80
|
{
|
|
78
81
|
key: hotkeys.getHotkey("cell.aiCompletion").key,
|
|
79
82
|
preventDefault: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { parseShortcut } from "../shortcuts";
|
|
3
|
+
import { duplicateWithCtrlModifier, parseShortcut } from "../shortcuts";
|
|
4
4
|
|
|
5
5
|
describe("parseShortcut", () => {
|
|
6
6
|
it("should recognize single key shortcuts", () => {
|
|
@@ -21,10 +21,14 @@ describe("parseShortcut", () => {
|
|
|
21
21
|
expect(shortcut(event)).toBe(true);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it("should recognize combined Cmd key shortcuts", () => {
|
|
24
|
+
it("should recognize combined Cmd key shortcuts with meta or ctrl", () => {
|
|
25
25
|
const shortcut = parseShortcut("Cmd-a");
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// Cmd should accept both metaKey and ctrlKey (like Mod)
|
|
27
|
+
const metaEvent = new KeyboardEvent("keydown", { key: "a", metaKey: true });
|
|
28
|
+
expect(shortcut(metaEvent)).toBe(true);
|
|
29
|
+
|
|
30
|
+
const ctrlEvent = new KeyboardEvent("keydown", { key: "a", ctrlKey: true });
|
|
31
|
+
expect(shortcut(ctrlEvent)).toBe(true);
|
|
28
32
|
});
|
|
29
33
|
|
|
30
34
|
it("should recognize Arrow key shortcuts", () => {
|
|
@@ -164,3 +168,56 @@ describe("parseShortcut", () => {
|
|
|
164
168
|
expect(parseShortcut("Ctrl+A")(event)).toBe(false);
|
|
165
169
|
});
|
|
166
170
|
});
|
|
171
|
+
|
|
172
|
+
describe("duplicateWithCtrlModifier", () => {
|
|
173
|
+
it("should duplicate Cmd binding with Ctrl variant on macOS", () => {
|
|
174
|
+
// Mock macOS platform
|
|
175
|
+
vi.spyOn(window.navigator, "platform", "get").mockReturnValue("MacIntel");
|
|
176
|
+
|
|
177
|
+
const binding = { key: "Cmd-Enter", run: () => true };
|
|
178
|
+
const result = duplicateWithCtrlModifier(binding);
|
|
179
|
+
|
|
180
|
+
expect(result).toHaveLength(2);
|
|
181
|
+
expect(result[0].key).toBe("Cmd-Enter");
|
|
182
|
+
expect(result[1].key).toBe("Ctrl-Enter");
|
|
183
|
+
|
|
184
|
+
vi.restoreAllMocks();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("should not duplicate binding without Cmd", () => {
|
|
188
|
+
vi.spyOn(window.navigator, "platform", "get").mockReturnValue("MacIntel");
|
|
189
|
+
|
|
190
|
+
const binding = { key: "Shift-Enter", run: () => true };
|
|
191
|
+
const result = duplicateWithCtrlModifier(binding);
|
|
192
|
+
|
|
193
|
+
expect(result).toHaveLength(1);
|
|
194
|
+
expect(result[0].key).toBe("Shift-Enter");
|
|
195
|
+
|
|
196
|
+
vi.restoreAllMocks();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("should not duplicate Cmd-Ctrl binding to avoid Ctrl-Ctrl", () => {
|
|
200
|
+
vi.spyOn(window.navigator, "platform", "get").mockReturnValue("MacIntel");
|
|
201
|
+
|
|
202
|
+
const binding = { key: "Cmd-Ctrl-Enter", run: () => true };
|
|
203
|
+
const result = duplicateWithCtrlModifier(binding);
|
|
204
|
+
|
|
205
|
+
// Should NOT create a Ctrl-Ctrl-Enter variant
|
|
206
|
+
expect(result).toHaveLength(1);
|
|
207
|
+
expect(result[0].key).toBe("Cmd-Ctrl-Enter");
|
|
208
|
+
|
|
209
|
+
vi.restoreAllMocks();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("should not duplicate on non-macOS platforms", () => {
|
|
213
|
+
vi.spyOn(window.navigator, "platform", "get").mockReturnValue("Win32");
|
|
214
|
+
|
|
215
|
+
const binding = { key: "Cmd-Enter", run: () => true };
|
|
216
|
+
const result = duplicateWithCtrlModifier(binding);
|
|
217
|
+
|
|
218
|
+
expect(result).toHaveLength(1);
|
|
219
|
+
expect(result[0].key).toBe("Cmd-Enter");
|
|
220
|
+
|
|
221
|
+
vi.restoreAllMocks();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import type { KeyBinding } from "@codemirror/view";
|
|
3
4
|
import { Logger } from "@/utils/Logger";
|
|
4
5
|
import { NOT_SET } from "./hotkeys";
|
|
5
6
|
|
|
@@ -106,8 +107,8 @@ function areKeysPressed(keys: string[], e: IKeyboardEvent): boolean {
|
|
|
106
107
|
function normalizeKey(key: string): string {
|
|
107
108
|
const specialKeys: { [key: string]: string } = {
|
|
108
109
|
control: "ctrl",
|
|
109
|
-
command: "
|
|
110
|
-
cmd: "
|
|
110
|
+
command: "mod",
|
|
111
|
+
cmd: "mod",
|
|
111
112
|
option: "alt",
|
|
112
113
|
return: "enter",
|
|
113
114
|
};
|
|
@@ -144,3 +145,34 @@ export function resolvePlatform(): Platform {
|
|
|
144
145
|
}
|
|
145
146
|
return "linux";
|
|
146
147
|
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* On macOS, duplicate a Cmd-based keybinding to also work with Ctrl.
|
|
151
|
+
* This allows users coming from Jupyter/Colab to use Ctrl-Enter to run cells.
|
|
152
|
+
*
|
|
153
|
+
* Returns an array with the original binding, plus a Ctrl variant on macOS.
|
|
154
|
+
* For use with CodeMirror keymap bindings.
|
|
155
|
+
*
|
|
156
|
+
* Design decision: User-defined Cmd shortcuts also get Ctrl equivalents.
|
|
157
|
+
* The edge case is if a user wants `Cmd+<x>` and `Ctrl+<x>` to trigger
|
|
158
|
+
* different actions, this isn't currently supported. Given the relatively
|
|
159
|
+
* small number of keymaps, we're keeping this simple. If it becomes an issue,
|
|
160
|
+
* we can refactor to resolve a special "Mod" key internally and require users
|
|
161
|
+
* to specify explicit single-key mappings.
|
|
162
|
+
*
|
|
163
|
+
* Note: If the binding already contains Ctrl (e.g., Cmd-Ctrl-Enter),
|
|
164
|
+
* no duplication is done to avoid producing invalid Ctrl-Ctrl-key combos.
|
|
165
|
+
*/
|
|
166
|
+
export function duplicateWithCtrlModifier<T extends KeyBinding>(
|
|
167
|
+
binding: T,
|
|
168
|
+
): T[] {
|
|
169
|
+
// Skip if not macOS, not a Cmd binding, or already has Ctrl
|
|
170
|
+
if (
|
|
171
|
+
!isPlatformMac() ||
|
|
172
|
+
!binding.key?.includes("Cmd") ||
|
|
173
|
+
binding.key.includes("Ctrl")
|
|
174
|
+
) {
|
|
175
|
+
return [binding];
|
|
176
|
+
}
|
|
177
|
+
return [binding, { ...binding, key: binding.key.replaceAll("Cmd", "Ctrl") }];
|
|
178
|
+
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{s as a}from"./chunk-LvLJmgfZ.js";import{t as u}from"./react-BGmjiNul.js";import"./react-dom-C9fstfnp.js";import"./compiler-runtime-DeeZ7FnK.js";import{u as f}from"./hotkeys-D3ICc8RW.js";import{t as d}from"./jsx-runtime-DN_bIXfG.js";import"./dist-CAcX026F.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{n as c}from"./error-banner-D2-5vgE4.js";import{t as h}from"./copy-icon-qVgCqhII.js";import{t as g}from"./esm-B3JckBtM.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{n as v,t as m}from"./esm-CCqLcax5.js";var j=a(u(),1),t=a(d(),1);const p={python:"py",javascript:"js",typescript:"ts",shell:"sh",bash:"sh"};function e(o){return o?o in m:!1}var x=({language:o,showCopyButton:n,extensions:r=[],...s})=>{o=p[o||""]||o;let i=e(o);i||f.warn(`Language ${o} not found in CodeMirror.`);let l=(0,j.useMemo)(()=>e(o)?[v(o),...r].filter(Boolean):r,[o,r]);return(0,t.jsxs)("div",{className:"relative w-full group hover-actions-parent",children:[!i&&(0,t.jsx)(c,{className:"mb-1 rounded-sm",error:`Language ${o} not supported.
|
|
2
|
-
|
|
3
|
-
Supported languages are: ${Object.keys(m).join(", ")}`}),n&&i&&(0,t.jsx)(h,{tooltip:!1,buttonClassName:"absolute top-2 right-2 z-10 hover-action",className:"h-4 w-4 text-muted-foreground",value:s.value||"",toastTitle:"Copied to clipboard"}),(0,t.jsx)(g,{...s,extensions:l})]})};export{p as LANGUAGE_MAP,x as default};
|
|
@@ -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};
|