@kdcloudjs/kdesign 1.7.23 → 1.7.25

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 (58) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/kdesign-complete.less +31 -18
  3. package/dist/kdesign.css +59 -18
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +522 -213
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +4 -4
  8. package/dist/kdesign.min.js +8 -8
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/_utils/usePopper.d.ts +1 -0
  11. package/es/_utils/usePopper.js +40 -21
  12. package/es/city-picker/city-picker.js +36 -25
  13. package/es/city-picker/interface.d.ts +1 -0
  14. package/es/city-picker/option.js +2 -2
  15. package/es/city-picker/style/index.css +14 -10
  16. package/es/city-picker/style/index.less +9 -6
  17. package/es/city-picker/style/token.less +4 -5
  18. package/es/input-number/inputNumber.js +20 -5
  19. package/es/input-number/useSelectionRange.d.ts +4 -0
  20. package/es/input-number/useSelectionRange.js +22 -0
  21. package/es/locale/locale.d.ts +4 -4
  22. package/es/locale/zh-CN.d.ts +4 -2
  23. package/es/locale/zh-CN.js +4 -2
  24. package/es/radio/style/index.css +2 -0
  25. package/es/radio/style/index.less +2 -0
  26. package/es/search/search.js +2 -1
  27. package/es/select/select.js +6 -5
  28. package/es/select/style/index.css +6 -3
  29. package/es/select/style/index.less +10 -4
  30. package/es/select/style/token.less +1 -1
  31. package/es/style/core/motion/slide.less +5 -2
  32. package/es/style/index.css +36 -4
  33. package/es/table/api.js +19 -3
  34. package/lib/_utils/usePopper.d.ts +1 -0
  35. package/lib/_utils/usePopper.js +40 -21
  36. package/lib/city-picker/city-picker.js +36 -25
  37. package/lib/city-picker/interface.d.ts +1 -0
  38. package/lib/city-picker/option.js +2 -2
  39. package/lib/city-picker/style/index.css +14 -10
  40. package/lib/city-picker/style/index.less +9 -6
  41. package/lib/city-picker/style/token.less +4 -5
  42. package/lib/input-number/inputNumber.js +19 -4
  43. package/lib/input-number/useSelectionRange.d.ts +4 -0
  44. package/lib/input-number/useSelectionRange.js +29 -0
  45. package/lib/locale/locale.d.ts +4 -4
  46. package/lib/locale/zh-CN.d.ts +4 -2
  47. package/lib/locale/zh-CN.js +4 -2
  48. package/lib/radio/style/index.css +2 -0
  49. package/lib/radio/style/index.less +2 -0
  50. package/lib/search/search.js +2 -1
  51. package/lib/select/select.js +6 -5
  52. package/lib/select/style/index.css +6 -3
  53. package/lib/select/style/index.less +10 -4
  54. package/lib/select/style/token.less +1 -1
  55. package/lib/style/core/motion/slide.less +5 -2
  56. package/lib/style/index.css +36 -4
  57. package/lib/table/api.js +19 -3
  58. package/package.json +2 -2
@@ -22,7 +22,7 @@ import VirtualList from '../virtual-list';
22
22
  import KeyCode from '../_utils/KeyCode';
23
23
  var INPUT_MIN_WIDTH = 4; // 输入框最小宽度
24
24
  var InternalSelect = function InternalSelect(props, ref) {
25
- var _context, _classNames6, _classNames12;
25
+ var _context, _classNames6, _classNames12, _context5;
26
26
  var _useContext = useContext(ConfigContext),
27
27
  getPrefixCls = _useContext.getPrefixCls,
28
28
  prefixCls = _useContext.prefixCls,
@@ -766,7 +766,7 @@ var InternalSelect = function InternalSelect(props, ref) {
766
766
  // open
767
767
  if (which === KeyCode.ENTER || which === KeyCode.UP || which === KeyCode.DOWN) {
768
768
  e.preventDefault();
769
- setOptionShow(true);
769
+ handleVisibleChange(true);
770
770
  }
771
771
  // backspace
772
772
  var _multipleRef$current5 = multipleRef.current,
@@ -794,6 +794,7 @@ var InternalSelect = function InternalSelect(props, ref) {
794
794
  offset = 1;
795
795
  } else if (which === KeyCode.ENTER) {
796
796
  var item = filledOptions[activeIndex];
797
+ if (!item) return;
797
798
  var key = ((_a = item.props) === null || _a === void 0 ? void 0 : _a.value) || item.value;
798
799
  var label = ((_b = item.props) === null || _b === void 0 ? void 0 : _b.children) || item.label;
799
800
  handleOption(key, label, true);
@@ -809,10 +810,10 @@ var InternalSelect = function InternalSelect(props, ref) {
809
810
  }));
810
811
  }
