@signal24/vue-foundation 4.13.1 → 4.13.2
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.
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { ObjectDirective } from 'vue';
|
|
2
|
-
|
|
2
|
+
interface ConfirmButtonOptions {
|
|
3
|
+
text?: string | null;
|
|
4
|
+
class?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const vConfirmButton: ObjectDirective<HTMLElement, ConfirmButtonOptions>;
|
|
7
|
+
export {};
|
|
@@ -1042,24 +1042,26 @@ function ve(e, t) {
|
|
|
1042
1042
|
const rn = {
|
|
1043
1043
|
mounted: an
|
|
1044
1044
|
}, A = Symbol("ConfirmState");
|
|
1045
|
-
function an(e) {
|
|
1046
|
-
e.addEventListener("click", (
|
|
1047
|
-
|
|
1045
|
+
function an(e, t) {
|
|
1046
|
+
e.addEventListener("click", (n) => {
|
|
1047
|
+
var r, l;
|
|
1048
|
+
const i = Date.now(), s = ((r = t.value) == null ? void 0 : r.text) !== void 0 ? t.value.text : "Confirm";
|
|
1048
1049
|
if (e[A]) {
|
|
1049
|
-
if (
|
|
1050
|
+
if (i - e[A].initTime < 300)
|
|
1050
1051
|
return;
|
|
1051
1052
|
e[A].resetHandler(), e.dispatchEvent(new Event("confirm"));
|
|
1052
1053
|
return;
|
|
1053
1054
|
}
|
|
1054
|
-
|
|
1055
|
-
const
|
|
1056
|
-
initTime:
|
|
1055
|
+
n.preventDefault(), n.stopImmediatePropagation();
|
|
1056
|
+
const o = {
|
|
1057
|
+
initTime: i,
|
|
1057
1058
|
preconfirmHtml: e.innerHTML,
|
|
1058
1059
|
resetHandler: () => {
|
|
1059
|
-
|
|
1060
|
+
var a;
|
|
1061
|
+
s && (e.innerHTML = o.preconfirmHtml), (a = t.value) != null && a.class && e.classList.remove(t.value.class), e.blur(), e.removeEventListener("mouseout", o.resetHandler), delete e[A];
|
|
1060
1062
|
}
|
|
1061
1063
|
};
|
|
1062
|
-
e[A] =
|
|
1064
|
+
e[A] = o, s && (e.innerHTML = s), (l = t.value) != null && l.class && e.classList.add(t.value.class), e.addEventListener("mouseout", o.resetHandler);
|
|
1063
1065
|
});
|
|
1064
1066
|
}
|
|
1065
1067
|
const cn = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import type { DirectiveBinding } from 'vue';
|
|
1
2
|
import type { ObjectDirective } from 'vue';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
interface ConfirmButtonOptions {
|
|
5
|
+
text?: string | null;
|
|
6
|
+
class?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const vConfirmButton: ObjectDirective<HTMLElement, ConfirmButtonOptions> = {
|
|
4
10
|
mounted: fn
|
|
5
11
|
};
|
|
6
12
|
|
|
@@ -14,9 +20,10 @@ interface IConfirmElement {
|
|
|
14
20
|
[ConfirmState]?: IConfirmState;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
|
-
function fn(el: HTMLElement & IConfirmElement) {
|
|
23
|
+
function fn(el: HTMLElement & IConfirmElement, binding: DirectiveBinding<ConfirmButtonOptions>) {
|
|
18
24
|
el.addEventListener('click', e => {
|
|
19
25
|
const now = Date.now();
|
|
26
|
+
const confirmText = binding.value?.text !== undefined ? binding.value.text : 'Confirm';
|
|
20
27
|
|
|
21
28
|
if (el[ConfirmState]) {
|
|
22
29
|
if (now - el[ConfirmState].initTime < 300) {
|
|
@@ -35,15 +42,18 @@ function fn(el: HTMLElement & IConfirmElement) {
|
|
|
35
42
|
initTime: now,
|
|
36
43
|
preconfirmHtml: el.innerHTML,
|
|
37
44
|
resetHandler: () => {
|
|
38
|
-
el.innerHTML = confirmState.preconfirmHtml;
|
|
45
|
+
if (confirmText) el.innerHTML = confirmState.preconfirmHtml;
|
|
46
|
+
if (binding.value?.class) el.classList.remove(binding.value.class);
|
|
39
47
|
el.blur();
|
|
40
48
|
|
|
41
49
|
el.removeEventListener('mouseout', confirmState.resetHandler);
|
|
42
50
|
delete el[ConfirmState];
|
|
43
51
|
}
|
|
44
52
|
};
|
|
53
|
+
|
|
45
54
|
el[ConfirmState] = confirmState;
|
|
46
|
-
el.innerHTML =
|
|
55
|
+
if (confirmText) el.innerHTML = confirmText;
|
|
56
|
+
if (binding.value?.class) el.classList.add(binding.value.class);
|
|
47
57
|
|
|
48
58
|
el.addEventListener('mouseout', confirmState.resetHandler);
|
|
49
59
|
});
|