@kdcloudjs/kdesign 1.5.1 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/kdesign-complete.less +20 -6
  3. package/dist/kdesign.css +23 -9
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +357 -219
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +8 -8
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/anchor/anchor-link.js +0 -6
  11. package/es/anchor/anchor.js +102 -2
  12. package/es/avatar/avatar.js +3 -1
  13. package/es/drawer/drawer.js +1 -0
  14. package/es/dropdown/dropdown.js +16 -6
  15. package/es/input/ClearableLabeledInput.js +7 -8
  16. package/es/input/style/index.css +10 -0
  17. package/es/input/style/index.less +11 -0
  18. package/es/radio/style/index.css +1 -1
  19. package/es/radio/style/index.less +1 -1
  20. package/es/select/select.js +1 -1
  21. package/es/select/style/index.css +5 -5
  22. package/es/select/style/index.less +1 -1
  23. package/es/select/style/token.less +3 -2
  24. package/es/stepper/stepper.js +9 -4
  25. package/es/stepper/style/index.css +2 -0
  26. package/es/stepper/style/index.less +2 -0
  27. package/es/stepper/style/token.less +1 -2
  28. package/es/style/icon/kdicon.css +2 -1
  29. package/es/style/icon/kdicon.woff +0 -0
  30. package/es/tabs/style/index.css +1 -0
  31. package/es/tabs/style/index.less +1 -0
  32. package/es/tooltip/tooltip.js +1 -1
  33. package/es/tree/tree.js +12 -9
  34. package/es/tree/treeHooks.d.ts +1 -1
  35. package/es/tree/treeHooks.js +3 -3
  36. package/es/tree/utils/treeUtils.d.ts +6 -3
  37. package/es/tree/utils/treeUtils.js +67 -43
  38. package/lib/anchor/anchor-link.js +0 -6
  39. package/lib/anchor/anchor.js +102 -2
  40. package/lib/avatar/avatar.js +3 -1
  41. package/lib/drawer/drawer.js +1 -0
  42. package/lib/dropdown/dropdown.js +15 -6
  43. package/lib/input/ClearableLabeledInput.js +7 -8
  44. package/lib/input/style/index.css +10 -0
  45. package/lib/input/style/index.less +11 -0
  46. package/lib/radio/style/index.css +1 -1
  47. package/lib/radio/style/index.less +1 -1
  48. package/lib/select/select.js +1 -1
  49. package/lib/select/style/index.css +5 -5
  50. package/lib/select/style/index.less +1 -1
  51. package/lib/select/style/token.less +3 -2
  52. package/lib/stepper/stepper.js +9 -4
  53. package/lib/stepper/style/index.css +2 -0
  54. package/lib/stepper/style/index.less +2 -0
  55. package/lib/stepper/style/token.less +1 -2
  56. package/lib/style/icon/kdicon.css +2 -1
  57. package/lib/style/icon/kdicon.woff +0 -0
  58. package/lib/tabs/style/index.css +1 -0
  59. package/lib/tabs/style/index.less +1 -0
  60. package/lib/tooltip/tooltip.js +1 -1
  61. package/lib/tree/tree.js +11 -9
  62. package/lib/tree/treeHooks.d.ts +1 -1
  63. package/lib/tree/treeHooks.js +3 -3
  64. package/lib/tree/utils/treeUtils.d.ts +6 -3
  65. package/lib/tree/utils/treeUtils.js +65 -43
  66. package/package.json +1 -1
@@ -7,13 +7,16 @@ import { TreeNodeData } from '../tree';
7
7
  * @param level
8
8
  * @param pos
9
9
  */
10
- export declare const flattenAll: (treeData: any[], newTreeData?: TreeNodeData[], level?: number, pos?: string | undefined) => TreeNodeData[];
10
+ export declare const flattenAll: (treeData: any[], newTreeData?: TreeNodeData[], level?: number, pos?: string | undefined) => {
11
+ flattenAllData: TreeNodeData[];
12
+ maxLevel: number;
13
+ };
11
14
  export declare const getExpand: (expandedKeys: string[], key: string) => boolean;
12
15
  export declare const getChecked: (checkedKeys: string[], key: string) => boolean;
13
16
  export declare const getSelected: (selectedKeys: string[], key: string) => boolean;
14
17
  export declare const getHalfChecked: (halfCheckedKeys: string[], key: string) => boolean;
15
18
  export declare const getAllFilterKeys: (data: any[], filterTreeNode: FunctionConstructor) => any[];
