jupyterlab_tabular_data_viewer_extension 1.2.33 → 1.2.38

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/lib/index.js CHANGED
@@ -20,6 +20,11 @@ class TabularDataWidgetFactory extends ABCWidgetFactory {
20
20
  const content = new TabularDataViewer(context.path, this._setLastContextMenuRow);
21
21
  const widget = new TabularDataDocument({ content, context });
22
22
  widget.title.label = context.path.split('/').pop() || 'Tabular Data File';
23
+ // Listen to context fileChanged signal to refresh data when file is reverted
24
+ context.fileChanged.connect(() => {
25
+ console.log('[Tabular Data Viewer] File changed, refreshing data');
26
+ content.refresh();
27
+ });
23
28
  // Track this as the active widget when context menu is used
24
29
  this._setActiveWidget(content);
25
30
  return widget;
@@ -63,6 +68,20 @@ const plugin = {
63
68
  console.error('[Tabular Data Viewer] Failed to load settings:', error);
64
69
  // console.log('[Tabular Data Viewer] Using default settings:', settings);
65
70
  }
71
+ // Command to refresh tabular data view
72
+ const refreshCommand = 'tabular-data-viewer:refresh';
73
+ commands.addCommand(refreshCommand, {
74
+ label: 'Refresh Tabular Data',
75
+ caption: 'Refresh the tabular data view from file',
76
+ isEnabled: () => {
77
+ return activeWidget !== null;
78
+ },
79
+ execute: async () => {
80
+ if (activeWidget) {
81
+ await activeWidget.refresh();
82
+ }
83
+ }
84
+ });
66
85
  // Command to copy row as JSON
67
86
  const copyRowCommand = 'tabular-data-viewer:copy-row-json';
68
87
  commands.addCommand(copyRowCommand, {
@@ -85,6 +104,12 @@ const plugin = {
85
104
  }
86
105
  }
87
106
  });
107
+ // Add refresh command to context menu for tabular data viewer
108
+ contextMenu.addItem({
109
+ command: refreshCommand,
110
+ selector: '.jp-TabularDataViewer',
111
+ rank: 0
112
+ });
88
113
  // Add to context menu for tabular data viewer rows
