@kdcloudjs/kdesign 1.8.14 → 1.8.15

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.
@@ -6,13 +6,14 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
6
6
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
7
7
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
8
8
  import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
9
+ import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
9
10
  import React, { useContext, useRef, useEffect, useState, useCallback, useMemo } from 'react';
10
11
  import { useMergedState } from '../_utils/hooks';
11
12
  import classNames from 'classnames';
12
13
  import ConfigContext from '../config-provider/ConfigContext';
13
14
  import { getCompProps } from '../_utils';
14
15
  import { Icon, Tabs, Spin } from '../index';
15
- import usePopper from '../_utils/usePopper';
16
+ import Popper from '../popper';
16
17
  import Option from './option';
17
18
  import escapeRegExp from 'lodash/escapeRegExp';
18
19
  import KeyCode from '../_utils/KeyCode';
@@ -152,15 +153,6 @@ var InternalSelect = function InternalSelect(props, ref) {
152
153
  setAfterChangeFocus(false);
153
154
  onBlur && onBlur(e);
154
155
  }, [onBlur]);
155
- useEffect(function () {
156
- selectionRef.current.addEventListener('mouseup', function (e) {
157
- var _a;
158
- 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;
159
- if (isCloseBtn) {
160
- e.stopPropagation();
161
- }
162
- });
163
- }, []);
164
156
  var handleSearchChange = useCallback(function (event) {
165
157
  var val = event.currentTarget.value;
166
158
  setOptionShow(true);
@@ -359,14 +351,7 @@ var InternalSelect = function InternalSelect(props, ref) {
359
351
  }, [optionShow]);
360
352
  useEffect(function () {
361
353
  var _a;
362
- var fn = function fn(e) {
363
- e.stopPropagation();
364
- };
365
- (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseup', fn);
366
- return function () {
367
- var _a;
368
- (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
369
- };
354
+ (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', handleReset);
370
355
  }, [initValue]);
371
356
  var curkeyboardList = useMemo(function () {
372
357
  if (!searchValue) {
@@ -395,14 +380,16 @@ var InternalSelect = function InternalSelect(props, ref) {
395
380
  setActiveIndex(index === undefined ? getActiveIndex(0) : index);
396
381
  };
397
382
  useEffect(function () {
398
- initActiveIndex(searchValue ? undefined : -1);
399
- }, [searchValue, tabsValue, curkeyboardList]);
383
+ var index = _findIndexInstanceProperty(curkeyboardList).call(curkeyboardList, function (item) {
384
+ return item.id === initValue;
385
+ });
386
+ initActiveIndex(index >= 0 ? index : undefined);
387
+ }, [curkeyboardList, initValue]);
400
388
  var onInternalKeyDown = function onInternalKeyDown(e) {
401
389
  var _a, _b, _c;
402
390
  var which = e.which;
403
391
  if (which === KeyCode.ENTER || which === KeyCode.UP || which === KeyCode.DOWN) {
404
392
  e.preventDefault();
405
- setOptionShow(true);
406
393
  }
407
394
  if (optionShow) {
408
395
  var offset = 0;
@@ -467,15 +454,11 @@ var InternalSelect = function InternalSelect(props, ref) {
467
454
  minWidth: width,
468
455
  maxWidth: 600
469
456
  }, dropdownStyle), {
470
- width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto',
471
- zIndex: 1050
457
+ width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto'
472
458
  }), popperStyle);
473
459
  }
474
460
  };
475
461
  var handleVisibleChange = function handleVisibleChange(visible) {
476
- if (!visible) {
477
- initActiveIndex(-1);
478
- }
479
462
  if (visible !== optionShow) {
480
463
  props.visible === undefined && setOptionShow(visible);
481
464
  onVisibleChange && onVisibleChange(visible);
@@ -488,14 +471,15 @@ var InternalSelect = function InternalSelect(props, ref) {
488
471
  defaultVisible: optionShow,
489
472
  visible: optionShow,
490
473
  onVisibleChange: handleVisibleChange,
491
- clickToClose: !searchValue,
492
474
  onTransitionEnd: function onTransitionEnd() {
493
475
  if (optionShow === false) {
494
476
  handleClear();
495
477
  }
496
478
  }
497
479
  });
498
- return usePopper(renderCityPicker(), renderContent(), popperProps);
480
+ return React.createElement(Popper, _extends({
481
+ tip: renderContent()
482
+ }, popperProps), renderCityPicker());
499
483
  };
500
484
  var Select = React.forwardRef(InternalSelect);
501
485
  Select.displayName = 'CityPicker';
@@ -33,16 +33,12 @@ var InternalOption = function InternalOption(props, ref) {
33
33
  var handleOnMouseEnter = function handleOnMouseEnter() {
34
34
  onChangeActiveIndex && onChangeActiveIndex(index);
35
35
  };
36
- var handleOnMouseLeave = function handleOnMouseLeave() {
37
- onChangeActiveIndex && onChangeActiveIndex(-1);
38
- };
39
36
  return React.createElement(React.Fragment, null, React.createElement("div", {
40
37
  ref: optionRef,
41
38
  className: optionCls,
42
39
  title: name,
43
40
  onClick: handleClick,
44
- onMouseEnter: handleOnMouseEnter,
45
- onMouseLeave: handleOnMouseLeave
41
+ onMouseEnter: handleOnMouseEnter
46
42
  }, typeof itemRender === 'function' ? itemRender(city) : React.createElement(React.Fragment, null, React.createElement("span", {
47
43
  className: "".concat(selectOptionPrefixCls, "-content")
48
44
  }, children), React.createElement("span", {
@@ -12,6 +12,7 @@ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
12
12
  var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
13
13
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
14
14
  var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
15
+ var _findIndex = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find-index"));
15
16
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
16
17
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
17
18
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
@@ -22,7 +23,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
22
23
  var _ConfigContext = _interopRequireDefault(require("../config-provider/ConfigContext"));
23
24
  var _utils = require("../_utils");
24
25
  var _index = require("../index");
25
- var _usePopper = _interopRequireDefault(require("../_utils/usePopper"));
26
+ var _popper = _interopRequireDefault(require("../popper"));
26
27
  var _option = _interopRequireDefault(require("./option"));
27
28
  var _escapeRegExp = _interopRequireDefault(require("lodash/escapeRegExp"));
28
29
  var _KeyCode = _interopRequireDefault(require("../_utils/KeyCode"));
@@ -164,15 +165,6 @@ var InternalSelect = function InternalSelect(props, ref) {
164
165
  setAfterChangeFocus(false);
165
166
  onBlur && onBlur(e);
166
167
  }, [onBlur]);
167
- (0, _react.useEffect)(function () {
168
- selectionRef.current.addEventListener('mouseup', function (e) {
169
- var _a;
170
- 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;
171
- if (isCloseBtn) {
172
- e.stopPropagation();
173
- }
174
- });
175
- }, []);
176
168
  var handleSearchChange = (0, _react.useCallback)(function (event) {
177
169
  var val = event.currentTarget.value;
178
170
  setOptionShow(true);
@@ -371,14 +363,7 @@ var InternalSelect = function InternalSelect(props, ref) {
371
363
  }, [optionShow]);
372
364
  (0, _react.useEffect)(function () {
373
365
  var _a;
374
- var fn = function fn(e) {
375
- e.stopPropagation();
376
- };
377
- (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseup', fn);
378
- return function () {
379
- var _a;
380
- (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseup', fn);
381
- };
366
+ (_a = clearRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', handleReset);
382
367
  }, [initValue]);
383
368
  var curkeyboardList = (0, _react.useMemo)(function () {
384
369
  if (!searchValue) {
@@ -407,14 +392,16 @@ var InternalSelect = function InternalSelect(props, ref) {
407
392
  setActiveIndex(index === undefined ? getActiveIndex(0) : index);
408
393
  };
409
394
  (0, _react.useEffect)(function () {
410
- initActiveIndex(searchValue ? undefined : -1);
411
- }, [searchValue, tabsValue, curkeyboardList]);
395
+ var index = (0, _findIndex.default)(curkeyboardList).call(curkeyboardList, function (item) {
396
+ return item.id === initValue;
397
+ });
398
+ initActiveIndex(index >= 0 ? index : undefined);
399
+ }, [curkeyboardList, initValue]);
412
400
  var onInternalKeyDown = function onInternalKeyDown(e) {
413
401
  var _a, _b, _c;
414
402
  var which = e.which;
415
403
  if (which === _KeyCode.default.ENTER || which === _KeyCode.default.UP || which === _KeyCode.default.DOWN) {
416
404
  e.preventDefault();
417
- setOptionShow(true);
418
405
  }
419
406
  if (optionShow) {
420
407
  var offset = 0;
@@ -479,15 +466,11 @@ var InternalSelect = function InternalSelect(props, ref) {
479
466
  minWidth: width,
480
467
  maxWidth: 600
481
468
  }, dropdownStyle), {
482
- width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto',
483
- zIndex: 1050
469
+ width: (dropdownStyle === null || dropdownStyle === void 0 ? void 0 : dropdownStyle.width) || 'auto'
484
470
  }), popperStyle);
485
471
  }
486
472
  };
487
473
  var handleVisibleChange = function handleVisibleChange(visible) {
488
- if (!visible) {
489
- initActiveIndex(-1);
490
- }
491
474
  if (visible !== optionShow) {
492
475
  props.visible === undefined && setOptionShow(visible);
493
476
  onVisibleChange && onVisibleChange(visible);
@@ -500,14 +483,15 @@ var InternalSelect = function InternalSelect(props, ref) {
500
483
  defaultVisible: optionShow,
501
484
  visible: optionShow,
502
485
  onVisibleChange: handleVisibleChange,
503
- clickToClose: !searchValue,
504
486
  onTransitionEnd: function onTransitionEnd() {
505
487
  if (optionShow === false) {
506
488
  handleClear();
507
489
  }
508
490
  }
509
491
  });
510
- return (0, _usePopper.default)(renderCityPicker(), renderContent(), popperProps);
492
+ return _react.default.createElement(_popper.default, (0, _extends2.default)({
493
+ tip: renderContent()
494
+ }, popperProps), renderCityPicker());
511
495
  };
512
496
  var Select = _react.default.forwardRef(InternalSelect);
513
497
  Select.displayName = 'CityPicker';
@@ -45,16 +45,12 @@ var InternalOption = function InternalOption(props, ref) {
45
45
  var handleOnMouseEnter = function handleOnMouseEnter() {
46
46
  onChangeActiveIndex && onChangeActiveIndex(index);
47
47
  };
48
- var handleOnMouseLeave = function handleOnMouseLeave() {
49
- onChangeActiveIndex && onChangeActiveIndex(-1);
50
- };
51
48
  return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
52
49
  ref: optionRef,
53
50
  className: optionCls,
54
51
  title: name,
55
52
  onClick: handleClick,
56
- onMouseEnter: handleOnMouseEnter,
57
- onMouseLeave: handleOnMouseLeave
53
+ onMouseEnter: handleOnMouseEnter
58
54
  }, typeof itemRender === 'function' ? itemRender(city) : _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("span", {
59
55
  className: "".concat(selectOptionPrefixCls, "-content")
60
56
  }, children), _react.default.createElement("span", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.8.14",
3
+ "version": "1.8.15",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [