@douyinfe/semi-ui 2.34.0-beta.0 → 2.34.1-alpha.2

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.
Files changed (71) hide show
  1. package/dist/css/semi.css +20 -44
  2. package/dist/css/semi.min.css +1 -1
  3. package/dist/umd/semi-ui.js +33404 -33022
  4. package/dist/umd/semi-ui.js.map +1 -1
  5. package/dist/umd/semi-ui.min.js +1 -1
  6. package/dist/umd/semi-ui.min.js.map +1 -1
  7. package/lib/cjs/breadcrumb/item.js +1 -1
  8. package/lib/cjs/calendar/interface.d.ts +2 -2
  9. package/lib/cjs/card/index.d.ts +36 -4
  10. package/lib/cjs/card/index.js +244 -67
  11. package/lib/cjs/cascader/index.d.ts +0 -2
  12. package/lib/cjs/cascader/index.js +0 -13
  13. package/lib/cjs/form/baseForm.d.ts +1 -1
  14. package/lib/cjs/form/field.d.ts +1 -1
  15. package/lib/cjs/modal/confirm.d.ts +6 -6
  16. package/lib/cjs/steps/basicStep.js +13 -7
  17. package/lib/cjs/steps/basicSteps.js +4 -2
  18. package/lib/cjs/steps/fillStep.js +13 -7
  19. package/lib/cjs/steps/fillSteps.js +3 -2
  20. package/lib/cjs/steps/index.d.ts +1 -0
  21. package/lib/cjs/steps/index.js +5 -2
  22. package/lib/cjs/steps/navStep.js +12 -4
  23. package/lib/cjs/steps/navSteps.js +4 -2
  24. package/lib/cjs/table/Body/index.d.ts +0 -1
  25. package/lib/cjs/table/Body/index.js +3 -3
  26. package/lib/cjs/table/HeadTable.d.ts +4 -4
  27. package/lib/cjs/table/HeadTable.js +3 -3
  28. package/lib/cjs/table/Table.js +4 -29
  29. package/lib/cjs/table/TableCell.js +3 -14
  30. package/lib/cjs/table/TableHeader.d.ts +0 -1
  31. package/lib/cjs/table/TableHeader.js +2 -11
  32. package/lib/cjs/table/TableHeaderRow.js +1 -2
  33. package/lib/cjs/table/interface.d.ts +1 -2
  34. package/lib/cjs/typography/base.d.ts +2 -1
  35. package/lib/cjs/typography/base.js +68 -66
  36. package/lib/cjs/typography/title.d.ts +1 -1
  37. package/lib/cjs/typography/util.d.ts +1 -4
  38. package/lib/cjs/typography/util.js +13 -32
  39. package/lib/es/breadcrumb/item.js +1 -1
  40. package/lib/es/calendar/interface.d.ts +2 -2
  41. package/lib/es/card/index.d.ts +36 -4
  42. package/lib/es/card/index.js +243 -66
  43. package/lib/es/cascader/index.d.ts +0 -2
  44. package/lib/es/cascader/index.js +0 -13
  45. package/lib/es/form/baseForm.d.ts +1 -1
  46. package/lib/es/form/field.d.ts +1 -1
  47. package/lib/es/modal/confirm.d.ts +6 -6
  48. package/lib/es/steps/basicStep.js +12 -7
  49. package/lib/es/steps/basicSteps.js +4 -2
  50. package/lib/es/steps/fillStep.js +12 -7
  51. package/lib/es/steps/fillSteps.js +3 -2
  52. package/lib/es/steps/index.d.ts +1 -0
  53. package/lib/es/steps/index.js +3 -0
  54. package/lib/es/steps/navStep.js +11 -4
  55. package/lib/es/steps/navSteps.js +4 -2
  56. package/lib/es/table/Body/index.d.ts +0 -1
  57. package/lib/es/table/Body/index.js +3 -3
  58. package/lib/es/table/HeadTable.d.ts +4 -4
  59. package/lib/es/table/HeadTable.js +3 -3
  60. package/lib/es/table/Table.js +5 -30
  61. package/lib/es/table/TableCell.js +4 -15
  62. package/lib/es/table/TableHeader.d.ts +0 -1
  63. package/lib/es/table/TableHeader.js +1 -9
  64. package/lib/es/table/TableHeaderRow.js +1 -2
  65. package/lib/es/table/interface.d.ts +1 -2
  66. package/lib/es/typography/base.d.ts +2 -1
  67. package/lib/es/typography/base.js +67 -64
  68. package/lib/es/typography/title.d.ts +1 -1
  69. package/lib/es/typography/util.d.ts +1 -4
  70. package/lib/es/typography/util.js +14 -32
  71. package/package.json +9 -8
@@ -1,7 +1,5 @@
1
- import _omit from "lodash/omit";
2
1
  import ReactDOM from 'react-dom';
3
2
  import React from 'react';
4
-
5
3
  /**
6
4
  * The logic of JS for text truncation is referenced from antd typography
7
5
  * https://github.com/ant-design/ant-design/blob/master/components/typography/util.tsx
@@ -9,6 +7,7 @@ import React from 'react';
9
7
  * For more thinking and analysis about this function, please refer to Feishu document
10
8
  * https://bytedance.feishu.cn/docs/doccnqovjjyoKm2U5O13bj30aTh
11
9
  */
10
+
12
11
  let ellipsisContainer;
13
12
 
