@kdcloudjs/kdesign 1.8.13 → 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", {
package/es/table/api.js CHANGED
@@ -115,6 +115,10 @@ export default function getApi(pipelineRef) {
115
115
  var pipeline = pipelineRef.current;
116
116
  return (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager.cache;
117
117
  }
118
+ function getFeatureApi(featureName) {
119
+ var pipeline = pipelineRef.current;
120
+ return pipeline.getFeatureApi(featureName);
121
+ }
118
122
  return {
119
123
  getColumns: getColumns,
120
124
  getDataSource: getDataSource,
@@ -122,6 +126,7 @@ export default function getApi(pipelineRef) {
122
126
  clearRangeSelection: clearRangeSelection,
123
127
  ensureRowIndexVisible: ensureRowIndexVisible,
124
128
  ensureColumnVisible: ensureColumnVisible,
125
- getHeightCache: getHeightCache
129
+ getHeightCache: getHeightCache,
130
+ getFeatureApi: getFeatureApi
126
131
  };
127
132
  }
@@ -1,3 +1,3 @@
1
1
  import { TableRowDrag, TablePipeline } from '../interface';
2
- declare function useRowDrag(pipeline: TablePipeline, rowDrag?: TableRowDrag, estimatedRowHeight?: number): void;
2
+ declare function useRowDrag(pipeline: TablePipeline, rowDrag?: TableRowDrag): void;
3
3
  export default useRowDrag;
@@ -1,10 +1,8 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
2
  import { features } from '@kdcloudjs/table';
3
- function useRowDrag(pipeline, rowDrag, estimatedRowHeight) {
3
+ function useRowDrag(pipeline, rowDrag) {
4
4
  if (rowDrag) {
5
- pipeline.use(features.rowDrag(_extends({
6
- rowHeight: estimatedRowHeight
7
- }, rowDrag)));
5
+ pipeline.use(features.rowDrag(_extends({}, rowDrag)));
8
6
  }
9
7
  }
10
8
  export default useRowDrag;
@@ -18,6 +18,7 @@ export declare type TableApi = {
18
18
  getHeightCache: () => number[];
19
19
  ensureRowIndexVisible: (rowIndex: number, position?: string | undefined) => void;
20
20
  ensureColumnVisible: (code: string) => void;
21
+ getFeatureApi: (featureName: string) => any;
21
22
  };
22
23
  export declare type TableInstance = {
23
24
  api: TableApi;
package/es/table/table.js CHANGED
@@ -98,7 +98,7 @@ var Table = forwardRef(function (props, ref) {
98
98
  useRangeSelection(pipeline, rangeSelection);
99
99
  useMergeCellHover(pipeline);
100
100
  useFooterDataSource(pipeline, footerDataSource);
101
- useRowDrag(pipeline, rowDrag, estimatedRowHeight);
101
+ useRowDrag(pipeline, rowDrag);
102
102
  if (typeof getRowProps === 'function') {
103
103
  pipeline.appendRowPropsGetter(getRowProps);
104
104
  } else {
package/es/tree/tree.js CHANGED
@@ -252,6 +252,7 @@ var InternalTree = React.forwardRef(function (props, ref) {
252
252
  setCheckedKeys(checkState.checkedKeys);
253
253
  setHalfCheckedKeys(checkState.halfCheckedKeys);
254
254
  }
255
+ setScrollKey(undefined);
255
256
  onCheck && onCheck(checkState.checkedKeys, {
256
257
  event: event,
257
258
  node: node,
@@ -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/lib/table/api.js CHANGED
@@ -122,6 +122,10 @@ function getApi(pipelineRef) {
122
122
  var pipeline = pipelineRef.current;
123
123
  return (_a = pipeline.ref) === null || _a === void 0 ? void 0 : _a.current.rowHeightManager.cache;
124
124
  }
125
+ function getFeatureApi(featureName) {
126
+ var pipeline = pipelineRef.current;
127
+ return pipeline.getFeatureApi(featureName);
128
+ }
125
129
  return {
126
130
  getColumns: getColumns,
127
131
  getDataSource: getDataSource,
@@ -129,6 +133,7 @@ function getApi(pipelineRef) {
129
133
  clearRangeSelection: clearRangeSelection,
130
134
  ensureRowIndexVisible: ensureRowIndexVisible,
131
135
  ensureColumnVisible: ensureColumnVisible,
132
- getHeightCache: getHeightCache
136
+ getHeightCache: getHeightCache,
137
+ getFeatureApi: getFeatureApi
133
138
  };
134
139
  }
@@ -1,3 +1,3 @@
1
1
  import { TableRowDrag, TablePipeline } from '../interface';
2
- declare function useRowDrag(pipeline: TablePipeline, rowDrag?: TableRowDrag, estimatedRowHeight?: number): void;
2
+ declare function useRowDrag(pipeline: TablePipeline, rowDrag?: TableRowDrag): void;
3
3
  export default useRowDrag;
@@ -7,11 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
9
9
  var _table = require("@kdcloudjs/table");
10
- function useRowDrag(pipeline, rowDrag, estimatedRowHeight) {
10
+ function useRowDrag(pipeline, rowDrag) {
11
11
  if (rowDrag) {
12
- pipeline.use(_table.features.rowDrag((0, _extends2.default)({
13
- rowHeight: estimatedRowHeight
14
- }, rowDrag)));
12
+ pipeline.use(_table.features.rowDrag((0, _extends2.default)({}, rowDrag)));
15
13
  }
16
14
  }
17
15
  var _default = useRowDrag;
@@ -18,6 +18,7 @@ export declare type TableApi = {
18
18
  getHeightCache: () => number[];
19
19
  ensureRowIndexVisible: (rowIndex: number, position?: string | undefined) => void;
20
20
  ensureColumnVisible: (code: string) => void;
21
+ getFeatureApi: (featureName: string) => any;
21
22
  };
22
23
  export declare type TableInstance = {
23
24
  api: TableApi;
@@ -110,7 +110,7 @@ var Table = (0, _react.forwardRef)(function (props, ref) {
110
110
  (0, _useRangeSelection.default)(pipeline, rangeSelection);
111
111
  (0, _mergeCellHover.default)(pipeline);
112
112
  (0, _useFooterDataSource.default)(pipeline, footerDataSource);
113
- (0, _useRowDrag.default)(pipeline, rowDrag, estimatedRowHeight);
113
+ (0, _useRowDrag.default)(pipeline, rowDrag);
114
114
  if (typeof getRowProps === 'function') {
115
115
  pipeline.appendRowPropsGetter(getRowProps);
116
116
  } else {
package/lib/tree/tree.js CHANGED
@@ -264,6 +264,7 @@ var InternalTree = _react.default.forwardRef(function (props, ref) {
264
264
  setCheckedKeys(checkState.checkedKeys);
265
265
  setHalfCheckedKeys(checkState.halfCheckedKeys);
266
266
  }
267
+ setScrollKey(undefined);
267
268
  onCheck && onCheck(checkState.checkedKeys, {
268
269
  event: event,
269
270
  node: node,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kdcloudjs/kdesign",
3
- "version": "1.8.13",
3
+ "version": "1.8.15",
4
4
  "description": "KDesign 金蝶前端react 组件库",
5
5
  "title": "kdesign",
6
6
  "keywords": [
@@ -78,7 +78,7 @@
78
78
  "@babel/runtime-corejs3": "^7.11.2",
79
79
  "@babel/standalone": "^7.14.3",
80
80
  "@kdcloudjs/kdesign-icons": "^1.0.5",
81
- "@kdcloudjs/table": "1.2.1-canary.7",
81
+ "@kdcloudjs/table": "1.2.2-canary.3",
82
82
  "@popperjs/core": "^2.11.8",
83
83
  "@types/js-cookie": "^3.0.3",
84
84
  "async-validator": "^3.5.1",