@signal24/vue-foundation 4.30.3 → 4.30.4
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/dist/src/components/alert-helpers.d.ts +1 -0
- package/dist/src/config.d.ts +1 -0
- package/dist/src/directives/sticky-min-width.d.ts +1 -1
- package/dist/src/directives/tooltip.d.ts +2 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/vue-foundation.es.js +660 -642
- package/package.json +1 -1
- package/src/components/alert-helpers.ts +1 -0
- package/src/components/vf-alert-modal.vue +3 -3
- package/src/config.ts +1 -0
- package/src/directives/sticky-min-width.ts +36 -15
- package/src/directives/tooltip.ts +14 -1
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
<i v-if="iconClass" :class="['vf-alert-icon', iconClass]" />
|
|
8
8
|
|
|
9
|
-
<div v-if="isHtml" :
|
|
10
|
-
<div v-else :innerText="
|
|
9
|
+
<div v-if="isHtml" :innerHTML="resolvedMessage" class="user-message"></div>
|
|
10
|
+
<div v-else :innerText="resolvedMessage"></div>
|
|
11
11
|
|
|
12
12
|
<template v-if="!isBare" #footer>
|
|
13
13
|
<template v-if="shouldConfirm">
|
|
@@ -36,7 +36,7 @@ const props = defineProps<{
|
|
|
36
36
|
callback: (ok: boolean) => void;
|
|
37
37
|
}>();
|
|
38
38
|
|
|
39
|
-
const
|
|
39
|
+
const resolvedMessage = computed(() => {
|
|
40
40
|
if (props.message instanceof Error) {
|
|
41
41
|
return formatError(props.message);
|
|
42
42
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,24 +1,45 @@
|
|
|
1
1
|
import type { ObjectDirective } from 'vue';
|
|
2
2
|
|
|
3
|
+
import { VfOptions } from '@/config';
|
|
4
|
+
|
|
3
5
|
const ObserverMap = new WeakMap<HTMLElement, ResizeObserver>();
|
|
4
6
|
|
|
5
|
-
export const vStickyMinWidth: ObjectDirective<HTMLElement> = {
|
|
6
|
-
beforeMount(el) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const computedMinWidth = computedMinWidthStr ? parseInt(computedMinWidthStr, 10) : 0;
|
|
10
|
-
if (el.clientWidth <= computedMinWidth) return;
|
|
11
|
-
el.style.minWidth = `${el.clientWidth}px`;
|
|
12
|
-
});
|
|
13
|
-
ObserverMap.set(el, observer);
|
|
14
|
-
observer.observe(el);
|
|
7
|
+
export const vStickyMinWidth: ObjectDirective<HTMLElement, boolean | undefined> = {
|
|
8
|
+
beforeMount(el, binding) {
|
|
9
|
+
if (binding.value === false || VfOptions.disableStickyMinWidthDirective) return;
|
|
10
|
+
setup(el);
|
|
15
11
|
},
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
updated(el, binding) {
|
|
14
|
+
if (binding.value !== binding.oldValue) {
|
|
15
|
+
if (binding.value === false || VfOptions.disableStickyMinWidthDirective) {
|
|
16
|
+
teardown(el);
|
|
17
|
+
} else {
|
|
18
|
+
setup(el);
|
|
19
|
+
}
|
|
22
20
|
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
beforeUnmount(el) {
|
|
24
|
+
teardown(el);
|
|
23
25
|
}
|
|
24
26
|
};
|
|
27
|
+
|
|
28
|
+
function setup(el: HTMLElement) {
|
|
29
|
+
const observer = new ResizeObserver(() => {
|
|
30
|
+
const computedMinWidthStr = window.getComputedStyle(el).minWidth.match(/^(\d+)px$/)?.[1];
|
|
31
|
+
const computedMinWidth = computedMinWidthStr ? parseInt(computedMinWidthStr, 10) : 0;
|
|
32
|
+
if (el.clientWidth <= computedMinWidth) return;
|
|
33
|
+
el.style.minWidth = `${el.clientWidth}px`;
|
|
34
|
+
});
|
|
35
|
+
ObserverMap.set(el, observer);
|
|
36
|
+
observer.observe(el);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function teardown(el: HTMLElement) {
|
|
40
|
+
const observer = ObserverMap.get(el);
|
|
41
|
+
if (observer) {
|
|
42
|
+
observer.unobserve(el);
|
|
43
|
+
ObserverMap.delete(el);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { DirectiveBinding, ObjectDirective } from 'vue';
|
|
2
2
|
|
|
3
|
+
import { showAlert } from '@/components';
|
|
4
|
+
|
|
3
5
|
type TooltipValue = string | null | false | undefined;
|
|
4
6
|
|
|
5
7
|
export const vTooltip: ObjectDirective<TooltipElement, TooltipValue> = {
|
|
@@ -21,7 +23,8 @@ function createTip(el: TooltipElement, binding: DirectiveBinding<TooltipValue>)
|
|
|
21
23
|
if (tipText) {
|
|
22
24
|
const config: ITooltipOptions = {
|
|
23
25
|
content: tipText,
|
|
24
|
-
html: el.getAttribute('html') !== null
|
|
26
|
+
html: el.getAttribute('html') !== null,
|
|
27
|
+
alertOnTap: el.getAttribute('alert-on-tap') !== null
|
|
25
28
|
};
|
|
26
29
|
|
|
27
30
|
if (!el[TooltipState]) {
|
|
@@ -45,6 +48,7 @@ interface ITooltipOptions {
|
|
|
45
48
|
delay?: number;
|
|
46
49
|
html?: boolean;
|
|
47
50
|
class?: string | string[];
|
|
51
|
+
alertOnTap?: boolean;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
// todo: improve with mutation observer to see removal of node
|
|
@@ -69,6 +73,7 @@ class VfTooltip {
|
|
|
69
73
|
el.addEventListener('mouseenter', this.handleTargetMouseEnterWithContext);
|
|
70
74
|
el.addEventListener('mouseleave', this.handleTargetMouseLeaveWithContext);
|
|
71
75
|
el.addEventListener('click', this.handleTargetMouseLeaveWithContext);
|
|
76
|
+
if (config.alertOnTap) el.addEventListener('touchstart', () => this.showTapAlert());
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
configure(config: ITooltipOptions) {
|
|
@@ -93,6 +98,14 @@ class VfTooltip {
|
|
|
93
98
|
if (e) this.handleMouseMove(e);
|
|
94
99
|
}
|
|
95
100
|
|
|
101
|
+
showTapAlert() {
|
|
102
|
+
showAlert({
|
|
103
|
+
title: this.config.title,
|
|
104
|
+
message: this.config.content,
|
|
105
|
+
isHtml: this.config.html ?? false
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
96
109
|
renderTooltip() {
|
|
97
110
|
if (!this.tipEl) {
|
|
98
111
|
this.tipEl = document.createElement('div');
|