upload.pyi 15 KB

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