@lemon-fe/components 1.5.7-alpha.3 → 1.5.7-alpha.5

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.
@@ -1021,26 +1021,25 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1021
1021
  }, {
1022
1022
  key: "getFullColumnDef",
1023
1023
  value: function getFullColumnDef(col) {
1024
- if (col.type === undefined) {
1025
- return col;
1026
- }
1027
1024
  var _this$props7 = this.props,
1028
1025
  mColumnTypes = _this$props7.columnTypes,
1029
1026
  mDefaultColDef = _this$props7.defaultColDef;
1030
- var colTypes = this.getMemoizedColumnTypes(mColumnTypes);
1031
1027
  var result = {};
1032
- var types;
1033
- if (typeof col.type === 'string') {
1034
- types = [col.type];
1035
- } else {
1036
- types = col.type;
1037
- }
1038
- types.forEach(function (type) {
1039
- var colType = colTypes[type];
1040
- if (colType !== undefined) {
1041
- Object.assign(result, colType);
1028
+ if (col.type !== undefined) {
1029
+ var colTypes = this.getMemoizedColumnTypes(mColumnTypes);
1030
+ var types;
1031
+ if (typeof col.type === 'string') {
1032
+ types = [col.type];
1033
+ } else {
1034
+ types = col.type;
1042
1035
  }
1043
- });
1036
+ types.forEach(function (type) {
1037
+ var colType = colTypes[type];
1038
+ if (colType !== undefined) {
1039
+ Object.assign(result, colType);
1040
+ }
1041
+ });
1042
+ }
1044
1043
  Object.assign(result, mDefaultColDef);
1045
1044
  return _objectSpread(_objectSpread({}, result), col);
1046
1045
  }
@@ -1055,8 +1054,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1055
1054
  rowActions = _this$props8.rowActions,
1056
1055
  rowSelection = _this$props8.rowSelection,
1057
1056
  locale = _this$props8.locale,
1058
- enableEstimateInitialColumnWidth = _this$props8.enableEstimateInitialColumnWidth,
1059
- keepInitialWidthWhenEstimate = _this$props8.keepInitialWidthWhenEstimate;
1057
+ enableEstimateInitialColumnWidth = _this$props8.enableEstimateInitialColumnWidth;
1060
1058
  var leafColIds = [];
1061
1059
  var groups = new Map();
1062
1060
  var map = function map(cols) {
@@ -1123,8 +1121,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1123
1121
  }
1124
1122
  var headerName = (_opts$headerName = opts.headerName) !== null && _opts$headerName !== void 0 ? _opts$headerName : def.headerName;
1125
1123
  var sortable = (_opts$sortable = opts.sortable) !== null && _opts$sortable !== void 0 ? _opts$sortable : def.sortable;
1126
- if (enableEstimateInitialColumnWidth && headerName && !keepInitialWidthWhenEstimate) {
1127
- opts.initialWidth = Math.min(getTextWidth(headerName) * 14 + 36 + (sortable ? 10 : 0) + (opts.headerComponentParams !== undefined ? 24 : 0), ESTIMATE_INITIAL_COLUMN_MAX_WIDTH);
1124
+ if (enableEstimateInitialColumnWidth && headerName) {
1125
+ var _def$initialWidth;
1126
+ opts.initialWidth = Math.max(Math.min(getTextWidth(headerName) * 14 + 36 + (sortable ? 10 : 0) + (opts.headerComponentParams !== undefined ? 24 : 0), ESTIMATE_INITIAL_COLUMN_MAX_WIDTH), (_def$initialWidth = def.initialWidth) !== null && _def$initialWidth !== void 0 ? _def$initialWidth : 0);
1128
1127
  }
1129
1128
 
1130
1129
  // editable
@@ -297,11 +297,7 @@ export interface DataGridProps<TData> extends Omit<AgGridReactProps<TData>, 'row
297
297
  useValueFormatterForExport?: boolean;
298
298
  };
299
299
  /**
300
- * @depscription 启用预估初始列宽 启用后根据字符长度计算宽度
300
+ * @depscription 启用预估初始列宽 启用后根据字符长度计算宽度,如果列传入了initialWidth,取两者较大值
301
301
  */
302
302
  enableEstimateInitialColumnWidth?: boolean;
303
- /**
304
- * @depscription 与enableEstimateInitialColumnWidth搭配使用,如果col传入了initialWidth,则不会进行预估初始列宽设置
305
- */
306
- keepInitialWidthWhenEstimate?: boolean;
307
303
  }
@@ -1,6 +1,79 @@
1
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
2
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
3
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ // windows下当前单元格样式拉丁字母大致宽度比例
5
+ var latinWidth = {
6
+ A: 0.75,
7
+ B: 0.75,
8
+ C: 0.75,
9
+ D: 0.75,
10
+ E: 0.67,
11
+ F: 0.6,
12
+ G: 0.82,
13
+ H: 0.75,
14
+ I: 0.3,
15
+ J: 0.6,
16
+ K: 0.75,
17
+ L: 0.6,
18
+ M: 0.97,
19
+ N: 0.75,
20
+ O: 0.82,
21
+ P: 0.67,
22
+ Q: 0.82,
23
+ R: 0.75,
24
+ S: 0.67,
25
+ T: 0.67,
26
+ U: 0.75,
27
+ V: 0.67,
28
+ W: 0.97,
29
+ X: 0.67,
30
+ Y: 0.67,
31
+ Z: 0.67,
32
+ a: 0.6,
33
+ b: 0.67,
34
+ c: 0.6,
35
+ d: 0.67,
36
+ e: 0.6,
37
+ f: 0.37,
38
+ g: 0.67,
39
+ h: 0.6,
40
+ i: 0.3,
41
+ j: 0.3,
42
+ k: 0.6,
43
+ l: 0.3,
44
+ m: 0.97,
45
+ n: 0.6,
46
+ o: 0.67,
47
+ p: 0.67,
48
+ q: 0.67,
49
+ r: 0.37,
50
+ s: 0.6,
51
+ t: 0.37,
52
+ u: 0.6,
53
+ v: 0.52,
54
+ w: 0.82,
55
+ x: 0.6,
56
+ y: 0.52,
57
+ z: 0.52
58
+ };
59
+
60
+ // 越南语独立的拉丁字母
61
+ var vietnameseSpecial = {
62
+ đ: 'd',
63
+ Đ: 'D',
64
+ ă: 'a',
65
+ Ă: 'A',
66
+ â: 'a',
67
+ Â: 'A',
68
+ ê: 'e',
69
+ Ê: 'E',
70
+ ô: 'o',
71
+ Ô: 'O',
72
+ ơ: 'o',
73
+ Ơ: 'O',
74
+ ư: 'u',
75
+ Ư: 'U'
76
+ };
4
77
  export function getTextWidth(text) {
5
78
  var width = 0;
6
79
  var _iterator = _createForOfIteratorHelper(text),
@@ -21,14 +94,15 @@ export function getTextWidth(text) {
21
94
  continue;
22
95
  }
23
96
 
24
- // 泰文、高棉文、缅甸文、老挝文;马来文 / 越南语 / 英文使用拉丁字符规则
97
+ // 泰文、高棉文、缅甸文、老挝文;
25
98
  if (isSEAComplexScript(code)) {
26
99
  width += 1;
27
100
  continue;
28
101
  }
29
102
 
30
103
  // 拉丁字母、数字、标点;覆盖英文、马来文、越南语预组合字符
31
- width += 0.6;
104
+ var letter = char.normalize('NFD')[0];
105
+ width += latinWidth[vietnameseSpecial[letter] || letter] || 0.6;
32
106
  }
33
107
  } catch (err) {
34
108
  _iterator.e(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.5.7-alpha.3",
3
+ "version": "1.5.7-alpha.5",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "registry": "https://registry.npmjs.org"
60
60
  },
61
- "gitHead": "2ac91e3697f76af6883a124f78461e3e119da69f"
61
+ "gitHead": "6171749dce121811f94a7d5d0c7e0c6782c5e4d5"
62
62
  }