@kdcloudjs/kdesign 1.6.15 → 1.6.17

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 (56) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/kdesign-complete.less +5 -0
  3. package/dist/kdesign.css +7 -1
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +563 -316
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +2 -2
  8. package/dist/kdesign.min.js +8 -8
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/usePopper.js +2 -0
  11. package/es/checkbox/checkbox.d.ts +1 -4
  12. package/es/checkbox/checkbox.js +26 -19
  13. package/es/checkbox/group.d.ts +11 -1
  14. package/es/checkbox/group.js +43 -71
  15. package/es/checkbox/index.d.ts +2 -1
  16. package/es/checkbox/index.js +1 -1
  17. package/es/date-picker/range/input-range.js +1 -1
  18. package/es/date-picker/single/input-date.js +1 -1
  19. package/es/modal/style/index.css +4 -0
  20. package/es/modal/style/index.less +2 -0
  21. package/es/select/select.js +4 -3
  22. package/es/stepper/style/index.css +2 -0
  23. package/es/stepper/style/index.less +3 -0
  24. package/es/table/feature/useFooterDataSource.d.ts +3 -0
  25. package/es/table/feature/useFooterDataSource.js +11 -0
  26. package/es/table/interface.d.ts +1 -0
  27. package/es/table/table.js +10 -9
  28. package/es/tree/tree.js +15 -1
  29. package/es/tree/treeHooks.d.ts +1 -1
  30. package/es/tree/treeHooks.js +5 -5
  31. package/es/tree/utils/treeUtils.d.ts +3 -2
  32. package/es/tree/utils/treeUtils.js +49 -17
  33. package/lib/_utils/usePopper.js +2 -0
  34. package/lib/checkbox/checkbox.d.ts +1 -4
  35. package/lib/checkbox/checkbox.js +32 -25
  36. package/lib/checkbox/group.d.ts +11 -1
  37. package/lib/checkbox/group.js +49 -75
  38. package/lib/checkbox/index.d.ts +2 -1
  39. package/lib/checkbox/index.js +4 -4
  40. package/lib/date-picker/range/input-range.js +1 -1
  41. package/lib/date-picker/single/input-date.js +1 -1
  42. package/lib/modal/style/index.css +4 -0
  43. package/lib/modal/style/index.less +2 -0
  44. package/lib/select/select.js +4 -3
  45. package/lib/stepper/style/index.css +2 -0
  46. package/lib/stepper/style/index.less +3 -0
  47. package/lib/table/feature/useFooterDataSource.d.ts +3 -0
  48. package/lib/table/feature/useFooterDataSource.js +19 -0
  49. package/lib/table/interface.d.ts +1 -0
  50. package/lib/table/table.js +11 -9
  51. package/lib/tree/tree.js +16 -1
  52. package/lib/tree/treeHooks.d.ts +1 -1
  53. package/lib/tree/treeHooks.js +5 -5
  54. package/lib/tree/utils/treeUtils.d.ts +3 -2
  55. package/lib/tree/utils/treeUtils.js +54 -19
  56. package/package.json +1 -1
@@ -3,12 +3,12 @@ import _extends from "@babel/runtime-corejs3/helpers/extends";
3
3
  import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
4
4
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
5
5
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
6
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
7
6
  import _Set from "@babel/runtime-corejs3/core-js-stable/set";
7
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
8
9
  import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
9
10
  import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
10
11
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
11
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
12
12
  import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/splice";
13
13
 
