chore: Update List, Tree, Kbd exports. (#1467)
## Break Change - Removed `Kbd` from root export, use `gpui_component::kbd::Kbd` instead. - Removed `List` from root export, use `gpui_component::list::*` instead. - Removed `Tree` from root export, use `gpui_component::tree:*` instead.
This commit is contained in:
parent
ed11282782
commit
e75c37a1ac
14 changed files with 33 additions and 260 deletions
|
|
@ -10,7 +10,7 @@ use std::{
|
||||||
use autocorrect::ignorer::Ignorer;
|
use autocorrect::ignorer::Ignorer;
|
||||||
use gpui::{prelude::FluentBuilder, *};
|
use gpui::{prelude::FluentBuilder, *};
|
||||||
use gpui_component::{
|
use gpui_component::{
|
||||||
ActiveTheme, ContextModal, IconName, ListItem, Sizable, TreeItem, TreeState,
|
ActiveTheme, ContextModal, IconName, Sizable,
|
||||||
button::{Button, ButtonVariants as _},
|
button::{Button, ButtonVariants as _},
|
||||||
h_flex,
|
h_flex,
|
||||||
highlighter::{Diagnostic, DiagnosticSeverity, Language, LanguageConfig, LanguageRegistry},
|
highlighter::{Diagnostic, DiagnosticSeverity, Language, LanguageConfig, LanguageRegistry},
|
||||||
|
|
@ -18,8 +18,10 @@ use gpui_component::{
|
||||||
self, CodeActionProvider, CompletionProvider, DefinitionProvider, DocumentColorProvider,
|
self, CodeActionProvider, CompletionProvider, DefinitionProvider, DocumentColorProvider,
|
||||||
HoverProvider, Input, InputEvent, InputState, Position, Rope, RopeExt, TabSize,
|
HoverProvider, Input, InputEvent, InputState, Position, Rope, RopeExt, TabSize,
|
||||||
},
|
},
|
||||||
|
list::ListItem,
|
||||||
resizable::{h_resizable, resizable_panel},
|
resizable::{h_resizable, resizable_panel},
|
||||||
tree, v_flex,
|
tree::{TreeItem, TreeState, tree},
|
||||||
|
v_flex,
|
||||||
};
|
};
|
||||||
use lsp_types::{
|
use lsp_types::{
|
||||||
CodeAction, CodeActionKind, CompletionContext, CompletionItem, CompletionResponse,
|
CodeAction, CodeActionKind, CompletionContext, CompletionItem, CompletionResponse,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use gpui::{
|
||||||
Styled, Window,
|
Styled, Window,
|
||||||
};
|
};
|
||||||
|
|
||||||
use gpui_component::{h_flex, v_flex, Kbd};
|
use gpui_component::{h_flex, kbd::Kbd, v_flex};
|
||||||
|
|
||||||
use crate::section;
|
use crate::section;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,13 @@ use gpui::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use gpui_component::{
|
use gpui_component::{
|
||||||
ActiveTheme as _, IconName, ListItem, StyledExt as _, TreeItem, TreeState, dock::PanelControl,
|
ActiveTheme as _, IconName, StyledExt as _,
|
||||||
h_flex, label::Label, tree, v_flex,
|
dock::PanelControl,
|
||||||
|
h_flex,
|
||||||
|
label::Label,
|
||||||
|
list::ListItem,
|
||||||
|
tree::{TreeItem, TreeState, tree},
|
||||||
|
v_flex,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Story, section};
|
use crate::{Story, section};
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
use std::{ops::Range, rc::Rc};
|
use std::{ops::Range, rc::Rc};
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, px, size, App, AppContext, Context, Div, Entity, FocusHandle, Focusable,
|
App, AppContext, Context, Div, Entity, FocusHandle, Focusable, InteractiveElement, IntoElement,
|
||||||
InteractiveElement, IntoElement, ParentElement, Pixels, Render, ScrollStrategy, Size, Styled,
|
ParentElement, Pixels, Render, ScrollStrategy, Size, Styled, Window, div, px, size,
|
||||||
Window,
|
|
||||||
};
|
};
|
||||||
use gpui_component::{
|
use gpui_component::{
|
||||||
|
ActiveTheme as _, Selectable, Sizable, VirtualListScrollHandle,
|
||||||
button::{Button, ButtonGroup},
|
button::{Button, ButtonGroup},
|
||||||
divider::Divider,
|
divider::Divider,
|
||||||
h_flex,
|
h_flex,
|
||||||
scroll::{Scrollbar, ScrollbarAxis, ScrollbarState},
|
scroll::{Scrollbar, ScrollbarAxis, ScrollbarState},
|
||||||
v_flex, v_virtual_list, ActiveTheme as _, Selectable, Sizable, VirtualListScrollHandle,
|
v_flex, v_virtual_list,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct VirtualListStory {
|
pub struct VirtualListStory {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
|
use gpui::{App, SharedString};
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
mod event;
|
mod event;
|
||||||
mod global_state;
|
mod global_state;
|
||||||
mod icon;
|
mod icon;
|
||||||
mod index_path;
|
mod index_path;
|
||||||
#[cfg(any(feature = "inspector", debug_assertions))]
|
#[cfg(any(feature = "inspector", debug_assertions))]
|
||||||
mod inspector;
|
mod inspector;
|
||||||
mod kbd;
|
|
||||||
mod root;
|
mod root;
|
||||||
mod styled;
|
mod styled;
|
||||||
mod time;
|
mod time;
|
||||||
mod title_bar;
|
mod title_bar;
|
||||||
mod tree;
|
|
||||||
mod virtual_list;
|
mod virtual_list;
|
||||||
mod window_border;
|
mod window_border;
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ pub mod highlighter;
|
||||||
pub mod history;
|
pub mod history;
|
||||||
pub mod indicator;
|
pub mod indicator;
|
||||||
pub mod input;
|
pub mod input;
|
||||||
|
pub mod kbd;
|
||||||
pub mod label;
|
pub mod label;
|
||||||
pub mod link;
|
pub mod link;
|
||||||
pub mod list;
|
pub mod list;
|
||||||
|
|
@ -59,36 +61,30 @@ pub mod tag;
|
||||||
pub mod text;
|
pub mod text;
|
||||||
pub mod theme;
|
pub mod theme;
|
||||||
pub mod tooltip;
|
pub mod tooltip;
|
||||||
|
pub mod tree;
|
||||||
|
pub use time::{calendar, date_picker};
|
||||||
|
|
||||||
#[cfg(feature = "webview")]
|
#[cfg(feature = "webview")]
|
||||||
pub mod webview;
|
pub mod webview;
|
||||||
|
|
||||||
use gpui::{App, SharedString};
|
|
||||||
// re-export
|
// re-export
|
||||||
#[cfg(feature = "webview")]
|
#[cfg(feature = "webview")]
|
||||||
pub use wry;
|
pub use wry;
|
||||||
|
|
||||||
pub use crate::Disableable;
|
pub use crate::Disableable;
|
||||||
pub use event::InteractiveElementExt;
|
pub use event::InteractiveElementExt;
|
||||||
|
pub use icon::*;
|
||||||
pub use index_path::IndexPath;
|
pub use index_path::IndexPath;
|
||||||
pub use input::{Rope, RopeExt, RopeLines};
|
pub use input::{Rope, RopeExt, RopeLines};
|
||||||
#[cfg(any(feature = "inspector", debug_assertions))]
|
#[cfg(any(feature = "inspector", debug_assertions))]
|
||||||
pub use inspector::*;
|
pub use inspector::*;
|
||||||
pub use list::*;
|
|
||||||
pub use root::{ContextModal, Root};
|
pub use root::{ContextModal, Root};
|
||||||
pub use styled::*;
|
pub use styled::*;
|
||||||
pub use time::*;
|
pub use theme::*;
|
||||||
pub use title_bar::*;
|
pub use title_bar::*;
|
||||||
pub use tree::*;
|
|
||||||
pub use virtual_list::{h_virtual_list, v_virtual_list, VirtualList, VirtualListScrollHandle};
|
pub use virtual_list::{h_virtual_list, v_virtual_list, VirtualList, VirtualListScrollHandle};
|
||||||
pub use window_border::{window_border, window_paddings, WindowBorder};
|
pub use window_border::{window_border, window_paddings, WindowBorder};
|
||||||
|
|
||||||
pub use icon::*;
|
|
||||||
pub use kbd::*;
|
|
||||||
pub use theme::*;
|
|
||||||
|
|
||||||
use std::ops::Deref;
|
|
||||||
|
|
||||||
rust_i18n::i18n!("locales", fallback = "en");
|
rust_i18n::i18n!("locales", fallback = "en");
|
||||||
|
|
||||||
/// Initialize the components.
|
/// Initialize the components.
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,13 @@ use std::time::Duration;
|
||||||
use crate::actions::{Cancel, Confirm, SelectDown, SelectUp};
|
use crate::actions::{Cancel, Confirm, SelectDown, SelectUp};
|
||||||
use crate::input::InputState;
|
use crate::input::InputState;
|
||||||
use crate::list::cache::{MeasuredEntrySize, RowEntry, RowsCache};
|
use crate::list::cache::{MeasuredEntrySize, RowEntry, RowsCache};
|
||||||
use crate::list::ListDelegate;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
input::{Input, InputEvent},
|
input::{Input, InputEvent},
|
||||||
scroll::{Scrollbar, ScrollbarState},
|
scroll::{Scrollbar, ScrollbarState},
|
||||||
v_flex, ActiveTheme, IconName, Size,
|
v_flex, ActiveTheme, IconName, Size,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{list::ListDelegate, v_virtual_list, VirtualListScrollHandle};
|
||||||
v_virtual_list, Icon, IndexPath, Selectable, Sizable as _, StyledExt, VirtualListScrollHandle,
|
use crate::{Icon, IndexPath, Selectable, Sizable as _, StyledExt};
|
||||||
};
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, prelude::FluentBuilder, AppContext, Entity, FocusHandle, Focusable, InteractiveElement,
|
div, prelude::FluentBuilder, AppContext, Entity, FocusHandle, Focusable, InteractiveElement,
|
||||||
IntoElement, KeyBinding, Length, MouseButton, ParentElement, Render, Styled, Task, Window,
|
IntoElement, KeyBinding, Length, MouseButton, ParentElement, Render, Styled, Task, Window,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::actions::{SelectLeft, SelectRight};
|
||||||
use crate::menu::menu_item::MenuItemElement;
|
use crate::menu::menu_item::MenuItemElement;
|
||||||
use crate::scroll::{Scrollbar, ScrollbarState};
|
use crate::scroll::{Scrollbar, ScrollbarState};
|
||||||
use crate::{h_flex, v_flex, ActiveTheme, Icon, IconName, Sizable as _};
|
use crate::{h_flex, v_flex, ActiveTheme, Icon, IconName, Sizable as _};
|
||||||
use crate::{Kbd, Side, Size, StyledExt};
|
use crate::{kbd::Kbd, Side, Size, StyledExt};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
anchored, canvas, div, prelude::FluentBuilder, px, rems, Action, AnyElement, App, AppContext,
|
anchored, canvas, div, prelude::FluentBuilder, px, rems, Action, AnyElement, App, AppContext,
|
||||||
Bounds, Context, Corner, DismissEvent, Edges, Entity, EventEmitter, FocusHandle, Focusable,
|
Bounds, Context, Corner, DismissEvent, Edges, Entity, EventEmitter, FocusHandle, Focusable,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use gpui::{
|
||||||
IntoElement, ParentElement, Render, SharedString, StyleRefinement, Styled, Window,
|
IntoElement, ParentElement, Render, SharedString, StyleRefinement, Styled, Window,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{h_flex, text::Text, ActiveTheme, Kbd, StyledExt};
|
use crate::{h_flex, kbd::Kbd, text::Text, ActiveTheme, StyledExt};
|
||||||
|
|
||||||
enum TooltipContext {
|
enum TooltipContext {
|
||||||
Text(Text),
|
Text(Text),
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,9 @@ use gpui::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
actions::{Confirm, SelectDown, SelectLeft, SelectRight, SelectUp},
|
actions::{Confirm, SelectDown, SelectLeft, SelectRight, SelectUp},
|
||||||
|
list::ListItem,
|
||||||
scroll::{Scrollbar, ScrollbarState},
|
scroll::{Scrollbar, ScrollbarState},
|
||||||
ListItem, StyledExt,
|
StyledExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
const CONTEXT: &str = "Tree";
|
const CONTEXT: &str = "Tree";
|
||||||
|
|
@ -450,7 +451,7 @@ impl RenderOnce for Tree {
|
||||||
mod tests {
|
mod tests {
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
use crate::TreeState;
|
use super::TreeState;
|
||||||
use gpui::AppContext as _;
|
use gpui::AppContext as _;
|
||||||
|
|
||||||
fn assert_entries(entries: &Vec<super::TreeEntry>, expected: &str) {
|
fn assert_entries(entries: &Vec<super::TreeEntry>, expected: &str) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ A component for displaying keyboard shortcuts and key combinations with proper p
|
||||||
## Import
|
## Import
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use gpui_component::Kbd;
|
use gpui_component::kbd::Kbd;
|
||||||
use gpui::Keystroke;
|
use gpui::Keystroke;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -130,32 +130,6 @@ The Kbd component automatically formats shortcuts according to platform conventi
|
||||||
| `enter` | ⏎ | Enter |
|
| `enter` | ⏎ | Enter |
|
||||||
| `left` | ← | Left |
|
| `left` | ← | Left |
|
||||||
|
|
||||||
## API Reference
|
|
||||||
|
|
||||||
### Kbd
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ----------------------------------------------------- | ------------------------------------------- |
|
|
||||||
| `new(keystroke)` | Create a new Kbd component from a keystroke |
|
|
||||||
| `appearance(bool)` | Show/hide visual styling (default: true) |
|
|
||||||
| `binding_for_action(action, context, window)` | Get keybinding for action in context |
|
|
||||||
| `binding_for_action_in(action, focus_handle, window)` | Get keybinding for action in focus |
|
|
||||||
| `format(keystroke)` | Static method to format keystroke as string |
|
|
||||||
|
|
||||||
### Static Methods
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ------------------------- | ---------------------------------------------- |
|
|
||||||
| `Kbd::format(&keystroke)` | Format a keystroke as platform-specific string |
|
|
||||||
|
|
||||||
### Trait Implementations
|
|
||||||
|
|
||||||
| Trait | Description |
|
|
||||||
| ----------------- | --------------------------------- |
|
|
||||||
| `From<Keystroke>` | Convert keystroke directly to Kbd |
|
|
||||||
| `Styled` | Apply styling refinements |
|
|
||||||
| `IntoElement` | Render as UI element |
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Keyboard Shortcut Help
|
### Keyboard Shortcut Help
|
||||||
|
|
|
||||||
|
|
@ -353,73 +353,6 @@ list.update(cx, |list, cx| {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Reference
|
|
||||||
|
|
||||||
### List
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ------------------------------------------ | ------------------------------- |
|
|
||||||
| `new(delegate, window, cx)` | Create a new list with delegate |
|
|
||||||
| `max_h(height)` | Set maximum height |
|
|
||||||
| `scrollbar_visible(bool)` | Show/hide scrollbar |
|
|
||||||
| `no_query()` | Remove search input |
|
|
||||||
| `selectable(bool)` | Enable/disable selection |
|
|
||||||
| `paddings(edges)` | Set internal padding |
|
|
||||||
| `set_selected_index(ix, window, cx)` | Set selected item |
|
|
||||||
| `scroll_to_item(ix, strategy, window, cx)` | Scroll to specific item |
|
|
||||||
| `scroll_to_selected_item(window, cx)` | Scroll to selected item |
|
|
||||||
|
|
||||||
### ListDelegate
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| -------------------------------------------- | ---------------------------------- |
|
|
||||||
| `sections_count(cx)` | Number of sections (default: 1) |
|
|
||||||
| `items_count(section, cx)` | Number of items in section |
|
|
||||||
| `render_item(ix, window, cx)` | Render list item |
|
|
||||||
| `render_section_header(section, window, cx)` | Render section header |
|
|
||||||
| `render_section_footer(section, window, cx)` | Render section footer |
|
|
||||||
| `render_empty(window, cx)` | Render empty state |
|
|
||||||
| `render_initial(window, cx)` | Render initial state |
|
|
||||||
| `render_loading(window, cx)` | Render loading state |
|
|
||||||
| `perform_search(query, window, cx)` | Handle search query |
|
|
||||||
| `set_selected_index(ix, window, cx)` | Update selection |
|
|
||||||
| `confirm(secondary, window, cx)` | Handle item confirmation |
|
|
||||||
| `cancel(window, cx)` | Handle selection cancel |
|
|
||||||
| `loading(cx)` | Return loading state |
|
|
||||||
| `is_eof(cx)` | Return if more data available |
|
|
||||||
| `load_more_threshold()` | Threshold for triggering load more |
|
|
||||||
| `load_more(window, cx)` | Load more data |
|
|
||||||
|
|
||||||
### ListItem
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| -------------------- | --------------------------------- |
|
|
||||||
| `new(id)` | Create new list item |
|
|
||||||
| `selected(bool)` | Set selected state |
|
|
||||||
| `confirmed(bool)` | Set confirmed state (shows check) |
|
|
||||||
| `disabled(bool)` | Set disabled state |
|
|
||||||
| `check_icon(icon)` | Set check icon |
|
|
||||||
| `suffix(fn)` | Add suffix element |
|
|
||||||
| `on_click(fn)` | Click handler |
|
|
||||||
| `on_mouse_enter(fn)` | Mouse enter handler |
|
|
||||||
|
|
||||||
### ListEvent
|
|
||||||
|
|
||||||
| Variant | Description |
|
|
||||||
| -------------------- | ---------------------------------- |
|
|
||||||
| `Select(IndexPath)` | Item was selected |
|
|
||||||
| `Confirm(IndexPath)` | Item was confirmed (clicked/Enter) |
|
|
||||||
| `Cancel` | Selection was cancelled (Escape) |
|
|
||||||
|
|
||||||
### IndexPath
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ------------------ | --------------------- |
|
|
||||||
| `new(row)` | Create new index path |
|
|
||||||
| `section(section)` | Set section index |
|
|
||||||
| `row` | Row index |
|
|
||||||
| `section` | Section index |
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### File Browser List
|
### File Browser List
|
||||||
|
|
|
||||||
|
|
@ -401,98 +401,6 @@ table.update(cx, |table, cx| {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Reference
|
|
||||||
|
|
||||||
### Table
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| --------------------------- | --------------------------------------------- |
|
|
||||||
| `new(delegate, window, cx)` | Create a new table with delegate |
|
|
||||||
| `stripe(bool)` | Enable alternating row colors |
|
|
||||||
| `border(bool)` | Show table border |
|
|
||||||
| `loop_selection(bool)` | Enable looping selection with keyboard |
|
|
||||||
| `col_movable(bool)` | Allow column reordering |
|
|
||||||
| `col_resizable(bool)` | Allow column resizing |
|
|
||||||
| `sortable(bool)` | Enable column sorting |
|
|
||||||
| `row_selectable(bool)` | Allow row selection |
|
|
||||||
| `col_selectable(bool)` | Allow column selection |
|
|
||||||
| `col_fixed(bool)` | Enable fixed columns feature |
|
|
||||||
| `scrollbar_visible(v, h)` | Set scrollbar visibility |
|
|
||||||
| `set_size(size, cx)` | Set table size (Small, Medium, Large, XSmall) |
|
|
||||||
| `scroll_to_row(ix, cx)` | Scroll to specific row |
|
|
||||||
| `scroll_to_col(ix, cx)` | Scroll to specific column |
|
|
||||||
| `set_selected_row(ix, cx)` | Select specific row |
|
|
||||||
| `set_selected_col(ix, cx)` | Select specific column |
|
|
||||||
| `clear_selection(cx)` | Clear all selections |
|
|
||||||
| `refresh(cx)` | Refresh table after data changes |
|
|
||||||
|
|
||||||
### Column
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| -------------------------- | --------------------------------------- |
|
|
||||||
| `new(key, name)` | Create column with key and display name |
|
|
||||||
| `width(pixels)` | Set column width |
|
|
||||||
| `sortable()` | Enable sorting with default order |
|
|
||||||
| `ascending()` | Set default ascending sort |
|
|
||||||
| `descending()` | Set default descending sort |
|
|
||||||
| `text_right()` | Right-align column content |
|
|
||||||
| `fixed(ColumnFixed::Left)` | Pin column to left side |
|
|
||||||
| `fixed_left()` | Pin column to left side (shorthand) |
|
|
||||||
| `resizable(bool)` | Allow column resizing |
|
|
||||||
| `movable(bool)` | Allow column moving |
|
|
||||||
| `selectable(bool)` | Allow column selection |
|
|
||||||
| `paddings(edges)` | Set custom cell padding |
|
|
||||||
| `p_0()` | Remove cell padding |
|
|
||||||
|
|
||||||
### TableDelegate
|
|
||||||
|
|
||||||
Required methods to implement:
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ---------------------------------------------- | ------------------------ |
|
|
||||||
| `columns_count(&self, cx)` | Return number of columns |
|
|
||||||
| `rows_count(&self, cx)` | Return number of rows |
|
|
||||||
| `column(&self, col_ix, cx)` | Get column definition |
|
|
||||||
| `render_td(&self, row_ix, col_ix, window, cx)` | Render table cell |
|
|
||||||
|
|
||||||
Optional methods:
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| ------------------------------------------------------- | -------------------------------- |
|
|
||||||
| `render_th(&self, col_ix, window, cx)` | Custom header cell rendering |
|
|
||||||
| `render_tr(&self, row_ix, window, cx)` | Custom row rendering |
|
|
||||||
| `render_empty(&self, window, cx)` | Empty state content |
|
|
||||||
| `render_loading(&self, size, window, cx)` | Loading state content |
|
|
||||||
| `context_menu(&self, row_ix, menu, window, cx)` | Row context menu |
|
|
||||||
| `perform_sort(&mut self, col_ix, sort, window, cx)` | Handle column sorting |
|
|
||||||
| `move_column(&mut self, col_ix, to_ix, window, cx)` | Handle column reordering |
|
|
||||||
| `load_more(&mut self, window, cx)` | Load more data |
|
|
||||||
| `loading(&self, cx)` | Return loading state |
|
|
||||||
| `is_eof(&self, cx)` | Return if no more data |
|
|
||||||
| `load_more_threshold(&self)` | Rows from bottom to trigger load |
|
|
||||||
| `visible_rows_changed(&mut self, range, window, cx)` | Visible range changed |
|
|
||||||
| `visible_columns_changed(&mut self, range, window, cx)` | Visible columns changed |
|
|
||||||
|
|
||||||
### TableEvent
|
|
||||||
|
|
||||||
Events emitted by the table:
|
|
||||||
|
|
||||||
| Event | Description |
|
|
||||||
| ---------------------------------- | ----------------------- |
|
|
||||||
| `SelectRow(usize)` | Row selected |
|
|
||||||
| `DoubleClickedRow(usize)` | Row double-clicked |
|
|
||||||
| `SelectColumn(usize)` | Column selected |
|
|
||||||
| `ColumnWidthsChanged(Vec<Pixels>)` | Column widths changed |
|
|
||||||
| `MoveColumn(usize, usize)` | Column moved (from, to) |
|
|
||||||
|
|
||||||
### ColumnSort
|
|
||||||
|
|
||||||
| Value | Description |
|
|
||||||
| ------------ | ------------------ |
|
|
||||||
| `Default` | No sorting applied |
|
|
||||||
| `Ascending` | Sort ascending |
|
|
||||||
| `Descending` | Sort descending |
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Financial Data Table
|
### Financial Data Table
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ A versatile tree component for displaying hierarchical data with expand/collapse
|
||||||
## Import
|
## Import
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use gpui_component::{tree, TreeState, TreeItem, TreeEntry};
|
use gpui_component::tree::{tree, TreeState, TreeItem, TreeEntry};
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
|
||||||
|
|
@ -356,50 +356,6 @@ impl MyView {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Reference
|
|
||||||
|
|
||||||
### Virtual List Functions
|
|
||||||
|
|
||||||
| Function | Description |
|
|
||||||
| -------------------------------------------- | ------------------------------ |
|
|
||||||
| `v_virtual_list(view, id, sizes, render_fn)` | Create vertical virtual list |
|
|
||||||
| `h_virtual_list(view, id, sizes, render_fn)` | Create horizontal virtual list |
|
|
||||||
|
|
||||||
### VirtualList Methods
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| -------------------------------- | -------------------------------- |
|
|
||||||
| `track_scroll(handle)` | Attach scroll handle for control |
|
|
||||||
| `with_sizing_behavior(behavior)` | Set list sizing behavior |
|
|
||||||
|
|
||||||
### VirtualListScrollHandle
|
|
||||||
|
|
||||||
| Method | Description |
|
|
||||||
| --------------------------------- | ------------------------- |
|
|
||||||
| `new()` | Create new scroll handle |
|
|
||||||
| `scroll_to_item(index, strategy)` | Scroll to specific item |
|
|
||||||
| `scroll_to_bottom()` | Scroll to the bottom |
|
|
||||||
| `offset()` | Get current scroll offset |
|
|
||||||
| `set_offset(point)` | Set scroll position |
|
|
||||||
| `content_size()` | Get total content size |
|
|
||||||
|
|
||||||
### ScrollStrategy
|
|
||||||
|
|
||||||
| Strategy | Description |
|
|
||||||
| -------- | -------------------------------- |
|
|
||||||
| `Top` | Align item to top of viewport |
|
|
||||||
| `Center` | Center item in viewport |
|
|
||||||
| `Bottom` | Align item to bottom of viewport |
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
| Parameter | Type | Description |
|
|
||||||
| ------------ | ----------------------- | -------------------------------- |
|
|
||||||
| `view` | `Entity<V>` | View entity containing the data |
|
|
||||||
| `id` | `impl Into<ElementId>` | Unique identifier for the list |
|
|
||||||
| `item_sizes` | `Rc<Vec<Size<Pixels>>>` | Size of each item |
|
|
||||||
| `render_fn` | Closure | Function to render visible items |
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### File Explorer with Virtual Scrolling
|
### File Explorer with Virtual Scrolling
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue