tanxin-ui 0.8.7 → 0.8.9
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/tanxin-ui.es.js +53 -5
- package/dist/tanxin-ui.umd.js +11 -11
- package/es/input/src/input.js +9 -3
- package/es/table/src/context.d.ts +2 -0
- package/es/table/src/table-body.js +13 -3
- package/es/utils/common.d.ts +16 -1
- package/es/utils/common.js +33 -1
- package/lib/input/src/input.js +8 -2
- package/lib/table/src/context.d.ts +2 -0
- package/lib/table/src/table-body.js +13 -3
- package/lib/utils/common.d.ts +16 -1
- package/lib/utils/common.js +34 -0
- package/package.json +1 -1
package/dist/tanxin-ui.es.js
CHANGED
|
@@ -1748,6 +1748,38 @@ function getParentComponent(instance2, typeName) {
|
|
|
1748
1748
|
} while (parent && (!name || name.indexOf(typeName) < 0) && i2 < 20);
|
|
1749
1749
|
return parent;
|
|
1750
1750
|
}
|
|
1751
|
+
function countIncludeChinse(str) {
|
|
1752
|
+
let realLength = 0;
|
|
1753
|
+
let charCode;
|
|
1754
|
+
for (let i2 = 0; i2 < str.length; i2++) {
|
|
1755
|
+
charCode = str.charCodeAt(i2);
|
|
1756
|
+
if (charCode >= 0 && charCode <= 128)
|
|
1757
|
+
realLength += 1;
|
|
1758
|
+
else
|
|
1759
|
+
realLength += 2;
|
|
1760
|
+
}
|
|
1761
|
+
return realLength;
|
|
1762
|
+
}
|
|
1763
|
+
function substring(str, start, count) {
|
|
1764
|
+
if (str.replace(/[\u4e00-\u9fa5]/g, "**").length <= count) {
|
|
1765
|
+
return str;
|
|
1766
|
+
}
|
|
1767
|
+
let len = 0;
|
|
1768
|
+
let tmpStr = "";
|
|
1769
|
+
for (let i2 = start; i2 < str.length; i2++) {
|
|
1770
|
+
if (/[\u4e00-\u9fa5]/.test(str[i2])) {
|
|
1771
|
+
len += 2;
|
|
1772
|
+
} else {
|
|
1773
|
+
len += 1;
|
|
1774
|
+
}
|
|
1775
|
+
if (len > count) {
|
|
1776
|
+
break;
|
|
1777
|
+
} else {
|
|
1778
|
+
tmpStr += str[i2];
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
return tmpStr;
|
|
1782
|
+
}
|
|
1751
1783
|
const iconProps = {
|
|
1752
1784
|
color: PropTypes.string,
|
|
1753
1785
|
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
@@ -5596,7 +5628,7 @@ var Input = defineComponent({
|
|
|
5596
5628
|
if (typeof currentValue.value === "number") {
|
|
5597
5629
|
return String(currentValue.value).length;
|
|
5598
5630
|
}
|
|
5599
|
-
return (currentValue.value || "")
|
|
5631
|
+
return countIncludeChinse(currentValue.value || "");
|
|
5600
5632
|
});
|
|
5601
5633
|
const shouldDisabled = computed(() => {
|
|
5602
5634
|
return props.disabled || txForm.disabled;
|
|
@@ -5641,11 +5673,17 @@ var Input = defineComponent({
|
|
|
5641
5673
|
emit("clear", event);
|
|
5642
5674
|
};
|
|
5643
5675
|
const handleInput = (event) => {
|
|
5644
|
-
|
|
5676
|
+
let {
|
|
5645
5677
|
value
|
|
5646
5678
|
} = event.target;
|
|
5647
5679
|
if (isComposing.value)
|
|
5648
5680
|
return;
|
|
5681
|
+
if (props.maxlength) {
|
|
5682
|
+
if (countIncludeChinse(value) > props.maxlength) {
|
|
5683
|
+
value = substring(value, 0, props.maxlength);
|
|
5684
|
+
event.target.value = value;
|
|
5685
|
+
}
|
|
5686
|
+
}
|
|
5649
5687
|
currentValue.value = value;
|
|
5650
5688
|
emit("update:value", value);
|
|
5651
5689
|
emit("input", event);
|
|
@@ -18200,10 +18238,20 @@ var TTableBody = defineComponent({
|
|
|
18200
18238
|
return value;
|
|
18201
18239
|
};
|
|
18202
18240
|
const getColumnData = (column, rowData) => {
|
|
18203
|
-
|
|
18204
|
-
|
|
18205
|
-
|
|
18241
|
+
let value = getColumnValue(rowData, column);
|
|
18242
|
+
if (column.hasOwnProperty("dictionary"))
|
|
18243
|
+
value = getDictionaryValue(column, value);
|
|
18244
|
+
return getValueWithDefault(column, value);
|
|
18245
|
+
};
|
|
18246
|
+
const getValueWithDefault = (column, value) => {
|
|
18247
|
+
var _a, _b;
|
|
18248
|
+
if (value === "" || value === ((_a = column.emptyValue) != null ? _a : ""))
|
|
18249
|
+
return (_b = column.empty) != null ? _b : "-";
|
|
18250
|
+
else
|
|
18206
18251
|
return value;
|
|
18252
|
+
};
|
|
18253
|
+
const getDictionaryValue = (column, value) => {
|
|
18254
|
+
var _a;
|
|
18207
18255
|
if (column.dictionary == null)
|
|
18208
18256
|
return value;
|
|
18209
18257
|
const item = column.dictionary.find((x2) => x2[column.valueKey] == value);
|