@kdcloudjs/kdesign 1.7.35 → 1.7.39
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/CHANGELOG.md +39 -0
- package/README.md +2 -1
- package/dist/kdesign-complete.less +189 -28
- package/dist/kdesign.css +233 -26
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +706 -251
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +5 -5
- package/dist/kdesign.min.js.map +1 -1
- package/es/cascader/cascader.js +8 -4
- package/es/cascader/style/index.css +5 -2
- package/es/cascader/style/index.less +4 -2
- package/es/city-picker/city-picker.js +1 -1
- package/es/clipboard/clipboard.d.ts +21 -0
- package/es/clipboard/clipboard.js +106 -0
- package/es/clipboard/index.d.ts +4 -0
- package/es/clipboard/index.js +3 -0
- package/es/clipboard/style/css.js +2 -0
- package/es/clipboard/style/index.css +190 -0
- package/es/clipboard/style/index.d.ts +2 -0
- package/es/clipboard/style/index.js +2 -0
- package/es/clipboard/style/index.less +32 -0
- package/es/clipboard/style/mixin.less +39 -0
- package/es/clipboard/style/token.less +52 -0
- package/es/clipboard/util.d.ts +13 -0
- package/es/clipboard/util.js +197 -0
- package/es/config-provider/compDefaultProps.d.ts +5 -0
- package/es/config-provider/compDefaultProps.js +5 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/input-number/inputNumber.js +20 -14
- package/es/input-number/useSelectionRange.d.ts +2 -1
- package/es/input-number/useSelectionRange.js +3 -2
- package/es/message/content.js +1 -4
- package/es/select/interface.d.ts +1 -0
- package/es/select/select.js +3 -8
- package/es/select/style/index.css +7 -4
- package/es/select/style/index.less +12 -4
- package/es/select/style/token.less +1 -0
- package/es/tree/style/index.css +22 -15
- package/es/tree/style/index.less +33 -18
- package/es/tree/tree.d.ts +1 -0
- package/es/tree/tree.js +29 -13
- package/es/tree/treeHooks.d.ts +2 -2
- package/es/tree/treeHooks.js +11 -6
- package/es/tree/treeNode.d.ts +2 -3
- package/es/tree/treeNode.js +6 -5
- package/es/tree/utils/treeUtils.d.ts +2 -2
- package/es/tree/utils/treeUtils.js +5 -6
- package/es/tree-select/interface.d.ts +1 -0
- package/es/tree-select/style/index.css +7 -4
- package/es/tree-select/style/index.less +12 -4
- package/es/tree-select/style/token.less +1 -0
- package/es/tree-select/tree-select.js +8 -4
- package/lib/cascader/cascader.js +8 -4
- package/lib/cascader/style/index.css +5 -2
- package/lib/cascader/style/index.less +4 -2
- package/lib/city-picker/city-picker.js +1 -1
- package/lib/clipboard/clipboard.d.ts +21 -0
- package/lib/clipboard/clipboard.js +121 -0
- package/lib/clipboard/index.d.ts +4 -0
- package/lib/clipboard/index.js +11 -0
- package/lib/clipboard/style/css.js +4 -0
- package/lib/clipboard/style/index.css +190 -0
- package/lib/clipboard/style/index.d.ts +2 -0
- package/lib/clipboard/style/index.js +4 -0
- package/lib/clipboard/style/index.less +32 -0
- package/lib/clipboard/style/mixin.less +39 -0
- package/lib/clipboard/style/token.less +52 -0
- package/lib/clipboard/util.d.ts +13 -0
- package/lib/clipboard/util.js +204 -0
- package/lib/config-provider/compDefaultProps.d.ts +5 -0
- package/lib/config-provider/compDefaultProps.js +5 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -0
- package/lib/input-number/inputNumber.js +20 -14
- package/lib/input-number/useSelectionRange.d.ts +2 -1
- package/lib/input-number/useSelectionRange.js +3 -2
- package/lib/message/content.js +1 -4
- package/lib/select/interface.d.ts +1 -0
- package/lib/select/select.js +3 -8
- package/lib/select/style/index.css +7 -4
- package/lib/select/style/index.less +12 -4
- package/lib/select/style/token.less +1 -0
- package/lib/style/components.less +1 -0
- package/lib/tree/style/index.css +22 -15
- package/lib/tree/style/index.less +33 -18
- package/lib/tree/tree.d.ts +1 -0
- package/lib/tree/tree.js +28 -12
- package/lib/tree/treeHooks.d.ts +2 -2
- package/lib/tree/treeHooks.js +10 -5
- package/lib/tree/treeNode.d.ts +2 -3
- package/lib/tree/treeNode.js +6 -5
- package/lib/tree/utils/treeUtils.d.ts +2 -2
- package/lib/tree/utils/treeUtils.js +5 -6
- package/lib/tree-select/interface.d.ts +1 -0
- package/lib/tree-select/style/index.css +7 -4
- package/lib/tree-select/style/index.less +12 -4
- package/lib/tree-select/style/token.less +1 -0
- package/lib/tree-select/tree-select.js +10 -6
- package/package.json +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取元素的内容
|
|
3
|
+
* @param {HTMLElement} element
|
|
4
|
+
* @return {string}
|
|
5
|
+
*/
|
|
6
|
+
var getContent = function getContent(element) {
|
|
7
|
+
var content;
|
|
8
|
+
if (element.nodeName === 'SELECT') {
|
|
9
|
+
content = element.value;
|
|
10
|
+
} else if (element.nodeName === 'INPUT') {
|
|
11
|
+
content = element.value;
|
|
12
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
13
|
+
content = element.value;
|
|
14
|
+
} else {
|
|
15
|
+
// 其他类型通过 select 与 range 来获取文本
|
|
16
|
+
// 获取 select
|
|
17
|
+
var selection = window.getSelection();
|
|
18
|
+
// 创建 range
|
|
19
|
+
var range = document.createRange();
|
|
20
|
+
// 设置 range 的元素
|
|
21
|
+
range.selectNodeContents(element);
|
|
22
|
+
// 重置 select
|
|
23
|
+
selection.removeAllRanges();
|
|
24
|
+
// 设置 select 的 range
|
|
25
|
+
selection.addRange(range);
|
|
26
|
+
// 获取选中的文本
|
|
27
|
+
content = selection.toString();
|
|
28
|
+
// 获取到文本后清空选中范围
|
|
29
|
+
selection.removeAllRanges();
|
|
30
|
+
}
|
|
31
|
+
return content;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* 清空元素的内容
|
|
35
|
+
* @param {HTMLElement} element
|
|
36
|
+
*/
|
|
37
|
+
var clearElement = function clearElement(element) {
|
|
38
|
+
if (element.nodeName === 'SELECT') {
|
|
39
|
+
;
|
|
40
|
+
element.value = '';
|
|
41
|
+
} else if (element.nodeName === 'INPUT') {
|
|
42
|
+
;
|
|
43
|
+
element.value = '';
|
|
44
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
45
|
+
;
|
|
46
|
+
element.value = '';
|
|
47
|
+
} else {
|
|
48
|
+
element.innerHTML = '';
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* 由将被复制的文本为 value 创建一个 HTMLTextAreaElement 容器
|
|
53
|
+
* @param {String} value
|
|
54
|
+
* @return {HTMLTextAreaElement}
|
|
55
|
+
*/
|
|
56
|
+
var createContainer = function createContainer(value) {
|
|
57
|
+
var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
|
|
58
|
+
var container = document.createElement('textarea');
|
|
59
|
+
// 防止在 ios 上缩放
|
|
60
|
+
container.style.fontSize = '12pt';
|
|
61
|
+
// 重置样式
|
|
62
|
+
container.style.border = '0';
|
|
63
|
+
container.style.padding = '0';
|
|
64
|
+
container.style.margin = '0';
|
|
65
|
+
// 把元素定位在视窗外
|
|
66
|
+
container.style.position = 'absolute';
|
|
67
|
+
container.style[isRTL ? 'right' : 'left'] = '-9999px';
|
|
68
|
+
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
69
|
+
container.style.top = "".concat(yPosition, "px");
|
|
70
|
+
// 设置为只读
|
|
71
|
+
container.setAttribute('readonly', '');
|
|
72
|
+
// 将文本赋值给元素
|
|
73
|
+
container.value = value;
|
|
74
|
+
document.body.appendChild(container);
|
|
75
|
+
return container;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* 删除元素
|
|
79
|
+
* @param {HTMLElement} container
|
|
80
|
+
*/
|
|
81
|
+
var removeContainer = function removeContainer(container) {
|
|
82
|
+
document.body.removeChild(container);
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* 添加选中状态
|
|
86
|
+
* @param {HTMLElement} element
|
|
87
|
+
*/
|
|
88
|
+
var addSelection = function addSelection(element) {
|
|
89
|
+
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
90
|
+
// 使用 select 对 <textarea> 及 <input> 单独处理
|
|
91
|
+
if (element.nodeName === 'INPUT') {
|
|
92
|
+
;
|
|
93
|
+
element.select();
|
|
94
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
95
|
+
;
|
|
96
|
+
element.select();
|
|
97
|
+
} else {
|
|
98
|
+
var selection = window.getSelection();
|
|
99
|
+
var range = document.createRange();
|
|
100
|
+
range.selectNodeContents(element);
|
|
101
|
+
selection.removeAllRanges();
|
|
102
|
+
selection.addRange(range);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* 移除选中状态
|
|
107
|
+
* @param {HTMLElement} element
|
|
108
|
+
*/
|
|
109
|
+
var removeSelection = function removeSelection(element) {
|
|
110
|
+
var _a;
|
|
111
|
+
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
112
|
+
// 使用 setSelectRange 对 <textarea> 及 <input> 单独处理
|
|
113
|
+
if (element.nodeName === 'INPUT') {
|
|
114
|
+
;
|
|
115
|
+
element.setSelectionRange(0, 0);
|
|
116
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
117
|
+
;
|
|
118
|
+
element.setSelectionRange(0, 0);
|
|
119
|
+
} else {
|
|
120
|
+
(_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* 剪贴板复制操作
|
|
125
|
+
* @param {string | HTMLElement} target
|
|
126
|
+
* @return {string}
|
|
127
|
+
*/
|
|
128
|
+
var onClipboardCopy = function onClipboardCopy(target) {
|
|
129
|
+
var copiedValue;
|
|
130
|
+
if (typeof target === 'string') {
|
|
131
|
+
// 如果传的是字符串,直接复制值
|
|
132
|
+
copiedValue = target;
|
|
133
|
+
if (navigator.clipboard) {
|
|
134
|
+
// navigator.clipboard api 存在时,优先使用其进行复制操作
|
|
135
|
+
if (copiedValue !== '') {
|
|
136
|
+
navigator.clipboard.writeText(copiedValue).then(null, function () {
|
|
137
|
+
throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
var container = createContainer(copiedValue);
|
|
142
|
+
addSelection(container);
|
|
143
|
+
document.execCommand('copy');
|
|
144
|
+
removeSelection(container);
|
|
145
|
+
removeContainer(container);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
// 通过元素来复制
|
|
149
|
+
copiedValue = getContent(target);
|
|
150
|
+
if (navigator.clipboard) {
|
|
151
|
+
if (copiedValue !== '') {
|
|
152
|
+
navigator.clipboard.writeText(copiedValue).then(null, function () {
|
|
153
|
+
throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
addSelection(target);
|
|
158
|
+
document.execCommand('copy');
|
|
159
|
+
removeSelection(target);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return copiedValue;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* 剪贴板剪切操作
|
|
166
|
+
* @param {HTMLElement} target
|
|
167
|
+
* @return {string}
|
|
168
|
+
*/
|
|
169
|
+
var onClipboardCut = function onClipboardCut(target) {
|
|
170
|
+
var cutValue = getContent(target);
|
|
171
|
+
if (target.nodeName === 'SELECT' || target.nodeName === 'INPUT' || target.nodeName === 'TEXTAREA') {
|
|
172
|
+
// 对于输入框,使用 document.execCommand('cut') 来剪切,防止受控的输入框无法清空内容
|
|
173
|
+
if (document.execCommand) {
|
|
174
|
+
addSelection(target);
|
|
175
|
+
document.execCommand('cut');
|
|
176
|
+
removeSelection(target);
|
|
177
|
+
} else {
|
|
178
|
+
// document.execCommand 命令不兼容,则抛出异常,因为受控的输入框无法清空元素内容
|
|
179
|
+
throw new Error("failed to cut to clipboard through unavailable api \"document.execCommand\"");
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
// 对于其他标签的元素,使用 navigator 写入剪贴板,并手动清空内容,防止其他标签无法清空内容
|
|
183
|
+
if (navigator.clipboard) {
|
|
184
|
+
if (cutValue !== '') {
|
|
185
|
+
navigator.clipboard.writeText(cutValue).then(null, function () {
|
|
186
|
+
throw new Error("failed to cut to clipboard of value '".concat(cutValue, "'"));
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
clearElement(target);
|
|
190
|
+
} else {
|
|
191
|
+
// navigator.clipboard 命令不兼容,则抛出异常,因为非输入框无法适用 document.execCommand('cut')
|
|
192
|
+
throw new Error("failed to cut to clipboard through unavailable api \"navigator.clipboard\"");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return cutValue;
|
|
196
|
+
};
|
|
197
|
+
export { onClipboardCopy, onClipboardCut };
|
|
@@ -479,6 +479,11 @@ var compDefaultProps = {
|
|
|
479
479
|
showDescription: true,
|
|
480
480
|
optionHighlightProps: 'highlightText',
|
|
481
481
|
allowClear: true
|
|
482
|
+
},
|
|
483
|
+
Clipboard: {
|
|
484
|
+
action: 'copy',
|
|
485
|
+
disabled: false,
|
|
486
|
+
size: 'middle'
|
|
482
487
|
}
|
|
483
488
|
};
|
|
484
489
|
export default compDefaultProps;
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -54,4 +54,5 @@ export { default as Stepper } from './stepper';
|
|
|
54
54
|
export { default as BaseData } from './base-data';
|
|
55
55
|
export { default as Link } from './link';
|
|
56
56
|
export { default as TreeSelect } from './tree-select';
|
|
57
|
-
export { default as ColorPicker } from './color-picker';
|
|
57
|
+
export { default as ColorPicker } from './color-picker';
|
|
58
|
+
export { default as Clipboard } from './clipboard';
|
|
@@ -58,6 +58,10 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
58
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
59
59
|
inputValue = _useState2[0],
|
|
60
60
|
setInputValue = _useState2[1];
|
|
61
|
+
var _useState3 = useState(1),
|
|
62
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
63
|
+
forceUpdate = _useState4[0],
|
|
64
|
+
setForceUpdate = _useState4[1];
|
|
61
65
|
var inputStatus = useRef({
|
|
62
66
|
isHandleChange: false,
|
|
63
67
|
inputFocused: false
|
|
@@ -109,10 +113,11 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
109
113
|
var handleChange = function handleChange(event) {
|
|
110
114
|
inputStatus.current.isHandleChange = true;
|
|
111
115
|
var legalNumber = verifiValue(event.target.value);
|
|
116
|
+
updateSelectionRangePosition(event);
|
|
112
117
|
if (legalNumber === false) {
|
|
118
|
+
setForceUpdate(forceUpdate + 1);
|
|
113
119
|
return false;
|
|
114
120
|
}
|
|
115
|
-
updateSelectionRangePosition(event);
|
|
116
121
|
value === undefined && setInputValue(legalNumber);
|
|
117
122
|
onChange && onChange(handleEventAttachValue(event, numberMode ? Number(legalNumber) : legalNumber));
|
|
118
123
|
};
|
|
@@ -151,23 +156,23 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
151
156
|
if (decimalValueLength <= decimalLength && integerValueLength <= digitLength - decimalLength) {
|
|
152
157
|
resultNumerical = numerical;
|
|
153
158
|
} else if (integerValueLength > digitLength - decimalLength) {
|
|
154
|
-
var _context;
|
|
155
|
-
resultNumerical = _concatInstanceProperty(_context = "".concat(sign)).call(
|
|
159
|
+
var _context, _context2;
|
|
160
|
+
resultNumerical = mustInPrecisionScope ? inputValue : _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "".concat(sign)).call(_context2, integerValue.substr(0, digitLength - decimalLength))).call(_context, decimalValue ? '.' + decimalValue : '');
|
|
156
161
|
} else if (decimalValueLength > decimalLength) {
|
|
157
|
-
var
|
|
158
|
-
resultNumerical = _concatInstanceProperty(
|
|
162
|
+
var _context3, _context4;
|
|
163
|
+
resultNumerical = mustInPrecisionScope ? inputValue : _concatInstanceProperty(_context3 = _concatInstanceProperty(_context4 = "".concat(sign)).call(_context4, integerValue, ".")).call(_context3, decimalValue.substr(0, decimalLength));
|
|
159
164
|
}
|
|
160
165
|
} else if (typeof decimalLength !== 'number' && typeof digitLength === 'number') {
|
|
161
166
|
if (integerValueLength >= digitLength) {
|
|
162
|
-
var
|
|
163
|
-
resultNumerical = _concatInstanceProperty(
|
|
167
|
+
var _context5;
|
|
168
|
+
resultNumerical = _concatInstanceProperty(_context5 = "".concat(sign)).call(_context5, integerValue.substr(0, digitLength));
|
|
164
169
|
} else {
|
|
165
|
-
var
|
|
166
|
-
resultNumerical = decimalValueLength ? _concatInstanceProperty(
|
|
170
|
+
var _context6, _context7, _context8;
|
|
171
|
+
resultNumerical = decimalValueLength ? _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "".concat(sign)).call(_context7, integerValue, ".")).call(_context6, decimalValue.substr(0, digitLength - integerValueLength)) : _concatInstanceProperty(_context8 = "".concat(sign)).call(_context8, integerValue);
|
|
167
172
|
}
|
|
168
173
|
} else if (typeof decimalLength === 'number' && typeof digitLength !== 'number') {
|
|
169
|
-
var
|
|
170
|
-
resultNumerical = decimalValueLength ? _concatInstanceProperty(
|
|
174
|
+
var _context9, _context10, _context11;
|
|
175
|
+
resultNumerical = decimalValueLength ? _concatInstanceProperty(_context9 = _concatInstanceProperty(_context10 = "".concat(sign)).call(_context10, integerValue, ".")).call(_context9, decimalValue.substr(0, decimalLength)) : _concatInstanceProperty(_context11 = "".concat(sign)).call(_context11, integerValue);
|
|
171
176
|
} else {
|
|
172
177
|
resultNumerical = numerical;
|
|
173
178
|
}
|
|
@@ -197,13 +202,13 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
197
202
|
});
|
|
198
203
|
};
|
|
199
204
|
var handleKeyDown = function handleKeyDown(event) {
|
|
200
|
-
var
|
|
205
|
+
var _context12;
|
|
201
206
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
202
207
|
if (!stepOption || props.disabled || props.readOnly) {
|
|
203
208
|
return;
|
|
204
209
|
}
|
|
205
210
|
var keyCode = event.keyCode;
|
|
206
|
-
if (_includesInstanceProperty(
|
|
211
|
+
if (_includesInstanceProperty(_context12 = [38, 40]).call(_context12, keyCode)) {
|
|
207
212
|
event.preventDefault();
|
|
208
213
|
handleStepChang(keyCode === 38 ? 'plus' : 'minus');
|
|
209
214
|
}
|
|
@@ -310,7 +315,8 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
310
315
|
}, [inputValue, formatter]);
|
|
311
316
|
var updateSelectionRangePosition = useSelectionRange({
|
|
312
317
|
inputElement: (_a = inputNumberRef.current) === null || _a === void 0 ? void 0 : _a.input,
|
|
313
|
-
inputValue: displayedInputValue
|
|
318
|
+
inputValue: displayedInputValue,
|
|
319
|
+
forceUpdate: forceUpdate
|
|
314
320
|
});
|
|
315
321
|
return /*#__PURE__*/React.createElement(Input, _extends({}, others, {
|
|
316
322
|
ref: inputNumberRef,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export default function useSelectionRange({ inputElement, inputValue, }: {
|
|
1
|
+
export default function useSelectionRange({ inputElement, inputValue, forceUpdate, }: {
|
|
2
2
|
inputElement: HTMLInputElement;
|
|
3
3
|
inputValue: string;
|
|
4
|
+
forceUpdate: number;
|
|
4
5
|
}): (event: any) => void;
|
|
@@ -2,7 +2,8 @@ import { useRef, useLayoutEffect } from 'react';
|
|
|
2
2
|
import isNumber from 'lodash/isNumber';
|
|
3
3
|
export default function useSelectionRange(_ref) {
|
|
4
4
|
var inputElement = _ref.inputElement,
|
|
5
|
-
inputValue = _ref.inputValue
|
|
5
|
+
inputValue = _ref.inputValue,
|
|
6
|
+
forceUpdate = _ref.forceUpdate;
|
|
6
7
|
var refSelectionPosition = useRef();
|
|
7
8
|
useLayoutEffect(function () {
|
|
8
9
|
var position = refSelectionPosition.current;
|
|
@@ -10,7 +11,7 @@ export default function useSelectionRange(_ref) {
|
|
|
10
11
|
var start = Math.max(0, inputValue.length - position);
|
|
11
12
|
inputElement.setSelectionRange(start, start);
|
|
12
13
|
}
|
|
13
|
-
}, [inputValue]);
|
|
14
|
+
}, [inputValue, forceUpdate]);
|
|
14
15
|
return function (event) {
|
|
15
16
|
var _event$target = event.target,
|
|
16
17
|
end = _event$target.selectionEnd,
|
package/es/message/content.js
CHANGED
|
@@ -58,16 +58,13 @@ var Content = function Content(args) {
|
|
|
58
58
|
}));
|
|
59
59
|
};
|
|
60
60
|
var getMainElement = function getMainElement() {
|
|
61
|
-
if (typeof content === 'string') {
|
|
61
|
+
if (typeof content === 'string' || /*#__PURE__*/React.isValidElement(content)) {
|
|
62
62
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
63
63
|
className: "".concat(classPrefix, "-main")
|
|
64
64
|
}, renderIcon(), /*#__PURE__*/React.createElement("div", {
|
|
65
65
|
className: "".concat(classPrefix, "-text")
|
|
66
66
|
}, content)), renderCloseIcon());
|
|
67
67
|
}
|
|
68
|
-
if ( /*#__PURE__*/React.isValidElement(content)) {
|
|
69
|
-
return content;
|
|
70
|
-
}
|
|
71
68
|
return null;
|
|
72
69
|
};
|
|
73
70
|
return /*#__PURE__*/React.createElement(React.Fragment, null, getMainElement());
|
package/es/select/interface.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export interface ISelectProps<T extends SelectValue> extends AbstractSelectProps
|
|
|
53
53
|
defaultValue?: T;
|
|
54
54
|
mode?: Mode;
|
|
55
55
|
autoFocus?: boolean;
|
|
56
|
+
status?: 'error';
|
|
56
57
|
onChange?: (value?: T, option?: React.ReactElement<any> | React.ReactElement<any>[]) => void;
|
|
57
58
|
onSelect?: (value?: T extends (infer I)[] ? I : T, option?: React.ReactElement<any>) => void;
|
|
58
59
|
onDeselect?: (value?: T extends (infer I)[] ? I : T, option?: React.ReactElement<any>) => void;
|
package/es/select/select.js
CHANGED
|
@@ -67,7 +67,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
67
67
|
_selectProps$popperSt = selectProps.popperStyle,
|
|
68
68
|
popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt,
|
|
69
69
|
tagRender = selectProps.tagRender,
|
|
70
|
-
virtualListProps = selectProps.virtualListProps
|
|
70
|
+
virtualListProps = selectProps.virtualListProps,
|
|
71
|
+
status = selectProps.status;
|
|
71
72
|
var isMultiple = mode === 'multiple'; // 是否多选
|
|
72
73
|
var _useMergedState = useMergedState(undefined, {
|
|
73
74
|
value: value,
|
|
@@ -127,7 +128,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
127
128
|
// 多选底部样式
|
|
128
129
|
var multipleFooterCls = classNames(_defineProperty({}, "".concat(selectPrefixCls, "-multiple-footer"), true));
|
|
129
130
|
// 多选,单选公共样式
|
|
130
|
-
var commCls = classNames((_classNames6 = {}, _defineProperty(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), _defineProperty(_classNames6, _concatInstanceProperty(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), _classNames6));
|
|
131
|
+
var commCls = classNames((_classNames6 = {}, _defineProperty(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), _defineProperty(_classNames6, _concatInstanceProperty(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), _defineProperty(_classNames6, "".concat(selectPrefixCls, "-error"), status === 'error'), _classNames6));
|
|
131
132
|
useEffect(function () {
|
|
132
133
|
if (typeof props.visible !== 'undefined') {
|
|
133
134
|
setOptionShow(props.visible);
|
|
@@ -786,12 +787,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
786
787
|
_spliceInstanceProperty(selectMulOpts).call(selectMulOpts, -1, 1);
|
|
787
788
|
setMulOptions(_toConsumableArray(selectMulOpts));
|
|
788
789
|
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
789
|
-
// !isMultiple
|
|
790
|
-
} else if (which === KeyCode.BACKSPACE && allowClear && !isMultiple) {
|
|
791
|
-
setInitValue('');
|
|
792
|
-
onClear && onClear('');
|
|
793
|
-
setSearchValue('');
|
|
794
|
-
onChange && onChange(undefined);
|
|
795
790
|
}
|
|
796
791
|
// optionsList: up、down、enter
|
|
797
792
|
if (optionShow) {
|
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
.kd-select-icon-clear:hover {
|
|
297
297
|
color: var(--kd-c-select-color-border-hover, var(--kd-g-color-theme, #5582f3));
|
|
298
298
|
}
|
|
299
|
-
.kd-select-focused {
|
|
299
|
+
.kd-select-focused:not(.kd-select-error) {
|
|
300
300
|
border-color: var(--kd-c-select-color-border-foucs, var(--kd-g-color-theme, #5582f3)) !important;
|
|
301
301
|
}
|
|
302
302
|
.kd-select-placeholder {
|
|
@@ -323,7 +323,7 @@
|
|
|
323
323
|
.kd-select-underline {
|
|
324
324
|
border-bottom: 1px solid var(--kd-c-select-color-border, var(--kd-g-color-input, #999));
|
|
325
325
|
}
|
|
326
|
-
.kd-select-underline:hover:not(.kd-select-multiple-disabled):not(.kd-select-single-disabled) {
|
|
326
|
+
.kd-select-underline:hover:not(.kd-select-multiple-disabled):not(.kd-select-single-disabled):not( .kd-select-error) {
|
|
327
327
|
border-bottom: 1px solid var(--kd-c-select-color-border-hover, var(--kd-g-color-theme, #5582f3));
|
|
328
328
|
}
|
|
329
329
|
.kd-select-bordered {
|
|
@@ -331,7 +331,7 @@
|
|
|
331
331
|
padding-left: var(--kd-c-select-bordered-spacing-padding-left, 8px) !important;
|
|
332
332
|
border-radius: var(--kd-c-select-bordered-radius-border, 2px);
|
|
333
333
|
}
|
|
334
|
-
.kd-select-bordered:hover:not(.kd-select-multiple-disabled):not(.kd-select-single-disabled) {
|
|
334
|
+
.kd-select-bordered:hover:not(.kd-select-multiple-disabled):not(.kd-select-single-disabled):not( .kd-select-error) {
|
|
335
335
|
border: 1px solid var(--kd-c-select-color-border-hover, var(--kd-g-color-theme, #5582f3));
|
|
336
336
|
}
|
|
337
337
|
.kd-select-bordered .kd-select-suffix {
|
|
@@ -522,7 +522,7 @@
|
|
|
522
522
|
white-space: nowrap;
|
|
523
523
|
text-overflow: ellipsis;
|
|
524
524
|
}
|
|
525
|
-
.kd-select .kd-select-single-focused {
|
|
525
|
+
.kd-select .kd-select-single-focused:not(.kd-select-error) {
|
|
526
526
|
border-color: var(--kd-c-select-color-border-foucs, var(--kd-g-color-theme, #5582f3)) !important;
|
|
527
527
|
}
|
|
528
528
|
.kd-select .kd-select-single-disabled {
|
|
@@ -702,6 +702,9 @@
|
|
|
702
702
|
color: var(--kd-c-select-footer-color-text-selected, #0e5fd8);
|
|
703
703
|
padding: 0 2px;
|
|
704
704
|
}
|
|
705
|
+
.kd-select-error:not(.kd-select-single-disabled):not(.kd-select-multiple-disabled) {
|
|
706
|
+
border-color: var(--kd-c-select-color-error, var(--kd-g-color-error, #fb2323));
|
|
707
|
+
}
|
|
705
708
|
.kd-select-dropdown-panel.topLeft.hidden,
|
|
706
709
|
.kd-select-dropdown-panel.bottomLeft.hidden,
|
|
707
710
|
.kd-select-dropdown-panel.topRight.hidden,
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
&-focused {
|
|
62
|
+
&-focused:not(.@{select-prefix-cls}-error) {
|
|
63
63
|
.focusColor();
|
|
64
64
|
}
|
|
65
65
|
&-placeholder {
|
|
@@ -83,7 +83,9 @@
|
|
|
83
83
|
|
|
84
84
|
&-underline {
|
|
85
85
|
border-bottom: 1px solid @select-g-color-border;
|
|
86
|
-
&:hover:not(.@{select-prefix-cls}-multiple-disabled):not(.@{select-prefix-cls}-single-disabled)
|
|
86
|
+
&:hover:not(.@{select-prefix-cls}-multiple-disabled):not(.@{select-prefix-cls}-single-disabled):not(
|
|
87
|
+
.@{select-prefix-cls}-error
|
|
88
|
+
) {
|
|
87
89
|
border-bottom: 1px solid @select-g-color-border-hover;
|
|
88
90
|
}
|
|
89
91
|
}
|
|
@@ -92,7 +94,9 @@
|
|
|
92
94
|
border: 1px solid @select-border-g-color-border;
|
|
93
95
|
padding-left: @select-bordered !important;
|
|
94
96
|
border-radius: @select-border-radius-border;
|
|
95
|
-
&:hover:not(.@{select-prefix-cls}-multiple-disabled):not(.@{select-prefix-cls}-single-disabled)
|
|
97
|
+
&:hover:not(.@{select-prefix-cls}-multiple-disabled):not(.@{select-prefix-cls}-single-disabled):not(
|
|
98
|
+
.@{select-prefix-cls}-error
|
|
99
|
+
) {
|
|
96
100
|
border: 1px solid @select-g-color-border-hover;
|
|
97
101
|
}
|
|
98
102
|
|
|
@@ -265,7 +269,7 @@
|
|
|
265
269
|
.over();
|
|
266
270
|
}
|
|
267
271
|
}
|
|
268
|
-
&-focused {
|
|
272
|
+
&-focused:not(.@{select-prefix-cls}-error) {
|
|
269
273
|
.focusColor();
|
|
270
274
|
}
|
|
271
275
|
&-disabled {
|
|
@@ -439,6 +443,10 @@
|
|
|
439
443
|
}
|
|
440
444
|
}
|
|
441
445
|
|
|
446
|
+
&-error:not(.@{select-prefix-cls}-single-disabled):not(.@{select-prefix-cls}-multiple-disabled) {
|
|
447
|
+
border-color: @select-error-color;
|
|
448
|
+
}
|
|
449
|
+
|
|
442
450
|
&-dropdown-panel {
|
|
443
451
|
&.topLeft.hidden,
|
|
444
452
|
&.bottomLeft.hidden,
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
@select-single-color-text: var(~'@{select-custom-prefix}-single-color-text', @color-text-primary);
|
|
23
23
|
@select-clear-color: var(~'@{select-custom-prefix}-icon-clear-color-text', #d9d9d9);
|
|
24
24
|
@select-clear-color-hover: var(~'@{select-custom-prefix}-icon-clear-color-text-hover', #999);
|
|
25
|
+
@select-error-color: var(~'@{select-custom-prefix}-color-error', @color-error);
|
|
25
26
|
|
|
26
27
|
// font
|
|
27
28
|
@select-list-font-size: var(~'@{select-custom-prefix}-dropdown-font-size', 12px); // 下拉列表文字大小
|
package/es/tree/style/index.css
CHANGED
|
@@ -143,10 +143,24 @@
|
|
|
143
143
|
-ms-flex-negative: 0;
|
|
144
144
|
flex-shrink: 0;
|
|
145
145
|
}
|
|
146
|
-
.kd-tree-
|
|
146
|
+
.kd-tree-show-line .kd-tree-node-indent {
|
|
147
|
+
position: relative;
|
|
148
|
+
}
|
|
149
|
+
.kd-tree-show-line .kd-tree-node-indent::before {
|
|
147
150
|
position: absolute;
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
left: 50%;
|
|
152
|
+
-webkit-transform: translateX(-50%);
|
|
153
|
+
transform: translateX(-50%);
|
|
154
|
+
width: 1px;
|
|
155
|
+
border-left: 1px solid #d9d9d9;
|
|
156
|
+
content: '';
|
|
157
|
+
-webkit-box-sizing: border-box;
|
|
158
|
+
box-sizing: border-box;
|
|
159
|
+
top: 0;
|
|
160
|
+
bottom: 0;
|
|
161
|
+
}
|
|
162
|
+
.kd-tree-show-line .kd-tree-node-indent-active::before {
|
|
163
|
+
border-color: var(--kd-c-tree-color-theme, var(--kd-g-color-theme, #5582f3));
|
|
150
164
|
}
|
|
151
165
|
.kd-tree-node-root {
|
|
152
166
|
position: relative;
|
|
@@ -192,20 +206,10 @@
|
|
|
192
206
|
display: -webkit-box;
|
|
193
207
|
display: -ms-flexbox;
|
|
194
208
|
display: flex;
|
|
195
|
-
width:
|
|
196
|
-
|
|
197
|
-
border-left: 11px;
|
|
198
|
-
border-bottom: 0;
|
|
199
|
-
border-right: 10px;
|
|
200
|
-
border-color: white;
|
|
201
|
-
border-style: solid;
|
|
209
|
+
width: var(--kd-c-tree-expand-icon-sizing-width, 16px);
|
|
210
|
+
margin-right: 6px;
|
|
202
211
|
height: 100%;
|
|
203
212
|
cursor: default;
|
|
204
|
-
opacity: 0;
|
|
205
|
-
}
|
|
206
|
-
.kd-tree-node-indent-line {
|
|
207
|
-
background-color: black;
|
|
208
|
-
opacity: 1;
|
|
209
213
|
}
|
|
210
214
|
.kd-tree-node-icon {
|
|
211
215
|
cursor: pointer;
|
|
@@ -316,6 +320,9 @@
|
|
|
316
320
|
width: 100%;
|
|
317
321
|
height: 100%;
|
|
318
322
|
}
|
|
323
|
+
.kd-tree-node-draggabled.kd-tree-node-dragging .kd-tree-node-indent::before {
|
|
324
|
+
border-color: transparent;
|
|
325
|
+
}
|
|
319
326
|
.kd-tree-node-drag-over {
|
|
320
327
|
background-color: var(--kd-c-tree-node-drag-over-color-background, #E3EBFF);
|
|
321
328
|
-webkit-box-shadow: inset 0 0 0 2px var(--kd-c-tree-node-drag-over-color-border, #5582f3);
|
package/es/tree/style/index.less
CHANGED
|
@@ -19,10 +19,26 @@
|
|
|
19
19
|
min-width: 100%;
|
|
20
20
|
flex-shrink: 0;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
|
|
23
|
+
&-show-line {
|
|
24
|
+
.@{tree-node-prefix-cls}-indent {
|
|
25
|
+
position: relative;
|
|
26
|
+
&::before {
|
|
27
|
+
position: absolute;
|
|
28
|
+
left: 50%;
|
|
29
|
+
transform: translateX(-50%);
|
|
30
|
+
width: 1px;
|
|
31
|
+
border-left: 1px solid #d9d9d9;
|
|
32
|
+
content: '';
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
top: 0;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-active::before {
|
|
39
|
+
border-color: @tree-color-theme;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
26
42
|
}
|
|
27
43
|
}
|
|
28
44
|
|
|
@@ -56,21 +72,13 @@
|
|
|
56
72
|
|
|
57
73
|
&-indent {
|
|
58
74
|
display: flex;
|
|
59
|
-
width:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
border-bottom: 0;
|
|
63
|
-
border-right: 10px;
|
|
64
|
-
border-color: white;
|
|
65
|
-
border-style: solid;
|
|
75
|
+
width: @tree-expand-icon-width;
|
|
76
|
+
margin-right: 6px;
|
|
77
|
+
|
|
66
78
|
height: 100%;
|
|
67
79
|
cursor: default;
|
|
68
|
-
opacity: 0;
|
|
69
|
-
}
|
|
70
|
-
&-indent-line {
|
|
71
|
-
background-color: black;
|
|
72
|
-
opacity: 1;
|
|
73
80
|
}
|
|
81
|
+
|
|
74
82
|
&-icon {
|
|
75
83
|
cursor: pointer;
|
|
76
84
|
height: @tree-expand-icon-height;
|
|
@@ -135,6 +143,12 @@
|
|
|
135
143
|
align-items: center;
|
|
136
144
|
width: 100%;
|
|
137
145
|
height: 100%;
|
|
146
|
+
|
|
147
|
+
&.@{tree-node-prefix-cls}-dragging {
|
|
148
|
+
.@{tree-node-prefix-cls}-indent::before {
|
|
149
|
+
border-color: transparent;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
138
152
|
}
|
|
139
153
|
|
|
140
154
|
&-drag-over {
|
|
@@ -143,13 +157,14 @@
|
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
&-drag-line {
|
|
146
|
-
&-top,
|
|
160
|
+
&-top,
|
|
161
|
+
&-bottom {
|
|
147
162
|
position: absolute;
|
|
148
163
|
left: 0;
|
|
149
164
|
top: 0;
|
|
150
165
|
width: 100%;
|
|
151
166
|
border-top: 2px solid @tree-node-drag-line-border-color;
|
|
152
|
-
|
|
167
|
+
|
|
153
168
|
&::before {
|
|
154
169
|
content: '';
|
|
155
170
|
width: 4px;
|
package/es/tree/tree.d.ts
CHANGED
|
@@ -70,5 +70,6 @@ export declare type KeysDataType = {
|
|
|
70
70
|
export declare type PosDataType = {
|
|
71
71
|
[key: string]: TreeNodeData;
|
|
72
72
|
};
|
|
73
|
+
export declare type SearchStatus = 'NONE' | 'SEARCH_START' | 'SEARCH_DONE';
|
|
73
74
|
declare const Tree: React.ForwardRefExoticComponent<TreeProps & React.RefAttributes<unknown>>;
|
|
74
75
|
export default Tree;
|