glib-web 4.35.9 → 4.35.11
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/actions/popovers/helper.js +7 -2
- package/actions/popovers/open.js +7 -8
- package/actions/popovers/show.js +3 -3
- package/app.vue +12 -1
- package/components/button.vue +1 -16
- package/components/component.vue +34 -2
- package/components/popover.vue +6 -4
- package/index.js +4 -2
- package/package.json +1 -1
- package/utils/launch/popover.js +7 -0
|
@@ -2,7 +2,12 @@ import { popovers } from "../../store";
|
|
|
2
2
|
|
|
3
3
|
function isExist(properties) {
|
|
4
4
|
const isPoped = popovers.value.map((v) => v.spec.key).includes(properties.key);
|
|
5
|
-
return
|
|
5
|
+
return isPoped;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function closeAllExcept(properties) {
|
|
9
|
+
const items = popovers.value.filter((v) => v.spec.key != properties.key);
|
|
10
|
+
items.forEach((popover) => popover.close());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { isExist, closeAllExcept };
|
package/actions/popovers/open.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import eventBus from "../../utils/eventBus";
|
|
2
2
|
import http from "../../utils/http";
|
|
3
|
-
import { isExist } from "./helper";
|
|
3
|
+
import { closeAllExcept, isExist } from "./helper";
|
|
4
4
|
|
|
5
5
|
export default class {
|
|
6
6
|
execute(properties, component) {
|
|
7
|
+
closeAllExcept(properties);
|
|
7
8
|
// show loading text
|
|
8
9
|
const prop = Object.assign({}, properties, { body: { childViews: [{ view: 'label', text: 'loading...', }] } }, { styleClasses: ['popovers-open'] });
|
|
9
10
|
|
|
10
11
|
if (!isExist(prop)) {
|
|
11
12
|
Utils.launch.popover.open(prop, component);
|
|
13
|
+
} else if (!prop.updateExisting) {
|
|
14
|
+
Utils.launch.popover.close(prop);
|
|
15
|
+
return;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
// send req to server and show response immediately
|
|
@@ -17,13 +21,8 @@ export default class {
|
|
|
17
21
|
'GET',
|
|
18
22
|
component,
|
|
19
23
|
(page) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
prop.body = page.body;
|
|
24
|
-
Utils.launch.popover.open(prop, component);
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
prop.body = page.body;
|
|
25
|
+
Utils.launch.popover.open(prop, component);
|
|
27
26
|
},
|
|
28
27
|
() => {
|
|
29
28
|
const page = { body: { childViews: [{ view: 'label', text: 'Something went wrong' }] } };
|
package/actions/popovers/show.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isExist } from "./helper";
|
|
1
|
+
import { closeAllExcept, isExist } from "./helper";
|
|
3
2
|
|
|
4
3
|
export default class {
|
|
5
4
|
execute(properties, component) {
|
|
5
|
+
closeAllExcept(properties);
|
|
6
6
|
if (isExist(properties)) {
|
|
7
|
-
|
|
7
|
+
Utils.launch.popover.close(properties);
|
|
8
8
|
} else {
|
|
9
9
|
Utils.launch.popover.open(properties, component);
|
|
10
10
|
}
|
package/app.vue
CHANGED
|
@@ -57,7 +57,7 @@ import FormPanel from "./components/panels/form.vue";
|
|
|
57
57
|
import { isRerender, vueApp } from "./store";
|
|
58
58
|
import { useSocket } from "./components/composable/socket";
|
|
59
59
|
import { usePasteable } from "./components/composable/pasteable";
|
|
60
|
-
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
|
60
|
+
import { computed, onBeforeUnmount, onMounted, provide, ref } from "vue";
|
|
61
61
|
import { TOOLTIP_ID } from "./constant";
|
|
62
62
|
import { watchGlibEvent } from "./store";
|
|
63
63
|
import { htmlElement } from "./components/helper";
|
|
@@ -70,22 +70,33 @@ export default {
|
|
|
70
70
|
usePasteable(filePaster);
|
|
71
71
|
const tooltipId = TOOLTIP_ID;
|
|
72
72
|
const appRef = ref(null);
|
|
73
|
+
const isChrome = !!window.chrome; // return true if browser is chrome, edge, or other chrome based engine
|
|
74
|
+
const mousePosition = ref({ x: null, y: null });
|
|
73
75
|
|
|
74
76
|
const handler = (event) => {
|
|
75
77
|
const { dirty } = event.detail;
|
|
76
78
|
vueApp.isFormDirty = dirty;
|
|
77
79
|
};
|
|
78
80
|
|
|
81
|
+
const handleMouseMove = (event) => {
|
|
82
|
+
mousePosition.value = { x: event.clientX, y: event.clientY };
|
|
83
|
+
};
|
|
84
|
+
|
|
79
85
|
onMounted(() => {
|
|
80
86
|
const el = htmlElement(appRef.value);
|
|
81
87
|
el.addEventListener('dirtyupdate', handler);
|
|
88
|
+
if (isChrome) el.addEventListener('mousemove', handleMouseMove);
|
|
82
89
|
});
|
|
83
90
|
|
|
84
91
|
onBeforeUnmount(() => {
|
|
85
92
|
const el = htmlElement(appRef.value);
|
|
86
93
|
el.removeEventListener('dirtyupdate', handler);
|
|
94
|
+
if (isChrome) el.removeEventListener('mousemove', handleMouseMove);
|
|
87
95
|
});
|
|
88
96
|
|
|
97
|
+
provide('mousePosition', mousePosition);
|
|
98
|
+
provide('isChrome', isChrome);
|
|
99
|
+
|
|
89
100
|
return { vueApp, tooltipId, appRef };
|
|
90
101
|
},
|
|
91
102
|
components: {
|
package/components/button.vue
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<common-button :style="$styles()" :class="$classes()" :spec="spec"
|
|
3
|
-
@[mleave]="handleMouseEvent(spec.onMouseLeave)" />
|
|
2
|
+
<common-button :style="$styles()" :class="$classes()" :spec="spec" />
|
|
4
3
|
</template>
|
|
5
4
|
|
|
6
5
|
<script>
|
|
@@ -8,20 +7,6 @@ export default {
|
|
|
8
7
|
props: {
|
|
9
8
|
spec: { type: Object, required: true }
|
|
10
9
|
},
|
|
11
|
-
// TODO: Reuse
|
|
12
|
-
computed: {
|
|
13
|
-
menter() {
|
|
14
|
-
return this.spec.onMouseEnter ? 'mouseenter' : null;
|
|
15
|
-
},
|
|
16
|
-
mleave() {
|
|
17
|
-
return this.spec.onMouseLeave ? 'mouseleave' : null;
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
methods: {
|
|
21
|
-
handleMouseEvent(spec) {
|
|
22
|
-
GLib.action.execute(spec, this);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
10
|
};
|
|
26
11
|
</script>
|
|
27
12
|
|
package/components/component.vue
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
</template>
|
|
31
31
|
|
|
32
32
|
<script>
|
|
33
|
-
import { defineAsyncComponent } from "vue";
|
|
33
|
+
import { defineAsyncComponent, getCurrentInstance, inject, onMounted, onUnmounted, ref } from "vue";
|
|
34
34
|
|
|
35
35
|
import H1 from "./h1.vue";
|
|
36
36
|
import H2 from "./h2.vue";
|
|
@@ -134,6 +134,7 @@ const ShareButton = defineAsyncComponent(() => import("./shareButton.vue"));
|
|
|
134
134
|
import tooltipMixin from "./mixins/tooltip";
|
|
135
135
|
|
|
136
136
|
import Skeleton from "./skeleton.vue";
|
|
137
|
+
import { htmlElement } from "./helper";
|
|
137
138
|
|
|
138
139
|
export default {
|
|
139
140
|
mixins: [tooltipMixin],
|
|
@@ -237,9 +238,40 @@ export default {
|
|
|
237
238
|
props: {
|
|
238
239
|
spec: { type: Object, required: true },
|
|
239
240
|
},
|
|
241
|
+
setup(props) {
|
|
242
|
+
const delegate = ref(null);
|
|
243
|
+
const instance = getCurrentInstance();
|
|
244
|
+
const isChrome = inject('isChrome');
|
|
245
|
+
const mousePosition = inject('mousePosition');
|
|
246
|
+
let num = null;
|
|
247
|
+
|
|
248
|
+
onMounted(() => {
|
|
249
|
+
// The onmouseleave event may not always execute when the cursor moves quickly in Chrome, so using setInterval can be a helpful workaround to manually trigger the required action.
|
|
250
|
+
if (props.spec.onMouseLeave && isChrome) {
|
|
251
|
+
num = setInterval(() => {
|
|
252
|
+
const el = htmlElement(delegate.value);
|
|
253
|
+
if (!el) return;
|
|
254
|
+
|
|
255
|
+
const mouseHoverEl = document.elementFromPoint(mousePosition.value.x, mousePosition.value.y);
|
|
256
|
+
const isHover = el.contains(mouseHoverEl);
|
|
257
|
+
|
|
258
|
+
if (!isHover) {
|
|
259
|
+
GLib.action.execute(props.spec.onMouseLeave, instance.ctx);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
}, 500);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
onUnmounted(() => {
|
|
267
|
+
if (num) clearInterval(num);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return { delegate };
|
|
271
|
+
},
|
|
240
272
|
data() {
|
|
241
273
|
return {
|
|
242
|
-
name: null
|
|
274
|
+
name: null,
|
|
243
275
|
// See events#$recursiveUpdate().
|
|
244
276
|
// $passthrough: true
|
|
245
277
|
};
|
package/components/popover.vue
CHANGED
|
@@ -25,6 +25,7 @@ import bus from "../utils/eventBus";
|
|
|
25
25
|
import { driver } from "driver.js";
|
|
26
26
|
import 'driver.js/dist/driver.css';
|
|
27
27
|
import { strandom } from "./helper";
|
|
28
|
+
import { APP_ID } from "..";
|
|
28
29
|
|
|
29
30
|
export default {
|
|
30
31
|
props: ['spec', 'reference', 'placeholder', 'styleClass'],
|
|
@@ -44,18 +45,19 @@ export default {
|
|
|
44
45
|
mounted() {
|
|
45
46
|
popovers.value.push(this);
|
|
46
47
|
bus.$on(`popovers/open-${this.spec.key}`, (body) => {
|
|
47
|
-
Object.assign(this.spec, body);
|
|
48
|
+
Object.assign(this.spec, { body });
|
|
48
49
|
this.key = strandom();
|
|
49
50
|
});
|
|
50
51
|
},
|
|
51
52
|
methods: {
|
|
52
53
|
$mounted() {
|
|
54
|
+
const appEl = document.getElementById(APP_ID);
|
|
53
55
|
bus.$once(`popover/close-${this.spec.key}`, (options) => {
|
|
54
|
-
|
|
56
|
+
appEl.removeEventListener('click', this.handleClose);
|
|
55
57
|
this.close();
|
|
56
58
|
});
|
|
57
59
|
if (!this.spec.persistent) {
|
|
58
|
-
|
|
60
|
+
appEl.addEventListener('click', this.handleClose);
|
|
59
61
|
window.addEventListener('resize', () => this.close());
|
|
60
62
|
}
|
|
61
63
|
if (this.spec.overlay) {
|
|
@@ -67,7 +69,7 @@ export default {
|
|
|
67
69
|
bus.$off(`popover/close-${this.spec.key}`);
|
|
68
70
|
bus.$off(`popover/open-${this.spec.key}`);
|
|
69
71
|
if (!this.spec.persistent) {
|
|
70
|
-
|
|
72
|
+
appEl.removeEventListener('click', this.handleClose);
|
|
71
73
|
window.removeEventListener('resize', () => this.close());
|
|
72
74
|
}
|
|
73
75
|
},
|
package/index.js
CHANGED
|
@@ -10,6 +10,8 @@ import './app.scss';
|
|
|
10
10
|
// lib for deep merge
|
|
11
11
|
import merge from 'lodash.merge';
|
|
12
12
|
|
|
13
|
+
const APP_ID = 'app';
|
|
14
|
+
|
|
13
15
|
const Vue = createApp({
|
|
14
16
|
setup() {
|
|
15
17
|
const themeConfig = useTheme();
|
|
@@ -142,7 +144,7 @@ Vue.use(vPhoneInput);
|
|
|
142
144
|
|
|
143
145
|
|
|
144
146
|
document.addEventListener("DOMContentLoaded", () => {
|
|
145
|
-
Vue.mount(
|
|
147
|
+
Vue.mount(`#${APP_ID}`);
|
|
146
148
|
});
|
|
147
149
|
|
|
148
150
|
function useGlibErrorReporter(endpointUrl = '/glib/errors') {
|
|
@@ -189,4 +191,4 @@ function useGlibErrorReporter(endpointUrl = '/glib/errors') {
|
|
|
189
191
|
});
|
|
190
192
|
}
|
|
191
193
|
|
|
192
|
-
export { Vue, settings, vueApp, useGlibErrorReporter };
|
|
194
|
+
export { Vue, settings, vueApp, useGlibErrorReporter, APP_ID };
|
package/package.json
CHANGED
package/utils/launch/popover.js
CHANGED
|
@@ -5,9 +5,16 @@ import { autoUpdate, computePosition, shift, offset, arrow, flip } from "@floati
|
|
|
5
5
|
|
|
6
6
|
import bus from "../eventBus";
|
|
7
7
|
import { htmlElement } from "../../components/helper";
|
|
8
|
+
import { isExist } from "../../actions/popovers/helper";
|
|
9
|
+
import eventBus from "../eventBus";
|
|
8
10
|
|
|
9
11
|
export default class LaunchPopover {
|
|
10
12
|
static open(properties, component) {
|
|
13
|
+
if (isExist(properties)) {
|
|
14
|
+
eventBus.$emit(`popovers/open-${properties.key}`, properties.body);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
const placeholder = document.createElement('div');
|
|
12
19
|
const arrowEl = document.createElement('div');
|
|
13
20
|
arrowEl.classList.add('popover-arrow');
|