setup.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import Vue from "vue";
  2. import {GoPlaidPortal} from "@/portal";
  3. import GoPlaidScope from "@/scope";
  4. import {initContext} from "@/initContext";
  5. import {fieldNameDirective} from "@/fieldname";
  6. import debounce from "@/debounce";
  7. import {keepScroll} from "@/keepScroll";
  8. import {Builder, plaid} from "@/builder";
  9. // @ts-ignore
  10. import GlobalEvents from 'vue-global-events'
  11. const form = new FormData();
  12. Vue.component('GoPlaidPortal', GoPlaidPortal());
  13. Vue.component('GoPlaidScope', GoPlaidScope);
  14. Vue.component('GlobalEvents', GlobalEvents);
  15. Vue.directive('init-context', initContext());
  16. Vue.directive('field-name', fieldNameDirective(form));
  17. Vue.directive('debounce', debounce);
  18. Vue.directive('keep-scroll', keepScroll());
  19. Vue.mixin({
  20. mounted() {
  21. window.addEventListener('fetchStart', (e: Event) => {
  22. (this as any).isFetching = true;
  23. });
  24. window.addEventListener('fetchEnd', (e: Event) => {
  25. (this as any).isFetching = false;
  26. });
  27. },
  28. data() {
  29. return {
  30. isFetching: false,
  31. plaidForm: form,
  32. };
  33. },
  34. methods: {
  35. $plaid: function (): Builder {
  36. return plaid().vueContext(this).form(form).vars((this as any).vars)
  37. }
  38. }
  39. })