def send_reply(pieces=None) -> None:
"""``pieces`` is the list's ``name=``: the files arrive with the form."""
files = pieces if isinstance(pieces, list) else [pieces] if pieces else []
ui.notification(f"Reply sent with {len(files)} attachment(s).", color="success")
def reply() -> None:
with ui.card(padding="md", classes="w-full max-w-xl"), \
ui.form(on_submit=send_reply), ui.vstack(gap="sm"):
ui.textarea(name="text", placeholder="Reply to Lumen Studio…", rows=3, size="sm")
pieces = ui.attachments(name="pieces", multiple=True, max_size_mb=25,
paste=True, drop="form", size="sm")
with ui.hstack(gap="xs", align="center"):
ui.button("Send", type="submit", icon_left="send", size="sm")
ui.icon_button("paperclip", variant="ghost", size="sm",
tooltip="Attach a file", aria_label="Attach a file",
on_click=pieces.pick())