aloha-vue 1.2.256 → 1.2.258

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
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.256",
17
+ "version": "1.2.258",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -1,75 +1,82 @@
1
- import {
2
- computed,
3
- ref,
4
- toRef,
5
- } from "vue";
6
-
7
- import {
8
- autoUpdate,
9
- computePosition,
10
- flip,
11
- shift,
12
- } from "@floating-ui/vue";
13
-
14
- export default function PopoverAPI(props, {
15
- dropdownButtonRef = ref(undefined),
16
- dropdownRef = ref(undefined),
17
- }) {
18
- const floatingFlip = toRef(props, "floatingFlip");
19
- const floatingShift = toRef(props, "floatingShift");
20
- const placement = toRef(props, "placement");
21
-
22
- const cleanupPopper = ref(undefined);
23
-
24
- const middleware = computed(() => {
25
- const MIDDLEWARE = [];
26
- if (floatingFlip.value?.use) {
27
- MIDDLEWARE.push(
28
- flip(floatingFlip.value),
29
- );
30
- }
31
- if (floatingShift.value?.use) {
32
- MIDDLEWARE.push(
33
- shift(floatingShift.value),
34
- );
35
- }
36
-
37
- return MIDDLEWARE;
38
- });
39
-
40
- const startPopper = () => {
41
- if (!cleanupPopper.value) {
42
- cleanupPopper.value = autoUpdate(
43
- dropdownButtonRef.value.$el,
44
- dropdownRef.value,
45
- () => {
46
- computePosition(
47
- dropdownButtonRef.value.$el,
48
- dropdownRef.value,
49
- {
50
- placement: placement.value,
51
- middleware: middleware.value,
52
- },
53
- ).then(({ x, y }) => {
54
- Object.assign(dropdownRef.value.style, {
55
- left: `${ x }px`,
56
- top: `${ y }px`,
57
- });
58
- });
59
- }
60
- );
61
- }
62
- };
63
-
64
- const destroyPopover = () => {
65
- if (cleanupPopper.value) {
66
- cleanupPopper.value();
67
- cleanupPopper.value = undefined;
68
- }
69
- };
70
-
71
- return {
72
- destroyPopover,
73
- startPopper,
74
- };
75
- }
1
+ import {
2
+ computed,
3
+ ref,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import {
8
+ autoUpdate,
9
+ computePosition,
10
+ flip,
11
+ shift,
12
+ } from "@floating-ui/vue";
13
+
14
+ export default function PopoverAPI(props, {
15
+ dropdownButtonRef = ref(undefined),
16
+ dropdownRef = ref(undefined),
17
+ }) {
18
+ const floatingFlip = toRef(props, "floatingFlip");
19
+ const floatingShift = toRef(props, "floatingShift");
20
+ const placement = toRef(props, "placement");
21
+
22
+ const cleanupPopper = ref(undefined);
23
+
24
+ const middleware = computed(() => {
25
+ const MIDDLEWARE = [];
26
+ if (floatingFlip.value?.use) {
27
+ MIDDLEWARE.push(
28
+ flip(floatingFlip.value),
29
+ );
30
+ }
31
+ if (floatingShift.value?.use) {
32
+ MIDDLEWARE.push(
33
+ shift(floatingShift.value),
34
+ );
35
+ }
36
+
37
+ return MIDDLEWARE;
38
+ });
39
+
40
+ const startPopper = () => {
41
+ if (!cleanupPopper.value &&
42
+ dropdownButtonRef.value.$el &&
43
+ dropdownRef.value) {
44
+ cleanupPopper.value = autoUpdate(
45
+ dropdownButtonRef.value.$el,
46
+ dropdownRef.value,
47
+ () => {
48
+ if (!dropdownButtonRef.value.$el ||
49
+ !dropdownRef.value) {
50
+ return;
51
+ }
52
+
53
+ computePosition(
54
+ dropdownButtonRef.value.$el,
55
+ dropdownRef.value,
56
+ {
57
+ placement: placement.value,
58
+ middleware: middleware.value,
59
+ },
60
+ ).then(({ x, y }) => {
61
+ Object.assign(dropdownRef.value.style, {
62
+ left: `${ x }px`,
63
+ top: `${ y }px`,
64
+ });
65
+ });
66
+ }
67
+ );
68
+ }
69
+ };
70
+
71
+ const destroyPopover = () => {
72
+ if (cleanupPopper.value) {
73
+ cleanupPopper.value();
74
+ cleanupPopper.value = undefined;
75
+ }
76
+ };
77
+
78
+ return {
79
+ destroyPopover,
80
+ startPopper,
81
+ };
82
+ }
@@ -1,131 +1,139 @@
1
- import {
2
- computed,
3
- ref,
4
- toRef,
5
- } from "vue";
6
-
7
- import {
8
- getElementId,
9
- } from "../utils/utils";
10
- import {
11
- autoUpdate,
12
- computePosition,
13
- flip,
14
- limitShift,
15
- shift
16
- } from "@floating-ui/vue";
17
- import {
18
- clone,
19
- forEach,
20
- } from "lodash-es";
21
-
22
- export default function PopoverAPI(props, {
23
- isMenuOpen = computed(() => false),
24
- panelParentsOpen = ref([]),
25
- }) {
26
- const menuId = toRef(props, "menuId");
27
-
28
- const cleanupPopper = ref({});
29
- const menuRef = ref(undefined);
30
- const isEventCloseClickStarted = ref(false);
31
-
32
- const getElementLink = ({ id }) => {
33
- const ID = getElementId({
34
- menuId: menuId.value,
35
- id,
36
- suffix: "link",
37
- });
38
- return document.getElementById(ID);
39
- };
40
-
41
- const getElementPanel = ({ id }) => {
42
- const ID = getElementId({
43
- menuId: menuId.value,
44
- id,
45
- suffix: "panel",
46
- });
47
- return document.getElementById(ID);
48
- };
49
-
50
- const onClickEvent = $event => {
51
- if (!menuRef.value.contains($event.target)) {
52
- panelParentsOpen.value = [];
53
- }
54
- };
55
-
56
- const setEventCloseClick = () => {
57
- if (!isEventCloseClickStarted.value) {
58
- isEventCloseClickStarted.value = true;
59
- document.addEventListener("click", onClickEvent);
60
- }
61
- };
62
-
63
- const destroyEventCloseClick = () => {
64
- isEventCloseClickStarted.value = false;
65
- document.removeEventListener("click", onClickEvent);
66
- };
67
-
68
- const cleanupPopperCurrent = key => {
69
- if (cleanupPopper.value[key]) {
70
- cleanupPopper.value[key]();
71
- delete cleanupPopper.value[key];
72
- const PANEL_ELEMENT = getElementPanel({ id: key });
73
- PANEL_ELEMENT.style.removeProperty("left");
74
- PANEL_ELEMENT.style.removeProperty("top");
75
- }
76
- };
77
-
78
- const startPopper = () => {
79
- if (isMenuOpen.value) {
80
- return;
81
- }
82
- setEventCloseClick();
83
- const CLEANUP_POPPER = clone(cleanupPopper.value);
84
- forEach(panelParentsOpen.value, id => {
85
- if (cleanupPopper.value[id]) {
86
- delete CLEANUP_POPPER[id];
87
- return;
88
- }
89
- const LINK_ELEMENT = getElementLink({ id });
90
- const PANEL_ELEMENT = getElementPanel({ id });
91
- cleanupPopper.value[id] = autoUpdate(
92
- LINK_ELEMENT,
93
- PANEL_ELEMENT,
94
- () => {
95
- computePosition(
96
- LINK_ELEMENT,
97
- PANEL_ELEMENT,
98
- {
99
- placement: "right",
100
- middleware: [
101
- flip(),
102
- shift({ limiter: limitShift() }),
103
- ]
104
- },
105
- ).then(({ x, y }) => {
106
- Object.assign(PANEL_ELEMENT.style, {
107
- left: `${ x }px`,
108
- top: `${ y }px`,
109
- });
110
- });
111
- }
112
- );
113
- });
114
- forEach(CLEANUP_POPPER, (_, key) => {
115
- cleanupPopperCurrent(key);
116
- });
117
- };
118
-
119
- const destroyPopover = () => {
120
- forEach(cleanupPopper.value, (_, key) => {
121
- cleanupPopperCurrent(key);
122
- });
123
- destroyEventCloseClick();
124
- };
125
-
126
- return {
127
- destroyPopover,
128
- menuRef,
129
- startPopper,
130
- };
131
- }
1
+ import {
2
+ computed,
3
+ ref,
4
+ toRef,
5
+ } from "vue";
6
+
7
+ import {
8
+ getElementId,
9
+ } from "../utils/utils";
10
+ import {
11
+ autoUpdate,
12
+ computePosition,
13
+ flip,
14
+ limitShift,
15
+ shift
16
+ } from "@floating-ui/vue";
17
+ import {
18
+ clone,
19
+ forEach,
20
+ } from "lodash-es";
21
+
22
+ export default function PopoverAPI(props, {
23
+ isMenuOpen = computed(() => false),
24
+ panelParentsOpen = ref([]),
25
+ }) {
26
+ const menuId = toRef(props, "menuId");
27
+
28
+ const cleanupPopper = ref({});
29
+ const menuRef = ref(undefined);
30
+ const isEventCloseClickStarted = ref(false);
31
+
32
+ const getElementLink = ({ id }) => {
33
+ const ID = getElementId({
34
+ menuId: menuId.value,
35
+ id,
36
+ suffix: "link",
37
+ });
38
+ return document.getElementById(ID);
39
+ };
40
+
41
+ const getElementPanel = ({ id }) => {
42
+ const ID = getElementId({
43
+ menuId: menuId.value,
44
+ id,
45
+ suffix: "panel",
46
+ });
47
+ return document.getElementById(ID);
48
+ };
49
+
50
+ const onClickEvent = $event => {
51
+ if (!menuRef.value.contains($event.target)) {
52
+ panelParentsOpen.value = [];
53
+ }
54
+ };
55
+
56
+ const setEventCloseClick = () => {
57
+ if (!isEventCloseClickStarted.value) {
58
+ isEventCloseClickStarted.value = true;
59
+ document.addEventListener("click", onClickEvent);
60
+ }
61
+ };
62
+
63
+ const destroyEventCloseClick = () => {
64
+ isEventCloseClickStarted.value = false;
65
+ document.removeEventListener("click", onClickEvent);
66
+ };
67
+
68
+ const cleanupPopperCurrent = key => {
69
+ if (cleanupPopper.value[key]) {
70
+ cleanupPopper.value[key]();
71
+ delete cleanupPopper.value[key];
72
+ const PANEL_ELEMENT = getElementPanel({ id: key });
73
+ PANEL_ELEMENT.style.removeProperty("left");
74
+ PANEL_ELEMENT.style.removeProperty("top");
75
+ }
76
+ };
77
+
78
+ const startPopper = () => {
79
+ if (isMenuOpen.value) {
80
+ return;
81
+ }
82
+ setEventCloseClick();
83
+ const CLEANUP_POPPER = clone(cleanupPopper.value);
84
+ forEach(panelParentsOpen.value, id => {
85
+ if (cleanupPopper.value[id]) {
86
+ delete CLEANUP_POPPER[id];
87
+ return;
88
+ }
89
+ const LINK_ELEMENT = getElementLink({ id });
90
+ const PANEL_ELEMENT = getElementPanel({ id });
91
+ if (!LINK_ELEMENT ||
92
+ !PANEL_ELEMENT) {
93
+ return;
94
+ }
95
+ cleanupPopper.value[id] = autoUpdate(
96
+ LINK_ELEMENT,
97
+ PANEL_ELEMENT,
98
+ () => {
99
+ if (!LINK_ELEMENT ||
100
+ !PANEL_ELEMENT) {
101
+ return;
102
+ }
103
+ computePosition(
104
+ LINK_ELEMENT,
105
+ PANEL_ELEMENT,
106
+ {
107
+ placement: "right",
108
+ middleware: [
109
+ flip(),
110
+ shift({ limiter: limitShift() }),
111
+ ]
112
+ },
113
+ ).then(({ x, y }) => {
114
+ Object.assign(PANEL_ELEMENT.style, {
115
+ left: `${ x }px`,
116
+ top: `${ y }px`,
117
+ });
118
+ });
119
+ }
120
+ );
121
+ });
122
+ forEach(CLEANUP_POPPER, (_, key) => {
123
+ cleanupPopperCurrent(key);
124
+ });
125
+ };
126
+
127
+ const destroyPopover = () => {
128
+ forEach(cleanupPopper.value, (_, key) => {
129
+ cleanupPopperCurrent(key);
130
+ });
131
+ destroyEventCloseClick();
132
+ };
133
+
134
+ return {
135
+ destroyPopover,
136
+ menuRef,
137
+ startPopper,
138
+ };
139
+ }
@@ -5,6 +5,7 @@ import {
5
5
  } from "vue";
6
6
 
7
7
  import {
8
+ debounce,
8
9
  get,
9
10
  } from "lodash-es";
10
11
 
@@ -33,9 +34,11 @@ export default function ObservingAPI(props, {
33
34
  if (isBtnHiddenDependentOnTextLength.value) {
34
35
  return;
35
36
  }
36
- observer.value = new ResizeObserver(() => {
37
- checkHeight();
38
- });
37
+ observer.value = new ResizeObserver(
38
+ debounce(() => {
39
+ checkHeight();
40
+ }, 300)
41
+ );
39
42
  observer.value.observe(containerRef.value);
40
43
  };
41
44
 
@@ -7,6 +7,7 @@ import {
7
7
  import PreviewRightRewAPI from "./PreviewRightRewAPI";
8
8
 
9
9
  import {
10
+ debounce,
10
11
  get,
11
12
  } from "lodash-es";
12
13
 
@@ -90,14 +91,16 @@ export default function PreviewRightResizeAPI(props, { emit }, {
90
91
  });
91
92
  };
92
93
 
93
- const resizeOb = new ResizeObserver(entries => {
94
- // since we are observing only a single element, so we access the first element in entries array
95
- const RECT = entries[0].contentRect;
96
- if (tableGrandparentWidth !== RECT.width) {
97
- tableGrandparentWidth = RECT.width;
98
- correctTableUndPreviewWidth();
99
- }
100
- });
94
+ const resizeOb = new ResizeObserver(
95
+ debounce(entries => {
96
+ // since we are observing only a single element, so we access the first element in entries array
97
+ const RECT = entries[0].contentRect;
98
+ if (tableGrandparentWidth !== RECT.width) {
99
+ tableGrandparentWidth = RECT.width;
100
+ correctTableUndPreviewWidth();
101
+ }
102
+ }, 300)
103
+ );
101
104
 
102
105
  const addEventListenerWindowResize = () => {
103
106
  resizeOb.observe(tableGrandparentRef.value);
@@ -12,6 +12,7 @@ import {
12
12
  } from "../utils/utils.js";
13
13
  import {
14
14
  cloneDeep,
15
+ debounce,
15
16
  forEach,
16
17
  isNil,
17
18
  isUndefined,
@@ -35,7 +36,6 @@ export default function ScrollControlAPI(props, { emit }, {
35
36
 
36
37
  const aTableRef = ref(undefined);
37
38
  const columnsVisibleAdditionalSpaceForOneGrow = ref(0);
38
- const resizeTimeout = ref(undefined);
39
39
  const tableWidth = ref(undefined);
40
40
  let changingTableWidth = false;
41
41
  const delta = 20; // approx scrollbar width + 2px for <tr> border
@@ -179,18 +179,16 @@ export default function ScrollControlAPI(props, { emit }, {
179
179
  }
180
180
  };
181
181
 
182
- const resizeOb = new ResizeObserver(entries => {
183
- // since we are observing only a single element, so we access the first element in entries array
184
- if (isUndefined(tableWidth.value)) {
185
- adjustTableWidth({ entries, forceAdjust: true });
186
- } else {
187
- clearTimeout(resizeTimeout.value);
188
-
189
- resizeTimeout.value = setTimeout(() => {
182
+ const resizeOb = new ResizeObserver(
183
+ debounce(entries => {
184
+ // since we are observing only a single element, so we access the first element in entries array
185
+ if (isUndefined(tableWidth.value)) {
186
+ adjustTableWidth({ entries, forceAdjust: true });
187
+ } else {
190
188
  adjustTableWidth({ entries });
191
- }, 300);
192
- }
193
- });
189
+ }
190
+ }, 300)
191
+ );
194
192
 
195
193
  const onWatchMobileScrollControl = newValue => {
196
194
  if (newValue) {