14
14
  var __rest = this && this.__rest || function (s, e) {
@@ -124,21 +124,52 @@ var isAllParentExpand = function isAllParentExpand(_data, pos, posData) {
124
124
  return expand;
125
125
  };
126
126
 
127
+ export function findfilterChildrenKeys(node, allFilterKeys) {
128
+ var nodes = new _Set();
129
+
130
+ var loop = function loop(children) {
131
+ _mapInstanceProperty(children).call(children, function (child) {
132
+ var key = child.key;
133
+ var item = child;
134
+ allFilterKeys.add(key);
135
+ loop(item.children || []);
136
+ });
137
+ };
138
+
139
+ if (node) {
140
+ loop(node.children || []);
141
+ }
142
+
143
+ return nodes;
144
+ }
127
145
  export var getAllFilterKeys = function getAllFilterKeys(data, filterTreeNode, keysData) {
128
- var allFilterKeys = [];
146
+ var allFilterKeys = new _Set();
147
+ var filterExpandKeys = new _Set();
129
148
 
130
- _filterInstanceProperty(data).call(data, function (item) {
149
+ var filterKeys = _filterInstanceProperty(data).call(data, function (item) {
131
150
  return filterTreeNode === null || filterTreeNode === void 0 ? void 0 : filterTreeNode(item);
132
- }).forEach(function (item) {
151
+ });
152
+
153
+ filterKeys.forEach(function (item) {
154
+ findfilterChildrenKeys(item, allFilterKeys);
155
+ });
156
+ filterKeys.forEach(function (item) {
133
157
  var node = _extends({}, item);
134
158
 
135
159
  while (node) {
136
- allFilterKeys.push(node.key);
160
+ var _context3;
161
+
162
+ allFilterKeys.add(node.key);
163
+ !_includesInstanceProperty(_context3 = _mapInstanceProperty(filterKeys).call(filterKeys, function (i) {
164
+ return i.key;
165
+ })).call(_context3, node.key) && filterExpandKeys.add(node.key);
137
166
  node = (keysData === null || keysData === void 0 ? void 0 : keysData[node === null || node === void 0 ? void 0 : node.parentKey]) || null;
138
167
  }
139
168
  });
140
-
141
- return _toConsumableArray(new _Set(allFilterKeys));
169
+ return {
170
+ allFilterKeys: _toConsumableArray(allFilterKeys),
171
+ filterExpandKeys: _toConsumableArray(filterExpandKeys)
172
+ };
142
173
  };
143
174
  export var getFilterData = function getFilterData(data, filterTreeNode, isSearching) {
144
175
  var posData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -147,7 +178,7 @@ export var getFilterData = function getFilterData(data, filterTreeNode, isSearch
147
178
  var allFilterKeys = null;
148
179
 
149
180
  if (isSearching) {
150
- allFilterKeys = getAllFilterKeys(filterData, filterTreeNode, keysData);
181
+ allFilterKeys = getAllFilterKeys(filterData, filterTreeNode, keysData).allFilterKeys;
151
182
  filterData = _filterInstanceProperty(filterData).call(filterData, function (item) {
152
183
  return _includesInstanceProperty(allFilterKeys).call(allFilterKeys, item.key);
153
184
  });
@@ -298,11 +329,11 @@ export var getSpreadAttrData = function getSpreadAttrData(treeData, expandedKeys
298
329
  };
299
330
  };
300
331
  export var addKeys = function addKeys() {
301
- var _context3;
332
+ var _context4;
302
333
 
303
334
  var prevKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
304
335
  var newKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
305
- return _Array$from(new _Set(_concatInstanceProperty(_context3 = []).call(_context3, _toConsumableArray(prevKeys), _toConsumableArray(newKeys))));
336
+ return _Array$from(new _Set(_concatInstanceProperty(_context4 = []).call(_context4, _toConsumableArray(prevKeys), _toConsumableArray(newKeys))));
306
337
  };
307
338
  export var getAllParentKeys = function getAllParentKeys(data) {
308
339
  var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@@ -355,14 +386,14 @@ export var getPos = function getPos(data, key) {
355
386
  return node === null || node === void 0 ? void 0 : node.pos;
356
387
  };
357
388
  export var getInitCheckedKeys = function getInitCheckedKeys(data, keys) {
358
- var _context4;
389
+ var _context5;
359
390
 
360
391
  var checkedKeys = [];
361
392
  keys.forEach(function (item) {
362
393
  var pos = getPos(data, item);
363
394
  checkedKeys.push.apply(checkedKeys, _toConsumableArray(getAllChildKeys(data, pos)));
364
395
  });
365
- return _Array$from(new _Set(_concatInstanceProperty(_context4 = []).call(_context4, checkedKeys, _toConsumableArray(keys))));
396
+ return _Array$from(new _Set(_concatInstanceProperty(_context5 = []).call(_context5, checkedKeys, _toConsumableArray(keys))));
366
397
  };
367
398
  export var getInitCheckededState = function getInitCheckededState(data) {
368
399
  var checkedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -484,7 +515,7 @@ var updateParent = function updateParent(key, keysNodeProps, allKeys, halfChecke
484
515
  };
485
516
 
486
517
  export var getInitCheckededKeys = function getInitCheckededKeys() {
487
- var _context5;
518
+ var _context6;
488
519
 
489
520
  var checkedKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
490
521
  var keysNodeProps = arguments.length > 1 ? arguments[1] : undefined;
@@ -506,7 +537,7 @@ export var getInitCheckededKeys = function getInitCheckededKeys() {
506
537
  }
507
538
  });
508
539
  return {
509
- checkedKeys: _toConsumableArray(new _Set(_concatInstanceProperty(_context5 = []).call(_context5, _toConsumableArray(checkedKeysSet), _toConsumableArray(childCheckedKeysSet)))),
540
+ checkedKeys: _toConsumableArray(new _Set(_concatInstanceProperty(_context6 = []).call(_context6, _toConsumableArray(checkedKeysSet), _toConsumableArray(childCheckedKeysSet)))),
510
541
  halfCheckedKeys: _toConsumableArray(halfCheckedKeysSet)
511
542
  };
512
543
  };
@@ -672,6 +703,7 @@ export var getInitExpandedKeys = function getInitExpandedKeys(data, expandedKeys
672
703
  var filterTreeNode = arguments.length > 7 ? arguments[7] : undefined;
673
704
  var isSearching = arguments.length > 8 ? arguments[8] : undefined;
674
705
  var keysData = arguments.length > 9 ? arguments[9] : undefined;
706
+ var searchExpandedKeys = arguments.length > 10 ? arguments[10] : undefined;
675
707
  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)) || [];
676
708
 
677
709
  if (defaultExpandAll) {
@@ -695,9 +727,9 @@ export var getInitExpandedKeys = function getInitExpandedKeys(data, expandedKeys
695
727
  }
696
728
 
697
729
  if (isSearching) {
698
- var _context6;
730
+ var _context7;
699
731
 
700
- keys = _concatInstanceProperty(_context6 = []).call(_context6, _toConsumableArray(keys), _toConsumableArray(getAllFilterKeys(data, filterTreeNode, keysData)));
732
+ keys = _concatInstanceProperty(_context7 = []).call(_context7, _toConsumableArray(searchExpandedKeys), _toConsumableArray(getAllFilterKeys(data, filterTreeNode, keysData).filterExpandKeys));
701
733
  }
702
734
 
703
735
  return _Array$from(new _Set(_toConsumableArray(keys)));
@@ -590,10 +590,12 @@ function usePopper(locatorElement, popperElement, props) {
590
590
  focus: 'mousedown',
591
591
  contextMenu: 'mousedown'
592
592
  };
593
+ popperNode === null || popperNode === void 0 ? void 0 : popperNode.addEventListener('mouseleave', debounceHidePopper);
593
594
  Array.isArray(trigger) ? trigger.forEach(function (action) {
594
595
  return document.addEventListener(mapEvent[action], debounceHidePopper);
595
596
  }) : document.addEventListener(mapEvent[trigger], debounceHidePopper);
596
597
  return function () {
598
+ popperNode === null || popperNode === void 0 ? void 0 : popperNode.removeEventListener('mouseleave', debounceHidePopper);
597
599
  Array.isArray(trigger) ? trigger.forEach(function (action) {
598
600
  return document.removeEventListener(mapEvent[action], debounceHidePopper);
599
601
  }) : document.removeEventListener(mapEvent[trigger], debounceHidePopper);
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
- export declare const CheckboxTypes: ["default", "square"];
3
- export declare type CheckboxType = typeof CheckboxTypes[number];
4
- export declare const CheckboxSizes: ["large", "middle", "small"];
5
- export declare type CheckboxSize = typeof CheckboxSizes[number];
2
+ import type { CheckboxType, CheckboxSize } from './group';
6
3
  export interface CheckboxProps {
7
4
  checked?: boolean;
8
5
  defaultChecked?: boolean;
@@ -11,7 +11,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
11
11
  Object.defineProperty(exports, "__esModule", {
12
12
  value: true
13
13
  });
14
- exports.default = exports.CheckboxTypes = exports.CheckboxSizes = void 0;
14
+ exports.default = void 0;
15
15
 
16
16
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
17
17
 
@@ -27,12 +27,12 @@ var _react = _interopRequireWildcard(require("react"));
27
27
 
28
28
  var _classnames = _interopRequireDefault(require("classnames"));
29
29
 
30
+ var _group = require("./group");
31
+
30
32
  var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));
31
33
 
32
34
  var _utils = require("../_utils");
33
35
 
34
- var _type = require("../_utils/type");
35
-
36
36
  var _isBoolean = _interopRequireDefault(require("lodash/isBoolean"));
37
37
 
38
38
  var _icon = _interopRequireDefault(require("../icon"));
@@ -56,11 +56,6 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
56
56
  return t;
57
57
  };
58
58
 
59
- var CheckboxTypes = (0, _type.tuple)('default', 'square');
60
- exports.CheckboxTypes = CheckboxTypes;
61
- var CheckboxSizes = (0, _type.tuple)('large', 'middle', 'small');
62
- exports.CheckboxSizes = CheckboxSizes;
63
-
64
59
  var InternalCheckbox = function InternalCheckbox(props, ref) {
65
60
  var _context, _context2, _context3, _classNames, _context4, _context5, _context6, _classNames2, _context7, _context8, _context9, _context10, _context11, _context12, _context13, _context14, _classNames4, _context15, _context16, _context17, _classNames5, _context18;
66
61
 
@@ -86,38 +81,50 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
86
81
  name = CheckboxProps.name,
87
82
  rest = __rest(CheckboxProps, ["checkboxType", "className", "prefixCls", "defaultChecked", "checked", "size", "onChange", "disabled", "children", "style", "value", "indeterminate", "name"]);
88
83
 
89
- var getChecked = function getChecked() {
90
- return (0, _isBoolean.default)(checked) ? checked : defaultChecked;
91
- };
84
+ var checkboxGroup = _react.default.useContext(_group.GroupContext);
92
85
 
93
- var _useState = (0, _react.useState)(getChecked()),
86
+ var mergedDisabled = (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.disabled) || disabled;
87
+ var mergedCheckboxType = (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.checkboxType) || checkboxType;
88
+ var mergedName = (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.name) || name;
89
+ var initChecked = (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.groupValue) ? (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.groupValue.indexOf(value)) > -1 : (0, _isBoolean.default)(checked) ? checked : defaultChecked;
90
+
91
+ var _useState = (0, _react.useState)(initChecked),
94
92
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
95
93
  selected = _useState2[0],
96
94
  setSelected = _useState2[1];
97
95
 
98
96
  var labelRef = (0, _react.useRef)(null);
99
- (0, _devwarning.default)(CheckboxTypes.indexOf(checkboxType) === -1, 'checkbox', "cannot found checkbox type '".concat(checkboxType, "'"));
100
- (0, _devwarning.default)(CheckboxSizes.indexOf(size) === -1, 'checkbox', "cannot found size type '".concat(size, "'"));
97
+
98
+ _react.default.useEffect(function () {
99
+ setSelected((checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.groupValue) ? (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.groupValue.indexOf(value)) > -1 : (0, _isBoolean.default)(checked) ? checked : defaultChecked);
100
+ }, [checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.groupValue, checked, defaultChecked]);
101
+
102
+ (0, _devwarning.default)(_group.CheckboxTypes.indexOf(mergedCheckboxType) === -1, 'checkbox', "cannot found checkbox type '".concat(mergedCheckboxType, "'"));
103
+ (0, _devwarning.default)(_group.CheckboxSizes.indexOf(size) === -1, 'checkbox', "cannot found size type '".concat(size, "'"));
101
104
  var checkboxPrefixCls = getPrefixCls(prefixCls, 'checkbox', customPrefixcls);
102
105
 
103
106
  var isDefaultType = function isDefaultType() {
104
- return checkboxType === 'default';
107
+ return mergedCheckboxType === 'default';
105
108
  };
106
109
 
107
110
  var getIndeterminate = function getIndeterminate() {
108
111
  return selected ? false : indeterminate;
109
112
  };
110
113
 
111
- var getDefaultClassName = (0, _classnames.default)(className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(checkboxPrefixCls), true), (0, _defineProperty2.default)(_classNames, "".concat(checkboxPrefixCls, "-no-child"), !children), (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context = "".concat(checkboxPrefixCls, "-")).call(_context, size), true && !!children), (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context2 = "".concat(checkboxPrefixCls, "-")).call(_context2, checkboxType), true), (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context3 = "".concat(checkboxPrefixCls, "-")).call(_context3, checkboxType, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames, "checked", selected), _classNames));
112
- var getSquareClassName = (0, _classnames.default)(className, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(checkboxPrefixCls), true), (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context4 = "".concat(checkboxPrefixCls, "-")).call(_context4, checkboxType), true), (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context5 = "".concat(checkboxPrefixCls, "-")).call(_context5, checkboxType, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context6 = "".concat(checkboxPrefixCls, "-")).call(_context6, checkboxType, "-checked"), selected && !disabled), (0, _defineProperty2.default)(_classNames2, "checked", selected), _classNames2));
114
+ var getDefaultClassName = (0, _classnames.default)(className, (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(checkboxPrefixCls), true), (0, _defineProperty2.default)(_classNames, "".concat(checkboxPrefixCls, "-no-child"), !children), (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context = "".concat(checkboxPrefixCls, "-")).call(_context, size), true && !!children), (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context2 = "".concat(checkboxPrefixCls, "-")).call(_context2, mergedCheckboxType), true), (0, _defineProperty2.default)(_classNames, (0, _concat.default)(_context3 = "".concat(checkboxPrefixCls, "-")).call(_context3, mergedCheckboxType, "-disabled"), mergedDisabled), (0, _defineProperty2.default)(_classNames, "checked", selected), _classNames));
115
+ var getSquareClassName = (0, _classnames.default)(className, (_classNames2 = {}, (0, _defineProperty2.default)(_classNames2, "".concat(checkboxPrefixCls), true), (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context4 = "".concat(checkboxPrefixCls, "-")).call(_context4, mergedCheckboxType), true), (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context5 = "".concat(checkboxPrefixCls, "-")).call(_context5, mergedCheckboxType, "-disabled"), mergedDisabled), (0, _defineProperty2.default)(_classNames2, (0, _concat.default)(_context6 = "".concat(checkboxPrefixCls, "-")).call(_context6, mergedCheckboxType, "-checked"), selected && !mergedDisabled), (0, _defineProperty2.default)(_classNames2, "checked", selected), _classNames2));
113
116
  var getRootClassName = isDefaultType() ? getDefaultClassName : getSquareClassName;
