@kdcloudjs/kdesign 1.7.19 → 1.7.21

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 (90) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/kdesign-complete.less +337 -240
  3. package/dist/kdesign.css +270 -240
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +766 -850
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +9 -9
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/button/style/token.less +1 -0
  11. package/es/checkbox/checkbox.js +5 -5
  12. package/es/checkbox/style/index.css +2 -0
  13. package/es/checkbox/style/index.less +2 -0
  14. package/es/checkbox/style/token.less +1 -1
  15. package/es/city-picker/city-picker.d.ts +3 -23
  16. package/es/city-picker/city-picker.js +351 -124
  17. package/es/city-picker/interface.d.ts +57 -0
  18. package/es/city-picker/interface.js +3 -0
  19. package/es/city-picker/option.d.ts +4 -0
  20. package/es/city-picker/option.js +42 -0
  21. package/es/city-picker/style/index.css +264 -239
  22. package/es/city-picker/style/index.less +262 -218
  23. package/es/city-picker/style/mixin.less +26 -3
  24. package/es/city-picker/style/token.less +42 -14
  25. package/es/config-provider/compDefaultProps.d.ts +15 -0
  26. package/es/config-provider/compDefaultProps.js +16 -1
  27. package/es/input/style/token.less +2 -8
  28. package/es/select/select.js +25 -15
  29. package/es/tree/tree.js +61 -57
  30. package/es/tree/treeNode.js +1 -6
  31. package/es/tree-select/interface.d.ts +1 -0
  32. package/es/tree-select/style/index.css +4 -1
  33. package/es/tree-select/style/index.less +5 -1
  34. package/es/tree-select/style/token.less +1 -0
  35. package/es/tree-select/tree-select.js +18 -4
  36. package/lib/button/style/token.less +1 -0
  37. package/lib/checkbox/checkbox.js +4 -4
  38. package/lib/checkbox/style/index.css +2 -0
  39. package/lib/checkbox/style/index.less +2 -0
  40. package/lib/checkbox/style/token.less +1 -1
  41. package/lib/city-picker/city-picker.d.ts +3 -23
  42. package/lib/city-picker/city-picker.js +350 -123
  43. package/lib/city-picker/interface.d.ts +57 -0
  44. package/lib/city-picker/interface.js +11 -0
  45. package/lib/city-picker/option.d.ts +4 -0
  46. package/lib/city-picker/option.js +55 -0
  47. package/lib/city-picker/style/index.css +264 -239
  48. package/lib/city-picker/style/index.less +262 -218
  49. package/lib/city-picker/style/mixin.less +26 -3
  50. package/lib/city-picker/style/token.less +42 -14
  51. package/lib/config-provider/compDefaultProps.d.ts +15 -0
  52. package/lib/config-provider/compDefaultProps.js +16 -1
  53. package/lib/input/style/token.less +2 -8
  54. package/lib/select/select.js +25 -15
  55. package/lib/tree/tree.js +60 -56
  56. package/lib/tree/treeNode.js +1 -6
  57. package/lib/tree-select/interface.d.ts +1 -0
  58. package/lib/tree-select/style/index.css +4 -1
  59. package/lib/tree-select/style/index.less +5 -1
  60. package/lib/tree-select/style/token.less +1 -0
  61. package/lib/tree-select/tree-select.js +20 -6
  62. package/package.json +1 -1
  63. package/es/city-picker/city-group.d.ts +0 -8
  64. package/es/city-picker/city-group.js +0 -38
  65. package/es/city-picker/city-list.d.ts +0 -12
  66. package/es/city-picker/city-list.js +0 -55
  67. package/es/city-picker/city-panel-item.d.ts +0 -13
  68. package/es/city-picker/city-panel-item.js +0 -22
  69. package/es/city-picker/city-panel.d.ts +0 -17
  70. package/es/city-picker/city-panel.js +0 -153
  71. package/es/city-picker/city-search-panel.d.ts +0 -9
  72. package/es/city-picker/city-search-panel.js +0 -44
  73. package/es/city-picker/no-data.d.ts +0 -3
  74. package/es/city-picker/no-data.js +0 -18
  75. package/es/city-picker/utils/grouping.d.ts +0 -7
  76. package/es/city-picker/utils/grouping.js +0 -24
  77. package/lib/city-picker/city-group.d.ts +0 -8
  78. package/lib/city-picker/city-group.js +0 -51
  79. package/lib/city-picker/city-list.d.ts +0 -12
  80. package/lib/city-picker/city-list.js +0 -68
  81. package/lib/city-picker/city-panel-item.d.ts +0 -13
  82. package/lib/city-picker/city-panel-item.js +0 -35
  83. package/lib/city-picker/city-panel.d.ts +0 -17
  84. package/lib/city-picker/city-panel.js +0 -166
  85. package/lib/city-picker/city-search-panel.d.ts +0 -9
  86. package/lib/city-picker/city-search-panel.js +0 -57
  87. package/lib/city-picker/no-data.d.ts +0 -3
  88. package/lib/city-picker/no-data.js +0 -31
  89. package/lib/city-picker/utils/grouping.d.ts +0 -7
  90. package/lib/city-picker/utils/grouping.js +0 -30
