"""A complete DyUI app that shows the `list` component.

Save it as app.py, then run:  dyui run app.py
"""
import dyui
from dyui import ui

app = dyui.App(title="List demo", starters=["Show me"], persist=False)


@app.on_message
async def reply(msg: dyui.Message, chat: dyui.Chat):
    yield "Here is the `list` component."
    yield ui.List(ui.ListItem("Hotel Avenida", "4.6 ★ · $180/night", action="pick_hotel"))


@app.on_action("pick_hotel")
async def on_pick_hotel(action: dyui.Action, chat: dyui.Chat):
    # action.values holds what the user entered or chose; action.data is the static data
    yield f"Got `{action.name}` from **{action.label}** with values `{action.values}`."
