@signal24/vue-foundation 4.13.1 → 4.13.3
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 {};
|
|
@@ -2,5 +2,5 @@ export { escapeHtml } from '@vue/shared';
|
|
|
2
2
|
export declare function nl2br(value: string): string;
|
|
3
3
|
export declare function desnakeCase(value: string): string;
|
|
4
4
|
export declare function formatPhone(value: string): string;
|
|
5
|
-
export declare function formatUSCurrency(value: string | number): string;
|
|
5
|
+
export declare function formatUSCurrency(value: string | number, divisor?: number): string;
|
|
6
6
|
export declare function uuid(): string;
|
|
@@ -460,8 +460,8 @@ function xt(e) {
|
|
|
460
460
|
const t = e.replace(/\D/g, "").replace(/^1/, "");
|
|
461
461
|
return t.length != 10 ? e : "(" + t.substring(0, 3) + ") " + t.substring(3, 6) + "-" + t.substring(6);
|
|
462
462
|
}
|
|
463
|
-
function Lt(e) {
|
|
464
|
-
return "$" + Number(e).toFixed(3).replace(/0$/, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
463
|
+
function Lt(e, t = 1) {
|
|
464
|
+
return "$" + (Number(e) / t).toFixed(3).replace(/0$/, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
465
465
|
}
|
|
466
466
|
function Kn() {
|
|
467
467
|
return St();
|
|
@@ -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
|
});
|
package/src/helpers/string.ts
CHANGED
|
@@ -18,10 +18,10 @@ export function formatPhone(value: string) {
|
|
|
18
18
|
return '(' + cleanValue.substring(0, 3) + ') ' + cleanValue.substring(3, 6) + '-' + cleanValue.substring(6);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function formatUSCurrency(value: string | number) {
|
|
21
|
+
export function formatUSCurrency(value: string | number, divisor = 1) {
|
|
22
22
|
return (
|
|
23
23
|
'$' +
|
|
24
|
-
Number(value)
|
|
24
|
+
(Number(value) / divisor)
|
|
25
25
|
.toFixed(3)
|
|
26
26
|
.replace(/0$/, '')
|
|
27
27
|
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|