matrix_components 2.0.359 → 2.0.360
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/README.md +7 -0
- package/dist/ComponentDemo/Test.vue +91 -1
- package/dist/matrix_components.js +81 -11
- package/dist/matrix_components.umd.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<span>当前: "{{ numberInput }}" ({{ numberInput.length }}/8)</span>
|
|
32
32
|
</div>
|
|
33
33
|
|
|
34
|
-
<h3
|
|
34
|
+
<h3>正则模式(不支持小数,使用v-length.range) - v-length.regex</h3>
|
|
35
35
|
<div class="input-group">
|
|
36
36
|
<label>字母数字,限制6位:</label>
|
|
37
37
|
<el-input
|
|
@@ -42,6 +42,87 @@
|
|
|
42
42
|
/>
|
|
43
43
|
<span>当前: "{{ regexInput }}" ({{ regexInput.length }}/6)</span>
|
|
44
44
|
</div>
|
|
45
|
+
|
|
46
|
+
<h3>范围模式 - v-length.range</h3>
|
|
47
|
+
<div class="input-group">
|
|
48
|
+
<label>数字范围 0-100:</label>
|
|
49
|
+
<el-input
|
|
50
|
+
v-model="rangeInput1"
|
|
51
|
+
v-length.range="{ min: 0, max: 100 }"
|
|
52
|
+
placeholder="输入0-100之间的数字"
|
|
53
|
+
style="width: 300px;"
|
|
54
|
+
/>
|
|
55
|
+
<span>当前: "{{ rangeInput1 }}"</span>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="input-group">
|
|
59
|
+
<label>负数范围 -50到50:</label>
|
|
60
|
+
<el-input
|
|
61
|
+
v-model="rangeInput2"
|
|
62
|
+
v-length.range="{ min: -50, max: 50, maxLength: 10 }"
|
|
63
|
+
placeholder="输入-50到50之间的数字"
|
|
64
|
+
style="width: 300px;"
|
|
65
|
+
/>
|
|
66
|
+
<span>当前: "{{ rangeInput2 }}"</span>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<div class="input-group">
|
|
70
|
+
<label>小数范围 0.1-99.9:</label>
|
|
71
|
+
<el-input
|
|
72
|
+
v-model="rangeInput3"
|
|
73
|
+
v-length.range="{ min: 0.1, max: 99.9 }"
|
|
74
|
+
placeholder="输入0.1-99.9之间的小数"
|
|
75
|
+
style="width: 300px;"
|
|
76
|
+
/>
|
|
77
|
+
<span>当前: "{{ rangeInput3 }}"</span>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div class="input-group">
|
|
81
|
+
<label>百分比范围 0-100%:</label>
|
|
82
|
+
<el-input
|
|
83
|
+
v-model="rangeInput4"
|
|
84
|
+
v-length.range="{ min: 0, max: 100, maxLength: 5 }"
|
|
85
|
+
placeholder="输入0-100之间的百分比数值"
|
|
86
|
+
style="width: 300px;"
|
|
87
|
+
>
|
|
88
|
+
<template #suffix>%</template>
|
|
89
|
+
</el-input>
|
|
90
|
+
<span>当前: "{{ rangeInput4 }}%"</span>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<h3>整数范围模式 - v-length.range (integerOnly)</h3>
|
|
94
|
+
<div class="input-group">
|
|
95
|
+
<label>整数范围 0-100 (仅整数):</label>
|
|
96
|
+
<el-input
|
|
97
|
+
v-model="rangeInput5"
|
|
98
|
+
v-length.range="{ min: 0, max: 100, integerOnly: true }"
|
|
99
|
+
placeholder="仅能输入0-100之间的整数"
|
|
100
|
+
style="width: 300px;"
|
|
101
|
+
/>
|
|
102
|
+
<span>当前: "{{ rangeInput5 }}"</span>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div class="input-group">
|
|
106
|
+
<label>年龄范围 1-120 (仅整数):</label>
|
|
107
|
+
<el-input
|
|
108
|
+
v-model="rangeInput6"
|
|
109
|
+
v-length.range="{ min: 1, max: 120, integerOnly: true, maxLength: 3 }"
|
|
110
|
+
placeholder="输入年龄1-120岁"
|
|
111
|
+
style="width: 300px;"
|
|
112
|
+
/>
|
|
113
|
+
<span>当前: "{{ rangeInput6 }}"岁</span>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div class="input-group">
|
|
117
|
+
<label>负整数范围 -10到10 (仅整数):</label>
|
|
118
|
+
<el-input
|
|
119
|
+
v-model="rangeInput7"
|
|
120
|
+
v-length.range="{ min: -10, max: 10, integerOnly: true }"
|
|
121
|
+
placeholder="输入-10到10之间的整数"
|
|
122
|
+
style="width: 300px;"
|
|
123
|
+
/>
|
|
124
|
+
<span>当前: "{{ rangeInput7 }}"</span>
|
|
125
|
+
</div>
|
|
45
126
|
</div>
|
|
46
127
|
|
|
47
128
|
<!-- v-permission 指令演示 -->
|
|
@@ -154,6 +235,15 @@ const regexInput = ref('')
|
|
|
154
235
|
const chineseInput = ref('')
|
|
155
236
|
const autocompleteInput = ref('')
|
|
156
237
|
|
|
238
|
+
// v-length.range 演示数据
|
|
239
|
+
const rangeInput1 = ref('')
|
|
240
|
+
const rangeInput2 = ref('')
|
|
241
|
+
const rangeInput3 = ref('')
|
|
242
|
+
const rangeInput4 = ref('')
|
|
243
|
+
const rangeInput5 = ref('')
|
|
244
|
+
const rangeInput6 = ref('')
|
|
245
|
+
const rangeInput7 = ref('')
|
|
246
|
+
|
|
157
247
|
// v-permission 演示数据
|
|
158
248
|
const btnsPermission = ref(JSON.parse(sessionStorage.getItem('btnsPermission')) || ['add_btn', 'edit_btn', 'admin-btn'])
|
|
159
249
|
sessionStorage.setItem('btnsPermission', JSON.stringify(btnsPermission.value))
|
|
@@ -7318,14 +7318,17 @@ function registerDirective(app2) {
|
|
|
7318
7318
|
});
|
|
7319
7319
|
app2.directive("length", {
|
|
7320
7320
|
mounted(el2, binding) {
|
|
7321
|
-
var _a3, _b;
|
|
7321
|
+
var _a3, _b, _c2;
|
|
7322
7322
|
const config = parseBindingValue(binding);
|
|
7323
7323
|
const handleInput = (e6) => {
|
|
7324
|
-
var _a4, _b2;
|
|
7325
|
-
if ((_a4 = binding.modifiers) == null ? void 0 : _a4.
|
|
7324
|
+
var _a4, _b2, _c3;
|
|
7325
|
+
if ((_a4 = binding.modifiers) == null ? void 0 : _a4.range) {
|
|
7326
|
+
e6.target.value = formatRangeInput(e6.target.value, config);
|
|
7327
|
+
e6.target.dispatchEvent(new Event("input"));
|
|
7328
|
+
} else if ((_b2 = binding.modifiers) == null ? void 0 : _b2.number) {
|
|
7326
7329
|
e6.target.value = formatNumberInput(e6.target.value, config.maxLength);
|
|
7327
7330
|
e6.target.dispatchEvent(new Event("input"));
|
|
7328
|
-
} else if (((
|
|
7331
|
+
} else if (((_c3 = binding.modifiers) == null ? void 0 : _c3.regex) && config.pattern) {
|
|
7329
7332
|
e6.target.value = formatRegexInput(e6.target.value, config.maxLength, config.pattern);
|
|
7330
7333
|
e6.target.dispatchEvent(new Event("input"));
|
|
7331
7334
|
} else {
|
|
@@ -7336,10 +7339,13 @@ function registerDirective(app2) {
|
|
|
7336
7339
|
el2.addEventListener("input", handleInput);
|
|
7337
7340
|
el2.addEventListener("change", handleInput);
|
|
7338
7341
|
if (el2.tagName === "INPUT") {
|
|
7339
|
-
if ((_a3 = binding.modifiers) == null ? void 0 : _a3.
|
|
7342
|
+
if ((_a3 = binding.modifiers) == null ? void 0 : _a3.range) {
|
|
7343
|
+
el2.value = formatRangeInput(el2.value, config);
|
|
7344
|
+
el2.dispatchEvent(new Event("input"));
|
|
7345
|
+
} else if ((_b = binding.modifiers) == null ? void 0 : _b.number) {
|
|
7340
7346
|
el2.value = formatNumberInput(el2.value, config.maxLength);
|
|
7341
7347
|
el2.dispatchEvent(new Event("input"));
|
|
7342
|
-
} else if (((
|
|
7348
|
+
} else if (((_c2 = binding.modifiers) == null ? void 0 : _c2.regex) && config.pattern) {
|
|
7343
7349
|
el2.value = formatRegexInput(el2.value, config.maxLength, config.pattern);
|
|
7344
7350
|
el2.dispatchEvent(new Event("input"));
|
|
7345
7351
|
} else {
|
|
@@ -7364,7 +7370,7 @@ function registerDirective(app2) {
|
|
|
7364
7370
|
});
|
|
7365
7371
|
}
|
|
7366
7372
|
function parseBindingValue(binding) {
|
|
7367
|
-
const defaultConfig = { maxLength: 50, pattern: null };
|
|
7373
|
+
const defaultConfig = { maxLength: 50, pattern: null, min: null, max: null, int: false };
|
|
7368
7374
|
if (!binding.value) {
|
|
7369
7375
|
return defaultConfig;
|
|
7370
7376
|
}
|
|
@@ -7374,7 +7380,10 @@ function parseBindingValue(binding) {
|
|
|
7374
7380
|
if (typeof binding.value === "object") {
|
|
7375
7381
|
return {
|
|
7376
7382
|
maxLength: binding.value.maxLength || defaultConfig.maxLength,
|
|
7377
|
-
pattern: binding.value.pattern || null
|
|
7383
|
+
pattern: binding.value.pattern || null,
|
|
7384
|
+
min: binding.value.min || null,
|
|
7385
|
+
max: binding.value.max || null,
|
|
7386
|
+
int: binding.value.int || false
|
|
7378
7387
|
};
|
|
7379
7388
|
}
|
|
7380
7389
|
return defaultConfig;
|
|
@@ -7394,12 +7403,15 @@ function updatedCheck(el2, binding) {
|
|
|
7394
7403
|
const config = parseBindingValue(binding);
|
|
7395
7404
|
const els = el2.querySelectorAll("input, textarea");
|
|
7396
7405
|
els.forEach((element) => {
|
|
7397
|
-
var _a3, _b;
|
|
7406
|
+
var _a3, _b, _c2;
|
|
7398
7407
|
if (element == null ? void 0 : element.value) {
|
|
7399
|
-
if ((_a3 = binding.modifiers) == null ? void 0 : _a3.
|
|
7408
|
+
if ((_a3 = binding.modifiers) == null ? void 0 : _a3.range) {
|
|
7409
|
+
element.value = formatRangeInput(element.value, config);
|
|
7410
|
+
element.dispatchEvent(new Event("input"));
|
|
7411
|
+
} else if ((_b = binding.modifiers) == null ? void 0 : _b.number) {
|
|
7400
7412
|
element.value = formatNumberInput(element.value, config.maxLength);
|
|
7401
7413
|
element.dispatchEvent(new Event("input"));
|
|
7402
|
-
} else if (((
|
|
7414
|
+
} else if (((_c2 = binding.modifiers) == null ? void 0 : _c2.regex) && config.pattern) {
|
|
7403
7415
|
element.value = formatRegexInput(element.value, config.maxLength, config.pattern);
|
|
7404
7416
|
element.dispatchEvent(new Event("input"));
|
|
7405
7417
|
} else {
|
|
@@ -7435,6 +7447,64 @@ function formatNumberInput(value, maxLength) {
|
|
|
7435
7447
|
}
|
|
7436
7448
|
return result.slice(0, maxLength);
|
|
7437
7449
|
}
|
|
7450
|
+
function formatIntegerInput(value, maxLength) {
|
|
7451
|
+
let result = "";
|
|
7452
|
+
let hasMinus = false;
|
|
7453
|
+
for (let i = 0; i < value.length; i++) {
|
|
7454
|
+
const char = value[i];
|
|
7455
|
+
if (char === "-") {
|
|
7456
|
+
if (i === 0 && !hasMinus) {
|
|
7457
|
+
result += char;
|
|
7458
|
+
hasMinus = true;
|
|
7459
|
+
}
|
|
7460
|
+
continue;
|
|
7461
|
+
}
|
|
7462
|
+
if (/^\d$/.test(char)) {
|
|
7463
|
+
result += char;
|
|
7464
|
+
}
|
|
7465
|
+
}
|
|
7466
|
+
return result.slice(0, maxLength);
|
|
7467
|
+
}
|
|
7468
|
+
function formatRangeInput(value, config) {
|
|
7469
|
+
if (config.int) {
|
|
7470
|
+
let result2 = formatIntegerInput(value, config.maxLength || 50);
|
|
7471
|
+
if (config.min === null && config.max === null) {
|
|
7472
|
+
return result2;
|
|
7473
|
+
}
|
|
7474
|
+
if (result2 === "" || result2 === "-") {
|
|
7475
|
+
return result2;
|
|
7476
|
+
}
|
|
7477
|
+
const numValue2 = parseInt(result2, 10);
|
|
7478
|
+
if (isNaN(numValue2)) {
|
|
7479
|
+
return "";
|
|
7480
|
+
}
|
|
7481
|
+
if (config.min !== null && numValue2 < config.min) {
|
|
7482
|
+
return Math.ceil(config.min).toString();
|
|
7483
|
+
}
|
|
7484
|
+
if (config.max !== null && numValue2 > config.max) {
|
|
7485
|
+
return Math.floor(config.max).toString();
|
|
7486
|
+
}
|
|
7487
|
+
return result2;
|
|
7488
|
+
}
|
|
7489
|
+
let result = formatNumberInput(value, config.maxLength || 50);
|
|
7490
|
+
if (config.min === null && config.max === null) {
|
|
7491
|
+
return result;
|
|
7492
|
+
}
|
|
7493
|
+
if (result === "" || result === "-" || result === ".") {
|
|
7494
|
+
return result;
|
|
7495
|
+
}
|
|
7496
|
+
const numValue = parseFloat(result);
|
|
7497
|
+
if (isNaN(numValue)) {
|
|
7498
|
+
return "";
|
|
7499
|
+
}
|
|
7500
|
+
if (config.min !== null && numValue < config.min) {
|
|
7501
|
+
return config.min.toString();
|
|
7502
|
+
}
|
|
7503
|
+
if (config.max !== null && numValue > config.max) {
|
|
7504
|
+
return config.max.toString();
|
|
7505
|
+
}
|
|
7506
|
+
return result;
|
|
7507
|
+
}
|
|
7438
7508
|
NsVideo.install = (app2) => {
|
|
7439
7509
|
app2.component(NsVideo.name, NsVideo);
|
|
7440
7510
|
try {
|