upload.pyi 14 KB

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