upload.pyi 15 KB

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