114
117
  var inputClassName = (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(checkboxPrefixCls, "-input"), true));
115
- var checkedWrapperClassName = (0, _classnames.default)((_classNames4 = {}, (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context7 = "".concat(checkboxPrefixCls, "-")).call(_context7, checkboxType, "-no-child"), !children), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context8 = "".concat(checkboxPrefixCls, "-")).call(_context8, checkboxType, "-wrapper"), true), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context9 = "".concat(checkboxPrefixCls, "-")).call(_context9, checkboxType, "-wrapper-size"), !!children), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context10 = "".concat(checkboxPrefixCls, "-")).call(_context10, checkboxType, "-margin"), !!children), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context11 = "".concat(checkboxPrefixCls, "-")).call(_context11, checkboxType, "-checked"), selected), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context12 = "".concat(checkboxPrefixCls, "-")).call(_context12, checkboxType, "-indeterminate"), getIndeterminate()), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context13 = "".concat(checkboxPrefixCls, "-")).call(_context13, checkboxType, "-disabled"), disabled && !selected), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context14 = "".concat(checkboxPrefixCls, "-")).call(_context14, checkboxType, "-checked-disabled"), disabled && selected), _classNames4));
116
- var triangleClassName = (0, _classnames.default)((_classNames5 = {}, (0, _defineProperty2.default)(_classNames5, (0, _concat.default)(_context15 = "".concat(checkboxPrefixCls, "-")).call(_context15, checkboxType, "-triangle"), !selected), (0, _defineProperty2.default)(_classNames5, (0, _concat.default)(_context16 = "".concat(checkboxPrefixCls, "-")).call(_context16, checkboxType, "-triangle-checked"), selected), (0, _defineProperty2.default)(_classNames5, (0, _concat.default)(_context17 = "".concat(checkboxPrefixCls, "-")).call(_context17, checkboxType, "-triangle-disabled"), disabled), _classNames5));
117
- var innerIconClassName = (0, _classnames.default)((0, _defineProperty2.default)({}, (0, _concat.default)(_context18 = "".concat(checkboxPrefixCls, "-")).call(_context18, checkboxType, "-inner"), true));
118
+ var checkedWrapperClassName = (0, _classnames.default)((_classNames4 = {}, (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context7 = "".concat(checkboxPrefixCls, "-")).call(_context7, mergedCheckboxType, "-no-child"), !children), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context8 = "".concat(checkboxPrefixCls, "-")).call(_context8, mergedCheckboxType, "-wrapper"), true), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context9 = "".concat(checkboxPrefixCls, "-")).call(_context9, mergedCheckboxType, "-wrapper-size"), !!children), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context10 = "".concat(checkboxPrefixCls, "-")).call(_context10, mergedCheckboxType, "-margin"), !!children), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context11 = "".concat(checkboxPrefixCls, "-")).call(_context11, mergedCheckboxType, "-checked"), selected), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context12 = "".concat(checkboxPrefixCls, "-")).call(_context12, mergedCheckboxType, "-indeterminate"), getIndeterminate()), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context13 = "".concat(checkboxPrefixCls, "-")).call(_context13, mergedCheckboxType, "-disabled"), mergedDisabled && !selected), (0, _defineProperty2.default)(_classNames4, (0, _concat.default)(_context14 = "".concat(checkboxPrefixCls, "-")).call(_context14, mergedCheckboxType, "-checked-disabled"), mergedDisabled && selected), _classNames4));
119
+ var triangleClassName = (0, _classnames.default)((_classNames5 = {}, (0, _defineProperty2.default)(_classNames5, (0, _concat.default)(_context15 = "".concat(checkboxPrefixCls, "-")).call(_context15, mergedCheckboxType, "-triangle"), !selected), (0, _defineProperty2.default)(_classNames5, (0, _concat.default)(_context16 = "".concat(checkboxPrefixCls, "-")).call(_context16, mergedCheckboxType, "-triangle-checked"), selected), (0, _defineProperty2.default)(_classNames5, (0, _concat.default)(_context17 = "".concat(checkboxPrefixCls, "-")).call(_context17, mergedCheckboxType, "-triangle-disabled"), mergedDisabled), _classNames5));
120
+ var innerIconClassName = (0, _classnames.default)((0, _defineProperty2.default)({}, (0, _concat.default)(_context18 = "".concat(checkboxPrefixCls, "-")).call(_context18, mergedCheckboxType, "-inner"), true));
118
121
  var handleChange = (0, _react.useCallback)(function (e) {
119
122
  onChange && onChange(e);
120
- setSelected(e.target.checked);
123
+ (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.onCheckboxGroupChange) && (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.onCheckboxGroupChange(value, e.target.checked));
124
+
125
+ if (!(checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.isControlled)) {
126
+ setSelected(e.target.checked);
127
+ }
121
128
  }, [onChange]);