14
13
  function pxToNumber(value) {
@@ -64,29 +63,20 @@ const getRenderText = function (originEle, rows) {
64
63
  ReactDOM.render( /*#__PURE__*/React.createElement(React.Fragment, null), ellipsisContainer); // Check if ellipsis in measure div is height enough for content
65
64
 
66
65
  function inRange() {
67
- // console.log('inrange?', ellipsisContainer.scrollHeight, ellipsisContainer.scrollHeight < maxHeight);
66
+ // console.log('inrange?', ellipsisContainer.scrollHeight, ellipsisContainer.scrollHeight < maxHeight)
68
67
  return ellipsisContainer.scrollHeight < maxHeight;
69
68
  } // ========================= Find match ellipsis content =========================
70
69
  // Create origin content holder
71
70
 
72
71
 
73
72
  const ellipsisContentHolder = document.createElement('span');
74
- const textNode = document.createTextNode(content);
75
- ellipsisContentHolder.appendChild(textNode);
73
+ const ellipsisTextNode = document.createTextNode(suffix);
74
+ ellipsisContentHolder.appendChild(ellipsisTextNode);
75
+ ellipsisContainer.appendChild(ellipsisContentHolder);
76
+ fixedContent.map(node => node && ellipsisContainer.appendChild(node.cloneNode(true))); // Append before fixed nodes
76
77
 
77
- if (suffix.length > 0) {
78
- const ellipsisTextNode = document.createTextNode(suffix);
79
- ellipsisContentHolder.appendChild(ellipsisTextNode);
80
- }
81
-
82
- ellipsisContainer.appendChild(ellipsisContentHolder); // Expand node needs to be added only when text needTruncated
83
-
84
- Object.values(_omit(fixedContent, 'expand')).map(node => node && ellipsisContainer.appendChild(node.cloneNode(true)));
85
-
86
- function appendExpandNode() {
87
- ellipsisContainer.innerHTML = '';
88
- ellipsisContainer.appendChild(ellipsisContentHolder);
89
- Object.values(fixedContent).map(node => node && ellipsisContainer.appendChild(node.cloneNode(true)));
78
+ function appendChildNode(node) {
79
+ ellipsisContentHolder.insertBefore(node, ellipsisTextNode);
90
80
  }
91
81
 
92
82
  function getCurrentText(text, pos) {
@@ -96,7 +86,7 @@ const getRenderText = function (originEle, rows) {
96
86
  return ellipsisStr;
97
87
  }
98
88
 
99
- if (ellipsisPos === 'end') {
89
+ if (ellipsisPos === 'end' || pos > end - pos) {
100
90
  return text.slice(0, pos) + ellipsisStr;
101
91
  }
102
92
 
@@ -118,8 +108,8 @@ const getRenderText = function (originEle, rows) {
118
108
  const currentStepText = getCurrentText(fullText, step);
119
109
  textNode.textContent = currentStepText;
120
110
 
121
- if (inRange()) {
122
- return currentStepText;
111
+ if (inRange() || !currentStepText) {
112
+ return step === fullText.length ? fullText : currentStepText;
123
113
  }
124
114
  }
125
115
  } else if (endLoc === 0) {
@@ -133,17 +123,9 @@ const getRenderText = function (originEle, rows) {
133
123
  return measureText(textNode, fullText, startLoc, midLoc, lastSuccessLoc);
134
124
  }
135
125
 
136
- let resText = content; // First judge whether the total length of fullText, plus suffix (possible)
137
- // and copied icon (possible) meets expectations?
138
- // If it does not meet expectations, add an expand button to find the largest content that meets size limit
139
- // 首先判断总文本长度,加上可能有的 suffix,复制按钮长度,看结果是否符合预期
140
- // 如果不符合预期,则再加上展开按钮,找最大符合尺寸的内容
141
-
142
- if (!inRange()) {
143
- appendExpandNode();
144
- resText = measureText(textNode, content, 0, ellipsisPos === 'middle' ? Math.floor(content.length / 2) : content.length);
145
- }
146
-
126
+ const textNode = document.createTextNode(content);
127
+ appendChildNode(textNode);
128
+ const resText = measureText(textNode, content);
147
129
  ellipsisContainer.innerHTML = '';
148
130
  return resText;
149
131
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.34.0-beta.0",
3
+ "version": "2.34.1-alpha.2",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -17,12 +17,12 @@
17
17
  "lib/*"
18
18
  ],
19
19
  "dependencies": {
20
- "@douyinfe/semi-animation": "2.34.0-beta.0",
21
- "@douyinfe/semi-animation-react": "2.34.0-beta.0",
22
- "@douyinfe/semi-foundation": "2.34.0-beta.0",
23
- "@douyinfe/semi-icons": "2.34.0-beta.0",
24
- "@douyinfe/semi-illustrations": "2.34.0-beta.0",
25
- "@douyinfe/semi-theme-default": "2.34.0-beta.0",
20
+ "@douyinfe/semi-animation": "2.34.1-alpha.2",
21
+ "@douyinfe/semi-animation-react": "2.34.1-alpha.2",
22
+ "@douyinfe/semi-foundation": "2.34.1-alpha.2",
23
+ "@douyinfe/semi-icons": "2.34.1-alpha.2",
24
+ "@douyinfe/semi-illustrations": "2.34.1-alpha.2",
25
+ "@douyinfe/semi-theme-default": "2.34.1-alpha.2",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,7 +69,7 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "66e287fcec3fff41839dfe30529b746ceee76aa5",
72
+ "gitHead": "f5462b68c0ab80669582aa520ce1cd334a5809e4",
73
73
  "devDependencies": {
74
74
  "@babel/plugin-proposal-decorators": "^7.15.8",
75
75
  "@babel/plugin-transform-runtime": "^7.15.8",
@@ -107,6 +107,7 @@
107
107
  "terser-webpack-plugin": "^4.2.3",
108
108
  "through2": "^4.0.2",
109
109
  "ts-loader": "^5.4.5",
110
+ "webpack": "^4.46.0",
110
111
  "webpackbar": "^5.0.0-3"
111
112
  }
112
113
  }