@@ -91,6 +91,7 @@
91
91
  @btn-middle-height: var(~'@{button-custom-prefix}-sizing-height-middle', 28px); // 中号 高度 高度配置
92
92
  @btn-middle-min-width: var(~'@{button-custom-prefix}-sizing-min-width-middle', 60px); // 中号 最小宽度
93
93
  @btn-large-height: var(~'@{button-custom-prefix}-sizing-height-large', 32px); // 大号 高度
94
+ @btn-middle-max-width: var(~'@{button-custom-prefix}-sizing-max-width-middle'); // 中号 最大宽度
94
95
  @btn-large-min-width: var(~'@{button-custom-prefix}-sizing-min-width-large', 80px); // 大号 最小宽度
95
96
  @btn-group-dropdown-item-height: var(~'@{button-custom-prefix}--group-dropdown-item-height', 30px);
96
97
  @btn-group-dropdown-min-width: var(~'@{button-custom-prefix}-group-dropdown-min-width', 80px);
@@ -11,7 +11,7 @@ var __rest = this && this.__rest || function (s, e) {
11
11
  }
12
12
  return t;
13
13
  };
14
- import React, { useCallback, useContext, useEffect, useState, useRef } from 'react';
14
+ import React, { useContext, useEffect, useState, useRef } from 'react';
15
15
  import classNames from 'classnames';
16
16
  import { GroupContext, CheckboxTypes, CheckboxSizes } from './group';
17
17
  import ConfigContext from '../config-provider/ConfigContext';
@@ -63,20 +63,20 @@ var InternalCheckbox = function InternalCheckbox(props, ref) {
63
63
  var getIndeterminate = function getIndeterminate() {
64
64
  return selected ? false : indeterminate;
65
65
  };
66
- var getDefaultClassName = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(checkboxPrefixCls), true), _defineProperty(_classNames, "".concat(checkboxPrefixCls, "-no-child"), !children), _defineProperty(_classNames, _concatInstanceProperty(_context = "".concat(checkboxPrefixCls, "-")).call(_context, mergedSize), true && !!children), _defineProperty(_classNames, _concatInstanceProperty(_context2 = "".concat(checkboxPrefixCls, "-")).call(_context2, mergedCheckboxType), true), _defineProperty(_classNames, _concatInstanceProperty(_context3 = "".concat(checkboxPrefixCls, "-")).call(_context3, mergedCheckboxType, "-disabled"), mergedDisabled), _defineProperty(_classNames, "checked", selected), _classNames));
67
- var getSquareClassName = classNames(className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(checkboxPrefixCls), true), _defineProperty(_classNames2, _concatInstanceProperty(_context4 = "".concat(checkboxPrefixCls, "-")).call(_context4, mergedCheckboxType), true), _defineProperty(_classNames2, _concatInstanceProperty(_context5 = "".concat(checkboxPrefixCls, "-")).call(_context5, mergedSize), true && !!children), _defineProperty(_classNames2, _concatInstanceProperty(_context6 = "".concat(checkboxPrefixCls, "-")).call(_context6, mergedCheckboxType, "-disabled"), mergedDisabled), _defineProperty(_classNames2, _concatInstanceProperty(_context7 = "".concat(checkboxPrefixCls, "-")).call(_context7, mergedCheckboxType, "-checked"), selected && !mergedDisabled), _defineProperty(_classNames2, "checked", selected), _classNames2));
66
+ var getDefaultClassName = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(checkboxPrefixCls), true), _defineProperty(_classNames, "".concat(checkboxPrefixCls, "-no-child"), !children), _defineProperty(_classNames, _concatInstanceProperty(_context = "".concat(checkboxPrefixCls, "-")).call(_context, mergedSize), !!children), _defineProperty(_classNames, _concatInstanceProperty(_context2 = "".concat(checkboxPrefixCls, "-")).call(_context2, mergedCheckboxType), true), _defineProperty(_classNames, _concatInstanceProperty(_context3 = "".concat(checkboxPrefixCls, "-")).call(_context3, mergedCheckboxType, "-disabled"), mergedDisabled), _defineProperty(_classNames, "checked", selected), _classNames));
67
+ var getSquareClassName = classNames(className, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(checkboxPrefixCls), true), _defineProperty(_classNames2, _concatInstanceProperty(_context4 = "".concat(checkboxPrefixCls, "-")).call(_context4, mergedCheckboxType), true), _defineProperty(_classNames2, _concatInstanceProperty(_context5 = "".concat(checkboxPrefixCls, "-")).call(_context5, mergedSize), !!children), _defineProperty(_classNames2, _concatInstanceProperty(_context6 = "".concat(checkboxPrefixCls, "-")).call(_context6, mergedCheckboxType, "-disabled"), mergedDisabled), _defineProperty(_classNames2, _concatInstanceProperty(_context7 = "".concat(checkboxPrefixCls, "-")).call(_context7, mergedCheckboxType, "-checked"), selected && !mergedDisabled), _defineProperty(_classNames2, "checked", selected), _classNames2));
68
68
  var getRootClassName = isDefaultType() ? getDefaultClassName : getSquareClassName;