122
129
  (0, _react.useEffect)(function () {
123
130
  (0, _isBoolean.default)(checked) && checked !== selected && setSelected(checked);
@@ -158,7 +165,7 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
158
165
  className: innerIconClassName
159
166
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
160
167
  type: "right-bold",
161
- className: (0, _concat.default)(_context19 = "".concat(checkboxPrefixCls, "-")).call(_context19, checkboxType, "-inner-icon")
168
+ className: (0, _concat.default)(_context19 = "".concat(checkboxPrefixCls, "-")).call(_context19, mergedCheckboxType, "-inner-icon")
162
169
  })), /*#__PURE__*/_react.default.createElement("input", {
163
170
  type: "checkbox",
164
171
  className: inputClassName,
@@ -166,8 +173,8 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
166
173
  ref: ref,
167
174
  value: value,
168
175
  checked: selected,
169
- disabled: disabled,
170
- name: name
176
+ disabled: mergedDisabled,
177
+ name: mergedName
171
178
  })), children && /*#__PURE__*/_react.default.createElement("span", {
172
179
  className: "".concat(checkboxPrefixCls, "-children")
173
180
  }, children), !isDefaultType() && /*#__PURE__*/_react.default.createElement("span", {
@@ -176,7 +183,7 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
176
183
  className: innerIconClassName
177
184
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
178
185
  type: "right-bold",
179
- className: (0, _concat.default)(_context20 = "".concat(checkboxPrefixCls, "-")).call(_context20, checkboxType, "-inner-icon")
186
+ className: (0, _concat.default)(_context20 = "".concat(checkboxPrefixCls, "-")).call(_context20, mergedCheckboxType, "-inner-icon")
180
187
  }))))
