@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.
- package/CHANGELOG.md +51 -0
- package/dist/kdesign-complete.less +337 -240
- package/dist/kdesign.css +270 -240
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +766 -850
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +9 -9
- package/dist/kdesign.min.js.map +1 -1
- package/es/button/style/token.less +1 -0
- package/es/checkbox/checkbox.js +5 -5
- package/es/checkbox/style/index.css +2 -0
- package/es/checkbox/style/index.less +2 -0
- package/es/checkbox/style/token.less +1 -1
- package/es/city-picker/city-picker.d.ts +3 -23
- package/es/city-picker/city-picker.js +351 -124
- package/es/city-picker/interface.d.ts +57 -0
- package/es/city-picker/interface.js +3 -0
- package/es/city-picker/option.d.ts +4 -0
- package/es/city-picker/option.js +42 -0
- package/es/city-picker/style/index.css +264 -239
- package/es/city-picker/style/index.less +262 -218
- package/es/city-picker/style/mixin.less +26 -3
- package/es/city-picker/style/token.less +42 -14
- package/es/config-provider/compDefaultProps.d.ts +15 -0
- package/es/config-provider/compDefaultProps.js +16 -1
- package/es/input/style/token.less +2 -8
- package/es/select/select.js +25 -15
- package/es/tree/tree.js +61 -57
- package/es/tree/treeNode.js +1 -6
- package/es/tree-select/interface.d.ts +1 -0
- package/es/tree-select/style/index.css +4 -1
- package/es/tree-select/style/index.less +5 -1
- package/es/tree-select/style/token.less +1 -0
- package/es/tree-select/tree-select.js +18 -4
- package/lib/button/style/token.less +1 -0
- package/lib/checkbox/checkbox.js +4 -4
- package/lib/checkbox/style/index.css +2 -0
- package/lib/checkbox/style/index.less +2 -0
- package/lib/checkbox/style/token.less +1 -1
- package/lib/city-picker/city-picker.d.ts +3 -23
- package/lib/city-picker/city-picker.js +350 -123
- package/lib/city-picker/interface.d.ts +57 -0
- package/lib/city-picker/interface.js +11 -0
- package/lib/city-picker/option.d.ts +4 -0
- package/lib/city-picker/option.js +55 -0
- package/lib/city-picker/style/index.css +264 -239
- package/lib/city-picker/style/index.less +262 -218
- package/lib/city-picker/style/mixin.less +26 -3
- package/lib/city-picker/style/token.less +42 -14
- package/lib/config-provider/compDefaultProps.d.ts +15 -0
- package/lib/config-provider/compDefaultProps.js +16 -1
- package/lib/input/style/token.less +2 -8
- package/lib/select/select.js +25 -15
- package/lib/tree/tree.js +60 -56
- package/lib/tree/treeNode.js +1 -6
- package/lib/tree-select/interface.d.ts +1 -0
- package/lib/tree-select/style/index.css +4 -1
- package/lib/tree-select/style/index.less +5 -1
- package/lib/tree-select/style/token.less +1 -0
- package/lib/tree-select/tree-select.js +20 -6
- package/package.json +1 -1
- package/es/city-picker/city-group.d.ts +0 -8
- package/es/city-picker/city-group.js +0 -38
- package/es/city-picker/city-list.d.ts +0 -12
- package/es/city-picker/city-list.js +0 -55
- package/es/city-picker/city-panel-item.d.ts +0 -13
- package/es/city-picker/city-panel-item.js +0 -22
- package/es/city-picker/city-panel.d.ts +0 -17
- package/es/city-picker/city-panel.js +0 -153
- package/es/city-picker/city-search-panel.d.ts +0 -9
- package/es/city-picker/city-search-panel.js +0 -44
- package/es/city-picker/no-data.d.ts +0 -3
- package/es/city-picker/no-data.js +0 -18
- package/es/city-picker/utils/grouping.d.ts +0 -7
- package/es/city-picker/utils/grouping.js +0 -24
- package/lib/city-picker/city-group.d.ts +0 -8
- package/lib/city-picker/city-group.js +0 -51
- package/lib/city-picker/city-list.d.ts +0 -12
- package/lib/city-picker/city-list.js +0 -68
- package/lib/city-picker/city-panel-item.d.ts +0 -13
- package/lib/city-picker/city-panel-item.js +0 -35
- package/lib/city-picker/city-panel.d.ts +0 -17
- package/lib/city-picker/city-panel.js +0 -166
- package/lib/city-picker/city-search-panel.d.ts +0 -9
- package/lib/city-picker/city-search-panel.js +0 -57
- package/lib/city-picker/no-data.d.ts +0 -3
- package/lib/city-picker/no-data.js +0 -31
- package/lib/city-picker/utils/grouping.d.ts +0 -7
- 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);
|
package/es/checkbox/checkbox.js
CHANGED
|
@@ -11,7 +11,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
11
11
|
}
|
|
12
12
|
return t;
|
|
13
13
|
};
|
|
14
|
-
import 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),
|
|
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),
|
|
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 =
|
|
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
|
-
}
|
|
79
|
+
};
|
|
80
80
|
useEffect(function () {
|
|
81
81
|
isBoolean(checked) && checked !== selected && setSelected(checked);
|
|
82
82
|
}, [checked, selected]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
@checkbox-prefix: '--@{kd-prefix}-c-checkbox';
|
|
4
4
|
|
|
5
|
-
//
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
|
11
|
-
import
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
81
|
+
optionShow = _useState2[0],
|
|
82
|
+
setOptionShow = _useState2[1];
|
|
33
83
|
var _useState3 = useState(''),
|
|
34
84
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
-
|
|
36
|
-
|
|
85
|
+
searchValue = _useState4[0],
|
|
86
|
+
setSearchValue = _useState4[1];
|
|
37
87
|
var _useState5 = useState(false),
|
|
38
88
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
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
|
|
45
|
-
if (
|
|
46
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}, [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
78
|
-
if (
|
|
79
|
-
return;
|
|
223
|
+
var renderNodeList = function renderNodeList(data, notContent) {
|
|
224
|
+
if (!data.length) {
|
|
225
|
+
return renderNotContent(notContent);
|
|
80
226
|
}
|
|
81
|
-
|
|
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
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
89
|
-
|
|
90
|
-
|
|
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
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
CityPicker.SearchPanel = SearchPanel;
|
|
152
|
-
export default CityPicker;
|
|
377
|
+
var Select = /*#__PURE__*/React.forwardRef(InternalSelect);
|
|
378
|
+
Select.displayName = 'CityPicker';
|
|
379
|
+
export default Select;
|