upload.pyi 13 KB

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