181
188
  );
182
189
  };
@@ -3,10 +3,20 @@ export declare const CheckboxTypes: ["default", "square"];
3
3
  export declare type CheckboxType = typeof CheckboxTypes[number];
4
4
  export declare const CheckboxSizes: ["large", "middle", "small"];
5
5
  export declare type CheckboxSize = typeof CheckboxSizes[number];
6
+ export declare type CheckboxValueType = string | number;
7
+ export interface CheckboxGroupContext {
8
+ name?: string;
9
+ isControlled?: boolean;
10
+ groupValue?: Array<CheckboxValueType>;
11
+ checkboxType?: CheckboxType;
12
+ disabled?: boolean;
13
+ onCheckboxGroupChange?: (checkedValue: CheckboxValueType, isChecked: boolean) => void;
14
+ }
15
+ export declare const GroupContext: React.Context<CheckboxGroupContext | null>;
6
16
  export interface CheckboxGroupProps {
7
17
  name?: string;
8
18
  size?: CheckboxSize;
9
- value?: string[];
19
+ value?: Array<CheckboxValueType>;
10
20
  checkboxType?: CheckboxType;
11
21
  disabled?: boolean;
12
22
  defaultValue?: string[] | string;
@@ -11,18 +11,14 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
11
11
  Object.defineProperty(exports, "__esModule", {
12
12
  value: true
13
13
  });
14
- exports.default = exports.CheckboxTypes = exports.CheckboxSizes = void 0;
14
+ exports.default = exports.GroupContext = exports.CheckboxTypes = exports.CheckboxSizes = void 0;
15
15
 
16
- var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
17
-
18
- var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
16
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
19
17
 
20
18
  var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
21
19
 
22
20
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
23
21
 
24
- var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
25
-
26
22
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
27
23
 
28
24
  var _react = _interopRequireWildcard(require("react"));
@@ -37,12 +33,8 @@ var _type = require("../_utils/type");
37
33
 
38
34
  var _arrayUtil = require("../_utils/arrayUtil");
39
35
 
40
- var _isArray = _interopRequireDefault(require("lodash/isArray"));
41
-
42
36
  var _checkbox = _interopRequireDefault(require("./checkbox"));
43
37
 
44
- var _isBoolean = _interopRequireDefault(require("lodash/isBoolean"));
45
-
46
38
  var _devwarning = _interopRequireDefault(require("../_utils/devwarning"));
47
39
 
48
40
  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); }
