@lemon-fe/components 1.5.7-alpha.4 → 1.5.7-alpha.6

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.
@@ -800,21 +800,28 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
800
800
  value: function componentWillUnmount() {
801
801
  if (this.isReady) {
802
802
  // 解决agGrid部分内存泄漏
803
-
803
+ var api = this.api;
804
+ setTimeout(function () {
805
+ // 由于下面代码是hack,所以需要捕获边界可能异常,防止崩溃
806
+ try {
807
+ api.setRowData([]);
808
+ api.setColumnDefs([]);
809
+ api.destroy();
810
+ var context = api.__getContext();
811
+ var gridOptionsService = context.getBean('gridOptionsService');
812
+ for (var field in gridOptionsService.gridOptions) {
813
+ delete gridOptionsService.gridOptions[field];
814
+ }
815
+ var userComponentFactory = context.getBean('userComponentFactory');
816
+ userComponentFactory.frameworkComponentWrapper.parent = null;
817
+ var eventService = context.getBean('eventService');
818
+ eventService.allAsyncListeners.clear();
819
+ eventService.globalAsyncListeners.clear();
820
+ } catch (err) {
821
+ console.error('DataGrid unmount error', err);
822
+ }
823
+ }, 0);
804
824
  this.dataSource = [];
805
- this.api.setRowData([]);
806
- this.api.setColumnDefs([]);
807
- this.api.destroy();
808
- var context = this.api.__getContext();
809
- var gridOptionsService = context.getBean('gridOptionsService');
810
- for (var field in gridOptionsService.gridOptions) {
811
- delete gridOptionsService.gridOptions[field];
812
- }
813
- var userComponentFactory = context.getBean('userComponentFactory');
814
- userComponentFactory.frameworkComponentWrapper.parent = null;
815
- var eventService = context.getBean('eventService');
816
- eventService.allAsyncListeners.clear();
817
- eventService.globalAsyncListeners.clear();
818
825
  this.api = new GridApi();
819
826
  this.columnApi = new ColumnApi();
820
827
  }
@@ -1054,8 +1061,7 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1054
1061
  rowActions = _this$props8.rowActions,
1055
1062
  rowSelection = _this$props8.rowSelection,
1056
1063
  locale = _this$props8.locale,
1057
- enableEstimateInitialColumnWidth = _this$props8.enableEstimateInitialColumnWidth,
1058
- keepInitialWidthWhenEstimate = _this$props8.keepInitialWidthWhenEstimate;
1064
+ enableEstimateInitialColumnWidth = _this$props8.enableEstimateInitialColumnWidth;
1059
1065
  var leafColIds = [];
1060
1066
  var groups = new Map();
1061
1067
  var map = function map(cols) {
@@ -1122,8 +1128,9 @@ var InternalDataGrid = /*#__PURE__*/function (_Component) {
1122
1128
  }
1123
1129
  var headerName = (_opts$headerName = opts.headerName) !== null && _opts$headerName !== void 0 ? _opts$headerName : def.headerName;
1124
1130
  var sortable = (_opts$sortable = opts.sortable) !== null && _opts$sortable !== void 0 ? _opts$sortable : def.sortable;
1125
- if (enableEstimateInitialColumnWidth && headerName && !keepInitialWidthWhenEstimate) {
1126
- opts.initialWidth = Math.min(getTextWidth(headerName) * 14 + 36 + (sortable ? 10 : 0) + (opts.headerComponentParams !== undefined ? 24 : 0), ESTIMATE_INITIAL_COLUMN_MAX_WIDTH);
1131
+ if (enableEstimateInitialColumnWidth && headerName) {
1132
+ var _def$initialWidth;
1133
+ 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);
1127
1134
  }
1128
1135
 
1129
1136
  // 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.4",
3
+ "version": "1.5.7-alpha.6",
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": "90aec9c179f56f47c778bf38e663ccc7fedb2889"
61
+ "gitHead": "6d26b5ca998c1e9f0455db9dc97880d1aa147bac"
62
62
  }