@datalayer/jupyter-react 0.0.7 → 0.0.8

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.
Files changed (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/package.json +16 -11
  4. package/lib/components/cell/Cell.d.ts +0 -15
  5. package/lib/components/cell/Cell.js +0 -48
  6. package/lib/components/cell/CellAdapter.d.ts +0 -14
  7. package/lib/components/cell/CellAdapter.js +0 -133
  8. package/lib/components/cell/CellCommands.d.ts +0 -6
  9. package/lib/components/cell/CellCommands.js +0 -37
  10. package/lib/components/cell/CellState.d.ts +0 -22
  11. package/lib/components/cell/CellState.js +0 -45
  12. package/lib/components/commands/Commands.d.ts +0 -2
  13. package/lib/components/commands/Commands.js +0 -8
  14. package/lib/components/commands/CommandsAdapter.d.ts +0 -9
  15. package/lib/components/commands/CommandsAdapter.js +0 -35
  16. package/lib/components/commands/CommandsState.d.ts +0 -15
  17. package/lib/components/commands/CommandsState.js +0 -29
  18. package/lib/components/console/Console.d.ts +0 -2
  19. package/lib/components/console/Console.js +0 -8
  20. package/lib/components/console/ConsoleAdapter.d.ts +0 -11
  21. package/lib/components/console/ConsoleAdapter.js +0 -85
  22. package/lib/components/console/ConsoleState.d.ts +0 -15
  23. package/lib/components/console/ConsoleState.js +0 -29
  24. package/lib/components/dialog/Dialog.d.ts +0 -2
  25. package/lib/components/dialog/Dialog.js +0 -12
  26. package/lib/components/dialog/DialogAdapter.d.ts +0 -10
  27. package/lib/components/dialog/DialogAdapter.js +0 -18
  28. package/lib/components/editor/CodeMirrorEditor.d.ts +0 -7
  29. package/lib/components/editor/CodeMirrorEditor.js +0 -61
  30. package/lib/components/filebrowser/FileBrowser.d.ts +0 -2
  31. package/lib/components/filebrowser/FileBrowser.js +0 -8
  32. package/lib/components/filebrowser/FileBrowserAdapter.d.ts +0 -13
  33. package/lib/components/filebrowser/FileBrowserAdapter.js +0 -266
  34. package/lib/components/filebrowser/FileBrowserState.d.ts +0 -15
  35. package/lib/components/filebrowser/FileBrowserState.js +0 -29
  36. package/lib/components/filebrowser/FileBrowserTree.d.ts +0 -2
  37. package/lib/components/filebrowser/FileBrowserTree.js +0 -59
  38. package/lib/components/ipywidgets/IpyWidgetsComponent.d.ts +0 -5
  39. package/lib/components/ipywidgets/IpyWidgetsComponent.js +0 -8
  40. package/lib/components/notebook/Notebook.d.ts +0 -25
  41. package/lib/components/notebook/Notebook.js +0 -78
  42. package/lib/components/notebook/NotebookAdapter.d.ts +0 -25
  43. package/lib/components/notebook/NotebookAdapter.js +0 -186
  44. package/lib/components/notebook/NotebookCommands.d.ts +0 -38
  45. package/lib/components/notebook/NotebookCommands.js +0 -368
  46. package/lib/components/notebook/NotebookState.d.ts +0 -49
  47. package/lib/components/notebook/NotebookState.js +0 -116
  48. package/lib/components/notebook/content/CellSidebar.d.ts +0 -8
  49. package/lib/components/notebook/content/CellSidebar.js +0 -22
  50. package/lib/components/notebook/content/ContentFactoryWithSidebar.d.ts +0 -14
  51. package/lib/components/notebook/content/ContentFactoryWithSidebar.js +0 -19
  52. package/lib/components/notebook/content/NotebookInputPrompt.d.ts +0 -21
  53. package/lib/components/notebook/content/NotebookInputPrompt.js +0 -66
  54. package/lib/components/notebook/render/marked.d.ts +0 -3
  55. package/lib/components/notebook/render/marked.js +0 -71
  56. package/lib/components/outputs/Output.d.ts +0 -16
  57. package/lib/components/outputs/Output.js +0 -55
  58. package/lib/components/outputs/OutputAdapter.d.ts +0 -20
  59. package/lib/components/outputs/OutputAdapter.js +0 -69
  60. package/lib/components/outputs/OutputState.d.ts +0 -15
  61. package/lib/components/outputs/OutputState.js +0 -29
  62. package/lib/components/settings/Settings.d.ts +0 -2
  63. package/lib/components/settings/Settings.js +0 -8
  64. package/lib/components/settings/SettingsAdapter.d.ts +0 -10
  65. package/lib/components/settings/SettingsAdapter.js +0 -15
  66. package/lib/components/settings/SettingsState.d.ts +0 -15
  67. package/lib/components/settings/SettingsState.js +0 -29
  68. package/lib/components/terminal/Terminal.d.ts +0 -2
  69. package/lib/components/terminal/Terminal.js +0 -15
  70. package/lib/components/terminal/TerminalAdapter.d.ts +0 -13
  71. package/lib/components/terminal/TerminalAdapter.js +0 -27
  72. package/lib/components/terminal/TerminalState.d.ts +0 -15
  73. package/lib/components/terminal/TerminalState.js +0 -37
  74. package/lib/index.d.ts +0 -23
  75. package/lib/index.js +0 -35
  76. package/lib/jupyter/AuthError.d.ts +0 -7
  77. package/lib/jupyter/AuthError.js +0 -7
  78. package/lib/jupyter/Handlers.d.ts +0 -8
  79. package/lib/jupyter/Handlers.js +0 -49
  80. package/lib/jupyter/Jupyter.d.ts +0 -23
  81. package/lib/jupyter/Jupyter.js +0 -34
  82. package/lib/jupyter/JupyterConfig.d.ts +0 -37
  83. package/lib/jupyter/JupyterConfig.js +0 -58
  84. package/lib/jupyter/JupyterContext.d.ts +0 -35
  85. package/lib/jupyter/JupyterContext.js +0 -63
  86. package/lib/jupyter/ipywidgets/IPyWidgetsAttached.d.ts +0 -8
  87. package/lib/jupyter/ipywidgets/IPyWidgetsAttached.js +0 -14
  88. package/lib/jupyter/ipywidgets/IPyWidgetsClassicManager.d.ts +0 -18
  89. package/lib/jupyter/ipywidgets/IPyWidgetsClassicManager.js +0 -75
  90. package/lib/jupyter/ipywidgets/IPyWidgetsJupyterLabPlugin.d.ts +0 -15
  91. package/lib/jupyter/ipywidgets/IPyWidgetsJupyterLabPlugin.js +0 -177
  92. package/lib/jupyter/ipywidgets/IpyWidgetsManager.d.ts +0 -11
  93. package/lib/jupyter/ipywidgets/IpyWidgetsManager.js +0 -70
  94. package/lib/jupyter/ipywidgets/plotly/Figure.d.ts +0 -587
  95. package/lib/jupyter/ipywidgets/plotly/Figure.js +0 -1696
  96. package/lib/jupyter/ipywidgets/plotly/JupyterlabPlugin.d.ts +0 -5
  97. package/lib/jupyter/ipywidgets/plotly/JupyterlabPlugin.js +0 -11
  98. package/lib/jupyter/ipywidgets/plotly/Version.d.ts +0 -8
  99. package/lib/jupyter/ipywidgets/plotly/Version.js +0 -15
  100. package/lib/jupyter/ipywidgets/plotly/index.d.ts +0 -2
  101. package/lib/jupyter/ipywidgets/plotly/index.js +0 -3
  102. package/lib/jupyter/lumino/LuminoAttached.d.ts +0 -9
  103. package/lib/jupyter/lumino/LuminoAttached.js +0 -22
  104. package/lib/jupyter/lumino/LuminoDetached.d.ts +0 -9
  105. package/lib/jupyter/lumino/LuminoDetached.js +0 -12
  106. package/lib/jupyter/lumino/LuminoObservable.d.ts +0 -6
  107. package/lib/jupyter/lumino/LuminoObservable.js +0 -15
  108. package/lib/jupyter/lumino/LuminoReactPortal.d.ts +0 -180
  109. package/lib/jupyter/lumino/LuminoReactPortal.js +0 -194
  110. package/lib/jupyter/lumino/LuminoRedux.d.ts +0 -8
  111. package/lib/jupyter/lumino/LuminoRedux.js +0 -1
  112. package/lib/jupyter/services/Services.d.ts +0 -16
  113. package/lib/jupyter/services/Services.js +0 -40
  114. package/lib/jupyter/services/kernel/Kernel.d.ts +0 -15
  115. package/lib/jupyter/services/kernel/Kernel.js +0 -64
  116. package/lib/jupyter/services/kernel/KernelModel.d.ts +0 -18
  117. package/lib/jupyter/services/kernel/KernelModel.js +0 -51
  118. package/lib/state/State.d.ts +0 -14
  119. package/lib/state/State.js +0 -31
  120. package/lib/state/Store.d.ts +0 -4
  121. package/lib/state/Store.js +0 -38
  122. package/lib/state/init/Init.d.ts +0 -3
  123. package/lib/state/init/Init.js +0 -11
  124. package/lib/state/init/InitState.d.ts +0 -19
  125. package/lib/state/init/InitState.js +0 -47
@@ -1,15 +0,0 @@
1
- export declare type IConsole = number;
2
- export interface IConsoleState {
3
- outputs: IConsole;
4
- }
5
- export declare const consoleInitialState: IConsoleState;
6
- export declare const selectConsole: () => IConsoleState;
7
- export declare enum ActionType {
8
- OUTPUTS = "console/OUTPUTS",
9
- EXECUTE = "console/EXECUTE"
10
- }
11
- export declare const consoleActions: {
12
- outputs: import("typescript-fsa").ActionCreator<number>;
13
- execute: import("typescript-fsa").ActionCreator<void>;
14
- };
15
- export declare const consoleReducer: import("typescript-fsa-reducers").ReducerBuilder<IConsoleState, IConsoleState>;
@@ -1,29 +0,0 @@
1
- import { useSelector } from "react-redux";
2
- import { reducerWithInitialState } from "typescript-fsa-reducers";
3
- export const consoleInitialState = {
4
- outputs: 0
5
- };
6
- /* Selectors */
7
- export const selectConsole = () => useSelector((state) => {
8
- if (state.console) {
9
- return state.console;
10
- }
11
- return { outputs: 0 };
12
- });
13
- /* Actions */
14
- import actionCreatorFactory from "typescript-fsa";
15
- export var ActionType;
16
- (function (ActionType) {
17
- ActionType["OUTPUTS"] = "console/OUTPUTS";
18
- ActionType["EXECUTE"] = "console/EXECUTE";
19
- })(ActionType || (ActionType = {}));
20
- const actionCreator = actionCreatorFactory('jupyterReact');
21
- export const consoleActions = {
22
- outputs: actionCreator(ActionType.OUTPUTS),
23
- execute: actionCreator(ActionType.EXECUTE),
24
- };
25
- /* Reducers */
26
- export const consoleReducer = reducerWithInitialState(consoleInitialState)
27
- .case(consoleActions.outputs, (state, success) => {
28
- return Object.assign(Object.assign({}, state), { outputs: success });
29
- });
@@ -1,2 +0,0 @@
1
- declare const Dialog: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
- export default Dialog;
@@ -1,12 +0,0 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- import { useState, useEffect } from 'react';
3
- import LuminoDetached from '../../jupyter/lumino/LuminoDetached';
4
- import DialogAdapter from './DialogAdapter';
5
- const Dialog = () => {
6
- const [dialogAdapter, _] = useState(new DialogAdapter());
7
- useEffect(() => {
8
- dialogAdapter.dialog.launch().then(success => success);
9
- }, []);
10
- return _jsx(LuminoDetached, { children: dialogAdapter.dialog }, void 0);
11
- };
12
- export default Dialog;
@@ -1,10 +0,0 @@
1
- import { Dialog as JupyerLabDialog } from '@jupyterlab/apputils';
2
- import '@jupyterlab/apputils/style/index.css';
3
- import '@jupyterlab/theme-light-extension/style/theme.css';
4
- import '@jupyterlab/theme-light-extension/style/variables.css';
5
- import './DialogAdapter.css';
6
- export declare class DialogAdapter {
7
- dialog: JupyerLabDialog<any>;
8
- constructor();
9
- }
10
- export default DialogAdapter;
@@ -1,18 +0,0 @@
1
- import { Dialog as JupyerLabDialog } from '@jupyterlab/apputils';
2
- import '@jupyterlab/apputils/style/index.css';
3
- import '@jupyterlab/theme-light-extension/style/theme.css';
4
- import '@jupyterlab/theme-light-extension/style/variables.css';
5
- import './DialogAdapter.css';
6
- export class DialogAdapter {
7
- constructor() {
8
- this.dialog = new JupyerLabDialog({
9
- title: 'Dialog Title',
10
- body: 'This is the body of the dialog...',
11
- buttons: [
12
- JupyerLabDialog.cancelButton(),
13
- JupyerLabDialog.okButton(),
14
- ]
15
- });
16
- }
17
- }
18
- export default DialogAdapter;
@@ -1,7 +0,0 @@
1
- import OutputAdapter from '../outputs/OutputAdapter';
2
- declare const CodeMirrorEditor: (props: {
3
- code: string;
4
- outputAdapter: OutputAdapter;
5
- autoRun: boolean;
6
- }) => import("@emotion/react/jsx-runtime").JSX.Element;
7
- export default CodeMirrorEditor;
@@ -1,61 +0,0 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- import { useRef, useEffect } from 'react';
3
- import { basicSetup } from '@codemirror/basic-setup';
4
- import { EditorState } from '@codemirror/state';
5
- import { keymap, EditorView } from '@codemirror/view';
6
- import { python } from '@codemirror/lang-python';
7
- const CodeMirrorEditor = (props) => {
8
- const { code, outputAdapter, autoRun } = props;
9
- const editor = useRef();
10
- useEffect(() => {
11
- let state;
12
- const keyBinding = [
13
- { key: 'Shift-Enter', run: () => runCode(), preventDefault: true },
14
- ];
15
- state = EditorState.create({
16
- doc: code,
17
- extensions: [basicSetup, python(), keymap.of([...keyBinding])],
18
- });
19
- const view = new EditorView({
20
- state: state,
21
- parent: editor.current,
22
- });
23
- const runCode = () => {
24
- outputAdapter.execute(String(view.state.doc));
25
- return true;
26
- };
27
- if (autoRun) {
28
- runCode();
29
- }
30
- return () => {
31
- view.destroy();
32
- };
33
- }, []);
34
- return _jsx("div", { ref: editor }, void 0);
35
- /*
36
- return <div ref={ref => {
37
- if (ref) {
38
- const kb = [{key: "Shift-Enter", run: () => runCode(), preventDefault: true}];
39
- let state = EditorState.create({
40
- doc: code,
41
- extensions: [
42
- basicSetup,
43
- javascript(),
44
- keymap.of([...kb]),
45
- ]
46
- });
47
- const view = new EditorView({
48
- state: state,
49
- parent: ref,
50
- });
51
- const runCode = () => {
52
- Output.execute(String(view.state.doc));
53
- return true;
54
- };
55
- runCode();
56
- };
57
- return <div ref={ref as any}></div>
58
- }}/>;
59
- */
60
- };
61
- export default CodeMirrorEditor;
@@ -1,2 +0,0 @@
1
- declare const FileBrowser: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
- export default FileBrowser;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- import FileBrowserAdapter from './FileBrowserAdapter';
3
- import LuminoAttached from '../../jupyter/lumino/LuminoAttached';
4
- const FileBrowser = () => {
5
- const fileBrowserAdpater = new FileBrowserAdapter();
6
- return _jsx(LuminoAttached, { children: fileBrowserAdpater.panel }, void 0);
7
- };
8
- export default FileBrowser;
@@ -1,13 +0,0 @@
1
- import { SplitPanel } from '@lumino/widgets';
2
- import '@jupyterlab/codemirror/style/index.css';
3
- import '@jupyterlab/filebrowser/style/index.css';
4
- import '@jupyterlab/ui-components/style/index.css';
5
- import '@jupyterlab/theme-light-extension/style/theme.css';
6
- import '@jupyterlab/theme-light-extension/style/variables.css';
7
- import './FileBrowserAdapter.css';
8
- declare class FileBrowserAdapter {
9
- private fileBrowserPanel;
10
- constructor();
11
- get panel(): SplitPanel;
12
- }
13
- export default FileBrowserAdapter;
@@ -1,266 +0,0 @@
1
- import { CommandRegistry } from '@lumino/commands';
2
- import { each } from '@lumino/algorithm';
3
- import { DockPanel, Menu, SplitPanel } from '@lumino/widgets';
4
- import { ServiceManager } from '@jupyterlab/services';
5
- import { Dialog, ToolbarButton, showDialog } from '@jupyterlab/apputils';
6
- import { CodeMirrorEditorFactory, CodeMirrorMimeTypeService } from '@jupyterlab/codemirror';
7
- import { DocumentManager } from '@jupyterlab/docmanager';
8
- import { DocumentRegistry } from '@jupyterlab/docregistry';
9
- import { FileBrowser, FilterFileBrowserModel } from '@jupyterlab/filebrowser';
10
- import { FileEditorFactory } from '@jupyterlab/fileeditor';
11
- import { addIcon } from '@jupyterlab/ui-components';
12
- import '@jupyterlab/codemirror/style/index.css';
13
- import '@jupyterlab/filebrowser/style/index.css';
14
- import '@jupyterlab/ui-components/style/index.css';
15
- import '@jupyterlab/theme-light-extension/style/theme.css';
16
- import '@jupyterlab/theme-light-extension/style/variables.css';
17
- import './FileBrowserAdapter.css';
18
- class FileBrowserAdapter {
19
- constructor() {
20
- this.fileBrowserPanel = new SplitPanel();
21
- this.fileBrowserPanel.id = 'dla-jlab-filebrowser';
22
- this.fileBrowserPanel.orientation = 'horizontal';
23
- this.fileBrowserPanel.spacing = 0;
24
- const manager = new ServiceManager();
25
- void manager.ready.then(() => {
26
- createApp(manager, this.fileBrowserPanel);
27
- });
28
- function createApp(manager, panel) {
29
- const widgets = [];
30
- let activeWidget;
31
- const opener = {
32
- open: (widget) => {
33
- if (widgets.indexOf(widget) === -1) {
34
- dock.addWidget(widget, { mode: 'tab-after' });
35
- widgets.push(widget);
36
- }
37
- dock.activateWidget(widget);
38
- activeWidget = widget;
39
- widget.disposed.connect((w) => {
40
- const index = widgets.indexOf(w);
41
- widgets.splice(index, 1);
42
- });
43
- }
44
- };
45
- const docRegistry = new DocumentRegistry();
46
- const docManager = new DocumentManager({
47
- registry: docRegistry,
48
- manager,
49
- opener
50
- });
51
- const editorServices = {
52
- factoryService: new CodeMirrorEditorFactory(),
53
- mimeTypeService: new CodeMirrorMimeTypeService()
54
- };
55
- const wFactory = new FileEditorFactory({
56
- editorServices,
57
- factoryOptions: {
58
- name: 'Editor',
59
- modelName: 'text',
60
- fileTypes: ['*'],
61
- defaultFor: ['*'],
62
- preferKernel: false,
63
- canStartKernel: true
64
- }
65
- });
66
- docRegistry.addWidgetFactory(wFactory);
67
- const commands = new CommandRegistry();
68
- const fbModel = new FilterFileBrowserModel({
69
- manager: docManager
70
- });
71
- const fbWidget = new FileBrowser({
72
- id: 'filebrowser',
73
- model: fbModel
74
- });
75
- // Add a creator toolbar item.
76
- const creator = new ToolbarButton({
77
- icon: addIcon,
78
- onClick: () => {
79
- void docManager
80
- .newUntitled({
81
- type: 'file',
82
- path: fbModel.path
83
- })
84
- .then(model => {
85
- docManager.open(model.path);
86
- });
87
- }
88
- });
89
- fbWidget.toolbar.insertItem(0, 'create', creator);
90
- panel.addWidget(fbWidget);
91
- SplitPanel.setStretch(fbWidget, 0);
92
- const dock = new DockPanel();
93
- panel.addWidget(dock);
94
- SplitPanel.setStretch(dock, 1);
95
- dock.spacing = 8;
96
- document.addEventListener('focus', event => {
97
- for (let i = 0; i < widgets.length; i++) {
98
- const widget = widgets[i];
99
- if (widget.node.contains(event.target)) {
100
- activeWidget = widget;
101
- break;
102
- }
103
- }
104
- });
105
- // Add commands.
106
- commands.addCommand('file-open', {
107
- label: 'Open',
108
- icon: 'fa fa-folder-open-o',
109
- mnemonic: 0,
110
- execute: () => {
111
- each(fbWidget.selectedItems(), item => {
112
- docManager.openOrReveal(item.path);
113
- });
114
- }
115
- });
116
- commands.addCommand('file-rename', {
117
- label: 'Rename',
118
- icon: 'fa fa-edit',
119
- mnemonic: 0,
120
- execute: () => {
121
- return fbWidget.rename();
122
- }
123
- });
124
- commands.addCommand('file-save', {
125
- execute: () => {
126
- const context = docManager.contextForWidget(activeWidget);
127
- return context === null || context === void 0 ? void 0 : context.save();
128
- }
129
- });
130
- commands.addCommand('file-cut', {
131
- label: 'Cut',
132
- icon: 'fa fa-cut',
133
- execute: () => {
134
- fbWidget.cut();
135
- }
136
- });
137
- commands.addCommand('file-copy', {
138
- label: 'Copy',
139
- icon: 'fa fa-copy',
140
- mnemonic: 0,
141
- execute: () => {
142
- fbWidget.copy();
143
- }
144
- });
145
- commands.addCommand('file-delete', {
146
- label: 'Delete',
147
- icon: 'fa fa-remove',
148
- mnemonic: 0,
149
- execute: () => {
150
- return fbWidget.delete();
151
- }
152
- });
153
- commands.addCommand('file-duplicate', {
154
- label: 'Duplicate',
155
- icon: 'fa fa-copy',
156
- mnemonic: 0,
157
- execute: () => {
158
- return fbWidget.duplicate();
159
- }
160
- });
161
- commands.addCommand('file-paste', {
162
- label: 'Paste',
163
- icon: 'fa fa-paste',
164
- mnemonic: 0,
165
- execute: () => {
166
- return fbWidget.paste();
167
- }
168
- });
169
- commands.addCommand('file-download', {
170
- label: 'Download',
171
- icon: 'fa fa-download',
172
- execute: () => {
173
- return fbWidget.download();
174
- }
175
- });
176
- commands.addCommand('file-shutdown-kernel', {
177
- label: 'Shut Down Kernel',
178
- icon: 'fa fa-stop-circle-o',
179
- execute: () => {
180
- return fbWidget.shutdownKernels();
181
- }
182
- });
183
- commands.addCommand('file-dialog-demo', {
184
- label: 'Dialog Demo',
185
- execute: () => {
186
- dialogDemo();
187
- }
188
- });
189
- commands.addCommand('file-info-demo', {
190
- label: 'Info Demo',
191
- execute: () => {
192
- const msg = 'The quick brown fox jumped over the lazy dog';
193
- void showDialog({
194
- title: 'Cool Title',
195
- body: msg,
196
- buttons: [Dialog.okButton()]
197
- });
198
- }
199
- });
200
- commands.addKeyBinding({
201
- keys: ['Enter'],
202
- selector: '.jp-DirListing',
203
- command: 'file-open'
204
- });
205
- commands.addKeyBinding({
206
- keys: ['Accel S'],
207
- selector: '.jp-CodeMirrorEditor',
208
- command: 'file-save'
209
- });
210
- window.addEventListener('keydown', event => {
211
- commands.processKeydownEvent(event);
212
- });
213
- // Create a context menu.
214
- const menu = new Menu({ commands });
215
- menu.addItem({ command: 'file-open' });
216
- menu.addItem({ command: 'file-rename' });
217
- menu.addItem({ command: 'file-remove' });
218
- menu.addItem({ command: 'file-duplicate' });
219
- menu.addItem({ command: 'file-delete' });
220
- menu.addItem({ command: 'file-cut' });
221
- menu.addItem({ command: 'file-copy' });
222
- menu.addItem({ command: 'file-paste' });
223
- menu.addItem({ command: 'file-shutdown-kernel' });
224
- menu.addItem({ command: 'file-dialog-demo' });
225
- menu.addItem({ command: 'file-info-demo' });
226
- // Add a context menu to the dir listing.
227
- const node = fbWidget.node.getElementsByClassName('jp-DirListing-content')[0];
228
- node.addEventListener('contextmenu', (event) => {
229
- event.preventDefault();
230
- const x = event.clientX;
231
- const y = event.clientY;
232
- menu.open(x, y);
233
- });
234
- // Handle resize events.
235
- window.addEventListener('resize', () => {
236
- panel.update();
237
- });
238
- }
239
- /**
240
- * Create a non-functional dialog demo.
241
- */
242
- function dialogDemo() {
243
- const body = document.createElement('div');
244
- const input = document.createElement('input');
245
- input.value = 'Untitled.ipynb';
246
- const selector = document.createElement('select');
247
- const option0 = document.createElement('option');
248
- option0.value = 'python';
249
- option0.text = 'Python 3';
250
- selector.appendChild(option0);
251
- const option1 = document.createElement('option');
252
- option1.value = 'julia';
253
- option1.text = 'Julia';
254
- selector.appendChild(option1);
255
- body.appendChild(input);
256
- body.appendChild(selector);
257
- void showDialog({
258
- title: 'Create new notebook'
259
- });
260
- }
261
- }
262
- get panel() {
263
- return this.fileBrowserPanel;
264
- }
265
- }
266
- export default FileBrowserAdapter;
@@ -1,15 +0,0 @@
1
- export declare type IFileBrowser = number;
2
- export interface IFileBrowserState {
3
- outputs: IFileBrowser;
4
- }
5
- export declare const fileBrowserInitialState: IFileBrowserState;
6
- export declare const selectFileBrowser: () => IFileBrowserState;
7
- export declare enum ActionType {
8
- OUTPUTS = "fileBrowser/OUTPUTS",
9
- EXECUTE = "fileBrowser/EXECUTE"
10
- }
11
- export declare const fileBrowserActions: {
12
- outputs: import("typescript-fsa").ActionCreator<number>;
13
- execute: import("typescript-fsa").ActionCreator<void>;
14
- };
15
- export declare const fileBrowserReducer: import("typescript-fsa-reducers").ReducerBuilder<IFileBrowserState, IFileBrowserState>;
@@ -1,29 +0,0 @@
1
- import actionCreatorFactory from "typescript-fsa";
2
- import { useSelector } from "react-redux";
3
- import { reducerWithInitialState } from "typescript-fsa-reducers";
4
- export const fileBrowserInitialState = {
5
- outputs: 0
6
- };
7
- /* Selectors */
8
- export const selectFileBrowser = () => useSelector((state) => {
9
- if (state.fileBrowser) {
10
- return state.fileBrowser;
11
- }
12
- return { outputs: 0 };
13
- });
14
- /* Actions */
15
- export var ActionType;
16
- (function (ActionType) {
17
- ActionType["OUTPUTS"] = "fileBrowser/OUTPUTS";
18
- ActionType["EXECUTE"] = "fileBrowser/EXECUTE";
19
- })(ActionType || (ActionType = {}));
20
- const actionCreator = actionCreatorFactory('jupyterReact');
21
- export const fileBrowserActions = {
22
- outputs: actionCreator(ActionType.OUTPUTS),
23
- execute: actionCreator(ActionType.EXECUTE),
24
- };
25
- /* Reducers */
26
- export const fileBrowserReducer = reducerWithInitialState(fileBrowserInitialState)
27
- .case(fileBrowserActions.outputs, (state, success) => {
28
- return Object.assign(Object.assign({}, state), { outputs: success });
29
- });
@@ -1,2 +0,0 @@
1
- declare const FileBrowserTree: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
- export default FileBrowserTree;
@@ -1,59 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
- import { useState, useEffect, useReducer } from 'react';
3
- import TreeView from '@mui/lab/TreeView';
4
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
5
- import ChevronRightIcon from '@mui/icons-material/ChevronRight';
6
- import TreeItem from '@mui/lab/TreeItem';
7
- import Services from '../../jupyter/services/Services';
8
- const initialTree = {
9
- id: 'root',
10
- name: 'Jupyter Content',
11
- };
12
- const FileBrowserTree = () => {
13
- const [tree, setTree] = useState(initialTree);
14
- const [, forceUpdate] = useReducer(x => x + 1, 0);
15
- const [services, _] = useState(new Services());
16
- const loadPath = (subTree, path) => {
17
- const loadFolderItems = (path) => {
18
- const folderItems = services.contents().get(path.join('/')).then(res => {
19
- const items = res.content.map((e) => {
20
- if (e.type === 'directory') {
21
- return {
22
- id: 'folder_' + e.name,
23
- name: e.name,
24
- children: new Array(),
25
- };
26
- }
27
- else {
28
- return {
29
- id: 'file_' + e.name,
30
- name: e.name,
31
- };
32
- }
33
- });
34
- return items;
35
- });
36
- return folderItems;
37
- };
38
- loadFolderItems(path).then(folderItems => {
39
- subTree.children = folderItems;
40
- for (const child of subTree.children) {
41
- if (child.id.startsWith('folder_')) {
42
- loadPath(child, path.concat(child.name));
43
- }
44
- }
45
- setTree(initialTree);
46
- forceUpdate();
47
- });
48
- };
49
- useEffect(() => {
50
- loadPath(initialTree, []);
51
- }, []);
52
- const renderTree = (nodes) => {
53
- return _jsx(TreeItem, Object.assign({ nodeId: nodes.id, label: nodes.name }, { children: Array.isArray(nodes.children)
54
- ? nodes.children.map(node => renderTree(node))
55
- : null }), nodes.id);
56
- };
57
- return (_jsx(_Fragment, { children: _jsx(TreeView, Object.assign({ "aria-label": "rich object", defaultCollapseIcon: _jsx(ExpandMoreIcon, {}, void 0), defaultExpanded: ['root'], defaultExpandIcon: _jsx(ChevronRightIcon, {}, void 0), sx: { height: 210, flexGrow: 1, maxWidth: 400, overflowY: 'auto' } }, { children: renderTree(tree) }), void 0) }, void 0));
58
- };
59
- export default FileBrowserTree;
@@ -1,5 +0,0 @@
1
- import './IpyWidgetsComponent.css';
2
- declare const IpyWidgetsComponent: (props: {
3
- widget: any;
4
- }) => import("@emotion/react/jsx-runtime").JSX.Element;
5
- export default IpyWidgetsComponent;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
- import IPyWidgetsAttached from '../../jupyter/ipywidgets/IPyWidgetsAttached';
3
- import './IpyWidgetsComponent.css';
4
- const IpyWidgetsComponent = (props) => {
5
- const { widget } = props;
6
- return _jsx(_Fragment, { children: _jsx(IPyWidgetsAttached, { widget: widget }, void 0) }, void 0);
7
- };
8
- export default IpyWidgetsComponent;
@@ -1,25 +0,0 @@
1
- /// <reference types="react" />
2
- import '@jupyterlab/completer/style/index.css';
3
- import '@jupyterlab/documentsearch/style/index.css';
4
- import '@jupyterlab/notebook/style/index.css';
5
- import '@jupyterlab/theme-light-extension/style/theme.css';
6
- import '@jupyterlab/theme-light-extension/style/variables.css';
7
- import './Notebook.css';
8
- export declare type INotebookProps = {
9
- path: string;
10
- ipywidgets?: 'classic' | 'lab';
11
- sidebarMargin: number;
12
- sidebarComponent?: (props: any) => JSX.Element;
13
- };
14
- /**
15
- * This component creates a Notebook as a collection
16
- * of cells with sidebars.
17
- *
18
- * @param props The notebook properties.
19
- * @returns A Notebook component.
20
- */
21
- export declare const Notebook: {
22
- (props: INotebookProps): import("@emotion/react/jsx-runtime").JSX.Element;
23
- defaultProps: Partial<INotebookProps>;
24
- };
25
- export default Notebook;