@douyinfe/semi-foundation 2.55.4 → 2.55.5
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/lib/cjs/slider/foundation.js +2 -1
- package/lib/cjs/tree/foundation.d.ts +5 -0
- package/lib/cjs/tree/foundation.js +44 -4
- package/lib/es/slider/foundation.js +2 -1
- package/lib/es/tree/foundation.d.ts +5 -0
- package/lib/es/tree/foundation.js +44 -4
- package/package.json +3 -3
- package/slider/foundation.ts +2 -1
- package/tree/foundation.ts +39 -4
|
@@ -458,7 +458,8 @@ class SliderFoundation extends _foundation.default {
|
|
|
458
458
|
this.onHandleLeave = () => {
|
|
459
459
|
// this._adapter.setEventDefault(e);
|
|
460
460
|
const disabled = this._adapter.getState('disabled');
|
|
461
|
-
|
|
461
|
+
const isDrag = this._adapter.getState('isDrag');
|
|
462
|
+
if (!disabled && !isDrag) {
|
|
462
463
|
this._adapter.onHandleLeave();
|
|
463
464
|
}
|
|
464
465
|
};
|
|
@@ -251,6 +251,11 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
251
251
|
_showFilteredOnly(): any;
|
|
252
252
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
253
253
|
notifyJsonChange(key: string[] | string, e: any): void;
|
|
254
|
+
constructDataForValue(value: string): {
|
|
255
|
+
[x: number]: string;
|
|
256
|
+
};
|
|
257
|
+
findDataForValue(findValue: string): any;
|
|
258
|
+
getDataForKeyNotInKeyEntities(value: string): any;
|
|
254
259
|
notifyMultipleChange(key: string[], e: any): void;
|
|
255
260
|
notifyChange(key: string[] | string, e: any): void;
|
|
256
261
|
handleInputChange(sugInput: string): void;
|
|
@@ -115,6 +115,45 @@ class TreeFoundation extends _foundation.default {
|
|
|
115
115
|
const value = (0, _pick2.default)(data, selectedPath);
|
|
116
116
|
this._adapter.notifyChange(value);
|
|
117
117
|
}
|
|
118
|
+
constructDataForValue(value) {
|
|
119
|
+
const {
|
|
120
|
+
keyMaps
|
|
121
|
+
} = this.getProps();
|
|
122
|
+
const keyName = (0, _get2.default)(keyMaps, 'key', 'key');
|
|
123
|
+
const labelName = (0, _get2.default)(keyMaps, 'label', 'label');
|
|
124
|
+
return {
|
|
125
|
+
[keyName]: value,
|
|
126
|
+
[labelName]: value
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
findDataForValue(findValue) {
|
|
130
|
+
const {
|
|
131
|
+
value,
|
|
132
|
+
defaultValue,
|
|
133
|
+
keyMaps
|
|
134
|
+
} = this.getProps();
|
|
135
|
+
const realValueName = (0, _get2.default)(keyMaps, 'value', 'value');
|
|
136
|
+
const realKeyName = (0, _get2.default)(keyMaps, 'key', 'key');
|
|
137
|
+
let valueArr = [];
|
|
138
|
+
if (value) {
|
|
139
|
+
valueArr = Array.isArray(value) ? value : [value];
|
|
140
|
+
} else if (defaultValue) {
|
|
141
|
+
valueArr = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
142
|
+
}
|
|
143
|
+
return valueArr.find(item => {
|
|
144
|
+
return item[realValueName] === findValue || item[realKeyName] === findValue;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
getDataForKeyNotInKeyEntities(value) {
|
|
148
|
+
const {
|
|
149
|
+
onChangeWithObject
|
|
150
|
+
} = this.getProps();
|
|
151
|
+
if (onChangeWithObject) {
|
|
152
|
+
return this.findDataForValue(value);
|
|
153
|
+
} else {
|
|
154
|
+
return this.constructDataForValue(value);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
118
157
|
notifyMultipleChange(key, e) {
|
|
119
158
|
const {
|
|
120
159
|
keyEntities
|
|
@@ -127,14 +166,15 @@ class TreeFoundation extends _foundation.default {
|
|
|
127
166
|
let value;
|
|
128
167
|
let keyList = [];
|
|
129
168
|
if (checkRelation === 'related') {
|
|
130
|
-
keyList = (0, _treeUtil.normalizeKeyList)(key, keyEntities, leafOnly);
|
|
169
|
+
keyList = (0, _treeUtil.normalizeKeyList)(key, keyEntities, leafOnly, true);
|
|
131
170
|
} else if (checkRelation === 'unRelated') {
|
|
132
171
|
keyList = key;
|
|
133
172
|
}
|
|
173
|
+
const nodes = keyList.map(key => keyEntities[key] ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key));
|
|
134
174
|
if (this.getProp('onChangeWithObject')) {
|
|
135
|
-
value =
|
|
175
|
+
value = nodes;
|
|
136
176
|
} else {
|
|
137
|
-
value = (0, _treeUtil.getValueOrKey)(
|
|
177
|
+
value = (0, _treeUtil.getValueOrKey)(nodes, keyMaps);
|
|
138
178
|
}
|
|
139
179
|
this._adapter.notifyChange(value);
|
|
140
180
|
}
|
|
@@ -293,7 +333,7 @@ class TreeFoundation extends _foundation.default {
|
|
|
293
333
|
return this.calcCheckedKeys(eventKey, targetStatus);
|
|
294
334
|
}
|
|
295
335
|
const nonDisabled = descendantKeys.filter(key => !disabledKeys.has(key));
|
|
296
|
-
const newCheckedKeys = targetStatus ? [...nonDisabled, ...checkedKeys] : (0, _difference2.default)((0, _treeUtil.normalizeKeyList)([...checkedKeys], keyEntities, true), nonDisabled);
|
|
336
|
+
const newCheckedKeys = targetStatus ? [...nonDisabled, ...checkedKeys] : (0, _difference2.default)((0, _treeUtil.normalizeKeyList)([...checkedKeys], keyEntities, true, true), nonDisabled);
|
|
297
337
|
return (0, _treeUtil.calcCheckedKeys)(newCheckedKeys, keyEntities);
|
|
298
338
|
}
|
|
299
339
|
/*
|
|
@@ -451,7 +451,8 @@ export default class SliderFoundation extends BaseFoundation {
|
|
|
451
451
|
this.onHandleLeave = () => {
|
|
452
452
|
// this._adapter.setEventDefault(e);
|
|
453
453
|
const disabled = this._adapter.getState('disabled');
|
|
454
|
-
|
|
454
|
+
const isDrag = this._adapter.getState('isDrag');
|
|
455
|
+
if (!disabled && !isDrag) {
|
|
455
456
|
this._adapter.onHandleLeave();
|
|
456
457
|
}
|
|
457
458
|
};
|
|
@@ -251,6 +251,11 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
251
251
|
_showFilteredOnly(): any;
|
|
252
252
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
253
253
|
notifyJsonChange(key: string[] | string, e: any): void;
|
|
254
|
+
constructDataForValue(value: string): {
|
|
255
|
+
[x: number]: string;
|
|
256
|
+
};
|
|
257
|
+
findDataForValue(findValue: string): any;
|
|
258
|
+
getDataForKeyNotInKeyEntities(value: string): any;
|
|
254
259
|
notifyMultipleChange(key: string[], e: any): void;
|
|
255
260
|
notifyChange(key: string[] | string, e: any): void;
|
|
256
261
|
handleInputChange(sugInput: string): void;
|
|
@@ -107,6 +107,45 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
107
107
|
const value = _pick(data, selectedPath);
|
|
108
108
|
this._adapter.notifyChange(value);
|
|
109
109
|
}
|
|
110
|
+
constructDataForValue(value) {
|
|
111
|
+
const {
|
|
112
|
+
keyMaps
|
|
113
|
+
} = this.getProps();
|
|
114
|
+
const keyName = _get(keyMaps, 'key', 'key');
|
|
115
|
+
const labelName = _get(keyMaps, 'label', 'label');
|
|
116
|
+
return {
|
|
117
|
+
[keyName]: value,
|
|
118
|
+
[labelName]: value
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
findDataForValue(findValue) {
|
|
122
|
+
const {
|
|
123
|
+
value,
|
|
124
|
+
defaultValue,
|
|
125
|
+
keyMaps
|
|
126
|
+
} = this.getProps();
|
|
127
|
+
const realValueName = _get(keyMaps, 'value', 'value');
|
|
128
|
+
const realKeyName = _get(keyMaps, 'key', 'key');
|
|
129
|
+
let valueArr = [];
|
|
130
|
+
if (value) {
|
|
131
|
+
valueArr = Array.isArray(value) ? value : [value];
|
|
132
|
+
} else if (defaultValue) {
|
|
133
|
+
valueArr = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
134
|
+
}
|
|
135
|
+
return valueArr.find(item => {
|
|
136
|
+
return item[realValueName] === findValue || item[realKeyName] === findValue;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
getDataForKeyNotInKeyEntities(value) {
|
|
140
|
+
const {
|
|
141
|
+
onChangeWithObject
|
|
142
|
+
} = this.getProps();
|
|
143
|
+
if (onChangeWithObject) {
|
|
144
|
+
return this.findDataForValue(value);
|
|
145
|
+
} else {
|
|
146
|
+
return this.constructDataForValue(value);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
110
149
|
notifyMultipleChange(key, e) {
|
|
111
150
|
const {
|
|
112
151
|
keyEntities
|
|
@@ -119,14 +158,15 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
119
158
|
let value;
|
|
120
159
|
let keyList = [];
|
|
121
160
|
if (checkRelation === 'related') {
|
|
122
|
-
keyList = normalizeKeyList(key, keyEntities, leafOnly);
|
|
161
|
+
keyList = normalizeKeyList(key, keyEntities, leafOnly, true);
|
|
123
162
|
} else if (checkRelation === 'unRelated') {
|
|
124
163
|
keyList = key;
|
|
125
164
|
}
|
|
165
|
+
const nodes = keyList.map(key => keyEntities[key] ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key));
|
|
126
166
|
if (this.getProp('onChangeWithObject')) {
|
|
127
|
-
value =
|
|
167
|
+
value = nodes;
|
|
128
168
|
} else {
|
|
129
|
-
value = getValueOrKey(
|
|
169
|
+
value = getValueOrKey(nodes, keyMaps);
|
|
130
170
|
}
|
|
131
171
|
this._adapter.notifyChange(value);
|
|
132
172
|
}
|
|
@@ -285,7 +325,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
285
325
|
return this.calcCheckedKeys(eventKey, targetStatus);
|
|
286
326
|
}
|
|
287
327
|
const nonDisabled = descendantKeys.filter(key => !disabledKeys.has(key));
|
|
288
|
-
const newCheckedKeys = targetStatus ? [...nonDisabled, ...checkedKeys] : _difference(normalizeKeyList([...checkedKeys], keyEntities, true), nonDisabled);
|
|
328
|
+
const newCheckedKeys = targetStatus ? [...nonDisabled, ...checkedKeys] : _difference(normalizeKeyList([...checkedKeys], keyEntities, true, true), nonDisabled);
|
|
289
329
|
return calcCheckedKeys(newCheckedKeys, keyEntities);
|
|
290
330
|
}
|
|
291
331
|
/*
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.55.
|
|
3
|
+
"version": "2.55.5",
|
|
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.55.
|
|
10
|
+
"@douyinfe/semi-animation": "2.55.5",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"*.scss",
|
|
25
25
|
"*.css"
|
|
26
26
|
],
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "4b283dae2b36fe704607cd2a8c367a36950a759d",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
30
30
|
"@babel/preset-env": "^7.15.8",
|
package/slider/foundation.ts
CHANGED
|
@@ -550,7 +550,8 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
|
|
|
550
550
|
onHandleLeave = () => {
|
|
551
551
|
// this._adapter.setEventDefault(e);
|
|
552
552
|
const disabled = this._adapter.getState('disabled');
|
|
553
|
-
|
|
553
|
+
const isDrag = this._adapter.getState('isDrag');
|
|
554
|
+
if (!disabled && !isDrag) {
|
|
554
555
|
this._adapter.onHandleLeave();
|
|
555
556
|
}
|
|
556
557
|
};
|
package/tree/foundation.ts
CHANGED
|
@@ -420,20 +420,55 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
420
420
|
this._adapter.notifyChange(value as BasicValue);
|
|
421
421
|
}
|
|
422
422
|
|
|
423
|
+
constructDataForValue(value: string) {
|
|
424
|
+
const { keyMaps } = this.getProps();
|
|
425
|
+
const keyName = get(keyMaps, 'key', 'key');
|
|
426
|
+
const labelName = get(keyMaps, 'label', 'label');
|
|
427
|
+
return {
|
|
428
|
+
[keyName]: value,
|
|
429
|
+
[labelName]: value
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
findDataForValue(findValue: string) {
|
|
434
|
+
const { value, defaultValue, keyMaps } = this.getProps();
|
|
435
|
+
const realValueName = get(keyMaps, 'value', 'value');
|
|
436
|
+
const realKeyName = get(keyMaps, 'key', 'key');
|
|
437
|
+
let valueArr = [];
|
|
438
|
+
if (value) {
|
|
439
|
+
valueArr = Array.isArray(value) ? value : [value];
|
|
440
|
+
} else if (defaultValue) {
|
|
441
|
+
valueArr = Array.isArray(defaultValue) ? defaultValue : [defaultValue];
|
|
442
|
+
}
|
|
443
|
+
return valueArr.find(item => {
|
|
444
|
+
return item[realValueName] === findValue || item[realKeyName] === findValue;
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
getDataForKeyNotInKeyEntities(value: string) {
|
|
449
|
+
const { onChangeWithObject } = this.getProps();
|
|
450
|
+
if (onChangeWithObject) {
|
|
451
|
+
return this.findDataForValue(value);
|
|
452
|
+
} else {
|
|
453
|
+
return this.constructDataForValue(value);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
423
457
|
notifyMultipleChange(key: string[], e: any) {
|
|
424
458
|
const { keyEntities } = this.getStates();
|
|
425
459
|
const { leafOnly, checkRelation, keyMaps } = this.getProps();
|
|
426
460
|
let value;
|
|
427
461
|
let keyList = [];
|
|
428
462
|
if (checkRelation === 'related') {
|
|
429
|
-
keyList = normalizeKeyList(key, keyEntities, leafOnly);
|
|
463
|
+
keyList = normalizeKeyList(key, keyEntities, leafOnly, true);
|
|
430
464
|
} else if (checkRelation === 'unRelated') {
|
|
431
465
|
keyList = key;
|
|
432
466
|
}
|
|
467
|
+
const nodes = keyList.map(key => keyEntities[key] ? keyEntities[key].data : this.getDataForKeyNotInKeyEntities(key));
|
|
433
468
|
if (this.getProp('onChangeWithObject')) {
|
|
434
|
-
value =
|
|
469
|
+
value = nodes;
|
|
435
470
|
} else {
|
|
436
|
-
value = getValueOrKey(
|
|
471
|
+
value = getValueOrKey(nodes, keyMaps);
|
|
437
472
|
}
|
|
438
473
|
this._adapter.notifyChange(value);
|
|
439
474
|
}
|
|
@@ -585,7 +620,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
585
620
|
const nonDisabled = descendantKeys.filter((key: string) => !disabledKeys.has(key));
|
|
586
621
|
const newCheckedKeys = targetStatus ?
|
|
587
622
|
[...nonDisabled, ...checkedKeys] :
|
|
588
|
-
difference(normalizeKeyList([...checkedKeys], keyEntities, true), nonDisabled);
|
|
623
|
+
difference(normalizeKeyList([...checkedKeys], keyEntities, true, true), nonDisabled);
|
|
589
624
|
return calcCheckedKeys(newCheckedKeys, keyEntities);
|
|
590
625
|
}
|
|
591
626
|
|