69
69
  var inputClassName = classNames(_defineProperty({}, "".concat(checkboxPrefixCls, "-input"), true));
70
70
  var checkedWrapperClassName = classNames((_classNames4 = {}, _defineProperty(_classNames4, _concatInstanceProperty(_context8 = "".concat(checkboxPrefixCls, "-")).call(_context8, mergedCheckboxType, "-no-child"), !children), _defineProperty(_classNames4, _concatInstanceProperty(_context9 = "".concat(checkboxPrefixCls, "-")).call(_context9, mergedCheckboxType, "-wrapper"), true), _defineProperty(_classNames4, _concatInstanceProperty(_context10 = "".concat(checkboxPrefixCls, "-")).call(_context10, mergedCheckboxType, "-wrapper-size"), !!children), _defineProperty(_classNames4, _concatInstanceProperty(_context11 = "".concat(checkboxPrefixCls, "-")).call(_context11, mergedCheckboxType, "-margin"), !!children), _defineProperty(_classNames4, _concatInstanceProperty(_context12 = "".concat(checkboxPrefixCls, "-")).call(_context12, mergedCheckboxType, "-checked"), selected), _defineProperty(_classNames4, _concatInstanceProperty(_context13 = "".concat(checkboxPrefixCls, "-")).call(_context13, mergedCheckboxType, "-indeterminate"), getIndeterminate()), _defineProperty(_classNames4, _concatInstanceProperty(_context14 = "".concat(checkboxPrefixCls, "-")).call(_context14, mergedCheckboxType, "-disabled"), mergedDisabled && !selected), _defineProperty(_classNames4, _concatInstanceProperty(_context15 = "".concat(checkboxPrefixCls, "-")).call(_context15, mergedCheckboxType, "-checked-disabled"), mergedDisabled && selected), _classNames4));
71
71
  var triangleClassName = classNames((_classNames5 = {}, _defineProperty(_classNames5, _concatInstanceProperty(_context16 = "".concat(checkboxPrefixCls, "-")).call(_context16, mergedCheckboxType, "-triangle"), !selected), _defineProperty(_classNames5, _concatInstanceProperty(_context17 = "".concat(checkboxPrefixCls, "-")).call(_context17, mergedCheckboxType, "-triangle-checked"), selected), _defineProperty(_classNames5, _concatInstanceProperty(_context18 = "".concat(checkboxPrefixCls, "-")).call(_context18, mergedCheckboxType, "-triangle-disabled"), mergedDisabled), _classNames5));
72
72
  var innerIconClassName = classNames(_defineProperty({}, _concatInstanceProperty(_context19 = "".concat(checkboxPrefixCls, "-")).call(_context19, mergedCheckboxType, "-inner"), true));
73
- var handleChange = useCallback(function (e) {
73
+ var handleChange = function handleChange(e) {
74
74
  onChange && onChange(e);
75
75
  (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.onCheckboxGroupChange) && (checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.onCheckboxGroupChange(value, e.target.checked, e));
76
76
  if (!(checkboxGroup === null || checkboxGroup === void 0 ? void 0 : checkboxGroup.isControlled)) {
77
77
  setSelected(e.target.checked);
78
78
  }
79
- }, [onChange]);
79
+ };
80
80
  useEffect(function () {
81
81
  isBoolean(checked) && checked !== selected && setSelected(checked);
82
82
  }, [checked, selected]);
@@ -141,6 +141,8 @@
141
141
  width: 100%;
142
142
  cursor: inherit;
143
143
  opacity: 0;
144
+ inset: 0;
145
+ z-index: 1;
144
146
  }
145
147
  .kd-checkbox-children {
146
148
  display: -webkit-inline-box;
@@ -32,6 +32,8 @@
32
32
  width: 100%;
33
33
  cursor: inherit;
34
34
  opacity: 0;
35
+ inset: 0;
36
+ z-index: 1;
35
37
  }
