@douyinfe/semi-foundation 2.4.1 → 2.5.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/cascader.scss +1 -0
- package/cascader/variables.scss +4 -2
- package/lib/cjs/autoComplete/constants.d.ts +1 -1
- package/lib/cjs/cascader/cascader.css +1 -0
- package/lib/cjs/cascader/cascader.scss +1 -0
- package/lib/cjs/cascader/variables.scss +4 -2
- package/lib/cjs/dropdown/constants.d.ts +1 -1
- package/lib/cjs/select/constants.d.ts +1 -1
- package/lib/cjs/select/optionFoundation.d.ts +1 -1
- package/lib/cjs/select/optionFoundation.js +3 -3
- package/lib/cjs/slider/foundation.js +2 -2
- package/lib/cjs/table/foundation.d.ts +2 -0
- package/lib/cjs/table/foundation.js +16 -4
- package/lib/cjs/tooltip/constants.d.ts +1 -1
- package/lib/cjs/tooltip/constants.js +1 -1
- package/lib/cjs/tooltip/foundation.js +65 -4
- package/lib/cjs/tree/foundation.d.ts +4 -1
- package/lib/cjs/tree/foundation.js +69 -20
- package/lib/cjs/treeSelect/foundation.d.ts +3 -3
- package/lib/cjs/treeSelect/foundation.js +103 -35
- package/lib/cjs/upload/upload.css +49 -27
- package/lib/cjs/upload/upload.scss +66 -41
- package/lib/cjs/upload/variables.scss +3 -1
- package/lib/es/autoComplete/constants.d.ts +1 -1
- package/lib/es/cascader/cascader.css +1 -0
- package/lib/es/cascader/cascader.scss +1 -0
- package/lib/es/cascader/variables.scss +4 -2
- package/lib/es/dropdown/constants.d.ts +1 -1
- package/lib/es/select/constants.d.ts +1 -1
- package/lib/es/select/optionFoundation.d.ts +1 -1
- package/lib/es/select/optionFoundation.js +3 -3
- package/lib/es/slider/foundation.js +2 -2
- package/lib/es/table/foundation.d.ts +2 -0
- package/lib/es/table/foundation.js +16 -4
- package/lib/es/tooltip/constants.d.ts +1 -1
- package/lib/es/tooltip/constants.js +1 -1
- package/lib/es/tooltip/foundation.js +65 -4
- package/lib/es/tree/foundation.d.ts +4 -1
- package/lib/es/tree/foundation.js +69 -20
- package/lib/es/treeSelect/foundation.d.ts +3 -3
- package/lib/es/treeSelect/foundation.js +102 -35
- package/lib/es/upload/upload.css +49 -27
- package/lib/es/upload/upload.scss +66 -41
- package/lib/es/upload/variables.scss +3 -1
- package/package.json +3 -3
- package/select/optionFoundation.ts +3 -3
- package/slider/foundation.ts +2 -2
- package/table/foundation.ts +23 -10
- package/tooltip/constants.ts +2 -0
- package/tooltip/foundation.ts +52 -4
- package/tree/foundation.ts +56 -17
- package/treeSelect/foundation.ts +89 -41
- package/upload/upload.scss +66 -41
- package/upload/variables.scss +3 -1
|
@@ -12,14 +12,14 @@ export default class OptionFoundation extends BaseFoundation {
|
|
|
12
12
|
destroy() {}
|
|
13
13
|
|
|
14
14
|
onOptionClick(option) {
|
|
15
|
-
const
|
|
15
|
+
const isDisabled = this._isDisabled();
|
|
16
16
|
|
|
17
|
-
if (!
|
|
17
|
+
if (!isDisabled) {
|
|
18
18
|
this._adapter.notifyClick(option);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
_isDisabled() {
|
|
23
23
|
return this.getProp('disabled');
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -147,7 +147,7 @@ export default class SliderFoundation extends BaseFoundation {
|
|
|
147
147
|
|
|
148
148
|
const scroll = node => regex.test(style(node, 'overflow') + style(node, 'overflow-y') + style(node, 'overflow-x'));
|
|
149
149
|
|
|
150
|
-
const scrollParent = node => !node || node === document.body ? document.body : scroll(node) ? node : scrollParent(node.parentNode);
|
|
150
|
+
const scrollParent = node => !node || node === document.body || !(node instanceof Element) ? document.body : scroll(node) ? node : scrollParent(node.parentNode);
|
|
151
151
|
|
|
152
152
|
return scrollParent(el);
|
|
153
153
|
};
|
|
@@ -271,7 +271,7 @@ export default class SliderFoundation extends BaseFoundation {
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
if (step !== 1) {
|
|
274
|
-
// Find nearest step point
|
|
274
|
+
// Find nearest step point
|
|
275
275
|
stepValue = Math.round(stepValue / step) * step;
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -8,6 +8,7 @@ export interface BaseColumnProps<RecordType> {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
colSpan?: number;
|
|
10
10
|
dataIndex?: string;
|
|
11
|
+
defaultFilteredValue?: any[];
|
|
11
12
|
defaultSortOrder?: BaseSortOrder;
|
|
12
13
|
filterChildrenRecord?: boolean;
|
|
13
14
|
filterDropdown?: any;
|
|
@@ -313,6 +314,7 @@ export interface BaseChangeInfoFilter<RecordType> {
|
|
|
313
314
|
filters?: BaseFilter[];
|
|
314
315
|
onFilter?: (filteredValue?: any, record?: RecordType) => boolean;
|
|
315
316
|
filteredValue?: any[];
|
|
317
|
+
defaultFilteredValue?: any[];
|
|
316
318
|
children?: BaseFilter[];
|
|
317
319
|
filterChildrenRecord?: boolean;
|
|
318
320
|
}
|
|
@@ -176,7 +176,17 @@ class TableFoundation extends BaseFoundation {
|
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
getFilteredSortedDataSource(dataSource, queries) {
|
|
179
|
-
const filteredDataSource = this.filterDataSource(dataSource, _filterInstanceProperty(queries).call(queries, query =>
|
|
179
|
+
const filteredDataSource = this.filterDataSource(dataSource, _filterInstanceProperty(queries).call(queries, query => {
|
|
180
|
+
/**
|
|
181
|
+
* 这里无需判断 filteredValue 是否为数组,初始化时它是 `undefined`,点击选择空时为 `[]`
|
|
182
|
+
* 初始化时我们应该用 `defaultFilteredValue`,点击后我们应该用 `filteredValue`
|
|
183
|
+
*
|
|
184
|
+
* There is no need to judge whether `filteredValue` is an array here, because it is `undefined` when initialized, and `[]` when you click to select empty
|
|
185
|
+
* When initializing we should use `defaultFilteredValue`, after clicking we should use `filteredValue`
|
|
186
|
+
*/
|
|
187
|
+
const currentFilteredValue = query.filteredValue ? query.filteredValue : query.defaultFilteredValue;
|
|
188
|
+
return _isFunction(query.onFilter) && _Array$isArray(query.filters) && query.filters.length && _Array$isArray(currentFilteredValue) && currentFilteredValue.length;
|
|
189
|
+
}));
|
|
180
190
|
const sortedDataSource = this.sortDataSource(filteredDataSource, _filterInstanceProperty(queries).call(queries, query => query && _isFunction(query.sorter)));
|
|
181
191
|
return sortedDataSource;
|
|
182
192
|
}
|
|
@@ -335,10 +345,12 @@ class TableFoundation extends BaseFoundation {
|
|
|
335
345
|
const {
|
|
336
346
|
onFilter,
|
|
337
347
|
filteredValue,
|
|
338
|
-
filterChildrenRecord
|
|
348
|
+
filterChildrenRecord,
|
|
349
|
+
defaultFilteredValue
|
|
339
350
|
} = filterObj;
|
|
351
|
+
const currentFilteredValue = _Array$isArray(filteredValue) ? filteredValue : defaultFilteredValue;
|
|
340
352
|
|
|
341
|
-
if (typeof onFilter === 'function' && _Array$isArray(
|
|
353
|
+
if (typeof onFilter === 'function' && _Array$isArray(currentFilteredValue) && currentFilteredValue.length) {
|
|
342
354
|
hasValidFilters = true;
|
|
343
355
|
|
|
344
356
|
if (filteredData === null) {
|
|
@@ -348,7 +360,7 @@ class TableFoundation extends BaseFoundation {
|
|
|
348
360
|
filteredData = new _Map();
|
|
349
361
|
}
|
|
350
362
|
|
|
351
|
-
_each(
|
|
363
|
+
_each(currentFilteredValue, value => {
|
|
352
364
|
_each(dataSource, record => {
|
|
353
365
|
const childrenRecords = _get(record, childrenRecordName);
|
|
354
366
|
|
|
@@ -2,7 +2,7 @@ declare const cssClasses: {
|
|
|
2
2
|
readonly PREFIX: "semi-tooltip";
|
|
3
3
|
};
|
|
4
4
|
declare const strings: {
|
|
5
|
-
readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver"];
|
|
5
|
+
readonly POSITION_SET: readonly ["top", "topLeft", "topRight", "left", "leftTop", "leftBottom", "right", "rightTop", "rightBottom", "bottom", "bottomLeft", "bottomRight", "leftTopOver", "rightTopOver", "leftBottomOver", "rightBottomOver"];
|
|
6
6
|
readonly TRIGGER_SET: readonly ["hover", "focus", "click", "custom"];
|
|
7
7
|
readonly STATUS_DISABLED: "disabled";
|
|
8
8
|
readonly STATUS_LOADING: "loading";
|
|
@@ -3,7 +3,7 @@ const cssClasses = {
|
|
|
3
3
|
PREFIX: "".concat(BASE_CLASS_PREFIX, "-tooltip")
|
|
4
4
|
};
|
|
5
5
|
const strings = {
|
|
6
|
-
POSITION_SET: ['top', 'topLeft', 'topRight', 'left', 'leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom', 'bottom', 'bottomLeft', 'bottomRight', 'leftTopOver', 'rightTopOver'],
|
|
6
|
+
POSITION_SET: ['top', 'topLeft', 'topRight', 'left', 'leftTop', 'leftBottom', 'right', 'rightTop', 'rightBottom', 'bottom', 'bottomLeft', 'bottomRight', 'leftTopOver', 'rightTopOver', 'leftBottomOver', 'rightBottomOver'],
|
|
7
7
|
TRIGGER_SET: ['hover', 'focus', 'click', 'custom'],
|
|
8
8
|
STATUS_DISABLED: 'disabled',
|
|
9
9
|
STATUS_LOADING: 'loading'
|
|
@@ -530,6 +530,19 @@ export default class Tooltip extends BaseFoundation {
|
|
|
530
530
|
translateX = -1;
|
|
531
531
|
break;
|
|
532
532
|
|
|
533
|
+
case 'leftBottomOver':
|
|
534
|
+
left = triggerRect.left;
|
|
535
|
+
top = triggerRect.bottom;
|
|
536
|
+
translateY = -1;
|
|
537
|
+
break;
|
|
538
|
+
|
|
539
|
+
case 'rightBottomOver':
|
|
540
|
+
left = triggerRect.right;
|
|
541
|
+
top = triggerRect.bottom;
|
|
542
|
+
translateX = -1;
|
|
543
|
+
translateY = -1;
|
|
544
|
+
break;
|
|
545
|
+
|
|
533
546
|
default:
|
|
534
547
|
break;
|
|
535
548
|
}
|
|
@@ -653,12 +666,16 @@ export default class Tooltip extends BaseFoundation {
|
|
|
653
666
|
|
|
654
667
|
const shouldReverseTop = clientTop < wrapperRect.height + spacing && restClientBottom > wrapperRect.height + spacing;
|
|
655
668
|
const shouldReverseLeft = clientLeft < wrapperRect.width + spacing && restClientRight > wrapperRect.width + spacing;
|
|
656
|
-
const
|
|
669
|
+
const shouldReverseBottom = restClientBottom < wrapperRect.height + spacing && clientTop > wrapperRect.height + spacing;
|
|
657
670
|
const shouldReverseRight = restClientRight < wrapperRect.width + spacing && clientLeft > wrapperRect.width + spacing;
|
|
671
|
+
const shouldReverseTopOver = restClientTop < wrapperRect.height + spacing && clientBottom > wrapperRect.height + spacing;
|
|
672
|
+
const shouldReverseBottomOver = clientBottom < wrapperRect.height + spacing && restClientTop > wrapperRect.height + spacing;
|
|
658
673
|
const shouldReverseTopSide = restClientTop < wrapperRect.height && clientBottom > wrapperRect.height;
|
|
659
674
|
const shouldReverseBottomSide = clientBottom < wrapperRect.height && restClientTop > wrapperRect.height;
|
|
660
675
|
const shouldReverseLeftSide = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
|
|
661
676
|
const shouldReverseRightSide = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
677
|
+
const shouldReverseLeftOver = restClientLeft < wrapperRect.width && clientRight > wrapperRect.width;
|
|
678
|
+
const shouldReverseRightOver = clientRight < wrapperRect.width && restClientLeft > wrapperRect.width;
|
|
662
679
|
|
|
663
680
|
switch (position) {
|
|
664
681
|
case 'top':
|
|
@@ -720,14 +737,14 @@ export default class Tooltip extends BaseFoundation {
|
|
|
720
737
|
break;
|
|
721
738
|
|
|
722
739
|
case 'bottom':
|
|
723
|
-
if (
|
|
740
|
+
if (shouldReverseBottom) {
|
|
724
741
|
position = this._reversePos(position, true);
|
|
725
742
|
}
|
|
726
743
|
|
|
727
744
|
break;
|
|
728
745
|
|
|
729
746
|
case 'bottomLeft':
|
|
730
|
-
if (
|
|
747
|
+
if (shouldReverseBottom) {
|
|
731
748
|
position = this._reversePos(position, true);
|
|
732
749
|
}
|
|
733
750
|
|
|
@@ -738,7 +755,7 @@ export default class Tooltip extends BaseFoundation {
|
|
|
738
755
|
break;
|
|
739
756
|
|
|
740
757
|
case 'bottomRight':
|
|
741
|
-
if (
|
|
758
|
+
if (shouldReverseBottom) {
|
|
742
759
|
position = this._reversePos(position, true);
|
|
743
760
|
}
|
|
744
761
|
|
|
@@ -777,6 +794,50 @@ export default class Tooltip extends BaseFoundation {
|
|
|
777
794
|
|
|
778
795
|
break;
|
|
779
796
|
|
|
797
|
+
case 'leftTopOver':
|
|
798
|
+
if (shouldReverseTopOver) {
|
|
799
|
+
position = this._reversePos(position, true);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (shouldReverseLeftOver) {
|
|
803
|
+
position = this._reversePos(position);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
break;
|
|
807
|
+
|
|
808
|
+
case 'leftBottomOver':
|
|
809
|
+
if (shouldReverseBottomOver) {
|
|
810
|
+
position = this._reversePos(position, true);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
if (shouldReverseLeftOver) {
|
|
814
|
+
position = this._reversePos(position);
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
break;
|
|
818
|
+
|
|
819
|
+
case 'rightTopOver':
|
|
820
|
+
if (shouldReverseTopOver) {
|
|
821
|
+
position = this._reversePos(position, true);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
if (shouldReverseRightOver) {
|
|
825
|
+
position = this._reversePos(position);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
break;
|
|
829
|
+
|
|
830
|
+
case 'rightBottomOver':
|
|
831
|
+
if (shouldReverseBottomOver) {
|
|
832
|
+
position = this._reversePos(position, true);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
if (shouldReverseRightOver) {
|
|
836
|
+
position = this._reversePos(position);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
break;
|
|
840
|
+
|
|
780
841
|
default:
|
|
781
842
|
break;
|
|
782
843
|
}
|
|
@@ -128,6 +128,7 @@ export interface Virtualize {
|
|
|
128
128
|
height?: number | string;
|
|
129
129
|
width?: number | string;
|
|
130
130
|
}
|
|
131
|
+
export declare type CheckRelation = 'related' | 'unRelated';
|
|
131
132
|
export interface BasicTreeProps {
|
|
132
133
|
autoExpandParent?: boolean;
|
|
133
134
|
autoExpandWhenDragEnter?: boolean;
|
|
@@ -183,6 +184,7 @@ export interface BasicTreeProps {
|
|
|
183
184
|
value?: BasicValue;
|
|
184
185
|
virtualize?: Virtualize;
|
|
185
186
|
icon?: any;
|
|
187
|
+
checkRelation?: CheckRelation;
|
|
186
188
|
'aria-label'?: string;
|
|
187
189
|
}
|
|
188
190
|
export interface BasicTreeInnerData {
|
|
@@ -193,6 +195,7 @@ export interface BasicTreeInnerData {
|
|
|
193
195
|
selectedKeys: string[];
|
|
194
196
|
checkedKeys: Set<string>;
|
|
195
197
|
halfCheckedKeys: Set<string>;
|
|
198
|
+
realCheckedKeys: Set<string>;
|
|
196
199
|
motionKeys: Set<string>;
|
|
197
200
|
motionType: string;
|
|
198
201
|
expandedKeys: Set<string>;
|
|
@@ -242,7 +245,7 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
242
245
|
getCopyFromState(items: string[] | string): Partial<BasicTreeInnerData>;
|
|
243
246
|
getTreeNodeProps(key: string): BasicTreeNodeProps;
|
|
244
247
|
notifyJsonChange(key: string[] | string, e: any): void;
|
|
245
|
-
notifyMultipleChange(key: string[]
|
|
248
|
+
notifyMultipleChange(key: string[], e: any): void;
|
|
246
249
|
notifyChange(key: string[] | string, e: any): void;
|
|
247
250
|
handleInputChange(sugInput: string): void;
|
|
248
251
|
handleNodeSelect(e: any, treeNode: BasicTreeNodeProps): void;
|
|
@@ -82,6 +82,7 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
82
82
|
selectedKeys = [],
|
|
83
83
|
checkedKeys = new _Set([]),
|
|
84
84
|
halfCheckedKeys = new _Set([]),
|
|
85
|
+
realCheckedKeys = new _Set([]),
|
|
85
86
|
keyEntities = {},
|
|
86
87
|
filteredKeys = new _Set([]),
|
|
87
88
|
inputValue = '',
|
|
@@ -91,13 +92,26 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
91
92
|
disabledKeys = new _Set([])
|
|
92
93
|
} = this.getStates();
|
|
93
94
|
const {
|
|
94
|
-
treeNodeFilterProp
|
|
95
|
+
treeNodeFilterProp,
|
|
96
|
+
checkRelation
|
|
95
97
|
} = this.getProps();
|
|
96
98
|
const entity = keyEntities[key];
|
|
97
99
|
const notExist = !entity;
|
|
98
100
|
|
|
99
101
|
if (notExist) {
|
|
100
102
|
return null;
|
|
103
|
+
} // if checkRelation is invalid, the checked status of node will be false
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
let realChecked = false;
|
|
107
|
+
let realHalfChecked = false;
|
|
108
|
+
|
|
109
|
+
if (checkRelation === 'related') {
|
|
110
|
+
realChecked = checkedKeys.has(key);
|
|
111
|
+
realHalfChecked = halfCheckedKeys.has(key);
|
|
112
|
+
} else if (checkRelation === 'unRelated') {
|
|
113
|
+
realChecked = realCheckedKeys.has(key);
|
|
114
|
+
realHalfChecked = false;
|
|
101
115
|
}
|
|
102
116
|
|
|
103
117
|
const isSearching = Boolean(inputValue);
|
|
@@ -105,8 +119,8 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
105
119
|
eventKey: key,
|
|
106
120
|
expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
|
|
107
121
|
selected: _includesInstanceProperty(selectedKeys).call(selectedKeys, key),
|
|
108
|
-
checked:
|
|
109
|
-
halfChecked:
|
|
122
|
+
checked: realChecked,
|
|
123
|
+
halfChecked: realHalfChecked,
|
|
110
124
|
pos: String(entity ? entity.pos : ''),
|
|
111
125
|
level: entity.level,
|
|
112
126
|
filtered: filteredKeys.has(key),
|
|
@@ -140,10 +154,17 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
140
154
|
keyEntities
|
|
141
155
|
} = this.getStates();
|
|
142
156
|
const {
|
|
143
|
-
leafOnly
|
|
157
|
+
leafOnly,
|
|
158
|
+
checkRelation
|
|
144
159
|
} = this.getProps();
|
|
145
160
|
let value;
|
|
146
|
-
|
|
161
|
+
let keyList = [];
|
|
162
|
+
|
|
163
|
+
if (checkRelation === 'related') {
|
|
164
|
+
keyList = normalizeKeyList(key, keyEntities, leafOnly);
|
|
165
|
+
} else if (checkRelation === 'unRelated') {
|
|
166
|
+
keyList = key;
|
|
167
|
+
}
|
|
147
168
|
|
|
148
169
|
if (this.getProp('onChangeWithObject')) {
|
|
149
170
|
value = _mapInstanceProperty(keyList).call(keyList, itemKey => keyEntities[itemKey].data);
|
|
@@ -358,30 +379,58 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
358
379
|
|
|
359
380
|
handleMultipleSelect(e, treeNode) {
|
|
360
381
|
const {
|
|
361
|
-
disableStrictly
|
|
362
|
-
|
|
382
|
+
disableStrictly,
|
|
383
|
+
checkRelation
|
|
384
|
+
} = this.getProps();
|
|
385
|
+
const {
|
|
386
|
+
realCheckedKeys
|
|
387
|
+
} = this.getStates(); // eventKey: The key value of the currently clicked node
|
|
363
388
|
|
|
364
389
|
const {
|
|
365
390
|
checked,
|
|
366
391
|
eventKey,
|
|
367
392
|
data
|
|
368
|
-
} = treeNode;
|
|
393
|
+
} = treeNode;
|
|
369
394
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
395
|
+
if (checkRelation === 'related') {
|
|
396
|
+
// Find the checked state of the current node
|
|
397
|
+
const targetStatus = disableStrictly ? this.calcChekcedStatus(!checked, eventKey) : !checked;
|
|
398
|
+
const {
|
|
399
|
+
checkedKeys,
|
|
400
|
+
halfCheckedKeys
|
|
401
|
+
} = disableStrictly ? this.calcNonDisabedCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
375
402
|
|
|
376
|
-
|
|
403
|
+
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
377
404
|
|
|
378
|
-
|
|
405
|
+
this.notifyChange([...checkedKeys], e);
|
|
379
406
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
407
|
+
if (!this._isControlledComponent()) {
|
|
408
|
+
this._adapter.updateState({
|
|
409
|
+
checkedKeys,
|
|
410
|
+
halfCheckedKeys
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
} else if (checkRelation === 'unRelated') {
|
|
414
|
+
const newRealCheckedKeys = new _Set(realCheckedKeys);
|
|
415
|
+
let targetStatus;
|
|
416
|
+
|
|
417
|
+
if (realCheckedKeys.has(eventKey)) {
|
|
418
|
+
newRealCheckedKeys.delete(eventKey);
|
|
419
|
+
targetStatus = false;
|
|
420
|
+
} else {
|
|
421
|
+
newRealCheckedKeys.add(eventKey);
|
|
422
|
+
targetStatus = true;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
426
|
+
|
|
427
|
+
this.notifyChange([...newRealCheckedKeys], e);
|
|
428
|
+
|
|
429
|
+
if (!this._isControlledComponent()) {
|
|
430
|
+
this._adapter.updateState({
|
|
431
|
+
realCheckedKeys: newRealCheckedKeys
|
|
432
|
+
});
|
|
433
|
+
}
|
|
385
434
|
}
|
|
386
435
|
}
|
|
387
436
|
|
|
@@ -27,7 +27,7 @@ export interface BasicOnChange {
|
|
|
27
27
|
(node: BasicTreeNodeData[] | BasicTreeNodeData, e: any): void;
|
|
28
28
|
(value: BasicTreeNodeData['value'] | Array<BasicTreeNodeData['value']>, node: BasicTreeNodeData[] | BasicTreeNodeData, e: any): void;
|
|
29
29
|
}
|
|
30
|
-
export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize' | 'renderFullLabel' | 'renderLabel' | 'autoExpandParent' | 'className' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'defaultValue' | 'disabled' | 'emptyContent' | 'expandAction' | 'expandedKeys' | 'filterTreeNode' | 'labelEllipsis' | 'leafOnly' | 'multiple' | 'onChangeWithObject' | 'showClear' | 'showFilteredOnly' | 'style' | 'treeData' | 'treeNodeFilterProp' | 'value' | 'onExpand' | 'onSearch' | 'expandAll' | 'disableStrictly' | 'aria-label'> {
|
|
30
|
+
export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize' | 'renderFullLabel' | 'renderLabel' | 'autoExpandParent' | 'className' | 'defaultExpandAll' | 'defaultExpandedKeys' | 'defaultValue' | 'disabled' | 'emptyContent' | 'expandAction' | 'expandedKeys' | 'filterTreeNode' | 'labelEllipsis' | 'leafOnly' | 'multiple' | 'onChangeWithObject' | 'showClear' | 'showFilteredOnly' | 'style' | 'treeData' | 'treeNodeFilterProp' | 'value' | 'onExpand' | 'onSearch' | 'expandAll' | 'disableStrictly' | 'aria-label' | 'checkRelation'> {
|
|
31
31
|
motion?: Motion;
|
|
32
32
|
mouseEnterDelay?: number;
|
|
33
33
|
mouseLeaveDelay?: number;
|
|
@@ -68,7 +68,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
|
|
|
68
68
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
69
69
|
onLoad?: (keys: Set<string>, data: BasicTreeNodeData) => void;
|
|
70
70
|
}
|
|
71
|
-
export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData, 'keyEntities' | 'treeData' | 'flattenNodes' | 'selectedKeys' | 'checkedKeys' | 'halfCheckedKeys' | 'motionKeys' | 'motionType' | 'expandedKeys' | 'filteredKeys' | 'filteredExpandedKeys' | 'filteredShownKeys' | 'cachedKeyValuePairs' | 'inputValue' | 'disabledKeys' | 'loadedKeys' | 'loadingKeys'> {
|
|
71
|
+
export interface BasicTreeSelectInnerData extends Pick<BasicTreeInnerData, 'keyEntities' | 'treeData' | 'flattenNodes' | 'selectedKeys' | 'checkedKeys' | 'halfCheckedKeys' | 'motionKeys' | 'motionType' | 'expandedKeys' | 'filteredKeys' | 'filteredExpandedKeys' | 'filteredShownKeys' | 'cachedKeyValuePairs' | 'inputValue' | 'disabledKeys' | 'loadedKeys' | 'loadingKeys' | 'realCheckedKeys'> {
|
|
72
72
|
inputTriggerFocus: boolean;
|
|
73
73
|
isOpen: boolean;
|
|
74
74
|
isInput: boolean;
|
|
@@ -82,7 +82,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
82
82
|
registerClickOutsideHandler: (cb: (e: any) => void) => void;
|
|
83
83
|
unregisterClickOutsideHandler: () => void;
|
|
84
84
|
rePositionDropdown: () => void;
|
|
85
|
-
updateState: (states:
|
|
85
|
+
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
86
86
|
notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
87
87
|
notifySearch: (input: string) => void;
|
|
88
88
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
@@ -124,6 +124,7 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
124
124
|
selectedKeys = [],
|
|
125
125
|
checkedKeys = new _Set([]),
|
|
126
126
|
halfCheckedKeys = new _Set([]),
|
|
127
|
+
realCheckedKeys = new _Set([]),
|
|
127
128
|
keyEntities = {},
|
|
128
129
|
filteredKeys = new _Set([]),
|
|
129
130
|
inputValue = '',
|
|
@@ -133,13 +134,26 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
133
134
|
disabledKeys = new _Set([])
|
|
134
135
|
} = this.getStates();
|
|
135
136
|
const {
|
|
136
|
-
treeNodeFilterProp
|
|
137
|
+
treeNodeFilterProp,
|
|
138
|
+
checkRelation
|
|
137
139
|
} = this.getProps();
|
|
138
140
|
const entity = keyEntities[key];
|
|
139
141
|
const notExist = !entity;
|
|
140
142
|
|
|
141
143
|
if (notExist) {
|
|
142
144
|
return null;
|
|
145
|
+
} // if checkRelation is invalid, the checked status of node will be false
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
let realChecked = false;
|
|
149
|
+
let realHalfChecked = false;
|
|
150
|
+
|
|
151
|
+
if (checkRelation === 'related') {
|
|
152
|
+
realChecked = checkedKeys.has(key);
|
|
153
|
+
realHalfChecked = halfCheckedKeys.has(key);
|
|
154
|
+
} else if (checkRelation === 'unRelated') {
|
|
155
|
+
realChecked = realCheckedKeys.has(key);
|
|
156
|
+
realHalfChecked = false;
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
const isSearching = Boolean(inputValue);
|
|
@@ -147,8 +161,8 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
147
161
|
eventKey: key,
|
|
148
162
|
expanded: isSearching ? filteredExpandedKeys.has(key) : expandedKeys.has(key),
|
|
149
163
|
selected: _includesInstanceProperty(selectedKeys).call(selectedKeys, key),
|
|
150
|
-
checked:
|
|
151
|
-
halfChecked:
|
|
164
|
+
checked: realChecked,
|
|
165
|
+
halfChecked: realHalfChecked,
|
|
152
166
|
pos: String(entity ? entity.pos : ''),
|
|
153
167
|
level: entity.level,
|
|
154
168
|
filtered: filteredKeys.has(key),
|
|
@@ -214,9 +228,16 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
214
228
|
keyEntities
|
|
215
229
|
} = this.getStates();
|
|
216
230
|
const {
|
|
217
|
-
leafOnly
|
|
231
|
+
leafOnly,
|
|
232
|
+
checkRelation
|
|
218
233
|
} = this.getProps();
|
|
219
|
-
|
|
234
|
+
let keyList = [];
|
|
235
|
+
|
|
236
|
+
if (checkRelation === 'related') {
|
|
237
|
+
keyList = normalizeKeyList(key, keyEntities, leafOnly);
|
|
238
|
+
} else if (checkRelation === 'unRelated') {
|
|
239
|
+
keyList = key;
|
|
240
|
+
}
|
|
220
241
|
|
|
221
242
|
const nodes = _mapInstanceProperty(keyList).call(keyList, i => keyEntities[i].data);
|
|
222
243
|
|
|
@@ -343,7 +364,8 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
343
364
|
this._adapter.updateState({
|
|
344
365
|
selectedKeys: [],
|
|
345
366
|
checkedKeys: new _Set(),
|
|
346
|
-
halfCheckedKeys: new _Set()
|
|
367
|
+
halfCheckedKeys: new _Set(),
|
|
368
|
+
realCheckedKeys: new _Set([])
|
|
347
369
|
});
|
|
348
370
|
} // When triggerSearch, clicking the clear button will trigger to clear Input
|
|
349
371
|
|
|
@@ -371,11 +393,13 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
371
393
|
|
|
372
394
|
removeTag(eventKey) {
|
|
373
395
|
const {
|
|
374
|
-
disableStrictly
|
|
396
|
+
disableStrictly,
|
|
397
|
+
checkRelation
|
|
375
398
|
} = this.getProps();
|
|
376
399
|
const {
|
|
377
400
|
keyEntities,
|
|
378
|
-
disabledKeys
|
|
401
|
+
disabledKeys,
|
|
402
|
+
realCheckedKeys
|
|
379
403
|
} = this.getStates();
|
|
380
404
|
const item = keyEntities[eventKey].data;
|
|
381
405
|
|
|
@@ -383,20 +407,35 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
383
407
|
return;
|
|
384
408
|
}
|
|
385
409
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
} = this.calcCheckedKeys(eventKey, false);
|
|
410
|
+
if (checkRelation === 'unRelated') {
|
|
411
|
+
const newRealCheckedKeys = new _Set(realCheckedKeys);
|
|
412
|
+
newRealCheckedKeys.delete(eventKey);
|
|
390
413
|
|
|
391
|
-
|
|
414
|
+
this._notifyChange([...newRealCheckedKeys], null);
|
|
392
415
|
|
|
393
|
-
|
|
394
|
-
|
|
416
|
+
if (!this._isControlledComponent()) {
|
|
417
|
+
this._adapter.updateState({
|
|
418
|
+
realCheckedKeys: newRealCheckedKeys
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
this._adapter.rePositionDropdown();
|
|
422
|
+
}
|
|
423
|
+
} else if (checkRelation === 'related') {
|
|
424
|
+
const {
|
|
395
425
|
checkedKeys,
|
|
396
426
|
halfCheckedKeys
|
|
397
|
-
});
|
|
427
|
+
} = this.calcCheckedKeys(eventKey, false);
|
|
398
428
|
|
|
399
|
-
this.
|
|
429
|
+
this._notifyChange([...checkedKeys], null);
|
|
430
|
+
|
|
431
|
+
if (!this._isControlledComponent()) {
|
|
432
|
+
this._adapter.updateState({
|
|
433
|
+
checkedKeys,
|
|
434
|
+
halfCheckedKeys
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
this._adapter.rePositionDropdown();
|
|
438
|
+
}
|
|
400
439
|
}
|
|
401
440
|
|
|
402
441
|
this._adapter.notifySelect(eventKey, false, item); // reposition dropdown when selected values change
|
|
@@ -547,39 +586,67 @@ export default class TreeSelectFoundation extends BaseFoundation {
|
|
|
547
586
|
handleMultipleSelect(e, treeNode) {
|
|
548
587
|
const {
|
|
549
588
|
searchPosition,
|
|
550
|
-
disableStrictly
|
|
589
|
+
disableStrictly,
|
|
590
|
+
checkRelation
|
|
551
591
|
} = this.getProps();
|
|
552
592
|
const {
|
|
553
|
-
inputValue
|
|
593
|
+
inputValue,
|
|
594
|
+
realCheckedKeys
|
|
554
595
|
} = this.getStates();
|
|
555
596
|
const {
|
|
556
597
|
checked,
|
|
557
598
|
eventKey,
|
|
558
599
|
data
|
|
559
600
|
} = treeNode;
|
|
560
|
-
const targetStatus = disableStrictly ? this.calcChekcedStatus(!checked, eventKey) : !checked;
|
|
561
|
-
const {
|
|
562
|
-
checkedKeys,
|
|
563
|
-
halfCheckedKeys
|
|
564
|
-
} = disableStrictly ? this.calcNonDisabedCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
565
601
|
|
|
566
|
-
|
|
602
|
+
if (checkRelation === 'related') {
|
|
603
|
+
const targetStatus = disableStrictly ? this.calcChekcedStatus(!checked, eventKey) : !checked;
|
|
604
|
+
const {
|
|
605
|
+
checkedKeys,
|
|
606
|
+
halfCheckedKeys
|
|
607
|
+
} = disableStrictly ? this.calcNonDisabedCheckedKeys(eventKey, targetStatus) : this.calcCheckedKeys(eventKey, targetStatus);
|
|
567
608
|
|
|
568
|
-
|
|
609
|
+
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
569
610
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
611
|
+
this._notifyChange([...checkedKeys], e);
|
|
612
|
+
|
|
613
|
+
if (!this._isControlledComponent()) {
|
|
614
|
+
this._adapter.updateState({
|
|
615
|
+
checkedKeys,
|
|
616
|
+
halfCheckedKeys
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
this._adapter.rePositionDropdown();
|
|
620
|
+
}
|
|
621
|
+
} else if (checkRelation === 'unRelated') {
|
|
622
|
+
const newRealCheckedKeys = new _Set(realCheckedKeys);
|
|
623
|
+
let targetStatus;
|
|
624
|
+
|
|
625
|
+
if (realCheckedKeys.has(eventKey)) {
|
|
626
|
+
newRealCheckedKeys.delete(eventKey);
|
|
627
|
+
targetStatus = false;
|
|
628
|
+
} else {
|
|
629
|
+
newRealCheckedKeys.add(eventKey);
|
|
630
|
+
targetStatus = true;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
this._adapter.notifySelect(eventKey, targetStatus, data);
|
|
634
|
+
|
|
635
|
+
this._notifyChange([...newRealCheckedKeys], e);
|
|
636
|
+
|
|
637
|
+
if (!this._isControlledComponent()) {
|
|
638
|
+
this._adapter.updateState({
|
|
639
|
+
realCheckedKeys: newRealCheckedKeys
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
this._adapter.rePositionDropdown();
|
|
643
|
+
}
|
|
574
644
|
}
|
|
575
645
|
|
|
576
|
-
if (
|
|
646
|
+
if (searchPosition === strings.SEARCH_POSITION_TRIGGER && inputValue !== '') {
|
|
577
647
|
this._adapter.updateState({
|
|
578
|
-
|
|
579
|
-
halfCheckedKeys
|
|
648
|
+
inputValue: ''
|
|
580
649
|
});
|
|
581
|
-
|
|
582
|
-
this._adapter.rePositionDropdown();
|
|
583
650
|
}
|
|
584
651
|
}
|
|
585
652
|
|