tables.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. """Tables classes."""
  2. from typing import Literal
  3. from reflex.vars.base import Var
  4. from .base import BaseHTML
  5. class Caption(BaseHTML):
  6. """Display the caption element."""
  7. tag = "caption"
  8. class Col(BaseHTML):
  9. """Display the col element."""
  10. tag = "col"
  11. # Number of columns the col element spans
  12. span: Var[int]
  13. class Colgroup(BaseHTML):
  14. """Display the colgroup element."""
  15. tag = "colgroup"
  16. # Number of columns the colgroup element spans
  17. span: Var[int]
  18. class Table(BaseHTML):
  19. """Display the table element."""
  20. tag = "table"
  21. # Alignment of the table
  22. align: Var[Literal["left", "center", "right"]]
  23. # Provides a summary of the table's purpose and structure
  24. summary: Var[str]
  25. class Tbody(BaseHTML):
  26. """Display the tbody element."""
  27. tag = "tbody"
  28. class Td(BaseHTML):
  29. """Display the td element."""
  30. tag = "td"
  31. # Alignment of the content within the table cell
  32. align: Var[Literal["left", "center", "right", "justify", "char"]]
  33. # Number of columns a cell should span
  34. col_span: Var[int]
  35. # IDs of the headers associated with this cell
  36. headers: Var[str]
  37. # Number of rows a cell should span
  38. row_span: Var[int]
  39. class Tfoot(BaseHTML):
  40. """Display the tfoot element."""
  41. tag = "tfoot"
  42. class Th(BaseHTML):
  43. """Display the th element."""
  44. tag = "th"
  45. # Alignment of the content within the table header cell
  46. align: Var[Literal["left", "center", "right", "justify", "char"]]
  47. # Number of columns a header cell should span
  48. col_span: Var[int]
  49. # IDs of the headers associated with this header cell
  50. headers: Var[str]
  51. # Number of rows a header cell should span
  52. row_span: Var[int]
  53. # Scope of the header cell (row, col, rowgroup, colgroup)
  54. scope: Var[str]
  55. class Thead(BaseHTML):
  56. """Display the thead element."""
  57. tag = "thead"
  58. class Tr(BaseHTML):
  59. """Display the tr element."""
  60. tag = "tr"
  61. caption = Caption.create
  62. col = Col.create
  63. colgroup = Colgroup.create
  64. table = Table.create
  65. tbody = Tbody.create
  66. td = Td.create
  67. tfoot = Tfoot.create
  68. th = Th.create
  69. thead = Thead.create
  70. tr = Tr.create