Commit 734302a
refactor: rewrite interactive table widget in Angular (#17416)
This PR rewrites the frontend implementation of the interactive
`TableWidget` in Angular, replacing the legacy vanilla JS version
(`table_widget.js`). This enables more structured state management and
paves the way for future UI improvements.
### Key Changes:
1. **Angular Frontend Rewrite**:
- Created a new Angular application workspace under
`bigframes/display/table_widget_angular`.
- Introduced `WidgetStateService` to manage the widget's internal state
(pages, sorting, column visibility) and synchronize updates with the
Python `anywidget` model.
- Rewrote the template, CSS variables (including VS Code dark mode
support), pagination controls, and column sorting handlers as Angular
components.
- Compiled and bundled the Angular workspace into the single
distribution file `table_widget_angular.js`, which is now loaded by the
Python class.
2. **Backend Refactoring**:
- Renamed `DataFrame._get_display_df` to `_process_display_df` and
refactored it to return both the processed display DataFrame and its
metadata.
- Updated `html.py` to standardize representation rendering pipelines,
enabling native rendering support for both `DataFrame` and `Series`
objects.
3. **Robust Multi-Instance Bootstrapping**:
- Configured the Angular bootstrap sequence to use `createApplication()`
and manually attach each component instance to its local widget
container (`el`). This prevents rendering conflicts and state bleeding
when rendering multiple widgets on the same notebook page.
4. **Testing**:
- Added a frontend test suite (`tests/js/table_widget_angular.test.js`)
to assert that multiple Angular widgets can bootstrap and render
distinct model configurations concurrently.
- Updated Python backend unit tests under `tests/unit/display/` to
conform to the new `_process_display_df` interface.
Verified at: go/scrcast/NTkzNjEzNzYyNDM1NDgxNnw4NTI0NjA5My1iMA
screen/4NJKSkYEjoYjpxA
Fixes #<505414691> 🦕
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent b254faf commit 734302a
15 files changed
Lines changed: 4922 additions & 2490 deletions
File tree
- packages/bigframes
- bigframes
- display
- table_widget_angular
- src
- app
- notebooks/dataframes
- tests
- js
- unit/display
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
819 | 819 | | |
820 | 820 | | |
821 | 821 | | |
822 | | - | |
| 822 | + | |
823 | 823 | | |
824 | 824 | | |
825 | 825 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
179 | | - | |
| 178 | + | |
| 179 | + | |
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
192 | 191 | | |
193 | 192 | | |
194 | 193 | | |
| 194 | + | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | | - | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
216 | 217 | | |
217 | 218 | | |
218 | 219 | | |
219 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
| |||
233 | 236 | | |
234 | 237 | | |
235 | 238 | | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
239 | 248 | | |
240 | 249 | | |
241 | 250 | | |
| |||
283 | 292 | | |
284 | 293 | | |
285 | 294 | | |
| 295 | + | |
| 296 | + | |
286 | 297 | | |
287 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
288 | 304 | | |
289 | 305 | | |
290 | 306 | | |
| |||
0 commit comments