811
812
  if (!isMultiple) {
812
- setOptionShow(false);
813
+ handleVisibleChange(false);
813
814
  }
814
815
  } else if (which === KeyCode.ESC) {
815
- setOptionShow(false);
816
+ handleVisibleChange(false);
816
817
  }
817
818
  if (offset !== 0) {
818
819
  var nextActiveIndex = getActiveIndex(activeIndex + offset, offset);
@@ -869,7 +870,7 @@ var InternalSelect = function InternalSelect(props, ref) {
869
870
  }
870
871
  };
871
872
  var popperProps = _extends(_extends({}, selectProps), {
872
- prefixCls: selectPrefixCls,
873
+ prefixCls: _concatInstanceProperty(_context5 = "".concat(selectPrefixCls, "-dropdown-panel")).call(_context5, isMultiple ? " ".concat(selectPrefixCls, "-multiple-dropdown-panel") : ''),
873
874
  placement: 'bottomLeft',
874
875
  popperStyle: catchStyle(),
875
876
  defaultVisible: optionShow,
@@ -359,7 +359,7 @@
359
359
  z-index: var(--kd-c-select-z-index, var(--kd-g-z-index-popper, 1050));
360
360
  -webkit-box-sizing: border-box;
361
361
  box-sizing: border-box;
362
- padding: 8px 0;
362
+ padding: var(--kd-c-select-dropdown-spacing-padding-vertical, 8px) 0;
363
363
  margin: 0;
364
364
  overflow: auto;
365
365
  font-size: var(--kd-c-select-dropdown-font-size, 12px);
@@ -382,6 +382,9 @@
382
382
  .kd-select-dropdown-search-hidden {
383
383
  display: none;
384
384
  }
385
+ .kd-select-multiple-dropdown-panel .kd-select-dropdown {
386
+ padding-bottom: 0;
387
+ }
385
388
  .kd-select-item {
386
389
  position: relative;
387
390
  display: block;
@@ -648,8 +651,8 @@
648
651
  align-items: center;
649
652
  width: 100%;
650
653
  padding: 0 12px;
651
- height: 32px;
652
- line-height: 32px;
654
+ height: 40px;
655
+ line-height: 40px;
653
656
  border-top: 1px solid #d9d9d9;
654
657
  -webkit-box-sizing: border-box;
655
658
  box-sizing: border-box;
@@ -132,10 +132,10 @@
132
132
  left: 0;
133
133
  z-index: @select-z-index;
134
134
  box-sizing: border-box;
135
- padding: 8px 0; // update
135
+ padding: @select-dropdown-padding-vertical 0;
136
136
  margin: 0;
137
137
  overflow: auto;
138
- font-size: @select-list-font-size; // update
138
+ font-size: @select-list-font-size;
139
139
  font-variant: initial;
140
140
  background-color: @select-dropdown-bg;
141
141
  border-radius: @select-g-radius-border;
@@ -159,6 +159,12 @@
159
159
  }
160
160
  }
161
161
 
162
+ &-multiple-dropdown-panel {
163
+ .@{select-prefix-cls}-dropdown {
164
+ padding-bottom: 0;
165
+ }
166
+ }
167
+
162
168
  // 下拉列表选项
163
169
  &-item {
164
170
  .item();
@@ -404,8 +410,8 @@
404
410
  align-items: center;
405
411
  width: 100%;
406
412
  padding: 0 12px;
407
- height: 32px;
408
- line-height: 32px;
413
+ height: 40px;
414
+ line-height: 40px;
409
415
  border-top: 1px solid #d9d9d9;
410
416
  box-sizing: border-box;
411
417
 
@@ -2,7 +2,6 @@
2
2
 
3
3
  @select-custom-prefix: ~'--@{kd-prefix}-c-select';
4
4
 
5
-
6
5
  // color
7
6
  @select-dropdown-bg: var(~'@{select-custom-prefix}-dropdown-color-background', @color-background);
8
7
  @select-disabled-option-bg: var(~'@{select-custom-prefix}-item-color-background-disabled', #fff);
@@ -45,6 +44,7 @@
45
44
  // spacing
46
45
  @select-bordered: var(~'@{select-custom-prefix}-bordered-spacing-padding-left', 8px);
47
46
  @select-wrapper-padding: var(~'@{select-custom-prefix}-wrapper-spacing-padding', 1px 28px 1px 0);
47
+ @select-dropdown-padding-vertical: var(~'@{select-custom-prefix}-dropdown-spacing-padding-vertical', 8px);
48
48
 
49
49
  // radius
50
50
  @select-g-radius-border: var(~'@{select-custom-prefix}-radius-border', @radius-border);
@@ -31,12 +31,15 @@
31
31
  .slide-motion(topLeft, kdSlideDown, kd-cascader-menus);
32
32
  .slide-motion(bottomLeft, kdSlideUp, kd-cascader-menus);
33
33
 
34
- .slide-motion(topLeft, kdSlideDown, kd-select);
35
- .slide-motion(bottomLeft, kdSlideUp, kd-select);
34
+ .slide-motion(topLeft, kdSlideDown, kd-select-dropdown-panel);
35
+ .slide-motion(bottomLeft, kdSlideUp, kd-select-dropdown-panel);
36
36
 
37
37
  .slide-motion(topLeft, kdSlideDown, kd-date-picker-panel);
38
38
  .slide-motion(bottomLeft, kdSlideUp, kd-date-picker-panel);
39
39
 
40
+ .slide-motion(topLeft, kdSlideDown, kd-city-picker-dropdown);
41
+ .slide-motion(bottomLeft, kdSlideUp, kd-city-picker-dropdown);
42
+
40
43
  @keyframes kdSlideCenterIn {
41
44
  0% {
42
45
  opacity: 0;
@@ -1361,7 +1361,7 @@
1361
1361
  -webkit-animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1362
1362
  animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1363
1363
  }
1364
- .kd-select.topLeft-active {
1364
+ .kd-select-dropdown-panel.topLeft-active {
1365
1365
  -webkit-animation-name: kdSlideDownIn;
1366
1366
  animation-name: kdSlideDownIn;
1367
1367
  -webkit-animation-duration: calc(0.3s - 0.1s);
@@ -1369,7 +1369,7 @@
1369
1369
  -webkit-animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1370
1370
  animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1371
1371
  }
1372
- .kd-select.topLeft.hidden {
1372
+ .kd-select-dropdown-panel.topLeft.hidden {
1373
1373
  -webkit-animation-name: kdSlideDownOut;
1374
1374
  animation-name: kdSlideDownOut;
1375
1375
  -webkit-animation-duration: 0.1s;
@@ -1377,7 +1377,7 @@
1377
1377
  -webkit-animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1378
1378
  animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1379
1379
  }
1380
- .kd-select.bottomLeft-active {
1380
+ .kd-select-dropdown-panel.bottomLeft-active {
1381
1381
  -webkit-animation-name: kdSlideUpIn;
1382
1382
  animation-name: kdSlideUpIn;
1383
1383
  -webkit-animation-duration: calc(0.3s - 0.1s);
@@ -1385,7 +1385,7 @@
1385
1385
  -webkit-animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1386
1386
  animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1387
1387
  }
1388
- .kd-select.bottomLeft.hidden {
1388
+ .kd-select-dropdown-panel.bottomLeft.hidden {
1389
1389
  -webkit-animation-name: kdSlideUpOut;
1390
1390
  animation-name: kdSlideUpOut;
1391
1391
  -webkit-animation-duration: 0.1s;
@@ -1425,6 +1425,38 @@
1425
1425
  -webkit-animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1426
1426
  animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1427
1427
  }
1428
+ .kd-city-picker-dropdown.topLeft-active {
1429
+ -webkit-animation-name: kdSlideDownIn;
1430
+ animation-name: kdSlideDownIn;
1431
+ -webkit-animation-duration: calc(0.3s - 0.1s);
1432
+ animation-duration: calc(0.3s - 0.1s);
1433
+ -webkit-animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1434
+ animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1435
+ }
1436
+ .kd-city-picker-dropdown.topLeft.hidden {
1437
+ -webkit-animation-name: kdSlideDownOut;
1438
+ animation-name: kdSlideDownOut;
1439
+ -webkit-animation-duration: 0.1s;
1440
+ animation-duration: 0.1s;
1441
+ -webkit-animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1442
+ animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1443
+ }
1444
+ .kd-city-picker-dropdown.bottomLeft-active {
1445
+ -webkit-animation-name: kdSlideUpIn;
1446
+ animation-name: kdSlideUpIn;
1447
+ -webkit-animation-duration: calc(0.3s - 0.1s);
1448
+ animation-duration: calc(0.3s - 0.1s);
1449
+ -webkit-animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1450
+ animation-timing-function: cubic-bezier(0, 0.4, 0.4, 1);
1451
+ }
1452
+ .kd-city-picker-dropdown.bottomLeft.hidden {
1453
+ -webkit-animation-name: kdSlideUpOut;
1454
+ animation-name: kdSlideUpOut;
1455
+ -webkit-animation-duration: 0.1s;
1456
+ animation-duration: 0.1s;
1457
+ -webkit-animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1458
+ animation-timing-function: cubic-bezier(0.4, 0, 1, 0.6);
1459
+ }
1428
1460
  @-webkit-keyframes kdSlideCenterIn {
1429
1461
  0% {
1430
1462
  opacity: 0;
package/es/table/api.js CHANGED
@@ -77,7 +77,7 @@ export default function getApi(pipelineRef) {
77
77
  * @returns
78
78
  */
79
79
  function ensureColumnVisible(code) {
80
- var _a, _b;
80
+ var _a, _b, _c, _d;
81
81
  var pipeline = pipelineRef.current;
82
82
  var tableBodyContainer = (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.domHelper.tableBody;
83
83
  var tableScroll = (_b = pipeline.ref) === null || _b === void 0 ? void 0 : _b.current.domHelper.stickyScroll;
@@ -93,14 +93,30 @@ export default function getApi(pipelineRef) {
93
93
  var colLeft = _sliceInstanceProperty(columnNodes).call(columnNodes, 0, index).reduce(function (acc, col) {
94
94
  return acc + col.width;
95
95
  }, 0);
96
+ var lockColumnLeft = 0;
97
+ var lockColumnRight = 0;
98
+ for (var i = 0; i < columnNodes.length; i++) {
99
+ if ((_c = columnNodes[i]) === null || _c === void 0 ? void 0 : _c.lock) {
100
+ lockColumnLeft += columnNodes[i].width;
101
+ } else {
102
+ break;
103
+ }
104
+ }
105
+ for (var _i = columnNodes.length - 1; _i >= 0; _i--) {
106
+ if ((_d = columnNodes[_i]) === null || _d === void 0 ? void 0 : _d.lock) {
107
+ lockColumnRight += columnNodes[_i].width;
108
+ } else {
109
+ break;
110
+ }
111
+ }
96
112
  var colLeftPixel = colLeft; // 目标列前面列宽总和
97
113
  var colRightPixel = colLeftPixel + column.width;
98
114
  var viewportWidth = tableBodyContainer.clientWidth; // 表体容器的宽度
99
115
  var scrollPosition = tableScroll.scrollLeft; // 滚动条滚动的距离
100
116
  var vScrollLeft = scrollPosition;
101
117
  var vScrollRight = scrollPosition + viewportWidth;
102
- var pxLeft = colLeftPixel;
103
- var pxRight = colRightPixel - viewportWidth;
118
+ var pxLeft = colLeftPixel - lockColumnLeft;
119
+ var pxRight = colRightPixel - viewportWidth + lockColumnRight;
104
120
  var colBeforeViewport = vScrollLeft > colLeftPixel; // 滚动距离大于目标列前面列宽总和,说明目标列在视口之前
105
121
  var colPastViewport = vScrollRight < colRightPixel; // 目标列是视口之后
106
122
  var colToSmallForViewport = viewportWidth < column.width;
@@ -25,6 +25,7 @@ export interface PopperProps {
25
25
  onVisibleChange?: (visible: boolean) => void;
26
26
  getTriggerElement?: (locatorNode: HTMLElement) => HTMLElement;
27
27
  getPopupContainer?: (locatorNode: HTMLElement) => HTMLElement;
28
+ onTransitionEnd?: (e: React.TransitionEvent) => void;
28
29
  }
29
30
  declare function usePopper(locatorElement: React.ReactElement, popperElement: React.ReactElement, props: PopperProps): JSX.Element;
30
31
  export default usePopper;
@@ -114,6 +114,19 @@ var getScrollDist = function getScrollDist(el, container) {
114
114
  }
115
115
  return elScroll;
116
116
  };
117
+ var getRealDom = function getRealDom(locatorRef, locatorElement) {
118
+ var _a;
119
+ if (!locatorRef.current) return locatorRef.current;
120
+ var REF_NAME_OBJ = {
121
+ Input: 'input',
122
+ InputNumber: 'input',
123
+ Select: 'select',
124
+ Upload: 'input'
125
+ };
126
+ if (locatorRef.current.tagName) return locatorRef.current;
127
+ var name = REF_NAME_OBJ[(_a = locatorElement === null || locatorElement === void 0 ? void 0 : locatorElement.type) === null || _a === void 0 ? void 0 : _a.displayName];
128
+ return locatorRef === null || locatorRef === void 0 ? void 0 : locatorRef.current[name];
129
+ };
117
130
  function usePopper(locatorElement, popperElement, props) {
118
131
  var _context3, _context4, _arrowStyle;
119
132
  var prefixCls = props.prefixCls,
@@ -154,7 +167,8 @@ function usePopper(locatorElement, popperElement, props) {
154
167
  _props$getPopupContai = props.getPopupContainer,
155
168
  getPopupContainer = _props$getPopupContai === void 0 ? function () {
156
169
  return document.body;
157
- } : _props$getPopupContai;
170
+ } : _props$getPopupContai,
171
+ onTransitionEnd = props.onTransitionEnd;
158
172
  var arrowWidth = Math.sqrt(2 * Math.pow(arrowSize, 2));
159
173
  var componentName = (prefixCls === null || prefixCls === void 0 ? void 0 : prefixCls.split('-')[1]) || '';
160
174
  (0, _devwarning.default)(Placements.indexOf(placement) === -1, componentName, (0, _concat.default)(_context3 = "cannot found ".concat(componentName, " placement '")).call(_context3, placement, "'"));
@@ -166,10 +180,11 @@ function usePopper(locatorElement, popperElement, props) {
166
180
  var popperEl = (0, _react.useRef)();
167
181
  var locatorRef = locatorElement.ref || locatorEl;
168
182
  var popperRef = popperElement.ref || popperEl;
169
- var container = getPopupContainer(locatorRef.current || document.body);
183
+ var container = getPopupContainer(getRealDom(locatorRef, locatorElement) || document.body);
170
184
  _promise.default.resolve().then(function () {
171
- var triggerNode = getTriggerElement(locatorRef.current);
172
- var container = getPopupContainer(locatorRef.current);
185
+ var realDom = getRealDom(locatorRef, locatorElement);
186
+ var triggerNode = getTriggerElement(realDom);
187
+ var container = getPopupContainer(realDom);
173
188
  (0, _devwarning.default)(!triggerNode, componentName, "getTriggerElement() must return a HTMLElement, but now it does not return anything");
174
189
  (0, _devwarning.default)(!container, componentName, "getPopupContainer() must return a HTMLElement, but now it does not return anything");
175
190
  });
@@ -232,30 +247,31 @@ function usePopper(locatorElement, popperElement, props) {
232
247
  nextPlacement = _useState18[0],
233
248
  setNextPlacement = _useState18[1];
234
249
  var alignPopper = (0, _react.useCallback)(function () {
235
- if ((locatorRef === null || locatorRef === void 0 ? void 0 : locatorRef.current) && (popperRef === null || popperRef === void 0 ? void 0 : popperRef.current)) {
250
+ var realDom = getRealDom(locatorRef, locatorElement);
251
+ if (realDom && (popperRef === null || popperRef === void 0 ? void 0 : popperRef.current)) {
236
252
  var _popperRef$current$ge = popperRef.current.getBoundingClientRect(),
237
253
  popperWidth = _popperRef$current$ge.width,
238
254
  popperHeight = _popperRef$current$ge.height;
239
- var _locatorRef$current$g = locatorRef.current.getBoundingClientRect(),
240
- top = _locatorRef$current$g.top,
241
- bottom = _locatorRef$current$g.bottom,
242
- left = _locatorRef$current$g.left,
243
- right = _locatorRef$current$g.right,
244
- height = _locatorRef$current$g.height,
245
- width = _locatorRef$current$g.width;
255
+ var _realDom$getBoundingC = realDom.getBoundingClientRect(),
256
+ top = _realDom$getBoundingC.top,
257
+ bottom = _realDom$getBoundingC.bottom,
258
+ left = _realDom$getBoundingC.left,
259
+ right = _realDom$getBoundingC.right,
260
+ height = _realDom$getBoundingC.height,
261
+ width = _realDom$getBoundingC.width;
246
262
  var _getOffsetPos = getOffsetPos(container),
247
263
  containerTop = _getOffsetPos.top,
248
264
  containerLeft = _getOffsetPos.left;
249
- var _getOffsetPos2 = getOffsetPos(locatorRef.current),
265
+ var _getOffsetPos2 = getOffsetPos(realDom),
250
266
  locatorTop = _getOffsetPos2.top,
251
267
  locatorLeft = _getOffsetPos2.left;
252
- var _getTranslatePos = getTranslatePos(locatorRef.current),
268
+ var _getTranslatePos = getTranslatePos(realDom),
253
269
  translateTop = _getTranslatePos.top,
254
270
  translateLeft = _getTranslatePos.left;
255
- var _getBorderWidth = getBorderWidth(locatorRef.current),
271
+ var _getBorderWidth = getBorderWidth(realDom),
256
272
  borderTop = _getBorderWidth.top,
257
273
  borderLeft = _getBorderWidth.left;
258
- var _getScrollDist = getScrollDist(locatorRef.current.parentElement, container),
274
+ var _getScrollDist = getScrollDist(realDom.parentElement, container),
259
275
  scrollTop = _getScrollDist.top,
260
276
  scrollLeft = _getScrollDist.left;
261
277
  var locatorPos = {
@@ -438,10 +454,11 @@ function usePopper(locatorElement, popperElement, props) {
438
454
  className: (0, _classnames.default)(prefixCls, popperClassName, nextPlacement, (0, _defineProperty2.default)({
439
455
  arrow: arrow,
440
456
  hidden: !visible
441
- }, "".concat(nextPlacement, "-active"), active))
457
+ }, "".concat(nextPlacement, "-active"), active)),
458
+ onTransitionEnd: typeof onTransitionEnd === 'function' ? onTransitionEnd : undefined
442
459
  };
443
460
  var popperNode = popperRef.current;
444
- var locatorNode = locatorRef.current;
461
+ var locatorNode = getRealDom(locatorRef, locatorElement);
445
462
  (0, _hooks.useResizeObserver)(popperNode || document.body, alignPopper);
446
463
  (0, _hooks.useResizeObserver)(locatorNode || document.body, alignPopper);
447
464
  var showPopper = (0, _react.useCallback)(function (evType) {
@@ -472,7 +489,8 @@ function usePopper(locatorElement, popperElement, props) {
472
489
  (0, _react.useEffect)(function () {
473
490
  if (exist && visible) {
474
491
  var mouseleaveTimer;
475
- var triggerNode = getTriggerElement(locatorRef.current);
492
+ var realDom = getRealDom(locatorRef, locatorElement);
493
+ var triggerNode = getTriggerElement(realDom);
476
494
  var handleHidePopper = function handleHidePopper(e) {
477
495
  var triggerRect = triggerNode.getBoundingClientRect();
478
496
  var popperRect = popperRef.current.getBoundingClientRect();
@@ -546,8 +564,9 @@ function usePopper(locatorElement, popperElement, props) {
546
564
  };
547
565
  }
548
566
  }, [alignPopper, exist, onVisibleChange, popperNode, props.visible, scrollHidden, locatorNode, visible, popperRef]);
549
- _react.default.useEffect(function () {
550
- var triggerNode = getTriggerElement(locatorRef.current);
567
+ (0, _react.useEffect)(function () {
568
+ var realDom = getRealDom(locatorRef, locatorElement);
569
+ var triggerNode = getTriggerElement(realDom);
551
570
  if (triggerNode) {
552
571
  var mouseenterTimer;
553
572
  var clearMouseLeave = function clearMouseLeave() {
@@ -26,20 +26,17 @@ var _option = _interopRequireDefault(require("./option"));
26
26
  var _escapeRegExp = _interopRequireDefault(require("lodash/escapeRegExp"));
27
27
  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); }
28
28
  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; }
29
- var tabsData = [{
30
- id: 'domestic',
31
- name: '国内'
32
- }, {
33
- id: 'foreign',
34
- name: '国际/中国港澳台'
35
- }];
36
29
  var InternalSelect = function InternalSelect(props, ref) {
37
30
  var _context, _classNames3, _classNames5;
38
31
  var _useContext = (0, _react.useContext)(_ConfigContext.default),
39
32
  getPrefixCls = _useContext.getPrefixCls,
40
33
  prefixCls = _useContext.prefixCls,
41
- userDefaultProps = _useContext.compDefaultProps;
34
+ userDefaultProps = _useContext.compDefaultProps,
35
+ locale = _useContext.locale;
42
36
  var selectProps = (0, _utils.getCompProps)('CityPicker', userDefaultProps, props);
37
+ var cityPickerLangMsg = locale.getCompLangMsg({
38
+ componentName: 'CityPicker'
39
+ });
43
40
  var type = selectProps.type,
44
41
  size = selectProps.size,
45
42
  value = selectProps.value,
@@ -75,7 +72,8 @@ var InternalSelect = function InternalSelect(props, ref) {
75
72
  domesticList = _selectProps$domestic === void 0 ? [] : _selectProps$domestic,
76
73
  _selectProps$foreignL = selectProps.foreignList,
77
74
  foreignList = _selectProps$foreignL === void 0 ? [] : _selectProps$foreignL,
78
- itemRender = selectProps.itemRender;
75
+ itemRender = selectProps.itemRender,
76
+ onTabPaneChange = selectProps.onTabPaneChange;
79
77
  var _useMergedState = (0, _hooks.useMergedState)(undefined, {
80
78
  value: value,
81
79
  defaultValue: defaultValue
@@ -83,6 +81,13 @@ var InternalSelect = function InternalSelect(props, ref) {
83
81
  _useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
84
82
  initValue = _useMergedState2[0],
85
83
  setInitValue = _useMergedState2[1];
84
+ var tabsData = [{
85
+ id: 'domestic',
86
+ name: cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.tabsDomestic
87
+ }, {
88
+ id: 'foreign',
89
+ name: cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.tabsInternation
90
+ }];
86
91
  var innerRef = (0, _react.useRef)();
87
92
  var selectRef = ref || innerRef;
88
93
  var searchRef = (0, _react.useRef)(null); // 搜索框ref
@@ -132,11 +137,6 @@ var InternalSelect = function InternalSelect(props, ref) {
132
137
  setOptionShow(props.visible);
133
138
  }
134
139
  }, [props.visible]);
135
- (0, _react.useEffect)(function () {
136
- if (optionShow === false) {
137
- handleClear();
138
- }
139
- }, [optionShow]);
140
140
  var handleFocus = (0, _react.useCallback)(function (e) {
141
141
  e.stopPropagation();
142
142
  setFocusd(true);
@@ -233,6 +233,7 @@ var InternalSelect = function InternalSelect(props, ref) {
233
233
  }
234
234
  };
235
235
  var renderNodeList = function renderNodeList(data, notContent) {
236
+ var isCommon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
236
237
  if (!data.length) {
237
238
  return renderNotContent(notContent);
238
239
  }
@@ -243,7 +244,9 @@ var InternalSelect = function InternalSelect(props, ref) {
243
244
  key: item.id,
244
245
  value: initValue,
245
246
  city: item,
246
- renderCityInfo: renderCityInfo,
247
+ renderCityInfo: function renderCityInfo(data, flag) {
248
+ return _renderCityInfo(data, isCommon, flag);
249
+ },
247
250
  onChangeSelect: handleOption,
248
251
  itemRender: itemRender
249
252
  }, searchValue ? getHighlightText(item === null || item === void 0 ? void 0 : item.name, (item === null || item === void 0 ? void 0 : item[optionHighlightProps]) || searchValue) : item === null || item === void 0 ? void 0 : item.name);
@@ -258,6 +261,7 @@ var InternalSelect = function InternalSelect(props, ref) {
258
261
  };
259
262
  var toggleTabPane = function toggleTabPane(type) {
260
263
  setTabsValue(type);
264
+ onTabPaneChange === null || onTabPaneChange === void 0 ? void 0 : onTabPaneChange(type);
261
265
  };
262
266
  // 渲染下拉列表框
263
267
  var renderContent = function renderContent() {
@@ -270,22 +274,24 @@ var InternalSelect = function InternalSelect(props, ref) {
270
274
  key: item.id,
271
275
  tab: item.name
272
276
  }, item);
273
- })), tabsValue === 'domestic' ? renderNodeList(domesticList, '暂无数据') : renderNodeList(foreignList, '暂无数据')) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !!commonList.length && /*#__PURE__*/_react.default.createElement("div", {
277
+ })), tabsValue === 'domestic' ? renderNodeList(domesticList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText) : renderNodeList(foreignList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !!commonList.length && /*#__PURE__*/_react.default.createElement("div", {
274
278
  className: "".concat(selectPrefixCls, "-dropdown-common")
275
- }, "\u5E38\u7528"), renderNodeList(commonList, '无常用城市')));
279
+ }, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.common), renderNodeList(commonList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.commonEmptyText, true)));
276
280
  };
277
- var renderCityInfo = (0, _react.useCallback)(function (data) {
278
- var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
279
- var symbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ', ';
281
+ var _renderCityInfo = (0, _react.useCallback)(function (data) {
282
+ var isCommon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
283
+ var flag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
284
+ var symbol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
280
285
  if (!data) return null;
281
286
  if (isDomestic(type)) {
282
287
  var _context3;
283
- return (0, _concat.default)(_context3 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context3, data === null || data === void 0 ? void 0 : data.province);
288
+ var curVal = tabsValue === 'domestic' || isCommon ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
289
+ return (0, _concat.default)(_context3 = "".concat(flag && curVal ? symbol : '')).call(_context3, curVal);
284
290
  } else {
285
291
  var _context4, _context5, _context6;
286
- return (0, _concat.default)(_context4 = (0, _concat.default)(_context5 = (0, _concat.default)(_context6 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.province)).call(_context5, (data === null || data === void 0 ? void 0 : data.country) ? symbol : '')).call(_context4, data === null || data === void 0 ? void 0 : data.country);
292
+ return (0, _concat.default)(_context4 = (0, _concat.default)(_context5 = (0, _concat.default)(_context6 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.province)).call(_context5, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context4, data === null || data === void 0 ? void 0 : data.country);
287
293
  }
288
- }, [type]);
294
+ }, [type, tabsValue]);
289
295
  var renderSingle = function renderSingle() {
290
296
  var hiddenStyle = !!searchValue || (initValue !== null && initValue !== void 0 ? initValue : '') !== '' ? {
291
297
  visibility: 'hidden'
@@ -310,7 +316,7 @@ var InternalSelect = function InternalSelect(props, ref) {
310
316
  title: seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name
311
317
  }, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue && /*#__PURE__*/_react.default.createElement("span", {
312
318
  className: "".concat(selectPrefixCls, "-content-info")
313
- }, renderCityInfo(seletedCity))), /*#__PURE__*/_react.default.createElement("span", {
319
+ }, _renderCityInfo(seletedCity))), /*#__PURE__*/_react.default.createElement("span", {
314
320
  className: "".concat(selectPrefixCls, "-placeholder"),
315
321
  style: hiddenStyle
316
322
  }, placeholder), /*#__PURE__*/_react.default.createElement("span", {
@@ -382,7 +388,12 @@ var InternalSelect = function InternalSelect(props, ref) {
382
388
  defaultVisible: optionShow,
383
389
  visible: optionShow,
384
390
  onVisibleChange: handleVisibleChange,
385
- clickToClose: !searchValue
391
+ clickToClose: !searchValue,
392
+ onTransitionEnd: function onTransitionEnd() {
393
+ if (optionShow === false) {
394
+ handleClear();
395
+ }
396
+ }
386
397
  });
387
398
  return (0, _usePopper.default)(renderCityPicker(), renderContent(), popperProps);
388
399
  };
@@ -43,6 +43,7 @@ export interface CityPickerProps {
43
43
  onSearch?: (value: string) => void;
44
44
  onClear?: () => void;
45
45
  itemRender?: (city: City) => React.ReactNode;
46
+ onTabPaneChange?: (id: Type) => void;
46
47
  }
47
48
  export interface ICityPickerOptionProps {
48
49
  disabled?: boolean;
@@ -43,9 +43,9 @@ var InternalOption = function InternalOption(props, ref) {
43
43
  className: optionCls,
44
44
  title: name,
45
45
  onClick: handleClick
46
- }, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
46
+ }, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
47
47
  className: "".concat(selectOptionPrefixCls, "-content")
48
- }, children), /*#__PURE__*/_react.default.createElement("div", {
48
+ }, children), /*#__PURE__*/_react.default.createElement("span", {
49
49
  className: "".concat(selectOptionPrefixCls, "-info")
50
50
  }, renderCityInfo === null || renderCityInfo === void 0 ? void 0 : renderCityInfo(city, true)))));
51
51
  };
@@ -264,6 +264,12 @@
264
264
  padding: 0 12px;
265
265
  font-size: 12px;
266
266
  }
267
+ .kd-city-picker-dropdown .kd-tabs-tab-list .kd-tab-pane-type-line .kd-tab-pane-text {
268
+ overflow: hidden;
269
+ white-space: nowrap;
270
+ text-overflow: ellipsis;
271
+ width: 100%;
272
+ }
267
273
  .kd-city-picker-dropdown .kd-tabs-noContainer {
268
274
  height: unset;
269
275
  }
@@ -307,8 +313,13 @@
307
313
  padding: 8px 0;
308
314
  max-height: 320px;
309
315
  overflow-y: auto;
316
+ -webkit-box-sizing: content-box;
317
+ box-sizing: content-box;
310
318
  }
311
319
  .kd-city-picker-list-item {
320
+ overflow: hidden;
321
+ white-space: nowrap;
322
+ text-overflow: ellipsis;
312
323
  position: relative;
313
324
  display: block;
314
325
  font-weight: normal;
@@ -317,16 +328,8 @@
317
328
  padding: 5px 12px;
318
329
  color: var(--kd-c-city-picker-footer-color-text, var(--kd-g-color-text-primary, #212121));
319
330
  line-height: var(--kd-c-city-picker-dropdown-line-height, 22px);
320
- display: -webkit-box;
321
- display: -ms-flexbox;
322
- display: flex;
323
331
  cursor: pointer;
324
332
  }
325
- .kd-city-picker-list-item-content {
326
- overflow: hidden;
327
- white-space: nowrap;
328
- text-overflow: ellipsis;
329
- }
330
333
  .kd-city-picker-list-item-info {
331
334
  color: var(--kd-c-city-picker-placeholder-color-text, #b2b2b2);
332
335
  white-space: nowrap;
@@ -335,7 +338,8 @@
335
338
  background-color: var(--kd-c-city-picker-color-background, #f5f5f5);
336
339
  }
337
340
  .kd-city-picker-list-item-selected:not(.kd-city-picker-list-item-disabled) {
338
- background-color: var(--kd-c-city-picker-color-background-selected, #f2f6ff);
341
+ background-color: var(--kd-c-city-picker-color-background-selected, var(--kd-g-color-theme-3, #e3eeff));
342
+ color: var(--kd-c-city-picker-list-item-color-text-selected, var(--kd-g-color-theme, #5582f3));
339
343
  }
340
344
  .kd-city-picker-list-item-disabled {
341
345
  color: var(--kd-c-city-picker-item-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
@@ -343,7 +347,7 @@
343
347
  background-color: var(--kd-c-city-picker-item-color-background-disabled, #fff);
344
348
  }
345
349
  .kd-city-picker-highlight {
346
- color: #5582f3;
350
+ color: var(--kd-c-city-picker-highlight-color-text, var(--kd-g-color-theme, #5582f3));
347
351
  }
348
352
  .kd-city-picker-size-small {
349
353
  min-height: var(--kd-c-city-picker-sizing-height-small, 24px);