@@ -55,6 +47,10 @@ exports.CheckboxTypes = CheckboxTypes;
55
47
  var CheckboxSizes = (0, _type.tuple)('large', 'middle', 'small');
56
48
  exports.CheckboxSizes = CheckboxSizes;
57
49
 
50
+ var GroupContext = /*#__PURE__*/_react.default.createContext(null);
51
+
52
+ exports.GroupContext = GroupContext;
53
+
58
54
  var CheckboxGroup = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
59
55
  // const CheckboxGroup = (props: CheckboxGroupProps): FunctionComponentElement<CheckboxGroupProps> => {
60
56
  var _useContext = (0, _react.useContext)(_ConfigContext.default),
@@ -76,111 +72,89 @@ var CheckboxGroup = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
76
72
  defaultValue = CheckboxProps.defaultValue,
77
73
  value = CheckboxProps.value,
78
74
  name = CheckboxProps.name;
75
+ var initData = value || (Array.isArray(defaultValue) ? defaultValue : typeof defaultValue !== 'undefined' ? [defaultValue] : []);
79
76
 
80
- var _React$useState = _react.default.useState(defaultValue),
77
+ var _React$useState = _react.default.useState([]),
81
78
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
82
79
  groupValue = _React$useState2[0],
83
80
  setGroupValue = _React$useState2[1];
84
81
 
82
+ var innerValue = _react.default.useRef(initData);
83
+
85
84
  _react.default.useEffect(function () {
86
- if (value) {
87
- setGroupValue(value);
88
- }
89
- }, [value]);
85
+ innerValue.current = value || (Array.isArray(defaultValue) ? defaultValue : typeof defaultValue !== 'undefined' ? [defaultValue] : []);
86
+ setGroupValue(innerValue.current);
87
+ }, [value, defaultValue]);
90
88
 
