upload.pyi 13 KB

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