@douyinfe/semi-foundation 2.52.0 → 2.53.0-beta.0
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/cascader/foundation.ts +7 -14
- package/datePicker/inputFoundation.ts +4 -3
- package/datePicker/yearAndMonthFoundation.ts +4 -4
- package/form/utils.ts +3 -2
- package/lib/cjs/cascader/foundation.d.ts +0 -1
- package/lib/cjs/cascader/foundation.js +6 -18
- package/lib/cjs/datePicker/inputFoundation.js +3 -3
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +4 -4
- package/lib/cjs/form/utils.js +2 -2
- package/lib/cjs/overflowList/foundation.js +3 -3
- package/lib/cjs/tree/foundation.d.ts +0 -1
- package/lib/cjs/tree/foundation.js +7 -23
- package/lib/cjs/treeSelect/foundation.d.ts +0 -1
- package/lib/cjs/treeSelect/foundation.js +8 -28
- package/lib/cjs/utils/getMotionObjFromProps.js +2 -2
- package/lib/es/cascader/foundation.d.ts +0 -1
- package/lib/es/cascader/foundation.js +6 -18
- package/lib/es/datePicker/inputFoundation.js +3 -3
- package/lib/es/datePicker/yearAndMonthFoundation.js +4 -4
- package/lib/es/form/utils.js +2 -2
- package/lib/es/overflowList/foundation.js +3 -3
- package/lib/es/tree/foundation.d.ts +0 -1
- package/lib/es/tree/foundation.js +7 -23
- package/lib/es/treeSelect/foundation.d.ts +0 -1
- package/lib/es/treeSelect/foundation.js +9 -29
- package/lib/es/utils/getMotionObjFromProps.js +2 -2
- package/overflowList/foundation.ts +5 -3
- package/package.json +4 -3
- package/tree/foundation.ts +8 -17
- package/treeSelect/foundation.ts +9 -21
- package/utils/getMotionObjFromProps.ts +3 -2
package/cascader/foundation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEqual, get, difference, isUndefined, assign,
|
|
1
|
+
import { isEqual, get, difference, isUndefined, assign, isEmpty, isNumber, includes, isFunction, isObject } from 'lodash';
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
3
3
|
import {
|
|
4
4
|
findAncestorKeys,
|
|
@@ -317,14 +317,6 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
317
317
|
return isDisabled;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
getCopyFromState(items: string | string[]) {
|
|
321
|
-
const res: Partial<BasicCascaderInnerData> = {};
|
|
322
|
-
normalizedArr(items).forEach(key => {
|
|
323
|
-
res[key] = cloneDeep(this.getState(key));
|
|
324
|
-
});
|
|
325
|
-
return res;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
320
|
// prop: is array, return all data
|
|
329
321
|
getItemPropPath(selectedKey: string, prop: string | any[], keyEntities?: BasicEntities) {
|
|
330
322
|
const searchMap = keyEntities || this.getState('keyEntities');
|
|
@@ -681,8 +673,8 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
681
673
|
|
|
682
674
|
handleNodeLoad(item: BasicEntity | BasicData) {
|
|
683
675
|
const { data, key } = item;
|
|
684
|
-
const prevLoadingKeys =
|
|
685
|
-
const prevLoadedKeys =
|
|
676
|
+
const prevLoadingKeys = new Set(this._adapter.getLoadingKeyRefValue());
|
|
677
|
+
const prevLoadedKeys = new Set(this._adapter.getLoadedKeyRefValue());
|
|
686
678
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
687
679
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
688
680
|
newLoadingKeys.delete(key);
|
|
@@ -702,7 +694,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
702
694
|
this._adapter.updateStates({ loading: false });
|
|
703
695
|
if (!data.isLeaf && !data.children && this.getProp('loadData')) {
|
|
704
696
|
const loadedKeys = this._adapter.getLoadedKeyRefValue();
|
|
705
|
-
const loadingKeys =
|
|
697
|
+
const loadingKeys = new Set(this._adapter.getLoadingKeyRefValue());
|
|
706
698
|
if (loadedKeys.has(key) || loadingKeys.has(key)) {
|
|
707
699
|
return;
|
|
708
700
|
}
|
|
@@ -844,7 +836,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
844
836
|
|
|
845
837
|
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean) {
|
|
846
838
|
const { keyEntities, disabledKeys } = this.getStates();
|
|
847
|
-
const
|
|
839
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
848
840
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
849
841
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
850
842
|
if (!hasDisabled) {
|
|
@@ -893,7 +885,8 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
893
885
|
*/
|
|
894
886
|
calcCheckedKeys(key: string, curCheckedStatus: boolean) {
|
|
895
887
|
const { keyEntities } = this.getStates();
|
|
896
|
-
const
|
|
888
|
+
const checkedKeys = new Set(this.getState('checkedKeys')) as Set<string>;
|
|
889
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys')) as Set<string>;
|
|
897
890
|
return curCheckedStatus ?
|
|
898
891
|
calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfCheckedKeys) :
|
|
899
892
|
calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedKeys);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObject, set, get } from 'lodash';
|
|
2
2
|
import { format as formatFn } from 'date-fns';
|
|
3
3
|
|
|
4
4
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
@@ -11,6 +11,7 @@ import { strings } from './constants';
|
|
|
11
11
|
import getDefaultPickerDate from './_utils/getDefaultPickerDate';
|
|
12
12
|
import { compatibleParse } from './_utils/parser';
|
|
13
13
|
import { isValidDate } from './_utils';
|
|
14
|
+
import copy from 'fast-copy';
|
|
14
15
|
|
|
15
16
|
const KEY_CODE_ENTER = 'Enter';
|
|
16
17
|
const KEY_CODE_TAB = 'Tab';
|
|
@@ -191,7 +192,7 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
|
|
|
191
192
|
const { value, valuePath, insetInputValue } = options;
|
|
192
193
|
const { format, type, rangeSeparator } = this._adapter.getProps();
|
|
193
194
|
const insetFormatToken = getInsetInputFormatToken({ type, format });
|
|
194
|
-
const newInsetInputValue = set(
|
|
195
|
+
const newInsetInputValue = set(copy(insetInputValue), valuePath, value);
|
|
195
196
|
const insetInputStr = this.concatInsetInputValue({ insetInputValue: newInsetInputValue });
|
|
196
197
|
const parsedInsetInputValueFromInputStr = getInsetInputValueFromInsetInputStr({ inputValue: insetInputStr, type, rangeSeparator });
|
|
197
198
|
const filledTimeInsetInputValue = this._autoFillTimeToInsetInputValue({ insetInputValue: parsedInsetInputValueFromInputStr, valuePath, format: insetFormatToken });
|
|
@@ -202,7 +203,7 @@ export default class InputFoundation extends BaseFoundation<DateInputAdapter> {
|
|
|
202
203
|
_autoFillTimeToInsetInputValue(options: { insetInputValue: InsetInputValue; format: string; valuePath: string}) {
|
|
203
204
|
const { valuePath, insetInputValue, format } = options;
|
|
204
205
|
const { type, defaultPickerValue, dateFnsLocale } = this._adapter.getProps();
|
|
205
|
-
const insetInputValueWithTime =
|
|
206
|
+
const insetInputValueWithTime = copy(insetInputValue);
|
|
206
207
|
const { nowDate, nextDate } = getDefaultPickerDate({ defaultPickerValue, format, dateFnsLocale });
|
|
207
208
|
|
|
208
209
|
if (type.includes('Time')) {
|
|
@@ -4,7 +4,7 @@ import { PresetPosition } from './foundation';
|
|
|
4
4
|
import { ArrayElement } from '../utils/type';
|
|
5
5
|
import { strings } from './constants';
|
|
6
6
|
import { PanelType } from './monthsGridFoundation';
|
|
7
|
-
import
|
|
7
|
+
import copy from 'fast-copy';
|
|
8
8
|
|
|
9
9
|
type Type = ArrayElement<typeof strings.TYPE_SET>;
|
|
10
10
|
|
|
@@ -76,7 +76,7 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
|
|
|
76
76
|
const left = strings.PANEL_TYPE_LEFT;
|
|
77
77
|
const right = strings.PANEL_TYPE_RIGHT;
|
|
78
78
|
|
|
79
|
-
const year =
|
|
79
|
+
const year = copy(currentYear);
|
|
80
80
|
year[panelType] = item.value;
|
|
81
81
|
|
|
82
82
|
// make sure the right panel time is always less than the left panel time
|
|
@@ -102,7 +102,7 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
|
|
|
102
102
|
const left = strings.PANEL_TYPE_LEFT;
|
|
103
103
|
const right = strings.PANEL_TYPE_RIGHT;
|
|
104
104
|
|
|
105
|
-
const month =
|
|
105
|
+
const month = copy(currentMonth);
|
|
106
106
|
month[panelType] = item.month;
|
|
107
107
|
|
|
108
108
|
// make sure the right panel time is always less than the left panel time
|
|
@@ -132,7 +132,7 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
|
|
|
132
132
|
validMonth = months.slice(0, currentIndex).find(({ month }) => !disabledDate(setMonth(currentDate, month - 1)));
|
|
133
133
|
}
|
|
134
134
|
if (validMonth) {
|
|
135
|
-
const month =
|
|
135
|
+
const month = copy(currentMonth);
|
|
136
136
|
month[panelType] = validMonth.month;
|
|
137
137
|
|
|
138
138
|
// change year and month same time
|
package/form/utils.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import AsyncValidator from 'async-validator';
|
|
2
|
-
import {
|
|
2
|
+
import { toPath, isUndefined } from 'lodash';
|
|
3
3
|
import { FieldValidateTriggerType, BasicTriggerType, ComponentProps, WithFieldOption } from './interface';
|
|
4
4
|
import { strings } from './constants';
|
|
5
|
+
import copy from 'fast-copy';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
@@ -172,7 +173,7 @@ export function mergeProps(props: any) {
|
|
|
172
173
|
delete rest.checked;
|
|
173
174
|
|
|
174
175
|
if (typeof initValue !== 'undefined') {
|
|
175
|
-
initValue =
|
|
176
|
+
initValue = copy(initValue);
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
const required = isRequired(rules);
|
|
@@ -194,7 +194,6 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
194
194
|
_notifyBlur(e: any): void;
|
|
195
195
|
_notifyFocus(e: any): void;
|
|
196
196
|
_isOptionDisabled(key: string, keyEntities: BasicEntities): boolean;
|
|
197
|
-
getCopyFromState(items: string | string[]): Partial<BasicCascaderInnerData>;
|
|
198
197
|
getItemPropPath(selectedKey: string, prop: string | any[], keyEntities?: BasicEntities): any[];
|
|
199
198
|
_getCacheValue(keyEntities: BasicEntities): any;
|
|
200
199
|
collectOptions(init?: boolean): void;
|
|
@@ -9,7 +9,6 @@ var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
|
9
9
|
var _includes2 = _interopRequireDefault(require("lodash/includes"));
|
|
10
10
|
var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
|
|
11
11
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
12
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
13
12
|
var _assign2 = _interopRequireDefault(require("lodash/assign"));
|
|
14
13
|
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
15
14
|
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
|
@@ -113,13 +112,6 @@ class CascaderFoundation extends _foundation.default {
|
|
|
113
112
|
const isDisabled = (0, _treeUtil.findAncestorKeys)([key], keyEntities, true).some(item => keyEntities[item].data.disabled);
|
|
114
113
|
return isDisabled;
|
|
115
114
|
}
|
|
116
|
-
getCopyFromState(items) {
|
|
117
|
-
const res = {};
|
|
118
|
-
(0, _util.normalizedArr)(items).forEach(key => {
|
|
119
|
-
res[key] = (0, _cloneDeep2.default)(this.getState(key));
|
|
120
|
-
});
|
|
121
|
-
return res;
|
|
122
|
-
}
|
|
123
115
|
// prop: is array, return all data
|
|
124
116
|
getItemPropPath(selectedKey, prop, keyEntities) {
|
|
125
117
|
const searchMap = keyEntities || this.getState('keyEntities');
|
|
@@ -496,8 +488,8 @@ class CascaderFoundation extends _foundation.default {
|
|
|
496
488
|
data,
|
|
497
489
|
key
|
|
498
490
|
} = item;
|
|
499
|
-
const prevLoadingKeys =
|
|
500
|
-
const prevLoadedKeys =
|
|
491
|
+
const prevLoadingKeys = new Set(this._adapter.getLoadingKeyRefValue());
|
|
492
|
+
const prevLoadedKeys = new Set(this._adapter.getLoadedKeyRefValue());
|
|
501
493
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
502
494
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
503
495
|
newLoadingKeys.delete(key);
|
|
@@ -520,7 +512,7 @@ class CascaderFoundation extends _foundation.default {
|
|
|
520
512
|
});
|
|
521
513
|
if (!data.isLeaf && !data.children && this.getProp('loadData')) {
|
|
522
514
|
const loadedKeys = this._adapter.getLoadedKeyRefValue();
|
|
523
|
-
const loadingKeys =
|
|
515
|
+
const loadingKeys = new Set(this._adapter.getLoadingKeyRefValue());
|
|
524
516
|
if (loadedKeys.has(key) || loadingKeys.has(key)) {
|
|
525
517
|
return;
|
|
526
518
|
}
|
|
@@ -680,9 +672,7 @@ class CascaderFoundation extends _foundation.default {
|
|
|
680
672
|
keyEntities,
|
|
681
673
|
disabledKeys
|
|
682
674
|
} = this.getStates();
|
|
683
|
-
const
|
|
684
|
-
checkedKeys
|
|
685
|
-
} = this.getCopyFromState(['checkedKeys']);
|
|
675
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
686
676
|
const descendantKeys = (0, _treeUtil.normalizeKeyList)((0, _treeUtil.findDescendantKeys)([eventKey], keyEntities, false), keyEntities, true);
|
|
687
677
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
688
678
|
if (!hasDisabled) {
|
|
@@ -732,10 +722,8 @@ class CascaderFoundation extends _foundation.default {
|
|
|
732
722
|
const {
|
|
733
723
|
keyEntities
|
|
734
724
|
} = this.getStates();
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
halfCheckedKeys
|
|
738
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
725
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
726
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys'));
|
|
739
727
|
return curCheckedStatus ? (0, _treeUtil.calcCheckedKeysForChecked)(key, keyEntities, checkedKeys, halfCheckedKeys) : (0, _treeUtil.calcCheckedKeysForUnchecked)(key, keyEntities, checkedKeys, halfCheckedKeys);
|
|
740
728
|
}
|
|
741
729
|
handleInputChange(sugInput) {
|
|
@@ -7,7 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
8
8
|
var _set2 = _interopRequireDefault(require("lodash/set"));
|
|
9
9
|
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
10
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
11
10
|
var _dateFns = require("date-fns");
|
|
12
11
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
13
12
|
var _formatter = require("./_utils/formatter");
|
|
@@ -18,6 +17,7 @@ var _constants = require("./constants");
|
|
|
18
17
|
var _getDefaultPickerDate = _interopRequireDefault(require("./_utils/getDefaultPickerDate"));
|
|
19
18
|
var _parser = require("./_utils/parser");
|
|
20
19
|
var _utils = require("./_utils");
|
|
20
|
+
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
const KEY_CODE_ENTER = 'Enter';
|
|
23
23
|
const KEY_CODE_TAB = 'Tab';
|
|
@@ -120,7 +120,7 @@ class InputFoundation extends _foundation.default {
|
|
|
120
120
|
type,
|
|
121
121
|
format
|
|
122
122
|
});
|
|
123
|
-
const newInsetInputValue = (0, _set2.default)((0,
|
|
123
|
+
const newInsetInputValue = (0, _set2.default)((0, _fastCopy.default)(insetInputValue), valuePath, value);
|
|
124
124
|
const insetInputStr = this.concatInsetInputValue({
|
|
125
125
|
insetInputValue: newInsetInputValue
|
|
126
126
|
});
|
|
@@ -154,7 +154,7 @@ class InputFoundation extends _foundation.default {
|
|
|
154
154
|
defaultPickerValue,
|
|
155
155
|
dateFnsLocale
|
|
156
156
|
} = this._adapter.getProps();
|
|
157
|
-
const insetInputValueWithTime = (0,
|
|
157
|
+
const insetInputValueWithTime = (0, _fastCopy.default)(insetInputValue);
|
|
158
158
|
const {
|
|
159
159
|
nowDate,
|
|
160
160
|
nextDate
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
8
7
|
var _dateFns = require("date-fns");
|
|
9
8
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
10
9
|
var _constants = require("./constants");
|
|
10
|
+
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
class YearAndMonthFoundation extends _foundation.default {
|
|
13
13
|
constructor(adapter) {
|
|
@@ -26,7 +26,7 @@ class YearAndMonthFoundation extends _foundation.default {
|
|
|
26
26
|
} = this.getProps();
|
|
27
27
|
const left = _constants.strings.PANEL_TYPE_LEFT;
|
|
28
28
|
const right = _constants.strings.PANEL_TYPE_RIGHT;
|
|
29
|
-
const year = (0,
|
|
29
|
+
const year = (0, _fastCopy.default)(currentYear);
|
|
30
30
|
year[panelType] = item.value;
|
|
31
31
|
// make sure the right panel time is always less than the left panel time
|
|
32
32
|
if (type === 'monthRange') {
|
|
@@ -53,7 +53,7 @@ class YearAndMonthFoundation extends _foundation.default {
|
|
|
53
53
|
} = this.getProps();
|
|
54
54
|
const left = _constants.strings.PANEL_TYPE_LEFT;
|
|
55
55
|
const right = _constants.strings.PANEL_TYPE_RIGHT;
|
|
56
|
-
const month = (0,
|
|
56
|
+
const month = (0, _fastCopy.default)(currentMonth);
|
|
57
57
|
month[panelType] = item.month;
|
|
58
58
|
// make sure the right panel time is always less than the left panel time
|
|
59
59
|
if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
|
|
@@ -100,7 +100,7 @@ class YearAndMonthFoundation extends _foundation.default {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
if (validMonth) {
|
|
103
|
-
const month = (0,
|
|
103
|
+
const month = (0, _fastCopy.default)(currentMonth);
|
|
104
104
|
month[panelType] = validMonth.month;
|
|
105
105
|
// change year and month same time
|
|
106
106
|
this._adapter.setCurrentYearAndMonth(year, month);
|
package/lib/cjs/form/utils.js
CHANGED
|
@@ -12,9 +12,9 @@ exports.mergeProps = mergeProps;
|
|
|
12
12
|
exports.transformDefaultBooleanAPI = transformDefaultBooleanAPI;
|
|
13
13
|
exports.transformTrigger = transformTrigger;
|
|
14
14
|
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
15
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
16
15
|
var _asyncValidator = _interopRequireDefault(require("async-validator"));
|
|
17
16
|
var _constants = require("./constants");
|
|
17
|
+
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
20
20
|
var t = {};
|
|
@@ -181,7 +181,7 @@ function mergeProps(props) {
|
|
|
181
181
|
delete rest.defaultValue;
|
|
182
182
|
delete rest.checked;
|
|
183
183
|
if (typeof initValue !== 'undefined') {
|
|
184
|
-
initValue = (0,
|
|
184
|
+
initValue = (0, _fastCopy.default)(initValue);
|
|
185
185
|
}
|
|
186
186
|
const required = isRequired(rules);
|
|
187
187
|
emptyValue = typeof emptyValue !== 'undefined' ? emptyValue : '';
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
8
7
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
9
8
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
10
9
|
var _constants = require("./constants");
|
|
10
|
+
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
const Boundary = _constants.strings.BOUNDARY_MAP;
|
|
13
13
|
const OverflowDirection = _constants.strings.OVERFLOW_DIR;
|
|
@@ -25,7 +25,7 @@ class OverflowListFoundation extends _foundation.default {
|
|
|
25
25
|
const {
|
|
26
26
|
items
|
|
27
27
|
} = this.getProps();
|
|
28
|
-
return (0,
|
|
28
|
+
return (0, _fastCopy.default)(items).reverse();
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
getOverflowItem() {
|
|
@@ -53,7 +53,7 @@ class OverflowListFoundation extends _foundation.default {
|
|
|
53
53
|
return overflowList;
|
|
54
54
|
}
|
|
55
55
|
handleIntersect(entries) {
|
|
56
|
-
const visibleState = (0,
|
|
56
|
+
const visibleState = (0, _fastCopy.default)(this.getState('visibleState'));
|
|
57
57
|
const res = {};
|
|
58
58
|
entries.forEach(entry => {
|
|
59
59
|
const itemKey = (0, _get2.default)(entry, 'target.dataset.scrollkey');
|
|
@@ -249,7 +249,6 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
249
249
|
_isLoadControlled(): boolean;
|
|
250
250
|
_isFilterable(): boolean;
|
|
251
251
|
_showFilteredOnly(): any;
|
|
252
|
-
getCopyFromState(items: string[] | string): Partial<BasicTreeInnerData>;
|
|
253
252
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
254
253
|
notifyJsonChange(key: string[] | string, e: any): void;
|
|
255
254
|
notifyMultipleChange(key: string[], e: any): void;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
8
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
9
8
|
var _pick2 = _interopRequireDefault(require("lodash/pick"));
|
|
10
9
|
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
|
11
10
|
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
@@ -56,13 +55,6 @@ class TreeFoundation extends _foundation.default {
|
|
|
56
55
|
} = this.getProps();
|
|
57
56
|
return Boolean(inputValue) && showFilteredOnly;
|
|
58
57
|
}
|
|
59
|
-
getCopyFromState(items) {
|
|
60
|
-
const res = {};
|
|
61
|
-
(0, _treeUtil.normalizedArr)(items).forEach(key => {
|
|
62
|
-
res[key] = (0, _cloneDeep2.default)(this.getState(key));
|
|
63
|
-
});
|
|
64
|
-
return res;
|
|
65
|
-
}
|
|
66
58
|
getTreeNodeProps(key) {
|
|
67
59
|
const {
|
|
68
60
|
expandedKeys = new Set([]),
|
|
@@ -231,9 +223,7 @@ class TreeFoundation extends _foundation.default {
|
|
|
231
223
|
this._adapter.notifyDoubleClick(e, treeNode.data);
|
|
232
224
|
}
|
|
233
225
|
handleSingleSelect(e, treeNode) {
|
|
234
|
-
let
|
|
235
|
-
selectedKeys
|
|
236
|
-
} = this.getCopyFromState('selectedKeys');
|
|
226
|
+
let selectedKeys = [...this.getState('selectedKeys')];
|
|
237
227
|
const {
|
|
238
228
|
selected,
|
|
239
229
|
eventKey,
|
|
@@ -258,10 +248,8 @@ class TreeFoundation extends _foundation.default {
|
|
|
258
248
|
const {
|
|
259
249
|
keyEntities
|
|
260
250
|
} = this.getStates();
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
halfCheckedKeys
|
|
264
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
251
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
252
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys'));
|
|
265
253
|
return targetStatus ? (0, _treeUtil.calcCheckedKeysForChecked)(eventKey, keyEntities, checkedKeys, halfCheckedKeys) : (0, _treeUtil.calcCheckedKeysForUnchecked)(eventKey, keyEntities, checkedKeys, halfCheckedKeys);
|
|
266
254
|
}
|
|
267
255
|
/*
|
|
@@ -297,9 +285,7 @@ class TreeFoundation extends _foundation.default {
|
|
|
297
285
|
keyEntities,
|
|
298
286
|
disabledKeys
|
|
299
287
|
} = this.getStates();
|
|
300
|
-
const
|
|
301
|
-
checkedKeys
|
|
302
|
-
} = this.getCopyFromState(['checkedKeys']);
|
|
288
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
303
289
|
const descendantKeys = (0, _treeUtil.normalizeKeyList)((0, _treeUtil.findDescendantKeys)([eventKey], keyEntities, false), keyEntities, true);
|
|
304
290
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
305
291
|
// If none of the descendant nodes are disabled, follow the normal logic
|
|
@@ -374,7 +360,7 @@ class TreeFoundation extends _foundation.default {
|
|
|
374
360
|
const isSearching = Boolean(inputValue);
|
|
375
361
|
const showFilteredOnly = this._showFilteredOnly();
|
|
376
362
|
const expandedStateKey = isSearching ? 'filteredExpandedKeys' : 'expandedKeys';
|
|
377
|
-
const expandedKeys = this.
|
|
363
|
+
const expandedKeys = new Set(this.getState(expandedStateKey));
|
|
378
364
|
let motionType = 'show';
|
|
379
365
|
const {
|
|
380
366
|
eventKey,
|
|
@@ -435,10 +421,8 @@ class TreeFoundation extends _foundation.default {
|
|
|
435
421
|
}
|
|
436
422
|
// Process the loaded data
|
|
437
423
|
loadData(data).then(() => {
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
loadingKeys: prevLoadingKeys
|
|
441
|
-
} = this.getCopyFromState(['loadedKeys', 'loadingKeys']);
|
|
424
|
+
const prevLoadedKeys = new Set(this.getState('loadedKeys'));
|
|
425
|
+
const prevLoadingKeys = new Set(this.getState('loadingKeys'));
|
|
442
426
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
443
427
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
444
428
|
newLoadingKeys.delete(key);
|
|
@@ -125,7 +125,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
125
125
|
[x: number]: string;
|
|
126
126
|
};
|
|
127
127
|
getDataForKeyNotInKeyEntities(value: string): any;
|
|
128
|
-
getCopyFromState(items: string | string[]): BasicTreeInnerData;
|
|
129
128
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
130
129
|
handleNodeLoad(loadedKeys: Set<string>, loadingKeys: Set<string>, data: BasicTreeNodeData, resolve: (value?: any) => void): {
|
|
131
130
|
loadingKeys?: undefined;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
|
8
8
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
9
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
10
9
|
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
11
10
|
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
12
11
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
@@ -139,13 +138,6 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
139
138
|
return this.constructDataForValue(value);
|
|
140
139
|
}
|
|
141
140
|
}
|
|
142
|
-
getCopyFromState(items) {
|
|
143
|
-
const res = {};
|
|
144
|
-
(0, _treeUtil.normalizedArr)(items).forEach(key => {
|
|
145
|
-
res[key] = (0, _cloneDeep2.default)(this.getState(key));
|
|
146
|
-
});
|
|
147
|
-
return res;
|
|
148
|
-
}
|
|
149
141
|
getTreeNodeProps(key) {
|
|
150
142
|
const {
|
|
151
143
|
expandedKeys = new Set([]),
|
|
@@ -211,10 +203,8 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
211
203
|
return {};
|
|
212
204
|
}
|
|
213
205
|
loadData(data).then(() => {
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
loadingKeys: prevLoadingKeys
|
|
217
|
-
} = this.getCopyFromState(['loadedKeys', 'loadingKeys']);
|
|
206
|
+
const prevLoadedKeys = new Set(this.getState('loadedKeys'));
|
|
207
|
+
const prevLoadingKeys = new Set(this.getState('loadingKeys'));
|
|
218
208
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
219
209
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
220
210
|
newLoadingKeys.delete(key);
|
|
@@ -527,9 +517,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
527
517
|
}
|
|
528
518
|
}
|
|
529
519
|
handleSingleSelect(e, treeNode) {
|
|
530
|
-
let
|
|
531
|
-
selectedKeys
|
|
532
|
-
} = this.getCopyFromState('selectedKeys');
|
|
520
|
+
let selectedKeys = [...this.getState('selectedKeys')];
|
|
533
521
|
const {
|
|
534
522
|
clickToHide
|
|
535
523
|
} = this.getProps();
|
|
@@ -557,10 +545,8 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
557
545
|
const {
|
|
558
546
|
keyEntities
|
|
559
547
|
} = this.getStates();
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
halfCheckedKeys
|
|
563
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
548
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
549
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys'));
|
|
564
550
|
if (targetStatus) {
|
|
565
551
|
return (0, _treeUtil.calcCheckedKeysForChecked)(eventKey, keyEntities, checkedKeys, halfCheckedKeys);
|
|
566
552
|
} else {
|
|
@@ -627,9 +613,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
627
613
|
keyEntities,
|
|
628
614
|
disabledKeys
|
|
629
615
|
} = this.getStates();
|
|
630
|
-
const
|
|
631
|
-
checkedKeys
|
|
632
|
-
} = this.getCopyFromState(['checkedKeys']);
|
|
616
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
633
617
|
const descendantKeys = (0, _treeUtil.normalizeKeyList)((0, _treeUtil.findDescendantKeys)([eventKey], keyEntities, false), keyEntities, true);
|
|
634
618
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
635
619
|
if (!hasDisabled) {
|
|
@@ -666,9 +650,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
666
650
|
} = this.getStates();
|
|
667
651
|
const showFilteredOnly = this._showFilteredOnly();
|
|
668
652
|
// clone otherwise will be modified unexpectedly
|
|
669
|
-
const
|
|
670
|
-
filteredExpandedKeys
|
|
671
|
-
} = this.getCopyFromState('filteredExpandedKeys');
|
|
653
|
+
const filteredExpandedKeys = new Set(this.getState('filteredExpandedKeys'));
|
|
672
654
|
let motionType = 'show';
|
|
673
655
|
const {
|
|
674
656
|
eventKey,
|
|
@@ -724,9 +706,7 @@ class TreeSelectFoundation extends _foundation.default {
|
|
|
724
706
|
treeData
|
|
725
707
|
} = this.getStates();
|
|
726
708
|
// clone otherwise will be modified unexpectedly
|
|
727
|
-
const
|
|
728
|
-
expandedKeys
|
|
729
|
-
} = this.getCopyFromState('expandedKeys');
|
|
709
|
+
const expandedKeys = new Set(this.getState('expandedKeys'));
|
|
730
710
|
let motionType = 'show';
|
|
731
711
|
const {
|
|
732
712
|
eventKey,
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getMotionObjFromProps;
|
|
7
7
|
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
8
|
-
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
9
8
|
var _warning = _interopRequireDefault(require("./warning"));
|
|
9
|
+
var _fastCopy = _interopRequireDefault(require("fast-copy"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
/**
|
|
12
12
|
* get motion object from props
|
|
@@ -31,7 +31,7 @@ function getMotionObjFromProps(props) {
|
|
|
31
31
|
} = props;
|
|
32
32
|
let motion = {};
|
|
33
33
|
if ((0, _isObject2.default)(motionProp)) {
|
|
34
|
-
motion = (0,
|
|
34
|
+
motion = (0, _fastCopy.default)(motionProp);
|
|
35
35
|
for (const key of Object.keys(motionProp)) {
|
|
36
36
|
const handler = motionProp[key];
|
|
37
37
|
if (typeof handler === 'function') {
|
|
@@ -194,7 +194,6 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter,
|
|
|
194
194
|
_notifyBlur(e: any): void;
|
|
195
195
|
_notifyFocus(e: any): void;
|
|
196
196
|
_isOptionDisabled(key: string, keyEntities: BasicEntities): boolean;
|
|
197
|
-
getCopyFromState(items: string | string[]): Partial<BasicCascaderInnerData>;
|
|
198
197
|
getItemPropPath(selectedKey: string, prop: string | any[], keyEntities?: BasicEntities): any[];
|
|
199
198
|
_getCacheValue(keyEntities: BasicEntities): any;
|
|
200
199
|
collectOptions(init?: boolean): void;
|
|
@@ -3,7 +3,6 @@ import _isFunction from "lodash/isFunction";
|
|
|
3
3
|
import _includes from "lodash/includes";
|
|
4
4
|
import _isNumber from "lodash/isNumber";
|
|
5
5
|
import _isEmpty from "lodash/isEmpty";
|
|
6
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
7
6
|
import _assign from "lodash/assign";
|
|
8
7
|
import _isUndefined from "lodash/isUndefined";
|
|
9
8
|
import _difference from "lodash/difference";
|
|
@@ -106,13 +105,6 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
106
105
|
const isDisabled = findAncestorKeys([key], keyEntities, true).some(item => keyEntities[item].data.disabled);
|
|
107
106
|
return isDisabled;
|
|
108
107
|
}
|
|
109
|
-
getCopyFromState(items) {
|
|
110
|
-
const res = {};
|
|
111
|
-
normalizedArr(items).forEach(key => {
|
|
112
|
-
res[key] = _cloneDeep(this.getState(key));
|
|
113
|
-
});
|
|
114
|
-
return res;
|
|
115
|
-
}
|
|
116
108
|
// prop: is array, return all data
|
|
117
109
|
getItemPropPath(selectedKey, prop, keyEntities) {
|
|
118
110
|
const searchMap = keyEntities || this.getState('keyEntities');
|
|
@@ -489,8 +481,8 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
489
481
|
data,
|
|
490
482
|
key
|
|
491
483
|
} = item;
|
|
492
|
-
const prevLoadingKeys =
|
|
493
|
-
const prevLoadedKeys =
|
|
484
|
+
const prevLoadingKeys = new Set(this._adapter.getLoadingKeyRefValue());
|
|
485
|
+
const prevLoadedKeys = new Set(this._adapter.getLoadedKeyRefValue());
|
|
494
486
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
495
487
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
496
488
|
newLoadingKeys.delete(key);
|
|
@@ -513,7 +505,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
513
505
|
});
|
|
514
506
|
if (!data.isLeaf && !data.children && this.getProp('loadData')) {
|
|
515
507
|
const loadedKeys = this._adapter.getLoadedKeyRefValue();
|
|
516
|
-
const loadingKeys =
|
|
508
|
+
const loadingKeys = new Set(this._adapter.getLoadingKeyRefValue());
|
|
517
509
|
if (loadedKeys.has(key) || loadingKeys.has(key)) {
|
|
518
510
|
return;
|
|
519
511
|
}
|
|
@@ -673,9 +665,7 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
673
665
|
keyEntities,
|
|
674
666
|
disabledKeys
|
|
675
667
|
} = this.getStates();
|
|
676
|
-
const
|
|
677
|
-
checkedKeys
|
|
678
|
-
} = this.getCopyFromState(['checkedKeys']);
|
|
668
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
679
669
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
680
670
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
681
671
|
if (!hasDisabled) {
|
|
@@ -725,10 +715,8 @@ export default class CascaderFoundation extends BaseFoundation {
|
|
|
725
715
|
const {
|
|
726
716
|
keyEntities
|
|
727
717
|
} = this.getStates();
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
halfCheckedKeys
|
|
731
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
718
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
719
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys'));
|
|
732
720
|
return curCheckedStatus ? calcCheckedKeysForChecked(key, keyEntities, checkedKeys, halfCheckedKeys) : calcCheckedKeysForUnchecked(key, keyEntities, checkedKeys, halfCheckedKeys);
|
|
733
721
|
}
|
|
734
722
|
handleInputChange(sugInput) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _get from "lodash/get";
|
|
2
2
|
import _set from "lodash/set";
|
|
3
3
|
import _isObject from "lodash/isObject";
|
|
4
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
5
4
|
import { format as formatFn } from 'date-fns';
|
|
6
5
|
import BaseFoundation from '../base/foundation';
|
|
7
6
|
import { formatDateValues } from './_utils/formatter';
|
|
@@ -12,6 +11,7 @@ import { strings } from './constants';
|
|
|
12
11
|
import getDefaultPickerDate from './_utils/getDefaultPickerDate';
|
|
13
12
|
import { compatibleParse } from './_utils/parser';
|
|
14
13
|
import { isValidDate } from './_utils';
|
|
14
|
+
import copy from 'fast-copy';
|
|
15
15
|
const KEY_CODE_ENTER = 'Enter';
|
|
16
16
|
const KEY_CODE_TAB = 'Tab';
|
|
17
17
|
export default class InputFoundation extends BaseFoundation {
|
|
@@ -113,7 +113,7 @@ export default class InputFoundation extends BaseFoundation {
|
|
|
113
113
|
type,
|
|
114
114
|
format
|
|
115
115
|
});
|
|
116
|
-
const newInsetInputValue = _set(
|
|
116
|
+
const newInsetInputValue = _set(copy(insetInputValue), valuePath, value);
|
|
117
117
|
const insetInputStr = this.concatInsetInputValue({
|
|
118
118
|
insetInputValue: newInsetInputValue
|
|
119
119
|
});
|
|
@@ -147,7 +147,7 @@ export default class InputFoundation extends BaseFoundation {
|
|
|
147
147
|
defaultPickerValue,
|
|
148
148
|
dateFnsLocale
|
|
149
149
|
} = this._adapter.getProps();
|
|
150
|
-
const insetInputValueWithTime =
|
|
150
|
+
const insetInputValueWithTime = copy(insetInputValue);
|
|
151
151
|
const {
|
|
152
152
|
nowDate,
|
|
153
153
|
nextDate
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
2
1
|
import { setMonth, setYear } from 'date-fns';
|
|
3
2
|
import BaseFoundation from '../base/foundation';
|
|
4
3
|
import { strings } from './constants';
|
|
4
|
+
import copy from 'fast-copy';
|
|
5
5
|
export default class YearAndMonthFoundation extends BaseFoundation {
|
|
6
6
|
constructor(adapter) {
|
|
7
7
|
super(Object.assign({}, adapter));
|
|
@@ -19,7 +19,7 @@ export default class YearAndMonthFoundation extends BaseFoundation {
|
|
|
19
19
|
} = this.getProps();
|
|
20
20
|
const left = strings.PANEL_TYPE_LEFT;
|
|
21
21
|
const right = strings.PANEL_TYPE_RIGHT;
|
|
22
|
-
const year =
|
|
22
|
+
const year = copy(currentYear);
|
|
23
23
|
year[panelType] = item.value;
|
|
24
24
|
// make sure the right panel time is always less than the left panel time
|
|
25
25
|
if (type === 'monthRange') {
|
|
@@ -46,7 +46,7 @@ export default class YearAndMonthFoundation extends BaseFoundation {
|
|
|
46
46
|
} = this.getProps();
|
|
47
47
|
const left = strings.PANEL_TYPE_LEFT;
|
|
48
48
|
const right = strings.PANEL_TYPE_RIGHT;
|
|
49
|
-
const month =
|
|
49
|
+
const month = copy(currentMonth);
|
|
50
50
|
month[panelType] = item.month;
|
|
51
51
|
// make sure the right panel time is always less than the left panel time
|
|
52
52
|
if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
|
|
@@ -93,7 +93,7 @@ export default class YearAndMonthFoundation extends BaseFoundation {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
if (validMonth) {
|
|
96
|
-
const month =
|
|
96
|
+
const month = copy(currentMonth);
|
|
97
97
|
month[panelType] = validMonth.month;
|
|
98
98
|
// change year and month same time
|
|
99
99
|
this._adapter.setCurrentYearAndMonth(year, month);
|
package/lib/es/form/utils.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _isUndefined from "lodash/isUndefined";
|
|
2
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
3
2
|
var __rest = this && this.__rest || function (s, e) {
|
|
4
3
|
var t = {};
|
|
5
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
@@ -10,6 +9,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
10
9
|
};
|
|
11
10
|
import AsyncValidator from 'async-validator';
|
|
12
11
|
import { strings } from './constants';
|
|
12
|
+
import copy from 'fast-copy';
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @param WrappedComponent React.ComponentType | any
|
|
@@ -167,7 +167,7 @@ export function mergeProps(props) {
|
|
|
167
167
|
delete rest.defaultValue;
|
|
168
168
|
delete rest.checked;
|
|
169
169
|
if (typeof initValue !== 'undefined') {
|
|
170
|
-
initValue =
|
|
170
|
+
initValue = copy(initValue);
|
|
171
171
|
}
|
|
172
172
|
const required = isRequired(rules);
|
|
173
173
|
emptyValue = typeof emptyValue !== 'undefined' ? emptyValue : '';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
2
1
|
import _get from "lodash/get";
|
|
3
2
|
import BaseFoundation from '../base/foundation';
|
|
4
3
|
import { strings } from './constants';
|
|
4
|
+
import copy from 'fast-copy';
|
|
5
5
|
const Boundary = strings.BOUNDARY_MAP;
|
|
6
6
|
const OverflowDirection = strings.OVERFLOW_DIR;
|
|
7
7
|
class OverflowListFoundation extends BaseFoundation {
|
|
@@ -18,7 +18,7 @@ class OverflowListFoundation extends BaseFoundation {
|
|
|
18
18
|
const {
|
|
19
19
|
items
|
|
20
20
|
} = this.getProps();
|
|
21
|
-
return
|
|
21
|
+
return copy(items).reverse();
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
getOverflowItem() {
|
|
@@ -46,7 +46,7 @@ class OverflowListFoundation extends BaseFoundation {
|
|
|
46
46
|
return overflowList;
|
|
47
47
|
}
|
|
48
48
|
handleIntersect(entries) {
|
|
49
|
-
const visibleState =
|
|
49
|
+
const visibleState = copy(this.getState('visibleState'));
|
|
50
50
|
const res = {};
|
|
51
51
|
entries.forEach(entry => {
|
|
52
52
|
const itemKey = _get(entry, 'target.dataset.scrollkey');
|
|
@@ -249,7 +249,6 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
249
249
|
_isLoadControlled(): boolean;
|
|
250
250
|
_isFilterable(): boolean;
|
|
251
251
|
_showFilteredOnly(): any;
|
|
252
|
-
getCopyFromState(items: string[] | string): Partial<BasicTreeInnerData>;
|
|
253
252
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
254
253
|
notifyJsonChange(key: string[] | string, e: any): void;
|
|
255
254
|
notifyMultipleChange(key: string[], e: any): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _get from "lodash/get";
|
|
2
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
3
2
|
import _pick from "lodash/pick";
|
|
4
3
|
import _difference from "lodash/difference";
|
|
5
4
|
import _isUndefined from "lodash/isUndefined";
|
|
@@ -48,13 +47,6 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
48
47
|
} = this.getProps();
|
|
49
48
|
return Boolean(inputValue) && showFilteredOnly;
|
|
50
49
|
}
|
|
51
|
-
getCopyFromState(items) {
|
|
52
|
-
const res = {};
|
|
53
|
-
normalizedArr(items).forEach(key => {
|
|
54
|
-
res[key] = _cloneDeep(this.getState(key));
|
|
55
|
-
});
|
|
56
|
-
return res;
|
|
57
|
-
}
|
|
58
50
|
getTreeNodeProps(key) {
|
|
59
51
|
const {
|
|
60
52
|
expandedKeys = new Set([]),
|
|
@@ -223,9 +215,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
223
215
|
this._adapter.notifyDoubleClick(e, treeNode.data);
|
|
224
216
|
}
|
|
225
217
|
handleSingleSelect(e, treeNode) {
|
|
226
|
-
let
|
|
227
|
-
selectedKeys
|
|
228
|
-
} = this.getCopyFromState('selectedKeys');
|
|
218
|
+
let selectedKeys = [...this.getState('selectedKeys')];
|
|
229
219
|
const {
|
|
230
220
|
selected,
|
|
231
221
|
eventKey,
|
|
@@ -250,10 +240,8 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
250
240
|
const {
|
|
251
241
|
keyEntities
|
|
252
242
|
} = this.getStates();
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
halfCheckedKeys
|
|
256
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
243
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
244
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys'));
|
|
257
245
|
return targetStatus ? calcCheckedKeysForChecked(eventKey, keyEntities, checkedKeys, halfCheckedKeys) : calcCheckedKeysForUnchecked(eventKey, keyEntities, checkedKeys, halfCheckedKeys);
|
|
258
246
|
}
|
|
259
247
|
/*
|
|
@@ -289,9 +277,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
289
277
|
keyEntities,
|
|
290
278
|
disabledKeys
|
|
291
279
|
} = this.getStates();
|
|
292
|
-
const
|
|
293
|
-
checkedKeys
|
|
294
|
-
} = this.getCopyFromState(['checkedKeys']);
|
|
280
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
295
281
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
296
282
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
297
283
|
// If none of the descendant nodes are disabled, follow the normal logic
|
|
@@ -366,7 +352,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
366
352
|
const isSearching = Boolean(inputValue);
|
|
367
353
|
const showFilteredOnly = this._showFilteredOnly();
|
|
368
354
|
const expandedStateKey = isSearching ? 'filteredExpandedKeys' : 'expandedKeys';
|
|
369
|
-
const expandedKeys = this.
|
|
355
|
+
const expandedKeys = new Set(this.getState(expandedStateKey));
|
|
370
356
|
let motionType = 'show';
|
|
371
357
|
const {
|
|
372
358
|
eventKey,
|
|
@@ -427,10 +413,8 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
427
413
|
}
|
|
428
414
|
// Process the loaded data
|
|
429
415
|
loadData(data).then(() => {
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
loadingKeys: prevLoadingKeys
|
|
433
|
-
} = this.getCopyFromState(['loadedKeys', 'loadingKeys']);
|
|
416
|
+
const prevLoadedKeys = new Set(this.getState('loadedKeys'));
|
|
417
|
+
const prevLoadingKeys = new Set(this.getState('loadingKeys'));
|
|
434
418
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
435
419
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
436
420
|
newLoadingKeys.delete(key);
|
|
@@ -125,7 +125,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
125
125
|
[x: number]: string;
|
|
126
126
|
};
|
|
127
127
|
getDataForKeyNotInKeyEntities(value: string): any;
|
|
128
|
-
getCopyFromState(items: string | string[]): BasicTreeInnerData;
|
|
129
128
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
130
129
|
handleNodeLoad(loadedKeys: Set<string>, loadingKeys: Set<string>, data: BasicTreeNodeData, resolve: (value?: any) => void): {
|
|
131
130
|
loadingKeys?: undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _difference from "lodash/difference";
|
|
2
2
|
import _isEmpty from "lodash/isEmpty";
|
|
3
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
4
3
|
import _isString from "lodash/isString";
|
|
5
4
|
import _isUndefined from "lodash/isUndefined";
|
|
6
5
|
import _get from "lodash/get";
|
|
@@ -8,7 +7,7 @@ import _isFunction from "lodash/isFunction";
|
|
|
8
7
|
import _isNumber from "lodash/isNumber";
|
|
9
8
|
import { strings } from '../treeSelect/constants';
|
|
10
9
|
import BaseFoundation from '../base/foundation';
|
|
11
|
-
import { flattenTreeData, findDescendantKeys, findAncestorKeys, filter,
|
|
10
|
+
import { flattenTreeData, findDescendantKeys, findAncestorKeys, filter, normalizeKeyList, getMotionKeys, calcCheckedKeysForChecked, calcCheckedKeys, calcCheckedKeysForUnchecked, getValueOrKey } from '../tree/treeUtil';
|
|
12
11
|
import isEnterPress from '../utils/isEnterPress';
|
|
13
12
|
export default class TreeSelectFoundation extends BaseFoundation {
|
|
14
13
|
constructor(adapter) {
|
|
@@ -132,13 +131,6 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
132
131
|
return this.constructDataForValue(value);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
|
-
getCopyFromState(items) {
|
|
136
|
-
const res = {};
|
|
137
|
-
normalizedArr(items).forEach(key => {
|
|
138
|
-
res[key] = _cloneDeep(this.getState(key));
|
|
139
|
-
});
|
|
140
|
-
return res;
|
|
141
|
-
}
|
|
142
134
|
getTreeNodeProps(key) {
|
|
143
135
|
const {
|
|
144
136
|
expandedKeys = new Set([]),
|
|
@@ -204,10 +196,8 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
204
196
|
return {};
|
|
205
197
|
}
|
|
206
198
|
loadData(data).then(() => {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
loadingKeys: prevLoadingKeys
|
|
210
|
-
} = this.getCopyFromState(['loadedKeys', 'loadingKeys']);
|
|
199
|
+
const prevLoadedKeys = new Set(this.getState('loadedKeys'));
|
|
200
|
+
const prevLoadingKeys = new Set(this.getState('loadingKeys'));
|
|
211
201
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
212
202
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
213
203
|
newLoadingKeys.delete(key);
|
|
@@ -520,9 +510,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
520
510
|
}
|
|
521
511
|
}
|
|
522
512
|
handleSingleSelect(e, treeNode) {
|
|
523
|
-
let
|
|
524
|
-
selectedKeys
|
|
525
|
-
} = this.getCopyFromState('selectedKeys');
|
|
513
|
+
let selectedKeys = [...this.getState('selectedKeys')];
|
|
526
514
|
const {
|
|
527
515
|
clickToHide
|
|
528
516
|
} = this.getProps();
|
|
@@ -550,10 +538,8 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
550
538
|
const {
|
|
551
539
|
keyEntities
|
|
552
540
|
} = this.getStates();
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
halfCheckedKeys
|
|
556
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
541
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
542
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys'));
|
|
557
543
|
if (targetStatus) {
|
|
558
544
|
return calcCheckedKeysForChecked(eventKey, keyEntities, checkedKeys, halfCheckedKeys);
|
|
559
545
|
} else {
|
|
@@ -620,9 +606,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
620
606
|
keyEntities,
|
|
621
607
|
disabledKeys
|
|
622
608
|
} = this.getStates();
|
|
623
|
-
const
|
|
624
|
-
checkedKeys
|
|
625
|
-
} = this.getCopyFromState(['checkedKeys']);
|
|
609
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
626
610
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
627
611
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
628
612
|
if (!hasDisabled) {
|
|
@@ -659,9 +643,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
659
643
|
} = this.getStates();
|
|
660
644
|
const showFilteredOnly = this._showFilteredOnly();
|
|
661
645
|
// clone otherwise will be modified unexpectedly
|
|
662
|
-
const
|
|
663
|
-
filteredExpandedKeys
|
|
664
|
-
} = this.getCopyFromState('filteredExpandedKeys');
|
|
646
|
+
const filteredExpandedKeys = new Set(this.getState('filteredExpandedKeys'));
|
|
665
647
|
let motionType = 'show';
|
|
666
648
|
const {
|
|
667
649
|
eventKey,
|
|
@@ -717,9 +699,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
717
699
|
treeData
|
|
718
700
|
} = this.getStates();
|
|
719
701
|
// clone otherwise will be modified unexpectedly
|
|
720
|
-
const
|
|
721
|
-
expandedKeys
|
|
722
|
-
} = this.getCopyFromState('expandedKeys');
|
|
702
|
+
const expandedKeys = new Set(this.getState('expandedKeys'));
|
|
723
703
|
let motionType = 'show';
|
|
724
704
|
const {
|
|
725
705
|
eventKey,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _isObject from "lodash/isObject";
|
|
2
|
-
import _cloneDeep from "lodash/cloneDeep";
|
|
3
2
|
import warning from './warning';
|
|
3
|
+
import copy from "fast-copy";
|
|
4
4
|
/**
|
|
5
5
|
* get motion object from props
|
|
6
6
|
*
|
|
@@ -24,7 +24,7 @@ export default function getMotionObjFromProps(props) {
|
|
|
24
24
|
} = props;
|
|
25
25
|
let motion = {};
|
|
26
26
|
if (_isObject(motionProp)) {
|
|
27
|
-
motion =
|
|
27
|
+
motion = copy(motionProp);
|
|
28
28
|
for (const key of Object.keys(motionProp)) {
|
|
29
29
|
const handler = motionProp[key];
|
|
30
30
|
if (typeof handler === 'function') {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
2
|
import { strings } from './constants';
|
|
3
|
-
import { noop, get
|
|
3
|
+
import { noop, get } from 'lodash';
|
|
4
|
+
import copy from 'fast-copy';
|
|
5
|
+
|
|
4
6
|
const Boundary = strings.BOUNDARY_MAP;
|
|
5
7
|
const OverflowDirection = strings.OVERFLOW_DIR;
|
|
6
8
|
|
|
@@ -42,7 +44,7 @@ class OverflowListFoundation extends BaseFoundation<OverflowListAdapter> {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
handleIntersect(entries: Array<IntersectionObserverEntry>): void {
|
|
45
|
-
const visibleState =
|
|
47
|
+
const visibleState = copy(this.getState('visibleState'));
|
|
46
48
|
|
|
47
49
|
const res = {};
|
|
48
50
|
entries.forEach(entry => {
|
|
@@ -75,7 +77,7 @@ class OverflowListFoundation extends BaseFoundation<OverflowListAdapter> {
|
|
|
75
77
|
|
|
76
78
|
getReversedItems = ()=>{
|
|
77
79
|
const { items } = this.getProps();
|
|
78
|
-
return
|
|
80
|
+
return copy(items).reverse();
|
|
79
81
|
}
|
|
80
82
|
handleCollapseOverflow() {
|
|
81
83
|
const { minVisibleItems, collapseFrom } = this.getProps();
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.53.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
7
7
|
"prepublishOnly": "npm run build:lib"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@douyinfe/semi-animation": "2.
|
|
10
|
+
"@douyinfe/semi-animation": "2.53.0-beta.0",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
14
14
|
"date-fns-tz": "^1.3.8",
|
|
15
|
+
"fast-copy": "^3.0.1 ",
|
|
15
16
|
"lodash": "^4.17.21",
|
|
16
17
|
"memoize-one": "^5.2.1",
|
|
17
18
|
"scroll-into-view-if-needed": "^2.2.24"
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
"*.scss",
|
|
24
25
|
"*.css"
|
|
25
26
|
],
|
|
26
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "89f93e5a8ad3b801d7b0db62e9bff8acbe0c50c0",
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
30
|
"@babel/preset-env": "^7.15.8",
|
package/tree/foundation.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* https://github.com/react-component/tree
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { isUndefined, difference, pick,
|
|
6
|
+
import { isUndefined, difference, pick, get } from 'lodash';
|
|
7
7
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
8
8
|
import {
|
|
9
9
|
flattenTreeData,
|
|
@@ -359,14 +359,6 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
359
359
|
return Boolean(inputValue) && showFilteredOnly;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
getCopyFromState(items: string[] | string) {
|
|
363
|
-
const res: Partial<BasicTreeInnerData> = {};
|
|
364
|
-
normalizedArr(items).forEach(key => {
|
|
365
|
-
res[key] = cloneDeep(this.getState(key));
|
|
366
|
-
});
|
|
367
|
-
return res;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
362
|
getTreeNodeProps(key: string) {
|
|
371
363
|
const {
|
|
372
364
|
expandedKeys = new Set([]),
|
|
@@ -528,7 +520,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
528
520
|
}
|
|
529
521
|
|
|
530
522
|
handleSingleSelect(e: any, treeNode: BasicTreeNodeProps) {
|
|
531
|
-
let
|
|
523
|
+
let selectedKeys = [...this.getState('selectedKeys')];
|
|
532
524
|
const { selected, eventKey, data } = treeNode;
|
|
533
525
|
const targetSelected = !selected;
|
|
534
526
|
|
|
@@ -549,7 +541,8 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
549
541
|
|
|
550
542
|
calcCheckedKeys(eventKey: string, targetStatus: boolean) {
|
|
551
543
|
const { keyEntities } = this.getStates();
|
|
552
|
-
const
|
|
544
|
+
const checkedKeys = new Set(this.getState('checkedKeys')) as Set<string>;
|
|
545
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys')) as Set<string>;
|
|
553
546
|
return targetStatus ?
|
|
554
547
|
calcCheckedKeysForChecked(eventKey, keyEntities, checkedKeys, halfCheckedKeys) :
|
|
555
548
|
calcCheckedKeysForUnchecked(eventKey, keyEntities, checkedKeys, halfCheckedKeys);
|
|
@@ -582,7 +575,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
582
575
|
*/
|
|
583
576
|
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean) {
|
|
584
577
|
const { keyEntities, disabledKeys } = this.getStates();
|
|
585
|
-
const
|
|
578
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
586
579
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
587
580
|
const hasDisabled = descendantKeys.some((key: string) => disabledKeys.has(key));
|
|
588
581
|
// If none of the descendant nodes are disabled, follow the normal logic
|
|
@@ -639,7 +632,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
639
632
|
const isSearching = Boolean(inputValue);
|
|
640
633
|
const showFilteredOnly = this._showFilteredOnly();
|
|
641
634
|
const expandedStateKey = isSearching ? 'filteredExpandedKeys' : 'expandedKeys';
|
|
642
|
-
const expandedKeys = this.
|
|
635
|
+
const expandedKeys = new Set(this.getState(expandedStateKey)) as Set<string>;
|
|
643
636
|
|
|
644
637
|
let motionType = 'show';
|
|
645
638
|
const { eventKey, expanded, data } = treeNode;
|
|
@@ -697,10 +690,8 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
697
690
|
|
|
698
691
|
// Process the loaded data
|
|
699
692
|
loadData(data).then(() => {
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
loadingKeys: prevLoadingKeys
|
|
703
|
-
} = this.getCopyFromState(['loadedKeys', 'loadingKeys']);
|
|
693
|
+
const prevLoadedKeys = new Set(this.getState('loadedKeys')) as Set<string>;
|
|
694
|
+
const prevLoadingKeys = new Set(this.getState('loadingKeys')) as Set<string>;
|
|
704
695
|
const newLoadedKeys = prevLoadedKeys.add(key);
|
|
705
696
|
const newLoadingKeys = new Set([...prevLoadingKeys]);
|
|
706
697
|
newLoadingKeys.delete(key);
|
package/treeSelect/foundation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNumber, isFunction, get, isUndefined, isString,
|
|
1
|
+
import { isNumber, isFunction, get, isUndefined, isString, isEmpty, difference } from 'lodash';
|
|
2
2
|
import { strings } from '../treeSelect/constants';
|
|
3
3
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
4
4
|
import {
|
|
@@ -306,14 +306,6 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
306
306
|
}
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
getCopyFromState(items: string | string[]) {
|
|
310
|
-
const res = {};
|
|
311
|
-
normalizedArr(items).forEach(key => {
|
|
312
|
-
res[key] = cloneDeep(this.getState(key));
|
|
313
|
-
});
|
|
314
|
-
return res as BasicTreeInnerData;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
309
|
getTreeNodeProps(key: string) {
|
|
318
310
|
const {
|
|
319
311
|
expandedKeys = new Set([]),
|
|
@@ -375,10 +367,8 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
375
367
|
return {};
|
|
376
368
|
}
|
|
377
369
|
loadData(data).then(() => {
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
loadingKeys: prevLoadingKeys
|
|
381
|
-
} = this.getCopyFromState(['loadedKeys', 'loadingKeys']);
|
|
370
|
+
const prevLoadedKeys = new Set(this.getState('loadedKeys')) as Set<string>;
|
|
371
|
+
const prevLoadingKeys = new Set(this.getState('loadingKeys')) as Set<string>;
|
|
382
372
|
const newLoadedKeys: Set<string> = prevLoadedKeys.add(key);
|
|
383
373
|
const newLoadingKeys: Set<string> = new Set([...prevLoadingKeys]);
|
|
384
374
|
newLoadingKeys.delete(key);
|
|
@@ -665,7 +655,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
665
655
|
}
|
|
666
656
|
|
|
667
657
|
handleSingleSelect(e: any, treeNode: BasicTreeNodeProps) {
|
|
668
|
-
let
|
|
658
|
+
let selectedKeys = [...this.getState('selectedKeys')];
|
|
669
659
|
const { clickToHide } = this.getProps();
|
|
670
660
|
const { selected, eventKey, data } = treeNode;
|
|
671
661
|
this._adapter.notifySelect(eventKey, true, data);
|
|
@@ -685,10 +675,8 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
685
675
|
|
|
686
676
|
calcCheckedKeys(eventKey: BasicTreeNodeProps['eventKey'], targetStatus: boolean) {
|
|
687
677
|
const { keyEntities } = this.getStates();
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
halfCheckedKeys
|
|
691
|
-
} = this.getCopyFromState(['checkedKeys', 'halfCheckedKeys']);
|
|
678
|
+
const checkedKeys = new Set(this.getState('checkedKeys')) as Set<string>;
|
|
679
|
+
const halfCheckedKeys = new Set(this.getState('halfCheckedKeys')) as Set<string>;
|
|
692
680
|
if (targetStatus) {
|
|
693
681
|
return calcCheckedKeysForChecked(eventKey, keyEntities, checkedKeys, halfCheckedKeys);
|
|
694
682
|
} else {
|
|
@@ -738,7 +726,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
738
726
|
|
|
739
727
|
calcNonDisabledCheckedKeys(eventKey: string, targetStatus: boolean) {
|
|
740
728
|
const { keyEntities, disabledKeys } = this.getStates();
|
|
741
|
-
const
|
|
729
|
+
const checkedKeys = new Set(this.getState('checkedKeys'));
|
|
742
730
|
const descendantKeys = normalizeKeyList(findDescendantKeys([eventKey], keyEntities, false), keyEntities, true);
|
|
743
731
|
const hasDisabled = descendantKeys.some(key => disabledKeys.has(key));
|
|
744
732
|
if (!hasDisabled) {
|
|
@@ -769,7 +757,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
769
757
|
const { treeData, filteredShownKeys, keyEntities, keyMaps } = this.getStates();
|
|
770
758
|
const showFilteredOnly = this._showFilteredOnly();
|
|
771
759
|
// clone otherwise will be modified unexpectedly
|
|
772
|
-
const
|
|
760
|
+
const filteredExpandedKeys = new Set(this.getState('filteredExpandedKeys')) as Set<string>;
|
|
773
761
|
let motionType = 'show';
|
|
774
762
|
const { eventKey, expanded, data } = treeNode;
|
|
775
763
|
|
|
@@ -821,7 +809,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
821
809
|
|
|
822
810
|
const { treeData } = this.getStates();
|
|
823
811
|
// clone otherwise will be modified unexpectedly
|
|
824
|
-
const
|
|
812
|
+
const expandedKeys = new Set(this.getState('expandedKeys')) as Set<string>;
|
|
825
813
|
let motionType = 'show';
|
|
826
814
|
const { eventKey, expanded, data } = treeNode;
|
|
827
815
|
if (!expanded) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MotionObject } from "./type";
|
|
2
|
-
import {
|
|
2
|
+
import { isObject } from 'lodash';
|
|
3
3
|
import warning from './warning';
|
|
4
|
+
import copy from "fast-copy";
|
|
4
5
|
|
|
5
6
|
export interface MergeMotionProps {
|
|
6
7
|
[x: string]: any;
|
|
@@ -37,7 +38,7 @@ export default function getMotionObjFromProps(props: MergeMotionProps) {
|
|
|
37
38
|
let motion: MotionObject = {};
|
|
38
39
|
|
|
39
40
|
if (isObject(motionProp)) {
|
|
40
|
-
motion =
|
|
41
|
+
motion = copy(motionProp);
|
|
41
42
|
for (const key of Object.keys(motionProp)) {
|
|
42
43
|
const handler = motionProp[key];
|
|
43
44
|
if (typeof handler === 'function') {
|