upload.pyi 16 KB

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