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 text-based filtering via a built-in context menu and filter
11//! prompt.
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//! [`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 format;
53pub mod grid;
54
55pub use config::{
56 BooleanFormat, ColumnOverride, DateFormat, GridConfig, KeyBinding, KeyBindings, NumberFormat,
57 RelativeDateFormat, RelativeUnit, ReplacementRule, ReplacementTiming, ResolvedColumnFormat,
58 StringFormat, TextAlignment, TextCase, TruncationBehavior,
59};
60pub use data::{
61 compare_cells, sample_data, CellValue, Column, ColumnKind, GridData, GridDataError,
62};
63pub use grid::{
64 ContextMenu, GridState, GridTheme, HitResult, MenuAction, MenuItem, ScrollbarAxis, Selection,
65 SortDirection, SqllyDataTable, SqllyDataTableBuilder,
66};