upload.pyi 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. """Stub file for reflex/components/core/upload.py"""
  2. # ------------------- DO NOT EDIT ----------------------
  3. # This file was generated by `reflex/utils/pyi_generator.py`!
  4. # ------------------------------------------------------
  5. from pathlib import Path
  6. from typing import Any, ClassVar, Dict, List, Optional, Union, overload
  7. from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
  8. from reflex.constants import Dirs
  9. from reflex.event import (
  10. CallableEventSpec,
  11. EventSpec,
  12. EventType,
  13. )
  14. from reflex.style import Style
  15. from reflex.utils.imports import ImportVar
  16. from reflex.vars import VarData
  17. from reflex.vars.base import CallableVar, Var
  18. DEFAULT_UPLOAD_ID: str
  19. upload_files_context_var_data: VarData
  20. @CallableVar
  21. def upload_file(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
  22. @CallableVar
  23. def selected_files(id_: str = DEFAULT_UPLOAD_ID) -> Var: ...
  24. @CallableEventSpec
  25. def clear_selected_files(id_: str = DEFAULT_UPLOAD_ID) -> EventSpec: ...
  26. def cancel_upload(upload_id: str) -> EventSpec: ...
  27. def get_upload_dir() -> Path: ...
  28. uploaded_files_url_prefix = Var(
  29. _js_expr="getBackendURL(env.UPLOAD)",
  30. _var_data=VarData(
  31. imports={
  32. f"$/{Dirs.STATE_PATH}": "getBackendURL",
  33. "$/env.json": ImportVar(tag="env", is_default=True),
  34. }
  35. ),
  36. ).to(str)
  37. def get_upload_url(file_path: str) -> Var[str]: ...
  38. class UploadFilesProvider(Component):
  39. @overload
  40. @classmethod
  41. def create( # type: ignore
  42. cls,
  43. *children,
  44. style: Optional[Style] = None,
  45. key: Optional[Any] = None,
  46. id: Optional[Any] = None,
  47. class_name: Optional[Any] = None,
  48. autofocus: Optional[bool] = None,
  49. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  50. on_blur: Optional[EventType[[]]] = None,
  51. on_click: Optional[EventType[[]]] = None,
  52. on_context_menu: Optional[EventType[[]]] = None,
  53. on_double_click: Optional[EventType[[]]] = None,
  54. on_focus: Optional[EventType[[]]] = None,
  55. on_mount: Optional[EventType[[]]] = None,
  56. on_mouse_down: Optional[EventType[[]]] = None,
  57. on_mouse_enter: Optional[EventType[[]]] = None,
  58. on_mouse_leave: Optional[EventType[[]]] = None,
  59. on_mouse_move: Optional[EventType[[]]] = None,
  60. on_mouse_out: Optional[EventType[[]]] = None,
  61. on_mouse_over: Optional[EventType[[]]] = None,
  62. on_mouse_up: Optional[EventType[[]]] = None,
  63. on_scroll: Optional[EventType[[]]] = None,
  64. on_unmount: Optional[EventType[[]]] = None,
  65. **props,
  66. ) -> "UploadFilesProvider":
  67. """Create the component.
  68. Args:
  69. *children: The children of the component.
  70. style: The style of the component.
  71. key: A unique key for the component.
  72. id: The id for the component.
  73. class_name: The class name for the component.
  74. autofocus: Whether the component should take the focus once the page is loaded
  75. custom_attrs: custom attribute
  76. **props: The props of the component.
  77. Returns:
  78. The component.
  79. """
  80. ...
  81. class Upload(MemoizationLeaf):
  82. is_used: ClassVar[bool] = False
  83. @overload
  84. @classmethod
  85. def create( # type: ignore
  86. cls,
  87. *children,
  88. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  89. disabled: Optional[Union[Var[bool], bool]] = None,
  90. max_files: Optional[Union[Var[int], int]] = None,
  91. max_size: Optional[Union[Var[int], int]] = None,
  92. min_size: Optional[Union[Var[int], int]] = None,
  93. multiple: Optional[Union[Var[bool], bool]] = None,
  94. no_click: Optional[Union[Var[bool], bool]] = None,
  95. no_drag: Optional[Union[Var[bool], bool]] = None,
  96. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  97. style: Optional[Style] = None,
  98. key: Optional[Any] = None,
  99. id: Optional[Any] = None,
  100. class_name: Optional[Any] = None,
  101. autofocus: Optional[bool] = None,
  102. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  103. on_blur: Optional[EventType[[]]] = None,
  104. on_click: Optional[EventType[[]]] = None,
  105. on_context_menu: Optional[EventType[[]]] = None,
  106. on_double_click: Optional[EventType[[]]] = None,
  107. on_drop: Optional[EventType[Any]] = None,
  108. on_focus: Optional[EventType[[]]] = None,
  109. on_mount: Optional[EventType[[]]] = None,
  110. on_mouse_down: Optional[EventType[[]]] = None,
  111. on_mouse_enter: Optional[EventType[[]]] = None,
  112. on_mouse_leave: Optional[EventType[[]]] = None,
  113. on_mouse_move: Optional[EventType[[]]] = None,
  114. on_mouse_out: Optional[EventType[[]]] = None,
  115. on_mouse_over: Optional[EventType[[]]] = None,
  116. on_mouse_up: Optional[EventType[[]]] = None,
  117. on_scroll: Optional[EventType[[]]] = None,
  118. on_unmount: Optional[EventType[[]]] = None,
  119. **props,
  120. ) -> "Upload":
  121. """Create an upload component.
  122. Args:
  123. *children: The children of the component.
  124. accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
  125. disabled: Whether the dropzone is disabled.
  126. max_files: The maximum number of files that can be uploaded.
  127. max_size: The maximum file size (bytes) that can be uploaded.
  128. min_size: The minimum file size (bytes) that can be uploaded.
  129. multiple: Whether to allow multiple files to be uploaded.
  130. no_click: Whether to disable click to upload.
  131. no_drag: Whether to disable drag and drop.
  132. no_keyboard: Whether to disable using the space/enter keys to upload.
  133. style: The style of the component.
  134. key: A unique key for the component.
  135. id: The id for the component.
  136. class_name: The class name for the component.
  137. autofocus: Whether the component should take the focus once the page is loaded
  138. custom_attrs: custom attribute
  139. **props: The properties of the component.
  140. Returns:
  141. The upload component.
  142. """
  143. ...
  144. class StyledUpload(Upload):
  145. @overload
  146. @classmethod
  147. def create( # type: ignore
  148. cls,
  149. *children,
  150. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  151. disabled: Optional[Union[Var[bool], bool]] = None,
  152. max_files: Optional[Union[Var[int], int]] = None,
  153. max_size: Optional[Union[Var[int], int]] = None,
  154. min_size: Optional[Union[Var[int], int]] = None,
  155. multiple: Optional[Union[Var[bool], bool]] = None,
  156. no_click: Optional[Union[Var[bool], bool]] = None,
  157. no_drag: Optional[Union[Var[bool], bool]] = None,
  158. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  159. style: Optional[Style] = None,
  160. key: Optional[Any] = None,
  161. id: Optional[Any] = None,
  162. class_name: Optional[Any] = None,
  163. autofocus: Optional[bool] = None,
  164. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  165. on_blur: Optional[EventType[[]]] = None,
  166. on_click: Optional[EventType[[]]] = None,
  167. on_context_menu: Optional[EventType[[]]] = None,
  168. on_double_click: Optional[EventType[[]]] = None,
  169. on_drop: Optional[EventType[Any]] = None,
  170. on_focus: Optional[EventType[[]]] = None,
  171. on_mount: Optional[EventType[[]]] = None,
  172. on_mouse_down: Optional[EventType[[]]] = None,
  173. on_mouse_enter: Optional[EventType[[]]] = None,
  174. on_mouse_leave: Optional[EventType[[]]] = None,
  175. on_mouse_move: Optional[EventType[[]]] = None,
  176. on_mouse_out: Optional[EventType[[]]] = None,
  177. on_mouse_over: Optional[EventType[[]]] = None,
  178. on_mouse_up: Optional[EventType[[]]] = None,
  179. on_scroll: Optional[EventType[[]]] = None,
  180. on_unmount: Optional[EventType[[]]] = None,
  181. **props,
  182. ) -> "StyledUpload":
  183. """Create the styled upload component.
  184. Args:
  185. *children: The children of the component.
  186. accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
  187. disabled: Whether the dropzone is disabled.
  188. max_files: The maximum number of files that can be uploaded.
  189. max_size: The maximum file size (bytes) that can be uploaded.
  190. min_size: The minimum file size (bytes) that can be uploaded.
  191. multiple: Whether to allow multiple files to be uploaded.
  192. no_click: Whether to disable click to upload.
  193. no_drag: Whether to disable drag and drop.
  194. no_keyboard: Whether to disable using the space/enter keys to upload.
  195. style: The style of the component.
  196. key: A unique key for the component.
  197. id: The id for the component.
  198. class_name: The class name for the component.
  199. autofocus: Whether the component should take the focus once the page is loaded
  200. custom_attrs: custom attribute
  201. **props: The properties of the component.
  202. Returns:
  203. The styled upload component.
  204. """
  205. ...
  206. class UploadNamespace(ComponentNamespace):
  207. root = Upload.create
  208. @staticmethod
  209. def __call__(
  210. *children,
  211. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  212. disabled: Optional[Union[Var[bool], bool]] = None,
  213. max_files: Optional[Union[Var[int], int]] = None,
  214. max_size: Optional[Union[Var[int], int]] = None,
  215. min_size: Optional[Union[Var[int], int]] = None,
  216. multiple: Optional[Union[Var[bool], bool]] = None,
  217. no_click: Optional[Union[Var[bool], bool]] = None,
  218. no_drag: Optional[Union[Var[bool], bool]] = None,
  219. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  220. style: Optional[Style] = None,
  221. key: Optional[Any] = None,
  222. id: Optional[Any] = None,
  223. class_name: Optional[Any] = None,
  224. autofocus: Optional[bool] = None,
  225. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  226. on_blur: Optional[EventType[[]]] = None,
  227. on_click: Optional[EventType[[]]] = None,
  228. on_context_menu: Optional[EventType[[]]] = None,
  229. on_double_click: Optional[EventType[[]]] = None,
  230. on_drop: Optional[EventType[Any]] = None,
  231. on_focus: Optional[EventType[[]]] = None,
  232. on_mount: Optional[EventType[[]]] = None,
  233. on_mouse_down: Optional[EventType[[]]] = None,
  234. on_mouse_enter: Optional[EventType[[]]] = None,
  235. on_mouse_leave: Optional[EventType[[]]] = None,
  236. on_mouse_move: Optional[EventType[[]]] = None,
  237. on_mouse_out: Optional[EventType[[]]] = None,
  238. on_mouse_over: Optional[EventType[[]]] = None,
  239. on_mouse_up: Optional[EventType[[]]] = None,
  240. on_scroll: Optional[EventType[[]]] = None,
  241. on_unmount: Optional[EventType[[]]] = None,
  242. **props,
  243. ) -> "StyledUpload":
  244. """Create the styled upload component.
  245. Args:
  246. *children: The children of the component.
  247. accept: The list of accepted file types. This should be a dictionary of MIME types as keys and array of file formats as values. supported MIME types: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
  248. disabled: Whether the dropzone is disabled.
  249. max_files: The maximum number of files that can be uploaded.
  250. max_size: The maximum file size (bytes) that can be uploaded.
  251. min_size: The minimum file size (bytes) that can be uploaded.
  252. multiple: Whether to allow multiple files to be uploaded.
  253. no_click: Whether to disable click to upload.
  254. no_drag: Whether to disable drag and drop.
  255. no_keyboard: Whether to disable using the space/enter keys to upload.
  256. style: The style of the component.
  257. key: A unique key for the component.
  258. id: The id for the component.
  259. class_name: The class name for the component.
  260. autofocus: Whether the component should take the focus once the page is loaded
  261. custom_attrs: custom attribute
  262. **props: The properties of the component.
  263. Returns:
  264. The styled upload component.
  265. """
  266. ...
  267. upload = UploadNamespace()