89
+ var isControlled = typeof value !== 'undefined';
91
90
  var checkboxGroupPrefixCls = getPrefixCls(prefixCls, 'checkbox-group', customPrefixcls); // 按钮样式前缀
92
91
 
93
- (0, _devwarning.default)((0, _arrayUtil.isArrayValueRepeat)(value), 'checkboxGroup', "variable value's value should be unique ");
94
-
95
- var getDisabled = function getDisabled(optionDisabled) {
96
- return (0, _isBoolean.default)(optionDisabled) ? optionDisabled : disabled;
97
- };
98
-
99
- var getChecked = function getChecked(props, value) {
100
- return (0, _isArray.default)(value) ? (0, _includes.default)(value).call(value, (props === null || props === void 0 ? void 0 : props.value) || props) || (0, _includes.default)(value).call(value, String((props === null || props === void 0 ? void 0 : props.value) || props)) : String(value) === String((props === null || props === void 0 ? void 0 : props.value) || props);
101
- };
92
+ (0, _devwarning.default)((0, _arrayUtil.isArrayValueRepeat)(groupValue), 'checkboxGroup', "variable value's value should be unique ");
102
93
 
103
94
  var getReduceItem = function getReduceItem(targetValue) {
104
- var index = value.indexOf(targetValue);
105
- (0, _splice.default)(value).call(value, index, 1);
106
- return value;
95
+ var _context;
96
+
97
+ return (0, _filter.default)(_context = innerValue.current).call(_context, function (d) {
98
+ return d !== targetValue;
99
+ });
107
100
  };
108
101
 
109
102
  var getAddItem = function getAddItem(targetValue) {
110
- return (0, _concat.default)(value).call(value, targetValue);
111
- };
103
+ var _context2;
112
104
 
113
- var onCheckboxChange = function onCheckboxChange(ev, item) {
114
- var _a;
105
+ return innerValue.current.indexOf(targetValue) > -1 ? innerValue.current : (0, _concat.default)(_context2 = innerValue.current).call(_context2, targetValue);
106
+ };
115
107
 
116
- var val = ev.target.value;
117
- var checked = ev.target.checked;
108
+ var onCheckboxChange = function onCheckboxChange(checkedValue, isChecked) {
118
109
  var newVal = [];
119
110
 
120
- if (checked) {
121
- newVal = getAddItem(val);
111
+ if (isChecked) {
112
+ newVal = getAddItem(checkedValue);
122
113
  } else {
123
- newVal = getReduceItem(val);
114
+ newVal = getReduceItem(checkedValue);
115
+ }
116
+
117
+ if (!isControlled) {
118
+ innerValue.current = newVal;
124
119
  }
125
120
 
126
- setGroupValue(newVal);
127
121
  onChange && onChange(newVal);
128
- ((_a = item.props) === null || _a === void 0 ? void 0 : _a.onChange) && item.props.onChange(ev);
122
+ };
123
+
124
+ var context = {
125
+ groupValue: groupValue,
126
+ disabled: disabled,
127
+ name: name,
128
+ isControlled: isControlled,
129
+ checkboxType: checkboxType,
130
+ onCheckboxGroupChange: function onCheckboxGroupChange(checkedValue, isChecked) {
131
+ onCheckboxChange(checkedValue, isChecked);
132
+ }
129
133
  };
130
134
 
131
135
  var renderByOptions = function renderByOptions() {
132
136
  return (0, _map.default)(options).call(options, function (option, index) {
133
137
  return /*#__PURE__*/_react.default.createElement(_checkbox.default, {
134
138
  size: size,
135
- disabled: getDisabled(option.disabled),
139
+ disabled: option.disabled,
136
140
  key: index,
137
141
  name: name,
138
- defaultChecked: getChecked(option, defaultValue),
139
- checked: getChecked(option, groupValue),
142
+ defaultChecked: option.defaultValue,
143
+ checked: option.checked,
140
144
  checkboxType: checkboxType,
141
145
  value: (option === null || option === void 0 ? void 0 : option.value) || option,
142
- onChange: function onChange(e) {
143
- return onCheckboxChange(e, option);
144
- }
146
+ onChange: option.onChange
145
147
  }, option.label || option);
146
148
  });
147
149
  };
148
150
 
149
- var renderChildren = function renderChildren() {
150
- var _context;
151
-
152
- return (0, _map.default)(_context = _react.default.Children).call(_context, children, function (item) {
153
- var _a, _b;
154
-
155
- var groupProps = {};
156
- groupProps = {
157
- name: name,
158
- size: size,
159
- onChange: function onChange(e) {
160
- return onCheckboxChange(e, item);
161
- },
162
- checkboxType: checkboxType || ((_a = item.props) === null || _a === void 0 ? void 0 : _a.checkboxType),
163
- disabled: (0, _isBoolean.default)(disabled) ? disabled : (_b = item.props) === null || _b === void 0 ? void 0 : _b.disabled,
164
- checked: getChecked(item.props, groupValue),
165
- defaultChecked: getChecked(item.props, defaultValue)
166
- };
167
- return /*#__PURE__*/_react.default.cloneElement(item, (0, _extends2.default)((0, _extends2.default)({}, item.props), groupProps));
168
- });
169
- };
170
-
171
- var renderCheckbox = function renderCheckbox() {
172
- if ((0, _isArray.default)(options)) {
173
- return renderByOptions();
174
- } else if (children) {
175
- return renderChildren();
176
- }
177
- };
178
-
179
151
  return /*#__PURE__*/_react.default.createElement("ul", {
180
152
  className: (0, _classnames.default)(checkboxGroupPrefixCls, className),
181
153
  style: style,
182
154
  ref: ref
183
- }, renderCheckbox());
155
+ }, /*#__PURE__*/_react.default.createElement(GroupContext.Provider, {
156
+ value: context
157
+ }, options && options.length > 0 ? renderByOptions() : children));
184
158
  });
