feat: search, filter and act on items from the library pages

This commit is contained in:
randogoth 2026-10-11 13:25:57 +03:00
parent 1b426ccd8b
commit 5cd053c8a9
11 changed files with 401 additions and 43 deletions

View file

@ -139,6 +139,33 @@ ListBlock choiceRow(List<Choice> options) {
);
}
/// A one-field search box that submits back to its own page, turning what the
/// reader typed into a query string. [keep] carries the parameters the submit
/// must not drop as hidden fields, the way an HTML form does.
///
/// Keep this at a fixed position in a page's blocks: the renderer matches form
/// state by position, so a block appearing above it would reset what the
/// reader typed.
FormBlock searchForm({
required String action,
required String label,
required String submitLabel,
required String query,
Map<String, String> keep = const {},
}) {
return FormBlock(
action: action,
method: 'get',
submitLabel: submitLabel,
fields: [
MewsTextField(name: 'q', label: label, password: false, value: query),
for (final kept in keep.entries)
MewsHiddenField(name: kept.key, value: kept.value),
MewsSubmitField(reset: false, label: submitLabel),
],
);
}
/// A plain list of links, used for menus and library lists alike.
ListBlock itemList(List<MewsListItem> items) =>
ListBlock(ordered: false, start: 1, items: items);