status-bar.ts 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { defineComponent, ref, h, type PropType } from 'vue'
  2. import StatusBarPlugin, { type StatusBarOptions } from '@uppy/status-bar'
  3. import { Uppy } from '@uppy/core'
  4. import useUppy from './useUppy'
  5. export default defineComponent({
  6. name: 'StatusBar',
  7. props: {
  8. uppy: {
  9. type: Uppy<any, any>,
  10. required: true,
  11. },
  12. props: {
  13. type: Object as PropType<StatusBarOptions>,
  14. },
  15. },
  16. setup(props) {
  17. const containerRef = ref<string>()
  18. const pluginRef = ref<StatusBarPlugin<any, any>>()
  19. const propsRef = ref(props.props)
  20. const onMount = () => {
  21. const { uppy } = props
  22. const options = {
  23. id: 'StatusBar',
  24. ...props,
  25. target: containerRef.value,
  26. }
  27. uppy.use(StatusBarPlugin, options)
  28. pluginRef.value = uppy.getPlugin(options.id) as StatusBarPlugin<any, any>
  29. }
  30. useUppy(onMount, pluginRef, props.uppy, propsRef)
  31. return () =>
  32. h('div', {
  33. ref: containerRef,
  34. })
  35. },
  36. })