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.
@@ -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 || "").length;
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
- const {
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
- var _a;
18204
- const value = getColumnValue(rowData, column);
18205
- if (!column.hasOwnProperty("dictionary"))
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);