upload.pyi 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 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[()]] = None,
  46. on_click: Optional[EventType[()]] = None,
  47. on_context_menu: Optional[EventType[()]] = None,
  48. on_double_click: Optional[EventType[()]] = None,
  49. on_focus: Optional[EventType[()]] = None,
  50. on_mount: Optional[EventType[()]] = None,
  51. on_mouse_down: Optional[EventType[()]] = None,
  52. on_mouse_enter: Optional[EventType[()]] = None,
  53. on_mouse_leave: Optional[EventType[()]] = None,
  54. on_mouse_move: Optional[EventType[()]] = None,
  55. on_mouse_out: Optional[EventType[()]] = None,
  56. on_mouse_over: Optional[EventType[()]] = None,
  57. on_mouse_up: Optional[EventType[()]] = None,
  58. on_scroll: Optional[EventType[()]] = None,
  59. on_unmount: Optional[EventType[()]] = 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[()]] = None,
  89. on_click: Optional[EventType[()]] = None,
  90. on_context_menu: Optional[EventType[()]] = None,
  91. on_double_click: Optional[EventType[()]] = None,
  92. on_drop: Optional[Union[EventType[()], EventType[Any]]] = None,
  93. on_focus: Optional[EventType[()]] = None,
  94. on_mount: Optional[EventType[()]] = None,
  95. on_mouse_down: Optional[EventType[()]] = None,
  96. on_mouse_enter: Optional[EventType[()]] = None,
  97. on_mouse_leave: Optional[EventType[()]] = None,
  98. on_mouse_move: Optional[EventType[()]] = None,
  99. on_mouse_out: Optional[EventType[()]] = None,
  100. on_mouse_over: Optional[EventType[()]] = None,
  101. on_mouse_up: Optional[EventType[()]] = None,
  102. on_scroll: Optional[EventType[()]] = None,
  103. on_unmount: Optional[EventType[()]] = None,
  104. **props,
  105. ) -> "GhostUpload":
  106. """Create the component.
  107. Args:
  108. *children: The children of the component.
  109. on_drop: Fired when files are dropped.
  110. style: The style of the component.
  111. key: A unique key for the component.
  112. id: The id for the component.
  113. class_name: The class name for the component.
  114. autofocus: Whether the component should take the focus once the page is loaded
  115. custom_attrs: custom attribute
  116. **props: The props of the component.
  117. Returns:
  118. The component.
  119. """
  120. ...
  121. class Upload(MemoizationLeaf):
  122. is_used: ClassVar[bool] = False
  123. @overload
  124. @classmethod
  125. def create( # type: ignore
  126. cls,
  127. *children,
  128. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  129. disabled: Optional[Union[Var[bool], bool]] = None,
  130. max_files: Optional[Union[Var[int], int]] = None,
  131. max_size: Optional[Union[Var[int], int]] = None,
  132. min_size: Optional[Union[Var[int], int]] = None,
  133. multiple: Optional[Union[Var[bool], bool]] = None,
  134. no_click: Optional[Union[Var[bool], bool]] = None,
  135. no_drag: Optional[Union[Var[bool], bool]] = None,
  136. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  137. style: Optional[Style] = None,
  138. key: Optional[Any] = None,
  139. id: Optional[Any] = None,
  140. class_name: Optional[Any] = None,
  141. autofocus: Optional[bool] = None,
  142. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  143. on_blur: Optional[EventType[()]] = None,
  144. on_click: Optional[EventType[()]] = None,
  145. on_context_menu: Optional[EventType[()]] = None,
  146. on_double_click: Optional[EventType[()]] = None,
  147. on_drop: Optional[Union[EventType[()], EventType[Any]]] = None,
  148. on_focus: Optional[EventType[()]] = None,
  149. on_mount: Optional[EventType[()]] = None,
  150. on_mouse_down: Optional[EventType[()]] = None,
  151. on_mouse_enter: Optional[EventType[()]] = None,
  152. on_mouse_leave: Optional[EventType[()]] = None,
  153. on_mouse_move: Optional[EventType[()]] = None,
  154. on_mouse_out: Optional[EventType[()]] = None,
  155. on_mouse_over: Optional[EventType[()]] = None,
  156. on_mouse_up: Optional[EventType[()]] = None,
  157. on_scroll: Optional[EventType[()]] = None,
  158. on_unmount: Optional[EventType[()]] = None,
  159. **props,
  160. ) -> "Upload":
  161. """Create an upload component.
  162. Args:
  163. *children: The children of the component.
  164. 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
  165. disabled: Whether the dropzone is disabled.
  166. max_files: The maximum number of files that can be uploaded.
  167. max_size: The maximum file size (bytes) that can be uploaded.
  168. min_size: The minimum file size (bytes) that can be uploaded.
  169. multiple: Whether to allow multiple files to be uploaded.
  170. no_click: Whether to disable click to upload.
  171. no_drag: Whether to disable drag and drop.
  172. no_keyboard: Whether to disable using the space/enter keys to upload.
  173. on_drop: Fired when files are dropped.
  174. style: The style of the component.
  175. key: A unique key for the component.
  176. id: The id for the component.
  177. class_name: The class name for the component.
  178. autofocus: Whether the component should take the focus once the page is loaded
  179. custom_attrs: custom attribute
  180. **props: The properties of the component.
  181. Returns:
  182. The upload component.
  183. """
  184. ...
  185. class StyledUpload(Upload):
  186. @overload
  187. @classmethod
  188. def create( # type: ignore
  189. cls,
  190. *children,
  191. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  192. disabled: Optional[Union[Var[bool], bool]] = None,
  193. max_files: Optional[Union[Var[int], int]] = None,
  194. max_size: Optional[Union[Var[int], int]] = None,
  195. min_size: Optional[Union[Var[int], int]] = None,
  196. multiple: Optional[Union[Var[bool], bool]] = None,
  197. no_click: Optional[Union[Var[bool], bool]] = None,
  198. no_drag: Optional[Union[Var[bool], bool]] = None,
  199. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  200. style: Optional[Style] = None,
  201. key: Optional[Any] = None,
  202. id: Optional[Any] = None,
  203. class_name: Optional[Any] = None,
  204. autofocus: Optional[bool] = None,
  205. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  206. on_blur: Optional[EventType[()]] = None,
  207. on_click: Optional[EventType[()]] = None,
  208. on_context_menu: Optional[EventType[()]] = None,
  209. on_double_click: Optional[EventType[()]] = None,
  210. on_drop: Optional[Union[EventType[()], EventType[Any]]] = None,
  211. on_focus: Optional[EventType[()]] = None,
  212. on_mount: Optional[EventType[()]] = None,
  213. on_mouse_down: Optional[EventType[()]] = None,
  214. on_mouse_enter: Optional[EventType[()]] = None,
  215. on_mouse_leave: Optional[EventType[()]] = None,
  216. on_mouse_move: Optional[EventType[()]] = None,
  217. on_mouse_out: Optional[EventType[()]] = None,
  218. on_mouse_over: Optional[EventType[()]] = None,
  219. on_mouse_up: Optional[EventType[()]] = None,
  220. on_scroll: Optional[EventType[()]] = None,
  221. on_unmount: Optional[EventType[()]] = None,
  222. **props,
  223. ) -> "StyledUpload":
  224. """Create the styled upload component.
  225. Args:
  226. *children: The children of the component.
  227. 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
  228. disabled: Whether the dropzone is disabled.
  229. max_files: The maximum number of files that can be uploaded.
  230. max_size: The maximum file size (bytes) that can be uploaded.
  231. min_size: The minimum file size (bytes) that can be uploaded.
  232. multiple: Whether to allow multiple files to be uploaded.
  233. no_click: Whether to disable click to upload.
  234. no_drag: Whether to disable drag and drop.
  235. no_keyboard: Whether to disable using the space/enter keys to upload.
  236. on_drop: Fired when files are dropped.
  237. style: The style of the component.
  238. key: A unique key for the component.
  239. id: The id for the component.
  240. class_name: The class name for the component.
  241. autofocus: Whether the component should take the focus once the page is loaded
  242. custom_attrs: custom attribute
  243. **props: The properties of the component.
  244. Returns:
  245. The styled upload component.
  246. """
  247. ...
  248. class UploadNamespace(ComponentNamespace):
  249. root = Upload.create
  250. @staticmethod
  251. def __call__(
  252. *children,
  253. accept: Optional[Union[Dict[str, List], Var[Optional[Dict[str, List]]]]] = None,
  254. disabled: Optional[Union[Var[bool], bool]] = None,
  255. max_files: Optional[Union[Var[int], int]] = None,
  256. max_size: Optional[Union[Var[int], int]] = None,
  257. min_size: Optional[Union[Var[int], int]] = None,
  258. multiple: Optional[Union[Var[bool], bool]] = None,
  259. no_click: Optional[Union[Var[bool], bool]] = None,
  260. no_drag: Optional[Union[Var[bool], bool]] = None,
  261. no_keyboard: Optional[Union[Var[bool], bool]] = None,
  262. style: Optional[Style] = None,
  263. key: Optional[Any] = None,
  264. id: Optional[Any] = None,
  265. class_name: Optional[Any] = None,
  266. autofocus: Optional[bool] = None,
  267. custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
  268. on_blur: Optional[EventType[()]] = None,
  269. on_click: Optional[EventType[()]] = None,
  270. on_context_menu: Optional[EventType[()]] = None,
  271. on_double_click: Optional[EventType[()]] = None,
  272. on_drop: Optional[Union[EventType[()], EventType[Any]]] = None,
  273. on_focus: Optional[EventType[()]] = None,
  274. on_mount: Optional[EventType[()]] = None,
  275. on_mouse_down: Optional[EventType[()]] = None,
  276. on_mouse_enter: Optional[EventType[()]] = None,
  277. on_mouse_leave: Optional[EventType[()]] = None,
  278. on_mouse_move: Optional[EventType[()]] = None,
  279. on_mouse_out: Optional[EventType[()]] = None,
  280. on_mouse_over: Optional[EventType[()]] = None,
  281. on_mouse_up: Optional[EventType[()]] = None,
  282. on_scroll: Optional[EventType[()]] = None,
  283. on_unmount: Optional[EventType[()]] = None,
  284. **props,
  285. ) -> "StyledUpload":
  286. """Create the styled upload component.
  287. Args:
  288. *children: The children of the component.
  289. 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
  290. disabled: Whether the dropzone is disabled.
  291. max_files: The maximum number of files that can be uploaded.
  292. max_size: The maximum file size (bytes) that can be uploaded.
  293. min_size: The minimum file size (bytes) that can be uploaded.
  294. multiple: Whether to allow multiple files to be uploaded.
  295. no_click: Whether to disable click to upload.
  296. no_drag: Whether to disable drag and drop.
  297. no_keyboard: Whether to disable using the space/enter keys to upload.
  298. on_drop: Fired when files are dropped.
  299. style: The style of the component.
  300. key: A unique key for the component.
  301. id: The id for the component.
  302. class_name: The class name for the component.
  303. autofocus: Whether the component should take the focus once the page is loaded
  304. custom_attrs: custom attribute
  305. **props: The properties of the component.
  306. Returns:
  307. The styled upload component.
  308. """
  309. ...
  310. upload = UploadNamespace()