@kdcloudjs/kdesign 1.7.27 → 1.7.29

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.
@@ -15,6 +15,13 @@ import usePopper from '../_utils/usePopper';
15
15
  import Option from './option';
16
16
  import escapeRegExp from 'lodash/escapeRegExp';
17
17
  import KeyCode from '../_utils/KeyCode';
18
+ import isObject from 'lodash/isObject';
19
+ var getCityId = function getCityId(data) {
20
+ if (isObject(data)) {
21
+ return data === null || data === void 0 ? void 0 : data.id;
22
+ }
23
+ return data;
24
+ };
18
25
  var InternalSelect = function InternalSelect(props, ref) {
19
26
  var _context, _classNames3, _classNames5;
20
27
  var _useContext = useContext(ConfigContext),
@@ -64,8 +71,8 @@ var InternalSelect = function InternalSelect(props, ref) {
64
71
  itemRender = selectProps.itemRender,
65
72
  onTabPaneChange = selectProps.onTabPaneChange;
66
73
  var _useMergedState = useMergedState(undefined, {
67
- value: value,
68
- defaultValue: defaultValue
74
+ value: getCityId(value),
75
+ defaultValue: getCityId(defaultValue)
69
76
  }),
70
77
  _useMergedState2 = _slicedToArray(_useMergedState, 2),
71
78
  initValue = _useMergedState2[0],
@@ -114,6 +121,10 @@ var InternalSelect = function InternalSelect(props, ref) {
114
121
  useEffect(function () {
115
122
  var _context2;
116
123
  if (typeof value === 'undefined') return;
124
+ if (isObject(value)) {
125
+ setSeletedCity(value);
126
+ return;
127
+ }
117
128
  var cityList = _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(commonList), _toConsumableArray(domesticList), _toConsumableArray(foreignList));
118
129
  var city = _findInstanceProperty(cityList).call(cityList, function (city) {
119
130
  return city.id === value;
@@ -214,6 +225,7 @@ var InternalSelect = function InternalSelect(props, ref) {
214
225
  };
215
226
  var handleOption = function handleOption(city) {
216
227
  handleVisibleChange(false);
228
+ city.type = tabsValue === 'domestic' ? 'domestic' : 'foreign';
217
229
  (city === null || city === void 0 ? void 0 : city.id) !== initValue && (onChange === null || onChange === void 0 ? void 0 : onChange(city === null || city === void 0 ? void 0 : city.id, city));
218
230
  if (typeof value === 'undefined') {
219
231
  setSeletedCity(city);
@@ -279,17 +291,22 @@ var InternalSelect = function InternalSelect(props, ref) {
279
291
  var symbol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
280
292
  if (!data) return null;
281
293
  if (isDomestic(type)) {
282
- var _context4;
294
+ var _context5;
283
295
  if (isCommon) {
284
296
  var _context3;
285
297
  var _curVal = (data === null || data === void 0 ? void 0 : data.province) ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
286
298
  return _concatInstanceProperty(_context3 = "".concat(flag && _curVal ? symbol : '')).call(_context3, _curVal);
287
299
  }
288
- var curVal = tabsValue === 'domestic' ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
289
- return _concatInstanceProperty(_context4 = "".concat(flag && curVal ? symbol : '')).call(_context4, curVal);
300
+ if (data === null || data === void 0 ? void 0 : data.type) {
301
+ var _context4;
302
+ var _curVal2 = data.type === 'domestic' ? (data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country) : data === null || data === void 0 ? void 0 : data.country;
303
+ return _concatInstanceProperty(_context4 = "".concat(flag && _curVal2 ? symbol : '')).call(_context4, _curVal2);
304
+ }
305
+ var curVal = tabsValue === 'domestic' ? (data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country) : data === null || data === void 0 ? void 0 : data.country;
306
+ return _concatInstanceProperty(_context5 = "".concat(flag && curVal ? symbol : '')).call(_context5, curVal);
290
307
  } else {
291
- var _context5, _context6, _context7;
292
- return _concatInstanceProperty(_context5 = _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = "".concat(flag && ((data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country)) ? symbol : '')).call(_context7, data === null || data === void 0 ? void 0 : data.province)).call(_context6, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context5, data === null || data === void 0 ? void 0 : data.country);
308
+ var _context6, _context7, _context8;
309
+ return _concatInstanceProperty(_context6 = _concatInstanceProperty(_context7 = _concatInstanceProperty(_context8 = "".concat(flag && ((data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country)) ? symbol : '')).call(_context8, data === null || data === void 0 ? void 0 : data.province)).call(_context7, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.country);
293
310
  }
294
311
  }, [type, tabsValue]);
295
312
  var renderSingle = function renderSingle() {
@@ -4,6 +4,7 @@ export declare type City = {
4
4
  country?: string;
5
5
  province?: string;
6
6
  name?: string;
7
+ type?: 'domestic' | 'foreign';
7
8
  [key: string]: any;
8
9
  };
9
10
  export declare const BorderTypes: ["none", "underline", "bordered"];
@@ -33,7 +34,7 @@ export interface CityPickerProps {
33
34
  clearIcon?: React.ReactNode;
34
35
  suffixIcon?: React.ReactNode;
35
36
  optionHighlightProps?: string;
36
- value?: string | number;
37
+ value?: string | number | City;
37
38
  defaultValue?: string | number;
38
39
  description?: React.ReactNode;
39
40
  showDescription?: boolean;
@@ -166,6 +166,7 @@
166
166
  opacity: 0;
167
167
  z-index: 1;
168
168
  position: absolute;
169
+ top: 0;
169
170
  background: #fff;
170
171
  -webkit-transition: opacity 0.15s ease;
171
172
  transition: opacity 0.15s ease;
@@ -181,6 +182,14 @@
181
182
  text-overflow: ellipsis;
182
183
  right: 24px;
183
184
  left: 0;
185
+ top: 0;
186
+ bottom: 0;
187
+ display: -webkit-box;
188
+ display: -ms-flexbox;
189
+ display: flex;
190
+ -webkit-box-align: center;
191
+ -ms-flex-align: center;
192
+ align-items: center;
184
193
  }
185
194
  .kd-city-picker-borderless {
186
195
  border: none;
@@ -387,6 +396,8 @@
387
396
  }
388
397
  .kd-city-picker-suffix {
389
398
  right: 0;
399
+ top: 0;
400
+ bottom: 0;
390
401
  position: absolute;
391
402
  display: -webkit-box;
392
403
  display: -ms-flexbox;
@@ -58,6 +58,7 @@
58
58
  opacity: 0;
59
59
  z-index: 1;
60
60
  position: absolute;
61
+ top: 0;
61
62
  background: #fff;
62
63
  transition: opacity 0.15s ease;
63
64
  &:hover {
@@ -74,6 +75,10 @@
74
75
  text-overflow: ellipsis;
75
76
  right: 24px;
76
77
  left: 0;
78
+ top: 0;
79
+ bottom: 0;
80
+ display: flex;
81
+ align-items: center;
77
82
  }
78
83
 
79
84
  &-borderless {
@@ -277,6 +282,8 @@
277
282
 
278
283
  &-suffix {
279
284
  right: 0;
285
+ top: 0;
286
+ bottom: 0;
280
287
  position: absolute;
281
288
  display: flex;
282
289
  flex: 0;
package/es/grid/col.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  interface ColBase {
3
3
  span?: number;
4
4
  pull?: number;
package/es/grid/col.js CHANGED
@@ -1,35 +1,52 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
2
3
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
3
- import * as React from 'react';
4
+ var __rest = this && this.__rest || function (s, e) {
5
+ var t = {};
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
7
+ if (s != null && typeof _Object$getOwnPropertySymbols === "function") for (var i = 0, p = _Object$getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { useContext } from 'react';
4
13
  import classNames from 'classnames';
5
14
  import { getCompProps } from '../_utils';
6
15
  import { ConfigContext } from '../config-provider';
7
16
  import { testBrowserType } from '../_utils/testBrowserType';
17
+ import { GapContext } from './row';
8
18
  var Col = function Col(props) {
9
19
  var _React$useContext = React.useContext(ConfigContext),
10
20
  getPrefixCls = _React$useContext.getPrefixCls,
11
21
  pkgPrefixCls = _React$useContext.prefixCls,
12
22
  userDefaultProps = _React$useContext.compDefaultProps;
13
23
  // 属性需要合并一遍用户定义的默认属性
14
- var _getCompProps = getCompProps('Col', userDefaultProps, props),
15
- xs = _getCompProps.xs,
16
- sm = _getCompProps.sm,
17
- md = _getCompProps.md,
18
- lg = _getCompProps.lg,
19
- xl = _getCompProps.xl,
20
- flex = _getCompProps.flex,
21
- span = _getCompProps.span,
22
- pull = _getCompProps.pull,
23
- push = _getCompProps.push,
24
- style = _getCompProps.style,
25
- order = _getCompProps.order,
26
- offset = _getCompProps.offset,
27
- winWidth = _getCompProps.winWidth,
28
- children = _getCompProps.children,
29
- className = _getCompProps.className,
30
- customPrefixcls = _getCompProps.prefixCls;
24
+ var _a = getCompProps('Col', userDefaultProps, props),
25
+ xs = _a.xs,
26
+ sm = _a.sm,
27
+ md = _a.md,
28
+ lg = _a.lg,
29
+ xl = _a.xl,
30
+ flex = _a.flex,
31
+ span = _a.span,
32
+ pull = _a.pull,
33
+ push = _a.push,
34
+ style = _a.style,
35
+ order = _a.order,
36
+ offset = _a.offset,
37
+ children = _a.children,
38
+ className = _a.className,
39
+ customPrefixcls = _a.prefixCls,
40
+ others = __rest(_a, ["xs", "sm", "md", "lg", "xl", "flex", "span", "pull", "push", "style", "order", "offset", "children", "className", "prefixCls"]);
41
+ var rowGroup = useContext(GapContext);
42
+ var mergedWinWidth = rowGroup.winWidth;
43
+ var gap = rowGroup.gap;
31
44
  // 浏览器名称
32
- var isSogou = testBrowserType(/^sogou/i, 0);
45
+ var isSogouOrIE = testBrowserType(/^sogou/i, 0) || /Trident|MSIE/.test(navigator.userAgent);
46
+ var colGapStyle = {
47
+ padding: "0 ".concat(gap.h / 2, "px")
48
+ };
49
+ if (isSogouOrIE && gap.v) colGapStyle.marginBottom = gap.v;
33
50
  // className前缀
34
51
  var prefixCls = getPrefixCls(pkgPrefixCls, 'col', customPrefixcls);
35
52
  var columns = 24;
@@ -40,23 +57,23 @@ var Col = function Col(props) {
40
57
  offset: offset,
41
58
  order: order
42
59
  };
43
- if (xs && winWidth > 0) {
60
+ if (xs && mergedWinWidth > 0) {
44
61
  if (xs.constructor === Number) base.span = xs;
45
62
  if (xs.constructor === Object) base = _extends(_extends({}, base), xs);
46
63
  }
47
- if (sm && winWidth >= 600) {
64
+ if (sm && mergedWinWidth >= 600) {
48
65
  if (sm.constructor === Number) base.span = sm;
49
66
  if (sm.constructor === Object) base = _extends(_extends({}, base), sm);
50
67
  }
51
- if (md && winWidth >= 1024) {
68
+ if (md && mergedWinWidth >= 1024) {
52
69
  if (md.constructor === Number) base.span = md;
53
70
  if (md.constructor === Object) base = _extends(_extends({}, base), md);
54
71
  }
55
- if (lg && winWidth >= 1280) {
72
+ if (lg && mergedWinWidth >= 1280) {
56
73
  if (lg.constructor === Number) base.span = lg;
57
74
  if (lg.constructor === Object) base = _extends(_extends({}, base), lg);
58
75
  }
59
- if (xl && winWidth >= 1920) {
76
+ if (xl && mergedWinWidth >= 1920) {
60
77
  if (xl.constructor === Number) base.span = xl;
61
78
  if (xl.constructor === Object) base = _extends(_extends({}, base), xl);
62
79
  }
@@ -76,20 +93,18 @@ var Col = function Col(props) {
76
93
  }
77
94
  }
78
95
  }
79
- var styleString = _extends({
96
+ var styleString = _extends(_extends({
80
97
  flex: flexstr,
81
98
  maxWidth: width,
82
99
  order: base.order,
83
100
  left: base.push && base.push / columns * 100 + '%',
84
101
  right: base.pull && base.pull / columns * 100 + '%',
85
102
  marginLeft: base.offset && base.offset / columns * 100 + '%'
86
- }, style);
87
- return /*#__PURE__*/React.createElement("div", {
88
- className: classNames(prefixCls, className, {
89
- 'sogou-col': isSogou
90
- }),
103
+ }, colGapStyle), style);
104
+ return /*#__PURE__*/React.createElement("div", _extends({
105
+ className: classNames(prefixCls, className),
91
106
  style: styleString
92
- }, children);
107
+ }, others), children);
93
108
  };
94
109
  Col.displayName = 'Col';
95
110
  export default Col;
package/es/grid/row.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  declare type Align = 'top' | 'middle' | 'bottom' | 'stretch';
3
3
  declare type Justify = 'start' | 'end' | 'center' | 'space-around' | 'space-between';
4
4
  interface gutterObject {
@@ -17,5 +17,13 @@ export interface RowProps {
17
17
  style?: React.CSSProperties;
18
18
  gutter?: number | gutterObject | Array<number | gutterObject>;
19
19
  }
20
+ export interface GridContext {
21
+ gap: {
22
+ v: number;
23
+ h: number;
24
+ };
25
+ winWidth: number;
26
+ }
27
+ export declare const GapContext: React.Context<GridContext>;
20
28
  declare const Row: React.FC<RowProps>;
21
29
  export default Row;
package/es/grid/row.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
- import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
4
- import * as React from 'react';
3
+ import React, { createContext } from 'react';
5
4
  import classNames from 'classnames';
6
5
  import { getCompProps } from '../_utils';
7
6
  import { ConfigContext } from '../config-provider';
@@ -21,8 +20,14 @@ function getGap(gutter, width) {
21
20
  if (xl && width >= 1920) gap = xl;
22
21
  return gap;
23
22
  }
23
+ export var GapContext = /*#__PURE__*/createContext({
24
+ gap: {
25
+ h: 0,
26
+ v: 0
27
+ },
28
+ winWidth: window.innerWidth
29
+ });
24
30
  var Row = function Row(props) {
25
- var _context;
26
31
  var _React$useContext = React.useContext(ConfigContext),
27
32
  getPrefixCls = _React$useContext.getPrefixCls,
28
33
  pkgPrefixCls = _React$useContext.prefixCls,
@@ -38,7 +43,7 @@ var Row = function Row(props) {
38
43
  justify = _getCompProps.justify,
39
44
  customPrefixcls = _getCompProps.prefixCls;
40
45
  // 浏览器名称
41
- var isSogou = testBrowserType(/^sogou/i, 0);
46
+ var isSogouOrIe = testBrowserType(/^sogou/i, 0) || /Trident|MSIE/.test(navigator.userAgent);
42
47
  // className前缀
43
48
  var prefixCls = getPrefixCls(pkgPrefixCls, 'row', customPrefixcls);
44
49
  var _React$useState = React.useState(window.innerWidth),
@@ -70,9 +75,10 @@ var Row = function Row(props) {
70
75
  }
71
76
  }
72
77
  var rowStyle = {
73
- '--cgap': "".concat(gap.h, "px")
78
+ 'row-gap': "".concat(gap.v, "px"),
79
+ margin: "0 ".concat(-1 * gap.h, "px")
74
80
  };
75
- if (gap.v) rowStyle['--rgap'] = "".concat(gap.v, "px");
81
+ if (gap.v && isSogouOrIe) rowStyle['margin-bottom'] = "".concat(-1 * gap.v / 2, "px");
76
82
  var toalign = {
77
83
  top: 'flex-start',
78
84
  middle: 'center',
@@ -82,22 +88,21 @@ var Row = function Row(props) {
82
88
  start: 'flex-start',
83
89
  end: 'flex-end'
84
90
  };
85
- var styleString = _extends(_extends(_extends({}, style), rowStyle), {
91
+ var styleString = _extends(_extends(_extends({}, rowStyle), style), {
86
92
  alignItems: toalign[align] || align,
87
93
  justifyContent: tojustify[justify] || justify
88
94
  });
89
- return /*#__PURE__*/React.createElement("div", {
95
+ return /*#__PURE__*/React.createElement(GapContext.Provider, {
96
+ value: {
97
+ gap: gap,
98
+ winWidth: winWidth
99
+ }
100
+ }, /*#__PURE__*/React.createElement("div", {
90
101
  className: classNames(prefixCls, className, {
91
102
  nowrap: !wrap
92
- }, {
93
- 'sogou-row': isSogou
94
103
  }),
95
104
  style: styleString
96
- }, _mapInstanceProperty(_context = React.Children).call(_context, children, function (child) {
97
- return /*#__PURE__*/React.cloneElement(child, {
98
- winWidth: winWidth
99
- });
100
- }));
105
+ }, children));
101
106
  };
102
107
  Row.displayName = 'Row';
103
108
  export default Row;
@@ -629,9 +629,9 @@ var InternalSelect = function InternalSelect(props, ref) {
629
629
  onFocus: handleFocus,
630
630
  onBlur: handleBlur,
631
631
  readOnly: !isShowSearch || !!disabled
632
- })), singleVal && !searchValue && /*#__PURE__*/React.createElement("span", {
632
+ })), singleVal && !searchValue ? /*#__PURE__*/React.createElement("span", {
633
633
  className: "".concat(selectPrefixCls, "-selection-item")
634
- }, singleVal), /*#__PURE__*/React.createElement("span", {
634
+ }, singleVal) : null, /*#__PURE__*/React.createElement("span", {
635
635
  className: "".concat(selectPrefixCls, "-placeholder"),
636
636
  style: hiddenStyle
637
637
  }, placeholder), /*#__PURE__*/React.createElement("span", {
@@ -280,6 +280,14 @@
280
280
  .kd-select-icon-clear {
281
281
  opacity: 0;
282
282
  z-index: 1;
283
+ top: 0;
284
+ bottom: 0;
285
+ display: -webkit-box;
286
+ display: -ms-flexbox;
287
+ display: flex;
288
+ -webkit-box-align: center;
289
+ -ms-flex-align: center;
290
+ align-items: center;
283
291
  position: absolute;
284
292
  background: #fff;
285
293
  -webkit-transition: opacity 0.15s ease;
@@ -299,6 +307,15 @@
299
307
  text-overflow: ellipsis;
300
308
  right: 28px;
301
309
  left: 0;
310
+ top: 0;
311
+ bottom: 0;
312
+ z-index: -1;
313
+ display: -webkit-box;
314
+ display: -ms-flexbox;
315
+ display: flex;
316
+ -webkit-box-align: center;
317
+ -ms-flex-align: center;
318
+ align-items: center;
302
319
  }
303
320
  .kd-select-borderless {
304
321
  border: none;
@@ -433,18 +450,32 @@
433
450
  max-height: calc(var(--kd-c-select-sizing-height-small, 24px) * 3 - 10px);
434
451
  font-size: var(--kd-c-select-font-size-small, 12px);
435
452
  }
453
+ .kd-select-size-small .kd-select-selection-item {
454
+ min-height: calc(var(--kd-c-select-sizing-height-small, 24px) - 4px);
455
+ line-height: calc(var(--kd-c-select-sizing-height-small, 24px) - 4px);
456
+ }
436
457
  .kd-select-size-middle {
437
458
  min-height: var(--kd-c-select-sizing-height-middle, 30px);
438
459
  max-height: calc(var(--kd-c-select-sizing-height-middle, 30px) * 3 - 10px);
439
460
  font-size: var(--kd-c-select-font-size-middle, 14px);
440
461
  }
462
+ .kd-select-size-middle .kd-select-selection-item {
463
+ min-height: calc(var(--kd-c-select-sizing-height-middle, 30px) - 4px);
464
+ line-height: calc(var(--kd-c-select-sizing-height-middle, 30px) - 4px);
465
+ }
441
466
  .kd-select-size-large {
442
467
  min-height: var(--kd-c-select-sizing-height-large, 36px);
443
468
  max-height: calc(var(--kd-c-select-sizing-height-large, 36px) * 3 - 10px);
444
469
  font-size: var(--kd-c-select-font-size-large, 16px);
445
470
  }
471
+ .kd-select-size-large .kd-select-selection-item {
472
+ min-height: calc(var(--kd-c-select-sizing-height-large, 36px) - 4px);
473
+ line-height: calc(var(--kd-c-select-sizing-height-large, 36px) - 4px);
474
+ }
446
475
  .kd-select-suffix {
447
476
  right: 0;
477
+ top: 0;
478
+ bottom: 0;
448
479
  position: absolute;
449
480
  display: -webkit-box;
450
481
  display: -ms-flexbox;
@@ -467,6 +498,14 @@
467
498
  right: 28px;
468
499
  left: 0;
469
500
  height: 100%;
501
+ top: 0;
502
+ bottom: 0;
503
+ display: -webkit-box;
504
+ display: -ms-flexbox;
505
+ display: flex;
506
+ -webkit-box-align: center;
507
+ -ms-flex-align: center;
508
+ align-items: center;
470
509
  }
471
510
  .kd-select .kd-select-single .kd-select-selection-search-input {
472
511
  outline: 0;
@@ -525,9 +564,6 @@
525
564
  align-items: center;
526
565
  vertical-align: middle;
527
566
  max-width: 100%;
528
- height: 20px;
529
- line-height: 20px;
530
- margin: 2px 8px 2px 0;
531
567
  cursor: default;
532
568
  -webkit-user-select: none;
533
569
  -moz-user-select: none;
@@ -46,6 +46,10 @@
46
46
  &-clear {
47
47
  opacity: 0;
48
48
  z-index: 1;
49
+ top: 0;
50
+ bottom: 0;
51
+ display: flex;
52
+ align-items: center;
49
53
  position: absolute;
50
54
  background: #fff;
51
55
  transition: opacity 0.15s ease;
@@ -66,6 +70,11 @@
66
70
  text-overflow: ellipsis;
67
71
  right: 28px;
68
72
  left: 0;
73
+ top: 0;
74
+ bottom: 0;
75
+ z-index: -1;
76
+ display: flex;
77
+ align-items: center;
69
78
  }
70
79
 
71
80
  &-borderless {
@@ -220,6 +229,8 @@
220
229
 
221
230
  &-suffix {
222
231
  right: 0;
232
+ top: 0;
233
+ bottom: 0;
223
234
  position: absolute;
224
235
  display: flex;
225
236
  flex: 0;
@@ -235,6 +246,10 @@
235
246
  right: 28px;
236
247
  left: 0;
237
248
  height: 100%;
249
+ top: 0;
250
+ bottom: 0;
251
+ display: flex;
252
+ align-items: center;
238
253
  &-input {
239
254
  outline: 0;
240
255
  border-radius: 0;
@@ -289,9 +304,6 @@
289
304
  align-items: center;
290
305
  vertical-align: middle;
291
306
  max-width: 100%;
292
- height: 20px;
293
- line-height: 20px;
294
- margin: 2px 8px 2px 0;
295
307
  cursor: default;
296
308
  user-select: none;
297
309
  &-small {
@@ -19,6 +19,11 @@
19
19
  min-height: @height;
20
20
  max-height: calc(@maxHeight * 3 - 10px);
21
21
  font-size: @fontSize;
22
+
23
+ .@{select-prefix-cls}-selection-item {
24
+ min-height: calc(@height - 4px);
25
+ line-height: calc(@height - 4px);
26
+ }
22
27
  }
23
28
 
24
29
  .over() {
@@ -52,7 +57,6 @@
52
57
  }
53
58
  }
54
59
 
55
-
56
60
  @keyframes SlideUpIn {
57
61
  0% {
58
62
  transform: scaleY(0.8);
@@ -77,4 +81,4 @@
77
81
  transform-origin: 100% 100%;
78
82
  opacity: 0;
79
83
  }
80
- }
84
+ }
@@ -282,7 +282,7 @@
282
282
  @radio-border-width: 1px;
283
283
  @radio-margin-right: 8px;
284
284
  @radio-transition-fn: cubic-bezier(0.075, 0.82, 0.165, 1);
285
- @radio-circle-size: 13px;
285
+ @radio-circle-size: 14px;
286
286
  @radio-square-height: 32px;
287
287
  @radio-square-padding: 0 20px;
288
288
  @radio-button-height: 24px;
@@ -706,4 +706,4 @@
706
706
  @advancedSelector-dropdown-options-height: 32px;
707
707
  @advancedSelector-hover-bg: @hover-color;
708
708
 
709
- /* ----------- AdvancedSelector ——————---- end */
709
+ /* ----------- AdvancedSelector ——————---- end */
@@ -25,8 +25,15 @@ var _usePopper = _interopRequireDefault(require("../_utils/usePopper"));
25
25
  var _option = _interopRequireDefault(require("./option"));
26
26
  var _escapeRegExp = _interopRequireDefault(require("lodash/escapeRegExp"));
27
27
  var _KeyCode = _interopRequireDefault(require("../_utils/KeyCode"));
28
+ var _isObject = _interopRequireDefault(require("lodash/isObject"));
28
29
  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); }
29
30
  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; }
31
+ var getCityId = function getCityId(data) {
32
+ if ((0, _isObject.default)(data)) {
33
+ return data === null || data === void 0 ? void 0 : data.id;
34
+ }
35
+ return data;
36
+ };
30
37
  var InternalSelect = function InternalSelect(props, ref) {
31
38
  var _context, _classNames3, _classNames5;
32
39
  var _useContext = (0, _react.useContext)(_ConfigContext.default),
@@ -76,8 +83,8 @@ var InternalSelect = function InternalSelect(props, ref) {
76
83
  itemRender = selectProps.itemRender,
77
84
  onTabPaneChange = selectProps.onTabPaneChange;
78
85
  var _useMergedState = (0, _hooks.useMergedState)(undefined, {
79
- value: value,
80
- defaultValue: defaultValue
86
+ value: getCityId(value),
87
+ defaultValue: getCityId(defaultValue)
81
88
  }),
82
89
  _useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
83
90
  initValue = _useMergedState2[0],
@@ -126,6 +133,10 @@ var InternalSelect = function InternalSelect(props, ref) {
126
133
  (0, _react.useEffect)(function () {
127
134
  var _context2;
128
135
  if (typeof value === 'undefined') return;
136
+ if ((0, _isObject.default)(value)) {
137
+ setSeletedCity(value);
138
+ return;
139
+ }
129
140
  var cityList = (0, _concat.default)(_context2 = []).call(_context2, (0, _toConsumableArray2.default)(commonList), (0, _toConsumableArray2.default)(domesticList), (0, _toConsumableArray2.default)(foreignList));
130
141
  var city = (0, _find.default)(cityList).call(cityList, function (city) {
131
142
  return city.id === value;
@@ -226,6 +237,7 @@ var InternalSelect = function InternalSelect(props, ref) {
226
237
  };
227
238
  var handleOption = function handleOption(city) {
228
239
  handleVisibleChange(false);
240
+ city.type = tabsValue === 'domestic' ? 'domestic' : 'foreign';
229
241
  (city === null || city === void 0 ? void 0 : city.id) !== initValue && (onChange === null || onChange === void 0 ? void 0 : onChange(city === null || city === void 0 ? void 0 : city.id, city));
230
242
  if (typeof value === 'undefined') {
231
243
  setSeletedCity(city);
@@ -291,17 +303,22 @@ var InternalSelect = function InternalSelect(props, ref) {
291
303
  var symbol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
292
304
  if (!data) return null;
293
305
  if (isDomestic(type)) {
294
- var _context4;
306
+ var _context5;
295
307
  if (isCommon) {
296
308
  var _context3;
297
309
  var _curVal = (data === null || data === void 0 ? void 0 : data.province) ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
298
310
  return (0, _concat.default)(_context3 = "".concat(flag && _curVal ? symbol : '')).call(_context3, _curVal);
299
311
  }
300
- var curVal = tabsValue === 'domestic' ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
301
- return (0, _concat.default)(_context4 = "".concat(flag && curVal ? symbol : '')).call(_context4, curVal);
312
+ if (data === null || data === void 0 ? void 0 : data.type) {
313
+ var _context4;
314
+ var _curVal2 = data.type === 'domestic' ? (data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country) : data === null || data === void 0 ? void 0 : data.country;
315
+ return (0, _concat.default)(_context4 = "".concat(flag && _curVal2 ? symbol : '')).call(_context4, _curVal2);
316
+ }
317
+ var curVal = tabsValue === 'domestic' ? (data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country) : data === null || data === void 0 ? void 0 : data.country;
318
+ return (0, _concat.default)(_context5 = "".concat(flag && curVal ? symbol : '')).call(_context5, curVal);
302
319
  } else {
303
- var _context5, _context6, _context7;
304
- return (0, _concat.default)(_context5 = (0, _concat.default)(_context6 = (0, _concat.default)(_context7 = "".concat(flag && ((data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country)) ? symbol : '')).call(_context7, data === null || data === void 0 ? void 0 : data.province)).call(_context6, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context5, data === null || data === void 0 ? void 0 : data.country);
320
+ var _context6, _context7, _context8;
321
+ return (0, _concat.default)(_context6 = (0, _concat.default)(_context7 = (0, _concat.default)(_context8 = "".concat(flag && ((data === null || data === void 0 ? void 0 : data.province) || (data === null || data === void 0 ? void 0 : data.country)) ? symbol : '')).call(_context8, data === null || data === void 0 ? void 0 : data.province)).call(_context7, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.country);
305
322
  }
306
323
  }, [type, tabsValue]);
307
324
  var renderSingle = function renderSingle() {
@@ -4,6 +4,7 @@ export declare type City = {
4
4
  country?: string;
5
5
  province?: string;
6
6
  name?: string;
7
+ type?: 'domestic' | 'foreign';
7
8
  [key: string]: any;
8
9
  };
9
10
  export declare const BorderTypes: ["none", "underline", "bordered"];
@@ -33,7 +34,7 @@ export interface CityPickerProps {
33
34
  clearIcon?: React.ReactNode;
34
35
  suffixIcon?: React.ReactNode;
35
36
  optionHighlightProps?: string;
36
- value?: string | number;
37
+ value?: string | number | City;
37
38
  defaultValue?: string | number;
38
39
  description?: React.ReactNode;
39
40
  showDescription?: boolean;