@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,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.onClipboardCut = exports.onClipboardCopy = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* 获取元素的内容
|
|
9
|
+
* @param {HTMLElement} element
|
|
10
|
+
* @return {string}
|
|
11
|
+
*/
|
|
12
|
+
var getContent = function getContent(element) {
|
|
13
|
+
var content;
|
|
14
|
+
if (element.nodeName === 'SELECT') {
|
|
15
|
+
content = element.value;
|
|
16
|
+
} else if (element.nodeName === 'INPUT') {
|
|
17
|
+
content = element.value;
|
|
18
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
19
|
+
content = element.value;
|
|
20
|
+
} else {
|
|
21
|
+
// 其他类型通过 select 与 range 来获取文本
|
|
22
|
+
// 获取 select
|
|
23
|
+
var selection = window.getSelection();
|
|
24
|
+
// 创建 range
|
|
25
|
+
var range = document.createRange();
|
|
26
|
+
// 设置 range 的元素
|
|
27
|
+
range.selectNodeContents(element);
|
|
28
|
+
// 重置 select
|
|
29
|
+
selection.removeAllRanges();
|
|
30
|
+
// 设置 select 的 range
|
|
31
|
+
selection.addRange(range);
|
|
32
|
+
// 获取选中的文本
|
|
33
|
+
content = selection.toString();
|
|
34
|
+
// 获取到文本后清空选中范围
|
|
35
|
+
selection.removeAllRanges();
|
|
36
|
+
}
|
|
37
|
+
return content;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 清空元素的内容
|
|
41
|
+
* @param {HTMLElement} element
|
|
42
|
+
*/
|
|
43
|
+
var clearElement = function clearElement(element) {
|
|
44
|
+
if (element.nodeName === 'SELECT') {
|
|
45
|
+
;
|
|
46
|
+
element.value = '';
|
|
47
|
+
} else if (element.nodeName === 'INPUT') {
|
|
48
|
+
;
|
|
49
|
+
element.value = '';
|
|
50
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
51
|
+
;
|
|
52
|
+
element.value = '';
|
|
53
|
+
} else {
|
|
54
|
+
element.innerHTML = '';
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 由将被复制的文本为 value 创建一个 HTMLTextAreaElement 容器
|
|
59
|
+
* @param {String} value
|
|
60
|
+
* @return {HTMLTextAreaElement}
|
|
61
|
+
*/
|
|
62
|
+
var createContainer = function createContainer(value) {
|
|
63
|
+
var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
|
|
64
|
+
var container = document.createElement('textarea');
|
|
65
|
+
// 防止在 ios 上缩放
|
|
66
|
+
container.style.fontSize = '12pt';
|
|
67
|
+
// 重置样式
|
|
68
|
+
container.style.border = '0';
|
|
69
|
+
container.style.padding = '0';
|
|
70
|
+
container.style.margin = '0';
|
|
71
|
+
// 把元素定位在视窗外
|
|
72
|
+
container.style.position = 'absolute';
|
|
73
|
+
container.style[isRTL ? 'right' : 'left'] = '-9999px';
|
|
74
|
+
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
75
|
+
container.style.top = "".concat(yPosition, "px");
|
|
76
|
+
// 设置为只读
|
|
77
|
+
container.setAttribute('readonly', '');
|
|
78
|
+
// 将文本赋值给元素
|
|
79
|
+
container.value = value;
|
|
80
|
+
document.body.appendChild(container);
|
|
81
|
+
return container;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* 删除元素
|
|
85
|
+
* @param {HTMLElement} container
|
|
86
|
+
*/
|
|
87
|
+
var removeContainer = function removeContainer(container) {
|
|
88
|
+
document.body.removeChild(container);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* 添加选中状态
|
|
92
|
+
* @param {HTMLElement} element
|
|
93
|
+
*/
|
|
94
|
+
var addSelection = function addSelection(element) {
|
|
95
|
+
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
96
|
+
// 使用 select 对 <textarea> 及 <input> 单独处理
|
|
97
|
+
if (element.nodeName === 'INPUT') {
|
|
98
|
+
;
|
|
99
|
+
element.select();
|
|
100
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
101
|
+
;
|
|
102
|
+
element.select();
|
|
103
|
+
} else {
|
|
104
|
+
var selection = window.getSelection();
|
|
105
|
+
var range = document.createRange();
|
|
106
|
+
range.selectNodeContents(element);
|
|
107
|
+
selection.removeAllRanges();
|
|
108
|
+
selection.addRange(range);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 移除选中状态
|
|
113
|
+
* @param {HTMLElement} element
|
|
114
|
+
*/
|
|
115
|
+
var removeSelection = function removeSelection(element) {
|
|
116
|
+
var _a;
|
|
117
|
+
// 在 Firefox, Edge (非 Chromium 版本) 及 Internet Explorer 中,getSelection() 对 <textarea> 及 <input> 元素不起作用
|
|
118
|
+
// 使用 setSelectRange 对 <textarea> 及 <input> 单独处理
|
|
119
|
+
if (element.nodeName === 'INPUT') {
|
|
120
|
+
;
|
|
121
|
+
element.setSelectionRange(0, 0);
|
|
122
|
+
} else if (element.nodeName === 'TEXTAREA') {
|
|
123
|
+
;
|
|
124
|
+
element.setSelectionRange(0, 0);
|
|
125
|
+
} else {
|
|
126
|
+
(_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.removeAllRanges();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* 剪贴板复制操作
|
|
131
|
+
* @param {string | HTMLElement} target
|
|
132
|
+
* @return {string}
|
|
133
|
+
*/
|
|
134
|
+
var onClipboardCopy = function onClipboardCopy(target) {
|
|
135
|
+
var copiedValue;
|
|
136
|
+
if (typeof target === 'string') {
|
|
137
|
+
// 如果传的是字符串,直接复制值
|
|
138
|
+
copiedValue = target;
|
|
139
|
+
if (navigator.clipboard) {
|
|
140
|
+
// navigator.clipboard api 存在时,优先使用其进行复制操作
|
|
141
|
+
if (copiedValue !== '') {
|
|
142
|
+
navigator.clipboard.writeText(copiedValue).then(null, function () {
|
|
143
|
+
throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
var container = createContainer(copiedValue);
|
|
148
|
+
addSelection(container);
|
|
149
|
+
document.execCommand('copy');
|
|
150
|
+
removeSelection(container);
|
|
151
|
+
removeContainer(container);
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
// 通过元素来复制
|
|
155
|
+
copiedValue = getContent(target);
|
|
156
|
+
if (navigator.clipboard) {
|
|
157
|
+
if (copiedValue !== '') {
|
|
158
|
+
navigator.clipboard.writeText(copiedValue).then(null, function () {
|
|
159
|
+
throw new Error("failed to copy to clipboard of value '".concat(copiedValue, "'"));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
addSelection(target);
|
|
164
|
+
document.execCommand('copy');
|
|
165
|
+
removeSelection(target);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return copiedValue;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* 剪贴板剪切操作
|
|
172
|
+
* @param {HTMLElement} target
|
|
173
|
+
* @return {string}
|
|
174
|
+
*/
|
|
175
|
+
exports.onClipboardCopy = onClipboardCopy;
|
|
176
|
+
var onClipboardCut = function onClipboardCut(target) {
|
|
177
|
+
var cutValue = getContent(target);
|
|
178
|
+
if (target.nodeName === 'SELECT' || target.nodeName === 'INPUT' || target.nodeName === 'TEXTAREA') {
|
|
179
|
+
// 对于输入框,使用 document.execCommand('cut') 来剪切,防止受控的输入框无法清空内容
|
|
180
|
+
if (document.execCommand) {
|
|
181
|
+
addSelection(target);
|
|
182
|
+
document.execCommand('cut');
|
|
183
|
+
removeSelection(target);
|
|
184
|
+
} else {
|
|
185
|
+
// document.execCommand 命令不兼容,则抛出异常,因为受控的输入框无法清空元素内容
|
|
186
|
+
throw new Error("failed to cut to clipboard through unavailable api \"document.execCommand\"");
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
// 对于其他标签的元素,使用 navigator 写入剪贴板,并手动清空内容,防止其他标签无法清空内容
|
|
190
|
+
if (navigator.clipboard) {
|
|
191
|
+
if (cutValue !== '') {
|
|
192
|
+
navigator.clipboard.writeText(cutValue).then(null, function () {
|
|
193
|
+
throw new Error("failed to cut to clipboard of value '".concat(cutValue, "'"));
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
clearElement(target);
|
|
197
|
+
} else {
|
|
198
|
+
// navigator.clipboard 命令不兼容,则抛出异常,因为非输入框无法适用 document.execCommand('cut')
|
|
199
|
+
throw new Error("failed to cut to clipboard through unavailable api \"navigator.clipboard\"");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return cutValue;
|
|
203
|
+
};
|
|
204
|
+
exports.onClipboardCut = onClipboardCut;
|
|
@@ -490,6 +490,11 @@ var compDefaultProps = {
|
|
|
490
490
|
showDescription: true,
|
|
491
491
|
optionHighlightProps: 'highlightText',
|
|
492
492
|
allowClear: true
|
|
493
|
+
},
|
|
494
|
+
Clipboard: {
|
|
495
|
+
action: 'copy',
|
|
496
|
+
disabled: false,
|
|
497
|
+
size: 'middle'
|
|
493
498
|
}
|
|
494
499
|
};
|
|
495
500
|
var _default = compDefaultProps;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -73,6 +73,12 @@ Object.defineProperty(exports, "CityPicker", {
|
|
|
73
73
|
return _cityPicker.default;
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
|
+
Object.defineProperty(exports, "Clipboard", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function get() {
|
|
79
|
+
return _clipboard.default;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
76
82
|
Object.defineProperty(exports, "Col", {
|
|
77
83
|
enumerable: true,
|
|
78
84
|
get: function get() {
|
|
@@ -430,6 +436,7 @@ var _baseData = _interopRequireDefault(require("./base-data"));
|
|
|
430
436
|
var _link = _interopRequireDefault(require("./link"));
|
|
431
437
|
var _treeSelect = _interopRequireDefault(require("./tree-select"));
|
|
432
438
|
var _colorPicker = _interopRequireDefault(require("./color-picker"));
|
|
439
|
+
var _clipboard = _interopRequireDefault(require("./clipboard"));
|
|
433
440
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
434
441
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
435
442
|
/* @remove-on-es-build-begin */
|
|
@@ -70,6 +70,10 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
70
70
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
71
71
|
inputValue = _useState2[0],
|
|
72
72
|
setInputValue = _useState2[1];
|
|
73
|
+
var _useState3 = (0, _react.useState)(1),
|
|
74
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
75
|
+
forceUpdate = _useState4[0],
|
|
76
|
+
setForceUpdate = _useState4[1];
|
|
73
77
|
var inputStatus = (0, _react.useRef)({
|
|
74
78
|
isHandleChange: false,
|
|
75
79
|
inputFocused: false
|
|
@@ -121,10 +125,11 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
121
125
|
var handleChange = function handleChange(event) {
|
|
122
126
|
inputStatus.current.isHandleChange = true;
|
|
123
127
|
var legalNumber = verifiValue(event.target.value);
|
|
128
|
+
updateSelectionRangePosition(event);
|
|
124
129
|
if (legalNumber === false) {
|
|
130
|
+
setForceUpdate(forceUpdate + 1);
|
|
125
131
|
return false;
|
|
126
132
|
}
|
|
127
|
-
updateSelectionRangePosition(event);
|
|
128
133
|
value === undefined && setInputValue(legalNumber);
|
|
129
134
|
onChange && onChange(handleEventAttachValue(event, numberMode ? Number(legalNumber) : legalNumber));
|
|
130
135
|
};
|
|
@@ -163,23 +168,23 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
163
168
|
if (decimalValueLength <= decimalLength && integerValueLength <= digitLength - decimalLength) {
|
|
164
169
|
resultNumerical = numerical;
|
|
165
170
|
} else if (integerValueLength > digitLength - decimalLength) {
|
|
166
|
-
var _context;
|
|
167
|
-
resultNumerical = (0, _concat.default)(_context = "".concat(sign)).call(
|
|
171
|
+
var _context, _context2;
|
|
172
|
+
resultNumerical = mustInPrecisionScope ? inputValue : (0, _concat.default)(_context = (0, _concat.default)(_context2 = "".concat(sign)).call(_context2, integerValue.substr(0, digitLength - decimalLength))).call(_context, decimalValue ? '.' + decimalValue : '');
|
|
168
173
|
} else if (decimalValueLength > decimalLength) {
|
|
169
|
-
var
|
|
170
|
-
resultNumerical = (0, _concat.default)(
|
|
174
|
+
var _context3, _context4;
|
|
175
|
+
resultNumerical = mustInPrecisionScope ? inputValue : (0, _concat.default)(_context3 = (0, _concat.default)(_context4 = "".concat(sign)).call(_context4, integerValue, ".")).call(_context3, decimalValue.substr(0, decimalLength));
|
|
171
176
|
}
|
|
172
177
|
} else if (typeof decimalLength !== 'number' && typeof digitLength === 'number') {
|
|
173
178
|
if (integerValueLength >= digitLength) {
|
|
174
|
-
var
|
|
175
|
-
resultNumerical = (0, _concat.default)(
|
|
179
|
+
var _context5;
|
|
180
|
+
resultNumerical = (0, _concat.default)(_context5 = "".concat(sign)).call(_context5, integerValue.substr(0, digitLength));
|
|
176
181
|
} else {
|
|
177
|
-
var
|
|
178
|
-
resultNumerical = decimalValueLength ? (0, _concat.default)(
|
|
182
|
+
var _context6, _context7, _context8;
|
|
183
|
+
resultNumerical = decimalValueLength ? (0, _concat.default)(_context6 = (0, _concat.default)(_context7 = "".concat(sign)).call(_context7, integerValue, ".")).call(_context6, decimalValue.substr(0, digitLength - integerValueLength)) : (0, _concat.default)(_context8 = "".concat(sign)).call(_context8, integerValue);
|
|
179
184
|
}
|
|
180
185
|
} else if (typeof decimalLength === 'number' && typeof digitLength !== 'number') {
|
|
181
|
-
var
|
|
182
|
-
resultNumerical = decimalValueLength ? (0, _concat.default)(
|
|
186
|
+
var _context9, _context10, _context11;
|
|
187
|
+
resultNumerical = decimalValueLength ? (0, _concat.default)(_context9 = (0, _concat.default)(_context10 = "".concat(sign)).call(_context10, integerValue, ".")).call(_context9, decimalValue.substr(0, decimalLength)) : (0, _concat.default)(_context11 = "".concat(sign)).call(_context11, integerValue);
|
|
183
188
|
} else {
|
|
184
189
|
resultNumerical = numerical;
|
|
185
190
|
}
|
|
@@ -209,13 +214,13 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
209
214
|
});
|
|
210
215
|
};
|
|
211
216
|
var handleKeyDown = function handleKeyDown(event) {
|
|
212
|
-
var
|
|
217
|
+
var _context12;
|
|
213
218
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
214
219
|
if (!stepOption || props.disabled || props.readOnly) {
|
|
215
220
|
return;
|
|
216
221
|
}
|
|
217
222
|
var keyCode = event.keyCode;
|
|
218
|
-
if ((0, _includes.default)(
|
|
223
|
+
if ((0, _includes.default)(_context12 = [38, 40]).call(_context12, keyCode)) {
|
|
219
224
|
event.preventDefault();
|
|
220
225
|
handleStepChang(keyCode === 38 ? 'plus' : 'minus');
|
|
221
226
|
}
|
|
@@ -322,7 +327,8 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
322
327
|
}, [inputValue, formatter]);
|
|
323
328
|
var updateSelectionRangePosition = (0, _useSelectionRange.default)({
|
|
324
329
|
inputElement: (_a = inputNumberRef.current) === null || _a === void 0 ? void 0 : _a.input,
|
|
325
|
-
inputValue: displayedInputValue
|
|
330
|
+
inputValue: displayedInputValue,
|
|
331
|
+
forceUpdate: forceUpdate
|
|
326
332
|
});
|
|
327
333
|
return /*#__PURE__*/_react.default.createElement(_input.default, (0, _extends2.default)({}, others, {
|
|
328
334
|
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;
|
|
@@ -9,7 +9,8 @@ var _react = require("react");
|
|
|
9
9
|
var _isNumber = _interopRequireDefault(require("lodash/isNumber"));
|
|
10
10
|
function useSelectionRange(_ref) {
|
|
11
11
|
var inputElement = _ref.inputElement,
|
|
12
|
-
inputValue = _ref.inputValue
|
|
12
|
+
inputValue = _ref.inputValue,
|
|
13
|
+
forceUpdate = _ref.forceUpdate;
|
|
13
14
|
var refSelectionPosition = (0, _react.useRef)();
|
|
14
15
|
(0, _react.useLayoutEffect)(function () {
|
|
15
16
|
var position = refSelectionPosition.current;
|
|
@@ -17,7 +18,7 @@ function useSelectionRange(_ref) {
|
|
|
17
18
|
var start = Math.max(0, inputValue.length - position);
|
|
18
19
|
inputElement.setSelectionRange(start, start);
|
|
19
20
|
}
|
|
20
|
-
}, [inputValue]);
|
|
21
|
+
}, [inputValue, forceUpdate]);
|
|
21
22
|
return function (event) {
|
|
22
23
|
var _event$target = event.target,
|
|
23
24
|
end = _event$target.selectionEnd,
|
package/lib/message/content.js
CHANGED
|
@@ -70,16 +70,13 @@ var Content = function Content(args) {
|
|
|
70
70
|
}));
|
|
71
71
|
};
|
|
72
72
|
var getMainElement = function getMainElement() {
|
|
73
|
-
if (typeof content === 'string') {
|
|
73
|
+
if (typeof content === 'string' || /*#__PURE__*/_react.default.isValidElement(content)) {
|
|
74
74
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
75
75
|
className: "".concat(classPrefix, "-main")
|
|
76
76
|
}, renderIcon(), /*#__PURE__*/_react.default.createElement("div", {
|
|
77
77
|
className: "".concat(classPrefix, "-text")
|
|
78
78
|
}, content)), renderCloseIcon());
|
|
79
79
|
}
|
|
80
|
-
if ( /*#__PURE__*/_react.default.isValidElement(content)) {
|
|
81
|
-
return content;
|
|
82
|
-
}
|
|
83
80
|
return null;
|
|
84
81
|
};
|
|
85
82
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, getMainElement());
|
|
@@ -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/lib/select/select.js
CHANGED
|
@@ -79,7 +79,8 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
79
79
|
_selectProps$popperSt = selectProps.popperStyle,
|
|
80
80
|
popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt,
|
|
81
81
|
tagRender = selectProps.tagRender,
|
|
82
|
-
virtualListProps = selectProps.virtualListProps
|
|
82
|
+
virtualListProps = selectProps.virtualListProps,
|
|
83
|
+
status = selectProps.status;
|
|
83
84
|
var isMultiple = mode === 'multiple'; // 是否多选
|
|
84
85
|
var _useMergedState = (0, _hooks.useMergedState)(undefined, {
|
|
85
86
|
value: value,
|
|
@@ -139,7 +140,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
139
140
|
// 多选底部样式
|
|
140
141
|
var multipleFooterCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-multiple-footer"), true));
|
|
141
142
|
// 多选,单选公共样式
|
|
142
|
-
var commCls = (0, _classnames.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames6, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), _classNames6));
|
|
143
|
+
var commCls = (0, _classnames.default)((_classNames6 = {}, (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), (0, _defineProperty2.default)(_classNames6, (0, _concat.default)(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-wrapper"), true), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-show-search"), isShowSearch && focusd), (0, _defineProperty2.default)(_classNames6, "".concat(selectPrefixCls, "-error"), status === 'error'), _classNames6));
|
|
143
144
|
(0, _react.useEffect)(function () {
|
|
144
145
|
if (typeof props.visible !== 'undefined') {
|
|
145
146
|
setOptionShow(props.visible);
|
|
@@ -798,12 +799,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
798
799
|
(0, _splice.default)(selectMulOpts).call(selectMulOpts, -1, 1);
|
|
799
800
|
setMulOptions((0, _toConsumableArray2.default)(selectMulOpts));
|
|
800
801
|
onChange && onChange(labelInValue ? selectMulOpts : selectedVal, selectMulOpts);
|
|
801
|
-
// !isMultiple
|
|
802
|
-
} else if (which === _KeyCode.default.BACKSPACE && allowClear && !isMultiple) {
|
|
803
|
-
setInitValue('');
|
|
804
|
-
onClear && onClear('');
|
|
805
|
-
setSearchValue('');
|
|
806
|
-
onChange && onChange(undefined);
|
|
807
802
|
}
|
|
808
803
|
// optionsList: up、down、enter
|
|
809
804
|
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); // 下拉列表文字大小
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
@import "../cascader/style/index.less";
|
|
10
10
|
@import "../checkbox/style/index.less";
|
|
11
11
|
@import "../city-picker/style/index.less";
|
|
12
|
+
@import "../clipboard/style/index.less";
|
|
12
13
|
@import "../collapse/style/index.less";
|
|
13
14
|
@import "../color-picker/style/index.less";
|
|
14
15
|
@import "../date-picker/style/index.less";
|
package/lib/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);
|