__init__.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. """Element classes."""
  2. from __future__ import annotations
  3. from reflex.utils import lazy_loader
  4. _MAPPING = {
  5. "forms": [
  6. "button",
  7. "datalist",
  8. "fieldset",
  9. "form",
  10. "input",
  11. "label",
  12. "legend",
  13. "meter",
  14. "optgroup",
  15. "option",
  16. "output",
  17. "progress",
  18. "select",
  19. "textarea",
  20. ],
  21. "inline": [
  22. "a",
  23. "abbr",
  24. "b",
  25. "bdi",
  26. "bdo",
  27. "br",
  28. "cite",
  29. "code",
  30. "data",
  31. "dfn",
  32. "em",
  33. "i",
  34. "kbd",
  35. "mark",
  36. "q",
  37. "rp",
  38. "rt",
  39. "ruby",
  40. "s",
  41. "samp",
  42. "small",
  43. "span",
  44. "strong",
  45. "sub",
  46. "sup",
  47. "time",
  48. "u",
  49. "wbr",
  50. ],
  51. "media": [
  52. "area",
  53. "audio",
  54. "img",
  55. "image",
  56. "map",
  57. "track",
  58. "video",
  59. "embed",
  60. "iframe",
  61. "object",
  62. "picture",
  63. "portal",
  64. "source",
  65. "svg",
  66. "text",
  67. "line",
  68. "circle",
  69. "ellipse",
  70. "rect",
  71. "polygon",
  72. "path",
  73. "stop",
  74. "linear_gradient",
  75. "radial_gradient",
  76. "defs",
  77. ],
  78. "metadata": [
  79. "base",
  80. "head",
  81. "link",
  82. "meta",
  83. "title",
  84. "style",
  85. ],
  86. "other": ["details", "dialog", "summary", "slot", "template", "math", "html"],
  87. "scripts": ["canvas", "noscript", "script"],
  88. "sectioning": [
  89. "address",
  90. "article",
  91. "aside",
  92. "body",
  93. "header",
  94. "footer",
  95. "h1",
  96. "h2",
  97. "h3",
  98. "h4",
  99. "h5",
  100. "h6",
  101. "main",
  102. "nav",
  103. "section",
  104. ],
  105. "tables": [
  106. "caption",
  107. "col",
  108. "colgroup",
  109. "table",
  110. "td",
  111. "tfoot",
  112. "th",
  113. "thead",
  114. "tr",
  115. "tbody",
  116. ],
  117. "typography": [
  118. "blockquote",
  119. "dd",
  120. "div",
  121. "dl",
  122. "dt",
  123. "figcaption",
  124. "hr",
  125. "ol",
  126. "li",
  127. "p",
  128. "pre",
  129. "ul",
  130. "ins",
  131. "del_",
  132. "Del",
  133. ],
  134. }
  135. EXCLUDE = ["del_", "Del", "image", "style"]
  136. for v in _MAPPING.values():
  137. from reflex.utils.format import to_camel_case
  138. v.extend(
  139. [
  140. to_camel_case(mod)[0].upper() + to_camel_case(mod)[1:]
  141. for mod in v
  142. if mod not in EXCLUDE
  143. ]
  144. )
  145. _MAPPING["metadata"].extend(["StyleEl"])
  146. _SUBMOD_ATTRS: dict[str, list[str]] = _MAPPING
  147. __getattr__, __dir__, __all__ = lazy_loader.attach(
  148. __name__,
  149. submod_attrs=_SUBMOD_ATTRS,
  150. )