@vrojs/base 0.0.12 → 0.0.13
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.
|
@@ -8,14 +8,8 @@ export declare const VroInput: import('..').WithInstall<import('vue').DefineComp
|
|
|
8
8
|
type: import('vue').PropType<string | number | null | undefined>;
|
|
9
9
|
default: string;
|
|
10
10
|
};
|
|
11
|
-
max:
|
|
12
|
-
|
|
13
|
-
default: number;
|
|
14
|
-
};
|
|
15
|
-
min: {
|
|
16
|
-
type: (NumberConstructor | StringConstructor)[];
|
|
17
|
-
default: number;
|
|
18
|
-
};
|
|
11
|
+
max: (NumberConstructor | StringConstructor)[];
|
|
12
|
+
min: (NumberConstructor | StringConstructor)[];
|
|
19
13
|
autoFix: BooleanConstructor;
|
|
20
14
|
maxlength: (NumberConstructor | StringConstructor)[];
|
|
21
15
|
placeholder: StringConstructor;
|
|
@@ -44,14 +38,8 @@ export declare const VroInput: import('..').WithInstall<import('vue').DefineComp
|
|
|
44
38
|
type: import('vue').PropType<string | number | null | undefined>;
|
|
45
39
|
default: string;
|
|
46
40
|
};
|
|
47
|
-
max:
|
|
48
|
-
|
|
49
|
-
default: number;
|
|
50
|
-
};
|
|
51
|
-
min: {
|
|
52
|
-
type: (NumberConstructor | StringConstructor)[];
|
|
53
|
-
default: number;
|
|
54
|
-
};
|
|
41
|
+
max: (NumberConstructor | StringConstructor)[];
|
|
42
|
+
min: (NumberConstructor | StringConstructor)[];
|
|
55
43
|
autoFix: BooleanConstructor;
|
|
56
44
|
maxlength: (NumberConstructor | StringConstructor)[];
|
|
57
45
|
placeholder: StringConstructor;
|
|
@@ -74,8 +62,6 @@ export declare const VroInput: import('..').WithInstall<import('vue').DefineComp
|
|
|
74
62
|
type: import('vue').InputTypeHTMLAttribute | "decimal";
|
|
75
63
|
modelValue: string | number | null | undefined;
|
|
76
64
|
disabled: boolean;
|
|
77
|
-
max: string | number;
|
|
78
|
-
min: string | number;
|
|
79
65
|
autoFix: boolean;
|
|
80
66
|
readonly: boolean;
|
|
81
67
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
@@ -22,22 +22,14 @@ export declare const vroInputProps: {
|
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* 最大值,仅当 type 为 decimal 时作为输入值上限使用。
|
|
25
|
-
*
|
|
26
|
-
* @default Number.MAX_SAFE_INTEGER
|
|
25
|
+
* 未设置时不限制上限。
|
|
27
26
|
*/
|
|
28
|
-
max:
|
|
29
|
-
type: (NumberConstructor | StringConstructor)[];
|
|
30
|
-
default: number;
|
|
31
|
-
};
|
|
27
|
+
max: (NumberConstructor | StringConstructor)[];
|
|
32
28
|
/**
|
|
33
29
|
* 最小值,仅当 type 为 decimal 时作为输入值下限使用。
|
|
34
|
-
*
|
|
35
|
-
* @default Number.MIN_SAFE_INTEGER
|
|
30
|
+
* 未设置时不限制下限,且允许输入负数。
|
|
36
31
|
*/
|
|
37
|
-
min:
|
|
38
|
-
type: (NumberConstructor | StringConstructor)[];
|
|
39
|
-
default: number;
|
|
40
|
-
};
|
|
32
|
+
min: (NumberConstructor | StringConstructor)[];
|
|
41
33
|
/**
|
|
42
34
|
* 输入值超出 min/max 后是否自动修正到边界值,仅当 type 为 decimal 时有效。
|
|
43
35
|
*
|
package/dist/vro-input/types.js
CHANGED
|
@@ -21,22 +21,14 @@ const e = {
|
|
|
21
21
|
},
|
|
22
22
|
/**
|
|
23
23
|
* 最大值,仅当 type 为 decimal 时作为输入值上限使用。
|
|
24
|
-
*
|
|
25
|
-
* @default Number.MAX_SAFE_INTEGER
|
|
24
|
+
* 未设置时不限制上限。
|
|
26
25
|
*/
|
|
27
|
-
max:
|
|
28
|
-
type: [String, Number],
|
|
29
|
-
default: Number.MAX_SAFE_INTEGER
|
|
30
|
-
},
|
|
26
|
+
max: [String, Number],
|
|
31
27
|
/**
|
|
32
28
|
* 最小值,仅当 type 为 decimal 时作为输入值下限使用。
|
|
33
|
-
*
|
|
34
|
-
* @default Number.MIN_SAFE_INTEGER
|
|
29
|
+
* 未设置时不限制下限,且允许输入负数。
|
|
35
30
|
*/
|
|
36
|
-
min:
|
|
37
|
-
type: [String, Number],
|
|
38
|
-
default: Number.MIN_SAFE_INTEGER
|
|
39
|
-
},
|
|
31
|
+
min: [String, Number],
|
|
40
32
|
/**
|
|
41
33
|
* 输入值超出 min/max 后是否自动修正到边界值,仅当 type 为 decimal 时有效。
|
|
42
34
|
*
|
|
@@ -7,14 +7,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
7
7
|
type: import('vue').PropType<string | number | null | undefined>;
|
|
8
8
|
default: string;
|
|
9
9
|
};
|
|
10
|
-
max:
|
|
11
|
-
|
|
12
|
-
default: number;
|
|
13
|
-
};
|
|
14
|
-
min: {
|
|
15
|
-
type: (NumberConstructor | StringConstructor)[];
|
|
16
|
-
default: number;
|
|
17
|
-
};
|
|
10
|
+
max: (NumberConstructor | StringConstructor)[];
|
|
11
|
+
min: (NumberConstructor | StringConstructor)[];
|
|
18
12
|
autoFix: BooleanConstructor;
|
|
19
13
|
maxlength: (NumberConstructor | StringConstructor)[];
|
|
20
14
|
placeholder: StringConstructor;
|
|
@@ -43,14 +37,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
43
37
|
type: import('vue').PropType<string | number | null | undefined>;
|
|
44
38
|
default: string;
|
|
45
39
|
};
|
|
46
|
-
max:
|
|
47
|
-
|
|
48
|
-
default: number;
|
|
49
|
-
};
|
|
50
|
-
min: {
|
|
51
|
-
type: (NumberConstructor | StringConstructor)[];
|
|
52
|
-
default: number;
|
|
53
|
-
};
|
|
40
|
+
max: (NumberConstructor | StringConstructor)[];
|
|
41
|
+
min: (NumberConstructor | StringConstructor)[];
|
|
54
42
|
autoFix: BooleanConstructor;
|
|
55
43
|
maxlength: (NumberConstructor | StringConstructor)[];
|
|
56
44
|
placeholder: StringConstructor;
|
|
@@ -73,8 +61,6 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
73
61
|
type: import('vue').InputTypeHTMLAttribute | "decimal";
|
|
74
62
|
modelValue: string | number | null | undefined;
|
|
75
63
|
disabled: boolean;
|
|
76
|
-
max: string | number;
|
|
77
|
-
min: string | number;
|
|
78
64
|
autoFix: boolean;
|
|
79
65
|
readonly: boolean;
|
|
80
66
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
@@ -1,62 +1,66 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { omit as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { parseNumberString as
|
|
5
|
-
import { vroInputProps as
|
|
6
|
-
const
|
|
1
|
+
import { defineComponent as F, ref as R, computed as _, createElementBlock as P, openBlock as O, mergeProps as w, unref as c } from "vue";
|
|
2
|
+
import { omit as D, isNumber as W } from "@daysnap/utils";
|
|
3
|
+
import { useId as j, useComposition as q } from "@vrojs/use";
|
|
4
|
+
import { parseNumberString as z, parseDecimalString as A } from "../utils/format.js";
|
|
5
|
+
import { vroInputProps as G } from "./types.js";
|
|
6
|
+
const H = ["value"], X = /* @__PURE__ */ F({
|
|
7
7
|
name: "VroInput",
|
|
8
8
|
__name: "vro-input",
|
|
9
|
-
props:
|
|
9
|
+
props: G,
|
|
10
10
|
emits: ["update:modelValue", "blur", "input"],
|
|
11
|
-
setup(
|
|
12
|
-
const m =
|
|
13
|
-
let { type:
|
|
14
|
-
return
|
|
15
|
-
...
|
|
16
|
-
id: m.id ??
|
|
17
|
-
type:
|
|
18
|
-
inputmode:
|
|
11
|
+
setup(C, { expose: S, emit: y }) {
|
|
12
|
+
const m = C, r = y, v = R(), I = j(), h = _(() => {
|
|
13
|
+
let { type: e, inputmode: t, ...n } = m;
|
|
14
|
+
return e === "decimal" ? (e = "text", t = "decimal") : e === "number" && (e = "tel", t = "numeric"), {
|
|
15
|
+
...D(n, ["autoFix", "formatter", "modelValue", "precision", "max", "min"]),
|
|
16
|
+
id: m.id ?? I,
|
|
17
|
+
type: e,
|
|
18
|
+
inputmode: t
|
|
19
19
|
};
|
|
20
|
-
}), { handleCompositionStart:
|
|
21
|
-
const { type:
|
|
22
|
-
if (
|
|
20
|
+
}), { handleCompositionStart: g, handleCompositionEnd: N } = q(), B = (e) => {
|
|
21
|
+
const { type: t, modelValue: n } = m;
|
|
22
|
+
if (t === "decimal") {
|
|
23
23
|
const i = n?.toString() ?? "";
|
|
24
24
|
i === "-" ? r("update:modelValue", "") : i.endsWith(".") ? r("update:modelValue", i.substring(0, i.length - 1)) : i !== "" && +i == 0 && r("update:modelValue", "0");
|
|
25
25
|
}
|
|
26
|
-
r("blur",
|
|
27
|
-
},
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
26
|
+
r("blur", e);
|
|
27
|
+
}, V = (e) => e != null && e !== "" && Number.isFinite(Number(e)), k = (e) => {
|
|
28
|
+
const t = e.target;
|
|
29
|
+
if (t?.composing)
|
|
30
30
|
return;
|
|
31
|
-
const { type: n, precision: i, min: s, max: f, formatter:
|
|
32
|
-
let
|
|
31
|
+
const { type: n, precision: i, min: s, max: f, formatter: x, modelValue: a, autoFix: E } = m;
|
|
32
|
+
let o = t.value;
|
|
33
33
|
if (n === "number")
|
|
34
|
-
|
|
34
|
+
o = z(o);
|
|
35
35
|
else if (n === "decimal") {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const l = V(s), b = V(f);
|
|
37
|
+
o = A(o, {
|
|
38
|
+
precision: +i,
|
|
39
|
+
allowNegativeNumber: !l || Number(s) < 0
|
|
40
|
+
});
|
|
41
|
+
const p = l ? Number(s) : void 0, d = b ? Number(f) : void 0, u = Number(o);
|
|
42
|
+
o !== "" && o !== "-" && Number.isFinite(u) && (l && p !== void 0 && u < p || b && d !== void 0 && u > d) && (E ? l && p !== void 0 && u < p ? o = String(s) : b && d !== void 0 && u > d && (o = String(f)) : o = a?.toString() ?? "");
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
x && (o = x(o, W(a) ? a.toString() : a ?? "")), t.value !== o && (t.value = o), r("update:modelValue", o), r("input", e);
|
|
41
45
|
};
|
|
42
|
-
return
|
|
46
|
+
return S({
|
|
43
47
|
get input() {
|
|
44
|
-
return
|
|
48
|
+
return v.value;
|
|
45
49
|
}
|
|
46
|
-
}), (
|
|
50
|
+
}), (e, t) => (O(), P("input", w(h.value, {
|
|
47
51
|
class: "vro-input",
|
|
48
52
|
ref_key: "inputRef",
|
|
49
|
-
ref:
|
|
50
|
-
value:
|
|
51
|
-
onCompositionstart:
|
|
52
|
-
(...n) =>
|
|
53
|
-
onCompositionend:
|
|
54
|
-
(...n) =>
|
|
55
|
-
onInput:
|
|
56
|
-
onBlur:
|
|
57
|
-
}), null, 16,
|
|
53
|
+
ref: v,
|
|
54
|
+
value: e.modelValue ?? "",
|
|
55
|
+
onCompositionstart: t[0] || (t[0] = //@ts-ignore
|
|
56
|
+
(...n) => c(g) && c(g)(...n)),
|
|
57
|
+
onCompositionend: t[1] || (t[1] = //@ts-ignore
|
|
58
|
+
(...n) => c(N) && c(N)(...n)),
|
|
59
|
+
onInput: k,
|
|
60
|
+
onBlur: B
|
|
61
|
+
}), null, 16, H));
|
|
58
62
|
}
|
|
59
63
|
});
|
|
60
64
|
export {
|
|
61
|
-
|
|
65
|
+
X as default
|
|
62
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vrojs/base",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "vrojs ui",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"vite": "^7.1.12",
|
|
42
42
|
"vite-plugin-dts": "^4.5.4",
|
|
43
43
|
"vue": "^3.5.22",
|
|
44
|
-
"@vrojs/use": "0.0.
|
|
44
|
+
"@vrojs/use": "0.0.7"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "npm run clean && vite build",
|