@douyinfe/semi-foundation 2.6.0 → 2.7.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/datePicker/_utils/formatter.ts +2 -2
- package/datePicker/_utils/getInsetInputFormatToken.ts +42 -0
- package/datePicker/_utils/getInsetInputValueFromInsetInputStr.ts +60 -0
- package/datePicker/constants.ts +2 -0
- package/datePicker/datePicker.scss +136 -3
- package/datePicker/foundation.ts +92 -15
- package/datePicker/inputFoundation.ts +133 -4
- package/datePicker/monthsGridFoundation.ts +4 -0
- package/datePicker/rtl.scss +8 -0
- package/datePicker/variables.scss +30 -0
- package/lib/cjs/datePicker/_utils/formatter.d.ts +2 -2
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +61 -0
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +76 -0
- package/lib/cjs/datePicker/constants.d.ts +2 -0
- package/lib/cjs/datePicker/constants.js +4 -3
- package/lib/cjs/datePicker/datePicker.css +104 -2
- package/lib/cjs/datePicker/datePicker.scss +136 -3
- package/lib/cjs/datePicker/foundation.d.ts +30 -7
- package/lib/cjs/datePicker/foundation.js +122 -9
- package/lib/cjs/datePicker/inputFoundation.d.ts +73 -3
- package/lib/cjs/datePicker/inputFoundation.js +196 -3
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/cjs/datePicker/monthsGridFoundation.js +4 -2
- package/lib/cjs/datePicker/rtl.scss +8 -0
- package/lib/cjs/datePicker/variables.scss +30 -0
- package/lib/cjs/tooltip/foundation.js +8 -8
- package/lib/cjs/treeSelect/foundation.d.ts +3 -2
- package/lib/cjs/treeSelect/foundation.js +28 -15
- package/lib/es/datePicker/_utils/formatter.d.ts +2 -2
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.d.ts +20 -0
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +48 -0
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.d.ts +31 -0
- package/lib/es/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +66 -0
- package/lib/es/datePicker/constants.d.ts +2 -0
- package/lib/es/datePicker/constants.js +4 -3
- package/lib/es/datePicker/datePicker.css +104 -2
- package/lib/es/datePicker/datePicker.scss +136 -3
- package/lib/es/datePicker/foundation.d.ts +30 -7
- package/lib/es/datePicker/foundation.js +120 -9
- package/lib/es/datePicker/inputFoundation.d.ts +73 -3
- package/lib/es/datePicker/inputFoundation.js +192 -4
- package/lib/es/datePicker/monthsGridFoundation.d.ts +1 -0
- package/lib/es/datePicker/monthsGridFoundation.js +4 -2
- package/lib/es/datePicker/rtl.scss +8 -0
- package/lib/es/datePicker/variables.scss +30 -0
- package/lib/es/tooltip/foundation.js +8 -8
- package/lib/es/treeSelect/foundation.d.ts +3 -2
- package/lib/es/treeSelect/foundation.js +27 -15
- package/package.json +3 -3
- package/tooltip/foundation.ts +8 -8
- package/treeSelect/foundation.ts +26 -19
package/treeSelect/foundation.ts
CHANGED
|
@@ -91,7 +91,6 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
|
|
|
91
91
|
| 'treeNodeFilterProp'
|
|
92
92
|
| 'value'
|
|
93
93
|
| 'onExpand'
|
|
94
|
-
| 'onSearch'
|
|
95
94
|
| 'expandAll'
|
|
96
95
|
| 'disableStrictly'
|
|
97
96
|
| 'aria-label'
|
|
@@ -133,6 +132,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
|
|
|
133
132
|
getPopupContainer?: () => HTMLElement;
|
|
134
133
|
// triggerRender?: (props: BasicTriggerRenderProps) => any;
|
|
135
134
|
onBlur?: (e: any) => void;
|
|
135
|
+
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
136
136
|
onChange?: BasicOnChange;
|
|
137
137
|
onFocus?: (e: any) => void;
|
|
138
138
|
onVisibleChange?: (isVisible: boolean) => void;
|
|
@@ -175,7 +175,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
175
175
|
rePositionDropdown: () => void;
|
|
176
176
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
177
177
|
notifySelect: (selectedKeys: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
178
|
-
notifySearch: (input: string) => void;
|
|
178
|
+
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
179
179
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
180
180
|
openMenu: () => void;
|
|
181
181
|
closeMenu: (cb?: () => void) => void;
|
|
@@ -302,7 +302,9 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
302
302
|
const isSearching = Boolean(inputValue);
|
|
303
303
|
const treeNodeProps: BasicTreeNodeProps = {
|
|
304
304
|
eventKey: key,
|
|
305
|
-
expanded: isSearching
|
|
305
|
+
expanded: isSearching && !this._isExpandControlled()
|
|
306
|
+
? filteredExpandedKeys.has(key)
|
|
307
|
+
: expandedKeys.has(key),
|
|
306
308
|
selected: selectedKeys.includes(key),
|
|
307
309
|
checked: realChecked,
|
|
308
310
|
halfChecked: realHalfChecked,
|
|
@@ -515,14 +517,16 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
515
517
|
}
|
|
516
518
|
|
|
517
519
|
clearInput() {
|
|
518
|
-
const { expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
520
|
+
const { flattenNodes, expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
521
|
+
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
522
|
+
const isExpandControlled = this._isExpandControlled();
|
|
519
523
|
const expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
520
|
-
expandedOptsKeys.forEach(item =>
|
|
521
|
-
const
|
|
524
|
+
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
525
|
+
const newFlattenNodes = flattenTreeData(treeData, newExpandedKeys);
|
|
522
526
|
|
|
523
527
|
this._adapter.updateState({
|
|
524
|
-
expandedKeys,
|
|
525
|
-
flattenNodes,
|
|
528
|
+
expandedKeys: isExpandControlled ? expandedKeys : newExpandedKeys,
|
|
529
|
+
flattenNodes: isExpandControlled ? flattenNodes : newFlattenNodes,
|
|
526
530
|
inputValue: '',
|
|
527
531
|
motionKeys: new Set([]),
|
|
528
532
|
filteredKeys: new Set([]),
|
|
@@ -534,16 +538,17 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
534
538
|
handleInputChange(sugInput: string) {
|
|
535
539
|
// Input is used as controlled component
|
|
536
540
|
this._adapter.updateInputValue(sugInput);
|
|
537
|
-
const { expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
541
|
+
const { flattenNodes, expandedKeys, selectedKeys, keyEntities, treeData } = this.getStates();
|
|
538
542
|
const { showFilteredOnly, filterTreeNode, treeNodeFilterProp } = this.getProps();
|
|
543
|
+
const newExpandedKeys: Set<string> = new Set(expandedKeys);
|
|
539
544
|
let filteredOptsKeys: string[] = [];
|
|
540
545
|
let expandedOptsKeys = [];
|
|
541
|
-
let
|
|
546
|
+
let newFlattenNodes = [];
|
|
542
547
|
let filteredShownKeys = new Set([]);
|
|
543
548
|
if (!sugInput) {
|
|
544
549
|
expandedOptsKeys = findAncestorKeys(selectedKeys, keyEntities);
|
|
545
|
-
expandedOptsKeys.forEach(item =>
|
|
546
|
-
|
|
550
|
+
expandedOptsKeys.forEach(item => newExpandedKeys.add(item));
|
|
551
|
+
newFlattenNodes = flattenTreeData(treeData, newExpandedKeys);
|
|
547
552
|
} else {
|
|
548
553
|
filteredOptsKeys = Object.values(keyEntities)
|
|
549
554
|
.filter((item: BasicKeyEntity) => {
|
|
@@ -554,15 +559,16 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
554
559
|
expandedOptsKeys = findAncestorKeys(filteredOptsKeys, keyEntities, false);
|
|
555
560
|
const shownChildKeys = findDescendantKeys(filteredOptsKeys, keyEntities, true);
|
|
556
561
|
filteredShownKeys = new Set([...shownChildKeys, ...expandedOptsKeys]);
|
|
557
|
-
|
|
562
|
+
newFlattenNodes = flattenTreeData(treeData, new Set(expandedOptsKeys), showFilteredOnly && filteredShownKeys);
|
|
558
563
|
}
|
|
559
|
-
|
|
564
|
+
const newFilteredExpandedKeys = new Set(expandedOptsKeys);
|
|
565
|
+
this._adapter.notifySearch(sugInput, Array.from(newFilteredExpandedKeys));
|
|
560
566
|
this._adapter.updateState({
|
|
561
|
-
expandedKeys,
|
|
562
|
-
flattenNodes,
|
|
567
|
+
expandedKeys: this._isExpandControlled() ? expandedKeys : newExpandedKeys,
|
|
568
|
+
flattenNodes: this._isExpandControlled() ? flattenNodes : newFlattenNodes,
|
|
563
569
|
motionKeys: new Set([]),
|
|
564
570
|
filteredKeys: new Set(filteredOptsKeys),
|
|
565
|
-
filteredExpandedKeys:
|
|
571
|
+
filteredExpandedKeys: newFilteredExpandedKeys,
|
|
566
572
|
filteredShownKeys,
|
|
567
573
|
});
|
|
568
574
|
}
|
|
@@ -724,7 +730,8 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
724
730
|
return;
|
|
725
731
|
}
|
|
726
732
|
|
|
727
|
-
|
|
733
|
+
const isExpandControlled = this._isExpandControlled();
|
|
734
|
+
if (isSearching && !isExpandControlled) {
|
|
728
735
|
this.handleNodeExpandInSearch(e, treeNode);
|
|
729
736
|
return;
|
|
730
737
|
}
|
|
@@ -742,7 +749,7 @@ export default class TreeSelectFoundation<P = Record<string, any>, S = Record<st
|
|
|
742
749
|
}
|
|
743
750
|
this._adapter.cacheFlattenNodes(motionType === 'hide' && this._isAnimated());
|
|
744
751
|
|
|
745
|
-
if (!
|
|
752
|
+
if (!isExpandControlled) {
|
|
746
753
|
const flattenNodes = flattenTreeData(treeData, expandedKeys);
|
|
747
754
|
const motionKeys = this._isAnimated() ? getMotionKeys(eventKey, expandedKeys, keyEntities) : [];
|
|
748
755
|
const newState = {
|