185
159
 
186
160
  var _default = /*#__PURE__*/_react.default.memo(CheckboxGroup);
@@ -1,8 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { CheckboxProps } from './checkbox';
3
3
  import Group from './group';
4
- export { CheckboxProps, CheckboxSizes, CheckboxTypes } from './checkbox';
4
+ export { CheckboxSizes, CheckboxTypes, CheckboxSize, CheckboxType, CheckboxValueType } from './group';
5
5
  export { CheckboxGroupProps } from './group';
6
+ export { CheckboxProps } from './checkbox';
6
7
  interface CompoundedComponent extends React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<HTMLElement>> {
7
8
  Group: typeof Group;
8
9
  }
@@ -14,13 +14,13 @@ Object.defineProperty(exports, "__esModule", {
14
14
  Object.defineProperty(exports, "CheckboxSizes", {
15
15
  enumerable: true,
16
16
  get: function get() {
17
- return _checkbox.CheckboxSizes;
17
+ return _group.CheckboxSizes;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "CheckboxTypes", {
21
21
  enumerable: true,
22
22
  get: function get() {
23
- return _checkbox.CheckboxTypes;
23
+ return _group.CheckboxTypes;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "Group", {
@@ -31,9 +31,9 @@ Object.defineProperty(exports, "Group", {
31
31
  });
32
32
  exports.default = void 0;
33
33
 
34
- var _checkbox = _interopRequireWildcard(require("./checkbox"));
34
+ var _checkbox = _interopRequireDefault(require("./checkbox"));
35
35
 
36
- var _group = _interopRequireDefault(require("./group"));
36
+ var _group = _interopRequireWildcard(require("./group"));
37
37
 
38
38
  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); }
39
39
 
@@ -167,7 +167,7 @@ function InputDate(props, ref) {
167
167
  }
168
168
 
169
169
  var getSuffixNode = function getSuffixNode() {
170
- if (isMouseEnter && (startHoverValue || endHoverValue || startText || endText)) {
170
+ if (isMouseEnter && (startHoverValue || endHoverValue || startText || endText) && allowClear) {
171
171
  return clearNode;
172
172
  }
173
173
 
@@ -87,7 +87,7 @@ function InputDate(props, ref) {
87
87
  var placeholder = (0, _utils.getPlaceholder)(picker, locale, propsPlaceholder);
88
88
 
89
89
  var getSuffixNode = function getSuffixNode() {
90
- if (isMouseEnter && (hoverValue || text)) {
90
+ if (isMouseEnter && (hoverValue || text) && allowClear) {
91
91
  return null;
92
92
  }
93
93
 
@@ -160,6 +160,8 @@
160
160
  -ms-flex-align: center;
161
161
  align-items: center;
162
162
  height: var(--kd-c-modal-header-sizing-height, 50px);
163
+ -ms-flex-negative: 0;
164
+ flex-shrink: 0;
163
165
  }
164
166
  .kd-modal-container-box .kd-modal-header .kd-modal-title-container {
165
167
  display: -webkit-box;
@@ -242,6 +244,8 @@
242
244
  align-items: center;
243
245
  font-size: var(--kd-c-modal-footer-font-size, 14px);
244
246
  color: var(--kd-c-modal-footer-text-color, var(--kd-g-color-text-secondary, #666));
247
+ -ms-flex-negative: 0;
248
+ flex-shrink: 0;
245
249
  }
246
250
  .kd-modal-margin-btn {
247
251
  margin-right: var(--kd-c-modal-footer-button-spacing, 12px);
@@ -58,6 +58,7 @@
58
58
  padding: @modal-header-sizing-padding-vertical @modal-header-sizing-padding-horizontal;
59
59
  align-items: center;
60
60
  height: @modal-header-sizing-height;
61
+ flex-shrink: 0;
61
62
  .@{modal-prefix-cls}-title-container {
62
63
  display: flex;
63
64
  justify-content: center;
@@ -113,6 +114,7 @@
113
114
  align-items: center;
114
115
  font-size: @modal-footer-font-size;
115
116
  color: @modal-footer-font-color;
117
+ flex-shrink: 0;
116
118
  }
117
119
  // each(@modal-footer-type-set, {
118
120
  // .@{modal-prefix-cls}-@{key}-footer {