16
- export declare const getFilterData: (data: any[], filterTreeNode: FunctionConstructor, filterValue: string) => any[];
19
+ export declare const getFilterData: (data: any[], filterTreeNode: FunctionConstructor, isSearching: boolean) => any[];
17
20
  export declare const getMaxLevel: (data: any[]) => number;
18
21
  /**
19
22
  *计算node的属性后返回新的 treedata
@@ -43,6 +46,6 @@ export declare const getDataCheckededStateStrictly: (checkedKeys: string[]) => {
43
46
  };
44
47
  export declare const delKey: (prevKeys: string[], delKeys: string[]) => never[] & string[];
45
48
  export declare const getAllNodeKeys: (data: any[]) => string[];
46
- export declare const getInitExpandedKeys: (data: any[], expandedKeys: string[], defaultExpandedKeys: string[], defaultExpandAll: boolean, defaultExpandRoot: boolean, defaultExpandParent: boolean, expandScrollkeys: string[] | undefined, filterTreeNode: FunctionConstructor, filterValue: string) => string[];
49
+ export declare const getInitExpandedKeys: (data: any[], expandedKeys: string[], defaultExpandedKeys: string[], defaultExpandAll: boolean, defaultExpandRoot: boolean, defaultExpandParent: boolean, expandScrollkeys: string[] | undefined, filterTreeNode: FunctionConstructor, isSearching: boolean) => string[];
47
50
  export declare const getExpandedKeys: (expandedKeys: string[], expandScrollkeys?: string[]) => string[];
48
51
  export declare const calcDropPosition: (event: React.MouseEvent, dropNode: HTMLElement) => 0 | 1 | -1;
@@ -5,7 +5,6 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
5
5
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
6
6
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
7
7
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
8
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
8
  import _Set from "@babel/runtime-corejs3/core-js-stable/set";
10
9
  import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
11
10
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
@@ -24,7 +23,7 @@ var __rest = this && this.__rest || function (s, e) {
24
23
  return t;
25
24
  };
26
25
 
27
- var DRAG_OFFSET = 0.4;
26
+ var DRAG_OFFSET = 0.3;
28
27
  /**
29
28
  * 打平所有数组,并添加pos位置信息,
30
29
  * 方便根据expandKeys等计算节点的expand,checkedKeys计算节点checked状态
@@ -38,29 +37,54 @@ export var flattenAll = function flattenAll(treeData) {
38
37
  var newTreeData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
39
38
  var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
40
39
  var pos = arguments.length > 3 ? arguments[3] : undefined;
41
- treeData && treeData.forEach(function (item, index) {
42
- var _context;
40
+ var maxLevel = 0;
43
41
 
44
- var children = item.children,
45
- title = item.title,
46
- key = item.key,
47
- others = __rest(item, ["children", "title", "key"]);
42
+ var fn = function fn(treeData) {
43
+ var newTreeData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
44
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
45
+ var pos = arguments.length > 3 ? arguments[3] : undefined;
46
+ var parent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
47
+ treeData && treeData.forEach(function (item, index) {
48
+ var _context;
48
49
 
49
- var _pos = pos ? _concatInstanceProperty(_context = "".concat(pos, "-")).call(_context, index) : "".concat(index);
50
+ var children = item.children,
51
+ title = item.title,
52
+ key = item.key,
53
+ others = __rest(item, ["children", "title", "key"]);
50
54
 
51
- var hasChildNode = children && children instanceof Array && children.length > 0;
52
- newTreeData.push(_extends({
53
- title: title,
54
- key: key,
55
- pos: _pos,
56
- hasChildNode: hasChildNode,
57
- level: level
58
- }, others));
59
- var _level = level;
60
- _level++;
61
- flattenAll(children, newTreeData, _level, _pos);
62
- });
63
- return newTreeData;
55
+ item.parent = parent;
56
+
57
+ var _pos = pos ? _concatInstanceProperty(_context = "".concat(pos, "-")).call(_context, index) : "".concat(index);
58
+
59
+ var hasChildNode = children && children instanceof Array && children.length > 0;
60
+
61
+ var flattenNode = _extends({
62
+ title: title,
63
+ key: key,
64
+ pos: _pos,
65
+ hasChildNode: hasChildNode,
66
+ level: level,
67
+ parent: parent
68
+ }, others);
69
+
70
+ newTreeData.push(flattenNode);
71
+ var _level = level;
72
+
73
+ if (maxLevel < level) {
74
+ maxLevel = level;
75
+ }
76
+
77
+ _level++;
78
+ fn(children, newTreeData, _level, _pos, flattenNode);
79
+ });
80
+ return newTreeData;
81
+ };
82
+
83
+ var flattenAllData = fn(treeData, newTreeData, level, pos);
84
+ return {
85
+ flattenAllData: flattenAllData,
86
+ maxLevel: maxLevel
87
+ };
64
88
  };
65
89
  export var getExpand = function getExpand(expandedKeys, key) {
66
90
  return expandedKeys === null || expandedKeys === void 0 ? void 0 : _includesInstanceProperty(expandedKeys).call(expandedKeys, key);
@@ -97,29 +121,29 @@ var isAllParentExpand = function isAllParentExpand(data, pos) {
97
121
  };
98
122
 
99
123
  export var getAllFilterKeys = function getAllFilterKeys(data, filterTreeNode) {
100
- var filterData = _filterInstanceProperty(data).call(data, function (item) {
101
- return filterTreeNode === null || filterTreeNode === void 0 ? void 0 : filterTreeNode(item);
102
- });
103
-
104
- var filterKeys = getAllNodeKeys(filterData);
105
124
  var allFilterKeys = [];
106
125
 
107
- _mapInstanceProperty(filterKeys).call(filterKeys, function (key) {
108
- var _context2;
126
+ _filterInstanceProperty(data).call(data, function (item) {
127
+ return filterTreeNode === null || filterTreeNode === void 0 ? void 0 : filterTreeNode(item);
128
+ }).forEach(function (item) {
129
+ var node = _extends({}, item);
109
130
 
110
- return allFilterKeys.push.apply(allFilterKeys, _concatInstanceProperty(_context2 = _toConsumableArray(getAllParentKeys(data, key))).call(_context2, [key]));
131
+ while (node) {
132
+ allFilterKeys.push(node.key);
133
+ node = node.parent;
134
+ }
111
135
  });
112
136
 
113
137
  return _toConsumableArray(new _Set(allFilterKeys));
114
138
  };
115
- export var getFilterData = function getFilterData(data, filterTreeNode, filterValue) {
139
+ export var getFilterData = function getFilterData(data, filterTreeNode, isSearching) {
116
140
  var filterData = data;
141
+ var allFilterKeys = null;
117
142
 
118
- if (typeof filterTreeNode === 'function' && filterValue) {
143
+ if (isSearching) {
144
+ allFilterKeys = getAllFilterKeys(filterData, filterTreeNode);
119
145
  filterData = _filterInstanceProperty(filterData).call(filterData, function (item) {
120
- var _context3;
121
-
122
- return _includesInstanceProperty(_context3 = getAllFilterKeys(filterData, filterTreeNode)).call(_context3, item.key);
146
+ return _includesInstanceProperty(allFilterKeys).call(allFilterKeys, item.key);
123
147
  });
124
148
  }
125
149
 
@@ -258,11 +282,11 @@ export var getSpreadAttrData = function getSpreadAttrData(treeData, expandedKeys
258
282
  return newTreeData;
259
283
  };
260
284
  export var addKeys = function addKeys() {
261
- var _context4;
285
+ var _context2;
262
286
 
263
287
  var prevKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
264
288
  var newKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
265
- return _Array$from(new _Set(_concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(prevKeys), _toConsumableArray(newKeys))));
289
+ return _Array$from(new _Set(_concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(prevKeys), _toConsumableArray(newKeys))));
266
290
  };
267
291
  export var getAllParentKeys = function getAllParentKeys(data) {
268
292
  var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@@ -315,14 +339,14 @@ export var getPos = function getPos(data, key) {
315
339
  return node === null || node === void 0 ? void 0 : node.pos;
316
340
  };
317
341
  export var getInitCheckedKeys = function getInitCheckedKeys(data, keys) {
318
- var _context5;
342
+ var _context3;
319
343
 
320
344
  var checkedKeys = [];
321
345
  keys.forEach(function (item) {
322
346
  var pos = getPos(data, item);
323
347
  checkedKeys.push.apply(checkedKeys, _toConsumableArray(getAllChildKeys(data, pos)));
324
348
  });
325
- return _Array$from(new _Set(_concatInstanceProperty(_context5 = []).call(_context5, checkedKeys, _toConsumableArray(keys))));
349
+ return _Array$from(new _Set(_concatInstanceProperty(_context3 = []).call(_context3, checkedKeys, _toConsumableArray(keys))));
326
350
  };
327
351
  export var getInitCheckededState = function getInitCheckededState(data) {
328
352
  var checkedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -497,7 +521,7 @@ var getRootKeys = function getRootKeys(data) {
497
521
  export var getInitExpandedKeys = function getInitExpandedKeys(data, expandedKeys, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent) {
498
522
  var expandScrollkeys = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
499
523
  var filterTreeNode = arguments.length > 7 ? arguments[7] : undefined;
500
- var filterValue = arguments.length > 8 ? arguments[8] : undefined;
524
+ var isSearching = arguments.length > 8 ? arguments[8] : undefined;
501
525
  var keys = (expandedKeys === null || expandedKeys === void 0 ? void 0 : _concatInstanceProperty(expandedKeys).call(expandedKeys, expandScrollkeys)) || (defaultExpandedKeys === null || defaultExpandedKeys === void 0 ? void 0 : _concatInstanceProperty(defaultExpandedKeys).call(defaultExpandedKeys, expandScrollkeys)) || [];
502
526
 
503
527
  if (defaultExpandAll) {
@@ -520,10 +544,10 @@ export var getInitExpandedKeys = function getInitExpandedKeys(data, expandedKeys
520
544
  }
521
545
  }
522
546
 
523
- if (typeof filterTreeNode === 'function' && filterValue) {
524
- var _context6;
547
+ if (isSearching) {
548
+ var _context4;
525
549
 
526
- keys = _concatInstanceProperty(_context6 = []).call(_context6, _toConsumableArray(keys), _toConsumableArray(getAllFilterKeys(data, filterTreeNode)));
550
+ keys = _concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(keys), _toConsumableArray(getAllFilterKeys(data, filterTreeNode)));
527
551
  }
528
552
 
529
553
  return _Array$from(new _Set(_toConsumableArray(keys)));
@@ -65,12 +65,6 @@ var AnchorLink = function AnchorLink(props) {
65
65
  }, [href, registerLink, prevHref]);
66
66
 
67
67
  var handleClick = function handleClick(e) {
68
- var anchorElement = document.getElementById(href.replace('#', ''));
69
-
70
- if (anchorElement) {
71
- anchorElement.scrollIntoView();
72
- }
73
-
74
68
  onClick === null || onClick === void 0 ? void 0 : onClick(e, {
75
69
  title: title,
76
70
  href: href
@@ -82,6 +82,85 @@ function getOffsetTop(element, container) {
82
82
  return rect.top;
83
83
  }
84
84
 
85
+ function isWindow(obj) {
86
+ return obj !== null && obj !== undefined && obj === obj.window;
87
+ }
88
+
89
+ function getScroll(target, top) {
90
+ var _a;
91
+
92
+ if (typeof window === 'undefined') {
93
+ return 0;
94
+ }
95
+
96
+ var method = top ? 'scrollTop' : 'scrollLeft';
97
+ var result = 0;
98
+
99
+ if (isWindow(target)) {
100
+ result = target[top ? 'pageYOffset' : 'pageXOffset'];
101
+ } else if (target instanceof Document) {
102
+ result = target.documentElement[method];
103
+ } else if (target) {
104
+ result = target[method];
105
+ }
106
+
107
+ if (target && !isWindow(target) && typeof result !== 'number') {
108
+ result = (_a = (target.ownerDocument || target).documentElement) === null || _a === void 0 ? void 0 : _a[method];
109
+ }
110
+
111
+ return result;
112
+ }
113
+
114
+ function easeInOutCubic(t, b, c, d) {
115
+ var cc = c - b;
116
+ t /= d / 2;
117
+
118
+ if (t < 1) {
119
+ return cc / 2 * t * t * t + b;
120
+ }
121
+
122
+ return cc / 2 * ((t -= 2) * t * t + 2) + b;
123
+ }
124
+
125
+ function scrollTo(y) {
126
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
127
+ var _options$getContainer = options.getContainer,
128
+ getContainer = _options$getContainer === void 0 ? function () {
129
+ return window;
130
+ } : _options$getContainer,
131
+ callback = options.callback,
132
+ _options$duration = options.duration,
133
+ duration = _options$duration === void 0 ? 450 : _options$duration;
134
+ var container = getContainer();
135
+ var scrollTop = getScroll(container, true);
136
+ var startTime = Date.now();
137
+
138
+ var frameFunc = function frameFunc() {
139
+ var timestamp = Date.now();
140
+ var time = timestamp - startTime;
141
+ var nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
142
+
143
+ if (isWindow(container)) {
144
+ ;
145
+ container.scrollTo(window.pageXOffset, nextScrollTop);
146
+ } else if (container instanceof HTMLDocument || container.constructor.name === 'HTMLDocument') {
147
+ ;
148
+ container.documentElement.scrollTop = nextScrollTop;
149
+ } else {
150
+ ;
151
+ container.scrollTop = nextScrollTop;
152
+ }
153
+
154
+ if (time < duration) {
155
+ window.requestAnimationFrame(frameFunc);
156
+ } else if (typeof callback === 'function') {
157
+ callback();
158
+ }
159
+ };
160
+
161
+ window.requestAnimationFrame(frameFunc);
162
+ }
163
+
85
164
  var InternalAnchor = function InternalAnchor(props, ref) {
86
165
  var _a;
87
166
 
@@ -100,6 +179,7 @@ var InternalAnchor = function InternalAnchor(props, ref) {
100
179
  getCurrentAnchor = anchorProps.getCurrentAnchor,
101
180
  _anchorProps$offsetTo = anchorProps.offsetTop,
102
181
  offsetTop = _anchorProps$offsetTo === void 0 ? 0 : _anchorProps$offsetTo,
182
+ targetOffset = anchorProps.targetOffset,
103
183
  getContainer = anchorProps.getContainer,
104
184
  _anchorProps$bounds = anchorProps.bounds,
105
185
  bounds = _anchorProps$bounds === void 0 ? 5 : _anchorProps$bounds,
@@ -312,6 +392,26 @@ var InternalAnchor = function InternalAnchor(props, ref) {
312
392
 
313
393
  var handleScrollTo = function handleScrollTo(link) {
314
394
  setCurrentActiveLink(link);
395
+ var container = getScrollContainer();
396
+ var scrollTop = getScroll(container, true);
397
+ var sharpLinkMatch = sharpMatcherRegx.exec(link);
398
+
399
+ if (!sharpLinkMatch) {
400
+ return;
401
+ }
402
+
403
+ var targetElement = document.getElementById(sharpLinkMatch[1]);
404
+
405
+ if (!targetElement) {
406
+ return;
407
+ }
408
+
409
+ var eleOffsetTop = getOffsetTop(targetElement, container);
410
+ var y = scrollTop + eleOffsetTop;
411
+ y -= targetOffset !== undefined ? targetOffset : offsetTop || 0;
412
+ scrollTo(y, {
413
+ getContainer: getScrollContainer
414
+ });
315
415
  };
316
416
 
317
417
  var setCurrentActiveLink = (0, _react.useCallback)(function (link) {
@@ -336,9 +436,9 @@ var InternalAnchor = function InternalAnchor(props, ref) {
336
436
  }
337
437
  }
338
438
 
339
- var currentActiveLink = getAnchor(offsetTop || 0, bounds);
439
+ var currentActiveLink = getAnchor(targetOffset !== undefined ? targetOffset : offsetTop || 0, bounds);
340
440
  currentActiveLink && setCurrentActiveLink(currentActiveLink);
341
- }, [affix, setFixedTop, offsetTop, bounds, getAnchor, setCurrentActiveLink, type, getScrollContainer, anchorRef]);
441
+ }, [affix, setFixedTop, offsetTop, bounds, getAnchor, setCurrentActiveLink, type, getScrollContainer, anchorRef, targetOffset]);
342
442
  (0, _react.useEffect)(function () {
343
443
  getScrollContainer().addEventListener('scroll', handleScroll);
344
444
  handleScroll();
@@ -64,7 +64,8 @@ var InternalAvatar = function InternalAvatar(props, ref) {
64
64
  alt = avatarProps.alt,
65
65
  children = avatarProps.children,
66
66
  gap = avatarProps.gap,
67
- disabled = avatarProps.disabled;
67
+ disabled = avatarProps.disabled,
68
+ srcSet = avatarProps.srcSet;
68
69
  (0, _devwarning.default)(AvatarSizes.indexOf(size) === -1 && typeof size !== 'number', 'avatar', "cannot found avatar type '".concat(size, "'"));
69
70
  (0, _devwarning.default)(AvatarShapes.indexOf(shape) === -1, 'avatar', "cannot found avatar shape '".concat(shape, "'"));
70
71
 
@@ -145,6 +146,7 @@ var InternalAvatar = function InternalAvatar(props, ref) {
145
146
  if (typeof src === 'string' && isImgExist) {
146
147
  childrenToRender = /*#__PURE__*/_react.default.createElement("img", {
147
148
  src: src,
149
+ srcSet: srcSet,
148
150
  draggable: draggable,
149
151
  onError: handleImgLoadError,
150
152
  alt: alt
@@ -241,6 +241,7 @@ var InternalDrawer = function InternalDrawer(props, ref) {
241
241
  width: width,
242
242
  transform: transform
243
243
  } : {
244
+ height: height,
244
245
  transform: transform
245
246
  });
246
247
 
@@ -35,6 +35,16 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
35
35
 
36
36
  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; }