36
38
  &-children {
37
39
  display: inline-flex;
@@ -2,7 +2,7 @@
2
2
 
3
3
  @checkbox-prefix: '--@{kd-prefix}-c-checkbox';
4
4
 
5
- // colors
5
+ // color
6
6
  @checkbox-color-theme: var(~'@{checkbox-prefix}-color-theme', @color-theme);
7
7
  @checkbox-font-color: var(~'@{checkbox-prefix}-color-text-primary', #212121);
8
8
  @checkbox-border-color: var(~'@{checkbox-prefix}-color-border', #d9d9d9);
@@ -1,24 +1,4 @@
1
1
  import React from 'react';
2
- import CityPanelItem from './city-panel-item';
3
- import CityPanel, { Common, Group, List as CityList } from './city-panel';
4
- import SearchPanel from './city-search-panel';
5
- export interface CityPickerProps {
6
- cityList?: CityList;
7
- className?: string;
8
- commons?: Common;
9
- disabled?: boolean;
10
- groups?: Group;
11
- inputClassName?: string;
12
- inputStyle?: React.CSSProperties;
13
- placeholder?: string;
14
- showTitle?: boolean;
15
- style?: React.CSSProperties;
16
- title?: string;
17
- }
18
- export interface MenuType extends React.FC<CityPickerProps> {
19
- PanelItem: typeof CityPanelItem;
20
- Panel: typeof CityPanel;
21
- SearchPanel: typeof SearchPanel;
22
- }
23
- declare const CityPicker: MenuType;
24
- export default CityPicker;
2
+ import { CityPickerProps } from './interface';
3
+ declare const Select: React.ForwardRefExoticComponent<CityPickerProps & React.RefAttributes<unknown>>;
4
+ export default Select;
@@ -1,152 +1,379 @@
1
+ import _extends from "@babel/runtime-corejs3/helpers/extends";
1
2
  import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
+ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
4
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
4
- import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
5
- import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
6
- import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
7
- import React, { useContext, useState, useRef, useEffect } from 'react';
6
+ import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
7
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
+ import React, { useContext, useRef, useEffect, useState, useCallback } from 'react';
9
+ import { useMergedState } from '../_utils/hooks';
8
10
  import classNames from 'classnames';
9
11
  import ConfigContext from '../config-provider/ConfigContext';
10
- import CityPanelItem from './city-panel-item';
11
- import CityPanel from './city-panel';
12
- import SearchPanel from './city-search-panel';
12
+ import { getCompProps } from '../_utils';
13
+ import { Icon, Tabs, Spin } from '../index';
13
14
  import usePopper from '../_utils/usePopper';
14
- var CityPicker = function CityPicker(_ref) {
15
- var cityList = _ref.cityList,
16
- className = _ref.className,
17
- commons = _ref.commons,
18
- disabled = _ref.disabled,
19
- groups = _ref.groups,
20
- inputClassName = _ref.inputClassName,
21
- inputStyle = _ref.inputStyle,
22
- placeholder = _ref.placeholder,
23
- showTitle = _ref.showTitle,
24
- style = _ref.style,
25
- title = _ref.title;
15
+ import Option from './option';
16
+ import escapeRegExp from 'lodash/escapeRegExp';
17
+ var tabsData = [{
18
+ id: 'domestic',
19
+ name: '国内'
20
+ }, {
21
+ id: 'foreign',
22
+ name: '国际/中国港澳台'
23
+ }];
24
+ var InternalSelect = function InternalSelect(props, ref) {
25
+ var _context, _classNames3, _classNames5;
26
26
  var _useContext = useContext(ConfigContext),
27
27
  getPrefixCls = _useContext.getPrefixCls,
28
- prefixCls = _useContext.prefixCls;
29
- var _useState = useState(''),
28
+ prefixCls = _useContext.prefixCls,
29
+ userDefaultProps = _useContext.compDefaultProps;
30
+ var selectProps = getCompProps('CityPicker', userDefaultProps, props);
31
+ var type = selectProps.type,
32
+ size = selectProps.size,
33
+ value = selectProps.value,
34
+ className = selectProps.className,
35
+ defaultOpen = selectProps.defaultOpen,
36
+ disabled = selectProps.disabled,
37
+ borderType = selectProps.borderType,
38
+ _selectProps$showArro = selectProps.showArrow,
39
+ showArrow = _selectProps$showArro === void 0 ? true : _selectProps$showArro,
40
+ allowClear = selectProps.allowClear,
41
+ customPrefixcls = selectProps.prefixCls,
42
+ onFocus = selectProps.onFocus,
43
+ onBlur = selectProps.onBlur,
44
+ onClear = selectProps.onClear,
45
+ onVisibleChange = selectProps.onVisibleChange,
46
+ onChange = selectProps.onChange,
47
+ onSearch = selectProps.onSearch,
48
+ defaultValue = selectProps.defaultValue,
49
+ placeholder = selectProps.placeholder,
50
+ _selectProps$dropdown = selectProps.dropdownStyle,
51
+ dropdownStyle = _selectProps$dropdown === void 0 ? {} : _selectProps$dropdown,
52
+ style = selectProps.style,
53
+ clearIcon = selectProps.clearIcon,
54
+ loading = selectProps.loading,
55
+ showDescription = selectProps.showDescription,
56
+ description = selectProps.description,
57
+ optionHighlightProps = selectProps.optionHighlightProps,
58
+ _selectProps$popperSt = selectProps.popperStyle,
59
+ popperStyle = _selectProps$popperSt === void 0 ? {} : _selectProps$popperSt,
60
+ _selectProps$commonLi = selectProps.commonList,
61
+ commonList = _selectProps$commonLi === void 0 ? [] : _selectProps$commonLi,
62
+ _selectProps$domestic = selectProps.domesticList,
63
+ domesticList = _selectProps$domestic === void 0 ? [] : _selectProps$domestic,
64
+ _selectProps$foreignL = selectProps.foreignList,
65
+ foreignList = _selectProps$foreignL === void 0 ? [] : _selectProps$foreignL,
66
+ itemRender = selectProps.itemRender;
67
+ var _useMergedState = useMergedState(undefined, {
68
+ value: value,
69
+ defaultValue: defaultValue
70
+ }),
71
+ _useMergedState2 = _slicedToArray(_useMergedState, 2),
72
+ initValue = _useMergedState2[0],
73
+ setInitValue = _useMergedState2[1];
74
+ var innerRef = useRef();
75
+ var selectRef = ref || innerRef;
76
+ var searchRef = useRef(null); // 搜索框ref
77
+ var selectionRef = useRef(null);
78
+ var clearRef = useRef(null);
79
+ var _useState = useState(typeof props.visible === 'undefined' ? !!defaultOpen : !!props.visible),
30
80
  _useState2 = _slicedToArray(_useState, 2),
31
- inputVal = _useState2[0],
32
- setInputVal = _useState2[1];
81
+ optionShow = _useState2[0],
82
+ setOptionShow = _useState2[1];
33
83
  var _useState3 = useState(''),
34
84
  _useState4 = _slicedToArray(_useState3, 2),
35
- additionalVal = _useState4[0],
36
- setAdditionalVal = _useState4[1];
85
+ searchValue = _useState4[0],
86
+ setSearchValue = _useState4[1];
37
87
  var _useState5 = useState(false),
38
88
  _useState6 = _slicedToArray(_useState5, 2),
39
- popperVisible = _useState6[0],
40
- setPopperVisible = _useState6[1];
41
- var inputRef = useRef(null);
42
- var allCity = useRef([]);
89
+ focusd = _useState6[0],
90
+ setFocusd = _useState6[1];
91
+ var _useState7 = useState(null),
92
+ _useState8 = _slicedToArray(_useState7, 2),
93
+ seletedCity = _useState8[0],
94
+ setSeletedCity = _useState8[1];
95
+ var _useState9 = useState('domestic'),
96
+ _useState10 = _slicedToArray(_useState9, 2),
97
+ tabsValue = _useState10[0],
98
+ setTabsValue = _useState10[1];
99
+ var isDomestic = function isDomestic(type) {
100
+ return type === 'domestic';
101
+ };
102
+ var selectPrefixCls = getPrefixCls(prefixCls, 'city-picker', customPrefixcls);
103
+ var cityPickerCls = classNames(selectPrefixCls, className, _defineProperty({}, "".concat(selectPrefixCls, "-visible"), optionShow));
104
+ var selectionCls = classNames(_defineProperty({}, "".concat(selectPrefixCls, "-selector"), true));
105
+ // 公共样式
106
+ var commCls = classNames((_classNames3 = {}, _defineProperty(_classNames3, "".concat(selectPrefixCls, "-bordered"), borderType === 'bordered'), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-underline"), borderType === 'underline'), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-borderless"), borderType === 'none'), _defineProperty(_classNames3, _concatInstanceProperty(_context = "".concat(selectPrefixCls, "-size-")).call(_context, size), size), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-wrapper"), true), _defineProperty(_classNames3, "".concat(selectPrefixCls, "-show-search"), focusd), _classNames3));
43
107
  useEffect(function () {
44
- var _context;
45
- if (!cityList) {
46
- return;
108
+ var _context2;
109
+ if (typeof value === 'undefined') return;
110
+ var cityList = _concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(commonList), _toConsumableArray(domesticList), _toConsumableArray(foreignList));
111
+ var city = _findInstanceProperty(cityList).call(cityList, function (city) {
112
+ return city.id === value;
113
+ });
114
+ if (city) {
115
+ setSeletedCity(city);
47
116
  }
48
- var domestic = cityList.domestic,
49
- foreign = cityList.foreign;
50
- allCity.current = _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(_Object$values(domestic)), _toConsumableArray(_Object$values(foreign))).reduce(function (arr, current) {
51
- return _concatInstanceProperty(arr).call(arr, current);
52
- }, []);
53
- }, [cityList]);
54
- var cityPickerPrefixCls = getPrefixCls(prefixCls, 'city-picker');
55
- var containerCls = classNames("".concat(cityPickerPrefixCls, "-container"), className);
56
- var contentCls = classNames("".concat(cityPickerPrefixCls, "-content"));
57
- var titleCls = classNames("".concat(cityPickerPrefixCls, "-title"));
58
- var additionalInfoCls = classNames("".concat(cityPickerPrefixCls, "-info"));
59
- var inputCls = classNames("".concat(cityPickerPrefixCls, "-input"), inputClassName);
60
- var arrowCls = classNames('kdicon kdicon-arrow-down', "".concat(cityPickerPrefixCls, "-arrow"), {
61
- 'arrow-up': popperVisible
62
- });
63
- var handleContainerClick = function handleContainerClick() {
64
- var _a;
65
- if (document.activeElement === inputRef.current) {
66
- return;
117
+ }, [commonList, domesticList, foreignList, value]);
118
+ useEffect(function () {
119
+ if (typeof props.visible !== 'undefined') {
120
+ setOptionShow(props.visible);
121
+ }
122
+ }, [props.visible]);
123
+ useEffect(function () {
124
+ if (optionShow === false) {
125
+ handleClear();
67
126
  }
68
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
127
+ }, [optionShow]);
128
+ var handleFocus = useCallback(function (e) {
129
+ e.stopPropagation();
130
+ setFocusd(true);
131
+ onFocus && onFocus(e);
132
+ }, [onFocus]);
133
+ var handleBlur = useCallback(function (e) {
134
+ e.stopPropagation();
135
+ setFocusd(false);
136
+ onBlur && onBlur(e);
137
+ }, [onBlur]);
138
+ useEffect(function () {
139
+ selectionRef.current.addEventListener('mouseup', function (e) {
140
+ var _a;
141
+ var isCloseBtn = ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.className.indexOf('kd-tag-close-icon')) > -1;
142
+ if (isCloseBtn) {
143
+ e.stopPropagation();
144
+ }
145
+ });
146
+ }, []);
147
+ // 输入框变化搜索内容
148
+ var handleSearchChange = useCallback(function (event) {
149
+ var val = event.currentTarget.value;
150
+ setOptionShow(true);
151
+ setSearchValue(val);
152
+ onSearch === null || onSearch === void 0 ? void 0 : onSearch(val);
153
+ }, [onSearch]);
154
+ // 清除搜索内容
155
+ var handleClear = useCallback(function () {
156
+ if (searchRef.current) {
157
+ searchRef.current.value = '';
158
+ setSearchValue('');
159
+ }
160
+ }, [searchRef]);
161
+ // 清空选择器内容
162
+ var handleReset = function handleReset(e) {
163
+ e.stopPropagation();
164
+ onClear && onClear('');
165
+ setInitValue('');
166
+ setSeletedCity(null);
167
+ setSearchValue('');
168
+ onChange && onChange(undefined, '');
169
+ };
170
+ // 渲染后缀图标
171
+ var renderSuffix = function renderSuffix() {
172
+ var _classNames4;
173
+ if (disabled) return null;
174
+ var suffixIcon = selectProps.suffixIcon;
175
+ var arrowIconCls = classNames((_classNames4 = {}, _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow"), true), _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-up"), optionShow), _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-down"), !optionShow), _defineProperty(_classNames4, "".concat(selectPrefixCls, "-icon-arrow-focus"), optionShow), _classNames4));
176
+ var iconShow = allowClear && !disabled && ((initValue !== null && initValue !== void 0 ? initValue : '') !== '' || searchValue);
177
+ return /*#__PURE__*/React.createElement(React.Fragment, null, iconShow && /*#__PURE__*/React.createElement("span", {
178
+ onClick: handleReset,
179
+ onMouseDown: function onMouseDown(e) {
180
+ return e.preventDefault();
181
+ },
182
+ className: "".concat(selectPrefixCls, "-icon-clear"),
183
+ ref: clearRef
184
+ }, clearIcon || /*#__PURE__*/React.createElement(Icon, {
185
+ type: "close-solid"
186
+ })), showArrow && /*#__PURE__*/React.createElement("span", {
187
+ className: arrowIconCls
188
+ }, suffixIcon || /*#__PURE__*/React.createElement(Icon, {
189
+ type: "arrow-down"
190
+ })));
69
191
  };
70
- var handleCitySelect = function handleCitySelect(city) {
71
- var _context2, _context3;
72
- setInputVal(city.name || '');
73
- var otherInfoStr = city.country === '中国' ? "".concat(city.province) : _concatInstanceProperty(_context2 = _concatInstanceProperty(_context3 = "".concat(city.province)).call(_context3, city.province ? ',' : '')).call(_context2, city.country);
74
- setAdditionalVal(otherInfoStr);
75
- setPopperVisible(false);
192
+ // 下拉列表为空时显示的内容
193
+ var renderNotContent = function renderNotContent(msg) {
194
+ var notFoundContent = selectProps.notFoundContent;
195
+ var emptyContent = notFoundContent || msg;
196
+ return /*#__PURE__*/React.createElement("div", {
197
+ className: "".concat(selectPrefixCls, "-dropdown-empty")
198
+ }, emptyContent);
199
+ };
200
+ var getHighlightText = function getHighlightText(text, inputValue) {
201
+ if (!inputValue || !text) return text;
202
+ var regex = new RegExp(Array.isArray(inputValue) ? _mapInstanceProperty(inputValue).call(inputValue, function (item) {
203
+ return "(".concat(escapeRegExp(item), ")");
204
+ }).join('|') : "(".concat(escapeRegExp(inputValue), ")"), 'i');
205
+ var strArr = text === null || text === void 0 ? void 0 : text.split(regex);
206
+ return /*#__PURE__*/React.createElement(React.Fragment, null, strArr === null || strArr === void 0 ? void 0 : _mapInstanceProperty(strArr).call(strArr, function (item, index) {
207
+ return (regex === null || regex === void 0 ? void 0 : regex.test(item)) ? /*#__PURE__*/React.createElement("span", {
208
+ key: index,
209
+ className: "".concat(selectPrefixCls, "-highlight")
210
+ }, item) : /*#__PURE__*/React.createElement("span", {
211
+ key: index
212
+ }, item);
213
+ }));
214
+ };
215
+ var handleOption = function handleOption(city) {
216
+ handleVisibleChange(false);
217
+ (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
+ if (typeof value === 'undefined') {
219
+ setSeletedCity(city);
220
+ setInitValue(city === null || city === void 0 ? void 0 : city.id);
221
+ }
76
222
  };
77
- var handleFocus = function handleFocus() {
78
- if (popperVisible) {
79
- return;
223
+ var renderNodeList = function renderNodeList(data, notContent) {
224
+ if (!data.length) {
225
+ return renderNotContent(notContent);
80
226
  }
81
- setPopperVisible(true);
227
+ return /*#__PURE__*/React.createElement("div", {
228
+ className: "".concat(selectPrefixCls, "-list")
229
+ }, _mapInstanceProperty(data).call(data, function (item) {
230
+ return /*#__PURE__*/React.createElement(Option, {
231
+ key: item.id,
232
+ value: initValue,
233
+ city: item,
234
+ renderCityInfo: renderCityInfo,
235
+ onChangeSelect: handleOption,
236
+ itemRender: itemRender
237
+ }, 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);
238
+ }));
82
239
  };
83
- var handleChange = function handleChange(evt) {
84
- var value = evt.target.value;
85
- setAdditionalVal('');
86
- setInputVal(value);
240
+ var renderLoading = function renderLoading() {
241
+ return /*#__PURE__*/React.createElement("div", {
242
+ className: "".concat(selectPrefixCls, "-dropdown-loading")
243
+ }, /*#__PURE__*/React.createElement(Spin, {
244
+ type: "container"
245
+ }));
87
246
  };
88
- var handlePopperVisibleChange = function handlePopperVisibleChange(visible) {
89
- if (!visible) {
90
- setPopperVisible(false);
247
+ var toggleTabPane = function toggleTabPane(type) {
248
+ setTabsValue(type);
249
+ };
250
+ // 渲染下拉列表框
251
+ var renderContent = function renderContent() {
252
+ return loading ? renderLoading() : /*#__PURE__*/React.createElement(React.Fragment, null, searchValue ? /*#__PURE__*/React.createElement(React.Fragment, null, isDomestic(type) && /*#__PURE__*/React.createElement(Tabs, {
253
+ noContainer: true,
254
+ onChange: toggleTabPane,
255
+ activeKey: tabsValue
256
+ }, _mapInstanceProperty(tabsData).call(tabsData, function (item) {
257
+ return /*#__PURE__*/React.createElement(Tabs.TabPane, {
258
+ key: item.id,
259
+ tab: item.name
260
+ }, item);
261
+ })), tabsValue === 'domestic' ? renderNodeList(domesticList, '暂无数据') : renderNodeList(foreignList, '暂无数据')) : /*#__PURE__*/React.createElement(React.Fragment, null, !!commonList.length && /*#__PURE__*/React.createElement("div", {
262
+ className: "".concat(selectPrefixCls, "-dropdown-common")
263
+ }, "\u5E38\u7528"), renderNodeList(commonList, '无常用城市')));
264
+ };
265
+ var renderCityInfo = useCallback(function (data) {
266
+ var flag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
267
+ var symbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ', ';
268
+ if (!data) return null;
269
+ if (isDomestic(type)) {
270
+ var _context3;
271
+ return _concatInstanceProperty(_context3 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context3, data === null || data === void 0 ? void 0 : data.province);
272
+ } else {
273
+ var _context4, _context5, _context6;
274
+ return _concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = _concatInstanceProperty(_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);
91
275
  }
276
+ }, [type]);
277
+ var renderSingle = function renderSingle() {
278
+ var hiddenStyle = !!searchValue || (initValue !== null && initValue !== void 0 ? initValue : '') !== '' ? {
279
+ visibility: 'hidden'
280
+ } : undefined;
281
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
282
+ className: singleCls,
283
+ ref: selectionRef
284
+ }, /*#__PURE__*/React.createElement("div", {
285
+ className: "".concat(selectPrefixCls, "-content")
286
+ }, /*#__PURE__*/React.createElement("span", {
287
+ className: "".concat(selectPrefixCls, "-content-search")
288
+ }, /*#__PURE__*/React.createElement("input", {
289
+ ref: searchRef,
290
+ value: searchValue,
291
+ className: "".concat(selectPrefixCls, "-content-search-input"),
292
+ onChange: handleSearchChange,
293
+ onFocus: handleFocus,
294
+ onBlur: handleBlur,
295
+ readOnly: !!disabled
296
+ }), !searchValue && /*#__PURE__*/React.createElement("span", {
297
+ className: "".concat(selectPrefixCls, "-content-item"),
298
+ title: seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name
299
+ }, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue && /*#__PURE__*/React.createElement("span", {
300
+ className: "".concat(selectPrefixCls, "-content-info")
301
+ }, renderCityInfo(seletedCity))), /*#__PURE__*/React.createElement("span", {
302
+ className: "".concat(selectPrefixCls, "-placeholder"),
303
+ style: hiddenStyle
304
+ }, placeholder), /*#__PURE__*/React.createElement("span", {
305
+ className: "".concat(selectPrefixCls, "-suffix")
306
+ }, renderSuffix())));
92
307
  };
93
- var inputSelector = /*#__PURE__*/React.createElement("div", {
94
- className: containerCls,
95
- style: style,
96
- onClick: handleContainerClick
97
- }, showTitle && /*#__PURE__*/React.createElement("div", {
98
- className: titleCls
99
- }, title), /*#__PURE__*/React.createElement("div", {
100
- className: contentCls
101
- }, /*#__PURE__*/React.createElement("input", {
102
- ref: inputRef,
103
- type: "text",
104
- readOnly: disabled,
105
- onChange: handleChange,
106
- placeholder: placeholder,
107
- style: inputStyle,
108
- className: inputCls,
109
- title: inputVal,
110
- value: inputVal,
111
- onFocus: handleFocus
112
- }), /*#__PURE__*/React.createElement("span", {
113
- className: additionalInfoCls
114
- }, additionalVal), /*#__PURE__*/React.createElement("i", {
115
- className: arrowCls
116
- })));
117
- var cityPanel = /*#__PURE__*/React.createElement(CityPanel, {
118
- commons: commons,
119
- groups: groups,
120
- cityList: cityList,
121
- onSelect: handleCitySelect
122
- });
123
- var getSearchResults = function getSearchResults() {
124
- var _context4;
125
- if (!allCity.current || allCity.current.length === 0 || !inputVal) {
126
- return [];
308
+ var singleCls = classNames(commCls, (_classNames5 = {}, _defineProperty(_classNames5, "".concat(selectPrefixCls, "-disabled"), disabled), _defineProperty(_classNames5, "".concat(selectPrefixCls, "-focused"), !disabled && focusd || optionShow), _classNames5));
309
+ useEffect(function () {
310
+ if (optionShow && !disabled) {
311
+ var onDropdownVisibleChange = selectProps.onDropdownVisibleChange;
312
+ onDropdownVisibleChange && onDropdownVisibleChange(true);
127
313
  }
128
- return _filterInstanceProperty(_context4 = allCity.current).call(_context4, function (city) {
314
+ }, [optionShow]);
315
+ useEffect(function () {
316
+ var _a;
317
+ var fn = function fn(e) {
318
+ e.stopPropagation();
319
+ };
320
+ (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseup', fn);
321
+ return function () {
129
322
  var _a;
130
- return (_a = city.name) === null || _a === void 0 ? void 0 : _startsWithInstanceProperty(_a).call(_a, inputVal);
131
- });
323
+ (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
324
+ };
325
+ }, [initValue]);
326
+ var renderCityPicker = function renderCityPicker() {
327
+ return /*#__PURE__*/React.createElement("div", {
328
+ className: cityPickerCls,
329
+ ref: selectRef,
330
+ style: style
331
+ }, showDescription && /*#__PURE__*/React.createElement("span", {
332
+ className: "".concat(selectPrefixCls, "-description")
333
+ }, description), /*#__PURE__*/React.createElement("span", {
334
+ className: selectionCls,
335
+ tabIndex: disabled ? -1 : 0,
336
+ onFocus: function onFocus() {
337
+ var _a;
338
+ return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.focus();
339
+ },
340
+ onBlur: function onBlur() {
341
+ var _a;
342
+ return (_a = searchRef.current) === null || _a === void 0 ? void 0 : _a.blur();
343
+ }
344
+ }, renderSingle()));
132
345
  };
133
- var searchPanel = /*#__PURE__*/React.createElement(SearchPanel, {
134
- keyword: inputVal,
135
- data: getSearchResults(),
136
- onSelect: handleCitySelect
137
- });
138
- var popperProps = {
139
- visible: popperVisible,
140
- placement: 'bottomLeft',
141
- trigger: 'focus',
142
- prefixCls: "".concat(cityPickerPrefixCls, "-panel"),
143
- onVisibleChange: handlePopperVisibleChange
346
+ var catchStyle = function catchStyle() {
347
+ var _a;
348
+ if (selectRef === null || selectRef === void 0 ? void 0 : selectRef.current) {
349
+ var _ref = (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect(),
350
+ width = _ref.width;
351
+ return _extends(_extends(_extends({
352
+ minWidth: width,
353
+ maxWidth: 600
354
+ }, dropdownStyle), {
355
+ width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto',
356
+ zIndex: 1050
357
+ }), popperStyle);
358
+ }
144
359
  };
145
- var panel = inputVal.length > 0 ? searchPanel : cityPanel;
146
- return usePopper(inputSelector, panel, popperProps);
360
+ var handleVisibleChange = function handleVisibleChange(visible) {
361
+ if (visible !== optionShow) {
362
+ props.visible === undefined && setOptionShow(visible);
363
+ onVisibleChange && onVisibleChange(visible);
364
+ }
365
+ };
366
+ var popperProps = _extends(_extends({}, selectProps), {
367
+ prefixCls: "".concat(selectPrefixCls, "-dropdown"),
368
+ placement: 'bottomLeft',
369
+ popperStyle: catchStyle(),
370
+ defaultVisible: optionShow,
371
+ visible: optionShow,
372
+ onVisibleChange: handleVisibleChange,
373
+ clickToClose: !searchValue
374
+ });
375
+ return usePopper(renderCityPicker(), renderContent(), popperProps);
147
376
  };
148
- CityPicker.displayName = 'CityPicker';
149
- CityPicker.PanelItem = CityPanelItem;
150
- CityPicker.Panel = CityPanel;
151
- CityPicker.SearchPanel = SearchPanel;
152
- export default CityPicker;
377
+ var Select = /*#__PURE__*/React.forwardRef(InternalSelect);
378
+ Select.displayName = 'CityPicker';
379
+ export default Select;