@douyinfe/semi-ui 2.34.0 → 2.34.1-alpha.3
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/css/semi.css +21 -45
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +41228 -40825
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/breadcrumb/item.js +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/buttonGroup.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/calendar/interface.d.ts +2 -2
- package/lib/cjs/card/index.d.ts +37 -4
- package/lib/cjs/card/index.js +248 -67
- package/lib/cjs/cascader/index.d.ts +0 -2
- package/lib/cjs/cascader/index.js +0 -13
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +2 -2
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonth.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +2 -2
- package/lib/cjs/form/field.d.ts +2 -2
- package/lib/cjs/form/group.js +2 -4
- package/lib/cjs/image/image.d.ts +0 -4
- package/lib/cjs/image/image.js +1 -23
- package/lib/cjs/image/preview.d.ts +1 -1
- package/lib/cjs/image/preview.js +16 -9
- package/lib/cjs/image/previewContext.d.ts +0 -1
- package/lib/cjs/input/index.d.ts +1 -1
- package/lib/cjs/input/inputGroup.d.ts +1 -1
- package/lib/cjs/modal/confirm.d.ts +19 -19
- package/lib/cjs/rating/index.d.ts +1 -1
- package/lib/cjs/rating/item.d.ts +1 -1
- package/lib/cjs/steps/basicStep.js +13 -7
- package/lib/cjs/steps/basicSteps.js +4 -2
- package/lib/cjs/steps/fillStep.js +13 -7
- package/lib/cjs/steps/fillSteps.js +3 -2
- package/lib/cjs/steps/index.d.ts +1 -0
- package/lib/cjs/steps/index.js +5 -2
- package/lib/cjs/steps/navStep.js +12 -4
- package/lib/cjs/steps/navSteps.js +4 -2
- package/lib/cjs/switch/index.d.ts +1 -1
- package/lib/cjs/table/Body/index.d.ts +0 -1
- package/lib/cjs/table/Body/index.js +3 -3
- package/lib/cjs/table/HeadTable.d.ts +4 -4
- package/lib/cjs/table/HeadTable.js +3 -3
- package/lib/cjs/table/Table.d.ts +2 -2
- package/lib/cjs/table/Table.js +14 -41
- package/lib/cjs/table/TableCell.js +3 -14
- package/lib/cjs/table/TableHeader.d.ts +0 -1
- package/lib/cjs/table/TableHeader.js +2 -11
- package/lib/cjs/table/TableHeaderRow.js +1 -2
- package/lib/cjs/table/index.d.ts +1 -1
- package/lib/cjs/table/interface.d.ts +1 -2
- package/lib/cjs/tagInput/index.d.ts +1 -1
- package/lib/cjs/timePicker/TimePicker.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +1 -1
- package/lib/cjs/typography/base.d.ts +2 -1
- package/lib/cjs/typography/base.js +68 -66
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/typography/util.d.ts +1 -4
- package/lib/cjs/typography/util.js +13 -36
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/breadcrumb/item.js +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/buttonGroup.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/calendar/interface.d.ts +2 -2
- package/lib/es/card/index.d.ts +37 -4
- package/lib/es/card/index.js +247 -66
- package/lib/es/cascader/index.d.ts +0 -2
- package/lib/es/cascader/index.js +0 -13
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +2 -2
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonth.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +2 -2
- package/lib/es/form/field.d.ts +2 -2
- package/lib/es/form/group.js +2 -4
- package/lib/es/image/image.d.ts +0 -4
- package/lib/es/image/image.js +1 -23
- package/lib/es/image/preview.d.ts +1 -1
- package/lib/es/image/preview.js +16 -9
- package/lib/es/image/previewContext.d.ts +0 -1
- package/lib/es/input/index.d.ts +1 -1
- package/lib/es/input/inputGroup.d.ts +1 -1
- package/lib/es/modal/confirm.d.ts +19 -19
- package/lib/es/rating/index.d.ts +1 -1
- package/lib/es/rating/item.d.ts +1 -1
- package/lib/es/steps/basicStep.js +12 -7
- package/lib/es/steps/basicSteps.js +4 -2
- package/lib/es/steps/fillStep.js +12 -7
- package/lib/es/steps/fillSteps.js +3 -2
- package/lib/es/steps/index.d.ts +1 -0
- package/lib/es/steps/index.js +3 -0
- package/lib/es/steps/navStep.js +11 -4
- package/lib/es/steps/navSteps.js +4 -2
- package/lib/es/switch/index.d.ts +1 -1
- package/lib/es/table/Body/index.d.ts +0 -1
- package/lib/es/table/Body/index.js +3 -3
- package/lib/es/table/HeadTable.d.ts +4 -4
- package/lib/es/table/HeadTable.js +3 -3
- package/lib/es/table/Table.d.ts +2 -2
- package/lib/es/table/Table.js +14 -41
- package/lib/es/table/TableCell.js +4 -15
- package/lib/es/table/TableHeader.d.ts +0 -1
- package/lib/es/table/TableHeader.js +1 -9
- package/lib/es/table/TableHeaderRow.js +1 -2
- package/lib/es/table/index.d.ts +1 -1
- package/lib/es/table/interface.d.ts +1 -2
- package/lib/es/tagInput/index.d.ts +1 -1
- package/lib/es/timePicker/TimePicker.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +1 -1
- package/lib/es/typography/base.d.ts +2 -1
- package/lib/es/typography/base.js +67 -64
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/typography/util.d.ts +1 -4
- package/lib/es/typography/util.js +14 -36
- 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) {
|
|
@@ -51,7 +50,6 @@ const getRenderText = function (originEle, rows) {
|
|
|
51
50
|
const lineHeight = pxToNumber(originStyle.lineHeight);
|
|
52
51
|
const maxHeight = Math.round(lineHeight * (rows + 1) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom)); // Set shadow
|
|
53
52
|
|
|
54
|
-
const maxWidth = parseInt(originStyle.width);
|
|
55
53
|
ellipsisContainer.setAttribute('style', originCSS);
|
|
56
54
|
ellipsisContainer.style.position = 'fixed';
|
|
57
55
|
ellipsisContainer.style.left = '0';
|
|
@@ -65,32 +63,20 @@ const getRenderText = function (originEle, rows) {
|
|
|
65
63
|
ReactDOM.render( /*#__PURE__*/React.createElement(React.Fragment, null), ellipsisContainer); // Check if ellipsis in measure div is height enough for content
|
|
66
64
|
|
|
67
65
|
function inRange() {
|
|
68
|
-
|
|
69
|
-
return ellipsisContainer.scrollWidth <= maxWidth;
|
|
70
|
-
}
|
|
71
|
-
|
|
66
|
+
// console.log('inrange?', ellipsisContainer.scrollHeight, ellipsisContainer.scrollHeight < maxHeight)
|
|
72
67
|
return ellipsisContainer.scrollHeight < maxHeight;
|
|
73
68
|
} // ========================= Find match ellipsis content =========================
|
|
74
69
|
// Create origin content holder
|
|
75
70
|
|
|
76
71
|
|
|
77
72
|
const ellipsisContentHolder = document.createElement('span');
|
|
78
|
-
const
|
|
79
|
-
ellipsisContentHolder.appendChild(
|
|
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
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
ellipsisContentHolder.appendChild(ellipsisTextNode);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
ellipsisContainer.appendChild(ellipsisContentHolder); // Expand node needs to be added only when text needTruncated
|
|
87
|
-
|
|
88
|
-
Object.values(_omit(fixedContent, 'expand')).map(node => node && ellipsisContainer.appendChild(node.cloneNode(true)));
|
|
89
|
-
|
|
90
|
-
function appendExpandNode() {
|
|
91
|
-
ellipsisContainer.innerHTML = '';
|
|
92
|
-
ellipsisContainer.appendChild(ellipsisContentHolder);
|
|
93
|
-
Object.values(fixedContent).map(node => node && ellipsisContainer.appendChild(node.cloneNode(true)));
|
|
78
|
+
function appendChildNode(node) {
|
|
79
|
+
ellipsisContentHolder.insertBefore(node, ellipsisTextNode);
|
|
94
80
|
}
|
|
95
81
|
|
|
96
82
|
function getCurrentText(text, pos) {
|
|
@@ -100,7 +86,7 @@ const getRenderText = function (originEle, rows) {
|
|
|
100
86
|
return ellipsisStr;
|
|
101
87
|
}
|
|
102
88
|
|
|
103
|
-
if (ellipsisPos === 'end') {
|
|
89
|
+
if (ellipsisPos === 'end' || pos > end - pos) {
|
|
104
90
|
return text.slice(0, pos) + ellipsisStr;
|
|
105
91
|
}
|
|
106
92
|
|
|
@@ -122,8 +108,8 @@ const getRenderText = function (originEle, rows) {
|
|
|
122
108
|
const currentStepText = getCurrentText(fullText, step);
|
|
123
109
|
textNode.textContent = currentStepText;
|
|
124
110
|
|
|
125
|
-
if (inRange()) {
|
|
126
|
-
return currentStepText;
|
|
111
|
+
if (inRange() || !currentStepText) {
|
|
112
|
+
return step === fullText.length ? fullText : currentStepText;
|
|
127
113
|
}
|
|
128
114
|
}
|
|
129
115
|
} else if (endLoc === 0) {
|
|
@@ -137,17 +123,9 @@ const getRenderText = function (originEle, rows) {
|
|
|
137
123
|
return measureText(textNode, fullText, startLoc, midLoc, lastSuccessLoc);
|
|
138
124
|
}
|
|
139
125
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// 首先判断总文本长度,加上可能有的 suffix,复制按钮长度,看结果是否符合预期
|
|
144
|
-
// 如果不符合预期,则再加上展开按钮,找最大符合尺寸的内容
|
|
145
|
-
|
|
146
|
-
if (!inRange()) {
|
|
147
|
-
appendExpandNode();
|
|
148
|
-
resText = measureText(textNode, content, 0, ellipsisPos === 'middle' ? Math.floor(content.length / 2) : content.length);
|
|
149
|
-
}
|
|
150
|
-
|
|
126
|
+
const textNode = document.createTextNode(content);
|
|
127
|
+
appendChildNode(textNode);
|
|
128
|
+
const resText = measureText(textNode, content);
|
|
151
129
|
ellipsisContainer.innerHTML = '';
|
|
152
130
|
return resText;
|
|
153
131
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.34.
|
|
3
|
+
"version": "2.34.1-alpha.3",
|
|
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.
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.34.
|
|
22
|
-
"@douyinfe/semi-foundation": "2.34.
|
|
23
|
-
"@douyinfe/semi-icons": "2.34.
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.34.
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.34.
|
|
20
|
+
"@douyinfe/semi-animation": "2.34.1-alpha.3",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.34.1-alpha.3",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.34.1-alpha.3",
|
|
23
|
+
"@douyinfe/semi-icons": "2.34.1-alpha.3",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.34.1-alpha.3",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.34.1-alpha.3",
|
|
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": "
|
|
72
|
+
"gitHead": "fc0c751427122de35d3bafb6e6d83a5f815d5f8e",
|
|
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
|
}
|