Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/nsh-base/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ pub fn Command(props: CommandProps, cx: Scope<CommandEvent>) -> impl IntoElement
render_item: props.render_item,
render_group: props.render_group,
};
let rows = virtual_list(
let rows = list(
move || shown.with(|s| s.rows.len()),
move |at| row(palette, parts, at),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/src/emoji_picker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ pub fn EmojiPicker(props: EmojiPickerProps, cx: Scope<EmojiPickerEvent>) -> impl
// A list of its own scroll view: a group's tab scrolls far, and the
// core follows the target as the rows on the way are measured (a list
// in its parent's scroll view lands where the estimates said).
let list = virtual_list(
let list = list(
move || shown.with(|s| s.0.rows.len()),
move |at| row(picker, parts, at),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/src/listbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ fn content(lb: Listbox, sheet: bool, parts: Parts, hooks: Hooks) -> Vec<AnyEleme
);
let rows = {
let hooks = hooks.clone();
virtual_list(
list(
move || lb.shown.with(|s| s.rows.len()),
move |at| row(lb, parts, hooks.clone(), at),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3239,7 +3239,7 @@ pub fn MenuList(props: MenuListProps, cx: Scope<NoEvent>) -> impl IntoElement {
let items = menu.as_ref().map(|m| m.items.clone());
let sheet = menu.filter(|m| m.sheet);
let (made, seen) = (rows.clone(), rows);
virtual_list(
nsh_core::element::list(
move || count.get() as usize,
move |at: Position| {
let cell = made.next_cell.get() + 1;
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/src/term/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ pub fn Terminal(props: TerminalProps, cx: Scope<TerminalEvent>) -> impl IntoElem
}
};
let row_term = term.clone();
let rows = virtual_list(count, move |at| {
let rows = list(count, move |at| {
row(row_term.clone(), props, font, cell_width, at)
})
.alignment(ListAlignment::Bottom)
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/src/text_view/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ impl Cx {
// render writes no state.
let asked = std::cell::Cell::new(false);
let shown = shown.clone();
let probe = virtual_list(1, move |_| {
let probe = list(1, move |_| {
if !asked.replace(true) {
shown.show(from);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ pub fn Tree(props: TreeProps, cx: Scope<TreeEvent>) -> impl IntoElement {
render_item: props.render_item,
press,
};
let rows = virtual_list(
let rows = nsh_core::element::list(
move || shown.with(|s| s.rows.len()),
move |at| row(model.clone(), at),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-base/tests/base/scrollbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ fn BuiltIn(props: BuiltInProps) -> impl IntoElement {
let offset = signal(0.0_f32);
let on_scroll = move |e: &ScrollEvent| offset.set(e.offset.y.0);
let view_of = if props.list {
virtual_list(20, |_| view().h(px(50.0)))
list(20, |_| view().h(px(50.0)))
.test_id("content")
.w(px(300.0))
.h(px(200.0))
Expand Down
4 changes: 2 additions & 2 deletions crates/nsh-core/src/core/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ enum Inner {
place: PlaceFn,
index: usize,
},
/// A cell of a component's own list ([`crate::element::virtual_list`]): it
/// A cell of a component's own list ([`crate::element::list`]): it
/// renders row `index` with the list's row function.
VirtualRow {
list: NodeId,
Expand Down Expand Up @@ -602,7 +602,7 @@ pub(super) struct Expanded {
style: StyleRefinement,
classes: Classes,
events: EventMask,
/// A list's layout, when this element is a `VirtualList`.
/// A list's layout, when this element is a `List`.
list: Option<Box<ListConfig>>,
pub(super) part: Part,
pub(super) children: Vec<Expanded>,
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-core/src/core/reconciliation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ thread_local! {
fn RecycledRegions() -> impl IntoElement {
let count = signal(3_usize);
NATIVE_COUNT.with(|saved| saved.set(Some(count)));
virtual_list(
list(
move || count.get(),
|at| {
let row = at.index();
Expand Down
49 changes: 24 additions & 25 deletions crates/nsh-core/src/core/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20274,7 +20274,7 @@ mod components {
)
.child(catch_error(
move || {
virtual_list(
list(
move || rows.with(Vec::len),
move |at| {
view()
Expand Down Expand Up @@ -20355,7 +20355,7 @@ mod components {
.flex_row()
.flex_1()
.child(
virtual_list(6, move |at| {
list(6, move |at| {
// 160, 320 and 480 points of text at 8 a char.
text("x".repeat(20 * (at.index() % 3 + 1)))
})
Expand Down Expand Up @@ -20457,7 +20457,7 @@ mod components {
.flex_1()
.child(view().h(px(20.0)).on_press(move |_: &()| menu.set(false)))
.child(
virtual_list(500, move |at| {
list(500, move |at| {
view()
.h(px(40.0))
.child(text(move || format!("row {}", at.index())))
Expand Down Expand Up @@ -20564,7 +20564,7 @@ mod components {
.child(view().h(px(20.0)).label("up").on_press(move_row(10, 2)))
.child(view().h(px(20.0)).label("down").on_press(move_row(3, 90)))
.child(
virtual_list(
list(
move || rows.with(Vec::len),
move |at| {
view()
Expand Down Expand Up @@ -20665,7 +20665,7 @@ mod components {
rows.update(change);
}))
.child(
virtual_list(
list(
move || rows.with(Vec::len),
move |at| {
view()
Expand All @@ -20692,7 +20692,7 @@ mod components {
})
}))
.child(
virtual_list(
list(
move || rows.with(Vec::len),
move |at| {
let tall = move || {
Expand Down Expand Up @@ -20955,7 +20955,7 @@ mod components {
rows.update(change);
}))
.child(
virtual_list(
list(
move || rows.with(Vec::len),
move |at| {
let cell = ID_CELLS.get();
Expand Down Expand Up @@ -21124,7 +21124,7 @@ mod components {
/// A long list of its own rows, each a stop of Tab.
#[component]
fn FocusableRows() -> impl IntoElement {
virtual_list(500, move |at| {
list(500, move |at| {
view()
.h(px(40.0))
.focusable(true)
Expand Down Expand Up @@ -21222,7 +21222,7 @@ mod components {
.child(when(open, move || {
provide_context(BranchContext("provided"));
let local = signal(1u32);
virtual_list(3, move |at| {
list(3, move |at| {
let label = use_context::<BranchContext>().map_or("missing", |c| c.0);
effect(move || {
tick.get();
Expand Down Expand Up @@ -21275,12 +21275,12 @@ mod components {
fn ReownedVirtualList() -> impl IntoElement {
let use_b = signal(false);
let (owner_a, list_a) = crate::element::create_root(|| {
virtual_list(1, |_| text("A").h(px(40.0)))
list(1, |_| text("A").h(px(40.0)))
.estimated_item_size(px(40.0))
.flex_1()
});
let (owner_b, list_b) = crate::element::create_root(|| {
virtual_list(1, |_| {
list(1, |_| {
let live = signal(7u32);
REOWNED_B_ROW.with(|r| r.set(Some(live)));
text("B").h(px(40.0))
Expand Down Expand Up @@ -21375,7 +21375,7 @@ mod components {
provide_context(BranchContext("provided"));
ScopedItemsHost::element(ScopedItemsProps::initial())
.flex_1()
.items(virtual_list(1, |at| {
.items(list(1, |at| {
let label = use_context::<BranchContext>().map_or("missing", |c| c.0);
text(format!("{label} {}", at.index())).h(px(40.0))
}))
Expand Down Expand Up @@ -21403,7 +21403,7 @@ mod components {
.on_press(move |_: &()| tall.update(|t| *t = !*t)),
)
.child(
virtual_list(20, move |at| {
list(20, move |at| {
view().h(move || {
px(if tall.get() && at.is_last() {
120.0
Expand Down Expand Up @@ -28123,7 +28123,7 @@ mod views {
});
}))
.child(
virtual_list(
list(
move || rows.with(Vec::len),
move |at| {
view()
Expand Down Expand Up @@ -28229,7 +28229,7 @@ mod views {
.child(dynamic(move || {
let replaced = replacement.get();
let source = if replaced { "second" } else { "first" };
let list = virtual_list(
let list = list(
move || rows.with(Vec::len),
move |at| {
text(move || rows.with(|r| format!("{source}: {}", r[at.index()].1)))
Expand Down Expand Up @@ -28286,7 +28286,7 @@ mod views {
.child(view().on_press(move || padding.set(100.0)))
.child(dynamic(move || {
let replaced = replacement.get();
let list = virtual_list(1, move |_| {
let list = list(1, move |_| {
text(if replaced { "new" } else { "old" }).h(px(40.0))
})
.flex_1();
Expand Down Expand Up @@ -28386,7 +28386,7 @@ mod views {
.flex_1()
.on_press(move |_: &()| padded.update(|p| *p = !*p))
.child(
virtual_list(3, |at| text(format!("row {}", at.index())).h(px(40.0)))
list(3, |at| text(format!("row {}", at.index())).h(px(40.0)))
.content_padding_top(move || if padded.get() { 10.0_f32 } else { 0.0 })
.flex_1(),
)
Expand Down Expand Up @@ -31110,7 +31110,7 @@ mod views {
#[component]
fn FilledRows() -> impl IntoElement {
view().flex_1().child(
virtual_list(200, move |at| {
list(200, move |at| {
let i = at.index();
view()
.h(px(40.0))
Expand Down Expand Up @@ -31211,7 +31211,7 @@ mod views {

fn messages(newest: f32) -> impl IntoElement {
view().flex_1().child(
virtual_list(50, move |at| {
list(50, move |at| {
let i = at.index();
text(format!("m{i}")).h(px(if i == 49 { newest } else { 60.0 }))
})
Expand Down Expand Up @@ -36953,7 +36953,7 @@ mod renders {
let (items, render) = (props.items, props.render_item);
view().max_h(px(300.0)).child(
scroll().flex_shrink(1.0).min_h(px(0.0)).child(
virtual_list(
list(
move || items.with(Vec::len),
move |at| {
view().child(dynamic(move || -> Option<Rendered> {
Expand Down Expand Up @@ -57203,8 +57203,7 @@ mod each_updates {
/// changes the kind of its `Create`.
#[component]
fn ParentList() -> impl IntoElement {
virtual_list(|| 3usize, |_| view().h(px(20.0)).child(text("row")))
.viewport(ListViewport::Parent)
list(|| 3usize, |_| view().h(px(20.0)).child(text("row"))).viewport(ListViewport::Parent)
}

/// Tips and lists in their parent's viewport, all components' roots
Expand Down Expand Up @@ -57312,7 +57311,7 @@ mod each_updates {
.flex_col()
.child(Tip::element(TipProps {}))
.child(
virtual_list(
list(
|| 40usize,
|_| view().h(px(30.0)).child(Tip::element(TipProps {})),
)
Expand Down Expand Up @@ -58544,7 +58543,7 @@ fn a_list_bound_after_the_mount_budget_makes_the_rows_that_show_at_once() {
.children((0..64).map(|_| view().w(px(10.0)).h(px(26.0)))),
)
.child(
virtual_list(3_usize, |_| {
list(3_usize, |_| {
view().h(px(26.0)).test_id("row").child(
view().child(
view().child(view().w(px(40.0)).h(px(20.0)).test_id("label")),
Expand Down Expand Up @@ -58601,7 +58600,7 @@ fn a_list_bound_after_the_mount_budget_gives_its_row_a_frame() {
.children((0..64).map(|_| view().w(px(10.0)).h(px(26.0)))),
)
.child(
virtual_list(1_usize, |_| {
list(1_usize, |_| {
view()
.h(px(26.0))
.test_id("row")
Expand Down
4 changes: 2 additions & 2 deletions crates/nsh-core/src/element/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ pub(crate) enum ElKind {
EachChild(PlaceFn),
/// The glue's list of an [`Items`] prop.
List(Box<ListEl>),
/// A list of the component's own rows ([`super::virtual_list`]).
/// A list of the component's own rows ([`super::list`]).
VirtualList(Box<super::virtual_list::VirtualListEl>),
/// A piece of a text's content among its spans (a raw text node, as
/// JS's strings in a `<text>`).
Expand Down Expand Up @@ -3339,7 +3339,7 @@ impl<C: Component> ComponentElement<C> {
/// and handled by this component; the layout and the styles are the
/// placing component's ([`ParentElement::list`]), so `list`'s own are
/// left out.
pub fn items(mut self, list: super::VirtualList) -> Self {
pub fn items(mut self, list: super::List) -> Self {
match <C::Props as super::Props>::ITEMS {
Some(name) => self.node.children.push(list.into_items(name)),
None => {
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-core/src/element/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub struct TextSelectionEvent {
pub struct TextSelectionEndpoint {
/// The item's key, as the list names it: a TSX `List`'s
/// `keyExtractor`, else the item's `key` or `id`, else its index. A
/// Rust component's list (`virtual_list`) in a TSX `List`'s item leaves
/// Rust component's list (`list`) in a TSX `List`'s item leaves
/// the key to that item; with no TSX list around, its row goes by its
/// index. The index is written in decimal.
pub key: String,
Expand Down
4 changes: 3 additions & 1 deletion crates/nsh-core/src/element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ pub use nsh_macros::{
pub use self::host::{Modal, Screen, Stack};
#[doc(hidden)]
pub use self::host::{modal, screen, stack};
#[allow(deprecated)]
pub use self::virtual_list::{VirtualList, virtual_list};
pub(crate) use self::{
ambient::act,
animated::LiveNode,
Expand Down Expand Up @@ -215,7 +217,7 @@ pub use self::{
InContext, JsValue, NodeRef, PropEnum, PropError, SharedString, TsType, TsTypes,
render_params_of, ts_of,
},
virtual_list::{ListLayout, ViewableItems, VirtualList, virtual_list},
virtual_list::{List, ListLayout, ViewableItems, list},
watch::OrderWatch,
};
#[doc(hidden)]
Expand Down
2 changes: 1 addition & 1 deletion crates/nsh-core/src/element/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
geometry::{Point, Points},
};

/// How an element scrolls: [`super::Scroll`], [`super::VirtualList`] and
/// How an element scrolls: [`super::Scroll`], [`super::List`] and
/// [`super::ListElement`] (the app's rows a component places). The
/// direction and the indicator are [`super::Scroll::horizontal`] /
/// [`super::ListLayout::horizontal`] and their `scrollbar`.
Expand Down
Loading
Loading