sqlly_datatable/lib.rs
1//! Configurable virtualized data grid for the [GPUI] toolkit.
2//!
3//! `sqlly-datatable` provides a self-contained `Entity<GridState>` widget that
4//! you can drop into a GPUI application. It supports:
5//!
6//! * Virtualized rendering for large datasets.
7//! * Cell, row, column and rectangular drag selection.
8//! * Sorting on column headers, with a cycle through ascending, descending,
9//! and unsorted.
10//! * Per-column filtering via a rich filter panel (operator predicates,
11//! value checklist, search) opened from the built-in context menu.
12//! * Configurable column resizing, mouse-driven scrollbars, and edge-scroll
13//! during drag selection.
14//! * Clipboard copy of any selection (with or without headers).
15//!
16//! The crate is intentionally GPUI-only on the UI side; the pure formatter in
17//! [`mod@format`] is usable in any context (export pipelines, server-side preview,
18//! etc.). All formatting is configurable per column by composing the
19//! [`config::GridConfig`] defaults with [`config::ColumnOverride`] entries.
20//!
21//! # Quick start
22//!
23//! ```no_run
24//! use gpui::App;
25//! use sqlly_datatable::{
26//! CellValue, Column, ColumnKind, GridConfig, GridData, SqllyDataTable,
27//! };
28//!
29//! let data = GridData::new(
30//! vec![Column { name: "id".into(), kind: ColumnKind::Integer, width: 80.0 }],
31//! vec![vec![CellValue::Integer(1)], vec![CellValue::Integer(2)]],
32//! ).expect("rectangular data");
33//! let app = gpui::Application::new();
34//! app.run(|cx: &mut App| {
35//! let _view = SqllyDataTable::builder(data)
36//! .config(GridConfig::default())
37//! .build(cx);
38//! });
39//! ```
40//!
41//! See `crates/sqlly-datatable-sample` for a runnable demo.
42//!
43//! [GPUI]: https://github.com/zed-industries/gpui
44
45// `missing_docs` is intentionally not enabled at the crate level. The public
46// surfaces documented here are stable; private internals will get docs as the
47// `grid::` modules mature. Run clippy with
48// `#![warn(missing_docs)]` in scope when cleaning up a module.
49
50pub mod config;
51pub mod data;
52pub mod filter;
53pub mod format;
54pub mod grid;
55
56pub use config::{
57 BooleanFormat, ColumnOverride, DateFormat, GridConfig, KeyBinding, KeyBindings, NumberFormat,
58 RelativeDateFormat, RelativeUnit, ReplacementRule, ReplacementTiming, ResolvedColumnFormat,
59 StringFormat, TextAlignment, TextCase, TruncationBehavior,
60};
61pub use data::{
62 compare_cells, sample_data, CellValue, Column, ColumnKind, GridData, GridDataError,
63};
64pub use filter::{ColumnFilter, FilterPredicate, NumberOp, TextOp};
65pub use grid::{
66 BusyState, ContextMenu, ContextMenuItem, ContextMenuProvider, ContextMenuRequest,
67 ContextMenuSelection, ContextMenuTarget, FilterPanel, GridState, GridTheme, HitResult,
68 MenuAction, MenuItem, ScrollbarAxis, SelectedCellContext, SelectedRowContext, Selection,
69 SortDirection, SqllyDataTable, SqllyDataTableBuilder,
70};