@kdcloudjs/kdesign 1.7.35 → 1.7.37
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/kdesign-complete.less +185 -26
- package/dist/kdesign.css +228 -24
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +565 -119
- 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/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/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 +6 -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/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 +6 -2
- 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';
|
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;
|
package/es/tree/tree.js
CHANGED
|
@@ -6,6 +6,7 @@ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable
|
|
|
6
6
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
7
7
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
8
8
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
9
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
9
10
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
10
11
|
var __rest = this && this.__rest || function (s, e) {
|
|
11
12
|
var t = {};
|
|
@@ -15,7 +16,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
15
16
|
}
|
|
16
17
|
return t;
|
|
17
18
|
};
|
|
18
|
-
import React, { useContext, useCallback, useEffect } from 'react';
|
|
19
|
+
import React, { useContext, useCallback, useEffect, useMemo } from 'react';
|
|
19
20
|
import classNames from 'classnames';
|
|
20
21
|
import cloneDeep from 'lodash/cloneDeep';
|
|
21
22
|
import ConfigContext from '../config-provider/ConfigContext';
|
|
@@ -26,6 +27,7 @@ import { getChecked, getHalfChecked, addKeys, flattenAll, delKey, getFilterData,
|
|
|
26
27
|
import { useChecked, useExpand, useSelect } from './treeHooks';
|
|
27
28
|
import isBoolean from 'lodash/isBoolean';
|
|
28
29
|
var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
30
|
+
var _classNames;
|
|
29
31
|
var _useContext = useContext(ConfigContext),
|
|
30
32
|
getPrefixCls = _useContext.getPrefixCls,
|
|
31
33
|
prefixCls = _useContext.prefixCls,
|
|
@@ -79,9 +81,10 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
79
81
|
onlyExpandOnClickIcon = _TreeProps$onlyExpand === void 0 ? false : _TreeProps$onlyExpand,
|
|
80
82
|
loadData = TreeProps.loadData,
|
|
81
83
|
notFoundContent = TreeProps.notFoundContent,
|
|
82
|
-
|
|
84
|
+
showLine = TreeProps.showLine,
|
|
85
|
+
others = __rest(TreeProps, ["prefixCls", "treeData", "virtual", "showIcon", "switcherIcon", "icon", "checkable", "checkStrictly", "disabled", "draggable", "scrollToKey", "expandedKeys", "checkedKeys", "defaultExpandRoot", "defaultExpandAll", "defaultExpandParent", "defaultExpandedKeys", "defaultCheckedKeys", "defaultSelectedKeys", "height", "onCheck", "onExpand", "onDragStart", "onDragOver", "onDragLeave", "onDragEnter", "onDragEnd", "onDrop", "onSelect", "selectedKeys", "setTreeNodeStyle", "setTreeNodeClassName", "estimatedItemSize", "style", "className", "filterTreeNode", "filterValue", "expandOnClickNode", "onlyExpandOnClickIcon", "loadData", "notFoundContent", "showLine"]);
|
|
83
86
|
var treePrefixCls = getPrefixCls(prefixCls, 'tree', customPrefixcls); // 树样式前缀
|
|
84
|
-
var treeNodeClassName = classNames(className,
|
|
87
|
+
var treeNodeClassName = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(treePrefixCls), true), _defineProperty(_classNames, "".concat(treePrefixCls, "-show-line"), showLine), _classNames));
|
|
85
88
|
var treeRootClassName = "".concat(treePrefixCls, "-root");
|
|
86
89
|
var estimatedItemSize = innerEstimatedItemSize; // 节点高度
|
|
87
90
|
var _React$useMemo = React.useMemo(function () {
|
|
@@ -125,17 +128,21 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
125
128
|
_React$useState12 = _slicedToArray(_React$useState11, 2),
|
|
126
129
|
loadingKeys = _React$useState12[0],
|
|
127
130
|
setLoadingKeys = _React$useState12[1];
|
|
128
|
-
var _React$useState13 = React.useState(
|
|
131
|
+
var _React$useState13 = React.useState('NONE'),
|
|
129
132
|
_React$useState14 = _slicedToArray(_React$useState13, 2),
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
searchStatus = _React$useState14[0],
|
|
134
|
+
setSearchStatus = _React$useState14[1];
|
|
132
135
|
var isSearching = React.useMemo(function () {
|
|
133
136
|
return typeof filterTreeNode === 'function' && !!filterValue;
|
|
134
137
|
}, [filterValue]);
|
|
135
138
|
useEffect(function () {
|
|
136
|
-
|
|
139
|
+
if (isSearching) {
|
|
140
|
+
setSearchStatus('SEARCH_START');
|
|
141
|
+
} else {
|
|
142
|
+
setSearchStatus('NONE');
|
|
143
|
+
}
|
|
137
144
|
}, [filterValue]);
|
|
138
|
-
var _useExpand = useExpand(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, isInit, filterTreeNode, isSearching, keysData,
|
|
145
|
+
var _useExpand = useExpand(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, isInit, filterTreeNode, isSearching, keysData, searchStatus),
|
|
139
146
|
_useExpand2 = _slicedToArray(_useExpand, 2),
|
|
140
147
|
expandedKeys = _useExpand2[0],
|
|
141
148
|
setExpandedKeys = _useExpand2[1];
|
|
@@ -220,12 +227,9 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
220
227
|
node: node,
|
|
221
228
|
expanded: expanded
|
|
222
229
|
});
|
|
223
|
-
if (isSearching) {
|
|
224
|
-
var newSearchExpandedKeys = expanded ? addKeys(searchExpandedKeys, [key]) : delKey(searchExpandedKeys, [key]);
|
|
225
|
-
setSearchExpandedKeys(newSearchExpandedKeys);
|
|
226
|
-
}
|
|
227
230
|
setScrollKey(undefined);
|
|
228
231
|
setIsInit(false);
|
|
232
|
+
setSearchStatus('SEARCH_DONE');
|
|
229
233
|
if (expanded && loadData) {
|
|
230
234
|
handleNodeLoad(loadedKeys, loadingKeys, node);
|
|
231
235
|
}
|
|
@@ -370,6 +374,16 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
370
374
|
useEffect(function () {
|
|
371
375
|
setCheckedKeys(checkedKeys);
|
|
372
376
|
}, [checkedKeys, setCheckedKeys]);
|
|
377
|
+
var isSelectedNodeChildrenKey = function isSelectedNodeChildrenKey() {
|
|
378
|
+
var parentKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
379
|
+
var key = Array.isArray(selectedKeys) ? selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0] : selectedKeys;
|
|
380
|
+
return _includesInstanceProperty(parentKeys).call(parentKeys, key);
|
|
381
|
+
};
|
|
382
|
+
var seletedKeyLevel = useMemo(function () {
|
|
383
|
+
var _a;
|
|
384
|
+
var key = Array.isArray(selectedKeys) ? selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys[0] : selectedKeys;
|
|
385
|
+
return (_a = keysData === null || keysData === void 0 ? void 0 : keysData[key]) === null || _a === void 0 ? void 0 : _a.level;
|
|
386
|
+
}, [keysData, selectedKeys]);
|
|
373
387
|
var renderTreeNode = function renderTreeNode(item) {
|
|
374
388
|
var checked = getChecked(checkedKeys, item.key);
|
|
375
389
|
var indeterminate = getHalfChecked(halfCheckedKeys, item.key);
|
|
@@ -404,9 +418,11 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
404
418
|
item.onlyExpandOnClickIcon = onlyExpandOnClickIcon;
|
|
405
419
|
item.loading = loadingKeys.has(item.key) && !loadedKeys.has(item.key);
|
|
406
420
|
item.loadData = loadData;
|
|
421
|
+
item.isActiveLine = showLine && isSelectedNodeChildrenKey(item.pathParentKeys);
|
|
407
422
|
return /*#__PURE__*/React.createElement(TreeNode, _extends({}, item, {
|
|
408
423
|
key: item.key,
|
|
409
|
-
ref: treeNodeRef
|
|
424
|
+
ref: treeNodeRef,
|
|
425
|
+
activeLevel: seletedKeyLevel
|
|
410
426
|
}));
|
|
411
427
|
};
|
|
412
428
|
return /*#__PURE__*/React.createElement("div", _extends({
|