@kdcloudjs/kdesign 1.7.24 → 1.7.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/kdesign-complete.less +13 -11
- package/dist/kdesign.css +14 -11
- package/dist/kdesign.css.map +1 -1
- package/dist/kdesign.js +99 -35
- package/dist/kdesign.js.map +1 -1
- package/dist/kdesign.min.css +3 -3
- package/dist/kdesign.min.js +8 -8
- package/dist/kdesign.min.js.map +1 -1
- package/es/_utils/usePopper.d.ts +1 -0
- package/es/_utils/usePopper.js +4 -2
- package/es/city-picker/city-picker.js +31 -23
- package/es/city-picker/option.js +2 -2
- package/es/city-picker/style/index.css +12 -10
- package/es/city-picker/style/index.less +8 -6
- package/es/city-picker/style/token.less +4 -5
- package/es/input-number/inputNumber.js +15 -3
- package/es/input-number/useSelectionRange.d.ts +4 -0
- package/es/input-number/useSelectionRange.js +22 -0
- package/es/locale/locale.d.ts +4 -4
- package/es/locale/zh-CN.d.ts +4 -2
- package/es/locale/zh-CN.js +4 -2
- package/es/radio/style/index.css +1 -0
- package/es/radio/style/index.less +1 -0
- package/es/select/select.js +3 -3
- package/lib/_utils/usePopper.d.ts +1 -0
- package/lib/_utils/usePopper.js +4 -2
- package/lib/city-picker/city-picker.js +31 -23
- package/lib/city-picker/option.js +2 -2
- package/lib/city-picker/style/index.css +12 -10
- package/lib/city-picker/style/index.less +8 -6
- package/lib/city-picker/style/token.less +4 -5
- package/lib/input-number/inputNumber.js +14 -2
- package/lib/input-number/useSelectionRange.d.ts +4 -0
- package/lib/input-number/useSelectionRange.js +29 -0
- package/lib/locale/locale.d.ts +4 -4
- package/lib/locale/zh-CN.d.ts +4 -2
- package/lib/locale/zh-CN.js +4 -2
- package/lib/radio/style/index.css +1 -0
- package/lib/radio/style/index.less +1 -0
- package/lib/select/select.js +3 -3
- package/package.json +1 -1
package/es/_utils/usePopper.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface PopperProps {
|
|
|
25
25
|
onVisibleChange?: (visible: boolean) => void;
|
|
26
26
|
getTriggerElement?: (locatorNode: HTMLElement) => HTMLElement;
|
|
27
27
|
getPopupContainer?: (locatorNode: HTMLElement) => HTMLElement;
|
|
28
|
+
onTransitionEnd?: (e: React.TransitionEvent) => void;
|
|
28
29
|
}
|
|
29
30
|
declare function usePopper(locatorElement: React.ReactElement, popperElement: React.ReactElement, props: PopperProps): JSX.Element;
|
|
30
31
|
export default usePopper;
|
package/es/_utils/usePopper.js
CHANGED
|
@@ -153,7 +153,8 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
153
153
|
_props$getPopupContai = props.getPopupContainer,
|
|
154
154
|
getPopupContainer = _props$getPopupContai === void 0 ? function () {
|
|
155
155
|
return document.body;
|
|
156
|
-
} : _props$getPopupContai
|
|
156
|
+
} : _props$getPopupContai,
|
|
157
|
+
onTransitionEnd = props.onTransitionEnd;
|
|
157
158
|
var arrowWidth = Math.sqrt(2 * Math.pow(arrowSize, 2));
|
|
158
159
|
var componentName = (prefixCls === null || prefixCls === void 0 ? void 0 : prefixCls.split('-')[1]) || '';
|
|
159
160
|
devWarning(Placements.indexOf(placement) === -1, componentName, _concatInstanceProperty(_context3 = "cannot found ".concat(componentName, " placement '")).call(_context3, placement, "'"));
|
|
@@ -439,7 +440,8 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
439
440
|
className: classNames(prefixCls, popperClassName, nextPlacement, _defineProperty({
|
|
440
441
|
arrow: arrow,
|
|
441
442
|
hidden: !visible
|
|
442
|
-
}, "".concat(nextPlacement, "-active"), active))
|
|
443
|
+
}, "".concat(nextPlacement, "-active"), active)),
|
|
444
|
+
onTransitionEnd: typeof onTransitionEnd === 'function' ? onTransitionEnd : undefined
|
|
443
445
|
};
|
|
444
446
|
var popperNode = popperRef.current;
|
|
445
447
|
var locatorNode = getRealDom(locatorRef, locatorElement);
|
|
@@ -14,20 +14,17 @@ import { Icon, Tabs, Spin } from '../index';
|
|
|
14
14
|
import usePopper from '../_utils/usePopper';
|
|
15
15
|
import Option from './option';
|
|
16
16
|
import escapeRegExp from 'lodash/escapeRegExp';
|
|
17
|
-
var tabsData = [{
|
|
18
|
-
id: 'domestic',
|
|
19
|
-
name: '国内'
|
|
20
|
-
}, {
|
|
21
|
-
id: 'foreign',
|
|
22
|
-
name: '国际/中国港澳台'
|
|
23
|
-
}];
|
|
24
17
|
var InternalSelect = function InternalSelect(props, ref) {
|
|
25
18
|
var _context, _classNames3, _classNames5;
|
|
26
19
|
var _useContext = useContext(ConfigContext),
|
|
27
20
|
getPrefixCls = _useContext.getPrefixCls,
|
|
28
21
|
prefixCls = _useContext.prefixCls,
|
|
29
|
-
userDefaultProps = _useContext.compDefaultProps
|
|
22
|
+
userDefaultProps = _useContext.compDefaultProps,
|
|
23
|
+
locale = _useContext.locale;
|
|
30
24
|
var selectProps = getCompProps('CityPicker', userDefaultProps, props);
|
|
25
|
+
var cityPickerLangMsg = locale.getCompLangMsg({
|
|
26
|
+
componentName: 'CityPicker'
|
|
27
|
+
});
|
|
31
28
|
var type = selectProps.type,
|
|
32
29
|
size = selectProps.size,
|
|
33
30
|
value = selectProps.value,
|
|
@@ -72,6 +69,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
72
69
|
_useMergedState2 = _slicedToArray(_useMergedState, 2),
|
|
73
70
|
initValue = _useMergedState2[0],
|
|
74
71
|
setInitValue = _useMergedState2[1];
|
|
72
|
+
var tabsData = [{
|
|
73
|
+
id: 'domestic',
|
|
74
|
+
name: cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.tabsDomestic
|
|
75
|
+
}, {
|
|
76
|
+
id: 'foreign',
|
|
77
|
+
name: cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.tabsInternation
|
|
78
|
+
}];
|
|
75
79
|
var innerRef = useRef();
|
|
76
80
|
var selectRef = ref || innerRef;
|
|
77
81
|
var searchRef = useRef(null); // 搜索框ref
|
|
@@ -121,11 +125,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
121
125
|
setOptionShow(props.visible);
|
|
122
126
|
}
|
|
123
127
|
}, [props.visible]);
|
|
124
|
-
useEffect(function () {
|
|
125
|
-
if (optionShow === false) {
|
|
126
|
-
handleClear();
|
|
127
|
-
}
|
|
128
|
-
}, [optionShow]);
|
|
129
128
|
var handleFocus = useCallback(function (e) {
|
|
130
129
|
e.stopPropagation();
|
|
131
130
|
setFocusd(true);
|
|
@@ -222,6 +221,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
222
221
|
}
|
|
223
222
|
};
|
|
224
223
|
var renderNodeList = function renderNodeList(data, notContent) {
|
|
224
|
+
var isCommon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
225
225
|
if (!data.length) {
|
|
226
226
|
return renderNotContent(notContent);
|
|
227
227
|
}
|
|
@@ -232,7 +232,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
232
232
|
key: item.id,
|
|
233
233
|
value: initValue,
|
|
234
234
|
city: item,
|
|
235
|
-
renderCityInfo: renderCityInfo,
|
|
235
|
+
renderCityInfo: function renderCityInfo(data, flag) {
|
|
236
|
+
return _renderCityInfo(data, isCommon, flag);
|
|
237
|
+
},
|
|
236
238
|
onChangeSelect: handleOption,
|
|
237
239
|
itemRender: itemRender
|
|
238
240
|
}, 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);
|
|
@@ -260,21 +262,22 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
260
262
|
key: item.id,
|
|
261
263
|
tab: item.name
|
|
262
264
|
}, item);
|
|
263
|
-
})), tabsValue === 'domestic' ? renderNodeList(domesticList,
|
|
265
|
+
})), tabsValue === 'domestic' ? renderNodeList(domesticList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText) : renderNodeList(foreignList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText)) : /*#__PURE__*/React.createElement(React.Fragment, null, !!commonList.length && /*#__PURE__*/React.createElement("div", {
|
|
264
266
|
className: "".concat(selectPrefixCls, "-dropdown-common")
|
|
265
|
-
},
|
|
267
|
+
}, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.common), renderNodeList(commonList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.commonEmptyText, true)));
|
|
266
268
|
};
|
|
267
|
-
var
|
|
268
|
-
var
|
|
269
|
-
var
|
|
269
|
+
var _renderCityInfo = useCallback(function (data) {
|
|
270
|
+
var isCommon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
271
|
+
var flag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
272
|
+
var symbol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
|
|
270
273
|
if (!data) return null;
|
|
271
274
|
if (isDomestic(type)) {
|
|
272
275
|
var _context3;
|
|
273
|
-
var curVal = tabsValue === 'domestic' ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
|
|
276
|
+
var curVal = tabsValue === 'domestic' || isCommon ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
|
|
274
277
|
return _concatInstanceProperty(_context3 = "".concat(flag && curVal ? symbol : '')).call(_context3, curVal);
|
|
275
278
|
} else {
|
|
276
279
|
var _context4, _context5, _context6;
|
|
277
|
-
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);
|
|
280
|
+
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) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context4, data === null || data === void 0 ? void 0 : data.country);
|
|
278
281
|
}
|
|
279
282
|
}, [type, tabsValue]);
|
|
280
283
|
var renderSingle = function renderSingle() {
|
|
@@ -301,7 +304,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
301
304
|
title: seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name
|
|
302
305
|
}, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue && /*#__PURE__*/React.createElement("span", {
|
|
303
306
|
className: "".concat(selectPrefixCls, "-content-info")
|
|
304
|
-
},
|
|
307
|
+
}, _renderCityInfo(seletedCity))), /*#__PURE__*/React.createElement("span", {
|
|
305
308
|
className: "".concat(selectPrefixCls, "-placeholder"),
|
|
306
309
|
style: hiddenStyle
|
|
307
310
|
}, placeholder), /*#__PURE__*/React.createElement("span", {
|
|
@@ -373,7 +376,12 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
373
376
|
defaultVisible: optionShow,
|
|
374
377
|
visible: optionShow,
|
|
375
378
|
onVisibleChange: handleVisibleChange,
|
|
376
|
-
clickToClose: !searchValue
|
|
379
|
+
clickToClose: !searchValue,
|
|
380
|
+
onTransitionEnd: function onTransitionEnd() {
|
|
381
|
+
if (optionShow === false) {
|
|
382
|
+
handleClear();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
377
385
|
});
|
|
378
386
|
return usePopper(renderCityPicker(), renderContent(), popperProps);
|
|
379
387
|
};
|
package/es/city-picker/option.js
CHANGED
|
@@ -31,9 +31,9 @@ var InternalOption = function InternalOption(props, ref) {
|
|
|
31
31
|
className: optionCls,
|
|
32
32
|
title: name,
|
|
33
33
|
onClick: handleClick
|
|
34
|
-
}, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("
|
|
34
|
+
}, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
35
35
|
className: "".concat(selectOptionPrefixCls, "-content")
|
|
36
|
-
}, children), /*#__PURE__*/React.createElement("
|
|
36
|
+
}, children), /*#__PURE__*/React.createElement("span", {
|
|
37
37
|
className: "".concat(selectOptionPrefixCls, "-info")
|
|
38
38
|
}, renderCityInfo === null || renderCityInfo === void 0 ? void 0 : renderCityInfo(city, true)))));
|
|
39
39
|
};
|
|
@@ -264,6 +264,12 @@
|
|
|
264
264
|
padding: 0 12px;
|
|
265
265
|
font-size: 12px;
|
|
266
266
|
}
|
|
267
|
+
.kd-city-picker-dropdown .kd-tabs-tab-list .kd-tab-pane-type-line .kd-tab-pane-text {
|
|
268
|
+
overflow: hidden;
|
|
269
|
+
white-space: nowrap;
|
|
270
|
+
text-overflow: ellipsis;
|
|
271
|
+
width: 100%;
|
|
272
|
+
}
|
|
267
273
|
.kd-city-picker-dropdown .kd-tabs-noContainer {
|
|
268
274
|
height: unset;
|
|
269
275
|
}
|
|
@@ -311,6 +317,9 @@
|
|
|
311
317
|
box-sizing: content-box;
|
|
312
318
|
}
|
|
313
319
|
.kd-city-picker-list-item {
|
|
320
|
+
overflow: hidden;
|
|
321
|
+
white-space: nowrap;
|
|
322
|
+
text-overflow: ellipsis;
|
|
314
323
|
position: relative;
|
|
315
324
|
display: block;
|
|
316
325
|
font-weight: normal;
|
|
@@ -319,16 +328,8 @@
|
|
|
319
328
|
padding: 5px 12px;
|
|
320
329
|
color: var(--kd-c-city-picker-footer-color-text, var(--kd-g-color-text-primary, #212121));
|
|
321
330
|
line-height: var(--kd-c-city-picker-dropdown-line-height, 22px);
|
|
322
|
-
display: -webkit-box;
|
|
323
|
-
display: -ms-flexbox;
|
|
324
|
-
display: flex;
|
|
325
331
|
cursor: pointer;
|
|
326
332
|
}
|
|
327
|
-
.kd-city-picker-list-item-content {
|
|
328
|
-
overflow: hidden;
|
|
329
|
-
white-space: nowrap;
|
|
330
|
-
text-overflow: ellipsis;
|
|
331
|
-
}
|
|
332
333
|
.kd-city-picker-list-item-info {
|
|
333
334
|
color: var(--kd-c-city-picker-placeholder-color-text, #b2b2b2);
|
|
334
335
|
white-space: nowrap;
|
|
@@ -337,7 +338,8 @@
|
|
|
337
338
|
background-color: var(--kd-c-city-picker-color-background, #f5f5f5);
|
|
338
339
|
}
|
|
339
340
|
.kd-city-picker-list-item-selected:not(.kd-city-picker-list-item-disabled) {
|
|
340
|
-
background-color: var(--kd-c-city-picker-color-background-selected, #
|
|
341
|
+
background-color: var(--kd-c-city-picker-color-background-selected, var(--kd-g-color-theme-3, #e3eeff));
|
|
342
|
+
color: var(--kd-c-city-picker-list-item-color-text-selected, var(--kd-g-color-theme, #5582f3));
|
|
341
343
|
}
|
|
342
344
|
.kd-city-picker-list-item-disabled {
|
|
343
345
|
color: var(--kd-c-city-picker-item-color-text-disabled, var(--kd-g-color-disabled, #b2b2b2));
|
|
@@ -345,7 +347,7 @@
|
|
|
345
347
|
background-color: var(--kd-c-city-picker-item-color-background-disabled, #fff);
|
|
346
348
|
}
|
|
347
349
|
.kd-city-picker-highlight {
|
|
348
|
-
color: #5582f3;
|
|
350
|
+
color: var(--kd-c-city-picker-highlight-color-text, var(--kd-g-color-theme, #5582f3));
|
|
349
351
|
}
|
|
350
352
|
.kd-city-picker-size-small {
|
|
351
353
|
min-height: var(--kd-c-city-picker-sizing-height-small, 24px);
|
|
@@ -159,6 +159,11 @@
|
|
|
159
159
|
&-type-line {
|
|
160
160
|
padding: 0 12px;
|
|
161
161
|
font-size: 12px;
|
|
162
|
+
|
|
163
|
+
.@{kd-prefix}-tab-pane-text {
|
|
164
|
+
.over();
|
|
165
|
+
width: 100%;
|
|
166
|
+
}
|
|
162
167
|
}
|
|
163
168
|
}
|
|
164
169
|
}
|
|
@@ -204,14 +209,10 @@
|
|
|
204
209
|
|
|
205
210
|
// 下拉列表选项
|
|
206
211
|
&-item {
|
|
212
|
+
.over();
|
|
207
213
|
.item();
|
|
208
|
-
display: flex;
|
|
209
214
|
cursor: pointer;
|
|
210
215
|
|
|
211
|
-
&-content {
|
|
212
|
-
.over();
|
|
213
|
-
}
|
|
214
|
-
|
|
215
216
|
&-info {
|
|
216
217
|
color: @city-picker-placeholder-color;
|
|
217
218
|
white-space: nowrap;
|
|
@@ -223,6 +224,7 @@
|
|
|
223
224
|
|
|
224
225
|
&-selected:not(&-disabled) {
|
|
225
226
|
background-color: @city-picker-item-selected-bg;
|
|
227
|
+
color: @city-picker-list-item-color-selected;
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
&-disabled {
|
|
@@ -234,7 +236,7 @@
|
|
|
234
236
|
}
|
|
235
237
|
|
|
236
238
|
&-highlight {
|
|
237
|
-
color:
|
|
239
|
+
color: @city-picker-highlight-color;
|
|
238
240
|
}
|
|
239
241
|
|
|
240
242
|
// 选择器框大小
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
@city-picker-dropdown-bg: var(~'@{city-picker-custom-prefix}-dropdown-color-background', @color-background);
|
|
7
7
|
@city-picker-disabled-option-bg: var(~'@{city-picker-custom-prefix}-item-color-background-disabled', #fff);
|
|
8
8
|
@city-picker-item-active-bg: var(~'@{city-picker-custom-prefix}-color-background', #f5f5f5);
|
|
9
|
-
@city-picker-item-selected-bg: var(~'@{city-picker-custom-prefix}-color-background-selected',
|
|
9
|
+
@city-picker-item-selected-bg: var(~'@{city-picker-custom-prefix}-color-background-selected', @color-theme-3);
|
|
10
10
|
@city-picker-g-color-border: var(~'@{city-picker-custom-prefix}-color-border', @color-input);
|
|
11
11
|
@city-picker-g-color-border-foucs: var(~'@{city-picker-custom-prefix}-color-border-foucs', @color-theme);
|
|
12
12
|
@city-picker-g-color-border-hover: var(~'@{city-picker-custom-prefix}-color-border-hover', @color-theme);
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
@city-picker-g-item-text-color-disabled: var(~'@{city-picker-custom-prefix}-item-color-text-disabled', @color-disabled);
|
|
17
17
|
@city-picker-color-background-disabled: var(~'@{city-picker-custom-prefix}-color-background-disabled', #fff);
|
|
18
18
|
@city-picker-color-text-disabled: var(~'@{city-picker-custom-prefix}-color-text-disabled', @color-disabled);
|
|
19
|
-
@city-picker-arrow-icon-color-text-disabled: var(
|
|
20
|
-
~'@{city-picker-custom-prefix}-arrow-icon-color-text-disabled',
|
|
21
|
-
#b2b2b2
|
|
22
|
-
);
|
|
19
|
+
@city-picker-arrow-icon-color-text-disabled: var(~'@{city-picker-custom-prefix}-arrow-icon-color-text-disabled', #b2b2b2);
|
|
23
20
|
@city-picker-clear-color: var(~'@{city-picker-custom-prefix}-icon-clear-color-text', #d9d9d9);
|
|
24
21
|
@city-picker-clear-color-hover: var(~'@{city-picker-custom-prefix}-icon-clear-color-text-hover', #999);
|
|
22
|
+
@city-picker-list-item-color-selected: var(~'@{city-picker-custom-prefix}-list-item-color-text-selected', @color-theme);
|
|
23
|
+
@city-picker-highlight-color: var(~'@{city-picker-custom-prefix}-highlight-color-text', @color-theme);
|
|
25
24
|
|
|
26
25
|
// font
|
|
27
26
|
@city-picker-list-font-size: var(~'@{city-picker-custom-prefix}-dropdown-font-size', 12px); // 下拉列表文字大小
|
|
@@ -11,7 +11,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
11
11
|
}
|
|
12
12
|
return t;
|
|
13
13
|
};
|
|
14
|
-
import React, { useContext, useState, useEffect, useRef, useCallback, useImperativeHandle } from 'react';
|
|
14
|
+
import React, { useContext, useState, useEffect, useRef, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
15
15
|
import Input from '../input';
|
|
16
16
|
import ConfigContext from '../config-provider/ConfigContext';
|
|
17
17
|
import { getCompProps } from '../_utils';
|
|
@@ -20,7 +20,9 @@ import { formatEditNumber, formatNumber } from '../_utils/formatUtil';
|
|
|
20
20
|
import devWarning from '../_utils/devwarning';
|
|
21
21
|
import Big from 'big.js';
|
|
22
22
|
import classNames from 'classnames';
|
|
23
|
+
import useSelectionRange from './useSelectionRange';
|
|
23
24
|
var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
25
|
+
var _a;
|
|
24
26
|
var _useContext = useContext(ConfigContext),
|
|
25
27
|
userDefaultProps = _useContext.compDefaultProps,
|
|
26
28
|
getPrefixCls = _useContext.getPrefixCls,
|
|
@@ -110,6 +112,7 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
110
112
|
if (legalNumber === false) {
|
|
111
113
|
return false;
|
|
112
114
|
}
|
|
115
|
+
updateSelectionRangePosition(event);
|
|
113
116
|
value === undefined && setInputValue(legalNumber);
|
|
114
117
|
onChange && onChange(handleEventAttachValue(event, numberMode ? Number(legalNumber) : legalNumber));
|
|
115
118
|
};
|
|
@@ -225,10 +228,12 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
225
228
|
// 还原最小值
|
|
226
229
|
if (typeof min === 'number' && bigValue.lt(min)) {
|
|
227
230
|
_inputValue = min.toString();
|
|
231
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(handleEventAttachValue(event, numberMode ? Number(_inputValue) : _inputValue));
|
|
228
232
|
}
|
|
229
233
|
// 还原最大值
|
|
230
|
-
if (typeof
|
|
234
|
+
if (typeof max === 'number' && bigValue.gt(max)) {
|
|
231
235
|
_inputValue = max.toString();
|
|
236
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(handleEventAttachValue(event, numberMode ? Number(_inputValue) : _inputValue));
|
|
232
237
|
}
|
|
233
238
|
// 超过精度位数直接截断
|
|
234
239
|
_inputValue = handleNumericalAccuracy(_inputValue);
|
|
@@ -300,9 +305,16 @@ var InternalInputNumber = function InternalInputNumber(props, ref) {
|
|
|
300
305
|
}
|
|
301
306
|
};
|
|
302
307
|
});
|
|
308
|
+
var displayedInputValue = useMemo(function () {
|
|
309
|
+
return formatter ? formatter(inputValue) : inputValue;
|
|
310
|
+
}, [inputValue, formatter]);
|
|
311
|
+
var updateSelectionRangePosition = useSelectionRange({
|
|
312
|
+
inputElement: (_a = inputNumberRef.current) === null || _a === void 0 ? void 0 : _a.input,
|
|
313
|
+
inputValue: displayedInputValue
|
|
314
|
+
});
|
|
303
315
|
return /*#__PURE__*/React.createElement(Input, _extends({}, others, {
|
|
304
316
|
ref: inputNumberRef,
|
|
305
|
-
value:
|
|
317
|
+
value: displayedInputValue,
|
|
306
318
|
prefix: prefix,
|
|
307
319
|
suffix: suffix,
|
|
308
320
|
onChange: handleChange,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useRef, useLayoutEffect } from 'react';
|
|
2
|
+
import isNumber from 'lodash/isNumber';
|
|
3
|
+
export default function useSelectionRange(_ref) {
|
|
4
|
+
var inputElement = _ref.inputElement,
|
|
5
|
+
inputValue = _ref.inputValue;
|
|
6
|
+
var refSelectionPosition = useRef();
|
|
7
|
+
useLayoutEffect(function () {
|
|
8
|
+
var position = refSelectionPosition.current;
|
|
9
|
+
if (inputElement && inputValue && isNumber(position)) {
|
|
10
|
+
var start = Math.max(0, inputValue.length - position);
|
|
11
|
+
inputElement.setSelectionRange(start, start);
|
|
12
|
+
}
|
|
13
|
+
}, [inputValue]);
|
|
14
|
+
return function (event) {
|
|
15
|
+
var _event$target = event.target,
|
|
16
|
+
end = _event$target.selectionEnd,
|
|
17
|
+
value = _event$target.value;
|
|
18
|
+
if (isNumber(end)) {
|
|
19
|
+
refSelectionPosition.current = value.length - end;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
package/es/locale/locale.d.ts
CHANGED
|
@@ -61,11 +61,11 @@ declare class LocaleCache {
|
|
|
61
61
|
'QuickSearch.emptyTip': string;
|
|
62
62
|
'QuickSearch.or': string;
|
|
63
63
|
'CityPicker.domestic': string;
|
|
64
|
-
'CityPicker.internation': string;
|
|
65
64
|
'CityPicker.common': string;
|
|
66
|
-
'CityPicker.
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
'CityPicker.emptyText': string;
|
|
66
|
+
'CityPicker.commonEmptyText': string;
|
|
67
|
+
'CityPicker.tabsDomestic': string;
|
|
68
|
+
'CityPicker.tabsInternation': string;
|
|
69
69
|
'ColorPicker.followFunctionalColor': string;
|
|
70
70
|
'Search.placeholder': string;
|
|
71
71
|
'Search.desc': string[];
|
package/es/locale/zh-CN.d.ts
CHANGED
|
@@ -35,9 +35,11 @@ declare const locale: {
|
|
|
35
35
|
'QuickSearch.emptyTip': string;
|
|
36
36
|
'QuickSearch.or': string;
|
|
37
37
|
'CityPicker.domestic': string;
|
|
38
|
-
'CityPicker.internation': string;
|
|
39
38
|
'CityPicker.common': string;
|
|
40
|
-
'CityPicker.
|
|
39
|
+
'CityPicker.emptyText': string;
|
|
40
|
+
'CityPicker.commonEmptyText': string;
|
|
41
|
+
'CityPicker.tabsDomestic': string;
|
|
42
|
+
'CityPicker.tabsInternation': string;
|
|
41
43
|
'ColorPicker.followFunctionalColor': string;
|
|
42
44
|
'Search.placeholder': string;
|
|
43
45
|
'Search.desc': string[];
|
package/es/locale/zh-CN.js
CHANGED
|
@@ -39,9 +39,11 @@ var locale = _extends(_extends({
|
|
|
39
39
|
'QuickSearch.emptyTip': '暂无数据',
|
|
40
40
|
'QuickSearch.or': '或',
|
|
41
41
|
'CityPicker.domestic': '国内',
|
|
42
|
-
'CityPicker.internation': '国际',
|
|
43
42
|
'CityPicker.common': '常用',
|
|
44
|
-
'CityPicker.
|
|
43
|
+
'CityPicker.emptyText': '暂无数据',
|
|
44
|
+
'CityPicker.commonEmptyText': '无常用城市',
|
|
45
|
+
'CityPicker.tabsDomestic': '国内',
|
|
46
|
+
'CityPicker.tabsInternation': '国际/中国港澳台',
|
|
45
47
|
'ColorPicker.followFunctionalColor': '跟随功能色',
|
|
46
48
|
'Search.placeholder': '请输入需要搜索的内容',
|
|
47
49
|
'Search.desc': ['空格代表"或",回车代表"且"'],
|
package/es/radio/style/index.css
CHANGED
package/es/select/select.js
CHANGED
|
@@ -766,7 +766,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
766
766
|
// open
|
|
767
767
|
if (which === KeyCode.ENTER || which === KeyCode.UP || which === KeyCode.DOWN) {
|
|
768
768
|
e.preventDefault();
|
|
769
|
-
|
|
769
|
+
handleVisibleChange(true);
|
|
770
770
|
}
|
|
771
771
|
// backspace
|
|
772
772
|
var _multipleRef$current5 = multipleRef.current,
|
|
@@ -810,10 +810,10 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
810
810
|
}));
|
|
811
811
|
}
|
|
812
812
|
if (!isMultiple) {
|
|
813
|
-
|
|
813
|
+
handleVisibleChange(false);
|
|
814
814
|
}
|
|
815
815
|
} else if (which === KeyCode.ESC) {
|
|
816
|
-
|
|
816
|
+
handleVisibleChange(false);
|
|
817
817
|
}
|
|
818
818
|
if (offset !== 0) {
|
|
819
819
|
var nextActiveIndex = getActiveIndex(activeIndex + offset, offset);
|
|
@@ -25,6 +25,7 @@ export interface PopperProps {
|
|
|
25
25
|
onVisibleChange?: (visible: boolean) => void;
|
|
26
26
|
getTriggerElement?: (locatorNode: HTMLElement) => HTMLElement;
|
|
27
27
|
getPopupContainer?: (locatorNode: HTMLElement) => HTMLElement;
|
|
28
|
+
onTransitionEnd?: (e: React.TransitionEvent) => void;
|
|
28
29
|
}
|
|
29
30
|
declare function usePopper(locatorElement: React.ReactElement, popperElement: React.ReactElement, props: PopperProps): JSX.Element;
|
|
30
31
|
export default usePopper;
|
package/lib/_utils/usePopper.js
CHANGED
|
@@ -167,7 +167,8 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
167
167
|
_props$getPopupContai = props.getPopupContainer,
|
|
168
168
|
getPopupContainer = _props$getPopupContai === void 0 ? function () {
|
|
169
169
|
return document.body;
|
|
170
|
-
} : _props$getPopupContai
|
|
170
|
+
} : _props$getPopupContai,
|
|
171
|
+
onTransitionEnd = props.onTransitionEnd;
|
|
171
172
|
var arrowWidth = Math.sqrt(2 * Math.pow(arrowSize, 2));
|
|
172
173
|
var componentName = (prefixCls === null || prefixCls === void 0 ? void 0 : prefixCls.split('-')[1]) || '';
|
|
173
174
|
(0, _devwarning.default)(Placements.indexOf(placement) === -1, componentName, (0, _concat.default)(_context3 = "cannot found ".concat(componentName, " placement '")).call(_context3, placement, "'"));
|
|
@@ -453,7 +454,8 @@ function usePopper(locatorElement, popperElement, props) {
|
|
|
453
454
|
className: (0, _classnames.default)(prefixCls, popperClassName, nextPlacement, (0, _defineProperty2.default)({
|
|
454
455
|
arrow: arrow,
|
|
455
456
|
hidden: !visible
|
|
456
|
-
}, "".concat(nextPlacement, "-active"), active))
|
|
457
|
+
}, "".concat(nextPlacement, "-active"), active)),
|
|
458
|
+
onTransitionEnd: typeof onTransitionEnd === 'function' ? onTransitionEnd : undefined
|
|
457
459
|
};
|
|
458
460
|
var popperNode = popperRef.current;
|
|
459
461
|
var locatorNode = getRealDom(locatorRef, locatorElement);
|
|
@@ -26,20 +26,17 @@ var _option = _interopRequireDefault(require("./option"));
|
|
|
26
26
|
var _escapeRegExp = _interopRequireDefault(require("lodash/escapeRegExp"));
|
|
27
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
var tabsData = [{
|
|
30
|
-
id: 'domestic',
|
|
31
|
-
name: '国内'
|
|
32
|
-
}, {
|
|
33
|
-
id: 'foreign',
|
|
34
|
-
name: '国际/中国港澳台'
|
|
35
|
-
}];
|
|
36
29
|
var InternalSelect = function InternalSelect(props, ref) {
|
|
37
30
|
var _context, _classNames3, _classNames5;
|
|
38
31
|
var _useContext = (0, _react.useContext)(_ConfigContext.default),
|
|
39
32
|
getPrefixCls = _useContext.getPrefixCls,
|
|
40
33
|
prefixCls = _useContext.prefixCls,
|
|
41
|
-
userDefaultProps = _useContext.compDefaultProps
|
|
34
|
+
userDefaultProps = _useContext.compDefaultProps,
|
|
35
|
+
locale = _useContext.locale;
|
|
42
36
|
var selectProps = (0, _utils.getCompProps)('CityPicker', userDefaultProps, props);
|
|
37
|
+
var cityPickerLangMsg = locale.getCompLangMsg({
|
|
38
|
+
componentName: 'CityPicker'
|
|
39
|
+
});
|
|
43
40
|
var type = selectProps.type,
|
|
44
41
|
size = selectProps.size,
|
|
45
42
|
value = selectProps.value,
|
|
@@ -84,6 +81,13 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
84
81
|
_useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
|
|
85
82
|
initValue = _useMergedState2[0],
|
|
86
83
|
setInitValue = _useMergedState2[1];
|
|
84
|
+
var tabsData = [{
|
|
85
|
+
id: 'domestic',
|
|
86
|
+
name: cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.tabsDomestic
|
|
87
|
+
}, {
|
|
88
|
+
id: 'foreign',
|
|
89
|
+
name: cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.tabsInternation
|
|
90
|
+
}];
|
|
87
91
|
var innerRef = (0, _react.useRef)();
|
|
88
92
|
var selectRef = ref || innerRef;
|
|
89
93
|
var searchRef = (0, _react.useRef)(null); // 搜索框ref
|
|
@@ -133,11 +137,6 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
133
137
|
setOptionShow(props.visible);
|
|
134
138
|
}
|
|
135
139
|
}, [props.visible]);
|
|
136
|
-
(0, _react.useEffect)(function () {
|
|
137
|
-
if (optionShow === false) {
|
|
138
|
-
handleClear();
|
|
139
|
-
}
|
|
140
|
-
}, [optionShow]);
|
|
141
140
|
var handleFocus = (0, _react.useCallback)(function (e) {
|
|
142
141
|
e.stopPropagation();
|
|
143
142
|
setFocusd(true);
|
|
@@ -234,6 +233,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
234
233
|
}
|
|
235
234
|
};
|
|
236
235
|
var renderNodeList = function renderNodeList(data, notContent) {
|
|
236
|
+
var isCommon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
237
237
|
if (!data.length) {
|
|
238
238
|
return renderNotContent(notContent);
|
|
239
239
|
}
|
|
@@ -244,7 +244,9 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
244
244
|
key: item.id,
|
|
245
245
|
value: initValue,
|
|
246
246
|
city: item,
|
|
247
|
-
renderCityInfo: renderCityInfo,
|
|
247
|
+
renderCityInfo: function renderCityInfo(data, flag) {
|
|
248
|
+
return _renderCityInfo(data, isCommon, flag);
|
|
249
|
+
},
|
|
248
250
|
onChangeSelect: handleOption,
|
|
249
251
|
itemRender: itemRender
|
|
250
252
|
}, searchValue ? getHighlightText(item === null || item === void 0 ? void 0 : item.name, (item === null || item === void 0 ? void 0 : item[optionHighlightProps]) || searchValue) : item === null || item === void 0 ? void 0 : item.name);
|
|
@@ -272,21 +274,22 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
272
274
|
key: item.id,
|
|
273
275
|
tab: item.name
|
|
274
276
|
}, item);
|
|
275
|
-
})), tabsValue === 'domestic' ? renderNodeList(domesticList,
|
|
277
|
+
})), tabsValue === 'domestic' ? renderNodeList(domesticList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText) : renderNodeList(foreignList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.emptyText)) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !!commonList.length && /*#__PURE__*/_react.default.createElement("div", {
|
|
276
278
|
className: "".concat(selectPrefixCls, "-dropdown-common")
|
|
277
|
-
},
|
|
279
|
+
}, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.common), renderNodeList(commonList, cityPickerLangMsg === null || cityPickerLangMsg === void 0 ? void 0 : cityPickerLangMsg.commonEmptyText, true)));
|
|
278
280
|
};
|
|
279
|
-
var
|
|
280
|
-
var
|
|
281
|
-
var
|
|
281
|
+
var _renderCityInfo = (0, _react.useCallback)(function (data) {
|
|
282
|
+
var isCommon = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
283
|
+
var flag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
284
|
+
var symbol = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', ';
|
|
282
285
|
if (!data) return null;
|
|
283
286
|
if (isDomestic(type)) {
|
|
284
287
|
var _context3;
|
|
285
|
-
var curVal = tabsValue === 'domestic' ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
|
|
288
|
+
var curVal = tabsValue === 'domestic' || isCommon ? data === null || data === void 0 ? void 0 : data.province : data === null || data === void 0 ? void 0 : data.country;
|
|
286
289
|
return (0, _concat.default)(_context3 = "".concat(flag && curVal ? symbol : '')).call(_context3, curVal);
|
|
287
290
|
} else {
|
|
288
291
|
var _context4, _context5, _context6;
|
|
289
|
-
return (0, _concat.default)(_context4 = (0, _concat.default)(_context5 = (0, _concat.default)(_context6 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.province)).call(_context5, (data === null || data === void 0 ? void 0 : data.country) ? symbol : '')).call(_context4, data === null || data === void 0 ? void 0 : data.country);
|
|
292
|
+
return (0, _concat.default)(_context4 = (0, _concat.default)(_context5 = (0, _concat.default)(_context6 = "".concat(flag && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context6, data === null || data === void 0 ? void 0 : data.province)).call(_context5, (data === null || data === void 0 ? void 0 : data.country) && (data === null || data === void 0 ? void 0 : data.province) ? symbol : '')).call(_context4, data === null || data === void 0 ? void 0 : data.country);
|
|
290
293
|
}
|
|
291
294
|
}, [type, tabsValue]);
|
|
292
295
|
var renderSingle = function renderSingle() {
|
|
@@ -313,7 +316,7 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
313
316
|
title: seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name
|
|
314
317
|
}, seletedCity === null || seletedCity === void 0 ? void 0 : seletedCity.name)), !searchValue && /*#__PURE__*/_react.default.createElement("span", {
|
|
315
318
|
className: "".concat(selectPrefixCls, "-content-info")
|
|
316
|
-
},
|
|
319
|
+
}, _renderCityInfo(seletedCity))), /*#__PURE__*/_react.default.createElement("span", {
|
|
317
320
|
className: "".concat(selectPrefixCls, "-placeholder"),
|
|
318
321
|
style: hiddenStyle
|
|
319
322
|
}, placeholder), /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -385,7 +388,12 @@ var InternalSelect = function InternalSelect(props, ref) {
|
|
|
385
388
|
defaultVisible: optionShow,
|
|
386
389
|
visible: optionShow,
|
|
387
390
|
onVisibleChange: handleVisibleChange,
|
|
388
|
-
clickToClose: !searchValue
|
|
391
|
+
clickToClose: !searchValue,
|
|
392
|
+
onTransitionEnd: function onTransitionEnd() {
|
|
393
|
+
if (optionShow === false) {
|
|
394
|
+
handleClear();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
389
397
|
});
|
|
390
398
|
return (0, _usePopper.default)(renderCityPicker(), renderContent(), popperProps);
|
|
391
399
|
};
|
|
@@ -43,9 +43,9 @@ var InternalOption = function InternalOption(props, ref) {
|
|
|
43
43
|
className: optionCls,
|
|
44
44
|
title: name,
|
|
45
45
|
onClick: handleClick
|
|
46
|
-
}, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("
|
|
46
|
+
}, typeof itemRender === 'function' ? itemRender(city) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("span", {
|
|
47
47
|
className: "".concat(selectOptionPrefixCls, "-content")
|
|
48
|
-
}, children), /*#__PURE__*/_react.default.createElement("
|
|
48
|
+
}, children), /*#__PURE__*/_react.default.createElement("span", {
|
|
49
49
|
className: "".concat(selectOptionPrefixCls, "-info")
|
|
50
50
|
}, renderCityInfo === null || renderCityInfo === void 0 ? void 0 : renderCityInfo(city, true)))));
|
|
51
51
|
};
|