37
37
 
38
+ var findItem = function findItem(element) {
39
+ var isItem = element.className === 'kd-dropdown-menu-item';
40
+
41
+ if (isItem) {
42
+ return element;
43
+ } else {
44
+ return element.parentNode ? findItem(element.parentNode) : null;
45
+ }
46
+ };
47
+
38
48
  var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
39
49
  var _a, _b, _c;
40
50
 
@@ -65,7 +75,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
65
75
  setVisible(!!props.visible);
66
76
  }, [props.visible]);
67
77
  var child = /*#__PURE__*/React.cloneElement(React.Children.only(children), {
68
- ref: ref,
78
+ ref: children.ref || ref,
69
79
  className: (0, _classnames.default)("".concat(prefixCls, "-trigger"), children.props.className, {
70
80
  disabled: disabled
71
81
  })
@@ -83,13 +93,12 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (props, ref) {
83
93
  var menuSelectable = ((_b = menu.props) === null || _b === void 0 ? void 0 : _b.selectable) === undefined ? selectable : (_c = menu.props) === null || _c === void 0 ? void 0 : _c.selectable;
84
94
 
85
95
  var handleItemClick = function handleItemClick(e) {
86
- var _a, _b;
96
+ var _a;
87
97
 
88
- var currentTarget = e.target;
89
- var parentTarget = currentTarget.parentNode;
90
- var key = ((_a = currentTarget.dataset) === null || _a === void 0 ? void 0 : _a.key) || ((_b = currentTarget.parentNode.dataset) === null || _b === void 0 ? void 0 : _b.key);
98
+ var item = findItem(e.target);
99
+ var key = (_a = item === null || item === void 0 ? void 0 : item.dataset) === null || _a === void 0 ? void 0 : _a.key;
91
100
 
92
- if (currentTarget.className.indexOf('disabled') === -1 && parentTarget.className.indexOf('disabled') === -1 && key) {
101
+ if ((item === null || item === void 0 ? void 0 : item.className.indexOf('disabled')) === -1 && key) {
93
102
  if (isMenu && menu.props.onClick) {
94
103
  menu.props.onClick(key);
95
104
  } else if (onItemClick) {
@@ -63,13 +63,13 @@ var ClearableInput = function ClearableInput(props) {
63
63
  };
64
64
 
65
65
  var renderSuffix = function renderSuffix() {
66
- if (!suffix && !allowClear) {
67
- return null;
66
+ if (suffix || !disabled && allowClear) {
67
+ return /*#__PURE__*/_react.default.createElement("span", {
68
+ className: "".concat(prefixCls, "-suffix")
69
+ }, renderClearIcon(), suffix);
68
70
  }
69
71
 
70
- return /*#__PURE__*/_react.default.createElement("span", {
71
- className: "".concat(prefixCls, "-suffix")
72
- }, renderClearIcon(), suffix);
72
+ return null;
73
73
  };
74
74
 
75
75
  var renderInputWithFixNode = function renderInputWithFixNode(originElement) {
@@ -93,7 +93,7 @@ var ClearableInput = function ClearableInput(props) {
93
93
  };
94
94
 
95
95
  var renderInputWithLabel = function renderInputWithLabel(originElement) {
96
- var _classNames4, _context2, _classNames5, _context3;
96
+ var _classNames4, _context2, _classNames5;
97
97
 
98
98
  if (!addonBefore && !addonAfter) {
99
99
  return originElement;
@@ -113,8 +113,7 @@ var ClearableInput = function ClearableInput(props) {
113
113
  className: inputGroupClasses,
114
114
  style: style
115
115
  }, addonBeforeNode, /*#__PURE__*/_react.default.cloneElement(originElement, {
116
- style: null,
117
- className: (0, _concat.default)(_context3 = "".concat(originElement.props.className || '', " ")).call(_context3, prefixCls, "-wrapper")
116
+ style: null
118
117
  }), addonAfterNode));
119
118
  };
120
119
 
@@ -360,6 +360,15 @@ textarea {
360
360
  .kd-input-wrapper-focused .kd-input-textarea-clear-icon {
361
361
  color: var(--kd-c-input-color-border-focused, var(--kd-g-color-theme, #5582f3));
362
362
  }
363
+ .kd-input-wrapper-disabled {
364
+ background-color: var(--kd-c-input-color-background-disabled, var(--kd-g-color-background-contain-disabled, #f5f5f5));
365
+ border-color: var(--kd-c-input-color-border-disabled, var(--kd-g-color-border-strong, #d9d9d9));
366
+ cursor: not-allowed;
367
+ }
368
+ .kd-input-wrapper-disabled .kd-input-suffix,
369
+ .kd-input-wrapper-disabled .kd-input-prefix {
370
+ color: var(--kd-c-input-color-disabled, var(--kd-g-color-disabled, #b2b2b2));
371
+ }
363
372
  .kd-input-wrapper-textarea {
364
373
  width: 100%;
365
374
  min-width: 0;
@@ -503,6 +512,7 @@ textarea {
503
512
  .kd-input-group-wrapper .kd-input-group .kd-input-group-addon-disabled {
504
513
  background-color: var(--kd-c-input-color-background-disabled, var(--kd-g-color-background-contain-disabled, #f5f5f5));
505
514
  border-color: var(--kd-c-input-color-border-disabled, var(--kd-g-color-border-strong, #d9d9d9));
515
+ color: var(--kd-c-input-color-disabled, var(--kd-g-color-disabled, #b2b2b2));
506
516
  cursor: not-allowed;
507
517
  }
508
518
  .kd-input-group-wrapper .kd-input-group-size-small .kd-input-group-addon {
@@ -126,6 +126,16 @@ textarea {
126
126
  color: @input-border-color-focused;
127
127
  }
128
128
  }
129
+
130
+ &-disabled {
131
+ background-color: @input-background-color-disabled-inner;
132
+ border-color: @input-border-color-disabled-inner;
133
+ cursor: not-allowed;
134
+
135
+ .@{input-prefix-cls}-suffix, .@{input-prefix-cls}-prefix {
136
+ color: @input-color-disabled-inner;
137
+ }
138
+ }
129
139
  }
130
140
  &-wrapper-textarea {
131
141
  .input(@input-prefix-cls);
@@ -219,6 +229,7 @@ textarea {
219
229
  &-disabled {
220
230
  background-color: @input-background-color-disabled-inner;
221
231
  border-color: @input-border-color-disabled-inner;
232
+ color: @input-color-disabled-inner;
222
233
  cursor: not-allowed;
223
234
  }
224
235
  }
@@ -407,7 +407,7 @@
407
407
  .kd-radio-button-checked:hover {
408
408
  color: var(--kd-c-radio-color-background, var(--kd-g-color-white, #fff));
409
409
  }
410
- .kd-radio-button-checked::before {
410
+ .kd-radio-button-checked:not(.kd-radio-button-disabled)::before {
411
411
  background-color: var(--kd-c-radio-color-theme, var(--kd-g-color-theme, #5582f3));
412
412
  }
413
413
  .kd-radio-button-checked:first-child {
@@ -312,7 +312,7 @@
312
312
  color: @radio-color-background;
313
313
  }
314
314
 
315
- &::before {
315
+ &:not(.@{radio-button-prefix-cls}-disabled)::before {
316
316
  background-color: @radio-color-theme;
317
317
  }
318
318
 
@@ -476,7 +476,7 @@ var InternalSelect = function InternalSelect(props, ref) {
476
476
  var selectedVal = multipleRef.current.selectedVal; // 选择器下拉icon样式
477
477
 
478
478
  var arrowIconCls = (0, _classnames.default)((_classNames8 = {}, (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow"), true), (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), (0, _defineProperty2.default)(_classNames8, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames8));
479
- var iconShow = allowClear && (isMultiple ? mulOptions.length > 0 : selectedVal);
479
+ var iconShow = allowClear && !disabled && (isMultiple ? mulOptions.length > 0 : (selectedVal !== null && selectedVal !== void 0 ? selectedVal : '') !== '');
480
480
  var clearIconCls = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(selectPrefixCls, "-icon-clear"), true));
481
481
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, iconShow && /*#__PURE__*/_react.default.createElement("span", {
482
482
  onClick: handleReset,
@@ -428,7 +428,7 @@
428
428
  .kd-select-item-option-disabled {
429
429
  color: var(--kd-c-select-item-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
430
430
  cursor: not-allowed;
431
- background-color: var(--kd-c-select-item-color-background-disabled, var(--kd-g-color-background-contain-disabled, #f5f5f5));
431
+ background-color: var(--kd-c-select-item-color-background-disabled, #fff);
432
432
  }
433
433
  .kd-select-size-small {
434
434
  min-height: var(--kd-c-select-sizing-height-small, 24px);
@@ -472,7 +472,7 @@
472
472
  }
473
473
  .kd-select-single-disabled {
474
474
  background-color: var(--kd-c-select-color-background-disabled, #f5f5f5);
475
- color: var(--kd-c-select-color-text-disabled, #212121);
475
+ color: var(--kd-c-select-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
476
476
  }
477
477
  .kd-select-single-disabled:hover {
478
478
  cursor: not-allowed;
@@ -484,13 +484,13 @@
484
484
  opacity: 1;
485
485
  }
486
486
  .kd-select-single-text {
487
- color: #666;
487
+ color: var(--kd-c-select-single-color-text, var(--kd-g-color-text-primary, #212121));
488
488
  overflow: hidden;
489
489
  white-space: nowrap;
490
490
  text-overflow: ellipsis;
491
491
  }
492
492
  .kd-select-single-disabled-text {
493
- color: var(--kd-c-select-color-text-disabled, #212121);
493
+ color: var(--kd-c-select-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
494
494
  }
495
495
  .kd-select .kd-select-selection-item {
496
496
  display: -webkit-inline-box;
@@ -564,7 +564,7 @@
564
564
  .kd-select-multiple-disabled {
565
565
  cursor: not-allowed;
566
566
  background-color: var(--kd-c-select-color-background-disabled, #f5f5f5);
567
- color: var(--kd-c-select-color-text-disabled, #212121);
567
+ color: var(--kd-c-select-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
568
568
  }
569
569
  .kd-select-multiple-disabled .kd-select-suffix {
570
570
  color: var(--kd-c-select-arrow-icon-color-text-disabled, #b2b2b2);
@@ -234,7 +234,7 @@
234
234
  opacity: 1;
235
235
  }
236
236
  &-text {
237
- color: #666;
237
+ color: @select-single-color-text;
238
238
  .over();
239
239
  }
240
240
  &-disabled-text {
@@ -5,7 +5,7 @@
5
5
 
6
6
  // color
7
7
  @select-dropdown-bg: var(~'@{select-custom-prefix}-dropdown-color-background', @color-background);
8
- @select-disabled-option-bg: var(~'@{select-custom-prefix}-item-color-background-disabled', @color-background-contain-disabled);
8
+ @select-disabled-option-bg: var(~'@{select-custom-prefix}-item-color-background-disabled', #fff);
9
9
  @select-item-active-bg: var(~'@{select-custom-prefix}-color-background', #f5f5f5);
10
10
  @select-item-selected-bg: var(~'@{select-custom-prefix}-color-background-selected', @color-theme-3);
11
11
  @select-g-color-border: var(~'@{select-custom-prefix}-color-border', @color-input);
@@ -18,8 +18,9 @@
18
18
  @select-footer-g-text-color-selected: var(~'@{select-custom-prefix}-footer-color-text-selected', #0e5fd8);
19
19
  @select-g-item-text-color-disabled: var(~'@{select-custom-prefix}-item-color-text-disabled', @color-disabled);
20
20
  @select-color-background-disabled: var(~'@{select-custom-prefix}-color-background-disabled', #f5f5f5);
21
- @select-color-text-disabled: var(~'@{select-custom-prefix}-color-text-disabled', #212121);
21
+ @select-color-text-disabled: var(~'@{select-custom-prefix}-color-text-disabled', @color-disabled);
22
22
  @select-arrow-icon-color-text-disabled: var(~'@{select-custom-prefix}-arrow-icon-color-text-disabled', #b2b2b2);
23
+ @select-single-color-text: var(~'@{select-custom-prefix}-single-color-text', @color-text-primary);
23
24
 
24
25
  // font
25
26
  @select-list-font-size: var(~'@{select-custom-prefix}-dropdown-font-size', 12px); // 下拉列表文字大小