89
114
  contextMenu.addItem({
90
115
  command: copyRowCommand,
package/lib/widget.d.ts CHANGED
@@ -44,6 +44,11 @@ export declare class TabularDataViewer extends Widget {
44
44
  * Get cleanup function to clear highlight (for external use)
45
45
  */
46
46
  getCleanupHighlight(): () => void;
47
+ /**
48
+ * Refresh the data view by reloading from the file
49
+ * Preserves scroll position and current filters/sorting
50
+ */
51
+ refresh(): Promise<void>;
47
52
  /**
48
53
  * Initialize the viewer by loading metadata and initial data
49
54
  */
package/lib/widget.js CHANGED
@@ -201,6 +201,30 @@ export class TabularDataViewer extends Widget {
201
201
  getCleanupHighlight() {
202
202
  return this._cleanupHighlight || (() => { });
203
203
  }
204
+ /**
205
+ * Refresh the data view by reloading from the file
206
+ * Preserves scroll position and current filters/sorting
207
+ */
208
+ async refresh() {
209
+ // Store current scroll position
210
+ const scrollTop = this._tableContainer.scrollTop;
211
+ const scrollLeft = this._tableContainer.scrollLeft;
212
+ try {
213
+ // Reload metadata (in case file structure changed)
214
+ await this._loadMetadata();
215
+ // Reload data with current filters and sorting
216
+ await this._loadData(true);
217
+ // Restore scroll position after a short delay to allow rendering
218
+ setTimeout(() => {
219
+ this._tableContainer.scrollTop = scrollTop;
220
+ this._tableContainer.scrollLeft = scrollLeft;
221
+ }, 100);
222
+ console.log(`Refreshed tabular data view: ${this._filePath}`);
223
+ }
224
+ catch (error) {
225
+ this._showError(`Failed to refresh data: ${error}`);
226
+ }
227
+ }
204
228
  /**
205
229
  * Initialize the viewer by loading metadata and initial data
206
230
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jupyterlab_tabular_data_viewer_extension",
3
- "version": "1.2.33",
3
+ "version": "1.2.38",
4
4
  "description": "Jupyterlab extension to browse tabular data files (Parquet, Excel, CSV, TSV) with filtering and sorting capabilities",
5
5
  "keywords": [
6
6
  "jupyter",
package/src/index.ts CHANGED
@@ -46,6 +46,12 @@ class TabularDataWidgetFactory extends ABCWidgetFactory<
46
46
  const widget = new TabularDataDocument({ content, context });
47
47
  widget.title.label = context.path.split('/').pop() || 'Tabular Data File';
48
48
 
49
+ // Listen to context fileChanged signal to refresh data when file is reverted
50
+ context.fileChanged.connect(() => {
51
+ console.log('[Tabular Data Viewer] File changed, refreshing data');
52
+ content.refresh();
53
+ });
54
+
49
55
  // Track this as the active widget when context menu is used
50
56
  this._setActiveWidget(content);
51
57
 
@@ -110,6 +116,21 @@ const plugin: JupyterFrontEndPlugin<void> = {
110
116
  // console.log('[Tabular Data Viewer] Using default settings:', settings);
111
117
  }
112
118
 
119
+ // Command to refresh tabular data view
120
+ const refreshCommand = 'tabular-data-viewer:refresh';
121
+ commands.addCommand(refreshCommand, {
122
+ label: 'Refresh Tabular Data',
123
+ caption: 'Refresh the tabular data view from file',
124
+ isEnabled: () => {
125
+ return activeWidget !== null;
126
+ },
127
+ execute: async () => {
128
+ if (activeWidget) {
129
+ await activeWidget.refresh();
130
+ }
131
+ }
132
+ });
133
+
113
134
  // Command to copy row as JSON
114
135
  const copyRowCommand = 'tabular-data-viewer:copy-row-json';
115
136
  commands.addCommand(copyRowCommand, {
@@ -134,6 +155,13 @@ const plugin: JupyterFrontEndPlugin<void> = {
134
155
  }
135
156
  });
136
157
 
158
+ // Add refresh command to context menu for tabular data viewer
159
+ contextMenu.addItem({
160
+ command: refreshCommand,
161
+ selector: '.jp-TabularDataViewer',
162
+ rank: 0
163
+ });
164
+
137
165
  // Add to context menu for tabular data viewer rows
138
166
  contextMenu.addItem({
139
167
  command: copyRowCommand,
package/src/widget.ts CHANGED
@@ -222,6 +222,34 @@ export class TabularDataViewer extends Widget {
222
222
  return this._cleanupHighlight || (() => {});
223
223
  }
224
224
 
225
+ /**
226
+ * Refresh the data view by reloading from the file
227
+ * Preserves scroll position and current filters/sorting
228
+ */
229
+ public async refresh(): Promise<void> {
230
+ // Store current scroll position
231
+ const scrollTop = this._tableContainer.scrollTop;
232
+ const scrollLeft = this._tableContainer.scrollLeft;
233
+
234
+ try {
235
+ // Reload metadata (in case file structure changed)
236
+ await this._loadMetadata();
237
+
238
+ // Reload data with current filters and sorting
239
+ await this._loadData(true);
240
+
241
+ // Restore scroll position after a short delay to allow rendering
242
+ setTimeout(() => {
243
+ this._tableContainer.scrollTop = scrollTop;
244
+ this._tableContainer.scrollLeft = scrollLeft;
245
+ }, 100);
246
+
247
+ console.log(`Refreshed tabular data view: ${this._filePath}`);
248
+ } catch (error) {
249
+ this._showError(`Failed to refresh data: ${error}`);
250
+ }
251
+ }
252
+
225
253
  /**
226
254
  * Initialize the viewer by loading metadata and initial data
227
255
  */
package/style/base.css CHANGED
@@ -124,9 +124,13 @@
124
124
  }
125
125
 
126
126
  .jp-TabularDataViewer-sortIndicator {
127
- margin-left: 4px;
127
+ position: absolute;
128
+ right: 8px;
129
+ bottom: 4px;
128
130
  color: var(--jp-brand-color1);
129
- font-size: var(--jp-ui-font-size0);
131
+ font-size: 16px;
132
+ font-weight: bold;
133
+ line-height: 1;
130
134
  }
131
135
 
132
136
  /* Column Resize Handle */