@webitel/ui-sdk 3.2.87 → 3.2.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "3.2.87",
3
+ "version": "3.2.88",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -2,12 +2,11 @@ import { mount } from '@vue/test-utils';
2
2
  import { ref } from 'vue';
3
3
  import AuditForm from '../audit-form.vue';
4
4
  import { generateQuestionSchema } from '../../schemas/AuditFormQuestionSchema';
5
-
6
5
  import {
7
6
  useDestroyableSortable,
8
- } from '../../composables/useDestroyableSortable';
7
+ } from '../../../../composables/useDestroyableSortable/useDestroyableSortable';
9
8
 
10
- jest.mock('../../composables/useDestroyableSortable');
9
+ jest.mock('../../../../composables/useDestroyableSortable/useDestroyableSortable');
11
10
 
12
11
  useDestroyableSortable.mockImplementation(() => ({ reloadSortable: ref(false) }));
13
12
 
@@ -37,7 +37,7 @@ import {
37
37
  reactive, nextTick,
38
38
  } from 'vue';
39
39
  import { useVuelidate } from '@vuelidate/core';
40
- import { useDestroyableSortable } from '../composables/useDestroyableSortable';
40
+ import { useDestroyableSortable } from '../../../composables/useDestroyableSortable/useDestroyableSortable';
41
41
  import AuditFormQuestion from './audit-form-question.vue';
42
42
  import WtButton from '../../../components/atoms/wt-button/wt-button.vue';
43
43
  import { generateQuestionSchema } from '../schemas/AuditFormQuestionSchema';
@@ -1,66 +0,0 @@
1
- import Sortable from 'sortablejs';
2
- import {
3
- ref,
4
- nextTick,
5
- onMounted,
6
- onUnmounted,
7
- } from 'vue';
8
-
9
- /**
10
- * @param elRef
11
- * @param options
12
- * @returns {{reloadSortable: Ref<UnwrapRef<boolean>>}}
13
- *
14
- * @description initializes Sortable on passed element ref and reinitializes it after each reorder
15
- *
16
- * WHY TO REINITIALIZE SORTABLE AFTER EACH ARRAY REORDER?
17
- * Sortable and Vue both changing DOM so that there are collisions
18
- * because both Vue and Sortable try to put element to the position. So element is put incorrectly.
19
- *
20
- * There are 2 vue packages for sortable (vue 2 and vue 3), but I had encountered issues when tried to use them.
21
- * Also, it seems to me that they aren't supported now :(
22
- *
23
- * So that I decided to reinitialize Sortable each time order changes to represent it correctly.
24
- * Bad decision, but I haven't come up with a better one
25
- */
26
-
27
- // eslint-disable-next-line import/prefer-default-export
28
- export function useDestroyableSortable(elRef, options) {
29
- let sortable = null;
30
-
31
- const reloadSortable = ref(false);
32
-
33
- function destroySortable() {
34
- return sortable.destroy();
35
- }
36
-
37
- function initSortable() {
38
- const replaceSortable = async () => {
39
- if (!sortable) return;
40
- destroySortable();
41
- reloadSortable.value = true;
42
- await nextTick();
43
- reloadSortable.value = false;
44
- await nextTick();
45
- initSortable();
46
- };
47
-
48
- sortable = Sortable.create(elRef.value, {
49
- ...options,
50
- onEnd: async (e) => {
51
- if (options.onEnd) options.onEnd(e);
52
- await replaceSortable();
53
- },
54
- });
55
- }
56
-
57
- onMounted(() => {
58
- initSortable();
59
- });
60
-
61
- onUnmounted(() => {
62
- destroySortable();
63
- });
64
-
65
- return { reloadSortable };
66
- }