reflex/reflex/components/radix/themes/components/table.py
Elijah Ahianyo 34bf25071a
[REF-2821]Improve Dynamic Imports (#3345)
* Improve import times

* add lazy loading to rx.el

* add lazy loading to reflex core components

* minor refactor

* Get imports working with reflex web

* get imports to work with all reflex examples

* refactor to define imports only in the root.

* lint

* deadcode remove

* update poetry deps

* unit tests fix

* app_harness fix

* app_harness fix

* pyi file generate

* pyi file generate

* sort pyi order

* fix pyi

* fix docker ci

* rework pyi-generator

* generate pyi for __init__ files

* test pyright

* test pyright ci

* partial pyright fix

* more pyright fix

* pyright fix

* fix pyi_generator

* add rx.serializer and others

* add future annotation import which fixes container CI, then also load recharts lazily

* add new pyi files

* pyright fix

* minor fixes for reflex-web and flexdown

* forward references for py38

* ruff fix

* pyi fix

* unit tests fix

* reduce coverage to 68%

* reduce coverage to 67%

* reduce coverage to 66%as a workaround to coverage's rounding issue

* reduce coverage to 66%as a workaround to coverage's rounding issue

* exclude lazy_loader dependency review checks.

* its lazy-loader

* Add docstrings and regenerate pyi files

* add link

* address Pr comments

* CI fix

* partially address PR comments.

* edit docstrings and fix integration tests

* fix typo in docstring

* pyi fix
2024-05-31 16:43:10 +00:00

127 lines
3.1 KiB
Python

"""Interactive components provided by @radix-ui/themes."""
from typing import List, Literal
from reflex.components.component import ComponentNamespace
from reflex.components.el import elements
from reflex.vars import Var
from ..base import (
RadixThemesComponent,
)
class TableRoot(elements.Table, RadixThemesComponent):
"""A semantic table for presenting tabular data."""
tag = "Table.Root"
# The size of the table: "1" | "2" | "3"
size: Var[Literal["1", "2", "3"]]
# The variant of the table
variant: Var[Literal["surface", "ghost"]]
class TableHeader(elements.Thead, RadixThemesComponent):
"""The header of the table defines column names and other non-data elements."""
tag = "Table.Header"
_invalid_children: List[str] = ["TableBody"]
_valid_parents: List[str] = ["TableRoot"]
class TableRow(elements.Tr, RadixThemesComponent):
"""A row containing table cells."""
tag = "Table.Row"
# The alignment of the row
align: Var[Literal["start", "center", "end", "baseline"]]
_invalid_children: List[str] = ["TableBody", "TableHeader", "TableRow"]
class TableColumnHeaderCell(elements.Th, RadixThemesComponent):
"""A table cell that is semantically treated as a column header."""
tag = "Table.ColumnHeaderCell"
# The justification of the column
justify: Var[Literal["start", "center", "end"]]
_invalid_children: List[str] = [
"TableBody",
"TableHeader",
"TableRow",
"TableCell",
"TableColumnHeaderCell",
"TableRowHeaderCell",
]
class TableBody(elements.Tbody, RadixThemesComponent):
"""The body of the table contains the data rows."""
tag = "Table.Body"
_invalid_children: List[str] = [
"TableHeader",
"TableRowHeaderCell",
"TableColumnHeaderCell",
"TableCell",
]
_valid_parents: List[str] = ["TableRoot"]
class TableCell(elements.Td, RadixThemesComponent):
"""A cell containing data."""
tag = "Table.Cell"
# The justification of the column
justify: Var[Literal["start", "center", "end"]]
_invalid_children: List[str] = [
"TableBody",
"TableHeader",
"TableRowHeaderCell",
"TableColumnHeaderCell",
"TableCell",
]
class TableRowHeaderCell(elements.Th, RadixThemesComponent):
"""A table cell that is semantically treated as a row header."""
tag = "Table.RowHeaderCell"
# The justification of the column
justify: Var[Literal["start", "center", "end"]]
_invalid_children: List[str] = [
"TableBody",
"TableHeader",
"TableRow",
"TableCell",
"TableColumnHeaderCell",
"TableRowHeaderCell",
]
class Table(ComponentNamespace):
"""Table components namespace."""
root = staticmethod(TableRoot.create)
header = staticmethod(TableHeader.create)
body = staticmethod(TableBody.create)
row = staticmethod(TableRow.create)
cell = staticmethod(TableCell.create)
column_header_cell = staticmethod(TableColumnHeaderCell.create)
row_header_cell = staticmethod(TableRowHeaderCell.create)
table = Table()