# List View


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

## Column Headers

Table header rendering based on configured columns.

------------------------------------------------------------------------

### render_list_header

``` python

def render_list_header(
    config:GalleryConfig, # Gallery configuration
    show_selection:bool=False, # Show selection checkbox column
)->functools.partial(<function ft_hx at 0x7f6e136ab240>, 'thead'): # Table header

```

*Render the table header row.*

``` python
from fasthtml.common import to_xml

# Test list header
config = GalleryConfig()
header = render_list_header(config)
html = to_xml(header)
assert "<thead" in html
assert "Name" in html
assert "Type" in html
assert "Size" in html
assert "Modified" in html

# Test with selection column
header = render_list_header(config, show_selection=True)
html = to_xml(header)
# Check for selection column (empty header) and all 4 data columns
assert 'class="w-10"' in html  # Selection column with width
assert "Name" in html
assert "Type" in html
assert "Size" in html
assert "Modified" in html

print("render_list_header tests passed!")
```

    render_list_header tests passed!

## List Row

Individual row component for a media file.

------------------------------------------------------------------------

### render_list_row

``` python

def render_list_row(
    file_info:FileInfo, # File to render
    config:GalleryConfig, # Gallery configuration
    index:int, # Index in the list
    is_selected:bool=False, # Whether file is selected
    preview_url:Optional=None, # URL for preview action
    select_url:Optional=None, # URL for selection action
    hx_target:Optional=None, # HTMX target for swaps
)->functools.partial(<function ft_hx at 0x7f6e136ab240>, 'tr'): # Table row

```

*Render a media file as a table row.*

``` python
# Test list row
config = GalleryConfig()
file_info = FileInfo(
    name="song.mp3", path="/music/song.mp3", is_directory=False,
    file_type=FileType.AUDIO, extension="mp3", size=5000000
)

row = render_list_row(
    file_info=file_info,
    config=config,
    index=0,
    preview_url="/preview"
)
html = to_xml(row)
assert "<tr" in html
assert "song.mp3" in html
assert "media-gallery-row-0" in html
assert "Audio" in html  # Type column
assert "hx-post" in html

# Test with selection
select_config = GalleryConfig(selection_mode=SelectionMode.SINGLE)
row = render_list_row(
    file_info=file_info,
    config=select_config,
    index=1,
    is_selected=True,
    select_url="/select"
)
html = to_xml(row)
assert "checkbox" in html
assert "checked" in html

print("render_list_row tests passed!")
```

    render_list_row tests passed!

## List View

Complete list view with table structure.

------------------------------------------------------------------------

### render_list_view

``` python

def render_list_view(
    files:List, # Files to display
    config:GalleryConfig, # Gallery configuration
    selected_paths:Optional=None, # Currently selected paths
    preview_url:Optional=None, # URL for preview action
    select_url:Optional=None, # URL for selection action
    hx_target:Optional=None, # HTMX target for swaps
    start_index:int=0, # Starting index for IDs (for pagination)
)->Any: # List view component

```

*Render a list view of media files.*

``` python
# Test list view
config = GalleryConfig()
files = [
    FileInfo(name="photo1.jpg", path="/photo1.jpg", is_directory=False, file_type=FileType.IMAGE, extension="jpg"),
    FileInfo(name="song.mp3", path="/song.mp3", is_directory=False, file_type=FileType.AUDIO, extension="mp3"),
    FileInfo(name="video.mp4", path="/video.mp4", is_directory=False, file_type=FileType.VIDEO, extension="mp4"),
]

list_view = render_list_view(
    files=files,
    config=config,
    preview_url="/preview"
)
html = to_xml(list_view)
assert 'id="media-gallery-list"' in html
assert "<table" in html
assert "<thead" in html
assert "<tbody" in html
assert "photo1.jpg" in html
assert "song.mp3" in html
assert "video.mp4" in html

# Test with striped and compact
from cjm_fasthtml_media_gallery.core.config import ListConfig
striped_config = GalleryConfig(list=ListConfig(striped=True, compact=True))
list_view = render_list_view(files=files, config=striped_config)
html = to_xml(list_view)
assert "table-zebra" in html
assert "table-sm" in html

print("render_list_view tests passed!")
```

    render_list_view tests passed!

## Empty State

------------------------------------------------------------------------

### render_list_empty_state

``` python

def render_list_empty_state(
    message:str='No media files found', # Message to display
)->Any: # Empty state component

```

*Render empty state for list view.*

``` python
# Test empty state
empty = render_list_empty_state()
html = to_xml(empty)
assert "No media files found" in html
assert 'id="media-gallery-list"' in html

print("render_list_empty_state tests passed!")
```

    render_list_empty_state tests passed!
